@qw-ui/core 0.3.0-next.8 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -37
- package/dist/action-sheet/action-sheet.d.ts +110 -0
- package/dist/action-sheet/index.d.ts +2 -0
- package/dist/action-sheet/index.js +2 -0
- package/dist/action-sheet-Cvcr1S_m.js +183 -0
- package/dist/action-sheet-Cvcr1S_m.js.map +1 -0
- package/dist/area-picker/area-picker.d.ts +113 -0
- package/dist/area-picker/index.d.ts +1 -0
- package/dist/area-picker/index.js +348 -0
- package/dist/area-picker/index.js.map +1 -0
- package/dist/aria-description-CimD2M_C.js +13 -0
- package/dist/aria-description-CimD2M_C.js.map +1 -0
- package/dist/aria-description.d.ts +2 -0
- package/dist/avatar/avatar-load.d.ts +76 -0
- package/dist/avatar/avatar.d.ts +22 -5
- package/dist/avatar/index.d.ts +1 -0
- package/dist/avatar/index.js +57 -18
- package/dist/avatar/index.js.map +1 -1
- package/dist/avatar-load-w9dq05oV.js +139 -0
- package/dist/avatar-load-w9dq05oV.js.map +1 -0
- package/dist/back-top/back-top.d.ts +77 -0
- package/dist/back-top/index.d.ts +1 -0
- package/dist/back-top/index.js +189 -0
- package/dist/back-top/index.js.map +1 -0
- package/dist/badge/badge.d.ts +85 -0
- package/dist/badge/index.d.ts +1 -0
- package/dist/badge/index.js +88 -0
- package/dist/badge/index.js.map +1 -0
- package/dist/button/button.d.ts +13 -0
- package/dist/button/index.js +3 -5
- package/dist/button/index.js.map +1 -1
- package/dist/calendar/calendar.d.ts +100 -0
- package/dist/calendar/index.d.ts +1 -0
- package/dist/calendar/index.js +2 -0
- package/dist/calendar-CmpK3stz.js +363 -0
- package/dist/calendar-CmpK3stz.js.map +1 -0
- package/dist/card/card.d.ts +68 -0
- package/dist/card/index.d.ts +2 -0
- package/dist/card/index.js +2 -0
- package/dist/card-DRtWa6Cr.js +107 -0
- package/dist/card-DRtWa6Cr.js.map +1 -0
- package/dist/cascader/cascader.d.ts +115 -0
- package/dist/cascader/index.d.ts +1 -0
- package/dist/cascader/index.js +2 -0
- package/dist/cascader-D-xMjs7P.js +333 -0
- package/dist/cascader-D-xMjs7P.js.map +1 -0
- package/dist/cell/cell.d.ts +41 -0
- package/dist/cell/index.d.ts +1 -0
- package/dist/cell/index.js +43 -0
- package/dist/cell/index.js.map +1 -0
- package/dist/check-list/check-list.d.ts +78 -0
- package/dist/check-list/index.d.ts +2 -0
- package/dist/check-list/index.js +2 -0
- package/dist/check-list-BvZHQt5w.js +60 -0
- package/dist/check-list-BvZHQt5w.js.map +1 -0
- package/dist/checkbox/checkbox.d.ts +59 -0
- package/dist/checkbox/index.d.ts +2 -0
- package/dist/checkbox/index.js +2 -0
- package/dist/checkbox-BlndJrz5.js +127 -0
- package/dist/checkbox-BlndJrz5.js.map +1 -0
- package/dist/checkbox-group/checkbox-group.d.ts +86 -0
- package/dist/checkbox-group/index.d.ts +3 -0
- package/dist/checkbox-group/index.js +2 -0
- package/dist/checkbox-group-gGfsTv-e.js +223 -0
- package/dist/checkbox-group-gGfsTv-e.js.map +1 -0
- package/dist/choice-group-C4c9m0qe.js +373 -0
- package/dist/choice-group-C4c9m0qe.js.map +1 -0
- package/dist/circle/circle.d.ts +97 -0
- package/dist/circle/index.d.ts +1 -0
- package/dist/circle/index.js +119 -0
- package/dist/circle/index.js.map +1 -0
- package/dist/collapse/collapse.d.ts +98 -0
- package/dist/collapse/index.d.ts +2 -0
- package/dist/collapse/index.js +2 -0
- package/dist/collapse-B969h7-H.js +226 -0
- package/dist/collapse-B969h7-H.js.map +1 -0
- package/dist/countdown/countdown.d.ts +114 -0
- package/dist/countdown/index.d.ts +1 -0
- package/dist/countdown/index.js +309 -0
- package/dist/countdown/index.js.map +1 -0
- package/dist/date-picker/date-picker.d.ts +168 -0
- package/dist/date-picker/index.d.ts +1 -0
- package/dist/date-picker/index.js +401 -0
- package/dist/date-picker/index.js.map +1 -0
- package/dist/descriptions/descriptions.d.ts +69 -0
- package/dist/descriptions/index.d.ts +1 -0
- package/dist/descriptions/index.js +86 -0
- package/dist/descriptions/index.js.map +1 -0
- package/dist/dialog/dialog.d.ts +61 -43
- package/dist/dialog/index.js +73 -19
- package/dist/dialog/index.js.map +1 -1
- package/dist/divider/divider.d.ts +18 -2
- package/dist/divider/index.js +20 -2
- package/dist/divider/index.js.map +1 -1
- package/dist/dropdown/dropdown.d.ts +172 -0
- package/dist/dropdown/index.d.ts +2 -0
- package/dist/dropdown/index.js +467 -0
- package/dist/dropdown/index.js.map +1 -0
- package/dist/ellipsis/ellipsis-layout.d.ts +34 -0
- package/dist/ellipsis/ellipsis.d.ts +88 -0
- package/dist/ellipsis/index.d.ts +2 -0
- package/dist/ellipsis/index.js +320 -0
- package/dist/ellipsis/index.js.map +1 -0
- package/dist/empty/empty-illustration.d.ts +3 -0
- package/dist/empty/empty.d.ts +43 -1
- package/dist/empty/index.js +2 -21
- package/dist/empty-CAgyvhUI.js +166 -0
- package/dist/empty-CAgyvhUI.js.map +1 -0
- package/dist/field/field.d.ts +95 -0
- package/dist/field/index.d.ts +2 -0
- package/dist/field/index.js +2 -0
- package/dist/field-DMHGIMZF.js +241 -0
- package/dist/field-DMHGIMZF.js.map +1 -0
- package/dist/floating-bubble/floating-bubble.d.ts +116 -0
- package/dist/floating-bubble/index.d.ts +1 -0
- package/dist/floating-bubble/index.js +333 -0
- package/dist/floating-bubble/index.js.map +1 -0
- package/dist/floating-panel/floating-panel.d.ts +80 -0
- package/dist/floating-panel/index.d.ts +2 -0
- package/dist/floating-panel/index.js +2 -0
- package/dist/floating-panel-Cbm5njBJ.js +363 -0
- package/dist/floating-panel-Cbm5njBJ.js.map +1 -0
- package/dist/footer/footer.d.ts +94 -0
- package/dist/footer/index.d.ts +1 -0
- package/dist/footer/index.js +154 -0
- package/dist/footer/index.js.map +1 -0
- package/dist/form/connect.d.ts +6 -0
- package/dist/form/form.d.ts +100 -0
- package/dist/form/ids.d.ts +14 -0
- package/dist/form/index.d.ts +13 -0
- package/dist/form/index.js +3 -0
- package/dist/form/methods.d.ts +5 -0
- package/dist/form/model.d.ts +24 -0
- package/dist/form/native.d.ts +25 -0
- package/dist/form/rules.d.ts +40 -0
- package/dist/form/ssr.d.ts +7 -0
- package/dist/form/types.d.ts +150 -0
- package/dist/form-BAGkIEMY.js +1354 -0
- package/dist/form-BAGkIEMY.js.map +1 -0
- package/dist/format-BDUY0C_c.js +89 -0
- package/dist/format-BDUY0C_c.js.map +1 -0
- package/dist/gesture-_SRHIvBm.js +30 -0
- package/dist/gesture-_SRHIvBm.js.map +1 -0
- package/dist/grid/grid-item.d.ts +22 -0
- package/dist/grid/grid.d.ts +42 -0
- package/dist/grid/index.d.ts +2 -0
- package/dist/grid/index.js +73 -0
- package/dist/grid/index.js.map +1 -0
- package/dist/icon/icon.d.ts +37 -1
- package/dist/icon/identity.d.ts +3 -0
- package/dist/icon/index.js +2 -20
- package/dist/icon-Cgdbnk1u.js +77 -0
- package/dist/icon-Cgdbnk1u.js.map +1 -0
- package/dist/image/image-load.d.ts +24 -0
- package/dist/image/image.d.ts +45 -8
- package/dist/image/index.d.ts +1 -0
- package/dist/image/index.js +116 -14
- package/dist/image/index.js.map +1 -1
- package/dist/image-preview/image-preview.d.ts +124 -0
- package/dist/image-preview/index.d.ts +1 -0
- package/dist/image-preview/index.js +450 -0
- package/dist/image-preview/index.js.map +1 -0
- package/dist/index-bar/index-bar.d.ts +121 -0
- package/dist/index-bar/index.d.ts +1 -0
- package/dist/index-bar/index.js +386 -0
- package/dist/index-bar/index.js.map +1 -0
- package/dist/index.d.ts +115 -10
- package/dist/index.js +151 -11
- package/dist/index.js.map +1 -0
- package/dist/infinite-scroll/index.d.ts +1 -0
- package/dist/infinite-scroll/index.js +248 -0
- package/dist/infinite-scroll/index.js.map +1 -0
- package/dist/infinite-scroll/infinite-scroll.d.ts +95 -0
- package/dist/input/index.js +181 -22
- package/dist/input/index.js.map +1 -1
- package/dist/input/input.d.ts +44 -1
- package/dist/layer-IpFrl5--.js +414 -0
- package/dist/layer-IpFrl5--.js.map +1 -0
- package/dist/layout-BRSqi4AQ.js +43 -0
- package/dist/layout-BRSqi4AQ.js.map +1 -0
- package/dist/layout.d.ts +13 -0
- package/dist/list/index.d.ts +2 -0
- package/dist/list/index.js +2 -0
- package/dist/list/list.d.ts +30 -0
- package/dist/list-6-iz-Irh.js +28 -0
- package/dist/list-6-iz-Irh.js.map +1 -0
- package/dist/loading/index.js +45 -2
- package/dist/loading/index.js.map +1 -1
- package/dist/loading/loading.d.ts +45 -2
- package/dist/modal-dialog-machine-CF9_z3Dm.js +487 -0
- package/dist/modal-dialog-machine-CF9_z3Dm.js.map +1 -0
- package/dist/modal-dialog-machine.d.ts +21 -0
- package/dist/modal-dismissable-lifetime.d.ts +21 -0
- package/dist/modal-registry.d.ts +24 -0
- package/dist/modal-render-hydration.d.ts +35 -0
- package/dist/modal-render-runtime.d.ts +19 -0
- package/dist/modal-render-scope.d.ts +63 -0
- package/dist/nav-bar/index.d.ts +1 -0
- package/dist/nav-bar/index.js +115 -0
- package/dist/nav-bar/index.js.map +1 -0
- package/dist/nav-bar/nav-bar.d.ts +76 -0
- package/dist/notice-bar/index.d.ts +2 -0
- package/dist/notice-bar/index.js +2 -0
- package/dist/notice-bar/notice-bar.d.ts +103 -0
- package/dist/notice-bar-DMpwLvRb.js +231 -0
- package/dist/notice-bar-DMpwLvRb.js.map +1 -0
- package/dist/notify/index.d.ts +1 -0
- package/dist/notify/index.js +251 -0
- package/dist/notify/index.js.map +1 -0
- package/dist/notify/notify.d.ts +123 -0
- package/dist/number-keyboard/index.d.ts +1 -0
- package/dist/number-keyboard/index.js +333 -0
- package/dist/number-keyboard/index.js.map +1 -0
- package/dist/number-keyboard/number-keyboard.d.ts +141 -0
- package/dist/overlay-panel/index.d.ts +2 -0
- package/dist/overlay-panel/index.js +2 -0
- package/dist/overlay-panel/overlay-panel.d.ts +20 -0
- package/dist/overlay-panel-Z_qdKeBj.js +26 -0
- package/dist/overlay-panel-Z_qdKeBj.js.map +1 -0
- package/dist/page-indicator/index.d.ts +1 -0
- package/dist/page-indicator/index.js +138 -0
- package/dist/page-indicator/index.js.map +1 -0
- package/dist/page-indicator/page-indicator.d.ts +93 -0
- package/dist/pagination/index.d.ts +1 -0
- package/dist/pagination/index.js +198 -0
- package/dist/pagination/index.js.map +1 -0
- package/dist/pagination/pagination.d.ts +125 -0
- package/dist/password-input/index.d.ts +1 -0
- package/dist/password-input/index.js +317 -0
- package/dist/password-input/index.js.map +1 -0
- package/dist/password-input/password-input.d.ts +144 -0
- package/dist/picker/index.d.ts +8 -0
- package/dist/picker/index.js +2 -0
- package/dist/picker/picker-machine.d.ts +80 -0
- package/dist/picker/picker.d.ts +121 -0
- package/dist/picker/platform.d.ts +84 -0
- package/dist/picker/selection-connect.d.ts +90 -0
- package/dist/picker/selection-model.d.ts +211 -0
- package/dist/picker-BykFntQN.js +1675 -0
- package/dist/picker-BykFntQN.js.map +1 -0
- package/dist/popover/index.d.ts +3 -0
- package/dist/popover/index.js +253 -0
- package/dist/popover/index.js.map +1 -0
- package/dist/popover/layer.d.ts +44 -0
- package/dist/popover/popover.d.ts +104 -0
- package/dist/popover/positioning.d.ts +132 -0
- package/dist/popup/index.d.ts +2 -0
- package/dist/popup/index.js +2 -0
- package/dist/popup/popup.d.ts +60 -0
- package/dist/popup-z5d8IYCt.js +576 -0
- package/dist/popup-z5d8IYCt.js.map +1 -0
- package/dist/portal-BHCNTWhg.js +78 -0
- package/dist/portal-BHCNTWhg.js.map +1 -0
- package/dist/portal.d.ts +61 -0
- package/dist/price/format.d.ts +19 -0
- package/dist/price/index.d.ts +1 -0
- package/dist/price/index.js +154 -0
- package/dist/price/index.js.map +1 -0
- package/dist/price/price.d.ts +88 -0
- package/dist/progress/index.d.ts +1 -0
- package/dist/progress/index.js +2 -0
- package/dist/progress/progress.d.ts +32 -0
- package/dist/progress-f3iYEfdA.js +37 -0
- package/dist/progress-f3iYEfdA.js.map +1 -0
- package/dist/pull-refresh/index.d.ts +1 -0
- package/dist/pull-refresh/index.js +414 -0
- package/dist/pull-refresh/index.js.map +1 -0
- package/dist/pull-refresh/pull-refresh.d.ts +118 -0
- package/dist/radio-group/index.d.ts +3 -0
- package/dist/radio-group/index.js +2 -0
- package/dist/radio-group/radio-group.d.ts +78 -0
- package/dist/radio-group-BOIMuqnS.js +230 -0
- package/dist/radio-group-BOIMuqnS.js.map +1 -0
- package/dist/rate/index.d.ts +1 -0
- package/dist/rate/index.js +2 -0
- package/dist/rate/rate-form.d.ts +28 -0
- package/dist/rate/rate.d.ts +144 -0
- package/dist/rate-5XsU2QkY.js +631 -0
- package/dist/rate-5XsU2QkY.js.map +1 -0
- package/dist/reorder/index.d.ts +1 -0
- package/dist/reorder/index.js +720 -0
- package/dist/reorder/index.js.map +1 -0
- package/dist/reorder/reorder.d.ts +190 -0
- package/dist/result/index.d.ts +1 -0
- package/dist/result/index.js +123 -0
- package/dist/result/index.js.map +1 -0
- package/dist/result/result.d.ts +88 -0
- package/dist/safe-area/index.d.ts +1 -0
- package/dist/safe-area/index.js +42 -0
- package/dist/safe-area/index.js.map +1 -0
- package/dist/safe-area/safe-area.d.ts +28 -0
- package/dist/search-bar/index.js +4 -2
- package/dist/search-bar/index.js.map +1 -1
- package/dist/search-bar/search-bar.d.ts +6 -0
- package/dist/segmented/index.d.ts +2 -0
- package/dist/segmented/index.js +2 -0
- package/dist/segmented/segmented.d.ts +127 -0
- package/dist/segmented-BaU38_L4.js +367 -0
- package/dist/segmented-BaU38_L4.js.map +1 -0
- package/dist/selection-form-BOM_odUk.js +88 -0
- package/dist/selection-form-BOM_odUk.js.map +1 -0
- package/dist/selection-form.d.ts +27 -0
- package/dist/selection-ivXqO1eu.js +55 -0
- package/dist/selection-ivXqO1eu.js.map +1 -0
- package/dist/selection.d.ts +29 -0
- package/dist/selector/choice-group.d.ts +114 -0
- package/dist/selector/index.d.ts +2 -0
- package/dist/selector/index.js +2 -0
- package/dist/selector/selector.d.ts +90 -0
- package/dist/selector-BU2MMJ4N.js +93 -0
- package/dist/selector-BU2MMJ4N.js.map +1 -0
- package/dist/share-sheet/index.d.ts +1 -0
- package/dist/share-sheet/index.js +138 -0
- package/dist/share-sheet/index.js.map +1 -0
- package/dist/share-sheet/share-sheet.d.ts +139 -0
- package/dist/side-nav/index.d.ts +1 -0
- package/dist/side-nav/index.js +99 -0
- package/dist/side-nav/index.js.map +1 -0
- package/dist/side-nav/side-nav.d.ts +94 -0
- package/dist/skeleton/index.js +51 -2
- package/dist/skeleton/index.js.map +1 -1
- package/dist/skeleton/skeleton.d.ts +34 -3
- package/dist/slider/index.d.ts +1 -0
- package/dist/slider/index.js +482 -0
- package/dist/slider/index.js.map +1 -0
- package/dist/slider/slider.d.ts +174 -0
- package/dist/space/index.d.ts +1 -0
- package/dist/space/index.js +52 -0
- package/dist/space/index.js.map +1 -0
- package/dist/space/space.d.ts +46 -0
- package/dist/statistic/index.d.ts +1 -0
- package/dist/statistic/index.js +152 -0
- package/dist/statistic/index.js.map +1 -0
- package/dist/statistic/statistic.d.ts +101 -0
- package/dist/stepper/index.d.ts +1 -0
- package/dist/stepper/index.js +172 -0
- package/dist/stepper/index.js.map +1 -0
- package/dist/stepper/stepper.d.ts +161 -0
- package/dist/steps/index.d.ts +1 -0
- package/dist/steps/index.js +72 -0
- package/dist/steps/index.js.map +1 -0
- package/dist/steps/steps.d.ts +67 -0
- package/dist/sticky/index.d.ts +1 -0
- package/dist/sticky/index.js +145 -0
- package/dist/sticky/index.js.map +1 -0
- package/dist/sticky/sticky.d.ts +70 -0
- package/dist/swipe-action/index.d.ts +1 -0
- package/dist/swipe-action/index.js +417 -0
- package/dist/swipe-action/index.js.map +1 -0
- package/dist/swipe-action/swipe-action.d.ts +148 -0
- package/dist/swiper/gesture.d.ts +32 -0
- package/dist/swiper/index.d.ts +1 -0
- package/dist/swiper/index.js +2 -0
- package/dist/swiper/swiper.d.ts +177 -0
- package/dist/swiper-BKivDkHp.js +550 -0
- package/dist/swiper-BKivDkHp.js.map +1 -0
- package/dist/switch/index.d.ts +1 -0
- package/dist/switch/index.js +168 -0
- package/dist/switch/index.js.map +1 -0
- package/dist/switch/switch.d.ts +142 -0
- package/dist/tabbar/index.d.ts +1 -0
- package/dist/tabbar/index.js +95 -0
- package/dist/tabbar/index.js.map +1 -0
- package/dist/tabbar/tabbar.d.ts +119 -0
- package/dist/tabs/index.js +22 -1
- package/dist/tabs/index.js.map +1 -1
- package/dist/tabs/tabs.d.ts +12 -8
- package/dist/tag/index.js +123 -2
- package/dist/tag/index.js.map +1 -1
- package/dist/tag/tag.d.ts +67 -1
- package/dist/textarea/index.d.ts +2 -0
- package/dist/textarea/index.js +2 -242
- package/dist/textarea/platform.d.ts +22 -0
- package/dist/textarea/textarea.d.ts +169 -46
- package/dist/textarea-qbnruDUG.js +775 -0
- package/dist/textarea-qbnruDUG.js.map +1 -0
- package/dist/time-picker/index.d.ts +1 -0
- package/dist/time-picker/index.js +228 -0
- package/dist/time-picker/index.js.map +1 -0
- package/dist/time-picker/time-picker.d.ts +83 -0
- package/dist/timeline/index.d.ts +1 -0
- package/dist/timeline/index.js +131 -0
- package/dist/timeline/index.js.map +1 -0
- package/dist/timeline/timeline.d.ts +79 -0
- package/dist/toast/index.js +47 -4
- package/dist/toast/index.js.map +1 -1
- package/dist/toast/toast.d.ts +26 -3
- package/dist/top-bar/index.js +16 -2
- package/dist/top-bar/index.js.map +1 -1
- package/dist/top-bar/top-bar.d.ts +13 -2
- package/dist/tree-select/index.d.ts +1 -0
- package/dist/tree-select/index.js +512 -0
- package/dist/tree-select/index.js.map +1 -0
- package/dist/tree-select/tree-select.d.ts +215 -0
- package/dist/typography/index.d.ts +1 -0
- package/dist/typography/index.js +82 -0
- package/dist/typography/index.js.map +1 -0
- package/dist/typography/typography.d.ts +54 -0
- package/dist/upload/index.d.ts +1 -0
- package/dist/upload/index.js +458 -0
- package/dist/upload/index.js.map +1 -0
- package/dist/upload/upload.d.ts +172 -0
- package/dist/virtual-list/index.d.ts +1 -0
- package/dist/virtual-list/index.js +445 -0
- package/dist/virtual-list/index.js.map +1 -0
- package/dist/virtual-list/virtual-list.d.ts +160 -0
- package/dist/visual-manifest.d.ts +27 -0
- package/dist/watermark/index.d.ts +1 -0
- package/dist/watermark/index.js +260 -0
- package/dist/watermark/index.js.map +1 -0
- package/dist/watermark/watermark.d.ts +106 -0
- package/package.json +417 -44
- package/dist/empty/index.js.map +0 -1
- package/dist/icon/index.js.map +0 -1
- package/dist/textarea/index.js.map +0 -1
package/dist/tabs/tabs.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type Api as ZagTabsApi, type Props as ZagTabsProps, type Service as ZagTabsService } from "@zag-js/tabs";
|
|
2
|
+
import type { NormalizeProps, PropTypes } from "@zag-js/types";
|
|
2
3
|
/**
|
|
3
4
|
* Tabs 契约 — 原型 B(有状态),core 包裹 zag.js tabs machine。
|
|
4
5
|
* 行为 props 进 createTabsProps → zag context;视觉 props(level/variant/size)
|
|
@@ -46,13 +47,16 @@ export interface QwTabsProps {
|
|
|
46
47
|
/** 字号,默认 "16"。仅 level=primary 生效。 */
|
|
47
48
|
size?: TabsSize;
|
|
48
49
|
}
|
|
49
|
-
/**
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
/** The Zag machine remains the sole selected-value/focus owner. */
|
|
51
|
+
export { machine as tabsMachine } from "@zag-js/tabs";
|
|
52
|
+
/** Shared list-props transport; omitted item information keeps the original getter. */
|
|
53
|
+
export type QwTabsApi<T extends PropTypes = PropTypes> = Omit<ZagTabsApi<T>, "getListProps"> & {
|
|
54
|
+
getListProps(items?: readonly {
|
|
55
|
+
disabled?: boolean;
|
|
56
|
+
}[]): T["element"];
|
|
57
|
+
};
|
|
58
|
+
/** Nonempty all-disabled lists retain native keyboard scrolling without activating a trigger. */
|
|
59
|
+
export declare function connect<T extends PropTypes>(service: ZagTabsService, normalize: NormalizeProps<T>): QwTabsApi<T>;
|
|
56
60
|
/**
|
|
57
61
|
* 把 QwTabsProps 的行为 props 转成 zag tabs machine 的 props (默认值收口 + 命名 rebrand)。
|
|
58
62
|
* 视觉 props(level/variant/size)不出现在返回值中——它们是适配层 data-* 属性。
|
package/dist/tag/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { createMachine } from "@zag-js/core";
|
|
1
2
|
//#region src/tag/tag.ts
|
|
2
3
|
/**
|
|
3
|
-
* Tag 契约 — 原型 A(无状态),
|
|
4
|
+
* Tag 契约 — 原型 A(无状态),Core 承载三栈共享的解析、属性和颜色契约。
|
|
4
5
|
* 渲染契约:`data-scope="tag"`,`data-part="root"`;
|
|
5
6
|
* `data-size` / `data-variant` / `data-bold` 摊平枚举。
|
|
6
7
|
*
|
|
@@ -16,7 +17,127 @@ const TAG_SIZES = [
|
|
|
16
17
|
const TAG_VARIANTS = ["solid", "outlined"];
|
|
17
18
|
/** Tag 各渲染部位全集(data-part 取值)。 */
|
|
18
19
|
const TAG_PARTS = ["root"];
|
|
20
|
+
/** Resolve runtime enums while preserving the existing caller color domain. */
|
|
21
|
+
function resolveTagState(props = {}) {
|
|
22
|
+
return {
|
|
23
|
+
size: TAG_SIZES.includes(props.size) ? props.size : "medium",
|
|
24
|
+
variant: TAG_VARIANTS.includes(props.variant) ? props.variant : "solid",
|
|
25
|
+
bold: props.bold === true,
|
|
26
|
+
bgcolor: props.bgcolor,
|
|
27
|
+
textcolor: props.textcolor,
|
|
28
|
+
borderColor: props.borderColor
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/** Plain-text root attributes; no interactive or live-region semantics. */
|
|
32
|
+
function getTagRootProps(state) {
|
|
33
|
+
return {
|
|
34
|
+
"data-scope": "tag",
|
|
35
|
+
"data-part": "root",
|
|
36
|
+
"data-size": state.size,
|
|
37
|
+
"data-variant": state.variant,
|
|
38
|
+
"data-bold": state.bold ? "true" : void 0
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/** Existing color overrides; caller style is applied after these values. */
|
|
42
|
+
function getTagStyle(state) {
|
|
43
|
+
const style = {};
|
|
44
|
+
if (state.bgcolor) style.background = state.bgcolor;
|
|
45
|
+
if (state.textcolor) style.color = state.textcolor;
|
|
46
|
+
if (state.variant === "outlined" && state.borderColor) style.borderColor = state.borderColor;
|
|
47
|
+
return style;
|
|
48
|
+
}
|
|
49
|
+
function createTagProps(props = {}) {
|
|
50
|
+
if ((props.selectable || props.closable) && (typeof props.id !== "string" || !props.id.trim())) throw new TypeError("Interactive Tag requires a stable nonempty id");
|
|
51
|
+
return { ...props };
|
|
52
|
+
}
|
|
53
|
+
const tagMachine = createMachine({
|
|
54
|
+
props: ({ props }) => createTagProps(props),
|
|
55
|
+
initialState: () => "idle",
|
|
56
|
+
context: ({ bindable, prop }) => ({
|
|
57
|
+
selected: bindable(() => ({
|
|
58
|
+
defaultValue: prop("defaultSelected") ?? false,
|
|
59
|
+
value: prop("selected"),
|
|
60
|
+
onChange: (value) => prop("onSelectedChange")?.(value)
|
|
61
|
+
})),
|
|
62
|
+
visible: bindable(() => ({
|
|
63
|
+
defaultValue: prop("defaultVisible") ?? true,
|
|
64
|
+
value: prop("visible"),
|
|
65
|
+
onChange: (value) => prop("onVisibleChange")?.(value)
|
|
66
|
+
}))
|
|
67
|
+
}),
|
|
68
|
+
states: { idle: {} }
|
|
69
|
+
});
|
|
70
|
+
/** Core owns the change requests, disabled guards, notification order and accepted-close focus. */
|
|
71
|
+
function connectTag(service, normalize) {
|
|
72
|
+
const { prop, context, scope } = service;
|
|
73
|
+
const selected = context.get("selected"), visible = context.get("visible");
|
|
74
|
+
const selectable = prop("selectable") === true, closable = prop("closable") === true;
|
|
75
|
+
const rootId = `tag:${scope.id}:root`, labelId = `tag:${scope.id}:label`;
|
|
76
|
+
return {
|
|
77
|
+
selected,
|
|
78
|
+
visible,
|
|
79
|
+
selectable,
|
|
80
|
+
closable,
|
|
81
|
+
getRootProps() {
|
|
82
|
+
return normalize.element({
|
|
83
|
+
...getTagRootProps(resolveTagState({
|
|
84
|
+
size: prop("size"),
|
|
85
|
+
variant: prop("variant"),
|
|
86
|
+
bold: prop("bold")
|
|
87
|
+
})),
|
|
88
|
+
...selectable || closable ? {
|
|
89
|
+
id: rootId,
|
|
90
|
+
"data-interactive": true,
|
|
91
|
+
"data-selected": selected || void 0,
|
|
92
|
+
"data-disabled": prop("disabled") || void 0
|
|
93
|
+
} : {},
|
|
94
|
+
...!visible ? { hidden: true } : {}
|
|
95
|
+
});
|
|
96
|
+
},
|
|
97
|
+
getLabelProps() {
|
|
98
|
+
return normalize.element({
|
|
99
|
+
"data-scope": "tag",
|
|
100
|
+
"data-part": "label",
|
|
101
|
+
id: labelId
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
getSelectionProps() {
|
|
105
|
+
return normalize.button({
|
|
106
|
+
"data-scope": "tag",
|
|
107
|
+
"data-part": "selection",
|
|
108
|
+
type: "button",
|
|
109
|
+
disabled: prop("disabled"),
|
|
110
|
+
"aria-pressed": selected,
|
|
111
|
+
"aria-label": prop("accessibleLabel"),
|
|
112
|
+
"aria-labelledby": prop("accessibleLabel") ? void 0 : labelId,
|
|
113
|
+
onClick(event) {
|
|
114
|
+
if (!selectable || prop("disabled") || !context.get("visible") || event?.currentTarget.matches(":disabled")) return;
|
|
115
|
+
context.set("selected", !context.get("selected"));
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
},
|
|
119
|
+
getCloseProps() {
|
|
120
|
+
return normalize.button({
|
|
121
|
+
"data-scope": "tag",
|
|
122
|
+
"data-part": "close",
|
|
123
|
+
type: "button",
|
|
124
|
+
disabled: prop("disabled"),
|
|
125
|
+
"aria-label": prop("closeLabel") ?? "Close tag",
|
|
126
|
+
onClick(event) {
|
|
127
|
+
if (!closable || prop("disabled") || !context.get("visible") || event?.currentTarget.matches(":disabled")) return;
|
|
128
|
+
const root = event?.currentTarget.closest("[data-scope=\"tag\"][data-part=\"root\"]") ?? scope.getById(rootId), focused = root?.contains(root.ownerDocument.activeElement);
|
|
129
|
+
context.set("visible", false);
|
|
130
|
+
prop("onClose")?.();
|
|
131
|
+
queueMicrotask(() => {
|
|
132
|
+
const target = prop("focusAfterCloseId");
|
|
133
|
+
if (!context.get("visible") && focused && target) scope.getById(target)?.focus({ preventScroll: true });
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
}
|
|
19
140
|
//#endregion
|
|
20
|
-
export { TAG_PARTS, TAG_SIZES, TAG_VARIANTS };
|
|
141
|
+
export { TAG_PARTS, TAG_SIZES, TAG_VARIANTS, connectTag, createTagProps, getTagRootProps, getTagStyle, resolveTagState, tagMachine };
|
|
21
142
|
|
|
22
143
|
//# sourceMappingURL=index.js.map
|
package/dist/tag/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/tag/tag.ts"],"sourcesContent":["/**\n * Tag 契约 — 原型 A(无状态),core 无 machine,只承载双栈共享的类型契约。\n * 渲染契约:`data-scope=\"tag\"`,`data-part=\"root\"`;\n * `data-size` / `data-variant` / `data-bold` 摊平枚举。\n *\n * 尺寸 / 变体 / 部位词表以运行时常量数组为唯一事实源(类型从常量推导),__test__ 直接锁死。\n */\n\n/** 尺寸全集:small(小)/ medium(中,默认)/ large(大)。 */\nexport const TAG_SIZES = [\"small\", \"medium\", \"large\"] as const;\n\n/** 变体全集:solid 填充(默认)/ outlined 框线。 */\nexport const TAG_VARIANTS = [\"solid\", \"outlined\"] as const;\n\n/** Tag 各渲染部位全集(data-part 取值)。 */\nexport const TAG_PARTS = [\"root\"] as const;\n\nexport type TagSize = (typeof TAG_SIZES)[number];\nexport type TagVariant = (typeof TAG_VARIANTS)[number];\nexport type TagPart = (typeof TAG_PARTS)[number];\n\n/**\n * QwTagProps — 双栈共享的行为契约(全字段可选)。\n * 颜色完全由业务方传入,组件不内置任何主题。\n */\nexport interface QwTagProps {\n /** 尺寸,默认 medium。 */\n size?: TagSize;\n /** 变体,默认 solid。 */\n variant?: TagVariant;\n /** 文字是否加粗,默认 false。 */\n bold?: boolean;\n /** 背景色,未传入时使用默认中性灰。 */\n bgcolor?: string;\n /** 文字色,未传入时使用默认灰。 */\n textcolor?: string;\n /** 边框色,仅在 variant=\"outlined\" 时生效;未传入时使用默认灰。 */\n borderColor?: string;\n}\n"],"mappings":";;;;;;;;;AASA,MAAa,YAAY;CAAC;CAAS;CAAU;AAAO;;AAGpD,MAAa,eAAe,CAAC,SAAS,UAAU;;AAGhD,MAAa,YAAY,CAAC,MAAM"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/tag/tag.ts"],"sourcesContent":["import { createMachine, type MachineSchema, type Service } from \"@zag-js/core\";\nimport type { PropTypes, NormalizeProps, JSX } from \"@zag-js/types\";\n\n/**\n * Tag 契约 — 原型 A(无状态),Core 承载三栈共享的解析、属性和颜色契约。\n * 渲染契约:`data-scope=\"tag\"`,`data-part=\"root\"`;\n * `data-size` / `data-variant` / `data-bold` 摊平枚举。\n *\n * 尺寸 / 变体 / 部位词表以运行时常量数组为唯一事实源(类型从常量推导),__test__ 直接锁死。\n */\n\n/** 尺寸全集:small(小)/ medium(中,默认)/ large(大)。 */\nexport const TAG_SIZES = [\"small\", \"medium\", \"large\"] as const;\n\n/** 变体全集:solid 填充(默认)/ outlined 框线。 */\nexport const TAG_VARIANTS = [\"solid\", \"outlined\"] as const;\n\n/** Tag 各渲染部位全集(data-part 取值)。 */\nexport const TAG_PARTS = [\"root\"] as const;\n\nexport type TagSize = (typeof TAG_SIZES)[number];\nexport type TagVariant = (typeof TAG_VARIANTS)[number];\nexport type TagPart = (typeof TAG_PARTS)[number];\n\n/**\n * QwTagProps — 双栈共享的行为契约(全字段可选)。\n * 颜色完全由业务方传入,组件不内置任何主题。\n */\nexport interface QwTagProps {\n id?: string;\n /** Beta: optional selection and independent close controls. */\n selectable?: boolean;\n closable?: boolean;\n disabled?: boolean;\n selected?: boolean;\n defaultSelected?: boolean;\n onSelectedChange?: (selected: boolean) => void;\n visible?: boolean;\n defaultVisible?: boolean;\n onVisibleChange?: (visible: boolean) => void;\n /** Notifies after the visibility request; owner may reject controlled close. */\n onClose?: () => void;\n accessibleLabel?: string;\n closeLabel?: string;\n /** Focus destination after accepted close when focus was inside this tag. */\n focusAfterCloseId?: string;\n /** 尺寸,默认 medium。 */\n size?: TagSize;\n /** 变体,默认 solid。 */\n variant?: TagVariant;\n /** 文字是否加粗,默认 false。 */\n bold?: boolean;\n /** 背景色,未传入时使用默认中性灰。 */\n bgcolor?: string;\n /** 文字色,未传入时使用默认灰。 */\n textcolor?: string;\n /** 边框色,仅在 variant=\"outlined\" 时生效;未传入时使用默认灰。 */\n borderColor?: string;\n}\n\n/** Normalized passive Tag contract shared by every framework. */\nexport interface TagState {\n readonly size: TagSize;\n readonly variant: TagVariant;\n readonly bold: boolean;\n readonly bgcolor?: string;\n readonly textcolor?: string;\n readonly borderColor?: string;\n}\n\n/** Resolve runtime enums while preserving the existing caller color domain. */\nexport function resolveTagState(props: QwTagProps = {}): TagState {\n return {\n size: TAG_SIZES.includes(props.size as TagSize) ? props.size! : \"medium\",\n variant: TAG_VARIANTS.includes(props.variant as TagVariant) ? props.variant! : \"solid\",\n bold: props.bold === true,\n bgcolor: props.bgcolor,\n textcolor: props.textcolor,\n borderColor: props.borderColor,\n };\n}\n\n/** Plain-text root attributes; no interactive or live-region semantics. */\nexport function getTagRootProps(state: TagState) {\n return {\n \"data-scope\": \"tag\" as const,\n \"data-part\": \"root\" as const,\n \"data-size\": state.size,\n \"data-variant\": state.variant,\n \"data-bold\": state.bold ? \"true\" : undefined,\n };\n}\n\n/** Existing color overrides; caller style is applied after these values. */\nexport function getTagStyle(state: TagState): Record<string, string> {\n const style: Record<string, string> = {};\n if (state.bgcolor) style.background = state.bgcolor;\n if (state.textcolor) style.color = state.textcolor;\n if (state.variant === \"outlined\" && state.borderColor) style.borderColor = state.borderColor;\n return style;\n}\n\n/** Shared optional interaction props; old resolveTagState/getTagRootProps stay passive. */\nexport interface TagSchema extends MachineSchema {\n props: QwTagProps;\n context: { selected: boolean; visible: boolean };\n state: \"idle\";\n event: { type: \"NOP\" };\n}\nexport function createTagProps(props: QwTagProps = {}): QwTagProps {\n if ((props.selectable || props.closable) && (typeof props.id !== \"string\" || !props.id.trim())) throw new TypeError(\"Interactive Tag requires a stable nonempty id\");\n return { ...props };\n}\nexport const tagMachine = createMachine<TagSchema>({\n props: ({ props }) => createTagProps(props),\n initialState: () => \"idle\",\n context: ({ bindable, prop }) => ({\n selected: bindable(() => ({ defaultValue: prop(\"defaultSelected\") ?? false, value: prop(\"selected\"), onChange: value => prop(\"onSelectedChange\")?.(value) })),\n visible: bindable(() => ({ defaultValue: prop(\"defaultVisible\") ?? true, value: prop(\"visible\"), onChange: value => prop(\"onVisibleChange\")?.(value) })),\n }),\n states: { idle: {} },\n});\nexport interface TagApi<T extends PropTypes = PropTypes> {\n selected: boolean;\n visible: boolean;\n selectable: boolean;\n closable: boolean;\n getRootProps(): T[\"element\"];\n getLabelProps(): T[\"element\"];\n getSelectionProps(): T[\"button\"];\n getCloseProps(): T[\"button\"];\n}\n/** Core owns the change requests, disabled guards, notification order and accepted-close focus. */\nexport function connectTag<T extends PropTypes>(service: Service<TagSchema>, normalize: NormalizeProps<T>): TagApi<T> {\n const { prop, context, scope } = service;\n const selected = context.get(\"selected\"), visible = context.get(\"visible\");\n const selectable = prop(\"selectable\") === true, closable = prop(\"closable\") === true;\n const rootId = `tag:${scope.id}:root`, labelId = `tag:${scope.id}:label`;\n return {\n selected, visible, selectable, closable,\n getRootProps() {\n return normalize.element({\n ...getTagRootProps(resolveTagState({ size: prop(\"size\"), variant: prop(\"variant\"), bold: prop(\"bold\") })),\n ...(selectable || closable ? { id: rootId, \"data-interactive\": true, \"data-selected\": selected || undefined, \"data-disabled\": prop(\"disabled\") || undefined } : {}),\n ...(!visible ? { hidden: true } : {}),\n });\n },\n getLabelProps() { return normalize.element({ \"data-scope\": \"tag\", \"data-part\": \"label\", id: labelId }); },\n getSelectionProps() {\n return normalize.button({\n \"data-scope\": \"tag\", \"data-part\": \"selection\", type: \"button\", disabled: prop(\"disabled\"), \"aria-pressed\": selected,\n \"aria-label\": prop(\"accessibleLabel\"), \"aria-labelledby\": prop(\"accessibleLabel\") ? undefined : labelId,\n onClick(event?: JSX.MouseEvent<HTMLButtonElement>) {\n if (!selectable || prop(\"disabled\") || !context.get(\"visible\") || event?.currentTarget.matches(\":disabled\")) return;\n context.set(\"selected\", !context.get(\"selected\"));\n },\n });\n },\n getCloseProps() {\n return normalize.button({\n \"data-scope\": \"tag\", \"data-part\": \"close\", type: \"button\", disabled: prop(\"disabled\"), \"aria-label\": prop(\"closeLabel\") ?? \"Close tag\",\n onClick(event?: JSX.MouseEvent<HTMLButtonElement>) {\n if (!closable || prop(\"disabled\") || !context.get(\"visible\") || event?.currentTarget.matches(\":disabled\")) return;\n const root = event?.currentTarget.closest<HTMLElement>('[data-scope=\"tag\"][data-part=\"root\"]') ?? scope.getById(rootId), focused = root?.contains(root.ownerDocument.activeElement);\n context.set(\"visible\", false);\n prop(\"onClose\")?.();\n queueMicrotask(() => {\n const target = prop(\"focusAfterCloseId\");\n if (!context.get(\"visible\") && focused && target) scope.getById<HTMLElement>(target)?.focus({ preventScroll: true });\n });\n },\n });\n },\n };\n}\n"],"mappings":"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"}
|
package/dist/tag/tag.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { type MachineSchema, type Service } from "@zag-js/core";
|
|
2
|
+
import type { PropTypes, NormalizeProps } from "@zag-js/types";
|
|
1
3
|
/**
|
|
2
|
-
* Tag 契约 — 原型 A(无状态),
|
|
4
|
+
* Tag 契约 — 原型 A(无状态),Core 承载三栈共享的解析、属性和颜色契约。
|
|
3
5
|
* 渲染契约:`data-scope="tag"`,`data-part="root"`;
|
|
4
6
|
* `data-size` / `data-variant` / `data-bold` 摊平枚举。
|
|
5
7
|
*
|
|
@@ -19,6 +21,23 @@ export type TagPart = (typeof TAG_PARTS)[number];
|
|
|
19
21
|
* 颜色完全由业务方传入,组件不内置任何主题。
|
|
20
22
|
*/
|
|
21
23
|
export interface QwTagProps {
|
|
24
|
+
id?: string;
|
|
25
|
+
/** Beta: optional selection and independent close controls. */
|
|
26
|
+
selectable?: boolean;
|
|
27
|
+
closable?: boolean;
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
selected?: boolean;
|
|
30
|
+
defaultSelected?: boolean;
|
|
31
|
+
onSelectedChange?: (selected: boolean) => void;
|
|
32
|
+
visible?: boolean;
|
|
33
|
+
defaultVisible?: boolean;
|
|
34
|
+
onVisibleChange?: (visible: boolean) => void;
|
|
35
|
+
/** Notifies after the visibility request; owner may reject controlled close. */
|
|
36
|
+
onClose?: () => void;
|
|
37
|
+
accessibleLabel?: string;
|
|
38
|
+
closeLabel?: string;
|
|
39
|
+
/** Focus destination after accepted close when focus was inside this tag. */
|
|
40
|
+
focusAfterCloseId?: string;
|
|
22
41
|
/** 尺寸,默认 medium。 */
|
|
23
42
|
size?: TagSize;
|
|
24
43
|
/** 变体,默认 solid。 */
|
|
@@ -32,3 +51,50 @@ export interface QwTagProps {
|
|
|
32
51
|
/** 边框色,仅在 variant="outlined" 时生效;未传入时使用默认灰。 */
|
|
33
52
|
borderColor?: string;
|
|
34
53
|
}
|
|
54
|
+
/** Normalized passive Tag contract shared by every framework. */
|
|
55
|
+
export interface TagState {
|
|
56
|
+
readonly size: TagSize;
|
|
57
|
+
readonly variant: TagVariant;
|
|
58
|
+
readonly bold: boolean;
|
|
59
|
+
readonly bgcolor?: string;
|
|
60
|
+
readonly textcolor?: string;
|
|
61
|
+
readonly borderColor?: string;
|
|
62
|
+
}
|
|
63
|
+
/** Resolve runtime enums while preserving the existing caller color domain. */
|
|
64
|
+
export declare function resolveTagState(props?: QwTagProps): TagState;
|
|
65
|
+
/** Plain-text root attributes; no interactive or live-region semantics. */
|
|
66
|
+
export declare function getTagRootProps(state: TagState): {
|
|
67
|
+
"data-scope": "tag";
|
|
68
|
+
"data-part": "root";
|
|
69
|
+
"data-size": "large" | "medium" | "small";
|
|
70
|
+
"data-variant": "outlined" | "solid";
|
|
71
|
+
"data-bold": string | undefined;
|
|
72
|
+
};
|
|
73
|
+
/** Existing color overrides; caller style is applied after these values. */
|
|
74
|
+
export declare function getTagStyle(state: TagState): Record<string, string>;
|
|
75
|
+
/** Shared optional interaction props; old resolveTagState/getTagRootProps stay passive. */
|
|
76
|
+
export interface TagSchema extends MachineSchema {
|
|
77
|
+
props: QwTagProps;
|
|
78
|
+
context: {
|
|
79
|
+
selected: boolean;
|
|
80
|
+
visible: boolean;
|
|
81
|
+
};
|
|
82
|
+
state: "idle";
|
|
83
|
+
event: {
|
|
84
|
+
type: "NOP";
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
export declare function createTagProps(props?: QwTagProps): QwTagProps;
|
|
88
|
+
export declare const tagMachine: import("@zag-js/core").Machine<TagSchema>;
|
|
89
|
+
export interface TagApi<T extends PropTypes = PropTypes> {
|
|
90
|
+
selected: boolean;
|
|
91
|
+
visible: boolean;
|
|
92
|
+
selectable: boolean;
|
|
93
|
+
closable: boolean;
|
|
94
|
+
getRootProps(): T["element"];
|
|
95
|
+
getLabelProps(): T["element"];
|
|
96
|
+
getSelectionProps(): T["button"];
|
|
97
|
+
getCloseProps(): T["button"];
|
|
98
|
+
}
|
|
99
|
+
/** Core owns the change requests, disabled guards, notification order and accepted-close focus. */
|
|
100
|
+
export declare function connectTag<T extends PropTypes>(service: Service<TagSchema>, normalize: NormalizeProps<T>): TagApi<T>;
|
package/dist/textarea/index.d.ts
CHANGED
package/dist/textarea/index.js
CHANGED
|
@@ -1,242 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
//#region src/textarea/textarea.ts
|
|
4
|
-
/**
|
|
5
|
-
* TextArea zag.js machine。
|
|
6
|
-
* 所有交互逻辑唯一来源:value、focus、clear、pasteRecognize。
|
|
7
|
-
*/
|
|
8
|
-
const machine = createMachine({
|
|
9
|
-
props({ props }) {
|
|
10
|
-
return {
|
|
11
|
-
defaultValue: "",
|
|
12
|
-
disabled: false,
|
|
13
|
-
readOnly: false,
|
|
14
|
-
showActions: true,
|
|
15
|
-
autoSize: false,
|
|
16
|
-
rows: 4,
|
|
17
|
-
...props
|
|
18
|
-
};
|
|
19
|
-
},
|
|
20
|
-
initialState() {
|
|
21
|
-
return "idle";
|
|
22
|
-
},
|
|
23
|
-
context({ bindable, prop }) {
|
|
24
|
-
return {
|
|
25
|
-
value: bindable(() => {
|
|
26
|
-
const controlledValue = prop("value");
|
|
27
|
-
return {
|
|
28
|
-
defaultValue: prop("defaultValue") ?? "",
|
|
29
|
-
sync: true,
|
|
30
|
-
...controlledValue !== void 0 ? { value: controlledValue } : {},
|
|
31
|
-
onChange(value, prev) {
|
|
32
|
-
if (value !== prev) prop("onChange")?.(value);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
}),
|
|
36
|
-
focused: bindable(() => ({ defaultValue: false }))
|
|
37
|
-
};
|
|
38
|
-
},
|
|
39
|
-
computed: {
|
|
40
|
-
charCount({ context }) {
|
|
41
|
-
return context.get("value").length;
|
|
42
|
-
},
|
|
43
|
-
hasMaxLength({ prop }) {
|
|
44
|
-
const max = prop("maxLength");
|
|
45
|
-
return max != null && max > 0;
|
|
46
|
-
},
|
|
47
|
-
showClear({ context, prop }) {
|
|
48
|
-
return context.get("value").length > 0 && !prop("disabled") && !prop("readOnly");
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
watch({ track, prop, context }) {
|
|
52
|
-
track([() => prop("value")], () => {
|
|
53
|
-
const external = prop("value");
|
|
54
|
-
if (external !== void 0 && external !== context.get("value")) context.set("value", external);
|
|
55
|
-
});
|
|
56
|
-
},
|
|
57
|
-
states: { idle: { on: {
|
|
58
|
-
"VALUE.SET": { actions: ["setValue"] },
|
|
59
|
-
"VALUE.CLEAR": { actions: ["clearValue", "invokeOnClear"] },
|
|
60
|
-
"FOCUS.SET": { actions: ["setFocused"] },
|
|
61
|
-
PASTE_RECOGNIZE: { actions: ["pasteValue", "invokeOnPasteRecognize"] }
|
|
62
|
-
} } },
|
|
63
|
-
implementations: { actions: {
|
|
64
|
-
setValue({ context, event, prop }) {
|
|
65
|
-
if (event.type === "VALUE.SET") {
|
|
66
|
-
const maxLength = prop("maxLength") ?? 0;
|
|
67
|
-
let next = event.value;
|
|
68
|
-
if (maxLength > 0 && next.length > maxLength) next = next.slice(0, maxLength);
|
|
69
|
-
context.set("value", next);
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
clearValue({ context }) {
|
|
73
|
-
context.set("value", "");
|
|
74
|
-
},
|
|
75
|
-
setFocused({ context, event, prop }) {
|
|
76
|
-
if (event.type === "FOCUS.SET") {
|
|
77
|
-
const next = event.focused;
|
|
78
|
-
const prev = context.get("focused");
|
|
79
|
-
context.set("focused", next);
|
|
80
|
-
if (next && !prev) prop("onFocus")?.();
|
|
81
|
-
if (!next && prev) prop("onBlur")?.();
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
invokeOnClear({ prop }) {
|
|
85
|
-
prop("onClear")?.();
|
|
86
|
-
},
|
|
87
|
-
pasteValue({ context, event, prop }) {
|
|
88
|
-
if (event.type === "PASTE_RECOGNIZE" && event.value !== void 0) {
|
|
89
|
-
const maxLength = prop("maxLength") ?? 0;
|
|
90
|
-
let next = event.value;
|
|
91
|
-
if (maxLength > 0 && next.length > maxLength) next = next.slice(0, maxLength);
|
|
92
|
-
context.set("value", next);
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
invokeOnPasteRecognize({ prop, event }) {
|
|
96
|
-
if (event.type === "PASTE_RECOGNIZE") prop("onPasteRecognize")?.(event.value ?? "");
|
|
97
|
-
},
|
|
98
|
-
invokeOnFocus() {},
|
|
99
|
-
invokeOnBlur() {}
|
|
100
|
-
} }
|
|
101
|
-
});
|
|
102
|
-
/**
|
|
103
|
-
* connect:把 service 接成业务友好的 prop-getter。
|
|
104
|
-
* 适配层只需调用 connect(service, normalizeProps)。
|
|
105
|
-
*/
|
|
106
|
-
function connect(service, normalizeProps) {
|
|
107
|
-
const { context, computed, prop, send } = service;
|
|
108
|
-
const value = context.get("value");
|
|
109
|
-
const focused = context.get("focused");
|
|
110
|
-
const charCount = computed("charCount");
|
|
111
|
-
const hasMaxLength = computed("hasMaxLength");
|
|
112
|
-
const showClear = computed("showClear");
|
|
113
|
-
const disabled = !!prop("disabled");
|
|
114
|
-
const readOnly = !!prop("readOnly");
|
|
115
|
-
const showActions = prop("showActions") ?? true;
|
|
116
|
-
const autoSize = !!prop("autoSize");
|
|
117
|
-
const maxLength = prop("maxLength");
|
|
118
|
-
const rows = prop("rows") ?? 4;
|
|
119
|
-
const isEmpty = value.length === 0;
|
|
120
|
-
return {
|
|
121
|
-
value,
|
|
122
|
-
focused,
|
|
123
|
-
charCount,
|
|
124
|
-
hasMaxLength,
|
|
125
|
-
showClear,
|
|
126
|
-
clear() {
|
|
127
|
-
send({ type: "VALUE.CLEAR" });
|
|
128
|
-
},
|
|
129
|
-
pasteRecognize(value) {
|
|
130
|
-
send({
|
|
131
|
-
type: "PASTE_RECOGNIZE",
|
|
132
|
-
value
|
|
133
|
-
});
|
|
134
|
-
},
|
|
135
|
-
getRootProps() {
|
|
136
|
-
return normalizeProps.element(compact({
|
|
137
|
-
"data-scope": "textarea",
|
|
138
|
-
"data-part": "root",
|
|
139
|
-
"data-focused": focused ? "true" : void 0,
|
|
140
|
-
"data-disabled": disabled ? "true" : void 0,
|
|
141
|
-
"data-readonly": readOnly ? "true" : void 0,
|
|
142
|
-
"data-show-actions": showActions ? "true" : "false",
|
|
143
|
-
"data-auto-size": autoSize ? "true" : void 0,
|
|
144
|
-
"data-empty": isEmpty ? "true" : "false"
|
|
145
|
-
}));
|
|
146
|
-
},
|
|
147
|
-
getTextareaProps() {
|
|
148
|
-
return normalizeProps.textarea(compact({
|
|
149
|
-
"data-scope": "textarea",
|
|
150
|
-
"data-part": "textarea",
|
|
151
|
-
value,
|
|
152
|
-
placeholder: prop("placeholder"),
|
|
153
|
-
disabled,
|
|
154
|
-
readOnly,
|
|
155
|
-
maxLength: maxLength && maxLength > 0 ? maxLength : void 0,
|
|
156
|
-
rows,
|
|
157
|
-
name: prop("name"),
|
|
158
|
-
"aria-disabled": disabled ? "true" : void 0,
|
|
159
|
-
"aria-readonly": readOnly ? "true" : void 0,
|
|
160
|
-
onFocus() {
|
|
161
|
-
send({
|
|
162
|
-
type: "FOCUS.SET",
|
|
163
|
-
focused: true
|
|
164
|
-
});
|
|
165
|
-
},
|
|
166
|
-
onBlur() {
|
|
167
|
-
send({
|
|
168
|
-
type: "FOCUS.SET",
|
|
169
|
-
focused: false
|
|
170
|
-
});
|
|
171
|
-
},
|
|
172
|
-
onChange(event) {
|
|
173
|
-
const target = event.target;
|
|
174
|
-
const isComposing = !!event.nativeEvent?.isComposing;
|
|
175
|
-
let next = target.value;
|
|
176
|
-
if (!isComposing) {
|
|
177
|
-
const maxLen = prop("maxLength") ?? 0;
|
|
178
|
-
if (maxLen > 0 && next.length > maxLen) next = next.slice(0, maxLen);
|
|
179
|
-
}
|
|
180
|
-
context.set("value", next);
|
|
181
|
-
}
|
|
182
|
-
}));
|
|
183
|
-
},
|
|
184
|
-
getBottomBarProps() {
|
|
185
|
-
return normalizeProps.element(compact({
|
|
186
|
-
"data-scope": "textarea",
|
|
187
|
-
"data-part": "bottom-bar",
|
|
188
|
-
"data-show-actions": showActions ? "true" : "false"
|
|
189
|
-
}));
|
|
190
|
-
},
|
|
191
|
-
getCounterProps() {
|
|
192
|
-
return normalizeProps.element(compact({
|
|
193
|
-
"data-scope": "textarea",
|
|
194
|
-
"data-part": "counter",
|
|
195
|
-
"data-has-max-length": hasMaxLength ? "true" : void 0,
|
|
196
|
-
"aria-live": "polite"
|
|
197
|
-
}));
|
|
198
|
-
},
|
|
199
|
-
getClearButtonProps() {
|
|
200
|
-
return normalizeProps.button(compact({
|
|
201
|
-
"data-scope": "textarea",
|
|
202
|
-
"data-part": "clear-button",
|
|
203
|
-
type: "button",
|
|
204
|
-
disabled: !showClear || disabled || readOnly,
|
|
205
|
-
"aria-label": "清除内容",
|
|
206
|
-
onClick() {
|
|
207
|
-
send({ type: "VALUE.CLEAR" });
|
|
208
|
-
}
|
|
209
|
-
}));
|
|
210
|
-
},
|
|
211
|
-
getPasteButtonProps() {
|
|
212
|
-
return normalizeProps.button(compact({
|
|
213
|
-
"data-scope": "textarea",
|
|
214
|
-
"data-part": "paste-button",
|
|
215
|
-
type: "button",
|
|
216
|
-
disabled,
|
|
217
|
-
"aria-label": "粘贴并识别",
|
|
218
|
-
onClick() {
|
|
219
|
-
send({ type: "PASTE_RECOGNIZE" });
|
|
220
|
-
}
|
|
221
|
-
}));
|
|
222
|
-
}
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
/**
|
|
226
|
-
* 把 QwTextAreaProps 转成 machine context(默认值收口)。
|
|
227
|
-
*/
|
|
228
|
-
function createTextAreaProps(props = {}) {
|
|
229
|
-
return {
|
|
230
|
-
defaultValue: props.defaultValue ?? "",
|
|
231
|
-
disabled: props.disabled ?? false,
|
|
232
|
-
readOnly: props.readOnly ?? false,
|
|
233
|
-
showActions: props.showActions ?? true,
|
|
234
|
-
autoSize: props.autoSize ?? false,
|
|
235
|
-
rows: props.rows ?? 4,
|
|
236
|
-
...props
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
//#endregion
|
|
240
|
-
export { connect, createTextAreaProps, machine };
|
|
241
|
-
|
|
242
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import { a as connect, i as computeTextAreaHeight, n as attachTextAreaPlatform, o as createTextAreaProps, r as clampUtf16, s as machine, t as TextAreaClipboardReadError } from "../textarea-qbnruDUG.js";
|
|
2
|
+
export { TextAreaClipboardReadError, attachTextAreaPlatform, clampUtf16, computeTextAreaHeight, connect, createTextAreaProps, machine };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { TextAreaClipboardFailure, TextAreaPlatformSink } from "./textarea.js";
|
|
2
|
+
/**
|
|
3
|
+
* TextArea 的平台装配:ref 之后的监听、测量和写回。
|
|
4
|
+
* 不判断接受、截断或组合 —— 那些仍然只在 Core 的 TextArea 状态机里。
|
|
5
|
+
* 各栈适配层只保留自己的生命周期胶水(React 的 ref callback、Vue 的 watch)。
|
|
6
|
+
*/
|
|
7
|
+
type ClipboardReason = Exclude<TextAreaClipboardFailure, "stale">;
|
|
8
|
+
/** 平台拒绝。`stale` 只由 Core 在 ticket 过期时产生。 */
|
|
9
|
+
export declare class TextAreaClipboardReadError extends Error {
|
|
10
|
+
readonly reason: ClipboardReason;
|
|
11
|
+
constructor(reason: ClipboardReason);
|
|
12
|
+
}
|
|
13
|
+
/** 宿主栈自己的写值前置动作。React 需要先推进它内部的 value tracker;其它栈不需要。 */
|
|
14
|
+
export interface TextAreaPlatformHost {
|
|
15
|
+
trackValue?(target: HTMLTextAreaElement, value: string): void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 只做 ref 之后的监听、测量和写回。不判断接受、截断或组合。
|
|
19
|
+
* 调用方在 target 与 sink 都可用之后再进入这里。
|
|
20
|
+
*/
|
|
21
|
+
export declare function attachTextAreaPlatform(target: HTMLTextAreaElement, getSink: () => TextAreaPlatformSink, host?: TextAreaPlatformHost): () => void;
|
|
22
|
+
export {};
|