@qw-ui/core 0.3.0-next.4 → 0.3.0-next.42
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 +85 -0
- package/dist/badge/index.d.ts +1 -0
- package/dist/badge/index.js +88 -0
- package/dist/badge/index.js.map +1 -0
- 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 +61 -43
- package/dist/dialog/index.js +73 -19
- 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 +115 -10
- package/dist/index.js +151 -11
- 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/overlay-panel/index.d.ts +2 -0
- package/dist/overlay-panel/index.js +2 -0
- package/dist/overlay-panel/overlay-panel.d.ts +20 -0
- package/dist/overlay-panel-Z_qdKeBj.js +26 -0
- package/dist/overlay-panel-Z_qdKeBj.js.map +1 -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 +4 -2
- package/dist/search-bar/index.js.map +1 -1
- package/dist/search-bar/search-bar.d.ts +6 -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/side-nav/index.d.ts +1 -0
- package/dist/side-nav/index.js +99 -0
- package/dist/side-nav/index.js.map +1 -0
- package/dist/side-nav/side-nav.d.ts +94 -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.d.ts +1 -0
- package/dist/stepper/index.js +172 -0
- package/dist/stepper/index.js.map +1 -0
- package/dist/stepper/stepper.d.ts +161 -0
- 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.d.ts +1 -0
- package/dist/switch/index.js +168 -0
- package/dist/switch/index.js.map +1 -0
- package/dist/switch/switch.d.ts +142 -0
- package/dist/tabbar/index.d.ts +1 -0
- package/dist/tabbar/index.js +95 -0
- package/dist/tabbar/index.js.map +1 -0
- package/dist/tabbar/tabbar.d.ts +119 -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 +169 -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 +27 -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 +417 -44
- 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,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: true }) as T[\"element\"]; },\n getCheckIconState: api.getCheckIconState,\n };\n}\n"],"mappings":";;;AAKA,MAAa,iBAAiB;CAAC;CAAQ;CAAS;CAAe;CAAW;CAAU;CAAS;CAAW;CAAQ;CAAsB;AAAO;;AAE7I,MAAa,mBAAmB;CAAC;CAAG;CAAG;CAAG;CAAG;CAAG;AAAC;;AAgDjD,SAAgB,uBAAuB,SAAsC;CAC3E,OAAO,OAAO,YAAY,YAAa,iBAAuC,SAAS,OAAO,IAAI,UAAU,KAAA;AAC9G;AACA,SAAgB,yBAAyB,SAA0D;CAAE,OAAO,qBAAqB,SAAS,UAAU;AAAG;AACvJ,SAAgB,uBAAuB,QAA2B,CAAC,GAAG,WAAW,OAAiB;CAAE,OAAO,qBAAqB,OAAO,QAAQ;AAAG;;AAElJ,SAAgB,oBAAoB,OAAmD;CACrF,MAAM,EAAE,SAAS,eAAe,GAAG,SAAS;CAC5C,OAAO;EAAE,GAAG,uBAAuB;GAAE,GAAG;GAAM,OAAO,WAAW,CAAC;GAAkB;EAA4D,GAAG,UAAU;EAC1J,SAAS,uBAAuB,MAAM,OAAO;EAAG,eAAe,MAAM,iBAAiB;CAAK;AAC/F;AACA,MAAa,kBAAqC,yBAAyB,UAAU;;AAyBrF,SAAgB,gBAAqC,SAA4B,WAAgD;CAC/H,MAAM,MAAM,mBAAmB,YAAY,SAAS,SAAS;CAC7D,MAAM,UAAU,uBAAuB,QAAQ,KAAK,SAAS,CAAC,GAAG,gBAAgB,QAAQ,KAAK,eAAe,MAAM;CACnH,OAAO;EACL,OAAO,IAAI;EAAO,SAAS,IAAI,MAAM,KAAK,EAAE,OAAO,OAAO,aAAa,gBAAgB;GAAE;GAAO;GAAO;GAAa;EAAS,EAAE;EAAG,OAAO,IAAI;EAAO,aAAa,IAAI;EAAa;EAClL,UAAU,IAAI;EAAU,aAAa,IAAI;EAAa,YAAY,IAAI;EACtE,oBAAoB,IAAI,aAAa;GAAE,gBAAgB;GAAS,mBAAmB,gBAAgB,KAAK,KAAA;EAAU,CAAC;EACnH,eAAe,IAAI;EAAe,qBAAqB,IAAI;EAC3D,uBAAuB,IAAI,cAAc,SAAS;EAClD,gBAAgB,IAAI;EACpB,iBAAiB,WAAW,IAAI,aAAa,QAAQ,QAAQ;EAC7D,eAAe,IAAI;EACnB,kBAAkB,WAAW,IAAI,iBAAiB,QAAQ,SAAS;EACnE,eAAe,WAAW,IAAI,aAAa,QAAQ,MAAM;EACzD,4BAA4B,WAAW,IAAI,wBAAwB,QAAQ,oBAAoB;EAC/F,gBAAgB,WAAW;GAAE,MAAM,QAAQ,IAAI,cAAc,QAAQ,OAAO;GAA8B,OAAQ,gBAAgB,QAAQ;IAAE,GAAG;IAAO,QAAQ;GAAK;EAAoB;EACvL,mBAAmB,IAAI;CACzB;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./share-sheet.js";
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { o as resolveIconState } from "../icon-Cgdbnk1u.js";
|
|
2
|
+
import { createMachine } from "@zag-js/core";
|
|
3
|
+
//#region src/share-sheet/share-sheet.ts
|
|
4
|
+
function createShareSheetProps(props = {}) {
|
|
5
|
+
return {
|
|
6
|
+
...props,
|
|
7
|
+
groups: props.groups ?? [],
|
|
8
|
+
ariaLabel: props.ariaLabel?.trim() || "分享面板"
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function resolveShareSheetGroups(groups = []) {
|
|
12
|
+
const seen = /* @__PURE__ */ new Set();
|
|
13
|
+
return groups.map((group, groupIndex) => ({
|
|
14
|
+
label: group.label,
|
|
15
|
+
groupIndex,
|
|
16
|
+
actions: group.actions.map((source, index) => {
|
|
17
|
+
const duplicate = seen.has(source.value);
|
|
18
|
+
seen.add(source.value);
|
|
19
|
+
return {
|
|
20
|
+
...source,
|
|
21
|
+
source,
|
|
22
|
+
index,
|
|
23
|
+
groupIndex,
|
|
24
|
+
disabled: !!source.disabled || duplicate || !source.value.trim() || !source.label.trim(),
|
|
25
|
+
duplicate
|
|
26
|
+
};
|
|
27
|
+
})
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
const shareSheetMachine = createMachine({
|
|
31
|
+
props: ({ props }) => createShareSheetProps(props),
|
|
32
|
+
initialState: () => "ready",
|
|
33
|
+
states: { ready: {} },
|
|
34
|
+
context: ({ bindable, prop }) => ({ open: bindable(() => ({
|
|
35
|
+
defaultValue: prop("defaultOpen") ?? false,
|
|
36
|
+
value: prop("open"),
|
|
37
|
+
onChange: (open) => prop("onOpenChange")?.(open)
|
|
38
|
+
})) }),
|
|
39
|
+
on: {
|
|
40
|
+
OPEN: { actions: ["open"] },
|
|
41
|
+
ACTIVATE: { actions: ["activate"] },
|
|
42
|
+
CANCEL: { actions: ["cancel"] }
|
|
43
|
+
},
|
|
44
|
+
implementations: { actions: {
|
|
45
|
+
open({ context, event }) {
|
|
46
|
+
if (event.type === "OPEN") context.set("open", event.open);
|
|
47
|
+
},
|
|
48
|
+
activate({ prop, context, event }) {
|
|
49
|
+
if (event.type !== "ACTIVATE" || !context.get("open")) return;
|
|
50
|
+
const latest = resolveShareSheetGroups(prop("groups"))[event.groupIndex]?.actions[event.index];
|
|
51
|
+
if (!latest || latest.source !== event.source || latest.disabled) return;
|
|
52
|
+
prop("onAction")?.({
|
|
53
|
+
value: latest.value,
|
|
54
|
+
groupIndex: event.groupIndex,
|
|
55
|
+
index: event.index
|
|
56
|
+
});
|
|
57
|
+
if (prop("closeOnAction") !== false) context.set("open", false);
|
|
58
|
+
},
|
|
59
|
+
cancel({ prop, context }) {
|
|
60
|
+
if (!context.get("open")) return;
|
|
61
|
+
prop("onCancel")?.();
|
|
62
|
+
context.set("open", false);
|
|
63
|
+
}
|
|
64
|
+
} }
|
|
65
|
+
});
|
|
66
|
+
function connectShareSheet(service, normalize) {
|
|
67
|
+
const groups = resolveShareSheetGroups(service.prop("groups")), open = service.context.get("open");
|
|
68
|
+
const part = (name) => ({
|
|
69
|
+
"data-scope": "share-sheet",
|
|
70
|
+
"data-part": name
|
|
71
|
+
});
|
|
72
|
+
return {
|
|
73
|
+
open,
|
|
74
|
+
groups,
|
|
75
|
+
popupProps: {
|
|
76
|
+
id: `${service.scope.id}-popup`,
|
|
77
|
+
open,
|
|
78
|
+
title: service.prop("title"),
|
|
79
|
+
ariaLabel: service.prop("ariaLabel"),
|
|
80
|
+
closeLabel: service.prop("closeLabel"),
|
|
81
|
+
placement: "bottom",
|
|
82
|
+
closeOnMaskClick: service.prop("closeOnMaskClick"),
|
|
83
|
+
disableBodyScroll: service.prop("disableBodyScroll"),
|
|
84
|
+
safeArea: service.prop("safeArea"),
|
|
85
|
+
returnFocus: service.prop("returnFocus"),
|
|
86
|
+
onOpenChange: (value) => service.send({
|
|
87
|
+
type: "OPEN",
|
|
88
|
+
open: value
|
|
89
|
+
})
|
|
90
|
+
},
|
|
91
|
+
cancelText: service.prop("cancelText")?.trim() || "取消",
|
|
92
|
+
setOpen: (value) => service.send({
|
|
93
|
+
type: "OPEN",
|
|
94
|
+
open: value
|
|
95
|
+
}),
|
|
96
|
+
getRootProps: () => normalize.element({
|
|
97
|
+
...part("root"),
|
|
98
|
+
lang: service.prop("lang"),
|
|
99
|
+
dir: service.prop("dir"),
|
|
100
|
+
"data-visual-target": "share-sheet-root"
|
|
101
|
+
}),
|
|
102
|
+
getGroupProps: (group) => normalize.element({
|
|
103
|
+
...part("group"),
|
|
104
|
+
role: "group",
|
|
105
|
+
"aria-label": group.label
|
|
106
|
+
}),
|
|
107
|
+
getActionProps: (action) => normalize.button({
|
|
108
|
+
...part("action"),
|
|
109
|
+
type: "button",
|
|
110
|
+
disabled: action.disabled,
|
|
111
|
+
"aria-label": action.label,
|
|
112
|
+
"data-value": action.value,
|
|
113
|
+
"data-visual-target": "share-sheet-action",
|
|
114
|
+
onClick: () => service.send({
|
|
115
|
+
type: "ACTIVATE",
|
|
116
|
+
source: action.source,
|
|
117
|
+
groupIndex: action.groupIndex,
|
|
118
|
+
index: action.index
|
|
119
|
+
})
|
|
120
|
+
}),
|
|
121
|
+
getIconState: (action) => resolveIconState({
|
|
122
|
+
id: `${service.scope.id}:share:${action.groupIndex}:${action.index}`,
|
|
123
|
+
name: action.icon
|
|
124
|
+
}),
|
|
125
|
+
getLabelProps: () => normalize.element(part("label")),
|
|
126
|
+
getDescriptionProps: () => normalize.element(part("description")),
|
|
127
|
+
getCancelProps: () => normalize.button({
|
|
128
|
+
...part("cancel"),
|
|
129
|
+
type: "button",
|
|
130
|
+
"data-visual-target": "share-sheet-cancel",
|
|
131
|
+
onClick: () => service.send({ type: "CANCEL" })
|
|
132
|
+
})
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
//#endregion
|
|
136
|
+
export { connectShareSheet, createShareSheetProps, resolveShareSheetGroups, shareSheetMachine };
|
|
137
|
+
|
|
138
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/share-sheet/share-sheet.ts"],"sourcesContent":["import { createMachine, type Machine, type Service } from \"@zag-js/core\";\nimport type { NormalizeProps, PropTypes } from \"@zag-js/types\";\nimport type { QwPopupProps } from \"../popup/popup.js\";\nimport { resolveIconState, type IconNameInput } from \"../icon/icon.js\";\n\nexport interface ShareSheetAction { value: string; label: string; icon: IconNameInput; description?: string; disabled?: boolean }\nexport interface ShareSheetGroup { label: string; actions: readonly ShareSheetAction[] }\nexport interface ShareSheetActionDetails { value: string; groupIndex: number; index: number }\nexport interface QwShareSheetProps extends Omit<QwPopupProps, \"placement\"> {\n /** Locale on the immediate Popup host; arbitrary outer ancestors are not copied into its portal. */\n lang?: string;\n dir?: string;\n groups?: readonly ShareSheetGroup[];\n /** Enabled actions request closing by default; no system share or network side effect. */\n closeOnAction?: boolean;\n cancelText?: string;\n onAction?: (details: ShareSheetActionDetails) => void;\n onCancel?: () => void;\n}\nexport interface QwShareSheetSchema {\n props: QwShareSheetProps;\n context: { open: boolean };\n state: \"ready\";\n action: \"open\" | \"activate\" | \"cancel\";\n event: { type: \"OPEN\"; open: boolean } | { type: \"ACTIVATE\"; source: ShareSheetAction; groupIndex: number; index: number } | { type: \"CANCEL\" };\n}\nexport type QwShareSheetService = Service<QwShareSheetSchema>;\nexport function createShareSheetProps(props: QwShareSheetProps = {}): QwShareSheetProps { return { ...props, groups: props.groups ?? [], ariaLabel: props.ariaLabel?.trim() || \"分享面板\" }; }\nexport function resolveShareSheetGroups(groups: readonly ShareSheetGroup[] = []) {\n const seen = new Set<string>();\n return groups.map((group, groupIndex) => ({ label: group.label, groupIndex, actions: group.actions.map((source, index) => {\n const duplicate = seen.has(source.value); seen.add(source.value);\n return { ...source, source, index, groupIndex, disabled: !!source.disabled || duplicate || !source.value.trim() || !source.label.trim(), duplicate };\n }) }));\n}\nexport const shareSheetMachine: Machine<QwShareSheetSchema> = createMachine<QwShareSheetSchema>({\n props: ({ props }) => createShareSheetProps(props), initialState: () => \"ready\", states: { ready: {} },\n context: ({ bindable, prop }) => ({ open: bindable(() => ({ defaultValue: prop(\"defaultOpen\") ?? false, value: prop(\"open\"), onChange: (open) => prop(\"onOpenChange\")?.(open) })) }),\n on: { OPEN: { actions: [\"open\"] }, ACTIVATE: { actions: [\"activate\"] }, CANCEL: { actions: [\"cancel\"] } },\n implementations: { actions: {\n open({ context, event }) { if (event.type === \"OPEN\") context.set(\"open\", event.open); },\n activate({ prop, context, event }) {\n if (event.type !== \"ACTIVATE\" || !context.get(\"open\")) return;\n const latest = resolveShareSheetGroups(prop(\"groups\"))[event.groupIndex]?.actions[event.index];\n if (!latest || latest.source !== event.source || latest.disabled) return;\n prop(\"onAction\")?.({ value: latest.value, groupIndex: event.groupIndex, index: event.index });\n if (prop(\"closeOnAction\") !== false) context.set(\"open\", false);\n },\n cancel({ prop, context }) { if (!context.get(\"open\")) return; prop(\"onCancel\")?.(); context.set(\"open\", false); },\n } },\n});\nexport function connectShareSheet<T extends PropTypes>(service: QwShareSheetService, normalize: NormalizeProps<T>) {\n const groups = resolveShareSheetGroups(service.prop(\"groups\")), open = service.context.get(\"open\");\n const part = (name: string) => ({ \"data-scope\": \"share-sheet\", \"data-part\": name });\n const popupProps: QwPopupProps = { id: `${service.scope.id}-popup`, open, title: service.prop(\"title\"), ariaLabel: service.prop(\"ariaLabel\"), closeLabel: service.prop(\"closeLabel\"), placement: \"bottom\", closeOnMaskClick: service.prop(\"closeOnMaskClick\"), disableBodyScroll: service.prop(\"disableBodyScroll\"), safeArea: service.prop(\"safeArea\"), returnFocus: service.prop(\"returnFocus\"), onOpenChange: (value) => service.send({ type: \"OPEN\", open: value }) };\n return { open, groups, popupProps, cancelText: service.prop(\"cancelText\")?.trim() || \"取消\",\n setOpen: (value: boolean) => service.send({ type: \"OPEN\", open: value }),\n getRootProps: () => normalize.element({ ...part(\"root\"), lang: service.prop(\"lang\"), dir: service.prop(\"dir\"), \"data-visual-target\": \"share-sheet-root\" }),\n getGroupProps: (group: (typeof groups)[number]) => normalize.element({ ...part(\"group\"), role: \"group\", \"aria-label\": group.label }),\n getActionProps: (action: (typeof groups)[number][\"actions\"][number]) => normalize.button({ ...part(\"action\"), type: \"button\", disabled: action.disabled, \"aria-label\": action.label, \"data-value\": action.value, \"data-visual-target\": \"share-sheet-action\", onClick: () => service.send({ type: \"ACTIVATE\", source: action.source, groupIndex: action.groupIndex, index: action.index }) }),\n getIconState: (action: (typeof groups)[number][\"actions\"][number]) => resolveIconState({ id: `${service.scope.id}:share:${action.groupIndex}:${action.index}`, name: action.icon }),\n getLabelProps: () => normalize.element(part(\"label\")), getDescriptionProps: () => normalize.element(part(\"description\")),\n getCancelProps: () => normalize.button({ ...part(\"cancel\"), type: \"button\", \"data-visual-target\": \"share-sheet-cancel\", onClick: () => service.send({ type: \"CANCEL\" }) }),\n };\n}\nexport type QwShareSheetApi<T extends PropTypes = PropTypes> = ReturnType<typeof connectShareSheet<T>>;\n"],"mappings":"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"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { type Machine, type Service } from "@zag-js/core";
|
|
2
|
+
import type { NormalizeProps, PropTypes } from "@zag-js/types";
|
|
3
|
+
import type { QwPopupProps } from "../popup/popup.js";
|
|
4
|
+
import { type IconNameInput } from "../icon/icon.js";
|
|
5
|
+
export interface ShareSheetAction {
|
|
6
|
+
value: string;
|
|
7
|
+
label: string;
|
|
8
|
+
icon: IconNameInput;
|
|
9
|
+
description?: string;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface ShareSheetGroup {
|
|
13
|
+
label: string;
|
|
14
|
+
actions: readonly ShareSheetAction[];
|
|
15
|
+
}
|
|
16
|
+
export interface ShareSheetActionDetails {
|
|
17
|
+
value: string;
|
|
18
|
+
groupIndex: number;
|
|
19
|
+
index: number;
|
|
20
|
+
}
|
|
21
|
+
export interface QwShareSheetProps extends Omit<QwPopupProps, "placement"> {
|
|
22
|
+
/** Locale on the immediate Popup host; arbitrary outer ancestors are not copied into its portal. */
|
|
23
|
+
lang?: string;
|
|
24
|
+
dir?: string;
|
|
25
|
+
groups?: readonly ShareSheetGroup[];
|
|
26
|
+
/** Enabled actions request closing by default; no system share or network side effect. */
|
|
27
|
+
closeOnAction?: boolean;
|
|
28
|
+
cancelText?: string;
|
|
29
|
+
onAction?: (details: ShareSheetActionDetails) => void;
|
|
30
|
+
onCancel?: () => void;
|
|
31
|
+
}
|
|
32
|
+
export interface QwShareSheetSchema {
|
|
33
|
+
props: QwShareSheetProps;
|
|
34
|
+
context: {
|
|
35
|
+
open: boolean;
|
|
36
|
+
};
|
|
37
|
+
state: "ready";
|
|
38
|
+
action: "open" | "activate" | "cancel";
|
|
39
|
+
event: {
|
|
40
|
+
type: "OPEN";
|
|
41
|
+
open: boolean;
|
|
42
|
+
} | {
|
|
43
|
+
type: "ACTIVATE";
|
|
44
|
+
source: ShareSheetAction;
|
|
45
|
+
groupIndex: number;
|
|
46
|
+
index: number;
|
|
47
|
+
} | {
|
|
48
|
+
type: "CANCEL";
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export type QwShareSheetService = Service<QwShareSheetSchema>;
|
|
52
|
+
export declare function createShareSheetProps(props?: QwShareSheetProps): QwShareSheetProps;
|
|
53
|
+
export declare function resolveShareSheetGroups(groups?: readonly ShareSheetGroup[]): {
|
|
54
|
+
label: string;
|
|
55
|
+
groupIndex: number;
|
|
56
|
+
actions: {
|
|
57
|
+
value: string;
|
|
58
|
+
label: string;
|
|
59
|
+
icon: IconNameInput;
|
|
60
|
+
description?: string;
|
|
61
|
+
source: ShareSheetAction;
|
|
62
|
+
index: number;
|
|
63
|
+
groupIndex: number;
|
|
64
|
+
disabled: boolean;
|
|
65
|
+
duplicate: boolean;
|
|
66
|
+
}[];
|
|
67
|
+
}[];
|
|
68
|
+
export declare const shareSheetMachine: Machine<QwShareSheetSchema>;
|
|
69
|
+
export declare function connectShareSheet<T extends PropTypes>(service: QwShareSheetService, normalize: NormalizeProps<T>): {
|
|
70
|
+
open: boolean;
|
|
71
|
+
groups: {
|
|
72
|
+
label: string;
|
|
73
|
+
groupIndex: number;
|
|
74
|
+
actions: {
|
|
75
|
+
value: string;
|
|
76
|
+
label: string;
|
|
77
|
+
icon: IconNameInput;
|
|
78
|
+
description?: string;
|
|
79
|
+
source: ShareSheetAction;
|
|
80
|
+
index: number;
|
|
81
|
+
groupIndex: number;
|
|
82
|
+
disabled: boolean;
|
|
83
|
+
duplicate: boolean;
|
|
84
|
+
}[];
|
|
85
|
+
}[];
|
|
86
|
+
popupProps: QwPopupProps;
|
|
87
|
+
cancelText: string;
|
|
88
|
+
setOpen: (value: boolean) => void;
|
|
89
|
+
getRootProps: () => T["element"];
|
|
90
|
+
getGroupProps: (group: ({
|
|
91
|
+
label: string;
|
|
92
|
+
groupIndex: number;
|
|
93
|
+
actions: {
|
|
94
|
+
value: string;
|
|
95
|
+
label: string;
|
|
96
|
+
icon: IconNameInput;
|
|
97
|
+
description?: string;
|
|
98
|
+
source: ShareSheetAction;
|
|
99
|
+
index: number;
|
|
100
|
+
groupIndex: number;
|
|
101
|
+
disabled: boolean;
|
|
102
|
+
duplicate: boolean;
|
|
103
|
+
}[];
|
|
104
|
+
}[])[number]) => T["element"];
|
|
105
|
+
getActionProps: (action: ({
|
|
106
|
+
label: string;
|
|
107
|
+
groupIndex: number;
|
|
108
|
+
actions: {
|
|
109
|
+
value: string;
|
|
110
|
+
label: string;
|
|
111
|
+
icon: IconNameInput;
|
|
112
|
+
description?: string;
|
|
113
|
+
source: ShareSheetAction;
|
|
114
|
+
index: number;
|
|
115
|
+
groupIndex: number;
|
|
116
|
+
disabled: boolean;
|
|
117
|
+
duplicate: boolean;
|
|
118
|
+
}[];
|
|
119
|
+
}[])[number]["actions"][number]) => T["button"];
|
|
120
|
+
getIconState: (action: ({
|
|
121
|
+
label: string;
|
|
122
|
+
groupIndex: number;
|
|
123
|
+
actions: {
|
|
124
|
+
value: string;
|
|
125
|
+
label: string;
|
|
126
|
+
icon: IconNameInput;
|
|
127
|
+
description?: string;
|
|
128
|
+
source: ShareSheetAction;
|
|
129
|
+
index: number;
|
|
130
|
+
groupIndex: number;
|
|
131
|
+
disabled: boolean;
|
|
132
|
+
duplicate: boolean;
|
|
133
|
+
}[];
|
|
134
|
+
}[])[number]["actions"][number]) => import("../index.js").IconState;
|
|
135
|
+
getLabelProps: () => T["element"];
|
|
136
|
+
getDescriptionProps: () => T["element"];
|
|
137
|
+
getCancelProps: () => T["button"];
|
|
138
|
+
};
|
|
139
|
+
export type QwShareSheetApi<T extends PropTypes = PropTypes> = ReturnType<typeof connectShareSheet<T>>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./side-nav.js";
|