@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,114 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CellProps, WithClassname } from '@jsonforms/core';
|
|
3
|
+
import { Slider } from 'antd';
|
|
4
|
+
import merge from 'lodash/merge';
|
|
5
|
+
import { useI18n } from '../util/translate';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A slider position for a value, or the fallback when there is nothing usable.
|
|
9
|
+
*
|
|
10
|
+
* Type-checked rather than truthy: `0` is a real value and must survive.
|
|
11
|
+
* `Number(data || schema.default)` turned a committed `0` into the default -
|
|
12
|
+
* the data said 0 while the knob sat at 10 - which section 18 forbids:
|
|
13
|
+
* "Zero is a real current value and must not be replaced by a default through
|
|
14
|
+
* a truthiness fallback."
|
|
15
|
+
*
|
|
16
|
+
* Strings are tolerated so incoming `"25"` still positions the thumb, but an
|
|
17
|
+
* empty or unparseable one falls back rather than becoming `Number('')` = 0.
|
|
18
|
+
*/
|
|
19
|
+
export const resolveSliderValue = (
|
|
20
|
+
value: unknown,
|
|
21
|
+
fallback: number,
|
|
22
|
+
): number => {
|
|
23
|
+
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
if (typeof value === 'string' && value.trim() !== '') {
|
|
27
|
+
const parsed = Number(value);
|
|
28
|
+
if (Number.isFinite(parsed)) {
|
|
29
|
+
return parsed;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return fallback;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/** Whether the control holds a value at all, as opposed to showing a fallback. */
|
|
36
|
+
export const hasSliderValue = (value: unknown): boolean =>
|
|
37
|
+
(typeof value === 'number' && Number.isFinite(value)) ||
|
|
38
|
+
(typeof value === 'string' &&
|
|
39
|
+
value.trim() !== '' &&
|
|
40
|
+
Number.isFinite(Number(value)));
|
|
41
|
+
|
|
42
|
+
export const AntdSlider = React.memo(function AntdSlider(
|
|
43
|
+
props: CellProps &
|
|
44
|
+
WithClassname & { inputProps?: React.ComponentProps<typeof Slider> },
|
|
45
|
+
) {
|
|
46
|
+
const {
|
|
47
|
+
data,
|
|
48
|
+
id,
|
|
49
|
+
enabled,
|
|
50
|
+
uischema,
|
|
51
|
+
path,
|
|
52
|
+
handleChange,
|
|
53
|
+
config,
|
|
54
|
+
schema,
|
|
55
|
+
inputProps,
|
|
56
|
+
} = props;
|
|
57
|
+
const t = useI18n();
|
|
58
|
+
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
59
|
+
|
|
60
|
+
const sliderStyle: { [x: string]: any } = {
|
|
61
|
+
marginTop: '7px',
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// data -> schema.default -> schema.minimum -> 0, each checked rather than
|
|
65
|
+
// trusted: the range tester requires a default, but not that it is a number.
|
|
66
|
+
const committed = hasSliderValue(data);
|
|
67
|
+
const effectiveValue = resolveSliderValue(
|
|
68
|
+
data,
|
|
69
|
+
resolveSliderValue(schema.default, schema.minimum ?? 0),
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
const marks = {
|
|
73
|
+
[schema.minimum!]: {
|
|
74
|
+
label: schema.minimum,
|
|
75
|
+
style: { whiteSpace: 'nowrap' as const },
|
|
76
|
+
},
|
|
77
|
+
[schema.maximum!]: {
|
|
78
|
+
label: schema.maximum,
|
|
79
|
+
style: { whiteSpace: 'nowrap' as const },
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<Slider
|
|
85
|
+
id={id}
|
|
86
|
+
style={sliderStyle}
|
|
87
|
+
min={schema.minimum}
|
|
88
|
+
max={schema.maximum}
|
|
89
|
+
marks={marks}
|
|
90
|
+
value={effectiveValue as any}
|
|
91
|
+
/*
|
|
92
|
+
Missing data may borrow the default's position, but the spec requires
|
|
93
|
+
it to be "visibly and accessibly identified as Not set until edited",
|
|
94
|
+
so it must not be announced as a committed number.
|
|
95
|
+
|
|
96
|
+
Through antd's own prop, not `aria-valuetext`: the announcement
|
|
97
|
+
belongs on the **handle**, which is what carries `aria-valuenow`, and
|
|
98
|
+
antd does not forward the bare attribute to it. Set as an attribute on
|
|
99
|
+
the control it never reached the DOM at all, so the number was
|
|
100
|
+
announced unqualified.
|
|
101
|
+
*/
|
|
102
|
+
ariaValueTextFormatterForHandle={
|
|
103
|
+
committed ? undefined : () => t('control.notSet')
|
|
104
|
+
}
|
|
105
|
+
onChange={(value: any) => {
|
|
106
|
+
handleChange(path, Number(value));
|
|
107
|
+
}}
|
|
108
|
+
disabled={!enabled}
|
|
109
|
+
step={schema.multipleOf || 1}
|
|
110
|
+
autoFocus={!!appliedUiSchemaOptions.focus}
|
|
111
|
+
{...inputProps}
|
|
112
|
+
></Slider>
|
|
113
|
+
);
|
|
114
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { CellProps, WithClassname } from '@jsonforms/core';
|
|
2
|
+
import { TimePicker } from 'antd';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { timePickerColumns } from '../util/temporalFormats';
|
|
5
|
+
import { useTemporalPicker } from './useTemporalPicker';
|
|
6
|
+
|
|
7
|
+
export const AntdTimePicker = React.memo(function AntdTimePicker(
|
|
8
|
+
props: CellProps &
|
|
9
|
+
WithClassname & { inputProps?: React.ComponentProps<typeof TimePicker> },
|
|
10
|
+
) {
|
|
11
|
+
const { pickerProps, options, disabledTime } = useTemporalPicker(
|
|
12
|
+
props,
|
|
13
|
+
'time',
|
|
14
|
+
);
|
|
15
|
+
return (
|
|
16
|
+
<TimePicker
|
|
17
|
+
{...pickerProps}
|
|
18
|
+
disabledTime={disabledTime}
|
|
19
|
+
// `views` picks the columns; absent, the display format still decides.
|
|
20
|
+
{...timePickerColumns(options.views)}
|
|
21
|
+
use12Hours={!!options.ampm}
|
|
22
|
+
{...props.inputProps}
|
|
23
|
+
/>
|
|
24
|
+
);
|
|
25
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CellProps, WithClassname } from '@jsonforms/core';
|
|
3
|
+
import { Switch } from 'antd';
|
|
4
|
+
import merge from 'lodash/merge';
|
|
5
|
+
import { useI18n } from '../util/translate';
|
|
6
|
+
import { visuallyHidden } from '../util/visuallyHidden';
|
|
7
|
+
|
|
8
|
+
export const AntdToggle = React.memo(function AntdToggle(
|
|
9
|
+
props: CellProps &
|
|
10
|
+
WithClassname & {
|
|
11
|
+
inputProps?: React.ComponentProps<typeof Switch> & React.AriaAttributes;
|
|
12
|
+
},
|
|
13
|
+
) {
|
|
14
|
+
const {
|
|
15
|
+
data,
|
|
16
|
+
id,
|
|
17
|
+
className,
|
|
18
|
+
enabled,
|
|
19
|
+
uischema,
|
|
20
|
+
path,
|
|
21
|
+
handleChange,
|
|
22
|
+
config,
|
|
23
|
+
inputProps,
|
|
24
|
+
} = props;
|
|
25
|
+
const appliedUiSchemaOptions = merge({}, config, uischema.options);
|
|
26
|
+
const t = useI18n();
|
|
27
|
+
/*
|
|
28
|
+
A switch cannot show an indeterminate state, so the specification asks for
|
|
29
|
+
an accessible "Not set" indication instead. `!!data` additionally rendered
|
|
30
|
+
the string `'false'` as on; only a real `true` is on.
|
|
31
|
+
*/
|
|
32
|
+
const committed = typeof data === 'boolean';
|
|
33
|
+
const stateId = `${id}-state`;
|
|
34
|
+
// Composed, not assigned: InputControl passes its help id through
|
|
35
|
+
// `inputProps`, which is spread after our props and would otherwise replace
|
|
36
|
+
// this one - leaving the state unannounced.
|
|
37
|
+
const describedBy =
|
|
38
|
+
[
|
|
39
|
+
(inputProps as { 'aria-describedby'?: string } | undefined)?.[
|
|
40
|
+
'aria-describedby'
|
|
41
|
+
],
|
|
42
|
+
committed ? undefined : stateId,
|
|
43
|
+
]
|
|
44
|
+
.filter(Boolean)
|
|
45
|
+
.join(' ') || undefined;
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<>
|
|
49
|
+
<Switch
|
|
50
|
+
id={id}
|
|
51
|
+
checked={data === true}
|
|
52
|
+
onChange={(isChecked) => handleChange(path, isChecked)}
|
|
53
|
+
className={className}
|
|
54
|
+
disabled={!enabled}
|
|
55
|
+
autoFocus={!!appliedUiSchemaOptions.focus}
|
|
56
|
+
{...inputProps}
|
|
57
|
+
aria-describedby={describedBy}
|
|
58
|
+
/>
|
|
59
|
+
{committed ? null : (
|
|
60
|
+
<span id={stateId} style={visuallyHidden}>
|
|
61
|
+
{t(
|
|
62
|
+
typeof data === 'undefined' || data === null
|
|
63
|
+
? 'boolean.notSet'
|
|
64
|
+
: 'boolean.invalid',
|
|
65
|
+
)}
|
|
66
|
+
</span>
|
|
67
|
+
)}
|
|
68
|
+
</>
|
|
69
|
+
);
|
|
70
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button, Popover, Typography, theme } from 'antd';
|
|
3
|
+
import WarningOutlined from '@ant-design/icons/WarningOutlined';
|
|
4
|
+
import ExclamationCircleOutlined from '@ant-design/icons/ExclamationCircleOutlined';
|
|
5
|
+
export const FileFeedback = ({
|
|
6
|
+
message,
|
|
7
|
+
cell,
|
|
8
|
+
severity,
|
|
9
|
+
}: {
|
|
10
|
+
message: string;
|
|
11
|
+
cell?: boolean;
|
|
12
|
+
severity: 'warning' | 'error';
|
|
13
|
+
}) => {
|
|
14
|
+
const { token } = theme.useToken();
|
|
15
|
+
const color = severity === 'warning' ? token.colorWarning : token.colorError;
|
|
16
|
+
return cell ? (
|
|
17
|
+
<Popover content={message} trigger={['hover', 'focus', 'click']}>
|
|
18
|
+
<Button
|
|
19
|
+
type='text'
|
|
20
|
+
size='small'
|
|
21
|
+
aria-label={message}
|
|
22
|
+
style={{ color, flexShrink: 0 }}
|
|
23
|
+
icon={
|
|
24
|
+
severity === 'warning' ? (
|
|
25
|
+
<WarningOutlined />
|
|
26
|
+
) : (
|
|
27
|
+
<ExclamationCircleOutlined />
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
/>
|
|
31
|
+
</Popover>
|
|
32
|
+
) : (
|
|
33
|
+
<Typography.Text style={{ color }} role='alert' data-file-rejection>
|
|
34
|
+
{message}
|
|
35
|
+
</Typography.Text>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export * from './AntdCheckbox';
|
|
2
|
+
export * from './AntdClearValueButton';
|
|
3
|
+
export * from './AntdClearableInput';
|
|
4
|
+
export * from './AntdOtp';
|
|
5
|
+
export * from './AntdRevealButton';
|
|
6
|
+
export * from './AntdDatePicker';
|
|
7
|
+
export * from './AntdFile';
|
|
8
|
+
export * from './AntdDateTimePicker';
|
|
9
|
+
export * from './AntdInputInteger';
|
|
10
|
+
export * from './AntdInputNumber';
|
|
11
|
+
export * from './AntdInputNumberFormat';
|
|
12
|
+
export * from './AntdInputText';
|
|
13
|
+
export * from './AntdRadioGroup';
|
|
14
|
+
export * from './AntdSelect';
|
|
15
|
+
export * from './AntdSlider';
|
|
16
|
+
export * from './AntdTimePicker';
|
|
17
|
+
export * from './AntdToggle';
|
|
18
|
+
export * from './AntdPassword';
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import type { CellProps, WithClassname } from '@jsonforms/core';
|
|
2
|
+
import { useJsonForms } from '@jsonforms/react';
|
|
3
|
+
import { useEffect, useMemo } from 'react';
|
|
4
|
+
import merge from 'lodash/merge';
|
|
5
|
+
import { createOnChangeHandler, getData } from '../util';
|
|
6
|
+
import {
|
|
7
|
+
specDateSaveFormat,
|
|
8
|
+
specDateTimeSaveFormat,
|
|
9
|
+
specTimeSaveFormat,
|
|
10
|
+
warnOnSaveFormat,
|
|
11
|
+
} from '../util/temporalFormats';
|
|
12
|
+
import {
|
|
13
|
+
disabledDateFor,
|
|
14
|
+
disabledTimeFor,
|
|
15
|
+
effectiveRestrict,
|
|
16
|
+
resolveDataBounds,
|
|
17
|
+
temporalBounds,
|
|
18
|
+
} from '../util/temporalBounds';
|
|
19
|
+
const JSON_SCHEMA_DATE_FORMATS = ['YYYY-MM-DD'];
|
|
20
|
+
const JSON_SCHEMA_DATE_TIME_FORMATS = [
|
|
21
|
+
'YYYY-MM-DDTHH:mm:ss.SSSZ',
|
|
22
|
+
'YYYY-MM-DDTHH:mm:ss.SSS',
|
|
23
|
+
'YYYY-MM-DDTHH:mm:ssZ',
|
|
24
|
+
'YYYY-MM-DDTHH:mm:ss',
|
|
25
|
+
];
|
|
26
|
+
const JSON_SCHEMA_TIME_FORMATS = [
|
|
27
|
+
'HH:mm:ss.SSSZ',
|
|
28
|
+
'HH:mm:ss.SSS',
|
|
29
|
+
'HH:mm:ssZ',
|
|
30
|
+
'HH:mm:ss',
|
|
31
|
+
];
|
|
32
|
+
const defaults = {
|
|
33
|
+
date: { formats: JSON_SCHEMA_DATE_FORMATS, saveFormat: specDateSaveFormat },
|
|
34
|
+
dateTime: {
|
|
35
|
+
formats: JSON_SCHEMA_DATE_TIME_FORMATS,
|
|
36
|
+
saveFormat: specDateTimeSaveFormat,
|
|
37
|
+
},
|
|
38
|
+
time: { formats: JSON_SCHEMA_TIME_FORMATS, saveFormat: specTimeSaveFormat },
|
|
39
|
+
};
|
|
40
|
+
const style = { width: '100%' };
|
|
41
|
+
|
|
42
|
+
function defaultDisplayFormat(kind: keyof typeof defaults, ampm: unknown) {
|
|
43
|
+
if (kind === 'date') return 'YYYY-MM-DD';
|
|
44
|
+
if (kind === 'dateTime') return 'YYYY-MM-DD HH:mm';
|
|
45
|
+
return ampm === true ? 'hh:mm a' : 'HH:mm';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function useTemporalPicker(
|
|
49
|
+
props: CellProps & WithClassname,
|
|
50
|
+
kind: keyof typeof defaults,
|
|
51
|
+
) {
|
|
52
|
+
const {
|
|
53
|
+
config,
|
|
54
|
+
uischema,
|
|
55
|
+
schema,
|
|
56
|
+
path,
|
|
57
|
+
data,
|
|
58
|
+
handleChange,
|
|
59
|
+
enabled,
|
|
60
|
+
isValid,
|
|
61
|
+
id,
|
|
62
|
+
className,
|
|
63
|
+
} = props;
|
|
64
|
+
const options = useMemo(
|
|
65
|
+
() => merge({}, config, uischema.options),
|
|
66
|
+
[config, uischema.options],
|
|
67
|
+
);
|
|
68
|
+
const rootData = useJsonForms().core?.data;
|
|
69
|
+
const boundsSchema = useMemo(
|
|
70
|
+
() => resolveDataBounds(schema as Record<string, unknown>, path, rootData),
|
|
71
|
+
[schema, path, rootData],
|
|
72
|
+
);
|
|
73
|
+
const format =
|
|
74
|
+
options[`${kind}Format`] ?? defaultDisplayFormat(kind, options.ampm);
|
|
75
|
+
const saveFormat = options[`${kind}SaveFormat`] ?? defaults[kind].saveFormat;
|
|
76
|
+
const formats = useMemo(
|
|
77
|
+
() => [saveFormat, format, ...defaults[kind].formats],
|
|
78
|
+
[saveFormat, format, kind],
|
|
79
|
+
);
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
warnOnSaveFormat(schema?.format, saveFormat);
|
|
82
|
+
}, [schema?.format, saveFormat]);
|
|
83
|
+
const value = useMemo(() => getData(data, formats), [data, formats]);
|
|
84
|
+
const onChange = useMemo(
|
|
85
|
+
() => createOnChangeHandler(path, handleChange, saveFormat),
|
|
86
|
+
[path, handleChange, saveFormat],
|
|
87
|
+
);
|
|
88
|
+
const restrict = effectiveRestrict(uischema.options, config);
|
|
89
|
+
const precision = format.includes('s') ? 'second' : 'minute';
|
|
90
|
+
const bounds = useMemo(
|
|
91
|
+
() =>
|
|
92
|
+
temporalBounds(
|
|
93
|
+
boundsSchema,
|
|
94
|
+
formats,
|
|
95
|
+
kind === 'date' ? 'day' : precision,
|
|
96
|
+
kind === 'time',
|
|
97
|
+
),
|
|
98
|
+
[boundsSchema, formats, kind, precision],
|
|
99
|
+
);
|
|
100
|
+
const disabledDate = useMemo(
|
|
101
|
+
() => (restrict && kind !== 'time' ? disabledDateFor(bounds) : undefined),
|
|
102
|
+
[bounds, restrict, kind],
|
|
103
|
+
);
|
|
104
|
+
const disabledTime = useMemo(
|
|
105
|
+
() =>
|
|
106
|
+
restrict && kind !== 'date'
|
|
107
|
+
? disabledTimeFor(bounds, kind === 'time', precision)
|
|
108
|
+
: undefined,
|
|
109
|
+
[bounds, kind, restrict, precision],
|
|
110
|
+
);
|
|
111
|
+
return {
|
|
112
|
+
options,
|
|
113
|
+
disabledDate,
|
|
114
|
+
disabledTime,
|
|
115
|
+
saveFormat,
|
|
116
|
+
pickerProps: {
|
|
117
|
+
value,
|
|
118
|
+
onChange,
|
|
119
|
+
format,
|
|
120
|
+
allowClear: enabled,
|
|
121
|
+
disabled: !enabled,
|
|
122
|
+
className,
|
|
123
|
+
id,
|
|
124
|
+
autoFocus: options.focus,
|
|
125
|
+
placeholder: options.placeholder,
|
|
126
|
+
style,
|
|
127
|
+
status: isValid ? undefined : ('error' as const),
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { useCompositeCellPresentation } from '@chobantonov/jsonforms-react-renderer-common/cells/useCompositeCellPresentation';
|
|
2
|
+
import React, { useLayoutEffect, useState, useRef } from 'react';
|
|
3
|
+
import { resolveEditorDetail } from '@chobantonov/jsonforms-react-renderer-common/core/detailUiSchema';
|
|
4
|
+
import { CellSummary } from '@chobantonov/jsonforms-react-renderer-common/cells/CellSummary';
|
|
5
|
+
import { ValidationIcon } from '../complex/ValidationIcon';
|
|
6
|
+
import { Button, theme } from 'antd';
|
|
7
|
+
import CloseOutlined from '@ant-design/icons/CloseOutlined';
|
|
8
|
+
import EditOutlined from '@ant-design/icons/EditOutlined';
|
|
9
|
+
import {
|
|
10
|
+
CellProps,
|
|
11
|
+
Translator,
|
|
12
|
+
JsonFormsCellRendererRegistryEntry,
|
|
13
|
+
JsonFormsRendererRegistryEntry,
|
|
14
|
+
UISchemaElement,
|
|
15
|
+
} from '@jsonforms/core';
|
|
16
|
+
|
|
17
|
+
/** DispatchCell forwards these, but they are not part of CellProps. */
|
|
18
|
+
type CompositeCellProps = CellProps & {
|
|
19
|
+
renderers?: JsonFormsRendererRegistryEntry[];
|
|
20
|
+
cells?: JsonFormsCellRendererRegistryEntry[];
|
|
21
|
+
/** Supplied by withTranslateProps; every visible string goes through it. */
|
|
22
|
+
t: Translator;
|
|
23
|
+
};
|
|
24
|
+
import {
|
|
25
|
+
JsonFormsDispatch,
|
|
26
|
+
useJsonForms,
|
|
27
|
+
withJsonFormsCellProps,
|
|
28
|
+
withTranslateProps,
|
|
29
|
+
} from '@jsonforms/react';
|
|
30
|
+
import { useConfirmation } from '../util/useConfirmation';
|
|
31
|
+
import { useI18nDefault } from '../util/translate';
|
|
32
|
+
import {
|
|
33
|
+
CompositeDetailDialog,
|
|
34
|
+
CompositeDetailDialogOptions,
|
|
35
|
+
} from './CompositeDetailDialog';
|
|
36
|
+
|
|
37
|
+
const AntdCompositeCell = (props: CompositeCellProps) => {
|
|
38
|
+
const { t } = props;
|
|
39
|
+
const context = useJsonForms();
|
|
40
|
+
const { token } = theme.useToken();
|
|
41
|
+
/*
|
|
42
|
+
The default message carries the locale bundle (§6.5), so it must not be
|
|
43
|
+
read straight out of the English table.
|
|
44
|
+
*/
|
|
45
|
+
const d = useI18nDefault();
|
|
46
|
+
const confirmation = useConfirmation();
|
|
47
|
+
const latest = useRef(props);
|
|
48
|
+
useLayoutEffect(() => {
|
|
49
|
+
latest.current = props;
|
|
50
|
+
}, [props]);
|
|
51
|
+
const [open, setOpen] = useState(false);
|
|
52
|
+
const [active, setActive] = useState(false);
|
|
53
|
+
const options = (props.uischema?.options ??
|
|
54
|
+
{}) as CompositeDetailDialogOptions & {
|
|
55
|
+
summary?: UISchemaElement;
|
|
56
|
+
detail?: UISchemaElement | string;
|
|
57
|
+
clearable?: boolean;
|
|
58
|
+
summaryOnly?: boolean;
|
|
59
|
+
showTypeIndicator?: boolean;
|
|
60
|
+
};
|
|
61
|
+
const { errors, summary } = useCompositeCellPresentation(props, t, d);
|
|
62
|
+
const isArray = Array.isArray(props.data) || props.schema?.type === 'array';
|
|
63
|
+
const label =
|
|
64
|
+
props.schema?.title ??
|
|
65
|
+
(isArray
|
|
66
|
+
? t('composite.itemsLabel', d('composite.itemsLabel'))
|
|
67
|
+
: t('composite.detailsLabel', d('composite.detailsLabel')));
|
|
68
|
+
const translateWithLabel = (key: 'composite.edit' | 'composite.remove') =>
|
|
69
|
+
t(key, d(key), { label }).replace('{label}', label);
|
|
70
|
+
const detail = resolveEditorDetail(
|
|
71
|
+
options.detail,
|
|
72
|
+
context.uischemas ?? [],
|
|
73
|
+
props.schema,
|
|
74
|
+
props.uischema.scope,
|
|
75
|
+
props.path,
|
|
76
|
+
props.rootSchema,
|
|
77
|
+
{ type: 'Control', scope: '#', label: false } as any,
|
|
78
|
+
);
|
|
79
|
+
// Cell removal shares the destructive-change policy.
|
|
80
|
+
const canClear =
|
|
81
|
+
props.enabled &&
|
|
82
|
+
!options.summaryOnly &&
|
|
83
|
+
(options.summary?.type !== 'Label' || !!options.detail) &&
|
|
84
|
+
props.data !== undefined &&
|
|
85
|
+
options.clearable !== false;
|
|
86
|
+
return (
|
|
87
|
+
<div
|
|
88
|
+
style={{ display: 'flex', alignItems: 'center', gap: 6, minWidth: 0 }}
|
|
89
|
+
onMouseEnter={() => setActive(true)}
|
|
90
|
+
onMouseLeave={() => setActive(false)}
|
|
91
|
+
onFocus={() => setActive(true)}
|
|
92
|
+
onBlur={() => setActive(false)}
|
|
93
|
+
>
|
|
94
|
+
{(options.showTypeIndicator ??
|
|
95
|
+
props.config?.showTypeIndicator ??
|
|
96
|
+
false) === true &&
|
|
97
|
+
(isArray || props.schema?.type === 'object') && (
|
|
98
|
+
<span
|
|
99
|
+
aria-hidden='true'
|
|
100
|
+
style={{ flex: 'none', opacity: 0.55, lineHeight: 0 }}
|
|
101
|
+
>
|
|
102
|
+
{isArray ? '[]' : '{}'}
|
|
103
|
+
</span>
|
|
104
|
+
)}
|
|
105
|
+
{/* one line: the row height must not grow with the content */}
|
|
106
|
+
<span
|
|
107
|
+
style={{
|
|
108
|
+
color:
|
|
109
|
+
summary.generated && options.summary?.type !== 'Label'
|
|
110
|
+
? token.colorTextSecondary
|
|
111
|
+
: undefined,
|
|
112
|
+
fontStyle:
|
|
113
|
+
summary.generated && options.summary?.type !== 'Label'
|
|
114
|
+
? 'italic'
|
|
115
|
+
: undefined,
|
|
116
|
+
flex: 1,
|
|
117
|
+
minWidth: 0,
|
|
118
|
+
overflow: 'hidden',
|
|
119
|
+
textOverflow: 'ellipsis',
|
|
120
|
+
whiteSpace: 'nowrap',
|
|
121
|
+
}}
|
|
122
|
+
>
|
|
123
|
+
{options.summary?.type === 'Label' ? (
|
|
124
|
+
<CellSummary
|
|
125
|
+
schema={props.schema}
|
|
126
|
+
path={props.path}
|
|
127
|
+
uischema={options.summary}
|
|
128
|
+
/>
|
|
129
|
+
) : (
|
|
130
|
+
summary.text
|
|
131
|
+
)}
|
|
132
|
+
</span>
|
|
133
|
+
<ValidationIcon
|
|
134
|
+
errorMessages={errors}
|
|
135
|
+
path={props.path}
|
|
136
|
+
id={`${props.path}-cell-errors`}
|
|
137
|
+
/>
|
|
138
|
+
{/* opacity rather than mounting: keeps the row from reflowing on hover */}
|
|
139
|
+
{((!options.summaryOnly && options.summary?.type !== 'Label') ||
|
|
140
|
+
options.detail) && (
|
|
141
|
+
<span
|
|
142
|
+
style={{
|
|
143
|
+
display: 'flex',
|
|
144
|
+
gap: 2,
|
|
145
|
+
flex: 'none',
|
|
146
|
+
opacity: active || open ? 1 : 0,
|
|
147
|
+
transition: 'opacity 0.2s',
|
|
148
|
+
}}
|
|
149
|
+
>
|
|
150
|
+
<Button
|
|
151
|
+
size='small'
|
|
152
|
+
type='text'
|
|
153
|
+
icon={<EditOutlined />}
|
|
154
|
+
onClick={() => setOpen(true)}
|
|
155
|
+
title={translateWithLabel('composite.edit')}
|
|
156
|
+
aria-label={translateWithLabel('composite.edit')}
|
|
157
|
+
/>
|
|
158
|
+
{canClear && (
|
|
159
|
+
<Button
|
|
160
|
+
size='small'
|
|
161
|
+
type='text'
|
|
162
|
+
danger
|
|
163
|
+
icon={<CloseOutlined />}
|
|
164
|
+
onClick={() => {
|
|
165
|
+
const target = props.data;
|
|
166
|
+
const path = props.path;
|
|
167
|
+
confirmation.request({
|
|
168
|
+
catalogId: 'compositeCell',
|
|
169
|
+
operation: 'delete',
|
|
170
|
+
options,
|
|
171
|
+
config: props.config,
|
|
172
|
+
discarded: [target],
|
|
173
|
+
perform: () => {
|
|
174
|
+
const current = latest.current;
|
|
175
|
+
if (
|
|
176
|
+
current.enabled &&
|
|
177
|
+
current.path === path &&
|
|
178
|
+
current.data === target &&
|
|
179
|
+
current.uischema.options?.clearable !== false
|
|
180
|
+
)
|
|
181
|
+
current.handleChange(path, undefined);
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
}}
|
|
185
|
+
title={translateWithLabel('composite.remove')}
|
|
186
|
+
aria-label={translateWithLabel('composite.remove')}
|
|
187
|
+
/>
|
|
188
|
+
)}
|
|
189
|
+
</span>
|
|
190
|
+
)}
|
|
191
|
+
{confirmation.dialog}
|
|
192
|
+
<CompositeDetailDialog
|
|
193
|
+
open={open}
|
|
194
|
+
title={
|
|
195
|
+
props.schema?.title ??
|
|
196
|
+
t('composite.detailsTitle', d('composite.detailsTitle'))
|
|
197
|
+
}
|
|
198
|
+
label={label}
|
|
199
|
+
path={props.path}
|
|
200
|
+
schema={props.schema}
|
|
201
|
+
enabled={Boolean(props.enabled)}
|
|
202
|
+
options={options}
|
|
203
|
+
t={t}
|
|
204
|
+
onClose={() => setOpen(false)}
|
|
205
|
+
onApply={(value) => props.handleChange(props.path, value)}
|
|
206
|
+
>
|
|
207
|
+
<JsonFormsDispatch
|
|
208
|
+
schema={props.schema}
|
|
209
|
+
uischema={detail}
|
|
210
|
+
path={props.path}
|
|
211
|
+
enabled={props.enabled}
|
|
212
|
+
renderers={props.renderers}
|
|
213
|
+
cells={props.cells}
|
|
214
|
+
/>
|
|
215
|
+
</CompositeDetailDialog>
|
|
216
|
+
</div>
|
|
217
|
+
);
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Structured, mixed and composed values. A catch-all would tie with scalar cells (also
|
|
222
|
+
* rank 1) and win on registration order, swallowing every string column.
|
|
223
|
+
*/
|
|
224
|
+
export { compositeCellTester as antdCompositeCellTester } from '@chobantonov/jsonforms-react-renderer-common/cells/compositeCellTester';
|
|
225
|
+
|
|
226
|
+
export default withJsonFormsCellProps(
|
|
227
|
+
withTranslateProps(AntdCompositeCell) as any,
|
|
228
|
+
);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
CellProps,
|
|
4
|
+
isBooleanControl,
|
|
5
|
+
RankedTester,
|
|
6
|
+
rankWith,
|
|
7
|
+
WithClassname,
|
|
8
|
+
} from '@jsonforms/core';
|
|
9
|
+
import { withJsonFormsCellProps } from '@jsonforms/react';
|
|
10
|
+
import { AntdCheckbox } from '../antd-controls/AntdCheckbox';
|
|
11
|
+
|
|
12
|
+
import { ValidationIcon } from '../complex/ValidationIcon';
|
|
13
|
+
|
|
14
|
+
export const BooleanCell = (props: CellProps & WithClassname) => {
|
|
15
|
+
return props.visible === false ? null : (
|
|
16
|
+
<span style={{ display: 'inline-flex', alignItems: 'center', gap: 4 }}>
|
|
17
|
+
<AntdCheckbox
|
|
18
|
+
{...props}
|
|
19
|
+
inputProps={{ 'aria-invalid': Boolean(props.errors) }}
|
|
20
|
+
/>
|
|
21
|
+
<ValidationIcon
|
|
22
|
+
local
|
|
23
|
+
errorMessages={props.errors}
|
|
24
|
+
path={props.path}
|
|
25
|
+
id={`${props.id}-error`}
|
|
26
|
+
/>
|
|
27
|
+
</span>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const booleanCellTester: RankedTester = rankWith(2, isBooleanControl);
|
|
32
|
+
|
|
33
|
+
export default withJsonFormsCellProps(BooleanCell);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
and,
|
|
4
|
+
CellProps,
|
|
5
|
+
isBooleanControl,
|
|
6
|
+
optionIs,
|
|
7
|
+
RankedTester,
|
|
8
|
+
rankWith,
|
|
9
|
+
WithClassname,
|
|
10
|
+
} from '@jsonforms/core';
|
|
11
|
+
import { withJsonFormsCellProps } from '@jsonforms/react';
|
|
12
|
+
import { AntdToggle } from '../antd-controls/AntdToggle';
|
|
13
|
+
|
|
14
|
+
import { ValidationIcon } from '../complex/ValidationIcon';
|
|
15
|
+
|
|
16
|
+
const BooleanToggleCell = (props: CellProps & WithClassname) => {
|
|
17
|
+
return props.visible === false ? null : (
|
|
18
|
+
<span style={{ display: 'inline-flex', alignItems: 'center', gap: 4 }}>
|
|
19
|
+
<AntdToggle
|
|
20
|
+
{...props}
|
|
21
|
+
inputProps={{ 'aria-invalid': Boolean(props.errors) }}
|
|
22
|
+
/>
|
|
23
|
+
<ValidationIcon
|
|
24
|
+
local
|
|
25
|
+
errorMessages={props.errors}
|
|
26
|
+
path={props.path}
|
|
27
|
+
id={`${props.id}-error`}
|
|
28
|
+
/>
|
|
29
|
+
</span>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const booleanToggleCellTester: RankedTester = rankWith(
|
|
34
|
+
3,
|
|
35
|
+
and(isBooleanControl, optionIs('toggle', true)),
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
export default withJsonFormsCellProps(BooleanToggleCell);
|