@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,646 @@
1
+ import { ValidationIcon } from './ValidationIcon';
2
+ import {
3
+ CollectionErrorNavigation,
4
+ RowErrorCount,
5
+ } from '@chobantonov/jsonforms-react-renderer-common/collections/CollectionErrorNavigation';
6
+ import { ItemProvider } from '@chobantonov/jsonforms-react-renderer-common/cells/CellSummary';
7
+ import {
8
+ ColumnResizeHandle,
9
+ useColumnWidths,
10
+ } from '@chobantonov/jsonforms-react-renderer-common/collections/columnResize';
11
+ import {
12
+ tableColumnFields,
13
+ tableColumnStyle,
14
+ TableColumnDefinition,
15
+ } from '@chobantonov/jsonforms-react-renderer-common/collections/tableColumns';
16
+ import { useTableSelection } from '@chobantonov/jsonforms-react-renderer-common/collections/useTableSelection';
17
+ import { PendingChangesProvider } from '@chobantonov/jsonforms-react-renderer-common/interaction/pendingChanges';
18
+ import { useCollectionPagination } from '@chobantonov/jsonforms-react-renderer-common/collections/collectionPagination';
19
+ import { useRowDetail } from '@chobantonov/jsonforms-react-renderer-common/collections/rowDetail';
20
+ import { RowDetailFrame, RowDetailToggle } from './RowDetailFrame';
21
+ import { CollectionPager } from './CollectionPager';
22
+ import ArrowDownOutlined from '@ant-design/icons/ArrowDownOutlined';
23
+ import ArrowUpOutlined from '@ant-design/icons/ArrowUpOutlined';
24
+ import DeleteFilled from '@ant-design/icons/DeleteFilled';
25
+ import EditOutlined from '@ant-design/icons/EditOutlined';
26
+ import {
27
+ ArrayLayoutProps,
28
+ ArrayTranslations,
29
+ ControlElement,
30
+ errorsAt,
31
+ formatErrorMessage,
32
+ JsonFormsCellRendererRegistryEntry,
33
+ JsonFormsRendererRegistryEntry,
34
+ JsonSchema,
35
+ Paths,
36
+ } from '@jsonforms/core';
37
+ import {
38
+ JsonFormsStateContext,
39
+ useJsonForms,
40
+ DispatchCell,
41
+ } from '@jsonforms/react';
42
+ import { Button, Table, TableColumnProps, Tooltip, theme } from 'antd';
43
+ import range from 'lodash/range';
44
+ import startCase from 'lodash/startCase';
45
+ import union from 'lodash/union';
46
+ import React, { useMemo } from 'react';
47
+
48
+ import merge from 'lodash/merge';
49
+ import { DeleteDialog, WithDeleteDialogSupport } from './DeleteDialog';
50
+ import DataCell, { DataCellProps } from './DataCell';
51
+ import TableToolbar from './TableToolbar';
52
+
53
+ type TableRow = { index: number; key: number };
54
+
55
+ interface TableColumn extends TableColumnProps<TableRow> {
56
+ dataIndex?: string;
57
+ title?: string;
58
+ width?: number;
59
+ render: (value: unknown, row: TableRow, index: number) => React.ReactNode;
60
+ }
61
+
62
+ const generateDataColumns = (props: ArrayLayoutProps): TableColumn[] => {
63
+ const { path, schema, enabled, cells } = props;
64
+ const cellOptions = (props.uischema as ControlElement)?.options?.cells as
65
+ | Record<string, Record<string, unknown>>
66
+ | undefined;
67
+
68
+ if (schema.type === 'object') {
69
+ const definitions = props.uischema.options?.columnDefs as
70
+ | TableColumnDefinition[]
71
+ | undefined;
72
+ return tableColumnFields(
73
+ schema.properties ?? {},
74
+ definitions,
75
+ getValidColumnProps(schema, cellOptions),
76
+ ).map<TableColumn>((prop) => {
77
+ const style = tableColumnStyle(
78
+ definitions?.find((column) => column.field === prop),
79
+ );
80
+ const props = {
81
+ propName: prop,
82
+ schema,
83
+ title:
84
+ definitions?.find((c) => c.field === prop)?.headerName ??
85
+ schema.properties?.[prop]?.title ??
86
+ startCase(prop),
87
+ enabled,
88
+ cells,
89
+ cellOptions: cellOptions?.[prop],
90
+ };
91
+ return {
92
+ dataIndex: props.propName,
93
+ width: style.width,
94
+ onHeaderCell: () => ({ style }),
95
+ onCell: () => ({ style }),
96
+ title: props.title,
97
+ render: (_field, row) => {
98
+ const rowPath = Paths.compose(path, `${row.index}`);
99
+ if (definitions?.some((c) => c.field === prop && c.scope === '#'))
100
+ return (
101
+ <ItemProvider path={rowPath}>
102
+ <DispatchCell
103
+ schema={schema}
104
+ path={rowPath}
105
+ uischema={{
106
+ type: 'Control',
107
+ scope: '#',
108
+ options: { ...cellOptions?.[prop], summaryOnly: true },
109
+ }}
110
+ enabled={enabled}
111
+ cells={cells}
112
+ />
113
+ </ItemProvider>
114
+ );
115
+
116
+ return (
117
+ <ItemProvider path={rowPath}>
118
+ <div
119
+ style={{
120
+ ...style,
121
+ width: style.width ? '100%' : undefined,
122
+ overflow: 'hidden',
123
+ }}
124
+ >
125
+ <RowDataCell {...props} rowPath={rowPath} />
126
+ </div>
127
+ </ItemProvider>
128
+ );
129
+ },
130
+ };
131
+ });
132
+ } else {
133
+ // primitives
134
+ const props = {
135
+ schema,
136
+ enabled,
137
+ };
138
+ return [
139
+ {
140
+ render: (_field, row) => {
141
+ const rowPath = Paths.compose(path, `${row.index}`);
142
+
143
+ return <RowDataCell {...props} rowPath={rowPath} />;
144
+ },
145
+ },
146
+ ];
147
+ }
148
+ };
149
+
150
+ const getValidColumnProps = (
151
+ scopedSchema: JsonSchema,
152
+ cellOptions?: Record<string, unknown>,
153
+ ) => {
154
+ const properties = scopedSchema.properties;
155
+ if (scopedSchema.type === 'object' && typeof properties === 'object') {
156
+ return Object.keys(properties).filter(
157
+ (prop) =>
158
+ // Array columns are skipped by default because a plain cell cannot show
159
+ // them, but a `cells` entry says how to summarise one, so keep it.
160
+ properties[prop].type !== 'array' || Boolean(cellOptions?.[prop]),
161
+ );
162
+ }
163
+ // primitives
164
+ return [''];
165
+ };
166
+
167
+ interface RowDataCellProps {
168
+ rowPath: string;
169
+ propName?: string;
170
+ schema: JsonSchema;
171
+ enabled: boolean;
172
+ renderers?: JsonFormsRendererRegistryEntry[];
173
+ cells?: JsonFormsCellRendererRegistryEntry[];
174
+ /** The array uischema's `cells` entry for this column. */
175
+ cellOptions?: Record<string, unknown>;
176
+ }
177
+
178
+ const ctxToDataCellProps = (
179
+ ctx: JsonFormsStateContext,
180
+ ownProps: RowDataCellProps,
181
+ ): DataCellProps => {
182
+ const path =
183
+ ownProps.rowPath +
184
+ (ownProps.schema.type === 'object' ? '.' + ownProps.propName : '');
185
+ const errors = formatErrorMessage(
186
+ union(
187
+ errorsAt(
188
+ path,
189
+ ownProps.schema,
190
+ (p) => p === path,
191
+ )(ctx.core?.errors ?? []).flatMap((error) => error.message ?? []),
192
+ ),
193
+ );
194
+ return {
195
+ propName: ownProps.propName,
196
+ schema: ownProps.schema,
197
+ rootSchema: ctx.core?.schema ?? ownProps.schema,
198
+ errors,
199
+ path,
200
+ enabled: ownProps.enabled,
201
+ cells: ownProps.cells || ctx.cells,
202
+ renderers: ownProps.renderers || ctx.renderers,
203
+ cellOptions: ownProps.cellOptions,
204
+ };
205
+ };
206
+
207
+ const RowDataCell = (ownProps: RowDataCellProps) => {
208
+ const ctx = useJsonForms();
209
+ const dataCellProps = ctxToDataCellProps(ctx, ownProps);
210
+
211
+ return <DataCell {...dataCellProps} />;
212
+ };
213
+
214
+ interface ActionCellProps {
215
+ childPath: string;
216
+ rowIndex: number;
217
+ moveUpCreator?: (path: string, position: number) => () => void;
218
+ moveDownCreator?: (path: string, position: number) => () => void;
219
+ enabled: boolean;
220
+ enableUp: boolean;
221
+ enableDown: boolean;
222
+ showSortButtons: boolean;
223
+ path: string;
224
+ translations: ArrayTranslations;
225
+ disableRemove?: boolean;
226
+ }
227
+
228
+ const ActionCell = ({
229
+ rowIndex,
230
+ moveUpCreator,
231
+ moveDownCreator,
232
+ enabled,
233
+ enableUp,
234
+ enableDown,
235
+ showSortButtons,
236
+ path,
237
+ translations,
238
+ }: ActionCellProps & WithDeleteDialogSupport) => {
239
+ const moveUp = useMemo(
240
+ () => moveUpCreator?.(path, rowIndex),
241
+ [moveUpCreator, path, rowIndex],
242
+ );
243
+ const moveDown = useMemo(
244
+ () => moveDownCreator?.(path, rowIndex),
245
+ [moveDownCreator, path, rowIndex],
246
+ );
247
+
248
+ return (
249
+ <div>
250
+ {showSortButtons ? (
251
+ <>
252
+ <Tooltip title={translations.up}>
253
+ <Button
254
+ shape='circle'
255
+ aria-label={translations.upAriaLabel}
256
+ icon={<ArrowUpOutlined rev={undefined} />}
257
+ onClick={moveUp}
258
+ disabled={!enabled || !enableUp || !moveUp}
259
+ />
260
+ </Tooltip>
261
+ <Tooltip title={translations.down}>
262
+ <Button
263
+ shape='circle'
264
+ aria-label={translations.downAriaLabel}
265
+ icon={<ArrowDownOutlined rev={undefined} />}
266
+ onClick={moveDown}
267
+ disabled={!enabled || !enableDown || !moveDown}
268
+ />
269
+ </Tooltip>
270
+ </>
271
+ ) : null}
272
+ </div>
273
+ );
274
+ };
275
+
276
+ interface GenerateColumns extends ArrayLayoutProps, WithDeleteDialogSupport {
277
+ moveUpCreator?: (path: string, position: number) => () => void;
278
+ moveDownCreator?: (path: string, position: number) => () => void;
279
+ showSortButtons: boolean;
280
+ path: string;
281
+ translations: ArrayTranslations;
282
+ disableRemove?: boolean;
283
+ }
284
+
285
+ const generateColumns = (props: GenerateColumns) => {
286
+ const path = props.path;
287
+ const width = props.showSortButtons ? 150 : 50;
288
+
289
+ return generateDataColumns(props).concat(
290
+ props.enabled && props.showSortButtons
291
+ ? [
292
+ {
293
+ key: 'actions',
294
+ dataIndex: '',
295
+ title: '',
296
+ width: width,
297
+ render: (_field, row) => {
298
+ const rowIndex = row.index;
299
+ const childPath = Paths.compose(path, `${rowIndex}`);
300
+
301
+ const enableUp = rowIndex !== 0;
302
+ const enableDown = rowIndex !== props.data - 1;
303
+
304
+ return (
305
+ <ActionCell
306
+ {...props}
307
+ enableUp={enableUp}
308
+ enableDown={enableDown}
309
+ rowIndex={rowIndex}
310
+ childPath={childPath}
311
+ />
312
+ );
313
+ },
314
+ },
315
+ ]
316
+ : [],
317
+ );
318
+ };
319
+
320
+ const CollectionTable = ({
321
+ props,
322
+ columns,
323
+ dataSource,
324
+ isObjectSchema,
325
+ renderFrame,
326
+ }: {
327
+ props: ArrayLayoutProps;
328
+ columns: TableColumn[];
329
+ dataSource: TableRow[];
330
+ isObjectSchema: boolean;
331
+ renderFrame: (
332
+ table: React.ReactNode,
333
+ actions: React.ReactNode,
334
+ ) => React.ReactNode;
335
+ }) => {
336
+ const { token } = theme.useToken();
337
+ const page = useCollectionPagination(
338
+ dataSource.map((row) => row.index),
339
+ props.uischema.options?.pagination,
340
+ props.config,
341
+ 'array',
342
+ true,
343
+ );
344
+ const [columnWidths, setColumnWidths] = useColumnWidths();
345
+ const detail = useRowDetail(props);
346
+ const selection = useTableSelection(props);
347
+ const actionColumn = columns.find((column) => column.key === 'actions');
348
+ const displayColumns: TableColumn[] = detail.options
349
+ ? [
350
+ ...columns.filter((column) => column.key !== 'actions'),
351
+ {
352
+ key: 'actions',
353
+ title: '',
354
+ width: (actionColumn?.width ?? 0) + 40,
355
+ render: (value, row, index) => (
356
+ <div
357
+ style={{
358
+ display: 'flex',
359
+ alignItems: 'center',
360
+ gap: 4,
361
+ whiteSpace: 'nowrap',
362
+ }}
363
+ >
364
+ <Tooltip title={detail.t('collection.editDetails')}>
365
+ <Button
366
+ icon={<EditOutlined />}
367
+ aria-label={detail.t('collection.editDetails')}
368
+ onClick={(event) => {
369
+ event.stopPropagation();
370
+ if (detail.options?.presentation === 'panel') {
371
+ detail.setPanelOpen(true);
372
+ }
373
+ detail.open(row.index);
374
+ }}
375
+ />
376
+ </Tooltip>
377
+ <RowErrorCount
378
+ path={props.path}
379
+ index={row.index}
380
+ renderIndicator={(message) => (
381
+ <ValidationIcon
382
+ errorMessages={message}
383
+ id={`${props.path}-${row.index}-row-errors`}
384
+ />
385
+ )}
386
+ />
387
+ {actionColumn?.render(value, row, index)}
388
+ </div>
389
+ ),
390
+ },
391
+ ]
392
+ : columns;
393
+ return (
394
+ <PendingChangesProvider changes={page.pending}>
395
+ {renderFrame(
396
+ <RowDetailFrame state={detail}>
397
+ <div style={{ minWidth: 0, overflow: 'auto' }}>
398
+ <Table<TableRow>
399
+ style={
400
+ columnWidths.__selection
401
+ ? {
402
+ width: Object.values(columnWidths).reduce(
403
+ (sum, value) => sum + value,
404
+ 0,
405
+ ),
406
+ maxWidth: 'none',
407
+ }
408
+ : undefined
409
+ }
410
+ tableLayout={columnWidths.__selection ? 'fixed' : 'auto'}
411
+ rowSelection={{
412
+ columnWidth: columnWidths.__selection,
413
+ selectedRowKeys: selection.selected,
414
+ onChange: (keys) =>
415
+ selection.setSelected(
416
+ keys.filter(
417
+ (key): key is number => typeof key === 'number',
418
+ ),
419
+ ),
420
+ getCheckboxProps: () => ({ disabled: !selection.selectable }),
421
+ }}
422
+ scroll={{
423
+ x: columnWidths.__selection
424
+ ? Object.values(columnWidths).reduce(
425
+ (sum, value) => sum + value,
426
+ 0,
427
+ )
428
+ : 'max-content',
429
+ }}
430
+ dataSource={page.indices.map((index) => dataSource[index])}
431
+ showHeader={isObjectSchema}
432
+ columns={displayColumns.map((column) => {
433
+ if (!column.dataIndex)
434
+ return {
435
+ ...column,
436
+ width: columnWidths.__actions ?? column.width,
437
+ };
438
+ const field = column.dataIndex;
439
+ const definition = props.uischema.options?.columnDefs?.find(
440
+ (item: TableColumnDefinition) => item.field === field,
441
+ );
442
+ const width = columnWidths[field] ?? column.width;
443
+ return {
444
+ ...column,
445
+ width,
446
+ onHeaderCell: () => ({
447
+ 'data-column-key': field,
448
+ style: {
449
+ ...tableColumnStyle(definition),
450
+ width,
451
+ position: 'relative',
452
+ paddingInlineEnd: 16,
453
+ },
454
+ }),
455
+ onCell: () => ({
456
+ style: { ...tableColumnStyle(definition), width },
457
+ }),
458
+ title: (
459
+ <>
460
+ {column.title}
461
+ {props.schema.required?.includes(field) &&
462
+ !(
463
+ props.uischema.options?.cells?.[field]
464
+ ?.hideRequiredAsterisk ??
465
+ props.uischema.options?.hideRequiredAsterisk ??
466
+ props.config?.hideRequiredAsterisk
467
+ ) && (
468
+ <span
469
+ aria-hidden='true'
470
+ style={{ color: token.colorError }}
471
+ >
472
+ {' '}
473
+ *
474
+ </span>
475
+ )}
476
+ <ColumnResizeHandle
477
+ colors={{
478
+ border: token.colorSplit,
479
+ active: token.colorPrimary,
480
+ focus: token.colorPrimaryBorder,
481
+ }}
482
+ field={String(column.title ?? field)}
483
+ definition={definition}
484
+ width={width}
485
+ onResizeStart={(widths) => setColumnWidths(widths)}
486
+ onResize={(value) =>
487
+ setColumnWidths((current) => ({
488
+ ...current,
489
+ [field]: value,
490
+ }))
491
+ }
492
+ />
493
+ </>
494
+ ),
495
+ };
496
+ })}
497
+ size='small'
498
+ pagination={false}
499
+ rowClassName={(row) =>
500
+ detail.options?.presentation === 'panel' &&
501
+ detail.panelOpen &&
502
+ detail.selection?.index === row.index
503
+ ? 'ant-table-row-selected'
504
+ : ''
505
+ }
506
+ onRow={(row) => ({
507
+ 'aria-current':
508
+ detail.options?.presentation === 'panel' &&
509
+ detail.panelOpen &&
510
+ detail.selection?.index === row.index
511
+ ? true
512
+ : undefined,
513
+ onClick: () => {
514
+ if (detail.options?.presentation === 'panel')
515
+ detail.open(row.index);
516
+ },
517
+ })}
518
+ />
519
+ <CollectionErrorNavigation
520
+ options={props.uischema.options}
521
+ renderAction={(label, onClick, icon) => (
522
+ <Tooltip title={label}>
523
+ <Button
524
+ size='small'
525
+ icon={icon}
526
+ aria-label={label}
527
+ onClick={onClick}
528
+ />
529
+ </Tooltip>
530
+ )}
531
+ path={props.path}
532
+ reveal={(index) => {
533
+ page.change(Math.floor(index / page.size) + 1);
534
+ if (detail.options) {
535
+ detail.setPanelOpen(true);
536
+ detail.open(index);
537
+ }
538
+ }}
539
+ />
540
+ <CollectionPager page={page} />
541
+ </div>
542
+ </RowDetailFrame>,
543
+ <React.Fragment key='table-actions'>
544
+ <RowDetailToggle state={detail} />
545
+ <Tooltip title={detail.t('collection.deleteSelected')}>
546
+ <Button
547
+ shape='circle'
548
+ icon={<DeleteFilled />}
549
+ danger
550
+ aria-label={detail.t('collection.deleteSelected')}
551
+ disabled={!selection.canDelete}
552
+ onClick={selection.request}
553
+ />
554
+ </Tooltip>
555
+ </React.Fragment>,
556
+ )}
557
+ <DeleteDialog
558
+ open={selection.confirming}
559
+ onConfirm={selection.confirm}
560
+ onCancel={selection.cancel}
561
+ title={detail.t('collection.deleteSelected')}
562
+ message={detail.t('collection.deleteSelectedMessage')}
563
+ acceptText={detail.t('collection.deleteSelected')}
564
+ declineText={detail.t('composite.cancel')}
565
+ />
566
+ </PendingChangesProvider>
567
+ );
568
+ };
569
+
570
+ export class TableControl extends React.Component<
571
+ ArrayLayoutProps &
572
+ WithDeleteDialogSupport & { translations: ArrayTranslations },
573
+ any
574
+ > {
575
+ addItem = (path: string, value: any) => this.props.addItem(path, value);
576
+ render() {
577
+ const {
578
+ label,
579
+ description,
580
+ path,
581
+ schema,
582
+ rootSchema,
583
+ uischema,
584
+ errors,
585
+ moveUp,
586
+ moveDown,
587
+ visible,
588
+ enabled,
589
+ translations,
590
+ disableAdd,
591
+ disableRemove,
592
+ config,
593
+ data,
594
+ } = this.props;
595
+
596
+ const appliedUiSchemaOptions = merge({}, config, uischema.options);
597
+ const doDisableAdd = disableAdd || appliedUiSchemaOptions.disableAdd;
598
+ const doDisableRemove =
599
+ disableRemove || appliedUiSchemaOptions.disableRemove;
600
+
601
+ const controlElement = uischema as ControlElement;
602
+ const isObjectSchema = schema.type === 'object';
603
+
604
+ if (!visible) {
605
+ return null;
606
+ }
607
+
608
+ const columns = generateColumns({
609
+ ...this.props,
610
+ disableRemove: doDisableRemove,
611
+ showSortButtons: appliedUiSchemaOptions.showSortButtons,
612
+ moveUpCreator: moveUp,
613
+ moveDownCreator: moveDown,
614
+ });
615
+
616
+ const dataSource = range(data).map((index) => ({ index, key: index }));
617
+
618
+ return (
619
+ <CollectionTable
620
+ props={this.props}
621
+ columns={columns}
622
+ dataSource={dataSource}
623
+ isObjectSchema={isObjectSchema}
624
+ renderFrame={(children: React.ReactNode, actions: React.ReactNode) => (
625
+ <TableToolbar
626
+ config={this.props.config}
627
+ errors={errors}
628
+ label={label}
629
+ description={description}
630
+ addItem={this.addItem}
631
+ path={path}
632
+ uischema={controlElement}
633
+ schema={schema}
634
+ rootSchema={rootSchema}
635
+ enabled={enabled}
636
+ translations={translations}
637
+ disableAdd={doDisableAdd}
638
+ actions={actions}
639
+ >
640
+ {children}
641
+ </TableToolbar>
642
+ )}
643
+ />
644
+ );
645
+ }
646
+ }