@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
package/package.json CHANGED
@@ -1,6 +1,92 @@
1
1
  {
2
2
  "name": "@chobantonov/jsonforms-react-antd-renderers",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "Ant Design Renderer Set for JSON Forms",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/kchobantonov/jsonforms-react-renderers.git",
8
+ "directory": "packages/jsonforms-react-antd-renderers"
9
+ },
10
+ "bugs": "https://github.com/kchobantonov/jsonforms-react-renderers/issues",
11
+ "homepage": "https://github.com/kchobantonov/jsonforms-react-renderers",
12
+ "license": "MIT",
13
+ "directories": {
14
+ "src": "src"
15
+ },
16
+ "files": [
17
+ "lib",
18
+ "src"
19
+ ],
20
+ "keywords": [
21
+ "antd",
22
+ "renderer",
23
+ "form",
24
+ "forms",
25
+ "json",
26
+ "jsonforms",
27
+ "frontend",
28
+ "generator",
29
+ "input",
30
+ "renderengine",
31
+ "jsonschema",
32
+ "schema",
33
+ "uischema",
34
+ "layout",
35
+ "customization"
36
+ ],
37
+ "main": "lib/jsonforms-react-antd.cjs.js",
38
+ "module": "lib/jsonforms-react-antd.esm.js",
39
+ "typings": "lib/index.d.ts",
40
+ "dependencies": {
41
+ "dayjs": "^1.11.11",
42
+ "lodash": "^4.18.1",
43
+ "@chobantonov/jsonforms-react-renderer-common": "0.1.0"
44
+ },
45
+ "peerDependencies": {
46
+ "@ant-design/icons": "^6.3.2",
47
+ "@jsonforms/core": "3.9.0-alpha.4",
48
+ "@jsonforms/react": "3.9.0-alpha.4",
49
+ "antd": "^6.6.5",
50
+ "react": "^18.0.0 || ^19.0.0",
51
+ "react-dom": "^18.0.0 || ^19.0.0"
52
+ },
53
+ "devDependencies": {
54
+ "@ant-design/icons": "6.3.2",
55
+ "@cfaester/enzyme-adapter-react-18": "^0.8.0",
56
+ "@jsonforms/core": "3.9.0-alpha.4",
57
+ "@jsonforms/react": "3.9.0-alpha.4",
58
+ "@types/enzyme": "^3.10.3",
59
+ "@types/react": "^18.3.23",
60
+ "@types/react-dom": "^18.3.7",
61
+ "@vitejs/plugin-react": "^5.2.0",
62
+ "@vitest/coverage-v8": "5.1.1",
63
+ "antd": "6.6.5",
64
+ "enzyme": "^3.11.0",
65
+ "jsdom": "^22.0.0",
66
+ "react": "^18.3.1",
67
+ "react-dom": "^18.3.1",
68
+ "rimraf": "^6.1.4",
69
+ "typedoc": "~0.28.20",
70
+ "typescript": "~6.0.3",
71
+ "vite": "npm:@voidzero-dev/vite-plus-core@8.3.8001",
72
+ "vitest": "5.1.1",
73
+ "@types/node": "^22.0.0",
74
+ "@chobantonov/jsonforms-extended-spec": "0.2.0",
75
+ "@types/lodash": "^4.17.27"
76
+ },
77
+ "publishConfig": {
78
+ "access": "public"
79
+ },
80
+ "scripts": {
81
+ "build": "vp build && tsc --emitDeclarationOnly && tsc --noEmit -p test/tsconfig.json",
82
+ "clean": "rimraf lib coverage dist .nyc_output 2> /dev/null",
83
+ "lint": "vp lint .",
84
+ "lint:fix": "vp run lint --fix",
85
+ "test": "vp test run",
86
+ "test:watch": "vp test",
87
+ "test-cov": "vp test run --coverage",
88
+ "doc": "typedoc --name 'JSON Forms React Ant Design Renderers' --excludeExternals --out docs src",
89
+ "tsc": "tsc --build tsconfig.json",
90
+ "typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p test/tsconfig.json"
91
+ }
6
92
  }
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import { LabelProps, RankedTester, rankWith, uiTypeIs } from '@jsonforms/core';
3
+ import { withJsonFormsLabelProps } from '@jsonforms/react';
4
+
5
+ /**
6
+ * Default tester for a label.
7
+ * @type {RankedTester}
8
+ */
9
+ export const labelRendererTester: RankedTester = rankWith(1, uiTypeIs('Label'));
10
+
11
+ /**
12
+ * Default renderer for a label.
13
+ */
14
+ export const LabelRenderer = ({ text, visible }: LabelProps) => {
15
+ if (!visible) {
16
+ return null;
17
+ }
18
+ return <label>{text}</label>;
19
+ };
20
+
21
+ export default withJsonFormsLabelProps(LabelRenderer);
@@ -0,0 +1,124 @@
1
+ import DeleteFilled from '@ant-design/icons/DeleteFilled';
2
+ import type {
3
+ OwnPropsOfMasterListItem,
4
+ StatePropsOfMasterItem,
5
+ } from '@jsonforms/core';
6
+ import { withJsonFormsMasterListItemProps } from '@jsonforms/react';
7
+ import {
8
+ Avatar,
9
+ Button,
10
+ Flex,
11
+ Tooltip,
12
+ Typography,
13
+ theme as antdTheme,
14
+ } from 'antd';
15
+ import React from 'react';
16
+
17
+ import { useI18n } from '../util/translate';
18
+
19
+ const { Text } = Typography;
20
+
21
+ const SR_ONLY: React.CSSProperties = {
22
+ position: 'absolute',
23
+ width: 1,
24
+ height: 1,
25
+ overflow: 'hidden',
26
+ clip: 'rect(0 0 0 0)',
27
+ whiteSpace: 'nowrap',
28
+ };
29
+
30
+ export const ListWithDetailMasterItem = ({
31
+ index,
32
+ childLabel,
33
+ selected,
34
+ enabled,
35
+ handleSelect,
36
+ removeItem,
37
+ path,
38
+ translations,
39
+ disableRemove,
40
+ hideAvatar,
41
+ }: StatePropsOfMasterItem & { hideAvatar?: boolean }) => {
42
+ const t = useI18n();
43
+ const { useToken } = antdTheme;
44
+ const { token: theme } = useToken();
45
+
46
+ return (
47
+ <Flex
48
+ align='center'
49
+ gap={theme.marginXS}
50
+ className='jsonforms-list-detail-item'
51
+ onClick={handleSelect(index)}
52
+ style={{
53
+ paddingBlock: theme.paddingSM,
54
+ paddingInline: theme.paddingXS,
55
+ background: selected ? theme.controlItemBgActive : undefined,
56
+ borderRadius: theme.borderRadius,
57
+ }}
58
+ >
59
+ <Button
60
+ type='text'
61
+ aria-pressed={selected}
62
+ onClick={(event) => {
63
+ event.stopPropagation();
64
+ handleSelect(index)();
65
+ }}
66
+ style={{
67
+ flex: 1,
68
+ minWidth: 0,
69
+ height: 'auto',
70
+ justifyContent: 'flex-start',
71
+ }}
72
+ >
73
+ {hideAvatar ? (
74
+ <span style={SR_ONLY}>
75
+ {t('array.indexLabel')} {index + 1}
76
+ </span>
77
+ ) : (
78
+ <Avatar
79
+ aria-label={t('array.indexLabel')}
80
+ style={
81
+ selected
82
+ ? { background: theme.colorPrimary, flexShrink: 0 }
83
+ : { flexShrink: 0 }
84
+ }
85
+ size='small'
86
+ >
87
+ {index + 1}
88
+ </Avatar>
89
+ )}
90
+ <Text ellipsis>{childLabel ?? index}</Text>
91
+ </Button>
92
+ <Tooltip title={translations.removeTooltip} key='action_remove'>
93
+ <Button
94
+ disabled={!enabled || disableRemove}
95
+ aria-label={translations.removeAriaLabel}
96
+ icon={<DeleteFilled rev={undefined} />}
97
+ onClick={(event) => {
98
+ /*
99
+ The whole row selects on click, and this button is inside it.
100
+ Without this, pressing Delete on one entry while reading
101
+ another also navigates to the one being deleted - and then
102
+ asks about it, so declining could not put the selection back:
103
+ the move had already happened on the way in.
104
+
105
+ The array layout and the mixed tree stop propagation on their
106
+ row actions for the same reason.
107
+ */
108
+ event.stopPropagation();
109
+ removeItem(path, index)();
110
+ }}
111
+ />
112
+ </Tooltip>
113
+ </Flex>
114
+ );
115
+ };
116
+
117
+ /*
118
+ `hideAvatar` is an own prop the renderer passes straight through, but the
119
+ HOC's own-props type is fixed by JSON Forms, so the connected component is
120
+ re-typed here rather than at each call site.
121
+ */
122
+ export default withJsonFormsMasterListItemProps(
123
+ ListWithDetailMasterItem,
124
+ ) as React.ComponentType<OwnPropsOfMasterListItem & { hideAvatar?: boolean }>;
@@ -0,0 +1,243 @@
1
+ import { findDetailUISchema as findUISchema } from '@chobantonov/jsonforms-react-renderer-common/core/detailUiSchema';
2
+ import {
3
+ and,
4
+ ArrayLayoutProps,
5
+ ArrayTranslations,
6
+ composePaths,
7
+ Resolve,
8
+ computeLabel,
9
+ createDefaultValue,
10
+ deriveTypes,
11
+ errorsAt,
12
+ formatErrorMessage,
13
+ RankedTester,
14
+ rankWith,
15
+ schemaTypeIs,
16
+ uiTypeIs,
17
+ } from '@jsonforms/core';
18
+ import {
19
+ JsonFormsDispatch,
20
+ withArrayTranslationProps,
21
+ withJsonFormsArrayLayoutProps,
22
+ withTranslateProps,
23
+ useJsonForms,
24
+ } from '@jsonforms/react';
25
+ import { Empty, Listy, Splitter } from 'antd';
26
+
27
+ import range from 'lodash/range';
28
+ import React, { useCallback, useMemo, useState } from 'react';
29
+ import { useConfirmation } from '../util/useConfirmation';
30
+ import { ArrayLayoutRenderer } from '../layouts/ArrayLayoutRenderer';
31
+ import { ArrayLayoutToolbar } from '../layouts/ArrayToolbar';
32
+ import ListWithDetailMasterItem from './ListWithDetailMasterItem';
33
+ import merge from 'lodash/merge';
34
+
35
+ export const ListWithDetailRenderer = (
36
+ props: ArrayLayoutProps & { translations: ArrayTranslations },
37
+ ) => {
38
+ const {
39
+ uischemas,
40
+ schema,
41
+ uischema,
42
+ path,
43
+ enabled,
44
+ errors,
45
+ visible,
46
+ label,
47
+ required,
48
+ removeItems,
49
+ addItem,
50
+ data,
51
+ renderers,
52
+ cells,
53
+ config,
54
+ rootSchema,
55
+ description,
56
+ disableAdd,
57
+ disableRemove,
58
+ translations,
59
+ } = props;
60
+ const [selectedIndex, setSelectedIndex] = useState<number>();
61
+ const confirmation = useConfirmation();
62
+ const ctx = useJsonForms();
63
+ const handleRemoveItem = useCallback(
64
+ (p: string, value: number) => () => {
65
+ const remove = () => {
66
+ removeItems?.(p, [value])();
67
+ if (selectedIndex === value) {
68
+ setSelectedIndex(undefined);
69
+ } else if (selectedIndex !== undefined && selectedIndex > value) {
70
+ setSelectedIndex(selectedIndex - 1);
71
+ }
72
+ };
73
+ // Section 14's `always` fallback: this used to remove silently.
74
+ confirmation.request({
75
+ operation: 'delete',
76
+ catalogId: 'listWithDetail',
77
+ /*
78
+ `data` on an array layout is the item **count**, not the array, so
79
+ the item has to be read from the form's own data. Reading it from
80
+ `data` yielded `undefined`, and a policy told nothing is being
81
+ discarded does not prompt.
82
+ */
83
+ discarded: [Resolve.data(ctx.core?.data, composePaths(p, `${value}`))],
84
+ options: props.uischema?.options as Record<string, unknown> | undefined,
85
+ config,
86
+ perform: remove,
87
+ });
88
+ },
89
+ [
90
+ confirmation,
91
+ config,
92
+ ctx.core?.data,
93
+ props.uischema,
94
+ removeItems,
95
+ selectedIndex,
96
+ ],
97
+ );
98
+ const handleListItemClick = useCallback(
99
+ (index: number) => () => setSelectedIndex(index),
100
+ [setSelectedIndex],
101
+ );
102
+ const handleCreateDefaultValue = useCallback(
103
+ () => createDefaultValue(schema, rootSchema),
104
+ [schema, rootSchema],
105
+ );
106
+ const foundUISchema = useMemo(
107
+ () =>
108
+ findUISchema(
109
+ uischemas ?? [],
110
+ schema,
111
+ uischema.scope,
112
+ path,
113
+ undefined,
114
+ uischema,
115
+ rootSchema,
116
+ ),
117
+ [uischemas, schema, path, uischema, rootSchema],
118
+ );
119
+ const appliedUiSchemaOptions = merge({}, config, uischema.options);
120
+ /*
121
+ `errors` on an array control is the control's own errors followed by a
122
+ combined child summary; hiding the summary shows only the former.
123
+ */
124
+ const ownErrors = formatErrorMessage(
125
+ errorsAt(
126
+ path,
127
+ schema,
128
+ (errorPath: string) => errorPath === path,
129
+ )(ctx.core?.errors ?? []).flatMap((error) => error.message ?? []),
130
+ );
131
+ const summaryErrors = appliedUiSchemaOptions.hideArraySummaryValidation
132
+ ? ownErrors
133
+ : errors;
134
+ const doDisableAdd = disableAdd || appliedUiSchemaOptions.disableAdd;
135
+ const doDisableRemove =
136
+ !removeItems || disableRemove || appliedUiSchemaOptions.disableRemove;
137
+
138
+ const [previousSchema, setPreviousSchema] = React.useState(schema);
139
+ if (previousSchema !== schema) {
140
+ setPreviousSchema(schema);
141
+ setSelectedIndex(undefined);
142
+ }
143
+
144
+ if (!visible) {
145
+ return null;
146
+ }
147
+
148
+ // Primitive list-with-detail examples use the same accordion presentation
149
+ // as other primitive arrays. Object arrays retain the master/detail layout.
150
+ // Object items may infer their type from properties or use allOf/$ref,
151
+ // as in Huge Test. Only known non-object items use the accordion fallback.
152
+ const itemTypes = deriveTypes(schema);
153
+ if (itemTypes.length > 0 && !itemTypes.includes('object')) {
154
+ return <ArrayLayoutRenderer {...props} />;
155
+ }
156
+
157
+ return (
158
+ <>
159
+ {confirmation.dialog}
160
+ <ArrayLayoutToolbar
161
+ options={uischema.options}
162
+ config={config}
163
+ translations={translations}
164
+ label={computeLabel(
165
+ label,
166
+ required ?? false,
167
+ appliedUiSchemaOptions.hideRequiredAsterisk,
168
+ )}
169
+ description={description}
170
+ errors={summaryErrors}
171
+ path={path}
172
+ enabled={enabled}
173
+ addItem={addItem}
174
+ createDefault={handleCreateDefaultValue}
175
+ disableAdd={doDisableAdd}
176
+ >
177
+ <Splitter orientation='horizontal'>
178
+ <Splitter.Panel defaultSize='25%' min='15%' max='60%'>
179
+ <div
180
+ style={{
181
+ maxHeight: '20rem',
182
+ overflowY: 'auto',
183
+ overscrollBehaviorY: 'contain',
184
+ }}
185
+ >
186
+ {data > 0 ? (
187
+ <Listy<number>
188
+ items={range(data)}
189
+ rowKey={(index) => index}
190
+ styles={{ item: { padding: 0 } }}
191
+ itemRender={(index) => (
192
+ <ListWithDetailMasterItem
193
+ index={index}
194
+ path={path}
195
+ schema={schema}
196
+ enabled={enabled}
197
+ handleSelect={handleListItemClick}
198
+ removeItem={handleRemoveItem}
199
+ selected={selectedIndex === index}
200
+ key={index}
201
+ uischema={foundUISchema}
202
+ childLabelProp={appliedUiSchemaOptions.elementLabelProp}
203
+ translations={translations}
204
+ disableRemove={doDisableRemove}
205
+ hideAvatar={appliedUiSchemaOptions.hideAvatar === true}
206
+ />
207
+ )}
208
+ />
209
+ ) : (
210
+ <Empty description={translations.noDataMessage} />
211
+ )}
212
+ </div>
213
+ </Splitter.Panel>
214
+ <Splitter.Panel min='25%'>
215
+ <div style={{ minWidth: 0, paddingInlineStart: 12 }}>
216
+ {selectedIndex !== undefined ? (
217
+ <JsonFormsDispatch
218
+ renderers={renderers}
219
+ cells={cells}
220
+ visible={visible}
221
+ schema={schema}
222
+ uischema={foundUISchema}
223
+ path={composePaths(path, `${selectedIndex}`)}
224
+ />
225
+ ) : (
226
+ <Empty description={translations.noSelection} />
227
+ )}
228
+ </div>
229
+ </Splitter.Panel>
230
+ </Splitter>
231
+ </ArrayLayoutToolbar>
232
+ </>
233
+ );
234
+ };
235
+
236
+ export const listWithDetailTester: RankedTester = rankWith(
237
+ 4,
238
+ and(uiTypeIs('ListWithDetail'), schemaTypeIs('array')),
239
+ );
240
+
241
+ export default withJsonFormsArrayLayoutProps(
242
+ withTranslateProps(withArrayTranslationProps(ListWithDetailRenderer)),
243
+ );
@@ -0,0 +1,14 @@
1
+ import LabelRenderer, { labelRendererTester } from './LabelRenderer';
2
+
3
+ import ListWithDetailRenderer, {
4
+ listWithDetailTester,
5
+ } from './ListWithDetailRenderer';
6
+
7
+ export {
8
+ LabelRenderer,
9
+ labelRendererTester,
10
+ ListWithDetailRenderer,
11
+ listWithDetailTester,
12
+ };
13
+
14
+ export * from './ListWithDetailMasterItem';
@@ -0,0 +1,8 @@
1
+ import { LabelRenderer } from './LabelRenderer';
2
+
3
+ import { ListWithDetailRenderer } from './ListWithDetailRenderer';
4
+
5
+ export const UnwrappedAdditional = {
6
+ LabelRenderer,
7
+ ListWithDetailRenderer,
8
+ };
@@ -0,0 +1,56 @@
1
+ import React from 'react';
2
+ import { CellProps, WithClassname } from '@jsonforms/core';
3
+ import { Checkbox } from 'antd';
4
+ import merge from 'lodash/merge';
5
+
6
+ type Props = {
7
+ label?: string;
8
+ };
9
+
10
+ export const AntdCheckbox = React.memo(function AntdCheckbox(
11
+ props: CellProps &
12
+ WithClassname &
13
+ Props & {
14
+ inputProps?: React.ComponentProps<typeof Checkbox> & React.AriaAttributes;
15
+ },
16
+ ) {
17
+ const {
18
+ data,
19
+ className,
20
+ id,
21
+ enabled,
22
+ label,
23
+ uischema,
24
+ path,
25
+ handleChange,
26
+ config,
27
+ inputProps,
28
+ } = props;
29
+ const appliedUiSchemaOptions = merge({}, config, uischema.options);
30
+ /*
31
+ Only a real `true` is checked, and anything that is not a boolean shows as
32
+ indeterminate rather than as a selection.
33
+
34
+ `!!data` made the *string* `'false'` render as checked - the case the
35
+ specification names - and made `0`, `''` and `{}` look like deliberate
36
+ answers. Incoming data that is not a boolean is preserved for correction
37
+ and reported by validation; it must not be presented as a valid true or
38
+ false selection.
39
+ */
40
+ const committed = typeof data === 'boolean';
41
+
42
+ return (
43
+ <Checkbox
44
+ indeterminate={!committed}
45
+ checked={data === true}
46
+ onChange={(e: any) => handleChange(path, e.target.checked)}
47
+ className={className}
48
+ id={id}
49
+ disabled={!enabled}
50
+ autoFocus={!!appliedUiSchemaOptions.focus}
51
+ {...inputProps}
52
+ >
53
+ {label}
54
+ </Checkbox>
55
+ );
56
+ });
@@ -0,0 +1,96 @@
1
+ import CloseCircleFilled from '@ant-design/icons/CloseCircleFilled';
2
+ import { Button, Tooltip } from 'antd';
3
+ import React from 'react';
4
+ import { useI18n } from '../util/translate';
5
+
6
+ /** Enough to clear a `Form.Item` feedback icon and the input's padding. */
7
+ export const CLEAR_OFFSET = 24;
8
+
9
+ /**
10
+ * Enough to also clear `InputNumber`'s stepper handles, which antd reveals on
11
+ * hover in the same corner - the default offset put the button on top of them.
12
+ * 22px is antd's handler-wrap width.
13
+ */
14
+ export const CLEAR_OFFSET_WITH_HANDLES = CLEAR_OFFSET + 22;
15
+
16
+ export interface AntdClearValueButtonProps {
17
+ clearable?: boolean;
18
+ data: unknown;
19
+ enabled: boolean;
20
+ onClear: () => void;
21
+ visible?: boolean;
22
+ /**
23
+ * Distance from the trailing edge, in pixels.
24
+ *
25
+ * The button is positioned over the control rather than handed to antd's
26
+ * `suffix` slot, because `Form.Item` feedback *replaces* that slot rather
27
+ * than composing with it - `suffix: suffixNode || suffix` in antd's
28
+ * `InputNumber` - so a field with a validation error would lose its clear
29
+ * button exactly when someone wants it.
30
+ *
31
+ * The default clears a feedback icon. A control that also shows stepper
32
+ * handles needs more; see `CLEAR_OFFSET_WITH_HANDLES`.
33
+ *
34
+ * Ignored when {@link AntdClearValueButtonProps.inline} is set.
35
+ */
36
+ offset?: number;
37
+ /**
38
+ * Render in the normal flow instead of over the control.
39
+ *
40
+ * `Input` - unlike `InputNumber` - *composes* its `suffix` with the
41
+ * `Form.Item` feedback icon (`<>{suffix}{hasFeedback && feedbackIcon}</>`),
42
+ * so a control built on it can put this button in that slot and let antd lay
43
+ * the row out. An `Input.Password` has three trailing affordances - reveal,
44
+ * clear and the error icon - and no fixed offset places the middle one
45
+ * correctly in both states: the feedback icon is only there while the value
46
+ * is invalid, so an offset that clears it leaves a gap when it is not.
47
+ */
48
+ inline?: boolean;
49
+ }
50
+
51
+ export const AntdClearValueButton = ({
52
+ clearable = true,
53
+ data,
54
+ enabled,
55
+ onClear,
56
+ visible = true,
57
+ offset = CLEAR_OFFSET,
58
+ inline = false,
59
+ }: AntdClearValueButtonProps) => {
60
+ const t = useI18n();
61
+ const populated = data !== undefined && data !== null && data !== '';
62
+ // A slotted button takes up space even at zero opacity. Password fields put
63
+ // it before the persistent reveal button, so remove it while inactive.
64
+ if (!clearable || !enabled || !populated || (inline && !visible)) return null;
65
+
66
+ return (
67
+ <Tooltip title={t('control.clearValue')}>
68
+ <Button
69
+ aria-label={t('control.clearValue')}
70
+ icon={<CloseCircleFilled />}
71
+ onClick={(event) => {
72
+ event.stopPropagation();
73
+ onClear();
74
+ }}
75
+ onMouseDown={(event) => event.preventDefault()}
76
+ shape='circle'
77
+ size='small'
78
+ style={{
79
+ opacity: visible ? 1 : 0,
80
+ pointerEvents: visible ? 'auto' : 'none',
81
+ transition: 'opacity 120ms ease',
82
+ ...(inline
83
+ ? {}
84
+ : {
85
+ insetBlockStart: '50%',
86
+ insetInlineEnd: `calc(${offset}px + var(--jf-end-adornment-space, 0px))`,
87
+ position: 'absolute',
88
+ transform: 'translateY(-50%)',
89
+ zIndex: 2,
90
+ }),
91
+ }}
92
+ type='text'
93
+ />
94
+ </Tooltip>
95
+ );
96
+ };