stellar-ui-plus 1.17.0 → 1.17.2
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/README.md +1 -1
- package/components/ste-checkbox/ste-checkbox.vue +1 -1
- package/components/ste-message-box/constants.ts +27 -21
- package/components/ste-message-box/ste-message-box.vue +19 -34
- package/components/ste-message-box/use-message-box.ts +26 -23
- package/components/ste-message-box/useData.ts +49 -49
- package/components/ste-number-keyboard/useData.ts +128 -116
- package/components/ste-radio/ste-radio.vue +1 -1
- package/components/ste-select/useData.ts +465 -438
- package/components/ste-tabs/useData.ts +357 -336
- package/components/ste-toast/ste-toast.ts +1 -0
- package/components/ste-toast/ste-toast.vue +17 -58
- package/components/ste-toast/use-toast.ts +24 -23
- package/composables.ts +2 -2
- package/package.json +2 -3
- package/store/color.ts +34 -22
- package/store/index.ts +5 -11
- package/store/message-box.ts +54 -54
- package/store/toast.ts +46 -46
- package/utils/utils.ts +456 -498
package/README.md
CHANGED
|
@@ -149,7 +149,7 @@ async function click() {
|
|
|
149
149
|
type PropsKeyTypee = keyof typeof props;
|
|
150
150
|
function getDefaultData(key: PropsKeyTypee, value: any) {
|
|
151
151
|
try {
|
|
152
|
-
if (Object.
|
|
152
|
+
if (Object.prototype.hasOwnProperty.call(props, key)) {
|
|
153
153
|
if (props[key]) {
|
|
154
154
|
return props[key];
|
|
155
155
|
} else {
|
|
@@ -1,25 +1,31 @@
|
|
|
1
1
|
export const ICON_OBJ = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
export const DURATION = 200
|
|
7
|
-
export const ANIMATION_PROP: UniApp.CreateAnimationOptions = { duration: DURATION, timingFunction: 'ease-out' }
|
|
2
|
+
info: '',
|
|
3
|
+
success: '',
|
|
4
|
+
error: '',
|
|
5
|
+
};
|
|
6
|
+
export const DURATION = 200;
|
|
7
|
+
export const ANIMATION_PROP: UniApp.CreateAnimationOptions = { duration: DURATION, timingFunction: 'ease-out' };
|
|
8
|
+
|
|
9
|
+
export type MessageBoxIcon = 'info' | 'success' | 'error';
|
|
8
10
|
|
|
9
|
-
export
|
|
11
|
+
export interface MessageBoxOptions {
|
|
12
|
+
show?: boolean;
|
|
13
|
+
title?: string;
|
|
14
|
+
content?: string;
|
|
15
|
+
icon?: MessageBoxIcon;
|
|
16
|
+
cancelText?: string;
|
|
17
|
+
confirmText?: string;
|
|
18
|
+
confirmColor?: string;
|
|
19
|
+
showCancel?: boolean;
|
|
20
|
+
showClose?: boolean;
|
|
21
|
+
cancelColor?: string;
|
|
22
|
+
editable?: boolean;
|
|
23
|
+
placeholderText?: string;
|
|
24
|
+
confirm?: (value?: string) => void;
|
|
25
|
+
cancel?: (value?: string) => void;
|
|
26
|
+
complete?: (value?: string) => void;
|
|
10
27
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
showCancel: true,
|
|
15
|
-
icon: '',
|
|
16
|
-
cancelText: '取消',
|
|
17
|
-
cancelColor: '#333333',
|
|
18
|
-
confirmText: '确认',
|
|
19
|
-
confirmColor: '',
|
|
20
|
-
editable: false,
|
|
21
|
-
placeholderText: '',
|
|
22
|
-
success: null,
|
|
23
|
-
fail: null,
|
|
24
|
-
complete: null,
|
|
28
|
+
closeOnClickOverlay?: boolean;
|
|
29
|
+
closeOnPressEscape?: boolean;
|
|
30
|
+
closeOnBackdropClick?: boolean;
|
|
25
31
|
}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import { watch, computed, useSlots, defineOptions } from 'vue';
|
|
2
|
+
import { inject, watch, ref, computed, useSlots, defineOptions } from 'vue';
|
|
3
|
+
import { messageBoxDefaultOptionsKey } from './ste-message-box';
|
|
3
4
|
import useData from './useData';
|
|
4
5
|
import type { BaseEvent } from '../../types/event';
|
|
5
6
|
import utils from '../../utils/utils';
|
|
6
|
-
import { ICON_OBJ, ANIMATION_PROP, DURATION } from './constants';
|
|
7
|
-
import type { MessageBoxOptions } from '../../types';
|
|
8
|
-
import { STE_MESSAGE_BOX_KEY } from './use-message-box';
|
|
9
|
-
import { useMsgBoxStore } from '../../store';
|
|
10
|
-
import { useColorStore } from '../../store/color';
|
|
11
|
-
let { getColor } = useColorStore();
|
|
7
|
+
import { ICON_OBJ, ANIMATION_PROP, DURATION, type MessageBoxOptions } from './constants';
|
|
12
8
|
|
|
13
9
|
defineOptions({
|
|
14
10
|
name: 'ste-message-box',
|
|
@@ -19,9 +15,6 @@ const slots = useSlots();
|
|
|
19
15
|
const props = defineProps<{
|
|
20
16
|
selector: string;
|
|
21
17
|
}>();
|
|
22
|
-
const customKey = props.selector || STE_MESSAGE_BOX_KEY;
|
|
23
|
-
const { getMessageBox, resetMessageBox } = useMsgBoxStore();
|
|
24
|
-
const messageBoxOption = getMessageBox(customKey);
|
|
25
18
|
|
|
26
19
|
const {
|
|
27
20
|
animationData,
|
|
@@ -44,6 +37,9 @@ const {
|
|
|
44
37
|
showInputPlaceholder,
|
|
45
38
|
} = useData();
|
|
46
39
|
|
|
40
|
+
const injectKey = props.selector ? props.selector : messageBoxDefaultOptionsKey;
|
|
41
|
+
const injectMessageBoxOption = ref<MessageBoxOptions>(inject(injectKey) || {});
|
|
42
|
+
|
|
47
43
|
// 用input自带占位符时,由于动画原因导致最终显示会有一个下降的效果
|
|
48
44
|
function handleInputFocus() {
|
|
49
45
|
showInputPlaceholder.value = false;
|
|
@@ -59,7 +55,7 @@ const cmpRootStyle = computed(() => {
|
|
|
59
55
|
return {
|
|
60
56
|
opacity: 0,
|
|
61
57
|
'--cancel-color': cancelColor.value,
|
|
62
|
-
'--confirm-color': confirmColor.value
|
|
58
|
+
'--confirm-color': confirmColor.value,
|
|
63
59
|
};
|
|
64
60
|
});
|
|
65
61
|
|
|
@@ -112,7 +108,6 @@ function closeBox() {
|
|
|
112
108
|
maskAnimationData.value = maskAnimation.export();
|
|
113
109
|
setTimeout(() => {
|
|
114
110
|
show.value = false;
|
|
115
|
-
resetMessageBox(customKey);
|
|
116
111
|
}, DURATION);
|
|
117
112
|
}
|
|
118
113
|
function handleInput(e: Event) {
|
|
@@ -149,18 +144,14 @@ function loadMessageBoxParams(options: MessageBoxOptions) {
|
|
|
149
144
|
complete.value = options.complete || complete.value;
|
|
150
145
|
}
|
|
151
146
|
|
|
152
|
-
watch(
|
|
153
|
-
()
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
},
|
|
162
|
-
{ deep: true }
|
|
163
|
-
);
|
|
147
|
+
watch(injectMessageBoxOption, val => {
|
|
148
|
+
if (val.show) {
|
|
149
|
+
loadMessageBoxParams(val);
|
|
150
|
+
showBox();
|
|
151
|
+
} else {
|
|
152
|
+
closeBox();
|
|
153
|
+
}
|
|
154
|
+
});
|
|
164
155
|
|
|
165
156
|
function showMsgBox(options: MessageBoxOptions) {
|
|
166
157
|
loadMessageBoxParams(options);
|
|
@@ -197,10 +188,10 @@ defineExpose({
|
|
|
197
188
|
</view>
|
|
198
189
|
</view>
|
|
199
190
|
<view class="footer">
|
|
200
|
-
<view class="
|
|
191
|
+
<view class="cancel text" v-if="showCancel" @click="handleCancel">
|
|
201
192
|
{{ cancelText }}
|
|
202
193
|
</view>
|
|
203
|
-
<view class="
|
|
194
|
+
<view class="confirm text" @click="handleConfirm">
|
|
204
195
|
{{ confirmText }}
|
|
205
196
|
</view>
|
|
206
197
|
</view>
|
|
@@ -244,7 +235,6 @@ defineExpose({
|
|
|
244
235
|
.ste-message-title {
|
|
245
236
|
padding-bottom: 48rpx !important;
|
|
246
237
|
}
|
|
247
|
-
|
|
248
238
|
.msg {
|
|
249
239
|
padding: 0 !important;
|
|
250
240
|
}
|
|
@@ -259,7 +249,6 @@ defineExpose({
|
|
|
259
249
|
display: inline-flex;
|
|
260
250
|
flex-direction: column;
|
|
261
251
|
transform: scale(0);
|
|
262
|
-
|
|
263
252
|
.content-box {
|
|
264
253
|
.icon-box {
|
|
265
254
|
padding-top: 4rpx;
|
|
@@ -273,7 +262,6 @@ defineExpose({
|
|
|
273
262
|
align-items: center;
|
|
274
263
|
justify-content: center;
|
|
275
264
|
}
|
|
276
|
-
|
|
277
265
|
.ste-message-title {
|
|
278
266
|
width: 100%;
|
|
279
267
|
padding-top: 48rpx;
|
|
@@ -286,7 +274,6 @@ defineExpose({
|
|
|
286
274
|
.msg {
|
|
287
275
|
padding: 0 32rpx 48rpx 32rpx;
|
|
288
276
|
text-align: center;
|
|
289
|
-
|
|
290
277
|
.text {
|
|
291
278
|
width: 100%;
|
|
292
279
|
font-size: var(--font-size-28, 28rpx);
|
|
@@ -317,12 +304,10 @@ defineExpose({
|
|
|
317
304
|
}
|
|
318
305
|
}
|
|
319
306
|
}
|
|
320
|
-
|
|
321
307
|
.footer {
|
|
322
308
|
display: flex;
|
|
323
309
|
height: 96rpx;
|
|
324
|
-
|
|
325
|
-
.footer-btn {
|
|
310
|
+
> view {
|
|
326
311
|
height: 100%;
|
|
327
312
|
border-top: 2rpx solid #eeeeee;
|
|
328
313
|
border-right: 2rpx solid #eeeeee;
|
|
@@ -346,7 +331,7 @@ defineExpose({
|
|
|
346
331
|
color: var(--confirm-color);
|
|
347
332
|
}
|
|
348
333
|
|
|
349
|
-
|
|
334
|
+
&:nth-last-child(1) {
|
|
350
335
|
border-right: none;
|
|
351
336
|
}
|
|
352
337
|
}
|
|
@@ -1,26 +1,29 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { provide, ref } from 'vue';
|
|
2
|
+
import { messageBoxDefaultOptionsKey } from './ste-message-box';
|
|
3
|
+
import type { MessageBoxOptions } from './constants';
|
|
3
4
|
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
export function useMessageBox(customKey?: string) {
|
|
6
|
+
const provideKey = customKey || messageBoxDefaultOptionsKey;
|
|
7
|
+
const MsgOptions = ref<MessageBoxOptions>({});
|
|
8
|
+
provide(provideKey, MsgOptions);
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
10
|
+
// 打开弹窗
|
|
11
|
+
function showMsgBox(options: MessageBoxOptions) {
|
|
12
|
+
MsgOptions.value = Object.assign(
|
|
13
|
+
{
|
|
14
|
+
show: true,
|
|
15
|
+
},
|
|
16
|
+
options
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
/** 关闭弹窗 */
|
|
20
|
+
function hideMsgBox() {
|
|
21
|
+
MsgOptions.value = {
|
|
22
|
+
show: false,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
showMsgBox,
|
|
27
|
+
hideMsgBox,
|
|
28
|
+
};
|
|
26
29
|
}
|
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
import { ref } from 'vue'
|
|
2
|
-
import {
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
import type { MessageBoxIcon } from './constants';
|
|
3
3
|
|
|
4
4
|
export default function useData() {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
5
|
+
const title = ref('确认删除订单?');
|
|
6
|
+
const content = ref('');
|
|
7
|
+
const icon = ref<MessageBoxIcon | ''>('');
|
|
8
|
+
const cancelText = ref('取消');
|
|
9
|
+
const cancelColor = ref('#333333');
|
|
10
|
+
const confirmText = ref('确认');
|
|
11
|
+
const confirmColor = ref('#0090ff');
|
|
12
|
+
const showCancel = ref(true);
|
|
13
|
+
const editable = ref(false);
|
|
14
|
+
const placeholderText = ref('');
|
|
15
|
+
const inputType = ref('');
|
|
16
|
+
const confirm = ref((_value?: string) => {});
|
|
17
|
+
const cancel = ref((_value?: string) => {});
|
|
18
|
+
const complete = ref((_value?: string) => {});
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
// 内部值
|
|
21
|
+
const pageShow = ref(true);
|
|
22
|
+
const show = ref(false);
|
|
23
|
+
const inputValue = ref('');
|
|
24
|
+
const animationData = ref(null);
|
|
25
|
+
const maskAnimationData = ref(null);
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
const open = ref(false);
|
|
28
|
+
const tmpMsg = ref(null);
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
const showInputPlaceholder = ref(true);
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
32
|
+
return {
|
|
33
|
+
title,
|
|
34
|
+
content,
|
|
35
|
+
icon,
|
|
36
|
+
cancelText,
|
|
37
|
+
cancelColor,
|
|
38
|
+
confirmText,
|
|
39
|
+
confirmColor,
|
|
40
|
+
showCancel,
|
|
41
|
+
editable,
|
|
42
|
+
placeholderText,
|
|
43
|
+
inputType,
|
|
44
|
+
confirm,
|
|
45
|
+
cancel,
|
|
46
|
+
complete,
|
|
47
|
+
pageShow,
|
|
48
|
+
show,
|
|
49
|
+
inputValue,
|
|
50
|
+
animationData,
|
|
51
|
+
maskAnimationData,
|
|
52
|
+
open,
|
|
53
|
+
tmpMsg,
|
|
54
|
+
showInputPlaceholder,
|
|
55
|
+
};
|
|
56
56
|
}
|
|
@@ -1,132 +1,144 @@
|
|
|
1
|
-
import { computed, ref, watch } from 'vue'
|
|
2
|
-
import utils from '../../utils/utils'
|
|
3
|
-
import { useColorStore } from '../../store/color'
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { computed, ref, watch } from 'vue'
|
|
2
|
+
import utils from '../../utils/utils'
|
|
3
|
+
import { useColorStore } from '../../store/color'
|
|
4
|
+
import type { NumberKeyboardProps } from './props'
|
|
5
|
+
|
|
6
|
+
const { getColor } = useColorStore()
|
|
6
7
|
export default function useData({
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
props,
|
|
9
|
+
emits,
|
|
9
10
|
}: {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
11
|
+
props: NumberKeyboardProps
|
|
12
|
+
emits: {
|
|
13
|
+
(e: 'change', value: string): void
|
|
14
|
+
(e: 'input', value: string): void
|
|
15
|
+
(e: 'update:modelValue', value: string): void
|
|
16
|
+
(e: 'clear'): void
|
|
17
|
+
(e: 'backspace'): void
|
|
18
|
+
(e: 'confirm', value: string): void
|
|
19
|
+
(e: 'click', key: string): void
|
|
20
|
+
(e: 'beforeinput', key: string, suspend: () => void, next: () => void, stop: () => void): void
|
|
21
|
+
(e: 'close'): void
|
|
22
|
+
(e: 'update:show', show: boolean): void
|
|
23
|
+
(e: 'open'): void
|
|
24
|
+
}
|
|
24
25
|
}) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
const dataValue = ref('')
|
|
27
|
+
const setDataValue = (value: string) => {
|
|
28
|
+
if (value === dataValue.value)
|
|
29
|
+
return
|
|
30
|
+
if (value === null || value === undefined)
|
|
31
|
+
dataValue.value = ''
|
|
32
|
+
else if (typeof value === 'string')
|
|
33
|
+
dataValue.value = value
|
|
34
|
+
else dataValue.value = String(value)
|
|
35
|
+
}
|
|
32
36
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
const dataShow = ref(false)
|
|
38
|
+
const setDataShow = (value: boolean) => {
|
|
39
|
+
if (value === dataShow.value)
|
|
40
|
+
return
|
|
41
|
+
dataShow.value = value
|
|
42
|
+
}
|
|
38
43
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
44
|
+
const cmpNumbers = computed(() => {
|
|
45
|
+
let keys = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0']
|
|
46
|
+
if (props.randomKeys)
|
|
47
|
+
keys = utils.randomArray(keys)
|
|
42
48
|
|
|
43
|
-
|
|
49
|
+
if (Array.isArray(props.customKeys))
|
|
50
|
+
keys.push(...props.customKeys)
|
|
44
51
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
52
|
+
if (!props.rightKeys) {
|
|
53
|
+
if (!props.showClear) {
|
|
54
|
+
keys.push('backspace')
|
|
55
|
+
return
|
|
56
|
+
}
|
|
57
|
+
const d = keys.length % 3
|
|
58
|
+
if (d === 1) {
|
|
59
|
+
const end = keys.pop()
|
|
60
|
+
keys.push('clear', end || '', 'backspace')
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
keys.push('clear', 'backspace')
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return keys
|
|
67
|
+
})
|
|
60
68
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
const cmpRootStyle = computed(() => {
|
|
70
|
+
return {
|
|
71
|
+
'--ste-number-keyboard-text-color': props.textColor,
|
|
72
|
+
'--ste-number-keyboard-text-size': `var(--font-size-${props.textSize},${utils.formatPx(props.textSize)})`,
|
|
73
|
+
'--ste-number-keyboard-clear-text-size': `var(--font-size-${props.textSize},${utils.formatPx(Number(props.textSize) - 8)})`,
|
|
74
|
+
'--ste-number-keyboard-confirm-text-size': `var(--font-size-${props.textSize},${utils.formatPx(Number(props.textSize) - 3)})`,
|
|
75
|
+
'--ste-number-keyboard-confirm-bg': props.confirmBg ? props.confirmBg : getColor().steThemeColor,
|
|
76
|
+
'--ste-number-keyboard-confirm-bg-active': utils.Color.formatColor(props.confirmBg, 0.8),
|
|
77
|
+
'--ste-number-keyboard-confirm-color': props.confirmColor,
|
|
78
|
+
}
|
|
79
|
+
})
|
|
72
80
|
|
|
73
|
-
|
|
74
|
-
|
|
81
|
+
watch(() => props.modelValue, setDataValue, { immediate: true })
|
|
82
|
+
watch(() => props.show, setDataShow, { immediate: true })
|
|
75
83
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
84
|
+
const onClose = () => {
|
|
85
|
+
setDataShow(false)
|
|
86
|
+
emits('update:show', false)
|
|
87
|
+
emits('close')
|
|
88
|
+
}
|
|
81
89
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
const beforInput = async (value: string) => {
|
|
91
|
+
let next = true
|
|
92
|
+
const stop = new Promise((resolve, reject) => {
|
|
93
|
+
emits(
|
|
94
|
+
'beforeinput',
|
|
95
|
+
value,
|
|
96
|
+
() => (next = false),
|
|
97
|
+
() => resolve('next'),
|
|
98
|
+
() => reject(new Error('beforInput stop')),
|
|
99
|
+
)
|
|
100
|
+
})
|
|
101
|
+
if (!next)
|
|
102
|
+
await stop
|
|
94
103
|
|
|
95
|
-
|
|
96
|
-
|
|
104
|
+
/* eslint prefer-promise-reject-errors: "error" */
|
|
105
|
+
}
|
|
97
106
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
107
|
+
const onChange = async (value: string) => {
|
|
108
|
+
try {
|
|
109
|
+
if (value === 'confirm') {
|
|
110
|
+
emits('confirm', dataValue.value)
|
|
111
|
+
onClose()
|
|
112
|
+
return
|
|
113
|
+
}
|
|
114
|
+
switch (value) {
|
|
115
|
+
case 'backspace':
|
|
116
|
+
setDataValue(dataValue.value.slice(0, dataValue.value.length - 1))
|
|
117
|
+
emits('backspace')
|
|
118
|
+
break
|
|
119
|
+
case 'clear':
|
|
120
|
+
setDataValue('')
|
|
121
|
+
emits('clear')
|
|
122
|
+
break
|
|
123
|
+
default:
|
|
124
|
+
await beforInput(value)
|
|
125
|
+
emits('click', value)
|
|
126
|
+
if (props.maxlength && dataValue.value.length >= Number(props.maxlength))
|
|
127
|
+
return
|
|
128
|
+
dataValue.value += value
|
|
129
|
+
break
|
|
130
|
+
}
|
|
131
|
+
emits('input', dataValue.value)
|
|
132
|
+
emits('change', dataValue.value)
|
|
133
|
+
emits('update:modelValue', dataValue.value)
|
|
134
|
+
}
|
|
135
|
+
catch (e) {
|
|
136
|
+
if (e)
|
|
137
|
+
console.error(e)
|
|
138
|
+
}
|
|
139
|
+
}
|
|
128
140
|
|
|
129
|
-
|
|
141
|
+
const onOpen = () => emits('open')
|
|
130
142
|
|
|
131
|
-
|
|
143
|
+
return { cmpNumbers, cmpRootStyle, dataShow, onClose, onChange, onOpen }
|
|
132
144
|
}
|
|
@@ -131,7 +131,7 @@ async function click() {
|
|
|
131
131
|
type PropsKeyTypee = keyof typeof props;
|
|
132
132
|
function getDefaultData(key: PropsKeyTypee, value: any) {
|
|
133
133
|
try {
|
|
134
|
-
if (Object.
|
|
134
|
+
if (Object.prototype.hasOwnProperty.call(props, key)) {
|
|
135
135
|
if (props[key]) {
|
|
136
136
|
return props[key];
|
|
137
137
|
} else {
|