@qw-ui/core 0.3.0-next.9 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (415) hide show
  1. package/README.md +21 -37
  2. package/dist/action-sheet/action-sheet.d.ts +110 -0
  3. package/dist/action-sheet/index.d.ts +2 -0
  4. package/dist/action-sheet/index.js +2 -0
  5. package/dist/action-sheet-Cvcr1S_m.js +183 -0
  6. package/dist/action-sheet-Cvcr1S_m.js.map +1 -0
  7. package/dist/area-picker/area-picker.d.ts +113 -0
  8. package/dist/area-picker/index.d.ts +1 -0
  9. package/dist/area-picker/index.js +348 -0
  10. package/dist/area-picker/index.js.map +1 -0
  11. package/dist/aria-description-CimD2M_C.js +13 -0
  12. package/dist/aria-description-CimD2M_C.js.map +1 -0
  13. package/dist/aria-description.d.ts +2 -0
  14. package/dist/avatar/avatar-load.d.ts +76 -0
  15. package/dist/avatar/avatar.d.ts +22 -5
  16. package/dist/avatar/index.d.ts +1 -0
  17. package/dist/avatar/index.js +57 -18
  18. package/dist/avatar/index.js.map +1 -1
  19. package/dist/avatar-load-w9dq05oV.js +139 -0
  20. package/dist/avatar-load-w9dq05oV.js.map +1 -0
  21. package/dist/back-top/back-top.d.ts +77 -0
  22. package/dist/back-top/index.d.ts +1 -0
  23. package/dist/back-top/index.js +189 -0
  24. package/dist/back-top/index.js.map +1 -0
  25. package/dist/badge/badge.d.ts +85 -0
  26. package/dist/badge/index.d.ts +1 -0
  27. package/dist/badge/index.js +88 -0
  28. package/dist/badge/index.js.map +1 -0
  29. package/dist/button/button.d.ts +13 -0
  30. package/dist/button/index.js +3 -5
  31. package/dist/button/index.js.map +1 -1
  32. package/dist/calendar/calendar.d.ts +100 -0
  33. package/dist/calendar/index.d.ts +1 -0
  34. package/dist/calendar/index.js +2 -0
  35. package/dist/calendar-CmpK3stz.js +363 -0
  36. package/dist/calendar-CmpK3stz.js.map +1 -0
  37. package/dist/card/card.d.ts +68 -0
  38. package/dist/card/index.d.ts +2 -0
  39. package/dist/card/index.js +2 -0
  40. package/dist/card-DRtWa6Cr.js +107 -0
  41. package/dist/card-DRtWa6Cr.js.map +1 -0
  42. package/dist/cascader/cascader.d.ts +115 -0
  43. package/dist/cascader/index.d.ts +1 -0
  44. package/dist/cascader/index.js +2 -0
  45. package/dist/cascader-D-xMjs7P.js +333 -0
  46. package/dist/cascader-D-xMjs7P.js.map +1 -0
  47. package/dist/cell/cell.d.ts +41 -0
  48. package/dist/cell/index.d.ts +1 -0
  49. package/dist/cell/index.js +43 -0
  50. package/dist/cell/index.js.map +1 -0
  51. package/dist/check-list/check-list.d.ts +78 -0
  52. package/dist/check-list/index.d.ts +2 -0
  53. package/dist/check-list/index.js +2 -0
  54. package/dist/check-list-BvZHQt5w.js +60 -0
  55. package/dist/check-list-BvZHQt5w.js.map +1 -0
  56. package/dist/checkbox/checkbox.d.ts +59 -0
  57. package/dist/checkbox/index.d.ts +2 -0
  58. package/dist/checkbox/index.js +2 -0
  59. package/dist/checkbox-BlndJrz5.js +127 -0
  60. package/dist/checkbox-BlndJrz5.js.map +1 -0
  61. package/dist/checkbox-group/checkbox-group.d.ts +86 -0
  62. package/dist/checkbox-group/index.d.ts +3 -0
  63. package/dist/checkbox-group/index.js +2 -0
  64. package/dist/checkbox-group-gGfsTv-e.js +223 -0
  65. package/dist/checkbox-group-gGfsTv-e.js.map +1 -0
  66. package/dist/choice-group-C4c9m0qe.js +373 -0
  67. package/dist/choice-group-C4c9m0qe.js.map +1 -0
  68. package/dist/circle/circle.d.ts +97 -0
  69. package/dist/circle/index.d.ts +1 -0
  70. package/dist/circle/index.js +119 -0
  71. package/dist/circle/index.js.map +1 -0
  72. package/dist/collapse/collapse.d.ts +98 -0
  73. package/dist/collapse/index.d.ts +2 -0
  74. package/dist/collapse/index.js +2 -0
  75. package/dist/collapse-B969h7-H.js +226 -0
  76. package/dist/collapse-B969h7-H.js.map +1 -0
  77. package/dist/countdown/countdown.d.ts +114 -0
  78. package/dist/countdown/index.d.ts +1 -0
  79. package/dist/countdown/index.js +309 -0
  80. package/dist/countdown/index.js.map +1 -0
  81. package/dist/date-picker/date-picker.d.ts +168 -0
  82. package/dist/date-picker/index.d.ts +1 -0
  83. package/dist/date-picker/index.js +401 -0
  84. package/dist/date-picker/index.js.map +1 -0
  85. package/dist/descriptions/descriptions.d.ts +69 -0
  86. package/dist/descriptions/index.d.ts +1 -0
  87. package/dist/descriptions/index.js +86 -0
  88. package/dist/descriptions/index.js.map +1 -0
  89. package/dist/dialog/dialog.d.ts +61 -43
  90. package/dist/dialog/index.js +73 -19
  91. package/dist/dialog/index.js.map +1 -1
  92. package/dist/divider/divider.d.ts +18 -2
  93. package/dist/divider/index.js +20 -2
  94. package/dist/divider/index.js.map +1 -1
  95. package/dist/dropdown/dropdown.d.ts +172 -0
  96. package/dist/dropdown/index.d.ts +2 -0
  97. package/dist/dropdown/index.js +467 -0
  98. package/dist/dropdown/index.js.map +1 -0
  99. package/dist/ellipsis/ellipsis-layout.d.ts +34 -0
  100. package/dist/ellipsis/ellipsis.d.ts +88 -0
  101. package/dist/ellipsis/index.d.ts +2 -0
  102. package/dist/ellipsis/index.js +320 -0
  103. package/dist/ellipsis/index.js.map +1 -0
  104. package/dist/empty/empty-illustration.d.ts +3 -0
  105. package/dist/empty/empty.d.ts +43 -1
  106. package/dist/empty/index.js +2 -21
  107. package/dist/empty-CAgyvhUI.js +166 -0
  108. package/dist/empty-CAgyvhUI.js.map +1 -0
  109. package/dist/field/field.d.ts +95 -0
  110. package/dist/field/index.d.ts +2 -0
  111. package/dist/field/index.js +2 -0
  112. package/dist/field-DMHGIMZF.js +241 -0
  113. package/dist/field-DMHGIMZF.js.map +1 -0
  114. package/dist/floating-bubble/floating-bubble.d.ts +116 -0
  115. package/dist/floating-bubble/index.d.ts +1 -0
  116. package/dist/floating-bubble/index.js +333 -0
  117. package/dist/floating-bubble/index.js.map +1 -0
  118. package/dist/floating-panel/floating-panel.d.ts +80 -0
  119. package/dist/floating-panel/index.d.ts +2 -0
  120. package/dist/floating-panel/index.js +2 -0
  121. package/dist/floating-panel-Cbm5njBJ.js +363 -0
  122. package/dist/floating-panel-Cbm5njBJ.js.map +1 -0
  123. package/dist/footer/footer.d.ts +94 -0
  124. package/dist/footer/index.d.ts +1 -0
  125. package/dist/footer/index.js +154 -0
  126. package/dist/footer/index.js.map +1 -0
  127. package/dist/form/connect.d.ts +6 -0
  128. package/dist/form/form.d.ts +100 -0
  129. package/dist/form/ids.d.ts +14 -0
  130. package/dist/form/index.d.ts +13 -0
  131. package/dist/form/index.js +3 -0
  132. package/dist/form/methods.d.ts +5 -0
  133. package/dist/form/model.d.ts +24 -0
  134. package/dist/form/native.d.ts +25 -0
  135. package/dist/form/rules.d.ts +40 -0
  136. package/dist/form/ssr.d.ts +7 -0
  137. package/dist/form/types.d.ts +150 -0
  138. package/dist/form-BAGkIEMY.js +1354 -0
  139. package/dist/form-BAGkIEMY.js.map +1 -0
  140. package/dist/format-BDUY0C_c.js +89 -0
  141. package/dist/format-BDUY0C_c.js.map +1 -0
  142. package/dist/gesture-_SRHIvBm.js +30 -0
  143. package/dist/gesture-_SRHIvBm.js.map +1 -0
  144. package/dist/grid/grid-item.d.ts +22 -0
  145. package/dist/grid/grid.d.ts +42 -0
  146. package/dist/grid/index.d.ts +2 -0
  147. package/dist/grid/index.js +73 -0
  148. package/dist/grid/index.js.map +1 -0
  149. package/dist/icon/icon.d.ts +37 -1
  150. package/dist/icon/identity.d.ts +3 -0
  151. package/dist/icon/index.js +2 -20
  152. package/dist/icon-Cgdbnk1u.js +77 -0
  153. package/dist/icon-Cgdbnk1u.js.map +1 -0
  154. package/dist/image/image-load.d.ts +24 -0
  155. package/dist/image/image.d.ts +45 -8
  156. package/dist/image/index.d.ts +1 -0
  157. package/dist/image/index.js +116 -14
  158. package/dist/image/index.js.map +1 -1
  159. package/dist/image-preview/image-preview.d.ts +124 -0
  160. package/dist/image-preview/index.d.ts +1 -0
  161. package/dist/image-preview/index.js +450 -0
  162. package/dist/image-preview/index.js.map +1 -0
  163. package/dist/index-bar/index-bar.d.ts +121 -0
  164. package/dist/index-bar/index.d.ts +1 -0
  165. package/dist/index-bar/index.js +386 -0
  166. package/dist/index-bar/index.js.map +1 -0
  167. package/dist/index.d.ts +115 -10
  168. package/dist/index.js +151 -11
  169. package/dist/index.js.map +1 -0
  170. package/dist/infinite-scroll/index.d.ts +1 -0
  171. package/dist/infinite-scroll/index.js +248 -0
  172. package/dist/infinite-scroll/index.js.map +1 -0
  173. package/dist/infinite-scroll/infinite-scroll.d.ts +95 -0
  174. package/dist/input/index.js +181 -22
  175. package/dist/input/index.js.map +1 -1
  176. package/dist/input/input.d.ts +44 -1
  177. package/dist/layer-IpFrl5--.js +414 -0
  178. package/dist/layer-IpFrl5--.js.map +1 -0
  179. package/dist/layout-BRSqi4AQ.js +43 -0
  180. package/dist/layout-BRSqi4AQ.js.map +1 -0
  181. package/dist/layout.d.ts +13 -0
  182. package/dist/list/index.d.ts +2 -0
  183. package/dist/list/index.js +2 -0
  184. package/dist/list/list.d.ts +30 -0
  185. package/dist/list-6-iz-Irh.js +28 -0
  186. package/dist/list-6-iz-Irh.js.map +1 -0
  187. package/dist/loading/index.js +45 -2
  188. package/dist/loading/index.js.map +1 -1
  189. package/dist/loading/loading.d.ts +45 -2
  190. package/dist/modal-dialog-machine-CF9_z3Dm.js +487 -0
  191. package/dist/modal-dialog-machine-CF9_z3Dm.js.map +1 -0
  192. package/dist/modal-dialog-machine.d.ts +21 -0
  193. package/dist/modal-dismissable-lifetime.d.ts +21 -0
  194. package/dist/modal-registry.d.ts +24 -0
  195. package/dist/modal-render-hydration.d.ts +35 -0
  196. package/dist/modal-render-runtime.d.ts +19 -0
  197. package/dist/modal-render-scope.d.ts +63 -0
  198. package/dist/nav-bar/index.d.ts +1 -0
  199. package/dist/nav-bar/index.js +115 -0
  200. package/dist/nav-bar/index.js.map +1 -0
  201. package/dist/nav-bar/nav-bar.d.ts +76 -0
  202. package/dist/notice-bar/index.d.ts +2 -0
  203. package/dist/notice-bar/index.js +2 -0
  204. package/dist/notice-bar/notice-bar.d.ts +103 -0
  205. package/dist/notice-bar-DMpwLvRb.js +231 -0
  206. package/dist/notice-bar-DMpwLvRb.js.map +1 -0
  207. package/dist/notify/index.d.ts +1 -0
  208. package/dist/notify/index.js +251 -0
  209. package/dist/notify/index.js.map +1 -0
  210. package/dist/notify/notify.d.ts +123 -0
  211. package/dist/number-keyboard/index.d.ts +1 -0
  212. package/dist/number-keyboard/index.js +333 -0
  213. package/dist/number-keyboard/index.js.map +1 -0
  214. package/dist/number-keyboard/number-keyboard.d.ts +141 -0
  215. package/dist/overlay-panel/index.d.ts +2 -0
  216. package/dist/overlay-panel/index.js +2 -0
  217. package/dist/overlay-panel/overlay-panel.d.ts +20 -0
  218. package/dist/overlay-panel-Z_qdKeBj.js +26 -0
  219. package/dist/overlay-panel-Z_qdKeBj.js.map +1 -0
  220. package/dist/page-indicator/index.d.ts +1 -0
  221. package/dist/page-indicator/index.js +138 -0
  222. package/dist/page-indicator/index.js.map +1 -0
  223. package/dist/page-indicator/page-indicator.d.ts +93 -0
  224. package/dist/pagination/index.d.ts +1 -0
  225. package/dist/pagination/index.js +198 -0
  226. package/dist/pagination/index.js.map +1 -0
  227. package/dist/pagination/pagination.d.ts +125 -0
  228. package/dist/password-input/index.d.ts +1 -0
  229. package/dist/password-input/index.js +317 -0
  230. package/dist/password-input/index.js.map +1 -0
  231. package/dist/password-input/password-input.d.ts +144 -0
  232. package/dist/picker/index.d.ts +8 -0
  233. package/dist/picker/index.js +2 -0
  234. package/dist/picker/picker-machine.d.ts +80 -0
  235. package/dist/picker/picker.d.ts +121 -0
  236. package/dist/picker/platform.d.ts +84 -0
  237. package/dist/picker/selection-connect.d.ts +90 -0
  238. package/dist/picker/selection-model.d.ts +211 -0
  239. package/dist/picker-BykFntQN.js +1675 -0
  240. package/dist/picker-BykFntQN.js.map +1 -0
  241. package/dist/popover/index.d.ts +3 -0
  242. package/dist/popover/index.js +253 -0
  243. package/dist/popover/index.js.map +1 -0
  244. package/dist/popover/layer.d.ts +44 -0
  245. package/dist/popover/popover.d.ts +104 -0
  246. package/dist/popover/positioning.d.ts +132 -0
  247. package/dist/popup/index.d.ts +2 -0
  248. package/dist/popup/index.js +2 -0
  249. package/dist/popup/popup.d.ts +60 -0
  250. package/dist/popup-z5d8IYCt.js +576 -0
  251. package/dist/popup-z5d8IYCt.js.map +1 -0
  252. package/dist/portal-BHCNTWhg.js +78 -0
  253. package/dist/portal-BHCNTWhg.js.map +1 -0
  254. package/dist/portal.d.ts +61 -0
  255. package/dist/price/format.d.ts +19 -0
  256. package/dist/price/index.d.ts +1 -0
  257. package/dist/price/index.js +154 -0
  258. package/dist/price/index.js.map +1 -0
  259. package/dist/price/price.d.ts +88 -0
  260. package/dist/progress/index.d.ts +1 -0
  261. package/dist/progress/index.js +2 -0
  262. package/dist/progress/progress.d.ts +32 -0
  263. package/dist/progress-f3iYEfdA.js +37 -0
  264. package/dist/progress-f3iYEfdA.js.map +1 -0
  265. package/dist/pull-refresh/index.d.ts +1 -0
  266. package/dist/pull-refresh/index.js +414 -0
  267. package/dist/pull-refresh/index.js.map +1 -0
  268. package/dist/pull-refresh/pull-refresh.d.ts +118 -0
  269. package/dist/radio-group/index.d.ts +3 -0
  270. package/dist/radio-group/index.js +2 -0
  271. package/dist/radio-group/radio-group.d.ts +78 -0
  272. package/dist/radio-group-BOIMuqnS.js +230 -0
  273. package/dist/radio-group-BOIMuqnS.js.map +1 -0
  274. package/dist/rate/index.d.ts +1 -0
  275. package/dist/rate/index.js +2 -0
  276. package/dist/rate/rate-form.d.ts +28 -0
  277. package/dist/rate/rate.d.ts +144 -0
  278. package/dist/rate-5XsU2QkY.js +631 -0
  279. package/dist/rate-5XsU2QkY.js.map +1 -0
  280. package/dist/reorder/index.d.ts +1 -0
  281. package/dist/reorder/index.js +720 -0
  282. package/dist/reorder/index.js.map +1 -0
  283. package/dist/reorder/reorder.d.ts +190 -0
  284. package/dist/result/index.d.ts +1 -0
  285. package/dist/result/index.js +123 -0
  286. package/dist/result/index.js.map +1 -0
  287. package/dist/result/result.d.ts +88 -0
  288. package/dist/safe-area/index.d.ts +1 -0
  289. package/dist/safe-area/index.js +42 -0
  290. package/dist/safe-area/index.js.map +1 -0
  291. package/dist/safe-area/safe-area.d.ts +28 -0
  292. package/dist/search-bar/index.js +4 -2
  293. package/dist/search-bar/index.js.map +1 -1
  294. package/dist/search-bar/search-bar.d.ts +6 -0
  295. package/dist/segmented/index.d.ts +2 -0
  296. package/dist/segmented/index.js +2 -0
  297. package/dist/segmented/segmented.d.ts +127 -0
  298. package/dist/segmented-BaU38_L4.js +367 -0
  299. package/dist/segmented-BaU38_L4.js.map +1 -0
  300. package/dist/selection-form-BOM_odUk.js +88 -0
  301. package/dist/selection-form-BOM_odUk.js.map +1 -0
  302. package/dist/selection-form.d.ts +27 -0
  303. package/dist/selection-ivXqO1eu.js +55 -0
  304. package/dist/selection-ivXqO1eu.js.map +1 -0
  305. package/dist/selection.d.ts +29 -0
  306. package/dist/selector/choice-group.d.ts +114 -0
  307. package/dist/selector/index.d.ts +2 -0
  308. package/dist/selector/index.js +2 -0
  309. package/dist/selector/selector.d.ts +90 -0
  310. package/dist/selector-BU2MMJ4N.js +93 -0
  311. package/dist/selector-BU2MMJ4N.js.map +1 -0
  312. package/dist/share-sheet/index.d.ts +1 -0
  313. package/dist/share-sheet/index.js +138 -0
  314. package/dist/share-sheet/index.js.map +1 -0
  315. package/dist/share-sheet/share-sheet.d.ts +139 -0
  316. package/dist/side-nav/index.d.ts +1 -0
  317. package/dist/side-nav/index.js +99 -0
  318. package/dist/side-nav/index.js.map +1 -0
  319. package/dist/side-nav/side-nav.d.ts +94 -0
  320. package/dist/skeleton/index.js +51 -2
  321. package/dist/skeleton/index.js.map +1 -1
  322. package/dist/skeleton/skeleton.d.ts +34 -3
  323. package/dist/slider/index.d.ts +1 -0
  324. package/dist/slider/index.js +482 -0
  325. package/dist/slider/index.js.map +1 -0
  326. package/dist/slider/slider.d.ts +174 -0
  327. package/dist/space/index.d.ts +1 -0
  328. package/dist/space/index.js +52 -0
  329. package/dist/space/index.js.map +1 -0
  330. package/dist/space/space.d.ts +46 -0
  331. package/dist/statistic/index.d.ts +1 -0
  332. package/dist/statistic/index.js +152 -0
  333. package/dist/statistic/index.js.map +1 -0
  334. package/dist/statistic/statistic.d.ts +101 -0
  335. package/dist/stepper/index.d.ts +1 -0
  336. package/dist/stepper/index.js +172 -0
  337. package/dist/stepper/index.js.map +1 -0
  338. package/dist/stepper/stepper.d.ts +161 -0
  339. package/dist/steps/index.d.ts +1 -0
  340. package/dist/steps/index.js +72 -0
  341. package/dist/steps/index.js.map +1 -0
  342. package/dist/steps/steps.d.ts +67 -0
  343. package/dist/sticky/index.d.ts +1 -0
  344. package/dist/sticky/index.js +145 -0
  345. package/dist/sticky/index.js.map +1 -0
  346. package/dist/sticky/sticky.d.ts +70 -0
  347. package/dist/swipe-action/index.d.ts +1 -0
  348. package/dist/swipe-action/index.js +417 -0
  349. package/dist/swipe-action/index.js.map +1 -0
  350. package/dist/swipe-action/swipe-action.d.ts +148 -0
  351. package/dist/swiper/gesture.d.ts +32 -0
  352. package/dist/swiper/index.d.ts +1 -0
  353. package/dist/swiper/index.js +2 -0
  354. package/dist/swiper/swiper.d.ts +177 -0
  355. package/dist/swiper-BKivDkHp.js +550 -0
  356. package/dist/swiper-BKivDkHp.js.map +1 -0
  357. package/dist/switch/index.d.ts +1 -0
  358. package/dist/switch/index.js +168 -0
  359. package/dist/switch/index.js.map +1 -0
  360. package/dist/switch/switch.d.ts +142 -0
  361. package/dist/tabbar/index.d.ts +1 -0
  362. package/dist/tabbar/index.js +95 -0
  363. package/dist/tabbar/index.js.map +1 -0
  364. package/dist/tabbar/tabbar.d.ts +119 -0
  365. package/dist/tabs/index.js +22 -1
  366. package/dist/tabs/index.js.map +1 -1
  367. package/dist/tabs/tabs.d.ts +12 -8
  368. package/dist/tag/index.js +123 -2
  369. package/dist/tag/index.js.map +1 -1
  370. package/dist/tag/tag.d.ts +67 -1
  371. package/dist/textarea/index.d.ts +2 -0
  372. package/dist/textarea/index.js +2 -242
  373. package/dist/textarea/platform.d.ts +22 -0
  374. package/dist/textarea/textarea.d.ts +169 -46
  375. package/dist/textarea-qbnruDUG.js +775 -0
  376. package/dist/textarea-qbnruDUG.js.map +1 -0
  377. package/dist/time-picker/index.d.ts +1 -0
  378. package/dist/time-picker/index.js +228 -0
  379. package/dist/time-picker/index.js.map +1 -0
  380. package/dist/time-picker/time-picker.d.ts +83 -0
  381. package/dist/timeline/index.d.ts +1 -0
  382. package/dist/timeline/index.js +131 -0
  383. package/dist/timeline/index.js.map +1 -0
  384. package/dist/timeline/timeline.d.ts +79 -0
  385. package/dist/toast/index.js +47 -4
  386. package/dist/toast/index.js.map +1 -1
  387. package/dist/toast/toast.d.ts +26 -3
  388. package/dist/top-bar/index.js +16 -2
  389. package/dist/top-bar/index.js.map +1 -1
  390. package/dist/top-bar/top-bar.d.ts +13 -2
  391. package/dist/tree-select/index.d.ts +1 -0
  392. package/dist/tree-select/index.js +512 -0
  393. package/dist/tree-select/index.js.map +1 -0
  394. package/dist/tree-select/tree-select.d.ts +215 -0
  395. package/dist/typography/index.d.ts +1 -0
  396. package/dist/typography/index.js +82 -0
  397. package/dist/typography/index.js.map +1 -0
  398. package/dist/typography/typography.d.ts +54 -0
  399. package/dist/upload/index.d.ts +1 -0
  400. package/dist/upload/index.js +458 -0
  401. package/dist/upload/index.js.map +1 -0
  402. package/dist/upload/upload.d.ts +172 -0
  403. package/dist/virtual-list/index.d.ts +1 -0
  404. package/dist/virtual-list/index.js +445 -0
  405. package/dist/virtual-list/index.js.map +1 -0
  406. package/dist/virtual-list/virtual-list.d.ts +160 -0
  407. package/dist/visual-manifest.d.ts +27 -0
  408. package/dist/watermark/index.d.ts +1 -0
  409. package/dist/watermark/index.js +260 -0
  410. package/dist/watermark/index.js.map +1 -0
  411. package/dist/watermark/watermark.d.ts +106 -0
  412. package/package.json +417 -44
  413. package/dist/empty/index.js.map +0 -1
  414. package/dist/icon/index.js.map +0 -1
  415. package/dist/textarea/index.js.map +0 -1
