arethesis 0.1.5 → 0.2.1

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 (383) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/README.md +5 -4
  3. package/dist/arethesis.js +2 -147
  4. package/dist/binding/data-binder.d.ts +8 -0
  5. package/dist/binding/data-binder.d.ts.map +1 -1
  6. package/dist/binding/data-binder.js +605 -0
  7. package/dist/binding/data-binder.js.map +1 -0
  8. package/dist/binding/types.d.ts +20 -0
  9. package/dist/binding/types.d.ts.map +1 -1
  10. package/dist/binding/validation-engine.js +160 -0
  11. package/dist/binding/validation-engine.js.map +1 -0
  12. package/dist/cdn/arethesis.min.js +2 -0
  13. package/dist/cdn/arethesis.min.js.map +1 -0
  14. package/dist/cdn/chunks/CdTL-MEv.min.js +3 -0
  15. package/dist/cdn/chunks/CdTL-MEv.min.js.map +1 -0
  16. package/dist/cdn/components.min.js +81 -0
  17. package/dist/cdn/components.min.js.map +1 -0
  18. package/dist/collab/index.d.ts +22 -0
  19. package/dist/collab/index.d.ts.map +1 -0
  20. package/dist/collab/index.js +23 -0
  21. package/dist/collab/index.js.map +1 -0
  22. package/dist/components/component.d.ts +17 -0
  23. package/dist/components/component.d.ts.map +1 -1
  24. package/dist/components/component.js +765 -0
  25. package/dist/components/component.js.map +1 -0
  26. package/dist/components/decorators.js +27 -0
  27. package/dist/components/decorators.js.map +1 -0
  28. package/dist/components/form-associated.d.ts +55 -0
  29. package/dist/components/form-associated.d.ts.map +1 -0
  30. package/dist/components/form-associated.js +180 -0
  31. package/dist/components/form-associated.js.map +1 -0
  32. package/dist/components/runtime.d.ts +2 -0
  33. package/dist/components/runtime.d.ts.map +1 -1
  34. package/dist/components/runtime.js +18 -0
  35. package/dist/components/runtime.js.map +1 -0
  36. package/dist/components/template-loader.js +90 -0
  37. package/dist/components/template-loader.js.map +1 -0
  38. package/dist/components.js +2 -606
  39. package/dist/core/arethesis.d.ts +13 -9
  40. package/dist/core/arethesis.d.ts.map +1 -1
  41. package/dist/core/arethesis.js +249 -0
  42. package/dist/core/arethesis.js.map +1 -0
  43. package/dist/core/hooks.d.ts +19 -0
  44. package/dist/core/hooks.d.ts.map +1 -0
  45. package/dist/core/hooks.js +23 -0
  46. package/dist/core/hooks.js.map +1 -0
  47. package/dist/core/index.d.ts +57 -0
  48. package/dist/core/index.d.ts.map +1 -0
  49. package/dist/core/index.js +25 -0
  50. package/dist/data/list-view-registry.js +300 -0
  51. package/dist/data/list-view-registry.js.map +1 -0
  52. package/dist/data/object-store.js +280 -0
  53. package/dist/data/object-store.js.map +1 -0
  54. package/dist/data/optimistic-updates.js +168 -0
  55. package/dist/data/optimistic-updates.js.map +1 -0
  56. package/dist/data/persistence-manager.js +233 -0
  57. package/dist/data/persistence-manager.js.map +1 -0
  58. package/dist/defaults.d.ts +1 -0
  59. package/dist/defaults.d.ts.map +1 -0
  60. package/dist/defaults.js +17 -0
  61. package/dist/defaults.js.map +1 -0
  62. package/dist/http/auth-manager.js +260 -0
  63. package/dist/http/auth-manager.js.map +1 -0
  64. package/dist/http/http-client.d.ts +7 -0
  65. package/dist/http/http-client.d.ts.map +1 -1
  66. package/dist/http/http-client.js +501 -0
  67. package/dist/http/http-client.js.map +1 -0
  68. package/dist/http/http-error.js +53 -0
  69. package/dist/http/http-error.js.map +1 -0
  70. package/dist/http/mapping.js +64 -0
  71. package/dist/http/mapping.js.map +1 -0
  72. package/dist/index.d.ts +3 -52
  73. package/dist/index.d.ts.map +1 -1
  74. package/dist/index.js +55 -0
  75. package/dist/kit/calendar.d.ts +43 -0
  76. package/dist/kit/calendar.d.ts.map +1 -0
  77. package/dist/kit/calendar.js +423 -0
  78. package/dist/kit/calendar.js.map +1 -0
  79. package/dist/kit/cell-editor.d.ts +47 -0
  80. package/dist/kit/cell-editor.d.ts.map +1 -0
  81. package/dist/kit/cell-editor.js +191 -0
  82. package/dist/kit/cell-editor.js.map +1 -0
  83. package/dist/kit/chart.d.ts +57 -0
  84. package/dist/kit/chart.d.ts.map +1 -0
  85. package/dist/kit/chart.js +541 -0
  86. package/dist/kit/chart.js.map +1 -0
  87. package/dist/kit/combobox.d.ts +57 -0
  88. package/dist/kit/combobox.d.ts.map +1 -0
  89. package/dist/kit/combobox.js +379 -0
  90. package/dist/kit/combobox.js.map +1 -0
  91. package/dist/kit/command-palette.d.ts +54 -0
  92. package/dist/kit/command-palette.d.ts.map +1 -0
  93. package/dist/kit/command-palette.js +315 -0
  94. package/dist/kit/command-palette.js.map +1 -0
  95. package/dist/kit/data-table.d.ts +17 -1
  96. package/dist/kit/data-table.d.ts.map +1 -1
  97. package/dist/kit/data-table.js +373 -0
  98. package/dist/kit/data-table.js.map +1 -0
  99. package/dist/kit/dialog.d.ts +31 -0
  100. package/dist/kit/dialog.d.ts.map +1 -0
  101. package/dist/kit/dialog.js +157 -0
  102. package/dist/kit/dialog.js.map +1 -0
  103. package/dist/kit/elements/calendar.d.ts +3 -0
  104. package/dist/kit/elements/calendar.d.ts.map +1 -0
  105. package/dist/kit/elements/calendar.js +11 -0
  106. package/dist/kit/elements/calendar.js.map +1 -0
  107. package/dist/kit/elements/chart.d.ts +3 -0
  108. package/dist/kit/elements/chart.d.ts.map +1 -0
  109. package/dist/kit/elements/chart.js +11 -0
  110. package/dist/kit/elements/chart.js.map +1 -0
  111. package/dist/kit/elements/combobox.d.ts +3 -0
  112. package/dist/kit/elements/combobox.d.ts.map +1 -0
  113. package/dist/kit/elements/combobox.js +11 -0
  114. package/dist/kit/elements/combobox.js.map +1 -0
  115. package/dist/kit/elements/command-palette.d.ts +3 -0
  116. package/dist/kit/elements/command-palette.d.ts.map +1 -0
  117. package/dist/kit/elements/command-palette.js +11 -0
  118. package/dist/kit/elements/command-palette.js.map +1 -0
  119. package/dist/kit/elements/data-table.d.ts +3 -0
  120. package/dist/kit/elements/data-table.d.ts.map +1 -0
  121. package/dist/kit/elements/data-table.js +11 -0
  122. package/dist/kit/elements/data-table.js.map +1 -0
  123. package/dist/kit/elements/dialog.d.ts +4 -0
  124. package/dist/kit/elements/dialog.d.ts.map +1 -0
  125. package/dist/kit/elements/dialog.js +11 -0
  126. package/dist/kit/elements/dialog.js.map +1 -0
  127. package/dist/kit/elements/flex-view.d.ts +3 -0
  128. package/dist/kit/elements/flex-view.d.ts.map +1 -0
  129. package/dist/kit/elements/flex-view.js +11 -0
  130. package/dist/kit/elements/flex-view.js.map +1 -0
  131. package/dist/kit/elements/form.d.ts +3 -0
  132. package/dist/kit/elements/form.d.ts.map +1 -0
  133. package/dist/kit/elements/form.js +11 -0
  134. package/dist/kit/elements/form.js.map +1 -0
  135. package/dist/kit/elements/kanban.d.ts +3 -0
  136. package/dist/kit/elements/kanban.d.ts.map +1 -0
  137. package/dist/kit/elements/kanban.js +11 -0
  138. package/dist/kit/elements/kanban.js.map +1 -0
  139. package/dist/kit/elements/list.d.ts +3 -0
  140. package/dist/kit/elements/list.d.ts.map +1 -0
  141. package/dist/kit/elements/list.js +11 -0
  142. package/dist/kit/elements/list.js.map +1 -0
  143. package/dist/kit/elements/markdown-editor.d.ts +3 -0
  144. package/dist/kit/elements/markdown-editor.d.ts.map +1 -0
  145. package/dist/kit/elements/markdown-editor.js +11 -0
  146. package/dist/kit/elements/markdown-editor.js.map +1 -0
  147. package/dist/kit/elements/presence.d.ts +3 -0
  148. package/dist/kit/elements/presence.d.ts.map +1 -0
  149. package/dist/kit/elements/presence.js +11 -0
  150. package/dist/kit/elements/presence.js.map +1 -0
  151. package/dist/kit/elements/sheet.d.ts +3 -0
  152. package/dist/kit/elements/sheet.d.ts.map +1 -0
  153. package/dist/kit/elements/sheet.js +11 -0
  154. package/dist/kit/elements/sheet.js.map +1 -0
  155. package/dist/kit/elements/tabs.d.ts +3 -0
  156. package/dist/kit/elements/tabs.d.ts.map +1 -0
  157. package/dist/kit/elements/tabs.js +11 -0
  158. package/dist/kit/elements/tabs.js.map +1 -0
  159. package/dist/kit/elements/toast.d.ts +4 -0
  160. package/dist/kit/elements/toast.d.ts.map +1 -0
  161. package/dist/kit/elements/toast.js +11 -0
  162. package/dist/kit/elements/toast.js.map +1 -0
  163. package/dist/kit/elements/tree.d.ts +3 -0
  164. package/dist/kit/elements/tree.d.ts.map +1 -0
  165. package/dist/kit/elements/tree.js +11 -0
  166. package/dist/kit/elements/tree.js.map +1 -0
  167. package/dist/kit/flex-view.d.ts +2 -0
  168. package/dist/kit/flex-view.d.ts.map +1 -1
  169. package/dist/kit/flex-view.js +346 -0
  170. package/dist/kit/flex-view.js.map +1 -0
  171. package/dist/kit/form.d.ts +2 -0
  172. package/dist/kit/form.d.ts.map +1 -1
  173. package/dist/kit/form.js +211 -0
  174. package/dist/kit/form.js.map +1 -0
  175. package/dist/kit/index.d.ts +33 -16
  176. package/dist/kit/index.d.ts.map +1 -1
  177. package/dist/kit/index.js +40 -0
  178. package/dist/kit/internal/modal.d.ts +26 -0
  179. package/dist/kit/internal/modal.d.ts.map +1 -0
  180. package/dist/kit/internal/modal.js +59 -0
  181. package/dist/kit/internal/modal.js.map +1 -0
  182. package/dist/kit/kanban.d.ts +73 -0
  183. package/dist/kit/kanban.d.ts.map +1 -0
  184. package/dist/kit/kanban.js +404 -0
  185. package/dist/kit/kanban.js.map +1 -0
  186. package/dist/kit/list.d.ts +4 -0
  187. package/dist/kit/list.d.ts.map +1 -1
  188. package/dist/kit/list.js +106 -0
  189. package/dist/kit/list.js.map +1 -0
  190. package/dist/kit/markdown/highlight.d.ts +29 -0
  191. package/dist/kit/markdown/highlight.d.ts.map +1 -0
  192. package/dist/kit/markdown/highlight.js +106 -0
  193. package/dist/kit/markdown/highlight.js.map +1 -0
  194. package/dist/kit/markdown/render.d.ts +31 -0
  195. package/dist/kit/markdown/render.d.ts.map +1 -0
  196. package/dist/kit/markdown/render.js +260 -0
  197. package/dist/kit/markdown/render.js.map +1 -0
  198. package/dist/kit/markdown-editor.d.ts +54 -0
  199. package/dist/kit/markdown-editor.d.ts.map +1 -0
  200. package/dist/kit/markdown-editor.js +797 -0
  201. package/dist/kit/markdown-editor.js.map +1 -0
  202. package/dist/kit/presence.d.ts +36 -0
  203. package/dist/kit/presence.d.ts.map +1 -0
  204. package/dist/kit/presence.js +262 -0
  205. package/dist/kit/presence.js.map +1 -0
  206. package/dist/kit/sheet/formula.d.ts +106 -0
  207. package/dist/kit/sheet/formula.d.ts.map +1 -0
  208. package/dist/kit/sheet/formula.js +364 -0
  209. package/dist/kit/sheet/formula.js.map +1 -0
  210. package/dist/kit/sheet/model.d.ts +28 -0
  211. package/dist/kit/sheet/model.d.ts.map +1 -0
  212. package/dist/kit/sheet/model.js +136 -0
  213. package/dist/kit/sheet/model.js.map +1 -0
  214. package/dist/kit/sheet/sheet.d.ts +47 -0
  215. package/dist/kit/sheet/sheet.d.ts.map +1 -0
  216. package/dist/kit/sheet/sheet.js +676 -0
  217. package/dist/kit/sheet/sheet.js.map +1 -0
  218. package/dist/kit/tabs.d.ts +17 -0
  219. package/dist/kit/tabs.d.ts.map +1 -0
  220. package/dist/kit/tabs.js +192 -0
  221. package/dist/kit/tabs.js.map +1 -0
  222. package/dist/kit/theme-boot.generated.d.ts +2 -0
  223. package/dist/kit/theme-boot.generated.d.ts.map +1 -1
  224. package/dist/kit/theme-boot.generated.js +8 -0
  225. package/dist/kit/theme-boot.generated.js.map +1 -0
  226. package/dist/kit/theme.d.ts +5 -3
  227. package/dist/kit/theme.d.ts.map +1 -1
  228. package/dist/kit/theme.js +89 -0
  229. package/dist/kit/theme.js.map +1 -0
  230. package/dist/kit/toast.d.ts +46 -0
  231. package/dist/kit/toast.d.ts.map +1 -0
  232. package/dist/kit/toast.js +154 -0
  233. package/dist/kit/toast.js.map +1 -0
  234. package/dist/kit/tree.d.ts +41 -0
  235. package/dist/kit/tree.d.ts.map +1 -0
  236. package/dist/kit/tree.js +422 -0
  237. package/dist/kit/tree.js.map +1 -0
  238. package/dist/mixins/context-menu.d.ts.map +1 -1
  239. package/dist/mixins/context-menu.js +183 -0
  240. package/dist/mixins/context-menu.js.map +1 -0
  241. package/dist/mixins/draggable.d.ts.map +1 -1
  242. package/dist/mixins/draggable.js +140 -0
  243. package/dist/mixins/draggable.js.map +1 -0
  244. package/dist/mixins/dropdown.d.ts.map +1 -1
  245. package/dist/mixins/dropdown.js +216 -0
  246. package/dist/mixins/dropdown.js.map +1 -0
  247. package/dist/mixins/editable.d.ts.map +1 -1
  248. package/dist/mixins/editable.js +175 -0
  249. package/dist/mixins/editable.js.map +1 -0
  250. package/dist/mixins/grid-navigation.d.ts.map +1 -1
  251. package/dist/mixins/grid-navigation.js +194 -0
  252. package/dist/mixins/grid-navigation.js.map +1 -0
  253. package/dist/mixins/index.d.ts +8 -2
  254. package/dist/mixins/index.d.ts.map +1 -1
  255. package/dist/mixins/index.js +38 -0
  256. package/dist/mixins/index.js.map +1 -0
  257. package/dist/mixins/infinite-scroll.d.ts.map +1 -1
  258. package/dist/mixins/infinite-scroll.js +83 -0
  259. package/dist/mixins/infinite-scroll.js.map +1 -0
  260. package/dist/mixins/listbox.d.ts +19 -0
  261. package/dist/mixins/listbox.d.ts.map +1 -0
  262. package/dist/mixins/listbox.js +208 -0
  263. package/dist/mixins/listbox.js.map +1 -0
  264. package/dist/mixins/popup.d.ts +36 -0
  265. package/dist/mixins/popup.d.ts.map +1 -0
  266. package/dist/mixins/popup.js +113 -0
  267. package/dist/mixins/popup.js.map +1 -0
  268. package/dist/mixins/registry.d.ts +6 -0
  269. package/dist/mixins/registry.d.ts.map +1 -1
  270. package/dist/mixins/registry.js +167 -0
  271. package/dist/mixins/registry.js.map +1 -0
  272. package/dist/mixins/resizable.d.ts.map +1 -1
  273. package/dist/mixins/resizable.js +128 -0
  274. package/dist/mixins/resizable.js.map +1 -0
  275. package/dist/mixins/sortable.d.ts.map +1 -1
  276. package/dist/mixins/sortable.js +511 -0
  277. package/dist/mixins/sortable.js.map +1 -0
  278. package/dist/mixins/tooltip.d.ts.map +1 -1
  279. package/dist/mixins/tooltip.js +80 -0
  280. package/dist/mixins/tooltip.js.map +1 -0
  281. package/dist/mixins/utils.js +105 -0
  282. package/dist/mixins/utils.js.map +1 -0
  283. package/dist/plugins/async-validators.js +118 -0
  284. package/dist/plugins/async-validators.js.map +1 -0
  285. package/dist/plugins/builtins.d.ts +1 -1
  286. package/dist/plugins/builtins.d.ts.map +1 -1
  287. package/dist/plugins/builtins.js +20 -0
  288. package/dist/plugins/builtins.js.map +1 -0
  289. package/dist/plugins/date-utils.js +128 -0
  290. package/dist/plugins/date-utils.js.map +1 -0
  291. package/dist/plugins/plugin-manager.d.ts.map +1 -1
  292. package/dist/plugins/plugin-manager.js +99 -0
  293. package/dist/plugins/plugin-manager.js.map +1 -0
  294. package/dist/plugins/rich-text.js +365 -0
  295. package/dist/plugins/rich-text.js.map +1 -0
  296. package/dist/realtime/azure-pubsub-manager.js +273 -0
  297. package/dist/realtime/azure-pubsub-manager.js.map +1 -0
  298. package/dist/realtime/collab/anchors.d.ts +10 -0
  299. package/dist/realtime/collab/anchors.d.ts.map +1 -0
  300. package/dist/realtime/collab/anchors.js +19 -0
  301. package/dist/realtime/collab/anchors.js.map +1 -0
  302. package/dist/realtime/collab/collab-session.d.ts +46 -1
  303. package/dist/realtime/collab/collab-session.d.ts.map +1 -1
  304. package/dist/realtime/collab/collab-session.js +396 -0
  305. package/dist/realtime/collab/collab-session.js.map +1 -0
  306. package/dist/realtime/collab/cursor-overlay.d.ts +10 -0
  307. package/dist/realtime/collab/cursor-overlay.d.ts.map +1 -1
  308. package/dist/realtime/collab/cursor-overlay.js +187 -0
  309. package/dist/realtime/collab/cursor-overlay.js.map +1 -0
  310. package/dist/realtime/collab/textarea-adapter.d.ts +13 -0
  311. package/dist/realtime/collab/textarea-adapter.d.ts.map +1 -1
  312. package/dist/realtime/collab/textarea-adapter.js +125 -0
  313. package/dist/realtime/collab/textarea-adapter.js.map +1 -0
  314. package/dist/realtime/collab/undo-manager.d.ts +44 -0
  315. package/dist/realtime/collab/undo-manager.d.ts.map +1 -0
  316. package/dist/realtime/collab/undo-manager.js +148 -0
  317. package/dist/realtime/collab/undo-manager.js.map +1 -0
  318. package/dist/realtime/index.d.ts +11 -0
  319. package/dist/realtime/index.d.ts.map +1 -0
  320. package/dist/realtime/index.js +22 -0
  321. package/dist/realtime/index.js.map +1 -0
  322. package/dist/realtime/ot/client.d.ts +1 -1
  323. package/dist/realtime/ot/client.d.ts.map +1 -1
  324. package/dist/realtime/ot/client.js +74 -0
  325. package/dist/realtime/ot/client.js.map +1 -0
  326. package/dist/realtime/ot/server.d.ts +13 -1
  327. package/dist/realtime/ot/server.d.ts.map +1 -1
  328. package/dist/realtime/ot/server.js +292 -0
  329. package/dist/realtime/ot/server.js.map +1 -0
  330. package/dist/realtime/ot/text-operation.js +282 -0
  331. package/dist/realtime/ot/text-operation.js.map +1 -0
  332. package/dist/realtime/reconnect.js +58 -0
  333. package/dist/realtime/reconnect.js.map +1 -0
  334. package/dist/realtime/sse-manager.js +172 -0
  335. package/dist/realtime/sse-manager.js.map +1 -0
  336. package/dist/realtime/types.d.ts +29 -1
  337. package/dist/realtime/types.d.ts.map +1 -1
  338. package/dist/realtime/websocket-manager.js +180 -0
  339. package/dist/realtime/websocket-manager.js.map +1 -0
  340. package/dist/theme-polychrome-boot.js +17 -0
  341. package/dist/theme-polychrome.css +310 -0
  342. package/dist/theme.css +490 -1
  343. package/dist/tokens/base.tokens.json +18 -0
  344. package/dist/tokens/dark-high-contrast.tokens.json +11 -0
  345. package/dist/tokens/dark.tokens.json +81 -0
  346. package/dist/tokens/light-high-contrast.tokens.json +11 -0
  347. package/dist/tokens/light.tokens.json +81 -0
  348. package/dist/tokens/polychrome.base.tokens.json +45 -0
  349. package/dist/tokens/polychrome.dark-high-contrast.tokens.json +183 -0
  350. package/dist/tokens/polychrome.dark.tokens.json +321 -0
  351. package/dist/tokens/polychrome.light-high-contrast.tokens.json +115 -0
  352. package/dist/tokens/polychrome.light.tokens.json +418 -0
  353. package/dist/tokens/polychrome.resolver.json +78 -0
  354. package/dist/utils/backoff.js +30 -0
  355. package/dist/utils/backoff.js.map +1 -0
  356. package/dist/utils/dates.js +67 -0
  357. package/dist/utils/dates.js.map +1 -0
  358. package/dist/utils/dom.js +30 -0
  359. package/dist/utils/dom.js.map +1 -0
  360. package/dist/utils/emitter.js +40 -0
  361. package/dist/utils/emitter.js.map +1 -0
  362. package/dist/utils/fuzzy.d.ts +23 -0
  363. package/dist/utils/fuzzy.d.ts.map +1 -0
  364. package/dist/utils/fuzzy.js +95 -0
  365. package/dist/utils/fuzzy.js.map +1 -0
  366. package/dist/utils/path.js +99 -0
  367. package/dist/utils/path.js.map +1 -0
  368. package/dist/utils/sanitize.js +161 -0
  369. package/dist/utils/sanitize.js.map +1 -0
  370. package/dist/utils/url.js +44 -0
  371. package/dist/utils/url.js.map +1 -0
  372. package/dist/utils/virtual-window.d.ts +25 -0
  373. package/dist/utils/virtual-window.d.ts.map +1 -0
  374. package/dist/utils/virtual-window.js +19 -0
  375. package/dist/utils/virtual-window.js.map +1 -0
  376. package/dist/version.d.ts +1 -1
  377. package/dist/version.js +6 -0
  378. package/dist/version.js.map +1 -0
  379. package/package.json +63 -11
  380. package/dist/arethesis-jPH9QdQE.js +0 -5345
  381. package/dist/arethesis-jPH9QdQE.js.map +0 -1
  382. package/dist/arethesis.js.map +0 -1
  383. package/dist/components.js.map +0 -1
