@qw-ui/core 0.3.0-next.9 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,116 @@
|
|
|
1
|
+
import { type Machine, type Service } from "@zag-js/core";
|
|
2
|
+
import type { NormalizeProps, PropTypes } from "@zag-js/types";
|
|
3
|
+
/** Stable DOM parts shared by every adapter. */
|
|
4
|
+
export declare const FLOATING_BUBBLE_PARTS: readonly ["root"];
|
|
5
|
+
export declare const FLOATING_BUBBLE_AXES: readonly ["xy", "x", "y", "lock"];
|
|
6
|
+
export declare const FLOATING_BUBBLE_MAGNETS: readonly ["x", "y", "none"];
|
|
7
|
+
export declare const FLOATING_BUBBLE_BOUNDARIES: readonly ["viewport", "parent"];
|
|
8
|
+
export type FloatingBubbleAxis = (typeof FLOATING_BUBBLE_AXES)[number];
|
|
9
|
+
export type FloatingBubbleMagnet = (typeof FLOATING_BUBBLE_MAGNETS)[number];
|
|
10
|
+
export type FloatingBubbleBoundary = (typeof FLOATING_BUBBLE_BOUNDARIES)[number];
|
|
11
|
+
export declare const FLOATING_BUBBLE_DEFAULT_STEP = 16;
|
|
12
|
+
/** Physical CSS px of the bubble's top-left corner relative to the containing block (viewport or offsetParent padding box). */
|
|
13
|
+
export interface FloatingBubbleOffset {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
}
|
|
17
|
+
export type FloatingBubbleOffsetReason = "drag" | "keyboard" | "resize";
|
|
18
|
+
export interface FloatingBubbleOffsetChangeDetails {
|
|
19
|
+
offset: FloatingBubbleOffset;
|
|
20
|
+
reason: FloatingBubbleOffsetReason;
|
|
21
|
+
}
|
|
22
|
+
/** Allowed resting range after subtracting the CSS-provided insets (gap + safe area) and the bubble size. */
|
|
23
|
+
export interface FloatingBubbleBounds {
|
|
24
|
+
minX: number;
|
|
25
|
+
maxX: number;
|
|
26
|
+
minY: number;
|
|
27
|
+
maxY: number;
|
|
28
|
+
}
|
|
29
|
+
export interface QwFloatingBubbleProps {
|
|
30
|
+
id?: string;
|
|
31
|
+
/** Required accessible name of the button. */
|
|
32
|
+
label?: string;
|
|
33
|
+
/** Controlled position; undefined lets Core own it (seeded by defaultOffset, else inline-end bottom after measuring). */
|
|
34
|
+
offset?: FloatingBubbleOffset;
|
|
35
|
+
defaultOffset?: FloatingBubbleOffset;
|
|
36
|
+
/** Called once per drag release, keyboard move or resize correction; controlled owners accept by updating offset. */
|
|
37
|
+
onOffsetChange?: (details: FloatingBubbleOffsetChangeDetails) => void;
|
|
38
|
+
/** Drag axes; lock disables dragging. Default xy. */
|
|
39
|
+
axis?: FloatingBubbleAxis;
|
|
40
|
+
/** Snap to the nearest horizontal (x) or vertical (y) edge after moving; default x. */
|
|
41
|
+
magnet?: FloatingBubbleMagnet;
|
|
42
|
+
/** viewport (position: fixed, default) or parent (position: absolute in the offsetParent). */
|
|
43
|
+
boundary?: FloatingBubbleBoundary;
|
|
44
|
+
/** Arrow-key step in px; 0 disables keyboard moving. Default 16. */
|
|
45
|
+
keyboardStep?: number;
|
|
46
|
+
disabled?: boolean;
|
|
47
|
+
}
|
|
48
|
+
export interface ResolvedFloatingBubbleState {
|
|
49
|
+
label: string;
|
|
50
|
+
axis: FloatingBubbleAxis;
|
|
51
|
+
magnet: FloatingBubbleMagnet;
|
|
52
|
+
boundary: FloatingBubbleBoundary;
|
|
53
|
+
keyboardStep: number;
|
|
54
|
+
disabled: boolean;
|
|
55
|
+
}
|
|
56
|
+
export declare function resolveFloatingBubbleState(props?: QwFloatingBubbleProps): ResolvedFloatingBubbleState;
|
|
57
|
+
export declare function createFloatingBubbleProps(props?: QwFloatingBubbleProps): QwFloatingBubbleProps;
|
|
58
|
+
export declare function clampFloatingBubbleOffset(offset: FloatingBubbleOffset, bounds: FloatingBubbleBounds): FloatingBubbleOffset;
|
|
59
|
+
/** Clamp, then move to the nearest edge on the magnet axis (ties go to the larger edge). */
|
|
60
|
+
export declare function snapFloatingBubbleOffset(offset: FloatingBubbleOffset, bounds: FloatingBubbleBounds, magnet: FloatingBubbleMagnet): FloatingBubbleOffset;
|
|
61
|
+
export interface QwFloatingBubbleSchema {
|
|
62
|
+
props: QwFloatingBubbleProps;
|
|
63
|
+
context: {
|
|
64
|
+
offset: FloatingBubbleOffset | null;
|
|
65
|
+
drag: FloatingBubbleOffset | null;
|
|
66
|
+
bounds: FloatingBubbleBounds | null;
|
|
67
|
+
animate: boolean;
|
|
68
|
+
};
|
|
69
|
+
refs: {
|
|
70
|
+
rtl: boolean;
|
|
71
|
+
suppressClick: boolean;
|
|
72
|
+
};
|
|
73
|
+
state: "ready";
|
|
74
|
+
action: "measure" | "drag" | "release" | "key";
|
|
75
|
+
effect: "track";
|
|
76
|
+
event: {
|
|
77
|
+
type: "MEASURE";
|
|
78
|
+
bounds: FloatingBubbleBounds;
|
|
79
|
+
rtl: boolean;
|
|
80
|
+
} | {
|
|
81
|
+
type: "DRAG";
|
|
82
|
+
position: FloatingBubbleOffset;
|
|
83
|
+
} | {
|
|
84
|
+
type: "RELEASE";
|
|
85
|
+
} | {
|
|
86
|
+
type: "KEY";
|
|
87
|
+
key: string;
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
export type QwFloatingBubbleMachine = Machine<QwFloatingBubbleSchema>;
|
|
91
|
+
export type QwFloatingBubbleService = Service<QwFloatingBubbleSchema>;
|
|
92
|
+
/** Core owns click/drag discrimination, clamping, magnet snapping, measurement, keyboard moving and listener cleanup. */
|
|
93
|
+
export declare const floatingBubbleMachine: QwFloatingBubbleMachine;
|
|
94
|
+
/** Minimal event surface shared by React, Vue and native events. */
|
|
95
|
+
export interface FloatingBubbleDomEvent {
|
|
96
|
+
readonly defaultPrevented: boolean;
|
|
97
|
+
readonly key?: string;
|
|
98
|
+
preventDefault?(): void;
|
|
99
|
+
stopPropagation?(): void;
|
|
100
|
+
}
|
|
101
|
+
export type FloatingBubbleEventHandler = (event: FloatingBubbleDomEvent) => void;
|
|
102
|
+
type Handlers = FloatingBubbleEventHandler | readonly FloatingBubbleEventHandler[] | undefined;
|
|
103
|
+
/** Caller onClick/onKeyDown run first (except the click swallowed after a drag); preventDefault() skips Core. */
|
|
104
|
+
export interface FloatingBubbleConnectOptions {
|
|
105
|
+
onClick?: Handlers;
|
|
106
|
+
onKeyDown?: Handlers;
|
|
107
|
+
}
|
|
108
|
+
export interface QwFloatingBubbleApi<T extends PropTypes = PropTypes> {
|
|
109
|
+
label: string;
|
|
110
|
+
dragging: boolean;
|
|
111
|
+
/** Rendered position, or null before the first measurement (CSS logical fallback). */
|
|
112
|
+
position: FloatingBubbleOffset | null;
|
|
113
|
+
getRootProps(): T["button"];
|
|
114
|
+
}
|
|
115
|
+
export declare function connectFloatingBubble<T extends PropTypes>(service: QwFloatingBubbleService, normalize: NormalizeProps<T>, options?: FloatingBubbleConnectOptions): QwFloatingBubbleApi<T>;
|
|
116
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./floating-bubble.js";
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import { createMachine } from "@zag-js/core";
|
|
2
|
+
//#region src/floating-bubble/floating-bubble.ts
|
|
3
|
+
/** Stable DOM parts shared by every adapter. */
|
|
4
|
+
const FLOATING_BUBBLE_PARTS = ["root"];
|
|
5
|
+
const FLOATING_BUBBLE_AXES = [
|
|
6
|
+
"xy",
|
|
7
|
+
"x",
|
|
8
|
+
"y",
|
|
9
|
+
"lock"
|
|
10
|
+
];
|
|
11
|
+
const FLOATING_BUBBLE_MAGNETS = [
|
|
12
|
+
"x",
|
|
13
|
+
"y",
|
|
14
|
+
"none"
|
|
15
|
+
];
|
|
16
|
+
const FLOATING_BUBBLE_BOUNDARIES = ["viewport", "parent"];
|
|
17
|
+
const FLOATING_BUBBLE_DEFAULT_STEP = 16;
|
|
18
|
+
const pick = (list, value, fallback) => list.includes(value) ? value : fallback;
|
|
19
|
+
function resolveFloatingBubbleState(props = {}) {
|
|
20
|
+
const step = props.keyboardStep;
|
|
21
|
+
return {
|
|
22
|
+
label: typeof props.label === "string" ? props.label.trim() : "",
|
|
23
|
+
axis: pick(FLOATING_BUBBLE_AXES, props.axis, "xy"),
|
|
24
|
+
magnet: pick(FLOATING_BUBBLE_MAGNETS, props.magnet, "x"),
|
|
25
|
+
boundary: pick(FLOATING_BUBBLE_BOUNDARIES, props.boundary, "viewport"),
|
|
26
|
+
keyboardStep: typeof step === "number" && Number.isFinite(step) && step >= 0 ? step : 16,
|
|
27
|
+
disabled: !!props.disabled
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const validOffset = (value) => {
|
|
31
|
+
const offset = value;
|
|
32
|
+
return offset && Number.isFinite(offset.x) && Number.isFinite(offset.y) ? {
|
|
33
|
+
x: offset.x,
|
|
34
|
+
y: offset.y
|
|
35
|
+
} : void 0;
|
|
36
|
+
};
|
|
37
|
+
function createFloatingBubbleProps(props = {}) {
|
|
38
|
+
if (props.id !== void 0 && (typeof props.id !== "string" || !props.id.trim())) throw new TypeError("FloatingBubble requires a nonempty instance id when provided");
|
|
39
|
+
if (typeof props.label !== "string" || !props.label.trim()) throw new TypeError("FloatingBubble requires a nonempty label (accessible name)");
|
|
40
|
+
return {
|
|
41
|
+
...props,
|
|
42
|
+
offset: props.offset === void 0 ? void 0 : validOffset(props.offset),
|
|
43
|
+
defaultOffset: validOffset(props.defaultOffset)
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
const clamp = (value, min, max) => Math.min(max, Math.max(min, value));
|
|
47
|
+
function clampFloatingBubbleOffset(offset, bounds) {
|
|
48
|
+
return {
|
|
49
|
+
x: clamp(offset.x, bounds.minX, bounds.maxX),
|
|
50
|
+
y: clamp(offset.y, bounds.minY, bounds.maxY)
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/** Clamp, then move to the nearest edge on the magnet axis (ties go to the larger edge). */
|
|
54
|
+
function snapFloatingBubbleOffset(offset, bounds, magnet) {
|
|
55
|
+
const next = clampFloatingBubbleOffset(offset, bounds);
|
|
56
|
+
if (magnet === "x") next.x = next.x - bounds.minX < bounds.maxX - next.x ? bounds.minX : bounds.maxX;
|
|
57
|
+
if (magnet === "y") next.y = next.y - bounds.minY < bounds.maxY - next.y ? bounds.minY : bounds.maxY;
|
|
58
|
+
return next;
|
|
59
|
+
}
|
|
60
|
+
const same = (a, b) => a === b || !!a && !!b && a.x === b.x && a.y === b.y;
|
|
61
|
+
const rootId = (scope) => `floating-bubble:${scope.id}`;
|
|
62
|
+
const live = (prop) => resolveFloatingBubbleState({
|
|
63
|
+
label: prop("label"),
|
|
64
|
+
axis: prop("axis"),
|
|
65
|
+
magnet: prop("magnet"),
|
|
66
|
+
boundary: prop("boundary"),
|
|
67
|
+
keyboardStep: prop("keyboardStep"),
|
|
68
|
+
disabled: prop("disabled")
|
|
69
|
+
});
|
|
70
|
+
/** Rendered position: the live drag, else the (controlled or owned) offset clamped to measured bounds; null until measured. */
|
|
71
|
+
function position(context) {
|
|
72
|
+
const drag = context.get("drag"), offset = context.get("offset"), bounds = context.get("bounds");
|
|
73
|
+
if (drag) return drag;
|
|
74
|
+
return offset && bounds ? clampFloatingBubbleOffset(offset, bounds) : offset;
|
|
75
|
+
}
|
|
76
|
+
function commit(context, prop, next, reason) {
|
|
77
|
+
if (same(context.get("offset"), next)) return;
|
|
78
|
+
context.set("offset", next);
|
|
79
|
+
prop("onOffsetChange")?.({
|
|
80
|
+
offset: next,
|
|
81
|
+
reason
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
const px = (value) => {
|
|
85
|
+
const number = Number.parseFloat(value);
|
|
86
|
+
return Number.isFinite(number) ? number : 0;
|
|
87
|
+
};
|
|
88
|
+
/** Core owns click/drag discrimination, clamping, magnet snapping, measurement, keyboard moving and listener cleanup. */
|
|
89
|
+
const floatingBubbleMachine = createMachine({
|
|
90
|
+
props: ({ props }) => createFloatingBubbleProps(props),
|
|
91
|
+
initialState: () => "ready",
|
|
92
|
+
context: ({ bindable, prop }) => ({
|
|
93
|
+
offset: bindable(() => ({
|
|
94
|
+
defaultValue: prop("defaultOffset") ?? null,
|
|
95
|
+
value: prop("offset"),
|
|
96
|
+
isEqual: same
|
|
97
|
+
})),
|
|
98
|
+
drag: bindable(() => ({
|
|
99
|
+
defaultValue: null,
|
|
100
|
+
isEqual: same
|
|
101
|
+
})),
|
|
102
|
+
animate: bindable(() => ({ defaultValue: false })),
|
|
103
|
+
bounds: bindable(() => ({ defaultValue: null }))
|
|
104
|
+
}),
|
|
105
|
+
refs: () => ({
|
|
106
|
+
rtl: false,
|
|
107
|
+
suppressClick: false
|
|
108
|
+
}),
|
|
109
|
+
effects: ["track"],
|
|
110
|
+
on: {
|
|
111
|
+
MEASURE: { actions: ["measure"] },
|
|
112
|
+
DRAG: { actions: ["drag"] },
|
|
113
|
+
RELEASE: { actions: ["release"] },
|
|
114
|
+
KEY: { actions: ["key"] }
|
|
115
|
+
},
|
|
116
|
+
states: { ready: {} },
|
|
117
|
+
implementations: {
|
|
118
|
+
actions: {
|
|
119
|
+
measure({ context, prop, refs, event }) {
|
|
120
|
+
if (event.type !== "MEASURE") return;
|
|
121
|
+
const first = !context.get("bounds"), offset = context.get("offset"), { bounds } = event;
|
|
122
|
+
context.set("animate", false);
|
|
123
|
+
refs.set("rtl", event.rtl);
|
|
124
|
+
context.set("bounds", bounds);
|
|
125
|
+
if (!offset) {
|
|
126
|
+
context.set("offset", {
|
|
127
|
+
x: event.rtl ? bounds.minX : bounds.maxX,
|
|
128
|
+
y: bounds.maxY
|
|
129
|
+
});
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (first) {
|
|
133
|
+
if (prop("offset") === void 0) context.set("offset", snapFloatingBubbleOffset(offset, bounds, live(prop).magnet));
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
if (!context.get("drag")) commit(context, prop, snapFloatingBubbleOffset(offset, bounds, live(prop).magnet), "resize");
|
|
137
|
+
},
|
|
138
|
+
drag({ context, event }) {
|
|
139
|
+
if (event.type === "DRAG") {
|
|
140
|
+
context.set("animate", false);
|
|
141
|
+
context.set("drag", event.position);
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
release({ context, prop }) {
|
|
145
|
+
const drag = context.get("drag"), bounds = context.get("bounds");
|
|
146
|
+
if (!drag || !bounds) return;
|
|
147
|
+
context.set("animate", true);
|
|
148
|
+
context.set("drag", null);
|
|
149
|
+
commit(context, prop, snapFloatingBubbleOffset(drag, bounds, live(prop).magnet), "drag");
|
|
150
|
+
},
|
|
151
|
+
key({ context, prop, event }) {
|
|
152
|
+
const state = live(prop), bounds = context.get("bounds"), current = position(context);
|
|
153
|
+
if (event.type !== "KEY" || !bounds || !current) return;
|
|
154
|
+
context.set("animate", true);
|
|
155
|
+
const horizontal = event.key === "ArrowLeft" || event.key === "ArrowRight", sign = event.key === "ArrowLeft" || event.key === "ArrowUp" ? -1 : 1;
|
|
156
|
+
const next = { ...current };
|
|
157
|
+
if (horizontal) next.x = state.magnet === "x" ? sign < 0 ? bounds.minX : bounds.maxX : current.x + sign * state.keyboardStep;
|
|
158
|
+
else next.y = state.magnet === "y" ? sign < 0 ? bounds.minY : bounds.maxY : current.y + sign * state.keyboardStep;
|
|
159
|
+
commit(context, prop, clampFloatingBubbleOffset(next, bounds), "keyboard");
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
effects: { track({ scope, prop, context, refs, send }) {
|
|
163
|
+
const root = scope.getById(rootId(scope)), win = root?.ownerDocument.defaultView;
|
|
164
|
+
if (!root || !win) return;
|
|
165
|
+
const measure = () => {
|
|
166
|
+
const style = win.getComputedStyle(root), container = live(prop).boundary === "parent" ? root.offsetParent : null;
|
|
167
|
+
const width = container ? container.clientWidth : root.ownerDocument.documentElement.clientWidth || win.innerWidth;
|
|
168
|
+
const height = container ? container.clientHeight : root.ownerDocument.documentElement.clientHeight || win.innerHeight;
|
|
169
|
+
const top = px(style.scrollMarginTop), right = px(style.scrollMarginRight), bottom = px(style.scrollMarginBottom);
|
|
170
|
+
const minX = px(style.scrollMarginLeft), minY = top;
|
|
171
|
+
send({
|
|
172
|
+
type: "MEASURE",
|
|
173
|
+
rtl: style.direction === "rtl",
|
|
174
|
+
bounds: {
|
|
175
|
+
minX,
|
|
176
|
+
minY,
|
|
177
|
+
maxX: Math.max(minX, width - root.offsetWidth - right),
|
|
178
|
+
maxY: Math.max(minY, height - root.offsetHeight - bottom)
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
let release = 0;
|
|
183
|
+
let cancelledPointer = null;
|
|
184
|
+
let gesture = null;
|
|
185
|
+
const clearAfterRelease = () => {
|
|
186
|
+
win.clearTimeout(release);
|
|
187
|
+
release = win.setTimeout(() => refs.set("suppressClick", false), 0);
|
|
188
|
+
};
|
|
189
|
+
const down = (event) => {
|
|
190
|
+
const state = live(prop), origin = position(context);
|
|
191
|
+
if (gesture || state.disabled || state.axis === "lock" || !origin || !context.get("bounds") || event.pointerType === "mouse" && event.button !== 0) return;
|
|
192
|
+
cancelledPointer = null;
|
|
193
|
+
win.clearTimeout(release);
|
|
194
|
+
refs.set("suppressClick", false);
|
|
195
|
+
gesture = {
|
|
196
|
+
id: event.pointerId,
|
|
197
|
+
x: event.clientX,
|
|
198
|
+
y: event.clientY,
|
|
199
|
+
origin,
|
|
200
|
+
dragging: false
|
|
201
|
+
};
|
|
202
|
+
try {
|
|
203
|
+
root.setPointerCapture?.(event.pointerId);
|
|
204
|
+
} catch {}
|
|
205
|
+
};
|
|
206
|
+
const move = (event) => {
|
|
207
|
+
const bounds = context.get("bounds");
|
|
208
|
+
if (!gesture || event.pointerId !== gesture.id || !bounds) return;
|
|
209
|
+
const axis = live(prop).axis, dx = axis === "y" ? 0 : event.clientX - gesture.x, dy = axis === "x" ? 0 : event.clientY - gesture.y;
|
|
210
|
+
if (!gesture.dragging) {
|
|
211
|
+
if (Math.max(Math.abs(event.clientX - gesture.x), Math.abs(event.clientY - gesture.y)) < 8) return;
|
|
212
|
+
gesture.dragging = true;
|
|
213
|
+
}
|
|
214
|
+
send({
|
|
215
|
+
type: "DRAG",
|
|
216
|
+
position: clampFloatingBubbleOffset({
|
|
217
|
+
x: gesture.origin.x + dx,
|
|
218
|
+
y: gesture.origin.y + dy
|
|
219
|
+
}, bounds)
|
|
220
|
+
});
|
|
221
|
+
};
|
|
222
|
+
const finish = (event) => {
|
|
223
|
+
if (!gesture) return;
|
|
224
|
+
const ended = gesture;
|
|
225
|
+
gesture = null;
|
|
226
|
+
if (ended.dragging) send({ type: "RELEASE" });
|
|
227
|
+
if (ended.dragging || event.type !== "pointerup") {
|
|
228
|
+
refs.set("suppressClick", true);
|
|
229
|
+
if (event.type === "pointerup") clearAfterRelease();
|
|
230
|
+
else cancelledPointer = ended.id;
|
|
231
|
+
}
|
|
232
|
+
try {
|
|
233
|
+
root.releasePointerCapture?.(ended.id);
|
|
234
|
+
} catch {}
|
|
235
|
+
};
|
|
236
|
+
const up = (event) => {
|
|
237
|
+
if (event.pointerId === gesture?.id) finish(event);
|
|
238
|
+
else if (event.type === "pointerup" && event.pointerId === cancelledPointer) {
|
|
239
|
+
cancelledPointer = null;
|
|
240
|
+
clearAfterRelease();
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
const Observer = win.ResizeObserver, observer = Observer ? new Observer(() => measure()) : null;
|
|
244
|
+
const doc = root.ownerDocument;
|
|
245
|
+
root.addEventListener("pointerdown", down);
|
|
246
|
+
root.addEventListener("lostpointercapture", up);
|
|
247
|
+
doc.addEventListener("pointermove", move, true);
|
|
248
|
+
doc.addEventListener("pointerup", up, true);
|
|
249
|
+
doc.addEventListener("pointercancel", up, true);
|
|
250
|
+
win.addEventListener("blur", finish);
|
|
251
|
+
win.addEventListener("resize", measure);
|
|
252
|
+
observer?.observe(root);
|
|
253
|
+
const parent = live(prop).boundary === "parent" ? root.offsetParent : null;
|
|
254
|
+
if (parent) observer?.observe(parent);
|
|
255
|
+
measure();
|
|
256
|
+
return () => {
|
|
257
|
+
root.removeEventListener("pointerdown", down);
|
|
258
|
+
root.removeEventListener("lostpointercapture", up);
|
|
259
|
+
doc.removeEventListener("pointermove", move, true);
|
|
260
|
+
doc.removeEventListener("pointerup", up, true);
|
|
261
|
+
doc.removeEventListener("pointercancel", up, true);
|
|
262
|
+
win.removeEventListener("blur", finish);
|
|
263
|
+
win.removeEventListener("resize", measure);
|
|
264
|
+
observer?.disconnect();
|
|
265
|
+
win.clearTimeout(release);
|
|
266
|
+
const id = gesture?.id;
|
|
267
|
+
gesture = null;
|
|
268
|
+
if (id !== void 0) try {
|
|
269
|
+
root.releasePointerCapture?.(id);
|
|
270
|
+
} catch {}
|
|
271
|
+
};
|
|
272
|
+
} }
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
function run(handlers, event) {
|
|
276
|
+
const list = typeof handlers === "function" ? [handlers] : handlers ?? [];
|
|
277
|
+
for (const handler of list) if (typeof handler === "function") handler(event);
|
|
278
|
+
return !event.defaultPrevented;
|
|
279
|
+
}
|
|
280
|
+
const ARROWS = /* @__PURE__ */ new Set([
|
|
281
|
+
"ArrowLeft",
|
|
282
|
+
"ArrowRight",
|
|
283
|
+
"ArrowUp",
|
|
284
|
+
"ArrowDown"
|
|
285
|
+
]);
|
|
286
|
+
function connectFloatingBubble(service, normalize, options = {}) {
|
|
287
|
+
const state = live(service.prop), { context, refs, send } = service, current = position(context), dragging = !!context.get("drag");
|
|
288
|
+
return {
|
|
289
|
+
label: state.label,
|
|
290
|
+
dragging,
|
|
291
|
+
position: current,
|
|
292
|
+
getRootProps: () => normalize.button({
|
|
293
|
+
"data-scope": "floating-bubble",
|
|
294
|
+
"data-part": "root",
|
|
295
|
+
id: rootId(service.scope),
|
|
296
|
+
type: "button",
|
|
297
|
+
"aria-label": state.label,
|
|
298
|
+
disabled: state.disabled || void 0,
|
|
299
|
+
"data-animate": context.get("animate") || void 0,
|
|
300
|
+
"data-boundary": state.boundary,
|
|
301
|
+
"data-axis": state.axis,
|
|
302
|
+
"data-dragging": dragging || void 0,
|
|
303
|
+
"data-positioned": current ? "" : void 0,
|
|
304
|
+
style: current ? {
|
|
305
|
+
"--qw-floating-bubble-x": `${current.x}px`,
|
|
306
|
+
"--qw-floating-bubble-y": `${current.y}px`
|
|
307
|
+
} : void 0,
|
|
308
|
+
onClick(event) {
|
|
309
|
+
if (refs.get("suppressClick") && !("detail" in event && event.detail === 0)) {
|
|
310
|
+
refs.set("suppressClick", false);
|
|
311
|
+
event.preventDefault?.();
|
|
312
|
+
event.stopPropagation?.();
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
run(options.onClick, event);
|
|
316
|
+
},
|
|
317
|
+
onKeyDown(event) {
|
|
318
|
+
const key = event.key ?? "";
|
|
319
|
+
if (!run(options.onKeyDown, event) || !ARROWS.has(key) || state.disabled || state.axis === "lock" || state.keyboardStep === 0) return;
|
|
320
|
+
if (state.axis === "x" && (key === "ArrowUp" || key === "ArrowDown") || state.axis === "y" && (key === "ArrowLeft" || key === "ArrowRight")) return;
|
|
321
|
+
event.preventDefault?.();
|
|
322
|
+
send({
|
|
323
|
+
type: "KEY",
|
|
324
|
+
key
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
})
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
//#endregion
|
|
331
|
+
export { FLOATING_BUBBLE_AXES, FLOATING_BUBBLE_BOUNDARIES, FLOATING_BUBBLE_DEFAULT_STEP, FLOATING_BUBBLE_MAGNETS, FLOATING_BUBBLE_PARTS, clampFloatingBubbleOffset, connectFloatingBubble, createFloatingBubbleProps, floatingBubbleMachine, resolveFloatingBubbleState, snapFloatingBubbleOffset };
|
|
332
|
+
|
|
333
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/floating-bubble/floating-bubble.ts"],"sourcesContent":["import { createMachine, type Machine, type Service } from \"@zag-js/core\";\nimport type { NormalizeProps, PropTypes } from \"@zag-js/types\";\nimport { GESTURE_SLOP } from \"../swiper/gesture.js\";\n\n/** Stable DOM parts shared by every adapter. */\nexport const FLOATING_BUBBLE_PARTS = [\"root\"] as const;\nexport const FLOATING_BUBBLE_AXES = [\"xy\", \"x\", \"y\", \"lock\"] as const;\nexport const FLOATING_BUBBLE_MAGNETS = [\"x\", \"y\", \"none\"] as const;\nexport const FLOATING_BUBBLE_BOUNDARIES = [\"viewport\", \"parent\"] as const;\nexport type FloatingBubbleAxis = (typeof FLOATING_BUBBLE_AXES)[number];\nexport type FloatingBubbleMagnet = (typeof FLOATING_BUBBLE_MAGNETS)[number];\nexport type FloatingBubbleBoundary = (typeof FLOATING_BUBBLE_BOUNDARIES)[number];\nexport const FLOATING_BUBBLE_DEFAULT_STEP = 16;\n/** Physical CSS px of the bubble's top-left corner relative to the containing block (viewport or offsetParent padding box). */\nexport interface FloatingBubbleOffset { x: number; y: number }\nexport type FloatingBubbleOffsetReason = \"drag\" | \"keyboard\" | \"resize\";\nexport interface FloatingBubbleOffsetChangeDetails { offset: FloatingBubbleOffset; reason: FloatingBubbleOffsetReason }\n/** Allowed resting range after subtracting the CSS-provided insets (gap + safe area) and the bubble size. */\nexport interface FloatingBubbleBounds { minX: number; maxX: number; minY: number; maxY: number }\n\nexport interface QwFloatingBubbleProps {\n id?: string;\n /** Required accessible name of the button. */\n label?: string;\n /** Controlled position; undefined lets Core own it (seeded by defaultOffset, else inline-end bottom after measuring). */\n offset?: FloatingBubbleOffset;\n defaultOffset?: FloatingBubbleOffset;\n /** Called once per drag release, keyboard move or resize correction; controlled owners accept by updating offset. */\n onOffsetChange?: (details: FloatingBubbleOffsetChangeDetails) => void;\n /** Drag axes; lock disables dragging. Default xy. */\n axis?: FloatingBubbleAxis;\n /** Snap to the nearest horizontal (x) or vertical (y) edge after moving; default x. */\n magnet?: FloatingBubbleMagnet;\n /** viewport (position: fixed, default) or parent (position: absolute in the offsetParent). */\n boundary?: FloatingBubbleBoundary;\n /** Arrow-key step in px; 0 disables keyboard moving. Default 16. */\n keyboardStep?: number;\n disabled?: boolean;\n}\nexport interface ResolvedFloatingBubbleState { label: string; axis: FloatingBubbleAxis; magnet: FloatingBubbleMagnet; boundary: FloatingBubbleBoundary; keyboardStep: number; disabled: boolean }\nconst pick = <T extends string>(list: readonly T[], value: unknown, fallback: T): T => list.includes(value as T) ? value as T : fallback;\nexport function resolveFloatingBubbleState(props: QwFloatingBubbleProps = {}): ResolvedFloatingBubbleState {\n const step = props.keyboardStep;\n return {\n label: typeof props.label === \"string\" ? props.label.trim() : \"\", axis: pick(FLOATING_BUBBLE_AXES, props.axis, \"xy\"), magnet: pick(FLOATING_BUBBLE_MAGNETS, props.magnet, \"x\"),\n boundary: pick(FLOATING_BUBBLE_BOUNDARIES, props.boundary, \"viewport\"),\n keyboardStep: typeof step === \"number\" && Number.isFinite(step) && step >= 0 ? step : FLOATING_BUBBLE_DEFAULT_STEP, disabled: !!props.disabled,\n };\n}\nconst validOffset = (value: unknown): FloatingBubbleOffset | undefined => {\n const offset = value as FloatingBubbleOffset | undefined;\n return offset && Number.isFinite(offset.x) && Number.isFinite(offset.y) ? { x: offset.x, y: offset.y } : undefined;\n};\nexport function createFloatingBubbleProps(props: QwFloatingBubbleProps = {}): QwFloatingBubbleProps {\n if (props.id !== undefined && (typeof props.id !== \"string\" || !props.id.trim())) throw new TypeError(\"FloatingBubble requires a nonempty instance id when provided\");\n if (typeof props.label !== \"string\" || !props.label.trim()) throw new TypeError(\"FloatingBubble requires a nonempty label (accessible name)\");\n return { ...props, offset: props.offset === undefined ? undefined : validOffset(props.offset), defaultOffset: validOffset(props.defaultOffset) };\n}\nconst clamp = (value: number, min: number, max: number) => Math.min(max, Math.max(min, value));\nexport function clampFloatingBubbleOffset(offset: FloatingBubbleOffset, bounds: FloatingBubbleBounds): FloatingBubbleOffset {\n return { x: clamp(offset.x, bounds.minX, bounds.maxX), y: clamp(offset.y, bounds.minY, bounds.maxY) };\n}\n/** Clamp, then move to the nearest edge on the magnet axis (ties go to the larger edge). */\nexport function snapFloatingBubbleOffset(offset: FloatingBubbleOffset, bounds: FloatingBubbleBounds, magnet: FloatingBubbleMagnet): FloatingBubbleOffset {\n const next = clampFloatingBubbleOffset(offset, bounds);\n if (magnet === \"x\") next.x = next.x - bounds.minX < bounds.maxX - next.x ? bounds.minX : bounds.maxX;\n if (magnet === \"y\") next.y = next.y - bounds.minY < bounds.maxY - next.y ? bounds.minY : bounds.maxY;\n return next;\n}\nconst same = (a: FloatingBubbleOffset | null | undefined, b: FloatingBubbleOffset | null | undefined) => a === b || (!!a && !!b && a.x === b.x && a.y === b.y);\n\nexport interface QwFloatingBubbleSchema {\n props: QwFloatingBubbleProps;\n context: { offset: FloatingBubbleOffset | null; drag: FloatingBubbleOffset | null; bounds: FloatingBubbleBounds | null; animate: boolean };\n refs: { rtl: boolean; suppressClick: boolean };\n state: \"ready\";\n action: \"measure\" | \"drag\" | \"release\" | \"key\";\n effect: \"track\";\n event:\n | { type: \"MEASURE\"; bounds: FloatingBubbleBounds; rtl: boolean }\n | { type: \"DRAG\"; position: FloatingBubbleOffset }\n | { type: \"RELEASE\" }\n | { type: \"KEY\"; key: string };\n}\nexport type QwFloatingBubbleMachine = Machine<QwFloatingBubbleSchema>;\nexport type QwFloatingBubbleService = Service<QwFloatingBubbleSchema>;\ntype Ctx = QwFloatingBubbleService[\"context\"];\ntype Prop = QwFloatingBubbleService[\"prop\"];\nconst rootId = (scope: QwFloatingBubbleService[\"scope\"]) => `floating-bubble:${scope.id}`;\nconst live = (prop: Prop) => resolveFloatingBubbleState({ label: prop(\"label\"), axis: prop(\"axis\"), magnet: prop(\"magnet\"), boundary: prop(\"boundary\"), keyboardStep: prop(\"keyboardStep\"), disabled: prop(\"disabled\") });\n/** Rendered position: the live drag, else the (controlled or owned) offset clamped to measured bounds; null until measured. */\nfunction position(context: Ctx): FloatingBubbleOffset | null {\n const drag = context.get(\"drag\"), offset = context.get(\"offset\"), bounds = context.get(\"bounds\");\n if (drag) return drag;\n return offset && bounds ? clampFloatingBubbleOffset(offset, bounds) : offset;\n}\nfunction commit(context: Ctx, prop: Prop, next: FloatingBubbleOffset, reason: FloatingBubbleOffsetReason) {\n if (same(context.get(\"offset\"), next)) return;\n context.set(\"offset\", next);\n prop(\"onOffsetChange\")?.({ offset: next, reason });\n}\nconst px = (value: string) => { const number = Number.parseFloat(value); return Number.isFinite(number) ? number : 0; };\n\n/** Core owns click/drag discrimination, clamping, magnet snapping, measurement, keyboard moving and listener cleanup. */\nexport const floatingBubbleMachine: QwFloatingBubbleMachine = createMachine<QwFloatingBubbleSchema>({\n props: ({ props }) => createFloatingBubbleProps(props), initialState: () => \"ready\",\n context: ({ bindable, prop }) => ({\n offset: bindable<FloatingBubbleOffset | null>(() => ({ defaultValue: prop(\"defaultOffset\") ?? null, value: prop(\"offset\"), isEqual: same })),\n drag: bindable<FloatingBubbleOffset | null>(() => ({ defaultValue: null, isEqual: same })),\n animate: bindable<boolean>(() => ({ defaultValue: false })),\n bounds: bindable<FloatingBubbleBounds | null>(() => ({ defaultValue: null })),\n }),\n refs: () => ({ rtl: false, suppressClick: false }),\n effects: [\"track\"],\n on: { MEASURE: { actions: [\"measure\"] }, DRAG: { actions: [\"drag\"] }, RELEASE: { actions: [\"release\"] }, KEY: { actions: [\"key\"] } },\n states: { ready: {} },\n implementations: {\n actions: {\n measure({ context, prop, refs, event }) {\n if (event.type !== \"MEASURE\") return;\n const first = !context.get(\"bounds\"), offset = context.get(\"offset\"), { bounds } = event;\n context.set(\"animate\", false);\n refs.set(\"rtl\", event.rtl); context.set(\"bounds\", bounds);\n // First measurement is silent: no offset rests at the inline-end bottom corner (mirrored in RTL); an owned offset is snapped;\n // a controlled offset is only clamped at render. Later measurements (resize) re-snap and report.\n if (!offset) { context.set(\"offset\", { x: event.rtl ? bounds.minX : bounds.maxX, y: bounds.maxY }); return; }\n if (first) { if (prop(\"offset\") === undefined) context.set(\"offset\", snapFloatingBubbleOffset(offset, bounds, live(prop).magnet)); return; }\n if (!context.get(\"drag\")) commit(context, prop, snapFloatingBubbleOffset(offset, bounds, live(prop).magnet), \"resize\");\n },\n drag({ context, event }) { if (event.type === \"DRAG\") { context.set(\"animate\", false); context.set(\"drag\", event.position); } },\n release({ context, prop }) {\n const drag = context.get(\"drag\"), bounds = context.get(\"bounds\");\n if (!drag || !bounds) return;\n context.set(\"animate\", true);\n context.set(\"drag\", null);\n commit(context, prop, snapFloatingBubbleOffset(drag, bounds, live(prop).magnet), \"drag\");\n },\n key({ context, prop, event }) {\n const state = live(prop), bounds = context.get(\"bounds\"), current = position(context);\n if (event.type !== \"KEY\" || !bounds || !current) return;\n context.set(\"animate\", true);\n const horizontal = event.key === \"ArrowLeft\" || event.key === \"ArrowRight\", sign = event.key === \"ArrowLeft\" || event.key === \"ArrowUp\" ? -1 : 1;\n const next = { ...current };\n if (horizontal) next.x = state.magnet === \"x\" ? (sign < 0 ? bounds.minX : bounds.maxX) : current.x + sign * state.keyboardStep;\n else next.y = state.magnet === \"y\" ? (sign < 0 ? bounds.minY : bounds.maxY) : current.y + sign * state.keyboardStep;\n commit(context, prop, clampFloatingBubbleOffset(next, bounds), \"keyboard\");\n },\n },\n effects: {\n track({ scope, prop, context, refs, send }) {\n const root = scope.getById<HTMLElement>(rootId(scope)), win = root?.ownerDocument.defaultView;\n if (!root || !win) return;\n const measure = () => {\n const style = win.getComputedStyle(root), container = live(prop).boundary === \"parent\" ? root.offsetParent as HTMLElement | null : null;\n const width = container ? container.clientWidth : root.ownerDocument.documentElement.clientWidth || win.innerWidth;\n const height = container ? container.clientHeight : root.ownerDocument.documentElement.clientHeight || win.innerHeight;\n // Insets (gap + safe area) come from CSS scroll-margin so env() stays in the style layer.\n const top = px(style.scrollMarginTop), right = px(style.scrollMarginRight), bottom = px(style.scrollMarginBottom), left = px(style.scrollMarginLeft);\n const minX = left, minY = top;\n send({ type: \"MEASURE\", rtl: style.direction === \"rtl\", bounds: { minX, minY, maxX: Math.max(minX, width - root.offsetWidth - right), maxY: Math.max(minY, height - root.offsetHeight - bottom) } });\n };\n let release = 0;\n let cancelledPointer: number | null = null;\n let gesture: { id: number; x: number; y: number; origin: FloatingBubbleOffset; dragging: boolean } | null = null;\n const clearAfterRelease = () => {\n win.clearTimeout(release);\n release = win.setTimeout(() => refs.set(\"suppressClick\", false), 0);\n };\n const down = (event: PointerEvent) => {\n const state = live(prop), origin = position(context);\n if (gesture || state.disabled || state.axis === \"lock\" || !origin || !context.get(\"bounds\") || (event.pointerType === \"mouse\" && event.button !== 0)) return;\n cancelledPointer = null;\n win.clearTimeout(release);\n refs.set(\"suppressClick\", false);\n gesture = { id: event.pointerId, x: event.clientX, y: event.clientY, origin, dragging: false };\n // Capture before the slop threshold: a fast first move can already land\n // outside this small button, including outside a scaled preview iframe.\n try { root.setPointerCapture?.(event.pointerId); } catch { /* document listeners remain the fallback */ }\n };\n const move = (event: PointerEvent) => {\n const bounds = context.get(\"bounds\");\n if (!gesture || event.pointerId !== gesture.id || !bounds) return;\n const axis = live(prop).axis, dx = axis === \"y\" ? 0 : event.clientX - gesture.x, dy = axis === \"x\" ? 0 : event.clientY - gesture.y;\n if (!gesture.dragging) {\n if (Math.max(Math.abs(event.clientX - gesture.x), Math.abs(event.clientY - gesture.y)) < GESTURE_SLOP) return;\n gesture.dragging = true;\n }\n send({ type: \"DRAG\", position: clampFloatingBubbleOffset({ x: gesture.origin.x + dx, y: gesture.origin.y + dy }, bounds) });\n };\n const finish = (event: Event) => {\n if (!gesture) return;\n const ended = gesture;\n // Clear first: releasing capture can synchronously deliver capture loss.\n gesture = null;\n if (ended.dragging) send({ type: \"RELEASE\" });\n if (ended.dragging || event.type !== \"pointerup\") {\n refs.set(\"suppressClick\", true);\n // Capture loss and blur can precede the physical release by multiple tasks.\n if (event.type === \"pointerup\") clearAfterRelease();\n else cancelledPointer = ended.id;\n }\n try { root.releasePointerCapture?.(ended.id); } catch { /* already released/cancelled */ }\n };\n const up = (event: PointerEvent) => {\n if (event.pointerId === gesture?.id) finish(event);\n else if (event.type === \"pointerup\" && event.pointerId === cancelledPointer) {\n cancelledPointer = null;\n clearAfterRelease();\n }\n };\n const Observer = win.ResizeObserver, observer = Observer ? new Observer(() => measure()) : null;\n const doc = root.ownerDocument;\n root.addEventListener(\"pointerdown\", down);\n root.addEventListener(\"lostpointercapture\", up);\n doc.addEventListener(\"pointermove\", move, true);\n doc.addEventListener(\"pointerup\", up, true);\n doc.addEventListener(\"pointercancel\", up, true);\n win.addEventListener(\"blur\", finish);\n win.addEventListener(\"resize\", measure);\n observer?.observe(root);\n const parent = live(prop).boundary === \"parent\" ? root.offsetParent : null;\n if (parent) observer?.observe(parent);\n measure();\n return () => {\n root.removeEventListener(\"pointerdown\", down); root.removeEventListener(\"lostpointercapture\", up);\n doc.removeEventListener(\"pointermove\", move, true); doc.removeEventListener(\"pointerup\", up, true); doc.removeEventListener(\"pointercancel\", up, true);\n win.removeEventListener(\"blur\", finish);\n win.removeEventListener(\"resize\", measure); observer?.disconnect(); win.clearTimeout(release);\n const id = gesture?.id;\n gesture = null;\n if (id !== undefined) { try { root.releasePointerCapture?.(id); } catch { /* root was detached */ } }\n };\n },\n },\n },\n});\n\n/** Minimal event surface shared by React, Vue and native events. */\nexport interface FloatingBubbleDomEvent { readonly defaultPrevented: boolean; readonly key?: string; preventDefault?(): void; stopPropagation?(): void }\nexport type FloatingBubbleEventHandler = (event: FloatingBubbleDomEvent) => void;\ntype Handlers = FloatingBubbleEventHandler | readonly FloatingBubbleEventHandler[] | undefined;\n/** Caller onClick/onKeyDown run first (except the click swallowed after a drag); preventDefault() skips Core. */\nexport interface FloatingBubbleConnectOptions { onClick?: Handlers; onKeyDown?: Handlers }\nexport interface QwFloatingBubbleApi<T extends PropTypes = PropTypes> {\n label: string; dragging: boolean;\n /** Rendered position, or null before the first measurement (CSS logical fallback). */\n position: FloatingBubbleOffset | null;\n getRootProps(): T[\"button\"];\n}\nfunction run(handlers: Handlers, event: FloatingBubbleDomEvent): boolean {\n const list = typeof handlers === \"function\" ? [handlers] : handlers ?? [];\n for (const handler of list) if (typeof handler === \"function\") handler(event);\n return !event.defaultPrevented;\n}\nconst ARROWS = new Set([\"ArrowLeft\", \"ArrowRight\", \"ArrowUp\", \"ArrowDown\"]);\nexport function connectFloatingBubble<T extends PropTypes>(service: QwFloatingBubbleService, normalize: NormalizeProps<T>, options: FloatingBubbleConnectOptions = {}): QwFloatingBubbleApi<T> {\n const state = live(service.prop), { context, refs, send } = service, current = position(context), dragging = !!context.get(\"drag\");\n return {\n label: state.label, dragging, position: current,\n getRootProps: () => normalize.button({\n \"data-scope\": \"floating-bubble\", \"data-part\": \"root\", id: rootId(service.scope), type: \"button\", \"aria-label\": state.label, disabled: state.disabled || undefined,\n \"data-animate\": context.get(\"animate\") || undefined, \"data-boundary\": state.boundary, \"data-axis\": state.axis, \"data-dragging\": dragging || undefined, \"data-positioned\": current ? \"\" : undefined,\n style: current ? { \"--qw-floating-bubble-x\": `${current.x}px`, \"--qw-floating-bubble-y\": `${current.y}px` } : undefined,\n onClick(event: FloatingBubbleDomEvent) {\n if (refs.get(\"suppressClick\") && !(\"detail\" in event && event.detail === 0)) { refs.set(\"suppressClick\", false); event.preventDefault?.(); event.stopPropagation?.(); return; }\n run(options.onClick, event);\n },\n onKeyDown(event: FloatingBubbleDomEvent) {\n const key = event.key ?? \"\";\n if (!run(options.onKeyDown, event) || !ARROWS.has(key) || state.disabled || state.axis === \"lock\" || state.keyboardStep === 0) return;\n if ((state.axis === \"x\" && (key === \"ArrowUp\" || key === \"ArrowDown\")) || (state.axis === \"y\" && (key === \"ArrowLeft\" || key === \"ArrowRight\"))) return;\n event.preventDefault?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W,KAAK,KAAK,CAAC,OAAO,IAAI,GAAG,KAAK,MAAM,YAAY,MAAM,SAAS,UAAU,MAAM,iBAAiB,GAAG;IAC/H,IAAK,MAAM,SAAS,QAAQ,QAAQ,aAAa,QAAQ,gBAAkB,MAAM,SAAS,QAAQ,QAAQ,eAAe,QAAQ,eAAgB;IACjJ,MAAM,iBAAiB;IAAG,KAAK;KAAE,MAAM;KAAO;IAAI,CAAC;GACrD;EACF,CAAC;CACH;AACF"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { type Machine, type Service } from "@zag-js/core";
|
|
2
|
+
import type { NormalizeProps, PropTypes } from "@zag-js/types";
|
|
3
|
+
export declare const FLOATING_PANEL_PARTS: readonly ["root", "handle", "indicator", "content", "status"];
|
|
4
|
+
export declare const FLOATING_PANEL_BOUNDARIES: readonly ["viewport", "parent"];
|
|
5
|
+
export declare const FLOATING_PANEL_DEFAULT_ANCHORS: readonly number[];
|
|
6
|
+
export type FloatingPanelBoundary = (typeof FLOATING_PANEL_BOUNDARIES)[number];
|
|
7
|
+
export type FloatingPanelHeightReason = "drag" | "keyboard" | "api" | "resize";
|
|
8
|
+
export interface FloatingPanelHeightChangeDetails {
|
|
9
|
+
height: number;
|
|
10
|
+
reason: FloatingPanelHeightReason;
|
|
11
|
+
}
|
|
12
|
+
export interface QwFloatingPanelProps {
|
|
13
|
+
id?: string;
|
|
14
|
+
/** Required accessible name for the region and height slider. */
|
|
15
|
+
label: string;
|
|
16
|
+
/** Positive finite visible border-box heights in CSS px; sorted and deduplicated. */
|
|
17
|
+
anchors?: readonly number[];
|
|
18
|
+
/** Owner-controlled settled height; keeping the value rejects a request. */
|
|
19
|
+
height?: number;
|
|
20
|
+
/** Initial uncontrolled height, defaults to the smallest anchor. */
|
|
21
|
+
defaultHeight?: number;
|
|
22
|
+
onHeightChange?: (details: FloatingPanelHeightChangeDetails) => void;
|
|
23
|
+
/** Fixed to viewport, or absolute in a positioned parent. */
|
|
24
|
+
boundary?: FloatingPanelBoundary;
|
|
25
|
+
/** Allow content drag until expanded; native scrolling takes over at maximum. Default true. */
|
|
26
|
+
contentDraggable?: boolean;
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
dir?: "ltr" | "rtl";
|
|
29
|
+
/** Accessible height text; {height} is replaced by CSS px. Default "{height}px". */
|
|
30
|
+
heightTextTemplate?: string;
|
|
31
|
+
}
|
|
32
|
+
export declare function resolveFloatingPanelAnchors(anchors: readonly number[] | undefined, available?: number): number[];
|
|
33
|
+
/** Nearest anchor, ties choose the larger anchor. */
|
|
34
|
+
export declare function snapFloatingPanelHeight(height: number | undefined, anchors: readonly number[]): number;
|
|
35
|
+
export declare function createFloatingPanelProps(props: QwFloatingPanelProps): QwFloatingPanelProps;
|
|
36
|
+
export interface QwFloatingPanelSchema {
|
|
37
|
+
props: QwFloatingPanelProps;
|
|
38
|
+
context: {
|
|
39
|
+
height: number;
|
|
40
|
+
preview: number | null;
|
|
41
|
+
available: number | null;
|
|
42
|
+
announcement: string;
|
|
43
|
+
};
|
|
44
|
+
refs: {
|
|
45
|
+
cancelGesture: (() => void) | null;
|
|
46
|
+
};
|
|
47
|
+
state: "ready";
|
|
48
|
+
action: "preview" | "settle" | "cancel" | "measure" | "reconcile" | "announce";
|
|
49
|
+
effect: "track";
|
|
50
|
+
event: {
|
|
51
|
+
type: "PREVIEW";
|
|
52
|
+
height: number;
|
|
53
|
+
} | {
|
|
54
|
+
type: "SETTLE";
|
|
55
|
+
height: number;
|
|
56
|
+
reason: FloatingPanelHeightReason;
|
|
57
|
+
} | {
|
|
58
|
+
type: "CANCEL";
|
|
59
|
+
} | {
|
|
60
|
+
type: "MEASURE";
|
|
61
|
+
available: number;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export type QwFloatingPanelMachine = Machine<QwFloatingPanelSchema>;
|
|
65
|
+
export type QwFloatingPanelService = Service<QwFloatingPanelSchema>;
|
|
66
|
+
export declare const floatingPanelMachine: QwFloatingPanelMachine;
|
|
67
|
+
export interface QwFloatingPanelApi<T extends PropTypes = PropTypes> {
|
|
68
|
+
height: number;
|
|
69
|
+
anchors: number[];
|
|
70
|
+
dragging: boolean;
|
|
71
|
+
label: string;
|
|
72
|
+
announcement: string;
|
|
73
|
+
setHeight(height: number): void;
|
|
74
|
+
getRootProps(): T["element"];
|
|
75
|
+
getHandleProps(): T["element"];
|
|
76
|
+
getIndicatorProps(): T["element"];
|
|
77
|
+
getContentProps(): T["element"];
|
|
78
|
+
getStatusProps(): T["element"];
|
|
79
|
+
}
|
|
80
|
+
export declare function connectFloatingPanel<T extends PropTypes>(service: QwFloatingPanelService, normalize: NormalizeProps<T>): QwFloatingPanelApi<T>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { FLOATING_PANEL_PARTS, FLOATING_PANEL_BOUNDARIES, FLOATING_PANEL_DEFAULT_ANCHORS, createFloatingPanelProps, resolveFloatingPanelAnchors, snapFloatingPanelHeight, floatingPanelMachine, connectFloatingPanel } from "./floating-panel.js";
|
|
2
|
+
export type { FloatingPanelBoundary, FloatingPanelHeightReason, FloatingPanelHeightChangeDetails, QwFloatingPanelProps, QwFloatingPanelSchema, QwFloatingPanelMachine, QwFloatingPanelService, QwFloatingPanelApi } from "./floating-panel.js";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as createFloatingPanelProps, c as snapFloatingPanelHeight, i as connectFloatingPanel, n as FLOATING_PANEL_DEFAULT_ANCHORS, o as floatingPanelMachine, r as FLOATING_PANEL_PARTS, s as resolveFloatingPanelAnchors, t as FLOATING_PANEL_BOUNDARIES } from "../floating-panel-Cbm5njBJ.js";
|
|
2
|
+
export { FLOATING_PANEL_BOUNDARIES, FLOATING_PANEL_DEFAULT_ANCHORS, FLOATING_PANEL_PARTS, connectFloatingPanel, createFloatingPanelProps, floatingPanelMachine, resolveFloatingPanelAnchors, snapFloatingPanelHeight };
|