@dartech/arsenal-ui 1.2.4 → 1.2.6

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 (271) hide show
  1. package/.babelrc +13 -0
  2. package/.eslintrc.json +22 -0
  3. package/{index.d.ts → index.ts} +5 -5
  4. package/jest.config.ts +11 -0
  5. package/package.json +3 -12
  6. package/project.json +94 -0
  7. package/rollup.config.js +146 -0
  8. package/src/assets/chevron_left_gray.svg +3 -0
  9. package/src/consts/index.ts +13 -0
  10. package/src/interfaces/common.ts +18 -0
  11. package/src/interfaces/definition.ts +143 -0
  12. package/src/interfaces/{index.d.ts → index.ts} +3 -3
  13. package/src/interfaces/ui.ts +80 -0
  14. package/src/lib/Alert/Alert.tsx +108 -0
  15. package/src/lib/Alert/index.ts +1 -0
  16. package/src/lib/Breadcrumbs/Breadcrumbs.styled.tsx +16 -0
  17. package/src/lib/Breadcrumbs/Breadcrumbs.tsx +40 -0
  18. package/src/lib/Breadcrumbs/{index.d.ts → index.ts} +1 -1
  19. package/src/lib/ContentLayout/ContentLayout.tsx +31 -0
  20. package/src/lib/ContentLayout/index.ts +1 -0
  21. package/src/lib/Definition/CreateDefinition/CreateDefinition.tsx +78 -0
  22. package/src/lib/Definition/CreateDefinition/{index.d.ts → index.ts} +1 -1
  23. package/src/lib/Definition/DefinitionFiller/DefinitionFiller.tsx +71 -0
  24. package/src/lib/Definition/DefinitionFiller/{index.d.ts → index.ts} +1 -1
  25. package/src/lib/Definition/DefinitionValueView/DefinitionValueView.tsx +54 -0
  26. package/src/lib/Definition/DefinitionValueView/PropertyDataView.tsx +67 -0
  27. package/src/lib/Definition/DefinitionValueView/{index.d.ts → index.ts} +1 -1
  28. package/src/lib/Definition/{index.d.ts → index.ts} +3 -3
  29. package/src/lib/Forms/BackButton.tsx +46 -0
  30. package/src/lib/Forms/ControlAceEditor.tsx +125 -0
  31. package/src/lib/Forms/ControlAutocomplete.tsx +145 -0
  32. package/src/lib/Forms/ControlCheckbox.tsx +113 -0
  33. package/src/lib/Forms/ControlDate.tsx +75 -0
  34. package/src/lib/Forms/ControlDateTime.tsx +77 -0
  35. package/src/lib/Forms/ControlDebouncedInput.tsx +80 -0
  36. package/src/lib/Forms/ControlInput.tsx +111 -0
  37. package/src/lib/Forms/ControlNumberInput.tsx +121 -0
  38. package/src/lib/Forms/ControlQueryAutocomplete.tsx +197 -0
  39. package/src/lib/Forms/ControlRadio.tsx +136 -0
  40. package/src/lib/Forms/ControlSelect.tsx +164 -0
  41. package/src/lib/Forms/ControlSwitch.tsx +71 -0
  42. package/src/lib/Forms/ControlTime.tsx +93 -0
  43. package/src/lib/Forms/CopyButton.tsx +46 -0
  44. package/src/lib/Forms/{index.d.ts → index.ts} +15 -15
  45. package/src/lib/Forms/useAutocomplete.tsx +47 -0
  46. package/src/lib/InfoItem/InfoItem.tsx +40 -0
  47. package/src/lib/InfoItem/{index.d.ts → index.ts} +1 -1
  48. package/src/lib/InfoItem/styles.ts +17 -0
  49. package/src/lib/JsonPathPicker/JsonPathPicker.tsx +73 -0
  50. package/src/lib/JsonPathPicker/PropertyStep.tsx +70 -0
  51. package/src/lib/JsonPathPicker/{index.d.ts → index.ts} +1 -1
  52. package/src/lib/JsonView/JsonView.tsx +41 -0
  53. package/src/lib/JsonView/{index.d.ts → index.ts} +1 -1
  54. package/src/lib/Loader/Loader.tsx +41 -0
  55. package/src/lib/Loader/{index.d.ts → index.ts} +1 -1
  56. package/src/lib/Modals/JsonModalView.tsx +53 -0
  57. package/src/lib/Modals/{index.d.ts → index.ts} +1 -1
  58. package/src/lib/Property/PropertyFiller/JsonEditor.tsx +58 -0
  59. package/src/lib/Property/PropertyFiller/MultiplePropertyFiller.tsx +129 -0
  60. package/src/lib/Property/PropertyFiller/MultiplePropertyWidget.tsx +85 -0
  61. package/src/lib/Property/PropertyFiller/PropertyFiller.tsx +199 -0
  62. package/src/lib/Property/PropertyFiller/{index.d.ts → index.ts} +2 -2
  63. package/src/lib/Property/PropertyFiller/usePropertyFiller.ts +72 -0
  64. package/src/lib/Property/PropertyFiller/useStyles.ts +12 -0
  65. package/src/lib/Property/PropertyValidator/NodeValidator.tsx +92 -0
  66. package/src/lib/Property/PropertyValidator/NodesList.tsx +26 -0
  67. package/src/lib/Property/PropertyValidator/NumericTypeValidator.tsx +59 -0
  68. package/src/lib/Property/PropertyValidator/PropertyValidator.tsx +42 -0
  69. package/src/lib/Property/PropertyValidator/PropertyValidatorContext.tsx +4 -0
  70. package/src/lib/Property/PropertyValidator/StringTypeValidator.tsx +36 -0
  71. package/src/lib/Property/PropertyValidator/ValidationNodeSelector.tsx +62 -0
  72. package/src/lib/Property/PropertyValidator/index.ts +1 -0
  73. package/src/lib/Property/PropertyValueField/BooleanValueField.tsx +49 -0
  74. package/src/lib/Property/PropertyValueField/DateTimeValueField.tsx +58 -0
  75. package/src/lib/Property/PropertyValueField/DateValueField.tsx +58 -0
  76. package/src/lib/Property/PropertyValueField/JsonValueField.tsx +65 -0
  77. package/src/lib/Property/PropertyValueField/PropertyValueField.tsx +49 -0
  78. package/src/lib/Property/PropertyValueField/StringValueField.tsx +50 -0
  79. package/src/lib/Property/PropertyValueField/TimeValueField.tsx +67 -0
  80. package/src/lib/Property/PropertyValueField/{index.d.ts → index.ts} +1 -1
  81. package/src/lib/Property/PropertyWidget/PropertyWidget.tsx +115 -0
  82. package/src/lib/Property/PropertyWidget/{index.d.ts → index.ts} +1 -1
  83. package/src/lib/Property/UpsertProperty/CreatePropertiesList.tsx +148 -0
  84. package/src/lib/Property/UpsertProperty/CreatePropertyFormFields.tsx +158 -0
  85. package/src/lib/Property/UpsertProperty/CustomPropertyField.tsx +40 -0
  86. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/BigDecimalPropertyFields.tsx +41 -0
  87. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/DateAdditionalFields.tsx +27 -0
  88. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityAdditionalFields.tsx +133 -0
  89. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityReferencePropertyFields.tsx +46 -0
  90. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/PropertyAdditionalFields.tsx +52 -0
  91. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/StringPropertyFields.tsx +103 -0
  92. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/{index.d.ts → index.ts} +1 -1
  93. package/src/lib/Property/UpsertProperty/{index.d.ts → index.ts} +2 -2
  94. package/src/lib/Property/UpsertProperty/useCustomFields.ts +22 -0
  95. package/src/lib/Property/ViewPropertiesList/ViewPropertiesList.tsx +37 -0
  96. package/src/lib/Property/ViewPropertiesList/{index.d.ts → index.ts} +1 -1
  97. package/src/lib/Property/ViewProperty/EntityPropertiesShortView.tsx +40 -0
  98. package/src/lib/Property/ViewProperty/EntityPropertiesView.tsx +48 -0
  99. package/src/lib/Property/ViewProperty/PropertyDataTable.tsx +148 -0
  100. package/src/lib/Property/ViewProperty/PropertyItem.tsx +43 -0
  101. package/src/lib/Property/ViewProperty/ViewProperty.tsx +52 -0
  102. package/src/lib/Property/ViewProperty/{index.d.ts → index.ts} +1 -1
  103. package/src/lib/Property/{index.d.ts → index.ts} +5 -5
  104. package/src/lib/Sidebar/Sidebar.styled.tsx +157 -0
  105. package/src/lib/Sidebar/Sidebar.tsx +27 -0
  106. package/src/lib/Sidebar/SidebarContext.tsx +37 -0
  107. package/src/lib/Sidebar/SidebarDrawer.tsx +50 -0
  108. package/src/lib/Sidebar/SidebarLink/MenuIcon.tsx +16 -0
  109. package/src/lib/Sidebar/SidebarLink/SidebarLink.tsx +54 -0
  110. package/src/lib/Sidebar/SidebarLink/SidebarLinkItem.tsx +54 -0
  111. package/src/lib/Sidebar/SidebarLink/SidebarNestedItem.tsx +62 -0
  112. package/src/lib/Sidebar/SidebarLink/{index.d.ts → index.ts} +2 -2
  113. package/src/lib/Sidebar/index.ts +2 -0
  114. package/src/lib/Status/Status.tsx +16 -0
  115. package/src/lib/Status/{index.d.ts → index.ts} +1 -1
  116. package/src/lib/Status/styles.ts +21 -0
  117. package/src/lib/StepperView/StepperView.tsx +73 -0
  118. package/src/lib/StepperView/{index.d.ts → index.ts} +1 -1
  119. package/src/lib/Table/DataGrid/JsonTypeCell.tsx +51 -0
  120. package/src/lib/Table/DataGrid/Table.tsx +117 -0
  121. package/src/lib/Table/DataGrid/TableAction.tsx +43 -0
  122. package/src/lib/Table/DataGrid/TableColumnMenu.tsx +12 -0
  123. package/src/lib/Table/DataGrid/TablePagination.tsx +42 -0
  124. package/src/lib/Table/DataGrid/index.ts +2 -0
  125. package/src/lib/Table/DataGrid/styles.ts +59 -0
  126. package/src/lib/Table/DataGrid/usePagination.ts +15 -0
  127. package/src/lib/Table/DataGrid/useTableQueryPagination.ts +47 -0
  128. package/src/lib/Table/DataGrid/useTableQuerySorting.ts +47 -0
  129. package/src/lib/Table/SimpleTable/SimpleTable.tsx +138 -0
  130. package/src/lib/Table/SimpleTable/TableActionCell.tsx +67 -0
  131. package/src/lib/Table/SimpleTable/index.ts +2 -0
  132. package/src/lib/Table/SimpleTable/useTablePagination.ts +54 -0
  133. package/src/lib/Table/SimpleTable/useTableSorting.ts +50 -0
  134. package/src/lib/Table/index.ts +2 -0
  135. package/src/lib/Tabs/RouteTabs.tsx +54 -0
  136. package/src/lib/Tabs/TabPanel.tsx +42 -0
  137. package/src/lib/Tabs/{index.d.ts → index.ts} +2 -2
  138. package/src/lib/{index.d.ts → index.ts} +16 -16
  139. package/src/theme/baseTheme.ts +128 -0
  140. package/src/theme/fonts.d.ts +2 -0
  141. package/src/theme/index.ts +126 -0
  142. package/src/theme/inputThemeOptions.ts +126 -0
  143. package/src/theme/stepperThemeOptions.ts +20 -0
  144. package/src/theme/tableThemeOptions.ts +50 -0
  145. package/src/theme/typographyThemeOptions.ts +32 -0
  146. package/src/utils/common.ts +73 -0
  147. package/src/utils/dem.ts +431 -0
  148. package/src/utils/hooks.ts +41 -0
  149. package/src/utils/{index.d.ts → index.ts} +5 -5
  150. package/src/utils/ui-utils.tsx +132 -0
  151. package/src/utils/validators.ts +14 -0
  152. package/tsconfig.json +25 -0
  153. package/tsconfig.lib.json +23 -0
  154. package/tsconfig.spec.json +20 -0
  155. package/index.js +0 -1
  156. package/src/consts/index.d.ts +0 -12
  157. package/src/interfaces/common.d.ts +0 -17
  158. package/src/interfaces/definition.d.ts +0 -107
  159. package/src/interfaces/ui.d.ts +0 -70
  160. package/src/lib/Alert/Alert.d.ts +0 -53
  161. package/src/lib/Alert/index.d.ts +0 -1
  162. package/src/lib/Breadcrumbs/Breadcrumbs.d.ts +0 -9
  163. package/src/lib/Breadcrumbs/Breadcrumbs.styled.d.ts +0 -2
  164. package/src/lib/ContentLayout/ContentLayout.d.ts +0 -9
  165. package/src/lib/ContentLayout/index.d.ts +0 -1
  166. package/src/lib/Definition/CreateDefinition/CreateDefinition.d.ts +0 -11
  167. package/src/lib/Definition/DefinitionFiller/DefinitionFiller.d.ts +0 -10
  168. package/src/lib/Definition/DefinitionValueView/DefinitionValueView.d.ts +0 -8
  169. package/src/lib/Definition/DefinitionValueView/PropertyDataView.d.ts +0 -9
  170. package/src/lib/Forms/BackButton.d.ts +0 -7
  171. package/src/lib/Forms/ControlAceEditor.d.ts +0 -24
  172. package/src/lib/Forms/ControlAutocomplete.d.ts +0 -69
  173. package/src/lib/Forms/ControlCheckbox.d.ts +0 -51
  174. package/src/lib/Forms/ControlDate.d.ts +0 -18
  175. package/src/lib/Forms/ControlDateTime.d.ts +0 -18
  176. package/src/lib/Forms/ControlDebouncedInput.d.ts +0 -4
  177. package/src/lib/Forms/ControlInput.d.ts +0 -59
  178. package/src/lib/Forms/ControlNumberInput.d.ts +0 -51
  179. package/src/lib/Forms/ControlQueryAutocomplete.d.ts +0 -16
  180. package/src/lib/Forms/ControlRadio.d.ts +0 -66
  181. package/src/lib/Forms/ControlSelect.d.ts +0 -67
  182. package/src/lib/Forms/ControlSwitch.d.ts +0 -19
  183. package/src/lib/Forms/ControlTime.d.ts +0 -18
  184. package/src/lib/Forms/CopyButton.d.ts +0 -20
  185. package/src/lib/Forms/useAutocomplete.d.ts +0 -10
  186. package/src/lib/InfoItem/InfoItem.d.ts +0 -10
  187. package/src/lib/InfoItem/styles.d.ts +0 -12
  188. package/src/lib/JsonPathPicker/JsonPathPicker.d.ts +0 -10
  189. package/src/lib/JsonPathPicker/PropertyStep.d.ts +0 -11
  190. package/src/lib/JsonView/JsonView.d.ts +0 -7
  191. package/src/lib/Loader/Loader.d.ts +0 -21
  192. package/src/lib/Modals/JsonModalView.d.ts +0 -10
  193. package/src/lib/Property/PropertyFiller/JsonEditor.d.ts +0 -10
  194. package/src/lib/Property/PropertyFiller/MultiplePropertyFiller.d.ts +0 -12
  195. package/src/lib/Property/PropertyFiller/MultiplePropertyWidget.d.ts +0 -11
  196. package/src/lib/Property/PropertyFiller/PropertyFiller.d.ts +0 -12
  197. package/src/lib/Property/PropertyFiller/usePropertyFiller.d.ts +0 -24
  198. package/src/lib/Property/PropertyFiller/useStyles.d.ts +0 -12
  199. package/src/lib/Property/PropertyValidator/NodeValidator.d.ts +0 -6
  200. package/src/lib/Property/PropertyValidator/NodesList.d.ts +0 -6
  201. package/src/lib/Property/PropertyValidator/NumericTypeValidator.d.ts +0 -8
  202. package/src/lib/Property/PropertyValidator/PropertyValidator.d.ts +0 -6
  203. package/src/lib/Property/PropertyValidator/PropertyValidatorContext.d.ts +0 -3
  204. package/src/lib/Property/PropertyValidator/StringTypeValidator.d.ts +0 -8
  205. package/src/lib/Property/PropertyValidator/ValidationNodeSelector.d.ts +0 -7
  206. package/src/lib/Property/PropertyValidator/index.d.ts +0 -1
  207. package/src/lib/Property/PropertyValueField/BooleanValueField.d.ts +0 -7
  208. package/src/lib/Property/PropertyValueField/DateTimeValueField.d.ts +0 -9
  209. package/src/lib/Property/PropertyValueField/DateValueField.d.ts +0 -9
  210. package/src/lib/Property/PropertyValueField/JsonValueField.d.ts +0 -10
  211. package/src/lib/Property/PropertyValueField/PropertyValueField.d.ts +0 -9
  212. package/src/lib/Property/PropertyValueField/StringValueField.d.ts +0 -9
  213. package/src/lib/Property/PropertyValueField/TimeValueField.d.ts +0 -9
  214. package/src/lib/Property/PropertyWidget/PropertyWidget.d.ts +0 -13
  215. package/src/lib/Property/UpsertProperty/CreatePropertiesList.d.ts +0 -13
  216. package/src/lib/Property/UpsertProperty/CreatePropertyFormFields.d.ts +0 -10
  217. package/src/lib/Property/UpsertProperty/CustomPropertyField.d.ts +0 -7
  218. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/BigDecimalPropertyFields.d.ts +0 -6
  219. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/DateAdditionalFields.d.ts +0 -7
  220. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityAdditionalFields.d.ts +0 -8
  221. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityReferencePropertyFields.d.ts +0 -6
  222. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/PropertyAdditionalFields.d.ts +0 -10
  223. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/StringPropertyFields.d.ts +0 -6
  224. package/src/lib/Property/UpsertProperty/useCustomFields.d.ts +0 -6
  225. package/src/lib/Property/ViewPropertiesList/ViewPropertiesList.d.ts +0 -8
  226. package/src/lib/Property/ViewProperty/EntityPropertiesShortView.d.ts +0 -7
  227. package/src/lib/Property/ViewProperty/EntityPropertiesView.d.ts +0 -8
  228. package/src/lib/Property/ViewProperty/PropertyDataTable.d.ts +0 -7
  229. package/src/lib/Property/ViewProperty/PropertyItem.d.ts +0 -9
  230. package/src/lib/Property/ViewProperty/ViewProperty.d.ts +0 -9
  231. package/src/lib/Sidebar/Sidebar.d.ts +0 -10
  232. package/src/lib/Sidebar/Sidebar.styled.d.ts +0 -117
  233. package/src/lib/Sidebar/SidebarContext.d.ts +0 -11
  234. package/src/lib/Sidebar/SidebarDrawer.d.ts +0 -9
  235. package/src/lib/Sidebar/SidebarLink/MenuIcon.d.ts +0 -7
  236. package/src/lib/Sidebar/SidebarLink/SidebarLink.d.ts +0 -7
  237. package/src/lib/Sidebar/SidebarLink/SidebarLinkItem.d.ts +0 -8
  238. package/src/lib/Sidebar/SidebarLink/SidebarNestedItem.d.ts +0 -10
  239. package/src/lib/Sidebar/index.d.ts +0 -2
  240. package/src/lib/Status/Status.d.ts +0 -8
  241. package/src/lib/Status/styles.d.ts +0 -12
  242. package/src/lib/StepperView/StepperView.d.ts +0 -11
  243. package/src/lib/Table/DataGrid/JsonTypeCell.d.ts +0 -7
  244. package/src/lib/Table/DataGrid/Table.d.ts +0 -49
  245. package/src/lib/Table/DataGrid/TableAction.d.ts +0 -13
  246. package/src/lib/Table/DataGrid/TableColumnMenu.d.ts +0 -3
  247. package/src/lib/Table/DataGrid/TablePagination.d.ts +0 -3
  248. package/src/lib/Table/DataGrid/index.d.ts +0 -2
  249. package/src/lib/Table/DataGrid/styles.d.ts +0 -12
  250. package/src/lib/Table/DataGrid/usePagination.d.ts +0 -5
  251. package/src/lib/Table/DataGrid/useTableQueryPagination.d.ts +0 -11
  252. package/src/lib/Table/DataGrid/useTableQuerySorting.d.ts +0 -6
  253. package/src/lib/Table/SimpleTable/SimpleTable.d.ts +0 -17
  254. package/src/lib/Table/SimpleTable/TableActionCell.d.ts +0 -10
  255. package/src/lib/Table/SimpleTable/index.d.ts +0 -2
  256. package/src/lib/Table/SimpleTable/useTablePagination.d.ts +0 -7
  257. package/src/lib/Table/SimpleTable/useTableSorting.d.ts +0 -6
  258. package/src/lib/Table/index.d.ts +0 -2
  259. package/src/lib/Tabs/RouteTabs.d.ts +0 -11
  260. package/src/lib/Tabs/TabPanel.d.ts +0 -25
  261. package/src/theme/baseTheme.d.ts +0 -2
  262. package/src/theme/index.d.ts +0 -1
  263. package/src/theme/inputThemeOptions.d.ts +0 -117
  264. package/src/theme/stepperThemeOptions.d.ts +0 -16
  265. package/src/theme/tableThemeOptions.d.ts +0 -47
  266. package/src/theme/typographyThemeOptions.d.ts +0 -29
  267. package/src/utils/common.d.ts +0 -7
  268. package/src/utils/dem.d.ts +0 -27
  269. package/src/utils/hooks.d.ts +0 -7
  270. package/src/utils/ui-utils.d.ts +0 -8
  271. package/src/utils/validators.d.ts +0 -5
