@dartech/arsenal-ui 0.0.1 → 0.0.3

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 (214) hide show
  1. package/{index.ts → index.d.ts} +3 -3
  2. package/index.esm.js +1 -0
  3. package/index.umd.js +1 -0
  4. package/package.json +5 -2
  5. package/src/interfaces/common.d.ts +10 -0
  6. package/src/interfaces/definition.d.ts +117 -0
  7. package/src/interfaces/{index.ts → index.d.ts} +3 -3
  8. package/src/interfaces/ui.d.ts +33 -0
  9. package/src/lib/Alert/Alert.d.ts +53 -0
  10. package/src/lib/Alert/index.d.ts +1 -0
  11. package/src/lib/Definition/CreateDefinition/CreateDefinition.d.ts +11 -0
  12. package/src/lib/Definition/CreateDefinition/{index.ts → index.d.ts} +1 -1
  13. package/src/lib/Definition/DefinitionFiller/DefinitionFiller.d.ts +8 -0
  14. package/src/lib/Definition/DefinitionFiller/WidgetDefinitionFiller.d.ts +9 -0
  15. package/src/lib/Definition/DefinitionFiller/{index.ts → index.d.ts} +2 -2
  16. package/src/lib/Definition/{index.ts → index.d.ts} +2 -2
  17. package/src/lib/DemPropertyField/DemPropertyField.d.ts +59 -0
  18. package/src/lib/DemPropertyField/DemPropertyView/DemPropertyView.d.ts +8 -0
  19. package/src/lib/DemPropertyField/DemPropertyView/{index.ts → index.d.ts} +1 -1
  20. package/src/lib/DemPropertyField/MultipleDemField/MultipleDemField.d.ts +9 -0
  21. package/src/lib/DemPropertyField/MultipleDemField/{index.tsx → index.d.ts} +1 -1
  22. package/src/lib/DemPropertyField/RestrictedValuesEditor.d.ts +6 -0
  23. package/src/lib/DemPropertyField/SingleDemField/SingleDemField.d.ts +9 -0
  24. package/src/lib/DemPropertyField/SingleDemField/{index.ts → index.d.ts} +1 -1
  25. package/src/lib/DemPropertyField/{index.ts → index.d.ts} +2 -2
  26. package/src/lib/DemPropertyField/styles.d.ts +2 -0
  27. package/src/lib/DemPropertyField/widgets/DemBooleanWidget.d.ts +7 -0
  28. package/src/lib/DemPropertyField/widgets/DemDateTimeWidget.d.ts +9 -0
  29. package/src/lib/DemPropertyField/widgets/DemDateWidget.d.ts +9 -0
  30. package/src/lib/DemPropertyField/widgets/DemFieldWidget.d.ts +11 -0
  31. package/src/lib/DemPropertyField/widgets/DemFloatWidget.d.ts +10 -0
  32. package/src/lib/DemPropertyField/widgets/DemIntegerWidget.d.ts +10 -0
  33. package/src/lib/DemPropertyField/widgets/DemJsonWidget.d.ts +9 -0
  34. package/src/lib/DemPropertyField/widgets/DemStringWidget.d.ts +10 -0
  35. package/src/lib/DemPropertyField/widgets/DemTimeWidget.d.ts +9 -0
  36. package/src/lib/DemPropertyField/widgets/{index.ts → index.d.ts} +1 -1
  37. package/src/lib/Forms/BackButton.d.ts +7 -0
  38. package/src/lib/Forms/ControlAceEditor.d.ts +20 -0
  39. package/src/lib/Forms/ControlAutocomplete.d.ts +49 -0
  40. package/src/lib/Forms/ControlCheckbox.d.ts +30 -0
  41. package/src/lib/Forms/ControlDebouncedInput.d.ts +4 -0
  42. package/src/lib/Forms/ControlInput.d.ts +54 -0
  43. package/src/lib/Forms/ControlNumberInput.d.ts +43 -0
  44. package/src/lib/Forms/ControlQueryAutocomplete.d.ts +7 -0
  45. package/src/lib/Forms/ControlRadioBtn.d.ts +26 -0
  46. package/src/lib/Forms/ControlSelect.d.ts +66 -0
  47. package/src/lib/Forms/CopyButton.d.ts +21 -0
  48. package/src/lib/Forms/{index.ts → index.d.ts} +11 -10
  49. package/src/lib/InfoItem/InfoItem.d.ts +10 -0
  50. package/src/lib/InfoItem/{index.ts → index.d.ts} +1 -1
  51. package/src/lib/InfoItem/styles.d.ts +2 -0
  52. package/src/lib/JsonPathPicker/JsonPathPicker.d.ts +10 -0
  53. package/src/lib/JsonPathPicker/PropertyStep.d.ts +11 -0
  54. package/src/lib/JsonPathPicker/{index.ts → index.d.ts} +1 -1
  55. package/src/lib/JsonView/JsonView.d.ts +9 -0
  56. package/src/lib/JsonView/{index.ts → index.d.ts} +1 -1
  57. package/src/lib/Loader/Loader.d.ts +21 -0
  58. package/src/lib/Loader/{index.ts → index.d.ts} +1 -1
  59. package/src/lib/Modals/JsonModalView.d.ts +10 -0
  60. package/src/lib/Modals/{index.ts → index.d.ts} +1 -1
  61. package/src/lib/Property/PropertyValueField/BooleanValueField.d.ts +7 -0
  62. package/src/lib/Property/PropertyValueField/DateTimeValueField.d.ts +9 -0
  63. package/src/lib/Property/PropertyValueField/DateValueField.d.ts +9 -0
  64. package/src/lib/Property/PropertyValueField/EntityValueField.d.ts +9 -0
  65. package/src/lib/Property/PropertyValueField/JsonValueField.d.ts +10 -0
  66. package/src/lib/Property/PropertyValueField/PropertyValue.d.ts +10 -0
  67. package/src/lib/Property/PropertyValueField/PropertyValueField.d.ts +9 -0
  68. package/src/lib/Property/PropertyValueField/StringValueField.d.ts +9 -0
  69. package/src/lib/Property/PropertyValueField/TimeValueField.d.ts +9 -0
  70. package/src/lib/Property/PropertyValueField/ValueComponent.d.ts +15 -0
  71. package/src/lib/Property/PropertyValueField/{index.ts → index.d.ts} +2 -1
  72. package/src/lib/Property/PropertyWidget/PropertyWidget.d.ts +9 -0
  73. package/src/lib/Property/PropertyWidget/{index.ts → index.d.ts} +1 -1
  74. package/src/lib/Property/UpsertProperty/CreatePropertiesList.d.ts +13 -0
  75. package/src/lib/Property/UpsertProperty/CreatePropertyFormFields.d.ts +10 -0
  76. package/src/lib/Property/UpsertProperty/CustomPropertyField.d.ts +7 -0
  77. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/BigDecimalPropertyFields.d.ts +6 -0
  78. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/DateAdditionalFields.d.ts +7 -0
  79. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityAdditionalFields.d.ts +8 -0
  80. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityReferencePropertyFields.d.ts +6 -0
  81. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/PropertyAdditionalFields.d.ts +10 -0
  82. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/StringPropertyFields.d.ts +6 -0
  83. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/{index.ts → index.d.ts} +1 -1
  84. package/src/lib/Property/UpsertProperty/{index.ts → index.d.ts} +2 -2
  85. package/src/lib/Property/UpsertProperty/useCustomFields.d.ts +6 -0
  86. package/src/lib/Property/ViewPropertiesList/ViewPropertiesList.d.ts +8 -0
  87. package/src/lib/Property/ViewPropertiesList/{index.ts → index.d.ts} +1 -1
  88. package/src/lib/Property/ViewProperty/EntityPropertiesShortView.d.ts +9 -0
  89. package/src/lib/Property/ViewProperty/EntityPropertiesView.d.ts +8 -0
  90. package/src/lib/Property/ViewProperty/PropertyDataTable.d.ts +7 -0
  91. package/src/lib/Property/ViewProperty/PropertyItem.d.ts +9 -0
  92. package/src/lib/Property/ViewProperty/ViewProperty.d.ts +9 -0
  93. package/src/lib/Property/ViewProperty/{index.ts → index.d.ts} +1 -1
  94. package/src/lib/Property/{index.ts → index.d.ts} +4 -4
  95. package/src/lib/Status/Status.d.ts +7 -0
  96. package/src/lib/Status/{index.ts → index.d.ts} +1 -1
  97. package/src/lib/Status/styles.d.ts +2 -0
  98. package/src/lib/StepperView/StepperView.d.ts +10 -0
  99. package/src/lib/StepperView/index.d.ts +1 -0
  100. package/src/lib/Table/Table.d.ts +49 -0
  101. package/src/lib/Table/TableColumnMenu.d.ts +3 -0
  102. package/src/lib/Table/TablePagination.d.ts +3 -0
  103. package/src/lib/Table/index.d.ts +1 -0
  104. package/src/lib/Table/styles.d.ts +2 -0
  105. package/src/lib/Table/usePagination.d.ts +5 -0
  106. package/src/lib/Table/useTableQueryPagination.d.ts +11 -0
  107. package/src/lib/Table/useTableQuerySorting.d.ts +6 -0
  108. package/src/lib/Tabs/RouteTabs.d.ts +11 -0
  109. package/src/lib/Tabs/TabPanel.d.ts +25 -0
  110. package/src/lib/Tabs/{index.ts → index.d.ts} +2 -2
  111. package/src/lib/TemplateContent/ExpressionDecorator.d.ts +5 -0
  112. package/src/lib/TemplateContent/TemplateContentEditor.d.ts +9 -0
  113. package/src/lib/TemplateContent/{index.ts → index.d.ts} +1 -1
  114. package/src/lib/{index.ts → index.d.ts} +15 -14
  115. package/src/utils/common.d.ts +7 -0
  116. package/src/utils/dem.d.ts +7 -0
  117. package/src/utils/hooks.d.ts +7 -0
  118. package/src/utils/{index.ts → index.d.ts} +5 -5
  119. package/src/utils/ui-utils.d.ts +7 -0
  120. package/src/utils/validators.d.ts +12 -0
  121. package/.babelrc +0 -12
  122. package/.eslintrc.json +0 -22
  123. package/jest.config.js +0 -9
  124. package/project.json +0 -69
  125. package/rollup.config.js +0 -135
  126. package/src/interfaces/common.ts +0 -12
  127. package/src/interfaces/definition.ts +0 -143
  128. package/src/interfaces/ui.ts +0 -35
  129. package/src/lib/Alert/Alert.tsx +0 -108
  130. package/src/lib/Alert/index.ts +0 -1
  131. package/src/lib/Definition/CreateDefinition/CreateDefinition.tsx +0 -74
  132. package/src/lib/Definition/DefinitionFiller/DefinitionFiller.tsx +0 -85
  133. package/src/lib/Definition/DefinitionFiller/WidgetDefinitionFiller.tsx +0 -96
  134. package/src/lib/DemPropertyField/DemPropertyField.tsx +0 -93
  135. package/src/lib/DemPropertyField/DemPropertyView/DemPropertyView.tsx +0 -44
  136. package/src/lib/DemPropertyField/MultipleDemField/MultipleDemField.tsx +0 -293
  137. package/src/lib/DemPropertyField/RestrictedValuesEditor.tsx +0 -63
  138. package/src/lib/DemPropertyField/SingleDemField/SingleDemField.tsx +0 -156
  139. package/src/lib/DemPropertyField/styles.ts +0 -50
  140. package/src/lib/DemPropertyField/widgets/DemBooleanWidget.tsx +0 -26
  141. package/src/lib/DemPropertyField/widgets/DemDateTimeWidget.tsx +0 -34
  142. package/src/lib/DemPropertyField/widgets/DemDateWidget.tsx +0 -33
  143. package/src/lib/DemPropertyField/widgets/DemFieldWidget.tsx +0 -67
  144. package/src/lib/DemPropertyField/widgets/DemFloatWidget.tsx +0 -49
  145. package/src/lib/DemPropertyField/widgets/DemIntegerWidget.tsx +0 -63
  146. package/src/lib/DemPropertyField/widgets/DemJsonWidget.tsx +0 -33
  147. package/src/lib/DemPropertyField/widgets/DemStringWidget.tsx +0 -35
  148. package/src/lib/DemPropertyField/widgets/DemTimeWidget.tsx +0 -46
  149. package/src/lib/Forms/BackButton.tsx +0 -45
  150. package/src/lib/Forms/ControlAceEditor.tsx +0 -103
  151. package/src/lib/Forms/ControlAutocomplete.tsx +0 -134
  152. package/src/lib/Forms/ControlCheckbox.tsx +0 -57
  153. package/src/lib/Forms/ControlDebouncedInput.tsx +0 -69
  154. package/src/lib/Forms/ControlInput.tsx +0 -102
  155. package/src/lib/Forms/ControlNumberInput.tsx +0 -144
  156. package/src/lib/Forms/ControlRadioBtn.tsx +0 -46
  157. package/src/lib/Forms/ControlSelect.tsx +0 -135
  158. package/src/lib/Forms/CopyButton.tsx +0 -49
  159. package/src/lib/InfoItem/InfoItem.tsx +0 -39
  160. package/src/lib/InfoItem/styles.ts +0 -17
  161. package/src/lib/JsonPathPicker/JsonPathPicker.tsx +0 -71
  162. package/src/lib/JsonPathPicker/PropertyStep.tsx +0 -74
  163. package/src/lib/JsonView/JsonView.tsx +0 -43
  164. package/src/lib/Loader/Loader.tsx +0 -41
  165. package/src/lib/Modals/JsonModalView.tsx +0 -52
  166. package/src/lib/Property/PropertyValueField/BooleanValueField.tsx +0 -41
  167. package/src/lib/Property/PropertyValueField/DateTimeValueField.tsx +0 -59
  168. package/src/lib/Property/PropertyValueField/DateValueField.tsx +0 -59
  169. package/src/lib/Property/PropertyValueField/EntityValueField.tsx +0 -33
  170. package/src/lib/Property/PropertyValueField/JsonValueField.tsx +0 -64
  171. package/src/lib/Property/PropertyValueField/PropertyValue.tsx +0 -97
  172. package/src/lib/Property/PropertyValueField/PropertyValueField.tsx +0 -86
  173. package/src/lib/Property/PropertyValueField/StringValueField.tsx +0 -21
  174. package/src/lib/Property/PropertyValueField/TimeValueField.tsx +0 -68
  175. package/src/lib/Property/PropertyValueField/ValueComponent.tsx +0 -63
  176. package/src/lib/Property/PropertyWidget/PropertyWidget.tsx +0 -167
  177. package/src/lib/Property/UpsertProperty/CreatePropertiesList.tsx +0 -131
  178. package/src/lib/Property/UpsertProperty/CreatePropertyFormFields.tsx +0 -147
  179. package/src/lib/Property/UpsertProperty/CustomPropertyField.tsx +0 -40
  180. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/BigDecimalPropertyFields.tsx +0 -41
  181. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/DateAdditionalFields.tsx +0 -27
  182. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityAdditionalFields.tsx +0 -133
  183. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityReferencePropertyFields.tsx +0 -46
  184. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/PropertyAdditionalFields.tsx +0 -52
  185. package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/StringPropertyFields.tsx +0 -98
  186. package/src/lib/Property/UpsertProperty/useCustomFields.ts +0 -22
  187. package/src/lib/Property/ViewPropertiesList/ViewPropertiesList.tsx +0 -50
  188. package/src/lib/Property/ViewProperty/EntityPropertiesShortView.tsx +0 -41
  189. package/src/lib/Property/ViewProperty/EntityPropertiesView.tsx +0 -48
  190. package/src/lib/Property/ViewProperty/PropertyDataTable.tsx +0 -139
  191. package/src/lib/Property/ViewProperty/PropertyItem.tsx +0 -46
  192. package/src/lib/Property/ViewProperty/ViewProperty.tsx +0 -52
  193. package/src/lib/Status/Status.tsx +0 -15
  194. package/src/lib/Status/styles.ts +0 -14
  195. package/src/lib/Table/Table.tsx +0 -116
  196. package/src/lib/Table/TableColumnMenu.tsx +0 -12
  197. package/src/lib/Table/TablePagination.tsx +0 -42
  198. package/src/lib/Table/index.ts +0 -1
  199. package/src/lib/Table/styles.ts +0 -59
  200. package/src/lib/Table/usePagination.ts +0 -15
  201. package/src/lib/Table/useTableQueryPagination.ts +0 -49
  202. package/src/lib/Table/useTableQuerySorting.ts +0 -52
  203. package/src/lib/Tabs/RouteTabs.tsx +0 -54
  204. package/src/lib/Tabs/TabPanel.tsx +0 -42
  205. package/src/lib/TemplateContent/ExpressionDecorator.tsx +0 -7
  206. package/src/lib/TemplateContent/TemplateContentEditor.tsx +0 -144
  207. package/src/utils/common.ts +0 -68
  208. package/src/utils/dem.ts +0 -78
  209. package/src/utils/hooks.ts +0 -41
  210. package/src/utils/ui-utils.tsx +0 -71
  211. package/src/utils/validators.ts +0 -130
  212. package/tsconfig.json +0 -24
  213. package/tsconfig.lib.json +0 -22
  214. package/tsconfig.spec.json +0 -19
