@tplc/wot 1.0.12 → 1.0.14

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 (68) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/components/common/abstracts/variable.scss +682 -183
  3. package/components/wd-calendar/index.scss +145 -58
  4. package/components/wd-calendar/types.ts +41 -23
  5. package/components/wd-calendar/wd-calendar.vue +130 -123
  6. package/components/wd-calendar-view/month/index.scss +65 -33
  7. package/components/wd-calendar-view/month/month.vue +113 -80
  8. package/components/wd-calendar-view/month/types.ts +1 -2
  9. package/components/wd-calendar-view/monthPanel/index.scss +15 -15
  10. package/components/wd-calendar-view/monthPanel/month-panel.vue +78 -64
  11. package/components/wd-calendar-view/monthPanel/types.ts +10 -58
  12. package/components/wd-calendar-view/types.ts +36 -12
  13. package/components/wd-calendar-view/utils.ts +36 -14
  14. package/components/wd-calendar-view/wd-calendar-view.vue +7 -7
  15. package/components/wd-calendar-view/year/index.scss +13 -18
  16. package/components/wd-calendar-view/year/types.ts +1 -2
  17. package/components/wd-calendar-view/year/year.vue +43 -25
  18. package/components/wd-calendar-view/yearPanel/index.scss +4 -4
  19. package/components/wd-calendar-view/yearPanel/types.ts +2 -2
  20. package/components/wd-calendar-view/yearPanel/year-panel.vue +41 -36
  21. package/components/wd-checkbox/index.scss +9 -9
  22. package/components/wd-checkbox/wd-checkbox.vue +19 -10
  23. package/components/wd-datetime-picker/types.ts +22 -6
  24. package/components/wd-datetime-picker/wd-datetime-picker.vue +136 -55
  25. package/components/wd-drop-menu/index.scss +45 -17
  26. package/components/wd-drop-menu/types.ts +3 -3
  27. package/components/wd-drop-menu/wd-drop-menu.vue +25 -61
  28. package/components/wd-drop-menu-item/index.scss +15 -15
  29. package/components/wd-drop-menu-item/types.ts +15 -18
  30. package/components/wd-drop-menu-item/wd-drop-menu-item.vue +54 -33
  31. package/components/wd-picker/wd-picker.vue +29 -18
  32. package/components/wd-radio/index.scss +9 -9
  33. package/package.json +1 -1
  34. package/types/components/common/dayjs.d.ts +26 -0
  35. package/types/components/wd-calendar/types.d.ts +18 -24
  36. package/types/components/wd-calendar/wd-calendar.vue.d.ts +24 -40
  37. package/types/components/wd-calendar-view/month/month.vue.d.ts +3 -11
  38. package/types/components/wd-calendar-view/month/types.d.ts +0 -4
  39. package/types/components/wd-calendar-view/monthPanel/month-panel.vue.d.ts +12 -18
  40. package/types/components/wd-calendar-view/monthPanel/types.d.ts +6 -48
  41. package/types/components/wd-calendar-view/types.d.ts +4 -11
  42. package/types/components/wd-calendar-view/utils.d.ts +12 -3
  43. package/types/components/wd-calendar-view/year/types.d.ts +0 -4
  44. package/types/components/wd-calendar-view/year/year.vue.d.ts +3 -11
  45. package/types/components/wd-cell/wd-cell.vue.d.ts +5 -5
  46. package/types/components/wd-col-picker/wd-col-picker.vue.d.ts +9 -9
  47. package/types/components/wd-datetime-picker/wd-datetime-picker.vue.d.ts +10 -10
  48. package/types/components/wd-datetime-picker-view/wd-datetime-picker-view.vue.d.ts +1 -1
  49. package/types/components/wd-drop-menu/types.d.ts +3 -3
  50. package/types/components/wd-drop-menu/wd-drop-menu.vue.d.ts +5 -5
  51. package/types/components/wd-drop-menu-item/types.d.ts +15 -27
  52. package/types/components/wd-drop-menu-item/wd-drop-menu-item.vue.d.ts +35 -46
  53. package/types/components/wd-floating-panel/wd-floating-panel.vue.d.ts +1 -1
  54. package/types/components/wd-form/wd-form.vue.d.ts +1 -1
  55. package/types/components/wd-form-item/wd-form-item.vue.d.ts +1 -1
  56. package/types/components/wd-grid-item/wd-grid-item.vue.d.ts +1 -1
  57. package/types/components/wd-input/wd-input.vue.d.ts +4 -4
  58. package/types/components/wd-keyboard/wd-keyboard.vue.d.ts +1 -1
  59. package/types/components/wd-notify/wd-notify.vue.d.ts +1 -1
  60. package/types/components/wd-number-keyboard/wd-number-keyboard.vue.d.ts +1 -1
  61. package/types/components/wd-picker/wd-picker.vue.d.ts +12 -12
  62. package/types/components/wd-picker-view/wd-picker-view.vue.d.ts +2 -2
  63. package/types/components/wd-select-picker/wd-select-picker.vue.d.ts +12 -12
  64. package/types/components/wd-signature/wd-signature.vue.d.ts +2 -2
  65. package/types/components/wd-steps/wd-steps.vue.d.ts +1 -1
  66. package/types/components/wd-swiper/wd-swiper.vue.d.ts +1 -1
  67. package/types/components/wd-tabs/wd-tabs.vue.d.ts +1 -1
  68. package/types/components/wd-textarea/wd-textarea.vue.d.ts +3 -3
