@lattice-php/lattice 0.17.2 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (748) hide show
  1. package/README.md +1 -1
  2. package/dist/action/components/action-form.d.ts +2 -2
  3. package/dist/action/components/action-form.js +11 -11
  4. package/dist/action/components/action-form.js.map +1 -1
  5. package/dist/action/components/action-group.d.ts +1 -1
  6. package/dist/action/components/action-group.js +6 -4
  7. package/dist/action/components/action-group.js.map +1 -1
  8. package/dist/action/components/action-trigger-provider.d.ts +10 -0
  9. package/dist/action/components/action-trigger-provider.js +24 -0
  10. package/dist/action/components/action-trigger-provider.js.map +1 -0
  11. package/dist/action/components/action.d.ts +1 -1
  12. package/dist/action/components/action.js +4 -4
  13. package/dist/action/components/action.js.map +1 -1
  14. package/dist/action/{use-action.d.ts → hooks/use-action.d.ts} +1 -1
  15. package/dist/action/{use-action.js → hooks/use-action.js} +7 -7
  16. package/dist/action/hooks/use-action.js.map +1 -0
  17. package/dist/action/index.d.ts +10 -1
  18. package/dist/action/index.js +8 -13
  19. package/dist/action/{run-action.d.ts → lib/run-action.d.ts} +1 -1
  20. package/dist/action/{run-action.js → lib/run-action.js} +2 -2
  21. package/dist/action/lib/run-action.js.map +1 -0
  22. package/dist/action/plugin.d.ts +1 -0
  23. package/dist/action/plugin.js +15 -0
  24. package/dist/action/plugin.js.map +1 -0
  25. package/dist/appearance/index.d.ts +4 -1
  26. package/dist/appearance/index.js +11 -2
  27. package/dist/appearance/index.js.map +1 -1
  28. package/dist/chat/components/chat-box.d.ts +1 -1
  29. package/dist/chat/components/chat-box.js +2 -2
  30. package/dist/chat/components/chat-box.js.map +1 -1
  31. package/dist/chat/components/message-list.d.ts +1 -1
  32. package/dist/chat/components/message-list.js.map +1 -1
  33. package/dist/chat/components/message.d.ts +1 -1
  34. package/dist/chat/components/message.js.map +1 -1
  35. package/dist/chat/components/prompt-input.js +1 -1
  36. package/dist/chat/components/prompt-input.js.map +1 -1
  37. package/dist/chat/{use-chat.d.ts → hooks/use-chat.d.ts} +1 -1
  38. package/dist/chat/{use-chat.js → hooks/use-chat.js} +2 -2
  39. package/dist/chat/hooks/use-chat.js.map +1 -0
  40. package/dist/chat/index.d.ts +4 -1
  41. package/dist/chat/index.js +3 -17
  42. package/dist/chat/{transport.d.ts → lib/transport.d.ts} +2 -2
  43. package/dist/chat/{transport.js → lib/transport.js} +2 -2
  44. package/dist/chat/lib/transport.js.map +1 -0
  45. package/dist/chat/parts/text.d.ts +1 -1
  46. package/dist/chat/parts/tool-call.d.ts +1 -1
  47. package/dist/chat/plugin.d.ts +2 -0
  48. package/dist/chat/plugin.js +17 -0
  49. package/dist/chat/plugin.js.map +1 -0
  50. package/dist/chat/types.d.ts +2 -2
  51. package/dist/clipboard/index.d.ts +1 -2
  52. package/dist/clipboard/index.js +1 -10
  53. package/dist/clipboard/index.js.map +1 -1
  54. package/dist/core/api.d.ts +1 -1
  55. package/dist/core/api.js.map +1 -1
  56. package/dist/core/headers.js.map +1 -1
  57. package/dist/core/{column-sizing.d.ts → hooks/column-sizing.d.ts} +2 -2
  58. package/dist/core/{column-sizing.js → hooks/column-sizing.js} +1 -1
  59. package/dist/core/hooks/column-sizing.js.map +1 -0
  60. package/dist/core/{use-column-resizing.d.ts → hooks/use-column-resizing.d.ts} +2 -1
  61. package/dist/core/{use-column-resizing.js → hooks/use-column-resizing.js} +59 -31
  62. package/dist/core/hooks/use-column-resizing.js.map +1 -0
  63. package/dist/core/index.d.ts +13 -0
  64. package/dist/core/index.js +10 -0
  65. package/dist/core/materialize.d.ts +9 -0
  66. package/dist/core/materialize.js +39 -0
  67. package/dist/core/materialize.js.map +1 -0
  68. package/dist/core/nodes.d.ts +6 -1
  69. package/dist/core/nodes.js +8 -1
  70. package/dist/core/nodes.js.map +1 -1
  71. package/dist/core/registry-context.d.ts +3 -3
  72. package/dist/core/registry-context.js.map +1 -1
  73. package/dist/core/registry.d.ts +5 -3
  74. package/dist/core/registry.js.map +1 -1
  75. package/dist/core/renderer.d.ts +1 -1
  76. package/dist/core/renderer.js +4 -6
  77. package/dist/core/renderer.js.map +1 -1
  78. package/dist/core/test-id.d.ts +1 -1
  79. package/dist/core/types.d.ts +1 -1
  80. package/dist/create-app.d.ts +3 -3
  81. package/dist/effects/dispatch.d.ts +2 -2
  82. package/dist/effects/registry.d.ts +4 -3
  83. package/dist/effects/registry.js +7 -7
  84. package/dist/effects/registry.js.map +1 -1
  85. package/dist/effects/use-effect-dispatcher.d.ts +1 -1
  86. package/dist/{events/event-bridge.d.ts → event-bridge.d.ts} +2 -3
  87. package/dist/{events/event-bridge.js → event-bridge.js} +4 -11
  88. package/dist/event-bridge.js.map +1 -0
  89. package/dist/events/event-names.d.ts +0 -3
  90. package/dist/events/event-names.js +0 -3
  91. package/dist/events/event-names.js.map +1 -1
  92. package/dist/form/components/base/field.d.ts +1 -1
  93. package/dist/form/components/base/field.js +5 -5
  94. package/dist/form/components/base/field.js.map +1 -1
  95. package/dist/form/components/base/submit-button.d.ts +1 -1
  96. package/dist/form/components/base/submit-button.js +3 -3
  97. package/dist/form/components/base/submit-button.js.map +1 -1
  98. package/dist/form/components/fields/{block-add-menu.d.ts → add-row-menu.d.ts} +3 -3
  99. package/dist/form/components/fields/{block-add-menu.js → add-row-menu.js} +10 -10
  100. package/dist/form/components/fields/add-row-menu.js.map +1 -0
  101. package/dist/form/components/fields/builder.d.ts +1 -1
  102. package/dist/form/components/fields/builder.js +80 -75
  103. package/dist/form/components/fields/builder.js.map +1 -1
  104. package/dist/form/components/fields/checkbox.d.ts +1 -1
  105. package/dist/form/components/fields/checkbox.js +12 -9
  106. package/dist/form/components/fields/checkbox.js.map +1 -1
  107. package/dist/form/components/fields/choice.d.ts +1 -1
  108. package/dist/form/components/fields/choice.js +4 -4
  109. package/dist/form/components/fields/choice.js.map +1 -1
  110. package/dist/form/components/fields/date-input.d.ts +1 -1
  111. package/dist/form/components/fields/date-picker-field.js +2 -2
  112. package/dist/form/components/fields/date-picker-field.js.map +1 -1
  113. package/dist/form/components/fields/date-picker.d.ts +1 -1
  114. package/dist/form/components/fields/date-time-input.d.ts +1 -1
  115. package/dist/form/components/fields/file-upload.d.ts +1 -1
  116. package/dist/form/components/fields/file-upload.js +4 -4
  117. package/dist/form/components/fields/file-upload.js.map +1 -1
  118. package/dist/form/components/fields/hidden-input.d.ts +1 -1
  119. package/dist/form/components/fields/hidden-input.js +1 -1
  120. package/dist/form/components/fields/hidden-input.js.map +1 -1
  121. package/dist/form/components/fields/number-input.d.ts +1 -1
  122. package/dist/form/components/fields/number-input.js +2 -2
  123. package/dist/form/components/fields/number-input.js.map +1 -1
  124. package/dist/form/components/fields/otp-input.d.ts +1 -1
  125. package/dist/form/components/fields/otp-input.js +1 -1
  126. package/dist/form/components/fields/otp-input.js.map +1 -1
  127. package/dist/form/components/fields/password-input.d.ts +1 -1
  128. package/dist/form/components/fields/password-input.js +6 -6
  129. package/dist/form/components/fields/password-input.js.map +1 -1
  130. package/dist/form/components/fields/repeater-rows.d.ts +6 -1
  131. package/dist/form/components/fields/repeater-rows.js +9 -5
  132. package/dist/form/components/fields/repeater-rows.js.map +1 -1
  133. package/dist/form/components/fields/repeater.d.ts +1 -1
  134. package/dist/form/components/fields/repeater.js +57 -48
  135. package/dist/form/components/fields/repeater.js.map +1 -1
  136. package/dist/form/components/fields/rich-editor-field.d.ts +1 -1
  137. package/dist/form/components/fields/rich-editor-field.js +8 -6
  138. package/dist/form/components/fields/rich-editor-field.js.map +1 -1
  139. package/dist/form/components/fields/rich-editor.d.ts +1 -1
  140. package/dist/form/components/fields/row-action-menu.d.ts +2 -2
  141. package/dist/form/components/fields/row-actions.js +1 -1
  142. package/dist/form/components/fields/row-actions.js.map +1 -1
  143. package/dist/form/components/fields/row-item.d.ts +3 -3
  144. package/dist/form/components/fields/row-item.js +3 -2
  145. package/dist/form/components/fields/row-item.js.map +1 -1
  146. package/dist/form/components/fields/row-key-inputs.d.ts +7 -0
  147. package/dist/form/components/fields/row-key-inputs.js +16 -0
  148. package/dist/form/components/fields/row-key-inputs.js.map +1 -0
  149. package/dist/form/components/fields/row-templates.d.ts +9 -0
  150. package/dist/form/components/fields/row-templates.js +14 -0
  151. package/dist/form/components/fields/row-templates.js.map +1 -0
  152. package/dist/form/components/fields/select.d.ts +1 -1
  153. package/dist/form/components/fields/select.js +23 -13
  154. package/dist/form/components/fields/select.js.map +1 -1
  155. package/dist/form/components/fields/simple-field.d.ts +2 -2
  156. package/dist/form/components/fields/simple-field.js +2 -2
  157. package/dist/form/components/fields/simple-field.js.map +1 -1
  158. package/dist/form/components/fields/table-rows.d.ts +3 -3
  159. package/dist/form/components/fields/table-rows.js +13 -13
  160. package/dist/form/components/fields/table-rows.js.map +1 -1
  161. package/dist/form/components/fields/text-input.d.ts +1 -1
  162. package/dist/form/components/fields/text-input.js +2 -2
  163. package/dist/form/components/fields/text-input.js.map +1 -1
  164. package/dist/form/components/fields/textarea.d.ts +1 -1
  165. package/dist/form/components/fields/textarea.js +1 -1
  166. package/dist/form/components/fields/textarea.js.map +1 -1
  167. package/dist/form/components/fields/time-input.d.ts +1 -1
  168. package/dist/form/components/fields/time-input.js +3 -3
  169. package/dist/form/components/fields/time-input.js.map +1 -1
  170. package/dist/form/components/fields/time-picker.d.ts +1 -1
  171. package/dist/form/components/fields/toggle.d.ts +1 -1
  172. package/dist/form/components/fields/toggle.js +10 -9
  173. package/dist/form/components/fields/toggle.js.map +1 -1
  174. package/dist/form/components/fields/use-row-collection.d.ts +1 -1
  175. package/dist/form/components/fields/use-row-collection.js +2 -2
  176. package/dist/form/components/fields/use-row-collection.js.map +1 -1
  177. package/dist/form/components/form.d.ts +1 -1
  178. package/dist/form/components/form.js +6 -6
  179. package/dist/form/components/form.js.map +1 -1
  180. package/dist/form/components/index.d.ts +17 -17
  181. package/dist/form/embed.d.ts +17 -0
  182. package/dist/form/embed.js +10 -0
  183. package/dist/form/{components → hooks}/context.d.ts +3 -0
  184. package/dist/form/{components → hooks}/context.js +2 -1
  185. package/dist/form/hooks/context.js.map +1 -0
  186. package/dist/form/{components → hooks}/field-scope.js +3 -3
  187. package/dist/form/hooks/field-scope.js.map +1 -0
  188. package/dist/form/{components → hooks}/prefill-context.js +1 -1
  189. package/dist/form/hooks/prefill-context.js.map +1 -0
  190. package/dist/form/{components → hooks}/resolved-nodes.d.ts +1 -1
  191. package/dist/form/{components → hooks}/resolved-nodes.js +2 -2
  192. package/dist/form/hooks/resolved-nodes.js.map +1 -0
  193. package/dist/form/{components → hooks}/row-layout-context.js +1 -1
  194. package/dist/form/hooks/row-layout-context.js.map +1 -0
  195. package/dist/form/{components → hooks}/use-controlled-field.d.ts +2 -2
  196. package/dist/form/{components → hooks}/use-controlled-field.js +6 -5
  197. package/dist/form/hooks/use-controlled-field.js.map +1 -0
  198. package/dist/form/hooks/use-dependent-field.d.ts +3 -0
  199. package/dist/form/{components → hooks}/use-dependent-field.js +6 -6
  200. package/dist/form/hooks/use-dependent-field.js.map +1 -0
  201. package/dist/form/{components → hooks}/use-field-commit.d.ts +5 -0
  202. package/dist/form/{components → hooks}/use-field-commit.js +9 -2
  203. package/dist/form/hooks/use-field-commit.js.map +1 -0
  204. package/dist/form/{components → hooks}/use-form-resolver.d.ts +2 -2
  205. package/dist/form/{components → hooks}/use-form-resolver.js +5 -5
  206. package/dist/form/hooks/use-form-resolver.js.map +1 -0
  207. package/dist/form/{components → hooks}/use-seed-default.js +1 -1
  208. package/dist/form/hooks/use-seed-default.js.map +1 -0
  209. package/dist/form/{components → hooks}/values.d.ts +3 -1
  210. package/dist/form/hooks/values.js +136 -0
  211. package/dist/form/hooks/values.js.map +1 -0
  212. package/dist/form/index.d.ts +4 -1
  213. package/dist/form/index.js +3 -30
  214. package/dist/form/{components → lib}/conditions.d.ts +2 -1
  215. package/dist/form/{components → lib}/conditions.js +12 -2
  216. package/dist/form/lib/conditions.js.map +1 -0
  217. package/dist/form/lib/field-dom-name.d.ts +1 -0
  218. package/dist/form/lib/field-dom-name.js +10 -0
  219. package/dist/form/lib/field-dom-name.js.map +1 -0
  220. package/dist/form/{components → lib}/field-props.d.ts +2 -3
  221. package/dist/form/{components → lib}/field-props.js +1 -1
  222. package/dist/form/lib/field-props.js.map +1 -0
  223. package/dist/form/{components → lib}/form-path.js +1 -1
  224. package/dist/form/lib/form-path.js.map +1 -0
  225. package/dist/form/{components → lib}/form-transport.d.ts +1 -1
  226. package/dist/form/lib/form-transport.js +21 -0
  227. package/dist/form/lib/form-transport.js.map +1 -0
  228. package/dist/form/lib/override-keys.js +12 -0
  229. package/dist/form/lib/override-keys.js.map +1 -0
  230. package/dist/form/{components → lib}/prefill-targets.d.ts +2 -2
  231. package/dist/form/{components → lib}/prefill-targets.js +4 -5
  232. package/dist/form/lib/prefill-targets.js.map +1 -0
  233. package/dist/form/plugin.d.ts +1 -0
  234. package/dist/form/plugin.js +47 -0
  235. package/dist/form/plugin.js.map +1 -0
  236. package/dist/form/toolkit.d.ts +17 -0
  237. package/dist/form/toolkit.js +14 -0
  238. package/dist/form/{components/types.d.ts → types.d.ts} +3 -3
  239. package/dist/format/number.d.ts +1 -1
  240. package/dist/format/value.d.ts +1 -1
  241. package/dist/i18n/backend.d.ts +1 -1
  242. package/dist/i18n/config.d.ts +1 -1
  243. package/dist/i18n/index.d.ts +13 -13
  244. package/dist/i18n/locale-reload.js +1 -1
  245. package/dist/i18n/locale-reload.js.map +1 -1
  246. package/dist/i18n/locale.js.map +1 -1
  247. package/dist/i18n/page-props.d.ts +1 -1
  248. package/dist/i18n/timezone.js.map +1 -1
  249. package/dist/i18n/translatable.d.ts +1 -1
  250. package/dist/icons/icon-renderer.js.map +1 -1
  251. package/dist/icons/index.d.ts +4 -4
  252. package/dist/icons/sprite.js.map +1 -1
  253. package/dist/index.d.ts +37 -38
  254. package/dist/index.js +10 -9
  255. package/dist/inertia.js +1 -1
  256. package/dist/lattice.css +12 -10
  257. package/dist/layout/{breadcrumbs.d.ts → components/breadcrumbs.d.ts} +1 -1
  258. package/dist/layout/{breadcrumbs.js → components/breadcrumbs.js} +2 -2
  259. package/dist/layout/components/breadcrumbs.js.map +1 -0
  260. package/dist/layout/{callouts.d.ts → components/callouts.d.ts} +1 -1
  261. package/dist/layout/{callouts.js → components/callouts.js} +7 -7
  262. package/dist/layout/components/callouts.js.map +1 -0
  263. package/dist/layout/{dropdown.d.ts → components/dropdown.d.ts} +1 -1
  264. package/dist/layout/{dropdown.js → components/dropdown.js} +2 -2
  265. package/dist/layout/components/dropdown.js.map +1 -0
  266. package/dist/layout/{menu-item.d.ts → components/menu-item.d.ts} +1 -1
  267. package/dist/layout/{menu-item.js → components/menu-item.js} +9 -8
  268. package/dist/layout/components/menu-item.js.map +1 -0
  269. package/dist/layout/{menu.d.ts → components/menu.d.ts} +1 -1
  270. package/dist/layout/{menu.js → components/menu.js} +2 -2
  271. package/dist/layout/components/menu.js.map +1 -0
  272. package/dist/layout/{outlet.d.ts → components/outlet.d.ts} +1 -1
  273. package/dist/layout/{outlet.js → components/outlet.js} +2 -2
  274. package/dist/layout/components/outlet.js.map +1 -0
  275. package/dist/layout/{popover.js → components/popover.js} +4 -4
  276. package/dist/layout/components/popover.js.map +1 -0
  277. package/dist/layout/{schema-layout.js → components/schema-layout.js} +3 -3
  278. package/dist/layout/components/schema-layout.js.map +1 -0
  279. package/dist/layout/{sidebar.d.ts → components/sidebar.d.ts} +1 -1
  280. package/dist/layout/{sidebar.js → components/sidebar.js} +5 -5
  281. package/dist/layout/components/sidebar.js.map +1 -0
  282. package/dist/layout/{topbar.d.ts → components/topbar.d.ts} +1 -1
  283. package/dist/layout/{topbar.js → components/topbar.js} +3 -3
  284. package/dist/layout/components/topbar.js.map +1 -0
  285. package/dist/layout/{context.d.ts → hooks/context.d.ts} +1 -1
  286. package/dist/layout/{context.js → hooks/context.js} +2 -2
  287. package/dist/layout/hooks/context.js.map +1 -0
  288. package/dist/layout/index.d.ts +4 -4
  289. package/dist/layout/index.js +4 -4
  290. package/dist/layout/plugin.d.ts +2 -0
  291. package/dist/layout/{components.js → plugin.js} +10 -10
  292. package/dist/layout/plugin.js.map +1 -0
  293. package/dist/notifications/api.d.ts +1 -1
  294. package/dist/notifications/components/notification-item.d.ts +1 -1
  295. package/dist/notifications/components/notification-item.js.map +1 -1
  296. package/dist/notifications/components/notification-list.d.ts +2 -2
  297. package/dist/notifications/components/notification-list.js +1 -1
  298. package/dist/notifications/components/notification-list.js.map +1 -1
  299. package/dist/notifications/components/notifications-echo.d.ts +1 -1
  300. package/dist/notifications/components/notifications-echo.js.map +1 -1
  301. package/dist/notifications/components/notifications.d.ts +1 -1
  302. package/dist/notifications/components/notifications.js +3 -3
  303. package/dist/notifications/components/notifications.js.map +1 -1
  304. package/dist/notifications/index.d.ts +2 -1
  305. package/dist/notifications/index.js +1 -10
  306. package/dist/notifications/plugin.d.ts +2 -0
  307. package/dist/notifications/plugin.js +11 -0
  308. package/dist/notifications/plugin.js.map +1 -0
  309. package/dist/notifications/store.d.ts +1 -1
  310. package/dist/notifications/types.d.ts +1 -1
  311. package/dist/page.d.ts +1 -1
  312. package/dist/provider-base.d.ts +2 -2
  313. package/dist/provider-base.js +5 -4
  314. package/dist/provider-base.js.map +1 -1
  315. package/dist/provider.d.ts +3 -3
  316. package/dist/realtime/build-effects.d.ts +2 -2
  317. package/dist/realtime/listeners.d.ts +1 -1
  318. package/dist/realtime/subscriptions.d.ts +1 -1
  319. package/dist/registry.d.ts +1 -1
  320. package/dist/registry.js +9 -9
  321. package/dist/registry.js.map +1 -1
  322. package/dist/remote/components/data-list.d.ts +2 -2
  323. package/dist/remote/components/data-list.js +1 -34
  324. package/dist/remote/components/data-list.js.map +1 -1
  325. package/dist/remote/index.d.ts +1 -1
  326. package/dist/remote/index.js +1 -10
  327. package/dist/remote/plugin.d.ts +2 -0
  328. package/dist/remote/plugin.js +11 -0
  329. package/dist/remote/plugin.js.map +1 -0
  330. package/dist/table/components/bulk-bar.d.ts +1 -1
  331. package/dist/table/components/bulk-bar.js +4 -4
  332. package/dist/table/components/bulk-bar.js.map +1 -1
  333. package/dist/table/components/cells/badge-cell.d.ts +1 -1
  334. package/dist/table/components/cells/badge-cell.js +1 -1
  335. package/dist/table/components/cells/badge-cell.js.map +1 -1
  336. package/dist/table/components/cells/boolean-cell.d.ts +1 -1
  337. package/dist/table/components/cells/boolean-cell.js.map +1 -1
  338. package/dist/table/components/cells/icon-cell.d.ts +1 -1
  339. package/dist/table/components/cells/icon-cell.js.map +1 -1
  340. package/dist/table/components/cells/image-cell.d.ts +1 -1
  341. package/dist/table/components/cells/image-cell.js +1 -1
  342. package/dist/table/components/cells/image-cell.js.map +1 -1
  343. package/dist/table/components/cells/money-cell.d.ts +1 -1
  344. package/dist/table/components/cells/money-cell.js +1 -1
  345. package/dist/table/components/cells/money-cell.js.map +1 -1
  346. package/dist/table/components/cells/number-cell.d.ts +1 -1
  347. package/dist/table/components/cells/number-cell.js +1 -1
  348. package/dist/table/components/cells/number-cell.js.map +1 -1
  349. package/dist/table/components/cells/stack-cell.d.ts +1 -1
  350. package/dist/table/components/cells/stack-cell.js +3 -7
  351. package/dist/table/components/cells/stack-cell.js.map +1 -1
  352. package/dist/table/components/cells/text-cell.d.ts +1 -1
  353. package/dist/table/components/cells/text-cell.js +4 -4
  354. package/dist/table/components/cells/text-cell.js.map +1 -1
  355. package/dist/table/components/column-filter-control.d.ts +3 -3
  356. package/dist/table/components/column-filter-control.js +34 -19
  357. package/dist/table/components/column-filter-control.js.map +1 -1
  358. package/dist/table/components/column-header.d.ts +1 -1
  359. package/dist/table/components/column-header.js +7 -7
  360. package/dist/table/components/column-header.js.map +1 -1
  361. package/dist/table/components/column-visibility-menu.d.ts +1 -1
  362. package/dist/table/components/column-visibility-menu.js +3 -3
  363. package/dist/table/components/column-visibility-menu.js.map +1 -1
  364. package/dist/table/components/filter-bar.d.ts +9 -7
  365. package/dist/table/components/filter-bar.js +62 -52
  366. package/dist/table/components/filter-bar.js.map +1 -1
  367. package/dist/table/components/filter-controls.d.ts +5 -9
  368. package/dist/table/components/filter-controls.js +96 -224
  369. package/dist/table/components/filter-controls.js.map +1 -1
  370. package/dist/table/components/filter-value-input.d.ts +1 -1
  371. package/dist/table/components/filter-value-input.js +1 -1
  372. package/dist/table/components/filter-value-input.js.map +1 -1
  373. package/dist/table/components/pagination.d.ts +2 -2
  374. package/dist/table/components/pagination.js.map +1 -1
  375. package/dist/table/components/sort-bar.d.ts +1 -1
  376. package/dist/table/components/sort-bar.js +2 -2
  377. package/dist/table/components/sort-bar.js.map +1 -1
  378. package/dist/table/components/table-action-node.d.ts +1 -1
  379. package/dist/table/components/table-action-node.js +1 -1
  380. package/dist/table/components/table-action-node.js.map +1 -1
  381. package/dist/table/components/table-cell.d.ts +1 -1
  382. package/dist/table/components/table-cell.js +2 -2
  383. package/dist/table/components/table-cell.js.map +1 -1
  384. package/dist/table/components/table.d.ts +1 -1
  385. package/dist/table/components/table.js +23 -31
  386. package/dist/table/components/table.js.map +1 -1
  387. package/dist/{core → table/hooks}/use-column-visibility.d.ts +5 -3
  388. package/dist/{core → table/hooks}/use-column-visibility.js +4 -4
  389. package/dist/table/hooks/use-column-visibility.js.map +1 -0
  390. package/dist/table/{use-table-selection.js → hooks/use-table-selection.js} +1 -1
  391. package/dist/table/hooks/use-table-selection.js.map +1 -0
  392. package/dist/table/{use-table.d.ts → hooks/use-table.d.ts} +7 -7
  393. package/dist/table/{use-table.js → hooks/use-table.js} +12 -9
  394. package/dist/table/hooks/use-table.js.map +1 -0
  395. package/dist/table/index.d.ts +6 -1
  396. package/dist/table/index.js +5 -11
  397. package/dist/table/{align.d.ts → lib/align.d.ts} +1 -1
  398. package/dist/table/{align.js → lib/align.js} +1 -1
  399. package/dist/table/lib/align.js.map +1 -0
  400. package/dist/table/{bulk.d.ts → lib/bulk.d.ts} +3 -3
  401. package/dist/table/{bulk.js → lib/bulk.js} +1 -1
  402. package/dist/table/lib/bulk.js.map +1 -0
  403. package/dist/table/{filter-values.d.ts → lib/filter-values.d.ts} +10 -3
  404. package/dist/table/{filter-values.js → lib/filter-values.js} +14 -4
  405. package/dist/table/lib/filter-values.js.map +1 -0
  406. package/dist/table/{format.d.ts → lib/format.d.ts} +2 -2
  407. package/dist/table/{format.js → lib/format.js} +3 -3
  408. package/dist/table/lib/format.js.map +1 -0
  409. package/dist/table/{payload.d.ts → lib/payload.d.ts} +2 -3
  410. package/dist/table/{payload.js → lib/payload.js} +12 -9
  411. package/dist/table/lib/payload.js.map +1 -0
  412. package/dist/table/{query.d.ts → lib/query.d.ts} +3 -3
  413. package/dist/table/{query.js → lib/query.js} +27 -27
  414. package/dist/table/lib/query.js.map +1 -0
  415. package/dist/table/plugin.d.ts +2 -0
  416. package/dist/table/plugin.js +11 -0
  417. package/dist/table/plugin.js.map +1 -0
  418. package/dist/table/registry.d.ts +3 -1
  419. package/dist/table/registry.js.map +1 -1
  420. package/dist/table/types.d.ts +57 -7
  421. package/dist/toast/callout.d.ts +1 -1
  422. package/dist/toast/callout.js.map +1 -1
  423. package/dist/toast/index.d.ts +6 -5
  424. package/dist/toast/index.js +2 -1
  425. package/dist/toast/toast.d.ts +1 -1
  426. package/dist/toast/toaster.js.map +1 -1
  427. package/dist/toast/variant-styles.d.ts +1 -1
  428. package/dist/types/generated.d.ts +118 -64
  429. package/dist/types/index.d.ts +1 -1
  430. package/dist/{action/components → ui}/action-menu-context.js +1 -1
  431. package/dist/ui/action-menu-context.js.map +1 -0
  432. package/dist/{form/components/base → ui}/affix-group.d.ts +1 -1
  433. package/dist/{form/components/base → ui}/affix-group.js +3 -3
  434. package/dist/ui/affix-group.js.map +1 -0
  435. package/dist/{core/components → ui}/badge.d.ts +1 -1
  436. package/dist/{core/components → ui}/badge.js +2 -2
  437. package/dist/ui/badge.js.map +1 -0
  438. package/dist/{core/components → ui}/button.d.ts +2 -2
  439. package/dist/{core/components → ui}/button.js +5 -5
  440. package/dist/ui/button.js.map +1 -0
  441. package/dist/{core/components → ui}/card.d.ts +1 -1
  442. package/dist/{core/components → ui}/card.js +3 -3
  443. package/dist/ui/card.js.map +1 -0
  444. package/dist/{core/components → ui}/chart-view.d.ts +1 -1
  445. package/dist/{core/components → ui}/chart-view.js +5 -5
  446. package/dist/ui/chart-view.js.map +1 -0
  447. package/dist/{core/components → ui}/chart.d.ts +1 -1
  448. package/dist/{core/components → ui}/chart.js +1 -1
  449. package/dist/ui/chart.js.map +1 -0
  450. package/dist/{core/components → ui}/checkbox.js +3 -3
  451. package/dist/ui/checkbox.js.map +1 -0
  452. package/dist/{core/use-click-behavior.d.ts → ui/click-behavior.d.ts} +17 -19
  453. package/dist/ui/click-behavior.js +46 -0
  454. package/dist/ui/click-behavior.js.map +1 -0
  455. package/dist/{core/components → ui}/collapsible.d.ts +1 -1
  456. package/dist/{core/components → ui}/collapsible.js +6 -6
  457. package/dist/ui/collapsible.js.map +1 -0
  458. package/dist/{core/components → ui}/combobox.d.ts +1 -1
  459. package/dist/{core/components → ui}/combobox.js +4 -4
  460. package/dist/ui/combobox.js.map +1 -0
  461. package/dist/{core/components → ui}/confirm-dialog.d.ts +1 -1
  462. package/dist/{core/components → ui}/confirm-dialog.js +1 -1
  463. package/dist/ui/confirm-dialog.js.map +1 -0
  464. package/dist/{core/components → ui}/control.d.ts +1 -1
  465. package/dist/{core/components → ui}/control.js +1 -1
  466. package/dist/ui/control.js.map +1 -0
  467. package/dist/{clipboard → ui}/copyable-text.d.ts +1 -0
  468. package/dist/{clipboard → ui}/copyable-text.js +11 -3
  469. package/dist/ui/copyable-text.js.map +1 -0
  470. package/dist/{core/components → ui}/dialog.js +3 -3
  471. package/dist/ui/dialog.js.map +1 -0
  472. package/dist/{core/components → ui}/dropdown-menu.d.ts +1 -1
  473. package/dist/{core/components → ui}/dropdown-menu.js +3 -3
  474. package/dist/ui/dropdown-menu.js.map +1 -0
  475. package/dist/{core/components → ui}/floating-panel.d.ts +1 -1
  476. package/dist/{core/components → ui}/floating-panel.js +4 -4
  477. package/dist/ui/floating-panel.js.map +1 -0
  478. package/dist/{core/components → ui}/fragment.d.ts +1 -1
  479. package/dist/{core/components → ui}/fragment.js +5 -5
  480. package/dist/ui/fragment.js.map +1 -0
  481. package/dist/{core/components → ui}/grid.d.ts +1 -1
  482. package/dist/{core/components → ui}/grid.js +3 -3
  483. package/dist/ui/grid.js.map +1 -0
  484. package/dist/{core/components → ui}/heading.d.ts +1 -1
  485. package/dist/{core/components → ui}/heading.js +2 -2
  486. package/dist/ui/heading.js.map +1 -0
  487. package/dist/{core/components → ui}/icon.d.ts +1 -1
  488. package/dist/{core/components → ui}/icon.js +3 -3
  489. package/dist/ui/icon.js.map +1 -0
  490. package/dist/ui/index.d.ts +27 -0
  491. package/dist/ui/index.js +26 -0
  492. package/dist/{core/components → ui}/info-tooltip.js +3 -3
  493. package/dist/ui/info-tooltip.js.map +1 -0
  494. package/dist/{form/components/base → ui}/input-error.js +2 -2
  495. package/dist/ui/input-error.js.map +1 -0
  496. package/dist/{form/components/base → ui}/input-otp.js +2 -2
  497. package/dist/ui/input-otp.js.map +1 -0
  498. package/dist/{form/components/base → ui}/input.js +3 -3
  499. package/dist/ui/input.js.map +1 -0
  500. package/dist/{form/components/base → ui}/label.js +2 -2
  501. package/dist/ui/label.js.map +1 -0
  502. package/dist/{core/components → ui}/link.d.ts +1 -1
  503. package/dist/{core/components → ui}/link.js +8 -7
  504. package/dist/ui/link.js.map +1 -0
  505. package/dist/{core/components → ui}/modal.d.ts +1 -1
  506. package/dist/{core/components → ui}/modal.js +2 -2
  507. package/dist/ui/modal.js.map +1 -0
  508. package/dist/{form/components/base → ui}/password-input.js +3 -3
  509. package/dist/ui/password-input.js.map +1 -0
  510. package/dist/ui/plugin.d.ts +1 -0
  511. package/dist/{core/components/index.js → ui/plugin.js} +6 -6
  512. package/dist/ui/plugin.js.map +1 -0
  513. package/dist/{core/components → ui}/popover.js +2 -2
  514. package/dist/ui/popover.js.map +1 -0
  515. package/dist/{core/components → ui}/raw-block.d.ts +1 -1
  516. package/dist/{core/components → ui}/raw-block.js +1 -1
  517. package/dist/ui/raw-block.js.map +1 -0
  518. package/dist/{core/components → ui}/section.d.ts +1 -1
  519. package/dist/{core/components → ui}/section.js +6 -6
  520. package/dist/ui/section.js.map +1 -0
  521. package/dist/{core/components → ui}/segmented-control.d.ts +1 -1
  522. package/dist/{core/components → ui}/segmented-control.js +1 -1
  523. package/dist/ui/segmented-control.js.map +1 -0
  524. package/dist/{core/components → ui}/segmented-pills.d.ts +1 -1
  525. package/dist/{core/components → ui}/segmented-pills.js +2 -2
  526. package/dist/ui/segmented-pills.js.map +1 -0
  527. package/dist/{core/components → ui}/skeleton.js +2 -2
  528. package/dist/ui/skeleton.js.map +1 -0
  529. package/dist/{core/components → ui}/spinner.js +4 -4
  530. package/dist/ui/spinner.js.map +1 -0
  531. package/dist/{core/components → ui}/stack.d.ts +1 -1
  532. package/dist/{core/components → ui}/stack.js +3 -3
  533. package/dist/ui/stack.js.map +1 -0
  534. package/dist/{core/components → ui}/tabs.d.ts +1 -1
  535. package/dist/{core/components → ui}/tabs.js +3 -3
  536. package/dist/ui/tabs.js.map +1 -0
  537. package/dist/{core/components → ui}/text.d.ts +1 -1
  538. package/dist/{core/components → ui}/text.js +4 -4
  539. package/dist/ui/text.js.map +1 -0
  540. package/dist/{form/components/base → ui}/textarea.js +3 -3
  541. package/dist/ui/textarea.js.map +1 -0
  542. package/dist/{core/components → ui}/tooltip.d.ts +1 -1
  543. package/dist/{core/components → ui}/tooltip.js +3 -3
  544. package/dist/ui/tooltip.js.map +1 -0
  545. package/dist/vite.js +2 -2
  546. package/dist/vite.js.map +1 -1
  547. package/dist-standalone/chunks/chart-view-CK5fKIkR.js +36 -0
  548. package/dist-standalone/chunks/date-picker-field-BlCPFhZd.js +1 -0
  549. package/dist-standalone/chunks/dist-PaT1gYi_.js +2 -0
  550. package/dist-standalone/chunks/jsx-runtime-CJ_btYLc.js +1 -0
  551. package/dist-standalone/chunks/notifications-echo-DsfNc4Ge.js +1 -0
  552. package/dist-standalone/chunks/react-B8IZ02wI.js +1 -0
  553. package/dist-standalone/chunks/rich-editor-field-DH5dS5c1.js +154 -0
  554. package/dist-standalone/chunks/subscriptions-B3UuDBmx.js +1 -0
  555. package/dist-standalone/chunks/test-id-Dh3L6Gfh.js +1 -0
  556. package/dist-standalone/chunks/use-effect-dispatcher-k98Nzf9M.js +97 -0
  557. package/dist-standalone/chunks/with-selector-BwDoCrJJ.js +1 -0
  558. package/dist-standalone/lattice.css +3 -0
  559. package/dist-standalone/lattice.js +66 -0
  560. package/dist-standalone/manifest.json +18 -0
  561. package/dist-standalone/sprite.svg +1 -0
  562. package/package.json +33 -95
  563. package/resources/icons/align-center.svg +1 -1
  564. package/resources/icons/align-justify.svg +1 -1
  565. package/resources/icons/align-left.svg +1 -1
  566. package/resources/icons/align-right.svg +1 -1
  567. package/resources/icons/arrow-down.svg +1 -1
  568. package/resources/icons/arrow-up.svg +1 -1
  569. package/resources/icons/bell.svg +1 -1
  570. package/resources/icons/bold.svg +1 -1
  571. package/resources/icons/calendar.svg +1 -1
  572. package/resources/icons/check.svg +1 -1
  573. package/resources/icons/chevron-down.svg +1 -1
  574. package/resources/icons/chevron-left.svg +1 -1
  575. package/resources/icons/chevron-right.svg +1 -1
  576. package/resources/icons/chevrons-up-down.svg +1 -1
  577. package/resources/icons/circle-alert.svg +1 -1
  578. package/resources/icons/circle-check.svg +1 -1
  579. package/resources/icons/circle-help.svg +1 -1
  580. package/resources/icons/circle-x.svg +1 -1
  581. package/resources/icons/clock.svg +1 -1
  582. package/resources/icons/code.svg +1 -1
  583. package/resources/icons/columns-3.svg +1 -1
  584. package/resources/icons/copy.svg +1 -1
  585. package/resources/icons/external-link.svg +1 -1
  586. package/resources/icons/eye-off.svg +1 -1
  587. package/resources/icons/eye.svg +1 -1
  588. package/resources/icons/filter.svg +1 -1
  589. package/resources/icons/heading-1.svg +1 -1
  590. package/resources/icons/heading-2.svg +1 -1
  591. package/resources/icons/heading-3.svg +1 -1
  592. package/resources/icons/highlighter.svg +1 -1
  593. package/resources/icons/info.svg +1 -1
  594. package/resources/icons/italic.svg +1 -1
  595. package/resources/icons/layout-dashboard.svg +1 -1
  596. package/resources/icons/link.svg +1 -1
  597. package/resources/icons/list-ordered.svg +1 -1
  598. package/resources/icons/list.svg +1 -1
  599. package/resources/icons/loader-2.svg +1 -1
  600. package/resources/icons/minus.svg +1 -1
  601. package/resources/icons/more-horizontal.svg +1 -1
  602. package/resources/icons/panel-left.svg +1 -1
  603. package/resources/icons/pencil-line.svg +1 -1
  604. package/resources/icons/pencil.svg +1 -1
  605. package/resources/icons/plus.svg +1 -1
  606. package/resources/icons/quote.svg +1 -1
  607. package/resources/icons/rotate-ccw.svg +1 -1
  608. package/resources/icons/rows-3.svg +1 -1
  609. package/resources/icons/search.svg +1 -1
  610. package/resources/icons/send.svg +1 -1
  611. package/resources/icons/settings.svg +1 -1
  612. package/resources/icons/smile.svg +1 -1
  613. package/resources/icons/strikethrough.svg +1 -1
  614. package/resources/icons/table.svg +1 -1
  615. package/resources/icons/trash-2.svg +1 -1
  616. package/resources/icons/underline.svg +1 -1
  617. package/resources/icons/x.svg +1 -1
  618. package/dist/action/components/action-menu-context.js.map +0 -1
  619. package/dist/action/index.js.map +0 -1
  620. package/dist/action/run-action.js.map +0 -1
  621. package/dist/action/use-action.js.map +0 -1
  622. package/dist/chat/index.js.map +0 -1
  623. package/dist/chat/transport.js.map +0 -1
  624. package/dist/chat/use-chat.js.map +0 -1
  625. package/dist/clipboard/copyable-text.js.map +0 -1
  626. package/dist/core/column-sizing.js.map +0 -1
  627. package/dist/core/components/badge.js.map +0 -1
  628. package/dist/core/components/button.js.map +0 -1
  629. package/dist/core/components/card.js.map +0 -1
  630. package/dist/core/components/chart-view.js.map +0 -1
  631. package/dist/core/components/chart.js.map +0 -1
  632. package/dist/core/components/checkbox.js.map +0 -1
  633. package/dist/core/components/collapsible.js.map +0 -1
  634. package/dist/core/components/combobox.js.map +0 -1
  635. package/dist/core/components/confirm-dialog.js.map +0 -1
  636. package/dist/core/components/control.js.map +0 -1
  637. package/dist/core/components/dialog.js.map +0 -1
  638. package/dist/core/components/dropdown-menu.js.map +0 -1
  639. package/dist/core/components/floating-panel.js.map +0 -1
  640. package/dist/core/components/fragment.js.map +0 -1
  641. package/dist/core/components/grid.js.map +0 -1
  642. package/dist/core/components/heading.js.map +0 -1
  643. package/dist/core/components/icon.js.map +0 -1
  644. package/dist/core/components/index.d.ts +0 -1
  645. package/dist/core/components/index.js.map +0 -1
  646. package/dist/core/components/info-tooltip.js.map +0 -1
  647. package/dist/core/components/link.js.map +0 -1
  648. package/dist/core/components/modal.js.map +0 -1
  649. package/dist/core/components/popover.js.map +0 -1
  650. package/dist/core/components/raw-block.js.map +0 -1
  651. package/dist/core/components/section.js.map +0 -1
  652. package/dist/core/components/segmented-control.js.map +0 -1
  653. package/dist/core/components/segmented-pills.js.map +0 -1
  654. package/dist/core/components/skeleton.js.map +0 -1
  655. package/dist/core/components/spinner.js.map +0 -1
  656. package/dist/core/components/stack.js.map +0 -1
  657. package/dist/core/components/tabs.js.map +0 -1
  658. package/dist/core/components/text.js.map +0 -1
  659. package/dist/core/components/tooltip.js.map +0 -1
  660. package/dist/core/use-click-behavior.js +0 -46
  661. package/dist/core/use-click-behavior.js.map +0 -1
  662. package/dist/core/use-column-resizing.js.map +0 -1
  663. package/dist/core/use-column-visibility.js.map +0 -1
  664. package/dist/events/event-bridge.js.map +0 -1
  665. package/dist/form/components/base/affix-group.js.map +0 -1
  666. package/dist/form/components/base/input-error.js.map +0 -1
  667. package/dist/form/components/base/input-otp.js.map +0 -1
  668. package/dist/form/components/base/input.js.map +0 -1
  669. package/dist/form/components/base/label.js.map +0 -1
  670. package/dist/form/components/base/password-input.js.map +0 -1
  671. package/dist/form/components/base/textarea.js.map +0 -1
  672. package/dist/form/components/conditions.js.map +0 -1
  673. package/dist/form/components/context.js.map +0 -1
  674. package/dist/form/components/field-props.js.map +0 -1
  675. package/dist/form/components/field-scope.js.map +0 -1
  676. package/dist/form/components/fields/block-add-menu.js.map +0 -1
  677. package/dist/form/components/form-path.js.map +0 -1
  678. package/dist/form/components/form-transport.js +0 -30
  679. package/dist/form/components/form-transport.js.map +0 -1
  680. package/dist/form/components/override-keys.js +0 -12
  681. package/dist/form/components/override-keys.js.map +0 -1
  682. package/dist/form/components/prefill-context.js.map +0 -1
  683. package/dist/form/components/prefill-targets.js.map +0 -1
  684. package/dist/form/components/resolved-nodes.js.map +0 -1
  685. package/dist/form/components/row-layout-context.js.map +0 -1
  686. package/dist/form/components/use-controlled-field.js.map +0 -1
  687. package/dist/form/components/use-dependent-field.d.ts +0 -3
  688. package/dist/form/components/use-dependent-field.js.map +0 -1
  689. package/dist/form/components/use-field-commit.js.map +0 -1
  690. package/dist/form/components/use-form-resolver.js.map +0 -1
  691. package/dist/form/components/use-seed-default.js.map +0 -1
  692. package/dist/form/components/values.js +0 -52
  693. package/dist/form/components/values.js.map +0 -1
  694. package/dist/form/index.js.map +0 -1
  695. package/dist/layout/breadcrumbs.js.map +0 -1
  696. package/dist/layout/callouts.js.map +0 -1
  697. package/dist/layout/components.d.ts +0 -1
  698. package/dist/layout/components.js.map +0 -1
  699. package/dist/layout/context.js.map +0 -1
  700. package/dist/layout/dropdown.js.map +0 -1
  701. package/dist/layout/menu-item.js.map +0 -1
  702. package/dist/layout/menu.js.map +0 -1
  703. package/dist/layout/outlet.js.map +0 -1
  704. package/dist/layout/popover.js.map +0 -1
  705. package/dist/layout/schema-layout.js.map +0 -1
  706. package/dist/layout/sidebar.js.map +0 -1
  707. package/dist/layout/topbar.js.map +0 -1
  708. package/dist/notifications/index.js.map +0 -1
  709. package/dist/remote/index.js.map +0 -1
  710. package/dist/svg-sprite-client/index.d.ts +0 -1
  711. package/dist/svg-sprite-client/index.js +0 -0
  712. package/dist/table/align.js.map +0 -1
  713. package/dist/table/bulk.js.map +0 -1
  714. package/dist/table/components/filter-stack-bar.d.ts +0 -7
  715. package/dist/table/components/filter-stack-bar.js +0 -38
  716. package/dist/table/components/filter-stack-bar.js.map +0 -1
  717. package/dist/table/filter-values.js.map +0 -1
  718. package/dist/table/format.js.map +0 -1
  719. package/dist/table/index.js.map +0 -1
  720. package/dist/table/payload.js.map +0 -1
  721. package/dist/table/query.js.map +0 -1
  722. package/dist/table/use-table-selection.js.map +0 -1
  723. package/dist/table/use-table.js.map +0 -1
  724. package/dist/types/generated.js +0 -0
  725. package/dist/types/index.js +0 -0
  726. /package/dist/form/{components → hooks}/field-scope.d.ts +0 -0
  727. /package/dist/form/{components → hooks}/prefill-context.d.ts +0 -0
  728. /package/dist/form/{components → hooks}/row-layout-context.d.ts +0 -0
  729. /package/dist/form/{components → hooks}/use-seed-default.d.ts +0 -0
  730. /package/dist/form/{components → lib}/form-path.d.ts +0 -0
  731. /package/dist/form/{components → lib}/override-keys.d.ts +0 -0
  732. /package/dist/form/{components/types.js → types.js} +0 -0
  733. /package/dist/layout/{popover.d.ts → components/popover.d.ts} +0 -0
  734. /package/dist/layout/{schema-layout.d.ts → components/schema-layout.d.ts} +0 -0
  735. /package/dist/table/{use-table-selection.d.ts → hooks/use-table-selection.d.ts} +0 -0
  736. /package/dist/{action/components → ui}/action-menu-context.d.ts +0 -0
  737. /package/dist/{core/components → ui}/checkbox.d.ts +0 -0
  738. /package/dist/{core/components → ui}/dialog.d.ts +0 -0
  739. /package/dist/{core/components → ui}/info-tooltip.d.ts +0 -0
  740. /package/dist/{form/components/base → ui}/input-error.d.ts +0 -0
  741. /package/dist/{form/components/base → ui}/input-otp.d.ts +0 -0
  742. /package/dist/{form/components/base → ui}/input.d.ts +0 -0
  743. /package/dist/{form/components/base → ui}/label.d.ts +0 -0
  744. /package/dist/{form/components/base → ui}/password-input.d.ts +0 -0
  745. /package/dist/{core/components → ui}/popover.d.ts +0 -0
  746. /package/dist/{core/components → ui}/skeleton.d.ts +0 -0
  747. /package/dist/{core/components → ui}/spinner.d.ts +0 -0
  748. /package/dist/{form/components/base → ui}/textarea.d.ts +0 -0
