@tuya-miniapp/smart-ui 2.10.0-beta-1 → 2.10.0

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.
@@ -22,25 +22,19 @@ SmartComponent({
22
22
  type: String,
23
23
  value: 'right',
24
24
  },
25
- isControl: {
26
- type: Boolean,
27
- value: false,
28
- },
29
25
  show: {
30
- type: null,
26
+ type: Boolean,
31
27
  observer(value) {
32
- // 动态设置受控模式:如果 show 有值(不是 undefined 或 null),则为受控模式
33
- // 如果 show 为 undefined 或 null,则为非受控模式
34
28
  if (this.data.cancel_timer) {
35
29
  clearTimeout(this.data.cancel_timer);
36
30
  this.data.cancel_timer = null;
37
31
  }
38
- if (value !== this.data.currentShow || this.data.isControl) {
32
+ if (value !== this.data.currentShow) {
39
33
  if (value) {
40
- this.onOpen(!this.data.isControl);
34
+ this.onOpen();
41
35
  }
42
36
  else {
43
- this.onClose(!this.data.isControl);
37
+ this.onClose();
44
38
  }
45
39
  }
46
40
  },
@@ -175,18 +169,10 @@ SmartComponent({
175
169
  this.setData(params);
176
170
  },
177
171
  onClick() {
178
- if (this.data.isControl) {
179
- // 受控模式下,不触发 show-change 事件,由外部控制
180
- return;
181
- }
182
- // 非受控模式下,如果 show 为 false,则不打开
183
- if (this.data.show === false) {
184
- return;
185
- }
186
172
  this.onOpen();
187
173
  },
188
174
  noop() { },
189
- onOpen(trigger = true) {
175
+ onOpen() {
190
176
  this.getButtonPosition();
191
177
  this.setData({
192
178
  currentShow: true,
@@ -196,14 +182,14 @@ SmartComponent({
196
182
  showStyle: 'opacity: 1;',
197
183
  });
198
184
  }, 100);
199
- trigger && this.$emit('show-change', true);
185
+ this.$emit('show-change', true);
200
186
  if (this.data.duration) {
201
187
  this.data.cancel_timer = setTimeout(() => {
202
- this.onClose(trigger);
188
+ this.onClose();
203
189
  }, this.data.duration);
204
190
  }
205
191
  },
206
- onClose(trigger = true) {
192
+ onClose() {
207
193
  if (this.data.cancel_timer) {
208
194
  clearTimeout(this.data.cancel_timer);
209
195
  this.data.cancel_timer = null;
@@ -215,8 +201,8 @@ SmartComponent({
215
201
  this.setData({
216
202
  currentShow: false,
217
203
  });
218
- trigger && this.$emit('show-change', false);
219
- trigger && this.$emit('close', false);
204
+ this.$emit('show-change', false);
205
+ this.$emit('close', false);
220
206
  }, 300);
221
207
  },
222
208
  },
@@ -35,25 +35,19 @@ function createSvgIcon(svg) {
35
35
  type: String,
36
36
  value: 'right',
37
37
  },
38
- isControl: {
39
- type: Boolean,
40
- value: false,
41
- },
42
38
  show: {
43
- type: null,
39
+ type: Boolean,
44
40
  observer: function (value) {
45
- // 动态设置受控模式:如果 show 有值(不是 undefined 或 null),则为受控模式
46
- // 如果 show 为 undefined 或 null,则为非受控模式
47
41
  if (this.data.cancel_timer) {
48
42
  clearTimeout(this.data.cancel_timer);
49
43
  this.data.cancel_timer = null;
50
44
  }
51
- if (value !== this.data.currentShow || this.data.isControl) {
45
+ if (value !== this.data.currentShow) {
52
46
  if (value) {
53
- this.onOpen(!this.data.isControl);
47
+ this.onOpen();
54
48
  }
55
49
  else {
56
- this.onClose(!this.data.isControl);
50
+ this.onClose();
57
51
  }
58
52
  }
59
53
  },
@@ -188,20 +182,11 @@ function createSvgIcon(svg) {
188
182
  this.setData(params);
189
183
  },
190
184
  onClick: function () {
191
- if (this.data.isControl) {
192
- // 受控模式下,不触发 show-change 事件,由外部控制
193
- return;
194
- }
195
- // 非受控模式下,如果 show 为 false,则不打开
196
- if (this.data.show === false) {
197
- return;
198
- }
199
185
  this.onOpen();
200
186
  },
201
187
  noop: function () { },
202
- onOpen: function (trigger) {
188
+ onOpen: function () {
203
189
  var _this = this;
204
- if (trigger === void 0) { trigger = true; }
205
190
  this.getButtonPosition();
206
191
  this.setData({
207
192
  currentShow: true,
@@ -211,16 +196,15 @@ function createSvgIcon(svg) {
211
196
  showStyle: 'opacity: 1;',
212
197
  });
213
198
  }, 100);
214
- trigger && this.$emit('show-change', true);
199
+ this.$emit('show-change', true);
215
200
  if (this.data.duration) {
216
201
  this.data.cancel_timer = setTimeout(function () {
217
- _this.onClose(trigger);
202
+ _this.onClose();
218
203
  }, this.data.duration);
219
204
  }
220
205
  },
221
- onClose: function (trigger) {
206
+ onClose: function () {
222
207
  var _this = this;
223
- if (trigger === void 0) { trigger = true; }
224
208
  if (this.data.cancel_timer) {
225
209
  clearTimeout(this.data.cancel_timer);
226
210
  this.data.cancel_timer = null;
@@ -232,8 +216,8 @@ function createSvgIcon(svg) {
232
216
  _this.setData({
233
217
  currentShow: false,
234
218
  });
235
- trigger && _this.$emit('show-change', false);
236
- trigger && _this.$emit('close', false);
219
+ _this.$emit('show-change', false);
220
+ _this.$emit('close', false);
237
221
  }, 300);
238
222
  },
239
223
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-miniapp/smart-ui",
3
- "version": "2.10.0-beta-1",
3
+ "version": "2.10.0",
4
4
  "author": "MiniApp Team",
5
5
  "license": "MIT",
6
6
  "miniprogram": "lib",