@@ -1,15 +1,10 @@
1
1
  <template>
2
- <view :style="customStyle" :class="`wd-drop-menu ${customClass}`" @click.stop.prevent="noop" :id="dropMenuId">
3
- <wd-overlay
4
- :show="overlayVisible"
5
- :duration="duration"
6
- :z-index="12"
7
- :custom-style="modalStyle"
8
- @click="handleClickOverlay"
9
- @touchmove="noop"
10
- v-if="modal"
11
- />
12
-
2
+ <view
3
+ :style="customStyle"
4
+ :class="`wd-drop-menu ${customClass}`"
5
+ @click.stop="noop"
6
+ :id="dropMenuId"
7
+ >
13
8
  <!-- #ifdef MP-DINGTALK -->
14
9
  <view :id="dropMenuId">
15
10
  <!-- #endif -->
@@ -18,10 +13,13 @@
18
13
  v-for="(child, index) in children"
19
14
  :key="index"
20
15
  @click="toggle(child)"
21
- :class="`wd-drop-menu__item ${child.disabled ? 'is-disabled' : ''} ${child.$.exposed!.getShowPop() ? 'is-active' : ''}`"
16
+ :class="`wd-drop-menu__item ${child.disabled ? 'is-disabled' : ''} ${child.$.exposed!.getShowPop() ? 'is-active' : ''} ${child.$.exposed!.getSelected() ? 'is-checked' : ''}`"
22
17
  >
23
18
  <view class="wd-drop-menu__item-title">
24
19
  <view class="wd-drop-menu__item-title-text">{{ getDisplayTitle(child) }}</view>
20
+ <view class="wd-drop-menu__item-title-dot" v-if="child.$.exposed!.getDot()">
21
+ {{ child.$.exposed!.getDot() }}
22
+ </view>
25
23
  <wd-icon :name="child.icon" :size="child.iconSize" custom-class="wd-drop-menu__arrow" />
26
24
  </view>
27
25
  </view>
@@ -38,58 +36,28 @@ export default {
38
36
  options: {
39
37
  virtualHost: true,
40
38
  addGlobalClass: true,
41
- styleIsolation: 'shared'
42
- }
39
+ styleIsolation: 'shared',
40
+ },
43
41
  }
44
42
  </script>
45
43
 
46
44
  <script lang="ts" setup>
47
- import { computed, getCurrentInstance, inject, onBeforeMount, ref, watch } from 'vue'
45
+ import { getCurrentInstance, inject, onBeforeMount, ref, watch } from 'vue'
48
46
  import { closeOther } from '../common/clickoutside'
49
47
  import { type Queue, queueKey } from '../composables/useQueue'
50
- import { getRect, getSystemInfo, uuid } from '../common/util'
48
+ import { getRect, uuid } from '../common/util'
51
49
  import { useChildren } from '../composables/useChildren'
52
50
  import { DROP_MENU_KEY, dropMenuProps } from './types'
