sygnal 7.0.0 → 7.2.0-preview.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (343) hide show
  1. package/CHANGELOG.md +632 -0
  2. package/dist/agent-ui.cjs.js +592 -0
  3. package/dist/agent-ui.cjs.js.map +1 -0
  4. package/dist/agent-ui.esm.js +582 -0
  5. package/dist/agent-ui.esm.js.map +1 -0
  6. package/dist/api.cjs.js +63 -0
  7. package/dist/api.cjs.js.map +1 -0
  8. package/dist/api.esm.js +2 -0
  9. package/dist/api.esm.js.map +1 -0
  10. package/dist/astro/index.cjs.js +968 -4
  11. package/dist/astro/index.cjs.js.map +1 -1
  12. package/dist/astro/index.mjs +968 -4
  13. package/dist/astro/index.mjs.map +1 -1
  14. package/dist/astro/server.cjs.js +73 -45
  15. package/dist/astro/server.cjs.js.map +1 -1
  16. package/dist/astro/server.mjs +73 -45
  17. package/dist/astro/server.mjs.map +1 -1
  18. package/dist/canvas.cjs.js +2919 -0
  19. package/dist/canvas.cjs.js.map +1 -0
  20. package/dist/canvas.esm.js +2866 -0
  21. package/dist/canvas.esm.js.map +1 -0
  22. package/dist/devtools.cjs.js +38 -6
  23. package/dist/devtools.cjs.js.map +1 -1
  24. package/dist/devtools.esm.js +38 -6
  25. package/dist/devtools.esm.js.map +1 -1
  26. package/dist/diagnostics.cjs.js +224 -20
  27. package/dist/diagnostics.cjs.js.map +1 -1
  28. package/dist/diagnostics.esm.js +224 -20
  29. package/dist/diagnostics.esm.js.map +1 -1
  30. package/dist/guide/accessibility.md +1 -1
  31. package/dist/guide/ai-compose.md +150 -0
  32. package/dist/guide/behaviors.md +2 -1
  33. package/dist/guide/collaborative-state.md +265 -0
  34. package/dist/guide/element-commands.md +36 -2
  35. package/dist/guide/forms-reference.md +5 -5
  36. package/dist/guide/forms.md +3 -2
  37. package/dist/guide/http.md +28 -1
  38. package/dist/guide/islands.md +240 -0
  39. package/dist/guide/recipes/code-editor.md +1 -1
  40. package/dist/guide/renderers/agent-ui.md +138 -0
  41. package/dist/guide/renderers/custom-targets.md +126 -0
  42. package/dist/guide/renderers/overview.md +120 -0
  43. package/dist/guide/renderers/react-native.md +128 -0
  44. package/dist/guide/renderers/terminal.md +306 -0
  45. package/dist/guide/renderers/three.md +332 -0
  46. package/dist/guide/renderers/write-once.md +137 -0
  47. package/dist/guide/resources.md +2 -0
  48. package/dist/guide/sandboxed-components.md +223 -0
  49. package/dist/guide/timers.md +32 -5
  50. package/dist/guide/typed-apis.md +442 -0
  51. package/dist/guide/ui/accordion.md +11 -0
  52. package/dist/guide/ui/combobox.md +112 -8
  53. package/dist/guide/ui/dialog.md +96 -20
  54. package/dist/guide/ui/menu.md +57 -5
  55. package/dist/guide/ui/overview.md +8 -4
  56. package/dist/guide/ui/popover.md +69 -9
  57. package/dist/guide/ui/select.md +54 -4
  58. package/dist/guide/ui/tabs.md +1 -1
  59. package/dist/guide/ui/tooltip.md +7 -5
  60. package/dist/guide/virtual-collections.md +3 -0
  61. package/dist/guide/widgets.md +90 -1
  62. package/dist/host.cjs.js +2181 -0
  63. package/dist/host.cjs.js.map +1 -0
  64. package/dist/host.esm.js +2146 -0
  65. package/dist/host.esm.js.map +1 -0
  66. package/dist/index.cjs.js +3948 -586
  67. package/dist/index.cjs.js.map +1 -1
  68. package/dist/index.d.ts +584 -44
  69. package/dist/index.esm.js +3918 -586
  70. package/dist/index.esm.js.map +1 -1
  71. package/dist/primitives.cjs.js +143 -0
  72. package/dist/primitives.cjs.js.map +1 -0
  73. package/dist/primitives.esm.js +133 -0
  74. package/dist/primitives.esm.js.map +1 -0
  75. package/dist/react-native.cjs.js +248 -0
  76. package/dist/react-native.cjs.js.map +1 -0
  77. package/dist/react-native.esm.js +244 -0
  78. package/dist/react-native.esm.js.map +1 -0
  79. package/dist/replay.cjs.js +39 -0
  80. package/dist/replay.cjs.js.map +1 -0
  81. package/dist/replay.esm.js +2 -0
  82. package/dist/replay.esm.js.map +1 -0
  83. package/dist/sandbox-build.cjs.js +140 -0
  84. package/dist/sandbox-build.cjs.js.map +1 -0
  85. package/dist/sandbox-build.esm.js +137 -0
  86. package/dist/sandbox-build.esm.js.map +1 -0
  87. package/dist/sandbox-kernel.esm.js +212 -0
  88. package/dist/sandbox-kernel.esm.js.map +1 -0
  89. package/dist/sandbox-worker.cjs.js +857 -0
  90. package/dist/sandbox-worker.cjs.js.map +1 -0
  91. package/dist/sandbox-worker.esm.js +854 -0
  92. package/dist/sandbox-worker.esm.js.map +1 -0
  93. package/dist/sandbox.cjs.js +1425 -0
  94. package/dist/sandbox.cjs.js.map +1 -0
  95. package/dist/sandbox.esm.js +1406 -0
  96. package/dist/sandbox.esm.js.map +1 -0
  97. package/dist/sygnal.min.js +1 -1
  98. package/dist/sygnal.min.js.map +1 -1
  99. package/dist/terminal.cjs.js +1314 -0
  100. package/dist/terminal.cjs.js.map +1 -0
  101. package/dist/terminal.esm.js +1304 -0
  102. package/dist/terminal.esm.js.map +1 -0
  103. package/dist/three.cjs.js +1111 -0
  104. package/dist/three.cjs.js.map +1 -0
  105. package/dist/three.esm.js +1079 -0
  106. package/dist/three.esm.js.map +1 -0
  107. package/dist/ui-combobox.cjs.js +256 -18
  108. package/dist/ui-combobox.cjs.js.map +1 -1
  109. package/dist/ui-combobox.esm.js +256 -18
  110. package/dist/ui-combobox.esm.js.map +1 -1
  111. package/dist/ui-menu.cjs.js +150 -16
  112. package/dist/ui-menu.cjs.js.map +1 -1
  113. package/dist/ui-menu.esm.js +151 -17
  114. package/dist/ui-menu.esm.js.map +1 -1
  115. package/dist/ui-select.cjs.js +95 -9
  116. package/dist/ui-select.cjs.js.map +1 -1
  117. package/dist/ui-select.esm.js +95 -9
  118. package/dist/ui-select.esm.js.map +1 -1
  119. package/dist/ui.cjs.js +679 -173
  120. package/dist/ui.cjs.js.map +1 -1
  121. package/dist/ui.esm.js +679 -175
  122. package/dist/ui.esm.js.map +1 -1
  123. package/dist/vike/config/package.json +1 -1
  124. package/dist/vite/plugin.cjs.js +968 -4
  125. package/dist/vite/plugin.cjs.js.map +1 -1
  126. package/dist/vite/plugin.mjs +968 -4
  127. package/dist/vite/plugin.mjs.map +1 -1
  128. package/dist/worker-page.cjs.js +669 -0
  129. package/dist/worker-page.cjs.js.map +1 -0
  130. package/dist/worker-page.esm.js +665 -0
  131. package/dist/worker-page.esm.js.map +1 -0
  132. package/dist/worker.cjs.js +377 -0
  133. package/dist/worker.cjs.js.map +1 -0
  134. package/dist/worker.esm.js +374 -0
  135. package/dist/worker.esm.js.map +1 -0
  136. package/dist/yjs-testing.cjs.js +98 -0
  137. package/dist/yjs-testing.cjs.js.map +1 -0
  138. package/dist/yjs-testing.esm.js +77 -0
  139. package/dist/yjs-testing.esm.js.map +1 -0
  140. package/dist/yjs.cjs.js +923 -0
  141. package/dist/yjs.cjs.js.map +1 -0
  142. package/dist/yjs.esm.js +900 -0
  143. package/dist/yjs.esm.js.map +1 -0
  144. package/dist/zag.cjs.js +11 -1
  145. package/dist/zag.cjs.js.map +1 -1
  146. package/dist/zag.esm.js +11 -1
  147. package/dist/zag.esm.js.map +1 -1
  148. package/llms/ai.md +65 -0
  149. package/llms/collaboration.md +5 -0
  150. package/llms/graphics.md +10 -0
  151. package/llms/renderers.md +7 -0
  152. package/llms/replay.md +5 -0
  153. package/llms/sandbox.md +5 -0
  154. package/llms/typed-apis.md +5 -0
  155. package/llms/ui.md +10 -0
  156. package/llms-full.txt +444 -0
  157. package/llms.txt +37 -35
  158. package/package.json +139 -3
  159. package/src/agent-ui/mcp.ts +152 -0
  160. package/src/agent-ui/snapshot.ts +212 -0
  161. package/src/agent-ui.d.ts +106 -0
  162. package/src/agent-ui.ts +249 -0
  163. package/src/ai.d.ts +95 -2
  164. package/src/api.d.ts +303 -0
  165. package/src/api.ts +9 -0
  166. package/src/canvas/Canvas.ts +585 -0
  167. package/src/canvas/backend.ts +627 -0
  168. package/src/canvas/geometry.ts +187 -0
  169. package/src/canvas/gesture.ts +23 -0
  170. package/src/canvas/image.ts +197 -0
  171. package/src/canvas/kit.ts +130 -0
  172. package/src/canvas/paint.ts +260 -0
  173. package/src/canvas/pointer.ts +25 -0
  174. package/src/canvas/snap.ts +68 -0
  175. package/src/canvas/svg.ts +99 -0
  176. package/src/canvas.d.ts +373 -0
  177. package/src/canvas.ts +46 -0
  178. package/src/core/actions.ts +14 -3
  179. package/src/core/cell.ts +12 -4
  180. package/src/core/debug.ts +8 -3
  181. package/src/core/hooks.ts +16 -2
  182. package/src/core/hosts/collection.ts +1 -1
  183. package/src/core/hosts/switchable.ts +26 -8
  184. package/src/core/instance.ts +98 -45
  185. package/src/core/markers/portal.ts +4 -0
  186. package/src/core/registry.ts +4 -0
  187. package/src/core/runtime.ts +34 -25
  188. package/src/core/statics.ts +5 -5
  189. package/src/cycle/dom/EventDelegator.ts +37 -33
  190. package/src/cycle/dom/MainDOMSource.ts +16 -14
  191. package/src/cycle/dom/enrichEventStream.ts +13 -9
  192. package/src/cycle/dom/fromEvent.ts +6 -10
  193. package/src/cycle/dom/index.ts +11 -7
  194. package/src/cycle/dom/isolate.ts +13 -6
  195. package/src/cycle/dom/makeDOMDriver.ts +6 -2
  196. package/src/cycle/dom/utils.ts +9 -2
  197. package/src/cycle/run/adapt.ts +4 -12
  198. package/src/devtools.d.ts +9 -0
  199. package/src/devtools.ts +2 -1
  200. package/src/extra/ai/compose/catalog.ts +2 -1
  201. package/src/extra/ai/compose/decisions.ts +1 -2
  202. package/src/extra/ai/compose/generated.ts +234 -0
  203. package/src/extra/ai/compose/index.ts +6 -2
  204. package/src/extra/ai/compose/layout.ts +3 -1
  205. package/src/extra/ai/compose/llm.ts +7 -3
  206. package/src/extra/ai/compose/types.ts +2 -2
  207. package/src/extra/ai/transports/shared.ts +3 -1
  208. package/src/extra/api/contract.ts +485 -0
  209. package/src/extra/api/index.ts +26 -0
  210. package/src/extra/behaviors.ts +3 -3
  211. package/src/extra/controlled.ts +44 -0
  212. package/src/extra/copyAsTest.ts +22 -0
  213. package/src/extra/devtools.ts +5 -3
  214. package/src/extra/devtoolsActions.ts +8 -0
  215. package/src/extra/devtoolsNext.ts +1 -1
  216. package/src/extra/diagnostics/checks/actionLog.ts +8 -3
  217. package/src/extra/diagnostics/checks/behaviors.ts +25 -0
  218. package/src/extra/diagnostics/checks/elementCommands.ts +17 -5
  219. package/src/extra/diagnostics/checks/index.ts +1 -1
  220. package/src/extra/diagnostics/checks/next.ts +78 -4
  221. package/src/extra/diagnostics/checks/props.ts +6 -1
  222. package/src/extra/diagnostics/checks/replies.ts +11 -7
  223. package/src/extra/diagnostics/checks/timers.ts +8 -2
  224. package/src/extra/diagnostics/checks/virtual.ts +11 -0
  225. package/src/extra/diagnostics/codes.ts +51 -1
  226. package/src/extra/elementCommands.ts +20 -4
  227. package/src/extra/fetchDriver.ts +4 -1
  228. package/src/extra/fetchEventSource.ts +6 -2
  229. package/src/extra/field.ts +29 -0
  230. package/src/extra/form.ts +42 -16
  231. package/src/extra/frame.ts +54 -0
  232. package/src/extra/keymap.ts +41 -0
  233. package/src/extra/pager.ts +2 -0
  234. package/src/extra/persist.ts +2 -1
  235. package/src/extra/pointer.ts +262 -0
  236. package/src/extra/processForm.ts +34 -1
  237. package/src/extra/replay/address.ts +49 -0
  238. package/src/extra/replay/entropy.ts +99 -0
  239. package/src/extra/replay/format.ts +263 -0
  240. package/src/extra/replay/index.ts +8 -0
  241. package/src/extra/replay/inert.ts +22 -0
  242. package/src/extra/replay/recorder.ts +247 -0
  243. package/src/extra/replay/replayer.ts +234 -0
  244. package/src/extra/replay/report.ts +126 -0
  245. package/src/extra/replay/schema.ts +52 -0
  246. package/src/extra/replay/version.ts +3 -0
  247. package/src/extra/router.ts +7 -3
  248. package/src/extra/selection.ts +2 -0
  249. package/src/extra/socketDriver.ts +51 -6
  250. package/src/extra/ssr.ts +128 -42
  251. package/src/extra/testing.ts +295 -39
  252. package/src/extra/timers.ts +96 -7
  253. package/src/extra/undo.ts +2 -0
  254. package/src/extra/virtual.ts +25 -2
  255. package/src/extra/widget.ts +106 -17
  256. package/src/host/actions.ts +383 -0
  257. package/src/host/delegation.ts +101 -0
  258. package/src/host/dom.ts +553 -0
  259. package/src/host/driver.ts +185 -0
  260. package/src/host/selector.ts +119 -0
  261. package/src/host/style.ts +51 -0
  262. package/src/host.d.ts +298 -0
  263. package/src/host.ts +46 -0
  264. package/src/index.d.ts +302 -38
  265. package/src/index.ts +15 -3
  266. package/src/pragma/blocks.ts +211 -0
  267. package/src/pragma/index.ts +44 -10
  268. package/src/primitives.d.ts +54 -0
  269. package/src/primitives.ts +136 -0
  270. package/src/react-native.d.ts +57 -0
  271. package/src/react-native.ts +285 -0
  272. package/src/react-peers.d.ts +21 -3
  273. package/src/replay.d.ts +185 -0
  274. package/src/replay.ts +6 -0
  275. package/src/sandbox/build.ts +119 -0
  276. package/src/sandbox/create.ts +187 -0
  277. package/src/sandbox/engine.ts +267 -0
  278. package/src/sandbox/generated.ts +195 -0
  279. package/src/sandbox/kernel.ts +180 -0
  280. package/src/sandbox/mirror.ts +269 -0
  281. package/src/sandbox/protocol.ts +128 -0
  282. package/src/sandbox/quickjs.ts +74 -0
  283. package/src/sandbox/ssr.ts +41 -0
  284. package/src/sandbox/widget.ts +60 -0
  285. package/src/sandbox/worker-entry.ts +59 -0
  286. package/src/sandbox/worker.ts +137 -0
  287. package/src/sandbox-build.d.ts +12 -0
  288. package/src/sandbox-build.ts +6 -0
  289. package/src/sandbox.d.ts +299 -0
  290. package/src/sandbox.ts +25 -0
  291. package/src/shared.ts +12 -0
  292. package/src/terminal/paint.ts +712 -0
  293. package/src/terminal.d.ts +167 -0
  294. package/src/terminal.ts +530 -0
  295. package/src/three/assets.ts +170 -0
  296. package/src/three/host.ts +36 -0
  297. package/src/three/scene.ts +217 -0
  298. package/src/three/target.ts +252 -0
  299. package/src/three.d.ts +221 -0
  300. package/src/three.ts +30 -0
  301. package/src/ui/accordion.ts +21 -7
  302. package/src/ui/dialog.ts +192 -90
  303. package/src/ui/disclosure.ts +2 -0
  304. package/src/ui/dom.ts +30 -0
  305. package/src/ui/layers.ts +132 -0
  306. package/src/ui/popover.ts +120 -21
  307. package/src/ui/shared.ts +98 -12
  308. package/src/ui/stack.ts +18 -0
  309. package/src/ui/tabs.ts +2 -0
  310. package/src/ui/toaster.ts +16 -15
  311. package/src/ui/tooltip.ts +24 -8
  312. package/src/ui/tooltips.ts +26 -14
  313. package/src/ui/zag/combobox.ts +180 -13
  314. package/src/ui/zag/menu.ts +97 -17
  315. package/src/ui/zag/select.ts +15 -4
  316. package/src/ui/zag/shared.ts +60 -8
  317. package/src/ui-combobox.d.ts +16 -1
  318. package/src/ui-menu.d.ts +22 -7
  319. package/src/ui-zag-types.d.ts +13 -5
  320. package/src/ui.d.ts +62 -7
  321. package/src/ui.ts +2 -2
  322. package/src/vite/api.ts +186 -0
  323. package/src/vite/compile.ts +280 -0
  324. package/src/vite/plugin.d.ts +34 -0
  325. package/src/vite/plugin.ts +78 -4
  326. package/src/vite/sandbox.ts +16 -0
  327. package/src/worker/page.ts +396 -0
  328. package/src/worker/protocol.ts +48 -0
  329. package/src/worker/target.ts +282 -0
  330. package/src/worker-page.d.ts +42 -0
  331. package/src/worker-page.ts +12 -0
  332. package/src/worker.d.ts +65 -0
  333. package/src/worker.ts +16 -0
  334. package/src/yjs/driver.ts +253 -0
  335. package/src/yjs/mapping.ts +389 -0
  336. package/src/yjs/shared.ts +138 -0
  337. package/src/yjs/testing.ts +91 -0
  338. package/src/yjs-testing.d.ts +34 -0
  339. package/src/yjs-testing.ts +7 -0
  340. package/src/yjs.d.ts +109 -0
  341. package/src/yjs.ts +18 -0
  342. package/src/zag.d.ts +2 -0
  343. package/src/zag.ts +8 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ui-combobox.cjs.js","sources":["../src/ui/zag/shared.ts","../src/ui/zag/combobox.ts"],"sourcesContent":["/*\n * PLAN-5 2-Z: helpers the Zag-based parts (Menu, Select, Combobox) share. '../../zag' becomes the\n * external 'sygnal/zag' and '../../index' the external 'sygnal' in the 'sygnal/ui/menu', 'sygnal/ui/select' and 'sygnal/ui/combobox' builds.\n */\n\n/** G-413: the naming props a part applies to its control (not the host) */\nexport const NAMING = ['aria-label', 'aria-labelledby', 'aria-describedby']\n\n/**\n * A control's (or listbox's) Zag props named from the part's props: without a label element, no\n * aria-labelledby to it; the props' aria-label / aria-labelledby (/ aria-describedby) win\n */\nexport const named = (bag: any, p: any, describe?: any) => {\n const a = bag.attrs\n if (p.label == null) delete a['aria-labelledby']\n for (const k of NAMING) if (p[k] != null && (describe || k != 'aria-describedby')) a[k] = p[k]\n if (p['aria-labelledby'] != null) delete a['aria-label']\n return bag\n}\n\n/** An item as the parts take it: a string, or { value, label?, disabled? } (Menu also { separator: true }) */\nexport const norm = (items: any): any[] =>\n (items || []).map((i: any) => (i && typeof i == 'object'\n ? {...i, value: String(i.value ?? ''), label: i.label ?? String(i.value ?? '')}\n : {value: String(i), label: String(i)}))\n\n/** A Select / Combobox value prop as Zag's string[] (undefined: uncontrolled; null or '': none) */\nexport const arr = (v: any): any =>\n v === undefined ? undefined : v == null || v === '' ? [] : Array.isArray(v) ? v.map(String) : [String(v)]\n\n/** The listbox collection options for Zag's collection() */\nexport const collectionOf = (z: any, items: any[]) =>\n z.collection({items, itemToValue: (i: any) => i.value, itemToString: (i: any) => i.label, isItemDisabled: (i: any) => !!i.disabled})\n\n/** value-change's detail: the value (single) or the values (multiple) */\nexport const valueOut = (d: any, x: any) => (x.multiple ? d.value : d.value[0] ?? null)\n\n/** Item rows of a listbox (Select, Combobox): text + a ✓ indicator Zag hides when unselected */\nexport const options = (h: any, api: any) =>\n api.collection.items.map((item: any) =>\n h('div', {key: item.value, ...api.getItemProps({item})},\n h('span', api.getItemTextProps({item}), item.label),\n h('span', api.getItemIndicatorProps({item}), '✓')))\n","/*\n * PLAN-5 2-Z (U-1): Combobox, a Zag combobox machine (WAI-ARIA editable combobox with a listbox\n * popup) as a widget tag.\n *\n * <Combobox className=\"city\" label=\"City\" items={CITIES} value={state.city} placeholder=\"Type a city\" />\n * intent: CITY: DOM.select('.city').events('value-change').detail() // 'Paris'\n *\n * Renders a label, the input (role=\"combobox\", aria-autocomplete=\"list\", aria-activedescendant\n * on the highlighted option), a trigger button, and the listbox in a positioner. The items are\n * filtered as the user types: by default the labels that contain the text (case-insensitive);\n * `filter={(item, text) => boolean}` replaces the test, `filter={false}` leaves it to the app (it\n * passes the `items` to show, from `input-change`). The filter text resets when the list closes.\n * Keyboard is Zag's: ArrowDown / ArrowUp open and move, Enter selects, Escape closes, Home / End\n * in the input move the caret. Styling hooks: `data-scope=\"combobox\"` + `data-part` (root, label,\n * control, input, trigger, positioner, content, item, item-text, item-indicator), `data-state`,\n * `data-highlighted`.\n *\n * Forms (G-411): with `name`, hidden inputs submit the value (one per value when `multiple`);\n * the visible input, which shows the label, has no name. `form` goes on the hidden inputs (G-434).\n * With `allowCustomValue` (single), the selected value is submitted unless the user typed since\n * the last selection; then the typed text (an item's exact label submits that item's value; G-435,\n * G-468).\n *\n * Props: `label`, `items` (strings or { value, label?, disabled? }), `value` (controlled: a\n * string, an array when `multiple`, null for none), `defaultValue`, `placeholder`, `filter`, and\n * Zag's combobox props (`multiple`, `name`, `form`, `disabled`, `readOnly`, `required`,\n * `invalid`, `allowCustomValue`, `openOnClick`, `inputBehavior`, `selectionBehavior`,\n * `closeOnSelect`, `loopFocus`, `positioning`, `open`, `id`). Events: `value-change` (the value,\n * or the values when multiple), `input-change` (the text the user typed), `open-change` (boolean).\n * Commands: `open`, `close`, `clear`, `focus` (the input).\n */\nimport * as combobox from '@zag-js/combobox'\nimport {fromZag} from '../../zag'\nimport {createElement as h} from '../../index'\nimport {NAMING, arr, collectionOf, named, norm, options, valueOut} from './shared'\n\nconst shown = (all: any[], f: any, q: string) => {\n if (f === false || !q) return all\n const l = q.toLowerCase()\n return all.filter((i) => (typeof f == 'function' ? f(i, q) : String(i.label).toLowerCase().includes(l)))\n}\n\n// the filter text: what the user typed; '' when the list closes\nconst setText = (x: any, q: string) => { if (x.q !== q) x.q = q, x.refresh() }\n\n// G-411: forms get the value, not the label the input shows: the visible input has no name; one\n// hidden input per value (a single combobox: one, '' when empty) carries `name`.\n// G-435 / G-468: a single combobox with `allowCustomValue` submits the selected value unless the\n// user typed since the last selection (`x.t`: set by input-change, cleared by a selection, a value\n// change or a new controlled value that isn't empty: G-494); then the value of an item whose label the text is, else the\n// text itself. So `selectionBehavior` 'preserve' / 'clear', items relabelled after a pick and a\n// `defaultValue` before the items load all submit the value.\nconst submitted = (api: any, x: any): string => {\n const v = api.value[0] ?? ''\n if (!x.custom || !x.t) return v\n const q = api.inputValue\n return x.items.find((i: any) => i.label === q)?.value ?? q\n}\nconst hidden = (api: any, p: any, x: any) => {\n if (p.name == null) return null\n const vs = x.multiple ? api.value : [submitted(api, x)]\n // G-434: `form` as an attribute (HTMLInputElement.form is a read-only property)\n const attrs = p.form == null ? undefined : {form: p.form}\n return vs.map((value: string, i: number) => h('input', {key: 'h' + i, type: 'hidden', name: p.name, attrs, disabled: !!p.disabled, value}))\n}\n\nexport const Combobox: any = /*#__PURE__*/ fromZag(combobox, (api: any, p: any, x: any) => {\n const input = named(api.getInputProps(), p, 1)\n delete input.attrs.name\n delete input.attrs.form\n return h('div', api.getRootProps(),\n p.label != null && h('label', api.getLabelProps(), p.label),\n h('div', api.getControlProps(),\n h('input', {...input, placeholder: p.placeholder}),\n h('button', api.getTriggerProps(), '▾')),\n h('div', api.getPositionerProps(), h('div', named(api.getContentProps(), p), options(h, api))),\n hidden(api, p, x))\n}, {\n name: 'Combobox',\n $own: 1,\n ownProps: [...NAMING, 'name'],\n props: ({items, label, placeholder, value, defaultValue, filter, 'aria-label': _l, 'aria-labelledby': _b, 'aria-describedby': _d, ...p}: any, x: any) => {\n x.multiple = !!p.multiple\n x.custom = !!p.allowCustomValue\n x.items = norm(items)\n // G-468: a new controlled value ends the typing. G-494: not an empty one (an app that clears\n // its value on input-change: the typed text is still what is submitted)\n const v = arr(value), k = v && JSON.stringify(v)\n if (k !== x.v) x.v = k, v?.length && (x.t = 0)\n return {\n ...p,\n collection: collectionOf(combobox, shown(x.items, filter, x.q || '')),\n value: v,\n defaultValue: arr(defaultValue),\n // typing only (not the label a selection writes): the filter text, and input-change\n // G-414: the app's own callbacks (p.onInputValueChange / p.onOpenChange) run first\n onInputValueChange: (d: any) => { p.onInputValueChange?.(d); if (d.reason == 'input-change') x.t = 1, setText(x, d.inputValue), x.dispatch('input-change', d.inputValue) },\n onSelect: (d: any) => { x.t = 0; p.onSelect?.(d) },\n onValueChange: (d: any) => { x.t = 0; p.onValueChange?.(d) },\n onOpenChange: (d: any) => { p.onOpenChange?.(d); d.open || setText(x, '') },\n }\n },\n events: {\n 'value-change': ['onValueChange', valueOut],\n 'input-change': null,\n 'open-change': ['onOpenChange', (d: any) => d.open],\n },\n commands: {\n open: (api: any) => api.setOpen(true),\n close: (api: any) => api.setOpen(false),\n clear: (api: any) => api.clearValue(),\n focus: (api: any) => api.focus(),\n },\n fallback: (p: any, hh: any) => hh('div', null, p.label != null && hh('label', null, p.label), hh('input', {placeholder: p.placeholder, disabled: true})),\n})\n"],"names":["h","fromZag","combobox"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;AAGG;AAEH;AACO,MAAM,MAAM,GAAG,CAAC,YAAY,EAAE,iBAAiB,EAAE,kBAAkB,CAAC,CAAA;AAE3E;;;AAGG;AACI,MAAM,KAAK,GAAG,CAAC,GAAQ,EAAE,CAAM,EAAE,QAAc,KAAI;AACxD,IAAA,MAAM,CAAC,GAAG,GAAG,CAAC,KAAK,CAAA;AACnB,IAAA,IAAI,CAAC,CAAC,KAAK,IAAI,IAAI;AAAE,QAAA,OAAO,CAAC,CAAC,iBAAiB,CAAC,CAAA;IAChD,KAAK,MAAM,CAAC,IAAI,MAAM;AAAE,QAAA,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,KAAK,QAAQ,IAAI,CAAC,IAAI,kBAAkB,CAAC;YAAE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AAW,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC;AACzJ,CAAA;;;;"}
