@qw-ui/core 0.3.0-next.40 → 0.3.0-next.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -37
- package/dist/action-sheet/action-sheet.d.ts +110 -0
- package/dist/action-sheet/index.d.ts +2 -0
- package/dist/action-sheet/index.js +2 -0
- package/dist/action-sheet-Cvcr1S_m.js +183 -0
- package/dist/action-sheet-Cvcr1S_m.js.map +1 -0
- package/dist/area-picker/area-picker.d.ts +113 -0
- package/dist/area-picker/index.d.ts +1 -0
- package/dist/area-picker/index.js +348 -0
- package/dist/area-picker/index.js.map +1 -0
- package/dist/aria-description-CimD2M_C.js +13 -0
- package/dist/aria-description-CimD2M_C.js.map +1 -0
- package/dist/aria-description.d.ts +2 -0
- package/dist/avatar/avatar-load.d.ts +76 -0
- package/dist/avatar/avatar.d.ts +22 -5
- package/dist/avatar/index.d.ts +1 -0
- package/dist/avatar/index.js +57 -18
- package/dist/avatar/index.js.map +1 -1
- package/dist/avatar-load-w9dq05oV.js +139 -0
- package/dist/avatar-load-w9dq05oV.js.map +1 -0
- package/dist/back-top/back-top.d.ts +77 -0
- package/dist/back-top/index.d.ts +1 -0
- package/dist/back-top/index.js +189 -0
- package/dist/back-top/index.js.map +1 -0
- package/dist/badge/badge.d.ts +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,174 @@
|
|
|
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 SLIDER_PARTS: readonly ["root", "label", "control", "track", "range", "thumb", "input"];
|
|
5
|
+
export declare const SLIDER_ORIENTATIONS: readonly ["horizontal", "vertical"];
|
|
6
|
+
export type SliderPart = (typeof SLIDER_PARTS)[number];
|
|
7
|
+
export type SliderOrientation = (typeof SLIDER_ORIENTATIONS)[number];
|
|
8
|
+
/** A single slider reports a number; a range slider reports an ascending `[start, end]` tuple. */
|
|
9
|
+
export type SliderValue = number | readonly [number, number];
|
|
10
|
+
export interface SliderValueChangeDetails {
|
|
11
|
+
value: SliderValue;
|
|
12
|
+
}
|
|
13
|
+
/** SSR-safe input shared by all adapters (no @zag-js/slider dependency; the machine is qw-ui Core). */
|
|
14
|
+
export interface QwSliderProps {
|
|
15
|
+
/** Page-unique instance identity; adapters generate one when omitted. */
|
|
16
|
+
id?: string;
|
|
17
|
+
/** Required nonempty accessible name; visible unless `hideLabel`. */
|
|
18
|
+
label: string;
|
|
19
|
+
/** Keep the name for assistive technology but hide it visually. */
|
|
20
|
+
hideLabel?: boolean;
|
|
21
|
+
/** Two thumbs selecting `[start, end]`. */
|
|
22
|
+
range?: boolean;
|
|
23
|
+
/** Controlled value. Defined means the owner decides; requests go through onValueChange. */
|
|
24
|
+
value?: SliderValue;
|
|
25
|
+
/** Initial Core-owned value and the form-reset value; defaults to min (range: [min, max]). */
|
|
26
|
+
defaultValue?: SliderValue;
|
|
27
|
+
/** Finite lower bound, default 0. */
|
|
28
|
+
min?: number;
|
|
29
|
+
/** Finite upper bound greater than min, default min + 100. */
|
|
30
|
+
max?: number;
|
|
31
|
+
/** Positive finite step, default 1. Values snap to min + k·step; max itself is always reachable. */
|
|
32
|
+
step?: number;
|
|
33
|
+
/** PageUp/PageDown step, default max(step, one tenth of the span) snapped to step. */
|
|
34
|
+
pageStep?: number;
|
|
35
|
+
disabled?: boolean;
|
|
36
|
+
readOnly?: boolean;
|
|
37
|
+
orientation?: SliderOrientation;
|
|
38
|
+
/** Standard HTML direction; RTL mirrors horizontal pointer mapping and Arrow keys. */
|
|
39
|
+
dir?: string;
|
|
40
|
+
/** Submitted with each thumb's value (range: two entries with the same name). */
|
|
41
|
+
name?: string;
|
|
42
|
+
form?: string;
|
|
43
|
+
/** Range thumb names appended to `label`; default ["最小值", "最大值"]. */
|
|
44
|
+
thumbLabels?: readonly [string, string];
|
|
45
|
+
/** aria-valuetext with {value}; default "{value}". */
|
|
46
|
+
valueTextTemplate?: string;
|
|
47
|
+
/** Every requested change (pointer move, key, programmatic). */
|
|
48
|
+
onValueChange?: (details: SliderValueChangeDetails) => void;
|
|
49
|
+
/** End of an interaction: pointer release or a keyboard step. */
|
|
50
|
+
onValueCommit?: (details: SliderValueChangeDetails) => void;
|
|
51
|
+
}
|
|
52
|
+
export interface ResolvedSliderState {
|
|
53
|
+
min: number;
|
|
54
|
+
max: number;
|
|
55
|
+
step: number;
|
|
56
|
+
pageStep: number;
|
|
57
|
+
range: boolean;
|
|
58
|
+
orientation: SliderOrientation;
|
|
59
|
+
dir: string | undefined;
|
|
60
|
+
disabled: boolean;
|
|
61
|
+
readOnly: boolean;
|
|
62
|
+
thumbLabels: [string, string];
|
|
63
|
+
valueTextTemplate: string;
|
|
64
|
+
}
|
|
65
|
+
export declare function resolveSliderState(props?: Partial<QwSliderProps>): ResolvedSliderState;
|
|
66
|
+
/** Clamp into [lower, upper] and snap to the step grid anchored at min; the bounds themselves stay reachable. */
|
|
67
|
+
export declare function snapSliderValue(state: Pick<ResolvedSliderState, "min" | "max" | "step">, value: number, lower?: number, upper?: number): number;
|
|
68
|
+
/** Any input shape becomes an ascending, snapped array of length 1 (single) or 2 (range). */
|
|
69
|
+
export declare function normalizeSliderValues(state: ResolvedSliderState, value: SliderValue | readonly number[] | undefined): number[];
|
|
70
|
+
/** Public payload shape. */
|
|
71
|
+
export declare function toSliderValue(state: Pick<ResolvedSliderState, "range">, values: readonly number[]): SliderValue;
|
|
72
|
+
/** Bounds a thumb may move within: range thumbs never cross. */
|
|
73
|
+
export declare function getSliderThumbBounds(state: ResolvedSliderState, values: readonly number[], index: number): {
|
|
74
|
+
lower: number;
|
|
75
|
+
upper: number;
|
|
76
|
+
};
|
|
77
|
+
export declare function getSliderPercent(state: Pick<ResolvedSliderState, "min" | "max">, value: number): number;
|
|
78
|
+
export interface SliderRect {
|
|
79
|
+
left: number;
|
|
80
|
+
right: number;
|
|
81
|
+
top: number;
|
|
82
|
+
bottom: number;
|
|
83
|
+
}
|
|
84
|
+
/** Pointer geometry → raw value. Horizontal RTL measures from the right; vertical measures from the bottom. */
|
|
85
|
+
export declare function getSliderPointValue(state: ResolvedSliderState, point: {
|
|
86
|
+
x: number;
|
|
87
|
+
y: number;
|
|
88
|
+
}, rect: SliderRect, rtl: boolean): number | null;
|
|
89
|
+
/** Nearest thumb; coincident thumbs choose by the side the pointer is on. */
|
|
90
|
+
export declare function getSliderClosestThumb(values: readonly number[], value: number): number;
|
|
91
|
+
/** Keyboard step result for one thumb (APG slider): Arrow ±step, Page ±pageStep, Home/End to the thumb bounds. */
|
|
92
|
+
export declare function getSliderKeyValue(state: ResolvedSliderState, values: readonly number[], index: number, key: string): number | null;
|
|
93
|
+
export declare function createSliderProps(props: QwSliderProps): QwSliderProps;
|
|
94
|
+
export interface QwSliderSchema {
|
|
95
|
+
props: QwSliderProps;
|
|
96
|
+
context: {
|
|
97
|
+
value: SliderValue;
|
|
98
|
+
activeIndex: number;
|
|
99
|
+
focusedIndex: number;
|
|
100
|
+
pointerId: number | null;
|
|
101
|
+
requested: number[] | null;
|
|
102
|
+
inheritedDisabled: boolean;
|
|
103
|
+
};
|
|
104
|
+
state: "idle" | "dragging";
|
|
105
|
+
guard: "canInteract";
|
|
106
|
+
action: "setThumb" | "setValues" | "startDrag" | "moveDrag" | "endDrag" | "cancelDrag" | "setFocus" | "resetForm" | "setInheritedDisabled";
|
|
107
|
+
effect: "trackForm" | "capturePointer";
|
|
108
|
+
event: {
|
|
109
|
+
type: "THUMB.SET";
|
|
110
|
+
index: number;
|
|
111
|
+
value: number;
|
|
112
|
+
commit?: boolean;
|
|
113
|
+
} | {
|
|
114
|
+
type: "VALUES.SET";
|
|
115
|
+
value: SliderValue;
|
|
116
|
+
} | {
|
|
117
|
+
type: "POINTER.DOWN";
|
|
118
|
+
pointerId: number;
|
|
119
|
+
value: number;
|
|
120
|
+
} | {
|
|
121
|
+
type: "POINTER.MOVE";
|
|
122
|
+
pointerId: number;
|
|
123
|
+
value: number;
|
|
124
|
+
} | {
|
|
125
|
+
type: "POINTER.UP";
|
|
126
|
+
pointerId: number;
|
|
127
|
+
} | {
|
|
128
|
+
type: "POINTER.CANCEL";
|
|
129
|
+
pointerId?: number;
|
|
130
|
+
} | {
|
|
131
|
+
type: "FOCUS.SET";
|
|
132
|
+
index: number;
|
|
133
|
+
} | {
|
|
134
|
+
type: "FORM.RESET";
|
|
135
|
+
} | {
|
|
136
|
+
type: "FIELDSET.DISABLED";
|
|
137
|
+
disabled: boolean;
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
export type QwSliderMachine = Machine<QwSliderSchema>;
|
|
141
|
+
export type QwSliderService = Service<QwSliderSchema>;
|
|
142
|
+
/** Bindable values own controlled/uncontrolled; a controlled owner rejects a request simply by not updating `value`. */
|
|
143
|
+
export declare const sliderMachine: QwSliderMachine;
|
|
144
|
+
export interface SliderThumb {
|
|
145
|
+
index: number;
|
|
146
|
+
key: string;
|
|
147
|
+
value: number;
|
|
148
|
+
percent: number;
|
|
149
|
+
label: string;
|
|
150
|
+
valueText: string;
|
|
151
|
+
min: number;
|
|
152
|
+
max: number;
|
|
153
|
+
active: boolean;
|
|
154
|
+
focused: boolean;
|
|
155
|
+
}
|
|
156
|
+
export interface QwSliderApi<T extends PropTypes = PropTypes> {
|
|
157
|
+
value: SliderValue;
|
|
158
|
+
values: number[];
|
|
159
|
+
thumbs: SliderThumb[];
|
|
160
|
+
label: string;
|
|
161
|
+
dragging: boolean;
|
|
162
|
+
disabled: boolean;
|
|
163
|
+
setValue(value: SliderValue): void;
|
|
164
|
+
setThumbValue(index: number, value: number): void;
|
|
165
|
+
getRootProps(): T["element"];
|
|
166
|
+
getLabelProps(): T["element"];
|
|
167
|
+
getControlProps(): T["element"];
|
|
168
|
+
getTrackProps(): T["element"];
|
|
169
|
+
getRangeProps(): T["element"];
|
|
170
|
+
getThumbProps(thumb: Pick<SliderThumb, "index">): T["element"];
|
|
171
|
+
/** One hidden form input per thumb. Always render them: they carry form reset/fieldset tracking and submit only with `name`. */
|
|
172
|
+
getInputProps(thumb: Pick<SliderThumb, "index">): T["input"];
|
|
173
|
+
}
|
|
174
|
+
export declare function connectSlider<T extends PropTypes>(service: QwSliderService, normalize: NormalizeProps<T>): QwSliderApi<T>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./space.js";
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { i as resolveLayoutGap, n as getLayoutGroupProps, t as LAYOUT_GAP_PRESETS } from "../layout-BRSqi4AQ.js";
|
|
2
|
+
//#region src/space/space.ts
|
|
3
|
+
const SPACE_DIRECTIONS = ["horizontal", "vertical"];
|
|
4
|
+
const SPACE_ALIGNS = [
|
|
5
|
+
"start",
|
|
6
|
+
"end",
|
|
7
|
+
"center",
|
|
8
|
+
"baseline",
|
|
9
|
+
"stretch"
|
|
10
|
+
];
|
|
11
|
+
const SPACE_JUSTIFIES = [
|
|
12
|
+
"start",
|
|
13
|
+
"end",
|
|
14
|
+
"center",
|
|
15
|
+
"between",
|
|
16
|
+
"around",
|
|
17
|
+
"evenly"
|
|
18
|
+
];
|
|
19
|
+
function resolveSpaceState(props = {}) {
|
|
20
|
+
const direction = SPACE_DIRECTIONS.includes(props.direction) ? props.direction : "horizontal";
|
|
21
|
+
return {
|
|
22
|
+
direction,
|
|
23
|
+
align: SPACE_ALIGNS.includes(props.align) ? props.align : direction === "vertical" ? "stretch" : "center",
|
|
24
|
+
justify: SPACE_JUSTIFIES.includes(props.justify) ? props.justify : "start",
|
|
25
|
+
wrap: direction === "horizontal" && !!props.wrap,
|
|
26
|
+
block: !!props.block,
|
|
27
|
+
gap: resolveLayoutGap(props.gap),
|
|
28
|
+
label: props.label
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function getSpaceRootProps(state) {
|
|
32
|
+
return {
|
|
33
|
+
"data-scope": "space",
|
|
34
|
+
"data-part": "root",
|
|
35
|
+
"data-direction": state.direction,
|
|
36
|
+
"data-align": state.align,
|
|
37
|
+
"data-justify": state.justify,
|
|
38
|
+
...state.wrap ? { "data-wrap": "true" } : {},
|
|
39
|
+
...state.block ? { "data-block": "true" } : {},
|
|
40
|
+
...getLayoutGroupProps(state.label)
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
function getSpaceStyle(state) {
|
|
44
|
+
return {
|
|
45
|
+
"--qw-space-row-gap": state.gap[0],
|
|
46
|
+
"--qw-space-column-gap": state.gap[1]
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { LAYOUT_GAP_PRESETS, SPACE_ALIGNS, SPACE_DIRECTIONS, SPACE_JUSTIFIES, getSpaceRootProps, getSpaceStyle, resolveSpaceState };
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/space/space.ts"],"sourcesContent":["import { resolveLayoutGap, getLayoutGroupProps, type LayoutGap, type LayoutStyle, type LayoutGroupProps } from \"../layout.js\";\nexport { LAYOUT_GAP_PRESETS } from \"../layout.js\";\nexport type { LayoutGap, LayoutGapAtom, LayoutStyle, LayoutGroupProps } from \"../layout.js\";\nexport const SPACE_DIRECTIONS = [\"horizontal\", \"vertical\"] as const;\nexport const SPACE_ALIGNS = [\"start\", \"end\", \"center\", \"baseline\", \"stretch\"] as const;\nexport const SPACE_JUSTIFIES = [\"start\", \"end\", \"center\", \"between\", \"around\", \"evenly\"] as const;\nexport type SpaceDirection = (typeof SPACE_DIRECTIONS)[number];\nexport type SpaceAlign = (typeof SPACE_ALIGNS)[number];\nexport type SpaceJustify = (typeof SPACE_JUSTIFIES)[number];\nexport interface QwSpaceProps {\n /** Main layout direction, default horizontal. */\n direction?: SpaceDirection;\n /** Cross-axis alignment; horizontal defaults center, vertical stretch. */\n align?: SpaceAlign;\n /** Main-axis distribution, default start. */\n justify?: SpaceJustify;\n /** Wrap horizontal items; ignored for vertical layouts. */\n wrap?: boolean;\n /** Fill the available inline width. */\n block?: boolean;\n /** Preset, numeric pixels, CSS length or CSS-order [row, column]. Default sm. */\n gap?: LayoutGap;\n /** Optional accessible group name; empty/omitted keeps a passive div. */\n label?: string | null;\n}\nexport interface ResolvedSpaceState { direction: SpaceDirection; align: SpaceAlign; justify: SpaceJustify; wrap: boolean; block: boolean; gap: readonly [string,string]; label?: string | null }\nexport function resolveSpaceState(props: QwSpaceProps = {}): ResolvedSpaceState {\n const direction = SPACE_DIRECTIONS.includes(props.direction!) ? props.direction! : \"horizontal\";\n return { direction, align: SPACE_ALIGNS.includes(props.align!) ? props.align! : direction === \"vertical\" ? \"stretch\" : \"center\",\n justify: SPACE_JUSTIFIES.includes(props.justify!) ? props.justify! : \"start\", wrap: direction === \"horizontal\" && !!props.wrap, block: !!props.block,\n gap: resolveLayoutGap(props.gap), label: props.label };\n}\nexport interface SpaceRootProps extends LayoutGroupProps { \"data-scope\": \"space\"; \"data-part\": \"root\"; \"data-direction\": SpaceDirection; \"data-align\": SpaceAlign; \"data-justify\": SpaceJustify; \"data-wrap\"?: \"true\"; \"data-block\"?: \"true\" }\nexport function getSpaceRootProps(state: ResolvedSpaceState): SpaceRootProps {\n return { \"data-scope\":\"space\", \"data-part\":\"root\", \"data-direction\":state.direction, \"data-align\":state.align, \"data-justify\":state.justify,\n ...(state.wrap ? {\"data-wrap\":\"true\" as const}:{}), ...(state.block ? {\"data-block\":\"true\" as const}:{}), ...getLayoutGroupProps(state.label) };\n}\nexport function getSpaceStyle(state: ResolvedSpaceState): LayoutStyle { return { \"--qw-space-row-gap\":state.gap[0], \"--qw-space-column-gap\":state.gap[1] }; }\n"],"mappings":";;AAGA,MAAa,mBAAmB,CAAC,cAAc,UAAU;AACzD,MAAa,eAAe;CAAC;CAAS;CAAO;CAAU;CAAY;AAAS;AAC5E,MAAa,kBAAkB;CAAC;CAAS;CAAO;CAAU;CAAW;CAAU;AAAQ;AAqBvF,SAAgB,kBAAkB,QAAsB,CAAC,GAAuB;CAC9E,MAAM,YAAY,iBAAiB,SAAS,MAAM,SAAU,IAAI,MAAM,YAAa;CACnF,OAAO;EAAE;EAAW,OAAO,aAAa,SAAS,MAAM,KAAM,IAAI,MAAM,QAAS,cAAc,aAAa,YAAY;EACrH,SAAS,gBAAgB,SAAS,MAAM,OAAQ,IAAI,MAAM,UAAW;EAAS,MAAM,cAAc,gBAAgB,CAAC,CAAC,MAAM;EAAM,OAAO,CAAC,CAAC,MAAM;EAC/I,KAAK,iBAAiB,MAAM,GAAG;EAAG,OAAO,MAAM;CAAM;AACzD;AAEA,SAAgB,kBAAkB,OAA2C;CAC3E,OAAO;EAAE,cAAa;EAAS,aAAY;EAAQ,kBAAiB,MAAM;EAAW,cAAa,MAAM;EAAO,gBAAe,MAAM;EAClI,GAAI,MAAM,OAAO,EAAC,aAAY,OAAe,IAAE,CAAC;EAAI,GAAI,MAAM,QAAQ,EAAC,cAAa,OAAe,IAAE,CAAC;EAAI,GAAG,oBAAoB,MAAM,KAAK;CAAE;AAClJ;AACA,SAAgB,cAAc,OAAwC;CAAE,OAAO;EAAE,sBAAqB,MAAM,IAAI;EAAI,yBAAwB,MAAM,IAAI;CAAG;AAAG"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type LayoutGap, type LayoutStyle, type LayoutGroupProps } from "../layout.js";
|
|
2
|
+
export { LAYOUT_GAP_PRESETS } from "../layout.js";
|
|
3
|
+
export type { LayoutGap, LayoutGapAtom, LayoutStyle, LayoutGroupProps } from "../layout.js";
|
|
4
|
+
export declare const SPACE_DIRECTIONS: readonly ["horizontal", "vertical"];
|
|
5
|
+
export declare const SPACE_ALIGNS: readonly ["start", "end", "center", "baseline", "stretch"];
|
|
6
|
+
export declare const SPACE_JUSTIFIES: readonly ["start", "end", "center", "between", "around", "evenly"];
|
|
7
|
+
export type SpaceDirection = (typeof SPACE_DIRECTIONS)[number];
|
|
8
|
+
export type SpaceAlign = (typeof SPACE_ALIGNS)[number];
|
|
9
|
+
export type SpaceJustify = (typeof SPACE_JUSTIFIES)[number];
|
|
10
|
+
export interface QwSpaceProps {
|
|
11
|
+
/** Main layout direction, default horizontal. */
|
|
12
|
+
direction?: SpaceDirection;
|
|
13
|
+
/** Cross-axis alignment; horizontal defaults center, vertical stretch. */
|
|
14
|
+
align?: SpaceAlign;
|
|
15
|
+
/** Main-axis distribution, default start. */
|
|
16
|
+
justify?: SpaceJustify;
|
|
17
|
+
/** Wrap horizontal items; ignored for vertical layouts. */
|
|
18
|
+
wrap?: boolean;
|
|
19
|
+
/** Fill the available inline width. */
|
|
20
|
+
block?: boolean;
|
|
21
|
+
/** Preset, numeric pixels, CSS length or CSS-order [row, column]. Default sm. */
|
|
22
|
+
gap?: LayoutGap;
|
|
23
|
+
/** Optional accessible group name; empty/omitted keeps a passive div. */
|
|
24
|
+
label?: string | null;
|
|
25
|
+
}
|
|
26
|
+
export interface ResolvedSpaceState {
|
|
27
|
+
direction: SpaceDirection;
|
|
28
|
+
align: SpaceAlign;
|
|
29
|
+
justify: SpaceJustify;
|
|
30
|
+
wrap: boolean;
|
|
31
|
+
block: boolean;
|
|
32
|
+
gap: readonly [string, string];
|
|
33
|
+
label?: string | null;
|
|
34
|
+
}
|
|
35
|
+
export declare function resolveSpaceState(props?: QwSpaceProps): ResolvedSpaceState;
|
|
36
|
+
export interface SpaceRootProps extends LayoutGroupProps {
|
|
37
|
+
"data-scope": "space";
|
|
38
|
+
"data-part": "root";
|
|
39
|
+
"data-direction": SpaceDirection;
|
|
40
|
+
"data-align": SpaceAlign;
|
|
41
|
+
"data-justify": SpaceJustify;
|
|
42
|
+
"data-wrap"?: "true";
|
|
43
|
+
"data-block"?: "true";
|
|
44
|
+
}
|
|
45
|
+
export declare function getSpaceRootProps(state: ResolvedSpaceState): SpaceRootProps;
|
|
46
|
+
export declare function getSpaceStyle(state: ResolvedSpaceState): LayoutStyle;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./statistic.js";
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { i as roundDecimal, n as parseDecimal, r as resolveDecimalPrecision, t as groupDecimalInteger } from "../format-BDUY0C_c.js";
|
|
2
|
+
import { visuallyHiddenStyle } from "@zag-js/dom-query";
|
|
3
|
+
//#region src/statistic/statistic.ts
|
|
4
|
+
const STATISTIC_SIZES = [
|
|
5
|
+
"sm",
|
|
6
|
+
"md",
|
|
7
|
+
"lg"
|
|
8
|
+
];
|
|
9
|
+
const STATISTIC_TRENDS = [
|
|
10
|
+
"up",
|
|
11
|
+
"down",
|
|
12
|
+
"flat"
|
|
13
|
+
];
|
|
14
|
+
const STATISTIC_LIVE_MODES = ["off", "polite"];
|
|
15
|
+
/** Stable DOM parts shared by every adapter. */
|
|
16
|
+
const STATISTIC_PARTS = [
|
|
17
|
+
"root",
|
|
18
|
+
"title",
|
|
19
|
+
"content",
|
|
20
|
+
"prefix",
|
|
21
|
+
"value",
|
|
22
|
+
"integer",
|
|
23
|
+
"decimal",
|
|
24
|
+
"fraction",
|
|
25
|
+
"suffix",
|
|
26
|
+
"trend",
|
|
27
|
+
"trend-label"
|
|
28
|
+
];
|
|
29
|
+
const STATISTIC_DEFAULT_PLACEHOLDER = "--";
|
|
30
|
+
const STATISTIC_TREND_LABELS = {
|
|
31
|
+
up: "上升",
|
|
32
|
+
down: "下降",
|
|
33
|
+
flat: "持平"
|
|
34
|
+
};
|
|
35
|
+
const TREND_GLYPHS = {
|
|
36
|
+
up: "▲",
|
|
37
|
+
down: "▼",
|
|
38
|
+
flat: "–"
|
|
39
|
+
};
|
|
40
|
+
const pick = (list, value, fallback) => list.includes(value) ? value : fallback;
|
|
41
|
+
/** Format the value synchronously so the readable text is always the final value. */
|
|
42
|
+
function resolveStatisticState(props) {
|
|
43
|
+
const trend = STATISTIC_TRENDS.includes(props.trend) ? props.trend : void 0;
|
|
44
|
+
const base = {
|
|
45
|
+
title: props.title ?? "",
|
|
46
|
+
prefix: props.prefix ?? "",
|
|
47
|
+
suffix: props.suffix ?? "",
|
|
48
|
+
trend,
|
|
49
|
+
trendGlyph: trend ? TREND_GLYPHS[trend] : "",
|
|
50
|
+
trendLabel: trend ? props.trendLabel ?? STATISTIC_TREND_LABELS[trend] : "",
|
|
51
|
+
live: pick(STATISTIC_LIVE_MODES, props.live, "off"),
|
|
52
|
+
size: pick(STATISTIC_SIZES, props.size, "md")
|
|
53
|
+
};
|
|
54
|
+
const parsed = props.value === void 0 || props.value === "" ? null : parseDecimal(props.value);
|
|
55
|
+
if (!parsed) return {
|
|
56
|
+
...base,
|
|
57
|
+
valid: false,
|
|
58
|
+
negative: false,
|
|
59
|
+
formatted: false,
|
|
60
|
+
text: props.placeholder ?? "--",
|
|
61
|
+
sign: "",
|
|
62
|
+
integer: "",
|
|
63
|
+
decimal: "",
|
|
64
|
+
fraction: ""
|
|
65
|
+
};
|
|
66
|
+
const precision = resolveDecimalPrecision(props.precision, void 0);
|
|
67
|
+
const rounded = precision === void 0 ? parsed : roundDecimal(parsed, precision);
|
|
68
|
+
const integer = groupDecimalInteger(rounded.integer, props.groupSeparator ?? ",");
|
|
69
|
+
const decimal = rounded.fraction ? props.decimalSeparator ?? "." : "";
|
|
70
|
+
const sign = rounded.negative ? "-" : "";
|
|
71
|
+
const text = `${sign}${integer}${decimal}${rounded.fraction}`;
|
|
72
|
+
let custom;
|
|
73
|
+
if (props.formatter) try {
|
|
74
|
+
custom = props.formatter({
|
|
75
|
+
value: props.value,
|
|
76
|
+
negative: rounded.negative,
|
|
77
|
+
integer,
|
|
78
|
+
fraction: rounded.fraction,
|
|
79
|
+
text
|
|
80
|
+
});
|
|
81
|
+
} catch {
|
|
82
|
+
custom = void 0;
|
|
83
|
+
}
|
|
84
|
+
const formatted = typeof custom === "string";
|
|
85
|
+
return {
|
|
86
|
+
...base,
|
|
87
|
+
valid: true,
|
|
88
|
+
negative: rounded.negative,
|
|
89
|
+
formatted,
|
|
90
|
+
text: formatted ? custom : text,
|
|
91
|
+
sign,
|
|
92
|
+
integer,
|
|
93
|
+
decimal,
|
|
94
|
+
fraction: rounded.fraction
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function getStatisticRootProps(state) {
|
|
98
|
+
return {
|
|
99
|
+
"data-scope": "statistic",
|
|
100
|
+
"data-part": "root",
|
|
101
|
+
"data-size": state.size,
|
|
102
|
+
...state.trend ? { "data-trend": state.trend } : {},
|
|
103
|
+
...state.negative ? { "data-negative": "" } : {},
|
|
104
|
+
...!state.valid ? { "data-invalid": "" } : {}
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/** The content row is one atomic polite region only when explicitly requested. */
|
|
108
|
+
function getStatisticContentProps(state) {
|
|
109
|
+
return {
|
|
110
|
+
"data-scope": "statistic",
|
|
111
|
+
"data-part": "content",
|
|
112
|
+
...state.live === "polite" ? {
|
|
113
|
+
"aria-live": "polite",
|
|
114
|
+
"aria-atomic": "true"
|
|
115
|
+
} : {}
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
/** Empty optional parts carry `hidden`, so adapters render a fixed tree without branches. */
|
|
119
|
+
function getStatisticPartProps(state, part) {
|
|
120
|
+
const props = {
|
|
121
|
+
"data-scope": "statistic",
|
|
122
|
+
"data-part": part,
|
|
123
|
+
...(part === "title" ? !state.title : part === "prefix" ? !state.prefix : part === "suffix" ? !state.suffix : part === "trend" || part === "trend-label" ? !state.trend : false) ? { hidden: true } : {}
|
|
124
|
+
};
|
|
125
|
+
if (part === "trend") props["aria-hidden"] = "true";
|
|
126
|
+
if (part === "trend-label") props.style = { ...visuallyHiddenStyle };
|
|
127
|
+
return props;
|
|
128
|
+
}
|
|
129
|
+
function getStatisticSegments(state) {
|
|
130
|
+
if (!state.valid || state.formatted) return [{
|
|
131
|
+
part: "integer",
|
|
132
|
+
text: state.text
|
|
133
|
+
}];
|
|
134
|
+
return [
|
|
135
|
+
{
|
|
136
|
+
part: "integer",
|
|
137
|
+
text: `${state.sign}${state.integer}`
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
part: "decimal",
|
|
141
|
+
text: state.decimal
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
part: "fraction",
|
|
145
|
+
text: state.fraction
|
|
146
|
+
}
|
|
147
|
+
].filter((segment) => segment.text !== "");
|
|
148
|
+
}
|
|
149
|
+
//#endregion
|
|
150
|
+
export { STATISTIC_DEFAULT_PLACEHOLDER, STATISTIC_LIVE_MODES, STATISTIC_PARTS, STATISTIC_SIZES, STATISTIC_TRENDS, STATISTIC_TREND_LABELS, getStatisticContentProps, getStatisticPartProps, getStatisticRootProps, getStatisticSegments, resolveStatisticState };
|
|
151
|
+
|
|
152
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/statistic/statistic.ts"],"sourcesContent":["import { visuallyHiddenStyle } from \"@zag-js/dom-query\";\nimport { groupDecimalInteger, parseDecimal, resolveDecimalPrecision, roundDecimal } from \"../price/format.js\";\n\nexport const STATISTIC_SIZES = [\"sm\", \"md\", \"lg\"] as const;\nexport const STATISTIC_TRENDS = [\"up\", \"down\", \"flat\"] as const;\nexport const STATISTIC_LIVE_MODES = [\"off\", \"polite\"] as const;\n/** Stable DOM parts shared by every adapter. */\nexport const STATISTIC_PARTS = [\"root\", \"title\", \"content\", \"prefix\", \"value\", \"integer\", \"decimal\", \"fraction\", \"suffix\", \"trend\", \"trend-label\"] as const;\nexport const STATISTIC_DEFAULT_PLACEHOLDER = \"--\";\nexport const STATISTIC_TREND_LABELS = { up: \"上升\", down: \"下降\", flat: \"持平\" } as const;\nconst TREND_GLYPHS = { up: \"▲\", down: \"▼\", flat: \"–\" } as const;\n\nexport type StatisticSize = (typeof STATISTIC_SIZES)[number];\nexport type StatisticTrend = (typeof STATISTIC_TRENDS)[number];\nexport type StatisticLiveMode = (typeof STATISTIC_LIVE_MODES)[number];\nexport type StatisticPart = (typeof STATISTIC_PARTS)[number];\n\n/** Input passed to a custom formatter; digit strings are already rounded and grouped. */\nexport interface StatisticFormatInput {\n /** Caller value as supplied. */\n value: number | string;\n negative: boolean;\n integer: string;\n fraction: string;\n /** Default formatted text, e.g. \"-12,345.60\". */\n text: string;\n}\nexport type StatisticFormatter = (input: StatisticFormatInput) => string;\n\nexport interface QwStatisticProps {\n /** Visible title read before the value. */\n title?: string;\n value?: number | string;\n /** Fraction digits 0–10; omitted keeps the supplied fraction digits. */\n precision?: number;\n /** Integer group separator; defaults to \",\". Empty disables grouping. */\n groupSeparator?: string;\n decimalSeparator?: string;\n prefix?: string;\n suffix?: string;\n /** Pure string formatter; exceptions or non-string results fall back to the default text. */\n formatter?: StatisticFormatter;\n /** Text for missing or invalid values; defaults to \"--\". */\n placeholder?: string;\n /** Non-color trend expression (glyph plus text). */\n trend?: StatisticTrend;\n trendLabel?: string;\n /** \"polite\" makes the value area a polite live region for refreshed KPIs; defaults \"off\". */\n live?: StatisticLiveMode;\n size?: StatisticSize;\n}\n\nexport interface ResolvedStatisticState {\n title: string;\n valid: boolean;\n negative: boolean;\n /** True when a custom formatter produced the value text. */\n formatted: boolean;\n /** Visible value text (without prefix/suffix). */\n text: string;\n sign: string;\n integer: string;\n decimal: string;\n fraction: string;\n prefix: string;\n suffix: string;\n trend?: StatisticTrend;\n trendGlyph: string;\n trendLabel: string;\n live: StatisticLiveMode;\n size: StatisticSize;\n}\n\nconst pick = <T extends string>(list: readonly T[], value: unknown, fallback: T): T => (list as readonly unknown[]).includes(value) ? value as T : fallback;\n\n/** Format the value synchronously so the readable text is always the final value. */\nexport function resolveStatisticState(props: QwStatisticProps): ResolvedStatisticState {\n const trend = (STATISTIC_TRENDS as readonly unknown[]).includes(props.trend) ? props.trend : undefined;\n const base = {\n title: props.title ?? \"\", prefix: props.prefix ?? \"\", suffix: props.suffix ?? \"\", trend,\n trendGlyph: trend ? TREND_GLYPHS[trend] : \"\", trendLabel: trend ? (props.trendLabel ?? STATISTIC_TREND_LABELS[trend]) : \"\",\n live: pick(STATISTIC_LIVE_MODES, props.live, \"off\"), size: pick(STATISTIC_SIZES, props.size, \"md\"),\n };\n const parsed = props.value === undefined || props.value === \"\" ? null : parseDecimal(props.value);\n if (!parsed) {\n return { ...base, valid: false, negative: false, formatted: false, text: props.placeholder ?? STATISTIC_DEFAULT_PLACEHOLDER, sign: \"\", integer: \"\", decimal: \"\", fraction: \"\" };\n }\n const precision = resolveDecimalPrecision(props.precision, undefined);\n const rounded = precision === undefined ? parsed : roundDecimal(parsed, precision);\n const integer = groupDecimalInteger(rounded.integer, props.groupSeparator ?? \",\");\n const decimal = rounded.fraction ? (props.decimalSeparator ?? \".\") : \"\";\n const sign = rounded.negative ? \"-\" : \"\";\n const text = `${sign}${integer}${decimal}${rounded.fraction}`;\n let custom: unknown;\n if (props.formatter) {\n try { custom = props.formatter({ value: props.value!, negative: rounded.negative, integer, fraction: rounded.fraction, text }); } catch { custom = undefined; }\n }\n const formatted = typeof custom === \"string\";\n return { ...base, valid: true, negative: rounded.negative, formatted, text: formatted ? custom as string : text, sign, integer, decimal, fraction: rounded.fraction };\n}\n\ninterface PartBase { \"data-scope\": \"statistic\"; \"data-part\": StatisticPart }\nexport interface StatisticRootProps extends PartBase {\n \"data-size\": StatisticSize;\n \"data-trend\"?: StatisticTrend;\n \"data-negative\"?: \"\";\n \"data-invalid\"?: \"\";\n}\nexport function getStatisticRootProps(state: ResolvedStatisticState): StatisticRootProps {\n return {\n \"data-scope\": \"statistic\", \"data-part\": \"root\", \"data-size\": state.size,\n ...(state.trend ? { \"data-trend\": state.trend } : {}),\n ...(state.negative ? { \"data-negative\": \"\" as const } : {}),\n ...(!state.valid ? { \"data-invalid\": \"\" as const } : {}),\n };\n}\nexport interface StatisticContentProps extends PartBase { \"aria-live\"?: \"polite\"; \"aria-atomic\"?: \"true\" }\n/** The content row is one atomic polite region only when explicitly requested. */\nexport function getStatisticContentProps(state: ResolvedStatisticState): StatisticContentProps {\n return { \"data-scope\": \"statistic\", \"data-part\": \"content\", ...(state.live === \"polite\" ? { \"aria-live\": \"polite\" as const, \"aria-atomic\": \"true\" as const } : {}) };\n}\nexport interface StatisticPartProps extends PartBase { \"aria-hidden\"?: \"true\"; hidden?: true; style?: Record<string, string> }\n/** Empty optional parts carry `hidden`, so adapters render a fixed tree without branches. */\nexport function getStatisticPartProps(state: ResolvedStatisticState, part: Exclude<StatisticPart, \"root\" | \"content\">): StatisticPartProps {\n const empty = part === \"title\" ? !state.title : part === \"prefix\" ? !state.prefix : part === \"suffix\" ? !state.suffix : part === \"trend\" || part === \"trend-label\" ? !state.trend : false;\n const props: StatisticPartProps = { \"data-scope\": \"statistic\", \"data-part\": part, ...(empty ? { hidden: true as const } : {}) };\n if (part === \"trend\") props[\"aria-hidden\"] = \"true\";\n if (part === \"trend-label\") props.style = { ...visuallyHiddenStyle } as Record<string, string>;\n return props;\n}\n\n/** Value segments: a formatter or placeholder yields one text segment, otherwise integer/decimal/fraction. */\nexport interface StatisticSegment { part: \"integer\" | \"decimal\" | \"fraction\"; text: string }\nexport function getStatisticSegments(state: ResolvedStatisticState): StatisticSegment[] {\n if (!state.valid || state.formatted) return [{ part: \"integer\", text: state.text }];\n return ([\n { part: \"integer\", text: `${state.sign}${state.integer}` },\n { part: \"decimal\", text: state.decimal },\n { part: \"fraction\", text: state.fraction },\n ] as StatisticSegment[]).filter((segment) => segment.text !== \"\");\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
export declare const STATISTIC_SIZES: readonly ["sm", "md", "lg"];
|
|
2
|
+
export declare const STATISTIC_TRENDS: readonly ["up", "down", "flat"];
|
|
3
|
+
export declare const STATISTIC_LIVE_MODES: readonly ["off", "polite"];
|
|
4
|
+
/** Stable DOM parts shared by every adapter. */
|
|
5
|
+
export declare const STATISTIC_PARTS: readonly ["root", "title", "content", "prefix", "value", "integer", "decimal", "fraction", "suffix", "trend", "trend-label"];
|
|
6
|
+
export declare const STATISTIC_DEFAULT_PLACEHOLDER = "--";
|
|
7
|
+
export declare const STATISTIC_TREND_LABELS: {
|
|
8
|
+
readonly up: "上升";
|
|
9
|
+
readonly down: "下降";
|
|
10
|
+
readonly flat: "持平";
|
|
11
|
+
};
|
|
12
|
+
export type StatisticSize = (typeof STATISTIC_SIZES)[number];
|
|
13
|
+
export type StatisticTrend = (typeof STATISTIC_TRENDS)[number];
|
|
14
|
+
export type StatisticLiveMode = (typeof STATISTIC_LIVE_MODES)[number];
|
|
15
|
+
export type StatisticPart = (typeof STATISTIC_PARTS)[number];
|
|
16
|
+
/** Input passed to a custom formatter; digit strings are already rounded and grouped. */
|
|
17
|
+
export interface StatisticFormatInput {
|
|
18
|
+
/** Caller value as supplied. */
|
|
19
|
+
value: number | string;
|
|
20
|
+
negative: boolean;
|
|
21
|
+
integer: string;
|
|
22
|
+
fraction: string;
|
|
23
|
+
/** Default formatted text, e.g. "-12,345.60". */
|
|
24
|
+
text: string;
|
|
25
|
+
}
|
|
26
|
+
export type StatisticFormatter = (input: StatisticFormatInput) => string;
|
|
27
|
+
export interface QwStatisticProps {
|
|
28
|
+
/** Visible title read before the value. */
|
|
29
|
+
title?: string;
|
|
30
|
+
value?: number | string;
|
|
31
|
+
/** Fraction digits 0–10; omitted keeps the supplied fraction digits. */
|
|
32
|
+
precision?: number;
|
|
33
|
+
/** Integer group separator; defaults to ",". Empty disables grouping. */
|
|
34
|
+
groupSeparator?: string;
|
|
35
|
+
decimalSeparator?: string;
|
|
36
|
+
prefix?: string;
|
|
37
|
+
suffix?: string;
|
|
38
|
+
/** Pure string formatter; exceptions or non-string results fall back to the default text. */
|
|
39
|
+
formatter?: StatisticFormatter;
|
|
40
|
+
/** Text for missing or invalid values; defaults to "--". */
|
|
41
|
+
placeholder?: string;
|
|
42
|
+
/** Non-color trend expression (glyph plus text). */
|
|
43
|
+
trend?: StatisticTrend;
|
|
44
|
+
trendLabel?: string;
|
|
45
|
+
/** "polite" makes the value area a polite live region for refreshed KPIs; defaults "off". */
|
|
46
|
+
live?: StatisticLiveMode;
|
|
47
|
+
size?: StatisticSize;
|
|
48
|
+
}
|
|
49
|
+
export interface ResolvedStatisticState {
|
|
50
|
+
title: string;
|
|
51
|
+
valid: boolean;
|
|
52
|
+
negative: boolean;
|
|
53
|
+
/** True when a custom formatter produced the value text. */
|
|
54
|
+
formatted: boolean;
|
|
55
|
+
/** Visible value text (without prefix/suffix). */
|
|
56
|
+
text: string;
|
|
57
|
+
sign: string;
|
|
58
|
+
integer: string;
|
|
59
|
+
decimal: string;
|
|
60
|
+
fraction: string;
|
|
61
|
+
prefix: string;
|
|
62
|
+
suffix: string;
|
|
63
|
+
trend?: StatisticTrend;
|
|
64
|
+
trendGlyph: string;
|
|
65
|
+
trendLabel: string;
|
|
66
|
+
live: StatisticLiveMode;
|
|
67
|
+
size: StatisticSize;
|
|
68
|
+
}
|
|
69
|
+
/** Format the value synchronously so the readable text is always the final value. */
|
|
70
|
+
export declare function resolveStatisticState(props: QwStatisticProps): ResolvedStatisticState;
|
|
71
|
+
interface PartBase {
|
|
72
|
+
"data-scope": "statistic";
|
|
73
|
+
"data-part": StatisticPart;
|
|
74
|
+
}
|
|
75
|
+
export interface StatisticRootProps extends PartBase {
|
|
76
|
+
"data-size": StatisticSize;
|
|
77
|
+
"data-trend"?: StatisticTrend;
|
|
78
|
+
"data-negative"?: "";
|
|
79
|
+
"data-invalid"?: "";
|
|
80
|
+
}
|
|
81
|
+
export declare function getStatisticRootProps(state: ResolvedStatisticState): StatisticRootProps;
|
|
82
|
+
export interface StatisticContentProps extends PartBase {
|
|
83
|
+
"aria-live"?: "polite";
|
|
84
|
+
"aria-atomic"?: "true";
|
|
85
|
+
}
|
|
86
|
+
/** The content row is one atomic polite region only when explicitly requested. */
|
|
87
|
+
export declare function getStatisticContentProps(state: ResolvedStatisticState): StatisticContentProps;
|
|
88
|
+
export interface StatisticPartProps extends PartBase {
|
|
89
|
+
"aria-hidden"?: "true";
|
|
90
|
+
hidden?: true;
|
|
91
|
+
style?: Record<string, string>;
|
|
92
|
+
}
|
|
93
|
+
/** Empty optional parts carry `hidden`, so adapters render a fixed tree without branches. */
|
|
94
|
+
export declare function getStatisticPartProps(state: ResolvedStatisticState, part: Exclude<StatisticPart, "root" | "content">): StatisticPartProps;
|
|
95
|
+
/** Value segments: a formatter or placeholder yields one text segment, otherwise integer/decimal/fraction. */
|
|
96
|
+
export interface StatisticSegment {
|
|
97
|
+
part: "integer" | "decimal" | "fraction";
|
|
98
|
+
text: string;
|
|
99
|
+
}
|
|
100
|
+
export declare function getStatisticSegments(state: ResolvedStatisticState): StatisticSegment[];
|
|
101
|
+
export {};
|
package/dist/stepper/index.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Stepper 加减(数量步进器)的跨框架行为契约。
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* 交互由原生 `<button>` 承担。数值归一化、边界、按钮可用性、非受控模型、
|
|
6
|
+
* 受控判断和取消都在 Core;适配层只运输点击并重绘。
|
|
7
7
|
*/
|
|
8
8
|
/** 尺寸全集:s = 15×15px,m = 18×18px。 */
|
|
9
9
|
const STEPPER_SIZES = ["s", "m"];
|
|
@@ -107,7 +107,66 @@ function getStepperValueProps() {
|
|
|
107
107
|
"aria-atomic": "true"
|
|
108
108
|
};
|
|
109
109
|
}
|
|
110
|
+
function seedStepperModel(props, snapshot) {
|
|
111
|
+
if (props.value === void 0 && typeof snapshot?.value === "number") return snapshot.value;
|
|
112
|
+
if (typeof props.defaultValue === "number") return props.defaultValue;
|
|
113
|
+
if (typeof props.min === "number") return props.min;
|
|
114
|
+
return 0;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* 步进器的行为源。下一步在提交时按当时的模型计算:同一次任务里连续激活会依次累计,
|
|
118
|
+
* 而不是共用渲染当时预算的同一个 next。取消只看提交时的 defaultPrevented、禁用和 stop。
|
|
119
|
+
*/
|
|
120
|
+
function createStepperModel(props = {}, options = {}) {
|
|
121
|
+
let current = props;
|
|
122
|
+
let internal = seedStepperModel(props, options.snapshot);
|
|
123
|
+
let generation = 0;
|
|
124
|
+
let stopped = false;
|
|
125
|
+
const controlledNow = () => current.value !== void 0;
|
|
126
|
+
const view = () => resolveStepperState({
|
|
127
|
+
...current,
|
|
128
|
+
value: controlledNow() ? current.value : internal
|
|
129
|
+
});
|
|
130
|
+
const readModel = () => controlledNow() ? current.value ?? internal : internal;
|
|
131
|
+
return {
|
|
132
|
+
get state() {
|
|
133
|
+
return view();
|
|
134
|
+
},
|
|
135
|
+
get modelValue() {
|
|
136
|
+
return readModel();
|
|
137
|
+
},
|
|
138
|
+
get controlled() {
|
|
139
|
+
return controlledNow();
|
|
140
|
+
},
|
|
141
|
+
update(next) {
|
|
142
|
+
current = next;
|
|
143
|
+
},
|
|
144
|
+
request(direction, notice) {
|
|
145
|
+
if (stopped || view().disabled) return;
|
|
146
|
+
const seen = generation;
|
|
147
|
+
queueMicrotask(() => {
|
|
148
|
+
if (stopped || seen !== generation || notice.defaultPrevented) return;
|
|
149
|
+
const resolved = view();
|
|
150
|
+
if (resolved.disabled) return;
|
|
151
|
+
const next = direction === "increment" ? getStepperIncrementValue(resolved) : getStepperDecrementValue(resolved);
|
|
152
|
+
if (!controlledNow()) internal = next;
|
|
153
|
+
current.onChange?.(next);
|
|
154
|
+
options.onCommit?.();
|
|
155
|
+
});
|
|
156
|
+
},
|
|
157
|
+
start() {
|
|
158
|
+
stopped = false;
|
|
159
|
+
},
|
|
160
|
+
stop() {
|
|
161
|
+
stopped = true;
|
|
162
|
+
generation += 1;
|
|
163
|
+
},
|
|
164
|
+
snapshot() {
|
|
165
|
+
return { value: readModel() };
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
}
|
|
110
169
|
//#endregion
|
|
111
|
-
export { STEPPER_PARTS, STEPPER_SIZES, STEPPER_VARIANTS, clampStepperValue, getStepperDecrementProps, getStepperDecrementValue, getStepperIncrementProps, getStepperIncrementValue, getStepperRootProps, getStepperValueProps, resolveStepperState };
|
|
170
|
+
export { STEPPER_PARTS, STEPPER_SIZES, STEPPER_VARIANTS, clampStepperValue, createStepperModel, getStepperDecrementProps, getStepperDecrementValue, getStepperIncrementProps, getStepperIncrementValue, getStepperRootProps, getStepperValueProps, resolveStepperState };
|
|
112
171
|
|
|
113
172
|
//# sourceMappingURL=index.js.map
|