@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,1675 @@
1
+ import { a as modalRequestSend, s as onModalBeforeClose } from "./modal-dialog-machine-CF9_z3Dm.js";
2
+ import { n as createPopupProps, o as popupMachine, t as connectPopup } from "./popup-z5d8IYCt.js";
3
+ import { MachineStatus } from "@zag-js/core";
4
+ //#region src/picker/selection-model.ts
5
+ /** 静默判定落定的内部时长;不是 API,也不是真实惯性承诺(真实触摸见 T029 浏览器验收)。 */
6
+ const QUIET_MS = 40;
7
+ /**
8
+ * 受控值请求后等待调用方回写的内部时长(不是 API)。到期仍未改写 value 即视为拒绝:
9
+ * 显示回到调用方的值并通知一次恢复后的预览(FR-004:受控时组件只发请求,显示跟随调用方)。
10
+ */
11
+ const OWNER_MS = 100;
12
+ const PAGE_STEP = 5;
13
+ const sameValue = (a, b) => a.length === b.length && a.every((item, index) => item === b[index]);
14
+ const resizeValue = (value, length) => Array.from({ length }, (_, index) => value[index] ?? null);
15
+ /** 可选 = 存在、未禁用、且是该值的逻辑第一项(第一项禁用也不提升后项)。 */
16
+ function isPickerOptionSelectable(column, index) {
17
+ const option = column.options[index];
18
+ return !!option && !option.disabled && column.options.findIndex((item) => item.value === option.value) === index;
19
+ }
20
+ /** 列的第一可选值;没有可选项时为 null。 */
21
+ function getPickerFirstValue(column) {
22
+ return column.options.find((_option, index) => isPickerOptionSelectable(column, index))?.value ?? null;
23
+ }
24
+ /** 值在列中的可选索引;不可选或不存在时为 -1(不伪造选中)。 */
25
+ function getPickerOptionIndex(column, value) {
26
+ return column.options.findIndex((option, index) => option.value === value && isPickerOptionSelectable(column, index));
27
+ }
28
+ /** 重复值诊断:每个后项一条,指向逻辑第一项。 */
29
+ function getPickerDiagnostics(columns) {
30
+ return columns.flatMap((column, columnIndex) => column.options.flatMap((option, optionIndex) => {
31
+ const firstIndex = column.options.findIndex((item) => item.value === option.value);
32
+ return firstIndex === optionIndex ? [] : [{
33
+ type: "duplicate-value",
34
+ columnIndex,
35
+ optionIndex,
36
+ firstIndex,
37
+ value: option.value
38
+ }];
39
+ }));
40
+ }
41
+ /** 键盘目标索引:跳过禁用与重复后项;没有可去的项时返回 -1。当前无效时向下类从首项、向上类从末项找。 */
42
+ function getPickerKeyboardTarget(column, current, move) {
43
+ const count = column.options.length;
44
+ const scan = (from, step, stop = step > 0 ? count : -1) => {
45
+ for (let index = from; step > 0 ? index < stop : index > stop; index += step) if (isPickerOptionSelectable(column, index)) return index;
46
+ return -1;
47
+ };
48
+ const valid = current >= 0 && current < count;
49
+ if (move === "first" || !valid && (move === "next" || move === "page-next")) return scan(0, 1);
50
+ if (move === "last" || !valid && (move === "previous" || move === "page-previous")) return scan(count - 1, -1);
51
+ if (move === "next") return scan(current + 1, 1);
52
+ if (move === "previous") return scan(current - 1, -1);
53
+ if (move === "page-next") {
54
+ const target = Math.min(count - 1, current + PAGE_STEP);
55
+ const forward = scan(target, 1);
56
+ return forward >= 0 ? forward : scan(target - 1, -1, current);
57
+ }
58
+ const target = Math.max(0, current - PAGE_STEP);
59
+ const backward = scan(target, -1);
60
+ return backward >= 0 ? backward : scan(target + 1, 1, current);
61
+ }
62
+ function sameColumns(a, b) {
63
+ return a.length === b.length && a.every((column, index) => {
64
+ const other = b[index];
65
+ return column.label === other.label && column.options.length === other.options.length && column.options.every((option, i) => {
66
+ const next = other.options[i];
67
+ return option.value === next.value && option.label === next.label && !!option.disabled === !!next.disabled;
68
+ });
69
+ });
70
+ }
71
+ function validGeometry(geometry, count) {
72
+ return Number.isFinite(geometry.viewportHeight) && geometry.viewportHeight > 0 && Number.isFinite(geometry.scrollHeight) && geometry.scrollHeight > 0 && Number.isFinite(geometry.scrollTop) && geometry.rows.length === count && geometry.rows.every((row, index) => Number.isFinite(row.top) && Number.isFinite(row.height) && row.height > 0 && (index === 0 || row.top >= geometry.rows[index - 1].top));
73
+ }
74
+ function nearest(column, geometry) {
75
+ const center = geometry.scrollTop + geometry.viewportHeight / 2;
76
+ let result = -1;
77
+ let distance = Infinity;
78
+ geometry.rows.forEach((row, index) => {
79
+ const next = Math.abs(row.top + row.height / 2 - center);
80
+ if (isPickerOptionSelectable(column, index) && next < distance) {
81
+ result = index;
82
+ distance = next;
83
+ }
84
+ });
85
+ return result;
86
+ }
87
+ function snapshotColumns(columns) {
88
+ return columns.map((column) => ({
89
+ ...column,
90
+ options: column.options.map((option) => ({ ...option }))
91
+ }));
92
+ }
93
+ /** Core 选择会话。由 pickerMachine 的 refs 持有;context 中的 snapshot 只是它的可观察投影。 */
94
+ var PickerSelectionModel = class {
95
+ props;
96
+ accepted;
97
+ restore;
98
+ preview;
99
+ source = "external";
100
+ externalInvalid = false;
101
+ lastUserColumn = -1;
102
+ columns;
103
+ epoch = 1;
104
+ sessionEpoch = 1;
105
+ active = true;
106
+ disposed = false;
107
+ pendingConfirm = false;
108
+ inlineDirty = false;
109
+ discreteTimer;
110
+ ownerTimer;
111
+ focusedColumn = 0;
112
+ userRevision = 0;
113
+ nextCommand = 0;
114
+ nextGeneration = 0;
115
+ nextMountEpoch = 0;
116
+ serviceId;
117
+ notificationSink;
118
+ mode;
119
+ constructor(serviceId, props, notificationSink, mode = "popup") {
120
+ this.serviceId = serviceId;
121
+ this.notificationSink = notificationSink;
122
+ this.mode = mode;
123
+ this.props = {
124
+ ...props,
125
+ columns: snapshotColumns(props.columns),
126
+ ...props.value ? { value: [...props.value] } : {}
127
+ };
128
+ this.accepted = [...props.value ?? props.defaultValue ?? props.columns.map(getPickerFirstValue)];
129
+ this.restore = resizeValue(this.accepted, props.columns.length);
130
+ this.preview = this.restore;
131
+ this.columns = props.columns.map(() => ({
132
+ generation: ++this.nextGeneration,
133
+ mountEpoch: 0,
134
+ attached: false,
135
+ user: false,
136
+ scrolling: false
137
+ }));
138
+ this.externalInvalid = props.value !== void 0 && !this.previewValid();
139
+ }
140
+ observer;
141
+ observe(observer) {
142
+ this.observer = observer;
143
+ observer(this.snapshot);
144
+ return () => {
145
+ if (this.observer === observer) this.observer = void 0;
146
+ };
147
+ }
148
+ publish() {
149
+ this.observer?.(this.snapshot);
150
+ }
151
+ notify(event) {
152
+ this.publish();
153
+ this.notificationSink(event);
154
+ }
155
+ get isDisposed() {
156
+ return this.disposed;
157
+ }
158
+ get snapshot() {
159
+ return {
160
+ mode: this.mode,
161
+ userRevision: this.userRevision,
162
+ committed: [...this.accepted],
163
+ preview: [...this.preview],
164
+ source: this.source,
165
+ selectedIndices: this.props.columns.map((column, index) => getPickerOptionIndex(column, this.preview[index] ?? null)),
166
+ valid: this.valid(),
167
+ pendingConfirm: this.pendingConfirm,
168
+ active: this.active,
169
+ focusedColumn: Math.max(0, Math.min(this.focusedColumn, this.props.columns.length - 1)),
170
+ tokens: this.columns.map((column, index) => this.active && column.attached ? this.token(index) : void 0),
171
+ commands: this.columns.flatMap((column) => column.command ? [{
172
+ ...column.command,
173
+ token: { ...column.command.token }
174
+ }] : [])
175
+ };
176
+ }
177
+ previewValid() {
178
+ return this.props.columns.length > 0 && this.props.columns.every((column, index) => getPickerOptionIndex(column, this.preview[index] ?? null) >= 0);
179
+ }
180
+ valid() {
181
+ return this.previewValid() && !this.externalInvalid;
182
+ }
183
+ token(columnIndex) {
184
+ const column = this.columns[columnIndex];
185
+ return {
186
+ serviceId: this.serviceId,
187
+ epoch: this.epoch,
188
+ columnIndex,
189
+ generation: column.generation,
190
+ mountEpoch: column.mountEpoch
191
+ };
192
+ }
193
+ current(token) {
194
+ const column = this.columns[token.columnIndex];
195
+ return this.active && column?.attached && token.serviceId === this.serviceId && token.epoch === this.epoch && token.generation === column.generation && token.mountEpoch === column.mountEpoch ? column : void 0;
196
+ }
197
+ attach(columnIndex) {
198
+ try {
199
+ const column = this.columns[columnIndex];
200
+ if (!this.active || !column) throw new Error("Inactive selection surface");
201
+ this.clearTimer(column);
202
+ column.mountEpoch = ++this.nextMountEpoch;
203
+ column.attached = true;
204
+ column.geometry = void 0;
205
+ column.command = void 0;
206
+ column.user = false;
207
+ column.pointer = void 0;
208
+ return this.token(columnIndex);
209
+ } finally {
210
+ this.publish();
211
+ }
212
+ }
213
+ detach(token) {
214
+ try {
215
+ const column = this.columns[token.columnIndex];
216
+ if (this.disposed || !column?.attached || token.serviceId !== this.serviceId || token.mountEpoch !== column.mountEpoch) return;
217
+ this.clearTimer(column);
218
+ column.mountEpoch = ++this.nextMountEpoch;
219
+ column.attached = false;
220
+ column.geometry = void 0;
221
+ column.command = void 0;
222
+ column.scrolling = false;
223
+ column.pointer = void 0;
224
+ column.user = false;
225
+ this.pendingConfirm = false;
226
+ } finally {
227
+ this.publish();
228
+ }
229
+ }
230
+ dispatch(token, signal) {
231
+ try {
232
+ const column = this.current(token);
233
+ if (!column) return;
234
+ if (signal.type === "MEASURE") {
235
+ if (!validGeometry(signal.geometry, this.props.columns[token.columnIndex].options.length)) {
236
+ this.clearTimer(column);
237
+ column.geometry = void 0;
238
+ column.command = void 0;
239
+ if (column.scrolling && !column.user && column.pointer === void 0) {
240
+ column.scrolling = false;
241
+ if (this.mode === "inline") this.flushInline();
242
+ else if (this.pendingConfirm && !this.waiting() && this.valid()) this.commit();
243
+ }
244
+ return;
245
+ }
246
+ column.geometry = {
247
+ ...signal.geometry,
248
+ rows: signal.geometry.rows.map((row) => ({ ...row }))
249
+ };
250
+ if (!this.align(token.columnIndex, "alignment") && column.scrolling) this.schedule(token);
251
+ return;
252
+ }
253
+ if (signal.type === "COMMAND.APPLIED") {
254
+ if (column.command?.commandId !== signal.commandId || !validGeometry(signal.geometry, this.props.columns[token.columnIndex].options.length)) return;
255
+ const reason = column.command.reason;
256
+ column.geometry = {
257
+ ...signal.geometry,
258
+ rows: signal.geometry.rows.map((row) => ({ ...row }))
259
+ };
260
+ column.command = void 0;
261
+ if (reason === "settlement" && column.user || this.pendingConfirm && column.scrolling) this.schedule(token);
262
+ return;
263
+ }
264
+ if (signal.type === "POINTER.START" || signal.type === "WHEEL") {
265
+ if (signal.type === "WHEEL" && !Number.isFinite(signal.deltaY)) return;
266
+ this.userRevision++;
267
+ column.user = true;
268
+ column.command = void 0;
269
+ this.clearTimer(column);
270
+ if (signal.type === "POINTER.START") {
271
+ if (column.pointer === void 0) column.pointer = signal.pointerId;
272
+ } else {
273
+ column.scrolling = true;
274
+ if (column.geometry) this.schedule(token);
275
+ }
276
+ return;
277
+ }
278
+ if (signal.type === "POINTER.END" || signal.type === "POINTER.CANCEL") {
279
+ if (column.pointer !== signal.pointerId) return;
280
+ column.pointer = void 0;
281
+ this.schedule(token);
282
+ return;
283
+ }
284
+ if (signal.type === "SCROLL") {
285
+ if (!column.geometry || !Number.isFinite(signal.scrollTop)) return;
286
+ column.geometry = {
287
+ ...column.geometry,
288
+ scrollTop: signal.scrollTop
289
+ };
290
+ if (!column.user) return;
291
+ column.scrolling = true;
292
+ const index = nearest(this.props.columns[token.columnIndex], column.geometry);
293
+ const value = index < 0 ? null : this.props.columns[token.columnIndex].options[index].value;
294
+ const preview = this.preview.map((item, i) => i === token.columnIndex ? value : item);
295
+ if (!sameValue(preview, this.preview)) {
296
+ this.setUserPreview(preview, token.columnIndex);
297
+ this.notify({
298
+ type: "preview",
299
+ value: [...preview]
300
+ });
301
+ }
302
+ if (this.current(token) && column.pointer === void 0) this.schedule(token);
303
+ }
304
+ } finally {
305
+ this.publish();
306
+ }
307
+ }
308
+ /** Captured identity must survive queueing; never relabel an old input. */
309
+ queue(token, signal) {
310
+ queueMicrotask(() => this.dispatch(token, signal));
311
+ }
312
+ /** 离散选择(点击/键盘):等同一次立即落定的用户选择;正在滚的本列被它取代。 */
313
+ select(columnIndex, optionIndex) {
314
+ try {
315
+ const column = this.props.columns[columnIndex];
316
+ const state = this.columns[columnIndex];
317
+ if (!this.active || this.disposed || !column || !state || !isPickerOptionSelectable(column, optionIndex)) return;
318
+ this.userRevision++;
319
+ this.focusedColumn = columnIndex;
320
+ this.clearTimer(state);
321
+ state.user = false;
322
+ state.scrolling = false;
323
+ state.pointer = void 0;
324
+ state.command = void 0;
325
+ const value = column.options[optionIndex].value;
326
+ const preview = resizeValue(this.preview, this.props.columns.length).map((item, i) => i === columnIndex ? value : item);
327
+ if (!sameValue(preview, this.preview)) {
328
+ this.setUserPreview(preview, columnIndex);
329
+ this.notify({
330
+ type: "preview",
331
+ value: [...preview]
332
+ });
333
+ }
334
+ if (!this.active || this.disposed || !this.columns[columnIndex]) return;
335
+ this.align(columnIndex, "alignment");
336
+ this.scheduleDiscrete();
337
+ } finally {
338
+ this.publish();
339
+ }
340
+ }
341
+ /**
342
+ * 离散选择的落定:与滚轮相同的静默窗口后才提交(内嵌)或兑现已按下的确定(工具栏)。
343
+ * 让框架下一次渲染才送达的联动后列先到,避免以旧后列冒充新数据(FR-011)。
344
+ */
345
+ scheduleDiscrete() {
346
+ if (this.mode !== "inline" && !this.pendingConfirm) return;
347
+ this.clearDiscrete();
348
+ const epoch = this.epoch;
349
+ const sessionEpoch = this.sessionEpoch;
350
+ this.discreteTimer = setTimeout(() => {
351
+ this.discreteTimer = void 0;
352
+ if (!this.active || this.disposed || this.epoch !== epoch || this.sessionEpoch !== sessionEpoch) return;
353
+ try {
354
+ if (this.mode === "inline") this.flushInline();
355
+ else if (this.pendingConfirm && !this.waiting() && this.valid()) this.commit();
356
+ } finally {
357
+ this.publish();
358
+ }
359
+ }, QUIET_MS);
360
+ }
361
+ clearDiscrete() {
362
+ if (this.discreteTimer !== void 0) clearTimeout(this.discreteTimer);
363
+ this.discreteTimer = void 0;
364
+ }
365
+ /** 列内键盘移动;目标不存在时只更新列焦点。 */
366
+ move(columnIndex, move) {
367
+ const column = this.props.columns[columnIndex];
368
+ if (!this.active || this.disposed || !column) return;
369
+ const target = getPickerKeyboardTarget(column, getPickerOptionIndex(column, this.preview[columnIndex] ?? null), move);
370
+ if (target >= 0) this.select(columnIndex, target);
371
+ else this.focus(columnIndex);
372
+ }
373
+ /** 记录逻辑列焦点(roving tabindex)。不发业务通知。 */
374
+ focus(columnIndex) {
375
+ if (this.disposed || columnIndex < 0 || columnIndex >= this.props.columns.length || columnIndex === this.focusedColumn) return;
376
+ this.focusedColumn = columnIndex;
377
+ this.publish();
378
+ }
379
+ setUserPreview(preview, columnIndex) {
380
+ this.preview = preview;
381
+ this.source = "user";
382
+ this.lastUserColumn = columnIndex;
383
+ if (this.mode === "inline") this.inlineDirty = true;
384
+ }
385
+ clearTimer(column) {
386
+ if (column.timer !== void 0) clearTimeout(column.timer);
387
+ column.timer = void 0;
388
+ }
389
+ schedule(token) {
390
+ const column = this.current(token);
391
+ if (!column || column.pointer !== void 0) return;
392
+ this.clearTimer(column);
393
+ column.timer = setTimeout(() => {
394
+ column.timer = void 0;
395
+ if (!this.current(token) || column.pointer !== void 0) return;
396
+ this.settle(token);
397
+ this.publish();
398
+ }, QUIET_MS);
399
+ }
400
+ align(columnIndex, reason) {
401
+ const column = this.columns[columnIndex];
402
+ const geometry = column.geometry;
403
+ const index = getPickerOptionIndex(this.props.columns[columnIndex], this.preview[columnIndex] ?? null);
404
+ if (!geometry || index < 0) return false;
405
+ const row = geometry.rows[index];
406
+ const offset = Math.max(0, Math.min(geometry.scrollHeight - geometry.viewportHeight, row.top + row.height / 2 - geometry.viewportHeight / 2));
407
+ if (geometry.scrollTop === offset) return false;
408
+ if (column.command?.offset === offset && column.command.reason === reason) return true;
409
+ column.command = {
410
+ token: this.token(columnIndex),
411
+ commandId: ++this.nextCommand,
412
+ offset,
413
+ behavior: "auto",
414
+ reason
415
+ };
416
+ return true;
417
+ }
418
+ settle(token) {
419
+ const column = this.current(token);
420
+ if (!column?.geometry) return;
421
+ if (this.align(token.columnIndex, "settlement")) return;
422
+ column.scrolling = false;
423
+ if (this.mode === "inline") this.flushInline();
424
+ else if (this.pendingConfirm && !this.waiting() && this.valid()) this.commit();
425
+ }
426
+ waiting() {
427
+ return this.columns.some((column) => column.pointer !== void 0 || column.scrolling || column.command?.reason === "settlement");
428
+ }
429
+ confirm() {
430
+ try {
431
+ if (!this.active || !this.valid() || this.mode === "inline") return;
432
+ if (this.waiting()) {
433
+ this.pendingConfirm = true;
434
+ return;
435
+ }
436
+ this.commit();
437
+ } finally {
438
+ this.publish();
439
+ }
440
+ }
441
+ commit() {
442
+ this.pendingConfirm = false;
443
+ const value = resizeValue(this.preview, this.props.columns.length);
444
+ if (this.props.value === void 0) this.accepted = [...value];
445
+ this.restore = resizeValue(this.accepted, this.props.columns.length);
446
+ this.invalidate();
447
+ const sessionEpoch = this.sessionEpoch;
448
+ this.notify({
449
+ type: "value",
450
+ value: [...value]
451
+ });
452
+ this.awaitOwner();
453
+ if (this.sessionEpoch === sessionEpoch && this.active && !this.disposed) this.notify({
454
+ type: "close",
455
+ open: false
456
+ });
457
+ }
458
+ /** 内嵌:所有列落定且有效、并且与已提交值不同,才通知一次 value。不关闭、不使在途输入失效。 */
459
+ flushInline() {
460
+ if (this.mode !== "inline" || !this.active || this.disposed || !this.inlineDirty || this.waiting() || !this.valid()) return;
461
+ this.inlineDirty = false;
462
+ const value = resizeValue(this.preview, this.props.columns.length);
463
+ if (sameValue(value, resizeValue(this.accepted, this.props.columns.length))) return;
464
+ if (this.props.value === void 0) this.accepted = [...value];
465
+ this.restore = resizeValue(this.accepted, this.props.columns.length);
466
+ this.notify({
467
+ type: "value",
468
+ value: [...value]
469
+ });
470
+ this.awaitOwner();
471
+ }
472
+ /**
473
+ * 受控请求发出后:调用方在 OWNER_MS 内没有改写 value(拒绝),且用户未再操作,
474
+ * 则显示回到调用方的值(同外部回写路径:新代次、桥重新测量并对齐),并通知一次恢复后的预览。
475
+ * 工具栏若已真实关闭,会话结束即可,重开本就从已提交值开始。
476
+ */
477
+ awaitOwner() {
478
+ this.clearOwner();
479
+ if (this.props.value === void 0 || this.disposed || !this.active) return;
480
+ const requested = [...this.props.value];
481
+ const revision = this.userRevision;
482
+ const sessionEpoch = this.sessionEpoch;
483
+ this.ownerTimer = setTimeout(() => {
484
+ this.ownerTimer = void 0;
485
+ if (this.disposed || !this.active || this.sessionEpoch !== sessionEpoch || this.userRevision !== revision || this.props.value === void 0) return;
486
+ if (!sameValue(this.props.value, requested) || this.waiting()) return;
487
+ const count = this.props.columns.length;
488
+ const restored = resizeValue(this.accepted, count);
489
+ if (sameValue(resizeValue(this.preview, count), restored)) return;
490
+ try {
491
+ this.invalidate();
492
+ this.preview = restored;
493
+ this.restore = [...restored];
494
+ this.source = "external";
495
+ this.externalInvalid = !this.previewValid();
496
+ this.notify({
497
+ type: "preview",
498
+ value: [...restored]
499
+ });
500
+ } finally {
501
+ this.publish();
502
+ }
503
+ }, OWNER_MS);
504
+ }
505
+ clearOwner() {
506
+ if (this.ownerTimer !== void 0) clearTimeout(this.ownerTimer);
507
+ this.ownerTimer = void 0;
508
+ }
509
+ cancel(requestClose = true) {
510
+ try {
511
+ if (!this.active || this.mode === "inline") return;
512
+ this.invalidate();
513
+ this.preview = resizeValue(this.restore, this.props.columns.length);
514
+ this.source = "restore";
515
+ const sessionEpoch = this.sessionEpoch;
516
+ this.notify({
517
+ type: "preview",
518
+ value: [...this.preview]
519
+ });
520
+ if (requestClose && this.sessionEpoch === sessionEpoch && this.active && !this.disposed) this.notify({
521
+ type: "close",
522
+ open: false
523
+ });
524
+ } finally {
525
+ this.publish();
526
+ }
527
+ }
528
+ /** Actual inherited Popup close fact, not another modal state transition. */
529
+ closed() {
530
+ try {
531
+ this.sessionEpoch++;
532
+ this.invalidate();
533
+ this.clearOwner();
534
+ this.active = false;
535
+ this.source = "external";
536
+ } finally {
537
+ this.publish();
538
+ }
539
+ }
540
+ stop() {
541
+ try {
542
+ this.sessionEpoch++;
543
+ this.invalidate();
544
+ this.clearOwner();
545
+ this.active = false;
546
+ this.disposed = true;
547
+ } finally {
548
+ this.publish();
549
+ }
550
+ }
551
+ invalidate() {
552
+ this.epoch++;
553
+ this.pendingConfirm = false;
554
+ this.inlineDirty = false;
555
+ this.clearDiscrete();
556
+ for (const column of this.columns) {
557
+ this.clearTimer(column);
558
+ column.generation = ++this.nextGeneration;
559
+ column.user = false;
560
+ column.scrolling = false;
561
+ column.pointer = void 0;
562
+ column.command = void 0;
563
+ }
564
+ }
565
+ update(props) {
566
+ try {
567
+ if (this.disposed) return;
568
+ const columnsChanged = !sameColumns(this.props.columns, props.columns);
569
+ const dependentChanged = props.columns.some((column, index) => index > this.lastUserColumn && (column.options.length !== this.props.columns[index]?.options.length || column.options.some((option, row) => {
570
+ const previous = this.props.columns[index]?.options[row];
571
+ return !previous || option.value !== previous.value || !!option.disabled !== !!previous.disabled;
572
+ })));
573
+ const externalChanged = props.value !== void 0 && (this.props.value === void 0 || !sameValue(props.value, this.props.value));
574
+ const controlledRemoved = props.value === void 0 && this.props.value !== void 0;
575
+ if (columnsChanged) {
576
+ this.columns.slice(props.columns.length).forEach((column) => this.clearTimer(column));
577
+ this.columns = props.columns.map((column, index) => {
578
+ const previous = this.columns[index];
579
+ const before = this.props.columns[index];
580
+ if (previous && before && sameColumns([before], [column])) return previous;
581
+ if (previous) this.clearTimer(previous);
582
+ return {
583
+ generation: ++this.nextGeneration,
584
+ mountEpoch: previous?.mountEpoch ?? 0,
585
+ attached: previous?.attached ?? false,
586
+ user: false,
587
+ scrolling: this.active && this.source === "user" && (previous?.attached ?? false)
588
+ };
589
+ });
590
+ }
591
+ this.props = {
592
+ ...props,
593
+ columns: snapshotColumns(props.columns),
594
+ ...props.value ? { value: [...props.value] } : {}
595
+ };
596
+ if (externalChanged) {
597
+ this.invalidate();
598
+ this.clearOwner();
599
+ this.accepted = [...props.value];
600
+ this.preview = resizeValue(this.accepted, props.columns.length);
601
+ this.source = "external";
602
+ this.restore = [...this.preview];
603
+ this.externalInvalid = !this.previewValid();
604
+ } else if (controlledRemoved) {
605
+ this.preview = resizeValue(this.accepted, props.columns.length);
606
+ this.source = "external";
607
+ this.pendingConfirm = false;
608
+ this.externalInvalid = false;
609
+ this.inlineDirty = false;
610
+ } else if (columnsChanged) {
611
+ this.preview = resizeValue(this.preview, props.columns.length);
612
+ if (this.source === "user" && dependentChanged) {
613
+ const next = this.preview.map((value, index) => index > this.lastUserColumn && getPickerOptionIndex(props.columns[index], value) < 0 ? getPickerFirstValue(props.columns[index]) : value);
614
+ this.externalInvalid = false;
615
+ if (!sameValue(next, this.preview)) {
616
+ this.setUserPreview(next, this.lastUserColumn);
617
+ this.notify({
618
+ type: "preview",
619
+ value: [...next]
620
+ });
621
+ }
622
+ this.flushInline();
623
+ } else {
624
+ this.externalInvalid = props.value !== void 0 && props.columns.some((column, index) => getPickerOptionIndex(column, this.accepted[index] ?? null) < 0);
625
+ if (!this.valid()) this.pendingConfirm = false;
626
+ }
627
+ }
628
+ } finally {
629
+ this.publish();
630
+ }
631
+ }
632
+ /** Begin a later actual Popup opening from the accepted entry value. */
633
+ reopened() {
634
+ try {
635
+ if (this.disposed) throw new Error("Disposed selection service");
636
+ this.sessionEpoch++;
637
+ this.invalidate();
638
+ this.clearOwner();
639
+ this.active = true;
640
+ this.restore = resizeValue(this.accepted, this.props.columns.length);
641
+ this.preview = [...this.restore];
642
+ this.source = "external";
643
+ this.externalInvalid = this.props.value !== void 0 && !this.previewValid();
644
+ } finally {
645
+ this.publish();
646
+ }
647
+ }
648
+ };
649
+ //#endregion
650
+ //#region src/picker/picker-machine.ts
651
+ const EMPTY_SELECTION = { columns: [] };
652
+ const noRefs = {
653
+ get: () => {
654
+ throw new Error("Pinned Popup has no refs");
655
+ },
656
+ set: () => {
657
+ throw new Error("Pinned Popup has no refs");
658
+ }
659
+ };
660
+ function popupContext(context) {
661
+ function set(key, value) {
662
+ context.set(key, value);
663
+ }
664
+ return {
665
+ get: (key) => context.get(key),
666
+ set,
667
+ initial: (key) => context.initial(key),
668
+ hash: (key) => context.hash(key)
669
+ };
670
+ }
671
+ function isPopupEvent(event) {
672
+ return !event.type.startsWith("SELECTION.");
673
+ }
674
+ function popupEvent(event) {
675
+ if (!isPopupEvent(event)) throw new Error("Picker events must not run upstream Popup handlers");
676
+ return event;
677
+ }
678
+ function popupMetadata(event) {
679
+ return event;
680
+ }
681
+ function popupParams(params) {
682
+ return {
683
+ ...params,
684
+ prop: (key) => params.prop(key),
685
+ context: popupContext(params.context),
686
+ refs: noRefs,
687
+ computed: (key) => params.computed(key),
688
+ event: popupMetadata(params.event),
689
+ send: (event) => params.send(event),
690
+ action: (keys) => params.action(keys),
691
+ guard: (key) => typeof key === "function" ? key(popupParams(params)) : params.guard(key),
692
+ choose: () => {
693
+ throw new Error("Pinned Popup has no inline choose implementation");
694
+ }
695
+ };
696
+ }
697
+ function transition(input) {
698
+ const guard = input.guard;
699
+ return {
700
+ ...input,
701
+ guard: (params) => !params.refs.get("selectionModel").isDisposed && (guard === void 0 || (typeof guard === "function" ? guard(popupParams(params)) : params.guard(guard)) === true)
702
+ };
703
+ }
704
+ function transitions(input) {
705
+ return Array.isArray(input) ? input.map((item) => transition(item)) : input ? transition(input) : void 0;
706
+ }
707
+ /** A queued selection close carries the actual service session and is re-checked at execution. */
708
+ function selectionClose(input) {
709
+ const items = transitions(input);
710
+ return items ? (Array.isArray(items) ? items : [items]).map((item) => ({
711
+ ...item,
712
+ guard: (params) => params.event.type === "SELECTION.CLOSE" && params.event.session === params.refs.get("selectionTransport").session && (item.guard === void 0 || (typeof item.guard === "function" ? item.guard(params) : params.guard(item.guard)) === true)
713
+ })) : void 0;
714
+ }
715
+ function state(input) {
716
+ const { entry, exit, effects, states: nested, ...rest } = input;
717
+ if (nested) throw new Error("Pinned Popup has no nested states");
718
+ return {
719
+ ...rest,
720
+ entry: typeof entry === "function" ? (params) => entry(popupParams(params)) : entry,
721
+ exit: typeof exit === "function" ? (params) => exit(popupParams(params)) : exit,
722
+ effects: typeof effects === "function" ? (params) => effects(popupParams(params)) : effects,
723
+ on: {
724
+ OPEN: transitions(input.on?.OPEN),
725
+ CLOSE: transitions(input.on?.CLOSE),
726
+ "SELECTION.CLOSE": selectionClose(input.on?.CLOSE),
727
+ TOGGLE: transitions(input.on?.TOGGLE),
728
+ "CONTROLLED.OPEN": transitions(input.on?.["CONTROLLED.OPEN"]),
729
+ "CONTROLLED.CLOSE": transitions(input.on?.["CONTROLLED.CLOSE"]),
730
+ "TRIGGER_VALUE.SET": transitions(input.on?.["TRIGGER_VALUE.SET"])
731
+ }
732
+ };
733
+ }
734
+ const closed = state(popupMachine.states.closed);
735
+ /** Inline keeps every inherited opening path closed: no lock, portal, ticket or registration. */
736
+ function onlyPopup(input) {
737
+ return input ? (Array.isArray(input) ? input : [input]).map((item) => ({
738
+ ...item,
739
+ guard: (params) => params.refs.get("mode") === "popup" && (item.guard === void 0 || (typeof item.guard === "function" ? item.guard(params) : params.guard(item.guard)) === true)
740
+ })) : void 0;
741
+ }
742
+ const disposed = (params) => params.refs.get("selectionModel").isDisposed;
743
+ /** Typed pinned upstream projection: one service, the original two modal states. */
744
+ const pickerMachine = {
745
+ props(params) {
746
+ return {
747
+ ...popupMachine.props({
748
+ props: params.props,
749
+ scope: params.scope
750
+ }),
751
+ mode: params.props.mode === "inline" ? "inline" : "popup",
752
+ selection: params.props.selection,
753
+ onSelectionNotice: params.props.onSelectionNotice
754
+ };
755
+ },
756
+ initialState(params) {
757
+ return params.prop("mode") === "inline" ? "closed" : popupMachine.initialState({ prop: (key) => params.prop(key) });
758
+ },
759
+ context(params) {
760
+ return {
761
+ ...popupMachine.context({
762
+ ...params,
763
+ prop: (key) => params.prop(key),
764
+ getContext: () => popupContext(params.getContext()),
765
+ getComputed: () => (key) => params.getComputed()(key),
766
+ getRefs: () => noRefs,
767
+ getEvent: () => popupEvent(params.getEvent())
768
+ }),
769
+ preview: params.bindable(() => ({ defaultValue: [] })),
770
+ selectionSnapshot: params.bindable(() => ({ defaultValue: null })),
771
+ surfaceTokens: params.bindable(() => ({ defaultValue: [] }))
772
+ };
773
+ },
774
+ refs({ prop }) {
775
+ const mode = prop("mode");
776
+ const selectionTransport = {
777
+ closeIntent: false,
778
+ session: 0
779
+ };
780
+ const selectionModel = new PickerSelectionModel(prop("id") ?? "", prop("selection") ?? EMPTY_SELECTION, (event) => selectionTransport.notice?.(event), mode);
781
+ if (mode === "popup" && !(prop("open") ?? prop("defaultOpen"))) selectionModel.closed();
782
+ return {
783
+ mode,
784
+ selectionModel,
785
+ selectionTransport
786
+ };
787
+ },
788
+ entry: (params) => typeof popupMachine.entry === "function" ? popupMachine.entry(popupParams(params)) : popupMachine.entry,
789
+ exit: (params) => typeof popupMachine.exit === "function" ? popupMachine.exit(popupParams(params)) : popupMachine.exit,
790
+ effects: ["selectionLifetime"],
791
+ watch(params) {
792
+ popupMachine.watch?.(popupParams(params));
793
+ params.track([() => JSON.stringify(params.prop("selection"))], () => {
794
+ params.refs.get("selectionModel").update(params.prop("selection") ?? EMPTY_SELECTION);
795
+ });
796
+ },
797
+ states: {
798
+ open: {
799
+ ...state(popupMachine.states.open),
800
+ entry(params) {
801
+ if (disposed(params)) return;
802
+ params.refs.get("selectionTransport").session++;
803
+ params.refs.get("selectionModel").reopened();
804
+ const entry = popupMachine.states.open.entry;
805
+ return typeof entry === "function" ? entry(popupParams(params)) : entry;
806
+ },
807
+ exit(params) {
808
+ const model = params.refs.get("selectionModel");
809
+ const transport = params.refs.get("selectionTransport");
810
+ transport.session++;
811
+ if (model.snapshot.active && !transport.closeIntent) model.cancel(false);
812
+ model.closed();
813
+ transport.closeIntent = false;
814
+ const exit = popupMachine.states.open.exit;
815
+ return typeof exit === "function" ? exit(popupParams(params)) : exit;
816
+ }
817
+ },
818
+ closed: {
819
+ ...closed,
820
+ on: {
821
+ ...closed.on,
822
+ OPEN: onlyPopup(closed.on?.OPEN),
823
+ TOGGLE: onlyPopup(closed.on?.TOGGLE),
824
+ "CONTROLLED.OPEN": onlyPopup(closed.on?.["CONTROLLED.OPEN"])
825
+ }
826
+ }
827
+ },
828
+ on: {
829
+ "SELECTION.MOUNT": { actions: ["selectionInput"] },
830
+ "SELECTION.UNMOUNT": { actions: ["selectionInput"] },
831
+ "SELECTION.INPUT": { actions: ["selectionInput"] },
832
+ "SELECTION.SELECT": { actions: ["selectionInput"] },
833
+ "SELECTION.MOVE": { actions: ["selectionInput"] },
834
+ "SELECTION.FOCUS": { actions: ["selectionInput"] },
835
+ "SELECTION.CONFIRM": { actions: ["selectionInput"] },
836
+ "SELECTION.CANCEL": { actions: ["selectionInput"] }
837
+ },
838
+ implementations: {
839
+ guards: { isOpenControlled: (params) => popupMachine.implementations.guards.isOpenControlled(popupParams(params)) },
840
+ effects: {
841
+ selectionLifetime(params) {
842
+ const model = params.refs.get("selectionModel");
843
+ const transport = params.refs.get("selectionTransport");
844
+ const releaseClose = onModalBeforeClose(params, () => {
845
+ if (model.snapshot.active && !transport.closeIntent) {
846
+ model.cancel(false);
847
+ transport.closeIntent = true;
848
+ }
849
+ });
850
+ let userRevision = model.snapshot.userRevision;
851
+ const unobserve = model.observe((snapshot) => {
852
+ if (snapshot.userRevision !== userRevision) transport.closeIntent = false;
853
+ userRevision = snapshot.userRevision;
854
+ params.context.set("selectionSnapshot", snapshot);
855
+ params.context.set("preview", snapshot.preview);
856
+ params.context.set("surfaceTokens", snapshot.tokens);
857
+ });
858
+ transport.notice = (event) => {
859
+ const session = transport.session;
860
+ params.prop("onSelectionNotice")?.(event);
861
+ if (event.type === "close" && model.snapshot.active && session === transport.session) {
862
+ transport.closeIntent = true;
863
+ modalRequestSend({
864
+ ...popupParams(params),
865
+ send: (event) => params.send({
866
+ ...event,
867
+ type: "SELECTION.CLOSE",
868
+ session
869
+ })
870
+ })({ type: "CLOSE" });
871
+ }
872
+ };
873
+ return () => {
874
+ releaseClose();
875
+ selectionPending.delete(model);
876
+ transport.session++;
877
+ transport.notice = void 0;
878
+ model.stop();
879
+ unobserve();
880
+ };
881
+ },
882
+ trackDismissableElement: (params) => disposed(params) ? void 0 : popupMachine.implementations.effects.trackDismissableElement(popupParams(params)),
883
+ trapFocus: (params) => disposed(params) ? void 0 : popupMachine.implementations.effects.trapFocus(popupParams(params)),
884
+ preventScroll: (params) => disposed(params) ? void 0 : popupMachine.implementations.effects.preventScroll(popupParams(params)),
885
+ hideContentBelow: (params) => disposed(params) ? void 0 : popupMachine.implementations.effects.hideContentBelow(popupParams(params))
886
+ },
887
+ actions: {
888
+ checkRenderedElements: (params) => disposed(params) ? void 0 : popupMachine.implementations.actions.checkRenderedElements(popupParams(params)),
889
+ setInitialFocus: (params) => disposed(params) ? void 0 : popupMachine.implementations.actions.setInitialFocus(popupParams(params)),
890
+ invokeOnClose(params) {
891
+ const model = params.refs.get("selectionModel");
892
+ const transport = params.refs.get("selectionTransport");
893
+ if (model.snapshot.active && !transport.closeIntent) {
894
+ model.cancel(false);
895
+ transport.closeIntent = true;
896
+ }
897
+ if (!model.isDisposed) popupMachine.implementations.actions.invokeOnClose(popupParams(params));
898
+ },
899
+ invokeOnOpen: (params) => disposed(params) ? void 0 : popupMachine.implementations.actions.invokeOnOpen(popupParams(params)),
900
+ toggleVisibility: (params) => disposed(params) ? void 0 : popupMachine.implementations.actions.toggleVisibility(popupParams(params)),
901
+ setTriggerValue: (params) => {
902
+ if (disposed(params)) return;
903
+ popupEvent(params.event);
904
+ popupMachine.implementations.actions.setTriggerValue(popupParams(params));
905
+ },
906
+ selectionInput(params) {
907
+ const ticket = params.event[selectionTicket];
908
+ if (ticket) {
909
+ if (ticket.processed) return;
910
+ ticket.processed = true;
911
+ const pending = selectionPending.get(params.refs.get("selectionModel"));
912
+ if (pending) pending.splice(pending.indexOf(ticket), 1);
913
+ }
914
+ requestPickerSelection(params);
915
+ }
916
+ }
917
+ }
918
+ };
919
+ /** Project the one service for the upstream Popup connector; never instantiate another. */
920
+ function toPopupService(service) {
921
+ return {
922
+ ...service,
923
+ context: popupContext(service.context),
924
+ prop: (key) => service.prop(key),
925
+ refs: noRefs,
926
+ computed: (key) => service.computed(key),
927
+ send: (event) => service.send(event),
928
+ event: popupMetadata(service.event)
929
+ };
930
+ }
931
+ function requestPickerSelection({ event, refs }) {
932
+ const model = refs.get("selectionModel");
933
+ if (event.type === "SELECTION.UNMOUNT") {
934
+ model.detach(event.token);
935
+ return;
936
+ }
937
+ if (!model.snapshot.active) return;
938
+ if (event.type === "SELECTION.MOUNT") model.attach(event.columnIndex);
939
+ else if (event.type === "SELECTION.INPUT") model.dispatch(event.token, event.signal);
940
+ else if (event.type === "SELECTION.SELECT") model.select(event.columnIndex, event.optionIndex);
941
+ else if (event.type === "SELECTION.MOVE") model.move(event.columnIndex, event.move);
942
+ else if (event.type === "SELECTION.FOCUS") model.focus(event.columnIndex);
943
+ else if (event.type === "SELECTION.CONFIRM") model.confirm();
944
+ else if (event.type === "SELECTION.CANCEL") model.cancel();
945
+ }
946
+ const selectionTicket = Symbol("qw-picker-input");
947
+ const selectionPending = /* @__PURE__ */ new WeakMap();
948
+ /** Keep input ordering when the machine scheduler has not consumed an earlier selection yet. */
949
+ function sendPickerSelection(service, event) {
950
+ if (service.getStatus() === MachineStatus.Stopped || service.refs.get("selectionModel").isDisposed) return;
951
+ if (service.getStatus() === MachineStatus.NotStarted) {
952
+ service.send(event);
953
+ return;
954
+ }
955
+ if (service.refs.get("mode") === "inline") {
956
+ service.send(event);
957
+ return;
958
+ }
959
+ if (event.type === "SELECTION.CONFIRM" || event.type === "SELECTION.CANCEL") {
960
+ const pending = selectionPending.get(service.refs.get("selectionModel"));
961
+ if (pending) while (pending.length) {
962
+ const ticket = pending.shift();
963
+ if (ticket.processed) continue;
964
+ ticket.processed = true;
965
+ requestPickerSelection({
966
+ refs: service.refs,
967
+ event: ticket.event
968
+ });
969
+ }
970
+ requestPickerSelection({
971
+ refs: service.refs,
972
+ event
973
+ });
974
+ return;
975
+ }
976
+ const ticket = {
977
+ event,
978
+ processed: false
979
+ };
980
+ let pending = selectionPending.get(service.refs.get("selectionModel"));
981
+ if (!pending) {
982
+ pending = [];
983
+ selectionPending.set(service.refs.get("selectionModel"), pending);
984
+ }
985
+ pending.push(ticket);
986
+ const envelope = {
987
+ ...event,
988
+ [selectionTicket]: ticket
989
+ };
990
+ service.send(envelope);
991
+ }
992
+ //#endregion
993
+ //#region src/picker/selection-connect.ts
994
+ /**
995
+ * 机械连接层(包内):同一 service 投影给原 Popup connector,选择输入保留 typed 队列;confirm/cancel 同步排空先前输入再请求关闭。
996
+ * 原生 IO 只运输捕获的票据与原始信号。connectPicker 在其上增加 ARIA/工具栏 getters。
997
+ */
998
+ function connectSelection(service, normalize, popupProps, runtime) {
999
+ const model = service.refs.get("selectionModel");
1000
+ return {
1001
+ popup: connectPopup(toPopupService(service), normalize, popupProps, runtime),
1002
+ snapshot: service.context.get("selectionSnapshot") ?? model.snapshot,
1003
+ mountColumn(columnIndex) {
1004
+ sendPickerSelection(service, {
1005
+ type: "SELECTION.MOUNT",
1006
+ columnIndex
1007
+ });
1008
+ },
1009
+ getColumnToken(columnIndex) {
1010
+ return model.snapshot.tokens[columnIndex];
1011
+ },
1012
+ unmountColumn(token) {
1013
+ sendPickerSelection(service, {
1014
+ type: "SELECTION.UNMOUNT",
1015
+ token
1016
+ });
1017
+ },
1018
+ input(token, signal) {
1019
+ sendPickerSelection(service, {
1020
+ type: "SELECTION.INPUT",
1021
+ token,
1022
+ signal
1023
+ });
1024
+ },
1025
+ select(columnIndex, optionIndex) {
1026
+ sendPickerSelection(service, {
1027
+ type: "SELECTION.SELECT",
1028
+ columnIndex,
1029
+ optionIndex
1030
+ });
1031
+ },
1032
+ move(columnIndex, move) {
1033
+ sendPickerSelection(service, {
1034
+ type: "SELECTION.MOVE",
1035
+ columnIndex,
1036
+ move
1037
+ });
1038
+ },
1039
+ focusColumn(columnIndex) {
1040
+ sendPickerSelection(service, {
1041
+ type: "SELECTION.FOCUS",
1042
+ columnIndex
1043
+ });
1044
+ },
1045
+ confirm() {
1046
+ sendPickerSelection(service, { type: "SELECTION.CONFIRM" });
1047
+ },
1048
+ cancel() {
1049
+ sendPickerSelection(service, { type: "SELECTION.CANCEL" });
1050
+ }
1051
+ };
1052
+ }
1053
+ //#endregion
1054
+ //#region src/picker/picker.ts
1055
+ const FALLBACK_NAME = "选择器";
1056
+ const CONFIRM_LABEL = "确定";
1057
+ const CANCEL_LABEL = "取消";
1058
+ const text = (value) => {
1059
+ const normalized = typeof value === "string" ? value.trim() : void 0;
1060
+ return normalized ? normalized : void 0;
1061
+ };
1062
+ /** 未知 mode 回退 popup。 */
1063
+ function resolvePickerMode(mode) {
1064
+ return mode === "inline" ? "inline" : "popup";
1065
+ }
1066
+ /** 可访问名称:title → ariaLabel → 「选择器」。空白视为缺省。 */
1067
+ function getPickerAccessibleName(props) {
1068
+ return text(props.title) ?? text(props.ariaLabel) ?? FALLBACK_NAME;
1069
+ }
1070
+ /** 业务值只接受 string/null 数组。 */
1071
+ function isPickerValue(value) {
1072
+ return Array.isArray(value) && value.every((item) => item === null || typeof item === "string");
1073
+ }
1074
+ /** 列结构校验:label 可选字符串,options 的 value/label 为字符串,disabled 可选布尔。 */
1075
+ function isPickerColumns(value) {
1076
+ return Array.isArray(value) && value.every((column) => {
1077
+ if (typeof column !== "object" || column === null) return false;
1078
+ const { label, options } = column;
1079
+ return (label === void 0 || typeof label === "string") && Array.isArray(options) && options.every((option) => {
1080
+ if (typeof option !== "object" || option === null) return false;
1081
+ const entry = option;
1082
+ return typeof entry.value === "string" && typeof entry.label === "string" && (entry.disabled === void 0 || typeof entry.disabled === "boolean");
1083
+ });
1084
+ });
1085
+ }
1086
+ /** 渲染数据:保留全部可见项,标出禁用/重复后项与当前预览项。 */
1087
+ function resolvePickerColumns(columns, preview = []) {
1088
+ return columns.map((column, index) => {
1089
+ const selectedIndex = getPickerOptionIndex(column, preview[index] ?? null);
1090
+ const options = column.options.map((option, optionIndex) => {
1091
+ const duplicate = column.options.findIndex((item) => item.value === option.value) !== optionIndex;
1092
+ return {
1093
+ index: optionIndex,
1094
+ value: option.value,
1095
+ label: option.label,
1096
+ duplicate,
1097
+ disabled: !isPickerOptionSelectable(column, optionIndex),
1098
+ selected: optionIndex === selectedIndex
1099
+ };
1100
+ });
1101
+ return {
1102
+ index,
1103
+ label: text(column.label) ?? `第 ${index + 1} 列`,
1104
+ options,
1105
+ selectedIndex,
1106
+ empty: options.every((option) => option.disabled)
1107
+ };
1108
+ });
1109
+ }
1110
+ /** Popup 的 data 属性(placement 固定 bottom)。 */
1111
+ function getPickerDataAttrs(props) {
1112
+ return {
1113
+ "data-placement": "bottom",
1114
+ "data-safe-area": props.safeArea === false ? void 0 : ""
1115
+ };
1116
+ }
1117
+ function toPopupProps(props, mode) {
1118
+ const { mode: _mode, columns: _columns, value: _value, defaultValue: _defaultValue, confirmLabel: _confirm, cancelLabel: _cancel, onValueChange: _onValue, onPreviewChange: _onPreview, ...rest } = props;
1119
+ const popup = {
1120
+ ...rest,
1121
+ placement: "bottom"
1122
+ };
1123
+ if (mode === "inline") {
1124
+ delete popup.open;
1125
+ popup.defaultOpen = false;
1126
+ }
1127
+ if (!text(props.title)) popup.ariaLabel = getPickerAccessibleName(props);
1128
+ return popup;
1129
+ }
1130
+ /** 只接受 popup 物理票据;有限 owner 只能缺省(React/Vue)或 "wc:picker"(qw-picker 宿主)。 */
1131
+ function pickerRuntime(mode, runtime) {
1132
+ if (mode === "inline" || !runtime) return void 0;
1133
+ const { kind, owner } = runtime.ticket;
1134
+ if (kind !== "popup" || owner !== void 0 && owner !== "wc:picker") throw new TypeError("Picker requires a popup modal ticket owned by wc:picker or unowned");
1135
+ return runtime;
1136
+ }
1137
+ /**
1138
+ * 公开 props → 同一 pickerMachine 的 props。机械委托 createPopupProps(props, runtime):
1139
+ * 受控优先、初态许可/拒绝仍由 Popup Core 决定;runtime 只在工具栏形态透传(WC 带 owner "wc:picker")。
1140
+ */
1141
+ function createPickerProps(props, runtime) {
1142
+ const columns = props.columns ?? [];
1143
+ if (!isPickerColumns(columns)) throw new TypeError("Picker columns must be an array of { label?, options: { value, label, disabled? }[] }");
1144
+ if (props.value !== void 0 && !isPickerValue(props.value)) throw new TypeError("Picker value must be an array of string | null");
1145
+ if (props.defaultValue !== void 0 && !isPickerValue(props.defaultValue)) throw new TypeError("Picker defaultValue must be an array of string | null");
1146
+ const mode = resolvePickerMode(props.mode);
1147
+ return {
1148
+ ...createPopupProps(toPopupProps(props, mode), pickerRuntime(mode, runtime)),
1149
+ mode,
1150
+ selection: {
1151
+ columns,
1152
+ value: props.value,
1153
+ defaultValue: props.defaultValue
1154
+ },
1155
+ onSelectionNotice(notice) {
1156
+ if (notice.type === "preview") props.onPreviewChange?.({ value: notice.value });
1157
+ else if (notice.type === "value") props.onValueChange?.({ value: notice.value });
1158
+ }
1159
+ };
1160
+ }
1161
+ const VERTICAL = {
1162
+ ArrowDown: "next",
1163
+ ArrowUp: "previous",
1164
+ Home: "first",
1165
+ End: "last",
1166
+ PageDown: "page-next",
1167
+ PageUp: "page-previous"
1168
+ };
1169
+ /** 物理方向只取渲染树上最近的 dir;逻辑列序不变。 */
1170
+ function isRtl(target) {
1171
+ return target?.closest?.("[dir]")?.getAttribute?.("dir")?.toLowerCase() === "rtl";
1172
+ }
1173
+ function focusSibling(target, index) {
1174
+ target?.closest?.("[data-scope=\"picker\"][data-part=\"columns\"]")?.querySelector?.(`[data-scope="picker"][data-part="column"][data-index="${index}"]`)?.focus?.({ preventScroll: true });
1175
+ }
1176
+ /**
1177
+ * 包装同一 service 的 connectPopup:继承开合/getters 与单层模态拒绝,增加滚轮 root/column/option、
1178
+ * 工具栏 cancel/confirm getters。确定/取消/键盘/点击都只发 typed 事件,由 selection-model 决定结果。
1179
+ */
1180
+ function connectPicker(service, normalize, props, runtime) {
1181
+ const mode = service.refs.get("mode");
1182
+ const selection = connectSelection(service, normalize, toPopupProps(props, mode), pickerRuntime(mode, runtime));
1183
+ const snapshot = selection.snapshot;
1184
+ const sourceColumns = service.prop("selection")?.columns ?? [];
1185
+ const columns = resolvePickerColumns(sourceColumns, snapshot.preview);
1186
+ const base = `picker:${service.scope.id ?? ""}`;
1187
+ const columnId = (index) => `${base}:column:${index}`;
1188
+ const optionId = (column, option) => `${base}:column:${column}:option:${option}`;
1189
+ const accessibleName = getPickerAccessibleName(props);
1190
+ const inline = mode === "inline";
1191
+ const part = (name) => ({
1192
+ "data-scope": "picker",
1193
+ "data-part": name
1194
+ });
1195
+ return {
1196
+ ...selection.popup,
1197
+ mode,
1198
+ columns,
1199
+ value: snapshot.committed,
1200
+ preview: snapshot.preview,
1201
+ valid: snapshot.valid,
1202
+ pendingConfirm: snapshot.pendingConfirm,
1203
+ active: snapshot.active,
1204
+ focusedColumn: snapshot.focusedColumn,
1205
+ selectedIndices: snapshot.selectedIndices,
1206
+ commands: snapshot.commands,
1207
+ diagnostics: getPickerDiagnostics(sourceColumns),
1208
+ accessibleName,
1209
+ confirmLabel: text(props.confirmLabel) ?? CONFIRM_LABEL,
1210
+ cancelLabel: text(props.cancelLabel) ?? CANCEL_LABEL,
1211
+ confirm: selection.confirm,
1212
+ cancel: selection.cancel,
1213
+ selectOption: selection.select,
1214
+ moveColumn: selection.move,
1215
+ mountColumn: selection.mountColumn,
1216
+ getColumnToken: selection.getColumnToken,
1217
+ unmountColumn: selection.unmountColumn,
1218
+ input: selection.input,
1219
+ getRootProps: () => normalize.element({
1220
+ ...part("root"),
1221
+ id: `${base}:root`,
1222
+ "data-visual-target": inline ? "picker-inline" : "picker-wheel",
1223
+ "data-mode": mode,
1224
+ "data-valid": snapshot.valid ? "" : void 0,
1225
+ "data-pending": snapshot.pendingConfirm ? "" : void 0,
1226
+ role: inline ? "group" : void 0,
1227
+ "aria-label": inline ? accessibleName : void 0
1228
+ }),
1229
+ getColumnsProps: () => normalize.element({
1230
+ ...part("columns"),
1231
+ "data-count": columns.length,
1232
+ "data-empty": columns.length === 0 ? "" : void 0
1233
+ }),
1234
+ getColumnProps({ index }) {
1235
+ const column = columns[index];
1236
+ const selected = column?.selectedIndex ?? -1;
1237
+ return normalize.element({
1238
+ ...part("column"),
1239
+ "data-visual-target": "picker-column",
1240
+ "data-index": index,
1241
+ id: columnId(index),
1242
+ role: "listbox",
1243
+ "aria-orientation": "vertical",
1244
+ "aria-label": column?.label ?? `第 ${index + 1} 列`,
1245
+ "aria-activedescendant": selected >= 0 ? optionId(index, selected) : void 0,
1246
+ "aria-disabled": !column || column.empty ? true : void 0,
1247
+ "data-empty": !column || column.empty ? "" : void 0,
1248
+ "data-invalid": selected < 0 ? "" : void 0,
1249
+ "data-focused": snapshot.focusedColumn === index ? "" : void 0,
1250
+ tabIndex: snapshot.focusedColumn === index ? 0 : -1,
1251
+ onFocus() {
1252
+ if (snapshot.focusedColumn !== index) selection.focusColumn(index);
1253
+ },
1254
+ onKeyDown(event) {
1255
+ if (event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey || event.isComposing) return;
1256
+ const move = VERTICAL[event.key];
1257
+ if (move) {
1258
+ event.preventDefault();
1259
+ selection.move(index, move);
1260
+ return;
1261
+ }
1262
+ if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
1263
+ event.preventDefault();
1264
+ const forward = event.key === "ArrowRight" !== isRtl(event.currentTarget);
1265
+ const next = Math.max(0, Math.min(columns.length - 1, index + (forward ? 1 : -1)));
1266
+ if (next === index) return;
1267
+ selection.focusColumn(next);
1268
+ focusSibling(event.currentTarget, next);
1269
+ }
1270
+ });
1271
+ },
1272
+ getOptionProps({ columnIndex, index }) {
1273
+ const option = columns[columnIndex]?.options[index];
1274
+ if (!option) return normalize.element({
1275
+ ...part("option"),
1276
+ role: "option",
1277
+ "aria-selected": false,
1278
+ "aria-disabled": true,
1279
+ "data-disabled": ""
1280
+ });
1281
+ return normalize.element({
1282
+ ...part("option"),
1283
+ "data-visual-target": "picker-option",
1284
+ "data-index": index,
1285
+ "data-value": option.value,
1286
+ id: optionId(columnIndex, index),
1287
+ role: "option",
1288
+ "aria-selected": option.selected,
1289
+ "aria-disabled": option.disabled ? true : void 0,
1290
+ "data-selected": option.selected ? "" : void 0,
1291
+ "data-disabled": option.disabled ? "" : void 0,
1292
+ "data-duplicate": option.duplicate ? "" : void 0,
1293
+ onClick() {
1294
+ if (!option.disabled) selection.select(columnIndex, index);
1295
+ }
1296
+ });
1297
+ },
1298
+ getIndicatorProps: () => normalize.element({
1299
+ ...part("indicator"),
1300
+ "aria-hidden": true
1301
+ }),
1302
+ getToolbarProps: () => normalize.element({
1303
+ ...part("toolbar"),
1304
+ "data-visual-target": "picker-toolbar"
1305
+ }),
1306
+ getCancelProps: () => normalize.element({
1307
+ ...part("cancel"),
1308
+ "data-visual-target": "picker-cancel",
1309
+ id: `${base}:cancel`,
1310
+ type: "button",
1311
+ onClick: () => selection.cancel()
1312
+ }),
1313
+ getConfirmProps: () => normalize.element({
1314
+ ...part("confirm"),
1315
+ "data-visual-target": "picker-confirm",
1316
+ id: `${base}:confirm`,
1317
+ type: "button",
1318
+ disabled: !snapshot.valid,
1319
+ "data-pending": snapshot.pendingConfirm ? "" : void 0,
1320
+ onClick: () => selection.confirm()
1321
+ })
1322
+ };
1323
+ }
1324
+ //#endregion
1325
+ //#region src/picker/platform.ts
1326
+ const sameToken = (a, b) => a.serviceId === b.serviceId && a.epoch === b.epoch && a.columnIndex === b.columnIndex && a.generation === b.generation && a.mountEpoch === b.mountEpoch;
1327
+ const sameMount = (a, b) => a.serviceId === b.serviceId && a.columnIndex === b.columnIndex && a.mountEpoch === b.mountEpoch;
1328
+ /** Private mechanical resources only. Option/settlement/selection policy remains in Core. */
1329
+ function createBinding(viewport, token, rows, sink, physical) {
1330
+ const view = viewport.ownerDocument.defaultView;
1331
+ if (!view) throw new Error("Column requires its owner window");
1332
+ const captured = { ...token };
1333
+ let bound = true;
1334
+ let lastCommandId;
1335
+ const resources = [];
1336
+ const releaseResources = () => {
1337
+ if (!bound) return [];
1338
+ bound = false;
1339
+ const errors = [];
1340
+ for (const release of resources.splice(0).reverse()) try {
1341
+ release();
1342
+ } catch (error) {
1343
+ errors.push(error);
1344
+ }
1345
+ return errors;
1346
+ };
1347
+ const emitRaw = (notice) => {
1348
+ if (physical.active()) sink(notice);
1349
+ };
1350
+ const measure = () => {
1351
+ const box = viewport.getBoundingClientRect();
1352
+ return {
1353
+ viewportHeight: viewport.clientHeight,
1354
+ scrollTop: viewport.scrollTop,
1355
+ scrollHeight: viewport.scrollHeight,
1356
+ rows: rows.map((row) => {
1357
+ const rect = row.getBoundingClientRect();
1358
+ return {
1359
+ top: rect.top - box.top - viewport.clientTop + viewport.scrollTop,
1360
+ height: rect.height
1361
+ };
1362
+ })
1363
+ };
1364
+ };
1365
+ const measureOwned = () => bound && physical.active() ? measure() : void 0;
1366
+ const measured = () => {
1367
+ const geometry = measureOwned();
1368
+ if (geometry) emitRaw({
1369
+ type: "INPUT",
1370
+ token: captured,
1371
+ signal: {
1372
+ type: "MEASURE",
1373
+ geometry
1374
+ },
1375
+ sampledAt: view.performance.now()
1376
+ });
1377
+ };
1378
+ const facts = (event) => ({
1379
+ type: event.type,
1380
+ timeStamp: event.timeStamp,
1381
+ isTrusted: event.isTrusted
1382
+ });
1383
+ const pointer = (event) => ({
1384
+ ...facts(event),
1385
+ pointerId: event.pointerId,
1386
+ pointerType: event.pointerType,
1387
+ clientX: event.clientX,
1388
+ clientY: event.clientY
1389
+ });
1390
+ const listeners = [
1391
+ ["scroll", (event) => emitRaw({
1392
+ type: "INPUT",
1393
+ token: captured,
1394
+ signal: {
1395
+ type: "SCROLL",
1396
+ scrollTop: viewport.scrollTop,
1397
+ ...lastCommandId === void 0 ? {} : { lastCommandId }
1398
+ },
1399
+ event: facts(event)
1400
+ })],
1401
+ ["wheel", (event) => {
1402
+ const e = event;
1403
+ emitRaw({
1404
+ type: "INPUT",
1405
+ token: captured,
1406
+ signal: {
1407
+ type: "WHEEL",
1408
+ deltaY: e.deltaY
1409
+ },
1410
+ event: {
1411
+ ...facts(e),
1412
+ deltaX: e.deltaX,
1413
+ deltaY: e.deltaY,
1414
+ deltaMode: e.deltaMode
1415
+ }
1416
+ });
1417
+ }],
1418
+ ...[
1419
+ "pointerdown",
1420
+ "pointerup",
1421
+ "pointercancel"
1422
+ ].map((type) => [type, ((event) => {
1423
+ const e = event;
1424
+ emitRaw({
1425
+ type: "INPUT",
1426
+ token: captured,
1427
+ signal: {
1428
+ type: type === "pointerdown" ? "POINTER.START" : type === "pointerup" ? "POINTER.END" : "POINTER.CANCEL",
1429
+ pointerId: e.pointerId
1430
+ },
1431
+ event: pointer(e)
1432
+ });
1433
+ })]),
1434
+ ["pointermove", (event) => emitRaw({
1435
+ type: "RAW.POINTER.MOVE",
1436
+ token: captured,
1437
+ event: pointer(event)
1438
+ })]
1439
+ ];
1440
+ try {
1441
+ for (const [type, listener] of listeners) {
1442
+ resources.push(() => viewport.removeEventListener(type, listener));
1443
+ viewport.addEventListener(type, listener, { passive: true });
1444
+ }
1445
+ if (typeof view.ResizeObserver === "function") {
1446
+ const resize = new view.ResizeObserver(measured);
1447
+ resources.push(() => resize.disconnect());
1448
+ resize.observe(viewport);
1449
+ for (const row of rows) resize.observe(row);
1450
+ }
1451
+ if (typeof view.IntersectionObserver === "function") {
1452
+ const intersect = new view.IntersectionObserver(measured);
1453
+ resources.push(() => intersect.disconnect());
1454
+ intersect.observe(viewport);
1455
+ }
1456
+ const fonts = viewport.ownerDocument.fonts;
1457
+ if (fonts) {
1458
+ resources.push(() => fonts.removeEventListener("loadingdone", measured));
1459
+ fonts.addEventListener("loadingdone", measured);
1460
+ if (fonts.ready) fonts.ready.then(measured);
1461
+ }
1462
+ } catch (error) {
1463
+ releaseResources();
1464
+ throw error;
1465
+ }
1466
+ return {
1467
+ measureOwned,
1468
+ rollback() {
1469
+ releaseResources();
1470
+ },
1471
+ release() {
1472
+ const errors = releaseResources();
1473
+ if (errors.length) throw errors[0];
1474
+ },
1475
+ execute(request) {
1476
+ const input = request.type === "SCROLL_TO" ? request.command.token : request.token;
1477
+ if (!bound || !physical.active() || !sameToken(captured, input)) {
1478
+ if (request.type === "SCROLL_TO") emitRaw({
1479
+ type: "COMMAND.FAILED",
1480
+ token: input,
1481
+ commandId: request.command.commandId,
1482
+ reason: "unbound"
1483
+ });
1484
+ return false;
1485
+ }
1486
+ if (request.type === "MEASURE") {
1487
+ measured();
1488
+ return true;
1489
+ }
1490
+ if (request.type === "FOCUS_COLUMN") {
1491
+ viewport.focus({ preventScroll: true });
1492
+ return true;
1493
+ }
1494
+ const command = request.command;
1495
+ if (command.commandId === lastCommandId) return true;
1496
+ const previous = lastCommandId;
1497
+ lastCommandId = command.commandId;
1498
+ let geometry;
1499
+ try {
1500
+ viewport.scrollTo({
1501
+ top: command.offset,
1502
+ behavior: command.behavior
1503
+ });
1504
+ geometry = physical.measureCurrent();
1505
+ } catch {
1506
+ if (lastCommandId === command.commandId) lastCommandId = previous;
1507
+ emitRaw({
1508
+ type: "COMMAND.FAILED",
1509
+ token: captured,
1510
+ commandId: command.commandId,
1511
+ reason: "exception"
1512
+ });
1513
+ return false;
1514
+ }
1515
+ if (!geometry) {
1516
+ emitRaw({
1517
+ type: "COMMAND.FAILED",
1518
+ token: captured,
1519
+ commandId: command.commandId,
1520
+ reason: "unbound"
1521
+ });
1522
+ return false;
1523
+ }
1524
+ emitRaw({
1525
+ type: "INPUT",
1526
+ token: captured,
1527
+ signal: {
1528
+ type: "COMMAND.APPLIED",
1529
+ commandId: command.commandId,
1530
+ geometry
1531
+ },
1532
+ sampledAt: view.performance.now()
1533
+ });
1534
+ return true;
1535
+ }
1536
+ };
1537
+ }
1538
+ /**
1539
+ * 一个物理列挂载:先按 Core 票据校验物理归属,再替换可换的输入绑定。
1540
+ * 票据刷新(epoch/generation)只换 binding;真实卸载才 dispose 并送 SURFACE.DETACHED。
1541
+ */
1542
+ function attachPickerColumn(viewport, initial, rows, sink) {
1543
+ const physicalOwner = { ...initial };
1544
+ let active = true;
1545
+ let current;
1546
+ const physical = {
1547
+ active: () => active,
1548
+ measureCurrent: () => current?.measureOwned()
1549
+ };
1550
+ const first = createBinding(viewport, initial, rows, sink, physical);
1551
+ current = first;
1552
+ try {
1553
+ sink({
1554
+ type: "SURFACE.MOUNTED",
1555
+ token: physicalOwner
1556
+ });
1557
+ first.execute({
1558
+ type: "MEASURE",
1559
+ token: initial
1560
+ });
1561
+ } catch (error) {
1562
+ active = false;
1563
+ first.rollback();
1564
+ throw error;
1565
+ }
1566
+ return {
1567
+ get binding() {
1568
+ if (!current) throw new Error("No physical binding");
1569
+ return current;
1570
+ },
1571
+ bind(token, nextRows) {
1572
+ if (!sameMount(physicalOwner, token)) throw new Error("Binding does not belong to this physical mount");
1573
+ if (!active) throw new Error("Cannot bind a detached physical surface");
1574
+ const previous = current;
1575
+ previous?.release();
1576
+ let own;
1577
+ try {
1578
+ own = createBinding(viewport, token, nextRows, sink, physical);
1579
+ current = own;
1580
+ own.execute({
1581
+ type: "MEASURE",
1582
+ token
1583
+ });
1584
+ return own;
1585
+ } catch (error) {
1586
+ own?.rollback();
1587
+ if (own && current === own) current = previous;
1588
+ throw error;
1589
+ }
1590
+ },
1591
+ dispose() {
1592
+ if (!active) return;
1593
+ active = false;
1594
+ const errors = [];
1595
+ try {
1596
+ current?.release();
1597
+ } catch (error) {
1598
+ errors.push(error);
1599
+ }
1600
+ try {
1601
+ sink({
1602
+ type: "SURFACE.DETACHED",
1603
+ token: physicalOwner
1604
+ });
1605
+ } catch (error) {
1606
+ errors.push(error);
1607
+ }
1608
+ if (errors.length) throw errors[0];
1609
+ }
1610
+ };
1611
+ }
1612
+ /**
1613
+ * 三栈共用的列生命周期胶水。getHost 每次返回最新 api(React/Vue/WC 每次渲染都会 connect 一次)。
1614
+ * Core 未签发票据(工具栏关闭、会话失效)时保持物理挂载但不输入;票据回来后只换绑定。
1615
+ */
1616
+ function connectPickerColumn(getHost, viewport, columnIndex, getRows) {
1617
+ let surface;
1618
+ let owner;
1619
+ let bound;
1620
+ let boundRows = [];
1621
+ let disposed = false;
1622
+ const sink = (notice) => {
1623
+ if (notice.type === "INPUT") getHost().input(notice.token, notice.signal);
1624
+ else if (notice.type === "SURFACE.DETACHED") getHost().unmountColumn(notice.token);
1625
+ };
1626
+ const sameRows = (a, b) => a.length === b.length && a.every((row, index) => row === b[index]);
1627
+ const release = () => {
1628
+ const previous = surface;
1629
+ surface = void 0;
1630
+ owner = void 0;
1631
+ bound = void 0;
1632
+ boundRows = [];
1633
+ previous?.dispose();
1634
+ };
1635
+ return {
1636
+ sync() {
1637
+ if (disposed) return;
1638
+ let token = getHost().getColumnToken(columnIndex);
1639
+ if (token && owner && !sameMount(token, owner)) release();
1640
+ if (!surface) {
1641
+ if (!token) {
1642
+ getHost().mountColumn(columnIndex);
1643
+ token = getHost().getColumnToken(columnIndex);
1644
+ }
1645
+ if (!token) return;
1646
+ const rows = getRows();
1647
+ surface = attachPickerColumn(viewport, token, rows, sink);
1648
+ owner = token;
1649
+ bound = token;
1650
+ boundRows = rows;
1651
+ } else if (token) {
1652
+ const rows = getRows();
1653
+ if (!bound || !sameToken(token, bound) || !sameRows(rows, boundRows)) {
1654
+ surface.bind(token, rows);
1655
+ bound = token;
1656
+ boundRows = rows;
1657
+ }
1658
+ }
1659
+ if (!token || !surface || !bound) return;
1660
+ for (const command of getHost().commands) if (sameToken(command.token, bound)) surface.binding.execute({
1661
+ type: "SCROLL_TO",
1662
+ command
1663
+ });
1664
+ },
1665
+ dispose() {
1666
+ if (disposed) return;
1667
+ disposed = true;
1668
+ release();
1669
+ }
1670
+ };
1671
+ }
1672
+ //#endregion
1673
+ export { isPickerOptionSelectable as _, getPickerAccessibleName as a, isPickerValue as c, pickerMachine as d, PickerSelectionModel as f, getPickerOptionIndex as g, getPickerKeyboardTarget as h, createPickerProps as i, resolvePickerColumns as l, getPickerFirstValue as m, connectPickerColumn as n, getPickerDataAttrs as o, getPickerDiagnostics as p, connectPicker as r, isPickerColumns as s, attachPickerColumn as t, resolvePickerMode as u };
1674
+
1675
+ //# sourceMappingURL=picker-BykFntQN.js.map