@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,107 @@
|
|
|
1
|
+
import { Category, UISchemaElement } from '@jsonforms/core';
|
|
2
|
+
import { theme as antTheme } from 'antd';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { useGroupState } from '../util/groupState';
|
|
5
|
+
import { useI18n } from '../util/translate';
|
|
6
|
+
import { useContainerValidation } from '../util/validationIndicator';
|
|
7
|
+
import { ContainerIndicator, DataDotIcon } from './ContainerIndicator';
|
|
8
|
+
import { ContainerValidationIndicator } from './ValidationIndicator';
|
|
9
|
+
|
|
10
|
+
export interface CategoryHeaderProps {
|
|
11
|
+
category: Category;
|
|
12
|
+
label?: string;
|
|
13
|
+
path: string;
|
|
14
|
+
config?: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type CategoryIndicatorsProps = Omit<CategoryHeaderProps, 'label'>;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The container markers for a Category: an error marker, and the dot that says
|
|
21
|
+
* the section holds data.
|
|
22
|
+
*
|
|
23
|
+
* A Category has no data scope - the same reason it needs an explicit `i18n`
|
|
24
|
+
* prefix - so both are aggregated from the Controls bound below it, through
|
|
25
|
+
* the one traversal shared with the Group's indicators.
|
|
26
|
+
*
|
|
27
|
+
* Rendered on its own rather than baked into the label, because where they
|
|
28
|
+
* belong depends on the shape of the header rather than on the presentation:
|
|
29
|
+
* see {@link CategoryHeader}. Returns `null` when there is nothing to show, so
|
|
30
|
+
* a caller can hand it straight to an `extra` slot.
|
|
31
|
+
*
|
|
32
|
+
* Both default to off: no indicator existed on categories before, and
|
|
33
|
+
* defaulting to on would change every existing form.
|
|
34
|
+
*/
|
|
35
|
+
export const CategoryIndicators = ({
|
|
36
|
+
category,
|
|
37
|
+
path,
|
|
38
|
+
config,
|
|
39
|
+
}: CategoryIndicatorsProps) => {
|
|
40
|
+
const { token } = antTheme.useToken();
|
|
41
|
+
// See GroupLayout: the default message is where the locale bundle arrives.
|
|
42
|
+
const t = useI18n();
|
|
43
|
+
const validation = useContainerValidation(
|
|
44
|
+
category as UISchemaElement,
|
|
45
|
+
path,
|
|
46
|
+
config,
|
|
47
|
+
false,
|
|
48
|
+
);
|
|
49
|
+
const group = useGroupState(category as UISchemaElement, path, config);
|
|
50
|
+
|
|
51
|
+
if (!validation.show && !group.hasData) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const indicatorLabel = t('group.dataIndicator');
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<span
|
|
59
|
+
data-category-indicators
|
|
60
|
+
style={{
|
|
61
|
+
display: 'inline-flex',
|
|
62
|
+
alignItems: 'center',
|
|
63
|
+
gap: token.marginXS,
|
|
64
|
+
// No leading of its own, or a header grows by the difference between
|
|
65
|
+
// its line box and the icons'.
|
|
66
|
+
lineHeight: 0,
|
|
67
|
+
}}
|
|
68
|
+
>
|
|
69
|
+
{validation.show ? (
|
|
70
|
+
<ContainerValidationIndicator count={validation.count} />
|
|
71
|
+
) : null}
|
|
72
|
+
{group.hasData ? (
|
|
73
|
+
<ContainerIndicator
|
|
74
|
+
label={indicatorLabel}
|
|
75
|
+
color={token.colorTextTertiary}
|
|
76
|
+
marker={{ 'data-category-data-indicator': true }}
|
|
77
|
+
>
|
|
78
|
+
<DataDotIcon />
|
|
79
|
+
</ContainerIndicator>
|
|
80
|
+
) : null}
|
|
81
|
+
</span>
|
|
82
|
+
);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* A category's **tab or step** label, with the indicators after it.
|
|
87
|
+
*
|
|
88
|
+
* A tab and a step label are just text: they are sized to their content and
|
|
89
|
+
* have no trailing edge, so the markers can only follow the words.
|
|
90
|
+
*
|
|
91
|
+
* An accordion header is a different shape - a full-width bar, like a Group's -
|
|
92
|
+
* and there the markers go at the end of the bar instead, through antd's
|
|
93
|
+
* `extra` slot, so that two collapsible sections in one form do not put their
|
|
94
|
+
* status in two different places. That is why this component is not used by
|
|
95
|
+
* the accordion; it renders {@link CategoryIndicators} directly.
|
|
96
|
+
*/
|
|
97
|
+
export const CategoryHeader = ({
|
|
98
|
+
category,
|
|
99
|
+
label,
|
|
100
|
+
path,
|
|
101
|
+
config,
|
|
102
|
+
}: CategoryHeaderProps) => (
|
|
103
|
+
<span style={{ display: 'inline-flex', alignItems: 'center', gap: 8 }}>
|
|
104
|
+
{label}
|
|
105
|
+
<CategoryIndicators category={category} path={path} config={config} />
|
|
106
|
+
</span>
|
|
107
|
+
);
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import ExclamationCircleOutlined from '@ant-design/icons/ExclamationCircleOutlined';
|
|
2
|
+
import { Tooltip, theme as antTheme } from 'antd';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A marker on a container's header.
|
|
7
|
+
*
|
|
8
|
+
* Both markers are **SVG**, not text glyphs and not CSS shapes. A glyph like
|
|
9
|
+
* `●` renders at whatever size and baseline the platform font gives it, so it
|
|
10
|
+
* never lines up with an icon beside it; a CSS circle is crisp but is a third
|
|
11
|
+
* mechanism to keep in sync. An SVG in antd's own icon box - `1em` square,
|
|
12
|
+
* `currentColor`, `viewBox="64 64 896 896"` - is resolution independent, takes
|
|
13
|
+
* its size from `fontSize` and its color from `color`, so two markers sharing
|
|
14
|
+
* this shell are aligned and sized identically by construction.
|
|
15
|
+
*
|
|
16
|
+
* The shell must not make its header taller. It uses the body font size, which
|
|
17
|
+
* is smaller than the header's line box, and `lineHeight: 0` so the inline box
|
|
18
|
+
* adds no leading of its own.
|
|
19
|
+
*/
|
|
20
|
+
export interface ContainerIndicatorProps {
|
|
21
|
+
/** Tooltip text and accessible name. One string, so they cannot diverge. */
|
|
22
|
+
label: string;
|
|
23
|
+
/** `colorError` for a failure, a muted color for data presence. */
|
|
24
|
+
color: string;
|
|
25
|
+
children: React.ReactNode;
|
|
26
|
+
/** Marks the element for tests and host styling. */
|
|
27
|
+
marker?: Record<string, boolean | number | string | undefined>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const ContainerIndicator = ({
|
|
31
|
+
label,
|
|
32
|
+
color,
|
|
33
|
+
children,
|
|
34
|
+
marker,
|
|
35
|
+
}: ContainerIndicatorProps) => {
|
|
36
|
+
const { token } = antTheme.useToken();
|
|
37
|
+
return (
|
|
38
|
+
<Tooltip title={label} trigger={['hover', 'focus']}>
|
|
39
|
+
<span
|
|
40
|
+
role='img'
|
|
41
|
+
aria-label={label}
|
|
42
|
+
tabIndex={0}
|
|
43
|
+
{...marker}
|
|
44
|
+
style={{
|
|
45
|
+
color,
|
|
46
|
+
display: 'inline-flex',
|
|
47
|
+
verticalAlign: 'middle',
|
|
48
|
+
alignItems: 'center',
|
|
49
|
+
// Body size, not the header's: large enough to read, never tall
|
|
50
|
+
// enough to stretch the row.
|
|
51
|
+
fontSize: token.fontSize,
|
|
52
|
+
lineHeight: 0,
|
|
53
|
+
}}
|
|
54
|
+
>
|
|
55
|
+
{children}
|
|
56
|
+
</span>
|
|
57
|
+
</Tooltip>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* A plain filled dot in antd's icon box.
|
|
63
|
+
*
|
|
64
|
+
* `@ant-design/icons` has no plain circle - every `*CircleFilled` carries a
|
|
65
|
+
* symbol - so this draws one, matching the box and attributes of the icons it
|
|
66
|
+
* sits beside. Deliberately smaller than a full icon: data presence is a
|
|
67
|
+
* quieter signal than a failure.
|
|
68
|
+
*/
|
|
69
|
+
export const DataDotIcon = () => (
|
|
70
|
+
<svg
|
|
71
|
+
viewBox='64 64 896 896'
|
|
72
|
+
width='1em'
|
|
73
|
+
height='1em'
|
|
74
|
+
fill='currentColor'
|
|
75
|
+
focusable='false'
|
|
76
|
+
aria-hidden='true'
|
|
77
|
+
>
|
|
78
|
+
<circle cx='512' cy='512' r='224' />
|
|
79
|
+
</svg>
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
/** The failure marker: antd's outlined exclamation, shared with array error summaries. */
|
|
83
|
+
export const ErrorIcon = () => <ExclamationCircleOutlined rev={undefined} />;
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import { ObjectDetailContext } from '@chobantonov/jsonforms-react-renderer-common/objects/ObjectDetail';
|
|
2
|
+
import { ValidationIcon } from '../complex/ValidationIcon';
|
|
3
|
+
import { ObjectErrorContext } from '@chobantonov/jsonforms-react-renderer-common/validation/errorSummary';
|
|
4
|
+
import { useGroupHeaderTitle } from '@chobantonov/jsonforms-react-renderer-common/layout/groupState';
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { Card, Collapse, theme as antTheme } from 'antd';
|
|
7
|
+
import {
|
|
8
|
+
GroupLayout,
|
|
9
|
+
LayoutProps,
|
|
10
|
+
RankedTester,
|
|
11
|
+
UISchemaElement,
|
|
12
|
+
rankWith,
|
|
13
|
+
uiTypeIs,
|
|
14
|
+
withIncreasedRank,
|
|
15
|
+
} from '@jsonforms/core';
|
|
16
|
+
import { JsonFormsDispatch, withJsonFormsLayoutProps } from '@jsonforms/react';
|
|
17
|
+
import { AntdLayoutRenderer } from '../util/layout';
|
|
18
|
+
import { useGroupState } from '../util/groupState';
|
|
19
|
+
import { useI18n } from '../util/translate';
|
|
20
|
+
import { useContainerValidation } from '../util/validationIndicator';
|
|
21
|
+
import { ContainerIndicator, DataDotIcon } from './ContainerIndicator';
|
|
22
|
+
import { ContainerValidationIndicator } from './ValidationIndicator';
|
|
23
|
+
|
|
24
|
+
const groupTester: RankedTester = rankWith(1, uiTypeIs('Group'));
|
|
25
|
+
|
|
26
|
+
export const GroupLayoutRenderer = (props: LayoutProps) => {
|
|
27
|
+
/*
|
|
28
|
+
`useI18n`, not the raw translator from context.
|
|
29
|
+
|
|
30
|
+
It used to call `translate?.(key, i18nDefaults[key])`, which supplies the
|
|
31
|
+
**English** string as the default message - and the default message is
|
|
32
|
+
exactly where the locale bundle is delivered (§6.5). So the indicator
|
|
33
|
+
stayed English in every language whose catalog did not happen to define
|
|
34
|
+
`group.dataIndicator`, which is the usual case: a form's catalog is
|
|
35
|
+
written for its own labels.
|
|
36
|
+
*/
|
|
37
|
+
const { token } = antTheme.useToken();
|
|
38
|
+
const t = useI18n();
|
|
39
|
+
const group = useGroupState(props.uischema, props.path, props.config);
|
|
40
|
+
// Default false for a Group: no indicator exists today, so defaulting to
|
|
41
|
+
// true would change every existing form's appearance.
|
|
42
|
+
const validation = useContainerValidation(
|
|
43
|
+
props.uischema,
|
|
44
|
+
props.path,
|
|
45
|
+
props.config,
|
|
46
|
+
false,
|
|
47
|
+
);
|
|
48
|
+
const object = React.useContext(ObjectErrorContext);
|
|
49
|
+
const objectOwned = object?.uischema === props.uischema;
|
|
50
|
+
const objectErrors = objectOwned ? object.message : '';
|
|
51
|
+
const objectDetail = React.useContext(ObjectDetailContext);
|
|
52
|
+
const additional =
|
|
53
|
+
objectDetail?.uischema === props.uischema ? objectDetail.additional : null;
|
|
54
|
+
const layout = props.uischema as GroupLayout;
|
|
55
|
+
const regions = layout as GroupLayout & {
|
|
56
|
+
cover?: UISchemaElement;
|
|
57
|
+
header?: UISchemaElement[];
|
|
58
|
+
footer?: UISchemaElement[];
|
|
59
|
+
};
|
|
60
|
+
const headerTitle = useGroupHeaderTitle(props.path, regions.header);
|
|
61
|
+
if (!props.visible) return null;
|
|
62
|
+
const renderRegion = (element: UISchemaElement, key: string) => (
|
|
63
|
+
<JsonFormsDispatch
|
|
64
|
+
key={key}
|
|
65
|
+
schema={props.schema}
|
|
66
|
+
uischema={element}
|
|
67
|
+
path={props.path}
|
|
68
|
+
enabled={props.enabled}
|
|
69
|
+
renderers={props.renderers}
|
|
70
|
+
cells={props.cells}
|
|
71
|
+
/>
|
|
72
|
+
);
|
|
73
|
+
const cover = regions.cover ? (
|
|
74
|
+
<div data-group-cover>{renderRegion(regions.cover, 'cover')}</div>
|
|
75
|
+
) : null;
|
|
76
|
+
const headerContent = regions.header?.map((element, index) =>
|
|
77
|
+
renderRegion(element, `header-${index}`),
|
|
78
|
+
);
|
|
79
|
+
const footer = regions.footer?.map((element, index) =>
|
|
80
|
+
renderRegion(element, `footer-${index}`),
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
// One string for the tooltip and the accessible name, so the two cannot
|
|
84
|
+
// drift apart.
|
|
85
|
+
const indicatorLabel = t('group.dataIndicator');
|
|
86
|
+
const indicator = group.hasData ? (
|
|
87
|
+
<ContainerIndicator
|
|
88
|
+
label={indicatorLabel}
|
|
89
|
+
color={token.colorTextTertiary}
|
|
90
|
+
marker={{ 'data-group-indicator': true }}
|
|
91
|
+
>
|
|
92
|
+
<DataDotIcon />
|
|
93
|
+
</ContainerIndicator>
|
|
94
|
+
) : undefined;
|
|
95
|
+
// Two different signals, deliberately side by side: the dot says data is
|
|
96
|
+
// present, the error marker says something below needs fixing.
|
|
97
|
+
const extra =
|
|
98
|
+
(objectOwned ? Boolean(objectErrors) : validation.show) || indicator ? (
|
|
99
|
+
// One flex row so the two markers share a centre line and a gap,
|
|
100
|
+
// whichever of them is present.
|
|
101
|
+
<span
|
|
102
|
+
data-group-indicators
|
|
103
|
+
style={{
|
|
104
|
+
display: 'inline-flex',
|
|
105
|
+
alignItems: 'center',
|
|
106
|
+
gap: token.marginXS,
|
|
107
|
+
// The row must not add leading of its own either, or the header
|
|
108
|
+
// grows by the difference between its line box and the icons'.
|
|
109
|
+
lineHeight: 0,
|
|
110
|
+
}}
|
|
111
|
+
>
|
|
112
|
+
{objectOwned ? (
|
|
113
|
+
objectErrors ? (
|
|
114
|
+
<ValidationIcon
|
|
115
|
+
local
|
|
116
|
+
errorMessages={objectErrors}
|
|
117
|
+
id={`${props.path}-object-errors`}
|
|
118
|
+
/>
|
|
119
|
+
) : null
|
|
120
|
+
) : validation.show ? (
|
|
121
|
+
<ContainerValidationIndicator count={validation.count} />
|
|
122
|
+
) : null}
|
|
123
|
+
{indicator}
|
|
124
|
+
</span>
|
|
125
|
+
) : undefined;
|
|
126
|
+
const content = (
|
|
127
|
+
<>
|
|
128
|
+
{layout.elements.length > 0 && (
|
|
129
|
+
<AntdLayoutRenderer
|
|
130
|
+
{...props}
|
|
131
|
+
direction='column'
|
|
132
|
+
elements={layout.elements}
|
|
133
|
+
/>
|
|
134
|
+
)}
|
|
135
|
+
{additional}
|
|
136
|
+
</>
|
|
137
|
+
);
|
|
138
|
+
const style = { marginBottom: '10px', width: '100%' };
|
|
139
|
+
|
|
140
|
+
if (!regions.cover && !regions.header?.length && !footer?.length) {
|
|
141
|
+
if (group.collapsible) {
|
|
142
|
+
return (
|
|
143
|
+
<section
|
|
144
|
+
role='group'
|
|
145
|
+
aria-label={props.label || undefined}
|
|
146
|
+
style={style}
|
|
147
|
+
>
|
|
148
|
+
<Collapse
|
|
149
|
+
activeKey={group.collapsed ? [] : ['group']}
|
|
150
|
+
onChange={(keys) => {
|
|
151
|
+
if (keys.includes('group') === group.collapsed) group.toggle();
|
|
152
|
+
}}
|
|
153
|
+
destroyOnHidden={false}
|
|
154
|
+
items={[
|
|
155
|
+
{
|
|
156
|
+
key: 'group',
|
|
157
|
+
label: props.label || t('control.group'),
|
|
158
|
+
extra,
|
|
159
|
+
forceRender: true,
|
|
160
|
+
children: content,
|
|
161
|
+
},
|
|
162
|
+
]}
|
|
163
|
+
/>
|
|
164
|
+
</section>
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
return (
|
|
168
|
+
<Card
|
|
169
|
+
title={props.label || undefined}
|
|
170
|
+
extra={extra}
|
|
171
|
+
style={style}
|
|
172
|
+
role='group'
|
|
173
|
+
aria-label={props.label || undefined}
|
|
174
|
+
>
|
|
175
|
+
{content}
|
|
176
|
+
</Card>
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const card = (
|
|
181
|
+
<Card
|
|
182
|
+
data-group-frame
|
|
183
|
+
cover={cover}
|
|
184
|
+
actions={
|
|
185
|
+
footer?.length && !group.collapsible
|
|
186
|
+
? [
|
|
187
|
+
<div
|
|
188
|
+
key='footer'
|
|
189
|
+
data-group-footer
|
|
190
|
+
style={{
|
|
191
|
+
display: 'flex',
|
|
192
|
+
alignItems: 'center',
|
|
193
|
+
flexWrap: 'wrap',
|
|
194
|
+
gap: token.marginXS,
|
|
195
|
+
paddingInline: token.padding,
|
|
196
|
+
}}
|
|
197
|
+
>
|
|
198
|
+
{footer}
|
|
199
|
+
</div>,
|
|
200
|
+
]
|
|
201
|
+
: undefined
|
|
202
|
+
}
|
|
203
|
+
style={style}
|
|
204
|
+
role='group'
|
|
205
|
+
aria-label={headerTitle || props.label || undefined}
|
|
206
|
+
>
|
|
207
|
+
<div
|
|
208
|
+
style={{
|
|
209
|
+
display: 'flex',
|
|
210
|
+
alignItems: 'flex-start',
|
|
211
|
+
justifyContent: 'space-between',
|
|
212
|
+
gap: token.marginXS,
|
|
213
|
+
marginBottom: group.collapsed ? 0 : token.margin,
|
|
214
|
+
}}
|
|
215
|
+
>
|
|
216
|
+
<div data-group-header style={{ minWidth: 0 }}>
|
|
217
|
+
<Card.Meta
|
|
218
|
+
title={headerContent?.[0] ?? props.label ?? undefined}
|
|
219
|
+
description={
|
|
220
|
+
headerContent?.length ? headerContent.slice(1) : undefined
|
|
221
|
+
}
|
|
222
|
+
/>
|
|
223
|
+
</div>
|
|
224
|
+
{(group.collapsible || extra) && (
|
|
225
|
+
<span
|
|
226
|
+
style={{
|
|
227
|
+
display: 'inline-flex',
|
|
228
|
+
alignItems: 'center',
|
|
229
|
+
flexShrink: 0,
|
|
230
|
+
gap: token.marginXS,
|
|
231
|
+
}}
|
|
232
|
+
>
|
|
233
|
+
{extra}
|
|
234
|
+
{group.collapsible && (
|
|
235
|
+
<button
|
|
236
|
+
type='button'
|
|
237
|
+
aria-label={headerTitle || props.label || t('control.group')}
|
|
238
|
+
aria-expanded={!group.collapsed}
|
|
239
|
+
aria-controls={group.contentId}
|
|
240
|
+
onClick={group.toggle}
|
|
241
|
+
style={{
|
|
242
|
+
display: 'inline-flex',
|
|
243
|
+
alignItems: 'center',
|
|
244
|
+
justifyContent: 'center',
|
|
245
|
+
border: 0,
|
|
246
|
+
background: 'transparent',
|
|
247
|
+
color: 'inherit',
|
|
248
|
+
cursor: 'pointer',
|
|
249
|
+
padding: token.paddingXS,
|
|
250
|
+
}}
|
|
251
|
+
>
|
|
252
|
+
<svg
|
|
253
|
+
aria-hidden='true'
|
|
254
|
+
width='14'
|
|
255
|
+
height='14'
|
|
256
|
+
viewBox='0 0 14 14'
|
|
257
|
+
>
|
|
258
|
+
<path
|
|
259
|
+
d='m5 3 4 4-4 4'
|
|
260
|
+
fill='none'
|
|
261
|
+
stroke='currentColor'
|
|
262
|
+
strokeWidth='1.5'
|
|
263
|
+
strokeLinecap='round'
|
|
264
|
+
strokeLinejoin='round'
|
|
265
|
+
transform={group.collapsed ? undefined : 'rotate(90 7 7)'}
|
|
266
|
+
/>
|
|
267
|
+
</svg>
|
|
268
|
+
</button>
|
|
269
|
+
)}
|
|
270
|
+
</span>
|
|
271
|
+
)}
|
|
272
|
+
</div>
|
|
273
|
+
{group.collapsible ? (
|
|
274
|
+
<div
|
|
275
|
+
id={group.contentId}
|
|
276
|
+
data-group-body
|
|
277
|
+
style={{ display: group.collapsed ? 'none' : undefined }}
|
|
278
|
+
>
|
|
279
|
+
{content}
|
|
280
|
+
{footer?.length ? (
|
|
281
|
+
<footer
|
|
282
|
+
data-group-footer
|
|
283
|
+
style={{
|
|
284
|
+
display: 'flex',
|
|
285
|
+
alignItems: 'center',
|
|
286
|
+
flexWrap: 'wrap',
|
|
287
|
+
gap: token.marginXS,
|
|
288
|
+
borderTop: `1px solid ${token.colorBorderSecondary}`,
|
|
289
|
+
paddingTop: token.padding,
|
|
290
|
+
marginTop: token.margin,
|
|
291
|
+
}}
|
|
292
|
+
>
|
|
293
|
+
{footer}
|
|
294
|
+
</footer>
|
|
295
|
+
) : null}
|
|
296
|
+
</div>
|
|
297
|
+
) : (
|
|
298
|
+
content
|
|
299
|
+
)}
|
|
300
|
+
</Card>
|
|
301
|
+
);
|
|
302
|
+
|
|
303
|
+
return card;
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
export default withJsonFormsLayoutProps(GroupLayoutRenderer);
|
|
307
|
+
export const antdGroupTester: RankedTester = withIncreasedRank(1, groupTester);
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
HorizontalLayout,
|
|
4
|
+
LayoutProps,
|
|
5
|
+
RankedTester,
|
|
6
|
+
rankWith,
|
|
7
|
+
uiTypeIs,
|
|
8
|
+
} from '@jsonforms/core';
|
|
9
|
+
import { withJsonFormsLayoutProps } from '@jsonforms/react';
|
|
10
|
+
import { AntdLayoutRenderer, AntdLayoutRendererProps } from '../util/layout';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Default tester for a horizontal layout.
|
|
14
|
+
* @type {RankedTester}
|
|
15
|
+
*/
|
|
16
|
+
export const horizontalLayoutTester: RankedTester = rankWith(
|
|
17
|
+
2,
|
|
18
|
+
uiTypeIs('HorizontalLayout'),
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
export const HorizontalLayoutRenderer = ({
|
|
22
|
+
uischema,
|
|
23
|
+
renderers,
|
|
24
|
+
cells,
|
|
25
|
+
schema,
|
|
26
|
+
path,
|
|
27
|
+
enabled,
|
|
28
|
+
visible,
|
|
29
|
+
config,
|
|
30
|
+
}: LayoutProps) => {
|
|
31
|
+
const layout = uischema as HorizontalLayout;
|
|
32
|
+
const childProps: AntdLayoutRendererProps = {
|
|
33
|
+
elements: layout.elements,
|
|
34
|
+
schema,
|
|
35
|
+
path,
|
|
36
|
+
enabled,
|
|
37
|
+
direction: 'row',
|
|
38
|
+
visible,
|
|
39
|
+
// The container half of the sizing model: gap, wrap, align, justify,
|
|
40
|
+
// minItemWidth, and gridColumns for a horizontal layout.
|
|
41
|
+
layoutOptions: layout.options as any,
|
|
42
|
+
config,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<AntdLayoutRenderer {...childProps} renderers={renderers} cells={cells} />
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default withJsonFormsLayoutProps(HorizontalLayoutRenderer);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { theme as antTheme } from 'antd';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { useI18n } from '../util/translate';
|
|
4
|
+
import { ContainerIndicator, ErrorIcon } from './ContainerIndicator';
|
|
5
|
+
|
|
6
|
+
export interface ValidationIndicatorProps {
|
|
7
|
+
/** Eligible errors at or below the container, or undefined to omit it. */
|
|
8
|
+
count?: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The marker a container shows when something below it fails validation.
|
|
13
|
+
*
|
|
14
|
+
* Deliberately not color alone: it carries a localized accessible name and a
|
|
15
|
+
* tooltip available on hover and keyboard focus, as a bare colored glyph
|
|
16
|
+
* communicates nothing to a screen reader and nothing on touch.
|
|
17
|
+
*/
|
|
18
|
+
export const ContainerValidationIndicator = ({
|
|
19
|
+
count,
|
|
20
|
+
}: ValidationIndicatorProps) => {
|
|
21
|
+
const { token } = antTheme.useToken();
|
|
22
|
+
const t = useI18n();
|
|
23
|
+
const key =
|
|
24
|
+
count === undefined
|
|
25
|
+
? 'validation.containerHasErrors'
|
|
26
|
+
: count === 1
|
|
27
|
+
? 'validation.containerError'
|
|
28
|
+
: 'validation.containerErrors';
|
|
29
|
+
// `useI18n` fills `{count}` itself, so the hand-rolled replace is gone.
|
|
30
|
+
const label = t(key, { count });
|
|
31
|
+
return (
|
|
32
|
+
<ContainerIndicator
|
|
33
|
+
label={label}
|
|
34
|
+
color={token.colorError}
|
|
35
|
+
marker={{
|
|
36
|
+
'data-container-validation-indicator': true,
|
|
37
|
+
'data-error-count': count,
|
|
38
|
+
}}
|
|
39
|
+
>
|
|
40
|
+
<ErrorIcon />
|
|
41
|
+
</ContainerIndicator>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
LayoutProps,
|
|
4
|
+
RankedTester,
|
|
5
|
+
rankWith,
|
|
6
|
+
uiTypeIs,
|
|
7
|
+
VerticalLayout,
|
|
8
|
+
} from '@jsonforms/core';
|
|
9
|
+
import { AntdLayoutRenderer, AntdLayoutRendererProps } from '../util/layout';
|
|
10
|
+
import { withJsonFormsLayoutProps } from '@jsonforms/react';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Default tester for a vertical layout.
|
|
14
|
+
* @type {RankedTester}
|
|
15
|
+
*/
|
|
16
|
+
export const verticalLayoutTester: RankedTester = rankWith(
|
|
17
|
+
1,
|
|
18
|
+
uiTypeIs('VerticalLayout'),
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
export const VerticalLayoutRenderer = ({
|
|
22
|
+
uischema,
|
|
23
|
+
schema,
|
|
24
|
+
path,
|
|
25
|
+
enabled,
|
|
26
|
+
visible,
|
|
27
|
+
renderers,
|
|
28
|
+
cells,
|
|
29
|
+
config,
|
|
30
|
+
}: LayoutProps) => {
|
|
31
|
+
const verticalLayout = uischema as VerticalLayout;
|
|
32
|
+
const childProps: AntdLayoutRendererProps = {
|
|
33
|
+
elements: verticalLayout.elements,
|
|
34
|
+
schema,
|
|
35
|
+
path,
|
|
36
|
+
enabled,
|
|
37
|
+
direction: 'column',
|
|
38
|
+
visible,
|
|
39
|
+
// The container half of the sizing model: gap, wrap, align, justify,
|
|
40
|
+
// minItemWidth, and gridColumns for a horizontal layout.
|
|
41
|
+
layoutOptions: verticalLayout.options as any,
|
|
42
|
+
config,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<AntdLayoutRenderer {...childProps} renderers={renderers} cells={cells} />
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default withJsonFormsLayoutProps(VerticalLayoutRenderer);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Card, Col, Row, Typography } from 'antd';
|
|
3
|
+
import { ValidationIcon } from '../complex/ValidationIcon';
|
|
4
|
+
const { Title } = Typography;
|
|
5
|
+
|
|
6
|
+
export const renderArrayTitle = (
|
|
7
|
+
label: string,
|
|
8
|
+
errors: string,
|
|
9
|
+
description: string | undefined,
|
|
10
|
+
) => (
|
|
11
|
+
<>
|
|
12
|
+
<Row align='middle'>
|
|
13
|
+
<Col>
|
|
14
|
+
<Title level={5} style={{ margin: 0 }}>
|
|
15
|
+
{label}
|
|
16
|
+
</Title>
|
|
17
|
+
</Col>
|
|
18
|
+
<Col style={{ paddingLeft: 8 }}>
|
|
19
|
+
{errors.length !== 0 && (
|
|
20
|
+
<ValidationIcon
|
|
21
|
+
id='tooltip-validation'
|
|
22
|
+
errorMessages={errors}
|
|
23
|
+
local
|
|
24
|
+
/>
|
|
25
|
+
)}
|
|
26
|
+
</Col>
|
|
27
|
+
</Row>
|
|
28
|
+
{description && <Card.Meta description={description} />}
|
|
29
|
+
</>
|
|
30
|
+
);
|