1 line
79 KiB
JSON
1 line
79 KiB
JSON
|
{"ast":null,"code":"import _slicedToArray from \"/Users/paolasanchez/Desktop/Pry4/Katoikia/katoikia-app/web-ui/sakai-react/node_modules/babel-preset-react-app/node_modules/@babel/runtime/helpers/esm/slicedToArray\";\n\nvar _this = this,\n _jsxFileName = \"/Users/paolasanchez/Desktop/Pry4/Katoikia/katoikia-app/web-ui/sakai-react/src/AppConfig.js\";\n\nimport React, { useCallback, useEffect, useRef, useState } from 'react';\nimport { RadioButton } from 'primereact/radiobutton';\nimport { InputSwitch } from 'primereact/inputswitch';\nimport classNames from 'classnames';\nimport { Button } from \"primereact/button\";\nexport var AppConfig = function AppConfig(props) {\n var _useState = useState(false),\n _useState2 = _slicedToArray(_useState, 2),\n active = _useState2[0],\n setActive = _useState2[1];\n\n var _useState3 = useState(14),\n _useState4 = _slicedToArray(_useState3, 2),\n scale = _useState4[0],\n setScale = _useState4[1];\n\n var _useState5 = useState([12, 13, 14, 15, 16]),\n _useState6 = _slicedToArray(_useState5, 1),\n scales = _useState6[0];\n\n var _useState7 = useState('lara-light-indigo'),\n _useState8 = _slicedToArray(_useState7, 2),\n theme = _useState8[0],\n setTheme = _useState8[1];\n\n var config = useRef(null);\n var outsideClickListener = useRef(null);\n var unbindOutsideClickListener = useCallback(function () {\n if (outsideClickListener.current) {\n document.removeEventListener('click', outsideClickListener.current);\n outsideClickListener.current = null;\n }\n }, []);\n var hideConfigurator = useCallback(function (event) {\n setActive(false);\n unbindOutsideClickListener();\n event.preventDefault();\n }, [unbindOutsideClickListener]);\n var bindOutsideClickListener = useCallback(function () {\n if (!outsideClickListener.current) {\n outsideClickListener.current = function (event) {\n if (active && isOutsideClicked(event)) {\n hideConfigurator(event);\n }\n };\n\n document.addEventListener('click', outsideClickListener.current);\n }\n }, [active, hideConfigurator]);\n useEffect(function () {\n if (active) {\n bindOutsideClickListener();\n } else {\n unbindOutsideClickListener();\n }\n }, [active, bindOutsideClickListener, unbindOutsideClickListener]);\n\n var isOutsideClicked = function isOutsideClicked(event) {\n return !(config.current.isSameNode(event.target) || config.current.contains(event.target));\n };\n\n var decrementScale = function decrementScale() {\n setScale(function (prevState) {\n return --prevState;\n });\n };\n\n var incrementScale = function incrementScale() {\n setScale(function (prevState) {\n return ++prevState;\n });\n };\n\n useEffect(function () {\n document.documentElement.style.fontSize = scale + 'px';\n }, [scale]);\n\n var toggleConfigurator = function toggleConfigurator(event) {\n setActive(function (prevState) {\n return !prevState;\n });\n };\n\n var configClassName = classNames('layout-config', {\n 'layout-config-active': active\n });\n var replaceLink = useCallback(function (linkElement, href, callback) {\n if (isIE()) {\n linkElement.setAttribute('href', href);\n\n if (callback) {\n callback();\n }\n } else {\n var id = linkElement.getAttribute('id');\n var cloneLinkElement = linkElement.cloneNode(true);\n cloneLinkElement.setAttribute('href', href);\n cloneLinkElement.setAttribute('id', id + '-clone');\n linkElement.parentNode.insertBefore(cloneLinkElement, linkElement.nextSibling);\n cloneLinkElement.addEventListener('load', function () {\n linkElement.remove();\n cloneLinkElement.setAttribute('id', id);\n\n if (callback) {\n callback();\n }\n });\n }\n }, []);\n useEffect(function () {\n var themeElement = document.getElementById('theme-link');\n var themeHref = 'assets/themes/' + theme + '/theme.css';\n replaceLink(themeElement, themeHref
|