@adia-ai/web-components 0.0.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 (468) hide show
  1. package/README.md +195 -0
  2. package/a2ui/dockables/action.js +152 -0
  3. package/a2ui/dockables/base.js +30 -0
  4. package/a2ui/dockables/controller.js +97 -0
  5. package/a2ui/dockables/data-source.js +103 -0
  6. package/a2ui/dockables/index.js +6 -0
  7. package/a2ui/dockables/lifecycle.js +84 -0
  8. package/a2ui/dockables/provider.js +59 -0
  9. package/a2ui/index.js +19 -0
  10. package/a2ui/manifest-runtime.js +226 -0
  11. package/a2ui/registry.js +200 -0
  12. package/a2ui/renderer.js +361 -0
  13. package/a2ui/root.js +152 -0
  14. package/a2ui/stream.js +243 -0
  15. package/a2ui/surface-manifest.js +294 -0
  16. package/a2ui/surface.js +222 -0
  17. package/a2ui/wire-factory.js +134 -0
  18. package/a2ui/wiring-engine.js +209 -0
  19. package/a2ui/wiring-registry.js +342 -0
  20. package/components/accordion/accordion.a2ui.json +129 -0
  21. package/components/accordion/accordion.css +133 -0
  22. package/components/accordion/accordion.js +125 -0
  23. package/components/accordion/accordion.yaml +527 -0
  24. package/components/action-list/action-list.a2ui.json +64 -0
  25. package/components/action-list/action-list.css +115 -0
  26. package/components/action-list/action-list.js +149 -0
  27. package/components/action-list/action-list.yaml +56 -0
  28. package/components/agent-artifact/agent-artifact.a2ui.json +99 -0
  29. package/components/agent-artifact/agent-artifact.css +94 -0
  30. package/components/agent-artifact/agent-artifact.js +169 -0
  31. package/components/agent-artifact/agent-artifact.yaml +71 -0
  32. package/components/agent-feedback-bar/agent-feedback-bar.a2ui.json +91 -0
  33. package/components/agent-feedback-bar/agent-feedback-bar.css +33 -0
  34. package/components/agent-feedback-bar/agent-feedback-bar.js +152 -0
  35. package/components/agent-feedback-bar/agent-feedback-bar.yaml +65 -0
  36. package/components/agent-questions/agent-questions.a2ui.json +89 -0
  37. package/components/agent-questions/agent-questions.css +146 -0
  38. package/components/agent-questions/agent-questions.js +189 -0
  39. package/components/agent-questions/agent-questions.yaml +63 -0
  40. package/components/agent-reasoning/agent-reasoning.a2ui.json +100 -0
  41. package/components/agent-reasoning/agent-reasoning.css +273 -0
  42. package/components/agent-reasoning/agent-reasoning.js +469 -0
  43. package/components/agent-reasoning/agent-reasoning.yaml +70 -0
  44. package/components/agent-suggestions/agent-suggestions.a2ui.json +87 -0
  45. package/components/agent-suggestions/agent-suggestions.css +18 -0
  46. package/components/agent-suggestions/agent-suggestions.js +87 -0
  47. package/components/agent-suggestions/agent-suggestions.yaml +59 -0
  48. package/components/agent-trace/agent-trace.a2ui.json +78 -0
  49. package/components/agent-trace/agent-trace.css +275 -0
  50. package/components/agent-trace/agent-trace.js +216 -0
  51. package/components/agent-trace/agent-trace.yaml +53 -0
  52. package/components/alert/alert.a2ui.json +211 -0
  53. package/components/alert/alert.css +88 -0
  54. package/components/alert/alert.js +96 -0
  55. package/components/alert/alert.yaml +205 -0
  56. package/components/avatar/avatar.a2ui.json +215 -0
  57. package/components/avatar/avatar.css +159 -0
  58. package/components/avatar/avatar.js +157 -0
  59. package/components/avatar/avatar.yaml +559 -0
  60. package/components/badge/badge.a2ui.json +169 -0
  61. package/components/badge/badge.css +78 -0
  62. package/components/badge/badge.js +53 -0
  63. package/components/badge/badge.yaml +612 -0
  64. package/components/block/block.a2ui.json +135 -0
  65. package/components/block/block.css +29 -0
  66. package/components/block/block.js +23 -0
  67. package/components/block/block.yaml +115 -0
  68. package/components/breadcrumb/breadcrumb.a2ui.json +86 -0
  69. package/components/breadcrumb/breadcrumb.css +78 -0
  70. package/components/breadcrumb/breadcrumb.js +44 -0
  71. package/components/breadcrumb/breadcrumb.yaml +84 -0
  72. package/components/button/button.a2ui.json +172 -0
  73. package/components/button/button.css +168 -0
  74. package/components/button/button.js +60 -0
  75. package/components/button/button.yaml +120 -0
  76. package/components/calendar-picker/calendar-picker.a2ui.json +139 -0
  77. package/components/calendar-picker/calendar-picker.css +321 -0
  78. package/components/calendar-picker/calendar-picker.js +324 -0
  79. package/components/calendar-picker/calendar-picker.yaml +243 -0
  80. package/components/canvas/canvas.a2ui.json +75 -0
  81. package/components/canvas/canvas.css +52 -0
  82. package/components/canvas/canvas.js +179 -0
  83. package/components/canvas/canvas.yaml +62 -0
  84. package/components/card/card.a2ui.json +276 -0
  85. package/components/card/card.css +362 -0
  86. package/components/card/card.js +58 -0
  87. package/components/card/card.yaml +527 -0
  88. package/components/chart/chart.a2ui.json +298 -0
  89. package/components/chart/chart.css +512 -0
  90. package/components/chart/chart.js +1075 -0
  91. package/components/chart/chart.yaml +540 -0
  92. package/components/chat/chat-input.css +141 -0
  93. package/components/chat/chat-input.js +242 -0
  94. package/components/chat/chat.a2ui.json +181 -0
  95. package/components/chat/chat.css +193 -0
  96. package/components/chat/chat.js +155 -0
  97. package/components/chat/chat.yaml +230 -0
  98. package/components/check/check.a2ui.json +134 -0
  99. package/components/check/check.css +126 -0
  100. package/components/check/check.js +58 -0
  101. package/components/check/check.yaml +109 -0
  102. package/components/code/code.a2ui.json +153 -0
  103. package/components/code/code.css +133 -0
  104. package/components/code/code.js +114 -0
  105. package/components/code/code.yaml +163 -0
  106. package/components/col/col.a2ui.json +104 -0
  107. package/components/col/col.css +36 -0
  108. package/components/col/col.js +19 -0
  109. package/components/col/col.yaml +364 -0
  110. package/components/color-picker/color-picker.a2ui.json +100 -0
  111. package/components/color-picker/color-picker.css +182 -0
  112. package/components/color-picker/color-picker.js +537 -0
  113. package/components/color-picker/color-picker.yaml +105 -0
  114. package/components/command/command.a2ui.json +221 -0
  115. package/components/command/command.css +251 -0
  116. package/components/command/command.js +284 -0
  117. package/components/command/command.yaml +186 -0
  118. package/components/description-list/description-list.a2ui.json +89 -0
  119. package/components/description-list/description-list.css +70 -0
  120. package/components/description-list/description-list.js +75 -0
  121. package/components/description-list/description-list.yaml +59 -0
  122. package/components/divider/divider.a2ui.json +126 -0
  123. package/components/divider/divider.css +102 -0
  124. package/components/divider/divider.js +47 -0
  125. package/components/divider/divider.yaml +366 -0
  126. package/components/drawer/drawer.a2ui.json +199 -0
  127. package/components/drawer/drawer.css +342 -0
  128. package/components/drawer/drawer.js +263 -0
  129. package/components/drawer/drawer.yaml +366 -0
  130. package/components/embed/embed.a2ui.json +150 -0
  131. package/components/embed/embed.css +28 -0
  132. package/components/embed/embed.js +63 -0
  133. package/components/embed/embed.yaml +224 -0
  134. package/components/empty-state/empty-state.a2ui.json +133 -0
  135. package/components/empty-state/empty-state.css +58 -0
  136. package/components/empty-state/empty-state.js +87 -0
  137. package/components/empty-state/empty-state.yaml +314 -0
  138. package/components/footer/footer.a2ui.json +79 -0
  139. package/components/footer/footer.yaml +239 -0
  140. package/components/grid/grid.a2ui.json +171 -0
  141. package/components/grid/grid.css +37 -0
  142. package/components/grid/grid.js +21 -0
  143. package/components/grid/grid.yaml +577 -0
  144. package/components/header/header.a2ui.json +76 -0
  145. package/components/header/header.yaml +336 -0
  146. package/components/heatmap/heatmap.a2ui.json +150 -0
  147. package/components/heatmap/heatmap.css +146 -0
  148. package/components/heatmap/heatmap.js +246 -0
  149. package/components/heatmap/heatmap.yaml +131 -0
  150. package/components/icon/icon.a2ui.json +79 -0
  151. package/components/icon/icon.css +20 -0
  152. package/components/icon/icon.js +26 -0
  153. package/components/icon/icon.yaml +233 -0
  154. package/components/image/image.a2ui.json +261 -0
  155. package/components/image/image.css +76 -0
  156. package/components/image/image.js +102 -0
  157. package/components/image/image.yaml +477 -0
  158. package/components/index.js +85 -0
  159. package/components/input/input.a2ui.json +284 -0
  160. package/components/input/input.css +162 -0
  161. package/components/input/input.js +148 -0
  162. package/components/input/input.yaml +496 -0
  163. package/components/inspector/inspector.a2ui.json +67 -0
  164. package/components/inspector/inspector.css +31 -0
  165. package/components/inspector/inspector.js +133 -0
  166. package/components/inspector/inspector.yaml +58 -0
  167. package/components/kbd/kbd.a2ui.json +96 -0
  168. package/components/kbd/kbd.css +62 -0
  169. package/components/kbd/kbd.js +24 -0
  170. package/components/kbd/kbd.yaml +213 -0
  171. package/components/list/list.a2ui.json +145 -0
  172. package/components/list/list.css +103 -0
  173. package/components/list/list.js +236 -0
  174. package/components/list/list.yaml +122 -0
  175. package/components/menu/menu.a2ui.json +146 -0
  176. package/components/menu/menu.css +146 -0
  177. package/components/menu/menu.js +296 -0
  178. package/components/menu/menu.yaml +123 -0
  179. package/components/modal/modal.a2ui.json +136 -0
  180. package/components/modal/modal.css +153 -0
  181. package/components/modal/modal.js +181 -0
  182. package/components/modal/modal.yaml +114 -0
  183. package/components/noodles/noodles.a2ui.json +145 -0
  184. package/components/noodles/noodles.css +118 -0
  185. package/components/noodles/noodles.js +470 -0
  186. package/components/noodles/noodles.yaml +123 -0
  187. package/components/otp-input/otp-input.a2ui.json +104 -0
  188. package/components/otp-input/otp-input.css +78 -0
  189. package/components/otp-input/otp-input.js +170 -0
  190. package/components/otp-input/otp-input.yaml +218 -0
  191. package/components/pagination/pagination.a2ui.json +122 -0
  192. package/components/pagination/pagination.css +162 -0
  193. package/components/pagination/pagination.js +185 -0
  194. package/components/pagination/pagination.yaml +165 -0
  195. package/components/pane/pane.a2ui.json +94 -0
  196. package/components/pane/pane.css +166 -0
  197. package/components/pane/pane.js +140 -0
  198. package/components/pane/pane.yaml +197 -0
  199. package/components/pipeline-status/pipeline-status.a2ui.json +90 -0
  200. package/components/pipeline-status/pipeline-status.css +162 -0
  201. package/components/pipeline-status/pipeline-status.js +176 -0
  202. package/components/pipeline-status/pipeline-status.yaml +99 -0
  203. package/components/popover/popover.a2ui.json +181 -0
  204. package/components/popover/popover.css +57 -0
  205. package/components/popover/popover.js +170 -0
  206. package/components/popover/popover.yaml +257 -0
  207. package/components/progress/progress.a2ui.json +199 -0
  208. package/components/progress/progress.css +88 -0
  209. package/components/progress/progress.js +64 -0
  210. package/components/progress/progress.yaml +342 -0
  211. package/components/progress-row/progress-row.a2ui.json +100 -0
  212. package/components/progress-row/progress-row.css +57 -0
  213. package/components/progress-row/progress-row.js +92 -0
  214. package/components/progress-row/progress-row.yaml +87 -0
  215. package/components/radio/radio.a2ui.json +232 -0
  216. package/components/radio/radio.css +102 -0
  217. package/components/radio/radio.js +73 -0
  218. package/components/radio/radio.yaml +248 -0
  219. package/components/range/range.a2ui.json +151 -0
  220. package/components/range/range.css +148 -0
  221. package/components/range/range.js +177 -0
  222. package/components/range/range.yaml +188 -0
  223. package/components/rating/rating.a2ui.json +105 -0
  224. package/components/rating/rating.css +92 -0
  225. package/components/rating/rating.js +138 -0
  226. package/components/rating/rating.yaml +74 -0
  227. package/components/richtext/richtext.a2ui.json +82 -0
  228. package/components/richtext/richtext.css +225 -0
  229. package/components/richtext/richtext.js +74 -0
  230. package/components/richtext/richtext.yaml +89 -0
  231. package/components/row/row.a2ui.json +102 -0
  232. package/components/row/row.css +51 -0
  233. package/components/row/row.js +39 -0
  234. package/components/row/row.yaml +358 -0
  235. package/components/search/search.a2ui.json +186 -0
  236. package/components/search/search.css +28 -0
  237. package/components/search/search.js +124 -0
  238. package/components/search/search.yaml +154 -0
  239. package/components/section/section.a2ui.json +78 -0
  240. package/components/section/section.yaml +338 -0
  241. package/components/segment/segment.a2ui.json +100 -0
  242. package/components/segment/segment.css +81 -0
  243. package/components/segment/segment.js +32 -0
  244. package/components/segment/segment.yaml +216 -0
  245. package/components/segmented/segmented.a2ui.json +106 -0
  246. package/components/segmented/segmented.css +67 -0
  247. package/components/segmented/segmented.js +149 -0
  248. package/components/segmented/segmented.yaml +91 -0
  249. package/components/select/select.a2ui.json +203 -0
  250. package/components/select/select.css +277 -0
  251. package/components/select/select.js +388 -0
  252. package/components/select/select.yaml +375 -0
  253. package/components/skeleton/skeleton.a2ui.json +120 -0
  254. package/components/skeleton/skeleton.css +47 -0
  255. package/components/skeleton/skeleton.js +43 -0
  256. package/components/skeleton/skeleton.yaml +153 -0
  257. package/components/slider/slider.a2ui.json +162 -0
  258. package/components/slider/slider.css +137 -0
  259. package/components/slider/slider.js +162 -0
  260. package/components/slider/slider.yaml +299 -0
  261. package/components/stack/stack.a2ui.json +62 -0
  262. package/components/stack/stack.css +28 -0
  263. package/components/stack/stack.js +18 -0
  264. package/components/stack/stack.yaml +54 -0
  265. package/components/stat/stat.a2ui.json +246 -0
  266. package/components/stat/stat.css +101 -0
  267. package/components/stat/stat.js +91 -0
  268. package/components/stat/stat.yaml +206 -0
  269. package/components/stepper/stepper.a2ui.json +77 -0
  270. package/components/stepper/stepper.css +243 -0
  271. package/components/stepper/stepper.js +118 -0
  272. package/components/stepper/stepper.yaml +73 -0
  273. package/components/stream/stream.a2ui.json +98 -0
  274. package/components/stream/stream.css +37 -0
  275. package/components/stream/stream.js +99 -0
  276. package/components/stream/stream.yaml +87 -0
  277. package/components/swiper/swiper.a2ui.json +140 -0
  278. package/components/swiper/swiper.css +267 -0
  279. package/components/swiper/swiper.js +285 -0
  280. package/components/swiper/swiper.yaml +268 -0
  281. package/components/switch/switch.a2ui.json +134 -0
  282. package/components/switch/switch.css +104 -0
  283. package/components/switch/switch.js +53 -0
  284. package/components/switch/switch.yaml +322 -0
  285. package/components/table/cell-types.js +296 -0
  286. package/components/table/table.a2ui.json +458 -0
  287. package/components/table/table.css +531 -0
  288. package/components/table/table.js +1392 -0
  289. package/components/table/table.yaml +528 -0
  290. package/components/tabs/tab.js +34 -0
  291. package/components/tabs/tabs.a2ui.json +174 -0
  292. package/components/tabs/tabs.css +162 -0
  293. package/components/tabs/tabs.js +226 -0
  294. package/components/tabs/tabs.yaml +255 -0
  295. package/components/tag/tag.a2ui.json +148 -0
  296. package/components/tag/tag.css +118 -0
  297. package/components/tag/tag.js +88 -0
  298. package/components/tag/tag.yaml +125 -0
  299. package/components/text/text.a2ui.json +99 -0
  300. package/components/text/text.css +65 -0
  301. package/components/text/text.js +35 -0
  302. package/components/text/text.yaml +360 -0
  303. package/components/textarea/textarea.a2ui.json +91 -0
  304. package/components/textarea/textarea.css +93 -0
  305. package/components/textarea/textarea.js +114 -0
  306. package/components/textarea/textarea.yaml +79 -0
  307. package/components/timeline/timeline.a2ui.json +82 -0
  308. package/components/timeline/timeline.css +389 -0
  309. package/components/timeline/timeline.js +171 -0
  310. package/components/timeline/timeline.yaml +185 -0
  311. package/components/toast/toast.a2ui.json +199 -0
  312. package/components/toast/toast.css +211 -0
  313. package/components/toast/toast.js +146 -0
  314. package/components/toast/toast.yaml +184 -0
  315. package/components/toggle-group/toggle-group.a2ui.json +126 -0
  316. package/components/toggle-group/toggle-group.css +102 -0
  317. package/components/toggle-group/toggle-group.js +147 -0
  318. package/components/toggle-group/toggle-group.yaml +98 -0
  319. package/components/toolbar/toolbar.a2ui.json +131 -0
  320. package/components/toolbar/toolbar.css +132 -0
  321. package/components/toolbar/toolbar.js +366 -0
  322. package/components/toolbar/toolbar.yaml +238 -0
  323. package/components/tooltip/tooltip.a2ui.json +148 -0
  324. package/components/tooltip/tooltip.css +39 -0
  325. package/components/tooltip/tooltip.js +96 -0
  326. package/components/tooltip/tooltip.yaml +201 -0
  327. package/components/tree/tree.a2ui.json +119 -0
  328. package/components/tree/tree.css +133 -0
  329. package/components/tree/tree.js +253 -0
  330. package/components/tree/tree.yaml +92 -0
  331. package/components/upload/upload.a2ui.json +185 -0
  332. package/components/upload/upload.css +115 -0
  333. package/components/upload/upload.js +189 -0
  334. package/components/upload/upload.yaml +302 -0
  335. package/core/anchor.js +187 -0
  336. package/core/controller.js +182 -0
  337. package/core/element.js +257 -0
  338. package/core/form.js +217 -0
  339. package/core/icons.js +180 -0
  340. package/core/markdown.js +95 -0
  341. package/core/polyfills.js +23 -0
  342. package/core/provider.js +262 -0
  343. package/core/signals.js +113 -0
  344. package/core/template.js +226 -0
  345. package/core/transport.js +77 -0
  346. package/package.json +38 -0
  347. package/patterns/adia-chat/adia-chat.a2ui.json +149 -0
  348. package/patterns/adia-chat/adia-chat.css +10 -0
  349. package/patterns/adia-chat/adia-chat.js +297 -0
  350. package/patterns/adia-chat/adia-chat.yaml +118 -0
  351. package/patterns/adia-chat/css/adia-chat.empty.css +12 -0
  352. package/patterns/adia-chat/css/adia-chat.layout.css +60 -0
  353. package/patterns/adia-chat/css/adia-chat.markdown.css +74 -0
  354. package/patterns/adia-chat/css/adia-chat.messages.css +87 -0
  355. package/patterns/adia-chat/css/adia-chat.streaming.css +30 -0
  356. package/patterns/adia-chat/css/adia-chat.tokens.css +95 -0
  357. package/patterns/adia-chat/index.html +93 -0
  358. package/patterns/adia-editor/adia-editor.a2ui.json +58 -0
  359. package/patterns/adia-editor/adia-editor.css +6 -0
  360. package/patterns/adia-editor/adia-editor.js +56 -0
  361. package/patterns/adia-editor/adia-editor.yaml +36 -0
  362. package/patterns/adia-editor/css/adia-editor.layout.css +86 -0
  363. package/patterns/adia-editor/css/adia-editor.tokens.css +28 -0
  364. package/patterns/adia-editor/index.html +179 -0
  365. package/patterns/app-nav/app-nav.a2ui.json +89 -0
  366. package/patterns/app-nav/app-nav.css +92 -0
  367. package/patterns/app-nav/app-nav.js +99 -0
  368. package/patterns/app-nav/app-nav.yaml +54 -0
  369. package/patterns/app-nav-group/app-nav-group.a2ui.json +82 -0
  370. package/patterns/app-nav-group/app-nav-group.css +261 -0
  371. package/patterns/app-nav-group/app-nav-group.js +116 -0
  372. package/patterns/app-nav-group/app-nav-group.yaml +59 -0
  373. package/patterns/app-nav-item/app-nav-item.a2ui.json +83 -0
  374. package/patterns/app-nav-item/app-nav-item.css +156 -0
  375. package/patterns/app-nav-item/app-nav-item.js +42 -0
  376. package/patterns/app-nav-item/app-nav-item.yaml +62 -0
  377. package/patterns/app-shell/app-shell.a2ui.json +114 -0
  378. package/patterns/app-shell/app-shell.css +14 -0
  379. package/patterns/app-shell/app-shell.js +251 -0
  380. package/patterns/app-shell/app-shell.yaml +66 -0
  381. package/patterns/app-shell/css/app-shell.collapsed.css +86 -0
  382. package/patterns/app-shell/css/app-shell.helpers.css +42 -0
  383. package/patterns/app-shell/css/app-shell.main.css +58 -0
  384. package/patterns/app-shell/css/app-shell.shell.css +44 -0
  385. package/patterns/app-shell/css/app-shell.sidebar.css +116 -0
  386. package/patterns/app-shell/css/app-shell.templates.css +214 -0
  387. package/patterns/app-shell/css/app-shell.tokens.css +116 -0
  388. package/patterns/app-shell/index.html +112 -0
  389. package/patterns/gen-ui/gen-ui.a2ui.json +72 -0
  390. package/patterns/gen-ui/gen-ui.css +83 -0
  391. package/patterns/gen-ui/gen-ui.js +136 -0
  392. package/patterns/gen-ui/gen-ui.yaml +43 -0
  393. package/patterns/index.js +10 -0
  394. package/patterns/section-nav/section-nav.a2ui.json +91 -0
  395. package/patterns/section-nav/section-nav.css +59 -0
  396. package/patterns/section-nav/section-nav.js +42 -0
  397. package/patterns/section-nav/section-nav.yaml +58 -0
  398. package/patterns/section-nav-group/section-nav-group.a2ui.json +95 -0
  399. package/patterns/section-nav-group/section-nav-group.css +74 -0
  400. package/patterns/section-nav-group/section-nav-group.js +84 -0
  401. package/patterns/section-nav-group/section-nav-group.yaml +66 -0
  402. package/patterns/section-nav-item/section-nav-item.a2ui.json +97 -0
  403. package/patterns/section-nav-item/section-nav-item.css +96 -0
  404. package/patterns/section-nav-item/section-nav-item.js +66 -0
  405. package/patterns/section-nav-item/section-nav-item.yaml +70 -0
  406. package/styles/colors/index.css +6 -0
  407. package/styles/colors/parameters.css +52 -0
  408. package/styles/colors/primitives-accent.css +89 -0
  409. package/styles/colors/primitives-brand.css +89 -0
  410. package/styles/colors/primitives-danger.css +89 -0
  411. package/styles/colors/primitives-info.css +89 -0
  412. package/styles/colors/primitives-neutral.css +91 -0
  413. package/styles/colors/primitives-shared.css +57 -0
  414. package/styles/colors/primitives-success.css +89 -0
  415. package/styles/colors/primitives-warning.css +89 -0
  416. package/styles/colors/primitives.css +17 -0
  417. package/styles/colors/scrims.css +182 -0
  418. package/styles/colors/semantics.css +595 -0
  419. package/styles/colors/surfaces.css +43 -0
  420. package/styles/fonts.css +99 -0
  421. package/styles/layouts/admin.css +7 -0
  422. package/styles/prose.css +186 -0
  423. package/styles/styles.css +193 -0
  424. package/styles/themes.css +155 -0
  425. package/styles/tokens.css +304 -0
  426. package/styles/typography.css +853 -0
  427. package/traits/active-state.js +24 -0
  428. package/traits/anchor-positioning.js +66 -0
  429. package/traits/attention-pulse.js +30 -0
  430. package/traits/confetti-burst.js +65 -0
  431. package/traits/confetti.js +57 -0
  432. package/traits/count-up.js +42 -0
  433. package/traits/define.js +76 -0
  434. package/traits/dirty-state.js +38 -0
  435. package/traits/drag-ghost.js +38 -0
  436. package/traits/draggable.js +73 -0
  437. package/traits/fade-presence.js +52 -0
  438. package/traits/focus-trap.js +63 -0
  439. package/traits/focusable.js +38 -0
  440. package/traits/glow-focus.js +33 -0
  441. package/traits/gradient-shift.js +32 -0
  442. package/traits/haptic-feedback.js +28 -0
  443. package/traits/hotkey.js +62 -0
  444. package/traits/hoverable.js +26 -0
  445. package/traits/index.js +55 -0
  446. package/traits/inertia-drag.js +133 -0
  447. package/traits/intersection-observer.js +33 -0
  448. package/traits/keyboard-nav.js +36 -0
  449. package/traits/magnetic-hover.js +37 -0
  450. package/traits/noise-texture.js +30 -0
  451. package/traits/parallax.js +42 -0
  452. package/traits/portal.js +27 -0
  453. package/traits/pressable.js +75 -0
  454. package/traits/resizable.js +100 -0
  455. package/traits/resize-observer.js +31 -0
  456. package/traits/ripple.js +53 -0
  457. package/traits/roving-tabindex.js +67 -0
  458. package/traits/scale-press.js +43 -0
  459. package/traits/scroll-lock.js +27 -0
  460. package/traits/shimmer-loading.js +44 -0
  461. package/traits/snap-to-grid.js +28 -0
  462. package/traits/sound-feedback.js +30 -0
  463. package/traits/spring-animate.js +56 -0
  464. package/traits/tilt-hover.js +37 -0
  465. package/traits/tossable.js +178 -0
  466. package/traits/typeahead.js +63 -0
  467. package/traits/typewriter.js +35 -0
  468. package/traits/validation.js +118 -0
