@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,158 +0,0 @@
|
|
|
1
|
-
import Grid from '@mui/material/Unstable_Grid2';
|
|
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 { PropertyValidator } from '../PropertyValidator';
|
|
12
|
-
import CustomPropertyField from './CustomPropertyField';
|
|
13
|
-
import { PropertyValidatorContext } from '../PropertyValidator/PropertyValidatorContext';
|
|
14
|
-
import { useMemo, useEffect } from 'react';
|
|
15
|
-
import { useFormContext, useWatch } from 'react-hook-form';
|
|
16
|
-
import useCustomFields from './useCustomFields';
|
|
17
|
-
|
|
18
|
-
import { CustomPropertyFieldProps, PropertyType } from '../../../interfaces';
|
|
19
|
-
|
|
20
|
-
type Props = {
|
|
21
|
-
propertyFieldName: string;
|
|
22
|
-
entityDefinition?: boolean;
|
|
23
|
-
globalParameter?: boolean;
|
|
24
|
-
customPropertyFields?: CustomPropertyFieldProps[];
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const propertyTypes = Object.values(PropertyType)
|
|
28
|
-
.sort((a, b) => a.localeCompare(b))
|
|
29
|
-
.map((propType) => ({
|
|
30
|
-
value: propType,
|
|
31
|
-
label: propType
|
|
32
|
-
.replace('_', ' ')
|
|
33
|
-
.toLowerCase()
|
|
34
|
-
.replace(/(^\w)|([-\s]\w)/g, (c) => c.toUpperCase()),
|
|
35
|
-
}));
|
|
36
|
-
|
|
37
|
-
export const CreatePropertyFormFields = ({
|
|
38
|
-
propertyFieldName,
|
|
39
|
-
entityDefinition = false,
|
|
40
|
-
globalParameter = false,
|
|
41
|
-
customPropertyFields = [],
|
|
42
|
-
}: Props) => {
|
|
43
|
-
const { control, setValue } = useFormContext();
|
|
44
|
-
const propertyType = useWatch({ control, name: `${propertyFieldName}.propertyType` });
|
|
45
|
-
const isMultiple = useWatch({ control, name: `${propertyFieldName}.isMultiple` });
|
|
46
|
-
const isRequired = useWatch({ control, name: `${propertyFieldName}.isRequired` });
|
|
47
|
-
|
|
48
|
-
const { customCheckboxes, customFields } = useCustomFields(customPropertyFields);
|
|
49
|
-
|
|
50
|
-
const valueLabel = useMemo(() => {
|
|
51
|
-
let label = globalParameter ? 'Value' : 'Default Value';
|
|
52
|
-
if (isMultiple) {
|
|
53
|
-
label += 's';
|
|
54
|
-
}
|
|
55
|
-
return label;
|
|
56
|
-
}, [globalParameter, isMultiple]);
|
|
57
|
-
|
|
58
|
-
const handlePropertyTypeChange = (_, value) => {
|
|
59
|
-
const fieldName = `${propertyFieldName}.propertyType`;
|
|
60
|
-
const valueFieldName = `${propertyFieldName}.${globalParameter ? 'value' : 'defaultValue'}`;
|
|
61
|
-
if (isMultiple) {
|
|
62
|
-
setValue(valueFieldName, []);
|
|
63
|
-
} else {
|
|
64
|
-
setValue(valueFieldName, null);
|
|
65
|
-
}
|
|
66
|
-
setValue(fieldName, value);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
useEffect(() => {
|
|
70
|
-
if (propertyType && typeof propertyType === 'string') {
|
|
71
|
-
setValue(`${propertyFieldName}.propertyType`, propertyTypes.find(el => el.value === propertyType));
|
|
72
|
-
}
|
|
73
|
-
}, [propertyType, setValue, propertyFieldName])
|
|
74
|
-
|
|
75
|
-
return (
|
|
76
|
-
<Grid container direction="column" spacing={2}>
|
|
77
|
-
<Grid>
|
|
78
|
-
<ControlDebouncedInput required control={control} name={`${propertyFieldName}.key`} label="Key" />
|
|
79
|
-
</Grid>
|
|
80
|
-
<Grid>
|
|
81
|
-
<ControlDebouncedInput required control={control} name={`${propertyFieldName}.name`} label="Name" />
|
|
82
|
-
</Grid>
|
|
83
|
-
<Grid>
|
|
84
|
-
<ControlAutocomplete
|
|
85
|
-
required
|
|
86
|
-
control={control}
|
|
87
|
-
name={`${propertyFieldName}.propertyType`}
|
|
88
|
-
label="Type"
|
|
89
|
-
options={propertyTypes}
|
|
90
|
-
onChange={handlePropertyTypeChange}
|
|
91
|
-
/>
|
|
92
|
-
</Grid>
|
|
93
|
-
<Grid>
|
|
94
|
-
<ControlNumberInput required control={control} name={`${propertyFieldName}.sortOrder`} label="Sort Order" />
|
|
95
|
-
</Grid>
|
|
96
|
-
|
|
97
|
-
<Grid>
|
|
98
|
-
<ControlAceEditor control={control} name={`${propertyFieldName}.uiSettings`} label="UI Settings" validateJson />
|
|
99
|
-
</Grid>
|
|
100
|
-
<Grid>
|
|
101
|
-
<ControlCheckbox control={control} name={`${propertyFieldName}.isMultiple`} label="Multiple" />
|
|
102
|
-
<ControlCheckbox control={control} name={`${propertyFieldName}.isEnabled`} label="Enabled" />
|
|
103
|
-
<ControlCheckbox control={control} name={`${propertyFieldName}.isRequired`} label="Required" />
|
|
104
|
-
{entityDefinition && (
|
|
105
|
-
<ControlCheckbox
|
|
106
|
-
control={control}
|
|
107
|
-
name={`${propertyFieldName}.isViewableInList`}
|
|
108
|
-
label="Is viewable in list"
|
|
109
|
-
/>
|
|
110
|
-
)}
|
|
111
|
-
{customCheckboxes.length ? (
|
|
112
|
-
<>
|
|
113
|
-
{customCheckboxes.map((field, index) => (
|
|
114
|
-
<ControlCheckbox
|
|
115
|
-
key={index}
|
|
116
|
-
control={control}
|
|
117
|
-
name={`${propertyFieldName}.${field.name}`}
|
|
118
|
-
label={field.label}
|
|
119
|
-
/>
|
|
120
|
-
))}
|
|
121
|
-
</>
|
|
122
|
-
) : null}
|
|
123
|
-
</Grid>
|
|
124
|
-
{propertyType && (
|
|
125
|
-
<>
|
|
126
|
-
<Grid>
|
|
127
|
-
<PropertyValidatorContext.Provider value={propertyType.value ?? propertyType}>
|
|
128
|
-
<PropertyValidator name={`${propertyFieldName}.validationNode`} />
|
|
129
|
-
</PropertyValidatorContext.Provider>
|
|
130
|
-
</Grid>
|
|
131
|
-
<PropertyAdditionalFields
|
|
132
|
-
propertyType={typeof propertyType === 'string' ? propertyType : propertyType.value}
|
|
133
|
-
propertyFieldName={propertyFieldName}
|
|
134
|
-
globalParameter={globalParameter}
|
|
135
|
-
entityDefinition={entityDefinition}
|
|
136
|
-
/>
|
|
137
|
-
<PropertyValueField
|
|
138
|
-
propertyFieldName={propertyFieldName}
|
|
139
|
-
name={`${propertyFieldName}.${globalParameter ? 'value' : 'defaultValue'}`}
|
|
140
|
-
label={valueLabel}
|
|
141
|
-
required={globalParameter ? isRequired : false}
|
|
142
|
-
/>
|
|
143
|
-
</>
|
|
144
|
-
)}
|
|
145
|
-
{customFields.length ? (
|
|
146
|
-
<>
|
|
147
|
-
{customFields.map((field, index) => (
|
|
148
|
-
<Grid key={index}>
|
|
149
|
-
<CustomPropertyField {...field} propertyFieldName={propertyFieldName} />
|
|
150
|
-
</Grid>
|
|
151
|
-
))}
|
|
152
|
-
</>
|
|
153
|
-
) : null}
|
|
154
|
-
</Grid>
|
|
155
|
-
);
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
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;
|
package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/BigDecimalPropertyFields.tsx
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import Grid from '@mui/material/Unstable_Grid2';
|
|
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>
|
|
19
|
-
<ControlNumberInput
|
|
20
|
-
required
|
|
21
|
-
control={control}
|
|
22
|
-
defaultValue={2}
|
|
23
|
-
name={`${propertyFieldName}.precisionScale`}
|
|
24
|
-
label="Precision Scale"
|
|
25
|
-
/>
|
|
26
|
-
</Grid>
|
|
27
|
-
<Grid>
|
|
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 '@mui/material/Unstable_Grid2';
|
|
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>
|
|
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;
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import Grid from '@mui/material/Unstable_Grid2';
|
|
2
|
-
import Button from '@mui/material/Button';
|
|
3
|
-
import Typography from '@mui/material/Typography';
|
|
4
|
-
import Dialog from '@mui/material/Dialog';
|
|
5
|
-
import DialogTitle from '@mui/material/DialogTitle';
|
|
6
|
-
import DialogContent from '@mui/material/DialogContent';
|
|
7
|
-
import DialogActions from '@mui/material/DialogActions';
|
|
8
|
-
import Stepper from '@mui/material/Stepper';
|
|
9
|
-
import Step from '@mui/material/Step';
|
|
10
|
-
import StepLabel from '@mui/material/StepLabel';
|
|
11
|
-
import StepContent from '@mui/material/StepContent';
|
|
12
|
-
import CreatePropertiesList from '../CreatePropertiesList';
|
|
13
|
-
import EntityPropertiesShortView from '../../ViewProperty/EntityPropertiesShortView';
|
|
14
|
-
|
|
15
|
-
import { useCallback, useState } from 'react';
|
|
16
|
-
import { useFormContext, useWatch } from 'react-hook-form';
|
|
17
|
-
import { useToggle } from '../../../../utils/hooks';
|
|
18
|
-
|
|
19
|
-
type Props = {
|
|
20
|
-
parentPropertyFieldName: string;
|
|
21
|
-
entityDefinition?: boolean;
|
|
22
|
-
globalParameter?: boolean;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const defaultPropertyValues = {
|
|
26
|
-
key: '',
|
|
27
|
-
propertyType: '',
|
|
28
|
-
name: '',
|
|
29
|
-
defaultValue: '',
|
|
30
|
-
isRequired: true,
|
|
31
|
-
isMultiple: false,
|
|
32
|
-
sortOrder: 0,
|
|
33
|
-
isEnabled: true,
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const EntityAdditionalFields = ({
|
|
37
|
-
parentPropertyFieldName,
|
|
38
|
-
entityDefinition = false,
|
|
39
|
-
globalParameter = false,
|
|
40
|
-
}: Props) => {
|
|
41
|
-
const { control, setValue, getValues, trigger } = useFormContext();
|
|
42
|
-
const properties = useWatch({
|
|
43
|
-
control,
|
|
44
|
-
name: `${parentPropertyFieldName}.properties`,
|
|
45
|
-
defaultValue: getValues(`${parentPropertyFieldName}.properties`) || [],
|
|
46
|
-
});
|
|
47
|
-
const parentPropertyName = useWatch({ control, name: `${parentPropertyFieldName}.name` });
|
|
48
|
-
|
|
49
|
-
const parametersModal = useToggle();
|
|
50
|
-
|
|
51
|
-
const [focusedProperty, setFocusedProperty] = useState(0);
|
|
52
|
-
|
|
53
|
-
const handleAddParameter = useCallback(() => {
|
|
54
|
-
if (properties) {
|
|
55
|
-
const propertyIndex = properties.length;
|
|
56
|
-
setValue(`${parentPropertyFieldName}.properties.${propertyIndex}`, defaultPropertyValues);
|
|
57
|
-
setFocusedProperty(propertyIndex);
|
|
58
|
-
} else {
|
|
59
|
-
setValue(`${parentPropertyFieldName}.properties`, [defaultPropertyValues]);
|
|
60
|
-
}
|
|
61
|
-
}, [properties, parentPropertyFieldName, setValue]);
|
|
62
|
-
|
|
63
|
-
const handleStepperClick = (index) => setFocusedProperty(index);
|
|
64
|
-
|
|
65
|
-
const handleSubmitClick = async () => {
|
|
66
|
-
const isValid = await trigger(`${parentPropertyFieldName}.properties`);
|
|
67
|
-
if (isValid) {
|
|
68
|
-
parametersModal.onClose();
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
return (
|
|
73
|
-
<>
|
|
74
|
-
<Grid>
|
|
75
|
-
<Typography variant="h6">Properties</Typography>
|
|
76
|
-
</Grid>
|
|
77
|
-
<Grid>
|
|
78
|
-
<EntityPropertiesShortView properties={properties} />
|
|
79
|
-
</Grid>
|
|
80
|
-
<Grid>
|
|
81
|
-
<Button variant="contained" color="primary" onClick={parametersModal.onOpen}>
|
|
82
|
-
Edit properties
|
|
83
|
-
</Button>
|
|
84
|
-
</Grid>
|
|
85
|
-
|
|
86
|
-
<Dialog disableEscapeKeyDown open={parametersModal.open} onClose={handleSubmitClick} fullWidth maxWidth="md">
|
|
87
|
-
<DialogTitle>{parentPropertyName || 'Entity'} Properties</DialogTitle>
|
|
88
|
-
<DialogContent style={{ height: '500px', overflow: 'hidden' }}>
|
|
89
|
-
<Grid container direction="row" spacing={2} style={{ height: '100%' }}>
|
|
90
|
-
<Grid xs={3} style={{ backgroundColor: '#f9f9f9' }}>
|
|
91
|
-
<Stepper nonLinear activeStep={focusedProperty} orientation="vertical" style={{ paddingLeft: '4px' }}>
|
|
92
|
-
{properties.map((property, index) => (
|
|
93
|
-
<Step key={index} onClick={() => handleStepperClick(index)} style={{ cursor: 'pointer' }}>
|
|
94
|
-
<StepLabel StepIconProps={{ icon: '' }} style={{ wordBreak: 'break-word' }}>
|
|
95
|
-
{property.name || '(no name)'}
|
|
96
|
-
</StepLabel>
|
|
97
|
-
<StepContent></StepContent>
|
|
98
|
-
</Step>
|
|
99
|
-
))}
|
|
100
|
-
</Stepper>
|
|
101
|
-
<Button variant="contained" size="small" color="primary" onClick={handleAddParameter}>
|
|
102
|
-
Add property
|
|
103
|
-
</Button>
|
|
104
|
-
</Grid>
|
|
105
|
-
<Grid
|
|
106
|
-
container
|
|
107
|
-
wrap="nowrap"
|
|
108
|
-
direction="column"
|
|
109
|
-
xs={9}
|
|
110
|
-
spacing={2}
|
|
111
|
-
style={{ height: '100%', overflowY: 'auto' }}
|
|
112
|
-
>
|
|
113
|
-
<CreatePropertiesList
|
|
114
|
-
hideAddButton
|
|
115
|
-
parentFieldName={parentPropertyFieldName}
|
|
116
|
-
focusOnIndex={focusedProperty}
|
|
117
|
-
entityDefinition={entityDefinition}
|
|
118
|
-
globalParameter={globalParameter}
|
|
119
|
-
/>
|
|
120
|
-
</Grid>
|
|
121
|
-
</Grid>
|
|
122
|
-
</DialogContent>
|
|
123
|
-
<DialogActions>
|
|
124
|
-
<Button variant="contained" color="primary" onClick={handleSubmitClick}>
|
|
125
|
-
Ok
|
|
126
|
-
</Button>
|
|
127
|
-
</DialogActions>
|
|
128
|
-
</Dialog>
|
|
129
|
-
</>
|
|
130
|
-
);
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
export default EntityAdditionalFields;
|
package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityReferencePropertyFields.tsx
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import Grid from '@mui/material/Unstable_Grid2';
|
|
2
|
-
import { ControlInput } from '../../../Forms';
|
|
3
|
-
|
|
4
|
-
import { useFormContext } from 'react-hook-form';
|
|
5
|
-
|
|
6
|
-
type Props = {
|
|
7
|
-
propertyFieldName: string;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const EntityReferencePropertyFields = ({ propertyFieldName }: Props) => {
|
|
11
|
-
const { control } = useFormContext();
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<>
|
|
15
|
-
<Grid>
|
|
16
|
-
<ControlInput required control={control} name={`${propertyFieldName}.definitionCode`} label="Definition Code" />
|
|
17
|
-
</Grid>
|
|
18
|
-
<Grid>
|
|
19
|
-
<ControlInput
|
|
20
|
-
required
|
|
21
|
-
control={control}
|
|
22
|
-
name={`${propertyFieldName}.definitionVersion`}
|
|
23
|
-
label="Definition Version"
|
|
24
|
-
/>
|
|
25
|
-
</Grid>
|
|
26
|
-
<Grid>
|
|
27
|
-
<ControlInput
|
|
28
|
-
required
|
|
29
|
-
control={control}
|
|
30
|
-
name={`${propertyFieldName}.labelPropertyCode`}
|
|
31
|
-
label="Label Property Code"
|
|
32
|
-
/>
|
|
33
|
-
</Grid>
|
|
34
|
-
<Grid>
|
|
35
|
-
<ControlInput
|
|
36
|
-
required
|
|
37
|
-
control={control}
|
|
38
|
-
name={`${propertyFieldName}.valuePropertyCode`}
|
|
39
|
-
label="Value Property Code"
|
|
40
|
-
/>
|
|
41
|
-
</Grid>
|
|
42
|
-
</>
|
|
43
|
-
);
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export default EntityReferencePropertyFields;
|
package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/PropertyAdditionalFields.tsx
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
PropertyType,
|
|
3
|
-
DATE_DEFAULT_FORMAT,
|
|
4
|
-
DATE_TIME_DEFAULT_FORMAT,
|
|
5
|
-
TIME_DEFAULT_FORMAT,
|
|
6
|
-
} from '../../../../interfaces';
|
|
7
|
-
import BigDecimalPropertyFields from './BigDecimalPropertyFields';
|
|
8
|
-
import DateAdditionalFields from './DateAdditionalFields';
|
|
9
|
-
import EntityAdditionalFields from './EntityAdditionalFields';
|
|
10
|
-
import EntityReferencePropertyFields from './EntityReferencePropertyFields';
|
|
11
|
-
import StringPropertyFields from './StringPropertyFields';
|
|
12
|
-
|
|
13
|
-
type Props = {
|
|
14
|
-
propertyType: PropertyType;
|
|
15
|
-
propertyFieldName: string;
|
|
16
|
-
entityDefinition?: boolean;
|
|
17
|
-
globalParameter?: boolean;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export const PropertyAdditionalFields = ({
|
|
21
|
-
propertyType,
|
|
22
|
-
propertyFieldName,
|
|
23
|
-
entityDefinition = false,
|
|
24
|
-
globalParameter = false,
|
|
25
|
-
}: Props) => {
|
|
26
|
-
switch (propertyType) {
|
|
27
|
-
case PropertyType.STRING:
|
|
28
|
-
return <StringPropertyFields propertyFieldName={propertyFieldName} />;
|
|
29
|
-
case PropertyType.BIG_DECIMAL:
|
|
30
|
-
return <BigDecimalPropertyFields propertyFieldName={propertyFieldName} />;
|
|
31
|
-
case PropertyType.DATE:
|
|
32
|
-
return <DateAdditionalFields propertyFieldName={propertyFieldName} defaultValue={DATE_DEFAULT_FORMAT} />;
|
|
33
|
-
case PropertyType.TIME:
|
|
34
|
-
return <DateAdditionalFields propertyFieldName={propertyFieldName} defaultValue={TIME_DEFAULT_FORMAT} />;
|
|
35
|
-
case PropertyType.DATE_TIME:
|
|
36
|
-
return <DateAdditionalFields propertyFieldName={propertyFieldName} defaultValue={DATE_TIME_DEFAULT_FORMAT} />;
|
|
37
|
-
case PropertyType.ENTITY_REFERENCE:
|
|
38
|
-
return <EntityReferencePropertyFields propertyFieldName={propertyFieldName} />;
|
|
39
|
-
case PropertyType.ENTITY:
|
|
40
|
-
return (
|
|
41
|
-
<EntityAdditionalFields
|
|
42
|
-
parentPropertyFieldName={propertyFieldName}
|
|
43
|
-
globalParameter={globalParameter}
|
|
44
|
-
entityDefinition={entityDefinition}
|
|
45
|
-
/>
|
|
46
|
-
);
|
|
47
|
-
default:
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export default PropertyAdditionalFields;
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import Grid from '@mui/material/Unstable_Grid2';
|
|
2
|
-
import Chip from '@mui/material/Chip';
|
|
3
|
-
import Box from '@mui/material/Box';
|
|
4
|
-
import Typography from '@mui/material/Typography';
|
|
5
|
-
import TextField from '@mui/material/TextField';
|
|
6
|
-
import IconButton from '@mui/material/IconButton';
|
|
7
|
-
import AddIcon from '@mui/icons-material/Add';
|
|
8
|
-
|
|
9
|
-
import { useFormContext, useWatch } from 'react-hook-form';
|
|
10
|
-
import { removeArrayItem } from '../../../../utils';
|
|
11
|
-
import { useCallback, useMemo, useState } from 'react';
|
|
12
|
-
|
|
13
|
-
type Props = {
|
|
14
|
-
propertyFieldName: string;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const StringPropertyFields = ({ propertyFieldName }: Props) => {
|
|
18
|
-
const fieldName = useMemo(() => `${propertyFieldName}.restrictedValues`, [propertyFieldName]);
|
|
19
|
-
|
|
20
|
-
const { control, setValue, getValues } = useFormContext();
|
|
21
|
-
const restrictedValues = useWatch({
|
|
22
|
-
control,
|
|
23
|
-
name: fieldName,
|
|
24
|
-
defaultValue: getValues(`${propertyFieldName}.restrictedValues`) || [],
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
const [inputValue, setInputValue] = useState('');
|
|
28
|
-
const [error, setError] = useState('');
|
|
29
|
-
|
|
30
|
-
const handleDelete = useCallback(
|
|
31
|
-
(index) => {
|
|
32
|
-
setValue(fieldName, removeArrayItem(restrictedValues, index));
|
|
33
|
-
},
|
|
34
|
-
[restrictedValues, fieldName, setValue]
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
const handleAddValue = () => {
|
|
38
|
-
if (inputValue) {
|
|
39
|
-
setValue(fieldName, [...restrictedValues, inputValue]);
|
|
40
|
-
setInputValue('');
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const handleInputChange = (e) => {
|
|
45
|
-
const { value } = e.target;
|
|
46
|
-
setInputValue(value);
|
|
47
|
-
|
|
48
|
-
if (restrictedValues.includes(value)) {
|
|
49
|
-
setError('This value already exists');
|
|
50
|
-
} else {
|
|
51
|
-
setError('');
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const handleKeyDown = (e) => {
|
|
56
|
-
if (e.key === 'Enter') {
|
|
57
|
-
handleAddValue();
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
return (
|
|
62
|
-
<>
|
|
63
|
-
<Grid>
|
|
64
|
-
<Typography variant="h6">Restricted Values</Typography>
|
|
65
|
-
</Grid>
|
|
66
|
-
{
|
|
67
|
-
!!restrictedValues?.length && (
|
|
68
|
-
<Grid>
|
|
69
|
-
<Box display="flex" flexWrap="wrap">
|
|
70
|
-
{restrictedValues.map((value, index) => (
|
|
71
|
-
<Chip sx={{ mr: 1 }} key={index} variant="outlined" label={value} onDelete={() => handleDelete(index)} />
|
|
72
|
-
))}
|
|
73
|
-
</Box>
|
|
74
|
-
</Grid>
|
|
75
|
-
)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
<Grid>
|
|
79
|
-
<TextField
|
|
80
|
-
fullWidth
|
|
81
|
-
variant="outlined"
|
|
82
|
-
size="small"
|
|
83
|
-
label="Add restricted value"
|
|
84
|
-
value={inputValue}
|
|
85
|
-
onChange={handleInputChange}
|
|
86
|
-
error={!!error}
|
|
87
|
-
helperText={error}
|
|
88
|
-
name="restrictedValues"
|
|
89
|
-
inputProps={{ onKeyDown: handleKeyDown }}
|
|
90
|
-
InputProps={{
|
|
91
|
-
endAdornment: (
|
|
92
|
-
<IconButton size="small" onClick={handleAddValue} disabled={!!error}>
|
|
93
|
-
<AddIcon />
|
|
94
|
-
</IconButton>
|
|
95
|
-
),
|
|
96
|
-
}}
|
|
97
|
-
/>
|
|
98
|
-
</Grid>
|
|
99
|
-
</>
|
|
100
|
-
);
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
export default StringPropertyFields;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
2
|
-
import { CustomPropertyFieldProps } from '../../../interfaces';
|
|
3
|
-
|
|
4
|
-
const useCustomFields = (customPropertyFields: CustomPropertyFieldProps[]) => {
|
|
5
|
-
const customCheckboxes = useMemo(() => {
|
|
6
|
-
if (customPropertyFields.length) {
|
|
7
|
-
return customPropertyFields.filter((field) => field.type === 'checkbox');
|
|
8
|
-
}
|
|
9
|
-
return [];
|
|
10
|
-
}, [customPropertyFields]);
|
|
11
|
-
|
|
12
|
-
const customFields = useMemo(() => {
|
|
13
|
-
if (customPropertyFields.length) {
|
|
14
|
-
return customPropertyFields.filter((field) => field.type !== 'checkbox');
|
|
15
|
-
}
|
|
16
|
-
return [];
|
|
17
|
-
}, [customPropertyFields]);
|
|
18
|
-
|
|
19
|
-
return { customCheckboxes, customFields };
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export default useCustomFields;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import Box from '@mui/material/Box';
|
|
2
|
-
import Typography from '@mui/material/Typography';
|
|
3
|
-
import { ViewProperty } from '../ViewProperty';
|
|
4
|
-
|
|
5
|
-
import { useMemo } from 'react';
|
|
6
|
-
import { propertiesObjectToArray } from '../../../utils';
|
|
7
|
-
import { PropertiesArrayType, PropertiesObjectType } from '../../../interfaces';
|
|
8
|
-
|
|
9
|
-
type Props = {
|
|
10
|
-
properties: PropertiesObjectType<unknown> | PropertiesArrayType<unknown>;
|
|
11
|
-
expandAll?: boolean;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const ViewPropertiesList = ({ properties, expandAll = true }: Props) => {
|
|
15
|
-
const propertiesList = useMemo(() => {
|
|
16
|
-
if (Array.isArray(properties)) {
|
|
17
|
-
return properties;
|
|
18
|
-
} else if (properties) {
|
|
19
|
-
return propertiesObjectToArray(properties);
|
|
20
|
-
}
|
|
21
|
-
return [];
|
|
22
|
-
}, [properties]);
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<Box display="flex" flexDirection="column">
|
|
26
|
-
{propertiesList.length ? (
|
|
27
|
-
propertiesList.map((property) => (
|
|
28
|
-
<ViewProperty key={property.key} property={property} defaultExpanded={expandAll} />
|
|
29
|
-
))
|
|
30
|
-
) : (
|
|
31
|
-
<Typography>No properties</Typography>
|
|
32
|
-
)}
|
|
33
|
-
</Box>
|
|
34
|
-
);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export default ViewPropertiesList;
|