@tplc/wot 1.0.12 → 1.0.13
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/CHANGELOG.md +2 -0
- package/components/wd-calendar/index.scss +145 -58
- package/components/wd-calendar/types.ts +41 -23
- package/components/wd-calendar/wd-calendar.vue +130 -123
- package/components/wd-calendar-view/month/index.scss +65 -33
- package/components/wd-calendar-view/month/month.vue +113 -80
- package/components/wd-calendar-view/month/types.ts +1 -2
- package/components/wd-calendar-view/monthPanel/index.scss +15 -15
- package/components/wd-calendar-view/monthPanel/month-panel.vue +78 -64
- package/components/wd-calendar-view/monthPanel/types.ts +10 -58
- package/components/wd-calendar-view/types.ts +36 -12
- package/components/wd-calendar-view/utils.ts +36 -14
- package/components/wd-calendar-view/wd-calendar-view.vue +7 -7
- package/components/wd-calendar-view/year/index.scss +13 -18
- package/components/wd-calendar-view/year/types.ts +1 -2
- package/components/wd-calendar-view/year/year.vue +43 -25
- package/components/wd-calendar-view/yearPanel/index.scss +4 -4
- package/components/wd-calendar-view/yearPanel/types.ts +2 -2
- package/components/wd-calendar-view/yearPanel/year-panel.vue +41 -36
- package/components/wd-drop-menu/index.scss +45 -17
- package/components/wd-drop-menu/types.ts +3 -3
- package/components/wd-drop-menu/wd-drop-menu.vue +25 -61
- package/components/wd-drop-menu-item/index.scss +15 -15
- package/components/wd-drop-menu-item/types.ts +15 -18
- package/components/wd-drop-menu-item/wd-drop-menu-item.vue +54 -33
- package/package.json +1 -1
- package/types/components/common/dayjs.d.ts +26 -0
- package/types/components/wd-calendar/types.d.ts +18 -24
- package/types/components/wd-calendar/wd-calendar.vue.d.ts +24 -40
- package/types/components/wd-calendar-view/month/month.vue.d.ts +3 -11
- package/types/components/wd-calendar-view/month/types.d.ts +0 -4
- package/types/components/wd-calendar-view/monthPanel/month-panel.vue.d.ts +12 -18
- package/types/components/wd-calendar-view/monthPanel/types.d.ts +6 -48
- package/types/components/wd-calendar-view/types.d.ts +4 -11
- package/types/components/wd-calendar-view/utils.d.ts +12 -3
- package/types/components/wd-calendar-view/year/types.d.ts +0 -4
- package/types/components/wd-calendar-view/year/year.vue.d.ts +3 -11
- package/types/components/wd-cell/wd-cell.vue.d.ts +5 -5
- package/types/components/wd-col-picker/wd-col-picker.vue.d.ts +9 -9
- package/types/components/wd-datetime-picker/wd-datetime-picker.vue.d.ts +10 -10
- package/types/components/wd-datetime-picker-view/wd-datetime-picker-view.vue.d.ts +1 -1
- package/types/components/wd-drop-menu/types.d.ts +3 -3
- package/types/components/wd-drop-menu/wd-drop-menu.vue.d.ts +5 -5
- package/types/components/wd-drop-menu-item/types.d.ts +15 -27
- package/types/components/wd-drop-menu-item/wd-drop-menu-item.vue.d.ts +35 -46
- package/types/components/wd-floating-panel/wd-floating-panel.vue.d.ts +1 -1
- package/types/components/wd-form/wd-form.vue.d.ts +1 -1
- package/types/components/wd-form-item/wd-form-item.vue.d.ts +1 -1
- package/types/components/wd-grid-item/wd-grid-item.vue.d.ts +1 -1
- package/types/components/wd-input/wd-input.vue.d.ts +4 -4
- package/types/components/wd-keyboard/wd-keyboard.vue.d.ts +1 -1
- package/types/components/wd-notify/wd-notify.vue.d.ts +1 -1
- package/types/components/wd-number-keyboard/wd-number-keyboard.vue.d.ts +1 -1
- package/types/components/wd-picker/wd-picker.vue.d.ts +12 -12
- package/types/components/wd-picker-view/wd-picker-view.vue.d.ts +2 -2
- package/types/components/wd-select-picker/wd-select-picker.vue.d.ts +12 -12
- package/types/components/wd-signature/wd-signature.vue.d.ts +2 -2
- package/types/components/wd-steps/wd-steps.vue.d.ts +1 -1
- package/types/components/wd-swiper/wd-swiper.vue.d.ts +1 -1
- package/types/components/wd-tabs/wd-tabs.vue.d.ts +1 -1
- package/types/components/wd-textarea/wd-textarea.vue.d.ts +3 -3
- /package/components/wd-input/{placeholder.scss → placeholder.css} +0 -0
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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 {
|
|
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,
|
|
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
|
|
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 =
|
|
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(
|
|
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
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
@include e(popup){
|
|
23
|
+
|
|
24
|
+
.wd-drop-item__popup {
|
|
25
25
|
position: absolute;
|
|
26
|
-
max-height:
|
|
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
|
-
|
|
35
|
-
|
|
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
|
-
|
|
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 {
|
|
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
|
-
* 列表数据,对应数据结构 [{
|
|
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:
|
|
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
|
-
*
|
|
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
|
-
|
|
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
|
|
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="`
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
:modal="
|
|
12
|
+
custom-style="position: absolute; max-height: 90%;"
|
|
13
|
+
modal-style="position: absolute;"
|
|
14
|
+
:modal="modal"
|
|
15
15
|
:close-on-click-modal="false"
|
|
16
|
-
|
|
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
|
-
<
|
|
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
|
-
|
|
36
|
+
size="20px"
|
|
37
|
+
:class="`wd-drop-item__icon ${customIcon}`"
|
|
37
38
|
/>
|
|
38
39
|
</view>
|
|
39
|
-
</
|
|
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
|
|
57
|
-
|
|
58
|
-
|
|
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(
|
|
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
|
-
|
|
139
|
-
|
|
152
|
+
emit(
|
|
153
|
+
'update:modelValue',
|
|
154
|
+
item[valueKey] !== '' && item[valueKey] !== undefined ? item[valueKey] : item,
|
|
155
|
+
)
|
|
140
156
|
emit('change', {
|
|
141
|
-
value:
|
|
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
|
|
241
|
+
@import './index';
|
|
221
242
|
</style>
|
package/package.json
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
declare class Dayjs {
|
|
2
|
+
utc: boolean
|
|
3
|
+
date: Date
|
|
4
|
+
timeZone: number
|
|
5
|
+
timeZoneString: any
|
|
6
|
+
mYear: any
|
|
7
|
+
mMonth: any
|
|
8
|
+
mDay: any
|
|
9
|
+
mWeek: any
|
|
10
|
+
mHour: any
|
|
11
|
+
mMinute: any
|
|
12
|
+
mSecond: any
|
|
13
|
+
constructor(dateStr?: string | number | Date)
|
|
14
|
+
parseConfig(dateStr?: string | number | Date): string | number | Date
|
|
15
|
+
padNumber(num: string, length: number, padChar: string): string
|
|
16
|
+
year(): any
|
|
17
|
+
month(): any
|
|
18
|
+
unix(): number
|
|
19
|
+
toString(): string
|
|
20
|
+
startOf(unit: string): Dayjs
|
|
21
|
+
add(amount: number, unit: string): Dayjs
|
|
22
|
+
subtract(amount: number, unit: string): Dayjs
|
|
23
|
+
format(formatStr?: string): string
|
|
24
|
+
}
|
|
25
|
+
export declare function dayjs(dateStr?: string | number | Date): Dayjs
|
|
26
|
+
export {}
|
|
@@ -80,9 +80,20 @@ export declare const calendarProps: {
|
|
|
80
80
|
/**
|
|
81
81
|
* 设置左侧标题宽度
|
|
82
82
|
*/
|
|
83
|
-
labelWidth:
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
labelWidth: StringConstructor
|
|
84
|
+
/**
|
|
85
|
+
* 使用 label 插槽时设置该选项
|
|
86
|
+
*/
|
|
87
|
+
useLabelSlot: {
|
|
88
|
+
type: BooleanConstructor
|
|
89
|
+
default: boolean
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* 使用默认插槽时设置该选项
|
|
93
|
+
*/
|
|
94
|
+
useDefaultSlot: {
|
|
95
|
+
type: BooleanConstructor
|
|
96
|
+
default: boolean
|
|
86
97
|
}
|
|
87
98
|
/**
|
|
88
99
|
* 禁用
|
|
@@ -243,6 +254,10 @@ export declare const calendarProps: {
|
|
|
243
254
|
type: BooleanConstructor
|
|
244
255
|
default: boolean
|
|
245
256
|
}
|
|
257
|
+
/**
|
|
258
|
+
* 打开前执行的函数
|
|
259
|
+
*/
|
|
260
|
+
initFun: PropType<() => void>
|
|
246
261
|
/**
|
|
247
262
|
* 是否使用内置单元格
|
|
248
263
|
* 默认为 true,使用内置单元格
|
|
@@ -251,27 +266,6 @@ export declare const calendarProps: {
|
|
|
251
266
|
type: BooleanConstructor
|
|
252
267
|
default: boolean
|
|
253
268
|
}
|
|
254
|
-
/**
|
|
255
|
-
* 是否从页面中脱离出来,用于解决各种 fixed 失效问题 (H5: teleport, APP: renderjs, 小程序: root-portal)
|
|
256
|
-
*/
|
|
257
|
-
rootPortal: {
|
|
258
|
-
type: BooleanConstructor
|
|
259
|
-
default: boolean
|
|
260
|
-
}
|
|
261
|
-
/**
|
|
262
|
-
* 必填标记位置,可选值:before、after
|
|
263
|
-
*/
|
|
264
|
-
markerSide: {
|
|
265
|
-
type: PropType<'before' | 'after'>
|
|
266
|
-
default: 'before' | 'after'
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
* 显示清空按钮
|
|
270
|
-
*/
|
|
271
|
-
clearable: {
|
|
272
|
-
type: BooleanConstructor
|
|
273
|
-
default: boolean
|
|
274
|
-
}
|
|
275
269
|
customStyle: {
|
|
276
270
|
type: PropType<string>
|
|
277
271
|
default: string
|