@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,138 @@
|
|
|
1
|
+
import { o as resolveIconState } from "../icon-Cgdbnk1u.js";
|
|
2
|
+
import { createMachine } from "@zag-js/core";
|
|
3
|
+
//#region src/share-sheet/share-sheet.ts
|
|
4
|
+
function createShareSheetProps(props = {}) {
|
|
5
|
+
return {
|
|
6
|
+
...props,
|
|
7
|
+
groups: props.groups ?? [],
|
|
8
|
+
ariaLabel: props.ariaLabel?.trim() || "分享面板"
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function resolveShareSheetGroups(groups = []) {
|
|
12
|
+
const seen = /* @__PURE__ */ new Set();
|
|
13
|
+
return groups.map((group, groupIndex) => ({
|
|
14
|
+
label: group.label,
|
|
15
|
+
groupIndex,
|
|
16
|
+
actions: group.actions.map((source, index) => {
|
|
17
|
+
const duplicate = seen.has(source.value);
|
|
18
|
+
seen.add(source.value);
|
|
19
|
+
return {
|
|
20
|
+
...source,
|
|
21
|
+
source,
|
|
22
|
+
index,
|
|
23
|
+
groupIndex,
|
|
24
|
+
disabled: !!source.disabled || duplicate || !source.value.trim() || !source.label.trim(),
|
|
25
|
+
duplicate
|
|
26
|
+
};
|
|
27
|
+
})
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
const shareSheetMachine = createMachine({
|
|
31
|
+
props: ({ props }) => createShareSheetProps(props),
|
|
32
|
+
initialState: () => "ready",
|
|
33
|
+
states: { ready: {} },
|
|
34
|
+
context: ({ bindable, prop }) => ({ open: bindable(() => ({
|
|
35
|
+
defaultValue: prop("defaultOpen") ?? false,
|
|
36
|
+
value: prop("open"),
|
|
37
|
+
onChange: (open) => prop("onOpenChange")?.(open)
|
|
38
|
+
})) }),
|
|
39
|
+
on: {
|
|
40
|
+
OPEN: { actions: ["open"] },
|
|
41
|
+
ACTIVATE: { actions: ["activate"] },
|
|
42
|
+
CANCEL: { actions: ["cancel"] }
|
|
43
|
+
},
|
|
44
|
+
implementations: { actions: {
|
|
45
|
+
open({ context, event }) {
|
|
46
|
+
if (event.type === "OPEN") context.set("open", event.open);
|
|
47
|
+
},
|
|
48
|
+
activate({ prop, context, event }) {
|
|
49
|
+
if (event.type !== "ACTIVATE" || !context.get("open")) return;
|
|
50
|
+
const latest = resolveShareSheetGroups(prop("groups"))[event.groupIndex]?.actions[event.index];
|
|
51
|
+
if (!latest || latest.source !== event.source || latest.disabled) return;
|
|
52
|
+
prop("onAction")?.({
|
|
53
|
+
value: latest.value,
|
|
54
|
+
groupIndex: event.groupIndex,
|
|
55
|
+
index: event.index
|
|
56
|
+
});
|
|
57
|
+
if (prop("closeOnAction") !== false) context.set("open", false);
|
|
58
|
+
},
|
|
59
|
+
cancel({ prop, context }) {
|
|
60
|
+
if (!context.get("open")) return;
|
|
61
|
+
prop("onCancel")?.();
|
|
62
|
+
context.set("open", false);
|
|
63
|
+
}
|
|
64
|
+
} }
|
|
65
|
+
});
|
|
66
|
+
function connectShareSheet(service, normalize) {
|
|
67
|
+
const groups = resolveShareSheetGroups(service.prop("groups")), open = service.context.get("open");
|
|
68
|
+
const part = (name) => ({
|
|
69
|
+
"data-scope": "share-sheet",
|
|
70
|
+
"data-part": name
|
|
71
|
+
});
|
|
72
|
+
return {
|
|
73
|
+
open,
|
|
74
|
+
groups,
|
|
75
|
+
popupProps: {
|
|
76
|
+
id: `${service.scope.id}-popup`,
|
|
77
|
+
open,
|
|
78
|
+
title: service.prop("title"),
|
|
79
|
+
ariaLabel: service.prop("ariaLabel"),
|
|
80
|
+
closeLabel: service.prop("closeLabel"),
|
|
81
|
+
placement: "bottom",
|
|
82
|
+
closeOnMaskClick: service.prop("closeOnMaskClick"),
|
|
83
|
+
disableBodyScroll: service.prop("disableBodyScroll"),
|
|
84
|
+
safeArea: service.prop("safeArea"),
|
|
85
|
+
returnFocus: service.prop("returnFocus"),
|
|
86
|
+
onOpenChange: (value) => service.send({
|
|
87
|
+
type: "OPEN",
|
|
88
|
+
open: value
|
|
89
|
+
})
|
|
90
|
+
},
|
|
91
|
+
cancelText: service.prop("cancelText")?.trim() || "取消",
|
|
92
|
+
setOpen: (value) => service.send({
|
|
93
|
+
type: "OPEN",
|
|
94
|
+
open: value
|
|
95
|
+
}),
|
|
96
|
+
getRootProps: () => normalize.element({
|
|
97
|
+
...part("root"),
|
|
98
|
+
lang: service.prop("lang"),
|
|
99
|
+
dir: service.prop("dir"),
|
|
100
|
+
"data-visual-target": "share-sheet-root"
|
|
101
|
+
}),
|
|
102
|
+
getGroupProps: (group) => normalize.element({
|
|
103
|
+
...part("group"),
|
|
104
|
+
role: "group",
|
|
105
|
+
"aria-label": group.label
|
|
106
|
+
}),
|
|
107
|
+
getActionProps: (action) => normalize.button({
|
|
108
|
+
...part("action"),
|
|
109
|
+
type: "button",
|
|
110
|
+
disabled: action.disabled,
|
|
111
|
+
"aria-label": action.label,
|
|
112
|
+
"data-value": action.value,
|
|
113
|
+
"data-visual-target": "share-sheet-action",
|
|
114
|
+
onClick: () => service.send({
|
|
115
|
+
type: "ACTIVATE",
|
|
116
|
+
source: action.source,
|
|
117
|
+
groupIndex: action.groupIndex,
|
|
118
|
+
index: action.index
|
|
119
|
+
})
|
|
120
|
+
}),
|
|
121
|
+
getIconState: (action) => resolveIconState({
|
|
122
|
+
id: `${service.scope.id}:share:${action.groupIndex}:${action.index}`,
|
|
123
|
+
name: action.icon
|
|
124
|
+
}),
|
|
125
|
+
getLabelProps: () => normalize.element(part("label")),
|
|
126
|
+
getDescriptionProps: () => normalize.element(part("description")),
|
|
127
|
+
getCancelProps: () => normalize.button({
|
|
128
|
+
...part("cancel"),
|
|
129
|
+
type: "button",
|
|
130
|
+
"data-visual-target": "share-sheet-cancel",
|
|
131
|
+
onClick: () => service.send({ type: "CANCEL" })
|
|
132
|
+
})
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
//#endregion
|
|
136
|
+
export { connectShareSheet, createShareSheetProps, resolveShareSheetGroups, shareSheetMachine };
|
|
137
|
+
|
|
138
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/share-sheet/share-sheet.ts"],"sourcesContent":["import { createMachine, type Machine, type Service } from \"@zag-js/core\";\nimport type { NormalizeProps, PropTypes } from \"@zag-js/types\";\nimport type { QwPopupProps } from \"../popup/popup.js\";\nimport { resolveIconState, type IconNameInput } from \"../icon/icon.js\";\n\nexport interface ShareSheetAction { value: string; label: string; icon: IconNameInput; description?: string; disabled?: boolean }\nexport interface ShareSheetGroup { label: string; actions: readonly ShareSheetAction[] }\nexport interface ShareSheetActionDetails { value: string; groupIndex: number; index: number }\nexport interface QwShareSheetProps extends Omit<QwPopupProps, \"placement\"> {\n /** Locale on the immediate Popup host; arbitrary outer ancestors are not copied into its portal. */\n lang?: string;\n dir?: string;\n groups?: readonly ShareSheetGroup[];\n /** Enabled actions request closing by default; no system share or network side effect. */\n closeOnAction?: boolean;\n cancelText?: string;\n onAction?: (details: ShareSheetActionDetails) => void;\n onCancel?: () => void;\n}\nexport interface QwShareSheetSchema {\n props: QwShareSheetProps;\n context: { open: boolean };\n state: \"ready\";\n action: \"open\" | \"activate\" | \"cancel\";\n event: { type: \"OPEN\"; open: boolean } | { type: \"ACTIVATE\"; source: ShareSheetAction; groupIndex: number; index: number } | { type: \"CANCEL\" };\n}\nexport type QwShareSheetService = Service<QwShareSheetSchema>;\nexport function createShareSheetProps(props: QwShareSheetProps = {}): QwShareSheetProps { return { ...props, groups: props.groups ?? [], ariaLabel: props.ariaLabel?.trim() || \"分享面板\" }; }\nexport function resolveShareSheetGroups(groups: readonly ShareSheetGroup[] = []) {\n const seen = new Set<string>();\n return groups.map((group, groupIndex) => ({ label: group.label, groupIndex, actions: group.actions.map((source, index) => {\n const duplicate = seen.has(source.value); seen.add(source.value);\n return { ...source, source, index, groupIndex, disabled: !!source.disabled || duplicate || !source.value.trim() || !source.label.trim(), duplicate };\n }) }));\n}\nexport const shareSheetMachine: Machine<QwShareSheetSchema> = createMachine<QwShareSheetSchema>({\n props: ({ props }) => createShareSheetProps(props), initialState: () => \"ready\", states: { ready: {} },\n context: ({ bindable, prop }) => ({ open: bindable(() => ({ defaultValue: prop(\"defaultOpen\") ?? false, value: prop(\"open\"), onChange: (open) => prop(\"onOpenChange\")?.(open) })) }),\n on: { OPEN: { actions: [\"open\"] }, ACTIVATE: { actions: [\"activate\"] }, CANCEL: { actions: [\"cancel\"] } },\n implementations: { actions: {\n open({ context, event }) { if (event.type === \"OPEN\") context.set(\"open\", event.open); },\n activate({ prop, context, event }) {\n if (event.type !== \"ACTIVATE\" || !context.get(\"open\")) return;\n const latest = resolveShareSheetGroups(prop(\"groups\"))[event.groupIndex]?.actions[event.index];\n if (!latest || latest.source !== event.source || latest.disabled) return;\n prop(\"onAction\")?.({ value: latest.value, groupIndex: event.groupIndex, index: event.index });\n if (prop(\"closeOnAction\") !== false) context.set(\"open\", false);\n },\n cancel({ prop, context }) { if (!context.get(\"open\")) return; prop(\"onCancel\")?.(); context.set(\"open\", false); },\n } },\n});\nexport function connectShareSheet<T extends PropTypes>(service: QwShareSheetService, normalize: NormalizeProps<T>) {\n const groups = resolveShareSheetGroups(service.prop(\"groups\")), open = service.context.get(\"open\");\n const part = (name: string) => ({ \"data-scope\": \"share-sheet\", \"data-part\": name });\n const popupProps: QwPopupProps = { id: `${service.scope.id}-popup`, open, title: service.prop(\"title\"), ariaLabel: service.prop(\"ariaLabel\"), closeLabel: service.prop(\"closeLabel\"), placement: \"bottom\", closeOnMaskClick: service.prop(\"closeOnMaskClick\"), disableBodyScroll: service.prop(\"disableBodyScroll\"), safeArea: service.prop(\"safeArea\"), returnFocus: service.prop(\"returnFocus\"), onOpenChange: (value) => service.send({ type: \"OPEN\", open: value }) };\n return { open, groups, popupProps, cancelText: service.prop(\"cancelText\")?.trim() || \"取消\",\n setOpen: (value: boolean) => service.send({ type: \"OPEN\", open: value }),\n getRootProps: () => normalize.element({ ...part(\"root\"), lang: service.prop(\"lang\"), dir: service.prop(\"dir\"), \"data-visual-target\": \"share-sheet-root\" }),\n getGroupProps: (group: (typeof groups)[number]) => normalize.element({ ...part(\"group\"), role: \"group\", \"aria-label\": group.label }),\n getActionProps: (action: (typeof groups)[number][\"actions\"][number]) => normalize.button({ ...part(\"action\"), type: \"button\", disabled: action.disabled, \"aria-label\": action.label, \"data-value\": action.value, \"data-visual-target\": \"share-sheet-action\", onClick: () => service.send({ type: \"ACTIVATE\", source: action.source, groupIndex: action.groupIndex, index: action.index }) }),\n getIconState: (action: (typeof groups)[number][\"actions\"][number]) => resolveIconState({ id: `${service.scope.id}:share:${action.groupIndex}:${action.index}`, name: action.icon }),\n getLabelProps: () => normalize.element(part(\"label\")), getDescriptionProps: () => normalize.element(part(\"description\")),\n getCancelProps: () => normalize.button({ ...part(\"cancel\"), type: \"button\", \"data-visual-target\": \"share-sheet-cancel\", onClick: () => service.send({ type: \"CANCEL\" }) }),\n };\n}\nexport type QwShareSheetApi<T extends PropTypes = PropTypes> = ReturnType<typeof connectShareSheet<T>>;\n"],"mappings":";;;AA2BA,SAAgB,sBAAsB,QAA2B,CAAC,GAAsB;CAAE,OAAO;EAAE,GAAG;EAAO,QAAQ,MAAM,UAAU,CAAC;EAAG,WAAW,MAAM,WAAW,KAAK,KAAK;CAAO;AAAG;AACzL,SAAgB,wBAAwB,SAAqC,CAAC,GAAG;CAC/E,MAAM,uBAAO,IAAI,IAAY;CAC7B,OAAO,OAAO,KAAK,OAAO,gBAAgB;EAAE,OAAO,MAAM;EAAO;EAAY,SAAS,MAAM,QAAQ,KAAK,QAAQ,UAAU;GACxH,MAAM,YAAY,KAAK,IAAI,OAAO,KAAK;GAAG,KAAK,IAAI,OAAO,KAAK;GAC/D,OAAO;IAAE,GAAG;IAAQ;IAAQ;IAAO;IAAY,UAAU,CAAC,CAAC,OAAO,YAAY,aAAa,CAAC,OAAO,MAAM,KAAK,KAAK,CAAC,OAAO,MAAM,KAAK;IAAG;GAAU;EACrJ,CAAC;CAAE,EAAE;AACP;AACA,MAAa,oBAAiD,cAAkC;CAC9F,QAAQ,EAAE,YAAY,sBAAsB,K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2BAA2B,UAAU,QAAQ,KAAK,aAAa,CAAC;EACvH,sBAAsB,UAAU,OAAO;GAAE,GAAG,KAAK,QAAQ;GAAG,MAAM;GAAU,sBAAsB;GAAsB,eAAe,QAAQ,KAAK,EAAE,MAAM,SAAS,CAAC;EAAE,CAAC;CAC3K;AACF"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { type Machine, type Service } from "@zag-js/core";
|
|
2
|
+
import type { NormalizeProps, PropTypes } from "@zag-js/types";
|
|
3
|
+
import type { QwPopupProps } from "../popup/popup.js";
|
|
4
|
+
import { type IconNameInput } from "../icon/icon.js";
|
|
5
|
+
export interface ShareSheetAction {
|
|
6
|
+
value: string;
|
|
7
|
+
label: string;
|
|
8
|
+
icon: IconNameInput;
|
|
9
|
+
description?: string;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface ShareSheetGroup {
|
|
13
|
+
label: string;
|
|
14
|
+
actions: readonly ShareSheetAction[];
|
|
15
|
+
}
|
|
16
|
+
export interface ShareSheetActionDetails {
|
|
17
|
+
value: string;
|
|
18
|
+
groupIndex: number;
|
|
19
|
+
index: number;
|
|
20
|
+
}
|
|
21
|
+
export interface QwShareSheetProps extends Omit<QwPopupProps, "placement"> {
|
|
22
|
+
/** Locale on the immediate Popup host; arbitrary outer ancestors are not copied into its portal. */
|
|
23
|
+
lang?: string;
|
|
24
|
+
dir?: string;
|
|
25
|
+
groups?: readonly ShareSheetGroup[];
|
|
26
|
+
/** Enabled actions request closing by default; no system share or network side effect. */
|
|
27
|
+
closeOnAction?: boolean;
|
|
28
|
+
cancelText?: string;
|
|
29
|
+
onAction?: (details: ShareSheetActionDetails) => void;
|
|
30
|
+
onCancel?: () => void;
|
|
31
|
+
}
|
|
32
|
+
export interface QwShareSheetSchema {
|
|
33
|
+
props: QwShareSheetProps;
|
|
34
|
+
context: {
|
|
35
|
+
open: boolean;
|
|
36
|
+
};
|
|
37
|
+
state: "ready";
|
|
38
|
+
action: "open" | "activate" | "cancel";
|
|
39
|
+
event: {
|
|
40
|
+
type: "OPEN";
|
|
41
|
+
open: boolean;
|
|
42
|
+
} | {
|
|
43
|
+
type: "ACTIVATE";
|
|
44
|
+
source: ShareSheetAction;
|
|
45
|
+
groupIndex: number;
|
|
46
|
+
index: number;
|
|
47
|
+
} | {
|
|
48
|
+
type: "CANCEL";
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export type QwShareSheetService = Service<QwShareSheetSchema>;
|
|
52
|
+
export declare function createShareSheetProps(props?: QwShareSheetProps): QwShareSheetProps;
|
|
53
|
+
export declare function resolveShareSheetGroups(groups?: readonly ShareSheetGroup[]): {
|
|
54
|
+
label: string;
|
|
55
|
+
groupIndex: number;
|
|
56
|
+
actions: {
|
|
57
|
+
value: string;
|
|
58
|
+
label: string;
|
|
59
|
+
icon: IconNameInput;
|
|
60
|
+
description?: string;
|
|
61
|
+
source: ShareSheetAction;
|
|
62
|
+
index: number;
|
|
63
|
+
groupIndex: number;
|
|
64
|
+
disabled: boolean;
|
|
65
|
+
duplicate: boolean;
|
|
66
|
+
}[];
|
|
67
|
+
}[];
|
|
68
|
+
export declare const shareSheetMachine: Machine<QwShareSheetSchema>;
|
|
69
|
+
export declare function connectShareSheet<T extends PropTypes>(service: QwShareSheetService, normalize: NormalizeProps<T>): {
|
|
70
|
+
open: boolean;
|
|
71
|
+
groups: {
|
|
72
|
+
label: string;
|
|
73
|
+
groupIndex: number;
|
|
74
|
+
actions: {
|
|
75
|
+
value: string;
|
|
76
|
+
label: string;
|
|
77
|
+
icon: IconNameInput;
|
|
78
|
+
description?: string;
|
|
79
|
+
source: ShareSheetAction;
|
|
80
|
+
index: number;
|
|
81
|
+
groupIndex: number;
|
|
82
|
+
disabled: boolean;
|
|
83
|
+
duplicate: boolean;
|
|
84
|
+
}[];
|
|
85
|
+
}[];
|
|
86
|
+
popupProps: QwPopupProps;
|
|
87
|
+
cancelText: string;
|
|
88
|
+
setOpen: (value: boolean) => void;
|
|
89
|
+
getRootProps: () => T["element"];
|
|
90
|
+
getGroupProps: (group: ({
|
|
91
|
+
label: string;
|
|
92
|
+
groupIndex: number;
|
|
93
|
+
actions: {
|
|
94
|
+
value: string;
|
|
95
|
+
label: string;
|
|
96
|
+
icon: IconNameInput;
|
|
97
|
+
description?: string;
|
|
98
|
+
source: ShareSheetAction;
|
|
99
|
+
index: number;
|
|
100
|
+
groupIndex: number;
|
|
101
|
+
disabled: boolean;
|
|
102
|
+
duplicate: boolean;
|
|
103
|
+
}[];
|
|
104
|
+
}[])[number]) => T["element"];
|
|
105
|
+
getActionProps: (action: ({
|
|
106
|
+
label: string;
|
|
107
|
+
groupIndex: number;
|
|
108
|
+
actions: {
|
|
109
|
+
value: string;
|
|
110
|
+
label: string;
|
|
111
|
+
icon: IconNameInput;
|
|
112
|
+
description?: string;
|
|
113
|
+
source: ShareSheetAction;
|
|
114
|
+
index: number;
|
|
115
|
+
groupIndex: number;
|
|
116
|
+
disabled: boolean;
|
|
117
|
+
duplicate: boolean;
|
|
118
|
+
}[];
|
|
119
|
+
}[])[number]["actions"][number]) => T["button"];
|
|
120
|
+
getIconState: (action: ({
|
|
121
|
+
label: string;
|
|
122
|
+
groupIndex: number;
|
|
123
|
+
actions: {
|
|
124
|
+
value: string;
|
|
125
|
+
label: string;
|
|
126
|
+
icon: IconNameInput;
|
|
127
|
+
description?: string;
|
|
128
|
+
source: ShareSheetAction;
|
|
129
|
+
index: number;
|
|
130
|
+
groupIndex: number;
|
|
131
|
+
disabled: boolean;
|
|
132
|
+
duplicate: boolean;
|
|
133
|
+
}[];
|
|
134
|
+
}[])[number]["actions"][number]) => import("../index.js").IconState;
|
|
135
|
+
getLabelProps: () => T["element"];
|
|
136
|
+
getDescriptionProps: () => T["element"];
|
|
137
|
+
getCancelProps: () => T["button"];
|
|
138
|
+
};
|
|
139
|
+
export type QwShareSheetApi<T extends PropTypes = PropTypes> = ReturnType<typeof connectShareSheet<T>>;
|
package/dist/skeleton/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region src/skeleton/skeleton.ts
|
|
2
2
|
/**
|
|
3
|
-
* Skeleton 契约 — 原型 A(无状态),
|
|
3
|
+
* Skeleton 契约 — 原型 A(无状态),Core 无 machine,承载三栈共享的类型与渲染契约。
|
|
4
4
|
* 渲染契约:`data-scope="skeleton"`,`aria-hidden="true"`;
|
|
5
5
|
* data-part 为 root / line;流光动效纯 CSS,尊重 `prefers-reduced-motion`。
|
|
6
6
|
*
|
|
@@ -22,7 +22,56 @@ const SKELETON_RADII = [
|
|
|
22
22
|
];
|
|
23
23
|
/** Skeleton 各渲染部位全集(data-part 取值)。 */
|
|
24
24
|
const SKELETON_PARTS = ["root", "line"];
|
|
25
|
+
const radiusVariables = {
|
|
26
|
+
control: "var(--qw-sem-size-radius-control)",
|
|
27
|
+
card: "var(--qw-sem-size-radius-card)",
|
|
28
|
+
full: "var(--qw-sem-size-radius-full)"
|
|
29
|
+
};
|
|
30
|
+
const length = (value) => typeof value === "number" ? `${value}px` : value;
|
|
31
|
+
/** Rendering, dimensions and invalid-input handling are shared by all adapters. */
|
|
32
|
+
function resolveSkeletonState(props = {}) {
|
|
33
|
+
const variant = SKELETON_VARIANTS.includes(props.variant) ? props.variant : "text";
|
|
34
|
+
const animation = SKELETON_ANIMATIONS.includes(props.animation) ? props.animation : "wave";
|
|
35
|
+
const radius = variant !== "circle" && SKELETON_RADII.includes(props.radius) ? props.radius : void 0;
|
|
36
|
+
const lines = Number.isInteger(props.lines) && props.lines > 0 && props.lines <= 4294967295 ? props.lines : 1;
|
|
37
|
+
const style = {};
|
|
38
|
+
if (props.width != null) style["--qw-skeleton-w"] = length(props.width);
|
|
39
|
+
if (props.height != null) style["--qw-skeleton-h"] = length(props.height);
|
|
40
|
+
if (radius) style["--qw-skeleton-r"] = radiusVariables[radius];
|
|
41
|
+
return {
|
|
42
|
+
variant,
|
|
43
|
+
animation,
|
|
44
|
+
radius,
|
|
45
|
+
lines,
|
|
46
|
+
style,
|
|
47
|
+
lineItems: variant === "text" && lines > 1 ? Array.from({ length: lines }, (_, index) => ({
|
|
48
|
+
index,
|
|
49
|
+
last: index === lines - 1
|
|
50
|
+
})) : []
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function getSkeletonRootProps(state) {
|
|
54
|
+
return {
|
|
55
|
+
"data-scope": "skeleton",
|
|
56
|
+
"data-part": "root",
|
|
57
|
+
"data-variant": state.variant,
|
|
58
|
+
"data-animation": state.animation,
|
|
59
|
+
"data-radius": state.radius,
|
|
60
|
+
"data-lines": state.lineItems.length ? state.lines : void 0,
|
|
61
|
+
"aria-hidden": "true"
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function getSkeletonStyle(state) {
|
|
65
|
+
return state.style;
|
|
66
|
+
}
|
|
67
|
+
function getSkeletonLineProps(line) {
|
|
68
|
+
return {
|
|
69
|
+
"data-scope": "skeleton",
|
|
70
|
+
"data-part": "line",
|
|
71
|
+
"data-last": line.last ? "true" : void 0
|
|
72
|
+
};
|
|
73
|
+
}
|
|
25
74
|
//#endregion
|
|
26
|
-
export { SKELETON_ANIMATIONS, SKELETON_PARTS, SKELETON_RADII, SKELETON_VARIANTS };
|
|
75
|
+
export { SKELETON_ANIMATIONS, SKELETON_PARTS, SKELETON_RADII, SKELETON_VARIANTS, getSkeletonLineProps, getSkeletonRootProps, getSkeletonStyle, resolveSkeletonState };
|
|
27
76
|
|
|
28
77
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/skeleton/skeleton.ts"],"sourcesContent":["/**\n * Skeleton 契约 — 原型 A(无状态),
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/skeleton/skeleton.ts"],"sourcesContent":["/**\n * Skeleton 契约 — 原型 A(无状态),Core 无 machine,承载三栈共享的类型与渲染契约。\n * 渲染契约:`data-scope=\"skeleton\"`,`aria-hidden=\"true\"`;\n * data-part 为 root / line;流光动效纯 CSS,尊重 `prefers-reduced-motion`。\n *\n * 形状 / 动效 / 圆角词表以运行时常量数组为唯一事实源(类型从常量推导),__test__ 直接锁死。\n */\n\n/** 形状全集:text 文本条 / circle 头像 / rect 图片卡片块。 */\nexport const SKELETON_VARIANTS = [\"text\", \"circle\", \"rect\"] as const;\n\n/** 动效全集:wave 流光(默认)/ none 静态。 */\nexport const SKELETON_ANIMATIONS = [\"wave\", \"none\"] as const;\n\n/** 圆角档位全集。 */\nexport const SKELETON_RADII = [\"control\", \"card\", \"full\"] as const;\n\n/** Skeleton 各渲染部位全集(data-part 取值)。 */\nexport const SKELETON_PARTS = [\"root\", \"line\"] as const;\n\nexport type SkeletonVariant = (typeof SKELETON_VARIANTS)[number];\nexport type SkeletonAnimation = (typeof SKELETON_ANIMATIONS)[number];\nexport type SkeletonRadius = (typeof SKELETON_RADII)[number];\nexport type SkeletonPart = (typeof SKELETON_PARTS)[number];\n\n/**\n * QwSkeletonProps — 三栈共享的行为与渲染契约。\n * 几何 width/height 的 number|string 形式是框架无关的;\n * 富内容不涉及(骨架不承载文本)。\n */\nexport interface QwSkeletonProps {\n /** 形状,默认 text。 */\n variant?: SkeletonVariant;\n /** 动效,默认 wave。 */\n animation?: SkeletonAnimation;\n /** 宽度,数值按 px 处理。 */\n width?: number | string;\n /** 高度,数值按 px 处理。 */\n height?: number | string;\n /** 圆角档位(circle 使用 full 圆角,忽略此项;显式宽高可独立设置)。 */\n radius?: SkeletonRadius;\n /** 仅 text:一次渲染多行文本条,末行更短。默认 1。 */\n lines?: number;\n}\n\n\nexport interface SkeletonLine { readonly index: number; readonly last: boolean }\nexport interface ResolvedSkeletonState {\n variant: SkeletonVariant; animation: SkeletonAnimation; radius?: SkeletonRadius; lines: number;\n style: Readonly<Record<string, string>>; lineItems: readonly SkeletonLine[];\n}\nconst radiusVariables: Record<SkeletonRadius, string> = {\n control: \"var(--qw-sem-size-radius-control)\", card: \"var(--qw-sem-size-radius-card)\", full: \"var(--qw-sem-size-radius-full)\",\n};\nconst length = (value: number | string): string => typeof value === \"number\" ? `${value}px` : value;\n/** Rendering, dimensions and invalid-input handling are shared by all adapters. */\nexport function resolveSkeletonState(props: QwSkeletonProps = {}): ResolvedSkeletonState {\n const variant = SKELETON_VARIANTS.includes(props.variant!) ? props.variant! : \"text\";\n const animation = SKELETON_ANIMATIONS.includes(props.animation!) ? props.animation! : \"wave\";\n const radius = variant !== \"circle\" && SKELETON_RADII.includes(props.radius!) ? props.radius : undefined;\n const lines = Number.isInteger(props.lines) && props.lines! > 0 && props.lines! <= 0xffff_ffff ? props.lines! : 1;\n const style: Record<string, string> = {};\n if (props.width != null) style[\"--qw-skeleton-w\"] = length(props.width);\n if (props.height != null) style[\"--qw-skeleton-h\"] = length(props.height);\n if (radius) style[\"--qw-skeleton-r\"] = radiusVariables[radius];\n return { variant, animation, radius, lines, style, lineItems: variant === \"text\" && lines > 1 ? Array.from({ length: lines }, (_, index) => ({ index, last: index === lines - 1 })) : [] };\n}\nexport interface SkeletonRootProps {\n \"data-scope\": \"skeleton\"; \"data-part\": \"root\"; \"data-variant\": SkeletonVariant; \"data-animation\": SkeletonAnimation;\n \"data-radius\"?: SkeletonRadius; \"data-lines\"?: number; \"aria-hidden\": \"true\";\n}\nexport function getSkeletonRootProps(state: ResolvedSkeletonState): SkeletonRootProps {\n return { \"data-scope\": \"skeleton\", \"data-part\": \"root\", \"data-variant\": state.variant, \"data-animation\": state.animation,\n \"data-radius\": state.radius, \"data-lines\": state.lineItems.length ? state.lines : undefined, \"aria-hidden\": \"true\" };\n}\nexport function getSkeletonStyle(state: ResolvedSkeletonState): Readonly<Record<string, string>> { return state.style; }\nexport interface SkeletonLineProps { \"data-scope\": \"skeleton\"; \"data-part\": \"line\"; \"data-last\"?: \"true\" }\nexport function getSkeletonLineProps(line: SkeletonLine): SkeletonLineProps {\n return { \"data-scope\": \"skeleton\", \"data-part\": \"line\", \"data-last\": line.last ? \"true\" : undefined };\n}\n"],"mappings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A;EAAW,eAAe;CAAO;AACvH;AACA,SAAgB,iBAAiB,OAAgE;CAAE,OAAO,MAAM;AAAO;AAEvH,SAAgB,qBAAqB,MAAuC;CAC1E,OAAO;EAAE,cAAc;EAAY,aAAa;EAAQ,aAAa,KAAK,OAAO,SAAS,KAAA;CAAU;AACtG"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Skeleton 契约 — 原型 A(无状态),
|
|
2
|
+
* Skeleton 契约 — 原型 A(无状态),Core 无 machine,承载三栈共享的类型与渲染契约。
|
|
3
3
|
* 渲染契约:`data-scope="skeleton"`,`aria-hidden="true"`;
|
|
4
4
|
* data-part 为 root / line;流光动效纯 CSS,尊重 `prefers-reduced-motion`。
|
|
5
5
|
*
|
|
@@ -18,7 +18,7 @@ export type SkeletonAnimation = (typeof SKELETON_ANIMATIONS)[number];
|
|
|
18
18
|
export type SkeletonRadius = (typeof SKELETON_RADII)[number];
|
|
19
19
|
export type SkeletonPart = (typeof SKELETON_PARTS)[number];
|
|
20
20
|
/**
|
|
21
|
-
* QwSkeletonProps —
|
|
21
|
+
* QwSkeletonProps — 三栈共享的行为与渲染契约。
|
|
22
22
|
* 几何 width/height 的 number|string 形式是框架无关的;
|
|
23
23
|
* 富内容不涉及(骨架不承载文本)。
|
|
24
24
|
*/
|
|
@@ -31,8 +31,39 @@ export interface QwSkeletonProps {
|
|
|
31
31
|
width?: number | string;
|
|
32
32
|
/** 高度,数值按 px 处理。 */
|
|
33
33
|
height?: number | string;
|
|
34
|
-
/** 圆角档位(circle
|
|
34
|
+
/** 圆角档位(circle 使用 full 圆角,忽略此项;显式宽高可独立设置)。 */
|
|
35
35
|
radius?: SkeletonRadius;
|
|
36
36
|
/** 仅 text:一次渲染多行文本条,末行更短。默认 1。 */
|
|
37
37
|
lines?: number;
|
|
38
38
|
}
|
|
39
|
+
export interface SkeletonLine {
|
|
40
|
+
readonly index: number;
|
|
41
|
+
readonly last: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface ResolvedSkeletonState {
|
|
44
|
+
variant: SkeletonVariant;
|
|
45
|
+
animation: SkeletonAnimation;
|
|
46
|
+
radius?: SkeletonRadius;
|
|
47
|
+
lines: number;
|
|
48
|
+
style: Readonly<Record<string, string>>;
|
|
49
|
+
lineItems: readonly SkeletonLine[];
|
|
50
|
+
}
|
|
51
|
+
/** Rendering, dimensions and invalid-input handling are shared by all adapters. */
|
|
52
|
+
export declare function resolveSkeletonState(props?: QwSkeletonProps): ResolvedSkeletonState;
|
|
53
|
+
export interface SkeletonRootProps {
|
|
54
|
+
"data-scope": "skeleton";
|
|
55
|
+
"data-part": "root";
|
|
56
|
+
"data-variant": SkeletonVariant;
|
|
57
|
+
"data-animation": SkeletonAnimation;
|
|
58
|
+
"data-radius"?: SkeletonRadius;
|
|
59
|
+
"data-lines"?: number;
|
|
60
|
+
"aria-hidden": "true";
|
|
61
|
+
}
|
|
62
|
+
export declare function getSkeletonRootProps(state: ResolvedSkeletonState): SkeletonRootProps;
|
|
63
|
+
export declare function getSkeletonStyle(state: ResolvedSkeletonState): Readonly<Record<string, string>>;
|
|
64
|
+
export interface SkeletonLineProps {
|
|
65
|
+
"data-scope": "skeleton";
|
|
66
|
+
"data-part": "line";
|
|
67
|
+
"data-last"?: "true";
|
|
68
|
+
}
|
|
69
|
+
export declare function getSkeletonLineProps(line: SkeletonLine): SkeletonLineProps;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./slider.js";
|