@@ -1,11 +1,11 @@
1
1
  import { LATTICE_EVENT } from "../../events/event-names.js";
2
2
  import { withHeaders } from "../../core/headers.js";
3
- import { FormProvider } from "./context.js";
4
- import { walkFields } from "./field-props.js";
5
- import { PrefillProvider } from "./prefill-context.js";
6
- import { ResolvedNodesProvider } from "./resolved-nodes.js";
7
- import { FormValuesProvider } from "./values.js";
8
- import { useFormResolver } from "./use-form-resolver.js";
3
+ import { FormProvider } from "../hooks/context.js";
4
+ import { PrefillProvider } from "../hooks/prefill-context.js";
5
+ import { walkFields } from "../lib/field-props.js";
6
+ import { ResolvedNodesProvider } from "../hooks/resolved-nodes.js";
7
+ import { FormValuesProvider } from "../hooks/values.js";
8
+ import { useFormResolver } from "../hooks/use-form-resolver.js";
9
9
  import { FormSubmitButton } from "./base/submit-button.js";
10
10
  import { Form } from "@inertiajs/react";
11
11
  import { useEffect, useMemo } from "react";
@@ -1 +1 @@
1
- {"version":3,"file":"form.js","names":[],"sources":["../../../resources/js/form/components/form.tsx"],"sourcesContent":["import { Form as InertiaForm } from \"@inertiajs/react\";\nimport { withHeaders } from \"@lattice-php/lattice/core/headers\";\nimport { LATTICE_EVENT } from \"@lattice-php/lattice/events/event-names\";\nimport type { Node, RendererComponent } from \"@lattice-php/lattice/core/types\";\nimport { useEffect, useMemo } from \"react\";\nimport { FormSubmitButton } from \"./base/submit-button\";\nimport { FormProvider } from \"./context\";\nimport { walkFields } from \"./field-props\";\nimport { PrefillProvider } from \"./prefill-context\";\nimport { ResolvedNodesProvider } from \"./resolved-nodes\";\nimport { useFormResolver } from \"./use-form-resolver\";\nimport { FormValuesProvider } from \"./values\";\n\ntype CollectedFields = {\n labels: Record<string, string>;\n values: Record<string, unknown>;\n};\n\nfunction collectFields(nodes: Node[] | undefined): CollectedFields {\n const collected: CollectedFields = { labels: {}, values: {} };\n\n walkFields(nodes, (props) => {\n if (!props.name) {\n return;\n }\n if (props.label) {\n collected.labels[props.name] = props.label;\n }\n if (props.value !== undefined) {\n collected.values[props.name] = props.value;\n }\n });\n\n return collected;\n}\n\nfunction FormResetListener({\n componentId,\n reset,\n}: {\n componentId?: string;\n reset: (...fields: string[]) => void;\n}) {\n useEffect(() => {\n const handler = (event: Event) => {\n const detail = (event as CustomEvent<{ form: string | null }>).detail;\n\n if (!detail?.form || detail.form === componentId) {\n reset();\n }\n };\n\n window.addEventListener(LATTICE_EVENT.resetForm, handler);\n\n return () => window.removeEventListener(LATTICE_EVENT.resetForm, handler);\n }, [componentId, reset]);\n\n return null;\n}\n\nfunction FormBody({\n action,\n children,\n componentRef,\n nodes,\n shouldRenderSubmitButton,\n submitLabel,\n summaryLabel,\n}: {\n action: string;\n children: React.ReactNode;\n componentRef: string;\n nodes: Node[] | undefined;\n shouldRenderSubmitButton: boolean;\n submitLabel: string;\n summaryLabel: string;\n}) {\n const { nodes: resolvedNodes, markUserEdit } = useFormResolver(action, componentRef, nodes);\n\n return (\n <PrefillProvider value={{ markUserEdit }}>\n <ResolvedNodesProvider nodes={resolvedNodes}>\n <div className=\"flex flex-col gap-6\">\n {children}\n\n {shouldRenderSubmitButton && (\n <div className=\"flex justify-end rounded-lt border border-lt-border bg-lt-surface px-lt-gutter py-4 shadow-lt-sm\">\n <FormSubmitButton label={submitLabel} summaryLabel={summaryLabel} />\n </div>\n )}\n </div>\n </ResolvedNodesProvider>\n </PrefillProvider>\n );\n}\n\nexport const FormComponent: RendererComponent<\"form\"> = ({ children, node }) => {\n const props = node.props;\n const action = props.action ?? \"#\";\n const errorBag = props.errorBag;\n const componentRef = props.ref ?? \"\";\n const method = props.method ?? \"post\";\n const precognitive = props.precognitive;\n const resetOnError = props.resetOnError ?? false;\n const resetOnSuccess = props.resetOnSuccess ?? [];\n const state = props.state;\n const { labels: fieldLabels, values: fieldValues } = useMemo(\n () => collectFields(node.schema),\n [node.schema],\n );\n const initialValues = useMemo(() => ({ ...fieldValues, ...state }), [fieldValues, state]);\n const shouldRenderSubmitButton = props.submitButton;\n const submitLabel = props.submitLabel ?? \"Submit\";\n const summaryLabel = props.validationSummaryLabel;\n const validationTimeout = props.validationTimeout ?? undefined;\n\n return (\n <InertiaForm\n action={action}\n data-slot=\"form\"\n data-lattice-component={node.id}\n errorBag={errorBag}\n method={method}\n resetOnError={resetOnError}\n resetOnSuccess={resetOnSuccess}\n validationTimeout={precognitive ? validationTimeout : undefined}\n headers={withHeaders(componentRef)}\n className=\"mx-auto flex w-full max-w-2xl flex-col gap-6\"\n >\n {({ clearErrors, errors, processing, reset, validate }) => (\n <FormProvider\n value={{\n action,\n clearErrors: (field) => clearErrors(field),\n componentId: node.id,\n componentRef,\n errors: errors as Record<string, string | undefined>,\n fieldLabels,\n precognitive,\n processing,\n validate: (field) => validate(field),\n }}\n >\n <FormResetListener componentId={node.id} reset={reset} />\n\n {props.status && (\n <div className=\"text-center text-sm font-medium text-lt-success\">{props.status}</div>\n )}\n\n <FormValuesProvider initial={initialValues}>\n <FormBody\n action={action}\n componentRef={componentRef}\n nodes={node.schema}\n shouldRenderSubmitButton={shouldRenderSubmitButton}\n submitLabel={submitLabel}\n summaryLabel={summaryLabel}\n >\n {children}\n </FormBody>\n </FormValuesProvider>\n </FormProvider>\n )}\n </InertiaForm>\n );\n};\n"],"mappings":";;;;;;;;;;;;;AAkBA,SAAS,cAAc,OAA4C;CACjE,MAAM,YAA6B;EAAE,QAAQ,CAAC;EAAG,QAAQ,CAAC;CAAE;CAE5D,WAAW,QAAQ,UAAU;EAC3B,IAAI,CAAC,MAAM,MACT;EAEF,IAAI,MAAM,OACR,UAAU,OAAO,MAAM,QAAQ,MAAM;EAEvC,IAAI,MAAM,UAAU,KAAA,GAClB,UAAU,OAAO,MAAM,QAAQ,MAAM;CAEzC,CAAC;CAED,OAAO;AACT;AAEA,SAAS,kBAAkB,EACzB,aACA,SAIC;CACD,gBAAgB;EACd,MAAM,WAAW,UAAiB;GAChC,MAAM,SAAU,MAA+C;GAE/D,IAAI,CAAC,QAAQ,QAAQ,OAAO,SAAS,aACnC,MAAM;EAEV;EAEA,OAAO,iBAAiB,cAAc,WAAW,OAAO;EAExD,aAAa,OAAO,oBAAoB,cAAc,WAAW,OAAO;CAC1E,GAAG,CAAC,aAAa,KAAK,CAAC;CAEvB,OAAO;AACT;AAEA,SAAS,SAAS,EAChB,QACA,UACA,cACA,OACA,0BACA,aACA,gBASC;CACD,MAAM,EAAE,OAAO,eAAe,iBAAiB,gBAAgB,QAAQ,cAAc,KAAK;CAE1F,OACE,oBAAC,iBAAD;EAAiB,OAAO,EAAE,aAAa;YACrC,oBAAC,uBAAD;GAAuB,OAAO;aAC5B,qBAAC,OAAD;IAAK,WAAU;cAAf,CACG,UAEA,4BACC,oBAAC,OAAD;KAAK,WAAU;eACb,oBAAC,kBAAD;MAAkB,OAAO;MAA2B;KAAe,CAAA;IAChE,CAAA,CAEJ;;EACgB,CAAA;CACR,CAAA;AAErB;AAEA,IAAa,iBAA4C,EAAE,UAAU,WAAW;CAC9E,MAAM,QAAQ,KAAK;CACnB,MAAM,SAAS,MAAM,UAAU;CAC/B,MAAM,WAAW,MAAM;CACvB,MAAM,eAAe,MAAM,OAAO;CAClC,MAAM,SAAS,MAAM,UAAU;CAC/B,MAAM,eAAe,MAAM;CAC3B,MAAM,eAAe,MAAM,gBAAgB;CAC3C,MAAM,iBAAiB,MAAM,kBAAkB,CAAC;CAChD,MAAM,QAAQ,MAAM;CACpB,MAAM,EAAE,QAAQ,aAAa,QAAQ,gBAAgB,cAC7C,cAAc,KAAK,MAAM,GAC/B,CAAC,KAAK,MAAM,CACd;CACA,MAAM,gBAAgB,eAAe;EAAE,GAAG;EAAa,GAAG;CAAM,IAAI,CAAC,aAAa,KAAK,CAAC;CACxF,MAAM,2BAA2B,MAAM;CACvC,MAAM,cAAc,MAAM,eAAe;CACzC,MAAM,eAAe,MAAM;CAC3B,MAAM,oBAAoB,MAAM,qBAAqB,KAAA;CAErD,OACE,oBAAC,MAAD;EACU;EACR,aAAU;EACV,0BAAwB,KAAK;EACnB;EACF;EACM;EACE;EAChB,mBAAmB,eAAe,oBAAoB,KAAA;EACtD,SAAS,YAAY,YAAY;EACjC,WAAU;aAER,EAAE,aAAa,QAAQ,YAAY,OAAO,eAC1C,qBAAC,cAAD;GACE,OAAO;IACL;IACA,cAAc,UAAU,YAAY,KAAK;IACzC,aAAa,KAAK;IAClB;IACQ;IACR;IACA;IACA;IACA,WAAW,UAAU,SAAS,KAAK;GACrC;aAXF;IAaE,oBAAC,mBAAD;KAAmB,aAAa,KAAK;KAAW;IAAQ,CAAA;IAEvD,MAAM,UACL,oBAAC,OAAD;KAAK,WAAU;eAAmD,MAAM;IAAY,CAAA;IAGtF,oBAAC,oBAAD;KAAoB,SAAS;eAC3B,oBAAC,UAAD;MACU;MACM;MACd,OAAO,KAAK;MACc;MACb;MACC;MAEb;KACO,CAAA;IACQ,CAAA;GACR;;CAEL,CAAA;AAEjB"}
1
+ {"version":3,"file":"form.js","names":[],"sources":["../../../resources/js/form/components/form.tsx"],"sourcesContent":["import { Form as InertiaForm } from \"@inertiajs/react\";\nimport { withHeaders } from \"@lattice-php/lattice/core/headers\";\nimport { LATTICE_EVENT } from \"@lattice-php/lattice/events/event-names\";\nimport type { Node, RendererComponent } from \"@lattice-php/lattice/core/types\";\nimport { useEffect, useMemo } from \"react\";\nimport { FormSubmitButton } from \"./base/submit-button\";\nimport { FormProvider } from \"@lattice-php/lattice/form/hooks/context\";\nimport { walkFields } from \"@lattice-php/lattice/form/lib/field-props\";\nimport { PrefillProvider } from \"@lattice-php/lattice/form/hooks/prefill-context\";\nimport { ResolvedNodesProvider } from \"@lattice-php/lattice/form/hooks/resolved-nodes\";\nimport { useFormResolver } from \"@lattice-php/lattice/form/hooks/use-form-resolver\";\nimport { FormValuesProvider } from \"@lattice-php/lattice/form/hooks/values\";\n\ntype CollectedFields = {\n labels: Record<string, string>;\n values: Record<string, unknown>;\n};\n\nfunction collectFields(nodes: Node[] | undefined): CollectedFields {\n const collected: CollectedFields = { labels: {}, values: {} };\n\n walkFields(nodes, (props) => {\n if (!props.name) {\n return;\n }\n if (props.label) {\n collected.labels[props.name] = props.label;\n }\n if (props.value !== undefined) {\n collected.values[props.name] = props.value;\n }\n });\n\n return collected;\n}\n\nfunction FormResetListener({\n componentId,\n reset,\n}: {\n componentId?: string;\n reset: (...fields: string[]) => void;\n}) {\n useEffect(() => {\n const handler = (event: Event) => {\n const detail = (event as CustomEvent<{ form: string | null }>).detail;\n\n if (!detail?.form || detail.form === componentId) {\n reset();\n }\n };\n\n window.addEventListener(LATTICE_EVENT.resetForm, handler);\n\n return () => window.removeEventListener(LATTICE_EVENT.resetForm, handler);\n }, [componentId, reset]);\n\n return null;\n}\n\nfunction FormBody({\n action,\n children,\n componentRef,\n nodes,\n shouldRenderSubmitButton,\n submitLabel,\n summaryLabel,\n}: {\n action: string;\n children: React.ReactNode;\n componentRef: string;\n nodes: Node[] | undefined;\n shouldRenderSubmitButton: boolean;\n submitLabel: string;\n summaryLabel: string;\n}) {\n const { nodes: resolvedNodes, markUserEdit } = useFormResolver(action, componentRef, nodes);\n\n return (\n <PrefillProvider value={{ markUserEdit }}>\n <ResolvedNodesProvider nodes={resolvedNodes}>\n <div className=\"flex flex-col gap-6\">\n {children}\n\n {shouldRenderSubmitButton && (\n <div className=\"flex justify-end rounded-lt border border-lt-border bg-lt-surface px-lt-gutter py-4 shadow-lt-sm\">\n <FormSubmitButton label={submitLabel} summaryLabel={summaryLabel} />\n </div>\n )}\n </div>\n </ResolvedNodesProvider>\n </PrefillProvider>\n );\n}\n\nexport const FormComponent: RendererComponent<\"form\"> = ({ children, node }) => {\n const props = node.props;\n const action = props.action ?? \"#\";\n const errorBag = props.errorBag;\n const componentRef = props.ref ?? \"\";\n const method = props.method ?? \"post\";\n const precognitive = props.precognitive;\n const resetOnError = props.resetOnError ?? false;\n const resetOnSuccess = props.resetOnSuccess ?? [];\n const state = props.state;\n const { labels: fieldLabels, values: fieldValues } = useMemo(\n () => collectFields(node.schema),\n [node.schema],\n );\n const initialValues = useMemo(() => ({ ...fieldValues, ...state }), [fieldValues, state]);\n const shouldRenderSubmitButton = props.submitButton;\n const submitLabel = props.submitLabel ?? \"Submit\";\n const summaryLabel = props.validationSummaryLabel;\n const validationTimeout = props.validationTimeout ?? undefined;\n\n return (\n <InertiaForm\n action={action}\n data-slot=\"form\"\n data-lattice-component={node.id}\n errorBag={errorBag}\n method={method}\n resetOnError={resetOnError}\n resetOnSuccess={resetOnSuccess}\n validationTimeout={precognitive ? validationTimeout : undefined}\n headers={withHeaders(componentRef)}\n className=\"mx-auto flex w-full max-w-2xl flex-col gap-6\"\n >\n {({ clearErrors, errors, processing, reset, validate }) => (\n <FormProvider\n value={{\n action,\n clearErrors: (field) => clearErrors(field),\n componentId: node.id,\n componentRef,\n errors: errors as Record<string, string | undefined>,\n fieldLabels,\n precognitive,\n processing,\n validate: (field) => validate(field),\n }}\n >\n <FormResetListener componentId={node.id} reset={reset} />\n\n {props.status && (\n <div className=\"text-center text-sm font-medium text-lt-success\">{props.status}</div>\n )}\n\n <FormValuesProvider initial={initialValues}>\n <FormBody\n action={action}\n componentRef={componentRef}\n nodes={node.schema}\n shouldRenderSubmitButton={shouldRenderSubmitButton}\n submitLabel={submitLabel}\n summaryLabel={summaryLabel}\n >\n {children}\n </FormBody>\n </FormValuesProvider>\n </FormProvider>\n )}\n </InertiaForm>\n );\n};\n"],"mappings":";;;;;;;;;;;;;AAkBA,SAAS,cAAc,OAA4C;CACjE,MAAM,YAA6B;EAAE,QAAQ,CAAC;EAAG,QAAQ,CAAC;CAAE;CAE5D,WAAW,QAAQ,UAAU;EAC3B,IAAI,CAAC,MAAM,MACT;EAEF,IAAI,MAAM,OACR,UAAU,OAAO,MAAM,QAAQ,MAAM;EAEvC,IAAI,MAAM,UAAU,KAAA,GAClB,UAAU,OAAO,MAAM,QAAQ,MAAM;CAEzC,CAAC;CAED,OAAO;AACT;AAEA,SAAS,kBAAkB,EACzB,aACA,SAIC;CACD,gBAAgB;EACd,MAAM,WAAW,UAAiB;GAChC,MAAM,SAAU,MAA+C;GAE/D,IAAI,CAAC,QAAQ,QAAQ,OAAO,SAAS,aACnC,MAAM;EAEV;EAEA,OAAO,iBAAiB,cAAc,WAAW,OAAO;EAExD,aAAa,OAAO,oBAAoB,cAAc,WAAW,OAAO;CAC1E,GAAG,CAAC,aAAa,KAAK,CAAC;CAEvB,OAAO;AACT;AAEA,SAAS,SAAS,EAChB,QACA,UACA,cACA,OACA,0BACA,aACA,gBASC;CACD,MAAM,EAAE,OAAO,eAAe,iBAAiB,gBAAgB,QAAQ,cAAc,KAAK;CAE1F,OACE,oBAAC,iBAAD;EAAiB,OAAO,EAAE,aAAa;YACrC,oBAAC,uBAAD;GAAuB,OAAO;aAC5B,qBAAC,OAAD;IAAK,WAAU;cAAf,CACG,UAEA,4BACC,oBAAC,OAAD;KAAK,WAAU;eACb,oBAAC,kBAAD;MAAkB,OAAO;MAA2B;KAAe,CAAA;IAChE,CAAA,CAEJ;;EACgB,CAAA;CACR,CAAA;AAErB;AAEA,IAAa,iBAA4C,EAAE,UAAU,WAAW;CAC9E,MAAM,QAAQ,KAAK;CACnB,MAAM,SAAS,MAAM,UAAU;CAC/B,MAAM,WAAW,MAAM;CACvB,MAAM,eAAe,MAAM,OAAO;CAClC,MAAM,SAAS,MAAM,UAAU;CAC/B,MAAM,eAAe,MAAM;CAC3B,MAAM,eAAe,MAAM,gBAAgB;CAC3C,MAAM,iBAAiB,MAAM,kBAAkB,CAAC;CAChD,MAAM,QAAQ,MAAM;CACpB,MAAM,EAAE,QAAQ,aAAa,QAAQ,gBAAgB,cAC7C,cAAc,KAAK,MAAM,GAC/B,CAAC,KAAK,MAAM,CACd;CACA,MAAM,gBAAgB,eAAe;EAAE,GAAG;EAAa,GAAG;CAAM,IAAI,CAAC,aAAa,KAAK,CAAC;CACxF,MAAM,2BAA2B,MAAM;CACvC,MAAM,cAAc,MAAM,eAAe;CACzC,MAAM,eAAe,MAAM;CAC3B,MAAM,oBAAoB,MAAM,qBAAqB,KAAA;CAErD,OACE,oBAAC,MAAD;EACU;EACR,aAAU;EACV,0BAAwB,KAAK;EACnB;EACF;EACM;EACE;EAChB,mBAAmB,eAAe,oBAAoB,KAAA;EACtD,SAAS,YAAY,YAAY;EACjC,WAAU;aAER,EAAE,aAAa,QAAQ,YAAY,OAAO,eAC1C,qBAAC,cAAD;GACE,OAAO;IACL;IACA,cAAc,UAAU,YAAY,KAAK;IACzC,aAAa,KAAK;IAClB;IACQ;IACR;IACA;IACA;IACA,WAAW,UAAU,SAAS,KAAK;GACrC;aAXF;IAaE,oBAAC,mBAAD;KAAmB,aAAa,KAAK;KAAW;IAAQ,CAAA;IAEvD,MAAM,UACL,oBAAC,OAAD;KAAK,WAAU;eAAmD,MAAM;IAAY,CAAA;IAGtF,oBAAC,oBAAD;KAAoB,SAAS;eAC3B,oBAAC,UAAD;MACU;MACM;MACd,OAAO,KAAK;MACc;MACb;MACC;MAEb;KACO,CAAA;IACQ,CAAA;GACR;;CAEL,CAAA;AAEjB"}
@@ -1,17 +1,17 @@
1
- export { BuilderComponent } from './fields/builder';
2
- export { CheckboxComponent } from './fields/checkbox';
3
- export { ChoiceComponent } from './fields/choice';
4
- export { DateInputComponent } from './fields/date-input';
5
- export { DateTimeInputComponent } from './fields/date-time-input';
6
- export { FileUploadComponent } from './fields/file-upload';
7
- export { FormComponent } from './form';
8
- export { HiddenInputComponent } from './fields/hidden-input';
9
- export { NumberInputComponent } from './fields/number-input';
10
- export { OtpInputComponent } from './fields/otp-input';
11
- export { PasswordInputComponent } from './fields/password-input';
12
- export { RepeaterComponent } from './fields/repeater';
13
- export { SelectComponent } from './fields/select';
14
- export { TextareaComponent } from './fields/textarea';
15
- export { TextInputComponent } from './fields/text-input';
16
- export { TimeInputComponent } from './fields/time-input';
17
- export { ToggleComponent } from './fields/toggle';
1
+ export { BuilderComponent } from './fields/builder.js';
2
+ export { CheckboxComponent } from './fields/checkbox.js';
3
+ export { ChoiceComponent } from './fields/choice.js';
4
+ export { DateInputComponent } from './fields/date-input.js';
5
+ export { DateTimeInputComponent } from './fields/date-time-input.js';
6
+ export { FileUploadComponent } from './fields/file-upload.js';
7
+ export { FormComponent } from './form.js';
8
+ export { HiddenInputComponent } from './fields/hidden-input.js';
9
+ export { NumberInputComponent } from './fields/number-input.js';
10
+ export { OtpInputComponent } from './fields/otp-input.js';
11
+ export { PasswordInputComponent } from './fields/password-input.js';
12
+ export { RepeaterComponent } from './fields/repeater.js';
13
+ export { SelectComponent } from './fields/select.js';
14
+ export { TextareaComponent } from './fields/textarea.js';
15
+ export { TextInputComponent } from './fields/text-input.js';
16
+ export { TimeInputComponent } from './fields/time-input.js';
17
+ export { ToggleComponent } from './fields/toggle.js';
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Entry point for hosting a form runtime outside the `<Form>` component — action
3
+ * dialogs, table filter rows, and similar schema-driven surfaces. The counterpart
4
+ * to `toolkit.ts` (which serves custom-field authors): everything a host needs to
5
+ * provide form state, prefill, and dependent-field resolution around rendered
6
+ * fields. Form modules not re-exported here or in the toolkit are internal and
7
+ * may change without notice.
8
+ */
9
+ export { FormProvider } from './hooks/context.js';
10
+ export { PrefillProvider } from './hooks/prefill-context.js';
11
+ export { ResolvedNodesProvider } from './hooks/resolved-nodes.js';
12
+ export { FieldCommitOverrideProvider } from './hooks/use-field-commit.js';
13
+ export { useFormResolver } from './hooks/use-form-resolver.js';
14
+ export { FormValuesProvider, useFormValues, useSetFormValue } from './hooks/values.js';
15
+ export { walkFields } from './lib/field-props.js';
16
+ export { appendPath, getPath, setPath } from './lib/form-path.js';
17
+ export { FORM_DEBOUNCE_MS } from './lib/form-transport.js';
@@ -0,0 +1,10 @@
1
+ import { FormProvider } from "./hooks/context.js";
2
+ import { PrefillProvider } from "./hooks/prefill-context.js";
3
+ import { walkFields } from "./lib/field-props.js";
4
+ import { appendPath, getPath, setPath } from "./lib/form-path.js";
5
+ import { ResolvedNodesProvider } from "./hooks/resolved-nodes.js";
6
+ import { FormValuesProvider, useFormValues, useSetFormValue } from "./hooks/values.js";
7
+ import { FieldCommitOverrideProvider } from "./hooks/use-field-commit.js";
8
+ import { FORM_DEBOUNCE_MS } from "./lib/form-transport.js";
9
+ import { useFormResolver } from "./hooks/use-form-resolver.js";
10
+ export { FORM_DEBOUNCE_MS, FieldCommitOverrideProvider, FormProvider, FormValuesProvider, PrefillProvider, ResolvedNodesProvider, appendPath, getPath, setPath, useFormResolver, useFormValues, useSetFormValue, walkFields };
@@ -1,12 +1,15 @@
1
+ import { Option } from '../../core/types.js';
1
2
  type FormContextValue = {
2
3
  action: string;
3
4
  clearErrors: (field: string) => void;
4
5
  componentId?: string;
5
6
  componentRef: string;
6
7
  errors: Record<string, string | undefined>;
8
+ fieldIdPrefix?: string;
7
9
  fieldLabels: Record<string, string>;
8
10
  precognitive: boolean;
9
11
  processing: boolean;
12
+ searchOptions?: (field: string, query: string, values: Record<string, unknown>, signal: AbortSignal) => Promise<Option[]>;
10
13
  validate: (field: string) => void;
11
14
  };
