@dartech/arsenal-ui 1.3.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{index.ts → index.d.ts} +5 -5
- package/index.js +1 -0
- package/package.json +10 -3
- package/src/consts/index.d.ts +12 -0
- package/src/interfaces/common.d.ts +17 -0
- package/src/interfaces/definition.d.ts +107 -0
- package/src/interfaces/{index.ts → index.d.ts} +3 -3
- package/src/interfaces/ui.d.ts +70 -0
- package/src/lib/Alert/Alert.d.ts +53 -0
- package/src/lib/Alert/index.d.ts +1 -0
- package/src/lib/Breadcrumbs/Breadcrumbs.d.ts +9 -0
- package/src/lib/Breadcrumbs/Breadcrumbs.styled.d.ts +2 -0
- package/src/lib/Breadcrumbs/{index.ts → index.d.ts} +1 -1
- package/src/lib/ContentLayout/ContentLayout.d.ts +9 -0
- package/src/lib/ContentLayout/index.d.ts +1 -0
- package/src/lib/Definition/CreateDefinition/CreateDefinition.d.ts +11 -0
- package/src/lib/Definition/CreateDefinition/{index.ts → index.d.ts} +1 -1
- package/src/lib/Definition/DefinitionFiller/DefinitionFiller.d.ts +10 -0
- package/src/lib/Definition/DefinitionFiller/{index.ts → index.d.ts} +1 -1
- package/src/lib/Definition/DefinitionValueView/DefinitionValueView.d.ts +8 -0
- package/src/lib/Definition/DefinitionValueView/PropertyDataView.d.ts +9 -0
- package/src/lib/Definition/DefinitionValueView/{index.ts → index.d.ts} +1 -1
- package/src/lib/Definition/{index.ts → index.d.ts} +3 -3
- package/src/lib/Forms/BackButton.d.ts +7 -0
- package/src/lib/Forms/ControlAceEditor.d.ts +24 -0
- package/src/lib/Forms/ControlAutocomplete.d.ts +69 -0
- package/src/lib/Forms/ControlCheckbox.d.ts +51 -0
- package/src/lib/Forms/ControlDate.d.ts +18 -0
- package/src/lib/Forms/ControlDateTime.d.ts +18 -0
- package/src/lib/Forms/ControlDebouncedInput.d.ts +4 -0
- package/src/lib/Forms/ControlInput.d.ts +59 -0
- package/src/lib/Forms/ControlNumberInput.d.ts +51 -0
- package/src/lib/Forms/ControlQueryAutocomplete.d.ts +16 -0
- package/src/lib/Forms/ControlRadio.d.ts +66 -0
- package/src/lib/Forms/ControlSelect.d.ts +67 -0
- package/src/lib/Forms/ControlSwitch.d.ts +19 -0
- package/src/lib/Forms/ControlTime.d.ts +18 -0
- package/src/lib/Forms/CopyButton.d.ts +20 -0
- package/src/lib/Forms/{index.ts → index.d.ts} +15 -15
- package/src/lib/Forms/useAutocomplete.d.ts +10 -0
- package/src/lib/InfoItem/InfoItem.d.ts +10 -0
- package/src/lib/InfoItem/{index.ts → index.d.ts} +1 -1
- package/src/lib/JsonPathPicker/JsonPathPicker.d.ts +10 -0
- package/src/lib/JsonPathPicker/PropertyStep.d.ts +11 -0
- package/src/lib/JsonPathPicker/{index.ts → index.d.ts} +1 -1
- package/src/lib/JsonView/JsonView.d.ts +7 -0
- package/src/lib/JsonView/{index.ts → index.d.ts} +1 -1
- package/src/lib/Loader/Loader.d.ts +21 -0
- package/src/lib/Loader/{index.ts → index.d.ts} +1 -1
- package/src/lib/Modals/JsonModalView.d.ts +10 -0
- package/src/lib/Modals/{index.ts → index.d.ts} +1 -1
- package/src/lib/Property/PropertyFiller/JsonEditor.d.ts +10 -0
- package/src/lib/Property/PropertyFiller/MultiplePropertyFiller.d.ts +12 -0
- package/src/lib/Property/PropertyFiller/MultiplePropertyWidget.d.ts +11 -0
- package/src/lib/Property/PropertyFiller/PropertyFiller.d.ts +12 -0
- package/src/lib/Property/PropertyFiller/{index.ts → index.d.ts} +2 -2
- package/src/lib/Property/PropertyFiller/styled.d.ts +18 -0
- package/src/lib/Property/PropertyFiller/usePropertyFiller.d.ts +24 -0
- package/src/lib/Property/PropertyValidator/NodeValidator.d.ts +6 -0
- package/src/lib/Property/PropertyValidator/NodesList.d.ts +6 -0
- package/src/lib/Property/PropertyValidator/NumericTypeValidator.d.ts +8 -0
- package/src/lib/Property/PropertyValidator/PropertyValidator.d.ts +6 -0
- package/src/lib/Property/PropertyValidator/PropertyValidatorContext.d.ts +3 -0
- package/src/lib/Property/PropertyValidator/StringTypeValidator.d.ts +8 -0
- package/src/lib/Property/PropertyValidator/ValidationNodeSelector.d.ts +7 -0
- package/src/lib/Property/PropertyValidator/index.d.ts +1 -0
- package/src/lib/Property/PropertyValueField/BooleanValueField.d.ts +7 -0
- package/src/lib/Property/PropertyValueField/DateTimeValueField.d.ts +9 -0
- package/src/lib/Property/PropertyValueField/DateValueField.d.ts +9 -0
- package/src/lib/Property/PropertyValueField/JsonValueField.d.ts +10 -0
- package/src/lib/Property/PropertyValueField/PropertyValueField.d.ts +9 -0
- package/src/lib/Property/PropertyValueField/StringValueField.d.ts +9 -0
- package/src/lib/Property/PropertyValueField/TimeValueField.d.ts +9 -0
- package/src/lib/Property/PropertyValueField/{index.ts → index.d.ts} +1 -1
- package/src/lib/Property/PropertyWidget/PropertyWidget.d.ts +13 -0
- package/src/lib/Property/PropertyWidget/{index.ts → index.d.ts} +1 -1
- package/src/lib/Property/UpsertProperty/CreatePropertiesList.d.ts +13 -0
- package/src/lib/Property/UpsertProperty/CreatePropertyFormFields.d.ts +10 -0
- package/src/lib/Property/UpsertProperty/CustomPropertyField.d.ts +7 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/BigDecimalPropertyFields.d.ts +6 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/DateAdditionalFields.d.ts +7 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityAdditionalFields.d.ts +8 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityReferencePropertyFields.d.ts +6 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/PropertyAdditionalFields.d.ts +10 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/StringPropertyFields.d.ts +6 -0
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/{index.ts → index.d.ts} +1 -1
- package/src/lib/Property/UpsertProperty/{index.ts → index.d.ts} +2 -2
- package/src/lib/Property/UpsertProperty/useCustomFields.d.ts +6 -0
- package/src/lib/Property/ViewPropertiesList/ViewPropertiesList.d.ts +8 -0
- package/src/lib/Property/ViewPropertiesList/{index.ts → index.d.ts} +1 -1
- package/src/lib/Property/ViewProperty/EntityPropertiesShortView.d.ts +7 -0
- package/src/lib/Property/ViewProperty/EntityPropertiesView.d.ts +8 -0
- package/src/lib/Property/ViewProperty/PropertyDataTable.d.ts +7 -0
- package/src/lib/Property/ViewProperty/PropertyItem.d.ts +9 -0
- package/src/lib/Property/ViewProperty/ViewProperty.d.ts +9 -0
- package/src/lib/Property/ViewProperty/{index.ts → index.d.ts} +1 -1
- package/src/lib/Property/{index.ts → index.d.ts} +5 -5
- package/src/lib/Sidebar/Sidebar.d.ts +10 -0
- package/src/lib/Sidebar/Sidebar.styled.d.ts +117 -0
- package/src/lib/Sidebar/SidebarContext.d.ts +11 -0
- package/src/lib/Sidebar/SidebarDrawer.d.ts +9 -0
- package/src/lib/Sidebar/SidebarLink/MenuIcon.d.ts +7 -0
- package/src/lib/Sidebar/SidebarLink/SidebarLink.d.ts +7 -0
- package/src/lib/Sidebar/SidebarLink/SidebarLinkItem.d.ts +8 -0
- package/src/lib/Sidebar/SidebarLink/SidebarNestedItem.d.ts +10 -0
- package/src/lib/Sidebar/SidebarLink/{index.ts → index.d.ts} +2 -2
- package/src/lib/Sidebar/index.d.ts +2 -0
- package/src/lib/Status/Status.d.ts +8 -0
- package/src/lib/Status/{index.ts → index.d.ts} +1 -1
- package/src/lib/StepperView/StepperView.d.ts +11 -0
- package/src/lib/StepperView/{index.ts → index.d.ts} +1 -1
- package/src/lib/Table/DataGrid/JsonTypeCell.d.ts +7 -0
- package/src/lib/Table/DataGrid/Table.d.ts +49 -0
- package/src/lib/Table/DataGrid/TableAction.d.ts +13 -0
- package/src/lib/Table/DataGrid/TableColumnMenu.d.ts +3 -0
- package/src/lib/Table/DataGrid/TablePagination.d.ts +3 -0
- package/src/lib/Table/DataGrid/index.d.ts +2 -0
- package/src/lib/Table/DataGrid/styles.d.ts +44 -0
- package/src/lib/Table/DataGrid/usePagination.d.ts +5 -0
- package/src/lib/Table/DataGrid/useTableQueryPagination.d.ts +11 -0
- package/src/lib/Table/DataGrid/useTableQuerySorting.d.ts +6 -0
- package/src/lib/Table/SimpleTable/SimpleTable.d.ts +17 -0
- package/src/lib/Table/SimpleTable/TableActionCell.d.ts +10 -0
- package/src/lib/Table/SimpleTable/index.d.ts +2 -0
- package/src/lib/Table/SimpleTable/useTablePagination.d.ts +7 -0
- package/src/lib/Table/SimpleTable/useTableSorting.d.ts +6 -0
- package/src/lib/Table/index.d.ts +2 -0
- package/src/lib/Tabs/RouteTabs.d.ts +11 -0
- package/src/lib/Tabs/TabPanel.d.ts +25 -0
- package/src/lib/Tabs/{index.ts → index.d.ts} +2 -2
- package/src/lib/{index.ts → index.d.ts} +16 -16
- package/src/theme/baseTheme.d.ts +2 -0
- package/src/theme/index.d.ts +1 -0
- package/src/theme/inputThemeOptions.d.ts +117 -0
- package/src/theme/stepperThemeOptions.d.ts +16 -0
- package/src/theme/tableThemeOptions.d.ts +47 -0
- package/src/theme/typographyThemeOptions.d.ts +29 -0
- package/src/utils/common.d.ts +7 -0
- package/src/utils/dem.d.ts +27 -0
- package/src/utils/hooks.d.ts +7 -0
- package/src/utils/{index.ts → index.d.ts} +5 -5
- package/src/utils/ui-utils.d.ts +16 -0
- package/src/utils/validators.d.ts +5 -0
- package/.babelrc +0 -13
- package/.eslintrc.json +0 -22
- package/jest.config.ts +0 -11
- package/project.json +0 -89
- package/rollup.config.js +0 -146
- package/src/assets/chevron_left_gray.svg +0 -3
- package/src/consts/index.ts +0 -13
- package/src/interfaces/common.ts +0 -18
- package/src/interfaces/definition.ts +0 -143
- package/src/interfaces/ui.ts +0 -80
- package/src/lib/Alert/Alert.tsx +0 -108
- package/src/lib/Alert/index.ts +0 -1
- package/src/lib/Breadcrumbs/Breadcrumbs.styled.tsx +0 -16
- package/src/lib/Breadcrumbs/Breadcrumbs.tsx +0 -40
- package/src/lib/ContentLayout/ContentLayout.tsx +0 -31
- package/src/lib/ContentLayout/index.ts +0 -1
- package/src/lib/Definition/CreateDefinition/CreateDefinition.tsx +0 -78
- package/src/lib/Definition/DefinitionFiller/DefinitionFiller.tsx +0 -71
- package/src/lib/Definition/DefinitionValueView/DefinitionValueView.tsx +0 -54
- package/src/lib/Definition/DefinitionValueView/PropertyDataView.tsx +0 -67
- package/src/lib/Forms/BackButton.tsx +0 -46
- package/src/lib/Forms/ControlAceEditor.tsx +0 -125
- package/src/lib/Forms/ControlAutocomplete.tsx +0 -145
- package/src/lib/Forms/ControlCheckbox.tsx +0 -113
- package/src/lib/Forms/ControlDate.tsx +0 -75
- package/src/lib/Forms/ControlDateTime.tsx +0 -77
- package/src/lib/Forms/ControlDebouncedInput.tsx +0 -80
- package/src/lib/Forms/ControlInput.tsx +0 -111
- package/src/lib/Forms/ControlNumberInput.tsx +0 -121
- package/src/lib/Forms/ControlQueryAutocomplete.tsx +0 -197
- package/src/lib/Forms/ControlRadio.tsx +0 -136
- package/src/lib/Forms/ControlSelect.tsx +0 -164
- package/src/lib/Forms/ControlSwitch.tsx +0 -71
- package/src/lib/Forms/ControlTime.tsx +0 -93
- package/src/lib/Forms/CopyButton.tsx +0 -46
- package/src/lib/Forms/useAutocomplete.tsx +0 -47
- package/src/lib/InfoItem/InfoItem.tsx +0 -40
- package/src/lib/InfoItem/styles.ts +0 -17
- package/src/lib/JsonPathPicker/JsonPathPicker.tsx +0 -73
- package/src/lib/JsonPathPicker/PropertyStep.tsx +0 -70
- package/src/lib/JsonView/JsonView.tsx +0 -41
- package/src/lib/Loader/Loader.tsx +0 -41
- package/src/lib/Modals/JsonModalView.tsx +0 -53
- package/src/lib/Property/PropertyFiller/JsonEditor.tsx +0 -58
- package/src/lib/Property/PropertyFiller/MultiplePropertyFiller.tsx +0 -129
- package/src/lib/Property/PropertyFiller/MultiplePropertyWidget.tsx +0 -85
- package/src/lib/Property/PropertyFiller/PropertyFiller.tsx +0 -199
- package/src/lib/Property/PropertyFiller/usePropertyFiller.ts +0 -72
- package/src/lib/Property/PropertyFiller/useStyles.ts +0 -12
- package/src/lib/Property/PropertyValidator/NodeValidator.tsx +0 -92
- package/src/lib/Property/PropertyValidator/NodesList.tsx +0 -26
- package/src/lib/Property/PropertyValidator/NumericTypeValidator.tsx +0 -59
- package/src/lib/Property/PropertyValidator/PropertyValidator.tsx +0 -42
- package/src/lib/Property/PropertyValidator/PropertyValidatorContext.tsx +0 -4
- package/src/lib/Property/PropertyValidator/StringTypeValidator.tsx +0 -36
- package/src/lib/Property/PropertyValidator/ValidationNodeSelector.tsx +0 -62
- package/src/lib/Property/PropertyValidator/index.ts +0 -1
- package/src/lib/Property/PropertyValueField/BooleanValueField.tsx +0 -49
- package/src/lib/Property/PropertyValueField/DateTimeValueField.tsx +0 -58
- package/src/lib/Property/PropertyValueField/DateValueField.tsx +0 -58
- package/src/lib/Property/PropertyValueField/JsonValueField.tsx +0 -65
- package/src/lib/Property/PropertyValueField/PropertyValueField.tsx +0 -49
- package/src/lib/Property/PropertyValueField/StringValueField.tsx +0 -50
- package/src/lib/Property/PropertyValueField/TimeValueField.tsx +0 -67
- package/src/lib/Property/PropertyWidget/PropertyWidget.tsx +0 -115
- package/src/lib/Property/UpsertProperty/CreatePropertiesList.tsx +0 -148
- package/src/lib/Property/UpsertProperty/CreatePropertyFormFields.tsx +0 -158
- package/src/lib/Property/UpsertProperty/CustomPropertyField.tsx +0 -40
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/BigDecimalPropertyFields.tsx +0 -41
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/DateAdditionalFields.tsx +0 -27
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityAdditionalFields.tsx +0 -133
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/EntityReferencePropertyFields.tsx +0 -46
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/PropertyAdditionalFields.tsx +0 -52
- package/src/lib/Property/UpsertProperty/PropertyAdditionalFields/StringPropertyFields.tsx +0 -103
- package/src/lib/Property/UpsertProperty/useCustomFields.ts +0 -22
- package/src/lib/Property/ViewPropertiesList/ViewPropertiesList.tsx +0 -37
- package/src/lib/Property/ViewProperty/EntityPropertiesShortView.tsx +0 -40
- package/src/lib/Property/ViewProperty/EntityPropertiesView.tsx +0 -48
- package/src/lib/Property/ViewProperty/PropertyDataTable.tsx +0 -148
- package/src/lib/Property/ViewProperty/PropertyItem.tsx +0 -43
- package/src/lib/Property/ViewProperty/ViewProperty.tsx +0 -52
- package/src/lib/Sidebar/Sidebar.styled.tsx +0 -157
- package/src/lib/Sidebar/Sidebar.tsx +0 -27
- package/src/lib/Sidebar/SidebarContext.tsx +0 -37
- package/src/lib/Sidebar/SidebarDrawer.tsx +0 -50
- package/src/lib/Sidebar/SidebarLink/MenuIcon.tsx +0 -16
- package/src/lib/Sidebar/SidebarLink/SidebarLink.tsx +0 -54
- package/src/lib/Sidebar/SidebarLink/SidebarLinkItem.tsx +0 -54
- package/src/lib/Sidebar/SidebarLink/SidebarNestedItem.tsx +0 -62
- package/src/lib/Sidebar/index.ts +0 -2
- package/src/lib/Status/Status.tsx +0 -16
- package/src/lib/Status/styles.ts +0 -21
- package/src/lib/StepperView/StepperView.tsx +0 -73
- package/src/lib/Table/DataGrid/JsonTypeCell.tsx +0 -51
- package/src/lib/Table/DataGrid/Table.tsx +0 -117
- package/src/lib/Table/DataGrid/TableAction.tsx +0 -43
- package/src/lib/Table/DataGrid/TableColumnMenu.tsx +0 -12
- package/src/lib/Table/DataGrid/TablePagination.tsx +0 -42
- package/src/lib/Table/DataGrid/index.ts +0 -2
- package/src/lib/Table/DataGrid/styles.ts +0 -59
- package/src/lib/Table/DataGrid/usePagination.ts +0 -15
- package/src/lib/Table/DataGrid/useTableQueryPagination.ts +0 -47
- package/src/lib/Table/DataGrid/useTableQuerySorting.ts +0 -47
- package/src/lib/Table/SimpleTable/SimpleTable.tsx +0 -138
- package/src/lib/Table/SimpleTable/TableActionCell.tsx +0 -67
- package/src/lib/Table/SimpleTable/index.ts +0 -2
- package/src/lib/Table/SimpleTable/useTablePagination.ts +0 -54
- package/src/lib/Table/SimpleTable/useTableSorting.ts +0 -50
- package/src/lib/Table/index.ts +0 -2
- package/src/lib/Tabs/RouteTabs.tsx +0 -54
- package/src/lib/Tabs/TabPanel.tsx +0 -42
- package/src/theme/baseTheme.ts +0 -41
- package/src/theme/fonts.d.ts +0 -2
- package/src/theme/index.ts +0 -126
- package/src/theme/inputThemeOptions.ts +0 -126
- package/src/theme/stepperThemeOptions.ts +0 -20
- package/src/theme/tableThemeOptions.ts +0 -50
- package/src/theme/typographyThemeOptions.ts +0 -32
- package/src/utils/common.ts +0 -73
- package/src/utils/dem.ts +0 -431
- package/src/utils/hooks.ts +0 -41
- package/src/utils/ui-utils.tsx +0 -134
- package/src/utils/validators.ts +0 -14
- package/tsconfig.json +0 -25
- package/tsconfig.lib.json +0 -23
- package/tsconfig.spec.json +0 -20
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import Box from '@mui/material/Box';
|
|
2
|
-
import { PropertiesArrayType } from '../../../interfaces';
|
|
3
|
-
import { StepperData, StepperView } from '../../StepperView';
|
|
4
|
-
import { useMemo } from 'react';
|
|
5
|
-
|
|
6
|
-
type Props = {
|
|
7
|
-
properties: PropertiesArrayType;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const EntityPropertiesShortView = ({ properties = [] }: Props) => {
|
|
11
|
-
const stepperData: StepperData = useMemo(() => {
|
|
12
|
-
if (properties) {
|
|
13
|
-
return properties.map((property) => {
|
|
14
|
-
const propertyType =
|
|
15
|
-
typeof property.propertyType === 'string' ? property.propertyType : property['propertyType']['value'];
|
|
16
|
-
return {
|
|
17
|
-
label: (
|
|
18
|
-
<Box display="flex" flexDirection="column">
|
|
19
|
-
<b>
|
|
20
|
-
{property.name}
|
|
21
|
-
{property.isRequired ? '*' : ''}
|
|
22
|
-
</b>
|
|
23
|
-
<span>
|
|
24
|
-
{property.key} | {property.isMultiple ? 'multiple' : 'single'} | {propertyType}
|
|
25
|
-
</span>
|
|
26
|
-
</Box>
|
|
27
|
-
),
|
|
28
|
-
content: property.propertyType === 'ENTITY' && (
|
|
29
|
-
<EntityPropertiesShortView properties={property.properties as PropertiesArrayType} />
|
|
30
|
-
),
|
|
31
|
-
};
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
return [];
|
|
35
|
-
}, [properties]);
|
|
36
|
-
|
|
37
|
-
return <StepperView data={stepperData} />;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export default EntityPropertiesShortView;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import Box from '@mui/material/Box';
|
|
2
|
-
import Stepper from '@mui/material/Stepper';
|
|
3
|
-
import Step from '@mui/material/Step';
|
|
4
|
-
import StepLabel from '@mui/material/StepLabel';
|
|
5
|
-
import StepContent from '@mui/material/StepContent';
|
|
6
|
-
import Typography from '@mui/material/Typography';
|
|
7
|
-
import ViewProperty from './ViewProperty';
|
|
8
|
-
|
|
9
|
-
import { memo, useMemo } from 'react';
|
|
10
|
-
import { PropertiesArrayType, PropertyType } from '../../../interfaces';
|
|
11
|
-
|
|
12
|
-
type Props = {
|
|
13
|
-
properties: PropertiesArrayType;
|
|
14
|
-
parentNames?: string[];
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const EntityPropertiesView = ({ properties, parentNames = [] }: Props) => {
|
|
18
|
-
const hasProperties = useMemo(() => {
|
|
19
|
-
let hasProps = false;
|
|
20
|
-
properties.every((property) => {
|
|
21
|
-
if (property.propertyType === PropertyType.ENTITY) {
|
|
22
|
-
hasProps = true;
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
return true;
|
|
26
|
-
});
|
|
27
|
-
return hasProps;
|
|
28
|
-
}, [properties]);
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<Box mt={4}>
|
|
32
|
-
<Typography variant="h6">Properties</Typography>
|
|
33
|
-
<Stepper orientation="vertical" style={{ paddingLeft: '4px' }}>
|
|
34
|
-
{properties.map((property) => (
|
|
35
|
-
<Step expanded key={property.key}>
|
|
36
|
-
<StepLabel StepIconProps={{ icon: '', completed: false, active: true }} />
|
|
37
|
-
<StepContent>
|
|
38
|
-
<ViewProperty property={property} parentNames={[...parentNames]} defaultExpanded={false} />
|
|
39
|
-
</StepContent>
|
|
40
|
-
</Step>
|
|
41
|
-
))}
|
|
42
|
-
{hasProperties && <Step />}
|
|
43
|
-
</Stepper>
|
|
44
|
-
</Box>
|
|
45
|
-
);
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export default memo(EntityPropertiesView);
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import Box from '@mui/material/Box';
|
|
2
|
-
import Table from '@mui/material/Table';
|
|
3
|
-
import TableBody from '@mui/material/TableBody';
|
|
4
|
-
import TableRow from '@mui/material/TableRow';
|
|
5
|
-
import TableCell from '@mui/material/TableCell';
|
|
6
|
-
import Typography from '@mui/material/Typography';
|
|
7
|
-
import Chip from '@mui/material/Chip';
|
|
8
|
-
import CheckCircleIcon from '@mui/icons-material/CheckCircle';
|
|
9
|
-
|
|
10
|
-
import { useMemo } from 'react';
|
|
11
|
-
import { PropertyType, PropertyUnion } from '../../../interfaces';
|
|
12
|
-
import { JsonView } from '../../JsonView';
|
|
13
|
-
|
|
14
|
-
type Props = {
|
|
15
|
-
property: PropertyUnion;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
type ValueDisplayProps = {
|
|
19
|
-
value: unknown;
|
|
20
|
-
type: PropertyType;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const labels = {
|
|
24
|
-
name: 'Name',
|
|
25
|
-
key: 'Key',
|
|
26
|
-
propertyType: 'Property Type',
|
|
27
|
-
defaultValue: 'Default Value',
|
|
28
|
-
defaultValues: 'Default Values',
|
|
29
|
-
sortOrder: 'Sort Order',
|
|
30
|
-
isRequired: 'Required',
|
|
31
|
-
isMultiple: 'Multiple',
|
|
32
|
-
isEnabled: 'Enabled',
|
|
33
|
-
isViewableInList: 'Is Viewable In List',
|
|
34
|
-
precisionScale: 'Precision Scale',
|
|
35
|
-
roundingMode: 'Rounding Mode',
|
|
36
|
-
format: 'Format',
|
|
37
|
-
definitionCode: 'Definition Code',
|
|
38
|
-
definitionVersion: 'Definition Version',
|
|
39
|
-
labelPropertyCode: 'Label Property Code',
|
|
40
|
-
valuePropertyCode: 'Value Property Code',
|
|
41
|
-
restrictedValues: 'Restricted Values',
|
|
42
|
-
value: 'Value',
|
|
43
|
-
values: 'Values',
|
|
44
|
-
uiSettings: 'UI Settings',
|
|
45
|
-
validationNode: 'Validation Node',
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const ValueDisplay = ({ value, type }: ValueDisplayProps) => {
|
|
49
|
-
if ((type === PropertyType.JSON || type === PropertyType.ENTITY || type === PropertyType.ANY) && value) {
|
|
50
|
-
return <JsonView value={value} />;
|
|
51
|
-
} else {
|
|
52
|
-
return (
|
|
53
|
-
<Typography variant="subtitle1" display="inline" style={{ wordBreak: 'break-word' }}>
|
|
54
|
-
{value === null ? 'null' : value.toString()}
|
|
55
|
-
</Typography>
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
const formatDiplayValue = (value: any, key: string, type: PropertyType) => {
|
|
61
|
-
switch (key) {
|
|
62
|
-
case 'isRequired':
|
|
63
|
-
case 'isMultiple':
|
|
64
|
-
case 'isEnabled':
|
|
65
|
-
case 'isViewableInList':
|
|
66
|
-
return value ? <CheckCircleIcon color="primary" fontSize="small" /> : null;
|
|
67
|
-
case 'restrictedValues':
|
|
68
|
-
return value ? (
|
|
69
|
-
<Box display="flex" flexWrap="wrap">
|
|
70
|
-
{(value as string[]).map((restrictedValue) => (
|
|
71
|
-
<Chip
|
|
72
|
-
key={restrictedValue}
|
|
73
|
-
label={restrictedValue}
|
|
74
|
-
style={{ wordBreak: 'break-word', maxWidth: '500px' }}
|
|
75
|
-
/>
|
|
76
|
-
))}
|
|
77
|
-
</Box>
|
|
78
|
-
) : null;
|
|
79
|
-
case 'defaultValue':
|
|
80
|
-
case 'value':
|
|
81
|
-
return <ValueDisplay value={value} type={type} />;
|
|
82
|
-
case 'values':
|
|
83
|
-
case 'defaultValues':
|
|
84
|
-
if (
|
|
85
|
-
!Array.isArray(value) ||
|
|
86
|
-
type === PropertyType.ENTITY ||
|
|
87
|
-
type === PropertyType.JSON ||
|
|
88
|
-
type === PropertyType.ANY
|
|
89
|
-
) {
|
|
90
|
-
return <JsonView value={value} />;
|
|
91
|
-
} else {
|
|
92
|
-
return (
|
|
93
|
-
<div>
|
|
94
|
-
[
|
|
95
|
-
{(value as unknown[])?.map((v, index) => (
|
|
96
|
-
<div key={index}>
|
|
97
|
-
<ValueDisplay value={v} type={type} />
|
|
98
|
-
</div>
|
|
99
|
-
))}
|
|
100
|
-
]
|
|
101
|
-
</div>
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
case 'uiSettings':
|
|
105
|
-
case 'validationNode':
|
|
106
|
-
return value ? <JsonView value={value} /> : null;
|
|
107
|
-
default:
|
|
108
|
-
return (
|
|
109
|
-
<Typography variant="subtitle1" display="inline" style={{ wordBreak: 'break-word' }}>
|
|
110
|
-
{value}
|
|
111
|
-
</Typography>
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
const PropertyDataTable = ({ property }: Props) => {
|
|
117
|
-
const propertyData = useMemo(() => {
|
|
118
|
-
if (property) {
|
|
119
|
-
if (property.isMultiple) {
|
|
120
|
-
delete property.defaultValue;
|
|
121
|
-
delete property['value'];
|
|
122
|
-
} else {
|
|
123
|
-
delete property.defaultValues;
|
|
124
|
-
delete property['values'];
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return property;
|
|
128
|
-
}, [property]);
|
|
129
|
-
|
|
130
|
-
return (
|
|
131
|
-
<Table size="small">
|
|
132
|
-
<TableBody>
|
|
133
|
-
{Object.keys(labels).map((key) =>
|
|
134
|
-
key in propertyData ? (
|
|
135
|
-
<TableRow key={key}>
|
|
136
|
-
<TableCell width="30%">
|
|
137
|
-
<Typography>{labels[key]}</Typography>
|
|
138
|
-
</TableCell>
|
|
139
|
-
<TableCell>{formatDiplayValue(propertyData[key], key, propertyData.propertyType)}</TableCell>
|
|
140
|
-
</TableRow>
|
|
141
|
-
) : null
|
|
142
|
-
)}
|
|
143
|
-
</TableBody>
|
|
144
|
-
</Table>
|
|
145
|
-
);
|
|
146
|
-
};
|
|
147
|
-
|
|
148
|
-
export default PropertyDataTable;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import TreeItem from '@mui/lab/TreeItem';
|
|
2
|
-
|
|
3
|
-
import { useMemo } from 'react';
|
|
4
|
-
import { PropertiesArrayType, PropertyType, PropertyUnion } from '../../../interfaces';
|
|
5
|
-
|
|
6
|
-
type PropertyItemProps = {
|
|
7
|
-
property: PropertyUnion;
|
|
8
|
-
showName: boolean;
|
|
9
|
-
showType: boolean;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const PropertyItem = ({ property, showName, showType }: PropertyItemProps) => {
|
|
13
|
-
const label = useMemo(() => {
|
|
14
|
-
let labelText = '';
|
|
15
|
-
|
|
16
|
-
if (property) {
|
|
17
|
-
labelText += `<b>${property.key}</b>`;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (showName) {
|
|
21
|
-
labelText += ` - ${property.name}`;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (showType) {
|
|
25
|
-
const type = property.propertyType['value'] ?? property.propertyType;
|
|
26
|
-
labelText += ` - ${type}${property.isMultiple ? '[]' : ''}`;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return labelText;
|
|
30
|
-
}, [property, showName, showType]);
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<TreeItem nodeId={property.key} label={<div dangerouslySetInnerHTML={{ __html: label }} />}>
|
|
34
|
-
{property.propertyType === PropertyType.ENTITY
|
|
35
|
-
? (property.properties as PropertiesArrayType).map((prop) => (
|
|
36
|
-
<PropertyItem key={prop.key} property={prop} showName={showName} showType={showType} />
|
|
37
|
-
))
|
|
38
|
-
: null}
|
|
39
|
-
</TreeItem>
|
|
40
|
-
);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export default PropertyItem;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import Box from '@mui/material/Box';
|
|
2
|
-
import Typography from '@mui/material/Typography';
|
|
3
|
-
import Accordion from '@mui/material/Accordion';
|
|
4
|
-
import AccordionSummary from '@mui/material/AccordionSummary';
|
|
5
|
-
import AccordionDetails from '@mui/material/AccordionDetails';
|
|
6
|
-
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
7
|
-
import PropertyDataTable from './PropertyDataTable';
|
|
8
|
-
import EntityPropertiesView from './EntityPropertiesView';
|
|
9
|
-
|
|
10
|
-
import { useEffect, useState } from 'react';
|
|
11
|
-
import { propertiesObjectToArray } from '../../../utils';
|
|
12
|
-
import { PropertiesObjectType, PropertyType, PropertyUnion } from '../../../interfaces';
|
|
13
|
-
|
|
14
|
-
type Props = {
|
|
15
|
-
property: PropertyUnion;
|
|
16
|
-
parentNames?: string[];
|
|
17
|
-
defaultExpanded?: boolean;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export const ViewProperty = ({ property, parentNames = [], defaultExpanded = true }: Props) => {
|
|
21
|
-
const [expanded, setExpanded] = useState(true);
|
|
22
|
-
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
setExpanded(defaultExpanded);
|
|
25
|
-
}, [defaultExpanded]);
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<Accordion
|
|
29
|
-
elevation={3}
|
|
30
|
-
style={{ backgroundColor: parentNames.length % 2 === 1 ? '#f1f1f1' : '#fff' }}
|
|
31
|
-
expanded={expanded}
|
|
32
|
-
onChange={() => setExpanded((prevState) => !prevState)}
|
|
33
|
-
>
|
|
34
|
-
<AccordionSummary expandIcon={<ExpandMoreIcon />}>
|
|
35
|
-
<Typography style={{ wordBreak: 'break-word', fontWeight: '600' }}>{property.name}</Typography>
|
|
36
|
-
</AccordionSummary>
|
|
37
|
-
<AccordionDetails>
|
|
38
|
-
<Box width="100%">
|
|
39
|
-
<PropertyDataTable property={property} />
|
|
40
|
-
{property.propertyType === PropertyType.ENTITY && (
|
|
41
|
-
<EntityPropertiesView
|
|
42
|
-
properties={propertiesObjectToArray(property.properties as PropertiesObjectType)}
|
|
43
|
-
parentNames={[...parentNames, property.name]}
|
|
44
|
-
/>
|
|
45
|
-
)}
|
|
46
|
-
</Box>
|
|
47
|
-
</AccordionDetails>
|
|
48
|
-
</Accordion>
|
|
49
|
-
);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
export default ViewProperty;
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import MuiDrawer from '@mui/material/Drawer';
|
|
2
|
-
import MuiList from '@mui/material/List';
|
|
3
|
-
import MuiListItem from '@mui/material/ListItem';
|
|
4
|
-
import MuiListItemIcon from '@mui/material/ListItemIcon';
|
|
5
|
-
import MuiListItemButton from '@mui/material/ListItemButton';
|
|
6
|
-
import MuiListSubheader from '@mui/material/ListSubheader';
|
|
7
|
-
import MuiListItemText from '@mui/material/ListItemText';
|
|
8
|
-
import Toolbar from '@mui/material/Toolbar';
|
|
9
|
-
import MuiButtonBase from '@mui/material/ButtonBase';
|
|
10
|
-
import { styled } from '@mui/material/styles';
|
|
11
|
-
|
|
12
|
-
const drawerWidth = 248;
|
|
13
|
-
|
|
14
|
-
export const Container = styled('div')({
|
|
15
|
-
position: 'relative',
|
|
16
|
-
'&:hover': {
|
|
17
|
-
'.button-collapse': {
|
|
18
|
-
opacity: 1,
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
export const Drawer = styled(MuiDrawer)((props) => ({
|
|
24
|
-
width: drawerWidth,
|
|
25
|
-
flexShrink: 0,
|
|
26
|
-
position: 'relative',
|
|
27
|
-
transition: 'all 0.3s ease-in-out',
|
|
28
|
-
'& .MuiDrawer-paper': {
|
|
29
|
-
backgroundColor: props.theme.palette.secondary.main,
|
|
30
|
-
width: drawerWidth,
|
|
31
|
-
boxSizing: 'border-box',
|
|
32
|
-
borderRight: 'none',
|
|
33
|
-
borderRadius: 0,
|
|
34
|
-
transition: 'all 0.3s ease-in-out',
|
|
35
|
-
overflow: 'hidden',
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
'&.collapsed': {
|
|
39
|
-
width: 64,
|
|
40
|
-
'& .MuiDrawer-paper': {
|
|
41
|
-
width: 64,
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
}));
|
|
45
|
-
|
|
46
|
-
export const Header = styled(Toolbar)(({ theme }) => ({
|
|
47
|
-
backgroundColor: '#fff',
|
|
48
|
-
borderRight: '1px solid rgba(38, 40, 66, 0.08)',
|
|
49
|
-
fontSize: 24,
|
|
50
|
-
fontWeight: 600,
|
|
51
|
-
// padding: theme.spacing(1, 4)
|
|
52
|
-
}));
|
|
53
|
-
|
|
54
|
-
export const List = styled(MuiList)((props) => ({
|
|
55
|
-
padding: props.theme.spacing(3),
|
|
56
|
-
margin: 0,
|
|
57
|
-
}));
|
|
58
|
-
|
|
59
|
-
export const ListItem = styled(MuiListItem)((props) => ({
|
|
60
|
-
color: '#fff',
|
|
61
|
-
height: props.theme.spacing(11),
|
|
62
|
-
overflow: 'hidden',
|
|
63
|
-
}));
|
|
64
|
-
|
|
65
|
-
export const ListItemButton = styled(MuiListItemButton)(({ theme }) => ({
|
|
66
|
-
borderRadius: theme.spacing(2.5),
|
|
67
|
-
padding: theme.spacing(2),
|
|
68
|
-
height: theme.spacing(11),
|
|
69
|
-
'&.active': {
|
|
70
|
-
backgroundColor: 'rgba(38, 40, 66, 0.12)',
|
|
71
|
-
'&.main': {
|
|
72
|
-
backgroundColor: 'rgba(255, 255, 255, 0.12)',
|
|
73
|
-
borderLeft: '4px solid #E0613A',
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
'&:hover': {
|
|
77
|
-
backgroundColor: 'rgba(255, 255, 255, 0.08)',
|
|
78
|
-
},
|
|
79
|
-
|
|
80
|
-
'&.collapsed': {
|
|
81
|
-
width: theme.spacing(11),
|
|
82
|
-
'&.active': {
|
|
83
|
-
'&.main': {
|
|
84
|
-
border: 'none',
|
|
85
|
-
backgroundColor: '#E0613A',
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
}));
|
|
90
|
-
|
|
91
|
-
export const ListItemIcon = styled(MuiListItemIcon)(({ theme }) => ({
|
|
92
|
-
color: '#fff',
|
|
93
|
-
width: 20,
|
|
94
|
-
height: 20,
|
|
95
|
-
minWidth: 20,
|
|
96
|
-
marginRight: theme.spacing(2),
|
|
97
|
-
'& svg': {
|
|
98
|
-
marginLeft: 2,
|
|
99
|
-
fill: '#fff',
|
|
100
|
-
color: '#fff',
|
|
101
|
-
},
|
|
102
|
-
'&.collapsed': {
|
|
103
|
-
marginRight: 0,
|
|
104
|
-
},
|
|
105
|
-
}));
|
|
106
|
-
|
|
107
|
-
export const ListSubheader = styled(MuiListSubheader)(() => ({
|
|
108
|
-
backgroundColor: 'inherit',
|
|
109
|
-
color: '#fff',
|
|
110
|
-
paddingLeft: 0,
|
|
111
|
-
textTransform: 'uppercase',
|
|
112
|
-
}));
|
|
113
|
-
|
|
114
|
-
export const ListItemText = styled(MuiListItemText)((props) => ({
|
|
115
|
-
width: '100%',
|
|
116
|
-
|
|
117
|
-
'& > *': {
|
|
118
|
-
overflow: 'hidden',
|
|
119
|
-
textOverflow: 'ellipsis',
|
|
120
|
-
wordBreak: 'break-all',
|
|
121
|
-
whiteSpace: 'nowrap',
|
|
122
|
-
},
|
|
123
|
-
|
|
124
|
-
'&.collapsed': {
|
|
125
|
-
display: 'none',
|
|
126
|
-
},
|
|
127
|
-
}));
|
|
128
|
-
|
|
129
|
-
export const ChildrenList = styled(MuiList)((props) => ({
|
|
130
|
-
margin: 0,
|
|
131
|
-
padding: 0,
|
|
132
|
-
'& .MuiListItemText-root': {
|
|
133
|
-
paddingLeft: props.theme.spacing(7),
|
|
134
|
-
},
|
|
135
|
-
}));
|
|
136
|
-
|
|
137
|
-
export const CollapseButton = styled(MuiButtonBase)((props) => ({
|
|
138
|
-
position: 'absolute',
|
|
139
|
-
top: props.theme.spacing(10),
|
|
140
|
-
left: 'calc(100% - 16px)',
|
|
141
|
-
width: props.theme.spacing(8),
|
|
142
|
-
height: props.theme.spacing(8),
|
|
143
|
-
border: '1px solid #E0E3EA',
|
|
144
|
-
borderRadius: '50%',
|
|
145
|
-
boxShadow: '0px 2px 8px rgba(0, 0, 0, 0.12)',
|
|
146
|
-
backgroundColor: '#fff',
|
|
147
|
-
zIndex: 8000,
|
|
148
|
-
opacity: 0,
|
|
149
|
-
transition: 'all 0.3s ease-in-out',
|
|
150
|
-
|
|
151
|
-
'&.collapsed': {
|
|
152
|
-
img: {
|
|
153
|
-
transition: 'all 0.3s ease-in-out',
|
|
154
|
-
transform: 'rotate(180deg)',
|
|
155
|
-
},
|
|
156
|
-
},
|
|
157
|
-
}));
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { ThemeProvider } from '@mui/material/styles';
|
|
2
|
-
import { SidebarContextProvider } from './SidebarContext';
|
|
3
|
-
import { theme as defaultTheme } from '@dartech/arsenal-ui';
|
|
4
|
-
import SidebarDrawer from './SidebarDrawer';
|
|
5
|
-
import type { Route } from '@dartech/arsenal-ui';
|
|
6
|
-
|
|
7
|
-
type Props = {
|
|
8
|
-
routes: Route[];
|
|
9
|
-
theme?: any;
|
|
10
|
-
title?: string;
|
|
11
|
-
id?: string;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export const Sidebar = ({
|
|
15
|
-
routes,
|
|
16
|
-
theme = defaultTheme,
|
|
17
|
-
title = '',
|
|
18
|
-
id
|
|
19
|
-
}: Props) => {
|
|
20
|
-
return (
|
|
21
|
-
<ThemeProvider theme={theme}>
|
|
22
|
-
<SidebarContextProvider>
|
|
23
|
-
<SidebarDrawer title={title} routes={routes} id={id} />
|
|
24
|
-
</SidebarContextProvider>
|
|
25
|
-
</ThemeProvider>
|
|
26
|
-
);
|
|
27
|
-
};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { createContext, useCallback, useContext, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
type SidebarContextProps = {
|
|
4
|
-
collapsed: boolean;
|
|
5
|
-
toggleCollapse: () => void;
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export const SidebarContext = createContext<SidebarContextProps>({
|
|
9
|
-
collapsed: false,
|
|
10
|
-
toggleCollapse: () => {
|
|
11
|
-
console.log('collapse toggle');
|
|
12
|
-
},
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
export const useSidebarContext = () => useContext(SidebarContext);
|
|
16
|
-
|
|
17
|
-
export const SidebarContextProvider = ({ children }) => {
|
|
18
|
-
const [collapsed, setCollapsed] = useState(
|
|
19
|
-
localStorage.getItem('sidebar_collapsed') === 'true'
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
const toggleCollapse = useCallback(() => {
|
|
23
|
-
setCollapsed(!collapsed);
|
|
24
|
-
localStorage.setItem('sidebar_collapsed', `${!collapsed}`);
|
|
25
|
-
window.dispatchEvent(new CustomEvent('sidebar_collapsed', {
|
|
26
|
-
detail: {
|
|
27
|
-
collapsed: !collapsed
|
|
28
|
-
}
|
|
29
|
-
}))
|
|
30
|
-
}, [collapsed]);
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<SidebarContext.Provider value={{ collapsed, toggleCollapse }}>
|
|
34
|
-
{children}
|
|
35
|
-
</SidebarContext.Provider>
|
|
36
|
-
);
|
|
37
|
-
};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import SidebarLink from './SidebarLink';
|
|
2
|
-
import {
|
|
3
|
-
Container,
|
|
4
|
-
CollapseButton,
|
|
5
|
-
Drawer,
|
|
6
|
-
Header,
|
|
7
|
-
List,
|
|
8
|
-
} from './Sidebar.styled';
|
|
9
|
-
import ArrowIcon from '../../assets/chevron_left_gray.svg';
|
|
10
|
-
import classnames from 'classnames';
|
|
11
|
-
import type { Route } from '../../interfaces';
|
|
12
|
-
import { useSidebarContext } from './SidebarContext';
|
|
13
|
-
|
|
14
|
-
type Props = {
|
|
15
|
-
title?: string;
|
|
16
|
-
routes: Route[];
|
|
17
|
-
id?: string;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const SidebarDrawer = ({ title, routes, id }: Props) => {
|
|
21
|
-
const { collapsed, toggleCollapse } = useSidebarContext();
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<Container>
|
|
25
|
-
<CollapseButton
|
|
26
|
-
className={classnames('button-collapse', {
|
|
27
|
-
collapsed,
|
|
28
|
-
})}
|
|
29
|
-
onClick={toggleCollapse}
|
|
30
|
-
>
|
|
31
|
-
<img src={ArrowIcon} alt="collapse" />
|
|
32
|
-
</CollapseButton>
|
|
33
|
-
<Drawer
|
|
34
|
-
variant="permanent"
|
|
35
|
-
anchor="left"
|
|
36
|
-
className={classnames({ collapsed })}
|
|
37
|
-
id={id}
|
|
38
|
-
>
|
|
39
|
-
{!!title && <Header>{title}</Header>}
|
|
40
|
-
<List>
|
|
41
|
-
{routes.map((route, index) => (
|
|
42
|
-
<SidebarLink key={index} route={route} />
|
|
43
|
-
))}
|
|
44
|
-
</List>
|
|
45
|
-
</Drawer>
|
|
46
|
-
</Container>
|
|
47
|
-
);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export default SidebarDrawer;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import Box from '@mui/material/Box';
|
|
2
|
-
|
|
3
|
-
type Props = {
|
|
4
|
-
src: string;
|
|
5
|
-
alt?: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export const MenuIcon = ({src, alt}: Props) => {
|
|
9
|
-
return (
|
|
10
|
-
<Box sx={{ width: 20, height: 20, display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
|
|
11
|
-
<img src={src} alt={alt} />
|
|
12
|
-
</Box>
|
|
13
|
-
)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export default MenuIcon
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import Collapse from '@mui/material/Collapse';
|
|
2
|
-
import SidebarLinkItem from './SidebarLinkItem';
|
|
3
|
-
import SidebarNestedItem from './SidebarNestedItem';
|
|
4
|
-
import type { Route } from '../../../interfaces';
|
|
5
|
-
import { useEffect, useMemo, useState } from 'react';
|
|
6
|
-
import { useLocation } from 'react-router-dom';
|
|
7
|
-
import { ChildrenList } from '../Sidebar.styled';
|
|
8
|
-
import { useSidebarContext } from '../SidebarContext';
|
|
9
|
-
|
|
10
|
-
type Props = {
|
|
11
|
-
route: Route;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const SidebarLink = ({ route }: Props) => {
|
|
15
|
-
const location = useLocation();
|
|
16
|
-
const { collapsed } = useSidebarContext();
|
|
17
|
-
|
|
18
|
-
const [open, setOpen] = useState(false);
|
|
19
|
-
|
|
20
|
-
const isActive = useMemo(
|
|
21
|
-
() => !!route.link && location.pathname.startsWith(route.link),
|
|
22
|
-
[location.pathname, route]
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
const handleClick = () => {
|
|
26
|
-
setOpen(!open);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
setOpen(isActive);
|
|
31
|
-
}, [isActive]);
|
|
32
|
-
|
|
33
|
-
return route.children?.length && !collapsed ? (
|
|
34
|
-
<>
|
|
35
|
-
<SidebarNestedItem
|
|
36
|
-
route={route}
|
|
37
|
-
isActive={isActive}
|
|
38
|
-
handleClick={handleClick}
|
|
39
|
-
isListOpen={open || !route.link}
|
|
40
|
-
/>
|
|
41
|
-
<Collapse in={open || !route.link} timeout="auto">
|
|
42
|
-
<ChildrenList>
|
|
43
|
-
{route.children?.map((childRoute, index) => (
|
|
44
|
-
<SidebarLink key={index} route={childRoute} />
|
|
45
|
-
))}
|
|
46
|
-
</ChildrenList>
|
|
47
|
-
</Collapse>
|
|
48
|
-
</>
|
|
49
|
-
) : (
|
|
50
|
-
<SidebarLinkItem route={route} isActive={isActive} />
|
|
51
|
-
);
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export default SidebarLink;
|