@chobantonov/jsonforms-react-antd-renderers 0.0.0-stage → 0.1.0
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/LICENSE +22 -0
- package/README.md +103 -2
- package/lib/additional/LabelRenderer.d.ts +13 -0
- package/lib/additional/ListWithDetailMasterItem.d.ts +9 -0
- package/lib/additional/ListWithDetailRenderer.d.ts +8 -0
- package/lib/additional/index.d.ts +4 -0
- package/lib/additional/unwrapped.d.ts +6 -0
- package/lib/antd-controls/AntdCheckbox.d.ts +10 -0
- package/lib/antd-controls/AntdClearValueButton.d.ts +44 -0
- package/lib/antd-controls/AntdClearableInput.d.ts +19 -0
- package/lib/antd-controls/AntdDatePicker.d.ts +7 -0
- package/lib/antd-controls/AntdDateTimePicker.d.ts +7 -0
- package/lib/antd-controls/AntdFile.d.ts +7 -0
- package/lib/antd-controls/AntdInputInteger.d.ts +3 -0
- package/lib/antd-controls/AntdInputNumber.d.ts +3 -0
- package/lib/antd-controls/AntdInputNumberFormat.d.ts +6 -0
- package/lib/antd-controls/AntdInputText.d.ts +6 -0
- package/lib/antd-controls/AntdNumericInput.d.ts +9 -0
- package/lib/antd-controls/AntdOtp.d.ts +33 -0
- package/lib/antd-controls/AntdPassword.d.ts +6 -0
- package/lib/antd-controls/AntdRadioGroup.d.ts +6 -0
- package/lib/antd-controls/AntdRevealButton.d.ts +32 -0
- package/lib/antd-controls/AntdSelect.d.ts +7 -0
- package/lib/antd-controls/AntdSlider.d.ts +21 -0
- package/lib/antd-controls/AntdTimePicker.d.ts +6 -0
- package/lib/antd-controls/AntdToggle.d.ts +6 -0
- package/lib/antd-controls/FileFeedback.d.ts +6 -0
- package/lib/antd-controls/index.d.ts +18 -0
- package/lib/antd-controls/useTemporalPicker.d.ts +49 -0
- package/lib/cells/AntdCompositeCell.d.ts +8 -0
- package/lib/cells/BooleanCell.d.ts +6 -0
- package/lib/cells/BooleanToggleCell.d.ts +5 -0
- package/lib/cells/CompositeDetailDialog.d.ts +15 -0
- package/lib/cells/CustomizableCells.d.ts +9 -0
- package/lib/cells/DateCell.d.ts +6 -0
- package/lib/cells/EnumCell.d.ts +11 -0
- package/lib/cells/IntegerCell.d.ts +6 -0
- package/lib/cells/NumberCell.d.ts +10 -0
- package/lib/cells/NumberFormatCell.d.ts +10 -0
- package/lib/cells/OneOfEnumCell.d.ts +11 -0
- package/lib/cells/PasswordCell.d.ts +5 -0
- package/lib/cells/TextCell.d.ts +10 -0
- package/lib/cells/TimeCell.d.ts +6 -0
- package/lib/cells/index.d.ts +14 -0
- package/lib/complex/AdditionalProperties.d.ts +4 -0
- package/lib/complex/AnyOfRenderer.d.ts +31 -0
- package/lib/complex/ArrayControlRenderer.d.ts +8 -0
- package/lib/complex/ChipsControl.d.ts +22 -0
- package/lib/complex/CollectionPager.d.ts +5 -0
- package/lib/complex/DataCell.d.ts +16 -0
- package/lib/complex/DeleteDialog.d.ts +14 -0
- package/lib/complex/DetailModal.d.ts +6 -0
- package/lib/complex/EnumArrayRenderer.d.ts +6 -0
- package/lib/complex/ErrorFeedback.d.ts +6 -0
- package/lib/complex/MixedRenderer.d.ts +6 -0
- package/lib/complex/MultiSelectControl.d.ts +17 -0
- package/lib/complex/ObjectRenderer.d.ts +5 -0
- package/lib/complex/OneOfRenderer.d.ts +6 -0
- package/lib/complex/OneOfTabRenderer.d.ts +5 -0
- package/lib/complex/RecursiveTreeRenderer.d.ts +4 -0
- package/lib/complex/RowDetailFrame.d.ts +10 -0
- package/lib/complex/ScalarCompositionRenderer.d.ts +4 -0
- package/lib/complex/TabSwitchConfirmDialog.d.ts +9 -0
- package/lib/complex/TableControl.d.ts +9 -0
- package/lib/complex/TableToolbar.d.ts +21 -0
- package/lib/complex/TupleAdditionalItems.d.ts +13 -0
- package/lib/complex/TupleControlRenderer.d.ts +6 -0
- package/lib/complex/TupleField.d.ts +4 -0
- package/lib/complex/ValidationIcon.d.ts +8 -0
- package/lib/complex/additionalProperties/AntdAdditionalPropertyActions.d.ts +9 -0
- package/lib/complex/additionalProperties/AntdAdditionalPropertyRenameDialog.d.ts +11 -0
- package/lib/complex/index.d.ts +20 -0
- package/lib/complex/mixed/AntdJsonTypeIcon.d.ts +4 -0
- package/lib/complex/mixed/AntdMixedNavigationContext.d.ts +5 -0
- package/lib/complex/mixed/AntdMixedSplitPane.d.ts +5 -0
- package/lib/complex/mixed/AntdMixedTree.d.ts +15 -0
- package/lib/complex/mixed/AntdMixedTypeSelector.d.ts +12 -0
- package/lib/complex/mixed/AntdNestedMixedNavigation.d.ts +7 -0
- package/lib/complex/mixed/mixedTree.d.ts +2 -0
- package/lib/complex/unwrapped.d.ts +10 -0
- package/lib/controls/AnyOfStringOrEnumControl.d.ts +9 -0
- package/lib/controls/BooleanControl.d.ts +6 -0
- package/lib/controls/BooleanToggleControl.d.ts +6 -0
- package/lib/controls/ChoiceCards.d.ts +1 -0
- package/lib/controls/DateControl.d.ts +6 -0
- package/lib/controls/DateTimeControl.d.ts +6 -0
- package/lib/controls/EnumControl.d.ts +7 -0
- package/lib/controls/FileControl.d.ts +7 -0
- package/lib/controls/InputControl.d.ts +6 -0
- package/lib/controls/IntegerControl.d.ts +6 -0
- package/lib/controls/NativeControl.d.ts +6 -0
- package/lib/controls/NumberControl.d.ts +6 -0
- package/lib/controls/OneOfEnumControl.d.ts +7 -0
- package/lib/controls/OneOfRadioGroupControl.d.ts +6 -0
- package/lib/controls/PasswordControl.d.ts +18 -0
- package/lib/controls/PasswordOtpControl.d.ts +38 -0
- package/lib/controls/RadioGroup.d.ts +3 -0
- package/lib/controls/RadioGroupControl.d.ts +6 -0
- package/lib/controls/SliderControl.d.ts +6 -0
- package/lib/controls/TextControl.d.ts +6 -0
- package/lib/controls/TimeControl.d.ts +6 -0
- package/lib/controls/index.d.ts +20 -0
- package/lib/controls/unwrapped.d.ts +19 -0
- package/lib/index.d.ts +50 -0
- package/lib/jsonforms-react-antd.cjs.js +39 -0
- package/lib/jsonforms-react-antd.cjs.js.map +1 -0
- package/lib/jsonforms-react-antd.esm.js +4235 -0
- package/lib/jsonforms-react-antd.esm.js.map +1 -0
- package/lib/layouts/ArrayLayout.d.ts +5 -0
- package/lib/layouts/ArrayLayoutRenderer.d.ts +8 -0
- package/lib/layouts/ArrayPanel.d.ts +7 -0
- package/lib/layouts/ArrayToolbar.d.ts +17 -0
- package/lib/layouts/CategorizationAccordionLayout.d.ts +21 -0
- package/lib/layouts/CategorizationLayout.d.ts +14 -0
- package/lib/layouts/CategorizationStepperLayout.d.ts +10 -0
- package/lib/layouts/CategoryHeader.d.ts +39 -0
- package/lib/layouts/ContainerIndicator.d.ts +37 -0
- package/lib/layouts/GroupLayout.d.ts +6 -0
- package/lib/layouts/HorizontalLayout.d.ts +10 -0
- package/lib/layouts/ValidationIndicator.d.ts +13 -0
- package/lib/layouts/VerticalLayout.d.ts +10 -0
- package/lib/layouts/arrayTitle.d.ts +2 -0
- package/lib/layouts/index.d.ts +11 -0
- package/lib/layouts/unwrapped.d.ts +11 -0
- package/lib/locale/index.d.ts +1 -0
- package/lib/util/additionalPropertyName.d.ts +2 -0
- package/lib/util/arrayChoices.d.ts +2 -0
- package/lib/util/categoryState.d.ts +3 -0
- package/lib/util/cellFrame.d.ts +27 -0
- package/lib/util/cellMode.d.ts +29 -0
- package/lib/util/clearAffordance.d.ts +1 -0
- package/lib/util/combinators.d.ts +1 -0
- package/lib/util/compositeActions.d.ts +1 -0
- package/lib/util/compositeSummary.d.ts +1 -0
- package/lib/util/configNamespaces.d.ts +1 -0
- package/lib/util/confirmation.d.ts +2 -0
- package/lib/util/datejs.d.ts +4 -0
- package/lib/util/debounce.d.ts +1 -0
- package/lib/util/dynamicProperties.d.ts +1 -0
- package/lib/util/focus.d.ts +1 -0
- package/lib/util/groupState.d.ts +1 -0
- package/lib/util/index.d.ts +25 -0
- package/lib/util/layout.d.ts +18 -0
- package/lib/util/layoutSizing.d.ts +6 -0
- package/lib/util/literalPropertySchema.d.ts +1 -0
- package/lib/util/locale.d.ts +68 -0
- package/lib/util/numeric.d.ts +1 -0
- package/lib/util/pendingChanges.d.ts +2 -0
- package/lib/util/preTouchErrors.d.ts +2 -0
- package/lib/util/rendererLocale.d.ts +2 -0
- package/lib/util/temporalBounds.d.ts +35 -0
- package/lib/util/temporalFormats.d.ts +26 -0
- package/lib/util/theme.d.ts +9 -0
- package/lib/util/translate.d.ts +1 -0
- package/lib/util/tuple.d.ts +2 -0
- package/lib/util/useConfirmation.d.ts +7 -0
- package/lib/util/validationIndicator.d.ts +2 -0
- package/lib/util/visuallyHidden.d.ts +1 -0
- package/package.json +89 -3
- package/src/additional/LabelRenderer.tsx +21 -0
- package/src/additional/ListWithDetailMasterItem.tsx +124 -0
- package/src/additional/ListWithDetailRenderer.tsx +243 -0
- package/src/additional/index.ts +14 -0
- package/src/additional/unwrapped.ts +8 -0
- package/src/antd-controls/AntdCheckbox.tsx +56 -0
- package/src/antd-controls/AntdClearValueButton.tsx +96 -0
- package/src/antd-controls/AntdClearableInput.tsx +63 -0
- package/src/antd-controls/AntdDatePicker.tsx +26 -0
- package/src/antd-controls/AntdDateTimePicker.tsx +31 -0
- package/src/antd-controls/AntdFile.tsx +395 -0
- package/src/antd-controls/AntdInputInteger.tsx +10 -0
- package/src/antd-controls/AntdInputNumber.tsx +10 -0
- package/src/antd-controls/AntdInputNumberFormat.tsx +63 -0
- package/src/antd-controls/AntdInputText.tsx +124 -0
- package/src/antd-controls/AntdNumericInput.tsx +83 -0
- package/src/antd-controls/AntdOtp.tsx +132 -0
- package/src/antd-controls/AntdPassword.tsx +106 -0
- package/src/antd-controls/AntdRadioGroup.tsx +60 -0
- package/src/antd-controls/AntdRevealButton.tsx +74 -0
- package/src/antd-controls/AntdSelect.tsx +113 -0
- package/src/antd-controls/AntdSlider.tsx +114 -0
- package/src/antd-controls/AntdTimePicker.tsx +25 -0
- package/src/antd-controls/AntdToggle.tsx +70 -0
- package/src/antd-controls/FileFeedback.tsx +37 -0
- package/src/antd-controls/index.ts +18 -0
- package/src/antd-controls/useTemporalPicker.ts +130 -0
- package/src/cells/AntdCompositeCell.tsx +228 -0
- package/src/cells/BooleanCell.tsx +33 -0
- package/src/cells/BooleanToggleCell.tsx +38 -0
- package/src/cells/CompositeDetailDialog.tsx +100 -0
- package/src/cells/CustomizableCells.ts +9 -0
- package/src/cells/DateCell.tsx +17 -0
- package/src/cells/EnumCell.tsx +30 -0
- package/src/cells/IntegerCell.tsx +17 -0
- package/src/cells/NumberCell.tsx +20 -0
- package/src/cells/NumberFormatCell.tsx +37 -0
- package/src/cells/OneOfEnumCell.tsx +32 -0
- package/src/cells/PasswordCell.tsx +22 -0
- package/src/cells/TextCell.tsx +22 -0
- package/src/cells/TimeCell.tsx +17 -0
- package/src/cells/index.ts +40 -0
- package/src/complex/AdditionalProperties.tsx +422 -0
- package/src/complex/AnyOfRenderer.tsx +158 -0
- package/src/complex/ArrayControlRenderer.tsx +121 -0
- package/src/complex/ChipsControl.tsx +205 -0
- package/src/complex/CollectionPager.tsx +26 -0
- package/src/complex/DataCell.tsx +82 -0
- package/src/complex/DeleteDialog.tsx +44 -0
- package/src/complex/DetailModal.tsx +110 -0
- package/src/complex/EnumArrayRenderer.tsx +148 -0
- package/src/complex/ErrorFeedback.tsx +51 -0
- package/src/complex/MixedRenderer.tsx +325 -0
- package/src/complex/MultiSelectControl.tsx +205 -0
- package/src/complex/ObjectRenderer.tsx +55 -0
- package/src/complex/OneOfRenderer.tsx +299 -0
- package/src/complex/OneOfTabRenderer.tsx +123 -0
- package/src/complex/RecursiveTreeRenderer.tsx +20 -0
- package/src/complex/RowDetailFrame.tsx +99 -0
- package/src/complex/ScalarCompositionRenderer.tsx +14 -0
- package/src/complex/TabSwitchConfirmDialog.tsx +36 -0
- package/src/complex/TableControl.tsx +646 -0
- package/src/complex/TableToolbar.tsx +80 -0
- package/src/complex/TupleAdditionalItems.tsx +100 -0
- package/src/complex/TupleControlRenderer.tsx +78 -0
- package/src/complex/TupleField.tsx +44 -0
- package/src/complex/ValidationIcon.tsx +30 -0
- package/src/complex/additionalProperties/AntdAdditionalPropertyActions.tsx +56 -0
- package/src/complex/additionalProperties/AntdAdditionalPropertyRenameDialog.tsx +56 -0
- package/src/complex/index.ts +48 -0
- package/src/complex/mixed/AntdJsonTypeIcon.tsx +40 -0
- package/src/complex/mixed/AntdMixedNavigationContext.ts +8 -0
- package/src/complex/mixed/AntdMixedSplitPane.tsx +51 -0
- package/src/complex/mixed/AntdMixedTree.tsx +287 -0
- package/src/complex/mixed/AntdMixedTypeSelector.tsx +60 -0
- package/src/complex/mixed/AntdNestedMixedNavigation.tsx +39 -0
- package/src/complex/mixed/mixedTree.ts +9 -0
- package/src/complex/unwrapped.ts +15 -0
- package/src/controls/AnyOfStringOrEnumControl.tsx +123 -0
- package/src/controls/BooleanControl.tsx +17 -0
- package/src/controls/BooleanToggleControl.tsx +24 -0
- package/src/controls/ChoiceCards.tsx +13 -0
- package/src/controls/DateControl.tsx +19 -0
- package/src/controls/DateTimeControl.tsx +22 -0
- package/src/controls/EnumControl.tsx +29 -0
- package/src/controls/FileControl.tsx +44 -0
- package/src/controls/InputControl.tsx +94 -0
- package/src/controls/IntegerControl.tsx +16 -0
- package/src/controls/NativeControl.tsx +79 -0
- package/src/controls/NumberControl.tsx +18 -0
- package/src/controls/OneOfEnumControl.tsx +32 -0
- package/src/controls/OneOfRadioGroupControl.tsx +25 -0
- package/src/controls/PasswordControl.tsx +43 -0
- package/src/controls/PasswordOtpControl.tsx +61 -0
- package/src/controls/RadioGroup.tsx +8 -0
- package/src/controls/RadioGroupControl.tsx +21 -0
- package/src/controls/SliderControl.tsx +19 -0
- package/src/controls/TextControl.tsx +17 -0
- package/src/controls/TimeControl.tsx +20 -0
- package/src/controls/index.ts +69 -0
- package/src/controls/unwrapped.ts +35 -0
- package/src/index.ts +267 -0
- package/src/layouts/ArrayLayout.tsx +435 -0
- package/src/layouts/ArrayLayoutRenderer.tsx +54 -0
- package/src/layouts/ArrayPanel.tsx +51 -0
- package/src/layouts/ArrayToolbar.tsx +67 -0
- package/src/layouts/CategorizationAccordionLayout.tsx +217 -0
- package/src/layouts/CategorizationLayout.tsx +149 -0
- package/src/layouts/CategorizationStepperLayout.tsx +164 -0
- package/src/layouts/CategoryHeader.tsx +107 -0
- package/src/layouts/ContainerIndicator.tsx +83 -0
- package/src/layouts/GroupLayout.tsx +307 -0
- package/src/layouts/HorizontalLayout.tsx +50 -0
- package/src/layouts/ValidationIndicator.tsx +43 -0
- package/src/layouts/VerticalLayout.tsx +50 -0
- package/src/layouts/arrayTitle.tsx +30 -0
- package/src/layouts/index.ts +35 -0
- package/src/layouts/unwrapped.ts +17 -0
- package/src/locale/index.ts +1 -0
- package/src/util/additionalPropertyName.ts +11 -0
- package/src/util/arrayChoices.ts +21 -0
- package/src/util/categoryState.ts +17 -0
- package/src/util/cellFrame.tsx +52 -0
- package/src/util/cellMode.tsx +145 -0
- package/src/util/clearAffordance.ts +2 -0
- package/src/util/combinators.ts +6 -0
- package/src/util/compositeActions.ts +2 -0
- package/src/util/compositeSummary.ts +2 -0
- package/src/util/configNamespaces.ts +4 -0
- package/src/util/confirmation.ts +15 -0
- package/src/util/datejs.tsx +42 -0
- package/src/util/debounce.ts +2 -0
- package/src/util/dynamicProperties.ts +6 -0
- package/src/util/focus.ts +2 -0
- package/src/util/groupState.ts +8 -0
- package/src/util/index.ts +25 -0
- package/src/util/layout.tsx +121 -0
- package/src/util/layoutSizing.ts +33 -0
- package/src/util/literalPropertySchema.ts +2 -0
- package/src/util/locale.ts +222 -0
- package/src/util/numeric.ts +2 -0
- package/src/util/pendingChanges.tsx +6 -0
- package/src/util/preTouchErrors.ts +10 -0
- package/src/util/rendererLocale.ts +10 -0
- package/src/util/temporalBounds.ts +106 -0
- package/src/util/temporalFormats.ts +95 -0
- package/src/util/theme.ts +9 -0
- package/src/util/translate.ts +6 -0
- package/src/util/tuple.ts +16 -0
- package/src/util/uiSchemaCycle.tsx +2 -0
- package/src/util/useConfirmation.tsx +25 -0
- package/src/util/validationIndicator.ts +10 -0
- package/src/util/visuallyHidden.ts +2 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
and,
|
|
5
|
+
ArrayLayoutProps,
|
|
6
|
+
ArrayTranslations,
|
|
7
|
+
isControl,
|
|
8
|
+
isObjectArrayWithNesting,
|
|
9
|
+
or,
|
|
10
|
+
RankedTester,
|
|
11
|
+
rankWith,
|
|
12
|
+
schemaMatches,
|
|
13
|
+
} from '@jsonforms/core';
|
|
14
|
+
import {
|
|
15
|
+
withArrayTranslationProps,
|
|
16
|
+
withJsonFormsArrayLayoutProps,
|
|
17
|
+
withTranslateProps,
|
|
18
|
+
} from '@jsonforms/react';
|
|
19
|
+
import { ArrayLayout } from './ArrayLayout';
|
|
20
|
+
|
|
21
|
+
export const ArrayLayoutRenderer = ({
|
|
22
|
+
visible,
|
|
23
|
+
addItem,
|
|
24
|
+
...props
|
|
25
|
+
}: ArrayLayoutProps & { translations: ArrayTranslations }) => {
|
|
26
|
+
const addItemCb = useCallback(
|
|
27
|
+
(p: string, value: any) => addItem(p, value),
|
|
28
|
+
[addItem],
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
if (!visible) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return <ArrayLayout visible={visible} addItem={addItemCb} {...props} />;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const arrayLayoutTester: RankedTester = rankWith(
|
|
39
|
+
4,
|
|
40
|
+
or(
|
|
41
|
+
isObjectArrayWithNesting,
|
|
42
|
+
and(
|
|
43
|
+
isControl,
|
|
44
|
+
schemaMatches(
|
|
45
|
+
(schema) =>
|
|
46
|
+
schema.type === 'array' &&
|
|
47
|
+
(schema as unknown as { items?: unknown }).items === true,
|
|
48
|
+
),
|
|
49
|
+
),
|
|
50
|
+
),
|
|
51
|
+
);
|
|
52
|
+
export default withJsonFormsArrayLayoutProps(
|
|
53
|
+
withTranslateProps(withArrayTranslationProps(ArrayLayoutRenderer)),
|
|
54
|
+
);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useI18n } from '@chobantonov/jsonforms-react-renderer-common/locale/translate';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Button, Card, CardProps } from 'antd';
|
|
4
|
+
import DownOutlined from '@ant-design/icons/DownOutlined';
|
|
5
|
+
import UpOutlined from '@ant-design/icons/UpOutlined';
|
|
6
|
+
import { useArrayPanelState } from '@chobantonov/jsonforms-react-renderer-common/collections/useArrayPanelState';
|
|
7
|
+
|
|
8
|
+
export const ArrayPanel = ({
|
|
9
|
+
options,
|
|
10
|
+
config,
|
|
11
|
+
panelLabel,
|
|
12
|
+
children,
|
|
13
|
+
extra,
|
|
14
|
+
...props
|
|
15
|
+
}: CardProps & {
|
|
16
|
+
options?: Record<string, any>;
|
|
17
|
+
config?: any;
|
|
18
|
+
panelLabel?: string;
|
|
19
|
+
}) => {
|
|
20
|
+
const t = useI18n();
|
|
21
|
+
const panel = useArrayPanelState(options, config);
|
|
22
|
+
return (
|
|
23
|
+
<Card
|
|
24
|
+
{...props}
|
|
25
|
+
style={{ minWidth: 0, maxWidth: '100%', ...props.style }}
|
|
26
|
+
extra={
|
|
27
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
|
|
28
|
+
{extra}
|
|
29
|
+
{panel.collapsible && (
|
|
30
|
+
<Button
|
|
31
|
+
shape='circle'
|
|
32
|
+
aria-label={panelLabel || t('control.array')}
|
|
33
|
+
aria-expanded={!panel.collapsed}
|
|
34
|
+
aria-controls={panel.contentId}
|
|
35
|
+
onClick={panel.toggle}
|
|
36
|
+
icon={panel.collapsed ? <DownOutlined /> : <UpOutlined />}
|
|
37
|
+
/>
|
|
38
|
+
)}
|
|
39
|
+
</div>
|
|
40
|
+
}
|
|
41
|
+
>
|
|
42
|
+
<div
|
|
43
|
+
id={panel.contentId}
|
|
44
|
+
hidden={panel.collapsed}
|
|
45
|
+
style={{ minWidth: 0, maxWidth: '100%' }}
|
|
46
|
+
>
|
|
47
|
+
{children}
|
|
48
|
+
</div>
|
|
49
|
+
</Card>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { usePathErrorIndicator } from '@chobantonov/jsonforms-react-renderer-common/validation/errorSummary';
|
|
2
|
+
import { ArrayPanel } from '../layouts/ArrayPanel';
|
|
3
|
+
import PlusOutlined from '@ant-design/icons/PlusOutlined';
|
|
4
|
+
import { ArrayTranslations } from '@jsonforms/core';
|
|
5
|
+
import { Button, Tooltip } from 'antd';
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { renderArrayTitle } from '../layouts/arrayTitle';
|
|
8
|
+
export interface ArrayLayoutToolbarProps {
|
|
9
|
+
options?: Record<string, any>;
|
|
10
|
+
config?: any;
|
|
11
|
+
label: string;
|
|
12
|
+
description: string | undefined;
|
|
13
|
+
errors: string;
|
|
14
|
+
path: string;
|
|
15
|
+
enabled: boolean;
|
|
16
|
+
addItem(path: string, data: any): () => void;
|
|
17
|
+
createDefault(): any;
|
|
18
|
+
translations: ArrayTranslations;
|
|
19
|
+
disableAdd?: boolean;
|
|
20
|
+
children?: React.ReactNode;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const ArrayLayoutToolbar = React.memo(function ArrayLayoutToolbar({
|
|
24
|
+
label,
|
|
25
|
+
description,
|
|
26
|
+
addItem,
|
|
27
|
+
path,
|
|
28
|
+
enabled,
|
|
29
|
+
createDefault,
|
|
30
|
+
translations,
|
|
31
|
+
disableAdd,
|
|
32
|
+
children,
|
|
33
|
+
options,
|
|
34
|
+
config,
|
|
35
|
+
}: ArrayLayoutToolbarProps) {
|
|
36
|
+
const arrayErrors = usePathErrorIndicator(
|
|
37
|
+
path,
|
|
38
|
+
options,
|
|
39
|
+
!(
|
|
40
|
+
options?.hideArraySummaryValidation ?? config?.hideArraySummaryValidation
|
|
41
|
+
),
|
|
42
|
+
);
|
|
43
|
+
return (
|
|
44
|
+
<ArrayPanel
|
|
45
|
+
options={options}
|
|
46
|
+
config={config}
|
|
47
|
+
panelLabel={label}
|
|
48
|
+
style={{ width: '100%' }}
|
|
49
|
+
size='small'
|
|
50
|
+
type='inner'
|
|
51
|
+
title={renderArrayTitle(label, arrayErrors, description)}
|
|
52
|
+
extra={[
|
|
53
|
+
<Tooltip key='1' title={translations.addTooltip}>
|
|
54
|
+
<Button
|
|
55
|
+
disabled={!enabled || disableAdd}
|
|
56
|
+
aria-label={translations.addTooltip}
|
|
57
|
+
onClick={addItem(path, createDefault())}
|
|
58
|
+
shape='circle'
|
|
59
|
+
icon={<PlusOutlined rev={undefined} />}
|
|
60
|
+
/>
|
|
61
|
+
</Tooltip>,
|
|
62
|
+
]}
|
|
63
|
+
>
|
|
64
|
+
{children}
|
|
65
|
+
</ArrayPanel>
|
|
66
|
+
);
|
|
67
|
+
});
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import React, { useEffect, useId, useMemo, useRef } from 'react';
|
|
2
|
+
import { Collapse } from 'antd';
|
|
3
|
+
import {
|
|
4
|
+
and,
|
|
5
|
+
Categorization,
|
|
6
|
+
categorizationHasCategory,
|
|
7
|
+
Category,
|
|
8
|
+
deriveLabelForUISchemaElement,
|
|
9
|
+
optionIs,
|
|
10
|
+
RankedTester,
|
|
11
|
+
rankWith,
|
|
12
|
+
StatePropsOfLayout,
|
|
13
|
+
uiTypeIs,
|
|
14
|
+
} from '@jsonforms/core';
|
|
15
|
+
import {
|
|
16
|
+
TranslateProps,
|
|
17
|
+
withJsonFormsLayoutProps,
|
|
18
|
+
withTranslateProps,
|
|
19
|
+
} from '@jsonforms/react';
|
|
20
|
+
import { CategoryIndicators } from './CategoryHeader';
|
|
21
|
+
import { categoryKey, useCategorySelection } from '../util/categoryState';
|
|
22
|
+
import {
|
|
23
|
+
AjvProps,
|
|
24
|
+
AntdLayoutRenderer,
|
|
25
|
+
AntdLayoutRendererProps,
|
|
26
|
+
withAjvProps,
|
|
27
|
+
} from '../util/layout';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Rank 3, above the stepper at 2 and the generic tabs renderer at 1, because
|
|
31
|
+
* the specification requires this explicit match to "take precedence over the
|
|
32
|
+
* generic Categorization renderer". Before this existed, `variant: "accordion"`
|
|
33
|
+
* fell through to tabs and the request was silently ignored.
|
|
34
|
+
*
|
|
35
|
+
* No schema type requirement, no scope, no array binding: categories are
|
|
36
|
+
* structural UI sections and may hold unbound content or be used with an empty
|
|
37
|
+
* data object.
|
|
38
|
+
*/
|
|
39
|
+
export const categorizationAccordionTester: RankedTester = rankWith(
|
|
40
|
+
3,
|
|
41
|
+
and(
|
|
42
|
+
uiTypeIs('Categorization'),
|
|
43
|
+
categorizationHasCategory,
|
|
44
|
+
optionIs('variant', 'accordion'),
|
|
45
|
+
),
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
export interface CategorizationAccordionLayoutRendererProps
|
|
49
|
+
extends StatePropsOfLayout, AjvProps, TranslateProps {
|
|
50
|
+
data?: unknown;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export const CategorizationAccordionLayoutRenderer = (
|
|
54
|
+
props: CategorizationAccordionLayoutRendererProps,
|
|
55
|
+
) => {
|
|
56
|
+
const {
|
|
57
|
+
data,
|
|
58
|
+
path,
|
|
59
|
+
renderers,
|
|
60
|
+
cells,
|
|
61
|
+
schema,
|
|
62
|
+
uischema,
|
|
63
|
+
visible,
|
|
64
|
+
enabled,
|
|
65
|
+
ajv,
|
|
66
|
+
config,
|
|
67
|
+
t,
|
|
68
|
+
} = props;
|
|
69
|
+
const categorization = uischema as Categorization;
|
|
70
|
+
const { categories, active, select, close } = useCategorySelection(
|
|
71
|
+
categorization,
|
|
72
|
+
data,
|
|
73
|
+
ajv,
|
|
74
|
+
config,
|
|
75
|
+
undefined,
|
|
76
|
+
// Closable: an accordion here may be closed entirely. This is the one
|
|
77
|
+
// place the project differs from section 8; see Adjustment 10.2.
|
|
78
|
+
true,
|
|
79
|
+
path,
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const labels = useMemo(
|
|
83
|
+
() =>
|
|
84
|
+
categories.map((category) => deriveLabelForUISchemaElement(category, t)),
|
|
85
|
+
[categories, t],
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
/*
|
|
89
|
+
The panel relationship section 8 asks for ("accessible accordion headings
|
|
90
|
+
and controls with expanded-state and panel relationships").
|
|
91
|
+
|
|
92
|
+
rc-collapse supplies `role="button"` and `aria-expanded` but never
|
|
93
|
+
`aria-controls`, and gives the panel no role or label at all, so a screen
|
|
94
|
+
reader is told a header can be expanded without being told what it expands.
|
|
95
|
+
There is no prop for it - extra item props land on the item wrapper, not on
|
|
96
|
+
the header - so the two are tied together here, after render. The selectors
|
|
97
|
+
are antd's stable panel structure, and `accordionAccessibility` in the tests
|
|
98
|
+
fails loudly if that changes.
|
|
99
|
+
*/
|
|
100
|
+
const rootRef = useRef<HTMLDivElement>(null);
|
|
101
|
+
const baseId = useId();
|
|
102
|
+
useEffect(() => {
|
|
103
|
+
const items = rootRef.current?.querySelectorAll<HTMLElement>(
|
|
104
|
+
':scope > .ant-collapse > .ant-collapse-item',
|
|
105
|
+
);
|
|
106
|
+
items?.forEach((item, index) => {
|
|
107
|
+
const header = item.querySelector<HTMLElement>(
|
|
108
|
+
':scope > .ant-collapse-header',
|
|
109
|
+
);
|
|
110
|
+
// `-panel` in antd 6, `-content` in 5. Accepting both means a version
|
|
111
|
+
// bump degrades to "no relationship" rather than to a crash, and the
|
|
112
|
+
// accessibility test says which one is actually in use.
|
|
113
|
+
const panel = item.querySelector<HTMLElement>(
|
|
114
|
+
':scope > .ant-collapse-panel, :scope > .ant-collapse-content',
|
|
115
|
+
);
|
|
116
|
+
if (!header || !panel) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const headerId = `${baseId}-header-${index}`;
|
|
120
|
+
const panelId = `${baseId}-panel-${index}`;
|
|
121
|
+
header.id = headerId;
|
|
122
|
+
header.setAttribute('aria-controls', panelId);
|
|
123
|
+
panel.id = panelId;
|
|
124
|
+
panel.setAttribute('role', 'region');
|
|
125
|
+
panel.setAttribute('aria-labelledby', headerId);
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
if (!visible) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const childProps = (category: Category): AntdLayoutRendererProps => ({
|
|
134
|
+
elements: category.elements,
|
|
135
|
+
schema,
|
|
136
|
+
path,
|
|
137
|
+
direction: 'column',
|
|
138
|
+
enabled,
|
|
139
|
+
visible,
|
|
140
|
+
renderers,
|
|
141
|
+
cells,
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
return (
|
|
145
|
+
<div ref={rootRef}>
|
|
146
|
+
<Collapse
|
|
147
|
+
/*
|
|
148
|
+
Deliberately *not* antd's `accordion` prop.
|
|
149
|
+
|
|
150
|
+
Its at-most-one-open behaviour is now what we want, but the prop also
|
|
151
|
+
switches the whole control to a tabs pattern - `role="tablist"` on the
|
|
152
|
+
root, `role="tab"` on each header, `role="tabpanel"` on each panel -
|
|
153
|
+
and then does not implement one: a `tab` reports `aria-expanded` where
|
|
154
|
+
the pattern calls for `aria-selected`, the panel gets no accessible
|
|
155
|
+
name, and only Enter is handled, with none of the arrow-key navigation
|
|
156
|
+
a `tablist` promises. A tablist also cannot express "no tab selected",
|
|
157
|
+
which is a legal state here. Without the prop the same component is a
|
|
158
|
+
disclosure - `role="button"` plus `aria-expanded` - which is what
|
|
159
|
+
rc-collapse actually implements and what an all-closed accordion needs.
|
|
160
|
+
|
|
161
|
+
Exclusivity is enforced here instead: `activeKey` never holds more than
|
|
162
|
+
one key.
|
|
163
|
+
*/
|
|
164
|
+
activeKey={active >= 0 ? [String(active)] : []}
|
|
165
|
+
onChange={(keys) => {
|
|
166
|
+
// Without `accordion`, opening a panel *adds* its key, so the newly
|
|
167
|
+
// opened one is whichever key was not already active. Clicking the
|
|
168
|
+
// open header removes its key and leaves none, which closes the
|
|
169
|
+
// accordion - see Adjustment 10.2.
|
|
170
|
+
const opened = (Array.isArray(keys) ? keys : [keys]).filter(
|
|
171
|
+
(key) => String(key) !== String(active),
|
|
172
|
+
);
|
|
173
|
+
if (opened.length > 0) {
|
|
174
|
+
select(Number(opened[0]));
|
|
175
|
+
} else {
|
|
176
|
+
close();
|
|
177
|
+
}
|
|
178
|
+
}}
|
|
179
|
+
items={categories.map((category, index) => ({
|
|
180
|
+
// Identity, not position, so a reorder keeps a panel's expansion and
|
|
181
|
+
// its content together rather than reusing the slot's DOM.
|
|
182
|
+
key: String(index),
|
|
183
|
+
'data-category-key': categoryKey(category, index),
|
|
184
|
+
label: labels[index],
|
|
185
|
+
/*
|
|
186
|
+
The indicators go in `extra` - the end of the header bar - not
|
|
187
|
+
after the label. An accordion header is the same shape as a
|
|
188
|
+
collapsible Group's, so putting its status somewhere else would
|
|
189
|
+
mean two collapsible sections in one form marking themselves
|
|
190
|
+
differently. A tab or a step has no trailing edge to use, which is
|
|
191
|
+
why those keep the markers beside the words; see `CategoryHeader`.
|
|
192
|
+
*/
|
|
193
|
+
extra: (
|
|
194
|
+
<CategoryIndicators
|
|
195
|
+
category={category}
|
|
196
|
+
path={path}
|
|
197
|
+
config={config}
|
|
198
|
+
/>
|
|
199
|
+
),
|
|
200
|
+
/*
|
|
201
|
+
Panels stay mounted. "Closing a category preserves its data and
|
|
202
|
+
validation" - and an unmounted subtree would take its controls'
|
|
203
|
+
pending debounced writes with it.
|
|
204
|
+
*/
|
|
205
|
+
forceRender: true,
|
|
206
|
+
children: <AntdLayoutRenderer {...childProps(category)} />,
|
|
207
|
+
}))}
|
|
208
|
+
/>
|
|
209
|
+
</div>
|
|
210
|
+
);
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
export default withAjvProps(
|
|
214
|
+
withTranslateProps(
|
|
215
|
+
withJsonFormsLayoutProps(CategorizationAccordionLayoutRenderer),
|
|
216
|
+
),
|
|
217
|
+
);
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
and,
|
|
4
|
+
Categorization,
|
|
5
|
+
Category,
|
|
6
|
+
RankedTester,
|
|
7
|
+
rankWith,
|
|
8
|
+
StatePropsOfLayout,
|
|
9
|
+
Tester,
|
|
10
|
+
UISchemaElement,
|
|
11
|
+
uiTypeIs,
|
|
12
|
+
} from '@jsonforms/core';
|
|
13
|
+
import {
|
|
14
|
+
TranslateProps,
|
|
15
|
+
withJsonFormsLayoutProps,
|
|
16
|
+
withTranslateProps,
|
|
17
|
+
} from '@jsonforms/react';
|
|
18
|
+
import { CategoryHeader } from './CategoryHeader';
|
|
19
|
+
import { useCategorySelection, useCategoryLabels } from '../util/categoryState';
|
|
20
|
+
import {
|
|
21
|
+
AjvProps,
|
|
22
|
+
AntdLayoutRenderer,
|
|
23
|
+
AntdLayoutRendererProps,
|
|
24
|
+
withAjvProps,
|
|
25
|
+
} from '../util/layout';
|
|
26
|
+
import { Tabs } from 'antd';
|
|
27
|
+
|
|
28
|
+
const isSingleLevelCategorization: Tester = and(
|
|
29
|
+
uiTypeIs('Categorization'),
|
|
30
|
+
(uischema: UISchemaElement): boolean => {
|
|
31
|
+
const categorization = uischema as Categorization;
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
categorization.elements &&
|
|
35
|
+
categorization.elements.reduce(
|
|
36
|
+
(acc, e) => acc && e.type === 'Category',
|
|
37
|
+
true,
|
|
38
|
+
)
|
|
39
|
+
);
|
|
40
|
+
},
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
export const categorizationTester: RankedTester = rankWith(
|
|
44
|
+
1,
|
|
45
|
+
isSingleLevelCategorization,
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
export interface CategorizationLayoutRendererProps
|
|
49
|
+
extends StatePropsOfLayout, AjvProps, TranslateProps {
|
|
50
|
+
selected?: number;
|
|
51
|
+
ownState?: boolean;
|
|
52
|
+
data?: any;
|
|
53
|
+
onChange?(selected: number, prevSelected: number): void;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export const CategorizationLayoutRenderer = (
|
|
57
|
+
props: CategorizationLayoutRendererProps,
|
|
58
|
+
) => {
|
|
59
|
+
const {
|
|
60
|
+
data,
|
|
61
|
+
path,
|
|
62
|
+
renderers,
|
|
63
|
+
cells,
|
|
64
|
+
schema,
|
|
65
|
+
uischema,
|
|
66
|
+
visible,
|
|
67
|
+
enabled,
|
|
68
|
+
selected,
|
|
69
|
+
onChange,
|
|
70
|
+
ajv,
|
|
71
|
+
config,
|
|
72
|
+
t,
|
|
73
|
+
} = props;
|
|
74
|
+
const categorization = uischema as Categorization;
|
|
75
|
+
// Visibility, `options.initial` and the "selected category became hidden"
|
|
76
|
+
// rule are the same for tabs, stepper and accordion, so section 8's
|
|
77
|
+
// navigation contract is implemented once and shared.
|
|
78
|
+
const { categories, active, select } = useCategorySelection(
|
|
79
|
+
categorization,
|
|
80
|
+
data,
|
|
81
|
+
ajv,
|
|
82
|
+
config,
|
|
83
|
+
selected,
|
|
84
|
+
false,
|
|
85
|
+
path,
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
/*
|
|
89
|
+
Per category, not per selection. antd keeps a tab panel mounted once it has
|
|
90
|
+
been visited, so a panel built from `categories[active]` goes on rendering
|
|
91
|
+
whatever is selected now - and the panels left behind end up duplicating
|
|
92
|
+
the selected category instead of holding their own.
|
|
93
|
+
*/
|
|
94
|
+
const childProps = (category: Category): AntdLayoutRendererProps => ({
|
|
95
|
+
elements: category.elements ?? [],
|
|
96
|
+
schema,
|
|
97
|
+
path,
|
|
98
|
+
direction: 'column',
|
|
99
|
+
enabled,
|
|
100
|
+
visible,
|
|
101
|
+
renderers,
|
|
102
|
+
cells,
|
|
103
|
+
});
|
|
104
|
+
const onTabChange = (value: string) => {
|
|
105
|
+
const category = parseInt(value);
|
|
106
|
+
|
|
107
|
+
if (onChange) {
|
|
108
|
+
onChange(category, active);
|
|
109
|
+
}
|
|
110
|
+
select(category);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const tabLabels = useCategoryLabels(categories, t);
|
|
114
|
+
|
|
115
|
+
if (!visible) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return (
|
|
120
|
+
<Tabs
|
|
121
|
+
/*
|
|
122
|
+
Controlled, not `defaultActiveKey`. An uncontrolled Tabs keeps its own
|
|
123
|
+
index, so when the selected category was hidden by a rule the tab strip
|
|
124
|
+
went on pointing at that slot and showed a different category's panel.
|
|
125
|
+
*/
|
|
126
|
+
activeKey={String(active)}
|
|
127
|
+
onChange={onTabChange}
|
|
128
|
+
items={categories.map(
|
|
129
|
+
(category: Category, idx: number) =>
|
|
130
|
+
({
|
|
131
|
+
label: (
|
|
132
|
+
<CategoryHeader
|
|
133
|
+
category={category}
|
|
134
|
+
label={tabLabels[idx]}
|
|
135
|
+
path={path}
|
|
136
|
+
config={config}
|
|
137
|
+
/>
|
|
138
|
+
),
|
|
139
|
+
key: String(idx),
|
|
140
|
+
children: <AntdLayoutRenderer {...childProps(category)} />,
|
|
141
|
+
}) as any,
|
|
142
|
+
)}
|
|
143
|
+
></Tabs>
|
|
144
|
+
);
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export default withAjvProps(
|
|
148
|
+
withTranslateProps(withJsonFormsLayoutProps(CategorizationLayoutRenderer)),
|
|
149
|
+
);
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import merge from 'lodash/merge';
|
|
3
|
+
import { Button, Steps } from 'antd';
|
|
4
|
+
import {
|
|
5
|
+
and,
|
|
6
|
+
Categorization,
|
|
7
|
+
categorizationHasCategory,
|
|
8
|
+
Category,
|
|
9
|
+
optionIs,
|
|
10
|
+
RankedTester,
|
|
11
|
+
rankWith,
|
|
12
|
+
StatePropsOfLayout,
|
|
13
|
+
uiTypeIs,
|
|
14
|
+
} from '@jsonforms/core';
|
|
15
|
+
import {
|
|
16
|
+
TranslateProps,
|
|
17
|
+
withJsonFormsLayoutProps,
|
|
18
|
+
withTranslateProps,
|
|
19
|
+
} from '@jsonforms/react';
|
|
20
|
+
import { CategoryHeader } from './CategoryHeader';
|
|
21
|
+
import { useCategorySelection, useCategoryLabels } from '../util/categoryState';
|
|
22
|
+
import { useI18n } from '../util/translate';
|
|
23
|
+
import {
|
|
24
|
+
AjvProps,
|
|
25
|
+
AntdLayoutRenderer,
|
|
26
|
+
AntdLayoutRendererProps,
|
|
27
|
+
withAjvProps,
|
|
28
|
+
} from '../util/layout';
|
|
29
|
+
|
|
30
|
+
export const categorizationStepperTester: RankedTester = rankWith(
|
|
31
|
+
2,
|
|
32
|
+
and(
|
|
33
|
+
uiTypeIs('Categorization'),
|
|
34
|
+
categorizationHasCategory,
|
|
35
|
+
optionIs('variant', 'stepper'),
|
|
36
|
+
),
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
interface CategorizationStepperLayoutRendererProps
|
|
40
|
+
extends StatePropsOfLayout, AjvProps, TranslateProps {
|
|
41
|
+
data: any;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const CategorizationStepperLayoutRenderer = (
|
|
45
|
+
props: CategorizationStepperLayoutRendererProps,
|
|
46
|
+
) => {
|
|
47
|
+
// The `t` from props is core's Translator, which returns undefined for a
|
|
48
|
+
// key with no fallback; useI18n always supplies the default.
|
|
49
|
+
const label = useI18n();
|
|
50
|
+
const {
|
|
51
|
+
data,
|
|
52
|
+
path,
|
|
53
|
+
renderers,
|
|
54
|
+
schema,
|
|
55
|
+
uischema,
|
|
56
|
+
visible,
|
|
57
|
+
cells,
|
|
58
|
+
config,
|
|
59
|
+
ajv,
|
|
60
|
+
t,
|
|
61
|
+
} = props;
|
|
62
|
+
const categorization = uischema as Categorization;
|
|
63
|
+
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
64
|
+
const buttonWrapperStyle = {
|
|
65
|
+
textAlign: 'right' as const,
|
|
66
|
+
width: '100%',
|
|
67
|
+
margin: '1em auto',
|
|
68
|
+
};
|
|
69
|
+
const buttonNextStyle = {
|
|
70
|
+
float: 'right' as const,
|
|
71
|
+
};
|
|
72
|
+
const buttonStyle = {
|
|
73
|
+
marginRight: '1em',
|
|
74
|
+
};
|
|
75
|
+
// Section 8's navigation contract, shared with the tabs and accordion
|
|
76
|
+
// presentations: visibility, `options.initial`, and what happens when the
|
|
77
|
+
// current category is hidden.
|
|
78
|
+
const {
|
|
79
|
+
categories,
|
|
80
|
+
active: activeCategory,
|
|
81
|
+
select,
|
|
82
|
+
} = useCategorySelection(
|
|
83
|
+
categorization,
|
|
84
|
+
data,
|
|
85
|
+
ajv,
|
|
86
|
+
config,
|
|
87
|
+
undefined,
|
|
88
|
+
false,
|
|
89
|
+
path,
|
|
90
|
+
);
|
|
91
|
+
const handleStep = (step: number) => {
|
|
92
|
+
// "Previous/Next actions operate on visible categories and stop at the
|
|
93
|
+
// first/last visible category."
|
|
94
|
+
select(Math.min(Math.max(step, 0), categories.length - 1));
|
|
95
|
+
};
|
|
96
|
+
const childProps: AntdLayoutRendererProps = {
|
|
97
|
+
// A Categorization whose categories are all hidden has "no active category
|
|
98
|
+
// or stale active panel"; indexing blindly here threw instead.
|
|
99
|
+
elements: categories[activeCategory]?.elements ?? [],
|
|
100
|
+
schema,
|
|
101
|
+
path,
|
|
102
|
+
direction: 'column',
|
|
103
|
+
visible,
|
|
104
|
+
renderers,
|
|
105
|
+
cells,
|
|
106
|
+
};
|
|
107
|
+
const tabLabels = useCategoryLabels(categories, t);
|
|
108
|
+
|
|
109
|
+
if (!visible) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<>
|
|
115
|
+
<Steps
|
|
116
|
+
current={activeCategory < 0 ? 0 : activeCategory}
|
|
117
|
+
items={categories.map((category: Category, idx: number) => ({
|
|
118
|
+
key: tabLabels[idx],
|
|
119
|
+
title: (
|
|
120
|
+
<CategoryHeader
|
|
121
|
+
category={category}
|
|
122
|
+
label={tabLabels[idx]}
|
|
123
|
+
path={path}
|
|
124
|
+
config={config}
|
|
125
|
+
/>
|
|
126
|
+
),
|
|
127
|
+
}))}
|
|
128
|
+
onChange={handleStep}
|
|
129
|
+
style={{ marginBottom: '10px' }}
|
|
130
|
+
/>
|
|
131
|
+
<div>
|
|
132
|
+
<AntdLayoutRenderer {...childProps} />
|
|
133
|
+
</div>
|
|
134
|
+
{appliedUiSchemaOptions.showNavButtons ? (
|
|
135
|
+
<div style={buttonWrapperStyle}>
|
|
136
|
+
<Button
|
|
137
|
+
style={buttonNextStyle}
|
|
138
|
+
color='primary'
|
|
139
|
+
disabled={activeCategory >= categories.length - 1}
|
|
140
|
+
onClick={() => handleStep(activeCategory + 1)}
|
|
141
|
+
>
|
|
142
|
+
{label('categorization.next')}
|
|
143
|
+
</Button>
|
|
144
|
+
<Button
|
|
145
|
+
style={buttonStyle}
|
|
146
|
+
color='default'
|
|
147
|
+
disabled={activeCategory <= 0}
|
|
148
|
+
onClick={() => handleStep(activeCategory - 1)}
|
|
149
|
+
>
|
|
150
|
+
{label('categorization.previous')}
|
|
151
|
+
</Button>
|
|
152
|
+
</div>
|
|
153
|
+
) : (
|
|
154
|
+
<></>
|
|
155
|
+
)}
|
|
156
|
+
</>
|
|
157
|
+
);
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
export default withAjvProps(
|
|
161
|
+
withTranslateProps(
|
|
162
|
+
withJsonFormsLayoutProps(CategorizationStepperLayoutRenderer),
|
|
163
|
+
),
|
|
164
|
+
);
|