@woodger/antd 0.1.1 → 0.1.3

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 (668) hide show
  1. package/dist/affix/Affix.svelte +12 -4
  2. package/dist/affix/affix.types.d.ts +3 -2
  3. package/dist/alert/Alert.svelte +22 -14
  4. package/dist/alert/alert.types.d.ts +12 -11
  5. package/dist/anchor/Anchor.svelte +5 -2
  6. package/dist/anchor/AnchorLink.svelte +4 -1
  7. package/dist/anchor/anchor.types.d.ts +10 -9
  8. package/dist/app/App.svelte +2 -1
  9. package/dist/app/app.types.d.ts +3 -2
  10. package/dist/auto-complete/AutoComplete.svelte +209 -43
  11. package/dist/auto-complete/auto-complete.types.d.ts +34 -3
  12. package/dist/avatar/Avatar.svelte +46 -32
  13. package/dist/avatar/AvatarGroup.svelte +34 -11
  14. package/dist/avatar/AvatarGroupOverflow.svelte +27 -8
  15. package/dist/avatar/AvatarGroupOverflow.svelte.d.ts +2 -0
  16. package/dist/avatar/avatar-group-context.d.ts +10 -0
  17. package/dist/avatar/avatar-group-context.js +11 -0
  18. package/dist/avatar/avatar-group.engine.d.ts +13 -4
  19. package/dist/avatar/avatar-group.engine.js +18 -0
  20. package/dist/avatar/avatar-group.types.d.ts +11 -5
  21. package/dist/avatar/avatar.component.d.ts +7 -0
  22. package/dist/avatar/avatar.component.js +4 -0
  23. package/dist/avatar/avatar.types.d.ts +6 -4
  24. package/dist/badge/Badge.svelte +37 -17
  25. package/dist/badge/BadgeRibbon.svelte +26 -21
  26. package/dist/badge/badge-ribbon.dom.d.ts +2 -4
  27. package/dist/badge/badge-ribbon.dom.js +14 -10
  28. package/dist/badge/badge-ribbon.types.d.ts +12 -11
  29. package/dist/badge/badge-style.dom.d.ts +2 -2
  30. package/dist/badge/badge-style.dom.js +9 -5
  31. package/dist/badge/badge-style.engine.d.ts +5 -0
  32. package/dist/badge/badge-style.engine.js +9 -2
  33. package/dist/badge/badge.component.d.ts +7 -0
  34. package/dist/badge/badge.component.js +4 -0
  35. package/dist/badge/badge.engine.js +1 -1
  36. package/dist/badge/badge.types.d.ts +15 -11
  37. package/dist/border-beam/BorderBeam.svelte +9 -5
  38. package/dist/border-beam/border-beam.engine.d.ts +2 -2
  39. package/dist/border-beam/border-beam.engine.js +7 -12
  40. package/dist/border-beam/border-beam.types.d.ts +4 -3
  41. package/dist/breadcrumb/Breadcrumb.svelte +9 -3
  42. package/dist/breadcrumb/BreadcrumbEntry.svelte +6 -19
  43. package/dist/breadcrumb/breadcrumb.engine.d.ts +5 -2
  44. package/dist/breadcrumb/breadcrumb.engine.js +25 -2
  45. package/dist/breadcrumb/breadcrumb.types.d.ts +30 -18
  46. package/dist/button/Button.svelte +35 -10
  47. package/dist/button/ButtonLabel.svelte +23 -0
  48. package/dist/button/ButtonLabel.svelte.d.ts +13 -0
  49. package/dist/button/button.engine.d.ts +6 -0
  50. package/dist/button/button.engine.js +35 -0
  51. package/dist/button/button.types.d.ts +11 -8
  52. package/dist/calendar/CalendarCore.svelte +26 -18
  53. package/dist/calendar/calendar.component.d.ts +7 -0
  54. package/dist/calendar/calendar.component.js +4 -0
  55. package/dist/calendar/calendar.types.d.ts +8 -7
  56. package/dist/card/Card.svelte +61 -19
  57. package/dist/card/CardGrid.svelte +4 -1
  58. package/dist/card/CardMeta.svelte +4 -1
  59. package/dist/card/card-semantic.engine.d.ts +1 -1
  60. package/dist/card/card-semantic.engine.js +2 -2
  61. package/dist/card/card.component.d.ts +9 -0
  62. package/dist/card/card.component.js +5 -0
  63. package/dist/card/card.engine.d.ts +2 -0
  64. package/dist/card/card.engine.js +7 -0
  65. package/dist/card/card.types.d.ts +19 -19
  66. package/dist/carousel/Carousel.svelte +11 -5
  67. package/dist/carousel/carousel-settings.engine.d.ts +1 -1
  68. package/dist/carousel/carousel.types.d.ts +4 -3
  69. package/dist/cascader/Cascader.svelte +8 -3
  70. package/dist/cascader/Cascader.svelte.d.ts +13 -13
  71. package/dist/cascader/CascaderColumns.svelte +25 -27
  72. package/dist/cascader/CascaderColumns.svelte.d.ts +9 -7
  73. package/dist/cascader/CascaderCore.svelte +814 -133
  74. package/dist/cascader/CascaderCore.svelte.d.ts +14 -14
  75. package/dist/cascader/CascaderPanel.svelte +9 -3
  76. package/dist/cascader/CascaderPanel.svelte.d.ts +13 -13
  77. package/dist/cascader/cascader.component.d.ts +17 -0
  78. package/dist/cascader/cascader.component.js +9 -0
  79. package/dist/cascader/cascader.dom.d.ts +1 -1
  80. package/dist/cascader/cascader.dom.js +2 -2
  81. package/dist/cascader/cascader.engine.d.ts +51 -24
  82. package/dist/cascader/cascader.engine.js +69 -6
  83. package/dist/cascader/cascader.types.d.ts +132 -43
  84. package/dist/checkbox/Checkbox.svelte +19 -10
  85. package/dist/checkbox/CheckboxGroup.svelte +14 -6
  86. package/dist/checkbox/checkbox-group.types.d.ts +7 -4
  87. package/dist/checkbox/checkbox.component.d.ts +7 -0
  88. package/dist/checkbox/checkbox.component.js +4 -0
  89. package/dist/checkbox/checkbox.types.d.ts +15 -13
  90. package/dist/collapse/Collapse.svelte +43 -11
  91. package/dist/collapse/CollapseItemView.svelte +5 -4
  92. package/dist/collapse/CollapsePanel.svelte +35 -3
  93. package/dist/collapse/CollapsePanel.svelte.d.ts +3 -0
  94. package/dist/collapse/collapse-context.d.ts +5 -1
  95. package/dist/collapse/collapse.engine.d.ts +5 -5
  96. package/dist/collapse/collapse.types.d.ts +20 -14
  97. package/dist/color-picker/ColorPicker.svelte +171 -110
  98. package/dist/color-picker/ColorPickerPresets.svelte +9 -4
  99. package/dist/color-picker/color-picker-alignment.dom.d.ts +17 -0
  100. package/dist/color-picker/color-picker-alignment.dom.js +144 -0
  101. package/dist/color-picker/color-picker.types.d.ts +14 -13
  102. package/dist/component-refs.types.d.ts +45 -0
  103. package/dist/component-refs.types.js +1 -0
  104. package/dist/component.types.d.ts +13 -0
  105. package/dist/component.types.js +1 -0
  106. package/dist/config-provider/ConfigProvider.svelte +18 -6
  107. package/dist/config-provider/ConfigProvider.svelte.d.ts +2 -0
  108. package/dist/config-provider/config-context.d.ts +7 -0
  109. package/dist/config-provider/config-context.js +1 -0
  110. package/dist/config-provider/config-provider.component.d.ts +6 -0
  111. package/dist/config-provider/config-provider.component.js +10 -1
  112. package/dist/descriptions/Descriptions.svelte +22 -13
  113. package/dist/descriptions/DescriptionsCell.svelte +19 -19
  114. package/dist/descriptions/DescriptionsCell.svelte.d.ts +2 -1
  115. package/dist/descriptions/descriptions-semantic.engine.d.ts +2 -2
  116. package/dist/descriptions/descriptions-semantic.engine.js +2 -2
  117. package/dist/descriptions/descriptions.types.d.ts +13 -13
  118. package/dist/dialog/dialog-container.model.svelte.d.ts +1 -1
  119. package/dist/dialog/dialog-container.model.svelte.js +14 -2
  120. package/dist/dialog/dialog-focus.dom.d.ts +3 -1
  121. package/dist/dialog/dialog-focus.dom.js +8 -7
  122. package/dist/divider/Divider.svelte +24 -14
  123. package/dist/divider/divider.types.d.ts +6 -5
  124. package/dist/drawer/Drawer.svelte +35 -19
  125. package/dist/drawer/DrawerPanel.svelte +8 -6
  126. package/dist/drawer/drawer-ancestor-clip.dom.d.ts +15 -0
  127. package/dist/drawer/drawer-ancestor-clip.dom.js +145 -0
  128. package/dist/drawer/drawer-clip-plane.dom.d.ts +22 -0
  129. package/dist/drawer/drawer-clip-plane.dom.js +100 -0
  130. package/dist/drawer/drawer-clip-shape.dom.d.ts +5 -0
  131. package/dist/drawer/drawer-clip-shape.dom.js +52 -0
  132. package/dist/drawer/drawer-clip-style.dom.d.ts +34 -0
  133. package/dist/drawer/drawer-clip-style.dom.js +190 -0
  134. package/dist/drawer/drawer-layout.dom.d.ts +6 -0
  135. package/dist/drawer/drawer-layout.dom.js +240 -0
  136. package/dist/drawer/drawer-overflow.dom.d.ts +9 -0
  137. package/dist/drawer/drawer-overflow.dom.js +249 -0
  138. package/dist/drawer/drawer-overflow.engine.d.ts +54 -0
  139. package/dist/drawer/drawer-overflow.engine.js +205 -0
  140. package/dist/drawer/drawer-panel.engine.d.ts +3 -2
  141. package/dist/drawer/drawer-panel.engine.js +4 -5
  142. package/dist/drawer/drawer-svg-clip.dom.d.ts +9 -0
  143. package/dist/drawer/drawer-svg-clip.dom.js +394 -0
  144. package/dist/drawer/drawer.dom.d.ts +2 -0
  145. package/dist/drawer/drawer.dom.js +16 -6
  146. package/dist/drawer/drawer.types.d.ts +22 -21
  147. package/dist/dropdown/Dropdown.svelte +131 -26
  148. package/dist/dropdown/dropdown-position.dom.d.ts +3 -1
  149. package/dist/dropdown/dropdown-position.dom.js +18 -7
  150. package/dist/dropdown/dropdown.engine.d.ts +10 -7
  151. package/dist/dropdown/dropdown.engine.js +29 -13
  152. package/dist/dropdown/dropdown.types.d.ts +7 -6
  153. package/dist/empty/Empty.svelte +17 -11
  154. package/dist/empty/empty.types.d.ts +9 -8
  155. package/dist/flex/Flex.svelte +26 -9
  156. package/dist/flex/flex.types.d.ts +2 -1
  157. package/dist/float-button/FloatButton.svelte +24 -13
  158. package/dist/float-button/FloatButtonBackTop.svelte +6 -6
  159. package/dist/float-button/FloatButtonGroup.svelte +26 -24
  160. package/dist/float-button/float-button-context.d.ts +2 -1
  161. package/dist/float-button/float-button.component.d.ts +9 -0
  162. package/dist/float-button/float-button.component.js +5 -0
  163. package/dist/float-button/float-button.types.d.ts +10 -8
  164. package/dist/form/Form.svelte +241 -42
  165. package/dist/form/Form.svelte.d.ts +4 -4
  166. package/dist/form/FormErrorList.svelte +19 -69
  167. package/dist/form/FormItem.svelte +296 -71
  168. package/dist/form/FormItem.svelte.d.ts +34 -6
  169. package/dist/form/FormItemControlBinding.svelte +68 -0
  170. package/dist/form/FormItemControlBinding.svelte.d.ts +10 -0
  171. package/dist/form/FormItemMessages.svelte +142 -0
  172. package/dist/form/FormItemMessages.svelte.d.ts +23 -0
  173. package/dist/form/FormItemTooltip.svelte +2 -2
  174. package/dist/form/FormList.svelte +49 -4
  175. package/dist/form/FormMessageMotion.svelte +133 -0
  176. package/dist/form/FormMessageMotion.svelte.d.ts +18 -0
  177. package/dist/form/FormProvider.svelte +9 -0
  178. package/dist/form/FormProvider.svelte.d.ts +4 -0
  179. package/dist/form/form-context.d.ts +24 -6
  180. package/dist/form/form-context.js +18 -0
  181. package/dist/form/form-control.engine.d.ts +2 -0
  182. package/dist/form/form-control.engine.js +13 -0
  183. package/dist/form/form-error-list-state.svelte.d.ts +21 -0
  184. package/dist/form/form-error-list-state.svelte.js +77 -0
  185. package/dist/form/form-error-list.engine.js +3 -1
  186. package/dist/form/form-error-list.types.d.ts +3 -2
  187. package/dist/form/form-field.dom.js +27 -4
  188. package/dist/form/form-internal.d.ts +33 -8
  189. package/dist/form/form-internal.js +2 -0
  190. package/dist/form/form-item-status.d.ts +2 -1
  191. package/dist/form/form-item-status.js +3 -1
  192. package/dist/form/form-list-context.d.ts +4 -0
  193. package/dist/form/form-list-context.js +3 -0
  194. package/dist/form/form-list.types.d.ts +5 -2
  195. package/dist/form/form-no-style.engine.d.ts +6 -5
  196. package/dist/form/form-provider-context.d.ts +13 -0
  197. package/dist/form/form-provider-context.js +74 -0
  198. package/dist/form/form-ref.engine.d.ts +5 -0
  199. package/dist/form/form-ref.engine.js +43 -0
  200. package/dist/form/form-store.engine.d.ts +3 -1
  201. package/dist/form/form-store.engine.js +25 -3
  202. package/dist/form/form-update.engine.d.ts +29 -0
  203. package/dist/form/form-update.engine.js +40 -0
  204. package/dist/form/form-watch.svelte.d.ts +25 -0
  205. package/dist/form/form-watch.svelte.js +56 -0
  206. package/dist/form/form.component.d.ts +28 -0
  207. package/dist/form/form.component.js +25 -0
  208. package/dist/form/form.model.svelte.d.ts +25 -3
  209. package/dist/form/form.model.svelte.js +764 -191
  210. package/dist/form/form.types.d.ts +135 -24
  211. package/dist/form/validation-message.engine.d.ts +17 -3
  212. package/dist/form/validation-message.engine.js +39 -2
  213. package/dist/form/validation-messages.types.d.ts +11 -0
  214. package/dist/form/validation-nested.engine.d.ts +5 -4
  215. package/dist/form/validation.engine.d.ts +8 -6
  216. package/dist/form/validation.engine.js +2 -2
  217. package/dist/grid/Col.svelte +18 -21
  218. package/dist/grid/Row.svelte +13 -15
  219. package/dist/grid/grid.engine.d.ts +4 -1
  220. package/dist/grid/grid.engine.js +15 -3
  221. package/dist/grid/grid.svelte.d.ts +7 -0
  222. package/dist/grid/grid.svelte.js +30 -0
  223. package/dist/grid/grid.types.d.ts +5 -2
  224. package/dist/image/Image.svelte +148 -58
  225. package/dist/image/ImagePreview.svelte +284 -137
  226. package/dist/image/ImagePreview.svelte.d.ts +11 -2
  227. package/dist/image/ImagePreviewGroup.svelte +40 -7
  228. package/dist/image/ImagePreviewIcons.svelte +18 -0
  229. package/dist/image/ImagePreviewIcons.svelte.d.ts +29 -0
  230. package/dist/image/ImageProgress.svelte +87 -0
  231. package/dist/image/ImageProgress.svelte.d.ts +14 -0
  232. package/dist/image/image-group-context.d.ts +2 -1
  233. package/dist/image/image-prefix.engine.js +4 -0
  234. package/dist/image/image-preview-group.types.d.ts +9 -8
  235. package/dist/image/image-preview-motion.dom.d.ts +16 -0
  236. package/dist/image/image-preview-motion.dom.js +72 -0
  237. package/dist/image/image-semantic.engine.d.ts +40 -0
  238. package/dist/image/image-semantic.engine.js +57 -0
  239. package/dist/image/image.component.d.ts +7 -0
  240. package/dist/image/image.component.js +4 -0
  241. package/dist/image/image.types.d.ts +86 -12
  242. package/dist/index.d.ts +58 -48
  243. package/dist/index.js +26 -21
  244. package/dist/input/Input.svelte +76 -55
  245. package/dist/input/InputOTP.svelte +14 -9
  246. package/dist/input/InputPassword.svelte +15 -27
  247. package/dist/input/InputSearch.svelte +45 -19
  248. package/dist/input/TextArea.svelte +30 -32
  249. package/dist/input/input-otp.types.d.ts +12 -9
  250. package/dist/input/input-password.types.d.ts +6 -6
  251. package/dist/input/input-search.types.d.ts +8 -8
  252. package/dist/input/input-value.svelte.d.ts +7 -0
  253. package/dist/input/input-value.svelte.js +21 -0
  254. package/dist/input/input.component.d.ts +13 -0
  255. package/dist/input/input.component.js +12 -0
  256. package/dist/input/input.types.d.ts +13 -8
  257. package/dist/input/textarea.types.d.ts +12 -8
  258. package/dist/input-number/InputNumberAction.svelte +2 -2
  259. package/dist/input-number/InputNumberControl.svelte +36 -23
  260. package/dist/input-number/input-number.types.d.ts +16 -16
  261. package/dist/layout/Layout.svelte +7 -3
  262. package/dist/layout/LayoutPart.svelte +9 -3
  263. package/dist/layout/LayoutSider.svelte +27 -17
  264. package/dist/layout/layout.component.d.ts +13 -0
  265. package/dist/layout/layout.component.js +7 -0
  266. package/dist/layout/layout.types.d.ts +6 -5
  267. package/dist/listy/Listy.svelte +20 -14
  268. package/dist/listy/ListyGroupHeader.svelte +8 -2
  269. package/dist/listy/ListyGroupHeader.svelte.d.ts +2 -1
  270. package/dist/listy/ListyRaw.svelte +7 -9
  271. package/dist/listy/ListyVirtual.svelte +5 -2
  272. package/dist/listy/listy.types.d.ts +13 -10
  273. package/dist/masonry/Masonry.svelte +32 -20
  274. package/dist/masonry/MasonryItem.svelte +0 -1
  275. package/dist/masonry/masonry.types.d.ts +8 -7
  276. package/dist/mentions/Mentions.svelte +44 -9
  277. package/dist/mentions/MentionsListbox.svelte +2 -1
  278. package/dist/mentions/mentions.component.d.ts +7 -0
  279. package/dist/mentions/mentions.component.js +4 -0
  280. package/dist/mentions/mentions.engine.d.ts +35 -0
  281. package/dist/mentions/mentions.engine.js +7 -0
  282. package/dist/mentions/mentions.types.d.ts +12 -8
  283. package/dist/menu/Menu.svelte +13 -6
  284. package/dist/menu/MenuItem.svelte +23 -14
  285. package/dist/menu/MenuItemTooltip.svelte +2 -1
  286. package/dist/menu/MenuList.svelte +7 -4
  287. package/dist/menu/MenuSubMenu.svelte +109 -32
  288. package/dist/menu/menu-motion.engine.js +3 -28
  289. package/dist/menu/menu-motion.svelte.d.ts +1 -7
  290. package/dist/menu/menu-motion.svelte.js +1 -33
  291. package/dist/menu/menu-popup-align.dom.d.ts +1 -1
  292. package/dist/menu/menu-popup-align.engine.d.ts +2 -2
  293. package/dist/menu/menu-popup-align.engine.js +1 -4
  294. package/dist/menu/menu-semantic.engine.d.ts +8 -8
  295. package/dist/menu/menu-semantic.engine.js +16 -6
  296. package/dist/menu/menu.engine.d.ts +5 -1
  297. package/dist/menu/menu.engine.js +15 -0
  298. package/dist/menu/menu.types.d.ts +25 -22
  299. package/dist/message/MessageHolder.svelte +9 -6
  300. package/dist/message/MessageNotice.svelte +12 -9
  301. package/dist/message/MessageNotice.svelte.d.ts +2 -1
  302. package/dist/message/message-semantic.engine.d.ts +1 -1
  303. package/dist/message/message.model.svelte.d.ts +2 -1
  304. package/dist/message/message.model.svelte.js +2 -1
  305. package/dist/message/message.types.d.ts +12 -10
  306. package/dist/modal/Modal.svelte +229 -57
  307. package/dist/modal/ModalConfirmation.svelte +9 -10
  308. package/dist/modal/ModalFooterScope.svelte +15 -0
  309. package/dist/modal/ModalFooterScope.svelte.d.ts +7 -0
  310. package/dist/modal/modal-close.engine.d.ts +1 -1
  311. package/dist/modal/modal-layout.engine.d.ts +1 -1
  312. package/dist/modal/modal-layout.engine.js +20 -3
  313. package/dist/modal/modal-motion.dom.d.ts +1 -0
  314. package/dist/modal/modal-motion.dom.js +21 -5
  315. package/dist/modal/modal-named-motion.dom.d.ts +1 -1
  316. package/dist/modal/modal-named-motion.dom.js +1 -2
  317. package/dist/modal/modal-semantic.engine.d.ts +8 -7
  318. package/dist/modal/modal-semantic.engine.js +2 -2
  319. package/dist/modal/modal.types.d.ts +27 -18
  320. package/dist/motion/collapse-motion.engine.d.ts +3 -0
  321. package/dist/motion/collapse-motion.engine.js +31 -0
  322. package/dist/motion/css-motion.svelte.d.ts +7 -0
  323. package/dist/motion/css-motion.svelte.js +35 -0
  324. package/dist/notice/notice-queue.model.svelte.js +4 -0
  325. package/dist/notice/notice-semantic.engine.d.ts +10 -7
  326. package/dist/notice/notice-semantic.engine.js +9 -4
  327. package/dist/notification/NotificationHolder.svelte +7 -5
  328. package/dist/notification/NotificationList.svelte +5 -2
  329. package/dist/notification/NotificationList.svelte.d.ts +2 -1
  330. package/dist/notification/NotificationNotice.svelte +16 -18
  331. package/dist/notification/NotificationNotice.svelte.d.ts +2 -1
  332. package/dist/notification/notification.model.svelte.d.ts +2 -1
  333. package/dist/notification/notification.types.d.ts +12 -9
  334. package/dist/pagination/Pagination.svelte +90 -18
  335. package/dist/pagination/PaginationControl.svelte +2 -0
  336. package/dist/pagination/pagination.types.d.ts +19 -14
  337. package/dist/picker/DatePicker.svelte +9 -1
  338. package/dist/picker/DatePicker.svelte.d.ts +4 -4
  339. package/dist/picker/DatePickerCalendar.svelte +15 -12
  340. package/dist/picker/DatePickerCalendar.svelte.d.ts +2 -2
  341. package/dist/picker/DatePickerTimePanel.svelte +5 -1
  342. package/dist/picker/DatePickerTimePanel.svelte.d.ts +2 -4
  343. package/dist/picker/PickerTimeColumn.svelte +27 -12
  344. package/dist/picker/PickerTimeColumn.svelte.d.ts +3 -0
  345. package/dist/picker/PickerTimePanel.svelte +16 -0
  346. package/dist/picker/PickerTimePanel.svelte.d.ts +3 -0
  347. package/dist/picker/RangePicker.svelte +3 -1
  348. package/dist/picker/RangePickerCore.svelte +874 -363
  349. package/dist/picker/RangePickerCore.svelte.d.ts +1 -0
  350. package/dist/picker/SinglePicker.svelte +684 -309
  351. package/dist/picker/SinglePicker.svelte.d.ts +1 -0
  352. package/dist/picker/TimePicker.svelte +3 -1
  353. package/dist/picker/TimeRangePicker.svelte +2 -0
  354. package/dist/picker/date-picker-semantic.engine.d.ts +7 -6
  355. package/dist/picker/date-picker-semantic.engine.js +5 -4
  356. package/dist/picker/date-picker.types.d.ts +58 -30
  357. package/dist/picker/picker-adapter-props.engine.d.ts +2 -0
  358. package/dist/picker/picker-adapter-props.engine.js +4 -0
  359. package/dist/picker/picker-mask-input.model.svelte.js +9 -5
  360. package/dist/picker/picker-panel-updates.d.ts +6 -0
  361. package/dist/picker/picker-panel-updates.js +33 -0
  362. package/dist/picker/picker-popup-portal.dom.d.ts +49 -0
  363. package/dist/picker/picker-popup-portal.dom.js +49 -0
  364. package/dist/picker/picker-popup.dom.d.ts +14 -2
  365. package/dist/picker/picker-popup.dom.js +153 -40
  366. package/dist/picker/picker-popup.model.svelte.d.ts +33 -8
  367. package/dist/picker/picker-popup.model.svelte.js +149 -19
  368. package/dist/picker/picker-prefix.engine.js +4 -1
  369. package/dist/picker/picker-style.engine.d.ts +27 -0
  370. package/dist/picker/picker-style.engine.js +64 -0
  371. package/dist/picker/picker-time-scroll.model.svelte.d.ts +16 -0
  372. package/dist/picker/picker-time-scroll.model.svelte.js +31 -0
  373. package/dist/picker/range-picker-interaction.engine.d.ts +3 -2
  374. package/dist/picker/range-picker-interaction.engine.js +10 -4
  375. package/dist/picker/range-picker-popup.dom.d.ts +2 -0
  376. package/dist/picker/range-picker-popup.dom.js +47 -0
  377. package/dist/picker/range-picker.types.d.ts +13 -6
  378. package/dist/picker/time-picker-column.dom.d.ts +6 -1
  379. package/dist/picker/time-picker-column.dom.js +27 -3
  380. package/dist/picker/time-picker-props.engine.js +3 -2
  381. package/dist/picker/time-picker-semantic.engine.d.ts +6 -2
  382. package/dist/picker/time-picker-semantic.engine.js +32 -18
  383. package/dist/picker/time-picker.component.d.ts +4 -1
  384. package/dist/picker/time-picker.component.js +3 -1
  385. package/dist/picker/time-picker.types.d.ts +28 -24
  386. package/dist/picker/time-range-picker-semantic.engine.d.ts +2 -0
  387. package/dist/picker/time-range-picker-semantic.engine.js +6 -8
  388. package/dist/picker/time-range-picker.types.d.ts +5 -4
  389. package/dist/popconfirm/Popconfirm.svelte +48 -12
  390. package/dist/popconfirm/popconfirm.types.d.ts +17 -11
  391. package/dist/popover/Popover.svelte +65 -42
  392. package/dist/popover/popover.types.d.ts +19 -12
  393. package/dist/popup/PopupContentContext.svelte +14 -0
  394. package/dist/popup/PopupContentContext.svelte.d.ts +7 -0
  395. package/dist/popup/overlay-motion.css +86 -3
  396. package/dist/popup/overlay-portal-alignment.dom.d.ts +34 -0
  397. package/dist/popup/overlay-portal-alignment.dom.js +166 -0
  398. package/dist/popup/overlay-semantic.engine.d.ts +16 -15
  399. package/dist/popup/overlay-semantic.engine.js +5 -6
  400. package/dist/popup/popup-container.model.svelte.d.ts +4 -1
  401. package/dist/popup/popup-container.model.svelte.js +7 -2
  402. package/dist/popup/popup-css-motion.dom.d.ts +24 -0
  403. package/dist/{tree-select/tree-select-motion.dom.js → popup/popup-css-motion.dom.js} +13 -3
  404. package/dist/popup/popup-css-motion.model.svelte.d.ts +25 -0
  405. package/dist/popup/popup-css-motion.model.svelte.js +73 -0
  406. package/dist/popup/popup-geometry.dom.d.ts +16 -0
  407. package/dist/popup/popup-geometry.dom.js +97 -0
  408. package/dist/popup/popup-plane.engine.d.ts +6 -0
  409. package/dist/popup/popup-plane.engine.js +18 -0
  410. package/dist/popup/popup-portal-fit.dom.d.ts +3 -0
  411. package/dist/popup/popup-portal-fit.dom.js +81 -0
  412. package/dist/popup/popup-portal-projection.dom.d.ts +52 -0
  413. package/dist/popup/popup-portal-projection.dom.js +208 -0
  414. package/dist/popup/popup-position.engine.d.ts +5 -3
  415. package/dist/popup/popup.dom.d.ts +7 -1
  416. package/dist/popup/popup.dom.js +69 -22
  417. package/dist/popup/select-popup-motion.engine.d.ts +4 -0
  418. package/dist/popup/select-popup-motion.engine.js +18 -0
  419. package/dist/progress/Progress.svelte +58 -28
  420. package/dist/progress/ProgressCircle.svelte +40 -22
  421. package/dist/progress/ProgressCircle.svelte.d.ts +2 -1
  422. package/dist/progress/progress-circle.engine.d.ts +1 -1
  423. package/dist/progress/progress.types.d.ts +6 -5
  424. package/dist/qr-code/QRCode.svelte +12 -8
  425. package/dist/qr-code/qrcode.types.d.ts +10 -9
  426. package/dist/radio/Radio.svelte +19 -10
  427. package/dist/radio/RadioGroup.svelte +14 -6
  428. package/dist/radio/radio.component.d.ts +9 -0
  429. package/dist/radio/radio.component.js +5 -0
  430. package/dist/radio/radio.types.d.ts +20 -18
  431. package/dist/rate/Rate.svelte +8 -4
  432. package/dist/rate/rate.types.d.ts +5 -4
  433. package/dist/render-content.engine.d.ts +9 -0
  434. package/dist/render-content.engine.js +21 -0
  435. package/dist/result/Result.svelte +19 -13
  436. package/dist/result/result.types.d.ts +11 -10
  437. package/dist/segmented/Segmented.svelte +28 -15
  438. package/dist/segmented/segmented.engine.js +2 -1
  439. package/dist/segmented/segmented.types.d.ts +11 -11
  440. package/dist/select/Select.svelte +309 -69
  441. package/dist/select/select-editor-focus.dom.d.ts +14 -0
  442. package/dist/select/select-editor-focus.dom.js +51 -0
  443. package/dist/select/select-icons.engine.d.ts +2 -0
  444. package/dist/select/select-icons.engine.js +17 -8
  445. package/dist/select/select-mouse-boundary.dom.d.ts +7 -0
  446. package/dist/select/select-mouse-boundary.dom.js +57 -0
  447. package/dist/select/select-semantic.engine.d.ts +2 -2
  448. package/dist/select/select-style.engine.d.ts +2 -2
  449. package/dist/select/select-style.engine.js +24 -2
  450. package/dist/select/select-token.engine.d.ts +4 -0
  451. package/dist/select/select-token.engine.js +13 -0
  452. package/dist/select/select.types.d.ts +35 -12
  453. package/dist/skeleton/Skeleton.svelte +25 -15
  454. package/dist/skeleton/SkeletonElement.svelte +16 -8
  455. package/dist/skeleton/skeleton.types.d.ts +11 -10
  456. package/dist/slider/SliderRange.svelte +35 -53
  457. package/dist/slider/SliderSingle.svelte +58 -73
  458. package/dist/slider/SliderTooltip.svelte +322 -0
  459. package/dist/slider/SliderTooltip.svelte.d.ts +18 -0
  460. package/dist/slider/slider-handle.dom.d.ts +5 -0
  461. package/dist/slider/slider-handle.dom.js +60 -0
  462. package/dist/slider/slider-range.engine.d.ts +4 -2
  463. package/dist/slider/slider-range.engine.js +15 -0
  464. package/dist/slider/slider-range.types.d.ts +10 -8
  465. package/dist/slider/slider-semantic.engine.d.ts +1 -1
  466. package/dist/slider/slider-semantic.engine.js +2 -6
  467. package/dist/slider/slider.types.d.ts +5 -3
  468. package/dist/space/Space.svelte +35 -16
  469. package/dist/space/SpaceAddon.svelte +11 -5
  470. package/dist/space/SpaceCompact.svelte +7 -2
  471. package/dist/space/SpaceCompactItem.svelte +4 -1
  472. package/dist/space/space-compact.types.d.ts +6 -6
  473. package/dist/space/space.component.d.ts +9 -0
  474. package/dist/space/space.component.js +5 -0
  475. package/dist/space/space.engine.d.ts +5 -1
  476. package/dist/space/space.engine.js +32 -7
  477. package/dist/space/space.types.d.ts +15 -12
  478. package/dist/spin/Spin.svelte +25 -14
  479. package/dist/spin/spin.types.d.ts +5 -3
  480. package/dist/splitter/Splitter.svelte +15 -14
  481. package/dist/splitter/SplitterArrow.svelte.d.ts +1 -1
  482. package/dist/splitter/SplitterBar.svelte +2 -1
  483. package/dist/splitter/SplitterPanel.svelte +14 -2
  484. package/dist/splitter/SplitterPanel.svelte.d.ts +2 -1
  485. package/dist/splitter/SplitterPanelDeclaration.svelte +20 -0
  486. package/dist/splitter/SplitterPanelDeclaration.svelte.d.ts +4 -0
  487. package/dist/splitter/SplitterPanelDeclarations.svelte +16 -0
  488. package/dist/splitter/SplitterPanelDeclarations.svelte.d.ts +10 -0
  489. package/dist/splitter/SplitterRoot.svelte +18 -0
  490. package/dist/splitter/SplitterRoot.svelte.d.ts +4 -0
  491. package/dist/splitter/splitter-panel-context.d.ts +10 -0
  492. package/dist/splitter/splitter-panel-context.js +11 -0
  493. package/dist/splitter/splitter.component.d.ts +7 -0
  494. package/dist/splitter/splitter.component.js +6 -0
  495. package/dist/splitter/splitter.engine.d.ts +6 -1
  496. package/dist/splitter/splitter.engine.js +18 -0
  497. package/dist/splitter/splitter.types.d.ts +13 -10
  498. package/dist/statistic/Statistic.svelte +25 -12
  499. package/dist/statistic/statistic.component.d.ts +7 -0
  500. package/dist/statistic/statistic.component.js +4 -0
  501. package/dist/statistic/statistic.types.d.ts +6 -4
  502. package/dist/steps/StepIcon.svelte +4 -2
  503. package/dist/steps/StepIcon.svelte.d.ts +2 -1
  504. package/dist/steps/StepItem.svelte +12 -16
  505. package/dist/steps/Steps.svelte +9 -9
  506. package/dist/steps/steps-data.engine.d.ts +5 -4
  507. package/dist/steps/steps-expanded.types.d.ts +2 -1
  508. package/dist/steps/steps-icon-context.d.ts +2 -1
  509. package/dist/steps/steps.types.d.ts +4 -3
  510. package/dist/style/inline-style-layers.engine.d.ts +11 -0
  511. package/dist/style/inline-style-layers.engine.js +120 -0
  512. package/dist/style/inline-style.engine.d.ts +4 -0
  513. package/dist/style/inline-style.engine.js +17 -9
  514. package/dist/style/inline-style.types.d.ts +12 -0
  515. package/dist/style/inline-style.types.js +1 -0
  516. package/dist/style/semantic-style.engine.d.ts +18 -12
  517. package/dist/style/semantic-style.engine.js +15 -9
  518. package/dist/styles.css +1 -0
  519. package/dist/styles.css.d.ts +1 -0
  520. package/dist/switch/Switch.svelte +17 -9
  521. package/dist/switch/switch.types.d.ts +14 -12
  522. package/dist/table/Table.svelte +30 -21
  523. package/dist/table/Table.svelte.d.ts +4 -2
  524. package/dist/table/TableColumn.svelte +20 -0
  525. package/dist/table/TableColumn.svelte.d.ts +25 -0
  526. package/dist/table/TableColumnDeclarations.svelte +18 -0
  527. package/dist/table/TableColumnDeclarations.svelte.d.ts +10 -0
  528. package/dist/table/TableColumnGroup.svelte +31 -0
  529. package/dist/table/TableColumnGroup.svelte.d.ts +25 -0
  530. package/dist/table/TableRoot.svelte +55 -0
  531. package/dist/table/TableRoot.svelte.d.ts +29 -0
  532. package/dist/table/table-cell.engine.d.ts +14 -14
  533. package/dist/table/table-column-declarations.svelte.d.ts +22 -0
  534. package/dist/table/table-column-declarations.svelte.js +45 -0
  535. package/dist/table/table-semantic.engine.d.ts +18 -6
  536. package/dist/table/table-semantic.engine.js +14 -14
  537. package/dist/table/table.component.d.ts +10 -2
  538. package/dist/table/table.component.js +4 -1
  539. package/dist/table/table.types.d.ts +55 -25
  540. package/dist/tabs/Tabs.svelte +35 -18
  541. package/dist/tabs/TabsNav.svelte +33 -18
  542. package/dist/tabs/TabsNav.svelte.d.ts +2 -1
  543. package/dist/tabs/TabsOverflow.svelte +98 -122
  544. package/dist/tabs/TabsOverflow.svelte.d.ts +2 -1
  545. package/dist/tabs/TabsPanel.svelte +10 -5
  546. package/dist/tabs/TabsPanel.svelte.d.ts +4 -3
  547. package/dist/tabs/tabs-more-alignment.dom.d.ts +32 -0
  548. package/dist/tabs/tabs-more-alignment.dom.js +158 -0
  549. package/dist/tabs/tabs-more.dom.d.ts +69 -13
  550. package/dist/tabs/tabs-more.dom.js +76 -65
  551. package/dist/tabs/tabs-motion.dom.d.ts +2 -1
  552. package/dist/tabs/tabs-motion.dom.js +2 -1
  553. package/dist/tabs/tabs-motion.types.d.ts +4 -3
  554. package/dist/tabs/tabs-nav.types.d.ts +6 -7
  555. package/dist/tabs/tabs-semantic.engine.d.ts +18 -12
  556. package/dist/tabs/tabs-semantic.engine.js +70 -19
  557. package/dist/tabs/tabs.types.d.ts +35 -29
  558. package/dist/tag/CheckableTag.svelte +8 -4
  559. package/dist/tag/CheckableTagGroup.svelte +42 -32
  560. package/dist/tag/CheckableTagGroup.svelte.d.ts +12 -12
  561. package/dist/tag/Tag.svelte +14 -20
  562. package/dist/tag/tag-style.dom.d.ts +3 -1
  563. package/dist/tag/tag-style.dom.js +19 -1
  564. package/dist/tag/tag.component.d.ts +10 -0
  565. package/dist/tag/tag.component.js +5 -0
  566. package/dist/tag/tag.types.d.ts +30 -27
  567. package/dist/theme/theme-context.svelte.d.ts +2 -0
  568. package/dist/theme/theme-context.svelte.js +6 -1
  569. package/dist/timeline/Timeline.svelte +13 -5
  570. package/dist/timeline/timeline.engine.js +3 -1
  571. package/dist/timeline/timeline.types.d.ts +7 -6
  572. package/dist/tooltip/Tooltip.svelte +18 -10
  573. package/dist/tooltip/TooltipPopup.svelte +44 -22
  574. package/dist/tooltip/TooltipUniqueContent.svelte +3 -6
  575. package/dist/tooltip/TooltipUniqueContent.svelte.d.ts +0 -1
  576. package/dist/tooltip/TooltipUniquePopup.svelte +1 -1
  577. package/dist/tooltip/tooltip-popup.types.d.ts +6 -0
  578. package/dist/tooltip/tooltip.engine.d.ts +58 -2
  579. package/dist/tooltip/tooltip.engine.js +54 -27
  580. package/dist/tooltip/tooltip.types.d.ts +38 -13
  581. package/dist/tour/Tour.svelte +37 -14
  582. package/dist/tour/TourPanel.svelte +13 -12
  583. package/dist/tour/TourPanel.svelte.d.ts +2 -1
  584. package/dist/tour/tour.engine.d.ts +7 -2
  585. package/dist/tour/tour.engine.js +58 -11
  586. package/dist/tour/tour.types.d.ts +20 -19
  587. package/dist/transfer/Transfer.svelte +44 -36
  588. package/dist/transfer/TransferAction.svelte +6 -7
  589. package/dist/transfer/TransferAction.svelte.d.ts +3 -2
  590. package/dist/transfer/TransferCheckbox.svelte +9 -3
  591. package/dist/transfer/TransferCheckbox.svelte.d.ts +2 -1
  592. package/dist/transfer/TransferList.svelte +18 -0
  593. package/dist/transfer/TransferList.svelte.d.ts +45 -0
  594. package/dist/transfer/TransferOperation.svelte +43 -0
  595. package/dist/transfer/TransferOperation.svelte.d.ts +4 -0
  596. package/dist/transfer/TransferPagination.svelte +3 -1
  597. package/dist/transfer/TransferSearch.svelte +44 -0
  598. package/dist/transfer/TransferSearch.svelte.d.ts +4 -0
  599. package/dist/transfer/TransferSection.svelte +42 -30
  600. package/dist/transfer/TransferSection.svelte.d.ts +2 -4
  601. package/dist/transfer/transfer-style.engine.d.ts +7 -0
  602. package/dist/transfer/transfer-style.engine.js +33 -0
  603. package/dist/transfer/transfer.component.d.ts +12 -0
  604. package/dist/transfer/transfer.component.js +6 -0
  605. package/dist/transfer/transfer.types.d.ts +44 -4
  606. package/dist/tree/Tree.svelte +8 -5
  607. package/dist/tree/TreeMotion.svelte +5 -1
  608. package/dist/tree/tree-motion.dom.js +12 -3
  609. package/dist/tree/tree-motion.types.d.ts +4 -3
  610. package/dist/tree/tree-semantic.engine.d.ts +9 -2
  611. package/dist/tree/tree-semantic.engine.js +37 -3
  612. package/dist/tree/tree.component.d.ts +10 -0
  613. package/dist/tree/tree.component.js +5 -0
  614. package/dist/tree/tree.types.d.ts +8 -6
  615. package/dist/tree-select/TreeSelectControl.svelte +127 -89
  616. package/dist/tree-select/tree-select-align.engine.d.ts +2 -6
  617. package/dist/tree-select/tree-select-align.engine.js +1 -18
  618. package/dist/tree-select/tree-select-motion-frame.dom.d.ts +2 -5
  619. package/dist/tree-select/tree-select-semantic.engine.d.ts +6 -6
  620. package/dist/tree-select/tree-select-semantic.engine.js +50 -25
  621. package/dist/tree-select/tree-select-token.engine.d.ts +1 -3
  622. package/dist/tree-select/tree-select-token.engine.js +1 -13
  623. package/dist/tree-select/tree-select.types.d.ts +9 -5
  624. package/dist/types.d.ts +5 -2
  625. package/dist/typography/TypographyEditable.svelte +11 -5
  626. package/dist/typography/TypographyEditable.svelte.d.ts +3 -2
  627. package/dist/typography/TypographyElement.svelte +13 -7
  628. package/dist/typography/TypographyElement.svelte.d.ts +3 -2
  629. package/dist/typography/TypographyTooltip.svelte +19 -8
  630. package/dist/typography/typography-semantic.engine.d.ts +9 -2
  631. package/dist/typography/typography-semantic.engine.js +15 -4
  632. package/dist/typography/typography.component.d.ts +13 -0
  633. package/dist/typography/typography.component.js +7 -0
  634. package/dist/typography/typography.types.d.ts +8 -7
  635. package/dist/upload/Upload.svelte +44 -4
  636. package/dist/upload/Upload.svelte.d.ts +1 -1
  637. package/dist/upload/UploadDragger.svelte +3 -2
  638. package/dist/upload/UploadDragger.svelte.d.ts +4 -4
  639. package/dist/upload/UploadList.svelte.d.ts +1 -1
  640. package/dist/upload/UploadListItem.svelte +52 -11
  641. package/dist/upload/upload.component.d.ts +9 -0
  642. package/dist/upload/upload.component.js +5 -0
  643. package/dist/upload/upload.engine.d.ts +8 -2
  644. package/dist/upload/upload.engine.js +80 -4
  645. package/dist/upload/upload.types.d.ts +2 -1
  646. package/dist/utils/declaration-order.svelte.d.ts +12 -0
  647. package/dist/utils/declaration-order.svelte.js +53 -0
  648. package/dist/vendor/compute-scroll-into-view.d.ts +3 -1
  649. package/dist/vendor/compute-scroll-into-view.js +3 -2
  650. package/dist/vendor/date-picker-prefix.css.js +2 -2
  651. package/dist/vendor/dropdown-motion.css +105 -0
  652. package/dist/vendor/image-prefix.css.js +3 -3
  653. package/dist/vendor/image.css +16 -2
  654. package/dist/vendor/tree-select-popup-motion.css +112 -112
  655. package/dist/vendor/tree-select-popup-motion.css.js +2 -2
  656. package/dist/version.d.ts +2 -0
  657. package/dist/version.js +3 -0
  658. package/dist/watermark/Watermark.svelte +8 -6
  659. package/dist/watermark/watermark.types.d.ts +3 -2
  660. package/package.json +15 -4
  661. package/readme.md +2 -2
  662. package/dist/picker/time-range-picker-popup.dom.d.ts +0 -2
  663. package/dist/picker/time-range-picker-popup.dom.js +0 -42
  664. package/dist/tree-select/tree-select-motion-css.engine.d.ts +0 -2
  665. package/dist/tree-select/tree-select-motion-css.engine.js +0 -11
  666. package/dist/tree-select/tree-select-motion.dom.d.ts +0 -18
  667. package/dist/tree-select/tree-select-motion.engine.d.ts +0 -2
  668. package/dist/tree-select/tree-select-motion.engine.js +0 -5
