@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
package/src/index.ts
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
import {
|
|
2
|
+
dynamicRendererEntry,
|
|
3
|
+
dynamicCellEntry,
|
|
4
|
+
} from '@chobantonov/jsonforms-react-renderer-common/dynamic/DynamicUiProvider';
|
|
5
|
+
import {
|
|
6
|
+
RecursiveTreeRenderer,
|
|
7
|
+
recursiveTreeTester,
|
|
8
|
+
} from './complex/RecursiveTreeRenderer';
|
|
9
|
+
import { ChoiceCards } from './controls/ChoiceCards';
|
|
10
|
+
import { choiceCardsTester } from '@chobantonov/jsonforms-react-renderer-common/composition/choiceCards';
|
|
11
|
+
import { withJsonFormsCellProps, withTranslateProps } from '@jsonforms/react';
|
|
12
|
+
import { AntdFile } from './antd-controls/AntdFile';
|
|
13
|
+
import AntdCompositeCell, {
|
|
14
|
+
antdCompositeCellTester,
|
|
15
|
+
} from './cells/AntdCompositeCell';
|
|
16
|
+
import { MixedRenderer, mixedControlTester } from './complex/MixedRenderer';
|
|
17
|
+
import ChipsControl, { chipsControlTester } from './complex/ChipsControl';
|
|
18
|
+
import MultiSelectControl, {
|
|
19
|
+
multiSelectControlTester,
|
|
20
|
+
} from './complex/MultiSelectControl';
|
|
21
|
+
import {
|
|
22
|
+
TupleControlRenderer,
|
|
23
|
+
tupleControlRendererTester,
|
|
24
|
+
} from './complex/TupleControlRenderer';
|
|
25
|
+
import {
|
|
26
|
+
JsonFormsCellRendererRegistryEntry,
|
|
27
|
+
JsonFormsRendererRegistryEntry,
|
|
28
|
+
} from '@jsonforms/core';
|
|
29
|
+
import {
|
|
30
|
+
allOfControlTester,
|
|
31
|
+
AllOfRenderer,
|
|
32
|
+
anyOfControlTester,
|
|
33
|
+
AnyOfRenderer,
|
|
34
|
+
ArrayControlRenderer,
|
|
35
|
+
arrayControlTester,
|
|
36
|
+
objectControlTester,
|
|
37
|
+
ObjectRenderer,
|
|
38
|
+
oneOfControlTester,
|
|
39
|
+
OneOfRenderer,
|
|
40
|
+
scalarCompositionTester,
|
|
41
|
+
ScalarCompositionRenderer,
|
|
42
|
+
EnumArrayRenderer,
|
|
43
|
+
enumArrayRendererTester,
|
|
44
|
+
} from './complex';
|
|
45
|
+
import {
|
|
46
|
+
LabelRenderer,
|
|
47
|
+
labelRendererTester,
|
|
48
|
+
ListWithDetailRenderer,
|
|
49
|
+
listWithDetailTester,
|
|
50
|
+
} from './additional';
|
|
51
|
+
import {
|
|
52
|
+
AnyOfStringOrEnumControl,
|
|
53
|
+
anyOfStringOrEnumControlTester,
|
|
54
|
+
BooleanControl,
|
|
55
|
+
booleanControlTester,
|
|
56
|
+
BooleanToggleControl,
|
|
57
|
+
booleanToggleControlTester,
|
|
58
|
+
DateControl,
|
|
59
|
+
dateControlTester,
|
|
60
|
+
DateTimeControl,
|
|
61
|
+
dateTimeControlTester,
|
|
62
|
+
TimeControl,
|
|
63
|
+
timeControlTester,
|
|
64
|
+
EnumControl,
|
|
65
|
+
enumControlTester,
|
|
66
|
+
IntegerControl,
|
|
67
|
+
integerControlTester,
|
|
68
|
+
NativeControl,
|
|
69
|
+
nativeControlTester,
|
|
70
|
+
NumberControl,
|
|
71
|
+
numberControlTester,
|
|
72
|
+
OneOfEnumControl,
|
|
73
|
+
oneOfEnumControlTester,
|
|
74
|
+
PasswordControl,
|
|
75
|
+
passwordControlTester,
|
|
76
|
+
PasswordOtpControl,
|
|
77
|
+
passwordOtpControlTester,
|
|
78
|
+
RadioGroupControl,
|
|
79
|
+
radioGroupControlTester,
|
|
80
|
+
SliderControl,
|
|
81
|
+
sliderControlTester,
|
|
82
|
+
TextControl,
|
|
83
|
+
textControlTester,
|
|
84
|
+
OneOfRadioGroupControl,
|
|
85
|
+
oneOfRadioGroupControlTester,
|
|
86
|
+
FileControl,
|
|
87
|
+
fileControlTester,
|
|
88
|
+
} from './controls';
|
|
89
|
+
import {
|
|
90
|
+
ArrayLayout,
|
|
91
|
+
arrayLayoutTester,
|
|
92
|
+
CategorizationLayout,
|
|
93
|
+
categorizationTester,
|
|
94
|
+
GroupLayout,
|
|
95
|
+
antdGroupTester,
|
|
96
|
+
HorizontalLayout,
|
|
97
|
+
horizontalLayoutTester,
|
|
98
|
+
VerticalLayout,
|
|
99
|
+
verticalLayoutTester,
|
|
100
|
+
} from './layouts';
|
|
101
|
+
import {
|
|
102
|
+
BooleanCell,
|
|
103
|
+
booleanCellTester,
|
|
104
|
+
BooleanToggleCell,
|
|
105
|
+
booleanToggleCellTester,
|
|
106
|
+
DateCell,
|
|
107
|
+
dateCellTester,
|
|
108
|
+
EnumCell,
|
|
109
|
+
enumCellTester,
|
|
110
|
+
IntegerCell,
|
|
111
|
+
integerCellTester,
|
|
112
|
+
NumberCell,
|
|
113
|
+
numberCellTester,
|
|
114
|
+
NumberFormatCell,
|
|
115
|
+
numberFormatCellTester,
|
|
116
|
+
OneOfEnumCell,
|
|
117
|
+
oneOfEnumCellTester,
|
|
118
|
+
PasswordCell,
|
|
119
|
+
passwordCellTester,
|
|
120
|
+
TextCell,
|
|
121
|
+
textCellTester,
|
|
122
|
+
TimeCell,
|
|
123
|
+
timeCellTester,
|
|
124
|
+
} from './cells';
|
|
125
|
+
import CategorizationStepperLayout, {
|
|
126
|
+
categorizationStepperTester,
|
|
127
|
+
} from './layouts/CategorizationStepperLayout';
|
|
128
|
+
import CategorizationAccordionLayout, {
|
|
129
|
+
categorizationAccordionTester,
|
|
130
|
+
} from './layouts/CategorizationAccordionLayout';
|
|
131
|
+
|
|
132
|
+
export * from './additional';
|
|
133
|
+
export * from './cells';
|
|
134
|
+
export * from './complex';
|
|
135
|
+
export * from './controls';
|
|
136
|
+
export * from './layouts';
|
|
137
|
+
export * from './util';
|
|
138
|
+
export * from './locale';
|
|
139
|
+
|
|
140
|
+
export const antdRenderers: JsonFormsRendererRegistryEntry[] = [
|
|
141
|
+
dynamicRendererEntry,
|
|
142
|
+
{ tester: recursiveTreeTester, renderer: RecursiveTreeRenderer },
|
|
143
|
+
{ tester: choiceCardsTester, renderer: ChoiceCards },
|
|
144
|
+
// controls
|
|
145
|
+
{ tester: mixedControlTester, renderer: MixedRenderer },
|
|
146
|
+
{ tester: multiSelectControlTester, renderer: MultiSelectControl },
|
|
147
|
+
{ tester: chipsControlTester, renderer: ChipsControl },
|
|
148
|
+
{ tester: tupleControlRendererTester, renderer: TupleControlRenderer },
|
|
149
|
+
{
|
|
150
|
+
tester: arrayControlTester,
|
|
151
|
+
renderer: ArrayControlRenderer,
|
|
152
|
+
},
|
|
153
|
+
{ tester: booleanControlTester, renderer: BooleanControl },
|
|
154
|
+
{
|
|
155
|
+
tester: booleanToggleControlTester,
|
|
156
|
+
renderer: BooleanToggleControl,
|
|
157
|
+
},
|
|
158
|
+
{ tester: nativeControlTester, renderer: NativeControl },
|
|
159
|
+
{ tester: enumControlTester, renderer: EnumControl },
|
|
160
|
+
{ tester: integerControlTester, renderer: IntegerControl },
|
|
161
|
+
{ tester: numberControlTester, renderer: NumberControl },
|
|
162
|
+
{ tester: textControlTester, renderer: TextControl },
|
|
163
|
+
{ tester: passwordControlTester, renderer: PasswordControl },
|
|
164
|
+
{ tester: passwordOtpControlTester, renderer: PasswordOtpControl },
|
|
165
|
+
{ tester: dateTimeControlTester, renderer: DateTimeControl },
|
|
166
|
+
{ tester: dateControlTester, renderer: DateControl },
|
|
167
|
+
{ tester: timeControlTester, renderer: TimeControl },
|
|
168
|
+
{ tester: sliderControlTester, renderer: SliderControl },
|
|
169
|
+
{ tester: objectControlTester, renderer: ObjectRenderer },
|
|
170
|
+
/*
|
|
171
|
+
Above the three combinator renderers: a composition that describes one
|
|
172
|
+
scalar editor gets one input rather than a branch selector. Below the
|
|
173
|
+
finite-choice renderers at rank 5, which keep their own conventions.
|
|
174
|
+
*/
|
|
175
|
+
{
|
|
176
|
+
tester: scalarCompositionTester,
|
|
177
|
+
renderer: ScalarCompositionRenderer,
|
|
178
|
+
},
|
|
179
|
+
{ tester: allOfControlTester, renderer: AllOfRenderer },
|
|
180
|
+
{ tester: anyOfControlTester, renderer: AnyOfRenderer },
|
|
181
|
+
{ tester: oneOfControlTester, renderer: OneOfRenderer },
|
|
182
|
+
{ tester: fileControlTester, renderer: FileControl },
|
|
183
|
+
{
|
|
184
|
+
tester: radioGroupControlTester,
|
|
185
|
+
renderer: RadioGroupControl,
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
tester: oneOfRadioGroupControlTester,
|
|
189
|
+
renderer: OneOfRadioGroupControl,
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
tester: oneOfEnumControlTester,
|
|
193
|
+
renderer: OneOfEnumControl,
|
|
194
|
+
},
|
|
195
|
+
// layouts
|
|
196
|
+
{ tester: antdGroupTester, renderer: GroupLayout },
|
|
197
|
+
{
|
|
198
|
+
tester: horizontalLayoutTester,
|
|
199
|
+
renderer: HorizontalLayout,
|
|
200
|
+
},
|
|
201
|
+
{ tester: verticalLayoutTester, renderer: VerticalLayout },
|
|
202
|
+
{
|
|
203
|
+
tester: categorizationTester,
|
|
204
|
+
renderer: CategorizationLayout,
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
tester: categorizationStepperTester,
|
|
208
|
+
renderer: CategorizationStepperLayout,
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
tester: categorizationAccordionTester,
|
|
212
|
+
renderer: CategorizationAccordionLayout,
|
|
213
|
+
},
|
|
214
|
+
{ tester: arrayLayoutTester, renderer: ArrayLayout },
|
|
215
|
+
// additional
|
|
216
|
+
{ tester: labelRendererTester, renderer: LabelRenderer },
|
|
217
|
+
{
|
|
218
|
+
tester: listWithDetailTester,
|
|
219
|
+
renderer: ListWithDetailRenderer,
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
tester: anyOfStringOrEnumControlTester,
|
|
223
|
+
renderer: AnyOfStringOrEnumControl,
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
tester: enumArrayRendererTester,
|
|
227
|
+
renderer: EnumArrayRenderer,
|
|
228
|
+
},
|
|
229
|
+
];
|
|
230
|
+
|
|
231
|
+
export const antdCells: JsonFormsCellRendererRegistryEntry[] = [
|
|
232
|
+
dynamicCellEntry,
|
|
233
|
+
// Rank 1 fallback: objects and arrays that no specialised cell handles get a
|
|
234
|
+
// summary plus a detail dialog instead of rendering nothing.
|
|
235
|
+
{
|
|
236
|
+
tester: fileControlTester,
|
|
237
|
+
cell: withJsonFormsCellProps(withTranslateProps(AntdFile)),
|
|
238
|
+
},
|
|
239
|
+
{ tester: antdCompositeCellTester, cell: AntdCompositeCell },
|
|
240
|
+
{ tester: booleanCellTester, cell: BooleanCell },
|
|
241
|
+
{ tester: booleanToggleCellTester, cell: BooleanToggleCell },
|
|
242
|
+
{ tester: dateCellTester, cell: DateCell },
|
|
243
|
+
{ tester: enumCellTester, cell: EnumCell },
|
|
244
|
+
{ tester: integerCellTester, cell: IntegerCell },
|
|
245
|
+
{ tester: numberCellTester, cell: NumberCell },
|
|
246
|
+
{ tester: numberFormatCellTester, cell: NumberFormatCell },
|
|
247
|
+
{ tester: oneOfEnumCellTester, cell: OneOfEnumCell },
|
|
248
|
+
{ tester: textCellTester, cell: TextCell },
|
|
249
|
+
{ tester: passwordCellTester, cell: PasswordCell },
|
|
250
|
+
{ tester: timeCellTester, cell: TimeCell },
|
|
251
|
+
];
|
|
252
|
+
|
|
253
|
+
import { UnwrappedAdditional } from './additional/unwrapped';
|
|
254
|
+
import { UnwrappedComplex } from './complex/unwrapped';
|
|
255
|
+
import { UnwrappedControls } from './controls/unwrapped';
|
|
256
|
+
import { UnwrappedLayouts } from './layouts/unwrapped';
|
|
257
|
+
|
|
258
|
+
export const Unwrapped = {
|
|
259
|
+
...UnwrappedAdditional,
|
|
260
|
+
...UnwrappedComplex,
|
|
261
|
+
...UnwrappedControls,
|
|
262
|
+
...UnwrappedLayouts,
|
|
263
|
+
};
|
|
264
|
+
|
|
265
|
+
export * from './antd-controls';
|
|
266
|
+
|
|
267
|
+
export { RowDetailFrame } from './complex/RowDetailFrame';
|
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
import { findDetailUISchema as findUISchema } from '@chobantonov/jsonforms-react-renderer-common/core/detailUiSchema';
|
|
2
|
+
import { ItemValidationIndicator } from '@chobantonov/jsonforms-react-renderer-common/validation/ItemValidationIndicator';
|
|
3
|
+
import { ContainerValidationIndicator } from './ValidationIndicator';
|
|
4
|
+
import { resolveCollapsed } from '@chobantonov/jsonforms-react-renderer-common/layout/groupState';
|
|
5
|
+
import ArrowDownOutlined from '@ant-design/icons/ArrowDownOutlined';
|
|
6
|
+
import ArrowUpOutlined from '@ant-design/icons/ArrowUpOutlined';
|
|
7
|
+
import DeleteFilled from '@ant-design/icons/DeleteFilled';
|
|
8
|
+
import {
|
|
9
|
+
ArrayLayoutProps,
|
|
10
|
+
ArrayTranslations,
|
|
11
|
+
Resolve,
|
|
12
|
+
composePaths,
|
|
13
|
+
computeLabel,
|
|
14
|
+
createControlElement,
|
|
15
|
+
createDefaultValue,
|
|
16
|
+
errorsAt,
|
|
17
|
+
formatErrorMessage,
|
|
18
|
+
getFirstPrimitiveProp,
|
|
19
|
+
} from '@jsonforms/core';
|
|
20
|
+
import {
|
|
21
|
+
JsonFormsDispatch,
|
|
22
|
+
JsonFormsStateContext,
|
|
23
|
+
useJsonForms,
|
|
24
|
+
} from '@jsonforms/react';
|
|
25
|
+
import {
|
|
26
|
+
Avatar,
|
|
27
|
+
Button,
|
|
28
|
+
Collapse,
|
|
29
|
+
Empty,
|
|
30
|
+
Space,
|
|
31
|
+
Tooltip,
|
|
32
|
+
Typography,
|
|
33
|
+
} from 'antd';
|
|
34
|
+
import map from 'lodash/map';
|
|
35
|
+
import merge from 'lodash/merge';
|
|
36
|
+
import range from 'lodash/range';
|
|
37
|
+
import React, { useCallback, useMemo, useState } from 'react';
|
|
38
|
+
import { useI18n } from '../util/translate';
|
|
39
|
+
import { useConfirmation } from '../util/useConfirmation';
|
|
40
|
+
import { ArrayLayoutToolbar } from './ArrayToolbar';
|
|
41
|
+
|
|
42
|
+
/*
|
|
43
|
+
`hideAvatar` hides the *marker*, not the item's identity - "without
|
|
44
|
+
suppressing accessible item identity or validation feedback". So the index
|
|
45
|
+
stays in the accessibility tree when the badge goes; `clip` rather than
|
|
46
|
+
`display: none`, which would take it out of that tree too.
|
|
47
|
+
*/
|
|
48
|
+
const SR_ONLY: React.CSSProperties = {
|
|
49
|
+
position: 'absolute',
|
|
50
|
+
width: 1,
|
|
51
|
+
height: 1,
|
|
52
|
+
overflow: 'hidden',
|
|
53
|
+
clip: 'rect(0 0 0 0)',
|
|
54
|
+
whiteSpace: 'nowrap',
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
interface ExtraProps {
|
|
58
|
+
rowIndex: number;
|
|
59
|
+
enableUp: boolean;
|
|
60
|
+
enableDown: boolean;
|
|
61
|
+
showSortButtons: boolean;
|
|
62
|
+
disableRemove?: boolean;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const ArrayLayoutComponent = (
|
|
66
|
+
props: { ctx: JsonFormsStateContext } & ArrayLayoutProps & {
|
|
67
|
+
translations: ArrayTranslations;
|
|
68
|
+
},
|
|
69
|
+
) => {
|
|
70
|
+
/*
|
|
71
|
+
The expanded item is tracked by **index**, not by panel key, because the
|
|
72
|
+
index is what every other operation here speaks: add appends at `data`,
|
|
73
|
+
the sort buttons swap neighbours, and delete shifts everything after it
|
|
74
|
+
down. Keeping a key would mean re-deriving the index on each of those.
|
|
75
|
+
|
|
76
|
+
This used to be `useState<string | boolean>(false)` with a curried
|
|
77
|
+
`handleChange(panel)(event, expanded)` that the `Collapse` called as
|
|
78
|
+
`handleChange(value)` - producing the inner function and discarding it. So
|
|
79
|
+
`setExpanded` never ran, the state was permanently `false`, and the
|
|
80
|
+
`Collapse` was left uncontrolled. `collapsed` and `collapseNewItems`
|
|
81
|
+
could not be implemented on top of that, and the only visible symptom was
|
|
82
|
+
an avatar highlight that never appeared.
|
|
83
|
+
*/
|
|
84
|
+
const [expandedIndex, setExpandedIndex] = useState<number | undefined>(() => {
|
|
85
|
+
// "False: initially open the first item if present." Initialization only.
|
|
86
|
+
const collapsed = resolveCollapsed(
|
|
87
|
+
props.uischema.options,
|
|
88
|
+
props.config,
|
|
89
|
+
'array',
|
|
90
|
+
);
|
|
91
|
+
return collapsed || props.data === 0 ? undefined : 0;
|
|
92
|
+
});
|
|
93
|
+
const innerCreateDefaultValue = useCallback(
|
|
94
|
+
() => createDefaultValue(props.schema, props.rootSchema),
|
|
95
|
+
[props.schema, props.rootSchema],
|
|
96
|
+
);
|
|
97
|
+
const {
|
|
98
|
+
arraySchema,
|
|
99
|
+
enabled,
|
|
100
|
+
data,
|
|
101
|
+
path,
|
|
102
|
+
schema,
|
|
103
|
+
uischema,
|
|
104
|
+
errors,
|
|
105
|
+
addItem,
|
|
106
|
+
renderers,
|
|
107
|
+
cells,
|
|
108
|
+
label,
|
|
109
|
+
required,
|
|
110
|
+
rootSchema,
|
|
111
|
+
config,
|
|
112
|
+
uischemas,
|
|
113
|
+
description,
|
|
114
|
+
disableAdd,
|
|
115
|
+
disableRemove,
|
|
116
|
+
translations,
|
|
117
|
+
moveUp,
|
|
118
|
+
moveDown,
|
|
119
|
+
removeItems,
|
|
120
|
+
} = props;
|
|
121
|
+
|
|
122
|
+
const t = useI18n();
|
|
123
|
+
const confirmation = useConfirmation();
|
|
124
|
+
const appliedUiSchemaOptions = useMemo(
|
|
125
|
+
() => merge({}, config, uischema.options),
|
|
126
|
+
[config, uischema.options],
|
|
127
|
+
);
|
|
128
|
+
const showSortButtons = appliedUiSchemaOptions.showSortButtons;
|
|
129
|
+
|
|
130
|
+
const hideAvatar = appliedUiSchemaOptions.hideAvatar === true;
|
|
131
|
+
const avatarStyle = useMemo(
|
|
132
|
+
(): React.CSSProperties => ({ marginRight: '10px' }),
|
|
133
|
+
[],
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
/*
|
|
137
|
+
"True: hide that summary only; retain validation and field/item error
|
|
138
|
+
feedback." The `errors` prop is the array's own errors followed by a
|
|
139
|
+
combined child summary, so hiding the summary means showing only the
|
|
140
|
+
array's own - not showing nothing.
|
|
141
|
+
*/
|
|
142
|
+
const ownErrors = useMemo(
|
|
143
|
+
() =>
|
|
144
|
+
formatErrorMessage(
|
|
145
|
+
errorsAt(
|
|
146
|
+
path,
|
|
147
|
+
schema,
|
|
148
|
+
(errorPath: string) => errorPath === path,
|
|
149
|
+
)(props.ctx.core?.errors ?? []).flatMap((error) => error.message ?? []),
|
|
150
|
+
),
|
|
151
|
+
[path, schema, props.ctx.core],
|
|
152
|
+
);
|
|
153
|
+
const summaryErrors = appliedUiSchemaOptions.hideArraySummaryValidation
|
|
154
|
+
? ownErrors
|
|
155
|
+
: errors;
|
|
156
|
+
|
|
157
|
+
/*
|
|
158
|
+
Expansion follows the *item*, not the slot. Reordering swaps two
|
|
159
|
+
neighbours, so the open panel has to move with the item the user opened -
|
|
160
|
+
"track the logical item through renderer-owned reorder operations rather
|
|
161
|
+
than transferring expansion to the item now at its old index".
|
|
162
|
+
*/
|
|
163
|
+
const trackSwap = useCallback((from: number, to: number) => {
|
|
164
|
+
setExpandedIndex((current) =>
|
|
165
|
+
current === from ? to : current === to ? from : current,
|
|
166
|
+
);
|
|
167
|
+
}, []);
|
|
168
|
+
// Deletion shifts every later item down one; the open panel must not end up
|
|
169
|
+
// on a different item, and must close if it was the one removed.
|
|
170
|
+
const trackRemoval = useCallback((removed: number) => {
|
|
171
|
+
setExpandedIndex((current) =>
|
|
172
|
+
current === undefined || current < removed
|
|
173
|
+
? current
|
|
174
|
+
: current === removed
|
|
175
|
+
? undefined
|
|
176
|
+
: current - 1,
|
|
177
|
+
);
|
|
178
|
+
}, []);
|
|
179
|
+
const handleAddItem = useCallback(
|
|
180
|
+
(p: string, value: any) => () => {
|
|
181
|
+
// Add appends, so the new item's index is the old count.
|
|
182
|
+
const inserted = data;
|
|
183
|
+
addItem(p, value)();
|
|
184
|
+
// "False: open the newly added item. True: leave it closed and preserve
|
|
185
|
+
// existing expansion."
|
|
186
|
+
if (!appliedUiSchemaOptions.collapseNewItems) {
|
|
187
|
+
setExpandedIndex(inserted);
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
[addItem, data, appliedUiSchemaOptions.collapseNewItems],
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
const getExtra = ({
|
|
194
|
+
rowIndex,
|
|
195
|
+
enableUp,
|
|
196
|
+
enableDown,
|
|
197
|
+
showSortButtons,
|
|
198
|
+
disableRemove,
|
|
199
|
+
}: ExtraProps) => {
|
|
200
|
+
return (
|
|
201
|
+
<>
|
|
202
|
+
{showSortButtons ? (
|
|
203
|
+
<>
|
|
204
|
+
<Tooltip title={translations.up}>
|
|
205
|
+
<Button
|
|
206
|
+
shape='circle'
|
|
207
|
+
aria-label={translations.upAriaLabel}
|
|
208
|
+
icon={<ArrowUpOutlined rev={undefined} />}
|
|
209
|
+
onClick={(event) => {
|
|
210
|
+
event.stopPropagation();
|
|
211
|
+
trackSwap(rowIndex, rowIndex - 1);
|
|
212
|
+
moveUp?.(path, rowIndex)();
|
|
213
|
+
}}
|
|
214
|
+
disabled={!enabled || !enableUp || !moveUp}
|
|
215
|
+
/>
|
|
216
|
+
</Tooltip>
|
|
217
|
+
<Tooltip title={translations.down}>
|
|
218
|
+
<Button
|
|
219
|
+
shape='circle'
|
|
220
|
+
aria-label={translations.downAriaLabel}
|
|
221
|
+
icon={<ArrowDownOutlined rev={undefined} />}
|
|
222
|
+
onClick={(event) => {
|
|
223
|
+
event.stopPropagation();
|
|
224
|
+
trackSwap(rowIndex, rowIndex + 1);
|
|
225
|
+
moveDown?.(path, rowIndex)();
|
|
226
|
+
}}
|
|
227
|
+
disabled={!enabled || !enableDown || !moveDown}
|
|
228
|
+
/>
|
|
229
|
+
</Tooltip>
|
|
230
|
+
</>
|
|
231
|
+
) : null}
|
|
232
|
+
<Tooltip key='tooltip-remove' title={translations.removeTooltip}>
|
|
233
|
+
<Button
|
|
234
|
+
onClick={(event) => {
|
|
235
|
+
event.stopPropagation();
|
|
236
|
+
// Section 14's `always` fallback: this used to delete silently.
|
|
237
|
+
confirmation.request({
|
|
238
|
+
operation: 'delete',
|
|
239
|
+
catalogId: 'arrayLayout',
|
|
240
|
+
/*
|
|
241
|
+
`data` here is the item *count*, not the array, so the value
|
|
242
|
+
being discarded is read from the form's own data at the
|
|
243
|
+
item's path.
|
|
244
|
+
*/
|
|
245
|
+
discarded: [
|
|
246
|
+
Resolve.data(
|
|
247
|
+
props.ctx.core?.data,
|
|
248
|
+
composePaths(path, `${rowIndex}`),
|
|
249
|
+
),
|
|
250
|
+
],
|
|
251
|
+
options: uischema?.options,
|
|
252
|
+
config,
|
|
253
|
+
perform: () => {
|
|
254
|
+
trackRemoval(rowIndex);
|
|
255
|
+
removeItems?.(path, [rowIndex])();
|
|
256
|
+
},
|
|
257
|
+
});
|
|
258
|
+
}}
|
|
259
|
+
shape='circle'
|
|
260
|
+
disabled={!enabled || disableRemove || !removeItems}
|
|
261
|
+
icon={<DeleteFilled rev={undefined} />}
|
|
262
|
+
aria-label={translations.removeAriaLabel}
|
|
263
|
+
/>
|
|
264
|
+
</Tooltip>
|
|
265
|
+
</>
|
|
266
|
+
);
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
const foundUISchema = useMemo(
|
|
270
|
+
() =>
|
|
271
|
+
findUISchema(
|
|
272
|
+
uischemas ?? [],
|
|
273
|
+
schema,
|
|
274
|
+
uischema.scope,
|
|
275
|
+
path,
|
|
276
|
+
// JSON Forms generates an empty layout for `items: true`; dispatch
|
|
277
|
+
// the unrestricted item as a Control so mixed values remain editable.
|
|
278
|
+
typeof schema === 'boolean' && schema
|
|
279
|
+
? () => createControlElement('#')
|
|
280
|
+
: undefined,
|
|
281
|
+
uischema,
|
|
282
|
+
rootSchema,
|
|
283
|
+
),
|
|
284
|
+
[uischemas, schema, path, uischema, rootSchema],
|
|
285
|
+
);
|
|
286
|
+
|
|
287
|
+
const doDisableAdd =
|
|
288
|
+
disableAdd ||
|
|
289
|
+
appliedUiSchemaOptions.disableAdd ||
|
|
290
|
+
(appliedUiSchemaOptions.restrict &&
|
|
291
|
+
arraySchema !== undefined &&
|
|
292
|
+
arraySchema.maxItems !== undefined &&
|
|
293
|
+
data >= arraySchema.maxItems);
|
|
294
|
+
|
|
295
|
+
const doDisableRemove =
|
|
296
|
+
disableRemove ||
|
|
297
|
+
appliedUiSchemaOptions.disableRemove ||
|
|
298
|
+
(appliedUiSchemaOptions.restrict &&
|
|
299
|
+
arraySchema !== undefined &&
|
|
300
|
+
arraySchema.minItems !== undefined &&
|
|
301
|
+
data <= arraySchema.minItems);
|
|
302
|
+
|
|
303
|
+
const childLabelForIndex = (childPath: string, index: number) => {
|
|
304
|
+
const childLabelProp =
|
|
305
|
+
uischema.options?.elementLabelProp ?? getFirstPrimitiveProp(schema);
|
|
306
|
+
if (!childLabelProp) {
|
|
307
|
+
return `${index}`;
|
|
308
|
+
}
|
|
309
|
+
const labelValue = Resolve.data(
|
|
310
|
+
props.ctx.core?.data,
|
|
311
|
+
composePaths(childPath, childLabelProp),
|
|
312
|
+
);
|
|
313
|
+
if (
|
|
314
|
+
labelValue === undefined ||
|
|
315
|
+
labelValue === null ||
|
|
316
|
+
Number.isNaN(labelValue)
|
|
317
|
+
) {
|
|
318
|
+
return '';
|
|
319
|
+
}
|
|
320
|
+
return `${labelValue}`;
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
return (
|
|
324
|
+
<>
|
|
325
|
+
{confirmation.dialog}
|
|
326
|
+
<ArrayLayoutToolbar
|
|
327
|
+
options={uischema.options}
|
|
328
|
+
config={config}
|
|
329
|
+
translations={translations}
|
|
330
|
+
label={computeLabel(
|
|
331
|
+
label,
|
|
332
|
+
required ?? false,
|
|
333
|
+
appliedUiSchemaOptions.hideRequiredAsterisk,
|
|
334
|
+
)}
|
|
335
|
+
description={description}
|
|
336
|
+
errors={summaryErrors}
|
|
337
|
+
path={path}
|
|
338
|
+
enabled={enabled}
|
|
339
|
+
addItem={handleAddItem}
|
|
340
|
+
createDefault={innerCreateDefaultValue}
|
|
341
|
+
disableAdd={doDisableAdd}
|
|
342
|
+
>
|
|
343
|
+
{data > 0 ? (
|
|
344
|
+
<Collapse
|
|
345
|
+
accordion
|
|
346
|
+
expandIconPlacement='end'
|
|
347
|
+
activeKey={
|
|
348
|
+
expandedIndex === undefined ? [] : [String(expandedIndex)]
|
|
349
|
+
}
|
|
350
|
+
onChange={(value) => {
|
|
351
|
+
// `accordion` gives at most one key back, and an empty list when
|
|
352
|
+
// the open panel is closed.
|
|
353
|
+
const key = Array.isArray(value) ? value[0] : value;
|
|
354
|
+
setExpandedIndex(key === undefined ? undefined : Number(key));
|
|
355
|
+
}}
|
|
356
|
+
items={map(range(data), (index) => {
|
|
357
|
+
const childPath = composePaths(path, `${index}`);
|
|
358
|
+
|
|
359
|
+
const text = childLabelForIndex(childPath, index);
|
|
360
|
+
|
|
361
|
+
return {
|
|
362
|
+
key: String(index),
|
|
363
|
+
label: (
|
|
364
|
+
<>
|
|
365
|
+
{/*
|
|
366
|
+
"True: hide that marker, without suppressing accessible
|
|
367
|
+
item identity." With the marker gone the header still has
|
|
368
|
+
to say which item it is, so the index moves onto the
|
|
369
|
+
header's own accessible name.
|
|
370
|
+
*/}
|
|
371
|
+
{hideAvatar ? (
|
|
372
|
+
<span style={SR_ONLY}>
|
|
373
|
+
{t('array.indexLabel')} {index + 1}
|
|
374
|
+
</span>
|
|
375
|
+
) : (
|
|
376
|
+
<Avatar
|
|
377
|
+
aria-label={t('array.indexLabel')}
|
|
378
|
+
style={avatarStyle}
|
|
379
|
+
>
|
|
380
|
+
{index + 1}
|
|
381
|
+
</Avatar>
|
|
382
|
+
)}
|
|
383
|
+
<Space
|
|
384
|
+
size='small'
|
|
385
|
+
align='center'
|
|
386
|
+
style={{ verticalAlign: 'middle' }}
|
|
387
|
+
>
|
|
388
|
+
{text ? <Typography.Text>{text}</Typography.Text> : null}
|
|
389
|
+
<ItemValidationIndicator
|
|
390
|
+
Indicator={ContainerValidationIndicator}
|
|
391
|
+
path={childPath}
|
|
392
|
+
options={props.uischema.options}
|
|
393
|
+
config={props.config}
|
|
394
|
+
/>
|
|
395
|
+
</Space>
|
|
396
|
+
</>
|
|
397
|
+
),
|
|
398
|
+
extra: (
|
|
399
|
+
<Space>
|
|
400
|
+
{getExtra({
|
|
401
|
+
rowIndex: index,
|
|
402
|
+
enableUp: index !== 0,
|
|
403
|
+
enableDown: index !== props.data - 1,
|
|
404
|
+
showSortButtons: showSortButtons,
|
|
405
|
+
disableRemove: doDisableRemove,
|
|
406
|
+
})}
|
|
407
|
+
</Space>
|
|
408
|
+
),
|
|
409
|
+
children: (
|
|
410
|
+
<JsonFormsDispatch
|
|
411
|
+
schema={schema}
|
|
412
|
+
uischema={foundUISchema}
|
|
413
|
+
path={childPath}
|
|
414
|
+
key={childPath}
|
|
415
|
+
renderers={renderers}
|
|
416
|
+
cells={cells}
|
|
417
|
+
/>
|
|
418
|
+
),
|
|
419
|
+
};
|
|
420
|
+
})}
|
|
421
|
+
></Collapse>
|
|
422
|
+
) : (
|
|
423
|
+
<Empty description={translations.noDataMessage} />
|
|
424
|
+
)}
|
|
425
|
+
</ArrayLayoutToolbar>
|
|
426
|
+
</>
|
|
427
|
+
);
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
export const ArrayLayout = React.memo(function ArrayLayout(
|
|
431
|
+
props: ArrayLayoutProps & { translations: ArrayTranslations },
|
|
432
|
+
) {
|
|
433
|
+
const ctx = useJsonForms();
|
|
434
|
+
return <ArrayLayoutComponent {...props} ctx={ctx} />;
|
|
435
|
+
});
|