@dartech/arsenal-ui 1.2.3 → 1.2.5
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/.babelrc +13 -0
- package/.eslintrc.json +22 -0
- package/{index.d.ts → index.ts} +5 -5
- package/jest.config.ts +11 -0
- package/package.json +3 -12
- package/project.json +94 -0
- package/rollup.config.js +146 -0
- package/src/assets/chevron_left_gray.svg +3 -0
- package/src/consts/index.ts +13 -0
- package/src/interfaces/common.ts +18 -0
- package/src/interfaces/definition.ts +143 -0
- package/src/interfaces/{index.d.ts → index.ts} +3 -3
- package/src/interfaces/ui.ts +80 -0
- package/src/lib/Alert/Alert.tsx +108 -0
- package/src/lib/Alert/index.ts +1 -0
- package/src/lib/Breadcrumbs/Breadcrumbs.styled.tsx +16 -0
- package/src/lib/Breadcrumbs/Breadcrumbs.tsx +40 -0
- package/src/lib/Breadcrumbs/{index.d.ts → index.ts} +1 -1
- package/src/lib/ContentLayout/ContentLayout.tsx +31 -0
- package/src/lib/ContentLayout/index.ts +1 -0
- package/src/lib/Definition/CreateDefinition/CreateDefinition.tsx +78 -0
- package/src/lib/Definition/CreateDefinition/{index.d.ts → index.ts} +1 -1
- package/src/lib/Definition/DefinitionFiller/DefinitionFiller.tsx +71 -0
- package/src/lib/Definition/DefinitionFiller/{index.d.ts → index.ts} +1 -1
- package/src/lib/Definition/DefinitionValueView/DefinitionValueView.tsx +54 -0
- package/src/lib/Definition/DefinitionValueView/PropertyDataView.tsx +67 -0
- package/src/lib/Definition/DefinitionValueView/{index.d.ts → index.ts} +1 -1
- package/src/lib/Definition/{index.d.ts → index.ts} +3 -3
- package/src/lib/Forms/BackButton.tsx +46 -0
- package/src/lib/Forms/ControlAceEditor.tsx +125 -0
- package/src/lib/Forms/ControlAutocomplete.tsx +145 -0
- package/src/lib/Forms/ControlCheckbox.tsx +113 -0
- package/src/lib/Forms/ControlDate.tsx +75 -0
- package/src/lib/Forms/ControlDateTime.tsx +77 -0
- package/src/lib/Forms/ControlDebouncedInput.tsx +80 -0
- package/src/lib/Forms/ControlInput.tsx +111 -0
- package/src/lib/Forms/ControlNumberInput.tsx +121 -0
- package/src/lib/Forms/ControlQueryAutocomplete.tsx +197 -0
- package/src/lib/Forms/ControlRadio.tsx +136 -0
- package/src/lib/Forms/ControlSelect.tsx +164 -0
- package/src/lib/Forms/ControlSwitch.tsx +71 -0
- package/src/lib/Forms/ControlTime.tsx +93 -0
- package/src/lib/Forms/CopyButton.tsx +46 -0
- package/src/lib/Forms/{index.d.ts → index.ts} +15 -15
- package/src/lib/Forms/useAutocomplete.tsx +47 -0
- package/src/lib/InfoItem/InfoItem.tsx +40 -0
- package/src/lib/InfoItem/{index.d.ts → index.ts} +1 -1
- package/src/lib/InfoItem/styles.ts +17 -0
- package/src/lib/JsonPathPicker/JsonPathPicker.tsx +73 -0
- package/src/lib/JsonPathPicker/PropertyStep.tsx +70 -0
- package/src/lib/JsonPathPicker/{index.d.ts → index.ts} +1 -1
- package/src/lib/JsonView/JsonView.tsx +41 -0
- package/src/lib/JsonView/{index.d.ts → index.ts} +1 -1
- package/src/lib/Loader/Loader.tsx +41 -0
- package/src/lib/Loader/{index.d.ts → index.ts} +1 -1
- package/src/lib/Modals/JsonModalView.tsx +53 -0
- package/src/lib/Modals/{index.d.ts → index.ts} +1 -1
- package/src/lib/Property/PropertyFiller/JsonEditor.tsx +58 -0
- package/src/lib/Property/PropertyFiller/MultiplePropertyFiller.tsx +129 -0
- package/src/lib/Property/PropertyFiller/MultiplePropertyWidget.tsx +85 -0
- package/src/lib/Property/PropertyFiller/PropertyFiller.tsx +199 -0
- package/src/lib/Property/PropertyFiller/{index.d.ts → index.ts} +2 -2
- package/src/lib/Property/PropertyFiller/usePropertyFiller.ts +72 -0
- package/src/lib/Property/PropertyFiller/useStyles.ts +12 -0
- package/src/lib/Property/PropertyValidator/NodeValidator.tsx +92 -0
- package/src/lib/Property/PropertyValidator/NodesList.tsx +26 -0
- package/src/lib/Property/PropertyValidator/NumericTypeValidator.tsx +59 -0
- package/src/lib/Property/PropertyValidator/PropertyValidator.tsx +42 -0
- package/src/lib/Property/PropertyValidator/PropertyValidatorContext.tsx +4 -0
- package/src/lib/Property/PropertyValidator/StringTypeValidator.tsx +36 -0
- package/src/lib/Property/PropertyValidator/ValidationNodeSelector.tsx +62 -0
- package/src/lib/Property/PropertyValidator/index.ts +1 -0
- package/src/lib/Property/PropertyValueField/BooleanValueField.tsx +49 -0
- package/src/lib/Property/PropertyValueField/DateTimeValueField.tsx +58 -0
- package/src/lib/Property/PropertyValueField/DateValueField.tsx +58 -0
- package/src/lib/Property/PropertyValueField/JsonValueField.tsx +65 -0
- package/src/lib/Property/PropertyValueField/PropertyValueField.tsx +49 -0
- package/src/lib/Property/PropertyValueField/StringValueField.tsx +50 -0
- package/src/lib/Property/PropertyValueField/TimeValueField.tsx +67 -0
- package/src/lib/Property/PropertyValueField/{index.d.ts → index.ts} +1 -1
- package/src/lib/Property/PropertyWidget/PropertyWidget.tsx +115 -0
- package/src/lib/Property/PropertyWidget/{index.d.ts → index.ts} +1 -1
- package/src/lib/Property/UpsertProperty/CreatePropertiesList.tsx +148 -0
- package/src/lib/Property/UpsertProperty/CreatePropertyFormFields.tsx +158 -0
- package/src/lib/Property/UpsertProperty/CustomPropertyField.tsx +40 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/BigDecimalPropertyFields.tsx +41 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/DateAdditionalFields.tsx +27 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityAdditionalFields.tsx +133 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityReferencePropertyFields.tsx +46 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/PropertyAdditionalFields.tsx +52 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/StringPropertyFields.tsx +103 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/{index.d.ts → index.ts} +1 -1
- package/src/lib/Property/UpsertProperty/{index.d.ts → index.ts} +2 -2
- package/src/lib/Property/UpsertProperty/useCustomFields.ts +22 -0
- package/src/lib/Property/ViewPropertiesList/ViewPropertiesList.tsx +37 -0
- package/src/lib/Property/ViewPropertiesList/{index.d.ts → index.ts} +1 -1
- package/src/lib/Property/ViewProperty/EntityPropertiesShortView.tsx +40 -0
- package/src/lib/Property/ViewProperty/EntityPropertiesView.tsx +48 -0
- package/src/lib/Property/ViewProperty/PropertyDataTable.tsx +148 -0
- package/src/lib/Property/ViewProperty/PropertyItem.tsx +43 -0
- package/src/lib/Property/ViewProperty/ViewProperty.tsx +52 -0
- package/src/lib/Property/ViewProperty/{index.d.ts → index.ts} +1 -1
- package/src/lib/Property/{index.d.ts → index.ts} +5 -5
- package/src/lib/Sidebar/Sidebar.styled.tsx +157 -0
- package/src/lib/Sidebar/Sidebar.tsx +27 -0
- package/src/lib/Sidebar/SidebarContext.tsx +37 -0
- package/src/lib/Sidebar/SidebarDrawer.tsx +50 -0
- package/src/lib/Sidebar/SidebarLink/MenuIcon.tsx +16 -0
- package/src/lib/Sidebar/SidebarLink/SidebarLink.tsx +54 -0
- package/src/lib/Sidebar/SidebarLink/SidebarLinkItem.tsx +54 -0
- package/src/lib/Sidebar/SidebarLink/SidebarNestedItem.tsx +62 -0
- package/src/lib/Sidebar/SidebarLink/{index.d.ts → index.ts} +2 -2
- package/src/lib/Sidebar/index.ts +2 -0
- package/src/lib/Status/Status.tsx +16 -0
- package/src/lib/Status/{index.d.ts → index.ts} +1 -1
- package/src/lib/Status/styles.ts +21 -0
- package/src/lib/StepperView/StepperView.tsx +73 -0
- package/src/lib/StepperView/{index.d.ts → index.ts} +1 -1
- package/src/lib/Table/DataGrid/JsonTypeCell.tsx +51 -0
- package/src/lib/Table/DataGrid/Table.tsx +117 -0
- package/src/lib/Table/DataGrid/TableAction.tsx +43 -0
- package/src/lib/Table/DataGrid/TableColumnMenu.tsx +12 -0
- package/src/lib/Table/DataGrid/TablePagination.tsx +42 -0
- package/src/lib/Table/DataGrid/index.ts +2 -0
- package/src/lib/Table/DataGrid/styles.ts +59 -0
- package/src/lib/Table/DataGrid/usePagination.ts +15 -0
- package/src/lib/Table/DataGrid/useTableQueryPagination.ts +47 -0
- package/src/lib/Table/DataGrid/useTableQuerySorting.ts +47 -0
- package/src/lib/Table/SimpleTable/SimpleTable.tsx +138 -0
- package/src/lib/Table/SimpleTable/TableActionCell.tsx +67 -0
- package/src/lib/Table/SimpleTable/index.ts +2 -0
- package/src/lib/Table/SimpleTable/useTablePagination.ts +54 -0
- package/src/lib/Table/SimpleTable/useTableSorting.ts +50 -0
- package/src/lib/Table/index.ts +2 -0
- package/src/lib/Tabs/RouteTabs.tsx +54 -0
- package/src/lib/Tabs/TabPanel.tsx +42 -0
- package/src/lib/Tabs/{index.d.ts → index.ts} +2 -2
- package/src/lib/{index.d.ts → index.ts} +16 -16
- package/src/theme/baseTheme.ts +128 -0
- package/src/theme/fonts.d.ts +2 -0
- package/src/theme/index.ts +126 -0
- package/src/theme/inputThemeOptions.ts +126 -0
- package/src/theme/stepperThemeOptions.ts +20 -0
- package/src/theme/tableThemeOptions.ts +50 -0
- package/src/theme/typographyThemeOptions.ts +32 -0
- package/src/utils/common.ts +73 -0
- package/src/utils/dem.ts +431 -0
- package/src/utils/hooks.ts +41 -0
- package/src/utils/{index.d.ts → index.ts} +5 -5
- package/src/utils/ui-utils.tsx +102 -0
- package/src/utils/validators.ts +14 -0
- package/tsconfig.json +25 -0
- package/tsconfig.lib.json +23 -0
- package/tsconfig.spec.json +20 -0
- package/index.js +0 -1
- package/src/consts/index.d.ts +0 -12
- package/src/interfaces/common.d.ts +0 -17
- package/src/interfaces/definition.d.ts +0 -107
- package/src/interfaces/ui.d.ts +0 -70
- package/src/lib/Alert/Alert.d.ts +0 -53
- package/src/lib/Alert/index.d.ts +0 -1
- package/src/lib/Breadcrumbs/Breadcrumbs.d.ts +0 -9
- package/src/lib/Breadcrumbs/Breadcrumbs.styled.d.ts +0 -2
- package/src/lib/ContentLayout/ContentLayout.d.ts +0 -9
- package/src/lib/ContentLayout/index.d.ts +0 -1
- package/src/lib/Definition/CreateDefinition/CreateDefinition.d.ts +0 -11
- package/src/lib/Definition/DefinitionFiller/DefinitionFiller.d.ts +0 -10
- package/src/lib/Definition/DefinitionValueView/DefinitionValueView.d.ts +0 -8
- package/src/lib/Definition/DefinitionValueView/PropertyDataView.d.ts +0 -9
- package/src/lib/Forms/BackButton.d.ts +0 -7
- package/src/lib/Forms/ControlAceEditor.d.ts +0 -24
- package/src/lib/Forms/ControlAutocomplete.d.ts +0 -69
- package/src/lib/Forms/ControlCheckbox.d.ts +0 -51
- package/src/lib/Forms/ControlDate.d.ts +0 -18
- package/src/lib/Forms/ControlDateTime.d.ts +0 -18
- package/src/lib/Forms/ControlDebouncedInput.d.ts +0 -4
- package/src/lib/Forms/ControlInput.d.ts +0 -59
- package/src/lib/Forms/ControlNumberInput.d.ts +0 -51
- package/src/lib/Forms/ControlQueryAutocomplete.d.ts +0 -16
- package/src/lib/Forms/ControlRadio.d.ts +0 -66
- package/src/lib/Forms/ControlSelect.d.ts +0 -67
- package/src/lib/Forms/ControlSwitch.d.ts +0 -19
- package/src/lib/Forms/ControlTime.d.ts +0 -18
- package/src/lib/Forms/CopyButton.d.ts +0 -20
- package/src/lib/Forms/useAutocomplete.d.ts +0 -10
- package/src/lib/InfoItem/InfoItem.d.ts +0 -10
- package/src/lib/InfoItem/styles.d.ts +0 -12
- package/src/lib/JsonPathPicker/JsonPathPicker.d.ts +0 -10
- package/src/lib/JsonPathPicker/PropertyStep.d.ts +0 -11
- package/src/lib/JsonView/JsonView.d.ts +0 -7
- package/src/lib/Loader/Loader.d.ts +0 -21
- package/src/lib/Modals/JsonModalView.d.ts +0 -10
- package/src/lib/Property/PropertyFiller/JsonEditor.d.ts +0 -10
- package/src/lib/Property/PropertyFiller/MultiplePropertyFiller.d.ts +0 -12
- package/src/lib/Property/PropertyFiller/MultiplePropertyWidget.d.ts +0 -11
- package/src/lib/Property/PropertyFiller/PropertyFiller.d.ts +0 -12
- package/src/lib/Property/PropertyFiller/usePropertyFiller.d.ts +0 -24
- package/src/lib/Property/PropertyFiller/useStyles.d.ts +0 -12
- package/src/lib/Property/PropertyValidator/NodeValidator.d.ts +0 -6
- package/src/lib/Property/PropertyValidator/NodesList.d.ts +0 -6
- package/src/lib/Property/PropertyValidator/NumericTypeValidator.d.ts +0 -8
- package/src/lib/Property/PropertyValidator/PropertyValidator.d.ts +0 -6
- package/src/lib/Property/PropertyValidator/PropertyValidatorContext.d.ts +0 -3
- package/src/lib/Property/PropertyValidator/StringTypeValidator.d.ts +0 -8
- package/src/lib/Property/PropertyValidator/ValidationNodeSelector.d.ts +0 -7
- package/src/lib/Property/PropertyValidator/index.d.ts +0 -1
- package/src/lib/Property/PropertyValueField/BooleanValueField.d.ts +0 -7
- package/src/lib/Property/PropertyValueField/DateTimeValueField.d.ts +0 -9
- package/src/lib/Property/PropertyValueField/DateValueField.d.ts +0 -9
- package/src/lib/Property/PropertyValueField/JsonValueField.d.ts +0 -10
- package/src/lib/Property/PropertyValueField/PropertyValueField.d.ts +0 -9
- package/src/lib/Property/PropertyValueField/StringValueField.d.ts +0 -9
- package/src/lib/Property/PropertyValueField/TimeValueField.d.ts +0 -9
- package/src/lib/Property/PropertyWidget/PropertyWidget.d.ts +0 -13
- package/src/lib/Property/UpsertProperty/CreatePropertiesList.d.ts +0 -13
- package/src/lib/Property/UpsertProperty/CreatePropertyFormFields.d.ts +0 -10
- package/src/lib/Property/UpsertProperty/CustomPropertyField.d.ts +0 -7
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/BigDecimalPropertyFields.d.ts +0 -6
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/DateAdditionalFields.d.ts +0 -7
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityAdditionalFields.d.ts +0 -8
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityReferencePropertyFields.d.ts +0 -6
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/PropertyAdditionalFields.d.ts +0 -10
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/StringPropertyFields.d.ts +0 -6
- package/src/lib/Property/UpsertProperty/useCustomFields.d.ts +0 -6
- package/src/lib/Property/ViewPropertiesList/ViewPropertiesList.d.ts +0 -8
- package/src/lib/Property/ViewProperty/EntityPropertiesShortView.d.ts +0 -7
- package/src/lib/Property/ViewProperty/EntityPropertiesView.d.ts +0 -8
- package/src/lib/Property/ViewProperty/PropertyDataTable.d.ts +0 -7
- package/src/lib/Property/ViewProperty/PropertyItem.d.ts +0 -9
- package/src/lib/Property/ViewProperty/ViewProperty.d.ts +0 -9
- package/src/lib/Sidebar/Sidebar.d.ts +0 -10
- package/src/lib/Sidebar/Sidebar.styled.d.ts +0 -117
- package/src/lib/Sidebar/SidebarContext.d.ts +0 -11
- package/src/lib/Sidebar/SidebarDrawer.d.ts +0 -9
- package/src/lib/Sidebar/SidebarLink/MenuIcon.d.ts +0 -7
- package/src/lib/Sidebar/SidebarLink/SidebarLink.d.ts +0 -7
- package/src/lib/Sidebar/SidebarLink/SidebarLinkItem.d.ts +0 -8
- package/src/lib/Sidebar/SidebarLink/SidebarNestedItem.d.ts +0 -10
- package/src/lib/Sidebar/index.d.ts +0 -2
- package/src/lib/Status/Status.d.ts +0 -8
- package/src/lib/Status/styles.d.ts +0 -12
- package/src/lib/StepperView/StepperView.d.ts +0 -11
- package/src/lib/Table/DataGrid/JsonTypeCell.d.ts +0 -7
- package/src/lib/Table/DataGrid/Table.d.ts +0 -49
- package/src/lib/Table/DataGrid/TableAction.d.ts +0 -13
- package/src/lib/Table/DataGrid/TableColumnMenu.d.ts +0 -3
- package/src/lib/Table/DataGrid/TablePagination.d.ts +0 -3
- package/src/lib/Table/DataGrid/index.d.ts +0 -2
- package/src/lib/Table/DataGrid/styles.d.ts +0 -12
- package/src/lib/Table/DataGrid/usePagination.d.ts +0 -5
- package/src/lib/Table/DataGrid/useTableQueryPagination.d.ts +0 -11
- package/src/lib/Table/DataGrid/useTableQuerySorting.d.ts +0 -6
- package/src/lib/Table/SimpleTable/SimpleTable.d.ts +0 -17
- package/src/lib/Table/SimpleTable/TableActionCell.d.ts +0 -10
- package/src/lib/Table/SimpleTable/index.d.ts +0 -2
- package/src/lib/Table/SimpleTable/useTablePagination.d.ts +0 -7
- package/src/lib/Table/SimpleTable/useTableSorting.d.ts +0 -6
- package/src/lib/Table/index.d.ts +0 -2
- package/src/lib/Tabs/RouteTabs.d.ts +0 -11
- package/src/lib/Tabs/TabPanel.d.ts +0 -25
- package/src/theme/baseTheme.d.ts +0 -2
- package/src/theme/index.d.ts +0 -1
- package/src/theme/inputThemeOptions.d.ts +0 -117
- package/src/theme/stepperThemeOptions.d.ts +0 -16
- package/src/theme/tableThemeOptions.d.ts +0 -47
- package/src/theme/typographyThemeOptions.d.ts +0 -29
- package/src/utils/common.d.ts +0 -7
- package/src/utils/dem.d.ts +0 -27
- package/src/utils/hooks.d.ts +0 -7
- package/src/utils/ui-utils.d.ts +0 -8
- package/src/utils/validators.d.ts +0 -5
@@ -0,0 +1,93 @@
|
|
1
|
+
import TextField from '@mui/material/TextField';
|
2
|
+
import { TimePicker } from '@mui/x-date-pickers/TimePicker';
|
3
|
+
|
4
|
+
import { parse, format as dateFnsFormat, isMatch, isValid } from 'date-fns';
|
5
|
+
import { useEffect, useState } from 'react';
|
6
|
+
import { Control, useController, useWatch } from 'react-hook-form';
|
7
|
+
import { TIME_DEFAULT_FORMAT } from '../../interfaces';
|
8
|
+
|
9
|
+
type Props = {
|
10
|
+
/**
|
11
|
+
* React Hook Form `control`
|
12
|
+
*/
|
13
|
+
control: Control<any>;
|
14
|
+
/**
|
15
|
+
* Is input required flag
|
16
|
+
*/
|
17
|
+
required?: boolean;
|
18
|
+
name: string;
|
19
|
+
label?: string;
|
20
|
+
format?: string;
|
21
|
+
hideErrorMessage?: boolean;
|
22
|
+
};
|
23
|
+
|
24
|
+
export const ControlTime = ({
|
25
|
+
control,
|
26
|
+
name,
|
27
|
+
required,
|
28
|
+
label,
|
29
|
+
format = TIME_DEFAULT_FORMAT,
|
30
|
+
hideErrorMessage = false,
|
31
|
+
}: Props) => {
|
32
|
+
const {
|
33
|
+
field: { onChange, ref },
|
34
|
+
fieldState: { error },
|
35
|
+
} = useController({
|
36
|
+
control,
|
37
|
+
name,
|
38
|
+
rules: {
|
39
|
+
required: required && 'Please, fill this field',
|
40
|
+
validate: (val) => {
|
41
|
+
if (isMatch(val, format)) {
|
42
|
+
return true;
|
43
|
+
}
|
44
|
+
return 'Incorrect date format';
|
45
|
+
},
|
46
|
+
},
|
47
|
+
});
|
48
|
+
const value = useWatch({ control, name });
|
49
|
+
|
50
|
+
const [fieldValue, setFieldValue] = useState(null);
|
51
|
+
|
52
|
+
const handleChange = (date: Date) => {
|
53
|
+
setFieldValue(date);
|
54
|
+
onChange(isValid(date) ? dateFnsFormat(date, format) : date);
|
55
|
+
};
|
56
|
+
|
57
|
+
useEffect(() => {
|
58
|
+
if (value && format) {
|
59
|
+
let parsedValue = parse(value, format, new Date());
|
60
|
+
|
61
|
+
if (!isValid(parsedValue)) {
|
62
|
+
parsedValue = parse(value, 'HH:mm:ss.SSS', new Date());
|
63
|
+
}
|
64
|
+
|
65
|
+
setFieldValue(parsedValue);
|
66
|
+
}
|
67
|
+
}, [value, format]);
|
68
|
+
|
69
|
+
return (
|
70
|
+
<TimePicker
|
71
|
+
mask=""
|
72
|
+
inputRef={ref}
|
73
|
+
label={label}
|
74
|
+
ampm={false}
|
75
|
+
value={fieldValue}
|
76
|
+
inputFormat={format}
|
77
|
+
onChange={handleChange}
|
78
|
+
renderInput={(props) => (
|
79
|
+
<TextField
|
80
|
+
{...props}
|
81
|
+
fullWidth
|
82
|
+
size="small"
|
83
|
+
variant="outlined"
|
84
|
+
name={name}
|
85
|
+
error={!!error}
|
86
|
+
helperText={!hideErrorMessage && error?.message}
|
87
|
+
/>
|
88
|
+
)}
|
89
|
+
/>
|
90
|
+
);
|
91
|
+
};
|
92
|
+
|
93
|
+
export default ControlTime;
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import { useState } from 'react';
|
2
|
+
// import FileCopyOutlinedIcon from '@mui/icons-material/FileCopyOutlined';
|
3
|
+
import Tooltip from '@mui/material/Tooltip';
|
4
|
+
import IconButton from '@mui/material/IconButton';
|
5
|
+
import SvgIcon from '@mui/material/SvgIcon';
|
6
|
+
/**
|
7
|
+
* This interface is referencing the [[CopyButton]] component props.
|
8
|
+
* @category Forms
|
9
|
+
*/
|
10
|
+
export interface CopyButtonProps {
|
11
|
+
/**
|
12
|
+
* Text to copy
|
13
|
+
*/
|
14
|
+
copyText: string;
|
15
|
+
/**
|
16
|
+
* Tooltip help text
|
17
|
+
*/
|
18
|
+
helpText?: string;
|
19
|
+
}
|
20
|
+
|
21
|
+
/**
|
22
|
+
* Copy value button
|
23
|
+
* @category Forms
|
24
|
+
*/
|
25
|
+
export const CopyButton = ({ copyText, helpText = 'Copy' }: CopyButtonProps) => {
|
26
|
+
const [tooltipText, setTooltipText] = useState(helpText);
|
27
|
+
|
28
|
+
const onCopy = () => {
|
29
|
+
navigator.clipboard.writeText(copyText);
|
30
|
+
setTooltipText('Copied!');
|
31
|
+
|
32
|
+
setTimeout(() => {
|
33
|
+
setTooltipText(helpText);
|
34
|
+
}, 1000);
|
35
|
+
};
|
36
|
+
|
37
|
+
return tooltipText ? (
|
38
|
+
<Tooltip title={tooltipText} placement="top">
|
39
|
+
<IconButton onClick={onCopy}>
|
40
|
+
<SvgIcon fontSize="small">
|
41
|
+
<path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm-1 4 6 6v10c0 1.1-.9 2-2 2H7.99C6.89 23 6 22.1 6 21l.01-14c0-1.1.89-2 1.99-2h7zm-1 7h5.5L14 6.5V12z"></path>
|
42
|
+
</SvgIcon>
|
43
|
+
</IconButton>
|
44
|
+
</Tooltip>
|
45
|
+
) : null;
|
46
|
+
};
|
@@ -1,15 +1,15 @@
|
|
1
|
-
export * from './ControlInput';
|
2
|
-
export * from './ControlDebouncedInput';
|
3
|
-
export * from './ControlSelect';
|
4
|
-
export * from './ControlCheckbox';
|
5
|
-
export * from './ControlRadio';
|
6
|
-
export * from './ControlAutocomplete';
|
7
|
-
export * from './ControlQueryAutocomplete';
|
8
|
-
export * from './CopyButton';
|
9
|
-
export * from './BackButton';
|
10
|
-
export * from './ControlAceEditor';
|
11
|
-
export * from './ControlNumberInput';
|
12
|
-
export * from './ControlSwitch';
|
13
|
-
export * from './ControlDate';
|
14
|
-
export * from './ControlDateTime';
|
15
|
-
export * from './ControlTime';
|
1
|
+
export * from './ControlInput';
|
2
|
+
export * from './ControlDebouncedInput';
|
3
|
+
export * from './ControlSelect';
|
4
|
+
export * from './ControlCheckbox';
|
5
|
+
export * from './ControlRadio';
|
6
|
+
export * from './ControlAutocomplete';
|
7
|
+
export * from './ControlQueryAutocomplete';
|
8
|
+
export * from './CopyButton';
|
9
|
+
export * from './BackButton';
|
10
|
+
export * from './ControlAceEditor';
|
11
|
+
export * from './ControlNumberInput';
|
12
|
+
export * from './ControlSwitch';
|
13
|
+
export * from './ControlDate';
|
14
|
+
export * from './ControlDateTime';
|
15
|
+
export * from './ControlTime';
|
@@ -0,0 +1,47 @@
|
|
1
|
+
import Box from '@mui/material/Box';
|
2
|
+
import { useCallback } from 'react';
|
3
|
+
|
4
|
+
const useAutocomplete = ({ valueKey, labelKey }) => {
|
5
|
+
const isOptionEqualToValue = useCallback(
|
6
|
+
(option, value) => {
|
7
|
+
if (option && value) {
|
8
|
+
if (typeof option === 'string') {
|
9
|
+
return option === value;
|
10
|
+
} else if (valueKey) {
|
11
|
+
return option[valueKey] === value[valueKey] || option[valueKey] === value;
|
12
|
+
} else if (option.value) {
|
13
|
+
return option.value === value.value || option.value === value;
|
14
|
+
}
|
15
|
+
}
|
16
|
+
return false;
|
17
|
+
},
|
18
|
+
[valueKey]
|
19
|
+
);
|
20
|
+
|
21
|
+
const getOptionLabel = useCallback(
|
22
|
+
(option) => {
|
23
|
+
if (!option) return '';
|
24
|
+
if (typeof option === 'string') {
|
25
|
+
return option;
|
26
|
+
} else if (labelKey && option[labelKey]) {
|
27
|
+
return option[labelKey] + '';
|
28
|
+
} else {
|
29
|
+
return option.label + '' || option.name + '' || option.value + '' || option.code + '' || '--no label--';
|
30
|
+
}
|
31
|
+
},
|
32
|
+
[labelKey]
|
33
|
+
);
|
34
|
+
|
35
|
+
const renderOption = useCallback(
|
36
|
+
(props, option) => (
|
37
|
+
<Box {...props} component="li" key={props.id}>
|
38
|
+
{getOptionLabel(option)}
|
39
|
+
</Box>
|
40
|
+
),
|
41
|
+
[getOptionLabel]
|
42
|
+
);
|
43
|
+
|
44
|
+
return { isOptionEqualToValue, getOptionLabel, renderOption };
|
45
|
+
};
|
46
|
+
|
47
|
+
export default useAutocomplete;
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import AceEditor from 'react-ace';
|
2
|
+
import useStyles from './styles';
|
3
|
+
import 'ace-builds/src-noconflict/ace';
|
4
|
+
import 'ace-builds/src-noconflict/mode-json';
|
5
|
+
|
6
|
+
type Props = {
|
7
|
+
title: string;
|
8
|
+
text?: string;
|
9
|
+
json?: any;
|
10
|
+
};
|
11
|
+
|
12
|
+
export const InfoItem = ({ title, text, json }: Props) => {
|
13
|
+
const { classes } = useStyles();
|
14
|
+
|
15
|
+
return (
|
16
|
+
<div className={classes.container}>
|
17
|
+
<div className={classes.title}>{title}</div>
|
18
|
+
{text && <div className={classes.text}>{text}</div>}
|
19
|
+
{json && (
|
20
|
+
<AceEditor
|
21
|
+
readOnly
|
22
|
+
value={json}
|
23
|
+
mode="json"
|
24
|
+
height="300px"
|
25
|
+
width="100%"
|
26
|
+
fontSize="16"
|
27
|
+
setOptions={{
|
28
|
+
enableSnippets: false,
|
29
|
+
copyWithEmptySelection: true,
|
30
|
+
showLineNumbers: true,
|
31
|
+
tabSize: 2,
|
32
|
+
useWorker: false
|
33
|
+
}}
|
34
|
+
/>
|
35
|
+
)}
|
36
|
+
</div>
|
37
|
+
);
|
38
|
+
};
|
39
|
+
|
40
|
+
export default InfoItem;
|
@@ -1 +1 @@
|
|
1
|
-
export * from './InfoItem';
|
1
|
+
export * from './InfoItem';
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { makeStyles } from 'tss-react/mui';
|
2
|
+
|
3
|
+
export default makeStyles()(() => ({
|
4
|
+
container: {
|
5
|
+
// borderBottom: '1px solid #ccc',
|
6
|
+
paddingBottom: '8px',
|
7
|
+
},
|
8
|
+
title: {
|
9
|
+
fontSize: '14px',
|
10
|
+
fontWeight: 600,
|
11
|
+
color: '#536DFE',
|
12
|
+
},
|
13
|
+
text: {
|
14
|
+
fontSize: '18px',
|
15
|
+
wordWrap: 'break-word',
|
16
|
+
},
|
17
|
+
}));
|
@@ -0,0 +1,73 @@
|
|
1
|
+
import Button from '@mui/material/Button';
|
2
|
+
import Dialog from '@mui/material/Dialog';
|
3
|
+
import DialogTitle from '@mui/material/DialogTitle';
|
4
|
+
import DialogContent from '@mui/material/DialogContent';
|
5
|
+
import DialogActions from '@mui/material/DialogActions';
|
6
|
+
import Typography from '@mui/material/Typography';
|
7
|
+
import PropertyStep from './PropertyStep';
|
8
|
+
|
9
|
+
import { useState } from 'react';
|
10
|
+
import { toast } from 'react-toastify';
|
11
|
+
import { JsonPathPickerProperty } from '../../interfaces';
|
12
|
+
|
13
|
+
type Props = {
|
14
|
+
properties: JsonPathPickerProperty[];
|
15
|
+
open: boolean;
|
16
|
+
onClose: () => void;
|
17
|
+
onPaste: (path: string) => void;
|
18
|
+
};
|
19
|
+
|
20
|
+
export const JsonPathPicker = ({ open = false, onClose, onPaste, properties }: Props) => {
|
21
|
+
const [selectedPropertyPath, setSelectedPropertyPath] = useState<string>('');
|
22
|
+
|
23
|
+
const onCopy = () => {
|
24
|
+
navigator.clipboard.writeText(`$(${selectedPropertyPath})`);
|
25
|
+
toast.success('Copied!');
|
26
|
+
};
|
27
|
+
|
28
|
+
const handlePaste = () => {
|
29
|
+
onPaste(`$(${selectedPropertyPath})`);
|
30
|
+
toast.success('Pasted!');
|
31
|
+
};
|
32
|
+
|
33
|
+
return (
|
34
|
+
<Dialog open={open} onClose={onClose} fullWidth maxWidth="md">
|
35
|
+
<DialogTitle>JSON path picker</DialogTitle>
|
36
|
+
<DialogContent>
|
37
|
+
{properties?.length ? (
|
38
|
+
properties.map((propEl, index) => (
|
39
|
+
<div key={index}>
|
40
|
+
<Typography variant="h6">{propEl.title}</Typography>
|
41
|
+
<PropertyStep
|
42
|
+
properties={propEl.properties}
|
43
|
+
prefix={propEl.pathPrefix}
|
44
|
+
onClick={setSelectedPropertyPath}
|
45
|
+
activePath={selectedPropertyPath}
|
46
|
+
/>
|
47
|
+
</div>
|
48
|
+
))
|
49
|
+
) : (
|
50
|
+
<Typography>Please, add properties</Typography>
|
51
|
+
)}
|
52
|
+
{selectedPropertyPath && (
|
53
|
+
<Typography variant="h6" gutterBottom>
|
54
|
+
Selected path : $({selectedPropertyPath})
|
55
|
+
</Typography>
|
56
|
+
)}
|
57
|
+
</DialogContent>
|
58
|
+
<DialogActions>
|
59
|
+
<Button variant="contained" color="primary" onClick={onCopy}>
|
60
|
+
Copy
|
61
|
+
</Button>
|
62
|
+
<Button variant="contained" color="primary" onClick={handlePaste}>
|
63
|
+
Paste
|
64
|
+
</Button>
|
65
|
+
<Button variant="contained" color="secondary" onClick={onClose}>
|
66
|
+
Close
|
67
|
+
</Button>
|
68
|
+
</DialogActions>
|
69
|
+
</Dialog>
|
70
|
+
);
|
71
|
+
};
|
72
|
+
|
73
|
+
export default JsonPathPicker;
|
@@ -0,0 +1,70 @@
|
|
1
|
+
import Stepper from '@mui/material/Stepper';
|
2
|
+
import Step from '@mui/material/Step';
|
3
|
+
import StepLabel from '@mui/material/StepLabel';
|
4
|
+
import StepContent from '@mui/material/StepContent';
|
5
|
+
|
6
|
+
import { EntityTypeProperty, PropertiesArrayType, PropertyType } from '../../interfaces';
|
7
|
+
import { makeStyles } from 'tss-react/mui';
|
8
|
+
|
9
|
+
type Props = {
|
10
|
+
properties: PropertiesArrayType;
|
11
|
+
parentKey?: string;
|
12
|
+
activePath: string;
|
13
|
+
prefix?: string;
|
14
|
+
onClick: (path: string) => void;
|
15
|
+
};
|
16
|
+
|
17
|
+
const useStyles = makeStyles()(() => ({
|
18
|
+
propertyStepLabel: {
|
19
|
+
'&:hover': {
|
20
|
+
fontWeight: '600',
|
21
|
+
cursor: 'pointer',
|
22
|
+
},
|
23
|
+
},
|
24
|
+
}));
|
25
|
+
|
26
|
+
const PropertyStep = ({ properties, parentKey = '', activePath = '', prefix = '', onClick }: Props) => {
|
27
|
+
const { classes } = useStyles();
|
28
|
+
|
29
|
+
const handleClick = (path: string) => {
|
30
|
+
if (prefix) {
|
31
|
+
onClick(`${prefix}.${path}`);
|
32
|
+
} else {
|
33
|
+
onClick(path);
|
34
|
+
}
|
35
|
+
};
|
36
|
+
|
37
|
+
return (
|
38
|
+
<Stepper orientation="vertical" onClick={(event) => event.stopPropagation()}>
|
39
|
+
{properties &&
|
40
|
+
properties.map((property) => {
|
41
|
+
const fullPropertyPath = parentKey ? `${parentKey}.${property.key}` : property.key;
|
42
|
+
const propertyType = property.propertyType['value'] ?? property.propertyType;
|
43
|
+
return (
|
44
|
+
<Step expanded key={property.key} onClick={() => handleClick(fullPropertyPath)}>
|
45
|
+
<StepLabel StepIconProps={{ icon: '', completed: false, active: activePath === fullPropertyPath }}>
|
46
|
+
<div className={classes.propertyStepLabel}>
|
47
|
+
{property.name} - {property.key} - {propertyType}
|
48
|
+
</div>
|
49
|
+
</StepLabel>
|
50
|
+
<StepContent>
|
51
|
+
<div>
|
52
|
+
{propertyType === PropertyType.ENTITY && (
|
53
|
+
<PropertyStep
|
54
|
+
key={property.key}
|
55
|
+
onClick={onClick}
|
56
|
+
activePath={activePath}
|
57
|
+
properties={(property as EntityTypeProperty).properties as PropertiesArrayType}
|
58
|
+
parentKey={fullPropertyPath}
|
59
|
+
/>
|
60
|
+
)}
|
61
|
+
</div>
|
62
|
+
</StepContent>
|
63
|
+
</Step>
|
64
|
+
);
|
65
|
+
})}
|
66
|
+
</Stepper>
|
67
|
+
);
|
68
|
+
};
|
69
|
+
|
70
|
+
export default PropertyStep;
|
@@ -1 +1 @@
|
|
1
|
-
export * from './JsonPathPicker';
|
1
|
+
export * from './JsonPathPicker';
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import { useMemo } from 'react';
|
2
|
+
import CodeMirror from '@uiw/react-codemirror';
|
3
|
+
import { langs } from '@uiw/codemirror-extensions-langs';
|
4
|
+
|
5
|
+
type Props = {
|
6
|
+
value: unknown;
|
7
|
+
height?: string;
|
8
|
+
};
|
9
|
+
|
10
|
+
|
11
|
+
export const JsonView = ({ value, height = '200px' }: Props) => {
|
12
|
+
|
13
|
+
const stringValue = useMemo(() => {
|
14
|
+
if (typeof value === 'string') {
|
15
|
+
return value;
|
16
|
+
} else if (typeof value === 'object') {
|
17
|
+
try {
|
18
|
+
return JSON.stringify(value, null, 2);
|
19
|
+
} catch (error) {
|
20
|
+
return 'Failed to stringify Object';
|
21
|
+
}
|
22
|
+
}
|
23
|
+
return '';
|
24
|
+
}, [value]);
|
25
|
+
|
26
|
+
return (
|
27
|
+
<CodeMirror
|
28
|
+
readOnly
|
29
|
+
width="100%"
|
30
|
+
value={stringValue}
|
31
|
+
height={height}
|
32
|
+
basicSetup={{
|
33
|
+
autocompletion: true,
|
34
|
+
history: true
|
35
|
+
}}
|
36
|
+
extensions={[langs.json()]}
|
37
|
+
style={{ fontSize: 16 }}
|
38
|
+
|
39
|
+
/>
|
40
|
+
);
|
41
|
+
};
|
@@ -1 +1 @@
|
|
1
|
-
export * from './JsonView';
|
1
|
+
export * from './JsonView';
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import Box from "@mui/material/Box";
|
2
|
+
import CircularProgress from "@mui/material/CircularProgress";
|
3
|
+
|
4
|
+
/**
|
5
|
+
* This interface is referencing the [[Loader]] component props.
|
6
|
+
* @category Common UI components
|
7
|
+
*/
|
8
|
+
export interface LoaderProps {
|
9
|
+
/**
|
10
|
+
* Background transparency flag. Default: `rgba(255, 255, 255, .3)`
|
11
|
+
*/
|
12
|
+
transparent?: boolean;
|
13
|
+
/**
|
14
|
+
* CSS `position` property. Default: `absolute`
|
15
|
+
*/
|
16
|
+
position?: 'absolute' | 'relative' | 'fixed';
|
17
|
+
}
|
18
|
+
/**
|
19
|
+
* Loader screen component. Used in the data loading process
|
20
|
+
* @category Common UI components
|
21
|
+
*/
|
22
|
+
export const Loader = ({ transparent, position }: LoaderProps) => {
|
23
|
+
return (
|
24
|
+
<Box
|
25
|
+
position={position ?? 'absolute'}
|
26
|
+
top={0}
|
27
|
+
left={0}
|
28
|
+
width="100%"
|
29
|
+
height="100%"
|
30
|
+
display="flex"
|
31
|
+
alignItems="center"
|
32
|
+
justifyContent="center"
|
33
|
+
bgcolor={transparent ? 'none' : 'rgba(255, 255, 255, .3)'}
|
34
|
+
zIndex={10}
|
35
|
+
>
|
36
|
+
<CircularProgress />
|
37
|
+
</Box>
|
38
|
+
)
|
39
|
+
}
|
40
|
+
|
41
|
+
export default Loader;
|
@@ -1 +1 @@
|
|
1
|
-
export * from './Loader';
|
1
|
+
export * from './Loader';
|
@@ -0,0 +1,53 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import AceEditor from 'react-ace';
|
3
|
+
import 'ace-builds/src-noconflict/ace';
|
4
|
+
import 'ace-builds/src-noconflict/mode-json';
|
5
|
+
import Dialog from '@mui/material/Dialog';
|
6
|
+
import DialogContent from '@mui/material/DialogContent';
|
7
|
+
import DialogActions from '@mui/material/DialogActions';
|
8
|
+
import Button from '@mui/material/Button';
|
9
|
+
import { CopyButton } from '../Forms';
|
10
|
+
|
11
|
+
type Props = {
|
12
|
+
open: boolean;
|
13
|
+
value: string;
|
14
|
+
onClose: () => void;
|
15
|
+
};
|
16
|
+
|
17
|
+
export const JsonModalView: React.FC<Props> = ({ open, onClose, value }) => {
|
18
|
+
return (
|
19
|
+
<Dialog
|
20
|
+
disableEscapeKeyDown
|
21
|
+
open={open}
|
22
|
+
onClose={onClose}
|
23
|
+
fullWidth
|
24
|
+
maxWidth="md"
|
25
|
+
style={{ width: 800, left: '30%' }}
|
26
|
+
>
|
27
|
+
<DialogContent>
|
28
|
+
<AceEditor
|
29
|
+
readOnly
|
30
|
+
value={value}
|
31
|
+
mode="json"
|
32
|
+
width="100%"
|
33
|
+
fontSize="16"
|
34
|
+
setOptions={{
|
35
|
+
enableSnippets: false,
|
36
|
+
copyWithEmptySelection: true,
|
37
|
+
showLineNumbers: true,
|
38
|
+
tabSize: 2,
|
39
|
+
useWorker: false
|
40
|
+
}}
|
41
|
+
/>
|
42
|
+
</DialogContent>
|
43
|
+
<DialogActions>
|
44
|
+
<CopyButton copyText={value} />
|
45
|
+
<Button onClick={onClose} variant="contained" color="secondary">
|
46
|
+
Close
|
47
|
+
</Button>
|
48
|
+
</DialogActions>
|
49
|
+
</Dialog>
|
50
|
+
);
|
51
|
+
};
|
52
|
+
|
53
|
+
export default JsonModalView;
|
@@ -1 +1 @@
|
|
1
|
-
export * from './JsonModalView';
|
1
|
+
export * from './JsonModalView';
|
@@ -0,0 +1,58 @@
|
|
1
|
+
import AceEditor from 'react-ace';
|
2
|
+
import 'ace-builds/src-noconflict/mode-json';
|
3
|
+
import { RefCallBack, useFormContext, useWatch } from 'react-hook-form';
|
4
|
+
|
5
|
+
type Props = {
|
6
|
+
validate?: boolean;
|
7
|
+
name: string;
|
8
|
+
inputRef: RefCallBack;
|
9
|
+
};
|
10
|
+
|
11
|
+
const JsonEditor = ({ validate = false, name, inputRef }: Props) => {
|
12
|
+
const { control, setValue, setError, clearErrors } = useFormContext();
|
13
|
+
const value = useWatch({ control, name });
|
14
|
+
|
15
|
+
const handleChange = (value: string) => {
|
16
|
+
setValue(name, value);
|
17
|
+
|
18
|
+
if (validate) {
|
19
|
+
try {
|
20
|
+
JSON.parse(value);
|
21
|
+
clearErrors(name);
|
22
|
+
} catch (err) {
|
23
|
+
setError(name, { message: 'Invalid JSON' });
|
24
|
+
}
|
25
|
+
}
|
26
|
+
};
|
27
|
+
|
28
|
+
return (
|
29
|
+
<AceEditor
|
30
|
+
wrapEnabled
|
31
|
+
width="100%"
|
32
|
+
height="200px"
|
33
|
+
theme="monokai"
|
34
|
+
fontSize={14}
|
35
|
+
showPrintMargin={false}
|
36
|
+
style={{ lineHeight: 1.4, zIndex: 0, isolation: 'isolate' }}
|
37
|
+
setOptions={{
|
38
|
+
enableLiveAutocompletion: true,
|
39
|
+
enableBasicAutocompletion: true,
|
40
|
+
showLineNumbers: true,
|
41
|
+
tabSize: 2,
|
42
|
+
useWorker: false
|
43
|
+
}}
|
44
|
+
ref={inputRef}
|
45
|
+
name={name}
|
46
|
+
value={typeof value !== 'string' ? (value === null ? '' : JSON.stringify(value)) : value}
|
47
|
+
onChange={handleChange}
|
48
|
+
mode="json"
|
49
|
+
onLoad={(editor) => {
|
50
|
+
if (!validate) {
|
51
|
+
editor.getSession().setUseWorker(false);
|
52
|
+
}
|
53
|
+
}}
|
54
|
+
/>
|
55
|
+
);
|
56
|
+
};
|
57
|
+
|
58
|
+
export default JsonEditor;
|