@@ -4,9 +4,18 @@ import { tick, untrack } from 'svelte';
4
4
  import { FormValidationError } from './FormValidationError';
5
5
  import { setFormHooks } from './form-internal';
6
6
  import { focusFormField, getFormFieldElement, scrollFormField } from './form-field.dom';
7
- import { mergeValidationMessages } from './validation-message.engine';
8
- import { containsFormPath, copyFormValue, formNamePath, getFormValue, mergeFormValues, sameFormPath, sameFormValue, setFormValue } from './form-store.engine';
7
+ import { readFormControlValue } from './form-control.engine';
8
+ import { copyValidationMessages, mergeValidationMessages, snapshotValidationMessages, validationMessageTexts } from './validation-message.engine';
9
+ import { containsFormPath, copyFormValue, formNamePath, getFormValue, hasFormValue, mergeFormValues, sameFormPath, sameFormValue, setFormValue } from './form-store.engine';
9
10
  import { validateFieldValue, resolveValidationRules } from './validation.engine';
11
+ // A snapshot fed back through Form.fields does not replace the running validator.
12
+ const fieldSnapshotOrigin = Symbol('ant-design-form-field-snapshot');
13
+ /** Matches configured event names without treating false as a trigger. */
14
+ function allowsValidationTrigger(triggers, event) {
15
+ return typeof triggers === 'string'
16
+ ? triggers !== '' && triggers === event
17
+ : triggers !== false && triggers.includes(event);
18
+ }
10
19
  /** Preserves numeric path segments, including infinities and the strict equality rule for NaN. */