53
- import wdOverlay from '../wd-overlay/wd-overlay.vue'
54
-
55
51
  const props = defineProps(dropMenuProps)
56
52
  const queue = inject<Queue | null>(queueKey, null)
57
53
  const dropMenuId = ref<string>(`dropMenuId${uuid()}`)
58
54
  const offset = ref<number>(0)
59
55
  const windowHeight = ref<number>(0)
60
- const modalStyle = computed(() => {
61
- return props.direction === 'down'
62
- ? `top: calc(var(--window-top) + ${offset.value}px); bottom: 0;`
63
- : `top: 0; bottom: calc(var(--window-bottom) + ${offset.value}px)`
64
- })
65
56
 
66
57
  const { proxy } = getCurrentInstance() as any
67
58
 
68
59
  const { linkChildren, children } = useChildren(DROP_MENU_KEY)
69
60
 
70
- const showOverlay = computed(() => {
71
- return children.some((child) => child.$.exposed!.getShowPop())
72
- })
73
-
74
- const overlayVisible = ref(false)
75
- let overlayTimer: ReturnType<typeof setTimeout> | null
76
-
77
- // 延迟关闭遮罩层,避免闪烁
78
- // 小程序中,即使先 fold 再 closeOther 也会有闪烁,使用延迟关闭遮罩层处理
79
- watch(showOverlay, (newVal) => {
80
- if (overlayTimer) {
81
- clearTimeout(overlayTimer)
82
- }
83
- if (newVal) {
84
- overlayVisible.value = true
85
- } else {
86
- overlayTimer = setTimeout(() => {
87
- overlayVisible.value = false
88
- overlayTimer = null
89
- }, 16)
90
- }
91
- })
92
-
93
61
  linkChildren({ props, fold, offset })
94
62
 
95
63
  watch(
@@ -97,17 +65,20 @@ watch(
97
65
  (newValue) => {
98
66
  if (!['up', 'down'].includes(newValue)) {
99
67
  // eslint-disable-next-line quotes
100
- console.error("[wot ui] warning(wd-drop-menu): direction must be 'up' or 'down'")
68
+ console.error("[wot design] warning(wd-drop-menu): direction must be 'up' or 'down'")
101
69
  }
102
70
  },
103
- { deep: true, immediate: true }
71
+ { deep: true, immediate: true },
104
72
  )
105
73
 
106
74
  onBeforeMount(() => {
107
- windowHeight.value = getSystemInfo().windowHeight
75
+ windowHeight.value = uni.getWindowInfo().windowHeight
108
76
  })
109
77
 
110
- function noop() {}
78
+ function noop(event: Event) {
79
+ event.preventDefault()
80
+ event.stopPropagation()
81
+ }
111
82
 
112
83
  function getDisplayTitle(child: any) {
113
84
  const { title, modelValue, options, valueKey, labelKey } = child
@@ -120,7 +91,9 @@ function getDisplayTitle(child: any) {
120
91
  return options[i][labelKey]
121
92
  }
122
93
  }
123
- console.error('[wot-design] warning(wd-drop-menu-item): no value is matched in the options option.')
94
+ console.error(
95
+ '[wot-design] warning(wd-drop-menu-item): no value is matched in the options option.',
96
+ )
124
97
  }
125
98
 
126
99
  function toggle(child: any) {
@@ -150,17 +123,8 @@ function fold(child: any) {
150
123
  child.$.exposed!.toggle()
151
124
  })
152
125
  }
153
-
154
- function handleClickOverlay() {
155
- if (props.closeOnClickModal) {
156
- // 关闭所有打开的菜单项
157
- children.forEach((child) => {
158
- child.$.exposed!.close()
159
- })
160
- }
161
- }
162
126
  </script>
163
127
 
164
128
  <style lang="scss" scoped>
165
- @import './index.scss';
129
+ @import './index';
166
130
  </style>
@@ -15,52 +15,52 @@
15
15
  position: fixed;
16
16
  right: 0;
17
17
  left: 0;
18
+ z-index: 101;
19
+ width: 100%;
18
20
  overflow: hidden;
19
21
  font-size: $-drop-menu-item-fs;
20
22
  color: $-drop-menu-item-color;