@@ -0,0 +1,27 @@
1
+ import { ThemeProvider } from '@mui/material/styles';
2
+ import { SidebarContextProvider } from './SidebarContext';
3
+ import { theme as defaultTheme } from '@dartech/arsenal-ui';
4
+ import SidebarDrawer from './SidebarDrawer';
5
+ import type { Route } from '@dartech/arsenal-ui';
6
+
7
+ type Props = {
8
+ routes: Route[];
9
+ theme?: any;
10
+ title?: string;
11
+ id?: string;
12
+ };
13
+
14
+ export const Sidebar = ({
15
+ routes,
16
+ theme = defaultTheme,
17
+ title = '',
18
+ id
19
+ }: Props) => {
20
+ return (
21
+ <ThemeProvider theme={theme}>
22
+ <SidebarContextProvider>
23
+ <SidebarDrawer title={title} routes={routes} id={id} />
24
+ </SidebarContextProvider>
25
+ </ThemeProvider>
26
+ );
27
+ };
@@ -0,0 +1,37 @@
1
+ import { createContext, useCallback, useContext, useState } from 'react';
2
+
3
+ type SidebarContextProps = {
4
+ collapsed: boolean;
5
+ toggleCollapse: () => void;
6
+ };
7
+
8
+ export const SidebarContext = createContext<SidebarContextProps>({
9
+ collapsed: false,
10
+ toggleCollapse: () => {
11
+ console.log('collapse toggle');
12
+ },
13
+ });
14
+
15
+ export const useSidebarContext = () => useContext(SidebarContext);
16
+
17
+ export const SidebarContextProvider = ({ children }) => {
18
+ const [collapsed, setCollapsed] = useState(
19
+ localStorage.getItem('sidebar_collapsed') === 'true'
20
+ );
21
+
22
+ const toggleCollapse = useCallback(() => {
23
+ setCollapsed(!collapsed);
24
+ localStorage.setItem('sidebar_collapsed', `${!collapsed}`);
25
+ window.dispatchEvent(new CustomEvent('sidebar_collapsed', {
26
+ detail: {
27
+ collapsed: !collapsed
28
+ }
29
+ }))
30
+ }, [collapsed]);
31
+
32
+ return (
33
+ <SidebarContext.Provider value={{ collapsed, toggleCollapse }}>
34
+ {children}
35
+ </SidebarContext.Provider>
36
+ );
37
+ };
@@ -0,0 +1,50 @@
1
+ import SidebarLink from './SidebarLink';
2
+ import {
3
+ Container,
4
+ CollapseButton,
5
+ Drawer,
6
+ Header,
7
+ List,
8
+ } from './Sidebar.styled';
9
+ import ArrowIcon from '../../assets/chevron_left_gray.svg';
10
+ import classnames from 'classnames';
11
+ import type { Route } from '../../interfaces';
12
+ import { useSidebarContext } from './SidebarContext';
13
+
14
+ type Props = {
15
+ title?: string;
16
+ routes: Route[];
17
+ id?: string;
18
+ };
19
+
20
+ const SidebarDrawer = ({ title, routes, id }: Props) => {
21
+ const { collapsed, toggleCollapse } = useSidebarContext();
22
+
23
+ return (
24
+ <Container>
25
+ <CollapseButton
26
+ className={classnames('button-collapse', {
27
+ collapsed,
28
+ })}
29
+ onClick={toggleCollapse}
30
+ >
31
+ <img src={ArrowIcon} alt="collapse" />
32
+ </CollapseButton>
33
+ <Drawer
34
+ variant="permanent"
35
+ anchor="left"
36
+ className={classnames({ collapsed })}
37
+ id={id}
38
+ >
39
+ {!!title && <Header>{title}</Header>}
40
+ <List>
41
+ {routes.map((route, index) => (
42
+ <SidebarLink key={index} route={route} />
43
+ ))}
44
+ </List>
45
+ </Drawer>
46
+ </Container>
47
+ );
48
+ };
49
+
50
+ export default SidebarDrawer;
@@ -0,0 +1,16 @@
1
+ import Box from '@mui/material/Box';
2
+
3
+ type Props = {
4
+ src: string;
5
+ alt?: string;
6
+ }
7
+
8
+ export const MenuIcon = ({src, alt}: Props) => {
9
+ return (
10
+ <Box sx={{ width: 20, height: 20, display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
11
+ <img src={src} alt={alt} />
12
+ </Box>
13
+ )
14
+ }
15
+
16
+ export default MenuIcon
@@ -0,0 +1,54 @@
1
+ import Collapse from '@mui/material/Collapse';
2
+ import SidebarLinkItem from './SidebarLinkItem';
3
+ import SidebarNestedItem from './SidebarNestedItem';
4
+ import type { Route } from '../../../interfaces';
5
+ import { useEffect, useMemo, useState } from 'react';
6
+ import { useLocation } from 'react-router-dom';
7
+ import { ChildrenList } from '../Sidebar.styled';
8
+ import { useSidebarContext } from '../SidebarContext';
9
+
10
+ type Props = {
11
+ route: Route;
12
+ };
13
+
14
+ const SidebarLink = ({ route }: Props) => {
15
+ const location = useLocation();
16
+ const { collapsed } = useSidebarContext();
17
+
18
+ const [open, setOpen] = useState(false);
19
+
20
+ const isActive = useMemo(
21
+ () => !!route.link && location.pathname.startsWith(route.link),
22
+ [location.pathname, route]
23
+ );
24
+
25
+ const handleClick = () => {
26
+ setOpen(!open);
27
+ };
28
+
29
+ useEffect(() => {
30
+ setOpen(isActive);
31
+ }, [isActive]);
32
+
33
+ return route.children?.length && !collapsed ? (
34
+ <>
35
+ <SidebarNestedItem
36
+ route={route}
37
+ isActive={isActive}
38
+ handleClick={handleClick}
39
+ isListOpen={open || !route.link}
40
+ />
41
+ <Collapse in={open || !route.link} timeout="auto">
42
+ <ChildrenList>
43
+ {route.children?.map((childRoute, index) => (
44
+ <SidebarLink key={index} route={childRoute} />
45
+ ))}
46
+ </ChildrenList>
47
+ </Collapse>
48
+ </>
49
+ ) : (
50
+ <SidebarLinkItem route={route} isActive={isActive} />
51
+ );
52
+ };
53
+
54
+ export default SidebarLink;
@@ -0,0 +1,54 @@
1
+ import { Link as RouterLink } from 'react-router-dom';
2
+ import {
3
+ ListItem,
4
+ ListItemButton,
5
+ ListItemIcon,
6
+ ListSubheader,
7
+ ListItemText,
8
+ } from '../Sidebar.styled';
9
+ import classnames from 'classnames';
10
+ import type { Route } from '../../../interfaces';
11
+ import { useSidebarContext } from '../SidebarContext';
12
+
13
+ type Props = {
14
+ route: Route;
15
+ isActive: boolean;
16
+ };
17
+
18
+ const SidebarLinkItem = ({ route, isActive }: Props) => {
19
+ const { collapsed } = useSidebarContext();
20
+
21
+ return route.link ? (
22
+ <ListItem
23
+ disablePadding
24
+ {...{
25
+ component: RouterLink,
26
+ replace: true,
27
+ to: { pathname: route.link, search: route.query },
28
+ }}
29
+ >
30
+ <ListItemButton
31
+ className={classnames({
32
+ active: isActive,
33
+ main: route.main,
34
+ collapsed,
35
+ })}
36
+ >
37
+ {route.icon && (
38
+ <ListItemIcon className={classnames({ collapsed })}>
39
+ {route.icon}
40
+ </ListItemIcon>
41
+ )}
42
+ <ListItemText
43
+ primary={route.name}
44
+ primaryTypographyProps={{ variant: 'body2' }}
45
+ className={classnames({ collapsed })}
46
+ />
47
+ </ListItemButton>
48
+ </ListItem>
49
+ ) : (
50
+ <ListSubheader>{route.name}</ListSubheader>
51
+ );
52
+ };
53
+
54
+ export default SidebarLinkItem;
@@ -0,0 +1,62 @@
1
+ import type { Route } from '../../../interfaces';
2
+ import {
3
+ ListItem,
4
+ ListItemButton,
5
+ ListItemIcon,
6
+ ListSubheader,
7
+ ListItemText,
8
+ } from '../Sidebar.styled';
9
+ import Box from '@mui/material/Box';
10
+ import ArrowIcon from '../../../assets/chevron_left.svg';
11
+
12
+ import classnames from 'classnames';
13
+ import { useSidebarContext } from '../SidebarContext';
14
+
15
+ type Props = {
16
+ route: Route;
17
+ isActive: boolean;
18
+ isListOpen: boolean;
19
+ handleClick: () => void;
20
+ };
21
+
22
+ function SidebarNestedItem({
23
+ route,
24
+ isActive,
25
+ isListOpen,
26
+ handleClick,
27
+ }: Props) {
28
+ const { collapsed } = useSidebarContext();
29
+
30
+ return route?.link ? (
31
+ <ListItem disablePadding onClick={handleClick}>
32
+ <ListItemButton
33
+ className={classnames({
34
+ active: isActive,
35
+ main: route.main,
36
+ collapsed,
37
+ })}
38
+ >
39
+ {route.icon && <ListItemIcon>{route.icon}</ListItemIcon>}
40
+ <ListItemText
41
+ primary={route.name}
42
+ primaryTypographyProps={{ variant: 'body2' }}
43
+ className={classnames({ collapsed })}
44
+ />
45
+ <Box
46
+ component="img"
47
+ src={ArrowIcon}
48
+ mr={3}
49
+ sx={{
50
+ transition: 'transform .3s',
51
+ transform: `rotate(${isListOpen ? '-90deg' : 0})`,
52
+ opacity: collapsed ? 0 : 1,
53
+ }}
54
+ />
55
+ </ListItemButton>
56
+ </ListItem>
57
+ ) : (
58
+ <ListSubheader>{route.name}</ListSubheader>
59
+ );
60
+ }
61
+
62
+ export default SidebarNestedItem;
@@ -1,2 +1,2 @@
1
- export { default } from './SidebarLink';
2
- export * from './MenuIcon';
1
+ export { default } from './SidebarLink';
2
+ export * from './MenuIcon';
@@ -0,0 +1,2 @@
1
+ export * from './Sidebar';
2
+ export * from './SidebarLink/MenuIcon';
@@ -0,0 +1,16 @@
1
+ import useStyles from './styles';
2
+ import cn from 'classnames';
3
+ import { StatusVariant } from '../../interfaces';
4
+
5
+ type Props = {
6
+ text: string;
7
+ status?: StatusVariant;
8
+ };
9
+
10
+ export const Status = ({ text, status = 'default' }: Props) => {
11
+ const { classes } = useStyles();
12
+
13
+ return <div className={cn(classes['root'], { [status]: true })}>{text}</div>;
14
+ };
15
+
16
+ export default Status;
@@ -1 +1 @@
1
- export * from './Status';
1
+ export * from './Status';
@@ -0,0 +1,21 @@
1
+ import { makeStyles } from 'tss-react/mui';
2
+
3
+ export default makeStyles()((theme) => ({
4
+ root: {
5
+ backgroundColor: '#eee',
6
+ fontSize: '14px',
7
+ padding: '0 8px',
8
+ borderRadius: '10px',
9
+ width: 'fit-content',
10
+
11
+ '&.success': {
12
+ backgroundColor: '#a9dfa9',
13
+ },
14
+ '&.error': {
15
+ backgroundColor: '#ff7e7e',
16
+ },
17
+ '&.warning': {
18
+ backgroundColor: theme.palette.warning.main,
19
+ },
20
+ },
21
+ }));
@@ -0,0 +1,73 @@
1
+ import { ReactNode } from 'react';
2
+ import Stepper from '@mui/material/Stepper';
3
+ import Step from '@mui/material/Step';
4
+ import StepLabel from '@mui/material/StepLabel';
5
+ import StepContent from '@mui/material/StepContent';
6
+ import StepConnector from '@mui/material/StepConnector';
7
+ import { makeStyles } from 'tss-react/mui';
8
+
9
+ export type StepperDataItem = { label: string | ReactNode; content: ReactNode };
10
+
11
+ export type StepperData = StepperDataItem[];
12
+
13
+ type Props = {
14
+ data: StepperData;
15
+ };
16
+
17
+ const useStyles = makeStyles()(() => ({
18
+ content: {
19
+ marginLeft: '4px',
20
+ },
21
+ connector: {
22
+ marginLeft: '4px',
23
+ },
24
+ stepper: {
25
+ padding: '12px',
26
+ },
27
+ label: {
28
+ display: 'flex',
29
+ alignItems: 'flex-start',
30
+ },
31
+ }));
32
+
33
+ const StepIcon = () => (
34
+ <div
35
+ style={{
36
+ display: 'inline-block',
37
+ width: '10px',
38
+ height: '10px',
39
+ borderRadius: '50%',
40
+ backgroundColor: '#536DFE',
41
+ marginTop: '5px',
42
+ }}
43
+ />
44
+ );
45
+
46
+ export const StepperView = ({ data }: Props) => {
47
+ const { classes } = useStyles();
48
+
49
+ return (
50
+ <Stepper
51
+ nonLinear
52
+ orientation="vertical"
53
+ className={classes.stepper}
54
+ connector={<StepConnector className={classes.connector} />}
55
+ >
56
+ {data.filter(Boolean).map((item, index) => (
57
+ <Step expanded key={index}>
58
+ <StepLabel
59
+ className={classes.label}
60
+ StepIconComponent={StepIcon}
61
+ StepIconProps={{ icon: '', completed: false, active: true }}
62
+ >
63
+ {item.label}
64
+ </StepLabel>
65
+ <StepContent className={classes.content}>{item.content}</StepContent>
66
+ </Step>
67
+ ))}
68
+ <Step />
69
+ </Stepper>
70
+ );
71
+ };
72
+
73
+ export default StepperView;
@@ -1 +1 @@
1
- export * from './StepperView';
1
+ export * from './StepperView';
@@ -0,0 +1,51 @@
1
+ import { useCallback, MouseEvent } from 'react';
2
+ import Box from '@mui/material/Box';
3
+ import Tooltip from '@mui/material/Tooltip';
4
+ import SvgIcon from '@mui/material/SvgIcon';
5
+ import IconButton from '@mui/material/IconButton';
6
+ import { getJsonStringValue, useToggle } from '../../../utils';
7
+ import { CopyButton } from '../../Forms';
8
+ import { JsonView } from '../../JsonView';
9
+ import { JsonModalView } from '../../Modals';
10
+
11
+ const JsonTypeCell = ({
12
+ value,
13
+ copyButton = false,
14
+ textField = false,
15
+ }: {
16
+ value: any;
17
+ copyButton?: boolean;
18
+ textField?: boolean;
19
+ }) => {
20
+ const { open: jsonModalOpen, onOpen: onJsonModalOpen, onClose: onJsonModalClose } = useToggle();
21
+
22
+ const handleClickOpen = useCallback((e: MouseEvent) => {
23
+ e.stopPropagation();
24
+ onJsonModalOpen();
25
+ }, [onJsonModalOpen])
26
+
27
+ return (
28
+ <Box width="100%">
29
+ <Box display="flex" alignItems="center" justifyContent="flex-end" pt={1} mb={2}>
30
+ {copyButton && <CopyButton copyText={getJsonStringValue(value)} />}
31
+ <Tooltip title="Open" placement="top">
32
+ <IconButton size="small" onClick={handleClickOpen}>
33
+ <SvgIcon>
34
+ <path d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z" />
35
+ </SvgIcon>
36
+ </IconButton>
37
+ </Tooltip>
38
+ </Box>
39
+ {textField ? (
40
+ <Box overflow="hidden" whiteSpace="nowrap">
41
+ {typeof value === 'object' ? JSON.stringify(value) : value}
42
+ </Box>
43
+ ) : (
44
+ <JsonView value={value} />
45
+ )}
46
+ <JsonModalView open={jsonModalOpen} value={getJsonStringValue(value)} onClose={onJsonModalClose} />
47
+ </Box>
48
+ );
49
+ };
50
+
51
+ export default JsonTypeCell;
@@ -0,0 +1,117 @@
1
+ import React from 'react';
2
+ import TablePagination from './TablePagination';
3
+ import TableColumnMenu from './TableColumnMenu';
4
+ import useTableQueryPagination from './useTableQueryPagination';
5
+ import useTableQuerySorting from './useTableQuerySorting';
6
+ import usePagination from './usePagination';
7
+ import { DataGrid, GridCellParams, GridColumns, GridFeatureMode, GridRowsProp } from '@mui/x-data-grid';
8
+ import useStyles from './styles';
9
+ import Box from '@mui/material/Box';
10
+
11
+ /**
12
+ * This interface is referencing the [[Table]] component props.
13
+ * @category Common UI components
14
+ */
15
+ export interface TableProps {
16
+ /**
17
+ * Data loading state
18
+ */
19
+ loading?: boolean;
20
+ /**
21
+ * Table columns
22
+ */
23
+ columns: GridColumns;
24
+ /**
25
+ * Table rows
26
+ */
27
+ rows: GridRowsProp;
28
+ /**
29
+ * Rows count to display
30
+ */
31
+ rowCount: number;
32
+ disableMargin?: boolean;
33
+ /**
34
+ * Data display mode.
35
+ * Values: `client` | `server`;
36
+ * Default: `server`
37
+ */
38
+ mode?: GridFeatureMode;
39
+ /**
40
+ * Page size. Default `10`
41
+ */
42
+ initialPageSize?: number;
43
+ /**
44
+ * On cell click handler function
45
+ * ```typescript
46
+ * (params: GridCellParams, event: React.MouseEvent) => void;
47
+ * ```
48
+ */
49
+ onCellClick?: (params: GridCellParams, event: React.MouseEvent) => void;
50
+ pagination?: boolean;
51
+ }
52
+
53
+ /**
54
+ * Main data display component. MUI DataGrid used
55
+ * @category Common UI components
56
+ */
57
+ export const Table = ({
58
+ columns,
59
+ rows,
60
+ rowCount,
61
+ loading,
62
+ disableMargin,
63
+ mode = 'server',
64
+ initialPageSize = 10,
65
+ pagination = true,
66
+ onCellClick,
67
+ }: TableProps) => {
68
+ const { classes } = useStyles();
69
+
70
+ const { page, size, onPageChange, onSizeChange } = useTableQueryPagination({ mode });
71
+ const { onColumnHeaderClick, getSortedColumns } = useTableQuerySorting();
72
+
73
+ const { pageSize, handlePageSizeChange } = usePagination(initialPageSize);
74
+
75
+ const tableProps = {
76
+ sortingMode: mode,
77
+ paginationMode: mode,
78
+ pageSize: mode === 'server' ? size : pagination ? pageSize : rowCount,
79
+ onPageSizeChange: mode === 'server' ? onSizeChange : handlePageSizeChange,
80
+ components: {
81
+ Pagination: TablePagination,
82
+ },
83
+ };
84
+
85
+ if (mode === 'server') {
86
+ tableProps['sortModel'] = [];
87
+ tableProps['onColumnHeaderClick'] = onColumnHeaderClick;
88
+ tableProps['page'] = page;
89
+ tableProps['onPageChange'] = onPageChange;
90
+ tableProps.components['ColumnMenu'] = TableColumnMenu;
91
+ }
92
+
93
+
94
+ return (
95
+ <Box mt={disableMargin ? 0 : 2}>
96
+ <DataGrid
97
+ autoHeight
98
+ hideFooterPagination={!pagination}
99
+ hideFooter={!pagination}
100
+ disableSelectionOnClick
101
+ showColumnRightBorder
102
+ showCellRightBorder
103
+ className={classes.root}
104
+ loading={loading}
105
+ rows={rows}
106
+ columns={getSortedColumns(columns)}
107
+ rowCount={rowCount}
108
+ rowsPerPageOptions={[10, 20, 50, 100]}
109
+ onCellClick={onCellClick}
110
+ {...tableProps}
111
+ />
112
+
113
+ </Box>
114
+ );
115
+ };
116
+
117
+ export default Table;
@@ -0,0 +1,43 @@
1
+ import Tooltip from '@mui/material/Tooltip';
2
+ import { GridActionsCellItem } from '@mui/x-data-grid';
3
+ import IconButton from '@mui/material/IconButton';
4
+ import { Link } from 'react-router-dom';
5
+ import React, { ReactElement } from 'react';
6
+
7
+ type Props = {
8
+ icon: ReactElement;
9
+ onClick?: () => void;
10
+ label: string;
11
+ showInMenu?: boolean;
12
+ location?: {
13
+ pathname: string;
14
+ state?: Record<string, unknown>;
15
+ }
16
+ };
17
+
18
+ export const TableAction = ({ icon, label, showInMenu, onClick, location }: Props) => {
19
+ if (location) {
20
+ return (
21
+ <IconButton component={Link} to={location} size="small">
22
+ <Tooltip title={label} arrow>
23
+ {React.cloneElement(icon, { fontSize: 'small' })}
24
+ </Tooltip>
25
+ </IconButton>
26
+ )
27
+ }
28
+ return (
29
+ <GridActionsCellItem
30
+ nonce=""
31
+ onResize={undefined}
32
+ onResizeCapture={undefined}
33
+ icon={
34
+ <Tooltip title={label} arrow>
35
+ {icon}
36
+ </Tooltip>
37
+ }
38
+ onClick={onClick}
39
+ label={label}
40
+ showInMenu={showInMenu}
41
+ />
42
+ );
43
+ };
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { GridColumnMenuContainer, GridFilterMenuItem } from '@mui/x-data-grid';
3
+
4
+ const TableColumnMenu = ({ hideMenu, currentColumn, onUnsort, ...rest }: any) => {
5
+ return (
6
+ <GridColumnMenuContainer hideMenu={hideMenu} currentColumn={currentColumn} {...rest}>
7
+ <GridFilterMenuItem onClick={hideMenu} column={currentColumn} />
8
+ </GridColumnMenuContainer>
9
+ );
10
+ };
11
+
12
+ export default TableColumnMenu;