@dartech/arsenal-ui 1.2.5 → 1.2.7
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 +12 -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/InfoItem/styles.d.ts +12 -0
- 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/usePropertyFiller.d.ts +24 -0
- package/src/lib/Property/PropertyFiller/useStyles.d.ts +12 -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/Status/styles.d.ts +12 -0
- 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 +12 -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 +14 -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 -94
- 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 -128
- 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 -102
- 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,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;
|
@@ -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;
|