21
- width: 100%;
22
- z-index: 101;
23
-
24
- @include e(popup){
23
+
24
+ .wd-drop-item__popup {
25
25
  position: absolute;
26
- max-height: 80%;
26
+ max-height: 90%;
27
27
  }
28
28
 
29
29
  @include e(option) {
30
30
  display: flex;
31
+ align-items: center;
32
+ justify-content: space-between;
31
33
  height: $-drop-menu-item-height;
32
- line-height: $-drop-menu-item-height;
33
34
  padding: 0 $-drop-menu-side-padding;
34
- justify-content: space-between;
35
- align-items: center;
36
- transition: color .2s;
35
+ line-height: $-drop-menu-item-height;
36
+ transition: color 0.2s;
37
37
 
38
38
  @include when(active) {
39
39
  color: $-drop-menu-item-color-active;
40
40
  }
41
41
  }
42
42
 
43
- @include e(title){
43
+ @include e(title) {
44
44
  display: block;
45
45
  }
46
46
 
47
47
  @include e(tip) {
48
48
  display: inline-block;
49
- color: $-drop-menu-item-color-tip;
50
- font-size: $-drop-menu-item-fs-tip;
51
49
  margin-left: 2px;
50
+ font-size: $-drop-menu-item-fs-tip;
51
+ color: $-drop-menu-item-color-tip;
52
52
  }
53
53
 
54
- @include edeep(icon){
54
+ @include edeep(icon) {
55
55
  display: block;
56
56
  font-size: $-drop-menu-option-check-size;
57
57
  }
58
58
 
59
59
  @include e(modal) {
60
60
  position: fixed;
61
- left: 0;
62
61
  right: 0;
63
- background: rgba(0, 0, 0, 0.7);
62
+ left: 0;
64
63
  height: 100%;
64
+ background: rgba(0, 0, 0, 0.7);
65
65
  }
66
66
  }
@@ -1,5 +1,11 @@
1
1
  import type { ComponentPublicInstance, ExtractPropTypes, PropType } from 'vue'
2
- import { baseProps, makeArrayProp, makeBooleanProp, makeNumericProp, makeStringProp, numericProp } from '../common/props'
2
+ import {
3
+ baseProps,
4
+ makeArrayProp,
5
+ makeBooleanProp,
6
+ makeNumberProp,
7
+ makeStringProp,
8
+ } from '../common/props'
3
9
 
4
10
  export type DropMenuItemBeforeToggleOption = {
5
11
  // 操作状态:true 打开下拉菜单,false 关闭下拉菜单
@@ -25,7 +31,7 @@ export const dorpMenuItemProps = {
25
31
  */
26
32
  modelValue: [String, Number],
27
33
  /**
28
- * 列表数据,对应数据结构 [{label: '标题', value: '0', tip: '提示文字'}]
34
+ * 列表数据,对应数据结构 [{text: '标题', value: '0', tip: '提示文字'}]
29
35
  */
30
36
  options: makeArrayProp<Record<string, any>>(),
31
37
  /**
@@ -47,7 +53,7 @@ export const dorpMenuItemProps = {
47
53
  /**
48
54
  * 菜单图标大小
49
55
  */
50
- iconSize: numericProp,
56
+ iconSize: makeStringProp('14px'),
51
57
  /**
52
58
  * 自定义点击事件
53
59
  */
@@ -64,22 +70,11 @@ export const dorpMenuItemProps = {
64
70
  * 选项对象中,选项说明对应的 key
65
71
  */
66
72
  tipKey: makeStringProp('tip'),
73
+ selected: makeBooleanProp(false),
67
74
  /**
68
- * 自定义下拉菜单popup样式类
69
- */
70
- customPopupClass: makeStringProp(''),
71
- /**
72
- * 自定义下拉菜单popup样式
73
- */
74
- customPopupStyle: makeStringProp(''),
75
- /**
76
- * 弹出层高度 这里设置了 就取这里的
77
- */
78
- popupHeight: makeStringProp(''),
79
- /**
80
- * 是否从页面中脱离出来,用于解决各种 fixed 失效问题 (H5: teleport, APP: renderjs, 小程序: root-portal)
75
+ * 选项对象中,选项说明对应的 key
81
76
  */
82
- rootPortal: makeBooleanProp(false)
77
+ dot: makeNumberProp(0),
83
78
  }
84
79
 
85
80
  export type DropMenuItemProps = ExtractPropTypes<typeof dorpMenuItemProps>
@@ -89,6 +84,8 @@ export type DropMenuItemExpose = {
89
84
  open: () => void
90
85
  close: () => void
91
86
  toggle: () => void
87
+ getSelected: () => boolean
88
+ getDot: () => number
92
89
  }
93
90
 
94
- export type DropMenuItemInstance = ComponentPublicInstance<DropMenuItemProps, DropMenuItemExpose>
91
+ export type DropMenuItemInstance = ComponentPublicInstance<DropMenuItemProps>
@@ -2,24 +2,24 @@
2
2
  <view
3
3
  v-if="showWrapper"
4
4
  :class="`wd-drop-item ${customClass}`"
5
- :style="`pointer-events: none; z-index: ${zIndex}; ${positionStyle};${customStyle}`"
5
+ :style="`z-index: ${zIndex}; ${positionStyle};${customStyle}`"
6
6
  >
7
7
  <wd-popup
8
8
  v-model="showPop"
9
9
  :z-index="zIndex"
10
10
  :duration="duration"
11
11
  :position="position"
12
- :custom-style="`position: absolute; pointer-events: auto; max-height: ${popupHeight ? popupHeight : '80%'}; ${customPopupStyle}`"
13
- :custom-class="customPopupClass"
14
- :modal="false"
12
+ custom-style="position: absolute; max-height: 90%;"
13
+ modal-style="position: absolute;"
14
+ :modal="modal"
15
15
  :close-on-click-modal="false"
16
- :root-portal="rootPortal"
16
+ @click-modal="closeOnClickModal && close()"
17
17
  @before-enter="beforeEnter"
18
18
  @after-enter="afterEnter"
19
19
  @before-leave="beforeLeave"
20
20
  @after-leave="afterLeave"
21
21
  >
22
- <scroll-view v-if="options.length" :style="popupHeight ? { height: popupHeight } : ''" scroll-y scroll-with-animation :show-scrollbar="true">
22
+ <view v-if="options.length">
23
23
  <view
24
24
  v-for="(item, index) in options"
25
25
  :key="index"
@@ -33,10 +33,11 @@
33
33
  <wd-icon
34
34
  v-if="(item[valueKey] !== '' ? item[valueKey] : item) === modelValue"
35
35
  :name="iconName"
36
- :custom-class="`wd-drop-item__icon ${customIcon}`"
36
+ size="20px"
37
+ :class="`wd-drop-item__icon ${customIcon}`"
37
38
  />
38
39
  </view>
39
- </scroll-view>
40
+ </view>
40
41
  <slot v-else />
41
42
  </wd-popup>
42
43
  </view>
@@ -47,15 +48,21 @@ export default {
47
48
  options: {
48
49
  virtualHost: true,
49
50
  addGlobalClass: true,
50
- styleIsolation: 'shared'
51
- }
51
+ styleIsolation: 'shared',
52
+ },
52
53
  }
53
54
  </script>
54
55
 
55
56
  <script lang="ts" setup>
56
- import wdPopup from '../wd-popup/wd-popup.vue'
57
- import wdIcon from '../wd-icon/wd-icon.vue'
58
- import { computed, getCurrentInstance, inject, onBeforeMount, onBeforeUnmount, ref, watch } from 'vue'
57
+ import {
58
+ computed,
59
+ getCurrentInstance,
60
+ inject,
61
+ onBeforeMount,
62
+ onBeforeUnmount,
63
+ ref,
64
+ watch,
65
+ } from 'vue'
59
66
  import { pushToQueue, removeFromQueue } from '../common/clickoutside'
60
67
  import { type Queue, queueKey } from '../composables/useQueue'
61
68
  import type { PopupType } from '../wd-popup/types'
@@ -65,26 +72,23 @@ import { isDef, isFunction } from '../common/util'
65
72
  import { dorpMenuItemProps, type DropMenuItemExpose } from './types'
66
73
 
67
74
  const props = defineProps(dorpMenuItemProps)
68
- const emit = defineEmits<{
69
- (e: 'update:modelValue', value: string | number): void
70
- (e: 'change', event: { value: string | number; selectedItem: Record<string, any> }): void
71
- (e: 'open'): void
72
- (e: 'opened'): void
73
- (e: 'close'): void
74
- (e: 'closed'): void
75
- }>()
75
+ const emit = defineEmits(['change', 'update:modelValue', 'open', 'opened', 'closed', 'close'])
76
76
 
77
77
  const queue = inject<Queue | null>(queueKey, null)
78
78
  const showWrapper = ref<boolean>(false)
79
79
  const showPop = ref<boolean>(false)
80
80
  const position = ref<PopupType>()
81
81
  const zIndex = ref<number>(12)
82
+ const modal = ref<boolean>(true)
83
+ const closeOnClickModal = ref<boolean>(true)
82
84
  const duration = ref<number>(0)
83
85
 
84
86
  const { parent: dropMenu } = useParent(DROP_MENU_KEY)
85
87
 
86
88
  const { proxy } = getCurrentInstance() as any
87
-
89
+ const popupProvide = inject('wd-popup', {
90
+ value: false,
91
+ })
88
92
  const positionStyle = computed(() => {
89
93
  let style: string = ''
90
94
  if (showWrapper.value && dropMenu) {
@@ -102,13 +106,15 @@ watch(
102
106
  () => props.modelValue,
103
107
  (newValue) => {
104
108
  if (isDef(newValue) && typeof newValue !== 'number' && typeof newValue !== 'string') {
105
- console.error('[wot-design] warning(wd-drop-menu-item): the type of value should be a number or a string.')
109
+ console.error(
110
+ '[wot-design] warning(wd-drop-menu-item): the type of value should be a number or a string.',
111
+ )
106
112
  }
107
113
  },
108
114
  {
109
115
  deep: true,
110
- immediate: true
111
- }
116
+ immediate: true,
117
+ },
112
118
  )
113
119
 
114
120
  onBeforeMount(() => {
@@ -130,16 +136,26 @@ onBeforeUnmount(() => {
130
136
  function getShowPop() {
131
137
  return showPop.value
132
138
  }
139
+
140
+ function getDot() {
141
+ return props.dot
142
+ }
143
+
144
+ function getSelected() {
145
+ return props.selected
146
+ }
133
147
  // 模拟单选操作 默认根据 value 选中操作
134
148
  function choose(index: number) {
135
149
  if (props.disabled) return
136
150
  const { valueKey } = props
137
151
  const item = props.options[index]
138
- const newValue = item[valueKey] !== undefined ? item[valueKey] : item
139
- emit('update:modelValue', newValue)
152
+ emit(
153
+ 'update:modelValue',
154
+ item[valueKey] !== '' && item[valueKey] !== undefined ? item[valueKey] : item,
155
+ )
140
156
  emit('change', {
141
- value: newValue,
142
- selectedItem: item
157
+ value: item[valueKey] !== '' && item[valueKey] !== undefined ? item[valueKey] : item,
158
+ selectedItem: item,
143
159
  })
144
160
  close()
145
161
  }
@@ -153,7 +169,7 @@ function close() {
153
169
  status: false,
154
170
  resolve: (isPass: boolean) => {
155
171
  isPass && handleClose()
156
- }
172
+ },
157
173
  })
158
174
  } else {
159
175
  handleClose()
@@ -163,6 +179,7 @@ function close() {
163
179
  function handleClose() {
164
180
  if (showPop.value) {
165
181
  showPop.value = false
182
+ popupProvide.value = false
166
183
  }
167
184
  }
168
185
 
@@ -175,7 +192,7 @@ function open() {
175
192
  status: true,
176
193
  resolve: (isPass) => {
177
194
  isPass && handleOpen()
178
- }
195
+ },
179
196
  })
180
197
  } else {
181
198
  handleOpen()
@@ -185,10 +202,14 @@ function open() {
185
202
  function handleOpen() {
186
203
  showWrapper.value = true
187
204
  showPop.value = true
205
+ popupProvide.value = true
188
206
  if (dropMenu) {
207
+ modal.value = Boolean(dropMenu.props.modal)
189
208
  duration.value = Number(dropMenu.props.duration)
209
+ closeOnClickModal.value = Boolean(dropMenu.props.closeOnClickModal)
190
210
  position.value = dropMenu.props.direction === 'down' ? 'top' : 'bottom'
191
211
  }
212
+ emit('open')
192
213
  }
193
214
 
194
215
  function toggle() {
@@ -213,9 +234,9 @@ function beforeLeave() {
213
234
  emit('close')
214
235
  }
215
236
 
216
- defineExpose<DropMenuItemExpose>({ getShowPop, open, close, toggle })
237
+ defineExpose<DropMenuItemExpose>({ getShowPop, open, close, toggle, getSelected, getDot })
217
238
  </script>
218
239
 
219
240
  <style lang="scss" scoped>
220
- @import './index.scss';
241
+ @import './index';
221
242
  </style>
@@ -86,8 +86,8 @@ export default {
86
86
  options: {
87
87
  virtualHost: true,
88
88
  addGlobalClass: true,
89
- styleIsolation: 'shared'
90
- }
89
+ styleIsolation: 'shared',
90
+ },
91
91
  }
92
92
  </script>
93
93
 
@@ -97,7 +97,14 @@ import wdPopup from '../wd-popup/wd-popup.vue'
97
97
  import wdPickerView from '../wd-picker-view/wd-picker-view.vue'
98
98
  import wdCell from '../wd-cell/wd-cell.vue'
99
99
  import { getCurrentInstance, onBeforeMount, ref, watch, computed, onMounted, nextTick } from 'vue'
100
- import { deepClone, defaultDisplayFormat, getType, isArray, isDef, isFunction } from '../common/util'
100
+ import {
101
+ deepClone,
102
+ defaultDisplayFormat,
103
+ getType,
104
+ isArray,
105
+ isDef,
106
+ isFunction,
107
+ } from '../common/util'
101
108
  import { type ColumnItem, formatArray, type PickerViewInstance } from '../wd-picker-view/types'
102
109
  import { FORM_KEY, type FormItemRule } from '../wd-form/types'
103
110
  import { useParent } from '../composables/useParent'
@@ -117,8 +124,12 @@ const popupShow = ref<boolean>(false)
117
124
  // 选定后展示的选中项
118
125
  const showValue = ref<string>('')
119
126
  const pickerValue = ref<string | number | boolean | string[] | number[] | boolean[]>('')
120
- const displayColumns = ref<Array<string | number | ColumnItem | Array<string | number | ColumnItem>>>([]) // 传入 pickerView 的columns
121
- const resetColumns = ref<Array<string | number | ColumnItem | Array<string | number | ColumnItem>>>([]) // 保存之前的 columns,当取消时,将数据源回滚,避免多级联动数据源不正确的情况
127
+ const displayColumns = ref<
128
+ Array<string | number | ColumnItem | Array<string | number | ColumnItem>>
129
+ >([]) // 传入 pickerView 的columns
130
+ const resetColumns = ref<Array<string | number | ColumnItem | Array<string | number | ColumnItem>>>(
131
+ [],
132
+ ) // 保存之前的 columns,当取消时,将数据源回滚,避免多级联动数据源不正确的情况
122
133
  const isPicking = ref<boolean>(false) // 判断pickview是否还在滑动中
123
134
  const hasConfirmed = ref<boolean>(false) // 判断用户是否点击了确认按钮
124
135
 
@@ -138,8 +149,8 @@ watch(
138
149
  },
139
150
  {
140
151
  immediate: true,
141
- deep: true
142
- }
152
+ deep: true,
153
+ },
143
154
  )
144
155
 
145
156
  watch(
@@ -151,8 +162,8 @@ watch(
151
162
  },
152
163
  {
153
164
  deep: true,
154
- immediate: true
155
- }
165
+ immediate: true,
166
+ },
156
167
  )
157
168
 
158
169
  watch(
@@ -171,8 +182,8 @@ watch(
171
182
  },
172
183
  {
173
184
  deep: true,
174
- immediate: true
175
- }
185
+ immediate: true,
186
+ },
176
187
  )
177
188
 
178
189
  watch(
@@ -184,8 +195,8 @@ watch(
184
195
  },
185
196
  {
186
197
  deep: true,
187
- immediate: true
188
- }
198
+ immediate: true,
199
+ },
189
200
  )
190
201
 
191
202
  // 是否展示清除按钮
@@ -263,7 +274,7 @@ function getSelects(value: string | number | Array<string | number | Array<any>>
263
274
  if (value.length === 0) {
264
275
  value = formatColumns.map(() => 0)
265
276
  }
266
- let selected: number[] = []
277
+ const selected: number[] = []
267
278
  value.forEach((target, col) => {
268
279
  let row = formatColumns[col].findIndex((row) => {
269
280
  return row[props.valueKey].toString() === target.toString()
@@ -306,7 +317,7 @@ function showPopup() {
306
317
  function onCancel() {
307
318
  popupShow.value = false
308
319
  emit('cancel')
309
- let timmer = setTimeout(() => {
320
+ const timmer = setTimeout(() => {
310
321
  clearTimeout(timmer)
311
322
  isDef(pickerViewWd.value) && pickerViewWd.value.resetColumns(resetColumns.value)
312
323
  }, 300)
@@ -330,7 +341,7 @@ function onConfirm() {
330
341
  (isPass: boolean) => {
331
342
  isPass && handleConfirm()
332
343
  },
333
- proxy.$.exposed
344
+ proxy.$.exposed,
334
345
  )
335
346
  } else {
336
347
  handleConfirm()
@@ -353,7 +364,7 @@ function handleConfirm() {
353
364
  setShowValue(selects)
354
365
  emit('confirm', {
355
366
  value: values,
356
- selectedItems: selects
367
+ selectedItems: selects,
357
368
  })
358
369
  }
359
370
  /**
@@ -404,7 +415,7 @@ function handleClear() {
404
415
  defineExpose<PickerExpose>({
405
416
  close,
406
417
  open,
407
- setLoading
418
+ setLoading,
408
419
  })
409
420
  </script>
410
421
  <style lang="scss" scoped>
@@ -1,5 +1,5 @@
1
- @import "./../common/abstracts/_mixin.scss";
2
- @import "./../common/abstracts/variable.scss";
1
+ @import './../common/abstracts/_mixin.scss';
2
+ @import './../common/abstracts/variable.scss';
3
3
 
4
4
  .wot-theme-dark {
5
5
  @include b(radio) {
@@ -29,7 +29,7 @@
29
29
  color: $-dark-color-gray;
30
30
  }
31
31
  }
32
-
32
+
33
33
  @include when(button) {
34
34
  .wd-radio__label {
35
35
  border-color: #c8c9cc;
@@ -44,7 +44,7 @@
44
44
  }
45
45
  }
46
46
  }
47
-
47
+
48
48
  @include when(dot) {
49
49
  .wd-radio__shape {
50
50
  border-color: #c8c9cc;
@@ -109,7 +109,7 @@
109
109
 
110
110
  @include when(dot) {
111
111
  .wd-radio__shape {
112
- border: 2px solid $-radio-dot-border-color;
112
+ border: 1px solid $-radio-dot-border-color;
113
113
  border-radius: 50%;
114
114
  position: relative;
115
115
  display: inline-block;
@@ -117,7 +117,7 @@
117
117
  transition: none;
118
118
 
119
119
  &::before {
120
- content: "";
120
+ content: '';
121
121
  position: absolute;
122
122
  width: $-radio-dot-size;
123
123
  height: $-radio-dot-size;
@@ -126,7 +126,7 @@
126
126
  border-radius: 50%;
127
127
  background-color: #fff;
128
128
  transform: scale(0);
129
- transition: transform .2s ease-in;
129
+ transition: transform 0.2s ease-in;
130
130
  }
131
131
  }
132
132
  @include when(checked) {
@@ -154,7 +154,7 @@
154
154
  height: $-radio-button-height;
155
155
  min-width: $-radio-button-min-width;
156
156
  max-width: $-radio-button-max-width;
157
- padding: 5px 15px;
157
+ padding: 4rpx 12rpx;
158
158
  margin-right: 0;
159
159
  border-radius: $-radio-button-radius;
160
160
  background-color: $-radio-button-bg;
@@ -190,7 +190,7 @@
190
190
  margin-right: 4px;
191
191
  float: left;
192
192
  &::after {
193
- content: "";
193
+ content: '';
194
194
  display: table;
195
195
  clear: both;
196
196
  }