@nethru/ui 1.0.82 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/base/AddableFormList.js +56 -0
  2. package/base/Alert.js +27 -0
  3. package/base/Checkbox.js +20 -0
  4. package/base/CircularProgressButton.js +36 -0
  5. package/base/ColumnedSection.js +44 -0
  6. package/base/DropdownButton.js +74 -0
  7. package/base/MainHeader.js +56 -0
  8. package/base/MenuItem.js +92 -0
  9. package/base/PropertyTable.js +69 -0
  10. package/base/SearchTextField.js +44 -0
  11. package/base/SearchableSelect.js +64 -0
  12. package/base/Select.js +33 -0
  13. package/{dist → base}/Slider.js +12 -13
  14. package/base/Snackbar.js +33 -0
  15. package/base/Switch.js +20 -0
  16. package/base/assets/icons.js +390 -0
  17. package/base/assets/images.js +1 -0
  18. package/{dist → base}/colors/blue.js +3 -1
  19. package/{dist → base}/colors/blueGrey.js +1 -1
  20. package/base/datagrid/DataGrid.js +57 -0
  21. package/base/datagrid/Footer.js +51 -0
  22. package/base/datagrid/Pagination.js +24 -0
  23. package/base/dialog/AlertDialog.js +21 -0
  24. package/base/dialog/ConfirmDialog.js +29 -0
  25. package/base/dialog/Dialog.js +56 -0
  26. package/base/dialog/SimpleDialog.js +33 -0
  27. package/{dist → base}/error/Error.js +1 -2
  28. package/base/frame/AppBar.js +54 -0
  29. package/base/frame/Brand.js +36 -0
  30. package/base/frame/Frame.js +49 -0
  31. package/{dist → base/frame}/sidebar/MenuToggler.js +14 -3
  32. package/{dist → base/frame}/sidebar/PrimaryMenu.js +15 -20
  33. package/base/frame/sidebar/SecondaryMenu.js +41 -0
  34. package/{dist → base/frame}/sidebar/Sidebar.js +21 -10
  35. package/base/frame/sidebar/SidebarContext.js +74 -0
  36. package/base/frame/sidebar/css/primary.module.css +69 -0
  37. package/base/frame/sidebar/css/sidebar.module.css +63 -0
  38. package/base/index.js +33 -0
  39. package/{dist → base}/samples/menu.sample.json +2 -2
  40. package/base/styles/borderRadius.js +7 -0
  41. package/base/styles/createTheme.js +90 -0
  42. package/base/styles/globalStyles.js +47 -0
  43. package/base/styles/mui/alert.js +40 -0
  44. package/base/styles/mui/appBar.js +17 -0
  45. package/base/styles/mui/autocomplete.js +46 -0
  46. package/base/styles/mui/avatar.js +14 -0
  47. package/base/styles/mui/button.js +276 -0
  48. package/base/styles/mui/buttonBase.js +10 -0
  49. package/base/styles/mui/checkbox.js +37 -0
  50. package/base/styles/mui/chip.js +83 -0
  51. package/base/styles/mui/cssBaseline.js +12 -0
  52. package/base/styles/mui/dataGrid.js +101 -0
  53. package/base/styles/mui/dialog.js +13 -0
  54. package/base/styles/mui/dialogActions.js +8 -0
  55. package/base/styles/mui/dialogContent.js +10 -0
  56. package/base/styles/mui/dialogTitle.js +11 -0
  57. package/base/styles/mui/formControl.js +8 -0
  58. package/base/styles/mui/formControlLabel.js +9 -0
  59. package/base/styles/mui/formHelperText.js +10 -0
  60. package/base/styles/mui/grid.js +15 -0
  61. package/base/styles/mui/icon.js +12 -0
  62. package/base/styles/mui/iconButton.js +79 -0
  63. package/base/styles/mui/inputLabel.js +13 -0
  64. package/base/styles/mui/list.js +11 -0
  65. package/base/styles/mui/menuItem.js +83 -0
  66. package/base/styles/mui/outlinedInput.js +53 -0
  67. package/base/styles/mui/paginationItem.js +25 -0
  68. package/base/styles/mui/paper.js +8 -0
  69. package/base/styles/mui/popover.js +11 -0
  70. package/base/styles/mui/select.js +11 -0
  71. package/base/styles/mui/slider.js +15 -0
  72. package/base/styles/mui/snackbar.js +24 -0
  73. package/base/styles/mui/switch.js +33 -0
  74. package/base/styles/mui/tab.js +23 -0
  75. package/base/styles/mui/tablePagination.js +8 -0
  76. package/base/styles/mui/tabs.js +20 -0
  77. package/base/styles/mui/textField.js +11 -0
  78. package/base/styles/mui/toggleButton.js +96 -0
  79. package/base/styles/mui/tooltip.js +22 -0
  80. package/base/styles/palette.js +40 -0
  81. package/base/styles/shadow.js +8 -0
  82. package/base/styles/typography.js +131 -0
  83. package/package.json +6 -5
  84. package/dist/Accordion.js +0 -45
  85. package/dist/AccordionDetails.js +0 -19
  86. package/dist/AccordionSummary.js +0 -35
  87. package/dist/AlertDialog.js +0 -55
  88. package/dist/AppBar.js +0 -68
  89. package/dist/AppendableFormList.js +0 -56
  90. package/dist/AvatarDropdown.js +0 -80
  91. package/dist/Button.js +0 -61
  92. package/dist/Checkbox.js +0 -27
  93. package/dist/CircularProgress.js +0 -33
  94. package/dist/ColumnedSection.js +0 -64
  95. package/dist/ConfirmDialog.js +0 -65
  96. package/dist/DataGrid.js +0 -150
  97. package/dist/Dialog.js +0 -42
  98. package/dist/DropdownButton.js +0 -59
  99. package/dist/FormLabel.js +0 -23
  100. package/dist/Frame.js +0 -47
  101. package/dist/GroupSelect.js +0 -67
  102. package/dist/ListItem.js +0 -21
  103. package/dist/ListItemDivider.js +0 -15
  104. package/dist/ListItemGrid.js +0 -12
  105. package/dist/ListItemText.js +0 -44
  106. package/dist/MainHeader.js +0 -59
  107. package/dist/PropertyTable.js +0 -141
  108. package/dist/ReferenceChipList.js +0 -59
  109. package/dist/SearchTextField.js +0 -24
  110. package/dist/SearchableSelect.js +0 -41
  111. package/dist/Section.js +0 -22
  112. package/dist/Select.js +0 -48
  113. package/dist/ShadowedSection.js +0 -36
  114. package/dist/Snackbar.js +0 -51
  115. package/dist/StatusChip.js +0 -34
  116. package/dist/Switch.js +0 -37
  117. package/dist/TabbedSection.js +0 -37
  118. package/dist/Tabs.js +0 -38
  119. package/dist/TextField.js +0 -25
  120. package/dist/index.js +0 -44
  121. package/dist/samples/global.sample.css +0 -59
  122. package/dist/sidebar/MenuTree.js +0 -95
  123. package/dist/sidebar/MenuTreeGroup.js +0 -65
  124. package/dist/sidebar/SecondaryMenu.js +0 -36
  125. package/dist/sidebar/SidebarContext.js +0 -122
  126. package/dist/sidebar/css/primary.module.css +0 -80
  127. package/dist/sidebar/css/sidebar.module.css +0 -50
  128. package/dist/variables.js +0 -6
  129. /package/{dist → base}/colors/green.js +0 -0
  130. /package/{dist → base}/colors/grey.js +0 -0
  131. /package/{dist → base}/colors/index.js +0 -0
  132. /package/{dist → base}/colors/lime.js +0 -0
  133. /package/{dist → base}/colors/orange.js +0 -0
  134. /package/{dist → base}/colors/purple.js +0 -0
  135. /package/{dist → base}/colors/red.js +0 -0
  136. /package/{dist → base}/colors/yellow.js +0 -0
  137. /package/{dist → base}/editor/Editor.js +0 -0
  138. /package/{dist → base}/editor/nScript.js +0 -0
  139. /package/{dist → base}/editor/nScriptKeywords.js +0 -0
  140. /package/{dist → base}/error/HttpError.js +0 -0
