@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,68 +0,0 @@
1
- import TextField from '@mui/material/TextField';
2
- import { TimePicker } from '@mui/x-date-pickers/TimePicker';
3
-
4
- import { format as dateFnsFormat, isValid, parse } from 'date-fns';
5
- import { useEffect, useState } from 'react';
6
- import { useController, useFormContext } from 'react-hook-form';
7
- import { TIME_DEFAULT_FORMAT } from '../../../interfaces';
8
-
9
- type Props = {
10
- name: string;
11
- label?: string;
12
- format?: string;
13
- required?: boolean;
14
- };
15
-
16
- const TimeValueField = ({ name, label, format = TIME_DEFAULT_FORMAT, required = false }: Props) => {
17
- const { control, setError, clearErrors } = useFormContext();
18
- const {
19
- field: { ref, onChange, value },
20
- fieldState: { error },
21
- } = useController({ control, name, rules: { required: required && 'Required field' } });
22
-
23
- const [fieldValue, setFieldValue] = useState(null);
24
-
25
- useEffect(() => {
26
- if (value && format) {
27
- let parsedValue = parse(value, format, new Date());
28
-
29
- if (!isValid(parsedValue)) {
30
- parsedValue = parse(value, 'HH:mm:ss.SSS', new Date());
31
- }
32
-
33
- setFieldValue(parsedValue);
34
- }
35
- }, [value, format]);
36
-
37
- const handleChange = (date: Date) => {
38
- setFieldValue(date);
39
- onChange(isValid(date) ? dateFnsFormat(date, format) : date);
40
- };
41
-
42
- const onError = (err) => {
43
- if (err) {
44
- setError(name, { type: 'custom', message: 'Incorrect date format' });
45
- } else {
46
- clearErrors(name);
47
- }
48
- };
49
-
50
- return (
51
- <TimePicker
52
- clearable
53
- mask=""
54
- inputRef={ref}
55
- label={label}
56
- ampm={false}
57
- value={fieldValue}
58
- inputFormat={format}
59
- onError={onError}
60
- onChange={handleChange}
61
- renderInput={(props) => (
62
- <TextField {...props} fullWidth size="small" variant="outlined" error={!!error} helperText={error?.message} />
63
- )}
64
- />
65
- );
66
- };
67
-
68
- export default TimeValueField;
@@ -1,63 +0,0 @@
1
- import { PropertiesArrayType, PropertyType } from '../../../interfaces';
2
- import { Control } from 'react-hook-form';
3
- import { DefinitionFiller } from '../../Definition';
4
- import { ControlInput, ControlNumberInput } from '../../Forms';
5
- import BooleanValueField from './BooleanValueField';
6
- import DateTimeValueField from './DateTimeValueField';
7
- import DateValueField from './DateValueField';
8
- import JsonValueField from './JsonValueField';
9
- import StringValueField from './StringValueField';
10
- import TimeValueField from './TimeValueField';
11
-
12
- export type ValueComponentProps = {
13
- control: Control;
14
- propertyType: PropertyType;
15
- name: string;
16
- label: string;
17
- required: boolean;
18
- format?: string;
19
- restrictedValues?: string[];
20
- properties?: PropertiesArrayType;
21
- };
22
-
23
- const ValueComponent = ({
24
- propertyType,
25
- control,
26
- name,
27
- label,
28
- required,
29
- format,
30
- restrictedValues,
31
- properties,
32
- }: ValueComponentProps) => {
33
- switch (propertyType) {
34
- case PropertyType.BIG_DECIMAL:
35
- case PropertyType.FLOAT:
36
- case PropertyType.DOUBLE:
37
- return <ControlNumberInput decimal control={control} name={name} label={label} required={required} />;
38
- case PropertyType.INTEGER:
39
- case PropertyType.BIG_INTEGER:
40
- case PropertyType.LONG:
41
- return <ControlNumberInput control={control} name={name} label={label} required={required} />;
42
- case PropertyType.BOOLEAN:
43
- return <BooleanValueField name={name} label={label} />;
44
- case PropertyType.DATE:
45
- return <DateValueField name={name} label={label} format={format} required={required} />;
46
- case PropertyType.TIME:
47
- return <TimeValueField name={name} label={label} format={format} required={required} />;
48
- case PropertyType.DATE_TIME:
49
- return <DateTimeValueField name={name} label={label} format={format} required={required} />;
50
- case PropertyType.JSON:
51
- return <JsonValueField name={name} label={label} required={required} />;
52
- case PropertyType.STRING:
53
- return <StringValueField name={name} label={label} required={required} restrictedValues={restrictedValues} />;
54
- case PropertyType.ENTITY_REFERENCE:
55
- return <ControlInput name={name} control={control} label={label} required={required} />;
56
- case PropertyType.ENTITY:
57
- return <DefinitionFiller dataFieldName={name} properties={properties} />;
58
- default:
59
- return null;
60
- }
61
- };
62
-
63
- export default ValueComponent;
@@ -1,167 +0,0 @@
1
- import Box from '@material-ui/core/Box';
2
- import Select from '@material-ui/core/Select';
3
- import MenuItem from '@material-ui/core/MenuItem';
4
- import FormControl from '@material-ui/core/FormControl';
5
- import InputLabel from '@material-ui/core/InputLabel';
6
- import Typography from '@material-ui/core/Typography';
7
- import { ControlAceEditor, ControlInput } from '../../Forms';
8
- import PropertyValue from '../PropertyValueField/PropertyValue';
9
- import { WidgetDefinitionFiller } from '../../Definition';
10
-
11
- import { useEffect, useMemo, useState } from 'react';
12
- import { useController, useFormContext, useWatch } from 'react-hook-form';
13
- import { getEntityStarterValue, isExpression } from '../../../utils';
14
-
15
- import { PropertyType, PropertyUnion } from '../../../interfaces';
16
-
17
- type Props = {
18
- property: PropertyUnion;
19
- nullable?: boolean;
20
- name: string;
21
- };
22
-
23
- type InputType = 'expression' | 'widget' | 'null' | 'string';
24
-
25
- const getInputTypes = (propertyType: PropertyType, nullable: boolean): { value: InputType; label: string }[] => {
26
- const options: { value: InputType; label: string }[] = [
27
- {
28
- value: 'widget',
29
- label: 'Widget',
30
- },
31
- {
32
- value: 'expression',
33
- label: 'Expression',
34
- },
35
- ];
36
-
37
- if (nullable) {
38
- options.push({
39
- value: 'null',
40
- label: 'NULL',
41
- });
42
- }
43
-
44
- switch (propertyType) {
45
- case PropertyType.STRING:
46
- options[0].label = 'Text input';
47
- break;
48
- case PropertyType.INTEGER:
49
- case PropertyType.BIG_INTEGER:
50
- case PropertyType.BIG_DECIMAL:
51
- case PropertyType.FLOAT:
52
- case PropertyType.LONG:
53
- case PropertyType.DOUBLE:
54
- options[0].label = 'Number input';
55
- break;
56
- case PropertyType.BOOLEAN:
57
- options[0].label = 'Checkbox';
58
- break;
59
- case PropertyType.ENTITY_REFERENCE:
60
- options[0].label = 'Entity reference fields';
61
- break;
62
- case PropertyType.JSON:
63
- options[0].label = 'JSON';
64
- break;
65
- case PropertyType.DATE:
66
- options[0].label = 'Date';
67
- options.push({ value: 'string', label: 'Text input' });
68
- break;
69
- case PropertyType.DATE_TIME:
70
- options[0].label = 'Date time';
71
- options.push({ value: 'string', label: 'Text input' });
72
- break;
73
- case PropertyType.TIME:
74
- options[0].label = 'Time';
75
- options.push({ value: 'string', label: 'Text input' });
76
- break;
77
- default:
78
- break;
79
- }
80
-
81
- return options;
82
- };
83
-
84
- export const PropertyWidget = ({ property, name = '', nullable = false }: Props) => {
85
- const { control, setValue } = useFormContext();
86
- const {
87
- fieldState: { error },
88
- } = useController({ name });
89
- const value = useWatch({ control, name });
90
-
91
- const [inputType, setInputType] = useState<InputType>('widget');
92
-
93
- const inputOptions = useMemo(
94
- () => getInputTypes(property.propertyType, nullable && !property.isRequired),
95
- [property, nullable]
96
- );
97
-
98
- const handleInputTypeChange = (event: React.ChangeEvent<{ value: InputType }>) => {
99
- setInputType(event.target.value);
100
- };
101
-
102
- useEffect(() => {
103
- if (value && !inputType) {
104
- if (value === null && nullable && !property.isRequired) {
105
- setInputType('null');
106
- } else if (isExpression(inputType)) {
107
- setInputType('expression');
108
- } else {
109
- setInputType('widget');
110
- }
111
- }
112
- }, [value, inputType, property.isRequired, nullable]);
113
-
114
- useEffect(() => {
115
- if (!value && inputType === 'expression' && property.propertyType === PropertyType.ENTITY) {
116
- setValue(name, JSON.stringify(getEntityStarterValue(property), null, 2));
117
- }
118
- }, [value, inputType, property.propertyType]);
119
-
120
- return (
121
- <>
122
- {inputOptions.length ? (
123
- <>
124
- <Box mb={2}>
125
- <FormControl fullWidth size="small" variant="outlined">
126
- <InputLabel htmlFor="type-select">Input type</InputLabel>
127
- <Select labelId="type-select" label="Input type" value={inputType} onChange={handleInputTypeChange}>
128
- {inputOptions.map((option) => (
129
- <MenuItem key={option.value} value={option.value}>
130
- {option.label}
131
- </MenuItem>
132
- ))}
133
- </Select>
134
- </FormControl>
135
- </Box>
136
- {inputType ? (
137
- <>
138
- {inputType === 'widget' &&
139
- (property.propertyType === PropertyType.ENTITY ? (
140
- <WidgetDefinitionFiller dataFieldName={name} properties={property.properties} nullable={nullable} />
141
- ) : (
142
- <PropertyValue name={name} property={property} label={property.name} />
143
- ))}
144
- {inputType === 'expression' &&
145
- (property.propertyType === PropertyType.ENTITY || property.propertyType === PropertyType.JSON ? (
146
- <ControlAceEditor
147
- required
148
- mode="json"
149
- fontSize={14}
150
- validateJson={false}
151
- control={control}
152
- name={name}
153
- />
154
- ) : (
155
- <ControlInput required name={name} control={control} label="Expression" />
156
- ))}
157
- {inputType === 'string' && <ControlInput required name={name} control={control} label={'Text input'} />}
158
- </>
159
- ) : null}
160
- </>
161
- ) : null}
162
- {error && <Typography color="secondary">{error.message}</Typography>}
163
- </>
164
- );
165
- };
166
-
167
- export default PropertyWidget;
@@ -1,131 +0,0 @@
1
- import Grid from '@material-ui/core/Grid';
2
- import Button from '@material-ui/core/Button';
3
- import Typography from '@material-ui/core/Typography';
4
- import Accordion from '@material-ui/core/Accordion';
5
- import AccordionSummary from '@material-ui/core/AccordionSummary';
6
- import AccordionDetails from '@material-ui/core/AccordionDetails';
7
- import AccordionActions from '@material-ui/core/AccordionActions';
8
- import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
9
- import CreatePropertyFormFields from './CreatePropertyFormFields';
10
-
11
- import { useCallback, useEffect, useMemo, useRef } from 'react';
12
- import { useController, useFormContext, useWatch } from 'react-hook-form';
13
- import { removeArrayItem } from '../../../utils';
14
- import { CustomPropertyFieldProps } from '../../../interfaces';
15
-
16
- type Props = {
17
- parentFieldName?: string;
18
- hideAddButton?: boolean;
19
- focusOnIndex?: number;
20
- required?: boolean;
21
- entityDefinition?: boolean;
22
- globalParameter?: boolean;
23
- customPropertyFields?: CustomPropertyFieldProps[];
24
- };
25
-
26
- const defaultPropertyValues = {
27
- key: '',
28
- propertyType: '',
29
- name: '',
30
- defaultValue: '',
31
- defaultValues: [],
32
- isRequired: true,
33
- isMultiple: false,
34
- sortOrder: 0,
35
- isEnabled: true,
36
- executeValue: '',
37
- uiSettings: '',
38
- };
39
-
40
- export const CreatePropertiesList = ({
41
- parentFieldName,
42
- hideAddButton,
43
- focusOnIndex,
44
- required,
45
- entityDefinition = false,
46
- globalParameter = false,
47
- customPropertyFields = [],
48
- }: Props) => {
49
- const fieldName = useMemo(
50
- () => (parentFieldName ? `${parentFieldName}.properties` : `properties`),
51
- [parentFieldName]
52
- );
53
-
54
- const { setValue, clearErrors, control } = useFormContext();
55
- const {
56
- fieldState: { error },
57
- } = useController({ control, name: fieldName, rules: { required: required && 'Please, add properties' } });
58
- const properties = useWatch({ control, name: fieldName });
59
-
60
- const refs = useRef([]);
61
-
62
- useEffect(() => {
63
- if (typeof focusOnIndex === 'number' && refs.current[focusOnIndex]) {
64
- refs.current[focusOnIndex].scrollIntoView({
65
- behavior: 'smooth',
66
- block: 'start',
67
- });
68
- }
69
- }, [focusOnIndex, refs]);
70
-
71
- const handleAddParameter = useCallback(() => {
72
- if (properties) {
73
- setValue(`${fieldName}.${properties.length}`, defaultPropertyValues);
74
- } else {
75
- setValue(fieldName, [defaultPropertyValues]);
76
- }
77
- clearErrors(fieldName);
78
- }, [properties, fieldName]);
79
-
80
- const handleRemoveParameter = useCallback(
81
- (index) => {
82
- setValue(`${fieldName}`, removeArrayItem(properties, index));
83
- },
84
- [properties, fieldName]
85
- );
86
-
87
- return (
88
- <>
89
- {error && error.message && (
90
- <Grid item sm={12} md={8} lg={6}>
91
- <Typography color="secondary">{error.message}</Typography>
92
- </Grid>
93
- )}
94
- {properties &&
95
- properties.map((property, index) => (
96
- <Grid item key={index} sm={12} md={8} lg={6} innerRef={(ref) => (refs.current[index] = ref)}>
97
- <Accordion defaultExpanded elevation={3}>
98
- <AccordionSummary expandIcon={<ExpandMoreIcon />}>
99
- <Typography color={error && error[index] ? 'secondary' : 'initial'} style={{ wordBreak: 'break-word' }}>
100
- {property.name || `Property ${index + 1}`}
101
- </Typography>
102
- </AccordionSummary>
103
- <AccordionDetails>
104
- <CreatePropertyFormFields
105
- propertyFieldName={`${fieldName}.${index}`}
106
- entityDefinition={entityDefinition}
107
- globalParameter={globalParameter}
108
- customPropertyFields={customPropertyFields}
109
- />
110
- </AccordionDetails>
111
- <AccordionActions>
112
- <Button variant="contained" size="small" color="secondary" onClick={() => handleRemoveParameter(index)}>
113
- Remove
114
- </Button>
115
- </AccordionActions>
116
- </Accordion>
117
- </Grid>
118
- ))}
119
-
120
- {!hideAddButton && (
121
- <Grid item xs={12}>
122
- <Button variant="contained" size="small" color="primary" onClick={handleAddParameter}>
123
- Add property
124
- </Button>
125
- </Grid>
126
- )}
127
- </>
128
- );
129
- };
130
-
131
- export default CreatePropertiesList;
@@ -1,147 +0,0 @@
1
- import Grid from '@material-ui/core/Grid';
2
- import {
3
- ControlCheckbox,
4
- ControlAutocomplete,
5
- ControlNumberInput,
6
- ControlAceEditor,
7
- ControlDebouncedInput,
8
- } from '../../Forms';
9
- import { PropertyAdditionalFields } from './PropertyAdditionalFields';
10
- import { PropertyValueField } from '../PropertyValueField';
11
- import CustomPropertyField from './CustomPropertyField';
12
-
13
- import { useMemo } from 'react';
14
- import { useFormContext, useWatch } from 'react-hook-form';
15
- import useCustomFields from './useCustomFields';
16
-
17
- import { CustomPropertyFieldProps, PropertyType } from '../../../interfaces';
18
-
19
- type Props = {
20
- propertyFieldName: string;
21
- entityDefinition?: boolean;
22
- globalParameter?: boolean;
23
- customPropertyFields?: CustomPropertyFieldProps[];
24
- };
25
-
26
- const propertyTypes = Object.values(PropertyType)
27
- .sort((a, b) => a.localeCompare(b))
28
- .map((propType) => ({
29
- value: propType,
30
- label: propType
31
- .replace('_', ' ')
32
- .toLowerCase()
33
- .replace(/(^\w)|([-\s]\w)/g, (c) => c.toUpperCase()),
34
- }));
35
-
36
- const CreatePropertyFormFields = ({
37
- propertyFieldName,
38
- entityDefinition = false,
39
- globalParameter = false,
40
- customPropertyFields = [],
41
- }: Props) => {
42
- const { control, setValue } = useFormContext();
43
- const propertyType = useWatch({ control, name: `${propertyFieldName}.propertyType` });
44
- const isMultiple = useWatch({ control, name: `${propertyFieldName}.isMultiple` });
45
- const isRequired = useWatch({ control, name: `${propertyFieldName}.isRequired` });
46
-
47
- const { customCheckboxes, customFields } = useCustomFields(customPropertyFields);
48
-
49
- const valueLabel = useMemo(() => {
50
- let label = globalParameter ? 'Value' : 'Default Value';
51
- if (isMultiple) {
52
- label += 's';
53
- }
54
- return label;
55
- }, [globalParameter, isMultiple]);
56
-
57
- const handlePropertyTypeChange = (fieldName, value) => {
58
- const valueFieldName = `${propertyFieldName}.${globalParameter ? 'value' : 'defaultValue'}`;
59
- if (isMultiple) {
60
- setValue(valueFieldName, []);
61
- } else {
62
- setValue(valueFieldName, null);
63
- }
64
- setValue(fieldName, value);
65
- };
66
-
67
- return (
68
- <Grid container direction="column" spacing={2}>
69
- <Grid item>
70
- <ControlDebouncedInput required control={control} name={`${propertyFieldName}.key`} label="Key" />
71
- </Grid>
72
- <Grid item>
73
- <ControlDebouncedInput required control={control} name={`${propertyFieldName}.name`} label="Name" />
74
- </Grid>
75
- <Grid item>
76
- <ControlAutocomplete
77
- required
78
- control={control}
79
- name={`${propertyFieldName}.propertyType`}
80
- label="Type"
81
- options={propertyTypes}
82
- onChange={handlePropertyTypeChange}
83
- />
84
- </Grid>
85
- <Grid item>
86
- <ControlNumberInput required control={control} name={`${propertyFieldName}.sortOrder`} label="Sort Order" />
87
- </Grid>
88
-
89
- <Grid item>
90
- <ControlAceEditor control={control} name={`${propertyFieldName}.uiSettings`} label="UI Settings" validateJson />
91
- </Grid>
92
- <Grid item>
93
- <ControlCheckbox control={control} name={`${propertyFieldName}.isMultiple`} label="Multiple" />
94
- <ControlCheckbox control={control} name={`${propertyFieldName}.isEnabled`} label="Enabled" />
95
- <ControlCheckbox control={control} name={`${propertyFieldName}.isRequired`} label="Required" />
96
- {entityDefinition && (
97
- <ControlCheckbox
98
- control={control}
99
- name={`${propertyFieldName}.isViewableInList`}
100
- label="Is viewable in list"
101
- />
102
- )}
103
- {customCheckboxes.length ? (
104
- <>
105
- {customCheckboxes.map((field, index) => (
106
- <ControlCheckbox
107
- key={index}
108
- control={control}
109
- name={`${propertyFieldName}.${field.name}`}
110
- label={field.label}
111
- />
112
- ))}
113
- </>
114
- ) : null}
115
- </Grid>
116
- {propertyType && (
117
- <>
118
- <PropertyAdditionalFields
119
- propertyType={typeof propertyType === 'string' ? propertyType : propertyType.value}
120
- propertyFieldName={propertyFieldName}
121
- globalParameter={globalParameter}
122
- entityDefinition={entityDefinition}
123
- />
124
- <Grid item>
125
- <PropertyValueField
126
- propertyFieldName={propertyFieldName}
127
- name={`${propertyFieldName}.${globalParameter ? 'value' : 'defaultValue'}`}
128
- label={valueLabel}
129
- required={globalParameter ? isRequired : false}
130
- />
131
- </Grid>
132
- </>
133
- )}
134
- {customFields.length ? (
135
- <>
136
- {customFields.map((field, index) => (
137
- <Grid item key={index}>
138
- <CustomPropertyField {...field} propertyFieldName={propertyFieldName} />
139
- </Grid>
140
- ))}
141
- </>
142
- ) : null}
143
- </Grid>
144
- );
145
- };
146
-
147
- export default CreatePropertyFormFields;
@@ -1,40 +0,0 @@
1
- import { useMemo } from 'react';
2
- import { useFormContext } from 'react-hook-form';
3
- import { CustomPropertyFieldProps } from '../../../interfaces';
4
- import { ControlAceEditor, ControlAutocomplete, ControlInput, ControlNumberInput, ControlSelect } from '../../Forms';
5
-
6
- type Props = CustomPropertyFieldProps & { propertyFieldName: string };
7
-
8
- export const CustomPropertyField = ({
9
- name,
10
- label = '',
11
- propertyFieldName,
12
- type,
13
- decimal = false,
14
- options = [],
15
- required = false,
16
- }: Props) => {
17
- const { control } = useFormContext();
18
- const fieldName = useMemo(() => `${propertyFieldName}.${name}`, [name, propertyFieldName]);
19
-
20
- switch (type) {
21
- case 'text':
22
- return <ControlInput control={control} name={fieldName} label={label} required={required} />;
23
- case 'number':
24
- return (
25
- <ControlNumberInput control={control} name={fieldName} label={label} decimal={decimal} required={required} />
26
- );
27
- case 'select':
28
- return <ControlSelect control={control} name={fieldName} label={label} options={options} required={required} />;
29
- case 'autocomplete':
30
- return (
31
- <ControlAutocomplete control={control} name={fieldName} label={label} options={options} required={required} />
32
- );
33
- case 'json':
34
- return <ControlAceEditor control={control} name={fieldName} label={label} mode="json" required={required} />;
35
- default:
36
- return null;
37
- }
38
- };
39
-
40
- export default CustomPropertyField;
@@ -1,41 +0,0 @@
1
- import Grid from '@material-ui/core/Grid';
2
- import { ControlNumberInput, ControlSelect } from '../../../Forms';
3
- import { RoundingMode } from '../../../../interfaces';
4
-
5
- import { useFormContext } from 'react-hook-form';
6
-
7
- type Props = {
8
- propertyFieldName: string;
9
- };
10
-
11
- const roundingModes = Object.values(RoundingMode).sort((a, b) => a.localeCompare(b));
12
-
13
- const BigDecimalPropertyFields = ({ propertyFieldName }: Props) => {
14
- const { control } = useFormContext();
15
-
16
- return (
17
- <>
18
- <Grid item>
19
- <ControlNumberInput
20
- required
21
- control={control}
22
- defaultValue={2}
23
- name={`${propertyFieldName}.precisionScale`}
24
- label="Precision Scale"
25
- />
26
- </Grid>
27
- <Grid item>
28
- <ControlSelect
29
- required
30
- control={control}
31
- name={`${propertyFieldName}.roundingMode`}
32
- label="Rounding Mode"
33
- defaultValue={RoundingMode.HALF_UP}
34
- options={roundingModes}
35
- />
36
- </Grid>
37
- </>
38
- );
39
- };
40
-
41
- export default BigDecimalPropertyFields;
@@ -1,27 +0,0 @@
1
- import Grid from '@material-ui/core/Grid';
2
- import { ControlInput } from '../../../Forms';
3
-
4
- import { useFormContext } from 'react-hook-form';
5
-
6
- type Props = {
7
- propertyFieldName: string;
8
- defaultValue?: string;
9
- };
10
-
11
- const DateAdditionalFields = ({ propertyFieldName, defaultValue = '' }: Props) => {
12
- const { control } = useFormContext();
13
-
14
- return (
15
- <Grid item>
16
- <ControlInput
17
- required
18
- control={control}
19
- defaultValue={defaultValue}
20
- name={`${propertyFieldName}.format`}
21
- label="Format"
22
- />
23
- </Grid>
24
- );
25
- };
26
-
27
- export default DateAdditionalFields;