11
20
  function fieldSelectionKey(path) {
12
21
  if (path.some(part => typeof part === 'number' && Number.isNaN(part))) {
@@ -46,18 +55,29 @@ function selectNamedFields(names, bindings) {
46
55
  * validation cannot replace errors for newer values.
47
56
  */
48
57
  export function createForm({ initialValues, rules = {} }) {
49
- const defaults = copyFormValue(initialValues);
58
+ const modelDefaults = copyFormValue(initialValues);
59
+ let defaults = modelDefaults;
50
60
  let valuesRevision = $state(0);
51
61
  let validationSequence = 0;
52
62
  let latestValidationRun = 0;
63
+ let submissionRevision = 0;
64
+ let mountedForms = 0;
65
+ let storeLifetime = 0;
66
+ let restoreDefaultsOnMount = false;
53
67
  let registrationOrder = 0;
54
- let initialValueOrder = 0;
68
+ let fieldMountOrder = 0;
55
69
  let values = $state(copyFormValue(defaults));
56
70
  let resetKey = $state.raw({});
57
71
  // At teardown Svelte reads the previous $state; the registry stores up-to-date registrations.
58
72
  const fieldRegistry = new Set();
73
+ const pendingRemovals = [];
59
74
  const validationDelays = new Map();
60
75
  const messageProviders = new Set();
76
+ const callbackProviders = new Set();
77
+ const storeListeners = new Set();
78
+ const resetObservers = new Map();
79
+ let storeSnapshot;
80
+ const controlDrivenFields = new WeakSet();
61
81
  let fields = $state.raw([]);
62
82
  let isSubmitting = $state(false);
63
83
  let submissionError = $state.raw();
@@ -65,16 +85,30 @@ export function createForm({ initialValues, rules = {} }) {
65
85
  function fieldPath(field) {
66
86
  return formNamePath(field.registration?.name ?? field.path);
67
87
  }
68
- // Compares the full path, keeping the difference of the string key and the index.
88
+ // A new editor can register before its predecessor releases a persistent field record.
69
89
  function findField(name) {
70
- return fields.find((field) => sameFormPath(fieldPath(field), name));
90
+ let unmounted;
91
+ for (const field of fields) {
92
+ if (!sameFormPath(fieldPath(field), name)) {
93
+ continue;
94
+ }
95
+ if (field.registration) {
96
+ return field;
97
+ }
98
+ unmounted ??= field;
99
+ }
100
+ return unmounted;
101
+ }
102
+ // A name can refer to multiple editors. The mount key identifies the emitting registration.
103
+ function findFieldByMountKey(mountKey) {
104
+ return fields.find((field) => field.registration?.mountKey === mountKey);
71
105
  }
72
106
  // Copies the arrays so that the listener does not change the metadata in the repository.
73
- function fieldMeta(field) {
107
+ function fieldMeta(field, path = fieldPath(field)) {
108
+ const messages = snapshotValidationMessages(field.errors, field.warnings);
74
109
  return {
75
- name: [...fieldPath(field)], touched: field.touched, validating: field.validating,
76
- validated: field.validated, errors: [...(field.errors ?? [])],
77
- warnings: [...(field.warnings ?? [])]
110
+ name: [...path], touched: field.touched, validating: field.validating,
111
+ validated: field.validated, ...messages
78
112
  };
79
113
  }
80
114
  // Publishes only a new state or signal to remove registration.
@@ -136,22 +170,73 @@ export function createForm({ initialValues, rules = {} }) {
136
170
  ? rules[path[0]] : undefined)
137
171
  ?? [];
138
172
  }
173
+ // Falsy defined initial values count, even when the field has never been touched.
174
+ function isValidationDirty(field, path = fieldPath(field)) {
175
+ return field.dirty || field.touched || field.registration?.initialValue !== undefined
176
+ || getFormValue(defaults, path) !== undefined;
177
+ }
178
+ // Follow the live paths and stop at pristine fields. Visit each registration once even in cycles.
179
+ function dependentFields(names) {
180
+ const byDependency = new Map();
181
+ for (const field of fields) {
182
+ for (const path of field.registration?.dependencies ?? []) {
183
+ const key = fieldSelectionKey(formNamePath(path));
184
+ const group = byDependency.get(key);
185
+ if (group) {
186
+ group.push(field);
187
+ }
188
+ else {
189
+ byDependency.set(key, [field]);
190
+ }
191
+ }
192
+ }
193
+ const visited = new Set();
194
+ const result = [];
195
+ for (const name of names) {
196
+ visit(formNamePath(name));
197
+ }
198
+ return result;
199
+ // Preserve the registration and path at the time an edit traverses the graph.
200
+ function visit(namePath) {
201
+ const list = byDependency.get(fieldSelectionKey(namePath));
202
+ if (!list) {
203
+ return;
204
+ }
205
+ for (const field of list) {
206
+ if (visited.has(field)) {
207
+ continue;
208
+ }
209
+ visited.add(field);
210
+ const path = fieldPath(field);
211
+ if (path.length && isValidationDirty(field, path)) {
212
+ result.push({ path, field });
213
+ visit(path);
214
+ }
215
+ }
216
+ }
217
+ }
139
218
  function rootErrors(entries) {
140
219
  return Object.fromEntries(entries.filter((field) => field.name.length === 1)
141
220
  .map((field) => [field.name[0], [...field.errors]]));
142
221
  }
143
222
  function getFieldsError(names) {
144
- return names
145
- ? names.map((name) => ({
146
- name: formNamePath(name),
147
- errors: [...(findField(name)?.errors ?? [])],
148
- warnings: [...(findField(name)?.warnings ?? [])]
149
- }))
150
- : fields.map((field) => ({
151
- name: fieldPath(field),
152
- errors: [...(field.errors ?? [])],
153
- warnings: [...(field.warnings ?? [])]
154
- }));
223
+ if (names) {
224
+ return names.map(name => {
225
+ const path = formNamePath(name);
226
+ const field = findField(path);
227
+ const messages = snapshotValidationMessages(field?.errors, field?.warnings);
228
+ return { name: path, ...messages };
229
+ });
230
+ }
231
+ return fields.map(field => ({
232
+ name: fieldPath(field),
233
+ ...snapshotValidationMessages(field.errors, field.warnings)
234
+ }));
235
+ }
236
+ // Reads one message list so error and warning accessors keep separate reactive dependencies.
237
+ function getFieldMessages(name, kind) {
238
+ const field = findField(name);
239
+ return field?.[kind] ?? [];
155
240
  }
156
241
  function isFieldTouched(name) {
157
242
  return fields.some((field) => containsFormPath(name, fieldPath(field)) && field.touched);
@@ -192,18 +277,14 @@ export function createForm({ initialValues, rules = {} }) {
192
277
  lists.push(path);
193
278
  continue;
194
279
  }
195
- const meta = field ? {
196
- touched: field.touched,
197
- validating: field.validating,
198
- errors: [...(field.errors ?? [])],
199
- warnings: [...(field.warnings ?? [])],
200
- name: [...path],
201
- validated: field.validated
202
- } : null;
203
- if (!filter || filter(meta)) {
204
- const currentValue = getFormValue(values, path);
205
- result = setFormValue(result, path, currentValue);
280
+ if (filter) {
281
+ const meta = field ? fieldMeta(field, path) : null;
282
+ if (!filter(meta)) {
283
+ continue;
284
+ }
206
285
  }
286
+ const currentValue = getFormValue(values, path);
287
+ result = setFormValue(result, path, currentValue);
207
288
  }
208
289
  for (const path of lists) {
209
290
  if (!getFormValue(result, path)) {
@@ -228,7 +309,77 @@ export function createForm({ initialValues, rules = {} }) {
228
309
  const selected = names ? selectNamedFields(names, bindings) : bindings;
229
310
  return projectFieldValues(selected, select);
230
311
  }
231
- // Confirms that for the field there was and the expectation of debounce was canceled.
312
+ // All mounted observers can read the same projection without subscribing to validation metadata.
313
+ const watchValues = $derived(getFieldsValue());
314
+ // Share one immutable root per write without copying the store when there are no observers.
315
+ function readStoreSnapshot() {
316
+ if (storeListeners.size) {
317
+ storeSnapshot ??= untrack(() => ({ ...values }));
318
+ return storeSnapshot;
319
+ }
320
+ }
321
+ // Predicates run in store order. Reads in a predicate cannot subscribe the writer's effect.
322
+ function notifyStoreUpdate(previous, update) {
323
+ if (!previous) {
324
+ return;
325
+ }
326
+ const current = readStoreSnapshot();
327
+ if (current) {
328
+ const listeners = [...storeListeners];
329
+ untrack(() => {
330
+ for (const listener of listeners) {
331
+ listener(previous, current, update);
332
+ }
333
+ });
334
+ }
335
+ }
336
+ // The last attached Form owns callbacks for this model until its registration is released.
337
+ function currentCallbackProvider() {
338
+ return [...callbackProviders].at(-1);
339
+ }
340
+ // Build both arguments from one field snapshot, including current indexed paths in lists.
341
+ function publishFieldsChange(names, owner = currentCallbackProvider()) {
342
+ if (!names.length || !owner) {
343
+ return;
344
+ }
345
+ untrack(() => {
346
+ if (owner !== currentCallbackProvider()) {
347
+ return;
348
+ }
349
+ const onFieldsChange = owner()?.onFieldsChange;
350
+ if (!onFieldsChange) {
351
+ return;
352
+ }
353
+ const allFields = [];
354
+ const changedFields = [];
355
+ for (const { path, field } of fieldBindings()) {
356
+ const value = getFormValue(values, path);
357
+ const snapshot = { ...fieldMeta(field, path), value: copyFormValue(value) };
358
+ Object.defineProperty(snapshot, fieldSnapshotOrigin, { value: true });
359
+ allFields.push(snapshot);
360
+ if (names.some((name) => sameFormPath(name, path))) {
361
+ changedFields.push(snapshot);
362
+ }
363
+ }
364
+ if (changedFields.length) {
365
+ onFieldsChange(changedFields, allFields);
366
+ }
367
+ });
368
+ }
369
+ // The edited path can include data outside the projection of mounted fields, such as a list row.
370
+ function publishValueChange(name, dependencies) {
371
+ untrack(() => {
372
+ const onValuesChange = currentCallbackProvider()?.()?.onValuesChange;
373
+ if (onValuesChange) {
374
+ const value = getFormValue(values, name);
375
+ const changed = setFormValue({}, name, value);
376
+ const all = setFormValue(getFieldsValue(), name, value);
377
+ onValuesChange(changed, all);
378
+ }
379
+ publishFieldsChange([name, ...dependencies]);
380
+ });
381
+ }
382
+ // Releases a waiting debounce timer or dependency frame when its field is superseded.
232
383
  function cancelValidationDelay(field) {
233
384
  const cancel = validationDelays.get(field);
234
385
  if (!cancel) {
@@ -237,22 +388,36 @@ export function createForm({ initialValues, rules = {} }) {
237
388
  cancel();
238
389
  return true;
239
390
  }
240
- // Finishes waiting both after the timer and after an obvious cancellation.
391
+ // Resolves true when the scheduled wait elapses, or false when the owner cancels it.
241
392
  function delayValidation(field, delay) {
242
393
  return new Promise((resolve) => {
243
- const timer = setTimeout(() => {
244
- validationDelays.delete(field);
245
- resolve(true);
246
- }, delay);
247
- validationDelays.set(field, () => {
394
+ let cancel;
395
+ function finish(elapsed) {
396
+ if (validationDelays.get(field) === cancel) {
397
+ validationDelays.delete(field);
398
+ }
399
+ resolve(elapsed);
400
+ }
401
+ if (delay === 'frame' && typeof requestAnimationFrame === 'function'
402
+ && typeof cancelAnimationFrame === 'function') {
403
+ const frame = requestAnimationFrame(() => finish(true));
404
+ cancel = () => {
405
+ cancelAnimationFrame(frame);
406
+ finish(false);
407
+ };
408
+ validationDelays.set(field, cancel);
409
+ return;
410
+ }
411
+ const timer = setTimeout(() => finish(true), delay === 'frame' ? 0 : delay);
412
+ cancel = () => {
248
413
  clearTimeout(timer);
249
- validationDelays.delete(field);
250
- resolve(false);
251
- });
414
+ finish(false);
415
+ };
416
+ validationDelays.set(field, cancel);
252
417
  });
253
418
  }
254
419
  // Runs selected checks at the same time and rejects an outdated shot.
255
- async function validate(selected, validateOnly = false, triggered = false) {
420
+ async function validate(selected, { source, validateOnly = false, trigger, changedList }) {
256
421
  if (!validateOnly) {
257
422
  for (const field of selected) {
258
423
  if (cancelValidationDelay(field)) {
@@ -266,13 +431,18 @@ export function createForm({ initialValues, rules = {} }) {
266
431
  const validationRun = ++validationSequence;
267
432
  // Promises share freshness tracking. validateOnly leaves the visible validation's field.run unchanged.
268
433
  latestValidationRun = validationRun;
269
- const entries = selected.map((field) => ({
270
- field,
271
- path: fieldPath(field),
272
- run: field.run,
273
- hasRules: fieldRules(field).length > 0,
274
- delay: triggered ? field.registration?.validateDebounce : undefined
275
- }));
434
+ const publishesChanges = source !== 'refresh' || changedList !== undefined;
435
+ const callbacks = publishesChanges ? currentCallbackProvider() : undefined;
436
+ const entries = selected.map((field) => {
437
+ const hasRules = fieldRules(field).length > 0;
438
+ const publishes = Boolean(callbacks && hasRules && (!changedList || changedList === field));
439
+ const event = source === 'control' ? trigger : field === changedList ? 'onChange' : undefined;
440
+ const debounced = source === 'refresh' || (source === 'control' && !!event);
441
+ return {
442
+ field, path: fieldPath(field), run: field.run, hasRules, publishes, event,
443
+ delay: debounced ? field.registration?.validateDebounce : undefined
444
+ };
445
+ });
276
446
  if (!validateOnly) {
277
447
  for (const { field, hasRules } of entries) {
278
448
  if (!hasRules) {
@@ -283,13 +453,45 @@ export function createForm({ initialValues, rules = {} }) {
283
453
  }
284
454
  field.run = validationRun;
285
455
  field.validating = true;
456
+ if (source === 'control' || source === 'dependency' || field === changedList) {
457
+ field.errors = [];
458
+ }
286
459
  field.warnings = [];
287
460
  field.dirty = true;
288
461
  field.validated = false;
289
462
  notifyFieldMeta(field);
290
463
  }
291
464
  }
292
- const results = await Promise.all(entries.map(validateEntry));
465
+ let results;
466
+ try {
467
+ if (callbacks) {
468
+ const started = entries.filter((entry) => entry.publishes).map(({ path }) => path);
469
+ publishFieldsChange(started, callbacks);
470
+ }
471
+ }
472
+ finally {
473
+ // A throwing listener must not leave validation pending forever.
474
+ results = await Promise.all(entries.map(validateEntry));
475
+ }
476
+ if ((callbacks || storeListeners.size) && valuesRevision === snapshotRevision) {
477
+ const validatedPaths = [];
478
+ const completed = [];
479
+ for (const [index, entry] of entries.entries()) {
480
+ const { field, path, run, hasRules, publishes } = entry;
481
+ if (hasRules && !results[index].cancelled && field.run === (validateOnly ? run : validationRun)
482
+ && fields.includes(field) && sameFormPath(path, fieldPath(field))) {
483
+ validatedPaths.push(path);
484
+ if (publishes)
485
+ completed.push(path);
486
+ }
487
+ }
488
+ if (storeListeners.size && (validatedPaths.length || entries.every(entry => !entry.hasRules))) {
489
+ notifyStoreUpdate(readStoreSnapshot(), { type: 'validateFinish', names: validatedPaths });
490
+ }
491
+ if (callbacks && valuesRevision === snapshotRevision) {
492
+ publishFieldsChange(completed, callbacks);
493
+ }
494
+ }
293
495
  const nextErrors = results.filter((field) => field.errors.length);
294
496
  const outOfDate = latestValidationRun !== validationRun || valuesRevision !== snapshotRevision
295
497
  || results.some((result) => result.cancelled)
@@ -299,12 +501,27 @@ export function createForm({ initialValues, rules = {} }) {
299
501
  throw new FormValidationError(snapshot, rootErrors(nextErrors), outOfDate, nextErrors);
300
502
  }
301
503
  return snapshot;
302
- // Rules and messages are read when you start a specific field. After await, only the owner of
303
- // the current inspection can publish its result.
304
- async function validateEntry({ field, path, hasRules, delay }) {
504
+ // A control event publishes pending metadata before the control finishes its own handler.
505
+ // Dependent rule factories run after the UI has had a frame to apply changes from the edit.
506
+ async function validateEntry({ field, path, hasRules, delay, event }) {
305
507
  if (!hasRules) {
306
508
  return { name: path, errors: [], warnings: [] };
307
509
  }
510
+ if (source === 'dependency') {
511
+ if (!isCurrent(field, path)) {
512
+ return cancelledEntry(field, path);
513
+ }
514
+ const elapsed = await delayValidation(field, 'frame');
515
+ if (!elapsed || !isCurrent(field, path)) {
516
+ return cancelledEntry(field, path);
517
+ }
518
+ }
519
+ else if (source === 'control') {
520
+ await tick();
521
+ if (!isCurrent(field, path)) {
522
+ return cancelledEntry(field, path);
523
+ }
524
+ }
308
525
  let rules;
309
526
  try {
310
527
  rules = resolveValidationRules(fieldRules(field), form);
@@ -316,6 +533,9 @@ export function createForm({ initialValues, rules = {} }) {
316
533
  }
317
534
  throw error;
318
535
  }
536
+ if (event) {
537
+ rules = rules.filter(({ validateTrigger }) => !validateTrigger || allowsValidationTrigger(validateTrigger, event));
538
+ }
319
539
  const messageContext = {
320
540
  name: path.map(String).join('.'),
321
541
  variables: { label: path.map(String).join('.'), ...field.registration?.messageVariables },
@@ -323,14 +543,12 @@ export function createForm({ initialValues, rules = {} }) {
323
543
  };
324
544
  const validateFirst = field.registration?.validateFirst;
325
545
  if (delay) {
546
+ if (!isCurrent(field, path)) {
547
+ return cancelledEntry(field, path);
548
+ }
326
549
  const elapsed = await delayValidation(field, delay);
327
- if (!elapsed || field.run !== validationRun || valuesRevision !== snapshotRevision
328
- || !fields.includes(field) || !sameFormPath(path, fieldPath(field))) {
329
- if (field.run === validationRun) {
330
- field.validating = false;
331
- notifyFieldMeta(field);
332
- }
333
- return { name: path, errors: [], warnings: [], cancelled: true };
550
+ if (!elapsed || !isCurrent(field, path)) {
551
+ return cancelledEntry(field, path);
334
552
  }
335
553
  }
336
554
  const value = getFormValue(snapshot, path);
@@ -338,13 +556,26 @@ export function createForm({ initialValues, rules = {} }) {
338
556
  if (!validateOnly && field.run === validationRun) {
339
557
  field.validating = false;
340
558
  if (valuesRevision === snapshotRevision && sameFormPath(path, fieldPath(field))) {
341
- field.errors = messages.errors;
342
- field.warnings = messages.warnings;
559
+ field.errors = copyValidationMessages(messages.errors);
560
+ field.warnings = copyValidationMessages(messages.warnings);
343
561
  field.validated = true;
344
562
  }
345
563
  notifyFieldMeta(field);
346
564
  }
347
- return { name: path, ...messages };
565
+ return { name: path, ...snapshotValidationMessages(messages.errors, messages.warnings) };
566
+ }
567
+ // A pending timer or frame cannot continue with another value or a reassigned list row.
568
+ function isCurrent(field, path) {
569
+ return field.run === validationRun && valuesRevision === snapshotRevision
570
+ && fieldRegistry.has(field) && sameFormPath(path, fieldPath(field));
571
+ }
572
+ // Only clear the pending flag if a newer check has not claimed this field.
573
+ function cancelledEntry(field, path) {
574
+ if (field.run === validationRun) {
575
+ field.validating = false;
576
+ notifyFieldMeta(field);
577
+ }
578
+ return { name: path, errors: [], warnings: [], cancelled: true };
348
579
  }
349
580
  }
350
581
  // Selects registered fields, descendants of the prefix or obvious paths.
@@ -364,28 +595,111 @@ export function createForm({ initialValues, rules = {} }) {
364
595
  }
365
596
  }
366
597
  if (settings?.dirty) {
367
- selected = selected.filter((field) => field.dirty || field.touched
368
- || field.registration?.initialValue !== undefined
369
- || getFormValue(defaults, fieldPath(field)) !== undefined);
598
+ selected = selected.filter((field) => isValidationDirty(field));
370
599
  }
371
- return validate(selected, settings?.validateOnly);
600
+ return validate(selected, { source: 'explicit', validateOnly: settings?.validateOnly });
372
601
  }
373
- // After changing the list, you check the touched fields if you do not submit.
374
- function revalidateTouched() {
375
- if (isSubmitting) {
602
+ // Automatic checks keep validation errors in the model; programming errors still surface.
603
+ function validateAutomatically(selected, request) {
604
+ void validate(selected, request).catch((error) => {
605
+ if (!(error instanceof FormValidationError)) {
606
+ throw error;
607
+ }
608
+ });
609
+ }
610
+ // A declared event or dependency opts a binding into the control validation path.
611
+ function usesControlValidation(field) {
612
+ const registration = field.registration;
613
+ return controlDrivenFields.has(field) || registration?.validateTrigger !== undefined
614
+ || registration?.dependencies !== undefined;
615
+ }
616
+ // Checks the field's event configuration before individual rules are filtered.
617
+ function validateControlEvent(field, trigger, sharedPath) {
618
+ const triggers = field.registration?.validateTrigger ?? 'onChange';
619
+ if (!allowsValidationTrigger(triggers, trigger) || !fieldRules(field).length) {
376
620
  return;
377
621
  }
378
- const selected = fields.filter((field) => field.touched);
379
- if (selected.length) {
380
- void validate(selected, false, true).catch((error) => {
381
- if (!(error instanceof FormValidationError)) {
382
- throw error;
622
+ const selected = sharedPath === undefined ? [field] : fields.filter((candidate) => sameFormPath(sharedPath, fieldPath(candidate)));
623
+ validateAutomatically(selected, { source: 'control', trigger });
624
+ }
625
+ // Dispatches through the originating editor and reports when it must receive the committed value.
626
+ function handleFieldEvent(mountKey, event, args) {
627
+ const field = findFieldByMountKey(mountKey);
628
+ const registration = field?.registration;
629
+ if (!field || !registration) {
630
+ return false;
631
+ }
632
+ const name = fieldPath(field);
633
+ const writesValue = event === (registration.trigger ?? 'onChange');
634
+ controlDrivenFields.add(field);
635
+ if (writesValue) {
636
+ applyControlValue(field, name, () => {
637
+ const extract = registration.getValueFromEvent;
638
+ if (extract) {
639
+ return extract(...args);
383
640
  }
641
+ return readFormControlValue(registration.valuePropName ?? 'value', args);
384
642
  });
385
643
  }
644
+ validateControlEvent(field, event, name);
645
+ return writesValue;
646
+ }
647
+ // Returns the affected paths so a control edit can include them in its field-change callback.
648
+ function startDependentValidation(names) {
649
+ const dependents = untrack(() => dependentFields(names));
650
+ if (dependents.length) {
651
+ validateAutomatically(dependents.map(({ field }) => field), { source: 'dependency' });
652
+ }
653
+ return dependents.map(({ path }) => path);
654
+ }
655
+ // Dependent fields enter validation before either value-change callback sees the new store.
656
+ function publishControlEdit(name, previous) {
657
+ notifyStoreUpdate(previous, { type: 'valueUpdate', source: 'internal', names: [name] });
658
+ const dependents = startDependentValidation([name]);
659
+ notifyStoreUpdate(previous, { type: 'dependenciesUpdate', names: [name, ...dependents] });
660
+ publishValueChange(name, dependents);
661
+ }
662
+ // Compatibility for manually wired fields, including list paths that change after a flush.
663
+ function revalidateTouched({ explicitTouch = false, changedList } = {}) {
664
+ if (isSubmitting) {
665
+ return;
666
+ }
667
+ const selected = fields.filter((field) => {
668
+ if (field === changedList) {
669
+ return allowsValidationTrigger(field.registration?.validateTrigger ?? 'onChange', 'onChange');
670
+ }
671
+ return field.touched && (explicitTouch || !usesControlValidation(field));
672
+ });
673
+ if (selected.length) {
674
+ validateAutomatically(selected, { source: 'refresh', changedList });
675
+ }
676
+ }
677
+ function markTouched(field) {
678
+ field.touched = true;
679
+ field.dirty = true;
680
+ notifyFieldMeta(field);
681
+ }
682
+ // Touch precedes extraction and normalization. Validation uses the value committed by this edit.
683
+ function applyControlValue(field, name, readValue) {
684
+ markTouched(field);
685
+ const previous = getFormValue(values, name);
686
+ const value = readValue();
687
+ const normalize = field.registration?.normalize;
688
+ // Keep the old root while preserving field identities for the synchronous normalizer.
689
+ const nextValue = normalize ? normalize(value, previous, { ...values }) : value;
690
+ if (previous === nextValue) {
691
+ return;
692
+ }
693
+ const previousStore = readStoreSnapshot();
694
+ const next = setFormValue(values, name, nextValue);
695
+ updateValues(next);
696
+ valuesRevision++;
697
+ submissionError = undefined;
698
+ publishControlEdit(name, previousStore);
386
699
  }
387
700
  // Updates the current proxy keys by saving the model’s reader links.
388
701
  function updateValues(next) {
702
+ storeSnapshot = undefined;
389
703
  // Svelte lists inherited names only in the presence of own property in the original target.
390
704
  if (Object.keys(next).some((name) => !Object.hasOwn(values, name)
391
705
  && Object.hasOwn(Object.prototype, name))) {
@@ -400,6 +714,69 @@ export function createForm({ initialValues, rules = {} }) {
400
714
  values[name] = next[name];
401
715
  }
402
716
  }
717
+ // A field batch applies values and metadata in the caller's order without validating.
718
+ function applyFieldUpdates(updates, controlled) {
719
+ const previousStore = readStoreSnapshot();
720
+ for (const update of updates) {
721
+ const { name, ...data } = update;
722
+ const hasValue = 'value' in data;
723
+ if (hasValue) {
724
+ const next = setFormValue(values, name, data.value);
725
+ const changed = !sameFormValue(values, next);
726
+ // Equal controlled echoes can read their data from the store itself.
727
+ if (!controlled || changed) {
728
+ updateValues(next);
729
+ }
730
+ else {
731
+ storeSnapshot = undefined;
732
+ }
733
+ if (changed) {
734
+ valuesRevision++;
735
+ submissionError = undefined;
736
+ for (const field of fields) {
737
+ if (containsFormPath(name, fieldPath(field))) {
738
+ cancelValidationDelay(field);
739
+ field.run = ++validationSequence;
740
+ const wasValidating = field.validating;
741
+ field.validating = false;
742
+ if (wasValidating)
743
+ notifyFieldMeta(field);
744
+ }
745
+ }
746
+ }
747
+ }
748
+ const keepValidator = controlled && Object.hasOwn(update, fieldSnapshotOrigin);
749
+ for (const field of fields) {
750
+ if (!sameFormPath(name, fieldPath(field))
751
+ || (!field.registration && !fieldRules(field).length)) {
752
+ continue;
753
+ }
754
+ if ('touched' in update)
755
+ field.touched = !!update.touched;
756
+ if ('validating' in update && !keepValidator) {
757
+ cancelValidationDelay(field);
758
+ field.run = ++validationSequence;
759
+ field.validating = !!update.validating;
760
+ field.validated = !field.validating;
761
+ }
762
+ if ('errorMessages' in update) {
763
+ field.errors = copyValidationMessages(update.errorMessages ?? []);
764
+ }
765
+ else if ('errors' in update) {
766
+ field.errors = [...(update.errors ?? [])];
767
+ }
768
+ if ('warningMessages' in update) {
769
+ field.warnings = copyValidationMessages(update.warningMessages ?? []);
770
+ }
771
+ else if ('warnings' in update) {
772
+ field.warnings = [...(update.warnings ?? [])];
773
+ }
774
+ field.dirty = true;
775
+ notifyFieldMeta(field);
776
+ }
777
+ notifyStoreUpdate(previousStore, { type: 'setField', name, hasValue });
778
+ }
779
+ }
403
780
  // Purifies the result of the field and deprives the previous verification of the right to publish.
404
781
  function clearField(field) {
405
782
  cancelValidationDelay(field);
@@ -409,6 +786,197 @@ export function createForm({ initialValues, rules = {} }) {
409
786
  field.run = ++validationSequence;
410
787
  notifyFieldMeta(field);
411
788
  }
789
+ // Resets flags and messages and releases work owned by the previous field lifetime.
790
+ function resetFieldMetadata(field) {
791
+ cancelValidationDelay(field);
792
+ field.errors = undefined;
793
+ field.warnings = undefined;
794
+ field.touched = false;
795
+ field.dirty = false;
796
+ field.validating = false;
797
+ field.validated = false;
798
+ field.run = ++validationSequence;
799
+ }
800
+ /** Clears each field's metadata immediately before that field's reset callback. */
801
+ function resetBindings(selected, includeObservers) {
802
+ const targets = selected.map(field => ({
803
+ order: field.mountOrder ?? 0,
804
+ field
805
+ }));
806
+ if (includeObservers) {
807
+ for (const [order, reset] of resetObservers) {
808
+ targets.push({ order, reset });
809
+ }
810
+ }
811
+ targets.sort((first, second) => first.order - second.order);
812
+ for (const target of targets) {
813
+ if ('field' in target) {
814
+ const { field } = target;
815
+ resetFieldMetadata(field);
816
+ notifyFieldMeta(field);
817
+ field.registration?.onReset?.();
818
+ }
819
+ else {
820
+ target.reset();
821
+ }
822
+ }
823
+ }
824
+ // Discard after the Svelte flush so sibling registrations and keyed list moves are visible.
825
+ function scheduleFieldRemoval(registration) {
826
+ if (registration.preserve !== false) {
827
+ return;
828
+ }
829
+ const path = formNamePath(registration.name);
830
+ const resolvePath = registration.isListField ? registration.getRemovalPath : () => path;
831
+ if (!resolvePath) {
832
+ return;
833
+ }
834
+ if (!pendingRemovals.length) {
835
+ queueMicrotask(discardUnmountedValues);
836
+ }
837
+ pendingRemovals.push({ resolvePath, isListField: registration.isListField });
838
+ }
839
+ // A restored parent represents its whole initial value, including nested list entries.
840
+ function discardUnmountedValues() {
841
+ const removals = pendingRemovals.splice(0);
842
+ if (!removals.length) {
843
+ return;
844
+ }
845
+ const mountedPaths = new Set();
846
+ for (const field of fieldRegistry) {
847
+ if (field.registration) {
848
+ mountedPaths.add(fieldSelectionKey(fieldPath(field)));
849
+ }
850
+ }
851
+ const updates = new Map();
852
+ for (const { resolvePath, isListField } of removals) {
853
+ const path = resolvePath((name) => getFormValue(values, name));
854
+ if (!path?.length) {
855
+ continue;
856
+ }
857
+ const key = fieldSelectionKey(path);
858
+ if (mountedPaths.has(key)) {
859
+ continue;
860
+ }
861
+ const value = isListField ? undefined : getFormValue(defaults, path);
862
+ if (!Object.is(getFormValue(values, path), value)) {
863
+ updates.set(key, { path, value });
864
+ }
865
+ }
866
+ let next = values;
867
+ const restored = [];
868
+ const ordered = [...updates.values()].sort((first, second) => first.path.length - second.path.length);
869
+ for (const { path, value } of ordered) {
870
+ if (!restored.some((parent) => containsFormPath(parent, path))) {
871
+ next = setFormValue(next, path, value, true);
872
+ restored.push(path);
873
+ }
874
+ }
875
+ if (next === values) {
876
+ return;
877
+ }
878
+ const previous = readStoreSnapshot();
879
+ updateValues(next);
880
+ valuesRevision++;
881
+ submissionError = undefined;
882
+ notifyStoreUpdate(previous, { type: 'remove', names: restored });
883
+ if (mountedForms) {
884
+ const names = ordered.map(({ path }) => path);
885
+ const dependents = startDependentValidation(names);
886
+ notifyStoreUpdate(previous, { type: 'dependenciesUpdate', names: [...names, ...dependents] });
887
+ }
888
+ }
889
+ // Clearing the last owner invalidates work from that attachment and defers defaults until remount.
890
+ function clearDetachedForm() {
891
+ storeLifetime++;
892
+ pendingRemovals.length = 0;
893
+ latestValidationRun = ++validationSequence;
894
+ for (const field of fieldRegistry) {
895
+ resetFieldMetadata(field);
896
+ }
897
+ storeSnapshot = undefined;
898
+ values = {};
899
+ valuesRevision++;
900
+ submissionRevision++;
901
+ isSubmitting = false;
902
+ submissionError = undefined;
903
+ restoreDefaultsOnMount = true;
904
+ }
905
+ // Form defaults take priority on reset. Connecting a model fills gaps beneath its current store.
906
+ function setInitialValues(initial, seed) {
907
+ defaults = initial === undefined ? modelDefaults : mergeFormValues(modelDefaults, initial);
908
+ if (!seed) {
909
+ return;
910
+ }
911
+ untrack(() => {
912
+ if (initial === undefined && !restoreDefaultsOnMount) {
913
+ return;
914
+ }
915
+ restoreDefaultsOnMount = false;
916
+ const next = mergeFormValues(defaults, values);
917
+ if (!sameFormValue(values, next)) {
918
+ updateValues(next);
919
+ valuesRevision++;
920
+ }
921
+ });
922
+ }
923
+ let submit = wrapSubmission(submitWithFinish);
924
+ /** Each read keeps its delegate when a caller wraps the callback-based submission method. */
925
+ function wrapSubmission(run) {
926
+ function submit(onFinish) {
927
+ if (typeof onFinish === 'function') {
928
+ return run.call(form, onFinish);
929
+ }
930
+ const provider = currentCallbackProvider();
931
+ const attachedSubmit = provider?.()?.submit;
932
+ if (attachedSubmit) {
933
+ attachedSubmit();
934
+ }
935
+ else {
936
+ void run.call(form, () => { });
937
+ }
938
+ }
939
+ return submit;
940
+ }
941
+ async function submitWithFinish(onFinish) {
942
+ if (isSubmitting) {
943
+ return { status: 'busy' };
944
+ }
945
+ const callbacks = currentCallbackProvider();
946
+ const revision = ++submissionRevision;
947
+ isSubmitting = true;
948
+ submissionError = undefined;
949
+ for (const field of fields) {
950
+ field.touched = true;
951
+ notifyFieldMeta(field);
952
+ }
953
+ try {
954
+ const result = await validateFields();
955
+ if (revision !== submissionRevision) {
956
+ const error = new FormValidationError(result, {}, true);
957
+ return { status: 'invalid', error };
958
+ }
959
+ if (callbacks && callbacks === currentCallbackProvider()) {
960
+ callbacks()?.onProviderFinish?.(result);
961
+ }
962
+ await onFinish(result);
963
+ return { status: 'success' };
964
+ }
965
+ catch (error) {
966
+ if (error instanceof FormValidationError) {
967
+ return { status: 'invalid', error };
968
+ }
969
+ if (revision === submissionRevision) {
970
+ submissionError = error;
971
+ }
972
+ return { status: 'failed', error };
973
+ }
974
+ finally {
975
+ if (revision === submissionRevision) {
976
+ isSubmitting = false;
977
+ }
978
+ }
979
+ }
412
980
  const form = {
413
981
  get values() {
414
982
  void valuesRevision;
@@ -416,7 +984,10 @@ export function createForm({ initialValues, rules = {} }) {
416
984
  },
417
985
  get errors() {
418
986
  return rootErrors(fields.filter((field) => field.errors !== undefined)
419
- .map((field) => ({ name: fieldPath(field), errors: field.errors ?? [], warnings: [] })));
987
+ .map(field => ({
988
+ name: fieldPath(field),
989
+ errors: validationMessageTexts(field.errors ?? [])
990
+ })));
420
991
  },
421
992
  get isSubmitting() {
422
993
  return isSubmitting;
@@ -432,13 +1003,11 @@ export function createForm({ initialValues, rules = {} }) {
432
1003
  getFieldsError,
433
1004
  // An unknown path returns an empty list, like a field without errors.
434
1005
  getFieldError(name) {
435
- const field = findField(name);
436
- return field?.errors ?? [];
1006
+ return validationMessageTexts(getFieldMessages(name, 'errors'));
437
1007
  },
438
1008
  // Warnings are read separately from the errors that block submitted.
439
1009
  getFieldWarning(name) {
440
- const field = findField(name);
441
- return field?.warnings ?? [];
1010
+ return validationMessageTexts(getFieldMessages(name, 'warnings'));
442
1011
  },
443
1012
  getFieldInstance(name) {
444
1013
  const registration = controlRegistration(name);
@@ -468,11 +1037,34 @@ export function createForm({ initialValues, rules = {} }) {
468
1037
  return field ? resolveValidationRules(fieldRules(field), form)
469
1038
  .some((rule) => rule.required && !rule.warningOnly) : false;
470
1039
  },
1040
+ changeFieldValue(name, value, trigger = 'onChange') {
1041
+ const field = ensureField(name);
1042
+ controlDrivenFields.add(field);
1043
+ applyControlValue(field, name, () => value);
1044
+ validateControlEvent(field, trigger);
1045
+ },
1046
+ validateFieldOn(name, trigger) {
1047
+ const field = findField(name);
1048
+ if (field) {
1049
+ controlDrivenFields.add(field);
1050
+ validateControlEvent(field, trigger);
1051
+ }
1052
+ },
471
1053
  setFieldValue(name, value) {
1054
+ const previous = readStoreSnapshot();
472
1055
  if (Object.is(getFormValue(values, name), value)) {
473
1056
  const field = findField(name);
474
1057
  if (field)
475
1058
  field.dirty = true;
1059
+ // An explicit undefined entry can suppress a default when a Form attaches later.
1060
+ if (value === undefined && !hasFormValue(values, formNamePath(name))) {
1061
+ const next = setFormValue(values, name, value);
1062
+ updateValues(next);
1063
+ valuesRevision++;
1064
+ }
1065
+ // Even equal writes publish a fresh store root to predicates.
1066
+ storeSnapshot = undefined;
1067
+ notifyStoreUpdate(previous, { type: 'setField', name, hasValue: true });
476
1068
  return;
477
1069
  }
478
1070
  updateValues(setFormValue(values, name, value));
@@ -485,9 +1077,11 @@ export function createForm({ initialValues, rules = {} }) {
485
1077
  }
486
1078
  valuesRevision++;
487
1079
  submissionError = undefined;
1080
+ notifyStoreUpdate(previous, { type: 'setField', name, hasValue: true });
488
1081
  revalidateTouched();
489
1082
  },
490
1083
  setFieldsValue(next) {
1084
+ const previous = readStoreSnapshot();
491
1085
  const merged = mergeFormValues(values, next);
492
1086
  for (const field of fields) {
493
1087
  const path = fieldPath(field);
@@ -495,9 +1089,7 @@ export function createForm({ initialValues, rules = {} }) {
495
1089
  field.dirty = true;
496
1090
  field.validated = true;
497
1091
  }
498
- const parent = getFormValue(next, path.slice(0, -1));
499
- const provided = parent !== null && typeof parent === 'object'
500
- && path.length > 0 && Object.hasOwn(parent, path[path.length - 1]);
1092
+ const provided = hasFormValue(next, path);
501
1093
  if (!Object.is(getFormValue(values, path), getFormValue(merged, path))
502
1094
  || provided) {
503
1095
  clearField(field);
@@ -506,61 +1098,21 @@ export function createForm({ initialValues, rules = {} }) {
506
1098
  updateValues(merged);
507
1099
  valuesRevision++;
508
1100
  submissionError = undefined;
1101
+ notifyStoreUpdate(previous, { type: 'valueUpdate', source: 'external' });
509
1102
  revalidateTouched();
510
1103
  },
511
1104
  setFields(updates) {
512
- for (const update of updates) {
513
- const { name, ...data } = update;
514
- if ('value' in data) {
515
- const next = setFormValue(values, name, data.value);
516
- const changed = !sameFormValue(values, next);
517
- updateValues(next);
518
- if (changed) {
519
- valuesRevision++;
520
- submissionError = undefined;
521
- for (const field of fields) {
522
- if (containsFormPath(name, fieldPath(field))) {
523
- cancelValidationDelay(field);
524
- field.run = ++validationSequence;
525
- const wasValidating = field.validating;
526
- field.validating = false;
527
- if (wasValidating)
528
- notifyFieldMeta(field);
529
- }
530
- }
531
- }
532
- }
533
- for (const field of fields) {
534
- if (!sameFormPath(name, fieldPath(field))
535
- || (!field.registration && !fieldRules(field).length)) {
536
- continue;
537
- }
538
- if ('touched' in update)
539
- field.touched = !!update.touched;
540
- if ('validating' in update) {
541
- cancelValidationDelay(field);
542
- field.run = ++validationSequence;
543
- field.validating = !!update.validating;
544
- field.validated = !field.validating;
545
- }
546
- if ('errors' in update)
547
- field.errors = [...(update.errors ?? [])];
548
- if ('warnings' in update)
549
- field.warnings = [...(update.warnings ?? [])];
550
- field.dirty = true;
551
- notifyFieldMeta(field);
552
- }
553
- }
1105
+ applyFieldUpdates(updates, false);
554
1106
  },
555
1107
  touchField(name) {
556
1108
  const field = ensureField(name);
557
- field.touched = true;
558
- field.dirty = true;
559
- notifyFieldMeta(field);
560
- revalidateTouched();
1109
+ markTouched(field);
1110
+ revalidateTouched({ explicitTouch: true });
561
1111
  },
562
1112
  resetFields(names) {
1113
+ const previous = readStoreSnapshot();
563
1114
  if (names?.length === 0) {
1115
+ notifyStoreUpdate(previous, { type: 'reset', names });
564
1116
  return;
565
1117
  }
566
1118
  const selected = names ? fields.filter((field) => names.some((name) => sameFormPath(name, fieldPath(field)))) : [...fields];
@@ -570,9 +1122,8 @@ export function createForm({ initialValues, rules = {} }) {
570
1122
  next = setFormValue(next, name, getFormValue(defaults, name));
571
1123
  }
572
1124
  }
573
- // Defaults are followed by mount order as React Field; registrationOrder preserves the
574
- // previous order value projection, refs and reset callbacks.
575
- const initialFields = [...selected].sort((first, second) => (first.initialValueOrder ?? 0) - (second.initialValueOrder ?? 0));
1125
+ // React Field applies declared defaults in mount order.
1126
+ const initialFields = [...selected].sort((first, second) => (first.mountOrder ?? 0) - (second.mountOrder ?? 0));
576
1127
  for (const field of initialFields) {
577
1128
  const registration = field.registration;
578
1129
  const path = fieldPath(field);
@@ -593,51 +1144,21 @@ export function createForm({ initialValues, rules = {} }) {
593
1144
  }
594
1145
  else {
595
1146
  valuesRevision++;
1147
+ storeSnapshot = undefined;
596
1148
  values = next;
597
1149
  resetKey = {};
598
1150
  }
599
- for (const field of selected) {
600
- cancelValidationDelay(field);
601
- field.errors = undefined;
602
- field.warnings = undefined;
603
- field.touched = false;
604
- field.dirty = false;
605
- field.validating = false;
606
- field.validated = false;
607
- field.run = ++validationSequence;
608
- notifyFieldMeta(field);
609
- }
610
1151
  submissionError = undefined;
611
- selected.sort((first, second) => (first.registrationOrder ?? 0) - (second.registrationOrder ?? 0));
612
- for (const field of selected)
613
- field.registration?.onReset?.();
1152
+ const includeObservers = !names || names.some(name => sameFormPath(name, []));
1153
+ resetBindings(selected, includeObservers);
1154
+ notifyStoreUpdate(previous, { type: 'reset', names });
614
1155
  },
615
1156
  validateFields,
616
- async submit(onFinish) {
617
- if (isSubmitting) {
618
- return { status: 'busy' };
619
- }
620
- isSubmitting = true;
621
- submissionError = undefined;
622
- for (const field of fields) {
623
- field.touched = true;
624
- notifyFieldMeta(field);
625
- }
626
- try {
627
- const result = await validateFields();
628
- await onFinish(result);
629
- return { status: 'success' };
630
- }
631
- catch (error) {
632
- if (error instanceof FormValidationError) {
633
- return { status: 'invalid', error };
634
- }
635
- submissionError = error;
636
- return { status: 'failed', error };
637
- }
638
- finally {
639
- isSubmitting = false;
640
- }
1157
+ get submit() {
1158
+ return submit;
1159
+ },
1160
+ set submit(run) {
1161
+ submit = wrapSubmission(run);
641
1162
  }
642
1163
  };
643
1164
  // Applies initialValue only to the missing value, without subscribing to the store.
@@ -653,29 +1174,78 @@ export function createForm({ initialValues, rules = {} }) {
653
1174
  get resetKey() {
654
1175
  return resetKey;
655
1176
  },
1177
+ setInitialValues,
1178
+ attachForm(getClearOnDestroy) {
1179
+ mountedForms++;
1180
+ return () => {
1181
+ mountedForms--;
1182
+ if (!mountedForms && getClearOnDestroy()) {
1183
+ clearDetachedForm();
1184
+ }
1185
+ };
1186
+ },
656
1187
  registerValidateMessages(getMessages) {
657
1188
  messageProviders.add(getMessages);
658
1189
  return () => { messageProviders.delete(getMessages); };
659
1190
  },
1191
+ registerCallbacks(getCallbacks) {
1192
+ callbackProviders.add(getCallbacks);
1193
+ return () => { callbackProviders.delete(getCallbacks); };
1194
+ },
1195
+ subscribeStoreUpdates(listener) {
1196
+ storeListeners.add(listener);
1197
+ return () => {
1198
+ storeListeners.delete(listener);
1199
+ if (!storeListeners.size)
1200
+ storeSnapshot = undefined;
1201
+ };
1202
+ },
1203
+ registerResetObserver(reset) {
1204
+ const order = ++fieldMountOrder;
1205
+ resetObservers.set(order, reset);
1206
+ return () => { resetObservers.delete(order); };
1207
+ },
1208
+ setControlledFields: (updates) => applyFieldUpdates(updates, true),
1209
+ getWatchValues: () => watchValues,
1210
+ getFieldMessages,
660
1211
  getFieldMeta(name) {
661
1212
  const field = findField(name);
662
1213
  return field ? fieldMeta(field) : undefined;
663
1214
  },
1215
+ handleFieldBlur(name) {
1216
+ const field = ensureField(name);
1217
+ if (usesControlValidation(field)) {
1218
+ validateControlEvent(field, 'onBlur');
1219
+ }
1220
+ else {
1221
+ markTouched(field);
1222
+ revalidateTouched();
1223
+ }
1224
+ },
1225
+ handleFieldEvent,
664
1226
  initializeField: initializeFieldValue,
665
1227
  initializeList: initializeFieldValue,
666
1228
  markFieldMounted(mountKey) {
667
- const field = fields.find((field) => field.registration?.mountKey === mountKey);
1229
+ const field = findFieldByMountKey(mountKey);
668
1230
  if (field)
669
- field.initialValueOrder = ++initialValueOrder;
1231
+ field.mountOrder = ++fieldMountOrder;
670
1232
  },
671
1233
  changeList(name, next) {
1234
+ const previous = readStoreSnapshot();
672
1235
  updateValues(setFormValue(values, name, next));
673
1236
  valuesRevision++;
674
1237
  submissionError = undefined;
675
1238
  const list = ensureField(name);
676
- clearField(list);
677
- list.touched = true;
678
- list.dirty = true;
1239
+ if (list.registration?.validateTrigger === undefined) {
1240
+ clearField(list);
1241
+ }
1242
+ else {
1243
+ // With explicit triggers, an edit retains the manual result until validation runs again.
1244
+ cancelValidationDelay(list);
1245
+ list.run = ++validationSequence;
1246
+ list.validating = false;
1247
+ }
1248
+ markTouched(list);
679
1249
  for (const field of fields) {
680
1250
  if (field !== list && containsFormPath(name, fieldPath(field))) {
681
1251
  cancelValidationDelay(field);
@@ -684,39 +1254,39 @@ export function createForm({ initialValues, rules = {} }) {
684
1254
  notifyFieldMeta(field);
685
1255
  }
686
1256
  }
1257
+ publishControlEdit(name, previous);
687
1258
  // The names of keyed rows will be updated with flush; the metadata remains with the previous line instance.
688
- void tick().then(revalidateTouched);
1259
+ void tick().then(() => revalidateTouched({ changedList: list }));
689
1260
  },
690
1261
  registerField(registration) {
691
1262
  return untrack(() => {
692
1263
  initializeFieldValue(registration.name, registration.initialValue);
693
- let field = findField(registration.name);
694
- if (!field || field.registration)
695
- field = addField(registration.name);
696
- const registered = field;
1264
+ const registeredLifetime = storeLifetime;
1265
+ const available = fields.find(field => !field.registration && sameFormPath(fieldPath(field), registration.name));
1266
+ const registered = available ?? addField(registration.name);
697
1267
  registered.registration = registration;
698
1268
  registered.registrationOrder = ++registrationOrder;
699
- registered.initialValueOrder = ++initialValueOrder;
1269
+ registered.mountOrder = ++fieldMountOrder;
700
1270
  registered.metaCache = undefined;
701
1271
  if (registered.touched || registered.validating || registered.validated
702
1272
  || registered.errors?.length || registered.warnings?.length) {
703
1273
  notifyFieldMeta(registered);
704
1274
  }
1275
+ if (registration.initialValue !== undefined) {
1276
+ notifyStoreUpdate(readStoreSnapshot(), {
1277
+ type: 'valueUpdate', source: 'internal', names: [registration.name]
1278
+ });
1279
+ }
705
1280
  return () => {
1281
+ controlDrivenFields.delete(registered);
706
1282
  notifyFieldMeta(registered, true);
707
1283
  if (cancelValidationDelay(registered)) {
708
1284
  registered.run = ++validationSequence;
709
1285
  registered.validating = false;
710
1286
  }
711
1287
  if (registered.persistent) {
712
- if (registration.rules !== undefined) {
713
- registered.run = ++validationSequence;
714
- registered.errors = undefined;
715
- registered.warnings = undefined;
716
- registered.touched = false;
717
- registered.dirty = false;
718
- registered.validating = false;
719
- registered.validated = false;
1288
+ if (registration.rules !== undefined || registration.preserve === false) {
1289
+ resetFieldMetadata(registered);
720
1290
  }
721
1291
  registered.registration = undefined;
722
1292
  }
@@ -725,6 +1295,9 @@ export function createForm({ initialValues, rules = {} }) {
725
1295
  fieldRegistry.delete(registered);
726
1296
  fields = [...fieldRegistry];
727
1297
  }
1298
+ if (registeredLifetime === storeLifetime) {
1299
+ scheduleFieldRemoval(registration);
1300
+ }
728
1301
  };
729
1302
  });
730
1303
  }