@chobantonov/jsonforms-react-renderer-common 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 (624) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +79 -2
  3. package/lib/cells/CellSummary.cjs.js +2 -0
  4. package/lib/cells/CellSummary.cjs.js.map +1 -0
  5. package/lib/cells/CellSummary.d.ts +14 -0
  6. package/lib/cells/CellSummary.esm.js +29 -0
  7. package/lib/cells/CellSummary.esm.js.map +1 -0
  8. package/lib/cells/cellMode.cjs.js +2 -0
  9. package/lib/cells/cellMode.cjs.js.map +1 -0
  10. package/lib/cells/cellMode.d.ts +14 -0
  11. package/lib/cells/cellMode.esm.js +6 -0
  12. package/lib/cells/cellMode.esm.js.map +1 -0
  13. package/lib/cells/compositeActions.cjs.js +2 -0
  14. package/lib/cells/compositeActions.cjs.js.map +1 -0
  15. package/lib/cells/compositeActions.d.ts +7 -0
  16. package/lib/cells/compositeActions.esm.js +14 -0
  17. package/lib/cells/compositeActions.esm.js.map +1 -0
  18. package/lib/cells/compositeCellTester.cjs.js +2 -0
  19. package/lib/cells/compositeCellTester.cjs.js.map +1 -0
  20. package/lib/cells/compositeCellTester.d.ts +2 -0
  21. package/lib/cells/compositeCellTester.esm.js +12 -0
  22. package/lib/cells/compositeCellTester.esm.js.map +1 -0
  23. package/lib/cells/compositeSummary.cjs.js +2 -0
  24. package/lib/cells/compositeSummary.cjs.js.map +1 -0
  25. package/lib/cells/compositeSummary.d.ts +10 -0
  26. package/lib/cells/compositeSummary.esm.js +44 -0
  27. package/lib/cells/compositeSummary.esm.js.map +1 -0
  28. package/lib/cells/useCompositeCellPresentation.cjs.js +2 -0
  29. package/lib/cells/useCompositeCellPresentation.cjs.js.map +1 -0
  30. package/lib/cells/useCompositeCellPresentation.d.ts +7 -0
  31. package/lib/cells/useCompositeCellPresentation.esm.js +18 -0
  32. package/lib/cells/useCompositeCellPresentation.esm.js.map +1 -0
  33. package/lib/cells/useCompositeDraft.cjs.js +2 -0
  34. package/lib/cells/useCompositeDraft.cjs.js.map +1 -0
  35. package/lib/cells/useCompositeDraft.d.ts +52 -0
  36. package/lib/cells/useCompositeDraft.esm.js +95 -0
  37. package/lib/cells/useCompositeDraft.esm.js.map +1 -0
  38. package/lib/collections/CollectionErrorNavigation.cjs.js +2 -0
  39. package/lib/collections/CollectionErrorNavigation.cjs.js.map +1 -0
  40. package/lib/collections/CollectionErrorNavigation.d.ts +12 -0
  41. package/lib/collections/CollectionErrorNavigation.esm.js +68 -0
  42. package/lib/collections/CollectionErrorNavigation.esm.js.map +1 -0
  43. package/lib/collections/arrayChoices.cjs.js +2 -0
  44. package/lib/collections/arrayChoices.cjs.js.map +1 -0
  45. package/lib/collections/arrayChoices.d.ts +85 -0
  46. package/lib/collections/arrayChoices.esm.js +54 -0
  47. package/lib/collections/arrayChoices.esm.js.map +1 -0
  48. package/lib/collections/collectionPagination.cjs.js +2 -0
  49. package/lib/collections/collectionPagination.cjs.js.map +1 -0
  50. package/lib/collections/collectionPagination.d.ts +22 -0
  51. package/lib/collections/collectionPagination.esm.js +51 -0
  52. package/lib/collections/collectionPagination.esm.js.map +1 -0
  53. package/lib/collections/columnResize.cjs.js +2 -0
  54. package/lib/collections/columnResize.cjs.js.map +1 -0
  55. package/lib/collections/columnResize.d.ts +16 -0
  56. package/lib/collections/columnResize.esm.js +85 -0
  57. package/lib/collections/columnResize.esm.js.map +1 -0
  58. package/lib/collections/rowDetail.cjs.js +2 -0
  59. package/lib/collections/rowDetail.cjs.js.map +1 -0
  60. package/lib/collections/rowDetail.d.ts +34 -0
  61. package/lib/collections/rowDetail.esm.js +106 -0
  62. package/lib/collections/rowDetail.esm.js.map +1 -0
  63. package/lib/collections/tableColumns.cjs.js +2 -0
  64. package/lib/collections/tableColumns.cjs.js.map +1 -0
  65. package/lib/collections/tableColumns.d.ts +13 -0
  66. package/lib/collections/tableColumns.esm.js +16 -0
  67. package/lib/collections/tableColumns.esm.js.map +1 -0
  68. package/lib/collections/useArrayPanelState.cjs.js +2 -0
  69. package/lib/collections/useArrayPanelState.cjs.js.map +1 -0
  70. package/lib/collections/useArrayPanelState.d.ts +7 -0
  71. package/lib/collections/useArrayPanelState.esm.js +18 -0
  72. package/lib/collections/useArrayPanelState.esm.js.map +1 -0
  73. package/lib/collections/useCollectionDelete.cjs.js +2 -0
  74. package/lib/collections/useCollectionDelete.cjs.js.map +1 -0
  75. package/lib/collections/useCollectionDelete.d.ts +17 -0
  76. package/lib/collections/useCollectionDelete.esm.js +38 -0
  77. package/lib/collections/useCollectionDelete.esm.js.map +1 -0
  78. package/lib/collections/useTableSelection.cjs.js +2 -0
  79. package/lib/collections/useTableSelection.cjs.js.map +1 -0
  80. package/lib/collections/useTableSelection.d.ts +11 -0
  81. package/lib/collections/useTableSelection.esm.js +41 -0
  82. package/lib/collections/useTableSelection.esm.js.map +1 -0
  83. package/lib/composition/AllOfRenderer.cjs.js +2 -0
  84. package/lib/composition/AllOfRenderer.cjs.js.map +1 -0
  85. package/lib/composition/AllOfRenderer.d.ts +5 -0
  86. package/lib/composition/AllOfRenderer.esm.js +33 -0
  87. package/lib/composition/AllOfRenderer.esm.js.map +1 -0
  88. package/lib/composition/CombinatorBranch.cjs.js +2 -0
  89. package/lib/composition/CombinatorBranch.cjs.js.map +1 -0
  90. package/lib/composition/CombinatorBranch.d.ts +17 -0
  91. package/lib/composition/CombinatorBranch.esm.js +54 -0
  92. package/lib/composition/CombinatorBranch.esm.js.map +1 -0
  93. package/lib/composition/CombinatorProperties.cjs.js +2 -0
  94. package/lib/composition/CombinatorProperties.cjs.js.map +1 -0
  95. package/lib/composition/CombinatorProperties.d.ts +12 -0
  96. package/lib/composition/CombinatorProperties.esm.js +20 -0
  97. package/lib/composition/CombinatorProperties.esm.js.map +1 -0
  98. package/lib/composition/ScalarCompositionControl.cjs.js +2 -0
  99. package/lib/composition/ScalarCompositionControl.cjs.js.map +1 -0
  100. package/lib/composition/ScalarCompositionControl.d.ts +6 -0
  101. package/lib/composition/ScalarCompositionControl.esm.js +22 -0
  102. package/lib/composition/ScalarCompositionControl.esm.js.map +1 -0
  103. package/lib/composition/choiceCards.cjs.js +2 -0
  104. package/lib/composition/choiceCards.cjs.js.map +1 -0
  105. package/lib/composition/choiceCards.d.ts +36 -0
  106. package/lib/composition/choiceCards.esm.js +162 -0
  107. package/lib/composition/choiceCards.esm.js.map +1 -0
  108. package/lib/composition/combinators.cjs.js +2 -0
  109. package/lib/composition/combinators.cjs.js.map +1 -0
  110. package/lib/composition/combinators.d.ts +40 -0
  111. package/lib/composition/combinators.esm.js +26 -0
  112. package/lib/composition/combinators.esm.js.map +1 -0
  113. package/lib/composition/discriminatorBranch.cjs.js +2 -0
  114. package/lib/composition/discriminatorBranch.cjs.js.map +1 -0
  115. package/lib/composition/discriminatorBranch.d.ts +6 -0
  116. package/lib/composition/discriminatorBranch.esm.js +41 -0
  117. package/lib/composition/discriminatorBranch.esm.js.map +1 -0
  118. package/lib/composition/scalarComposition.cjs.js +2 -0
  119. package/lib/composition/scalarComposition.cjs.js.map +1 -0
  120. package/lib/composition/scalarComposition.d.ts +27 -0
  121. package/lib/composition/scalarComposition.esm.js +76 -0
  122. package/lib/composition/scalarComposition.esm.js.map +1 -0
  123. package/lib/composition/useCombinatorSelection.cjs.js +2 -0
  124. package/lib/composition/useCombinatorSelection.cjs.js.map +1 -0
  125. package/lib/composition/useCombinatorSelection.d.ts +6 -0
  126. package/lib/composition/useCombinatorSelection.esm.js +22 -0
  127. package/lib/composition/useCombinatorSelection.esm.js.map +1 -0
  128. package/lib/composition/useScalarComposition.cjs.js +2 -0
  129. package/lib/composition/useScalarComposition.cjs.js.map +1 -0
  130. package/lib/composition/useScalarComposition.d.ts +18 -0
  131. package/lib/composition/useScalarComposition.esm.js +24 -0
  132. package/lib/composition/useScalarComposition.esm.js.map +1 -0
  133. package/lib/controls/FileArrayInput.cjs.js +2 -0
  134. package/lib/controls/FileArrayInput.cjs.js.map +1 -0
  135. package/lib/controls/FileArrayInput.d.ts +19 -0
  136. package/lib/controls/FileArrayInput.esm.js +232 -0
  137. package/lib/controls/FileArrayInput.esm.js.map +1 -0
  138. package/lib/controls/controlHelp.cjs.js +2 -0
  139. package/lib/controls/controlHelp.cjs.js.map +1 -0
  140. package/lib/controls/controlHelp.d.ts +15 -0
  141. package/lib/controls/controlHelp.esm.js +9 -0
  142. package/lib/controls/controlHelp.esm.js.map +1 -0
  143. package/lib/controls/inputAdornments.cjs.js +2 -0
  144. package/lib/controls/inputAdornments.cjs.js.map +1 -0
  145. package/lib/controls/inputAdornments.d.ts +32 -0
  146. package/lib/controls/inputAdornments.esm.js +192 -0
  147. package/lib/controls/inputAdornments.esm.js.map +1 -0
  148. package/lib/controls/numeric.cjs.js +2 -0
  149. package/lib/controls/numeric.cjs.js.map +1 -0
  150. package/lib/controls/numeric.d.ts +36 -0
  151. package/lib/controls/numeric.esm.js +9 -0
  152. package/lib/controls/numeric.esm.js.map +1 -0
  153. package/lib/controls/useClearAffordance.cjs.js +2 -0
  154. package/lib/controls/useClearAffordance.cjs.js.map +1 -0
  155. package/lib/controls/useClearAffordance.d.ts +15 -0
  156. package/lib/controls/useClearAffordance.esm.js +17 -0
  157. package/lib/controls/useClearAffordance.esm.js.map +1 -0
  158. package/lib/controls/useDebouncedChange.cjs.js +2 -0
  159. package/lib/controls/useDebouncedChange.cjs.js.map +1 -0
  160. package/lib/controls/useDebouncedChange.d.ts +37 -0
  161. package/lib/controls/useDebouncedChange.esm.js +40 -0
  162. package/lib/controls/useDebouncedChange.esm.js.map +1 -0
  163. package/lib/controls/useFocus.cjs.js +2 -0
  164. package/lib/controls/useFocus.cjs.js.map +1 -0
  165. package/lib/controls/useFocus.d.ts +1 -0
  166. package/lib/controls/useFocus.esm.js +13 -0
  167. package/lib/controls/useFocus.esm.js.map +1 -0
  168. package/lib/core/configNamespaces.cjs.js +2 -0
  169. package/lib/core/configNamespaces.cjs.js.map +1 -0
  170. package/lib/core/configNamespaces.d.ts +32 -0
  171. package/lib/core/configNamespaces.esm.js +15 -0
  172. package/lib/core/configNamespaces.esm.js.map +1 -0
  173. package/lib/core/dataPointer.cjs.js +2 -0
  174. package/lib/core/dataPointer.cjs.js.map +1 -0
  175. package/lib/core/dataPointer.d.ts +1 -0
  176. package/lib/core/dataPointer.esm.js +5 -0
  177. package/lib/core/dataPointer.esm.js.map +1 -0
  178. package/lib/core/detailUiSchema.cjs.js +2 -0
  179. package/lib/core/detailUiSchema.cjs.js.map +1 -0
  180. package/lib/core/detailUiSchema.d.ts +7 -0
  181. package/lib/core/detailUiSchema.esm.js +23 -0
  182. package/lib/core/detailUiSchema.esm.js.map +1 -0
  183. package/lib/core/plainRecord.cjs.js +2 -0
  184. package/lib/core/plainRecord.cjs.js.map +1 -0
  185. package/lib/core/plainRecord.d.ts +1 -0
  186. package/lib/core/plainRecord.esm.js +5 -0
  187. package/lib/core/plainRecord.esm.js.map +1 -0
  188. package/lib/core/uiSchemaCycle.cjs.js +2 -0
  189. package/lib/core/uiSchemaCycle.cjs.js.map +1 -0
  190. package/lib/core/uiSchemaCycle.d.ts +18 -0
  191. package/lib/core/uiSchemaCycle.esm.js +27 -0
  192. package/lib/core/uiSchemaCycle.esm.js.map +1 -0
  193. package/lib/dynamic/DynamicUiProvider.cjs.js +4 -0
  194. package/lib/dynamic/DynamicUiProvider.cjs.js.map +1 -0
  195. package/lib/dynamic/DynamicUiProvider.d.ts +35 -0
  196. package/lib/dynamic/DynamicUiProvider.esm.js +182 -0
  197. package/lib/dynamic/DynamicUiProvider.esm.js.map +1 -0
  198. package/lib/dynamic/dynamicCel.cjs.js +2 -0
  199. package/lib/dynamic/dynamicCel.cjs.js.map +1 -0
  200. package/lib/dynamic/dynamicCel.d.ts +1 -0
  201. package/lib/dynamic/dynamicCel.esm.js +43 -0
  202. package/lib/dynamic/dynamicCel.esm.js.map +1 -0
  203. package/lib/dynamic/dynamicConfig.cjs.js +2 -0
  204. package/lib/dynamic/dynamicConfig.cjs.js.map +1 -0
  205. package/lib/dynamic/dynamicConfig.d.ts +7 -0
  206. package/lib/dynamic/dynamicConfig.esm.js +13 -0
  207. package/lib/dynamic/dynamicConfig.esm.js.map +1 -0
  208. package/lib/dynamic/dynamicRuntime.cjs.js +2 -0
  209. package/lib/dynamic/dynamicRuntime.cjs.js.map +1 -0
  210. package/lib/dynamic/dynamicRuntime.d.ts +4 -0
  211. package/lib/dynamic/dynamicRuntime.esm.js +16 -0
  212. package/lib/dynamic/dynamicRuntime.esm.js.map +1 -0
  213. package/lib/dynamic/dynamicScope.cjs.js +2 -0
  214. package/lib/dynamic/dynamicScope.cjs.js.map +1 -0
  215. package/lib/dynamic/dynamicScope.d.ts +2 -0
  216. package/lib/dynamic/dynamicScope.esm.js +17 -0
  217. package/lib/dynamic/dynamicScope.esm.js.map +1 -0
  218. package/lib/dynamic/dynamicTree.cjs.js +2 -0
  219. package/lib/dynamic/dynamicTree.cjs.js.map +1 -0
  220. package/lib/dynamic/dynamicTree.d.ts +12 -0
  221. package/lib/dynamic/dynamicTree.esm.js +57 -0
  222. package/lib/dynamic/dynamicTree.esm.js.map +1 -0
  223. package/lib/dynamic/dynamicUi.cjs.js +2 -0
  224. package/lib/dynamic/dynamicUi.cjs.js.map +1 -0
  225. package/lib/dynamic/dynamicUi.d.ts +39 -0
  226. package/lib/dynamic/dynamicUi.esm.js +397 -0
  227. package/lib/dynamic/dynamicUi.esm.js.map +1 -0
  228. package/lib/formats/colorFormat.cjs.js +2 -0
  229. package/lib/formats/colorFormat.cjs.js.map +1 -0
  230. package/lib/formats/colorFormat.d.ts +127 -0
  231. package/lib/formats/colorFormat.esm.js +139 -0
  232. package/lib/formats/colorFormat.esm.js.map +1 -0
  233. package/lib/formats/dateValues.cjs.js +2 -0
  234. package/lib/formats/dateValues.cjs.js.map +1 -0
  235. package/lib/formats/dateValues.d.ts +3 -0
  236. package/lib/formats/dateValues.esm.js +21 -0
  237. package/lib/formats/dateValues.esm.js.map +1 -0
  238. package/lib/formats/duration.cjs.js +2 -0
  239. package/lib/formats/duration.cjs.js.map +1 -0
  240. package/lib/formats/duration.d.ts +13 -0
  241. package/lib/formats/duration.esm.js +28 -0
  242. package/lib/formats/duration.esm.js.map +1 -0
  243. package/lib/formats/maskControls.cjs.js +2 -0
  244. package/lib/formats/maskControls.cjs.js.map +1 -0
  245. package/lib/formats/maskControls.d.ts +32 -0
  246. package/lib/formats/maskControls.esm.js +16 -0
  247. package/lib/formats/maskControls.esm.js.map +1 -0
  248. package/lib/formats/maskFormat.cjs.js +2 -0
  249. package/lib/formats/maskFormat.cjs.js.map +1 -0
  250. package/lib/formats/maskFormat.d.ts +198 -0
  251. package/lib/formats/maskFormat.esm.js +79 -0
  252. package/lib/formats/maskFormat.esm.js.map +1 -0
  253. package/lib/formats/temporalBounds.cjs.js +2 -0
  254. package/lib/formats/temporalBounds.cjs.js.map +1 -0
  255. package/lib/formats/temporalBounds.d.ts +82 -0
  256. package/lib/formats/temporalBounds.esm.js +76 -0
  257. package/lib/formats/temporalBounds.esm.js.map +1 -0
  258. package/lib/formats/temporalFormats.cjs.js +2 -0
  259. package/lib/formats/temporalFormats.cjs.js.map +1 -0
  260. package/lib/formats/temporalFormats.d.ts +62 -0
  261. package/lib/formats/temporalFormats.esm.js +18 -0
  262. package/lib/formats/temporalFormats.esm.js.map +1 -0
  263. package/lib/formats/useMaskedInput.cjs.js +2 -0
  264. package/lib/formats/useMaskedInput.cjs.js.map +1 -0
  265. package/lib/formats/useMaskedInput.d.ts +11 -0
  266. package/lib/formats/useMaskedInput.esm.js +80 -0
  267. package/lib/formats/useMaskedInput.esm.js.map +1 -0
  268. package/lib/index.cjs.js +1 -0
  269. package/lib/index.d.ts +42 -0
  270. package/lib/index.esm.js +44 -0
  271. package/lib/interaction/confirmation.cjs.js +2 -0
  272. package/lib/interaction/confirmation.cjs.js.map +1 -0
  273. package/lib/interaction/confirmation.d.ts +112 -0
  274. package/lib/interaction/confirmation.esm.js +18 -0
  275. package/lib/interaction/confirmation.esm.js.map +1 -0
  276. package/lib/interaction/createDeleteConfirmation.cjs.js +2 -0
  277. package/lib/interaction/createDeleteConfirmation.cjs.js.map +1 -0
  278. package/lib/interaction/createDeleteConfirmation.d.ts +10 -0
  279. package/lib/interaction/createDeleteConfirmation.esm.js +17 -0
  280. package/lib/interaction/createDeleteConfirmation.esm.js.map +1 -0
  281. package/lib/interaction/detailDialog.cjs.js +2 -0
  282. package/lib/interaction/detailDialog.cjs.js.map +1 -0
  283. package/lib/interaction/detailDialog.d.ts +30 -0
  284. package/lib/interaction/detailDialog.esm.js +89 -0
  285. package/lib/interaction/detailDialog.esm.js.map +1 -0
  286. package/lib/interaction/pendingChanges.cjs.js +2 -0
  287. package/lib/interaction/pendingChanges.cjs.js.map +1 -0
  288. package/lib/interaction/pendingChanges.d.ts +19 -0
  289. package/lib/interaction/pendingChanges.esm.js +17 -0
  290. package/lib/interaction/pendingChanges.esm.js.map +1 -0
  291. package/lib/interaction/useConfirmationState.cjs.js +2 -0
  292. package/lib/interaction/useConfirmationState.cjs.js.map +1 -0
  293. package/lib/interaction/useConfirmationState.d.ts +11 -0
  294. package/lib/interaction/useConfirmationState.esm.js +39 -0
  295. package/lib/interaction/useConfirmationState.esm.js.map +1 -0
  296. package/lib/interaction/visuallyHidden.cjs.js +2 -0
  297. package/lib/interaction/visuallyHidden.cjs.js.map +1 -0
  298. package/lib/interaction/visuallyHidden.d.ts +9 -0
  299. package/lib/interaction/visuallyHidden.esm.js +14 -0
  300. package/lib/interaction/visuallyHidden.esm.js.map +1 -0
  301. package/lib/layout/categoryState.cjs.js +2 -0
  302. package/lib/layout/categoryState.cjs.js.map +1 -0
  303. package/lib/layout/categoryState.d.ts +66 -0
  304. package/lib/layout/categoryState.esm.js +42 -0
  305. package/lib/layout/categoryState.esm.js.map +1 -0
  306. package/lib/layout/groupState.cjs.js +2 -0
  307. package/lib/layout/groupState.cjs.js.map +1 -0
  308. package/lib/layout/groupState.d.ts +34 -0
  309. package/lib/layout/groupState.esm.js +63 -0
  310. package/lib/layout/groupState.esm.js.map +1 -0
  311. package/lib/layout/layoutContext.cjs.js +2 -0
  312. package/lib/layout/layoutContext.cjs.js.map +1 -0
  313. package/lib/layout/layoutContext.d.ts +16 -0
  314. package/lib/layout/layoutContext.esm.js +26 -0
  315. package/lib/layout/layoutContext.esm.js.map +1 -0
  316. package/lib/layout/layoutSizing.cjs.js +2 -0
  317. package/lib/layout/layoutSizing.cjs.js.map +1 -0
  318. package/lib/layout/layoutSizing.d.ts +104 -0
  319. package/lib/layout/layoutSizing.esm.js +69 -0
  320. package/lib/layout/layoutSizing.esm.js.map +1 -0
  321. package/lib/locale/bg.cjs.js +2 -0
  322. package/lib/locale/bg.cjs.js.map +1 -0
  323. package/lib/locale/bg.d.ts +279 -0
  324. package/lib/locale/bg.esm.js +271 -0
  325. package/lib/locale/bg.esm.js.map +1 -0
  326. package/lib/locale/calendar.cjs.js +2 -0
  327. package/lib/locale/calendar.cjs.js.map +1 -0
  328. package/lib/locale/calendar.d.ts +23 -0
  329. package/lib/locale/calendar.esm.js +57 -0
  330. package/lib/locale/calendar.esm.js.map +1 -0
  331. package/lib/locale/en.cjs.js +2 -0
  332. package/lib/locale/en.cjs.js.map +1 -0
  333. package/lib/locale/en.d.ts +275 -0
  334. package/lib/locale/en.esm.js +271 -0
  335. package/lib/locale/en.esm.js.map +1 -0
  336. package/lib/locale/index.cjs.js +1 -0
  337. package/lib/locale/index.d.ts +3 -0
  338. package/lib/locale/index.esm.js +3 -0
  339. package/lib/locale/intl.cjs.js +2 -0
  340. package/lib/locale/intl.cjs.js.map +1 -0
  341. package/lib/locale/intl.d.ts +2 -0
  342. package/lib/locale/intl.esm.js +11 -0
  343. package/lib/locale/intl.esm.js.map +1 -0
  344. package/lib/locale/rendererLocale.cjs.js +2 -0
  345. package/lib/locale/rendererLocale.cjs.js.map +1 -0
  346. package/lib/locale/rendererLocale.d.ts +40 -0
  347. package/lib/locale/rendererLocale.esm.js +24 -0
  348. package/lib/locale/rendererLocale.esm.js.map +1 -0
  349. package/lib/locale/translate.cjs.js +2 -0
  350. package/lib/locale/translate.cjs.js.map +1 -0
  351. package/lib/locale/translate.d.ts +43 -0
  352. package/lib/locale/translate.esm.js +25 -0
  353. package/lib/locale/translate.esm.js.map +1 -0
  354. package/lib/mixed/MixedDetailControl.cjs.js +2 -0
  355. package/lib/mixed/MixedDetailControl.cjs.js.map +1 -0
  356. package/lib/mixed/MixedDetailControl.d.ts +20 -0
  357. package/lib/mixed/MixedDetailControl.esm.js +73 -0
  358. package/lib/mixed/MixedDetailControl.esm.js.map +1 -0
  359. package/lib/mixed/RecursiveTreeRenderer.cjs.js +2 -0
  360. package/lib/mixed/RecursiveTreeRenderer.cjs.js.map +1 -0
  361. package/lib/mixed/RecursiveTreeRenderer.d.ts +35 -0
  362. package/lib/mixed/RecursiveTreeRenderer.esm.js +206 -0
  363. package/lib/mixed/RecursiveTreeRenderer.esm.js.map +1 -0
  364. package/lib/mixed/createMixedTypeChangeHandler.cjs.js +2 -0
  365. package/lib/mixed/createMixedTypeChangeHandler.cjs.js.map +1 -0
  366. package/lib/mixed/createMixedTypeChangeHandler.d.ts +16 -0
  367. package/lib/mixed/createMixedTypeChangeHandler.esm.js +34 -0
  368. package/lib/mixed/createMixedTypeChangeHandler.esm.js.map +1 -0
  369. package/lib/mixed/mixedComposition.cjs.js +2 -0
  370. package/lib/mixed/mixedComposition.cjs.js.map +1 -0
  371. package/lib/mixed/mixedComposition.d.ts +7 -0
  372. package/lib/mixed/mixedComposition.esm.js +37 -0
  373. package/lib/mixed/mixedComposition.esm.js.map +1 -0
  374. package/lib/mixed/mixedNodeEditor.cjs.js +2 -0
  375. package/lib/mixed/mixedNodeEditor.cjs.js.map +1 -0
  376. package/lib/mixed/mixedNodeEditor.d.ts +12 -0
  377. package/lib/mixed/mixedNodeEditor.esm.js +20 -0
  378. package/lib/mixed/mixedNodeEditor.esm.js.map +1 -0
  379. package/lib/mixed/mixedScalar.cjs.js +2 -0
  380. package/lib/mixed/mixedScalar.cjs.js.map +1 -0
  381. package/lib/mixed/mixedScalar.d.ts +4 -0
  382. package/lib/mixed/mixedScalar.esm.js +6 -0
  383. package/lib/mixed/mixedScalar.esm.js.map +1 -0
  384. package/lib/mixed/mixedSchema.cjs.js +2 -0
  385. package/lib/mixed/mixedSchema.cjs.js.map +1 -0
  386. package/lib/mixed/mixedSchema.d.ts +22 -0
  387. package/lib/mixed/mixedSchema.esm.js +88 -0
  388. package/lib/mixed/mixedSchema.esm.js.map +1 -0
  389. package/lib/mixed/mixedTree.cjs.js +2 -0
  390. package/lib/mixed/mixedTree.cjs.js.map +1 -0
  391. package/lib/mixed/mixedTree.d.ts +19 -0
  392. package/lib/mixed/mixedTree.esm.js +78 -0
  393. package/lib/mixed/mixedTree.esm.js.map +1 -0
  394. package/lib/mixed/mixedTreeActions.cjs.js +2 -0
  395. package/lib/mixed/mixedTreeActions.cjs.js.map +1 -0
  396. package/lib/mixed/mixedTreeActions.d.ts +6 -0
  397. package/lib/mixed/mixedTreeActions.esm.js +17 -0
  398. package/lib/mixed/mixedTreeActions.esm.js.map +1 -0
  399. package/lib/mixed/recursiveTree.cjs.js +2 -0
  400. package/lib/mixed/recursiveTree.cjs.js.map +1 -0
  401. package/lib/mixed/recursiveTree.d.ts +9 -0
  402. package/lib/mixed/recursiveTree.esm.js +49 -0
  403. package/lib/mixed/recursiveTree.esm.js.map +1 -0
  404. package/lib/mixed/useMixedNavigation.cjs.js +2 -0
  405. package/lib/mixed/useMixedNavigation.cjs.js.map +1 -0
  406. package/lib/mixed/useMixedNavigation.d.ts +6 -0
  407. package/lib/mixed/useMixedNavigation.esm.js +21 -0
  408. package/lib/mixed/useMixedNavigation.esm.js.map +1 -0
  409. package/lib/mixed/useMixedRenderer.cjs.js +2 -0
  410. package/lib/mixed/useMixedRenderer.cjs.js.map +1 -0
  411. package/lib/mixed/useMixedRenderer.d.ts +61 -0
  412. package/lib/mixed/useMixedRenderer.esm.js +185 -0
  413. package/lib/mixed/useMixedRenderer.esm.js.map +1 -0
  414. package/lib/mixed/useMixedType.cjs.js +2 -0
  415. package/lib/mixed/useMixedType.cjs.js.map +1 -0
  416. package/lib/mixed/useMixedType.d.ts +6 -0
  417. package/lib/mixed/useMixedType.esm.js +23 -0
  418. package/lib/mixed/useMixedType.esm.js.map +1 -0
  419. package/lib/objects/IsolatedPropertyEditor.cjs.js +2 -0
  420. package/lib/objects/IsolatedPropertyEditor.cjs.js.map +1 -0
  421. package/lib/objects/IsolatedPropertyEditor.d.ts +35 -0
  422. package/lib/objects/IsolatedPropertyEditor.esm.js +27 -0
  423. package/lib/objects/IsolatedPropertyEditor.esm.js.map +1 -0
  424. package/lib/objects/ObjectDetail.cjs.js +2 -0
  425. package/lib/objects/ObjectDetail.cjs.js.map +1 -0
  426. package/lib/objects/ObjectDetail.d.ts +42 -0
  427. package/lib/objects/ObjectDetail.esm.js +103 -0
  428. package/lib/objects/ObjectDetail.esm.js.map +1 -0
  429. package/lib/objects/additionalProperties.cjs.js +2 -0
  430. package/lib/objects/additionalProperties.cjs.js.map +1 -0
  431. package/lib/objects/additionalProperties.d.ts +14 -0
  432. package/lib/objects/additionalProperties.esm.js +41 -0
  433. package/lib/objects/additionalProperties.esm.js.map +1 -0
  434. package/lib/objects/additionalPropertyName.cjs.js +2 -0
  435. package/lib/objects/additionalPropertyName.cjs.js.map +1 -0
  436. package/lib/objects/additionalPropertyName.d.ts +63 -0
  437. package/lib/objects/additionalPropertyName.esm.js +46 -0
  438. package/lib/objects/additionalPropertyName.esm.js.map +1 -0
  439. package/lib/objects/conditionalFields.cjs.js +2 -0
  440. package/lib/objects/conditionalFields.cjs.js.map +1 -0
  441. package/lib/objects/conditionalFields.d.ts +18 -0
  442. package/lib/objects/conditionalFields.esm.js +105 -0
  443. package/lib/objects/conditionalFields.esm.js.map +1 -0
  444. package/lib/objects/dynamicProperties.cjs.js +2 -0
  445. package/lib/objects/dynamicProperties.cjs.js.map +1 -0
  446. package/lib/objects/dynamicProperties.d.ts +10 -0
  447. package/lib/objects/dynamicProperties.esm.js +33 -0
  448. package/lib/objects/dynamicProperties.esm.js.map +1 -0
  449. package/lib/objects/literalPropertySchema.cjs.js +2 -0
  450. package/lib/objects/literalPropertySchema.cjs.js.map +1 -0
  451. package/lib/objects/literalPropertySchema.d.ts +2 -0
  452. package/lib/objects/literalPropertySchema.esm.js +38 -0
  453. package/lib/objects/literalPropertySchema.esm.js.map +1 -0
  454. package/lib/objects/useAdditionalPropertyEntries.cjs.js +2 -0
  455. package/lib/objects/useAdditionalPropertyEntries.cjs.js.map +1 -0
  456. package/lib/objects/useAdditionalPropertyEntries.d.ts +72 -0
  457. package/lib/objects/useAdditionalPropertyEntries.esm.js +71 -0
  458. package/lib/objects/useAdditionalPropertyEntries.esm.js.map +1 -0
  459. package/lib/rolldown-runtime-BocRIvOZ.js +1 -0
  460. package/lib/tuple/TupleControlContent.cjs.js +2 -0
  461. package/lib/tuple/TupleControlContent.cjs.js.map +1 -0
  462. package/lib/tuple/TupleControlContent.d.ts +17 -0
  463. package/lib/tuple/TupleControlContent.esm.js +74 -0
  464. package/lib/tuple/TupleControlContent.esm.js.map +1 -0
  465. package/lib/tuple/TupleField.cjs.js +2 -0
  466. package/lib/tuple/TupleField.cjs.js.map +1 -0
  467. package/lib/tuple/TupleField.d.ts +15 -0
  468. package/lib/tuple/TupleField.esm.js +72 -0
  469. package/lib/tuple/TupleField.esm.js.map +1 -0
  470. package/lib/tuple/tupleSchema.cjs.js +2 -0
  471. package/lib/tuple/tupleSchema.cjs.js.map +1 -0
  472. package/lib/tuple/tupleSchema.d.ts +93 -0
  473. package/lib/tuple/tupleSchema.esm.js +63 -0
  474. package/lib/tuple/tupleSchema.esm.js.map +1 -0
  475. package/lib/tuple/useTupleAdditionalItems.cjs.js +2 -0
  476. package/lib/tuple/useTupleAdditionalItems.cjs.js.map +1 -0
  477. package/lib/tuple/useTupleAdditionalItems.d.ts +45 -0
  478. package/lib/tuple/useTupleAdditionalItems.esm.js +47 -0
  479. package/lib/tuple/useTupleAdditionalItems.esm.js.map +1 -0
  480. package/lib/tuple/useTupleControl.cjs.js +3 -0
  481. package/lib/tuple/useTupleControl.cjs.js.map +1 -0
  482. package/lib/tuple/useTupleControl.d.ts +26 -0
  483. package/lib/tuple/useTupleControl.esm.js +84 -0
  484. package/lib/tuple/useTupleControl.esm.js.map +1 -0
  485. package/lib/tuple/useTupleField.cjs.js +2 -0
  486. package/lib/tuple/useTupleField.cjs.js.map +1 -0
  487. package/lib/tuple/useTupleField.d.ts +38 -0
  488. package/lib/tuple/useTupleField.esm.js +80 -0
  489. package/lib/tuple/useTupleField.esm.js.map +1 -0
  490. package/lib/validation/ItemValidationIndicator.cjs.js +2 -0
  491. package/lib/validation/ItemValidationIndicator.cjs.js.map +1 -0
  492. package/lib/validation/ItemValidationIndicator.d.ts +9 -0
  493. package/lib/validation/ItemValidationIndicator.esm.js +14 -0
  494. package/lib/validation/ItemValidationIndicator.esm.js.map +1 -0
  495. package/lib/validation/errorSummary.cjs.js +9 -0
  496. package/lib/validation/errorSummary.cjs.js.map +1 -0
  497. package/lib/validation/errorSummary.d.ts +44 -0
  498. package/lib/validation/errorSummary.esm.js +194 -0
  499. package/lib/validation/errorSummary.esm.js.map +1 -0
  500. package/lib/validation/preTouchErrors.cjs.js +2 -0
  501. package/lib/validation/preTouchErrors.cjs.js.map +1 -0
  502. package/lib/validation/preTouchErrors.d.ts +77 -0
  503. package/lib/validation/preTouchErrors.esm.js +42 -0
  504. package/lib/validation/preTouchErrors.esm.js.map +1 -0
  505. package/lib/validation/validationIndicator.cjs.js +2 -0
  506. package/lib/validation/validationIndicator.cjs.js.map +1 -0
  507. package/lib/validation/validationIndicator.d.ts +72 -0
  508. package/lib/validation/validationIndicator.esm.js +66 -0
  509. package/lib/validation/validationIndicator.esm.js.map +1 -0
  510. package/lib/webcomponent/element.cjs.js +2 -0
  511. package/lib/webcomponent/element.cjs.js.map +1 -0
  512. package/lib/webcomponent/element.d.ts +48 -0
  513. package/lib/webcomponent/element.esm.js +85 -0
  514. package/lib/webcomponent/element.esm.js.map +1 -0
  515. package/lib/webcomponent/input.cjs.js +2 -0
  516. package/lib/webcomponent/input.cjs.js.map +1 -0
  517. package/lib/webcomponent/input.d.ts +6 -0
  518. package/lib/webcomponent/input.esm.js +25 -0
  519. package/lib/webcomponent/input.esm.js.map +1 -0
  520. package/package.json +86 -3
  521. package/src/cells/CellSummary.tsx +59 -0
  522. package/src/cells/cellMode.tsx +21 -0
  523. package/src/cells/compositeActions.ts +21 -0
  524. package/src/cells/compositeCellTester.ts +15 -0
  525. package/src/cells/compositeSummary.ts +149 -0
  526. package/src/cells/useCompositeCellPresentation.ts +37 -0
  527. package/src/cells/useCompositeDraft.ts +199 -0
  528. package/src/collections/CollectionErrorNavigation.tsx +123 -0
  529. package/src/collections/arrayChoices.ts +235 -0
  530. package/src/collections/collectionPagination.ts +95 -0
  531. package/src/collections/columnResize.tsx +151 -0
  532. package/src/collections/rowDetail.tsx +208 -0
  533. package/src/collections/tableColumns.ts +39 -0
  534. package/src/collections/useArrayPanelState.ts +25 -0
  535. package/src/collections/useCollectionDelete.ts +62 -0
  536. package/src/collections/useTableSelection.ts +77 -0
  537. package/src/composition/AllOfRenderer.tsx +79 -0
  538. package/src/composition/CombinatorBranch.tsx +93 -0
  539. package/src/composition/CombinatorProperties.tsx +56 -0
  540. package/src/composition/ScalarCompositionControl.tsx +34 -0
  541. package/src/composition/choiceCards.tsx +389 -0
  542. package/src/composition/combinators.ts +131 -0
  543. package/src/composition/discriminatorBranch.ts +82 -0
  544. package/src/composition/scalarComposition.ts +193 -0
  545. package/src/composition/useCombinatorSelection.ts +53 -0
  546. package/src/composition/useScalarComposition.ts +67 -0
  547. package/src/controls/FileArrayInput.tsx +407 -0
  548. package/src/controls/controlHelp.ts +28 -0
  549. package/src/controls/inputAdornments.tsx +337 -0
  550. package/src/controls/numeric.ts +43 -0
  551. package/src/controls/useClearAffordance.ts +22 -0
  552. package/src/controls/useDebouncedChange.ts +138 -0
  553. package/src/controls/useFocus.ts +32 -0
  554. package/src/core/configNamespaces.ts +67 -0
  555. package/src/core/dataPointer.ts +8 -0
  556. package/src/core/detailUiSchema.ts +88 -0
  557. package/src/core/plainRecord.ts +8 -0
  558. package/src/core/uiSchemaCycle.tsx +122 -0
  559. package/src/dynamic/DynamicUiProvider.tsx +414 -0
  560. package/src/dynamic/dynamicCel.ts +68 -0
  561. package/src/dynamic/dynamicConfig.ts +26 -0
  562. package/src/dynamic/dynamicRuntime.ts +25 -0
  563. package/src/dynamic/dynamicScope.ts +22 -0
  564. package/src/dynamic/dynamicTree.ts +128 -0
  565. package/src/dynamic/dynamicUi.ts +711 -0
  566. package/src/formats/colorFormat.ts +390 -0
  567. package/src/formats/dateValues.ts +45 -0
  568. package/src/formats/duration.ts +60 -0
  569. package/src/formats/maskControls.ts +88 -0
  570. package/src/formats/maskFormat.ts +375 -0
  571. package/src/formats/temporalBounds.ts +219 -0
  572. package/src/formats/temporalFormats.ts +128 -0
  573. package/src/formats/useMaskedInput.ts +194 -0
  574. package/src/index.ts +42 -0
  575. package/src/interaction/confirmation.ts +211 -0
  576. package/src/interaction/createDeleteConfirmation.ts +23 -0
  577. package/src/interaction/detailDialog.ts +138 -0
  578. package/src/interaction/pendingChanges.tsx +55 -0
  579. package/src/interaction/useConfirmationState.ts +55 -0
  580. package/src/interaction/visuallyHidden.ts +19 -0
  581. package/src/layout/categoryState.ts +189 -0
  582. package/src/layout/groupState.ts +201 -0
  583. package/src/layout/layoutContext.tsx +49 -0
  584. package/src/layout/layoutSizing.ts +369 -0
  585. package/src/locale/bg.ts +309 -0
  586. package/src/locale/calendar.ts +57 -0
  587. package/src/locale/en.ts +375 -0
  588. package/src/locale/index.ts +5 -0
  589. package/src/locale/intl.ts +10 -0
  590. package/src/locale/rendererLocale.ts +74 -0
  591. package/src/locale/translate.ts +98 -0
  592. package/src/mixed/MixedDetailControl.tsx +182 -0
  593. package/src/mixed/RecursiveTreeRenderer.tsx +388 -0
  594. package/src/mixed/createMixedTypeChangeHandler.ts +77 -0
  595. package/src/mixed/mixedComposition.ts +76 -0
  596. package/src/mixed/mixedNodeEditor.ts +47 -0
  597. package/src/mixed/mixedScalar.ts +7 -0
  598. package/src/mixed/mixedSchema.ts +283 -0
  599. package/src/mixed/mixedTree.ts +199 -0
  600. package/src/mixed/mixedTreeActions.ts +60 -0
  601. package/src/mixed/recursiveTree.ts +105 -0
  602. package/src/mixed/useMixedNavigation.ts +36 -0
  603. package/src/mixed/useMixedRenderer.ts +300 -0
  604. package/src/mixed/useMixedType.ts +45 -0
  605. package/src/objects/IsolatedPropertyEditor.tsx +86 -0
  606. package/src/objects/ObjectDetail.tsx +232 -0
  607. package/src/objects/additionalProperties.ts +151 -0
  608. package/src/objects/additionalPropertyName.ts +185 -0
  609. package/src/objects/conditionalFields.ts +173 -0
  610. package/src/objects/dynamicProperties.tsx +68 -0
  611. package/src/objects/literalPropertySchema.ts +100 -0
  612. package/src/objects/useAdditionalPropertyEntries.ts +204 -0
  613. package/src/tuple/TupleControlContent.tsx +152 -0
  614. package/src/tuple/TupleField.tsx +150 -0
  615. package/src/tuple/tupleSchema.ts +245 -0
  616. package/src/tuple/useTupleAdditionalItems.ts +131 -0
  617. package/src/tuple/useTupleControl.tsx +173 -0
  618. package/src/tuple/useTupleField.ts +164 -0
  619. package/src/validation/ItemValidationIndicator.tsx +21 -0
  620. package/src/validation/errorSummary.tsx +489 -0
  621. package/src/validation/preTouchErrors.ts +185 -0
  622. package/src/validation/validationIndicator.ts +202 -0
  623. package/src/webcomponent/element.ts +107 -0
  624. package/src/webcomponent/input.ts +56 -0