@@ -1,74 +0,0 @@
1
- import Stepper from '@material-ui/core/Stepper';
2
- import Step from '@material-ui/core/Step';
3
- import StepLabel from '@material-ui/core/StepLabel';
4
- import StepContent from '@material-ui/core/StepContent';
5
-
6
- import { EntityTypeProperty, PropertiesArrayType, PropertyType } from '../../interfaces';
7
- import { makeStyles } from '@material-ui/core/styles';
8
-
9
- type Props = {
10
- properties: PropertiesArrayType;
11
- parentKey?: string;
12
- activePath: string;
13
- prefix?: string;
14
- onClick: (path: string) => void;
15
- };
16
-
17
- const useStyles = makeStyles(() => ({
18
- propertyStepLabel: {
19
- '&:hover': {
20
- fontWeight: '600',
21
- cursor: 'pointer',
22
- },
23
- },
24
- }));
25
-
26
- const PropertyStep = ({ properties, parentKey = '', activePath = '', prefix = '', onClick }: Props) => {
27
- const classes = useStyles();
28
-
29
- const handleClick = (path: string) => {
30
- if (prefix) {
31
- onClick(`${prefix}.${path}`);
32
- } else {
33
- onClick(path);
34
- }
35
- };
36
-
37
- return (
38
- <Stepper orientation="vertical" onClick={(event) => event.stopPropagation()}>
39
- {properties.map((property) => {
40
- const fullPropertyPath = parentKey ? `${parentKey}.${property.key}` : property.key;
41
- let propertyType;
42
- if (typeof property.propertyType === 'string') {
43
- propertyType = property.propertyType;
44
- } else {
45
- propertyType = property.propertyType['value'];
46
- }
47
- return (
48
- <Step expanded key={property.key} onClick={() => handleClick(fullPropertyPath)}>
49
- <StepLabel StepIconProps={{ icon: '', completed: false, active: activePath === fullPropertyPath }}>
50
- <div className={classes.propertyStepLabel}>
51
- {property.name} - {property.key} - {propertyType}
52
- </div>
53
- </StepLabel>
54
- <StepContent>
55
- <div>
56
- {propertyType === PropertyType.ENTITY && (
57
- <PropertyStep
58
- key={property.key}
59
- onClick={onClick}
60
- activePath={activePath}
61
- properties={(property as EntityTypeProperty).properties as PropertiesArrayType}
62
- parentKey={fullPropertyPath}
63
- />
64
- )}
65
- </div>
66
- </StepContent>
67
- </Step>
68
- );
69
- })}
70
- </Stepper>
71
- );
72
- };
73
-
74
- export default PropertyStep;
@@ -1,43 +0,0 @@
1
- import { useMemo } from 'react';
2
- import AceEditor from 'react-ace';
3
- import 'ace-builds/src-noconflict/ace';
4
- import 'ace-builds/src-noconflict/mode-json';
5
-
6
- type Props = {
7
- value: unknown;
8
- height?: string;
9
- };
10
-
11
- export const JsonView = ({ value, height = '200px' }: Props) => {
12
- const stringValue = useMemo(() => {
13
- if (typeof value === 'string') {
14
- return value;
15
- } else if (typeof value === 'object') {
16
- try {
17
- return JSON.stringify(value, null, '\t');
18
- } catch (error) {
19
- return 'Failed to parse JSON';
20
- }
21
- }
22
- return null;
23
- }, [value]);
24
-
25
- return (
26
- <AceEditor
27
- readOnly
28
- value={stringValue}
29
- mode="json"
30
- width="100%"
31
- height={height}
32
- fontSize="16"
33
- setOptions={{
34
- enableSnippets: false,
35
- copyWithEmptySelection: true,
36
- showLineNumbers: true,
37
- tabSize: 2,
38
- }}
39
- />
40
- );
41
- };
42
-
43
- export default JsonView;
@@ -1,41 +0,0 @@
1
- import Box from "@material-ui/core/Box";
2
- import CircularProgress from "@material-ui/core/CircularProgress";
3
-
4
- /**
5
- * This interface is referencing the [[Loader]] component props.
6
- * @category Common UI components
7
- */
8
- export interface LoaderProps {
9
- /**
10
- * Background transparency flag. Default: `rgba(255, 255, 255, .3)`
11
- */
12
- transparent?: boolean;
13
- /**
14
- * CSS `position` property. Default: `absolute`
15
- */
16
- position?: string;
17
- }
18
- /**
19
- * Loader screen component. Used in the data loading process
20
- * @category Common UI components
21
- */
22
- export const Loader = ({ transparent, position }: LoaderProps) => {
23
- return (
24
- <Box
25
- position={position ?? 'absolute'}
26
- top={0}
27
- left={0}
28
- width="100%"
29
- height="100%"
30
- display="flex"
31
- alignItems="center"
32
- justifyContent="center"
33
- bgcolor={transparent ? 'none' : 'rgba(255, 255, 255, .3)'}
34
- zIndex={10}
35
- >
36
- <CircularProgress />
37
- </Box>
38
- )
39
- }
40
-
41
- export default Loader;
@@ -1,52 +0,0 @@
1
- import React from 'react';
2
- import AceEditor from 'react-ace';
3
- import 'ace-builds/src-noconflict/ace';
4
- import 'ace-builds/src-noconflict/mode-json';
5
- import Dialog from '@material-ui/core/Dialog';
6
- import DialogContent from '@material-ui/core/DialogContent';
7
- import DialogActions from '@material-ui/core/DialogActions';
8
- import Button from '@material-ui/core/Button';
9
- import { CopyButton } from '../Forms';
10
-
11
- type Props = {
12
- open: boolean;
13
- value: string;
14
- onClose: () => void;
15
- };
16
-
17
- export const JsonModalView: React.FC<Props> = ({ open, onClose, value }) => {
18
- return (
19
- <Dialog
20
- disableEscapeKeyDown
21
- open={open}
22
- onClose={onClose}
23
- fullWidth
24
- maxWidth="md"
25
- style={{ width: 800, left: '30%' }}
26
- >
27
- <DialogContent>
28
- <AceEditor
29
- readOnly
30
- value={value}
31
- mode="json"
32
- width="100%"
33
- fontSize="16"
34
- setOptions={{
35
- enableSnippets: false,
36
- copyWithEmptySelection: true,
37
- showLineNumbers: true,
38
- tabSize: 2,
39
- }}
40
- />
41
- </DialogContent>
42
- <DialogActions>
43
- <CopyButton copyText={value} />
44
- <Button onClick={onClose} variant="contained" color="secondary">
45
- Close
46
- </Button>
47
- </DialogActions>
48
- </Dialog>
49
- );
50
- };
51
-
52
- export default JsonModalView;
@@ -1,41 +0,0 @@
1
- import Switch from '@material-ui/core/Switch';
2
- import Typography from '@material-ui/core/Typography';
3
- import FormControlLabel from '@material-ui/core/FormControlLabel';
4
- import { Controller, useFormContext } from 'react-hook-form';
5
-
6
- type Props = {
7
- name: string;
8
- label?: string;
9
- };
10
-
11
- const BooleanValueField = ({ name, label = '' }: Props) => {
12
- const { control } = useFormContext();
13
-
14
- return (
15
- <>
16
- <Typography>{label}</Typography>
17
- <Controller
18
- control={control}
19
- name={name}
20
- render={({ field }) => (
21
- <FormControlLabel
22
- label={(!!field.value + '').toUpperCase()}
23
- control={
24
- <Switch
25
- color="primary"
26
- size="small"
27
- onChange={(e) => {
28
- const { checked } = e.target;
29
- field.onChange(checked);
30
- }}
31
- checked={!!field.value + '' === 'true'}
32
- />
33
- }
34
- />
35
- )}
36
- />
37
- </>
38
- );
39
- };
40
-
41
- export default BooleanValueField;
@@ -1,59 +0,0 @@
1
- import TextField from '@mui/material/TextField';
2
- import { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker';
3
-
4
- import { format as dateFnsFormat, isValid } from 'date-fns';
5
- import { Controller, useFormContext } from 'react-hook-form';
6
- import { DATE_TIME_DEFAULT_FORMAT } from '../../../interfaces';
7
-
8
- type Props = {
9
- name: string;
10
- label?: string;
11
- required?: boolean;
12
- format?: string;
13
- };
14
-
15
- const DateTimeValueField = ({ name, label, required = false, format = DATE_TIME_DEFAULT_FORMAT }: Props) => {
16
- const { control, setError, clearErrors } = useFormContext();
17
-
18
- const onError = (err) => {
19
- if (err) {
20
- setError(name, { type: 'custom', message: 'Incorrect date format' });
21
- } else {
22
- clearErrors(name);
23
- }
24
- };
25
-
26
- return (
27
- <Controller
28
- control={control}
29
- name={name}
30
- rules={{ required: required && 'Required field' }}
31
- render={({ field: { ref, value, onChange }, fieldState: { error } }) => (
32
- <DateTimePicker
33
- clearable
34
- ampm={false}
35
- inputRef={ref}
36
- label={label}
37
- value={value || null}
38
- inputFormat={format}
39
- onError={onError}
40
- onChange={(date) => {
41
- onChange(isValid(date) ? dateFnsFormat(date, format) : date);
42
- }}
43
- renderInput={(props) => (
44
- <TextField
45
- {...props}
46
- fullWidth
47
- size="small"
48
- variant="outlined"
49
- error={!!error}
50
- helperText={error?.message}
51
- />
52
- )}
53
- />
54
- )}
55
- />
56
- );
57
- };
58
-
59
- export default DateTimeValueField;
@@ -1,59 +0,0 @@
1
- import TextField from '@mui/material/TextField';
2
- import { DatePicker } from '@mui/x-date-pickers/DatePicker';
3
-
4
- import { format as dateFnsFormat, isValid } from 'date-fns';
5
- import { Controller, useFormContext } from 'react-hook-form';
6
- import { DATE_DEFAULT_FORMAT } from '../../../interfaces';
7
-
8
- type Props = {
9
- name: string;
10
- format: string;
11
- label?: string;
12
- required?: boolean;
13
- };
14
-
15
- const DateValueField = ({ name, label = '', required = false, format = DATE_DEFAULT_FORMAT }: Props) => {
16
- const { control, setError, clearErrors } = useFormContext();
17
-
18
- const onError = (err) => {
19
- if (err) {
20
- setError(name, { type: 'custom', message: 'Incorrect date format' });
21
- } else {
22
- clearErrors(name);
23
- }
24
- };
25
-
26
- return (
27
- <Controller
28
- control={control}
29
- name={name}
30
- rules={{ required: required && 'Required field' }}
31
- render={({ field: { ref, value, onChange }, fieldState: { error } }) => (
32
- <DatePicker
33
- clearable
34
- mask=""
35
- label={label}
36
- inputRef={ref}
37
- inputFormat={format}
38
- value={value || null}
39
- onError={onError}
40
- onChange={(date) => {
41
- onChange(isValid(date) ? dateFnsFormat(date, format) : date);
42
- }}
43
- renderInput={(props) => (
44
- <TextField
45
- {...props}
46
- fullWidth
47
- size="small"
48
- variant="outlined"
49
- error={!!error}
50
- helperText={error?.message}
51
- />
52
- )}
53
- />
54
- )}
55
- />
56
- );
57
- };
58
-
59
- export default DateValueField;
@@ -1,33 +0,0 @@
1
- import Step from '@material-ui/core/Step';
2
- import StepContent from '@material-ui/core/StepContent';
3
- import StepLabel from '@material-ui/core/StepLabel';
4
- import Stepper from '@material-ui/core/Stepper';
5
- import PropertyValue from './PropertyValue';
6
-
7
- import { PropertiesArrayType } from '../../../interfaces';
8
-
9
- type Props = {
10
- label?: string;
11
- name?: string;
12
- properties: PropertiesArrayType;
13
- };
14
-
15
- const EntityValueField = ({ name, properties }: Props) => {
16
- return properties && properties.length ? (
17
- <Stepper nonLinear orientation="vertical">
18
- {properties.map((property, index) => (
19
- <Step expanded key={index}>
20
- <StepLabel StepIconProps={{ icon: '', completed: false, active: true }}>
21
- {property.name} - {property.key}
22
- </StepLabel>
23
- <StepContent>
24
- <PropertyValue name={`${name}.${property.key}`} property={property} label={property.name} />
25
- </StepContent>
26
- </Step>
27
- ))}
28
- <Step />
29
- </Stepper>
30
- ) : null;
31
- };
32
-
33
- export default EntityValueField;
@@ -1,64 +0,0 @@
1
- import AceEditor from 'react-ace';
2
- import FormHelperText from '@material-ui/core/FormHelperText';
3
- import Typography from '@material-ui/core/Typography';
4
- import { Controller, useFormContext } from 'react-hook-form';
5
-
6
- import 'ace-builds/src-noconflict/ace';
7
- import 'ace-builds/src-noconflict/mode-json';
8
-
9
- type Props = {
10
- name: string;
11
- label?: string;
12
- required?: boolean;
13
- };
14
-
15
- const JsonValueField = ({ name, label, required = false }: Props) => {
16
- const { control, setError, clearErrors } = useFormContext();
17
-
18
- return (
19
- <>
20
- <Typography>{label}</Typography>
21
- <Controller
22
- control={control}
23
- name={name}
24
- rules={{
25
- required: required && 'Required field',
26
- }}
27
- render={({ field: { value, onChange }, fieldState: { error } }) => (
28
- <>
29
- <AceEditor
30
- value={value && typeof value !== 'string' ? JSON.stringify(value, null, 2) : value}
31
- onChange={(value) => {
32
- if (!value) {
33
- onChange('');
34
- return null;
35
- }
36
- try {
37
- clearErrors(name);
38
- const val = JSON.parse(value);
39
- onChange(Array.isArray(val) ? '' : val);
40
- } catch (e) {
41
- setError(name, { message: 'Invalid JSON' });
42
- onChange(value);
43
- }
44
- }}
45
- mode="json"
46
- width="100%"
47
- height="200px"
48
- fontSize="16"
49
- setOptions={{
50
- enableSnippets: false,
51
- copyWithEmptySelection: true,
52
- showLineNumbers: true,
53
- tabSize: 2,
54
- }}
55
- />
56
- {error && <FormHelperText error>{error.message}</FormHelperText>}
57
- </>
58
- )}
59
- />
60
- </>
61
- );
62
- };
63
-
64
- export default JsonValueField;
@@ -1,97 +0,0 @@
1
- import Box from '@material-ui/core/Box';
2
- import Grid from '@material-ui/core/Grid';
3
- import Button from '@material-ui/core/Button';
4
- import Typography from '@material-ui/core/Typography';
5
- import IconButton from '@material-ui/core/IconButton';
6
- import CloseIcon from '@material-ui/icons/Close';
7
- import ValueComponent, { ValueComponentProps } from './ValueComponent';
8
-
9
- import { useCallback, useMemo } from 'react';
10
- import { useFormContext, useWatch } from 'react-hook-form';
11
-
12
- import { PropertyUnion } from '../../../interfaces';
13
- import { removeArrayItem } from '../../../utils';
14
-
15
- type Props = {
16
- property: PropertyUnion;
17
- name: string;
18
- label?: string;
19
- required?: boolean | 'byProperty';
20
- };
21
-
22
- const PropertyValue = ({ property, name, label, required = 'byProperty' }: Props) => {
23
- const { control, setValue } = useFormContext();
24
- const values = useWatch({ control, name });
25
-
26
- const handleDeleteValue = useCallback(
27
- (index) => {
28
- setValue(name, removeArrayItem(values, index));
29
- },
30
- [name, values]
31
- );
32
-
33
- const handleAddValue = useCallback(() => {
34
- if (values && Array.isArray(values)) {
35
- setValue(`${name}.${values.length}`, null);
36
- } else {
37
- setValue(name, [null]);
38
- }
39
- }, [name, values]);
40
-
41
- const valueComponentProps: ValueComponentProps = useMemo(
42
- () => ({
43
- control,
44
- name,
45
- label,
46
- required: required === 'byProperty' ? property.isRequired : required,
47
- propertyType: typeof property.propertyType === 'string' ? property.propertyType : property.propertyType['value'],
48
- format: property['format'],
49
- restrictedValues: property['restrictedValues'],
50
- properties: property['properties'],
51
- }),
52
- [
53
- name,
54
- label,
55
- required,
56
- property.propertyType,
57
- property['format'],
58
- property['restrictedValues'],
59
- property['properties'],
60
- ]
61
- );
62
-
63
- return property.isMultiple ? (
64
- <Grid item container spacing={2} direction="column">
65
- <Grid item>
66
- <Typography variant="h6">{label}</Typography>
67
- </Grid>
68
- {values && Array.isArray(values) ? (
69
- <>
70
- {values.map((_, index) => (
71
- <Grid item key={index}>
72
- <Box display="flex" alignItems="center">
73
- <ValueComponent
74
- {...valueComponentProps}
75
- label={`${property.name} (${index})`}
76
- name={`${name}.${index}`}
77
- />
78
- <IconButton size="small" onClick={() => handleDeleteValue(index)}>
79
- <CloseIcon fontSize="small" />
80
- </IconButton>
81
- </Box>
82
- </Grid>
83
- ))}
84
- </>
85
- ) : null}
86
- <Grid item>
87
- <Button variant="contained" size="small" color="primary" onClick={handleAddValue}>
88
- Add value
89
- </Button>
90
- </Grid>
91
- </Grid>
92
- ) : (
93
- <ValueComponent {...valueComponentProps} />
94
- );
95
- };
96
-
97
- export default PropertyValue;
@@ -1,86 +0,0 @@
1
- import Box from '@material-ui/core/Box';
2
- import Grid from '@material-ui/core/Grid';
3
- import Button from '@material-ui/core/Button';
4
- import Typography from '@material-ui/core/Typography';
5
- import IconButton from '@material-ui/core/IconButton';
6
- import CloseIcon from '@material-ui/icons/Close';
7
- import ValueComponent, { ValueComponentProps } from './ValueComponent';
8
-
9
- import { useCallback, useEffect, useMemo } from 'react';
10
- import { useFormContext, useWatch } from 'react-hook-form';
11
- import { removeArrayItem } from '../../../utils';
12
-
13
- type Props = {
14
- propertyFieldName: string;
15
- name: string;
16
- label?: string;
17
- required?: boolean;
18
- };
19
-
20
- export const PropertyValueField = ({ propertyFieldName, name, label = '', required }: Props) => {
21
- const { control, setValue } = useFormContext();
22
-
23
- const propertyType = useWatch({ control, name: `${propertyFieldName}.propertyType` });
24
- const isMultiple = useWatch({ control, name: `${propertyFieldName}.isMultiple` });
25
- const format = useWatch({ control, name: `${propertyFieldName}.format` });
26
- const restrictedValues = useWatch({ control, name: `${propertyFieldName}.restrictedValues` });
27
- const properties = useWatch({ control, name: `${propertyFieldName}.properties` });
28
- const values = useWatch({ control, name });
29
-
30
- useEffect(() => {
31
- if (isMultiple && !Array.isArray(values)) {
32
- setValue(name, [values]);
33
- } else if (!isMultiple && Array.isArray(values)) {
34
- setValue(name, values[0]);
35
- }
36
- }, [isMultiple, values, name]);
37
-
38
- const valueComponentProps: ValueComponentProps = useMemo(() => {
39
- const typeValue = typeof propertyType === 'string' ? propertyType : propertyType.value;
40
- return { control, name, label, required, format, restrictedValues, properties, propertyType: typeValue };
41
- }, [propertyType, format, restrictedValues, name, label, required, properties]);
42
-
43
- const handleDeleteValue = useCallback(
44
- (index) => {
45
- setValue(name, removeArrayItem(values, index));
46
- },
47
- [name, values]
48
- );
49
-
50
- const handleAddValue = useCallback(() => {
51
- if (values && Array.isArray(values)) {
52
- setValue(`${name}.${values.length}`, null);
53
- } else {
54
- setValue(name, [null]);
55
- }
56
- }, [name, values]);
57
-
58
- return isMultiple ? (
59
- values && Array.isArray(values) ? (
60
- <Grid item container spacing={2} direction="column">
61
- <Grid item>
62
- <Typography variant="h6">{label}</Typography>
63
- </Grid>
64
- {values.map((_, index) => (
65
- <Grid item key={index}>
66
- <Box display="flex" alignItems="center">
67
- <ValueComponent {...valueComponentProps} label="" name={`${name}.${index}`} />
68
- <IconButton size="small" onClick={() => handleDeleteValue(index)}>
69
- <CloseIcon fontSize="small" />
70
- </IconButton>
71
- </Box>
72
- </Grid>
73
- ))}
74
- <Grid item>
75
- <Button variant="contained" size="small" color="primary" onClick={handleAddValue}>
76
- Add value
77
- </Button>
78
- </Grid>
79
- </Grid>
80
- ) : null
81
- ) : (
82
- <ValueComponent {...valueComponentProps} />
83
- );
84
- };
85
-
86
- export default PropertyValueField;
@@ -1,21 +0,0 @@
1
- import { useFormContext, useWatch } from 'react-hook-form';
2
- import { ControlInput, ControlSelect } from '../../Forms';
3
-
4
- type Props = {
5
- name: string;
6
- label?: string;
7
- required?: boolean;
8
- restrictedValues?: string[];
9
- };
10
-
11
- const StringValueField = ({ name, label, required = false, restrictedValues }: Props) => {
12
- const { control } = useFormContext();
13
-
14
- return Array.isArray(restrictedValues) && restrictedValues.length ? (
15
- <ControlSelect required={required} control={control} name={name} label={label} options={restrictedValues} />
16
- ) : (
17
- <ControlInput required={required} control={control} name={name} label={label} />
18
- );
19
- };
20
-
21
- export default StringValueField;