@wot-ui/ui 1.0.0 → 2.0.0-alpha.4
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 +63 -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 +2061 -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/index.ts +2 -0
- package/components/wd-form/types.ts +133 -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 +16 -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 +6 -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,77 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- #ifdef H5 -->
|
|
3
|
+
<!-- H5端使用 teleport -->
|
|
4
|
+
<teleport to="body">
|
|
5
|
+
<!-- #endif -->
|
|
6
|
+
<!-- #ifdef MP-WEIXIN || MP-ALIPAY -->
|
|
7
|
+
<!-- #ifndef MP-DINGTALK -->
|
|
8
|
+
<!-- 小程序使用 root-portal -->
|
|
9
|
+
<root-portal>
|
|
10
|
+
<!-- #endif -->
|
|
11
|
+
<!-- #endif -->
|
|
12
|
+
<view :class="themeClass" :style="configProviderStyle" class="wd-root-portal">
|
|
13
|
+
<slot />
|
|
14
|
+
</view>
|
|
15
|
+
<!-- #ifdef MP-WEIXIN || MP-ALIPAY -->
|
|
16
|
+
<!-- #ifndef MP-DINGTALK -->
|
|
17
|
+
</root-portal>
|
|
18
|
+
<!-- #endif -->
|
|
19
|
+
<!-- #endif -->
|
|
20
|
+
<!-- #ifdef H5 -->
|
|
21
|
+
</teleport>
|
|
22
|
+
<!-- #endif -->
|
|
23
|
+
</template>
|
|
24
|
+
<script lang="ts">
|
|
25
|
+
export default {
|
|
26
|
+
name: 'wd-root-portal',
|
|
27
|
+
options: {
|
|
28
|
+
// #ifndef MP-TOUTIAO
|
|
29
|
+
virtualHost: true,
|
|
30
|
+
// #endif
|
|
31
|
+
addGlobalClass: true,
|
|
32
|
+
styleIsolation: 'shared'
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
</script>
|
|
36
|
+
<script lang="ts" setup>
|
|
37
|
+
import { computed, inject } from 'vue'
|
|
38
|
+
import { useParent } from '../../composables/useParent'
|
|
39
|
+
import { USE_CONFIG_PROVIDER_KEY } from '../../composables/useConfigProvider'
|
|
40
|
+
import { CONFIG_PROVIDER_KEY, type ConfigProviderProvide } from '../wd-config-provider/types'
|
|
41
|
+
import { baseProps } from '../../common/props'
|
|
42
|
+
|
|
43
|
+
const props = defineProps({
|
|
44
|
+
...baseProps
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
const None = Symbol('None')
|
|
48
|
+
const hooksProvider = inject<ConfigProviderProvide | typeof None>(USE_CONFIG_PROVIDER_KEY, None)
|
|
49
|
+
const { parent: configProvider } = useParent(CONFIG_PROVIDER_KEY)
|
|
50
|
+
|
|
51
|
+
const configProviderStyle = computed(() => {
|
|
52
|
+
return hooksProvider !== None ? hooksProvider.themeStyle.value || '' : configProvider.value?.themeStyle.value || ''
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
const themeClass = computed(() => {
|
|
56
|
+
const theme = hooksProvider !== None ? hooksProvider.theme?.value : configProvider.value?.theme?.value
|
|
57
|
+
return theme ? `wot-theme-${theme}` : 'wot-theme-light'
|
|
58
|
+
})
|
|
59
|
+
</script>
|
|
60
|
+
|
|
61
|
+
<!-- #ifdef APP-PLUS -->
|
|
62
|
+
<script module="render" lang="renderjs">
|
|
63
|
+
export default {
|
|
64
|
+
mounted() {
|
|
65
|
+
if (this.$ownerInstance.$el) {
|
|
66
|
+
(document.querySelector('uni-app') || document.body).appendChild(this.$ownerInstance.$el)
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
beforeDestroy() {
|
|
70
|
+
// 清理,将元素移回原位置
|
|
71
|
+
if (this.$ownerInstance.$el) {
|
|
72
|
+
(document.querySelector('uni-app') || document.body).removeChild(this.$ownerInstance.$el)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
</script>
|
|
77
|
+
<!-- #endif -->
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type ExtractPropTypes, type InjectionKey } from 'vue'
|
|
2
|
+
import { baseProps, makeNumberProp, makeStringProp } from '../../common/props'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 水平对齐方式
|
|
6
|
+
*/
|
|
7
|
+
export type RowJustify = 'start' | 'center' | 'end' | 'space-between' | 'space-around' | 'space-evenly'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 垂直对齐方式
|
|
11
|
+
*/
|
|
12
|
+
export type RowAlign = 'top' | 'middle' | 'bottom'
|
|
13
|
+
|
|
14
|
+
export type RowProvide = {
|
|
15
|
+
props: { gutter?: number }
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const ROW_KEY: InjectionKey<RowProvide> = Symbol('wd-row')
|
|
19
|
+
|
|
20
|
+
export const rowProps = {
|
|
21
|
+
...baseProps,
|
|
22
|
+
/**
|
|
23
|
+
* 列元素之间的间距(单位为 px)
|
|
24
|
+
*/
|
|
25
|
+
gutter: makeNumberProp(0),
|
|
26
|
+
/**
|
|
27
|
+
* 主轴对齐方式
|
|
28
|
+
*/
|
|
29
|
+
justify: makeStringProp<RowJustify>('start'),
|
|
30
|
+
/**
|
|
31
|
+
* 交叉轴对齐方式
|
|
32
|
+
*/
|
|
33
|
+
align: makeStringProp<RowAlign>('top')
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export type RowProps = ExtractPropTypes<typeof rowProps>
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
* @Author: weisheng
|
|
3
|
+
* @Date: 2025-12-18 14:30:46
|
|
4
|
+
* @LastEditTime: 2026-02-10 22:19:29
|
|
5
|
+
* @LastEditors: weisheng
|
|
6
|
+
* @Description:
|
|
7
|
+
* @FilePath: /wot-ui/src/uni_modules/wot-ui/components/wd-row/wd-row.vue
|
|
8
|
+
* 记得注释
|
|
9
|
+
-->
|
|
10
|
+
<template>
|
|
11
|
+
<view :class="rootClass" :style="rootStyle">
|
|
12
|
+
<!-- 每一行 -->
|
|
13
|
+
<slot />
|
|
14
|
+
</view>
|
|
15
|
+
</template>
|
|
16
|
+
<script lang="ts">
|
|
17
|
+
export default {
|
|
18
|
+
name: 'wd-row',
|
|
19
|
+
options: {
|
|
20
|
+
// #ifndef MP-TOUTIAO
|
|
21
|
+
virtualHost: true,
|
|
22
|
+
// #endif
|
|
23
|
+
addGlobalClass: true,
|
|
24
|
+
styleIsolation: 'shared'
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
</script>
|
|
28
|
+
<script lang="ts" setup>
|
|
29
|
+
import { computed, type CSSProperties } from 'vue'
|
|
30
|
+
import { useChildren } from '../../composables/useChildren'
|
|
31
|
+
import { ROW_KEY, rowProps } from './types'
|
|
32
|
+
import { addUnit, objToStyle } from '../../common/util'
|
|
33
|
+
|
|
34
|
+
const props = defineProps(rowProps)
|
|
35
|
+
const { linkChildren } = useChildren(ROW_KEY)
|
|
36
|
+
|
|
37
|
+
linkChildren({ props })
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* justify 值映射到 CSS flex justify-content
|
|
41
|
+
*/
|
|
42
|
+
const justifyMap: Record<string, string> = {
|
|
43
|
+
start: 'flex-start',
|
|
44
|
+
center: 'center',
|
|
45
|
+
end: 'flex-end',
|
|
46
|
+
'space-between': 'space-between',
|
|
47
|
+
'space-around': 'space-around',
|
|
48
|
+
'space-evenly': 'space-evenly'
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* align 值映射到 CSS flex align-items
|
|
53
|
+
*/
|
|
54
|
+
const alignMap: Record<string, string> = {
|
|
55
|
+
top: 'flex-start',
|
|
56
|
+
middle: 'center',
|
|
57
|
+
bottom: 'flex-end'
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const rootClass = computed(() => {
|
|
61
|
+
return `wd-row ${props.customClass}`
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
const rootStyle = computed(() => {
|
|
65
|
+
const style: CSSProperties = {}
|
|
66
|
+
const { gutter, justify, align } = props
|
|
67
|
+
|
|
68
|
+
if (gutter < 0) {
|
|
69
|
+
console.error('[wot ui] warning(wd-row): attribute gutter must be greater than or equal to 0')
|
|
70
|
+
} else if (gutter) {
|
|
71
|
+
style.marginLeft = addUnit(-gutter / 2)
|
|
72
|
+
style.marginRight = addUnit(-gutter / 2)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (justify && justify !== 'start') {
|
|
76
|
+
style.justifyContent = justifyMap[justify] || justify
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (align && align !== 'top') {
|
|
80
|
+
style.alignItems = alignMap[align] || align
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return `${objToStyle(style)}${props.customStyle}`
|
|
84
|
+
})
|
|
85
|
+
</script>
|
|
86
|
+
<style lang="scss">
|
|
87
|
+
@use './index.scss';
|
|
88
|
+
</style>
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
@use '../../styles/mixin/mixin.scss' as *;
|
|
2
|
+
@use '../../styles/variable.scss' as *;
|
|
3
|
+
|
|
4
|
+
// 组件整体内边距
|
|
5
|
+
$search-padding: var(--wot-search-padding, $padding-tight $padding-loose) !default;
|
|
6
|
+
// 输入框圆角
|
|
7
|
+
$search-input-radius: var(--wot-search-input-radius, $radius-radius-full) !default;
|
|
8
|
+
// 输入框高度
|
|
9
|
+
$search-input-height: var(--wot-search-input-height, $n-36) !default;
|
|
10
|
+
// 输入框内边距
|
|
11
|
+
$search-field-padding: var(--wot-search-field-padding, $padding-zero $padding-loose) !default;
|
|
12
|
+
// 输入框左侧搜索图标向右间距
|
|
13
|
+
$search-left-icon-margin-right: var(--wot-search-left-icon-margin-right, $spacing-super-tight) !default;
|
|
14
|
+
// 输入框背景色 (filled)
|
|
15
|
+
$search-input-bg: var(--wot-search-input-bg, $filled-bottom) !default;
|
|
16
|
+
// 组件容器背景色 (filled)
|
|
17
|
+
$search-bg: var(--wot-search-bg, $filled-oppo) !default;
|
|
18
|
+
// 组件覆盖层背景色 (filled)
|
|
19
|
+
$search-cover-bg: var(--wot-search-cover-bg, $filled-bottom) !default;
|
|
20
|
+
// light 模式容器背景色
|
|
21
|
+
$search-light-bg: var(--wot-search-light-bg, $filled-bottom) !default;
|
|
22
|
+
// light 模式内容块背景色
|
|
23
|
+
$search-light-block-bg: var(--wot-search-light-block-bg, $filled-oppo) !default;
|
|
24
|
+
// light 模式覆盖层背景色
|
|
25
|
+
$search-light-cover-bg: var(--wot-search-light-cover-bg, $filled-oppo) !default;
|
|
26
|
+
// plain 模式容器背景色
|
|
27
|
+
$search-plain-bg: var(--wot-search-plain-bg, $filled-oppo) !default;
|
|
28
|
+
// plain 模式内容块背景色
|
|
29
|
+
$search-plain-block-bg: var(--wot-search-plain-block-bg, $filled-oppo) !default;
|
|
30
|
+
// plain 模式内容块边框
|
|
31
|
+
$search-plain-block-border-color: var(--wot-search-plain-block-border-color, $border-light) !default;
|
|
32
|
+
// plain 模式覆盖层背景色
|
|
33
|
+
$search-plain-cover-bg: var(--wot-search-plain-cover-bg, $filled-oppo) !default;
|
|
34
|
+
// block 向右间距
|
|
35
|
+
$search-block-margin-right: var(--wot-search-block-margin-right, $spacing-extra-tight) !default;
|
|
36
|
+
// 输入框字号
|
|
37
|
+
$search-input-font-size: var(--wot-search-input-font-size, $typography-body-size-main) !default;
|
|
38
|
+
// 输入框文字颜色
|
|
39
|
+
$search-input-color: var(--wot-search-input-color, $text-main) !default;
|
|
40
|
+
// 输入框文字行高
|
|
41
|
+
$search-input-line-height: var(--wot-search-input-line-height, $typography-body-line--height-size-main) !default;
|
|
42
|
+
// 搜索图标颜色
|
|
43
|
+
$search-icon-color: var(--wot-search-icon-color, $icon-secondary) !default;
|
|
44
|
+
// 搜索图标大小
|
|
45
|
+
$search-icon-size: var(--wot-search-icon-size, $typography-title-size-main) !default;
|
|
46
|
+
// 清除图标大小
|
|
47
|
+
$search-clear-icon-size: var(--wot-search-clear-icon-size, $n-20) !default;
|
|
48
|
+
// 清除图标颜色
|
|
49
|
+
$search-clear-icon-color: var(--wot-search-clear-icon-color, $icon-disabled) !default;
|
|
50
|
+
// 清除图标向右间距
|
|
51
|
+
$search-clear-icon-margin-left: var(--wot-search-clear-icon-margin-left, $spacing-super-tight) !default;
|
|
52
|
+
// 占位符颜色
|
|
53
|
+
$search-placeholder-color: var(--wot-search-placeholder-color, $text-placeholder) !default;
|
|
54
|
+
// 占位符字号
|
|
55
|
+
$search-placeholder-font-size: var(--wot-search-placeholder-font-size, $typography-body-size-main) !default;
|
|
56
|
+
// 占位符行高
|
|
57
|
+
$search-placeholder-line-height: var(--wot-search-placeholder-line-height, $typography-body-line--height-size-main) !default;
|
|
58
|
+
// 取消按钮字号
|
|
59
|
+
$search-cancel-font-size: var(--wot-search-cancel-font-size, $typography-body-size-main) !default;
|
|
60
|
+
// 取消按钮行高
|
|
61
|
+
$search-cancel-line-height: var(--wot-search-cancel-line-height, $typography-body-line--height-size-main) !default;
|
|
62
|
+
// 取消按钮颜色
|
|
63
|
+
$search-cancel-color: var(--wot-search-cancel-color, $primary-6) !default;
|
|
64
|
+
|
|
65
|
+
@include b(search) {
|
|
66
|
+
display: flex;
|
|
67
|
+
padding: $search-padding;
|
|
68
|
+
align-items: center;
|
|
69
|
+
background: $search-bg;
|
|
70
|
+
|
|
71
|
+
@include e(block) {
|
|
72
|
+
flex: 1;
|
|
73
|
+
background-color: $search-input-bg;
|
|
74
|
+
border-radius: $search-input-radius;
|
|
75
|
+
display: flex;
|
|
76
|
+
flex-direction: row;
|
|
77
|
+
align-items: center;
|
|
78
|
+
position: relative;
|
|
79
|
+
box-sizing: border-box;
|
|
80
|
+
margin-right: $search-block-margin-right;
|
|
81
|
+
}
|
|
82
|
+
@include e(field) {
|
|
83
|
+
flex: 1;
|
|
84
|
+
display: flex;
|
|
85
|
+
flex-direction: row;
|
|
86
|
+
align-items: center;
|
|
87
|
+
position: relative;
|
|
88
|
+
padding: $search-field-padding;
|
|
89
|
+
}
|
|
90
|
+
@include e(input) {
|
|
91
|
+
flex: 1;
|
|
92
|
+
height: $search-input-height;
|
|
93
|
+
font-size: $search-input-font-size;
|
|
94
|
+
line-height: $search-input-line-height;
|
|
95
|
+
color: $search-input-color;
|
|
96
|
+
box-sizing: border-box;
|
|
97
|
+
border: none;
|
|
98
|
+
background: transparent;
|
|
99
|
+
-webkit-appearance: none;
|
|
100
|
+
outline: none;
|
|
101
|
+
z-index: 0;
|
|
102
|
+
|
|
103
|
+
@include lineEllipsis;
|
|
104
|
+
|
|
105
|
+
&::-webkit-search-cancel-button {
|
|
106
|
+
-webkit-appearance: none;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
@include e(cover) {
|
|
110
|
+
width: 100%;
|
|
111
|
+
height: $search-input-height;
|
|
112
|
+
background-color: $search-cover-bg;
|
|
113
|
+
line-height: $search-input-height;
|
|
114
|
+
font-size: $search-input-font-size;
|
|
115
|
+
border-radius: $search-input-radius;
|
|
116
|
+
flex-direction: row;
|
|
117
|
+
justify-content: center;
|
|
118
|
+
align-items: center;
|
|
119
|
+
}
|
|
120
|
+
@include edeep(search-icon) {
|
|
121
|
+
margin-right: $search-left-icon-margin-right;
|
|
122
|
+
color: $search-icon-color;
|
|
123
|
+
font-size: $search-icon-size;
|
|
124
|
+
}
|
|
125
|
+
@include edeep(search-left-icon) {
|
|
126
|
+
margin-right: $search-left-icon-margin-right;
|
|
127
|
+
font-size: $search-icon-size;
|
|
128
|
+
color: $search-icon-color;
|
|
129
|
+
}
|
|
130
|
+
@include e(placeholder-txt) {
|
|
131
|
+
color: $search-placeholder-color;
|
|
132
|
+
font-size: $search-placeholder-font-size;
|
|
133
|
+
line-height: $search-placeholder-line-height;
|
|
134
|
+
}
|
|
135
|
+
@include edeep(clear-icon) {
|
|
136
|
+
font-size: $search-clear-icon-size;
|
|
137
|
+
color: $search-clear-icon-color;
|
|
138
|
+
margin-left: $search-clear-icon-margin-left;
|
|
139
|
+
}
|
|
140
|
+
@include e(cancel) {
|
|
141
|
+
line-height: $search-cancel-line-height;
|
|
142
|
+
font-size: $search-cancel-font-size;
|
|
143
|
+
color: $search-cancel-color;
|
|
144
|
+
}
|
|
145
|
+
@include when(light) {
|
|
146
|
+
background: $search-light-bg;
|
|
147
|
+
|
|
148
|
+
.wd-search__block {
|
|
149
|
+
background: $search-light-block-bg;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.wd-search__cover {
|
|
153
|
+
background: $search-light-cover-bg;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
@include when(plain) {
|
|
157
|
+
background: $search-plain-bg;
|
|
158
|
+
|
|
159
|
+
.wd-search__block {
|
|
160
|
+
background: $search-plain-block-bg;
|
|
161
|
+
@include pixelBorderSurround($search-plain-block-border-color)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.wd-search__cover {
|
|
165
|
+
background: $search-plain-cover-bg;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
@include when(without-cancel) {
|
|
169
|
+
// padding-right: $search-side-padding;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @Author: weisheng
|
|
3
|
+
* @Date: 2024-09-01 15:42:04
|
|
4
|
+
* @LastEditTime: 2026-03-11 15:14:39
|
|
5
|
+
* @LastEditors: weisheng
|
|
6
|
+
* @Description:
|
|
7
|
+
* @FilePath: /wot-ui/src/uni_modules/wot-ui/components/wd-search/types.ts
|
|
8
|
+
* 记得注释
|
|
9
|
+
*/
|
|
10
|
+
import { baseProps, makeBooleanProp, makeNumberProp, makeNumericProp, makeStringProp } from '../../common/props'
|
|
11
|
+
|
|
12
|
+
export type SearchVariant = 'filled' | 'plain' | 'light'
|
|
13
|
+
|
|
14
|
+
export const searchProps = {
|
|
15
|
+
...baseProps,
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 自定义输入框类名
|
|
19
|
+
* 类型: string
|
|
20
|
+
* 默认值: ''
|
|
21
|
+
*/
|
|
22
|
+
customInputClass: makeStringProp(''),
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 输入框内容,双向绑定
|
|
26
|
+
* 类型: string
|
|
27
|
+
* 默认值: ''
|
|
28
|
+
*/
|
|
29
|
+
modelValue: makeStringProp(''),
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 搜索框占位文本
|
|
33
|
+
* 类型: string
|
|
34
|
+
*/
|
|
35
|
+
placeholder: String,
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* 搜索框右侧文本
|
|
39
|
+
* 类型: string
|
|
40
|
+
*/
|
|
41
|
+
cancelTxt: String,
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* 搜索框变体
|
|
45
|
+
* 类型: string
|
|
46
|
+
* 可选值: 'filled' | 'plain' | 'light'
|
|
47
|
+
* 默认值: 'plain'
|
|
48
|
+
*/
|
|
49
|
+
variant: makeStringProp<SearchVariant>('plain'),
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* 是否隐藏右侧文本
|
|
53
|
+
* 类型: boolean
|
|
54
|
+
* 默认值: false
|
|
55
|
+
*/
|
|
56
|
+
hideCancel: makeBooleanProp(false),
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* 是否禁用搜索框
|
|
60
|
+
* 类型: boolean
|
|
61
|
+
* 默认值: false
|
|
62
|
+
*/
|
|
63
|
+
disabled: makeBooleanProp(false),
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 原生属性,设置最大长度。-1 表示无限制
|
|
67
|
+
* 类型: string | number
|
|
68
|
+
* 默认值: -1
|
|
69
|
+
*/
|
|
70
|
+
maxlength: makeNumberProp(-1),
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* placeholder 居左边
|
|
74
|
+
* 类型: boolean
|
|
75
|
+
* 默认值: false
|
|
76
|
+
*/
|
|
77
|
+
placeholderLeft: makeBooleanProp(false),
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* 是否自动聚焦
|
|
81
|
+
* 类型: boolean
|
|
82
|
+
* 默认值: false
|
|
83
|
+
* 最低版本: 0.1.63
|
|
84
|
+
*/
|
|
85
|
+
focus: makeBooleanProp(false),
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* 是否在点击清除按钮时聚焦输入框
|
|
89
|
+
* 类型: boolean
|
|
90
|
+
* 默认值: false
|
|
91
|
+
* 最低版本: 0.1.63
|
|
92
|
+
*/
|
|
93
|
+
focusWhenClear: makeBooleanProp(false),
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* 原生属性,指定 placeholder 的样式,目前仅支持color,font-size和font-weight
|
|
97
|
+
* 类型: string
|
|
98
|
+
*/
|
|
99
|
+
placeholderStyle: String,
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* 原生属性,指定 placeholder 的样式类
|
|
103
|
+
* 类型: string
|
|
104
|
+
* 默认值: ''
|
|
105
|
+
*/
|
|
106
|
+
placeholderClass: makeStringProp('')
|
|
107
|
+
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view :class="rootClass" :style="customStyle">
|
|
3
|
+
<view class="wd-search__block" @click="handleClick">
|
|
4
|
+
<slot name="prefix"></slot>
|
|
5
|
+
<view class="wd-search__field">
|
|
6
|
+
<view v-if="!placeholderLeft" :style="coverStyle" class="wd-search__cover" @click="closeCover">
|
|
7
|
+
<wd-icon name="search-line" custom-class="wd-search__search-icon"></wd-icon>
|
|
8
|
+
<text :class="`wd-search__placeholder-txt ${placeholderClass}`">{{ placeholder || translate('search') }}</text>
|
|
9
|
+
</view>
|
|
10
|
+
<wd-icon v-if="showInput || inputValue || placeholderLeft" name="search-line" custom-class="wd-search__search-left-icon"></wd-icon>
|
|
11
|
+
<input
|
|
12
|
+
v-if="showInput || inputValue || placeholderLeft"
|
|
13
|
+
:placeholder="placeholder || translate('search')"
|
|
14
|
+
:placeholder-class="`wd-search__placeholder-txt ${placeholderClass}`"
|
|
15
|
+
:placeholder-style="placeholderStyle"
|
|
16
|
+
confirm-type="search"
|
|
17
|
+
v-model="inputValue"
|
|
18
|
+
:class="['wd-search__input', customInputClass]"
|
|
19
|
+
@focus="handleFocus"
|
|
20
|
+
@input="handleInput"
|
|
21
|
+
@blur="handleBlur"
|
|
22
|
+
@confirm="handleConfirm"
|
|
23
|
+
:disabled="disabled"
|
|
24
|
+
:maxlength="maxlength"
|
|
25
|
+
:focus="isFocused"
|
|
26
|
+
/>
|
|
27
|
+
<wd-icon v-if="inputValue" custom-class="wd-search__clear-icon" name="close-circle-fill" @click="handleClear" />
|
|
28
|
+
<slot name="input-suffix"></slot>
|
|
29
|
+
</view>
|
|
30
|
+
</view>
|
|
31
|
+
|
|
32
|
+
<slot v-if="!hideCancel" name="suffix">
|
|
33
|
+
<view class="wd-search__cancel" @click="handleCancel">
|
|
34
|
+
{{ cancelTxt || translate('cancel') }}
|
|
35
|
+
</view>
|
|
36
|
+
</slot>
|
|
37
|
+
</view>
|
|
38
|
+
</template>
|
|
39
|
+
|
|
40
|
+
<script lang="ts">
|
|
41
|
+
export default {
|
|
42
|
+
name: 'wd-search',
|
|
43
|
+
options: {
|
|
44
|
+
// #ifndef MP-TOUTIAO
|
|
45
|
+
virtualHost: true,
|
|
46
|
+
// #endif
|
|
47
|
+
addGlobalClass: true,
|
|
48
|
+
styleIsolation: 'shared'
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<script lang="ts" setup>
|
|
54
|
+
import wdIcon from '../wd-icon/wd-icon.vue'
|
|
55
|
+
import { type CSSProperties, computed, onMounted, ref, watch } from 'vue'
|
|
56
|
+
import { objToStyle, pause } from '../../common/util'
|
|
57
|
+
import { useTranslate } from '../../composables/useTranslate'
|
|
58
|
+
import { searchProps } from './types'
|
|
59
|
+
|
|
60
|
+
const props = defineProps(searchProps)
|
|
61
|
+
const emit = defineEmits(['update:modelValue', 'change', 'clear', 'search', 'focus', 'blur', 'cancel', 'click'])
|
|
62
|
+
|
|
63
|
+
const { translate } = useTranslate('search')
|
|
64
|
+
|
|
65
|
+
const isFocused = ref<boolean>(false) // 是否聚焦中
|
|
66
|
+
const showInput = ref<boolean>(false) // 是否显示输入框 用于实现聚焦的hack
|
|
67
|
+
const inputValue = ref<string>('') // 输入框的值
|
|
68
|
+
const showPlaceHolder = ref<boolean>(true)
|
|
69
|
+
const clearing = ref<boolean>(false)
|
|
70
|
+
|
|
71
|
+
watch(
|
|
72
|
+
() => props.modelValue,
|
|
73
|
+
(newValue) => {
|
|
74
|
+
inputValue.value = newValue
|
|
75
|
+
if (newValue) {
|
|
76
|
+
showInput.value = true
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{ immediate: true }
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
watch(
|
|
83
|
+
() => props.focus,
|
|
84
|
+
(newValue) => {
|
|
85
|
+
if (newValue) {
|
|
86
|
+
if (props.disabled) return
|
|
87
|
+
closeCover()
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
onMounted(() => {
|
|
93
|
+
if (props.focus) {
|
|
94
|
+
closeCover()
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
const rootClass = computed(() => {
|
|
99
|
+
const isLight = props.variant === 'light'
|
|
100
|
+
const isPlain = props.variant === 'plain'
|
|
101
|
+
return `wd-search ${isLight ? 'is-light' : ''} ${isPlain ? 'is-plain' : ''} ${props.hideCancel ? 'is-without-cancel' : ''} ${props.customClass}`
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
const coverStyle = computed(() => {
|
|
105
|
+
const coverStyle: CSSProperties = {
|
|
106
|
+
display: inputValue.value === '' && showPlaceHolder.value ? 'flex' : 'none'
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return objToStyle(coverStyle)
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
async function hackFocus(focus: boolean) {
|
|
113
|
+
showInput.value = focus
|
|
114
|
+
await pause()
|
|
115
|
+
isFocused.value = focus
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
async function closeCover() {
|
|
119
|
+
if (props.disabled) return
|
|
120
|
+
await pause(100)
|
|
121
|
+
showPlaceHolder.value = false
|
|
122
|
+
hackFocus(true)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function handleInput(event: any) {
|
|
126
|
+
inputValue.value = event.detail.value
|
|
127
|
+
emit('update:modelValue', event.detail.value)
|
|
128
|
+
emit('change', {
|
|
129
|
+
value: event.detail.value
|
|
130
|
+
})
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
async function handleClear() {
|
|
134
|
+
inputValue.value = ''
|
|
135
|
+
if (props.focusWhenClear) {
|
|
136
|
+
clearing.value = true
|
|
137
|
+
isFocused.value = false
|
|
138
|
+
}
|
|
139
|
+
await pause()
|
|
140
|
+
if (props.focusWhenClear) {
|
|
141
|
+
showPlaceHolder.value = false
|
|
142
|
+
hackFocus(true)
|
|
143
|
+
} else {
|
|
144
|
+
showPlaceHolder.value = true
|
|
145
|
+
hackFocus(false)
|
|
146
|
+
}
|
|
147
|
+
emit('change', {
|
|
148
|
+
value: ''
|
|
149
|
+
})
|
|
150
|
+
emit('update:modelValue', '')
|
|
151
|
+
emit('clear')
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function handleConfirm({ detail: { value } }: any) {
|
|
155
|
+
// 组件触发search事件
|
|
156
|
+
emit('search', {
|
|
157
|
+
value
|
|
158
|
+
})
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function handleFocus() {
|
|
162
|
+
showPlaceHolder.value = false
|
|
163
|
+
emit('focus', {
|
|
164
|
+
value: inputValue.value
|
|
165
|
+
})
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
async function handleBlur() {
|
|
169
|
+
// 等待150毫秒,clear执行完毕
|
|
170
|
+
await pause(150)
|
|
171
|
+
if (clearing.value) {
|
|
172
|
+
clearing.value = false
|
|
173
|
+
return
|
|
174
|
+
}
|
|
175
|
+
// 组件触发blur事件
|
|
176
|
+
showPlaceHolder.value = !inputValue.value
|
|
177
|
+
showInput.value = !showPlaceHolder.value
|
|
178
|
+
isFocused.value = false
|
|
179
|
+
emit('blur', {
|
|
180
|
+
value: inputValue.value
|
|
181
|
+
})
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function handleCancel() {
|
|
185
|
+
emit('cancel', {
|
|
186
|
+
value: inputValue.value
|
|
187
|
+
})
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function handleClick() {
|
|
191
|
+
if (props.disabled) {
|
|
192
|
+
emit('click')
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
</script>
|
|
196
|
+
<style lang="scss">
|
|
197
|
+
@use './index.scss';
|
|
198
|
+
</style>
|