@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,150 @@
|
|
|
1
|
+
@use '../../styles/mixin/mixin.scss'as *;
|
|
2
|
+
@use '../../styles/variable.scss'as *;
|
|
3
|
+
|
|
4
|
+
// 默认尺寸
|
|
5
|
+
$avatar-size-normal: var(--wot-avatar-size-normal, $n-36) !default;
|
|
6
|
+
// 大尺寸
|
|
7
|
+
$avatar-size-large: var(--wot-avatar-size-large, $n-56) !default;
|
|
8
|
+
// 中尺寸
|
|
9
|
+
$avatar-size-medium: var(--wot-avatar-size-medium, $n-48) !default;
|
|
10
|
+
// 小尺寸
|
|
11
|
+
$avatar-size-small: var(--wot-avatar-size-small, $n-24) !default;
|
|
12
|
+
// 头像文字颜色
|
|
13
|
+
$avatar-text-color: var(--wot-avatar-text-color, $text-white) !default;
|
|
14
|
+
// 头像文字字重
|
|
15
|
+
$avatar-font-weight: var(--wot-avatar-font-weight, $typography-body-font-weight-strong) !default;
|
|
16
|
+
// 默认文字字号
|
|
17
|
+
$avatar-font-size: var(--wot-avatar-font-size, $typography-title-size-large) !default;
|
|
18
|
+
// 大尺寸文字字号
|
|
19
|
+
$avatar-font-size-large: var(--wot-avatar-font-size-large, $typography-title-size-extra-large) !default;
|
|
20
|
+
// 中尺寸文字字号
|
|
21
|
+
$avatar-font-size-medium: var(--wot-avatar-font-size-medium, $typography-title-size-large) !default;
|
|
22
|
+
// 小尺寸文字字号
|
|
23
|
+
$avatar-font-size-small: var(--wot-avatar-font-size-small, $typography-title-size-main) !default;
|
|
24
|
+
// 默认文字行高
|
|
25
|
+
$avatar-line-height: var(--wot-avatar-line-height, $typography-title-line--height-size-large) !default;
|
|
26
|
+
// 大尺寸文字行高
|
|
27
|
+
$avatar-line-height-large: var(--wot-avatar-line-height-large, $typography-title-line--height-size-extra-large) !default;
|
|
28
|
+
// 中尺寸文字行高
|
|
29
|
+
$avatar-line-height-medium: var(--wot-avatar-line-height-medium, $typography-title-line--height-size-large) !default;
|
|
30
|
+
// 小尺寸文字行高
|
|
31
|
+
$avatar-line-height-small: var(--wot-avatar-line-height-small, $typography-title-line--height-size-main) !default;
|
|
32
|
+
// 头像背景颜色
|
|
33
|
+
$avatar-bg: var(--wot-avatar-bg, $filled-strong) !default;
|
|
34
|
+
// 默认圆角
|
|
35
|
+
$avatar-border-radius: var(--wot-avatar-border-radius, $radius-main) !default;
|
|
36
|
+
// 全圆角
|
|
37
|
+
$avatar-border-radius-full: var(--wot-avatar-border-radius-full, $radius-radius-full) !default;
|
|
38
|
+
// 头像重叠距离
|
|
39
|
+
$avatar-overlap: var(--wot-avatar-overlap) !default;
|
|
40
|
+
// 图标颜色
|
|
41
|
+
$avatar-icon-color: var(--wot-avatar-icon-color, $icon-auxiliary) !default;
|
|
42
|
+
// 文本颜色
|
|
43
|
+
$avatar-color: var(--wot-avatar-color, $text-auxiliary) !default;
|
|
44
|
+
|
|
45
|
+
@include b(avatar) {
|
|
46
|
+
display: inline-flex;
|
|
47
|
+
align-items: center;
|
|
48
|
+
justify-content: center;
|
|
49
|
+
width: $avatar-size-normal;
|
|
50
|
+
height: $avatar-size-normal;
|
|
51
|
+
color: $avatar-text-color;
|
|
52
|
+
font-weight: $avatar-font-weight;
|
|
53
|
+
font-size: $avatar-font-size;
|
|
54
|
+
line-height: $avatar-line-height;
|
|
55
|
+
text-align: center;
|
|
56
|
+
background: $avatar-bg;
|
|
57
|
+
border-radius: $avatar-border-radius;
|
|
58
|
+
overflow: hidden;
|
|
59
|
+
user-select: none;
|
|
60
|
+
vertical-align: middle;
|
|
61
|
+
flex-shrink: 0;
|
|
62
|
+
color: $avatar-color;
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
@include when(round) {
|
|
66
|
+
border-radius: $avatar-border-radius-full;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@include when(square) {
|
|
70
|
+
border-radius: $avatar-border-radius;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@include m(large) {
|
|
74
|
+
width: $avatar-size-large;
|
|
75
|
+
height: $avatar-size-large;
|
|
76
|
+
font-size: $avatar-font-size-large;
|
|
77
|
+
line-height: $avatar-line-height-large;
|
|
78
|
+
--wot-avatar-overlap: calc(#{$avatar-size-large} * -0.25);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@include m(medium) {
|
|
82
|
+
width: $avatar-size-medium;
|
|
83
|
+
height: $avatar-size-medium;
|
|
84
|
+
font-size: $avatar-font-size-medium;
|
|
85
|
+
line-height: $avatar-line-height-medium;
|
|
86
|
+
--wot-avatar-overlap: calc(#{$avatar-size-medium} * -0.25);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@include m(normal) {
|
|
90
|
+
width: $avatar-size-normal;
|
|
91
|
+
height: $avatar-size-normal;
|
|
92
|
+
font-size: $avatar-font-size;
|
|
93
|
+
line-height: $avatar-line-height;
|
|
94
|
+
--wot-avatar-overlap: calc(#{$avatar-size-normal} * -0.25);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@include m(small) {
|
|
98
|
+
width: $avatar-size-small;
|
|
99
|
+
height: $avatar-size-small;
|
|
100
|
+
font-size: $avatar-font-size-small;
|
|
101
|
+
line-height: $avatar-line-height-small;
|
|
102
|
+
--wot-avatar-overlap: calc(#{$avatar-size-small} * -0.25);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
@include e(group-item) {
|
|
106
|
+
position: relative;
|
|
107
|
+
flex-shrink: 0;
|
|
108
|
+
box-sizing: border-box;
|
|
109
|
+
|
|
110
|
+
&:first-child {
|
|
111
|
+
margin-left: 0;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
&+& {
|
|
115
|
+
margin-left: $avatar-overlap;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@include m(vertical) {
|
|
119
|
+
|
|
120
|
+
// 第一个元素不需要负 margin
|
|
121
|
+
&:first-child {
|
|
122
|
+
margin-top: 0;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
&+& {
|
|
126
|
+
margin-left: 0;
|
|
127
|
+
margin-top: $avatar-overlap;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
@include e(text) {
|
|
135
|
+
white-space: nowrap;
|
|
136
|
+
overflow: hidden;
|
|
137
|
+
text-overflow: ellipsis;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
@include edeep(icon) {
|
|
141
|
+
font-size: inherit;
|
|
142
|
+
color: $avatar-icon-color;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
@include edeep(img) {
|
|
146
|
+
border-radius: inherit;
|
|
147
|
+
width: 100%;
|
|
148
|
+
height: 100%;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { ExtractPropTypes, PropType } from 'vue'
|
|
2
|
+
import { baseProps, makeStringProp } from '../../common/props'
|
|
3
|
+
import type { ImageMode } from '../wd-img/types'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 头像尺寸类型
|
|
7
|
+
* 可选值: 'large' | 'medium' | 'normal' | 'small'
|
|
8
|
+
*/
|
|
9
|
+
export type AvatarSize = 'large' | 'medium' | 'normal' | 'small'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 头像形状类型
|
|
13
|
+
* 可选值: 'square' | 'round'
|
|
14
|
+
*/
|
|
15
|
+
export type AvatarShape = 'square' | 'round'
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Avatar 组件 Props 定义
|
|
19
|
+
*/
|
|
20
|
+
export const avatarProps = {
|
|
21
|
+
...baseProps,
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 图片地址
|
|
25
|
+
* 类型: string
|
|
26
|
+
* 默认值: ''
|
|
27
|
+
*/
|
|
28
|
+
src: makeStringProp(''),
|
|
29
|
+
/**
|
|
30
|
+
* 文本内容
|
|
31
|
+
* 类型: string
|
|
32
|
+
* 默认值: 空字符串
|
|
33
|
+
*/
|
|
34
|
+
text: makeStringProp(''),
|
|
35
|
+
/**
|
|
36
|
+
* 头像尺寸,支持预设尺寸或自定义大小
|
|
37
|
+
* 类型: string | number | AvatarSize
|
|
38
|
+
* 可选值: 'large' | 'medium' | 'normal' | 'small' 或带单位的字符串(如 40px、100rpx)
|
|
39
|
+
* 默认值: 'normal'
|
|
40
|
+
*/
|
|
41
|
+
size: {
|
|
42
|
+
type: [String, Number] as PropType<string | number | AvatarSize>
|
|
43
|
+
},
|
|
44
|
+
/**
|
|
45
|
+
* 头像形状
|
|
46
|
+
* 类型: AvatarShape
|
|
47
|
+
* 可选值: 'round' | 'square'
|
|
48
|
+
* 默认值: 'round'
|
|
49
|
+
*/
|
|
50
|
+
shape: String as PropType<AvatarShape>,
|
|
51
|
+
/**
|
|
52
|
+
* 背景颜色
|
|
53
|
+
* 类型: string
|
|
54
|
+
* 默认值: ''
|
|
55
|
+
*/
|
|
56
|
+
bgColor: makeStringProp(''),
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* 文字颜色
|
|
60
|
+
* 类型: string
|
|
61
|
+
* 默认值: ''
|
|
62
|
+
*/
|
|
63
|
+
color: makeStringProp(''),
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 图标名称,用于显示 wd-icon 组件
|
|
67
|
+
* 类型: string
|
|
68
|
+
* 默认值: ''
|
|
69
|
+
*/
|
|
70
|
+
icon: makeStringProp(''),
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 图片加载失败时的占位文本
|
|
74
|
+
* 类型: string
|
|
75
|
+
* 默认值: ''
|
|
76
|
+
*/
|
|
77
|
+
alt: makeStringProp(''),
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* 图片填充模式,与 uni-app image 组件的 mode 属性一致
|
|
81
|
+
* 类型: ImageMode
|
|
82
|
+
* 默认值: 'aspectFill'
|
|
83
|
+
*/
|
|
84
|
+
mode: makeStringProp<ImageMode>('aspectFill'),
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* 内部标记,用于 avatar-group 组件内部使用
|
|
88
|
+
* 类型: boolean
|
|
89
|
+
* 默认值: false
|
|
90
|
+
* @private
|
|
91
|
+
*/
|
|
92
|
+
_internal: Boolean
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Avatar 组件 Props 类型
|
|
97
|
+
*/
|
|
98
|
+
export type AvatarProps = ExtractPropTypes<typeof avatarProps>
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view v-if="isShow" :class="rootClass" :style="rootStyle" @click="handleClick">
|
|
3
|
+
<!-- 默认插槽优先 -->
|
|
4
|
+
<slot v-if="hasDefaultSlot"></slot>
|
|
5
|
+
<!-- 图片 -->
|
|
6
|
+
<wd-img v-else-if="src" :src="src" :mode="mode" custom-class="wd-avatar__img" @error="handleError" />
|
|
7
|
+
<!-- 文本 -->
|
|
8
|
+
<text v-else-if="text" class="wd-avatar__text">{{ text }}</text>
|
|
9
|
+
<!-- 图标 -->
|
|
10
|
+
<wd-icon v-else-if="icon" :name="icon" custom-class="wd-avatar__icon" />
|
|
11
|
+
</view>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script lang="ts">
|
|
15
|
+
export default {
|
|
16
|
+
name: 'wd-avatar',
|
|
17
|
+
options: {
|
|
18
|
+
addGlobalClass: true,
|
|
19
|
+
// #ifndef MP-TOUTIAO
|
|
20
|
+
virtualHost: true,
|
|
21
|
+
// #endif
|
|
22
|
+
styleIsolation: 'shared'
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<script lang="ts" setup>
|
|
28
|
+
import { computed, useSlots, type CSSProperties, ref } from 'vue'
|
|
29
|
+
import wdIcon from '../wd-icon/wd-icon.vue'
|
|
30
|
+
import wdImg from '../wd-img/wd-img.vue'
|
|
31
|
+
import { addUnit, getPropByPath, isDef, isString, objToStyle } from '../../common/util'
|
|
32
|
+
import { avatarProps, type AvatarShape, type AvatarSize } from './types'
|
|
33
|
+
import { useParent } from '../../composables/useParent'
|
|
34
|
+
import { AVATAR_GROUP_KEY } from '../wd-avatar-group/types'
|
|
35
|
+
|
|
36
|
+
const props = defineProps(avatarProps)
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Avatar 组件事件定义
|
|
40
|
+
* - error: 图片加载失败时触发
|
|
41
|
+
* - click: 点击头像时触发
|
|
42
|
+
*/
|
|
43
|
+
const emit = defineEmits(['error', 'click'])
|
|
44
|
+
const slots = useSlots()
|
|
45
|
+
|
|
46
|
+
// 父组件上下文:_internal 用于 avatar-group 内部的溢出计数头像,跳过父组件上下文
|
|
47
|
+
const { parent: avatarGroup, index } = props._internal ? { parent: ref(null), index: ref(-1) } : useParent(AVATAR_GROUP_KEY)
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 计算头像是否应该显示
|
|
51
|
+
* 在 avatar-group 中根据 maxCount 判断是否超出数量限制
|
|
52
|
+
*/
|
|
53
|
+
const isShow = computed(() => {
|
|
54
|
+
if (!avatarGroup.value) {
|
|
55
|
+
return true
|
|
56
|
+
}
|
|
57
|
+
// 在 avatar-group 中,根据 maxCount 判断
|
|
58
|
+
const maxCount = avatarGroup.value.props.maxCount
|
|
59
|
+
if (!isDef(maxCount)) {
|
|
60
|
+
return true
|
|
61
|
+
}
|
|
62
|
+
const count = typeof maxCount === 'number' ? maxCount : parseInt(maxCount, 10)
|
|
63
|
+
// 检查 count 是否为有效数字
|
|
64
|
+
if (isNaN(count) || count <= 0) {
|
|
65
|
+
return true
|
|
66
|
+
}
|
|
67
|
+
return index.value < count
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* 获取头像尺寸
|
|
72
|
+
* 优先级: Props > avatarGroup Props > 默认值
|
|
73
|
+
*/
|
|
74
|
+
const sizeValue = computed(() => {
|
|
75
|
+
return props.size || (getPropByPath(avatarGroup.value, 'props.size') as string | number | AvatarSize) || 'normal'
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* 判断是否使用内置尺寸(large/medium/normal/small)
|
|
80
|
+
*/
|
|
81
|
+
const isBuiltInSize = computed(() => {
|
|
82
|
+
return isString(sizeValue.value) && ['large', 'medium', 'normal', 'small'].includes(sizeValue.value)
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* 获取头像形状
|
|
87
|
+
* 优先级: Props > avatarGroup Props > 默认值
|
|
88
|
+
*/
|
|
89
|
+
const shapeValue = computed(() => {
|
|
90
|
+
return props.shape || (getPropByPath(avatarGroup.value, 'props.shape') as AvatarShape) || 'round'
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* 判断是否存在默认插槽
|
|
95
|
+
*/
|
|
96
|
+
const hasDefaultSlot = computed(() => !!slots.default)
|
|
97
|
+
|
|
98
|
+
const rootClass = computed(() => {
|
|
99
|
+
const classes = ['wd-avatar', props.customClass]
|
|
100
|
+
classes.push(`is-${shapeValue.value}`)
|
|
101
|
+
|
|
102
|
+
// 尺寸类仅预设尺寸
|
|
103
|
+
if (isBuiltInSize.value) {
|
|
104
|
+
classes.push(`wd-avatar--${sizeValue.value}`)
|
|
105
|
+
}
|
|
106
|
+
// 在 avatar-group 中时,添加 item 类
|
|
107
|
+
if (avatarGroup.value) {
|
|
108
|
+
classes.push('wd-avatar__group-item')
|
|
109
|
+
if (avatarGroup.value.props.vertical) {
|
|
110
|
+
classes.push('wd-avatar__group-item--vertical')
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return classes.join(' ')
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* 根节点样式
|
|
118
|
+
*/
|
|
119
|
+
const rootStyle = computed(() => {
|
|
120
|
+
const style: CSSProperties = {}
|
|
121
|
+
if (isDef(sizeValue.value) && !isBuiltInSize.value) {
|
|
122
|
+
style.width = addUnit(sizeValue.value)
|
|
123
|
+
style.height = addUnit(sizeValue.value)
|
|
124
|
+
style.fontSize = `calc(${addUnit(sizeValue.value)} * 0.45)`
|
|
125
|
+
if (avatarGroup.value) {
|
|
126
|
+
style['--wot-avatar-overlap' as any] = `calc(${addUnit(sizeValue.value)} * -0.25)`
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// 处理层叠效果的 z-index
|
|
131
|
+
if (avatarGroup.value) {
|
|
132
|
+
const cascading = avatarGroup.value.props.cascading
|
|
133
|
+
if (cascading === 'left-up') {
|
|
134
|
+
// 左侧在上,越后面越大
|
|
135
|
+
style.zIndex = index.value + 1
|
|
136
|
+
} else if (cascading === 'right-up') {
|
|
137
|
+
// 右侧在上,越前面越大
|
|
138
|
+
const maxCount = avatarGroup.value.props.maxCount
|
|
139
|
+
let count = avatarGroup.value.children?.length ?? 0
|
|
140
|
+
|
|
141
|
+
if (isDef(maxCount)) {
|
|
142
|
+
const parsedCount = typeof maxCount === 'number' ? maxCount : parseInt(maxCount, 10)
|
|
143
|
+
if (!isNaN(parsedCount) && parsedCount > 0) {
|
|
144
|
+
count = parsedCount
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
style.zIndex = count - index.value
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (props.color) {
|
|
152
|
+
style.color = props.color
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (props.bgColor) {
|
|
156
|
+
style.background = props.bgColor
|
|
157
|
+
// 有背景色但无文字色时,默认白色
|
|
158
|
+
if (!props.color) {
|
|
159
|
+
style.color = '#fff'
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return `${objToStyle(style)} ${props.customStyle}`
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* 处理图片加载失败事件
|
|
168
|
+
* @param {Event} event 失败事件对象
|
|
169
|
+
*/
|
|
170
|
+
const handleError = (event: Event) => {
|
|
171
|
+
emit('error', event)
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* 处理点击事件
|
|
176
|
+
*/
|
|
177
|
+
const handleClick = () => {
|
|
178
|
+
emit('click')
|
|
179
|
+
}
|
|
180
|
+
</script>
|
|
181
|
+
|
|
182
|
+
<style lang="scss">
|
|
183
|
+
@use './index.scss';
|
|
184
|
+
</style>
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { ExtractPropTypes, PropType } from 'vue'
|
|
2
|
+
import type { InjectionKey } from 'vue'
|
|
3
|
+
import { baseProps, makeStringProp, makeNumericProp } from '../../common/props'
|
|
4
|
+
import type { AvatarShape, AvatarSize } from '../wd-avatar/types'
|
|
5
|
+
|
|
6
|
+
export type AvatarGroupCascadingValue = 'left-up' | 'right-up'
|
|
7
|
+
|
|
8
|
+
export type AvatarGroupProvide = {
|
|
9
|
+
props: AvatarGroupProps
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const AVATAR_GROUP_KEY: InjectionKey<AvatarGroupProvide> = Symbol('wd-avatar-group')
|
|
13
|
+
|
|
14
|
+
export const avatarGroupProps = {
|
|
15
|
+
...baseProps,
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 最多显示的头像数量
|
|
19
|
+
* 类型: string | number
|
|
20
|
+
* 默认值: undefined
|
|
21
|
+
*/
|
|
22
|
+
maxCount: Number,
|
|
23
|
+
/**
|
|
24
|
+
* 头像层叠方向
|
|
25
|
+
* 可选值: left-up(左侧叠层) / right-up(右侧叠层)
|
|
26
|
+
* 类型: string
|
|
27
|
+
* 默认值: 'left-up'
|
|
28
|
+
*/
|
|
29
|
+
cascading: makeStringProp<AvatarGroupCascadingValue>('left-up'),
|
|
30
|
+
/**
|
|
31
|
+
* 统一设置组内所有头像的形状
|
|
32
|
+
* 类型: string
|
|
33
|
+
*/
|
|
34
|
+
shape: {
|
|
35
|
+
type: String as PropType<AvatarShape>,
|
|
36
|
+
default: 'round'
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 统一设置组内所有头像的尺寸,支持预设尺寸(large/medium/normal/small)或带单位的字符串(如 40px、100rpx)
|
|
41
|
+
* 类型: string | number
|
|
42
|
+
*/
|
|
43
|
+
size: {
|
|
44
|
+
type: [String, Number] as PropType<string | number | AvatarSize>,
|
|
45
|
+
default: 'normal'
|
|
46
|
+
},
|
|
47
|
+
/**
|
|
48
|
+
* 超出最大数量时折叠头像显示的内容
|
|
49
|
+
* 类型: string
|
|
50
|
+
* 默认值: undefined
|
|
51
|
+
*/
|
|
52
|
+
collapseAvatar: makeStringProp(''),
|
|
53
|
+
/**
|
|
54
|
+
* 是否垂直展示
|
|
55
|
+
* 类型: boolean
|
|
56
|
+
* 默认值: false
|
|
57
|
+
*/
|
|
58
|
+
vertical: Boolean
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export type AvatarGroupProps = ExtractPropTypes<typeof avatarGroupProps>
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view :class="rootClass" :style="customStyle">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
<!-- 折叠头像 -->
|
|
5
|
+
<wd-avatar
|
|
6
|
+
v-if="showCollapse"
|
|
7
|
+
:custom-style="collapseStyle"
|
|
8
|
+
_internal
|
|
9
|
+
:text="collapseText"
|
|
10
|
+
:shape="shape"
|
|
11
|
+
:size="size"
|
|
12
|
+
bg-color="#ebedf0"
|
|
13
|
+
color="#969799"
|
|
14
|
+
/>
|
|
15
|
+
</view>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<script lang="ts">
|
|
19
|
+
export default {
|
|
20
|
+
name: 'wd-avatar-group',
|
|
21
|
+
options: {
|
|
22
|
+
addGlobalClass: true,
|
|
23
|
+
// #ifndef MP-TOUTIAO
|
|
24
|
+
virtualHost: true,
|
|
25
|
+
// #endif
|
|
26
|
+
styleIsolation: 'shared'
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<script lang="ts" setup>
|
|
32
|
+
import { computed, useSlots, type CSSProperties } from 'vue'
|
|
33
|
+
import wdAvatar from '../wd-avatar/wd-avatar.vue'
|
|
34
|
+
import { avatarGroupProps, AVATAR_GROUP_KEY } from './types'
|
|
35
|
+
import { useChildren } from '../../composables/useChildren'
|
|
36
|
+
import { objToStyle, addUnit, isString } from '../../common/util'
|
|
37
|
+
|
|
38
|
+
const props = defineProps(avatarGroupProps)
|
|
39
|
+
const slots = useSlots()
|
|
40
|
+
|
|
41
|
+
const { children, linkChildren } = useChildren(AVATAR_GROUP_KEY)
|
|
42
|
+
|
|
43
|
+
linkChildren({ props })
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 根节点类名
|
|
47
|
+
*/
|
|
48
|
+
const rootClass = computed(() => {
|
|
49
|
+
return `wd-avatar-group wd-avatar-group--${props.cascading} ${props.customClass} ${props.vertical ? 'is-vertical' : ''}`
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
const maxCountValue = computed(() => {
|
|
53
|
+
if (!props.maxCount) {
|
|
54
|
+
return 0
|
|
55
|
+
}
|
|
56
|
+
const count = typeof props.maxCount === 'number' ? props.maxCount : parseInt(props.maxCount, 10)
|
|
57
|
+
return isNaN(count) || count <= 0 ? 0 : count
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* 是否显示折叠头像
|
|
62
|
+
*/
|
|
63
|
+
const showCollapse = computed(() => {
|
|
64
|
+
return maxCountValue.value > 0 && children.length > maxCountValue.value
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* 剩余未显示的数量
|
|
69
|
+
*/
|
|
70
|
+
const restCount = computed(() => {
|
|
71
|
+
if (maxCountValue.value <= 0) {
|
|
72
|
+
return 0
|
|
73
|
+
}
|
|
74
|
+
return Math.max(0, children.length - maxCountValue.value)
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* 折叠头像文本
|
|
79
|
+
*/
|
|
80
|
+
const collapseText = computed(() => {
|
|
81
|
+
return props.collapseAvatar || `+${restCount.value}`
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* 是否有默认插槽
|
|
86
|
+
*/
|
|
87
|
+
const hasDefaultSlot = computed(() => !!slots.default)
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* 折叠头像样式
|
|
91
|
+
*/
|
|
92
|
+
const collapseStyle = computed(() => {
|
|
93
|
+
const style: CSSProperties = {}
|
|
94
|
+
if (props.cascading === 'left-up') {
|
|
95
|
+
const count = maxCountValue.value > 0 ? maxCountValue.value : children.length
|
|
96
|
+
style.zIndex = count + 1
|
|
97
|
+
} else {
|
|
98
|
+
style.zIndex = 0
|
|
99
|
+
}
|
|
100
|
+
if (hasDefaultSlot.value) {
|
|
101
|
+
const isBuiltIn = isString(props.size) && ['large', 'medium', 'normal', 'small'].includes(props.size)
|
|
102
|
+
const margin = isBuiltIn ? 'var(--wot-avatar-overlap)' : `calc(${addUnit(props.size)} * -0.25)`
|
|
103
|
+
if (props.vertical) {
|
|
104
|
+
style.marginTop = margin
|
|
105
|
+
} else {
|
|
106
|
+
style.marginLeft = margin
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return objToStyle(style)
|
|
110
|
+
})
|
|
111
|
+
</script>
|
|
112
|
+
|
|
113
|
+
<style lang="scss">
|
|
114
|
+
@use './index.scss';
|
|
115
|
+
</style>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
@use '../../styles/mixin/mixin.scss'as *;
|
|
2
|
+
@use '../../styles/variable.scss'as *;
|
|
3
|
+
|
|
4
|
+
// 背景色
|
|
5
|
+
$backtop-bg: var(--wot-backtop-bg, $filled-oppo) !default;
|
|
6
|
+
// 边框颜色
|
|
7
|
+
$backtop-border-color: var(--wot-backtop-border-color, $border-main) !default;
|
|
8
|
+
// 按钮宽度
|
|
9
|
+
$backtop-width: var(--wot-backtop-width, $n-48) !default;
|
|
10
|
+
// 按钮高度
|
|
11
|
+
$backtop-height: var(--wot-backtop-height, $n-48) !default;
|
|
12
|
+
// 方形模式圆角
|
|
13
|
+
$backtop-radius: var(--wot-backtop-radius, $radius-main) !default;
|
|
14
|
+
// 圆形模式圆角
|
|
15
|
+
$backtop-radius-circle: var(--wot-backtop-radius-circle, $radius-radius-full) !default;
|
|
16
|
+
// 按钮图标颜色
|
|
17
|
+
$backtop-color: var(--wot-backtop-color, $icon-main) !default;
|
|
18
|
+
// 按钮图标尺寸
|
|
19
|
+
$backtop-icon-size: var(--wot-backtop-icon-size, $n-20) !default;
|
|
20
|
+
// 文本字号
|
|
21
|
+
$backtop-text-font-size: var(--wot-backtop-text-font-size, $typography-label-size-main) !default;
|
|
22
|
+
// 文本颜色
|
|
23
|
+
$backtop-text-color: var(--wot-backtop-text-color, $text-main) !default;
|
|
24
|
+
// 文本行高
|
|
25
|
+
$backtop-text-line-height: var(--wot-backtop-text-line-height, $typography-label-line--height-size-main) !default;
|
|
26
|
+
// 组件层级
|
|
27
|
+
$backtop-z-index: var(--wot-backtop-z-index, 100) !default;
|
|
28
|
+
|
|
29
|
+
@include b(backtop) {
|
|
30
|
+
@include pixelBorderSurround($backtop-border-color);
|
|
31
|
+
position: fixed;
|
|
32
|
+
background: $backtop-bg;
|
|
33
|
+
width: $backtop-width;
|
|
34
|
+
height: $backtop-height;
|
|
35
|
+
display: flex;
|
|
36
|
+
justify-content: center;
|
|
37
|
+
align-items: center;
|
|
38
|
+
color: $backtop-color;
|
|
39
|
+
z-index: $backtop-z-index;
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@include e(content) {
|
|
44
|
+
display: flex;
|
|
45
|
+
justify-content: center;
|
|
46
|
+
align-items: center;
|
|
47
|
+
flex-direction: column;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@include e(text) {
|
|
51
|
+
font-size: $backtop-text-font-size;
|
|
52
|
+
line-height: $backtop-text-line-height;
|
|
53
|
+
color: $backtop-text-color;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@include edeep(backicon) {
|
|
57
|
+
font-size: $backtop-icon-size;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@include when(circle) {
|
|
61
|
+
border-radius: $backtop-radius-circle;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@include when(square) {
|
|
65
|
+
border-radius: $backtop-radius;
|
|
66
|
+
}
|
|
67
|
+
}
|