UNPKG

@tomino/dynamic-form-semantic-ui

Version:

Semantic UI form renderer based on dynamic form generation

43 lines 1.83 kB
import React from 'react'; import { Icon } from 'semantic-ui-react'; import { pointer } from '../common'; export const PanelExpander = ({ panelClass, storedName, panelConfig, panelIndex }) => { const [expanded, setExpanded] = React.useState(true); return (React.createElement("div", { className: pointer, onClick: () => { let elem = document.querySelector(panelClass + ' .Pane1'); let body = document.querySelector(panelClass + ` .Pane${panelIndex} .paneBody`); if (panelIndex === 1) { if (expanded) { elem.style.height = '40px'; body.style.height = '0px'; panelConfig[0] = false; } else { elem.style.height = panelConfig[1] ? (localStorage.getItem(storedName) || '280') + 'px' : 'calc(100% - 40px)'; body.style.height = 'inherit'; panelConfig[0] = true; } } else { if (expanded) { if (panelConfig[0]) { elem.style.height = 'calc(100% - 40px)'; } body.style.height = '0px'; panelConfig[1] = false; } else { if (panelConfig[0]) { elem.style.height = (localStorage.getItem(storedName) || '280') + 'px'; } body.style.height = 'inherit'; panelConfig[1] = true; } } setExpanded(!expanded); } }, React.createElement(Icon, { name: expanded ? 'caret down' : 'caret right' }))); }; //# sourceMappingURL=panel_expander.js.map