@@ -1,34 +0,0 @@
1
- import { Chip } from "@mui/material";
2
- import CheckCircleIcon from "@mui/icons-material/CheckCircle";
3
- import ErrorIcon from "@mui/icons-material/Error";
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- export default function StatusChip({
6
- id,
7
- label,
8
- status,
9
- onOperate,
10
- sx,
11
- ...props
12
- }) {
13
- const styles = {
14
- '&': {
15
- bgcolor: status === 'normal' ? '#4caf50' : '#fff'
16
- },
17
- '.MuiSvgIcon-root.MuiChip-deleteIcon': {
18
- cursor: onOperate ? 'pointer' : 'default'
19
- }
20
- };
21
- return /*#__PURE__*/_jsx(Chip, {
22
- id: id,
23
- label: label,
24
- variant: status === 'normal' ? 'filled' : 'outlined',
25
- color: status === 'normal' ? 'success' : 'default',
26
- deleteIcon: status === 'normal' ? /*#__PURE__*/_jsx(CheckCircleIcon, {}) : /*#__PURE__*/_jsx(ErrorIcon, {}),
27
- onDelete: _ => onOperate && onOperate(id, status),
28
- sx: {
29
- ...sx,
30
- ...styles
31
- },
32
- ...props
33
- });
34
- }
package/dist/Switch.js DELETED
@@ -1,37 +0,0 @@
1
- import { FormControlLabel, Stack } from "@mui/material";
2
- import MuiSwitch from "@mui/material/Switch";
3
- import { jsx as _jsx } from "react/jsx-runtime";
4
- import { Fragment as _Fragment } from "react/jsx-runtime";
5
- import { jsxs as _jsxs } from "react/jsx-runtime";
6
- export default function Switch({
7
- label,
8
- labelPlacement = 'top',
9
- ...props
10
- }) {
11
- return /*#__PURE__*/_jsxs(_Fragment, {
12
- children: [label && /*#__PURE__*/_jsx(Stack, {
13
- direction: "row",
14
- alignItems: "center",
15
- sx: {
16
- '.MuiFormControlLabel-label': {
17
- color: '#666',
18
- fontSize: 11
19
- },
20
- '.MuiFormControlLabel-root': {
21
- ml: labelPlacement === 'start' ? '0px' : '-10px',
22
- mr: 0
23
- }
24
- },
25
- children: /*#__PURE__*/_jsx(FormControlLabel, {
26
- control: /*#__PURE__*/_jsx(MuiSwitch, {
27
- color: "primary",
28
- ...props
29
- }),
30
- label: label,
31
- labelPlacement: labelPlacement
32
- })
33
- }), !label && /*#__PURE__*/_jsx(MuiSwitch, {
34
- ...props
35
- })]
36
- });
37
- }
@@ -1,37 +0,0 @@
1
- import { Stack, Tab } from "@mui/material";
2
- import Tabs from "./Tabs";
3
- import Section from "./Section";
4
- import { jsx as _jsx } from "react/jsx-runtime";
5
- import { jsxs as _jsxs } from "react/jsx-runtime";
6
- export default function TabbedSection({
7
- orientation,
8
- labels = [],
9
- tabProps = {},
10
- sectionProps = {},
11
- children,
12
- ...props
13
- }) {
14
- const styles = {
15
- mt: 0,
16
- width: orientation === 'vertical' ? '100%' : 'unset'
17
- };
18
- return /*#__PURE__*/_jsxs(Stack, {
19
- direction: orientation === 'vertical' ? 'row' : 'column',
20
- children: [/*#__PURE__*/_jsx(Tabs, {
21
- orientation: orientation,
22
- ...props,
23
- children: labels.map((label, index) => /*#__PURE__*/_jsx(Tab, {
24
- label: label,
25
- wrapped: orientation === 'vertical',
26
- ...tabProps
27
- }, index))
28
- }), /*#__PURE__*/_jsx(Section, {
29
- sx: {
30
- ...styles,
31
- ...sectionProps.sx
32
- },
33
- ...sectionProps,
34
- children: children
35
- })]
36
- });
37
- }
package/dist/Tabs.js DELETED
@@ -1,38 +0,0 @@
1
- import React from "react";
2
- import MuiTabs from "@mui/material/Tabs";
3
- import { jsx as _jsx } from "react/jsx-runtime";
4
- import { Fragment as _Fragment } from "react/jsx-runtime";
5
- export default function Tabs({
6
- orientation,
7
- sx,
8
- ...props
9
- }) {
10
- const vertical = orientation === 'vertical';
11
- const styles = {
12
- ml: vertical ? 0 : 0.5,
13
- mr: vertical ? 0 : 0.5,
14
- mt: vertical ? 0.5 : 0,
15
- mb: vertical ? 0.5 : 0,
16
- '& .MuiButtonBase-root.MuiTab-root': {
17
- fontSize: '15px'
18
- },
19
- '&.MuiTabs-root.MuiTabs-vertical': {
20
- minWidth: '40px',
21
- maxWidth: '40px'
22
- },
23
- '&.MuiTabs-root.MuiTabs-vertical .MuiButtonBase-root.MuiTab-root': {
24
- minWidth: '40px',
25
- maxWidth: '40px'
26
- }
27
- };
28
- return /*#__PURE__*/_jsx(_Fragment, {
29
- children: /*#__PURE__*/_jsx(MuiTabs, {
30
- orientation: orientation,
31
- sx: {
32
- ...styles,
33
- ...sx
34
- },
35
- ...props
36
- })
37
- });
38
- }
package/dist/TextField.js DELETED
@@ -1,25 +0,0 @@
1
- import MuiTextField from "@mui/material/TextField";
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- import { Fragment as _Fragment } from "react/jsx-runtime";
4
- export default function TextField({
5
- width,
6
- fontSize,
7
- textAlign,
8
- inputProps,
9
- ...props
10
- }) {
11
- const styles = {
12
- fontSize: fontSize ? fontSize : 16,
13
- textAlign: textAlign ? textAlign : 'left',
14
- width
15
- };
16
- return /*#__PURE__*/_jsx(_Fragment, {
17
- children: /*#__PURE__*/_jsx(MuiTextField, {
18
- inputProps: {
19
- ...inputProps,
20
- style: styles
21
- },
22
- ...props
23
- })
24
- });
25
- }
package/dist/index.js DELETED
@@ -1,44 +0,0 @@
1
- import * as colors from './colors';
2
- export { colors };
3
- export { default as Accordion } from "./Accordion";
4
- export { default as AccordionDetails } from "./AccordionDetails";
5
- export { default as AccordionSummary } from "./AccordionSummary";
6
- export { default as AlertDialog } from "./AlertDialog";
7
- export { default as AppBar } from "./AppBar";
8
- export { default as AppendableFormList } from "./AppendableFormList";
9
- export { default as AvatarDropdown } from "./AvatarDropdown";
10
- export { default as Button } from "./Button";
11
- export { default as Checkbox } from "./Checkbox";
12
- export { default as CircularProgress } from "./CircularProgress";
13
- export { default as ColumnedSection } from "./ColumnedSection";
14
- export { default as ConfirmDialog } from "./ConfirmDialog";
15
- export { default as DataGrid } from "./DataGrid";
16
- export { default as Dialog } from "./Dialog";
17
- export { default as DropdownButton } from "./DropdownButton";
18
- export { default as Editor } from "./editor/Editor";
19
- export { default as FormLabel } from "./FormLabel";
20
- export { default as Frame } from "./Frame";
21
- export { default as GroupSelect } from "./GroupSelect";
22
- export { default as ListItem } from "./ListItem";
23
- export { default as ListItemDivider } from "./ListItemDivider";
24
- export { default as ListItemGrid } from "./ListItemGrid";
25
- export { default as ListItemText } from "./ListItemText";
26
- export { default as MainHeader } from "./MainHeader";
27
- export { default as PropertyTable } from "./PropertyTable";
28
- export { default as ReferenceChipList } from "./ReferenceChipList";
29
- export { default as SearchableSelect } from "./SearchableSelect";
30
- export { default as SearchTextField } from "./SearchTextField";
31
- export { default as Section } from "./Section";
32
- export { default as Select } from "./Select";
33
- export { default as ShadowedSection } from "./ShadowedSection";
34
- export { default as Slider } from "./Slider";
35
- export { default as Snackbar } from "./Snackbar";
36
- export { default as StatusChip } from "./StatusChip";
37
- export { default as Switch } from "./Switch";
38
- export { default as TabbedSection } from "./TabbedSection";
39
- export { default as Tabs } from "./Tabs";
40
- export { default as TextField } from "./TextField";
41
- export { default as Sidebar } from "./sidebar/Sidebar";
42
- export * from './sidebar/SidebarContext';
43
- export { default as Error } from "./error/Error";
44
- export { default as HttpError } from "./error/HttpError";
@@ -1,59 +0,0 @@
1
- /* variable */
2
- :root {
3
- --body-background-color: #f8f9fa;
4
- --gnb-height: 64px;
5
- --primary-menu-width: 56px;
6
- --secondary-menu-width: 256px;
7
- }
8
-
9
-
10
- /* global */
11
- html, body {
12
- margin: 0;
13
- height: 100%;
14
- }
15
-
16
- #root {
17
- display: flex;
18
- flex-direction: column;
19
- height: 100%;
20
- }
21
-
22
-
23
- /* margin */
24
- .ml-auto {
25
- margin-left: auto;
26
- }
27
- .mr-auto {
28
- margin-right: auto;
29
- }
30
- .mt-auto {
31
- margin-top: auto;
32
- }
33
- .mt-bottom {
34
- margin-bottom: auto;
35
- }
36
-
37
-
38
- /* Highchart */
39
- .highcharts-tooltip-box {
40
- fill-opacity: 0;
41
- }
42
-
43
- .highcharts-tooltip > span {
44
- background: #fff;
45
- border: 1px solid #ccc;
46
- border-radius: 3px;
47
- padding: 8px;
48
- }
49
-
50
-
51
- /* CodeMirror */
52
- .cm-theme-light {
53
- font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace;
54
- font-size: 14px;
55
- }
56
-
57
- .cm-editor, .cm-editor.cm-focused {
58
- outline: 1px solid #eaeaea;
59
- }
@@ -1,95 +0,0 @@
1
- import { useNavigate } from "react-router-dom";
2
- import { getMenuTreeStates, useSidebarContext } from "./SidebarContext";
3
- import { TreeItem, TreeView } from "@mui/x-tree-view";
4
- import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown';
5
- import ArrowRightIcon from '@mui/icons-material/ArrowRight';
6
- import { jsx as _jsx } from "react/jsx-runtime";
7
- const HAS_CHILDREN = "has-children";
8
- export default function MenuTree({
9
- id,
10
- data
11
- }) {
12
- const styles = {
13
- paddingRight: '18px',
14
- '.MuiTreeItem-content': {
15
- padding: '7px 8px'
16
- },
17
- '.MuiTreeItem-content.Mui-selected': {
18
- backgroundColor: 'rgba(25, 118, 210, 0.2)'
19
- },
20
- '.MuiTreeItem-content .MuiTreeItem-label': {
21
- fontSize: '0.9rem'
22
- },
23
- 'li.has-children > .MuiTreeItem-content': {
24
- backgroundColor: 'transparent'
25
- }
26
- };
27
- const navigate = useNavigate();
28
- const {
29
- states,
30
- dispatch
31
- } = useSidebarContext();
32
- const {
33
- expanded
34
- } = getMenuTreeStates(states, id);
35
- const handleSelect = (event, ids) => {
36
- dispatch({
37
- type: "treeItemSelected",
38
- id,
39
- ids,
40
- hasChildren: hasChildren(event.target)
41
- });
42
- const node = getNode(ids);
43
- if (node && node.href) navigate(node.href instanceof Array ? node.href[0] : node.href);
44
- };
45
- const handleToggle = (event, ids) => {
46
- dispatch({
47
- type: "treeItemExpanded",
48
- id,
49
- ids
50
- });
51
- };
52
- return /*#__PURE__*/_jsx(TreeView, {
53
- defaultCollapseIcon: /*#__PURE__*/_jsx(ArrowDropDownIcon, {}),
54
- defaultExpandIcon: /*#__PURE__*/_jsx(ArrowRightIcon, {}),
55
- sx: styles,
56
- selected: states.activeSecondaryItem || '',
57
- expanded: expanded,
58
- onNodeSelect: handleSelect,
59
- onNodeToggle: handleToggle,
60
- children: render(data)
61
- });
62
- function render(nodes) {
63
- return nodes ? nodes.map(node => /*#__PURE__*/_jsx(TreeItem, {
64
- nodeId: node.id,
65
- label: node.name,
66
- className: node.submenu.length > 0 ? HAS_CHILDREN : "",
67
- children: render(node.submenu)
68
- }, node.id)) : null;
69
- }
70
- function hasChildren(element) {
71
- const target = findTreeItemRoot(element);
72
- return target ? hasClass(target, HAS_CHILDREN) : false;
73
- }
74
- function findTreeItemRoot(element) {
75
- while (element) {
76
- if (hasClass(element, "MuiTreeItem-root")) break;
77
- element = element.parentElement;
78
- }
79
- return element;
80
- }
81
- function hasClass(element, className) {
82
- return [...element.classList].includes(className);
83
- }
84
- function getNode(id, nodes) {
85
- nodes = nodes || data;
86
- for (let node of nodes) {
87
- if (node.id === id) return node;
88
- if (node.submenu.length > 0) {
89
- const child = getNode(id, node.submenu);
90
- if (child) return child;
91
- }
92
- }
93
- return null;
94
- }
95
- }
@@ -1,65 +0,0 @@
1
- import { getMenuGroupStates, useSidebarContext } from './SidebarContext';
2
- import Accordion from '@mui/material/Accordion';
3
- import AccordionSummary from '@mui/material/AccordionSummary';
4
- import AccordionDetails from '@mui/material/AccordionDetails';
5
- import Typography from '@mui/material/Typography';
6
- import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
7
- import { variables } from '../variables';
8
- import { jsx as _jsx } from "react/jsx-runtime";
9
- import { jsxs as _jsxs } from "react/jsx-runtime";
10
- export default function MenuTreeGroup({
11
- id,
12
- title,
13
- children
14
- }) {
15
- const styles = {
16
- backgroundColor: variables.bodyBackgroundColor,
17
- boxShadow: 'none',
18
- '&:before': {
19
- display: 'none'
20
- },
21
- '&.Mui-expanded': {
22
- margin: 0
23
- },
24
- '.MuiSvgIcon-root': {
25
- width: '0.9em',
26
- height: '0.9em'
27
- },
28
- '.MuiAccordionSummary-root.Mui-expanded': {
29
- minHeight: '48px'
30
- },
31
- '.MuiAccordionSummary-content.Mui-expanded': {
32
- margin: 0
33
- },
34
- '.MuiAccordionDetails-root': {
35
- padding: '0 16px 0 8px'
36
- }
37
- };
38
- const {
39
- states,
40
- dispatch
41
- } = useSidebarContext();
42
- const expanded = getMenuGroupStates(states, id);
43
- const handleChange = (event, expanded) => {
44
- dispatch({
45
- type: "menuGroupExpanded",
46
- id,
47
- expanded
48
- });
49
- };
50
- return /*#__PURE__*/_jsxs(Accordion, {
51
- expanded: expanded,
52
- onChange: handleChange,
53
- square: true,
54
- sx: styles,
55
- children: [/*#__PURE__*/_jsx(AccordionSummary, {
56
- expandIcon: /*#__PURE__*/_jsx(ExpandMoreIcon, {}),
57
- children: /*#__PURE__*/_jsx(Typography, {
58
- variant: "body2",
59
- children: title
60
- })
61
- }), /*#__PURE__*/_jsx(AccordionDetails, {
62
- children: children
63
- })]
64
- });
65
- }
@@ -1,36 +0,0 @@
1
- import { Divider, Stack } from '@mui/material';
2
- import MenuTreeGroup from './MenuTreeGroup';
3
- import MenuTree from './MenuTree';
4
- import styles from './css/sidebar.module.css';
5
- import { jsx as _jsx } from "react/jsx-runtime";
6
- export default function SecondaryMenu({
7
- sections,
8
- closed
9
- }) {
10
- return /*#__PURE__*/_jsx(Stack, {
11
- className: `${styles.secondary} ${closed ? styles.closed : styles.opened}`,
12
- children: sections.map((section, index) => {
13
- let jsx = [];
14
- jsx.push(index > 0 ? /*#__PURE__*/_jsx(Divider, {
15
- sx: {
16
- ml: 2,
17
- mr: 2
18
- }
19
- }, `${section.id}_${index}`) : null);
20
- jsx.push(section.name ? /*#__PURE__*/_jsx(MenuTreeGroup, {
21
- id: section.id,
22
- title: section.name,
23
- children: /*#__PURE__*/_jsx(MenuTree, {
24
- id: section.id,
25
- data: section.menu
26
- })
27
- }, section.id) : /*#__PURE__*/_jsx("div", {
28
- children: /*#__PURE__*/_jsx(MenuTree, {
29
- id: section.id,
30
- data: section.menu
31
- })
32
- }, section.id));
33
- return jsx;
34
- })
35
- });
36
- }
@@ -1,122 +0,0 @@
1
- import { createContext, useContext, useReducer } from "react";
2
- import { produce } from "immer";
3
- import { jsx as _jsx } from "react/jsx-runtime";
4
- const SidebarContext = /*#__PURE__*/createContext();
5
- export function SidebarContextProvider({
6
- menu,
7
- icons,
8
- children
9
- }) {
10
- const [states, dispatch] = useReducer(reducer, initialStates);
11
- return /*#__PURE__*/_jsx(SidebarContext.Provider, {
12
- value: {
13
- menu,
14
- icons,
15
- states,
16
- dispatch
17
- },
18
- children: children
19
- });
20
- }
21
- export function useSidebarContext() {
22
- return useContext(SidebarContext);
23
- }
24
- export function getMenuGroupStates(states, id) {
25
- return states.menuGroupsExpanded[id] !== undefined ? states.menuGroupsExpanded[id] : true;
26
- }
27
- export function getMenuTreeStates(states, id) {
28
- return states.menuTrees[id] || emptyState();
29
- }
30
- function reducer(states, action) {
31
- const {
32
- id,
33
- type
34
- } = action;
35
- switch (type) {
36
- case 'secondaryMenuToggled':
37
- return produce(states, draft => {
38
- draft.menuClosed = !states.menuClosed;
39
- });
40
- case 'menuGroupExpanded':
41
- return produce(states, draft => {
42
- draft.menuGroupsExpanded[id] = action.expanded;
43
- });
44
- case 'treeItemSelected':
45
- return produce(states, draft => {
46
- for (const key in draft.menuTrees) {
47
- draft.menuTrees[key].selected = [];
48
- }
49
- if (!(id in draft.menuTrees)) draft.menuTrees[id] = emptyState();
50
- draft.menuTrees[id].selected = action.ids;
51
- });
52
- case 'treeItemExpanded':
53
- return produce(states, draft => {
54
- if (!(id in draft.menuTrees)) draft.menuTrees[id] = emptyState();
55
- draft.menuTrees[id].expanded = [...action.ids];
56
- });
57
- case 'updateActiveItems':
58
- return produce(states, draft => {
59
- updateActiveItems(draft, action.menu, action.href);
60
- });
61
- default:
62
- throw new Error(`Undefined Sidebar Action Type: ${JSON.stringify(action)}`);
63
- }
64
- }
65
- function emptyState() {
66
- return {
67
- selected: [],
68
- expanded: []
69
- };
70
- }
71
- const initialStates = {
72
- activePrimaryItem: undefined,
73
- activeSecondaryItem: undefined,
74
- menuClosed: false,
75
- menuGroupsExpanded: {},
76
- menuTrees: {}
77
- };
78
- function updateActiveItems(draft, menu, href) {
79
- draft.activePrimaryItem = undefined;
80
- draft.activeSecondaryItem = undefined;
81
- for (let item of menu) {
82
- if (item.href === href) {
83
- draft.activePrimaryItem = item.id;
84
- return;
85
- }
86
- if (updateActiveSection(item.sections)) {
87
- draft.activePrimaryItem = item.id;
88
- return;
89
- }
90
- }
91
- function updateActiveSection(sections) {
92
- if (!sections) return;
93
- for (let section of sections) {
94
- if (startsWith(section.href)) {
95
- draft.activeSecondaryItem = section.id;
96
- return true;
97
- }
98
- if (updateActiveSubmenuItems(section.id, section.menu)) {
99
- draft.menuGroupsExpanded[section.id] = true;
100
- return true;
101
- }
102
- }
103
- }
104
- function updateActiveSubmenuItems(id, submenu) {
105
- if (!submenu) return;
106
- for (let item of submenu) {
107
- if (startsWith(item.href)) {
108
- if (!(id in draft.menuTrees)) draft.menuTrees[id] = emptyState();
109
- draft.activeSecondaryItem = item.id;
110
- return true;
111
- }
112
- if (updateActiveSubmenuItems(id, item.submenu)) {
113
- draft.menuTrees[id].expanded.push(item.id);
114
- return true;
115
- }
116
- }
117
- }
118
- function startsWith(hrefs) {
119
- const menuHrefs = hrefs instanceof Array ? hrefs : [hrefs];
120
- return menuHrefs.some(menuHref => href.startsWith(menuHref));
121
- }
122
- }
@@ -1,80 +0,0 @@
1
- .container {
2
- display: flex;
3
- flex-direction: column;
4
- position: absolute;
5
- width: var(--primary-menu-width);
6
- height: 100%;
7
- border-right: 1px solid #dee2e6;
8
- z-index: 30;
9
- transition-property: width background-color;
10
- transition-duration: .2s;
11
- }
12
- .container:hover {
13
- width: 240px;
14
- background-color: #fff;
15
- box-shadow: 1px 1px 12px #dadce0;
16
- }
17
- .container a {
18
- text-decoration: none;
19
- cursor: pointer;
20
- }
21
- .container a:first-child {
22
- padding-top: 10px;
23
- }
24
- .container a:last-child {
25
- padding-bottom: 10px;
26
- }
27
-
28
- .nav-item {
29
- position: relative;
30
- display: flex;
31
- height: 48px;
32
- align-items: center;
33
- color: #495057;
34
- }
35
- .nav-item:hover {
36
- /*border-radius: 0 48px 48px 0;*/
37
- background-color: #e9ecef;
38
- }
39
- .nav-item.active {
40
- /*color: #fff;*/
41
- /*border-left: 5px solid #0d6efd;*/
42
- }
43
- .container:hover .nav-item.active {
44
- /*border-radius: 0 48px 48px 0;*/
45
- /*background-color: #0d6efd !important;*/
46
- }
47
-
48
- .highlight {
49
- position: absolute;
50
- left: 0px;
51
- width: 5px;
52
- height: 36px;
53
- z-index: 100;
54
- /*border-radius: 50%;*/
55
- background-color: #0d6efd;
56
- transition-property: height;
57
- transition-duration: .2s;
58
- }
59
- .container:hover .highlight {
60
- height: 48px;
61
- /*display: none;*/
62
- }
63
-
64
- .icon {
65
- margin: 4px 15px 0px 16px;
66
- }
67
- .icon > svg {
68
- width: 24px;
69
- height: 24px;
70
- }
71
-
72
- .text {
73
- font-size: .9rem;
74
- display: none;
75
- white-space: nowrap;
76
- overflow-x: hidden;
77
- }
78
- .container:hover .text {
79
- display: block;
80
- }