@wot-ui/ui 2.0.7 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +11 -11
  2. package/attributes.json +1 -1
  3. package/changelog.md +26 -0
  4. package/common/AbortablePromise.ts +28 -0
  5. package/common/canvasHelper.ts +49 -0
  6. package/common/clickoutside.ts +25 -0
  7. package/common/event.ts +8 -0
  8. package/common/formatDate.ts +68 -0
  9. package/common/interceptor.ts +43 -0
  10. package/common/props.ts +53 -0
  11. package/common/util.ts +836 -0
  12. package/components/wd-avatar/wd-avatar.vue +1 -1
  13. package/components/wd-button/types.ts +11 -8
  14. package/components/wd-button/wd-button.vue +26 -4
  15. package/components/wd-calendar-view/monthPanel/month-panel.vue +1 -0
  16. package/components/wd-calendar-view/yearPanel/year-panel.vue +1 -0
  17. package/components/wd-cell/index.scss +12 -1
  18. package/components/wd-config-provider/global-config.ts +50 -0
  19. package/components/wd-config-provider/theme-vars.ts +2073 -0
  20. package/components/wd-config-provider/types.ts +20 -2071
  21. package/components/wd-config-provider/wd-config-provider.vue +15 -4
  22. package/components/wd-dialog/wd-dialog.vue +1 -0
  23. package/components/wd-drop-menu/wd-drop-menu.vue +1 -0
  24. package/components/wd-grid/wd-grid.vue +0 -2
  25. package/components/wd-icon/wd-icon.vue +2 -2
  26. package/components/wd-img/wd-img.vue +1 -0
  27. package/components/wd-index-anchor/index.scss +5 -5
  28. package/components/wd-index-bar/index.scss +14 -14
  29. package/components/wd-keyboard/key/index.vue +2 -0
  30. package/components/wd-notify/wd-notify.vue +1 -0
  31. package/components/wd-picker-view/useSelection.ts +3 -1
  32. package/components/wd-root-portal/wd-root-portal.vue +1 -1
  33. package/components/wd-select-picker/wd-select-picker.vue +1 -0
  34. package/components/wd-signature/wd-signature.vue +1 -0
  35. package/components/wd-slider/index.scss +45 -45
  36. package/components/wd-slider/wd-slider.vue +19 -3
  37. package/components/wd-switch/wd-switch.vue +2 -0
  38. package/components/wd-tabs/wd-tabs.vue +1 -0
  39. package/components/wd-tag/index.scss +8 -7
  40. package/components/wd-tag/types.ts +10 -7
  41. package/components/wd-tag/wd-tag.vue +23 -6
  42. package/components/wd-toast/wd-toast.vue +4 -0
  43. package/composables/index.ts +2 -0
  44. package/composables/useConfigProvider.ts +27 -12
  45. package/composables/useGlobalConfig.ts +9 -0
  46. package/index.ts +1 -1
  47. package/package.json +1 -1
  48. package/styles/variable.scss +381 -381
  49. package/tags.json +1 -1
  50. package/web-types.json +1 -1
@@ -22,21 +22,22 @@ import { computed, inject } from 'vue'
22
22
  import { configProviderProps, CONFIG_PROVIDER_KEY, type ConfigProviderProvide } from './types'
23
23
  import { objToStyle } from '../../common/util'
24
24
  import { useChildren } from '../../composables/useChildren'
25
+ import { useParent } from '../../composables/useParent'
25
26
  import { mapThemeVarsToCSSVars } from '../../composables/useConfigProvider'
26
27
  import { USE_CONFIG_PROVIDER_KEY } from '../../composables/useConfigProvider'
28
+ import { mergeConfig, type ConfigProviderInput, type GlobalConfig } from './global-config'
27
29
 
28
30
  const None = Symbol('None')
29
31
  const hooksProvider = inject<ConfigProviderProvide | typeof None>(USE_CONFIG_PROVIDER_KEY, None)
30
32
  const props = defineProps(configProviderProps)
31
33
 
32
34
  const { linkChildren } = useChildren(CONFIG_PROVIDER_KEY)
35
+ const { parent: parentConfigProvider } = useParent(CONFIG_PROVIDER_KEY)
33
36
 
34
37
  const themeClass = computed(() => {
35
38
  return `wot-theme-${props.theme} ${props.customClass}`
36
39
  })
37
40
 
