spell-ui 0.8.6 → 0.8.7

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 (722) hide show
  1. package/README-components.md +14 -6
  2. package/README-frameworks.md +22 -12
  3. package/README-migrating.md +7 -6
  4. package/README-runtime.md +14 -13
  5. package/README-site.md +11 -11
  6. package/README-themes.md +38 -11
  7. package/README.md +61 -73
  8. package/dist/Dragging-CMZoLEWQ.js +169 -0
  9. package/dist/Dragging-CMZoLEWQ.js.map +1 -0
  10. package/dist/{MarkdownEngine-CbuT9Mjc.js → MarkdownEngine-CW1WGqNp.js} +122 -100
  11. package/dist/MarkdownEngine-CW1WGqNp.js.map +1 -0
  12. package/dist/{PrefStore-CeaTtjTz.js → PrefStore-Qv0e5y04.js} +22 -22
  13. package/dist/PrefStore-Qv0e5y04.js.map +1 -0
  14. package/dist/ScrollingRow-7n7Z-HIE.js +88 -0
  15. package/dist/ScrollingRow-7n7Z-HIE.js.map +1 -0
  16. package/dist/SitePages-CciwREek.js +51 -0
  17. package/dist/SitePages-CciwREek.js.map +1 -0
  18. package/dist/{SlottedItems-Ch0tzzlL.js → SlottedItems-Du3aJwG1.js} +22 -22
  19. package/dist/{SlottedItems-Ch0tzzlL.js.map → SlottedItems-Du3aJwG1.js.map} +1 -1
  20. package/dist/ThemeDraft-B7NPif4d.js +805 -0
  21. package/dist/ThemeDraft-B7NPif4d.js.map +1 -0
  22. package/dist/TreeMeasure-BVJeGb1L.js +42 -0
  23. package/dist/TreeMeasure-BVJeGb1L.js.map +1 -0
  24. package/dist/UIButton-DFEds67r.js +6 -0
  25. package/dist/UIButton-DFEds67r.js.map +1 -0
  26. package/dist/UIInput-BodVbUoQ.js +6 -0
  27. package/dist/UIInput-BodVbUoQ.js.map +1 -0
  28. package/dist/{UIKeys-DJF2TIKE.js → UIKeys-Rh_gUZjP.js} +10 -9
  29. package/dist/UIKeys-Rh_gUZjP.js.map +1 -0
  30. package/dist/UILabel-DgJUBzB_.js +6 -0
  31. package/dist/UILabel-DgJUBzB_.js.map +1 -0
  32. package/dist/UIMenu-zdcAtwTa.js +42 -0
  33. package/dist/UIMenu-zdcAtwTa.js.map +1 -0
  34. package/dist/{UIRuntime-BBuehGly.js → UIRuntime-KH309p5B.js} +398 -207
  35. package/dist/UIRuntime-KH309p5B.js.map +1 -0
  36. package/dist/_spell-element/DOMElement.d.ts +62 -5
  37. package/dist/_spell-element/MoveAndResize.d.ts +75 -0
  38. package/dist/_spell-element/UIComponent.d.ts +42 -0
  39. package/dist/_spell-element/elements.types.d.ts +47 -0
  40. package/dist/_spell-element/index.d.ts +1 -0
  41. package/dist/_spell-element/vocabulary.types.d.ts +34 -2
  42. package/dist/{runtime → _util}/Api.d.ts +14 -4
  43. package/dist/_util/Dragging.d.ts +148 -0
  44. package/dist/_util/ListSelection.d.ts +46 -0
  45. package/dist/{util → _util}/LoadOnce.d.ts +9 -1
  46. package/dist/_util/ReconnectingSocket.d.ts +51 -0
  47. package/dist/_util/diagram/DiagramColumns.d.ts +14 -0
  48. package/dist/_util/diagram/DiagramLayout.d.ts +119 -0
  49. package/dist/_util/diagram/DiagramSVG.d.ts +17 -0
  50. package/dist/_util/dom.d.ts +10 -0
  51. package/dist/_util/fetching.d.ts +92 -0
  52. package/dist/_util/measures/Dimension.d.ts +63 -0
  53. package/dist/_util/measures/MeasureSystem.d.ts +66 -0
  54. package/dist/_util/measures/dimensions.generated.d.ts +16 -0
  55. package/dist/_util/persist/ColorScheme.d.ts +6 -0
  56. package/dist/_util/persist/ServerPlace.d.ts +42 -0
  57. package/dist/_util/persist/WaitedOnPlace.d.ts +27 -0
  58. package/dist/_util/persist/persist.types.d.ts +21 -2
  59. package/dist/_util/timing.d.ts +10 -1
  60. package/dist/api.js +8 -7
  61. package/dist/api.js.map +1 -1
  62. package/dist/components/ComponentDefinitions.d.ts +29 -0
  63. package/dist/components/components.es.d.ts +13 -0
  64. package/dist/components/components.types.d.ts +113 -8
  65. package/dist/components/ui-accordion/UIAccordion.d.ts +1 -0
  66. package/dist/components/ui-accordion/UIAccordion.en.d.ts +1 -0
  67. package/dist/components/ui-action/UIAction.en.d.ts +5 -1
  68. package/dist/components/ui-ad/UIAd.d.ts +1 -0
  69. package/dist/components/ui-ad/UIAd.en.d.ts +1 -0
  70. package/dist/components/ui-breadcrumbs/UIBreadcrumb.d.ts +1 -0
  71. package/dist/components/ui-breadcrumbs/UIBreadcrumb.en.d.ts +1 -0
  72. package/dist/components/ui-breadcrumbs/UIBreadcrumbs.d.ts +1 -0
  73. package/dist/components/ui-breadcrumbs/UIBreadcrumbs.en.d.ts +1 -0
  74. package/dist/components/ui-button/UIButton.d.ts +8 -3
  75. package/dist/components/ui-button/UIButton.en.d.ts +9 -4
  76. package/dist/components/ui-button/UIButton.es.d.ts +6 -0
  77. package/dist/components/ui-button/UIButton.fallback.d.ts +8 -3
  78. package/dist/components/ui-button/UIButtons.d.ts +1 -0
  79. package/dist/components/ui-button/UIButtons.en.d.ts +1 -0
  80. package/dist/components/ui-button/UIOr.d.ts +1 -0
  81. package/dist/components/ui-button/UIOr.en.d.ts +1 -0
  82. package/dist/components/ui-calendar/UICalendar.d.ts +6 -0
  83. package/dist/components/ui-calendar/UICalendar.en.d.ts +6 -0
  84. package/dist/components/ui-calendar/UICalendar.fallback.d.ts +6 -0
  85. package/dist/components/ui-card/CardClicks.d.ts +40 -0
  86. package/dist/components/ui-card/UICard.d.ts +41 -0
  87. package/dist/components/ui-card/UICard.en.d.ts +49 -0
  88. package/dist/components/ui-card/UICard.es.d.ts +1 -0
  89. package/dist/components/ui-card/UICards.d.ts +31 -0
  90. package/dist/components/ui-card/UICards.en.d.ts +31 -0
  91. package/dist/components/ui-card/UICards.es.d.ts +8 -0
  92. package/dist/components/ui-checkbox/CheckControl.d.ts +7 -0
  93. package/dist/components/ui-checkbox/UICheckbox.d.ts +7 -0
  94. package/dist/components/ui-checkbox/UICheckbox.en.d.ts +7 -0
  95. package/dist/components/ui-checkbox/UICheckbox.es.d.ts +1 -0
  96. package/dist/components/ui-checkbox/UICheckbox.fallback.d.ts +7 -0
  97. package/dist/components/ui-checkbox/UICheckbox.types.d.ts +5 -0
  98. package/dist/components/ui-checkbox/UIRadio.d.ts +8 -0
  99. package/dist/components/ui-checkbox/UIRadio.en.d.ts +6 -0
  100. package/dist/components/ui-code/UICode.en.d.ts +1 -0
  101. package/dist/components/ui-comment/UIComment.d.ts +1 -0
  102. package/dist/components/ui-comment/UIComment.en.d.ts +1 -0
  103. package/dist/components/ui-comment/UIComments.d.ts +1 -0
  104. package/dist/components/ui-comment/UIComments.en.d.ts +1 -0
  105. package/dist/components/ui-components/PackHotSwap.d.ts +13 -3
  106. package/dist/components/ui-components/UIComponents.d.ts +1 -0
  107. package/dist/components/ui-components/UIComponents.en.d.ts +1 -0
  108. package/dist/components/ui-container/UIContainer.d.ts +11 -0
  109. package/dist/components/ui-container/UIContainer.en.d.ts +7 -0
  110. package/dist/components/ui-container/UIContainer.es.d.ts +1 -0
  111. package/dist/components/ui-diagram/UIDiagram.d.ts +268 -0
  112. package/dist/components/ui-diagram/UIDiagram.en.d.ts +106 -0
  113. package/dist/components/ui-diagram/UIDiagram.es.d.ts +37 -0
  114. package/dist/components/ui-diagram/UIDiagramNode.d.ts +98 -0
  115. package/dist/components/ui-diagram/UIDiagramNode.en.d.ts +38 -0
  116. package/dist/components/ui-diagram/UIDiagramNode.es.d.ts +16 -0
  117. package/dist/components/ui-diagram/index.d.ts +8 -0
  118. package/dist/components/ui-dimension/UIDimension.d.ts +81 -0
  119. package/dist/components/ui-dimension/UIDimension.en.d.ts +54 -0
  120. package/dist/components/ui-dimension/UIDimension.es.d.ts +22 -0
  121. package/dist/components/ui-dimension/index.d.ts +2 -0
  122. package/dist/components/ui-dimmer/UIDimmer.d.ts +6 -1
  123. package/dist/components/ui-dimmer/UIDimmer.en.d.ts +1 -0
  124. package/dist/components/ui-dimmer/UIDimmer.es.d.ts +1 -1
  125. package/dist/components/ui-divider/UIDivider.d.ts +2 -0
  126. package/dist/components/ui-divider/UIDivider.en.d.ts +2 -0
  127. package/dist/components/ui-divider/UIDivider.es.d.ts +1 -0
  128. package/dist/components/ui-dropdown/UIDropdown.d.ts +6 -0
  129. package/dist/components/ui-dropdown/UIDropdown.en.d.ts +6 -0
  130. package/dist/components/ui-dropdown/UIDropdown.fallback.d.ts +6 -0
  131. package/dist/components/ui-embed/UIEmbed.d.ts +1 -0
  132. package/dist/components/ui-embed/UIEmbed.en.d.ts +1 -0
  133. package/dist/components/ui-emoji/UIEmoji.d.ts +1 -0
  134. package/dist/components/ui-emoji/UIEmoji.en.d.ts +1 -0
  135. package/dist/components/ui-example/UIExample.en.d.ts +4 -2
  136. package/dist/components/ui-example/UIExample.es.d.ts +3 -2
  137. package/dist/components/ui-feed/UIFeed.d.ts +1 -0
  138. package/dist/components/ui-feed/UIFeed.en.d.ts +1 -0
  139. package/dist/components/ui-feed/UIFeedEvent.d.ts +1 -0
  140. package/dist/components/ui-feed/UIFeedEvent.en.d.ts +1 -0
  141. package/dist/components/ui-flag/UIFlag.d.ts +1 -0
  142. package/dist/components/ui-flag/UIFlag.en.d.ts +1 -0
  143. package/dist/components/ui-flyout/UIFlyout.d.ts +1 -0
  144. package/dist/components/ui-flyout/UIFlyout.en.d.ts +1 -0
  145. package/dist/components/ui-form/FormBinding.d.ts +13 -1
  146. package/dist/components/ui-form/FormFields.d.ts +4 -4
  147. package/dist/components/ui-form/UIField.d.ts +30 -3
  148. package/dist/components/ui-form/UIField.en.d.ts +9 -0
  149. package/dist/components/ui-form/UIField.es.d.ts +6 -0
  150. package/dist/components/ui-form/UIFields.d.ts +1 -0
  151. package/dist/components/ui-form/UIFields.en.d.ts +1 -0
  152. package/dist/components/ui-form/UIForm.d.ts +15 -0
  153. package/dist/components/ui-form/UIForm.en.d.ts +6 -0
  154. package/dist/components/ui-form/UIRepeat.d.ts +1 -0
  155. package/dist/components/ui-form/UIRepeat.en.d.ts +1 -0
  156. package/dist/components/ui-form/index.d.ts +2 -1
  157. package/dist/components/ui-grid/UIColumn.d.ts +1 -0
  158. package/dist/components/ui-grid/UIColumn.en.d.ts +1 -0
  159. package/dist/components/ui-grid/UIGrid.d.ts +1 -0
  160. package/dist/components/ui-grid/UIGrid.en.d.ts +1 -0
  161. package/dist/components/ui-grid/UIRow.d.ts +1 -0
  162. package/dist/components/ui-grid/UIRow.en.d.ts +1 -0
  163. package/dist/components/ui-icon/UIIcon.d.ts +3 -2
  164. package/dist/components/ui-icon/UIIcon.en.d.ts +3 -2
  165. package/dist/components/ui-icon/UIIcons.d.ts +1 -0
  166. package/dist/components/ui-icon/UIIcons.en.d.ts +1 -0
  167. package/dist/components/ui-icon-picker/UIIconPicker.d.ts +6 -0
  168. package/dist/components/ui-icon-picker/UIIconPicker.en.d.ts +6 -0
  169. package/dist/components/ui-icon-picker/UIIconPicker.fallback.d.ts +6 -0
  170. package/dist/components/ui-image/UIImage.d.ts +34 -0
  171. package/dist/components/ui-image/UIImage.en.d.ts +23 -0
  172. package/dist/components/ui-image/UIImage.es.d.ts +2 -0
  173. package/dist/components/ui-image/UIImages.d.ts +1 -0
  174. package/dist/components/ui-image/UIImages.en.d.ts +1 -0
  175. package/dist/components/ui-include/UIInclude.d.ts +1 -0
  176. package/dist/components/ui-include/UIInclude.en.d.ts +1 -0
  177. package/dist/components/ui-input/TextControl.d.ts +7 -0
  178. package/dist/components/ui-input/UIInput.d.ts +22 -3
  179. package/dist/components/ui-input/UIInput.en.d.ts +9 -2
  180. package/dist/components/ui-input/UIInput.es.d.ts +2 -0
  181. package/dist/components/ui-input/UIInput.fallback.d.ts +9 -2
  182. package/dist/components/ui-input/UITextarea.d.ts +20 -0
  183. package/dist/components/ui-input/UITextarea.en.d.ts +15 -0
  184. package/dist/components/ui-input/UITextarea.es.d.ts +4 -0
  185. package/dist/components/ui-item/UIItem.d.ts +27 -4
  186. package/dist/components/ui-item/UIItem.en.d.ts +5 -1
  187. package/dist/components/ui-items/UIItems.d.ts +1 -0
  188. package/dist/components/ui-items/UIItems.en.d.ts +1 -0
  189. package/dist/components/ui-json/JsonChild.d.ts +30 -0
  190. package/dist/components/ui-json/UIJson.d.ts +128 -0
  191. package/dist/components/ui-json/UIJson.en.d.ts +71 -0
  192. package/dist/components/ui-json/UIJson.es.d.ts +12 -0
  193. package/dist/components/ui-json/index.d.ts +3 -0
  194. package/dist/components/ui-keys/UIKeys.d.ts +1 -0
  195. package/dist/components/ui-keys/UIKeys.en.d.ts +1 -0
  196. package/dist/components/ui-label/UILabel.d.ts +2 -0
  197. package/dist/components/ui-label/UILabel.en.d.ts +2 -0
  198. package/dist/components/ui-label/UILabel.es.d.ts +1 -0
  199. package/dist/components/ui-label/UILabels.d.ts +1 -0
  200. package/dist/components/ui-label/UILabels.en.d.ts +1 -0
  201. package/dist/components/ui-list/UIList.d.ts +2 -0
  202. package/dist/components/ui-list/UIList.en.d.ts +2 -0
  203. package/dist/components/ui-list/UIList.es.d.ts +1 -0
  204. package/dist/components/ui-loader/UILoader.d.ts +1 -0
  205. package/dist/components/ui-loader/UILoader.en.d.ts +1 -0
  206. package/dist/components/ui-markdown/MarkdownBox.d.ts +143 -0
  207. package/dist/components/ui-markdown/MarkdownEngine.d.ts +14 -2
  208. package/dist/components/ui-markdown/MarkdownFormats.d.ts +95 -0
  209. package/dist/components/ui-markdown/MarkdownSource.d.ts +57 -0
  210. package/dist/components/ui-markdown/UIMarkdown.d.ts +126 -6
  211. package/dist/components/ui-markdown/UIMarkdown.en.d.ts +111 -8
  212. package/dist/components/ui-markdown/UIMarkdown.es.d.ts +29 -1
  213. package/dist/components/ui-markdown/UIMarkdown.types.d.ts +26 -0
  214. package/dist/components/ui-menu/ScrollingRow.d.ts +79 -0
  215. package/dist/components/ui-menu/TitleFit.d.ts +3 -0
  216. package/dist/components/ui-menu/UIMenu.d.ts +97 -4
  217. package/dist/components/ui-menu/UIMenu.en.d.ts +50 -1
  218. package/dist/components/ui-menu/UIMenu.es.d.ts +4 -0
  219. package/dist/components/ui-message/UIMessage.d.ts +2 -0
  220. package/dist/components/ui-message/UIMessage.en.d.ts +2 -0
  221. package/dist/components/ui-message/UIMessage.es.d.ts +1 -0
  222. package/dist/components/ui-modal/UIModal.d.ts +1 -0
  223. package/dist/components/ui-modal/UIModal.en.d.ts +1 -0
  224. package/dist/components/ui-nag/UINag.d.ts +1 -0
  225. package/dist/components/ui-nag/UINag.en.d.ts +1 -0
  226. package/dist/components/ui-page/UIPage.d.ts +15 -0
  227. package/dist/components/ui-page/UIPage.en.d.ts +15 -0
  228. package/dist/components/ui-page/UIPage.es.d.ts +1 -0
  229. package/dist/components/ui-panel/UIPanel.d.ts +6 -0
  230. package/dist/components/ui-panel/UIPanel.en.d.ts +33 -20
  231. package/dist/components/ui-parts/UIActions.d.ts +1 -0
  232. package/dist/components/ui-parts/UIActions.en.d.ts +1 -0
  233. package/dist/components/ui-parts/UIAuthor.d.ts +1 -0
  234. package/dist/components/ui-parts/UIAuthor.en.d.ts +1 -0
  235. package/dist/components/ui-parts/UIAvatar.d.ts +1 -0
  236. package/dist/components/ui-parts/UIAvatar.en.d.ts +1 -0
  237. package/dist/components/ui-parts/UIContent.d.ts +1 -0
  238. package/dist/components/ui-parts/UIContent.en.d.ts +1 -0
  239. package/dist/components/ui-parts/UIDate.d.ts +1 -0
  240. package/dist/components/ui-parts/UIDate.en.d.ts +1 -0
  241. package/dist/components/ui-parts/UIDescription.d.ts +1 -0
  242. package/dist/components/ui-parts/UIDescription.en.d.ts +1 -0
  243. package/dist/components/ui-parts/UIDetail.d.ts +1 -0
  244. package/dist/components/ui-parts/UIDetail.en.d.ts +1 -0
  245. package/dist/components/ui-parts/UIExtra.d.ts +1 -0
  246. package/dist/components/ui-parts/UIExtra.en.d.ts +1 -0
  247. package/dist/components/ui-parts/UIHeader.d.ts +3 -1
  248. package/dist/components/ui-parts/UIHeader.en.d.ts +3 -1
  249. package/dist/components/ui-parts/UIMeta.d.ts +1 -0
  250. package/dist/components/ui-parts/UIMeta.en.d.ts +1 -0
  251. package/dist/components/ui-parts/UIParts.types.d.ts +15 -1
  252. package/dist/components/ui-parts/UISummary.d.ts +1 -0
  253. package/dist/components/ui-parts/UISummary.en.d.ts +1 -0
  254. package/dist/components/ui-parts/UITitle.d.ts +1 -0
  255. package/dist/components/ui-parts/UITitle.en.d.ts +1 -0
  256. package/dist/components/ui-parts/UIValue.d.ts +1 -0
  257. package/dist/components/ui-parts/UIValue.en.d.ts +1 -0
  258. package/dist/components/ui-placeholder/UIPlaceholder.d.ts +1 -0
  259. package/dist/components/ui-placeholder/UIPlaceholder.en.d.ts +1 -0
  260. package/dist/components/ui-placeholder/UIPlaceholderHeader.d.ts +1 -0
  261. package/dist/components/ui-placeholder/UIPlaceholderHeader.en.d.ts +1 -0
  262. package/dist/components/ui-placeholder/UIPlaceholderImage.d.ts +1 -0
  263. package/dist/components/ui-placeholder/UIPlaceholderImage.en.d.ts +1 -0
  264. package/dist/components/ui-placeholder/UIPlaceholderLine.d.ts +1 -0
  265. package/dist/components/ui-placeholder/UIPlaceholderLine.en.d.ts +1 -0
  266. package/dist/components/ui-placeholder/UIPlaceholderParagraph.d.ts +1 -0
  267. package/dist/components/ui-placeholder/UIPlaceholderParagraph.en.d.ts +1 -0
  268. package/dist/components/ui-popup/UIPopup.d.ts +30 -3
  269. package/dist/components/ui-popup/UIPopup.en.d.ts +7 -0
  270. package/dist/components/ui-popup/UIPopup.es.d.ts +1 -0
  271. package/dist/components/ui-progress/UIProgress.d.ts +2 -0
  272. package/dist/components/ui-progress/UIProgress.en.d.ts +2 -0
  273. package/dist/components/ui-progress/UIProgress.es.d.ts +1 -0
  274. package/dist/components/ui-property-editor/UIProperty.d.ts +132 -5
  275. package/dist/components/ui-property-editor/UIProperty.en.d.ts +11 -44
  276. package/dist/components/ui-property-editor/UIProperty.es.d.ts +4 -0
  277. package/dist/components/ui-property-editor/UIPropertyEditor.d.ts +38 -0
  278. package/dist/components/ui-property-editor/UIPropertyEditor.en.d.ts +1 -0
  279. package/dist/components/ui-property-editor/UIPropertyEditor.es.d.ts +4 -0
  280. package/dist/components/ui-property-editor/UIPropertyEditor.types.d.ts +33 -0
  281. package/dist/components/ui-property-editor/UIPropertyGroup.d.ts +12 -0
  282. package/dist/components/ui-property-editor/UIPropertyGroup.en.d.ts +2 -0
  283. package/dist/components/ui-property-editor/UIPropertyGroup.es.d.ts +9 -0
  284. package/dist/components/ui-property-editor/index.d.ts +1 -0
  285. package/dist/components/ui-quote/UIQuote.d.ts +1 -0
  286. package/dist/components/ui-quote/UIQuote.en.d.ts +1 -0
  287. package/dist/components/ui-rail/UIRail.d.ts +1 -0
  288. package/dist/components/ui-rail/UIRail.en.d.ts +1 -0
  289. package/dist/components/ui-rating/UIRating.d.ts +6 -0
  290. package/dist/components/ui-rating/UIRating.en.d.ts +6 -0
  291. package/dist/components/ui-rating/UIRating.fallback.d.ts +6 -0
  292. package/dist/components/ui-reveal/UIReveal.d.ts +1 -0
  293. package/dist/components/ui-reveal/UIReveal.en.d.ts +1 -0
  294. package/dist/components/ui-root/UIRoot.d.ts +18 -3
  295. package/dist/components/ui-root/UIRoot.en.d.ts +15 -0
  296. package/dist/components/ui-root/UIRoot.es.d.ts +1 -0
  297. package/dist/components/ui-search/UISearch.d.ts +48 -7
  298. package/dist/components/ui-search/UISearch.en.d.ts +13 -1
  299. package/dist/components/ui-search/UISearch.es.d.ts +1 -0
  300. package/dist/components/ui-search/UISearch.fallback.d.ts +13 -1
  301. package/dist/components/ui-section/UISection.d.ts +22 -1
  302. package/dist/components/ui-section/UISection.en.d.ts +10 -0
  303. package/dist/components/ui-section/UISection.es.d.ts +1 -0
  304. package/dist/components/ui-section/UISections.d.ts +1 -0
  305. package/dist/components/ui-section/UISections.en.d.ts +1 -0
  306. package/dist/components/ui-segment/UISegment.d.ts +2 -0
  307. package/dist/components/ui-segment/UISegment.en.d.ts +2 -0
  308. package/dist/components/ui-segment/UISegment.es.d.ts +1 -0
  309. package/dist/components/ui-segment/UISegments.d.ts +1 -0
  310. package/dist/components/ui-segment/UISegments.en.d.ts +1 -0
  311. package/dist/components/ui-select/UISelect.d.ts +6 -0
  312. package/dist/components/ui-select/UISelect.en.d.ts +6 -0
  313. package/dist/components/ui-select/UISelect.fallback.d.ts +6 -0
  314. package/dist/components/ui-shape/UIShape.d.ts +23 -2
  315. package/dist/components/ui-shape/UIShape.en.d.ts +8 -0
  316. package/dist/components/ui-shape/UIShape.es.d.ts +1 -0
  317. package/dist/components/ui-shape/UISide.d.ts +4 -0
  318. package/dist/components/ui-shape/UISide.en.d.ts +4 -0
  319. package/dist/components/ui-sidebar/UIPushable.d.ts +1 -0
  320. package/dist/components/ui-sidebar/UIPushable.en.d.ts +1 -0
  321. package/dist/components/ui-sidebar/UIPusher.d.ts +1 -0
  322. package/dist/components/ui-sidebar/UIPusher.en.d.ts +1 -0
  323. package/dist/components/ui-sidebar/UISidebar.d.ts +1 -0
  324. package/dist/components/ui-sidebar/UISidebar.en.d.ts +1 -0
  325. package/dist/components/ui-sides/UISides.d.ts +209 -0
  326. package/dist/components/ui-sides/UISides.en.d.ts +122 -0
  327. package/dist/components/ui-sides/UISides.es.d.ts +30 -0
  328. package/dist/components/ui-sides/UISides.fallback.d.ts +134 -0
  329. package/dist/components/ui-sides/index.d.ts +2 -0
  330. package/dist/components/ui-site-nav/SitePages.d.ts +53 -0
  331. package/dist/components/ui-site-nav/UISiteNav.d.ts +207 -0
  332. package/dist/components/ui-site-nav/UISiteNav.en.d.ts +87 -0
  333. package/dist/components/ui-site-nav/UISiteNav.es.d.ts +29 -0
  334. package/dist/components/ui-site-nav/index.d.ts +1 -0
  335. package/dist/components/ui-site-tabs/UISiteTabs.d.ts +126 -0
  336. package/dist/components/ui-site-tabs/UISiteTabs.en.d.ts +49 -0
  337. package/dist/components/ui-site-tabs/UISiteTabs.es.d.ts +18 -0
  338. package/dist/components/ui-site-tabs/index.d.ts +1 -0
  339. package/dist/components/ui-slider/UISlider.d.ts +7 -0
  340. package/dist/components/ui-slider/UISlider.en.d.ts +7 -0
  341. package/dist/components/ui-slider/UISlider.es.d.ts +1 -0
  342. package/dist/components/ui-slider/UISlider.fallback.d.ts +7 -0
  343. package/dist/components/ui-space/UISpace.d.ts +1 -0
  344. package/dist/components/ui-space/UISpace.en.d.ts +1 -0
  345. package/dist/components/ui-split-panel/UISplitPanel.d.ts +175 -0
  346. package/dist/components/ui-split-panel/UISplitPanel.en.d.ts +74 -0
  347. package/dist/components/ui-split-panel/UISplitPanel.es.d.ts +25 -0
  348. package/dist/components/ui-split-panel/index.d.ts +2 -0
  349. package/dist/components/ui-stack/UIStack.d.ts +31 -5
  350. package/dist/components/ui-stack/UIStack.en.d.ts +15 -3
  351. package/dist/components/ui-statistic/UIStatistic.d.ts +1 -0
  352. package/dist/components/ui-statistic/UIStatistic.en.d.ts +1 -0
  353. package/dist/components/ui-statistic/UIStatistics.d.ts +1 -0
  354. package/dist/components/ui-statistic/UIStatistics.en.d.ts +1 -0
  355. package/dist/components/ui-step/UIStep.d.ts +1 -0
  356. package/dist/components/ui-step/UIStep.en.d.ts +1 -0
  357. package/dist/components/ui-step/UISteps.d.ts +1 -0
  358. package/dist/components/ui-step/UISteps.en.d.ts +1 -0
  359. package/dist/components/ui-sticky/UISticky.d.ts +4 -0
  360. package/dist/components/ui-sticky/UISticky.en.d.ts +1 -0
  361. package/dist/components/ui-tab/UITab.d.ts +8 -0
  362. package/dist/components/ui-tab/UITab.en.d.ts +1 -0
  363. package/dist/components/ui-tab/UITabs.d.ts +107 -16
  364. package/dist/components/ui-tab/UITabs.en.d.ts +40 -1
  365. package/dist/components/ui-tab/UITabs.es.d.ts +4 -0
  366. package/dist/components/ui-table/TableEditing.d.ts +77 -0
  367. package/dist/components/ui-table/UICell.d.ts +1 -0
  368. package/dist/components/ui-table/UICell.en.d.ts +1 -0
  369. package/dist/components/ui-table/UITable.d.ts +145 -5
  370. package/dist/components/ui-table/UITable.en.d.ts +19 -0
  371. package/dist/components/ui-table/UITable.es.d.ts +3 -0
  372. package/dist/components/ui-terms/UITerm.d.ts +1 -0
  373. package/dist/components/ui-terms/UITerm.en.d.ts +1 -0
  374. package/dist/components/ui-terms/UITerms.d.ts +1 -0
  375. package/dist/components/ui-terms/UITerms.en.d.ts +1 -0
  376. package/dist/components/ui-text/UILink.d.ts +11 -0
  377. package/dist/components/ui-text/UILink.en.d.ts +4 -0
  378. package/dist/components/ui-text/UIText.d.ts +7 -0
  379. package/dist/components/ui-text/UIText.en.d.ts +7 -0
  380. package/dist/components/ui-text/UIText.es.d.ts +2 -0
  381. package/dist/components/ui-theme-editor/SavedTheme.d.ts +55 -43
  382. package/dist/components/ui-theme-editor/ThemeDraft.d.ts +15 -0
  383. package/dist/components/ui-theme-editor/UIColorChip.d.ts +1 -0
  384. package/dist/components/ui-theme-editor/UIColorChip.en.d.ts +1 -0
  385. package/dist/components/ui-theme-editor/UIThemeEditor.d.ts +157 -26
  386. package/dist/components/ui-theme-editor/UIThemeEditor.en.d.ts +79 -6
  387. package/dist/components/ui-theme-editor/UIThemeEditor.es.d.ts +20 -2
  388. package/dist/components/ui-theme-editor/UIThemeEditor.types.d.ts +0 -2
  389. package/dist/components/ui-theme-editor/UIThemeToken.d.ts +1 -0
  390. package/dist/components/ui-theme-editor/UIThemeToken.en.d.ts +1 -0
  391. package/dist/components/ui-theme-menu/HueDropdown.d.ts +47 -0
  392. package/dist/components/ui-theme-menu/ThemeMenu.d.ts +18 -7
  393. package/dist/components/ui-theme-menu/ThemePreference.d.ts +145 -36
  394. package/dist/components/ui-theme-menu/UIThemeMenu.d.ts +118 -7
  395. package/dist/components/ui-theme-menu/UIThemeMenu.en.d.ts +82 -2
  396. package/dist/components/ui-theme-menu/UIThemeMenu.es.d.ts +21 -1
  397. package/dist/components/ui-theme-menu/UIThemeMenu.types.d.ts +36 -8
  398. package/dist/components/ui-theme-menu/index.d.ts +2 -1
  399. package/dist/components/ui-toast/UIToast.d.ts +1 -0
  400. package/dist/components/ui-toast/UIToast.en.d.ts +1 -0
  401. package/dist/components/ui-toc/UIToc.d.ts +1 -0
  402. package/dist/components/ui-toc/UIToc.en.d.ts +1 -0
  403. package/dist/components/ui-toolbar/UIToolbar.d.ts +13 -10
  404. package/dist/components/ui-toolbar/UIToolbar.en.d.ts +138 -84
  405. package/dist/components/ui-toolbar/UIToolbar.es.d.ts +2 -0
  406. package/dist/components/ui-transition/UITransition.d.ts +1 -0
  407. package/dist/components/ui-transition/UITransition.en.d.ts +1 -0
  408. package/dist/components/ui-tree/UITree.d.ts +162 -0
  409. package/dist/components/ui-tree/UITree.en.d.ts +88 -0
  410. package/dist/components/ui-tree/UITree.es.d.ts +35 -0
  411. package/dist/components/ui-tree/UITreeItem.d.ts +204 -0
  412. package/dist/components/ui-tree/UITreeItem.en.d.ts +142 -0
  413. package/dist/components/ui-tree/UITreeItem.es.d.ts +32 -0
  414. package/dist/components/ui-tree/index.d.ts +3 -0
  415. package/dist/components/ui-tree-diagram/TreeData.d.ts +3 -12
  416. package/dist/components/ui-tree-diagram/TreeLayout.d.ts +54 -21
  417. package/dist/components/ui-tree-diagram/TreeMeasure.d.ts +36 -0
  418. package/dist/components/ui-tree-diagram/UITreeDiagram.d.ts +152 -27
  419. package/dist/components/ui-tree-diagram/UITreeDiagram.en.d.ts +47 -7
  420. package/dist/components/ui-tree-diagram/UITreeDiagram.es.d.ts +12 -1
  421. package/dist/components/ui-tree-diagram/UITreeDiagram.types.d.ts +66 -21
  422. package/dist/components/ui-tree-diagram/UITreeNode.d.ts +148 -0
  423. package/dist/components/ui-tree-diagram/UITreeNode.en.d.ts +69 -0
  424. package/dist/components/ui-tree-diagram/UITreeNode.es.d.ts +21 -0
  425. package/dist/components/ui-tree-diagram/index.d.ts +4 -2
  426. package/dist/components/ui-video/UIAudio.d.ts +1 -0
  427. package/dist/components/ui-video/UIAudio.en.d.ts +1 -0
  428. package/dist/components/ui-video/UIVideo.d.ts +1 -0
  429. package/dist/components/ui-video/UIVideo.en.d.ts +1 -0
  430. package/dist/components/ui-visibility/UIVisibility.d.ts +1 -0
  431. package/dist/components/ui-visibility/UIVisibility.en.d.ts +1 -0
  432. package/dist/components/ui-zoom/UIZoom.d.ts +1 -0
  433. package/dist/components/ui-zoom/UIZoom.en.d.ts +1 -0
  434. package/dist/{components.es-DmLzT-Bq.js → components.es-BOa_7gFF.js} +498 -109
  435. package/dist/components.es-BOa_7gFF.js.map +1 -0
  436. package/dist/core.d.ts +3 -1
  437. package/dist/core.js +1082 -511
  438. package/dist/core.js.map +1 -1
  439. package/dist/crisp-VfYZlTph.js +6 -0
  440. package/dist/{crisp-CoZRRDuQ.js.map → crisp-VfYZlTph.js.map} +1 -1
  441. package/dist/docs-components/index.d.ts +1 -0
  442. package/dist/docs-components/ui-docs-index/UIDocsIndex.d.ts +89 -0
  443. package/dist/docs-components/ui-docs-index/UIDocsIndex.en.d.ts +43 -0
  444. package/dist/docs-components/ui-docs-index/index.d.ts +2 -0
  445. package/dist/docs-components/ui-docs-nav/UIDocsNav.d.ts +54 -87
  446. package/dist/docs-components/ui-docs-nav/UIDocsNav.types.d.ts +2 -29
  447. package/dist/docs-components/ui-docs-search/SearchIndex.d.ts +8 -2
  448. package/dist/docs-components/ui-docs-search/UIDocsSearch.d.ts +10 -0
  449. package/dist/docs-components/ui-docs-search/UIDocsSearch.en.d.ts +5 -0
  450. package/dist/elements/AddressParameter.d.ts +87 -0
  451. package/dist/elements/DOMFormControl.d.ts +5 -0
  452. package/dist/elements/FormComponent.d.ts +32 -0
  453. package/dist/elements/LoadableBody.d.ts +6 -1
  454. package/dist/elements/LoadableComponent.d.ts +10 -1
  455. package/dist/elements/RootSettings.d.ts +43 -6
  456. package/dist/elements/SpellUISettings.d.ts +1 -0
  457. package/dist/elements/StickyWatch.d.ts +20 -0
  458. package/dist/elements/elements.types.d.ts +15 -0
  459. package/dist/elements/index.d.ts +2 -0
  460. package/dist/forms.js +93 -63
  461. package/dist/forms.js.map +1 -1
  462. package/dist/fruity-BRVlgJZd.js +6 -0
  463. package/dist/fruity-BRVlgJZd.js.map +1 -0
  464. package/dist/{fruity.theme-BJcMiPl1.js → fruity.theme-CbC7Jyvk.js} +2 -2
  465. package/dist/fruity.theme-CbC7Jyvk.js.map +1 -0
  466. package/dist/glass-x9tbbwVq.js +6 -0
  467. package/dist/glass-x9tbbwVq.js.map +1 -0
  468. package/dist/glass.theme-24wY2wH9.js +6 -0
  469. package/dist/glass.theme-24wY2wH9.js.map +1 -0
  470. package/dist/hot.js +530 -24
  471. package/dist/hot.js.map +1 -1
  472. package/dist/index.d.ts +8 -0
  473. package/dist/index.js +91 -81
  474. package/dist/jsx.d.ts +21149 -10377
  475. package/dist/matrix-QY2gWbJ0.js +6 -0
  476. package/dist/{matrix-CqA59hiF.js.map → matrix-QY2gWbJ0.js.map} +1 -1
  477. package/dist/{matrix.theme-jqQZjcq3.js → matrix.theme-_8xtwhDq.js} +2 -2
  478. package/dist/matrix.theme-_8xtwhDq.js.map +1 -0
  479. package/dist/midnight-BxlTQSfw.js +6 -0
  480. package/dist/{midnight-BnoVOrhC.js.map → midnight-BxlTQSfw.js.map} +1 -1
  481. package/dist/mockup-83ELBuVr.js +6 -0
  482. package/dist/mockup-83ELBuVr.js.map +1 -0
  483. package/dist/mockup.theme-DmpBgGBl.js +6 -0
  484. package/dist/mockup.theme-DmpBgGBl.js.map +1 -0
  485. package/dist/paper-M61nUilz.js +6 -0
  486. package/dist/{paper-CynH8ZuT.js.map → paper-M61nUilz.js.map} +1 -1
  487. package/dist/persist.types-D2m6wD-S.js +9 -0
  488. package/dist/persist.types-D2m6wD-S.js.map +1 -0
  489. package/dist/pop-CxXfytjk.js +6 -0
  490. package/dist/{pop-D2i9V_rG.js.map → pop-CxXfytjk.js.map} +1 -1
  491. package/dist/runtime/DataTooltips.d.ts +75 -0
  492. package/dist/runtime/PropertyControls.d.ts +15 -1
  493. package/dist/runtime/Sources.d.ts +16 -4
  494. package/dist/runtime/Styles.d.ts +11 -0
  495. package/dist/runtime/Themes.d.ts +10 -4
  496. package/dist/runtime/UIRuntime.d.ts +4 -1
  497. package/dist/runtime/index.d.ts +1 -1
  498. package/dist/runtime/runtime.types.d.ts +18 -85
  499. package/dist/spell-By5Y3jKP.js +6 -0
  500. package/dist/{spell-BFtLICm7.js.map → spell-By5Y3jKP.js.map} +1 -1
  501. package/dist/{spell.theme-B7AU7SQX.js → spell.theme-DxGj7qHx.js} +2 -2
  502. package/dist/spell.theme-DxGj7qHx.js.map +1 -0
  503. package/dist/styles/CodeThemeFile.d.ts +73 -0
  504. package/dist/styles/StyleGenerator.d.ts +6 -0
  505. package/dist/styles/styles.en.d.ts +141 -3
  506. package/dist/styles/styles.types.d.ts +2 -0
  507. package/dist/{styles.en-RLpYiO5_.js → styles.en-CUUxNwHo.js} +71 -14
  508. package/dist/styles.en-CUUxNwHo.js.map +1 -0
  509. package/dist/styles.js +13 -13
  510. package/dist/styles.js.map +1 -1
  511. package/dist/ui-accordion.js +54 -53
  512. package/dist/ui-accordion.js.map +1 -1
  513. package/dist/ui-action.js +20 -19
  514. package/dist/ui-action.js.map +1 -1
  515. package/dist/ui-ad.js +5 -4
  516. package/dist/ui-ad.js.map +1 -1
  517. package/dist/ui-breadcrumbs.js +15 -13
  518. package/dist/ui-breadcrumbs.js.map +1 -1
  519. package/dist/ui-button.js +132 -125
  520. package/dist/ui-button.js.map +1 -1
  521. package/dist/ui-calendar.js +208 -206
  522. package/dist/ui-calendar.js.map +1 -1
  523. package/dist/ui-card.js +260 -98
  524. package/dist/ui-card.js.map +1 -1
  525. package/dist/ui-checkbox.js +95 -81
  526. package/dist/ui-checkbox.js.map +1 -1
  527. package/dist/ui-code.js +25 -24
  528. package/dist/ui-code.js.map +1 -1
  529. package/dist/ui-comment.js +14 -12
  530. package/dist/ui-comment.js.map +1 -1
  531. package/dist/ui-components.js +7 -6
  532. package/dist/ui-components.js.map +1 -1
  533. package/dist/ui-container.js +24 -12
  534. package/dist/ui-container.js.map +1 -1
  535. package/dist/ui-diagram.js +1328 -0
  536. package/dist/ui-diagram.js.map +1 -0
  537. package/dist/ui-dimension.js +779 -0
  538. package/dist/ui-dimension.js.map +1 -0
  539. package/dist/ui-dimmer.js +36 -34
  540. package/dist/ui-dimmer.js.map +1 -1
  541. package/dist/ui-divider.js +7 -5
  542. package/dist/ui-divider.js.map +1 -1
  543. package/dist/ui-dropdown.js +107 -105
  544. package/dist/ui-dropdown.js.map +1 -1
  545. package/dist/ui-embed.js +36 -35
  546. package/dist/ui-embed.js.map +1 -1
  547. package/dist/ui-emoji.js +10 -9
  548. package/dist/ui-emoji.js.map +1 -1
  549. package/dist/ui-example.js +63 -61
  550. package/dist/ui-example.js.map +1 -1
  551. package/dist/ui-feed.js +12 -10
  552. package/dist/ui-feed.js.map +1 -1
  553. package/dist/ui-flag.js +10 -9
  554. package/dist/ui-flag.js.map +1 -1
  555. package/dist/ui-flyout.js +7 -6
  556. package/dist/ui-flyout.js.map +1 -1
  557. package/dist/ui-form.js +244 -162
  558. package/dist/ui-form.js.map +1 -1
  559. package/dist/ui-grid.js +21 -18
  560. package/dist/ui-grid.js.map +1 -1
  561. package/dist/ui-icon-picker.js +46 -44
  562. package/dist/ui-icon-picker.js.map +1 -1
  563. package/dist/ui-icon.js +17 -14
  564. package/dist/ui-icon.js.map +1 -1
  565. package/dist/ui-image.js +93 -55
  566. package/dist/ui-image.js.map +1 -1
  567. package/dist/ui-include.js +18 -17
  568. package/dist/ui-include.js.map +1 -1
  569. package/dist/ui-input.js +154 -112
  570. package/dist/ui-input.js.map +1 -1
  571. package/dist/ui-item.js +152 -102
  572. package/dist/ui-item.js.map +1 -1
  573. package/dist/ui-items.js +9 -8
  574. package/dist/ui-items.js.map +1 -1
  575. package/dist/ui-json.js +115 -0
  576. package/dist/ui-json.js.map +1 -0
  577. package/dist/ui-keys.js +1 -1
  578. package/dist/ui-label.js +18 -15
  579. package/dist/ui-label.js.map +1 -1
  580. package/dist/ui-list.js +7 -5
  581. package/dist/ui-list.js.map +1 -1
  582. package/dist/ui-loader.js +7 -6
  583. package/dist/ui-loader.js.map +1 -1
  584. package/dist/ui-markdown.js +975 -83
  585. package/dist/ui-markdown.js.map +1 -1
  586. package/dist/ui-menu.js +329 -196
  587. package/dist/ui-menu.js.map +1 -1
  588. package/dist/ui-message.js +20 -18
  589. package/dist/ui-message.js.map +1 -1
  590. package/dist/ui-modal.js +46 -45
  591. package/dist/ui-modal.js.map +1 -1
  592. package/dist/ui-nag.js +19 -18
  593. package/dist/ui-nag.js.map +1 -1
  594. package/dist/ui-page.js +8 -7
  595. package/dist/ui-page.js.map +1 -1
  596. package/dist/ui-panel.js +28 -17
  597. package/dist/ui-panel.js.map +1 -1
  598. package/dist/ui-parts.js +66 -52
  599. package/dist/ui-parts.js.map +1 -1
  600. package/dist/ui-placeholder.js +21 -16
  601. package/dist/ui-placeholder.js.map +1 -1
  602. package/dist/ui-popup.js +113 -84
  603. package/dist/ui-popup.js.map +1 -1
  604. package/dist/ui-progress.js +9 -7
  605. package/dist/ui-progress.js.map +1 -1
  606. package/dist/ui-property-editor.js +706 -203
  607. package/dist/ui-property-editor.js.map +1 -1
  608. package/dist/ui-quote.js +5 -4
  609. package/dist/ui-quote.js.map +1 -1
  610. package/dist/ui-rail.js +5 -4
  611. package/dist/ui-rail.js.map +1 -1
  612. package/dist/ui-rating.js +31 -29
  613. package/dist/ui-rating.js.map +1 -1
  614. package/dist/ui-reveal.js +7 -6
  615. package/dist/ui-reveal.js.map +1 -1
  616. package/dist/ui-root.js +324 -158
  617. package/dist/ui-root.js.map +1 -1
  618. package/dist/ui-search.js +210 -168
  619. package/dist/ui-search.js.map +1 -1
  620. package/dist/ui-section.js +124 -92
  621. package/dist/ui-section.js.map +1 -1
  622. package/dist/ui-segment.js +15 -12
  623. package/dist/ui-segment.js.map +1 -1
  624. package/dist/ui-select.js +83 -81
  625. package/dist/ui-select.js.map +1 -1
  626. package/dist/ui-shape.js +86 -58
  627. package/dist/ui-shape.js.map +1 -1
  628. package/dist/ui-sidebar.js +59 -56
  629. package/dist/ui-sidebar.js.map +1 -1
  630. package/dist/ui-sides.js +325 -0
  631. package/dist/ui-sides.js.map +1 -0
  632. package/dist/ui-site-nav.js +329 -0
  633. package/dist/ui-site-nav.js.map +1 -0
  634. package/dist/ui-site-tabs.js +177 -0
  635. package/dist/ui-site-tabs.js.map +1 -0
  636. package/dist/ui-slider.js +84 -81
  637. package/dist/ui-slider.js.map +1 -1
  638. package/dist/ui-space.js +7 -6
  639. package/dist/ui-space.js.map +1 -1
  640. package/dist/ui-split-panel.js +298 -0
  641. package/dist/ui-split-panel.js.map +1 -0
  642. package/dist/ui-stack.js +47 -23
  643. package/dist/ui-stack.js.map +1 -1
  644. package/dist/ui-statistic.js +15 -13
  645. package/dist/ui-statistic.js.map +1 -1
  646. package/dist/ui-step.js +31 -29
  647. package/dist/ui-step.js.map +1 -1
  648. package/dist/ui-sticky.js +7 -6
  649. package/dist/ui-sticky.js.map +1 -1
  650. package/dist/ui-tab.js +230 -138
  651. package/dist/ui-tab.js.map +1 -1
  652. package/dist/ui-table.js +724 -162
  653. package/dist/ui-table.js.map +1 -1
  654. package/dist/ui-terms.js +12 -10
  655. package/dist/ui-terms.js.map +1 -1
  656. package/dist/ui-text.js +53 -28
  657. package/dist/ui-text.js.map +1 -1
  658. package/dist/ui-theme-editor.js +1018 -1545
  659. package/dist/ui-theme-editor.js.map +1 -1
  660. package/dist/ui-theme-menu-CuIjr8Ou.js +1493 -0
  661. package/dist/ui-theme-menu-CuIjr8Ou.js.map +1 -0
  662. package/dist/ui-toast.js +45 -44
  663. package/dist/ui-toast.js.map +1 -1
  664. package/dist/ui-toc.js +75 -74
  665. package/dist/ui-toc.js.map +1 -1
  666. package/dist/ui-toolbar.js +51 -73
  667. package/dist/ui-toolbar.js.map +1 -1
  668. package/dist/ui-transition.js +12 -11
  669. package/dist/ui-transition.js.map +1 -1
  670. package/dist/ui-tree-diagram.js +676 -197
  671. package/dist/ui-tree-diagram.js.map +1 -1
  672. package/dist/ui-tree.js +625 -0
  673. package/dist/ui-tree.js.map +1 -0
  674. package/dist/ui-video.js +13 -11
  675. package/dist/ui-video.js.map +1 -1
  676. package/dist/ui-visibility.js +26 -25
  677. package/dist/ui-visibility.js.map +1 -1
  678. package/dist/ui-zoom.js +79 -78
  679. package/dist/ui-zoom.js.map +1 -1
  680. package/dist/util/TopLayerTip.d.ts +28 -0
  681. package/dist/util/index.d.ts +5 -2
  682. package/dist/vocabulary/DefaultValues.d.ts +34 -0
  683. package/dist/vocabulary/SharedVocabulary.d.ts +4 -0
  684. package/dist/vocabulary/SharedVocabulary.es.d.ts +7 -0
  685. package/dist/vocabulary/ValueSets.d.ts +18 -0
  686. package/dist/vocabulary/Vocabulary.d.ts +1 -0
  687. package/dist/vocabulary/defaults.generated.d.ts +6 -0
  688. package/dist/vocabulary/index.d.ts +1 -0
  689. package/package.json +1 -1
  690. package/dist/MarkdownEngine-CbuT9Mjc.js.map +0 -1
  691. package/dist/PrefStore-CeaTtjTz.js.map +0 -1
  692. package/dist/UIButton-XkfGqgh6.js +0 -6
  693. package/dist/UIButton-XkfGqgh6.js.map +0 -1
  694. package/dist/UIInput-BUudZstW.js +0 -6
  695. package/dist/UIInput-BUudZstW.js.map +0 -1
  696. package/dist/UIKeys-DJF2TIKE.js.map +0 -1
  697. package/dist/UILabel-C1jy3Yl8.js +0 -6
  698. package/dist/UILabel-C1jy3Yl8.js.map +0 -1
  699. package/dist/UIMenu-Btd-8V3A.js +0 -42
  700. package/dist/UIMenu-Btd-8V3A.js.map +0 -1
  701. package/dist/UIRuntime-BBuehGly.js.map +0 -1
  702. package/dist/components.es-DmLzT-Bq.js.map +0 -1
  703. package/dist/crisp-CoZRRDuQ.js +0 -6
  704. package/dist/fruity-CQFYeRlh.js +0 -6
  705. package/dist/fruity-CQFYeRlh.js.map +0 -1
  706. package/dist/fruity.theme-BJcMiPl1.js.map +0 -1
  707. package/dist/glass-CAfW11kL.js +0 -6
  708. package/dist/glass-CAfW11kL.js.map +0 -1
  709. package/dist/glass.theme-DQcBbtCW.js +0 -6
  710. package/dist/glass.theme-DQcBbtCW.js.map +0 -1
  711. package/dist/matrix-CqA59hiF.js +0 -6
  712. package/dist/matrix.theme-jqQZjcq3.js.map +0 -1
  713. package/dist/midnight-BnoVOrhC.js +0 -6
  714. package/dist/paper-CynH8ZuT.js +0 -6
  715. package/dist/persist.types-CsZxS8TG.js +0 -9
  716. package/dist/persist.types-CsZxS8TG.js.map +0 -1
  717. package/dist/pop-D2i9V_rG.js +0 -6
  718. package/dist/spell-BFtLICm7.js +0 -6
  719. package/dist/spell.theme-B7AU7SQX.js.map +0 -1
  720. package/dist/styles.en-RLpYiO5_.js.map +0 -1
  721. package/dist/ui-theme-menu-DyKZygpV.js +0 -921
  722. package/dist/ui-theme-menu-DyKZygpV.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ui-form.js","names":["UIT.FIELD_HOST_STATE","E.byDocumentOrder","UIT.DISABLED_STATE","_init","E.untracked","E.after","__name","UIT.FormStates","_init","<Show when={this.hasRow} fallback={this.controlSlotElement()}>\n {this.labelRow()}\n <div class={CLASSES.control} part={this.partForName(\"control\")}>\n {this.controlSlotElement()}\n </div>\n </Show>","this","this.labelRow()","part={this.partForName(\"control\")}","<div class={this.rootClass} part={this.partForName(\"field\")} inert={this.disabled}>\n <Show when={this.hasRow} fallback={this.controlSlotElement()}>\n {this.labelRow()}\n <div class={CLASSES.control} part={this.partForName(\"control\")}>\n {this.controlSlotElement()}\n </div>\n </Show>\n <Show when={this.hasHint}>\n <div class={CLASSES.hint} part={this.partForName(\"hint\")}>\n <slot name={this.slotForName(\"hint\")}>{this.hint}</slot>\n </div>\n </Show>\n <Show when={this.errors.length}>\n <div class={CLASSES.error} part={this.partForName(\"error\")} role=\"alert\">\n <For each={this.errors}>{(message) => <div class={UIT.MESSAGE}>{message}</div>}</For>\n </div>\n </Show>\n </div>","<Show when={this.hasHint}>\n <div class={CLASSES.hint} part={this.partForName(\"hint\")}>\n <slot name={this.slotForName(\"hint\")}>{this.hint}</slot>\n </div>\n </Show>","part={this.partForName(\"hint\")}","name={this.slotForName(\"hint\")}","<div class={CLASSES.hint} part={this.partForName(\"hint\")}>\n <slot name={this.slotForName(\"hint\")}>{this.hint}</slot>\n </div>","<Show when={this.errors.length}>\n <div class={CLASSES.error} part={this.partForName(\"error\")} role=\"alert\">\n <For each={this.errors}>{(message) => <div class={UIT.MESSAGE}>{message}</div>}</For>\n </div>\n </Show>","<For each={this.errors}>{(message) => <div class={UIT.MESSAGE}>{message}</div>}</For>","part={this.partForName(\"error\")}","<div class={CLASSES.error} part={this.partForName(\"error\")} role=\"alert\">\n <For each={this.errors}>{(message) => <div class={UIT.MESSAGE}>{message}</div>}</For>\n </div>","part={this.partForName(\"field\")}","inert={this.disabled}","<Show when={this.hasActions}>\n <span class={CLASSES.actions} part={this.partForName(\"actions\")}>\n <slot name={this.slotForName(\"actions\")} />\n </span>\n </Show>","part={this.partForName(\"actions\")}","name={this.slotForName(\"actions\")}","<span class={CLASSES.actions} part={this.partForName(\"actions\")}>\n <slot name={this.slotForName(\"actions\")} />\n </span>","<div class={CLASSES.row} part={this.partForName(\"row\")}>\n <span class={CLASSES.label} part={this.partForName(\"label\")} onClick={this.onLabelClick}>\n <slot name={this.slotForName(\"label\")}>{this.labelText}</slot>\n </span>\n <Show when={this.hasActions}>\n <span class={CLASSES.actions} part={this.partForName(\"actions\")}>\n <slot name={this.slotForName(\"actions\")} />\n </span>\n </Show>\n <Show when={this.hasOutput}>\n <span class={CLASSES.output} part={this.partForName(\"output\")}>\n <slot name={this.slotForName(\"output\")}>{this.output}</slot>\n </span>\n </Show>\n <Show when={this.hasDescription}>\n <span\n class={CLASSES.info}\n part={this.partForName(\"info\")}\n tabindex=\"0\"\n role=\"img\"\n aria-label={this.translationForKey(\"info\", { label: this.labelText ?? \"\" })}\n aria-describedby={TIP_ID}\n >\n {this.infoGlyph.svg}\n <span id={TIP_ID} class={CLASSES.tip} part={this.partForName(\"tip\")} role=\"tooltip\">\n <slot name={this.slotForName(\"description\")}>{this.descriptionText}</slot>\n </span>\n </span>\n </Show>\n </div>","<Show when={this.hasOutput}>\n <span class={CLASSES.output} part={this.partForName(\"output\")}>\n <slot name={this.slotForName(\"output\")}>{this.output}</slot>\n </span>\n </Show>","part={this.partForName(\"output\")}","name={this.slotForName(\"output\")}","<span class={CLASSES.output} part={this.partForName(\"output\")}>\n <slot name={this.slotForName(\"output\")}>{this.output}</slot>\n </span>","<Show when={this.hasDescription}>\n <span\n class={CLASSES.info}\n part={this.partForName(\"info\")}\n tabindex=\"0\"\n role=\"img\"\n aria-label={this.translationForKey(\"info\", { label: this.labelText ?? \"\" })}\n aria-describedby={TIP_ID}\n >\n {this.infoGlyph.svg}\n <span id={TIP_ID} class={CLASSES.tip} part={this.partForName(\"tip\")} role=\"tooltip\">\n <slot name={this.slotForName(\"description\")}>{this.descriptionText}</slot>\n </span>\n </span>\n </Show>","<span\n class={CLASSES.info}\n part={this.partForName(\"info\")}\n tabindex=\"0\"\n role=\"img\"\n aria-label={this.translationForKey(\"info\", { label: this.labelText ?? \"\" })}\n aria-describedby={TIP_ID}\n >\n {this.infoGlyph.svg}\n <span id={TIP_ID} class={CLASSES.tip} part={this.partForName(\"tip\")} role=\"tooltip\">\n <slot name={this.slotForName(\"description\")}>{this.descriptionText}</slot>\n </span>\n </span>","part={this.partForName(\"info\")}","aria-label={this.translationForKey(\"info\", { label: this.labelText ?? \"\" })}","class={CLASSES.tip}","part={this.partForName(\"tip\")}","name={this.slotForName(\"description\")}","part={this.partForName(\"row\")}","class={CLASSES.label}","part={this.partForName(\"label\")}","name={this.slotForName(\"label\")}","ref={(element) => this.controlSlot = element}","<slot ref={(element) => this.controlSlot = element} onSlotChange={this.onControlChange} />","_tmpl$","_tmpl$2","_tmpl$3","_a","_init","_elementSetup_dec","_vocabulary_dec","_b","_init2","E.DOMElement","E.untracked","__name","E.UIComponent","E.proto","E.protoMerged","E.state","E.cssState","E.onChange","E.SlotContent","E.IconGlyph","_$createComponent","_$memo","_$readShallow","_$setAttribute","_$getOwner","UIT.MESSAGE","formCSS","fieldCSS","_$delegateEvents","UIT.FormStates","this","part={this.partForName(\"fields\")}","inert={this.disabled}","<div class={this.rootClass} part={this.partForName(\"fields\")} inert={this.disabled}>\n <slot />\n </div>","_tmpl$","_elementSetup_dec","_vocabulary_dec","_a","_init","E.UIComponent","E.proto","E.protoMerged","_$getOwner","_$readShallow","_$setAttribute","__name","formCSS","UIT.FormStates","UIT.StackWithValues","_nativeForm_dec","_init","detail","rules","this","part={this.partForName(\"form\")}","inert={this.disabled || this.loading}","aria-busy={this.loading ? \"true\" : void 0}","<div\n class={this.rootClass}\n part={this.partForName(\"form\")}\n inert={this.disabled || this.loading}\n aria-busy={this.loading ? \"true\" : void 0}\n >\n <slot />\n {this.debugBox()}\n </div>","<Show when={this.debug}>\n <figure class=\"debug\">\n <figcaption>{this.debugCaption}</figcaption>\n <pre part={this.partForName(\"debug\")}>{this.debugText}</pre>\n </figure>\n </Show>","<figure class=\"debug\">\n <figcaption>{this.debugCaption}</figcaption>\n <pre part={this.partForName(\"debug\")}>{this.debugText}</pre>\n </figure>","<form\n {...rest}\n class={[this.rootClass, authorClass]}\n part={this.partForName(\"form\")}\n inert={this.disabled || this.loading}\n aria-busy={this.loading ? \"true\" : void 0}\n >\n <slot />\n </form>","_tmpl$","_a","_init","_elementSetup_dec","_vocabulary_dec","E.DOMElement","E.untracked","__name","E.UIComponent","E.proto","E.protoMerged","E.state","E.cssState","E.whileConnected","E.onChange","E.on","_$getOwner","_$readShallow","_$setAttribute","_$createComponent","formCSS","<slot />","E.UIComponent","E.proto","E.protoMerged","E.state","E.whileConnected","E.onChange","_$getOwner","__name","formCSS","__publicField","__decorateElement","__decoratorMetadata","__decoratorStart","MESSAGE","__name$1","FormStates","__runInitializers","FIELD_HOST_STATE","StackWithValues","DISABLED_STATE","StackClasses","__privateAdd","getOwner$1","STATE_STATES","ValidationTriggers","FormApplyModes","ERROR","state","shown","FIELD_SELECTOR","FormFields","domElement","form","candidates","CONTROL_SELECTOR","inside","el","byDocumentOrder","byIdentifier","control","identifier","list","controls","field","values","fields","labels","text","label","live","errors","flags","spec","rules","result","FormComponent","error","validity","message","VALIDITY_FLAGS","flag","element","first","chosen","value","entry","rule","EMPTY","NOT_EMPTY","BUTTON_TYPES","name","UNNAMED_NOTED","Warnings","option","Converters","_dropHeld_dec","_saveHeld_dec","_writeBack_dec","untracked","_init$4","_FormBinding","event","apply","isCommitted","DOMElement","binding","scope","tag","timer","Reactive","createEffect","UNBOUND","MIXED","afterSolidUpdate","after","delay","targets","current","next","target","owner","key","node","changes","things","read","keys","delayed","DEFAULT_DELAY","isMixed","MIXED_TEXT","own","NUMBER_TYPES","type","number","FormBinding","fieldVocabulary","UIForm_default","UIField_default","_tmpl$$3","_tmpl$2$1","_tmpl$3$1","_tmpl$4","_tmpl$5","_tmpl$6","_tmpl$7","_tmpl$8","_mixedText_dec","_shownLabel_dec","_errors_dec","_a$3","_init$3","_onControlChange_dec","_onLabelChanged_dec","_isField_dec","_isReadOnly_dec","_isMixed_dec","_showErrors_dec","_formErrors_dec","_elementSetup_dec$3","_vocabulary_dec$3","_b$1","_init2$1","_formErrors","_DOMFieldElement","messages","DOMFieldElement","_UIField","UIComponent","proto","protoMerged","cssState","onChange","SlotContent","IconGlyph","INFO_ICON","fromForm","index","_self$","_el$","_el$3","_el$6","_el$8","insert","createComponent","Show","memo","_el$2","effect","readShallow","CLASSES","className","_p$","t","setAttribute","_el$4","_el$5","a","_el$7","For","_el$9","_v$","_$p","_self$2","_el$10","_el$11","_el$12","_el$15","_el$18","_el$22","addEvent","_el$13","_el$14","_el$16","_el$17","_el$19","_el$20","_el$21","TIP_ID","i","n","_self$3","_el$23","ref","isReady","UIField","NAMED_ATTRIBUTES","delegateEvents","fieldsVocabulary","_tmpl$$2","_elementSetup_dec$2","_vocabulary_dec$2","_a$2","_init$2","_UIFields","UIFields","formVocabulary","_tmpl$$1","_tmpl$2","_tmpl$3","_nativeForm_dec","_a$1","_init$1","_onBeforeUnload_dec","_onFocusOut_dec","_onControlChanged_dec","_onSubmit_dec","_passes_dec","_cancel_dec","_save_dec","_reset_dec","_changeCount_dec","_onBindingChanged_dec","_onNativeFormChanged_dec","_findForm_dec","_onContentChanged_dec","_watchForm_dec","_nativeForm_dec2","_isRoot_dec","_hasHeldChanges_dec","_lastCheckFailed_dec","_elementSetup_dec$1","_vocabulary_dec$1","_b","_init2","_lastCheckFailed","_hasHeldChanges","_nativeForm","_changeCount","_DOMFormElement","DOMFormElement","_UIForm","whileConnected","on","ON_SAVE","write","isServer","detail2","detail","o","authorClass","rest","attributes","spread","\"class\"","observer","noValidate","isBound","connected","mode","candidate","formRules","rules2","ownList","theirs","soon","IMMEDIATELY","ON_LEAVE","identifiers","others","UIForm","repeatVocabulary","_tmpl$","_onItemsChanged_dec","_watchTemplate_dec","_templateVersion_dec","_elementSetup_dec","_vocabulary_dec","_a","_init","_templateVersion","_UIRepeat","authored","template","copied","part","content","row","unused","same","rows","items","item","left","nodes","parent","moveBefore","before","UIRepeat"],"sources":["../src/components/ui-form/UIForm.types.ts","../src/components/ui-form/FormFields.ts","../src/components/ui-form/FormBinding.ts","../src/components/ui-form/UIField.en.ts","../src/components/ui-form/UIForm.css?inline","../src/components/ui-form/UIField.css?inline","../src/components/ui-form/UIField.tsx","../src/components/ui-form/UIFields.en.ts","../src/components/ui-form/UIFields.tsx","../src/components/ui-form/UIForm.en.ts","../src/components/ui-form/UIForm.tsx","../src/components/ui-form/UIRepeat.en.ts","../src/components/ui-form/UIRepeat.tsx","../src/components/ui-form/index.ts"],"sourcesContent":["/**\n * The `ui-form` family's loose constants and types: what its components, its vocabularies and `FormFields` share.\n * - Pure data, at the bottom of the folder's imports, so node can load it (`yarn site:data`):\n * - `import type` only, its vocabularies too: they value-import this file\n * - `UIT` by value, straight from `components.types`\n * - A word only ONE class uses sits below that class instead (epic `wwod-spell-ui`, Q18).\n */\n\nimport type { E } from \"spell/ui/core\"\nimport * as UIT from \"spell/ui/components/components.types\"\n\n////////////////\n// ## Vocabulary pieces\n////////////////\n\n/** The DOM element's states for the form states, so page CSS (`native.css`) can show messages by them. */\nexport const STATE_STATES = [\n { name: \"error\", description: \"In the error state (attribute, or failed validation).\" },\n { name: \"info\", description: \"In the info state.\" },\n { name: \"success\", description: \"In the success state.\" },\n { name: \"warning\", description: \"In the warning state.\" }\n] as const\n\n/**\n * When `<ui-form>`'s fields validate (its `validate`): as each changes, as the cursor leaves each,\n * or only on Save / submit.\n */\nexport const ValidationTriggers = [\"immediately\", \"on leave\", \"on save\"] as const\n/** One of `ValidationTriggers`, e.g. `\"on leave\"`. */\nexport type ValidationTrigger = (typeof ValidationTriggers)[number]\n\n/** When `<ui-form>`'s edits land in the thing (its `apply`): at once, or together on Save. */\nexport const FormApplyModes = [\"immediately\", \"on save\"] as const\n/** One of `FormApplyModes`. */\nexport type FormApplyMode = (typeof FormApplyModes)[number]\n\n/**\n * When a field takes an edit (`<ui-field apply>`), read from its text by `FormBinding.applyOf()`.\n * - `immediately`: each change\n * - `delayed`: after a pause in typing of `delay` ms\n * - `on leave`: when the cursor leaves the field\n */\nexport type FieldApply = { mode: \"immediately\" } | { mode: \"delayed\"; delay: number } | { mode: \"on leave\" }\n\n////////////////\n// ## Form states\n////////////////\n\n// Each of `UIT.FormStates` is also the state the DOM element of a form, field or fields carries for it\n// (`:state(error)` ...; `FormStateFlags`).\n\n/** The validation state: failed validation shows it over the author's `state`. */\nexport const ERROR = \"error\"\n\n/** The form states as `:state()`s: `<ui-form>`, `<ui-fields>` and `<ui-field>` each show one. */\nexport class FormStateFlags {\n /**\n * Every form state, only `shown` on: `{ error: true, info: false, success: false, warning: false }`.\n * - What each component's `cssStates()` hands `UIComponent`; each works out its own `shownState`.\n * - Static: pure.\n */\n static of(shown: UIT.FormState | undefined): Record<UIT.FormState, boolean> {\n return Object.fromEntries(UIT.FormStates.map((state) => [state, state === shown])) as Record<UIT.FormState, boolean>\n }\n}\n\n////////////////\n// ## Fields\n////////////////\n\n/** One named field: its controls, in document order. */\nexport type Field = {\n /** name (or id) */\n identifier: string\n /** its controls: one, or several of one name (checkboxes, radios) */\n controls: Element[]\n}\n\n/** `UIT.FormFieldRules`, normalized. */\nexport type FieldSpec = {\n /** every rule, `empty` renamed `notEmpty` */\n rules: E.ValidationRule[]\n /** skip the rules while the field is blank */\n optional: boolean\n /** skip the rules while this other field is blank */\n depends?: string\n /** the field it's for, when its key in `rules` isn't */\n identifier?: string\n}\n\n/** A control's `<ui-field>`. */\nexport const FIELD_SELECTOR = `:state(${UIT.FIELD_HOST_STATE})`\n","import { E, UIT } from \"spell/ui/core\"\nimport { F } from \"spell/ui/forms\"\nimport { FIELD_SELECTOR, type Field, type FieldSpec } from \"./UIForm.types\"\n\n/****************\n * ### `FormFields`\n * What `<ui-form>` validates, read from the DOM: its controls grouped by name (else id),\n * their values and labels, and one field's errors.\n * - Plain DOM, no Solid, so it reads light-DOM natives and `ui-*` elements alike.\n * - Controls:\n * - the native form's `elements` (which include form-associated `ui-*` elements),\n * those inside the `<ui-form>` when the form is outside it\n * - without a form, every control inside\n * - Buttons are skipped.\n * A `ui-*` element counts when it has the form-control API (`validity`), so `<ui-button>` doesn't.\n * - Values, Fomantic's `get.values()` shape:\n * - one checkbox (`ui-checkbox` / native): its value when chosen, else its `off-value` or `false`\n * - `true` for the native default, `on`, with no `value` attribute\n * - several checkboxes of one name:\n * what each submits, the chosen values and the unchosen ones' off-values\n * - a `ui-*` element's values come from the element (`chosenValue` / `unchosenValue`),\n * so its class's defaults count\n * - radios: the chosen one's value, else `null` (Fomantic's, kept: pages read it, and JSON keeps it)\n * - anything else: its `value` (`string`, or `string[]` for a multiple dropdown / select); several => a list\n * - Errors of a field, de-duplicated:\n * - its `rules` through `Validator`, with every value for `match` / `different`,\n * and every label for their prompts\n * - THEN each control's own constraint validation (`validationMessage`)\n * - Its readings of ONE control are public, as `FormBinding` reads controls the same way:\n * `nameOf()`, `isCheckable()`, `isRadio()`, `isChosen()`, `chosenValueFor()`.\n ****************/\nexport class FormFields {\n /**\n * The `<ui-form>`'s DOM element.\n * - STATIC for the object's life: a different DOM element is a different `FormFields`.\n */\n private readonly domElement: HTMLElement\n\n /** The native form, when there is one; read on every call, as the form comes and goes. */\n private readonly form: () => HTMLFormElement | undefined\n\n constructor({ domElement, form }: FormFieldsProps) {\n this.domElement = domElement\n this.form = form\n }\n\n ////////////////\n // ## Reading\n ////////////////\n\n /** Every control, in document order. */\n controls(): Element[] {\n const form = this.form()\n const candidates = form\n ? [...form.elements]\n : [...this.domElement.querySelectorAll(CONTROL_SELECTOR), ...this.customControls()]\n const inside =\n !form || !form.contains(this.domElement) ? candidates : candidates.filter((el) => this.domElement.contains(el))\n return [...new Set(inside)].filter(FormFields.isControl).sort(E.byDocumentOrder)\n }\n\n /** Fields by identifier, in document order. */\n fields(): Field[] {\n const byIdentifier = new Map<string, Element[]>()\n for (const control of this.controls()) {\n const identifier = FormFields.identifierFor(control)\n if (!identifier) continue\n const list = byIdentifier.get(identifier)\n if (list) list.push(control)\n else byIdentifier.set(identifier, [control])\n }\n return [...byIdentifier].map(([identifier, controls]) => ({ identifier, controls }))\n }\n\n /** The field named `identifier`, if any. */\n field(identifier: string): Field | undefined {\n return this.fields().find((field) => field.identifier === identifier)\n }\n\n /** Every field's value, see the class doc. */\n values(fields: readonly Field[] = this.fields()): UIT.FormValues {\n const values: UIT.FormValues = {}\n for (const { identifier, controls } of fields) values[identifier] = FormFields.valueFor(controls)\n return values\n }\n\n /**\n * Human label of a field, the first there is:\n * - its controls' `<label>`s\n * - its `<ui-field>`'s label: a `<label>` in it, else the one it draws\n * - the identifier\n */\n label({ identifier, controls }: Field): string {\n for (const control of controls) {\n const labels = (control as { labels?: NodeList | null }).labels\n const text = labels ? [...labels].map((label) => label.textContent?.trim() ?? \"\").find(Boolean) : undefined\n if (text) return text\n }\n const field = controls[0]?.closest(FIELD_SELECTOR)\n const fieldLabel =\n field?.querySelector(\":scope > label\")?.textContent?.trim() ||\n (field as { shownLabel?: string } | null)?.shownLabel\n if (fieldLabel) return fieldLabel\n const own =\n controls.length === 1 && FormFields.isCheckable(controls[0]!) ? controls[0]!.textContent?.trim() : undefined\n return own || identifier\n }\n\n /** Labels of every field, for prompts. */\n labels(fields: readonly Field[]): Record<string, string> {\n const labels: Record<string, string> = {}\n for (const field of fields) labels[field.identifier] = this.label(field)\n return labels\n }\n\n ////////////////\n // ## Validating\n ////////////////\n\n /**\n * Prompts of one field, `[]` when it passes.\n * - `rules` for it (by identifier, or a spec whose `identifier` names it), then the controls' own validity.\n * - Skipped:\n * - controls that don't validate (`willValidate` false: disabled, readonly, fieldset-disabled)\n * - fields in a disabled `<ui-field>`\n */\n errors({ field, rules, values, labels }: FieldErrorsParams): string[] {\n const live = field.controls.filter((control) => FormFields.willValidate(control))\n if (!live.length) return []\n const errors: string[] = []\n const flags = new Set<string>()\n const spec = FormFields.specFor(rules, field.identifier)\n if (spec && !(spec.depends && FormFields.isBlank(values[spec.depends]))) {\n const result = F.FormComponent.validator.validate(values[field.identifier], spec.rules, {\n name: field.identifier,\n label: labels[field.identifier],\n fieldValues: values,\n fieldLabels: labels,\n optional: spec.optional\n })\n for (const error of result.errors) {\n errors.push(error.message)\n flags.add(error.flag)\n }\n }\n for (const control of live) {\n const validity = (control as { validity?: ValidityState }).validity\n const message = (control as { validationMessage?: string }).validationMessage\n if (!validity || validity.valid || !message || errors.includes(message)) continue\n // a rule already said it (`email` rule + `type=\"email\"`): the rule's prompt wins\n if (VALIDITY_FLAGS.filter((flag) => validity[flag]).every((flag) => flags.has(flag))) continue\n errors.push(message)\n }\n return errors\n }\n\n ////////////////\n // ## Helpers\n ////////////////\n\n /** Form-associated custom elements inside the `<ui-form>`: no selector reaches them. */\n private customControls(): Element[] {\n return [...this.domElement.querySelectorAll(\"*\")].filter(\n (element) => (element.constructor as { formAssociated?: boolean }).formAssociated\n )\n }\n\n ////////////////\n // ## Pure helpers\n // STATIC, every one: it reads only its arguments, so it needs no instance.\n ////////////////\n\n /** The value of a field made of `controls`; `null` for none (Fomantic's shape, see the class doc). */\n private static valueFor(controls: readonly Element[]): E.FieldValue {\n const [first] = controls\n if (!first) return null\n if (FormFields.isRadio(first)) {\n const chosen = controls.find((control) => FormFields.isChosen(control))\n return chosen ? FormFields.chosenValueFor(chosen) : null\n }\n if (FormFields.isCheckable(first)) {\n if (controls.length === 1) {\n if (!FormFields.isChosen(first)) return FormFields.unchosenValueFor(first) ?? false\n const value = FormFields.chosenValueFor(first)\n // Fomantic's `value || true`, as our attribute reading always had it (epic `wwod-spell-ui`, J44's aside)\n return value === \"on\" && !first.hasAttribute(\"value\") ? true : value\n }\n return controls.flatMap((control) => {\n const value = FormFields.isChosen(control)\n ? FormFields.chosenValueFor(control)\n : FormFields.unchosenValueFor(control)\n return value === undefined ? [] : [value]\n })\n }\n const values = controls.map((control) => FormFields.ownValueFor(control))\n return values.length === 1 ? values[0]! : values.flat()\n }\n\n /** `rules` for `identifier`, normalized; `empty` => `notEmpty`. */\n private static specFor(rules: UIT.FormRules | undefined, identifier: string): FieldSpec | undefined {\n if (!rules) return undefined\n let entry: UIT.FormFieldRules | undefined = rules[identifier]\n if (entry === undefined) {\n entry = Object.values(rules).find(\n (value) =>\n typeof value === \"object\" && !Array.isArray(value) && \"rules\" in value && value.identifier === identifier\n )\n }\n if (entry === undefined) return undefined\n const spec: FieldSpec =\n typeof entry === \"object\" && !Array.isArray(entry) && \"rules\" in entry\n ? { rules: [...entry.rules], optional: !!entry.optional, depends: entry.depends, identifier: entry.identifier }\n : { rules: Array.isArray(entry) ? [...entry] : [entry as E.ValidationRule], optional: false }\n spec.rules = spec.rules.map(FormFields.renameEmpty)\n return spec\n }\n\n /** Fomantic's deprecated `empty` rule is `notEmpty`. */\n private static renameEmpty(rule: E.ValidationRule): E.ValidationRule {\n if (typeof rule === \"string\") return rule === EMPTY ? NOT_EMPTY : rule\n return rule.type === EMPTY ? { ...rule, type: NOT_EMPTY } : rule\n }\n\n /** Blank, as `depends` sees it. */\n private static isBlank(value: E.FieldValue): boolean {\n return value == null || value === false || value === \"\" || (Array.isArray(value) && !value.length)\n }\n\n /** A control `<ui-form>` reads: native value controls, and `ui-*` elements with the form-control API. */\n private static isControl(element: Element): boolean {\n if (element instanceof HTMLInputElement) return !BUTTON_TYPES.has(element.type)\n if (element instanceof HTMLSelectElement || element instanceof HTMLTextAreaElement) return true\n if (element instanceof HTMLButtonElement || element instanceof HTMLFieldSetElement) return false\n return \"validity\" in element && (element.constructor as { formAssociated?: boolean }).formAssociated === true\n }\n\n /**\n * Its `name`: what the form's rules, messages and value know it by.\n * - Never its `id`, which finds an element, never data (debut Q19, epic `ui-gaps` P5).\n * - SIDE EFFECT: a control with an `id` but no `name` is noted in the console, once each, rather than half-working.\n */\n private static identifierFor(control: Element): string | undefined {\n const name = FormFields.nameOf(control)\n if (!name && control.id && !UNNAMED_NOTED.has(control)) {\n UNNAMED_NOTED.add(control)\n E.Warnings.warn(\"<ui-form>\", `#${control.id} has no name, so the form skips it; give it name=\"...\"`)\n }\n return name\n }\n\n /** Its `name` (the property, else the attribute), if any: what `<ui-form value>` binds it to. */\n static nameOf(control: Element): string | undefined {\n const name = (control as { name?: unknown }).name\n return (typeof name === \"string\" && name) || control.getAttribute(\"name\") || undefined\n }\n\n /** A checkbox (native, or a `ui-*` element saying so). */\n static isCheckable(control: Element): boolean {\n if (control instanceof HTMLInputElement) return control.type === \"checkbox\" || control.type === \"radio\"\n return !!(control as { checkable?: string }).checkable\n }\n\n /** A radio (native, or a `ui-*` element saying so). */\n static isRadio(control: Element): boolean {\n if (control instanceof HTMLInputElement) return control.type === \"radio\"\n return (control as { checkable?: string }).checkable === \"radio\"\n }\n\n /** Chosen now: its `checked`, the same in every language (a `ui-*` checkbox's `selected`). */\n static isChosen(control: Element): boolean {\n return !!(control as { checked?: boolean }).checked\n }\n\n /**\n * What a chosen checkable submits: a `ui-*` element's `chosenValue`, else its `value` attribute, else `on` (native).\n */\n static chosenValueFor(control: Element): string {\n return (control as CheckableElement).chosenValue ?? control.getAttribute(\"value\") ?? \"on\"\n }\n\n /** What an unchosen checkable submits: a `ui-*` element's `unchosenValue` (`off-value`); a native: nothing. */\n private static unchosenValueFor(control: Element): string | undefined {\n return (control as CheckableElement).unchosenValue\n }\n\n /** The value of a non-checkable control. */\n private static ownValueFor(control: Element): string | string[] {\n if (control instanceof HTMLSelectElement && control.multiple) {\n return [...control.selectedOptions].map((option) => option.value)\n }\n const value = (control as { value?: unknown }).value\n if (Array.isArray(value)) return value.map(String)\n // a `multiple` element's attribute value is a list in one string (`value=\"a,b\"`)\n if (typeof value === \"string\" && control.hasAttribute(\"multiple\") && !(control instanceof HTMLInputElement)) {\n return E.Converters.list(value)\n }\n if (typeof value === \"string\") return value\n return typeof value === \"number\" || typeof value === \"boolean\" ? String(value) : \"\"\n }\n\n /** Takes part in validation? */\n private static willValidate(control: Element): boolean {\n if ((control as { willValidate?: boolean }).willValidate === false) return false\n return !control.closest(FIELD_SELECTOR)?.matches(UIT.DISABLED_STATE)\n }\n}\n\n/** What `new FormFields()` reads: the collaborators it works over. */\nexport type FormFieldsProps = {\n /** The `<ui-form>`'s DOM element. */\n domElement: HTMLElement\n /** The native form, when there is one; read on every call. */\n form: () => HTMLFormElement | undefined\n}\n\n/**\n * What a checkable `ui-*` element says it submits (`DOMCheckElement`).\n * - Structural, so this file never imports that family.\n */\ntype CheckableElement = Element & {\n /** submitted while chosen; none before its component exists */\n chosenValue?: string\n /** submitted while unchosen; none ~== nothing */\n unchosenValue?: string\n}\n\n/** What `FormFields.errors()` checks one field against. */\nexport type FieldErrorsParams = {\n /** The field to check. */\n field: Field\n /** `<ui-form>`'s `rules`, if any. */\n rules: UIT.FormRules | undefined\n /** Every field's value, for `match` / `different` / `depends`. */\n values: UIT.FormValues\n /** Every field's label, for prompts. */\n labels: Record<string, string>\n}\n\n/** Native controls. */\nconst CONTROL_SELECTOR = \"input, select, textarea\"\n\n/** Constraint Validation flags a control may raise. */\nconst VALIDITY_FLAGS: readonly (keyof ValidityStateFlags)[] = [\n \"valueMissing\",\n \"typeMismatch\",\n \"patternMismatch\",\n \"tooLong\",\n \"tooShort\",\n \"rangeUnderflow\",\n \"rangeOverflow\",\n \"stepMismatch\",\n \"badInput\",\n \"customError\"\n]\n\n/** Fomantic's old name for `notEmpty`. */\nconst EMPTY = \"empty\"\n\n/** What `EMPTY` means. */\nconst NOT_EMPTY = \"notEmpty\"\n\n/** Native input types that are buttons, not values. */\nconst BUTTON_TYPES = new Set([\"submit\", \"reset\", \"button\", \"image\"])\n\n/** The controls `identifierFor()` already noted as unnamed: each is noted once. */\nconst UNNAMED_NOTED = new WeakSet<Element>()\n","// oxlint-disable-next-line spell-ui/no-solid-effect -- a helper class, not a component: one effect per bound control, in a root of its own\nimport { createEffect } from \"solid-js\"\n\nimport { E, UIT } from \"spell/ui/core\"\nimport { FormFields } from \"./FormFields\"\nimport { FIELD_SELECTOR, type FieldApply } from \"./UIForm.types\"\n\n/****************\n * ### `FormBinding`\n * Ties a `<ui-form value>`'s named controls to an object (or to many), both ways:\n * each control shows its property of the object, and writes it back as the person changes it.\n *\n * - What a control binds to, its SCOPE: the nearest scope holder at or above it.\n * - the `<ui-form>` holds its `value`\n * - a `<ui-repeat>` row's elements hold the row's item\n * - they say so through `FormBinding.hold()`, and `scopeAround()` finds one:\n * so a nested `<ui-repeat>` reads its list from its own row's item\n * - MANY THINGS: a scope that's a list (an array) binds each control to every thing in it.\n * - a control shows the value they all agree on\n * - when they don't, it shows blank: its `<ui-field>` gets `mixed`, and the control a \"Mixed\" placeholder\n * - a write sets the property on all of them\n * - Object => control: one Solid effect per control, reading `scope[name]`.\n * - So it follows whatever Solid can: signals, Spell UI's reactive members,\n * spell's objects (their page bridges spell cells into Solid)\n * - a checkbox / toggle shows `!!value` (`selected`)\n * - a radio is chosen while `value` is its own value\n * - anything else shows `value` (`\"\"` for nullish)\n * - A dotted `name` reaches into nested things: `name=\"font.size\"` shows and writes `scope.font.size`.\n * - Control => object: a change from a bound control (`input`, `change`, `ui-changed`) writes `scope[name]`,\n * when its `<ui-field apply>` says (`applyOf()`):\n * - `immediately` (the default): a microtask later, once the control holds its new value\n * - `delayed [ms]`: after a pause in typing (300ms); a committed `change` writes at once\n * - `on leave`: when the cursor leaves the field (`onLeave()`), or the control commits (`change`)\n * - a checkbox writes its `selected`; a chosen radio, its value; anything else, its `value`\n * - numbers: a `type=\"number\"` / `\"range\"` control writes a number (`null` while blank);\n * any other control keeps a number property a number while what's typed reads as one\n * - never when equal (`===`); showing a value sends no event, so nothing loops\n * - never a value the form refuses (`canWrite`: it fails validation)\n * - HELD edits (`<ui-form apply=\"on save\">`, `isHolding`): a write is kept, not made, until `save()`.\n * `cancel()` drops them and shows the object again.\n * - Controls come and go (rows of a repeat, conditional fields): `update()` binds the new ones\n * and lets go of those gone.\n * - a `ui-*` control whose family loads later (`<ui-root>` loads them on demand) is bound once its tag is defined\n * - Plain DOM plus Solid. What it knows of the rest:\n * - `<ui-form>` and `<ui-repeat>`: only as scope holders\n * - `<ui-field>`: by its attributes\n * - controls: it reads them the way `FormFields` does\n ****************/\nexport class FormBinding {\n /**\n * The `<ui-form>`'s DOM element.\n * - STATIC for the object's life: a different DOM element is a different `FormBinding`.\n */\n private readonly domElement: HTMLElement\n\n /** The form's controls, read from the DOM. */\n private readonly fields: FormFields\n\n /** What the form says about writes: hold them, and may this control's value be written. */\n private readonly form: FormBindingProps[\"form\"]\n\n /** Bound controls, each with its binding. */\n private readonly bindings = new Map<Element, Binding>()\n\n /** Controls changed, to write back on the next microtask. */\n private readonly changed = new Set<Element>()\n\n /** `delayed` controls waiting for a pause in typing, each with its timer. */\n private readonly delayed = new Map<Element, { cancel(): void }>()\n\n constructor({ domElement, fields, form }: FormBindingProps) {\n this.domElement = domElement\n this.fields = fields\n this.form = form\n }\n\n ////////////////\n // ## Binding\n ////////////////\n\n /** Binding now: between `update()` and `stop()`. */\n private isBinding = false\n\n /** Tags inside the form not defined yet, each waited for once: a page may load a control's family later. */\n private readonly awaitedTags = new Set<string>()\n\n /**\n * Bind every named control not bound yet; let go of those no longer in the form.\n * - A `ui-*` control whose family hasn't loaded isn't a control yet: this runs again once it has.\n */\n update() {\n this.isBinding = true\n for (const element of this.domElement.querySelectorAll(E.DOMElement.notAttached)) {\n this.updateWhenAttached(element.localName)\n }\n const controls = new Set(this.fields.controls())\n for (const [control, binding] of this.bindings) {\n if (controls.has(control)) continue\n binding.dispose()\n this.bindings.delete(control)\n this.held.delete(control)\n }\n for (const control of controls) {\n if (this.bindings.has(control)) continue\n const name = FormFields.nameOf(control)\n const scope = name ? FormBinding.holderAround(control) : undefined\n if (name && scope) this.bindings.set(control, FormBinding.bind(control, name, scope))\n }\n }\n\n /** `update()` again once `tag`'s family has loaded (while still binding). */\n private updateWhenAttached(tag: string) {\n if (this.awaitedTags.has(tag)) return\n this.awaitedTags.add(tag)\n void E.DOMElement.whenAttached(tag)\n .then(() => {\n this.awaitedTags.delete(tag)\n if (this.isBinding) this.update()\n })\n .catch((error) => E.Warnings.warn(\"<ui-form value>\", `can't wait for <${tag}>:`, error))\n }\n\n /** Let go of every control, and of held edits. */\n stop() {\n this.isBinding = false\n for (const binding of this.bindings.values()) binding.dispose()\n for (const timer of this.delayed.values()) timer.cancel()\n this.bindings.clear()\n this.changed.clear()\n this.delayed.clear()\n this.waiting.clear()\n this.dropHeld()\n }\n\n /**\n * One control: an effect showing `scope()[name]` in it, in a root of its own (disposed when it goes).\n * - Many things: the value they agree on, else `MIXED`.\n * - STATIC: needs only its arguments.\n */\n private static bind(control: Element, name: string, scope: () => unknown): Binding {\n return E.Reactive.ownRoot((dispose) => {\n createEffect(\n () => FormBinding.valueIn(scope(), name),\n (value) => {\n if (value === UNBOUND) return\n FormBinding.markMixed(control, value === MIXED)\n FormBinding.show(control, value === MIXED ? undefined : value)\n }\n )\n return { name, scope, dispose }\n })\n }\n\n ////////////////\n // ## Writing back\n ////////////////\n\n /**\n * A control changed: write it back when its field's `apply` says (see the class doc).\n * - `change` is a COMMITTED change (a text field left, a choice made): it writes a `delayed` or `on leave` one too.\n */\n readonly onChange = (event: Event) => {\n if (!this.bindings.size) return\n const control = this.controlFor(event)\n if (!control) return\n const apply = FormBinding.applyOf(control)\n const isCommitted = event.type === \"change\"\n if (apply.mode === \"on leave\" && !isCommitted) return void this.waiting.add(control)\n if (apply.mode === \"delayed\" && !isCommitted) return this.writeAfterPause(control, apply.delay)\n this.delayed.get(control)?.cancel()\n this.delayed.delete(control)\n this.writeSoon(control)\n }\n\n /** The cursor left a control: write it back if its field writes `on leave` (or has a `delayed` write waiting). */\n readonly onLeave = (event: Event) => {\n if (!this.bindings.size) return\n const control = this.controlFor(event)\n if (!control) return\n const apply = FormBinding.applyOf(control)\n if (apply.mode === \"on leave\" || this.delayed.has(control)) {\n this.delayed.get(control)?.cancel()\n this.delayed.delete(control)\n this.writeSoon(control)\n }\n }\n\n /** Write `control` back on the next microtask, once it holds its new value. */\n private writeSoon(control: Element) {\n if (this.changed.has(control)) return\n this.changed.add(control)\n E.afterSolidUpdate(() => {\n if (!this.changed.delete(control)) return\n this.writeBack(control)\n })\n }\n\n /** Write `control` back once typing pauses for `delay` ms; each change starts the wait again. */\n private writeAfterPause(control: Element, delay: number) {\n this.waiting.add(control)\n this.delayed.get(control)?.cancel()\n this.delayed.set(\n control,\n E.after(delay / 1000, () => {\n this.delayed.delete(control)\n this.writeBack(control)\n })\n )\n }\n\n /** Controls changed but not written yet: a `delayed` one waiting for the pause, an `on leave` one for the leave. */\n private readonly waiting = new Set<Element>()\n\n /**\n * Write every control still waiting (`delayed`, `on leave`) now: before a save or a submit,\n * which a keyboard or a script can start without the cursor leaving the field.\n */\n flushWaiting() {\n for (const control of [...this.waiting]) {\n this.delayed.get(control)?.cancel()\n this.delayed.delete(control)\n this.writeBack(control)\n }\n }\n\n /** Write every bound control back: after a reset or a clear changed them all. */\n writeAll() {\n for (const control of this.bindings.keys()) this.writeBack(control)\n }\n\n /**\n * `scope[name] = ` what the control holds now (on every thing, for many), unless that's what it holds already.\n * - Held instead while the form holds edits.\n * - NEVER throws: a property that can't be set (a getter alone) warns.\n * - Untracked: it reads the scope and the property to write them, never to follow them.\n */\n @E.untracked\n private writeBack(control: Element) {\n this.waiting.delete(control)\n const binding = this.bindings.get(control)\n if (!binding) return\n const targets = FormBinding.targetsOf(binding.scope())\n if (!targets.length) return\n const current = FormBinding.valueIn(binding.scope(), binding.name)\n const next = FormBinding.valueFor(control, current === MIXED ? undefined : current)\n if (next === UNBOUND || !this.form.canWrite(control)) return\n if (this.form.isHolding()) return this.hold(control, binding, next)\n if (next === current) return\n FormBinding.markMixed(control, false)\n for (const target of targets) FormBinding.write(target, binding.name, next)\n this.form.onWrite?.({ control, name: binding.name, value: next, things: targets })\n }\n\n /** `target[name] = value`, unless it's that already; warns if it can't be set. */\n private static write(target: Record<PropertyKey, unknown>, name: string, value: unknown) {\n if (FormBinding.read(target, name) === value) return\n try {\n const { owner, key } = FormBinding.ownerOf(target, name)\n if (owner) owner[key] = value\n } catch (error) {\n E.Warnings.warn(\"<ui-form value>\", `can't set \\`${name}\\`:`, error)\n }\n }\n\n /** The bound control an event came from: the first at or above its `target`, inside the form. */\n private controlFor(event: Event): Element | undefined {\n for (let node = event.target as Element | null; node && node !== this.domElement; node = node.parentElement) {\n if (this.bindings.has(node)) return node\n }\n return undefined\n }\n\n ////////////////\n // ## Held edits (`apply=\"on save\"`)\n ////////////////\n\n /** Edits held until `save()`, by control: the control keeps showing its new value meanwhile. */\n private readonly held = new Map<Element, HeldEdit>()\n\n /** The controls whose edits are held. */\n get heldControls(): Element[] {\n return [...this.held.keys()]\n }\n\n /** Holds edits now. */\n get hasHeld(): boolean {\n return this.held.size > 0\n }\n\n /** The held edits, in the order they were made: one per thing a control writes to. */\n get changes(): UIT.FormChange[] {\n const changes: UIT.FormChange[] = []\n for (const { binding, value } of this.held.values()) {\n for (const target of FormBinding.targetsOf(binding.scope())) changes.push({ name: binding.name, value, target })\n }\n return changes\n }\n\n /** Hold `control`'s new value; an edit back to the object's own value is no longer held. */\n private hold(control: Element, binding: Binding, value: unknown) {\n this.held.delete(control)\n if (value !== FormBinding.valueIn(binding.scope(), binding.name)) this.held.set(control, { binding, value })\n this.form.onHeldChange()\n }\n\n /** Write every held edit, then hold none. */\n @E.untracked\n saveHeld() {\n for (const [control, { binding, value }] of this.held) {\n FormBinding.markMixed(control, false)\n const things = FormBinding.targetsOf(binding.scope())\n for (const target of things) FormBinding.write(target, binding.name, value)\n this.form.onWrite?.({ control, name: binding.name, value, things })\n }\n this.held.clear()\n this.form.onHeldChange()\n }\n\n /** Drop every held edit: each control shows the object's value again. */\n @E.untracked\n dropHeld() {\n if (!this.held.size) return\n for (const [control, { binding }] of this.held) {\n const value = FormBinding.valueIn(binding.scope(), binding.name)\n if (value === UNBOUND) continue\n FormBinding.markMixed(control, value === MIXED)\n FormBinding.show(control, value === MIXED ? undefined : value)\n }\n this.held.clear()\n this.form.onHeldChange()\n }\n\n ////////////////\n // ## Scopes\n ////////////////\n\n /**\n * Make `element` a scope holder: bound controls (and `<ui-repeat>`s) at or inside it read `read()`.\n * - `<ui-form>` holds its `value`; each top-level element of a `<ui-repeat>` row holds its item.\n */\n static hold(element: Element, read: () => unknown) {\n FormBinding.holders.set(element, read)\n }\n\n /** The scope at `element`: its nearest holder's (itself included), read now; tracked inside a computation. */\n static scopeAround(element: Element): unknown {\n return FormBinding.holderAround(element)?.()\n }\n\n /** The nearest holder's `read`, at or above `element`. */\n private static holderAround(element: Element): (() => unknown) | undefined {\n for (let node: Element | null = element; node; node = node.parentElement) {\n const read = FormBinding.holders.get(node)\n if (read) return read\n }\n return undefined\n }\n\n /**\n * Every scope holder, page-wide.\n * - A `WeakMap`: a holder that leaves the page goes with it, so there's nothing to reset.\n */\n private static readonly holders = new WeakMap<Element, () => unknown>()\n\n ////////////////\n // ## Pure helpers\n // STATIC, every one: it reads only its arguments, so it needs no instance.\n ////////////////\n\n /** Something with properties to bind to: an object (a class instance, an array ...) or a function. */\n static isObject(value: unknown): value is Record<PropertyKey, unknown> {\n return value !== null && (typeof value === \"object\" || typeof value === \"function\")\n }\n\n /** The things a scope binds to: each of a list's (objects only), else the scope itself; `[]` for none. */\n private static targetsOf(scope: unknown): Record<PropertyKey, unknown>[] {\n if (Array.isArray(scope)) return scope.filter(FormBinding.isObject)\n return FormBinding.isObject(scope) ? [scope] : []\n }\n\n /**\n * `scope[name]`: for many things, the value they agree on, else `MIXED`; `UNBOUND` for nothing to bind to.\n * - Tracked inside a computation: it reads each thing's property.\n */\n private static valueIn(scope: unknown, name: string): unknown {\n const targets = FormBinding.targetsOf(scope)\n if (!targets.length) return UNBOUND\n const first = FormBinding.read(targets[0]!, name)\n return targets.every((target) => FormBinding.read(target, name) === first) ? first : MIXED\n }\n\n /**\n * `target`'s property `name`; a dotted name reaches into nested things (`font.size`).\n * - `undefined` where the path meets nothing.\n */\n static read(target: unknown, name: string): unknown {\n let value = target\n for (const key of name.split(\".\")) {\n if (!FormBinding.isObject(value)) return undefined\n value = value[key]\n }\n return value\n }\n\n /**\n * What a dotted `name` writes to: the thing holding its last key, and that key.\n * - The thing is `undefined` where the path meets nothing.\n */\n private static ownerOf(\n target: Record<PropertyKey, unknown>,\n name: string\n ): { owner?: Record<PropertyKey, unknown>; key: string } {\n const keys = name.split(\".\")\n const key = keys.pop()!\n const owner = keys.length ? FormBinding.read(target, keys.join(\".\")) : target\n return { owner: FormBinding.isObject(owner) ? owner : undefined, key }\n }\n\n /**\n * When `control`'s field takes an edit: its `<ui-field apply>`, read from its text.\n * - `delayed` alone is 300ms; `delayed 100`, 100ms. Anything unknown is `immediately`.\n */\n static applyOf(control: Element): FieldApply {\n const text = control.closest(FIELD_SELECTOR)?.getAttribute(\"apply\")?.trim() ?? \"\"\n if (text === \"on leave\") return { mode: \"on leave\" }\n const delayed = /^delayed(?:\\s+(\\d+)(?:\\s*ms)?)?$/.exec(text)\n if (delayed) return { mode: \"delayed\", delay: delayed[1] ? Number(delayed[1]) : DEFAULT_DELAY }\n return { mode: \"immediately\" }\n }\n\n /**\n * Show \"mixed\" on `control`, or stop: its `<ui-field>`'s `mixed`, and a \"Mixed\" placeholder (its own kept).\n * - SIDE EFFECT: writes the field's `mixed` and the control's `placeholder`.\n */\n private static markMixed(control: Element, isMixed: boolean) {\n const field = control.closest(FIELD_SELECTOR) as (Element & { mixedText?: string }) | null\n if (field && field.hasAttribute(\"mixed\") !== isMixed) field.toggleAttribute(\"mixed\", isMixed)\n const wasMixed = FormBinding.ownPlaceholders.has(control)\n if (isMixed === wasMixed || FormFields.isCheckable(control)) return\n if (isMixed) {\n FormBinding.ownPlaceholders.set(control, control.getAttribute(\"placeholder\"))\n control.setAttribute(\"placeholder\", field?.mixedText ?? MIXED_TEXT)\n } else {\n const own = FormBinding.ownPlaceholders.get(control)\n FormBinding.ownPlaceholders.delete(control)\n if (own == null) control.removeAttribute(\"placeholder\")\n else control.setAttribute(\"placeholder\", own)\n }\n }\n\n /** A mixed control's own placeholder (`null`: none), to put back when it's no longer mixed. */\n private static readonly ownPlaceholders = new WeakMap<Element, string | null>()\n\n /** Show `value` in `control`, see the class doc; writes nothing that's already shown. */\n private static show(control: Element, value: unknown) {\n if (FormFields.isCheckable(control)) {\n const chosen = FormFields.isRadio(control) ? FormBinding.isRadioValue(control, value) : !!value\n if (FormFields.isChosen(control) === chosen) return\n // `checked`: a native checkbox's, and a `ui-*` one's in any language (`selected`)\n ;(control as Element & { checked: boolean }).checked = chosen\n return\n }\n const shown = Array.isArray(value) ? value : FormBinding.textOf(value)\n const element = control as Element & { value: unknown }\n if (element.value !== shown) element.value = shown\n }\n\n /** What `control` writes back, see the class doc; `UNBOUND` for nothing (a radio not chosen). */\n private static valueFor(control: Element, current: unknown): unknown {\n if (FormFields.isRadio(control)) {\n return FormFields.isChosen(control)\n ? FormBinding.keepNumber(FormFields.chosenValueFor(control), current)\n : UNBOUND\n }\n if (FormFields.isCheckable(control)) return FormFields.isChosen(control)\n const { value, type } = control as Element & { value?: unknown; type?: unknown }\n if (typeof value === \"string\" && NUMBER_TYPES.has(type as string)) return value.trim() === \"\" ? null : Number(value)\n return FormBinding.keepNumber(value, current)\n }\n\n /** A radio's own value is `value` (as text: a number property matches `value=\"2\"`). */\n private static isRadioValue(control: Element, value: unknown): boolean {\n return value != null && FormBinding.textOf(value) === FormFields.chosenValueFor(control)\n }\n\n /** `value` as a control shows it: `\"\"` for nullish, a primitive as text, anything else as JSON. */\n private static textOf(value: unknown): string {\n if (value == null) return \"\"\n if (typeof value === \"string\") return value\n if (typeof value === \"number\" || typeof value === \"boolean\" || typeof value === \"bigint\") return String(value)\n return JSON.stringify(value) ?? \"\"\n }\n\n /** `value` as a number when the property it replaces is one and it reads as one; else `value` itself. */\n private static keepNumber(value: unknown, current: unknown): unknown {\n if (typeof current !== \"number\" || typeof value !== \"string\" || value.trim() === \"\") return value\n const number = Number(value)\n return Number.isFinite(number) ? number : value\n }\n}\n\n/** What `new FormBinding()` reads: the collaborators it works over. */\nexport type FormBindingProps = {\n /** The `<ui-form>`'s DOM element. */\n domElement: HTMLElement\n /** The form's controls. */\n fields: FormFields\n /** What the form says about writes. */\n form: {\n /** Hold edits instead of writing them (`apply=\"on save\"`). */\n isHolding(): boolean\n /** May `control`'s value be written: it passes validation. */\n canWrite(control: Element): boolean\n /** The held edits changed: some, none, or others. */\n onHeldChange(): void\n /** A control's value was written to its things (after a save, for held edits). */\n onWrite?(write: { control: Element; name: string; value: unknown; things: readonly object[] }): void\n }\n}\n\n/** One bound control. */\ntype Binding = {\n /** The property it shows and writes. */\n name: string\n /** Its scope holder's `read`: the object (or list of things) it binds to. */\n scope: () => unknown\n /** Stop its effect. */\n dispose: () => void\n}\n\n/** One held edit: the control's binding, and the value it will write. */\ntype HeldEdit = { binding: Binding; value: unknown }\n\n/** \"No value to show or write\": no object to bind to, or a radio that isn't chosen. */\nconst UNBOUND = Symbol(\"unbound\")\n\n/** \"The things disagree\": the control shows blank, and mixed. */\nconst MIXED = Symbol(\"mixed\")\n\n/** A mixed control's placeholder, when its field doesn't say (`<ui-field>`'s `mixed` text). */\nconst MIXED_TEXT = \"Mixed\"\n\n/** `apply=\"delayed\"`'s pause, in ms, when it names none. */\nconst DEFAULT_DELAY = 300\n\n/** Input `type`s whose value is a number: they write a number (`null` while blank). */\nconst NUMBER_TYPES = new Set([\"number\", \"range\"])\n","/**\n * The English vocabulary of `<ui-field>`: every name the tag uses.\n * - Its tag, attributes (each with its kind and allowed values), slots, parts, states and texts.\n * The shape is `E.ComponentVocabulary` (`spell/ui/vocabulary`).\n * - Pure data: node imports it (`yarn site:data`, `yarn gen:root`), so `spell/ui/core` for types only,\n * `UIT` by value straight from `components.types`.\n * - The family's grammar notes are in `UIForm.en.ts`.\n */\n\nimport type { E } from \"spell/ui/core\"\nimport * as UIT from \"spell/ui/components/components.types\"\nimport { STATE_STATES } from \"./UIForm.types\"\n\n/****************\n * ### `fieldVocabulary`\n * The names of `<ui-field>`, one field of a form:\n * a LABEL ROW (the label, then at its far end actions, an output and an info tip), the CONTROL,\n * then a hint and the error.\n * - The label row is drawn only when there's something in it:\n * a field that slots its own `<label>` looks as it always did.\n ****************/\nexport const fieldVocabulary = {\n tag: \"ui-field\",\n topics: [\"forms\", \"inputs\", \"collections\"],\n aka: [\"form field\", \"form group\", \"form control\", \"label and input\", \"property\", \"inspector row\"],\n skeleton: \"4.5 tall\",\n noun: \"field\",\n ui: false,\n description: \"A field is a form element containing a label and an input, with a hint, a tip and its errors.\",\n attributes: [\n {\n name: \"label\",\n group: \"name\",\n kind: \"string\",\n description:\n 'The label, in the label row; `slot=\"label\"` is the rich version. Names the control for screen readers.'\n },\n {\n name: \"description\",\n group: \"content\",\n kind: \"string\",\n description:\n 'A tip behind an info icon at the end of the label row, shown on hover and focus; `slot=\"description\"` is ' +\n \"the rich version (bold words, line breaks).\"\n },\n {\n name: \"hint\",\n group: \"form\",\n kind: \"string\",\n description: 'Text under the control; `slot=\"hint\"` is the rich version.'\n },\n {\n name: \"output\",\n group: \"content\",\n kind: \"string\",\n description: 'A value shown at the end of the label row (`100%`, `+8°`); `slot=\"output\"` is the rich version.'\n },\n {\n name: \"error\",\n group: \"form\",\n kind: \"string\",\n description:\n \"An error, as a line under the control, and the `error` state. `<ui-form>`'s validation shows its own there.\"\n },\n {\n name: \"state\",\n group: \"form\",\n kind: \"valueOnly\",\n values: UIT.FormStates,\n description: \"Field state: tints its label and controls. An error shows `error` on top.\"\n },\n {\n name: \"apply\",\n group: \"form\",\n kind: \"string\",\n default: \"immediately\",\n description:\n \"When a change to the control is written to the bound value: `immediately`; `delayed`, after a pause in \" +\n \"typing (300ms; `delayed 100` for 100ms); or `on leave`, when the cursor leaves the field.\"\n },\n {\n name: \"mixed\",\n group: \"appearance\",\n kind: \"boolean\",\n description:\n \"The things being edited disagree on this value: the control shows blank, with a `Mixed` placeholder. \" +\n \"Set by the form; writing a value clears it.\"\n },\n {\n name: \"rules\",\n group: \"form\",\n kind: \"json\",\n reflect: false,\n description:\n 'Validation rules for this field\\'s control, in `<ui-form rules>`\\'s shape (`\"email\"`, `[\"notEmpty\", ' +\n '\"minLength[6]\"]`); added to the form\\'s own rules for it.'\n },\n { name: \"inline\", group: \"layout\", kind: \"keyOnly\", description: \"Label beside the control, not above it.\" },\n {\n name: \"required\",\n group: \"form\",\n kind: \"keyOnly\",\n description: \"Marks the label with an asterisk (validation is `rules` / `required`).\"\n },\n {\n name: \"readonly\",\n group: \"form\",\n kind: \"boolean\",\n description:\n \"Shows the value; it can't be changed. Nests like `disabled`: set on a group, it reaches each field.\"\n },\n { name: \"disabled\", group: \"states\", kind: \"keyOnly\", description: \"Dimmed and not usable (`inert`).\" },\n {\n name: \"width\",\n group: \"layout\",\n kind: \"width\",\n description: \"Width in a row of fields: columns (`4` of 16), fractions (`1/4`) or percentages (`25%`).\"\n }\n ],\n events: [],\n slots: [\n {\n name: \"\",\n description: \"The control(s): `<ui-input>`, `<ui-dropdown>`, native inputs ...; or a `<label for>`, then them.\"\n },\n { name: \"label\", description: \"Rich label (instead of `label`).\" },\n { name: \"description\", description: \"Rich tip (instead of `description`): bold words, line breaks.\" },\n { name: \"hint\", description: \"Rich hint (instead of `hint`).\" },\n { name: \"output\", description: \"Rich output (instead of `output`).\" },\n {\n name: \"actions\",\n description: \"Small buttons at the end of the label row (`Reset`, `Auto`); a taller one never grows the row.\"\n }\n ],\n parts: [\n { name: \"field\", description: \"The field box.\" },\n { name: \"row\", description: \"The label row.\" },\n { name: \"label\", description: \"The label.\" },\n { name: \"actions\", description: \"The actions, at the end of the label row.\" },\n { name: \"output\", description: \"The output.\" },\n { name: \"info\", description: \"The info icon.\" },\n { name: \"tip\", description: \"The tip, shown from the info icon.\" },\n {\n name: \"control\",\n description: \"Around the control(s) under a label row; no box of its own (`display: contents`).\"\n },\n { name: \"hint\", description: \"The hint.\" },\n { name: \"error\", description: \"The error lines.\" }\n ],\n states: [\n { name: \"field\", description: \"Always: how `<ui-form>` finds a control's field (`closest(':state(field)')`).\" },\n ...STATE_STATES,\n { name: \"mixed\", description: \"The things being edited disagree on this value (`mixed`).\" },\n { name: \"readonly\", description: \"Can't be changed (`readonly`, its own or a group's).\" },\n { name: \"disabled\", description: \"Can't be used.\" }\n ],\n texts: [\n { key: \"info\", text: \"More about {label}\", description: \"The info icon's name; `{label}` is the label.\" },\n { key: \"mixed\", text: \"Mixed\", description: \"The placeholder of a control whose things disagree.\" },\n {\n key: \"none\",\n text: \"none\",\n description: \"What a property's select shows, in italics, when it has no value and no default.\"\n }\n ]\n} as const satisfies E.ComponentVocabulary\n","/*\n * The style sheet of `<ui-form>`, `<ui-field>` and `<ui-fields>`: a port of Fomantic's `form.less` + `form.variables`.\n * - ONE sheet for the three elements; each adopts it after the foundation.\n * `<ui-field>` also adopts `UIField.css` AFTER it, for its own parts (label row, tip, hint, errors).\n * `<ui-repeat>` adopts it too, for its `display: contents` host alone (its shadow is a bare `<slot>`).\n * - Shadow markup contract (class grammar; a form's box has no better element than `<div>`):\n * - `<ui-form>`: `<div class=\"ui [size state] [equal width inverted loading disabled unstackable] form\"\n * part=\"form\" [inert]><slot></slot>[<figure class=\"debug\"><figcaption>…</figcaption><pre part=\"debug\">…</pre></figure>]</div>` -- the NATIVE `<form>` is light DOM, slotted inside it (or around\n * the `<ui-form>`): a form-associated control belongs to the nearest `<form>` ancestor in its own tree,\n * so a `<form>` in this shadow root would own nothing (see `UIForm`, `notes/grammar.md`)\n * - `<ui-field>`: `<div class=\"[state] [inline required disabled] [N wide] field\" part=\"field\" [inert]>\n * [<div class=\"row\" part=\"row\">…</div>]<div class=\"control\" part=\"control\"><slot></slot></div>\n * [<div class=\"hint\" part=\"hint\">…</div>][<div class=\"error prompt\" part=\"error\" role=\"alert\">…</div>]</div>`\n * -- the label row only when it has something, the errors only while there are any (`UIField.css`)\n * - `<ui-fields>`: `<div class=\"[state] [inline grouped unstackable required disabled] [two | equal width]\n * fields\" part=\"fields\" [inert]><slot></slot></div>`\n * - DOM elements are `display: contents`, so each ROOT is the box:\n * a field's root is the flex item of its row, as in Fomantic's markup.\n * Spacing that Fomantic decides with `:last-child` is decided again by the DOM element's position\n * (`:host(:last-child)`); static markup keeps Fomantic's selectors.\n * - Selectors are bare `.field` / `.fields`: inside a shadow root nothing else carries them,\n * and static (class-grammar) markup is Fomantic's own.\n * - Public tokens (`--ui-form-*`, the theming surface) are NEVER declared here: the form's token block reads each\n * through a private alias, `--_ui-form-gutter: var(--ui-form-gutter, 1em)`, and every rule reads the alias.\n * So a value set on `:root`, an ancestor, the DOM element, `::part(form)` or in the app stylesheet reaches the box\n * (`notes/theming.md` \"Component tokens\").\n * - a field's / fields' root is OUTSIDE the form's box (its own shadow root), so it reads a form token as\n * `var(--_ui-form-x, var(--ui-form-x, <default>))`: the form's alias inside a form, else the public one\n * - Tokens handed DOWN (private, inherited; never set them from outside, theme with `--ui-form-*`):\n *\n * | Token | Set by | Read by |\n * | ------------------------------ | ----------------- | ------------------------------------------------ |\n * | `--_ui-fields-child-width` | fields (`widths`) | field: its width, unless its own `N wide` |\n * | `--_ui-fields-child-flex` | equal width | field: its `flex` |\n * | `--_ui-fields-pad-start` / `-end` | fields | field: the gutter |\n * | `--_ui-fields-field-margin` | fields, grouped | field: its margin (`0 0 1em` alone) |\n * | `--_ui-fields-inline` | inline fields | field: inline label (style query) |\n * | `--_ui-fields-required` | required fields | field: asterisk on its label (style query) |\n * | `--_ui-fields-stacked` | narrow form | field: full width (style query) |\n * | `--_ui-form-label-color` | form (`inverted`) | field / fields: label colour (the alias of `--ui-form-label-color`) |\n * | `--_ui-form-equal-width` / `--_ui-form-unstackable` | form | fields (style query) |\n * | `--_ui-input-owner-width` | field | `UIInput.css`: the control fills the field |\n * | `--_ui-field-state-color` / `-background` / `-border` | field / fields state | `UIInput.css`, `UICheckbox.css`, `native.css` |\n *\n * - a field's / fields' `<slot>` resets the colour remap (`--ui-color*`) and the fields tokens, so a field state\n * reaches controls ONLY as the resolved `--_ui-field-state-*` tokens and rows don't leak into nested rows\n * - Responsive: the form ROOT is the `ui-form` size container; rows stack below 768px of FORM width\n * (`unstackable` form / fields opt out).\n * - Messages: a form / field / fields shows the `<ui-message state=\"…\">`s of its state and hides the others --\n * light-DOM rules in `native.css` keyed on the DOM elements' `:state(error)` ... (a message's box is in ITS shadow).\n * - NOTE: left out, on purpose:\n * - styles for native controls inside fields -- `native.css` has them (light DOM)\n * - Fomantic's dropdown / checkbox rules inside stated fields: controls read `--ui-field-state-*`;\n * a `<ui-dropdown>` keeps its own look (give it `state` too)\n * - `.ui.form .fields .wide.field` inline wide inputs, `transparent` form inputs, `select` styling:\n * `<ui-input fluid>` / `native.css`\n * - checkbox top margins in rows of fields: rows centre their fields (`align-items`) instead\n * - the `:has()` label colouring of a `fields` group whose child has a state\n */\n\n@layer ui.components.form.types, ui.components.form.content, ui.components.form.variations, ui.components.form.states;\n\n/* Breakpoints (`@custom-media`), inlined at build time: `stack-with=\"page\"`. */\n@import \"../../styles/media.css\";\n\n/* Loader spin, shared by `loading` forms. */\n@keyframes ui-form-spin {\n to {\n rotate: 1turn;\n }\n}\n\n/*******************************\n Form\n*******************************/\n\n@layer ui.components.form.types {\n /* DOM elements: no box of their own; each root is the box (the form's block, a row's flex items). */\n /*\n * DOM element: a real block box and a size container,\n * so a slotted `<ui-fields>` finds the form's width in every engine.\n * - WebKit looks for a container through shadow-including ANCESTORS (not the flat tree through the slot),\n * and keeps container names to their own shadow tree, so the `.ui.form` root inside this shadow is invisible\n * to the fields' shadow roots there; the DOM element is an ancestor of the fields in the light tree.\n * - Chromium finds `.ui.form` first: the same width.\n */\n :host {\n display: contents;\n }\n /* (`:state(root)`: only the form's DOM element; `<ui-fields>` / `<ui-field>` adopt this sheet too) */\n :host(:state(root)) {\n display: block;\n container-type: inline-size;\n }\n\n /*\n * Tokens: one per `form.variables` entry that still matters, from the global tokens -- each the private alias\n * of its public token (never declare the public one: it would block inherited values).\n */\n .ui.form {\n --_ui-form-gutter: var(--ui-form-gutter, 1em);\n --_ui-form-row-distance: var(--ui-form-row-distance, 1em);\n --_ui-form-label-distance: var(--ui-form-label-distance, 0.28571em);\n --_ui-form-label-font-size: var(--ui-form-label-font-size, 0.92857em);\n --_ui-form-label-font-weight: var(--ui-form-label-font-weight, var(--ui-font-weight-bold));\n --_ui-form-required-color: var(--ui-form-required-color, var(--ui-negative-text));\n --_ui-form-disabled-opacity: var(--ui-form-disabled-opacity, var(--ui-disabled-opacity));\n --_ui-form-loader-size: var(--ui-form-loader-size, 3em);\n --_ui-form-loader-width: var(--ui-form-loader-width, 0.2em);\n --_ui-form-loader-fill: var(--ui-form-loader-fill, oklch(from var(--ui-ink) l c h / 0.1));\n --_ui-form-loader-line: var(--ui-form-loader-line, var(--ui-text-muted));\n --_ui-form-loader-speed: var(--ui-form-loader-speed, 0.6s);\n --_ui-form-loader-dimmer: var(--ui-form-loader-dimmer, color-mix(in oklab, var(--ui-surface) 80%, transparent));\n --_ui-form-inverted-label-color: var(--ui-form-inverted-label-color, var(--ui-text-inverted-color));\n /* ## Owner tokens: declared on every root, so a nested form never inherits an outer one's. */\n --_ui-form-label-color: var(--ui-form-label-color, var(--ui-text-color));\n --_ui-form-equal-width: 0;\n --_ui-form-unstackable: 0;\n /* `stack-with`: the element's class (below), else the page-wide token, else `container` */\n --_ui-form-stack-with: var(--ui-stack-with, container);\n\n position: relative;\n box-sizing: border-box;\n max-width: 100%;\n container: ui-form / inline-size;\n color: var(--ui-text-color);\n font-family: var(--ui-font-family);\n font-size: calc(var(--ui-font-size) * var(--ui-scale, 1));\n line-height: var(--ui-line-height);\n }\n .ui.form ::slotted(form) {\n display: block;\n margin: 0;\n }\n\n /* Field */\n .field {\n --_ui-input-owner-width: 100%;\n box-sizing: border-box;\n width: var(--_field-width, var(--_ui-fields-child-width, auto));\n flex: var(--_ui-fields-child-flex, 0 1 auto);\n min-width: 0;\n clear: both;\n margin: var(--_ui-fields-field-margin, 0 0 var(--_ui-form-row-distance, var(--ui-form-row-distance, 1em)));\n padding-inline: var(--_ui-fields-pad-start, 0) var(--_ui-fields-pad-end, 0);\n }\n :host(:last-child) > .field,\n .ui.form .field:last-child {\n margin-block-end: 0;\n }\n .field > slot,\n .field > .control > slot {\n /* A row inside a field starts clean. */\n --_ui-fields-child-width: initial;\n --_ui-fields-child-flex: initial;\n --_ui-fields-pad-start: initial;\n --_ui-fields-pad-end: initial;\n --_ui-fields-field-margin: initial;\n --_ui-fields-inline: initial;\n --_ui-fields-required: initial;\n --_ui-fields-stacked: initial;\n }\n .field > slot,\n .field > .control > slot,\n .fields > slot {\n /* Only the RESOLVED state tokens reach the controls, never the colour remap. */\n --ui-color: initial;\n --ui-color-text: initial;\n --ui-color-header: initial;\n --ui-color-border: initial;\n --ui-color-background: initial;\n --ui-color-inverted: initial;\n --ui-color-on: initial;\n --ui-color-inverted-on: initial;\n --ui-color-hover: initial;\n --ui-color-focus: initial;\n --ui-color-down: initial;\n --ui-color-active: initial;\n }\n\n /* Fields: a row; its children share it. */\n .fields {\n --_ui-fields-child-width: auto;\n --_ui-fields-child-flex: 0 1 auto;\n --_ui-fields-pad-start: calc(var(--_ui-form-gutter, var(--ui-form-gutter, 1em)) / 2);\n --_ui-fields-pad-end: calc(var(--_ui-form-gutter, var(--ui-form-gutter, 1em)) / 2);\n --_ui-fields-field-margin: 0;\n --_ui-fields-inline: 0;\n --_ui-fields-required: 0;\n --_ui-fields-stacked: 0;\n box-sizing: border-box;\n display: flex;\n flex-direction: row;\n margin: 0 calc(var(--_ui-form-gutter, var(--ui-form-gutter, 1em)) / -2)\n var(--_ui-form-row-distance, var(--ui-form-row-distance, 1em));\n }\n :host(:last-child) > .fields,\n .ui.form .fields:last-child {\n margin-block-end: 0;\n }\n}\n\n/*******************************\n Content\n*******************************/\n\n@layer ui.components.form.content {\n /* Labels: above the control, bold and small. */\n .field ::slotted(label),\n .fields ::slotted(label),\n .ui.form :is(.field, .fields) > label {\n display: block;\n margin: 0 0 var(--_ui-form-label-distance, var(--ui-form-label-distance, 0.28571em));\n color: var(--_field-label-color, var(--_ui-form-label-color, var(--ui-form-label-color, var(--ui-text-color))));\n font-size: var(--_ui-form-label-font-size, var(--ui-form-label-font-size, 0.92857em));\n font-weight: var(--_ui-form-label-font-weight, var(--ui-form-label-font-weight, var(--ui-font-weight-bold)));\n text-transform: none;\n }\n /* `debug` (ours, not Fomantic's): the bound object as JSON, below the content, in a captioned box,\n so it reads as the form's output, not as page text. */\n .ui.form > .debug {\n margin: 1em 0 0;\n padding: 0.5em 0.75em;\n border: var(--ui-border);\n border-radius: var(--ui-radius);\n background-color: var(--ui-surface-strong);\n }\n .ui.form > .debug > figcaption {\n margin: 0 0 0.25em;\n color: var(--ui-text-muted);\n font-size: 0.85714em;\n font-weight: var(--ui-font-weight-bold);\n }\n .ui.form > .debug > pre {\n margin: 0;\n font-family: var(--ui-font-family-mono);\n font-size: 0.85714em;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n }\n /* Static markup: a `.ui.input` fills its field (elements get `--_ui-input-owner-width`). */\n .ui.form .field .ui.input {\n width: 100%;\n }\n .ui.form .inline:is(.field, .fields) .ui.input {\n width: auto;\n }\n .field ::slotted(p),\n .ui.form .field > p {\n margin: 1em 0;\n }\n\n /* Static markup: a message of a state shows only inside a form / fields / field in that state (elements:\n `native.css`, keyed on the DOM elements' states). */\n .ui.form .message:is(.error, .info, .success, .warning) {\n display: none;\n }\n .ui.error.form .error.message,\n .ui.form .error:is(.field, .fields) .error.message,\n .ui.info.form .info.message,\n .ui.form .info:is(.field, .fields) .info.message,\n .ui.success.form .success.message,\n .ui.form .success:is(.field, .fields) .success.message,\n .ui.warning.form .warning.message,\n .ui.form .warning:is(.field, .fields) .warning.message {\n display: block;\n }\n}\n\n/*******************************\n Variations\n*******************************/\n\n@layer ui.components.form.variations {\n /* Widths: N of 16 in a row. */\n .one.wide.field {\n --_field-width: 6.25%;\n }\n .two.wide.field {\n --_field-width: 12.5%;\n }\n .three.wide.field {\n --_field-width: 18.75%;\n }\n .four.wide.field {\n --_field-width: 25%;\n }\n .five.wide.field {\n --_field-width: 31.25%;\n }\n .six.wide.field {\n --_field-width: 37.5%;\n }\n .seven.wide.field {\n --_field-width: 43.75%;\n }\n .eight.wide.field {\n --_field-width: 50%;\n }\n .nine.wide.field {\n --_field-width: 56.25%;\n }\n .ten.wide.field {\n --_field-width: 62.5%;\n }\n .eleven.wide.field {\n --_field-width: 68.75%;\n }\n .twelve.wide.field {\n --_field-width: 75%;\n }\n .thirteen.wide.field {\n --_field-width: 81.25%;\n }\n .fourteen.wide.field {\n --_field-width: 87.5%;\n }\n .fifteen.wide.field {\n --_field-width: 93.75%;\n }\n .sixteen.wide.field {\n --_field-width: 100%;\n }\n\n /* Rows of N equal fields. */\n .two.fields {\n --_ui-fields-child-width: 50%;\n }\n .three.fields {\n --_ui-fields-child-width: 33.33333%;\n }\n .four.fields {\n --_ui-fields-child-width: 25%;\n }\n .five.fields {\n --_ui-fields-child-width: 20%;\n }\n .six.fields {\n --_ui-fields-child-width: 16.66666%;\n }\n .seven.fields {\n --_ui-fields-child-width: 14.28571%;\n }\n .eight.fields {\n --_ui-fields-child-width: 12.5%;\n }\n .nine.fields {\n --_ui-fields-child-width: 11.11111%;\n }\n .ten.fields {\n --_ui-fields-child-width: 10%;\n }\n .fields[class*=\"equal width\"] {\n --_ui-fields-child-width: 100%;\n --_ui-fields-child-flex: 1 1 auto;\n }\n .ui[class*=\"equal width\"].form {\n --_ui-form-equal-width: 1;\n }\n @container style(--_ui-form-equal-width: 1) {\n .fields {\n --_ui-fields-child-width: 100%;\n --_ui-fields-child-flex: 1 1 auto;\n }\n }\n\n /* Grouped: stacked fields under one label. */\n .grouped.fields {\n --_ui-fields-pad-start: 0;\n --_ui-fields-pad-end: 0;\n --_ui-fields-field-margin: 0.5em 0;\n display: block;\n margin: 0 0 var(--_ui-form-row-distance, var(--ui-form-row-distance, 1em));\n }\n\n /* Inline: labels beside controls. */\n .inline.fields {\n --_ui-fields-pad-start: 0;\n --_ui-fields-pad-end: 1em;\n --_ui-fields-inline: 1;\n --_ui-input-owner-width: auto;\n align-items: center;\n margin: 0 0 var(--_ui-form-row-distance, var(--ui-form-row-distance, 1em));\n }\n .inline.fields ::slotted(label),\n .ui.form .inline.fields > label {\n display: inline-block;\n margin: 0.03571em 1em 0 0;\n }\n .inline.field {\n --_ui-input-owner-width: auto;\n }\n .inline.field ::slotted(label),\n .ui.form .inline:is(.field, .fields) .field > label,\n .ui.form .inline.field > label {\n display: inline-block;\n width: auto;\n margin: 0 0.85714em 0 0;\n vertical-align: baseline;\n }\n @container style(--_ui-fields-inline: 1) {\n .field {\n --_ui-input-owner-width: auto;\n }\n .field ::slotted(label) {\n display: inline-block;\n margin: 0 0.85714em 0 0;\n vertical-align: baseline;\n }\n }\n /* Required: an asterisk after the label. */\n .required.field ::slotted(label)::after,\n .required:is(.grouped, .inline).fields ::slotted(label)::after,\n .ui.form .required.field > label::after,\n .ui.form .required:is(.grouped, .inline).fields > label::after,\n .ui.form .required.fields:not(.grouped, .inline) > .field > label::after {\n content: \"*\";\n display: inline-block;\n margin: -0.2em 0 0 0.2em;\n color: var(--_ui-form-required-color, var(--ui-form-required-color, var(--ui-negative-text)));\n vertical-align: top;\n }\n .required.fields:not(.grouped, .inline) {\n --_ui-fields-required: 1;\n }\n @container style(--_ui-fields-required: 1) {\n .field ::slotted(label)::after {\n content: \"*\";\n display: inline-block;\n margin: -0.2em 0 0 0.2em;\n color: var(--_ui-form-required-color, var(--ui-form-required-color, var(--ui-negative-text)));\n vertical-align: top;\n }\n }\n\n /* Inverted: light labels. */\n .ui.inverted.form {\n --_ui-form-label-color: var(--_ui-form-inverted-label-color);\n color: var(--_ui-form-inverted-label-color);\n }\n\n /* Unstackable */\n .ui.unstackable.form {\n --_ui-form-unstackable: 1;\n }\n\n /* Stack with: the form's own width (the default) or the screen's, read by its rows. */\n .ui.stack-with-page.form {\n --_ui-form-stack-with: page;\n }\n .ui.stack-with-container.form {\n --_ui-form-stack-with: container;\n }\n\n /*\n * Narrow forms stack their rows: below 768px of the FORM (`stack-with=\"container\"`, the default; UNNAMED:\n * WebKit can't see a container name from another shadow tree) ...\n */\n @container (width < 768px) {\n @container style(not (--_ui-form-unstackable: 1)) and style(not (--_ui-form-stack-with: page)) {\n .fields:not(.unstackable) {\n --_ui-fields-child-width: 100%;\n --_ui-fields-stacked: 1;\n --_ui-fields-field-margin: 0 0 var(--_ui-form-row-distance, var(--ui-form-row-distance, 1em));\n flex-wrap: wrap;\n margin-block-end: 0;\n }\n }\n }\n /* ... or of the screen (`stack-with=\"page\"`). */\n @media (--ui-mobile) {\n @container style(not (--_ui-form-unstackable: 1)) and style(--_ui-form-stack-with: page) {\n .fields:not(.unstackable) {\n --_ui-fields-child-width: 100%;\n --_ui-fields-stacked: 1;\n --_ui-fields-field-margin: 0 0 var(--_ui-form-row-distance, var(--ui-form-row-distance, 1em));\n flex-wrap: wrap;\n margin-block-end: 0;\n }\n }\n }\n @container style(--_ui-fields-stacked: 1) {\n .field {\n width: 100%;\n }\n }\n}\n\n/*******************************\n States\n*******************************/\n\n@layer ui.components.form.states {\n /*\n * Field states: resolved colours for the controls, tinted labels. Per state, not a `--ui-color` read:\n * fields have no `ui` class, so `colors.css`'s `.ui.error` remap never runs on them (as Fomantic's `.field.error`).\n */\n :is(.field, .fields).error {\n --_ui-field-state-color: var(--ui-error-text);\n --_ui-field-state-background: var(--ui-error-background);\n --_ui-field-state-border: var(--ui-error-border);\n }\n :is(.field, .fields).info {\n --_ui-field-state-color: var(--ui-info-text);\n --_ui-field-state-background: var(--ui-info-background);\n --_ui-field-state-border: var(--ui-info-border);\n }\n :is(.field, .fields).success {\n --_ui-field-state-color: var(--ui-success-text);\n --_ui-field-state-background: var(--ui-success-background);\n --_ui-field-state-border: var(--ui-success-border);\n }\n :is(.field, .fields).warning {\n --_ui-field-state-color: var(--ui-warning-text);\n --_ui-field-state-background: var(--ui-warning-background);\n --_ui-field-state-border: var(--ui-warning-border);\n }\n :is(.field, .fields):is(.error, .info, .success, .warning) {\n --_field-label-color: var(--_ui-field-state-color);\n }\n\n /* Disabled: dimmed, inert (the element sets `inert`). */\n :is(.field, .fields).disabled,\n .ui.disabled.form {\n opacity: var(--_ui-form-disabled-opacity, var(--ui-form-disabled-opacity, var(--ui-disabled-opacity)));\n pointer-events: none;\n }\n\n /* Loading: dimmed behind a spinner. */\n .ui.loading.form {\n cursor: default;\n pointer-events: none;\n }\n .ui.loading.form::before {\n content: \"\";\n position: absolute;\n inset: 0;\n z-index: 100;\n background: var(--_ui-form-loader-dimmer);\n }\n .ui.loading.form::after {\n content: \"\";\n position: absolute;\n top: 50%;\n left: 50%;\n z-index: 101;\n box-sizing: border-box;\n width: var(--_ui-form-loader-size);\n height: var(--_ui-form-loader-size);\n margin: calc(var(--_ui-form-loader-size) / -2) 0 0 calc(var(--_ui-form-loader-size) / -2);\n border: var(--_ui-form-loader-width) solid var(--_ui-form-loader-fill);\n border-top-color: var(--_ui-form-loader-line);\n border-radius: var(--ui-radius-circle);\n animation: ui-form-spin var(--_ui-form-loader-speed) linear infinite;\n }\n\n @media (prefers-reduced-motion: reduce) {\n .ui.loading.form::after {\n animation-duration: calc(var(--_ui-form-loader-speed) * 4);\n }\n }\n}\n","/*\n * The style sheet of `<ui-field>`'s own parts, adopted AFTER the family's (`UIForm.css`, which lays the field out).\n * - Markup: `div.field` > `.row` (`.label`, `.actions`, `.output`, `.info` > `.tip`), `.control` (the default slot),\n * `.hint`, `.error.prompt`.\n * - The label row is drawn only when it has something in it; its label reads the form's label tokens, so it\n * looks like a slotted `<label>`.\n * Actions, the output (mono, muted) and the info icon (faded, its tip a dark bubble under it) sit at its end.\n * Actions never grow the row: a taller pill overhangs it.\n * - `.control` has no box (`display: contents`): the controls lay out as they did before the row existed.\n * - Errors are plain lines under the control, in the error colour.\n * - Public tokens (`--ui-field-*`) are never declared here: read through private aliases.\n */\n\n@layer ui.components.field.types, ui.components.field.content, ui.components.field.states;\n\n@layer ui.components.field.types {\n .field {\n --_ui-field-row-gap: var(--ui-field-row-gap, 0.5em);\n --_ui-field-output-color: var(--ui-field-output-color, var(--ui-text-muted));\n --_ui-field-hint-color: var(--ui-field-hint-color, var(--ui-text-muted));\n --_ui-field-error-color: var(--ui-field-error-color, var(--ui-negative-text));\n --_ui-field-tip-background: var(--ui-field-tip-background, var(--ui-text-dark));\n --_ui-field-tip-color: var(--ui-field-tip-color, var(--ui-surface));\n --_ui-field-tip-width: var(--ui-field-tip-width, 16.25em);\n /* how long a hover waits before the tip shows; keyboard focus shows it at once */\n --_ui-field-tip-delay: var(--ui-field-tip-delay, var(--ui-hover-delay, 0s));\n }\n .field > .control {\n display: contents;\n }\n}\n\n@layer ui.components.field.content {\n /* ## The label row: above the control, the form's label look */\n .field > .row {\n display: flex;\n align-items: center;\n gap: var(--_ui-field-row-gap);\n margin: 0 0 var(--_ui-form-label-distance, var(--ui-form-label-distance, 0.28571em));\n color: var(--_field-label-color, var(--_ui-form-label-color, var(--ui-form-label-color, var(--ui-text-color))));\n font-size: var(--_ui-form-label-font-size, var(--ui-form-label-font-size, 0.92857em));\n font-weight: var(--_ui-form-label-font-weight, var(--ui-form-label-font-weight, var(--ui-font-weight-bold)));\n line-height: 1.2;\n }\n .field > .row > .label {\n flex: 0 1 auto;\n min-width: 0;\n margin-inline-end: auto;\n }\n .required.field > .row > .label::after {\n content: \"*\";\n display: inline-block;\n margin: -0.2em 0 0 0.2em;\n color: var(--_ui-form-required-color, var(--ui-form-required-color, var(--ui-negative-text)));\n vertical-align: top;\n }\n /* Actions keep the row's height: a taller pill (a mini `<ui-button>`) overhangs it evenly, so the row never grows\n when one appears (a Reset shown once the value changes), and the control under it never moves */\n .field > .row > .actions {\n display: inline-flex;\n align-items: center;\n gap: 0.25em;\n height: 1.2em;\n }\n .field > .row > .output {\n color: var(--_ui-field-output-color);\n font-family: var(--ui-font-family-mono);\n font-size: 0.92em;\n font-weight: var(--ui-font-weight-normal);\n font-variant-numeric: tabular-nums;\n }\n\n /* ## The info icon and its tip */\n .field > .row > .info {\n position: relative;\n display: inline-flex;\n width: 1em;\n height: 1em;\n opacity: 0.4;\n cursor: help;\n border-radius: var(--ui-radius-circle, 50%);\n }\n .field > .row > .info:is(:hover, :focus-visible) {\n opacity: 1;\n }\n .field > .row > .info:focus-visible {\n outline: var(--ui-focus-width) solid var(--ui-focus-color);\n outline-offset: 2px;\n }\n .field > .row > .info > svg {\n width: 100%;\n height: 100%;\n fill: currentColor;\n }\n .field > .row > .info > .tip {\n position: absolute;\n inset-block-start: calc(100% + 0.5em);\n inset-inline-end: -0.5em;\n z-index: var(--ui-z-popup, 30);\n box-sizing: border-box;\n width: var(--_ui-field-tip-width);\n padding: 0.625em 0.75em;\n border-radius: var(--ui-radius-s, 8px);\n background: var(--_ui-field-tip-background);\n box-shadow: var(--ui-shadow-floating);\n color: var(--_ui-field-tip-color);\n font-size: 0.92em;\n font-weight: var(--ui-font-weight-normal);\n line-height: 1.45;\n opacity: 0;\n visibility: hidden;\n pointer-events: none;\n transition:\n opacity var(--ui-duration-fast) var(--ui-ease),\n visibility var(--ui-duration-fast);\n }\n /* shown: no longer faded with the icon */\n .field > .row > .info:is(:hover, :focus-visible) > .tip {\n opacity: 1;\n visibility: visible;\n }\n .field > .row > .info:hover > .tip {\n transition-delay: var(--_ui-field-tip-delay);\n }\n .field > .row > .info:focus-visible > .tip {\n transition-delay: 0s;\n }\n\n /* ## The hint and the errors: lines under the control */\n .field > :is(.hint, .error.prompt) {\n margin: 0.375em 0 0;\n font-size: 0.85714em;\n line-height: 1.4;\n }\n .field > .hint {\n color: var(--_ui-field-hint-color);\n }\n .field > .error.prompt {\n color: var(--_ui-field-error-color);\n }\n .field > .error.prompt > .message {\n display: block;\n }\n}\n\n@layer ui.components.field.states {\n /* Inline, with a label row: the row beside the control; the hint and errors on lines of their own under both */\n .inline.field:has(> .row) {\n display: flex;\n flex-flow: row wrap;\n align-items: center;\n column-gap: 0.85714em;\n }\n .inline.field > .row {\n margin: 0;\n }\n .inline.field > .row > .label {\n margin-inline-end: 0;\n }\n .inline.field > .control {\n display: flex;\n flex: 1 1 12em;\n align-items: center;\n gap: 0.5em;\n min-width: 0;\n }\n .inline.field > :is(.hint, .error.prompt) {\n flex-basis: 100%;\n }\n /* The label row's label takes the state's colour, as a slotted label does */\n .error.field > .row > .label {\n color: var(--_ui-field-error-color);\n }\n}\n","import { For, Show } from \"solid-js\"\nimport type { JSX } from \"@solidjs/web\"\n\nimport { E, UIT } from \"spell/ui/core\"\nimport { fieldVocabulary } from \"./UIField.en\"\nimport { ERROR, FormStateFlags } from \"./UIForm.types\"\n\nimport formCSS from \"./UIForm.css?inline\"\nimport fieldCSS from \"./UIField.css?inline\"\n\n/****************\n * ### `DOMFieldElement`\n * The DOM element of `<ui-field>`: it adds `showErrors()`, which `<ui-form>` calls\n * to show (or, with `[]`, clear) the field's errors and error state.\n *\n * - No attribute is written, so the author's `state` and `error` stay theirs.\n * - `errors`: the messages `<ui-form>` asked to show.\n * - `DOMElement` checks its members against the attributes' property names; neither of these is one.\n * - Above the component: its `elementSetup` reads this class while the component is defined.\n ****************/\nexport class DOMFieldElement extends E.DOMElement<UIField> {\n /** Show `messages` as the field's errors (and `error` state); `[]` clears. */\n showErrors(messages: readonly string[]) {\n this.component?.showErrors(messages)\n }\n\n /** Messages `<ui-form>` asked to show. */\n @E.untracked\n get errors(): readonly string[] {\n return this.component?.formErrors ?? []\n }\n\n /**\n * The label it shows, and `<ui-form>`'s name for it in a message (\"Name must have a value\").\n * - Its `label`, else what its kind works out: a `<ui-property>`'s from its schema, or its name.\n */\n @E.untracked\n get shownLabel(): string | undefined {\n return this.component?.labelText\n }\n\n /** The placeholder `<ui-form>` shows in a control while its things disagree (`mixed`), in the page's language. */\n @E.untracked\n get mixedText(): string | undefined {\n return this.component?.translationForKey(\"mixed\")\n }\n}\n\n/****************\n * ### `UIField`\n * The component behind `<ui-field>`: one field of a form.\n * Its box, `<div class=\"… field\" part=\"field\">`, holds:\n * - the label row (`.row`): the label, then actions, the output, and the info icon with its tip\n * - the control (`.control`, the default slot)\n * - then the hint and the errors\n *\n * - The label row is drawn only when it has something: `label`, actions, `output` or `description`.\n * - A field that slots its own `<label for>` with its control has no row, and no `.control` either:\n * its markup is Fomantic's, as it always was (the static render's too).\n * - `SlotContent` watches the light children for the rich slots.\n * - It names the control: a slotted control with no `aria-label` or `aria-labelledby` of its own\n * gets `aria-label` = `label`.\n * - Why: a `<label for>` can't reach across the shadow boundary.\n * - A click on the label focuses it.\n * - The tip: a CSS tooltip under the info icon, shown on hover and keyboard focus.\n * The icon is described by it.\n *\n * - Errors: what `<ui-form>` asked for through `showErrors()`, else `error`.\n * - Shown as plain lines under the control, with `role=\"alert\"`.\n * - Either shows the `error` state.\n * - Failed validation shows `error` over the author's `state`, and clears back to it.\n *\n * - `apply`, `mixed` and `rules` are read by `<ui-form>`'s binding.\n * The field shows `mixed` as `:state(mixed)`.\n * - `readonly`: `:state(readonly)`.\n *\n * - The DOM element is `display: contents` (`UIForm.css`):\n * the root is the flex item of a `<ui-fields>` row, which hands it its width and gutter as inherited tokens.\n * - `.control` has no box either (`display: contents`), so the controls lay out as they always did.\n * - It hands its controls inherited owner tokens (`InputOwnerTokens`): full width, and its state's colours.\n *\n * - `disabled`: unusable, the base class's way (`elementSetup.disabled`):\n * - the root `inert`, so the slotted controls can't be used\n * - and `aria-disabled`\n * - The root also says `inert` itself, for the static render: the base class's reaches only a browser.\n * - Always carries `:state(field)`, which is how `<ui-form>` finds a control's field.\n * - SIDE EFFECT: writes `aria-label` on slotted controls (only ones that had no name).\n ****************/\nexport class UIField extends E.UIComponent<typeof fieldVocabulary> {\n @E.proto static vocabulary = fieldVocabulary\n // `Partial`: the property (`UIProperty`) and the editor (`UIPropertyEditor`) extend it\n @E.protoMerged static elementSetup: Partial<E.ElementSetup> = {\n styleSheets: { form: formCSS, field: fieldCSS },\n DOMElement: DOMFieldElement,\n delegatesFocus: false\n } satisfies Partial<E.ElementSetup>\n\n ////////////////\n // ## The label row\n ////////////////\n\n /** Which named slots have light-DOM content: label, description, hint, output, actions. */\n readonly slots = new E.SlotContent(this.domElement)\n\n /** The label the row shows: `label`; a subclass may find another (a property's, from its schema). */\n get labelText(): string | undefined {\n return this.label\n }\n\n /** The tip the row shows: `description`; a subclass may find another. */\n get descriptionText(): string | undefined {\n return this.description\n }\n\n /** Has a label in the row: `labelText`, or `slot=\"label\"`. */\n get hasLabel(): boolean {\n return !!this.labelText || this.slots.hasContent(this.slotForName(\"label\"))\n }\n\n /** Has actions (`slot=\"actions\"`). */\n get hasActions(): boolean {\n return this.slots.hasContent(this.slotForName(\"actions\"))\n }\n\n /** Has an output: `output`, or `slot=\"output\"`. */\n get hasOutput(): boolean {\n return !!this.output || this.slots.hasContent(this.slotForName(\"output\"))\n }\n\n /** Has a tip: `description`, or `slot=\"description\"`. */\n get hasDescription(): boolean {\n return !!this.descriptionText || this.slots.hasContent(this.slotForName(\"description\"))\n }\n\n /** Has a hint: `hint`, or `slot=\"hint\"`. */\n get hasHint(): boolean {\n return !!this.hint || this.slots.hasContent(this.slotForName(\"hint\"))\n }\n\n /** Draws the label row: it has something in it. */\n get hasRow(): boolean {\n return this.hasLabel || this.hasActions || this.hasOutput || this.hasDescription\n }\n\n /** Glyph of the info icon, while there's a tip. */\n readonly infoGlyph = new E.IconGlyph({ owner: this, name: () => (this.hasDescription ? INFO_ICON : undefined) })\n\n ////////////////\n // ## Errors\n ////////////////\n\n /** Messages `<ui-form>` asked to show; `DOMFieldElement.errors` reads them untracked. */\n @E.state accessor formErrors: readonly string[] = []\n\n /** Error lines shown: `<ui-form>`'s, else `error`. */\n get errors(): readonly string[] {\n const fromForm = this.formErrors\n if (fromForm.length) return fromForm\n return this.error ? [this.error] : []\n }\n\n /** Show `messages` (see `DOMFieldElement`). */\n @E.untracked\n showErrors(messages: readonly string[]) {\n const current = this.formErrors\n if (current.length !== messages.length || current.some((message, index) => message !== messages[index])) {\n this.formErrors = [...messages]\n }\n }\n\n ////////////////\n // ## State and classes\n ////////////////\n\n /** The state shown: `error` while there's an error, else the attribute. */\n get shownState(): UIT.FormState | undefined {\n return this.errors.length ? ERROR : this.state\n }\n\n /** `:state(error)`, `:state(info)` ...: the state shown. */\n protected cssStates() {\n return FormStateFlags.of(this.shownState)\n }\n\n /** `:state(mixed)`: the things being edited disagree (`mixed`). */\n @E.cssState(\"mixed\")\n get isMixed(): boolean {\n return !!this.mixed\n }\n\n /** `:state(readonly)`: `readonly`. */\n @E.cssState(\"readonly\")\n get isReadOnly(): boolean {\n return !!this.readonly\n }\n\n /** Always `:state(field)`: how `<ui-form>` finds a control's field. */\n @E.cssState(\"field\")\n get isField(): boolean {\n return true\n }\n\n protected classValue(name: E.AttributeName<typeof fieldVocabulary>): unknown {\n if (name === \"state\") return this.shownState\n return super.classValue(name)\n }\n\n ////////////////\n // ## Rendering\n ////////////////\n\n render(): JSX.Element {\n return (\n <div class={this.rootClass} part={this.partForName(\"field\")} inert={this.disabled}>\n <Show when={this.hasRow} fallback={this.controlSlotElement()}>\n {this.labelRow()}\n <div class={CLASSES.control} part={this.partForName(\"control\")}>\n {this.controlSlotElement()}\n </div>\n </Show>\n <Show when={this.hasHint}>\n <div class={CLASSES.hint} part={this.partForName(\"hint\")}>\n <slot name={this.slotForName(\"hint\")}>{this.hint}</slot>\n </div>\n </Show>\n <Show when={this.errors.length}>\n <div class={CLASSES.error} part={this.partForName(\"error\")} role=\"alert\">\n <For each={this.errors}>{(message) => <div class={UIT.MESSAGE}>{message}</div>}</For>\n </div>\n </Show>\n </div>\n )\n }\n\n /** The label row: the label, then (at its far end) actions, the output and the info icon with its tip. */\n private labelRow(): JSX.Element {\n return (\n <div class={CLASSES.row} part={this.partForName(\"row\")}>\n <span class={CLASSES.label} part={this.partForName(\"label\")} onClick={this.onLabelClick}>\n <slot name={this.slotForName(\"label\")}>{this.labelText}</slot>\n </span>\n <Show when={this.hasActions}>\n <span class={CLASSES.actions} part={this.partForName(\"actions\")}>\n <slot name={this.slotForName(\"actions\")} />\n </span>\n </Show>\n <Show when={this.hasOutput}>\n <span class={CLASSES.output} part={this.partForName(\"output\")}>\n <slot name={this.slotForName(\"output\")}>{this.output}</slot>\n </span>\n </Show>\n <Show when={this.hasDescription}>\n <span\n class={CLASSES.info}\n part={this.partForName(\"info\")}\n tabindex=\"0\"\n role=\"img\"\n aria-label={this.translationForKey(\"info\", { label: this.labelText ?? \"\" })}\n aria-describedby={TIP_ID}\n >\n {this.infoGlyph.svg}\n <span id={TIP_ID} class={CLASSES.tip} part={this.partForName(\"tip\")} role=\"tooltip\">\n <slot name={this.slotForName(\"description\")}>{this.descriptionText}</slot>\n </span>\n </span>\n </Show>\n </div>\n )\n }\n\n ////////////////\n // ## The control\n ////////////////\n\n /** The default slot, holding the control(s). */\n private controlSlot?: HTMLSlotElement\n\n /**\n * The default slot: in `.control` under a label row, else straight in the field's box.\n * - Straight in the box for a field with no row (one that slots its own `<label>`):\n * its markup, and the static render's, stay Fomantic's (`.field > label`).\n */\n private controlSlotElement(): JSX.Element {\n return <slot ref={(element) => (this.controlSlot = element)} onSlotChange={this.onControlChange} />\n }\n\n /** Controls this field named (`aria-label`), so a new `label` renames them and nothing else. */\n private readonly named = new WeakSet<Element>()\n\n /** A new `label`, once drawn: rename the controls this field named. */\n @E.onChange(\"labelText\", \"isReady\")\n protected onLabelChanged(label: string | undefined, isReady: boolean) {\n if (isReady) this.nameControls(label)\n }\n\n /** The slotted controls changed: name the new ones. */\n @E.untracked\n private readonly onControlChange = () => {\n this.nameControls(this.labelText)\n }\n\n /**\n * Give each slotted control without a name of its own `aria-label` = `label`.\n * - A slotted `<label>` is skipped: it names its control itself.\n * - SIDE EFFECT: writes the controls' `aria-label`.\n * Only ones this field named before are renamed or cleared.\n */\n private nameControls(label: string | undefined) {\n for (const control of this.controlSlot?.assignedElements() ?? []) {\n if (control.localName === \"label\") continue\n const hasOwnName = NAMED_ATTRIBUTES.some((name) => control.hasAttribute(name)) && !this.named.has(control)\n if (hasOwnName) continue\n if (label) {\n control.setAttribute(\"aria-label\", label)\n this.named.add(control)\n } else if (this.named.has(control)) {\n control.removeAttribute(\"aria-label\")\n this.named.delete(control)\n }\n }\n }\n\n /** A click on the label focuses the first control, as a `<label for>` would. */\n private readonly onLabelClick = () => {\n const control = this.controlSlot?.assignedElements().find((element) => element.localName !== \"label\")\n ;(control as HTMLElement | undefined)?.focus()\n }\n}\n\n/** The vocabulary getters, typed (`UIComponent`'s doc). */\nexport interface UIField extends E.AttributeValues<typeof fieldVocabulary> {}\n\n/** Icon of the tip. */\nconst INFO_ICON = \"circle info\"\n\n/** Shadow-root id of the tip, which the info icon is described by. */\nconst TIP_ID = \"tip\"\n\n/** A control with one of these has a name of its own: the field doesn't name it. */\nconst NAMED_ATTRIBUTES = [\"aria-label\", \"aria-labelledby\"] as const\n\n/** Shadow classes, one per part (the vocabulary's part names). */\nconst CLASSES = {\n row: \"row\",\n label: \"label\",\n actions: \"actions\",\n output: \"output\",\n info: \"info\",\n tip: \"tip\",\n control: \"control\",\n hint: \"hint\",\n error: \"error prompt\"\n} as const\n","/**\n * The English vocabulary of `<ui-fields>`: every name the tag uses.\n * - Its tag, attributes (each with its kind and allowed values), slots, parts and states.\n * The shape is `E.ComponentVocabulary` (`spell/ui/vocabulary`).\n * - Pure data: node imports it (`yarn site:data`, `yarn gen:root`), so `spell/ui/core` for types only,\n * `UIT` by value straight from `components.types`.\n * - The family's grammar notes are in `UIForm.en.ts`.\n */\n\nimport type { E } from \"spell/ui/core\"\nimport * as UIT from \"spell/ui/components/components.types\"\nimport { STATE_STATES } from \"./UIForm.types\"\n\n/****************\n * ### `fieldsVocabulary`\n * The names of `<ui-fields>`, a row (or group) of fields: `<div class=\"… fields\" part=\"fields\"><slot></slot></div>`.\n ****************/\nexport const fieldsVocabulary = {\n tag: \"ui-fields\",\n topics: [\"forms\", \"layout\", \"collections\"],\n aka: [\"field group\", \"form row\", \"inline fields\"],\n noun: \"fields\",\n ui: false,\n description: \"A set of fields can appear grouped together, side by side or stacked.\",\n attributes: [\n {\n name: \"state\",\n group: \"form\",\n kind: \"valueOnly\",\n values: UIT.FormStates,\n description: \"State of every field inside.\"\n },\n { name: \"inline\", group: \"layout\", kind: \"keyOnly\", description: \"Fields and their labels on one line.\" },\n {\n name: \"grouped\",\n group: \"content\",\n kind: \"keyOnly\",\n description: \"Fields stacked under one label (radio / checkbox groups).\"\n },\n { name: \"unstackable\", group: \"layout\", kind: \"keyOnly\", description: \"Never stacks on a narrow form.\" },\n {\n name: \"required\",\n group: \"form\",\n kind: \"keyOnly\",\n description: \"Marks every field label (or the group label) with an asterisk.\"\n },\n { name: \"disabled\", group: \"states\", kind: \"keyOnly\", description: \"Every field dimmed and not usable.\" },\n {\n name: \"equal\",\n group: \"layout\",\n kind: \"keyOnly\",\n key: \"equal width\",\n description:\n \"Every field the same width, from the fields themselves (no count): an equal share of the row each \" +\n '(Fomantic\\'s `equal width fields`; ~== `widths=\"equal\"`).'\n },\n {\n name: \"widths\",\n group: \"appearance\",\n kind: \"width\",\n widthClass: \"\",\n canEqual: true,\n values: [\"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\"],\n description:\n 'Older, count-based alias of `equal`: fields per row, sharing it equally (`widths=\"2\"` => `two fields`); ' +\n '`\"equal\"` => any number (`equal width`).'\n }\n ],\n events: [],\n slots: [{ name: \"\", description: \"`<ui-field>`s, and a `<label>` for a grouped / inline set.\" }],\n parts: [{ name: \"fields\", description: \"The row box.\" }],\n states: [...STATE_STATES, { name: \"disabled\", description: \"Can't be used.\" }],\n texts: []\n} as const satisfies E.ComponentVocabulary\n","import type { JSX } from \"@solidjs/web\"\n\nimport { E } from \"spell/ui/core\"\nimport { fieldsVocabulary } from \"./UIFields.en\"\nimport { FormStateFlags } from \"./UIForm.types\"\n\nimport formCSS from \"./UIForm.css?inline\"\n\n/****************\n * ### `UIFields`\n * The component behind `<ui-fields>`:\n * a row (or a `grouped` stack) of fields, `<div class=\"… fields\" part=\"fields\"><slot></slot></div>`.\n *\n * - The DOM element is `display: contents`; the root is the flex row,\n * and hands each `<ui-field>` its share of the width (`widths`), the gutter and its state\n * as inherited tokens (`UIForm.css`).\n * - `disabled`: unusable, the base class's way (`elementSetup.disabled`):\n * the root `inert`, `aria-disabled`.\n * - The root also says `inert` itself, for the static render: the base class's reaches only a browser.\n ****************/\nexport class UIFields extends E.UIComponent<typeof fieldsVocabulary> {\n @E.proto static vocabulary = fieldsVocabulary\n @E.protoMerged static elementSetup = {\n styleSheets: { form: formCSS },\n delegatesFocus: false\n } satisfies Partial<E.ElementSetup>\n\n /** `:state(error)`, `:state(info)` ...: its `state`. */\n protected cssStates() {\n return FormStateFlags.of(this.state)\n }\n\n render(): JSX.Element {\n return (\n <div class={this.rootClass} part={this.partForName(\"fields\")} inert={this.disabled}>\n <slot />\n </div>\n )\n }\n}\n\n/** The vocabulary getters, typed (`UIComponent`'s doc). */\nexport interface UIFields extends E.AttributeValues<typeof fieldsVocabulary> {}\n","/**\n * The English vocabulary of `<ui-form>`: every name the tag uses.\n * - Its tag, attributes (each with its kind and allowed values), events, slots, parts, states and texts.\n * The shape is `E.ComponentVocabulary` (`spell/ui/vocabulary`).\n * - Pure data: node imports it (`yarn site:data`, `yarn gen:root`), so `spell/ui/core` for types only,\n * `UIT` by value straight from `components.types`.\n * - The notes below are the whole family's: `<ui-field>`, `<ui-fields>` and `<ui-repeat>` too.\n * - Class words come out through `ClassBuilder`, in Fomantic's grammar:\n * - `<ui-form size=\"large\" state=\"error\">` => `ui large error form`\n * - `<ui-field width=\"4\" required>` => `required four wide field`\n * - `<ui-fields widths=\"2\" inline>` => `inline two fields`, `widths=\"equal\"` => `equal width fields`\n * - Fields have no `ui` (Fomantic styles them inside `.ui.form`).\n * - `state` is `kind: \"valueOnly\"`: it emits its value alone (`error field`), a remap in `colors.css`.\n * - Validation lives on `<ui-form>`: `rules` is a PROPERTY (`json`) in Fomantic's `fields` shape.\n * - Binding too: `value` is a PROPERTY (`json`), the object its named controls show and edit.\n * `<ui-repeat name>` repeats its fields per item of one of its lists.\n */\n\nimport type { E } from \"spell/ui/core\"\nimport * as UIT from \"spell/ui/components/components.types\"\nimport { FormApplyModes, STATE_STATES, ValidationTriggers } from \"./UIForm.types\"\n\n/****************\n * ### `formVocabulary`\n * The names of `<ui-form>`: a form's look and its validation,\n * around a NATIVE `<form>` (slotted inside it, or around it).\n * - Its shadow DOM: `<div class=\"ui … form\" part=\"form\"><slot></slot></div>`.\n ****************/\nexport const formVocabulary = {\n tag: \"ui-form\",\n topics: [\"forms\", \"inputs\", \"basic\", \"collections\"],\n aka: [\"form layout\", \"fieldset\", \"validation\"],\n noun: \"form\",\n description: \"A form displays a set of related input fields in a structured way.\",\n attributes: [\n {\n name: \"size\",\n group: \"appearance\",\n kind: \"size\",\n description: \"Size of everything inside, `mini` ... `massive`.\"\n },\n {\n name: \"state\",\n group: \"form\",\n kind: \"valueOnly\",\n values: UIT.FormStates,\n description:\n \"Form state: shows the `<ui-message>`s of that state inside. Failed validation sets `error` on top.\"\n },\n {\n name: \"equal-width\",\n group: \"layout\",\n kind: \"keyOnly\",\n key: \"equal width\",\n description: \"Every row of fields shares its width equally.\"\n },\n { name: \"inverted\", group: \"appearance\", kind: \"keyOnly\", description: \"For dark backgrounds: light labels.\" },\n { name: \"loading\", group: \"states\", kind: \"keyOnly\", description: \"Busy: dimmed behind a spinner, not usable.\" },\n { name: \"disabled\", group: \"states\", kind: \"keyOnly\", description: \"Nothing inside can be used (`inert`).\" },\n {\n name: \"unstackable\",\n group: \"layout\",\n kind: \"keyOnly\",\n description: \"Rows of fields never stack on narrow forms.\"\n },\n {\n name: \"stack-with\",\n group: \"layout\",\n kind: \"enum\",\n values: UIT.StackWithValues,\n description:\n \"What its rows of fields stack by: `container` (the default) -- the form's own width; `page` -- \" +\n \"the screen's, as in Fomantic. Its `<ui-fields>` follow it. Unset: the page-wide \" +\n \"`--ui-stack-with` token decides (`<ui-root stack-with>`).\"\n },\n {\n name: \"validate\",\n group: \"form\",\n kind: \"enum\",\n // not `validate`: that's the DOM element's `validate()`\n property: \"validateOn\",\n values: ValidationTriggers,\n default: \"on save\",\n description:\n \"When fields validate: `immediately`, as each changes; `on leave`, as the cursor leaves each; or only \" +\n \"`on save` (a submit, or `save()`). A field showing an error always validates again as it changes.\"\n },\n {\n name: \"apply\",\n group: \"form\",\n kind: \"enum\",\n values: FormApplyModes,\n default: \"immediately\",\n description:\n \"When edits land in the bound `value`: `immediately`; or `on save`, all together on `save()`, while \" +\n \"`cancel()` drops them (`:state(changed)` while any are held). Each field's own `apply` says when it takes an edit.\"\n },\n {\n name: \"rules\",\n group: \"form\",\n kind: \"json\",\n reflect: false,\n description:\n 'Validation rules by field name (or id), Fomantic\\'s `fields` shape: `{ email: \"email\", password: ' +\n '[\"notEmpty\", \"minLength[6]\"], name: { rules: [{ type: \"notEmpty\", prompt: \"...\" }], optional: true } }`.'\n },\n {\n name: \"error-focus\",\n group: \"advanced\",\n kind: \"boolean\",\n default: true,\n description: 'Focus the first invalid field when a submit fails; `error-focus=\"no\"` to keep focus.'\n },\n {\n name: \"prevent-leaving\",\n group: \"advanced\",\n kind: \"boolean\",\n description: \"Ask before leaving the page while fields differ from their starting values.\"\n },\n {\n name: \"value\",\n group: \"form\",\n kind: \"json\",\n reflect: false,\n description:\n \"The object the form is BOUND to: each control with a `name` shows that property and writes it back as \" +\n \"it changes, live both ways (Solid signals, reactive members, spell objects); a control in a \" +\n \"`<ui-repeat>` row binds to the row's item. Unset: nothing is bound.\"\n },\n {\n name: \"debug\",\n group: \"advanced\",\n kind: \"boolean\",\n description: \"Show the bound `value` (else `values`) as JSON below the form, live.\"\n }\n ],\n events: [\n {\n name: \"ui-valid\",\n detail: \"{ field: string, value: FieldValue, values: Record<string, FieldValue> }\",\n description: \"A field passed validation.\"\n },\n {\n name: \"ui-invalid\",\n detail: \"{ field: string, value: FieldValue, errors: string[], values: Record<string, FieldValue> }\",\n description: \"A field failed validation; `errors` are its prompts.\"\n },\n {\n name: \"ui-saving\",\n detail: \"{ values: Record<string, FieldValue>, originalEvent?: Event }\",\n cancelable: true,\n description:\n \"A submit passed validation; `preventDefault()` stops the native submission (e.g. to send it by fetch).\"\n },\n {\n name: \"ui-save-failed\",\n detail: \"{ values: Record<string, FieldValue>, errors: Record<string, string[]>, originalEvent?: Event }\",\n description: \"A submit failed validation (the native submission is stopped); `errors` by field.\"\n },\n {\n name: \"ui-applying\",\n detail: \"{ changes: FormChange[], value: unknown }\",\n cancelable: true,\n description:\n '`save()`, with `apply=\"on save\"`: the held edits are about to land; `preventDefault()` keeps them held.'\n },\n {\n name: \"ui-applied\",\n detail: \"{ changes: FormChange[], value: unknown }\",\n description: \"The held edits landed in the bound `value`.\"\n },\n {\n name: \"ui-cancelling\",\n detail: \"{ changes: FormChange[] }\",\n cancelable: true,\n description: \"`cancel()`: the held edits are about to be dropped; `preventDefault()` keeps them.\"\n },\n {\n name: \"ui-cancelled\",\n detail: \"{ changes: FormChange[] }\",\n description: \"The held edits were dropped: every control shows the bound `value` again.\"\n }\n ],\n slots: [{ name: \"\", description: \"The native `<form>` (or its content, when the `<ui-form>` sits inside one).\" }],\n parts: [\n { name: \"form\", description: \"The form box.\" },\n { name: \"debug\", description: \"The JSON `debug` shows, a `<pre>` in a captioned box below the content.\" }\n ],\n states: [\n ...STATE_STATES,\n { name: \"loading\", description: \"Busy.\" },\n { name: \"changed\", description: '`apply=\"on save\"`: edits are held, not saved yet.' },\n { name: \"disabled\", description: \"Can't be used.\" },\n {\n name: \"root\",\n description:\n \"Always on: the form's own host (its sheet also styles `<ui-fields>` / `<ui-field>` hosts), a block and the size container its rows stack by.\"\n }\n ],\n texts: [\n { key: \"formDebugBound\", text: \"Bound object\", description: \"Caption of `debug`'s JSON while the form is bound.\" },\n {\n key: \"formDebugValues\",\n text: \"Values\",\n description: \"Caption of `debug`'s JSON while it isn't: the form's `values`.\"\n }\n ]\n} as const satisfies E.ComponentVocabulary\n","import { Show } from \"solid-js\"\nimport { isServer, type JSX } from \"@solidjs/web\"\n\nimport { E, UIT } from \"spell/ui/core\"\nimport { formVocabulary } from \"./UIForm.en\"\nimport { FormBinding } from \"./FormBinding\"\nimport { FormFields } from \"./FormFields\"\nimport type { DOMFieldElement } from \"./UIField\"\nimport { ERROR, FIELD_SELECTOR, FormStateFlags, type Field } from \"./UIForm.types\"\n\nimport formCSS from \"./UIForm.css?inline\"\n\n/****************\n * ### `DOMFormElement`\n * The DOM element of `<ui-form>`, as `HTMLFormElement` is `<form>`'s:\n * it adds the form's script API (`validate()`, `isValid()`, `reset()`, `clear()`, `values`, `nativeForm`),\n * each handed to the component.\n *\n * - Before the component exists, it answers as an empty form: valid, no values, no native form.\n * - `DOMElement` checks its members against the attributes' property names; none of these is one.\n * - Above the component: its `elementSetup` reads this class while the component is defined.\n ****************/\nexport class DOMFormElement extends E.DOMElement<UIForm> {\n /** Validate every field, show prompts and states; true when valid. */\n validate(): boolean {\n return this.component?.validateFields() ?? true\n }\n\n /** The same verdict as `validate()`, showing nothing. */\n isValid(): boolean {\n return this.component?.isValid() ?? true\n }\n\n /** The native form's reset (controls back to their starting values), then prompts cleared. */\n reset() {\n this.component?.reset()\n }\n\n /** Every control emptied (text `\"\"`, checkboxes unchosen), then prompts cleared. */\n clear() {\n this.component?.clear()\n }\n\n /**\n * `apply=\"on save\"`: the held edits land in the bound `value`, after every field validates.\n * - `ui-applying` (cancelable), then `ui-applied`.\n * - True when they landed.\n */\n save(): boolean {\n return this.component?.save() ?? false\n }\n\n /**\n * `apply=\"on save\"`: drop the held edits.\n * - `ui-cancelling` (cancelable), then `ui-cancelled`.\n * - True when dropped.\n */\n cancel(): boolean {\n return this.component?.cancel() ?? false\n }\n\n /** Every field's value, by name (Fomantic's `get values`). */\n get values(): UIT.FormValues {\n return this.component?.values ?? {}\n }\n\n /** The `<form>` it works with, if any. */\n @E.untracked\n get nativeForm(): HTMLFormElement | undefined {\n return this.component?.nativeForm\n }\n}\n\n/****************\n * ### `UIForm`\n * The component behind `<ui-form>`: a form's look and its VALIDATION, over a NATIVE form.\n * - Its look: `<div class=\"ui … form\" part=\"form\"><slot></slot></div>`.\n *\n * - Why not a form of its own:\n * a form-associated control belongs to the nearest `<form>` ANCESTOR in its own tree.\n * - So a `<form>` in this shadow root would never own the slotted controls.\n * - And a custom element can't BE a form.\n * - So `<ui-form>` works with a light-DOM `<form>`: one slotted INSIDE it (`<ui-form><form>…`, preferred),\n * else the one AROUND it (`<form><ui-form>…`).\n * - It never creates or moves one: frameworks own that DOM.\n * - Without any, it still validates (`validate()`, `validate=\"on leave | immediately\"`), but nothing submits.\n *\n * - SIDE EFFECT: sets `noValidate` on that form while connected (restored after),\n * so the browser's bubbles don't pre-empt Fomantic's prompts;\n * constraint validation still counts (see `FormFields.errors()`).\n *\n * - Submit (in the capture phase, on the form): every field validates.\n * - Invalid: the prompts, the `error` state, `ui-save-failed`, and focus on the first invalid field (`error-focus`);\n * plus `preventDefault()` and `stopImmediatePropagation()`,\n * so the page's own submit handlers never see an invalid form, as natively.\n * - Valid: the cancelable `ui-saving` (cancelled => no native submission).\n *\n * - Prompts: each field's first control's `<ui-field>` (`:state(field)`) gets `showErrors()`.\n * - Failing controls get `aria-invalid=\"true\"` (removed when they pass).\n * - A field that shows an error validates again as it changes, whatever `validate` says.\n * - `validate`, when fields validate:\n * - `on save` (the default): on submit and `save()`\n * - `on leave`: also as the cursor leaves a field\n * - `immediately`: also as one changes\n * - Each field's rules: the form's `rules` for it, plus its `<ui-field rules>`.\n *\n * - `ui-valid` / `ui-invalid` fire per field validated.\n * - The script API (`values`, `validate()`, `isValid()`, `reset()`, `clear()`) is the DOM element's, `DOMFormElement`.\n *\n * - `prevent-leaving`: a `beforeunload` guard while the values differ from those at connect, reset or success.\n *\n * - `value`: the form is BOUND to that object (`FormBinding`).\n * - each named control shows its property, and writes it back as the person changes it\n * - a control inside a `<ui-repeat>` row binds to that row's item instead\n * - live both ways, for anything Solid follows (signals, reactive members, spell's objects)\n * - after a reset or a clear, the object takes the controls' values\n * - a LIST of things binds each control to all of them: the value they agree on, else blank and `mixed`\n * - each field writes when its `<ui-field apply>` says: `immediately`, `delayed` after a pause, or `on leave`\n * - a value that fails validation is never written\n * - `apply=\"on save\"`: edits are held (`:state(changed)`) until `save()`, and `cancel()` drops them\n * - without it, nothing is bound: the form works as it always has\n * - `debug`: below the content, a captioned box whose `<pre part=\"debug\">` shows, redrawn as they change:\n * - the bound `value` as JSON (its `toJSON()` counts)\n * - else `values`\n * - Why the box and caption: bare JSON under a form reads as page text, and gets missed.\n *\n * - Static server render (`spell/ui/static`): a `<form>` slotted inside it MERGES into the root,\n * which becomes `<form class=\"ui … form\">` with the author's attributes (`mergedForm`).\n * - That's Fomantic's own markup, so the form's rules reach its fields and messages,\n * and the page still submits natively.\n * - A form around it stays as it is.\n ****************/\nexport class UIForm extends E.UIComponent<typeof formVocabulary> {\n @E.proto static vocabulary = formVocabulary\n // `Partial`: the property (`UIProperty`) and the editor (`UIPropertyEditor`) extend it\n @E.protoMerged static elementSetup: Partial<E.ElementSetup> = {\n styleSheets: { form: formCSS },\n DOMElement: DOMFormElement,\n delegatesFocus: false,\n // `disabled`: unusable, the default; the root also says `inert` itself, for the static render\n // `loading`: Fomantic's veil, its content inert\n loading: \"its own\"\n } satisfies Partial<E.ElementSetup>\n\n /** Controls, values, labels, errors. */\n readonly fields = new FormFields({ domElement: this.domElement, form: () => this.nativeForm })\n\n /** The controls bound to `value`. */\n private readonly binding = new FormBinding({\n domElement: this.domElement,\n fields: this.fields,\n form: {\n isHolding: () => this.apply === ON_SAVE,\n canWrite: (control) => this.passes(control),\n onHeldChange: () => {\n this.hasHeldChanges = this.binding.hasHeld\n this.onHeldChanged()\n },\n onWrite: (write) => this.onWritten(write)\n }\n })\n\n /** Fields showing an error now. */\n private readonly fieldsShowingErrors = new Set<string>()\n\n /** Values at connect / reset / success, for `prevent-leaving`. */\n private savedValues = \"\"\n\n /** Validation deferred to after the controls settle, by field. */\n private readonly fieldsAwaitingCheck = new Set<string>()\n\n /**\n * Server render only: attributes of the author's `<form>` merged into the root, `undefined` when there's none.\n * - SIDE EFFECT: unwraps that form in the DOM element's light DOM, so its children fill the root's slot.\n */\n private readonly mergedForm = isServer ? UIForm.unwrapForm(this.domElement) : undefined\n\n ////////////////\n // ## State and classes\n ////////////////\n\n /** The last submit / `validate()` failed: `error` shows. */\n @E.state accessor lastCheckFailed = false\n\n /** `error` after a failed submit, else the attribute. */\n private get shownState(): UIT.FormState | undefined {\n return this.lastCheckFailed ? ERROR : this.state\n }\n\n /** `:state(error)`, `:state(info)` ...: the state shown. */\n protected cssStates() {\n return FormStateFlags.of(this.shownState)\n }\n\n /** `:state(changed)`: `apply=\"on save\"` holds edits, not saved yet. */\n @E.cssState(\"changed\")\n @E.state\n accessor hasHeldChanges = false\n\n /** Always `:state(root)`. */\n @E.cssState(\"root\")\n get isRoot(): boolean {\n return true\n }\n\n protected classValue(name: E.AttributeName<typeof formVocabulary>): unknown {\n if (name === \"state\") return this.shownState\n return super.classValue(name)\n }\n\n /** `stack-with`'s class (`UIT.StackClasses`): sets the switch its rows stack by. */\n protected get extraClass(): string | undefined {\n return UIT.StackClasses.classFor(this.stackWith)\n }\n\n ////////////////\n // ## Rendering\n ////////////////\n\n render(): JSX.Element {\n if (this.mergedForm) return this.formRoot(this.mergedForm)\n return (\n <div\n class={this.rootClass}\n part={this.partForName(\"form\")}\n inert={this.disabled || this.loading}\n aria-busy={this.loading ? \"true\" : undefined}\n >\n <slot />\n {this.debugBox()}\n </div>\n )\n }\n\n /** `debug`'s box: the bound object (or `values`) as JSON, below the content; a subclass draws it too. */\n protected debugBox(): JSX.Element {\n return (\n <Show when={this.debug}>\n <figure class=\"debug\">\n <figcaption>{this.debugCaption}</figcaption>\n <pre part={this.partForName(\"debug\")}>{this.debugText}</pre>\n </figure>\n </Show>\n )\n }\n\n /** Server render: the root as the author's `<form>`, its attributes kept, its class after ours. */\n private formRoot(attributes: Record<string, string>): JSX.Element {\n const { class: authorClass, ...rest } = attributes\n return (\n <form\n {...rest}\n class={[this.rootClass, authorClass]}\n part={this.partForName(\"form\")}\n inert={this.disabled || this.loading}\n aria-busy={this.loading ? \"true\" : undefined}\n >\n <slot />\n </form>\n )\n }\n\n ////////////////\n // ## The native form\n ////////////////\n\n /** The native form it works with (`findForm()`). */\n @E.state accessor nativeForm: HTMLFormElement | undefined = undefined\n\n /** The DOM element holds `value` as the scope its controls bind to (`FormBinding.hold()`). */\n onMount() {\n FormBinding.hold(this.domElement, () => this.value)\n return super.onMount()\n }\n\n /**\n * While connected: find the native form (and again as the subtree changes),\n * and listen for the page leaving; returns their undo.\n * - Its own `MutationObserver`, not `@watches`: it watches only while connected.\n */\n @E.whileConnected\n protected watchForm() {\n // oxlint-disable-next-line spell-ui/no-mutation-observer -- only while connected: `@E.watches` lasts the element's whole life\n const observer = new MutationObserver(() => this.onContentChanged())\n observer.observe(this.domElement, { childList: true, subtree: true })\n this.findForm()\n window.addEventListener(\"beforeunload\", this.onBeforeUnload)\n E.afterSolidUpdate(() => this.saveValues())\n return () => {\n this.nativeForm = undefined\n observer.disconnect()\n window.removeEventListener(\"beforeunload\", this.onBeforeUnload)\n }\n }\n\n /** Controls came or went: find the native form again, bind what's new, redraw `debug`. */\n @E.untracked\n private onContentChanged() {\n this.findForm()\n if (this.isBound) this.binding.update()\n this.changeCount++\n }\n\n /** The native form: one inside, else the one around. */\n @E.untracked\n private findForm() {\n const form = this.domElement.querySelector(\"form\") ?? this.domElement.parentElement?.closest(\"form\") ?? undefined\n if (form !== this.nativeForm) this.nativeForm = form\n }\n\n /** A native form to work with: `noValidate` on, its submit and reset listened to; all undone when it goes. */\n @E.onChange(\"nativeForm\")\n protected onNativeFormChanged(form: HTMLFormElement | undefined) {\n if (!form) return undefined\n const noValidate = form.noValidate\n form.noValidate = true\n form.addEventListener(\"submit\", this.onSubmit, { capture: true })\n form.addEventListener(\"reset\", this.onReset)\n return () => {\n form.noValidate = noValidate\n form.removeEventListener(\"submit\", this.onSubmit, { capture: true })\n form.removeEventListener(\"reset\", this.onReset)\n }\n }\n\n ////////////////\n // ## The bound object (`value`) and `debug`\n ////////////////\n\n /** Bound: `value` is an object to show and edit. */\n get isBound(): boolean {\n return FormBinding.isObject(this.value)\n }\n\n /** Bind the controls while bound and connected; let go of them when either ends. */\n @E.onChange(\"isBound\", \"isConnected\")\n protected onBindingChanged(isBound: boolean, connected: boolean) {\n if (!isBound || !connected || isServer) return undefined\n this.binding.update()\n return () => this.binding.stop()\n }\n\n /** Bumped a microtask after every change, and as controls come and go: `debug` redraws. */\n @E.state private accessor changeCount = 0\n\n /** `debug`'s caption: what the JSON is, the bound object or the form's `values`. */\n private get debugCaption(): string {\n return this.translationForKey(this.isBound ? \"formDebugBound\" : \"formDebugValues\")\n }\n\n /**\n * What `debug` shows: the bound `value` as JSON (an object's own `toJSON()` counts), else `values`.\n * - Tracked: the JSON reads every property it shows, so a reactive object redraws it as it changes.\n * - `changeCount` covers the rest (a plain object, `values` read from the DOM).\n */\n private get debugText(): string {\n const { value } = this\n const shown = this.changeCount >= 0 && FormBinding.isObject(value) ? value : this.values\n try {\n return JSON.stringify(shown, null, 2)\n } catch (error) {\n return String(error)\n }\n }\n\n ////////////////\n // ## Script API (the DOM element's: `DOMFormElement`)\n ////////////////\n\n /** Validate every field, show the results; true when all pass. */\n validateFields(): boolean {\n return !Object.keys(this.validateAll()).length\n }\n\n /** Validate and show every field, set the failed state; errors by field. */\n private validateAll(): Record<string, string[]> {\n const errors = this.check(\"show\")\n this.lastCheckFailed = !!Object.keys(errors).length\n return errors\n }\n\n /** Would every field pass? Shows nothing. */\n isValid(): boolean {\n return !Object.keys(this.check(\"silently\")).length\n }\n\n /** The native reset, then prompts and states cleared. */\n @E.untracked\n reset() {\n const form = this.nativeForm\n if (form) form.reset()\n else {\n for (const control of this.fields.controls()) UIForm.resetControl(control)\n E.afterSolidUpdate(() => this.binding.writeAll())\n }\n this.clearErrors()\n }\n\n /** Every control emptied, prompts and states cleared; a bound object takes the empty values. */\n clear() {\n for (const control of this.fields.controls()) UIForm.clearControl(control)\n this.clearErrors()\n E.afterSolidUpdate(() => this.binding.writeAll())\n }\n\n /** Every field's value, by name; read from the DOM, untracked. */\n get values(): UIT.FormValues {\n return this.fields.values()\n }\n\n /** Validate, then land the held edits (`DOMFormElement.save()`). */\n @E.untracked\n save(): boolean {\n this.binding.flushWaiting()\n if (!this.validateFields()) return false\n const detail: UIT.FormSaveDetail = { changes: this.binding.changes, value: this.value }\n if (!this.send(\"ui-applying\", detail)) return false\n this.binding.saveHeld()\n this.send(\"ui-applied\", detail)\n this.onSucceeded()\n E.afterSolidUpdate(() => this.saveValues())\n return true\n }\n\n /** Drop the held edits (`DOMFormElement.cancel()`). */\n @E.untracked\n cancel(): boolean {\n const detail: UIT.FormCancelDetail = { changes: this.binding.changes }\n if (!this.send(\"ui-cancelling\", detail)) return false\n this.binding.dropHeld()\n this.clearErrors()\n this.send(\"ui-cancelled\", detail)\n return true\n }\n\n ////////////////\n // ## Validating\n ////////////////\n\n /**\n * Validate every field; errors by field.\n * - `\"show\"`: prompts, `aria-invalid` and per-field events too.\n * The caller focuses the first invalid field.\n * - `\"silently\"`: the verdict alone.\n */\n private check(mode: CheckMode): Record<string, string[]> {\n const fields = this.fields.fields()\n const values = this.fields.values(fields)\n const labels = this.fields.labels(fields)\n const rules = this.rulesFor(fields)\n const errors: Record<string, string[]> = {}\n for (const field of fields) {\n const messages = this.fields.errors({ field, rules, values, labels })\n if (messages.length) errors[field.identifier] = messages\n if (mode === \"show\") this.show({ field, messages, values })\n }\n return errors\n }\n\n /** Validate ONE field now and show it. */\n private checkField(identifier: string) {\n const fields = this.fields.fields()\n const field = fields.find((candidate) => candidate.identifier === identifier)\n if (!field) return\n const values = this.fields.values(fields)\n const labels = this.fields.labels(fields)\n const messages = this.fields.errors({ field, rules: this.rulesFor([field]), values, labels })\n this.show({ field, messages, values })\n if (!this.fieldsShowingErrors.size && this.lastCheckFailed) this.lastCheckFailed = false\n }\n\n /** Would `control`'s field pass now? Shows nothing: the binding writes only a value that passes. */\n @E.untracked\n private passes(control: Element): boolean {\n const field = this.fields.fields().find((candidate) => candidate.controls.includes(control))\n if (!field) return true\n const fields = this.fields.fields()\n const values = this.fields.values(fields)\n const labels = this.fields.labels(fields)\n return !this.fields.errors({ field, rules: this.rulesFor([field]), values, labels }).length\n }\n\n /**\n * The rules for `fields`: the form's `rules`, plus each field's `<ui-field rules>` (after the form's own for it).\n * - A field's rules are its first control's `<ui-field>`'s.\n */\n private rulesFor(fields: readonly Field[]): UIT.FormRules | undefined {\n const formRules = this.formRules\n let rules: UIT.FormRules | undefined = formRules\n for (const { identifier, controls } of fields) {\n const field = UIForm.fieldElementFor(controls)\n const own = [field?.rules, field?.schemaRules].flatMap((rules) =>\n rules ? (Array.isArray(rules) ? rules : [rules]) : []\n )\n if (!own.length) continue\n const ownList = own as E.ValidationRule[]\n const theirs = formRules?.[identifier]\n rules = { ...rules, [identifier]: UIForm.joinRules(theirs, ownList) }\n }\n return rules\n }\n\n /**\n * A form's rules for a field, then a field's own after them.\n * - STATIC: pure.\n */\n private static joinRules(theirs: UIT.FormFieldRules | undefined, own: E.ValidationRule[]): UIT.FormFieldRules {\n if (theirs === undefined) return own\n if (typeof theirs === \"object\" && !Array.isArray(theirs) && \"rules\" in theirs) {\n return { ...theirs, rules: [...theirs.rules, ...own] }\n }\n return [...(Array.isArray(theirs) ? theirs : [theirs as E.ValidationRule]), ...own]\n }\n\n /** Show `messages` for a field (or clear it), and dispatch `ui-valid` / `ui-invalid`. */\n private show({ field: { identifier, controls }, messages, values }: ShownField) {\n UIForm.fieldElementFor(controls)?.showErrors?.(messages)\n for (const control of controls) {\n if (messages.length) control.setAttribute(\"aria-invalid\", \"true\")\n else if (control.getAttribute(\"aria-invalid\") === \"true\") control.removeAttribute(\"aria-invalid\")\n }\n if (messages.length) this.fieldsShowingErrors.add(identifier)\n else this.fieldsShowingErrors.delete(identifier)\n this.onFieldChecked({ identifier, controls }, messages)\n const value = values[identifier]\n if (messages.length) {\n const detail: UIT.FormInvalidDetail = { field: identifier, value, errors: messages, values }\n this.send(\"ui-invalid\", detail)\n } else {\n const detail: UIT.FormValidDetail = { field: identifier, value, values }\n this.send(\"ui-valid\", detail)\n }\n }\n\n /** A field was validated and shown: for a subclass (the property editor tells the field's group); nothing here. */\n protected onFieldChecked(_field: Field, _messages: readonly string[]) {}\n\n /** Held edits came or went (`hasHeldChanges`): for a subclass; nothing here. */\n protected onHeldChanged() {}\n\n /** The controls whose edits are held (`apply=\"on save\"`). */\n protected get heldControls(): readonly Element[] {\n return this.binding.heldControls\n }\n\n /** A submit or a save passed validation: for a subclass (the property editor tells its groups); nothing here. */\n protected onSucceeded() {}\n\n /** A control's value was written to its things: for a subclass (`ui-changed`, \"on change\" rules); nothing here. */\n protected onWritten(_write: { control: Element; name: string; value: unknown; things: readonly object[] }) {}\n\n /** Forget every prompt, `aria-invalid` and the failed state. */\n private clearErrors() {\n for (const identifier of this.fieldsShowingErrors) {\n const field = this.fields.field(identifier)\n if (!field) continue\n UIForm.fieldElementFor(field.controls)?.showErrors?.([])\n for (const control of field.controls) control.removeAttribute(\"aria-invalid\")\n }\n this.fieldsShowingErrors.clear()\n this.lastCheckFailed = false\n E.afterSolidUpdate(() => this.saveValues())\n }\n\n /** The `rules` property, as an object; fresh, so a `validate()` right after `el.rules = …` sees the new rules. */\n private get formRules(): UIT.FormRules | undefined {\n const { rules } = this\n return rules && typeof rules === \"object\" && !Array.isArray(rules) ? (rules as UIT.FormRules) : undefined\n }\n\n /** Validate `identifier` once the controls have settled (their value and validity land on a microtask). */\n private checkFieldSoon(identifier: string) {\n if (this.fieldsAwaitingCheck.has(identifier)) return\n this.fieldsAwaitingCheck.add(identifier)\n E.soon(() => {\n this.fieldsAwaitingCheck.delete(identifier)\n this.checkField(identifier)\n })\n }\n\n /** Remember the values now. */\n private saveValues() {\n this.savedValues = JSON.stringify(this.values)\n }\n\n ////////////////\n // ## Handlers\n ////////////////\n\n /** Submit: validate everything first, see the class doc. */\n @E.untracked\n private readonly onSubmit = (event: Event) => {\n this.binding.flushWaiting()\n const errors = this.validateAll()\n if (Object.keys(errors).length) {\n event.preventDefault()\n event.stopImmediatePropagation()\n const detail: UIT.FormFailureDetail = { values: this.values, errors, originalEvent: event }\n this.send(\"ui-save-failed\", detail)\n if (this.errorFocus) this.focusFirst(Object.keys(errors))\n return\n }\n const detail: UIT.FormSuccessDetail = { values: this.values, originalEvent: event }\n if (!this.send(\"ui-saving\", detail)) event.preventDefault()\n else {\n this.saveValues()\n this.onSucceeded()\n }\n }\n\n /** Native reset: prompts go once the controls have reset, and a bound object takes their values. */\n private readonly onReset = () => {\n E.afterSolidUpdate(() => {\n this.clearErrors()\n this.binding.writeAll()\n })\n }\n\n /**\n * A control changed (a light-DOM control's native `change` / `input`, an element's `ui-changed`):\n * - write it back to `value` and redraw `debug`, both a microtask later\n * - validate it for `validate=\"immediately\"`, or while it shows an error\n */\n @E.on(\"change\")\n @E.on(\"input\")\n @E.on(\"ui-changed\")\n protected onControlChanged(event: Event) {\n this.binding.onChange(event)\n E.afterSolidUpdate(() => this.changeCount++)\n const identifier = this.identifierFor(event)\n if (!identifier) return\n if (this.fieldsShowingErrors.has(identifier) || this.validate === IMMEDIATELY) this.checkFieldSoon(identifier)\n }\n\n /**\n * A control lost focus:\n * - write it back if its field writes `on leave`\n * - validate it for `validate=\"on leave\"`\n */\n @E.on(\"focusout\")\n protected onFocusOut(event: FocusEvent) {\n this.binding.onLeave(event)\n if (this.validate !== ON_LEAVE) return\n const identifier = this.identifierFor(event)\n if (identifier) this.checkFieldSoon(identifier)\n }\n\n /** `prevent-leaving`: ask while the values changed. */\n @E.untracked\n private readonly onBeforeUnload = (event: BeforeUnloadEvent) => {\n if (!this.preventLeaving) return\n if (JSON.stringify(this.values) === this.savedValues) return\n event.preventDefault()\n }\n\n /**\n * Field identifier of the control an event came from: the first control at or above its `target`.\n * - `target` is already retargeted to the form's tree: typing into a `<ui-input>` gives the `<ui-input>`.\n */\n private identifierFor(event: Event): string | undefined {\n const fields = this.fields.fields()\n for (let node = event.target as Element | null; node && node !== this.domElement; node = node.parentElement) {\n const field = fields.find((candidate) => candidate.controls.includes(node!))\n if (field) return field.identifier\n }\n return undefined\n }\n\n /** Focus the first control of the first of `identifiers`, in document order. */\n private focusFirst(identifiers: readonly string[]) {\n const field = this.fields.fields().find((candidate) => identifiers.includes(candidate.identifier))\n ;(field?.controls[0] as HTMLElement | undefined)?.focus()\n }\n\n /**\n * Server render: unwrap the author's `<form>`, when it is the DOM element's only element child\n * (its children take its place).\n * - Returns its attributes, else `undefined`.\n * - STATIC: it runs from a field initializer, before the instance is ready, and needs only the DOM element.\n */\n private static unwrapForm(domElement: Element): Record<string, string> | undefined {\n const [form, ...others] = domElement.children\n if (!form || others.length || form.localName !== \"form\") return undefined\n const attributes = Object.fromEntries([...form.attributes].map(({ name, value }) => [name, value]))\n form.replaceWith(...form.childNodes)\n return attributes\n }\n\n /**\n * The `<ui-field>` of a field's first control, if any: where its prompt shows.\n * - STATIC: pure, reads only the controls.\n */\n private static fieldElementFor(\n controls: readonly Element[]\n ): (DOMFieldElement & { rules?: unknown; schemaRules?: unknown }) | undefined {\n return (controls[0]?.closest(FIELD_SELECTOR) as DOMFieldElement | null) ?? undefined\n }\n\n /**\n * Put a control back to its starting value (no native form to reset it).\n * - STATIC: works on the control alone, no instance state.\n */\n private static resetControl(control: Element) {\n if (control instanceof HTMLInputElement) {\n if (control.type === \"checkbox\" || control.type === \"radio\") control.checked = control.defaultChecked\n else control.value = control.defaultValue\n } else if (control instanceof HTMLTextAreaElement) control.value = control.defaultValue\n else if (control instanceof HTMLSelectElement) {\n for (const option of control.options) option.selected = option.defaultSelected\n } else (control as { component?: { formReset?(): void } }).component?.formReset?.()\n }\n\n /**\n * Empty a control.\n * - STATIC: works on the control alone, no instance state.\n */\n private static clearControl(control: Element) {\n if (control instanceof HTMLInputElement) {\n if (control.type === \"checkbox\" || control.type === \"radio\") control.checked = false\n else control.value = \"\"\n } else if (control instanceof HTMLTextAreaElement) control.value = \"\"\n else if (control instanceof HTMLSelectElement) control.selectedIndex = -1\n else if ((control as { checkable?: string }).checkable)\n (control as unknown as { selected: boolean }).selected = false\n else {\n const element = control as unknown as { value: unknown }\n element.value = Array.isArray(element.value) ? [] : \"\"\n }\n }\n}\n\n/** The vocabulary's attribute getters, typed (see \"Attributes\" in `UIComponent`). */\nexport interface UIForm extends E.AttributeValues<typeof formVocabulary> {}\n\n/** `apply` / `validate` words the form acts on. */\nconst ON_SAVE = \"on save\"\nconst ON_LEAVE = \"on leave\"\nconst IMMEDIATELY = \"immediately\"\n\n/** How `UIForm.check()` reports: `\"show\"` prompts, states and events, or `\"silently\"` the verdict alone. */\ntype CheckMode = \"show\" | \"silently\"\n\n/** What `UIForm.show()` shows: one field's prompts. */\ntype ShownField = {\n /** The field checked. */\n field: Field\n /** Its prompts; `[]` clears it. */\n messages: string[]\n /** Every field's value, for the events' `detail`. */\n values: UIT.FormValues\n}\n","/**\n * The English vocabulary of `<ui-repeat>`: every name the tag uses.\n * - Its tag, its one attribute and its slot. The shape is `E.ComponentVocabulary` (`spell/ui/vocabulary`).\n * - Pure data: node imports it (`yarn site:data`, `yarn gen:root`), so `spell/ui/core` for types only.\n * - The family's grammar notes are in `UIForm.en.ts`.\n */\n\nimport type { E } from \"spell/ui/core\"\n\n/****************\n * ### `repeatVocabulary`\n * The names of `<ui-repeat>`, its children once per item of a list in a bound `<ui-form>`:\n * `<slot></slot>`, its rows in the light DOM.\n ****************/\nexport const repeatVocabulary = {\n tag: \"ui-repeat\",\n topics: [\"forms\", \"lists\", \"collections\"],\n aka: [\"repeater\", \"field array\", \"form list\", \"for each\", \"list editor\"],\n noun: \"repeat\",\n ui: false,\n description: \"A repeat shows its fields once per item of a list, each row bound to its own item.\",\n attributes: [\n {\n name: \"items\",\n group: \"content\",\n kind: \"json\",\n reflect: false,\n description:\n \"The list to repeat over, given as a property: any iterable (an array, a `Set`, spell's `List`), followed \" +\n \"as it changes. Set, it wins over `name`.\"\n },\n {\n name: \"name\",\n group: \"name\",\n kind: \"string\",\n description:\n \"The list to repeat over, by name: this property of the scope -- the `<ui-form>`'s `value`, or the item of \" +\n \"the `<ui-repeat>` row around it. Any iterable (an array, a `Set` ...).\"\n }\n ],\n events: [],\n slots: [\n {\n name: \"\",\n description:\n \"The TEMPLATE: markup copied once per item (its controls' `name`s bind to the item); a `<template>`, or \" +\n \"plain children, taken into one as it connects.\"\n }\n ],\n parts: [],\n states: [],\n texts: []\n} as const satisfies E.ComponentVocabulary\n","import type { JSX } from \"@solidjs/web\"\n\nimport { E } from \"spell/ui/core\"\nimport { repeatVocabulary } from \"./UIRepeat.en\"\nimport { FormBinding } from \"./FormBinding\"\n\nimport formCSS from \"./UIForm.css?inline\"\n\n/****************\n * ### `UIRepeat`\n * The component behind `<ui-repeat items>` / `<ui-repeat name>`: its children once per item of a list,\n * e.g. a row of fields per task in a `<ui-form value>` bound to a to-do list.\n *\n * - The list: its `items` property, when set (`<ui-repeat items={the shown tasks of the app}>` in spell);\n * else `scope[name]`, where the scope is the item of the `<ui-repeat>` row around it,\n * else the `<ui-form>`'s `value` (`FormBinding.scopeAround()`).\n * - any iterable: an array, a `Set`, an object with `[Symbol.iterator]` (spell's `List`)\n * - read inside a Solid computation, so the rows follow the list as it changes:\n * signals, Spell UI's reactive members, spell's objects\n * - none, or empty: no rows\n * - Its children are the TEMPLATE: a `<template>`, or plain markup, taken into one as it connects\n * (and children added later, which remake the rows).\n * - the template stays as its LAST child: invisible, and so no row is ever `:last-child`\n * - attribute-only markup: each row is a fresh copy, so what a framework changes in the template later\n * doesn't reach the rows (bind it through `name` instead)\n * - Rows: a copy of the template per item, in the LIGHT DOM, so the form (and the native form) sees their controls.\n * - each row's top-level elements hold its item as their scope (`FormBinding.hold()`): the form binds the row's\n * controls to it, and a `<ui-repeat>` inside reads its list from it\n * - kept by IDENTITY: an item added, removed or moved adds, removes or moves only its row's nodes\n * (with `moveBefore()` where the browser has it, so a moved row keeps focus)\n * - NO wrapper element per row: the form's rows of fields drop their bottom margin by `:last-child`,\n * which a wrapper would make true of every row\n * - ids in the template repeat in every row: label controls by `aria-label`, or by wrapping them\n * - The DOM element is `display: contents`: rows sit in the layout as if written in its place.\n ****************/\nexport class UIRepeat extends E.UIComponent<typeof repeatVocabulary> {\n @E.proto static vocabulary = repeatVocabulary\n @E.protoMerged static elementSetup = {\n styleSheets: { form: formCSS },\n delegatesFocus: false\n } satisfies Partial<E.ElementSetup>\n\n render(): JSX.Element {\n return <slot />\n }\n\n ////////////////\n // ## The template\n ////////////////\n\n /** What every row copies: kept as the last child, once taken. */\n private template: HTMLTemplateElement | undefined\n\n /** Bumped each time the template is taken: the rows are made afresh from it. */\n @E.state private accessor templateVersion = 0\n\n /**\n * While connected: take the template, and again as children are added later; returns the watch's undo.\n * - Its own `MutationObserver`, not `@watches`: it watches only while connected.\n */\n @E.whileConnected\n protected watchTemplate() {\n this.takeTemplate()\n // oxlint-disable-next-line spell-ui/no-mutation-observer -- only while connected: `@E.watches` lasts the element's whole life\n const observer = new MutationObserver(() => this.takeTemplate())\n observer.observe(this.domElement, { childList: true })\n return () => observer.disconnect()\n }\n\n /**\n * Copy every child that isn't a row into the template, then remove it; when any was, the rows are made again.\n * - Copied into the template's own (inert) document, never moved: a `ui-*` element there stays plain markup,\n * while one moved there would still finish drawing into a document that isn't the page's.\n * - The removed originals are left to finish drawing (and resolve `ready`, which a page may wait for),\n * then to be collected: nothing refers to them.\n */\n private takeTemplate() {\n const { domElement } = this\n const authored = [...domElement.childNodes].filter((node) => node !== this.template && !this.rowOf.has(node))\n if (this.template && !authored.length) return\n const template = (this.template ??= document.createElement(\"template\"))\n const { content } = template\n for (const node of authored) {\n // a `<template>` gives its content; one made by script may hold its children directly\n const copied = node instanceof HTMLTemplateElement ? [node.content, ...node.childNodes] : [node]\n for (const part of copied) content.append(content.ownerDocument.importNode(part, true))\n node.remove()\n }\n for (const row of this.rows) for (const node of row.nodes) node.remove()\n this.rows = []\n domElement.append(template)\n this.templateVersion++\n }\n\n ////////////////\n // ## Rows\n ////////////////\n\n /**\n * The items shown: `items`, else `scope[name]`, as a list; `[]` while it's none, or before the template is taken.\n * - Tracked: read inside the effect, it follows changes to the property, the scope and the list\n * (and iterating it follows the list's items).\n */\n get shownItems(): readonly unknown[] {\n if (!this.isConnected || !this.templateVersion) return []\n const list = this.items ?? this.listByName()\n return UIRepeat.isIterable(list) ? [...list] : []\n }\n\n /** `scope[name]`: the list `name` names, in the scope around the repeat. */\n private listByName(): unknown {\n if (!this.name) return undefined\n const scope = FormBinding.scopeAround(this.domElement)\n return FormBinding.isObject(scope) ? scope[this.name] : undefined\n }\n\n /** Rows shown, in list order. */\n private rows: Row[] = []\n\n /** The row each row node belongs to. */\n private readonly rowOf = new WeakMap<Node, Row>()\n\n /** The list changed: show a row per item, keeping each item's row. */\n @E.onChange(\"shownItems\")\n protected onItemsChanged(items: readonly unknown[]) {\n const { template } = this\n if (!template) return\n const unused = new Map<unknown, Row[]>()\n for (const row of this.rows) {\n const same = unused.get(row.item)\n if (same) same.push(row)\n else unused.set(row.item, [row])\n }\n const rows = items.map((item) => unused.get(item)?.shift() ?? this.newRow(item, template))\n for (const left of unused.values()) for (const row of left) for (const node of row.nodes) node.remove()\n this.rows = rows\n this.place([...rows.flatMap((row) => row.nodes), template])\n }\n\n /** A copy of the template for `item`: its top-level elements hold `item` as their scope. */\n private newRow(item: unknown, template: HTMLTemplateElement): Row {\n const copy = document.importNode(template.content, true)\n const row: Row = { item, nodes: [...copy.childNodes] }\n for (const node of row.nodes) {\n this.rowOf.set(node, row)\n if (node.nodeType === Node.ELEMENT_NODE) FormBinding.hold(node as Element, () => item)\n }\n return row\n }\n\n /** Put `nodes` in this order as the children, moving only what's out of place. */\n private place(nodes: readonly ChildNode[]) {\n const { domElement } = this\n let next = domElement.firstChild\n for (const node of nodes) {\n if (node === next) next = node.nextSibling\n else UIRepeat.move(domElement, node, next)\n }\n }\n\n ////////////////\n // ## Pure helpers\n // STATIC, every one: it reads only its arguments, so it needs no instance.\n ////////////////\n\n /** Something to repeat over: iterable, but not a string. */\n private static isIterable(value: unknown): value is Iterable<unknown> {\n return FormBinding.isObject(value) && typeof value[Symbol.iterator] === \"function\"\n }\n\n /**\n * `node` into `parent`, before `before`: `moveBefore()` when both are on the page and the browser has it,\n * so a moved row keeps its focus and state; else `insertBefore()`.\n */\n private static move(parent: Element, node: ChildNode, before: ChildNode | null) {\n const { moveBefore } = parent as Element & Partial<MovingParent>\n if (moveBefore && node.isConnected && parent.isConnected) moveBefore.call(parent, node, before)\n else parent.insertBefore(node, before)\n }\n}\n\n/** The vocabulary getters, typed (`UIComponent`'s doc). */\nexport interface UIRepeat extends E.AttributeValues<typeof repeatVocabulary> {}\n\n/** One row: the nodes copied from the template for one item. */\ntype Row = {\n /** Its item, which its controls bind to. */\n item: unknown\n /** Its top-level nodes, in order. */\n nodes: ChildNode[]\n}\n\n/** `Element.moveBefore()`, which not every browser (or TypeScript's DOM types) has yet. */\ntype MovingParent = {\n /** Move `node` before `child` (`null`: to the end), keeping its state. */\n moveBefore(node: Node, child: Node | null): void\n}\n","/**\n * The form family: defines `<ui-field>`, `<ui-fields>`, `<ui-form>` and `<ui-repeat>`.\n * - It exports their components (`UIField`, `UIFields`, `UIForm`, `UIRepeat`)\n * and DOM element classes (`DOMFieldElement`, `DOMFormElement`).\n * - SIDE EFFECT: importing it defines the tags.\n * - `<ui-repeat>` after `<ui-form>`: a repeat reads its list from the form around it, which then exists already.\n * - Also the library's `spell/ui/ui-form` entry (its size is in `notes/report.md`).\n * - NOTE: the controls are their own families (`input`, `checkbox`, `dropdown`):\n * a form validates (and binds) whatever form-associated elements and native controls it holds,\n * without importing them.\n */\n\nimport { FormBinding } from \"./FormBinding\"\nimport { DOMFieldElement, UIField } from \"./UIField\"\nimport { UIFields } from \"./UIFields\"\nimport { DOMFormElement, UIForm } from \"./UIForm\"\nimport { UIRepeat } from \"./UIRepeat\"\n\nUIField.define()\nUIFields.define()\nUIForm.define()\nUIRepeat.define()\n\nexport { UIField, UIFields, UIForm, UIRepeat, DOMFieldElement, DOMFormElement, FormBinding }\n"],"mappings":";;;;;;AAgBA,IAAawJ,KAAe;CAC1B;EAAE,MAAM;EAAS,aAAa;CAAwD;CACtF;EAAE,MAAM;EAAQ,aAAa;CAAqB;CAClD;EAAE,MAAM;EAAW,aAAa;CAAwB;CACxD;EAAE,MAAM;EAAW,aAAa;CAAwB;AAC1D,GAMaC,KAAqB;CAAC;CAAe;CAAY;AAAS,GAK1DC,KAAiB,CAAC,eAAe,SAAS,GAoB1CC,KAAQ,SAGR,iBAAb,MAA4B;CAM1B,OAAO,GAAG,GAAkE;EAC1E,OAAO,OAAO,YAAAX,EAA2B,KAAK,MAAU,CAACY,GAAOA,MAAUC,CAAK,CAAC,CAAC;CACnF;AACF,GA2BaC,IAAiB,UAAU9J,GAAqB,IC5DhD+J,IAAb,MAAa,WAAW;CAKtB;CAGA;CAEA,YAAY,EAAE,eAAY,WAAyB;EAEjD,AADA,KAAK,aAAaC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BiR,GAAA,IAFJE,GAE0B;CACnC,aAAa,EAAE,MAAM3R,EAAQ;CAC7B,gBAAgB;AAClB,CAAA,CAAA,GAHeQ,EAAAiR,GAAA,IAFJE,CAAA;AAAN,IAAMiB,KAANjB;ACjBPtF,GAAQ,OAAO,GACfU,GAAS,OAAO,GAChBiE,GAAO,OAAO,GACd4B,GAAS,OAAO"}
1
+ {"version":3,"file":"ui-form.js","names":["UIT.FIELD_HOST_STATE","E.byDocumentOrder","UIT.DISABLED_STATE","_init","E.untracked","E.after","__name","UIT.FormStates","_init","<Show when={this.hasRow} fallback={this.controlSlotElement()}>\n {this.labelRow()}\n <div class={CLASSES.control} part={this.partForName(\"control\")}>\n {this.controlStart()}\n {this.controlSlotElement()}\n </div>\n </Show>","this","this.labelRow()","<div class={CLASSES.control} part={this.partForName(\"control\")}>\n {this.controlStart()}\n {this.controlSlotElement()}\n </div>","part={this.partForName(\"control\")}","<div class={this.rootClass} part={this.partForName(\"field\")} inert={this.disabled}>\n <Show when={this.hasRow} fallback={this.controlSlotElement()}>\n {this.labelRow()}\n <div class={CLASSES.control} part={this.partForName(\"control\")}>\n {this.controlStart()}\n {this.controlSlotElement()}\n </div>\n </Show>\n <Show when={this.hasHint && !this.hasHintInRow}>\n <div class={CLASSES.hint} part={this.partForName(\"hint\")}>\n <slot name={this.slotForName(\"hint\")}>{this.hintText}</slot>\n </div>\n </Show>\n <Show when={this.errors.length}>\n <div class={CLASSES.error} part={this.partForName(\"error\")} role=\"alert\">\n <For each={this.errors}>{(message) => <div class={UIT.MESSAGE}>{message}</div>}</For>\n </div>\n </Show>\n </div>","<Show when={this.hasHint && !this.hasHintInRow}>\n <div class={CLASSES.hint} part={this.partForName(\"hint\")}>\n <slot name={this.slotForName(\"hint\")}>{this.hintText}</slot>\n </div>\n </Show>","this.hasHint && !this.hasHintInRow","part={this.partForName(\"hint\")}","name={this.slotForName(\"hint\")}","<div class={CLASSES.hint} part={this.partForName(\"hint\")}>\n <slot name={this.slotForName(\"hint\")}>{this.hintText}</slot>\n </div>","<Show when={this.errors.length}>\n <div class={CLASSES.error} part={this.partForName(\"error\")} role=\"alert\">\n <For each={this.errors}>{(message) => <div class={UIT.MESSAGE}>{message}</div>}</For>\n </div>\n </Show>","<For each={this.errors}>{(message) => <div class={UIT.MESSAGE}>{message}</div>}</For>","part={this.partForName(\"error\")}","<div class={CLASSES.error} part={this.partForName(\"error\")} role=\"alert\">\n <For each={this.errors}>{(message) => <div class={UIT.MESSAGE}>{message}</div>}</For>\n </div>","part={this.partForName(\"field\")}","inert={this.disabled}","<Show when={this.hasActions}>\n <span class={CLASSES.actions} part={this.partForName(\"actions\")}>\n <slot name={this.slotForName(\"actions\")} />\n </span>\n </Show>","part={this.partForName(\"actions\")}","name={this.slotForName(\"actions\")}","<span class={CLASSES.actions} part={this.partForName(\"actions\")}>\n <slot name={this.slotForName(\"actions\")} />\n </span>","<div class={CLASSES.row} part={this.partForName(\"row\")}>\n <span\n class={CLASSES.label}\n part={this.partForName(\"label\")}\n title={this.labelTitle}\n onClick={this.onLabelClick}\n >\n <slot name={this.slotForName(\"label\")}>{this.labelText}</slot>\n </span>\n <Show when={this.hasActions}>\n <span class={CLASSES.actions} part={this.partForName(\"actions\")}>\n <slot name={this.slotForName(\"actions\")} />\n </span>\n </Show>\n <Show when={this.hasOutput}>\n <span class={CLASSES.output} part={this.partForName(\"output\")}>\n <slot name={this.slotForName(\"output\")}>{this.output}</slot>\n </span>\n </Show>\n {this.rowEnd()}\n <Show when={this.hasHint && this.hasHintInRow}>\n <span class={CLASSES.hint} part={this.partForName(\"hint\")} title={this.hintText}>\n <slot name={this.slotForName(\"hint\")}>{this.hintText}</slot>\n </span>\n </Show>\n <Show when={this.hasDescription}>\n <span\n ref={(info) => E.TopLayerTip.showIn(info, `.${CLASSES.info}`, { showOnClick: true })}\n class={CLASSES.info}\n part={this.partForName(\"info\")}\n tabindex=\"0\"\n role=\"img\"\n aria-label={this.translationForKey(\"info\", { label: this.labelText ?? \"\" })}\n aria-describedby={TIP_ID}\n >\n {this.infoGlyph.svg}\n <span id={TIP_ID} class={CLASSES.tip} part={this.partForName(\"tip\")} role=\"tooltip\">\n <slot name={this.slotForName(\"description\")}>{this.descriptionText}</slot>\n </span>\n </span>\n </Show>\n <Show when={this.unsavedText}>\n <span\n class={CLASSES.unsaved}\n part={this.partForName(\"unsaved\")}\n title={this.unsavedText}\n role=\"img\"\n aria-label={this.unsavedText}\n >\n {this.unsavedGlyph.svg}\n </span>\n </Show>\n </div>","<Show when={this.hasOutput}>\n <span class={CLASSES.output} part={this.partForName(\"output\")}>\n <slot name={this.slotForName(\"output\")}>{this.output}</slot>\n </span>\n </Show>","part={this.partForName(\"output\")}","name={this.slotForName(\"output\")}","<span class={CLASSES.output} part={this.partForName(\"output\")}>\n <slot name={this.slotForName(\"output\")}>{this.output}</slot>\n </span>","<Show when={this.hasHint && this.hasHintInRow}>\n <span class={CLASSES.hint} part={this.partForName(\"hint\")} title={this.hintText}>\n <slot name={this.slotForName(\"hint\")}>{this.hintText}</slot>\n </span>\n </Show>","this.hasHint && this.hasHintInRow","title={this.hintText}","<span class={CLASSES.hint} part={this.partForName(\"hint\")} title={this.hintText}>\n <slot name={this.slotForName(\"hint\")}>{this.hintText}</slot>\n </span>","<Show when={this.hasDescription}>\n <span\n ref={(info) => E.TopLayerTip.showIn(info, `.${CLASSES.info}`, { showOnClick: true })}\n class={CLASSES.info}\n part={this.partForName(\"info\")}\n tabindex=\"0\"\n role=\"img\"\n aria-label={this.translationForKey(\"info\", { label: this.labelText ?? \"\" })}\n aria-describedby={TIP_ID}\n >\n {this.infoGlyph.svg}\n <span id={TIP_ID} class={CLASSES.tip} part={this.partForName(\"tip\")} role=\"tooltip\">\n <slot name={this.slotForName(\"description\")}>{this.descriptionText}</slot>\n </span>\n </span>\n </Show>","ref={(info) => E.TopLayerTip.showIn(info, `.${CLASSES.info}`, { showOnClick: true })}","<span\n ref={(info) => E.TopLayerTip.showIn(info, `.${CLASSES.info}`, { showOnClick: true })}\n class={CLASSES.info}\n part={this.partForName(\"info\")}\n tabindex=\"0\"\n role=\"img\"\n aria-label={this.translationForKey(\"info\", { label: this.labelText ?? \"\" })}\n aria-describedby={TIP_ID}\n >\n {this.infoGlyph.svg}\n <span id={TIP_ID} class={CLASSES.tip} part={this.partForName(\"tip\")} role=\"tooltip\">\n <slot name={this.slotForName(\"description\")}>{this.descriptionText}</slot>\n </span>\n </span>","part={this.partForName(\"info\")}","aria-label={this.translationForKey(\"info\", { label: this.labelText ?? \"\" })}","class={CLASSES.tip}","part={this.partForName(\"tip\")}","name={this.slotForName(\"description\")}","<Show when={this.unsavedText}>\n <span\n class={CLASSES.unsaved}\n part={this.partForName(\"unsaved\")}\n title={this.unsavedText}\n role=\"img\"\n aria-label={this.unsavedText}\n >\n {this.unsavedGlyph.svg}\n </span>\n </Show>","part={this.partForName(\"unsaved\")}","title={this.unsavedText}","aria-label={this.unsavedText}","<span\n class={CLASSES.unsaved}\n part={this.partForName(\"unsaved\")}\n title={this.unsavedText}\n role=\"img\"\n aria-label={this.unsavedText}\n >\n {this.unsavedGlyph.svg}\n </span>","part={this.partForName(\"row\")}","class={CLASSES.label}","part={this.partForName(\"label\")}","title={this.labelTitle}","name={this.slotForName(\"label\")}","ref={(element) => this.controlSlot = element}","<slot ref={(element) => this.controlSlot = element} onSlotChange={this.onControlChange} />","_tmpl$","_tmpl$2","_tmpl$3","_a","_init","_elementSetup_dec","_vocabulary_dec","_b","_init2","E.DOMElement","E.untracked","__name","E.UIComponent","E.proto","E.protoMerged","E.state","E.cssState","E.onChange","E.SlotContent","E.IconGlyph","_$createComponent","_$memo","_$readShallow","_$setAttribute","_$getOwner","UIT.MESSAGE","formCSS","fieldCSS","_$delegateEvents","UIT.FormStates","this","part={this.partForName(\"fields\")}","inert={this.disabled}","<div class={this.rootClass} part={this.partForName(\"fields\")} inert={this.disabled}>\n <slot />\n </div>","_tmpl$","_elementSetup_dec","_vocabulary_dec","_a","_init","E.UIComponent","E.proto","E.protoMerged","_$getOwner","_$readShallow","_$setAttribute","__name","formCSS","UIT.FormStates","UIT.StackWithValues","_nativeForm_dec","_init","detail","rules","this","part={this.partForName(\"form\")}","inert={this.disabled || this.loading}","aria-busy={this.loading ? \"true\" : void 0}","<div\n class={this.rootClass}\n part={this.partForName(\"form\")}\n inert={this.disabled || this.loading}\n aria-busy={this.loading ? \"true\" : void 0}\n >\n <slot />\n {this.debugBox()}\n </div>","<Show when={this.debug}>\n <figure class=\"debug\">\n <figcaption>{this.debugCaption}</figcaption>\n <pre part={this.partForName(\"debug\")}>{this.debugText}</pre>\n </figure>\n </Show>","<figure class=\"debug\">\n <figcaption>{this.debugCaption}</figcaption>\n <pre part={this.partForName(\"debug\")}>{this.debugText}</pre>\n </figure>","<form\n {...rest}\n class={[this.rootClass, authorClass]}\n part={this.partForName(\"form\")}\n inert={this.disabled || this.loading}\n aria-busy={this.loading ? \"true\" : void 0}\n >\n <slot />\n </form>","_tmpl$","_a","_init","_elementSetup_dec","_vocabulary_dec","E.DOMElement","E.untracked","__name","E.UIComponent","E.proto","E.protoMerged","E.state","E.cssState","E.whileConnected","E.on","E.onChange","_$getOwner","_$readShallow","_$setAttribute","_$createComponent","formCSS","<slot />","E.UIComponent","E.proto","E.protoMerged","E.state","E.whileConnected","E.onChange","_$getOwner","__name","formCSS","__name$1","__publicField","__decorateElement","MESSAGE","__decoratorMetadata","FormStates","__runInitializers","__privateAdd","FIELD_HOST_STATE","StackClasses","DISABLED_STATE","StackWithValues","__decoratorStart","getOwner$1","STATE_STATES","ValidationTriggers","FormApplyModes","ERROR","state","shown","FIELD_SELECTOR","FormFields","domElement","form","candidates","CONTROL_SELECTOR","inside","el","byDocumentOrder","byIdentifier","control","identifier","list","controls","field","values","fields","labels","text","label","live","errors","flags","spec","rules","result","FormComponent","error","validity","message","VALIDITY_FLAGS","flag","element","FORM_VALUE_STATE","first","chosen","value","entry","rule","EMPTY","NOT_EMPTY","BUTTON_TYPES","name","UNNAMED_NOTED","Warnings","option","Converters","_dropHeld_dec","_saveHeld_dec","_writeBack_dec","untracked","_init$4","_FormBinding","event","apply","isCommitted","DOMElement","binding","scope","tag","timer","Reactive","createEffect","UNBOUND","MIXED","afterSolidUpdate","after","delay","targets","current","next","target","owner","key","node","changes","things","read","keys","delayed","DEFAULT_DELAY","isMixed","MIXED_TEXT","own","NUMBER_TYPES","type","number","FormBinding","fieldVocabulary","UIForm_default","UIField_default","_tmpl$$3","_tmpl$2$1","_tmpl$3$1","_tmpl$4","_tmpl$5","_tmpl$6","_tmpl$7","_tmpl$8","_tmpl$9","_tmpl$10","_mixedText_dec","_shownLabel_dec","_errors_dec","_a$3","_init$3","_onControlChange_dec","_onLabelChanged_dec","_isField_dec","_isReadOnly_dec","_isMixed_dec","_showErrors_dec","_formErrors_dec","_elementSetup_dec$3","_vocabulary_dec$3","_b$1","_init2$1","_formErrors","_DOMFieldElement","messages","DOMFieldElement","_UIField","UIComponent","proto","protoMerged","cssState","onChange","SlotContent","IconGlyph","INFO_ICON","UNSAVED_ICON","fromForm","index","_self$","_el$","_el$5","_el$8","_el$10","insert","createComponent","Show","memo","_el$2","_el$3","_el$4","effect","readShallow","CLASSES","className","_p$","t","setAttribute","_el$6","_el$7","a","_el$9","For","_el$11","_v$","_$p","_self$2","_el$12","_el$13","_el$14","_el$17","_el$20","_el$21","_el$24","_el$28","_el$30","addEvent","_el$15","_el$16","_el$18","_el$19","_el$22","_el$23","o","_el$25","_el$26","_el$27","TIP_ID","ref","TopLayerTip","info","i","n","_el$29","_self$3","_el$31","isReady","UIField","NAMED_ATTRIBUTES","delegateEvents","fieldsVocabulary","_tmpl$$2","_elementSetup_dec$2","_vocabulary_dec$2","_a$2","_init$2","_UIFields","UIFields","formVocabulary","_tmpl$$1","_tmpl$2","_tmpl$3","_nativeForm_dec","_a$1","_init$1","_onBeforeUnload_dec","_onFocusOut_dec","_onControlChanged_dec","_onSubmit_dec","_passes_dec","_cancel_dec","_save_dec","_reset_dec","_changeCount_dec","_onBindingChanged_dec","_onNativeFormChanged_dec","_findForm_dec","_onContentChanged_dec","_onFormValueReady_dec","_watchForm_dec","_nativeForm_dec2","_isRoot_dec","_hasHeldChanges_dec","_isFluid_dec","_lastCheckFailed_dec","_elementSetup_dec$1","_vocabulary_dec$1","_b","_init2","_lastCheckFailed","_hasHeldChanges","_nativeForm","_changeCount","_DOMFormElement","DOMFormElement","_UIForm","whileConnected","on","ON_SAVE","write","isServer","detail2","detail","authorClass","rest","attributes","spread","\"class\"","observer","noValidate","isBound","connected","mode","candidate","formRules","rules2","ownList","theirs","soon","IMMEDIATELY","ON_LEAVE","identifiers","others","UIForm","repeatVocabulary","_tmpl$","_onItemsChanged_dec","_watchTemplate_dec","_templateVersion_dec","_elementSetup_dec","_vocabulary_dec","_a","_init","_templateVersion","_UIRepeat","authored","template","copied","part","content","row","unused","same","rows","items","item","left","nodes","parent","moveBefore","before","UIRepeat"],"sources":["../src/components/ui-form/UIForm.types.ts","../src/components/ui-form/FormFields.ts","../src/components/ui-form/FormBinding.ts","../src/components/ui-form/UIField.en.ts","../src/components/ui-form/UIForm.css?inline","../src/components/ui-form/UIField.css?inline","../src/components/ui-form/UIField.tsx","../src/components/ui-form/UIFields.en.ts","../src/components/ui-form/UIFields.tsx","../src/components/ui-form/UIForm.en.ts","../src/components/ui-form/UIForm.tsx","../src/components/ui-form/UIRepeat.en.ts","../src/components/ui-form/UIRepeat.tsx","../src/components/ui-form/index.ts"],"sourcesContent":["/**\n * The `ui-form` family's loose constants and types: what its components, its vocabularies and `FormFields` share.\n * - Pure data, at the bottom of the folder's imports, so node can load it (`yarn site:data`):\n * - `import type` only, its vocabularies too: they value-import this file\n * - `UIT` by value, straight from `components.types`\n * - A word only ONE class uses sits below that class instead (epic `wwod-spell-ui`, Q18).\n */\n\nimport type { E } from \"spell/ui/core\"\nimport * as UIT from \"spell/ui/components/components.types\"\n\n////////////////\n// ## Vocabulary pieces\n////////////////\n\n/** The DOM element's states for the form states, so page CSS (`native.css`) can show messages by them. */\nexport const STATE_STATES = [\n { name: \"error\", description: \"In the error state (attribute, or failed validation).\" },\n { name: \"info\", description: \"In the info state.\" },\n { name: \"success\", description: \"In the success state.\" },\n { name: \"warning\", description: \"In the warning state.\" }\n] as const\n\n/**\n * When `<ui-form>`'s fields validate (its `validate`): as each changes, as the cursor leaves each,\n * or only on Save / submit.\n */\nexport const ValidationTriggers = [\"immediately\", \"on leave\", \"on save\"] as const\n/** One of `ValidationTriggers`, e.g. `\"on leave\"`. */\nexport type ValidationTrigger = (typeof ValidationTriggers)[number]\n\n/** When `<ui-form>`'s edits land in the thing (its `apply`): at once, or together on Save. */\nexport const FormApplyModes = [\"immediately\", \"on save\"] as const\n/** One of `FormApplyModes`. */\nexport type FormApplyMode = (typeof FormApplyModes)[number]\n\n/**\n * When a field takes an edit (`<ui-field apply>`), read from its text by `FormBinding.applyOf()`.\n * - `immediately`: each change\n * - `delayed`: after a pause in typing of `delay` ms\n * - `on leave`: when the cursor leaves the field\n */\nexport type FieldApply = { mode: \"immediately\" } | { mode: \"delayed\"; delay: number } | { mode: \"on leave\" }\n\n////////////////\n// ## Form states\n////////////////\n\n// Each of `UIT.FormStates` is also the state the DOM element of a form, field or fields carries for it\n// (`:state(error)` ...; `FormStateFlags`).\n\n/** The validation state: failed validation shows it over the author's `state`. */\nexport const ERROR = \"error\"\n\n/** The form states as `:state()`s: `<ui-form>`, `<ui-fields>` and `<ui-field>` each show one. */\nexport class FormStateFlags {\n /**\n * Every form state, only `shown` on: `{ error: true, info: false, success: false, warning: false }`.\n * - What each component's `cssStates()` hands `UIComponent`; each works out its own `shownState`.\n * - Static: pure.\n */\n static of(shown: UIT.FormState | undefined): Record<UIT.FormState, boolean> {\n return Object.fromEntries(UIT.FormStates.map((state) => [state, state === shown])) as Record<UIT.FormState, boolean>\n }\n}\n\n////////////////\n// ## Fields\n////////////////\n\n/** One named field: its controls, in document order. */\nexport type Field = {\n /** name (or id) */\n identifier: string\n /** its controls: one, or several of one name (checkboxes, radios) */\n controls: Element[]\n}\n\n/** `UIT.FormFieldRules`, normalized. */\nexport type FieldSpec = {\n /** every rule, `empty` renamed `notEmpty` */\n rules: E.ValidationRule[]\n /** skip the rules while the field is blank */\n optional: boolean\n /** skip the rules while this other field is blank */\n depends?: string\n /** the field it's for, when its key in `rules` isn't */\n identifier?: string\n}\n\n/** A control's `<ui-field>`. */\nexport const FIELD_SELECTOR = `:state(${UIT.FIELD_HOST_STATE})`\n","import { E, UIT } from \"spell/ui/core\"\nimport { F } from \"spell/ui/forms\"\nimport { FIELD_SELECTOR, type Field, type FieldSpec } from \"./UIForm.types\"\n\n/****************\n * ### `FormFields`\n * What `<ui-form>` validates, read from the DOM: its controls grouped by name (else id),\n * their values and labels, and one field's errors.\n * - Plain DOM, no Solid, so it reads light-DOM natives and `ui-*` elements alike.\n * - Controls:\n * - the native form's `elements` (which include form-associated `ui-*` elements),\n * those inside the `<ui-form>` when the form is outside it\n * - without a form, every control inside\n * - Buttons are skipped.\n * A `ui-*` element counts when it has the form-control API (`validity`), so `<ui-button>` doesn't.\n * - Values, Fomantic's `get.values()` shape:\n * - one checkbox (`ui-checkbox` / native): its value when chosen, else its `off-value` or `false`\n * - `true` for the native default, `on`, with no `value` attribute\n * - several checkboxes of one name:\n * what each submits, the chosen values and the unchosen ones' off-values\n * - a `ui-*` element's values come from the element (`chosenValue` / `unchosenValue`),\n * so its class's defaults count\n * - radios: the chosen one's value, else `null` (Fomantic's, kept: pages read it, and JSON keeps it)\n * - anything else: its `value` (`string`, or `string[]` for a multiple dropdown / select); several => a list\n * - Errors of a field, de-duplicated:\n * - its `rules` through `Validator`, with every value for `match` / `different`,\n * and every label for their prompts\n * - THEN each control's own constraint validation (`validationMessage`)\n * - Its readings of ONE control are public, as `FormBinding` reads controls the same way:\n * `nameOf()`, `isCheckable()`, `isRadio()`, `isChosen()`, `chosenValueFor()`.\n ****************/\nexport class FormFields {\n /**\n * The `<ui-form>`'s DOM element.\n * - STATIC for the object's life: a different DOM element is a different `FormFields`.\n */\n private readonly domElement: HTMLElement\n\n /** The native form, when there is one; read on every call, as the form comes and goes. */\n private readonly form: () => HTMLFormElement | undefined\n\n constructor({ domElement, form }: FormFieldsProps) {\n this.domElement = domElement\n this.form = form\n }\n\n ////////////////\n // ## Reading\n ////////////////\n\n /** Every control, in document order. */\n controls(): Element[] {\n const form = this.form()\n const candidates = form\n ? [...form.elements]\n : [...this.domElement.querySelectorAll(CONTROL_SELECTOR), ...this.customControls()]\n const inside =\n !form || !form.contains(this.domElement) ? candidates : candidates.filter((el) => this.domElement.contains(el))\n return [...new Set(inside)].filter(FormFields.isControl).sort(E.byDocumentOrder)\n }\n\n /** Fields by identifier, in document order. */\n fields(): Field[] {\n const byIdentifier = new Map<string, Element[]>()\n for (const control of this.controls()) {\n const identifier = FormFields.identifierFor(control)\n if (!identifier) continue\n const list = byIdentifier.get(identifier)\n if (list) list.push(control)\n else byIdentifier.set(identifier, [control])\n }\n return [...byIdentifier].map(([identifier, controls]) => ({ identifier, controls }))\n }\n\n /** The field named `identifier`, if any. */\n field(identifier: string): Field | undefined {\n return this.fields().find((field) => field.identifier === identifier)\n }\n\n /** Every field's value, see the class doc. */\n values(fields: readonly Field[] = this.fields()): UIT.FormValues {\n const values: UIT.FormValues = {}\n for (const { identifier, controls } of fields) values[identifier] = FormFields.valueFor(controls)\n return values\n }\n\n /**\n * Human label of a field, the first there is:\n * - its controls' `<label>`s\n * - its `<ui-field>`'s label: a `<label>` in it, else the one it draws\n * - the identifier\n */\n label({ identifier, controls }: Field): string {\n for (const control of controls) {\n const labels = (control as { labels?: NodeList | null }).labels\n const text = labels ? [...labels].map((label) => label.textContent?.trim() ?? \"\").find(Boolean) : undefined\n if (text) return text\n }\n const field = controls[0]?.closest(FIELD_SELECTOR)\n const fieldLabel =\n field?.querySelector(\":scope > label\")?.textContent?.trim() ||\n (field as { shownLabel?: string } | null)?.shownLabel\n if (fieldLabel) return fieldLabel\n const own =\n controls.length === 1 && FormFields.isCheckable(controls[0]!) ? controls[0]!.textContent?.trim() : undefined\n return own || identifier\n }\n\n /** Labels of every field, for prompts. */\n labels(fields: readonly Field[]): Record<string, string> {\n const labels: Record<string, string> = {}\n for (const field of fields) labels[field.identifier] = this.label(field)\n return labels\n }\n\n ////////////////\n // ## Validating\n ////////////////\n\n /**\n * Prompts of one field, `[]` when it passes.\n * - `rules` for it (by identifier, or a spec whose `identifier` names it), then the controls' own validity.\n * - Skipped:\n * - controls that don't validate (`willValidate` false: disabled, readonly, fieldset-disabled)\n * - fields in a disabled `<ui-field>`\n */\n errors({ field, rules, values, labels }: FieldErrorsParams): string[] {\n const live = field.controls.filter((control) => FormFields.willValidate(control))\n if (!live.length) return []\n const errors: string[] = []\n const flags = new Set<string>()\n const spec = FormFields.specFor(rules, field.identifier)\n if (spec && !(spec.depends && FormFields.isBlank(values[spec.depends]))) {\n const result = F.FormComponent.validator.validate(values[field.identifier], spec.rules, {\n name: field.identifier,\n label: labels[field.identifier],\n fieldValues: values,\n fieldLabels: labels,\n optional: spec.optional\n })\n for (const error of result.errors) {\n errors.push(error.message)\n flags.add(error.flag)\n }\n }\n for (const control of live) {\n const validity = (control as { validity?: ValidityState }).validity\n const message = (control as { validationMessage?: string }).validationMessage\n if (!validity || validity.valid || !message || errors.includes(message)) continue\n // a rule already said it (`email` rule + `type=\"email\"`): the rule's prompt wins\n if (VALIDITY_FLAGS.filter((flag) => validity[flag]).every((flag) => flags.has(flag))) continue\n errors.push(message)\n }\n return errors\n }\n\n ////////////////\n // ## Helpers\n ////////////////\n\n /** Form-associated custom elements inside the `<ui-form>`: no selector reaches them. */\n private customControls(): Element[] {\n return [...this.domElement.querySelectorAll(\"*\")].filter(\n (element) =>\n (element.constructor as { formAssociated?: boolean }).formAssociated || element.matches(FORM_VALUE_STATE)\n )\n }\n\n ////////////////\n // ## Pure helpers\n // STATIC, every one: it reads only its arguments, so it needs no instance.\n ////////////////\n\n /** The value of a field made of `controls`; `null` for none (Fomantic's shape, see the class doc). */\n static valueFor(controls: readonly Element[]): E.FieldValue {\n const [first] = controls\n if (!first) return null\n if (FormFields.isRadio(first)) {\n const chosen = controls.find((control) => FormFields.isChosen(control))\n return chosen ? FormFields.chosenValueFor(chosen) : null\n }\n if (FormFields.isCheckable(first)) {\n if (controls.length === 1) {\n if (!FormFields.isChosen(first)) return FormFields.unchosenValueFor(first) ?? false\n const value = FormFields.chosenValueFor(first)\n // Fomantic's `value || true`, as our attribute reading always had it (epic `wwod-spell-ui`, J44's aside)\n return value === \"on\" && !first.hasAttribute(\"value\") ? true : value\n }\n return controls.flatMap((control) => {\n const value = FormFields.isChosen(control)\n ? FormFields.chosenValueFor(control)\n : FormFields.unchosenValueFor(control)\n return value === undefined ? [] : [value]\n })\n }\n const values = controls.map((control) => FormFields.ownValueFor(control))\n return values.length === 1 ? values[0]! : values.flat()\n }\n\n /** `rules` for `identifier`, normalized; `empty` => `notEmpty`. */\n private static specFor(rules: UIT.FormRules | undefined, identifier: string): FieldSpec | undefined {\n if (!rules) return undefined\n let entry: UIT.FormFieldRules | undefined = rules[identifier]\n if (entry === undefined) {\n entry = Object.values(rules).find(\n (value) =>\n typeof value === \"object\" && !Array.isArray(value) && \"rules\" in value && value.identifier === identifier\n )\n }\n if (entry === undefined) return undefined\n const spec: FieldSpec =\n typeof entry === \"object\" && !Array.isArray(entry) && \"rules\" in entry\n ? { rules: [...entry.rules], optional: !!entry.optional, depends: entry.depends, identifier: entry.identifier }\n : { rules: Array.isArray(entry) ? [...entry] : [entry as E.ValidationRule], optional: false }\n spec.rules = spec.rules.map(FormFields.renameEmpty)\n return spec\n }\n\n /** Fomantic's deprecated `empty` rule is `notEmpty`. */\n private static renameEmpty(rule: E.ValidationRule): E.ValidationRule {\n if (typeof rule === \"string\") return rule === EMPTY ? NOT_EMPTY : rule\n return rule.type === EMPTY ? { ...rule, type: NOT_EMPTY } : rule\n }\n\n /** Blank, as `depends` sees it. */\n static isBlank(value: E.FieldValue): boolean {\n return value == null || value === false || value === \"\" || (Array.isArray(value) && !value.length)\n }\n\n /** A control `<ui-form>` reads: native value controls, and `ui-*` elements with the form-control API. */\n static isControl(element: Element): boolean {\n if (element instanceof HTMLInputElement) return !BUTTON_TYPES.has(element.type)\n if (element instanceof HTMLSelectElement || element instanceof HTMLTextAreaElement) return true\n if (element instanceof HTMLButtonElement || element instanceof HTMLFieldSetElement) return false\n if (\"validity\" in element && (element.constructor as { formAssociated?: boolean }).formAssociated === true) {\n return true\n }\n // a `ui-*` element holding a form value without being a form control: a segmented `<ui-menu name>`\n return element.matches(FORM_VALUE_STATE)\n }\n\n /**\n * Its `name`: what the form's rules, messages and value know it by.\n * - Never its `id`, which finds an element, never data (debut Q19, epic `ui-gaps` P5).\n * - SIDE EFFECT: a control with an `id` but no `name` is noted in the console, once each, rather than half-working.\n */\n private static identifierFor(control: Element): string | undefined {\n const name = FormFields.nameOf(control)\n if (!name && control.id && !UNNAMED_NOTED.has(control)) {\n UNNAMED_NOTED.add(control)\n E.Warnings.warn(\"<ui-form>\", `#${control.id} has no name, so the form skips it; give it name=\"...\"`)\n }\n return name\n }\n\n /** Its `name` (the property, else the attribute), if any: what `<ui-form value>` binds it to. */\n static nameOf(control: Element): string | undefined {\n const name = (control as { name?: unknown }).name\n return (typeof name === \"string\" && name) || control.getAttribute(\"name\") || undefined\n }\n\n /** A checkbox (native, or a `ui-*` element saying so). */\n static isCheckable(control: Element): boolean {\n if (control instanceof HTMLInputElement) return control.type === \"checkbox\" || control.type === \"radio\"\n return !!(control as { checkable?: string }).checkable\n }\n\n /** A radio (native, or a `ui-*` element saying so). */\n static isRadio(control: Element): boolean {\n if (control instanceof HTMLInputElement) return control.type === \"radio\"\n return (control as { checkable?: string }).checkable === \"radio\"\n }\n\n /** Chosen now: its `checked`, the same in every language (a `ui-*` checkbox's `selected`). */\n static isChosen(control: Element): boolean {\n return !!(control as { checked?: boolean }).checked\n }\n\n /**\n * What a chosen checkable submits: a `ui-*` element's `chosenValue`, else its `value` attribute, else `on` (native).\n */\n static chosenValueFor(control: Element): string {\n return (control as CheckableElement).chosenValue ?? control.getAttribute(\"value\") ?? \"on\"\n }\n\n /** What an unchosen checkable submits: a `ui-*` element's `unchosenValue` (`off-value`); a native: nothing. */\n private static unchosenValueFor(control: Element): string | undefined {\n return (control as CheckableElement).unchosenValue\n }\n\n /** The value of a non-checkable control. */\n private static ownValueFor(control: Element): string | string[] {\n if (control instanceof HTMLSelectElement && control.multiple) {\n return [...control.selectedOptions].map((option) => option.value)\n }\n const value = (control as { value?: unknown }).value\n if (Array.isArray(value)) return value.map(String)\n // a `multiple` element's attribute value is a list in one string (`value=\"a,b\"`)\n if (typeof value === \"string\" && control.hasAttribute(\"multiple\") && !(control instanceof HTMLInputElement)) {\n return E.Converters.list(value)\n }\n if (typeof value === \"string\") return value\n return typeof value === \"number\" || typeof value === \"boolean\" ? String(value) : \"\"\n }\n\n /** Takes part in validation? */\n private static willValidate(control: Element): boolean {\n if ((control as { willValidate?: boolean }).willValidate === false) return false\n return !control.closest(FIELD_SELECTOR)?.matches(UIT.DISABLED_STATE)\n }\n}\n\n/** What `new FormFields()` reads: the collaborators it works over. */\nexport type FormFieldsProps = {\n /** The `<ui-form>`'s DOM element. */\n domElement: HTMLElement\n /** The native form, when there is one; read on every call. */\n form: () => HTMLFormElement | undefined\n}\n\n/**\n * What a checkable `ui-*` element says it submits (`DOMCheckElement`).\n * - Structural, so this file never imports that family.\n */\ntype CheckableElement = Element & {\n /** submitted while chosen; none before its component exists */\n chosenValue?: string\n /** submitted while unchosen; none ~== nothing */\n unchosenValue?: string\n}\n\n/** What `FormFields.errors()` checks one field against. */\nexport type FieldErrorsParams = {\n /** The field to check. */\n field: Field\n /** `<ui-form>`'s `rules`, if any. */\n rules: UIT.FormRules | undefined\n /** Every field's value, for `match` / `different` / `depends`. */\n values: UIT.FormValues\n /** Every field's label, for prompts. */\n labels: Record<string, string>\n}\n\n/** Native controls. */\nconst CONTROL_SELECTOR = \"input, select, textarea\"\n\n/** Constraint Validation flags a control may raise. */\nconst VALIDITY_FLAGS: readonly (keyof ValidityStateFlags)[] = [\n \"valueMissing\",\n \"typeMismatch\",\n \"patternMismatch\",\n \"tooLong\",\n \"tooShort\",\n \"rangeUnderflow\",\n \"rangeOverflow\",\n \"stepMismatch\",\n \"badInput\",\n \"customError\"\n]\n\n/** Fomantic's old name for `notEmpty`. */\nconst EMPTY = \"empty\"\n\n/** What `EMPTY` means. */\nconst NOT_EMPTY = \"notEmpty\"\n\n/** Native input types that are buttons, not values. */\nconst BUTTON_TYPES = new Set([\"submit\", \"reset\", \"button\", \"image\"])\n\n/** The controls `identifierFor()` already noted as unnamed: each is noted once. */\nconst UNNAMED_NOTED = new WeakSet<Element>()\n\n/** The state a `ui-*` element that holds a form value, but isn't form-associated, carries (`<ui-menu>`'s). */\nconst FORM_VALUE_STATE = \":state(form-value)\"\n","// oxlint-disable-next-line spell-ui/no-solid-effect -- a helper class, not a component: one effect per bound control, in a root of its own\nimport { createEffect } from \"solid-js\"\n\nimport { E, UIT } from \"spell/ui/core\"\nimport { FormFields } from \"./FormFields\"\nimport { FIELD_SELECTOR, type FieldApply } from \"./UIForm.types\"\n\n/****************\n * ### `FormBinding`\n * Ties a `<ui-form value>`'s named controls to an object (or to many), both ways:\n * each control shows its property of the object, and writes it back as the person changes it.\n *\n * - What a control binds to, its SCOPE: the nearest scope holder at or above it.\n * - the `<ui-form>` holds its `value`\n * - a `<ui-repeat>` row's elements hold the row's item\n * - they say so through `FormBinding.hold()`, and `scopeAround()` finds one:\n * so a nested `<ui-repeat>` reads its list from its own row's item\n * - MANY THINGS: a scope that's a list (an array) binds each control to every thing in it.\n * - a control shows the value they all agree on\n * - when they don't, it shows blank: its `<ui-field>` gets `mixed`, and the control a \"Mixed\" placeholder\n * - a write sets the property on all of them\n * - Object => control: one Solid effect per control, reading `scope[name]`.\n * - So it follows whatever Solid can: signals, Spell UI's reactive members,\n * spell's objects (their page bridges spell cells into Solid)\n * - a checkbox / toggle shows `!!value` (`selected`)\n * - a radio is chosen while `value` is its own value\n * - anything else shows `value` (`\"\"` for nullish)\n * - A dotted `name` reaches into nested things: `name=\"font.size\"` shows and writes `scope.font.size`.\n * - Control => object: a change from a bound control (`input`, `change`, `ui-changed`) writes `scope[name]`,\n * (a control that `settlesItself`, a `<ui-search>`, only on `ui-changed` and `change`, after its own pause)\n * when its `<ui-field apply>` says (`applyOf()`):\n * - `immediately` (the default): a microtask later, once the control holds its new value\n * - `delayed [ms]`: after a pause in typing (300ms); a committed `change` writes at once\n * - `on leave`: when the cursor leaves the field (`onLeave()`), or the control commits (`change`)\n * - a checkbox writes its `selected`; a chosen radio, its value; anything else, its `value`\n * - numbers: a `type=\"number\"` / `\"range\"` control writes a number (`null` while blank);\n * any other control keeps a number property a number while what's typed reads as one\n * - never when equal (`===`); showing a value sends no event, so nothing loops\n * - never a value the form refuses (`canWrite`: it fails validation)\n * - HELD edits (`<ui-form apply=\"on save\">`, `isHolding`): a write is kept, not made, until `save()`.\n * `cancel()` drops them and shows the object again.\n * - Controls come and go (rows of a repeat, conditional fields): `update()` binds the new ones\n * and lets go of those gone.\n * - a `ui-*` control whose family loads later (`<ui-root>` loads them on demand) is bound once its tag is defined\n * - Plain DOM plus Solid. What it knows of the rest:\n * - `<ui-form>` and `<ui-repeat>`: only as scope holders\n * - `<ui-field>`: by its attributes\n * - controls: it reads them the way `FormFields` does\n ****************/\nexport class FormBinding {\n /**\n * The `<ui-form>`'s DOM element.\n * - STATIC for the object's life: a different DOM element is a different `FormBinding`.\n */\n private readonly domElement: HTMLElement\n\n /** The form's controls, read from the DOM. */\n private readonly fields: FormFields\n\n /** What the form says about writes: hold them, and may this control's value be written. */\n private readonly form: FormBindingProps[\"form\"]\n\n /** Bound controls, each with its binding. */\n private readonly bindings = new Map<Element, Binding>()\n\n /** Controls changed, to write back on the next microtask. */\n private readonly changed = new Set<Element>()\n\n /** `delayed` controls waiting for a pause in typing, each with its timer. */\n private readonly delayed = new Map<Element, { cancel(): void }>()\n\n constructor({ domElement, fields, form }: FormBindingProps) {\n this.domElement = domElement\n this.fields = fields\n this.form = form\n }\n\n ////////////////\n // ## Binding\n ////////////////\n\n /** Binding now: between `update()` and `stop()`. */\n private isBinding = false\n\n /** Tags inside the form not defined yet, each waited for once: a page may load a control's family later. */\n private readonly awaitedTags = new Set<string>()\n\n /**\n * Bind every named control not bound yet; let go of those no longer in the form.\n * - A `ui-*` control whose family hasn't loaded isn't a control yet: this runs again once it has.\n */\n update() {\n this.isBinding = true\n for (const element of this.domElement.querySelectorAll(E.DOMElement.notAttached)) {\n this.updateWhenAttached(element.localName)\n }\n const controls = new Set(this.fields.controls())\n for (const [control, binding] of this.bindings) {\n if (controls.has(control)) continue\n binding.dispose()\n this.bindings.delete(control)\n this.held.delete(control)\n }\n for (const control of controls) {\n if (this.bindings.has(control)) continue\n const name = FormFields.nameOf(control)\n const scope = name ? FormBinding.holderAround(control) : undefined\n if (name && scope) this.bindings.set(control, FormBinding.bind(control, name, scope))\n }\n }\n\n /** `update()` again once `tag`'s family has loaded (while still binding). */\n private updateWhenAttached(tag: string) {\n if (this.awaitedTags.has(tag)) return\n this.awaitedTags.add(tag)\n void E.DOMElement.whenAttached(tag)\n .then(() => {\n this.awaitedTags.delete(tag)\n if (this.isBinding) this.update()\n })\n .catch((error) => E.Warnings.warn(\"<ui-form value>\", `can't wait for <${tag}>:`, error))\n }\n\n /** Let go of every control, and of held edits. */\n stop() {\n this.isBinding = false\n for (const binding of this.bindings.values()) binding.dispose()\n for (const timer of this.delayed.values()) timer.cancel()\n this.bindings.clear()\n this.changed.clear()\n this.delayed.clear()\n this.waiting.clear()\n this.dropHeld()\n }\n\n /**\n * One control: an effect showing `scope()[name]` in it, in a root of its own (disposed when it goes).\n * - Many things: the value they agree on, else `MIXED`.\n * - STATIC: needs only its arguments.\n */\n private static bind(control: Element, name: string, scope: () => unknown): Binding {\n return E.Reactive.ownRoot((dispose) => {\n createEffect(\n () => FormBinding.valueIn(scope(), name),\n (value) => {\n if (value === UNBOUND) return\n FormBinding.markMixed(control, value === MIXED)\n FormBinding.show(control, value === MIXED ? undefined : value)\n }\n )\n return { name, scope, dispose }\n })\n }\n\n ////////////////\n // ## Writing back\n ////////////////\n\n /**\n * A control changed: write it back when its field's `apply` says (see the class doc).\n * - `change` is a COMMITTED change (a text field left, a choice made): it writes a `delayed` or `on leave` one too.\n */\n readonly onChange = (event: Event) => {\n if (!this.bindings.size) return\n const control = this.controlFor(event)\n if (!control) return\n // a control that settles itself (a search) writes on `ui-changed` alone, never a keystroke's `input`\n if (event.type === \"input\" && (control as { settlesItself?: boolean }).settlesItself) return\n const apply = FormBinding.applyOf(control)\n const isCommitted = event.type === \"change\"\n if (apply.mode === \"on leave\" && !isCommitted) return void this.waiting.add(control)\n if (apply.mode === \"delayed\" && !isCommitted) return this.writeAfterPause(control, apply.delay)\n this.delayed.get(control)?.cancel()\n this.delayed.delete(control)\n this.writeSoon(control)\n }\n\n /** The cursor left a control: write it back if its field writes `on leave` (or has a `delayed` write waiting). */\n readonly onLeave = (event: Event) => {\n if (!this.bindings.size) return\n const control = this.controlFor(event)\n if (!control) return\n const apply = FormBinding.applyOf(control)\n if (apply.mode === \"on leave\" || this.delayed.has(control)) {\n this.delayed.get(control)?.cancel()\n this.delayed.delete(control)\n this.writeSoon(control)\n }\n }\n\n /** Write `control` back on the next microtask, once it holds its new value. */\n private writeSoon(control: Element) {\n if (this.changed.has(control)) return\n this.changed.add(control)\n E.afterSolidUpdate(() => {\n if (!this.changed.delete(control)) return\n this.writeBack(control)\n })\n }\n\n /** Write `control` back once typing pauses for `delay` ms; each change starts the wait again. */\n private writeAfterPause(control: Element, delay: number) {\n this.waiting.add(control)\n this.delayed.get(control)?.cancel()\n this.delayed.set(\n control,\n E.after(delay / 1000, () => {\n this.delayed.delete(control)\n this.writeBack(control)\n })\n )\n }\n\n /** Controls changed but not written yet: a `delayed` one waiting for the pause, an `on leave` one for the leave. */\n private readonly waiting = new Set<Element>()\n\n /**\n * Write every control still waiting (`delayed`, `on leave`) now: before a save or a submit,\n * which a keyboard or a script can start without the cursor leaving the field.\n */\n flushWaiting() {\n for (const control of [...this.waiting]) {\n this.delayed.get(control)?.cancel()\n this.delayed.delete(control)\n this.writeBack(control)\n }\n }\n\n /** Write every bound control back: after a reset or a clear changed them all. */\n writeAll() {\n for (const control of this.bindings.keys()) this.writeBack(control)\n }\n\n /**\n * `scope[name] = ` what the control holds now (on every thing, for many), unless that's what it holds already.\n * - Held instead while the form holds edits.\n * - NEVER throws: a property that can't be set (a getter alone) warns.\n * - Untracked: it reads the scope and the property to write them, never to follow them.\n */\n @E.untracked\n private writeBack(control: Element) {\n this.waiting.delete(control)\n const binding = this.bindings.get(control)\n if (!binding) return\n const targets = FormBinding.targetsOf(binding.scope())\n if (!targets.length) return\n const current = FormBinding.valueIn(binding.scope(), binding.name)\n const next = FormBinding.valueFor(control, current === MIXED ? undefined : current)\n if (next === UNBOUND || !this.form.canWrite(control)) return\n if (this.form.isHolding()) return this.hold(control, binding, next)\n if (next === current) return\n FormBinding.markMixed(control, false)\n for (const target of targets) this.write(target, binding.name, next)\n this.form.onWrite?.({ control, name: binding.name, value: next, things: targets })\n }\n\n /** `target[name] = value`, unless the form writes it itself (`writesItself()`). */\n private write(target: Record<PropertyKey, unknown>, name: string, value: unknown) {\n if (this.form.writesItself?.(target, name, value)) return\n FormBinding.write(target, name, value)\n }\n\n /** `target[name] = value`, unless it's that already; warns if it can't be set. */\n private static write(target: Record<PropertyKey, unknown>, name: string, value: unknown) {\n if (FormBinding.read(target, name) === value) return\n try {\n const { owner, key } = FormBinding.ownerOf(target, name)\n if (owner) owner[key] = value\n } catch (error) {\n E.Warnings.warn(\"<ui-form value>\", `can't set \\`${name}\\`:`, error)\n }\n }\n\n /** The bound control an event came from: the first at or above its `target`, inside the form. */\n private controlFor(event: Event): Element | undefined {\n for (let node = event.target as Element | null; node && node !== this.domElement; node = node.parentElement) {\n if (this.bindings.has(node)) return node\n }\n return undefined\n }\n\n ////////////////\n // ## Held edits (`apply=\"on save\"`)\n ////////////////\n\n /** Edits held until `save()`, by control: the control keeps showing its new value meanwhile. */\n private readonly held = new Map<Element, HeldEdit>()\n\n /** The controls whose edits are held. */\n get heldControls(): Element[] {\n return [...this.held.keys()]\n }\n\n /** Holds edits now. */\n get hasHeld(): boolean {\n return this.held.size > 0\n }\n\n /** The held edits, in the order they were made: one per thing a control writes to. */\n get changes(): UIT.FormChange[] {\n const changes: UIT.FormChange[] = []\n for (const { binding, value } of this.held.values()) {\n for (const target of FormBinding.targetsOf(binding.scope())) changes.push({ name: binding.name, value, target })\n }\n return changes\n }\n\n /** Hold `control`'s new value; an edit back to the object's own value is no longer held. */\n private hold(control: Element, binding: Binding, value: unknown) {\n this.held.delete(control)\n if (value !== FormBinding.valueIn(binding.scope(), binding.name)) this.held.set(control, { binding, value })\n this.form.onHeldChange()\n }\n\n /** Write every held edit, then hold none. */\n @E.untracked\n saveHeld() {\n for (const [control, { binding, value }] of this.held) {\n FormBinding.markMixed(control, false)\n const things = FormBinding.targetsOf(binding.scope())\n for (const target of things) this.write(target, binding.name, value)\n this.form.onWrite?.({ control, name: binding.name, value, things })\n }\n this.held.clear()\n this.form.onHeldChange()\n }\n\n /** Drop every held edit: each control shows the object's value again. */\n @E.untracked\n dropHeld() {\n if (!this.held.size) return\n for (const [control, { binding }] of this.held) {\n const value = FormBinding.valueIn(binding.scope(), binding.name)\n if (value === UNBOUND) continue\n FormBinding.markMixed(control, value === MIXED)\n FormBinding.show(control, value === MIXED ? undefined : value)\n }\n this.held.clear()\n this.form.onHeldChange()\n }\n\n ////////////////\n // ## Scopes\n ////////////////\n\n /**\n * Make `element` a scope holder: bound controls (and `<ui-repeat>`s) at or inside it read `read()`.\n * - `<ui-form>` holds its `value`; each top-level element of a `<ui-repeat>` row holds its item.\n */\n static hold(element: Element, read: () => unknown) {\n FormBinding.holders.set(element, read)\n }\n\n /** The scope at `element`: its nearest holder's (itself included), read now; tracked inside a computation. */\n static scopeAround(element: Element): unknown {\n return FormBinding.holderAround(element)?.()\n }\n\n /** The nearest holder's `read`, at or above `element`. */\n private static holderAround(element: Element): (() => unknown) | undefined {\n for (let node: Element | null = element; node; node = node.parentElement) {\n const read = FormBinding.holders.get(node)\n if (read) return read\n }\n return undefined\n }\n\n /**\n * Every scope holder, page-wide.\n * - A `WeakMap`: a holder that leaves the page goes with it, so there's nothing to reset.\n */\n private static readonly holders = new WeakMap<Element, () => unknown>()\n\n ////////////////\n // ## Pure helpers\n // STATIC, every one: it reads only its arguments, so it needs no instance.\n ////////////////\n\n /** Something with properties to bind to: an object (a class instance, an array ...) or a function. */\n static isObject(value: unknown): value is Record<PropertyKey, unknown> {\n return value !== null && (typeof value === \"object\" || typeof value === \"function\")\n }\n\n /** The things a scope binds to: each of a list's (objects only), else the scope itself; `[]` for none. */\n private static targetsOf(scope: unknown): Record<PropertyKey, unknown>[] {\n if (Array.isArray(scope)) return scope.filter(FormBinding.isObject)\n return FormBinding.isObject(scope) ? [scope] : []\n }\n\n /**\n * `scope[name]`: for many things, the value they agree on, else `MIXED`; `UNBOUND` for nothing to bind to.\n * - Tracked inside a computation: it reads each thing's property.\n */\n private static valueIn(scope: unknown, name: string): unknown {\n const targets = FormBinding.targetsOf(scope)\n if (!targets.length) return UNBOUND\n const first = FormBinding.read(targets[0]!, name)\n return targets.every((target) => FormBinding.read(target, name) === first) ? first : MIXED\n }\n\n /**\n * `target`'s property `name`; a dotted name reaches into nested things (`font.size`).\n * - `undefined` where the path meets nothing.\n */\n static read(target: unknown, name: string): unknown {\n let value = target\n for (const key of name.split(\".\")) {\n if (!FormBinding.isObject(value)) return undefined\n value = value[key]\n }\n return value\n }\n\n /**\n * What a dotted `name` writes to: the thing holding its last key, and that key.\n * - The thing is `undefined` where the path meets nothing.\n */\n private static ownerOf(\n target: Record<PropertyKey, unknown>,\n name: string\n ): { owner?: Record<PropertyKey, unknown>; key: string } {\n const keys = name.split(\".\")\n const key = keys.pop()!\n const owner = keys.length ? FormBinding.read(target, keys.join(\".\")) : target\n return { owner: FormBinding.isObject(owner) ? owner : undefined, key }\n }\n\n /**\n * When `control`'s field takes an edit: its `<ui-field apply>`, read from its text.\n * - `delayed` alone is 300ms; `delayed 100`, 100ms. Anything unknown is `immediately`.\n */\n static applyOf(control: Element): FieldApply {\n const text = control.closest(FIELD_SELECTOR)?.getAttribute(\"apply\")?.trim() ?? \"\"\n if (text === \"on leave\") return { mode: \"on leave\" }\n const delayed = /^delayed(?:\\s+(\\d+)(?:\\s*ms)?)?$/.exec(text)\n if (delayed) return { mode: \"delayed\", delay: delayed[1] ? Number(delayed[1]) : DEFAULT_DELAY }\n return { mode: \"immediately\" }\n }\n\n /**\n * Show \"mixed\" on `control`, or stop: its `<ui-field>`'s `mixed`, and a \"Mixed\" placeholder (its own kept).\n * - SIDE EFFECT: writes the field's `mixed` and the control's `placeholder`.\n */\n private static markMixed(control: Element, isMixed: boolean) {\n const field = control.closest(FIELD_SELECTOR) as (Element & { mixedText?: string }) | null\n if (field && field.hasAttribute(\"mixed\") !== isMixed) field.toggleAttribute(\"mixed\", isMixed)\n const wasMixed = FormBinding.ownPlaceholders.has(control)\n if (isMixed === wasMixed || FormFields.isCheckable(control)) return\n if (isMixed) {\n FormBinding.ownPlaceholders.set(control, control.getAttribute(\"placeholder\"))\n control.setAttribute(\"placeholder\", field?.mixedText ?? MIXED_TEXT)\n } else {\n const own = FormBinding.ownPlaceholders.get(control)\n FormBinding.ownPlaceholders.delete(control)\n if (own == null) control.removeAttribute(\"placeholder\")\n else control.setAttribute(\"placeholder\", own)\n }\n }\n\n /** A mixed control's own placeholder (`null`: none), to put back when it's no longer mixed. */\n private static readonly ownPlaceholders = new WeakMap<Element, string | null>()\n\n /**\n * Show `value` in `control`, see the class doc; writes nothing that's already shown.\n * - SIDE EFFECT: tells the field around it, which may follow its control's value (`valueShown()`: a property's\n * `:state(set)`).\n */\n private static show(control: Element, value: unknown) {\n if (FormFields.isCheckable(control)) {\n const chosen = FormFields.isRadio(control) ? FormBinding.isRadioValue(control, value) : !!value\n if (FormFields.isChosen(control) === chosen) return\n // `checked`: a native checkbox's, and a `ui-*` one's in any language (`selected`)\n ;(control as Element & { checked: boolean }).checked = chosen\n } else {\n const shown = Array.isArray(value) ? value : FormBinding.textOf(value)\n const element = control as Element & { value: unknown }\n if (element.value === shown) return\n element.value = shown\n }\n const field = control.parentElement as (Element & { valueShown?(): void }) | null\n field?.valueShown?.()\n }\n\n /** What `control` writes back, see the class doc; `UNBOUND` for nothing (a radio not chosen). */\n private static valueFor(control: Element, current: unknown): unknown {\n if (FormFields.isRadio(control)) {\n return FormFields.isChosen(control)\n ? FormBinding.keepNumber(FormFields.chosenValueFor(control), current)\n : UNBOUND\n }\n if (FormFields.isCheckable(control)) return FormFields.isChosen(control)\n const { value, type } = control as Element & { value?: unknown; type?: unknown }\n if (typeof value === \"string\" && NUMBER_TYPES.has(type as string)) return value.trim() === \"\" ? null : Number(value)\n return FormBinding.keepNumber(value, current)\n }\n\n /** A radio's own value is `value` (as text: a number property matches `value=\"2\"`). */\n private static isRadioValue(control: Element, value: unknown): boolean {\n return value != null && FormBinding.textOf(value) === FormFields.chosenValueFor(control)\n }\n\n /** `value` as a control shows it: `\"\"` for nullish, a primitive as text, anything else as JSON. */\n private static textOf(value: unknown): string {\n if (value == null) return \"\"\n if (typeof value === \"string\") return value\n if (typeof value === \"number\" || typeof value === \"boolean\" || typeof value === \"bigint\") return String(value)\n return JSON.stringify(value) ?? \"\"\n }\n\n /** `value` as a number when the property it replaces is one and it reads as one; else `value` itself. */\n private static keepNumber(value: unknown, current: unknown): unknown {\n if (typeof current !== \"number\" || typeof value !== \"string\" || value.trim() === \"\") return value\n const number = Number(value)\n return Number.isFinite(number) ? number : value\n }\n}\n\n/** What `new FormBinding()` reads: the collaborators it works over. */\nexport type FormBindingProps = {\n /** The `<ui-form>`'s DOM element. */\n domElement: HTMLElement\n /** The form's controls. */\n fields: FormFields\n /** What the form says about writes. */\n form: {\n /** Hold edits instead of writing them (`apply=\"on save\"`). */\n isHolding(): boolean\n /** May `control`'s value be written: it passes validation. */\n canWrite(control: Element): boolean\n /** The held edits changed: some, none, or others. */\n onHeldChange(): void\n /**\n * Write `value` to `target` itself, in place of the plain set: `true` when it did.\n * - Left out, or `false`: `target[name] = value`.\n */\n writesItself?(target: object, name: string, value: unknown): boolean\n /** A control's value was written to its things (after a save, for held edits). */\n onWrite?(write: { control: Element; name: string; value: unknown; things: readonly object[] }): void\n }\n}\n\n/** One bound control. */\ntype Binding = {\n /** The property it shows and writes. */\n name: string\n /** Its scope holder's `read`: the object (or list of things) it binds to. */\n scope: () => unknown\n /** Stop its effect. */\n dispose: () => void\n}\n\n/** One held edit: the control's binding, and the value it will write. */\ntype HeldEdit = { binding: Binding; value: unknown }\n\n/** \"No value to show or write\": no object to bind to, or a radio that isn't chosen. */\nconst UNBOUND = Symbol(\"unbound\")\n\n/** \"The things disagree\": the control shows blank, and mixed. */\nconst MIXED = Symbol(\"mixed\")\n\n/** A mixed control's placeholder, when its field doesn't say (`<ui-field>`'s `mixed` text). */\nconst MIXED_TEXT = \"Mixed\"\n\n/** `apply=\"delayed\"`'s pause, in ms, when it names none. */\nconst DEFAULT_DELAY = 300\n\n/** Input `type`s whose value is a number: they write a number (`null` while blank). */\nconst NUMBER_TYPES = new Set([\"number\", \"range\"])\n","/**\n * The English vocabulary of `<ui-field>`: every name the tag uses.\n * - Its tag, attributes (each with its kind and allowed values), slots, parts, states and texts.\n * The shape is `E.ComponentVocabulary` (`spell/ui/vocabulary`).\n * - Pure data: node imports it (`yarn site:data`, `yarn gen:root`), so `spell/ui/core` for types only,\n * `UIT` by value straight from `components.types`.\n * - The family's grammar notes are in `UIForm.en.ts`.\n */\n\nimport type { E } from \"spell/ui/core\"\nimport * as UIT from \"spell/ui/components/components.types\"\nimport { STATE_STATES } from \"./UIForm.types\"\n\n/****************\n * ### `fieldVocabulary`\n * The names of `<ui-field>`, one field of a form:\n * a LABEL ROW (the label, then at its far end actions, an output and an info tip), the CONTROL,\n * then a hint and the error.\n * - The label row is drawn only when there's something in it:\n * a field that slots its own `<label>` looks as it always did.\n ****************/\nexport const fieldVocabulary = {\n tag: \"ui-field\",\n icon: \"edit outline\",\n topics: [\"forms\", \"inputs\", \"collections\"],\n aka: [\"form field\", \"form group\", \"form control\", \"label and input\", \"property\", \"inspector row\"],\n skeleton: \"4.5 tall\",\n noun: \"field\",\n ui: false,\n description: \"A field is a form element containing a label and an input, with a hint, a tip and its errors.\",\n attributes: [\n {\n name: \"label\",\n group: \"name\",\n kind: \"string\",\n description:\n 'The label, in the label row; `slot=\"label\"` is the rich version. Names the control for screen readers.'\n },\n {\n name: \"description\",\n group: \"content\",\n kind: \"string\",\n description:\n 'A tip behind an info icon at the end of the label row, shown on hover and focus; `slot=\"description\"` is ' +\n \"the rich version (bold words, line breaks).\"\n },\n {\n name: \"unsaved\",\n group: \"form\",\n kind: \"string\",\n description:\n \"A change here can't be saved: a crossed-out save icon after the info icon, this text its tip. \" +\n \"The control still changes the value.\"\n },\n {\n name: \"hint\",\n group: \"form\",\n kind: \"string\",\n description: 'Text under the control; `slot=\"hint\"` is the rich version.'\n },\n {\n name: \"output\",\n group: \"content\",\n kind: \"string\",\n description: 'A value shown at the end of the label row (`100%`, `+8°`); `slot=\"output\"` is the rich version.'\n },\n {\n name: \"error\",\n group: \"form\",\n kind: \"string\",\n description:\n \"An error, as a line under the control, and the `error` state. `<ui-form>`'s validation shows its own there.\"\n },\n {\n name: \"state\",\n group: \"form\",\n kind: \"valueOnly\",\n values: UIT.FormStates,\n description: \"Field state: tints its label and controls. An error shows `error` on top.\"\n },\n {\n name: \"apply\",\n group: \"form\",\n kind: \"string\",\n default: \"immediately\",\n description:\n \"When a change to the control is written to the bound value: `immediately`; `delayed`, after a pause in \" +\n \"typing (300ms; `delayed 100` for 100ms); or `on leave`, when the cursor leaves the field.\"\n },\n {\n name: \"mixed\",\n group: \"appearance\",\n kind: \"boolean\",\n description:\n \"The things being edited disagree on this value: the control shows blank, with a `Mixed` placeholder. \" +\n \"Set by the form; writing a value clears it.\"\n },\n {\n name: \"rules\",\n group: \"form\",\n kind: \"json\",\n reflect: false,\n description:\n 'Validation rules for this field\\'s control, in `<ui-form rules>`\\'s shape (`\"email\"`, `[\"notEmpty\", ' +\n '\"minLength[6]\"]`); added to the form\\'s own rules for it.'\n },\n { name: \"inline\", group: \"layout\", kind: \"keyOnly\", description: \"Label beside the control, not above it.\" },\n {\n name: \"required\",\n group: \"form\",\n kind: \"keyOnly\",\n description: \"Marks the label with an asterisk (validation is `rules` / `required`).\"\n },\n {\n name: \"readonly\",\n group: \"form\",\n kind: \"boolean\",\n description:\n \"Shows the value; it can't be changed. Nests like `disabled`: set on a group, it reaches each field.\"\n },\n { name: \"disabled\", group: \"states\", kind: \"keyOnly\", description: \"Dimmed and not usable (`inert`).\" },\n {\n name: \"width\",\n group: \"layout\",\n kind: \"width\",\n description: \"Width in a row of fields: columns (`4` of 16), fractions (`1/4`) or percentages (`25%`).\"\n }\n ],\n events: [],\n slots: [\n {\n name: \"\",\n description: \"The control(s): `<ui-input>`, `<ui-dropdown>`, native inputs ...; or a `<label for>`, then them.\"\n },\n { name: \"label\", description: \"Rich label (instead of `label`).\" },\n { name: \"description\", description: \"Rich tip (instead of `description`): bold words, line breaks.\" },\n { name: \"hint\", description: \"Rich hint (instead of `hint`).\" },\n { name: \"output\", description: \"Rich output (instead of `output`).\" },\n {\n name: \"actions\",\n description: \"Small buttons at the end of the label row (`Reset`, `Auto`); a taller one never grows the row.\"\n }\n ],\n parts: [\n { name: \"field\", description: \"The field box.\" },\n { name: \"row\", description: \"The label row.\" },\n { name: \"label\", description: \"The label.\" },\n { name: \"actions\", description: \"The actions, at the end of the label row.\" },\n { name: \"output\", description: \"The output.\" },\n { name: \"info\", description: \"The info icon.\" },\n { name: \"tip\", description: \"The tip, shown from the info icon.\" },\n { name: \"unsaved\", description: \"The crossed-out save icon after the info icon, with `unsaved`.\" },\n {\n name: \"control\",\n description: \"Around the control(s) under a label row; no box of its own (`display: contents`).\"\n },\n { name: \"hint\", description: \"The hint.\" },\n { name: \"error\", description: \"The error lines.\" }\n ],\n states: [\n { name: \"field\", description: \"Always: how `<ui-form>` finds a control's field (`closest(':state(field)')`).\" },\n ...STATE_STATES,\n { name: \"mixed\", description: \"The things being edited disagree on this value (`mixed`).\" },\n { name: \"readonly\", description: \"Can't be changed (`readonly`, its own or a group's).\" },\n { name: \"disabled\", description: \"Can't be used.\" }\n ],\n texts: [\n { key: \"info\", text: \"More about {label}\", description: \"The info icon's name; `{label}` is the label.\" },\n { key: \"mixed\", text: \"Mixed\", description: \"The placeholder of a control whose things disagree.\" },\n {\n key: \"none\",\n text: \"none\",\n description: \"What a property's select shows, in italics, when it has no value and no default.\"\n }\n ]\n} as const satisfies E.ComponentVocabulary\n","/*\n * The style sheet of `<ui-form>`, `<ui-field>` and `<ui-fields>`: a port of Fomantic's `form.less` + `form.variables`.\n * - ONE sheet for the three elements; each adopts it after the foundation.\n * `<ui-field>` also adopts `UIField.css` AFTER it, for its own parts (label row, tip, hint, errors).\n * `<ui-repeat>` adopts it too, for its `display: contents` host alone (its shadow is a bare `<slot>`).\n * - Shadow markup contract (class grammar; a form's box has no better element than `<div>`):\n * - `<ui-form>`: `<div class=\"ui [size state] [equal width inverted loading disabled unstackable] form\"\n * part=\"form\" [inert]><slot></slot>[<figure class=\"debug\"><figcaption>…</figcaption><pre part=\"debug\">…</pre></figure>]</div>` -- the NATIVE `<form>` is light DOM, slotted inside it (or around\n * the `<ui-form>`): a form-associated control belongs to the nearest `<form>` ancestor in its own tree,\n * so a `<form>` in this shadow root would own nothing (see `UIForm`, `notes/grammar.md`)\n * - `<ui-field>`: `<div class=\"[state] [inline required disabled] [N wide] field\" part=\"field\" [inert]>\n * [<div class=\"row\" part=\"row\">…</div>]<div class=\"control\" part=\"control\"><slot></slot></div>\n * [<div class=\"hint\" part=\"hint\">…</div>][<div class=\"error prompt\" part=\"error\" role=\"alert\">…</div>]</div>`\n * -- the label row only when it has something, the errors only while there are any (`UIField.css`)\n * - `<ui-fields>`: `<div class=\"[state] [inline grouped unstackable required disabled] [two | equal width]\n * fields\" part=\"fields\" [inert]><slot></slot></div>`\n * - DOM elements are `display: contents`, so each ROOT is the box:\n * a field's root is the flex item of its row, as in Fomantic's markup.\n * Spacing that Fomantic decides with `:last-child` is decided again by the DOM element's position\n * (`:host(:last-child)`); static markup keeps Fomantic's selectors.\n * - Selectors are bare `.field` / `.fields`: inside a shadow root nothing else carries them,\n * and static (class-grammar) markup is Fomantic's own.\n * - Public tokens (`--ui-form-*`, the theming surface) are NEVER declared here: the form's token block reads each\n * through a private alias, `--_ui-form-gutter: var(--ui-form-gutter, 1em)`, and every rule reads the alias.\n * So a value set on `:root`, an ancestor, the DOM element, `::part(form)` or in the app stylesheet reaches the box\n * (`notes/theming.md` \"Component tokens\").\n * - a field's / fields' root is OUTSIDE the form's box (its own shadow root), so it reads a form token as\n * `var(--_ui-form-x, var(--ui-form-x, <default>))`: the form's alias inside a form, else the public one\n * - Tokens handed DOWN (private, inherited; never set them from outside, theme with `--ui-form-*`):\n *\n * | Token | Set by | Read by |\n * | ------------------------------ | ----------------- | ------------------------------------------------ |\n * | `--_ui-fields-child-width` | fields (`widths`) | field: its width, unless its own `N wide` |\n * | `--_ui-fields-child-flex` | equal width | field: its `flex` |\n * | `--_ui-fields-pad-start` / `-end` | fields | field: the gutter |\n * | `--_ui-fields-field-margin` | fields, grouped | field: its margin (`0 0 1em` alone) |\n * | `--_ui-fields-inline` | inline fields | field: inline label (style query) |\n * | `--_ui-fields-required` | required fields | field: asterisk on its label (style query) |\n * | `--_ui-fields-stacked` | narrow form | field: full width (style query) |\n * | `--_ui-form-label-color` | form (`inverted`) | field / fields: label colour (the alias of `--ui-form-label-color`) |\n * | `--_ui-form-equal-width` / `--_ui-form-unstackable` | form | fields (style query) |\n * | `--_ui-input-owner-width` | field | `UIInput.css`: the control fills the field |\n * | `--_ui-field-state-color` / `-background` / `-border` | field / fields state | `UIInput.css`, `UICheckbox.css`, `native.css` |\n *\n * - a field's / fields' `<slot>` resets the colour remap (`--ui-color*`) and the fields tokens, so a field state\n * reaches controls ONLY as the resolved `--_ui-field-state-*` tokens and rows don't leak into nested rows\n * - Responsive: the form ROOT is the `ui-form` size container; rows stack below 768px of FORM width\n * (`unstackable` form / fields opt out).\n * - Messages: a form / field / fields shows the `<ui-message state=\"…\">`s of its state and hides the others --\n * light-DOM rules in `native.css` keyed on the DOM elements' `:state(error)` ... (a message's box is in ITS shadow).\n * - NOTE: left out, on purpose:\n * - styles for native controls inside fields -- `native.css` has them (light DOM)\n * - Fomantic's dropdown / checkbox rules inside stated fields: controls read `--ui-field-state-*`;\n * a `<ui-dropdown>` keeps its own look (give it `state` too)\n * - `.ui.form .fields .wide.field` inline wide inputs, `transparent` form inputs, `select` styling:\n * `<ui-input fluid>` / `native.css`\n * - checkbox top margins in rows of fields: rows centre their fields (`align-items`) instead\n * - the `:has()` label colouring of a `fields` group whose child has a state\n */\n\n@layer ui.components.form.types, ui.components.form.content, ui.components.form.variations, ui.components.form.states;\n\n/* Breakpoints (`@custom-media`), inlined at build time: `stack-with=\"page\"`. */\n@import \"../../styles/media.css\";\n\n/* Loader spin, shared by `loading` forms. */\n@keyframes ui-form-spin {\n to {\n rotate: 1turn;\n }\n}\n\n/*******************************\n Form\n*******************************/\n\n@layer ui.components.form.types {\n /* DOM elements: no box of their own; each root is the box (the form's block, a row's flex items). */\n /*\n * DOM element: a real block box and a size container,\n * so a slotted `<ui-fields>` finds the form's width in every engine.\n * - WebKit looks for a container through shadow-including ANCESTORS (not the flat tree through the slot),\n * and keeps container names to their own shadow tree, so the `.ui.form` root inside this shadow is invisible\n * to the fields' shadow roots there; the DOM element is an ancestor of the fields in the light tree.\n * - Chromium finds `.ui.form` first: the same width.\n */\n :host {\n display: contents;\n }\n /* (`:state(root)`: only the form's DOM element; `<ui-fields>` / `<ui-field>` adopt this sheet too) */\n :host(:state(root)) {\n display: block;\n container-type: inline-size;\n }\n\n /*\n * Tokens: one per `form.variables` entry that still matters, from the global tokens -- each the private alias\n * of its public token (never declare the public one: it would block inherited values).\n */\n .ui.form {\n --_ui-form-gutter: var(--ui-form-gutter, 1em);\n --_ui-form-row-distance: var(--ui-form-row-distance, 1em);\n --_ui-form-label-distance: var(--ui-form-label-distance, 0.28571em);\n --_ui-form-label-font-size: var(--ui-form-label-font-size, 0.92857em);\n --_ui-form-label-font-weight: var(--ui-form-label-font-weight, var(--ui-font-weight-bold));\n --_ui-form-required-color: var(--ui-form-required-color, var(--ui-negative-text));\n --_ui-form-disabled-opacity: var(--ui-form-disabled-opacity, var(--ui-disabled-opacity));\n --_ui-form-loader-size: var(--ui-form-loader-size, 3em);\n --_ui-form-loader-width: var(--ui-form-loader-width, 0.2em);\n --_ui-form-loader-fill: var(--ui-form-loader-fill, oklch(from var(--ui-ink) l c h / 0.1));\n --_ui-form-loader-line: var(--ui-form-loader-line, var(--ui-text-muted));\n --_ui-form-loader-speed: var(--ui-form-loader-speed, 0.6s);\n --_ui-form-loader-dimmer: var(--ui-form-loader-dimmer, color-mix(in oklab, var(--ui-surface) 80%, transparent));\n --_ui-form-inverted-label-color: var(--ui-form-inverted-label-color, var(--ui-text-inverted-color));\n /* ## Owner tokens: declared on every root, so a nested form never inherits an outer one's. */\n --_ui-form-label-color: var(--ui-form-label-color, var(--ui-text-color));\n --_ui-form-equal-width: 0;\n --_ui-form-unstackable: 0;\n /* `stack-with`: the element's class (below), else the page-wide token, else `container` */\n --_ui-form-stack-with: var(--ui-stack-with, container);\n\n position: relative;\n box-sizing: border-box;\n max-width: 100%;\n container: ui-form / inline-size;\n color: var(--ui-text-color);\n font-family: var(--ui-font-family);\n font-size: calc(var(--ui-font-size) * var(--ui-scale, 1));\n line-height: var(--ui-line-height);\n }\n .ui.form ::slotted(form) {\n display: block;\n margin: 0;\n }\n\n /* Field */\n .field {\n --_ui-input-owner-width: 100%;\n box-sizing: border-box;\n width: var(--_field-width, var(--_ui-fields-child-width, auto));\n flex: var(--_ui-fields-child-flex, 0 1 auto);\n min-width: 0;\n clear: both;\n margin: var(--_ui-fields-field-margin, 0 0 var(--_ui-form-row-distance, var(--ui-form-row-distance, 1em)));\n padding-inline: var(--_ui-fields-pad-start, 0) var(--_ui-fields-pad-end, 0);\n }\n :host(:last-child) > .field,\n .ui.form .field:last-child {\n margin-block-end: 0;\n }\n .field > slot,\n .field > .control > slot {\n /* A row inside a field starts clean. */\n --_ui-fields-child-width: initial;\n --_ui-fields-child-flex: initial;\n --_ui-fields-pad-start: initial;\n --_ui-fields-pad-end: initial;\n --_ui-fields-field-margin: initial;\n --_ui-fields-inline: initial;\n --_ui-fields-required: initial;\n --_ui-fields-stacked: initial;\n }\n .field > slot,\n .field > .control > slot,\n .fields > slot {\n /* Only the RESOLVED state tokens reach the controls, never the colour remap. */\n --ui-color: initial;\n --ui-color-text: initial;\n --ui-color-header: initial;\n --ui-color-border: initial;\n --ui-color-background: initial;\n --ui-color-inverted: initial;\n --ui-color-on: initial;\n --ui-color-inverted-on: initial;\n --ui-color-hover: initial;\n --ui-color-focus: initial;\n --ui-color-down: initial;\n --ui-color-active: initial;\n }\n\n /* Fields: a row; its children share it. */\n .fields {\n --_ui-fields-child-width: auto;\n --_ui-fields-child-flex: 0 1 auto;\n --_ui-fields-pad-start: calc(var(--_ui-form-gutter, var(--ui-form-gutter, 1em)) / 2);\n --_ui-fields-pad-end: calc(var(--_ui-form-gutter, var(--ui-form-gutter, 1em)) / 2);\n --_ui-fields-field-margin: 0;\n --_ui-fields-inline: 0;\n --_ui-fields-required: 0;\n --_ui-fields-stacked: 0;\n box-sizing: border-box;\n display: flex;\n flex-direction: row;\n margin: 0 calc(var(--_ui-form-gutter, var(--ui-form-gutter, 1em)) / -2)\n var(--_ui-form-row-distance, var(--ui-form-row-distance, 1em));\n }\n :host(:last-child) > .fields,\n .ui.form .fields:last-child {\n margin-block-end: 0;\n }\n}\n\n/*******************************\n Content\n*******************************/\n\n@layer ui.components.form.content {\n /* Labels: above the control, bold and small. */\n .field ::slotted(label),\n .fields ::slotted(label),\n .ui.form :is(.field, .fields) > label {\n display: block;\n margin: 0 0 var(--_ui-form-label-distance, var(--ui-form-label-distance, 0.28571em));\n color: var(--_field-label-color, var(--_ui-form-label-color, var(--ui-form-label-color, var(--ui-text-color))));\n font-size: var(--_ui-form-label-font-size, var(--ui-form-label-font-size, 0.92857em));\n font-weight: var(--_ui-form-label-font-weight, var(--ui-form-label-font-weight, var(--ui-font-weight-bold)));\n text-transform: none;\n }\n /* `debug` (ours, not Fomantic's): the bound object as JSON, below the content, in a captioned box,\n so it reads as the form's output, not as page text. */\n .ui.form > .debug {\n margin: 1em 0 0;\n padding: 0.5em 0.75em;\n border: var(--ui-border);\n border-radius: var(--ui-radius);\n background-color: var(--ui-surface-strong);\n }\n .ui.form > .debug > figcaption {\n margin: 0 0 0.25em;\n color: var(--ui-text-muted);\n font-size: 0.85714em;\n font-weight: var(--ui-font-weight-bold);\n }\n .ui.form > .debug > pre {\n margin: 0;\n font-family: var(--ui-font-family-mono);\n font-size: 0.85714em;\n white-space: pre-wrap;\n overflow-wrap: anywhere;\n }\n /* Static markup: a `.ui.input` fills its field (elements get `--_ui-input-owner-width`). */\n .ui.form .field .ui.input {\n width: 100%;\n }\n .ui.form .inline:is(.field, .fields) .ui.input {\n width: auto;\n }\n .field ::slotted(p),\n .ui.form .field > p {\n margin: 1em 0;\n }\n\n /* Static markup: a message of a state shows only inside a form / fields / field in that state (elements:\n `native.css`, keyed on the DOM elements' states). */\n .ui.form .message:is(.error, .info, .success, .warning) {\n display: none;\n }\n .ui.error.form .error.message,\n .ui.form .error:is(.field, .fields) .error.message,\n .ui.info.form .info.message,\n .ui.form .info:is(.field, .fields) .info.message,\n .ui.success.form .success.message,\n .ui.form .success:is(.field, .fields) .success.message,\n .ui.warning.form .warning.message,\n .ui.form .warning:is(.field, .fields) .warning.message {\n display: block;\n }\n}\n\n/*******************************\n Variations\n*******************************/\n\n@layer ui.components.form.variations {\n /* Widths: N of 16 in a row. */\n .one.wide.field {\n --_field-width: 6.25%;\n }\n .two.wide.field {\n --_field-width: 12.5%;\n }\n .three.wide.field {\n --_field-width: 18.75%;\n }\n .four.wide.field {\n --_field-width: 25%;\n }\n .five.wide.field {\n --_field-width: 31.25%;\n }\n .six.wide.field {\n --_field-width: 37.5%;\n }\n .seven.wide.field {\n --_field-width: 43.75%;\n }\n .eight.wide.field {\n --_field-width: 50%;\n }\n .nine.wide.field {\n --_field-width: 56.25%;\n }\n .ten.wide.field {\n --_field-width: 62.5%;\n }\n .eleven.wide.field {\n --_field-width: 68.75%;\n }\n .twelve.wide.field {\n --_field-width: 75%;\n }\n .thirteen.wide.field {\n --_field-width: 81.25%;\n }\n .fourteen.wide.field {\n --_field-width: 87.5%;\n }\n .fifteen.wide.field {\n --_field-width: 93.75%;\n }\n .sixteen.wide.field {\n --_field-width: 100%;\n }\n\n /* Rows of N equal fields. */\n .two.fields {\n --_ui-fields-child-width: 50%;\n }\n .three.fields {\n --_ui-fields-child-width: 33.33333%;\n }\n .four.fields {\n --_ui-fields-child-width: 25%;\n }\n .five.fields {\n --_ui-fields-child-width: 20%;\n }\n .six.fields {\n --_ui-fields-child-width: 16.66666%;\n }\n .seven.fields {\n --_ui-fields-child-width: 14.28571%;\n }\n .eight.fields {\n --_ui-fields-child-width: 12.5%;\n }\n .nine.fields {\n --_ui-fields-child-width: 11.11111%;\n }\n .ten.fields {\n --_ui-fields-child-width: 10%;\n }\n .fields[class*=\"equal width\"] {\n --_ui-fields-child-width: 100%;\n --_ui-fields-child-flex: 1 1 auto;\n }\n .ui[class*=\"equal width\"].form {\n --_ui-form-equal-width: 1;\n }\n @container style(--_ui-form-equal-width: 1) {\n .fields {\n --_ui-fields-child-width: 100%;\n --_ui-fields-child-flex: 1 1 auto;\n }\n }\n\n /* Grouped: stacked fields under one label. */\n .grouped.fields {\n --_ui-fields-pad-start: 0;\n --_ui-fields-pad-end: 0;\n --_ui-fields-field-margin: 0.5em 0;\n display: block;\n margin: 0 0 var(--_ui-form-row-distance, var(--ui-form-row-distance, 1em));\n }\n\n /* Inline: labels beside controls. */\n .inline.fields {\n --_ui-fields-pad-start: 0;\n --_ui-fields-pad-end: 1em;\n --_ui-fields-inline: 1;\n --_ui-input-owner-width: auto;\n align-items: center;\n margin: 0 0 var(--_ui-form-row-distance, var(--ui-form-row-distance, 1em));\n }\n .inline.fields ::slotted(label),\n .ui.form .inline.fields > label {\n display: inline-block;\n margin: 0.03571em 1em 0 0;\n }\n .inline.field {\n --_ui-input-owner-width: auto;\n }\n .inline.field ::slotted(label),\n .ui.form .inline:is(.field, .fields) .field > label,\n .ui.form .inline.field > label {\n display: inline-block;\n width: auto;\n margin: 0 0.85714em 0 0;\n vertical-align: baseline;\n }\n @container style(--_ui-fields-inline: 1) {\n .field {\n --_ui-input-owner-width: auto;\n }\n .field ::slotted(label) {\n display: inline-block;\n margin: 0 0.85714em 0 0;\n vertical-align: baseline;\n }\n }\n /* Required: an asterisk after the label. */\n .required.field ::slotted(label)::after,\n .required:is(.grouped, .inline).fields ::slotted(label)::after,\n .ui.form .required.field > label::after,\n .ui.form .required:is(.grouped, .inline).fields > label::after,\n .ui.form .required.fields:not(.grouped, .inline) > .field > label::after {\n content: \"*\";\n display: inline-block;\n margin: -0.2em 0 0 0.2em;\n color: var(--_ui-form-required-color, var(--ui-form-required-color, var(--ui-negative-text)));\n vertical-align: top;\n }\n .required.fields:not(.grouped, .inline) {\n --_ui-fields-required: 1;\n }\n @container style(--_ui-fields-required: 1) {\n .field ::slotted(label)::after {\n content: \"*\";\n display: inline-block;\n margin: -0.2em 0 0 0.2em;\n color: var(--_ui-form-required-color, var(--ui-form-required-color, var(--ui-negative-text)));\n vertical-align: top;\n }\n }\n\n /* Inverted: light labels. */\n .ui.inverted.form {\n --_ui-form-label-color: var(--_ui-form-inverted-label-color);\n color: var(--_ui-form-inverted-label-color);\n }\n\n /* Unstackable */\n .ui.unstackable.form {\n --_ui-form-unstackable: 1;\n }\n\n /* Stack with: the form's own width (the default) or the screen's, read by its rows. */\n .ui.stack-with-page.form {\n --_ui-form-stack-with: page;\n }\n .ui.stack-with-container.form {\n --_ui-form-stack-with: container;\n }\n\n /*\n * Narrow forms stack their rows: below 768px of the FORM (`stack-with=\"container\"`, the default; UNNAMED:\n * WebKit can't see a container name from another shadow tree) ...\n */\n @container (width < 768px) {\n @container style(not (--_ui-form-unstackable: 1)) and style(not (--_ui-form-stack-with: page)) {\n .fields:not(.unstackable) {\n --_ui-fields-child-width: 100%;\n --_ui-fields-stacked: 1;\n --_ui-fields-field-margin: 0 0 var(--_ui-form-row-distance, var(--ui-form-row-distance, 1em));\n flex-wrap: wrap;\n margin-block-end: 0;\n }\n }\n }\n /* ... or of the screen (`stack-with=\"page\"`). */\n @media (--ui-mobile) {\n @container style(not (--_ui-form-unstackable: 1)) and style(--_ui-form-stack-with: page) {\n .fields:not(.unstackable) {\n --_ui-fields-child-width: 100%;\n --_ui-fields-stacked: 1;\n --_ui-fields-field-margin: 0 0 var(--_ui-form-row-distance, var(--ui-form-row-distance, 1em));\n flex-wrap: wrap;\n margin-block-end: 0;\n }\n }\n }\n @container style(--_ui-fields-stacked: 1) {\n .field {\n width: 100%;\n }\n }\n}\n\n/*******************************\n States\n*******************************/\n\n@layer ui.components.form.states {\n /*\n * Field states: resolved colours for the controls, tinted labels. Per state, not a `--ui-color` read:\n * fields have no `ui` class, so `colors.css`'s `.ui.error` remap never runs on them (as Fomantic's `.field.error`).\n */\n :is(.field, .fields).error {\n --_ui-field-state-color: var(--ui-error-text);\n --_ui-field-state-background: var(--ui-error-background);\n --_ui-field-state-border: var(--ui-error-border);\n }\n :is(.field, .fields).info {\n --_ui-field-state-color: var(--ui-info-text);\n --_ui-field-state-background: var(--ui-info-background);\n --_ui-field-state-border: var(--ui-info-border);\n }\n :is(.field, .fields).success {\n --_ui-field-state-color: var(--ui-success-text);\n --_ui-field-state-background: var(--ui-success-background);\n --_ui-field-state-border: var(--ui-success-border);\n }\n :is(.field, .fields).warning {\n --_ui-field-state-color: var(--ui-warning-text);\n --_ui-field-state-background: var(--ui-warning-background);\n --_ui-field-state-border: var(--ui-warning-border);\n }\n :is(.field, .fields):is(.error, .info, .success, .warning) {\n --_field-label-color: var(--_ui-field-state-color);\n }\n\n /* Disabled: dimmed, inert (the element sets `inert`). */\n :is(.field, .fields).disabled,\n .ui.disabled.form {\n opacity: var(--_ui-form-disabled-opacity, var(--ui-form-disabled-opacity, var(--ui-disabled-opacity)));\n pointer-events: none;\n }\n\n /* Loading: dimmed behind a spinner. */\n .ui.loading.form {\n cursor: default;\n pointer-events: none;\n }\n .ui.loading.form::before {\n content: \"\";\n position: absolute;\n inset: 0;\n z-index: 100;\n background: var(--_ui-form-loader-dimmer);\n }\n .ui.loading.form::after {\n content: \"\";\n position: absolute;\n top: 50%;\n left: 50%;\n z-index: 101;\n box-sizing: border-box;\n width: var(--_ui-form-loader-size);\n height: var(--_ui-form-loader-size);\n margin: calc(var(--_ui-form-loader-size) / -2) 0 0 calc(var(--_ui-form-loader-size) / -2);\n border: var(--_ui-form-loader-width) solid var(--_ui-form-loader-fill);\n border-top-color: var(--_ui-form-loader-line);\n border-radius: var(--ui-radius-circle);\n animation: ui-form-spin var(--_ui-form-loader-speed) linear infinite;\n }\n\n @media (prefers-reduced-motion: reduce) {\n .ui.loading.form::after {\n animation-duration: calc(var(--_ui-form-loader-speed) * 4);\n }\n }\n}\n","/*\n * The style sheet of `<ui-field>`'s own parts, adopted AFTER the family's (`UIForm.css`, which lays the field out).\n * - Markup: `div.field` > `.row` (`.label`, `.actions`, `.output`, `.info` > `.tip`), `.control` (the default slot),\n * `.hint`, `.error.prompt`.\n * - The label row is drawn only when it has something in it; its label reads the form's label tokens, so it\n * looks like a slotted `<label>`.\n * Actions, the output (mono, muted) and the info icon (faded, its tip a dark bubble under it) sit at its end.\n * Actions never grow the row: a taller pill overhangs it.\n * - `.control` has no box (`display: contents`): the controls lay out as they did before the row existed.\n * - Errors are plain lines under the control, in the error colour.\n * - Public tokens (`--ui-field-*`) are never declared here: read through private aliases.\n */\n\n@layer ui.components.field.types, ui.components.field.content, ui.components.field.states;\n\n@layer ui.components.field.types {\n .field {\n --_ui-field-row-gap: var(--ui-field-row-gap, 0.5em);\n --_ui-field-output-color: var(--ui-field-output-color, var(--ui-text-muted));\n --_ui-field-hint-color: var(--ui-field-hint-color, var(--ui-text-muted));\n --_ui-field-error-color: var(--ui-field-error-color, var(--ui-negative-text));\n --_ui-field-tip-background: var(--ui-field-tip-background, var(--ui-text-dark));\n --_ui-field-tip-color: var(--ui-field-tip-color, var(--ui-text-inverted-color));\n --_ui-field-tip-width: var(--ui-field-tip-width, 16.25em);\n /* how long a hover waits before the tip shows; keyboard focus shows it at once */\n --_ui-field-tip-delay: var(--ui-field-tip-delay, var(--ui-hover-delay, 0s));\n }\n .field > .control {\n display: contents;\n }\n}\n\n@layer ui.components.field.content {\n /* ## The label row: above the control, the form's label look */\n .field > .row {\n display: flex;\n align-items: center;\n gap: var(--_ui-field-row-gap);\n margin: 0 0 var(--_ui-form-label-distance, var(--ui-form-label-distance, 0.28571em));\n color: var(--_field-label-color, var(--_ui-form-label-color, var(--ui-form-label-color, var(--ui-text-color))));\n font-size: var(--_ui-form-label-font-size, var(--ui-form-label-font-size, 0.92857em));\n font-weight: var(--_ui-form-label-font-weight, var(--ui-form-label-font-weight, var(--ui-font-weight-bold)));\n line-height: 1.2;\n }\n .field > .row > .label {\n flex: 0 1 auto;\n min-width: 0;\n margin-inline-end: auto;\n }\n .required.field > .row > .label::after {\n content: \"*\";\n display: inline-block;\n margin: -0.2em 0 0 0.2em;\n color: var(--_ui-form-required-color, var(--ui-form-required-color, var(--ui-negative-text)));\n vertical-align: top;\n }\n /* Actions keep the row's height: a taller pill (a mini `<ui-button>`) overhangs it evenly, so the row never grows\n when one appears (a Reset shown once the value changes), and the control under it never moves */\n .field > .row > .actions {\n display: inline-flex;\n align-items: center;\n gap: 0.25em;\n height: 1.2em;\n }\n .field > .row > .output {\n color: var(--_ui-field-output-color);\n font-family: var(--ui-font-family-mono);\n font-size: 0.92em;\n font-weight: var(--ui-font-weight-normal);\n font-variant-numeric: tabular-nums;\n }\n\n /* A hint in the label row (a compact property editor's): light, cut short, the whole text its tooltip */\n .field > .row > .hint {\n flex: 0 1 auto;\n min-width: 0;\n overflow: hidden;\n color: var(--_ui-field-hint-color);\n font-size: 0.84615em;\n font-weight: var(--ui-font-weight-normal);\n text-overflow: ellipsis;\n white-space: nowrap;\n }\n\n /* ## The not-saved icon: a save icon, a line through it */\n .field > .row > .unsaved {\n position: relative;\n display: inline-flex;\n width: 1em;\n height: 1em;\n opacity: 0.5;\n cursor: help;\n }\n .field > .row > .unsaved > svg {\n width: 100%;\n height: 100%;\n fill: currentColor;\n }\n .field > .row > .unsaved::after {\n content: \"\";\n position: absolute;\n inset-block-start: 50%;\n inset-inline-start: -10%;\n width: 120%;\n height: 0.15em;\n border-radius: 0.1em;\n background: currentColor;\n box-shadow: 0 0 0 0.06em var(--ui-panel-background, transparent);\n transform: rotate(-45deg);\n }\n\n /* ## The info icon and its tip */\n .field > .row > .info {\n position: relative;\n display: inline-flex;\n width: 1em;\n height: 1em;\n opacity: 0.4;\n cursor: help;\n border-radius: var(--ui-radius-circle, 50%);\n }\n .field > .row > .info:is(:hover, :focus-visible) {\n opacity: 1;\n }\n .field > .row > .info:focus-visible {\n outline: var(--ui-focus-width) solid var(--ui-focus-color);\n outline-offset: 2px;\n }\n .field > .row > .info > svg {\n width: 100%;\n height: 100%;\n fill: currentColor;\n }\n .field > .row > .info > .tip {\n position: absolute;\n inset-block-start: calc(100% + 0.5em);\n inset-inline-end: -0.5em;\n z-index: var(--ui-z-popup, 30);\n box-sizing: border-box;\n width: var(--_ui-field-tip-width);\n padding: 0.625em 0.75em;\n border-radius: var(--ui-radius-s, 8px);\n background: var(--_ui-field-tip-background);\n box-shadow: var(--ui-shadow-floating);\n color: var(--_ui-field-tip-color);\n font-size: 0.92em;\n font-weight: var(--ui-font-weight-normal);\n line-height: 1.45;\n opacity: 0;\n visibility: hidden;\n pointer-events: none;\n transition:\n opacity var(--ui-duration-fast) var(--ui-ease),\n visibility var(--ui-duration-fast);\n }\n /* shown: no longer faded with the icon */\n .field > .row > .info:is(:hover, :focus) > .tip {\n opacity: 1;\n visibility: visible;\n }\n .field > .row > .info:hover > .tip {\n transition-delay: var(--_ui-field-tip-delay);\n }\n /* focus shows it at once: none, not a delay of 0, which would leave a hover already waiting to run on */\n .field > .row > .info:focus > .tip {\n transition: none;\n }\n /* In the top layer while it shows (`TopLayerTip`): under the icon, flipping to stay in the window. */\n .field > .row > .info {\n anchor-name: --ui-field-info;\n }\n .field > .row > .info > .tip:popover-open {\n position: fixed;\n position-anchor: --ui-field-info;\n position-area: block-end span-inline-start;\n position-try-fallbacks:\n flip-block,\n flip-inline,\n flip-block flip-inline;\n inset: auto;\n max-width: calc(100vw - 1em);\n height: fit-content;\n margin: 0.5em 0;\n border: 0;\n overflow: visible;\n }\n .field > .row > .info:is(:hover, :focus) > .tip:popover-open {\n @starting-style {\n opacity: 0;\n visibility: hidden;\n }\n }\n\n /* ## The hint and the errors: lines under the control */\n .field > :is(.hint, .error.prompt) {\n margin: 0.375em 0 0;\n font-size: 0.85714em;\n line-height: 1.4;\n }\n .field > .hint {\n color: var(--_ui-field-hint-color);\n }\n .field > .error.prompt {\n color: var(--_ui-field-error-color);\n }\n .field > .error.prompt > .message {\n display: block;\n }\n}\n\n@layer ui.components.field.states {\n /* Inline, with a label row: the row beside the control; the hint and errors on lines of their own under both */\n .inline.field:has(> .row) {\n display: flex;\n flex-flow: row wrap;\n align-items: center;\n column-gap: 0.85714em;\n }\n .inline.field > .row {\n margin: 0;\n }\n .inline.field > .row > .label {\n margin-inline-end: 0;\n }\n .inline.field > .control {\n display: flex;\n flex: 1 1 12em;\n align-items: center;\n gap: 0.5em;\n min-width: 0;\n }\n .inline.field > :is(.hint, .error.prompt) {\n flex-basis: 100%;\n }\n /* The label row's label takes the state's colour, as a slotted label does */\n .error.field > .row > .label {\n color: var(--_ui-field-error-color);\n }\n}\n","import { For, Show } from \"solid-js\"\nimport type { JSX } from \"@solidjs/web\"\n\nimport { E, UIT } from \"spell/ui/core\"\nimport { fieldVocabulary } from \"./UIField.en\"\nimport { ERROR, FormStateFlags } from \"./UIForm.types\"\n\nimport formCSS from \"./UIForm.css?inline\"\nimport fieldCSS from \"./UIField.css?inline\"\n\n/****************\n * ### `DOMFieldElement`\n * The DOM element of `<ui-field>`: it adds `showErrors()`, which `<ui-form>` calls\n * to show (or, with `[]`, clear) the field's errors and error state.\n *\n * - No attribute is written, so the author's `state` and `error` stay theirs.\n * - `errors`: the messages `<ui-form>` asked to show.\n * - `DOMElement` checks its members against the attributes' property names; neither of these is one.\n * - Above the component: its `elementSetup` reads this class while the component is defined.\n ****************/\nexport class DOMFieldElement extends E.DOMElement<UIField> {\n /** Show `messages` as the field's errors (and `error` state); `[]` clears. */\n showErrors(messages: readonly string[]) {\n this.component?.showErrors(messages)\n }\n\n /** Messages `<ui-form>` asked to show. */\n @E.untracked\n get errors(): readonly string[] {\n return this.component?.formErrors ?? []\n }\n\n /**\n * The label it shows, and `<ui-form>`'s name for it in a message (\"Name must have a value\").\n * - Its `label`, else what its kind works out: a `<ui-property>`'s from its schema, or its name.\n */\n @E.untracked\n get shownLabel(): string | undefined {\n return this.component?.labelText\n }\n\n /** The placeholder `<ui-form>` shows in a control while its things disagree (`mixed`), in the page's language. */\n @E.untracked\n get mixedText(): string | undefined {\n return this.component?.translationForKey(\"mixed\")\n }\n}\n\n/****************\n * ### `UIField`\n * The component behind `<ui-field>`: one field of a form.\n * Its box, `<div class=\"… field\" part=\"field\">`, holds:\n * - the label row (`.row`): the label, then actions, the output, (a subclass's hint), and the info icon with its tip\n * - the control (`.control`, the default slot)\n * - then the hint and the errors\n *\n * - The label row is drawn only when it has something: `label`, actions, `output` or `description`.\n * - A field that slots its own `<label for>` with its control has no row, and no `.control` either:\n * its markup is Fomantic's, as it always was (the static render's too).\n * - `SlotContent` watches the light children for the rich slots.\n * - It names the control: a slotted control with no `aria-label` or `aria-labelledby` of its own\n * gets `aria-label` = `label`.\n * - Why: a `<label for>` can't reach across the shadow boundary.\n * - A click on the label focuses it.\n * - The tip: a tooltip under the info icon, shown on hover and keyboard focus, and at once on a click,\n * in the browser's top layer so no parent frame cuts it off (`TopLayerTip`).\n * The icon is described by it.\n *\n * - Errors: what `<ui-form>` asked for through `showErrors()`, else `error`.\n * - Shown as plain lines under the control, with `role=\"alert\"`.\n * - Either shows the `error` state.\n * - Failed validation shows `error` over the author's `state`, and clears back to it.\n *\n * - `apply`, `mixed` and `rules` are read by `<ui-form>`'s binding.\n * The field shows `mixed` as `:state(mixed)`.\n * - `readonly`: `:state(readonly)`.\n *\n * - The DOM element is `display: contents` (`UIForm.css`):\n * the root is the flex item of a `<ui-fields>` row, which hands it its width and gutter as inherited tokens.\n * - `.control` has no box either (`display: contents`), so the controls lay out as they always did.\n * - It hands its controls inherited owner tokens (`InputOwnerTokens`): full width, and its state's colours.\n *\n * - `disabled`: unusable, the base class's way (`elementSetup.disabled`):\n * - the root `inert`, so the slotted controls can't be used\n * - and `aria-disabled`\n * - The root also says `inert` itself, for the static render: the base class's reaches only a browser.\n * - Always carries `:state(field)`, which is how `<ui-form>` finds a control's field.\n * - SIDE EFFECT: writes `aria-label` on slotted controls (only ones that had no name).\n ****************/\nexport class UIField extends E.UIComponent<typeof fieldVocabulary> {\n @E.proto static vocabulary = fieldVocabulary\n // `Partial`: the property (`UIProperty`) and the editor (`UIPropertyEditor`) extend it\n @E.protoMerged static elementSetup: Partial<E.ElementSetup> = {\n styleSheets: { form: formCSS, field: fieldCSS },\n DOMElement: DOMFieldElement,\n delegatesFocus: false\n } satisfies Partial<E.ElementSetup>\n\n ////////////////\n // ## The label row\n ////////////////\n\n /** Which named slots have light-DOM content: label, description, hint, output, actions. */\n readonly slots = new E.SlotContent(this.domElement)\n\n /** The label the row shows: `label`; a subclass may find another (a property's, from its schema). */\n get labelText(): string | undefined {\n return this.label\n }\n\n /** The tip the row shows: `description`; a subclass may find another. */\n get descriptionText(): string | undefined {\n return this.description\n }\n\n /** Has a label in the row: `labelText`, or `slot=\"label\"`. */\n get hasLabel(): boolean {\n return !!this.labelText || this.slots.hasContent(this.slotForName(\"label\"))\n }\n\n /** Has actions (`slot=\"actions\"`). */\n get hasActions(): boolean {\n return this.slots.hasContent(this.slotForName(\"actions\"))\n }\n\n /** Has an output: `output`, or `slot=\"output\"`. */\n get hasOutput(): boolean {\n return !!this.output || this.slots.hasContent(this.slotForName(\"output\"))\n }\n\n /** Has a tip: `description`, or `slot=\"description\"`. */\n get hasDescription(): boolean {\n return !!this.descriptionText || this.slots.hasContent(this.slotForName(\"description\"))\n }\n\n /** The hint shown: `hint`; a subclass may find another (a property's, from its schema). */\n get hintText(): string | undefined {\n return this.hint\n }\n\n /** Why a change here can't be saved: `unsaved`; a subclass may find another (a property's, from its editor). */\n get unsavedText(): string | undefined {\n return this.unsaved || undefined\n }\n\n /** Has a hint: `hintText`, or `slot=\"hint\"`. */\n get hasHint(): boolean {\n return !!this.hintText || this.slots.hasContent(this.slotForName(\"hint\"))\n }\n\n /**\n * The hint sits at the label row's end, before the info icon, instead of under the control:\n * a subclass says so (a compact property editor's property).\n */\n get hasHintInRow(): boolean {\n return false\n }\n\n /** Draws the label row: it has something in it. */\n get hasRow(): boolean {\n return (\n this.hasLabel ||\n this.hasActions ||\n this.hasOutput ||\n this.hasDescription ||\n this.hasHintInRow ||\n !!this.unsavedText\n )\n }\n\n /** The label's tooltip: none here; a subclass may give one (a property says where its value comes from). */\n get labelTitle(): string | undefined {\n return undefined\n }\n\n /** Glyph of the info icon, while there's a tip. */\n readonly infoGlyph = new E.IconGlyph({ owner: this, name: () => (this.hasDescription ? INFO_ICON : undefined) })\n\n /** Glyph of the not-saved icon, while a change here can't be saved: a save icon, crossed out by CSS. */\n readonly unsavedGlyph = new E.IconGlyph({ owner: this, name: () => (this.unsavedText ? UNSAVED_ICON : undefined) })\n\n ////////////////\n // ## Errors\n ////////////////\n\n /** Messages `<ui-form>` asked to show; `DOMFieldElement.errors` reads them untracked. */\n @E.state accessor formErrors: readonly string[] = []\n\n /** Error lines shown: `<ui-form>`'s, else `error`. */\n get errors(): readonly string[] {\n const fromForm = this.formErrors\n if (fromForm.length) return fromForm\n return this.error ? [this.error] : []\n }\n\n /** Show `messages` (see `DOMFieldElement`). */\n @E.untracked\n showErrors(messages: readonly string[]) {\n const current = this.formErrors\n if (current.length !== messages.length || current.some((message, index) => message !== messages[index])) {\n this.formErrors = [...messages]\n }\n }\n\n ////////////////\n // ## State and classes\n ////////////////\n\n /** The state shown: `error` while there's an error, else the attribute. */\n get shownState(): UIT.FormState | undefined {\n return this.errors.length ? ERROR : this.state\n }\n\n /** `:state(error)`, `:state(info)` ...: the state shown. */\n protected cssStates() {\n return FormStateFlags.of(this.shownState)\n }\n\n /** `:state(mixed)`: the things being edited disagree (`mixed`). */\n @E.cssState(\"mixed\")\n get isMixed(): boolean {\n return !!this.mixed\n }\n\n /** `:state(readonly)`: `readonly`. */\n @E.cssState(\"readonly\")\n get isReadOnly(): boolean {\n return !!this.readonly\n }\n\n /** Always `:state(field)`: how `<ui-form>` finds a control's field. */\n @E.cssState(\"field\")\n get isField(): boolean {\n return true\n }\n\n protected classValue(name: E.AttributeName<typeof fieldVocabulary>): unknown {\n if (name === \"state\") return this.shownState\n return super.classValue(name)\n }\n\n ////////////////\n // ## Rendering\n ////////////////\n\n render(): JSX.Element {\n return (\n <div class={this.rootClass} part={this.partForName(\"field\")} inert={this.disabled}>\n <Show when={this.hasRow} fallback={this.controlSlotElement()}>\n {this.labelRow()}\n <div class={CLASSES.control} part={this.partForName(\"control\")}>\n {this.controlStart()}\n {this.controlSlotElement()}\n </div>\n </Show>\n <Show when={this.hasHint && !this.hasHintInRow}>\n <div class={CLASSES.hint} part={this.partForName(\"hint\")}>\n <slot name={this.slotForName(\"hint\")}>{this.hintText}</slot>\n </div>\n </Show>\n <Show when={this.errors.length}>\n <div class={CLASSES.error} part={this.partForName(\"error\")} role=\"alert\">\n <For each={this.errors}>{(message) => <div class={UIT.MESSAGE}>{message}</div>}</For>\n </div>\n </Show>\n </div>\n )\n }\n\n /** What a subclass adds at the label row's far end, before the hint: nothing here. */\n protected rowEnd(): JSX.Element {\n return undefined\n }\n\n /** The label row: the label, then (at its far end) actions, the output and the info icon with its tip. */\n private labelRow(): JSX.Element {\n return (\n <div class={CLASSES.row} part={this.partForName(\"row\")}>\n <span\n class={CLASSES.label}\n part={this.partForName(\"label\")}\n title={this.labelTitle}\n onClick={this.onLabelClick}\n >\n <slot name={this.slotForName(\"label\")}>{this.labelText}</slot>\n </span>\n <Show when={this.hasActions}>\n <span class={CLASSES.actions} part={this.partForName(\"actions\")}>\n <slot name={this.slotForName(\"actions\")} />\n </span>\n </Show>\n <Show when={this.hasOutput}>\n <span class={CLASSES.output} part={this.partForName(\"output\")}>\n <slot name={this.slotForName(\"output\")}>{this.output}</slot>\n </span>\n </Show>\n {this.rowEnd()}\n <Show when={this.hasHint && this.hasHintInRow}>\n <span class={CLASSES.hint} part={this.partForName(\"hint\")} title={this.hintText}>\n <slot name={this.slotForName(\"hint\")}>{this.hintText}</slot>\n </span>\n </Show>\n <Show when={this.hasDescription}>\n <span\n ref={(info) => E.TopLayerTip.showIn(info, `.${CLASSES.info}`, { showOnClick: true })}\n class={CLASSES.info}\n part={this.partForName(\"info\")}\n tabindex=\"0\"\n role=\"img\"\n aria-label={this.translationForKey(\"info\", { label: this.labelText ?? \"\" })}\n aria-describedby={TIP_ID}\n >\n {this.infoGlyph.svg}\n <span id={TIP_ID} class={CLASSES.tip} part={this.partForName(\"tip\")} role=\"tooltip\">\n <slot name={this.slotForName(\"description\")}>{this.descriptionText}</slot>\n </span>\n </span>\n </Show>\n <Show when={this.unsavedText}>\n <span\n class={CLASSES.unsaved}\n part={this.partForName(\"unsaved\")}\n title={this.unsavedText}\n role=\"img\"\n aria-label={this.unsavedText}\n >\n {this.unsavedGlyph.svg}\n </span>\n </Show>\n </div>\n )\n }\n\n ////////////////\n // ## The control\n ////////////////\n\n /** Drawn before the slotted control, under a label row: a subclass's own (nothing here). */\n protected controlStart(): JSX.Element {\n return undefined\n }\n\n /** The default slot, holding the control(s). */\n private controlSlot?: HTMLSlotElement\n\n /**\n * The default slot: in `.control` under a label row, else straight in the field's box.\n * - Straight in the box for a field with no row (one that slots its own `<label>`):\n * its markup, and the static render's, stay Fomantic's (`.field > label`).\n */\n private controlSlotElement(): JSX.Element {\n return <slot ref={(element) => (this.controlSlot = element)} onSlotChange={this.onControlChange} />\n }\n\n /** Controls this field named (`aria-label`), so a new `label` renames them and nothing else. */\n private readonly named = new WeakSet<Element>()\n\n /** A new `label`, once drawn: rename the controls this field named. */\n @E.onChange(\"labelText\", \"isReady\")\n protected onLabelChanged(label: string | undefined, isReady: boolean) {\n if (isReady) this.nameControls(label)\n }\n\n /** The slotted controls changed: name the new ones. */\n @E.untracked\n private readonly onControlChange = () => {\n this.nameControls(this.labelText)\n }\n\n /**\n * Give each slotted control without a name of its own `aria-label` = `label`.\n * - A slotted `<label>` is skipped: it names its control itself.\n * - SIDE EFFECT: writes the controls' `aria-label`.\n * Only ones this field named before are renamed or cleared.\n */\n private nameControls(label: string | undefined) {\n for (const control of this.controlSlot?.assignedElements() ?? []) {\n if (control.localName === \"label\") continue\n const hasOwnName = NAMED_ATTRIBUTES.some((name) => control.hasAttribute(name)) && !this.named.has(control)\n if (hasOwnName) continue\n if (label) {\n control.setAttribute(\"aria-label\", label)\n this.named.add(control)\n } else if (this.named.has(control)) {\n control.removeAttribute(\"aria-label\")\n this.named.delete(control)\n }\n }\n }\n\n /** A click on the label focuses the first control, as a `<label for>` would. */\n private readonly onLabelClick = () => {\n const control = this.controlSlot?.assignedElements().find((element) => element.localName !== \"label\")\n ;(control as HTMLElement | undefined)?.focus()\n }\n}\n\n/** The vocabulary getters, typed (`UIComponent`'s doc). */\nexport interface UIField extends E.AttributeValues<typeof fieldVocabulary> {}\n\n/** Icon of the tip. */\nconst INFO_ICON = \"circle info\"\n\n/** The not-saved icon: a save icon, which the CSS crosses out. */\nconst UNSAVED_ICON = \"save\"\n\n/** Shadow-root id of the tip, which the info icon is described by. */\nconst TIP_ID = \"tip\"\n\n/** A control with one of these has a name of its own: the field doesn't name it. */\nconst NAMED_ATTRIBUTES = [\"aria-label\", \"aria-labelledby\"] as const\n\n/** Shadow classes, one per part (the vocabulary's part names). */\nconst CLASSES = {\n row: \"row\",\n label: \"label\",\n actions: \"actions\",\n output: \"output\",\n info: \"info\",\n tip: \"tip\",\n unsaved: \"unsaved\",\n control: \"control\",\n hint: \"hint\",\n error: \"error prompt\"\n} as const\n","/**\n * The English vocabulary of `<ui-fields>`: every name the tag uses.\n * - Its tag, attributes (each with its kind and allowed values), slots, parts and states.\n * The shape is `E.ComponentVocabulary` (`spell/ui/vocabulary`).\n * - Pure data: node imports it (`yarn site:data`, `yarn gen:root`), so `spell/ui/core` for types only,\n * `UIT` by value straight from `components.types`.\n * - The family's grammar notes are in `UIForm.en.ts`.\n */\n\nimport type { E } from \"spell/ui/core\"\nimport * as UIT from \"spell/ui/components/components.types\"\nimport { STATE_STATES } from \"./UIForm.types\"\n\n/****************\n * ### `fieldsVocabulary`\n * The names of `<ui-fields>`, a row (or group) of fields: `<div class=\"… fields\" part=\"fields\"><slot></slot></div>`.\n ****************/\nexport const fieldsVocabulary = {\n tag: \"ui-fields\",\n icon: \"wpforms\",\n topics: [\"forms\", \"layout\", \"collections\"],\n aka: [\"field group\", \"form row\", \"inline fields\"],\n noun: \"fields\",\n ui: false,\n description: \"A set of fields can appear grouped together, side by side or stacked.\",\n attributes: [\n {\n name: \"state\",\n group: \"form\",\n kind: \"valueOnly\",\n values: UIT.FormStates,\n description: \"State of every field inside.\"\n },\n { name: \"inline\", group: \"layout\", kind: \"keyOnly\", description: \"Fields and their labels on one line.\" },\n {\n name: \"grouped\",\n group: \"content\",\n kind: \"keyOnly\",\n description: \"Fields stacked under one label (radio / checkbox groups).\"\n },\n { name: \"unstackable\", group: \"layout\", kind: \"keyOnly\", description: \"Never stacks on a narrow form.\" },\n {\n name: \"required\",\n group: \"form\",\n kind: \"keyOnly\",\n description: \"Marks every field label (or the group label) with an asterisk.\"\n },\n { name: \"disabled\", group: \"states\", kind: \"keyOnly\", description: \"Every field dimmed and not usable.\" },\n {\n name: \"equal\",\n group: \"layout\",\n kind: \"keyOnly\",\n key: \"equal width\",\n description:\n \"Every field the same width, from the fields themselves (no count): an equal share of the row each \" +\n '(Fomantic\\'s `equal width fields`; ~== `widths=\"equal\"`).'\n },\n {\n name: \"widths\",\n group: \"appearance\",\n kind: \"width\",\n widthClass: \"\",\n canEqual: true,\n values: [\"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\"],\n description:\n 'Older, count-based alias of `equal`: fields per row, sharing it equally (`widths=\"2\"` => `two fields`); ' +\n '`\"equal\"` => any number (`equal width`).'\n }\n ],\n events: [],\n slots: [{ name: \"\", description: \"`<ui-field>`s, and a `<label>` for a grouped / inline set.\" }],\n parts: [{ name: \"fields\", description: \"The row box.\" }],\n states: [...STATE_STATES, { name: \"disabled\", description: \"Can't be used.\" }],\n texts: []\n} as const satisfies E.ComponentVocabulary\n","import type { JSX } from \"@solidjs/web\"\n\nimport { E } from \"spell/ui/core\"\nimport { fieldsVocabulary } from \"./UIFields.en\"\nimport { FormStateFlags } from \"./UIForm.types\"\n\nimport formCSS from \"./UIForm.css?inline\"\n\n/****************\n * ### `UIFields`\n * The component behind `<ui-fields>`:\n * a row (or a `grouped` stack) of fields, `<div class=\"… fields\" part=\"fields\"><slot></slot></div>`.\n *\n * - The DOM element is `display: contents`; the root is the flex row,\n * and hands each `<ui-field>` its share of the width (`widths`), the gutter and its state\n * as inherited tokens (`UIForm.css`).\n * - `disabled`: unusable, the base class's way (`elementSetup.disabled`):\n * the root `inert`, `aria-disabled`.\n * - The root also says `inert` itself, for the static render: the base class's reaches only a browser.\n ****************/\nexport class UIFields extends E.UIComponent<typeof fieldsVocabulary> {\n @E.proto static vocabulary = fieldsVocabulary\n @E.protoMerged static elementSetup = {\n styleSheets: { form: formCSS },\n delegatesFocus: false\n } satisfies Partial<E.ElementSetup>\n\n /** `:state(error)`, `:state(info)` ...: its `state`. */\n protected cssStates() {\n return FormStateFlags.of(this.state)\n }\n\n render(): JSX.Element {\n return (\n <div class={this.rootClass} part={this.partForName(\"fields\")} inert={this.disabled}>\n <slot />\n </div>\n )\n }\n}\n\n/** The vocabulary getters, typed (`UIComponent`'s doc). */\nexport interface UIFields extends E.AttributeValues<typeof fieldsVocabulary> {}\n","/**\n * The English vocabulary of `<ui-form>`: every name the tag uses.\n * - Its tag, attributes (each with its kind and allowed values), events, slots, parts, states and texts.\n * The shape is `E.ComponentVocabulary` (`spell/ui/vocabulary`).\n * - Pure data: node imports it (`yarn site:data`, `yarn gen:root`), so `spell/ui/core` for types only,\n * `UIT` by value straight from `components.types`.\n * - The notes below are the whole family's: `<ui-field>`, `<ui-fields>` and `<ui-repeat>` too.\n * - Class words come out through `ClassBuilder`, in Fomantic's grammar:\n * - `<ui-form size=\"large\" state=\"error\">` => `ui large error form`\n * - `<ui-field width=\"4\" required>` => `required four wide field`\n * - `<ui-fields widths=\"2\" inline>` => `inline two fields`, `widths=\"equal\"` => `equal width fields`\n * - Fields have no `ui` (Fomantic styles them inside `.ui.form`).\n * - `state` is `kind: \"valueOnly\"`: it emits its value alone (`error field`), a remap in `colors.css`.\n * - Validation lives on `<ui-form>`: `rules` is a PROPERTY (`json`) in Fomantic's `fields` shape.\n * - Binding too: `value` is a PROPERTY (`json`), the object its named controls show and edit.\n * `<ui-repeat name>` repeats its fields per item of one of its lists.\n */\n\nimport type { E } from \"spell/ui/core\"\nimport * as UIT from \"spell/ui/components/components.types\"\nimport { FormApplyModes, STATE_STATES, ValidationTriggers } from \"./UIForm.types\"\n\n/****************\n * ### `formVocabulary`\n * The names of `<ui-form>`: a form's look and its validation,\n * around a NATIVE `<form>` (slotted inside it, or around it).\n * - Its shadow DOM: `<div class=\"ui … form\" part=\"form\"><slot></slot></div>`.\n ****************/\nexport const formVocabulary = {\n tag: \"ui-form\",\n icon: \"wpforms\",\n topics: [\"forms\", \"inputs\", \"basic\", \"collections\"],\n aka: [\"form layout\", \"fieldset\", \"validation\"],\n noun: \"form\",\n description: \"A form displays a set of related input fields in a structured way.\",\n attributes: [\n {\n name: \"fluid\",\n group: \"layout\",\n kind: \"boolean\",\n description:\n \"In a `<ui-stack>`'s row, takes the room left: a search field between a logo and a button. With the shared \" +\n '`min-width` and `max-width`, between those (`fluid min-width=\"16em\" max-width=\"26em\"`).'\n },\n {\n name: \"size\",\n group: \"appearance\",\n kind: \"size\",\n description: \"Size of everything inside, `mini` ... `massive`.\"\n },\n {\n name: \"state\",\n group: \"form\",\n kind: \"valueOnly\",\n values: UIT.FormStates,\n description:\n \"Form state: shows the `<ui-message>`s of that state inside. Failed validation sets `error` on top.\"\n },\n {\n name: \"equal-width\",\n group: \"layout\",\n kind: \"keyOnly\",\n key: \"equal width\",\n description: \"Every row of fields shares its width equally.\"\n },\n { name: \"inverted\", group: \"appearance\", kind: \"keyOnly\", description: \"For dark backgrounds: light labels.\" },\n { name: \"loading\", group: \"states\", kind: \"keyOnly\", description: \"Busy: dimmed behind a spinner, not usable.\" },\n { name: \"disabled\", group: \"states\", kind: \"keyOnly\", description: \"Nothing inside can be used (`inert`).\" },\n {\n name: \"unstackable\",\n group: \"layout\",\n kind: \"keyOnly\",\n description: \"Rows of fields never stack on narrow forms.\"\n },\n {\n name: \"stack-with\",\n group: \"layout\",\n kind: \"enum\",\n values: UIT.StackWithValues,\n description:\n \"What its rows of fields stack by: `container` (the default) -- the form's own width; `page` -- \" +\n \"the screen's, as in Fomantic. Its `<ui-fields>` follow it. Unset: the page-wide \" +\n \"`--ui-stack-with` token decides (`<ui-root stack-with>`).\"\n },\n {\n name: \"validate\",\n group: \"form\",\n kind: \"enum\",\n // not `validate`: that's the DOM element's `validate()`\n property: \"validateOn\",\n values: ValidationTriggers,\n default: \"on save\",\n description:\n \"When fields validate: `immediately`, as each changes; `on leave`, as the cursor leaves each; or only \" +\n \"`on save` (a submit, or `save()`). A field showing an error always validates again as it changes.\"\n },\n {\n name: \"apply\",\n group: \"form\",\n kind: \"enum\",\n values: FormApplyModes,\n default: \"immediately\",\n description:\n \"When edits land in the bound `value`: `immediately`; or `on save`, all together on `save()`, while \" +\n \"`cancel()` drops them (`:state(changed)` while any are held). Each field's own `apply` says when it takes an edit.\"\n },\n {\n name: \"rules\",\n group: \"form\",\n kind: \"json\",\n reflect: false,\n description:\n 'Validation rules by field name (or id), Fomantic\\'s `fields` shape: `{ email: \"email\", password: ' +\n '[\"notEmpty\", \"minLength[6]\"], name: { rules: [{ type: \"notEmpty\", prompt: \"...\" }], optional: true } }`.'\n },\n {\n name: \"error-focus\",\n group: \"advanced\",\n kind: \"boolean\",\n default: true,\n description: 'Focus the first invalid field when a submit fails; `error-focus=\"no\"` to keep focus.'\n },\n {\n name: \"prevent-leaving\",\n group: \"advanced\",\n kind: \"boolean\",\n description: \"Ask before leaving the page while fields differ from their starting values.\"\n },\n {\n name: \"value\",\n group: \"form\",\n kind: \"json\",\n reflect: false,\n description:\n \"The object the form is BOUND to: each control with a `name` shows that property and writes it back as \" +\n \"it changes, live both ways (Solid signals, reactive members, spell objects); a control in a \" +\n \"`<ui-repeat>` row binds to the row's item. Unset: nothing is bound.\"\n },\n {\n name: \"debug\",\n group: \"advanced\",\n kind: \"boolean\",\n description: \"Show the bound `value` (else `values`) as JSON below the form, live.\"\n }\n ],\n events: [\n {\n name: \"ui-valid\",\n detail: \"{ field: string, value: FieldValue, values: Record<string, FieldValue> }\",\n description: \"A field passed validation.\"\n },\n {\n name: \"ui-invalid\",\n detail: \"{ field: string, value: FieldValue, errors: string[], values: Record<string, FieldValue> }\",\n description: \"A field failed validation; `errors` are its prompts.\"\n },\n {\n name: \"ui-saving\",\n detail: \"{ values: Record<string, FieldValue>, originalEvent?: Event }\",\n cancelable: true,\n description:\n \"A submit passed validation; `preventDefault()` stops the native submission (e.g. to send it by fetch).\"\n },\n {\n name: \"ui-save-failed\",\n detail: \"{ values: Record<string, FieldValue>, errors: Record<string, string[]>, originalEvent?: Event }\",\n description: \"A submit failed validation (the native submission is stopped); `errors` by field.\"\n },\n {\n name: \"ui-applying\",\n detail: \"{ changes: FormChange[], value: unknown }\",\n cancelable: true,\n description:\n '`save()`, with `apply=\"on save\"`: the held edits are about to land; `preventDefault()` keeps them held.'\n },\n {\n name: \"ui-applied\",\n detail: \"{ changes: FormChange[], value: unknown }\",\n description: \"The held edits landed in the bound `value`.\"\n },\n {\n name: \"ui-cancelling\",\n detail: \"{ changes: FormChange[] }\",\n cancelable: true,\n description: \"`cancel()`: the held edits are about to be dropped; `preventDefault()` keeps them.\"\n },\n {\n name: \"ui-cancelled\",\n detail: \"{ changes: FormChange[] }\",\n description: \"The held edits were dropped: every control shows the bound `value` again.\"\n }\n ],\n slots: [{ name: \"\", description: \"The native `<form>` (or its content, when the `<ui-form>` sits inside one).\" }],\n parts: [\n { name: \"form\", description: \"The form box.\" },\n { name: \"debug\", description: \"The JSON `debug` shows, a `<pre>` in a captioned box below the content.\" }\n ],\n states: [\n ...STATE_STATES,\n { name: \"loading\", description: \"Busy.\" },\n { name: \"changed\", description: '`apply=\"on save\"`: edits are held, not saved yet.' },\n { name: \"disabled\", description: \"Can't be used.\" },\n {\n name: \"root\",\n description:\n \"Always on: the form's own host (its sheet also styles `<ui-fields>` / `<ui-field>` hosts), a block and the size container its rows stack by.\"\n }\n ],\n texts: [\n { key: \"formDebugBound\", text: \"Bound object\", description: \"Caption of `debug`'s JSON while the form is bound.\" },\n {\n key: \"formDebugValues\",\n text: \"Values\",\n description: \"Caption of `debug`'s JSON while it isn't: the form's `values`.\"\n }\n ]\n} as const satisfies E.ComponentVocabulary\n","import { Show } from \"solid-js\"\nimport { isServer, type JSX } from \"@solidjs/web\"\n\nimport { E, UIT } from \"spell/ui/core\"\nimport { formVocabulary } from \"./UIForm.en\"\nimport { FormBinding } from \"./FormBinding\"\nimport { FormFields } from \"./FormFields\"\nimport type { DOMFieldElement } from \"./UIField\"\nimport { ERROR, FIELD_SELECTOR, FormStateFlags, type Field } from \"./UIForm.types\"\n\nimport formCSS from \"./UIForm.css?inline\"\n\n/****************\n * ### `DOMFormElement`\n * The DOM element of `<ui-form>`, as `HTMLFormElement` is `<form>`'s:\n * it adds the form's script API (`validate()`, `isValid()`, `reset()`, `clear()`, `values`, `nativeForm`),\n * each handed to the component.\n *\n * - Before the component exists, it answers as an empty form: valid, no values, no native form.\n * - `DOMElement` checks its members against the attributes' property names; none of these is one.\n * - Above the component: its `elementSetup` reads this class while the component is defined.\n ****************/\nexport class DOMFormElement extends E.DOMElement<UIForm> {\n /** Validate every field, show prompts and states; true when valid. */\n validate(): boolean {\n return this.component?.validateFields() ?? true\n }\n\n /** The same verdict as `validate()`, showing nothing. */\n isValid(): boolean {\n return this.component?.isValid() ?? true\n }\n\n /** The native form's reset (controls back to their starting values), then prompts cleared. */\n reset() {\n this.component?.reset()\n }\n\n /** Every control emptied (text `\"\"`, checkboxes unchosen), then prompts cleared. */\n clear() {\n this.component?.clear()\n }\n\n /**\n * `apply=\"on save\"`: the held edits land in the bound `value`, after every field validates.\n * - `ui-applying` (cancelable), then `ui-applied`.\n * - True when they landed.\n */\n save(): boolean {\n return this.component?.save() ?? false\n }\n\n /**\n * `apply=\"on save\"`: drop the held edits.\n * - `ui-cancelling` (cancelable), then `ui-cancelled`.\n * - True when dropped.\n */\n cancel(): boolean {\n return this.component?.cancel() ?? false\n }\n\n /** Every field's value, by name (Fomantic's `get values`). */\n get values(): UIT.FormValues {\n return this.component?.values ?? {}\n }\n\n /** The `<form>` it works with, if any. */\n @E.untracked\n get nativeForm(): HTMLFormElement | undefined {\n return this.component?.nativeForm\n }\n}\n\n/****************\n * ### `UIForm`\n * The component behind `<ui-form>`: a form's look and its VALIDATION, over a NATIVE form.\n * - Its look: `<div class=\"ui … form\" part=\"form\"><slot></slot></div>`.\n *\n * - Why not a form of its own:\n * a form-associated control belongs to the nearest `<form>` ANCESTOR in its own tree.\n * - So a `<form>` in this shadow root would never own the slotted controls.\n * - And a custom element can't BE a form.\n * - So `<ui-form>` works with a light-DOM `<form>`: one slotted INSIDE it (`<ui-form><form>…`, preferred),\n * else the one AROUND it (`<form><ui-form>…`).\n * - It never creates or moves one: frameworks own that DOM.\n * - Without any, it still validates (`validate()`, `validate=\"on leave | immediately\"`), but nothing submits.\n *\n * - SIDE EFFECT: sets `noValidate` on that form while connected (restored after),\n * so the browser's bubbles don't pre-empt Fomantic's prompts;\n * constraint validation still counts (see `FormFields.errors()`).\n *\n * - Submit (in the capture phase, on the form): every field validates.\n * - Invalid: the prompts, the `error` state, `ui-save-failed`, and focus on the first invalid field (`error-focus`);\n * plus `preventDefault()` and `stopImmediatePropagation()`,\n * so the page's own submit handlers never see an invalid form, as natively.\n * - Valid: the cancelable `ui-saving` (cancelled => no native submission).\n *\n * - Prompts: each field's first control's `<ui-field>` (`:state(field)`) gets `showErrors()`.\n * - Failing controls get `aria-invalid=\"true\"` (removed when they pass).\n * - A field that shows an error validates again as it changes, whatever `validate` says.\n * - `validate`, when fields validate:\n * - `on save` (the default): on submit and `save()`\n * - `on leave`: also as the cursor leaves a field\n * - `immediately`: also as one changes\n * - Each field's rules: the form's `rules` for it, plus its `<ui-field rules>`.\n *\n * - `ui-valid` / `ui-invalid` fire per field validated.\n * - The script API (`values`, `validate()`, `isValid()`, `reset()`, `clear()`) is the DOM element's, `DOMFormElement`.\n *\n * - `prevent-leaving`: a `beforeunload` guard while the values differ from those at connect, reset or success.\n *\n * - `value`: the form is BOUND to that object (`FormBinding`).\n * - each named control shows its property, and writes it back as the person changes it\n * - a control inside a `<ui-repeat>` row binds to that row's item instead\n * - live both ways, for anything Solid follows (signals, reactive members, spell's objects)\n * - after a reset or a clear, the object takes the controls' values\n * - a LIST of things binds each control to all of them: the value they agree on, else blank and `mixed`\n * - each field writes when its `<ui-field apply>` says: `immediately`, `delayed` after a pause, or `on leave`\n * - a value that fails validation is never written\n * - `apply=\"on save\"`: edits are held (`:state(changed)`) until `save()`, and `cancel()` drops them\n * - without it, nothing is bound: the form works as it always has\n * - `debug`: below the content, a captioned box whose `<pre part=\"debug\">` shows, redrawn as they change:\n * - the bound `value` as JSON (its `toJSON()` counts)\n * - else `values`\n * - Why the box and caption: bare JSON under a form reads as page text, and gets missed.\n *\n * - Static server render (`spell/ui/static`): a `<form>` slotted inside it MERGES into the root,\n * which becomes `<form class=\"ui … form\">` with the author's attributes (`mergedForm`).\n * - That's Fomantic's own markup, so the form's rules reach its fields and messages,\n * and the page still submits natively.\n * - A form around it stays as it is.\n ****************/\nexport class UIForm extends E.UIComponent<typeof formVocabulary> {\n @E.proto static vocabulary = formVocabulary\n // `Partial`: the property (`UIProperty`) and the editor (`UIPropertyEditor`) extend it\n @E.protoMerged static elementSetup: Partial<E.ElementSetup> = {\n styleSheets: { form: formCSS },\n DOMElement: DOMFormElement,\n delegatesFocus: false,\n // `disabled`: unusable, the default; the root also says `inert` itself, for the static render\n // `loading`: Fomantic's veil, its content inert\n loading: \"its own\"\n } satisfies Partial<E.ElementSetup>\n\n /** Controls, values, labels, errors. */\n readonly fields = new FormFields({ domElement: this.domElement, form: () => this.nativeForm })\n\n /** The controls bound to `value`. */\n private readonly binding = new FormBinding({\n domElement: this.domElement,\n fields: this.fields,\n form: {\n isHolding: () => this.apply === ON_SAVE,\n canWrite: (control) => this.passes(control),\n onHeldChange: () => {\n this.hasHeldChanges = this.binding.hasHeld\n this.onHeldChanged()\n },\n writesItself: (target, name, value) => this.writesItself(target, name, value),\n onWrite: (write) => this.onWritten(write)\n }\n })\n\n /** Fields showing an error now. */\n private readonly fieldsShowingErrors = new Set<string>()\n\n /** Values at connect / reset / success, for `prevent-leaving`. */\n private savedValues = \"\"\n\n /** Validation deferred to after the controls settle, by field. */\n private readonly fieldsAwaitingCheck = new Set<string>()\n\n /**\n * Server render only: attributes of the author's `<form>` merged into the root, `undefined` when there's none.\n * - SIDE EFFECT: unwraps that form in the DOM element's light DOM, so its children fill the root's slot.\n */\n private readonly mergedForm = isServer ? UIForm.unwrapForm(this.domElement) : undefined\n\n ////////////////\n // ## State and classes\n ////////////////\n\n /** The last submit / `validate()` failed: `error` shows. */\n @E.state accessor lastCheckFailed = false\n\n /** `error` after a failed submit, else the attribute. */\n private get shownState(): UIT.FormState | undefined {\n return this.lastCheckFailed ? ERROR : this.state\n }\n\n /** `:state(error)`, `:state(info)` ...: the state shown. */\n protected cssStates() {\n return FormStateFlags.of(this.shownState)\n }\n\n /** `:state(fluid)`: in a `<ui-stack>`'s row, it takes the room left (`UIStack.css`; epic `language` P35). */\n @E.cssState(\"fluid\")\n get isFluid(): boolean {\n return !!this.fluid\n }\n\n /** `:state(changed)`: `apply=\"on save\"` holds edits, not saved yet. */\n @E.cssState(\"changed\")\n @E.state\n accessor hasHeldChanges = false\n\n /** Always `:state(root)`. */\n @E.cssState(\"root\")\n get isRoot(): boolean {\n return true\n }\n\n protected classValue(name: E.AttributeName<typeof formVocabulary>): unknown {\n if (name === \"state\") return this.shownState\n return super.classValue(name)\n }\n\n /** `stack-with`'s class (`UIT.StackClasses`): sets the switch its rows stack by. */\n protected get extraClass(): string | undefined {\n return UIT.StackClasses.classFor(this.stackWith)\n }\n\n ////////////////\n // ## Rendering\n ////////////////\n\n render(): JSX.Element {\n if (this.mergedForm) return this.formRoot(this.mergedForm)\n return (\n <div\n class={this.rootClass}\n part={this.partForName(\"form\")}\n inert={this.disabled || this.loading}\n aria-busy={this.loading ? \"true\" : undefined}\n >\n <slot />\n {this.debugBox()}\n </div>\n )\n }\n\n /** `debug`'s box: the bound object (or `values`) as JSON, below the content; a subclass draws it too. */\n protected debugBox(): JSX.Element {\n return (\n <Show when={this.debug}>\n <figure class=\"debug\">\n <figcaption>{this.debugCaption}</figcaption>\n <pre part={this.partForName(\"debug\")}>{this.debugText}</pre>\n </figure>\n </Show>\n )\n }\n\n /** Server render: the root as the author's `<form>`, its attributes kept, its class after ours. */\n private formRoot(attributes: Record<string, string>): JSX.Element {\n const { class: authorClass, ...rest } = attributes\n return (\n <form\n {...rest}\n class={[this.rootClass, authorClass]}\n part={this.partForName(\"form\")}\n inert={this.disabled || this.loading}\n aria-busy={this.loading ? \"true\" : undefined}\n >\n <slot />\n </form>\n )\n }\n\n ////////////////\n // ## The native form\n ////////////////\n\n /** The native form it works with (`findForm()`). */\n @E.state accessor nativeForm: HTMLFormElement | undefined = undefined\n\n /** The DOM element holds `value` as the scope its controls bind to (`FormBinding.hold()`). */\n onMount() {\n FormBinding.hold(this.domElement, () => this.value)\n return super.onMount()\n }\n\n /**\n * While connected: find the native form (and again as the subtree changes),\n * and listen for the page leaving; returns their undo.\n * - Its own `MutationObserver`, not `@watches`: it watches only while connected.\n */\n @E.whileConnected\n protected watchForm() {\n // oxlint-disable-next-line spell-ui/no-mutation-observer -- only while connected: `@E.watches` lasts the element's whole life\n const observer = new MutationObserver(() => this.onContentChanged())\n observer.observe(this.domElement, { childList: true, subtree: true })\n this.findForm()\n window.addEventListener(\"beforeunload\", this.onBeforeUnload)\n E.afterSolidUpdate(() => this.saveValues())\n return () => {\n this.nativeForm = undefined\n observer.disconnect()\n window.removeEventListener(\"beforeunload\", this.onBeforeUnload)\n }\n }\n\n /** A `ui-*` element inside became a form value once drawn (a segmented `<ui-menu name>`): bind it. */\n @E.on(\"ui-form-value\")\n protected onFormValueReady() {\n this.onContentChanged()\n }\n\n /** Controls came or went: find the native form again, bind what's new, redraw `debug`. */\n @E.untracked\n private onContentChanged() {\n this.findForm()\n if (this.isBound) this.binding.update()\n this.changeCount++\n }\n\n /** The native form: one inside, else the one around. */\n @E.untracked\n private findForm() {\n const form = this.domElement.querySelector(\"form\") ?? this.domElement.parentElement?.closest(\"form\") ?? undefined\n if (form !== this.nativeForm) this.nativeForm = form\n }\n\n /** A native form to work with: `noValidate` on, its submit and reset listened to; all undone when it goes. */\n @E.onChange(\"nativeForm\")\n protected onNativeFormChanged(form: HTMLFormElement | undefined) {\n if (!form) return undefined\n const noValidate = form.noValidate\n form.noValidate = true\n form.addEventListener(\"submit\", this.onSubmit, { capture: true })\n form.addEventListener(\"reset\", this.onReset)\n return () => {\n form.noValidate = noValidate\n form.removeEventListener(\"submit\", this.onSubmit, { capture: true })\n form.removeEventListener(\"reset\", this.onReset)\n }\n }\n\n ////////////////\n // ## The bound object (`value`) and `debug`\n ////////////////\n\n /** Bound: `value` is an object to show and edit. */\n get isBound(): boolean {\n return FormBinding.isObject(this.value)\n }\n\n /** Bind the controls while bound and connected; let go of them when either ends. */\n @E.onChange(\"isBound\", \"isConnected\")\n protected onBindingChanged(isBound: boolean, connected: boolean) {\n if (!isBound || !connected || isServer) return undefined\n this.binding.update()\n return () => this.binding.stop()\n }\n\n /** Bumped a microtask after every change, and as controls come and go: `debug` redraws. */\n @E.state private accessor changeCount = 0\n\n /** `debug`'s caption: what the JSON is, the bound object or the form's `values`. */\n private get debugCaption(): string {\n return this.translationForKey(this.isBound ? \"formDebugBound\" : \"formDebugValues\")\n }\n\n /**\n * What `debug` shows: the bound `value` as JSON (an object's own `toJSON()` counts), else `values`.\n * - Tracked: the JSON reads every property it shows, so a reactive object redraws it as it changes.\n * - `changeCount` covers the rest (a plain object, `values` read from the DOM).\n */\n private get debugText(): string {\n const { value } = this\n const shown = this.changeCount >= 0 && FormBinding.isObject(value) ? value : this.values\n try {\n return JSON.stringify(shown, null, 2)\n } catch (error) {\n return String(error)\n }\n }\n\n ////////////////\n // ## Script API (the DOM element's: `DOMFormElement`)\n ////////////////\n\n /** Validate every field, show the results; true when all pass. */\n validateFields(): boolean {\n return !Object.keys(this.validateAll()).length\n }\n\n /** Validate and show every field, set the failed state; errors by field. */\n private validateAll(): Record<string, string[]> {\n const errors = this.check(\"show\")\n this.lastCheckFailed = !!Object.keys(errors).length\n return errors\n }\n\n /** Would every field pass? Shows nothing. */\n isValid(): boolean {\n return !Object.keys(this.check(\"silently\")).length\n }\n\n /** The native reset, then prompts and states cleared. */\n @E.untracked\n reset() {\n const form = this.nativeForm\n if (form) form.reset()\n else {\n for (const control of this.fields.controls()) UIForm.resetControl(control)\n E.afterSolidUpdate(() => this.binding.writeAll())\n }\n this.clearErrors()\n }\n\n /** Every control emptied, prompts and states cleared; a bound object takes the empty values. */\n clear() {\n for (const control of this.fields.controls()) UIForm.clearControl(control)\n this.clearErrors()\n E.afterSolidUpdate(() => this.binding.writeAll())\n }\n\n /** Every field's value, by name; read from the DOM, untracked. */\n get values(): UIT.FormValues {\n return this.fields.values()\n }\n\n /** Validate, then land the held edits (`DOMFormElement.save()`). */\n @E.untracked\n save(): boolean {\n this.binding.flushWaiting()\n if (!this.validateFields()) return false\n const detail: UIT.FormSaveDetail = { changes: this.binding.changes, value: this.value }\n if (!this.send(\"ui-applying\", detail)) return false\n this.binding.saveHeld()\n this.send(\"ui-applied\", detail)\n this.onSucceeded()\n E.afterSolidUpdate(() => this.saveValues())\n return true\n }\n\n /** Drop the held edits (`DOMFormElement.cancel()`). */\n @E.untracked\n cancel(): boolean {\n const detail: UIT.FormCancelDetail = { changes: this.binding.changes }\n if (!this.send(\"ui-cancelling\", detail)) return false\n this.binding.dropHeld()\n this.clearErrors()\n this.send(\"ui-cancelled\", detail)\n return true\n }\n\n ////////////////\n // ## Validating\n ////////////////\n\n /**\n * Validate every field; errors by field.\n * - `\"show\"`: prompts, `aria-invalid` and per-field events too.\n * The caller focuses the first invalid field.\n * - `\"silently\"`: the verdict alone.\n */\n private check(mode: CheckMode): Record<string, string[]> {\n const fields = this.fields.fields()\n const values = this.fields.values(fields)\n const labels = this.fields.labels(fields)\n const rules = this.rulesFor(fields)\n const errors: Record<string, string[]> = {}\n for (const field of fields) {\n const messages = this.fields.errors({ field, rules, values, labels })\n if (messages.length) errors[field.identifier] = messages\n if (mode === \"show\") this.show({ field, messages, values })\n }\n return errors\n }\n\n /** Validate ONE field now and show it. */\n private checkField(identifier: string) {\n const fields = this.fields.fields()\n const field = fields.find((candidate) => candidate.identifier === identifier)\n if (!field) return\n const values = this.fields.values(fields)\n const labels = this.fields.labels(fields)\n const messages = this.fields.errors({ field, rules: this.rulesFor([field]), values, labels })\n this.show({ field, messages, values })\n if (!this.fieldsShowingErrors.size && this.lastCheckFailed) this.lastCheckFailed = false\n }\n\n /** Would `control`'s field pass now? Shows nothing: the binding writes only a value that passes. */\n @E.untracked\n private passes(control: Element): boolean {\n const field = this.fields.fields().find((candidate) => candidate.controls.includes(control))\n if (!field) return true\n const fields = this.fields.fields()\n const values = this.fields.values(fields)\n const labels = this.fields.labels(fields)\n return !this.fields.errors({ field, rules: this.rulesFor([field]), values, labels }).length\n }\n\n /**\n * The rules for `fields`: the form's `rules`, plus each field's `<ui-field rules>` (after the form's own for it).\n * - A field's rules are its first control's `<ui-field>`'s.\n */\n private rulesFor(fields: readonly Field[]): UIT.FormRules | undefined {\n const formRules = this.formRules\n let rules: UIT.FormRules | undefined = formRules\n for (const { identifier, controls } of fields) {\n const field = UIForm.fieldElementFor(controls)\n const own = [field?.rules, field?.schemaRules].flatMap((rules) =>\n rules ? (Array.isArray(rules) ? rules : [rules]) : []\n )\n if (!own.length) continue\n const ownList = own as E.ValidationRule[]\n const theirs = formRules?.[identifier]\n rules = { ...rules, [identifier]: UIForm.joinRules(theirs, ownList) }\n }\n return rules\n }\n\n /**\n * A form's rules for a field, then a field's own after them.\n * - STATIC: pure.\n */\n private static joinRules(theirs: UIT.FormFieldRules | undefined, own: E.ValidationRule[]): UIT.FormFieldRules {\n if (theirs === undefined) return own\n if (typeof theirs === \"object\" && !Array.isArray(theirs) && \"rules\" in theirs) {\n return { ...theirs, rules: [...theirs.rules, ...own] }\n }\n return [...(Array.isArray(theirs) ? theirs : [theirs as E.ValidationRule]), ...own]\n }\n\n /** Show `messages` for a field (or clear it), and dispatch `ui-valid` / `ui-invalid`. */\n private show({ field: { identifier, controls }, messages, values }: ShownField) {\n UIForm.fieldElementFor(controls)?.showErrors?.(messages)\n for (const control of controls) {\n if (messages.length) control.setAttribute(\"aria-invalid\", \"true\")\n else if (control.getAttribute(\"aria-invalid\") === \"true\") control.removeAttribute(\"aria-invalid\")\n }\n if (messages.length) this.fieldsShowingErrors.add(identifier)\n else this.fieldsShowingErrors.delete(identifier)\n this.onFieldChecked({ identifier, controls }, messages)\n const value = values[identifier]\n if (messages.length) {\n const detail: UIT.FormInvalidDetail = { field: identifier, value, errors: messages, values }\n this.send(\"ui-invalid\", detail)\n } else {\n const detail: UIT.FormValidDetail = { field: identifier, value, values }\n this.send(\"ui-valid\", detail)\n }\n }\n\n /** A field was validated and shown: for a subclass (the property editor tells the field's group); nothing here. */\n protected onFieldChecked(_field: Field, _messages: readonly string[]) {}\n\n /** Held edits came or went (`hasHeldChanges`): for a subclass; nothing here. */\n protected onHeldChanged() {}\n\n /** The controls whose edits are held (`apply=\"on save\"`). */\n protected get heldControls(): readonly Element[] {\n return this.binding.heldControls\n }\n\n /** A submit or a save passed validation: for a subclass (the property editor tells its groups); nothing here. */\n protected onSucceeded() {}\n\n /**\n * Write `value` to `target` itself, in place of the plain set: for a subclass (the property editor's `writer`).\n * - `true` when it did; here, never.\n */\n protected writesItself(_target: object, _name: string, _value: unknown): boolean {\n return false\n }\n\n /** A control's value was written to its things: for a subclass (`ui-changed`, \"on change\" rules); nothing here. */\n protected onWritten(_write: { control: Element; name: string; value: unknown; things: readonly object[] }) {}\n\n /** Forget every prompt, `aria-invalid` and the failed state. */\n private clearErrors() {\n for (const identifier of this.fieldsShowingErrors) {\n const field = this.fields.field(identifier)\n if (!field) continue\n UIForm.fieldElementFor(field.controls)?.showErrors?.([])\n for (const control of field.controls) control.removeAttribute(\"aria-invalid\")\n }\n this.fieldsShowingErrors.clear()\n this.lastCheckFailed = false\n E.afterSolidUpdate(() => this.saveValues())\n }\n\n /** The `rules` property, as an object; fresh, so a `validate()` right after `el.rules = …` sees the new rules. */\n private get formRules(): UIT.FormRules | undefined {\n const { rules } = this\n return rules && typeof rules === \"object\" && !Array.isArray(rules) ? (rules as UIT.FormRules) : undefined\n }\n\n /** Validate `identifier` once the controls have settled (their value and validity land on a microtask). */\n private checkFieldSoon(identifier: string) {\n if (this.fieldsAwaitingCheck.has(identifier)) return\n this.fieldsAwaitingCheck.add(identifier)\n E.soon(() => {\n this.fieldsAwaitingCheck.delete(identifier)\n this.checkField(identifier)\n })\n }\n\n /** Remember the values now. */\n private saveValues() {\n this.savedValues = JSON.stringify(this.values)\n }\n\n ////////////////\n // ## Handlers\n ////////////////\n\n /** Submit: validate everything first, see the class doc. */\n @E.untracked\n private readonly onSubmit = (event: Event) => {\n this.binding.flushWaiting()\n const errors = this.validateAll()\n if (Object.keys(errors).length) {\n event.preventDefault()\n event.stopImmediatePropagation()\n const detail: UIT.FormFailureDetail = { values: this.values, errors, originalEvent: event }\n this.send(\"ui-save-failed\", detail)\n if (this.errorFocus) this.focusFirst(Object.keys(errors))\n return\n }\n const detail: UIT.FormSuccessDetail = { values: this.values, originalEvent: event }\n if (!this.send(\"ui-saving\", detail)) event.preventDefault()\n else {\n this.saveValues()\n this.onSucceeded()\n }\n }\n\n /** Native reset: prompts go once the controls have reset, and a bound object takes their values. */\n private readonly onReset = () => {\n E.afterSolidUpdate(() => {\n this.clearErrors()\n this.binding.writeAll()\n })\n }\n\n /**\n * A control changed (a light-DOM control's native `change` / `input`, an element's `ui-changed`):\n * - write it back to `value` and redraw `debug`, both a microtask later\n * - validate it for `validate=\"immediately\"`, or while it shows an error\n */\n @E.on(\"change\")\n @E.on(\"input\")\n @E.on(\"ui-changed\")\n protected onControlChanged(event: Event) {\n this.binding.onChange(event)\n E.afterSolidUpdate(() => this.changeCount++)\n const identifier = this.identifierFor(event)\n if (!identifier) return\n if (this.fieldsShowingErrors.has(identifier) || this.validate === IMMEDIATELY) this.checkFieldSoon(identifier)\n }\n\n /**\n * A control lost focus:\n * - write it back if its field writes `on leave`\n * - validate it for `validate=\"on leave\"`\n */\n @E.on(\"focusout\")\n protected onFocusOut(event: FocusEvent) {\n this.binding.onLeave(event)\n if (this.validate !== ON_LEAVE) return\n const identifier = this.identifierFor(event)\n if (identifier) this.checkFieldSoon(identifier)\n }\n\n /** `prevent-leaving`: ask while the values changed. */\n @E.untracked\n private readonly onBeforeUnload = (event: BeforeUnloadEvent) => {\n if (!this.preventLeaving) return\n if (JSON.stringify(this.values) === this.savedValues) return\n event.preventDefault()\n }\n\n /**\n * Field identifier of the control an event came from: the first control at or above its `target`.\n * - `target` is already retargeted to the form's tree: typing into a `<ui-input>` gives the `<ui-input>`.\n */\n private identifierFor(event: Event): string | undefined {\n const fields = this.fields.fields()\n for (let node = event.target as Element | null; node && node !== this.domElement; node = node.parentElement) {\n const field = fields.find((candidate) => candidate.controls.includes(node!))\n if (field) return field.identifier\n }\n return undefined\n }\n\n /** Focus the first control of the first of `identifiers`, in document order. */\n private focusFirst(identifiers: readonly string[]) {\n const field = this.fields.fields().find((candidate) => identifiers.includes(candidate.identifier))\n ;(field?.controls[0] as HTMLElement | undefined)?.focus()\n }\n\n /**\n * Server render: unwrap the author's `<form>`, when it is the DOM element's only element child\n * (its children take its place).\n * - Returns its attributes, else `undefined`.\n * - STATIC: it runs from a field initializer, before the instance is ready, and needs only the DOM element.\n */\n private static unwrapForm(domElement: Element): Record<string, string> | undefined {\n const [form, ...others] = domElement.children\n if (!form || others.length || form.localName !== \"form\") return undefined\n const attributes = Object.fromEntries([...form.attributes].map(({ name, value }) => [name, value]))\n form.replaceWith(...form.childNodes)\n return attributes\n }\n\n /**\n * The `<ui-field>` of a field's first control, if any: where its prompt shows.\n * - STATIC: pure, reads only the controls.\n */\n private static fieldElementFor(\n controls: readonly Element[]\n ): (DOMFieldElement & { rules?: unknown; schemaRules?: unknown }) | undefined {\n return (controls[0]?.closest(FIELD_SELECTOR) as DOMFieldElement | null) ?? undefined\n }\n\n /**\n * Put a control back to its starting value (no native form to reset it).\n * - STATIC: works on the control alone, no instance state.\n */\n private static resetControl(control: Element) {\n if (control instanceof HTMLInputElement) {\n if (control.type === \"checkbox\" || control.type === \"radio\") control.checked = control.defaultChecked\n else control.value = control.defaultValue\n } else if (control instanceof HTMLTextAreaElement) control.value = control.defaultValue\n else if (control instanceof HTMLSelectElement) {\n for (const option of control.options) option.selected = option.defaultSelected\n } else (control as { component?: { formReset?(): void } }).component?.formReset?.()\n }\n\n /**\n * Empty a control.\n * - STATIC: works on the control alone, no instance state.\n */\n private static clearControl(control: Element) {\n if (control instanceof HTMLInputElement) {\n if (control.type === \"checkbox\" || control.type === \"radio\") control.checked = false\n else control.value = \"\"\n } else if (control instanceof HTMLTextAreaElement) control.value = \"\"\n else if (control instanceof HTMLSelectElement) control.selectedIndex = -1\n else if ((control as { checkable?: string }).checkable)\n (control as unknown as { selected: boolean }).selected = false\n else {\n const element = control as unknown as { value: unknown }\n element.value = Array.isArray(element.value) ? [] : \"\"\n }\n }\n}\n\n/** The vocabulary's attribute getters, typed (see \"Attributes\" in `UIComponent`). */\nexport interface UIForm extends E.AttributeValues<typeof formVocabulary> {}\n\n/** `apply` / `validate` words the form acts on. */\nconst ON_SAVE = \"on save\"\nconst ON_LEAVE = \"on leave\"\nconst IMMEDIATELY = \"immediately\"\n\n/** How `UIForm.check()` reports: `\"show\"` prompts, states and events, or `\"silently\"` the verdict alone. */\ntype CheckMode = \"show\" | \"silently\"\n\n/** What `UIForm.show()` shows: one field's prompts. */\ntype ShownField = {\n /** The field checked. */\n field: Field\n /** Its prompts; `[]` clears it. */\n messages: string[]\n /** Every field's value, for the events' `detail`. */\n values: UIT.FormValues\n}\n","/**\n * The English vocabulary of `<ui-repeat>`: every name the tag uses.\n * - Its tag, its one attribute and its slot. The shape is `E.ComponentVocabulary` (`spell/ui/vocabulary`).\n * - Pure data: node imports it (`yarn site:data`, `yarn gen:root`), so `spell/ui/core` for types only.\n * - The family's grammar notes are in `UIForm.en.ts`.\n */\n\nimport type { E } from \"spell/ui/core\"\n\n/****************\n * ### `repeatVocabulary`\n * The names of `<ui-repeat>`, its children once per item of a list in a bound `<ui-form>`:\n * `<slot></slot>`, its rows in the light DOM.\n ****************/\nexport const repeatVocabulary = {\n tag: \"ui-repeat\",\n icon: \"redo\",\n topics: [\"forms\", \"lists\", \"collections\"],\n aka: [\"repeater\", \"field array\", \"form list\", \"for each\", \"list editor\"],\n noun: \"repeat\",\n ui: false,\n description: \"A repeat shows its fields once per item of a list, each row bound to its own item.\",\n attributes: [\n {\n name: \"items\",\n group: \"content\",\n kind: \"json\",\n reflect: false,\n description:\n \"The list to repeat over, given as a property: any iterable (an array, a `Set`, spell's `List`), followed \" +\n \"as it changes. Set, it wins over `name`.\"\n },\n {\n name: \"name\",\n group: \"name\",\n kind: \"string\",\n description:\n \"The list to repeat over, by name: this property of the scope -- the `<ui-form>`'s `value`, or the item of \" +\n \"the `<ui-repeat>` row around it. Any iterable (an array, a `Set` ...).\"\n }\n ],\n events: [],\n slots: [\n {\n name: \"\",\n description:\n \"The TEMPLATE: markup copied once per item (its controls' `name`s bind to the item); a `<template>`, or \" +\n \"plain children, taken into one as it connects.\"\n }\n ],\n parts: [],\n states: [],\n texts: []\n} as const satisfies E.ComponentVocabulary\n","import type { JSX } from \"@solidjs/web\"\n\nimport { E } from \"spell/ui/core\"\nimport { repeatVocabulary } from \"./UIRepeat.en\"\nimport { FormBinding } from \"./FormBinding\"\n\nimport formCSS from \"./UIForm.css?inline\"\n\n/****************\n * ### `UIRepeat`\n * The component behind `<ui-repeat items>` / `<ui-repeat name>`: its children once per item of a list,\n * e.g. a row of fields per task in a `<ui-form value>` bound to a to-do list.\n *\n * - The list: its `items` property, when set (`<ui-repeat items={the shown tasks of the app}>` in spell);\n * else `scope[name]`, where the scope is the item of the `<ui-repeat>` row around it,\n * else the `<ui-form>`'s `value` (`FormBinding.scopeAround()`).\n * - any iterable: an array, a `Set`, an object with `[Symbol.iterator]` (spell's `List`)\n * - read inside a Solid computation, so the rows follow the list as it changes:\n * signals, Spell UI's reactive members, spell's objects\n * - none, or empty: no rows\n * - Its children are the TEMPLATE: a `<template>`, or plain markup, taken into one as it connects\n * (and children added later, which remake the rows).\n * - the template stays as its LAST child: invisible, and so no row is ever `:last-child`\n * - attribute-only markup: each row is a fresh copy, so what a framework changes in the template later\n * doesn't reach the rows (bind it through `name` instead)\n * - Rows: a copy of the template per item, in the LIGHT DOM, so the form (and the native form) sees their controls.\n * - each row's top-level elements hold its item as their scope (`FormBinding.hold()`): the form binds the row's\n * controls to it, and a `<ui-repeat>` inside reads its list from it\n * - kept by IDENTITY: an item added, removed or moved adds, removes or moves only its row's nodes\n * (with `moveBefore()` where the browser has it, so a moved row keeps focus)\n * - NO wrapper element per row: the form's rows of fields drop their bottom margin by `:last-child`,\n * which a wrapper would make true of every row\n * - ids in the template repeat in every row: label controls by `aria-label`, or by wrapping them\n * - The DOM element is `display: contents`: rows sit in the layout as if written in its place.\n ****************/\nexport class UIRepeat extends E.UIComponent<typeof repeatVocabulary> {\n @E.proto static vocabulary = repeatVocabulary\n @E.protoMerged static elementSetup = {\n styleSheets: { form: formCSS },\n delegatesFocus: false\n } satisfies Partial<E.ElementSetup>\n\n render(): JSX.Element {\n return <slot />\n }\n\n ////////////////\n // ## The template\n ////////////////\n\n /** What every row copies: kept as the last child, once taken. */\n private template: HTMLTemplateElement | undefined\n\n /** Bumped each time the template is taken: the rows are made afresh from it. */\n @E.state private accessor templateVersion = 0\n\n /**\n * While connected: take the template, and again as children are added later; returns the watch's undo.\n * - Its own `MutationObserver`, not `@watches`: it watches only while connected.\n */\n @E.whileConnected\n protected watchTemplate() {\n this.takeTemplate()\n // oxlint-disable-next-line spell-ui/no-mutation-observer -- only while connected: `@E.watches` lasts the element's whole life\n const observer = new MutationObserver(() => this.takeTemplate())\n observer.observe(this.domElement, { childList: true })\n return () => observer.disconnect()\n }\n\n /**\n * Copy every child that isn't a row into the template, then remove it; when any was, the rows are made again.\n * - Copied into the template's own (inert) document, never moved: a `ui-*` element there stays plain markup,\n * while one moved there would still finish drawing into a document that isn't the page's.\n * - The removed originals are left to finish drawing (and resolve `ready`, which a page may wait for),\n * then to be collected: nothing refers to them.\n */\n private takeTemplate() {\n const { domElement } = this\n const authored = [...domElement.childNodes].filter((node) => node !== this.template && !this.rowOf.has(node))\n if (this.template && !authored.length) return\n const template = (this.template ??= document.createElement(\"template\"))\n const { content } = template\n for (const node of authored) {\n // a `<template>` gives its content; one made by script may hold its children directly\n const copied = node instanceof HTMLTemplateElement ? [node.content, ...node.childNodes] : [node]\n for (const part of copied) content.append(content.ownerDocument.importNode(part, true))\n node.remove()\n }\n for (const row of this.rows) for (const node of row.nodes) node.remove()\n this.rows = []\n domElement.append(template)\n this.templateVersion++\n }\n\n ////////////////\n // ## Rows\n ////////////////\n\n /**\n * The items shown: `items`, else `scope[name]`, as a list; `[]` while it's none, or before the template is taken.\n * - Tracked: read inside the effect, it follows changes to the property, the scope and the list\n * (and iterating it follows the list's items).\n */\n get shownItems(): readonly unknown[] {\n if (!this.isConnected || !this.templateVersion) return []\n const list = this.items ?? this.listByName()\n return UIRepeat.isIterable(list) ? [...list] : []\n }\n\n /** `scope[name]`: the list `name` names, in the scope around the repeat. */\n private listByName(): unknown {\n if (!this.name) return undefined\n const scope = FormBinding.scopeAround(this.domElement)\n return FormBinding.isObject(scope) ? scope[this.name] : undefined\n }\n\n /** Rows shown, in list order. */\n private rows: Row[] = []\n\n /** The row each row node belongs to. */\n private readonly rowOf = new WeakMap<Node, Row>()\n\n /** The list changed: show a row per item, keeping each item's row. */\n @E.onChange(\"shownItems\")\n protected onItemsChanged(items: readonly unknown[]) {\n const { template } = this\n if (!template) return\n const unused = new Map<unknown, Row[]>()\n for (const row of this.rows) {\n const same = unused.get(row.item)\n if (same) same.push(row)\n else unused.set(row.item, [row])\n }\n const rows = items.map((item) => unused.get(item)?.shift() ?? this.newRow(item, template))\n for (const left of unused.values()) for (const row of left) for (const node of row.nodes) node.remove()\n this.rows = rows\n this.place([...rows.flatMap((row) => row.nodes), template])\n }\n\n /** A copy of the template for `item`: its top-level elements hold `item` as their scope. */\n private newRow(item: unknown, template: HTMLTemplateElement): Row {\n const copy = document.importNode(template.content, true)\n const row: Row = { item, nodes: [...copy.childNodes] }\n for (const node of row.nodes) {\n this.rowOf.set(node, row)\n if (node.nodeType === Node.ELEMENT_NODE) FormBinding.hold(node as Element, () => item)\n }\n return row\n }\n\n /** Put `nodes` in this order as the children, moving only what's out of place. */\n private place(nodes: readonly ChildNode[]) {\n const { domElement } = this\n let next = domElement.firstChild\n for (const node of nodes) {\n if (node === next) next = node.nextSibling\n else UIRepeat.move(domElement, node, next)\n }\n }\n\n ////////////////\n // ## Pure helpers\n // STATIC, every one: it reads only its arguments, so it needs no instance.\n ////////////////\n\n /** Something to repeat over: iterable, but not a string. */\n private static isIterable(value: unknown): value is Iterable<unknown> {\n return FormBinding.isObject(value) && typeof value[Symbol.iterator] === \"function\"\n }\n\n /**\n * `node` into `parent`, before `before`: `moveBefore()` when both are on the page and the browser has it,\n * so a moved row keeps its focus and state; else `insertBefore()`.\n */\n private static move(parent: Element, node: ChildNode, before: ChildNode | null) {\n const { moveBefore } = parent as Element & Partial<MovingParent>\n if (moveBefore && node.isConnected && parent.isConnected) moveBefore.call(parent, node, before)\n else parent.insertBefore(node, before)\n }\n}\n\n/** The vocabulary getters, typed (`UIComponent`'s doc). */\nexport interface UIRepeat extends E.AttributeValues<typeof repeatVocabulary> {}\n\n/** One row: the nodes copied from the template for one item. */\ntype Row = {\n /** Its item, which its controls bind to. */\n item: unknown\n /** Its top-level nodes, in order. */\n nodes: ChildNode[]\n}\n\n/** `Element.moveBefore()`, which not every browser (or TypeScript's DOM types) has yet. */\ntype MovingParent = {\n /** Move `node` before `child` (`null`: to the end), keeping its state. */\n moveBefore(node: Node, child: Node | null): void\n}\n","/**\n * The form family: defines `<ui-field>`, `<ui-fields>`, `<ui-form>` and `<ui-repeat>`.\n * - It exports their components (`UIField`, `UIFields`, `UIForm`, `UIRepeat`)\n * and DOM element classes (`DOMFieldElement`, `DOMFormElement`).\n * - SIDE EFFECT: importing it defines the tags.\n * - `<ui-repeat>` after `<ui-form>`: a repeat reads its list from the form around it, which then exists already.\n * - Also the library's `spell/ui/ui-form` entry (its size is in `notes/report.md`).\n * - NOTE: the controls are their own families (`input`, `checkbox`, `dropdown`):\n * a form validates (and binds) whatever form-associated elements and native controls it holds,\n * without importing them.\n */\n\nimport { FormBinding } from \"./FormBinding\"\nimport { FormFields } from \"./FormFields\"\nimport { DOMFieldElement, UIField } from \"./UIField\"\nimport { UIFields } from \"./UIFields\"\nimport { DOMFormElement, UIForm } from \"./UIForm\"\nimport { UIRepeat } from \"./UIRepeat\"\n\nUIField.define()\nUIFields.define()\nUIForm.define()\nUIRepeat.define()\n\nexport { UIField, UIFields, UIForm, UIRepeat, DOMFieldElement, DOMFormElement, FormBinding, FormFields }\n"],"mappings":";;;;;;AAgBA,IAAaqK,KAAe;CAC1B;EAAE,MAAM;EAAS,aAAa;CAAwD;CACtF;EAAE,MAAM;EAAQ,aAAa;CAAqB;CAClD;EAAE,MAAM;EAAW,aAAa;CAAwB;CACxD;EAAE,MAAM;EAAW,aAAa;CAAwB;AAC1D,GAMaC,KAAqB;CAAC;CAAe;CAAY;AAAS,GAK1DC,KAAiB,CAAC,eAAe,SAAS,GAoB1CC,KAAQ,SAGR,iBAAb,MAA4B;CAM1B,OAAO,GAAG,GAAkE;EAC1E,OAAO,OAAO,YAAAZ,EAA2B,KAAK,MAAU,CAACa,GAAOA,MAAUC,CAAK,CAAC,CAAC;CACnF;AACF,GA2BaC,IAAiB,UAAU3K,GAAqB,IC5DhD4K,IAAb,MAAa,WAAW;CAKtB;CAGA;CAEA,YAAY,EAAE,eAAY,WAAyB;EAEjD,AADA,KAAK,aAAaC,GAClB,KAAK,OAAOC;CACd;CAOA,WAAsB;EACpB,IAAMA,IAAO,KAAK,KAAK,GACjBC,IAAaD,IACf,CAAC,GAAGA,EAAK,QAAQ,IACjB,CAAC,GAAG,KAAK,WAAW,iBAAiBE,EAAgB,GAAG,GAAG,KAAK,eA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