@flanksource/clicky-ui 0.3.64 → 0.3.66

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 (592) hide show
  1. package/NOTICE.md +4 -2
  2. package/dist/comments/CommentAuthor.cjs +6 -1
  3. package/dist/comments/CommentAuthor.cjs.map +1 -1
  4. package/dist/comments/CommentAuthor.d.ts.map +1 -1
  5. package/dist/comments/CommentAuthor.js +8 -3
  6. package/dist/comments/CommentAuthor.js.map +1 -1
  7. package/dist/comments/CommentComposer.cjs +4 -1
  8. package/dist/comments/CommentComposer.cjs.map +1 -1
  9. package/dist/comments/CommentComposer.d.ts.map +1 -1
  10. package/dist/comments/CommentComposer.js +4 -1
  11. package/dist/comments/CommentComposer.js.map +1 -1
  12. package/dist/comments/CommentEditor.cjs +3 -6
  13. package/dist/comments/CommentEditor.cjs.map +1 -1
  14. package/dist/comments/CommentEditor.d.ts.map +1 -1
  15. package/dist/comments/CommentEditor.js +3 -6
  16. package/dist/comments/CommentEditor.js.map +1 -1
  17. package/dist/comments/CommentProvider.cjs +3 -1
  18. package/dist/comments/CommentProvider.cjs.map +1 -1
  19. package/dist/comments/CommentProvider.d.ts +2 -0
  20. package/dist/comments/CommentProvider.d.ts.map +1 -1
  21. package/dist/comments/CommentProvider.js +3 -1
  22. package/dist/comments/CommentProvider.js.map +1 -1
  23. package/dist/comments/CommentRail.cjs +31 -18
  24. package/dist/comments/CommentRail.cjs.map +1 -1
  25. package/dist/comments/CommentRail.d.ts.map +1 -1
  26. package/dist/comments/CommentRail.js +31 -18
  27. package/dist/comments/CommentRail.js.map +1 -1
  28. package/dist/comments/agent-delivery.cjs +1 -2
  29. package/dist/comments/agent-delivery.cjs.map +1 -1
  30. package/dist/comments/agent-delivery.d.ts +1 -1
  31. package/dist/comments/agent-delivery.d.ts.map +1 -1
  32. package/dist/comments/agent-delivery.js +1 -2
  33. package/dist/comments/agent-delivery.js.map +1 -1
  34. package/dist/comments/annotation-types.d.ts +16 -0
  35. package/dist/comments/annotation-types.d.ts.map +1 -1
  36. package/dist/comments/comment-context.cjs.map +1 -1
  37. package/dist/comments/comment-context.d.ts +2 -1
  38. package/dist/comments/comment-context.d.ts.map +1 -1
  39. package/dist/comments/comment-context.js.map +1 -1
  40. package/dist/comments/comment-types.cjs.map +1 -1
  41. package/dist/comments/comment-types.d.ts +10 -1
  42. package/dist/comments/comment-types.d.ts.map +1 -1
  43. package/dist/comments/comment-types.js.map +1 -1
  44. package/dist/comments/gavel/CommentAgentSessions.cjs +55 -44
  45. package/dist/comments/gavel/CommentAgentSessions.cjs.map +1 -1
  46. package/dist/comments/gavel/CommentAgentSessions.d.ts +5 -2
  47. package/dist/comments/gavel/CommentAgentSessions.d.ts.map +1 -1
  48. package/dist/comments/gavel/CommentAgentSessions.js +55 -44
  49. package/dist/comments/gavel/CommentAgentSessions.js.map +1 -1
  50. package/dist/comments/gavel/client.cjs +3 -1
  51. package/dist/comments/gavel/client.cjs.map +1 -1
  52. package/dist/comments/gavel/client.d.ts.map +1 -1
  53. package/dist/comments/gavel/client.js +3 -1
  54. package/dist/comments/gavel/client.js.map +1 -1
  55. package/dist/comments/gavel/comment-agent-model.cjs +1 -1
  56. package/dist/comments/gavel/comment-agent-model.cjs.map +1 -1
  57. package/dist/comments/gavel/comment-agent-model.js +1 -1
  58. package/dist/comments/gavel/comment-agent-model.js.map +1 -1
  59. package/dist/comments/gavel/inbox-prompt.cjs +3 -1
  60. package/dist/comments/gavel/inbox-prompt.cjs.map +1 -1
  61. package/dist/comments/gavel/inbox-prompt.d.ts.map +1 -1
  62. package/dist/comments/gavel/inbox-prompt.js +3 -1
  63. package/dist/comments/gavel/inbox-prompt.js.map +1 -1
  64. package/dist/comments/gavel/index.d.ts +2 -1
  65. package/dist/comments/gavel/index.d.ts.map +1 -1
  66. package/dist/comments/gavel/useGavelComments.cjs +17 -9
  67. package/dist/comments/gavel/useGavelComments.cjs.map +1 -1
  68. package/dist/comments/gavel/useGavelComments.d.ts.map +1 -1
  69. package/dist/comments/gavel/useGavelComments.js +18 -10
  70. package/dist/comments/gavel/useGavelComments.js.map +1 -1
  71. package/dist/comments-gavel.cjs +4 -0
  72. package/dist/comments-gavel.js +3 -1
  73. package/dist/comments.d.ts +1 -1
  74. package/dist/comments.d.ts.map +1 -1
  75. package/dist/components/FilterBar.cjs +12 -5
  76. package/dist/components/FilterBar.cjs.map +1 -1
  77. package/dist/components/FilterBar.d.ts.map +1 -1
  78. package/dist/components/FilterBar.js +12 -5
  79. package/dist/components/FilterBar.js.map +1 -1
  80. package/dist/components/JsonSchemaForm.cjs +4 -1
  81. package/dist/components/JsonSchemaForm.cjs.map +1 -1
  82. package/dist/components/JsonSchemaForm.d.ts.map +1 -1
  83. package/dist/components/JsonSchemaForm.js +4 -1
  84. package/dist/components/JsonSchemaForm.js.map +1 -1
  85. package/dist/components/SecretFormField.cjs +3 -0
  86. package/dist/components/SecretFormField.cjs.map +1 -1
  87. package/dist/components/SecretFormField.d.ts.map +1 -1
  88. package/dist/components/SecretFormField.js +3 -0
  89. package/dist/components/SecretFormField.js.map +1 -1
  90. package/dist/components/SecretKeySelector.cjs +28 -2
  91. package/dist/components/SecretKeySelector.cjs.map +1 -1
  92. package/dist/components/SecretKeySelector.d.ts +7 -1
  93. package/dist/components/SecretKeySelector.d.ts.map +1 -1
  94. package/dist/components/SecretKeySelector.js +28 -2
  95. package/dist/components/SecretKeySelector.js.map +1 -1
  96. package/dist/components/SegmentedControl.cjs +4 -1
  97. package/dist/components/SegmentedControl.cjs.map +1 -1
  98. package/dist/components/SegmentedControl.d.ts +3 -3
  99. package/dist/components/SegmentedControl.d.ts.map +1 -1
  100. package/dist/components/SegmentedControl.js +5 -2
  101. package/dist/components/SegmentedControl.js.map +1 -1
  102. package/dist/components/WorkspaceAccessDialog.cjs +273 -99
  103. package/dist/components/WorkspaceAccessDialog.cjs.map +1 -1
  104. package/dist/components/WorkspaceAccessDialog.d.ts +4 -2
  105. package/dist/components/WorkspaceAccessDialog.d.ts.map +1 -1
  106. package/dist/components/WorkspaceAccessDialog.js +275 -101
  107. package/dist/components/WorkspaceAccessDialog.js.map +1 -1
  108. package/dist/components/json-schema-form-accordion-array.cjs +5 -3
  109. package/dist/components/json-schema-form-accordion-array.cjs.map +1 -1
  110. package/dist/components/json-schema-form-accordion-array.d.ts.map +1 -1
  111. package/dist/components/json-schema-form-accordion-array.js +7 -5
  112. package/dist/components/json-schema-form-accordion-array.js.map +1 -1
  113. package/dist/components/json-schema-form-cards-array.cjs +1 -0
  114. package/dist/components/json-schema-form-cards-array.cjs.map +1 -1
  115. package/dist/components/json-schema-form-cards-array.d.ts.map +1 -1
  116. package/dist/components/json-schema-form-cards-array.js +2 -1
  117. package/dist/components/json-schema-form-cards-array.js.map +1 -1
  118. package/dist/components/json-schema-form-conditionals.cjs +1 -4
  119. package/dist/components/json-schema-form-conditionals.cjs.map +1 -1
  120. package/dist/components/json-schema-form-conditionals.d.ts.map +1 -1
  121. package/dist/components/json-schema-form-conditionals.js +1 -4
  122. package/dist/components/json-schema-form-conditionals.js.map +1 -1
  123. package/dist/components/json-schema-form-enum-choice.cjs +4 -3
  124. package/dist/components/json-schema-form-enum-choice.cjs.map +1 -1
  125. package/dist/components/json-schema-form-enum-choice.d.ts.map +1 -1
  126. package/dist/components/json-schema-form-enum-choice.js +4 -3
  127. package/dist/components/json-schema-form-enum-choice.js.map +1 -1
  128. package/dist/components/json-schema-form-item-row.cjs +4 -0
  129. package/dist/components/json-schema-form-item-row.cjs.map +1 -1
  130. package/dist/components/json-schema-form-item-row.d.ts +3 -0
  131. package/dist/components/json-schema-form-item-row.d.ts.map +1 -1
  132. package/dist/components/json-schema-form-item-row.js +5 -2
  133. package/dist/components/json-schema-form-item-row.js.map +1 -1
  134. package/dist/components/json-schema-form-item-summary.cjs +10 -0
  135. package/dist/components/json-schema-form-item-summary.cjs.map +1 -1
  136. package/dist/components/json-schema-form-item-summary.d.ts +1 -0
  137. package/dist/components/json-schema-form-item-summary.d.ts.map +1 -1
  138. package/dist/components/json-schema-form-item-summary.js +10 -1
  139. package/dist/components/json-schema-form-item-summary.js.map +1 -1
  140. package/dist/components/json-schema-form-listeners.cjs +1 -5
  141. package/dist/components/json-schema-form-listeners.cjs.map +1 -1
  142. package/dist/components/json-schema-form-listeners.js +1 -5
  143. package/dist/components/json-schema-form-listeners.js.map +1 -1
  144. package/dist/components/json-schema-form-refs.cjs +29 -4
  145. package/dist/components/json-schema-form-refs.cjs.map +1 -1
  146. package/dist/components/json-schema-form-refs.js +29 -4
  147. package/dist/components/json-schema-form-refs.js.map +1 -1
  148. package/dist/components/json-schema-form-render.cjs +39 -16
  149. package/dist/components/json-schema-form-render.cjs.map +1 -1
  150. package/dist/components/json-schema-form-render.d.ts.map +1 -1
  151. package/dist/components/json-schema-form-render.js +40 -17
  152. package/dist/components/json-schema-form-render.js.map +1 -1
  153. package/dist/components/json-schema-form-resolve.cjs +3 -1
  154. package/dist/components/json-schema-form-resolve.cjs.map +1 -1
  155. package/dist/components/json-schema-form-resolve.d.ts.map +1 -1
  156. package/dist/components/json-schema-form-resolve.js +3 -1
  157. package/dist/components/json-schema-form-resolve.js.map +1 -1
  158. package/dist/components/json-schema-form-runtime-types.d.ts +8 -0
  159. package/dist/components/json-schema-form-runtime-types.d.ts.map +1 -1
  160. package/dist/components/json-schema-form-table-array.cjs +1 -1
  161. package/dist/components/json-schema-form-table-array.cjs.map +1 -1
  162. package/dist/components/json-schema-form-table-array.js +2 -2
  163. package/dist/components/json-schema-form-table-array.js.map +1 -1
  164. package/dist/components/json-schema-form-types.d.ts +6 -0
  165. package/dist/components/json-schema-form-types.d.ts.map +1 -1
  166. package/dist/components/json-schema-form-utils.cjs +12 -3
  167. package/dist/components/json-schema-form-utils.cjs.map +1 -1
  168. package/dist/components/json-schema-form-utils.d.ts +4 -1
  169. package/dist/components/json-schema-form-utils.d.ts.map +1 -1
  170. package/dist/components/json-schema-form-utils.js +12 -3
  171. package/dist/components/json-schema-form-utils.js.map +1 -1
  172. package/dist/components/secret-form-extension.cjs.map +1 -1
  173. package/dist/components/secret-form-extension.d.ts +2 -0
  174. package/dist/components/secret-form-extension.d.ts.map +1 -1
  175. package/dist/components/secret-form-extension.js.map +1 -1
  176. package/dist/components/useSingleRowTagCount.cjs +16 -13
  177. package/dist/components/useSingleRowTagCount.cjs.map +1 -1
  178. package/dist/components/useSingleRowTagCount.d.ts +0 -5
  179. package/dist/components/useSingleRowTagCount.d.ts.map +1 -1
  180. package/dist/components/useSingleRowTagCount.js +16 -13
  181. package/dist/components/useSingleRowTagCount.js.map +1 -1
  182. package/dist/components.cjs +4 -0
  183. package/dist/components.d.ts +2 -0
  184. package/dist/components.d.ts.map +1 -1
  185. package/dist/components.js +3 -1
  186. package/dist/connections/connectionSchemaFormExtensions.cjs +13 -2
  187. package/dist/connections/connectionSchemaFormExtensions.cjs.map +1 -1
  188. package/dist/connections/connectionSchemaFormExtensions.d.ts.map +1 -1
  189. package/dist/connections/connectionSchemaFormExtensions.js +13 -2
  190. package/dist/connections/connectionSchemaFormExtensions.js.map +1 -1
  191. package/dist/data/DataTable.cjs +128 -82
  192. package/dist/data/DataTable.cjs.map +1 -1
  193. package/dist/data/DataTable.d.ts +29 -0
  194. package/dist/data/DataTable.d.ts.map +1 -1
  195. package/dist/data/DataTable.js +129 -83
  196. package/dist/data/DataTable.js.map +1 -1
  197. package/dist/data/DataTableList.cjs +43 -0
  198. package/dist/data/DataTableList.cjs.map +1 -0
  199. package/dist/data/DataTableList.d.ts +13 -0
  200. package/dist/data/DataTableList.d.ts.map +1 -0
  201. package/dist/data/DataTableList.js +43 -0
  202. package/dist/data/DataTableList.js.map +1 -0
  203. package/dist/data/DataTableOverflowCue.cjs +18 -8
  204. package/dist/data/DataTableOverflowCue.cjs.map +1 -1
  205. package/dist/data/DataTableOverflowCue.d.ts.map +1 -1
  206. package/dist/data/DataTableOverflowCue.js +18 -8
  207. package/dist/data/DataTableOverflowCue.js.map +1 -1
  208. package/dist/data/Markdown.cjs +11 -1
  209. package/dist/data/Markdown.cjs.map +1 -1
  210. package/dist/data/Markdown.d.ts.map +1 -1
  211. package/dist/data/Markdown.js +11 -1
  212. package/dist/data/Markdown.js.map +1 -1
  213. package/dist/data/PromptBanner.cjs +13 -4
  214. package/dist/data/PromptBanner.cjs.map +1 -1
  215. package/dist/data/PromptBanner.d.ts.map +1 -1
  216. package/dist/data/PromptBanner.js +13 -4
  217. package/dist/data/PromptBanner.js.map +1 -1
  218. package/dist/data/SelectionActionBar.cjs +20 -5
  219. package/dist/data/SelectionActionBar.cjs.map +1 -1
  220. package/dist/data/SelectionActionBar.d.ts +6 -1
  221. package/dist/data/SelectionActionBar.d.ts.map +1 -1
  222. package/dist/data/SelectionActionBar.js +20 -5
  223. package/dist/data/SelectionActionBar.js.map +1 -1
  224. package/dist/data/StatStrip.cjs +12 -4
  225. package/dist/data/StatStrip.cjs.map +1 -1
  226. package/dist/data/StatStrip.d.ts +0 -8
  227. package/dist/data/StatStrip.d.ts.map +1 -1
  228. package/dist/data/StatStrip.js +12 -4
  229. package/dist/data/StatStrip.js.map +1 -1
  230. package/dist/data/TaskManager.cjs +173 -53
  231. package/dist/data/TaskManager.cjs.map +1 -1
  232. package/dist/data/TaskManager.d.ts +9 -1
  233. package/dist/data/TaskManager.d.ts.map +1 -1
  234. package/dist/data/TaskManager.js +175 -55
  235. package/dist/data/TaskManager.js.map +1 -1
  236. package/dist/data/TaskPoolUsage.cjs +65 -1
  237. package/dist/data/TaskPoolUsage.cjs.map +1 -1
  238. package/dist/data/TaskPoolUsage.d.ts +19 -1
  239. package/dist/data/TaskPoolUsage.d.ts.map +1 -1
  240. package/dist/data/TaskPoolUsage.js +65 -2
  241. package/dist/data/TaskPoolUsage.js.map +1 -1
  242. package/dist/data/ai/SessionInspector.cjs +24 -14
  243. package/dist/data/ai/SessionInspector.cjs.map +1 -1
  244. package/dist/data/ai/SessionInspector.collection.cjs +9 -7
  245. package/dist/data/ai/SessionInspector.collection.cjs.map +1 -1
  246. package/dist/data/ai/SessionInspector.collection.d.ts +1 -1
  247. package/dist/data/ai/SessionInspector.collection.d.ts.map +1 -1
  248. package/dist/data/ai/SessionInspector.collection.js +9 -7
  249. package/dist/data/ai/SessionInspector.collection.js.map +1 -1
  250. package/dist/data/ai/SessionInspector.d.ts +8 -3
  251. package/dist/data/ai/SessionInspector.d.ts.map +1 -1
  252. package/dist/data/ai/SessionInspector.hierarchy-state.cjs +5 -4
  253. package/dist/data/ai/SessionInspector.hierarchy-state.cjs.map +1 -1
  254. package/dist/data/ai/SessionInspector.hierarchy-state.js +6 -5
  255. package/dist/data/ai/SessionInspector.hierarchy-state.js.map +1 -1
  256. package/dist/data/ai/SessionInspector.host-tabs.cjs +28 -0
  257. package/dist/data/ai/SessionInspector.host-tabs.cjs.map +1 -0
  258. package/dist/data/ai/SessionInspector.host-tabs.d.ts +17 -0
  259. package/dist/data/ai/SessionInspector.host-tabs.d.ts.map +1 -0
  260. package/dist/data/ai/SessionInspector.host-tabs.js +28 -0
  261. package/dist/data/ai/SessionInspector.host-tabs.js.map +1 -0
  262. package/dist/data/ai/SessionInspector.js +24 -14
  263. package/dist/data/ai/SessionInspector.js.map +1 -1
  264. package/dist/data/ai/SessionInspector.legacy.cjs +13 -6
  265. package/dist/data/ai/SessionInspector.legacy.cjs.map +1 -1
  266. package/dist/data/ai/SessionInspector.legacy.d.ts +3 -1
  267. package/dist/data/ai/SessionInspector.legacy.d.ts.map +1 -1
  268. package/dist/data/ai/SessionInspector.legacy.js +13 -6
  269. package/dist/data/ai/SessionInspector.legacy.js.map +1 -1
  270. package/dist/data/ai/SessionInspector.remote.cjs +7 -3
  271. package/dist/data/ai/SessionInspector.remote.cjs.map +1 -1
  272. package/dist/data/ai/SessionInspector.remote.d.ts +1 -1
  273. package/dist/data/ai/SessionInspector.remote.d.ts.map +1 -1
  274. package/dist/data/ai/SessionInspector.remote.js +8 -4
  275. package/dist/data/ai/SessionInspector.remote.js.map +1 -1
  276. package/dist/data/ai/SessionViewer.input.cjs +78 -1
  277. package/dist/data/ai/SessionViewer.input.cjs.map +1 -1
  278. package/dist/data/ai/SessionViewer.input.d.ts +9 -0
  279. package/dist/data/ai/SessionViewer.input.d.ts.map +1 -1
  280. package/dist/data/ai/SessionViewer.input.js +77 -2
  281. package/dist/data/ai/SessionViewer.input.js.map +1 -1
  282. package/dist/data/ai/SessionViewer.tool-details.cjs +44 -13
  283. package/dist/data/ai/SessionViewer.tool-details.cjs.map +1 -1
  284. package/dist/data/ai/SessionViewer.tool-details.d.ts +7 -1
  285. package/dist/data/ai/SessionViewer.tool-details.d.ts.map +1 -1
  286. package/dist/data/ai/SessionViewer.tool-details.js +44 -13
  287. package/dist/data/ai/SessionViewer.tool-details.js.map +1 -1
  288. package/dist/data/ai/SessionViewer.tool-row.cjs +7 -3
  289. package/dist/data/ai/SessionViewer.tool-row.cjs.map +1 -1
  290. package/dist/data/ai/SessionViewer.tool-row.d.ts.map +1 -1
  291. package/dist/data/ai/SessionViewer.tool-row.js +8 -4
  292. package/dist/data/ai/SessionViewer.tool-row.js.map +1 -1
  293. package/dist/data/ai/index.d.ts +1 -1
  294. package/dist/data/ai/index.d.ts.map +1 -1
  295. package/dist/data/ai/runtime-preset-menu/use-runtime-preset-menu.cjs +5 -2
  296. package/dist/data/ai/runtime-preset-menu/use-runtime-preset-menu.cjs.map +1 -1
  297. package/dist/data/ai/runtime-preset-menu/use-runtime-preset-menu.d.ts.map +1 -1
  298. package/dist/data/ai/runtime-preset-menu/use-runtime-preset-menu.js +6 -3
  299. package/dist/data/ai/runtime-preset-menu/use-runtime-preset-menu.js.map +1 -1
  300. package/dist/data/ai/runtime-profiles/RuntimeProfilesWorkspace.cjs +2 -1
  301. package/dist/data/ai/runtime-profiles/RuntimeProfilesWorkspace.cjs.map +1 -1
  302. package/dist/data/ai/runtime-profiles/RuntimeProfilesWorkspace.d.ts.map +1 -1
  303. package/dist/data/ai/runtime-profiles/RuntimeProfilesWorkspace.js +2 -1
  304. package/dist/data/ai/runtime-profiles/RuntimeProfilesWorkspace.js.map +1 -1
  305. package/dist/data/ai/runtime-profiles/use-runtime-profile-picker.cjs +2 -1
  306. package/dist/data/ai/runtime-profiles/use-runtime-profile-picker.cjs.map +1 -1
  307. package/dist/data/ai/runtime-profiles/use-runtime-profile-picker.d.ts.map +1 -1
  308. package/dist/data/ai/runtime-profiles/use-runtime-profile-picker.js +2 -1
  309. package/dist/data/ai/runtime-profiles/use-runtime-profile-picker.js.map +1 -1
  310. package/dist/data/ai/use-session-scroll.cjs +120 -41
  311. package/dist/data/ai/use-session-scroll.cjs.map +1 -1
  312. package/dist/data/ai/use-session-scroll.d.ts +3 -3
  313. package/dist/data/ai/use-session-scroll.d.ts.map +1 -1
  314. package/dist/data/ai/use-session-scroll.js +120 -41
  315. package/dist/data/ai/use-session-scroll.js.map +1 -1
  316. package/dist/data/cells/timestamp-format.cjs +57 -2
  317. package/dist/data/cells/timestamp-format.cjs.map +1 -1
  318. package/dist/data/cells/timestamp-format.d.ts +16 -2
  319. package/dist/data/cells/timestamp-format.d.ts.map +1 -1
  320. package/dist/data/cells/timestamp-format.js +56 -3
  321. package/dist/data/cells/timestamp-format.js.map +1 -1
  322. package/dist/data/chat/AgentIdentity.cjs +10 -3
  323. package/dist/data/chat/AgentIdentity.cjs.map +1 -1
  324. package/dist/data/chat/AgentIdentity.d.ts +2 -1
  325. package/dist/data/chat/AgentIdentity.d.ts.map +1 -1
  326. package/dist/data/chat/AgentIdentity.js +10 -3
  327. package/dist/data/chat/AgentIdentity.js.map +1 -1
  328. package/dist/data/chat/Conversation.cjs +14 -5
  329. package/dist/data/chat/Conversation.cjs.map +1 -1
  330. package/dist/data/chat/Conversation.d.ts.map +1 -1
  331. package/dist/data/chat/Conversation.js +14 -5
  332. package/dist/data/chat/Conversation.js.map +1 -1
  333. package/dist/data/data-table-list.cjs +24 -0
  334. package/dist/data/data-table-list.cjs.map +1 -0
  335. package/dist/data/data-table-list.d.ts +31 -0
  336. package/dist/data/data-table-list.d.ts.map +1 -0
  337. package/dist/data/data-table-list.js +24 -0
  338. package/dist/data/data-table-list.js.map +1 -0
  339. package/dist/data/delimited.cjs +48 -0
  340. package/dist/data/delimited.cjs.map +1 -0
  341. package/dist/data/delimited.d.ts +10 -0
  342. package/dist/data/delimited.d.ts.map +1 -0
  343. package/dist/data/delimited.js +47 -0
  344. package/dist/data/delimited.js.map +1 -0
  345. package/dist/data/git/index.d.ts +1 -0
  346. package/dist/data/git/index.d.ts.map +1 -1
  347. package/dist/data/git/pickers/GitPickers.cjs +2 -0
  348. package/dist/data/git/pickers/GitPickers.cjs.map +1 -1
  349. package/dist/data/git/pickers/GitPickers.d.ts.map +1 -1
  350. package/dist/data/git/pickers/GitPickers.js +2 -0
  351. package/dist/data/git/pickers/GitPickers.js.map +1 -1
  352. package/dist/data/git/pickers/GitSourcePicker.cjs +9 -2
  353. package/dist/data/git/pickers/GitSourcePicker.cjs.map +1 -1
  354. package/dist/data/git/pickers/GitSourcePicker.d.ts.map +1 -1
  355. package/dist/data/git/pickers/GitSourcePicker.js +9 -2
  356. package/dist/data/git/pickers/GitSourcePicker.js.map +1 -1
  357. package/dist/data/git/pickers/ReferencePicker.cjs +60 -6
  358. package/dist/data/git/pickers/ReferencePicker.cjs.map +1 -1
  359. package/dist/data/git/pickers/ReferencePicker.d.ts +9 -1
  360. package/dist/data/git/pickers/ReferencePicker.d.ts.map +1 -1
  361. package/dist/data/git/pickers/ReferencePicker.js +61 -7
  362. package/dist/data/git/pickers/ReferencePicker.js.map +1 -1
  363. package/dist/data/git/pickers/git-ref-group-limits.cjs +14 -0
  364. package/dist/data/git/pickers/git-ref-group-limits.cjs.map +1 -0
  365. package/dist/data/git/pickers/git-ref-group-limits.d.ts +11 -0
  366. package/dist/data/git/pickers/git-ref-group-limits.d.ts.map +1 -0
  367. package/dist/data/git/pickers/git-ref-group-limits.js +14 -0
  368. package/dist/data/git/pickers/git-ref-group-limits.js.map +1 -0
  369. package/dist/data/git/pickers/types.d.ts +2 -0
  370. package/dist/data/git/pickers/types.d.ts.map +1 -1
  371. package/dist/data/lint/LintList.cjs +154 -0
  372. package/dist/data/lint/LintList.cjs.map +1 -0
  373. package/dist/data/lint/LintList.d.ts +14 -0
  374. package/dist/data/lint/LintList.d.ts.map +1 -0
  375. package/dist/data/lint/LintList.js +154 -0
  376. package/dist/data/lint/LintList.js.map +1 -0
  377. package/dist/data/lint/LintResults.cjs +31 -10
  378. package/dist/data/lint/LintResults.cjs.map +1 -1
  379. package/dist/data/lint/LintResults.d.ts +5 -3
  380. package/dist/data/lint/LintResults.d.ts.map +1 -1
  381. package/dist/data/lint/LintResults.js +31 -10
  382. package/dist/data/lint/LintResults.js.map +1 -1
  383. package/dist/data/lint/actions.cjs +3 -1
  384. package/dist/data/lint/actions.cjs.map +1 -1
  385. package/dist/data/lint/actions.d.ts.map +1 -1
  386. package/dist/data/lint/actions.js +3 -1
  387. package/dist/data/lint/actions.js.map +1 -1
  388. package/dist/data/lint/index.d.ts +2 -0
  389. package/dist/data/lint/index.d.ts.map +1 -1
  390. package/dist/data/lint/list-grouping.cjs +39 -0
  391. package/dist/data/lint/list-grouping.cjs.map +1 -0
  392. package/dist/data/lint/list-grouping.d.ts +20 -0
  393. package/dist/data/lint/list-grouping.d.ts.map +1 -0
  394. package/dist/data/lint/list-grouping.js +39 -0
  395. package/dist/data/lint/list-grouping.js.map +1 -0
  396. package/dist/data/task-run-format.cjs +20 -0
  397. package/dist/data/task-run-format.cjs.map +1 -0
  398. package/dist/data/task-run-format.d.ts +6 -0
  399. package/dist/data/task-run-format.d.ts.map +1 -0
  400. package/dist/data/task-run-format.js +20 -0
  401. package/dist/data/task-run-format.js.map +1 -0
  402. package/dist/data/test-runner/TestDetailPanel.cjs +15 -4
  403. package/dist/data/test-runner/TestDetailPanel.cjs.map +1 -1
  404. package/dist/data/test-runner/TestDetailPanel.d.ts.map +1 -1
  405. package/dist/data/test-runner/TestDetailPanel.js +16 -5
  406. package/dist/data/test-runner/TestDetailPanel.js.map +1 -1
  407. package/dist/data/test-runner/TestList.cjs +87 -0
  408. package/dist/data/test-runner/TestList.cjs.map +1 -0
  409. package/dist/data/test-runner/TestList.d.ts +9 -0
  410. package/dist/data/test-runner/TestList.d.ts.map +1 -0
  411. package/dist/data/test-runner/TestList.js +87 -0
  412. package/dist/data/test-runner/TestList.js.map +1 -0
  413. package/dist/data/test-runner/TestRunner.cjs +21 -2
  414. package/dist/data/test-runner/TestRunner.cjs.map +1 -1
  415. package/dist/data/test-runner/TestRunner.d.ts +9 -1
  416. package/dist/data/test-runner/TestRunner.d.ts.map +1 -1
  417. package/dist/data/test-runner/TestRunner.js +21 -2
  418. package/dist/data/test-runner/TestRunner.js.map +1 -1
  419. package/dist/data/test-runner/TestTreeNode.cjs +1 -1
  420. package/dist/data/test-runner/TestTreeNode.cjs.map +1 -1
  421. package/dist/data/test-runner/TestTreeNode.js +1 -1
  422. package/dist/data/test-runner/TestTreeNode.js.map +1 -1
  423. package/dist/data/test-runner/TestViewToggle.cjs +32 -0
  424. package/dist/data/test-runner/TestViewToggle.cjs.map +1 -0
  425. package/dist/data/test-runner/TestViewToggle.d.ts +5 -0
  426. package/dist/data/test-runner/TestViewToggle.d.ts.map +1 -0
  427. package/dist/data/test-runner/TestViewToggle.js +32 -0
  428. package/dist/data/test-runner/TestViewToggle.js.map +1 -0
  429. package/dist/data/test-runner/adapter.cjs +14 -0
  430. package/dist/data/test-runner/adapter.cjs.map +1 -1
  431. package/dist/data/test-runner/adapter.d.ts +15 -0
  432. package/dist/data/test-runner/adapter.d.ts.map +1 -1
  433. package/dist/data/test-runner/adapter.js +14 -0
  434. package/dist/data/test-runner/adapter.js.map +1 -1
  435. package/dist/data/test-runner/context.cjs.map +1 -1
  436. package/dist/data/test-runner/context.d.ts +5 -0
  437. package/dist/data/test-runner/context.d.ts.map +1 -1
  438. package/dist/data/test-runner/context.js.map +1 -1
  439. package/dist/data/test-runner/index.d.ts +3 -0
  440. package/dist/data/test-runner/index.d.ts.map +1 -1
  441. package/dist/data/test-runner/status.cjs +5 -0
  442. package/dist/data/test-runner/status.cjs.map +1 -1
  443. package/dist/data/test-runner/status.d.ts +2 -0
  444. package/dist/data/test-runner/status.d.ts.map +1 -1
  445. package/dist/data/test-runner/status.js +5 -1
  446. package/dist/data/test-runner/status.js.map +1 -1
  447. package/dist/data/traces/index.d.ts +2 -1
  448. package/dist/data/traces/index.d.ts.map +1 -1
  449. package/dist/data/traces/otel/OtelTraceBrowser.cjs +173 -0
  450. package/dist/data/traces/otel/OtelTraceBrowser.cjs.map +1 -0
  451. package/dist/data/traces/otel/OtelTraceBrowser.d.ts +31 -0
  452. package/dist/data/traces/otel/OtelTraceBrowser.d.ts.map +1 -0
  453. package/dist/data/traces/otel/OtelTraceBrowser.js +173 -0
  454. package/dist/data/traces/otel/OtelTraceBrowser.js.map +1 -0
  455. package/dist/data/traces/otel/OtelTraceDetail.cjs +6 -4
  456. package/dist/data/traces/otel/OtelTraceDetail.cjs.map +1 -1
  457. package/dist/data/traces/otel/OtelTraceDetail.d.ts +5 -1
  458. package/dist/data/traces/otel/OtelTraceDetail.d.ts.map +1 -1
  459. package/dist/data/traces/otel/OtelTraceDetail.js +6 -4
  460. package/dist/data/traces/otel/OtelTraceDetail.js.map +1 -1
  461. package/dist/data/traces/otel/OtelTraceSearch.cjs +2 -1
  462. package/dist/data/traces/otel/OtelTraceSearch.cjs.map +1 -1
  463. package/dist/data/traces/otel/OtelTraceSearch.d.ts +3 -1
  464. package/dist/data/traces/otel/OtelTraceSearch.d.ts.map +1 -1
  465. package/dist/data/traces/otel/OtelTraceSearch.js +2 -1
  466. package/dist/data/traces/otel/OtelTraceSearch.js.map +1 -1
  467. package/dist/data/traces/otel/OtelTraceTable.cjs +62 -6
  468. package/dist/data/traces/otel/OtelTraceTable.cjs.map +1 -1
  469. package/dist/data/traces/otel/OtelTraceTable.d.ts +22 -1
  470. package/dist/data/traces/otel/OtelTraceTable.d.ts.map +1 -1
  471. package/dist/data/traces/otel/OtelTraceTable.js +62 -6
  472. package/dist/data/traces/otel/OtelTraceTable.js.map +1 -1
  473. package/dist/data/traces/otel/QueryBar.cjs +23 -10
  474. package/dist/data/traces/otel/QueryBar.cjs.map +1 -1
  475. package/dist/data/traces/otel/QueryBar.d.ts +3 -1
  476. package/dist/data/traces/otel/QueryBar.d.ts.map +1 -1
  477. package/dist/data/traces/otel/QueryBar.js +23 -10
  478. package/dist/data/traces/otel/QueryBar.js.map +1 -1
  479. package/dist/data/traces/otel/browser-state.cjs +86 -0
  480. package/dist/data/traces/otel/browser-state.cjs.map +1 -0
  481. package/dist/data/traces/otel/browser-state.d.ts +22 -0
  482. package/dist/data/traces/otel/browser-state.d.ts.map +1 -0
  483. package/dist/data/traces/otel/browser-state.js +83 -0
  484. package/dist/data/traces/otel/browser-state.js.map +1 -0
  485. package/dist/data/version-info.cjs +3 -3
  486. package/dist/data/version-info.js +3 -3
  487. package/dist/data.cjs +17 -0
  488. package/dist/data.d.ts +3 -3
  489. package/dist/data.d.ts.map +1 -1
  490. package/dist/data.js +10 -3
  491. package/dist/file-findings/file-review/FileReview.cjs +38 -11
  492. package/dist/file-findings/file-review/FileReview.cjs.map +1 -1
  493. package/dist/file-findings/file-review/FileReview.d.ts.map +1 -1
  494. package/dist/file-findings/file-review/FileReview.js +39 -12
  495. package/dist/file-findings/file-review/FileReview.js.map +1 -1
  496. package/dist/file-findings/file-review/geometry.cjs +20 -15
  497. package/dist/file-findings/file-review/geometry.cjs.map +1 -1
  498. package/dist/file-findings/file-review/geometry.d.ts +5 -3
  499. package/dist/file-findings/file-review/geometry.d.ts.map +1 -1
  500. package/dist/file-findings/file-review/geometry.js +21 -16
  501. package/dist/file-findings/file-review/geometry.js.map +1 -1
  502. package/dist/file-findings/file-review/patch-comments.cjs +23 -16
  503. package/dist/file-findings/file-review/patch-comments.cjs.map +1 -1
  504. package/dist/file-findings/file-review/patch-comments.d.ts +22 -12
  505. package/dist/file-findings/file-review/patch-comments.d.ts.map +1 -1
  506. package/dist/file-findings/file-review/patch-comments.js +23 -17
  507. package/dist/file-findings/file-review/patch-comments.js.map +1 -1
  508. package/dist/file-findings/file-review/quote-anchor.cjs +23 -9
  509. package/dist/file-findings/file-review/quote-anchor.cjs.map +1 -1
  510. package/dist/file-findings/file-review/quote-anchor.d.ts +12 -2
  511. package/dist/file-findings/file-review/quote-anchor.d.ts.map +1 -1
  512. package/dist/file-findings/file-review/quote-anchor.js +22 -9
  513. package/dist/file-findings/file-review/quote-anchor.js.map +1 -1
  514. package/dist/file-findings/file-review/selection-lines.cjs +17 -8
  515. package/dist/file-findings/file-review/selection-lines.cjs.map +1 -1
  516. package/dist/file-findings/file-review/selection-lines.d.ts +3 -2
  517. package/dist/file-findings/file-review/selection-lines.d.ts.map +1 -1
  518. package/dist/file-findings/file-review/selection-lines.js +17 -8
  519. package/dist/file-findings/file-review/selection-lines.js.map +1 -1
  520. package/dist/file-findings/file-review/table-cell.cjs +95 -0
  521. package/dist/file-findings/file-review/table-cell.cjs.map +1 -0
  522. package/dist/file-findings/file-review/table-cell.d.ts +31 -0
  523. package/dist/file-findings/file-review/table-cell.d.ts.map +1 -0
  524. package/dist/file-findings/file-review/table-cell.js +92 -0
  525. package/dist/file-findings/file-review/table-cell.js.map +1 -0
  526. package/dist/file-findings.cjs +2 -0
  527. package/dist/file-findings.d.ts +1 -0
  528. package/dist/file-findings.d.ts.map +1 -1
  529. package/dist/file-findings.js +2 -1
  530. package/dist/icons/components/UiFolderGit.cjs +8 -8
  531. package/dist/icons/components/UiFolderGit.cjs.map +1 -1
  532. package/dist/icons/components/UiFolderGit.js +8 -8
  533. package/dist/icons/components/UiFolderGit.js.map +1 -1
  534. package/dist/icons/components/UiUserSwitch.cjs +51 -0
  535. package/dist/icons/components/UiUserSwitch.cjs.map +1 -0
  536. package/dist/icons/components/UiUserSwitch.d.ts +15 -0
  537. package/dist/icons/components/UiUserSwitch.d.ts.map +1 -0
  538. package/dist/icons/components/UiUserSwitch.js +48 -0
  539. package/dist/icons/components/UiUserSwitch.js.map +1 -0
  540. package/dist/icons/index.d.ts +2 -0
  541. package/dist/icons/index.d.ts.map +1 -1
  542. package/dist/icons/registry.cjs +2 -0
  543. package/dist/icons/registry.cjs.map +1 -1
  544. package/dist/icons/registry.d.ts.map +1 -1
  545. package/dist/icons/registry.js +2 -0
  546. package/dist/icons/registry.js.map +1 -1
  547. package/dist/icons.cjs +3 -0
  548. package/dist/icons.js +2 -1
  549. package/dist/index.cjs +23 -0
  550. package/dist/index.js +13 -3
  551. package/dist/jvm/model/threads.cjs +1 -1
  552. package/dist/jvm/model/threads.cjs.map +1 -1
  553. package/dist/jvm/model/threads.js +1 -1
  554. package/dist/jvm/model/threads.js.map +1 -1
  555. package/dist/lib/random-uuid.cjs +12 -0
  556. package/dist/lib/random-uuid.cjs.map +1 -0
  557. package/dist/lib/random-uuid.d.ts +2 -0
  558. package/dist/lib/random-uuid.d.ts.map +1 -0
  559. package/dist/lib/random-uuid.js +12 -0
  560. package/dist/lib/random-uuid.js.map +1 -0
  561. package/dist/overlay/Modal.cjs +22 -11
  562. package/dist/overlay/Modal.cjs.map +1 -1
  563. package/dist/overlay/Modal.d.ts +5 -1
  564. package/dist/overlay/Modal.d.ts.map +1 -1
  565. package/dist/overlay/Modal.js +22 -11
  566. package/dist/overlay/Modal.js.map +1 -1
  567. package/dist/overlay/ModalProvider.cjs +238 -0
  568. package/dist/overlay/ModalProvider.cjs.map +1 -0
  569. package/dist/overlay/ModalProvider.d.ts +10 -0
  570. package/dist/overlay/ModalProvider.d.ts.map +1 -0
  571. package/dist/overlay/ModalProvider.js +238 -0
  572. package/dist/overlay/ModalProvider.js.map +1 -0
  573. package/dist/overlay/modal-context.cjs +12 -0
  574. package/dist/overlay/modal-context.cjs.map +1 -0
  575. package/dist/overlay/modal-context.d.ts +46 -0
  576. package/dist/overlay/modal-context.d.ts.map +1 -0
  577. package/dist/overlay/modal-context.js +11 -0
  578. package/dist/overlay/modal-context.js.map +1 -0
  579. package/dist/overlay/modal-draft-storage.cjs +51 -0
  580. package/dist/overlay/modal-draft-storage.cjs.map +1 -0
  581. package/dist/overlay/modal-draft-storage.d.ts +19 -0
  582. package/dist/overlay/modal-draft-storage.d.ts.map +1 -0
  583. package/dist/overlay/modal-draft-storage.js +47 -0
  584. package/dist/overlay/modal-draft-storage.js.map +1 -0
  585. package/dist/runtime/barrels.json +8696 -8652
  586. package/dist/runtime/importmap.json +2116 -2103
  587. package/dist/styles.css +1 -1
  588. package/dist/utils.cjs +2 -0
  589. package/dist/utils.d.ts +1 -0
  590. package/dist/utils.d.ts.map +1 -1
  591. package/dist/utils.js +2 -1
  592. package/package.json +2 -2
