@dartech/arsenal-ui 1.3.0 → 1.3.2
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.
- package/{index.ts → index.d.ts} +5 -5
- package/index.js +1 -0
- package/package.json +10 -3
- package/src/consts/index.d.ts +12 -0
- package/src/interfaces/common.d.ts +17 -0
- package/src/interfaces/definition.d.ts +107 -0
- package/src/interfaces/{index.ts → index.d.ts} +3 -3
- package/src/interfaces/ui.d.ts +70 -0
- package/src/lib/Alert/Alert.d.ts +53 -0
- package/src/lib/Alert/index.d.ts +1 -0
- package/src/lib/Breadcrumbs/Breadcrumbs.d.ts +9 -0
- package/src/lib/Breadcrumbs/Breadcrumbs.styled.d.ts +2 -0
- package/src/lib/Breadcrumbs/{index.ts → index.d.ts} +1 -1
- package/src/lib/ContentLayout/ContentLayout.d.ts +9 -0
- package/src/lib/ContentLayout/index.d.ts +1 -0
- package/src/lib/Definition/CreateDefinition/CreateDefinition.d.ts +11 -0
- package/src/lib/Definition/CreateDefinition/{index.ts → index.d.ts} +1 -1
- package/src/lib/Definition/DefinitionFiller/DefinitionFiller.d.ts +10 -0
- package/src/lib/Definition/DefinitionFiller/{index.ts → index.d.ts} +1 -1
- package/src/lib/Definition/DefinitionValueView/DefinitionValueView.d.ts +8 -0
- package/src/lib/Definition/DefinitionValueView/PropertyDataView.d.ts +9 -0
- package/src/lib/Definition/DefinitionValueView/{index.ts → index.d.ts} +1 -1
- package/src/lib/Definition/{index.ts → index.d.ts} +3 -3
- package/src/lib/Forms/BackButton.d.ts +7 -0
- package/src/lib/Forms/ControlAceEditor.d.ts +24 -0
- package/src/lib/Forms/ControlAutocomplete.d.ts +69 -0
- package/src/lib/Forms/ControlCheckbox.d.ts +51 -0
- package/src/lib/Forms/ControlDate.d.ts +18 -0
- package/src/lib/Forms/ControlDateTime.d.ts +18 -0
- package/src/lib/Forms/ControlDebouncedInput.d.ts +4 -0
- package/src/lib/Forms/ControlInput.d.ts +59 -0
- package/src/lib/Forms/ControlNumberInput.d.ts +51 -0
- package/src/lib/Forms/ControlQueryAutocomplete.d.ts +16 -0
- package/src/lib/Forms/ControlRadio.d.ts +66 -0
- package/src/lib/Forms/ControlSelect.d.ts +67 -0
- package/src/lib/Forms/ControlSwitch.d.ts +19 -0
- package/src/lib/Forms/ControlTime.d.ts +18 -0
- package/src/lib/Forms/CopyButton.d.ts +20 -0
- package/src/lib/Forms/{index.ts → index.d.ts} +15 -15
- package/src/lib/Forms/useAutocomplete.d.ts +10 -0
- package/src/lib/InfoItem/InfoItem.d.ts +10 -0
- package/src/lib/InfoItem/{index.ts → index.d.ts} +1 -1
- package/src/lib/JsonPathPicker/JsonPathPicker.d.ts +10 -0
- package/src/lib/JsonPathPicker/PropertyStep.d.ts +11 -0
- package/src/lib/JsonPathPicker/{index.ts → index.d.ts} +1 -1
- package/src/lib/JsonView/JsonView.d.ts +7 -0
- package/src/lib/JsonView/{index.ts → index.d.ts} +1 -1
- package/src/lib/Loader/Loader.d.ts +21 -0
- package/src/lib/Loader/{index.ts → index.d.ts} +1 -1
- package/src/lib/Modals/JsonModalView.d.ts +10 -0
- package/src/lib/Modals/{index.ts → index.d.ts} +1 -1
- package/src/lib/Property/PropertyFiller/JsonEditor.d.ts +10 -0
- package/src/lib/Property/PropertyFiller/MultiplePropertyFiller.d.ts +12 -0
- package/src/lib/Property/PropertyFiller/MultiplePropertyWidget.d.ts +11 -0
- package/src/lib/Property/PropertyFiller/PropertyFiller.d.ts +12 -0
- package/src/lib/Property/PropertyFiller/{index.ts → index.d.ts} +2 -2
- package/src/lib/Property/PropertyFiller/styled.d.ts +18 -0
- package/src/lib/Property/PropertyFiller/usePropertyFiller.d.ts +24 -0
- package/src/lib/Property/PropertyValidator/NodeValidator.d.ts +6 -0
- package/src/lib/Property/PropertyValidator/NodesList.d.ts +6 -0
- package/src/lib/Property/PropertyValidator/NumericTypeValidator.d.ts +8 -0
- package/src/lib/Property/PropertyValidator/PropertyValidator.d.ts +6 -0
- package/src/lib/Property/PropertyValidator/PropertyValidatorContext.d.ts +3 -0
- package/src/lib/Property/PropertyValidator/StringTypeValidator.d.ts +8 -0
- package/src/lib/Property/PropertyValidator/ValidationNodeSelector.d.ts +7 -0
- package/src/lib/Property/PropertyValidator/index.d.ts +1 -0
- package/src/lib/Property/PropertyValueField/BooleanValueField.d.ts +7 -0
- package/src/lib/Property/PropertyValueField/DateTimeValueField.d.ts +9 -0
- package/src/lib/Property/PropertyValueField/DateValueField.d.ts +9 -0
- package/src/lib/Property/PropertyValueField/JsonValueField.d.ts +10 -0
- package/src/lib/Property/PropertyValueField/PropertyValueField.d.ts +9 -0
- package/src/lib/Property/PropertyValueField/StringValueField.d.ts +9 -0
- package/src/lib/Property/PropertyValueField/TimeValueField.d.ts +9 -0
- package/src/lib/Property/PropertyValueField/{index.ts → index.d.ts} +1 -1
- package/src/lib/Property/PropertyWidget/PropertyWidget.d.ts +13 -0
- package/src/lib/Property/PropertyWidget/{index.ts → index.d.ts} +1 -1
- package/src/lib/Property/UpsertProperty/CreatePropertiesList.d.ts +13 -0
- package/src/lib/Property/UpsertProperty/CreatePropertyFormFields.d.ts +10 -0
- package/src/lib/Property/UpsertProperty/CustomPropertyField.d.ts +7 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/BigDecimalPropertyFields.d.ts +6 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/DateAdditionalFields.d.ts +7 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityAdditionalFields.d.ts +8 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityReferencePropertyFields.d.ts +6 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/PropertyAdditionalFields.d.ts +10 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/StringPropertyFields.d.ts +6 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/{index.ts → index.d.ts} +1 -1
- package/src/lib/Property/UpsertProperty/{index.ts → index.d.ts} +2 -2
- package/src/lib/Property/UpsertProperty/useCustomFields.d.ts +6 -0
- package/src/lib/Property/ViewPropertiesList/ViewPropertiesList.d.ts +8 -0
- package/src/lib/Property/ViewPropertiesList/{index.ts → index.d.ts} +1 -1
- package/src/lib/Property/ViewProperty/EntityPropertiesShortView.d.ts +7 -0
- package/src/lib/Property/ViewProperty/EntityPropertiesView.d.ts +8 -0
- package/src/lib/Property/ViewProperty/PropertyDataTable.d.ts +7 -0
- package/src/lib/Property/ViewProperty/PropertyItem.d.ts +9 -0
- package/src/lib/Property/ViewProperty/ViewProperty.d.ts +9 -0
- package/src/lib/Property/ViewProperty/{index.ts → index.d.ts} +1 -1
- package/src/lib/Property/{index.ts → index.d.ts} +5 -5
- package/src/lib/Sidebar/Sidebar.d.ts +10 -0
- package/src/lib/Sidebar/Sidebar.styled.d.ts +117 -0
- package/src/lib/Sidebar/SidebarContext.d.ts +11 -0
- package/src/lib/Sidebar/SidebarDrawer.d.ts +9 -0
- package/src/lib/Sidebar/SidebarLink/MenuIcon.d.ts +7 -0
- package/src/lib/Sidebar/SidebarLink/SidebarLink.d.ts +7 -0
- package/src/lib/Sidebar/SidebarLink/SidebarLinkItem.d.ts +8 -0
- package/src/lib/Sidebar/SidebarLink/SidebarNestedItem.d.ts +10 -0
- package/src/lib/Sidebar/SidebarLink/{index.ts → index.d.ts} +2 -2
- package/src/lib/Sidebar/index.d.ts +2 -0
- package/src/lib/Status/Status.d.ts +8 -0
- package/src/lib/Status/{index.ts → index.d.ts} +1 -1
- package/src/lib/StepperView/StepperView.d.ts +11 -0
- package/src/lib/StepperView/{index.ts → index.d.ts} +1 -1
- package/src/lib/Table/DataGrid/JsonTypeCell.d.ts +7 -0
- package/src/lib/Table/DataGrid/Table.d.ts +49 -0
- package/src/lib/Table/DataGrid/TableAction.d.ts +13 -0
- package/src/lib/Table/DataGrid/TableColumnMenu.d.ts +3 -0
- package/src/lib/Table/DataGrid/TablePagination.d.ts +3 -0
- package/src/lib/Table/DataGrid/index.d.ts +2 -0
- package/src/lib/Table/DataGrid/styles.d.ts +44 -0
- package/src/lib/Table/DataGrid/usePagination.d.ts +5 -0
- package/src/lib/Table/DataGrid/useTableQueryPagination.d.ts +11 -0
- package/src/lib/Table/DataGrid/useTableQuerySorting.d.ts +6 -0
- package/src/lib/Table/SimpleTable/SimpleTable.d.ts +17 -0
- package/src/lib/Table/SimpleTable/TableActionCell.d.ts +10 -0
- package/src/lib/Table/SimpleTable/index.d.ts +2 -0
- package/src/lib/Table/SimpleTable/useTablePagination.d.ts +7 -0
- package/src/lib/Table/SimpleTable/useTableSorting.d.ts +6 -0
- package/src/lib/Table/index.d.ts +2 -0
- package/src/lib/Tabs/RouteTabs.d.ts +11 -0
- package/src/lib/Tabs/TabPanel.d.ts +25 -0
- package/src/lib/Tabs/{index.ts → index.d.ts} +2 -2
- package/src/lib/{index.ts → index.d.ts} +16 -16
- package/src/theme/baseTheme.d.ts +2 -0
- package/src/theme/index.d.ts +1 -0
- package/src/theme/inputThemeOptions.d.ts +117 -0
- package/src/theme/stepperThemeOptions.d.ts +16 -0
- package/src/theme/tableThemeOptions.d.ts +47 -0
- package/src/theme/typographyThemeOptions.d.ts +29 -0
- package/src/utils/common.d.ts +7 -0
- package/src/utils/dem.d.ts +27 -0
- package/src/utils/hooks.d.ts +7 -0
- package/src/utils/{index.ts → index.d.ts} +5 -5
- package/src/utils/ui-utils.d.ts +16 -0
- package/src/utils/validators.d.ts +5 -0
- package/.babelrc +0 -13
- package/.eslintrc.json +0 -22
- package/jest.config.ts +0 -11
- package/project.json +0 -89
- package/rollup.config.js +0 -146
- package/src/assets/chevron_left_gray.svg +0 -3
- package/src/consts/index.ts +0 -13
- package/src/interfaces/common.ts +0 -18
- package/src/interfaces/definition.ts +0 -143
- package/src/interfaces/ui.ts +0 -80
- package/src/lib/Alert/Alert.tsx +0 -108
- package/src/lib/Alert/index.ts +0 -1
- package/src/lib/Breadcrumbs/Breadcrumbs.styled.tsx +0 -16
- package/src/lib/Breadcrumbs/Breadcrumbs.tsx +0 -40
- package/src/lib/ContentLayout/ContentLayout.tsx +0 -31
- package/src/lib/ContentLayout/index.ts +0 -1
- package/src/lib/Definition/CreateDefinition/CreateDefinition.tsx +0 -78
- package/src/lib/Definition/DefinitionFiller/DefinitionFiller.tsx +0 -71
- package/src/lib/Definition/DefinitionValueView/DefinitionValueView.tsx +0 -54
- package/src/lib/Definition/DefinitionValueView/PropertyDataView.tsx +0 -67
- package/src/lib/Forms/BackButton.tsx +0 -46
- package/src/lib/Forms/ControlAceEditor.tsx +0 -125
- package/src/lib/Forms/ControlAutocomplete.tsx +0 -145
- package/src/lib/Forms/ControlCheckbox.tsx +0 -113
- package/src/lib/Forms/ControlDate.tsx +0 -75
- package/src/lib/Forms/ControlDateTime.tsx +0 -77
- package/src/lib/Forms/ControlDebouncedInput.tsx +0 -80
- package/src/lib/Forms/ControlInput.tsx +0 -111
- package/src/lib/Forms/ControlNumberInput.tsx +0 -121
- package/src/lib/Forms/ControlQueryAutocomplete.tsx +0 -197
- package/src/lib/Forms/ControlRadio.tsx +0 -136
- package/src/lib/Forms/ControlSelect.tsx +0 -164
- package/src/lib/Forms/ControlSwitch.tsx +0 -71
- package/src/lib/Forms/ControlTime.tsx +0 -93
- package/src/lib/Forms/CopyButton.tsx +0 -46
- package/src/lib/Forms/useAutocomplete.tsx +0 -47
- package/src/lib/InfoItem/InfoItem.tsx +0 -40
- package/src/lib/InfoItem/styles.ts +0 -17
- package/src/lib/JsonPathPicker/JsonPathPicker.tsx +0 -73
- package/src/lib/JsonPathPicker/PropertyStep.tsx +0 -70
- package/src/lib/JsonView/JsonView.tsx +0 -41
- package/src/lib/Loader/Loader.tsx +0 -41
- package/src/lib/Modals/JsonModalView.tsx +0 -53
- package/src/lib/Property/PropertyFiller/JsonEditor.tsx +0 -58
- package/src/lib/Property/PropertyFiller/MultiplePropertyFiller.tsx +0 -129
- package/src/lib/Property/PropertyFiller/MultiplePropertyWidget.tsx +0 -85
- package/src/lib/Property/PropertyFiller/PropertyFiller.tsx +0 -199
- package/src/lib/Property/PropertyFiller/usePropertyFiller.ts +0 -72
- package/src/lib/Property/PropertyFiller/useStyles.ts +0 -12
- package/src/lib/Property/PropertyValidator/NodeValidator.tsx +0 -92
- package/src/lib/Property/PropertyValidator/NodesList.tsx +0 -26
- package/src/lib/Property/PropertyValidator/NumericTypeValidator.tsx +0 -59
- package/src/lib/Property/PropertyValidator/PropertyValidator.tsx +0 -42
- package/src/lib/Property/PropertyValidator/PropertyValidatorContext.tsx +0 -4
- package/src/lib/Property/PropertyValidator/StringTypeValidator.tsx +0 -36
- package/src/lib/Property/PropertyValidator/ValidationNodeSelector.tsx +0 -62
- package/src/lib/Property/PropertyValidator/index.ts +0 -1
- package/src/lib/Property/PropertyValueField/BooleanValueField.tsx +0 -49
- package/src/lib/Property/PropertyValueField/DateTimeValueField.tsx +0 -58
- package/src/lib/Property/PropertyValueField/DateValueField.tsx +0 -58
- package/src/lib/Property/PropertyValueField/JsonValueField.tsx +0 -65
- package/src/lib/Property/PropertyValueField/PropertyValueField.tsx +0 -49
- package/src/lib/Property/PropertyValueField/StringValueField.tsx +0 -50
- package/src/lib/Property/PropertyValueField/TimeValueField.tsx +0 -67
- package/src/lib/Property/PropertyWidget/PropertyWidget.tsx +0 -115
- package/src/lib/Property/UpsertProperty/CreatePropertiesList.tsx +0 -148
- package/src/lib/Property/UpsertProperty/CreatePropertyFormFields.tsx +0 -158
- package/src/lib/Property/UpsertProperty/CustomPropertyField.tsx +0 -40
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/BigDecimalPropertyFields.tsx +0 -41
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/DateAdditionalFields.tsx +0 -27
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityAdditionalFields.tsx +0 -133
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityReferencePropertyFields.tsx +0 -46
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/PropertyAdditionalFields.tsx +0 -52
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/StringPropertyFields.tsx +0 -103
- package/src/lib/Property/UpsertProperty/useCustomFields.ts +0 -22
- package/src/lib/Property/ViewPropertiesList/ViewPropertiesList.tsx +0 -37
- package/src/lib/Property/ViewProperty/EntityPropertiesShortView.tsx +0 -40
- package/src/lib/Property/ViewProperty/EntityPropertiesView.tsx +0 -48
- package/src/lib/Property/ViewProperty/PropertyDataTable.tsx +0 -148
- package/src/lib/Property/ViewProperty/PropertyItem.tsx +0 -43
- package/src/lib/Property/ViewProperty/ViewProperty.tsx +0 -52
- package/src/lib/Sidebar/Sidebar.styled.tsx +0 -157
- package/src/lib/Sidebar/Sidebar.tsx +0 -27
- package/src/lib/Sidebar/SidebarContext.tsx +0 -37
- package/src/lib/Sidebar/SidebarDrawer.tsx +0 -50
- package/src/lib/Sidebar/SidebarLink/MenuIcon.tsx +0 -16
- package/src/lib/Sidebar/SidebarLink/SidebarLink.tsx +0 -54
- package/src/lib/Sidebar/SidebarLink/SidebarLinkItem.tsx +0 -54
- package/src/lib/Sidebar/SidebarLink/SidebarNestedItem.tsx +0 -62
- package/src/lib/Sidebar/index.ts +0 -2
- package/src/lib/Status/Status.tsx +0 -16
- package/src/lib/Status/styles.ts +0 -21
- package/src/lib/StepperView/StepperView.tsx +0 -73
- package/src/lib/Table/DataGrid/JsonTypeCell.tsx +0 -51
- package/src/lib/Table/DataGrid/Table.tsx +0 -117
- package/src/lib/Table/DataGrid/TableAction.tsx +0 -43
- package/src/lib/Table/DataGrid/TableColumnMenu.tsx +0 -12
- package/src/lib/Table/DataGrid/TablePagination.tsx +0 -42
- package/src/lib/Table/DataGrid/index.ts +0 -2
- package/src/lib/Table/DataGrid/styles.ts +0 -59
- package/src/lib/Table/DataGrid/usePagination.ts +0 -15
- package/src/lib/Table/DataGrid/useTableQueryPagination.ts +0 -47
- package/src/lib/Table/DataGrid/useTableQuerySorting.ts +0 -47
- package/src/lib/Table/SimpleTable/SimpleTable.tsx +0 -138
- package/src/lib/Table/SimpleTable/TableActionCell.tsx +0 -67
- package/src/lib/Table/SimpleTable/index.ts +0 -2
- package/src/lib/Table/SimpleTable/useTablePagination.ts +0 -54
- package/src/lib/Table/SimpleTable/useTableSorting.ts +0 -50
- package/src/lib/Table/index.ts +0 -2
- package/src/lib/Tabs/RouteTabs.tsx +0 -54
- package/src/lib/Tabs/TabPanel.tsx +0 -42
- package/src/theme/baseTheme.ts +0 -41
- package/src/theme/fonts.d.ts +0 -2
- package/src/theme/index.ts +0 -126
- package/src/theme/inputThemeOptions.ts +0 -126
- package/src/theme/stepperThemeOptions.ts +0 -20
- package/src/theme/tableThemeOptions.ts +0 -50
- package/src/theme/typographyThemeOptions.ts +0 -32
- package/src/utils/common.ts +0 -73
- package/src/utils/dem.ts +0 -431
- package/src/utils/hooks.ts +0 -41
- package/src/utils/ui-utils.tsx +0 -134
- package/src/utils/validators.ts +0 -14
- package/tsconfig.json +0 -25
- package/tsconfig.lib.json +0 -23
- package/tsconfig.spec.json +0 -20
@@ -1,199 +0,0 @@
|
|
1
|
-
import Box from '@mui/material/Box';
|
2
|
-
import Grid from '@mui/material/Unstable_Grid2';
|
3
|
-
import Select, { SelectChangeEvent } from '@mui/material/Select';
|
4
|
-
import MenuItem from '@mui/material/MenuItem';
|
5
|
-
import FormControl from '@mui/material/FormControl';
|
6
|
-
import InputLabel from '@mui/material/InputLabel';
|
7
|
-
import Typography from '@mui/material/Typography';
|
8
|
-
import JsonEditor from './JsonEditor';
|
9
|
-
import { ControlInput } from '../../Forms';
|
10
|
-
import { PropertyWidget } from '../PropertyWidget';
|
11
|
-
|
12
|
-
import { useEffect } from 'react';
|
13
|
-
import { useController, useFormContext, useWatch } from 'react-hook-form';
|
14
|
-
import usePropertyFiller from './usePropertyFiller';
|
15
|
-
import useStyles from './useStyles';
|
16
|
-
|
17
|
-
import {
|
18
|
-
PropertyFillType,
|
19
|
-
PropertyType,
|
20
|
-
PropertyUnion,
|
21
|
-
} from '../../../interfaces';
|
22
|
-
import { CreateDefinition } from '../../Definition';
|
23
|
-
import { defaultDefinitionArrayValue } from '../../../consts';
|
24
|
-
import {
|
25
|
-
propertiesArrayToObject,
|
26
|
-
propertiesObjectToArray,
|
27
|
-
} from '../../../utils';
|
28
|
-
|
29
|
-
type Props = {
|
30
|
-
property: PropertyUnion;
|
31
|
-
name: string;
|
32
|
-
useExpression?: boolean;
|
33
|
-
label?: string;
|
34
|
-
required?: boolean;
|
35
|
-
title?: string;
|
36
|
-
};
|
37
|
-
|
38
|
-
export const PropertyFiller = ({
|
39
|
-
property,
|
40
|
-
name,
|
41
|
-
useExpression,
|
42
|
-
label,
|
43
|
-
required,
|
44
|
-
title,
|
45
|
-
}: Props) => {
|
46
|
-
const { control, clearErrors } = useFormContext();
|
47
|
-
const {
|
48
|
-
field: { ref, onChange },
|
49
|
-
fieldState: { error, isDirty },
|
50
|
-
} = useController({
|
51
|
-
name,
|
52
|
-
});
|
53
|
-
const value = useWatch({ control, name });
|
54
|
-
|
55
|
-
const {
|
56
|
-
propertyType,
|
57
|
-
valueLabel,
|
58
|
-
fillOptionLabel,
|
59
|
-
fillOption,
|
60
|
-
fillOptions,
|
61
|
-
setFillOption,
|
62
|
-
} = usePropertyFiller({
|
63
|
-
value,
|
64
|
-
property,
|
65
|
-
isDirty,
|
66
|
-
label,
|
67
|
-
required,
|
68
|
-
useExpression,
|
69
|
-
});
|
70
|
-
|
71
|
-
const handleFillOptionChange = (
|
72
|
-
event: SelectChangeEvent<PropertyFillType>
|
73
|
-
) => {
|
74
|
-
const selectedType = event.target.value as PropertyFillType;
|
75
|
-
if (selectedType === 'null') {
|
76
|
-
onChange(null);
|
77
|
-
// register(name, { value: null });
|
78
|
-
} else if (selectedType === 'widget') {
|
79
|
-
if (
|
80
|
-
propertyType === PropertyType.JSON &&
|
81
|
-
value &&
|
82
|
-
typeof value !== 'string' &&
|
83
|
-
fillOption === 'dem_builder' &&
|
84
|
-
'properties' in value
|
85
|
-
) {
|
86
|
-
const definitionValue = {
|
87
|
-
...value,
|
88
|
-
properties: propertiesArrayToObject(value.property || []),
|
89
|
-
};
|
90
|
-
try {
|
91
|
-
onChange(JSON.stringify(definitionValue, null, '\t'));
|
92
|
-
} catch (error) {
|
93
|
-
console.log('Stringify failed');
|
94
|
-
}
|
95
|
-
} else {
|
96
|
-
onChange(null);
|
97
|
-
}
|
98
|
-
} else if (selectedType === 'expression' || selectedType === 'string') {
|
99
|
-
onChange('');
|
100
|
-
} else if (selectedType === 'dem_builder') {
|
101
|
-
if (value) {
|
102
|
-
try {
|
103
|
-
const definitionValue = JSON.parse(value);
|
104
|
-
definitionValue['properties'] = propertiesObjectToArray(
|
105
|
-
definitionValue['properties'] || {}
|
106
|
-
);
|
107
|
-
onChange(definitionValue);
|
108
|
-
} catch (error) {
|
109
|
-
onChange(defaultDefinitionArrayValue);
|
110
|
-
console.log('Parse failed');
|
111
|
-
}
|
112
|
-
} else {
|
113
|
-
onChange(defaultDefinitionArrayValue);
|
114
|
-
}
|
115
|
-
}
|
116
|
-
setFillOption(selectedType);
|
117
|
-
clearErrors(name);
|
118
|
-
};
|
119
|
-
|
120
|
-
useEffect(() => {
|
121
|
-
if (value === undefined) {
|
122
|
-
onChange(null);
|
123
|
-
}
|
124
|
-
}, [value, onChange]);
|
125
|
-
|
126
|
-
const { classes } = useStyles();
|
127
|
-
return (
|
128
|
-
<Grid xs={12}>
|
129
|
-
{title && (
|
130
|
-
<Box mb={2}>
|
131
|
-
<Typography variant="h6">{title}</Typography>
|
132
|
-
</Box>
|
133
|
-
)}
|
134
|
-
{fillOptions ? (
|
135
|
-
<Box mb={2}>
|
136
|
-
<FormControl fullWidth size="small" variant="outlined">
|
137
|
-
<InputLabel htmlFor="type-select" className={classes.inputLabel}>
|
138
|
-
{fillOptionLabel}
|
139
|
-
</InputLabel>
|
140
|
-
<Select
|
141
|
-
labelId="type-select"
|
142
|
-
label={fillOptionLabel}
|
143
|
-
value={fillOption || ''}
|
144
|
-
onChange={handleFillOptionChange}
|
145
|
-
>
|
146
|
-
{fillOptions.map((option) => (
|
147
|
-
<MenuItem key={option.value} value={option.value}>
|
148
|
-
{option.label}
|
149
|
-
</MenuItem>
|
150
|
-
))}
|
151
|
-
</Select>
|
152
|
-
</FormControl>
|
153
|
-
</Box>
|
154
|
-
) : null}
|
155
|
-
{fillOption === 'expression' &&
|
156
|
-
(propertyType === PropertyType.JSON ||
|
157
|
-
propertyType === PropertyType.ENTITY ||
|
158
|
-
propertyType === PropertyType.ANY ? (
|
159
|
-
<JsonEditor name={name} inputRef={ref} />
|
160
|
-
) : (
|
161
|
-
<ControlInput
|
162
|
-
control={control}
|
163
|
-
name={name}
|
164
|
-
label={valueLabel}
|
165
|
-
required
|
166
|
-
hideErrorMessage
|
167
|
-
/>
|
168
|
-
))}
|
169
|
-
{fillOption === 'string' && (
|
170
|
-
<ControlInput
|
171
|
-
control={control}
|
172
|
-
name={name}
|
173
|
-
label={valueLabel}
|
174
|
-
required
|
175
|
-
hideErrorMessage
|
176
|
-
/>
|
177
|
-
)}
|
178
|
-
{fillOption === 'json_notvalid' && (
|
179
|
-
<JsonEditor name={name} inputRef={ref} />
|
180
|
-
)}
|
181
|
-
{fillOption === 'widget' && (
|
182
|
-
<PropertyWidget
|
183
|
-
property={property}
|
184
|
-
name={name}
|
185
|
-
useExpression={useExpression}
|
186
|
-
label={valueLabel}
|
187
|
-
inputRef={ref}
|
188
|
-
required={required}
|
189
|
-
/>
|
190
|
-
)}
|
191
|
-
{fillOption === 'dem_builder' && (
|
192
|
-
<CreateDefinition title="JSON" definitionFieldName={name} />
|
193
|
-
)}
|
194
|
-
{error && <Typography color="secondary">{error.message}</Typography>}
|
195
|
-
</Grid>
|
196
|
-
);
|
197
|
-
};
|
198
|
-
|
199
|
-
export default PropertyFiller;
|
@@ -1,72 +0,0 @@
|
|
1
|
-
import { useEffect, useMemo, useState } from 'react';
|
2
|
-
import {
|
3
|
-
getMultiplePropertyFillOptions,
|
4
|
-
getSinglePropertyFillOptions,
|
5
|
-
isExpression,
|
6
|
-
isPropertyValueEmpty,
|
7
|
-
} from '../../../utils';
|
8
|
-
|
9
|
-
import { PropertyFillType, PropertyUnion } from '../../../interfaces';
|
10
|
-
|
11
|
-
type Props = {
|
12
|
-
value: unknown;
|
13
|
-
property: PropertyUnion;
|
14
|
-
isDirty: boolean;
|
15
|
-
label?: string;
|
16
|
-
required?: boolean;
|
17
|
-
useExpression?: boolean;
|
18
|
-
multipleOptions?: boolean;
|
19
|
-
};
|
20
|
-
|
21
|
-
const usePropertyFiller = ({
|
22
|
-
value,
|
23
|
-
property,
|
24
|
-
label,
|
25
|
-
isDirty,
|
26
|
-
required = false,
|
27
|
-
useExpression = false,
|
28
|
-
multipleOptions = false,
|
29
|
-
}: Props) => {
|
30
|
-
const valueLabel = useMemo(() => (label ? `${label} (value)` : `${property.name} (value)`), [label, property]);
|
31
|
-
const fillOptionLabel = useMemo(() => (label ? `${label} (widget)` : `${property.name} (widget)`), [label, property]);
|
32
|
-
|
33
|
-
const propertyType = useMemo(
|
34
|
-
() => (typeof property.propertyType === 'string' ? property.propertyType : property['propertyType']['value']),
|
35
|
-
[property]
|
36
|
-
);
|
37
|
-
|
38
|
-
const [fillOption, setFillOption] = useState<PropertyFillType>(null);
|
39
|
-
const fillOptions = useMemo(
|
40
|
-
() =>
|
41
|
-
multipleOptions
|
42
|
-
? getMultiplePropertyFillOptions({ propertyType, required, useExpression })
|
43
|
-
: getSinglePropertyFillOptions({
|
44
|
-
propertyType,
|
45
|
-
required,
|
46
|
-
useExpression,
|
47
|
-
}),
|
48
|
-
[useExpression, required, propertyType, multipleOptions]
|
49
|
-
);
|
50
|
-
|
51
|
-
useEffect(() => {
|
52
|
-
if (!fillOption) {
|
53
|
-
if (isPropertyValueEmpty(value) && fillOptions?.length) {
|
54
|
-
setFillOption(fillOptions[0].value);
|
55
|
-
} else if (useExpression && isExpression(value)) {
|
56
|
-
setFillOption('expression');
|
57
|
-
} else {
|
58
|
-
setFillOption('widget');
|
59
|
-
}
|
60
|
-
} else if (!isDirty) {
|
61
|
-
if (isExpression(value) && fillOption !== 'expression') {
|
62
|
-
setFillOption('expression');
|
63
|
-
} else if (value !== null && value !== undefined && !isExpression(value) && fillOption !== 'widget') {
|
64
|
-
setFillOption('widget');
|
65
|
-
}
|
66
|
-
}
|
67
|
-
}, [value, fillOption, fillOptions, useExpression, isDirty]);
|
68
|
-
|
69
|
-
return { propertyType, valueLabel, fillOptionLabel, fillOption, fillOptions, setFillOption };
|
70
|
-
};
|
71
|
-
|
72
|
-
export default usePropertyFiller;
|
@@ -1,92 +0,0 @@
|
|
1
|
-
import { useContext, useMemo, useEffect } from 'react';
|
2
|
-
import Box from '@mui/material/Box';
|
3
|
-
import { PropertyType } from '../../../interfaces';
|
4
|
-
import { ControlSelect, ControlInput, ControlAceEditor } from '../../Forms';
|
5
|
-
import { PropertyValidatorContext } from './PropertyValidatorContext';
|
6
|
-
import { useWatch, useFormContext } from 'react-hook-form';
|
7
|
-
import { StepperView } from '../../StepperView';
|
8
|
-
import { StringTypeValidator } from './StringTypeValidator';
|
9
|
-
import { NumericTypeValidator } from './NumericTypeValidator';
|
10
|
-
|
11
|
-
type Props = {
|
12
|
-
name: string;
|
13
|
-
}
|
14
|
-
|
15
|
-
const validatorTypes = ['STRING_REGEX', 'JSON_SCHEMA'];
|
16
|
-
|
17
|
-
const numericTypes = new Set([PropertyType.INTEGER, PropertyType.FLOAT, PropertyType.DOUBLE, PropertyType.BIG_DECIMAL, PropertyType.BIG_INTEGER, PropertyType.LONG]);
|
18
|
-
|
19
|
-
const NodeValidator = ({ name }: Props) => {
|
20
|
-
const { control, setValue } = useFormContext();
|
21
|
-
const propertyType = useContext(PropertyValidatorContext);
|
22
|
-
const selectedType = useWatch({ control, name: `${name}.type` });
|
23
|
-
const renderValidator = useMemo(() => {
|
24
|
-
if (selectedType === 'STRING_REGEX') {
|
25
|
-
return (
|
26
|
-
<ControlInput
|
27
|
-
control={control}
|
28
|
-
name={`${name}.pattern`}
|
29
|
-
label="Pattern"
|
30
|
-
/>
|
31
|
-
)
|
32
|
-
}
|
33
|
-
if (selectedType === 'JSON_SCHEMA') {
|
34
|
-
switch (true) {
|
35
|
-
case propertyType === PropertyType.STRING: {
|
36
|
-
return <StringTypeValidator name={`${name}.node`} control={control} />
|
37
|
-
}
|
38
|
-
case numericTypes.has(propertyType as PropertyType): {
|
39
|
-
return <NumericTypeValidator name={`${name}.node`} control={control} />
|
40
|
-
}
|
41
|
-
case propertyType === PropertyType.JSON: {
|
42
|
-
return (
|
43
|
-
<ControlAceEditor
|
44
|
-
label="Properties"
|
45
|
-
control={control}
|
46
|
-
name={`${name}.properties`}
|
47
|
-
validateJson
|
48
|
-
parseValue
|
49
|
-
/>
|
50
|
-
)
|
51
|
-
}
|
52
|
-
default: return 'Not available for type ' + propertyType;
|
53
|
-
}
|
54
|
-
}
|
55
|
-
return null;
|
56
|
-
}, [propertyType, selectedType, control, name]);
|
57
|
-
|
58
|
-
useEffect(() => {
|
59
|
-
if (numericTypes.has(propertyType as PropertyType) && selectedType === 'JSON_SCHEMA') {
|
60
|
-
// setting default values
|
61
|
-
setValue(`${name}.node.exclusiveMinimum`, false)
|
62
|
-
setValue(`${name}.node.exclusiveMaximum`, false)
|
63
|
-
}
|
64
|
-
}, [propertyType, selectedType, setValue, name]);
|
65
|
-
|
66
|
-
return (
|
67
|
-
<StepperView
|
68
|
-
data={[{
|
69
|
-
label: 'Validator',
|
70
|
-
content: (
|
71
|
-
<>
|
72
|
-
<Box>
|
73
|
-
<ControlSelect
|
74
|
-
control={control}
|
75
|
-
name={`${name}.type`}
|
76
|
-
label="Type"
|
77
|
-
options={validatorTypes}
|
78
|
-
onChange={e => {
|
79
|
-
setValue(name, {});
|
80
|
-
setValue(`${name}.type`, e.target.value)
|
81
|
-
}}
|
82
|
-
/>
|
83
|
-
</Box>
|
84
|
-
<Box mt={2}>{renderValidator}</Box>
|
85
|
-
</>
|
86
|
-
)
|
87
|
-
}]}
|
88
|
-
/>
|
89
|
-
)
|
90
|
-
}
|
91
|
-
|
92
|
-
export default NodeValidator;
|
@@ -1,26 +0,0 @@
|
|
1
|
-
import { useMemo } from 'react';
|
2
|
-
import ValidationNodeSelector from './ValidationNodeSelector';
|
3
|
-
import Box from '@mui/material/Box';
|
4
|
-
import Button from '@mui/material/Button';
|
5
|
-
import { useFieldArray, useFormContext } from 'react-hook-form';
|
6
|
-
|
7
|
-
type Props = {
|
8
|
-
name: string;
|
9
|
-
}
|
10
|
-
|
11
|
-
const NodesList = ({ name }: Props) => {
|
12
|
-
const listItem = useMemo(() => ({
|
13
|
-
type: ''
|
14
|
-
}), []);
|
15
|
-
const { control } = useFormContext();
|
16
|
-
const { fields, append, remove } = useFieldArray({ control, name });
|
17
|
-
|
18
|
-
return (
|
19
|
-
<Box mt={2}>
|
20
|
-
<Button variant="outlined" size="small" onClick={() => append(listItem)}>Add node</Button>
|
21
|
-
{fields.map(({ id }, idx) => <ValidationNodeSelector removeHandle={() => remove(idx)} key={id} name={`${name}.${idx}`} />)}
|
22
|
-
</Box>
|
23
|
-
)
|
24
|
-
}
|
25
|
-
|
26
|
-
export default NodesList;
|
@@ -1,59 +0,0 @@
|
|
1
|
-
import React from 'react'
|
2
|
-
import { ControlInput, ControlCheckbox } from '../../Forms';
|
3
|
-
import Box from '@mui/material/Box';
|
4
|
-
import Typography from '@mui/material/Typography';
|
5
|
-
import { Control } from 'react-hook-form';
|
6
|
-
|
7
|
-
type Props = {
|
8
|
-
name: string;
|
9
|
-
control: Control<any>;
|
10
|
-
}
|
11
|
-
|
12
|
-
export const NumericTypeValidator = ({ name, control }: Props) => {
|
13
|
-
return (
|
14
|
-
<>
|
15
|
-
<Typography variant="body2" gutterBottom>Node</Typography>
|
16
|
-
<Box>
|
17
|
-
<ControlInput
|
18
|
-
control={control}
|
19
|
-
name={`${name}.multipleOf`}
|
20
|
-
label="Multiple Of"
|
21
|
-
type="number"
|
22
|
-
/>
|
23
|
-
</Box>
|
24
|
-
<Box mt={2}>
|
25
|
-
<ControlInput
|
26
|
-
control={control}
|
27
|
-
name={`${name}.minimum`}
|
28
|
-
label="Minimum"
|
29
|
-
type="number"
|
30
|
-
/>
|
31
|
-
</Box>
|
32
|
-
<Box mt={2}>
|
33
|
-
<ControlInput
|
34
|
-
control={control}
|
35
|
-
name={`${name}.maximum`}
|
36
|
-
label="Maximum"
|
37
|
-
type="number"
|
38
|
-
/>
|
39
|
-
</Box>
|
40
|
-
<Box mt={2}>
|
41
|
-
<ControlCheckbox
|
42
|
-
control={control}
|
43
|
-
name={`${name}.exclusiveMinimum`}
|
44
|
-
label="Exclusive Minimum"
|
45
|
-
defaultValue={'false'}
|
46
|
-
/>
|
47
|
-
<ControlCheckbox
|
48
|
-
control={control}
|
49
|
-
name={`${name}.exclusiveMaximum`}
|
50
|
-
label="Exclusive Maximum"
|
51
|
-
defaultValue={'false'}
|
52
|
-
/>
|
53
|
-
</Box>
|
54
|
-
|
55
|
-
</>
|
56
|
-
)
|
57
|
-
}
|
58
|
-
|
59
|
-
export default NumericTypeValidator;
|
@@ -1,42 +0,0 @@
|
|
1
|
-
import { useState, useCallback, useEffect } from 'react';
|
2
|
-
import Typography from '@mui/material/Typography';
|
3
|
-
import Box from '@mui/material/Box';
|
4
|
-
import FormControlLabel from '@mui/material/FormControlLabel';
|
5
|
-
import Checkbox from '@mui/material/Checkbox';
|
6
|
-
import ValidationNodeSelector from './ValidationNodeSelector';
|
7
|
-
import { useFormContext } from 'react-hook-form';
|
8
|
-
|
9
|
-
type Props = {
|
10
|
-
name: string;
|
11
|
-
}
|
12
|
-
|
13
|
-
export const PropertyValidator = ({ name }: Props) => {
|
14
|
-
const [enable, setEnable] = useState(false);
|
15
|
-
const { setValue, getValues } = useFormContext();
|
16
|
-
|
17
|
-
const handleChangeEnable = useCallback(e => {
|
18
|
-
setEnable(e.target.checked);
|
19
|
-
if (!e.target.checked) {
|
20
|
-
setValue(name, null);
|
21
|
-
}
|
22
|
-
}, [setValue, name]);
|
23
|
-
|
24
|
-
useEffect(() => {
|
25
|
-
const validator = getValues(name);
|
26
|
-
if (validator) setEnable(true);
|
27
|
-
}, [name, getValues]);
|
28
|
-
|
29
|
-
return (
|
30
|
-
<>
|
31
|
-
<Box display="flex" justifyContent="space-between">
|
32
|
-
<Typography variant="h6">Validator</Typography>
|
33
|
-
<FormControlLabel label="Enable" control={<Checkbox color="primary" checked={enable} onChange={handleChangeEnable} /> } />
|
34
|
-
</Box>
|
35
|
-
{
|
36
|
-
enable && <ValidationNodeSelector name={name} />
|
37
|
-
}
|
38
|
-
</>
|
39
|
-
)
|
40
|
-
}
|
41
|
-
|
42
|
-
export default PropertyValidator;
|
@@ -1,36 +0,0 @@
|
|
1
|
-
import React from 'react'
|
2
|
-
import { ControlInput } from '../../Forms';
|
3
|
-
import Box from '@mui/material/Box';
|
4
|
-
import Typography from '@mui/material/Typography';
|
5
|
-
import { Control } from 'react-hook-form';
|
6
|
-
|
7
|
-
type Props = {
|
8
|
-
name: string;
|
9
|
-
control: Control;
|
10
|
-
}
|
11
|
-
|
12
|
-
export const StringTypeValidator = ({ name, control }: Props) => {
|
13
|
-
return (
|
14
|
-
<>
|
15
|
-
<Typography variant="body2" gutterBottom>Node</Typography>
|
16
|
-
<Box>
|
17
|
-
<ControlInput
|
18
|
-
control={control}
|
19
|
-
name={`${name}.minimumLength`}
|
20
|
-
label="Minimum Length"
|
21
|
-
type="number"
|
22
|
-
/>
|
23
|
-
</Box>
|
24
|
-
<Box mt={2}>
|
25
|
-
<ControlInput
|
26
|
-
control={control}
|
27
|
-
name={`${name}.maximumLength`}
|
28
|
-
label="Maximum Length"
|
29
|
-
type="number"
|
30
|
-
/>
|
31
|
-
</Box>
|
32
|
-
</>
|
33
|
-
)
|
34
|
-
}
|
35
|
-
|
36
|
-
export default StringTypeValidator;
|
@@ -1,62 +0,0 @@
|
|
1
|
-
import { useMemo } from 'react';
|
2
|
-
import { useFormContext, useWatch } from 'react-hook-form';
|
3
|
-
import { ControlSelect } from '../../Forms';
|
4
|
-
import IconButton from '@mui/material/IconButton';
|
5
|
-
import DeleteIcon from '@mui/icons-material/Delete';
|
6
|
-
import Box from '@mui/material/Box';
|
7
|
-
import NodesList from './NodesList';
|
8
|
-
import NodeValidator from './NodeValidator';
|
9
|
-
import { StepperView } from '../../StepperView';
|
10
|
-
|
11
|
-
type Props = {
|
12
|
-
name: string;
|
13
|
-
removeHandle?: () => void;
|
14
|
-
}
|
15
|
-
|
16
|
-
const nodeTypes = ['AND', 'OR', 'NOT', 'NODE'];
|
17
|
-
|
18
|
-
const ValidationNodeSelector = ({ name, removeHandle }: Props) => {
|
19
|
-
const { control } = useFormContext();
|
20
|
-
const selectedType = useWatch({ control, name: `${name}.type` });
|
21
|
-
const nodeComponent = useMemo(() => ({
|
22
|
-
AND: <NodesList name={`${name}.nodes`} />,
|
23
|
-
OR: <NodesList name={`${name}.nodes`} />,
|
24
|
-
NODE: <NodeValidator name={`${name}.validator`} />,
|
25
|
-
NOT: <ValidationNodeSelector name={`${name}.node`} />,
|
26
|
-
}), [name]);
|
27
|
-
return (
|
28
|
-
<StepperView
|
29
|
-
data={[{
|
30
|
-
label: 'Node Type',
|
31
|
-
content: (
|
32
|
-
<>
|
33
|
-
<Box display="flex" alignItems="center">
|
34
|
-
<ControlSelect
|
35
|
-
required
|
36
|
-
control={control}
|
37
|
-
name={`${name}.type`}
|
38
|
-
label="Type"
|
39
|
-
options={nodeTypes}
|
40
|
-
/>
|
41
|
-
{
|
42
|
-
removeHandle && (
|
43
|
-
<Box ml={2}>
|
44
|
-
<IconButton onClick={removeHandle} color="primary">
|
45
|
-
<DeleteIcon />
|
46
|
-
</IconButton>
|
47
|
-
</Box>
|
48
|
-
|
49
|
-
)
|
50
|
-
}
|
51
|
-
</Box>
|
52
|
-
<Box>
|
53
|
-
{nodeComponent[selectedType]}
|
54
|
-
</Box>
|
55
|
-
</>
|
56
|
-
)
|
57
|
-
}]}
|
58
|
-
/>
|
59
|
-
)
|
60
|
-
}
|
61
|
-
|
62
|
-
export default ValidationNodeSelector;
|
@@ -1 +0,0 @@
|
|
1
|
-
export * from './PropertyValidator';
|
@@ -1,49 +0,0 @@
|
|
1
|
-
import Switch from '@mui/material/Switch';
|
2
|
-
import Typography from '@mui/material/Typography';
|
3
|
-
import FormControlLabel from '@mui/material/FormControlLabel';
|
4
|
-
import { Controller, useFormContext, useWatch } from 'react-hook-form';
|
5
|
-
import { useEffect } from 'react';
|
6
|
-
|
7
|
-
type Props = {
|
8
|
-
name: string;
|
9
|
-
label?: string;
|
10
|
-
};
|
11
|
-
|
12
|
-
const BooleanValueField = ({ name, label = '' }: Props) => {
|
13
|
-
const { control, setValue } = useFormContext();
|
14
|
-
const value = useWatch({ name, control });
|
15
|
-
|
16
|
-
useEffect(() => {
|
17
|
-
if (value === null) {
|
18
|
-
setValue(name, false);
|
19
|
-
}
|
20
|
-
}, [value, name]);
|
21
|
-
|
22
|
-
return (
|
23
|
-
<>
|
24
|
-
<Typography>{label}</Typography>
|
25
|
-
<Controller
|
26
|
-
control={control}
|
27
|
-
name={name}
|
28
|
-
render={({ field }) => (
|
29
|
-
<FormControlLabel
|
30
|
-
label={(!!field.value + '').toUpperCase()}
|
31
|
-
control={
|
32
|
-
<Switch
|
33
|
-
color="primary"
|
34
|
-
size="small"
|
35
|
-
onChange={(e) => {
|
36
|
-
const { checked } = e.target;
|
37
|
-
field.onChange(checked);
|
38
|
-
}}
|
39
|
-
checked={!!field.value + '' === 'true'}
|
40
|
-
/>
|
41
|
-
}
|
42
|
-
/>
|
43
|
-
)}
|
44
|
-
/>
|
45
|
-
</>
|
46
|
-
);
|
47
|
-
};
|
48
|
-
|
49
|
-
export default BooleanValueField;
|