@tuya-miniapp/smart-ui 2.2.0 → 2.2.1-beta-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/dist/dialog/dialog.d.ts +2 -1
- package/dist/dialog/dialog.js +5 -5
- package/dist/dialog/index.js +8 -1
- package/dist/toast/index.js +15 -1
- package/dist/toast/toast.d.ts +2 -1
- package/dist/toast/toast.js +3 -2
- package/lib/dialog/dialog.d.ts +2 -1
- package/lib/dialog/dialog.js +5 -5
- package/lib/dialog/index.js +8 -1
- package/lib/toast/index.js +15 -1
- package/lib/toast/toast.d.ts +2 -1
- package/lib/toast/toast.js +3 -2
- package/package.json +1 -1
package/dist/dialog/dialog.d.ts
CHANGED
@@ -35,6 +35,7 @@ interface DialogOptions {
|
|
35
35
|
closeOnClickOverlay?: boolean;
|
36
36
|
confirmButtonOpenType?: string;
|
37
37
|
value?: null | string;
|
38
|
+
ignoreQueue?: boolean;
|
38
39
|
password?: boolean;
|
39
40
|
placeholder?: string;
|
40
41
|
maxlength?: number;
|
@@ -47,7 +48,7 @@ interface DialogInputOptions extends DialogOptions {
|
|
47
48
|
maxlength?: number;
|
48
49
|
}
|
49
50
|
export declare const contextRef: {
|
50
|
-
value: DialogContext | null
|
51
|
+
value: Record<string, DialogContext | null>;
|
51
52
|
};
|
52
53
|
declare const Dialog: {
|
53
54
|
(options: DialogOptions): Promise<WechatMiniprogram.Component.TrivialInstance>;
|
package/dist/dialog/dialog.js
CHANGED
@@ -11,8 +11,6 @@ const defaultOptions = {
|
|
11
11
|
zIndex: 100,
|
12
12
|
overlay: true,
|
13
13
|
selector: '#smart-dialog',
|
14
|
-
// className: '',
|
15
|
-
// asyncClose: false,
|
16
14
|
beforeClose: null,
|
17
15
|
transition: 'scale',
|
18
16
|
customStyle: '',
|
@@ -25,6 +23,7 @@ const defaultOptions = {
|
|
25
23
|
closeOnClickOverlay: false,
|
26
24
|
confirmButtonOpenType: '',
|
27
25
|
icon: false,
|
26
|
+
ignoreQueue: false,
|
28
27
|
value: null,
|
29
28
|
password: false,
|
30
29
|
placeholder: '',
|
@@ -32,17 +31,18 @@ const defaultOptions = {
|
|
32
31
|
};
|
33
32
|
let currentOptions = Object.assign({}, defaultOptions);
|
34
33
|
export const contextRef = {
|
35
|
-
value:
|
34
|
+
value: {},
|
36
35
|
};
|
37
36
|
const Dialog = (options) => {
|
38
37
|
options = Object.assign(Object.assign({}, currentOptions), options);
|
39
38
|
return new Promise((resolve, reject) => {
|
40
39
|
const context = (typeof options.context === 'function' ? options.context() : options.context) ||
|
41
|
-
contextRef.value ||
|
40
|
+
contextRef.value[options.selector] ||
|
42
41
|
getCurrentPage();
|
43
42
|
const selector = options.selector;
|
44
43
|
const dialog = context.selectComponent(options.selector);
|
45
|
-
if (
|
44
|
+
if (!options.ignoreQueue &&
|
45
|
+
queueRef.value.length > 0 &&
|
46
46
|
queueRef.value.find(item => dialog && item && item.id === dialog.id)) {
|
47
47
|
console.warn(`相同选择器的 Dialog 调用过于频繁,${dialog.id} 已忽略重复调用`);
|
48
48
|
return;
|
package/dist/dialog/index.js
CHANGED
@@ -93,7 +93,14 @@ SmartComponent({
|
|
93
93
|
callback: (() => { }),
|
94
94
|
},
|
95
95
|
mounted: function () {
|
96
|
-
|
96
|
+
if (!this.id)
|
97
|
+
return;
|
98
|
+
contextRef.value[`#${this.id}`] = getCurrentPage();
|
99
|
+
},
|
100
|
+
destroyed: function () {
|
101
|
+
if (!this.id)
|
102
|
+
return;
|
103
|
+
contextRef.value[`#${this.id}`] = null;
|
97
104
|
},
|
98
105
|
methods: {
|
99
106
|
onConfirm() {
|
package/dist/toast/index.js
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
/*
|
2
|
+
* @Author: mjh
|
3
|
+
* @Date: 2025-02-14 16:33:01
|
4
|
+
* @LastEditors: mjh
|
5
|
+
* @LastEditTime: 2025-02-18 10:12:49
|
6
|
+
* @Description:
|
7
|
+
*/
|
1
8
|
import { Success, Alarm, Error } from './icons';
|
2
9
|
import { SmartComponent } from '../common/component';
|
3
10
|
import { contextRef } from './toast';
|
@@ -34,7 +41,14 @@ SmartComponent({
|
|
34
41
|
warn: Alarm,
|
35
42
|
},
|
36
43
|
mounted: function () {
|
37
|
-
|
44
|
+
if (!this.id)
|
45
|
+
return;
|
46
|
+
contextRef.value[`#${this.id}`] = getCurrentPage();
|
47
|
+
},
|
48
|
+
destroyed: function () {
|
49
|
+
if (!this.id)
|
50
|
+
return;
|
51
|
+
contextRef.value[`#${this.id}`] = null;
|
38
52
|
},
|
39
53
|
methods: {
|
40
54
|
// for prevent touchmove
|
package/dist/toast/toast.d.ts
CHANGED
@@ -12,13 +12,14 @@ interface ToastOptions {
|
|
12
12
|
duration?: number;
|
13
13
|
selector?: string;
|
14
14
|
forbidClick?: boolean;
|
15
|
+
ignoreQueue?: boolean;
|
15
16
|
loadingType?: string;
|
16
17
|
message?: ToastMessage;
|
17
18
|
onClose?: () => void;
|
18
19
|
width?: number;
|
19
20
|
}
|
20
21
|
export declare const contextRef: {
|
21
|
-
value: ToastContext | null
|
22
|
+
value: Record<string, ToastContext | null>;
|
22
23
|
};
|
23
24
|
declare function Toast(toastOptions: ToastOptions | ToastMessage): WechatMiniprogram.Component.TrivialInstance | undefined;
|
24
25
|
declare namespace Toast {
|
package/dist/toast/toast.js
CHANGED
@@ -7,6 +7,7 @@ const defaultOptions = {
|
|
7
7
|
show: true,
|
8
8
|
zIndex: 1000,
|
9
9
|
duration: 2000,
|
10
|
+
ignoreQueue: false,
|
10
11
|
position: 'middle',
|
11
12
|
forbidClick: false,
|
12
13
|
loadingType: 'circular',
|
@@ -22,12 +23,12 @@ function parseOptions(message) {
|
|
22
23
|
return isObj(message) ? message : { message };
|
23
24
|
}
|
24
25
|
export const contextRef = {
|
25
|
-
value:
|
26
|
+
value: {},
|
26
27
|
};
|
27
28
|
function Toast(toastOptions) {
|
28
29
|
const options = Object.assign(Object.assign({}, currentOptions), parseOptions(toastOptions));
|
29
30
|
const context = (typeof options.context === 'function' ? options.context() : options.context) ||
|
30
|
-
contextRef.value ||
|
31
|
+
contextRef.value[options.selector] ||
|
31
32
|
getCurrentPage();
|
32
33
|
const toast = context.selectComponent(options.selector);
|
33
34
|
if (!toast) {
|
package/lib/dialog/dialog.d.ts
CHANGED
@@ -35,6 +35,7 @@ interface DialogOptions {
|
|
35
35
|
closeOnClickOverlay?: boolean;
|
36
36
|
confirmButtonOpenType?: string;
|
37
37
|
value?: null | string;
|
38
|
+
ignoreQueue?: boolean;
|
38
39
|
password?: boolean;
|
39
40
|
placeholder?: string;
|
40
41
|
maxlength?: number;
|
@@ -47,7 +48,7 @@ interface DialogInputOptions extends DialogOptions {
|
|
47
48
|
maxlength?: number;
|
48
49
|
}
|
49
50
|
export declare const contextRef: {
|
50
|
-
value: DialogContext | null
|
51
|
+
value: Record<string, DialogContext | null>;
|
51
52
|
};
|
52
53
|
declare const Dialog: {
|
53
54
|
(options: DialogOptions): Promise<WechatMiniprogram.Component.TrivialInstance>;
|
package/lib/dialog/dialog.js
CHANGED
@@ -25,8 +25,6 @@ var defaultOptions = {
|
|
25
25
|
zIndex: 100,
|
26
26
|
overlay: true,
|
27
27
|
selector: '#smart-dialog',
|
28
|
-
// className: '',
|
29
|
-
// asyncClose: false,
|
30
28
|
beforeClose: null,
|
31
29
|
transition: 'scale',
|
32
30
|
customStyle: '',
|
@@ -39,6 +37,7 @@ var defaultOptions = {
|
|
39
37
|
closeOnClickOverlay: false,
|
40
38
|
confirmButtonOpenType: '',
|
41
39
|
icon: false,
|
40
|
+
ignoreQueue: false,
|
42
41
|
value: null,
|
43
42
|
password: false,
|
44
43
|
placeholder: '',
|
@@ -46,17 +45,18 @@ var defaultOptions = {
|
|
46
45
|
};
|
47
46
|
var currentOptions = __assign({}, defaultOptions);
|
48
47
|
exports.contextRef = {
|
49
|
-
value:
|
48
|
+
value: {},
|
50
49
|
};
|
51
50
|
var Dialog = function (options) {
|
52
51
|
options = __assign(__assign({}, currentOptions), options);
|
53
52
|
return new Promise(function (resolve, reject) {
|
54
53
|
var context = (typeof options.context === 'function' ? options.context() : options.context) ||
|
55
|
-
exports.contextRef.value ||
|
54
|
+
exports.contextRef.value[options.selector] ||
|
56
55
|
(0, utils_1.getCurrentPage)();
|
57
56
|
var selector = options.selector;
|
58
57
|
var dialog = context.selectComponent(options.selector);
|
59
|
-
if (
|
58
|
+
if (!options.ignoreQueue &&
|
59
|
+
queueRef.value.length > 0 &&
|
60
60
|
queueRef.value.find(function (item) { return dialog && item && item.id === dialog.id; })) {
|
61
61
|
console.warn("\u76F8\u540C\u9009\u62E9\u5668\u7684 Dialog \u8C03\u7528\u8FC7\u4E8E\u9891\u7E41\uFF0C".concat(dialog.id, " \u5DF2\u5FFD\u7565\u91CD\u590D\u8C03\u7528"));
|
62
62
|
return;
|
package/lib/dialog/index.js
CHANGED
@@ -98,7 +98,14 @@ var dialog_1 = require("./dialog");
|
|
98
98
|
callback: (function () { }),
|
99
99
|
},
|
100
100
|
mounted: function () {
|
101
|
-
|
101
|
+
if (!this.id)
|
102
|
+
return;
|
103
|
+
dialog_1.contextRef.value["#".concat(this.id)] = (0, utils_1.getCurrentPage)();
|
104
|
+
},
|
105
|
+
destroyed: function () {
|
106
|
+
if (!this.id)
|
107
|
+
return;
|
108
|
+
dialog_1.contextRef.value["#".concat(this.id)] = null;
|
102
109
|
},
|
103
110
|
methods: {
|
104
111
|
onConfirm: function () {
|
package/lib/toast/index.js
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
/*
|
4
|
+
* @Author: mjh
|
5
|
+
* @Date: 2025-02-14 16:33:01
|
6
|
+
* @LastEditors: mjh
|
7
|
+
* @LastEditTime: 2025-02-18 10:12:49
|
8
|
+
* @Description:
|
9
|
+
*/
|
3
10
|
var icons_1 = require("./icons");
|
4
11
|
var component_1 = require("../common/component");
|
5
12
|
var toast_1 = require("./toast");
|
@@ -36,7 +43,14 @@ var utils_1 = require("../common/utils");
|
|
36
43
|
warn: icons_1.Alarm,
|
37
44
|
},
|
38
45
|
mounted: function () {
|
39
|
-
|
46
|
+
if (!this.id)
|
47
|
+
return;
|
48
|
+
toast_1.contextRef.value["#".concat(this.id)] = (0, utils_1.getCurrentPage)();
|
49
|
+
},
|
50
|
+
destroyed: function () {
|
51
|
+
if (!this.id)
|
52
|
+
return;
|
53
|
+
toast_1.contextRef.value["#".concat(this.id)] = null;
|
40
54
|
},
|
41
55
|
methods: {
|
42
56
|
// for prevent touchmove
|
package/lib/toast/toast.d.ts
CHANGED
@@ -12,13 +12,14 @@ interface ToastOptions {
|
|
12
12
|
duration?: number;
|
13
13
|
selector?: string;
|
14
14
|
forbidClick?: boolean;
|
15
|
+
ignoreQueue?: boolean;
|
15
16
|
loadingType?: string;
|
16
17
|
message?: ToastMessage;
|
17
18
|
onClose?: () => void;
|
18
19
|
width?: number;
|
19
20
|
}
|
20
21
|
export declare const contextRef: {
|
21
|
-
value: ToastContext | null
|
22
|
+
value: Record<string, ToastContext | null>;
|
22
23
|
};
|
23
24
|
declare function Toast(toastOptions: ToastOptions | ToastMessage): WechatMiniprogram.Component.TrivialInstance | undefined;
|
24
25
|
declare namespace Toast {
|
package/lib/toast/toast.js
CHANGED
@@ -21,6 +21,7 @@ var defaultOptions = {
|
|
21
21
|
show: true,
|
22
22
|
zIndex: 1000,
|
23
23
|
duration: 2000,
|
24
|
+
ignoreQueue: false,
|
24
25
|
position: 'middle',
|
25
26
|
forbidClick: false,
|
26
27
|
loadingType: 'circular',
|
@@ -36,12 +37,12 @@ function parseOptions(message) {
|
|
36
37
|
return (0, validator_1.isObj)(message) ? message : { message: message };
|
37
38
|
}
|
38
39
|
exports.contextRef = {
|
39
|
-
value:
|
40
|
+
value: {},
|
40
41
|
};
|
41
42
|
function Toast(toastOptions) {
|
42
43
|
var options = __assign(__assign({}, currentOptions), parseOptions(toastOptions));
|
43
44
|
var context = (typeof options.context === 'function' ? options.context() : options.context) ||
|
44
|
-
exports.contextRef.value ||
|
45
|
+
exports.contextRef.value[options.selector] ||
|
45
46
|
(0, utils_1.getCurrentPage)();
|
46
47
|
var toast = context.selectComponent(options.selector);
|
47
48
|
if (!toast) {
|