@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,58 +0,0 @@
|
|
1
|
-
import TextField from '@mui/material/TextField';
|
2
|
-
import { DateTimePicker } from '@mui/x-date-pickers/DateTimePicker';
|
3
|
-
|
4
|
-
import { format as dateFnsFormat, isValid } from 'date-fns';
|
5
|
-
import { Controller, useFormContext } from 'react-hook-form';
|
6
|
-
import { DATE_TIME_DEFAULT_FORMAT } from '../../../interfaces';
|
7
|
-
|
8
|
-
type Props = {
|
9
|
-
name: string;
|
10
|
-
label?: string;
|
11
|
-
required?: boolean;
|
12
|
-
format?: string;
|
13
|
-
};
|
14
|
-
|
15
|
-
const DateTimeValueField = ({ name, label, required = false, format = DATE_TIME_DEFAULT_FORMAT }: Props) => {
|
16
|
-
const { control, setError, clearErrors } = useFormContext();
|
17
|
-
|
18
|
-
const onError = (err) => {
|
19
|
-
if (err) {
|
20
|
-
setError(name, { type: 'custom', message: 'Incorrect date format' });
|
21
|
-
} else {
|
22
|
-
clearErrors(name);
|
23
|
-
}
|
24
|
-
};
|
25
|
-
|
26
|
-
return (
|
27
|
-
<Controller
|
28
|
-
control={control}
|
29
|
-
name={name}
|
30
|
-
rules={{ required: required && 'Required field' }}
|
31
|
-
render={({ field: { ref, value, onChange }, fieldState: { error } }) => (
|
32
|
-
<DateTimePicker
|
33
|
-
ampm={false}
|
34
|
-
inputRef={ref}
|
35
|
-
label={label}
|
36
|
-
value={value || null}
|
37
|
-
inputFormat={format}
|
38
|
-
onError={onError}
|
39
|
-
onChange={(date) => {
|
40
|
-
onChange(isValid(date) ? dateFnsFormat(date, format) : date);
|
41
|
-
}}
|
42
|
-
renderInput={(props) => (
|
43
|
-
<TextField
|
44
|
-
{...props}
|
45
|
-
fullWidth
|
46
|
-
size="small"
|
47
|
-
variant="outlined"
|
48
|
-
error={!!error}
|
49
|
-
helperText={error?.message}
|
50
|
-
/>
|
51
|
-
)}
|
52
|
-
/>
|
53
|
-
)}
|
54
|
-
/>
|
55
|
-
);
|
56
|
-
};
|
57
|
-
|
58
|
-
export default DateTimeValueField;
|
@@ -1,58 +0,0 @@
|
|
1
|
-
import TextField from '@mui/material/TextField';
|
2
|
-
import { DatePicker } from '@mui/x-date-pickers/DatePicker';
|
3
|
-
|
4
|
-
import { format as dateFnsFormat, isValid } from 'date-fns';
|
5
|
-
import { Controller, useFormContext } from 'react-hook-form';
|
6
|
-
import { DATE_DEFAULT_FORMAT } from '../../../interfaces';
|
7
|
-
|
8
|
-
type Props = {
|
9
|
-
name: string;
|
10
|
-
format: string;
|
11
|
-
label?: string;
|
12
|
-
required?: boolean;
|
13
|
-
};
|
14
|
-
|
15
|
-
const DateValueField = ({ name, label = '', required = false, format = DATE_DEFAULT_FORMAT }: Props) => {
|
16
|
-
const { control, setError, clearErrors } = useFormContext();
|
17
|
-
|
18
|
-
const onError = (err) => {
|
19
|
-
if (err) {
|
20
|
-
setError(name, { type: 'custom', message: 'Incorrect date format' });
|
21
|
-
} else {
|
22
|
-
clearErrors(name);
|
23
|
-
}
|
24
|
-
};
|
25
|
-
|
26
|
-
return (
|
27
|
-
<Controller
|
28
|
-
control={control}
|
29
|
-
name={name}
|
30
|
-
rules={{ required: required && 'Required field' }}
|
31
|
-
render={({ field: { ref, value, onChange }, fieldState: { error } }) => (
|
32
|
-
<DatePicker
|
33
|
-
mask=""
|
34
|
-
label={label}
|
35
|
-
inputRef={ref}
|
36
|
-
inputFormat={format}
|
37
|
-
value={value || null}
|
38
|
-
onError={onError}
|
39
|
-
onChange={(date) => {
|
40
|
-
onChange(isValid(date) ? dateFnsFormat(date, format) : date);
|
41
|
-
}}
|
42
|
-
renderInput={(props) => (
|
43
|
-
<TextField
|
44
|
-
{...props}
|
45
|
-
fullWidth
|
46
|
-
size="small"
|
47
|
-
variant="outlined"
|
48
|
-
error={!!error}
|
49
|
-
helperText={error?.message}
|
50
|
-
/>
|
51
|
-
)}
|
52
|
-
/>
|
53
|
-
)}
|
54
|
-
/>
|
55
|
-
);
|
56
|
-
};
|
57
|
-
|
58
|
-
export default DateValueField;
|
@@ -1,65 +0,0 @@
|
|
1
|
-
import AceEditor from 'react-ace';
|
2
|
-
import FormHelperText from '@mui/material/FormHelperText';
|
3
|
-
import Typography from '@mui/material/Typography';
|
4
|
-
import { Controller, useFormContext } from 'react-hook-form';
|
5
|
-
|
6
|
-
import 'ace-builds/src-noconflict/ace';
|
7
|
-
import 'ace-builds/src-noconflict/mode-json';
|
8
|
-
|
9
|
-
type Props = {
|
10
|
-
name: string;
|
11
|
-
label?: string;
|
12
|
-
required?: boolean;
|
13
|
-
};
|
14
|
-
|
15
|
-
const JsonValueField = ({ name, label, required = false }: Props) => {
|
16
|
-
const { control, setError, clearErrors } = useFormContext();
|
17
|
-
|
18
|
-
return (
|
19
|
-
<>
|
20
|
-
<Typography>{label}</Typography>
|
21
|
-
<Controller
|
22
|
-
control={control}
|
23
|
-
name={name}
|
24
|
-
rules={{
|
25
|
-
required: required && 'Required field',
|
26
|
-
}}
|
27
|
-
render={({ field: { value, onChange }, fieldState: { error } }) => (
|
28
|
-
<>
|
29
|
-
<AceEditor
|
30
|
-
value={value && typeof value !== 'string' ? JSON.stringify(value, null, 2) : value}
|
31
|
-
onChange={(value) => {
|
32
|
-
if (!value) {
|
33
|
-
onChange('');
|
34
|
-
return null;
|
35
|
-
}
|
36
|
-
try {
|
37
|
-
clearErrors(name);
|
38
|
-
const val = JSON.parse(value);
|
39
|
-
onChange(Array.isArray(val) ? '' : val);
|
40
|
-
} catch (e) {
|
41
|
-
setError(name, { message: 'Invalid JSON' });
|
42
|
-
onChange(value);
|
43
|
-
}
|
44
|
-
}}
|
45
|
-
mode="json"
|
46
|
-
width="100%"
|
47
|
-
height="200px"
|
48
|
-
fontSize="16"
|
49
|
-
setOptions={{
|
50
|
-
enableSnippets: false,
|
51
|
-
copyWithEmptySelection: true,
|
52
|
-
showLineNumbers: true,
|
53
|
-
tabSize: 2,
|
54
|
-
useWorker: false
|
55
|
-
}}
|
56
|
-
/>
|
57
|
-
{error && <FormHelperText error>{error.message}</FormHelperText>}
|
58
|
-
</>
|
59
|
-
)}
|
60
|
-
/>
|
61
|
-
</>
|
62
|
-
);
|
63
|
-
};
|
64
|
-
|
65
|
-
export default JsonValueField;
|
@@ -1,49 +0,0 @@
|
|
1
|
-
import { useMemo } from 'react';
|
2
|
-
import { useFormContext, useWatch } from 'react-hook-form';
|
3
|
-
import { MultiplePropertyFiller, PropertyFiller } from '../PropertyFiller';
|
4
|
-
import { PropertyUnion } from '../../../interfaces';
|
5
|
-
|
6
|
-
type Props = {
|
7
|
-
propertyFieldName: string;
|
8
|
-
name: string;
|
9
|
-
label?: string;
|
10
|
-
required?: boolean;
|
11
|
-
};
|
12
|
-
|
13
|
-
export const PropertyValueField = ({ propertyFieldName, name, label = '', required }: Props) => {
|
14
|
-
const { control } = useFormContext();
|
15
|
-
|
16
|
-
const propertyType = useWatch({ control, name: `${propertyFieldName}.propertyType` });
|
17
|
-
const isMultiple = useWatch({ control, name: `${propertyFieldName}.isMultiple` });
|
18
|
-
const format = useWatch({ control, name: `${propertyFieldName}.format` });
|
19
|
-
const restrictedValues = useWatch({ control, name: `${propertyFieldName}.restrictedValues` });
|
20
|
-
const properties = useWatch({ control, name: `${propertyFieldName}.properties` });
|
21
|
-
const isRequired = useWatch({ control, name: `${propertyFieldName}.isRequired` });
|
22
|
-
|
23
|
-
const fillerProperty: PropertyUnion = useMemo(() => {
|
24
|
-
const typeValue = typeof propertyType === 'string' ? propertyType : propertyType.value;
|
25
|
-
return {
|
26
|
-
name: label,
|
27
|
-
isRequired,
|
28
|
-
isMultiple,
|
29
|
-
format,
|
30
|
-
restrictedValues,
|
31
|
-
properties,
|
32
|
-
propertyType: typeValue,
|
33
|
-
defaultValue: null,
|
34
|
-
defaultValues: [],
|
35
|
-
sortOrder: 0,
|
36
|
-
isEnabled: true,
|
37
|
-
uiSettings: null,
|
38
|
-
validationNode: null,
|
39
|
-
};
|
40
|
-
}, [propertyType, format, restrictedValues, isMultiple, label, isRequired, properties]);
|
41
|
-
|
42
|
-
return isMultiple ? (
|
43
|
-
<MultiplePropertyFiller name={name} property={fillerProperty} title={label} required={required} />
|
44
|
-
) : (
|
45
|
-
<PropertyFiller name={name} property={fillerProperty} title={label} required={required} />
|
46
|
-
);
|
47
|
-
};
|
48
|
-
|
49
|
-
export default PropertyValueField;
|
@@ -1,50 +0,0 @@
|
|
1
|
-
import Select from '@mui/material/Select';
|
2
|
-
import MenuItem from '@mui/material/MenuItem';
|
3
|
-
import FormControl from '@mui/material/FormControl';
|
4
|
-
import InputLabel from '@mui/material/InputLabel';
|
5
|
-
import { ControlInput } from '../../Forms';
|
6
|
-
|
7
|
-
import { useController, useFormContext, useWatch } from 'react-hook-form';
|
8
|
-
|
9
|
-
type Props = {
|
10
|
-
name: string;
|
11
|
-
label?: string;
|
12
|
-
required?: boolean;
|
13
|
-
restrictedValues?: string[];
|
14
|
-
};
|
15
|
-
|
16
|
-
const StringValueField = ({ name, label, required, restrictedValues }: Props) => {
|
17
|
-
const { control } = useFormContext();
|
18
|
-
const {
|
19
|
-
field: { onChange, ref },
|
20
|
-
fieldState: { error },
|
21
|
-
} = useController({
|
22
|
-
control,
|
23
|
-
name,
|
24
|
-
rules: {
|
25
|
-
required:
|
26
|
-
required &&
|
27
|
-
(Array.isArray(restrictedValues) && restrictedValues.length
|
28
|
-
? 'Please, select a value'
|
29
|
-
: 'Please, fill this field'),
|
30
|
-
},
|
31
|
-
});
|
32
|
-
const value = useWatch({ control, name });
|
33
|
-
|
34
|
-
return Array.isArray(restrictedValues) && restrictedValues.length ? (
|
35
|
-
<FormControl fullWidth size="small" variant="outlined" error={!!error}>
|
36
|
-
<InputLabel htmlFor="type-select">{label}</InputLabel>
|
37
|
-
<Select labelId="type-select" label={label} value={value || ''} onChange={onChange} ref={ref}>
|
38
|
-
{restrictedValues.map((restrictedValue) => (
|
39
|
-
<MenuItem key={restrictedValue} value={restrictedValue}>
|
40
|
-
{restrictedValue}
|
41
|
-
</MenuItem>
|
42
|
-
))}
|
43
|
-
</Select>
|
44
|
-
</FormControl>
|
45
|
-
) : (
|
46
|
-
<ControlInput hideErrorMessage required={required} control={control} name={name} label={label} />
|
47
|
-
);
|
48
|
-
};
|
49
|
-
|
50
|
-
export default StringValueField;
|
@@ -1,67 +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
|
-
mask=""
|
53
|
-
inputRef={ref}
|
54
|
-
label={label}
|
55
|
-
ampm={false}
|
56
|
-
value={fieldValue}
|
57
|
-
inputFormat={format}
|
58
|
-
onError={onError}
|
59
|
-
onChange={handleChange}
|
60
|
-
renderInput={(props) => (
|
61
|
-
<TextField {...props} fullWidth size="small" variant="outlined" error={!!error} helperText={error?.message} />
|
62
|
-
)}
|
63
|
-
/>
|
64
|
-
);
|
65
|
-
};
|
66
|
-
|
67
|
-
export default TimeValueField;
|
@@ -1,115 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
ControlDate,
|
3
|
-
ControlDateTime,
|
4
|
-
ControlInput,
|
5
|
-
ControlNumberInput,
|
6
|
-
ControlSwitch,
|
7
|
-
ControlTime,
|
8
|
-
} from '../../Forms';
|
9
|
-
import JsonEditor from '../PropertyFiller/JsonEditor';
|
10
|
-
import StringValueField from '../PropertyValueField/StringValueField';
|
11
|
-
import { DefinitionFiller } from '../../Definition';
|
12
|
-
|
13
|
-
import { RefCallBack, useFormContext } from 'react-hook-form';
|
14
|
-
|
15
|
-
import {
|
16
|
-
DateProperty,
|
17
|
-
DateTimeProperty,
|
18
|
-
EntityTypeProperty,
|
19
|
-
PropertiesArrayType,
|
20
|
-
PropertyType,
|
21
|
-
PropertyUnion,
|
22
|
-
StringProperty,
|
23
|
-
TimeProperty,
|
24
|
-
} from '../../../interfaces';
|
25
|
-
import { useMemo } from 'react';
|
26
|
-
|
27
|
-
type Props = {
|
28
|
-
property: PropertyUnion;
|
29
|
-
name: string;
|
30
|
-
label?: string;
|
31
|
-
useExpression?: boolean;
|
32
|
-
required?: boolean;
|
33
|
-
inputRef: RefCallBack;
|
34
|
-
};
|
35
|
-
|
36
|
-
export const PropertyWidget = ({ property, name, label, useExpression, inputRef }: Props) => {
|
37
|
-
const { control } = useFormContext();
|
38
|
-
const propertyType = useMemo(
|
39
|
-
() => (typeof property.propertyType === 'string' ? property.propertyType : property['propertyType']['value']),
|
40
|
-
[property]
|
41
|
-
);
|
42
|
-
|
43
|
-
switch (propertyType) {
|
44
|
-
case PropertyType.BIG_DECIMAL:
|
45
|
-
case PropertyType.FLOAT:
|
46
|
-
case PropertyType.DOUBLE:
|
47
|
-
return <ControlNumberInput decimal required hideErrorMessage control={control} name={name} label={label} />;
|
48
|
-
case PropertyType.INTEGER:
|
49
|
-
case PropertyType.BIG_INTEGER:
|
50
|
-
case PropertyType.LONG:
|
51
|
-
return <ControlNumberInput required hideErrorMessage control={control} name={name} label={label} />;
|
52
|
-
case PropertyType.BOOLEAN:
|
53
|
-
return <ControlSwitch control={control} name={name} />;
|
54
|
-
case PropertyType.DATE:
|
55
|
-
return (
|
56
|
-
<ControlDate
|
57
|
-
required
|
58
|
-
hideErrorMessage
|
59
|
-
control={control}
|
60
|
-
name={name}
|
61
|
-
label={label}
|
62
|
-
format={(property as DateProperty).format}
|
63
|
-
/>
|
64
|
-
);
|
65
|
-
case PropertyType.TIME:
|
66
|
-
return (
|
67
|
-
<ControlTime
|
68
|
-
required
|
69
|
-
hideErrorMessage
|
70
|
-
control={control}
|
71
|
-
name={name}
|
72
|
-
label={label}
|
73
|
-
format={(property as TimeProperty).format}
|
74
|
-
/>
|
75
|
-
);
|
76
|
-
case PropertyType.DATE_TIME:
|
77
|
-
return (
|
78
|
-
<ControlDateTime
|
79
|
-
required
|
80
|
-
hideErrorMessage
|
81
|
-
control={control}
|
82
|
-
name={name}
|
83
|
-
label={label}
|
84
|
-
format={(property as DateTimeProperty).format}
|
85
|
-
/>
|
86
|
-
);
|
87
|
-
case PropertyType.JSON:
|
88
|
-
return <JsonEditor validate name={name} inputRef={inputRef} />;
|
89
|
-
case PropertyType.STRING:
|
90
|
-
return (
|
91
|
-
<StringValueField
|
92
|
-
required
|
93
|
-
name={name}
|
94
|
-
label={label}
|
95
|
-
restrictedValues={(property as StringProperty).restrictedValues}
|
96
|
-
/>
|
97
|
-
);
|
98
|
-
case PropertyType.ENTITY_REFERENCE:
|
99
|
-
return <ControlInput required hideErrorMessage name={name} label={label} control={control} />;
|
100
|
-
case PropertyType.ANY:
|
101
|
-
return <JsonEditor name={name} inputRef={inputRef} />;
|
102
|
-
case PropertyType.ENTITY:
|
103
|
-
return (
|
104
|
-
<DefinitionFiller
|
105
|
-
properties={(property as EntityTypeProperty).properties as PropertiesArrayType}
|
106
|
-
dataFieldName={name}
|
107
|
-
useExpression={useExpression}
|
108
|
-
/>
|
109
|
-
);
|
110
|
-
default:
|
111
|
-
return <div>No widget</div>;
|
112
|
-
}
|
113
|
-
};
|
114
|
-
|
115
|
-
export default PropertyWidget;
|
@@ -1,148 +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 Accordion from '@mui/material/Accordion';
|
5
|
-
import AccordionSummary from '@mui/material/AccordionSummary';
|
6
|
-
import AccordionDetails from '@mui/material/AccordionDetails';
|
7
|
-
import AccordionActions from '@mui/material/AccordionActions';
|
8
|
-
import { ExpandMore } from '@mui/icons-material';
|
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/common';
|
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: null,
|
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({
|
58
|
-
control,
|
59
|
-
name: fieldName,
|
60
|
-
rules: { required: required && 'Please, add properties' },
|
61
|
-
});
|
62
|
-
const properties = useWatch({ control, name: fieldName });
|
63
|
-
|
64
|
-
const refs = useRef([]);
|
65
|
-
|
66
|
-
useEffect(() => {
|
67
|
-
if (typeof focusOnIndex === 'number' && refs.current[focusOnIndex]) {
|
68
|
-
refs.current[focusOnIndex].scrollIntoView({
|
69
|
-
behavior: 'smooth',
|
70
|
-
block: 'start',
|
71
|
-
});
|
72
|
-
}
|
73
|
-
}, [focusOnIndex, refs]);
|
74
|
-
|
75
|
-
const handleAddParameter = useCallback(() => {
|
76
|
-
if (properties) {
|
77
|
-
setValue(`${fieldName}.${properties.length}`, defaultPropertyValues);
|
78
|
-
} else {
|
79
|
-
setValue(fieldName, [defaultPropertyValues]);
|
80
|
-
}
|
81
|
-
clearErrors(fieldName);
|
82
|
-
}, [properties, fieldName, clearErrors, setValue]);
|
83
|
-
|
84
|
-
const handleRemoveParameter = useCallback(
|
85
|
-
(index) => {
|
86
|
-
setValue(`${fieldName}`, removeArrayItem(properties, index));
|
87
|
-
},
|
88
|
-
[properties, fieldName, setValue]
|
89
|
-
);
|
90
|
-
|
91
|
-
return (
|
92
|
-
<>
|
93
|
-
{error && error.message && (
|
94
|
-
<Grid sm={12}>
|
95
|
-
<Typography color="secondary">{error.message}</Typography>
|
96
|
-
</Grid>
|
97
|
-
)}
|
98
|
-
{properties &&
|
99
|
-
properties.map((property, index) => (
|
100
|
-
<Grid key={index} sm={12} ref={(ref) => (refs.current[index] = ref)}>
|
101
|
-
<Accordion defaultExpanded elevation={3}>
|
102
|
-
<AccordionSummary expandIcon={<ExpandMore />}>
|
103
|
-
<Typography
|
104
|
-
color={error && error[index] ? 'secondary' : 'initial'}
|
105
|
-
style={{ wordBreak: 'break-word' }}
|
106
|
-
>
|
107
|
-
{property.name || `Property ${index + 1}`}
|
108
|
-
</Typography>
|
109
|
-
</AccordionSummary>
|
110
|
-
<AccordionDetails>
|
111
|
-
<CreatePropertyFormFields
|
112
|
-
propertyFieldName={`${fieldName}.${index}`}
|
113
|
-
entityDefinition={entityDefinition}
|
114
|
-
globalParameter={globalParameter}
|
115
|
-
customPropertyFields={customPropertyFields}
|
116
|
-
/>
|
117
|
-
</AccordionDetails>
|
118
|
-
<AccordionActions>
|
119
|
-
<Button
|
120
|
-
variant="contained"
|
121
|
-
size="small"
|
122
|
-
color="secondary"
|
123
|
-
onClick={() => handleRemoveParameter(index)}
|
124
|
-
>
|
125
|
-
Remove
|
126
|
-
</Button>
|
127
|
-
</AccordionActions>
|
128
|
-
</Accordion>
|
129
|
-
</Grid>
|
130
|
-
))}
|
131
|
-
|
132
|
-
{!hideAddButton && (
|
133
|
-
<Grid xs={12}>
|
134
|
-
<Button
|
135
|
-
variant="contained"
|
136
|
-
size="small"
|
137
|
-
color="primary"
|
138
|
-
onClick={handleAddParameter}
|
139
|
-
>
|
140
|
-
Add property
|
141
|
-
</Button>
|
142
|
-
</Grid>
|
143
|
-
)}
|
144
|
-
</>
|
145
|
-
);
|
146
|
-
};
|
147
|
-
|
148
|
-
export default CreatePropertiesList;
|