12
15
  export declare function FormProvider({ children, value, }: {
@@ -1,12 +1,13 @@
1
1
  import { createContext, useContext } from "react";
2
2
  import { jsx } from "react/jsx-runtime";
3
- //#region resources/js/form/components/context.tsx
3
+ //#region resources/js/form/hooks/context.tsx
4
4
  var FormContext = createContext({
5
5
  action: "#",
6
6
  clearErrors: () => {},
7
7
  componentId: void 0,
8
8
  componentRef: "",
9
9
  errors: {},
10
+ fieldIdPrefix: void 0,
10
11
  fieldLabels: {},
11
12
  precognitive: false,
12
13
  processing: false,
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","names":[],"sources":["../../../resources/js/form/hooks/context.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport type { Option } from \"@lattice-php/lattice/core/types\";\n\ntype FormContextValue = {\n action: string;\n clearErrors: (field: string) => void;\n componentId?: string;\n componentRef: string;\n errors: Record<string, string | undefined>;\n fieldIdPrefix?: string;\n fieldLabels: Record<string, string>;\n precognitive: boolean;\n processing: boolean;\n searchOptions?: (\n field: string,\n query: string,\n values: Record<string, unknown>,\n signal: AbortSignal,\n ) => Promise<Option[]>;\n validate: (field: string) => void;\n};\n\nconst FormContext = createContext<FormContextValue>({\n action: \"#\",\n clearErrors: () => {},\n componentId: undefined,\n componentRef: \"\",\n errors: {},\n fieldIdPrefix: undefined,\n fieldLabels: {},\n precognitive: false,\n processing: false,\n validate: () => {},\n});\n\nexport function FormProvider({\n children,\n value,\n}: {\n children: React.ReactNode;\n value: FormContextValue;\n}) {\n return <FormContext.Provider value={value}>{children}</FormContext.Provider>;\n}\n\nexport function useFormContext() {\n return useContext(FormContext);\n}\n"],"mappings":";;;AAsBA,IAAM,cAAc,cAAgC;CAClD,QAAQ;CACR,mBAAmB,CAAC;CACpB,aAAa,KAAA;CACb,cAAc;CACd,QAAQ,CAAC;CACT,eAAe,KAAA;CACf,aAAa,CAAC;CACd,cAAc;CACd,YAAY;CACZ,gBAAgB,CAAC;AACnB,CAAC;AAED,SAAgB,aAAa,EAC3B,UACA,SAIC;CACD,OAAO,oBAAC,YAAY,UAAb;EAA6B;EAAQ;CAA+B,CAAA;AAC7E;AAEA,SAAgB,iBAAiB;CAC/B,OAAO,WAAW,WAAW;AAC/B"}
@@ -1,8 +1,8 @@
1
- import { appendPath, getPath, toHtmlName } from "./form-path.js";
2
- import { buildOverrideKey, rowIdFrom } from "./override-keys.js";
1
+ import { appendPath, getPath, toHtmlName } from "../lib/form-path.js";
2
+ import { buildOverrideKey, rowIdFrom } from "../lib/override-keys.js";
3
3
  import { createContext, useContext, useMemo } from "react";
4
4
  import { jsx } from "react/jsx-runtime";
5
- //#region resources/js/form/components/field-scope.tsx
5
+ //#region resources/js/form/hooks/field-scope.tsx
6
6
  var FieldScopeContext = createContext(null);
7
7
  function childCollectionIdentity(base, parent) {
8
8
  if (!parent) return base;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-scope.js","names":[],"sources":["../../../resources/js/form/hooks/field-scope.tsx"],"sourcesContent":["import { createContext, useContext, useMemo } from \"react\";\nimport { appendPath, getPath, toHtmlName } from \"@lattice-php/lattice/form/lib/form-path\";\nimport { buildOverrideKey, rowIdFrom } from \"@lattice-php/lattice/form/lib/override-keys\";\n\ntype FieldScopeValue = {\n row: Record<string, unknown>;\n rowId: string | null;\n path: string;\n values: Record<string, unknown>;\n identityPath: string;\n getValue: (name: string) => unknown;\n setValue: (name: string, value: unknown) => void;\n scopedName: (name: string) => string;\n errorKey: (name: string) => string;\n overrideKey: (name: string) => string;\n};\n\nconst FieldScopeContext = createContext<FieldScopeValue | null>(null);\n\nfunction childCollectionIdentity(base: string, parent: FieldScopeValue | null): string {\n if (!parent) {\n return base;\n }\n\n const local = base.startsWith(`${parent.path}.`) ? base.slice(parent.path.length + 1) : base;\n\n return appendPath(parent.identityPath, local);\n}\n\nexport function FieldScopeProvider({\n base,\n index,\n row,\n onChange,\n children,\n}: {\n base: string;\n index: number;\n row: Record<string, unknown>;\n onChange: (name: string, value: unknown) => void;\n children: React.ReactNode;\n}) {\n const parent = useContext(FieldScopeContext);\n\n const value = useMemo<FieldScopeValue>(() => {\n const scopedRow = row ?? {};\n const rowId = rowIdFrom(scopedRow);\n const path = appendPath(base, index);\n const identityCollection = childCollectionIdentity(base, parent);\n const identityPath = appendPath(identityCollection, rowId ?? index);\n\n return {\n row: scopedRow,\n rowId,\n path,\n values: parent ? { ...parent.values, ...scopedRow } : scopedRow,\n identityPath,\n getValue: (name) => getPath(scopedRow, name),\n setValue: onChange,\n scopedName: (name) => toHtmlName(appendPath(path, name)),\n errorKey: (name) => appendPath(path, name),\n overrideKey: (name) => buildOverrideKey(identityCollection, rowId, index, name),\n };\n }, [base, index, row, onChange, parent]);\n\n return <FieldScopeContext.Provider value={value}>{children}</FieldScopeContext.Provider>;\n}\n\n/** Null outside a row so callers can preserve top-level behavior without a wrapper. */\nexport function useFieldScope(): FieldScopeValue | null {\n return useContext(FieldScopeContext);\n}\n"],"mappings":";;;;;AAiBA,IAAM,oBAAoB,cAAsC,IAAI;AAEpE,SAAS,wBAAwB,MAAc,QAAwC;CACrF,IAAI,CAAC,QACH,OAAO;CAGT,MAAM,QAAQ,KAAK,WAAW,GAAG,OAAO,KAAK,EAAE,IAAI,KAAK,MAAM,OAAO,KAAK,SAAS,CAAC,IAAI;CAExF,OAAO,WAAW,OAAO,cAAc,KAAK;AAC9C;AAEA,SAAgB,mBAAmB,EACjC,MACA,OACA,KACA,UACA,YAOC;CACD,MAAM,SAAS,WAAW,iBAAiB;CAE3C,MAAM,QAAQ,cAA+B;EAC3C,MAAM,YAAY,OAAO,CAAC;EAC1B,MAAM,QAAQ,UAAU,SAAS;EACjC,MAAM,OAAO,WAAW,MAAM,KAAK;EACnC,MAAM,qBAAqB,wBAAwB,MAAM,MAAM;EAC/D,MAAM,eAAe,WAAW,oBAAoB,SAAS,KAAK;EAElE,OAAO;GACL,KAAK;GACL;GACA;GACA,QAAQ,SAAS;IAAE,GAAG,OAAO;IAAQ,GAAG;GAAU,IAAI;GACtD;GACA,WAAW,SAAS,QAAQ,WAAW,IAAI;GAC3C,UAAU;GACV,aAAa,SAAS,WAAW,WAAW,MAAM,IAAI,CAAC;GACvD,WAAW,SAAS,WAAW,MAAM,IAAI;GACzC,cAAc,SAAS,iBAAiB,oBAAoB,OAAO,OAAO,IAAI;EAChF;CACF,GAAG;EAAC;EAAM;EAAO;EAAK;EAAU;CAAM,CAAC;CAEvC,OAAO,oBAAC,kBAAkB,UAAnB;EAAmC;EAAQ;CAAqC,CAAA;AACzF;;AAGA,SAAgB,gBAAwC;CACtD,OAAO,WAAW,iBAAiB;AACrC"}
@@ -1,5 +1,5 @@
1
1
  import { createContext, useContext } from "react";
2
- //#region resources/js/form/components/prefill-context.ts
2
+ //#region resources/js/form/hooks/prefill-context.ts
3
3
  var PrefillContext = createContext(null);
4
4
  var PrefillProvider = PrefillContext.Provider;
5
5
  function usePrefillController() {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prefill-context.js","names":[],"sources":["../../../resources/js/form/hooks/prefill-context.ts"],"sourcesContent":["import { createContext, useContext } from \"react\";\n\nexport type PrefillController = {\n markUserEdit: (overrideKey: string) => void;\n};\n\nconst PrefillContext = createContext<PrefillController | null>(null);\n\nexport const PrefillProvider = PrefillContext.Provider;\n\nexport function usePrefillController(): PrefillController | null {\n return useContext(PrefillContext);\n}\n"],"mappings":";;AAMA,IAAM,iBAAiB,cAAwC,IAAI;AAEnE,IAAa,kBAAkB,eAAe;AAE9C,SAAgB,uBAAiD;CAC/D,OAAO,WAAW,cAAc;AAClC"}
