@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,422 @@
1
+ import { renamePropertyKey } from '@chobantonov/jsonforms-react-renderer-common/objects/additionalProperties';
2
+ import {
3
+ useAdditionalPropertyEntries,
4
+ useAdditionalPropertyActions,
5
+ type AdditionalPropertiesProps,
6
+ } from '@chobantonov/jsonforms-react-renderer-common/objects/useAdditionalPropertyEntries';
7
+ import { ValidationIcon } from './ValidationIcon';
8
+ import {
9
+ useNameConstraintMessage,
10
+ usePropertyNameErrors,
11
+ useAdditionalPropertyErrors,
12
+ } from '@chobantonov/jsonforms-react-renderer-common/validation/errorSummary';
13
+ import { DeleteDialog } from './DeleteDialog';
14
+ import { PendingChangesProvider } from '@chobantonov/jsonforms-react-renderer-common/interaction/pendingChanges';
15
+ import { CollectionPager } from './CollectionPager';
16
+ import {
17
+ DynamicPropertyProvider,
18
+ clearedDynamicPropertyValue,
19
+ } from '@chobantonov/jsonforms-react-renderer-common/objects/dynamicProperties';
20
+
21
+ import type { JsonSchema } from '@jsonforms/core';
22
+ import PlusOutlined from '@ant-design/icons/PlusOutlined';
23
+ import { JsonFormsDispatch, useJsonForms } from '@jsonforms/react';
24
+ import {
25
+ Button,
26
+ Card,
27
+ Col,
28
+ Flex,
29
+ Form,
30
+ Input,
31
+ Row,
32
+ Tooltip,
33
+ Typography,
34
+ } from 'antd';
35
+ import React, { useState } from 'react';
36
+ import { useI18n } from '../util/translate';
37
+ import {
38
+ AdditionalPropertyNameError,
39
+ AdditionalPropertyNameResult,
40
+ assignOwnProperty,
41
+ needsIsolatedEditor,
42
+ validateAdditionalPropertyName,
43
+ } from '../util/additionalPropertyName';
44
+ import { IsolatedPropertyEditor } from '@chobantonov/jsonforms-react-renderer-common/objects/IsolatedPropertyEditor';
45
+ import { literalPropertySchema } from '../util/literalPropertySchema';
46
+ import { AntdAdditionalPropertyActions } from './additionalProperties/AntdAdditionalPropertyActions';
47
+ import { AntdAdditionalPropertyRenameDialog } from './additionalProperties/AntdAdditionalPropertyRenameDialog';
48
+
49
+ export type { AdditionalPropertiesProps } from '@chobantonov/jsonforms-react-renderer-common/objects/useAdditionalPropertyEntries';
50
+
51
+ export const AdditionalProperties = (props: AdditionalPropertiesProps) => {
52
+ const {
53
+ embedded = false,
54
+ cells,
55
+
56
+ data,
57
+ enabled,
58
+ handleChange,
59
+ label,
60
+ path,
61
+ readonly,
62
+ renderers,
63
+ rootSchema,
64
+ schema,
65
+ } = props;
66
+ const context = useJsonForms();
67
+ const [newPropertyName, setNewPropertyName] = useState('');
68
+ const [renamingPropertyName, setRenamingPropertyName] = useState<
69
+ string | null
70
+ >(null);
71
+ const t = useI18n();
72
+ const [renameValue, setRenameValue] = useState('');
73
+ const entries = useAdditionalPropertyEntries(props);
74
+ const {
75
+ objectSchema,
76
+ appliedOptions,
77
+ objectData,
78
+ reservedPropertyNames,
79
+ page,
80
+ additionalPropertyItems,
81
+ shouldShow,
82
+ } = entries;
83
+ const restrict = appliedOptions.restrict !== false;
84
+ const allowEmptyPropertyNames =
85
+ appliedOptions.allowEmptyPropertyNames === true;
86
+
87
+ // Exactly as typed. Trimming here would store `"a"` for `" a "`, and with
88
+ // empty names permitted it would erase a whitespace-only key entirely.
89
+ const propertyName = newPropertyName;
90
+ /*
91
+ One message per reason, all through the translator.
92
+
93
+ Only the schema refuses a name now. A dot or an empty name is accepted and
94
+ routed to an isolated editor rather than rejected, because a property that
95
+ no data path can address is still perfectly legal data - see Adjustment 14.
96
+ */
97
+ const nameMessage = (
98
+ error: AdditionalPropertyNameError,
99
+ name: string,
100
+ ): string => {
101
+ switch (error) {
102
+ case 'required':
103
+ return t('additionalProperties.nameRequired');
104
+ case 'already-defined':
105
+ return t('additionalProperties.nameTaken', { name });
106
+ default:
107
+ return t('additionalProperties.nameInvalid', { name });
108
+ }
109
+ };
110
+ const constraintMessage = useNameConstraintMessage();
111
+ const ajv = context.core?.ajv;
112
+ const validateName = (name: string, currentName?: string) => {
113
+ const result: AdditionalPropertyNameResult = validateAdditionalPropertyName(
114
+ {
115
+ name,
116
+ schema,
117
+ rootSchema,
118
+ data,
119
+ currentName,
120
+ disallowedNames: reservedPropertyNames,
121
+ allowEmptyName: allowEmptyPropertyNames,
122
+ validate: ajv
123
+ ? (nameSchema, value) => ajv.validate(nameSchema, value)
124
+ : undefined,
125
+ },
126
+ );
127
+ return result.error === undefined
128
+ ? undefined
129
+ : (constraintMessage(result.errors) ??
130
+ nameMessage(result.error, result.name));
131
+ };
132
+ const propertyNameError = validateName(propertyName);
133
+ /*
134
+ Section 18's draft rule: an exactly empty name input "must not show inline
135
+ name-validation errors on initial load or after it is cleared or reset,
136
+ including an empty-name collision when `allowEmptyPropertyNames` is
137
+ enabled". Suppressing the message must not suppress the judgement, so Add
138
+ still consults `propertyNameError` below.
139
+ */
140
+ const showPropertyNameError =
141
+ newPropertyName !== '' && Boolean(propertyNameError);
142
+ const {
143
+ addPropertyDisabled,
144
+ removePropertyDisabled,
145
+ deletion,
146
+ addProperty,
147
+ removeProperty,
148
+ } = useAdditionalPropertyActions(props, entries, {
149
+ restrict,
150
+ propertyName,
151
+ propertyNameError,
152
+ setNewPropertyName,
153
+ });
154
+ const renameProperty = (propertyToRename: string) => {
155
+ const nextName = renameValue;
156
+ const renameError = validateName(nextName, propertyToRename);
157
+ if (renameError || nextName === propertyToRename || !objectData) {
158
+ return;
159
+ }
160
+
161
+ // Rebuilt in order, so renaming does not move the property to the end.
162
+ const updatedData = renamePropertyKey(
163
+ objectData,
164
+ propertyToRename,
165
+ nextName,
166
+ );
167
+ handleChange(path, updatedData);
168
+ setRenamingPropertyName(null);
169
+ setRenameValue('');
170
+ };
171
+
172
+ const renameError =
173
+ renamingPropertyName === null
174
+ ? undefined
175
+ : validateName(renameValue, renamingPropertyName);
176
+ const closeRename = () => {
177
+ setRenamingPropertyName(null);
178
+ setRenameValue('');
179
+ };
180
+
181
+ const propertyErrors = useAdditionalPropertyErrors(path);
182
+ const nameErrors = usePropertyNameErrors(path);
183
+ if (!shouldShow) return null;
184
+
185
+ return (
186
+ <PendingChangesProvider changes={page.pending}>
187
+ <Card
188
+ className='jsonforms-additional-properties'
189
+ size='small'
190
+ variant={embedded ? 'borderless' : 'outlined'}
191
+ styles={embedded ? { body: { padding: 0 } } : undefined}
192
+ >
193
+ <DeleteDialog
194
+ open={deletion.confirming}
195
+ onCancel={deletion.cancel}
196
+ onConfirm={deletion.confirm}
197
+ />
198
+ <Flex vertical gap='middle'>
199
+ <Row align='bottom' gutter={[12, 8]}>
200
+ <Col md={5} xs={24}>
201
+ <Typography.Text>
202
+ {t('additionalProperties.title')}
203
+ {propertyErrors && (
204
+ <ValidationIcon
205
+ local
206
+ errorMessages={propertyErrors}
207
+ id={`${path}-additional-property-errors`}
208
+ />
209
+ )}
210
+ </Typography.Text>
211
+ </Col>
212
+ <Col md={18} xs={20}>
213
+ <Form.Item
214
+ label={t('additionalProperties.namePlaceholder')}
215
+ validateStatus={showPropertyNameError ? 'error' : undefined}
216
+ style={{ marginBottom: 0 }}
217
+ >
218
+ <Input
219
+ aria-label={
220
+ label
221
+ ? t('additionalProperties.addTo', { label })
222
+ : t('additionalProperties.add')
223
+ }
224
+ disabled={!enabled || readonly}
225
+ placeholder={t('additionalProperties.namePlaceholder')}
226
+ value={newPropertyName}
227
+ onChange={(event) =>
228
+ setNewPropertyName(event.currentTarget.value)
229
+ }
230
+ onPressEnter={addProperty}
231
+ />
232
+ </Form.Item>
233
+ </Col>
234
+ <Col md={1} xs={4}>
235
+ <Tooltip title={t('additionalProperties.add')}>
236
+ <Button
237
+ aria-label={t('additionalProperties.add')}
238
+ disabled={addPropertyDisabled}
239
+ icon={<PlusOutlined />}
240
+ onClick={addProperty}
241
+ shape='circle'
242
+ size='small'
243
+ />
244
+ </Tooltip>
245
+ </Col>
246
+ </Row>
247
+ {showPropertyNameError ? (
248
+ <Typography.Text
249
+ className='jsonforms-additional-properties-error'
250
+ type='danger'
251
+ >
252
+ {propertyNameError}
253
+ </Typography.Text>
254
+ ) : null}
255
+ <Flex
256
+ className='jsonforms-additional-properties-list'
257
+ vertical
258
+ gap='middle'
259
+ >
260
+ {page.indices
261
+ .map((index) => additionalPropertyItems[index])
262
+ .map((item) => {
263
+ /*
264
+ A name a data path cannot address - empty, or containing a dot -
265
+ is edited in a form of its own. The row keeps the heading and the
266
+ actions in that case, because the isolated editor draws no label.
267
+ */
268
+ const isolated = needsIsolatedEditor(item.propertyName);
269
+ const actions = enabled ? (
270
+ <AntdAdditionalPropertyActions
271
+ deleteDisabled={
272
+ removePropertyDisabled ||
273
+ Boolean(
274
+ restrict &&
275
+ objectSchema.required?.includes(item.propertyName),
276
+ )
277
+ }
278
+ name={item.propertyName}
279
+ onDelete={() => removeProperty(item.propertyName)}
280
+ onRename={() => {
281
+ setRenamingPropertyName(item.propertyName);
282
+ setRenameValue(item.propertyName);
283
+ }}
284
+ readonly={readonly}
285
+ />
286
+ ) : null;
287
+ return (
288
+ <Flex
289
+ align='start'
290
+ className='jsonforms-additional-property'
291
+ key={item.propertyName}
292
+ style={{ position: 'relative', width: '100%' }}
293
+ vertical
294
+ >
295
+ {
296
+ <Flex
297
+ align='center'
298
+ justify='space-between'
299
+ style={{ width: '100%' }}
300
+ >
301
+ {/*
302
+ Section 18: an empty name "has a visually blank label. Do
303
+ not display the literal text `""` as a substitute name."
304
+ The non-breaking space keeps the row its normal height so
305
+ Rename and Delete stay above the value input rather than
306
+ dropping into a row of their own.
307
+ */}
308
+ <Flex align='center' gap={4}>
309
+ <Typography.Text
310
+ type={
311
+ nameErrors.has(item.propertyName)
312
+ ? 'danger'
313
+ : undefined
314
+ }
315
+ data-property-name={item.propertyName}
316
+ >
317
+ {item.propertyName === ''
318
+ ? '\u00a0'
319
+ : item.propertyName}
320
+ </Typography.Text>
321
+ {nameErrors.get(item.propertyName) && (
322
+ <ValidationIcon
323
+ local
324
+ errorMessages={nameErrors.get(item.propertyName)!}
325
+ id={`${item.path}-name-errors`}
326
+ />
327
+ )}
328
+ </Flex>
329
+ {actions}
330
+ </Flex>
331
+ }
332
+ <div
333
+ className='jsonforms-additional-property-control'
334
+ style={{ width: '100%' }}
335
+ >
336
+ {isolated ? (
337
+ <IsolatedPropertyEditor
338
+ cells={cells}
339
+ enabled={Boolean(enabled)}
340
+ onChange={(next) =>
341
+ handleChange(
342
+ path,
343
+ assignOwnProperty(
344
+ { ...objectData },
345
+ item.propertyName,
346
+ next === undefined
347
+ ? clearedDynamicPropertyValue(
348
+ item.schema,
349
+ rootSchema,
350
+ objectData?.[item.propertyName],
351
+ )
352
+ : next,
353
+ ),
354
+ )
355
+ }
356
+ readonly={readonly}
357
+ renderers={renderers}
358
+ /*
359
+ Rebundled, so a local `$ref` inside this property's
360
+ schema still resolves once the value is its own
361
+ document. See `literalPropertySchema`.
362
+ */
363
+ schema={literalPropertySchema(
364
+ item.schema as JsonSchema,
365
+ rootSchema,
366
+ )}
367
+ uischema={{
368
+ type: 'Control',
369
+ scope: '#',
370
+ label: false,
371
+ }}
372
+ value={
373
+ objectData &&
374
+ Object.prototype.hasOwnProperty.call(
375
+ objectData,
376
+ item.propertyName,
377
+ )
378
+ ? objectData[item.propertyName]
379
+ : undefined
380
+ }
381
+ />
382
+ ) : (
383
+ <DynamicPropertyProvider path={item.path}>
384
+ <JsonFormsDispatch
385
+ schema={item.schema}
386
+ uischema={{ ...item.uischema, label: false } as any}
387
+ path={item.path}
388
+ enabled={enabled}
389
+ renderers={renderers}
390
+ cells={cells}
391
+ readonly={readonly}
392
+ />
393
+ </DynamicPropertyProvider>
394
+ )}
395
+ </div>
396
+ </Flex>
397
+ );
398
+ })}
399
+ </Flex>
400
+ <CollectionPager page={page} />
401
+ </Flex>
402
+ <AntdAdditionalPropertyRenameDialog
403
+ disabled={
404
+ !enabled ||
405
+ Boolean(readonly) ||
406
+ Boolean(renameError) ||
407
+ !renameValue.trim() ||
408
+ renameValue.trim() === renamingPropertyName
409
+ }
410
+ error={renameError}
411
+ oldName={renamingPropertyName}
412
+ onCancel={closeRename}
413
+ onChange={setRenameValue}
414
+ onRename={() => {
415
+ if (renamingPropertyName) renameProperty(renamingPropertyName);
416
+ }}
417
+ value={renameValue}
418
+ />
419
+ </Card>
420
+ </PendingChangesProvider>
421
+ );
422
+ };
@@ -0,0 +1,158 @@
1
+ import { CombinatorBranch } from '@chobantonov/jsonforms-react-renderer-common/composition/CombinatorBranch';
2
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
3
+
4
+ import {
5
+ CombinatorRendererProps,
6
+ createCombinatorRenderInfos,
7
+ isAnyOfControl,
8
+ JsonSchema,
9
+ RankedTester,
10
+ rankWith,
11
+ } from '@jsonforms/core';
12
+ import { JsonFormsDispatch, withJsonFormsAnyOfProps } from '@jsonforms/react';
13
+ import { Tabs } from 'antd';
14
+ import { CombinatorProperties } from '@chobantonov/jsonforms-react-renderer-common/composition/CombinatorProperties';
15
+
16
+ /**
17
+ * `anyOf` - tabs over one value.
18
+ *
19
+ * Section 18: "Tabs selecting the branch form to display over the same bound
20
+ * value… Tab navigation alone preserves data; one or more branches may
21
+ * validate. These are editor views, not checkboxes enabling schema branches."
22
+ * And of the worked example: "Switching tabs does not delete email or phone.
23
+ * A value containing both can satisfy anyOf; the active tab is presentation
24
+ * state only."
25
+ *
26
+ * So changing tab writes nothing at all - no generated defaults, and
27
+ * therefore nothing to confirm.
28
+ *
29
+ * That holds even for a branch whose type the current value is not, such as
30
+ * an object branch over a string. It looks as though those inputs would have
31
+ * nowhere to write, but JSON Forms' `update` builds the containers along the
32
+ * path: a child write of `note` against a string value yields
33
+ * `{ "note": "…" }`, replacing the string. The branch becomes real when the
34
+ * user edits it, which is the moment they actually chose it - not when they
35
+ * looked at it.
36
+ *
37
+ * `oneOf` is the opposite case and must write on selection: its branches
38
+ * carry generated defaults, typically a `const` discriminator, that no amount
39
+ * of typing in the visible fields would produce.
40
+ */
41
+ export const AnyOfRenderer = ({
42
+ schema,
43
+ rootSchema,
44
+ indexOfFittingSchema,
45
+ visible,
46
+ enabled,
47
+ path,
48
+ renderers,
49
+ cells,
50
+ uischema,
51
+ uischemas,
52
+ }: CombinatorRendererProps) => {
53
+ const [selectedAnyOf, setSelectedAnyOf] = useState(
54
+ indexOfFittingSchema ?? -1,
55
+ );
56
+
57
+ /*
58
+ Which tab opens is derived from the data only until the user picks one.
59
+ Afterwards the choice is theirs: re-deriving it moved the tab out from
60
+ under them as soon as their editing changed which branch fits - emptying
61
+ the value while on a chosen tab left no tab selected and the panel blank,
62
+ mid-edit. Section 22 counts the selected tab as runtime state.
63
+ */
64
+ const chosen = useRef(false);
65
+ useEffect(() => {
66
+ if (!chosen.current) {
67
+ setSelectedAnyOf(indexOfFittingSchema ?? -1);
68
+ }
69
+ }, [indexOfFittingSchema]);
70
+
71
+ const handleTabChange = useCallback((value: string) => {
72
+ chosen.current = true;
73
+ setSelectedAnyOf(parseInt(value, 10));
74
+ }, []);
75
+
76
+ const anyOf = 'anyOf';
77
+ const anyOfRenderInfos = createCombinatorRenderInfos(
78
+ (schema as JsonSchema).anyOf ?? [],
79
+ rootSchema,
80
+ anyOf,
81
+ uischema,
82
+ path,
83
+ uischemas,
84
+ );
85
+
86
+ if (!visible) {
87
+ return null;
88
+ }
89
+
90
+ if (anyOfRenderInfos.length === 1) {
91
+ const branch = anyOfRenderInfos[0];
92
+ return (
93
+ <>
94
+ <CombinatorProperties
95
+ schema={schema}
96
+ combinatorKeyword={'anyOf'}
97
+ path={path}
98
+ rootSchema={rootSchema}
99
+ />
100
+ <CombinatorBranch
101
+ options={uischema.options}
102
+ schema={branch.schema}
103
+ path={path}
104
+ >
105
+ <JsonFormsDispatch
106
+ schema={branch.schema}
107
+ uischema={branch.uischema}
108
+ path={path}
109
+ renderers={renderers}
110
+ cells={cells}
111
+ enabled={enabled}
112
+ />
113
+ </CombinatorBranch>
114
+ </>
115
+ );
116
+ }
117
+
118
+ return (
119
+ <>
120
+ <CombinatorProperties
121
+ schema={schema}
122
+ combinatorKeyword={anyOf}
123
+ path={path}
124
+ rootSchema={rootSchema}
125
+ />
126
+ <Tabs
127
+ activeKey={selectedAnyOf >= 0 ? selectedAnyOf.toString() : ''}
128
+ onChange={handleTabChange}
129
+ items={anyOfRenderInfos.map(
130
+ (anyOfRenderInfo, anyOfIndex) =>
131
+ ({
132
+ label: anyOfRenderInfo.label,
133
+ key: String(anyOfIndex),
134
+ children: selectedAnyOf === anyOfIndex && (
135
+ <CombinatorBranch
136
+ options={uischema.options}
137
+ schema={anyOfRenderInfo.schema}
138
+ path={path}
139
+ >
140
+ <JsonFormsDispatch
141
+ schema={anyOfRenderInfo.schema}
142
+ uischema={anyOfRenderInfo.uischema}
143
+ path={path}
144
+ renderers={renderers}
145
+ cells={cells}
146
+ />
147
+ </CombinatorBranch>
148
+ ),
149
+ }) as any,
150
+ )}
151
+ ></Tabs>
152
+ </>
153
+ );
154
+ };
155
+
156
+ export const anyOfControlTester: RankedTester = rankWith(3, isAnyOfControl);
157
+
158
+ export default withJsonFormsAnyOfProps(AnyOfRenderer);
@@ -0,0 +1,121 @@
1
+ import {
2
+ ArrayLayoutProps,
3
+ ArrayTranslations,
4
+ optionIs,
5
+ RankedTester,
6
+ isObjectArrayControl,
7
+ isPrimitiveArrayControl,
8
+ or,
9
+ rankWith,
10
+ Resolve,
11
+ } from '@jsonforms/core';
12
+ import {
13
+ withArrayTranslationProps,
14
+ withJsonFormsArrayLayoutProps,
15
+ withTranslateProps,
16
+ useJsonForms,
17
+ } from '@jsonforms/react';
18
+ import React, { useCallback, useState } from 'react';
19
+ import { shouldConfirm } from '../util/confirmation';
20
+ import { DeleteDialog } from './DeleteDialog';
21
+ import { TableControl } from './TableControl';
22
+
23
+ export const ArrayControlRenderer = (
24
+ props: ArrayLayoutProps & { translations: ArrayTranslations },
25
+ ) => {
26
+ const [pending, setPending] = useState<{ path: string; index: number }>();
27
+ const { removeItems, visible, translations } = props;
28
+
29
+ /*
30
+ This table used to confirm unconditionally, which the gap review noted
31
+ "matches by accident" - it happened to agree with the `always` fallback but
32
+ could not be configured, so `confirmation: { delete: "never" }` did nothing.
33
+ The prompt is now the policy's decision, and the dialog below is only opened
34
+ when the policy asks for one.
35
+ */
36
+ const ctx = useJsonForms();
37
+ const confirmDelete = useCallback(
38
+ (p: string, rowIndex: number) => {
39
+ if (!removeItems) return;
40
+ const parent = p.substring(0, p.lastIndexOf('.'));
41
+ /*
42
+ `p` is the *row's* path, and `props.data` on an array control is the
43
+ item **count**, not the array - so the row has to be read from the
44
+ form's own data. Taking it from `props.data` yielded `undefined`, and a
45
+ policy told nothing was being discarded does not prompt: the table
46
+ silently lost the confirmation it used to have.
47
+ */
48
+ const discarded = [Resolve.data(ctx.core?.data, p)];
49
+ if (
50
+ shouldConfirm(
51
+ {
52
+ options: props.uischema?.options,
53
+ config: props.config,
54
+ catalogId: 'arrayTable',
55
+ operation: 'delete',
56
+ },
57
+ discarded,
58
+ )
59
+ ) {
60
+ setPending({ path: parent, index: rowIndex });
61
+ return;
62
+ }
63
+ removeItems(parent, [rowIndex])();
64
+ },
65
+ [ctx.core?.data, props.config, props.uischema, removeItems],
66
+ );
67
+ const openDeleteDialog = confirmDelete;
68
+ const deleteCancel = useCallback(() => setPending(undefined), []);
69
+ const deleteConfirm = useCallback(() => {
70
+ if (pending) removeItems?.(pending.path, [pending.index])();
71
+ setPending(undefined);
72
+ }, [pending, removeItems]);
73
+
74
+ if (!visible) {
75
+ return null;
76
+ }
77
+
78
+ return (
79
+ <>
80
+ <TableControl
81
+ {...props}
82
+ openDeleteDialog={openDeleteDialog}
83
+ translations={translations}
84
+ />
85
+ <DeleteDialog
86
+ open={!!pending}
87
+ onCancel={deleteCancel}
88
+ onConfirm={deleteConfirm}
89
+ acceptText={translations.deleteDialogAccept}
90
+ declineText={translations.deleteDialogDecline}
91
+ title={translations.deleteDialogTitle}
92
+ message={translations.deleteDialogMessage}
93
+ />
94
+ </>
95
+ );
96
+ };
97
+
98
+ const supportedArray = or(isObjectArrayControl, isPrimitiveArrayControl);
99
+ const defaultTableTester = rankWith(3, supportedArray);
100
+ /**
101
+ * Nested objects/arrays make isObjectArrayWithNesting true, so the detail
102
+ * renderer (rank 4) normally wins. `table: true` (or `format: 'table'`) opts a
103
+ * composite array back into the table, where the `cells` option decides how
104
+ * each composite column is summarised.
105
+ */
106
+ const forcedTableTester = rankWith(
107
+ 5,
108
+ or(optionIs('table', true), optionIs('format', 'table')),
109
+ );
110
+
111
+ export const arrayControlTester: RankedTester = (uischema, schema, context) =>
112
+ supportedArray(uischema, schema, context)
113
+ ? Math.max(
114
+ defaultTableTester(uischema, schema, context),
115
+ forcedTableTester(uischema, schema, context),
116
+ )
117
+ : -1;
118
+
119
+ export default withJsonFormsArrayLayoutProps(
120
+ withTranslateProps(withArrayTranslationProps(ArrayControlRenderer)),
121
+ );