@dartech/arsenal-ui 1.2.3 → 1.2.5

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 +102 -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,103 @@
1
+ import Grid from '@mui/material/Unstable_Grid2';
2
+ import Chip from '@mui/material/Chip';
3
+ import Box from '@mui/material/Box';
4
+ import Typography from '@mui/material/Typography';
5
+ import TextField from '@mui/material/TextField';
6
+ import IconButton from '@mui/material/IconButton';
7
+ import AddIcon from '@mui/icons-material/Add';
8
+
9
+ import { useFormContext, useWatch } from 'react-hook-form';
10
+ import { removeArrayItem } from '../../../../utils';
11
+ import { useCallback, useMemo, useState } from 'react';
12
+
13
+ type Props = {
14
+ propertyFieldName: string;
15
+ };
16
+
17
+ const StringPropertyFields = ({ propertyFieldName }: Props) => {
18
+ const fieldName = useMemo(() => `${propertyFieldName}.restrictedValues`, [propertyFieldName]);
19
+
20
+ const { control, setValue, getValues } = useFormContext();
21
+ const restrictedValues = useWatch({
22
+ control,
23
+ name: fieldName,
24
+ defaultValue: getValues(`${propertyFieldName}.restrictedValues`) || [],
25
+ });
26
+
27
+ const [inputValue, setInputValue] = useState('');
28
+ const [error, setError] = useState('');
29
+
30
+ const handleDelete = useCallback(
31
+ (index) => {
32
+ setValue(fieldName, removeArrayItem(restrictedValues, index));
33
+ },
34
+ [restrictedValues, fieldName, setValue]
35
+ );
36
+
37
+ const handleAddValue = () => {
38
+ if (inputValue) {
39
+ setValue(fieldName, [...restrictedValues, inputValue]);
40
+ setInputValue('');
41
+ }
42
+ };
43
+
44
+ const handleInputChange = (e) => {
45
+ const { value } = e.target;
46
+ setInputValue(value);
47
+
48
+ if (restrictedValues.includes(value)) {
49
+ setError('This value already exists');
50
+ } else {
51
+ setError('');
52
+ }
53
+ };
54
+
55
+ const handleKeyDown = (e) => {
56
+ if (e.key === 'Enter') {
57
+ handleAddValue();
58
+ }
59
+ };
60
+
61
+ return (
62
+ <>
63
+ <Grid>
64
+ <Typography variant="h6">Restricted Values</Typography>
65
+ </Grid>
66
+ {
67
+ !!restrictedValues?.length && (
68
+ <Grid>
69
+ <Box display="flex" flexWrap="wrap">
70
+ {restrictedValues.map((value, index) => (
71
+ <Chip sx={{ mr: 1 }} key={index} variant="outlined" label={value} onDelete={() => handleDelete(index)} />
72
+ ))}
73
+ </Box>
74
+ </Grid>
75
+ )
76
+ }
77
+
78
+ <Grid>
79
+ <TextField
80
+ fullWidth
81
+ variant="outlined"
82
+ size="small"
83
+ label="Add restricted value"
84
+ value={inputValue}
85
+ onChange={handleInputChange}
86
+ error={!!error}
87
+ helperText={error}
88
+ name="restrictedValues"
89
+ inputProps={{ onKeyDown: handleKeyDown }}
90
+ InputProps={{
91
+ endAdornment: (
92
+ <IconButton size="small" onClick={handleAddValue} disabled={!!error}>
93
+ <AddIcon />
94
+ </IconButton>
95
+ ),
96
+ }}
97
+ />
98
+ </Grid>
99
+ </>
100
+ );
101
+ };
102
+
103
+ export default StringPropertyFields;
@@ -1 +1 @@
1
- export * from './PropertyAdditionalFields';
1
+ export * from './PropertyAdditionalFields';
@@ -1,2 +1,2 @@
1
- export * from './CreatePropertiesList';
2
- export * from './CreatePropertyFormFields';
1
+ export * from './CreatePropertiesList';
2
+ export * from './CreatePropertyFormFields';
@@ -0,0 +1,22 @@
1
+ import { useMemo } from 'react';
2
+ import { CustomPropertyFieldProps } from '../../../interfaces';
3
+
4
+ const useCustomFields = (customPropertyFields: CustomPropertyFieldProps[]) => {
5
+ const customCheckboxes = useMemo(() => {
6
+ if (customPropertyFields.length) {
7
+ return customPropertyFields.filter((field) => field.type === 'checkbox');
8
+ }
9
+ return [];
10
+ }, [customPropertyFields]);
11
+
12
+ const customFields = useMemo(() => {
13
+ if (customPropertyFields.length) {
14
+ return customPropertyFields.filter((field) => field.type !== 'checkbox');
15
+ }
16
+ return [];
17
+ }, [customPropertyFields]);
18
+
19
+ return { customCheckboxes, customFields };
20
+ };
21
+
22
+ export default useCustomFields;
@@ -0,0 +1,37 @@
1
+ import Box from '@mui/material/Box';
2
+ import Typography from '@mui/material/Typography';
3
+ import { ViewProperty } from '../ViewProperty';
4
+
5
+ import { useMemo } from 'react';
6
+ import { propertiesObjectToArray } from '../../../utils';
7
+ import { PropertiesArrayType, PropertiesObjectType } from '../../../interfaces';
8
+
9
+ type Props = {
10
+ properties: PropertiesObjectType<unknown> | PropertiesArrayType<unknown>;
11
+ expandAll?: boolean;
12
+ };
13
+
14
+ export const ViewPropertiesList = ({ properties, expandAll = true }: Props) => {
15
+ const propertiesList = useMemo(() => {
16
+ if (Array.isArray(properties)) {
17
+ return properties;
18
+ } else if (properties) {
19
+ return propertiesObjectToArray(properties);
20
+ }
21
+ return [];
22
+ }, [properties]);
23
+
24
+ return (
25
+ <Box display="flex" flexDirection="column">
26
+ {propertiesList.length ? (
27
+ propertiesList.map((property) => (
28
+ <ViewProperty key={property.key} property={property} defaultExpanded={expandAll} />
29
+ ))
30
+ ) : (
31
+ <Typography>No properties</Typography>
32
+ )}
33
+ </Box>
34
+ );
35
+ };
36
+
37
+ export default ViewPropertiesList;
@@ -1 +1 @@
1
- export * from './ViewPropertiesList';
1
+ export * from './ViewPropertiesList';
@@ -0,0 +1,40 @@
1
+ import Box from '@mui/material/Box';
2
+ import { PropertiesArrayType } from '../../../interfaces';
3
+ import { StepperData, StepperView } from '../../StepperView';
4
+ import { useMemo } from 'react';
5
+
6
+ type Props = {
7
+ properties: PropertiesArrayType;
8
+ };
9
+
10
+ const EntityPropertiesShortView = ({ properties = [] }: Props) => {
11
+ const stepperData: StepperData = useMemo(() => {
12
+ if (properties) {
13
+ return properties.map((property) => {
14
+ const propertyType =
15
+ typeof property.propertyType === 'string' ? property.propertyType : property['propertyType']['value'];
16
+ return {
17
+ label: (
18
+ <Box display="flex" flexDirection="column">
19
+ <b>
20
+ {property.name}
21
+ {property.isRequired ? '*' : ''}
22
+ </b>
23
+ <span>
24
+ {property.key} | {property.isMultiple ? 'multiple' : 'single'} | {propertyType}
25
+ </span>
26
+ </Box>
27
+ ),
28
+ content: property.propertyType === 'ENTITY' && (
29
+ <EntityPropertiesShortView properties={property.properties as PropertiesArrayType} />
30
+ ),
31
+ };
32
+ });
33
+ }
34
+ return [];
35
+ }, [properties]);
36
+
37
+ return <StepperView data={stepperData} />;
38
+ };
39
+
40
+ export default EntityPropertiesShortView;
@@ -0,0 +1,48 @@
1
+ import Box from '@mui/material/Box';
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 Typography from '@mui/material/Typography';
7
+ import ViewProperty from './ViewProperty';
8
+
9
+ import { memo, useMemo } from 'react';
10
+ import { PropertiesArrayType, PropertyType } from '../../../interfaces';
11
+
12
+ type Props = {
13
+ properties: PropertiesArrayType;
14
+ parentNames?: string[];
15
+ };
16
+
17
+ const EntityPropertiesView = ({ properties, parentNames = [] }: Props) => {
18
+ const hasProperties = useMemo(() => {
19
+ let hasProps = false;
20
+ properties.every((property) => {
21
+ if (property.propertyType === PropertyType.ENTITY) {
22
+ hasProps = true;
23
+ return false;
24
+ }
25
+ return true;
26
+ });
27
+ return hasProps;
28
+ }, [properties]);
29
+
30
+ return (
31
+ <Box mt={4}>
32
+ <Typography variant="h6">Properties</Typography>
33
+ <Stepper orientation="vertical" style={{ paddingLeft: '4px' }}>
34
+ {properties.map((property) => (
35
+ <Step expanded key={property.key}>
36
+ <StepLabel StepIconProps={{ icon: '', completed: false, active: true }} />
37
+ <StepContent>
38
+ <ViewProperty property={property} parentNames={[...parentNames]} defaultExpanded={false} />
39
+ </StepContent>
40
+ </Step>
41
+ ))}
42
+ {hasProperties && <Step />}
43
+ </Stepper>
44
+ </Box>
45
+ );
46
+ };
47
+
48
+ export default memo(EntityPropertiesView);
@@ -0,0 +1,148 @@
1
+ import Box from '@mui/material/Box';
2
+ import Table from '@mui/material/Table';
3
+ import TableBody from '@mui/material/TableBody';
4
+ import TableRow from '@mui/material/TableRow';
5
+ import TableCell from '@mui/material/TableCell';
6
+ import Typography from '@mui/material/Typography';
7
+ import Chip from '@mui/material/Chip';
8
+ import CheckCircleIcon from '@mui/icons-material/CheckCircle';
9
+
10
+ import { useMemo } from 'react';
11
+ import { PropertyType, PropertyUnion } from '../../../interfaces';
12
+ import { JsonView } from '../../JsonView';
13
+
14
+ type Props = {
15
+ property: PropertyUnion;
16
+ };
17
+
18
+ type ValueDisplayProps = {
19
+ value: unknown;
20
+ type: PropertyType;
21
+ };
22
+
23
+ const labels = {
24
+ name: 'Name',
25
+ key: 'Key',
26
+ propertyType: 'Property Type',
27
+ defaultValue: 'Default Value',
28
+ defaultValues: 'Default Values',
29
+ sortOrder: 'Sort Order',
30
+ isRequired: 'Required',
31
+ isMultiple: 'Multiple',
32
+ isEnabled: 'Enabled',
33
+ isViewableInList: 'Is Viewable In List',
34
+ precisionScale: 'Precision Scale',
35
+ roundingMode: 'Rounding Mode',
36
+ format: 'Format',
37
+ definitionCode: 'Definition Code',
38
+ definitionVersion: 'Definition Version',
39
+ labelPropertyCode: 'Label Property Code',
40
+ valuePropertyCode: 'Value Property Code',
41
+ restrictedValues: 'Restricted Values',
42
+ value: 'Value',
43
+ values: 'Values',
44
+ uiSettings: 'UI Settings',
45
+ validationNode: 'Validation Node',
46
+ };
47
+
48
+ const ValueDisplay = ({ value, type }: ValueDisplayProps) => {
49
+ if ((type === PropertyType.JSON || type === PropertyType.ENTITY || type === PropertyType.ANY) && value) {
50
+ return <JsonView value={value} />;
51
+ } else {
52
+ return (
53
+ <Typography variant="subtitle1" display="inline" style={{ wordBreak: 'break-word' }}>
54
+ {value === null ? 'null' : value.toString()}
55
+ </Typography>
56
+ );
57
+ }
58
+ };
59
+
60
+ const formatDiplayValue = (value: any, key: string, type: PropertyType) => {
61
+ switch (key) {
62
+ case 'isRequired':
63
+ case 'isMultiple':
64
+ case 'isEnabled':
65
+ case 'isViewableInList':
66
+ return value ? <CheckCircleIcon color="primary" fontSize="small" /> : null;
67
+ case 'restrictedValues':
68
+ return value ? (
69
+ <Box display="flex" flexWrap="wrap">
70
+ {(value as string[]).map((restrictedValue) => (
71
+ <Chip
72
+ key={restrictedValue}
73
+ label={restrictedValue}
74
+ style={{ wordBreak: 'break-word', maxWidth: '500px' }}
75
+ />
76
+ ))}
77
+ </Box>
78
+ ) : null;
79
+ case 'defaultValue':
80
+ case 'value':
81
+ return <ValueDisplay value={value} type={type} />;
82
+ case 'values':
83
+ case 'defaultValues':
84
+ if (
85
+ !Array.isArray(value) ||
86
+ type === PropertyType.ENTITY ||
87
+ type === PropertyType.JSON ||
88
+ type === PropertyType.ANY
89
+ ) {
90
+ return <JsonView value={value} />;
91
+ } else {
92
+ return (
93
+ <div>
94
+ [
95
+ {(value as unknown[])?.map((v, index) => (
96
+ <div key={index}>
97
+ <ValueDisplay value={v} type={type} />
98
+ </div>
99
+ ))}
100
+ ]
101
+ </div>
102
+ );
103
+ }
104
+ case 'uiSettings':
105
+ case 'validationNode':
106
+ return value ? <JsonView value={value} /> : null;
107
+ default:
108
+ return (
109
+ <Typography variant="subtitle1" display="inline" style={{ wordBreak: 'break-word' }}>
110
+ {value}
111
+ </Typography>
112
+ );
113
+ }
114
+ };
115
+
116
+ const PropertyDataTable = ({ property }: Props) => {
117
+ const propertyData = useMemo(() => {
118
+ if (property) {
119
+ if (property.isMultiple) {
120
+ delete property.defaultValue;
121
+ delete property['value'];
122
+ } else {
123
+ delete property.defaultValues;
124
+ delete property['values'];
125
+ }
126
+ }
127
+ return property;
128
+ }, [property]);
129
+
130
+ return (
131
+ <Table size="small">
132
+ <TableBody>
133
+ {Object.keys(labels).map((key) =>
134
+ key in propertyData ? (
135
+ <TableRow key={key}>
136
+ <TableCell width="30%">
137
+ <Typography>{labels[key]}</Typography>
138
+ </TableCell>
139
+ <TableCell>{formatDiplayValue(propertyData[key], key, propertyData.propertyType)}</TableCell>
140
+ </TableRow>
141
+ ) : null
142
+ )}
143
+ </TableBody>
144
+ </Table>
145
+ );
146
+ };
147
+
148
+ export default PropertyDataTable;
@@ -0,0 +1,43 @@
1
+ import TreeItem from '@mui/lab/TreeItem';
2
+
3
+ import { useMemo } from 'react';
4
+ import { PropertiesArrayType, PropertyType, PropertyUnion } from '../../../interfaces';
5
+
6
+ type PropertyItemProps = {
7
+ property: PropertyUnion;
8
+ showName: boolean;
9
+ showType: boolean;
10
+ };
11
+
12
+ const PropertyItem = ({ property, showName, showType }: PropertyItemProps) => {
13
+ const label = useMemo(() => {
14
+ let labelText = '';
15
+
16
+ if (property) {
17
+ labelText += `<b>${property.key}</b>`;
18
+ }
19
+
20
+ if (showName) {
21
+ labelText += ` - ${property.name}`;
22
+ }
23
+
24
+ if (showType) {
25
+ const type = property.propertyType['value'] ?? property.propertyType;
26
+ labelText += ` - ${type}${property.isMultiple ? '[]' : ''}`;
27
+ }
28
+
29
+ return labelText;
30
+ }, [property, showName, showType]);
31
+
32
+ return (
33
+ <TreeItem nodeId={property.key} label={<div dangerouslySetInnerHTML={{ __html: label }} />}>
34
+ {property.propertyType === PropertyType.ENTITY
35
+ ? (property.properties as PropertiesArrayType).map((prop) => (
36
+ <PropertyItem key={prop.key} property={prop} showName={showName} showType={showType} />
37
+ ))
38
+ : null}
39
+ </TreeItem>
40
+ );
41
+ };
42
+
43
+ export default PropertyItem;
@@ -0,0 +1,52 @@
1
+ import Box from '@mui/material/Box';
2
+ import Typography from '@mui/material/Typography';
3
+ import Accordion from '@mui/material/Accordion';
4
+ import AccordionSummary from '@mui/material/AccordionSummary';
5
+ import AccordionDetails from '@mui/material/AccordionDetails';
6
+ import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
7
+ import PropertyDataTable from './PropertyDataTable';
8
+ import EntityPropertiesView from './EntityPropertiesView';
9
+
10
+ import { useEffect, useState } from 'react';
11
+ import { propertiesObjectToArray } from '../../../utils';
12
+ import { PropertiesObjectType, PropertyType, PropertyUnion } from '../../../interfaces';
13
+
14
+ type Props = {
15
+ property: PropertyUnion;
16
+ parentNames?: string[];
17
+ defaultExpanded?: boolean;
18
+ };
19
+
20
+ export const ViewProperty = ({ property, parentNames = [], defaultExpanded = true }: Props) => {
21
+ const [expanded, setExpanded] = useState(true);
22
+
23
+ useEffect(() => {
24
+ setExpanded(defaultExpanded);
25
+ }, [defaultExpanded]);
26
+
27
+ return (
28
+ <Accordion
29
+ elevation={3}
30
+ style={{ backgroundColor: parentNames.length % 2 === 1 ? '#f1f1f1' : '#fff' }}
31
+ expanded={expanded}
32
+ onChange={() => setExpanded((prevState) => !prevState)}
33
+ >
34
+ <AccordionSummary expandIcon={<ExpandMoreIcon />}>
35
+ <Typography style={{ wordBreak: 'break-word', fontWeight: '600' }}>{property.name}</Typography>
36
+ </AccordionSummary>
37
+ <AccordionDetails>
38
+ <Box width="100%">
39
+ <PropertyDataTable property={property} />
40
+ {property.propertyType === PropertyType.ENTITY && (
41
+ <EntityPropertiesView
42
+ properties={propertiesObjectToArray(property.properties as PropertiesObjectType)}
43
+ parentNames={[...parentNames, property.name]}
44
+ />
45
+ )}
46
+ </Box>
47
+ </AccordionDetails>
48
+ </Accordion>
49
+ );
50
+ };
51
+
52
+ export default ViewProperty;
@@ -1 +1 @@
1
- export * from './ViewProperty';
1
+ export * from './ViewProperty';
@@ -1,5 +1,5 @@
1
- export * from './UpsertProperty';
2
- export * from './PropertyValueField';
3
- export * from './ViewProperty';
4
- export * from './ViewPropertiesList';
5
- export * from './PropertyFiller';
1
+ export * from './UpsertProperty';
2
+ export * from './PropertyValueField';
3
+ export * from './ViewProperty';
4
+ export * from './ViewPropertiesList';
5
+ export * from './PropertyFiller';
@@ -0,0 +1,157 @@
1
+ import MuiDrawer from '@mui/material/Drawer';
2
+ import MuiList from '@mui/material/List';
3
+ import MuiListItem from '@mui/material/ListItem';
4
+ import MuiListItemIcon from '@mui/material/ListItemIcon';
5
+ import MuiListItemButton from '@mui/material/ListItemButton';
6
+ import MuiListSubheader from '@mui/material/ListSubheader';
7
+ import MuiListItemText from '@mui/material/ListItemText';
8
+ import Toolbar from '@mui/material/Toolbar';
9
+ import MuiButtonBase from '@mui/material/ButtonBase';
10
+ import { styled } from '@mui/material/styles';
11
+
12
+ const drawerWidth = 248;
13
+
14
+ export const Container = styled('div')({
15
+ position: 'relative',
16
+ '&:hover': {
17
+ '.button-collapse': {
18
+ opacity: 1,
19
+ },
20
+ },
21
+ });
22
+
23
+ export const Drawer = styled(MuiDrawer)((props) => ({
24
+ width: drawerWidth,
25
+ flexShrink: 0,
26
+ position: 'relative',
27
+ transition: 'all 0.3s ease-in-out',
28
+ '& .MuiDrawer-paper': {
29
+ backgroundColor: props.theme.palette.secondary.main,
30
+ width: drawerWidth,
31
+ boxSizing: 'border-box',
32
+ borderRight: 'none',
33
+ borderRadius: 0,
34
+ transition: 'all 0.3s ease-in-out',
35
+ overflow: 'hidden',
36
+ },
37
+
38
+ '&.collapsed': {
39
+ width: 64,
40
+ '& .MuiDrawer-paper': {
41
+ width: 64,
42
+ },
43
+ },
44
+ }));
45
+
46
+ export const Header = styled(Toolbar)(({ theme }) => ({
47
+ backgroundColor: '#fff',
48
+ borderRight: '1px solid rgba(38, 40, 66, 0.08)',
49
+ fontSize: 24,
50
+ fontWeight: 600,
51
+ // padding: theme.spacing(1, 4)
52
+ }));
53
+
54
+ export const List = styled(MuiList)((props) => ({
55
+ padding: props.theme.spacing(3),
56
+ margin: 0,
57
+ }));
58
+
59
+ export const ListItem = styled(MuiListItem)((props) => ({
60
+ color: '#fff',
61
+ height: props.theme.spacing(11),
62
+ overflow: 'hidden',
63
+ }));
64
+
65
+ export const ListItemButton = styled(MuiListItemButton)(({ theme }) => ({
66
+ borderRadius: theme.spacing(2.5),
67
+ padding: theme.spacing(2),
68
+ height: theme.spacing(11),
69
+ '&.active': {
70
+ backgroundColor: 'rgba(38, 40, 66, 0.12)',
71
+ '&.main': {
72
+ backgroundColor: 'rgba(255, 255, 255, 0.12)',
73
+ borderLeft: '4px solid #E0613A',
74
+ },
75
+ },
76
+ '&:hover': {
77
+ backgroundColor: 'rgba(255, 255, 255, 0.08)',
78
+ },
79
+
80
+ '&.collapsed': {
81
+ width: theme.spacing(11),
82
+ '&.active': {
83
+ '&.main': {
84
+ border: 'none',
85
+ backgroundColor: '#E0613A',
86
+ },
87
+ },
88
+ },
89
+ }));
90
+
91
+ export const ListItemIcon = styled(MuiListItemIcon)(({ theme }) => ({
92
+ color: '#fff',
93
+ width: 20,
94
+ height: 20,
95
+ minWidth: 20,
96
+ marginRight: theme.spacing(2),
97
+ '& svg': {
98
+ marginLeft: 2,
99
+ fill: '#fff',
100
+ color: '#fff',
101
+ },
102
+ '&.collapsed': {
103
+ marginRight: 0,
104
+ },
105
+ }));
106
+
107
+ export const ListSubheader = styled(MuiListSubheader)(() => ({
108
+ backgroundColor: 'inherit',
109
+ color: '#fff',
110
+ paddingLeft: 0,
111
+ textTransform: 'uppercase',
112
+ }));
113
+
114
+ export const ListItemText = styled(MuiListItemText)((props) => ({
115
+ width: '100%',
116
+
117
+ '& > *': {
118
+ overflow: 'hidden',
119
+ textOverflow: 'ellipsis',
120
+ wordBreak: 'break-all',
121
+ whiteSpace: 'nowrap',
122
+ },
123
+
124
+ '&.collapsed': {
125
+ display: 'none',
126
+ },
127
+ }));
128
+
129
+ export const ChildrenList = styled(MuiList)((props) => ({
130
+ margin: 0,
131
+ padding: 0,
132
+ '& .MuiListItemText-root': {
133
+ paddingLeft: props.theme.spacing(7),
134
+ },
135
+ }));
136
+
137
+ export const CollapseButton = styled(MuiButtonBase)((props) => ({
138
+ position: 'absolute',
139
+ top: props.theme.spacing(10),
140
+ left: 'calc(100% - 16px)',
141
+ width: props.theme.spacing(8),
142
+ height: props.theme.spacing(8),
143
+ border: '1px solid #E0E3EA',
144
+ borderRadius: '50%',
145
+ boxShadow: '0px 2px 8px rgba(0, 0, 0, 0.12)',
146
+ backgroundColor: '#fff',
147
+ zIndex: 8000,
148
+ opacity: 0,
149
+ transition: 'all 0.3s ease-in-out',
150
+
151
+ '&.collapsed': {
152
+ img: {
153
+ transition: 'all 0.3s ease-in-out',
154
+ transform: 'rotate(180deg)',
155
+ },
156
+ },
157
+ }));