@wot-ui/ui 1.0.0 → 2.0.0-alpha.3
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/LICENSE +21 -0
- package/README.md +134 -0
- package/attributes.json +1 -0
- package/changelog.md +53 -0
- package/common/AbortablePromise.ts +28 -0
- package/common/canvasHelper.ts +49 -0
- package/common/clickoutside.ts +25 -0
- package/common/event.ts +8 -0
- package/common/formatDate.ts +68 -0
- package/common/interceptor.ts +43 -0
- package/common/props.ts +53 -0
- package/common/util.ts +836 -0
- package/components/wd-action-sheet/index.scss +232 -0
- package/components/wd-action-sheet/types.ts +155 -0
- package/components/wd-action-sheet/wd-action-sheet.vue +176 -0
- package/components/wd-avatar/index.scss +150 -0
- package/components/wd-avatar/types.ts +98 -0
- package/components/wd-avatar/wd-avatar.vue +184 -0
- package/components/wd-avatar-group/index.scss +11 -0
- package/components/wd-avatar-group/types.ts +61 -0
- package/components/wd-avatar-group/wd-avatar-group.vue +115 -0
- package/components/wd-backtop/index.scss +67 -0
- package/components/wd-backtop/types.ts +66 -0
- package/components/wd-backtop/wd-backtop.vue +57 -0
- package/components/wd-badge/index.scss +116 -0
- package/components/wd-badge/types.ts +94 -0
- package/components/wd-badge/wd-badge.vue +78 -0
- package/components/wd-button/index.scss +436 -0
- package/components/wd-button/types.ts +204 -0
- package/components/wd-button/wd-button.vue +210 -0
- package/components/wd-calendar/index.scss +97 -0
- package/components/wd-calendar/types.ts +221 -0
- package/components/wd-calendar/wd-calendar.vue +339 -0
- package/components/wd-calendar-view/index.scss +41 -0
- package/components/wd-calendar-view/month/index.scss +144 -0
- package/components/wd-calendar-view/month/month.vue +389 -0
- package/components/wd-calendar-view/month/types.ts +70 -0
- package/components/wd-calendar-view/monthPanel/index.scss +84 -0
- package/components/wd-calendar-view/monthPanel/month-panel.vue +541 -0
- package/components/wd-calendar-view/monthPanel/types.ts +151 -0
- package/components/wd-calendar-view/types.ts +166 -0
- package/components/wd-calendar-view/utils.ts +318 -0
- package/components/wd-calendar-view/wd-calendar-view.vue +117 -0
- package/components/wd-calendar-view/year/index.scss +148 -0
- package/components/wd-calendar-view/year/types.ts +74 -0
- package/components/wd-calendar-view/year/year.vue +206 -0
- package/components/wd-calendar-view/yearPanel/index.scss +42 -0
- package/components/wd-calendar-view/yearPanel/types.ts +96 -0
- package/components/wd-calendar-view/yearPanel/year-panel.vue +249 -0
- package/components/wd-card/index.scss +104 -0
- package/components/wd-card/types.ts +47 -0
- package/components/wd-card/wd-card.vue +38 -0
- package/components/wd-cascader/index.scss +154 -0
- package/components/wd-cascader/types.ts +191 -0
- package/components/wd-cascader/wd-cascader.vue +589 -0
- package/components/wd-cell/index.scss +244 -0
- package/components/wd-cell/types.ts +205 -0
- package/components/wd-cell/wd-cell.vue +172 -0
- package/components/wd-cell-group/index.scss +53 -0
- package/components/wd-cell-group/types.ts +97 -0
- package/components/wd-cell-group/wd-cell-group.vue +48 -0
- package/components/wd-checkbox/index.scss +166 -0
- package/components/wd-checkbox/types.ts +118 -0
- package/components/wd-checkbox/wd-checkbox.vue +216 -0
- package/components/wd-checkbox-group/index.scss +5 -0
- package/components/wd-checkbox-group/types.ts +93 -0
- package/components/wd-checkbox-group/wd-checkbox-group.vue +148 -0
- package/components/wd-circle/index.scss +28 -0
- package/components/wd-circle/types.ts +54 -0
- package/components/wd-circle/wd-circle.vue +306 -0
- package/components/wd-col/index.scss +5 -0
- package/components/wd-col/types.ts +16 -0
- package/components/wd-col/wd-col.vue +83 -0
- package/components/wd-collapse/index.scss +71 -0
- package/components/wd-collapse/types.ts +68 -0
- package/components/wd-collapse/wd-collapse.vue +165 -0
- package/components/wd-collapse-item/index.scss +86 -0
- package/components/wd-collapse-item/types.ts +62 -0
- package/components/wd-collapse-item/wd-collapse-item.vue +184 -0
- package/components/wd-config-provider/index.scss +10 -0
- package/components/wd-config-provider/types.ts +2063 -0
- package/components/wd-config-provider/wd-config-provider.vue +61 -0
- package/components/wd-count-down/index.scss +16 -0
- package/components/wd-count-down/types.ts +58 -0
- package/components/wd-count-down/utils.ts +52 -0
- package/components/wd-count-down/wd-count-down.vue +62 -0
- package/components/wd-count-to/index.scss +25 -0
- package/components/wd-count-to/types.ts +121 -0
- package/components/wd-count-to/wd-count-to.vue +126 -0
- package/components/wd-curtain/index.scss +96 -0
- package/components/wd-curtain/types.ts +82 -0
- package/components/wd-curtain/wd-curtain.vue +172 -0
- package/components/wd-datetime-picker/index.scss +133 -0
- package/components/wd-datetime-picker/types.ts +198 -0
- package/components/wd-datetime-picker/wd-datetime-picker.vue +526 -0
- package/components/wd-datetime-picker-view/types.ts +171 -0
- package/components/wd-datetime-picker-view/util.ts +30 -0
- package/components/wd-datetime-picker-view/wd-datetime-picker-view.vue +402 -0
- package/components/wd-dialog/index.scss +281 -0
- package/components/wd-dialog/index.ts +168 -0
- package/components/wd-dialog/types.ts +452 -0
- package/components/wd-dialog/wd-dialog.vue +586 -0
- package/components/wd-divider/index.scss +122 -0
- package/components/wd-divider/types.ts +50 -0
- package/components/wd-divider/wd-divider.vue +54 -0
- package/components/wd-drop-menu/index.scss +90 -0
- package/components/wd-drop-menu/types.ts +38 -0
- package/components/wd-drop-menu/wd-drop-menu.vue +168 -0
- package/components/wd-drop-menu-item/index.scss +96 -0
- package/components/wd-drop-menu-item/types.ts +93 -0
- package/components/wd-drop-menu-item/wd-drop-menu-item.vue +205 -0
- package/components/wd-empty/index.scss +46 -0
- package/components/wd-empty/types.ts +37 -0
- package/components/wd-empty/wd-empty.vue +47 -0
- package/components/wd-fab/index.scss +124 -0
- package/components/wd-fab/types.ts +119 -0
- package/components/wd-fab/wd-fab.vue +322 -0
- package/components/wd-floating-panel/index.scss +73 -0
- package/components/wd-floating-panel/type.ts +32 -0
- package/components/wd-floating-panel/wd-floating-panel.vue +142 -0
- package/components/wd-form/adapters/zod.ts +56 -0
- package/components/wd-form/types.ts +147 -0
- package/components/wd-form/wd-form.vue +121 -0
- package/components/wd-form-item/index.scss +26 -0
- package/components/wd-form-item/types.ts +134 -0
- package/components/wd-form-item/wd-form-item.vue +182 -0
- package/components/wd-gap/index.scss +9 -0
- package/components/wd-gap/types.ts +26 -0
- package/components/wd-gap/wd-gap.vue +38 -0
- package/components/wd-grid/index.scss +11 -0
- package/components/wd-grid/types.ts +97 -0
- package/components/wd-grid/wd-grid.vue +48 -0
- package/components/wd-grid-item/index.scss +187 -0
- package/components/wd-grid-item/types.ts +98 -0
- package/components/wd-grid-item/wd-grid-item.vue +295 -0
- package/components/wd-icon/index.scss +46 -0
- package/components/wd-icon/types.ts +44 -0
- package/components/wd-icon/wd-icon.vue +66 -0
- package/components/wd-image-preview/index.scss +94 -0
- package/components/wd-image-preview/index.ts +95 -0
- package/components/wd-image-preview/types.ts +165 -0
- package/components/wd-image-preview/wd-image-preview.vue +233 -0
- package/components/wd-img/index.scss +82 -0
- package/components/wd-img/types.ts +96 -0
- package/components/wd-img/wd-img.vue +91 -0
- package/components/wd-img-cropper/index.scss +259 -0
- package/components/wd-img-cropper/types.ts +101 -0
- package/components/wd-img-cropper/wd-img-cropper.vue +653 -0
- package/components/wd-index-anchor/index.scss +34 -0
- package/components/wd-index-anchor/type.ts +9 -0
- package/components/wd-index-anchor/wd-index-anchor.vue +55 -0
- package/components/wd-index-bar/index.scss +68 -0
- package/components/wd-index-bar/type.ts +23 -0
- package/components/wd-index-bar/wd-index-bar.vue +157 -0
- package/components/wd-input/index.scss +129 -0
- package/components/wd-input/types.ts +165 -0
- package/components/wd-input/wd-input.vue +237 -0
- package/components/wd-input-number/index.scss +233 -0
- package/components/wd-input-number/types.ts +131 -0
- package/components/wd-input-number/wd-input-number.vue +473 -0
- package/components/wd-keyboard/constants.ts +81 -0
- package/components/wd-keyboard/index.scss +104 -0
- package/components/wd-keyboard/key/index.scss +103 -0
- package/components/wd-keyboard/key/index.vue +84 -0
- package/components/wd-keyboard/key/types.ts +44 -0
- package/components/wd-keyboard/types.ts +138 -0
- package/components/wd-keyboard/wd-keyboard.vue +236 -0
- package/components/wd-loading/index.scss +205 -0
- package/components/wd-loading/types.ts +61 -0
- package/components/wd-loading/wd-loading.vue +70 -0
- package/components/wd-loadmore/index.scss +62 -0
- package/components/wd-loadmore/types.ts +42 -0
- package/components/wd-loadmore/wd-loadmore.vue +68 -0
- package/components/wd-navbar/index.scss +96 -0
- package/components/wd-navbar/types.ts +74 -0
- package/components/wd-navbar/wd-navbar.vue +136 -0
- package/components/wd-navbar-capsule/index.scss +70 -0
- package/components/wd-navbar-capsule/types.ts +11 -0
- package/components/wd-navbar-capsule/wd-navbar-capsule.vue +48 -0
- package/components/wd-notice-bar/index.scss +94 -0
- package/components/wd-notice-bar/types.ts +97 -0
- package/components/wd-notice-bar/wd-notice-bar.vue +270 -0
- package/components/wd-notify/index.scss +114 -0
- package/components/wd-notify/index.ts +63 -0
- package/components/wd-notify/types.ts +130 -0
- package/components/wd-notify/wd-notify.vue +162 -0
- package/components/wd-overlay/index.scss +14 -0
- package/components/wd-overlay/types.ts +42 -0
- package/components/wd-overlay/wd-overlay.vue +55 -0
- package/components/wd-pagination/index.scss +71 -0
- package/components/wd-pagination/types.ts +69 -0
- package/components/wd-pagination/wd-pagination.vue +118 -0
- package/components/wd-password-input/index.scss +134 -0
- package/components/wd-password-input/types.ts +42 -0
- package/components/wd-password-input/wd-password-input.vue +51 -0
- package/components/wd-picker/index.scss +72 -0
- package/components/wd-picker/types.ts +141 -0
- package/components/wd-picker/wd-picker.vue +220 -0
- package/components/wd-picker-view/index.scss +93 -0
- package/components/wd-picker-view/types.ts +145 -0
- package/components/wd-picker-view/useSelection.ts +385 -0
- package/components/wd-picker-view/wd-picker-view.vue +227 -0
- package/components/wd-popover/index.scss +117 -0
- package/components/wd-popover/types.ts +106 -0
- package/components/wd-popover/wd-popover.vue +212 -0
- package/components/wd-popup/index.scss +89 -0
- package/components/wd-popup/types.ts +110 -0
- package/components/wd-popup/wd-popup.vue +174 -0
- package/components/wd-progress/index.scss +155 -0
- package/components/wd-progress/types.ts +94 -0
- package/components/wd-progress/wd-progress.vue +249 -0
- package/components/wd-radio/index.scss +189 -0
- package/components/wd-radio/types.ts +64 -0
- package/components/wd-radio/wd-radio.vue +164 -0
- package/components/wd-radio-group/index.scss +5 -0
- package/components/wd-radio-group/types.ts +70 -0
- package/components/wd-radio-group/wd-radio-group.vue +53 -0
- package/components/wd-rate/index.scss +57 -0
- package/components/wd-rate/types.ts +86 -0
- package/components/wd-rate/wd-rate.vue +168 -0
- package/components/wd-resize/index.scss +31 -0
- package/components/wd-resize/types.ts +14 -0
- package/components/wd-resize/wd-resize.vue +157 -0
- package/components/wd-root-portal/wd-root-portal.vue +77 -0
- package/components/wd-row/index.scss +6 -0
- package/components/wd-row/types.ts +36 -0
- package/components/wd-row/wd-row.vue +88 -0
- package/components/wd-search/index.scss +171 -0
- package/components/wd-search/types.ts +107 -0
- package/components/wd-search/wd-search.vue +198 -0
- package/components/wd-segmented/index.scss +155 -0
- package/components/wd-segmented/types.ts +81 -0
- package/components/wd-segmented/wd-segmented.vue +169 -0
- package/components/wd-select-picker/index.scss +72 -0
- package/components/wd-select-picker/types.ts +72 -0
- package/components/wd-select-picker/wd-select-picker.vue +371 -0
- package/components/wd-sidebar/index.scss +25 -0
- package/components/wd-sidebar/types.ts +34 -0
- package/components/wd-sidebar/wd-sidebar.vue +57 -0
- package/components/wd-sidebar-item/index.scss +91 -0
- package/components/wd-sidebar-item/types.ts +28 -0
- package/components/wd-sidebar-item/wd-sidebar-item.vue +118 -0
- package/components/wd-signature/index.scss +42 -0
- package/components/wd-signature/types.ts +295 -0
- package/components/wd-signature/wd-signature.vue +664 -0
- package/components/wd-skeleton/index.scss +112 -0
- package/components/wd-skeleton/types.ts +124 -0
- package/components/wd-skeleton/wd-skeleton.vue +110 -0
- package/components/wd-slide-verify/index.scss +112 -0
- package/components/wd-slide-verify/types.ts +98 -0
- package/components/wd-slide-verify/wd-slide-verify.vue +222 -0
- package/components/wd-slider/index.scss +485 -0
- package/components/wd-slider/types.ts +166 -0
- package/components/wd-slider/wd-slider.vue +529 -0
- package/components/wd-sort-button/index.scss +126 -0
- package/components/wd-sort-button/types.ts +68 -0
- package/components/wd-sort-button/wd-sort-button.vue +67 -0
- package/components/wd-step/index.scss +366 -0
- package/components/wd-step/types.ts +43 -0
- package/components/wd-step/wd-step.vue +181 -0
- package/components/wd-steps/index.scss +7 -0
- package/components/wd-steps/types.ts +50 -0
- package/components/wd-steps/wd-steps.vue +39 -0
- package/components/wd-sticky/index.scss +9 -0
- package/components/wd-sticky/types.ts +13 -0
- package/components/wd-sticky/wd-sticky.vue +192 -0
- package/components/wd-sticky-box/index.scss +6 -0
- package/components/wd-sticky-box/types.ts +20 -0
- package/components/wd-sticky-box/wd-sticky-box.vue +157 -0
- package/components/wd-swipe-action/index.scss +22 -0
- package/components/wd-swipe-action/types.ts +87 -0
- package/components/wd-swipe-action/wd-swipe-action.vue +320 -0
- package/components/wd-swiper/index.scss +69 -0
- package/components/wd-swiper/types.ts +275 -0
- package/components/wd-swiper/wd-swiper.vue +332 -0
- package/components/wd-swiper-nav/index.scss +179 -0
- package/components/wd-swiper-nav/types.ts +42 -0
- package/components/wd-swiper-nav/wd-swiper-nav.vue +42 -0
- package/components/wd-switch/index.scss +177 -0
- package/components/wd-switch/types.ts +93 -0
- package/components/wd-switch/wd-switch.vue +107 -0
- package/components/wd-tab/index.scss +16 -0
- package/components/wd-tab/types.ts +45 -0
- package/components/wd-tab/wd-tab.vue +99 -0
- package/components/wd-tabbar/index.scss +71 -0
- package/components/wd-tabbar/types.ts +79 -0
- package/components/wd-tabbar/wd-tabbar.vue +109 -0
- package/components/wd-tabbar-item/index.scss +50 -0
- package/components/wd-tabbar-item/types.ts +45 -0
- package/components/wd-tabbar-item/wd-tabbar-item.vue +101 -0
- package/components/wd-table/index.scss +128 -0
- package/components/wd-table/types.ts +160 -0
- package/components/wd-table/wd-table.vue +331 -0
- package/components/wd-table-column/index.scss +15 -0
- package/components/wd-table-column/types.ts +81 -0
- package/components/wd-table-column/wd-table-column.vue +198 -0
- package/components/wd-tabs/index.scss +332 -0
- package/components/wd-tabs/types.ts +155 -0
- package/components/wd-tabs/wd-tabs.vue +508 -0
- package/components/wd-tag/index.scss +325 -0
- package/components/wd-tag/types.ts +90 -0
- package/components/wd-tag/wd-tag.vue +158 -0
- package/components/wd-text/index.scss +52 -0
- package/components/wd-text/types.ts +107 -0
- package/components/wd-text/wd-text.vue +141 -0
- package/components/wd-textarea/index.scss +112 -0
- package/components/wd-textarea/types.ts +151 -0
- package/components/wd-textarea/wd-textarea.vue +212 -0
- package/components/wd-toast/index.scss +92 -0
- package/components/wd-toast/index.ts +97 -0
- package/components/wd-toast/types.ts +190 -0
- package/components/wd-toast/wd-toast.vue +158 -0
- package/components/wd-tooltip/index.scss +77 -0
- package/components/wd-tooltip/types.ts +105 -0
- package/components/wd-tooltip/wd-tooltip.vue +169 -0
- package/components/wd-tour/index.scss +106 -0
- package/components/wd-tour/types.ts +268 -0
- package/components/wd-tour/wd-tour.vue +518 -0
- package/components/wd-transition/index.scss +67 -0
- package/components/wd-transition/types.ts +106 -0
- package/components/wd-transition/wd-transition.vue +238 -0
- package/components/wd-upload/index.scss +204 -0
- package/components/wd-upload/types.ts +390 -0
- package/components/wd-upload/wd-upload.vue +565 -0
- package/components/wd-video-preview/index.scss +54 -0
- package/components/wd-video-preview/index.ts +64 -0
- package/components/wd-video-preview/types.ts +66 -0
- package/components/wd-video-preview/wd-video-preview.vue +141 -0
- package/components/wd-watermark/index.scss +21 -0
- package/components/wd-watermark/types.ts +130 -0
- package/components/wd-watermark/wd-watermark.vue +718 -0
- package/components/wot-ui/wot-ui.vue +5 -0
- package/composables/index.ts +12 -0
- package/composables/useCell.ts +34 -0
- package/composables/useChildren.ts +120 -0
- package/composables/useConfigProvider.ts +45 -0
- package/composables/useCountDown.ts +138 -0
- package/composables/useDeviceInfo.ts +136 -0
- package/composables/useLockScroll.ts +37 -0
- package/composables/useParent.ts +51 -0
- package/composables/usePopover.ts +212 -0
- package/composables/useQueue.ts +52 -0
- package/composables/useRaf.ts +37 -0
- package/composables/useTouch.ts +43 -0
- package/composables/useTranslate.ts +12 -0
- package/composables/useUpload.ts +366 -0
- package/global.d.ts +106 -0
- package/index.ts +11 -0
- package/locale/index.ts +32 -0
- package/locale/lang/ar-SA.ts +150 -0
- package/locale/lang/de-DE.ts +150 -0
- package/locale/lang/en-US.ts +150 -0
- package/locale/lang/es-ES.ts +150 -0
- package/locale/lang/fr-FR.ts +150 -0
- package/locale/lang/ja-JP.ts +150 -0
- package/locale/lang/ko-KR.ts +150 -0
- package/locale/lang/pt-PT.ts +150 -0
- package/locale/lang/ru-RU.ts +150 -0
- package/locale/lang/th-TH.ts +150 -0
- package/locale/lang/tr-TR.ts +155 -0
- package/locale/lang/ug-CN.ts +154 -0
- package/locale/lang/vi-VN.ts +89 -0
- package/locale/lang/zh-CN.ts +154 -0
- package/locale/lang/zh-HK.ts +78 -0
- package/locale/lang/zh-TW.ts +78 -0
- package/package.json +1 -11
- package/styles/iconfont/iconfont.scss +1243 -0
- package/styles/mixin/_config.scss +7 -0
- package/styles/mixin/_function.scss +44 -0
- package/styles/mixin/_mixin.scss +473 -0
- package/styles/theme/base/color.scss +210 -0
- package/styles/theme/base/font.scss +13 -0
- package/styles/theme/base/index.scss +8 -0
- package/styles/theme/base/insets.scss +32 -0
- package/styles/theme/base/number.scss +36 -0
- package/styles/theme/base/opacity.scss +9 -0
- package/styles/theme/base/radius.scss +13 -0
- package/styles/theme/base/stroke.scss +9 -0
- package/styles/theme/base/typography.scss +44 -0
- package/styles/theme/dark.scss +101 -0
- package/styles/theme/index.scss +16 -0
- package/styles/theme/light.scss +101 -0
- package/styles/variable.scss +472 -0
- package/tags.json +1 -0
- package/web-types.json +1 -0
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
@use '../../styles/variable.scss'as *;
|
|
2
|
+
@use '../../styles/mixin/mixin'as *;
|
|
3
|
+
|
|
4
|
+
// 导航定位间距
|
|
5
|
+
$swiper-nav-spacing: var(--wot-swiper-nav-spacing, $spacing-tight) !default;
|
|
6
|
+
// dot & dots-bar
|
|
7
|
+
// dot 颜色
|
|
8
|
+
$swiper-nav-dot-color: var(--wot-swiper-nav-dot-color, $filled-extra-strong) !default;
|
|
9
|
+
// dot 激活颜色
|
|
10
|
+
$swiper-nav-dot-color-active: var(--wot-swiper-nav-dot-color-active, $icon-white) !default;
|
|
11
|
+
// dot 尺寸
|
|
12
|
+
$swiper-nav-dot-size: var(--wot-swiper-nav-dot-size, $n-6) !default;
|
|
13
|
+
// dot 间距
|
|
14
|
+
$swiper-nav-dot-margin: var(--wot-swiper-nav-dot-margin, $spacing-super-tight) !default;
|
|
15
|
+
// dots-bar 激活宽度
|
|
16
|
+
$swiper-nav-dots-bar-width-active: var(--wot-swiper-nav-dots-bar-width-active, $n-15) !default;
|
|
17
|
+
// dot 圆角
|
|
18
|
+
$swiper-nav-dot-border-radius: var(--wot-swiper-nav-dot-border-radius, $radius-radius-full) !default;
|
|
19
|
+
// fraction
|
|
20
|
+
// 分数模式文字颜色
|
|
21
|
+
$swiper-nav-fraction-color: var(--wot-swiper-nav-fraction-color, $icon-white) !default;
|
|
22
|
+
// 分数模式背景色
|
|
23
|
+
$swiper-nav-fraction-bg: var(--wot-swiper-nav-fraction-bg, $opacfilled-main-cover) !default;
|
|
24
|
+
// 分数模式行高
|
|
25
|
+
$swiper-nav-fraction-line-height: var(--wot-swiper-nav-fraction-line-height, $typography-label-line--height-size-large) !default;
|
|
26
|
+
// 分数模式字号
|
|
27
|
+
$swiper-nav-fraction-font-size: var(--wot-swiper-nav-fraction-font-size, $typography-label-size-large) !default;
|
|
28
|
+
// 分数模式内边距
|
|
29
|
+
$swiper-nav-fraction-padding: var(--wot-swiper-nav-fraction-padding, $padding-ultra-tight $padding-extra-tight) !default;
|
|
30
|
+
// 分数模式圆角
|
|
31
|
+
$swiper-nav-fraction-border-radius: var(--wot-swiper-nav-fraction-border-radius, $radius-main) !default;
|
|
32
|
+
// button
|
|
33
|
+
// 按钮图标颜色
|
|
34
|
+
$swiper-nav-btn-color: var(--wot-swiper-nav-btn-color, $icon-white) !default;
|
|
35
|
+
// 按钮背景色
|
|
36
|
+
$swiper-nav-btn-bg: var(--wot-swiper-nav-btn-bg, $opacfilled-main-cover) !default;
|
|
37
|
+
// 按钮尺寸
|
|
38
|
+
$swiper-nav-btn-size: var(--wot-swiper-nav-btn-size, $n-24) !default;
|
|
39
|
+
// 按钮图标尺寸
|
|
40
|
+
$swiper-nav-btn-icon-size: var(--wot-swiper-nav-btn-icon-size, $n-16) !default;
|
|
41
|
+
// 按钮水平间距
|
|
42
|
+
$swiper-nav-btn-spacing: var(--wot-swiper-nav-btn-spacing, $spacing-loose) !default;
|
|
43
|
+
// 按钮圆角
|
|
44
|
+
$swiper-nav-btn-border-radius: var(--wot-swiper-nav-btn-border-radius, $radius-radius-full) !default;
|
|
45
|
+
|
|
46
|
+
@include b(swiper-nav) {
|
|
47
|
+
|
|
48
|
+
@include e(btn) {
|
|
49
|
+
position: absolute;
|
|
50
|
+
top: 50%;
|
|
51
|
+
transform: translateY(-50%);
|
|
52
|
+
display: flex;
|
|
53
|
+
align-items: center;
|
|
54
|
+
justify-content: center;
|
|
55
|
+
width: $swiper-nav-btn-size;
|
|
56
|
+
height: $swiper-nav-btn-size;
|
|
57
|
+
border-radius: $swiper-nav-btn-border-radius;
|
|
58
|
+
background: $swiper-nav-btn-bg;
|
|
59
|
+
|
|
60
|
+
@include m(prev) {
|
|
61
|
+
left: $swiper-nav-btn-spacing;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@include m(next) {
|
|
65
|
+
right: $swiper-nav-btn-spacing;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@include edeep(btn-icon) {
|
|
70
|
+
font-size: $swiper-nav-btn-icon-size;
|
|
71
|
+
line-height: $swiper-nav-btn-icon-size;
|
|
72
|
+
color: $swiper-nav-btn-color;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@include m(dots, dots-bar) {
|
|
76
|
+
display: flex;
|
|
77
|
+
flex-direction: row;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@include m(fraction) {
|
|
81
|
+
padding: $swiper-nav-fraction-padding;
|
|
82
|
+
line-height: $swiper-nav-fraction-line-height;
|
|
83
|
+
border-radius: $swiper-nav-fraction-border-radius;
|
|
84
|
+
background: $swiper-nav-fraction-bg;
|
|
85
|
+
color: $swiper-nav-fraction-color;
|
|
86
|
+
font-size: $swiper-nav-fraction-font-size;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@include e(item) {
|
|
90
|
+
@include m(dots, dots-bar) {
|
|
91
|
+
width: $swiper-nav-dot-size;
|
|
92
|
+
height: $swiper-nav-dot-size;
|
|
93
|
+
background: $swiper-nav-dot-color;
|
|
94
|
+
border-radius: $swiper-nav-dot-border-radius;
|
|
95
|
+
margin: 0 $swiper-nav-dot-margin;
|
|
96
|
+
transition: all 0.4s ease-in;
|
|
97
|
+
|
|
98
|
+
@include when(vertical) {
|
|
99
|
+
margin: $swiper-nav-dot-margin 0;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
@include when(active) {
|
|
103
|
+
background: $swiper-nav-dot-color-active;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@include m(dots-bar) {
|
|
108
|
+
|
|
109
|
+
@include when(vertical) {
|
|
110
|
+
@include when(active) {
|
|
111
|
+
width: $swiper-nav-dot-size;
|
|
112
|
+
height: $swiper-nav-dots-bar-width-active;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
@include when(active) {
|
|
117
|
+
width: $swiper-nav-dots-bar-width-active;
|
|
118
|
+
border-radius: $swiper-nav-dot-border-radius;
|
|
119
|
+
background: $swiper-nav-dot-color-active;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
@include m(left) {
|
|
125
|
+
position: absolute;
|
|
126
|
+
left: $swiper-nav-spacing;
|
|
127
|
+
top: 50%;
|
|
128
|
+
transform: translateY(-50%);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
@include m(right) {
|
|
132
|
+
position: absolute;
|
|
133
|
+
right: $swiper-nav-spacing;
|
|
134
|
+
top: 50%;
|
|
135
|
+
transform: translateY(-50%);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
@include m(top-left) {
|
|
139
|
+
position: absolute;
|
|
140
|
+
top: $swiper-nav-spacing;
|
|
141
|
+
left: $swiper-nav-spacing;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
@include m(top) {
|
|
145
|
+
position: absolute;
|
|
146
|
+
left: 50%;
|
|
147
|
+
top: $swiper-nav-spacing;
|
|
148
|
+
transform: translateX(-50%);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
@include m(top-right) {
|
|
152
|
+
position: absolute;
|
|
153
|
+
top: $swiper-nav-spacing;
|
|
154
|
+
right: $swiper-nav-spacing;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
@include m(bottom-left) {
|
|
158
|
+
position: absolute;
|
|
159
|
+
left: $swiper-nav-spacing;
|
|
160
|
+
bottom: $swiper-nav-spacing;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
@include m(bottom) {
|
|
164
|
+
position: absolute;
|
|
165
|
+
left: 50%;
|
|
166
|
+
bottom: $swiper-nav-spacing;
|
|
167
|
+
transform: translateX(-50%);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
@include m(bottom-right) {
|
|
171
|
+
position: absolute;
|
|
172
|
+
right: $swiper-nav-spacing;
|
|
173
|
+
bottom: $swiper-nav-spacing;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
@include m(vertical) {
|
|
177
|
+
flex-direction: column;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ExtractPropTypes } from 'vue'
|
|
2
|
+
import { baseProps, makeBooleanProp, makeNumberProp, makeStringProp } from '../../common/props'
|
|
3
|
+
import type { DirectionType, IndicatorPositionType } from '../wd-swiper/types'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 指示器类型,点状(dots)、点条状(dots-bar)、分式(fraction)等
|
|
7
|
+
*/
|
|
8
|
+
export type SwiperIndicatorType = 'dots' | 'dots-bar' | 'fraction'
|
|
9
|
+
|
|
10
|
+
export const swiperNavprops = {
|
|
11
|
+
...baseProps,
|
|
12
|
+
/**
|
|
13
|
+
* 当前轮播在哪一项(下标)
|
|
14
|
+
*/
|
|
15
|
+
current: makeNumberProp(0),
|
|
16
|
+
/**
|
|
17
|
+
* 轮播滑动方向,包括横向滑动和纵向滑动两个方向
|
|
18
|
+
*/
|
|
19
|
+
direction: makeStringProp<DirectionType>('horizontal'),
|
|
20
|
+
/**
|
|
21
|
+
* 小于这个数字不会显示导航器
|
|
22
|
+
*/
|
|
23
|
+
minShowNum: makeNumberProp(2),
|
|
24
|
+
/**
|
|
25
|
+
* 指示器位置
|
|
26
|
+
*/
|
|
27
|
+
indicatorPosition: makeStringProp<IndicatorPositionType>('bottom'),
|
|
28
|
+
/**
|
|
29
|
+
* 是否显示两侧的控制按钮
|
|
30
|
+
*/
|
|
31
|
+
showControls: makeBooleanProp(false),
|
|
32
|
+
/**
|
|
33
|
+
* 总共的项数
|
|
34
|
+
*/
|
|
35
|
+
total: makeNumberProp(0),
|
|
36
|
+
/**
|
|
37
|
+
* 指示器类型,点状(dots)、点条状(dots-bar)、分式(fraction)等
|
|
38
|
+
*/
|
|
39
|
+
type: makeStringProp<SwiperIndicatorType>('dots')
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type SwiperNavProps = ExtractPropTypes<typeof swiperNavprops>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<template v-if="showControls">
|
|
3
|
+
<view class="wd-swiper-nav__btn wd-swiper-nav__btn--prev" @click="handleNav('prev')">
|
|
4
|
+
<wd-icon name="left" custom-class="wd-swiper-nav__btn-icon"></wd-icon>
|
|
5
|
+
</view>
|
|
6
|
+
<view class="wd-swiper-nav__btn wd-swiper-nav__btn--next" @click="handleNav('next')">
|
|
7
|
+
<wd-icon name="right" custom-class="wd-swiper-nav__btn-icon"></wd-icon>
|
|
8
|
+
</view>
|
|
9
|
+
</template>
|
|
10
|
+
<view
|
|
11
|
+
v-if="total >= minShowNum"
|
|
12
|
+
:style="customStyle"
|
|
13
|
+
:class="`wd-swiper-nav wd-swiper-nav--${direction} wd-swiper-nav--${type} wd-swiper-nav--${indicatorPosition} ${customClass}`"
|
|
14
|
+
>
|
|
15
|
+
<block v-if="type === 'dots' || type === 'dots-bar'">
|
|
16
|
+
<view
|
|
17
|
+
v-for="(_, index) in total"
|
|
18
|
+
:key="index"
|
|
19
|
+
:class="`wd-swiper-nav__item--${type} ${current === index ? 'is-active' : ''} is-${direction}`"
|
|
20
|
+
></view>
|
|
21
|
+
</block>
|
|
22
|
+
<block v-if="type === 'fraction'">{{ current + 1 }}/{{ total }}</block>
|
|
23
|
+
</view>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<script lang="ts" setup>
|
|
27
|
+
import { swiperNavprops } from './types'
|
|
28
|
+
import wdIcon from '../wd-icon/wd-icon.vue'
|
|
29
|
+
|
|
30
|
+
defineProps(swiperNavprops)
|
|
31
|
+
|
|
32
|
+
const emit = defineEmits(['change'])
|
|
33
|
+
|
|
34
|
+
function handleNav(dir: 'prev' | 'next') {
|
|
35
|
+
const source: string = 'nav'
|
|
36
|
+
emit('change', { dir, source })
|
|
37
|
+
}
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<style lang="scss">
|
|
41
|
+
@use './index.scss';
|
|
42
|
+
</style>
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
@use '../../styles/mixin/mixin.scss'as *;
|
|
2
|
+
@use '../../styles/variable.scss'as *;
|
|
3
|
+
// 操作块背景色
|
|
4
|
+
$switch-color-action-bg: var(--wot-switch-color-action-bg, $base-white) !default;
|
|
5
|
+
// 操作块图标颜色
|
|
6
|
+
$switch-color-action-icon: var(--wot-switch-color-action-icon, $primary-6) !default;
|
|
7
|
+
// 激活态背景色
|
|
8
|
+
$switch-color-active-bg: var(--wot-switch-color-active-bg, $primary-6) !default;
|
|
9
|
+
// 内部文案激活态颜色
|
|
10
|
+
$switch-color-inner-active-text: var(--wot-switch-color-inner-active-text, $text-white) !default;
|
|
11
|
+
// 内部文案非激活态颜色
|
|
12
|
+
$switch-color-inner-inactive-text: var(--wot-switch-color-inner-inactive-text, $text-auxiliary) !default;
|
|
13
|
+
// 内部图标激活态颜色
|
|
14
|
+
$switch-color-active-icon: var(--wot-switch-color-active-icon, $icon-white) !default;
|
|
15
|
+
// 非激活态背景色
|
|
16
|
+
$switch-color-inactive-bg: var(--wot-switch-color-inactive-bg, $filled-strong) !default;
|
|
17
|
+
// 非激活态图标颜色
|
|
18
|
+
$switch-color-inactive-icon: var(--wot-switch-color-inactive-icon, $icon-auxiliary) !default;
|
|
19
|
+
|
|
20
|
+
// 水平内边距
|
|
21
|
+
$switch-left-right-padding: var(--wot-switch-left-right-padding, $padding-tight) !default;
|
|
22
|
+
// 垂直内边距
|
|
23
|
+
$switch-top-bottom-padding: var(--wot-switch-top-bottom-padding, $padding-ultra-tight) !default;
|
|
24
|
+
|
|
25
|
+
// 组件尺寸
|
|
26
|
+
$switch-size: var(--wot-switch-size, $n-26) !default;
|
|
27
|
+
// 内部图标尺寸
|
|
28
|
+
$switch-size-icon: var(--wot-switch-size-icon, 0.5em) !default;
|
|
29
|
+
// 操作块高度
|
|
30
|
+
$switch-size-action-height: var(--wot-switch-size-action-height, 1em) !default;
|
|
31
|
+
// 操作块宽度
|
|
32
|
+
$switch-size-action-width: var(--wot-switch-size-action-width, 1em) !default;
|
|
33
|
+
// 操作块图标尺寸
|
|
34
|
+
$switch-size-action-icon: var(--wot-switch-size-action-icon, 0.5em) !default;
|
|
35
|
+
// 内部容器高度
|
|
36
|
+
$switch-size-inner-height: var(--wot-switch-size-inner-height, calc($switch-size-action-height + $switch-top-bottom-padding * 2)) !default;
|
|
37
|
+
// 内部容器最小宽度
|
|
38
|
+
$switch-size-inner-min-width: var(--wot-switch-size-inner-min-width, calc(1.8em + $switch-top-bottom-padding * 2)) !default;
|
|
39
|
+
|
|
40
|
+
// 内部文案字号
|
|
41
|
+
$switch-inner-font-size: var(--wot-switch-inner-font-size, $typography-body-size-main) !default;
|
|
42
|
+
|
|
43
|
+
// 方角模式圆角
|
|
44
|
+
$switch-radius: var(--wot-switch-radius, $radius-main) !default;
|
|
45
|
+
// 圆角模式圆角
|
|
46
|
+
$switch-radius-full: var(--wot-switch-radius-full, $radius-radius-full) !default;
|
|
47
|
+
|
|
48
|
+
// 方角模式操作块圆角
|
|
49
|
+
$switch-radius-action: var(--wot-switch-radius-action, $radius-small) !default;
|
|
50
|
+
// 圆角模式操作块圆角
|
|
51
|
+
$switch-radius-action-full: var(--wot-switch-radius-action-full, $radius-radius-full) !default;
|
|
52
|
+
|
|
53
|
+
// 图标与文案间距
|
|
54
|
+
$switch-spacing: var(--wot-switch-spacing, $spacing-super-tight) !default;
|
|
55
|
+
// 过渡时长
|
|
56
|
+
$switch-transition-duration: var(--wot-switch-transition-duration, 0.3s) !default;
|
|
57
|
+
// 禁用态透明度
|
|
58
|
+
$switch-disabled: var(--wot-switch-disabled, $opacity-disabled) !default;
|
|
59
|
+
|
|
60
|
+
@include b(switch) {
|
|
61
|
+
display: inline-flex;
|
|
62
|
+
align-items: center;
|
|
63
|
+
position: relative;
|
|
64
|
+
font-size: $switch-size;
|
|
65
|
+
vertical-align: middle;
|
|
66
|
+
|
|
67
|
+
@include when(disabled) {
|
|
68
|
+
opacity: $switch-disabled;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@include when(loading) {
|
|
72
|
+
opacity: $opacity-oveylay;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@include e(inner) {
|
|
76
|
+
box-sizing: border-box;
|
|
77
|
+
font-size: inherit;
|
|
78
|
+
display: flex;
|
|
79
|
+
align-items: center;
|
|
80
|
+
min-width: $switch-size-inner-min-width;
|
|
81
|
+
height: $switch-size-inner-height;
|
|
82
|
+
transition: all $switch-transition-duration ease;
|
|
83
|
+
border-radius: $switch-radius-full;
|
|
84
|
+
padding: $switch-top-bottom-padding $switch-left-right-padding;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
@include e(action) {
|
|
88
|
+
position: absolute;
|
|
89
|
+
box-sizing: border-box;
|
|
90
|
+
display: inline-flex;
|
|
91
|
+
justify-content: center;
|
|
92
|
+
align-items: center;
|
|
93
|
+
font-size: inherit;
|
|
94
|
+
width: $switch-size-action-width;
|
|
95
|
+
height: $switch-size-action-height;
|
|
96
|
+
background: $switch-color-action-bg;
|
|
97
|
+
border-radius: $switch-radius-action-full;
|
|
98
|
+
transition: all $switch-transition-duration ease;
|
|
99
|
+
left: $switch-top-bottom-padding;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
@include m(round) {
|
|
103
|
+
.wd-switch__inner {
|
|
104
|
+
border-radius: $switch-radius-full;
|
|
105
|
+
}
|
|
106
|
+
.wd-switch__action {
|
|
107
|
+
border-radius: $switch-radius-action-full;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
@include m(square) {
|
|
112
|
+
.wd-switch__inner {
|
|
113
|
+
border-radius: $switch-radius;
|
|
114
|
+
}
|
|
115
|
+
.wd-switch__action {
|
|
116
|
+
border-radius: $switch-radius-action;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
@include edeep(action-loading) {
|
|
121
|
+
font-size: $switch-size-action-icon;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
@include e(action-text) {}
|
|
125
|
+
|
|
126
|
+
@include e(inner-text) {
|
|
127
|
+
font-size: $switch-inner-font-size;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@include edeep(inner-icon) {
|
|
131
|
+
font-size: $switch-size-icon;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
@include edeep(action-icon) {
|
|
135
|
+
font-size: $switch-size-action-icon;
|
|
136
|
+
color: $switch-color-action-icon;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
@include when(active) {
|
|
141
|
+
.wd-switch__inner {
|
|
142
|
+
background: $switch-color-active-bg;
|
|
143
|
+
padding-right: calc($switch-size-action-width + $switch-top-bottom-padding);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
:deep(.wd-switch__inner-icon) {
|
|
147
|
+
color: $switch-color-active-icon;
|
|
148
|
+
margin-right: $switch-spacing;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.wd-switch__inner-text {
|
|
152
|
+
color: $switch-color-inner-active-text;
|
|
153
|
+
margin-right: $switch-spacing;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.wd-switch__action {
|
|
157
|
+
left: calc(100% - $switch-size-action-width - $switch-top-bottom-padding);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
@include when(inactive) {
|
|
162
|
+
.wd-switch__inner {
|
|
163
|
+
background: $switch-color-inactive-bg;
|
|
164
|
+
padding-left: calc($switch-size-action-width + $switch-top-bottom-padding);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
:deep(.wd-switch__inner-icon) {
|
|
168
|
+
color: $switch-color-inactive-icon;
|
|
169
|
+
margin-left: $switch-spacing;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.wd-switch__inner-text {
|
|
173
|
+
color: $switch-color-inner-inactive-text;
|
|
174
|
+
margin-left: $switch-spacing;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { ExtractPropTypes, PropType } from 'vue'
|
|
2
|
+
import { baseProps, makeBooleanProp, makeStringProp, numericProp } from '../../common/props'
|
|
3
|
+
import { type LoadingProps } from '../wd-loading/types'
|
|
4
|
+
|
|
5
|
+
export type SwitchShape = 'round' | 'square'
|
|
6
|
+
|
|
7
|
+
export type SwitchBeforeChange = (value: number | string | boolean) => boolean | Promise<boolean>
|
|
8
|
+
|
|
9
|
+
export const switchProps = {
|
|
10
|
+
...baseProps,
|
|
11
|
+
/**
|
|
12
|
+
* 绑定值
|
|
13
|
+
*/
|
|
14
|
+
modelValue: {
|
|
15
|
+
type: [Boolean, String, Number] as PropType<boolean | string | number>,
|
|
16
|
+
default: false
|
|
17
|
+
},
|
|
18
|
+
/**
|
|
19
|
+
* 是否禁用
|
|
20
|
+
*/
|
|
21
|
+
disabled: makeBooleanProp(false),
|
|
22
|
+
/**
|
|
23
|
+
* 非激活状态操作按钮图标
|
|
24
|
+
*/
|
|
25
|
+
inactiveActionIcon: String,
|
|
26
|
+
/**
|
|
27
|
+
* 激活状态操作按钮图标
|
|
28
|
+
*/
|
|
29
|
+
activeActionIcon: String,
|
|
30
|
+
/**
|
|
31
|
+
* 激活状态图标,设置后将忽略 `activeText`
|
|
32
|
+
*/
|
|
33
|
+
activeIcon: String,
|
|
34
|
+
/**
|
|
35
|
+
* 非激活状态图标,设置后将忽略 `inactiveText`
|
|
36
|
+
*/
|
|
37
|
+
inactiveIcon: String,
|
|
38
|
+
/**
|
|
39
|
+
* 激活状态文本
|
|
40
|
+
*/
|
|
41
|
+
activeText: makeStringProp(''),
|
|
42
|
+
/**
|
|
43
|
+
* 非激活状态文本
|
|
44
|
+
*/
|
|
45
|
+
inactiveText: makeStringProp(''),
|
|
46
|
+
/**
|
|
47
|
+
* 激活值
|
|
48
|
+
*/
|
|
49
|
+
activeValue: {
|
|
50
|
+
type: [Boolean, String, Number] as PropType<boolean | string | number>,
|
|
51
|
+
default: true
|
|
52
|
+
},
|
|
53
|
+
/**
|
|
54
|
+
* 非激活值
|
|
55
|
+
*/
|
|
56
|
+
inactiveValue: {
|
|
57
|
+
type: [Boolean, String, Number] as PropType<boolean | string | number>,
|
|
58
|
+
default: false
|
|
59
|
+
},
|
|
60
|
+
/**
|
|
61
|
+
* 激活颜色
|
|
62
|
+
*/
|
|
63
|
+
activeColor: String,
|
|
64
|
+
/**
|
|
65
|
+
* 非激活颜色
|
|
66
|
+
*/
|
|
67
|
+
inactiveColor: String,
|
|
68
|
+
/**
|
|
69
|
+
* 大小
|
|
70
|
+
*/
|
|
71
|
+
size: numericProp,
|
|
72
|
+
/**
|
|
73
|
+
* 形状
|
|
74
|
+
*/
|
|
75
|
+
shape: makeStringProp<SwitchShape>('round'),
|
|
76
|
+
/**
|
|
77
|
+
* 是否显示加载中
|
|
78
|
+
*/
|
|
79
|
+
loading: Boolean,
|
|
80
|
+
/**
|
|
81
|
+
* 加载配置项
|
|
82
|
+
*/
|
|
83
|
+
loadingProps: Object as PropType<Partial<LoadingProps>>,
|
|
84
|
+
/**
|
|
85
|
+
* 在改变前执行的函数
|
|
86
|
+
*/
|
|
87
|
+
beforeChange: Function as PropType<SwitchBeforeChange>,
|
|
88
|
+
/**
|
|
89
|
+
* 自定义类名
|
|
90
|
+
*/
|
|
91
|
+
classPrefix: makeStringProp('wd-icon')
|
|
92
|
+
}
|
|
93
|
+
export type SwitchProps = ExtractPropTypes<typeof switchProps>
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view :class="rootClass" :style="rootStyle" @click="switchValue">
|
|
3
|
+
<view class="wd-switch__inner" :style="innerStyle">
|
|
4
|
+
<wd-icon custom-class="wd-switch__inner-icon" :name="innerIcon" v-if="innerIcon" :class-prefix="classPrefix"></wd-icon>
|
|
5
|
+
<text v-else class="wd-switch__inner-text">{{ isActive ? activeText : inactiveText }}</text>
|
|
6
|
+
</view>
|
|
7
|
+
<view class="wd-switch__action">
|
|
8
|
+
<wd-loading v-bind="customLoadingProps" v-if="loading"></wd-loading>
|
|
9
|
+
<wd-icon custom-class="wd-switch__action-icon" :name="actionIcon" v-else-if="actionIcon" :class-prefix="classPrefix"></wd-icon>
|
|
10
|
+
</view>
|
|
11
|
+
</view>
|
|
12
|
+
</template>
|
|
13
|
+
<script lang="ts">
|
|
14
|
+
export default {
|
|
15
|
+
name: 'wd-switch',
|
|
16
|
+
options: {
|
|
17
|
+
addGlobalClass: true,
|
|
18
|
+
// #ifndef MP-TOUTIAO
|
|
19
|
+
virtualHost: true,
|
|
20
|
+
// #endif
|
|
21
|
+
styleIsolation: 'shared'
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<script lang="ts" setup>
|
|
27
|
+
import { computed, type CSSProperties, onBeforeMount } from 'vue'
|
|
28
|
+
import { callInterceptor } from '../../common/interceptor'
|
|
29
|
+
import { addUnit, isDef, isUndefined, objToStyle, omitBy } from '../../common/util'
|
|
30
|
+
import { switchProps } from './types'
|
|
31
|
+
import { type LoadingProps } from '../wd-loading/types'
|
|
32
|
+
|
|
33
|
+
const props = defineProps(switchProps)
|
|
34
|
+
const emit = defineEmits(['change', 'update:modelValue'])
|
|
35
|
+
|
|
36
|
+
const isActive = computed(() => {
|
|
37
|
+
return props.modelValue === props.activeValue
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const rootClass = computed(() => {
|
|
41
|
+
return `wd-switch ${props.customClass} ${props.disabled ? 'is-disabled' : ''} ${props.loading ? 'is-loading' : ''} wd-switch--${props.shape} is-${
|
|
42
|
+
isActive.value ? 'active' : 'inactive'
|
|
43
|
+
}`
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
const rootStyle = computed(() => {
|
|
47
|
+
const style: CSSProperties = {}
|
|
48
|
+
if (props.size) {
|
|
49
|
+
style['font-size'] = addUnit(props.size)
|
|
50
|
+
}
|
|
51
|
+
return `${objToStyle(style)}${props.customStyle}`
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
const innerStyle = computed(() => {
|
|
55
|
+
const style: CSSProperties = {
|
|
56
|
+
background: isActive.value ? props.activeColor : props.inactiveColor
|
|
57
|
+
}
|
|
58
|
+
return `${objToStyle(style)}$`
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
const innerIcon = computed(() => {
|
|
62
|
+
return isActive.value ? props.activeIcon : props.inactiveIcon
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
const actionIcon = computed(() => {
|
|
66
|
+
return isActive.value ? props.activeActionIcon : props.inactiveActionIcon
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
const customLoadingProps = computed<Partial<LoadingProps>>(() => {
|
|
70
|
+
const overrides: Partial<LoadingProps> = isDef(props.loadingProps) ? omitBy(props.loadingProps, isUndefined) : {}
|
|
71
|
+
const customSpinnerClass = [isDef(overrides.customSpinnerClass) ? overrides.customSpinnerClass : '', 'wd-switch__action-loading']
|
|
72
|
+
.filter(Boolean)
|
|
73
|
+
.join(' ')
|
|
74
|
+
|
|
75
|
+
const type = isDef(overrides.type) ? overrides.type : 'spinner'
|
|
76
|
+
|
|
77
|
+
return { ...overrides, customSpinnerClass, type }
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
function switchValue() {
|
|
81
|
+
if (props.disabled || props.loading) return
|
|
82
|
+
const newVal = isActive.value ? props.inactiveValue : props.activeValue
|
|
83
|
+
const doSwitch = () => {
|
|
84
|
+
emit('update:modelValue', newVal)
|
|
85
|
+
emit('change', {
|
|
86
|
+
value: newVal
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
callInterceptor(props.beforeChange, {
|
|
91
|
+
args: [newVal],
|
|
92
|
+
done: doSwitch
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
onBeforeMount(() => {
|
|
97
|
+
if ([props.activeValue, props.inactiveValue].indexOf(props.modelValue) === -1) {
|
|
98
|
+
emit('update:modelValue', props.inactiveValue)
|
|
99
|
+
emit('change', {
|
|
100
|
+
value: props.inactiveValue
|
|
101
|
+
})
|
|
102
|
+
}
|
|
103
|
+
})
|
|
104
|
+
</script>
|
|
105
|
+
<style lang="scss">
|
|
106
|
+
@use './index.scss';
|
|
107
|
+
</style>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
@use '../../styles/variable.scss' as *;
|
|
2
|
+
@use '../../styles/mixin/mixin.scss' as *;
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
@include b(tab) {
|
|
6
|
+
width: 100%;
|
|
7
|
+
flex-shrink: 0;
|
|
8
|
+
box-sizing: border-box;
|
|
9
|
+
|
|
10
|
+
@include e(body) {
|
|
11
|
+
@include m(inactive) {
|
|
12
|
+
height: 0;
|
|
13
|
+
transition: height 0.3s ease-in-out;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: weisheng
|
|
3
|
+
* @Date: 2025-05-08 22:54:27
|
|
4
|
+
* @LastEditTime: 2026-02-09 16:22:40
|
|
5
|
+
* @LastEditors: weisheng
|
|
6
|
+
* @Description:
|
|
7
|
+
* @FilePath: /wot-ui/src/uni_modules/wot-ui/components/wd-tab/types.ts
|
|
8
|
+
* 记得注释
|
|
9
|
+
*/
|
|
10
|
+
import type { ExtractPropTypes, PropType } from 'vue'
|
|
11
|
+
import { baseProps, makeBooleanProp, numericProp } from '../../common/props'
|
|
12
|
+
import type { BadgeProps } from '../wd-badge/types'
|
|
13
|
+
|
|
14
|
+
export const tabProps = {
|
|
15
|
+
...baseProps,
|
|
16
|
+
/**
|
|
17
|
+
* 唯一标识符,默认为索引
|
|
18
|
+
* 类型: number | string
|
|
19
|
+
*/
|
|
20
|
+
name: numericProp,
|
|
21
|
+
/**
|
|
22
|
+
* tab 的标题
|
|
23
|
+
* 类型: string
|
|
24
|
+
*/
|
|
25
|
+
title: String,
|
|
26
|
+
/**
|
|
27
|
+
* 是否禁用,无法点击
|
|
28
|
+
* 类型: boolean
|
|
29
|
+
* 默认值: false
|
|
30
|
+
*/
|
|
31
|
+
disabled: makeBooleanProp(false),
|
|
32
|
+
/**
|
|
33
|
+
* 是否懒加载,切换到该tab时才加载内容
|
|
34
|
+
* 类型: boolean
|
|
35
|
+
* 默认值: true
|
|
36
|
+
*/
|
|
37
|
+
lazy: makeBooleanProp(true),
|
|
38
|
+
/**
|
|
39
|
+
* 徽标属性,透传给 Badge 组件
|
|
40
|
+
* 类型: object
|
|
41
|
+
*/
|
|
42
|
+
badgeProps: Object as PropType<Partial<BadgeProps>>
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type TabProps = ExtractPropTypes<typeof tabProps>
|