@@ -0,0 +1,103 @@
1
+ import { UiSchemaCycleProvider as e, useUiSchemaCycleGuard as t } from "../core/uiSchemaCycle.esm.js";
2
+ import { useDynamicTreeResolver as n } from "../dynamic/DynamicUiProvider.esm.js";
3
+ import { findDetailUISchema as r } from "../core/detailUiSchema.esm.js";
4
+ import { ObjectErrorContext as i, usePathErrorIndicator as a } from "../validation/errorSummary.esm.js";
5
+ import { conditionalFieldsEnabled as o, conditionalLayout as s, hasConditionalFields as c, useConditionalFields as l } from "./conditionalFields.esm.js";
6
+ import u, { useMemo as d } from "react";
7
+ import { Generate as f, isObjectControl as p } from "@jsonforms/core";
8
+ import { JsonFormsDispatch as m, useJsonForms as h } from "@jsonforms/react";
9
+ // src/objects/ObjectDetail.tsx
10
+ var g = u.createContext(void 0);
11
+ function _({ schema: e, rootSchema: t, data: n, uischema: r, config: i }) {
12
+ let a = h(), o = d(() => a.uischemas ?? [], [a.uischemas]), s = l(e, t, n, r, i), c = s.schema;
13
+ return {
14
+ uischemas: o,
15
+ conditional: s,
16
+ schema: c,
17
+ additionalSchema: {
18
+ ...c,
19
+ properties: {
20
+ ...Object.fromEntries([...s.known].map((e) => [e, {}])),
21
+ ...c.properties
22
+ }
23
+ }
24
+ };
25
+ }
26
+ function v({ props: e, schema: t, uischema: n, diagnostics: r, errors: a, additional: o }) {
27
+ let s = n.elements, c = n.type === "Group" || !Array.isArray(s) || s.length > 0;
28
+ return /* @__PURE__ */ u.createElement(u.Fragment, null, r.map((e) => /* @__PURE__ */ u.createElement("div", {
29
+ key: e,
30
+ role: "alert"
31
+ }, e)), /* @__PURE__ */ u.createElement(i.Provider, { value: {
32
+ uischema: n,
33
+ message: a
34
+ } }, /* @__PURE__ */ u.createElement(g.Provider, { value: {
35
+ uischema: n,
36
+ additional: o
37
+ } }, c && /* @__PURE__ */ u.createElement(m, {
38
+ visible: e.visible,
39
+ enabled: e.enabled,
40
+ schema: t,
41
+ uischema: n,
42
+ path: e.path,
43
+ renderers: e.renderers,
44
+ cells: e.cells,
45
+ readonly: e.readonly
46
+ }))));
47
+ }
48
+ var y = (e, t, n) => p(e, t, n) ? o(e, n.config) && c(t) ? 25 : 2 : -1;
49
+ function b(t) {
50
+ return (n, r, i, a, o) => {
51
+ let s = i.type === "Group", c = /* @__PURE__ */ u.createElement(t, {
52
+ ...n,
53
+ embedded: !!n.path || s,
54
+ schema: r.additionalSchema,
55
+ uischemas: r.uischemas
56
+ });
57
+ return {
58
+ isGroup: s,
59
+ additional: c,
60
+ detail: /* @__PURE__ */ u.createElement(e, { stack: a }, /* @__PURE__ */ u.createElement(v, {
61
+ props: n,
62
+ schema: r.schema,
63
+ uischema: i,
64
+ diagnostics: r.conditional.diagnostics,
65
+ errors: o,
66
+ additional: c
67
+ })),
68
+ title: n.label && n.path && n.uischema.label !== !1 ? n.label : void 0
69
+ };
70
+ };
71
+ }
72
+ function x(e, i, o = !1) {
73
+ let c = b(e);
74
+ return function(e) {
75
+ let l = _(e), { path: p, rootSchema: m, uischema: h, label: g } = e, { schema: v, conditional: y, uischemas: b } = l, x = d(() => ({
76
+ ...f.uiSchema(v, p ? "Group" : "VerticalLayout", void 0, m),
77
+ ...p ? { label: o && h.label === !1 ? void 0 : g } : {}
78
+ }), [
79
+ v,
80
+ p,
81
+ m,
82
+ h.label,
83
+ g
84
+ ]), S = d(() => r(b, v, h.scope, p, () => x, h, m), [
85
+ b,
86
+ v,
87
+ h,
88
+ p,
89
+ x,
90
+ m
91
+ ]), { cycle: C, stack: w } = t(S, p, "the object renderer"), T = n(p), E = s(T(C ? x : S), v, y.known), D = a(p, void 0, !1);
92
+ if (!e.visible) return null;
93
+ let O = c(e, l, E, w, D);
94
+ return O.isGroup ? O.detail : /* @__PURE__ */ u.createElement(i, {
95
+ path: p,
96
+ errors: D,
97
+ ...O
98
+ });
99
+ };
100
+ }
101
+ export { v as ObjectDetail, g as ObjectDetailContext, b as createObjectPresentation, x as createObjectRenderer, y as objectControlTester, _ as useObjectSchema };
102
+
103
+ //# sourceMappingURL=ObjectDetail.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ObjectDetail.esm.js","names":["React","ObjectDetailContext","useObjectSchema","originalSchema","jsonforms","useJsonForms","uischemas","useMemo","conditional","useConditionalFields","rootSchema","data","uischema","config","schema","key","ObjectDetail","elements","showContent","diagnostics","message","ObjectErrorContext","errors","JsonFormsDispatch","props","objectControlTester","isObjectControl","ui","context","conditionalFieldsEnabled","hasConditionalFields","createObjectPresentation","isGroup","additional","AdditionalProperties","state","UiSchemaCycleProvider","createObjectRenderer","presentation","generated","Generate","path","hideGeneratedLabel","label","detailUiSchema","findDetailUISchema","useUiSchemaCycleGuard","resolveTree","useDynamicTreeResolver","dispatchUiSchema","conditionalLayout","cycle","usePathErrorIndicator","content","stack","Frame"],"sources":["../../src/objects/ObjectDetail.tsx"],"sourcesContent":["import {\n UiSchemaCycleProvider,\n useUiSchemaCycleGuard,\n} from '../core/uiSchemaCycle';\nimport type { AdditionalPropertiesProps } from './useAdditionalPropertyEntries';\nimport React, { useMemo } from 'react';\nimport {\n Generate,\n isObjectControl,\n type RankedTester,\n type ControlProps,\n type UISchemaElement,\n} from '@jsonforms/core';\nimport { JsonFormsDispatch, useJsonForms } from '@jsonforms/react';\nimport { useDynamicTreeResolver } from '../dynamic/DynamicUiProvider';\nimport { findDetailUISchema } from '../core/detailUiSchema';\nimport {\n ObjectErrorContext,\n usePathErrorIndicator,\n} from '../validation/errorSummary';\nimport {\n conditionalLayout,\n useConditionalFields,\n conditionalFieldsEnabled,\n hasConditionalFields,\n} from './conditionalFields';\n\nexport const ObjectDetailContext = React.createContext<\n { uischema: UISchemaElement; additional: React.ReactNode } | undefined\n>(undefined);\n\nexport function useObjectSchema({\n schema: originalSchema,\n rootSchema,\n data,\n uischema,\n config,\n}: ControlProps) {\n const jsonforms = useJsonForms();\n const uischemas = useMemo(\n () => jsonforms.uischemas ?? [],\n [jsonforms.uischemas],\n );\n const conditional = useConditionalFields(\n originalSchema,\n rootSchema,\n data,\n uischema,\n config,\n );\n const schema = conditional.schema;\n const additionalSchema = {\n ...schema,\n properties: {\n ...Object.fromEntries([...conditional.known].map((key) => [key, {}])),\n ...schema.properties,\n },\n } as ControlProps['schema'];\n return { uischemas, conditional, schema, additionalSchema };\n}\n\nexport function ObjectDetail({\n props,\n schema,\n uischema,\n diagnostics,\n errors,\n additional,\n}: {\n props: ControlProps;\n schema: ControlProps['schema'];\n uischema: UISchemaElement;\n diagnostics: readonly string[];\n errors: string;\n additional: React.ReactNode;\n}) {\n const elements = (uischema as { elements?: unknown[] }).elements;\n const showContent =\n uischema.type === 'Group' ||\n !Array.isArray(elements) ||\n elements.length > 0;\n return (\n <>\n {diagnostics.map((message) => (\n <div key={message} role='alert'>\n {message}\n </div>\n ))}\n <ObjectErrorContext.Provider value={{ uischema, message: errors }}>\n <ObjectDetailContext.Provider value={{ uischema, additional }}>\n {showContent && (\n <JsonFormsDispatch\n visible={props.visible}\n enabled={props.enabled}\n schema={schema}\n uischema={uischema}\n path={props.path}\n renderers={props.renderers}\n cells={props.cells}\n readonly={props.readonly}\n />\n )}\n </ObjectDetailContext.Provider>\n </ObjectErrorContext.Provider>\n </>\n );\n}\n\nexport const objectControlTester: RankedTester = (ui, schema, context) =>\n isObjectControl(ui, schema, context)\n ? conditionalFieldsEnabled(ui, context.config) &&\n hasConditionalFields(schema)\n ? 25\n : 2\n : -1;\n\n/** Assemble the shared object boundary while adapters retain their native outer frame. */\nexport function createObjectPresentation(\n AdditionalProperties: React.ComponentType<AdditionalPropertiesProps>,\n) {\n return (\n props: ControlProps,\n state: ReturnType<typeof useObjectSchema>,\n uischema: UISchemaElement,\n stack: ReadonlySet<string>,\n errors: string,\n ) => {\n const isGroup = uischema.type === 'Group';\n const additional = (\n <AdditionalProperties\n {...props}\n embedded={Boolean(props.path) || isGroup}\n schema={state.additionalSchema}\n uischemas={state.uischemas}\n />\n );\n const detail = (\n <UiSchemaCycleProvider stack={stack}>\n <ObjectDetail\n props={props}\n schema={state.schema}\n uischema={uischema}\n diagnostics={state.conditional.diagnostics}\n errors={errors}\n additional={additional}\n />\n </UiSchemaCycleProvider>\n );\n return {\n isGroup,\n additional,\n detail,\n title:\n props.label && props.path && props.uischema.label !== false\n ? props.label\n : undefined,\n };\n };\n}\n\nexport interface ObjectFrameProps {\n path: string;\n title?: string;\n errors: string;\n detail: React.ReactNode;\n additional: React.ReactNode;\n}\n\n/** Shared resolution and boundary ownership; native frames remain adapter-specific. */\nexport function createObjectRenderer(\n AdditionalProperties: React.ComponentType<AdditionalPropertiesProps>,\n Frame: React.ComponentType<ObjectFrameProps>,\n hideGeneratedLabel = false,\n) {\n const presentation = createObjectPresentation(AdditionalProperties);\n return function ObjectRenderer(props: ControlProps) {\n const state = useObjectSchema(props);\n const { path, rootSchema, uischema, label } = props;\n const { schema, conditional, uischemas } = state;\n const generated = useMemo(\n () => ({\n ...Generate.uiSchema(\n schema,\n path ? 'Group' : 'VerticalLayout',\n undefined,\n rootSchema,\n ),\n ...(path\n ? {\n label:\n hideGeneratedLabel && uischema.label === false\n ? undefined\n : label,\n }\n : {}),\n }),\n [schema, path, rootSchema, uischema.label, label],\n );\n const detailUiSchema = useMemo(\n () =>\n findDetailUISchema(\n uischemas,\n schema,\n uischema.scope,\n path,\n () => generated,\n uischema,\n rootSchema,\n ),\n [uischemas, schema, uischema, path, generated, rootSchema],\n );\n const { cycle, stack } = useUiSchemaCycleGuard(\n detailUiSchema,\n path,\n 'the object renderer',\n );\n const resolveTree = useDynamicTreeResolver(path);\n const dispatchUiSchema = conditionalLayout(\n resolveTree(cycle ? generated : detailUiSchema),\n schema,\n conditional.known,\n );\n const errors = usePathErrorIndicator(path, undefined, false);\n if (!props.visible) return null;\n const content = presentation(props, state, dispatchUiSchema, stack, errors);\n return content.isGroup ? (\n content.detail\n ) : (\n <Frame path={path} errors={errors} {...content} />\n );\n };\n}\n"],"mappings":";;;;;;;;;AA2BA,IAAaC,IAAsBD,EAAM,cAEvC,KAAA,CAAS;AAEX,SAAgBE,EAAgB,EAC9B,QAAQC,GACR,eACA,SACA,aACA,aACe;CACf,IAAMC,IAAYC,EAAa,GACzBC,IAAYC,QACVH,EAAU,aAAa,CAAC,GAC9B,CAACA,EAAU,SAAS,CACtB,GACMI,IAAcC,EAClBN,GACAO,GACAC,GACAC,GACAC,CACF,G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AER,kBAAA,cAACE,GAAD;GAAa;GAAc;GAAQ,GAAIF;EAAU,CAAA;CAErD;AACF"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@jsonforms/core");var t=[`array`,`boolean`,`integer`,`null`,`number`,`object`,`string`],n=e=>typeof e==`object`?e:{},r=e=>{let t=n(e);return!!(t.patternProperties&&Object.keys(t.patternProperties).length>0)||typeof t.additionalProperties==`object`||t.additionalProperties===!0},i=(r,i,a,o)=>{let s=n(i),c;if(s.patternProperties){let e=Object.entries(s.patternProperties).filter(([e])=>new RegExp(e).test(r)).map(([,e])=>e);e.length===1&&(c=e[0]),e.length>1&&(c={allOf:e})}return c||typeof s.additionalProperties!=`object`&&s.additionalProperties!==!0||(c=s.additionalProperties===!0?{type:t}:s.additionalProperties),!c&&o&&(c={type:t}),typeof c==`object`&&typeof c.$ref==`string`&&(c=(0,e.resolveSchema)(a,c.$ref,a)),c=c??{type:t},typeof c==`object`&&c.type===void 0&&(c={...c,type:t}),c},a=(t,n,r,a,o)=>{let s=i(t,r,a,o),c=(0,e.createControlElement)(`#`);return typeof s==`object`&&s.type===`array`&&(c=e.Generate.uiSchema(s,`Group`,void 0,a),c.label=s.title??t),typeof s==`object`&&(s={...s,title:t},s.type===`object`?s.additionalProperties=s.additionalProperties===!1?!1:s.additionalProperties??!0:s.type===`array`&&(s.items=s.items??{})),{propertyName:t,path:(0,e.composePaths)(n,t),schema:s,uischema:c}};function o(e,t,n){return Object.fromEntries(Object.entries(e).map(([e,r])=>[e===t?n:e,r]))}exports.getMatchingAdditionalPropertySchema=i,exports.hasAdditionalProperties=r,exports.renamePropertyKey=o,exports.toAdditionalPropertyItem=a,exports.toObjectSchema=n;
2
+ //# sourceMappingURL=additionalProperties.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"additionalProperties.cjs.js","names":["resolveSchema","createControlElement","Generate","composePaths","_jsonforms_core","ANY_TYPE","toObjectSchema","schema","hasAdditionalProperties","objectSchema","getMatchingAdditionalPropertySchema","parentSchema","propSchema","matchingSchemas","pattern","propName","candidate","allowIfMissing","rootSchema","toAdditionalPropertyItem","propUiSchema","parentPath","renamePropertyKey","data","key","value","previous","next"],"sources":["../../src/objects/additionalProperties.ts"],"sourcesContent":["import {\n composePaths,\n createControlElement,\n Generate,\n GroupLayout,\n JsonSchema,\n JsonSchema7,\n resolveSchema,\n UISchemaElement,\n} from '@jsonforms/core';\nconst ANY_TYPE: JsonSchema7['type'] = [\n 'array',\n 'boolean',\n 'integer',\n 'null',\n 'number',\n 'object',\n 'string',\n];\n\nexport type AdditionalPropertyItem = {\n propertyName: string;\n path: string;\n schema: JsonSchema;\n uischema: UISchemaElement;\n};\n\nexport const toObjectSchema = (schema: JsonSchema): JsonSchema7 =>\n typeof schema === 'object' ? (schema as JsonSchema7) : {};\n\nexport const hasAdditionalProperties = (schema: JsonSchema): boolean => {\n const objectSchema = toObjectSchema(schema);\n return (\n Boolean(\n objectSchema.patternProperties &&\n Object.keys(objectSchema.patternProperties).length > 0,\n ) ||\n typeof objectSchema.additionalProperties === 'object' ||\n objectSchema.additionalProperties === true\n );\n};\n\nexport const getMatchingAdditionalPropertySchema = (\n propName: string,\n parentSchema: JsonSchema,\n rootSchema: JsonSchema,\n allowIfMissing: boolean,\n): JsonSchema => {\n const objectSchema = toObjectSchema(parentSchema);\n let propSchema: JsonSchema | undefined;\n\n if (objectSchema.patternProperties) {\n const matchingSchemas = Object.entries(objectSchema.patternProperties)\n .filter(([pattern]) => new RegExp(pattern).test(propName))\n .map(([, candidate]) => candidate);\n if (matchingSchemas.length === 1) propSchema = matchingSchemas[0];\n if (matchingSchemas.length > 1) propSchema = { allOf: matchingSchemas };\n }\n\n if (\n !propSchema &&\n (typeof objectSchema.additionalProperties === 'object' ||\n objectSchema.additionalProperties === true)\n ) {\n propSchema =\n objectSchema.additionalProperties === true\n ? { type: ANY_TYPE }\n : objectSchema.additionalProperties;\n }\n\n if (!propSchema && allowIfMissing) {\n propSchema = { type: ANY_TYPE };\n }\n\n if (typeof propSchema === 'object' && typeof propSchema.$ref === 'string') {\n propSchema = resolveSchema(rootSchema, propSchema.$ref, rootSchema);\n }\n\n propSchema = propSchema ?? { type: ANY_TYPE };\n\n if (typeof propSchema === 'object' && propSchema.type === undefined) {\n propSchema = {\n ...propSchema,\n type: ANY_TYPE,\n };\n }\n\n return propSchema;\n};\n\nexport const toAdditionalPropertyItem = (\n propName: string,\n parentPath: string,\n parentSchema: JsonSchema,\n rootSchema: JsonSchema,\n allowIfMissing: boolean,\n): AdditionalPropertyItem => {\n let propSchema = getMatchingAdditionalPropertySchema(\n propName,\n parentSchema,\n rootSchema,\n allowIfMissing,\n );\n let propUiSchema: UISchemaElement = createControlElement('#');\n\n if (typeof propSchema === 'object' && propSchema.type === 'array') {\n propUiSchema = Generate.uiSchema(\n propSchema,\n 'Group',\n undefined,\n rootSchema,\n );\n (propUiSchema as GroupLayout).label = propSchema.title ?? propName;\n }\n\n if (typeof propSchema === 'object') {\n propSchema = {\n ...propSchema,\n title: propName,\n };\n\n if (propSchema.type === 'object') {\n propSchema.additionalProperties =\n propSchema.additionalProperties !== false\n ? (propSchema.additionalProperties ?? true)\n : false;\n } else if (propSchema.type === 'array') {\n propSchema.items = propSchema.items ?? {};\n }\n }\n\n return {\n propertyName: propName,\n path: composePaths(parentPath, propName),\n schema: propSchema,\n uischema: propUiSchema,\n };\n};\n\nexport function renamePropertyKey(\n data: object,\n previous: string,\n next: string,\n) {\n return Object.fromEntries(\n Object.entries(data).map(([key, value]) => [\n key === previous ? next : key,\n value,\n ]),\n );\n}\n"],"mappings":"A,oGAUA,IAAMK,EAAgC,CACpC,QACA,UACA,UACA,OACA,SACA,SACA,QACF,EASaC,EAAkB,GAC7B,OAAOC,GAAW,SAAYA,EAAyB,CAAC,EAE7CC,EAA2B,GAAgC,CACtE,IAAMC,EAAeH,EAAeC,CAAM,EAC1C,MACE,GACEE,EAAa,mBACb,OAAO,KAAKA,E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MAAOG,CACT,EAEIH,EAAW,OAAS,SACtB,EAAW,qBACTA,EAAW,uBAAyB,GAEhC,GADCA,EAAW,sBAAwB,GAEjCA,EAAW,OAAS,UAC7B,EAAW,MAAQA,EAAW,OAAS,CAAC,IAIrC,CACL,aAAcG,EACd,MAAA,EAAMZ,EAAAA,aAAAA,CAAakB,EAAYN,CAAQ,EACvC,OAAQH,EACR,SAAUQ,CACZ,CACF,EAEA,SAAgBE,EACd,EACA,EACA,EACA,CACA,OAAO,OAAO,YACZ,OAAO,QAAQC,CAAI,CAAC,CAAC,KAAK,CAACC,EAAKC,KAAW,CACzCD,IAAQE,EAAWC,EAAOH,EAC1BC,CACF,CAAC,CACH,CACF,C"}
@@ -0,0 +1,14 @@
1
+ import { JsonSchema, JsonSchema7, UISchemaElement } from '@jsonforms/core';
2
+ export type AdditionalPropertyItem = {
3
+ propertyName: string;
4
+ path: string;
5
+ schema: JsonSchema;
6
+ uischema: UISchemaElement;
7
+ };
8
+ export declare const toObjectSchema: (schema: JsonSchema) => JsonSchema7;
9
+ export declare const hasAdditionalProperties: (schema: JsonSchema) => boolean;
10
+ export declare const getMatchingAdditionalPropertySchema: (propName: string, parentSchema: JsonSchema, rootSchema: JsonSchema, allowIfMissing: boolean) => JsonSchema;
11
+ export declare const toAdditionalPropertyItem: (propName: string, parentPath: string, parentSchema: JsonSchema, rootSchema: JsonSchema, allowIfMissing: boolean) => AdditionalPropertyItem;
12
+ export declare function renamePropertyKey(data: object, previous: string, next: string): {
13
+ [k: string]: any;
14
+ };
@@ -0,0 +1,41 @@
1
+ import { Generate as e, composePaths as t, createControlElement as n, resolveSchema as r } from "@jsonforms/core";
2
+ // src/objects/additionalProperties.ts
3
+ var i = [
4
+ "array",
5
+ "boolean",
6
+ "integer",
7
+ "null",
8
+ "number",
9
+ "object",
10
+ "string"
11
+ ], a = (e) => typeof e == "object" ? e : {}, o = (e) => {
12
+ let t = a(e);
13
+ return !!(t.patternProperties && Object.keys(t.patternProperties).length > 0) || typeof t.additionalProperties == "object" || t.additionalProperties === !0;
14
+ }, s = (e, t, n, o) => {
15
+ let s = a(t), c;
16
+ if (s.patternProperties) {
17
+ let t = Object.entries(s.patternProperties).filter(([t]) => new RegExp(t).test(e)).map(([, e]) => e);
18
+ t.length === 1 && (c = t[0]), t.length > 1 && (c = { allOf: t });
19
+ }
20
+ return c || typeof s.additionalProperties != "object" && s.additionalProperties !== !0 || (c = s.additionalProperties === !0 ? { type: i } : s.additionalProperties), !c && o && (c = { type: i }), typeof c == "object" && typeof c.$ref == "string" && (c = r(n, c.$ref, n)), c = c ?? { type: i }, typeof c == "object" && c.type === void 0 && (c = {
21
+ ...c,
22
+ type: i
23
+ }), c;
24
+ }, c = (r, i, a, o, c) => {
25
+ let l = s(r, a, o, c), u = n("#");
26
+ return typeof l == "object" && l.type === "array" && (u = e.uiSchema(l, "Group", void 0, o), u.label = l.title ?? r), typeof l == "object" && (l = {
27
+ ...l,
28
+ title: r
29
+ }, l.type === "object" ? l.additionalProperties = l.additionalProperties === !1 ? !1 : l.additionalProperties ?? !0 : l.type === "array" && (l.items = l.items ?? {})), {
30
+ propertyName: r,
31
+ path: t(i, r),
32
+ schema: l,
33
+ uischema: u
34
+ };
35
+ };
36
+ function l(e, t, n) {
37
+ return Object.fromEntries(Object.entries(e).map(([e, r]) => [e === t ? n : e, r]));
38
+ }
39
+ export { s as getMatchingAdditionalPropertySchema, o as hasAdditionalProperties, l as renamePropertyKey, c as toAdditionalPropertyItem, a as toObjectSchema };
40
+
41
+ //# sourceMappingURL=additionalProperties.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"additionalProperties.esm.js","names":["ANY_TYPE","toObjectSchema","schema","hasAdditionalProperties","objectSchema","getMatchingAdditionalPropertySchema","parentSchema","propSchema","matchingSchemas","pattern","propName","candidate","allowIfMissing","resolveSchema","rootSchema","toAdditionalPropertyItem","propUiSchema","createControlElement","Generate","composePaths","parentPath","renamePropertyKey","data","key","value","previous","next"],"sources":["../../src/objects/additionalProperties.ts"],"sourcesContent":["import {\n composePaths,\n createControlElement,\n Generate,\n GroupLayout,\n JsonSchema,\n JsonSchema7,\n resolveSchema,\n UISchemaElement,\n} from '@jsonforms/core';\nconst ANY_TYPE: JsonSchema7['type'] = [\n 'array',\n 'boolean',\n 'integer',\n 'null',\n 'number',\n 'object',\n 'string',\n];\n\nexport type AdditionalPropertyItem = {\n propertyName: string;\n path: string;\n schema: JsonSchema;\n uischema: UISchemaElement;\n};\n\nexport const toObjectSchema = (schema: JsonSchema): JsonSchema7 =>\n typeof schema === 'object' ? (schema as JsonSchema7) : {};\n\nexport const hasAdditionalProperties = (schema: JsonSchema): boolean => {\n const objectSchema = toObjectSchema(schema);\n return (\n Boolean(\n objectSchema.patternProperties &&\n Object.keys(objectSchema.patternProperties).length > 0,\n ) ||\n typeof objectSchema.additionalProperties === 'object' ||\n objectSchema.additionalProperties === true\n );\n};\n\nexport const getMatchingAdditionalPropertySchema = (\n propName: string,\n parentSchema: JsonSchema,\n rootSchema: JsonSchema,\n allowIfMissing: boolean,\n): JsonSchema => {\n const objectSchema = toObjectSchema(parentSchema);\n let propSchema: JsonSchema | undefined;\n\n if (objectSchema.patternProperties) {\n const matchingSchemas = Object.entries(objectSchema.patternProperties)\n .filter(([pattern]) => new RegExp(pattern).test(propName))\n .map(([, candidate]) => candidate);\n if (matchingSchemas.length === 1) propSchema = matchingSchemas[0];\n if (matchingSchemas.length > 1) propSchema = { allOf: matchingSchemas };\n }\n\n if (\n !propSchema &&\n (typeof objectSchema.additionalProperties === 'object' ||\n objectSchema.additionalProperties === true)\n ) {\n propSchema =\n objectSchema.additionalProperties === true\n ? { type: ANY_TYPE }\n : objectSchema.additionalProperties;\n }\n\n if (!propSchema && allowIfMissing) {\n propSchema = { type: ANY_TYPE };\n }\n\n if (typeof propSchema === 'object' && typeof propSchema.$ref === 'string') {\n propSchema = resolveSchema(rootSchema, propSchema.$ref, rootSchema);\n }\n\n propSchema = propSchema ?? { type: ANY_TYPE };\n\n if (typeof propSchema === 'object' && propSchema.type === undefined) {\n propSchema = {\n ...propSchema,\n type: ANY_TYPE,\n };\n }\n\n return propSchema;\n};\n\nexport const toAdditionalPropertyItem = (\n propName: string,\n parentPath: string,\n parentSchema: JsonSchema,\n rootSchema: JsonSchema,\n allowIfMissing: boolean,\n): AdditionalPropertyItem => {\n let propSchema = getMatchingAdditionalPropertySchema(\n propName,\n parentSchema,\n rootSchema,\n allowIfMissing,\n );\n let propUiSchema: UISchemaElement = createControlElement('#');\n\n if (typeof propSchema === 'object' && propSchema.type === 'array') {\n propUiSchema = Generate.uiSchema(\n propSchema,\n 'Group',\n undefined,\n rootSchema,\n );\n (propUiSchema as GroupLayout).label = propSchema.title ?? propName;\n }\n\n if (typeof propSchema === 'object') {\n propSchema = {\n ...propSchema,\n title: propName,\n };\n\n if (propSchema.type === 'object') {\n propSchema.additionalProperties =\n propSchema.additionalProperties !== false\n ? (propSchema.additionalProperties ?? true)\n : false;\n } else if (propSchema.type === 'array') {\n propSchema.items = propSchema.items ?? {};\n }\n }\n\n return {\n propertyName: propName,\n path: composePaths(parentPath, propName),\n schema: propSchema,\n uischema: propUiSchema,\n };\n};\n\nexport function renamePropertyKey(\n data: object,\n previous: string,\n next: string,\n) {\n return Object.fromEntries(\n Object.entries(data).map(([key, value]) => [\n key === previous ? next : key,\n value,\n ]),\n );\n}\n"],"mappings":";;AAUA,IAAMA,IAAgC;CACpC;CACA;CACA;CACA;CACA;CACA;CACA;AACF,GASaC,KAAkB,MAC7B,OAAOC,KAAW,WAAYA,IAAyB,CAAC,GAE7CC,KAA2B,MAAgC;CACtE,IAAMC,IAAeH,EAAeC,CAAM;CAC1C,OACE,GACEE,EAAa,qBACb,OAAO,KAAKA,EAAa,iBAAiB,CAAC,CAAC,SAAS,MAEvD,OAAOA,EAAa,wBAAyB,YAC7CA,EAAa,yBAAyB;AAE1C,GAEaC,KACX,GACA,GACA,GACA,MACe;CACf,IAAMD,IAAeH,EAAeK,CAAY,GAC5CC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vC,QAAQH;EACR,UAAUS;CACZ;AACF;AAEA,SAAgBK,EACd,GACA,GACA,GACA;CACA,OAAO,OAAO,YACZ,OAAO,QAAQC,CAAI,CAAC,CAAC,KAAK,CAACC,GAAKC,OAAW,CACzCD,MAAQE,IAAWC,IAAOH,GAC1BC,CACF,CAAC,CACH;AACF"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@jsonforms/core");var t=e=>e===``||e.includes(`.`),n=(e,t,n)=>(Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0}),e),r=(t,n)=>{let r=[],i=t.propertyNames;if(i===!1)r.push({not:{}});else if(typeof i==`object`&&i){let t=typeof i.$ref==`string`?e.Resolve.schema(n,i.$ref,n)??i:i;r.push(t)}if(t.additionalProperties===!1){let e=Object.keys(t.patternProperties??{});r.push(e.length>0?{anyOf:e.map(e=>({pattern:e}))}:{not:{}})}return{type:`string`,...r.length>0?{allOf:r}:{}}},i=(0,e.createAjv)(),a=({name:e,schema:t,rootSchema:n,data:a,currentName:o,disallowedNames:s=[],allowEmptyName:c=!1,validate:l})=>{if(!c&&e.trim().length===0)return{name:e,error:`required`};if(([...Object.keys(t.properties??{}),...s].includes(e)||typeof a==`object`&&a&&!Array.isArray(a)&&Object.prototype.hasOwnProperty.call(a,e))&&e!==o)return{name:e,error:`already-defined`};let u=r(t,n),d=!0,f=[];try{d=l?l(u,e):i.validate(u,e),d||(i.validate(u,e),f=[...i.errors??[]])}catch{d=!0}return d?{name:e}:{name:e,error:`invalid`,errors:f}};exports.assignOwnProperty=n,exports.createAdditionalPropertyNameSchema=r,exports.needsIsolatedEditor=t,exports.validateAdditionalPropertyName=a;
2
+ //# sourceMappingURL=additionalPropertyName.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"additionalPropertyName.cjs.js","names":["Resolve","createAjv","_jsonforms_core","needsIsolatedEditor","name","assignOwnProperty","target","createAdditionalPropertyNameSchema","constraints","propertyNames","schema","resolved","rootSchema","patterns","defaultNameValidator","validateAdditionalPropertyName","allowEmptyName","disallowedNames","data","currentName","nameSchema","permitted","errors","validate"],"sources":["../../src/objects/additionalPropertyName.ts"],"sourcesContent":["import { createAjv, JsonSchema, JsonSchema7, Resolve } from '@jsonforms/core';\n\n/**\n * Naming a dynamic property, with no React in it.\n *\n * What a property may be called is decidable from the schema and the current\n * data, so it is settled here and tested without rendering anything.\n */\n\nexport type AdditionalPropertyNameError =\n | 'required'\n | 'already-defined'\n | 'invalid';\n\n/**\n * The name exactly as supplied, and why it was refused if it was.\n *\n * A flat shape with an optional `error` rather than the discriminated union the\n * Svelte module uses: this package compiles with `strict` off, and without\n * `strictNullChecks` TypeScript does not narrow a union on a boolean literal\n * discriminant, so `if (result.valid)` would not give the caller access to\n * `result.error`. `error === undefined` means accepted.\n */\nexport interface AdditionalPropertyNameResult {\n name: string;\n error?: AdditionalPropertyNameError;\n errors?: import('ajv').ErrorObject[];\n}\n\nexport interface ValidateAdditionalPropertyNameOptions {\n name: string;\n schema: JsonSchema;\n rootSchema: JsonSchema;\n data?: unknown;\n /** The name being renamed, which may of course keep its own name. */\n currentName?: string;\n /** Names that are taken for another reason, e.g. declared properties. */\n disallowedNames?: readonly string[];\n allowEmptyName?: boolean;\n /** Only used to evaluate the property-name schema; optional. */\n validate?: (schema: JsonSchema, value: unknown) => boolean;\n}\n\n/**\n * Whether a property with this name can be reached by a JSON Forms data path.\n *\n * A dot is the separator and an empty segment composes away to the parent's own\n * path, so neither name can address the property it belongs to. Such a property\n * is still perfectly legal data and must stay editable - through an isolated\n * editor rooted at its value, per section 18's literal-key contract.\n */\nexport const needsIsolatedEditor = (name: string): boolean =>\n name === '' || name.includes('.');\n\n/**\n * Sets an own property, even when the name is one the prototype also carries.\n *\n * `data['__proto__'] = value` replaces the object's prototype instead of\n * creating a property, and `'toString' in data` is true of every object. Now\n * that names are only restricted by the path grammar, both are reachable.\n */\nexport const assignOwnProperty = <T extends Record<string, unknown>>(\n target: T,\n name: string,\n value: unknown,\n): T => {\n Object.defineProperty(target, name, {\n value,\n writable: true,\n enumerable: true,\n configurable: true,\n });\n return target;\n};\n\n/**\n * The schema a dynamic property's *name* has to satisfy.\n *\n * Built as a real schema rather than a regular expression so the whole of\n * `propertyNames` applies - `minLength`, `enum`, `format`, `allOf`, `not` and\n * anything else - instead of only its `pattern`. A joined alternation of\n * patterns, which is what this used to do, silently dropped every other\n * keyword.\n */\nexport const createAdditionalPropertyNameSchema = (\n schema: JsonSchema,\n rootSchema: JsonSchema,\n): JsonSchema7 => {\n const constraints: JsonSchema7[] = [];\n const propertyNames = (\n schema as JsonSchema7 & { propertyNames?: JsonSchema7 | boolean }\n ).propertyNames;\n\n if (propertyNames === false) {\n // JSON Forms' JsonSchema7 type cannot express a boolean schema, so the\n // equivalent always-failing schema stands in for it.\n constraints.push({ not: {} });\n } else if (typeof propertyNames === 'object' && propertyNames !== null) {\n const resolved =\n typeof propertyNames.$ref === 'string'\n ? ((Resolve.schema(rootSchema, propertyNames.$ref, rootSchema) as\n | JsonSchema7\n | undefined) ?? propertyNames)\n : propertyNames;\n constraints.push(resolved);\n }\n\n if (schema.additionalProperties === false) {\n // With no `additionalProperties`, a new name is only admissible if some\n // `patternProperties` entry claims it - and none at all means nothing is.\n const patterns = Object.keys(schema.patternProperties ?? {});\n constraints.push(\n patterns.length > 0\n ? { anyOf: patterns.map((pattern) => ({ pattern })) }\n : { not: {} },\n );\n }\n\n return {\n type: 'string',\n ...(constraints.length > 0 ? { allOf: constraints } : {}),\n };\n};\n\nconst defaultNameValidator = createAjv();\n\nexport const validateAdditionalPropertyName = ({\n name,\n schema,\n rootSchema,\n data,\n currentName,\n disallowedNames = [],\n allowEmptyName = false,\n validate,\n}: ValidateAdditionalPropertyNameOptions): AdditionalPropertyNameResult => {\n /*\n The name is kept **exactly** as typed. Section 18: \"preserve every accepted\n name exactly; trimming is only a blankness check\". So `trim()` decides\n whether the name counts as empty and is used for nothing else - `\" a \"`\n is a different key from `\"a\"`, and with empty names permitted `\" \"` is a\n key in its own right.\n */\n if (!allowEmptyName && name.trim().length === 0) {\n return { name, error: 'required' };\n }\n\n // Renaming a property to what it is already called is not a collision.\n\n const taken = [...Object.keys(schema.properties ?? {}), ...disallowedNames];\n const isTaken =\n taken.includes(name) ||\n (typeof data === 'object' &&\n data !== null &&\n !Array.isArray(data) &&\n Object.prototype.hasOwnProperty.call(data, name));\n\n if (isTaken && name !== currentName) {\n return { name, error: 'already-defined' };\n }\n\n const nameSchema = createAdditionalPropertyNameSchema(schema, rootSchema);\n let permitted = true;\n let errors: import('ajv').ErrorObject[] = [];\n try {\n permitted = validate\n ? validate(nameSchema, name)\n : (defaultNameValidator.validate(nameSchema, name) as boolean);\n if (!permitted) {\n defaultNameValidator.validate(nameSchema, name);\n errors = [...(defaultNameValidator.errors ?? [])];\n }\n } catch {\n // A malformed `propertyNames`, or a pattern that is not a valid regular\n // expression, cannot be evaluated here. The form's own validator reports it\n // against the data; refusing every name because this preview could not run\n // would be worse than letting it through.\n permitted = true;\n }\n if (!permitted) {\n return { name, error: 'invalid', errors };\n }\n\n return { name };\n};\n"],"mappings":"A,oGAmDA,IAAaG,EAAuB,GAClCC,IAAS,IAAMA,EAAK,SAAS,GAAG,EASrBC,GACX,EACA,EACA,KAEA,OAAO,eAAeC,EAAQF,EAAM,CAClC,QACA,SAAU,GACV,WAAY,GACZ,aAAc,EAChB,CAAC,EACME,GAYIC,GACX,EACA,IACgB,CAChB,IAAMC,EAA6B,CAAC,EAC9BC,EACJC,EACA,cAEF,GAAID,IAAkB,GAGpBD,EAAY,KAAK,CAAE,IAAK,CAAC,CAAE,CAAC,OACvB,GAAI,OAAOC,GAAkB,UAAYA,EAAwB,CACtE,IAAME,EACJ,OAAOF,EAAc,MAAS,SACxBT,EAAAA,QAAQ,OAAOY,EAAYH,EAAc,KAAMG,CAAU,GAEzCH,EAClBA,EACND,EAAY,KAAKG,CAAQ,CAC3B,CAEA,GAAID,EAAO,uBA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ynamic property, with no React in it.
4
+ *
5
+ * What a property may be called is decidable from the schema and the current
6
+ * data, so it is settled here and tested without rendering anything.
7
+ */
8
+ export type AdditionalPropertyNameError = 'required' | 'already-defined' | 'invalid';
9
+ /**
10
+ * The name exactly as supplied, and why it was refused if it was.
11
+ *
12
+ * A flat shape with an optional `error` rather than the discriminated union the
13
+ * Svelte module uses: this package compiles with `strict` off, and without
14
+ * `strictNullChecks` TypeScript does not narrow a union on a boolean literal
15
+ * discriminant, so `if (result.valid)` would not give the caller access to
16
+ * `result.error`. `error === undefined` means accepted.
17
+ */
18
+ export interface AdditionalPropertyNameResult {
19
+ name: string;
20
+ error?: AdditionalPropertyNameError;
21
+ errors?: import('ajv').ErrorObject[];
22
+ }
23
+ export interface ValidateAdditionalPropertyNameOptions {
24
+ name: string;
25
+ schema: JsonSchema;
26
+ rootSchema: JsonSchema;
27
+ data?: unknown;
28
+ /** The name being renamed, which may of course keep its own name. */
29
+ currentName?: string;
30
+ /** Names that are taken for another reason, e.g. declared properties. */
31
+ disallowedNames?: readonly string[];
32
+ allowEmptyName?: boolean;
33
+ /** Only used to evaluate the property-name schema; optional. */
34
+ validate?: (schema: JsonSchema, value: unknown) => boolean;
35
+ }
36
+ /**
37
+ * Whether a property with this name can be reached by a JSON Forms data path.
38
+ *
39
+ * A dot is the separator and an empty segment composes away to the parent's own
40
+ * path, so neither name can address the property it belongs to. Such a property
41
+ * is still perfectly legal data and must stay editable - through an isolated
42
+ * editor rooted at its value, per section 18's literal-key contract.
43
+ */
44
+ export declare const needsIsolatedEditor: (name: string) => boolean;
45
+ /**
46
+ * Sets an own property, even when the name is one the prototype also carries.
47
+ *
48
+ * `data['__proto__'] = value` replaces the object's prototype instead of
49
+ * creating a property, and `'toString' in data` is true of every object. Now
50
+ * that names are only restricted by the path grammar, both are reachable.
51
+ */
52
+ export declare const assignOwnProperty: <T extends Record<string, unknown>>(target: T, name: string, value: unknown) => T;
53
+ /**
54
+ * The schema a dynamic property's *name* has to satisfy.
55
+ *
56
+ * Built as a real schema rather than a regular expression so the whole of
57
+ * `propertyNames` applies - `minLength`, `enum`, `format`, `allOf`, `not` and
58
+ * anything else - instead of only its `pattern`. A joined alternation of
59
+ * patterns, which is what this used to do, silently dropped every other
60
+ * keyword.
61
+ */
62
+ export declare const createAdditionalPropertyNameSchema: (schema: JsonSchema, rootSchema: JsonSchema) => JsonSchema7;
63
+ export declare const validateAdditionalPropertyName: ({ name, schema, rootSchema, data, currentName, disallowedNames, allowEmptyName, validate, }: ValidateAdditionalPropertyNameOptions) => AdditionalPropertyNameResult;
@@ -0,0 +1,46 @@
1
+ import { Resolve as e, createAjv as t } from "@jsonforms/core";
2
+ // src/objects/additionalPropertyName.ts
3
+ var n = (e) => e === "" || e.includes("."), r = (e, t, n) => (Object.defineProperty(e, t, {
4
+ value: n,
5
+ writable: !0,
6
+ enumerable: !0,
7
+ configurable: !0
8
+ }), e), i = (t, n) => {
9
+ let r = [], i = t.propertyNames;
10
+ if (i === !1) r.push({ not: {} });
11
+ else if (typeof i == "object" && i) {
12
+ let t = typeof i.$ref == "string" ? e.schema(n, i.$ref, n) ?? i : i;
13
+ r.push(t);
14
+ }
15
+ if (t.additionalProperties === !1) {
16
+ let e = Object.keys(t.patternProperties ?? {});
17
+ r.push(e.length > 0 ? { anyOf: e.map((e) => ({ pattern: e })) } : { not: {} });
18
+ }
19
+ return {
20
+ type: "string",
21
+ ...r.length > 0 ? { allOf: r } : {}
22
+ };
23
+ }, a = t(), o = ({ name: e, schema: t, rootSchema: n, data: r, currentName: o, disallowedNames: s = [], allowEmptyName: c = !1, validate: l }) => {
24
+ if (!c && e.trim().length === 0) return {
25
+ name: e,
26
+ error: "required"
27
+ };
28
+ if (([...Object.keys(t.properties ?? {}), ...s].includes(e) || typeof r == "object" && r && !Array.isArray(r) && Object.prototype.hasOwnProperty.call(r, e)) && e !== o) return {
29
+ name: e,
30
+ error: "already-defined"
31
+ };
32
+ let u = i(t, n), d = !0, f = [];
33
+ try {
34
+ d = l ? l(u, e) : a.validate(u, e), d || (a.validate(u, e), f = [...a.errors ?? []]);
35
+ } catch {
36
+ d = !0;
37
+ }
38
+ return d ? { name: e } : {
39
+ name: e,
40
+ error: "invalid",
41
+ errors: f
42
+ };
43
+ };
44
+ export { r as assignOwnProperty, i as createAdditionalPropertyNameSchema, n as needsIsolatedEditor, o as validateAdditionalPropertyName };
45
+
46
+ //# sourceMappingURL=additionalPropertyName.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"additionalPropertyName.esm.js","names":["needsIsolatedEditor","name","assignOwnProperty","target","createAdditionalPropertyNameSchema","constraints","propertyNames","schema","resolved","Resolve","rootSchema","patterns","defaultNameValidator","createAjv","validateAdditionalPropertyName","allowEmptyName","disallowedNames","data","currentName","nameSchema","permitted","errors","validate"],"sources":["../../src/objects/additionalPropertyName.ts"],"sourcesContent":["import { createAjv, JsonSchema, JsonSchema7, Resolve } from '@jsonforms/core';\n\n/**\n * Naming a dynamic property, with no React in it.\n *\n * What a property may be called is decidable from the schema and the current\n * data, so it is settled here and tested without rendering anything.\n */\n\nexport type AdditionalPropertyNameError =\n | 'required'\n | 'already-defined'\n | 'invalid';\n\n/**\n * The name exactly as supplied, and why it was refused if it was.\n *\n * A flat shape with an optional `error` rather than the discriminated union the\n * Svelte module uses: this package compiles with `strict` off, and without\n * `strictNullChecks` TypeScript does not narrow a union on a boolean literal\n * discriminant, so `if (result.valid)` would not give the caller access to\n * `result.error`. `error === undefined` means accepted.\n */\nexport interface AdditionalPropertyNameResult {\n name: string;\n error?: AdditionalPropertyNameError;\n errors?: import('ajv').ErrorObject[];\n}\n\nexport interface ValidateAdditionalPropertyNameOptions {\n name: string;\n schema: JsonSchema;\n rootSchema: JsonSchema;\n data?: unknown;\n /** The name being renamed, which may of course keep its own name. */\n currentName?: string;\n /** Names that are taken for another reason, e.g. declared properties. */\n disallowedNames?: readonly string[];\n allowEmptyName?: boolean;\n /** Only used to evaluate the property-name schema; optional. */\n validate?: (schema: JsonSchema, value: unknown) => boolean;\n}\n\n/**\n * Whether a property with this name can be reached by a JSON Forms data path.\n *\n * A dot is the separator and an empty segment composes away to the parent's own\n * path, so neither name can address the property it belongs to. Such a property\n * is still perfectly legal data and must stay editable - through an isolated\n * editor rooted at its value, per section 18's literal-key contract.\n */\nexport const needsIsolatedEditor = (name: string): boolean =>\n name === '' || name.includes('.');\n\n/**\n * Sets an own property, even when the name is one the prototype also carries.\n *\n * `data['__proto__'] = value` replaces the object's prototype instead of\n * creating a property, and `'toString' in data` is true of every object. Now\n * that names are only restricted by the path grammar, both are reachable.\n */\nexport const assignOwnProperty = <T extends Record<string, unknown>>(\n target: T,\n name: string,\n value: unknown,\n): T => {\n Object.defineProperty(target, name, {\n value,\n writable: true,\n enumerable: true,\n configurable: true,\n });\n return target;\n};\n\n/**\n * The schema a dynamic property's *name* has to satisfy.\n *\n * Built as a real schema rather than a regular expression so the whole of\n * `propertyNames` applies - `minLength`, `enum`, `format`, `allOf`, `not` and\n * anything else - instead of only its `pattern`. A joined alternation of\n * patterns, which is what this used to do, silently dropped every other\n * keyword.\n */\nexport const createAdditionalPropertyNameSchema = (\n schema: JsonSchema,\n rootSchema: JsonSchema,\n): JsonSchema7 => {\n const constraints: JsonSchema7[] = [];\n const propertyNames = (\n schema as JsonSchema7 & { propertyNames?: JsonSchema7 | boolean }\n ).propertyNames;\n\n if (propertyNames === false) {\n // JSON Forms' JsonSchema7 type cannot express a boolean schema, so the\n // equivalent always-failing schema stands in for it.\n constraints.push({ not: {} });\n } else if (typeof propertyNames === 'object' && propertyNames !== null) {\n const resolved =\n typeof propertyNames.$ref === 'string'\n ? ((Resolve.schema(rootSchema, propertyNames.$ref, rootSchema) as\n | JsonSchema7\n | undefined) ?? propertyNames)\n : propertyNames;\n constraints.push(resolved);\n }\n\n if (schema.additionalProperties === false) {\n // With no `additionalProperties`, a new name is only admissible if some\n // `patternProperties` entry claims it - and none at all means nothing is.\n const patterns = Object.keys(schema.patternProperties ?? {});\n constraints.push(\n patterns.length > 0\n ? { anyOf: patterns.map((pattern) => ({ pattern })) }\n : { not: {} },\n );\n }\n\n return {\n type: 'string',\n ...(constraints.length > 0 ? { allOf: constraints } : {}),\n };\n};\n\nconst defaultNameValidator = createAjv();\n\nexport const validateAdditionalPropertyName = ({\n name,\n schema,\n rootSchema,\n data,\n currentName,\n disallowedNames = [],\n allowEmptyName = false,\n validate,\n}: ValidateAdditionalPropertyNameOptions): AdditionalPropertyNameResult => {\n /*\n The name is kept **exactly** as typed. Section 18: \"preserve every accepted\n name exactly; trimming is only a blankness check\". So `trim()` decides\n whether the name counts as empty and is used for nothing else - `\" a \"`\n is a different key from `\"a\"`, and with empty names permitted `\" \"` is a\n key in its own right.\n */\n if (!allowEmptyName && name.trim().length === 0) {\n return { name, error: 'required' };\n }\n\n // Renaming a property to what it is already called is not a collision.\n\n const taken = [...Object.keys(schema.properties ?? {}), ...disallowedNames];\n const isTaken =\n taken.includes(name) ||\n (typeof data === 'object' &&\n data !== null &&\n !Array.isArray(data) &&\n Object.prototype.hasOwnProperty.call(data, name));\n\n if (isTaken && name !== currentName) {\n return { name, error: 'already-defined' };\n }\n\n const nameSchema = createAdditionalPropertyNameSchema(schema, rootSchema);\n let permitted = true;\n let errors: import('ajv').ErrorObject[] = [];\n try {\n permitted = validate\n ? validate(nameSchema, name)\n : (defaultNameValidator.validate(nameSchema, name) as boolean);\n if (!permitted) {\n defaultNameValidator.validate(nameSchema, name);\n errors = [...(defaultNameValidator.errors ?? [])];\n }\n } catch {\n // A malformed `propertyNames`, or a pattern that is not a valid regular\n // expression, cannot be evaluated here. The form's own validator reports it\n // against the data; refusing every name because this preview could not run\n // would be worse than letting it through.\n permitted = true;\n }\n if (!permitted) {\n return { name, error: 'invalid', errors };\n }\n\n return { name };\n};\n"],"mappings":";;AAmDA,IAAaA,KAAuB,MAClCC,MAAS,MAAMA,EAAK,SAAS,GAAG,GASrBC,KACX,GACA,GACA,OAEA,OAAO,eAAeC,GAAQF,GAAM;CAClC;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C3C,IAAI;EAIF,AAHA,IAAYC,IACRA,EAASH,GAAYlB,CAAI,IACxBW,EAAqB,SAASO,GAAYlB,CAAI,GAC9CmB,MACHR,EAAqB,SAASO,GAAYlB,CAAI,GAC9C,IAAS,CAAC,GAAIW,EAAqB,UAAU,CAAC,CAAE;CAEpD,QAAQ;EAKN,IAAY;CACd;CAKA,OAJKQ,IAIE,EAAE,QAAK,IAHL;EAAE;EAAM,OAAO;EAAW;CAAO;AAI5C"}
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../rolldown-runtime-BocRIvOZ.js"),t=require("../dynamic/dynamicTree.cjs.js"),n=require("./literalPropertySchema.cjs.js");let r=require("react"),i=require("@jsonforms/core"),a=require("@jsonforms/react"),o=require("lodash/cloneDeep");o=e.t(o);var s=(e,t)=>{var n,r;return(((n=e.options)==null?void 0:n.conditionalFields)??(t==null||(r=t.jsonformsExtended)==null?void 0:r.conditionalFields))===!0},c=(e,t=new Set)=>!e||typeof e!=`object`||t.has(e)?!1:(t.add(e),e.if!==void 0&&(e.then!==void 0||e.else!==void 0)||Object.keys(e.dependencies??{}).length>0||(e.allOf??[]).some(e=>c(e,t))),l=new WeakMap,u=(e,t,r,i)=>{if(typeof t==`boolean`)return t;let a=l.get(e);a||l.set(e,a=new WeakMap);let s=a.get(r);s||a.set(r,s=new WeakMap);let c=s.get(t);return c||(c=e.compile(n.literalPropertySchema(t,r)),s.set(t,c)),!!c((0,o.default)(i))},d=(e,t,n,r)=>{let a=Object.create(null),o=new Set,s=new Set,c=[],l=new Set,d=(e,f)=>{if(e&&typeof e==`object`&&!l.has(e)){if(l.add(e),e.$ref)try{d(i.Resolve.schema(t,e.$ref,t),f)}catch{c.push(`A conditional schema reference could not be resolved.`)}for(let[t,n]of Object.entries(e.properties??{}))if(o.add(t),f){let e=a[t];a[t]=e===void 0?n:{...typeof e==`object`?e:{},...typeof n==`object`?n:{},allOf:[e,n]}}if(f)for(let t of e.required??[])s.add(t);for(let t of e.allOf??[])d(t,f);if(e.if!==void 0){let i;if(f)try{i=u(r,e.if,t,n)}catch{c.push(`A conditional field condition could not be evaluated.`)}d(e.then,f&&i===!0),d(e.else,f&&i===!1)}for(let[t,r]of Object.entries(e.dependencies??{})){let e=f&&typeof n==`object`&&!!n&&Object.prototype.hasOwnProperty.call(n,t);if(Array.isArray(r)){if(e)for(let e of r)s.add(e)}else d(r,e)}l.delete(e)}};d(e,!0);let f={...e,properties:a,required:[...s]};for(let e of[`$ref`,`if`,`then`,`else`,`dependencies`,`allOf`])delete f[e];return{schema:f,known:o,diagnostics:c}},f=(e,t,n,i,o)=>{var l;let u=(l=(0,a.useJsonForms)().core)==null?void 0:l.ajv,f=s(i,o)&&c(e);return(0,r.useMemo)(()=>f&&u?d(e,t,n,u):{schema:e,known:new Set,diagnostics:[]},[f,e,t,n,u])},p=(e,n,r)=>{if(r.size===0)return e;let i=e=>{var a;let o=e.type===`Control`&&/^#\/properties\/([^/]*)(?:\/|$)/.exec(e.scope??``),s=o==null||(a=o[1])==null?void 0:a.replace(/~1/g,`/`).replace(/~0/g,`~`);if(s===void 0||!r.has(s)||Object.prototype.hasOwnProperty.call(n.properties??{},s))return Array.isArray(e.elements)?t.retainDynamicPresentation(e,{...e,elements:e.elements.map(i).filter(Boolean)}):e};return i(e)??{type:`VerticalLayout`,elements:[]}};exports.conditionalFieldsEnabled=s,exports.conditionalLayout=p,exports.hasConditionalFields=c,exports.projectConditionalFields=d,exports.useConditionalFields=f;
2
+ //# sourceMappingURL=conditionalFields.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conditionalFields.cjs.js","names":["literalPropertySchema","cloneDeep","Resolve","useJsonForms","useMemo","retainDynamicPresentation","require_rolldown_runtime","require_dynamic_dynamicTree","require_objects_literalPropertySchema","react","_jsonforms_core","_jsonforms_react","lodash_cloneDeep","conditionalFieldsEnabled","_ui$options","_config$jsonformsExte","ui","config","hasConditionalFields","schema","seen","part","validators","evaluate","condition","roots","ajv","conditions","root","validate","data","projectConditionalFields","properties","known","required","diagnostics","visit","input","rootSchema","active","key","value","previous","matches","dependency","present","field","projected","useConditionalFields","_context$core","enabled","conditionalLayout","_key$","element","name"],"sources":["../../src/objects/conditionalFields.ts"],"sourcesContent":["import { retainDynamicPresentation } from '../dynamic/dynamicTree';\nimport { JsonSchema, Resolve, UISchemaElement } from '@jsonforms/core';\nimport type Ajv from 'ajv';\nimport cloneDeep from 'lodash/cloneDeep';\nimport { useMemo } from 'react';\nimport { useJsonForms } from '@jsonforms/react';\nimport { literalPropertySchema } from './literalPropertySchema';\n\nexport const conditionalFieldsEnabled = (ui: any, config: any): boolean =>\n (ui.options?.conditionalFields ??\n config?.jsonformsExtended?.conditionalFields) === true;\n\nexport const hasConditionalFields = (\n schema: any,\n seen = new Set<any>(),\n): boolean => {\n if (!schema || typeof schema !== 'object' || seen.has(schema)) return false;\n seen.add(schema);\n return (\n (schema.if !== undefined &&\n (schema.then !== undefined || schema.else !== undefined)) ||\n Object.keys(schema.dependencies ?? {}).length > 0 ||\n (schema.allOf ?? []).some((part: any) => hasConditionalFields(part, seen))\n );\n};\n\nconst validators = new WeakMap<\n Ajv,\n WeakMap<object, WeakMap<object, ReturnType<Ajv['compile']>>>\n>();\nconst evaluate = (\n ajv: Ajv,\n condition: any,\n root: JsonSchema,\n data: unknown,\n) => {\n if (typeof condition === 'boolean') return condition;\n let roots = validators.get(ajv);\n if (!roots) validators.set(ajv, (roots = new WeakMap()));\n let conditions = roots.get(root);\n if (!conditions) roots.set(root, (conditions = new WeakMap()));\n let validate = conditions.get(condition);\n if (!validate) {\n validate = ajv.compile(literalPropertySchema(condition, root));\n conditions.set(condition, validate);\n }\n return Boolean(validate(cloneDeep(data)));\n};\n\n/** Presentation projection only. The host still validates the original schema. */\nexport const projectConditionalFields = (\n schema: JsonSchema,\n rootSchema: JsonSchema,\n data: unknown,\n ajv: Ajv,\n) => {\n const properties: Record<string, any> = Object.create(null);\n const known = new Set<string>();\n const required = new Set<string>();\n const diagnostics: string[] = [];\n const seen = new Set<any>();\n const visit = (input: any, active: boolean) => {\n if (!input || typeof input !== 'object' || seen.has(input)) return;\n seen.add(input);\n if (input.$ref) {\n try {\n visit(Resolve.schema(rootSchema, input.$ref, rootSchema), active);\n } catch {\n diagnostics.push(\n 'A conditional schema reference could not be resolved.',\n );\n }\n }\n for (const [key, value] of Object.entries(input.properties ?? {})) {\n known.add(key);\n if (active) {\n const previous = properties[key];\n // Preserve every constraint; top-level annotations guide editor selection.\n properties[key] =\n previous === undefined\n ? value\n : {\n ...(typeof previous === 'object' ? previous : {}),\n ...(typeof value === 'object' ? value : {}),\n allOf: [previous, value],\n };\n }\n }\n if (active) for (const key of input.required ?? []) required.add(key);\n for (const part of input.allOf ?? []) visit(part, active);\n if (input.if !== undefined) {\n let matches: boolean | undefined;\n if (active) {\n try {\n matches = evaluate(ajv, input.if, rootSchema, data);\n } catch {\n diagnostics.push(\n 'A conditional field condition could not be evaluated.',\n );\n }\n }\n visit(input.then, active && matches === true);\n visit(input.else, active && matches === false);\n }\n for (const [key, dependency] of Object.entries(input.dependencies ?? {})) {\n const present =\n active &&\n data !== null &&\n typeof data === 'object' &&\n Object.prototype.hasOwnProperty.call(data, key);\n if (Array.isArray(dependency)) {\n if (present) for (const field of dependency) required.add(field);\n } else visit(dependency, present);\n }\n seen.delete(input);\n };\n visit(schema, true);\n const projected = { ...schema, properties, required: [...required] } as any;\n // These have already contributed to this object's presentation. Retaining them\n // here would redispatch the same branch or duplicate its fields.\n for (const key of ['$ref', 'if', 'then', 'else', 'dependencies', 'allOf'])\n delete projected[key];\n return { schema: projected as JsonSchema, known, diagnostics };\n};\n\nexport const useConditionalFields = (\n schema: JsonSchema,\n root: JsonSchema,\n data: unknown,\n ui: any,\n config: any,\n) => {\n const context = useJsonForms();\n const ajv = context.core?.ajv;\n const enabled =\n conditionalFieldsEnabled(ui, config) && hasConditionalFields(schema);\n return useMemo(\n () =>\n enabled && ajv\n ? projectConditionalFields(schema, root, data, ajv)\n : { schema, known: new Set<string>(), diagnostics: [] as string[] },\n [enabled, schema, root, data, ajv],\n );\n};\n\n/** Explicit details retain authored order and groups. Only inactive branch-only\n * bindings are omitted; base fields stay visible even if conditionally required. */\nexport const conditionalLayout = (\n ui: UISchemaElement,\n schema: JsonSchema,\n known: Set<string>,\n): UISchemaElement => {\n if (known.size === 0) return ui;\n const visit = (element: any): any => {\n const key =\n element.type === 'Control' &&\n /^#\\/properties\\/([^/]*)(?:\\/|$)/.exec(element.scope ?? '');\n const name = key?.[1]?.replace(/~1/g, '/').replace(/~0/g, '~');\n if (\n name !== undefined &&\n known.has(name) &&\n !Object.prototype.hasOwnProperty.call(schema.properties ?? {}, name)\n )\n return undefined;\n return Array.isArray(element.elements)\n ? retainDynamicPresentation(element, {\n ...element,\n elements: element.elements.map(visit).filter(Boolean),\n })\n : element;\n };\n return visit(ui) ?? { type: 'VerticalLayout', elements: [] };\n};\n"],"mappings":"A,sUAQA,IAAaa,GAA4B,EAAS,IAAA,C,QAC/C,SAAA,EAAAG,EAAG,UAAA,KAAA,IAAA,GAAAF,EAAS,qBAAAG,GAAA,OAAA,EACXA,EAAQ,oBAAA,KAAA,IAAA,GAAAF,EAAmB,sBAAuB,EAAA,EAEzCG,GACX,EACA,EAAO,IAAI,MAEP,CAACC,GAAU,OAAOA,GAAW,UAAYC,EAAK,IAAID,CAAM,EAAU,IACtEC,EAAK,IAAID,CAAM,EAEZA,EAAO,KAAO,IAAA,KACZA,EAAO,OAAS,IAAA,IAAaA,EAAO,OAAS,IAAA,KAChD,OAAO,KAAKA,EAAO,cAAgB,CAAC,CAAC,CAAC,CAAC,OAAS,IAC/CA,EAAO,OAAS,CAAC,EAAA,CAAG,KAAM,GAAcD,EAAqBG,EAAMD,CAAI,CAAC,GAIvEE,EAAa,IAAI,QAIjBC,GACJ,EACA,EACA,EACA,IACG,CACH,GAAI,OAAOC,GAAc,UAAW,OAAOA,EAC3C,IAAIC,EAAQH,EAAW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AAQ,MAAO,IAAI,IAAe,YAAa,CAAC,CAAc,EACtE,CAACwB,EAAS/B,EAAQS,EAAME,EAAMJ,CAAG,CACnC,CACF,EAIayB,GACX,EACA,EACA,IACoB,CACpB,GAAIlB,EAAM,OAAS,EAAG,OAAOjB,EAC7B,IAAMoB,EAAS,GAAsB,C,MACnC,IAAMI,EACJa,EAAQ,OAAS,WACjB,kCAAkC,KAAKA,EAAQ,OAAS,EAAE,EACtDC,EAAAd,GAAA,OAAA,EAAOA,EAAM,KAAA,KAAA,IAAA,GAAAY,EAAI,QAAQ,MAAO,GAAG,CAAC,CAAC,QAAQ,MAAO,GAAG,EAC7D,GACEE,IAAS,IAAA,IACT,GAAM,IAAIA,CAAI,GACb,OAAO,UAAU,eAAe,KAAKnC,EAAO,YAAc,CAAC,EAAGmC,CAAI,EAGrE,OAAO,MAAM,QAAQD,EAAQ,QAAQ,EACjChD,EAAAA,0BAA0BgD,EAAS,CACjC,GAAGA,EACH,SAAUA,EAAQ,SAAS,IAAIjB,CAAK,CAAC,CAAC,OAAO,OAAO,CACtD,CAAC,EACDiB,CACN,EACA,OAAOjB,EAAMpB,CAAE,GAAK,CAAE,KAAM,iBAAkB,SAAU,CAAC,CAAE,CAC7D,E"}
@@ -0,0 +1,18 @@
1
+ import { JsonSchema, UISchemaElement } from '@jsonforms/core';
2
+ import type Ajv from 'ajv';
3
+ export declare const conditionalFieldsEnabled: (ui: any, config: any) => boolean;
4
+ export declare const hasConditionalFields: (schema: any, seen?: Set<any>) => boolean;
5
+ /** Presentation projection only. The host still validates the original schema. */
6
+ export declare const projectConditionalFields: (schema: JsonSchema, rootSchema: JsonSchema, data: unknown, ajv: Ajv) => {
7
+ schema: JsonSchema;
8
+ known: Set<string>;
9
+ diagnostics: string[];
10
+ };
11
+ export declare const useConditionalFields: (schema: JsonSchema, root: JsonSchema, data: unknown, ui: any, config: any) => {
12
+ schema: JsonSchema;
13
+ known: Set<string>;
14
+ diagnostics: string[];
15
+ };
16
+ /** Explicit details retain authored order and groups. Only inactive branch-only
17
+ * bindings are omitted; base fields stay visible even if conditionally required. */
18
+ export declare const conditionalLayout: (ui: UISchemaElement, schema: JsonSchema, known: Set<string>) => UISchemaElement;
@@ -0,0 +1,105 @@
1
+ import { retainDynamicPresentation as e } from "../dynamic/dynamicTree.esm.js";
2
+ import { literalPropertySchema as t } from "./literalPropertySchema.esm.js";
3
+ import { useMemo as n } from "react";
4
+ import { Resolve as r } from "@jsonforms/core";
5
+ import { useJsonForms as i } from "@jsonforms/react";
6
+ import a from "lodash/cloneDeep";
7
+ // src/objects/conditionalFields.ts
8
+ var o = (e, t) => {
9
+ var n, r;
10
+ return (((n = e.options) == null ? void 0 : n.conditionalFields) ?? (t == null || (r = t.jsonformsExtended) == null ? void 0 : r.conditionalFields)) === !0;
11
+ }, s = (e, t = /* @__PURE__ */ new Set()) => !e || typeof e != "object" || t.has(e) ? !1 : (t.add(e), e.if !== void 0 && (e.then !== void 0 || e.else !== void 0) || Object.keys(e.dependencies ?? {}).length > 0 || (e.allOf ?? []).some((e) => s(e, t))), c = /* @__PURE__ */ new WeakMap(), l = (e, n, r, i) => {
12
+ if (typeof n == "boolean") return n;
13
+ let o = c.get(e);
14
+ o || c.set(e, o = /* @__PURE__ */ new WeakMap());
15
+ let s = o.get(r);
16
+ s || o.set(r, s = /* @__PURE__ */ new WeakMap());
17
+ let l = s.get(n);
18
+ return l || (l = e.compile(t(n, r)), s.set(n, l)), !!l(a(i));
19
+ }, u = (e, t, n, i) => {
20
+ let a = Object.create(null), o = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), c = [], u = /* @__PURE__ */ new Set(), d = (e, f) => {
21
+ if (e && typeof e == "object" && !u.has(e)) {
22
+ if (u.add(e), e.$ref) try {
23
+ d(r.schema(t, e.$ref, t), f);
24
+ } catch {
25
+ c.push("A conditional schema reference could not be resolved.");
26
+ }
27
+ for (let [t, n] of Object.entries(e.properties ?? {})) if (o.add(t), f) {
28
+ let e = a[t];
29
+ a[t] = e === void 0 ? n : {
30
+ ...typeof e == "object" ? e : {},
31
+ ...typeof n == "object" ? n : {},
32
+ allOf: [e, n]
33
+ };
34
+ }
35
+ if (f) for (let t of e.required ?? []) s.add(t);
36
+ for (let t of e.allOf ?? []) d(t, f);
37
+ if (e.if !== void 0) {
38
+ let r;
39
+ if (f) try {
40
+ r = l(i, e.if, t, n);
41
+ } catch {
42
+ c.push("A conditional field condition could not be evaluated.");
43
+ }
44
+ d(e.then, f && r === !0), d(e.else, f && r === !1);
45
+ }
46
+ for (let [t, r] of Object.entries(e.dependencies ?? {})) {
47
+ let e = f && typeof n == "object" && !!n && Object.prototype.hasOwnProperty.call(n, t);
48
+ if (Array.isArray(r)) {
49
+ if (e) for (let e of r) s.add(e);
50
+ } else d(r, e);
51
+ }
52
+ u.delete(e);
53
+ }
54
+ };
55
+ d(e, !0);
56
+ let f = {
57
+ ...e,
58
+ properties: a,
59
+ required: [...s]
60
+ };
61
+ for (let e of [
62
+ "$ref",
63
+ "if",
64
+ "then",
65
+ "else",
66
+ "dependencies",
67
+ "allOf"
68
+ ]) delete f[e];
69
+ return {
70
+ schema: f,
71
+ known: o,
72
+ diagnostics: c
73
+ };
74
+ }, d = (e, t, r, a, c) => {
75
+ var l;
76
+ let d = (l = i().core) == null ? void 0 : l.ajv, f = o(a, c) && s(e);
77
+ return n(() => f && d ? u(e, t, r, d) : {
78
+ schema: e,
79
+ known: /* @__PURE__ */ new Set(),
80
+ diagnostics: []
81
+ }, [
82
+ f,
83
+ e,
84
+ t,
85
+ r,
86
+ d
87
+ ]);
88
+ }, f = (t, n, r) => {
89
+ if (r.size === 0) return t;
90
+ let i = (t) => {
91
+ var a;
92
+ let o = t.type === "Control" && /^#\/properties\/([^/]*)(?:\/|$)/.exec(t.scope ?? ""), s = o == null || (a = o[1]) == null ? void 0 : a.replace(/~1/g, "/").replace(/~0/g, "~");
93
+ if (s === void 0 || !r.has(s) || Object.prototype.hasOwnProperty.call(n.properties ?? {}, s)) return Array.isArray(t.elements) ? e(t, {
94
+ ...t,
95
+ elements: t.elements.map(i).filter(Boolean)
96
+ }) : t;
97
+ };
98
+ return i(t) ?? {
99
+ type: "VerticalLayout",
100
+ elements: []
101
+ };
102
+ };
103
+ export { o as conditionalFieldsEnabled, f as conditionalLayout, s as hasConditionalFields, u as projectConditionalFields, d as useConditionalFields };
104
+
105
+ //# sourceMappingURL=conditionalFields.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conditionalFields.esm.js","names":["cloneDeep","conditionalFieldsEnabled","_ui$options","_config$jsonformsExte","ui","config","hasConditionalFields","schema","seen","part","validators","evaluate","condition","roots","ajv","conditions","root","validate","literalPropertySchema","data","projectConditionalFields","properties","known","required","diagnostics","visit","input","Resolve","rootSchema","active","key","value","previous","matches","dependency","present","field","projected","useConditionalFields","_context$core","useJsonForms","enabled","useMemo","conditionalLayout","_key$","element","name","retainDynamicPresentation"],"sources":["../../src/objects/conditionalFields.ts"],"sourcesContent":["import { retainDynamicPresentation } from '../dynamic/dynamicTree';\nimport { JsonSchema, Resolve, UISchemaElement } from '@jsonforms/core';\nimport type Ajv from 'ajv';\nimport cloneDeep from 'lodash/cloneDeep';\nimport { useMemo } from 'react';\nimport { useJsonForms } from '@jsonforms/react';\nimport { literalPropertySchema } from './literalPropertySchema';\n\nexport const conditionalFieldsEnabled = (ui: any, config: any): boolean =>\n (ui.options?.conditionalFields ??\n config?.jsonformsExtended?.conditionalFields) === true;\n\nexport const hasConditionalFields = (\n schema: any,\n seen = new Set<any>(),\n): boolean => {\n if (!schema || typeof schema !== 'object' || seen.has(schema)) return false;\n seen.add(schema);\n return (\n (schema.if !== undefined &&\n (schema.then !== undefined || schema.else !== undefined)) ||\n Object.keys(schema.dependencies ?? {}).length > 0 ||\n (schema.allOf ?? []).some((part: any) => hasConditionalFields(part, seen))\n );\n};\n\nconst validators = new WeakMap<\n Ajv,\n WeakMap<object, WeakMap<object, ReturnType<Ajv['compile']>>>\n>();\nconst evaluate = (\n ajv: Ajv,\n condition: any,\n root: JsonSchema,\n data: unknown,\n) => {\n if (typeof condition === 'boolean') return condition;\n let roots = validators.get(ajv);\n if (!roots) validators.set(ajv, (roots = new WeakMap()));\n let conditions = roots.get(root);\n if (!conditions) roots.set(root, (conditions = new WeakMap()));\n let validate = conditions.get(condition);\n if (!validate) {\n validate = ajv.compile(literalPropertySchema(condition, root));\n conditions.set(condition, validate);\n }\n return Boolean(validate(cloneDeep(data)));\n};\n\n/** Presentation projection only. The host still validates the original schema. */\nexport const projectConditionalFields = (\n schema: JsonSchema,\n rootSchema: JsonSchema,\n data: unknown,\n ajv: Ajv,\n) => {\n const properties: Record<string, any> = Object.create(null);\n const known = new Set<string>();\n const required = new Set<string>();\n const diagnostics: string[] = [];\n const seen = new Set<any>();\n const visit = (input: any, active: boolean) => {\n if (!input || typeof input !== 'object' || seen.has(input)) return;\n seen.add(input);\n if (input.$ref) {\n try {\n visit(Resolve.schema(rootSchema, input.$ref, rootSchema), active);\n } catch {\n diagnostics.push(\n 'A conditional schema reference could not be resolved.',\n );\n }\n }\n for (const [key, value] of Object.entries(input.properties ?? {})) {\n known.add(key);\n if (active) {\n const previous = properties[key];\n // Preserve every constraint; top-level annotations guide editor selection.\n properties[key] =\n previous === undefined\n ? value\n : {\n ...(typeof previous === 'object' ? previous : {}),\n ...(typeof value === 'object' ? value : {}),\n allOf: [previous, value],\n };\n }\n }\n if (active) for (const key of input.required ?? []) required.add(key);\n for (const part of input.allOf ?? []) visit(part, active);\n if (input.if !== undefined) {\n let matches: boolean | undefined;\n if (active) {\n try {\n matches = evaluate(ajv, input.if, rootSchema, data);\n } catch {\n diagnostics.push(\n 'A conditional field condition could not be evaluated.',\n );\n }\n }\n visit(input.then, active && matches === true);\n visit(input.else, active && matches === false);\n }\n for (const [key, dependency] of Object.entries(input.dependencies ?? {})) {\n const present =\n active &&\n data !== null &&\n typeof data === 'object' &&\n Object.prototype.hasOwnProperty.call(data, key);\n if (Array.isArray(dependency)) {\n if (present) for (const field of dependency) required.add(field);\n } else visit(dependency, present);\n }\n seen.delete(input);\n };\n visit(schema, true);\n const projected = { ...schema, properties, required: [...required] } as any;\n // These have already contributed to this object's presentation. Retaining them\n // here would redispatch the same branch or duplicate its fields.\n for (const key of ['$ref', 'if', 'then', 'else', 'dependencies', 'allOf'])\n delete projected[key];\n return { schema: projected as JsonSchema, known, diagnostics };\n};\n\nexport const useConditionalFields = (\n schema: JsonSchema,\n root: JsonSchema,\n data: unknown,\n ui: any,\n config: any,\n) => {\n const context = useJsonForms();\n const ajv = context.core?.ajv;\n const enabled =\n conditionalFieldsEnabled(ui, config) && hasConditionalFields(schema);\n return useMemo(\n () =>\n enabled && ajv\n ? projectConditionalFields(schema, root, data, ajv)\n : { schema, known: new Set<string>(), diagnostics: [] as string[] },\n [enabled, schema, root, data, ajv],\n );\n};\n\n/** Explicit details retain authored order and groups. Only inactive branch-only\n * bindings are omitted; base fields stay visible even if conditionally required. */\nexport const conditionalLayout = (\n ui: UISchemaElement,\n schema: JsonSchema,\n known: Set<string>,\n): UISchemaElement => {\n if (known.size === 0) return ui;\n const visit = (element: any): any => {\n const key =\n element.type === 'Control' &&\n /^#\\/properties\\/([^/]*)(?:\\/|$)/.exec(element.scope ?? '');\n const name = key?.[1]?.replace(/~1/g, '/').replace(/~0/g, '~');\n if (\n name !== undefined &&\n known.has(name) &&\n !Object.prototype.hasOwnProperty.call(schema.properties ?? {}, name)\n )\n return undefined;\n return Array.isArray(element.elements)\n ? retainDynamicPresentation(element, {\n ...element,\n elements: element.elements.map(visit).filter(Boolean),\n })\n : element;\n };\n return visit(ui) ?? { type: 'VerticalLayout', elements: [] };\n};\n"],"mappings":";;;;;;;AAQA,IAAaC,KAA4B,GAAS,MAAA;;CAC/C,UAAA,IAAAG,EAAG,YAAA,OAAA,KAAA,IAAAF,EAAS,uBAAAG,KAAA,SAAA,IACXA,EAAQ,sBAAA,OAAA,KAAA,IAAAF,EAAmB,wBAAuB;AAAA,GAEzCG,KACX,GACA,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});const e=require("../rolldown-runtime-BocRIvOZ.js");let t=require("react");t=e.t(t);let n=require("@jsonforms/core"),r=require("@jsonforms/react");var i=(0,t.createContext)(void 0),a=({path:e,schema:a,rootSchema:o,children:c})=>{let l=(0,r.useJsonForms)(),u=(0,t.useMemo)(()=>({...l,dispatch:t=>{if(a&&t.type===n.UPDATE_DATA&&t.path===e){var r;(r=l.dispatch)==null||r.call(l,{...t,updater:e=>{let n=t.updater(e);return n===void 0?s(a,o??a,e):n}})}else{var i;(i=l.dispatch)==null||i.call(l,t)}}}),[l,e,a,o]);return t.default.createElement(i.Provider,{value:e},t.default.createElement(r.JsonFormsContext.Provider,{value:a?u:l},c))},o=e=>(0,t.useContext)(i)===e,s=(e,t,r)=>e.type===`string`||typeof r==`string`?``:(0,n.createDefaultValue)(e,t)??r;exports.DynamicPropertyProvider=a,exports.clearedDynamicPropertyValue=s,exports.useDynamicProperty=o;
2
+ //# sourceMappingURL=dynamicProperties.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dynamicProperties.cjs.js","names":["createContext","useJsonForms","useMemo","UPDATE_DATA","JsonFormsContext","useContext","createDefaultValue","require_rolldown_runtime","react","_jsonforms_core","_jsonforms_react","DynamicPropertyPath","DynamicPropertyProvider","parent","context","schema","action","path","_parent$dispatch","value","previous","clearedDynamicPropertyValue","rootSchema","_parent$dispatch2","children","useDynamicProperty"],"sources":["../../src/objects/dynamicProperties.tsx"],"sourcesContent":["import { createDefaultValue, JsonSchema, UPDATE_DATA } from '@jsonforms/core';\nimport { JsonFormsContext, useJsonForms } from '@jsonforms/react';\n\nimport React, { createContext, useContext, useMemo } from 'react';\n\nconst DynamicPropertyPath = createContext<string | undefined>(undefined);\n\nexport const DynamicPropertyProvider = ({\n path,\n schema,\n rootSchema,\n children,\n}: React.PropsWithChildren<{\n path: string;\n schema?: JsonSchema;\n rootSchema?: JsonSchema;\n}>) => {\n const parent = useJsonForms();\n const context = useMemo(\n () => ({\n ...parent,\n dispatch: (\n action: Parameters<NonNullable<typeof parent.dispatch>>[0],\n ) => {\n // Protect only this property's own value. Nested fields and the\n // collection's explicit Delete update their respective paths normally.\n if (schema && action.type === UPDATE_DATA && action.path === path) {\n parent.dispatch?.({\n ...action,\n updater: (previous) => {\n const value = action.updater(previous);\n return value === undefined\n ? clearedDynamicPropertyValue(\n schema,\n rootSchema ?? schema,\n previous,\n )\n : value;\n },\n });\n } else {\n parent.dispatch?.(action);\n }\n },\n }),\n [parent, path, schema, rootSchema],\n );\n return (\n <DynamicPropertyPath.Provider value={path}>\n <JsonFormsContext.Provider value={schema ? context : parent}>\n {children}\n </JsonFormsContext.Provider>\n </DynamicPropertyPath.Provider>\n );\n};\n\n/** Only the property itself is protected; its nested fields clear normally. */\nexport const useDynamicProperty = (path: string): boolean =>\n useContext(DynamicPropertyPath) === path;\n\nexport const clearedDynamicPropertyValue = (\n schema: JsonSchema,\n rootSchema: JsonSchema,\n previous?: unknown,\n): unknown =>\n schema.type === 'string' || typeof previous === 'string'\n ? ''\n : (createDefaultValue(schema, rootSchema) ?? previous);\n"],"mappings":"A,qNAKA,IAAMW,GAAA,EAAsBX,EAAAA,cAAAA,CAAkC,IAAA,EAAS,EAE1DY,GAA2B,CACtC,OACA,SACA,aACA,cAKK,CACL,IAAMC,GAAA,EAASZ,EAAAA,aAAAA,CAAa,EACtBa,GAAA,EAAUZ,EAAAA,QAAAA,MACP,CACL,GAAGW,EACH,SACE,GACG,CAGH,GAAIE,GAAUC,EAAO,OAASb,EAAAA,aAAea,EAAO,OAASC,EAAM,C,OACjE,EAAAJ,EAAO,WAAA,MAAAK,EAAA,KAAAL,EAAW,CAChB,GAAGG,EACH,QAAU,GAAa,CACrB,IAAMG,EAAQH,EAAO,QAAQI,CAAQ,EACrC,OAAOD,IAAU,IAAA,GACbE,EACEN,EACAO,GAAcP,EACdK,CACF,EACAD,CACN,CACF,CAAC,CACH,KAAO,C,OACL,EAAAN,EAAO,WAAA,MAAAU,EAAA,KAAAV,EAAWG,CAAM,CAC1B,CACF,CACF,GACA,CAACH,EAAQI,EAAMF,EAAQO,CAAU,CACnC,EACA,OACEd,EAAA,QAAA,cAACG,EAAoB,SAArB,CAA8B,MAAOM,CAIP,EAH5BT,EAAA,QAAA,cAACJ,EAAAA,iBAAiB,SAAlB,CAA2B,MAAOW,EAASD,EAAUD,CAE1B,EADxBW,CACwB,CACC,CAElC,EAGaC,EAAsB,IAAA,EACjCpB,EAAAA,WAAAA,CAAWM,CAAmB,IAAMM,EAEzBI,GACX,EACA,EACA,IAEAN,EAAO,OAAS,UAAY,OAAOK,GAAa,SAC5C,IAAA,EACCd,EAAAA,mBAAAA,CAAmBS,EAAQO,CAAU,GAAKF,E"}
@@ -0,0 +1,10 @@
1
+ import { JsonSchema } from '@jsonforms/core';
2
+ import React from 'react';
3
+ export declare const DynamicPropertyProvider: ({ path, schema, rootSchema, children, }: React.PropsWithChildren<{
4
+ path: string;
5
+ schema?: JsonSchema;
6
+ rootSchema?: JsonSchema;
7
+ }>) => React.JSX.Element;
8
+ /** Only the property itself is protected; its nested fields clear normally. */
9
+ export declare const useDynamicProperty: (path: string) => boolean;
10
+ export declare const clearedDynamicPropertyValue: (schema: JsonSchema, rootSchema: JsonSchema, previous?: unknown) => unknown;