@tuya-miniapp/smart-ui 2.1.11-beta-5 → 2.1.11-beta-7
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.js +10 -8
- package/dist/dialog/index.js +29 -4
- package/dist/dialog/index.wxml +6 -0
- package/dist/mixins/transition.js +11 -2
- package/dist/tabbar/index.wxml +2 -2
- package/lib/dialog/dialog.js +10 -8
- package/lib/dialog/index.js +29 -4
- package/lib/dialog/index.wxml +6 -0
- package/lib/mixins/transition.js +11 -2
- package/lib/tabbar/index.wxml +2 -2
- package/package.json +1 -1
package/dist/dialog/dialog.js
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
import { getCurrentPage } from '../common/utils';
|
2
|
-
|
2
|
+
const queueRef = {
|
3
|
+
value: [],
|
4
|
+
};
|
3
5
|
const defaultOptions = {
|
4
6
|
show: false,
|
5
7
|
title: '',
|
@@ -35,13 +37,13 @@ export const contextRef = {
|
|
35
37
|
const Dialog = (options) => {
|
36
38
|
options = Object.assign(Object.assign({}, currentOptions), options);
|
37
39
|
return new Promise((resolve, reject) => {
|
38
|
-
var _a;
|
39
40
|
const context = (typeof options.context === 'function' ? options.context() : options.context) ||
|
40
41
|
contextRef.value ||
|
41
42
|
getCurrentPage();
|
42
43
|
const selector = options.selector;
|
43
44
|
const dialog = context.selectComponent(options.selector);
|
44
|
-
if (
|
45
|
+
if (queueRef.value.length > 0 &&
|
46
|
+
queueRef.value.find(item => dialog && item && item.id === dialog.id)) {
|
45
47
|
console.warn(`相同选择器的 Dialog 调用过于频繁,${dialog.id} 已忽略重复调用`);
|
46
48
|
return;
|
47
49
|
}
|
@@ -56,13 +58,13 @@ const Dialog = (options) => {
|
|
56
58
|
/**
|
57
59
|
* 在声明式调用的情况下,在 close 后需要手动清空队列
|
58
60
|
*/
|
59
|
-
|
61
|
+
queueRef.value = queueRef.value.filter(item => item.id !== dialog.id);
|
60
62
|
action === 'confirm' ? resolve(instance) : reject(instance);
|
61
63
|
} }, optionsWithInputValue));
|
62
64
|
wx.nextTick(() => {
|
63
65
|
dialog.setData({ show: true });
|
64
66
|
});
|
65
|
-
|
67
|
+
queueRef.value.push(dialog);
|
66
68
|
}
|
67
69
|
else {
|
68
70
|
console.warn(`未找到 ${(selector !== null && selector !== void 0 ? selector : '#smart-dialog').replace('#', '')} 节点,请确认 selector 及 context 是否正确`);
|
@@ -73,13 +75,13 @@ Dialog.alert = (options) => Dialog(options);
|
|
73
75
|
Dialog.confirm = (options) => Dialog(Object.assign({ showCancelButton: true }, options));
|
74
76
|
Dialog.input = ((options) => Dialog(Object.assign({ showCancelButton: true }, options)));
|
75
77
|
Dialog.close = () => {
|
76
|
-
|
78
|
+
queueRef.value.forEach(dialog => {
|
77
79
|
dialog.close();
|
78
80
|
});
|
79
|
-
|
81
|
+
queueRef.value = [];
|
80
82
|
};
|
81
83
|
Dialog.stopLoading = () => {
|
82
|
-
|
84
|
+
queueRef.value.forEach(dialog => {
|
83
85
|
dialog.stopLoading();
|
84
86
|
});
|
85
87
|
};
|
package/dist/dialog/index.js
CHANGED
@@ -89,6 +89,7 @@ SmartComponent({
|
|
89
89
|
confirm: false,
|
90
90
|
cancel: false,
|
91
91
|
},
|
92
|
+
actionType: '',
|
92
93
|
callback: (() => { }),
|
93
94
|
},
|
94
95
|
mounted: function () {
|
@@ -110,12 +111,14 @@ SmartComponent({
|
|
110
111
|
},
|
111
112
|
close(action) {
|
112
113
|
this.setData({ show: false });
|
114
|
+
this.setData({ actionType: action });
|
113
115
|
wx.nextTick(() => {
|
114
116
|
this.$emit('close', action);
|
115
|
-
const { callback } = this.data;
|
116
|
-
|
117
|
-
|
118
|
-
|
117
|
+
// const { callback } = this.data;
|
118
|
+
// console.log(callback, 'close');
|
119
|
+
// if (callback) {
|
120
|
+
// callback(action, this);
|
121
|
+
// }
|
119
122
|
});
|
120
123
|
},
|
121
124
|
stopLoading() {
|
@@ -151,5 +154,27 @@ SmartComponent({
|
|
151
154
|
});
|
152
155
|
}
|
153
156
|
},
|
157
|
+
onBeforeEnter() {
|
158
|
+
this.$emit('before-enter');
|
159
|
+
},
|
160
|
+
onEnter() {
|
161
|
+
this.$emit('enter');
|
162
|
+
},
|
163
|
+
onAfterEnter() {
|
164
|
+
this.$emit('after-enter');
|
165
|
+
},
|
166
|
+
onBeforeLeave() {
|
167
|
+
this.$emit('before-leave');
|
168
|
+
},
|
169
|
+
onLeave() {
|
170
|
+
this.$emit('leave');
|
171
|
+
},
|
172
|
+
onAfterLeave() {
|
173
|
+
this.$emit('after-leave');
|
174
|
+
const { callback, actionType } = this.data;
|
175
|
+
if (callback) {
|
176
|
+
callback(actionType, this);
|
177
|
+
}
|
178
|
+
},
|
154
179
|
},
|
155
180
|
});
|
package/dist/dialog/index.wxml
CHANGED
@@ -11,6 +11,12 @@
|
|
11
11
|
close-on-click-overlay="{{ closeOnClickOverlay }}"
|
12
12
|
root-portal="{{ rootPortal }}"
|
13
13
|
bind:close="onClickOverlay"
|
14
|
+
bind:before-enter="onBeforeEnter"
|
15
|
+
bind:enter="onEnter"
|
16
|
+
bind:after-enter="onAfterEnter"
|
17
|
+
bind:before-leave="onBeforeLeave"
|
18
|
+
bind:leave="onLeave"
|
19
|
+
bind:after-leave="onAfterLeave"
|
14
20
|
>
|
15
21
|
<view
|
16
22
|
wx:if="{{ title || useTitleSlot }}"
|
@@ -77,11 +77,16 @@ export function transition(showDefaultValue) {
|
|
77
77
|
});
|
78
78
|
});
|
79
79
|
});
|
80
|
+
this.enterFinishedPromise.catch(err => {
|
81
|
+
this.enterFinishedPromise = null;
|
82
|
+
console.log(err, '---error');
|
83
|
+
});
|
80
84
|
},
|
81
85
|
leave() {
|
82
86
|
if (!this.enterFinishedPromise)
|
83
87
|
return;
|
84
|
-
this.enterFinishedPromise
|
88
|
+
this.enterFinishedPromise
|
89
|
+
.then(() => {
|
85
90
|
if (!this.data.display) {
|
86
91
|
return;
|
87
92
|
}
|
@@ -105,12 +110,16 @@ export function transition(showDefaultValue) {
|
|
105
110
|
}
|
106
111
|
this.transitionEnded = false;
|
107
112
|
setTimeout(() => {
|
108
|
-
this.onTransitionEnd();
|
109
113
|
this.enterFinishedPromise = null;
|
114
|
+
this.onTransitionEnd();
|
110
115
|
}, currentDuration);
|
111
116
|
this.setData({ classes: classNames['leave-to'] });
|
112
117
|
});
|
113
118
|
});
|
119
|
+
})
|
120
|
+
.catch(err => {
|
121
|
+
this.enterFinishedPromise = null;
|
122
|
+
console.log(err, '---error');
|
114
123
|
});
|
115
124
|
},
|
116
125
|
onTransitionEnd() {
|
package/dist/tabbar/index.wxml
CHANGED
@@ -4,9 +4,9 @@
|
|
4
4
|
class="{{ utils.bem('tabbar', { border: true }) }} {{ utils.bem('tabbar', { fixed, safe: safeAreaInsetBottom }) }} custom-class"
|
5
5
|
style="{{ zIndex ? 'z-index: ' + zIndex : '' }}"
|
6
6
|
>
|
7
|
-
<slot name="
|
7
|
+
<slot name="left" />
|
8
8
|
<slot />
|
9
|
-
<slot name="
|
9
|
+
<slot name="right" />
|
10
10
|
</view>
|
11
11
|
|
12
12
|
<view wx:if="{{ fixed && placeholder }}" style="height: {{ height }}px;"></view>
|
package/lib/dialog/dialog.js
CHANGED
@@ -13,7 +13,9 @@ var __assign = (this && this.__assign) || function () {
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
14
14
|
exports.contextRef = void 0;
|
15
15
|
var utils_1 = require("../common/utils");
|
16
|
-
var
|
16
|
+
var queueRef = {
|
17
|
+
value: [],
|
18
|
+
};
|
17
19
|
var defaultOptions = {
|
18
20
|
show: false,
|
19
21
|
title: '',
|
@@ -49,13 +51,13 @@ exports.contextRef = {
|
|
49
51
|
var Dialog = function (options) {
|
50
52
|
options = __assign(__assign({}, currentOptions), options);
|
51
53
|
return new Promise(function (resolve, reject) {
|
52
|
-
var _a;
|
53
54
|
var context = (typeof options.context === 'function' ? options.context() : options.context) ||
|
54
55
|
exports.contextRef.value ||
|
55
56
|
(0, utils_1.getCurrentPage)();
|
56
57
|
var selector = options.selector;
|
57
58
|
var dialog = context.selectComponent(options.selector);
|
58
|
-
if (
|
59
|
+
if (queueRef.value.length > 0 &&
|
60
|
+
queueRef.value.find(function (item) { return dialog && item && item.id === dialog.id; })) {
|
59
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"));
|
60
62
|
return;
|
61
63
|
}
|
@@ -70,13 +72,13 @@ var Dialog = function (options) {
|
|
70
72
|
/**
|
71
73
|
* 在声明式调用的情况下,在 close 后需要手动清空队列
|
72
74
|
*/
|
73
|
-
|
75
|
+
queueRef.value = queueRef.value.filter(function (item) { return item.id !== dialog.id; });
|
74
76
|
action === 'confirm' ? resolve(instance) : reject(instance);
|
75
77
|
} }, optionsWithInputValue));
|
76
78
|
wx.nextTick(function () {
|
77
79
|
dialog.setData({ show: true });
|
78
80
|
});
|
79
|
-
|
81
|
+
queueRef.value.push(dialog);
|
80
82
|
}
|
81
83
|
else {
|
82
84
|
console.warn("\u672A\u627E\u5230 ".concat((selector !== null && selector !== void 0 ? selector : '#smart-dialog').replace('#', ''), " \u8282\u70B9\uFF0C\u8BF7\u786E\u8BA4 selector \u53CA context \u662F\u5426\u6B63\u786E"));
|
@@ -91,13 +93,13 @@ Dialog.input = (function (options) {
|
|
91
93
|
return Dialog(__assign({ showCancelButton: true }, options));
|
92
94
|
});
|
93
95
|
Dialog.close = function () {
|
94
|
-
|
96
|
+
queueRef.value.forEach(function (dialog) {
|
95
97
|
dialog.close();
|
96
98
|
});
|
97
|
-
|
99
|
+
queueRef.value = [];
|
98
100
|
};
|
99
101
|
Dialog.stopLoading = function () {
|
100
|
-
|
102
|
+
queueRef.value.forEach(function (dialog) {
|
101
103
|
dialog.stopLoading();
|
102
104
|
});
|
103
105
|
};
|
package/lib/dialog/index.js
CHANGED
@@ -94,6 +94,7 @@ var dialog_1 = require("./dialog");
|
|
94
94
|
confirm: false,
|
95
95
|
cancel: false,
|
96
96
|
},
|
97
|
+
actionType: '',
|
97
98
|
callback: (function () { }),
|
98
99
|
},
|
99
100
|
mounted: function () {
|
@@ -116,12 +117,14 @@ var dialog_1 = require("./dialog");
|
|
116
117
|
close: function (action) {
|
117
118
|
var _this = this;
|
118
119
|
this.setData({ show: false });
|
120
|
+
this.setData({ actionType: action });
|
119
121
|
wx.nextTick(function () {
|
120
122
|
_this.$emit('close', action);
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
123
|
+
// const { callback } = this.data;
|
124
|
+
// console.log(callback, 'close');
|
125
|
+
// if (callback) {
|
126
|
+
// callback(action, this);
|
127
|
+
// }
|
125
128
|
});
|
126
129
|
},
|
127
130
|
stopLoading: function () {
|
@@ -159,5 +162,27 @@ var dialog_1 = require("./dialog");
|
|
159
162
|
});
|
160
163
|
}
|
161
164
|
},
|
165
|
+
onBeforeEnter: function () {
|
166
|
+
this.$emit('before-enter');
|
167
|
+
},
|
168
|
+
onEnter: function () {
|
169
|
+
this.$emit('enter');
|
170
|
+
},
|
171
|
+
onAfterEnter: function () {
|
172
|
+
this.$emit('after-enter');
|
173
|
+
},
|
174
|
+
onBeforeLeave: function () {
|
175
|
+
this.$emit('before-leave');
|
176
|
+
},
|
177
|
+
onLeave: function () {
|
178
|
+
this.$emit('leave');
|
179
|
+
},
|
180
|
+
onAfterLeave: function () {
|
181
|
+
this.$emit('after-leave');
|
182
|
+
var _a = this.data, callback = _a.callback, actionType = _a.actionType;
|
183
|
+
if (callback) {
|
184
|
+
callback(actionType, this);
|
185
|
+
}
|
186
|
+
},
|
162
187
|
},
|
163
188
|
});
|
package/lib/dialog/index.wxml
CHANGED
@@ -11,6 +11,12 @@
|
|
11
11
|
close-on-click-overlay="{{ closeOnClickOverlay }}"
|
12
12
|
root-portal="{{ rootPortal }}"
|
13
13
|
bind:close="onClickOverlay"
|
14
|
+
bind:before-enter="onBeforeEnter"
|
15
|
+
bind:enter="onEnter"
|
16
|
+
bind:after-enter="onAfterEnter"
|
17
|
+
bind:before-leave="onBeforeLeave"
|
18
|
+
bind:leave="onLeave"
|
19
|
+
bind:after-leave="onAfterLeave"
|
14
20
|
>
|
15
21
|
<view
|
16
22
|
wx:if="{{ title || useTitleSlot }}"
|
package/lib/mixins/transition.js
CHANGED
@@ -81,12 +81,17 @@ function transition(showDefaultValue) {
|
|
81
81
|
});
|
82
82
|
});
|
83
83
|
});
|
84
|
+
this.enterFinishedPromise.catch(function (err) {
|
85
|
+
_this.enterFinishedPromise = null;
|
86
|
+
console.log(err, '---error');
|
87
|
+
});
|
84
88
|
},
|
85
89
|
leave: function () {
|
86
90
|
var _this = this;
|
87
91
|
if (!this.enterFinishedPromise)
|
88
92
|
return;
|
89
|
-
this.enterFinishedPromise
|
93
|
+
this.enterFinishedPromise
|
94
|
+
.then(function () {
|
90
95
|
if (!_this.data.display) {
|
91
96
|
return;
|
92
97
|
}
|
@@ -110,12 +115,16 @@ function transition(showDefaultValue) {
|
|
110
115
|
}
|
111
116
|
_this.transitionEnded = false;
|
112
117
|
setTimeout(function () {
|
113
|
-
_this.onTransitionEnd();
|
114
118
|
_this.enterFinishedPromise = null;
|
119
|
+
_this.onTransitionEnd();
|
115
120
|
}, currentDuration);
|
116
121
|
_this.setData({ classes: classNames['leave-to'] });
|
117
122
|
});
|
118
123
|
});
|
124
|
+
})
|
125
|
+
.catch(function (err) {
|
126
|
+
_this.enterFinishedPromise = null;
|
127
|
+
console.log(err, '---error');
|
119
128
|
});
|
120
129
|
},
|
121
130
|
onTransitionEnd: function () {
|
package/lib/tabbar/index.wxml
CHANGED
@@ -4,9 +4,9 @@
|
|
4
4
|
class="{{ utils.bem('tabbar', { border: true }) }} {{ utils.bem('tabbar', { fixed, safe: safeAreaInsetBottom }) }} custom-class"
|
5
5
|
style="{{ zIndex ? 'z-index: ' + zIndex : '' }}"
|
6
6
|
>
|
7
|
-
<slot name="
|
7
|
+
<slot name="left" />
|
8
8
|
<slot />
|
9
|
-
<slot name="
|
9
|
+
<slot name="right" />
|
10
10
|
</view>
|
11
11
|
|
12
12
|
<view wx:if="{{ fixed && placeholder }}" style="height: {{ height }}px;"></view>
|