@tplc/wot 0.0.1
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/components/common/AbortablePromise.ts +36 -0
- package/components/common/abstracts/_config.scss +7 -0
- package/components/common/abstracts/_function.scss +76 -0
- package/components/common/abstracts/_mixin.scss +339 -0
- package/components/common/abstracts/variable.scss +1346 -0
- package/components/common/base64.ts +30 -0
- package/components/common/canvasHelper.ts +49 -0
- package/components/common/clickoutside.ts +34 -0
- package/components/common/dayjs.ts +157 -0
- package/components/common/event.ts +8 -0
- package/components/common/props.ts +51 -0
- package/components/common/util.ts +751 -0
- package/components/composables/useCell.ts +13 -0
- package/components/composables/useChildren.ts +122 -0
- package/components/composables/useCountDown.ts +138 -0
- package/components/composables/useLockScroll.ts +39 -0
- package/components/composables/useParent.ts +41 -0
- package/components/composables/usePopover.ts +193 -0
- package/components/composables/useQueue.ts +52 -0
- package/components/composables/useRaf.ts +37 -0
- package/components/composables/useTouch.ts +44 -0
- package/components/composables/useTranslate.ts +22 -0
- package/components/wd-action-sheet/index.scss +204 -0
- package/components/wd-action-sheet/types.ts +128 -0
- package/components/wd-action-sheet/wd-action-sheet.vue +174 -0
- package/components/wd-backtop/index.scss +25 -0
- package/components/wd-backtop/types.ts +37 -0
- package/components/wd-backtop/wd-backtop.vue +48 -0
- package/components/wd-badge/index.scss +59 -0
- package/components/wd-badge/types.ts +53 -0
- package/components/wd-badge/wd-badge.vue +69 -0
- package/components/wd-button/index.scss +340 -0
- package/components/wd-button/types.ts +112 -0
- package/components/wd-button/wd-button.vue +176 -0
- package/components/wd-calendar/index.scss +244 -0
- package/components/wd-calendar/types.ts +235 -0
- package/components/wd-calendar/wd-calendar.vue +456 -0
- package/components/wd-calendar-view/index.scss +9 -0
- package/components/wd-calendar-view/month/index.scss +151 -0
- package/components/wd-calendar-view/month/month.vue +391 -0
- package/components/wd-calendar-view/month/types.ts +19 -0
- package/components/wd-calendar-view/monthPanel/index.scss +89 -0
- package/components/wd-calendar-view/monthPanel/month-panel.vue +388 -0
- package/components/wd-calendar-view/monthPanel/types.ts +48 -0
- package/components/wd-calendar-view/types.ts +134 -0
- package/components/wd-calendar-view/utils.ts +451 -0
- package/components/wd-calendar-view/wd-calendar-view.vue +111 -0
- package/components/wd-calendar-view/year/index.scss +148 -0
- package/components/wd-calendar-view/year/types.ts +19 -0
- package/components/wd-calendar-view/year/year.vue +220 -0
- package/components/wd-calendar-view/yearPanel/index.scss +24 -0
- package/components/wd-calendar-view/yearPanel/types.ts +38 -0
- package/components/wd-calendar-view/yearPanel/year-panel.vue +140 -0
- package/components/wd-card/index.scss +70 -0
- package/components/wd-card/types.ts +30 -0
- package/components/wd-card/wd-card.vue +40 -0
- package/components/wd-cell/index.scss +189 -0
- package/components/wd-cell/types.ts +96 -0
- package/components/wd-cell/wd-cell.vue +135 -0
- package/components/wd-cell-group/index.scss +55 -0
- package/components/wd-cell-group/types.ts +41 -0
- package/components/wd-cell-group/wd-cell-group.vue +45 -0
- package/components/wd-checkbox/index.scss +285 -0
- package/components/wd-checkbox/types.ts +68 -0
- package/components/wd-checkbox/wd-checkbox.vue +185 -0
- package/components/wd-checkbox-group/index.scss +20 -0
- package/components/wd-checkbox-group/types.ts +59 -0
- package/components/wd-checkbox-group/wd-checkbox-group.vue +103 -0
- package/components/wd-circle/index.scss +18 -0
- package/components/wd-circle/types.ts +54 -0
- package/components/wd-circle/wd-circle.vue +318 -0
- package/components/wd-col/index.scss +19 -0
- package/components/wd-col/types.ts +15 -0
- package/components/wd-col/wd-col.vue +91 -0
- package/components/wd-col-picker/index.scss +241 -0
- package/components/wd-col-picker/types.ts +170 -0
- package/components/wd-col-picker/wd-col-picker.vue +550 -0
- package/components/wd-collapse/index.scss +55 -0
- package/components/wd-collapse/types.ts +63 -0
- package/components/wd-collapse/wd-collapse.vue +160 -0
- package/components/wd-collapse-item/index.scss +79 -0
- package/components/wd-collapse-item/types.ts +36 -0
- package/components/wd-collapse-item/wd-collapse-item.vue +182 -0
- package/components/wd-config-provider/types.ts +1023 -0
- package/components/wd-config-provider/wd-config-provider.vue +82 -0
- package/components/wd-count-down/index.scss +14 -0
- package/components/wd-count-down/types.ts +41 -0
- package/components/wd-count-down/utils.ts +52 -0
- package/components/wd-count-down/wd-count-down.vue +60 -0
- package/components/wd-count-to/index.scss +6 -0
- package/components/wd-count-to/types.ts +110 -0
- package/components/wd-count-to/wd-count-to.vue +134 -0
- package/components/wd-curtain/index.scss +80 -0
- package/components/wd-curtain/types.ts +45 -0
- package/components/wd-curtain/wd-curtain.vue +174 -0
- package/components/wd-datetime-picker/index.scss +243 -0
- package/components/wd-datetime-picker/types.ts +225 -0
- package/components/wd-datetime-picker/wd-datetime-picker.vue +827 -0
- package/components/wd-datetime-picker-view/index.scss +0 -0
- package/components/wd-datetime-picker-view/types.ts +137 -0
- package/components/wd-datetime-picker-view/wd-datetime-picker-view.vue +514 -0
- package/components/wd-divider/index.scss +32 -0
- package/components/wd-divider/types.ts +12 -0
- package/components/wd-divider/wd-divider.vue +29 -0
- package/components/wd-drop-menu/index.scss +89 -0
- package/components/wd-drop-menu/types.ts +38 -0
- package/components/wd-drop-menu/wd-drop-menu.vue +128 -0
- package/components/wd-drop-menu-item/index.scss +66 -0
- package/components/wd-drop-menu-item/types.ts +78 -0
- package/components/wd-drop-menu-item/wd-drop-menu-item.vue +230 -0
- package/components/wd-fab/index.scss +115 -0
- package/components/wd-fab/types.ts +61 -0
- package/components/wd-fab/wd-fab.vue +257 -0
- package/components/wd-form/index.scss +10 -0
- package/components/wd-form/types.ts +93 -0
- package/components/wd-form/wd-form.vue +185 -0
- package/components/wd-form-item/index.scss +17 -0
- package/components/wd-form-item/types.ts +22 -0
- package/components/wd-form-item/wd-form-item.vue +65 -0
- package/components/wd-gap/index.scss +9 -0
- package/components/wd-gap/types.ts +23 -0
- package/components/wd-gap/wd-gap.vue +39 -0
- package/components/wd-grid/index.scss +9 -0
- package/components/wd-grid/types.ts +54 -0
- package/components/wd-grid/wd-grid.vue +107 -0
- package/components/wd-grid-item/index.scss +137 -0
- package/components/wd-grid-item/types.ts +74 -0
- package/components/wd-grid-item/wd-grid-item.vue +181 -0
- package/components/wd-icon/index.scss +1222 -0
- package/components/wd-icon/types.ts +21 -0
- package/components/wd-icon/wd-icon.vue +53 -0
- package/components/wd-icon/wd-icons.ttf +0 -0
- package/components/wd-img/index.scss +19 -0
- package/components/wd-img/types.ts +53 -0
- package/components/wd-img/wd-img.vue +76 -0
- package/components/wd-img-cropper/index.scss +227 -0
- package/components/wd-img-cropper/types.ts +87 -0
- package/components/wd-img-cropper/wd-img-cropper.vue +659 -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 +57 -0
- package/components/wd-index-bar/index.scss +39 -0
- package/components/wd-index-bar/type.ts +28 -0
- package/components/wd-index-bar/wd-index-bar.vue +158 -0
- package/components/wd-input/index.scss +326 -0
- package/components/wd-input/types.ts +182 -0
- package/components/wd-input/wd-input.vue +327 -0
- package/components/wd-input-number/index.scss +132 -0
- package/components/wd-input-number/types.ts +78 -0
- package/components/wd-input-number/wd-input-number.vue +221 -0
- package/components/wd-loading/index.scss +34 -0
- package/components/wd-loading/types.ts +31 -0
- package/components/wd-loading/wd-loading.vue +90 -0
- package/components/wd-loadmore/index.scss +39 -0
- package/components/wd-loadmore/types.ts +24 -0
- package/components/wd-loadmore/wd-loadmore.vue +53 -0
- package/components/wd-message-box/index.scss +121 -0
- package/components/wd-message-box/index.ts +95 -0
- package/components/wd-message-box/types.ts +116 -0
- package/components/wd-message-box/wd-message-box.vue +326 -0
- package/components/wd-navbar/index.scss +103 -0
- package/components/wd-navbar/types.ts +52 -0
- package/components/wd-navbar/wd-navbar.vue +142 -0
- package/components/wd-navbar-capsule/index.scss +65 -0
- package/components/wd-navbar-capsule/types.ts +0 -0
- package/components/wd-navbar-capsule/wd-navbar-capsule.vue +31 -0
- package/components/wd-notice-bar/index.scss +86 -0
- package/components/wd-notice-bar/types.ts +56 -0
- package/components/wd-notice-bar/wd-notice-bar.vue +223 -0
- package/components/wd-notify/index.scss +34 -0
- package/components/wd-notify/index.ts +59 -0
- package/components/wd-notify/types.ts +62 -0
- package/components/wd-notify/wd-notify.vue +83 -0
- package/components/wd-number-keyboard/index.scss +78 -0
- package/components/wd-number-keyboard/key/index.scss +79 -0
- package/components/wd-number-keyboard/key/index.vue +76 -0
- package/components/wd-number-keyboard/key/types.ts +11 -0
- package/components/wd-number-keyboard/types.ts +79 -0
- package/components/wd-number-keyboard/wd-number-keyboard.vue +173 -0
- package/components/wd-overlay/index.scss +17 -0
- package/components/wd-overlay/types.ts +25 -0
- package/components/wd-overlay/wd-overlay.vue +46 -0
- package/components/wd-pagination/index.scss +57 -0
- package/components/wd-pagination/types.ts +41 -0
- package/components/wd-pagination/wd-pagination.vue +121 -0
- package/components/wd-password-input/index.scss +123 -0
- package/components/wd-password-input/types.ts +48 -0
- package/components/wd-password-input/wd-password-input.vue +58 -0
- package/components/wd-picker/index.scss +216 -0
- package/components/wd-picker/types.ts +186 -0
- package/components/wd-picker/wd-picker.vue +409 -0
- package/components/wd-picker-view/index.scss +91 -0
- package/components/wd-picker-view/types.ts +162 -0
- package/components/wd-picker-view/wd-picker-view.vue +361 -0
- package/components/wd-popover/index.scss +123 -0
- package/components/wd-popover/types.ts +69 -0
- package/components/wd-popover/wd-popover.vue +216 -0
- package/components/wd-popup/index.scss +112 -0
- package/components/wd-popup/types.ts +68 -0
- package/components/wd-popup/wd-popup.vue +227 -0
- package/components/wd-progress/index.scss +62 -0
- package/components/wd-progress/types.ts +40 -0
- package/components/wd-progress/wd-progress.vue +201 -0
- package/components/wd-radio/index.scss +300 -0
- package/components/wd-radio/types.ts +42 -0
- package/components/wd-radio/wd-radio.vue +136 -0
- package/components/wd-radio-group/index.scss +23 -0
- package/components/wd-radio-group/types.ts +36 -0
- package/components/wd-radio-group/wd-radio-group.vue +54 -0
- package/components/wd-rate/index.scss +24 -0
- package/components/wd-rate/types.ts +91 -0
- package/components/wd-rate/wd-rate.vue +131 -0
- package/components/wd-resize/index.scss +26 -0
- package/components/wd-resize/types.ts +6 -0
- package/components/wd-resize/wd-resize.vue +155 -0
- package/components/wd-row/index.scss +10 -0
- package/components/wd-row/types.ts +16 -0
- package/components/wd-row/wd-row.vue +63 -0
- package/components/wd-search/index.scss +148 -0
- package/components/wd-search/types.ts +83 -0
- package/components/wd-search/wd-search.vue +237 -0
- package/components/wd-segmented/index.scss +97 -0
- package/components/wd-segmented/types.ts +68 -0
- package/components/wd-segmented/wd-segmented.vue +143 -0
- package/components/wd-select-picker/index.scss +177 -0
- package/components/wd-select-picker/types.ts +116 -0
- package/components/wd-select-picker/wd-select-picker.vue +486 -0
- package/components/wd-sidebar/index.scss +25 -0
- package/components/wd-sidebar/types.ts +28 -0
- package/components/wd-sidebar/wd-sidebar.vue +41 -0
- package/components/wd-sidebar-item/index.scss +93 -0
- package/components/wd-sidebar-item/types.ts +31 -0
- package/components/wd-sidebar-item/wd-sidebar-item.vue +114 -0
- package/components/wd-skeleton/index.scss +101 -0
- package/components/wd-skeleton/index.ts +1 -0
- package/components/wd-skeleton/types.ts +69 -0
- package/components/wd-skeleton/wd-skeleton.vue +135 -0
- package/components/wd-slider/index.scss +91 -0
- package/components/wd-slider/types.ts +104 -0
- package/components/wd-slider/wd-slider.vue +377 -0
- package/components/wd-sort-button/index.scss +86 -0
- package/components/wd-sort-button/types.ts +43 -0
- package/components/wd-sort-button/wd-sort-button.vue +76 -0
- package/components/wd-status-tip/index.scss +37 -0
- package/components/wd-status-tip/types.ts +59 -0
- package/components/wd-status-tip/wd-status-tip.vue +94 -0
- package/components/wd-step/index.scss +236 -0
- package/components/wd-step/types.ts +33 -0
- package/components/wd-step/wd-step.vue +151 -0
- package/components/wd-steps/index.scss +10 -0
- package/components/wd-steps/types.ts +59 -0
- package/components/wd-steps/wd-steps.vue +37 -0
- package/components/wd-sticky/index.scss +9 -0
- package/components/wd-sticky/types.ts +13 -0
- package/components/wd-sticky/wd-sticky.vue +190 -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 +154 -0
- package/components/wd-swipe-action/index.scss +22 -0
- package/components/wd-swipe-action/types.ts +43 -0
- package/components/wd-swipe-action/wd-swipe-action.vue +307 -0
- package/components/wd-swiper/index.scss +23 -0
- package/components/wd-swiper/types.ts +189 -0
- package/components/wd-swiper/wd-swiper.vue +202 -0
- package/components/wd-swiper-nav/index.scss +153 -0
- package/components/wd-swiper-nav/types.ts +42 -0
- package/components/wd-swiper-nav/wd-swiper-nav.vue +37 -0
- package/components/wd-switch/index.scss +58 -0
- package/components/wd-switch/types.ts +56 -0
- package/components/wd-switch/wd-switch.vue +83 -0
- package/components/wd-tab/index.scss +8 -0
- package/components/wd-tab/types.ts +20 -0
- package/components/wd-tab/wd-tab.vue +100 -0
- package/components/wd-tabbar/index.scss +57 -0
- package/components/wd-tabbar/types.ts +88 -0
- package/components/wd-tabbar/wd-tabbar.vue +104 -0
- package/components/wd-tabbar-item/index.scss +52 -0
- package/components/wd-tabbar-item/types.ts +51 -0
- package/components/wd-tabbar-item/wd-tabbar-item.vue +101 -0
- package/components/wd-table/index.scss +132 -0
- package/components/wd-table/types.ts +69 -0
- package/components/wd-table/wd-table.vue +255 -0
- package/components/wd-table-col/index.scss +44 -0
- package/components/wd-table-col/types.ts +54 -0
- package/components/wd-table-col/wd-table-col.vue +149 -0
- package/components/wd-tabs/index.scss +280 -0
- package/components/wd-tabs/types.ts +71 -0
- package/components/wd-tabs/wd-tabs.vue +528 -0
- package/components/wd-tag/index.scss +115 -0
- package/components/wd-tag/types.ts +81 -0
- package/components/wd-tag/wd-tag.vue +154 -0
- package/components/wd-text/index.scss +34 -0
- package/components/wd-text/types.ts +98 -0
- package/components/wd-text/wd-text.vue +138 -0
- package/components/wd-textarea/index.scss +343 -0
- package/components/wd-textarea/types.ts +298 -0
- package/components/wd-textarea/wd-textarea.vue +303 -0
- package/components/wd-toast/index.scss +66 -0
- package/components/wd-toast/index.ts +109 -0
- package/components/wd-toast/types.ts +76 -0
- package/components/wd-toast/wd-toast.vue +212 -0
- package/components/wd-tooltip/index.scss +61 -0
- package/components/wd-tooltip/types.ts +102 -0
- package/components/wd-tooltip/wd-tooltip.vue +167 -0
- package/components/wd-transition/index.scss +91 -0
- package/components/wd-transition/types.ts +89 -0
- package/components/wd-transition/wd-transition.vue +221 -0
- package/components/wd-upload/index.scss +173 -0
- package/components/wd-upload/types.ts +378 -0
- package/components/wd-upload/utils.ts +152 -0
- package/components/wd-upload/wd-upload.vue +737 -0
- package/components/wd-video-preview/index.scss +34 -0
- package/components/wd-video-preview/types.ts +32 -0
- package/components/wd-video-preview/wd-video-preview.vue +76 -0
- package/components/wd-watermark/index.scss +18 -0
- package/components/wd-watermark/types.ts +82 -0
- package/components/wd-watermark/wd-watermark.vue +592 -0
- package/components/wot-design-uni/wot-design-uni.vue +14 -0
- package/global.d.ts +108 -0
- package/index.ts +30 -0
- package/locale/index.ts +41 -0
- package/locale/lang/en-US.ts +128 -0
- package/locale/lang/th-TH.ts +127 -0
- package/locale/lang/vi-VN.ts +89 -0
- package/locale/lang/zh-CN.ts +127 -0
- package/locale/lang/zh-HK.ts +84 -0
- package/locale/lang/zh-TW.ts +84 -0
- package/package.json +20 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { ExtractPropTypes } from 'vue'
|
|
2
|
+
import { baseProps, makeBooleanProp, makeStringProp } from '../common/props'
|
|
3
|
+
|
|
4
|
+
export type TagType = 'default' | 'primary' | 'success' | 'warning' | 'danger'
|
|
5
|
+
|
|
6
|
+
export const tagProps = {
|
|
7
|
+
...baseProps,
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 是否开启图标插槽
|
|
11
|
+
* 类型:boolean
|
|
12
|
+
* 默认值:false
|
|
13
|
+
*/
|
|
14
|
+
useIconSlot: makeBooleanProp(false),
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 标签类型
|
|
18
|
+
* 类型:string
|
|
19
|
+
* 可选值:'default' / 'primary' / 'danger' / 'warning' / 'success'
|
|
20
|
+
* 默认值:'default'
|
|
21
|
+
*/
|
|
22
|
+
type: makeStringProp<TagType>('default'),
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 左侧图标
|
|
26
|
+
* 类型:string
|
|
27
|
+
* 默认值:空字符串
|
|
28
|
+
*/
|
|
29
|
+
icon: makeStringProp(''),
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 是否可关闭(只对圆角类型支持)
|
|
33
|
+
* 类型:boolean
|
|
34
|
+
* 默认值:false
|
|
35
|
+
*/
|
|
36
|
+
closable: makeBooleanProp(false),
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 幽灵类型
|
|
40
|
+
* 类型:boolean
|
|
41
|
+
* 默认值:false
|
|
42
|
+
*/
|
|
43
|
+
plain: makeBooleanProp(false),
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 是否为新增标签
|
|
47
|
+
* 类型:boolean
|
|
48
|
+
* 默认值:false
|
|
49
|
+
*/
|
|
50
|
+
dynamic: makeBooleanProp(false),
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 文字颜色
|
|
54
|
+
* 类型:string
|
|
55
|
+
* 默认值:空字符串
|
|
56
|
+
*/
|
|
57
|
+
color: makeStringProp(''),
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 背景色和边框色
|
|
61
|
+
* 类型:string
|
|
62
|
+
* 默认值:空字符串
|
|
63
|
+
*/
|
|
64
|
+
bgColor: makeStringProp(''),
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* 圆角类型
|
|
68
|
+
* 类型:boolean
|
|
69
|
+
* 默认值:false
|
|
70
|
+
*/
|
|
71
|
+
round: makeBooleanProp(false),
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 标记类型
|
|
75
|
+
* 类型:boolean
|
|
76
|
+
* 默认值:false
|
|
77
|
+
*/
|
|
78
|
+
mark: makeBooleanProp(false),
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export type TagProps = ExtractPropTypes<typeof tagProps>
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view :class="rootClass" :style="rootStyle" @click="handleClick">
|
|
3
|
+
<view v-if="useIconSlot" class="wd-tag__icon">
|
|
4
|
+
<slot name="icon" />
|
|
5
|
+
</view>
|
|
6
|
+
<wd-icon v-else-if="icon" :name="icon" custom-class="wd-tag__icon" />
|
|
7
|
+
<view class="wd-tag__text" :style="textStyle">
|
|
8
|
+
<slot />
|
|
9
|
+
</view>
|
|
10
|
+
<view class="wd-tag__close" v-if="closable && round" @click.stop="handleClose">
|
|
11
|
+
<wd-icon name="error-fill" />
|
|
12
|
+
</view>
|
|
13
|
+
<input
|
|
14
|
+
v-if="dynamicInput && dynamic"
|
|
15
|
+
class="wd-tag__add-text"
|
|
16
|
+
:placeholder="translate('placeholder')"
|
|
17
|
+
type="text"
|
|
18
|
+
focus="true"
|
|
19
|
+
v-model="dynamicValue"
|
|
20
|
+
@blur="handleBlur"
|
|
21
|
+
@confirm="handleConfirm"
|
|
22
|
+
/>
|
|
23
|
+
<view v-else-if="dynamic" class="wd-tag__text" :style="textStyle" @click.stop="handleAdd">
|
|
24
|
+
<slot name="add" v-if="$slots.add"></slot>
|
|
25
|
+
<template v-else>
|
|
26
|
+
<wd-icon name="add" custom-class="wd-tag__add wd-tag__icon" />
|
|
27
|
+
<text>{{ translate('add') }}</text>
|
|
28
|
+
</template>
|
|
29
|
+
</view>
|
|
30
|
+
</view>
|
|
31
|
+
</template>
|
|
32
|
+
|
|
33
|
+
<script lang="ts">
|
|
34
|
+
export default {
|
|
35
|
+
name: 'wd-tag',
|
|
36
|
+
options: {
|
|
37
|
+
addGlobalClass: true,
|
|
38
|
+
virtualHost: true,
|
|
39
|
+
styleIsolation: 'shared',
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
</script>
|
|
43
|
+
<script lang="ts" setup>
|
|
44
|
+
import { objToStyle } from '../common/util'
|
|
45
|
+
import { computed, ref, watch } from 'vue'
|
|
46
|
+
import { useTranslate } from '../composables/useTranslate'
|
|
47
|
+
import { tagProps } from './types'
|
|
48
|
+
|
|
49
|
+
const props = defineProps(tagProps)
|
|
50
|
+
const emit = defineEmits(['click', 'close', 'confirm'])
|
|
51
|
+
|
|
52
|
+
const { translate } = useTranslate('tag')
|
|
53
|
+
|
|
54
|
+
const tagClass = ref<string>('')
|
|
55
|
+
const dynamicValue = ref<string>('')
|
|
56
|
+
const dynamicInput = ref<boolean>(false)
|
|
57
|
+
|
|
58
|
+
watch(
|
|
59
|
+
[
|
|
60
|
+
() => props.useIconSlot,
|
|
61
|
+
() => props.icon,
|
|
62
|
+
() => props.plain,
|
|
63
|
+
() => props.dynamic,
|
|
64
|
+
() => props.round,
|
|
65
|
+
() => props.mark,
|
|
66
|
+
],
|
|
67
|
+
() => {
|
|
68
|
+
computeTagClass()
|
|
69
|
+
},
|
|
70
|
+
{ deep: true, immediate: true },
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
watch(
|
|
74
|
+
() => props.type,
|
|
75
|
+
(newValue) => {
|
|
76
|
+
if (!newValue) return
|
|
77
|
+
// type: 'primary', 'danger', 'warning', 'success'
|
|
78
|
+
const type = ['primary', 'danger', 'warning', 'success', 'default']
|
|
79
|
+
if (type.indexOf(newValue) === -1) console.error(`type must be one of ${type.toString()}`)
|
|
80
|
+
computeTagClass()
|
|
81
|
+
},
|
|
82
|
+
{ deep: true, immediate: true },
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
watch(
|
|
86
|
+
() => dynamicInput.value,
|
|
87
|
+
() => {
|
|
88
|
+
computeTagClass()
|
|
89
|
+
},
|
|
90
|
+
{ deep: true, immediate: true },
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
const rootClass = computed(() => {
|
|
94
|
+
return `wd-tag ${props.customClass} ${tagClass.value}`
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
const rootStyle = computed(() => {
|
|
98
|
+
const rootStyle: Record<string, any> = {}
|
|
99
|
+
if (!props.plain && props.bgColor) {
|
|
100
|
+
rootStyle.background = props.bgColor
|
|
101
|
+
}
|
|
102
|
+
if (props.bgColor) {
|
|
103
|
+
rootStyle['border-color'] = props.bgColor
|
|
104
|
+
}
|
|
105
|
+
return `${objToStyle(rootStyle)};${props.customStyle}`
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
const textStyle = computed(() => {
|
|
109
|
+
const textStyle: Record<string, any> = {}
|
|
110
|
+
if (props.color) {
|
|
111
|
+
textStyle.color = props.color
|
|
112
|
+
}
|
|
113
|
+
return objToStyle(textStyle)
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
function computeTagClass() {
|
|
117
|
+
const { type, plain, round, mark, dynamic, icon, useIconSlot } = props
|
|
118
|
+
const tagClassList: string[] = []
|
|
119
|
+
type && tagClassList.push(`is-${type}`)
|
|
120
|
+
plain && tagClassList.push('is-plain')
|
|
121
|
+
round && tagClassList.push('is-round')
|
|
122
|
+
mark && tagClassList.push('is-mark')
|
|
123
|
+
dynamic && tagClassList.push('is-dynamic')
|
|
124
|
+
dynamicInput.value && tagClassList.push('is-dynamic-input')
|
|
125
|
+
if (icon || useIconSlot) tagClassList.push('is-icon')
|
|
126
|
+
tagClass.value = tagClassList.join(' ')
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function handleClick(event: any) {
|
|
130
|
+
emit('click', event)
|
|
131
|
+
}
|
|
132
|
+
function handleClose(event: any) {
|
|
133
|
+
emit('close', event)
|
|
134
|
+
}
|
|
135
|
+
function handleAdd() {
|
|
136
|
+
dynamicInput.value = true
|
|
137
|
+
dynamicValue.value = ''
|
|
138
|
+
}
|
|
139
|
+
function handleBlur() {
|
|
140
|
+
setDynamicInput()
|
|
141
|
+
}
|
|
142
|
+
function handleConfirm(event: any) {
|
|
143
|
+
setDynamicInput()
|
|
144
|
+
emit('confirm', {
|
|
145
|
+
value: event.detail.value,
|
|
146
|
+
})
|
|
147
|
+
}
|
|
148
|
+
function setDynamicInput() {
|
|
149
|
+
dynamicInput.value = false
|
|
150
|
+
}
|
|
151
|
+
</script>
|
|
152
|
+
<style lang="scss" scoped>
|
|
153
|
+
@import './index';
|
|
154
|
+
</style>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
@import '../common/abstracts/variable';
|
|
2
|
+
@import '../common/abstracts/mixin';
|
|
3
|
+
|
|
4
|
+
@include b(text) {
|
|
5
|
+
@include when(bold) {
|
|
6
|
+
font-weight: bold;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
@for $i from 1 through 5 {
|
|
10
|
+
&.is-lines-#{$i} {
|
|
11
|
+
@include multiEllipsis($i);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@include when(default) {
|
|
16
|
+
color: $-text-info-color;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@include when(primary) {
|
|
20
|
+
color: $-text-primary-color;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@include when(error) {
|
|
24
|
+
color: $-text-error-color;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@include when(warning) {
|
|
28
|
+
color: $-text-warning-color;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@include when(success) {
|
|
32
|
+
color: $-text-success-color;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { ExtractPropTypes } from 'vue'
|
|
2
|
+
import { baseProps, makeBooleanProp, makeStringProp } from '../common/props'
|
|
3
|
+
|
|
4
|
+
export type TextType = 'default' | 'primary' | 'success' | 'warning' | 'error'
|
|
5
|
+
|
|
6
|
+
export const textProps = {
|
|
7
|
+
...baseProps,
|
|
8
|
+
/**
|
|
9
|
+
* 主题类型
|
|
10
|
+
* 类型:string
|
|
11
|
+
* 可选值:'default' /'primary' / 'error' / 'warning' / 'success'
|
|
12
|
+
* 默认值:'default'
|
|
13
|
+
*/
|
|
14
|
+
type: makeStringProp<TextType>('default'),
|
|
15
|
+
/**
|
|
16
|
+
* 文字
|
|
17
|
+
* 类型:string
|
|
18
|
+
* 默认值:'空字符串'
|
|
19
|
+
*/
|
|
20
|
+
text: makeStringProp(''),
|
|
21
|
+
/**
|
|
22
|
+
* 字体大小
|
|
23
|
+
* 类型:string
|
|
24
|
+
* 默认值:'空字符串'
|
|
25
|
+
*/
|
|
26
|
+
size: makeStringProp(''),
|
|
27
|
+
/**
|
|
28
|
+
* 文本处理的匹配模式
|
|
29
|
+
* 可选值:'text-普通文本' / 'date - 日期' / 'phone - 手机号' / 'name - 姓名' / 'price - 金额'
|
|
30
|
+
* 类型:string
|
|
31
|
+
* 默认值:'text'
|
|
32
|
+
*/
|
|
33
|
+
mode: makeStringProp('text'),
|
|
34
|
+
/**
|
|
35
|
+
* 文字装饰,下划线,中划线等
|
|
36
|
+
* 可选值:'underline/line-through/overline'
|
|
37
|
+
* 类型:string
|
|
38
|
+
* 默认值:'none'
|
|
39
|
+
*/
|
|
40
|
+
decoration: makeStringProp('none'),
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* mode=phone时,点击文本是否拨打电话
|
|
44
|
+
* 类型:boolean
|
|
45
|
+
* 默认值:false
|
|
46
|
+
*/
|
|
47
|
+
call: makeBooleanProp(false),
|
|
48
|
+
/**
|
|
49
|
+
* 是否粗体,默认normal
|
|
50
|
+
* 类型:boolean
|
|
51
|
+
* 默认值:false
|
|
52
|
+
*/
|
|
53
|
+
bold: makeBooleanProp(false),
|
|
54
|
+
/**
|
|
55
|
+
* 是否脱敏,当mode为phone和name时生效
|
|
56
|
+
* 类型:boolean
|
|
57
|
+
* 默认值:false
|
|
58
|
+
*/
|
|
59
|
+
format: makeBooleanProp(false),
|
|
60
|
+
/**
|
|
61
|
+
* 文本颜色
|
|
62
|
+
* 类型:string
|
|
63
|
+
* 默认值:''
|
|
64
|
+
*/
|
|
65
|
+
color: makeStringProp(''),
|
|
66
|
+
/**
|
|
67
|
+
* 前置插槽
|
|
68
|
+
* 类型:string
|
|
69
|
+
* 默认值:''
|
|
70
|
+
*/
|
|
71
|
+
prefix: String,
|
|
72
|
+
/**
|
|
73
|
+
* 后置插槽
|
|
74
|
+
* 类型:string
|
|
75
|
+
* 默认值:''
|
|
76
|
+
*/
|
|
77
|
+
suffix: String,
|
|
78
|
+
/**
|
|
79
|
+
* 文本显示的行数,如果设置,超出此行数,将会显示省略号。最大值为5。
|
|
80
|
+
*/
|
|
81
|
+
lines: Number,
|
|
82
|
+
/**
|
|
83
|
+
* 文本行高
|
|
84
|
+
* 类型:string
|
|
85
|
+
* 默认值:''
|
|
86
|
+
*/
|
|
87
|
+
lineHeight: makeStringProp(''),
|
|
88
|
+
/**
|
|
89
|
+
* 自定义根节点样式
|
|
90
|
+
*/
|
|
91
|
+
customStyle: makeStringProp(''),
|
|
92
|
+
/**
|
|
93
|
+
* 自定义根节点样式类
|
|
94
|
+
*/
|
|
95
|
+
customClass: makeStringProp(''),
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export type TextProps = ExtractPropTypes<typeof textProps>
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<text @click="handleClick" :class="rootClass" :style="rootStyle">
|
|
3
|
+
<slot v-if="$slots.prefix || prefix" name="prefix">{{ prefix }}</slot>
|
|
4
|
+
<text>{{ formattedText }}</text>
|
|
5
|
+
<slot v-if="$slots.suffix || suffix" name="suffix">{{ suffix }}</slot>
|
|
6
|
+
</text>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script lang="ts">
|
|
10
|
+
export default {
|
|
11
|
+
name: 'wd-text',
|
|
12
|
+
options: {
|
|
13
|
+
virtualHost: true,
|
|
14
|
+
addGlobalClass: true,
|
|
15
|
+
styleIsolation: 'shared',
|
|
16
|
+
},
|
|
17
|
+
}
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<script lang="ts" setup>
|
|
21
|
+
import { computed, ref, watch } from 'vue'
|
|
22
|
+
import { isDef, objToStyle } from '../common/util'
|
|
23
|
+
import { textProps } from './types'
|
|
24
|
+
import { dayjs } from '../common/dayjs'
|
|
25
|
+
|
|
26
|
+
// 获取组件的 props 和 emit 函数
|
|
27
|
+
const props = defineProps(textProps)
|
|
28
|
+
const emit = defineEmits(['click'])
|
|
29
|
+
|
|
30
|
+
// 存储文本类名的响应式变量
|
|
31
|
+
const textClass = ref<string>('')
|
|
32
|
+
|
|
33
|
+
// 监听 props 变化,合并 watch 逻辑
|
|
34
|
+
watch(
|
|
35
|
+
() => ({
|
|
36
|
+
type: props.type,
|
|
37
|
+
text: props.text,
|
|
38
|
+
mode: props.mode,
|
|
39
|
+
color: props.color,
|
|
40
|
+
bold: props.bold,
|
|
41
|
+
lines: props.lines,
|
|
42
|
+
format: props.format,
|
|
43
|
+
}),
|
|
44
|
+
({ type }) => {
|
|
45
|
+
// 验证 type 属性
|
|
46
|
+
if (type && !['primary', 'error', 'warning', 'success', 'default'].includes(type)) {
|
|
47
|
+
console.error(`type must be one of ${type.toString()}`)
|
|
48
|
+
}
|
|
49
|
+
computeTextClass()
|
|
50
|
+
},
|
|
51
|
+
{ deep: true, immediate: true },
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
// 计算根元素的类名
|
|
55
|
+
const rootClass = computed(() => {
|
|
56
|
+
return `wd-text ${props.customClass} ${textClass.value}`
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
// 计算根元素的样式
|
|
60
|
+
const rootStyle = computed(() => {
|
|
61
|
+
const rootStyle: Record<string, any> = {}
|
|
62
|
+
if (props.color) {
|
|
63
|
+
rootStyle.color = props.color
|
|
64
|
+
}
|
|
65
|
+
if (props.size) {
|
|
66
|
+
rootStyle['font-size'] = `${props.size}`
|
|
67
|
+
}
|
|
68
|
+
if (props.lineHeight) {
|
|
69
|
+
rootStyle['line-height'] = `${props.lineHeight}`
|
|
70
|
+
}
|
|
71
|
+
if (props.decoration) {
|
|
72
|
+
rootStyle['text-decoration'] = `${props.decoration}`
|
|
73
|
+
}
|
|
74
|
+
return `${objToStyle(rootStyle)};${props.customStyle}`
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
// 计算文本类名的函数
|
|
78
|
+
function computeTextClass() {
|
|
79
|
+
const { type, color, bold, lines } = props
|
|
80
|
+
const textClassList: string[] = []
|
|
81
|
+
if (!color) {
|
|
82
|
+
textClassList.push(`is-${type}`)
|
|
83
|
+
}
|
|
84
|
+
if (isDef(lines)) {
|
|
85
|
+
textClassList.push(`is-lines-${lines}`)
|
|
86
|
+
}
|
|
87
|
+
bold && textClassList.push('is-bold')
|
|
88
|
+
textClass.value = textClassList.join(' ')
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// 格式化文本的函数
|
|
92
|
+
function formatText(text: string, format: boolean, mode: string): string {
|
|
93
|
+
if (format) {
|
|
94
|
+
if (mode === 'phone') {
|
|
95
|
+
return text.replace(/^(\d{3})\d{4}(\d{4})$/, '$1****$2')
|
|
96
|
+
} else if (mode === 'name') {
|
|
97
|
+
return text.replace(/^(.).*(.)$/, '$1**$2')
|
|
98
|
+
} else {
|
|
99
|
+
throw new Error('mode must be one of phone or name for encryption')
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return text
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// 格式化数字的函数
|
|
106
|
+
function formatNumber(num: number | string): string {
|
|
107
|
+
num = Number(num).toFixed(2)
|
|
108
|
+
const x = num.split('.')
|
|
109
|
+
let x1 = x[0]
|
|
110
|
+
const x2 = x.length > 1 ? '.' + x[1] : ''
|
|
111
|
+
const rgx = /(\d+)(\d{3})/
|
|
112
|
+
while (rgx.test(x1)) {
|
|
113
|
+
x1 = x1.replace(rgx, '$1,$2')
|
|
114
|
+
}
|
|
115
|
+
return x1 + x2
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// 计算格式化后的文本
|
|
119
|
+
const formattedText = computed(() => {
|
|
120
|
+
const { text, mode, format } = props
|
|
121
|
+
if (mode === 'date') {
|
|
122
|
+
return dayjs(Number(text)).format('YYYY-MM-DD')
|
|
123
|
+
}
|
|
124
|
+
if (mode === 'price') {
|
|
125
|
+
return formatNumber(text)
|
|
126
|
+
}
|
|
127
|
+
return formatText(text, format, mode)
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
// 处理点击事件
|
|
131
|
+
function handleClick(event: Event) {
|
|
132
|
+
emit('click', event)
|
|
133
|
+
}
|
|
134
|
+
</script>
|
|
135
|
+
|
|
136
|
+
<style lang="scss" scoped>
|
|
137
|
+
@import './index';
|
|
138
|
+
</style>
|