@@ -0,0 +1,57 @@
1
+ import { FormAssociatedComponent } from '../components/form-associated';
2
+ import { Params } from '../http/types';
3
+ export interface ComboboxOption {
4
+ value: string;
5
+ label?: string;
6
+ /** Extra text that matches (shown nowhere). */
7
+ keywords?: string;
8
+ disabled?: boolean;
9
+ /** The object it came from, for a search source. */
10
+ data?: unknown;
11
+ }
12
+ export type ComboboxSource = Array<string | ComboboxOption> | ((query: string, signal: AbortSignal) => Promise<Array<string | ComboboxOption | Record<string, unknown>>>) | {
13
+ endpoint: string;
14
+ param?: string;
15
+ params?: Params;
16
+ };
17
+ export interface ComboboxConfig {
18
+ /** Options, a search function, or an endpoint to search. @default the `<option>` children */
19
+ source?: ComboboxSource;
20
+ /** For objects from a search: the field holding the value. @default 'id' */
21
+ valueField?: string;
22
+ /** For objects from a search: the field shown. @default 'name', then 'label', 'title' */
23
+ labelField?: string;
24
+ /** Wait this long after typing before searching. @default 200 (0 for local options) */
25
+ debounce?: number;
26
+ /** Characters needed before searching. @default 1 (0 for local options) */
27
+ minChars?: number;
28
+ /** Accept text that isn't one of the options as the value. @default false */
29
+ allowCustom?: boolean;
30
+ /** Most options shown. @default 50 */
31
+ limit?: number;
32
+ /** Shown when nothing matches. @default 'No matches' */
33
+ emptyText?: string;
34
+ }
35
+ export declare class Combobox extends FormAssociatedComponent<string> {
36
+ #private;
37
+ /** Set the source and options. Can be called before or after it's connected. */
38
+ configure(config: ComboboxConfig): void;
39
+ /** The options currently in the list. */
40
+ get options(): ComboboxOption[];
41
+ /** The text shown for the current value. */
42
+ get label(): string;
43
+ get open(): boolean;
44
+ protected get focusTarget(): HTMLElement;
45
+ protected serialize(value: string): string | null;
46
+ protected parse(state: string): string;
47
+ protected emptyValue(): string;
48
+ protected onConnected(): void;
49
+ protected onDisconnected(): void;
50
+ protected onValueChange(value: string): void;
51
+ protected onDisabledChange(disabled: boolean): void;
52
+ static get observedAttributes(): string[];
53
+ attributeChangedCallback(name: string): void;
54
+ }
55
+ /** Define `<a-combobox>` (idempotent). `import 'arethesis/components/combobox'` calls this. */
56
+ export declare function defineCombobox(): void;
57
+ //# sourceMappingURL=combobox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"combobox.d.ts","sourceRoot":"","sources":["../../src/kit/combobox.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAOxE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAG5C,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,E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S,KAAK,WAAW,IAAI,WAAW,CAEvC;IAED,SAAS,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAIjD,SAAS,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAItC,SAAS,CAAC,UAAU,IAAI,MAAM;cAIX,WAAW,IAAI,IAAI;cAInB,cAAc,IAAI,IAAI;cAKtB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;cAOlC,gBAAgB,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI;IAK5D,MAAM,KAAK,kBAAkB,IAAI,MAAM,EAAE,CAExC;IAED,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;CA4R7C;AAUD,+FAA+F;AAC/F,wBAAgB,cAAc,IAAI,IAAI,CAErC"}
@@ -0,0 +1,379 @@
1
+ import { FormAssociatedComponent } from "../components/form-associated.js";
2
+ import { defineComponent } from "../components/decorators.js";
3
+ import { getRuntime } from "../components/runtime.js";
4
+ import { attachPopup } from "../mixins/popup.js";
5
+ import { announce } from "../mixins/utils.js";
6
+ import { fuzzyFilter, highlightMatch } from "../utils/fuzzy.js";
7
+ import { getPath } from "../utils/path.js";
8
+ import { uniqueId } from "../utils/dom.js";
9
+ // src/kit/combobox.ts
10
+ /**
11
+ * `<a-combobox>`: a text field with a list of suggestions (the WAI-ARIA
12
+ * combobox pattern with list autocomplete). It's a form control: its value is
13
+ * submitted under its `name`, and `required` works as on an input.
14
+ *
15
+ * Options can be written in the markup, so it works before scripts run:
16
+ *
17
+ * ```html
18
+ * <label for="city">City</label>
19
+ * <a-combobox id="city" name="city" required>
20
+ * <option value="ath">Athens</option>
21
+ * <option value="spa">Sparta</option>
22
+ * </a-combobox>
23
+ * ```
24
+ *
25
+ * Or come from a function or an endpoint, searched as you type:
26
+ *
27
+ * ```ts
28
+ * combobox.configure({ source: { endpoint: 'searchPeople', param: 'q' }, valueField: 'id', labelField: 'name' });
29
+ * ```
30
+ *
31
+ * Keys: Down/Up open the list and move through it, Enter picks, Escape closes
32
+ * (and a second Escape clears the text), Alt+Down opens without moving.
33
+ * Typing filters; matched letters are highlighted. Results are announced.
34
+ *
35
+ * Event: `combobox:select` (`{ value, label, data }`), as well as `input` and `change`.
36
+ *
37
+ * @module components/combobox
38
+ */
39
+ var Combobox = class extends FormAssociatedComponent {
40
+ #config = {};
41
+ #input = null;
42
+ #list = null;
43
+ #popup = null;
44
+ #options = [];
45
+ #shown = [];
46
+ #active = -1;
47
+ #label = "";
48
+ #timer = null;
49
+ #search = null;
50
+ #escapes = 0;
51
+ /** Set the source and options. Can be called before or after it's connected. */
52
+ configure(config) {
53
+ this.#config = {
54
+ ...this.#config,
55
+ ...config
56
+ };
57
+ if (Array.isArray(config.source)) this.#options = config.source.map(normalize);
58
+ if (this.#input) this.#syncLabel();
59
+ }
60
+ /** The options currently in the list. */
61
+ get options() {
62
+ return this.#shown.map((s) => s.option);
63
+ }
64
+ /** The text shown for the current value. */
65
+ get label() {
66
+ return this.#label;
67
+ }
68
+ get open() {
69
+ return this.#popup?.isOpen() ?? false;
70
+ }
71
+ get focusTarget() {
72
+ return this.#input;
73
+ }
74
+ serialize(value) {
75
+ return value === "" ? null : value;
76
+ }
77
+ parse(state) {
78
+ return state;
79
+ }
80
+ emptyValue() {
81
+ return "";
82
+ }
83
+ onConnected() {
84
+ if (!this.#input) this.#build();
85
+ }
86
+ onDisconnected() {
87
+ this.#close();
88
+ this.#search?.abort();
89
+ }
90
+ onValueChange(value) {
91
+ if (!this.#input) return;
92
+ const option = this.#find(value);
93
+ this.#label = option ? labelOf(option) : value;
94
+ if (document.activeElement !== this.#input || !this.open) this.#input.value = this.#label;
95
+ }
96
+ onDisabledChange(disabled) {
97
+ if (this.#input) this.#input.disabled = disabled;
98
+ if (disabled) this.#close();
99
+ }
100
+ static get observedAttributes() {
101
+ return ["disabled", "placeholder"];
102
+ }
103
+ attributeChangedCallback(name) {
104
+ if (!this.#input) return;
105
+ if (name === "disabled") this.onDisabledChange(this.disabled);
106
+ if (name === "placeholder") this.#input.placeholder = this.getAttribute("placeholder") ?? "";
107
+ }
108
+ #build() {
109
+ const id = this.id || uniqueId("ar-combobox");
110
+ const markup = Array.from(this.querySelectorAll("option")).map((o) => ({
111
+ value: o.value,
112
+ label: o.textContent?.trim() || o.value,
113
+ disabled: o.disabled
114
+ }));
115
+ if (!this.#config.source && markup.length) this.#options = markup;
116
+ const initial = this.getAttribute("value") ?? this.querySelector("option[selected]")?.value ?? "";
117
+ const input = document.createElement("input");
118
+ input.type = "text";
119
+ input.className = "ar-combobox__input input";
120
+ input.id = `${id}-input`;
121
+ input.autocomplete = "off";
122
+ input.spellcheck = false;
123
+ input.setAttribute("role", "combobox");
124
+ input.setAttribute("aria-autocomplete", "list");
125
+ input.setAttribute("aria-expanded", "false");
126
+ input.setAttribute("aria-controls", `${id}-list`);
127
+ input.placeholder = this.getAttribute("placeholder") ?? "";
128
+ input.disabled = this.disabled;
129
+ const ariaLabel = this.getAttribute("aria-label");
130
+ if (ariaLabel) input.setAttribute("aria-label", ariaLabel);
131
+ if (this.required) input.setAttribute("aria-required", "true");
132
+ const list = document.createElement("ul");
133
+ list.className = "ar-combobox__list";
134
+ list.id = `${id}-list`;
135
+ list.setAttribute("role", "listbox");
136
+ if (ariaLabel) list.setAttribute("aria-label", ariaLabel);
137
+ this.replaceChildren(input, list);
138
+ this.#input = input;
139
+ this.#list = list;
140
+ this.#popup = attachPopup(list, {
141
+ anchor: () => input,
142
+ placement: "bottom",
143
+ gap: 4,
144
+ matchWidth: true
145
+ });
146
+ const signal = this.signal;
147
+ input.addEventListener("input", (e) => {
148
+ e.stopPropagation();
149
+ this.#escapes = 0;
150
+ this.#query(input.value);
151
+ }, { signal });
152
+ input.addEventListener("change", (e) => e.stopPropagation(), { signal });
153
+ input.addEventListener("keydown", (e) => this.#onKey(e), { signal });
154
+ input.addEventListener("blur", () => this.#onBlur(), { signal });
155
+ input.addEventListener("click", () => {
156
+ if (!this.open) this.#query(input.value === this.#label ? "" : input.value);
157
+ }, { signal });
158
+ list.addEventListener("pointerdown", (e) => e.preventDefault(), { signal });
159
+ list.addEventListener("click", (e) => {
160
+ const li = e.target.closest("[role=\"option\"]");
161
+ if (li && li.getAttribute("aria-disabled") !== "true") this.#pick(Number(li.dataset.index));
162
+ }, { signal });
163
+ this.value = initial;
164
+ this.#syncLabel();
165
+ }
166
+ #syncLabel() {
167
+ this.onValueChange(this.value);
168
+ }
169
+ #find(value) {
170
+ return this.#options.find((o) => o.value === value) ?? this.#shown.find((s) => s.option.value === value)?.option;
171
+ }
172
+ #isLocal() {
173
+ return !this.#config.source || Array.isArray(this.#config.source);
174
+ }
175
+ #query(text) {
176
+ if (this.#timer) clearTimeout(this.#timer);
177
+ const local = this.#isLocal();
178
+ const minChars = this.#config.minChars ?? (local ? 0 : 1);
179
+ if (text.trim().length < minChars) {
180
+ this.#search?.abort();
181
+ if (local) this.#show(this.#filter(""));
182
+ else this.#close();
183
+ return;
184
+ }
185
+ if (local) {
186
+ this.#show(this.#filter(text));
187
+ return;
188
+ }
189
+ const delay = this.#config.debounce ?? 200;
190
+ this.#timer = setTimeout(() => void this.#remote(text), delay);
191
+ }
192
+ #filter(text) {
193
+ const limit = this.#config.limit ?? 50;
194
+ if (!text.trim()) return this.#options.slice(0, limit).map((option) => ({ option }));
195
+ return fuzzyFilter(text, this.#options, (o) => [labelOf(o), o.keywords ?? ""]).slice(0, limit).map((r) => ({
196
+ option: r.item,
197
+ indices: r.field === 0 ? r.match.indices : void 0
198
+ }));
199
+ }
200
+ async #remote(text) {
201
+ this.#search?.abort();
202
+ const controller = new AbortController();
203
+ this.#search = controller;
204
+ this.#input?.setAttribute("aria-busy", "true");
205
+ try {
206
+ const source = this.#config.source;
207
+ let items;
208
+ if (typeof source === "function") items = await source(text, controller.signal);
209
+ else {
210
+ const s = source;
211
+ const result = await getRuntime().http.fetchEndpoint(s.endpoint, {
212
+ ...s.params,
213
+ [s.param ?? "q"]: text
214
+ }, { signal: controller.signal });
215
+ items = Array.isArray(result.data) ? result.data : [];
216
+ }
217
+ if (controller.signal.aborted || this.#search !== controller) return;
218
+ this.#options = items.map((item) => this.#toOption(item));
219
+ const limit = this.#config.limit ?? 50;
220
+ this.#show(this.#options.slice(0, limit).map((option) => ({
221
+ option,
222
+ indices: fuzzyFilter(text, [option], labelOf)[0]?.match.indices
223
+ })));
224
+ } catch (error) {
225
+ if (controller.signal.aborted) return;
226
+ this.emit("combobox:error", { error });
227
+ this.#show([]);
228
+ } finally {
229
+ if (this.#search === controller) this.#input?.removeAttribute("aria-busy");
230
+ }
231
+ }
232
+ #toOption(item) {
233
+ if (typeof item === "string") return { value: item };
234
+ const obj = item;
235
+ if (typeof obj.value === "string" && !this.#config.valueField) return normalize(obj);
236
+ const value = getPath(obj, this.#config.valueField ?? "id");
237
+ const labelField = this.#config.labelField;
238
+ const label = labelField ? getPath(obj, labelField) : obj.name ?? obj.label ?? obj.title;
239
+ return {
240
+ value: String(value ?? ""),
241
+ label: label === void 0 ? void 0 : String(label),
242
+ data: item
243
+ };
244
+ }
245
+ #show(results) {
246
+ const list = this.#list;
247
+ this.#shown = results;
248
+ list.replaceChildren();
249
+ results.forEach(({ option, indices }, index) => {
250
+ const li = document.createElement("li");
251
+ li.id = `${list.id}-${index}`;
252
+ li.className = "ar-combobox__option";
253
+ li.setAttribute("role", "option");
254
+ li.dataset.index = String(index);
255
+ li.setAttribute("aria-selected", String(option.value === this.value));
256
+ if (option.disabled) li.setAttribute("aria-disabled", "true");
257
+ li.append(...highlightMatch(labelOf(option), indices));
258
+ list.append(li);
259
+ });
260
+ if (!results.length) {
261
+ const li = document.createElement("li");
262
+ li.className = "ar-combobox__empty";
263
+ li.setAttribute("role", "presentation");
264
+ li.textContent = this.#config.emptyText ?? "No matches";
265
+ list.append(li);
266
+ }
267
+ this.#popup.show();
268
+ this.#input.setAttribute("aria-expanded", "true");
269
+ const selected = results.findIndex((r) => r.option.value === this.value);
270
+ this.#setActive(selected >= 0 && !this.#input.value.trim() ? selected : -1);
271
+ this.#popup.reposition();
272
+ announce(results.length ? `${results.length} ${results.length === 1 ? "result" : "results"}` : this.#config.emptyText ?? "No matches");
273
+ }
274
+ #setActive(index) {
275
+ this.#active = index;
276
+ const items = Array.from(this.#list.querySelectorAll("[role=\"option\"]"));
277
+ items.forEach((li, i) => li.classList.toggle("is-active", i === index));
278
+ if (index >= 0 && items[index]) {
279
+ this.#input.setAttribute("aria-activedescendant", items[index].id);
280
+ items[index].scrollIntoView?.({ block: "nearest" });
281
+ } else this.#input.removeAttribute("aria-activedescendant");
282
+ }
283
+ #move(delta) {
284
+ const n = this.#shown.length;
285
+ if (!n) return;
286
+ let i = this.#active;
287
+ for (let step = 0; step < n; step++) {
288
+ i = i < 0 ? delta > 0 ? 0 : n - 1 : (i + delta + n) % n;
289
+ if (!this.#shown[i].option.disabled) break;
290
+ }
291
+ this.#setActive(i);
292
+ }
293
+ #close() {
294
+ if (this.#timer) clearTimeout(this.#timer);
295
+ this.#popup?.hide();
296
+ this.#input?.setAttribute("aria-expanded", "false");
297
+ this.#input?.removeAttribute("aria-activedescendant");
298
+ this.#active = -1;
299
+ }
300
+ #pick(index) {
301
+ const entry = this.#shown[index];
302
+ if (!entry || entry.option.disabled) return;
303
+ const { option } = entry;
304
+ if (!this.#options.includes(option)) this.#options.push(option);
305
+ this.#close();
306
+ this.#input.value = labelOf(option);
307
+ if (option.value !== this.value) this.commitValue(option.value);
308
+ else this.onValueChange(option.value);
309
+ this.emit("combobox:select", {
310
+ value: option.value,
311
+ label: labelOf(option),
312
+ data: option.data
313
+ });
314
+ }
315
+ #onKey(e) {
316
+ switch (e.key) {
317
+ case "ArrowDown":
318
+ e.preventDefault();
319
+ if (!this.open) {
320
+ this.#query(this.#input.value === this.#label ? "" : this.#input.value);
321
+ if (!e.altKey) this.#move(1);
322
+ } else this.#move(1);
323
+ break;
324
+ case "ArrowUp":
325
+ e.preventDefault();
326
+ if (this.open) this.#move(-1);
327
+ break;
328
+ case "Enter":
329
+ if (this.open && this.#active >= 0) {
330
+ e.preventDefault();
331
+ this.#pick(this.#active);
332
+ } else if (this.#config.allowCustom) this.#commitText();
333
+ break;
334
+ case "Escape":
335
+ if (this.open) {
336
+ e.preventDefault();
337
+ this.#close();
338
+ this.#escapes = 1;
339
+ } else if (this.#escapes >= 1 || !this.#config.allowCustom) {
340
+ this.#input.value = "";
341
+ if (this.value !== "") this.commitValue("");
342
+ this.#escapes = 0;
343
+ }
344
+ break;
345
+ case "Tab": this.#close();
346
+ }
347
+ }
348
+ #onBlur() {
349
+ this.#close();
350
+ this.markTouched();
351
+ const text = this.#input.value.trim();
352
+ if (this.#config.allowCustom) this.#commitText();
353
+ else if (!text) {
354
+ if (this.value !== "") this.commitValue("");
355
+ } else {
356
+ const exact = this.#options.find((o) => labelOf(o).toLowerCase() === text.toLowerCase() && !o.disabled);
357
+ if (exact && exact.value !== this.value) this.commitValue(exact.value);
358
+ this.#input.value = this.#find(this.value) ? labelOf(this.#find(this.value)) : this.value;
359
+ }
360
+ }
361
+ #commitText() {
362
+ const text = this.#input.value.trim();
363
+ const next = this.#options.find((o) => labelOf(o).toLowerCase() === text.toLowerCase())?.value ?? text;
364
+ if (next !== this.value) this.commitValue(next);
365
+ }
366
+ };
367
+ function normalize(option) {
368
+ return typeof option === "string" ? { value: option } : option;
369
+ }
370
+ function labelOf(option) {
371
+ return option.label ?? option.value;
372
+ }
373
+ /** Define `<a-combobox>` (idempotent). `import 'arethesis/components/combobox'` calls this. */
374
+ function defineCombobox() {
375
+ defineComponent({ tag: "a-combobox" })(Combobox);
376
+ }
377
+ export { Combobox, defineCombobox };
378
+
379
+ //# sourceMappingURL=combobox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"combobox.js","names":[],"sources":["../../src/kit/combobox.ts"],"sourcesContent":["/**\n * `<a-combobox>`: a text field with a list of suggestions (the WAI-ARIA\n * combobox pattern with list autocomplete). It's a form control: its value is\n * submitted under its `name`, and `required` works as on an input.\n *\n * Options can be written in the markup, so it works before scripts run:\n *\n * ```html\n * <label for=\"city\">City</label>\n * <a-combobox id=\"city\" name=\"city\" required>\n * <option value=\"ath\">Athens</option>\n * <option value=\"spa\">Sparta</option>\n * </a-combobox>\n * ```\n *\n * Or come from a function or an endpoint, searched as you type:\n *\n * ```ts\n * combobox.configure({ source: { endpoint: 'searchPeople', param: 'q' }, valueField: 'id', labelField: 'name' });\n * ```\n *\n * Keys: Down/Up open the list and move through it, Enter picks, Escape closes\n * (and a second Escape clears the text), Alt+Down opens without moving.\n * Typing filters; matched letters are highlighted. Results are announced.\n *\n * Event: `combobox:select` (`{ value, label, data }`), as well as `input` and `change`.\n *\n * @module components/combobox\n */\n\nimport { FormAssociatedComponent } from '../components/form-associated';\nimport { defineComponent } from '../components/decorators';\nimport { getRuntime } from '../components/runtime';\nimport { attachPopup, type Popup } from '../mixins/popup';\nimport { announce } from '../mixins/utils';\nimport { fuzzyFilter, highlightMatch } from '../utils/fuzzy';\nimport { getPath } from '../utils/path';\nimport type { Params } from '../http/types';\nimport { uniqueId } from '../utils/dom';\n\nexport interface ComboboxOption {\n value: string;\n label?: string;\n /** Extra text that matches (shown nowhere). */\n keywords?: string;\n disabled?: boolean;\n /** The object it came from, for a search source. */\n data?: unknown;\n}\n\nexport type ComboboxSource =\n | Array<string | ComboboxOption>\n | ((query: string, signal: AbortSignal) => Promise<Array<string | ComboboxOption | Record<string, unknown>>>)\n | { endpoint: string; param?: string; params?: Params };\n\nexport interface ComboboxConfig {\n /** Options, a search function, or an endpoint to search. @default the `<option>` children */\n source?: ComboboxSource;\n /** For objects from a search: the field holding the value. @default 'id' */\n valueField?: string;\n /** For objects from a search: the field shown. @default 'name', then 'label', 'title' */\n labelField?: string;\n /** Wait this long after typing before searching. @default 200 (0 for local options) */\n debounce?: number;\n /** Characters needed before searching. @default 1 (0 for local options) */\n minChars?: number;\n /** Accept text that isn't one of the options as the value. @default false */\n allowCustom?: boolean;\n /** Most options shown. @default 50 */\n limit?: number;\n /** Shown when nothing matches. @default 'No matches' */\n emptyText?: string;\n}\n\nexport class Combobox extends FormAssociatedComponent<string> {\n #config: ComboboxConfig = {};\n #input: HTMLInputElement | null = null;\n #list: HTMLUListElement | null = null;\n #popup: Popup | null = null;\n #options: ComboboxOption[] = [];\n #shown: Array<{ option: ComboboxOption; indices?: number[] }> = [];\n #active = -1;\n #label = '';\n #timer: ReturnType<typeof setTimeout> | null = null;\n #search: AbortController | null = null;\n #escapes = 0;\n\n /** Set the source and options. Can be called before or after it's connected. */\n configure(config: ComboboxConfig): void {\n this.#config = { ...this.#config, ...config };\n if (Array.isArray(config.source)) this.#options = config.source.map(normalize);\n if (this.#input) this.#syncLabel();\n }\n\n /** The options currently in the list. */\n get options(): ComboboxOption[] {\n return this.#shown.map(s => s.option);\n }\n\n /** The text shown for the current value. */\n get label(): string {\n return this.#label;\n }\n\n get open(): boolean {\n return this.#popup?.isOpen() ?? false;\n }\n\n protected get focusTarget(): HTMLElement {\n return this.#input!;\n }\n\n protected serialize(value: string): string | null {\n return value === '' ? null : value;\n }\n\n protected parse(state: string): string {\n return state;\n }\n\n protected emptyValue(): string {\n return '';\n }\n\n protected override onConnected(): void {\n if (!this.#input) this.#build();\n }\n\n protected override onDisconnected(): void {\n this.#close();\n this.#search?.abort();\n }\n\n protected override onValueChange(value: string): void {\n if (!this.#input) return;\n const option = this.#find(value);\n this.#label = option ? labelOf(option) : value;\n if (document.activeElement !== this.#input || !this.open) this.#input.value = this.#label;\n }\n\n protected override onDisabledChange(disabled: boolean): void {\n if (this.#input) this.#input.disabled = disabled;\n if (disabled) this.#close();\n }\n\n static get observedAttributes(): string[] {\n return ['disabled', 'placeholder'];\n }\n\n attributeChangedCallback(name: string): void {\n if (!this.#input) return;\n if (name === 'disabled') this.onDisabledChange(this.disabled);\n if (name === 'placeholder') this.#input.placeholder = this.getAttribute('placeholder') ?? '';\n }\n\n // ── Building ─────────────────────────────────────────────────────────────\n\n #build(): void {\n const id = this.id || uniqueId('ar-combobox');\n // Options written in the markup.\n const markup = Array.from(this.querySelectorAll('option')).map(o => ({ value: o.value, label: o.textContent?.trim() || o.value, disabled: o.disabled }));\n if (!this.#config.source && markup.length) this.#options = markup;\n const initial = this.getAttribute('value') ?? this.querySelector<HTMLOptionElement>('option[selected]')?.value ?? '';\n\n const input = document.createElement('input');\n input.type = 'text';\n input.className = 'ar-combobox__input input';\n input.id = `${id}-input`;\n input.autocomplete = 'off';\n input.spellcheck = false;\n input.setAttribute('role', 'combobox');\n input.setAttribute('aria-autocomplete', 'list');\n input.setAttribute('aria-expanded', 'false');\n input.setAttribute('aria-controls', `${id}-list`);\n input.placeholder = this.getAttribute('placeholder') ?? '';\n input.disabled = this.disabled;\n const ariaLabel = this.getAttribute('aria-label');\n if (ariaLabel) input.setAttribute('aria-label', ariaLabel);\n if (this.required) input.setAttribute('aria-required', 'true');\n\n const list = document.createElement('ul');\n list.className = 'ar-combobox__list';\n list.id = `${id}-list`;\n list.setAttribute('role', 'listbox');\n if (ariaLabel) list.setAttribute('aria-label', ariaLabel);\n\n this.replaceChildren(input, list);\n this.#input = input;\n this.#list = list;\n this.#popup = attachPopup(list, { anchor: () => input, placement: 'bottom', gap: 4, matchWidth: true });\n\n const signal = this.signal;\n input.addEventListener('input', e => {\n // The form value only changes on a pick (or on commit with allowCustom).\n e.stopPropagation();\n this.#escapes = 0;\n this.#query(input.value);\n }, { signal });\n // The inner input's own `change` isn't the component's.\n input.addEventListener('change', e => e.stopPropagation(), { signal });\n input.addEventListener('keydown', e => this.#onKey(e), { signal });\n input.addEventListener('blur', () => this.#onBlur(), { signal });\n input.addEventListener('click', () => {\n if (!this.open) this.#query(input.value === this.#label ? '' : input.value);\n }, { signal });\n // Keep focus in the input while picking with the mouse.\n list.addEventListener('pointerdown', e => e.preventDefault(), { signal });\n list.addEventListener('click', e => {\n const li = (e.target as Element).closest<HTMLElement>('[role=\"option\"]');\n if (li && li.getAttribute('aria-disabled') !== 'true') this.#pick(Number(li.dataset.index));\n }, { signal });\n\n this.value = initial;\n this.#syncLabel();\n }\n\n #syncLabel(): void {\n this.onValueChange(this.value);\n }\n\n #find(value: string): ComboboxOption | undefined {\n return this.#options.find(o => o.value === value) ?? this.#shown.find(s => s.option.value === value)?.option;\n }\n\n // ── Searching ────────────────────────────────────────────────────────────\n\n #isLocal(): boolean {\n return !this.#config.source || Array.isArray(this.#config.source);\n }\n\n #query(text: string): void {\n if (this.#timer) clearTimeout(this.#timer);\n const local = this.#isLocal();\n const minChars = this.#config.minChars ?? (local ? 0 : 1);\n if (text.trim().length < minChars) {\n this.#search?.abort();\n if (local) this.#show(this.#filter(''));\n else this.#close();\n return;\n }\n if (local) {\n this.#show(this.#filter(text));\n return;\n }\n const delay = this.#config.debounce ?? 200;\n this.#timer = setTimeout(() => void this.#remote(text), delay);\n }\n\n #filter(text: string): Array<{ option: ComboboxOption; indices?: number[] }> {\n const limit = this.#config.limit ?? 50;\n if (!text.trim()) return this.#options.slice(0, limit).map(option => ({ option }));\n return fuzzyFilter(text, this.#options, o => [labelOf(o), o.keywords ?? ''])\n .slice(0, limit)\n .map(r => ({ option: r.item, indices: r.field === 0 ? r.match.indices : undefined }));\n }\n\n async #remote(text: string): Promise<void> {\n this.#search?.abort();\n const controller = new AbortController();\n this.#search = controller;\n this.#input?.setAttribute('aria-busy', 'true');\n try {\n const source = this.#config.source!;\n let items: unknown[];\n if (typeof source === 'function') {\n items = await source(text, controller.signal);\n } else {\n const s = source as { endpoint: string; param?: string; params?: Params };\n const result = await getRuntime().http.fetchEndpoint<unknown>(s.endpoint, { ...s.params, [s.param ?? 'q']: text }, { signal: controller.signal });\n items = Array.isArray(result.data) ? result.data : [];\n }\n // A newer search started meanwhile: drop these results.\n if (controller.signal.aborted || this.#search !== controller) return;\n this.#options = items.map(item => this.#toOption(item));\n const limit = this.#config.limit ?? 50;\n this.#show(this.#options.slice(0, limit).map(option => ({ option, indices: fuzzyFilter(text, [option], labelOf)[0]?.match.indices })));\n } catch (error) {\n if (controller.signal.aborted) return;\n this.emit('combobox:error', { error });\n this.#show([]);\n } finally {\n if (this.#search === controller) this.#input?.removeAttribute('aria-busy');\n }\n }\n\n #toOption(item: unknown): ComboboxOption {\n if (typeof item === 'string') return { value: item };\n const obj = item as Record<string, unknown>;\n if (typeof obj.value === 'string' && !this.#config.valueField) return normalize(obj as unknown as ComboboxOption);\n const value = getPath(obj, this.#config.valueField ?? 'id');\n const labelField = this.#config.labelField;\n const label = labelField ? getPath(obj, labelField) : obj.name ?? obj.label ?? obj.title;\n return { value: String(value ?? ''), label: label === undefined ? undefined : String(label), data: item };\n }\n\n // ── The list ─────────────────────────────────────────────────────────────\n\n #show(results: Array<{ option: ComboboxOption; indices?: number[] }>): void {\n const list = this.#list!;\n this.#shown = results;\n list.replaceChildren();\n results.forEach(({ option, indices }, index) => {\n const li = document.createElement('li');\n li.id = `${list.id}-${index}`;\n li.className = 'ar-combobox__option';\n li.setAttribute('role', 'option');\n li.dataset.index = String(index);\n li.setAttribute('aria-selected', String(option.value === this.value));\n if (option.disabled) li.setAttribute('aria-disabled', 'true');\n li.append(...highlightMatch(labelOf(option), indices));\n list.append(li);\n });\n if (!results.length) {\n const li = document.createElement('li');\n li.className = 'ar-combobox__empty';\n li.setAttribute('role', 'presentation');\n li.textContent = this.#config.emptyText ?? 'No matches';\n list.append(li);\n }\n this.#popup!.show();\n this.#input!.setAttribute('aria-expanded', 'true');\n const selected = results.findIndex(r => r.option.value === this.value);\n this.#setActive(selected >= 0 && !this.#input!.value.trim() ? selected : -1);\n this.#popup!.reposition();\n announce(results.length ? `${results.length} ${results.length === 1 ? 'result' : 'results'}` : this.#config.emptyText ?? 'No matches');\n }\n\n #setActive(index: number): void {\n this.#active = index;\n const items = Array.from(this.#list!.querySelectorAll<HTMLElement>('[role=\"option\"]'));\n items.forEach((li, i) => li.classList.toggle('is-active', i === index));\n if (index >= 0 && items[index]) {\n this.#input!.setAttribute('aria-activedescendant', items[index].id);\n items[index].scrollIntoView?.({ block: 'nearest' });\n } else {\n this.#input!.removeAttribute('aria-activedescendant');\n }\n }\n\n #move(delta: number): void {\n const n = this.#shown.length;\n if (!n) return;\n let i = this.#active;\n for (let step = 0; step < n; step++) {\n i = i < 0 ? (delta > 0 ? 0 : n - 1) : (i + delta + n) % n;\n if (!this.#shown[i].option.disabled) break;\n }\n this.#setActive(i);\n }\n\n #close(): void {\n if (this.#timer) clearTimeout(this.#timer);\n this.#popup?.hide();\n this.#input?.setAttribute('aria-expanded', 'false');\n this.#input?.removeAttribute('aria-activedescendant');\n this.#active = -1;\n }\n\n #pick(index: number): void {\n const entry = this.#shown[index];\n if (!entry || entry.option.disabled) return;\n const { option } = entry;\n if (!this.#options.includes(option)) this.#options.push(option);\n this.#close();\n this.#input!.value = labelOf(option);\n if (option.value !== this.value) this.commitValue(option.value);\n else this.onValueChange(option.value);\n this.emit('combobox:select', { value: option.value, label: labelOf(option), data: option.data });\n }\n\n #onKey(e: KeyboardEvent): void {\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault();\n if (!this.open) {\n this.#query(this.#input!.value === this.#label ? '' : this.#input!.value);\n if (!e.altKey) this.#move(1);\n } else {\n this.#move(1);\n }\n break;\n case 'ArrowUp':\n e.preventDefault();\n if (this.open) this.#move(-1);\n break;\n case 'Enter':\n if (this.open && this.#active >= 0) {\n e.preventDefault();\n this.#pick(this.#active);\n } else if (this.#config.allowCustom) {\n this.#commitText();\n }\n break;\n case 'Escape':\n if (this.open) {\n e.preventDefault();\n this.#close();\n this.#escapes = 1;\n } else if (this.#escapes >= 1 || !this.#config.allowCustom) {\n // Second Escape: clear.\n this.#input!.value = '';\n if (this.value !== '') this.commitValue('');\n this.#escapes = 0;\n }\n break;\n case 'Tab':\n this.#close();\n break;\n }\n }\n\n #onBlur(): void {\n this.#close();\n this.markTouched();\n const text = this.#input!.value.trim();\n if (this.#config.allowCustom) {\n this.#commitText();\n } else if (!text) {\n if (this.value !== '') this.commitValue('');\n } else {\n // Pick an exact match, or go back to the current value's label.\n const exact = this.#options.find(o => labelOf(o).toLowerCase() === text.toLowerCase() && !o.disabled);\n if (exact && exact.value !== this.value) this.commitValue(exact.value);\n this.#input!.value = this.#find(this.value) ? labelOf(this.#find(this.value)!) : this.value;\n }\n }\n\n #commitText(): void {\n const text = this.#input!.value.trim();\n const exact = this.#options.find(o => labelOf(o).toLowerCase() === text.toLowerCase());\n const next = exact?.value ?? text;\n if (next !== this.value) this.commitValue(next);\n }\n}\n\nfunction normalize(option: string | ComboboxOption): ComboboxOption {\n return typeof option === 'string' ? { value: option } : option;\n}\n\nfunction labelOf(option: ComboboxOption): string {\n return option.label ?? option.value;\n}\n\n/** Define `<a-combobox>` (idempotent). `import 'arethesis/components/combobox'` calls this. */\nexport function defineCombobox(): void {\n defineComponent({ tag: 'a-combobox' })(Combobox);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0EA,IAAa,WAAb,cAA8B,wBAAgC;CAC5D,UAA0B,CAAC;CAC3B,SAAkC;CAClC,QAAiC;CACjC,SAAuB;CACvB,WAA6B,CAAC;CAC9B,SAAgE,CAAC;CACjE,UAAU;CACV,SAAS;CACT,SAA+C;CAC/C,UAAkC;CAClC,WAAW;;CAGX,UAAU,QAA8B;EACtC,KAAK,UAAU;GAAE,GAAG,KAAK;GAAS,GAAG;EAAO;EAC5C,IAAI,MAAM,QAAQ,OAAO,MAAM,GAAG,KAAK,WAAW,OAAO,OAAO,IAAI,SAAS;EAC7E,IAAI,KAAK,QAAQ,KAAK,WAAW;CACnC;;CAGA,IAAI,UAA4B;EAC9B,OAAO,KAAK,OAAO,KAAI,MAAK,EAAE,MAAM;CACtC;;CAGA,IAAI,QAAgB;EAClB,OAAO,KAAK;CACd;CAEA,IAAI,OAAgB;EAClB,OAAO,KAAK,QAAQ,OAAO,KAAK;CAClC;CAEA,IAAc,cAA2B;EACvC,OAAO,KAAK;CACd;CAEA,UAAoB,OAA8B;EAChD,OAAO,UAAU,KAAK,O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ACjB,MAAM,OAAO,KAAK,OAAQ,MAAM,KAAK;EACrC,IAAI,KAAK,QAAQ,aACf,KAAK,YAAY;OACZ,IAAI,CAAC,MACN;OAAA,KAAK,UAAU,IAAI,KAAK,YAAY,EAAE;EAAA,OACrC;GAEL,MAAM,QAAQ,KAAK,SAAS,MAAK,MAAK,QAAQ,CAAC,CAAC,CAAC,YAAY,MAAM,KAAK,YAAY,KAAK,CAAC,EAAE,QAAQ;GACpG,IAAI,SAAS,MAAM,UAAU,KAAK,OAAO,KAAK,YAAY,MAAM,KAAK;GACrE,KAAK,OAAQ,QAAQ,KAAK,MAAM,KAAK,KAAK,IAAI,QAAQ,KAAK,MAAM,KAAK,KAAK,CAAE,IAAI,KAAK;EACxF;CACF;CAEA,cAAoB;EAClB,MAAM,OAAO,KAAK,OAAQ,MAAM,KAAK;EAErC,MAAM,OADQ,KAAK,SAAS,MAAK,MAAK,QAAQ,CAAC,CAAC,CAAC,YAAY,MAAM,KAAK,YAAY,CACvE,CAAA,EAAO,SAAS;EAC7B,IAAI,SAAS,KAAK,OAAO,KAAK,YAAY,IAAI;CAChD;AACF;AAEA,SAAS,UAAU,QAAiD;CAClE,OAAO,OAAO,WAAW,WAAW,EAAE,OAAO,OAAO,IAAI;AAC1D;AAEA,SAAS,QAAQ,QAAgC;CAC/C,OAAO,OAAO,SAAS,OAAO;AAChC;;AAGA,SAAgB,iBAAuB;CACrC,gBAAgB,EAAE,KAAK,aAAa,CAAC,CAAC,CAAC,QAAQ;AACjD"}
@@ -0,0 +1,54 @@
1
+ import { Component } from '../components/component';
2
+ export interface PaletteCommand {
3
+ id: string;
4
+ title: string;
5
+ /** Shown under the title, and searched (with less weight). */
6
+ subtitle?: string;
7
+ /** Other words that should find this command. */
8
+ keywords?: string[];
9
+ /** Shortcut hint, e.g. "Ctrl+Shift+L". */
10
+ shortcut?: string;
11
+ /** A short glyph shown before the title. */
12
+ icon?: string;
13
+ run: () => void | Promise<void>;
14
+ }
15
+ export interface PaletteSource {
16
+ id: string;
17
+ /** Group heading. */
18
+ label: string;
19
+ /** All commands (filtered by the palette). */
20
+ commands?: () => PaletteCommand[];
21
+ /** Or search yourself, for large or remote data: return matches for a query. */
22
+ search?: (query: string) => PaletteCommand[] | Promise<PaletteCommand[]>;
23
+ /** Most items shown from this source. @default 8 */
24
+ limit?: number;
25
+ /** Lower comes first. @default 0 */
26
+ order?: number;
27
+ }
28
+ /** A source that searches objects of one type in the store. */
29
+ export declare function storeSource<T>(options: {
30
+ type: string;
31
+ label: string;
32
+ title: (data: T) => string;
33
+ subtitle?: (data: T) => string;
34
+ icon?: string;
35
+ run: (data: T, id: string) => void;
36
+ limit?: number;
37
+ order?: number;
38
+ }): PaletteSource;
39
+ export declare class CommandPalette extends Component {
40
+ #private;
41
+ static get observedAttributes(): string[];
42
+ attributeChangedCallback(): void;
43
+ /** Add (or replace) a source of commands. Returns a function that removes it. */
44
+ addSource(source: PaletteSource): () => void;
45
+ removeSource(id: string): void;
46
+ get isOpen(): boolean;
47
+ protected onConnected(): void;
48
+ /** Open the palette, optionally with a query. */
49
+ open(query?: string): void;
50
+ close(): void;
51
+ }
52
+ /** Define `<a-command-palette>` (idempotent). `import 'arethesis/components/command-palette'` calls this. */
53
+ export declare function defineCommandPalette(): void;
54
+ //# sourceMappingURL=command-palette.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-palette.d.ts","sourceRoot":"","sources":["../../src/kit/command-palette.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAOpD,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,0CAA0C;IAC1C,QAAQ,CAAC,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