1
+ {"version":3,"file":"ui-combobox.cjs.js","sources":["../src/ui/stack.ts","../src/ui/zag/shared.ts","../src/ui/zag/combobox.ts"],"sourcesContent":["/*\n * UI sweep round 4: the layer stack's entries alone (layers.ts adds the listeners that dismiss).\n * One stack per page on a global, shared by sygnal/ui and the Zag parts' bundles, which each have\n * their own copy of this file: a Zag part only adds and removes its layer (Zag dismisses it), so it\n * doesn't carry the listeners, which only controlled layers (sygnal/ui's, installing them) need.\n */\nconst G: any = globalThis\nexport const S: any = (G[Symbol.for('sygnal.layers')] ||= {stack: []})\n/** `el` closed */\nexport const pull = (el: any) => {\n const i = S.stack.findIndex((l: any) => l.el === el)\n i < 0 || S.stack.splice(i, 1)\n}\n/** `el` opened: on top of the stack (again) */\nexport const add = (el: any, l: any) => {\n pull(el)\n S.stack.push({el, ...l})\n}\n","/*\n * PLAN-5 2-Z: helpers the Zag-based parts (Menu, Select, Combobox) share. '../../zag' becomes the\n * external 'sygnal/zag' and '../../index' the external 'sygnal' in the 'sygnal/ui/menu', 'sygnal/ui/select' and 'sygnal/ui/combobox' builds.\n */\nimport {add, pull} from '../stack'\n\n/** G-413: the naming props a part applies to its control (not the host) */\nexport const NAMING = ['aria-label', 'aria-labelledby', 'aria-describedby']\n\n/**\n * A control's (or listbox's) Zag props named from the part's props: without a label element, no\n * aria-labelledby to it; the props' aria-label / aria-labelledby (/ aria-describedby) win\n */\nexport const named = (bag: any, p: any, describe?: any) => {\n const a = bag.attrs\n if (p.label == null) delete a['aria-labelledby']\n for (const k of NAMING) if (p[k] != null && (describe || k != 'aria-describedby')) a[k] = p[k]\n if (p['aria-labelledby'] != null) delete a['aria-label']\n return bag\n}\n\n/**\n * The items as the parts take them: a string, or { value, label?, disabled? } (Menu also\n * { separator: true } and its item kinds); a group (UI sweep round 2) { group, items } is its\n * items, each with `group` (its label)\n */\nexport const norm = (items: any): any[] =>\n (items || []).flatMap((i: any) => (i && typeof i == 'object'\n ? i.group != null && Array.isArray(i.items) ? norm(i.items).map((j: any) => ({...j, group: String(i.group)}))\n : {...i, value: String(i.value ?? ''), label: i.label ?? String(i.value ?? '')}\n : {value: String(i), label: String(i)}))\n\n/** A Select / Combobox value prop as Zag's string[] (undefined: uncontrolled; null or '': none) */\nexport const arr = (v: any): any =>\n v === undefined ? undefined : v == null || v === '' ? [] : Array.isArray(v) ? v.map(String) : [String(v)]\n\n/** The listbox collection options for Zag's collection() */\nexport const collectionOf = (z: any, items: any[]) =>\n z.collection({items, itemToValue: (i: any) => i.value, itemToString: (i: any) => i.label, isItemDisabled: (i: any) => !!i.disabled,\n // round 2: groups (Zag orders the items by group, as they are shown)\n ...(items.some((i) => i.group != null) && {groupBy: (i: any) => i.group ?? ''})})\n\n/** value-change's detail: the value (single) or the values (multiple) */\nexport const valueOut = (d: any, x: any) => (x.multiple ? d.value : d.value[0] ?? null)\n\n/**\n * Item rows of a listbox (Select, Combobox): text + a ✓ indicator Zag hides when unselected;\n * grouped items (round 2) in a role=\"group\" named by its label (items without a group first)\n */\nexport const options = (h: any, api: any) => {\n const c = api.collection\n const row = (item: any) =>\n h('div', {key: item.value, ...api.getItemProps({item})},\n h('span', api.getItemTextProps({item}), item.label),\n h('span', api.getItemIndicatorProps({item}), '✓'))\n if (!c.items.some((i: any) => i.group != null)) return c.items.map(row)\n return c.group().flatMap(([g, items]: any, k: number) => {\n if (!g) return items.map(row)\n const id = 'g' + k + '-' + g.replace(/[^\\w-]/g, '_')\n return h('div', {key: 'group:' + g, ...api.getItemGroupProps({id})}, h('div', api.getItemGroupLabelProps({htmlFor: id}), g), items.map(row))\n })\n}\n\n/**\n * The parts are form fields (the widget field contract, extra/field.ts): `value-change`'s detail\n * is the field's value, and between picks the machine's value\n */\nexport const field = {event: 'value-change', read: (x: any) => valueOut({value: x.api().value}, x)}\n\n/**\n * Round 2 (Radix's Popper): the positioner is `position: fixed` by default, so a clipping\n * container (`overflow: hidden` / `auto`: a card, a scrolling panel, a <dialog>) doesn't cut the\n * list off or flip it off-screen. An ancestor with a `transform`, `filter` or `contain` is then\n * its containing block; `positioning={{ strategy: 'absolute' }}` (merged over the default) goes back\n */\nexport const placed = (p: any) => ({...p, positioning: {strategy: 'fixed', ...p.positioning}})\n\n/**\n * UI sweep round 4: an open part's content is a layer on sygnal/ui's layer stack (src/ui/stack.ts,\n * shared through a global, so this bundle's copy and sygnal/ui's are one stack; layers.ts reads it). Zag dismisses it\n * itself (its own @zag-js/dismissable layer: Escape, a press or a focus outside); on the stack it\n * is a layer the stack doesn't dismiss (`ctl` false), anchored at the widget's host: so a\n * controlled popover or dialog it opened in counts a press in it as inside, wherever the content\n * renders (Radix's nested DismissableLayer), and Escape is the Zag part's while it is on top. Called\n * from the render; the content exists after the patch, so the stack is updated in a microtask.\n */\nexport const layered = (x: any, open: boolean) => {\n if (!!x.layer == open) return\n x.layer = open || null\n queueMicrotask(() => {\n const c = open && x.el?.querySelector?.('[data-part=\"content\"]')\n if (c && x.layer) add(x.lc = c, {anchor: x.el})\n else if (!x.layer && x.lc) pull(x.lc), x.lc = null\n })\n}\n","/*\n * PLAN-5 2-Z (U-1): Combobox, a Zag combobox machine (WAI-ARIA editable combobox with a listbox\n * popup) as a widget tag.\n *\n * <Combobox className=\"city\" label=\"City\" items={CITIES} value={state.city} placeholder=\"Type a city\" />\n * intent: CITY: DOM.select('.city').events('value-change').detail() // 'Paris'\n *\n * Renders a label, the input (role=\"combobox\", aria-autocomplete=\"list\", aria-activedescendant\n * on the highlighted option), a trigger button, and the listbox in a positioner. The items are\n * filtered as the user types: by default the labels that contain the text (case-insensitive);\n * `filter={(item, text) => boolean}` replaces the test, `filter={false}` leaves it to the app (it\n * passes the `items` to show, from `input-change`). The filter text resets when the list closes.\n * Keyboard is Zag's: ArrowDown / ArrowUp open and move, Enter selects, Escape closes, Home / End\n * in the input move the caret. Styling hooks: `data-scope=\"combobox\"` + `data-part` (root, label,\n * control, input, trigger, positioner, content, item, item-text, item-indicator), `data-state`,\n * `data-highlighted`.\n *\n * Forms (G-411): with `name`, hidden inputs submit the value (one per value when `multiple`);\n * the visible input, which shows the label, has no name. `form` goes on the hidden inputs (G-434).\n * With `allowCustomValue` (single), the selected value is submitted unless the user typed since\n * the last selection; then the typed text (an item's exact label submits that item's value; G-435,\n * G-468).\n * It is a widget field (extra/field.ts): the form behavior and processForm read its value; a form\n * reset puts the first value back (ZS-4).\n *\n * Props: `label`, `items` (strings or { value, label?, disabled? }), `value` (controlled: a\n * string, an array when `multiple`, null for none), `defaultValue`, `placeholder`, `filter`,\n * `loading` (7.2: the items are loading; a value no item has yet isn't custom text), and\n * Zag's combobox props (`multiple`, `name`, `form`, `disabled`, `readOnly`, `required`,\n * `invalid`, `allowCustomValue`, `openOnClick`, `inputBehavior`, `selectionBehavior`,\n * `closeOnSelect`, `loopFocus`, `positioning`, `open`, `id`). Events: `value-change` (the value,\n * or the values when multiple), `input-change` (the text the user typed), `open-change` (boolean).\n * Commands: `open`, `close`, `clear`, `focus` (the input).\n */\nimport * as combobox from '@zag-js/combobox'\nimport {fromZag} from '../../zag'\nimport {createElement as h} from '../../index'\nimport {NAMING, field, placed, arr, collectionOf, layered, named, norm, options, valueOut} from './shared'\n\nconst shown = (all: any[], f: any, q: string) => {\n if (f === false || !q) return all\n const l = q.toLowerCase()\n return all.filter((i) => (typeof f == 'function' ? f(i, q) : String(i.label).toLowerCase().includes(l)))\n}\n\n// the filter text: what the user typed; '' when the list closes\nconst setText = (x: any, q: string) => { if (x.q !== q) x.q = q, x.refresh() }\n\n// Round 2 (React Aria's allowsCustomValue): with `allowCustomValue` (single), the typed text is\n// committed when the focus leaves the combobox, or on Enter with no active option: text that is an\n// item's label picks that item, other text is the value itself (a value no item has), '' is no\n// value. It is reported with value-change like a pick; the input keeps showing it (`shows`).\nconst commit = (x: any, blur?: any) => {\n if (!x.custom || x.multiple || !x.t) return\n const a = x.api(), q = a.inputValue, it = x.items.find((i: any) => i.label === q)\n x.t = 0\n // leaving closes the list (Zag closes it on a pointer or focus outside, not on every blur)\n blur && a.open && a.setOpen(false)\n a.setValue(it ? [it.value] : q ? [q] : [])\n}\n\n// G-411: forms get the value, not the label the input shows: the visible input has no name; one\n// hidden input per value (a single combobox: one, '' when empty) carries `name`.\n// G-435 / G-468: a single combobox with `allowCustomValue` submits the typed text while the user\n// is typing (`x.t`: set by input-change, cleared by a selection, a commit, a value change or a new\n// controlled value that isn't empty: G-494): the value of an item whose label the text is, else\n// the text itself; otherwise the value. So `selectionBehavior` 'preserve' / 'clear', items\n// relabelled after a pick and a `defaultValue` before the items load all submit the value.\nconst submitted = (api: any, x: any): string => {\n const v = api.value[0] ?? ''\n if (!x.custom || !x.t) return v\n const q = api.inputValue\n return x.items.find((i: any) => i.label === q)?.value ?? q\n}\nconst hidden = (api: any, p: any, x: any) => {\n if (p.name == null) return null\n const vs = x.multiple ? api.value : [submitted(api, x)]\n // G-434: `form` as an attribute (HTMLInputElement.form is a read-only property)\n const attrs = p.form == null ? undefined : {form: p.form}\n return vs.map((value: string, i: number) => h('input', {key: 'h' + i, type: 'hidden', name: p.name, attrs, disabled: !!p.disabled, value}))\n}\n\n// ZS-3: the input shows the value's label (with allowCustomValue, a value no item has: its text)\n// while nothing is typed and the list is closed. Zag writes it only when the value changes: not\n// when the items arrive after the value (async loading) or relabel it, and it writes the picked\n// label even when a controlled value refuses the pick ('' for a custom value). Single,\n// selectionBehavior 'replace' (the default) only; checked after each render and each of Zag's\n// own writes, once the app's flush has run (an accepted pick's value arrives then)\n// 7.2: while `loading`, a value no item has yet isn't custom text: it shows nothing until its item\n// arrives (React Aria: the input shows the selected item's text, '' while it isn't in the collection)\nconst shows = (a: any, x: any) =>\n a.value.map((v: string) => x.items.find((i: any) => i.value === v)?.label ?? (x.custom && !x.loading ? v : '')).filter((l: string) => l).join(', ')\nconst sync = (api: any, p: any, x: any) => {\n const off = (a: any) => x.multiple || x.t || a.open || (p.selectionBehavior ?? 'replace') != 'replace' || a.inputValue === shows(a, x)\n api && off(api) || x.sq || (x.sq = 1, queueMicrotask(() => { x.sq = 0; const a = x.el.isConnected && x.api(); a && !off(a) && a.setInputValue(shows(a, x)) }))\n}\n\n// 7.2: the listbox is aria-busy while the items load (React Spectrum's loadingState)\nconst busy = (bag: any, x: any) => (x.loading && (bag.attrs['aria-busy'] = 'true'), bag)\n\n// ZS-4: a form reset puts the first value back (as Zag's Select does: the controlled value's\n// first, or defaultValue: value-change reports it) and the input shows its label; after the\n// browser's own reset, which empties the visible input\nconst onReset = (x: any, input: any) => (e: any) => e.defaultPrevented || setTimeout(() => {\n if (!input.isConnected) return\n const c = x.machine.service.context\n c.set('value', c.initial('value') || [])\n x.t = 0\n setText(x, '')\n const a = x.api(), text = x.multiple ? '' : shows({value: c.initial('value') || []}, x)\n a.setInputValue(text)\n input.value = text\n})\n\n// Round 2 (F-2): a multiple combobox's values as chips before the input (chips={false}: none),\n// each with a remove button (Zag's clearValue(value)); Backspace in the empty input removes the\n// last one, the `remove` command one by value. The buttons are out of the tab order and named by\n// `removeLabel`.\n// Round 3 (React Aria's TagGroup): the chips are a grid of rows, one tab stop (roving tabindex:\n// the last focused chip, else the first). ArrowLeft at the start of the input focuses the last\n// chip; ArrowLeft / ArrowRight move between chips (swapped when dir=\"rtl\"), ArrowRight past the\n// last returns to the input, Home / End the first / last; Delete / Backspace remove the focused\n// chip and focus the next one (else the previous, else the input). A removal is announced in the\n// status region (`removedMessage`); an addition is not: the option's aria-selected already is,\n// and React Aria announces added tags only while the focus is in the group.\nconst labelOf = (x: any, v: string) => x.items.find((i: any) => i.value === v)?.label ?? v\nconst remove = (x: any, v?: any) => {\n const a = x.api(), p = x.p\n if (p.disabled || p.readOnly || !a.value.length) return\n a.clearValue(x.rq = v ?? a.value[a.value.length - 1])\n}\nconst rows = (x: any): any[] => [...x.el.querySelectorAll('[data-part=item-chip]')]\nconst chipKey = (x: any, v: string) => (e: any) => {\n const r = rows(x), i = r.findIndex((c) => c.dataset.value === v), rtl = x.p.dir == 'rtl'\n const k = e.key == 'ArrowLeft' ? (rtl ? 1 : -1) : e.key == 'ArrowRight' ? (rtl ? -1 : 1) : 0\n const go = (j: number) => (j >= r.length ? x.api().focus() : r[Math.max(j, 0)].focus(), e.preventDefault())\n if (k) go(i + k)\n else if (e.key == 'Home') go(0)\n else if (e.key == 'End') go(r.length - 1)\n else if ((e.key == 'Delete' || e.key == 'Backspace') && !x.p.disabled && !x.p.readOnly) {\n e.preventDefault()\n const n = r[i + 1] || r[i - 1]\n remove(x, v)\n // the neighbour's row is kept (keyed), whether the removal is in yet (a controlled value: after\n // the app's flush)\n n?.isConnected ? n.focus() : x.api().focus()\n }\n}\nconst chips = (api: any, p: any, x: any) => {\n if (!x.multiple || p.chips === false || !api.value.length) return null\n const say = p.removeLabel ?? ((l: string) => 'Remove ' + l), off = !!(p.disabled || p.readOnly)\n // the tab stop: the focused (or last focused) chip while it is a value, else the first\n const stop = api.value.includes(x.cf) ? x.cf : api.value[0], d = x.hint && {'aria-describedby': x.hint}\n return h('div', {attrs: {'data-scope': 'combobox', 'data-part': 'item-chips', role: 'grid', 'aria-label': p.chipsLabel ?? (p.label != null ? String(p.label) : 'Selected')}},\n api.value.map((v: string) => {\n const l = labelOf(x, v)\n return h('div', {\n key: v,\n attrs: {'data-scope': 'combobox', 'data-part': 'item-chip', 'data-value': v, role: 'row', 'aria-label': l, tabindex: !p.disabled && v === stop ? '0' : '-1', 'data-disabled': off ? '' : undefined, ...(!off && d)},\n on: {keydown: chipKey(x, v), focus: () => { x.cf !== v && (x.cf = v, x.draw()) }},\n }, h('div', {attrs: {role: 'gridcell', 'data-scope': 'combobox', 'data-part': 'item-chip-cell'}},\n h('span', {attrs: {'data-scope': 'combobox', 'data-part': 'item-chip-text'}}, l),\n h('button', {\n attrs: {type: 'button', tabindex: '-1', 'data-scope': 'combobox', 'data-part': 'item-chip-remove', 'aria-label': typeof say == 'function' ? say(l) : say + ' ' + l},\n props: {disabled: off},\n // the focus stays where it is (the input, or the chip)\n on: {mousedown: (e: any) => e.preventDefault(), click: () => remove(x, v)},\n }, '×')))\n }))\n}\n// the status region's text: a removal once its value is gone (announced; a zero-width space after\n// every other one, so the same text twice is announced twice); `empty` while it shows\nconst status = (api: any, p: any, x: any, none: any) => {\n if (x.rq != null && !api.value.includes(x.rq)) {\n const m = p.removedMessage, l = labelOf(x, x.rq)\n x.rq = null\n if (m !== false) x.say = (typeof m == 'function' ? m(l) : l + ' removed') + ((x.n = !x.n) ? '' : '\\u200b')\n }\n // shown text is not announced again when it comes back\n return none ? (x.say = '', p.empty) : x.say || ''\n}\n// visually hidden, in the accessibility tree (the empty row's status region)\nconst SR = {position: 'absolute', width: '1px', height: '1px', margin: '-1px', padding: '0', border: '0', overflow: 'hidden', clip: 'rect(0 0 0 0)', whiteSpace: 'nowrap'}\n\nexport const Combobox: any = /*#__PURE__*/ fromZag(combobox, (api: any, p: any, x: any) => {\n const input = named(api.getInputProps(), p, 1)\n layered(x, api.open)\n delete input.attrs.name\n delete input.attrs.form\n // Round 2: commit the typed text (allowCustomValue) when the focus leaves the combobox, or on\n // Enter with no active option (Zag's handlers first)\n const on = input.on, out = on.focusout, kd = on.keydown\n on.focusout = (e: any) => { out?.(e); x.el.contains(e.relatedTarget) || commit(x, 1) }\n on.keydown = (e: any) => {\n const none = x.api().highlightedValue == null, empty = e.target.value === ''\n kd?.(e)\n if (e.key == 'Enter' && none) commit(x)\n // F-2: Backspace in the empty input removes the last chip\n else if (e.key == 'Backspace' && empty && x.multiple && p.chips !== false) remove(x)\n // Round 3: ArrowLeft (ArrowRight when rtl) at the start of the input: the last chip\n else if (e.key == (p.dir == 'rtl' ? 'ArrowRight' : 'ArrowLeft') && !e.defaultPrevented && e.target.selectionStart === 0 && e.target.selectionEnd === 0) {\n const r = x.multiple && rows(x)\n r?.length && (e.preventDefault(), r[r.length - 1].focus())\n }\n }\n x.p = p\n sync(api, p, x)\n // ZS-4: the reset listener on the input's form (its ancestor, or the `form` attribute's)\n const hook = {\n insert: (v: any) => {\n const f = x.form = p.form != null ? v.elm.ownerDocument.getElementById(p.form) : v.elm.closest('form')\n f?.addEventListener('reset', x.reset = onReset(x, v.elm))\n },\n destroy: () => x.form?.removeEventListener('reset', x.reset),\n }\n // F-4: `empty` while the list is open with no items: a row after the listbox, and the status\n // region's text (announced)\n const none = api.open && !api.collection.items.length && p.empty != null && !x.loading\n // Round 3: one \"Press Delete to remove\" description the chips point at (removeHint={false}: none)\n const tags = x.multiple && p.chips !== false\n x.hint = tags && p.removeHint !== false ? x.machine.service.prop('id') + '-chip-hint' : 0\n return h('div', api.getRootProps(),\n p.label != null && h('label', api.getLabelProps(), p.label),\n h('div', api.getControlProps(),\n chips(api, p, x),\n h('input', {...input, placeholder: p.placeholder, hook}),\n h('button', api.getTriggerProps(), '▾')),\n h('div', api.getPositionerProps(),\n h('div', busy(named(api.getContentProps(), p), x), options(h, api)),\n p.empty != null && h('div', {attrs: {'data-scope': 'combobox', 'data-part': 'empty', hidden: !none}}, p.empty)),\n (p.empty != null || tags) && h('div', {attrs: {role: 'status', 'data-scope': 'combobox', 'data-part': 'status'}, style: SR}, status(api, p, x, none)),\n x.hint && h('span', {attrs: {id: x.hint, hidden: true}}, p.removeHint ?? 'Press Delete to remove.'),\n hidden(api, p, x))\n}, {\n name: 'Combobox',\n $own: 1,\n field,\n ownProps: [...NAMING, 'name'],\n props: ({items, label, placeholder, value, defaultValue, filter, empty, loading, chips: _c, removeLabel, chipsLabel, removedMessage, removeHint, 'aria-label': _l, 'aria-labelledby': _b, 'aria-describedby': _d, ...p}: any, x: any) => {\n x.multiple = !!p.multiple\n x.custom = !!p.allowCustomValue\n x.loading = !!loading\n x.items = norm(items)\n // G-468: a new controlled value ends the typing. G-494: not an empty one (an app that clears\n // its value on input-change: the typed text is still what is submitted)\n const v = arr(value), k = v && JSON.stringify(v)\n if (k !== x.v) x.v = k, v?.length && (x.t = 0)\n // the first value (ZS-4), whether controlled; a controlled custom value (Round 2)\n return {\n ...placed(p),\n collection: collectionOf(combobox, shown(x.items, filter, x.q || '')),\n value: v,\n defaultValue: arr(defaultValue),\n // typing only (not the label a selection writes): the filter text, and input-change\n // G-414: the app's own callbacks (p.onInputValueChange / p.onOpenChange) run first\n // ZS-3: Zag's own writes (a value change's label, outside a render) are checked too, once\n // they are in (after this callback)\n onInputValueChange: (d: any) => {\n p.onInputValueChange?.(d)\n if (d.reason == 'input-change') x.t = 1, setText(x, d.inputValue), x.dispatch('input-change', d.inputValue)\n else sync(0, x.p, x)\n },\n onSelect: (d: any) => { x.t = 0; p.onSelect?.(d) },\n onValueChange: (d: any) => { x.t = 0; p.onValueChange?.(d) },\n onOpenChange: (d: any) => { p.onOpenChange?.(d); d.open || (setText(x, ''), sync(0, x.p, x)) },\n }\n },\n events: {\n 'value-change': ['onValueChange', valueOut],\n 'input-change': null,\n 'open-change': ['onOpenChange', (d: any) => d.open],\n },\n commands: {\n open: (api: any) => api.setOpen(true),\n close: (api: any) => api.setOpen(false),\n clear: (api: any) => api.clearValue(),\n // F-2: { remove: '.c', value } removes one value (without `value`: the last)\n remove: (_: any, o: any, x: any) => remove(x, o.value),\n focus: (api: any) => api.focus(),\n },\n fallback: (p: any, hh: any) => hh('div', null, p.label != null && hh('label', null, p.label), hh('input', {placeholder: p.placeholder, disabled: true})),\n})\n"],"names":["h","fromZag","combobox"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;AAKG;AACH,MAAM,CAAC,GAAQ,UAAU,CAAA;AAClB,MAAM,CAAC,IAAS,CAAC,CAAA,EAAA,GAAC,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA,KAA7B,CAAC,CAAkC,EAAA,CAAA,GAAA,EAAC,KAAK,EAAE,EAAE,EAAC,CAAA,CAAC,CAAA;AACtE;AACO,MAAM,IAAI,GAAG,CAAC,EAAO,KAAI;AAC9B,IAAA,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CA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C,EAAE,CAAC,CAAC,CAAC,CAAA,EAAE;SAC/F,CAAA;KACF;AACD,IAAA,MAAM,EAAE;AACN,QAAA,cAAc,EAAE,CAAC,eAAe,EAAE,QAAQ,CAAC;AAC3C,QAAA,cAAc,EAAE,IAAI;AACpB,QAAA,aAAa,EAAE,CAAC,cAAc,EAAE,CAAC,CAAM,KAAK,CAAC,CAAC,IAAI,CAAC;AACpD,KAAA;AACD,IAAA,QAAQ,EAAE;QACR,IAAI,EAAE,CAAC,GAAQ,KAAK,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC;QACrC,KAAK,EAAE,CAAC,GAAQ,KAAK,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC;QACvC,KAAK,EAAE,CAAC,GAAQ,KAAK,GAAG,CAAC,UAAU,EAAE;;AAErC,QAAA,MAAM,EAAE,CAAC,CAAM,EAAE,CAAM,EAAE,CAAM,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC;QACtD,KAAK,EAAE,CAAC,GAAQ,KAAK,GAAG,CAAC,KAAK,EAAE;AACjC,KAAA;IACD,QAAQ,EAAE,CAAC,CAAM,EAAE,EAAO,KAAK,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,IAAI,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,OAAO,EAAE,EAAC,WAAW,EAAE,CAAC,CAAC,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC;AACzJ,CAAA;;;;"}
@@ -2,6 +2,26 @@ import * as combobox from '@zag-js/combobox';
2
2
  import { fromZag } from 'sygnal/zag';
3
3
  import { createElement } from 'sygnal';
4
4
 
5
+ var _a;
6
+ /*
7
+ * UI sweep round 4: the layer stack's entries alone (layers.ts adds the listeners that dismiss).
8
+ * One stack per page on a global, shared by sygnal/ui and the Zag parts' bundles, which each have
9
+ * their own copy of this file: a Zag part only adds and removes its layer (Zag dismisses it), so it
10
+ * doesn't carry the listeners, which only controlled layers (sygnal/ui's, installing them) need.
11
+ */
12
+ const G = globalThis;
13
+ const S = (G[_a = Symbol.for('sygnal.layers')] || (G[_a] = { stack: [] }));
14
+ /** `el` closed */
15
+ const pull = (el) => {
16
+ const i = S.stack.findIndex((l) => l.el === el);
17
+ i < 0 || S.stack.splice(i, 1);
18
+ };
19
+ /** `el` opened: on top of the stack (again) */
20
+ const add = (el, l) => {
21
+ pull(el);
22
+ S.stack.push({ el, ...l });
23
+ };
24
+
5
25
  /*
6
26
  * PLAN-5 2-Z: helpers the Zag-based parts (Menu, Select, Combobox) share. '../../zag' becomes the
7
27
  * external 'sygnal/zag' and '../../index' the external 'sygnal' in the 'sygnal/ui/menu', 'sygnal/ui/select' and 'sygnal/ui/combobox' builds.
@@ -23,18 +43,72 @@ const named = (bag, p, describe) => {
23
43
  delete a['aria-label'];
24
44
  return bag;
25
45
  };
26
- /** An item as the parts take it: a string, or { value, label?, disabled? } (Menu also { separator: true }) */
27
- const norm = (items) => (items || []).map((i) => (i && typeof i == 'object'
28
- ? { ...i, value: String(i.value ?? ''), label: i.label ?? String(i.value ?? '') }
46
+ /**
47
+ * The items as the parts take them: a string, or { value, label?, disabled? } (Menu also
48
+ * { separator: true } and its item kinds); a group (UI sweep round 2) { group, items } is its
49
+ * items, each with `group` (its label)
50
+ */
51
+ const norm = (items) => (items || []).flatMap((i) => (i && typeof i == 'object'
52
+ ? i.group != null && Array.isArray(i.items) ? norm(i.items).map((j) => ({ ...j, group: String(i.group) }))
53
+ : { ...i, value: String(i.value ?? ''), label: i.label ?? String(i.value ?? '') }
29
54
  : { value: String(i), label: String(i) }));
30
55
  /** A Select / Combobox value prop as Zag's string[] (undefined: uncontrolled; null or '': none) */
31
56
  const arr = (v) => v === undefined ? undefined : v == null || v === '' ? [] : Array.isArray(v) ? v.map(String) : [String(v)];
32
57
  /** The listbox collection options for Zag's collection() */
33
- const collectionOf = (z, items) => z.collection({ items, itemToValue: (i) => i.value, itemToString: (i) => i.label, isItemDisabled: (i) => !!i.disabled });
58
+ const collectionOf = (z, items) => z.collection({ items, itemToValue: (i) => i.value, itemToString: (i) => i.label, isItemDisabled: (i) => !!i.disabled,
59
+ // round 2: groups (Zag orders the items by group, as they are shown)
60
+ ...(items.some((i) => i.group != null) && { groupBy: (i) => i.group ?? '' }) });
34
61
  /** value-change's detail: the value (single) or the values (multiple) */
35
62
  const valueOut = (d, x) => (x.multiple ? d.value : d.value[0] ?? null);
36
- /** Item rows of a listbox (Select, Combobox): text + a ✓ indicator Zag hides when unselected */
37
- const options = (h, api) => api.collection.items.map((item) => h('div', { key: item.value, ...api.getItemProps({ item }) }, h('span', api.getItemTextProps({ item }), item.label), h('span', api.getItemIndicatorProps({ item }), '✓')));
63
+ /**
64
+ * Item rows of a listbox (Select, Combobox): text + a ✓ indicator Zag hides when unselected;
65
+ * grouped items (round 2) in a role="group" named by its label (items without a group first)
66
+ */
67
+ const options = (h, api) => {
68
+ const c = api.collection;
69
+ const row = (item) => h('div', { key: item.value, ...api.getItemProps({ item }) }, h('span', api.getItemTextProps({ item }), item.label), h('span', api.getItemIndicatorProps({ item }), '✓'));
70
+ if (!c.items.some((i) => i.group != null))
71
+ return c.items.map(row);
72
+ return c.group().flatMap(([g, items], k) => {
73
+ if (!g)
74
+ return items.map(row);
75
+ const id = 'g' + k + '-' + g.replace(/[^\w-]/g, '_');
76
+ return h('div', { key: 'group:' + g, ...api.getItemGroupProps({ id }) }, h('div', api.getItemGroupLabelProps({ htmlFor: id }), g), items.map(row));
77
+ });
78
+ };
79
+ /**
80
+ * The parts are form fields (the widget field contract, extra/field.ts): `value-change`'s detail
81
+ * is the field's value, and between picks the machine's value
82
+ */
83
+ const field = { event: 'value-change', read: (x) => valueOut({ value: x.api().value }, x) };
84
+ /**
85
+ * Round 2 (Radix's Popper): the positioner is `position: fixed` by default, so a clipping
86
+ * container (`overflow: hidden` / `auto`: a card, a scrolling panel, a <dialog>) doesn't cut the
87
+ * list off or flip it off-screen. An ancestor with a `transform`, `filter` or `contain` is then
88
+ * its containing block; `positioning={{ strategy: 'absolute' }}` (merged over the default) goes back
89
+ */
90
+ const placed = (p) => ({ ...p, positioning: { strategy: 'fixed', ...p.positioning } });
91
+ /**
92
+ * UI sweep round 4: an open part's content is a layer on sygnal/ui's layer stack (src/ui/stack.ts,
93
+ * shared through a global, so this bundle's copy and sygnal/ui's are one stack; layers.ts reads it). Zag dismisses it
94
+ * itself (its own @zag-js/dismissable layer: Escape, a press or a focus outside); on the stack it
95
+ * is a layer the stack doesn't dismiss (`ctl` false), anchored at the widget's host: so a
96
+ * controlled popover or dialog it opened in counts a press in it as inside, wherever the content
97
+ * renders (Radix's nested DismissableLayer), and Escape is the Zag part's while it is on top. Called
98
+ * from the render; the content exists after the patch, so the stack is updated in a microtask.
99
+ */
100
+ const layered = (x, open) => {
101
+ if (!!x.layer == open)
102
+ return;
103
+ x.layer = open || null;
104
+ queueMicrotask(() => {
105
+ const c = open && x.el?.querySelector?.('[data-part="content"]');
106
+ if (c && x.layer)
107
+ add(x.lc = c, { anchor: x.el });
108
+ else if (!x.layer && x.lc)
109
+ pull(x.lc), x.lc = null;
110
+ });
111
+ };
38
112
 
39
113
  /*
40
114
  * PLAN-5 2-Z (U-1): Combobox, a Zag combobox machine (WAI-ARIA editable combobox with a listbox
@@ -58,9 +132,12 @@ const options = (h, api) => api.collection.items.map((item) => h('div', { key: i
58
132
  * With `allowCustomValue` (single), the selected value is submitted unless the user typed since
59
133
  * the last selection; then the typed text (an item's exact label submits that item's value; G-435,
60
134
  * G-468).
135
+ * It is a widget field (extra/field.ts): the form behavior and processForm read its value; a form
136
+ * reset puts the first value back (ZS-4).
61
137
  *
62
138
  * Props: `label`, `items` (strings or { value, label?, disabled? }), `value` (controlled: a
63
- * string, an array when `multiple`, null for none), `defaultValue`, `placeholder`, `filter`, and
139
+ * string, an array when `multiple`, null for none), `defaultValue`, `placeholder`, `filter`,
140
+ * `loading` (7.2: the items are loading; a value no item has yet isn't custom text), and
64
141
  * Zag's combobox props (`multiple`, `name`, `form`, `disabled`, `readOnly`, `required`,
65
142
  * `invalid`, `allowCustomValue`, `openOnClick`, `inputBehavior`, `selectionBehavior`,
66
143
  * `closeOnSelect`, `loopFocus`, `positioning`, `open`, `id`). Events: `value-change` (the value,
@@ -76,13 +153,26 @@ const shown = (all, f, q) => {
76
153
  // the filter text: what the user typed; '' when the list closes
77
154
  const setText = (x, q) => { if (x.q !== q)
78
155
  x.q = q, x.refresh(); };
156
+ // Round 2 (React Aria's allowsCustomValue): with `allowCustomValue` (single), the typed text is
157
+ // committed when the focus leaves the combobox, or on Enter with no active option: text that is an
158
+ // item's label picks that item, other text is the value itself (a value no item has), '' is no
159
+ // value. It is reported with value-change like a pick; the input keeps showing it (`shows`).
160
+ const commit = (x, blur) => {
161
+ if (!x.custom || x.multiple || !x.t)
162
+ return;
163
+ const a = x.api(), q = a.inputValue, it = x.items.find((i) => i.label === q);
164
+ x.t = 0;
165
+ // leaving closes the list (Zag closes it on a pointer or focus outside, not on every blur)
166
+ blur && a.open && a.setOpen(false);
167
+ a.setValue(it ? [it.value] : q ? [q] : []);
168
+ };
79
169
  // G-411: forms get the value, not the label the input shows: the visible input has no name; one
80
170
  // hidden input per value (a single combobox: one, '' when empty) carries `name`.
81
- // G-435 / G-468: a single combobox with `allowCustomValue` submits the selected value unless the
82
- // user typed since the last selection (`x.t`: set by input-change, cleared by a selection, a value
83
- // change or a new controlled value that isn't empty: G-494); then the value of an item whose label the text is, else the
84
- // text itself. So `selectionBehavior` 'preserve' / 'clear', items relabelled after a pick and a
85
- // `defaultValue` before the items load all submit the value.
171
+ // G-435 / G-468: a single combobox with `allowCustomValue` submits the typed text while the user
172
+ // is typing (`x.t`: set by input-change, cleared by a selection, a commit, a value change or a new
173
+ // controlled value that isn't empty: G-494): the value of an item whose label the text is, else
174
+ // the text itself; otherwise the value. So `selectionBehavior` 'preserve' / 'clear', items
175
+ // relabelled after a pick and a `defaultValue` before the items load all submit the value.
86
176
  const submitted = (api, x) => {
87
177
  const v = api.value[0] ?? '';
88
178
  if (!x.custom || !x.t)
@@ -98,36 +188,182 @@ const hidden = (api, p, x) => {
98
188
  const attrs = p.form == null ? undefined : { form: p.form };
99
189
  return vs.map((value, i) => createElement('input', { key: 'h' + i, type: 'hidden', name: p.name, attrs, disabled: !!p.disabled, value }));
100
190
  };
191
+ // ZS-3: the input shows the value's label (with allowCustomValue, a value no item has: its text)
192
+ // while nothing is typed and the list is closed. Zag writes it only when the value changes: not
193
+ // when the items arrive after the value (async loading) or relabel it, and it writes the picked
194
+ // label even when a controlled value refuses the pick ('' for a custom value). Single,
195
+ // selectionBehavior 'replace' (the default) only; checked after each render and each of Zag's
196
+ // own writes, once the app's flush has run (an accepted pick's value arrives then)
197
+ // 7.2: while `loading`, a value no item has yet isn't custom text: it shows nothing until its item
198
+ // arrives (React Aria: the input shows the selected item's text, '' while it isn't in the collection)
199
+ const shows = (a, x) => a.value.map((v) => x.items.find((i) => i.value === v)?.label ?? (x.custom && !x.loading ? v : '')).filter((l) => l).join(', ');
200
+ const sync = (api, p, x) => {
201
+ const off = (a) => x.multiple || x.t || a.open || (p.selectionBehavior ?? 'replace') != 'replace' || a.inputValue === shows(a, x);
202
+ api && off(api) || x.sq || (x.sq = 1, queueMicrotask(() => { x.sq = 0; const a = x.el.isConnected && x.api(); a && !off(a) && a.setInputValue(shows(a, x)); }));
203
+ };
204
+ // 7.2: the listbox is aria-busy while the items load (React Spectrum's loadingState)
205
+ const busy = (bag, x) => (x.loading && (bag.attrs['aria-busy'] = 'true'), bag);
206
+ // ZS-4: a form reset puts the first value back (as Zag's Select does: the controlled value's
207
+ // first, or defaultValue: value-change reports it) and the input shows its label; after the
208
+ // browser's own reset, which empties the visible input
209
+ const onReset = (x, input) => (e) => e.defaultPrevented || setTimeout(() => {
210
+ if (!input.isConnected)
211
+ return;
212
+ const c = x.machine.service.context;
213
+ c.set('value', c.initial('value') || []);
214
+ x.t = 0;
215
+ setText(x, '');
216
+ const a = x.api(), text = x.multiple ? '' : shows({ value: c.initial('value') || [] }, x);
217
+ a.setInputValue(text);
218
+ input.value = text;
219
+ });
220
+ // Round 2 (F-2): a multiple combobox's values as chips before the input (chips={false}: none),
221
+ // each with a remove button (Zag's clearValue(value)); Backspace in the empty input removes the
222
+ // last one, the `remove` command one by value. The buttons are out of the tab order and named by
223
+ // `removeLabel`.
224
+ // Round 3 (React Aria's TagGroup): the chips are a grid of rows, one tab stop (roving tabindex:
225
+ // the last focused chip, else the first). ArrowLeft at the start of the input focuses the last
226
+ // chip; ArrowLeft / ArrowRight move between chips (swapped when dir="rtl"), ArrowRight past the
227
+ // last returns to the input, Home / End the first / last; Delete / Backspace remove the focused
228
+ // chip and focus the next one (else the previous, else the input). A removal is announced in the
229
+ // status region (`removedMessage`); an addition is not: the option's aria-selected already is,
230
+ // and React Aria announces added tags only while the focus is in the group.
231
+ const labelOf = (x, v) => x.items.find((i) => i.value === v)?.label ?? v;
232
+ const remove = (x, v) => {
233
+ const a = x.api(), p = x.p;
234
+ if (p.disabled || p.readOnly || !a.value.length)
235
+ return;
236
+ a.clearValue(x.rq = v ?? a.value[a.value.length - 1]);
237
+ };
238
+ const rows = (x) => [...x.el.querySelectorAll('[data-part=item-chip]')];
239
+ const chipKey = (x, v) => (e) => {
240
+ const r = rows(x), i = r.findIndex((c) => c.dataset.value === v), rtl = x.p.dir == 'rtl';
241
+ const k = e.key == 'ArrowLeft' ? (rtl ? 1 : -1) : e.key == 'ArrowRight' ? (rtl ? -1 : 1) : 0;
242
+ const go = (j) => (j >= r.length ? x.api().focus() : r[Math.max(j, 0)].focus(), e.preventDefault());
243
+ if (k)
244
+ go(i + k);
245
+ else if (e.key == 'Home')
246
+ go(0);
247
+ else if (e.key == 'End')
248
+ go(r.length - 1);
249
+ else if ((e.key == 'Delete' || e.key == 'Backspace') && !x.p.disabled && !x.p.readOnly) {
250
+ e.preventDefault();
251
+ const n = r[i + 1] || r[i - 1];
252
+ remove(x, v);
253
+ // the neighbour's row is kept (keyed), whether the removal is in yet (a controlled value: after
254
+ // the app's flush)
255
+ n?.isConnected ? n.focus() : x.api().focus();
256
+ }
257
+ };
258
+ const chips = (api, p, x) => {
259
+ if (!x.multiple || p.chips === false || !api.value.length)
260
+ return null;
261
+ const say = p.removeLabel ?? ((l) => 'Remove ' + l), off = !!(p.disabled || p.readOnly);
262
+ // the tab stop: the focused (or last focused) chip while it is a value, else the first
263
+ const stop = api.value.includes(x.cf) ? x.cf : api.value[0], d = x.hint && { 'aria-describedby': x.hint };
264
+ return createElement('div', { attrs: { 'data-scope': 'combobox', 'data-part': 'item-chips', role: 'grid', 'aria-label': p.chipsLabel ?? (p.label != null ? String(p.label) : 'Selected') } }, api.value.map((v) => {
265
+ const l = labelOf(x, v);
266
+ return createElement('div', {
267
+ key: v,
268
+ attrs: { 'data-scope': 'combobox', 'data-part': 'item-chip', 'data-value': v, role: 'row', 'aria-label': l, tabindex: !p.disabled && v === stop ? '0' : '-1', 'data-disabled': off ? '' : undefined, ...(!off && d) },
269
+ on: { keydown: chipKey(x, v), focus: () => { x.cf !== v && (x.cf = v, x.draw()); } },
270
+ }, createElement('div', { attrs: { role: 'gridcell', 'data-scope': 'combobox', 'data-part': 'item-chip-cell' } }, createElement('span', { attrs: { 'data-scope': 'combobox', 'data-part': 'item-chip-text' } }, l), createElement('button', {
271
+ attrs: { type: 'button', tabindex: '-1', 'data-scope': 'combobox', 'data-part': 'item-chip-remove', 'aria-label': typeof say == 'function' ? say(l) : say + ' ' + l },
272
+ props: { disabled: off },
273
+ // the focus stays where it is (the input, or the chip)
274
+ on: { mousedown: (e) => e.preventDefault(), click: () => remove(x, v) },
275
+ }, '×')));
276
+ }));
277
+ };
278
+ // the status region's text: a removal once its value is gone (announced; a zero-width space after
279
+ // every other one, so the same text twice is announced twice); `empty` while it shows
280
+ const status = (api, p, x, none) => {
281
+ if (x.rq != null && !api.value.includes(x.rq)) {
282
+ const m = p.removedMessage, l = labelOf(x, x.rq);
283
+ x.rq = null;
284
+ if (m !== false)
285
+ x.say = (typeof m == 'function' ? m(l) : l + ' removed') + ((x.n = !x.n) ? '' : '\u200b');
286
+ }
287
+ // shown text is not announced again when it comes back
288
+ return none ? (x.say = '', p.empty) : x.say || '';
289
+ };
290
+ // visually hidden, in the accessibility tree (the empty row's status region)
291
+ const SR = { position: 'absolute', width: '1px', height: '1px', margin: '-1px', padding: '0', border: '0', overflow: 'hidden', clip: 'rect(0 0 0 0)', whiteSpace: 'nowrap' };
101
292
  const Combobox = /*#__PURE__*/ fromZag(combobox, (api, p, x) => {
102
293
  const input = named(api.getInputProps(), p, 1);
294
+ layered(x, api.open);
103
295
  delete input.attrs.name;
104
296
  delete input.attrs.form;
105
- return createElement('div', api.getRootProps(), p.label != null && createElement('label', api.getLabelProps(), p.label), createElement('div', api.getControlProps(), createElement('input', { ...input, placeholder: p.placeholder }), createElement('button', api.getTriggerProps(), '▾')), createElement('div', api.getPositionerProps(), createElement('div', named(api.getContentProps(), p), options(createElement, api))), hidden(api, p, x));
297
+ // Round 2: commit the typed text (allowCustomValue) when the focus leaves the combobox, or on
298
+ // Enter with no active option (Zag's handlers first)
299
+ const on = input.on, out = on.focusout, kd = on.keydown;
300
+ on.focusout = (e) => { out?.(e); x.el.contains(e.relatedTarget) || commit(x, 1); };
301
+ on.keydown = (e) => {
302
+ const none = x.api().highlightedValue == null, empty = e.target.value === '';
303
+ kd?.(e);
304
+ if (e.key == 'Enter' && none)
305
+ commit(x);
306
+ // F-2: Backspace in the empty input removes the last chip
307
+ else if (e.key == 'Backspace' && empty && x.multiple && p.chips !== false)
308
+ remove(x);
309
+ // Round 3: ArrowLeft (ArrowRight when rtl) at the start of the input: the last chip
310
+ else if (e.key == (p.dir == 'rtl' ? 'ArrowRight' : 'ArrowLeft') && !e.defaultPrevented && e.target.selectionStart === 0 && e.target.selectionEnd === 0) {
311
+ const r = x.multiple && rows(x);
312
+ r?.length && (e.preventDefault(), r[r.length - 1].focus());
313
+ }
314
+ };
315
+ x.p = p;
316
+ sync(api, p, x);
317
+ // ZS-4: the reset listener on the input's form (its ancestor, or the `form` attribute's)
318
+ const hook = {
319
+ insert: (v) => {
320
+ const f = x.form = p.form != null ? v.elm.ownerDocument.getElementById(p.form) : v.elm.closest('form');
321
+ f?.addEventListener('reset', x.reset = onReset(x, v.elm));
322
+ },
323
+ destroy: () => x.form?.removeEventListener('reset', x.reset),
324
+ };
325
+ // F-4: `empty` while the list is open with no items: a row after the listbox, and the status
326
+ // region's text (announced)
327
+ const none = api.open && !api.collection.items.length && p.empty != null && !x.loading;
328
+ // Round 3: one "Press Delete to remove" description the chips point at (removeHint={false}: none)
329
+ const tags = x.multiple && p.chips !== false;
330
+ x.hint = tags && p.removeHint !== false ? x.machine.service.prop('id') + '-chip-hint' : 0;
331
+ return createElement('div', api.getRootProps(), p.label != null && createElement('label', api.getLabelProps(), p.label), createElement('div', api.getControlProps(), chips(api, p, x), createElement('input', { ...input, placeholder: p.placeholder, hook }), createElement('button', api.getTriggerProps(), '▾')), createElement('div', api.getPositionerProps(), createElement('div', busy(named(api.getContentProps(), p), x), options(createElement, api)), p.empty != null && createElement('div', { attrs: { 'data-scope': 'combobox', 'data-part': 'empty', hidden: !none } }, p.empty)), (p.empty != null || tags) && createElement('div', { attrs: { role: 'status', 'data-scope': 'combobox', 'data-part': 'status' }, style: SR }, status(api, p, x, none)), x.hint && createElement('span', { attrs: { id: x.hint, hidden: true } }, p.removeHint ?? 'Press Delete to remove.'), hidden(api, p, x));
106
332
  }, {
107
333
  name: 'Combobox',
108
334
  $own: 1,
335
+ field,
109
336
  ownProps: [...NAMING, 'name'],
110
- props: ({ items, label, placeholder, value, defaultValue, filter, 'aria-label': _l, 'aria-labelledby': _b, 'aria-describedby': _d, ...p }, x) => {
337
+ props: ({ items, label, placeholder, value, defaultValue, filter, empty, loading, chips: _c, removeLabel, chipsLabel, removedMessage, removeHint, 'aria-label': _l, 'aria-labelledby': _b, 'aria-describedby': _d, ...p }, x) => {
111
338
  x.multiple = !!p.multiple;
112
339
  x.custom = !!p.allowCustomValue;
340
+ x.loading = !!loading;
113
341
  x.items = norm(items);
114
342
  // G-468: a new controlled value ends the typing. G-494: not an empty one (an app that clears
115
343
  // its value on input-change: the typed text is still what is submitted)
116
344
  const v = arr(value), k = v && JSON.stringify(v);
117
345
  if (k !== x.v)
118
346
  x.v = k, v?.length && (x.t = 0);
347
+ // the first value (ZS-4), whether controlled; a controlled custom value (Round 2)
119
348
  return {
120
- ...p,
349
+ ...placed(p),
121
350
  collection: collectionOf(combobox, shown(x.items, filter, x.q || '')),
122
351
  value: v,
123
352
  defaultValue: arr(defaultValue),
124
353
  // typing only (not the label a selection writes): the filter text, and input-change
125
354
  // G-414: the app's own callbacks (p.onInputValueChange / p.onOpenChange) run first
126
- onInputValueChange: (d) => { p.onInputValueChange?.(d); if (d.reason == 'input-change')
127
- x.t = 1, setText(x, d.inputValue), x.dispatch('input-change', d.inputValue); },
355
+ // ZS-3: Zag's own writes (a value change's label, outside a render) are checked too, once
356
+ // they are in (after this callback)
357
+ onInputValueChange: (d) => {
358
+ p.onInputValueChange?.(d);
359
+ if (d.reason == 'input-change')
360
+ x.t = 1, setText(x, d.inputValue), x.dispatch('input-change', d.inputValue);
361
+ else
362
+ sync(0, x.p, x);
363
+ },
128
364
  onSelect: (d) => { x.t = 0; p.onSelect?.(d); },
129
365
  onValueChange: (d) => { x.t = 0; p.onValueChange?.(d); },
130
- onOpenChange: (d) => { p.onOpenChange?.(d); d.open || setText(x, ''); },
366
+ onOpenChange: (d) => { p.onOpenChange?.(d); d.open || (setText(x, ''), sync(0, x.p, x)); },
131
367
  };
132
368
  },
133
369
  events: {
@@ -139,6 +375,8 @@ const Combobox = /*#__PURE__*/ fromZag(combobox, (api, p, x) => {
139
375
  open: (api) => api.setOpen(true),
140
376
  close: (api) => api.setOpen(false),
141
377
  clear: (api) => api.clearValue(),
378
+ // F-2: { remove: '.c', value } removes one value (without `value`: the last)
379
+ remove: (_, o, x) => remove(x, o.value),
142
380
  focus: (api) => api.focus(),
143
381
  },
144
382
  fallback: (p, hh) => hh('div', null, p.label != null && hh('label', null, p.label), hh('input', { placeholder: p.placeholder, disabled: true })),