@qw-ui/core 0.3.0-next.40 → 0.3.0-next.43

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 (402) 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 +9 -0
  26. package/dist/badge/index.js +14 -1
  27. package/dist/badge/index.js.map +1 -1
  28. package/dist/button/button.d.ts +13 -0
  29. package/dist/button/index.js +3 -5
  30. package/dist/button/index.js.map +1 -1
  31. package/dist/calendar/calendar.d.ts +100 -0
  32. package/dist/calendar/index.d.ts +1 -0
  33. package/dist/calendar/index.js +2 -0
  34. package/dist/calendar-CmpK3stz.js +363 -0
  35. package/dist/calendar-CmpK3stz.js.map +1 -0
  36. package/dist/card/card.d.ts +68 -0
  37. package/dist/card/index.d.ts +2 -0
  38. package/dist/card/index.js +2 -0
  39. package/dist/card-DRtWa6Cr.js +107 -0
  40. package/dist/card-DRtWa6Cr.js.map +1 -0
  41. package/dist/cascader/cascader.d.ts +115 -0
  42. package/dist/cascader/index.d.ts +1 -0
  43. package/dist/cascader/index.js +2 -0
  44. package/dist/cascader-D-xMjs7P.js +333 -0
  45. package/dist/cascader-D-xMjs7P.js.map +1 -0
  46. package/dist/cell/cell.d.ts +41 -0
  47. package/dist/cell/index.d.ts +1 -0
  48. package/dist/cell/index.js +43 -0
  49. package/dist/cell/index.js.map +1 -0
  50. package/dist/check-list/check-list.d.ts +78 -0
  51. package/dist/check-list/index.d.ts +2 -0
  52. package/dist/check-list/index.js +2 -0
  53. package/dist/check-list-BvZHQt5w.js +60 -0
  54. package/dist/check-list-BvZHQt5w.js.map +1 -0
  55. package/dist/checkbox/checkbox.d.ts +59 -0
  56. package/dist/checkbox/index.d.ts +2 -0
  57. package/dist/checkbox/index.js +2 -0
  58. package/dist/checkbox-BlndJrz5.js +127 -0
  59. package/dist/checkbox-BlndJrz5.js.map +1 -0
  60. package/dist/checkbox-group/checkbox-group.d.ts +86 -0
  61. package/dist/checkbox-group/index.d.ts +3 -0
  62. package/dist/checkbox-group/index.js +2 -0
  63. package/dist/checkbox-group-gGfsTv-e.js +223 -0
  64. package/dist/checkbox-group-gGfsTv-e.js.map +1 -0
  65. package/dist/choice-group-C4c9m0qe.js +373 -0
  66. package/dist/choice-group-C4c9m0qe.js.map +1 -0
  67. package/dist/circle/circle.d.ts +97 -0
  68. package/dist/circle/index.d.ts +1 -0
  69. package/dist/circle/index.js +119 -0
  70. package/dist/circle/index.js.map +1 -0
  71. package/dist/collapse/collapse.d.ts +98 -0
  72. package/dist/collapse/index.d.ts +2 -0
  73. package/dist/collapse/index.js +2 -0
  74. package/dist/collapse-B969h7-H.js +226 -0
  75. package/dist/collapse-B969h7-H.js.map +1 -0
  76. package/dist/countdown/countdown.d.ts +114 -0
  77. package/dist/countdown/index.d.ts +1 -0
  78. package/dist/countdown/index.js +309 -0
  79. package/dist/countdown/index.js.map +1 -0
  80. package/dist/date-picker/date-picker.d.ts +168 -0
  81. package/dist/date-picker/index.d.ts +1 -0
  82. package/dist/date-picker/index.js +401 -0
  83. package/dist/date-picker/index.js.map +1 -0
  84. package/dist/descriptions/descriptions.d.ts +69 -0
  85. package/dist/descriptions/index.d.ts +1 -0
  86. package/dist/descriptions/index.js +86 -0
  87. package/dist/descriptions/index.js.map +1 -0
  88. package/dist/dialog/dialog.d.ts +32 -3
  89. package/dist/dialog/index.js +58 -3
  90. package/dist/dialog/index.js.map +1 -1
  91. package/dist/divider/divider.d.ts +18 -2
  92. package/dist/divider/index.js +20 -2
  93. package/dist/divider/index.js.map +1 -1
  94. package/dist/dropdown/dropdown.d.ts +172 -0
  95. package/dist/dropdown/index.d.ts +2 -0
  96. package/dist/dropdown/index.js +467 -0
  97. package/dist/dropdown/index.js.map +1 -0
  98. package/dist/ellipsis/ellipsis-layout.d.ts +34 -0
  99. package/dist/ellipsis/ellipsis.d.ts +88 -0
  100. package/dist/ellipsis/index.d.ts +2 -0
  101. package/dist/ellipsis/index.js +320 -0
  102. package/dist/ellipsis/index.js.map +1 -0
  103. package/dist/empty/empty-illustration.d.ts +3 -0
  104. package/dist/empty/empty.d.ts +43 -1
  105. package/dist/empty/index.js +2 -21
  106. package/dist/empty-CAgyvhUI.js +166 -0
  107. package/dist/empty-CAgyvhUI.js.map +1 -0
  108. package/dist/field/field.d.ts +95 -0
  109. package/dist/field/index.d.ts +2 -0
  110. package/dist/field/index.js +2 -0
  111. package/dist/field-DMHGIMZF.js +241 -0
  112. package/dist/field-DMHGIMZF.js.map +1 -0
  113. package/dist/floating-bubble/floating-bubble.d.ts +116 -0
  114. package/dist/floating-bubble/index.d.ts +1 -0
  115. package/dist/floating-bubble/index.js +333 -0
  116. package/dist/floating-bubble/index.js.map +1 -0
  117. package/dist/floating-panel/floating-panel.d.ts +80 -0
  118. package/dist/floating-panel/index.d.ts +2 -0
  119. package/dist/floating-panel/index.js +2 -0
  120. package/dist/floating-panel-Cbm5njBJ.js +363 -0
  121. package/dist/floating-panel-Cbm5njBJ.js.map +1 -0
  122. package/dist/footer/footer.d.ts +94 -0
  123. package/dist/footer/index.d.ts +1 -0
  124. package/dist/footer/index.js +154 -0
  125. package/dist/footer/index.js.map +1 -0
  126. package/dist/form/connect.d.ts +6 -0
  127. package/dist/form/form.d.ts +100 -0
  128. package/dist/form/ids.d.ts +14 -0
  129. package/dist/form/index.d.ts +13 -0
  130. package/dist/form/index.js +3 -0
  131. package/dist/form/methods.d.ts +5 -0
  132. package/dist/form/model.d.ts +24 -0
  133. package/dist/form/native.d.ts +25 -0
  134. package/dist/form/rules.d.ts +40 -0
  135. package/dist/form/ssr.d.ts +7 -0
  136. package/dist/form/types.d.ts +150 -0
  137. package/dist/form-BAGkIEMY.js +1354 -0
  138. package/dist/form-BAGkIEMY.js.map +1 -0
  139. package/dist/format-BDUY0C_c.js +89 -0
  140. package/dist/format-BDUY0C_c.js.map +1 -0
  141. package/dist/gesture-_SRHIvBm.js +30 -0
  142. package/dist/gesture-_SRHIvBm.js.map +1 -0
  143. package/dist/grid/grid-item.d.ts +22 -0
  144. package/dist/grid/grid.d.ts +42 -0
  145. package/dist/grid/index.d.ts +2 -0
  146. package/dist/grid/index.js +73 -0
  147. package/dist/grid/index.js.map +1 -0
  148. package/dist/icon/icon.d.ts +37 -1
  149. package/dist/icon/identity.d.ts +3 -0
  150. package/dist/icon/index.js +2 -20
  151. package/dist/icon-Cgdbnk1u.js +77 -0
  152. package/dist/icon-Cgdbnk1u.js.map +1 -0
  153. package/dist/image/image-load.d.ts +24 -0
  154. package/dist/image/image.d.ts +45 -8
  155. package/dist/image/index.d.ts +1 -0
  156. package/dist/image/index.js +116 -14
  157. package/dist/image/index.js.map +1 -1
  158. package/dist/image-preview/image-preview.d.ts +124 -0
  159. package/dist/image-preview/index.d.ts +1 -0
  160. package/dist/image-preview/index.js +450 -0
  161. package/dist/image-preview/index.js.map +1 -0
  162. package/dist/index-bar/index-bar.d.ts +121 -0
  163. package/dist/index-bar/index.d.ts +1 -0
  164. package/dist/index-bar/index.js +386 -0
  165. package/dist/index-bar/index.js.map +1 -0
  166. package/dist/index.d.ts +107 -14
  167. package/dist/index.js +148 -14
  168. package/dist/index.js.map +1 -0
  169. package/dist/infinite-scroll/index.d.ts +1 -0
  170. package/dist/infinite-scroll/index.js +248 -0
  171. package/dist/infinite-scroll/index.js.map +1 -0
  172. package/dist/infinite-scroll/infinite-scroll.d.ts +95 -0
  173. package/dist/input/index.js +181 -22
  174. package/dist/input/index.js.map +1 -1
  175. package/dist/input/input.d.ts +44 -1
  176. package/dist/layer-IpFrl5--.js +414 -0
  177. package/dist/layer-IpFrl5--.js.map +1 -0
  178. package/dist/layout-BRSqi4AQ.js +43 -0
  179. package/dist/layout-BRSqi4AQ.js.map +1 -0
  180. package/dist/layout.d.ts +13 -0
  181. package/dist/list/index.d.ts +2 -0
  182. package/dist/list/index.js +2 -0
  183. package/dist/list/list.d.ts +30 -0
  184. package/dist/list-6-iz-Irh.js +28 -0
  185. package/dist/list-6-iz-Irh.js.map +1 -0
  186. package/dist/loading/index.js +45 -2
  187. package/dist/loading/index.js.map +1 -1
  188. package/dist/loading/loading.d.ts +45 -2
  189. package/dist/modal-dialog-machine-CF9_z3Dm.js +487 -0
  190. package/dist/modal-dialog-machine-CF9_z3Dm.js.map +1 -0
  191. package/dist/modal-dialog-machine.d.ts +21 -0
  192. package/dist/modal-dismissable-lifetime.d.ts +21 -0
  193. package/dist/modal-registry.d.ts +24 -0
  194. package/dist/modal-render-hydration.d.ts +35 -0
  195. package/dist/modal-render-runtime.d.ts +19 -0
  196. package/dist/modal-render-scope.d.ts +63 -0
  197. package/dist/nav-bar/index.d.ts +1 -0
  198. package/dist/nav-bar/index.js +115 -0
  199. package/dist/nav-bar/index.js.map +1 -0
  200. package/dist/nav-bar/nav-bar.d.ts +76 -0
  201. package/dist/notice-bar/index.d.ts +2 -0
  202. package/dist/notice-bar/index.js +2 -0
  203. package/dist/notice-bar/notice-bar.d.ts +103 -0
  204. package/dist/notice-bar-DMpwLvRb.js +231 -0
  205. package/dist/notice-bar-DMpwLvRb.js.map +1 -0
  206. package/dist/notify/index.d.ts +1 -0
  207. package/dist/notify/index.js +251 -0
  208. package/dist/notify/index.js.map +1 -0
  209. package/dist/notify/notify.d.ts +123 -0
  210. package/dist/number-keyboard/index.d.ts +1 -0
  211. package/dist/number-keyboard/index.js +333 -0
  212. package/dist/number-keyboard/index.js.map +1 -0
  213. package/dist/number-keyboard/number-keyboard.d.ts +141 -0
  214. package/dist/page-indicator/index.d.ts +1 -0
  215. package/dist/page-indicator/index.js +138 -0
  216. package/dist/page-indicator/index.js.map +1 -0
  217. package/dist/page-indicator/page-indicator.d.ts +93 -0
  218. package/dist/pagination/index.d.ts +1 -0
  219. package/dist/pagination/index.js +198 -0
  220. package/dist/pagination/index.js.map +1 -0
  221. package/dist/pagination/pagination.d.ts +125 -0
  222. package/dist/password-input/index.d.ts +1 -0
  223. package/dist/password-input/index.js +317 -0
  224. package/dist/password-input/index.js.map +1 -0
  225. package/dist/password-input/password-input.d.ts +144 -0
  226. package/dist/picker/index.d.ts +8 -0
  227. package/dist/picker/index.js +2 -0
  228. package/dist/picker/picker-machine.d.ts +80 -0
  229. package/dist/picker/picker.d.ts +121 -0
  230. package/dist/picker/platform.d.ts +84 -0
  231. package/dist/picker/selection-connect.d.ts +90 -0
  232. package/dist/picker/selection-model.d.ts +211 -0
  233. package/dist/picker-BykFntQN.js +1675 -0
  234. package/dist/picker-BykFntQN.js.map +1 -0
  235. package/dist/popover/index.d.ts +3 -0
  236. package/dist/popover/index.js +253 -0
  237. package/dist/popover/index.js.map +1 -0
  238. package/dist/popover/layer.d.ts +44 -0
  239. package/dist/popover/popover.d.ts +104 -0
  240. package/dist/popover/positioning.d.ts +132 -0
  241. package/dist/popup/index.d.ts +2 -0
  242. package/dist/popup/index.js +2 -0
  243. package/dist/popup/popup.d.ts +60 -0
  244. package/dist/popup-z5d8IYCt.js +576 -0
  245. package/dist/popup-z5d8IYCt.js.map +1 -0
  246. package/dist/portal-BHCNTWhg.js +78 -0
  247. package/dist/portal-BHCNTWhg.js.map +1 -0
  248. package/dist/portal.d.ts +61 -0
  249. package/dist/price/format.d.ts +19 -0
  250. package/dist/price/index.d.ts +1 -0
  251. package/dist/price/index.js +154 -0
  252. package/dist/price/index.js.map +1 -0
  253. package/dist/price/price.d.ts +88 -0
  254. package/dist/progress/index.d.ts +1 -0
  255. package/dist/progress/index.js +2 -0
  256. package/dist/progress/progress.d.ts +32 -0
  257. package/dist/progress-f3iYEfdA.js +37 -0
  258. package/dist/progress-f3iYEfdA.js.map +1 -0
  259. package/dist/pull-refresh/index.d.ts +1 -0
  260. package/dist/pull-refresh/index.js +414 -0
  261. package/dist/pull-refresh/index.js.map +1 -0
  262. package/dist/pull-refresh/pull-refresh.d.ts +118 -0
  263. package/dist/radio-group/index.d.ts +3 -0
  264. package/dist/radio-group/index.js +2 -0
  265. package/dist/radio-group/radio-group.d.ts +78 -0
  266. package/dist/radio-group-BOIMuqnS.js +230 -0
  267. package/dist/radio-group-BOIMuqnS.js.map +1 -0
  268. package/dist/rate/index.d.ts +1 -0
  269. package/dist/rate/index.js +2 -0
  270. package/dist/rate/rate-form.d.ts +28 -0
  271. package/dist/rate/rate.d.ts +144 -0
  272. package/dist/rate-5XsU2QkY.js +631 -0
  273. package/dist/rate-5XsU2QkY.js.map +1 -0
  274. package/dist/reorder/index.d.ts +1 -0
  275. package/dist/reorder/index.js +720 -0
  276. package/dist/reorder/index.js.map +1 -0
  277. package/dist/reorder/reorder.d.ts +190 -0
  278. package/dist/result/index.d.ts +1 -0
  279. package/dist/result/index.js +123 -0
  280. package/dist/result/index.js.map +1 -0
  281. package/dist/result/result.d.ts +88 -0
  282. package/dist/safe-area/index.d.ts +1 -0
  283. package/dist/safe-area/index.js +42 -0
  284. package/dist/safe-area/index.js.map +1 -0
  285. package/dist/safe-area/safe-area.d.ts +28 -0
  286. package/dist/search-bar/index.js +3 -1
  287. package/dist/search-bar/index.js.map +1 -1
  288. package/dist/search-bar/search-bar.d.ts +4 -0
  289. package/dist/segmented/index.d.ts +2 -0
  290. package/dist/segmented/index.js +2 -0
  291. package/dist/segmented/segmented.d.ts +127 -0
  292. package/dist/segmented-BaU38_L4.js +367 -0
  293. package/dist/segmented-BaU38_L4.js.map +1 -0
  294. package/dist/selection-form-BOM_odUk.js +88 -0
  295. package/dist/selection-form-BOM_odUk.js.map +1 -0
  296. package/dist/selection-form.d.ts +27 -0
  297. package/dist/selection-ivXqO1eu.js +55 -0
  298. package/dist/selection-ivXqO1eu.js.map +1 -0
  299. package/dist/selection.d.ts +29 -0
  300. package/dist/selector/choice-group.d.ts +114 -0
  301. package/dist/selector/index.d.ts +2 -0
  302. package/dist/selector/index.js +2 -0
  303. package/dist/selector/selector.d.ts +90 -0
  304. package/dist/selector-BU2MMJ4N.js +93 -0
  305. package/dist/selector-BU2MMJ4N.js.map +1 -0
  306. package/dist/share-sheet/index.d.ts +1 -0
  307. package/dist/share-sheet/index.js +138 -0
  308. package/dist/share-sheet/index.js.map +1 -0
  309. package/dist/share-sheet/share-sheet.d.ts +139 -0
  310. package/dist/skeleton/index.js +51 -2
  311. package/dist/skeleton/index.js.map +1 -1
  312. package/dist/skeleton/skeleton.d.ts +34 -3
  313. package/dist/slider/index.d.ts +1 -0
  314. package/dist/slider/index.js +482 -0
  315. package/dist/slider/index.js.map +1 -0
  316. package/dist/slider/slider.d.ts +174 -0
  317. package/dist/space/index.d.ts +1 -0
  318. package/dist/space/index.js +52 -0
  319. package/dist/space/index.js.map +1 -0
  320. package/dist/space/space.d.ts +46 -0
  321. package/dist/statistic/index.d.ts +1 -0
  322. package/dist/statistic/index.js +152 -0
  323. package/dist/statistic/index.js.map +1 -0
  324. package/dist/statistic/statistic.d.ts +101 -0
  325. package/dist/stepper/index.js +62 -3
  326. package/dist/stepper/index.js.map +1 -1
  327. package/dist/stepper/stepper.d.ts +44 -4
  328. package/dist/steps/index.d.ts +1 -0
  329. package/dist/steps/index.js +72 -0
  330. package/dist/steps/index.js.map +1 -0
  331. package/dist/steps/steps.d.ts +67 -0
  332. package/dist/sticky/index.d.ts +1 -0
  333. package/dist/sticky/index.js +145 -0
  334. package/dist/sticky/index.js.map +1 -0
  335. package/dist/sticky/sticky.d.ts +70 -0
  336. package/dist/swipe-action/index.d.ts +1 -0
  337. package/dist/swipe-action/index.js +417 -0
  338. package/dist/swipe-action/index.js.map +1 -0
  339. package/dist/swipe-action/swipe-action.d.ts +148 -0
  340. package/dist/swiper/gesture.d.ts +32 -0
  341. package/dist/swiper/index.d.ts +1 -0
  342. package/dist/swiper/index.js +2 -0
  343. package/dist/swiper/swiper.d.ts +177 -0
  344. package/dist/swiper-BKivDkHp.js +550 -0
  345. package/dist/swiper-BKivDkHp.js.map +1 -0
  346. package/dist/switch/index.js +135 -10
  347. package/dist/switch/index.js.map +1 -1
  348. package/dist/switch/switch.d.ts +93 -6
  349. package/dist/tabbar/index.js +46 -1
  350. package/dist/tabbar/index.js.map +1 -1
  351. package/dist/tabbar/tabbar.d.ts +50 -0
  352. package/dist/tabs/index.js +22 -1
  353. package/dist/tabs/index.js.map +1 -1
  354. package/dist/tabs/tabs.d.ts +12 -8
  355. package/dist/tag/index.js +123 -2
  356. package/dist/tag/index.js.map +1 -1
  357. package/dist/tag/tag.d.ts +67 -1
  358. package/dist/textarea/index.d.ts +2 -0
  359. package/dist/textarea/index.js +2 -242
  360. package/dist/textarea/platform.d.ts +22 -0
  361. package/dist/textarea/textarea.d.ts +165 -46
  362. package/dist/textarea-qbnruDUG.js +775 -0
  363. package/dist/textarea-qbnruDUG.js.map +1 -0
  364. package/dist/time-picker/index.d.ts +1 -0
  365. package/dist/time-picker/index.js +228 -0
  366. package/dist/time-picker/index.js.map +1 -0
  367. package/dist/time-picker/time-picker.d.ts +83 -0
  368. package/dist/timeline/index.d.ts +1 -0
  369. package/dist/timeline/index.js +131 -0
  370. package/dist/timeline/index.js.map +1 -0
  371. package/dist/timeline/timeline.d.ts +79 -0
  372. package/dist/toast/index.js +47 -4
  373. package/dist/toast/index.js.map +1 -1
  374. package/dist/toast/toast.d.ts +26 -3
  375. package/dist/top-bar/index.js +16 -2
  376. package/dist/top-bar/index.js.map +1 -1
  377. package/dist/top-bar/top-bar.d.ts +13 -2
  378. package/dist/tree-select/index.d.ts +1 -0
  379. package/dist/tree-select/index.js +512 -0
  380. package/dist/tree-select/index.js.map +1 -0
  381. package/dist/tree-select/tree-select.d.ts +215 -0
  382. package/dist/typography/index.d.ts +1 -0
  383. package/dist/typography/index.js +82 -0
  384. package/dist/typography/index.js.map +1 -0
  385. package/dist/typography/typography.d.ts +54 -0
  386. package/dist/upload/index.d.ts +1 -0
  387. package/dist/upload/index.js +458 -0
  388. package/dist/upload/index.js.map +1 -0
  389. package/dist/upload/upload.d.ts +172 -0
  390. package/dist/virtual-list/index.d.ts +1 -0
  391. package/dist/virtual-list/index.js +445 -0
  392. package/dist/virtual-list/index.js.map +1 -0
  393. package/dist/virtual-list/virtual-list.d.ts +160 -0
  394. package/dist/visual-manifest.d.ts +6 -0
  395. package/dist/watermark/index.d.ts +1 -0
  396. package/dist/watermark/index.js +260 -0
  397. package/dist/watermark/index.js.map +1 -0
  398. package/dist/watermark/watermark.d.ts +106 -0
  399. package/package.json +399 -50
  400. package/dist/empty/index.js.map +0 -1
  401. package/dist/icon/index.js.map +0 -1
  402. package/dist/textarea/index.js.map +0 -1