@@ -15,6 +15,7 @@ function resolveItemSpec(arraySchema, itemSchema) {
15
15
  const raw = require_collections.isPlainObject(arraySchema["x-item"]) ? arraySchema["x-item"] : {};
16
16
  const title = stringArray(raw.title);
17
17
  const summary = summaryParts(raw.summary);
18
+ const badges = summaryParts(raw.badges);
18
19
  const glyph = typeof raw.glyph === "string" ? raw.glyph : autoGlyphKey(itemSchema);
19
20
  return {
20
21
  title: title.length > 0 ? title : DEFAULT_TITLE_KEYS,
@@ -22,6 +23,8 @@ function resolveItemSpec(arraySchema, itemSchema) {
22
23
  ...summary.length > 0 ? { summary } : {},
23
24
  ...glyph ? { glyph } : {},
24
25
  ...typeof raw.badge === "string" && raw.badge ? { badge: raw.badge } : {},
26
+ ...badges.length > 0 ? { badges } : {},
27
+ ...raw.count === false ? { count: false } : {},
25
28
  ...typeof raw.flag === "string" && raw.flag ? { flag: raw.flag } : {},
26
29
  ...Array.isArray(raw.actions) ? { actions: itemActions(raw.actions) } : {},
27
30
  noun: firstNonEmpty([raw.noun, itemSchema?.title]) ?? "item",
@@ -57,6 +60,7 @@ function itemSummaryFor({ item, index, spec, itemSchema }) {
57
60
  return value && enumLabel(props[key], value);
58
61
  })) ?? spec.fallback ?? `Item ${index + 1}`;
59
62
  const summary = (spec.summary ?? []).map((part) => summaryPart(obj, part)).filter((s) => !!s).join(SUMMARY_SEPARATOR);
63
+ const badges = (spec.badges ?? []).map((part) => summaryPart(obj, part)).filter((s) => !!s);
60
64
  const glyphValue = spec.glyph ? text(obj[spec.glyph]) : "";
61
65
  const glyphProp = spec.glyph ? props[spec.glyph] : void 0;
62
66
  const badgeValue = spec.badge ? text(obj[spec.badge]) : "";
@@ -74,6 +78,7 @@ function itemSummaryFor({ item, index, spec, itemSchema }) {
74
78
  ...badgeIcon ? { icon: badgeIcon } : {},
75
79
  label: enumLabel(badgeProp, badgeValue)
76
80
  } } : {},
81
+ ...badges.length > 0 ? { badges } : {},
77
82
  ...spec.flag && obj[spec.flag] === true ? { flagged: true } : {}
78
83
  };
79
84
  }
