@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,287 @@
|
|
|
1
|
+
import DeleteOutlined from '@ant-design/icons/DeleteOutlined';
|
|
2
|
+
import EditOutlined from '@ant-design/icons/EditOutlined';
|
|
3
|
+
import EyeInvisibleOutlined from '@ant-design/icons/EyeInvisibleOutlined';
|
|
4
|
+
import EyeOutlined from '@ant-design/icons/EyeOutlined';
|
|
5
|
+
import { Button, Flex, Input, Tooltip, Tree, Typography } from 'antd';
|
|
6
|
+
import type { DataNode } from 'antd/es/tree';
|
|
7
|
+
import { useI18n } from '../../util/translate';
|
|
8
|
+
import React, { useMemo, useState } from 'react';
|
|
9
|
+
import { AntdAdditionalPropertyRenameDialog } from '../additionalProperties/AntdAdditionalPropertyRenameDialog';
|
|
10
|
+
import { AntdJsonTypeIcon } from './AntdJsonTypeIcon';
|
|
11
|
+
import {
|
|
12
|
+
mixedPathKey,
|
|
13
|
+
MixedTreeNode,
|
|
14
|
+
MixedTreePath,
|
|
15
|
+
mixedTreeLabel,
|
|
16
|
+
} from './mixedTree';
|
|
17
|
+
|
|
18
|
+
export interface AntdMixedTreeProps {
|
|
19
|
+
domainTree?: boolean;
|
|
20
|
+
renderIndicator?: (node: MixedTreeNode) => React.ReactNode;
|
|
21
|
+
canDelete: (node: MixedTreeNode) => boolean;
|
|
22
|
+
canRename: (node: MixedTreeNode) => boolean;
|
|
23
|
+
onDelete: (node: MixedTreeNode) => void;
|
|
24
|
+
onRename: (node: MixedTreeNode, nextName: string) => void;
|
|
25
|
+
onSelect: (node: MixedTreeNode) => void;
|
|
26
|
+
root: MixedTreeNode;
|
|
27
|
+
selectedPath: MixedTreePath;
|
|
28
|
+
validateRename: (node: MixedTreeNode, nextName: string) => string | undefined;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const containsSearch = (node: MixedTreeNode, search: string): boolean =>
|
|
32
|
+
mixedTreeLabel(node).toLowerCase().includes(search) ||
|
|
33
|
+
node.children.some((child) => containsSearch(child, search));
|
|
34
|
+
|
|
35
|
+
export const AntdMixedTree = ({
|
|
36
|
+
domainTree,
|
|
37
|
+
renderIndicator,
|
|
38
|
+
canDelete,
|
|
39
|
+
canRename,
|
|
40
|
+
onDelete,
|
|
41
|
+
onRename,
|
|
42
|
+
onSelect,
|
|
43
|
+
root,
|
|
44
|
+
selectedPath,
|
|
45
|
+
validateRename,
|
|
46
|
+
}: AntdMixedTreeProps) => {
|
|
47
|
+
const t = useI18n();
|
|
48
|
+
const [search, setSearch] = useState('');
|
|
49
|
+
const [showPrimitives, setShowPrimitives] = useState(false);
|
|
50
|
+
const [expandedKeys, setExpandedKeys] = useState<React.Key[]>([
|
|
51
|
+
mixedPathKey([]),
|
|
52
|
+
]);
|
|
53
|
+
const [renamingNode, setRenamingNode] = useState<MixedTreeNode | null>(null);
|
|
54
|
+
const [renameValue, setRenameValue] = useState('');
|
|
55
|
+
const normalizedSearch = search.trim().toLowerCase();
|
|
56
|
+
const nodeMap = new Map<string, MixedTreeNode>();
|
|
57
|
+
const renameError = renamingNode
|
|
58
|
+
? validateRename(renamingNode, renameValue.trim())
|
|
59
|
+
: undefined;
|
|
60
|
+
const searchExpandedKeys = useMemo(() => {
|
|
61
|
+
if (!normalizedSearch) return [];
|
|
62
|
+
const keys: React.Key[] = [];
|
|
63
|
+
const collectMatchingBranches = (node: MixedTreeNode) => {
|
|
64
|
+
if (!containsSearch(node, normalizedSearch)) return;
|
|
65
|
+
if (node.type === 'object' || node.type === 'array') {
|
|
66
|
+
keys.push(mixedPathKey(node.path));
|
|
67
|
+
}
|
|
68
|
+
node.children.forEach(collectMatchingBranches);
|
|
69
|
+
};
|
|
70
|
+
collectMatchingBranches(root);
|
|
71
|
+
return keys;
|
|
72
|
+
}, [normalizedSearch, root]);
|
|
73
|
+
|
|
74
|
+
const selectedKey = JSON.stringify(selectedPath);
|
|
75
|
+
const [previousSelectedKey, setPreviousSelectedKey] = useState<string>();
|
|
76
|
+
if (previousSelectedKey !== selectedKey) {
|
|
77
|
+
setPreviousSelectedKey(selectedKey);
|
|
78
|
+
const ancestorKeys = selectedPath.map((_, index) =>
|
|
79
|
+
mixedPathKey(selectedPath.slice(0, index)),
|
|
80
|
+
);
|
|
81
|
+
setExpandedKeys((current) => [
|
|
82
|
+
...new Set([...current, mixedPathKey([]), ...ancestorKeys]),
|
|
83
|
+
]);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const closeRename = () => {
|
|
87
|
+
setRenamingNode(null);
|
|
88
|
+
setRenameValue('');
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
const toDataNode = (node: MixedTreeNode): DataNode | null => {
|
|
92
|
+
const structured = node.type === 'object' || node.type === 'array';
|
|
93
|
+
if (
|
|
94
|
+
node.path.length > 0 &&
|
|
95
|
+
!structured &&
|
|
96
|
+
!showPrimitives &&
|
|
97
|
+
mixedPathKey(selectedPath) !== mixedPathKey(node.path) &&
|
|
98
|
+
!normalizedSearch
|
|
99
|
+
) {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
if (normalizedSearch && !containsSearch(node, normalizedSearch))
|
|
103
|
+
return null;
|
|
104
|
+
const key = mixedPathKey(node.path);
|
|
105
|
+
nodeMap.set(key, node);
|
|
106
|
+
const rootNode = node.path.length === 0;
|
|
107
|
+
const deletable = !rootNode && canDelete(node);
|
|
108
|
+
const renameable = (!rootNode || domainTree) && canRename(node);
|
|
109
|
+
return {
|
|
110
|
+
icon: <AntdJsonTypeIcon type={node.type} />,
|
|
111
|
+
key,
|
|
112
|
+
title: (
|
|
113
|
+
<Flex
|
|
114
|
+
align='center'
|
|
115
|
+
className='jsonforms-mixed-tree-row'
|
|
116
|
+
gap={4}
|
|
117
|
+
data-recursive-node={domainTree ? mixedPathKey(node.path) : undefined}
|
|
118
|
+
>
|
|
119
|
+
{rootNode && !domainTree ? null : (
|
|
120
|
+
<Typography.Text
|
|
121
|
+
className='jsonforms-mixed-tree-label'
|
|
122
|
+
ellipsis={{ tooltip: mixedTreeLabel(node) }}
|
|
123
|
+
>
|
|
124
|
+
{mixedTreeLabel(node)}
|
|
125
|
+
</Typography.Text>
|
|
126
|
+
)}
|
|
127
|
+
{renderIndicator?.(node)}
|
|
128
|
+
<Flex
|
|
129
|
+
className={`jsonforms-mixed-tree-actions${
|
|
130
|
+
rootNode && !domainTree ? ' root-actions' : ''
|
|
131
|
+
}`}
|
|
132
|
+
gap={2}
|
|
133
|
+
>
|
|
134
|
+
{rootNode && !domainTree ? (
|
|
135
|
+
<Tooltip
|
|
136
|
+
title={t(
|
|
137
|
+
showPrimitives
|
|
138
|
+
? 'mixed.hidePrimitives'
|
|
139
|
+
: 'mixed.showPrimitives',
|
|
140
|
+
)}
|
|
141
|
+
>
|
|
142
|
+
<Button
|
|
143
|
+
aria-label={t(
|
|
144
|
+
showPrimitives
|
|
145
|
+
? 'mixed.hidePrimitives'
|
|
146
|
+
: 'mixed.showPrimitives',
|
|
147
|
+
)}
|
|
148
|
+
icon={
|
|
149
|
+
showPrimitives ? <EyeOutlined /> : <EyeInvisibleOutlined />
|
|
150
|
+
}
|
|
151
|
+
onClick={(event) => {
|
|
152
|
+
event.stopPropagation();
|
|
153
|
+
setShowPrimitives((current) => !current);
|
|
154
|
+
}}
|
|
155
|
+
size='small'
|
|
156
|
+
type='text'
|
|
157
|
+
/>
|
|
158
|
+
</Tooltip>
|
|
159
|
+
) : null}
|
|
160
|
+
{renameable ? (
|
|
161
|
+
<Tooltip title={t('mixed.rename')}>
|
|
162
|
+
<Button
|
|
163
|
+
aria-label={t('mixed.renameNamed', {
|
|
164
|
+
name: mixedTreeLabel(node),
|
|
165
|
+
})}
|
|
166
|
+
icon={<EditOutlined />}
|
|
167
|
+
onClick={(event) => {
|
|
168
|
+
event.stopPropagation();
|
|
169
|
+
setRenamingNode(node);
|
|
170
|
+
setRenameValue(
|
|
171
|
+
domainTree
|
|
172
|
+
? node.label
|
|
173
|
+
: String(node.path[node.path.length - 1]),
|
|
174
|
+
);
|
|
175
|
+
}}
|
|
176
|
+
size='small'
|
|
177
|
+
type='text'
|
|
178
|
+
/>
|
|
179
|
+
</Tooltip>
|
|
180
|
+
) : null}
|
|
181
|
+
{deletable ? (
|
|
182
|
+
<Tooltip title={t('mixed.delete')}>
|
|
183
|
+
<Button
|
|
184
|
+
aria-label={t('mixed.deleteNamed', {
|
|
185
|
+
name: mixedTreeLabel(node),
|
|
186
|
+
})}
|
|
187
|
+
danger
|
|
188
|
+
icon={<DeleteOutlined />}
|
|
189
|
+
onClick={(event) => {
|
|
190
|
+
event.stopPropagation();
|
|
191
|
+
/*
|
|
192
|
+
Every node goes through the host's `onDelete`, including a
|
|
193
|
+
structured one with children. This used to raise its own
|
|
194
|
+
modal for that case, which is now a second prompt on top
|
|
195
|
+
of the shared section 14 one - and an unconfigurable one,
|
|
196
|
+
so `confirmation: { delete: "never" }` could not silence
|
|
197
|
+
it.
|
|
198
|
+
*/
|
|
199
|
+
onDelete(node);
|
|
200
|
+
}}
|
|
201
|
+
size='small'
|
|
202
|
+
type='text'
|
|
203
|
+
/>
|
|
204
|
+
</Tooltip>
|
|
205
|
+
) : null}
|
|
206
|
+
</Flex>
|
|
207
|
+
</Flex>
|
|
208
|
+
),
|
|
209
|
+
children: node.children
|
|
210
|
+
.map(toDataNode)
|
|
211
|
+
.filter((child): child is DataNode => Boolean(child)),
|
|
212
|
+
};
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
const treeData = [toDataNode(root)].filter((node): node is DataNode =>
|
|
216
|
+
Boolean(node),
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
return (
|
|
220
|
+
<Flex className='jsonforms-mixed-tree' vertical gap='small'>
|
|
221
|
+
<style>{`
|
|
222
|
+
.jsonforms-mixed-tree .ant-tree-treenode { align-items: center; display: flex; width: 100%; }
|
|
223
|
+
.jsonforms-mixed-tree .ant-tree-indent-unit { width: 20px; }
|
|
224
|
+
.jsonforms-mixed-tree .ant-tree-node-content-wrapper { display: flex; flex: 1 1 auto; min-width: 0; }
|
|
225
|
+
.jsonforms-mixed-tree .ant-tree-iconEle { flex: 0 0 24px; margin-inline-end: 0; text-align: center; }
|
|
226
|
+
.jsonforms-mixed-tree .ant-tree-title { display: block; flex: 1 1 auto; min-width: 0; }
|
|
227
|
+
.jsonforms-mixed-tree .ant-tree-list-holder-inner { min-width: max-content; }
|
|
228
|
+
.jsonforms-mixed-tree-row { min-width: 0; width: 100%; }
|
|
229
|
+
.jsonforms-mixed-tree-label { min-width: 0; flex: 1 1 auto; }
|
|
230
|
+
.jsonforms-mixed-tree-actions { margin-inline-start: auto; flex: 0 0 auto; opacity: 0; visibility: hidden; }
|
|
231
|
+
.jsonforms-mixed-tree-actions.root-actions,
|
|
232
|
+
.ant-tree-node-content-wrapper:hover .jsonforms-mixed-tree-actions,
|
|
233
|
+
.ant-tree-node-content-wrapper:focus-within .jsonforms-mixed-tree-actions { opacity: 1; visibility: visible; }
|
|
234
|
+
.jsonforms-mixed-tree-actions .ant-btn { height: 24px; padding: 0; width: 24px; }
|
|
235
|
+
.jsonforms-mixed-tree-type-icon { align-items: center; display: inline-flex; justify-content: center; width: 20px; }
|
|
236
|
+
`}</style>
|
|
237
|
+
<Input.Search
|
|
238
|
+
allowClear
|
|
239
|
+
aria-label={t('mixed.searchLabel')}
|
|
240
|
+
onChange={(event) => setSearch(event.currentTarget.value)}
|
|
241
|
+
placeholder={t('mixed.searchPlaceholder')}
|
|
242
|
+
value={search}
|
|
243
|
+
/>
|
|
244
|
+
<Tree
|
|
245
|
+
aria-label={t('mixed.treeLabel')}
|
|
246
|
+
autoExpandParent={Boolean(normalizedSearch)}
|
|
247
|
+
blockNode
|
|
248
|
+
expandedKeys={normalizedSearch ? searchExpandedKeys : expandedKeys}
|
|
249
|
+
onExpand={(keys) => setExpandedKeys(keys)}
|
|
250
|
+
onSelect={(keys) => {
|
|
251
|
+
const node = keys[0] ? nodeMap.get(String(keys[0])) : undefined;
|
|
252
|
+
if (node) onSelect(node);
|
|
253
|
+
}}
|
|
254
|
+
selectedKeys={[mixedPathKey(selectedPath)]}
|
|
255
|
+
showIcon
|
|
256
|
+
treeData={treeData}
|
|
257
|
+
/>
|
|
258
|
+
<AntdAdditionalPropertyRenameDialog
|
|
259
|
+
disabled={
|
|
260
|
+
!renamingNode ||
|
|
261
|
+
Boolean(renameError) ||
|
|
262
|
+
!renameValue.trim() ||
|
|
263
|
+
renameValue.trim() ===
|
|
264
|
+
(domainTree
|
|
265
|
+
? renamingNode.label
|
|
266
|
+
: String(renamingNode.path[renamingNode.path.length - 1]))
|
|
267
|
+
}
|
|
268
|
+
error={renameError}
|
|
269
|
+
oldName={
|
|
270
|
+
renamingNode
|
|
271
|
+
? domainTree
|
|
272
|
+
? renamingNode.label
|
|
273
|
+
: String(renamingNode.path[renamingNode.path.length - 1])
|
|
274
|
+
: null
|
|
275
|
+
}
|
|
276
|
+
onCancel={closeRename}
|
|
277
|
+
onChange={setRenameValue}
|
|
278
|
+
onRename={() => {
|
|
279
|
+
if (!renamingNode || renameError) return;
|
|
280
|
+
onRename(renamingNode, renameValue.trim());
|
|
281
|
+
closeRename();
|
|
282
|
+
}}
|
|
283
|
+
value={renameValue}
|
|
284
|
+
/>
|
|
285
|
+
</Flex>
|
|
286
|
+
);
|
|
287
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { useTranslator } from '@chobantonov/jsonforms-react-renderer-common/locale/translate';
|
|
2
|
+
import { Select, Typography } from 'antd';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { useI18n } from '../../util/translate';
|
|
5
|
+
import { visuallyHidden } from '../../util/visuallyHidden';
|
|
6
|
+
|
|
7
|
+
export interface AntdMixedTypeSelectorProps {
|
|
8
|
+
clearable?: boolean;
|
|
9
|
+
disabled: boolean;
|
|
10
|
+
error?: string;
|
|
11
|
+
fullWidth?: boolean;
|
|
12
|
+
onChange: (value: string | undefined) => void;
|
|
13
|
+
required?: boolean;
|
|
14
|
+
types: string[];
|
|
15
|
+
value: string | null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const AntdMixedTypeSelector = ({
|
|
19
|
+
clearable = true,
|
|
20
|
+
disabled,
|
|
21
|
+
error,
|
|
22
|
+
fullWidth = false,
|
|
23
|
+
onChange,
|
|
24
|
+
required,
|
|
25
|
+
types,
|
|
26
|
+
value,
|
|
27
|
+
}: AntdMixedTypeSelectorProps) => {
|
|
28
|
+
const t = useI18n();
|
|
29
|
+
const translateType = useTranslator();
|
|
30
|
+
return (
|
|
31
|
+
<div
|
|
32
|
+
className={
|
|
33
|
+
fullWidth
|
|
34
|
+
? 'jsonforms-mixed-type-selector jsonforms-mixed-type-selector-full-width'
|
|
35
|
+
: 'jsonforms-mixed-type-selector'
|
|
36
|
+
}
|
|
37
|
+
style={{ minWidth: 140, width: fullWidth ? '100%' : undefined }}
|
|
38
|
+
>
|
|
39
|
+
<Select
|
|
40
|
+
allowClear={clearable}
|
|
41
|
+
aria-label={t('mixed.typeLabel')}
|
|
42
|
+
disabled={disabled}
|
|
43
|
+
onChange={onChange}
|
|
44
|
+
options={types.map((type) => ({
|
|
45
|
+
label: translateType(`mixed.type.${type}`, type),
|
|
46
|
+
value: type,
|
|
47
|
+
}))}
|
|
48
|
+
placeholder={t('mixed.typePlaceholder')}
|
|
49
|
+
popupMatchSelectWidth={false}
|
|
50
|
+
status={error ? 'error' : undefined}
|
|
51
|
+
value={value ?? undefined}
|
|
52
|
+
style={{ width: '100%' }}
|
|
53
|
+
/>
|
|
54
|
+
{error ? <Typography.Text type='danger'>{error}</Typography.Text> : null}
|
|
55
|
+
{required ? (
|
|
56
|
+
<span style={visuallyHidden}>{t('mixed.required')}</span>
|
|
57
|
+
) : null}
|
|
58
|
+
</div>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useI18n } from '../../util/translate';
|
|
2
|
+
import EyeOutlined from '@ant-design/icons/EyeOutlined';
|
|
3
|
+
import { Button, Flex, Tooltip, Typography } from 'antd';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
|
|
6
|
+
export const AntdNestedMixedNavigation = ({
|
|
7
|
+
description,
|
|
8
|
+
label,
|
|
9
|
+
onView,
|
|
10
|
+
selector,
|
|
11
|
+
}: {
|
|
12
|
+
description?: string;
|
|
13
|
+
label?: string;
|
|
14
|
+
onView: () => void;
|
|
15
|
+
selector: React.ReactNode;
|
|
16
|
+
}) => {
|
|
17
|
+
const t = useI18n();
|
|
18
|
+
return (
|
|
19
|
+
<Flex className='jsonforms-mixed-nested-navigation' vertical gap={4}>
|
|
20
|
+
{label ? <Typography.Text>{label}</Typography.Text> : null}
|
|
21
|
+
<Flex align='center' gap='small'>
|
|
22
|
+
{selector}
|
|
23
|
+
<Tooltip
|
|
24
|
+
title={t('mixed.view', { label: label || t('control.value') })}
|
|
25
|
+
>
|
|
26
|
+
<Button
|
|
27
|
+
aria-label={t('mixed.view', { label: label || t('control.value') })}
|
|
28
|
+
icon={<EyeOutlined />}
|
|
29
|
+
onClick={onView}
|
|
30
|
+
size='small'
|
|
31
|
+
/>
|
|
32
|
+
</Tooltip>
|
|
33
|
+
</Flex>
|
|
34
|
+
{description ? (
|
|
35
|
+
<Typography.Text type='secondary'>{description}</Typography.Text>
|
|
36
|
+
) : null}
|
|
37
|
+
</Flex>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AllOfRenderer } from '@chobantonov/jsonforms-react-renderer-common/composition/AllOfRenderer';
|
|
2
|
+
import { AnyOfRenderer } from './AnyOfRenderer';
|
|
3
|
+
import { ArrayControlRenderer } from './ArrayControlRenderer';
|
|
4
|
+
import { EnumArrayRenderer } from './EnumArrayRenderer';
|
|
5
|
+
import { ObjectRenderer } from './ObjectRenderer';
|
|
6
|
+
import { OneOfRenderer } from './OneOfRenderer';
|
|
7
|
+
|
|
8
|
+
export const UnwrappedComplex = {
|
|
9
|
+
AllOfRenderer,
|
|
10
|
+
AnyOfRenderer,
|
|
11
|
+
ArrayControlRenderer,
|
|
12
|
+
EnumArrayRenderer,
|
|
13
|
+
ObjectRenderer,
|
|
14
|
+
OneOfRenderer,
|
|
15
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import {
|
|
2
|
+
and,
|
|
3
|
+
ControlProps,
|
|
4
|
+
ControlState,
|
|
5
|
+
EnumCellProps,
|
|
6
|
+
JsonSchema,
|
|
7
|
+
RankedTester,
|
|
8
|
+
rankWith,
|
|
9
|
+
schemaMatches,
|
|
10
|
+
uiTypeIs,
|
|
11
|
+
WithClassname,
|
|
12
|
+
} from '@jsonforms/core';
|
|
13
|
+
import { Control, withJsonFormsControlProps } from '@jsonforms/react';
|
|
14
|
+
import merge from 'lodash/merge';
|
|
15
|
+
import React, { useMemo, useState } from 'react';
|
|
16
|
+
import { useDebouncedChange } from '../util';
|
|
17
|
+
import { InputControl } from './InputControl';
|
|
18
|
+
import { AutoComplete } from 'antd';
|
|
19
|
+
|
|
20
|
+
interface AutoCompleteOption {
|
|
21
|
+
value: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const findEnumSchema = (schemas: JsonSchema[]) =>
|
|
25
|
+
schemas.find(
|
|
26
|
+
(s) =>
|
|
27
|
+
s.enum !== undefined && (s.type === 'string' || s.type === undefined),
|
|
28
|
+
);
|
|
29
|
+
const findTextSchema = (schemas: JsonSchema[]) =>
|
|
30
|
+
schemas.find((s) => s.type === 'string' && s.enum === undefined);
|
|
31
|
+
|
|
32
|
+
const AntdAutocompleteInputText = (props: EnumCellProps & WithClassname) => {
|
|
33
|
+
const {
|
|
34
|
+
data,
|
|
35
|
+
config,
|
|
36
|
+
className,
|
|
37
|
+
id,
|
|
38
|
+
enabled,
|
|
39
|
+
uischema,
|
|
40
|
+
path,
|
|
41
|
+
handleChange,
|
|
42
|
+
schema,
|
|
43
|
+
} = props;
|
|
44
|
+
const enumSchema = findEnumSchema(schema.anyOf ?? []);
|
|
45
|
+
const stringSchema = findTextSchema(schema.anyOf ?? []);
|
|
46
|
+
const maxLength = stringSchema?.maxLength;
|
|
47
|
+
const appliedUiSchemaOptions = useMemo(
|
|
48
|
+
() => merge({}, config, uischema.options),
|
|
49
|
+
[config, uischema.options],
|
|
50
|
+
);
|
|
51
|
+
const options: AutoCompleteOption[] = (enumSchema?.enum ?? []).map(
|
|
52
|
+
(value) => ({
|
|
53
|
+
value,
|
|
54
|
+
}),
|
|
55
|
+
);
|
|
56
|
+
const [filteredOptions, setFilteredOptions] =
|
|
57
|
+
useState<AutoCompleteOption[]>(options);
|
|
58
|
+
const [inputText, onChange] = useDebouncedChange(
|
|
59
|
+
handleChange,
|
|
60
|
+
'',
|
|
61
|
+
data,
|
|
62
|
+
path,
|
|
63
|
+
(ev: any) => ev || undefined,
|
|
64
|
+
);
|
|
65
|
+
const onSearch = (searchText: string) => {
|
|
66
|
+
setFilteredOptions(
|
|
67
|
+
!searchText
|
|
68
|
+
? options
|
|
69
|
+
: options.filter((option) =>
|
|
70
|
+
option.value.toLowerCase().includes(searchText),
|
|
71
|
+
),
|
|
72
|
+
);
|
|
73
|
+
};
|
|
74
|
+
const inputStyle = { width: '100%' };
|
|
75
|
+
return (
|
|
76
|
+
<AutoComplete
|
|
77
|
+
value={inputText}
|
|
78
|
+
onSearch={onSearch}
|
|
79
|
+
onChange={onChange}
|
|
80
|
+
onSelect={onChange}
|
|
81
|
+
options={filteredOptions}
|
|
82
|
+
className={className}
|
|
83
|
+
id={id}
|
|
84
|
+
disabled={!enabled}
|
|
85
|
+
autoFocus={appliedUiSchemaOptions.focus}
|
|
86
|
+
maxLength={maxLength}
|
|
87
|
+
style={inputStyle}
|
|
88
|
+
allowClear={enabled}
|
|
89
|
+
/>
|
|
90
|
+
);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export class AnyOfStringOrEnumControl extends Control<
|
|
94
|
+
ControlProps,
|
|
95
|
+
ControlState
|
|
96
|
+
> {
|
|
97
|
+
render() {
|
|
98
|
+
return <InputControl {...this.props} input={AntdAutocompleteInputText} />;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const hasEnumAndText = (schemas: JsonSchema[]) => {
|
|
102
|
+
// idea: map to type,enum and check that all types are string and at least one item is of type enum,
|
|
103
|
+
const enumSchema = findEnumSchema(schemas);
|
|
104
|
+
const stringSchema = findTextSchema(schemas);
|
|
105
|
+
const remainingSchemas = schemas.filter(
|
|
106
|
+
(s) => s !== enumSchema || s !== stringSchema,
|
|
107
|
+
);
|
|
108
|
+
const wrongType = remainingSchemas.find((s) => s.type && s.type !== 'string');
|
|
109
|
+
return !!enumSchema && !!stringSchema && !wrongType;
|
|
110
|
+
};
|
|
111
|
+
const simpleAnyOf = and(
|
|
112
|
+
uiTypeIs('Control'),
|
|
113
|
+
schemaMatches(
|
|
114
|
+
(schema) =>
|
|
115
|
+
Object.prototype.hasOwnProperty.call(schema, 'anyOf') &&
|
|
116
|
+
hasEnumAndText(schema.anyOf ?? []),
|
|
117
|
+
),
|
|
118
|
+
);
|
|
119
|
+
export const anyOfStringOrEnumControlTester: RankedTester = rankWith(
|
|
120
|
+
5,
|
|
121
|
+
simpleAnyOf,
|
|
122
|
+
);
|
|
123
|
+
export default withJsonFormsControlProps(AnyOfStringOrEnumControl);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
isBooleanControl,
|
|
4
|
+
RankedTester,
|
|
5
|
+
rankWith,
|
|
6
|
+
ControlProps,
|
|
7
|
+
} from '@jsonforms/core';
|
|
8
|
+
import { withJsonFormsControlProps } from '@jsonforms/react';
|
|
9
|
+
import { AntdCheckbox } from '../antd-controls/AntdCheckbox';
|
|
10
|
+
import { InputControl } from './InputControl';
|
|
11
|
+
|
|
12
|
+
export const BooleanControl = (props: ControlProps) => (
|
|
13
|
+
<InputControl {...props} input={AntdCheckbox} />
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
export const booleanControlTester: RankedTester = rankWith(2, isBooleanControl);
|
|
17
|
+
export default withJsonFormsControlProps(BooleanControl);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ControlProps,
|
|
3
|
+
RankedTester,
|
|
4
|
+
and,
|
|
5
|
+
isBooleanControl,
|
|
6
|
+
optionIs,
|
|
7
|
+
rankWith,
|
|
8
|
+
} from '@jsonforms/core';
|
|
9
|
+
import { withJsonFormsControlProps } from '@jsonforms/react';
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import { AntdToggle } from '../antd-controls/AntdToggle';
|
|
12
|
+
|
|
13
|
+
import { InputControl } from './InputControl';
|
|
14
|
+
|
|
15
|
+
export const BooleanToggleControl = (props: ControlProps) => (
|
|
16
|
+
<InputControl {...props} input={AntdToggle} />
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
export const booleanToggleControlTester: RankedTester = rankWith(
|
|
20
|
+
3,
|
|
21
|
+
and(isBooleanControl, optionIs('toggle', true)),
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
export default withJsonFormsControlProps(BooleanToggleControl);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { theme } from 'antd';
|
|
2
|
+
import { createChoiceCards } from '@chobantonov/jsonforms-react-renderer-common/composition/choiceCards';
|
|
3
|
+
import { useConfirmation } from '../util/useConfirmation';
|
|
4
|
+
export const ChoiceCards = createChoiceCards(useConfirmation, () => {
|
|
5
|
+
const { token } = theme.useToken();
|
|
6
|
+
return {
|
|
7
|
+
border: token.colorBorder,
|
|
8
|
+
selected: token.colorPrimary,
|
|
9
|
+
focus: token.colorPrimary,
|
|
10
|
+
background: token.colorBgContainer,
|
|
11
|
+
error: token.colorError,
|
|
12
|
+
};
|
|
13
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ControlProps,
|
|
3
|
+
RankedTester,
|
|
4
|
+
isDateControl,
|
|
5
|
+
rankWith,
|
|
6
|
+
} from '@jsonforms/core';
|
|
7
|
+
import { withJsonFormsControlProps } from '@jsonforms/react';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { AntdDatePicker } from '../antd-controls/AntdDatePicker';
|
|
10
|
+
|
|
11
|
+
import { InputControl } from './InputControl';
|
|
12
|
+
|
|
13
|
+
export const DateControl = (props: ControlProps) => (
|
|
14
|
+
<InputControl {...props} input={AntdDatePicker} />
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
export const dateControlTester: RankedTester = rankWith(4, isDateControl);
|
|
18
|
+
|
|
19
|
+
export default withJsonFormsControlProps(DateControl);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ControlProps,
|
|
3
|
+
RankedTester,
|
|
4
|
+
isDateTimeControl,
|
|
5
|
+
rankWith,
|
|
6
|
+
} from '@jsonforms/core';
|
|
7
|
+
import { withJsonFormsControlProps } from '@jsonforms/react';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { AntdDateTimePicker } from '../antd-controls/AntdDateTimePicker';
|
|
10
|
+
|
|
11
|
+
import { InputControl } from './InputControl';
|
|
12
|
+
|
|
13
|
+
export const DateTimeControl = (props: ControlProps) => (
|
|
14
|
+
<InputControl {...props} input={AntdDateTimePicker} />
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
export const dateTimeControlTester: RankedTester = rankWith(
|
|
18
|
+
2,
|
|
19
|
+
isDateTimeControl,
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export default withJsonFormsControlProps(DateTimeControl);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ControlProps,
|
|
3
|
+
isEnumControl,
|
|
4
|
+
OwnPropsOfEnum,
|
|
5
|
+
RankedTester,
|
|
6
|
+
rankWith,
|
|
7
|
+
} from '@jsonforms/core';
|
|
8
|
+
import {
|
|
9
|
+
TranslateProps,
|
|
10
|
+
withJsonFormsEnumProps,
|
|
11
|
+
withTranslateProps,
|
|
12
|
+
} from '@jsonforms/react';
|
|
13
|
+
import React from 'react';
|
|
14
|
+
import { AntdSelect } from '../antd-controls/AntdSelect';
|
|
15
|
+
import { InputControl } from './InputControl';
|
|
16
|
+
|
|
17
|
+
export const EnumControl = (
|
|
18
|
+
props: ControlProps & OwnPropsOfEnum & TranslateProps,
|
|
19
|
+
) => {
|
|
20
|
+
return <InputControl {...props} input={AntdSelect} />;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const enumControlTester: RankedTester = rankWith(2, isEnumControl);
|
|
24
|
+
|
|
25
|
+
// HOC order can be reversed with https://github.com/eclipsesource/jsonforms/issues/1987
|
|
26
|
+
export default withJsonFormsEnumProps(
|
|
27
|
+
withTranslateProps(React.memo(EnumControl)),
|
|
28
|
+
false,
|
|
29
|
+
);
|