38
- const themeValue = computed(() => props.theme)
39
-
40
41
  const themeStyle = computed(() => {
41
42
  if (hooksProvider !== None) {
42
43
  return hooksProvider.themeStyle.value
@@ -50,9 +51,19 @@ const rootStyle = computed(() => {
50
51
  return style
51
52
  })
52
53
 
54
+ const globalConfig = computed<GlobalConfig>(() => {
55
+ const parentGlobalConfig = parentConfigProvider.value?.globalConfig.value || null
56
+ return mergeConfig(parentGlobalConfig, {
57
+ theme: props.theme,
58
+ themeVars: props.themeVars,
59
+ button: props.button,
60
+ tag: props.tag
61
+ } as ConfigProviderInput)
62
+ })
63
+
53
64
  linkChildren({
54
- theme: themeValue,
55
- themeStyle
65
+ themeStyle,
66
+ globalConfig
56
67
  })
57
68
  </script>
58
69
 
@@ -136,6 +136,7 @@ export default {
136
136
  <script lang="ts" setup>
137
137
  import wdPopup from '../wd-popup/wd-popup.vue'
138
138
  import wdButton from '../wd-button/wd-button.vue'
139
+ import wdIcon from '../wd-icon/wd-icon.vue'
139
140
  import wdInput from '../wd-input/wd-input.vue'
140
141
  import wdTextarea from '../wd-textarea/wd-textarea.vue'
141
142
  import { computed, inject, reactive, ref, watch } from 'vue'
@@ -53,6 +53,7 @@ import { getRect, getSystemInfo, uuid } from '../../common/util'
53
53
  import { useChildren } from '../../composables/useChildren'
54
54
  import { DROP_MENU_KEY, dropMenuProps } from './types'
55
55
  import wdOverlay from '../wd-overlay/wd-overlay.vue'
56
+ import wdIcon from '../wd-icon/wd-icon.vue'
56
57
 
57
58
  const props = defineProps(dropMenuProps)
58
59
  const queue = inject<Queue | null>(queueKey, null)
@@ -32,8 +32,6 @@ const rootStyle = computed(() => {
32
32
  const style: CSSProperties = {}
33
33
  if (isDef(props.gutter)) {
34
34
  style.paddingLeft = addUnit(props.gutter)
35
- console.log(props.square)
36
-
37
35
  if (props.square) {
38
36
  style.marginBottom = addUnit(-props.gutter)
39
37
  }
@@ -61,8 +61,8 @@ const rootStyle = computed(() => {
61
61
  if (props.size) {
62
62
  const sizeValue = addUnit(props.size)
63
63
  style['font-size'] = sizeValue
64
- // CSS 图标模式下,同步设置 width/height
65
- if (props.cssIcon) {
64
+ // CSS 图标和图片模式下,同步设置 width/height
65
+ if (props.cssIcon || isImage.value) {
66
66
  style['width'] = sizeValue
67
67
  style['height'] = sizeValue
68
68
  }
@@ -36,6 +36,7 @@ export default {
36
36
  </script>
37
37
 
38
38
  <script lang="ts" setup>
39
+ import wdIcon from '../wd-icon/wd-icon.vue'
39
40
  import { computed, ref } from 'vue'
40
41
  import { addUnit, isDef, objToStyle } from '../../common/util'
41
42
  import { imgProps } from './types'
@@ -1,11 +1,11 @@
1
1
  @use '../../styles/mixin/mixin.scss' as *;
2
2
  @use '../../styles/variable.scss' as *;
3
3
 
4
- $index-anchor-bg: var(--wot-index-anchor-bg, $filled-bottom) !default;
5
- $index-anchor-padding: var(--wot-index-anchor-padding, $padding-main) !default;
6
- $index-anchor-font-size: var(--wot-index-anchor-font-size, $typography-body-size-main) !default;
7
- $index-anchor-color: var(--wot-index-anchor-color, $text-main) !default;
8
- $index-anchor-z-index: var(--wot-index-anchor-z-index, 1) !default;
4
+ $index-anchor-bg: var(--wot-index-anchor-bg, $filled-bottom) !default; // 索引锚点背景色
5
+ $index-anchor-padding: var(--wot-index-anchor-padding, $padding-main) !default; // 索引锚点内边距
6
+ $index-anchor-font-size: var(--wot-index-anchor-font-size, $typography-body-size-main) !default; // 索引锚点文字字号
7
+ $index-anchor-color: var(--wot-index-anchor-color, $text-main) !default; // 索引锚点文字颜色
8
+ $index-anchor-z-index: var(--wot-index-anchor-z-index, 1) !default; // 索引锚点吸顶层级
9
9
 
10
10
  // #ifdef MP-DINGTALK
11
11
  @include b(index-anchor-ding) {
@@ -1,20 +1,20 @@
1
1
  @use '../../styles/mixin/mixin.scss' as *;
2
2
  @use '../../styles/variable.scss' as *;
3
3
 
4
- $index-bar-sidebar-right: var(--wot-index-bar-sidebar-right, $spacing-super-tight) !default;
5
- $index-bar-index-font-size: var(--wot-index-bar-index-font-size, $typography-label-size-main) !default;
6
- $index-bar-index-width: var(--wot-index-bar-index-width, $typography-label-line-height-size-main) !default;
7
- $index-bar-index-height: var(--wot-index-bar-index-height, $typography-label-line-height-size-main) !default;
8
- $index-bar-index-font-weight: var(--wot-index-bar-index-font-weight, $font-weight-medium) !default;
9
- $index-bar-index-color: var(--wot-index-bar-index-color, $text-auxiliary) !default;
10
- $index-bar-index-border-radius: var(--wot-index-bar-index-border-radius, $radius-full) !default;
11
- $index-bar-index-color-active: var(--wot-index-bar-index-color-active, $text-white) !default;
12
- $index-bar-index-bg-active: var(--wot-index-bar-index-bg-active, $primary-6) !default;
13
- $index-bar-current-index-size: var(--wot-index-bar-current-index-size, $n-56) !default;
14
- $index-bar-current-index-bg: var(--wot-index-bar-current-index-bg, $primary-6) !default;
15
- $index-bar-current-index-color: var(--wot-index-bar-current-index-color, $text-white) !default;
16
- $index-bar-current-index-font-size: var(--wot-index-bar-current-index-font-size, $typography-title-size-extra-large) !default;
17
- $index-bar-current-index-z-index: var(--wot-index-bar-current-index-z-index, 10) !default;
4
+ $index-bar-sidebar-right: var(--wot-index-bar-sidebar-right, $spacing-super-tight) !default; // 索引侧边栏右侧偏移
5
+ $index-bar-index-font-size: var(--wot-index-bar-index-font-size, $typography-label-size-main) !default; // 索引项文字字号
6
+ $index-bar-index-width: var(--wot-index-bar-index-width, $typography-label-line-height-size-main) !default; // 索引项宽度
7
+ $index-bar-index-height: var(--wot-index-bar-index-height, $typography-label-line-height-size-main) !default; // 索引项高度
8
+ $index-bar-index-font-weight: var(--wot-index-bar-index-font-weight, $font-weight-medium) !default; // 索引项字重
9
+ $index-bar-index-color: var(--wot-index-bar-index-color, $text-auxiliary) !default; // 索引项文字颜色
10
+ $index-bar-index-border-radius: var(--wot-index-bar-index-border-radius, $radius-full) !default; // 索引项圆角
11
+ $index-bar-index-color-active: var(--wot-index-bar-index-color-active, $text-white) !default; // 激活索引项文字颜色
12
+ $index-bar-index-bg-active: var(--wot-index-bar-index-bg-active, $primary-6) !default; // 激活索引项背景色
13
+ $index-bar-current-index-size: var(--wot-index-bar-current-index-size, $n-56) !default; // 当前索引提示尺寸
14
+ $index-bar-current-index-bg: var(--wot-index-bar-current-index-bg, $primary-6) !default; // 当前索引提示背景色
15
+ $index-bar-current-index-color: var(--wot-index-bar-current-index-color, $text-white) !default; // 当前索引提示文字颜色
16
+ $index-bar-current-index-font-size: var(--wot-index-bar-current-index-font-size, $typography-title-size-extra-large) !default; // 当前索引提示文字字号
17
+ $index-bar-current-index-z-index: var(--wot-index-bar-current-index-z-index, 10) !default; // 当前索引提示层级
18
18
 
19
19
  @include b(index-bar) {
20
20
  position: relative;
@@ -32,6 +32,8 @@ export default {
32
32
  </script>
33
33
 
34
34
  <script lang="ts" setup>
35
+ import wdLoading from '../../wd-loading/wd-loading.vue'
36
+ import wdIcon from '../../wd-icon/wd-icon.vue'
35
37
  import { computed, ref } from 'vue'
36
38
  import { useTouch } from '../../../composables/useTouch'
37
39
  import { keyProps } from './types'
@@ -49,6 +49,7 @@ export default {
49
49
 
50
50
  <script lang="ts" setup>
51
51
  import wdPopup from '../wd-popup/wd-popup.vue'
52
+ import wdIcon from '../wd-icon/wd-icon.vue'
52
53
  import { inject, computed, watch, ref, type CSSProperties } from 'vue'
53
54
  import { notifyProps, type NotifyProps } from './types'
54
55
  import { getNotifyOptionKey } from '.'
@@ -108,7 +108,9 @@ export function useSelection(valueKey: string, labelKey: string, childrenKey: st
108
108
  * @returns {string[]} label数组
109
109
  */
110
110
  const selectedLabels = computed(() => {
111
- return selectedIndex.value.map((row, col) => String(formatColumns.value[col][row][labelKey] ?? ''))
111
+ return selectedIndex.value.map((row, col) =>
112
+ String(isDef(formatColumns.value[col][row][labelKey]) ? formatColumns.value[col][row][labelKey] : '')
113
+ )
112
114
  })
113
115
 
114
116
  /**
@@ -53,7 +53,7 @@ const configProviderStyle = computed(() => {
53
53
  })
54
54
 
55
55
  const themeClass = computed(() => {
56
- const theme = hooksProvider !== None ? hooksProvider.theme?.value : configProvider.value?.theme?.value
56
+ const theme = hooksProvider !== None ? hooksProvider.globalConfig?.value.theme : configProvider.value?.globalConfig?.value.theme
57
57
  return theme ? `wot-theme-${theme}` : 'wot-theme-light'
58
58
  })
59
59
  </script>
@@ -109,6 +109,7 @@ import wdRadio from '../wd-radio/wd-radio.vue'
109
109
  import wdRadioGroup from '../wd-radio-group/wd-radio-group.vue'
110
110
  import wdButton from '../wd-button/wd-button.vue'
111
111
  import wdLoading from '../wd-loading/wd-loading.vue'
112
+ import wdSearch from '../wd-search/wd-search.vue'
112
113
 
113
114
  import { getCurrentInstance, onBeforeMount, ref, watch, nextTick, computed } from 'vue'
114
115
  import { getRect, isArray, isDef, isFunction, pause } from '../../common/util'
@@ -72,6 +72,7 @@ export default {
72
72
  }
73
73
  </script>
74
74
  <script lang="ts" setup>
75
+ import wdButton from '../wd-button/wd-button.vue'
75
76
  import { computed, getCurrentInstance, onBeforeMount, onMounted, reactive, ref, watch, type CSSProperties } from 'vue'
76
77
  import { addUnit, getRect, getSystemInfo, isDef, objToStyle, uuid } from '../../common/util'
77
78
  import { signatureProps, type SignatureExpose, type SignatureResult, type Point, type Line } from './types'
@@ -4,64 +4,64 @@
4
4
  /* ================================ 组件SCSS变量 ================================ */
5
5
 
6
6
  /* 轨道 (Track) */
7
- $slider-bar-height: var(--wot-slider-bar-height, $n-2) !default;
8
- $slider-bar-height-capsule: var(--wot-slider-bar-height-capsule, $n-24) !default;
9
- $slider-bar-bg: var(--wot-slider-bar-bg, $filled-strong) !default;
10
- $slider-bar-radius: var(--wot-slider-bar-radius, $radius-full) !default;
11
- $slider-bar-height-vertical: var(--wot-slider-bar-height-vertical, $n-248) !default;
7
+ $slider-bar-height: var(--wot-slider-bar-height, $n-2) !default; // 轨道高度
8
+ $slider-bar-height-capsule: var(--wot-slider-bar-height-capsule, $n-24) !default; // 胶囊轨道高度
9
+ $slider-bar-bg: var(--wot-slider-bar-bg, $filled-strong) !default; // 轨道背景色
10
+ $slider-bar-radius: var(--wot-slider-bar-radius, $radius-full) !default; // 轨道圆角
11
+ $slider-bar-height-vertical: var(--wot-slider-bar-height-vertical, $n-248) !default; // 垂直轨道高度
12
12
 
13
13
  /* 进度条 (Range) */
14
- $slider-line-bg: var(--wot-slider-line-bg, $primary-6) !default;
15
- $slider-line-height: var(--wot-slider-line-height, $n-2) !default;
16
- $slider-line-height-capsule: var(--wot-slider-line-height-capsule, $n-18) !default;
14
+ $slider-line-bg: var(--wot-slider-line-bg, $primary-6) !default; // 进度条背景色
15
+ $slider-line-height: var(--wot-slider-line-height, $n-2) !default; // 进度条高度
16
+ $slider-line-height-capsule: var(--wot-slider-line-height-capsule, $n-18) !default; // 胶囊进度条高度
17
17
 
18
18
  /* 滑块 (Thumb) */
19
- $slider-dot-size: var(--wot-slider-dot-size, $n-24) !default;
20
- $slider-dot-bg: var(--wot-slider-dot-bg, $filled-oppo) !default;
21
- $slider-dot-shadow: var(--wot-slider-dot-shadow, 0 2px 8px 0 rgba(0, 0, 0, 0.1)) !default;
19
+ $slider-dot-size: var(--wot-slider-dot-size, $n-24) !default; // 滑块尺寸
20
+ $slider-dot-bg: var(--wot-slider-dot-bg, $filled-oppo) !default; // 滑块背景色
21
+ $slider-dot-shadow: var(--wot-slider-dot-shadow, 0 2px 8px 0 rgba(0, 0, 0, 0.1)) !default; // 滑块阴影
22
22
 
23
23
  /* 气泡提示 (Popover) */
24
- $slider-dot-popover-bg: var(--wot-slider-dot-popover-bg, $opacfilled-tooltip-toast-cover) !default;
25
- $slider-dot-popover-color: var(--wot-slider-dot-popover-color, $text-white) !default;
26
- $slider-dot-popover-radius: var(--wot-slider-dot-popover-radius, $radius-main) !default;
27
- $slider-dot-popover-padding: var(--wot-slider-dot-popover-padding, $padding-extra-tight $padding-loose) !default;
28
- $slider-dot-popover-font-size: var(--wot-slider-dot-popover-font-size, $typography-body-size-main) !default;
29
- $slider-dot-popover-line-height: var(--wot-slider-dot-popover-line-height, $typography-body-line-height-size-main) !default;
30
- $slider-dot-popover-gap: var(--wot-slider-dot-popover-gap, $n-3) !default;
31
- $slider-dot-popover-arrow-width: var(--wot-slider-dot-popover-arrow-width, $n-12) !default;
32
- $slider-dot-popover-arrow-height: var(--wot-slider-dot-popover-arrow-height, $n-6) !default;
33
- $slider-dot-popover-duration-exit: var(--wot-slider-dot-popover-duration-exit, 100ms) !default;
34
- $slider-dot-popover-easing-exit: var(--wot-slider-dot-popover-easing-exit, cubic-bezier(0.4, 0, 1, 1)) !default;
35
- $slider-dot-popover-duration-enter: var(--wot-slider-dot-popover-duration-enter, 200ms) !default;
36
- $slider-dot-popover-easing-enter: var(--wot-slider-dot-popover-easing-enter, cubic-bezier(0.34, 1.56, 0.64, 1)) !default;
24
+ $slider-dot-popover-bg: var(--wot-slider-dot-popover-bg, $opacfilled-tooltip-toast-cover) !default; // 气泡提示背景色
25
+ $slider-dot-popover-color: var(--wot-slider-dot-popover-color, $text-white) !default; // 气泡提示文字颜色
26
+ $slider-dot-popover-radius: var(--wot-slider-dot-popover-radius, $radius-main) !default; // 气泡提示圆角
27
+ $slider-dot-popover-padding: var(--wot-slider-dot-popover-padding, $padding-extra-tight $padding-loose) !default; // 气泡提示内边距
28
+ $slider-dot-popover-font-size: var(--wot-slider-dot-popover-font-size, $typography-body-size-main) !default; // 气泡提示文字字号
29
+ $slider-dot-popover-line-height: var(--wot-slider-dot-popover-line-height, $typography-body-line-height-size-main) !default; // 气泡提示行高
30
+ $slider-dot-popover-gap: var(--wot-slider-dot-popover-gap, $n-3) !default; // 气泡提示与滑块间距
31
+ $slider-dot-popover-arrow-width: var(--wot-slider-dot-popover-arrow-width, $n-12) !default; // 气泡提示箭头宽度
32
+ $slider-dot-popover-arrow-height: var(--wot-slider-dot-popover-arrow-height, $n-6) !default; // 气泡提示箭头高度
33
+ $slider-dot-popover-duration-exit: var(--wot-slider-dot-popover-duration-exit, 100ms) !default; // 气泡提示离场动画时长
34
+ $slider-dot-popover-easing-exit: var(--wot-slider-dot-popover-easing-exit, cubic-bezier(0.4, 0, 1, 1)) !default; // 气泡提示离场动画缓动
35
+ $slider-dot-popover-duration-enter: var(--wot-slider-dot-popover-duration-enter, 200ms) !default; // 气泡提示入场动画时长
36
+ $slider-dot-popover-easing-enter: var(--wot-slider-dot-popover-easing-enter, cubic-bezier(0.34, 1.56, 0.64, 1)) !default; // 气泡提示入场动画缓动
37
37
 
38
38
  /* 刻度 (Scale) */
39
- $slider-scale-size: var(--wot-slider-scale-size, $n-6) !default;
40
- $slider-scale-border-radius: var(--wot-slider-scale-border-radius, $radius-full) !default;
41
- $slider-scale-bg: var(--wot-slider-scale-bg, $filled-strong) !default;
42
- $slider-scale-bg-active: var(--wot-slider-scale-bg-active, $primary-6) !default;
43
- $slider-scale-capsule-bg: var(--wot-slider-scale-capsule-bg, $filled-strong) !default;
44
- $slider-scale-capsule-width: var(--wot-slider-scale-capsule-width, $n-2) !default;
45
- $slider-scale-capsule-border-radius: var(--wot-slider-scale-capsule-border-radius, $radius-zero) !default;
46
- $slider-scale-desc-font-size: var(--wot-slider-scale-desc-font-size, $typography-body-size-main) !default;
47
- $slider-scale-desc-line-height: var(--wot-slider-scale-desc-line-height, $typography-body-line-height-size-main) !default;
48
- $slider-scale-desc-color: var(--wot-slider-scale-desc-color, $text-main) !default;
49
- $slider-scale-desc-spacing: var(--wot-slider-scale-desc-spacing, $spacing-tight) !default;
50
- $slider-marks-desc-spacing: var(--wot-slider-marks-desc-spacing, calc($slider-dot-size / 2 + $spacing-tight)) !default;
51
- $slider-marks-desc-capsule-spacing: var(--wot-slider-marks-desc-capsule-spacing, calc($slider-dot-size + $spacing-super-tight)) !default;
52
- $slider-marks-extra-padding: var(--wot-slider-marks-extra-padding, $padding-super-loose) !default;
53
- $slider-marks-extra-capsule-padding: var(--wot-slider-marks-extra-capsule-padding, $padding-ultra-loose) !default;
39
+ $slider-scale-size: var(--wot-slider-scale-size, $n-6) !default; // 刻度尺寸
40
+ $slider-scale-border-radius: var(--wot-slider-scale-border-radius, $radius-full) !default; // 刻度圆角
41
+ $slider-scale-bg: var(--wot-slider-scale-bg, $filled-strong) !default; // 刻度背景色
42
+ $slider-scale-bg-active: var(--wot-slider-scale-bg-active, $primary-6) !default; // 激活刻度背景色
43
+ $slider-scale-capsule-bg: var(--wot-slider-scale-capsule-bg, $filled-strong) !default; // 胶囊刻度背景色
44
+ $slider-scale-capsule-width: var(--wot-slider-scale-capsule-width, $n-2) !default; // 胶囊刻度宽度
45
+ $slider-scale-capsule-border-radius: var(--wot-slider-scale-capsule-border-radius, $radius-zero) !default; // 胶囊刻度圆角
46
+ $slider-scale-desc-font-size: var(--wot-slider-scale-desc-font-size, $typography-body-size-main) !default; // 刻度描述文字字号
47
+ $slider-scale-desc-line-height: var(--wot-slider-scale-desc-line-height, $typography-body-line-height-size-main) !default; // 刻度描述行高
48
+ $slider-scale-desc-color: var(--wot-slider-scale-desc-color, $text-main) !default; // 刻度描述文字颜色
49
+ $slider-scale-desc-spacing: var(--wot-slider-scale-desc-spacing, $spacing-tight) !default; // 刻度描述间距
50
+ $slider-marks-desc-spacing: var(--wot-slider-marks-desc-spacing, calc($slider-dot-size / 2 + $spacing-tight)) !default; // 标记描述间距
51
+ $slider-marks-desc-capsule-spacing: var(--wot-slider-marks-desc-capsule-spacing, calc($slider-dot-size + $spacing-super-tight)) !default; // 胶囊标记描述间距
52
+ $slider-marks-extra-padding: var(--wot-slider-marks-extra-padding, $padding-super-loose) !default; // 标记额外内边距
53
+ $slider-marks-extra-capsule-padding: var(--wot-slider-marks-extra-capsule-padding, $padding-ultra-loose) !default; // 胶囊标记额外内边距
54
54
 
55
55
  /* 布局 (Layout) */
56
- $slider-capsule-track-inset: var(--wot-slider-capsule-track-inset, $n-3) !default;
57
- $slider-extreme-spacing: var(--wot-slider-extreme-spacing, $spacing-loose) !default;
56
+ $slider-capsule-track-inset: var(--wot-slider-capsule-track-inset, $n-3) !default; // 胶囊轨道内缩距离
57
+ $slider-extreme-spacing: var(--wot-slider-extreme-spacing, $spacing-loose) !default; // 极值文字与轨道间距
58
58
 
59
59
  /* 极值文字 (Extreme Value) */
60
- $slider-value-font-size: var(--wot-slider-value-font-size, $typography-body-size-main) !default;
61
- $slider-value-color: var(--wot-slider-value-color, $text-secondary) !default;
60
+ $slider-value-font-size: var(--wot-slider-value-font-size, $typography-body-size-main) !default; // 极值文字字号
61
+ $slider-value-color: var(--wot-slider-value-color, $text-secondary) !default; // 极值文字颜色
62
62
 
63
63
  /* 状态 (States) */
64
- $slider-opacity-disabled: var(--wot-slider-opacity-disabled, $opacity-disabled) !default;
64
+ $slider-opacity-disabled: var(--wot-slider-opacity-disabled, $opacity-disabled) !default; // 禁用态透明度
65
65
 
66
66
  @include b(slider) {
67
67
  display: flex;
@@ -482,4 +482,4 @@ $slider-opacity-disabled: var(--wot-slider-opacity-disabled, $opacity-disabled)
482
482
  opacity: $slider-opacity-disabled;
483
483
  pointer-events: none;
484
484
  }
485
- }
485
+ }
@@ -304,8 +304,24 @@ function initSlider() {
304
304
  */
305
305
  function getPointerPosition(event: any): number {
306
306
  return props.vertical
307
- ? Number(event.detail?.y ?? event.clientY ?? event.touches?.[0]?.clientY ?? 0)
308
- : Number(event.detail?.x ?? event.clientX ?? event.touches?.[0]?.clientX ?? 0)
307
+ ? Number(
308
+ isDef(event.detail?.y)
309
+ ? event.detail?.y
310
+ : isDef(event.clientY)
311
+ ? event.clientY
312
+ : isDef(event.touches?.[0]?.clientY)
313
+ ? event.touches?.[0]?.clientY
314
+ : 0
315
+ )
316
+ : Number(
317
+ isDef(event.detail?.x)
318
+ ? event.detail?.x
319
+ : isDef(event.clientX)
320
+ ? event.clientX
321
+ : isDef(event.touches?.[0]?.clientX)
322
+ ? event.touches?.[0]?.clientX
323
+ : 0
324
+ )
309
325
  }
310
326
 
311
327
  /**
@@ -413,7 +429,7 @@ function dotDisplayValue(index: number): number {
413
429
  return modelValue.value as number
414
430
  }
415
431
  const values = currentValue.value
416
- return values[index] ?? values[0]
432
+ return isDef(values[index]) ? values[index] : values[0]
417
433
  }
418
434
 
419
435
  /**
@@ -36,6 +36,8 @@ export default {
36
36
  </script>
37
37
 
38
38
  <script lang="ts" setup>
39
+ import wdIcon from '../wd-icon/wd-icon.vue'
40
+ import wdLoading from '../wd-loading/wd-loading.vue'
39
41
  import { computed, type CSSProperties, onBeforeMount } from 'vue'
40
42
  import { callInterceptor } from '../../common/interceptor'
41
43
  import { addUnit, isDef, isUndefined, objToStyle, omitBy } from '../../common/util'
@@ -140,6 +140,7 @@ export default {
140
140
  </script>
141
141
  <script lang="ts" setup>
142
142
  import wdIcon from '../wd-icon/wd-icon.vue'
143
+ import wdBadge from '../wd-badge/wd-badge.vue'
143
144
  import wdSticky from '../wd-sticky/wd-sticky.vue'
144
145
  import wdStickyBox from '../wd-sticky-box/wd-sticky-box.vue'
145
146
  import { computed, getCurrentInstance, onMounted, watch, nextTick, reactive, type CSSProperties, type ComponentInstance } from 'vue'
@@ -127,6 +127,7 @@ $tag-extra-large-round-padding: var(--wot-tag-extra-large-round-padding, $n-3 $p
127
127
  // 超大尺寸图标尺寸
128
128
  $tag-extra-large-icon-size: var(--wot-tag-extra-large-icon-size, $n-12) !default;
129
129
 
130
+ // 这里的顺序决定了生成的 CSS 优先级,default 必须放在首位以确保其他尺寸可以覆盖它
130
131
  $tag-types: (
131
132
  "default": (
132
133
  "color": $tag-info-color,
@@ -181,6 +182,13 @@ $tag-types: (
181
182
  );
182
183
 
183
184
  $tag-sizes: (
185
+ "default": (
186
+ "font-size": $tag-default-font-size,
187
+ "line-height": $tag-default-line-height,
188
+ "padding": $tag-default-padding,
189
+ "round-padding": $tag-default-round-padding,
190
+ "icon-size": $tag-default-icon-size
191
+ ),
184
192
  "small": (
185
193
  "font-size": $tag-small-font-size,
186
194
  "line-height": $tag-small-line-height,
@@ -195,13 +203,6 @@ $tag-sizes: (
195
203
  "round-padding": $tag-medium-round-padding,
196
204
  "icon-size": $tag-medium-icon-size
197
205
  ),
198
- "default": (
199
- "font-size": $tag-default-font-size,
200
- "line-height": $tag-default-line-height,
201
- "padding": $tag-default-padding,
202
- "round-padding": $tag-default-round-padding,
203
- "icon-size": $tag-default-icon-size
204
- ),
205
206
  "large": (
206
207
  "font-size": $tag-large-font-size,
207
208
  "line-height": $tag-large-line-height,
@@ -1,4 +1,4 @@
1
- import type { ExtractPropTypes } from 'vue'
1
+ import type { ExtractPropTypes, PropType } from 'vue'
2
2
  import { baseProps, makeBooleanProp, makeStringProp } from '../../common/props'
3
3
 
4
4
  /**
@@ -26,9 +26,9 @@ export const tagProps = {
26
26
  * 标签尺寸
27
27
  * 类型: TagSize
28
28
  * 可选值: 'small' | 'medium' | 'large' | 'extra-large' | 'default'
29
- * 默认值: 'default'
29
+ * 不传则继承全局配置
30
30
  */
31
- size: makeStringProp<TagSize>('default'),
31
+ size: String as PropType<TagSize>,
32
32
  /**
33
33
  * 标签类型
34
34
  * 类型: TagType
@@ -69,9 +69,12 @@ export const tagProps = {
69
69
  /**
70
70
  * 圆角类型
71
71
  * 类型: boolean
72
- * 默认值: false
72
+ * 不传则继承全局配置
73
73
  */
74
- round: makeBooleanProp(false),
74
+ round: {
75
+ type: Boolean,
76
+ default: void 0
77
+ },
75
78
  /**
76
79
  * 标记类型
77
80
  * 类型: boolean
@@ -82,9 +85,9 @@ export const tagProps = {
82
85
  * 标签变体
83
86
  * 类型: TagVariant
84
87
  * 可选值: 'light' | 'dark' | 'plain' | 'dashed' | 'text'
85
- * 默认值: 'dark'
88
+ * 不传则继承全局配置
86
89
  */
87
- variant: makeStringProp<TagVariant>('dark')
90
+ variant: String as PropType<TagVariant>
88
91
  }
89
92
 
90
93
  export type TagProps = ExtractPropTypes<typeof tagProps>
@@ -46,15 +46,32 @@ export default {
46
46
  </script>
47
47
  <script lang="ts" setup>
48
48
  import wdIcon from '../wd-icon/wd-icon.vue'
49
- import { objToStyle } from '../../common/util'
49
+ import { objToStyle, isUndefined } from '../../common/util'
50
50
  import { computed, ref } from 'vue'
51
51
  import { useTranslate } from '../../composables/useTranslate'
52
52
  import { tagProps } from './types'
53
+ import { useGlobalConfig } from '../../composables/useGlobalConfig'
53
54
 
54
55
  const props = defineProps(tagProps)
55
56
  const emit = defineEmits(['click', 'close', 'confirm'])
56
57
 
57
58
  const { translate } = useTranslate('tag')
59
+ const globalConfig = useGlobalConfig()
60
+
61
+ const effectiveSize = computed(() => {
62
+ return props.size || globalConfig.value.tag?.size || 'default'
63
+ })
64
+
65
+ const effectiveVariant = computed(() => {
66
+ return props.variant || globalConfig.value.tag?.variant || 'dark'
67
+ })
68
+
69
+ const effectiveRound = computed(() => {
70
+ if (isUndefined(props.round)) {
71
+ return isUndefined(globalConfig.value.tag?.round) ? false : globalConfig.value.tag?.round
72
+ }
73
+ return props.round
74
+ })
58
75
 
59
76
  const dynamicValue = ref<string>('')
60
77
  const dynamicInput = ref<boolean>(false)
@@ -63,12 +80,12 @@ const dynamicInput = ref<boolean>(false)
63
80
  * 根节点类名
64
81
  */
65
82
  const rootClass = computed<string>(() => {
66
- const { type, variant, size, round, mark, customClass } = props
83
+ const { type, mark, customClass } = props
67
84
  const classList: string[] = []
68
85
  type && classList.push(`is-${type}`)
69
- variant && classList.push(`is-${variant}`)
70
- size && classList.push(`is-${size}`)
71
- round && classList.push('is-round')
86
+ effectiveVariant.value && classList.push(`is-${effectiveVariant.value}`)
87
+ effectiveSize.value && classList.push(`is-${effectiveSize.value}`)
88
+ effectiveRound.value && classList.push('is-round')
72
89
  mark && classList.push('is-mark')
73
90
  return `wd-tag ${customClass} ${classList.join(' ')}`
74
91
  })
@@ -78,7 +95,7 @@ const rootClass = computed<string>(() => {
78
95
  */
79
96
  const rootStyle = computed<string>(() => {
80
97
  const rootStyle: Record<string, any> = {}
81
- if (props.variant !== 'plain' && props.variant !== 'dashed' && props.variant !== 'text' && props.bgColor) {
98
+ if (effectiveVariant.value !== 'plain' && effectiveVariant.value !== 'dashed' && effectiveVariant.value !== 'text' && props.bgColor) {
82
99
  rootStyle['background'] = props.bgColor
83
100
  }
84
101
  if (props.bgColor) {
@@ -16,6 +16,7 @@
16
16
  :custom-class="`wd-toast__icon ${direction === 'vertical' ? 'is-vertical' : ''}`"
17
17
  :size="iconSize"
18
18
  :class-prefix="classPrefix"
19
+ :color="iconColor"
19
20
  :name="toastIcon[iconName]"
20
21
  ></wd-icon>
21
22
  <wd-icon
@@ -23,6 +24,7 @@
23
24
  :custom-class="`wd-toast__icon ${direction === 'vertical' ? 'is-vertical' : ''}`"
24
25
  :size="iconSize"
25
26
  :class-prefix="classPrefix"
27
+ :color="iconColor"
26
28
  :name="iconClass"
27
29
  :css-icon="cssIcon"
28
30
  ></wd-icon>
@@ -65,6 +67,7 @@ const zIndex = ref<number>(100)
65
67
  const loadingType = ref<ToastLoadingType>('circular')
66
68
  const loadingColor = ref<string>('#fff')
67
69
  const iconSize = ref<string>() // 图标大小
70
+ const iconColor = ref<string>() // 图标颜色
68
71
  const loadingSize = ref<string>() // loading大小
69
72
  const cover = ref<boolean>(false) // 是否存在遮罩层
70
73
  const classPrefix = ref<string>('wd-icon') // 图标前缀
@@ -148,6 +151,7 @@ function mergeOptionsWithProps(option: ToastOptions, props: ToastProps) {
148
151
  loadingType.value = isDef(option.loadingType!) ? option.loadingType! : props.loadingType
149
152
  loadingColor.value = isDef(option.loadingColor!) ? option.loadingColor! : props.loadingColor
150
153
  iconSize.value = isDef(option.iconSize) ? addUnit(option.iconSize) : isDef(props.iconSize) ? addUnit(props.iconSize) : undefined
154
+ iconColor.value = isDef(option.iconColor!) ? option.iconColor! : props.iconColor
151
155
  loadingSize.value = isDef(option.loadingSize) ? addUnit(option.loadingSize) : isDef(props.loadingSize) ? addUnit(props.loadingSize) : undefined
152
156
  cover.value = isDef(option.cover!) ? option.cover! : props.cover
153
157
  classPrefix.value = isDef(option.classPrefix) ? option.classPrefix : props.classPrefix
@@ -10,7 +10,9 @@ export { useTouch } from './useTouch'
10
10
  export { useTranslate } from './useTranslate'
11
11
  export { useUpload } from './useUpload'
12
12
  export { useConfigProvider } from './useConfigProvider'
13
+ export { useGlobalConfig } from './useGlobalConfig'
13
14
  export { useToast } from '../components/wd-toast'
14
15
  export { useDialog } from '../components/wd-dialog'
15
16
  export { useImagePreview } from '../components/wd-image-preview'
17
+ export { useVideoPreview } from '../components/wd-video-preview'
16
18
  export { useNotify, setNotifyDefaultOptions, resetNotifyDefaultOptions } from '../components/wd-notify'
@@ -1,6 +1,13 @@
1
- import { computed, provide, unref, type Ref } from 'vue'
2
- import { type ConfigProviderThemeVars } from '../components/wd-config-provider/types'
1
+ import { computed, provide, unref, type MaybeRef } from 'vue'
2
+ import { type ConfigProviderThemeVars } from '../components/wd-config-provider/theme-vars'
3
3
  import { objToStyle } from '../common/util'
4
+ import {
5
+ mergeConfig,
6
+ type GlobalConfig,
7
+ type ConfigProviderInput,
8
+ type ButtonConfig,
9
+ type TagConfig
10
+ } from '../components/wd-config-provider/global-config'
4
11
 
5
12
  export const USE_CONFIG_PROVIDER_KEY = '__CONFIG_PROVIDER__'
6
13
 
@@ -22,24 +29,32 @@ export const mapThemeVarsToCSSVars = (themeVars: Record<string, string>) => {
22
29
  return cssVars
23
30
  }
24
31
 
25
- export function useConfigProvider({
26
- themeVars,
27
- theme
28
- }: {
29
- themeVars?: ConfigProviderThemeVars | Ref<ConfigProviderThemeVars>
30
- theme?: string | Ref<string>
31
- }) {
32
+ export interface UseConfigProviderOptions {
33
+ themeVars?: MaybeRef<ConfigProviderThemeVars>
34
+ theme?: MaybeRef<string>
35
+ button?: MaybeRef<ButtonConfig>
36
+ tag?: MaybeRef<TagConfig>
37
+ }
38
+
39
+ export function useConfigProvider(options: UseConfigProviderOptions = {}) {
40
+ const { themeVars, theme, button, tag } = options
41
+
32
42
  const themeStyle = computed(() => {
33
43
  const styleObj = mapThemeVarsToCSSVars(unref(themeVars) || {})
34
44
  return styleObj ? `${objToStyle(styleObj)}` : ''
35
45
  })
36
46
 
37
- const themeValue = computed(() => {
38
- return unref(theme) || 'light'
47
+ const globalConfig = computed<GlobalConfig>(() => {
48
+ return mergeConfig(null, {
49
+ theme: unref(theme) || 'light',
50
+ themeVars: unref(themeVars) || {},
51
+ button: unref(button) || {},
52
+ tag: unref(tag) || {}
53
+ } as ConfigProviderInput)
39
54
  })
40
55
 
41
56
  provide(USE_CONFIG_PROVIDER_KEY, {
42
57
  themeStyle,
43
- theme: themeValue
58
+ globalConfig
44
59
  })
45
60
  }