@@ -83,6 +88,10 @@ function addItemLabel(spec) {
83
88
  function itemCountLabel(spec, count) {
84
89
  return count === 1 ? `1 ${spec.noun ?? "item"}` : `${count} ${spec.nounPlural ?? "items"}`;
85
90
  }
91
+ function itemCountLine(spec, count) {
92
+ if (count === 0) return noItemsLabel(spec);
93
+ return spec.count === false ? void 0 : itemCountLabel(spec, count);
94
+ }
86
95
  function emptyItemsCopy(spec, arraySchema) {
87
96
  if (spec.empty) return spec.empty;
88
97
  return (typeof arraySchema.description === "string" ? arraySchema.description.trim() : "") || void 0;
@@ -135,6 +144,7 @@ exports.addItemLabel = addItemLabel;
135
144
  exports.emptyItemsCopy = emptyItemsCopy;
136
145
  exports.itemActionsAllow = itemActionsAllow;
137
146
  exports.itemCountLabel = itemCountLabel;
147
+ exports.itemCountLine = itemCountLine;
138
148
  exports.itemSummaryFor = itemSummaryFor;
139
149
  exports.noItemsLabel = noItemsLabel;
140
150
  exports.resolveItemSpec = resolveItemSpec;
@@ -1 +1 @@
1
- {"version":3,"file":"json-schema-form-item-summary.cjs","names":["isPlainObject","effectiveProperties","normalizeTone"],"sources":["../../src/components/json-schema-form-item-summary.ts"],"sourcesContent":["import { isPlainObject } from \"../lib/collections\";\nimport { effectiveProperties } from \"./json-schema-form-conditionals\";\nimport { normalizeTone } from \"./json-schema-form-tone\";\nimport type {\n ArrayItemAction,\n ArrayItemSpec,\n ArrayItemSummary,\n ArrayItemSummaryPart,\n JsonSchemaObject,\n JsonSchemaProperty,\n} from \"./json-schema-form-types\";\n\n// Property names worth trying for a row title when the schema does not say.\n// Ordered most-human-readable first.\nconst DEFAULT_TITLE_KEYS = [\"title\", \"name\", \"label\", \"id\", \"key\"];\n\nconst SUMMARY_SEPARATOR = \" · \";\nconst VALUE_SEPARATOR = \", \";\n\n// resolveItemSpec reads the array's `x-item` and fills in every default, so the\n// renderer never has to ask whether a key was supplied. With no `x-item` at all\n// the result reproduces today's behaviour exactly: an `Item <n>` title and an\n// \"Add item\" button.\nexport function resolveItemSpec(\n arraySchema: JsonSchemaProperty,\n itemSchema: JsonSchemaProperty | undefined,\n): ArrayItemSpec {\n const raw = isPlainObject(arraySchema[\"x-item\"])\n ? (arraySchema[\"x-item\"] as ArrayItemSpec)\n : {};\n const title = stringArray(raw.title);\n const summary = summaryParts(raw.summary);\n const glyph = typeof raw.glyph === \"string\" ? raw.glyph : autoGlyphKey(itemSchema);\n return {\n title: title.length > 0 ? title : DEFAULT_TITLE_KEYS,\n ...(typeof raw.fallback === \"string\" && raw.fallback ? { fallback: raw.fallback } : {}),\n ...(summary.length > 0 ? { summary } : {}),\n ...(glyph ? { glyph } : {}),\n ...(typeof raw.badge === \"string\" && raw.badge ? { badge: raw.badge } : {}),\n ...(typeof raw.flag === \"string\" && raw.flag ? { flag: raw.flag } : {}),\n // Only carried when the schema actually said something: an absent key means\n // every action, while an explicit empty list means none, and those two\n // cannot be told apart once the default has been filled in.\n ...(Array.isArray(raw.actions) ? { actions: itemActions(raw.actions) } : {}),\n noun: firstNonEmpty([raw.noun, itemSchema?.title]) ?? \"item\",\n nounPlural: firstNonEmpty([raw.nounPlural, arraySchema.title]) ?? \"items\",\n ...(typeof raw.empty === \"string\" && raw.empty ? { empty: raw.empty } : {}),\n };\n}\n\nconst ITEM_ACTIONS: ArrayItemAction[] = [\"reorder\", \"duplicate\", \"remove\"];\n\nfunction itemActions(value: unknown[]): ArrayItemAction[] {\n return value.filter((entry): entry is ArrayItemAction =>\n ITEM_ACTIONS.includes(entry as ArrayItemAction),\n );\n}\n\n// itemActionsAllow is the one question every array display asks of `x-item`, so\n// the accordion and the cards never disagree about what a schema permitted.\nexport function itemActionsAllow(spec: ArrayItemSpec, action: ArrayItemAction): boolean {\n return spec.actions ? spec.actions.includes(action) : true;\n}\n\n// itemProperties is the item schema's effective properties — `allOf` members\n// included, so items composed of flattened `$ref`s summarize like any other —\n// resolved against `value`.\nfunction itemProperties(\n itemSchema: JsonSchemaProperty | undefined,\n value: Record<string, unknown>,\n): Record<string, JsonSchemaProperty> {\n return itemSchema ? effectiveProperties(itemSchema as JsonSchemaObject, value).properties : {};\n}\n\n// autoGlyphKey picks the item property that can colour a row without being told:\n// the first enum carrying per-value icons. Keeps a schema that already declares\n// x-enum-icons from having to repeat itself in x-item. The spec is one per\n// array, so there is no item value to select a conditional branch: only base\n// and unconditional properties (and `else` branches, which `{}` selects) count.\nfunction autoGlyphKey(itemSchema: JsonSchemaProperty | undefined): string | undefined {\n for (const [key, prop] of Object.entries(itemProperties(itemSchema, {}))) {\n const icons = prop[\"x-enum-icons\"];\n if (Array.isArray(prop.enum) && icons && Object.keys(icons).length > 0) return key;\n }\n return undefined;\n}\n\n// itemSummaryFor derives one collapsed row from the item's raw VALUE — never\n// from its rendered fields. A consumer pre-extension may hide a property's\n// control entirely (returning null) and still have it appear in the summary.\nexport function itemSummaryFor({\n item,\n index,\n spec,\n itemSchema,\n}: {\n item: unknown;\n index: number;\n spec: ArrayItemSpec;\n itemSchema: JsonSchemaProperty | undefined;\n}): ArrayItemSummary {\n const obj = isPlainObject(item) ? item : {};\n // Resolved against this item's own value, as the item's body is rendered,\n // so a property a matching `then`/`else` branch declares labels its chip.\n const props = itemProperties(itemSchema, obj);\n\n const title =\n firstNonEmpty(\n (spec.title ?? DEFAULT_TITLE_KEYS).map((key) => {\n const value = text(obj[key]);\n return value && enumLabel(props[key], value);\n }),\n ) ??\n spec.fallback ??\n `Item ${index + 1}`;\n\n const summary = (spec.summary ?? [])\n .map((part) => summaryPart(obj, part))\n .filter((s): s is string => !!s)\n .join(SUMMARY_SEPARATOR);\n\n const glyphValue = spec.glyph ? text(obj[spec.glyph]) : \"\";\n const glyphProp = spec.glyph ? props[spec.glyph] : undefined;\n const badgeValue = spec.badge ? text(obj[spec.badge]) : \"\";\n const badgeProp = spec.badge ? props[spec.badge] : undefined;\n const badgeIcon = badgeProp?.[\"x-enum-icons\"]?.[badgeValue];\n\n return {\n title,\n ...(summary ? { summary } : {}),\n ...(spec.glyph\n ? {\n glyph: {\n ...(glyphProp?.[\"x-enum-icons\"]?.[glyphValue]\n ? { icon: glyphProp[\"x-enum-icons\"][glyphValue] }\n : {}),\n tone: normalizeTone(glyphProp?.[\"x-enum-tones\"]?.[glyphValue]),\n ...(glyphValue ? { label: enumLabel(glyphProp, glyphValue) } : {}),\n },\n }\n : {}),\n ...(badgeValue\n ? {\n badge: {\n ...(badgeIcon ? { icon: badgeIcon } : {}),\n label: enumLabel(badgeProp, badgeValue),\n },\n }\n : {}),\n ...(spec.flag && obj[spec.flag] === true ? { flagged: true } : {}),\n };\n}\n\n// The add row's button text — \"Add parameter\" when the schema names its noun,\n// and the historical \"Add item\" when it does not.\nexport function addItemLabel(spec: ArrayItemSpec): string {\n return `Add ${spec.noun ?? \"item\"}`;\n}\n\nexport function itemCountLabel(spec: ArrayItemSpec, count: number): string {\n return count === 1\n ? `1 ${spec.noun ?? \"item\"}`\n : `${count} ${spec.nounPlural ?? \"items\"}`;\n}\n\n// The zero-item explanation. Falls back to the array's own description, so a\n// schema that already documents the field gets the empty state for free.\nexport function emptyItemsCopy(\n spec: ArrayItemSpec,\n arraySchema: JsonSchemaProperty,\n): string | undefined {\n if (spec.empty) return spec.empty;\n const description = typeof arraySchema.description === \"string\" ? arraySchema.description.trim() : \"\";\n return description || undefined;\n}\n\nexport function noItemsLabel(spec: ArrayItemSpec): string {\n return `No ${spec.nounPlural ?? \"items\"} yet`;\n}\n\n// summaryPart renders one part, substituting the value into a single literal\n// `{}` in the pattern. A pattern without `{}` renders as-is (it is a literal),\n// and a missing value drops the part rather than leaving a dangling separator.\nfunction summaryPart(\n obj: Record<string, unknown>,\n part: string | ArrayItemSummaryPart,\n): string | undefined {\n const { property, pattern } = typeof part === \"string\" ? { property: part, pattern: undefined } : part;\n const value = text(obj[property]);\n if (!value) return undefined;\n return pattern ? pattern.replace(\"{}\", value) : value;\n}\n\n// enumLabel prefers the human label the schema declares for a code, falling back\n// to the code itself. Unlike the combobox option list this does NOT render\n// \"Label (code)\" — a chip has room for one of the two, and the label is the one\n// worth reading.\nfunction enumLabel(prop: JsonSchemaProperty | undefined, value: string): string {\n const label = prop?.[\"x-enum-labels\"]?.[value];\n return typeof label === \"string\" && label ? label : value;\n}\n\n// text flattens a value to its display string. Arrays join, so a list-valued\n// property still reads as one line.\nfunction text(value: unknown): string {\n if (value === undefined || value === null) return \"\";\n if (Array.isArray(value)) return value.map(text).filter(Boolean).join(VALUE_SEPARATOR);\n if (typeof value === \"object\") return \"\";\n return String(value).trim();\n}\n\nfunction stringArray(value: unknown): string[] {\n if (typeof value === \"string\") return [value];\n if (!Array.isArray(value)) return [];\n return value.filter((v): v is string => typeof v === \"string\" && !!v);\n}\n\nfunction summaryParts(value: unknown): Array<string | ArrayItemSummaryPart> {\n if (!Array.isArray(value)) return [];\n return (value as unknown[]).flatMap((part): Array<string | ArrayItemSummaryPart> => {\n if (typeof part === \"string\" && part) return [part];\n if (isPlainObject(part) && typeof part.property === \"string\" && part.property) {\n return [\n {\n property: part.property,\n ...(typeof part.pattern === \"string\" && part.pattern ? { pattern: part.pattern } : {}),\n } satisfies ArrayItemSummaryPart,\n ];\n }\n return [];\n });\n}\n\nfunction firstNonEmpty(values: Array<string | undefined>): string | undefined {\n for (const value of values) {\n const trimmed = typeof value === \"string\" ? value.trim() : \"\";\n if (trim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GAAG;CACxC,OAAO,OAAO,UAAU,YAAY,QAAQ,QAAQ;AACtD;AAIA,SAAS,KAAK,OAAwB;CACpC,IAAI,UAAU,KAAA,KAAa,UAAU,MAAM,OAAO;CAClD,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,MAAM,IAAI,IAAI,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,eAAe;CACrF,IAAI,OAAO,UAAU,UAAU,OAAO;CACtC,OAAO,OAAO,KAAK,CAAC,CAAC,KAAK;AAC5B;AAEA,SAAS,YAAY,OAA0B;CAC7C,IAAI,OAAO,UAAU,UAAU,OAAO,CAAC,KAAK;CAC5C,IAAI,CAAC,MAAM,QAAQ,KAAK,GAAG,OAAO,CAAC;CACnC,OAAO,MAAM,QAAQ,MAAmB,OAAO,MAAM,YAAY,CAAC,CAAC,CAAC;AACtE;AAEA,SAAS,aAAa,OAAsD;CAC1E,IAAI,CAAC,MAAM,QAAQ,KAAK,GAAG,OAAO,CAAC;CACnC,OAAQ,MAAoB,SAAS,SAA+C;EAClF,IAAI,OAAO,SAAS,YAAY,MAAM,OAAO,CAAC,IAAI;EAClD,IAAIF,oBAAAA,cAAc,IAAI,KAAK,OAAO,KAAK,aAAa,YAAY,KAAK,UACnE,OAAO,CACL;GACE,UAAU,KAAK;GACf,GAAI,OAAO,KAAK,YAAY,YAAY,KAAK,UAAU,EAAE,SAAS,KAAK,QAAQ,IAAI,CAAC;EACtF,CACF;EAEF,OAAO,CAAC;CACV,CAAC;AACH;AAEA,SAAS,cAAc,QAAuD;CAC5E,KAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,UAAU,OAAO,UAAU,WAAW,MAAM,KAAK,IAAI;EAC3D,IAAI,SAAS,OAAO;CACtB;AAEF"}
1
+ {"version":3,"file":"json-schema-form-item-summary.cjs","names":["isPlainObject","effectiveProperties","normalizeTone"],"sources":["../../src/components/json-schema-form-item-summary.ts"],"sourcesContent":["import { isPlainObject } from \"../lib/collections\";\nimport { effectiveProperties } from \"./json-schema-form-conditionals\";\nimport { normalizeTone } from \"./json-schema-form-tone\";\nimport type {\n ArrayItemAction,\n ArrayItemSpec,\n ArrayItemSummary,\n ArrayItemSummaryPart,\n JsonSchemaObject,\n JsonSchemaProperty,\n} from \"./json-schema-form-types\";\n\n// Property names worth trying for a row title when the schema does not say.\n// Ordered most-human-readable first.\nconst DEFAULT_TITLE_KEYS = [\"title\", \"name\", \"label\", \"id\", \"key\"];\n\nconst SUMMARY_SEPARATOR = \" · \";\nconst VALUE_SEPARATOR = \", \";\n\n// resolveItemSpec reads the array's `x-item` and fills in every default, so the\n// renderer never has to ask whether a key was supplied. With no `x-item` at all\n// the result reproduces today's behaviour exactly: an `Item <n>` title and an\n// \"Add item\" button.\nexport function resolveItemSpec(\n arraySchema: JsonSchemaProperty,\n itemSchema: JsonSchemaProperty | undefined,\n): ArrayItemSpec {\n const raw = isPlainObject(arraySchema[\"x-item\"])\n ? (arraySchema[\"x-item\"] as ArrayItemSpec)\n : {};\n const title = stringArray(raw.title);\n const summary = summaryParts(raw.summary);\n const badges = summaryParts(raw.badges);\n const glyph = typeof raw.glyph === \"string\" ? raw.glyph : autoGlyphKey(itemSchema);\n return {\n title: title.length > 0 ? title : DEFAULT_TITLE_KEYS,\n ...(typeof raw.fallback === \"string\" && raw.fallback ? { fallback: raw.fallback } : {}),\n ...(summary.length > 0 ? { summary } : {}),\n ...(glyph ? { glyph } : {}),\n ...(typeof raw.badge === \"string\" && raw.badge ? { badge: raw.badge } : {}),\n ...(badges.length > 0 ? { badges } : {}),\n ...(raw.count === false ? { count: false } : {}),\n ...(typeof raw.flag === \"string\" && raw.flag ? { flag: raw.flag } : {}),\n // Only carried when the schema actually said something: an absent key means\n // every action, while an explicit empty list means none, and those two\n // cannot be told apart once the default has been filled in.\n ...(Array.isArray(raw.actions) ? { actions: itemActions(raw.actions) } : {}),\n noun: firstNonEmpty([raw.noun, itemSchema?.title]) ?? \"item\",\n nounPlural: firstNonEmpty([raw.nounPlural, arraySchema.title]) ?? \"items\",\n ...(typeof raw.empty === \"string\" && raw.empty ? { empty: raw.empty } : {}),\n };\n}\n\nconst ITEM_ACTIONS: ArrayItemAction[] = [\"reorder\", \"duplicate\", \"remove\"];\n\nfunction itemActions(value: unknown[]): ArrayItemAction[] {\n return value.filter((entry): entry is ArrayItemAction =>\n ITEM_ACTIONS.includes(entry as ArrayItemAction),\n );\n}\n\n// itemActionsAllow is the one question every array display asks of `x-item`, so\n// the accordion and the cards never disagree about what a schema permitted.\nexport function itemActionsAllow(spec: ArrayItemSpec, action: ArrayItemAction): boolean {\n return spec.actions ? spec.actions.includes(action) : true;\n}\n\n// itemProperties is the item schema's effective properties — `allOf` members\n// included, so items composed of flattened `$ref`s summarize like any other —\n// resolved against `value`.\nfunction itemProperties(\n itemSchema: JsonSchemaProperty | undefined,\n value: Record<string, unknown>,\n): Record<string, JsonSchemaProperty> {\n return itemSchema ? effectiveProperties(itemSchema as JsonSchemaObject, value).properties : {};\n}\n\n// autoGlyphKey picks the item property that can colour a row without being told:\n// the first enum carrying per-value icons. Keeps a schema that already declares\n// x-enum-icons from having to repeat itself in x-item. The spec is one per\n// array, so there is no item value to select a conditional branch: only base\n// and unconditional properties (and `else` branches, which `{}` selects) count.\nfunction autoGlyphKey(itemSchema: JsonSchemaProperty | undefined): string | undefined {\n for (const [key, prop] of Object.entries(itemProperties(itemSchema, {}))) {\n const icons = prop[\"x-enum-icons\"];\n if (Array.isArray(prop.enum) && icons && Object.keys(icons).length > 0) return key;\n }\n return undefined;\n}\n\n// itemSummaryFor derives one collapsed row from the item's raw VALUE — never\n// from its rendered fields. A consumer pre-extension may hide a property's\n// control entirely (returning null) and still have it appear in the summary.\nexport function itemSummaryFor({\n item,\n index,\n spec,\n itemSchema,\n}: {\n item: unknown;\n index: number;\n spec: ArrayItemSpec;\n itemSchema: JsonSchemaProperty | undefined;\n}): ArrayItemSummary {\n const obj = isPlainObject(item) ? item : {};\n // Resolved against this item's own value, as the item's body is rendered,\n // so a property a matching `then`/`else` branch declares labels its chip.\n const props = itemProperties(itemSchema, obj);\n\n const title =\n firstNonEmpty(\n (spec.title ?? DEFAULT_TITLE_KEYS).map((key) => {\n const value = text(obj[key]);\n return value && enumLabel(props[key], value);\n }),\n ) ??\n spec.fallback ??\n `Item ${index + 1}`;\n\n const summary = (spec.summary ?? [])\n .map((part) => summaryPart(obj, part))\n .filter((s): s is string => !!s)\n .join(SUMMARY_SEPARATOR);\n\n const badges = (spec.badges ?? [])\n .map((part) => summaryPart(obj, part))\n .filter((s): s is string => !!s);\n\n const glyphValue = spec.glyph ? text(obj[spec.glyph]) : \"\";\n const glyphProp = spec.glyph ? props[spec.glyph] : undefined;\n const badgeValue = spec.badge ? text(obj[spec.badge]) : \"\";\n const badgeProp = spec.badge ? props[spec.badge] : undefined;\n const badgeIcon = badgeProp?.[\"x-enum-icons\"]?.[badgeValue];\n\n return {\n title,\n ...(summary ? { summary } : {}),\n ...(spec.glyph\n ? {\n glyph: {\n ...(glyphProp?.[\"x-enum-icons\"]?.[glyphValue]\n ? { icon: glyphProp[\"x-enum-icons\"][glyphValue] }\n : {}),\n tone: normalizeTone(glyphProp?.[\"x-enum-tones\"]?.[glyphValue]),\n ...(glyphValue ? { label: enumLabel(glyphProp, glyphValue) } : {}),\n },\n }\n : {}),\n ...(badgeValue\n ? {\n badge: {\n ...(badgeIcon ? { icon: badgeIcon } : {}),\n label: enumLabel(badgeProp, badgeValue),\n },\n }\n : {}),\n ...(badges.length > 0 ? { badges } : {}),\n ...(spec.flag && obj[spec.flag] === true ? { flagged: true } : {}),\n };\n}\n\n// The add row's button text — \"Add parameter\" when the schema names its noun,\n// and the historical \"Add item\" when it does not.\nexport function addItemLabel(spec: ArrayItemSpec): string {\n return `Add ${spec.noun ?? \"item\"}`;\n}\n\nexport function itemCountLabel(spec: ArrayItemSpec, count: number): string {\n return count === 1\n ? `1 ${spec.noun ?? \"item\"}`\n : `${count} ${spec.nounPlural ?? \"items\"}`;\n}\n\n// The line above a list: \"No items yet\" when it is empty, else the count, which\n// `x-item.count: false` drops for a list whose rows say enough.\nexport function itemCountLine(spec: ArrayItemSpec, count: number): string | undefined {\n if (count === 0) return noItemsLabel(spec);\n return spec.count === false ? undefined : itemCountLabel(spec, count);\n}\n\n// The zero-item explanation. Falls back to the array's own description, so a\n// schema that already documents the field gets the empty state for free.\nexport function emptyItemsCopy(\n spec: ArrayItemSpec,\n arraySchema: JsonSchemaProperty,\n): string | undefined {\n if (spec.empty) return spec.empty;\n const description = typeof arraySchema.description === \"string\" ? arraySchema.description.trim() : \"\";\n return description || undefined;\n}\n\nexport function noItemsLabel(spec: ArrayItemSpec): string {\n return `No ${spec.nounPlural ?? \"items\"} yet`;\n}\n\n// summaryPart renders one part, substituting the value into a single literal\n// `{}` in the pattern. A pattern without `{}` renders as-is (it is a literal),\n// and a missing value drops the part rather than leaving a dangling separator.\nfunction summaryPart(\n obj: Record<string, unknown>,\n part: string | ArrayItemSummaryPart,\n): string | undefined {\n const { property, pattern } = typeof part === \"string\" ? { property: part, pattern: undefined } : part;\n const value = text(obj[property]);\n if (!value) return undefined;\n return pattern ? pattern.replace(\"{}\", value) : value;\n}\n\n// enumLabel prefers the human label the schema declares for a code, falling back\n// to the code itself. Unlike the combobox option list this does NOT render\n// \"Label (code)\" — a chip has room for one of the two, and the label is the one\n// worth reading.\nfunction enumLabel(prop: JsonSchemaProperty | undefined, value: string): string {\n const label = prop?.[\"x-enum-labels\"]?.[value];\n return typeof label === \"string\" && label ? label : value;\n}\n\n// text flattens a value to its display string. Arrays join, so a list-valued\n// property still reads as one line.\nfunction text(value: unknown): string {\n if (value === undefined || value === null) return \"\";\n if (Array.isArray(value)) return value.map(text).filter(Boolean).join(VALUE_SEPARATOR);\n if (typeof value === \"object\") return \"\";\n return String(value).trim();\n}\n\nfunction stringArray(value: unknown): string[] {\n if (typeof value === \"string\") return [value];\n if (!Array.isArray(value)) return [];\n return value.filter((v): v is string => typeof v === \"string\" && !!v);\n}\n\nfunction summaryParts(value: unknown): Array<string | ArrayItemSummaryPart> {\n if (!Array.isArray(value)) return [];\n return (value as unknown[]).flatMap((part): Array<string | ArrayItemSummaryPart> => {\n if (typeof part === \"string\" && part) return [part];\n if (isPlainObject(part) && typeof part.property === \"string\" && part.property) {\n return [\n {\n property: part.property,\n ...(typeof part.pattern === \"string\" && part.pattern ? { pattern: part.pattern } : {}),\n } satisfies ArrayItemSummaryPart,\n ];\n }\n return [];\n });\n}\n\nfunction firstNonEmpty(values: Array<string | undefined>): string | undefined {\n for (const value of values) {\n const trimmed = typeof value === \"string\" ? value.trim() : \"\";\n if (trimmed) return trimmed;\n }\n return undefined;\n}\n"],"mappings":";;;;AAcA,IAAM,qBAAqB;CAAC;CAAS;CAAQ;CAAS;CAAM;AAAK;AAEjE,IAAM,oBAAoB;AAC1B,IAAM,kBAAkB;AAMxB,SAAgB,gBACd,aACA,YACe;CACf,MAAM,MAAMA,oBAAAA,cAAc,YAAY,SAAS,IAC1C,YAAY,YACb,CAAC;CACL,MAAM,QAAQ,YAAY,IAAI,KAAK;CACnC,MAAM,UAAU,aAAa,IAAI,OAAO;CACxC,MAAM,SAAS,aAAa,IAAI,MAAM;CACtC,MAAM,QAAQ,OAAO,IAAI,UAAU,WAAW,IAAI,QAAQ,aAAa,UAAU;CACjF,OAAO;EACL,OAAO,MAAM,SAAS,IAAI,QAAQ;EAClC,GAAI,OAAO,IAAI,aAAa,YAAY,IAAI,WAAW,EAAE,UAAU,IAAI,SAAS,IAAI,CAAC;EACrF,GAAI,QAAQ,SAAS,IAAI,EAAE,QAAQ,IAAI,CAAC;EACxC,GAAI,QAAQ,EAAE,MAAM,IAAI,CAAC;EACzB,GAAI,OAAO,IAAI,UAAU,YAAY,IAAI,QAAQ,EAAE,OAAO,IAAI,MAAM,IAAI,CAAC;EACzE,GAAI,OAAO,SAAS,IAAI,EAAE,OAAO,IAAI,CAAC;EACtC,GAAI,IAAI,UAAU,QAAQ,EAAE,OAAO,MAAM,IAAI,CAAC;EAC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,UAAU,OAAO,CAAC,KAAK;CAC5C,IAAI,CAAC,MAAM,QAAQ,KAAK,GAAG,OAAO,CAAC;CACnC,OAAO,MAAM,QAAQ,MAAmB,OAAO,MAAM,YAAY,CAAC,CAAC,CAAC;AACtE;AAEA,SAAS,aAAa,OAAsD;CAC1E,IAAI,CAAC,MAAM,QAAQ,KAAK,GAAG,OAAO,CAAC;CACnC,OAAQ,MAAoB,SAAS,SAA+C;EAClF,IAAI,OAAO,SAAS,YAAY,MAAM,OAAO,CAAC,IAAI;EAClD,IAAIF,oBAAAA,cAAc,IAAI,KAAK,OAAO,KAAK,aAAa,YAAY,KAAK,UACnE,OAAO,CACL;GACE,UAAU,KAAK;GACf,GAAI,OAAO,KAAK,YAAY,YAAY,KAAK,UAAU,EAAE,SAAS,KAAK,QAAQ,IAAI,CAAC;EACtF,CACF;EAEF,OAAO,CAAC;CACV,CAAC;AACH;AAEA,SAAS,cAAc,QAAuD;CAC5E,KAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,UAAU,OAAO,UAAU,WAAW,MAAM,KAAK,IAAI;EAC3D,IAAI,SAAS,OAAO;CACtB;AAEF"}
@@ -9,6 +9,7 @@ export declare function itemSummaryFor({ item, index, spec, itemSchema, }: {
9
9
  }): ArrayItemSummary;
10
10
  export declare function addItemLabel(spec: ArrayItemSpec): string;
11
11
  export declare function itemCountLabel(spec: ArrayItemSpec, count: number): string;
12
+ export declare function itemCountLine(spec: ArrayItemSpec, count: number): string | undefined;
12
13
  export declare function emptyItemsCopy(spec: ArrayItemSpec, arraySchema: JsonSchemaProperty): string | undefined;
13
14
  export declare function noItemsLabel(spec: ArrayItemSpec): string;
14
15
  //# sourceMappingURL=json-schema-form-item-summary.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"json-schema-form-item-summary.d.ts","sourceRoot":"","sources":["../../src/components/json-schema-form-item-summary.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,eAAe,EACf,aAAa,EACb,gBAAgB,EAGhB,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AAalC,wBAAgB,eAAe,CAC7B,WAAW,EAAE,kBAAkB,EAC/B,UAAU,EAAE,kBAAkB,GAAG,SAAS,GACzC,aAAa,CAsBf;AAYD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAEtF;AA4BD,wBAAgB,cAAc,CAAC,EAC7B,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,UAAU,GACX,EAAE;IACD,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,aAAa,CAAC;IACpB,UAAU,EAAE,kBAAkB,GAAG,SAAS,CAAC;CAC5C,GAAG,gBAAgB,CAmDnB;AAID,wBAAgB,YAAY,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAExD;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAIzE;AAID,wBAAgB,cAAc,CAC5B,IAAI,EAAE,aAAa,EACnB,WAAW,EAAE,kBAAkB,GAC9B,MAAM,GAAG,SAAS,CAIpB;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAExD"}
1
+ {"version":3,"file":"json-schema-form-item-summary.d.ts","sourceRoot":"","sources":["../../src/components/json-schema-form-item-summary.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,eAAe,EACf,aAAa,EACb,gBAAgB,EAGhB,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AAalC,wBAAgB,eAAe,CAC7B,WAAW,EAAE,kBAAkB,EAC/B,UAAU,EAAE,kBAAkB,GAAG,SAAS,GACzC,aAAa,CAyBf;AAYD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAEtF;AA4BD,wBAAgB,cAAc,CAAC,EAC7B,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,UAAU,GACX,EAAE;IACD,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,aAAa,CAAC;IACpB,UAAU,EAAE,kBAAkB,GAAG,SAAS,CAAC;CAC5C,GAAG,gBAAgB,CAwDnB;AAID,wBAAgB,YAAY,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAExD;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAIzE;AAID,wBAAgB,aAAa,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAGpF;AAID,wBAAgB,cAAc,CAC5B,IAAI,EAAE,aAAa,EACnB,WAAW,EAAE,kBAAkB,GAC9B,MAAM,GAAG,SAAS,CAIpB;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAExD"}
@@ -15,6 +15,7 @@ function resolveItemSpec(arraySchema, itemSchema) {
15
15
  const raw = isPlainObject(arraySchema["x-item"]) ? arraySchema["x-item"] : {};
16
16
  const title = stringArray(raw.title);
17
17
  const summary = summaryParts(raw.summary);
18
+ const badges = summaryParts(raw.badges);
18
19
  const glyph = typeof raw.glyph === "string" ? raw.glyph : autoGlyphKey(itemSchema);
19
20
  return {
20
21
  title: title.length > 0 ? title : DEFAULT_TITLE_KEYS,
@@ -22,6 +23,8 @@ function resolveItemSpec(arraySchema, itemSchema) {
22
23
  ...summary.length > 0 ? { summary } : {},
23
24
  ...glyph ? { glyph } : {},
24
25
  ...typeof raw.badge === "string" && raw.badge ? { badge: raw.badge } : {},
26
+ ...badges.length > 0 ? { badges } : {},
27
+ ...raw.count === false ? { count: false } : {},
25
28
  ...typeof raw.flag === "string" && raw.flag ? { flag: raw.flag } : {},
26
29
  ...Array.isArray(raw.actions) ? { actions: itemActions(raw.actions) } : {},
27
30
  noun: firstNonEmpty([raw.noun, itemSchema?.title]) ?? "item",
@@ -57,6 +60,7 @@ function itemSummaryFor({ item, index, spec, itemSchema }) {
57
60
  return value && enumLabel(props[key], value);
58
61
  })) ?? spec.fallback ?? `Item ${index + 1}`;
59
62
  const summary = (spec.summary ?? []).map((part) => summaryPart(obj, part)).filter((s) => !!s).join(SUMMARY_SEPARATOR);
63
+ const badges = (spec.badges ?? []).map((part) => summaryPart(obj, part)).filter((s) => !!s);
60
64
  const glyphValue = spec.glyph ? text(obj[spec.glyph]) : "";
61
65
  const glyphProp = spec.glyph ? props[spec.glyph] : void 0;
62
66
  const badgeValue = spec.badge ? text(obj[spec.badge]) : "";
@@ -74,6 +78,7 @@ function itemSummaryFor({ item, index, spec, itemSchema }) {
74
78
  ...badgeIcon ? { icon: badgeIcon } : {},
75
79
  label: enumLabel(badgeProp, badgeValue)
76
80
  } } : {},
81
+ ...badges.length > 0 ? { badges } : {},
77
82
  ...spec.flag && obj[spec.flag] === true ? { flagged: true } : {}
78
83
  };
79
84
  }
@@ -83,6 +88,10 @@ function addItemLabel(spec) {
83
88
  function itemCountLabel(spec, count) {
84
89
  return count === 1 ? `1 ${spec.noun ?? "item"}` : `${count} ${spec.nounPlural ?? "items"}`;
85
90
  }
91
+ function itemCountLine(spec, count) {
92
+ if (count === 0) return noItemsLabel(spec);
93
+ return spec.count === false ? void 0 : itemCountLabel(spec, count);
94
+ }
86
95
  function emptyItemsCopy(spec, arraySchema) {
87
96
  if (spec.empty) return spec.empty;
88
97
  return (typeof arraySchema.description === "string" ? arraySchema.description.trim() : "") || void 0;
@@ -131,6 +140,6 @@ function firstNonEmpty(values) {
131
140
  if (trimmed) return trimmed;
132
141
  }
133
142
  }
134
- export { addItemLabel, emptyItemsCopy, itemActionsAllow, itemCountLabel, itemSummaryFor, noItemsLabel, resolveItemSpec };
143
+ export { addItemLabel, emptyItemsCopy, itemActionsAllow, itemCountLabel, itemCountLine, itemSummaryFor, noItemsLabel, resolveItemSpec };
135
144
 
136
145
  //# sourceMappingURL=json-schema-form-item-summary.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"json-schema-form-item-summary.js","names":[],"sources":["../../src/components/json-schema-form-item-summary.ts"],"sourcesContent":["import { isPlainObject } from \"../lib/collections\";\nimport { effectiveProperties } from \"./json-schema-form-conditionals\";\nimport { normalizeTone } from \"./json-schema-form-tone\";\nimport type {\n ArrayItemAction,\n ArrayItemSpec,\n ArrayItemSummary,\n ArrayItemSummaryPart,\n JsonSchemaObject,\n JsonSchemaProperty,\n} from \"./json-schema-form-types\";\n\n// Property names worth trying for a row title when the schema does not say.\n// Ordered most-human-readable first.\nconst DEFAULT_TITLE_KEYS = [\"title\", \"name\", \"label\", \"id\", \"key\"];\n\nconst SUMMARY_SEPARATOR = \" · \";\nconst VALUE_SEPARATOR = \", \";\n\n// resolveItemSpec reads the array's `x-item` and fills in every default, so the\n// renderer never has to ask whether a key was supplied. With no `x-item` at all\n// the result reproduces today's behaviour exactly: an `Item <n>` title and an\n// \"Add item\" button.\nexport function resolveItemSpec(\n arraySchema: JsonSchemaProperty,\n itemSchema: JsonSchemaProperty | undefined,\n): ArrayItemSpec {\n const raw = isPlainObject(arraySchema[\"x-item\"])\n ? (arraySchema[\"x-item\"] as ArrayItemSpec)\n : {};\n const title = stringArray(raw.title);\n const summary = summaryParts(raw.summary);\n const glyph = typeof raw.glyph === \"string\" ? raw.glyph : autoGlyphKey(itemSchema);\n return {\n title: title.length > 0 ? title : DEFAULT_TITLE_KEYS,\n ...(typeof raw.fallback === \"string\" && raw.fallback ? { fallback: raw.fallback } : {}),\n ...(summary.length > 0 ? { summary } : {}),\n ...(glyph ? { glyph } : {}),\n ...(typeof raw.badge === \"string\" && raw.badge ? { badge: raw.badge } : {}),\n ...(typeof raw.flag === \"string\" && raw.flag ? { flag: raw.flag } : {}),\n // Only carried when the schema actually said something: an absent key means\n // every action, while an explicit empty list means none, and those two\n // cannot be told apart once the default has been filled in.\n ...(Array.isArray(raw.actions) ? { actions: itemActions(raw.actions) } : {}),\n noun: firstNonEmpty([raw.noun, itemSchema?.title]) ?? \"item\",\n nounPlural: firstNonEmpty([raw.nounPlural, arraySchema.title]) ?? \"items\",\n ...(typeof raw.empty === \"string\" && raw.empty ? { empty: raw.empty } : {}),\n };\n}\n\nconst ITEM_ACTIONS: ArrayItemAction[] = [\"reorder\", \"duplicate\", \"remove\"];\n\nfunction itemActions(value: unknown[]): ArrayItemAction[] {\n return value.filter((entry): entry is ArrayItemAction =>\n ITEM_ACTIONS.includes(entry as ArrayItemAction),\n );\n}\n\n// itemActionsAllow is the one question every array display asks of `x-item`, so\n// the accordion and the cards never disagree about what a schema permitted.\nexport function itemActionsAllow(spec: ArrayItemSpec, action: ArrayItemAction): boolean {\n return spec.actions ? spec.actions.includes(action) : true;\n}\n\n// itemProperties is the item schema's effective properties — `allOf` members\n// included, so items composed of flattened `$ref`s summarize like any other —\n// resolved against `value`.\nfunction itemProperties(\n itemSchema: JsonSchemaProperty | undefined,\n value: Record<string, unknown>,\n): Record<string, JsonSchemaProperty> {\n return itemSchema ? effectiveProperties(itemSchema as JsonSchemaObject, value).properties : {};\n}\n\n// autoGlyphKey picks the item property that can colour a row without being told:\n// the first enum carrying per-value icons. Keeps a schema that already declares\n// x-enum-icons from having to repeat itself in x-item. The spec is one per\n// array, so there is no item value to select a conditional branch: only base\n// and unconditional properties (and `else` branches, which `{}` selects) count.\nfunction autoGlyphKey(itemSchema: JsonSchemaProperty | undefined): string | undefined {\n for (const [key, prop] of Object.entries(itemProperties(itemSchema, {}))) {\n const icons = prop[\"x-enum-icons\"];\n if (Array.isArray(prop.enum) && icons && Object.keys(icons).length > 0) return key;\n }\n return undefined;\n}\n\n// itemSummaryFor derives one collapsed row from the item's raw VALUE — never\n// from its rendered fields. A consumer pre-extension may hide a property's\n// control entirely (returning null) and still have it appear in the summary.\nexport function itemSummaryFor({\n item,\n index,\n spec,\n itemSchema,\n}: {\n item: unknown;\n index: number;\n spec: ArrayItemSpec;\n itemSchema: JsonSchemaProperty | undefined;\n}): ArrayItemSummary {\n const obj = isPlainObject(item) ? item : {};\n // Resolved against this item's own value, as the item's body is rendered,\n // so a property a matching `then`/`else` branch declares labels its chip.\n const props = itemProperties(itemSchema, obj);\n\n const title =\n firstNonEmpty(\n (spec.title ?? DEFAULT_TITLE_KEYS).map((key) => {\n const value = text(obj[key]);\n return value && enumLabel(props[key], value);\n }),\n ) ??\n spec.fallback ??\n `Item ${index + 1}`;\n\n const summary = (spec.summary ?? [])\n .map((part) => summaryPart(obj, part))\n .filter((s): s is string => !!s)\n .join(SUMMARY_SEPARATOR);\n\n const glyphValue = spec.glyph ? text(obj[spec.glyph]) : \"\";\n const glyphProp = spec.glyph ? props[spec.glyph] : undefined;\n const badgeValue = spec.badge ? text(obj[spec.badge]) : \"\";\n const badgeProp = spec.badge ? props[spec.badge] : undefined;\n const badgeIcon = badgeProp?.[\"x-enum-icons\"]?.[badgeValue];\n\n return {\n title,\n ...(summary ? { summary } : {}),\n ...(spec.glyph\n ? {\n glyph: {\n ...(glyphProp?.[\"x-enum-icons\"]?.[glyphValue]\n ? { icon: glyphProp[\"x-enum-icons\"][glyphValue] }\n : {}),\n tone: normalizeTone(glyphProp?.[\"x-enum-tones\"]?.[glyphValue]),\n ...(glyphValue ? { label: enumLabel(glyphProp, glyphValue) } : {}),\n },\n }\n : {}),\n ...(badgeValue\n ? {\n badge: {\n ...(badgeIcon ? { icon: badgeIcon } : {}),\n label: enumLabel(badgeProp, badgeValue),\n },\n }\n : {}),\n ...(spec.flag && obj[spec.flag] === true ? { flagged: true } : {}),\n };\n}\n\n// The add row's button text — \"Add parameter\" when the schema names its noun,\n// and the historical \"Add item\" when it does not.\nexport function addItemLabel(spec: ArrayItemSpec): string {\n return `Add ${spec.noun ?? \"item\"}`;\n}\n\nexport function itemCountLabel(spec: ArrayItemSpec, count: number): string {\n return count === 1\n ? `1 ${spec.noun ?? \"item\"}`\n : `${count} ${spec.nounPlural ?? \"items\"}`;\n}\n\n// The zero-item explanation. Falls back to the array's own description, so a\n// schema that already documents the field gets the empty state for free.\nexport function emptyItemsCopy(\n spec: ArrayItemSpec,\n arraySchema: JsonSchemaProperty,\n): string | undefined {\n if (spec.empty) return spec.empty;\n const description = typeof arraySchema.description === \"string\" ? arraySchema.description.trim() : \"\";\n return description || undefined;\n}\n\nexport function noItemsLabel(spec: ArrayItemSpec): string {\n return `No ${spec.nounPlural ?? \"items\"} yet`;\n}\n\n// summaryPart renders one part, substituting the value into a single literal\n// `{}` in the pattern. A pattern without `{}` renders as-is (it is a literal),\n// and a missing value drops the part rather than leaving a dangling separator.\nfunction summaryPart(\n obj: Record<string, unknown>,\n part: string | ArrayItemSummaryPart,\n): string | undefined {\n const { property, pattern } = typeof part === \"string\" ? { property: part, pattern: undefined } : part;\n const value = text(obj[property]);\n if (!value) return undefined;\n return pattern ? pattern.replace(\"{}\", value) : value;\n}\n\n// enumLabel prefers the human label the schema declares for a code, falling back\n// to the code itself. Unlike the combobox option list this does NOT render\n// \"Label (code)\" — a chip has room for one of the two, and the label is the one\n// worth reading.\nfunction enumLabel(prop: JsonSchemaProperty | undefined, value: string): string {\n const label = prop?.[\"x-enum-labels\"]?.[value];\n return typeof label === \"string\" && label ? label : value;\n}\n\n// text flattens a value to its display string. Arrays join, so a list-valued\n// property still reads as one line.\nfunction text(value: unknown): string {\n if (value === undefined || value === null) return \"\";\n if (Array.isArray(value)) return value.map(text).filter(Boolean).join(VALUE_SEPARATOR);\n if (typeof value === \"object\") return \"\";\n return String(value).trim();\n}\n\nfunction stringArray(value: unknown): string[] {\n if (typeof value === \"string\") return [value];\n if (!Array.isArray(value)) return [];\n return value.filter((v): v is string => typeof v === \"string\" && !!v);\n}\n\nfunction summaryParts(value: unknown): Array<string | ArrayItemSummaryPart> {\n if (!Array.isArray(value)) return [];\n return (value as unknown[]).flatMap((part): Array<string | ArrayItemSummaryPart> => {\n if (typeof part === \"string\" && part) return [part];\n if (isPlainObject(part) && typeof part.property === \"string\" && part.property) {\n return [\n {\n property: part.property,\n ...(typeof part.pattern === \"string\" && part.pattern ? { pattern: part.pattern } : {}),\n } satisfies ArrayItemSummaryPart,\n ];\n }\n return [];\n });\n}\n\nfunction firstNonEmpty(values: Array<string | undefined>): string | undefined {\n for (const value of values) {\n const trimmed = typeof value === \"string\" ? value.trim() : \"\";\n if (trimmed) return trimmed;\n }\n return undefined;\n}\n"],"mappings":";;;;AAcA,IAAM,qBAAqB;CAAC;CAAS;CAAQ;CAAS;CAAM;AAAK;AAEjE,IAAM,oBAAoB;AAC1B,IAAM,kBAAkB;AAMxB,SAAgB,gBACd,aACA,YACe;CACf,MAAM,MAAM,cAAc,YAAY,SAAS,IAC1C,YAAY,YACb,CAAC;CACL,MAAM,QAAQ,YAAY,IAAI,KAAK;CACnC,MAAM,UAAU,aAAa,IAAI,OAAO;CACxC,MAAM,QAAQ,OAAO,IAAI,UAAU,WAAW,IAAI,QAAQ,aAAa,UAAU;CACjF,OAAO;EACL,OAAO,MAAM,SAAS,IAAI,QAAQ;EAClC,GAAI,OAAO,IAAI,aAAa,YAAY,IAAI,WAAW,EAAE,UAAU,IAAI,SAAS,IAAI,CAAC;EACrF,GAAI,QAAQ,SAAS,IAAI,EAAE,QAAQ,IAAI,CAAC;EACxC,GAAI,QAAQ,EAAE,MAAM,IAAI,CAAC;EACzB,GAAI,OAAO,IAAI,UAAU,YAAY,IAAI,QAAQ,EAAE,OAAO,IAAI,MAAM,IAAI,CAAC;EACzE,GAAI,OAAO,IAAI,SAAS,YAAY,IAAI,OAAO,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;EAIrE,GAAI,MAAM,QAAQ,IAAI,OAAO,IAAI,EAAE,SAAS,YAAY,IAAI,OAAO,EAAE,IAAI,CAAC;EAC1E,MAAM,cAAc,CAAC,IAAI,MAAM,YAAY,KAAK,CAAC,KAAK;EACtD,YAAY,cAAc,CAAC,IAAI,YAAY,YAAY,KAAK,CAAC,KAAK;EAClE,GAAI,OAAO,IAAI,UAAU,YAAY,IAAI,QAAQ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}
1
+ {"version":3,"file":"json-schema-form-item-summary.js","names":[],"sources":["../../src/components/json-schema-form-item-summary.ts"],"sourcesContent":["import { isPlainObject } from \"../lib/collections\";\nimport { effectiveProperties } from \"./json-schema-form-conditionals\";\nimport { normalizeTone } from \"./json-schema-form-tone\";\nimport type {\n ArrayItemAction,\n ArrayItemSpec,\n ArrayItemSummary,\n ArrayItemSummaryPart,\n JsonSchemaObject,\n JsonSchemaProperty,\n} from \"./json-schema-form-types\";\n\n// Property names worth trying for a row title when the schema does not say.\n// Ordered most-human-readable first.\nconst DEFAULT_TITLE_KEYS = [\"title\", \"name\", \"label\", \"id\", \"key\"];\n\nconst SUMMARY_SEPARATOR = \" · \";\nconst VALUE_SEPARATOR = \", \";\n\n// resolveItemSpec reads the array's `x-item` and fills in every default, so the\n// renderer never has to ask whether a key was supplied. With no `x-item` at all\n// the result reproduces today's behaviour exactly: an `Item <n>` title and an\n// \"Add item\" button.\nexport function resolveItemSpec(\n arraySchema: JsonSchemaProperty,\n itemSchema: JsonSchemaProperty | undefined,\n): ArrayItemSpec {\n const raw = isPlainObject(arraySchema[\"x-item\"])\n ? (arraySchema[\"x-item\"] as ArrayItemSpec)\n : {};\n const title = stringArray(raw.title);\n const summary = summaryParts(raw.summary);\n const badges = summaryParts(raw.badges);\n const glyph = typeof raw.glyph === \"string\" ? raw.glyph : autoGlyphKey(itemSchema);\n return {\n title: title.length > 0 ? title : DEFAULT_TITLE_KEYS,\n ...(typeof raw.fallback === \"string\" && raw.fallback ? { fallback: raw.fallback } : {}),\n ...(summary.length > 0 ? { summary } : {}),\n ...(glyph ? { glyph } : {}),\n ...(typeof raw.badge === \"string\" && raw.badge ? { badge: raw.badge } : {}),\n ...(badges.length > 0 ? { badges } : {}),\n ...(raw.count === false ? { count: false } : {}),\n ...(typeof raw.flag === \"string\" && raw.flag ? { flag: raw.flag } : {}),\n // Only carried when the schema actually said something: an absent key means\n // every action, while an explicit empty list means none, and those two\n // cannot be told apart once the default has been filled in.\n ...(Array.isArray(raw.actions) ? { actions: itemActions(raw.actions) } : {}),\n noun: firstNonEmpty([raw.noun, itemSchema?.title]) ?? \"item\",\n nounPlural: firstNonEmpty([raw.nounPlural, arraySchema.title]) ?? \"items\",\n ...(typeof raw.empty === \"string\" && raw.empty ? { empty: raw.empty } : {}),\n };\n}\n\nconst ITEM_ACTIONS: ArrayItemAction[] = [\"reorder\", \"duplicate\", \"remove\"];\n\nfunction itemActions(value: unknown[]): ArrayItemAction[] {\n return value.filter((entry): entry is ArrayItemAction =>\n ITEM_ACTIONS.includes(entry as ArrayItemAction),\n );\n}\n\n// itemActionsAllow is the one question every array display asks of `x-item`, so\n// the accordion and the cards never disagree about what a schema permitted.\nexport function itemActionsAllow(spec: ArrayItemSpec, action: ArrayItemAction): boolean {\n return spec.actions ? spec.actions.includes(action) : true;\n}\n\n// itemProperties is the item schema's effective properties — `allOf` members\n// included, so items composed of flattened `$ref`s summarize like any other —\n// resolved against `value`.\nfunction itemProperties(\n itemSchema: JsonSchemaProperty | undefined,\n value: Record<string, unknown>,\n): Record<string, JsonSchemaProperty> {\n return itemSchema ? effectiveProperties(itemSchema as JsonSchemaObject, value).properties : {};\n}\n\n// autoGlyphKey picks the item property that can colour a row without being told:\n// the first enum carrying per-value icons. Keeps a schema that already declares\n// x-enum-icons from having to repeat itself in x-item. The spec is one per\n// array, so there is no item value to select a conditional branch: only base\n// and unconditional properties (and `else` branches, which `{}` selects) count.\nfunction autoGlyphKey(itemSchema: JsonSchemaProperty | undefined): string | undefined {\n for (const [key, prop] of Object.entries(itemProperties(itemSchema, {}))) {\n const icons = prop[\"x-enum-icons\"];\n if (Array.isArray(prop.enum) && icons && Object.keys(icons).length > 0) return key;\n }\n return undefined;\n}\n\n// itemSummaryFor derives one collapsed row from the item's raw VALUE — never\n// from its rendered fields. A consumer pre-extension may hide a property's\n// control entirely (returning null) and still have it appear in the summary.\nexport function itemSummaryFor({\n item,\n index,\n spec,\n itemSchema,\n}: {\n item: unknown;\n index: number;\n spec: ArrayItemSpec;\n itemSchema: JsonSchemaProperty | undefined;\n}): ArrayItemSummary {\n const obj = isPlainObject(item) ? item : {};\n // Resolved against this item's own value, as the item's body is rendered,\n // so a property a matching `then`/`else` branch declares labels its chip.\n const props = itemProperties(itemSchema, obj);\n\n const title =\n firstNonEmpty(\n (spec.title ?? DEFAULT_TITLE_KEYS).map((key) => {\n const value = text(obj[key]);\n return value && enumLabel(props[key], value);\n }),\n ) ??\n spec.fallback ??\n `Item ${index + 1}`;\n\n const summary = (spec.summary ?? [])\n .map((part) => summaryPart(obj, part))\n .filter((s): s is string => !!s)\n .join(SUMMARY_SEPARATOR);\n\n const badges = (spec.badges ?? [])\n .map((part) => summaryPart(obj, part))\n .filter((s): s is string => !!s);\n\n const glyphValue = spec.glyph ? text(obj[spec.glyph]) : \"\";\n const glyphProp = spec.glyph ? props[spec.glyph] : undefined;\n const badgeValue = spec.badge ? text(obj[spec.badge]) : \"\";\n const badgeProp = spec.badge ? props[spec.badge] : undefined;\n const badgeIcon = badgeProp?.[\"x-enum-icons\"]?.[badgeValue];\n\n return {\n title,\n ...(summary ? { summary } : {}),\n ...(spec.glyph\n ? {\n glyph: {\n ...(glyphProp?.[\"x-enum-icons\"]?.[glyphValue]\n ? { icon: glyphProp[\"x-enum-icons\"][glyphValue] }\n : {}),\n tone: normalizeTone(glyphProp?.[\"x-enum-tones\"]?.[glyphValue]),\n ...(glyphValue ? { label: enumLabel(glyphProp, glyphValue) } : {}),\n },\n }\n : {}),\n ...(badgeValue\n ? {\n badge: {\n ...(badgeIcon ? { icon: badgeIcon } : {}),\n label: enumLabel(badgeProp, badgeValue),\n },\n }\n : {}),\n ...(badges.length > 0 ? { badges } : {}),\n ...(spec.flag && obj[spec.flag] === true ? { flagged: true } : {}),\n };\n}\n\n// The add row's button text — \"Add parameter\" when the schema names its noun,\n// and the historical \"Add item\" when it does not.\nexport function addItemLabel(spec: ArrayItemSpec): string {\n return `Add ${spec.noun ?? \"item\"}`;\n}\n\nexport function itemCountLabel(spec: ArrayItemSpec, count: number): string {\n return count === 1\n ? `1 ${spec.noun ?? \"item\"}`\n : `${count} ${spec.nounPlural ?? \"items\"}`;\n}\n\n// The line above a list: \"No items yet\" when it is empty, else the count, which\n// `x-item.count: false` drops for a list whose rows say enough.\nexport function itemCountLine(spec: ArrayItemSpec, count: number): string | undefined {\n if (count === 0) return noItemsLabel(spec);\n return spec.count === false ? undefined : itemCountLabel(spec, count);\n}\n\n// The zero-item explanation. Falls back to the array's own description, so a\n// schema that already documents the field gets the empty state for free.\nexport function emptyItemsCopy(\n spec: ArrayItemSpec,\n arraySchema: JsonSchemaProperty,\n): string | undefined {\n if (spec.empty) return spec.empty;\n const description = typeof arraySchema.description === \"string\" ? arraySchema.description.trim() : \"\";\n return description || undefined;\n}\n\nexport function noItemsLabel(spec: ArrayItemSpec): string {\n return `No ${spec.nounPlural ?? \"items\"} yet`;\n}\n\n// summaryPart renders one part, substituting the value into a single literal\n// `{}` in the pattern. A pattern without `{}` renders as-is (it is a literal),\n// and a missing value drops the part rather than leaving a dangling separator.\nfunction summaryPart(\n obj: Record<string, unknown>,\n part: string | ArrayItemSummaryPart,\n): string | undefined {\n const { property, pattern } = typeof part === \"string\" ? { property: part, pattern: undefined } : part;\n const value = text(obj[property]);\n if (!value) return undefined;\n return pattern ? pattern.replace(\"{}\", value) : value;\n}\n\n// enumLabel prefers the human label the schema declares for a code, falling back\n// to the code itself. Unlike the combobox option list this does NOT render\n// \"Label (code)\" — a chip has room for one of the two, and the label is the one\n// worth reading.\nfunction enumLabel(prop: JsonSchemaProperty | undefined, value: string): string {\n const label = prop?.[\"x-enum-labels\"]?.[value];\n return typeof label === \"string\" && label ? label : value;\n}\n\n// text flattens a value to its display string. Arrays join, so a list-valued\n// property still reads as one line.\nfunction text(value: unknown): string {\n if (value === undefined || value === null) return \"\";\n if (Array.isArray(value)) return value.map(text).filter(Boolean).join(VALUE_SEPARATOR);\n if (typeof value === \"object\") return \"\";\n return String(value).trim();\n}\n\nfunction stringArray(value: unknown): string[] {\n if (typeof value === \"string\") return [value];\n if (!Array.isArray(value)) return [];\n return value.filter((v): v is string => typeof v === \"string\" && !!v);\n}\n\nfunction summaryParts(value: unknown): Array<string | ArrayItemSummaryPart> {\n if (!Array.isArray(value)) return [];\n return (value as unknown[]).flatMap((part): Array<string | ArrayItemSummaryPart> => {\n if (typeof part === \"string\" && part) return [part];\n if (isPlainObject(part) && typeof part.property === \"string\" && part.property) {\n return [\n {\n property: part.property,\n ...(typeof part.pattern === \"string\" && part.pattern ? { pattern: part.pattern } : {}),\n } satisfies ArrayItemSummaryPart,\n ];\n }\n return [];\n });\n}\n\nfunction firstNonEmpty(values: Array<string | undefined>): string | undefined {\n for (const value of values) {\n const trimmed = typeof value === \"string\" ? value.trim() : \"\";\n if (trimmed) return trimmed;\n }\n return undefined;\n}\n"],"mappings":";;;;AAcA,IAAM,qBAAqB;CAAC;CAAS;CAAQ;CAAS;CAAM;AAAK;AAEjE,IAAM,oBAAoB;AAC1B,IAAM,kBAAkB;AAMxB,SAAgB,gBACd,aACA,YACe;CACf,MAAM,MAAM,cAAc,YAAY,SAAS,IAC1C,YAAY,YACb,CAAC;CACL,MAAM,QAAQ,YAAY,IAAI,KAAK;CACnC,MAAM,UAAU,aAAa,IAAI,OAAO;CACxC,MAAM,SAAS,aAAa,IAAI,MAAM;CACtC,MAAM,QAAQ,OAAO,IAAI,UAAU,WAAW,IAAI,QAAQ,aAAa,UAAU;CACjF,OAAO;EACL,OAAO,MAAM,SAAS,IAAI,QAAQ;EAClC,GAAI,OAAO,IAAI,aAAa,YAAY,IAAI,WAAW,EAAE,UAAU,IAAI,SAAS,IAAI,CAAC;EACrF,GAAI,QAAQ,SAAS,IAAI,EAAE,QAAQ,IAAI,CAAC;EACxC,GAAI,QAAQ,EAAE,MAAM,IAAI,CAAC;EACzB,GAAI,OAAO,IAAI,UAAU,YAAY,IAAI,QAAQ,EAAE,OAAO,IAAI,MAAM,IAAI,CAAC;EACzE,GA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O,KAAK,CAAC,CAAC,KAAK;AAC5B;AAEA,SAAS,YAAY,OAA0B;CAC7C,IAAI,OAAO,UAAU,UAAU,OAAO,CAAC,KAAK;CAC5C,IAAI,CAAC,MAAM,QAAQ,KAAK,GAAG,OAAO,CAAC;CACnC,OAAO,MAAM,QAAQ,MAAmB,OAAO,MAAM,YAAY,CAAC,CAAC,CAAC;AACtE;AAEA,SAAS,aAAa,OAAsD;CAC1E,IAAI,CAAC,MAAM,QAAQ,KAAK,GAAG,OAAO,CAAC;CACnC,OAAQ,MAAoB,SAAS,SAA+C;EAClF,IAAI,OAAO,SAAS,YAAY,MAAM,OAAO,CAAC,IAAI;EAClD,IAAI,cAAc,IAAI,KAAK,OAAO,KAAK,aAAa,YAAY,KAAK,UACnE,OAAO,CACL;GACE,UAAU,KAAK;GACf,GAAI,OAAO,KAAK,YAAY,YAAY,KAAK,UAAU,EAAE,SAAS,KAAK,QAAQ,IAAI,CAAC;EACtF,CACF;EAEF,OAAO,CAAC;CACV,CAAC;AACH;AAEA,SAAS,cAAc,QAAuD;CAC5E,KAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,UAAU,OAAO,UAAU,WAAW,MAAM,KAAK,IAAI;EAC3D,IAAI,SAAS,OAAO;CACtB;AAEF"}
@@ -285,11 +285,7 @@ function list(actions, name) {
285
285
  function declaredKeys(schema) {
286
286
  const keys = new Set(Object.keys(schema.properties ?? {}));
287
287
  for (const branch of require_json_schema_form_conditionals.declaredBranches(schema)) for (const key of Object.keys(branch.properties ?? {})) keys.add(key);
288
- for (const clause of schema.allOf ?? []) for (const branch of [
289
- clause,
290
- clause.then,
291
- clause.else
292
- ]) for (const key of Object.keys(branch?.properties ?? {})) keys.add(key);
288
+ for (const clause of schema.allOf ?? []) for (const branch of [clause, ...require_json_schema_form_conditionals.declaredBranches(clause)]) for (const key of Object.keys(branch?.properties ?? {})) keys.add(key);
293
289
  return keys;
294
290
  }
295
291
  exports.applyChangeEffects = applyChangeEffects;
@@ -1 +1 @@
1
- {"version":3,"file":"json-schema-form-listeners.cjs","names":["effectiveProperties","selectedBranches","matchesIf","cloneSchemaDefault","evaluatePredicate","isPlainObject","isPathTarget","targetSegments","declaredBranches"],"sources":["../../src/components/json-schema-form-listeners.ts"],"sourcesContent":["import { isPlainObject } from \"../lib/collections\";\nimport {\n declaredBranches,\n effectiveProperties,\n evaluatePredicate,\n matchesIf,\n selectedBranches,\n type EffectiveProperties,\n} from \"./json-schema-form-conditionals\";\nimport { cloneSchemaDefault } from \"./json-schema-form-defaults\";\nimport { isPathTarget, patchTarget, targetSegments } from \"./json-schema-form-listener-paths\";\nimport type {\n ChangeActions,\n ChangeListener,\n ExpressionEvaluator,\n JsonSchemaObject,\n JsonSchemaProperty,\n} from \"./json-schema-form-types\";\n\n// `x-on-change` listeners: a property names what happens to its siblings when\n// its value is, or becomes, something. `x-on-load` listeners: an object names\n// the state its properties start in. See ChangeActions for the split between\n// derived state actions and transitional value actions.\n\nexport interface ListenerOptions {\n root: Record<string, unknown>;\n evaluate?: ExpressionEvaluator;\n}\n\n// ListenerSource says where a listener came from. `label` prefixes every error\n// it raises; `key` is the property whose value `when` reads (and the\n// evaluator's `key`) — for x-on-load, \"\" and the object itself.\ninterface ListenerSource {\n label: string;\n key: string;\n load: boolean;\n}\n\ninterface BoundListener {\n listener: ChangeListener;\n source: ListenerSource;\n}\n\ntype ListName = \"hide\" | \"show\" | \"enable\" | \"disable\" | \"require\" | \"optional\" | \"reset\";\n\n// Actions that write values or required-ness: they act on sibling keys only\n// (never a path), and have no place in x-on-load, which only derives state.\nconst LOCAL_ACTIONS: (\"require\" | \"optional\" | \"reset\" | \"set\")[] = [\"require\", \"optional\", \"reset\", \"set\"];\n\nconst STATE_FLAGS: [ListName, \"x-hidden\" | \"x-disabled\", boolean][] = [\n [\"hide\", \"x-hidden\", true],\n [\"show\", \"x-hidden\", false],\n [\"disable\", \"x-disabled\", true],\n [\"enable\", \"x-disabled\", false],\n];\n\nconst CONTRADICTIONS: [ListName, ListName][] = [\n [\"hide\", \"show\"],\n [\"enable\", \"disable\"],\n [\"require\", \"optional\"],\n];\n\nconst LIST_NAMES: ListName[] = [\"hide\", \"show\", \"enable\", \"disable\", \"require\", \"optional\", \"reset\"];\n\n// Keywords a `patch` may not set, with the tool that does the job instead.\nconst PATCH_DENIED: Record<string, string> = {\n ...Object.fromEntries(\n [\"type\", \"properties\", \"items\", \"additionalProperties\", \"patternProperties\", \"allOf\", \"anyOf\", \"oneOf\", \"if\", \"then\", \"else\", \"not\", \"$ref\", \"$defs\"].map(\n (keyword) => [keyword, \"it changes the field's shape; use an allOf branch\"],\n ),\n ),\n required: \"use require/optional\",\n default: \"a patch changes presentation, not values; use set/reset\",\n const: \"a patch changes presentation, not values; use set/reset\",\n \"x-on-change\": \"listeners cannot be patched in\",\n \"x-on-load\": \"listeners cannot be patched in\",\n};\n\n// applyListenerState is effectiveProperties plus the state actions of every\n// listener, evaluated against the current value: first the object's\n// `x-on-load` listeners, then each property's `x-on-change` listeners — load,\n// then change, the order the events happen in. A listener is applied after\n// `allOf`, so it wins over a branch; later listeners win over earlier ones. A\n// target the current shape does not declare stays absent. Property schemas are\n// cloned, never mutated.\nexport function applyListenerState(\n schema: JsonSchemaObject,\n value: Record<string, unknown>,\n options: ListenerOptions,\n): EffectiveProperties {\n const { properties, required } = effectiveProperties(schema, value);\n const requiredSet = new Set(required);\n const known = declaredKeys(schema);\n const bound: BoundListener[] = [\n ...loadListenersOf(schema, value),\n ...Object.entries(properties).flatMap(([key, prop]) =>\n listenersOf(key, prop).map((listener) => ({ listener, source: changeSource(key) })),\n ),\n ];\n for (const { listener, source } of bound) {\n const actions = selectActions({ listener, source, self: value, known, options });\n for (const [name, keyword, flag] of STATE_FLAGS) {\n for (const target of list(actions, name)) {\n patchTarget({ properties, value, target, apply: (leaf) => hiddenBy({ ...leaf, [keyword]: flag }, keyword, flag, source.label) });\n }\n }\n for (const target of list(actions, \"require\")) {\n if (properties[target]) requiredSet.add(target);\n }\n for (const target of list(actions, \"optional\")) requiredSet.delete(target);\n for (const [target, keywords] of Object.entries(actions.patch ?? {})) {\n patchTarget({ properties, value, target, apply: (leaf) => ({ ...leaf, ...keywords }) });\n }\n }\n return { properties, required: [...requiredSet] };\n}\n\n// hiddenBy records which listener hid a field (`x-hidden-by`), so the form's\n// debug mode can say why it is missing; a show clears it.\nfunction hiddenBy(leaf: JsonSchemaProperty, keyword: string, flag: boolean, label: string): JsonSchemaProperty {\n if (keyword !== \"x-hidden\") return leaf;\n if (flag) return { ...leaf, \"x-hidden-by\": label };\n const { \"x-hidden-by\": _by, ...shown } = leaf;\n return shown;\n}\n\n// loadListenersOf collects an object's `x-on-load` listeners in order: the\n// schema's own, then each `allOf` member's — an unconditional member's own, or\n// those of the `then`/`else` branch that applies, selected exactly as\n// effectiveProperties selects the branch it merges.\nfunction loadListenersOf(schema: JsonSchemaObject, value: Record<string, unknown>): BoundListener[] {\n const bound = loadListenersAt(schema[\"x-on-load\"], \"#/x-on-load\");\n for (const { branch, pointer } of selectedBranches(schema, value)) {\n bound.push(...loadListenersAt(branch[\"x-on-load\"], `#${pointer}/x-on-load`));\n }\n for (const [index, clause] of (schema.allOf ?? []).entries()) {\n if (clause.if === undefined && clause.then === undefined) {\n bound.push(...loadListenersAt(clause[\"x-on-load\"], `#/allOf/${index}/x-on-load`));\n continue;\n }\n const branch = matchesIf(clause.if, value) ? \"then\" : \"else\";\n bound.push(...loadListenersAt(clause[branch]?.[\"x-on-load\"], `#/allOf/${index}/${branch}/x-on-load`));\n }\n return bound;\n}\n\nfunction loadListenersAt(listeners: unknown, pointer: string): BoundListener[] {\n if (listeners === undefined) return [];\n if (!Array.isArray(listeners)) {\n throw new Error(`x-on-load at ${pointer} must be an array of listeners, got ${typeof listeners}`);\n }\n return listeners.map((listener: ChangeListener, index) => ({\n listener,\n source: { label: `x-on-load at ${pointer}/${index}`, key: \"\", load: true },\n }));\n}\n\nfunction changeSource(key: string): ListenerSource {\n return { label: `x-on-change on \"${key}\"`, key, load: false };\n}\n\n// applyChangeEffects commits `next` at `key` and runs the value actions\n// (reset/set) of that key's listeners against the post-edit object. A target\n// whose value actually changes fires its own listeners in turn; each key fires\n// at most once per commit, so a cycle ends. When `root` is the edited object\n// itself (the top level), expressions see the post-edit value as root too.\nexport function applyChangeEffects(\n schema: JsonSchemaObject,\n edit: ListenerOptions & { value: Record<string, unknown>; key: string; next: unknown },\n): Record<string, unknown> {\n let current: Record<string, unknown> = { ...edit.value, [edit.key]: edit.next };\n const known = declaredKeys(schema);\n const fired = new Set<string>();\n const queue = [edit.key];\n for (let source = queue.shift(); source !== undefined; source = queue.shift()) {\n if (fired.has(source)) continue;\n fired.add(source);\n const { properties } = effectiveProperties(schema, current);\n const options: ListenerOptions = {\n root: edit.root === edit.value ? current : edit.root,\n ...(edit.evaluate ? { evaluate: edit.evaluate } : {}),\n };\n for (const listener of listenersOf(source, properties[source])) {\n const actions = selectActions({ listener, source: changeSource(source), self: current, known, options });\n for (const [target, nextValue] of valueChanges(actions, properties)) {\n if (Object.is(current[target], nextValue)) continue;\n current = { ...current };\n if (nextValue === undefined) delete current[target];\n else current[target] = nextValue;\n queue.push(target);\n }\n }\n }\n return current;\n}\n\nfunction valueChanges(\n actions: ChangeActions,\n properties: Record<string, JsonSchemaProperty>,\n): [string, unknown][] {\n return [\n ...list(actions, \"reset\").map((target): [string, unknown] => {\n const fallback = properties[target]?.default;\n return [target, fallback === undefined ? undefined : cloneSchemaDefault(fallback)];\n }),\n ...Object.entries(actions.set ?? {}).map(([target, v]): [string, unknown] => [target, cloneSchemaDefault(v)]),\n ];\n}\n\nfunction listenersOf(key: string, prop: JsonSchemaProperty | undefined): ChangeListener[] {\n const listeners = prop?.[\"x-on-change\"];\n if (listeners === undefined) return [];\n if (!Array.isArray(listeners)) {\n throw new Error(`\"${key}\": x-on-change must be an array of listeners, got ${typeof listeners}`);\n }\n return listeners;\n}\n\n// selectActions validates both branches of a listener (so a schema error\n// surfaces whichever branch is live) and returns the one that applies now.\nfunction selectActions({\n listener,\n source,\n self,\n known,\n options,\n}: {\n listener: ChangeListener;\n source: ListenerSource;\n self: Record<string, unknown>;\n known: Set<string>;\n options: ListenerOptions;\n}): ChangeActions {\n validateActions(source, listener, known);\n if (listener.else) validateActions(source, listener.else, known);\n return listenerHolds(listener, source, self, options) ? listener : (listener.else ?? {});\n}\n\n// listenerHolds evaluates `when` against the source's subject: the property's\n// value for x-on-change, the object itself for x-on-load.\nfunction listenerHolds(\n listener: ChangeListener,\n { label, key, load }: ListenerSource,\n self: Record<string, unknown>,\n options: ListenerOptions,\n): boolean {\n if (listener.when === undefined) return true;\n const { expr, ...predicate } = listener.when;\n const hasPredicate = Object.keys(predicate).length > 0;\n const subject = load ? self : self[key];\n if (!hasPredicate && expr === undefined) {\n throw new Error(`${label}: when states nothing it can evaluate`);\n }\n if (expr !== undefined && typeof expr !== \"string\") {\n throw new Error(`${label}: when.expr must be a string, got ${typeof expr}`);\n }\n if (expr !== undefined && !options.evaluate) {\n throw new Error(`${label}: when.expr \"${expr}\" needs the form's expressionEvaluator`);\n }\n if (hasPredicate) {\n const holds = evaluatePredicate(predicate, subject);\n if (holds === undefined) {\n throw new Error(`${label}: when states nothing it can evaluate (${JSON.stringify(predicate)})`);\n }\n if (!holds) return false;\n }\n if (expr === undefined || !options.evaluate) return true;\n const result: unknown = options.evaluate({ expr, key, value: subject, self, root: options.root });\n if (typeof result !== \"boolean\") {\n throw new Error(`${label}: expressionEvaluator returned ${typeof result} for \"${expr}\", expected boolean`);\n }\n return result;\n}\n\nfunction validateActions(source: ListenerSource, actions: ChangeActions, known: Set<string>): void {\n const { label } = source;\n if (actions.set !== undefined && !isPlainObject(actions.set)) {\n throw new Error(`${label}: set must be an object of target → value`);\n }\n if (source.load) {\n const local = LOCAL_ACTIONS.find((name) => actions[name] !== undefined);\n if (local) {\n throw new Error(`${label}: ${local} is not allowed in x-on-load, which only derives state (hide/show/enable/disable/patch)`);\n }\n }\n const setKeys = Object.keys(actions.set ?? {});\n for (const name of LOCAL_ACTIONS) {\n const targets = name === \"set\" ? setKeys : list(actions, name);\n const path = targets.find(isPathTarget);\n if (path !== undefined) {\n throw new Error(`${label}: ${name} \"${path}\" cannot take a path; value and required actions act on sibling keys only`);\n }\n }\n for (const target of [...LIST_NAMES.flatMap((name) => list(actions, name)), ...setKeys]) {\n validateTarget(label, target, known);\n }\n const pairs: [string, string[], string, string[]][] = [\n ...CONTRADICTIONS.map(([a, b]): [string, string[], string, string[]] => [a, list(actions, a), b, list(actions, b)]),\n [\"reset\", list(actions, \"reset\"), \"set\", setKeys],\n ];\n for (const [a, left, b, right] of pairs) {\n const clash = left.find((target) => right.includes(target));\n if (clash !== undefined) {\n throw new Error(`${label}: both ${a} and ${b} \"${clash}\"`);\n }\n }\n validatePatch(label, actions, known);\n}\n\n// validateTarget checks a target's grammar and that its first segment is a key\n// the schema declares in some branch.\nfunction validateTarget(label: string, target: string, known: Set<string>): void {\n if (isPathTarget(target) && known.has(target)) {\n throw new Error(`${label}: target \"${target}\" is both a declared key and a path`);\n }\n const [first = \"\"] = targetSegments(label, target);\n if (!known.has(first)) throw new Error(`${label}: unknown target \"${target}\"`);\n}\n\n// validatePatch checks a `patch`: an object of keyword objects on known\n// targets, no denied keyword, and no keyword a verb in the same actions sets.\nfunction validatePatch(label: string, actions: ChangeActions, known: Set<string>): void {\n const patch: unknown = actions.patch;\n if (patch === undefined) return;\n if (!isPlainObject(patch)) {\n throw new Error(`${label}: patch must be an object of target → keywords`);\n }\n for (const [target, keywords] of Object.entries(patch)) {\n validateTarget(label, target, known);\n if (!isPlainObject(keywords)) {\n throw new Error(`${label}: patch \"${target}\" must be an object of keywords`);\n }\n for (const keyword of Object.keys(keywords)) {\n const denied = PATCH_DENIED[keyword];\n if (denied) throw new Error(`${label}: patch \"${target}\" may not set ${keyword} (${denied})`);\n }\n for (const [verb, keyword] of STATE_FLAGS) {\n if (keyword in keywords && list(actions, verb).includes(target)) {\n throw new Error(`${label}: both ${verb} and patch ${keyword} on \"${target}\"`);\n }\n }\n }\n}\n\nfunction list(actions: ChangeActions, name: ListName): string[] {\n const targets = actions[name];\n if (targets === undefined) return [];\n if (!Array.isArray(targets)) {\n throw new Error(`x-on-change: ${name} must be an array of property keys, got ${typeof targets}`);\n }\n return targets;\n}\n\n// Every key the schema can declare in any branch — a listener may target a\n// field that only exists while some `allOf` branch is live.\nfunction declaredKeys(schema: JsonSchemaObject): Set<string> {\n const keys = new Set(Object.keys(schema.properties ?? {}));\n for (const branch of declaredBranches(schema)) {\n for (const key of Object.keys(branch.properties ?? {})) keys.add(key);\n }\n for (const clause of schema.allOf ?? []) {\n for (const branch of [clause, clause.then, clause.else]) {\n for (const key of Object.keys(branch?.properties ?? {})) keys.add(key);\n }\n }\n return keys;\n}\n"],"mappings":";;;;;AA+CA,IAAM,gBAA8D;CAAC;CAAW;CAAY;CAAS;AAAK;AAE1G,IAAM,cAAgE;CACpE;EAAC;EAAQ;EAAY;CAAI;CACzB;EAAC;EAAQ;EAAY;CAAK;CAC1B;EAAC;EAAW;EAAc;CAAI;CAC9B;EAAC;EAAU;EAAc;CAAK;AAChC;AAEA,IAAM,iBAAyC;CAC7C,CAAC,QAAQ,MAAM;CACf,CAAC,UAAU,SAAS;CACpB,CAAC,WAAW,UAAU;AACxB;AAEA,IAAM,aAAyB;CAAC;CAAQ;CAAQ;CAAU;CAAW;CAAW;CAAY;AAAO;AAGnG,IAAM,eAAuC;CAC3C,GAAG,OAAO,YACR;EAAC;EAAQ;EAAc;EAAS;EAAwB;EAAqB;EAAS;EAAS;EAAS;EAAM;EAAQ;EAAQ;EAAO;EAAQ;CAAO,CAAC,CAAC,KACnJ,YAAY,CAAC,SAAS,mDAAmD,CAC5E,CACF;CACA,UAAU;CACV,SAAS;CACT,OAAO;CACP,eAAe;CACf,aAAa;AACf;AASA,SAAgB,mBACd,QACA,OACA,SACqB;CACrB,MAAM,EAAE,YAAY,aAAaA,sCAAAA,oBAAoB,QAAQ,KAAK;CAClE,MAAM,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BAAgB,KAAK,0CAA0C,OAAO,SAAS;CAEjG,OAAO;AACT;AAIA,SAAS,aAAa,QAAuC;CAC3D,MAAM,OAAO,IAAI,IAAI,OAAO,KAAK,OAAO,cAAc,CAAC,CAAC,CAAC;CACzD,KAAK,MAAM,UAAUG,sCAAAA,iBAAiB,MAAM,GAC1C,KAAK,MAAM,OAAO,OAAO,KAAK,OAAO,cAAc,CAAC,CAAC,GAAG,KAAK,IAAI,GAAG;CAEtE,KAAK,MAAM,UAAU,OAAO,SAAS,CAAC,GACpC,KAAK,MAAM,UAAU;EAAC;EAAQ,OAAO;EAAM,OAAO;CAAI,GACpD,KAAK,MAAM,OAAO,OAAO,KAAK,QAAQ,cAAc,CAAC,CAAC,GAAG,KAAK,IAAI,GAAG;CAGzE,OAAO;AACT"}
1
+ {"version":3,"file":"json-schema-form-listeners.cjs","names":["effectiveProperties","selectedBranches","matchesIf","cloneSchemaDefault","evaluatePredicate","isPlainObject","isPathTarget","targetSegments","declaredBranches"],"sources":["../../src/components/json-schema-form-listeners.ts"],"sourcesContent":["import { isPlainObject } from \"../lib/collections\";\nimport {\n declaredBranches,\n effectiveProperties,\n evaluatePredicate,\n matchesIf,\n selectedBranches,\n type EffectiveProperties,\n} from \"./json-schema-form-conditionals\";\nimport { cloneSchemaDefault } from \"./json-schema-form-defaults\";\nimport { isPathTarget, patchTarget, targetSegments } from \"./json-schema-form-listener-paths\";\nimport type {\n ChangeActions,\n ChangeListener,\n ExpressionEvaluator,\n JsonSchemaObject,\n JsonSchemaProperty,\n} from \"./json-schema-form-types\";\n\n// `x-on-change` listeners: a property names what happens to its siblings when\n// its value is, or becomes, something. `x-on-load` listeners: an object names\n// the state its properties start in. See ChangeActions for the split between\n// derived state actions and transitional value actions.\n\nexport interface ListenerOptions {\n root: Record<string, unknown>;\n evaluate?: ExpressionEvaluator;\n}\n\n// ListenerSource says where a listener came from. `label` prefixes every error\n// it raises; `key` is the property whose value `when` reads (and the\n// evaluator's `key`) — for x-on-load, \"\" and the object itself.\ninterface ListenerSource {\n label: string;\n key: string;\n load: boolean;\n}\n\ninterface BoundListener {\n listener: ChangeListener;\n source: ListenerSource;\n}\n\ntype ListName = \"hide\" | \"show\" | \"enable\" | \"disable\" | \"require\" | \"optional\" | \"reset\";\n\n// Actions that write values or required-ness: they act on sibling keys only\n// (never a path), and have no place in x-on-load, which only derives state.\nconst LOCAL_ACTIONS: (\"require\" | \"optional\" | \"reset\" | \"set\")[] = [\"require\", \"optional\", \"reset\", \"set\"];\n\nconst STATE_FLAGS: [ListName, \"x-hidden\" | \"x-disabled\", boolean][] = [\n [\"hide\", \"x-hidden\", true],\n [\"show\", \"x-hidden\", false],\n [\"disable\", \"x-disabled\", true],\n [\"enable\", \"x-disabled\", false],\n];\n\nconst CONTRADICTIONS: [ListName, ListName][] = [\n [\"hide\", \"show\"],\n [\"enable\", \"disable\"],\n [\"require\", \"optional\"],\n];\n\nconst LIST_NAMES: ListName[] = [\"hide\", \"show\", \"enable\", \"disable\", \"require\", \"optional\", \"reset\"];\n\n// Keywords a `patch` may not set, with the tool that does the job instead.\nconst PATCH_DENIED: Record<string, string> = {\n ...Object.fromEntries(\n [\"type\", \"properties\", \"items\", \"additionalProperties\", \"patternProperties\", \"allOf\", \"anyOf\", \"oneOf\", \"if\", \"then\", \"else\", \"not\", \"$ref\", \"$defs\"].map(\n (keyword) => [keyword, \"it changes the field's shape; use an allOf branch\"],\n ),\n ),\n required: \"use require/optional\",\n default: \"a patch changes presentation, not values; use set/reset\",\n const: \"a patch changes presentation, not values; use set/reset\",\n \"x-on-change\": \"listeners cannot be patched in\",\n \"x-on-load\": \"listeners cannot be patched in\",\n};\n\n// applyListenerState is effectiveProperties plus the state actions of every\n// listener, evaluated against the current value: first the object's\n// `x-on-load` listeners, then each property's `x-on-change` listeners — load,\n// then change, the order the events happen in. A listener is applied after\n// `allOf`, so it wins over a branch; later listeners win over earlier ones. A\n// target the current shape does not declare stays absent. Property schemas are\n// cloned, never mutated.\nexport function applyListenerState(\n schema: JsonSchemaObject,\n value: Record<string, unknown>,\n options: ListenerOptions,\n): EffectiveProperties {\n const { properties, required } = effectiveProperties(schema, value);\n const requiredSet = new Set(required);\n const known = declaredKeys(schema);\n const bound: BoundListener[] = [\n ...loadListenersOf(schema, value),\n ...Object.entries(properties).flatMap(([key, prop]) =>\n listenersOf(key, prop).map((listener) => ({ listener, source: changeSource(key) })),\n ),\n ];\n for (const { listener, source } of bound) {\n const actions = selectActions({ listener, source, self: value, known, options });\n for (const [name, keyword, flag] of STATE_FLAGS) {\n for (const target of list(actions, name)) {\n patchTarget({ properties, value, target, apply: (leaf) => hiddenBy({ ...leaf, [keyword]: flag }, keyword, flag, source.label) });\n }\n }\n for (const target of list(actions, \"require\")) {\n if (properties[target]) requiredSet.add(target);\n }\n for (const target of list(actions, \"optional\")) requiredSet.delete(target);\n for (const [target, keywords] of Object.entries(actions.patch ?? {})) {\n patchTarget({ properties, value, target, apply: (leaf) => ({ ...leaf, ...keywords }) });\n }\n }\n return { properties, required: [...requiredSet] };\n}\n\n// hiddenBy records which listener hid a field (`x-hidden-by`), so the form's\n// debug mode can say why it is missing; a show clears it.\nfunction hiddenBy(leaf: JsonSchemaProperty, keyword: string, flag: boolean, label: string): JsonSchemaProperty {\n if (keyword !== \"x-hidden\") return leaf;\n if (flag) return { ...leaf, \"x-hidden-by\": label };\n const { \"x-hidden-by\": _by, ...shown } = leaf;\n return shown;\n}\n\n// loadListenersOf collects an object's `x-on-load` listeners in order: the\n// schema's own, then each `allOf` member's — an unconditional member's own, or\n// those of the `then`/`else` branch that applies, selected exactly as\n// effectiveProperties selects the branch it merges.\nfunction loadListenersOf(schema: JsonSchemaObject, value: Record<string, unknown>): BoundListener[] {\n const bound = loadListenersAt(schema[\"x-on-load\"], \"#/x-on-load\");\n for (const { branch, pointer } of selectedBranches(schema, value)) {\n bound.push(...loadListenersAt(branch[\"x-on-load\"], `#${pointer}/x-on-load`));\n }\n for (const [index, clause] of (schema.allOf ?? []).entries()) {\n if (clause.if === undefined && clause.then === undefined) {\n bound.push(...loadListenersAt(clause[\"x-on-load\"], `#/allOf/${index}/x-on-load`));\n continue;\n }\n const branch = matchesIf(clause.if, value) ? \"then\" : \"else\";\n bound.push(...loadListenersAt(clause[branch]?.[\"x-on-load\"], `#/allOf/${index}/${branch}/x-on-load`));\n }\n return bound;\n}\n\nfunction loadListenersAt(listeners: unknown, pointer: string): BoundListener[] {\n if (listeners === undefined) return [];\n if (!Array.isArray(listeners)) {\n throw new Error(`x-on-load at ${pointer} must be an array of listeners, got ${typeof listeners}`);\n }\n return listeners.map((listener: ChangeListener, index) => ({\n listener,\n source: { label: `x-on-load at ${pointer}/${index}`, key: \"\", load: true },\n }));\n}\n\nfunction changeSource(key: string): ListenerSource {\n return { label: `x-on-change on \"${key}\"`, key, load: false };\n}\n\n// applyChangeEffects commits `next` at `key` and runs the value actions\n// (reset/set) of that key's listeners against the post-edit object. A target\n// whose value actually changes fires its own listeners in turn; each key fires\n// at most once per commit, so a cycle ends. When `root` is the edited object\n// itself (the top level), expressions see the post-edit value as root too.\nexport function applyChangeEffects(\n schema: JsonSchemaObject,\n edit: ListenerOptions & { value: Record<string, unknown>; key: string; next: unknown },\n): Record<string, unknown> {\n let current: Record<string, unknown> = { ...edit.value, [edit.key]: edit.next };\n const known = declaredKeys(schema);\n const fired = new Set<string>();\n const queue = [edit.key];\n for (let source = queue.shift(); source !== undefined; source = queue.shift()) {\n if (fired.has(source)) continue;\n fired.add(source);\n const { properties } = effectiveProperties(schema, current);\n const options: ListenerOptions = {\n root: edit.root === edit.value ? current : edit.root,\n ...(edit.evaluate ? { evaluate: edit.evaluate } : {}),\n };\n for (const listener of listenersOf(source, properties[source])) {\n const actions = selectActions({ listener, source: changeSource(source), self: current, known, options });\n for (const [target, nextValue] of valueChanges(actions, properties)) {\n if (Object.is(current[target], nextValue)) continue;\n current = { ...current };\n if (nextValue === undefined) delete current[target];\n else current[target] = nextValue;\n queue.push(target);\n }\n }\n }\n return current;\n}\n\nfunction valueChanges(\n actions: ChangeActions,\n properties: Record<string, JsonSchemaProperty>,\n): [string, unknown][] {\n return [\n ...list(actions, \"reset\").map((target): [string, unknown] => {\n const fallback = properties[target]?.default;\n return [target, fallback === undefined ? undefined : cloneSchemaDefault(fallback)];\n }),\n ...Object.entries(actions.set ?? {}).map(([target, v]): [string, unknown] => [target, cloneSchemaDefault(v)]),\n ];\n}\n\nfunction listenersOf(key: string, prop: JsonSchemaProperty | undefined): ChangeListener[] {\n const listeners = prop?.[\"x-on-change\"];\n if (listeners === undefined) return [];\n if (!Array.isArray(listeners)) {\n throw new Error(`\"${key}\": x-on-change must be an array of listeners, got ${typeof listeners}`);\n }\n return listeners;\n}\n\n// selectActions validates both branches of a listener (so a schema error\n// surfaces whichever branch is live) and returns the one that applies now.\nfunction selectActions({\n listener,\n source,\n self,\n known,\n options,\n}: {\n listener: ChangeListener;\n source: ListenerSource;\n self: Record<string, unknown>;\n known: Set<string>;\n options: ListenerOptions;\n}): ChangeActions {\n validateActions(source, listener, known);\n if (listener.else) validateActions(source, listener.else, known);\n return listenerHolds(listener, source, self, options) ? listener : (listener.else ?? {});\n}\n\n// listenerHolds evaluates `when` against the source's subject: the property's\n// value for x-on-change, the object itself for x-on-load.\nfunction listenerHolds(\n listener: ChangeListener,\n { label, key, load }: ListenerSource,\n self: Record<string, unknown>,\n options: ListenerOptions,\n): boolean {\n if (listener.when === undefined) return true;\n const { expr, ...predicate } = listener.when;\n const hasPredicate = Object.keys(predicate).length > 0;\n const subject = load ? self : self[key];\n if (!hasPredicate && expr === undefined) {\n throw new Error(`${label}: when states nothing it can evaluate`);\n }\n if (expr !== undefined && typeof expr !== \"string\") {\n throw new Error(`${label}: when.expr must be a string, got ${typeof expr}`);\n }\n if (expr !== undefined && !options.evaluate) {\n throw new Error(`${label}: when.expr \"${expr}\" needs the form's expressionEvaluator`);\n }\n if (hasPredicate) {\n const holds = evaluatePredicate(predicate, subject);\n if (holds === undefined) {\n throw new Error(`${label}: when states nothing it can evaluate (${JSON.stringify(predicate)})`);\n }\n if (!holds) return false;\n }\n if (expr === undefined || !options.evaluate) return true;\n const result: unknown = options.evaluate({ expr, key, value: subject, self, root: options.root });\n if (typeof result !== \"boolean\") {\n throw new Error(`${label}: expressionEvaluator returned ${typeof result} for \"${expr}\", expected boolean`);\n }\n return result;\n}\n\nfunction validateActions(source: ListenerSource, actions: ChangeActions, known: Set<string>): void {\n const { label } = source;\n if (actions.set !== undefined && !isPlainObject(actions.set)) {\n throw new Error(`${label}: set must be an object of target → value`);\n }\n if (source.load) {\n const local = LOCAL_ACTIONS.find((name) => actions[name] !== undefined);\n if (local) {\n throw new Error(`${label}: ${local} is not allowed in x-on-load, which only derives state (hide/show/enable/disable/patch)`);\n }\n }\n const setKeys = Object.keys(actions.set ?? {});\n for (const name of LOCAL_ACTIONS) {\n const targets = name === \"set\" ? setKeys : list(actions, name);\n const path = targets.find(isPathTarget);\n if (path !== undefined) {\n throw new Error(`${label}: ${name} \"${path}\" cannot take a path; value and required actions act on sibling keys only`);\n }\n }\n for (const target of [...LIST_NAMES.flatMap((name) => list(actions, name)), ...setKeys]) {\n validateTarget(label, target, known);\n }\n const pairs: [string, string[], string, string[]][] = [\n ...CONTRADICTIONS.map(([a, b]): [string, string[], string, string[]] => [a, list(actions, a), b, list(actions, b)]),\n [\"reset\", list(actions, \"reset\"), \"set\", setKeys],\n ];\n for (const [a, left, b, right] of pairs) {\n const clash = left.find((target) => right.includes(target));\n if (clash !== undefined) {\n throw new Error(`${label}: both ${a} and ${b} \"${clash}\"`);\n }\n }\n validatePatch(label, actions, known);\n}\n\n// validateTarget checks a target's grammar and that its first segment is a key\n// the schema declares in some branch.\nfunction validateTarget(label: string, target: string, known: Set<string>): void {\n if (isPathTarget(target) && known.has(target)) {\n throw new Error(`${label}: target \"${target}\" is both a declared key and a path`);\n }\n const [first = \"\"] = targetSegments(label, target);\n if (!known.has(first)) throw new Error(`${label}: unknown target \"${target}\"`);\n}\n\n// validatePatch checks a `patch`: an object of keyword objects on known\n// targets, no denied keyword, and no keyword a verb in the same actions sets.\nfunction validatePatch(label: string, actions: ChangeActions, known: Set<string>): void {\n const patch: unknown = actions.patch;\n if (patch === undefined) return;\n if (!isPlainObject(patch)) {\n throw new Error(`${label}: patch must be an object of target → keywords`);\n }\n for (const [target, keywords] of Object.entries(patch)) {\n validateTarget(label, target, known);\n if (!isPlainObject(keywords)) {\n throw new Error(`${label}: patch \"${target}\" must be an object of keywords`);\n }\n for (const keyword of Object.keys(keywords)) {\n const denied = PATCH_DENIED[keyword];\n if (denied) throw new Error(`${label}: patch \"${target}\" may not set ${keyword} (${denied})`);\n }\n for (const [verb, keyword] of STATE_FLAGS) {\n if (keyword in keywords && list(actions, verb).includes(target)) {\n throw new Error(`${label}: both ${verb} and patch ${keyword} on \"${target}\"`);\n }\n }\n }\n}\n\nfunction list(actions: ChangeActions, name: ListName): string[] {\n const targets = actions[name];\n if (targets === undefined) return [];\n if (!Array.isArray(targets)) {\n throw new Error(`x-on-change: ${name} must be an array of property keys, got ${typeof targets}`);\n }\n return targets;\n}\n\n// Every key the schema can declare in any branch — a listener may target a\n// field that only exists while some `allOf` branch is live.\nfunction declaredKeys(schema: JsonSchemaObject): Set<string> {\n const keys = new Set(Object.keys(schema.properties ?? {}));\n for (const branch of declaredBranches(schema)) {\n for (const key of Object.keys(branch.properties ?? {})) keys.add(key);\n }\n for (const clause of schema.allOf ?? []) {\n // A member's `else` may itself be an if/then/else chain (an answer that is\n // handled, open or not applicable), so walk every branch it can select.\n for (const branch of [clause, ...declaredBranches(clause)]) {\n for (const key of Object.keys(branch?.properties ?? {})) keys.add(key);\n }\n }\n return keys;\n}\n"],"mappings":";;;;;AA+CA,IAAM,gBAA8D;CAAC;CAAW;CAAY;CAAS;AAAK;AAE1G,IAAM,cAAgE;CACpE;EAAC;EAAQ;EAAY;CAAI;CACzB;EAAC;EAAQ;EAAY;CAAK;CAC1B;EAAC;EAAW;EAAc;CAAI;CAC9B;EAAC;EAAU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W,OAAO,gCAAgC;EAE7E,KAAK,MAAM,WAAW,OAAO,KAAK,QAAQ,GAAG;GAC3C,MAAM,SAAS,aAAa;GAC5B,IAAI,QAAQ,MAAM,IAAI,MAAM,GAAG,MAAM,WAAW,OAAO,gBAAgB,QAAQ,IAAI,OAAO,EAAE;EAC9F;EACA,KAAK,MAAM,CAAC,MAAM,YAAY,aAC5B,IAAI,WAAW,YAAY,KAAK,SAAS,IAAI,CAAC,CAAC,SAAS,MAAM,GAC5D,MAAM,IAAI,MAAM,GAAG,MAAM,SAAS,KAAK,aAAa,QAAQ,OAAO,OAAO,EAAE;CAGlF;AACF;AAEA,SAAS,KAAK,SAAwB,MAA0B;CAC9D,MAAM,UAAU,QAAQ;CACxB,IAAI,YAAY,KAAA,GAAW,OAAO,CAAC;CACnC,IAAI,CAAC,MAAM,QAAQ,OAAO,GACxB,MAAM,IAAI,MAAM,gBAAgB,KAAK,0CAA0C,OAAO,SAAS;CAEjG,OAAO;AACT;AAIA,SAAS,aAAa,QAAuC;CAC3D,MAAM,OAAO,IAAI,IAAI,OAAO,KAAK,OAAO,cAAc,CAAC,CAAC,CAAC;CACzD,KAAK,MAAM,UAAUG,sCAAAA,iBAAiB,MAAM,GAC1C,KAAK,MAAM,OAAO,OAAO,KAAK,OAAO,cAAc,CAAC,CAAC,GAAG,KAAK,IAAI,GAAG;CAEtE,KAAK,MAAM,UAAU,OAAO,SAAS,CAAC,GAGpC,KAAK,MAAM,UAAU,CAAC,QAAQ,GAAGA,sCAAAA,iBAAiB,MAAM,CAAC,GACvD,KAAK,MAAM,OAAO,OAAO,KAAK,QAAQ,cAAc,CAAC,CAAC,GAAG,KAAK,IAAI,GAAG;CAGzE,OAAO;AACT"}
@@ -285,11 +285,7 @@ function list(actions, name) {
285
285
  function declaredKeys(schema) {
286
286
  const keys = new Set(Object.keys(schema.properties ?? {}));
287
287
  for (const branch of declaredBranches(schema)) for (const key of Object.keys(branch.properties ?? {})) keys.add(key);
288
- for (const clause of schema.allOf ?? []) for (const branch of [
289
- clause,
290
- clause.then,
291
- clause.else
292
- ]) for (const key of Object.keys(branch?.properties ?? {})) keys.add(key);
288
+ for (const clause of schema.allOf ?? []) for (const branch of [clause, ...declaredBranches(clause)]) for (const key of Object.keys(branch?.properties ?? {})) keys.add(key);
293
289
  return keys;
294
290
  }
295
291
  export { applyChangeEffects, applyListenerState };
@@ -1 +1 @@
1
- {"version":3,"file":"json-schema-form-listeners.js","names":[],"sources":["../../src/components/json-schema-form-listeners.ts"],"sourcesContent":["import { isPlainObject } from \"../lib/collections\";\nimport {\n declaredBranches,\n effectiveProperties,\n evaluatePredicate,\n matchesIf,\n selectedBranches,\n type EffectiveProperties,\n} from \"./json-schema-form-conditionals\";\nimport { cloneSchemaDefault } from \"./json-schema-form-defaults\";\nimport { isPathTarget, patchTarget, targetSegments } from \"./json-schema-form-listener-paths\";\nimport type {\n ChangeActions,\n ChangeListener,\n ExpressionEvaluator,\n JsonSchemaObject,\n JsonSchemaProperty,\n} from \"./json-schema-form-types\";\n\n// `x-on-change` listeners: a property names what happens to its siblings when\n// its value is, or becomes, something. `x-on-load` listeners: an object names\n// the state its properties start in. See ChangeActions for the split between\n// derived state actions and transitional value actions.\n\nexport interface ListenerOptions {\n root: Record<string, unknown>;\n evaluate?: ExpressionEvaluator;\n}\n\n// ListenerSource says where a listener came from. `label` prefixes every error\n// it raises; `key` is the property whose value `when` reads (and the\n// evaluator's `key`) — for x-on-load, \"\" and the object itself.\ninterface ListenerSource {\n label: string;\n key: string;\n load: boolean;\n}\n\ninterface BoundListener {\n listener: ChangeListener;\n source: ListenerSource;\n}\n\ntype ListName = \"hide\" | \"show\" | \"enable\" | \"disable\" | \"require\" | \"optional\" | \"reset\";\n\n// Actions that write values or required-ness: they act on sibling keys only\n// (never a path), and have no place in x-on-load, which only derives state.\nconst LOCAL_ACTIONS: (\"require\" | \"optional\" | \"reset\" | \"set\")[] = [\"require\", \"optional\", \"reset\", \"set\"];\n\nconst STATE_FLAGS: [ListName, \"x-hidden\" | \"x-disabled\", boolean][] = [\n [\"hide\", \"x-hidden\", true],\n [\"show\", \"x-hidden\", false],\n [\"disable\", \"x-disabled\", true],\n [\"enable\", \"x-disabled\", false],\n];\n\nconst CONTRADICTIONS: [ListName, ListName][] = [\n [\"hide\", \"show\"],\n [\"enable\", \"disable\"],\n [\"require\", \"optional\"],\n];\n\nconst LIST_NAMES: ListName[] = [\"hide\", \"show\", \"enable\", \"disable\", \"require\", \"optional\", \"reset\"];\n\n// Keywords a `patch` may not set, with the tool that does the job instead.\nconst PATCH_DENIED: Record<string, string> = {\n ...Object.fromEntries(\n [\"type\", \"properties\", \"items\", \"additionalProperties\", \"patternProperties\", \"allOf\", \"anyOf\", \"oneOf\", \"if\", \"then\", \"else\", \"not\", \"$ref\", \"$defs\"].map(\n (keyword) => [keyword, \"it changes the field's shape; use an allOf branch\"],\n ),\n ),\n required: \"use require/optional\",\n default: \"a patch changes presentation, not values; use set/reset\",\n const: \"a patch changes presentation, not values; use set/reset\",\n \"x-on-change\": \"listeners cannot be patched in\",\n \"x-on-load\": \"listeners cannot be patched in\",\n};\n\n// applyListenerState is effectiveProperties plus the state actions of every\n// listener, evaluated against the current value: first the object's\n// `x-on-load` listeners, then each property's `x-on-change` listeners — load,\n// then change, the order the events happen in. A listener is applied after\n// `allOf`, so it wins over a branch; later listeners win over earlier ones. A\n// target the current shape does not declare stays absent. Property schemas are\n// cloned, never mutated.\nexport function applyListenerState(\n schema: JsonSchemaObject,\n value: Record<string, unknown>,\n options: ListenerOptions,\n): EffectiveProperties {\n const { properties, required } = effectiveProperties(schema, value);\n const requiredSet = new Set(required);\n const known = declaredKeys(schema);\n const bound: BoundListener[] = [\n ...loadListenersOf(schema, value),\n ...Object.entries(properties).flatMap(([key, prop]) =>\n listenersOf(key, prop).map((listener) => ({ listener, source: changeSource(key) })),\n ),\n ];\n for (const { listener, source } of bound) {\n const actions = selectActions({ listener, source, self: value, known, options });\n for (const [name, keyword, flag] of STATE_FLAGS) {\n for (const target of list(actions, name)) {\n patchTarget({ properties, value, target, apply: (leaf) => hiddenBy({ ...leaf, [keyword]: flag }, keyword, flag, source.label) });\n }\n }\n for (const target of list(actions, \"require\")) {\n if (properties[target]) requiredSet.add(target);\n }\n for (const target of list(actions, \"optional\")) requiredSet.delete(target);\n for (const [target, keywords] of Object.entries(actions.patch ?? {})) {\n patchTarget({ properties, value, target, apply: (leaf) => ({ ...leaf, ...keywords }) });\n }\n }\n return { properties, required: [...requiredSet] };\n}\n\n// hiddenBy records which listener hid a field (`x-hidden-by`), so the form's\n// debug mode can say why it is missing; a show clears it.\nfunction hiddenBy(leaf: JsonSchemaProperty, keyword: string, flag: boolean, label: string): JsonSchemaProperty {\n if (keyword !== \"x-hidden\") return leaf;\n if (flag) return { ...leaf, \"x-hidden-by\": label };\n const { \"x-hidden-by\": _by, ...shown } = leaf;\n return shown;\n}\n\n// loadListenersOf collects an object's `x-on-load` listeners in order: the\n// schema's own, then each `allOf` member's — an unconditional member's own, or\n// those of the `then`/`else` branch that applies, selected exactly as\n// effectiveProperties selects the branch it merges.\nfunction loadListenersOf(schema: JsonSchemaObject, value: Record<string, unknown>): BoundListener[] {\n const bound = loadListenersAt(schema[\"x-on-load\"], \"#/x-on-load\");\n for (const { branch, pointer } of selectedBranches(schema, value)) {\n bound.push(...loadListenersAt(branch[\"x-on-load\"], `#${pointer}/x-on-load`));\n }\n for (const [index, clause] of (schema.allOf ?? []).entries()) {\n if (clause.if === undefined && clause.then === undefined) {\n bound.push(...loadListenersAt(clause[\"x-on-load\"], `#/allOf/${index}/x-on-load`));\n continue;\n }\n const branch = matchesIf(clause.if, value) ? \"then\" : \"else\";\n bound.push(...loadListenersAt(clause[branch]?.[\"x-on-load\"], `#/allOf/${index}/${branch}/x-on-load`));\n }\n return bound;\n}\n\nfunction loadListenersAt(listeners: unknown, pointer: string): BoundListener[] {\n if (listeners === undefined) return [];\n if (!Array.isArray(listeners)) {\n throw new Error(`x-on-load at ${pointer} must be an array of listeners, got ${typeof listeners}`);\n }\n return listeners.map((listener: ChangeListener, index) => ({\n listener,\n source: { label: `x-on-load at ${pointer}/${index}`, key: \"\", load: true },\n }));\n}\n\nfunction changeSource(key: string): ListenerSource {\n return { label: `x-on-change on \"${key}\"`, key, load: false };\n}\n\n// applyChangeEffects commits `next` at `key` and runs the value actions\n// (reset/set) of that key's listeners against the post-edit object. A target\n// whose value actually changes fires its own listeners in turn; each key fires\n// at most once per commit, so a cycle ends. When `root` is the edited object\n// itself (the top level), expressions see the post-edit value as root too.\nexport function applyChangeEffects(\n schema: JsonSchemaObject,\n edit: ListenerOptions & { value: Record<string, unknown>; key: string; next: unknown },\n): Record<string, unknown> {\n let current: Record<string, unknown> = { ...edit.value, [edit.key]: edit.next };\n const known = declaredKeys(schema);\n const fired = new Set<string>();\n const queue = [edit.key];\n for (let source = queue.shift(); source !== undefined; source = queue.shift()) {\n if (fired.has(source)) continue;\n fired.add(source);\n const { properties } = effectiveProperties(schema, current);\n const options: ListenerOptions = {\n root: edit.root === edit.value ? current : edit.root,\n ...(edit.evaluate ? { evaluate: edit.evaluate } : {}),\n };\n for (const listener of listenersOf(source, properties[source])) {\n const actions = selectActions({ listener, source: changeSource(source), self: current, known, options });\n for (const [target, nextValue] of valueChanges(actions, properties)) {\n if (Object.is(current[target], nextValue)) continue;\n current = { ...current };\n if (nextValue === undefined) delete current[target];\n else current[target] = nextValue;\n queue.push(target);\n }\n }\n }\n return current;\n}\n\nfunction valueChanges(\n actions: ChangeActions,\n properties: Record<string, JsonSchemaProperty>,\n): [string, unknown][] {\n return [\n ...list(actions, \"reset\").map((target): [string, unknown] => {\n const fallback = properties[target]?.default;\n return [target, fallback === undefined ? undefined : cloneSchemaDefault(fallback)];\n }),\n ...Object.entries(actions.set ?? {}).map(([target, v]): [string, unknown] => [target, cloneSchemaDefault(v)]),\n ];\n}\n\nfunction listenersOf(key: string, prop: JsonSchemaProperty | undefined): ChangeListener[] {\n const listeners = prop?.[\"x-on-change\"];\n if (listeners === undefined) return [];\n if (!Array.isArray(listeners)) {\n throw new Error(`\"${key}\": x-on-change must be an array of listeners, got ${typeof listeners}`);\n }\n return listeners;\n}\n\n// selectActions validates both branches of a listener (so a schema error\n// surfaces whichever branch is live) and returns the one that applies now.\nfunction selectActions({\n listener,\n source,\n self,\n known,\n options,\n}: {\n listener: ChangeListener;\n source: ListenerSource;\n self: Record<string, unknown>;\n known: Set<string>;\n options: ListenerOptions;\n}): ChangeActions {\n validateActions(source, listener, known);\n if (listener.else) validateActions(source, listener.else, known);\n return listenerHolds(listener, source, self, options) ? listener : (listener.else ?? {});\n}\n\n// listenerHolds evaluates `when` against the source's subject: the property's\n// value for x-on-change, the object itself for x-on-load.\nfunction listenerHolds(\n listener: ChangeListener,\n { label, key, load }: ListenerSource,\n self: Record<string, unknown>,\n options: ListenerOptions,\n): boolean {\n if (listener.when === undefined) return true;\n const { expr, ...predicate } = listener.when;\n const hasPredicate = Object.keys(predicate).length > 0;\n const subject = load ? self : self[key];\n if (!hasPredicate && expr === undefined) {\n throw new Error(`${label}: when states nothing it can evaluate`);\n }\n if (expr !== undefined && typeof expr !== \"string\") {\n throw new Error(`${label}: when.expr must be a string, got ${typeof expr}`);\n }\n if (expr !== undefined && !options.evaluate) {\n throw new Error(`${label}: when.expr \"${expr}\" needs the form's expressionEvaluator`);\n }\n if (hasPredicate) {\n const holds = evaluatePredicate(predicate, subject);\n if (holds === undefined) {\n throw new Error(`${label}: when states nothing it can evaluate (${JSON.stringify(predicate)})`);\n }\n if (!holds) return false;\n }\n if (expr === undefined || !options.evaluate) return true;\n const result: unknown = options.evaluate({ expr, key, value: subject, self, root: options.root });\n if (typeof result !== \"boolean\") {\n throw new Error(`${label}: expressionEvaluator returned ${typeof result} for \"${expr}\", expected boolean`);\n }\n return result;\n}\n\nfunction validateActions(source: ListenerSource, actions: ChangeActions, known: Set<string>): void {\n const { label } = source;\n if (actions.set !== undefined && !isPlainObject(actions.set)) {\n throw new Error(`${label}: set must be an object of target → value`);\n }\n if (source.load) {\n const local = LOCAL_ACTIONS.find((name) => actions[name] !== undefined);\n if (local) {\n throw new Error(`${label}: ${local} is not allowed in x-on-load, which only derives state (hide/show/enable/disable/patch)`);\n }\n }\n const setKeys = Object.keys(actions.set ?? {});\n for (const name of LOCAL_ACTIONS) {\n const targets = name === \"set\" ? setKeys : list(actions, name);\n const path = targets.find(isPathTarget);\n if (path !== undefined) {\n throw new Error(`${label}: ${name} \"${path}\" cannot take a path; value and required actions act on sibling keys only`);\n }\n }\n for (const target of [...LIST_NAMES.flatMap((name) => list(actions, name)), ...setKeys]) {\n validateTarget(label, target, known);\n }\n const pairs: [string, string[], string, string[]][] = [\n ...CONTRADICTIONS.map(([a, b]): [string, string[], string, string[]] => [a, list(actions, a), b, list(actions, b)]),\n [\"reset\", list(actions, \"reset\"), \"set\", setKeys],\n ];\n for (const [a, left, b, right] of pairs) {\n const clash = left.find((target) => right.includes(target));\n if (clash !== undefined) {\n throw new Error(`${label}: both ${a} and ${b} \"${clash}\"`);\n }\n }\n validatePatch(label, actions, known);\n}\n\n// validateTarget checks a target's grammar and that its first segment is a key\n// the schema declares in some branch.\nfunction validateTarget(label: string, target: string, known: Set<string>): void {\n if (isPathTarget(target) && known.has(target)) {\n throw new Error(`${label}: target \"${target}\" is both a declared key and a path`);\n }\n const [first = \"\"] = targetSegments(label, target);\n if (!known.has(first)) throw new Error(`${label}: unknown target \"${target}\"`);\n}\n\n// validatePatch checks a `patch`: an object of keyword objects on known\n// targets, no denied keyword, and no keyword a verb in the same actions sets.\nfunction validatePatch(label: string, actions: ChangeActions, known: Set<string>): void {\n const patch: unknown = actions.patch;\n if (patch === undefined) return;\n if (!isPlainObject(patch)) {\n throw new Error(`${label}: patch must be an object of target → keywords`);\n }\n for (const [target, keywords] of Object.entries(patch)) {\n validateTarget(label, target, known);\n if (!isPlainObject(keywords)) {\n throw new Error(`${label}: patch \"${target}\" must be an object of keywords`);\n }\n for (const keyword of Object.keys(keywords)) {\n const denied = PATCH_DENIED[keyword];\n if (denied) throw new Error(`${label}: patch \"${target}\" may not set ${keyword} (${denied})`);\n }\n for (const [verb, keyword] of STATE_FLAGS) {\n if (keyword in keywords && list(actions, verb).includes(target)) {\n throw new Error(`${label}: both ${verb} and patch ${keyword} on \"${target}\"`);\n }\n }\n }\n}\n\nfunction list(actions: ChangeActions, name: ListName): string[] {\n const targets = actions[name];\n if (targets === undefined) return [];\n if (!Array.isArray(targets)) {\n throw new Error(`x-on-change: ${name} must be an array of property keys, got ${typeof targets}`);\n }\n return targets;\n}\n\n// Every key the schema can declare in any branch — a listener may target a\n// field that only exists while some `allOf` branch is live.\nfunction declaredKeys(schema: JsonSchemaObject): Set<string> {\n const keys = new Set(Object.keys(schema.properties ?? {}));\n for (const branch of declaredBranches(schema)) {\n for (const key of Object.keys(branch.properties ?? {})) keys.add(key);\n }\n for (const clause of schema.allOf ?? []) {\n for (const branch of [clause, clause.then, clause.else]) {\n for (const key of Object.keys(branch?.properties ?? {})) keys.add(key);\n }\n }\n return keys;\n}\n"],"mappings":";;;;;AA+CA,IAAM,gBAA8D;CAAC;CAAW;CAAY;CAAS;AAAK;AAE1G,IAAM,cAAgE;CACpE;EAAC;EAAQ;EAAY;CAAI;CACzB;EAAC;EAAQ;EAAY;CAAK;CAC1B;EAAC;EAAW;EAAc;CAAI;CAC9B;EAAC;EAAU;EAAc;CAAK;AAChC;AAEA,IAAM,iBAAyC;CAC7C,CAAC,QAAQ,MAAM;CACf,CAAC,UAAU,SAAS;CACpB,CAAC,WAAW,UAAU;AACxB;AAEA,IAAM,aAAyB;CAAC;CAAQ;CAAQ;CAAU;CAAW;CAAW;CAAY;AAAO;AAGnG,IAAM,eAAuC;CAC3C,GAAG,OAAO,YACR;EAAC;EAAQ;EAAc;EAAS;EAAwB;EAAqB;EAAS;EAAS;EAAS;EAAM;EAAQ;EAAQ;EAAO;EAAQ;CAAO,CAAC,CAAC,KACnJ,YAAY,CAAC,SAAS,mDAAmD,CAC5E,CACF;CACA,UAAU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ACxB,MAAM,IAAI,MAAM,gBAAgB,KAAK,0CAA0C,OAAO,SAAS;CAEjG,OAAO;AACT;AAIA,SAAS,aAAa,QAAuC;CAC3D,MAAM,OAAO,IAAI,IAAI,OAAO,KAAK,OAAO,cAAc,CAAC,CAAC,CAAC;CACzD,KAAK,MAAM,UAAU,iBAAiB,MAAM,GAC1C,KAAK,MAAM,OAAO,OAAO,KAAK,OAAO,cAAc,CAAC,CAAC,GAAG,KAAK,IAAI,GAAG;CAEtE,KAAK,MAAM,UAAU,OAAO,SAAS,CAAC,GACpC,KAAK,MAAM,UAAU;EAAC;EAAQ,OAAO;EAAM,OAAO;CAAI,GACpD,KAAK,MAAM,OAAO,OAAO,KAAK,QAAQ,cAAc,CAAC,CAAC,GAAG,KAAK,IAAI,GAAG;CAGzE,OAAO;AACT"}
1
+ {"version":3,"file":"json-schema-form-listeners.js","names":[],"sources":["../../src/components/json-schema-form-listeners.ts"],"sourcesContent":["import { isPlainObject } from \"../lib/collections\";\nimport {\n declaredBranches,\n effectiveProperties,\n evaluatePredicate,\n matchesIf,\n selectedBranches,\n type EffectiveProperties,\n} from \"./json-schema-form-conditionals\";\nimport { cloneSchemaDefault } from \"./json-schema-form-defaults\";\nimport { isPathTarget, patchTarget, targetSegments } from \"./json-schema-form-listener-paths\";\nimport type {\n ChangeActions,\n ChangeListener,\n ExpressionEvaluator,\n JsonSchemaObject,\n JsonSchemaProperty,\n} from \"./json-schema-form-types\";\n\n// `x-on-change` listeners: a property names what happens to its siblings when\n// its value is, or becomes, something. `x-on-load` listeners: an object names\n// the state its properties start in. See ChangeActions for the split between\n// derived state actions and transitional value actions.\n\nexport interface ListenerOptions {\n root: Record<string, unknown>;\n evaluate?: ExpressionEvaluator;\n}\n\n// ListenerSource says where a listener came from. `label` prefixes every error\n// it raises; `key` is the property whose value `when` reads (and the\n// evaluator's `key`) — for x-on-load, \"\" and the object itself.\ninterface ListenerSource {\n label: string;\n key: string;\n load: boolean;\n}\n\ninterface BoundListener {\n listener: ChangeListener;\n source: ListenerSource;\n}\n\ntype ListName = \"hide\" | \"show\" | \"enable\" | \"disable\" | \"require\" | \"optional\" | \"reset\";\n\n// Actions that write values or required-ness: they act on sibling keys only\n// (never a path), and have no place in x-on-load, which only derives state.\nconst LOCAL_ACTIONS: (\"require\" | \"optional\" | \"reset\" | \"set\")[] = [\"require\", \"optional\", \"reset\", \"set\"];\n\nconst STATE_FLAGS: [ListName, \"x-hidden\" | \"x-disabled\", boolean][] = [\n [\"hide\", \"x-hidden\", true],\n [\"show\", \"x-hidden\", false],\n [\"disable\", \"x-disabled\", true],\n [\"enable\", \"x-disabled\", false],\n];\n\nconst CONTRADICTIONS: [ListName, ListName][] = [\n [\"hide\", \"show\"],\n [\"enable\", \"disable\"],\n [\"require\", \"optional\"],\n];\n\nconst LIST_NAMES: ListName[] = [\"hide\", \"show\", \"enable\", \"disable\", \"require\", \"optional\", \"reset\"];\n\n// Keywords a `patch` may not set, with the tool that does the job instead.\nconst PATCH_DENIED: Record<string, string> = {\n ...Object.fromEntries(\n [\"type\", \"properties\", \"items\", \"additionalProperties\", \"patternProperties\", \"allOf\", \"anyOf\", \"oneOf\", \"if\", \"then\", \"else\", \"not\", \"$ref\", \"$defs\"].map(\n (keyword) => [keyword, \"it changes the field's shape; use an allOf branch\"],\n ),\n ),\n required: \"use require/optional\",\n default: \"a patch changes presentation, not values; use set/reset\",\n const: \"a patch changes presentation, not values; use set/reset\",\n \"x-on-change\": \"listeners cannot be patched in\",\n \"x-on-load\": \"listeners cannot be patched in\",\n};\n\n// applyListenerState is effectiveProperties plus the state actions of every\n// listener, evaluated against the current value: first the object's\n// `x-on-load` listeners, then each property's `x-on-change` listeners — load,\n// then change, the order the events happen in. A listener is applied after\n// `allOf`, so it wins over a branch; later listeners win over earlier ones. A\n// target the current shape does not declare stays absent. Property schemas are\n// cloned, never mutated.\nexport function applyListenerState(\n schema: JsonSchemaObject,\n value: Record<string, unknown>,\n options: ListenerOptions,\n): EffectiveProperties {\n const { properties, required } = effectiveProperties(schema, value);\n const requiredSet = new Set(required);\n const known = declaredKeys(schema);\n const bound: BoundListener[] = [\n ...loadListenersOf(schema, value),\n ...Object.entries(properties).flatMap(([key, prop]) =>\n listenersOf(key, prop).map((listener) => ({ listener, source: changeSource(key) })),\n ),\n ];\n for (const { listener, source } of bound) {\n const actions = selectActions({ listener, source, self: value, known, options });\n for (const [name, keyword, flag] of STATE_FLAGS) {\n for (const target of list(actions, name)) {\n patchTarget({ properties, value, target, apply: (leaf) => hiddenBy({ ...leaf, [keyword]: flag }, keyword, flag, source.label) });\n }\n }\n for (const target of list(actions, \"require\")) {\n if (properties[target]) requiredSet.add(target);\n }\n for (const target of list(actions, \"optional\")) requiredSet.delete(target);\n for (const [target, keywords] of Object.entries(actions.patch ?? {})) {\n patchTarget({ properties, value, target, apply: (leaf) => ({ ...leaf, ...keywords }) });\n }\n }\n return { properties, required: [...requiredSet] };\n}\n\n// hiddenBy records which listener hid a field (`x-hidden-by`), so the form's\n// debug mode can say why it is missing; a show clears it.\nfunction hiddenBy(leaf: JsonSchemaProperty, keyword: string, flag: boolean, label: string): JsonSchemaProperty {\n if (keyword !== \"x-hidden\") return leaf;\n if (flag) return { ...leaf, \"x-hidden-by\": label };\n const { \"x-hidden-by\": _by, ...shown } = leaf;\n return shown;\n}\n\n// loadListenersOf collects an object's `x-on-load` listeners in order: the\n// schema's own, then each `allOf` member's — an unconditional member's own, or\n// those of the `then`/`else` branch that applies, selected exactly as\n// effectiveProperties selects the branch it merges.\nfunction loadListenersOf(schema: JsonSchemaObject, value: Record<string, unknown>): BoundListener[] {\n const bound = loadListenersAt(schema[\"x-on-load\"], \"#/x-on-load\");\n for (const { branch, pointer } of selectedBranches(schema, value)) {\n bound.push(...loadListenersAt(branch[\"x-on-load\"], `#${pointer}/x-on-load`));\n }\n for (const [index, clause] of (schema.allOf ?? []).entries()) {\n if (clause.if === undefined && clause.then === undefined) {\n bound.push(...loadListenersAt(clause[\"x-on-load\"], `#/allOf/${index}/x-on-load`));\n continue;\n }\n const branch = matchesIf(clause.if, value) ? \"then\" : \"else\";\n bound.push(...loadListenersAt(clause[branch]?.[\"x-on-load\"], `#/allOf/${index}/${branch}/x-on-load`));\n }\n return bound;\n}\n\nfunction loadListenersAt(listeners: unknown, pointer: string): BoundListener[] {\n if (listeners === undefined) return [];\n if (!Array.isArray(listeners)) {\n throw new Error(`x-on-load at ${pointer} must be an array of listeners, got ${typeof listeners}`);\n }\n return listeners.map((listener: ChangeListener, index) => ({\n listener,\n source: { label: `x-on-load at ${pointer}/${index}`, key: \"\", load: true },\n }));\n}\n\nfunction changeSource(key: string): ListenerSource {\n return { label: `x-on-change on \"${key}\"`, key, load: false };\n}\n\n// applyChangeEffects commits `next` at `key` and runs the value actions\n// (reset/set) of that key's listeners against the post-edit object. A target\n// whose value actually changes fires its own listeners in turn; each key fires\n// at most once per commit, so a cycle ends. When `root` is the edited object\n// itself (the top level), expressions see the post-edit value as root too.\nexport function applyChangeEffects(\n schema: JsonSchemaObject,\n edit: ListenerOptions & { value: Record<string, unknown>; key: string; next: unknown },\n): Record<string, unknown> {\n let current: Record<string, unknown> = { ...edit.value, [edit.key]: edit.next };\n const known = declaredKeys(schema);\n const fired = new Set<string>();\n const queue = [edit.key];\n for (let source = queue.shift(); source !== undefined; source = queue.shift()) {\n if (fired.has(source)) continue;\n fired.add(source);\n const { properties } = effectiveProperties(schema, current);\n const options: ListenerOptions = {\n root: edit.root === edit.value ? current : edit.root,\n ...(edit.evaluate ? { evaluate: edit.evaluate } : {}),\n };\n for (const listener of listenersOf(source, properties[source])) {\n const actions = selectActions({ listener, source: changeSource(source), self: current, known, options });\n for (const [target, nextValue] of valueChanges(actions, properties)) {\n if (Object.is(current[target], nextValue)) continue;\n current = { ...current };\n if (nextValue === undefined) delete current[target];\n else current[target] = nextValue;\n queue.push(target);\n }\n }\n }\n return current;\n}\n\nfunction valueChanges(\n actions: ChangeActions,\n properties: Record<string, JsonSchemaProperty>,\n): [string, unknown][] {\n return [\n ...list(actions, \"reset\").map((target): [string, unknown] => {\n const fallback = properties[target]?.default;\n return [target, fallback === undefined ? undefined : cloneSchemaDefault(fallback)];\n }),\n ...Object.entries(actions.set ?? {}).map(([target, v]): [string, unknown] => [target, cloneSchemaDefault(v)]),\n ];\n}\n\nfunction listenersOf(key: string, prop: JsonSchemaProperty | undefined): ChangeListener[] {\n const listeners = prop?.[\"x-on-change\"];\n if (listeners === undefined) return [];\n if (!Array.isArray(listeners)) {\n throw new Error(`\"${key}\": x-on-change must be an array of listeners, got ${typeof listeners}`);\n }\n return listeners;\n}\n\n// selectActions validates both branches of a listener (so a schema error\n// surfaces whichever branch is live) and returns the one that applies now.\nfunction selectActions({\n listener,\n source,\n self,\n known,\n options,\n}: {\n listener: ChangeListener;\n source: ListenerSource;\n self: Record<string, unknown>;\n known: Set<string>;\n options: ListenerOptions;\n}): ChangeActions {\n validateActions(source, listener, known);\n if (listener.else) validateActions(source, listener.else, known);\n return listenerHolds(listener, source, self, options) ? listener : (listener.else ?? {});\n}\n\n// listenerHolds evaluates `when` against the source's subject: the property's\n// value for x-on-change, the object itself for x-on-load.\nfunction listenerHolds(\n listener: ChangeListener,\n { label, key, load }: ListenerSource,\n self: Record<string, unknown>,\n options: ListenerOptions,\n): boolean {\n if (listener.when === undefined) return true;\n const { expr, ...predicate } = listener.when;\n const hasPredicate = Object.keys(predicate).length > 0;\n const subject = load ? self : self[key];\n if (!hasPredicate && expr === undefined) {\n throw new Error(`${label}: when states nothing it can evaluate`);\n }\n if (expr !== undefined && typeof expr !== \"string\") {\n throw new Error(`${label}: when.expr must be a string, got ${typeof expr}`);\n }\n if (expr !== undefined && !options.evaluate) {\n throw new Error(`${label}: when.expr \"${expr}\" needs the form's expressionEvaluator`);\n }\n if (hasPredicate) {\n const holds = evaluatePredicate(predicate, subject);\n if (holds === undefined) {\n throw new Error(`${label}: when states nothing it can evaluate (${JSON.stringify(predicate)})`);\n }\n if (!holds) return false;\n }\n if (expr === undefined || !options.evaluate) return true;\n const result: unknown = options.evaluate({ expr, key, value: subject, self, root: options.root });\n if (typeof result !== \"boolean\") {\n throw new Error(`${label}: expressionEvaluator returned ${typeof result} for \"${expr}\", expected boolean`);\n }\n return result;\n}\n\nfunction validateActions(source: ListenerSource, actions: ChangeActions, known: Set<string>): void {\n const { label } = source;\n if (actions.set !== undefined && !isPlainObject(actions.set)) {\n throw new Error(`${label}: set must be an object of target → value`);\n }\n if (source.load) {\n const local = LOCAL_ACTIONS.find((name) => actions[name] !== undefined);\n if (local) {\n throw new Error(`${label}: ${local} is not allowed in x-on-load, which only derives state (hide/show/enable/disable/patch)`);\n }\n }\n const setKeys = Object.keys(actions.set ?? {});\n for (const name of LOCAL_ACTIONS) {\n const targets = name === \"set\" ? setKeys : list(actions, name);\n const path = targets.find(isPathTarget);\n if (path !== undefined) {\n throw new Error(`${label}: ${name} \"${path}\" cannot take a path; value and required actions act on sibling keys only`);\n }\n }\n for (const target of [...LIST_NAMES.flatMap((name) => list(actions, name)), ...setKeys]) {\n validateTarget(label, target, known);\n }\n const pairs: [string, string[], string, string[]][] = [\n ...CONTRADICTIONS.map(([a, b]): [string, string[], string, string[]] => [a, list(actions, a), b, list(actions, b)]),\n [\"reset\", list(actions, \"reset\"), \"set\", setKeys],\n ];\n for (const [a, left, b, right] of pairs) {\n const clash = left.find((target) => right.includes(target));\n if (clash !== undefined) {\n throw new Error(`${label}: both ${a} and ${b} \"${clash}\"`);\n }\n }\n validatePatch(label, actions, known);\n}\n\n// validateTarget checks a target's grammar and that its first segment is a key\n// the schema declares in some branch.\nfunction validateTarget(label: string, target: string, known: Set<string>): void {\n if (isPathTarget(target) && known.has(target)) {\n throw new Error(`${label}: target \"${target}\" is both a declared key and a path`);\n }\n const [first = \"\"] = targetSegments(label, target);\n if (!known.has(first)) throw new Error(`${label}: unknown target \"${target}\"`);\n}\n\n// validatePatch checks a `patch`: an object of keyword objects on known\n// targets, no denied keyword, and no keyword a verb in the same actions sets.\nfunction validatePatch(label: string, actions: ChangeActions, known: Set<string>): void {\n const patch: unknown = actions.patch;\n if (patch === undefined) return;\n if (!isPlainObject(patch)) {\n throw new Error(`${label}: patch must be an object of target → keywords`);\n }\n for (const [target, keywords] of Object.entries(patch)) {\n validateTarget(label, target, known);\n if (!isPlainObject(keywords)) {\n throw new Error(`${label}: patch \"${target}\" must be an object of keywords`);\n }\n for (const keyword of Object.keys(keywords)) {\n const denied = PATCH_DENIED[keyword];\n if (denied) throw new Error(`${label}: patch \"${target}\" may not set ${keyword} (${denied})`);\n }\n for (const [verb, keyword] of STATE_FLAGS) {\n if (keyword in keywords && list(actions, verb).includes(target)) {\n throw new Error(`${label}: both ${verb} and patch ${keyword} on \"${target}\"`);\n }\n }\n }\n}\n\nfunction list(actions: ChangeActions, name: ListName): string[] {\n const targets = actions[name];\n if (targets === undefined) return [];\n if (!Array.isArray(targets)) {\n throw new Error(`x-on-change: ${name} must be an array of property keys, got ${typeof targets}`);\n }\n return targets;\n}\n\n// Every key the schema can declare in any branch — a listener may target a\n// field that only exists while some `allOf` branch is live.\nfunction declaredKeys(schema: JsonSchemaObject): Set<string> {\n const keys = new Set(Object.keys(schema.properties ?? {}));\n for (const branch of declaredBranches(schema)) {\n for (const key of Object.keys(branch.properties ?? {})) keys.add(key);\n }\n for (const clause of schema.allOf ?? []) {\n // A member's `else` may itself be an if/then/else chain (an answer that is\n // handled, open or not applicable), so walk every branch it can select.\n for (const branch of [clause, ...declaredBranches(clause)]) {\n for (const key of Object.keys(branch?.properties ?? {})) keys.add(key);\n }\n }\n return keys;\n}\n"],"mappings":";;;;;AA+CA,IAAM,gBAA8D;CAAC;CAAW;CAAY;CAAS;AAAK;AAE1G,IAAM,cAAgE;CACpE;EAAC;EAAQ;EAAY;CAAI;CACzB;EAAC;EAAQ;EAAY;CAAK;CAC1B;EAAC;EAAW;EAAc;CAAI;CAC9B;EAAC;EAAU;EAAc;CAAK;AAChC;AAEA,IAAM,iBAAyC;CAC7C,CAAC,QAAQ,MAAM;CACf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AAK,MAAM,CAAC,MAAM,YAAY,aAC5B,IAAI,WAAW,YAAY,KAAK,SAAS,IAAI,CAAC,CAAC,SAAS,MAAM,GAC5D,MAAM,IAAI,MAAM,GAAG,MAAM,SAAS,KAAK,aAAa,QAAQ,OAAO,OAAO,EAAE;CAGlF;AACF;AAEA,SAAS,KAAK,SAAwB,MAA0B;CAC9D,MAAM,UAAU,QAAQ;CACxB,IAAI,YAAY,KAAA,GAAW,OAAO,CAAC;CACnC,IAAI,CAAC,MAAM,QAAQ,OAAO,GACxB,MAAM,IAAI,MAAM,gBAAgB,KAAK,0CAA0C,OAAO,SAAS;CAEjG,OAAO;AACT;AAIA,SAAS,aAAa,QAAuC;CAC3D,MAAM,OAAO,IAAI,IAAI,OAAO,KAAK,OAAO,cAAc,CAAC,CAAC,CAAC;CACzD,KAAK,MAAM,UAAU,iBAAiB,MAAM,GAC1C,KAAK,MAAM,OAAO,OAAO,KAAK,OAAO,cAAc,CAAC,CAAC,GAAG,KAAK,IAAI,GAAG;CAEtE,KAAK,MAAM,UAAU,OAAO,SAAS,CAAC,GAGpC,KAAK,MAAM,UAAU,CAAC,QAAQ,GAAG,iBAAiB,MAAM,CAAC,GACvD,KAAK,MAAM,OAAO,OAAO,KAAK,QAAQ,cAAc,CAAC,CAAC,GAAG,KAAK,IAAI,GAAG;CAGzE,OAAO;AACT"}
@@ -44,10 +44,7 @@ function rehydrateRefs(schema) {
44
44
  siblings[k] = walk(v);
45
45
  hasSiblings = true;
46
46
  }
47
- return hasSiblings ? {
48
- ...resolved,
49
- ...siblings
50
- } : resolved;
47
+ return hasSiblings ? mergeRefSiblings(resolved, siblings) : resolved;
51
48
  }
52
49
  let changed = false;
53
50
  const out = {};
@@ -82,6 +79,34 @@ function rehydrateRefs(schema) {
82
79
  $defs: walk($defs)
83
80
  } : resolved;
84
81
  }
82
+ function mergeRefSiblings(base, local) {
83
+ const merged = {
84
+ ...base,
85
+ ...local
86
+ };
87
+ if (isRecord(base.properties) && isRecord(local.properties)) merged.properties = {
88
+ ...base.properties,
89
+ ...local.properties
90
+ };
91
+ if (Array.isArray(base.required) && Array.isArray(local.required)) merged.required = [.../* @__PURE__ */ new Set([...base.required, ...local.required])];
92
+ const allOf = [...Array.isArray(base.allOf) ? base.allOf : [], ...Array.isArray(local.allOf) ? local.allOf : []];
93
+ const bothConditional = base.if !== void 0 && local.if !== void 0;
94
+ if (bothConditional) {
95
+ delete merged.if;
96
+ delete merged.then;
97
+ delete merged.else;
98
+ allOf.push(conditionalOf(base), conditionalOf(local));
99
+ }
100
+ if (bothConditional || Array.isArray(base.allOf) && Array.isArray(local.allOf)) merged.allOf = allOf;
101
+ return merged;
102
+ }
103
+ function conditionalOf(node) {
104
+ return Object.fromEntries([
105
+ "if",
106
+ "then",
107
+ "else"
108
+ ].filter((key) => node[key] !== void 0).map((key) => [key, node[key]]));
109
+ }
85
110
  function isLocalPointerRef(ref) {
86
111
  if (!ref.startsWith("#")) return false;
87
112
  if (ref === "#") return true;