@qw-ui/core 0.3.0-next.40 → 0.3.0-next.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -37
- package/dist/action-sheet/action-sheet.d.ts +110 -0
- package/dist/action-sheet/index.d.ts +2 -0
- package/dist/action-sheet/index.js +2 -0
- package/dist/action-sheet-Cvcr1S_m.js +183 -0
- package/dist/action-sheet-Cvcr1S_m.js.map +1 -0
- package/dist/area-picker/area-picker.d.ts +113 -0
- package/dist/area-picker/index.d.ts +1 -0
- package/dist/area-picker/index.js +348 -0
- package/dist/area-picker/index.js.map +1 -0
- package/dist/aria-description-CimD2M_C.js +13 -0
- package/dist/aria-description-CimD2M_C.js.map +1 -0
- package/dist/aria-description.d.ts +2 -0
- package/dist/avatar/avatar-load.d.ts +76 -0
- package/dist/avatar/avatar.d.ts +22 -5
- package/dist/avatar/index.d.ts +1 -0
- package/dist/avatar/index.js +57 -18
- package/dist/avatar/index.js.map +1 -1
- package/dist/avatar-load-w9dq05oV.js +139 -0
- package/dist/avatar-load-w9dq05oV.js.map +1 -0
- package/dist/back-top/back-top.d.ts +77 -0
- package/dist/back-top/index.d.ts +1 -0
- package/dist/back-top/index.js +189 -0
- package/dist/back-top/index.js.map +1 -0
- package/dist/badge/badge.d.ts +9 -0
- package/dist/badge/index.js +14 -1
- package/dist/badge/index.js.map +1 -1
- package/dist/button/button.d.ts +13 -0
- package/dist/button/index.js +3 -5
- package/dist/button/index.js.map +1 -1
- package/dist/calendar/calendar.d.ts +100 -0
- package/dist/calendar/index.d.ts +1 -0
- package/dist/calendar/index.js +2 -0
- package/dist/calendar-CmpK3stz.js +363 -0
- package/dist/calendar-CmpK3stz.js.map +1 -0
- package/dist/card/card.d.ts +68 -0
- package/dist/card/index.d.ts +2 -0
- package/dist/card/index.js +2 -0
- package/dist/card-DRtWa6Cr.js +107 -0
- package/dist/card-DRtWa6Cr.js.map +1 -0
- package/dist/cascader/cascader.d.ts +115 -0
- package/dist/cascader/index.d.ts +1 -0
- package/dist/cascader/index.js +2 -0
- package/dist/cascader-D-xMjs7P.js +333 -0
- package/dist/cascader-D-xMjs7P.js.map +1 -0
- package/dist/cell/cell.d.ts +41 -0
- package/dist/cell/index.d.ts +1 -0
- package/dist/cell/index.js +43 -0
- package/dist/cell/index.js.map +1 -0
- package/dist/check-list/check-list.d.ts +78 -0
- package/dist/check-list/index.d.ts +2 -0
- package/dist/check-list/index.js +2 -0
- package/dist/check-list-BvZHQt5w.js +60 -0
- package/dist/check-list-BvZHQt5w.js.map +1 -0
- package/dist/checkbox/checkbox.d.ts +59 -0
- package/dist/checkbox/index.d.ts +2 -0
- package/dist/checkbox/index.js +2 -0
- package/dist/checkbox-BlndJrz5.js +127 -0
- package/dist/checkbox-BlndJrz5.js.map +1 -0
- package/dist/checkbox-group/checkbox-group.d.ts +86 -0
- package/dist/checkbox-group/index.d.ts +3 -0
- package/dist/checkbox-group/index.js +2 -0
- package/dist/checkbox-group-gGfsTv-e.js +223 -0
- package/dist/checkbox-group-gGfsTv-e.js.map +1 -0
- package/dist/choice-group-C4c9m0qe.js +373 -0
- package/dist/choice-group-C4c9m0qe.js.map +1 -0
- package/dist/circle/circle.d.ts +97 -0
- package/dist/circle/index.d.ts +1 -0
- package/dist/circle/index.js +119 -0
- package/dist/circle/index.js.map +1 -0
- package/dist/collapse/collapse.d.ts +98 -0
- package/dist/collapse/index.d.ts +2 -0
- package/dist/collapse/index.js +2 -0
- package/dist/collapse-B969h7-H.js +226 -0
- package/dist/collapse-B969h7-H.js.map +1 -0
- package/dist/countdown/countdown.d.ts +114 -0
- package/dist/countdown/index.d.ts +1 -0
- package/dist/countdown/index.js +309 -0
- package/dist/countdown/index.js.map +1 -0
- package/dist/date-picker/date-picker.d.ts +168 -0
- package/dist/date-picker/index.d.ts +1 -0
- package/dist/date-picker/index.js +401 -0
- package/dist/date-picker/index.js.map +1 -0
- package/dist/descriptions/descriptions.d.ts +69 -0
- package/dist/descriptions/index.d.ts +1 -0
- package/dist/descriptions/index.js +86 -0
- package/dist/descriptions/index.js.map +1 -0
- package/dist/dialog/dialog.d.ts +32 -3
- package/dist/dialog/index.js +58 -3
- package/dist/dialog/index.js.map +1 -1
- package/dist/divider/divider.d.ts +18 -2
- package/dist/divider/index.js +20 -2
- package/dist/divider/index.js.map +1 -1
- package/dist/dropdown/dropdown.d.ts +172 -0
- package/dist/dropdown/index.d.ts +2 -0
- package/dist/dropdown/index.js +467 -0
- package/dist/dropdown/index.js.map +1 -0
- package/dist/ellipsis/ellipsis-layout.d.ts +34 -0
- package/dist/ellipsis/ellipsis.d.ts +88 -0
- package/dist/ellipsis/index.d.ts +2 -0
- package/dist/ellipsis/index.js +320 -0
- package/dist/ellipsis/index.js.map +1 -0
- package/dist/empty/empty-illustration.d.ts +3 -0
- package/dist/empty/empty.d.ts +43 -1
- package/dist/empty/index.js +2 -21
- package/dist/empty-CAgyvhUI.js +166 -0
- package/dist/empty-CAgyvhUI.js.map +1 -0
- package/dist/field/field.d.ts +95 -0
- package/dist/field/index.d.ts +2 -0
- package/dist/field/index.js +2 -0
- package/dist/field-DMHGIMZF.js +241 -0
- package/dist/field-DMHGIMZF.js.map +1 -0
- package/dist/floating-bubble/floating-bubble.d.ts +116 -0
- package/dist/floating-bubble/index.d.ts +1 -0
- package/dist/floating-bubble/index.js +333 -0
- package/dist/floating-bubble/index.js.map +1 -0
- package/dist/floating-panel/floating-panel.d.ts +80 -0
- package/dist/floating-panel/index.d.ts +2 -0
- package/dist/floating-panel/index.js +2 -0
- package/dist/floating-panel-Cbm5njBJ.js +363 -0
- package/dist/floating-panel-Cbm5njBJ.js.map +1 -0
- package/dist/footer/footer.d.ts +94 -0
- package/dist/footer/index.d.ts +1 -0
- package/dist/footer/index.js +154 -0
- package/dist/footer/index.js.map +1 -0
- package/dist/form/connect.d.ts +6 -0
- package/dist/form/form.d.ts +100 -0
- package/dist/form/ids.d.ts +14 -0
- package/dist/form/index.d.ts +13 -0
- package/dist/form/index.js +3 -0
- package/dist/form/methods.d.ts +5 -0
- package/dist/form/model.d.ts +24 -0
- package/dist/form/native.d.ts +25 -0
- package/dist/form/rules.d.ts +40 -0
- package/dist/form/ssr.d.ts +7 -0
- package/dist/form/types.d.ts +150 -0
- package/dist/form-BAGkIEMY.js +1354 -0
- package/dist/form-BAGkIEMY.js.map +1 -0
- package/dist/format-BDUY0C_c.js +89 -0
- package/dist/format-BDUY0C_c.js.map +1 -0
- package/dist/gesture-_SRHIvBm.js +30 -0
- package/dist/gesture-_SRHIvBm.js.map +1 -0
- package/dist/grid/grid-item.d.ts +22 -0
- package/dist/grid/grid.d.ts +42 -0
- package/dist/grid/index.d.ts +2 -0
- package/dist/grid/index.js +73 -0
- package/dist/grid/index.js.map +1 -0
- package/dist/icon/icon.d.ts +37 -1
- package/dist/icon/identity.d.ts +3 -0
- package/dist/icon/index.js +2 -20
- package/dist/icon-Cgdbnk1u.js +77 -0
- package/dist/icon-Cgdbnk1u.js.map +1 -0
- package/dist/image/image-load.d.ts +24 -0
- package/dist/image/image.d.ts +45 -8
- package/dist/image/index.d.ts +1 -0
- package/dist/image/index.js +116 -14
- package/dist/image/index.js.map +1 -1
- package/dist/image-preview/image-preview.d.ts +124 -0
- package/dist/image-preview/index.d.ts +1 -0
- package/dist/image-preview/index.js +450 -0
- package/dist/image-preview/index.js.map +1 -0
- package/dist/index-bar/index-bar.d.ts +121 -0
- package/dist/index-bar/index.d.ts +1 -0
- package/dist/index-bar/index.js +386 -0
- package/dist/index-bar/index.js.map +1 -0
- package/dist/index.d.ts +107 -14
- package/dist/index.js +148 -14
- package/dist/index.js.map +1 -0
- package/dist/infinite-scroll/index.d.ts +1 -0
- package/dist/infinite-scroll/index.js +248 -0
- package/dist/infinite-scroll/index.js.map +1 -0
- package/dist/infinite-scroll/infinite-scroll.d.ts +95 -0
- package/dist/input/index.js +181 -22
- package/dist/input/index.js.map +1 -1
- package/dist/input/input.d.ts +44 -1
- package/dist/layer-IpFrl5--.js +414 -0
- package/dist/layer-IpFrl5--.js.map +1 -0
- package/dist/layout-BRSqi4AQ.js +43 -0
- package/dist/layout-BRSqi4AQ.js.map +1 -0
- package/dist/layout.d.ts +13 -0
- package/dist/list/index.d.ts +2 -0
- package/dist/list/index.js +2 -0
- package/dist/list/list.d.ts +30 -0
- package/dist/list-6-iz-Irh.js +28 -0
- package/dist/list-6-iz-Irh.js.map +1 -0
- package/dist/loading/index.js +45 -2
- package/dist/loading/index.js.map +1 -1
- package/dist/loading/loading.d.ts +45 -2
- package/dist/modal-dialog-machine-CF9_z3Dm.js +487 -0
- package/dist/modal-dialog-machine-CF9_z3Dm.js.map +1 -0
- package/dist/modal-dialog-machine.d.ts +21 -0
- package/dist/modal-dismissable-lifetime.d.ts +21 -0
- package/dist/modal-registry.d.ts +24 -0
- package/dist/modal-render-hydration.d.ts +35 -0
- package/dist/modal-render-runtime.d.ts +19 -0
- package/dist/modal-render-scope.d.ts +63 -0
- package/dist/nav-bar/index.d.ts +1 -0
- package/dist/nav-bar/index.js +115 -0
- package/dist/nav-bar/index.js.map +1 -0
- package/dist/nav-bar/nav-bar.d.ts +76 -0
- package/dist/notice-bar/index.d.ts +2 -0
- package/dist/notice-bar/index.js +2 -0
- package/dist/notice-bar/notice-bar.d.ts +103 -0
- package/dist/notice-bar-DMpwLvRb.js +231 -0
- package/dist/notice-bar-DMpwLvRb.js.map +1 -0
- package/dist/notify/index.d.ts +1 -0
- package/dist/notify/index.js +251 -0
- package/dist/notify/index.js.map +1 -0
- package/dist/notify/notify.d.ts +123 -0
- package/dist/number-keyboard/index.d.ts +1 -0
- package/dist/number-keyboard/index.js +333 -0
- package/dist/number-keyboard/index.js.map +1 -0
- package/dist/number-keyboard/number-keyboard.d.ts +141 -0
- package/dist/page-indicator/index.d.ts +1 -0
- package/dist/page-indicator/index.js +138 -0
- package/dist/page-indicator/index.js.map +1 -0
- package/dist/page-indicator/page-indicator.d.ts +93 -0
- package/dist/pagination/index.d.ts +1 -0
- package/dist/pagination/index.js +198 -0
- package/dist/pagination/index.js.map +1 -0
- package/dist/pagination/pagination.d.ts +125 -0
- package/dist/password-input/index.d.ts +1 -0
- package/dist/password-input/index.js +317 -0
- package/dist/password-input/index.js.map +1 -0
- package/dist/password-input/password-input.d.ts +144 -0
- package/dist/picker/index.d.ts +8 -0
- package/dist/picker/index.js +2 -0
- package/dist/picker/picker-machine.d.ts +80 -0
- package/dist/picker/picker.d.ts +121 -0
- package/dist/picker/platform.d.ts +84 -0
- package/dist/picker/selection-connect.d.ts +90 -0
- package/dist/picker/selection-model.d.ts +211 -0
- package/dist/picker-BykFntQN.js +1675 -0
- package/dist/picker-BykFntQN.js.map +1 -0
- package/dist/popover/index.d.ts +3 -0
- package/dist/popover/index.js +253 -0
- package/dist/popover/index.js.map +1 -0
- package/dist/popover/layer.d.ts +44 -0
- package/dist/popover/popover.d.ts +104 -0
- package/dist/popover/positioning.d.ts +132 -0
- package/dist/popup/index.d.ts +2 -0
- package/dist/popup/index.js +2 -0
- package/dist/popup/popup.d.ts +60 -0
- package/dist/popup-z5d8IYCt.js +576 -0
- package/dist/popup-z5d8IYCt.js.map +1 -0
- package/dist/portal-BHCNTWhg.js +78 -0
- package/dist/portal-BHCNTWhg.js.map +1 -0
- package/dist/portal.d.ts +61 -0
- package/dist/price/format.d.ts +19 -0
- package/dist/price/index.d.ts +1 -0
- package/dist/price/index.js +154 -0
- package/dist/price/index.js.map +1 -0
- package/dist/price/price.d.ts +88 -0
- package/dist/progress/index.d.ts +1 -0
- package/dist/progress/index.js +2 -0
- package/dist/progress/progress.d.ts +32 -0
- package/dist/progress-f3iYEfdA.js +37 -0
- package/dist/progress-f3iYEfdA.js.map +1 -0
- package/dist/pull-refresh/index.d.ts +1 -0
- package/dist/pull-refresh/index.js +414 -0
- package/dist/pull-refresh/index.js.map +1 -0
- package/dist/pull-refresh/pull-refresh.d.ts +118 -0
- package/dist/radio-group/index.d.ts +3 -0
- package/dist/radio-group/index.js +2 -0
- package/dist/radio-group/radio-group.d.ts +78 -0
- package/dist/radio-group-BOIMuqnS.js +230 -0
- package/dist/radio-group-BOIMuqnS.js.map +1 -0
- package/dist/rate/index.d.ts +1 -0
- package/dist/rate/index.js +2 -0
- package/dist/rate/rate-form.d.ts +28 -0
- package/dist/rate/rate.d.ts +144 -0
- package/dist/rate-5XsU2QkY.js +631 -0
- package/dist/rate-5XsU2QkY.js.map +1 -0
- package/dist/reorder/index.d.ts +1 -0
- package/dist/reorder/index.js +720 -0
- package/dist/reorder/index.js.map +1 -0
- package/dist/reorder/reorder.d.ts +190 -0
- package/dist/result/index.d.ts +1 -0
- package/dist/result/index.js +123 -0
- package/dist/result/index.js.map +1 -0
- package/dist/result/result.d.ts +88 -0
- package/dist/safe-area/index.d.ts +1 -0
- package/dist/safe-area/index.js +42 -0
- package/dist/safe-area/index.js.map +1 -0
- package/dist/safe-area/safe-area.d.ts +28 -0
- package/dist/search-bar/index.js +3 -1
- package/dist/search-bar/index.js.map +1 -1
- package/dist/search-bar/search-bar.d.ts +4 -0
- package/dist/segmented/index.d.ts +2 -0
- package/dist/segmented/index.js +2 -0
- package/dist/segmented/segmented.d.ts +127 -0
- package/dist/segmented-BaU38_L4.js +367 -0
- package/dist/segmented-BaU38_L4.js.map +1 -0
- package/dist/selection-form-BOM_odUk.js +88 -0
- package/dist/selection-form-BOM_odUk.js.map +1 -0
- package/dist/selection-form.d.ts +27 -0
- package/dist/selection-ivXqO1eu.js +55 -0
- package/dist/selection-ivXqO1eu.js.map +1 -0
- package/dist/selection.d.ts +29 -0
- package/dist/selector/choice-group.d.ts +114 -0
- package/dist/selector/index.d.ts +2 -0
- package/dist/selector/index.js +2 -0
- package/dist/selector/selector.d.ts +90 -0
- package/dist/selector-BU2MMJ4N.js +93 -0
- package/dist/selector-BU2MMJ4N.js.map +1 -0
- package/dist/share-sheet/index.d.ts +1 -0
- package/dist/share-sheet/index.js +138 -0
- package/dist/share-sheet/index.js.map +1 -0
- package/dist/share-sheet/share-sheet.d.ts +139 -0
- package/dist/skeleton/index.js +51 -2
- package/dist/skeleton/index.js.map +1 -1
- package/dist/skeleton/skeleton.d.ts +34 -3
- package/dist/slider/index.d.ts +1 -0
- package/dist/slider/index.js +482 -0
- package/dist/slider/index.js.map +1 -0
- package/dist/slider/slider.d.ts +174 -0
- package/dist/space/index.d.ts +1 -0
- package/dist/space/index.js +52 -0
- package/dist/space/index.js.map +1 -0
- package/dist/space/space.d.ts +46 -0
- package/dist/statistic/index.d.ts +1 -0
- package/dist/statistic/index.js +152 -0
- package/dist/statistic/index.js.map +1 -0
- package/dist/statistic/statistic.d.ts +101 -0
- package/dist/stepper/index.js +62 -3
- package/dist/stepper/index.js.map +1 -1
- package/dist/stepper/stepper.d.ts +44 -4
- package/dist/steps/index.d.ts +1 -0
- package/dist/steps/index.js +72 -0
- package/dist/steps/index.js.map +1 -0
- package/dist/steps/steps.d.ts +67 -0
- package/dist/sticky/index.d.ts +1 -0
- package/dist/sticky/index.js +145 -0
- package/dist/sticky/index.js.map +1 -0
- package/dist/sticky/sticky.d.ts +70 -0
- package/dist/swipe-action/index.d.ts +1 -0
- package/dist/swipe-action/index.js +417 -0
- package/dist/swipe-action/index.js.map +1 -0
- package/dist/swipe-action/swipe-action.d.ts +148 -0
- package/dist/swiper/gesture.d.ts +32 -0
- package/dist/swiper/index.d.ts +1 -0
- package/dist/swiper/index.js +2 -0
- package/dist/swiper/swiper.d.ts +177 -0
- package/dist/swiper-BKivDkHp.js +550 -0
- package/dist/swiper-BKivDkHp.js.map +1 -0
- package/dist/switch/index.js +135 -10
- package/dist/switch/index.js.map +1 -1
- package/dist/switch/switch.d.ts +93 -6
- package/dist/tabbar/index.js +46 -1
- package/dist/tabbar/index.js.map +1 -1
- package/dist/tabbar/tabbar.d.ts +50 -0
- package/dist/tabs/index.js +22 -1
- package/dist/tabs/index.js.map +1 -1
- package/dist/tabs/tabs.d.ts +12 -8
- package/dist/tag/index.js +123 -2
- package/dist/tag/index.js.map +1 -1
- package/dist/tag/tag.d.ts +67 -1
- package/dist/textarea/index.d.ts +2 -0
- package/dist/textarea/index.js +2 -242
- package/dist/textarea/platform.d.ts +22 -0
- package/dist/textarea/textarea.d.ts +165 -46
- package/dist/textarea-qbnruDUG.js +775 -0
- package/dist/textarea-qbnruDUG.js.map +1 -0
- package/dist/time-picker/index.d.ts +1 -0
- package/dist/time-picker/index.js +228 -0
- package/dist/time-picker/index.js.map +1 -0
- package/dist/time-picker/time-picker.d.ts +83 -0
- package/dist/timeline/index.d.ts +1 -0
- package/dist/timeline/index.js +131 -0
- package/dist/timeline/index.js.map +1 -0
- package/dist/timeline/timeline.d.ts +79 -0
- package/dist/toast/index.js +47 -4
- package/dist/toast/index.js.map +1 -1
- package/dist/toast/toast.d.ts +26 -3
- package/dist/top-bar/index.js +16 -2
- package/dist/top-bar/index.js.map +1 -1
- package/dist/top-bar/top-bar.d.ts +13 -2
- package/dist/tree-select/index.d.ts +1 -0
- package/dist/tree-select/index.js +512 -0
- package/dist/tree-select/index.js.map +1 -0
- package/dist/tree-select/tree-select.d.ts +215 -0
- package/dist/typography/index.d.ts +1 -0
- package/dist/typography/index.js +82 -0
- package/dist/typography/index.js.map +1 -0
- package/dist/typography/typography.d.ts +54 -0
- package/dist/upload/index.d.ts +1 -0
- package/dist/upload/index.js +458 -0
- package/dist/upload/index.js.map +1 -0
- package/dist/upload/upload.d.ts +172 -0
- package/dist/virtual-list/index.d.ts +1 -0
- package/dist/virtual-list/index.js +445 -0
- package/dist/virtual-list/index.js.map +1 -0
- package/dist/virtual-list/virtual-list.d.ts +160 -0
- package/dist/visual-manifest.d.ts +6 -0
- package/dist/watermark/index.d.ts +1 -0
- package/dist/watermark/index.js +260 -0
- package/dist/watermark/index.js.map +1 -0
- package/dist/watermark/watermark.d.ts +106 -0
- package/package.json +399 -50
- package/dist/empty/index.js.map +0 -1
- package/dist/icon/index.js.map +0 -1
- package/dist/textarea/index.js.map +0 -1
|
@@ -0,0 +1,631 @@
|
|
|
1
|
+
import { a as resolveIconName, o as resolveIconState } from "./icon-Cgdbnk1u.js";
|
|
2
|
+
import { createMachine } from "@zag-js/core";
|
|
3
|
+
import { addDomEvent, dataAttr, getAncestorElements, getComputedStyle, getEventKey, getEventPoint, getNodeName, isHTMLElement, isInputElement, observeAttributes, observeChildren, setProperty, visuallyHiddenStyle } from "@zag-js/dom-query";
|
|
4
|
+
//#region src/rate/rate-form.ts
|
|
5
|
+
/**
|
|
6
|
+
* The value content attribute and the value property are the same effective form string.
|
|
7
|
+
* HTML reset reads that attribute, so defaultValue must not be a different initial string.
|
|
8
|
+
* A connected reset still requests the declared default through onReset, then syncs again.
|
|
9
|
+
* Read-only is intentionally not copied onto the proxy.
|
|
10
|
+
*/
|
|
11
|
+
function syncRateInput(options) {
|
|
12
|
+
const input = options.scope.getById(options.inputId);
|
|
13
|
+
if (!isInputElement(input)) return;
|
|
14
|
+
const limits = options.constraints();
|
|
15
|
+
const current = options.current();
|
|
16
|
+
setProperty(input, "defaultValue", current);
|
|
17
|
+
setProperty(input, "value", current);
|
|
18
|
+
setProperty(input, "required", limits.required);
|
|
19
|
+
setProperty(input, "disabled", limits.disabled);
|
|
20
|
+
setProperty(input, "min", limits.min);
|
|
21
|
+
setProperty(input, "max", limits.max);
|
|
22
|
+
setProperty(input, "step", limits.step);
|
|
23
|
+
}
|
|
24
|
+
/** Actual form ownership, cancellation and native fieldset disabled rules are tracked in Core. */
|
|
25
|
+
function trackRateForm(options) {
|
|
26
|
+
let stopped = false, queued = false, lastDisabled;
|
|
27
|
+
const cleanups = [], pending = /* @__PURE__ */ new Set();
|
|
28
|
+
const release = () => {
|
|
29
|
+
cleanups.splice(0).forEach((cleanup) => cleanup());
|
|
30
|
+
};
|
|
31
|
+
const sync = () => {
|
|
32
|
+
if (!stopped) syncRateInput(options);
|
|
33
|
+
};
|
|
34
|
+
const refreshSoon = () => {
|
|
35
|
+
if (stopped || queued) return;
|
|
36
|
+
queued = true;
|
|
37
|
+
queueMicrotask(() => {
|
|
38
|
+
queued = false;
|
|
39
|
+
refresh();
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
function refresh() {
|
|
43
|
+
if (stopped) return;
|
|
44
|
+
release();
|
|
45
|
+
const input = options.scope.getById(options.inputId), root = options.scope.getById(options.rootId);
|
|
46
|
+
if (!isInputElement(input)) return;
|
|
47
|
+
const disabled = input.matches(":disabled");
|
|
48
|
+
if (disabled !== lastDisabled) {
|
|
49
|
+
lastDisabled = disabled;
|
|
50
|
+
options.onDisabledChange(disabled);
|
|
51
|
+
}
|
|
52
|
+
if (input.form && getNodeName(input.form) === "form") cleanups.push(addDomEvent(input.form, "reset", (event) => {
|
|
53
|
+
const timer = setTimeout(() => {
|
|
54
|
+
pending.delete(timer);
|
|
55
|
+
if (stopped || event.defaultPrevented) return;
|
|
56
|
+
options.onReset();
|
|
57
|
+
sync();
|
|
58
|
+
}, 0);
|
|
59
|
+
pending.add(timer);
|
|
60
|
+
}));
|
|
61
|
+
for (const node of getAncestorElements(input).filter(isHTMLElement)) if (getNodeName(node) === "fieldset") cleanups.push(observeAttributes(node, {
|
|
62
|
+
attributes: ["disabled"],
|
|
63
|
+
callback: refreshSoon
|
|
64
|
+
}));
|
|
65
|
+
cleanups.push(observeAttributes(input, {
|
|
66
|
+
attributes: [
|
|
67
|
+
"disabled",
|
|
68
|
+
"form",
|
|
69
|
+
"name",
|
|
70
|
+
"required"
|
|
71
|
+
],
|
|
72
|
+
callback: refreshSoon
|
|
73
|
+
}));
|
|
74
|
+
const Observer = input.ownerDocument.defaultView?.MutationObserver;
|
|
75
|
+
if (Observer) {
|
|
76
|
+
const observer = new Observer(refreshSoon);
|
|
77
|
+
for (const node of getAncestorElements(input).filter(isHTMLElement)) observer.observe(node, { childList: true });
|
|
78
|
+
cleanups.push(() => observer.disconnect());
|
|
79
|
+
}
|
|
80
|
+
if (isHTMLElement(root)) cleanups.push(observeChildren(root, { callback: refreshSoon }));
|
|
81
|
+
sync();
|
|
82
|
+
}
|
|
83
|
+
refresh();
|
|
84
|
+
return () => {
|
|
85
|
+
stopped = true;
|
|
86
|
+
release();
|
|
87
|
+
pending.forEach(clearTimeout);
|
|
88
|
+
pending.clear();
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region src/rate/rate.ts
|
|
93
|
+
const RATE_SIZES = [
|
|
94
|
+
"sm",
|
|
95
|
+
"md",
|
|
96
|
+
"lg"
|
|
97
|
+
];
|
|
98
|
+
const RATE_PARTS = [
|
|
99
|
+
"root",
|
|
100
|
+
"label",
|
|
101
|
+
"description",
|
|
102
|
+
"control",
|
|
103
|
+
"item",
|
|
104
|
+
"empty-icon",
|
|
105
|
+
"filled-icon",
|
|
106
|
+
"input",
|
|
107
|
+
"clear",
|
|
108
|
+
"content"
|
|
109
|
+
];
|
|
110
|
+
function normalizeRateCount(count) {
|
|
111
|
+
return typeof count === "number" && Number.isSafeInteger(count) && count >= 1 && count <= 1e3 ? count : 5;
|
|
112
|
+
}
|
|
113
|
+
const rawValue = (value) => typeof value === "number" && Number.isFinite(value) ? Math.max(0, value) : 0;
|
|
114
|
+
function normalizeRateValue(value, count = 5, allowHalf = false, readOnly = false) {
|
|
115
|
+
const bounded = Math.min(normalizeRateCount(count), rawValue(value));
|
|
116
|
+
return readOnly ? bounded : Math.round(bounded * (allowHalf ? 2 : 1)) / (allowHalf ? 2 : 1);
|
|
117
|
+
}
|
|
118
|
+
/** Logical item geometry includes gaps; midpoint and gap ties prefer the preceding half/item. */
|
|
119
|
+
function getRatePointValue(x, rects, allowHalf, dir) {
|
|
120
|
+
if (!Number.isFinite(x)) return null;
|
|
121
|
+
const items = rects.filter((rect) => Number.isFinite(rect.left) && Number.isFinite(rect.right) && rect.right > rect.left).slice().sort((a, b) => dir === "rtl" ? b.right - a.right : a.left - b.left);
|
|
122
|
+
if (!items.length) return null;
|
|
123
|
+
if (dir === "rtl" ? x > items[0].right : x < items[0].left) return 0;
|
|
124
|
+
if (dir === "rtl" ? x < items.at(-1).left : x > items.at(-1).right) return items.length;
|
|
125
|
+
let index = 0, distance = Infinity;
|
|
126
|
+
for (const [i, item] of items.entries()) {
|
|
127
|
+
const next = x < item.left ? item.left - x : x > item.right ? x - item.right : 0;
|
|
128
|
+
if (next < distance) {
|
|
129
|
+
index = i;
|
|
130
|
+
distance = next;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const item = items[index], half = dir === "rtl" ? x >= (item.left + item.right) / 2 : x <= (item.left + item.right) / 2;
|
|
134
|
+
return index + (allowHalf && half ? .5 : 1);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Width of the touch target, measured from its inline start, that reaches `fill` of a centered glyph.
|
|
138
|
+
* Half often matches by centering; other fractions do not. Rendering must clip the glyph box instead.
|
|
139
|
+
*/
|
|
140
|
+
function rateTouchCoverageForGlyphFill(fill, touch, glyph) {
|
|
141
|
+
if (!Number.isFinite(fill) || !Number.isFinite(touch) || !Number.isFinite(glyph) || !(touch > 0) || glyph < 0 || glyph > touch) throw new RangeError("Rate glyph box must fit inside its touch target");
|
|
142
|
+
const clamped = Math.min(1, Math.max(0, fill));
|
|
143
|
+
return ((touch - glyph) / 2 + clamped * glyph) / touch;
|
|
144
|
+
}
|
|
145
|
+
function createRateProps(props) {
|
|
146
|
+
if (typeof props.label !== "string" || !props.label.trim()) throw new TypeError("Rate requires a nonempty accessible label");
|
|
147
|
+
if (props.id !== void 0 && (typeof props.id !== "string" || !props.id.trim())) throw new TypeError("Rate requires a nonempty instance id when provided");
|
|
148
|
+
return {
|
|
149
|
+
...props,
|
|
150
|
+
count: normalizeRateCount(props.count),
|
|
151
|
+
value: props.value === void 0 ? void 0 : rawValue(props.value),
|
|
152
|
+
defaultValue: rawValue(props.defaultValue),
|
|
153
|
+
allowHalf: props.allowHalf ?? false,
|
|
154
|
+
allowClear: props.allowClear ?? true,
|
|
155
|
+
touchable: props.touchable ?? true,
|
|
156
|
+
size: RATE_SIZES.includes(props.size) ? props.size : "md",
|
|
157
|
+
iconName: resolveIconName(props.iconName ?? "star-fill"),
|
|
158
|
+
emptyIconName: resolveIconName(props.emptyIconName ?? "star"),
|
|
159
|
+
valueTextTemplate: props.valueTextTemplate?.trim() ? props.valueTextTemplate : "{value} / {count}",
|
|
160
|
+
clearLabel: props.clearLabel?.trim() ? props.clearLabel : "清除评分"
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
function prefix(id) {
|
|
164
|
+
return `qw-rate-${id.split("").map((char) => char.charCodeAt(0).toString(16).padStart(4, "0")).join("")}`;
|
|
165
|
+
}
|
|
166
|
+
const rootId = (scope) => {
|
|
167
|
+
if (!scope.id?.trim()) throw new TypeError("Rate requires a nonempty stable id");
|
|
168
|
+
return prefix(scope.id);
|
|
169
|
+
};
|
|
170
|
+
const inputId = (scope) => `${rootId(scope)}-input`;
|
|
171
|
+
const controlId = (scope) => `${rootId(scope)}-control`;
|
|
172
|
+
const effective = (params, value = params.context.get("value")) => normalizeRateValue(value, params.prop("count"), params.prop("allowHalf"), params.prop("readOnly"));
|
|
173
|
+
const locked = (params) => !!params.prop("disabled") || params.context.get("inheritedDisabled") || !!params.prop("readOnly");
|
|
174
|
+
const formValue = (params, value) => params.prop("required") && value === 0 ? "" : String(value);
|
|
175
|
+
const glyphFill = (value) => Math.round(Math.max(0, Math.min(1, value)) * 1e6) / 1e6;
|
|
176
|
+
const constraints = (params) => ({
|
|
177
|
+
required: !!params.prop("required"),
|
|
178
|
+
disabled: !!params.prop("disabled"),
|
|
179
|
+
min: "0",
|
|
180
|
+
max: String(params.prop("count")),
|
|
181
|
+
step: params.prop("readOnly") ? "any" : params.prop("allowHalf") ? "0.5" : "1"
|
|
182
|
+
});
|
|
183
|
+
const sync = (params) => {
|
|
184
|
+
syncRateInput({
|
|
185
|
+
scope: params.scope,
|
|
186
|
+
inputId: inputId(params.scope),
|
|
187
|
+
current: () => formValue(params, effective(params)),
|
|
188
|
+
initial: () => formValue(params, effective(params, params.prop("defaultValue"))),
|
|
189
|
+
constraints: () => constraints(params)
|
|
190
|
+
});
|
|
191
|
+
if (!params.context.get("validationError")) return;
|
|
192
|
+
const input = params.scope.getById(inputId(params.scope));
|
|
193
|
+
if (!isInputElement(input) || input.matches(":disabled") || input.validity.valid) params.context.set("validationError", false);
|
|
194
|
+
};
|
|
195
|
+
const clearPreview = (params) => {
|
|
196
|
+
params.context.set("previewValue", null);
|
|
197
|
+
params.context.set("pointerId", null);
|
|
198
|
+
params.context.set("moved", false);
|
|
199
|
+
};
|
|
200
|
+
/** One bindable owns raw models; mode/domain changes derive values without fake change callbacks. */
|
|
201
|
+
const rateMachine = createMachine({
|
|
202
|
+
props: ({ props }) => createRateProps({
|
|
203
|
+
...props,
|
|
204
|
+
label: props.label ?? ""
|
|
205
|
+
}),
|
|
206
|
+
initialState: () => "ready",
|
|
207
|
+
context({ prop, bindable }) {
|
|
208
|
+
return {
|
|
209
|
+
value: bindable(() => ({
|
|
210
|
+
defaultValue: prop("defaultValue"),
|
|
211
|
+
value: prop("value"),
|
|
212
|
+
onChange: (value) => prop("onValueChange")?.({ value })
|
|
213
|
+
})),
|
|
214
|
+
previewValue: bindable(() => ({
|
|
215
|
+
defaultValue: null,
|
|
216
|
+
onChange: (value) => prop("onPreviewChange")?.({ value })
|
|
217
|
+
})),
|
|
218
|
+
focused: bindable(() => ({ defaultValue: false })),
|
|
219
|
+
pointerId: bindable(() => ({ defaultValue: null })),
|
|
220
|
+
startX: bindable(() => ({ defaultValue: 0 })),
|
|
221
|
+
startY: bindable(() => ({ defaultValue: 0 })),
|
|
222
|
+
moved: bindable(() => ({ defaultValue: false })),
|
|
223
|
+
inheritedDisabled: bindable(() => ({ defaultValue: false })),
|
|
224
|
+
validationError: bindable(() => ({ defaultValue: false }))
|
|
225
|
+
};
|
|
226
|
+
},
|
|
227
|
+
watch({ track, context, prop, action, send }) {
|
|
228
|
+
track([() => context.hash("value")], () => {
|
|
229
|
+
context.set("validationError", false);
|
|
230
|
+
action(["syncInput"]);
|
|
231
|
+
});
|
|
232
|
+
track([
|
|
233
|
+
() => prop("count"),
|
|
234
|
+
() => prop("allowHalf"),
|
|
235
|
+
() => prop("readOnly"),
|
|
236
|
+
() => prop("disabled"),
|
|
237
|
+
() => prop("required"),
|
|
238
|
+
() => prop("defaultValue")
|
|
239
|
+
], () => send({ type: "DOMAIN.CHANGED" }));
|
|
240
|
+
},
|
|
241
|
+
effects: ["trackForm"],
|
|
242
|
+
on: {
|
|
243
|
+
"VALUE.SET": { actions: ["setValue", "syncInput"] },
|
|
244
|
+
"PREVIEW.SET": { actions: ["setPreview"] },
|
|
245
|
+
"FOCUS.SET": { actions: ["setFocus"] },
|
|
246
|
+
"DISABLED.SET": { actions: ["setDisabled"] },
|
|
247
|
+
"FORM.RESET": {
|
|
248
|
+
target: "ready",
|
|
249
|
+
actions: [
|
|
250
|
+
"resetForm",
|
|
251
|
+
"cancelPointer",
|
|
252
|
+
"syncInput"
|
|
253
|
+
]
|
|
254
|
+
},
|
|
255
|
+
"INVALID": { actions: ["markInvalid"] },
|
|
256
|
+
"DOMAIN.CHANGED": {
|
|
257
|
+
target: "ready",
|
|
258
|
+
actions: ["cancelPointer", "syncInput"]
|
|
259
|
+
},
|
|
260
|
+
"POINTER.CANCEL": {
|
|
261
|
+
guard: ({ event, context }) => event.type === "POINTER.CANCEL" && (event.pointerId === void 0 || event.pointerId === context.get("pointerId") || context.get("pointerId") == null && !event.captureLost),
|
|
262
|
+
target: "ready",
|
|
263
|
+
actions: ["cancelPointer"]
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
states: {
|
|
267
|
+
ready: { on: { "POINTER.START": {
|
|
268
|
+
guard: "canInteract",
|
|
269
|
+
target: "dragging",
|
|
270
|
+
actions: ["startPointer"]
|
|
271
|
+
} } },
|
|
272
|
+
dragging: {
|
|
273
|
+
effects: ["capturePointer"],
|
|
274
|
+
on: {
|
|
275
|
+
"POINTER.MOVE": { actions: ["movePointer"] },
|
|
276
|
+
"POINTER.END": {
|
|
277
|
+
guard: ({ event, context }) => event.type === "POINTER.END" && event.pointerId === context.get("pointerId"),
|
|
278
|
+
target: "ready",
|
|
279
|
+
actions: ["commitPointer", "syncInput"]
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
implementations: {
|
|
285
|
+
guards: { canInteract: (params) => !locked(params) },
|
|
286
|
+
effects: {
|
|
287
|
+
trackForm(params) {
|
|
288
|
+
return trackRateForm({
|
|
289
|
+
scope: params.scope,
|
|
290
|
+
rootId: rootId(params.scope),
|
|
291
|
+
inputId: inputId(params.scope),
|
|
292
|
+
current: () => formValue(params, effective(params)),
|
|
293
|
+
initial: () => formValue(params, effective(params, params.prop("defaultValue"))),
|
|
294
|
+
constraints: () => constraints(params),
|
|
295
|
+
onReset: () => params.send({ type: "FORM.RESET" }),
|
|
296
|
+
onDisabledChange: (value) => params.send({
|
|
297
|
+
type: "DISABLED.SET",
|
|
298
|
+
value
|
|
299
|
+
})
|
|
300
|
+
});
|
|
301
|
+
},
|
|
302
|
+
capturePointer({ scope, context, event }) {
|
|
303
|
+
const target = scope.getById(controlId(scope)), id = event.type === "POINTER.START" ? event.pointerId : context.get("pointerId");
|
|
304
|
+
if (target && id !== null) try {
|
|
305
|
+
target.setPointerCapture?.(id);
|
|
306
|
+
} catch {}
|
|
307
|
+
return () => {
|
|
308
|
+
if (target && id !== null && target.hasPointerCapture?.(id)) try {
|
|
309
|
+
target.releasePointerCapture(id);
|
|
310
|
+
} catch {}
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
actions: {
|
|
315
|
+
syncInput: sync,
|
|
316
|
+
setValue(params) {
|
|
317
|
+
if (params.event.type !== "VALUE.SET" || locked(params)) return;
|
|
318
|
+
params.context.set("value", normalizeRateValue(params.event.value, params.prop("count"), params.prop("allowHalf")));
|
|
319
|
+
clearPreview(params);
|
|
320
|
+
},
|
|
321
|
+
setPreview(params) {
|
|
322
|
+
if (params.event.type !== "PREVIEW.SET" || locked(params)) return;
|
|
323
|
+
params.context.set("previewValue", params.event.value === null ? null : normalizeRateValue(params.event.value, params.prop("count"), params.prop("allowHalf")));
|
|
324
|
+
},
|
|
325
|
+
startPointer(params) {
|
|
326
|
+
if (params.event.type !== "POINTER.START" || locked(params)) return;
|
|
327
|
+
params.context.set("pointerId", params.event.pointerId);
|
|
328
|
+
params.context.set("startX", params.event.x);
|
|
329
|
+
params.context.set("startY", params.event.y);
|
|
330
|
+
params.context.set("moved", false);
|
|
331
|
+
params.context.set("previewValue", params.event.value);
|
|
332
|
+
},
|
|
333
|
+
movePointer(params) {
|
|
334
|
+
if (params.event.type !== "POINTER.MOVE" || params.event.pointerId !== params.context.get("pointerId") || locked(params)) return;
|
|
335
|
+
const dx = Math.abs(params.event.x - params.context.get("startX")), dy = Math.abs(params.event.y - params.context.get("startY"));
|
|
336
|
+
if (params.event.touch && dy > dx && dy > 8) {
|
|
337
|
+
params.send({ type: "POINTER.CANCEL" });
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
if (dx > 8 || dy > 8) params.context.set("moved", true);
|
|
341
|
+
params.context.set("previewValue", params.event.value);
|
|
342
|
+
},
|
|
343
|
+
commitPointer(params) {
|
|
344
|
+
if (params.event.type !== "POINTER.END" || params.event.pointerId !== params.context.get("pointerId") || locked(params)) {
|
|
345
|
+
clearPreview(params);
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
const value = !params.context.get("moved") && params.prop("allowClear") && params.event.value === effective(params) ? 0 : params.event.value;
|
|
349
|
+
params.context.set("value", value);
|
|
350
|
+
params.context.set("validationError", false);
|
|
351
|
+
clearPreview(params);
|
|
352
|
+
},
|
|
353
|
+
cancelPointer: clearPreview,
|
|
354
|
+
setFocus({ context, event }) {
|
|
355
|
+
if (event.type === "FOCUS.SET") context.set("focused", event.value);
|
|
356
|
+
},
|
|
357
|
+
setDisabled(params) {
|
|
358
|
+
if (params.event.type !== "DISABLED.SET") return;
|
|
359
|
+
params.context.set("inheritedDisabled", params.event.value);
|
|
360
|
+
if (params.event.value) params.send({ type: "POINTER.CANCEL" });
|
|
361
|
+
sync(params);
|
|
362
|
+
},
|
|
363
|
+
resetForm({ context, prop }) {
|
|
364
|
+
context.set("value", prop("defaultValue"));
|
|
365
|
+
context.set("validationError", false);
|
|
366
|
+
},
|
|
367
|
+
markInvalid({ context, scope }) {
|
|
368
|
+
context.set("validationError", true);
|
|
369
|
+
scope.getById(controlId(scope))?.focus();
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
function connect(service, normalize) {
|
|
375
|
+
const id = rootId(service.scope), value = service.context.get("value"), committed = effective(service), preview = service.context.get("previewValue"), displayed = preview ?? committed;
|
|
376
|
+
const disabled = !!service.prop("disabled") || service.context.get("inheritedDisabled"), readOnly = !!service.prop("readOnly"), invalid = !!service.prop("invalid") || service.context.get("validationError");
|
|
377
|
+
const parts = (part) => ({
|
|
378
|
+
"data-scope": "rate",
|
|
379
|
+
"data-part": part
|
|
380
|
+
});
|
|
381
|
+
const items = Array.from({ length: service.prop("count") }, (_, index) => {
|
|
382
|
+
const fill = glyphFill(displayed - index);
|
|
383
|
+
return {
|
|
384
|
+
index: index + 1,
|
|
385
|
+
fill,
|
|
386
|
+
state: fill === 0 ? "empty" : fill === 1 ? "full" : "half"
|
|
387
|
+
};
|
|
388
|
+
});
|
|
389
|
+
const item = (props) => {
|
|
390
|
+
const result = items[props.index - 1];
|
|
391
|
+
if (!result) throw new RangeError("Rate item is outside count");
|
|
392
|
+
return result;
|
|
393
|
+
};
|
|
394
|
+
const direction = (target) => {
|
|
395
|
+
const dir = service.prop("dir");
|
|
396
|
+
return dir === "rtl" || dir === "ltr" ? dir : getComputedStyle(target).direction === "rtl" ? "rtl" : "ltr";
|
|
397
|
+
};
|
|
398
|
+
const valueAt = (event) => {
|
|
399
|
+
const target = event.currentTarget, point = getEventPoint(event, "client");
|
|
400
|
+
const rects = items.map((entry) => service.scope.getById(`${id}-item-${entry.index}`)?.getBoundingClientRect()).filter((rect) => !!rect);
|
|
401
|
+
return {
|
|
402
|
+
...point,
|
|
403
|
+
value: getRatePointValue(point.x, rects, service.prop("allowHalf"), direction(target))
|
|
404
|
+
};
|
|
405
|
+
};
|
|
406
|
+
const blocked = () => {
|
|
407
|
+
const input = service.scope.getById(inputId(service.scope));
|
|
408
|
+
return disabled || readOnly || isInputElement(input) && input.matches(":disabled");
|
|
409
|
+
};
|
|
410
|
+
const pointerEvent = (type, event) => {
|
|
411
|
+
if (blocked() || event.defaultPrevented || event.isPrimary === false || event.pointerType === "touch" && !service.prop("touchable")) return;
|
|
412
|
+
const result = valueAt(event);
|
|
413
|
+
if (result.value === null) return;
|
|
414
|
+
service.send({
|
|
415
|
+
type,
|
|
416
|
+
pointerId: event.pointerId ?? 0,
|
|
417
|
+
...result,
|
|
418
|
+
value: result.value,
|
|
419
|
+
touch: event.pointerType === "touch"
|
|
420
|
+
});
|
|
421
|
+
};
|
|
422
|
+
return {
|
|
423
|
+
value,
|
|
424
|
+
effectiveValue: committed,
|
|
425
|
+
previewValue: preview,
|
|
426
|
+
displayValue: displayed,
|
|
427
|
+
label: service.prop("label"),
|
|
428
|
+
description: service.prop("description") ?? "",
|
|
429
|
+
clearLabel: service.prop("clearLabel"),
|
|
430
|
+
character: service.prop("character"),
|
|
431
|
+
items,
|
|
432
|
+
setValue: (value) => service.send({
|
|
433
|
+
type: "VALUE.SET",
|
|
434
|
+
value
|
|
435
|
+
}),
|
|
436
|
+
setPreviewValue: (value) => service.send({
|
|
437
|
+
type: "PREVIEW.SET",
|
|
438
|
+
value
|
|
439
|
+
}),
|
|
440
|
+
getRootProps: () => normalize.element({
|
|
441
|
+
...parts("root"),
|
|
442
|
+
id,
|
|
443
|
+
dir: service.prop("dir"),
|
|
444
|
+
"data-size": service.prop("size"),
|
|
445
|
+
"data-value": value,
|
|
446
|
+
"data-effective-value": committed,
|
|
447
|
+
"data-preview-value": preview ?? void 0,
|
|
448
|
+
"data-disabled": dataAttr(disabled),
|
|
449
|
+
"data-readonly": dataAttr(readOnly),
|
|
450
|
+
"data-invalid": dataAttr(invalid)
|
|
451
|
+
}),
|
|
452
|
+
getLabelProps: () => normalize.element({
|
|
453
|
+
...parts("label"),
|
|
454
|
+
id: `${id}-label`
|
|
455
|
+
}),
|
|
456
|
+
getDescriptionProps: () => normalize.element({
|
|
457
|
+
...parts("description"),
|
|
458
|
+
id: `${id}-description`,
|
|
459
|
+
hidden: !service.prop("description")
|
|
460
|
+
}),
|
|
461
|
+
getControlProps: () => normalize.element({
|
|
462
|
+
...parts("control"),
|
|
463
|
+
id: controlId(service.scope),
|
|
464
|
+
role: "slider",
|
|
465
|
+
tabIndex: disabled ? -1 : 0,
|
|
466
|
+
"aria-labelledby": `${id}-label`,
|
|
467
|
+
"aria-describedby": service.prop("description") ? `${id}-description` : void 0,
|
|
468
|
+
"aria-valuemin": 0,
|
|
469
|
+
"aria-valuemax": service.prop("count"),
|
|
470
|
+
"aria-valuenow": committed,
|
|
471
|
+
"aria-valuetext": service.prop("valueTextTemplate").replace(/\{value\}/g, String(committed)).replace(/\{count\}/g, String(service.prop("count"))),
|
|
472
|
+
"aria-disabled": disabled || void 0,
|
|
473
|
+
"aria-readonly": readOnly || void 0,
|
|
474
|
+
"aria-required": service.prop("required") || void 0,
|
|
475
|
+
"aria-invalid": invalid || void 0,
|
|
476
|
+
"aria-orientation": "horizontal",
|
|
477
|
+
onFocus() {
|
|
478
|
+
service.send({
|
|
479
|
+
type: "FOCUS.SET",
|
|
480
|
+
value: true
|
|
481
|
+
});
|
|
482
|
+
},
|
|
483
|
+
onBlur() {
|
|
484
|
+
service.send({
|
|
485
|
+
type: "FOCUS.SET",
|
|
486
|
+
value: false
|
|
487
|
+
});
|
|
488
|
+
service.send({ type: "POINTER.CANCEL" });
|
|
489
|
+
},
|
|
490
|
+
onKeyDown(event) {
|
|
491
|
+
if (event.defaultPrevented || event.ctrlKey || event.altKey || event.metaKey) return;
|
|
492
|
+
if (event.key === "Escape") {
|
|
493
|
+
service.send({ type: "POINTER.CANCEL" });
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
if (![
|
|
497
|
+
"ArrowLeft",
|
|
498
|
+
"ArrowRight",
|
|
499
|
+
"ArrowUp",
|
|
500
|
+
"ArrowDown",
|
|
501
|
+
"Home",
|
|
502
|
+
"End",
|
|
503
|
+
"PageUp",
|
|
504
|
+
"PageDown"
|
|
505
|
+
].includes(event.key)) return;
|
|
506
|
+
event.preventDefault();
|
|
507
|
+
if (blocked()) return;
|
|
508
|
+
const key = getEventKey(event, { dir: direction(event.currentTarget) }), step = service.prop("allowHalf") ? .5 : 1, page = Math.max(1, Math.floor(service.prop("count") / 5));
|
|
509
|
+
const next = key === "Home" ? 0 : key === "End" ? service.prop("count") : committed + (key === "PageUp" ? page : key === "PageDown" ? -page : key === "ArrowRight" || key === "ArrowUp" ? step : -step);
|
|
510
|
+
service.send({
|
|
511
|
+
type: "VALUE.SET",
|
|
512
|
+
value: next
|
|
513
|
+
});
|
|
514
|
+
},
|
|
515
|
+
onPointerDown(event) {
|
|
516
|
+
if (event.button !== 0 || blocked()) return;
|
|
517
|
+
event.currentTarget.focus();
|
|
518
|
+
pointerEvent("POINTER.START", event);
|
|
519
|
+
},
|
|
520
|
+
onPointerMove(event) {
|
|
521
|
+
if (service.context.get("pointerId") != null) pointerEvent("POINTER.MOVE", event);
|
|
522
|
+
else if (event.pointerType !== "touch" && !blocked()) {
|
|
523
|
+
const result = valueAt(event);
|
|
524
|
+
service.send({
|
|
525
|
+
type: "PREVIEW.SET",
|
|
526
|
+
value: result.value
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
},
|
|
530
|
+
onPointerUp(event) {
|
|
531
|
+
pointerEvent("POINTER.END", event);
|
|
532
|
+
},
|
|
533
|
+
onPointerCancel(event) {
|
|
534
|
+
service.send({
|
|
535
|
+
type: "POINTER.CANCEL",
|
|
536
|
+
pointerId: event.pointerId ?? 0
|
|
537
|
+
});
|
|
538
|
+
},
|
|
539
|
+
onLostPointerCapture(event) {
|
|
540
|
+
service.send({
|
|
541
|
+
type: "POINTER.CANCEL",
|
|
542
|
+
pointerId: event.pointerId ?? 0,
|
|
543
|
+
captureLost: true
|
|
544
|
+
});
|
|
545
|
+
},
|
|
546
|
+
onPointerLeave() {
|
|
547
|
+
if (service.context.get("pointerId") == null) service.send({
|
|
548
|
+
type: "PREVIEW.SET",
|
|
549
|
+
value: null
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
}),
|
|
553
|
+
getItemProps: (props) => {
|
|
554
|
+
const entry = item(props);
|
|
555
|
+
return normalize.element({
|
|
556
|
+
...parts("item"),
|
|
557
|
+
id: `${id}-item-${entry.index}`,
|
|
558
|
+
"data-index": entry.index,
|
|
559
|
+
"data-state": entry.state,
|
|
560
|
+
"aria-hidden": true
|
|
561
|
+
});
|
|
562
|
+
},
|
|
563
|
+
getEmptyIconProps: (props) => {
|
|
564
|
+
item(props);
|
|
565
|
+
return normalize.element({
|
|
566
|
+
...parts("empty-icon"),
|
|
567
|
+
"aria-hidden": true
|
|
568
|
+
});
|
|
569
|
+
},
|
|
570
|
+
getFilledIconProps: (props) => {
|
|
571
|
+
const entry = item(props);
|
|
572
|
+
return normalize.element({
|
|
573
|
+
...parts("filled-icon"),
|
|
574
|
+
"aria-hidden": true,
|
|
575
|
+
style: { "--qw-rate-fill": String(entry.fill) }
|
|
576
|
+
});
|
|
577
|
+
},
|
|
578
|
+
getItemIconState: (props, filled) => {
|
|
579
|
+
const entry = item(props);
|
|
580
|
+
return resolveIconState({
|
|
581
|
+
id: `${id}-${entry.index}-${filled ? "full" : "empty"}`,
|
|
582
|
+
name: filled ? service.prop("iconName") : service.prop("emptyIconName")
|
|
583
|
+
});
|
|
584
|
+
},
|
|
585
|
+
getInputProps: () => normalize.input({
|
|
586
|
+
...parts("input"),
|
|
587
|
+
id: inputId(service.scope),
|
|
588
|
+
type: "number",
|
|
589
|
+
name: service.prop("name"),
|
|
590
|
+
form: service.prop("form"),
|
|
591
|
+
value: formValue(service, committed),
|
|
592
|
+
min: 0,
|
|
593
|
+
max: service.prop("count"),
|
|
594
|
+
step: readOnly ? "any" : service.prop("allowHalf") ? .5 : 1,
|
|
595
|
+
required: !!service.prop("required"),
|
|
596
|
+
disabled: !!service.prop("disabled"),
|
|
597
|
+
tabIndex: -1,
|
|
598
|
+
"aria-hidden": true,
|
|
599
|
+
style: visuallyHiddenStyle,
|
|
600
|
+
onChange(event) {
|
|
601
|
+
if (!blocked()) service.send({
|
|
602
|
+
type: "VALUE.SET",
|
|
603
|
+
value: event.currentTarget.valueAsNumber
|
|
604
|
+
});
|
|
605
|
+
queueMicrotask(() => sync(service));
|
|
606
|
+
},
|
|
607
|
+
onInvalid(event) {
|
|
608
|
+
event.preventDefault();
|
|
609
|
+
service.send({ type: "INVALID" });
|
|
610
|
+
}
|
|
611
|
+
}),
|
|
612
|
+
getClearProps: () => normalize.button({
|
|
613
|
+
...parts("clear"),
|
|
614
|
+
type: "button",
|
|
615
|
+
hidden: !service.prop("allowClear") || readOnly || committed === 0,
|
|
616
|
+
disabled,
|
|
617
|
+
"aria-label": service.prop("clearLabel"),
|
|
618
|
+
onClick() {
|
|
619
|
+
service.send({
|
|
620
|
+
type: "VALUE.SET",
|
|
621
|
+
value: 0
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
}),
|
|
625
|
+
getContentProps: () => normalize.element(parts("content"))
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
//#endregion
|
|
629
|
+
export { getRatePointValue as a, rateMachine as c, createRateProps as i, rateTouchCoverageForGlyphFill as l, RATE_SIZES as n, normalizeRateCount as o, connect as r, normalizeRateValue as s, RATE_PARTS as t };
|
|
630
|
+
|
|
631
|
+
//# sourceMappingURL=rate-5XsU2QkY.js.map
|