@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,71 +0,0 @@
|
|
1
|
-
import Box from '@mui/material/Box';
|
2
|
-
import Grid from '@mui/material/Unstable_Grid2';
|
3
|
-
import { StepperData, StepperView } from '../../StepperView';
|
4
|
-
import { PropertyFiller } from '../../Property';
|
5
|
-
import { MultiplePropertyFiller } from '../../Property';
|
6
|
-
|
7
|
-
import { useMemo } from 'react';
|
8
|
-
|
9
|
-
import { PropertiesArrayType } from '../../../interfaces';
|
10
|
-
|
11
|
-
type Props = {
|
12
|
-
properties: PropertiesArrayType;
|
13
|
-
dataFieldName: string;
|
14
|
-
useExpression?: boolean;
|
15
|
-
title?: string;
|
16
|
-
};
|
17
|
-
|
18
|
-
export const DefinitionFiller = ({ properties, dataFieldName, useExpression = false, title }: Props) => {
|
19
|
-
const stepperData: StepperData = useMemo(() => {
|
20
|
-
if (properties) {
|
21
|
-
return properties.map((property) => {
|
22
|
-
const propertyType =
|
23
|
-
typeof property.propertyType === 'string' ? property.propertyType : property['propertyType']['value'];
|
24
|
-
return {
|
25
|
-
label: (
|
26
|
-
<Box display="flex" flexDirection="column">
|
27
|
-
<b>
|
28
|
-
{property.name}
|
29
|
-
{property.isRequired ? '*' : ''}
|
30
|
-
</b>
|
31
|
-
<span>
|
32
|
-
{property.key} | {property.isMultiple ? 'multiple' : 'single'} | {propertyType}
|
33
|
-
</span>
|
34
|
-
</Box>
|
35
|
-
),
|
36
|
-
content: property.isMultiple ? (
|
37
|
-
<MultiplePropertyFiller
|
38
|
-
property={property}
|
39
|
-
name={`${dataFieldName}.${property.key}`}
|
40
|
-
useExpression={useExpression}
|
41
|
-
label={property.name}
|
42
|
-
required={property.isRequired}
|
43
|
-
/>
|
44
|
-
) : (
|
45
|
-
<PropertyFiller
|
46
|
-
property={property}
|
47
|
-
name={`${dataFieldName}.${property.key}`}
|
48
|
-
useExpression={useExpression}
|
49
|
-
label={property.name}
|
50
|
-
required={property.isRequired}
|
51
|
-
/>
|
52
|
-
),
|
53
|
-
};
|
54
|
-
});
|
55
|
-
}
|
56
|
-
return [];
|
57
|
-
}, [properties, dataFieldName, useExpression]);
|
58
|
-
|
59
|
-
return (
|
60
|
-
<Grid container direction="column" spacing={2}>
|
61
|
-
{title && (
|
62
|
-
<Grid xs={12}>
|
63
|
-
<div style={{ fontWeight: '600' }}>{title}</div>
|
64
|
-
</Grid>
|
65
|
-
)}
|
66
|
-
<StepperView data={stepperData} />
|
67
|
-
</Grid>
|
68
|
-
);
|
69
|
-
};
|
70
|
-
|
71
|
-
export default DefinitionFiller;
|
@@ -1,54 +0,0 @@
|
|
1
|
-
import Box from '@mui/material/Box';
|
2
|
-
import Grid from '@mui/material/Unstable_Grid2';
|
3
|
-
import { StepperData, StepperView } from '../../StepperView';
|
4
|
-
import PropertyDataView from './PropertyDataView';
|
5
|
-
|
6
|
-
import { useMemo } from 'react';
|
7
|
-
import { PropertiesArrayType, PropertyType } from '../../../interfaces';
|
8
|
-
|
9
|
-
type Props = {
|
10
|
-
properties: PropertiesArrayType<unknown>;
|
11
|
-
data: unknown;
|
12
|
-
};
|
13
|
-
|
14
|
-
export const DefinitionValueView = ({ properties, data }: Props) => {
|
15
|
-
const stepperData: StepperData = useMemo(() => {
|
16
|
-
if (properties && data) {
|
17
|
-
return properties.map((property) => {
|
18
|
-
const { key, name, isMultiple, propertyType } = property;
|
19
|
-
const value = data[property.key] ?? data;
|
20
|
-
return {
|
21
|
-
label: (
|
22
|
-
<Box display="flex" flexDirection="column">
|
23
|
-
<b>{name}</b>
|
24
|
-
<span>
|
25
|
-
{key} | {isMultiple ? 'multiple' : 'single'} | {propertyType}
|
26
|
-
</span>
|
27
|
-
</Box>
|
28
|
-
),
|
29
|
-
content:
|
30
|
-
isMultiple && Array.isArray(value) && property.propertyType !== PropertyType.ANY ? (
|
31
|
-
<>
|
32
|
-
{value.map((itemValue, index) => (
|
33
|
-
<Box key={index} mb={2}>
|
34
|
-
<PropertyDataView property={property} data={itemValue} hasBackground />
|
35
|
-
</Box>
|
36
|
-
))}
|
37
|
-
</>
|
38
|
-
) : (
|
39
|
-
<PropertyDataView property={property} data={value} />
|
40
|
-
),
|
41
|
-
};
|
42
|
-
});
|
43
|
-
}
|
44
|
-
return [];
|
45
|
-
}, [properties, data]);
|
46
|
-
|
47
|
-
return (
|
48
|
-
<Grid container direction="column" spacing={2}>
|
49
|
-
<StepperView data={stepperData} />
|
50
|
-
</Grid>
|
51
|
-
);
|
52
|
-
};
|
53
|
-
|
54
|
-
export default DefinitionValueView;
|
@@ -1,67 +0,0 @@
|
|
1
|
-
import Box from '@mui/material/Box';
|
2
|
-
import { JsonView } from '../../JsonView';
|
3
|
-
import DefinitionValueView from './DefinitionValueView';
|
4
|
-
|
5
|
-
import { useMemo } from 'react';
|
6
|
-
import { isExpression, propertiesObjectToArray } from '../../../utils';
|
7
|
-
|
8
|
-
import { PropertyUnion, PropertyType, PropertiesArrayType } from '../../../interfaces';
|
9
|
-
|
10
|
-
type Props = {
|
11
|
-
property: PropertyUnion;
|
12
|
-
data: unknown;
|
13
|
-
hasBackground?: boolean;
|
14
|
-
};
|
15
|
-
|
16
|
-
type PropertyValueComponentProps = {
|
17
|
-
property: PropertyUnion;
|
18
|
-
data: unknown;
|
19
|
-
properties?: PropertiesArrayType;
|
20
|
-
};
|
21
|
-
|
22
|
-
const PropertyValueComponent = ({ property, data, properties }: PropertyValueComponentProps) => {
|
23
|
-
const defaultRender = (value: any) => (
|
24
|
-
<Box style={{ backgroundColor: '#fff', border: '1px solid #ccc', borderRadius: '4px', padding: '4px' }}>
|
25
|
-
{value === null ? 'null' : value?.toString()}
|
26
|
-
</Box>
|
27
|
-
)
|
28
|
-
if (isExpression(data)) {
|
29
|
-
return defaultRender(data);
|
30
|
-
} else {
|
31
|
-
switch (property.propertyType) {
|
32
|
-
case PropertyType.JSON:
|
33
|
-
return <JsonView value={data} />;
|
34
|
-
case PropertyType.ENTITY:
|
35
|
-
return <DefinitionValueView properties={properties} data={data} />;
|
36
|
-
case PropertyType.ANY:
|
37
|
-
// TODO need to prefetch data and show as is
|
38
|
-
return (typeof data === 'object' ? <JsonView value={data} /> : defaultRender(data));
|
39
|
-
default:
|
40
|
-
return defaultRender(data);
|
41
|
-
}
|
42
|
-
}
|
43
|
-
};
|
44
|
-
|
45
|
-
export const PropertyDataView = ({ property, data, hasBackground = false }: Props) => {
|
46
|
-
const properties = useMemo(() => {
|
47
|
-
if (property.propertyType === PropertyType.ENTITY) {
|
48
|
-
if (Array.isArray(property.properties)) {
|
49
|
-
return property.properties;
|
50
|
-
}
|
51
|
-
return propertiesObjectToArray(property.properties);
|
52
|
-
}
|
53
|
-
return [];
|
54
|
-
}, [property]);
|
55
|
-
|
56
|
-
return (
|
57
|
-
<Box
|
58
|
-
style={{
|
59
|
-
backgroundColor: hasBackground ? '#f1f1f1' : 'none',
|
60
|
-
}}
|
61
|
-
>
|
62
|
-
<PropertyValueComponent property={property} data={data} properties={properties} />
|
63
|
-
</Box>
|
64
|
-
);
|
65
|
-
};
|
66
|
-
|
67
|
-
export default PropertyDataView;
|
@@ -1,46 +0,0 @@
|
|
1
|
-
import { useCallback, useMemo } from 'react';
|
2
|
-
import SvgIcon from '@mui/material/SvgIcon';
|
3
|
-
import { useNavigate, useLocation, Link } from 'react-router-dom';
|
4
|
-
import IconButton from '@mui/material/IconButton';
|
5
|
-
import Button from '@mui/material/Button';
|
6
|
-
import Box from '@mui/material/Box';
|
7
|
-
|
8
|
-
type Props = {
|
9
|
-
text?: string;
|
10
|
-
buttonProps?: Record<string, unknown>;
|
11
|
-
};
|
12
|
-
export const BackButton = ({ text, buttonProps = {} }: Props) => {
|
13
|
-
const navigate = useNavigate();
|
14
|
-
const { state } = useLocation();
|
15
|
-
const fromLocation = useMemo(() => state?.['from'], [state]);
|
16
|
-
|
17
|
-
const handleClick = useCallback(() => {
|
18
|
-
if (fromLocation) {
|
19
|
-
navigate(fromLocation);
|
20
|
-
} else navigate(-1);
|
21
|
-
}, [navigate, fromLocation]);
|
22
|
-
|
23
|
-
return (
|
24
|
-
<Box mr={2}>
|
25
|
-
{text ? (
|
26
|
-
<Button
|
27
|
-
color="inherit"
|
28
|
-
onClick={!fromLocation ? handleClick : null}
|
29
|
-
component={Link}
|
30
|
-
to={fromLocation ?? ''}
|
31
|
-
{...buttonProps}
|
32
|
-
>
|
33
|
-
{text}
|
34
|
-
</Button>
|
35
|
-
) : (
|
36
|
-
<IconButton onClick={handleClick}>
|
37
|
-
<SvgIcon>
|
38
|
-
<path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z" />
|
39
|
-
</SvgIcon>
|
40
|
-
</IconButton>
|
41
|
-
)}
|
42
|
-
</Box>
|
43
|
-
);
|
44
|
-
};
|
45
|
-
|
46
|
-
export default BackButton;
|
@@ -1,125 +0,0 @@
|
|
1
|
-
import AceEditor from 'react-ace';
|
2
|
-
import 'ace-builds/src-noconflict/mode-python';
|
3
|
-
import 'ace-builds/src-noconflict/theme-monokai';
|
4
|
-
import 'ace-builds/src-noconflict/ext-language_tools';
|
5
|
-
import Typography from '@mui/material/Typography';
|
6
|
-
import Box from '@mui/material/Box';
|
7
|
-
import FormHelperText from '@mui/material/FormHelperText';
|
8
|
-
import { Control, useFormContext, useController, useWatch } from 'react-hook-form';
|
9
|
-
import { forwardRef } from 'react';
|
10
|
-
|
11
|
-
export interface ControlAceEditorProps {
|
12
|
-
name: string;
|
13
|
-
control: Control<any>;
|
14
|
-
mode?: string;
|
15
|
-
label?: string;
|
16
|
-
width?: string;
|
17
|
-
height?: string;
|
18
|
-
theme?: string;
|
19
|
-
readOnly?: boolean;
|
20
|
-
required?: boolean;
|
21
|
-
validateJson?: boolean;
|
22
|
-
fontSize?: number;
|
23
|
-
validate?: boolean;
|
24
|
-
parseValue?: boolean;
|
25
|
-
[key: string]: unknown;
|
26
|
-
}
|
27
|
-
|
28
|
-
export const ControlAceEditor = forwardRef<AceEditor, ControlAceEditorProps>(({
|
29
|
-
control,
|
30
|
-
name,
|
31
|
-
mode = 'json',
|
32
|
-
label,
|
33
|
-
width = '100%',
|
34
|
-
height = '200px',
|
35
|
-
theme = 'monokai',
|
36
|
-
readOnly,
|
37
|
-
required = false,
|
38
|
-
validateJson = false,
|
39
|
-
fontSize = 16,
|
40
|
-
validate = true,
|
41
|
-
parseValue,
|
42
|
-
...otherProps
|
43
|
-
}, ref) => {
|
44
|
-
const { setError, clearErrors } = useFormContext();
|
45
|
-
const {
|
46
|
-
field: { onChange },
|
47
|
-
fieldState: { error },
|
48
|
-
} = useController({ control, name });
|
49
|
-
const value = useWatch({ control, name });
|
50
|
-
|
51
|
-
const handleChange = (value) => {
|
52
|
-
if (!value && required) {
|
53
|
-
setError(name, { message: 'Required field' });
|
54
|
-
} else {
|
55
|
-
clearErrors(name);
|
56
|
-
}
|
57
|
-
|
58
|
-
if (validateJson) {
|
59
|
-
try {
|
60
|
-
JSON.parse(value);
|
61
|
-
clearErrors(name);
|
62
|
-
} catch (error) {
|
63
|
-
setError(name, { message: 'Invalid JSON' });
|
64
|
-
}
|
65
|
-
}
|
66
|
-
|
67
|
-
if (parseValue) {
|
68
|
-
try {
|
69
|
-
const val = JSON.parse(value);
|
70
|
-
console.log('parsed val:', val);
|
71
|
-
onChange(val);
|
72
|
-
} catch (e) {
|
73
|
-
onChange(value);
|
74
|
-
}
|
75
|
-
} else {
|
76
|
-
onChange(value);
|
77
|
-
}
|
78
|
-
};
|
79
|
-
|
80
|
-
return (
|
81
|
-
<Box display="flex" flexDirection="column" width="100%">
|
82
|
-
<Box>
|
83
|
-
{label && (
|
84
|
-
<Typography variant="subtitle1" display="inline" style={{ marginRight: 10 }}>
|
85
|
-
{label}
|
86
|
-
</Typography>
|
87
|
-
)}
|
88
|
-
</Box>
|
89
|
-
<>
|
90
|
-
<AceEditor
|
91
|
-
ref={ref}
|
92
|
-
focus
|
93
|
-
wrapEnabled
|
94
|
-
width={width}
|
95
|
-
height={height}
|
96
|
-
showPrintMargin={false}
|
97
|
-
theme={theme}
|
98
|
-
fontSize={fontSize}
|
99
|
-
setOptions={{
|
100
|
-
enableLiveAutocompletion: true,
|
101
|
-
enableBasicAutocompletion: true,
|
102
|
-
enableSnippets: true,
|
103
|
-
showLineNumbers: true,
|
104
|
-
tabSize: 2,
|
105
|
-
useWorker: false
|
106
|
-
}}
|
107
|
-
style={{ lineHeight: 1.4, zIndex: 0, isolation: 'isolate' }}
|
108
|
-
readOnly={readOnly}
|
109
|
-
value={mode === 'json' && typeof value !== 'string' ? (value === null ? '' : JSON.stringify(value)) : value}
|
110
|
-
onChange={handleChange}
|
111
|
-
mode={mode}
|
112
|
-
onLoad={(editor) => {
|
113
|
-
if (!validate || !validateJson) {
|
114
|
-
editor.getSession().setUseWorker(false);
|
115
|
-
}
|
116
|
-
}}
|
117
|
-
{...otherProps}
|
118
|
-
/>
|
119
|
-
{error && <FormHelperText error>{error.message}</FormHelperText>}
|
120
|
-
</>
|
121
|
-
</Box>
|
122
|
-
);
|
123
|
-
});
|
124
|
-
|
125
|
-
export default ControlAceEditor;
|
@@ -1,145 +0,0 @@
|
|
1
|
-
import Autocomplete, { AutocompleteProps } from '@mui/material/Autocomplete';
|
2
|
-
import TextField, { TextFieldProps } from '@mui/material/TextField';
|
3
|
-
import { Control, useController, useWatch } from 'react-hook-form';
|
4
|
-
|
5
|
-
import useAutocomplete from './useAutocomplete';
|
6
|
-
import { ValidateFunc } from '../../interfaces';
|
7
|
-
|
8
|
-
/**
|
9
|
-
* This interface is referencing the [[ControlAutocomplete]] component props.
|
10
|
-
* @category Forms
|
11
|
-
*/
|
12
|
-
export type ControlAutocompleteProps = Omit<
|
13
|
-
AutocompleteProps<unknown, boolean, boolean, boolean, React.ElementType<any>>,
|
14
|
-
'renderInput'
|
15
|
-
> & {
|
16
|
-
/**
|
17
|
-
* React Hook Form control `name` propery
|
18
|
-
*/
|
19
|
-
name: string;
|
20
|
-
/**
|
21
|
-
* Label for MUI TextField select component
|
22
|
-
*/
|
23
|
-
label?: string;
|
24
|
-
/**
|
25
|
-
* React Hook Form `control`
|
26
|
-
*/
|
27
|
-
control: Control<any>;
|
28
|
-
/**
|
29
|
-
* Is input required flag
|
30
|
-
*/
|
31
|
-
required?: boolean;
|
32
|
-
/**
|
33
|
-
* React Hook Form `defaultValue`
|
34
|
-
*/
|
35
|
-
defaultValue?: unknown;
|
36
|
-
/**
|
37
|
-
* Is disabled input flag
|
38
|
-
*/
|
39
|
-
disabled?: boolean;
|
40
|
-
/**
|
41
|
-
* React Hook Form validate function
|
42
|
-
* ```typescript
|
43
|
-
* type ValidateFunc = (value: string) => boolean | string;
|
44
|
-
* ```
|
45
|
-
*/
|
46
|
-
validate?: ValidateFunc | Record<string, ValidateFunc>;
|
47
|
-
/**
|
48
|
-
* Hide error message flag
|
49
|
-
*/
|
50
|
-
hideErrorMessage?: boolean;
|
51
|
-
/**
|
52
|
-
* Custom onChange functionƒ
|
53
|
-
*/
|
54
|
-
onChange?: (event: React.ChangeEvent<HTMLInputElement>, value: unknown) => void;
|
55
|
-
/**
|
56
|
-
* Key for option label
|
57
|
-
*/
|
58
|
-
labelKey?: string;
|
59
|
-
/**
|
60
|
-
* Key for option value
|
61
|
-
*/
|
62
|
-
valueKey?: string;
|
63
|
-
/**
|
64
|
-
* Select options
|
65
|
-
*/
|
66
|
-
options: string[] | unknown[];
|
67
|
-
textFieldProps?: TextFieldProps;
|
68
|
-
};
|
69
|
-
|
70
|
-
/**
|
71
|
-
* Material UI `Autocomplete` controlled component. Used with react-hook-form
|
72
|
-
* @category Forms
|
73
|
-
*/
|
74
|
-
export const ControlAutocomplete = ({
|
75
|
-
control,
|
76
|
-
validate,
|
77
|
-
name = '',
|
78
|
-
label = '',
|
79
|
-
required = false,
|
80
|
-
defaultValue = '',
|
81
|
-
disabled = false,
|
82
|
-
hideErrorMessage = false,
|
83
|
-
onChange: customOnChange,
|
84
|
-
labelKey,
|
85
|
-
valueKey,
|
86
|
-
options = [],
|
87
|
-
multiple,
|
88
|
-
textFieldProps = {},
|
89
|
-
disableCloseOnSelect,
|
90
|
-
...autocompleteProps
|
91
|
-
}: ControlAutocompleteProps) => {
|
92
|
-
const {
|
93
|
-
field: { ref, onChange },
|
94
|
-
fieldState: { error },
|
95
|
-
} = useController({
|
96
|
-
name,
|
97
|
-
control,
|
98
|
-
defaultValue,
|
99
|
-
rules: {
|
100
|
-
required: required && 'Please, fill this field',
|
101
|
-
validate,
|
102
|
-
},
|
103
|
-
});
|
104
|
-
const formValue = useWatch({ control, name, defaultValue: multiple ? [] : null });
|
105
|
-
const { getOptionLabel, isOptionEqualToValue, renderOption } = useAutocomplete({ valueKey, labelKey });
|
106
|
-
|
107
|
-
const handleChange = (_, value) => {
|
108
|
-
onChange(value);
|
109
|
-
};
|
110
|
-
|
111
|
-
return (
|
112
|
-
<Autocomplete
|
113
|
-
fullWidth
|
114
|
-
disablePortal
|
115
|
-
size="small"
|
116
|
-
readOnly={disabled}
|
117
|
-
options={options}
|
118
|
-
multiple={multiple}
|
119
|
-
getOptionLabel={getOptionLabel}
|
120
|
-
isOptionEqualToValue={isOptionEqualToValue}
|
121
|
-
disableCloseOnSelect={disableCloseOnSelect || multiple}
|
122
|
-
filterSelectedOptions={multiple}
|
123
|
-
value={formValue}
|
124
|
-
onChange={customOnChange ? customOnChange : handleChange}
|
125
|
-
renderOption={renderOption}
|
126
|
-
renderInput={(params) => {
|
127
|
-
return (
|
128
|
-
<TextField
|
129
|
-
{...params}
|
130
|
-
variant="outlined"
|
131
|
-
name={name}
|
132
|
-
label={label}
|
133
|
-
error={!!error}
|
134
|
-
inputRef={ref}
|
135
|
-
helperText={!hideErrorMessage && error?.message}
|
136
|
-
{...textFieldProps}
|
137
|
-
/>
|
138
|
-
);
|
139
|
-
}}
|
140
|
-
{...autocompleteProps}
|
141
|
-
/>
|
142
|
-
);
|
143
|
-
};
|
144
|
-
|
145
|
-
export default ControlAutocomplete;
|
@@ -1,113 +0,0 @@
|
|
1
|
-
import FormControl from '@mui/material/FormControl';
|
2
|
-
import FormControlLabel from '@mui/material/FormControlLabel';
|
3
|
-
import FormHelperText from '@mui/material/FormHelperText';
|
4
|
-
import Checkbox, { CheckboxProps } from '@mui/material/Checkbox';
|
5
|
-
|
6
|
-
import { useMemo } from 'react';
|
7
|
-
import { Control, useController, useWatch } from 'react-hook-form';
|
8
|
-
import { ValidateFunc } from '../../interfaces';
|
9
|
-
|
10
|
-
/**
|
11
|
-
* This interface is referencing the [[ControlCheckbox]] component props.
|
12
|
-
* @category Forms
|
13
|
-
*/
|
14
|
-
export type ControlCheckboxProps = CheckboxProps & {
|
15
|
-
/**
|
16
|
-
* React Hook Form control `name` propery
|
17
|
-
*/
|
18
|
-
name: string;
|
19
|
-
/**
|
20
|
-
* Label for MUI TextField component
|
21
|
-
*/
|
22
|
-
label?: string;
|
23
|
-
/**
|
24
|
-
* React Hook Form `control`
|
25
|
-
*/
|
26
|
-
control: Control<any>;
|
27
|
-
/**
|
28
|
-
* React Hook Form `defaultValue`
|
29
|
-
*/
|
30
|
-
defaultValue?: unknown;
|
31
|
-
/**
|
32
|
-
* Is disabled input flag
|
33
|
-
*/
|
34
|
-
disabled?: boolean;
|
35
|
-
/**
|
36
|
-
* React Hook Form validate function
|
37
|
-
* ```typescript
|
38
|
-
* type ValidateFunc = (value: string) => boolean | string;
|
39
|
-
* ```
|
40
|
-
*/
|
41
|
-
validate?: ValidateFunc | Record<string, ValidateFunc>;
|
42
|
-
/**
|
43
|
-
* Hide error message flag
|
44
|
-
*/
|
45
|
-
hideErrorMessage?: boolean;
|
46
|
-
/**
|
47
|
-
* Custom onChange functionƒ
|
48
|
-
*/
|
49
|
-
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
50
|
-
};
|
51
|
-
|
52
|
-
/**
|
53
|
-
* Material UI `Checkbox` controlled component. Used with react-hook-form
|
54
|
-
* @category Forms
|
55
|
-
*/
|
56
|
-
export const ControlCheckbox = ({
|
57
|
-
control,
|
58
|
-
validate,
|
59
|
-
name = '',
|
60
|
-
label = '',
|
61
|
-
required = false,
|
62
|
-
defaultValue = '',
|
63
|
-
disabled = false,
|
64
|
-
hideErrorMessage = false,
|
65
|
-
onChange: customOnChange,
|
66
|
-
...checkboxProps
|
67
|
-
}: ControlCheckboxProps) => {
|
68
|
-
const {
|
69
|
-
field: { ref, onChange },
|
70
|
-
fieldState: { error },
|
71
|
-
} = useController({
|
72
|
-
name,
|
73
|
-
control,
|
74
|
-
defaultValue,
|
75
|
-
});
|
76
|
-
const value = useWatch({ control, name });
|
77
|
-
|
78
|
-
const checked = useMemo(() => {
|
79
|
-
if (typeof value === 'boolean') {
|
80
|
-
return value;
|
81
|
-
} else if (typeof value === 'string') {
|
82
|
-
if (value === 'false') {
|
83
|
-
onChange(false);
|
84
|
-
return false;
|
85
|
-
} else if (value === 'true') {
|
86
|
-
onChange(true);
|
87
|
-
return true;
|
88
|
-
}
|
89
|
-
}
|
90
|
-
return false;
|
91
|
-
}, [value, onChange]);
|
92
|
-
|
93
|
-
return (
|
94
|
-
<FormControl error={!!error} component="fieldset" variant="standard" disabled={disabled}>
|
95
|
-
<FormControlLabel
|
96
|
-
control={
|
97
|
-
<Checkbox
|
98
|
-
checked={checked}
|
99
|
-
onChange={customOnChange ? customOnChange : onChange}
|
100
|
-
name={name}
|
101
|
-
inputRef={ref}
|
102
|
-
disabled={disabled}
|
103
|
-
{...checkboxProps}
|
104
|
-
/>
|
105
|
-
}
|
106
|
-
label={label}
|
107
|
-
/>
|
108
|
-
{!hideErrorMessage && error?.message && <FormHelperText>{error.message}</FormHelperText>}
|
109
|
-
</FormControl>
|
110
|
-
);
|
111
|
-
};
|
112
|
-
|
113
|
-
export default ControlCheckbox;
|
@@ -1,75 +0,0 @@
|
|
1
|
-
import TextField from '@mui/material/TextField';
|
2
|
-
import { DatePicker } from '@mui/x-date-pickers/DatePicker';
|
3
|
-
|
4
|
-
import { isValid, format as dateFnsFormat, isMatch } from 'date-fns';
|
5
|
-
import { Control, useController, useWatch } from 'react-hook-form';
|
6
|
-
import { DATE_DEFAULT_FORMAT } from '../../interfaces';
|
7
|
-
|
8
|
-
type Props = {
|
9
|
-
/**
|
10
|
-
* React Hook Form `control`
|
11
|
-
*/
|
12
|
-
control: Control<any>;
|
13
|
-
/**
|
14
|
-
* Is input required flag
|
15
|
-
*/
|
16
|
-
required?: boolean;
|
17
|
-
name: string;
|
18
|
-
label?: string;
|
19
|
-
format?: string;
|
20
|
-
hideErrorMessage?: boolean;
|
21
|
-
};
|
22
|
-
|
23
|
-
export const ControlDate = ({
|
24
|
-
control,
|
25
|
-
name,
|
26
|
-
required,
|
27
|
-
label,
|
28
|
-
format = DATE_DEFAULT_FORMAT,
|
29
|
-
hideErrorMessage = false,
|
30
|
-
}: Props) => {
|
31
|
-
const {
|
32
|
-
field: { onChange, ref },
|
33
|
-
fieldState: { error },
|
34
|
-
} = useController({
|
35
|
-
control,
|
36
|
-
name,
|
37
|
-
rules: {
|
38
|
-
required: required && 'Please, fill this field',
|
39
|
-
validate: (val) => {
|
40
|
-
if (isMatch(val, format)) {
|
41
|
-
return true;
|
42
|
-
}
|
43
|
-
return 'Incorrect date format';
|
44
|
-
},
|
45
|
-
},
|
46
|
-
});
|
47
|
-
const value = useWatch({ control, name });
|
48
|
-
|
49
|
-
const handleChange = (date) => {
|
50
|
-
onChange(isValid(date) ? dateFnsFormat(date, format) : date);
|
51
|
-
};
|
52
|
-
|
53
|
-
return (
|
54
|
-
<DatePicker
|
55
|
-
label={label}
|
56
|
-
inputRef={ref}
|
57
|
-
inputFormat={format}
|
58
|
-
value={value || null}
|
59
|
-
onChange={handleChange}
|
60
|
-
renderInput={(props) => (
|
61
|
-
<TextField
|
62
|
-
{...props}
|
63
|
-
fullWidth
|
64
|
-
size="small"
|
65
|
-
variant="outlined"
|
66
|
-
name={name}
|
67
|
-
error={!!error}
|
68
|
-
helperText={!hideErrorMessage && error?.message}
|
69
|
-
/>
|
70
|
-
)}
|
71
|
-
/>
|
72
|
-
);
|
73
|
-
};
|
74
|
-
|
75
|
-
export default ControlDate;
|