@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.
- package/README.md +21 -37
- package/dist/action-sheet/action-sheet.d.ts +110 -0
- package/dist/action-sheet/index.d.ts +2 -0
- package/dist/action-sheet/index.js +2 -0
- package/dist/action-sheet-Cvcr1S_m.js +183 -0
- package/dist/action-sheet-Cvcr1S_m.js.map +1 -0
- package/dist/area-picker/area-picker.d.ts +113 -0
- package/dist/area-picker/index.d.ts +1 -0
- package/dist/area-picker/index.js +348 -0
- package/dist/area-picker/index.js.map +1 -0
- package/dist/aria-description-CimD2M_C.js +13 -0
- package/dist/aria-description-CimD2M_C.js.map +1 -0
- package/dist/aria-description.d.ts +2 -0
- package/dist/avatar/avatar-load.d.ts +76 -0
- package/dist/avatar/avatar.d.ts +22 -5
- package/dist/avatar/index.d.ts +1 -0
- package/dist/avatar/index.js +57 -18
- package/dist/avatar/index.js.map +1 -1
- package/dist/avatar-load-w9dq05oV.js +139 -0
- package/dist/avatar-load-w9dq05oV.js.map +1 -0
- package/dist/back-top/back-top.d.ts +77 -0
- package/dist/back-top/index.d.ts +1 -0
- package/dist/back-top/index.js +189 -0
- package/dist/back-top/index.js.map +1 -0
- package/dist/badge/badge.d.ts +9 -0
- package/dist/badge/index.js +14 -1
- package/dist/badge/index.js.map +1 -1
- package/dist/button/button.d.ts +13 -0
- package/dist/button/index.js +3 -5
- package/dist/button/index.js.map +1 -1
- package/dist/calendar/calendar.d.ts +100 -0
- package/dist/calendar/index.d.ts +1 -0
- package/dist/calendar/index.js +2 -0
- package/dist/calendar-CmpK3stz.js +363 -0
- package/dist/calendar-CmpK3stz.js.map +1 -0
- package/dist/card/card.d.ts +68 -0
- package/dist/card/index.d.ts +2 -0
- package/dist/card/index.js +2 -0
- package/dist/card-DRtWa6Cr.js +107 -0
- package/dist/card-DRtWa6Cr.js.map +1 -0
- package/dist/cascader/cascader.d.ts +115 -0
- package/dist/cascader/index.d.ts +1 -0
- package/dist/cascader/index.js +2 -0
- package/dist/cascader-D-xMjs7P.js +333 -0
- package/dist/cascader-D-xMjs7P.js.map +1 -0
- package/dist/cell/cell.d.ts +41 -0
- package/dist/cell/index.d.ts +1 -0
- package/dist/cell/index.js +43 -0
- package/dist/cell/index.js.map +1 -0
- package/dist/check-list/check-list.d.ts +78 -0
- package/dist/check-list/index.d.ts +2 -0
- package/dist/check-list/index.js +2 -0
- package/dist/check-list-BvZHQt5w.js +60 -0
- package/dist/check-list-BvZHQt5w.js.map +1 -0
- package/dist/checkbox/checkbox.d.ts +59 -0
- package/dist/checkbox/index.d.ts +2 -0
- package/dist/checkbox/index.js +2 -0
- package/dist/checkbox-BlndJrz5.js +127 -0
- package/dist/checkbox-BlndJrz5.js.map +1 -0
- package/dist/checkbox-group/checkbox-group.d.ts +86 -0
- package/dist/checkbox-group/index.d.ts +3 -0
- package/dist/checkbox-group/index.js +2 -0
- package/dist/checkbox-group-gGfsTv-e.js +223 -0
- package/dist/checkbox-group-gGfsTv-e.js.map +1 -0
- package/dist/choice-group-C4c9m0qe.js +373 -0
- package/dist/choice-group-C4c9m0qe.js.map +1 -0
- package/dist/circle/circle.d.ts +97 -0
- package/dist/circle/index.d.ts +1 -0
- package/dist/circle/index.js +119 -0
- package/dist/circle/index.js.map +1 -0
- package/dist/collapse/collapse.d.ts +98 -0
- package/dist/collapse/index.d.ts +2 -0
- package/dist/collapse/index.js +2 -0
- package/dist/collapse-B969h7-H.js +226 -0
- package/dist/collapse-B969h7-H.js.map +1 -0
- package/dist/countdown/countdown.d.ts +114 -0
- package/dist/countdown/index.d.ts +1 -0
- package/dist/countdown/index.js +309 -0
- package/dist/countdown/index.js.map +1 -0
- package/dist/date-picker/date-picker.d.ts +168 -0
- package/dist/date-picker/index.d.ts +1 -0
- package/dist/date-picker/index.js +401 -0
- package/dist/date-picker/index.js.map +1 -0
- package/dist/descriptions/descriptions.d.ts +69 -0
- package/dist/descriptions/index.d.ts +1 -0
- package/dist/descriptions/index.js +86 -0
- package/dist/descriptions/index.js.map +1 -0
- package/dist/dialog/dialog.d.ts +32 -3
- package/dist/dialog/index.js +58 -3
- package/dist/dialog/index.js.map +1 -1
- package/dist/divider/divider.d.ts +18 -2
- package/dist/divider/index.js +20 -2
- package/dist/divider/index.js.map +1 -1
- package/dist/dropdown/dropdown.d.ts +172 -0
- package/dist/dropdown/index.d.ts +2 -0
- package/dist/dropdown/index.js +467 -0
- package/dist/dropdown/index.js.map +1 -0
- package/dist/ellipsis/ellipsis-layout.d.ts +34 -0
- package/dist/ellipsis/ellipsis.d.ts +88 -0
- package/dist/ellipsis/index.d.ts +2 -0
- package/dist/ellipsis/index.js +320 -0
- package/dist/ellipsis/index.js.map +1 -0
- package/dist/empty/empty-illustration.d.ts +3 -0
- package/dist/empty/empty.d.ts +43 -1
- package/dist/empty/index.js +2 -21
- package/dist/empty-CAgyvhUI.js +166 -0
- package/dist/empty-CAgyvhUI.js.map +1 -0
- package/dist/field/field.d.ts +95 -0
- package/dist/field/index.d.ts +2 -0
- package/dist/field/index.js +2 -0
- package/dist/field-DMHGIMZF.js +241 -0
- package/dist/field-DMHGIMZF.js.map +1 -0
- package/dist/floating-bubble/floating-bubble.d.ts +116 -0
- package/dist/floating-bubble/index.d.ts +1 -0
- package/dist/floating-bubble/index.js +333 -0
- package/dist/floating-bubble/index.js.map +1 -0
- package/dist/floating-panel/floating-panel.d.ts +80 -0
- package/dist/floating-panel/index.d.ts +2 -0
- package/dist/floating-panel/index.js +2 -0
- package/dist/floating-panel-Cbm5njBJ.js +363 -0
- package/dist/floating-panel-Cbm5njBJ.js.map +1 -0
- package/dist/footer/footer.d.ts +94 -0
- package/dist/footer/index.d.ts +1 -0
- package/dist/footer/index.js +154 -0
- package/dist/footer/index.js.map +1 -0
- package/dist/form/connect.d.ts +6 -0
- package/dist/form/form.d.ts +100 -0
- package/dist/form/ids.d.ts +14 -0
- package/dist/form/index.d.ts +13 -0
- package/dist/form/index.js +3 -0
- package/dist/form/methods.d.ts +5 -0
- package/dist/form/model.d.ts +24 -0
- package/dist/form/native.d.ts +25 -0
- package/dist/form/rules.d.ts +40 -0
- package/dist/form/ssr.d.ts +7 -0
- package/dist/form/types.d.ts +150 -0
- package/dist/form-BAGkIEMY.js +1354 -0
- package/dist/form-BAGkIEMY.js.map +1 -0
- package/dist/format-BDUY0C_c.js +89 -0
- package/dist/format-BDUY0C_c.js.map +1 -0
- package/dist/gesture-_SRHIvBm.js +30 -0
- package/dist/gesture-_SRHIvBm.js.map +1 -0
- package/dist/grid/grid-item.d.ts +22 -0
- package/dist/grid/grid.d.ts +42 -0
- package/dist/grid/index.d.ts +2 -0
- package/dist/grid/index.js +73 -0
- package/dist/grid/index.js.map +1 -0
- package/dist/icon/icon.d.ts +37 -1
- package/dist/icon/identity.d.ts +3 -0
- package/dist/icon/index.js +2 -20
- package/dist/icon-Cgdbnk1u.js +77 -0
- package/dist/icon-Cgdbnk1u.js.map +1 -0
- package/dist/image/image-load.d.ts +24 -0
- package/dist/image/image.d.ts +45 -8
- package/dist/image/index.d.ts +1 -0
- package/dist/image/index.js +116 -14
- package/dist/image/index.js.map +1 -1
- package/dist/image-preview/image-preview.d.ts +124 -0
- package/dist/image-preview/index.d.ts +1 -0
- package/dist/image-preview/index.js +450 -0
- package/dist/image-preview/index.js.map +1 -0
- package/dist/index-bar/index-bar.d.ts +121 -0
- package/dist/index-bar/index.d.ts +1 -0
- package/dist/index-bar/index.js +386 -0
- package/dist/index-bar/index.js.map +1 -0
- package/dist/index.d.ts +107 -14
- package/dist/index.js +148 -14
- package/dist/index.js.map +1 -0
- package/dist/infinite-scroll/index.d.ts +1 -0
- package/dist/infinite-scroll/index.js +248 -0
- package/dist/infinite-scroll/index.js.map +1 -0
- package/dist/infinite-scroll/infinite-scroll.d.ts +95 -0
- package/dist/input/index.js +181 -22
- package/dist/input/index.js.map +1 -1
- package/dist/input/input.d.ts +44 -1
- package/dist/layer-IpFrl5--.js +414 -0
- package/dist/layer-IpFrl5--.js.map +1 -0
- package/dist/layout-BRSqi4AQ.js +43 -0
- package/dist/layout-BRSqi4AQ.js.map +1 -0
- package/dist/layout.d.ts +13 -0
- package/dist/list/index.d.ts +2 -0
- package/dist/list/index.js +2 -0
- package/dist/list/list.d.ts +30 -0
- package/dist/list-6-iz-Irh.js +28 -0
- package/dist/list-6-iz-Irh.js.map +1 -0
- package/dist/loading/index.js +45 -2
- package/dist/loading/index.js.map +1 -1
- package/dist/loading/loading.d.ts +45 -2
- package/dist/modal-dialog-machine-CF9_z3Dm.js +487 -0
- package/dist/modal-dialog-machine-CF9_z3Dm.js.map +1 -0
- package/dist/modal-dialog-machine.d.ts +21 -0
- package/dist/modal-dismissable-lifetime.d.ts +21 -0
- package/dist/modal-registry.d.ts +24 -0
- package/dist/modal-render-hydration.d.ts +35 -0
- package/dist/modal-render-runtime.d.ts +19 -0
- package/dist/modal-render-scope.d.ts +63 -0
- package/dist/nav-bar/index.d.ts +1 -0
- package/dist/nav-bar/index.js +115 -0
- package/dist/nav-bar/index.js.map +1 -0
- package/dist/nav-bar/nav-bar.d.ts +76 -0
- package/dist/notice-bar/index.d.ts +2 -0
- package/dist/notice-bar/index.js +2 -0
- package/dist/notice-bar/notice-bar.d.ts +103 -0
- package/dist/notice-bar-DMpwLvRb.js +231 -0
- package/dist/notice-bar-DMpwLvRb.js.map +1 -0
- package/dist/notify/index.d.ts +1 -0
- package/dist/notify/index.js +251 -0
- package/dist/notify/index.js.map +1 -0
- package/dist/notify/notify.d.ts +123 -0
- package/dist/number-keyboard/index.d.ts +1 -0
- package/dist/number-keyboard/index.js +333 -0
- package/dist/number-keyboard/index.js.map +1 -0
- package/dist/number-keyboard/number-keyboard.d.ts +141 -0
- package/dist/page-indicator/index.d.ts +1 -0
- package/dist/page-indicator/index.js +138 -0
- package/dist/page-indicator/index.js.map +1 -0
- package/dist/page-indicator/page-indicator.d.ts +93 -0
- package/dist/pagination/index.d.ts +1 -0
- package/dist/pagination/index.js +198 -0
- package/dist/pagination/index.js.map +1 -0
- package/dist/pagination/pagination.d.ts +125 -0
- package/dist/password-input/index.d.ts +1 -0
- package/dist/password-input/index.js +317 -0
- package/dist/password-input/index.js.map +1 -0
- package/dist/password-input/password-input.d.ts +144 -0
- package/dist/picker/index.d.ts +8 -0
- package/dist/picker/index.js +2 -0
- package/dist/picker/picker-machine.d.ts +80 -0
- package/dist/picker/picker.d.ts +121 -0
- package/dist/picker/platform.d.ts +84 -0
- package/dist/picker/selection-connect.d.ts +90 -0
- package/dist/picker/selection-model.d.ts +211 -0
- package/dist/picker-BykFntQN.js +1675 -0
- package/dist/picker-BykFntQN.js.map +1 -0
- package/dist/popover/index.d.ts +3 -0
- package/dist/popover/index.js +253 -0
- package/dist/popover/index.js.map +1 -0
- package/dist/popover/layer.d.ts +44 -0
- package/dist/popover/popover.d.ts +104 -0
- package/dist/popover/positioning.d.ts +132 -0
- package/dist/popup/index.d.ts +2 -0
- package/dist/popup/index.js +2 -0
- package/dist/popup/popup.d.ts +60 -0
- package/dist/popup-z5d8IYCt.js +576 -0
- package/dist/popup-z5d8IYCt.js.map +1 -0
- package/dist/portal-BHCNTWhg.js +78 -0
- package/dist/portal-BHCNTWhg.js.map +1 -0
- package/dist/portal.d.ts +61 -0
- package/dist/price/format.d.ts +19 -0
- package/dist/price/index.d.ts +1 -0
- package/dist/price/index.js +154 -0
- package/dist/price/index.js.map +1 -0
- package/dist/price/price.d.ts +88 -0
- package/dist/progress/index.d.ts +1 -0
- package/dist/progress/index.js +2 -0
- package/dist/progress/progress.d.ts +32 -0
- package/dist/progress-f3iYEfdA.js +37 -0
- package/dist/progress-f3iYEfdA.js.map +1 -0
- package/dist/pull-refresh/index.d.ts +1 -0
- package/dist/pull-refresh/index.js +414 -0
- package/dist/pull-refresh/index.js.map +1 -0
- package/dist/pull-refresh/pull-refresh.d.ts +118 -0
- package/dist/radio-group/index.d.ts +3 -0
- package/dist/radio-group/index.js +2 -0
- package/dist/radio-group/radio-group.d.ts +78 -0
- package/dist/radio-group-BOIMuqnS.js +230 -0
- package/dist/radio-group-BOIMuqnS.js.map +1 -0
- package/dist/rate/index.d.ts +1 -0
- package/dist/rate/index.js +2 -0
- package/dist/rate/rate-form.d.ts +28 -0
- package/dist/rate/rate.d.ts +144 -0
- package/dist/rate-5XsU2QkY.js +631 -0
- package/dist/rate-5XsU2QkY.js.map +1 -0
- package/dist/reorder/index.d.ts +1 -0
- package/dist/reorder/index.js +720 -0
- package/dist/reorder/index.js.map +1 -0
- package/dist/reorder/reorder.d.ts +190 -0
- package/dist/result/index.d.ts +1 -0
- package/dist/result/index.js +123 -0
- package/dist/result/index.js.map +1 -0
- package/dist/result/result.d.ts +88 -0
- package/dist/safe-area/index.d.ts +1 -0
- package/dist/safe-area/index.js +42 -0
- package/dist/safe-area/index.js.map +1 -0
- package/dist/safe-area/safe-area.d.ts +28 -0
- package/dist/search-bar/index.js +3 -1
- package/dist/search-bar/index.js.map +1 -1
- package/dist/search-bar/search-bar.d.ts +4 -0
- package/dist/segmented/index.d.ts +2 -0
- package/dist/segmented/index.js +2 -0
- package/dist/segmented/segmented.d.ts +127 -0
- package/dist/segmented-BaU38_L4.js +367 -0
- package/dist/segmented-BaU38_L4.js.map +1 -0
- package/dist/selection-form-BOM_odUk.js +88 -0
- package/dist/selection-form-BOM_odUk.js.map +1 -0
- package/dist/selection-form.d.ts +27 -0
- package/dist/selection-ivXqO1eu.js +55 -0
- package/dist/selection-ivXqO1eu.js.map +1 -0
- package/dist/selection.d.ts +29 -0
- package/dist/selector/choice-group.d.ts +114 -0
- package/dist/selector/index.d.ts +2 -0
- package/dist/selector/index.js +2 -0
- package/dist/selector/selector.d.ts +90 -0
- package/dist/selector-BU2MMJ4N.js +93 -0
- package/dist/selector-BU2MMJ4N.js.map +1 -0
- package/dist/share-sheet/index.d.ts +1 -0
- package/dist/share-sheet/index.js +138 -0
- package/dist/share-sheet/index.js.map +1 -0
- package/dist/share-sheet/share-sheet.d.ts +139 -0
- package/dist/skeleton/index.js +51 -2
- package/dist/skeleton/index.js.map +1 -1
- package/dist/skeleton/skeleton.d.ts +34 -3
- package/dist/slider/index.d.ts +1 -0
- package/dist/slider/index.js +482 -0
- package/dist/slider/index.js.map +1 -0
- package/dist/slider/slider.d.ts +174 -0
- package/dist/space/index.d.ts +1 -0
- package/dist/space/index.js +52 -0
- package/dist/space/index.js.map +1 -0
- package/dist/space/space.d.ts +46 -0
- package/dist/statistic/index.d.ts +1 -0
- package/dist/statistic/index.js +152 -0
- package/dist/statistic/index.js.map +1 -0
- package/dist/statistic/statistic.d.ts +101 -0
- package/dist/stepper/index.js +62 -3
- package/dist/stepper/index.js.map +1 -1
- package/dist/stepper/stepper.d.ts +44 -4
- package/dist/steps/index.d.ts +1 -0
- package/dist/steps/index.js +72 -0
- package/dist/steps/index.js.map +1 -0
- package/dist/steps/steps.d.ts +67 -0
- package/dist/sticky/index.d.ts +1 -0
- package/dist/sticky/index.js +145 -0
- package/dist/sticky/index.js.map +1 -0
- package/dist/sticky/sticky.d.ts +70 -0
- package/dist/swipe-action/index.d.ts +1 -0
- package/dist/swipe-action/index.js +417 -0
- package/dist/swipe-action/index.js.map +1 -0
- package/dist/swipe-action/swipe-action.d.ts +148 -0
- package/dist/swiper/gesture.d.ts +32 -0
- package/dist/swiper/index.d.ts +1 -0
- package/dist/swiper/index.js +2 -0
- package/dist/swiper/swiper.d.ts +177 -0
- package/dist/swiper-BKivDkHp.js +550 -0
- package/dist/swiper-BKivDkHp.js.map +1 -0
- package/dist/switch/index.js +135 -10
- package/dist/switch/index.js.map +1 -1
- package/dist/switch/switch.d.ts +93 -6
- package/dist/tabbar/index.js +46 -1
- package/dist/tabbar/index.js.map +1 -1
- package/dist/tabbar/tabbar.d.ts +50 -0
- package/dist/tabs/index.js +22 -1
- package/dist/tabs/index.js.map +1 -1
- package/dist/tabs/tabs.d.ts +12 -8
- package/dist/tag/index.js +123 -2
- package/dist/tag/index.js.map +1 -1
- package/dist/tag/tag.d.ts +67 -1
- package/dist/textarea/index.d.ts +2 -0
- package/dist/textarea/index.js +2 -242
- package/dist/textarea/platform.d.ts +22 -0
- package/dist/textarea/textarea.d.ts +165 -46
- package/dist/textarea-qbnruDUG.js +775 -0
- package/dist/textarea-qbnruDUG.js.map +1 -0
- package/dist/time-picker/index.d.ts +1 -0
- package/dist/time-picker/index.js +228 -0
- package/dist/time-picker/index.js.map +1 -0
- package/dist/time-picker/time-picker.d.ts +83 -0
- package/dist/timeline/index.d.ts +1 -0
- package/dist/timeline/index.js +131 -0
- package/dist/timeline/index.js.map +1 -0
- package/dist/timeline/timeline.d.ts +79 -0
- package/dist/toast/index.js +47 -4
- package/dist/toast/index.js.map +1 -1
- package/dist/toast/toast.d.ts +26 -3
- package/dist/top-bar/index.js +16 -2
- package/dist/top-bar/index.js.map +1 -1
- package/dist/top-bar/top-bar.d.ts +13 -2
- package/dist/tree-select/index.d.ts +1 -0
- package/dist/tree-select/index.js +512 -0
- package/dist/tree-select/index.js.map +1 -0
- package/dist/tree-select/tree-select.d.ts +215 -0
- package/dist/typography/index.d.ts +1 -0
- package/dist/typography/index.js +82 -0
- package/dist/typography/index.js.map +1 -0
- package/dist/typography/typography.d.ts +54 -0
- package/dist/upload/index.d.ts +1 -0
- package/dist/upload/index.js +458 -0
- package/dist/upload/index.js.map +1 -0
- package/dist/upload/upload.d.ts +172 -0
- package/dist/virtual-list/index.d.ts +1 -0
- package/dist/virtual-list/index.js +445 -0
- package/dist/virtual-list/index.js.map +1 -0
- package/dist/virtual-list/virtual-list.d.ts +160 -0
- package/dist/visual-manifest.d.ts +6 -0
- package/dist/watermark/index.d.ts +1 -0
- package/dist/watermark/index.js +260 -0
- package/dist/watermark/index.js.map +1 -0
- package/dist/watermark/watermark.d.ts +106 -0
- package/package.json +399 -50
- package/dist/empty/index.js.map +0 -1
- package/dist/icon/index.js.map +0 -1
- package/dist/textarea/index.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"segmented-BaU38_L4.js","names":[],"sources":["../src/segmented/segmented.ts"],"sourcesContent":["import { mergeDescriptionIds } from \"../aria-description.js\";\nimport { createMachine, type Machine, type Params, type Service } from \"@zag-js/core\";\nimport { dataAttr, getComputedStyle, getEventKey, visuallyHiddenStyle } from \"@zag-js/dom-query\";\nimport type { NormalizeProps, PropTypes } from \"@zag-js/types\";\nimport { normalizeSelectionItems, normalizeSelectionValue, selectionItemKey, toggleSelectionValue, type QwSelectionItem } from \"../selection.js\";\nimport { syncSelectionInputs, trackSelectionForm } from \"../selection-form.js\";\nimport { resolveIconState, type IconNameInput, type IconState } from \"../icon/index.js\";\n\n/** Supported single/multiple selection modes. */\nexport const SEGMENTED_MODES = [\"single\", \"multiple\"] as const;\n/** Existing T3 control-height sizes; large is the mobile default. */\nexport const SEGMENTED_SIZES = [\"sm\", \"md\", \"lg\"] as const;\n/** Stable DOM parts shared by every adapter. */\nexport const SEGMENTED_PARTS = [\"root\", \"label\", \"description\", \"items\", \"item\", \"input\", \"content\", \"icon\", \"text\", \"item-description\"] as const;\nexport type SegmentedSelectionMode = (typeof SEGMENTED_MODES)[number];\nexport type SegmentedSize = (typeof SEGMENTED_SIZES)[number];\n/** Accessible option name remains required even in icon-only presentation. */\nexport interface QwSegmentedItem extends QwSelectionItem { icon?: IconNameInput; iconOnly?: boolean }\n/** Requested ordered values; callers receive independent snapshots. */\nexport interface SegmentedValueChangeDetails { value: string[] }\n/** SSR-safe input shared by all adapters. */\nexport interface QwSegmentedProps {\n id?: string;\n /** Visible, nonempty accessible group name rendered as legend. */\n label: string;\n description?: string;\n /** External Field help/error references, merged with the control-owned description. */\n describedBy?: string;\n /** Unique nonempty values and nonempty accessible labels. */\n items: QwSegmentedItem[];\n selectionMode?: SegmentedSelectionMode;\n /** Defined arrays, including [], are controlled. Unknown values are retained. */\n value?: string[];\n /** Initial value and form reset target; defaults to []. */\n defaultValue?: string[];\n /** Allow a selected single item to toggle off; defaults false. */\n allowEmpty?: boolean;\n /** Minimum/maximum apply only to multiple-mode user removals/additions. */\n min?: number;\n max?: number;\n disabled?: boolean;\n /** Block user selection while retaining focus and native submitted values. */\n readOnly?: boolean;\n /** Native form validation requires an enabled rendered selection. */\n required?: boolean;\n invalid?: boolean;\n name?: string;\n form?: string;\n orientation?: \"horizontal\" | \"vertical\";\n /** Standard HTML direction; auto/empty inherit the input's direction. */\n dir?: string;\n /** Keyboard navigation wraps by default. */\n loop?: boolean;\n /** Single-mode arrow/Home/End selection; defaults true. Multiple only focuses. */\n selectOnFocus?: boolean;\n size?: SegmentedSize;\n block?: boolean;\n /** Horizontal content scrolls with intrinsic option widths. */\n scrollable?: boolean;\n onValueChange?: (details: SegmentedValueChangeDetails) => void;\n}\nexport interface QwSegmentedSchema {\n props: QwSegmentedProps & { selectionMode: SegmentedSelectionMode; defaultValue: string[]; orientation: \"horizontal\" | \"vertical\"; loop: boolean; selectOnFocus: boolean; size: SegmentedSize };\n context: { value: string[]; focusedValue: string | null; disabledIds: string[] };\n state: \"ready\";\n action: \"setValue\" | \"toggleValue\" | \"selectValue\" | \"setFocus\" | \"syncInputs\" | \"normalizeMode\";\n effect: \"trackForm\";\n event: { type: \"VALUE.SET\"; value: string[] } | { type: \"VALUE.TOGGLE\" | \"VALUE.SELECT\" | \"FOCUS\"; value: string };\n}\nexport type QwSegmentedMachine = Machine<QwSegmentedSchema>;\nexport type QwSegmentedService = Service<QwSegmentedSchema>;\nexport interface QwSegmentedItemProps { value: string }\nexport interface QwSegmentedItemState { selected: boolean; disabled: boolean; readOnly: boolean; iconOnly: boolean }\n\n/** Validate accessible identities and copy every caller option. */\nexport function normalizeSegmentedItems(items: readonly QwSegmentedItem[]): QwSegmentedItem[] {\n return normalizeSelectionItems(items).map((entry) => {\n const item = entry as QwSegmentedItem;\n if (typeof item.label !== \"string\" || !item.label.trim()) throw new TypeError(\"Segmented item labels must be nonempty accessible text\");\n if (item.icon !== undefined && typeof item.icon !== \"string\") throw new TypeError(\"Segmented icons must be system icon names\");\n if (item.iconOnly && !item.icon?.trim()) throw new TypeError(\"Segmented icon-only items require an icon and accessible label\");\n return { ...item };\n });\n}\n/** Single selection retains the earliest unique caller value, including unknowns. */\nexport function normalizeSegmentedValue(value: readonly string[] = [], mode: SegmentedSelectionMode = \"single\"): string[] {\n const values = normalizeSelectionValue(value);\n return mode === \"single\" ? values.slice(0, 1) : values;\n}\nexport function createSegmentedProps(props: QwSegmentedProps): Partial<QwSegmentedSchema[\"props\"]> {\n if (typeof props.label !== \"string\" || !props.label.trim()) throw new TypeError(\"Segmented requires a nonempty accessible group label\");\n if (props.id !== undefined && (typeof props.id !== \"string\" || !props.id.trim())) throw new TypeError(\"Segmented requires a nonempty instance id when provided\");\n const selectionMode = SEGMENTED_MODES.includes(props.selectionMode!) ? props.selectionMode! : \"single\";\n return { ...props, selectionMode, items: normalizeSegmentedItems(props.items), value: props.value === undefined ? undefined : normalizeSegmentedValue(props.value, selectionMode), defaultValue: normalizeSegmentedValue(props.defaultValue, selectionMode),\n orientation: props.orientation === \"vertical\" ? \"vertical\" : \"horizontal\", loop: props.loop ?? true, selectOnFocus: props.selectOnFocus ?? true, size: SEGMENTED_SIZES.includes(props.size!) ? props.size! : \"md\" };\n}\nconst same = (a: string[], b: string[] | undefined) => !!b && a.length === b.length && a.every((value, index) => value === b[index]);\nconst rootId = (scope: QwSegmentedService[\"scope\"]) => `segmented:${scope.id}`;\nconst inputId = (scope: QwSegmentedService[\"scope\"], value: string) => `${rootId(scope)}:input:${selectionItemKey(value)}`;\ntype GroupParams = Pick<Params<QwSegmentedSchema>, \"scope\" | \"context\" | \"prop\">;\nfunction currentValue(params: GroupParams) { return normalizeSegmentedValue(params.context.get(\"value\"), params.prop(\"selectionMode\")); }\nfunction isDisabled(params: GroupParams, item: QwSegmentedItem) { return !!params.prop(\"disabled\") || !!item.disabled || params.context.get(\"disabledIds\").includes(inputId(params.scope, item.value)); }\nfunction sync(params: GroupParams) {\n const values = currentValue(params);\n syncSelectionInputs(params.scope, params.prop(\"items\").map((item) => ({ id: inputId(params.scope, item.value), checked: values.includes(item.value) })));\n}\nfunction changeFor(params: GroupParams, value: string, selectOnly = false): string[] | null {\n const item = params.prop(\"items\").find((entry) => entry.value === value);\n if (!item || isDisabled(params, item) || params.prop(\"readOnly\")) return null;\n const values = currentValue(params);\n if (params.prop(\"selectionMode\") === \"single\") return values.includes(value) ? (!selectOnly && params.prop(\"allowEmpty\") ? [] : values) : [value];\n const result = toggleSelectionValue(values, item, { min: params.prop(\"min\"), max: params.prop(\"max\") });\n return result.blocked ? null : result.value;\n}\n\n/** One Zag bindable lifecycle; Core alone owns selection, keys and native forms. */\nexport const segmentedMachine: QwSegmentedMachine = createMachine<QwSegmentedSchema>({\n props: ({ props }) => createSegmentedProps({ ...props, label: props.label ?? \"\", items: props.items ?? [] }) as QwSegmentedSchema[\"props\"],\n initialState: () => \"ready\",\n context({ prop, bindable }) {\n return {\n value: bindable(() => ({ defaultValue: prop(\"defaultValue\"), value: prop(\"value\"), isEqual: same, onChange: (value) => prop(\"onValueChange\")?.({ value: [...value] }) })),\n focusedValue: bindable(() => ({ defaultValue: null as string | null })),\n disabledIds: bindable(() => ({ defaultValue: [] as string[], isEqual: same })),\n };\n },\n watch({ track, context, prop, action }) {\n track([() => context.hash(\"value\"), () => context.hash(\"disabledIds\")], () => action([\"syncInputs\"]));\n track([() => prop(\"selectionMode\")], () => action([\"normalizeMode\"]));\n },\n effects: [\"trackForm\"],\n on: { \"VALUE.SET\": { actions: [\"setValue\"] }, \"VALUE.TOGGLE\": { actions: [\"toggleValue\"] }, \"VALUE.SELECT\": { actions: [\"selectValue\"] }, FOCUS: { actions: [\"setFocus\"] } },\n states: { ready: {} },\n implementations: {\n effects: { trackForm(params) {\n return trackSelectionForm({ scope: params.scope, rootId: rootId(params.scope), form: () => params.prop(\"form\"),\n getState: () => params.prop(\"items\").map((item) => ({ id: inputId(params.scope, item.value), checked: currentValue(params).includes(item.value) })),\n onReset: () => params.context.set(\"value\", normalizeSegmentedValue(params.prop(\"defaultValue\"), params.prop(\"selectionMode\"))),\n onDisabledChange: (ids) => params.context.set(\"disabledIds\", [...ids]),\n }).stop;\n } },\n actions: {\n syncInputs: sync,\n normalizeMode(params) { params.context.set(\"value\", currentValue(params)); queueMicrotask(() => sync(params)); },\n setValue(params) { if (params.event.type === \"VALUE.SET\") params.context.set(\"value\", normalizeSegmentedValue(params.event.value, params.prop(\"selectionMode\"))); queueMicrotask(() => sync(params)); },\n toggleValue(params) { if (params.event.type === \"VALUE.TOGGLE\") { const values = changeFor(params, params.event.value); if (values) params.context.set(\"value\", values); } queueMicrotask(() => sync(params)); },\n selectValue(params) { if (params.event.type === \"VALUE.SELECT\") { const values = changeFor(params, params.event.value, true); if (values) params.context.set(\"value\", values); } queueMicrotask(() => sync(params)); },\n setFocus(params) { if (params.event.type === \"FOCUS\") params.context.set(\"focusedValue\", params.event.value); },\n },\n },\n});\n\nexport interface QwSegmentedApi<T extends PropTypes = PropTypes> {\n value: string[]; items: QwSegmentedItem[]; label: string; description: string;\n setValue(value: string[]): void;\n toggleValue(value: string): void;\n getRootProps(): T[\"element\"];\n getLabelProps(): T[\"element\"];\n getDescriptionProps(): T[\"element\"];\n getItemsProps(): T[\"element\"];\n getItemState(item: QwSegmentedItemProps): QwSegmentedItemState;\n getItemProps(item: QwSegmentedItemProps): T[\"label\"];\n getInputProps(item: QwSegmentedItemProps): T[\"input\"];\n getContentProps(item: QwSegmentedItemProps): T[\"element\"];\n getItemIconProps(item: QwSegmentedItemProps): T[\"element\"];\n getItemIconState(item: QwSegmentedItemProps): IconState;\n getTextProps(item: QwSegmentedItemProps): T[\"element\"];\n getItemDescriptionProps(item: QwSegmentedItemProps): T[\"element\"];\n}\n/** Getters are SSR-pure; only client events/effects use the existing Zag DOM scope. */\nexport function connect<T extends PropTypes>(service: QwSegmentedService, normalize: NormalizeProps<T>): QwSegmentedApi<T> {\n const id = rootId(service.scope), values = currentValue(service), items = service.prop(\"items\");\n const single = service.prop(\"selectionMode\") === \"single\";\n const enabled = items.filter((item) => !isDisabled(service, item));\n const focused = service.context.get(\"focusedValue\");\n const tabAnchor = enabled.find((item) => item.value === focused) ?? enabled.find((item) => values.includes(item.value)) ?? enabled[0];\n const requiredAnchor = service.prop(\"required\") && !enabled.some((item) => values.includes(item.value)) ? enabled[0]?.value : undefined;\n const resolve = ({ value }: QwSegmentedItemProps) => { const item = items.find((entry) => entry.value === value); if (!item) throw new RangeError(\"Segmented item is not present in items\"); return item; };\n const part = (name: string) => ({ \"data-scope\": \"segmented\", \"data-part\": name });\n const data = (item: QwSegmentedItem) => ({ \"data-state\": values.includes(item.value) ? \"checked\" : \"unchecked\", \"data-disabled\": dataAttr(isDisabled(service, item)), \"data-readonly\": dataAttr(service.prop(\"readOnly\")), \"data-invalid\": dataAttr(service.prop(\"invalid\")), \"data-icon-only\": dataAttr(item.iconOnly) });\n return {\n value: [...values], items: items.map((item) => ({ ...item })), label: service.prop(\"label\"), description: service.prop(\"description\") ?? \"\",\n setValue: (value) => service.send({ type: \"VALUE.SET\", value: normalizeSegmentedValue(value, service.prop(\"selectionMode\")) }),\n toggleValue: (value) => service.send({ type: \"VALUE.TOGGLE\", value }),\n getRootProps: () => normalize.element({ ...part(\"root\"), id, role: single ? \"radiogroup\" : \"group\", disabled: !!service.prop(\"disabled\"), form: service.prop(\"form\"), dir: service.prop(\"dir\"),\n \"aria-labelledby\": `${id}:label`, \"aria-describedby\": mergeDescriptionIds(service.prop(\"description\") ? `${id}:description` : undefined, service.prop(\"describedBy\")),\n \"aria-required\": single && service.prop(\"required\") || undefined, \"aria-readonly\": single && service.prop(\"readOnly\") || undefined,\n \"aria-disabled\": service.prop(\"disabled\") || (items.length > 0 && !enabled.length) || undefined, \"aria-invalid\": service.prop(\"invalid\") || undefined,\n \"data-selection-mode\": service.prop(\"selectionMode\"), \"data-orientation\": service.prop(\"orientation\"), \"data-size\": service.prop(\"size\"),\n \"data-block\": dataAttr(service.prop(\"block\")), \"data-scrollable\": dataAttr(service.prop(\"scrollable\")), \"data-disabled\": dataAttr(service.prop(\"disabled\")), \"data-readonly\": dataAttr(service.prop(\"readOnly\")), \"data-invalid\": dataAttr(service.prop(\"invalid\")) }),\n getLabelProps: () => normalize.element({ ...part(\"label\"), id: `${id}:label` }),\n getDescriptionProps: () => normalize.element({ ...part(\"description\"), id: `${id}:description` }),\n getItemsProps: () => normalize.element(part(\"items\")),\n getItemState: (props) => { const item = resolve(props); return { selected: values.includes(item.value), disabled: isDisabled(service, item), readOnly: !!service.prop(\"readOnly\"), iconOnly: !!item.iconOnly }; },\n getItemProps: (props) => { const item = resolve(props); return normalize.label({ ...part(\"item\"), ...data(item), htmlFor: inputId(service.scope, item.value) }); },\n getInputProps(props) {\n const item = resolve(props), disabled = isDisabled(service, item);\n return normalize.input({ ...part(\"input\"), ...data(item), id: inputId(service.scope, item.value), type: single ? \"radio\" : \"checkbox\", value: item.value,\n checked: values.includes(item.value), disabled: !!service.prop(\"disabled\") || !!item.disabled, readOnly: !!service.prop(\"readOnly\"),\n name: disabled ? undefined : service.prop(\"name\") || (single ? service.scope.id : undefined), form: service.prop(\"form\"),\n required: single ? !!service.prop(\"required\") && !disabled : requiredAnchor === item.value, tabIndex: single ? (tabAnchor?.value === item.value ? 0 : -1) : 0,\n \"aria-checked\": values.includes(item.value), \"aria-readonly\": !single && service.prop(\"readOnly\") || undefined, \"aria-invalid\": service.prop(\"invalid\") || undefined,\n \"aria-labelledby\": `${id}:text:${selectionItemKey(item.value)}`, \"aria-describedby\": item.description ? `${id}:description:${selectionItemKey(item.value)}` : undefined,\n style: visuallyHiddenStyle, onChange() {},\n onFocus() { service.send({ type: \"FOCUS\", value: item.value }); },\n onClick(event) {\n if (event.defaultPrevented) return;\n if (!changeFor(service, item.value)) event.preventDefault();\n service.send({ type: \"VALUE.TOGGLE\", value: item.value }); queueMicrotask(() => sync(service));\n },\n onKeyDown(event) {\n if (event.defaultPrevented || event.ctrlKey || event.altKey || event.metaKey) return;\n if (event.key === \" \" || event.key === \"Enter\") { event.preventDefault(); if (!event.repeat) service.send({ type: \"VALUE.TOGGLE\", value: item.value }); queueMicrotask(() => sync(service)); return; }\n if (![\"ArrowLeft\", \"ArrowRight\", \"ArrowUp\", \"ArrowDown\", \"Home\", \"End\"].includes(event.key)) return;\n event.preventDefault();\n const candidates = service.prop(\"items\").filter((entry) => !isDisabled(service, entry));\n if (!candidates.length || isDisabled(service, item)) return;\n const direction = service.prop(\"dir\");\n const dir = direction === \"rtl\" || direction === \"ltr\" ? direction : getComputedStyle(event.currentTarget).direction === \"rtl\" ? \"rtl\" : \"ltr\";\n const key = getEventKey(event, { dir }), index = candidates.findIndex((entry) => entry.value === item.value);\n let target = key === \"Home\" ? 0 : key === \"End\" ? candidates.length - 1 : index + (key === \"ArrowRight\" || key === \"ArrowDown\" ? 1 : -1);\n if (service.prop(\"loop\")) target = (target + candidates.length) % candidates.length;\n const next = candidates[target]; if (!next) return;\n service.scope.getById<HTMLInputElement>(inputId(service.scope, next.value))?.focus();\n service.send({ type: \"FOCUS\", value: next.value });\n if (service.prop(\"selectionMode\") === \"single\" && service.prop(\"selectOnFocus\")) service.send({ type: \"VALUE.SELECT\", value: next.value });\n },\n });\n },\n getContentProps: (props) => normalize.element({ ...part(\"content\"), ...data(resolve(props)) }),\n getItemIconProps: (props) => { const item = resolve(props); return normalize.element({ ...part(\"icon\"), hidden: !item.icon, \"aria-hidden\": true }); },\n getItemIconState: (props) => { const item = resolve(props); return resolveIconState({ id: `${id}:icon:${selectionItemKey(item.value)}`, name: item.icon || \"component\" }); },\n getTextProps: (props) => { const item = resolve(props); return normalize.element({ ...part(\"text\"), id: `${id}:text:${selectionItemKey(item.value)}`, style: item.iconOnly ? visuallyHiddenStyle : undefined }); },\n getItemDescriptionProps: (props) => { const item = resolve(props); return normalize.element({ ...part(\"item-description\"), id: `${id}:description:${selectionItemKey(item.value)}` }); },\n };\n}\n"],"mappings":";;;;;;;;AASA,MAAa,kBAAkB,CAAC,UAAU,UAAU;;AAE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E,GAAG,KAAK,kBAAkB;IAAG,IAAI,GAAG,GAAG,eAAe,iBAAiB,KAAK,KAAK;GAAI,CAAC;EAAG;CACzL;AACF"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { addDomEvent, getAncestorElements, getNodeName, isHTMLElement, isInputElement, observeAttributes, observeChildren, queryAll, setProperty } from "@zag-js/dom-query";
|
|
2
|
+
//#region src/selection-form.ts
|
|
3
|
+
/** Assign properties through Zag; do not overwrite native defaultChecked. */
|
|
4
|
+
function syncSelectionInputs(scope, states) {
|
|
5
|
+
for (const state of states) {
|
|
6
|
+
const input = scope.getById(state.id);
|
|
7
|
+
if (!isInputElement(input)) continue;
|
|
8
|
+
setProperty(input, "checked", state.checked);
|
|
9
|
+
setProperty(input, "indeterminate", state.indeterminate ?? false);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/** All listeners belong to one machine lifecycle, including deferred reset work. */
|
|
13
|
+
function trackSelectionForm(options) {
|
|
14
|
+
let stopped = false;
|
|
15
|
+
let refreshQueued = false;
|
|
16
|
+
let disabledIds;
|
|
17
|
+
const cleanups = [];
|
|
18
|
+
const pendingResets = /* @__PURE__ */ new Set();
|
|
19
|
+
const release = () => {
|
|
20
|
+
cleanups.splice(0).forEach((cleanup) => cleanup());
|
|
21
|
+
};
|
|
22
|
+
const sync = () => {
|
|
23
|
+
if (!stopped) syncSelectionInputs(options.scope, options.getState());
|
|
24
|
+
};
|
|
25
|
+
const queueRefresh = () => {
|
|
26
|
+
if (stopped || refreshQueued) return;
|
|
27
|
+
refreshQueued = true;
|
|
28
|
+
queueMicrotask(() => {
|
|
29
|
+
refreshQueued = false;
|
|
30
|
+
refresh();
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
const reportDisabled = () => {
|
|
34
|
+
const nativeDisabled = new Set(queryAll(options.scope.getRootNode(), "input:disabled"));
|
|
35
|
+
const next = options.getState().filter((state) => nativeDisabled.has(options.scope.getById(state.id))).map((state) => state.id);
|
|
36
|
+
if (disabledIds?.length === next.length && disabledIds.every((id, index) => id === next[index])) return;
|
|
37
|
+
disabledIds = next;
|
|
38
|
+
options.onDisabledChange([...next]);
|
|
39
|
+
};
|
|
40
|
+
function refresh() {
|
|
41
|
+
if (stopped) return;
|
|
42
|
+
release();
|
|
43
|
+
const inputs = options.getState().map((state) => options.scope.getById(state.id)).filter(isInputElement);
|
|
44
|
+
const root = options.scope.getById(options.rootId);
|
|
45
|
+
const anchor = inputs[0] ?? root;
|
|
46
|
+
const ancestors = anchor ? getAncestorElements(anchor) : [];
|
|
47
|
+
const formId = options.form?.();
|
|
48
|
+
const form = formId !== void 0 ? options.scope.getById(formId) : inputs.length ? inputs[0].form : ancestors.find((element) => getNodeName(element) === "form");
|
|
49
|
+
if (form && getNodeName(form) === "form") cleanups.push(addDomEvent(form, "reset", (event) => {
|
|
50
|
+
const pending = setTimeout(() => {
|
|
51
|
+
pendingResets.delete(pending);
|
|
52
|
+
if (stopped || event.defaultPrevented) return;
|
|
53
|
+
options.onReset();
|
|
54
|
+
sync();
|
|
55
|
+
reportDisabled();
|
|
56
|
+
}, 0);
|
|
57
|
+
pendingResets.add(pending);
|
|
58
|
+
}));
|
|
59
|
+
const fieldsets = new Set(inputs.flatMap((input) => getAncestorElements(input)).filter((element) => isHTMLElement(element) && getNodeName(element) === "fieldset"));
|
|
60
|
+
for (const fieldset of fieldsets) cleanups.push(observeAttributes(fieldset, {
|
|
61
|
+
attributes: ["disabled"],
|
|
62
|
+
callback: queueRefresh
|
|
63
|
+
}));
|
|
64
|
+
for (const input of inputs) cleanups.push(observeAttributes(input, {
|
|
65
|
+
attributes: ["disabled", "form"],
|
|
66
|
+
callback: queueRefresh
|
|
67
|
+
}));
|
|
68
|
+
const roots = new Set([root, root ? getAncestorElements(root)[1] : void 0].filter(isHTMLElement));
|
|
69
|
+
for (const node of roots) cleanups.push(observeChildren(node, { callback: queueRefresh }));
|
|
70
|
+
sync();
|
|
71
|
+
reportDisabled();
|
|
72
|
+
}
|
|
73
|
+
refresh();
|
|
74
|
+
return {
|
|
75
|
+
sync,
|
|
76
|
+
refresh,
|
|
77
|
+
stop() {
|
|
78
|
+
stopped = true;
|
|
79
|
+
release();
|
|
80
|
+
pendingResets.forEach(clearTimeout);
|
|
81
|
+
pendingResets.clear();
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
//#endregion
|
|
86
|
+
export { trackSelectionForm as n, syncSelectionInputs as t };
|
|
87
|
+
|
|
88
|
+
//# sourceMappingURL=selection-form-BOM_odUk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selection-form-BOM_odUk.js","names":[],"sources":["../src/selection-form.ts"],"sourcesContent":["import { addDomEvent, getAncestorElements, getNodeName, isHTMLElement, isInputElement, observeAttributes, observeChildren, queryAll, setProperty } from \"@zag-js/dom-query\";\n\n/** Client effects receive a Zag scope; imports and SSR getters never create one. */\nexport interface SelectionFormScope {\n getRootNode(): Document | Element | ShadowRoot;\n getById<T extends Element = HTMLElement>(id: string): T | null;\n}\nexport interface SelectionNativeState { id: string; checked: boolean; indeterminate?: boolean }\nexport interface SelectionFormOptions {\n scope: SelectionFormScope;\n rootId: string;\n getState(): readonly SelectionNativeState[];\n form?: () => string | undefined;\n onReset(): void;\n onDisabledChange(ids: readonly string[]): void;\n}\nexport interface SelectionFormTracker { sync(): void; refresh(): void; stop(): void }\n\n/** Assign properties through Zag; do not overwrite native defaultChecked. */\nexport function syncSelectionInputs(scope: SelectionFormScope, states: readonly SelectionNativeState[]): void {\n for (const state of states) {\n const input = scope.getById<HTMLInputElement>(state.id);\n if (!isInputElement(input)) continue;\n setProperty(input, \"checked\", state.checked);\n setProperty(input, \"indeterminate\", state.indeterminate ?? false);\n }\n}\n\n/** All listeners belong to one machine lifecycle, including deferred reset work. */\nexport function trackSelectionForm(options: SelectionFormOptions): SelectionFormTracker {\n let stopped = false;\n let refreshQueued = false;\n let disabledIds: string[] | undefined;\n const cleanups: Array<() => void> = [];\n const pendingResets = new Set<ReturnType<typeof setTimeout>>();\n const release = () => { cleanups.splice(0).forEach((cleanup) => cleanup()); };\n const sync = () => { if (!stopped) syncSelectionInputs(options.scope, options.getState()); };\n const queueRefresh = () => {\n if (stopped || refreshQueued) return;\n refreshQueued = true;\n queueMicrotask(() => { refreshQueued = false; refresh(); });\n };\n const reportDisabled = () => {\n const nativeDisabled = new Set(queryAll(options.scope.getRootNode(), \"input:disabled\"));\n const next = options.getState().filter((state) => nativeDisabled.has(options.scope.getById(state.id)!)).map((state) => state.id);\n if (disabledIds?.length === next.length && disabledIds.every((id, index) => id === next[index])) return;\n disabledIds = next;\n options.onDisabledChange([...next]);\n };\n function refresh() {\n if (stopped) return;\n release();\n const inputs = options.getState().map((state) => options.scope.getById<HTMLInputElement>(state.id)).filter(isInputElement);\n const root = options.scope.getById(options.rootId);\n const anchor = inputs[0] ?? root;\n const ancestors = anchor ? getAncestorElements(anchor) : [];\n const formId = options.form?.();\n const form = formId !== undefined ? options.scope.getById(formId) : inputs.length ? inputs[0]!.form : ancestors.find((element) => getNodeName(element) === \"form\");\n if (form && getNodeName(form) === \"form\") {\n cleanups.push(addDomEvent(form, \"reset\", (event) => {\n // Native button dispatch can checkpoint microtasks before a later canceling listener.\n const pending = setTimeout(() => {\n pendingResets.delete(pending);\n if (stopped || event.defaultPrevented) return;\n options.onReset();\n sync();\n reportDisabled();\n }, 0);\n pendingResets.add(pending);\n }));\n }\n const fieldsets = new Set(inputs.flatMap((input) => getAncestorElements(input)).filter((element): element is HTMLElement => isHTMLElement(element) && getNodeName(element) === \"fieldset\"));\n for (const fieldset of fieldsets) cleanups.push(observeAttributes(fieldset, { attributes: [\"disabled\"], callback: queueRefresh }));\n for (const input of inputs) cleanups.push(observeAttributes(input, { attributes: [\"disabled\", \"form\"], callback: queueRefresh }));\n // Observe the rendered subtree and its parent so list changes/reparenting rebind.\n const roots = new Set([root, root ? getAncestorElements(root)[1] : undefined].filter(isHTMLElement));\n for (const node of roots) cleanups.push(observeChildren(node, { callback: queueRefresh }));\n sync();\n reportDisabled();\n }\n refresh();\n return { sync, refresh, stop() { stopped = true; release(); pendingResets.forEach(clearTimeout); pendingResets.clear(); } };\n}\n"],"mappings":";;;AAmBA,SAAgB,oBAAoB,OAA2B,QAA+C;CAC5G,KAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,QAAQ,MAAM,QAA0B,MAAM,EAAE;EACtD,IAAI,CAAC,eAAe,KAAK,GAAG;EAC5B,YAAY,OAAO,WAAW,MAAM,OAAO;EAC3C,YAAY,OAAO,iBAAiB,MAAM,iBAAiB,KAAK;CAClE;AACF;;AAGA,SAAgB,mBAAmB,SAAqD;CACtF,IAAI,UAAU;CACd,IAAI,gBAAgB;CACpB,IAAI;CACJ,MAAM,WAA8B,CAAC;CACrC,MAAM,gCAAgB,IAAI,IAAmC;CAC7D,MAAM,gBAAgB;EAAE,SAAS,OAAO,CAAC,CAAC,CAAC,SAAS,YAAY,QAAQ,CAAC;CAAG;CAC5E,MAAM,aAAa;EAAE,IAAI,CAAC,SAAS,oBAAoB,QAAQ,OAAO,QAAQ,SAAS,CAAC;CAAG;CAC3F,MAAM,qBAAqB;EACzB,IAAI,WAAW,eAAe;EAC9B,gBAAgB;EAChB,qBAAqB;GAAE,gBAAgB;GAAO,QAAQ;EAAG,CAAC;CAC5D;CACA,MAAM,uBAAuB;EAC3B,MAAM,iBAAiB,IAAI,IAAI,SAAS,QAAQ,MAAM,YAAY,GAAG,gBAAgB,CAAC;EACtF,MAAM,OAAO,QAAQ,SAAS,CAAC,CAAC,QAAQ,UAAU,eAAe,IAAI,QAAQ,MAAM,QAAQ,MAAM,EAAE,CAAE,CAAC,CAAC,CAAC,KAAK,UAAU,MAAM,EAAE;EAC/H,IAAI,aAAa,WAAW,KAAK,UAAU,YAAY,OAAO,IAAI,UAAU,OAAO,KAAK,MAAM,GAAG;EACjG,cAAc;EACd,QAAQ,iBAAiB,CAAC,GAAG,IAAI,CAAC;CACpC;C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,aAAa,CAAC;EACnG,KAAK,MAAM,QAAQ,OAAO,SAAS,KAAK,gBAAgB,MAAM,EAAE,UAAU,aAAa,CAAC,CAAC;EACzF,KAAK;EACL,eAAe;CACjB;CACA,QAAQ;CACR,OAAO;EAAE;EAAM;EAAS,OAAO;GAAE,UAAU;GAAM,QAAQ;GAAG,cAAc,QAAQ,YAAY;GAAG,cAAc,MAAM;EAAG;CAAE;AAC5H"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Client effects receive a Zag scope; imports and SSR getters never create one. */
|
|
2
|
+
export interface SelectionFormScope {
|
|
3
|
+
getRootNode(): Document | Element | ShadowRoot;
|
|
4
|
+
getById<T extends Element = HTMLElement>(id: string): T | null;
|
|
5
|
+
}
|
|
6
|
+
export interface SelectionNativeState {
|
|
7
|
+
id: string;
|
|
8
|
+
checked: boolean;
|
|
9
|
+
indeterminate?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface SelectionFormOptions {
|
|
12
|
+
scope: SelectionFormScope;
|
|
13
|
+
rootId: string;
|
|
14
|
+
getState(): readonly SelectionNativeState[];
|
|
15
|
+
form?: () => string | undefined;
|
|
16
|
+
onReset(): void;
|
|
17
|
+
onDisabledChange(ids: readonly string[]): void;
|
|
18
|
+
}
|
|
19
|
+
export interface SelectionFormTracker {
|
|
20
|
+
sync(): void;
|
|
21
|
+
refresh(): void;
|
|
22
|
+
stop(): void;
|
|
23
|
+
}
|
|
24
|
+
/** Assign properties through Zag; do not overwrite native defaultChecked. */
|
|
25
|
+
export declare function syncSelectionInputs(scope: SelectionFormScope, states: readonly SelectionNativeState[]): void;
|
|
26
|
+
/** All listeners belong to one machine lifecycle, including deferred reset work. */
|
|
27
|
+
export declare function trackSelectionForm(options: SelectionFormOptions): SelectionFormTracker;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
//#region src/selection.ts
|
|
2
|
+
function normalizeSelectionItems(items) {
|
|
3
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4
|
+
return items.map((item) => {
|
|
5
|
+
if (typeof item.value !== "string" || item.value.length === 0) throw new TypeError("Selection item values must be non-empty strings");
|
|
6
|
+
if (seen.has(item.value)) throw new TypeError("Selection item values must be unique");
|
|
7
|
+
seen.add(item.value);
|
|
8
|
+
return { ...item };
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
function normalizeSelectionValue(value = []) {
|
|
12
|
+
if (value.some((item) => typeof item !== "string" || item.length === 0)) throw new TypeError("Selection values must be non-empty strings");
|
|
13
|
+
return [...new Set(value)];
|
|
14
|
+
}
|
|
15
|
+
function resolveSelectionLimits(min, max) {
|
|
16
|
+
const lower = typeof min === "number" && Number.isFinite(min) ? Math.max(0, Math.floor(min)) : 0;
|
|
17
|
+
return {
|
|
18
|
+
min: lower,
|
|
19
|
+
max: typeof max === "number" && Number.isFinite(max) ? Math.max(lower, Math.floor(max), 0) : Infinity
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/** Caller values are preserved; limits apply only to a user addition/removal. */
|
|
23
|
+
function toggleSelectionValue(value, item, restrictions = {}) {
|
|
24
|
+
const values = normalizeSelectionValue(value);
|
|
25
|
+
const { min, max } = resolveSelectionLimits(restrictions.min, restrictions.max);
|
|
26
|
+
if (restrictions.disabled || item.disabled) return {
|
|
27
|
+
value: values,
|
|
28
|
+
blocked: "disabled"
|
|
29
|
+
};
|
|
30
|
+
if (restrictions.readOnly) return {
|
|
31
|
+
value: values,
|
|
32
|
+
blocked: "readonly"
|
|
33
|
+
};
|
|
34
|
+
const selected = values.includes(item.value);
|
|
35
|
+
if (selected && values.length <= min) return {
|
|
36
|
+
value: values,
|
|
37
|
+
blocked: "min"
|
|
38
|
+
};
|
|
39
|
+
if (!selected && values.length >= max) return {
|
|
40
|
+
value: values,
|
|
41
|
+
blocked: "max"
|
|
42
|
+
};
|
|
43
|
+
return {
|
|
44
|
+
value: selected ? values.filter((entry) => entry !== item.value) : [...values, item.value],
|
|
45
|
+
blocked: null
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/** Injective UTF-16 identity for native item ids, including unmatched surrogates. */
|
|
49
|
+
function selectionItemKey(value) {
|
|
50
|
+
return value.split("").map((unit) => unit.charCodeAt(0).toString(16)).join("-");
|
|
51
|
+
}
|
|
52
|
+
//#endregion
|
|
53
|
+
export { toggleSelectionValue as i, normalizeSelectionValue as n, selectionItemKey as r, normalizeSelectionItems as t };
|
|
54
|
+
|
|
55
|
+
//# sourceMappingURL=selection-ivXqO1eu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selection-ivXqO1eu.js","names":[],"sources":["../src/selection.ts"],"sourcesContent":["/** Shared identity and value rules for selection machines. */\nexport interface QwSelectionItem {\n value: string;\n label: string;\n description?: string;\n disabled?: boolean;\n}\n\nexport interface SelectionLimits { min: number; max: number }\nexport interface SelectionRestrictions { min?: number; max?: number; disabled?: boolean; readOnly?: boolean }\nexport type SelectionBlockedReason = \"disabled\" | \"readonly\" | \"min\" | \"max\";\nexport interface SelectionChange { value: string[]; blocked: SelectionBlockedReason | null }\n\nexport function normalizeSelectionItems(items: readonly QwSelectionItem[]): QwSelectionItem[] {\n const seen = new Set<string>();\n return items.map((item) => {\n if (typeof item.value !== \"string\" || item.value.length === 0) throw new TypeError(\"Selection item values must be non-empty strings\");\n if (seen.has(item.value)) throw new TypeError(\"Selection item values must be unique\");\n seen.add(item.value);\n return { ...item };\n });\n}\n\nexport function normalizeSelectionValue(value: readonly string[] = []): string[] {\n if (value.some((item) => typeof item !== \"string\" || item.length === 0)) throw new TypeError(\"Selection values must be non-empty strings\");\n return [...new Set(value)];\n}\n\nexport function resolveSelectionLimits(min?: number, max?: number): SelectionLimits {\n const lower = typeof min === \"number\" && Number.isFinite(min) ? Math.max(0, Math.floor(min)) : 0;\n const upper = typeof max === \"number\" && Number.isFinite(max) ? Math.max(lower, Math.floor(max), 0) : Infinity;\n return { min: lower, max: upper };\n}\n\n/** Caller values are preserved; limits apply only to a user addition/removal. */\nexport function toggleSelectionValue(value: readonly string[], item: QwSelectionItem, restrictions: SelectionRestrictions = {}): SelectionChange {\n const values = normalizeSelectionValue(value);\n const { min, max } = resolveSelectionLimits(restrictions.min, restrictions.max);\n if (restrictions.disabled || item.disabled) return { value: values, blocked: \"disabled\" };\n if (restrictions.readOnly) return { value: values, blocked: \"readonly\" };\n const selected = values.includes(item.value);\n if (selected && values.length <= min) return { value: values, blocked: \"min\" };\n if (!selected && values.length >= max) return { value: values, blocked: \"max\" };\n return { value: selected ? values.filter((entry) => entry !== item.value) : [...values, item.value], blocked: null };\n}\n\n/** Injective UTF-16 identity for native item ids, including unmatched surrogates. */\nexport function selectionItemKey(value: string): string {\n return value.split(\"\").map(unit => unit.charCodeAt(0).toString(16)).join(\"-\");\n}\n"],"mappings":";AAaA,SAAgB,wBAAwB,OAAsD;CAC5F,MAAM,uBAAO,IAAI,IAAY;CAC7B,OAAO,MAAM,KAAK,SAAS;EACzB,IAAI,OAAO,KAAK,UAAU,YAAY,KAAK,MAAM,WAAW,GAAG,MAAM,IAAI,UAAU,iDAAiD;EACpI,IAAI,KAAK,IAAI,KAAK,KAAK,GAAG,MAAM,IAAI,UAAU,sCAAsC;EACpF,KAAK,IAAI,KAAK,KAAK;EACnB,OAAO,EAAE,GAAG,KAAK;CACnB,CAAC;AACH;AAEA,SAAgB,wBAAwB,QAA2B,CAAC,GAAa;CAC/E,IAAI,MAAM,MAAM,SAAS,OAAO,SAAS,YAAY,KAAK,WAAW,CAAC,GAAG,MAAM,IAAI,UAAU,4CAA4C;CACzI,OAAO,CAAC,GAAG,IAAI,IAAI,KAAK,CAAC;AAC3B;AAEA,SAAgB,uBAAuB,KAAc,KAA+B;CAClF,MAAM,QAAQ,OAAO,QAAQ,YAAY,OAAO,SAAS,GAAG,IAAI,KAAK,IAAI,GAAG,KAAK,MAAM,GAAG,CAAC,IAAI;CAE/F,OAAO;EAAE,KAAK;EAAO,KADP,OAAO,QAAQ,YAAY,OAAO,SAAS,GAAG,IAAI,KAAK,IAAI,OAAO,KAAK,MAAM,GAAG,GAAG,CAAC,IAAI;CACtE;AAClC;;AAGA,SAAgB,qBAAqB,OAA0B,MAAuB,eAAsC,CAAC,GAAoB;CAC/I,MAAM,SAAS,wBAAwB,KAAK;CAC5C,MAAM,EAAE,KAAK,QAAQ,uBAAuB,aAAa,KAAK,aAAa,GAAG;CAC9E,IAAI,aAAa,YAAY,KAAK,UAAU,OAAO;EAAE,OAAO;EAAQ,SAAS;CAAW;CACxF,IAAI,aAAa,UAAU,OAAO;EAAE,OAAO;EAAQ,SAAS;CAAW;CACvE,MAAM,WAAW,OAAO,SAAS,KAAK,KAAK;CAC3C,IAAI,YAAY,OAAO,UAAU,KAAK,OAAO;EAAE,OAAO;EAAQ,SAAS;CAAM;CAC7E,IAAI,CAAC,YAAY,OAAO,UAAU,KAAK,OAAO;EAAE,OAAO;EAAQ,SAAS;CAAM;CAC9E,OAAO;EAAE,OAAO,WAAW,OAAO,QAAQ,UAAU,UAAU,KAAK,KAAK,IAAI,CAAC,GAAG,QAAQ,KAAK,KAAK;EAAG,SAAS;CAAK;AACrH;;AAGA,SAAgB,iBAAiB,OAAuB;CACtD,OAAO,MAAM,MAAM,EAAE,CAAC,CAAC,KAAI,SAAQ,KAAK,WAAW,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG;AAC9E"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** Shared identity and value rules for selection machines. */
|
|
2
|
+
export interface QwSelectionItem {
|
|
3
|
+
value: string;
|
|
4
|
+
label: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface SelectionLimits {
|
|
9
|
+
min: number;
|
|
10
|
+
max: number;
|
|
11
|
+
}
|
|
12
|
+
export interface SelectionRestrictions {
|
|
13
|
+
min?: number;
|
|
14
|
+
max?: number;
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
readOnly?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export type SelectionBlockedReason = "disabled" | "readonly" | "min" | "max";
|
|
19
|
+
export interface SelectionChange {
|
|
20
|
+
value: string[];
|
|
21
|
+
blocked: SelectionBlockedReason | null;
|
|
22
|
+
}
|
|
23
|
+
export declare function normalizeSelectionItems(items: readonly QwSelectionItem[]): QwSelectionItem[];
|
|
24
|
+
export declare function normalizeSelectionValue(value?: readonly string[]): string[];
|
|
25
|
+
export declare function resolveSelectionLimits(min?: number, max?: number): SelectionLimits;
|
|
26
|
+
/** Caller values are preserved; limits apply only to a user addition/removal. */
|
|
27
|
+
export declare function toggleSelectionValue(value: readonly string[], item: QwSelectionItem, restrictions?: SelectionRestrictions): SelectionChange;
|
|
28
|
+
/** Injective UTF-16 identity for native item ids, including unmatched surrogates. */
|
|
29
|
+
export declare function selectionItemKey(value: string): string;
|
|
@@ -0,0 +1,114 @@
|
|
|
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 IconState } from "../icon/index.js";
|
|
5
|
+
export interface ChoiceGroupItem extends QwSelectionItem {
|
|
6
|
+
/** Item-level read-only: focusable and submitted, but cannot change. */
|
|
7
|
+
readOnly?: boolean;
|
|
8
|
+
/** Supporting trailing text, read after the description. */
|
|
9
|
+
extra?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ChoiceGroupValueChangeDetails<I extends ChoiceGroupItem = ChoiceGroupItem> {
|
|
12
|
+
/** Requested ordered values (independent copy). */
|
|
13
|
+
value: string[];
|
|
14
|
+
/** Known items for the requested values, in value order (copies). */
|
|
15
|
+
items: I[];
|
|
16
|
+
}
|
|
17
|
+
export interface ChoiceGroupProps {
|
|
18
|
+
id?: string;
|
|
19
|
+
label: string;
|
|
20
|
+
hideLabel?: boolean;
|
|
21
|
+
description?: string;
|
|
22
|
+
describedBy?: string;
|
|
23
|
+
items: ChoiceGroupItem[];
|
|
24
|
+
multiple?: boolean;
|
|
25
|
+
value?: string[];
|
|
26
|
+
defaultValue?: string[];
|
|
27
|
+
required?: boolean;
|
|
28
|
+
min?: number;
|
|
29
|
+
max?: number;
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
readOnly?: boolean;
|
|
32
|
+
invalid?: boolean;
|
|
33
|
+
name?: string;
|
|
34
|
+
form?: string;
|
|
35
|
+
dir?: string;
|
|
36
|
+
loop?: boolean;
|
|
37
|
+
onValueChange?: (details: ChoiceGroupValueChangeDetails) => void;
|
|
38
|
+
}
|
|
39
|
+
export interface ChoiceGroupSchema {
|
|
40
|
+
props: ChoiceGroupProps & {
|
|
41
|
+
multiple: boolean;
|
|
42
|
+
defaultValue: string[];
|
|
43
|
+
loop: boolean;
|
|
44
|
+
} & Record<string, unknown>;
|
|
45
|
+
context: {
|
|
46
|
+
value: string[];
|
|
47
|
+
focusedValue: string | null;
|
|
48
|
+
disabledIds: string[];
|
|
49
|
+
};
|
|
50
|
+
state: "ready";
|
|
51
|
+
action: "setValue" | "toggleValue" | "selectValue" | "setFocus" | "syncInputs" | "normalizeMode";
|
|
52
|
+
effect: "trackForm";
|
|
53
|
+
event: {
|
|
54
|
+
type: "VALUE.SET";
|
|
55
|
+
value: string[];
|
|
56
|
+
} | {
|
|
57
|
+
type: "VALUE.TOGGLE" | "VALUE.SELECT" | "FOCUS";
|
|
58
|
+
value: string;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export type ChoiceGroupMachine = Machine<ChoiceGroupSchema>;
|
|
62
|
+
export type ChoiceGroupService = Service<ChoiceGroupSchema>;
|
|
63
|
+
export interface ChoiceGroupItemState {
|
|
64
|
+
selected: boolean;
|
|
65
|
+
disabled: boolean;
|
|
66
|
+
readOnly: boolean;
|
|
67
|
+
}
|
|
68
|
+
export declare function normalizeChoiceItems<I extends ChoiceGroupItem>(items: readonly I[], family: string): I[];
|
|
69
|
+
export declare function normalizeChoiceValue(value?: readonly string[], multiple?: boolean): string[];
|
|
70
|
+
export declare function createChoiceGroupProps(props: ChoiceGroupProps, family: string): ChoiceGroupSchema["props"];
|
|
71
|
+
/** One machine per family; `family` is the data-scope and id prefix. */
|
|
72
|
+
export declare function createChoiceGroupMachine(family: string): ChoiceGroupMachine;
|
|
73
|
+
export interface ChoiceGroupApi<T extends PropTypes = PropTypes> {
|
|
74
|
+
value: string[];
|
|
75
|
+
items: ChoiceGroupItem[];
|
|
76
|
+
label: string;
|
|
77
|
+
description: string;
|
|
78
|
+
setValue(value: string[]): void;
|
|
79
|
+
toggleValue(value: string): void;
|
|
80
|
+
clearValue(): void;
|
|
81
|
+
getRootProps(extra?: Record<string, unknown>): T["element"];
|
|
82
|
+
getLabelProps(): T["element"];
|
|
83
|
+
getDescriptionProps(): T["element"];
|
|
84
|
+
getGroupProps(part: string): T["element"];
|
|
85
|
+
getItemState(item: {
|
|
86
|
+
value: string;
|
|
87
|
+
}): ChoiceGroupItemState;
|
|
88
|
+
getItemProps(item: {
|
|
89
|
+
value: string;
|
|
90
|
+
}, part: string): T["label"];
|
|
91
|
+
getInputProps(item: {
|
|
92
|
+
value: string;
|
|
93
|
+
}): T["input"];
|
|
94
|
+
getItemPartProps(item: {
|
|
95
|
+
value: string;
|
|
96
|
+
}, part: string): T["element"];
|
|
97
|
+
getTextProps(item: {
|
|
98
|
+
value: string;
|
|
99
|
+
}, part: string): T["element"];
|
|
100
|
+
getItemDescriptionProps(item: {
|
|
101
|
+
value: string;
|
|
102
|
+
}, part: string): T["element"];
|
|
103
|
+
getExtraProps(item: {
|
|
104
|
+
value: string;
|
|
105
|
+
}, part: string): T["element"];
|
|
106
|
+
getCheckProps(item: {
|
|
107
|
+
value: string;
|
|
108
|
+
}, part: string): T["element"];
|
|
109
|
+
getCheckIconState(item: {
|
|
110
|
+
value: string;
|
|
111
|
+
}): IconState;
|
|
112
|
+
}
|
|
113
|
+
/** SSR-pure getters; client handlers use the Zag DOM scope only inside events. */
|
|
114
|
+
export declare function connectChoiceGroup<T extends PropTypes>(family: string, service: ChoiceGroupService, normalize: NormalizeProps<T>): ChoiceGroupApi<T>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { SELECTOR_PARTS, SELECTOR_COLUMNS, resolveSelectorColumns, normalizeSelectorOptions, normalizeSelectorValue, createSelectorProps, selectorMachine, connectSelector } from "./selector.js";
|
|
2
|
+
export type { SelectorPart, QwSelectorOption, SelectorValueChangeDetails, QwSelectorProps, QwSelectorSchema, QwSelectorMachine, QwSelectorService, QwSelectorOptionState, QwSelectorOptionProps, QwSelectorApi } from "./selector.js";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as normalizeSelectorOptions, c as selectorMachine, i as createSelectorProps, n as SELECTOR_PARTS, o as normalizeSelectorValue, r as connectSelector, s as resolveSelectorColumns, t as SELECTOR_COLUMNS } from "../selector-BU2MMJ4N.js";
|
|
2
|
+
export { SELECTOR_COLUMNS, SELECTOR_PARTS, connectSelector, createSelectorProps, normalizeSelectorOptions, normalizeSelectorValue, resolveSelectorColumns, selectorMachine };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { NormalizeProps, PropTypes } from "@zag-js/types";
|
|
2
|
+
import type { IconState } from "../icon/index.js";
|
|
3
|
+
import { type ChoiceGroupItemState, type ChoiceGroupMachine, type ChoiceGroupSchema, type ChoiceGroupService, type ChoiceGroupValueChangeDetails } from "./choice-group.js";
|
|
4
|
+
/** Stable DOM parts shared by every adapter. */
|
|
5
|
+
export declare const SELECTOR_PARTS: readonly ["root", "label", "description", "options", "option", "input", "content", "text", "option-description", "check"];
|
|
6
|
+
/** Supported fixed column counts; anything else uses the auto-wrapping flow. */
|
|
7
|
+
export declare const SELECTOR_COLUMNS: readonly [1, 2, 3, 4, 5, 6];
|
|
8
|
+
export type SelectorPart = (typeof SELECTOR_PARTS)[number];
|
|
9
|
+
/** One tile. `label` is the accessible option name. */
|
|
10
|
+
export interface QwSelectorOption {
|
|
11
|
+
value: string;
|
|
12
|
+
label: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
disabled?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export type SelectorValueChangeDetails = ChoiceGroupValueChangeDetails<QwSelectorOption>;
|
|
17
|
+
export interface QwSelectorProps {
|
|
18
|
+
id?: string;
|
|
19
|
+
/** Required nonempty group name rendered as the fieldset legend. */
|
|
20
|
+
label: string;
|
|
21
|
+
/** Visually hide the legend while it still names the group. */
|
|
22
|
+
hideLabel?: boolean;
|
|
23
|
+
description?: string;
|
|
24
|
+
/** External Field help/error references merged with the own description. */
|
|
25
|
+
describedBy?: string;
|
|
26
|
+
/** Ordered tiles with unique nonempty values and labels. */
|
|
27
|
+
options: QwSelectorOption[];
|
|
28
|
+
/** Multiple checkboxes instead of single radios. Defaults false. */
|
|
29
|
+
multiple?: boolean;
|
|
30
|
+
/** Defined arrays (including []) are controlled; user actions only request changes. */
|
|
31
|
+
value?: string[];
|
|
32
|
+
/** Initial value and form reset target. Defaults []. */
|
|
33
|
+
defaultValue?: string[];
|
|
34
|
+
/** Native validation; in single mode it also blocks clearing the selected tile. */
|
|
35
|
+
required?: boolean;
|
|
36
|
+
/** Multiple-mode limits for user removal/addition. */
|
|
37
|
+
min?: number;
|
|
38
|
+
max?: number;
|
|
39
|
+
disabled?: boolean;
|
|
40
|
+
readOnly?: boolean;
|
|
41
|
+
invalid?: boolean;
|
|
42
|
+
name?: string;
|
|
43
|
+
form?: string;
|
|
44
|
+
dir?: string;
|
|
45
|
+
/** Arrow-key wrapping; defaults true. */
|
|
46
|
+
loop?: boolean;
|
|
47
|
+
/** Equal column count 1–6; otherwise tiles wrap by content. */
|
|
48
|
+
columns?: number;
|
|
49
|
+
/** Corner check mark on selected tiles (non-color cue). Defaults true. */
|
|
50
|
+
showCheckMark?: boolean;
|
|
51
|
+
onValueChange?: (details: SelectorValueChangeDetails) => void;
|
|
52
|
+
}
|
|
53
|
+
export type QwSelectorSchema = ChoiceGroupSchema;
|
|
54
|
+
export type QwSelectorMachine = ChoiceGroupMachine;
|
|
55
|
+
export type QwSelectorService = ChoiceGroupService;
|
|
56
|
+
export type QwSelectorOptionState = ChoiceGroupItemState;
|
|
57
|
+
export interface QwSelectorOptionProps {
|
|
58
|
+
value: string;
|
|
59
|
+
}
|
|
60
|
+
/** Resolve columns to a supported integer or undefined (auto flow). */
|
|
61
|
+
export declare function resolveSelectorColumns(columns: unknown): number | undefined;
|
|
62
|
+
export declare function normalizeSelectorOptions(options: readonly QwSelectorOption[]): QwSelectorOption[];
|
|
63
|
+
export declare function normalizeSelectorValue(value?: readonly string[], multiple?: boolean): string[];
|
|
64
|
+
/** Map public props to the shared choice-group machine props. */
|
|
65
|
+
export declare function createSelectorProps(props: QwSelectorProps): QwSelectorSchema["props"];
|
|
66
|
+
export declare const selectorMachine: QwSelectorMachine;
|
|
67
|
+
export interface QwSelectorApi<T extends PropTypes = PropTypes> {
|
|
68
|
+
value: string[];
|
|
69
|
+
options: QwSelectorOption[];
|
|
70
|
+
label: string;
|
|
71
|
+
description: string;
|
|
72
|
+
showCheckMark: boolean;
|
|
73
|
+
setValue(value: string[]): void;
|
|
74
|
+
toggleValue(value: string): void;
|
|
75
|
+
clearValue(): void;
|
|
76
|
+
getRootProps(): T["element"];
|
|
77
|
+
getLabelProps(): T["element"];
|
|
78
|
+
getDescriptionProps(): T["element"];
|
|
79
|
+
getOptionsProps(): T["element"];
|
|
80
|
+
getOptionState(option: QwSelectorOptionProps): QwSelectorOptionState;
|
|
81
|
+
getOptionProps(option: QwSelectorOptionProps): T["label"];
|
|
82
|
+
getInputProps(option: QwSelectorOptionProps): T["input"];
|
|
83
|
+
getContentProps(option: QwSelectorOptionProps): T["element"];
|
|
84
|
+
getTextProps(option: QwSelectorOptionProps): T["element"];
|
|
85
|
+
getOptionDescriptionProps(option: QwSelectorOptionProps): T["element"];
|
|
86
|
+
getCheckProps(option: QwSelectorOptionProps): T["element"];
|
|
87
|
+
getCheckIconState(option: QwSelectorOptionProps): IconState;
|
|
88
|
+
}
|
|
89
|
+
/** Mechanical part mapping over the shared kernel. */
|
|
90
|
+
export declare function connectSelector<T extends PropTypes>(service: QwSelectorService, normalize: NormalizeProps<T>): QwSelectorApi<T>;
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { a as normalizeChoiceValue, i as normalizeChoiceItems, n as createChoiceGroupMachine, r as createChoiceGroupProps, t as connectChoiceGroup } from "./choice-group-C4c9m0qe.js";
|
|
2
|
+
//#region src/selector/selector.ts
|
|
3
|
+
/** Stable DOM parts shared by every adapter. */
|
|
4
|
+
const SELECTOR_PARTS = [
|
|
5
|
+
"root",
|
|
6
|
+
"label",
|
|
7
|
+
"description",
|
|
8
|
+
"options",
|
|
9
|
+
"option",
|
|
10
|
+
"input",
|
|
11
|
+
"content",
|
|
12
|
+
"text",
|
|
13
|
+
"option-description",
|
|
14
|
+
"check"
|
|
15
|
+
];
|
|
16
|
+
/** Supported fixed column counts; anything else uses the auto-wrapping flow. */
|
|
17
|
+
const SELECTOR_COLUMNS = [
|
|
18
|
+
1,
|
|
19
|
+
2,
|
|
20
|
+
3,
|
|
21
|
+
4,
|
|
22
|
+
5,
|
|
23
|
+
6
|
|
24
|
+
];
|
|
25
|
+
/** Resolve columns to a supported integer or undefined (auto flow). */
|
|
26
|
+
function resolveSelectorColumns(columns) {
|
|
27
|
+
return typeof columns === "number" && SELECTOR_COLUMNS.includes(columns) ? columns : void 0;
|
|
28
|
+
}
|
|
29
|
+
function normalizeSelectorOptions(options) {
|
|
30
|
+
return normalizeChoiceItems(options, "Selector");
|
|
31
|
+
}
|
|
32
|
+
function normalizeSelectorValue(value = [], multiple = false) {
|
|
33
|
+
return normalizeChoiceValue(value, multiple);
|
|
34
|
+
}
|
|
35
|
+
/** Map public props to the shared choice-group machine props. */
|
|
36
|
+
function createSelectorProps(props) {
|
|
37
|
+
const { options, onValueChange, ...rest } = props;
|
|
38
|
+
return {
|
|
39
|
+
...createChoiceGroupProps({
|
|
40
|
+
...rest,
|
|
41
|
+
items: options ?? [],
|
|
42
|
+
onValueChange
|
|
43
|
+
}, "Selector"),
|
|
44
|
+
columns: resolveSelectorColumns(props.columns),
|
|
45
|
+
showCheckMark: props.showCheckMark ?? true
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
const selectorMachine = createChoiceGroupMachine("selector");
|
|
49
|
+
/** Mechanical part mapping over the shared kernel. */
|
|
50
|
+
function connectSelector(service, normalize) {
|
|
51
|
+
const api = connectChoiceGroup("selector", service, normalize);
|
|
52
|
+
const columns = resolveSelectorColumns(service.prop("columns")), showCheckMark = service.prop("showCheckMark") !== false;
|
|
53
|
+
return {
|
|
54
|
+
value: api.value,
|
|
55
|
+
options: api.items.map(({ value, label, description, disabled }) => ({
|
|
56
|
+
value,
|
|
57
|
+
label,
|
|
58
|
+
description,
|
|
59
|
+
disabled
|
|
60
|
+
})),
|
|
61
|
+
label: api.label,
|
|
62
|
+
description: api.description,
|
|
63
|
+
showCheckMark,
|
|
64
|
+
setValue: api.setValue,
|
|
65
|
+
toggleValue: api.toggleValue,
|
|
66
|
+
clearValue: api.clearValue,
|
|
67
|
+
getRootProps: () => api.getRootProps({
|
|
68
|
+
"data-columns": columns,
|
|
69
|
+
"data-check-mark": showCheckMark ? "" : void 0
|
|
70
|
+
}),
|
|
71
|
+
getLabelProps: api.getLabelProps,
|
|
72
|
+
getDescriptionProps: api.getDescriptionProps,
|
|
73
|
+
getOptionsProps: () => api.getGroupProps("options"),
|
|
74
|
+
getOptionState: api.getItemState,
|
|
75
|
+
getOptionProps: (option) => api.getItemProps(option, "option"),
|
|
76
|
+
getInputProps: api.getInputProps,
|
|
77
|
+
getContentProps: (option) => api.getItemPartProps(option, "content"),
|
|
78
|
+
getTextProps: (option) => api.getTextProps(option, "text"),
|
|
79
|
+
getOptionDescriptionProps: (option) => api.getItemDescriptionProps(option, "option-description"),
|
|
80
|
+
getCheckProps: (option) => {
|
|
81
|
+
const props = api.getCheckProps(option, "check");
|
|
82
|
+
return showCheckMark ? props : {
|
|
83
|
+
...props,
|
|
84
|
+
hidden: true
|
|
85
|
+
};
|
|
86
|
+
},
|
|
87
|
+
getCheckIconState: api.getCheckIconState
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
//#endregion
|
|
91
|
+
export { normalizeSelectorOptions as a, selectorMachine as c, createSelectorProps as i, SELECTOR_PARTS as n, normalizeSelectorValue as o, connectSelector as r, resolveSelectorColumns as s, SELECTOR_COLUMNS as t };
|
|
92
|
+
|
|
93
|
+
//# sourceMappingURL=selector-BU2MMJ4N.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selector-BU2MMJ4N.js","names":[],"sources":["../src/selector/selector.ts"],"sourcesContent":["import type { NormalizeProps, PropTypes } from \"@zag-js/types\";\nimport type { IconState } from \"../icon/index.js\";\nimport { connectChoiceGroup, createChoiceGroupMachine, createChoiceGroupProps, normalizeChoiceItems, normalizeChoiceValue, type ChoiceGroupItemState, type ChoiceGroupMachine, type ChoiceGroupSchema, type ChoiceGroupService, type ChoiceGroupValueChangeDetails } from \"./choice-group.js\";\n\n/** Stable DOM parts shared by every adapter. */\nexport const SELECTOR_PARTS = [\"root\", \"label\", \"description\", \"options\", \"option\", \"input\", \"content\", \"text\", \"option-description\", \"check\"] as const;\n/** Supported fixed column counts; anything else uses the auto-wrapping flow. */\nexport const SELECTOR_COLUMNS = [1, 2, 3, 4, 5, 6] as const;\nexport type SelectorPart = (typeof SELECTOR_PARTS)[number];\n/** One tile. `label` is the accessible option name. */\nexport interface QwSelectorOption { value: string; label: string; description?: string; disabled?: boolean }\nexport type SelectorValueChangeDetails = ChoiceGroupValueChangeDetails<QwSelectorOption>;\nexport interface QwSelectorProps {\n id?: string;\n /** Required nonempty group name rendered as the fieldset legend. */\n label: string;\n /** Visually hide the legend while it still names the group. */\n hideLabel?: boolean;\n description?: string;\n /** External Field help/error references merged with the own description. */\n describedBy?: string;\n /** Ordered tiles with unique nonempty values and labels. */\n options: QwSelectorOption[];\n /** Multiple checkboxes instead of single radios. Defaults false. */\n multiple?: boolean;\n /** Defined arrays (including []) are controlled; user actions only request changes. */\n value?: string[];\n /** Initial value and form reset target. Defaults []. */\n defaultValue?: string[];\n /** Native validation; in single mode it also blocks clearing the selected tile. */\n required?: boolean;\n /** Multiple-mode limits for user removal/addition. */\n min?: number;\n max?: number;\n disabled?: boolean;\n readOnly?: boolean;\n invalid?: boolean;\n name?: string;\n form?: string;\n dir?: string;\n /** Arrow-key wrapping; defaults true. */\n loop?: boolean;\n /** Equal column count 1–6; otherwise tiles wrap by content. */\n columns?: number;\n /** Corner check mark on selected tiles (non-color cue). Defaults true. */\n showCheckMark?: boolean;\n onValueChange?: (details: SelectorValueChangeDetails) => void;\n}\nexport type QwSelectorSchema = ChoiceGroupSchema;\nexport type QwSelectorMachine = ChoiceGroupMachine;\nexport type QwSelectorService = ChoiceGroupService;\nexport type QwSelectorOptionState = ChoiceGroupItemState;\nexport interface QwSelectorOptionProps { value: string }\n\n/** Resolve columns to a supported integer or undefined (auto flow). */\nexport function resolveSelectorColumns(columns: unknown): number | undefined {\n return typeof columns === \"number\" && (SELECTOR_COLUMNS as readonly number[]).includes(columns) ? columns : undefined;\n}\nexport function normalizeSelectorOptions(options: readonly QwSelectorOption[]): QwSelectorOption[] { return normalizeChoiceItems(options, \"Selector\"); }\nexport function normalizeSelectorValue(value: readonly string[] = [], multiple = false): string[] { return normalizeChoiceValue(value, multiple); }\n/** Map public props to the shared choice-group machine props. */\nexport function createSelectorProps(props: QwSelectorProps): QwSelectorSchema[\"props\"] {\n const { options, onValueChange, ...rest } = props;\n return { ...createChoiceGroupProps({ ...rest, items: options ?? [], onValueChange: onValueChange as QwSelectorSchema[\"props\"][\"onValueChange\"] }, \"Selector\"),\n columns: resolveSelectorColumns(props.columns), showCheckMark: props.showCheckMark ?? true };\n}\nexport const selectorMachine: QwSelectorMachine = createChoiceGroupMachine(\"selector\");\n\nexport interface QwSelectorApi<T extends PropTypes = PropTypes> {\n value: string[];\n options: QwSelectorOption[];\n label: string;\n description: string;\n showCheckMark: boolean;\n setValue(value: string[]): void;\n toggleValue(value: string): void;\n clearValue(): void;\n getRootProps(): T[\"element\"];\n getLabelProps(): T[\"element\"];\n getDescriptionProps(): T[\"element\"];\n getOptionsProps(): T[\"element\"];\n getOptionState(option: QwSelectorOptionProps): QwSelectorOptionState;\n getOptionProps(option: QwSelectorOptionProps): T[\"label\"];\n getInputProps(option: QwSelectorOptionProps): T[\"input\"];\n getContentProps(option: QwSelectorOptionProps): T[\"element\"];\n getTextProps(option: QwSelectorOptionProps): T[\"element\"];\n getOptionDescriptionProps(option: QwSelectorOptionProps): T[\"element\"];\n getCheckProps(option: QwSelectorOptionProps): T[\"element\"];\n getCheckIconState(option: QwSelectorOptionProps): IconState;\n}\n/** Mechanical part mapping over the shared kernel. */\nexport function connectSelector<T extends PropTypes>(service: QwSelectorService, normalize: NormalizeProps<T>): QwSelectorApi<T> {\n const api = connectChoiceGroup(\"selector\", service, normalize);\n const columns = resolveSelectorColumns(service.prop(\"columns\")), showCheckMark = service.prop(\"showCheckMark\") !== false;\n return {\n value: api.value, options: api.items.map(({ value, label, description, disabled }) => ({ value, label, description, disabled })), label: api.label, description: api.description, showCheckMark,\n setValue: api.setValue, toggleValue: api.toggleValue, clearValue: api.clearValue,\n getRootProps: () => api.getRootProps({ \"data-columns\": columns, \"data-check-mark\": showCheckMark ? \"\" : undefined }),\n getLabelProps: api.getLabelProps, getDescriptionProps: api.getDescriptionProps,\n getOptionsProps: () => api.getGroupProps(\"options\"),\n getOptionState: api.getItemState,\n getOptionProps: (option) => api.getItemProps(option, \"option\"),\n getInputProps: api.getInputProps,\n getContentProps: (option) => api.getItemPartProps(option, \"content\"),\n getTextProps: (option) => api.getTextProps(option, \"text\"),\n getOptionDescriptionProps: (option) => api.getItemDescriptionProps(option, \"option-description\"),\n getCheckProps: (option) => { const props = api.getCheckProps(option, \"check\") as Record<string, unknown>; return (showCheckMark ? props : { ...props, hidden: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