@tuya-miniapp/smart-ui 2.8.0 → 2.8.1-beta-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.
@@ -1,5 +1,8 @@
1
1
  /// <reference types="miniprogram-api-typings" />
2
2
  /// <reference types="miniprogram-api-typings" />
3
+ export declare const queueRef: {
4
+ value: WechatMiniprogram.Component.TrivialInstance[];
5
+ };
3
6
  export type Action = 'confirm' | 'cancel' | 'overlay';
4
7
  type DialogContext = WechatMiniprogram.Page.TrivialInstance | WechatMiniprogram.Component.TrivialInstance;
5
8
  type AnyObject = {};
@@ -1,6 +1,6 @@
1
1
  import appLog from '../common/appLog';
2
2
  import { getCurrentPage } from '../common/utils';
3
- const queueRef = {
3
+ export const queueRef = {
4
4
  value: [],
5
5
  };
6
6
  const defaultOptions = {
@@ -3,7 +3,7 @@ import { SmartComponent } from '../common/component';
3
3
  import { button } from '../mixins/button';
4
4
  import appLog from '../common/appLog';
5
5
  import { getCurrentPage, toPromise } from '../common/utils';
6
- import { contextRef } from './dialog';
6
+ import { contextRef, queueRef } from './dialog';
7
7
  SmartComponent({
8
8
  mixins: [button],
9
9
  classes: ['cancle-button-class', 'confirm-button-class'],
@@ -118,6 +118,7 @@ SmartComponent({
118
118
  if (!this.id)
119
119
  return;
120
120
  contextRef.value[`#${this.id}`] = null;
121
+ queueRef.value = queueRef.value.filter(item => item.id !== this.id);
121
122
  appLog.info(`dialog #${this.id} destroyed`);
122
123
  },
123
124
  methods: {
@@ -1,5 +1,8 @@
1
1
  /// <reference types="miniprogram-api-typings" />
2
2
  /// <reference types="miniprogram-api-typings" />
3
+ export declare const queueRef: {
4
+ value: WechatMiniprogram.Component.TrivialInstance[];
5
+ };
3
6
  export type Action = 'confirm' | 'cancel' | 'overlay';
4
7
  type DialogContext = WechatMiniprogram.Page.TrivialInstance | WechatMiniprogram.Component.TrivialInstance;
5
8
  type AnyObject = {};
@@ -14,10 +14,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.contextRef = void 0;
17
+ exports.contextRef = exports.queueRef = void 0;
18
18
  var appLog_1 = __importDefault(require("../common/appLog"));
19
19
  var utils_1 = require("../common/utils");
20
- var queueRef = {
20
+ exports.queueRef = {
21
21
  value: [],
22
22
  };
23
23
  var defaultOptions = {
@@ -62,12 +62,12 @@ var Dialog = function (options) {
62
62
  (0, utils_1.getCurrentPage)();
63
63
  var selector = options.selector;
64
64
  appLog_1.default.info("dialog selector: ".concat(selector));
65
- appLog_1.default.info("queue : ".concat(JSON.stringify(queueRef.value)));
65
+ appLog_1.default.info("queue : ".concat(JSON.stringify(exports.queueRef.value)));
66
66
  var dialog = context.selectComponent(options.selector);
67
67
  appLog_1.default.info("dialog component ".concat(dialog ? 'success' : 'fail'));
68
68
  if (!options.ignoreQueue &&
69
- queueRef.value.length > 0 &&
70
- queueRef.value.find(function (item) { return dialog && item && item.id === dialog.id; })) {
69
+ exports.queueRef.value.length > 0 &&
70
+ exports.queueRef.value.find(function (item) { return dialog && item && item.id === dialog.id; })) {
71
71
  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"));
72
72
  appLog_1.default.info("\u76F8\u540C\u9009\u62E9\u5668\u7684 Dialog \u8C03\u7528\u8FC7\u4E8E\u9891\u7E41\uFF0C".concat(dialog.id, " \u5DF2\u5FFD\u7565\u91CD\u590D\u8C03\u7528"));
73
73
  return;
@@ -83,7 +83,7 @@ var Dialog = function (options) {
83
83
  /**
84
84
  * 在声明式调用的情况下,在 close 后需要手动清空队列
85
85
  */
86
- queueRef.value = queueRef.value.filter(function (item) { return item.id !== dialog.id; });
86
+ exports.queueRef.value = exports.queueRef.value.filter(function (item) { return item.id !== dialog.id; });
87
87
  action === 'confirm' ? resolve(instance) : reject(instance);
88
88
  appLog_1.default.info("dialog ".concat(dialog.id, " callback"));
89
89
  } }, optionsWithInputValue));
@@ -91,7 +91,7 @@ var Dialog = function (options) {
91
91
  appLog_1.default.info("start open dialog ".concat(dialog.id));
92
92
  dialog.setData({ show: true });
93
93
  });
94
- queueRef.value.push(dialog);
94
+ exports.queueRef.value.push(dialog);
95
95
  }
96
96
  else {
97
97
  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"));
@@ -101,7 +101,7 @@ var Dialog = function (options) {
101
101
  prom.catch(function (err) {
102
102
  appLog_1.default.info("Dialog promise Error", err);
103
103
  console.log(err, '---Dialog-error');
104
- queueRef.value = [];
104
+ exports.queueRef.value = [];
105
105
  });
106
106
  return prom;
107
107
  };
@@ -113,13 +113,13 @@ Dialog.input = (function (options) {
113
113
  return Dialog(__assign({ showCancelButton: true }, options));
114
114
  });
115
115
  Dialog.close = function () {
116
- queueRef.value.forEach(function (dialog) {
116
+ exports.queueRef.value.forEach(function (dialog) {
117
117
  dialog.close();
118
118
  });
119
- queueRef.value = [];
119
+ exports.queueRef.value = [];
120
120
  };
121
121
  Dialog.stopLoading = function () {
122
- queueRef.value.forEach(function (dialog) {
122
+ exports.queueRef.value.forEach(function (dialog) {
123
123
  dialog.stopLoading();
124
124
  });
125
125
  };
@@ -120,9 +120,11 @@ var dialog_1 = require("./dialog");
120
120
  appLog_1.default.info("Dialog #".concat(this.id, " mounted"));
121
121
  },
122
122
  destroyed: function () {
123
+ var _this = this;
123
124
  if (!this.id)
124
125
  return;
125
126
  dialog_1.contextRef.value["#".concat(this.id)] = null;
127
+ dialog_1.queueRef.value = dialog_1.queueRef.value.filter(function (item) { return item.id !== _this.id; });
126
128
  appLog_1.default.info("dialog #".concat(this.id, " destroyed"));
127
129
  },
128
130
  methods: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-miniapp/smart-ui",
3
- "version": "2.8.0",
3
+ "version": "2.8.1-beta-0",
4
4
  "author": "MiniApp Team",
5
5
  "license": "MIT",
6
6
  "miniprogram": "lib",