@@ -0,0 +1,367 @@
1
+ import { o as resolveIconState } from "./icon-Cgdbnk1u.js";
2
+ import { i as toggleSelectionValue, n as normalizeSelectionValue, r as selectionItemKey, t as normalizeSelectionItems } from "./selection-ivXqO1eu.js";
3
+ import { t as mergeDescriptionIds } from "./aria-description-CimD2M_C.js";
4
+ import { n as trackSelectionForm, t as syncSelectionInputs } from "./selection-form-BOM_odUk.js";
5
+ import { createMachine } from "@zag-js/core";
6
+ import { dataAttr, getComputedStyle, getEventKey, visuallyHiddenStyle } from "@zag-js/dom-query";
7
+ //#region src/segmented/segmented.ts
8
+ /** Supported single/multiple selection modes. */
9
+ const SEGMENTED_MODES = ["single", "multiple"];
10
+ /** Existing T3 control-height sizes; large is the mobile default. */
11
+ const SEGMENTED_SIZES = [
12
+ "sm",
13
+ "md",
14
+ "lg"
15
+ ];
16
+ /** Stable DOM parts shared by every adapter. */
17
+ const SEGMENTED_PARTS = [
18
+ "root",
19
+ "label",
20
+ "description",
21
+ "items",
22
+ "item",
23
+ "input",
24
+ "content",
25
+ "icon",
26
+ "text",
27
+ "item-description"
28
+ ];
29
+ /** Validate accessible identities and copy every caller option. */
30
+ function normalizeSegmentedItems(items) {
31
+ return normalizeSelectionItems(items).map((entry) => {
32
+ const item = entry;
33
+ if (typeof item.label !== "string" || !item.label.trim()) throw new TypeError("Segmented item labels must be nonempty accessible text");
34
+ if (item.icon !== void 0 && typeof item.icon !== "string") throw new TypeError("Segmented icons must be system icon names");
35
+ if (item.iconOnly && !item.icon?.trim()) throw new TypeError("Segmented icon-only items require an icon and accessible label");
36
+ return { ...item };
37
+ });
38
+ }
39
+ /** Single selection retains the earliest unique caller value, including unknowns. */
40
+ function normalizeSegmentedValue(value = [], mode = "single") {
41
+ const values = normalizeSelectionValue(value);
42
+ return mode === "single" ? values.slice(0, 1) : values;
43
+ }
44
+ function createSegmentedProps(props) {
45
+ if (typeof props.label !== "string" || !props.label.trim()) throw new TypeError("Segmented requires a nonempty accessible group label");
46
+ if (props.id !== void 0 && (typeof props.id !== "string" || !props.id.trim())) throw new TypeError("Segmented requires a nonempty instance id when provided");
47
+ const selectionMode = SEGMENTED_MODES.includes(props.selectionMode) ? props.selectionMode : "single";
48
+ return {
49
+ ...props,
50
+ selectionMode,
51
+ items: normalizeSegmentedItems(props.items),
52
+ value: props.value === void 0 ? void 0 : normalizeSegmentedValue(props.value, selectionMode),
53
+ defaultValue: normalizeSegmentedValue(props.defaultValue, selectionMode),
54
+ orientation: props.orientation === "vertical" ? "vertical" : "horizontal",
55
+ loop: props.loop ?? true,
56
+ selectOnFocus: props.selectOnFocus ?? true,
57
+ size: SEGMENTED_SIZES.includes(props.size) ? props.size : "md"
58
+ };
59
+ }
60
+ const same = (a, b) => !!b && a.length === b.length && a.every((value, index) => value === b[index]);
61
+ const rootId = (scope) => `segmented:${scope.id}`;
62
+ const inputId = (scope, value) => `${rootId(scope)}:input:${selectionItemKey(value)}`;
63
+ function currentValue(params) {
64
+ return normalizeSegmentedValue(params.context.get("value"), params.prop("selectionMode"));
65
+ }
66
+ function isDisabled(params, item) {
67
+ return !!params.prop("disabled") || !!item.disabled || params.context.get("disabledIds").includes(inputId(params.scope, item.value));
68
+ }
69
+ function sync(params) {
70
+ const values = currentValue(params);
71
+ syncSelectionInputs(params.scope, params.prop("items").map((item) => ({
72
+ id: inputId(params.scope, item.value),
73
+ checked: values.includes(item.value)
74
+ })));
75
+ }
76
+ function changeFor(params, value, selectOnly = false) {
77
+ const item = params.prop("items").find((entry) => entry.value === value);
78
+ if (!item || isDisabled(params, item) || params.prop("readOnly")) return null;
79
+ const values = currentValue(params);
80
+ if (params.prop("selectionMode") === "single") return values.includes(value) ? !selectOnly && params.prop("allowEmpty") ? [] : values : [value];
81
+ const result = toggleSelectionValue(values, item, {
82
+ min: params.prop("min"),
83
+ max: params.prop("max")
84
+ });
85
+ return result.blocked ? null : result.value;
86
+ }
87
+ /** One Zag bindable lifecycle; Core alone owns selection, keys and native forms. */
88
+ const segmentedMachine = createMachine({
89
+ props: ({ props }) => createSegmentedProps({
90
+ ...props,
91
+ label: props.label ?? "",
92
+ items: props.items ?? []
93
+ }),
94
+ initialState: () => "ready",
95
+ context({ prop, bindable }) {
96
+ return {
97
+ value: bindable(() => ({
98
+ defaultValue: prop("defaultValue"),
99
+ value: prop("value"),
100
+ isEqual: same,
101
+ onChange: (value) => prop("onValueChange")?.({ value: [...value] })
102
+ })),
103
+ focusedValue: bindable(() => ({ defaultValue: null })),
104
+ disabledIds: bindable(() => ({
105
+ defaultValue: [],
106
+ isEqual: same
107
+ }))
108
+ };
109
+ },
110
+ watch({ track, context, prop, action }) {
111
+ track([() => context.hash("value"), () => context.hash("disabledIds")], () => action(["syncInputs"]));
112
+ track([() => prop("selectionMode")], () => action(["normalizeMode"]));
113
+ },
114
+ effects: ["trackForm"],
115
+ on: {
116
+ "VALUE.SET": { actions: ["setValue"] },
117
+ "VALUE.TOGGLE": { actions: ["toggleValue"] },
118
+ "VALUE.SELECT": { actions: ["selectValue"] },
119
+ FOCUS: { actions: ["setFocus"] }
120
+ },
121
+ states: { ready: {} },
122
+ implementations: {
123
+ effects: { trackForm(params) {
124
+ return trackSelectionForm({
125
+ scope: params.scope,
126
+ rootId: rootId(params.scope),
127
+ form: () => params.prop("form"),
128
+ getState: () => params.prop("items").map((item) => ({
129
+ id: inputId(params.scope, item.value),
130
+ checked: currentValue(params).includes(item.value)
131
+ })),
132
+ onReset: () => params.context.set("value", normalizeSegmentedValue(params.prop("defaultValue"), params.prop("selectionMode"))),
133
+ onDisabledChange: (ids) => params.context.set("disabledIds", [...ids])
134
+ }).stop;
135
+ } },
136
+ actions: {
137
+ syncInputs: sync,
138
+ normalizeMode(params) {
139
+ params.context.set("value", currentValue(params));
140
+ queueMicrotask(() => sync(params));
141
+ },
142
+ setValue(params) {
143
+ if (params.event.type === "VALUE.SET") params.context.set("value", normalizeSegmentedValue(params.event.value, params.prop("selectionMode")));
144
+ queueMicrotask(() => sync(params));
145
+ },
146
+ toggleValue(params) {
147
+ if (params.event.type === "VALUE.TOGGLE") {
148
+ const values = changeFor(params, params.event.value);
149
+ if (values) params.context.set("value", values);
150
+ }
151
+ queueMicrotask(() => sync(params));
152
+ },
153
+ selectValue(params) {
154
+ if (params.event.type === "VALUE.SELECT") {
155
+ const values = changeFor(params, params.event.value, true);
156
+ if (values) params.context.set("value", values);
157
+ }
158
+ queueMicrotask(() => sync(params));
159
+ },
160
+ setFocus(params) {
161
+ if (params.event.type === "FOCUS") params.context.set("focusedValue", params.event.value);
162
+ }
163
+ }
164
+ }
165
+ });
166
+ /** Getters are SSR-pure; only client events/effects use the existing Zag DOM scope. */
167
+ function connect(service, normalize) {
168
+ const id = rootId(service.scope), values = currentValue(service), items = service.prop("items");
169
+ const single = service.prop("selectionMode") === "single";
170
+ const enabled = items.filter((item) => !isDisabled(service, item));
171
+ const focused = service.context.get("focusedValue");
172
+ const tabAnchor = enabled.find((item) => item.value === focused) ?? enabled.find((item) => values.includes(item.value)) ?? enabled[0];
173
+ const requiredAnchor = service.prop("required") && !enabled.some((item) => values.includes(item.value)) ? enabled[0]?.value : void 0;
174
+ const resolve = ({ value }) => {
175
+ const item = items.find((entry) => entry.value === value);
176
+ if (!item) throw new RangeError("Segmented item is not present in items");
177
+ return item;
178
+ };
179
+ const part = (name) => ({
180
+ "data-scope": "segmented",
181
+ "data-part": name
182
+ });
183
+ const data = (item) => ({
184
+ "data-state": values.includes(item.value) ? "checked" : "unchecked",
185
+ "data-disabled": dataAttr(isDisabled(service, item)),
186
+ "data-readonly": dataAttr(service.prop("readOnly")),
187
+ "data-invalid": dataAttr(service.prop("invalid")),
188
+ "data-icon-only": dataAttr(item.iconOnly)
189
+ });
190
+ return {
191
+ value: [...values],
192
+ items: items.map((item) => ({ ...item })),
193
+ label: service.prop("label"),
194
+ description: service.prop("description") ?? "",
195
+ setValue: (value) => service.send({
196
+ type: "VALUE.SET",
197
+ value: normalizeSegmentedValue(value, service.prop("selectionMode"))
198
+ }),
199
+ toggleValue: (value) => service.send({
200
+ type: "VALUE.TOGGLE",
201
+ value
202
+ }),
203
+ getRootProps: () => normalize.element({
204
+ ...part("root"),
205
+ id,
206
+ role: single ? "radiogroup" : "group",
207
+ disabled: !!service.prop("disabled"),
208
+ form: service.prop("form"),
209
+ dir: service.prop("dir"),
210
+ "aria-labelledby": `${id}:label`,
211
+ "aria-describedby": mergeDescriptionIds(service.prop("description") ? `${id}:description` : void 0, service.prop("describedBy")),
212
+ "aria-required": single && service.prop("required") || void 0,
213
+ "aria-readonly": single && service.prop("readOnly") || void 0,
214
+ "aria-disabled": service.prop("disabled") || items.length > 0 && !enabled.length || void 0,
215
+ "aria-invalid": service.prop("invalid") || void 0,
216
+ "data-selection-mode": service.prop("selectionMode"),
217
+ "data-orientation": service.prop("orientation"),
218
+ "data-size": service.prop("size"),
219
+ "data-block": dataAttr(service.prop("block")),
220
+ "data-scrollable": dataAttr(service.prop("scrollable")),
221
+ "data-disabled": dataAttr(service.prop("disabled")),
222
+ "data-readonly": dataAttr(service.prop("readOnly")),
223
+ "data-invalid": dataAttr(service.prop("invalid"))
224
+ }),
225
+ getLabelProps: () => normalize.element({
226
+ ...part("label"),
227
+ id: `${id}:label`
228
+ }),
229
+ getDescriptionProps: () => normalize.element({
230
+ ...part("description"),
231
+ id: `${id}:description`
232
+ }),
233
+ getItemsProps: () => normalize.element(part("items")),
234
+ getItemState: (props) => {
235
+ const item = resolve(props);
236
+ return {
237
+ selected: values.includes(item.value),
238
+ disabled: isDisabled(service, item),
239
+ readOnly: !!service.prop("readOnly"),
240
+ iconOnly: !!item.iconOnly
241
+ };
242
+ },
243
+ getItemProps: (props) => {
244
+ const item = resolve(props);
245
+ return normalize.label({
246
+ ...part("item"),
247
+ ...data(item),
248
+ htmlFor: inputId(service.scope, item.value)
249
+ });
250
+ },
251
+ getInputProps(props) {
252
+ const item = resolve(props), disabled = isDisabled(service, item);
253
+ return normalize.input({
254
+ ...part("input"),
255
+ ...data(item),
256
+ id: inputId(service.scope, item.value),
257
+ type: single ? "radio" : "checkbox",
258
+ value: item.value,
259
+ checked: values.includes(item.value),
260
+ disabled: !!service.prop("disabled") || !!item.disabled,
261
+ readOnly: !!service.prop("readOnly"),
262
+ name: disabled ? void 0 : service.prop("name") || (single ? service.scope.id : void 0),
263
+ form: service.prop("form"),
264
+ required: single ? !!service.prop("required") && !disabled : requiredAnchor === item.value,
265
+ tabIndex: single ? tabAnchor?.value === item.value ? 0 : -1 : 0,
266
+ "aria-checked": values.includes(item.value),
267
+ "aria-readonly": !single && service.prop("readOnly") || void 0,
268
+ "aria-invalid": service.prop("invalid") || void 0,
269
+ "aria-labelledby": `${id}:text:${selectionItemKey(item.value)}`,
270
+ "aria-describedby": item.description ? `${id}:description:${selectionItemKey(item.value)}` : void 0,
271
+ style: visuallyHiddenStyle,
272
+ onChange() {},
273
+ onFocus() {
274
+ service.send({
275
+ type: "FOCUS",
276
+ value: item.value
277
+ });
278
+ },
279
+ onClick(event) {
280
+ if (event.defaultPrevented) return;
281
+ if (!changeFor(service, item.value)) event.preventDefault();
282
+ service.send({
283
+ type: "VALUE.TOGGLE",
284
+ value: item.value
285
+ });
286
+ queueMicrotask(() => sync(service));
287
+ },
288
+ onKeyDown(event) {
289
+ if (event.defaultPrevented || event.ctrlKey || event.altKey || event.metaKey) return;
290
+ if (event.key === " " || event.key === "Enter") {
291
+ event.preventDefault();
292
+ if (!event.repeat) service.send({
293
+ type: "VALUE.TOGGLE",
294
+ value: item.value
295
+ });
296
+ queueMicrotask(() => sync(service));
297
+ return;
298
+ }
299
+ if (![
300
+ "ArrowLeft",
301
+ "ArrowRight",
302
+ "ArrowUp",
303
+ "ArrowDown",
304
+ "Home",
305
+ "End"
306
+ ].includes(event.key)) return;
307
+ event.preventDefault();
308
+ const candidates = service.prop("items").filter((entry) => !isDisabled(service, entry));
309
+ if (!candidates.length || isDisabled(service, item)) return;
310
+ const direction = service.prop("dir");
311
+ const key = getEventKey(event, { dir: direction === "rtl" || direction === "ltr" ? direction : getComputedStyle(event.currentTarget).direction === "rtl" ? "rtl" : "ltr" }), index = candidates.findIndex((entry) => entry.value === item.value);
312
+ let target = key === "Home" ? 0 : key === "End" ? candidates.length - 1 : index + (key === "ArrowRight" || key === "ArrowDown" ? 1 : -1);
313
+ if (service.prop("loop")) target = (target + candidates.length) % candidates.length;
314
+ const next = candidates[target];
315
+ if (!next) return;
316
+ service.scope.getById(inputId(service.scope, next.value))?.focus();
317
+ service.send({
318
+ type: "FOCUS",
319
+ value: next.value
320
+ });
321
+ if (service.prop("selectionMode") === "single" && service.prop("selectOnFocus")) service.send({
322
+ type: "VALUE.SELECT",
323
+ value: next.value
324
+ });
325
+ }
326
+ });
327
+ },
328
+ getContentProps: (props) => normalize.element({
329
+ ...part("content"),
330
+ ...data(resolve(props))
331
+ }),
332
+ getItemIconProps: (props) => {
333
+ const item = resolve(props);
334
+ return normalize.element({
335
+ ...part("icon"),
336
+ hidden: !item.icon,
337
+ "aria-hidden": true
338
+ });
339
+ },
340
+ getItemIconState: (props) => {
341
+ const item = resolve(props);
342
+ return resolveIconState({
343
+ id: `${id}:icon:${selectionItemKey(item.value)}`,
344
+ name: item.icon || "component"
345
+ });
346
+ },
347
+ getTextProps: (props) => {
348
+ const item = resolve(props);
349
+ return normalize.element({
350
+ ...part("text"),
351
+ id: `${id}:text:${selectionItemKey(item.value)}`,
352
+ style: item.iconOnly ? visuallyHiddenStyle : void 0
353
+ });
354
+ },
355
+ getItemDescriptionProps: (props) => {
356
+ const item = resolve(props);
357
+ return normalize.element({
358
+ ...part("item-description"),
359
+ id: `${id}:description:${selectionItemKey(item.value)}`
360
+ });
361
+ }
362
+ };
363
+ }
364
+ //#endregion
365
+ export { createSegmentedProps as a, segmentedMachine as c, connect as i, SEGMENTED_PARTS as n, normalizeSegmentedItems as o, SEGMENTED_SIZES as r, normalizeSegmentedValue as s, SEGMENTED_MODES as t };
366
+
367
+ //# sourceMappingURL=segmented-BaU38_L4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"segmented-BaU38_L4.js","names":[],"sources":["../src/segmented/segmented.ts"],"sourcesContent":["import { mergeDescriptionIds } from \"../aria-description.js\";\nimport { createMachine, type Machine, type Params, type Service } from \"@zag-js/core\";\nimport { dataAttr, getComputedStyle, getEventKey, visuallyHiddenStyle } from \"@zag-js/dom-query\";\nimport type { NormalizeProps, PropTypes } from \"@zag-js/types\";\nimport { normalizeSelectionItems, normalizeSelectionValue, selectionItemKey, toggleSelectionValue, type QwSelectionItem } from \"../selection.js\";\nimport { syncSelectionInputs, trackSelectionForm } from \"../selection-form.js\";\nimport { resolveIconState, type IconNameInput, type IconState } from \"../icon/index.js\";\n\n/** Supported single/multiple selection modes. */\nexport const SEGMENTED_MODES = [\"single\", \"multiple\"] as const;\n/** Existing T3 control-height sizes; large is the mobile default. */\nexport const SEGMENTED_SIZES = [\"sm\", \"md\", \"lg\"] as const;\n/** Stable DOM parts shared by every adapter. */\nexport const SEGMENTED_PARTS = [\"root\", \"label\", \"description\", \"items\", \"item\", \"input\", \"content\", \"icon\", \"text\", \"item-description\"] as const;\nexport type SegmentedSelectionMode = (typeof SEGMENTED_MODES)[number];\nexport type SegmentedSize = (typeof SEGMENTED_SIZES)[number];\n/** Accessible option name remains required even in icon-only presentation. */\nexport interface QwSegmentedItem extends QwSelectionItem { icon?: IconNameInput; iconOnly?: boolean }\n/** Requested ordered values; callers receive independent snapshots. */\nexport interface SegmentedValueChangeDetails { value: string[] }\n/** SSR-safe input shared by all adapters. */\nexport interface QwSegmentedProps {\n id?: string;\n /** Visible, nonempty accessible group name rendered as legend. */\n label: string;\n description?: string;\n /** External Field help/error references, merged with the control-owned description. */\n describedBy?: string;\n /** Unique nonempty values and nonempty accessible labels. */\n items: QwSegmentedItem[];\n selectionMode?: SegmentedSelectionMode;\n /** Defined arrays, including [], are controlled. Unknown values are retained. */\n value?: string[];\n /** Initial value and form reset target; defaults to []. */\n defaultValue?: string[];\n /** Allow a selected single item to toggle off; defaults false. */\n allowEmpty?: boolean;\n /** Minimum/maximum apply only to multiple-mode user removals/additions. */\n min?: number;\n max?: number;\n disabled?: boolean;\n /** Block user selection while retaining focus and native submitted values. */\n readOnly?: boolean;\n /** Native form validation requires an enabled rendered selection. */\n required?: boolean;\n invalid?: boolean;\n name?: string;\n form?: string;\n orientation?: \"horizontal\" | \"vertical\";\n /** Standard HTML direction; auto/empty inherit the input's direction. */\n dir?: string;\n /** Keyboard navigation wraps by default. */\n loop?: boolean;\n /** Single-mode arrow/Home/End selection; defaults true. Multiple only focuses. */\n selectOnFocus?: boolean;\n size?: SegmentedSize;\n block?: boolean;\n /** Horizontal content scrolls with intrinsic option widths. */\n scrollable?: boolean;\n onValueChange?: (details: SegmentedValueChangeDetails) => void;\n}\nexport interface QwSegmentedSchema {\n props: QwSegmentedProps & { selectionMode: SegmentedSelectionMode; defaultValue: string[]; orientation: \"horizontal\" | \"vertical\"; loop: boolean; selectOnFocus: boolean; size: SegmentedSize };\n context: { value: string[]; focusedValue: string | null; disabledIds: string[] };\n state: \"ready\";\n action: \"setValue\" | \"toggleValue\" | \"selectValue\" | \"setFocus\" | \"syncInputs\" | \"normalizeMode\";\n effect: \"trackForm\";\n event: { type: \"VALUE.SET\"; value: string[] } | { type: \"VALUE.TOGGLE\" | \"VALUE.SELECT\" | \"FOCUS\"; value: string };\n}\nexport type QwSegmentedMachine = Machine<QwSegmentedSchema>;\nexport type QwSegmentedService = Service<QwSegmentedSchema>;\nexport interface QwSegmentedItemProps { value: string }\nexport interface QwSegmentedItemState { selected: boolean; disabled: boolean; readOnly: boolean; iconOnly: boolean }\n\n/** Validate accessible identities and copy every caller option. */\nexport function normalizeSegmentedItems(items: readonly QwSegmentedItem[]): QwSegmentedItem[] {\n return normalizeSelectionItems(items).map((entry) => {\n const item = entry as QwSegmentedItem;\n if (typeof item.label !== \"string\" || !item.label.trim()) throw new TypeError(\"Segmented item labels must be nonempty accessible text\");\n if (item.icon !== undefined && typeof item.icon !== \"string\") throw new TypeError(\"Segmented icons must be system icon names\");\n if (item.iconOnly && !item.icon?.trim()) throw new TypeError(\"Segmented icon-only items require an icon and accessible label\");\n return { ...item };\n });\n}\n/** Single selection retains the earliest unique caller value, including unknowns. */\nexport function normalizeSegmentedValue(value: readonly string[] = [], mode: SegmentedSelectionMode = \"single\"): string[] {\n const values = normalizeSelectionValue(value);\n return mode === \"single\" ? values.slice(0, 1) : values;\n}\nexport function createSegmentedProps(props: QwSegmentedProps): Partial<QwSegmentedSchema[\"props\"]> {\n if (typeof props.label !== \"string\" || !props.label.trim()) throw new TypeError(\"Segmented requires a nonempty accessible group label\");\n if (props.id !== undefined && (typeof props.id !== \"string\" || !props.id.trim())) throw new TypeError(\"Segmented requires a nonempty instance id when provided\");\n const selectionMode = SEGMENTED_MODES.includes(props.selectionMode!) ? props.selectionMode! : \"single\";\n return { ...props, selectionMode, items: normalizeSegmentedItems(props.items), value: props.value === undefined ? undefined : normalizeSegmentedValue(props.value, selectionMode), defaultValue: normalizeSegmentedValue(props.defaultValue, selectionMode),\n orientation: props.orientation === \"vertical\" ? \"vertical\" : \"horizontal\", loop: props.loop ?? true, selectOnFocus: props.selectOnFocus ?? true, size: SEGMENTED_SIZES.includes(props.size!) ? props.size! : \"md\" };\n}\nconst same = (a: string[], b: string[] | undefined) => !!b && a.length === b.length && a.every((value, index) => value === b[index]);\nconst rootId = (scope: QwSegmentedService[\"scope\"]) => `segmented:${scope.id}`;\nconst inputId = (scope: QwSegmentedService[\"scope\"], value: string) => `${rootId(scope)}:input:${selectionItemKey(value)}`;\ntype GroupParams = Pick<Params<QwSegmentedSchema>, \"scope\" | \"context\" | \"prop\">;\nfunction currentValue(params: GroupParams) { return normalizeSegmentedValue(params.context.get(\"value\"), params.prop(\"selectionMode\")); }\nfunction isDisabled(params: GroupParams, item: QwSegmentedItem) { return !!params.prop(\"disabled\") || !!item.disabled || params.context.get(\"disabledIds\").includes(inputId(params.scope, item.value)); }\nfunction sync(params: GroupParams) {\n const values = currentValue(params);\n syncSelectionInputs(params.scope, params.prop(\"items\").map((item) => ({ id: inputId(params.scope, item.value), checked: values.includes(item.value) })));\n}\nfunction changeFor(params: GroupParams, value: string, selectOnly = false): string[] | null {\n const item = params.prop(\"items\").find((entry) => entry.value === value);\n if (!item || isDisabled(params, item) || params.prop(\"readOnly\")) return null;\n const values = currentValue(params);\n if (params.prop(\"selectionMode\") === \"single\") return values.includes(value) ? (!selectOnly && params.prop(\"allowEmpty\") ? [] : values) : [value];\n const result = toggleSelectionValue(values, item, { min: params.prop(\"min\"), max: params.prop(\"max\") });\n return result.blocked ? null : result.value;\n}\n\n/** One Zag bindable lifecycle; Core alone owns selection, keys and native forms. */\nexport const segmentedMachine: QwSegmentedMachine = createMachine<QwSegmentedSchema>({\n props: ({ props }) => createSegmentedProps({ ...props, label: props.label ?? \"\", items: props.items ?? [] }) as QwSegmentedSchema[\"props\"],\n initialState: () => \"ready\",\n context({ prop, bindable }) {\n return {\n value: bindable(() => ({ defaultValue: prop(\"defaultValue\"), value: prop(\"value\"), isEqual: same, onChange: (value) => prop(\"onValueChange\")?.({ value: [...value] }) })),\n focusedValue: bindable(() => ({ defaultValue: null as string | null })),\n disabledIds: bindable(() => ({ defaultValue: [] as string[], isEqual: same })),\n };\n },\n watch({ track, context, prop, action }) {\n track([() => context.hash(\"value\"), () => context.hash(\"disabledIds\")], () => action([\"syncInputs\"]));\n track([() => prop(\"selectionMode\")], () => action([\"normalizeMode\"]));\n },\n effects: [\"trackForm\"],\n on: { \"VALUE.SET\": { actions: [\"setValue\"] }, \"VALUE.TOGGLE\": { actions: [\"toggleValue\"] }, \"VALUE.SELECT\": { actions: [\"selectValue\"] }, FOCUS: { actions: [\"setFocus\"] } },\n states: { ready: {} },\n implementations: {\n effects: { trackForm(params) {\n return trackSelectionForm({ scope: params.scope, rootId: rootId(params.scope), form: () => params.prop(\"form\"),\n getState: () => params.prop(\"items\").map((item) => ({ id: inputId(params.scope, item.value), checked: currentValue(params).includes(item.value) })),\n onReset: () => params.context.set(\"value\", normalizeSegmentedValue(params.prop(\"defaultValue\"), params.prop(\"selectionMode\"))),\n onDisabledChange: (ids) => params.context.set(\"disabledIds\", [...ids]),\n }).stop;\n } },\n actions: {\n syncInputs: sync,\n normalizeMode(params) { params.context.set(\"value\", currentValue(params)); queueMicrotask(() => sync(params)); },\n setValue(params) { if (params.event.type === \"VALUE.SET\") params.context.set(\"value\", normalizeSegmentedValue(params.event.value, params.prop(\"selectionMode\"))); queueMicrotask(() => sync(params)); },\n toggleValue(params) { if (params.event.type === \"VALUE.TOGGLE\") { const values = changeFor(params, params.event.value); if (values) params.context.set(\"value\", values); } queueMicrotask(() => sync(params)); },\n selectValue(params) { if (params.event.type === \"VALUE.SELECT\") { const values = changeFor(params, params.event.value, true); if (values) params.context.set(\"value\", values); } queueMicrotask(() => sync(params)); },\n setFocus(params) { if (params.event.type === \"FOCUS\") params.context.set(\"focusedValue\", params.event.value); },\n },\n },\n});\n\nexport interface QwSegmentedApi<T extends PropTypes = PropTypes> {\n value: string[]; items: QwSegmentedItem[]; label: string; description: string;\n setValue(value: string[]): void;\n toggleValue(value: string): void;\n getRootProps(): T[\"element\"];\n getLabelProps(): T[\"element\"];\n getDescriptionProps(): T[\"element\"];\n getItemsProps(): T[\"element\"];\n getItemState(item: QwSegmentedItemProps): QwSegmentedItemState;\n getItemProps(item: QwSegmentedItemProps): T[\"label\"];\n getInputProps(item: QwSegmentedItemProps): T[\"input\"];\n getContentProps(item: QwSegmentedItemProps): T[\"element\"];\n getItemIconProps(item: QwSegmentedItemProps): T[\"element\"];\n getItemIconState(item: QwSegmentedItemProps): IconState;\n getTextProps(item: QwSegmentedItemProps): T[\"element\"];\n getItemDescriptionProps(item: QwSegmentedItemProps): T[\"element\"];\n}\n/** Getters are SSR-pure; only client events/effects use the existing Zag DOM scope. */\nexport function connect<T extends PropTypes>(service: QwSegmentedService, normalize: NormalizeProps<T>): QwSegmentedApi<T> {\n const id = rootId(service.scope), values = currentValue(service), items = service.prop(\"items\");\n const single = service.prop(\"selectionMode\") === \"single\";\n const enabled = items.filter((item) => !isDisabled(service, item));\n const focused = service.context.get(\"focusedValue\");\n const tabAnchor = enabled.find((item) => item.value === focused) ?? enabled.find((item) => values.includes(item.value)) ?? enabled[0];\n const requiredAnchor = service.prop(\"required\") && !enabled.some((item) => values.includes(item.value)) ? enabled[0]?.value : undefined;\n const resolve = ({ value }: QwSegmentedItemProps) => { const item = items.find((entry) => entry.value === value); if (!item) throw new RangeError(\"Segmented item is not present in items\"); return item; };\n const part = (name: string) => ({ \"data-scope\": \"segmented\", \"data-part\": name });\n const data = (item: QwSegmentedItem) => ({ \"data-state\": values.includes(item.value) ? \"checked\" : \"unchecked\", \"data-disabled\": dataAttr(isDisabled(service, item)), \"data-readonly\": dataAttr(service.prop(\"readOnly\")), \"data-invalid\": dataAttr(service.prop(\"invalid\")), \"data-icon-only\": dataAttr(item.iconOnly) });\n return {\n value: [...values], items: items.map((item) => ({ ...item })), label: service.prop(\"label\"), description: service.prop(\"description\") ?? \"\",\n setValue: (value) => service.send({ type: \"VALUE.SET\", value: normalizeSegmentedValue(value, service.prop(\"selectionMode\")) }),\n toggleValue: (value) => service.send({ type: \"VALUE.TOGGLE\", value }),\n getRootProps: () => normalize.element({ ...part(\"root\"), id, role: single ? \"radiogroup\" : \"group\", disabled: !!service.prop(\"disabled\"), form: service.prop(\"form\"), dir: service.prop(\"dir\"),\n \"aria-labelledby\": `${id}:label`, \"aria-describedby\": mergeDescriptionIds(service.prop(\"description\") ? `${id}:description` : undefined, service.prop(\"describedBy\")),\n \"aria-required\": single && service.prop(\"required\") || undefined, \"aria-readonly\": single && service.prop(\"readOnly\") || undefined,\n \"aria-disabled\": service.prop(\"disabled\") || (items.length > 0 && !enabled.length) || undefined, \"aria-invalid\": service.prop(\"invalid\") || undefined,\n \"data-selection-mode\": service.prop(\"selectionMode\"), \"data-orientation\": service.prop(\"orientation\"), \"data-size\": service.prop(\"size\"),\n \"data-block\": dataAttr(service.prop(\"block\")), \"data-scrollable\": dataAttr(service.prop(\"scrollable\")), \"data-disabled\": dataAttr(service.prop(\"disabled\")), \"data-readonly\": dataAttr(service.prop(\"readOnly\")), \"data-invalid\": dataAttr(service.prop(\"invalid\")) }),\n getLabelProps: () => normalize.element({ ...part(\"label\"), id: `${id}:label` }),\n getDescriptionProps: () => normalize.element({ ...part(\"description\"), id: `${id}:description` }),\n getItemsProps: () => normalize.element(part(\"items\")),\n getItemState: (props) => { const item = resolve(props); return { selected: values.includes(item.value), disabled: isDisabled(service, item), readOnly: !!service.prop(\"readOnly\"), iconOnly: !!item.iconOnly }; },\n getItemProps: (props) => { const item = resolve(props); return normalize.label({ ...part(\"item\"), ...data(item), htmlFor: inputId(service.scope, item.value) }); },\n getInputProps(props) {\n const item = resolve(props), disabled = isDisabled(service, item);\n return normalize.input({ ...part(\"input\"), ...data(item), id: inputId(service.scope, item.value), type: single ? \"radio\" : \"checkbox\", value: item.value,\n checked: values.includes(item.value), disabled: !!service.prop(\"disabled\") || !!item.disabled, readOnly: !!service.prop(\"readOnly\"),\n name: disabled ? undefined : service.prop(\"name\") || (single ? service.scope.id : undefined), form: service.prop(\"form\"),\n required: single ? !!service.prop(\"required\") && !disabled : requiredAnchor === item.value, tabIndex: single ? (tabAnchor?.value === item.value ? 0 : -1) : 0,\n \"aria-checked\": values.includes(item.value), \"aria-readonly\": !single && service.prop(\"readOnly\") || undefined, \"aria-invalid\": service.prop(\"invalid\") || undefined,\n \"aria-labelledby\": `${id}:text:${selectionItemKey(item.value)}`, \"aria-describedby\": item.description ? `${id}:description:${selectionItemKey(item.value)}` : undefined,\n style: visuallyHiddenStyle, onChange() {},\n onFocus() { service.send({ type: \"FOCUS\", value: item.value }); },\n onClick(event) {\n if (event.defaultPrevented) return;\n if (!changeFor(service, item.value)) event.preventDefault();\n service.send({ type: \"VALUE.TOGGLE\", value: item.value }); queueMicrotask(() => sync(service));\n },\n onKeyDown(event) {\n if (event.defaultPrevented || event.ctrlKey || event.altKey || event.metaKey) return;\n if (event.key === \" \" || event.key === \"Enter\") { event.preventDefault(); if (!event.repeat) service.send({ type: \"VALUE.TOGGLE\", value: item.value }); queueMicrotask(() => sync(service)); return; }\n if (![\"ArrowLeft\", \"ArrowRight\", \"ArrowUp\", \"ArrowDown\", \"Home\", \"End\"].includes(event.key)) return;\n event.preventDefault();\n const candidates = service.prop(\"items\").filter((entry) => !isDisabled(service, entry));\n if (!candidates.length || isDisabled(service, item)) return;\n const direction = service.prop(\"dir\");\n const dir = direction === \"rtl\" || direction === \"ltr\" ? direction : getComputedStyle(event.currentTarget).direction === \"rtl\" ? \"rtl\" : \"ltr\";\n const key = getEventKey(event, { dir }), index = candidates.findIndex((entry) => entry.value === item.value);\n let target = key === \"Home\" ? 0 : key === \"End\" ? candidates.length - 1 : index + (key === \"ArrowRight\" || key === \"ArrowDown\" ? 1 : -1);\n if (service.prop(\"loop\")) target = (target + candidates.length) % candidates.length;\n const next = candidates[target]; if (!next) return;\n service.scope.getById<HTMLInputElement>(inputId(service.scope, next.value))?.focus();\n service.send({ type: \"FOCUS\", value: next.value });\n if (service.prop(\"selectionMode\") === \"single\" && service.prop(\"selectOnFocus\")) service.send({ type: \"VALUE.SELECT\", value: next.value });\n },\n });\n },\n getContentProps: (props) => normalize.element({ ...part(\"content\"), ...data(resolve(props)) }),\n getItemIconProps: (props) => { const item = resolve(props); return normalize.element({ ...part(\"icon\"), hidden: !item.icon, \"aria-hidden\": true }); },\n getItemIconState: (props) => { const item = resolve(props); return resolveIconState({ id: `${id}:icon:${selectionItemKey(item.value)}`, name: item.icon || \"component\" }); },\n getTextProps: (props) => { const item = resolve(props); return normalize.element({ ...part(\"text\"), id: `${id}:text:${selectionItemKey(item.value)}`, style: item.iconOnly ? visuallyHiddenStyle : undefined }); },\n getItemDescriptionProps: (props) => { const item = resolve(props); return normalize.element({ ...part(\"item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sB,KAAA;GAAU,CAAC;EAAG;EACjN,0BAA0B,UAAU;GAAE,MAAM,OAAO,QAAQ,KAAK;GAAG,OAAO,UAAU,QAAQ;IAAE,GAAG,KAAK,kBAAkB;IAAG,IAAI,GAAG,GAAG,eAAe,iBAAiB,KAAK,KAAK;GAAI,CAAC;EAAG;CACzL;AACF"}
@@ -0,0 +1,88 @@
1
+ import { addDomEvent, getAncestorElements, getNodeName, isHTMLElement, isInputElement, observeAttributes, observeChildren, queryAll, setProperty } from "@zag-js/dom-query";
2
+ //#region src/selection-form.ts
3
+ /** Assign properties through Zag; do not overwrite native defaultChecked. */
4
+ function syncSelectionInputs(scope, states) {
5
+ for (const state of states) {
6
+ const input = scope.getById(state.id);
7
+ if (!isInputElement(input)) continue;
8
+ setProperty(input, "checked", state.checked);
9
+ setProperty(input, "indeterminate", state.indeterminate ?? false);
10
+ }
11
+ }
12
+ /** All listeners belong to one machine lifecycle, including deferred reset work. */
13
+ function trackSelectionForm(options) {
14
+ let stopped = false;
15
+ let refreshQueued = false;
16
+ let disabledIds;
17
+ const cleanups = [];
18
+ const pendingResets = /* @__PURE__ */ new Set();
19
+ const release = () => {
20
+ cleanups.splice(0).forEach((cleanup) => cleanup());
21
+ };
22
+ const sync = () => {
23
+ if (!stopped) syncSelectionInputs(options.scope, options.getState());
24
+ };
25
+ const queueRefresh = () => {
26
+ if (stopped || refreshQueued) return;
27
+ refreshQueued = true;
28
+ queueMicrotask(() => {
29
+ refreshQueued = false;
30
+ refresh();
31
+ });
32
+ };
33
+ const reportDisabled = () => {
34
+ const nativeDisabled = new Set(queryAll(options.scope.getRootNode(), "input:disabled"));
35
+ const next = options.getState().filter((state) => nativeDisabled.has(options.scope.getById(state.id))).map((state) => state.id);
36
+ if (disabledIds?.length === next.length && disabledIds.every((id, index) => id === next[index])) return;
37
+ disabledIds = next;
38
+ options.onDisabledChange([...next]);
39
+ };
40
+ function refresh() {
41
+ if (stopped) return;
42
+ release();
43
+ const inputs = options.getState().map((state) => options.scope.getById(state.id)).filter(isInputElement);
44
+ const root = options.scope.getById(options.rootId);
45
+ const anchor = inputs[0] ?? root;
46
+ const ancestors = anchor ? getAncestorElements(anchor) : [];
47
+ const formId = options.form?.();
48
+ const form = formId !== void 0 ? options.scope.getById(formId) : inputs.length ? inputs[0].form : ancestors.find((element) => getNodeName(element) === "form");
49
+ if (form && getNodeName(form) === "form") cleanups.push(addDomEvent(form, "reset", (event) => {
50
+ const pending = setTimeout(() => {
51
+ pendingResets.delete(pending);
52
+ if (stopped || event.defaultPrevented) return;
53
+ options.onReset();
54
+ sync();
55
+ reportDisabled();
56
+ }, 0);
57
+ pendingResets.add(pending);
58
+ }));
59
+ const fieldsets = new Set(inputs.flatMap((input) => getAncestorElements(input)).filter((element) => isHTMLElement(element) && getNodeName(element) === "fieldset"));
60
+ for (const fieldset of fieldsets) cleanups.push(observeAttributes(fieldset, {
61
+ attributes: ["disabled"],
62
+ callback: queueRefresh
63
+ }));
64
+ for (const input of inputs) cleanups.push(observeAttributes(input, {
65
+ attributes: ["disabled", "form"],
66
+ callback: queueRefresh
67
+ }));
68
+ const roots = new Set([root, root ? getAncestorElements(root)[1] : void 0].filter(isHTMLElement));
69
+ for (const node of roots) cleanups.push(observeChildren(node, { callback: queueRefresh }));
70
+ sync();
71
+ reportDisabled();
72
+ }
73
+ refresh();
74
+ return {
75
+ sync,
76
+ refresh,
77
+ stop() {
78
+ stopped = true;
79
+ release();
80
+ pendingResets.forEach(clearTimeout);
81
+ pendingResets.clear();
82
+ }
83
+ };
84
+ }
85
+ //#endregion
86
+ export { trackSelectionForm as n, syncSelectionInputs as t };
87
+
88
+ //# sourceMappingURL=selection-form-BOM_odUk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selection-form-BOM_odUk.js","names":[],"sources":["../src/selection-form.ts"],"sourcesContent":["import { addDomEvent, getAncestorElements, getNodeName, isHTMLElement, isInputElement, observeAttributes, observeChildren, queryAll, setProperty } from \"@zag-js/dom-query\";\n\n/** Client effects receive a Zag scope; imports and SSR getters never create one. */\nexport interface SelectionFormScope {\n getRootNode(): Document | Element | ShadowRoot;\n getById<T extends Element = HTMLElement>(id: string): T | null;\n}\nexport interface SelectionNativeState { id: string; checked: boolean; indeterminate?: boolean }\nexport interface SelectionFormOptions {\n scope: SelectionFormScope;\n rootId: string;\n getState(): readonly SelectionNativeState[];\n form?: () => string | undefined;\n onReset(): void;\n onDisabledChange(ids: readonly string[]): void;\n}\nexport interface SelectionFormTracker { sync(): void; refresh(): void; stop(): void }\n\n/** Assign properties through Zag; do not overwrite native defaultChecked. */\nexport function syncSelectionInputs(scope: SelectionFormScope, states: readonly SelectionNativeState[]): void {\n for (const state of states) {\n const input = scope.getById<HTMLInputElement>(state.id);\n if (!isInputElement(input)) continue;\n setProperty(input, \"checked\", state.checked);\n setProperty(input, \"indeterminate\", state.indeterminate ?? false);\n }\n}\n\n/** All listeners belong to one machine lifecycle, including deferred reset work. */\nexport function trackSelectionForm(options: SelectionFormOptions): SelectionFormTracker {\n let stopped = false;\n let refreshQueued = false;\n let disabledIds: string[] | undefined;\n const cleanups: Array<() => void> = [];\n const pendingResets = new Set<ReturnType<typeof setTimeout>>();\n const release = () => { cleanups.splice(0).forEach((cleanup) => cleanup()); };\n const sync = () => { if (!stopped) syncSelectionInputs(options.scope, options.getState()); };\n const queueRefresh = () => {\n if (stopped || refreshQueued) return;\n refreshQueued = true;\n queueMicrotask(() => { refreshQueued = false; refresh(); });\n };\n const reportDisabled = () => {\n const nativeDisabled = new Set(queryAll(options.scope.getRootNode(), \"input:disabled\"));\n const next = options.getState().filter((state) => nativeDisabled.has(options.scope.getById(state.id)!)).map((state) => state.id);\n if (disabledIds?.length === next.length && disabledIds.every((id, index) => id === next[index])) return;\n disabledIds = next;\n options.onDisabledChange([...next]);\n };\n function refresh() {\n if (stopped) return;\n release();\n const inputs = options.getState().map((state) => options.scope.getById<HTMLInputElement>(state.id)).filter(isInputElement);\n const root = options.scope.getById(options.rootId);\n const anchor = inputs[0] ?? root;\n const ancestors = anchor ? getAncestorElements(anchor) : [];\n const formId = options.form?.();\n const form = formId !== undefined ? options.scope.getById(formId) : inputs.length ? inputs[0]!.form : ancestors.find((element) => getNodeName(element) === \"form\");\n if (form && getNodeName(form) === \"form\") {\n cleanups.push(addDomEvent(form, \"reset\", (event) => {\n // Native button dispatch can checkpoint microtasks before a later canceling listener.\n const pending = setTimeout(() => {\n pendingResets.delete(pending);\n if (stopped || event.defaultPrevented) return;\n options.onReset();\n sync();\n reportDisabled();\n }, 0);\n pendingResets.add(pending);\n }));\n }\n const fieldsets = new Set(inputs.flatMap((input) => getAncestorElements(input)).filter((element): element is HTMLElement => isHTMLElement(element) && getNodeName(element) === \"fieldset\"));\n for (const fieldset of fieldsets) cleanups.push(observeAttributes(fieldset, { attributes: [\"disabled\"], callback: queueRefresh }));\n for (const input of inputs) cleanups.push(observeAttributes(input, { attributes: [\"disabled\", \"form\"], callback: queueRefresh }));\n // Observe the rendered subtree and its parent so list changes/reparenting rebind.\n const roots = new Set([root, root ? getAncestorElements(root)[1] : undefined].filter(isHTMLElement));\n for (const node of roots) cleanups.push(observeChildren(node, { callback: queueRefresh }));\n sync();\n reportDisabled();\n }\n refresh();\n return { sync, refresh, stop() { stopped = true; release(); pendingResets.forEach(clearTimeout); pendingResets.clear(); } };\n}\n"],"mappings":";;;AAmBA,SAAgB,oBAAoB,OAA2B,QAA+C;CAC5G,KAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,QAAQ,MAAM,QAA0B,MAAM,EAAE;EACtD,IAAI,CAAC,eAAe,KAAK,GAAG;EAC5B,YAAY,OAAO,WAAW,MAAM,OAAO;EAC3C,YAAY,OAAO,iBAAiB,MAAM,iBAAiB,KAAK;CAClE;AACF;;AAGA,SAAgB,mBAAmB,SAAqD;CACtF,IAAI,UAAU;CACd,IAAI,gBAAgB;CACpB,IAAI;CACJ,MAAM,WAA8B,CAAC;CACrC,MAAM,gCAAgB,IAAI,IAAmC;CAC7D,MAAM,gB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,UAAU;GAElD,MAAM,UAAU,iBAAiB;IAC/B,cAAc,OAAO,OAAO;IAC5B,IAAI,WAAW,MAAM,kBAAkB;IACvC,QAAQ,QAAQ;IAChB,KAAK;IACL,eAAe;GACjB,GAAG,CAAC;GACJ,cAAc,IAAI,OAAO;EAC3B,CAAC,CAAC;EAEJ,MAAM,YAAY,IAAI,IAAI,OAAO,SAAS,UAAU,oBAAoB,KAAK,CAAC,CAAC,CAAC,QAAQ,YAAoC,cAAc,OAAO,KAAK,YAAY,OAAO,MAAM,UAAU,CAAC;EAC1L,KAAK,MAAM,YAAY,WAAW,SAAS,KAAK,kBAAkB,UAAU;GAAE,YAAY,CAAC,UAAU;GAAG,UAAU;EAAa,CAAC,CAAC;EACjI,KAAK,MAAM,SAAS,QAAQ,SAAS,KAAK,kBAAkB,OAAO;GAAE,YAAY,CAAC,YAAY,MAAM;GAAG,UAAU;EAAa,CAAC,CAAC;EAEhI,MAAM,QAAQ,IAAI,IAAI,CAAC,MAAM,OAAO,oBAAoB,IAAI,CAAC,CAAC,KAAK,KAAA,CAAS,CAAC,CAAC,OAAO,aAAa,CAAC;EACnG,KAAK,MAAM,QAAQ,OAAO,SAAS,KAAK,gBAAgB,MAAM,EAAE,UAAU,aAAa,CAAC,CAAC;EACzF,KAAK;EACL,eAAe;CACjB;CACA,QAAQ;CACR,OAAO;EAAE;EAAM;EAAS,OAAO;GAAE,UAAU;GAAM,QAAQ;GAAG,cAAc,QAAQ,YAAY;GAAG,cAAc,MAAM;EAAG;CAAE;AAC5H"}
@@ -0,0 +1,27 @@
1
+ /** Client effects receive a Zag scope; imports and SSR getters never create one. */
2
+ export interface SelectionFormScope {
3
+ getRootNode(): Document | Element | ShadowRoot;
4
+ getById<T extends Element = HTMLElement>(id: string): T | null;
5
+ }
6
+ export interface SelectionNativeState {
7
+ id: string;
8
+ checked: boolean;
9
+ indeterminate?: boolean;
10
+ }
11
+ export interface SelectionFormOptions {
12
+ scope: SelectionFormScope;
13
+ rootId: string;
14
+ getState(): readonly SelectionNativeState[];
15
+ form?: () => string | undefined;
16
+ onReset(): void;
17
+ onDisabledChange(ids: readonly string[]): void;
18
+ }
19
+ export interface SelectionFormTracker {
20
+ sync(): void;
21
+ refresh(): void;
22
+ stop(): void;
23
+ }
24
+ /** Assign properties through Zag; do not overwrite native defaultChecked. */
25
+ export declare function syncSelectionInputs(scope: SelectionFormScope, states: readonly SelectionNativeState[]): void;
26
+ /** All listeners belong to one machine lifecycle, including deferred reset work. */
27
+ export declare function trackSelectionForm(options: SelectionFormOptions): SelectionFormTracker;
@@ -0,0 +1,55 @@
1
+ //#region src/selection.ts
2
+ function normalizeSelectionItems(items) {
3
+ const seen = /* @__PURE__ */ new Set();
4
+ return items.map((item) => {
5
+ if (typeof item.value !== "string" || item.value.length === 0) throw new TypeError("Selection item values must be non-empty strings");
6
+ if (seen.has(item.value)) throw new TypeError("Selection item values must be unique");
7
+ seen.add(item.value);
8
+ return { ...item };
9
+ });
10
+ }
11
+ function normalizeSelectionValue(value = []) {
12
+ if (value.some((item) => typeof item !== "string" || item.length === 0)) throw new TypeError("Selection values must be non-empty strings");
13
+ return [...new Set(value)];
14
+ }
15
+ function resolveSelectionLimits(min, max) {
16
+ const lower = typeof min === "number" && Number.isFinite(min) ? Math.max(0, Math.floor(min)) : 0;
17
+ return {
18
+ min: lower,
19
+ max: typeof max === "number" && Number.isFinite(max) ? Math.max(lower, Math.floor(max), 0) : Infinity
20
+ };
21
+ }
22
+ /** Caller values are preserved; limits apply only to a user addition/removal. */
23
+ function toggleSelectionValue(value, item, restrictions = {}) {
24
+ const values = normalizeSelectionValue(value);
25
+ const { min, max } = resolveSelectionLimits(restrictions.min, restrictions.max);
26
+ if (restrictions.disabled || item.disabled) return {
27
+ value: values,
28
+ blocked: "disabled"
29
+ };
30
+ if (restrictions.readOnly) return {
31
+ value: values,
32
+ blocked: "readonly"
33
+ };
34
+ const selected = values.includes(item.value);
35
+ if (selected && values.length <= min) return {
36
+ value: values,
37
+ blocked: "min"
38
+ };
39
+ if (!selected && values.length >= max) return {
40
+ value: values,
41
+ blocked: "max"
42
+ };
43
+ return {
44
+ value: selected ? values.filter((entry) => entry !== item.value) : [...values, item.value],
45
+ blocked: null
46
+ };
47
+ }
48
+ /** Injective UTF-16 identity for native item ids, including unmatched surrogates. */
49
+ function selectionItemKey(value) {
50
+ return value.split("").map((unit) => unit.charCodeAt(0).toString(16)).join("-");
51
+ }
52
+ //#endregion
53
+ export { toggleSelectionValue as i, normalizeSelectionValue as n, selectionItemKey as r, normalizeSelectionItems as t };
54
+
55
+ //# sourceMappingURL=selection-ivXqO1eu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"selection-ivXqO1eu.js","names":[],"sources":["../src/selection.ts"],"sourcesContent":["/** Shared identity and value rules for selection machines. */\nexport interface QwSelectionItem {\n value: string;\n label: string;\n description?: string;\n disabled?: boolean;\n}\n\nexport interface SelectionLimits { min: number; max: number }\nexport interface SelectionRestrictions { min?: number; max?: number; disabled?: boolean; readOnly?: boolean }\nexport type SelectionBlockedReason = \"disabled\" | \"readonly\" | \"min\" | \"max\";\nexport interface SelectionChange { value: string[]; blocked: SelectionBlockedReason | null }\n\nexport function normalizeSelectionItems(items: readonly QwSelectionItem[]): QwSelectionItem[] {\n const seen = new Set<string>();\n return items.map((item) => {\n if (typeof item.value !== \"string\" || item.value.length === 0) throw new TypeError(\"Selection item values must be non-empty strings\");\n if (seen.has(item.value)) throw new TypeError(\"Selection item values must be unique\");\n seen.add(item.value);\n return { ...item };\n });\n}\n\nexport function normalizeSelectionValue(value: readonly string[] = []): string[] {\n if (value.some((item) => typeof item !== \"string\" || item.length === 0)) throw new TypeError(\"Selection values must be non-empty strings\");\n return [...new Set(value)];\n}\n\nexport function resolveSelectionLimits(min?: number, max?: number): SelectionLimits {\n const lower = typeof min === \"number\" && Number.isFinite(min) ? Math.max(0, Math.floor(min)) : 0;\n const upper = typeof max === \"number\" && Number.isFinite(max) ? Math.max(lower, Math.floor(max), 0) : Infinity;\n return { min: lower, max: upper };\n}\n\n/** Caller values are preserved; limits apply only to a user addition/removal. */\nexport function toggleSelectionValue(value: readonly string[], item: QwSelectionItem, restrictions: SelectionRestrictions = {}): SelectionChange {\n const values = normalizeSelectionValue(value);\n const { min, max } = resolveSelectionLimits(restrictions.min, restrictions.max);\n if (restrictions.disabled || item.disabled) return { value: values, blocked: \"disabled\" };\n if (restrictions.readOnly) return { value: values, blocked: \"readonly\" };\n const selected = values.includes(item.value);\n if (selected && values.length <= min) return { value: values, blocked: \"min\" };\n if (!selected && values.length >= max) return { value: values, blocked: \"max\" };\n return { value: selected ? values.filter((entry) => entry !== item.value) : [...values, item.value], blocked: null };\n}\n\n/** Injective UTF-16 identity for native item ids, including unmatched surrogates. */\nexport function selectionItemKey(value: string): string {\n return value.split(\"\").map(unit => unit.charCodeAt(0).toString(16)).join(\"-\");\n}\n"],"mappings":";AAaA,SAAgB,wBAAwB,OAAsD;CAC5F,MAAM,uBAAO,IAAI,IAAY;CAC7B,OAAO,MAAM,KAAK,SAAS;EACzB,IAAI,OAAO,KAAK,UAAU,YAAY,KAAK,MAAM,WAAW,GAAG,MAAM,IAAI,UAAU,iDAAiD;EACpI,IAAI,KAAK,IAAI,KAAK,KAAK,GAAG,MAAM,IAAI,UAAU,sCAAsC;EACpF,KAAK,IAAI,KAAK,KAAK;EACnB,OAAO,EAAE,GAAG,KAAK;CACnB,CAAC;AACH;AAEA,SAAgB,wBAAwB,QAA2B,CAAC,GAAa;CAC/E,IAAI,MAAM,MAAM,SAAS,OAAO,SAAS,YAAY,KAAK,WAAW,CAAC,GAAG,MAAM,IAAI,UAAU,4CAA4C;CACzI,OAAO,CAAC,GAAG,IAAI,IAAI,KAAK,CAAC;AAC3B;AAEA,SAAgB,uBAAuB,KAAc,KAA+B;CAClF,MAAM,QAAQ,OAAO,QAAQ,YAAY,OAAO,SAAS,GAAG,IAAI,KAAK,IAAI,GAAG,KAAK,MAAM,GAAG,CAAC,IAAI;CAE/F,OAAO;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