@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.
Files changed (312) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +103 -2
  3. package/lib/additional/LabelRenderer.d.ts +13 -0
  4. package/lib/additional/ListWithDetailMasterItem.d.ts +9 -0
  5. package/lib/additional/ListWithDetailRenderer.d.ts +8 -0
  6. package/lib/additional/index.d.ts +4 -0
  7. package/lib/additional/unwrapped.d.ts +6 -0
  8. package/lib/antd-controls/AntdCheckbox.d.ts +10 -0
  9. package/lib/antd-controls/AntdClearValueButton.d.ts +44 -0
  10. package/lib/antd-controls/AntdClearableInput.d.ts +19 -0
  11. package/lib/antd-controls/AntdDatePicker.d.ts +7 -0
  12. package/lib/antd-controls/AntdDateTimePicker.d.ts +7 -0
  13. package/lib/antd-controls/AntdFile.d.ts +7 -0
  14. package/lib/antd-controls/AntdInputInteger.d.ts +3 -0
  15. package/lib/antd-controls/AntdInputNumber.d.ts +3 -0
  16. package/lib/antd-controls/AntdInputNumberFormat.d.ts +6 -0
  17. package/lib/antd-controls/AntdInputText.d.ts +6 -0
  18. package/lib/antd-controls/AntdNumericInput.d.ts +9 -0
  19. package/lib/antd-controls/AntdOtp.d.ts +33 -0
  20. package/lib/antd-controls/AntdPassword.d.ts +6 -0
  21. package/lib/antd-controls/AntdRadioGroup.d.ts +6 -0
  22. package/lib/antd-controls/AntdRevealButton.d.ts +32 -0
  23. package/lib/antd-controls/AntdSelect.d.ts +7 -0
  24. package/lib/antd-controls/AntdSlider.d.ts +21 -0
  25. package/lib/antd-controls/AntdTimePicker.d.ts +6 -0
  26. package/lib/antd-controls/AntdToggle.d.ts +6 -0
  27. package/lib/antd-controls/FileFeedback.d.ts +6 -0
  28. package/lib/antd-controls/index.d.ts +18 -0
  29. package/lib/antd-controls/useTemporalPicker.d.ts +49 -0
  30. package/lib/cells/AntdCompositeCell.d.ts +8 -0
  31. package/lib/cells/BooleanCell.d.ts +6 -0
  32. package/lib/cells/BooleanToggleCell.d.ts +5 -0
  33. package/lib/cells/CompositeDetailDialog.d.ts +15 -0
  34. package/lib/cells/CustomizableCells.d.ts +9 -0
  35. package/lib/cells/DateCell.d.ts +6 -0
  36. package/lib/cells/EnumCell.d.ts +11 -0
  37. package/lib/cells/IntegerCell.d.ts +6 -0
  38. package/lib/cells/NumberCell.d.ts +10 -0
  39. package/lib/cells/NumberFormatCell.d.ts +10 -0
  40. package/lib/cells/OneOfEnumCell.d.ts +11 -0
  41. package/lib/cells/PasswordCell.d.ts +5 -0
  42. package/lib/cells/TextCell.d.ts +10 -0
  43. package/lib/cells/TimeCell.d.ts +6 -0
  44. package/lib/cells/index.d.ts +14 -0
  45. package/lib/complex/AdditionalProperties.d.ts +4 -0
  46. package/lib/complex/AnyOfRenderer.d.ts +31 -0
  47. package/lib/complex/ArrayControlRenderer.d.ts +8 -0
  48. package/lib/complex/ChipsControl.d.ts +22 -0
  49. package/lib/complex/CollectionPager.d.ts +5 -0
  50. package/lib/complex/DataCell.d.ts +16 -0
  51. package/lib/complex/DeleteDialog.d.ts +14 -0
  52. package/lib/complex/DetailModal.d.ts +6 -0
  53. package/lib/complex/EnumArrayRenderer.d.ts +6 -0
  54. package/lib/complex/ErrorFeedback.d.ts +6 -0
  55. package/lib/complex/MixedRenderer.d.ts +6 -0
  56. package/lib/complex/MultiSelectControl.d.ts +17 -0
  57. package/lib/complex/ObjectRenderer.d.ts +5 -0
  58. package/lib/complex/OneOfRenderer.d.ts +6 -0
  59. package/lib/complex/OneOfTabRenderer.d.ts +5 -0
  60. package/lib/complex/RecursiveTreeRenderer.d.ts +4 -0
  61. package/lib/complex/RowDetailFrame.d.ts +10 -0
  62. package/lib/complex/ScalarCompositionRenderer.d.ts +4 -0
  63. package/lib/complex/TabSwitchConfirmDialog.d.ts +9 -0
  64. package/lib/complex/TableControl.d.ts +9 -0
  65. package/lib/complex/TableToolbar.d.ts +21 -0
  66. package/lib/complex/TupleAdditionalItems.d.ts +13 -0
  67. package/lib/complex/TupleControlRenderer.d.ts +6 -0
  68. package/lib/complex/TupleField.d.ts +4 -0
  69. package/lib/complex/ValidationIcon.d.ts +8 -0
  70. package/lib/complex/additionalProperties/AntdAdditionalPropertyActions.d.ts +9 -0
  71. package/lib/complex/additionalProperties/AntdAdditionalPropertyRenameDialog.d.ts +11 -0
  72. package/lib/complex/index.d.ts +20 -0
  73. package/lib/complex/mixed/AntdJsonTypeIcon.d.ts +4 -0
  74. package/lib/complex/mixed/AntdMixedNavigationContext.d.ts +5 -0
  75. package/lib/complex/mixed/AntdMixedSplitPane.d.ts +5 -0
  76. package/lib/complex/mixed/AntdMixedTree.d.ts +15 -0
  77. package/lib/complex/mixed/AntdMixedTypeSelector.d.ts +12 -0
  78. package/lib/complex/mixed/AntdNestedMixedNavigation.d.ts +7 -0
  79. package/lib/complex/mixed/mixedTree.d.ts +2 -0
  80. package/lib/complex/unwrapped.d.ts +10 -0
  81. package/lib/controls/AnyOfStringOrEnumControl.d.ts +9 -0
  82. package/lib/controls/BooleanControl.d.ts +6 -0
  83. package/lib/controls/BooleanToggleControl.d.ts +6 -0
  84. package/lib/controls/ChoiceCards.d.ts +1 -0
  85. package/lib/controls/DateControl.d.ts +6 -0
  86. package/lib/controls/DateTimeControl.d.ts +6 -0
  87. package/lib/controls/EnumControl.d.ts +7 -0
  88. package/lib/controls/FileControl.d.ts +7 -0
  89. package/lib/controls/InputControl.d.ts +6 -0
  90. package/lib/controls/IntegerControl.d.ts +6 -0
  91. package/lib/controls/NativeControl.d.ts +6 -0
  92. package/lib/controls/NumberControl.d.ts +6 -0
  93. package/lib/controls/OneOfEnumControl.d.ts +7 -0
  94. package/lib/controls/OneOfRadioGroupControl.d.ts +6 -0
  95. package/lib/controls/PasswordControl.d.ts +18 -0
  96. package/lib/controls/PasswordOtpControl.d.ts +38 -0
  97. package/lib/controls/RadioGroup.d.ts +3 -0
  98. package/lib/controls/RadioGroupControl.d.ts +6 -0
  99. package/lib/controls/SliderControl.d.ts +6 -0
  100. package/lib/controls/TextControl.d.ts +6 -0
  101. package/lib/controls/TimeControl.d.ts +6 -0
  102. package/lib/controls/index.d.ts +20 -0
  103. package/lib/controls/unwrapped.d.ts +19 -0
  104. package/lib/index.d.ts +50 -0
  105. package/lib/jsonforms-react-antd.cjs.js +39 -0
  106. package/lib/jsonforms-react-antd.cjs.js.map +1 -0
  107. package/lib/jsonforms-react-antd.esm.js +4235 -0
  108. package/lib/jsonforms-react-antd.esm.js.map +1 -0
  109. package/lib/layouts/ArrayLayout.d.ts +5 -0
  110. package/lib/layouts/ArrayLayoutRenderer.d.ts +8 -0
  111. package/lib/layouts/ArrayPanel.d.ts +7 -0
  112. package/lib/layouts/ArrayToolbar.d.ts +17 -0
  113. package/lib/layouts/CategorizationAccordionLayout.d.ts +21 -0
  114. package/lib/layouts/CategorizationLayout.d.ts +14 -0
  115. package/lib/layouts/CategorizationStepperLayout.d.ts +10 -0
  116. package/lib/layouts/CategoryHeader.d.ts +39 -0
  117. package/lib/layouts/ContainerIndicator.d.ts +37 -0
  118. package/lib/layouts/GroupLayout.d.ts +6 -0
  119. package/lib/layouts/HorizontalLayout.d.ts +10 -0
  120. package/lib/layouts/ValidationIndicator.d.ts +13 -0
  121. package/lib/layouts/VerticalLayout.d.ts +10 -0
  122. package/lib/layouts/arrayTitle.d.ts +2 -0
  123. package/lib/layouts/index.d.ts +11 -0
  124. package/lib/layouts/unwrapped.d.ts +11 -0
  125. package/lib/locale/index.d.ts +1 -0
  126. package/lib/util/additionalPropertyName.d.ts +2 -0
  127. package/lib/util/arrayChoices.d.ts +2 -0
  128. package/lib/util/categoryState.d.ts +3 -0
  129. package/lib/util/cellFrame.d.ts +27 -0
  130. package/lib/util/cellMode.d.ts +29 -0
  131. package/lib/util/clearAffordance.d.ts +1 -0
  132. package/lib/util/combinators.d.ts +1 -0
  133. package/lib/util/compositeActions.d.ts +1 -0
  134. package/lib/util/compositeSummary.d.ts +1 -0
  135. package/lib/util/configNamespaces.d.ts +1 -0
  136. package/lib/util/confirmation.d.ts +2 -0
  137. package/lib/util/datejs.d.ts +4 -0
  138. package/lib/util/debounce.d.ts +1 -0
  139. package/lib/util/dynamicProperties.d.ts +1 -0
  140. package/lib/util/focus.d.ts +1 -0
  141. package/lib/util/groupState.d.ts +1 -0
  142. package/lib/util/index.d.ts +25 -0
  143. package/lib/util/layout.d.ts +18 -0
  144. package/lib/util/layoutSizing.d.ts +6 -0
  145. package/lib/util/literalPropertySchema.d.ts +1 -0
  146. package/lib/util/locale.d.ts +68 -0
  147. package/lib/util/numeric.d.ts +1 -0
  148. package/lib/util/pendingChanges.d.ts +2 -0
  149. package/lib/util/preTouchErrors.d.ts +2 -0
  150. package/lib/util/rendererLocale.d.ts +2 -0
  151. package/lib/util/temporalBounds.d.ts +35 -0
  152. package/lib/util/temporalFormats.d.ts +26 -0
  153. package/lib/util/theme.d.ts +9 -0
  154. package/lib/util/translate.d.ts +1 -0
  155. package/lib/util/tuple.d.ts +2 -0
  156. package/lib/util/useConfirmation.d.ts +7 -0
  157. package/lib/util/validationIndicator.d.ts +2 -0
  158. package/lib/util/visuallyHidden.d.ts +1 -0
  159. package/package.json +89 -3
  160. package/src/additional/LabelRenderer.tsx +21 -0
  161. package/src/additional/ListWithDetailMasterItem.tsx +124 -0
  162. package/src/additional/ListWithDetailRenderer.tsx +243 -0
  163. package/src/additional/index.ts +14 -0
  164. package/src/additional/unwrapped.ts +8 -0
  165. package/src/antd-controls/AntdCheckbox.tsx +56 -0
  166. package/src/antd-controls/AntdClearValueButton.tsx +96 -0
  167. package/src/antd-controls/AntdClearableInput.tsx +63 -0
  168. package/src/antd-controls/AntdDatePicker.tsx +26 -0
  169. package/src/antd-controls/AntdDateTimePicker.tsx +31 -0
  170. package/src/antd-controls/AntdFile.tsx +395 -0
  171. package/src/antd-controls/AntdInputInteger.tsx +10 -0
  172. package/src/antd-controls/AntdInputNumber.tsx +10 -0
  173. package/src/antd-controls/AntdInputNumberFormat.tsx +63 -0
  174. package/src/antd-controls/AntdInputText.tsx +124 -0
  175. package/src/antd-controls/AntdNumericInput.tsx +83 -0
  176. package/src/antd-controls/AntdOtp.tsx +132 -0
  177. package/src/antd-controls/AntdPassword.tsx +106 -0
  178. package/src/antd-controls/AntdRadioGroup.tsx +60 -0
  179. package/src/antd-controls/AntdRevealButton.tsx +74 -0
  180. package/src/antd-controls/AntdSelect.tsx +113 -0
  181. package/src/antd-controls/AntdSlider.tsx +114 -0
  182. package/src/antd-controls/AntdTimePicker.tsx +25 -0
  183. package/src/antd-controls/AntdToggle.tsx +70 -0
  184. package/src/antd-controls/FileFeedback.tsx +37 -0
  185. package/src/antd-controls/index.ts +18 -0
  186. package/src/antd-controls/useTemporalPicker.ts +130 -0
  187. package/src/cells/AntdCompositeCell.tsx +228 -0
  188. package/src/cells/BooleanCell.tsx +33 -0
  189. package/src/cells/BooleanToggleCell.tsx +38 -0
  190. package/src/cells/CompositeDetailDialog.tsx +100 -0
  191. package/src/cells/CustomizableCells.ts +9 -0
  192. package/src/cells/DateCell.tsx +17 -0
  193. package/src/cells/EnumCell.tsx +30 -0
  194. package/src/cells/IntegerCell.tsx +17 -0
  195. package/src/cells/NumberCell.tsx +20 -0
  196. package/src/cells/NumberFormatCell.tsx +37 -0
  197. package/src/cells/OneOfEnumCell.tsx +32 -0
  198. package/src/cells/PasswordCell.tsx +22 -0
  199. package/src/cells/TextCell.tsx +22 -0
  200. package/src/cells/TimeCell.tsx +17 -0
  201. package/src/cells/index.ts +40 -0
  202. package/src/complex/AdditionalProperties.tsx +422 -0
  203. package/src/complex/AnyOfRenderer.tsx +158 -0
  204. package/src/complex/ArrayControlRenderer.tsx +121 -0
  205. package/src/complex/ChipsControl.tsx +205 -0
  206. package/src/complex/CollectionPager.tsx +26 -0
  207. package/src/complex/DataCell.tsx +82 -0
  208. package/src/complex/DeleteDialog.tsx +44 -0
  209. package/src/complex/DetailModal.tsx +110 -0
  210. package/src/complex/EnumArrayRenderer.tsx +148 -0
  211. package/src/complex/ErrorFeedback.tsx +51 -0
  212. package/src/complex/MixedRenderer.tsx +325 -0
  213. package/src/complex/MultiSelectControl.tsx +205 -0
  214. package/src/complex/ObjectRenderer.tsx +55 -0
  215. package/src/complex/OneOfRenderer.tsx +299 -0
  216. package/src/complex/OneOfTabRenderer.tsx +123 -0
  217. package/src/complex/RecursiveTreeRenderer.tsx +20 -0
  218. package/src/complex/RowDetailFrame.tsx +99 -0
  219. package/src/complex/ScalarCompositionRenderer.tsx +14 -0
  220. package/src/complex/TabSwitchConfirmDialog.tsx +36 -0
  221. package/src/complex/TableControl.tsx +646 -0
  222. package/src/complex/TableToolbar.tsx +80 -0
  223. package/src/complex/TupleAdditionalItems.tsx +100 -0
  224. package/src/complex/TupleControlRenderer.tsx +78 -0
  225. package/src/complex/TupleField.tsx +44 -0
  226. package/src/complex/ValidationIcon.tsx +30 -0
  227. package/src/complex/additionalProperties/AntdAdditionalPropertyActions.tsx +56 -0
  228. package/src/complex/additionalProperties/AntdAdditionalPropertyRenameDialog.tsx +56 -0
  229. package/src/complex/index.ts +48 -0
  230. package/src/complex/mixed/AntdJsonTypeIcon.tsx +40 -0
  231. package/src/complex/mixed/AntdMixedNavigationContext.ts +8 -0
  232. package/src/complex/mixed/AntdMixedSplitPane.tsx +51 -0
  233. package/src/complex/mixed/AntdMixedTree.tsx +287 -0
  234. package/src/complex/mixed/AntdMixedTypeSelector.tsx +60 -0
  235. package/src/complex/mixed/AntdNestedMixedNavigation.tsx +39 -0
  236. package/src/complex/mixed/mixedTree.ts +9 -0
  237. package/src/complex/unwrapped.ts +15 -0
  238. package/src/controls/AnyOfStringOrEnumControl.tsx +123 -0
  239. package/src/controls/BooleanControl.tsx +17 -0
  240. package/src/controls/BooleanToggleControl.tsx +24 -0
  241. package/src/controls/ChoiceCards.tsx +13 -0
  242. package/src/controls/DateControl.tsx +19 -0
  243. package/src/controls/DateTimeControl.tsx +22 -0
  244. package/src/controls/EnumControl.tsx +29 -0
  245. package/src/controls/FileControl.tsx +44 -0
  246. package/src/controls/InputControl.tsx +94 -0
  247. package/src/controls/IntegerControl.tsx +16 -0
  248. package/src/controls/NativeControl.tsx +79 -0
  249. package/src/controls/NumberControl.tsx +18 -0
  250. package/src/controls/OneOfEnumControl.tsx +32 -0
  251. package/src/controls/OneOfRadioGroupControl.tsx +25 -0
  252. package/src/controls/PasswordControl.tsx +43 -0
  253. package/src/controls/PasswordOtpControl.tsx +61 -0
  254. package/src/controls/RadioGroup.tsx +8 -0
  255. package/src/controls/RadioGroupControl.tsx +21 -0
  256. package/src/controls/SliderControl.tsx +19 -0
  257. package/src/controls/TextControl.tsx +17 -0
  258. package/src/controls/TimeControl.tsx +20 -0
  259. package/src/controls/index.ts +69 -0
  260. package/src/controls/unwrapped.ts +35 -0
  261. package/src/index.ts +267 -0
  262. package/src/layouts/ArrayLayout.tsx +435 -0
  263. package/src/layouts/ArrayLayoutRenderer.tsx +54 -0
  264. package/src/layouts/ArrayPanel.tsx +51 -0
  265. package/src/layouts/ArrayToolbar.tsx +67 -0
  266. package/src/layouts/CategorizationAccordionLayout.tsx +217 -0
  267. package/src/layouts/CategorizationLayout.tsx +149 -0
  268. package/src/layouts/CategorizationStepperLayout.tsx +164 -0
  269. package/src/layouts/CategoryHeader.tsx +107 -0
  270. package/src/layouts/ContainerIndicator.tsx +83 -0
  271. package/src/layouts/GroupLayout.tsx +307 -0
  272. package/src/layouts/HorizontalLayout.tsx +50 -0
  273. package/src/layouts/ValidationIndicator.tsx +43 -0
  274. package/src/layouts/VerticalLayout.tsx +50 -0
  275. package/src/layouts/arrayTitle.tsx +30 -0
  276. package/src/layouts/index.ts +35 -0
  277. package/src/layouts/unwrapped.ts +17 -0
  278. package/src/locale/index.ts +1 -0
  279. package/src/util/additionalPropertyName.ts +11 -0
  280. package/src/util/arrayChoices.ts +21 -0
  281. package/src/util/categoryState.ts +17 -0
  282. package/src/util/cellFrame.tsx +52 -0
  283. package/src/util/cellMode.tsx +145 -0
  284. package/src/util/clearAffordance.ts +2 -0
  285. package/src/util/combinators.ts +6 -0
  286. package/src/util/compositeActions.ts +2 -0
  287. package/src/util/compositeSummary.ts +2 -0
  288. package/src/util/configNamespaces.ts +4 -0
  289. package/src/util/confirmation.ts +15 -0
  290. package/src/util/datejs.tsx +42 -0
  291. package/src/util/debounce.ts +2 -0
  292. package/src/util/dynamicProperties.ts +6 -0
  293. package/src/util/focus.ts +2 -0
  294. package/src/util/groupState.ts +8 -0
  295. package/src/util/index.ts +25 -0
  296. package/src/util/layout.tsx +121 -0
  297. package/src/util/layoutSizing.ts +33 -0
  298. package/src/util/literalPropertySchema.ts +2 -0
  299. package/src/util/locale.ts +222 -0
  300. package/src/util/numeric.ts +2 -0
  301. package/src/util/pendingChanges.tsx +6 -0
  302. package/src/util/preTouchErrors.ts +10 -0
  303. package/src/util/rendererLocale.ts +10 -0
  304. package/src/util/temporalBounds.ts +106 -0
  305. package/src/util/temporalFormats.ts +95 -0
  306. package/src/util/theme.ts +9 -0
  307. package/src/util/translate.ts +6 -0
  308. package/src/util/tuple.ts +16 -0
  309. package/src/util/uiSchemaCycle.tsx +2 -0
  310. package/src/util/useConfirmation.tsx +25 -0
  311. package/src/util/validationIndicator.ts +10 -0
  312. package/src/util/visuallyHidden.ts +2 -0
