@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,222 @@
1
+ import { useEffect, useState } from 'react';
2
+ import dayjs from 'dayjs';
3
+ import type { Locale } from 'antd/es/locale';
4
+
5
+ /**
6
+ * Teaching antd which language it is in.
7
+ *
8
+ * JSON Forms carries a locale (`i18n.locale`) and translates the strings the
9
+ * *renderers* own. It says nothing to antd, which owns a second set of strings
10
+ * nobody authored here: the month and weekday names in a calendar, "Today",
11
+ * "OK", a select's empty text, a table's sort tooltips. Without this they stay
12
+ * English however the form is configured, which looks like a translation gap
13
+ * in the form rather than a missing setting.
14
+ *
15
+ * dayjs has to be told separately, because antd's locale supplies the widget
16
+ * chrome while dayjs supplies the formatted date itself.
17
+ *
18
+ * ## Why loaders rather than imports
19
+ *
20
+ * antd ships 75 locales and dayjs 143. Importing them statically puts every
21
+ * one in the bundle to use at most one, so each entry here is a **loader**: a
22
+ * function whose `import()` the bundler turns into its own chunk, fetched only
23
+ * if that locale is asked for.
24
+ *
25
+ * The specifiers are deliberately literal. A computed `import(path)` cannot be
26
+ * analysed statically, and a bundler answers that by emitting either nothing
27
+ * or all 75 - so the list below *is* the build-time selection of supported
28
+ * locales, and adding one means adding a line.
29
+ */
30
+
31
+ /**
32
+ * A loaded locale: antd's chrome, plus the name dayjs knows it by.
33
+ *
34
+ * The dayjs name is carried rather than applied by the loader, because
35
+ * `dayjs.locale()` is global state and has to be set **every time this locale
36
+ * becomes the active one** - not only the first time it is fetched. Applying
37
+ * it inside the loader looked right and left the last-loaded language in
38
+ * charge, so switching back to an already-cached one formatted its dates in
39
+ * the wrong language.
40
+ */
41
+ export interface LoadedLocale {
42
+ antd: Locale;
43
+ dayjsName: string;
44
+ }
45
+
46
+ export type AntdLocaleLoader = () => Promise<LoadedLocale>;
47
+
48
+ /** Both halves of a locale: the widget chrome, and the date formatting. */
49
+ const entry =
50
+ (
51
+ antd: () => Promise<{ default: Locale }>,
52
+ day: () => Promise<unknown>,
53
+ dayjsName: string,
54
+ ): AntdLocaleLoader =>
55
+ async () => {
56
+ const [locale] = await Promise.all([antd(), day()]);
57
+ return { antd: locale.default, dayjsName };
58
+ };
59
+
60
+ /**
61
+ * The locales this build includes.
62
+ *
63
+ * Keyed by language tag, matched case-insensitively and by language alone -
64
+ * `bg-BG`, `bg_BG` and `bg` all reach the same entry - so a host that carries
65
+ * a regional tag does not have to normalise it first.
66
+ *
67
+ * Replace or extend it with {@link setAntdLocaleLoaders} at startup; the key
68
+ * is what `i18n.locale` will hold.
69
+ */
70
+ export const defaultAntdLocaleLoaders: Record<string, AntdLocaleLoader> = {
71
+ en: entry(
72
+ () => import('antd/locale/en_US'),
73
+ () => import('dayjs/locale/en'),
74
+ 'en',
75
+ ),
76
+ bg: entry(
77
+ () => import('antd/locale/bg_BG'),
78
+ () => import('dayjs/locale/bg'),
79
+ 'bg',
80
+ ),
81
+ es: entry(
82
+ () => import('antd/locale/es_ES'),
83
+ () => import('dayjs/locale/es'),
84
+ 'es',
85
+ ),
86
+ fr: entry(
87
+ () => import('antd/locale/fr_FR'),
88
+ () => import('dayjs/locale/fr'),
89
+ 'fr',
90
+ ),
91
+ it: entry(
92
+ () => import('antd/locale/it_IT'),
93
+ () => import('dayjs/locale/it'),
94
+ 'it',
95
+ ),
96
+ ja: entry(
97
+ () => import('antd/locale/ja_JP'),
98
+ () => import('dayjs/locale/ja'),
99
+ 'ja',
100
+ ),
101
+ nl: entry(
102
+ () => import('antd/locale/nl_NL'),
103
+ () => import('dayjs/locale/nl'),
104
+ 'nl',
105
+ ),
106
+ pl: entry(
107
+ () => import('antd/locale/pl_PL'),
108
+ () => import('dayjs/locale/pl'),
109
+ 'pl',
110
+ ),
111
+ pt: entry(
112
+ () => import('antd/locale/pt_PT'),
113
+ () => import('dayjs/locale/pt'),
114
+ 'pt',
115
+ ),
116
+ ru: entry(
117
+ () => import('antd/locale/ru_RU'),
118
+ () => import('dayjs/locale/ru'),
119
+ 'ru',
120
+ ),
121
+ tr: entry(
122
+ () => import('antd/locale/tr_TR'),
123
+ () => import('dayjs/locale/tr'),
124
+ 'tr',
125
+ ),
126
+ uk: entry(
127
+ () => import('antd/locale/uk_UA'),
128
+ () => import('dayjs/locale/uk'),
129
+ 'uk',
130
+ ),
131
+ zh: entry(
132
+ () => import('antd/locale/zh_CN'),
133
+ () => import('dayjs/locale/zh-cn'),
134
+ 'zh-cn',
135
+ ),
136
+ };
137
+
138
+ let loaders: Record<string, AntdLocaleLoader> = defaultAntdLocaleLoaders;
139
+
140
+ /**
141
+ * Replaces the supported set, for a build that wants fewer chunks or more
142
+ * languages than the list above.
143
+ */
144
+ export const setAntdLocaleLoaders = (
145
+ next: Record<string, AntdLocaleLoader>,
146
+ ): void => {
147
+ loaders = next;
148
+ };
149
+
150
+ export const getAntdLocaleLoaders = (): Record<string, AntdLocaleLoader> =>
151
+ loaders;
152
+
153
+ /** `bg-BG` and `bg_BG` both mean `bg`, and case never matters. */
154
+ export const localeKey = (locale: string | undefined): string | undefined => {
155
+ if (!locale) {
156
+ return undefined;
157
+ }
158
+ const lower = locale.toLowerCase().replace(/_/g, '-');
159
+ return loaders[lower] ? lower : lower.split('-')[0];
160
+ };
161
+
162
+ const cache = new Map<string, LoadedLocale>();
163
+
164
+ /** Applying a locale is two things, and dayjs is global. */
165
+ const apply = (loaded: LoadedLocale): Locale => {
166
+ dayjs.locale(loaded.dayjsName);
167
+ return loaded.antd;
168
+ };
169
+
170
+ /**
171
+ * Resolves the antd locale for a language tag, loading it on first use.
172
+ *
173
+ * Returns `undefined` until it arrives and for a tag this build does not
174
+ * carry, which is what antd's own default handles - English chrome is a
175
+ * better answer than a form that will not render.
176
+ */
177
+ export const useAntdLocale = (
178
+ locale: string | undefined,
179
+ ): Locale | undefined => {
180
+ const key = localeKey(locale);
181
+ const [resolved, setResolved] = useState<{ key: string; locale: Locale }>();
182
+
183
+ useEffect(() => {
184
+ if (!key) {
185
+ return;
186
+ }
187
+ const cached = cache.get(key);
188
+ if (cached) {
189
+ // Re-applied, not just re-read: another locale may have been the last
190
+ // one to set dayjs.
191
+ apply(cached);
192
+ return;
193
+ }
194
+ const load = loaders[key];
195
+ if (!load) {
196
+ return;
197
+ }
198
+ let live = true;
199
+ load()
200
+ .then((value) => {
201
+ cache.set(key, value);
202
+ if (live) {
203
+ setResolved({ key, locale: apply(value) });
204
+ }
205
+ })
206
+ .catch(() => {
207
+ // A missing chunk must not take the form down; antd falls back to its
208
+ // own default, which is English.
209
+ if (live) {
210
+ setResolved(undefined);
211
+ }
212
+ });
213
+ return () => {
214
+ live = false;
215
+ };
216
+ }, [key]);
217
+
218
+ return key
219
+ ? (cache.get(key)?.antd ??
220
+ (resolved?.key === key ? resolved.locale : undefined))
221
+ : undefined;
222
+ };
@@ -0,0 +1,2 @@
1
+ // Compatibility export; implementation is shared by all renderer families.
2
+ export { toCommittableNumber } from '@chobantonov/jsonforms-react-renderer-common/controls/numeric';
@@ -0,0 +1,6 @@
1
+ // Compatibility export; implementation is shared by all renderer families.
2
+ export {
3
+ PendingChangesProvider,
4
+ useRegisterPendingChange,
5
+ } from '@chobantonov/jsonforms-react-renderer-common/interaction/pendingChanges';
6
+ export type { PendingChange } from '@chobantonov/jsonforms-react-renderer-common/interaction/pendingChanges';
@@ -0,0 +1,10 @@
1
+ // Compatibility export; implementation is shared by all renderer families.
2
+ export {
3
+ filterErrorsBeforeTouch,
4
+ usePreTouchErrors,
5
+ } from '@chobantonov/jsonforms-react-renderer-common/validation/preTouchErrors';
6
+ export type {
7
+ FilterErrorsBeforeTouchInput,
8
+ PreTouchErrorsProps,
9
+ PreTouchErrors,
10
+ } from '@chobantonov/jsonforms-react-renderer-common/validation/preTouchErrors';
@@ -0,0 +1,10 @@
1
+ // Compatibility export; implementation is shared by all renderer families.
2
+ export {
3
+ defaultRendererLocales,
4
+ setRendererLocales,
5
+ getRendererLocales,
6
+ registerRendererLocale,
7
+ resolveRendererLocale,
8
+ rendererDefault,
9
+ } from '@chobantonov/jsonforms-react-renderer-common/locale/rendererLocale';
10
+ export type { RendererLocaleCatalog } from '@chobantonov/jsonforms-react-renderer-common/locale/rendererLocale';
@@ -0,0 +1,106 @@
1
+ import dayjs from 'dayjs';
2
+ import type {
3
+ TemporalBounds,
4
+ BoundPrecision,
5
+ } from '@chobantonov/jsonforms-react-renderer-common/formats/temporalBounds';
6
+ export {
7
+ temporalBounds,
8
+ effectiveRestrict,
9
+ resolveDataBounds,
10
+ } from '@chobantonov/jsonforms-react-renderer-common/formats/temporalBounds';
11
+ export type {
12
+ BoundPrecision,
13
+ TemporalBounds,
14
+ } from '@chobantonov/jsonforms-react-renderer-common/formats/temporalBounds';
15
+ const CLOCK_DAY = '2000-01-01';
16
+
17
+ /** A `disabledDate` for antd, or undefined when nothing is bounded. */
18
+ export const disabledDateFor = (bounds: TemporalBounds) => {
19
+ if (bounds.empty) {
20
+ return () => true;
21
+ }
22
+ if (!bounds.min && !bounds.max) {
23
+ return undefined;
24
+ }
25
+ return (current: dayjs.Dayjs) => outside(current, bounds, 'day');
26
+ };
27
+
28
+ const range = (from: number, to: number): number[] => {
29
+ const out: number[] = [];
30
+ for (let value = from; value <= to; value += 1) {
31
+ out.push(value);
32
+ }
33
+ return out;
34
+ };
35
+
36
+ /**
37
+ * A `disabledTime` for antd.
38
+ *
39
+ * For a date-time the bounds only bite on the **boundary days** - the section
40
+ * asks for exactly that, "date-time bounds applied per boundary day". On any
41
+ * day strictly inside the range every hour is available, and on a day outside
42
+ * it `disabledDate` has already removed the day itself.
43
+ *
44
+ * The parameter is **not** nullable, although at runtime it can be: antd
45
+ * types it as `(date: DateType) => DisabledTimes`, and declaring
46
+ * `DateType | null` makes TypeScript infer the picker's whole generic as
47
+ * `Dayjs | null`. That then rejects the `onChange` handler beside it, whose
48
+ * value is a plain `Dayjs` - an error that points at `onChange` and is caused
49
+ * here. The runtime guard below stays, because a bare time picker really can
50
+ * be called with nothing.
51
+ */
52
+ export const disabledTimeFor = (
53
+ bounds: TemporalBounds,
54
+ timeOnly: boolean,
55
+ precision: BoundPrecision,
56
+ ) => {
57
+ if (!bounds.min && !bounds.max) {
58
+ return undefined;
59
+ }
60
+ const useSeconds = precision === 'second';
61
+
62
+ return (current: dayjs.Dayjs) => {
63
+ const day = timeOnly
64
+ ? dayjs(CLOCK_DAY).startOf('day')
65
+ : // `current` is typed non-null and is not always supplied.
66
+ (current ?? bounds.min ?? bounds.max)!.startOf('day');
67
+
68
+ const lower =
69
+ bounds.min && bounds.min.isSame(day, 'day') ? bounds.min : undefined;
70
+ const upper =
71
+ bounds.max && bounds.max.isSame(day, 'day') ? bounds.max : undefined;
72
+ if (!lower && !upper) {
73
+ return {};
74
+ }
75
+
76
+ const disabledHours = () => [
77
+ ...(lower ? range(0, lower.hour() - 1) : []),
78
+ ...(upper ? range(upper.hour() + 1, 23) : []),
79
+ ];
80
+ const disabledMinutes = (hour: number) => [
81
+ ...(lower && hour === lower.hour() ? range(0, lower.minute() - 1) : []),
82
+ ...(upper && hour === upper.hour() ? range(upper.minute() + 1, 59) : []),
83
+ ];
84
+ const disabledSeconds = (hour: number, minute: number) => [
85
+ ...(lower && hour === lower.hour() && minute === lower.minute()
86
+ ? range(0, lower.second() - 1)
87
+ : []),
88
+ ...(upper && hour === upper.hour() && minute === upper.minute()
89
+ ? range(upper.second() + 1, 59)
90
+ : []),
91
+ ];
92
+
93
+ return useSeconds
94
+ ? { disabledHours, disabledMinutes, disabledSeconds }
95
+ : { disabledHours, disabledMinutes };
96
+ };
97
+ };
98
+
99
+ /** Whether a whole unit at `value` is outside the range. */
100
+ const outside = (
101
+ value: dayjs.Dayjs,
102
+ { min, max }: TemporalBounds,
103
+ precision: BoundPrecision,
104
+ ): boolean =>
105
+ (!!min && value.isBefore(min.startOf(precision))) ||
106
+ (!!max && value.isAfter(max.startOf(precision)));
@@ -0,0 +1,95 @@
1
+ export {
2
+ specDateSaveFormat,
3
+ specTimeSaveFormat,
4
+ specDateTimeSaveFormat,
5
+ saveFormatSatisfies,
6
+ SAVE_FORMAT_DIAGNOSTIC,
7
+ warnOnSaveFormat,
8
+ } from '@chobantonov/jsonforms-react-renderer-common/formats/temporalFormats';
9
+
10
+ /** The calendar views a date picker may offer, per section 18. */
11
+ type DateView = 'year' | 'month' | 'day';
12
+
13
+ /**
14
+ * The picker granularity, from `views` or - failing that - the save format.
15
+ *
16
+ * Section 18 makes `views` "a date-only array drawn from `year`, `month`,
17
+ * `day`", and is explicit that it "does not automatically change
18
+ * `dateSaveFormat`". The two are independent settings: a year/month picker
19
+ * that stores a full date is a legitimate thing to ask for.
20
+ *
21
+ * Before this existed the granularity was **inferred from the save format** -
22
+ * no `D` meant a month picker, no `M` a year picker. That is the coupling the
23
+ * section rules out, and backwards: it made the storage decide the interaction.
24
+ * The inference is kept as a fallback for forms authored against it, below an
25
+ * explicit `views`.
26
+ */
27
+ /** The time columns a picker may offer. */
28
+ type TimeView = 'hours' | 'minutes' | 'seconds';
29
+
30
+ /**
31
+ * Which time columns `views` asks for, or `undefined` to leave it to the
32
+ * display format.
33
+ *
34
+ * The specification narrows `views` to a date-only array, but the convention
35
+ * it comes from uses time views as well - a time picker defaults to
36
+ * `['hours','minutes']` there, and a date-time picker to
37
+ * `['year','day','hours','minutes']`. Honouring them costs nothing and means a
38
+ * UI schema carrying `views: ['hours','minutes']` hides the seconds column
39
+ * rather than being accepted and ignored.
40
+ *
41
+ * `undefined` rather than all-true when no time view is named: a picker
42
+ * already derives its columns from the display format, and overriding that
43
+ * with an explicit set would make `views: ['year']` on a time picker blank the
44
+ * whole panel. An array naming no time view leaves the format in charge.
45
+ *
46
+ * Independent of the save format, as `views` is everywhere: asking for hours
47
+ * and minutes does not stop seconds being stored.
48
+ */
49
+ export const timePickerColumns = (
50
+ views: unknown,
51
+ ):
52
+ | { showHour: boolean; showMinute: boolean; showSecond: boolean }
53
+ | undefined => {
54
+ if (!Array.isArray(views)) {
55
+ return undefined;
56
+ }
57
+ const wanted = views.filter(
58
+ (view): view is TimeView =>
59
+ view === 'hours' || view === 'minutes' || view === 'seconds',
60
+ );
61
+ if (wanted.length === 0) {
62
+ return undefined;
63
+ }
64
+ return {
65
+ showHour: wanted.includes('hours'),
66
+ showMinute: wanted.includes('minutes'),
67
+ showSecond: wanted.includes('seconds'),
68
+ };
69
+ };
70
+
71
+ export const datePickerMode = (
72
+ views: unknown,
73
+ saveFormat: string,
74
+ ): 'date' | 'month' | 'year' => {
75
+ if (Array.isArray(views)) {
76
+ const wanted = views.filter(
77
+ (view): view is DateView =>
78
+ view === 'year' || view === 'month' || view === 'day',
79
+ );
80
+ // The finest view the author asked for is the one the picker lands on.
81
+ if (wanted.includes('day')) {
82
+ return 'date';
83
+ }
84
+ if (wanted.includes('month')) {
85
+ return 'month';
86
+ }
87
+ if (wanted.includes('year')) {
88
+ return 'year';
89
+ }
90
+ }
91
+ if (!saveFormat.includes('D')) {
92
+ return saveFormat.includes('M') ? 'month' : 'year';
93
+ }
94
+ return 'date';
95
+ };
@@ -0,0 +1,9 @@
1
+ export interface JsonFormsTheme {
2
+ jsonforms?: {
3
+ input?: {
4
+ delete?: {
5
+ background?: string;
6
+ };
7
+ };
8
+ };
9
+ }
@@ -0,0 +1,6 @@
1
+ // Compatibility export; implementation is shared by all renderer families.
2
+ export {
3
+ useTranslator,
4
+ useI18n,
5
+ useI18nDefault,
6
+ } from '@chobantonov/jsonforms-react-renderer-common/locale/translate';
@@ -0,0 +1,16 @@
1
+ // Compatibility export; implementation is shared by all renderer families.
2
+ export {
3
+ tupleDefinition,
4
+ tupleControlTester,
5
+ resolveTupleSchema,
6
+ tupleInitialValue,
7
+ tupleEmptyValue,
8
+ UNCONSTRAINED_TYPES,
9
+ tupleRenderSchema,
10
+ isComplexTupleSchema,
11
+ tupleFieldOwnsLabel,
12
+ } from '@chobantonov/jsonforms-react-renderer-common/tuple/tupleSchema';
13
+ export type {
14
+ TupleSchema,
15
+ TupleDefinition,
16
+ } from '@chobantonov/jsonforms-react-renderer-common/tuple/tupleSchema';
@@ -0,0 +1,2 @@
1
+ // Compatibility export; implementation is shared by all renderer families.
2
+ export { UI_SCHEMA_CYCLE_DIAGNOSTIC } from '@chobantonov/jsonforms-react-renderer-common/core/uiSchemaCycle';
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ import { Modal } from 'antd';
3
+ import { useConfirmationState } from '@chobantonov/jsonforms-react-renderer-common/interaction/useConfirmationState';
4
+ export type { ConfirmationRequest as ConfirmRequest } from '@chobantonov/jsonforms-react-renderer-common/interaction/confirmation';
5
+
6
+ /** Presents the shared destructive-change policy with an AntD dialog. */
7
+ export const useConfirmation = () => {
8
+ const { t, pending, request, close, confirm, title, message } =
9
+ useConfirmationState();
10
+ const dialog = pending ? (
11
+ <Modal
12
+ open
13
+ title={title}
14
+ okText={t('confirm.accept')}
15
+ cancelText={t('confirm.decline')}
16
+ okButtonProps={{ danger: pending.operation === 'delete' }}
17
+ onOk={confirm}
18
+ onCancel={close}
19
+ data-confirm={pending.operation}
20
+ >
21
+ <p>{message}</p>
22
+ </Modal>
23
+ ) : null;
24
+ return { request, dialog };
25
+ };
@@ -0,0 +1,10 @@
1
+ // Compatibility export; implementation is shared by all renderer families.
2
+ export {
3
+ errorDataPath,
4
+ buildErrorIndex,
5
+ sharedErrorIndex,
6
+ displayableErrors,
7
+ resolveIndicatorOption,
8
+ useContainerValidation,
9
+ } from '@chobantonov/jsonforms-react-renderer-common/validation/validationIndicator';
10
+ export type { ContainerValidation } from '@chobantonov/jsonforms-react-renderer-common/validation/validationIndicator';
@@ -0,0 +1,2 @@
1
+ // Compatibility export; implementation is shared by all renderer families.
2
+ export { visuallyHidden } from '@chobantonov/jsonforms-react-renderer-common/interaction/visuallyHidden';