@@ -0,0 +1,28 @@
1
+ /** Beta passive, physical-edge safe-area layout. All rules are shared across adapters. */
2
+ export declare const SAFE_AREA_EDGES: readonly ["top", "right", "bottom", "left"];
3
+ export declare const SAFE_AREA_MODES: readonly ["padding", "margin"];
4
+ export declare const SAFE_AREA_MINIMUM_PRESETS: readonly ["none", "sm", "md", "lg"];
5
+ export type SafeAreaEdge = (typeof SAFE_AREA_EDGES)[number];
6
+ export type SafeAreaMode = (typeof SAFE_AREA_MODES)[number];
7
+ export interface QwSafeAreaProps {
8
+ /** Protected physical edges, default bottom. An empty list disables all edges. */
9
+ edges?: readonly SafeAreaEdge[];
10
+ /** Apply protection as padding or margin; default padding. Margin follows CSS collapse rules. */
11
+ mode?: SafeAreaMode;
12
+ /** Minimum per selected edge: none/sm/md/lg, nonnegative pixels or CSS length. Default none. */
13
+ minInset?: number | string;
14
+ }
15
+ export interface ResolvedSafeAreaState {
16
+ edges: readonly SafeAreaEdge[];
17
+ mode: SafeAreaMode;
18
+ minimum: string;
19
+ }
20
+ export declare function resolveSafeAreaState(props?: QwSafeAreaProps): ResolvedSafeAreaState;
21
+ export interface SafeAreaRootProps {
22
+ "data-scope": "safe-area";
23
+ "data-part": "root";
24
+ "data-mode": SafeAreaMode;
25
+ "data-edges": string;
26
+ }
27
+ export declare function getSafeAreaRootProps(state: ResolvedSafeAreaState): SafeAreaRootProps;
28
+ export declare function getSafeAreaStyle(state: ResolvedSafeAreaState): Readonly<Record<string, string>>;
@@ -150,6 +150,8 @@ function connect(service, normalizeProps) {
150
150
  role: "searchbox",
151
151
  value,
152
152
  placeholder: prop("placeholder"),
153
+ "aria-label": prop("labelledBy")?.trim() ? void 0 : prop("accessibleLabel"),
154
+ "aria-labelledby": prop("labelledBy")?.trim() || void 0,
153
155
  disabled,
154
156
  readOnly,
155
157
  maxLength: maxLength && maxLength > 0 ? maxLength : void 0,
@@ -169,7 +171,7 @@ function connect(service, normalizeProps) {
169
171
  },
170
172
  onChange(event) {
171
173
  const target = event.target;
172
- const isComposing = !!event.nativeEvent?.isComposing;
174
+ const isComposing = !!(event.nativeEvent ?? event).isComposing;
173
175
  let next = target.value;
174
176
  if (!isComposing) {
175
177
  const maxLen = prop("maxLength") ?? 0;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/search-bar/search-bar.ts"],"sourcesContent":["import { createMachine } from \"@zag-js/core\";\nimport type { MachineSchema, Service } from \"@zag-js/core\";\nimport type { PropTypes, NormalizeProps } from \"@zag-js/types\";\nimport type { JSX } from \"@zag-js/types\";\nimport { compact } from \"@zag-js/utils\";\n\n/**\n * 清除按钮显示策略。\n */\nexport type SearchBarClearable = boolean | { showWhen?: \"always\" | \"focus\" | \"non-empty\" };\n\n/**\n * 内部归一化后的显示策略(包含 `never`,表示 `clearable={false}`)。\n */\nexport type SearchBarClearableMode = \"always\" | \"focus\" | \"non-empty\" | \"never\";\n\nexport interface SearchBarClearableConfig {\n showWhen: SearchBarClearableMode;\n}\n\n/**\n * 右侧 action 按钮角色。\n */\nexport type SearchBarActionType = \"cancel\" | \"search\";\n\n/**\n * 右侧 action 按钮配置。\n */\nexport interface SearchBarAction {\n /** 按钮角色。 */\n type: SearchBarActionType;\n /** 展示内容:文案或自定义节点。 */\n content: string | unknown;\n /** 取消时是否清空输入。 */\n clearOnCancel?: boolean;\n /** 按钮可访问名称;当 content 为纯图标时必填。 */\n ariaLabel?: string;\n}\n\n/**\n * SearchBar 公共 props 契约(双栈共享)。\n */\nexport interface QwSearchBarProps {\n /** 唯一 id 前缀。 */\n id?: string;\n /** 受控值。 */\n value?: string;\n /** 非受控初始值。 */\n defaultValue?: string;\n /** 占位符。 */\n placeholder?: string;\n /** 最大字符数。 */\n maxLength?: number;\n /** 禁用态。 */\n disabled?: boolean;\n /** 只读态。 */\n readOnly?: boolean;\n /** 清除按钮配置。 */\n clearable?: SearchBarClearable;\n /** 清除按钮 aria-label,默认「清除搜索内容」。 */\n clearLabel?: string;\n /** 左侧搜索图标:字符串文案或自定义节点。 */\n searchIcon?: string | unknown;\n /** 左侧按钮配置。 */\n prefix?: SearchBarAction;\n /** 右侧按钮配置。 */\n action?: SearchBarAction;\n /** 输入变化回调。 */\n onChange?: (value: string) => void;\n /** 搜索确认回调(Enter 或点击搜索按钮)。 */\n onSearch?: (value: string) => void;\n /** 清空回调。 */\n onClear?: () => void;\n /** 取消回调。 */\n onCancel?: () => void;\n /** 聚焦回调。 */\n onFocus?: () => void;\n /** 失焦回调。 */\n onBlur?: () => void;\n}\n\n/**\n * 内部 schema,用于 createMachine 类型推导。\n */\ninterface SearchBarSchema extends MachineSchema {\n props: QwSearchBarProps;\n context: {\n value: string;\n focused: boolean;\n };\n computed: {\n showClear: boolean;\n clearableConfig: SearchBarClearableConfig;\n };\n state: \"idle\";\n event:\n | { type: \"VALUE.SET\"; value: string; src?: string }\n | { type: \"VALUE.CLEAR\" }\n | { type: \"FOCUS.SET\"; focused: boolean }\n | { type: \"SEARCH\" }\n | { type: \"CANCEL\"; src?: \"prefix\" | \"action\" };\n action:\n | \"setValue\"\n | \"clearValue\"\n | \"setFocused\"\n | \"invokeOnSearch\"\n | \"invokeOnClear\"\n | \"invokeOnCancel\"\n | \"invokeOnFocus\"\n | \"invokeOnBlur\";\n}\n\n/**\n * 解析 clearable 配置为统一对象。\n */\nfunction normalizeClearable(clearable?: SearchBarClearable): SearchBarClearableConfig {\n if (clearable === false) return { showWhen: \"never\" };\n if (clearable === true || clearable == null) return { showWhen: \"non-empty\" };\n return { showWhen: clearable.showWhen ?? \"non-empty\" };\n}\n\n/**\n * SearchBar zag.js machine。\n * 所有交互逻辑唯一来源:value、focus、clear、action、keyboard。\n */\nexport const machine = createMachine<SearchBarSchema>({\n props({ props }) {\n return {\n defaultValue: \"\",\n disabled: false,\n readOnly: false,\n ...props,\n };\n },\n\n initialState() {\n return \"idle\";\n },\n\n context({ bindable, prop }) {\n return {\n value: bindable<string>(() => {\n const controlledValue = prop(\"value\");\n return {\n defaultValue: prop(\"defaultValue\") ?? \"\",\n sync: true,\n ...(controlledValue !== undefined ? { value: controlledValue } : {}),\n onChange(value, prev) {\n if (value !== prev) {\n prop(\"onChange\")?.(value);\n }\n },\n };\n }),\n focused: bindable(() => ({\n defaultValue: false,\n })),\n };\n },\n\n computed: {\n clearableConfig({ prop }) {\n return normalizeClearable(prop(\"clearable\"));\n },\n showClear({ context, computed }) {\n const cfg = computed(\"clearableConfig\");\n if (cfg.showWhen === \"always\") return true;\n if (cfg.showWhen === \"never\") return false;\n if (cfg.showWhen === \"focus\") return context.get(\"focused\");\n return context.get(\"value\").length > 0;\n },\n },\n\n watch({ track, prop, context }) {\n track([() => prop(\"value\")], () => {\n const external = prop(\"value\");\n if (external !== undefined && external !== context.get(\"value\")) {\n context.set(\"value\", external);\n }\n });\n },\n\n states: {\n idle: {\n on: {\n \"VALUE.SET\": {\n actions: [\"setValue\"],\n },\n \"VALUE.CLEAR\": {\n actions: [\"clearValue\", \"invokeOnClear\"],\n },\n \"FOCUS.SET\": {\n actions: [\"setFocused\"],\n },\n SEARCH: {\n actions: [\"invokeOnSearch\"],\n },\n CANCEL: {\n actions: [\"invokeOnCancel\"],\n },\n },\n },\n },\n\n implementations: {\n actions: {\n setValue({ context, event, prop }) {\n if (event.type === \"VALUE.SET\") {\n const maxLength = prop(\"maxLength\") ?? 0;\n const current = context.get(\"value\");\n let next = event.value;\n if (maxLength > 0 && next.length > maxLength) {\n // 达到 maxLength 后阻止继续输入,保留旧值\n next = current;\n }\n context.set(\"value\", next);\n }\n },\n clearValue({ context }) {\n context.set(\"value\", \"\");\n },\n setFocused({ context, event, prop }) {\n if (event.type === \"FOCUS.SET\") {\n const next = event.focused;\n const prev = context.get(\"focused\");\n context.set(\"focused\", next);\n if (next && !prev) prop(\"onFocus\")?.();\n if (!next && prev) prop(\"onBlur\")?.();\n }\n },\n invokeOnSearch({ context, prop }) {\n prop(\"onSearch\")?.(context.get(\"value\"));\n },\n invokeOnClear({ prop }) {\n prop(\"onClear\")?.();\n },\n invokeOnCancel({ context, prop, event }) {\n const config = event.src === \"prefix\" ? prop(\"prefix\") : prop(\"action\");\n if (config?.type === \"cancel\" && config.clearOnCancel && !prop(\"readOnly\")) {\n context.set(\"value\", \"\");\n }\n prop(\"onCancel\")?.();\n },\n invokeOnFocus() {\n // focus 回调在 setFocused 中已触发\n },\n invokeOnBlur() {\n // blur 回调在 setFocused 中已触发\n },\n },\n },\n});\n\n/**\n * SearchBar api 类型(由 connect 返回)。\n */\nexport interface SearchBarApi<T extends PropTypes = PropTypes> {\n /** 当前输入值。 */\n value: string;\n /** 当前是否聚焦。 */\n focused: boolean;\n /** 是否显示清除按钮。 */\n showClear: boolean;\n /** 清空输入。 */\n clear(): void;\n /** 触发搜索。 */\n search(): void;\n /** 根容器 prop-getter。 */\n getRootProps(): T[\"element\"];\n /** 输入区容器 prop-getter(包含图标、输入框、清除按钮)。 */\n getFieldProps(): T[\"element\"];\n /** 输入框 prop-getter。 */\n getInputProps(): T[\"input\"];\n /** 左侧图标 prop-getter。 */\n getIconProps(): T[\"element\"];\n /** 清除按钮 prop-getter。 */\n getClearButtonProps(): T[\"button\"];\n /** 左侧 prefix 按钮 prop-getter。 */\n getPrefixButtonProps(): T[\"button\"];\n /** 右侧 action 按钮 prop-getter。 */\n getActionButtonProps(): T[\"button\"];\n}\n\n/**\n * connect:把 service 接成业务友好的 prop-getter。\n * 适配层只需调用 connect(service, normalizeProps)。\n */\nexport function connect<T extends PropTypes>(service: Service<SearchBarSchema>, normalizeProps: NormalizeProps<T>): SearchBarApi<T> {\n const { context, computed, prop, send } = service;\n\n const value = context.get(\"value\");\n const focused = context.get(\"focused\");\n const showClear = computed(\"showClear\");\n const disabled = !!prop(\"disabled\");\n const readOnly = !!prop(\"readOnly\");\n const maxLength = prop(\"maxLength\");\n const prefix = prop(\"prefix\");\n const action = prop(\"action\");\n\n return {\n value,\n focused,\n showClear,\n\n clear() {\n send({ type: \"VALUE.CLEAR\" });\n },\n\n search() {\n send({ type: \"SEARCH\" });\n },\n\n getRootProps() {\n return normalizeProps.element(\n compact({\n \"data-scope\": \"search-bar\",\n \"data-part\": \"root\",\n // readOnly/disabled 时输入区仍可聚焦(readOnly HTML 语义),但不应呈现聚焦视觉态\n \"data-focused\": focused && !readOnly && !disabled ? \"true\" : undefined,\n \"data-disabled\": disabled ? \"true\" : undefined,\n \"data-readonly\": readOnly ? \"true\" : undefined,\n }),\n );\n },\n\n getFieldProps() {\n return normalizeProps.element(\n compact({\n \"data-scope\": \"search-bar\",\n \"data-part\": \"field\",\n }),\n );\n },\n\n getInputProps() {\n return normalizeProps.input(\n compact({\n \"data-scope\": \"search-bar\",\n \"data-part\": \"input\",\n type: \"search\" as const,\n role: \"searchbox\" as const,\n value,\n placeholder: prop(\"placeholder\"),\n disabled,\n readOnly,\n maxLength: maxLength && maxLength > 0 ? maxLength : undefined,\n \"aria-disabled\": disabled ? (\"true\" as const) : undefined,\n \"aria-readonly\": readOnly ? (\"true\" as const) : undefined,\n onFocus() {\n send({ type: \"FOCUS.SET\", focused: true });\n },\n onBlur() {\n send({ type: \"FOCUS.SET\", focused: false });\n },\n onChange(event: JSX.ChangeEvent<HTMLInputElement>) {\n const target = event.target as HTMLInputElement;\n const nativeEvent = (event as { nativeEvent?: { isComposing?: boolean } }).nativeEvent;\n const isComposing = !!nativeEvent?.isComposing;\n let next = target.value;\n // IME composing 期间跳过 maxLength 截断,允许拼音中间态值流过\n if (!isComposing) {\n const maxLen = prop(\"maxLength\") ?? 0;\n if (maxLen > 0 && next.length > maxLen) {\n next = next.slice(0, maxLen);\n }\n }\n // 直接同步更新,绕过 send() 的 queueMicrotask 延迟\n context.set(\"value\", next);\n },\n onKeyDown(event: JSX.KeyboardEvent<HTMLInputElement>) {\n if (event.key === \"Enter\") {\n send({ type: \"SEARCH\" });\n }\n },\n }),\n );\n },\n\n getIconProps() {\n return normalizeProps.element(\n compact({\n \"data-scope\": \"search-bar\",\n \"data-part\": \"icon\",\n \"aria-hidden\": \"true\" as const,\n }),\n );\n },\n\n getClearButtonProps() {\n return normalizeProps.button(\n compact({\n \"data-scope\": \"search-bar\",\n \"data-part\": \"clear-button\",\n type: \"button\" as const,\n disabled: disabled || readOnly,\n \"aria-label\": prop(\"clearLabel\") ?? \"清除搜索内容\",\n \"aria-hidden\": !showClear,\n hidden: !showClear,\n onClick() {\n send({ type: \"VALUE.CLEAR\" });\n },\n }),\n );\n },\n\n getPrefixButtonProps() {\n return normalizeProps.button(\n compact({\n \"data-scope\": \"search-bar\",\n \"data-part\": \"prefix-button\",\n type: \"button\" as const,\n disabled,\n \"aria-label\": prefix?.ariaLabel,\n \"data-action\": prefix?.type,\n onClick() {\n if (prefix?.type === \"cancel\") {\n send({ type: \"CANCEL\", src: \"prefix\" });\n } else if (prefix?.type === \"search\") {\n send({ type: \"SEARCH\" });\n }\n },\n }),\n );\n },\n\n getActionButtonProps() {\n return normalizeProps.button(\n compact({\n \"data-scope\": \"search-bar\",\n \"data-part\": \"action-button\",\n type: \"button\" as const,\n disabled,\n \"aria-label\": action?.ariaLabel,\n \"data-action\": action?.type,\n onClick() {\n if (action?.type === \"cancel\") {\n send({ type: \"CANCEL\", src: \"action\" });\n } else if (action?.type === \"search\") {\n send({ type: \"SEARCH\" });\n }\n },\n }),\n );\n },\n };\n}\n\n/**\n * 把 QwSearchBarProps 转成 machine context(默认值收口)。\n */\nexport function createSearchBarProps(props: QwSearchBarProps = {}): Partial<QwSearchBarProps> {\n return {\n defaultValue: props.defaultValue ?? \"\",\n disabled: props.disabled ?? false,\n readOnly: props.readOnly ?? false,\n ...props,\n };\n}\n"],"mappings":";;;;;;AAmHA,SAAS,mBAAmB,WAA0D;CACpF,IAAI,cAAc,OAAO,OAAO,EAAE,UAAU,QAAQ;CACpD,IAAI,cAAc,QAAQ,aAAa,MAAM,OAAO,EAAE,UAAU,YAAY;CAC5E,OAAO,EAAE,UAAU,UAAU,YAAY,YAAY;AACvD;;;;;AAMA,MAAa,UAAU,cAA+B;CACpD,MAAM,EAAE,SAAS;EACf,OAAO;GACL,cAAc;GACd,UAAU;GACV,UAAU;GACV,GAAG;EACL;CACF;CAEA,eAAe;EACb,OAAO;CACT;CAEA,QAAQ,EAAE,UAAU,QAAQ;EAC1B,OAAO;GACL,OAAO,eAAuB;IAC5B,MAAM,kBAAkB,KAAK,OAAO;IACpC,OAAO;KACL,cAAc,KAAK,cAAc,KAAK;KACtC,MAAM;KACN,GAAI,oBAAoB,KAAA,IAAY,EAAE,OAAO,gBAAgB,IA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,CAAC,CACH;EACF;EAEA,sBAAsB;GACpB,OAAO,eAAe,OACpB,QAAQ;IACN,cAAc;IACd,aAAa;IACb,MAAM;IACN,UAAU,YAAY;IACtB,cAAc,KAAK,YAAY,KAAK;IACpC,eAAe,CAAC;IAChB,QAAQ,CAAC;IACT,UAAU;KACR,KAAK,EAAE,MAAM,cAAc,CAAC;IAC9B;GACF,CAAC,CACH;EACF;EAEA,uBAAuB;GACrB,OAAO,eAAe,OACpB,QAAQ;IACN,cAAc;IACd,aAAa;IACb,MAAM;IACN;IACA,cAAc,QAAQ;IACtB,eAAe,QAAQ;IACvB,UAAU;KACR,IAAI,QAAQ,SAAS,UACnB,KAAK;MAAE,MAAM;MAAU,KAAK;KAAS,CAAC;UACjC,IAAI,QAAQ,SAAS,UAC1B,KAAK,EAAE,MAAM,SAAS,CAAC;IAE3B;GACF,CAAC,CACH;EACF;EAEA,uBAAuB;GACrB,OAAO,eAAe,OACpB,QAAQ;IACN,cAAc;IACd,aAAa;IACb,MAAM;IACN;IACA,cAAc,QAAQ;IACtB,eAAe,QAAQ;IACvB,UAAU;KACR,IAAI,QAAQ,SAAS,UACnB,KAAK;MAAE,MAAM;MAAU,KAAK;KAAS,CAAC;UACjC,IAAI,QAAQ,SAAS,UAC1B,KAAK,EAAE,MAAM,SAAS,CAAC;IAE3B;GACF,CAAC,CACH;EACF;CACF;AACF;;;;AAKA,SAAgB,qBAAqB,QAA0B,CAAC,GAA8B;CAC5F,OAAO;EACL,cAAc,MAAM,gBAAgB;EACpC,UAAU,MAAM,YAAY;EAC5B,UAAU,MAAM,YAAY;EAC5B,GAAG;CACL;AACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/search-bar/search-bar.ts"],"sourcesContent":["import { createMachine } from \"@zag-js/core\";\nimport type { MachineSchema, Service } from \"@zag-js/core\";\nimport type { PropTypes, NormalizeProps } from \"@zag-js/types\";\nimport type { JSX } from \"@zag-js/types\";\nimport { compact } from \"@zag-js/utils\";\n\n/**\n * 清除按钮显示策略。\n */\nexport type SearchBarClearable = boolean | { showWhen?: \"always\" | \"focus\" | \"non-empty\" };\n\n/**\n * 内部归一化后的显示策略(包含 `never`,表示 `clearable={false}`)。\n */\nexport type SearchBarClearableMode = \"always\" | \"focus\" | \"non-empty\" | \"never\";\n\nexport interface SearchBarClearableConfig {\n showWhen: SearchBarClearableMode;\n}\n\n/**\n * 右侧 action 按钮角色。\n */\nexport type SearchBarActionType = \"cancel\" | \"search\";\n\n/**\n * 右侧 action 按钮配置。\n */\nexport interface SearchBarAction {\n /** 按钮角色。 */\n type: SearchBarActionType;\n /** 展示内容:文案或自定义节点。 */\n content: string | unknown;\n /** 取消时是否清空输入。 */\n clearOnCancel?: boolean;\n /** 按钮可访问名称;当 content 为纯图标时必填。 */\n ariaLabel?: string;\n}\n\n/**\n * SearchBar 公共 props 契约(双栈共享)。\n */\nexport interface QwSearchBarProps {\n /** 唯一 id 前缀。 */\n id?: string;\n /** 受控值。 */\n value?: string;\n /** 非受控初始值。 */\n defaultValue?: string;\n /** 占位符。 */\n placeholder?: string;\n /** 搜索框的可访问名称;可见标签优先使用 labelledBy 关联。 */\n accessibleLabel?: string;\n /** 可见标签节点的 ID,可用空格分隔多个 ID;优先于 accessibleLabel。 */\n labelledBy?: string;\n /** 最大字符数。 */\n maxLength?: number;\n /** 禁用态。 */\n disabled?: boolean;\n /** 只读态。 */\n readOnly?: boolean;\n /** 清除按钮配置。 */\n clearable?: SearchBarClearable;\n /** 清除按钮 aria-label,默认「清除搜索内容」。 */\n clearLabel?: string;\n /** 左侧搜索图标:字符串文案或自定义节点。 */\n searchIcon?: string | unknown;\n /** 左侧按钮配置。 */\n prefix?: SearchBarAction;\n /** 右侧按钮配置。 */\n action?: SearchBarAction;\n /** 输入变化回调。 */\n onChange?: (value: string) => void;\n /** 搜索确认回调(Enter 或点击搜索按钮)。 */\n onSearch?: (value: string) => void;\n /** 清空回调。 */\n onClear?: () => void;\n /** 取消回调。 */\n onCancel?: () => void;\n /** 聚焦回调。 */\n onFocus?: () => void;\n /** 失焦回调。 */\n onBlur?: () => void;\n}\n\n/**\n * 内部 schema,用于 createMachine 类型推导。\n */\ninterface SearchBarSchema extends MachineSchema {\n props: QwSearchBarProps;\n context: {\n value: string;\n focused: boolean;\n };\n computed: {\n showClear: boolean;\n clearableConfig: SearchBarClearableConfig;\n };\n state: \"idle\";\n event:\n | { type: \"VALUE.SET\"; value: string; src?: string }\n | { type: \"VALUE.CLEAR\" }\n | { type: \"FOCUS.SET\"; focused: boolean }\n | { type: \"SEARCH\" }\n | { type: \"CANCEL\"; src?: \"prefix\" | \"action\" };\n action:\n | \"setValue\"\n | \"clearValue\"\n | \"setFocused\"\n | \"invokeOnSearch\"\n | \"invokeOnClear\"\n | \"invokeOnCancel\"\n | \"invokeOnFocus\"\n | \"invokeOnBlur\";\n}\n\n/**\n * 解析 clearable 配置为统一对象。\n */\nfunction normalizeClearable(clearable?: SearchBarClearable): SearchBarClearableConfig {\n if (clearable === false) return { showWhen: \"never\" };\n if (clearable === true || clearable == null) return { showWhen: \"non-empty\" };\n return { showWhen: clearable.showWhen ?? \"non-empty\" };\n}\n\n/**\n * SearchBar zag.js machine。\n * 所有交互逻辑唯一来源:value、focus、clear、action、keyboard。\n */\nexport const machine = createMachine<SearchBarSchema>({\n props({ props }) {\n return {\n defaultValue: \"\",\n disabled: false,\n readOnly: false,\n ...props,\n };\n },\n\n initialState() {\n return \"idle\";\n },\n\n context({ bindable, prop }) {\n return {\n value: bindable<string>(() => {\n const controlledValue = prop(\"value\");\n return {\n defaultValue: prop(\"defaultValue\") ?? \"\",\n sync: true,\n ...(controlledValue !== undefined ? { value: controlledValue } : {}),\n onChange(value, prev) {\n if (value !== prev) {\n prop(\"onChange\")?.(value);\n }\n },\n };\n }),\n focused: bindable(() => ({\n defaultValue: false,\n })),\n };\n },\n\n computed: {\n clearableConfig({ prop }) {\n return normalizeClearable(prop(\"clearable\"));\n },\n showClear({ context, computed }) {\n const cfg = computed(\"clearableConfig\");\n if (cfg.showWhen === \"always\") return true;\n if (cfg.showWhen === \"never\") return false;\n if (cfg.showWhen === \"focus\") return context.get(\"focused\");\n return context.get(\"value\").length > 0;\n },\n },\n\n watch({ track, prop, context }) {\n track([() => prop(\"value\")], () => {\n const external = prop(\"value\");\n if (external !== undefined && external !== context.get(\"value\")) {\n context.set(\"value\", external);\n }\n });\n },\n\n states: {\n idle: {\n on: {\n \"VALUE.SET\": {\n actions: [\"setValue\"],\n },\n \"VALUE.CLEAR\": {\n actions: [\"clearValue\", \"invokeOnClear\"],\n },\n \"FOCUS.SET\": {\n actions: [\"setFocused\"],\n },\n SEARCH: {\n actions: [\"invokeOnSearch\"],\n },\n CANCEL: {\n actions: [\"invokeOnCancel\"],\n },\n },\n },\n },\n\n implementations: {\n actions: {\n setValue({ context, event, prop }) {\n if (event.type === \"VALUE.SET\") {\n const maxLength = prop(\"maxLength\") ?? 0;\n const current = context.get(\"value\");\n let next = event.value;\n if (maxLength > 0 && next.length > maxLength) {\n // 达到 maxLength 后阻止继续输入,保留旧值\n next = current;\n }\n context.set(\"value\", next);\n }\n },\n clearValue({ context }) {\n context.set(\"value\", \"\");\n },\n setFocused({ context, event, prop }) {\n if (event.type === \"FOCUS.SET\") {\n const next = event.focused;\n const prev = context.get(\"focused\");\n context.set(\"focused\", next);\n if (next && !prev) prop(\"onFocus\")?.();\n if (!next && prev) prop(\"onBlur\")?.();\n }\n },\n invokeOnSearch({ context, prop }) {\n prop(\"onSearch\")?.(context.get(\"value\"));\n },\n invokeOnClear({ prop }) {\n prop(\"onClear\")?.();\n },\n invokeOnCancel({ context, prop, event }) {\n const config = event.src === \"prefix\" ? prop(\"prefix\") : prop(\"action\");\n if (config?.type === \"cancel\" && config.clearOnCancel && !prop(\"readOnly\")) {\n context.set(\"value\", \"\");\n }\n prop(\"onCancel\")?.();\n },\n invokeOnFocus() {\n // focus 回调在 setFocused 中已触发\n },\n invokeOnBlur() {\n // blur 回调在 setFocused 中已触发\n },\n },\n },\n});\n\n/**\n * SearchBar api 类型(由 connect 返回)。\n */\nexport interface SearchBarApi<T extends PropTypes = PropTypes> {\n /** 当前输入值。 */\n value: string;\n /** 当前是否聚焦。 */\n focused: boolean;\n /** 是否显示清除按钮。 */\n showClear: boolean;\n /** 清空输入。 */\n clear(): void;\n /** 触发搜索。 */\n search(): void;\n /** 根容器 prop-getter。 */\n getRootProps(): T[\"element\"];\n /** 输入区容器 prop-getter(包含图标、输入框、清除按钮)。 */\n getFieldProps(): T[\"element\"];\n /** 输入框 prop-getter。 */\n getInputProps(): T[\"input\"];\n /** 左侧图标 prop-getter。 */\n getIconProps(): T[\"element\"];\n /** 清除按钮 prop-getter。 */\n getClearButtonProps(): T[\"button\"];\n /** 左侧 prefix 按钮 prop-getter。 */\n getPrefixButtonProps(): T[\"button\"];\n /** 右侧 action 按钮 prop-getter。 */\n getActionButtonProps(): T[\"button\"];\n}\n\n/**\n * connect:把 service 接成业务友好的 prop-getter。\n * 适配层只需调用 connect(service, normalizeProps)。\n */\nexport function connect<T extends PropTypes>(service: Service<SearchBarSchema>, normalizeProps: NormalizeProps<T>): SearchBarApi<T> {\n const { context, computed, prop, send } = service;\n\n const value = context.get(\"value\");\n const focused = context.get(\"focused\");\n const showClear = computed(\"showClear\");\n const disabled = !!prop(\"disabled\");\n const readOnly = !!prop(\"readOnly\");\n const maxLength = prop(\"maxLength\");\n const prefix = prop(\"prefix\");\n const action = prop(\"action\");\n\n return {\n value,\n focused,\n showClear,\n\n clear() {\n send({ type: \"VALUE.CLEAR\" });\n },\n\n search() {\n send({ type: \"SEARCH\" });\n },\n\n getRootProps() {\n return normalizeProps.element(\n compact({\n \"data-scope\": \"search-bar\",\n \"data-part\": \"root\",\n // readOnly/disabled 时输入区仍可聚焦(readOnly HTML 语义),但不应呈现聚焦视觉态\n \"data-focused\": focused && !readOnly && !disabled ? \"true\" : undefined,\n \"data-disabled\": disabled ? \"true\" : undefined,\n \"data-readonly\": readOnly ? \"true\" : undefined,\n }),\n );\n },\n\n getFieldProps() {\n return normalizeProps.element(\n compact({\n \"data-scope\": \"search-bar\",\n \"data-part\": \"field\",\n }),\n );\n },\n\n getInputProps() {\n return normalizeProps.input(\n compact({\n \"data-scope\": \"search-bar\",\n \"data-part\": \"input\",\n type: \"search\" as const,\n role: \"searchbox\" as const,\n value,\n placeholder: prop(\"placeholder\"),\n \"aria-label\": prop(\"labelledBy\")?.trim() ? undefined : prop(\"accessibleLabel\"),\n \"aria-labelledby\": prop(\"labelledBy\")?.trim() || undefined,\n disabled,\n readOnly,\n maxLength: maxLength && maxLength > 0 ? maxLength : undefined,\n \"aria-disabled\": disabled ? (\"true\" as const) : undefined,\n \"aria-readonly\": readOnly ? (\"true\" as const) : undefined,\n onFocus() {\n send({ type: \"FOCUS.SET\", focused: true });\n },\n onBlur() {\n send({ type: \"FOCUS.SET\", focused: false });\n },\n onChange(event: JSX.ChangeEvent<HTMLInputElement>) {\n const target = event.target as HTMLInputElement;\n const nativeEvent = (event as { nativeEvent?: { isComposing?: boolean } }).nativeEvent ?? event;\n const isComposing = !!(nativeEvent as { isComposing?: boolean }).isComposing;\n let next = target.value;\n // IME composing 期间跳过 maxLength 截断,允许拼音中间态值流过\n if (!isComposing) {\n const maxLen = prop(\"maxLength\") ?? 0;\n if (maxLen > 0 && next.length > maxLen) {\n next = next.slice(0, maxLen);\n }\n }\n // 直接同步更新,绕过 send() 的 queueMicrotask 延迟\n context.set(\"value\", next);\n },\n onKeyDown(event: JSX.KeyboardEvent<HTMLInputElement>) {\n if (event.key === \"Enter\") {\n send({ type: \"SEARCH\" });\n }\n },\n }),\n );\n },\n\n getIconProps() {\n return normalizeProps.element(\n compact({\n \"data-scope\": \"search-bar\",\n \"data-part\": \"icon\",\n \"aria-hidden\": \"true\" as const,\n }),\n );\n },\n\n getClearButtonProps() {\n return normalizeProps.button(\n compact({\n \"data-scope\": \"search-bar\",\n \"data-part\": \"clear-button\",\n type: \"button\" as const,\n disabled: disabled || readOnly,\n \"aria-label\": prop(\"clearLabel\") ?? \"清除搜索内容\",\n \"aria-hidden\": !showClear,\n hidden: !showClear,\n onClick() {\n send({ type: \"VALUE.CLEAR\" });\n },\n }),\n );\n },\n\n getPrefixButtonProps() {\n return normalizeProps.button(\n compact({\n \"data-scope\": \"search-bar\",\n \"data-part\": \"prefix-button\",\n type: \"button\" as const,\n disabled,\n \"aria-label\": prefix?.ariaLabel,\n \"data-action\": prefix?.type,\n onClick() {\n if (prefix?.type === \"cancel\") {\n send({ type: \"CANCEL\", src: \"prefix\" });\n } else if (prefix?.type === \"search\") {\n send({ type: \"SEARCH\" });\n }\n },\n }),\n );\n },\n\n getActionButtonProps() {\n return normalizeProps.button(\n compact({\n \"data-scope\": \"search-bar\",\n \"data-part\": \"action-button\",\n type: \"button\" as const,\n disabled,\n \"aria-label\": action?.ariaLabel,\n \"data-action\": action?.type,\n onClick() {\n if (action?.type === \"cancel\") {\n send({ type: \"CANCEL\", src: \"action\" });\n } else if (action?.type === \"search\") {\n send({ type: \"SEARCH\" });\n }\n },\n }),\n );\n },\n };\n}\n\n/**\n * 把 QwSearchBarProps 转成 machine context(默认值收口)。\n */\nexport function createSearchBarProps(props: QwSearchBarProps = {}): Partial<QwSearchBarProps> {\n return {\n defaultValue: props.defaultValue ?? \"\",\n disabled: props.disabled ?? false,\n readOnly: props.readOnly ?? false,\n ...props,\n };\n}\n"],"mappings":";;;;;;AAuHA,SAAS,mBAAmB,WAA0D;CACpF,IAAI,cAAc,OAAO,OAAO,EAAE,UAAU,QAAQ;CACpD,IAAI,cAAc,QAAQ,aAAa,MAAM,OAAO,EAAE,UAAU,YAAY;CAC5E,OAAO,EAAE,UAAU,UAAU,YAAY,YAAY;AACvD;;;;;AAMA,MAAa,UAAU,cAA+B;CACpD,MAAM,EAAE,SAAS;EACf,OAAO;GACL,cAAc;GACd,UAAU;GACV,UAAU;GACV,GAAG;EACL;CACF;CAEA,eAAe;EACb,OAAO;CACT;CAEA,QAAQ,EAAE,UAAU,QAAQ;EAC1B,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AAM,gBAAgB;EACpC,UAAU,MAAM,YAAY;EAC5B,UAAU,MAAM,YAAY;EAC5B,GAAG;CACL;AACF"}