@@ -1,4 +1,4 @@
1
- import { Node } from '../../core/types';
1
+ import { Node } from '../../core/types.js';
2
2
  export declare function ResolvedNodesProvider({ nodes, children, }: {
3
3
  nodes: Record<string, Node>;
4
4
  children: React.ReactNode;
@@ -1,8 +1,8 @@
1
- import { fieldProps } from "./field-props.js";
1
+ import { fieldProps } from "../lib/field-props.js";
2
2
  import { useFieldScope } from "./field-scope.js";
3
3
  import { createContext, useContext } from "react";
4
4
  import { jsx } from "react/jsx-runtime";
5
- //#region resources/js/form/components/resolved-nodes.tsx
5
+ //#region resources/js/form/hooks/resolved-nodes.tsx
6
6
  var ResolvedNodesContext = createContext({});
7
7
  function ResolvedNodesProvider({ nodes, children }) {
8
8
  return /* @__PURE__ */ jsx(ResolvedNodesContext.Provider, {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolved-nodes.js","names":[],"sources":["../../../resources/js/form/hooks/resolved-nodes.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport type { Node } from \"@lattice-php/lattice/core/types\";\nimport { fieldProps } from \"@lattice-php/lattice/form/lib/field-props\";\nimport { useFieldScope } from \"./field-scope\";\n\nconst ResolvedNodesContext = createContext<Record<string, Node>>({});\n\nexport function ResolvedNodesProvider({\n nodes,\n children,\n}: {\n nodes: Record<string, Node>;\n children: React.ReactNode;\n}) {\n return <ResolvedNodesContext.Provider value={nodes}>{children}</ResolvedNodesContext.Provider>;\n}\n\nexport function useResolvedNode(node: Node): Node {\n const nodes = useContext(ResolvedNodesContext);\n const name = fieldProps(node).name ?? \"\";\n const scope = useFieldScope();\n const path = name && scope ? scope.errorKey(name) : name;\n\n return (path && nodes[path]) || (name && nodes[name]) || node;\n}\n"],"mappings":";;;;;AAKA,IAAM,uBAAuB,cAAoC,CAAC,CAAC;AAEnE,SAAgB,sBAAsB,EACpC,OACA,YAIC;CACD,OAAO,oBAAC,qBAAqB,UAAtB;EAA+B,OAAO;EAAQ;CAAwC,CAAA;AAC/F;AAEA,SAAgB,gBAAgB,MAAkB;CAChD,MAAM,QAAQ,WAAW,oBAAoB;CAC7C,MAAM,OAAO,WAAW,IAAI,EAAE,QAAQ;CACtC,MAAM,QAAQ,cAAc;CAC5B,MAAM,OAAO,QAAQ,QAAQ,MAAM,SAAS,IAAI,IAAI;CAEpD,OAAQ,QAAQ,MAAM,SAAW,QAAQ,MAAM,SAAU;AAC3D"}
@@ -1,6 +1,6 @@
1
1
  import { createContext, useContext } from "react";
2
2
  import { jsx } from "react/jsx-runtime";
3
- //#region resources/js/form/components/row-layout-context.tsx
3
+ //#region resources/js/form/hooks/row-layout-context.tsx
4
4
  var TableCellContext = createContext(false);
5
5
  function TableCellProvider({ children }) {
6
6
  return /* @__PURE__ */ jsx(TableCellContext.Provider, {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"row-layout-context.js","names":[],"sources":["../../../resources/js/form/hooks/row-layout-context.tsx"],"sourcesContent":["import { createContext, useContext } from \"react\";\n\nconst TableCellContext = createContext(false);\n\nexport function TableCellProvider({ children }: { children: React.ReactNode }) {\n return <TableCellContext.Provider value={true}>{children}</TableCellContext.Provider>;\n}\n\n/** True when a field is being rendered inside a table-layout cell (no own label). */\nexport function useInTableCell(): boolean {\n return useContext(TableCellContext);\n}\n"],"mappings":";;;AAEA,IAAM,mBAAmB,cAAc,KAAK;AAE5C,SAAgB,kBAAkB,EAAE,YAA2C;CAC7E,OAAO,oBAAC,iBAAiB,UAAlB;EAA2B,OAAO;EAAO;CAAoC,CAAA;AACtF;;AAGA,SAAgB,iBAA0B;CACxC,OAAO,WAAW,gBAAgB;AACpC"}
@@ -1,5 +1,5 @@
1
- import { Node } from '../../core/types';
2
- import { FieldState } from './conditions';
1
+ import { Node } from '../../core/types.js';
2
+ import { FieldState } from '../lib/conditions.js';
3
3
  export type ControlledField = FieldState & {
4
4
  localName: string;
5
5
  name: string;
@@ -1,13 +1,14 @@
1
1
  import { testIdentity } from "../../core/test-id.js";
2
2
  import { useFormContext } from "./context.js";
3
- import { fieldProps } from "./field-props.js";
3
+ import { fieldProps } from "../lib/field-props.js";
4
4
  import { useFieldScope } from "./field-scope.js";
5
5
  import { useFormValue } from "./values.js";
6
- import { useDependentField } from "./use-dependent-field.js";
7
6
  import { useFieldCommit } from "./use-field-commit.js";
8
- //#region resources/js/form/components/use-controlled-field.ts
7
+ import { useDependentField } from "./use-dependent-field.js";
8
+ import { fieldDomName } from "../lib/field-dom-name.js";
9
+ //#region resources/js/form/hooks/use-controlled-field.ts
9
10
  function useControlledField(node) {
10
- const { errors } = useFormContext();
11
+ const { errors, fieldIdPrefix } = useFormContext();
11
12
  const scope = useFieldScope();
12
13
  const state = useDependentField(node);
13
14
  const props = fieldProps(node);
@@ -16,7 +17,7 @@ function useControlledField(node) {
16
17
  const storedValue = scope ? scope.getValue(localName) : globalValue;
17
18
  const currentValue = storedValue !== void 0 ? storedValue : props.value;
18
19
  const value = typeof currentValue === "string" || typeof currentValue === "number" ? String(currentValue) : "";
19
- const domName = scope ? scope.scopedName(localName) : localName;
20
+ const domName = fieldDomName(scope ? scope.scopedName(localName) : localName, fieldIdPrefix);
20
21
  const errorKey = scope ? scope.errorKey(localName) : localName;
21
22
  const { commit: commitField, change: changeField, blur: blurField } = useFieldCommit();
22
23
  const commit = (next) => commitField(localName, next);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-controlled-field.js","names":[],"sources":["../../../resources/js/form/hooks/use-controlled-field.ts"],"sourcesContent":["import type { Node } from \"@lattice-php/lattice/core/types\";\nimport { testIdentity } from \"@lattice-php/lattice/core/test-id\";\nimport type { FieldState } from \"@lattice-php/lattice/form/lib/conditions\";\nimport { fieldProps } from \"@lattice-php/lattice/form/lib/field-props\";\nimport { useFieldScope } from \"./field-scope\";\nimport { useFormContext } from \"./context\";\nimport { fieldDomName } from \"@lattice-php/lattice/form/lib/field-dom-name\";\nimport { useDependentField } from \"./use-dependent-field\";\nimport { useFieldCommit } from \"./use-field-commit\";\nimport { useFormValue } from \"./values\";\n\nexport type ControlledField = FieldState & {\n localName: string;\n name: string;\n testId?: string;\n value: string;\n error?: string;\n commit: (value: unknown) => void;\n change: (value: unknown) => void;\n blur: () => void;\n};\n\nexport function useControlledField(node: Node): ControlledField {\n const { errors, fieldIdPrefix } = useFormContext();\n const scope = useFieldScope();\n const state = useDependentField(node);\n const props = fieldProps(node);\n const localName = props.name ?? \"\";\n\n const globalValue = useFormValue(localName);\n const storedValue = scope ? scope.getValue(localName) : globalValue;\n const currentValue = storedValue !== undefined ? storedValue : props.value;\n const value =\n typeof currentValue === \"string\" || typeof currentValue === \"number\"\n ? String(currentValue)\n : \"\";\n\n const domName = fieldDomName(scope ? scope.scopedName(localName) : localName, fieldIdPrefix);\n const errorKey = scope ? scope.errorKey(localName) : localName;\n\n const { commit: commitField, change: changeField, blur: blurField } = useFieldCommit();\n const commit = (next: unknown): void => commitField(localName, next);\n const change = (next: unknown): void => changeField(localName, next);\n const blur = (): void => blurField(localName);\n\n return {\n ...state,\n localName,\n name: domName,\n testId: testIdentity(localName),\n value,\n error: errors[errorKey],\n commit,\n change,\n blur,\n };\n}\n"],"mappings":";;;;;;;;;AAsBA,SAAgB,mBAAmB,MAA6B;CAC9D,MAAM,EAAE,QAAQ,kBAAkB,eAAe;CACjD,MAAM,QAAQ,cAAc;CAC5B,MAAM,QAAQ,kBAAkB,IAAI;CACpC,MAAM,QAAQ,WAAW,IAAI;CAC7B,MAAM,YAAY,MAAM,QAAQ;CAEhC,MAAM,cAAc,aAAa,SAAS;CAC1C,MAAM,cAAc,QAAQ,MAAM,SAAS,SAAS,IAAI;CACxD,MAAM,eAAe,gBAAgB,KAAA,IAAY,cAAc,MAAM;CACrE,MAAM,QACJ,OAAO,iBAAiB,YAAY,OAAO,iBAAiB,WACxD,OAAO,YAAY,IACnB;CAEN,MAAM,UAAU,aAAa,QAAQ,MAAM,WAAW,SAAS,IAAI,WAAW,aAAa;CAC3F,MAAM,WAAW,QAAQ,MAAM,SAAS,SAAS,IAAI;CAErD,MAAM,EAAE,QAAQ,aAAa,QAAQ,aAAa,MAAM,cAAc,eAAe;CACrF,MAAM,UAAU,SAAwB,YAAY,WAAW,IAAI;CACnE,MAAM,UAAU,SAAwB,YAAY,WAAW,IAAI;CACnE,MAAM,aAAmB,UAAU,SAAS;CAE5C,OAAO;EACL,GAAG;EACH;EACA,MAAM;EACN,QAAQ,aAAa,SAAS;EAC9B;EACA,OAAO,OAAO;EACd;EACA;EACA;CACF;AACF"}
@@ -0,0 +1,3 @@
1
+ import { Node } from '../../core/types.js';
2
+ import { FieldState } from '../lib/conditions.js';
3
+ export declare function useDependentField(node: Node): FieldState;
@@ -1,18 +1,18 @@
1
- import { fieldProps } from "./field-props.js";
1
+ import { fieldProps } from "../lib/field-props.js";
2
2
  import { useFieldScope } from "./field-scope.js";
3
- import { useFormValues } from "./values.js";
4
- import { evaluateConditions } from "./conditions.js";
5
- //#region resources/js/form/components/use-dependent-field.ts
3
+ import { useFormValuesFor } from "./values.js";
4
+ import { conditionFields, evaluateConditions } from "../lib/conditions.js";
5
+ import { useMemo } from "react";
6
+ //#region resources/js/form/hooks/use-dependent-field.ts
6
7
  function useDependentField(node) {
7
- const values = useFormValues();
8
8
  const scope = useFieldScope();
9
9
  const props = fieldProps(node);
10
+ const values = useFormValuesFor(useMemo(() => conditionFields(props.conditions), [props.conditions]));
10
11
  const conditionValues = scope ? {
11
12
  ...values,
12
13
  ...scope.values
13
14
  } : values;
14
15
  return evaluateConditions(props.conditions ?? void 0, conditionValues, {
15
- hidden: props.hidden ?? false,
16
16
  required: props.required ?? false,
17
17
  readOnly: props.readOnly ?? false,
18
18
  disabled: props.disabled ?? false
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-dependent-field.js","names":[],"sources":["../../../resources/js/form/hooks/use-dependent-field.ts"],"sourcesContent":["import type { Node } from \"@lattice-php/lattice/core/types\";\nimport { useMemo } from \"react\";\nimport {\n conditionFields,\n type FieldState,\n evaluateConditions,\n} from \"@lattice-php/lattice/form/lib/conditions\";\nimport { fieldProps } from \"@lattice-php/lattice/form/lib/field-props\";\nimport { useFieldScope } from \"./field-scope\";\nimport { useFormValuesFor } from \"./values\";\n\nexport function useDependentField(node: Node): FieldState {\n const scope = useFieldScope();\n const props = fieldProps(node);\n const fields = useMemo(() => conditionFields(props.conditions), [props.conditions]);\n const values = useFormValuesFor(fields);\n // Bare condition names resolve to row siblings first; form values remain the fallback.\n const conditionValues = scope ? { ...values, ...scope.values } : values;\n\n return evaluateConditions(props.conditions ?? undefined, conditionValues, {\n required: props.required ?? false,\n readOnly: props.readOnly ?? false,\n disabled: props.disabled ?? false,\n });\n}\n"],"mappings":";;;;;;AAWA,SAAgB,kBAAkB,MAAwB;CACxD,MAAM,QAAQ,cAAc;CAC5B,MAAM,QAAQ,WAAW,IAAI;CAE7B,MAAM,SAAS,iBADA,cAAc,gBAAgB,MAAM,UAAU,GAAG,CAAC,MAAM,UAAU,CACjD,CAAM;CAEtC,MAAM,kBAAkB,QAAQ;EAAE,GAAG;EAAQ,GAAG,MAAM;CAAO,IAAI;CAEjE,OAAO,mBAAmB,MAAM,cAAc,KAAA,GAAW,iBAAiB;EACxE,UAAU,MAAM,YAAY;EAC5B,UAAU,MAAM,YAAY;EAC5B,UAAU,MAAM,YAAY;CAC9B,CAAC;AACH"}
@@ -1,3 +1,4 @@
1
+ import { ReactNode } from 'react';
1
2
  type FieldCommit = {
2
3
  /** Write the value and validate immediately (precognitive) or clear errors. */
3
4
  commit: (name: string, value: unknown) => void;
@@ -6,6 +7,10 @@ type FieldCommit = {
6
7
  /** Validate the field now if precognitive (e.g. on blur or popover close). */
7
8
  blur: (name: string) => void;
8
9
  };
10
+ export declare function FieldCommitOverrideProvider({ children, value, }: {
11
+ children: ReactNode;
12
+ value: FieldCommit;
13
+ }): import('react').FunctionComponentElement<import('react').ProviderProps<FieldCommit | null>>;
9
14
  /**
10
15
  * The shared field-mutation contract every form field uses to write its value
11
16
  * and drive precognition. Fields that validate on change call `commit`; fields
@@ -2,7 +2,12 @@ import { useFormContext } from "./context.js";
2
2
  import { usePrefillController } from "./prefill-context.js";
3
3
  import { useFieldScope } from "./field-scope.js";
4
4
  import { useSetFormValue } from "./values.js";
5
- //#region resources/js/form/components/use-field-commit.ts
5
+ import { createContext, createElement, useContext } from "react";
6
+ //#region resources/js/form/hooks/use-field-commit.ts
7
+ var FieldCommitOverrideContext = createContext(null);
8
+ function FieldCommitOverrideProvider({ children, value }) {
9
+ return createElement(FieldCommitOverrideContext.Provider, { value }, children);
10
+ }
6
11
  /**
7
12
  * The shared field-mutation contract every form field uses to write its value
8
13
  * and drive precognition. Fields that validate on change call `commit`; fields
@@ -13,10 +18,12 @@ import { useSetFormValue } from "./values.js";
13
18
  * behavior is identical to before.
14
19
  */
15
20
  function useFieldCommit() {
21
+ const override = useContext(FieldCommitOverrideContext);
16
22
  const { clearErrors, precognitive, validate } = useFormContext();
17
23
  const setGlobal = useSetFormValue();
18
24
  const scope = useFieldScope();
19
25
  const prefill = usePrefillController();
26
+ if (override) return override;
20
27
  const write = (name, value) => {
21
28
  if (scope) scope.setValue(name, value);
22
29
  else setGlobal(name, value);
@@ -39,6 +46,6 @@ function useFieldCommit() {
39
46
  };
40
47
  }
41
48
  //#endregion
42
- export { useFieldCommit };
49
+ export { FieldCommitOverrideProvider, useFieldCommit };
43
50
 
44
51
  //# sourceMappingURL=use-field-commit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-field-commit.js","names":[],"sources":["../../../resources/js/form/hooks/use-field-commit.ts"],"sourcesContent":["import { createContext, createElement, useContext } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { useFieldScope } from \"./field-scope\";\nimport { useFormContext } from \"./context\";\nimport { usePrefillController } from \"./prefill-context\";\nimport { useSetFormValue } from \"./values\";\n\ntype FieldCommit = {\n /** Write the value and validate immediately (precognitive) or clear errors. */\n commit: (name: string, value: unknown) => void;\n /** Write the value and clear errors, deferring validation to a later `blur`. */\n change: (name: string, value: unknown) => void;\n /** Validate the field now if precognitive (e.g. on blur or popover close). */\n blur: (name: string) => void;\n};\n\nconst FieldCommitOverrideContext = createContext<FieldCommit | null>(null);\n\nexport function FieldCommitOverrideProvider({\n children,\n value,\n}: {\n children: ReactNode;\n value: FieldCommit;\n}) {\n return createElement(FieldCommitOverrideContext.Provider, { value }, children);\n}\n\n/**\n * The shared field-mutation contract every form field uses to write its value\n * and drive precognition. Fields that validate on change call `commit`; fields\n * that validate on blur/close (rich editor, select) call `change` then `blur`.\n *\n * When called inside a `FieldScopeProvider`, writes go through the scope's\n * `setValue` and error paths use the scoped dot-key; outside a scope the\n * behavior is identical to before.\n */\nexport function useFieldCommit(): FieldCommit {\n const override = useContext(FieldCommitOverrideContext);\n const { clearErrors, precognitive, validate } = useFormContext();\n const setGlobal = useSetFormValue();\n const scope = useFieldScope();\n const prefill = usePrefillController();\n\n if (override) {\n return override;\n }\n\n const write = (name: string, value: unknown): void => {\n if (scope) {\n scope.setValue(name, value);\n } else {\n setGlobal(name, value);\n }\n prefill?.markUserEdit(scope ? scope.overrideKey(name) : name);\n };\n const errorPath = (name: string): string => (scope ? scope.errorKey(name) : name);\n\n return {\n commit(name, value) {\n write(name, value);\n if (precognitive) {\n validate(errorPath(name));\n } else {\n clearErrors(errorPath(name));\n }\n },\n change(name, value) {\n write(name, value);\n clearErrors(errorPath(name));\n },\n blur(name) {\n if (precognitive) {\n validate(errorPath(name));\n }\n },\n };\n}\n"],"mappings":";;;;;;AAgBA,IAAM,6BAA6B,cAAkC,IAAI;AAEzE,SAAgB,4BAA4B,EAC1C,UACA,SAIC;CACD,OAAO,cAAc,2BAA2B,UAAU,EAAE,MAAM,GAAG,QAAQ;AAC/E;;;;;;;;;;AAWA,SAAgB,iBAA8B;CAC5C,MAAM,WAAW,WAAW,0BAA0B;CACtD,MAAM,EAAE,aAAa,cAAc,aAAa,eAAe;CAC/D,MAAM,YAAY,gBAAgB;CAClC,MAAM,QAAQ,cAAc;CAC5B,MAAM,UAAU,qBAAqB;CAErC,IAAI,UACF,OAAO;CAGT,MAAM,SAAS,MAAc,UAAyB;EACpD,IAAI,OACF,MAAM,SAAS,MAAM,KAAK;OAE1B,UAAU,MAAM,KAAK;EAEvB,SAAS,aAAa,QAAQ,MAAM,YAAY,IAAI,IAAI,IAAI;CAC9D;CACA,MAAM,aAAa,SAA0B,QAAQ,MAAM,SAAS,IAAI,IAAI;CAE5E,OAAO;EACL,OAAO,MAAM,OAAO;GAClB,MAAM,MAAM,KAAK;GACjB,IAAI,cACF,SAAS,UAAU,IAAI,CAAC;QAExB,YAAY,UAAU,IAAI,CAAC;EAE/B;EACA,OAAO,MAAM,OAAO;GAClB,MAAM,MAAM,KAAK;GACjB,YAAY,UAAU,IAAI,CAAC;EAC7B;EACA,KAAK,MAAM;GACT,IAAI,cACF,SAAS,UAAU,IAAI,CAAC;EAE5B;CACF;AACF"}
@@ -1,5 +1,5 @@
1
- import { Node } from '../../core/types';
2
- import { PrefillController } from './prefill-context';
1
+ import { Node } from '../../core/types.js';
2
+ import { PrefillController } from './prefill-context.js';
3
3
  type FormResolver = {
4
4
  nodes: Record<string, Node>;
5
5
  markUserEdit: PrefillController["markUserEdit"];
@@ -1,10 +1,10 @@
1
- import { walkFields } from "./field-props.js";
2
- import { postFormAction } from "./form-transport.js";
3
- import { getPath } from "./form-path.js";
4
- import { collectPrefillTargets, pathsToClear, pruneOverrides, seededOverrides } from "./prefill-targets.js";
1
+ import { walkFields } from "../lib/field-props.js";
2
+ import { getPath } from "../lib/form-path.js";
5
3
  import { useFormValues, useSetFormValue } from "./values.js";
4
+ import { postFormAction } from "../lib/form-transport.js";
5
+ import { collectPrefillTargets, pathsToClear, pruneOverrides, seededOverrides } from "../lib/prefill-targets.js";
6
6
  import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
7
- //#region resources/js/form/components/use-form-resolver.ts
7
+ //#region resources/js/form/hooks/use-form-resolver.ts
8
8
  function useFormResolver(action, componentRef, nodes) {
9
9
  const values = useFormValues();
10
10
  const setValue = useSetFormValue();
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-form-resolver.js","names":[],"sources":["../../../resources/js/form/hooks/use-form-resolver.ts"],"sourcesContent":["import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from \"react\";\nimport type { Node } from \"@lattice-php/lattice/core/types\";\nimport { walkFields } from \"@lattice-php/lattice/form/lib/field-props\";\nimport { FORM_DEBOUNCE_MS, postFormAction } from \"@lattice-php/lattice/form/lib/form-transport\";\nimport {\n collectPrefillTargets,\n getPath,\n pathsToClear,\n pruneOverrides,\n seededOverrides,\n} from \"@lattice-php/lattice/form/lib/prefill-targets\";\nimport type { PrefillController } from \"./prefill-context\";\nimport { useFormValues, useSetFormValue } from \"./values\";\n\ntype ResolveResponse = {\n fields?: Record<string, Node>;\n values?: Record<string, unknown>;\n prefill?: Record<string, unknown>;\n};\n\ntype FormResolver = {\n nodes: Record<string, Node>;\n markUserEdit: PrefillController[\"markUserEdit\"];\n};\n\nexport function useFormResolver(\n action: string,\n componentRef: string,\n nodes: Node[] | undefined,\n): FormResolver {\n const values = useFormValues();\n const setValue = useSetFormValue();\n const [resolved, setResolved] = useState<Record<string, Node>>({});\n\n const targets = useMemo(() => collectPrefillTargets(nodes, values), [nodes, values]);\n\n const overrides = useRef<Set<string>>(new Set());\n const seededOverrideKeys = useRef<Set<string>>(new Set());\n const previousValues = useRef<Record<string, unknown>>(values);\n const previousTargets = useRef(targets);\n\n // Read targets via a ref inside the effect: `targets` changes identity on every\n // value change, but the effect must fire only when `watchSignature` changes\n // (which already reflects added/removed target paths). Keeping `targets` out of\n // the dep array preserves the targeted watch in non-\"any\" mode.\n const targetsRef = useRef(targets);\n targetsRef.current = targets;\n\n useLayoutEffect(() => {\n const liveOverrideKeys = new Set(targets.map((target) => target.overrideKey));\n seededOverrideKeys.current = new Set(\n [...seededOverrideKeys.current].filter((overrideKey) => liveOverrideKeys.has(overrideKey)),\n );\n const freshTargets = targets.filter(\n (target) => !seededOverrideKeys.current.has(target.overrideKey),\n );\n\n // Layout ordering seeds loaded values before the first resolve effect can apply prefill.\n for (const overrideKey of seededOverrides(freshTargets, values)) {\n overrides.current.add(overrideKey);\n }\n\n for (const target of freshTargets) {\n seededOverrideKeys.current.add(target.overrideKey);\n }\n }, [targets, values]);\n\n const markUserEdit = useCallback((overrideKey: string) => {\n overrides.current.add(overrideKey);\n }, []);\n\n const watch = useMemo(() => {\n const keys = new Set<string>();\n let any = false;\n walkFields(nodes, (props) => {\n if (Array.isArray(props.dependsOnKeys)) {\n for (const key of props.dependsOnKeys) {\n keys.add(String(key));\n }\n }\n if (props.dependsOnAny) {\n any = true;\n }\n });\n return { keys: [...keys], any };\n }, [nodes]);\n\n const watchPaths = useMemo(() => {\n const set = new Set<string>(watch.keys);\n for (const target of targets) {\n for (const dep of target.resetOn) {\n set.add(dep);\n }\n for (const dep of target.refreshOn) {\n set.add(dep);\n }\n }\n return [...set];\n }, [watch.keys, targets]);\n\n // In \"any\" mode the values store keeps a stable reference until something\n // actually changes, so its identity is the change signal. Otherwise hash the\n // watched paths (form-level and per-row).\n const watchSignature = watch.any\n ? values\n : JSON.stringify(watchPaths.map((path) => getPath(values, path)));\n\n useEffect(() => {\n if (watchPaths.length === 0 && !watch.any) {\n return;\n }\n\n const previous = previousValues.current;\n previousValues.current = values;\n\n // `resetOn` deps unlock a path (a fresh product gives a fresh price); `refreshOn`\n // deps only re-ask the server and never clear an override (a customer change\n // re-prices untouched rows but leaves user-edited ones alone).\n for (const overrideKey of pathsToClear(\n { targets: previousTargets.current, values: previous },\n { targets: targetsRef.current, values },\n )) {\n overrides.current.delete(overrideKey);\n }\n previousTargets.current = targetsRef.current;\n\n // Override ownership is row-id keyed, so pruning removes departed rows without reindex drift.\n overrides.current = pruneOverrides(overrides.current, targetsRef.current);\n\n const controller = new AbortController();\n\n const timer = window.setTimeout(() => {\n void postFormAction<ResolveResponse>(\n action,\n componentRef,\n { _resolve: true, ...values },\n controller.signal,\n )\n .then((response) => {\n if (!response) {\n return;\n }\n for (const [name, value] of Object.entries(response.values ?? {})) {\n setValue(name, value);\n }\n const targetsByPath = new Map(\n targetsRef.current.map((target) => [target.path, target] as const),\n );\n for (const [path, value] of Object.entries(response.prefill ?? {})) {\n const target = targetsByPath.get(path);\n\n if (target && !overrides.current.has(target.overrideKey)) {\n setValue(path, value);\n }\n }\n if (response.fields) {\n setResolved(response.fields);\n }\n })\n .catch(() => {});\n }, FORM_DEBOUNCE_MS);\n\n return () => {\n window.clearTimeout(timer);\n controller.abort();\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [watchSignature, action, componentRef, watch.any, setValue]);\n\n return { nodes: resolved, markUserEdit };\n}\n"],"mappings":";;;;;;;AAyBA,SAAgB,gBACd,QACA,cACA,OACc;CACd,MAAM,SAAS,cAAc;CAC7B,MAAM,WAAW,gBAAgB;CACjC,MAAM,CAAC,UAAU,eAAe,SAA+B,CAAC,CAAC;CAEjE,MAAM,UAAU,cAAc,sBAAsB,OAAO,MAAM,GAAG,CAAC,OAAO,MAAM,CAAC;CAEnF,MAAM,YAAY,uBAAoB,IAAI,IAAI,CAAC;CAC/C,MAAM,qBAAqB,uBAAoB,IAAI,IAAI,CAAC;CACxD,MAAM,iBAAiB,OAAgC,MAAM;CAC7D,MAAM,kBAAkB,OAAO,OAAO;CAMtC,MAAM,aAAa,OAAO,OAAO;CACjC,WAAW,UAAU;CAErB,sBAAsB;EACpB,MAAM,mBAAmB,IAAI,IAAI,QAAQ,KAAK,WAAW,OAAO,WAAW,CAAC;EAC5E,mBAAmB,UAAU,IAAI,IAC/B,CAAC,GAAG,mBAAmB,OAAO,EAAE,QAAQ,gBAAgB,iBAAiB,IAAI,WAAW,CAAC,CAC3F;EACA,MAAM,eAAe,QAAQ,QAC1B,WAAW,CAAC,mBAAmB,QAAQ,IAAI,OAAO,WAAW,CAChE;EAGA,KAAK,MAAM,eAAe,gBAAgB,cAAc,MAAM,GAC5D,UAAU,QAAQ,IAAI,WAAW;EAGnC,KAAK,MAAM,UAAU,cACnB,mBAAmB,QAAQ,IAAI,OAAO,WAAW;CAErD,GAAG,CAAC,SAAS,MAAM,CAAC;CAEpB,MAAM,eAAe,aAAa,gBAAwB;EACxD,UAAU,QAAQ,IAAI,WAAW;CACnC,GAAG,CAAC,CAAC;CAEL,MAAM,QAAQ,cAAc;EAC1B,MAAM,uBAAO,IAAI,IAAY;EAC7B,IAAI,MAAM;EACV,WAAW,QAAQ,UAAU;GAC3B,IAAI,MAAM,QAAQ,MAAM,aAAa,GACnC,KAAK,MAAM,OAAO,MAAM,eACtB,KAAK,IAAI,OAAO,GAAG,CAAC;GAGxB,IAAI,MAAM,cACR,MAAM;EAEV,CAAC;EACD,OAAO;GAAE,MAAM,CAAC,GAAG,IAAI;GAAG;EAAI;CAChC,GAAG,CAAC,KAAK,CAAC;CAEV,MAAM,aAAa,cAAc;EAC/B,MAAM,MAAM,IAAI,IAAY,MAAM,IAAI;EACtC,KAAK,MAAM,UAAU,SAAS;GAC5B,KAAK,MAAM,OAAO,OAAO,SACvB,IAAI,IAAI,GAAG;GAEb,KAAK,MAAM,OAAO,OAAO,WACvB,IAAI,IAAI,GAAG;EAEf;EACA,OAAO,CAAC,GAAG,GAAG;CAChB,GAAG,CAAC,MAAM,MAAM,OAAO,CAAC;CASxB,gBAAgB;EACd,IAAI,WAAW,WAAW,KAAK,CAAC,MAAM,KACpC;EAGF,MAAM,WAAW,eAAe;EAChC,eAAe,UAAU;EAKzB,KAAK,MAAM,eAAe,aACxB;GAAE,SAAS,gBAAgB;GAAS,QAAQ;EAAS,GACrD;GAAE,SAAS,WAAW;GAAS;EAAO,CACxC,GACE,UAAU,QAAQ,OAAO,WAAW;EAEtC,gBAAgB,UAAU,WAAW;EAGrC,UAAU,UAAU,eAAe,UAAU,SAAS,WAAW,OAAO;EAExE,MAAM,aAAa,IAAI,gBAAgB;EAEvC,MAAM,QAAQ,OAAO,iBAAiB;GACpC,eACE,QACA,cACA;IAAE,UAAU;IAAM,GAAG;GAAO,GAC5B,WAAW,MACb,EACG,MAAM,aAAa;IAClB,IAAI,CAAC,UACH;IAEF,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,SAAS,UAAU,CAAC,CAAC,GAC9D,SAAS,MAAM,KAAK;IAEtB,MAAM,gBAAgB,IAAI,IACxB,WAAW,QAAQ,KAAK,WAAW,CAAC,OAAO,MAAM,MAAM,CAAU,CACnE;IACA,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,SAAS,WAAW,CAAC,CAAC,GAAG;KAClE,MAAM,SAAS,cAAc,IAAI,IAAI;KAErC,IAAI,UAAU,CAAC,UAAU,QAAQ,IAAI,OAAO,WAAW,GACrD,SAAS,MAAM,KAAK;IAExB;IACA,IAAI,SAAS,QACX,YAAY,SAAS,MAAM;GAE/B,CAAC,EACA,YAAY,CAAC,CAAC;EACnB,GAAA,GAAmB;EAEnB,aAAa;GACX,OAAO,aAAa,KAAK;GACzB,WAAW,MAAM;EACnB;CAEF,GAAG;EAhEoB,MAAM,MACzB,SACA,KAAK,UAAU,WAAW,KAAK,SAAS,QAAQ,QAAQ,IAAI,CAAC,CAAC;EA8D9C;EAAQ;EAAc,MAAM;EAAK;CAAQ,CAAC;CAE9D,OAAO;EAAE,OAAO;EAAU;CAAa;AACzC"}
@@ -1,7 +1,7 @@
1
1
  import { useFieldScope } from "./field-scope.js";
2
2
  import { useFormValue, useSetFormValue } from "./values.js";
3
3
  import { useEffect } from "react";
4
- //#region resources/js/form/components/use-seed-default.ts
4
+ //#region resources/js/form/hooks/use-seed-default.ts
5
5
  /**
6
6
  * Seed a field's default into the store so dependent fields and the submitted
7
7
  * payload reflect it before the user interacts. Pass undefined to skip.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-seed-default.js","names":[],"sources":["../../../resources/js/form/hooks/use-seed-default.ts"],"sourcesContent":["import { useEffect } from \"react\";\nimport { useFieldScope } from \"./field-scope\";\nimport { useFormValue, useSetFormValue } from \"./values\";\n\n/**\n * Seed a field's default into the store so dependent fields and the submitted\n * payload reflect it before the user interacts. Pass undefined to skip.\n */\nexport function useSeedDefault(name: string, value: unknown): void {\n const scope = useFieldScope();\n const globalStored = useFormValue(name);\n const stored = scope ? scope.getValue(name) : globalStored;\n const setValue = useSetFormValue();\n\n useEffect(() => {\n if (stored === undefined && value !== undefined) {\n if (scope) {\n scope.setValue(name, value);\n } else {\n setValue(name, value);\n }\n }\n }, [name, value, stored, setValue, scope]);\n}\n"],"mappings":";;;;;;;;AAQA,SAAgB,eAAe,MAAc,OAAsB;CACjE,MAAM,QAAQ,cAAc;CAC5B,MAAM,eAAe,aAAa,IAAI;CACtC,MAAM,SAAS,QAAQ,MAAM,SAAS,IAAI,IAAI;CAC9C,MAAM,WAAW,gBAAgB;CAEjC,gBAAgB;EACd,IAAI,WAAW,KAAA,KAAa,UAAU,KAAA,GACpC,IAAI,OACF,MAAM,SAAS,MAAM,KAAK;OAE1B,SAAS,MAAM,KAAK;CAG1B,GAAG;EAAC;EAAM;EAAO;EAAQ;EAAU;CAAK,CAAC;AAC3C"}
@@ -1,7 +1,9 @@
1
+ export type SetFormValue = (name: string, value: unknown | ((previous: unknown) => unknown)) => void;
1
2
  export declare function FormValuesProvider({ initial, children, }: {
2
3
  initial: Record<string, unknown>;
3
4
  children: React.ReactNode;
4
5
  }): import("react").JSX.Element;
5
6
  export declare function useFormValues(): Record<string, unknown>;
6
7
  export declare function useFormValue(name: string): unknown;
7
- export declare function useSetFormValue(): (name: string, value: unknown) => void;
8
+ export declare function useFormValuesFor(paths: string[]): Record<string, unknown>;
9
+ export declare function useSetFormValue(): SetFormValue;
@@ -0,0 +1,136 @@
1
+ import { getPath, setPath } from "../lib/form-path.js";
2
+ import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useSyncExternalStore } from "react";
3
+ import { jsx } from "react/jsx-runtime";
4
+ //#region resources/js/form/hooks/values.tsx
5
+ var emptyValues = {};
6
+ var emptySelectedValues = {};
7
+ var FormValuesStoreContext = createContext(null);
8
+ var SetFormValueContext = createContext(() => {});
9
+ function valuesEqual(a, b) {
10
+ if (Object.is(a, b)) return true;
11
+ if (!a || !b || typeof a !== "object" || typeof b !== "object") return false;
12
+ if (Array.isArray(a) || Array.isArray(b)) return Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((value, index) => valuesEqual(value, b[index]));
13
+ const aEntries = Object.entries(a);
14
+ const bObject = b;
15
+ return aEntries.length === Object.keys(bObject).length && aEntries.every(([key, value]) => valuesEqual(value, bObject[key]));
16
+ }
17
+ function normalizePath(path) {
18
+ return path.split(".").filter((part) => part !== "").join(".");
19
+ }
20
+ function pathsOverlap(left, right) {
21
+ return left === "" || right === "" || left === right || left.startsWith(`${right}.`) || right.startsWith(`${left}.`);
22
+ }
23
+ function createFormValuesStore(initial) {
24
+ let initialValues = initial;
25
+ let values = initial;
26
+ const listeners = /* @__PURE__ */ new Set();
27
+ const pathListeners = /* @__PURE__ */ new Map();
28
+ const selectedCache = /* @__PURE__ */ new Map();
29
+ const notify = (path) => {
30
+ for (const listener of listeners) listener();
31
+ const normalizedPath = normalizePath(path);
32
+ for (const [subscribedPath, subscribedListeners] of pathListeners) {
33
+ if (!pathsOverlap(subscribedPath, normalizedPath)) continue;
34
+ for (const listener of subscribedListeners) listener();
35
+ }
36
+ };
37
+ const updateValues = (next, path) => {
38
+ if (Object.is(values, next)) return;
39
+ values = next;
40
+ selectedCache.clear();
41
+ notify(path);
42
+ };
43
+ const subscribePath = (path, listener) => {
44
+ const normalizedPath = normalizePath(path);
45
+ const listenersForPath = pathListeners.get(normalizedPath) ?? /* @__PURE__ */ new Set();
46
+ listenersForPath.add(listener);
47
+ pathListeners.set(normalizedPath, listenersForPath);
48
+ return () => {
49
+ listenersForPath.delete(listener);
50
+ if (listenersForPath.size === 0) pathListeners.delete(normalizedPath);
51
+ };
52
+ };
53
+ return {
54
+ getPathSnapshot: (path) => getPath(values, path),
55
+ getPathsSnapshot: (paths) => {
56
+ if (paths.length === 0) return emptySelectedValues;
57
+ const normalizedPaths = paths.map(normalizePath);
58
+ const key = JSON.stringify(paths);
59
+ const selectedValues = normalizedPaths.map((path) => getPath(values, path));
60
+ const cached = selectedCache.get(key);
61
+ if (cached && cached.values.length === selectedValues.length && selectedValues.every((value, index) => Object.is(value, cached.values[index]))) return cached.snapshot;
62
+ const snapshot = Object.fromEntries(paths.map((path, index) => [path, selectedValues[index]]));
63
+ selectedCache.set(key, {
64
+ snapshot,
65
+ values: selectedValues
66
+ });
67
+ return snapshot;
68
+ },
69
+ getSnapshot: () => values,
70
+ replaceInitial: (nextInitial) => {
71
+ if (valuesEqual(initialValues, nextInitial)) return;
72
+ initialValues = nextInitial;
73
+ updateValues(nextInitial, "");
74
+ },
75
+ setValue: (name, value) => {
76
+ const previous = getPath(values, name);
77
+ const next = typeof value === "function" ? value(previous) : value;
78
+ if (Object.is(previous, next)) return;
79
+ updateValues(setPath(values, name, next), name);
80
+ },
81
+ subscribe: (listener) => {
82
+ listeners.add(listener);
83
+ return () => listeners.delete(listener);
84
+ },
85
+ subscribePath,
86
+ subscribePaths: (paths, listener) => {
87
+ const unsubscribers = Array.from(new Set(paths.map(normalizePath))).map((path) => subscribePath(path, listener));
88
+ return () => {
89
+ for (const unsubscribe of unsubscribers) unsubscribe();
90
+ };
91
+ }
92
+ };
93
+ }
94
+ var fallbackFormValuesStore = createFormValuesStore(emptyValues);
95
+ function FormValuesProvider({ initial, children }) {
96
+ const storeRef = useRef(null);
97
+ if (storeRef.current === null) storeRef.current = createFormValuesStore(initial);
98
+ useEffect(() => {
99
+ storeRef.current?.replaceInitial(initial);
100
+ }, [initial]);
101
+ return /* @__PURE__ */ jsx(FormValuesStoreContext.Provider, {
102
+ value: storeRef.current,
103
+ children: /* @__PURE__ */ jsx(SetFormValueContext.Provider, {
104
+ value: storeRef.current.setValue,
105
+ children
106
+ })
107
+ });
108
+ }
109
+ function useFormValuesStore() {
110
+ return useContext(FormValuesStoreContext) ?? fallbackFormValuesStore;
111
+ }
112
+ function useFormValues() {
113
+ const store = useFormValuesStore();
114
+ return useSyncExternalStore(store.subscribe, store.getSnapshot, store.getSnapshot);
115
+ }
116
+ function useFormValue(name) {
117
+ const store = useFormValuesStore();
118
+ const subscribe = useCallback((listener) => store.subscribePath(name, listener), [name, store]);
119
+ const getSnapshot = useCallback(() => store.getPathSnapshot(name), [name, store]);
120
+ return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
121
+ }
122
+ function useFormValuesFor(paths) {
123
+ const store = useFormValuesStore();
124
+ const pathsKey = JSON.stringify(paths);
125
+ const selectedPaths = useMemo(() => JSON.parse(pathsKey), [pathsKey]);
126
+ const subscribe = useCallback((listener) => store.subscribePaths(selectedPaths, listener), [selectedPaths, store]);
127
+ const getSnapshot = useCallback(() => store.getPathsSnapshot(selectedPaths), [selectedPaths, store]);
128
+ return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
129
+ }
130
+ function useSetFormValue() {
131
+ return useContext(SetFormValueContext);
132
+ }
133
+ //#endregion
134
+ export { FormValuesProvider, useFormValue, useFormValues, useFormValuesFor, useSetFormValue };
135
+
136
+ //# sourceMappingURL=values.js.map