@@ -0,0 +1,177 @@
1
+ /**
2
+ * <range-input label="Width" value="63" min="0" max="100" step="1" suffix="rem"></range-input>
3
+ *
4
+ * A draggable numeric field — NOT a slider. The entire field is the scrubber surface.
5
+ * Horizontal drag on the value changes it. No track, no thumb.
6
+ *
7
+ * Layout: [label] [value] [suffix]
8
+ * - Label left-aligned, muted
9
+ * - Value right-aligned, bold, editable via horizontal drag
10
+ * - Suffix after value, muted
11
+ * - While dragging: accent highlight on the field
12
+ */
13
+
14
+ import { AdiaFormElement } from '@core/form.js';
15
+
16
+ class AdiaRange extends AdiaFormElement {
17
+ static properties = {
18
+ ...AdiaFormElement.properties,
19
+ /** value: Number — overrides AdiaFormElement.value (String); syncs as string on form submit. */
20
+ value: { type: Number, default: 0, reflect: true },
21
+ min: { type: Number, default: 0, reflect: true },
22
+ max: { type: Number, default: 100, reflect: true },
23
+ step: { type: Number, default: 1, reflect: true },
24
+ label: { type: String, default: '', reflect: true },
25
+ suffix: { type: String, default: '', reflect: true },
26
+ };
27
+
28
+ static template = () => null;
29
+
30
+ #fieldEl = null;
31
+ #valueEl = null;
32
+ #dragging = false;
33
+ #startX = 0;
34
+ #startVal = 0;
35
+
36
+ connected() {
37
+ super.connected();
38
+ this.setAttribute('role', 'spinbutton');
39
+ this.setAttribute('tabindex', '0');
40
+
41
+ if (!this.querySelector('[slot="field"]')) {
42
+ const inner = `
43
+ <span slot="label">${this.label}</span>
44
+ <span slot="value">${this.#format(this.value)}</span>
45
+ ${this.suffix ? `<span slot="suffix">${this.suffix}</span>` : ''}
46
+ `;
47
+ this.innerHTML = `
48
+ <div slot="field">
49
+ <div slot="layer" data-layer="base">${inner}</div>
50
+ <div slot="layer" data-layer="fill" aria-hidden="true">${inner}</div>
51
+ </div>
52
+ `;
53
+ }
54
+
55
+ this.#fieldEl = this.querySelector('[slot="field"]');
56
+ this.#valueEl = this.querySelector('[data-layer="base"] [slot="value"]');
57
+
58
+ if (this.#fieldEl) this.#fieldEl.addEventListener('pointerdown', this.#onPointerDown);
59
+ this.addEventListener('keydown', this.#onKey);
60
+ }
61
+
62
+ render() {
63
+ if (!this.#fieldEl) return;
64
+
65
+ const formatted = this.#format(this.value);
66
+ if (this.#valueEl) this.#valueEl.textContent = formatted;
67
+ const fillValueEl = this.querySelector('[data-layer="fill"] [slot="value"]');
68
+ if (fillValueEl) fillValueEl.textContent = formatted;
69
+
70
+ // Update fill percentage via CSS var (drives clip-path on fill layer)
71
+ const range = this.max - this.min;
72
+ const pct = range > 0 ? ((this.value - this.min) / range) * 100 : 0;
73
+ this.style.setProperty('--range-fill-pct', `${pct}%`);
74
+
75
+ this.setAttribute('aria-valuemin', this.min);
76
+ this.setAttribute('aria-valuemax', this.max);
77
+ this.setAttribute('aria-valuenow', this.value);
78
+ this.setAttribute('aria-valuetext', `${this.value}${this.suffix ? ' ' + this.suffix : ''}`);
79
+ this.setAttribute('aria-label', this.label || '');
80
+
81
+ this.syncValue(String(this.value));
82
+ }
83
+
84
+ #format(v) {
85
+ // Show decimal places matching step precision
86
+ const decimals = (String(this.step).split('.')[1] || '').length;
87
+ return decimals > 0 ? v.toFixed(decimals) : String(v);
88
+ }
89
+
90
+ #snap(raw) {
91
+ const stepped = Math.round((raw - this.min) / this.step) * this.step + this.min;
92
+ return Math.max(this.min, Math.min(this.max, parseFloat(stepped.toFixed(10))));
93
+ }
94
+
95
+ #setValue(v) {
96
+ const snapped = this.#snap(v);
97
+ if (snapped === this.value) return;
98
+ this.value = snapped;
99
+ this.dispatchEvent(new Event('input', { bubbles: true }));
100
+ }
101
+
102
+ // ── Pointer drag ──
103
+
104
+ #valueFromX(clientX) {
105
+ const rect = this.#fieldEl.getBoundingClientRect();
106
+ const ratio = Math.max(0, Math.min(1, (clientX - rect.left) / rect.width));
107
+ return this.#snap(this.min + ratio * (this.max - this.min));
108
+ }
109
+
110
+ #onPointerDown = (e) => {
111
+ if (this.disabled) return;
112
+ e.preventDefault();
113
+
114
+ // Click: jump to position immediately
115
+ this.#setValue(this.#valueFromX(e.clientX));
116
+
117
+ // Then start drag from that position
118
+ this.#dragging = true;
119
+ this.#startX = e.clientX;
120
+ this.#startVal = this.value;
121
+ this.setAttribute('data-dragging', '');
122
+ this.#fieldEl.setPointerCapture(e.pointerId);
123
+ this.#fieldEl.addEventListener('pointermove', this.#onPointerMove);
124
+ this.#fieldEl.addEventListener('pointerup', this.#onPointerUp);
125
+ };
126
+
127
+ #onPointerMove = (e) => {
128
+ if (!this.#dragging) return;
129
+ const dx = e.clientX - this.#startX;
130
+ // 1:1 — dragging across the full field width traverses the full range
131
+ const fieldWidth = this.#fieldEl.getBoundingClientRect().width;
132
+ const range = this.max - this.min;
133
+ const delta = (dx / fieldWidth) * range;
134
+ this.#setValue(this.#startVal + delta);
135
+ };
136
+
137
+ #onPointerUp = (e) => {
138
+ this.#dragging = false;
139
+ this.removeAttribute('data-dragging');
140
+ this.#fieldEl.releasePointerCapture(e.pointerId);
141
+ this.#fieldEl.removeEventListener('pointermove', this.#onPointerMove);
142
+ this.#fieldEl.removeEventListener('pointerup', this.#onPointerUp);
143
+ this.dispatchEvent(new Event('change', { bubbles: true }));
144
+ };
145
+
146
+ // ── Keyboard ──
147
+
148
+ #onKey = (e) => {
149
+ if (this.disabled) return;
150
+ let v = this.value;
151
+ switch (e.key) {
152
+ case 'ArrowRight': case 'ArrowUp': v += this.step; break;
153
+ case 'ArrowLeft': case 'ArrowDown': v -= this.step; break;
154
+ case 'Home': v = this.min; break;
155
+ case 'End': v = this.max; break;
156
+ case 'PageUp': v += this.step * 10; break;
157
+ case 'PageDown': v -= this.step * 10; break;
158
+ default: return;
159
+ }
160
+ e.preventDefault();
161
+ this.#setValue(v);
162
+ this.dispatchEvent(new Event('change', { bubbles: true }));
163
+ };
164
+
165
+ disconnected() {
166
+ super.disconnected();
167
+ this.#fieldEl?.removeEventListener('pointerdown', this.#onPointerDown);
168
+ this.#fieldEl?.removeEventListener('pointermove', this.#onPointerMove);
169
+ this.#fieldEl?.removeEventListener('pointerup', this.#onPointerUp);
170
+ this.removeEventListener('keydown', this.#onKey);
171
+ this.#fieldEl = null;
172
+ this.#valueEl = null;
173
+ }
174
+ }
175
+ customElements.define('range-ui', AdiaRange);
176
+
177
+ export { AdiaRange };
@@ -0,0 +1,188 @@
1
+ # Generated by scripts/migrate-yamls-to-v1.mjs — migrated to v1 contract.
2
+ # Edit this file; run `npm run build:components` to regenerate a2ui.json.
3
+ $schema: ../../../../scripts/schemas/component.yaml.schema.json
4
+ name: AdiaRange
5
+ tag: range-ui
6
+ component: Range
7
+ category: input
8
+ version: 1
9
+ description: Draggable numeric field — horizontal drag on the value changes it. No track/thumb, the
10
+ entire field is the scrubber. Form-associated.
11
+ props:
12
+ name:
13
+ description: Form field name
14
+ type: string
15
+ default: ""
16
+ required:
17
+ description: Required for validation
18
+ type: boolean
19
+ default: false
20
+ reflect: true
21
+ disabled:
22
+ description: Disables interaction
23
+ type: boolean
24
+ default: false
25
+ reflect: true
26
+ error:
27
+ description: Validation error
28
+ type: string
29
+ default: ""
30
+ label:
31
+ description: Left-aligned label text
32
+ type: string
33
+ default: ""
34
+ max:
35
+ description: Maximum value
36
+ type: number
37
+ default: 100
38
+ min:
39
+ description: Minimum value
40
+ type: number
41
+ default: 0
42
+ step:
43
+ description: Step increment
44
+ type: number
45
+ default: 1
46
+ suffix:
47
+ description: Unit suffix after value (px, rem, %)
48
+ type: string
49
+ default: ""
50
+ value:
51
+ description: Current numeric value
52
+ type: number
53
+ default: 0
54
+ events:
55
+ change:
56
+ description: Fired on drag end or keyboard commit
57
+ input:
58
+ description: Fired on each value change during drag or keyboard
59
+ slots: {}
60
+ states:
61
+ - name: idle
62
+ description: Default, ready for interaction.
63
+ - name: disabled
64
+ description: Non-interactive; dimmed.
65
+ attribute: disabled
66
+ traits: []
67
+ tokens:
68
+ --range-background:
69
+ description: Field background
70
+ --range-border-color:
71
+ description: Border color
72
+ --range-fill-background:
73
+ description: Fill bar background
74
+ --range-height:
75
+ description: Field height
76
+ --range-label-color:
77
+ description: Label text color
78
+ --range-radius:
79
+ description: Border radius
80
+ --range-value-color:
81
+ description: Value text color
82
+ a2ui:
83
+ rules: []
84
+ anti_patterns: []
85
+ examples:
86
+ - name: price-range-filter
87
+ description: E-commerce price range filter with range slider, min/max number inputs, and apply button.
88
+ a2ui: >-
89
+ [
90
+ {
91
+ "id": "root",
92
+ "component": "Card",
93
+ "children": [
94
+ "hdr",
95
+ "sec"
96
+ ]
97
+ },
98
+ {
99
+ "id": "hdr",
100
+ "component": "Header",
101
+ "children": [
102
+ "title"
103
+ ]
104
+ },
105
+ {
106
+ "id": "title",
107
+ "component": "Text",
108
+ "slot": "heading",
109
+ "textContent": "Price Range",
110
+ "variant": "section"
111
+ },
112
+ {
113
+ "id": "sec",
114
+ "component": "Section",
115
+ "children": [
116
+ "fields"
117
+ ]
118
+ },
119
+ {
120
+ "id": "fields",
121
+ "component": "Column",
122
+ "children": [
123
+ "range",
124
+ "inputs-row",
125
+ "apply-btn"
126
+ ],
127
+ "gap": "4"
128
+ },
129
+ {
130
+ "id": "range",
131
+ "component": "Range",
132
+ "min": 0,
133
+ "max": 1000,
134
+ "name": "priceRange"
135
+ },
136
+ {
137
+ "id": "inputs-row",
138
+ "component": "Row",
139
+ "children": [
140
+ "min-input",
141
+ "separator",
142
+ "max-input"
143
+ ],
144
+ "gap": "3"
145
+ },
146
+ {
147
+ "id": "min-input",
148
+ "component": "Input",
149
+ "label": "Min",
150
+ "type": "number",
151
+ "name": "minPrice",
152
+ "placeholder": "0"
153
+ },
154
+ {
155
+ "id": "separator",
156
+ "component": "Text",
157
+ "variant": "body",
158
+ "textContent": "to"
159
+ },
160
+ {
161
+ "id": "max-input",
162
+ "component": "Input",
163
+ "label": "Max",
164
+ "type": "number",
165
+ "name": "maxPrice",
166
+ "placeholder": "1000"
167
+ },
168
+ {
169
+ "id": "apply-btn",
170
+ "component": "Button",
171
+ "text": "Apply Filter",
172
+ "variant": "primary"
173
+ }
174
+ ]
175
+ keywords:
176
+ - range
177
+ - volume
178
+ synonyms:
179
+ range:
180
+ - slider
181
+ - range
182
+ volume:
183
+ - slider
184
+ - range
185
+ - music
186
+ related:
187
+ - input
188
+ - button
@@ -0,0 +1,105 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://adiaui.dev/a2ui/v0_9/components/Rating.json",
4
+ "title": "Rating",
5
+ "description": "Pictorial discrete rating (stars by default) with optional half-step precision. Supports keyboard, mouse hover preview, and form participation.",
6
+ "type": "object",
7
+ "allOf": [
8
+ {
9
+ "$ref": "common_types.json#/$defs/ComponentCommon"
10
+ },
11
+ {
12
+ "$ref": "common_types.json#/$defs/CatalogComponentCommon"
13
+ }
14
+ ],
15
+ "properties": {
16
+ "allowHalf": {
17
+ "description": "Enable 0.5-step precision on click/hover",
18
+ "type": "boolean",
19
+ "default": false
20
+ },
21
+ "component": {
22
+ "const": "Rating"
23
+ },
24
+ "icon": {
25
+ "description": "Phosphor icon name for each symbol (e.g. star, heart, thumbs-up)",
26
+ "type": "string",
27
+ "default": "star"
28
+ },
29
+ "max": {
30
+ "description": "Number of rating symbols",
31
+ "type": "number",
32
+ "default": 5
33
+ },
34
+ "name": {
35
+ "description": "Form participation — field name when submitted",
36
+ "type": "string",
37
+ "default": ""
38
+ },
39
+ "readonly": {
40
+ "description": "Display-only — disables interaction but remains readable",
41
+ "type": "boolean",
42
+ "default": false
43
+ },
44
+ "size": {
45
+ "description": "Symbol size",
46
+ "type": "string",
47
+ "enum": [
48
+ "sm",
49
+ "md",
50
+ "lg"
51
+ ],
52
+ "default": "md"
53
+ },
54
+ "value": {
55
+ "description": "Current rating value (0..max, supports 0.5 steps when allowHalf)",
56
+ "type": "number",
57
+ "default": 0
58
+ }
59
+ },
60
+ "required": [
61
+ "component"
62
+ ],
63
+ "unevaluatedProperties": false,
64
+ "x-adiaui": {
65
+ "anti_patterns": [],
66
+ "category": "form",
67
+ "events": {
68
+ "[object Object]": {
69
+ "description": "Fired on [object Object]."
70
+ }
71
+ },
72
+ "examples": [],
73
+ "keywords": [
74
+ "rating",
75
+ "stars",
76
+ "review",
77
+ "feedback",
78
+ "score",
79
+ "vote",
80
+ "heart",
81
+ "like"
82
+ ],
83
+ "name": "AdiaRating",
84
+ "related": [],
85
+ "slots": {},
86
+ "states": [
87
+ {
88
+ "description": "Default, ready for interaction.",
89
+ "name": "idle"
90
+ }
91
+ ],
92
+ "synonyms": {
93
+ "rating": [
94
+ "rating",
95
+ "star rating",
96
+ "review score",
97
+ "feedback rating"
98
+ ]
99
+ },
100
+ "tag": "rating-ui",
101
+ "tokens": {},
102
+ "traits": [],
103
+ "version": 1
104
+ }
105
+ }
@@ -0,0 +1,92 @@
1
+ @scope (rating-ui) {
2
+ :where(:scope) {
3
+ /* ── Layout ── */
4
+ --rating-gap: var(--a-space-1);
5
+ --rating-symbol-size: var(--a-space-5);
6
+
7
+ /* ── Colors ── */
8
+ --rating-fg-empty: var(--a-fg-muted);
9
+ --rating-fg-filled: var(--a-fg-strong);
10
+ --rating-fg-hover: var(--a-fg-strong);
11
+
12
+ /* ── Interaction ── */
13
+ --rating-duration: var(--a-duration-fast);
14
+ --rating-easing: var(--a-easing);
15
+ --rating-focus-ring: 0 0 0 2px var(--a-focus-ring);
16
+ --rating-focus-offset: var(--a-space-1);
17
+ --rating-focus-radius: var(--a-radius-sm);
18
+ }
19
+
20
+ :scope {
21
+ /* ── Base ── */
22
+ box-sizing: border-box;
23
+ display: inline-flex;
24
+ align-items: center;
25
+ gap: var(--rating-gap);
26
+ cursor: pointer;
27
+ user-select: none;
28
+ line-height: 1;
29
+ }
30
+
31
+ :scope[readonly],
32
+ :scope[disabled] {
33
+ cursor: default;
34
+ }
35
+ :scope[disabled] {
36
+ opacity: 0.5;
37
+ pointer-events: none;
38
+ }
39
+
40
+ :scope:focus-visible {
41
+ outline: none;
42
+ border-radius: var(--rating-focus-radius);
43
+ box-shadow: var(--rating-focus-ring);
44
+ outline-offset: var(--rating-focus-offset);
45
+ }
46
+
47
+ [data-rating-symbol] {
48
+ position: relative;
49
+ display: inline-block;
50
+ width: var(--rating-symbol-size);
51
+ height: var(--rating-symbol-size);
52
+ color: var(--rating-fg-empty);
53
+ transition: color var(--rating-duration) var(--rating-easing);
54
+ }
55
+
56
+ [data-rating-symbol] icon-ui {
57
+ --a-icon-size: var(--rating-symbol-size);
58
+ position: absolute;
59
+ inset: 0;
60
+ }
61
+
62
+ [data-rating-symbol-fg] {
63
+ color: var(--rating-fg-filled);
64
+ clip-path: inset(0 100% 0 0);
65
+ transition: clip-path var(--rating-duration) var(--rating-easing);
66
+ }
67
+
68
+ [data-rating-symbol][data-fill="half"] [data-rating-symbol-fg] {
69
+ clip-path: inset(0 50% 0 0);
70
+ }
71
+ [data-rating-symbol][data-fill="full"] [data-rating-symbol-fg] {
72
+ clip-path: inset(0 0 0 0);
73
+ }
74
+
75
+ :scope:hover [data-rating-symbol] {
76
+ color: var(--rating-fg-hover);
77
+ }
78
+
79
+ /* ── Variants override TOKENS only ── */
80
+ :scope[variant="accent"] {
81
+ --rating-fg-filled: var(--a-accent-bg);
82
+ --rating-fg-hover: var(--a-accent-bg);
83
+ }
84
+ :scope[variant="warning"] {
85
+ --rating-fg-filled: var(--a-warning-bg);
86
+ --rating-fg-hover: var(--a-warning-bg);
87
+ }
88
+
89
+ /* ── Size ── */
90
+ :scope[size="sm"] { --rating-symbol-size: var(--a-space-4); }
91
+ :scope[size="lg"] { --rating-symbol-size: var(--a-space-7); }
92
+ }
@@ -0,0 +1,138 @@
1
+ /**
2
+ * <rating-ui> — Discrete pictorial rating (stars by default).
3
+ *
4
+ * Supports keyboard (arrows), mouse hover preview, and 0.5-step precision.
5
+ * The host is role=slider per ARIA APG for custom rating widgets.
6
+ *
7
+ * <rating-ui value="3.5" max="5" allow-half name="review"></rating-ui>
8
+ * <rating-ui value="4" icon="heart" variant="accent"></rating-ui>
9
+ * <rating-ui value="5" readonly></rating-ui>
10
+ */
11
+
12
+ import { AdiaFormElement } from '@core/form.js';
13
+
14
+ class AdiaRating extends AdiaFormElement {
15
+ static properties = {
16
+ ...AdiaFormElement.properties,
17
+ /** value: Number — overrides AdiaFormElement.value (String); syncs as string on form submit. */
18
+ value: { type: Number, default: 0, reflect: true },
19
+ max: { type: Number, default: 5, reflect: true },
20
+ icon: { type: String, default: 'star', reflect: true },
21
+ readonly: { type: Boolean, default: false, reflect: true },
22
+ allowHalf: { type: Boolean, default: false, reflect: true, attribute: 'allow-half' },
23
+ size: { type: String, default: 'md', reflect: true },
24
+ };
25
+
26
+ static template = () => null;
27
+
28
+ #hoverValue = null;
29
+
30
+ connected() {
31
+ super.connected();
32
+ this.setAttribute('role', 'slider');
33
+ this.setAttribute('aria-orientation', 'horizontal');
34
+ this.setAttribute('aria-valuemin', '0');
35
+ if (!this.hasAttribute('tabindex')) this.setAttribute('tabindex', this.readonly ? '-1' : '0');
36
+ this.addEventListener('pointermove', this.#onPointer);
37
+ this.addEventListener('pointerleave', this.#onLeave);
38
+ this.addEventListener('click', this.#onClick);
39
+ this.addEventListener('keydown', this.#onKey);
40
+ }
41
+
42
+ render() {
43
+ const max = Number(this.max) || 5;
44
+ const display = this.#hoverValue ?? (Number(this.value) || 0);
45
+
46
+ const symbols = Array.from({ length: max }, (_, i) => {
47
+ const slotValue = i + 1;
48
+ const fill =
49
+ display >= slotValue ? 'full' :
50
+ display >= slotValue - 0.5 ? 'half' :
51
+ 'empty';
52
+ return `
53
+ <span data-rating-symbol data-fill="${fill}" aria-hidden="true">
54
+ <icon-ui name="${this.icon}" data-rating-symbol-bg></icon-ui>
55
+ <icon-ui name="${this.icon}" weight="fill" data-rating-symbol-fg></icon-ui>
56
+ </span>
57
+ `;
58
+ }).join('');
59
+
60
+ this.innerHTML = symbols;
61
+ this.setAttribute('aria-valuemax', String(max));
62
+ this.setAttribute('aria-valuenow', String(Number(this.value) || 0));
63
+ this.setAttribute('aria-valuetext', `${Number(this.value) || 0} out of ${max}`);
64
+ if (this.readonly) this.setAttribute('aria-readonly', 'true');
65
+ else this.removeAttribute('aria-readonly');
66
+ }
67
+
68
+ #valueFromEvent(e) {
69
+ const symbols = [...this.querySelectorAll('[data-rating-symbol]')];
70
+ const target = symbols.find(s => s.contains(e.target));
71
+ if (!target) return null;
72
+ const idx = symbols.indexOf(target);
73
+ if (idx === -1) return null;
74
+ if (this.allowHalf) {
75
+ const rect = target.getBoundingClientRect();
76
+ const isHalf = (e.clientX - rect.left) < rect.width / 2;
77
+ return idx + (isHalf ? 0.5 : 1);
78
+ }
79
+ return idx + 1;
80
+ }
81
+
82
+ #onPointer = (e) => {
83
+ if (this.readonly || this.disabled) return;
84
+ const v = this.#valueFromEvent(e);
85
+ if (v == null) return;
86
+ if (v !== this.#hoverValue) {
87
+ this.#hoverValue = v;
88
+ this.render();
89
+ }
90
+ };
91
+
92
+ #onLeave = () => {
93
+ if (this.#hoverValue == null) return;
94
+ this.#hoverValue = null;
95
+ this.render();
96
+ };
97
+
98
+ #onClick = (e) => {
99
+ if (this.readonly || this.disabled) return;
100
+ const v = this.#valueFromEvent(e);
101
+ if (v == null) return;
102
+ this.#commit(v);
103
+ };
104
+
105
+ #onKey = (e) => {
106
+ if (this.readonly || this.disabled) return;
107
+ const step = this.allowHalf ? 0.5 : 1;
108
+ const max = Number(this.max) || 5;
109
+ const v = Number(this.value) || 0;
110
+ let next = v;
111
+ if (e.key === 'ArrowRight' || e.key === 'ArrowUp') { next = Math.min(max, v + step); }
112
+ else if (e.key === 'ArrowLeft' || e.key === 'ArrowDown') { next = Math.max(0, v - step); }
113
+ else if (e.key === 'Home') next = 0;
114
+ else if (e.key === 'End') next = max;
115
+ else return;
116
+ e.preventDefault();
117
+ this.#commit(next);
118
+ };
119
+
120
+ #commit(v) {
121
+ this.value = v;
122
+ this.#hoverValue = null;
123
+ this.syncValue(String(v));
124
+ this.dispatchEvent(new Event('change', { bubbles: true }));
125
+ this.render();
126
+ }
127
+
128
+ disconnected() {
129
+ super.disconnected();
130
+ this.removeEventListener('pointermove', this.#onPointer);
131
+ this.removeEventListener('pointerleave', this.#onLeave);
132
+ this.removeEventListener('click', this.#onClick);
133
+ this.removeEventListener('keydown', this.#onKey);
134
+ }
135
+ }
136
+
137
+ customElements.define('rating-ui', AdiaRating);
138
+ export { AdiaRating };