@@ -42,6 +42,10 @@ export interface QwSearchBarProps {
42
42
  defaultValue?: string;
43
43
  /** 占位符。 */
44
44
  placeholder?: string;
45
+ /** 搜索框的可访问名称;可见标签优先使用 labelledBy 关联。 */
46
+ accessibleLabel?: string;
47
+ /** 可见标签节点的 ID,可用空格分隔多个 ID;优先于 accessibleLabel。 */
48
+ labelledBy?: string;
45
49
  /** 最大字符数。 */
46
50
  maxLength?: number;
47
51
  /** 禁用态。 */
@@ -0,0 +1,2 @@
1
+ export { SEGMENTED_MODES, SEGMENTED_SIZES, SEGMENTED_PARTS, normalizeSegmentedItems, normalizeSegmentedValue, createSegmentedProps, segmentedMachine, connect } from "./segmented.js";
2
+ export type { SegmentedSelectionMode, SegmentedSize, SegmentedValueChangeDetails, QwSegmentedItem, QwSegmentedProps, QwSegmentedSchema, QwSegmentedMachine, QwSegmentedService, QwSegmentedItemProps, QwSegmentedItemState, QwSegmentedApi } from "./segmented.js";
@@ -0,0 +1,2 @@
1
+ import { a as createSegmentedProps, c as segmentedMachine, i as connect, n as SEGMENTED_PARTS, o as normalizeSegmentedItems, r as SEGMENTED_SIZES, s as normalizeSegmentedValue, t as SEGMENTED_MODES } from "../segmented-BaU38_L4.js";
2
+ export { SEGMENTED_MODES, SEGMENTED_PARTS, SEGMENTED_SIZES, connect, createSegmentedProps, normalizeSegmentedItems, normalizeSegmentedValue, segmentedMachine };
@@ -0,0 +1,127 @@
1
+ import { type Machine, type Service } from "@zag-js/core";
2
+ import type { NormalizeProps, PropTypes } from "@zag-js/types";
3
+ import { type QwSelectionItem } from "../selection.js";
4
+ import { type IconNameInput, type IconState } from "../icon/index.js";
5
+ /** Supported single/multiple selection modes. */
6
+ export declare const SEGMENTED_MODES: readonly ["single", "multiple"];
7
+ /** Existing T3 control-height sizes; large is the mobile default. */
8
+ export declare const SEGMENTED_SIZES: readonly ["sm", "md", "lg"];
9
+ /** Stable DOM parts shared by every adapter. */
10
+ export declare const SEGMENTED_PARTS: readonly ["root", "label", "description", "items", "item", "input", "content", "icon", "text", "item-description"];
11
+ export type SegmentedSelectionMode = (typeof SEGMENTED_MODES)[number];
12
+ export type SegmentedSize = (typeof SEGMENTED_SIZES)[number];
13
+ /** Accessible option name remains required even in icon-only presentation. */
14
+ export interface QwSegmentedItem extends QwSelectionItem {
15
+ icon?: IconNameInput;
16
+ iconOnly?: boolean;
17
+ }
18
+ /** Requested ordered values; callers receive independent snapshots. */
19
+ export interface SegmentedValueChangeDetails {
20
+ value: string[];
21
+ }
22
+ /** SSR-safe input shared by all adapters. */
23
+ export interface QwSegmentedProps {
24
+ id?: string;
25
+ /** Visible, nonempty accessible group name rendered as legend. */
26
+ label: string;
27
+ description?: string;
28
+ /** External Field help/error references, merged with the control-owned description. */
29
+ describedBy?: string;
30
+ /** Unique nonempty values and nonempty accessible labels. */
31
+ items: QwSegmentedItem[];
32
+ selectionMode?: SegmentedSelectionMode;
33
+ /** Defined arrays, including [], are controlled. Unknown values are retained. */
34
+ value?: string[];
35
+ /** Initial value and form reset target; defaults to []. */
36
+ defaultValue?: string[];
37
+ /** Allow a selected single item to toggle off; defaults false. */
38
+ allowEmpty?: boolean;
39
+ /** Minimum/maximum apply only to multiple-mode user removals/additions. */
40
+ min?: number;
41
+ max?: number;
42
+ disabled?: boolean;
43
+ /** Block user selection while retaining focus and native submitted values. */
44
+ readOnly?: boolean;
45
+ /** Native form validation requires an enabled rendered selection. */
46
+ required?: boolean;
47
+ invalid?: boolean;
48
+ name?: string;
49
+ form?: string;
50
+ orientation?: "horizontal" | "vertical";
51
+ /** Standard HTML direction; auto/empty inherit the input's direction. */
52
+ dir?: string;
53
+ /** Keyboard navigation wraps by default. */
54
+ loop?: boolean;
55
+ /** Single-mode arrow/Home/End selection; defaults true. Multiple only focuses. */
56
+ selectOnFocus?: boolean;
57
+ size?: SegmentedSize;
58
+ block?: boolean;
59
+ /** Horizontal content scrolls with intrinsic option widths. */
60
+ scrollable?: boolean;
61
+ onValueChange?: (details: SegmentedValueChangeDetails) => void;
62
+ }
63
+ export interface QwSegmentedSchema {
64
+ props: QwSegmentedProps & {
65
+ selectionMode: SegmentedSelectionMode;
66
+ defaultValue: string[];
67
+ orientation: "horizontal" | "vertical";
68
+ loop: boolean;
69
+ selectOnFocus: boolean;
70
+ size: SegmentedSize;
71
+ };
72
+ context: {
73
+ value: string[];
74
+ focusedValue: string | null;
75
+ disabledIds: string[];
76
+ };
77
+ state: "ready";
78
+ action: "setValue" | "toggleValue" | "selectValue" | "setFocus" | "syncInputs" | "normalizeMode";
79
+ effect: "trackForm";
80
+ event: {
81
+ type: "VALUE.SET";
82
+ value: string[];
83
+ } | {
84
+ type: "VALUE.TOGGLE" | "VALUE.SELECT" | "FOCUS";
85
+ value: string;
86
+ };
87
+ }
88
+ export type QwSegmentedMachine = Machine<QwSegmentedSchema>;
89
+ export type QwSegmentedService = Service<QwSegmentedSchema>;
90
+ export interface QwSegmentedItemProps {
91
+ value: string;
92
+ }
93
+ export interface QwSegmentedItemState {
94
+ selected: boolean;
95
+ disabled: boolean;
96
+ readOnly: boolean;
97
+ iconOnly: boolean;
98
+ }
99
+ /** Validate accessible identities and copy every caller option. */
100
+ export declare function normalizeSegmentedItems(items: readonly QwSegmentedItem[]): QwSegmentedItem[];
101
+ /** Single selection retains the earliest unique caller value, including unknowns. */
102
+ export declare function normalizeSegmentedValue(value?: readonly string[], mode?: SegmentedSelectionMode): string[];
103
+ export declare function createSegmentedProps(props: QwSegmentedProps): Partial<QwSegmentedSchema["props"]>;
104
+ /** One Zag bindable lifecycle; Core alone owns selection, keys and native forms. */
105
+ export declare const segmentedMachine: QwSegmentedMachine;
106
+ export interface QwSegmentedApi<T extends PropTypes = PropTypes> {
107
+ value: string[];
108
+ items: QwSegmentedItem[];
109
+ label: string;
110
+ description: string;
111
+ setValue(value: string[]): void;
112
+ toggleValue(value: string): void;
113
+ getRootProps(): T["element"];
114
+ getLabelProps(): T["element"];
115
+ getDescriptionProps(): T["element"];
116
+ getItemsProps(): T["element"];
117
+ getItemState(item: QwSegmentedItemProps): QwSegmentedItemState;
118
+ getItemProps(item: QwSegmentedItemProps): T["label"];
119
+ getInputProps(item: QwSegmentedItemProps): T["input"];
120
+ getContentProps(item: QwSegmentedItemProps): T["element"];
121
+ getItemIconProps(item: QwSegmentedItemProps): T["element"];
122
+ getItemIconState(item: QwSegmentedItemProps): IconState;
123
+ getTextProps(item: QwSegmentedItemProps): T["element"];
124
+ getItemDescriptionProps(item: QwSegmentedItemProps): T["element"];
125
+ }
126
+ /** Getters are SSR-pure; only client events/effects use the existing Zag DOM scope. */
127
+ export declare function connect<T extends PropTypes>(service: QwSegmentedService, normalize: NormalizeProps<T>): QwSegmentedApi<T>;
@@ -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