@@ -0,0 +1,325 @@
1
+ import {
2
+ MixedNodeControl,
3
+ MixedDetailControl,
4
+ MixedCodeControl,
5
+ } from '@chobantonov/jsonforms-react-renderer-common/mixed/MixedDetailControl';
6
+ import { mixedParentNode } from '@chobantonov/jsonforms-react-renderer-common/mixed/mixedTreeActions';
7
+ import { useMixedRenderer } from '@chobantonov/jsonforms-react-renderer-common/mixed/useMixedRenderer';
8
+ import { ContainerValidationIndicator } from '../layouts/ValidationIndicator';
9
+ import { schemaForType } from '@chobantonov/jsonforms-react-renderer-common/mixed/mixedSchema';
10
+ export {
11
+ schemaForType,
12
+ isArrayElementPath,
13
+ isMixedSchema,
14
+ isMixedControl,
15
+ mixedControlTester,
16
+ } from '@chobantonov/jsonforms-react-renderer-common/mixed/mixedSchema';
17
+ export type { JsonDataType } from '@chobantonov/jsonforms-react-renderer-common/mixed/mixedSchema';
18
+ import { ControlProps, JsonSchema7, resolveSchema } from '@jsonforms/core';
19
+ import { withJsonFormsControlProps } from '@jsonforms/react';
20
+ import { Breadcrumb, Collapse, Flex, Typography } from 'antd';
21
+ import React from 'react';
22
+ import { AntdMixedNavigationContext } from './mixed/AntdMixedNavigationContext';
23
+ import { AntdMixedSplitPane } from './mixed/AntdMixedSplitPane';
24
+ import { useConfirmation } from '../util/useConfirmation';
25
+ import { AntdMixedTree } from './mixed/AntdMixedTree';
26
+ import { AntdMixedTypeSelector } from './mixed/AntdMixedTypeSelector';
27
+ import { AntdNestedMixedNavigation } from './mixed/AntdNestedMixedNavigation';
28
+ import { AntdJsonTypeIcon } from './mixed/AntdJsonTypeIcon';
29
+ import { MixedTreeNode } from './mixed/mixedTree';
30
+
31
+ export const MixedRendererComponent = (props: ControlProps) => {
32
+ const { description, label, path, rootSchema, uischema } = props;
33
+ const confirmation = useConfirmation();
34
+ const model = useMixedRenderer(props, confirmation.request);
35
+ const {
36
+ structuredLayout,
37
+ t,
38
+ collapsible,
39
+ expanded,
40
+ setSelectedPath,
41
+ selectedType,
42
+ tree,
43
+ selectedNode,
44
+ canRenameNode,
45
+ } = model;
46
+ const parentNavigation = React.useContext(AntdMixedNavigationContext);
47
+
48
+ const renderedControl = (
49
+ <MixedDetailControl
50
+ {...model.detailProps}
51
+ selectedType={selectedType}
52
+ selectedSchema={model.selectedSchema}
53
+ />
54
+ );
55
+ const isStructuredType =
56
+ selectedType === 'object' || selectedType === 'array';
57
+
58
+ const selector = <AntdMixedTypeSelector {...model.selectorProps} />;
59
+ if (!props.visible) return null;
60
+
61
+ const validateNodeRename = (node: MixedTreeNode, nextName: string) => {
62
+ const oldName = node.path[node.path.length - 1];
63
+ const parent = mixedParentNode(tree, node);
64
+ if (!nextName) return t('additionalProperties.nameRequired');
65
+ if (!parent || typeof oldName !== 'string' || !canRenameNode(node)) {
66
+ return t('mixed.renameBlocked');
67
+ }
68
+ if (
69
+ nextName.includes('.') ||
70
+ nextName.includes('[') ||
71
+ nextName.includes(']')
72
+ ) {
73
+ return t('additionalProperties.nameInvalid', { name: nextName });
74
+ }
75
+ if (
76
+ parent.data &&
77
+ typeof parent.data === 'object' &&
78
+ nextName !== oldName &&
79
+ Object.prototype.hasOwnProperty.call(parent.data, nextName)
80
+ ) {
81
+ return t('additionalProperties.nameTaken', { name: nextName });
82
+ }
83
+ const parentSchema = schemaForType(
84
+ parent.schema,
85
+ 'object',
86
+ rootSchema,
87
+ ) as JsonSchema7;
88
+ let propertyNames = parentSchema.propertyNames as JsonSchema7 | undefined;
89
+ if (propertyNames?.$ref) {
90
+ propertyNames =
91
+ (resolveSchema(rootSchema, propertyNames.$ref, rootSchema) as
92
+ | JsonSchema7
93
+ | undefined) ?? propertyNames;
94
+ }
95
+ const ajv = model.jsonforms.core?.ajv;
96
+ if (propertyNames && ajv && !ajv.validate(propertyNames, nextName)) {
97
+ /*
98
+ ajv's own text where it has some - it names the constraint that
99
+ failed, which is more use than any fixed sentence - and the
100
+ translated message where it does not. ajv's text follows the
101
+ validator's locale, not the form's; see the ajv localizers in the
102
+ extended package.
103
+ */
104
+ return (
105
+ ajv.errorsText(ajv.errors) ||
106
+ t('additionalProperties.nameInvalid', { name: nextName })
107
+ );
108
+ }
109
+ if (
110
+ parentSchema.additionalProperties === false &&
111
+ parentSchema.patternProperties &&
112
+ !Object.keys(parentSchema.patternProperties).some((pattern) => {
113
+ try {
114
+ return new RegExp(pattern).test(nextName);
115
+ } catch {
116
+ return false;
117
+ }
118
+ })
119
+ ) {
120
+ return t('additionalProperties.namePattern');
121
+ }
122
+ return undefined;
123
+ };
124
+ const renameNode = (node: MixedTreeNode, nextName: string) => {
125
+ if (!validateNodeRename(node, nextName)) model.renameNode(node, nextName);
126
+ };
127
+
128
+ if (structuredLayout === 'code') return <MixedCodeControl {...props} />;
129
+
130
+ if (structuredLayout === 'tree' && parentNavigation && isStructuredType) {
131
+ return (
132
+ <AntdNestedMixedNavigation
133
+ description={description}
134
+ label={label}
135
+ onView={() => parentNavigation.selectPath(path)}
136
+ selector={selector}
137
+ />
138
+ );
139
+ }
140
+
141
+ const content = (
142
+ <Flex
143
+ data-structured-layout={structuredLayout}
144
+ className='jsonforms-mixed-renderer'
145
+ vertical
146
+ gap='small'
147
+ >
148
+ {confirmation.dialog}
149
+ <style>{`
150
+ .jsonforms-mixed-renderer-primitive,
151
+ .jsonforms-mixed-renderer-detail-primitive {
152
+ align-items: start;
153
+ display: grid;
154
+ gap: 8px;
155
+ grid-template-columns: 140px minmax(0, 1fr);
156
+ }
157
+ .jsonforms-mixed-renderer-unselected {
158
+ grid-template-columns: minmax(0, 1fr);
159
+ }
160
+ .jsonforms-mixed-renderer-detail-control,
161
+ .jsonforms-mixed-renderer-value {
162
+ min-width: 0;
163
+ }
164
+ @media (max-width: 600px) {
165
+ .jsonforms-mixed-renderer-primitive,
166
+ .jsonforms-mixed-renderer-detail-primitive {
167
+ grid-template-columns: minmax(0, 1fr);
168
+ }
169
+ }
170
+ `}</style>
171
+ {isStructuredType ? (
172
+ <>
173
+ {label && uischema.label !== false && (
174
+ <Typography.Text>{label}</Typography.Text>
175
+ )}
176
+ <Collapse
177
+ ghost
178
+ styles={{
179
+ header: { padding: 0, alignItems: 'center' },
180
+ body: { padding: '12px 0' },
181
+ }}
182
+ activeKey={expanded ? ['value'] : []}
183
+ className='jsonforms-mixed-renderer-structured'
184
+ expandIconPlacement='end'
185
+ onChange={(keys) => model.setExpanded(keys.includes('value'))}
186
+ items={[
187
+ {
188
+ key: 'value',
189
+ collapsible: collapsible ? undefined : 'disabled',
190
+ showArrow: collapsible,
191
+ label: (
192
+ <Flex align='center' gap='middle'>
193
+ <div
194
+ onClick={(event) => event.stopPropagation()}
195
+ onKeyDown={(event) => event.stopPropagation()}
196
+ >
197
+ {selector}
198
+ </div>
199
+ {model.validation.show && (
200
+ <ContainerValidationIndicator
201
+ count={model.validation.count}
202
+ />
203
+ )}
204
+ </Flex>
205
+ ),
206
+ children:
207
+ structuredLayout === 'nested' ? (
208
+ renderedControl
209
+ ) : tree && selectedNode ? (
210
+ <AntdMixedSplitPane
211
+ tree={
212
+ <AntdMixedTree
213
+ canDelete={model.canDeleteNode}
214
+ canRename={canRenameNode}
215
+ onDelete={model.deleteNode}
216
+ onRename={renameNode}
217
+ onSelect={(node) => setSelectedPath(node.path)}
218
+ root={tree}
219
+ selectedPath={selectedNode.path}
220
+ validateRename={validateNodeRename}
221
+ />
222
+ }
223
+ detail={
224
+ <Flex vertical gap='small'>
225
+ <Breadcrumb
226
+ items={[
227
+ {
228
+ title: <AntdJsonTypeIcon type={tree.type} />,
229
+ ...(selectedNode.path.length > 0
230
+ ? {
231
+ href: '#',
232
+ onClick: (
233
+ event: React.MouseEvent<
234
+ HTMLAnchorElement | HTMLSpanElement
235
+ >,
236
+ ) => {
237
+ event.preventDefault();
238
+ setSelectedPath([]);
239
+ },
240
+ }
241
+ : {}),
242
+ },
243
+ ...selectedNode.path.map((segment, index) => {
244
+ const breadcrumbPath = selectedNode.path.slice(
245
+ 0,
246
+ index + 1,
247
+ );
248
+ const breadcrumbLabel =
249
+ typeof segment === 'number'
250
+ ? `Item ${segment}`
251
+ : segment;
252
+ const current =
253
+ index === selectedNode.path.length - 1;
254
+ return {
255
+ title: breadcrumbLabel,
256
+ ...(current
257
+ ? {}
258
+ : {
259
+ href: '#',
260
+ onClick: (
261
+ event: React.MouseEvent<
262
+ HTMLAnchorElement | HTMLSpanElement
263
+ >,
264
+ ) => {
265
+ event.preventDefault();
266
+ setSelectedPath(breadcrumbPath);
267
+ },
268
+ }),
269
+ };
270
+ }),
271
+ ]}
272
+ />
273
+ <MixedNodeControl
274
+ {...model.detailProps}
275
+ node={selectedNode}
276
+ {...model.nodeEditorProps}
277
+ MixedTypeSelector={AntdMixedTypeSelector}
278
+ wrapStructured={(children) => (
279
+ <Flex vertical gap='small'>
280
+ {children}
281
+ </Flex>
282
+ )}
283
+ />
284
+ </Flex>
285
+ }
286
+ />
287
+ ) : null,
288
+ },
289
+ ]}
290
+ />
291
+ </>
292
+ ) : (
293
+ <>
294
+ {label && uischema.label !== false ? (
295
+ <Typography.Text>{label}</Typography.Text>
296
+ ) : null}
297
+ <div
298
+ className={`jsonforms-mixed-renderer-primitive${
299
+ selectedType ? '' : ' jsonforms-mixed-renderer-unselected'
300
+ }`}
301
+ >
302
+ <div className='jsonforms-mixed-renderer-type'>{selector}</div>
303
+ {selectedType ? (
304
+ <div className='jsonforms-mixed-renderer-value'>
305
+ {renderedControl}
306
+ </div>
307
+ ) : null}
308
+ </div>
309
+ </>
310
+ )}
311
+ {description ? (
312
+ <Typography.Text type='secondary'>{description}</Typography.Text>
313
+ ) : null}
314
+ </Flex>
315
+ );
316
+ return structuredLayout === 'nested' || parentNavigation ? (
317
+ content
318
+ ) : (
319
+ <AntdMixedNavigationContext.Provider value={model.navigation}>
320
+ {content}
321
+ </AntdMixedNavigationContext.Provider>
322
+ );
323
+ };
324
+
325
+ export const MixedRenderer = withJsonFormsControlProps(MixedRendererComponent);
@@ -0,0 +1,205 @@
1
+ import React from 'react';
2
+ import { Select, Tag, Tooltip } from 'antd';
3
+ import { ExclamationCircleOutlined } from '@ant-design/icons';
4
+ import {
5
+ ControlProps,
6
+ RankedTester,
7
+ defaultErrorTranslator,
8
+ getCombinedErrorMessage,
9
+ rankWith,
10
+ and,
11
+ uiTypeIs,
12
+ } from '@jsonforms/core';
13
+ import { useJsonForms, withJsonFormsControlProps } from '@jsonforms/react';
14
+ import { displayableErrors } from '@chobantonov/jsonforms-react-renderer-common/validation/validationIndicator';
15
+ import { useTranslator } from '@chobantonov/jsonforms-react-renderer-common/locale/translate';
16
+ import { ControlFormItem } from '../util/cellMode';
17
+ import { usePreTouchErrors } from '../util/preTouchErrors';
18
+ import { useI18n } from '../util/translate';
19
+ import {
20
+ arrayChoicesOf,
21
+ arrayChoiceItemErrors,
22
+ asArrayValue,
23
+ canAddChoice,
24
+ canRemoveChoice,
25
+ isMultiSelectControl,
26
+ resolveItemSchema,
27
+ sameChoice,
28
+ } from '../util/arrayChoices';
29
+
30
+ /**
31
+ * `variant: "multi-select"` — several finite choices in one compact control.
32
+ *
33
+ * Rank 6, above the automatic checkbox group at 5, because the specification
34
+ * says "explicit selection takes precedence over automatic checkboxes". It
35
+ * matches the same schema shapes that group does, so the only thing choosing
36
+ * between them is the variant.
37
+ *
38
+ * There is **no free entry**: the choices come from the schema, and a search
39
+ * query filters them rather than adding to them.
40
+ */
41
+ export const multiSelectControlTester: RankedTester = rankWith(
42
+ 6,
43
+ and(uiTypeIs('Control'), isMultiSelectControl),
44
+ );
45
+
46
+ export const MultiSelectControl = (props: ControlProps) => {
47
+ const t = useI18n();
48
+ const context = useJsonForms();
49
+ const translate = useTranslator();
50
+ const {
51
+ data,
52
+ enabled,
53
+ id,
54
+ label,
55
+ path,
56
+ required,
57
+ rootSchema,
58
+ schema,
59
+ uischema,
60
+ visible,
61
+ } = props;
62
+ const options = {
63
+ ...props.config,
64
+ ...uischema.options,
65
+ } as Record<string, any>;
66
+ const values = asArrayValue(data);
67
+ const itemSchema = resolveItemSchema(schema, rootSchema);
68
+ const choices = arrayChoicesOf(itemSchema) ?? [];
69
+ const [primary, additional] = displayableErrors(context.core ?? {});
70
+ const itemErrors = arrayChoiceItemErrors(
71
+ [...(primary ?? []), ...(additional ?? [])],
72
+ path,
73
+ values.length,
74
+ );
75
+ const itemMessages = itemErrors.map((errors, index) =>
76
+ getCombinedErrorMessage(
77
+ errors,
78
+ context.i18n?.translateError ?? defaultErrorTranslator,
79
+ translate,
80
+ itemSchema,
81
+ uischema,
82
+ path ? `${path}.${index}` : String(index),
83
+ ),
84
+ );
85
+ // See `usePreTouchErrors`; unchanged unless filtering is on.
86
+ const { errors, onFocus, onBlur } = usePreTouchErrors({
87
+ errors: [
88
+ props.errors,
89
+ ...itemMessages.map((message, index) =>
90
+ message ? `${String(values[index])}: ${message}` : '',
91
+ ),
92
+ ]
93
+ .filter(Boolean)
94
+ .join('\n'),
95
+ path,
96
+ schema,
97
+ uischema: uischema as any,
98
+ config: props.config,
99
+ });
100
+ const limits = {
101
+ minItems: schema.minItems,
102
+ maxItems: schema.maxItems,
103
+ restrict: options.restrict !== false,
104
+ };
105
+ const addable = canAddChoice(values, limits);
106
+ const removable = canRemoveChoice(values, limits);
107
+
108
+ if (!visible) {
109
+ return null;
110
+ }
111
+
112
+ /*
113
+ Incoming values the schema does not admit are shown as choices of their own
114
+ rather than dropped. Section 19, and the array-choice contract: "do not
115
+ silently deduplicate, coerce, or discard invalid incoming values."
116
+ */
117
+ const unknownValues = values.filter(
118
+ (value) => !choices.some((choice) => sameChoice(choice.value, value)),
119
+ );
120
+
121
+ return (
122
+ <ControlFormItem
123
+ hideRequiredAsterisk={uischema.options?.hideRequiredAsterisk}
124
+ id={id}
125
+ label={label}
126
+ required={required}
127
+ errors={errors || undefined}
128
+ help={errors || props.description}
129
+ >
130
+ <Select
131
+ mode='multiple'
132
+ data-multi-select
133
+ disabled={!enabled}
134
+ onFocus={onFocus}
135
+ onBlur={onBlur}
136
+ autoFocus={options.focus === true}
137
+ style={{ width: '100%' }}
138
+ placeholder={options.placeholder}
139
+ value={values}
140
+ status={errors ? 'error' : undefined}
141
+ tagRender={({ label: tagLabel, value, closable, onClose }) => {
142
+ const index = values.findIndex((entry) => sameChoice(entry, value));
143
+ const issue = errors && index >= 0 ? itemMessages[index] : '';
144
+ return (
145
+ <Tooltip title={issue || undefined}>
146
+ <Tag
147
+ color={issue ? 'red' : undefined}
148
+ closable={closable}
149
+ onClose={onClose}
150
+ onMouseDown={(event) => event.preventDefault()}
151
+ >
152
+ <span aria-invalid={Boolean(issue)}>{tagLabel}</span>
153
+ {issue ? (
154
+ <ExclamationCircleOutlined
155
+ aria-label={issue}
156
+ style={{ marginInlineStart: 4 }}
157
+ />
158
+ ) : null}
159
+ </Tag>
160
+ </Tooltip>
161
+ );
162
+ }}
163
+ /*
164
+ Searching filters the labels; it never creates a value. `mode="tags"`
165
+ would, which is what makes it the wrong mode here even though it looks
166
+ the same.
167
+ */
168
+ showSearch={{
169
+ optionFilterProp: 'label',
170
+ filterOption: (input, option) =>
171
+ String(option?.label ?? '')
172
+ .toLowerCase()
173
+ .includes(input.toLowerCase()),
174
+ }}
175
+ notFoundContent={t('enum.noMatches')}
176
+ onChange={(next: unknown[]) => {
177
+ /*
178
+ antd reports the whole selection, so the bound has to be applied to
179
+ the *direction* of the change: refusing a longer list when the
180
+ maximum is reached, and a shorter one when the minimum is.
181
+ */
182
+ if (next.length > values.length && !addable) {
183
+ return;
184
+ }
185
+ if (next.length < values.length && !removable) {
186
+ return;
187
+ }
188
+ props.handleChange(path, next);
189
+ }}
190
+ options={[
191
+ ...choices.map((choice) => ({
192
+ value: choice.value as string,
193
+ label: choice.label,
194
+ })),
195
+ ...unknownValues.map((value) => ({
196
+ value: value as string,
197
+ label: String(value),
198
+ })),
199
+ ]}
200
+ />
201
+ </ControlFormItem>
202
+ );
203
+ };
204
+
205
+ export default withJsonFormsControlProps(MultiSelectControl);
@@ -0,0 +1,55 @@
1
+ import React from 'react';
2
+ import { Card, Typography } from 'antd';
3
+ import { withJsonFormsControlProps } from '@jsonforms/react';
4
+ import {
5
+ createObjectRenderer,
6
+ type ObjectFrameProps,
7
+ } from '@chobantonov/jsonforms-react-renderer-common/objects/ObjectDetail';
8
+ export { objectControlTester } from '@chobantonov/jsonforms-react-renderer-common/objects/ObjectDetail';
9
+ import { ValidationIcon } from './ValidationIcon';
10
+ import { AdditionalProperties } from './AdditionalProperties';
11
+
12
+ const ObjectFrame = ({
13
+ path,
14
+ title,
15
+ errors,
16
+ detail,
17
+ additional,
18
+ }: ObjectFrameProps) => {
19
+ const content = (
20
+ <div style={{ display: 'grid', gap: 12, minWidth: 0 }}>
21
+ {!title && errors && (
22
+ <Typography.Text type='danger' role='alert'>
23
+ {errors}
24
+ </Typography.Text>
25
+ )}
26
+ {detail}
27
+ {additional}
28
+ </div>
29
+ );
30
+ return path ? (
31
+ <Card
32
+ className='jsonforms-object'
33
+ title={title}
34
+ extra={
35
+ title && errors ? (
36
+ <ValidationIcon
37
+ local
38
+ errorMessages={errors}
39
+ id={`${path}-object-errors`}
40
+ />
41
+ ) : undefined
42
+ }
43
+ >
44
+ {content}
45
+ </Card>
46
+ ) : (
47
+ content
48
+ );
49
+ };
50
+
51
+ export const ObjectRenderer = createObjectRenderer(
52
+ AdditionalProperties,
53
+ ObjectFrame,
54
+ );
55
+ export default withJsonFormsControlProps(ObjectRenderer);