@tuya-miniapp/smart-ui 2.2.0 → 2.2.1-beta-1

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.
@@ -47,7 +47,7 @@ interface DialogInputOptions extends DialogOptions {
47
47
  maxlength?: number;
48
48
  }
49
49
  export declare const contextRef: {
50
- value: DialogContext | null;
50
+ value: Record<string, DialogContext | null>;
51
51
  };
52
52
  declare const Dialog: {
53
53
  (options: DialogOptions): Promise<WechatMiniprogram.Component.TrivialInstance>;
@@ -32,13 +32,13 @@ const defaultOptions = {
32
32
  };
33
33
  let currentOptions = Object.assign({}, defaultOptions);
34
34
  export const contextRef = {
35
- value: null,
35
+ value: {},
36
36
  };
37
37
  const Dialog = (options) => {
38
38
  options = Object.assign(Object.assign({}, currentOptions), options);
39
39
  return new Promise((resolve, reject) => {
40
40
  const context = (typeof options.context === 'function' ? options.context() : options.context) ||
41
- contextRef.value ||
41
+ contextRef.value[options.selector] ||
42
42
  getCurrentPage();
43
43
  const selector = options.selector;
44
44
  const dialog = context.selectComponent(options.selector);
@@ -93,7 +93,14 @@ SmartComponent({
93
93
  callback: (() => { }),
94
94
  },
95
95
  mounted: function () {
96
- contextRef.value = getCurrentPage();
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() {
@@ -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
- contextRef.value = getCurrentPage();
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
@@ -18,7 +18,7 @@ interface ToastOptions {
18
18
  width?: number;
19
19
  }
20
20
  export declare const contextRef: {
21
- value: ToastContext | null;
21
+ value: Record<string, ToastContext | null>;
22
22
  };
23
23
  declare function Toast(toastOptions: ToastOptions | ToastMessage): WechatMiniprogram.Component.TrivialInstance | undefined;
24
24
  declare namespace Toast {
@@ -22,12 +22,12 @@ function parseOptions(message) {
22
22
  return isObj(message) ? message : { message };
23
23
  }
24
24
  export const contextRef = {
25
- value: null,
25
+ value: {},
26
26
  };
27
27
  function Toast(toastOptions) {
28
28
  const options = Object.assign(Object.assign({}, currentOptions), parseOptions(toastOptions));
29
29
  const context = (typeof options.context === 'function' ? options.context() : options.context) ||
30
- contextRef.value ||
30
+ contextRef.value[options.selector] ||
31
31
  getCurrentPage();
32
32
  const toast = context.selectComponent(options.selector);
33
33
  if (!toast) {
@@ -47,7 +47,7 @@ interface DialogInputOptions extends DialogOptions {
47
47
  maxlength?: number;
48
48
  }
49
49
  export declare const contextRef: {
50
- value: DialogContext | null;
50
+ value: Record<string, DialogContext | null>;
51
51
  };
52
52
  declare const Dialog: {
53
53
  (options: DialogOptions): Promise<WechatMiniprogram.Component.TrivialInstance>;
@@ -46,13 +46,13 @@ var defaultOptions = {
46
46
  };
47
47
  var currentOptions = __assign({}, defaultOptions);
48
48
  exports.contextRef = {
49
- value: null,
49
+ value: {},
50
50
  };
51
51
  var Dialog = function (options) {
52
52
  options = __assign(__assign({}, currentOptions), options);
53
53
  return new Promise(function (resolve, reject) {
54
54
  var context = (typeof options.context === 'function' ? options.context() : options.context) ||
55
- exports.contextRef.value ||
55
+ exports.contextRef.value[options.selector] ||
56
56
  (0, utils_1.getCurrentPage)();
57
57
  var selector = options.selector;
58
58
  var dialog = context.selectComponent(options.selector);
@@ -98,7 +98,14 @@ var dialog_1 = require("./dialog");
98
98
  callback: (function () { }),
99
99
  },
100
100
  mounted: function () {
101
- dialog_1.contextRef.value = (0, utils_1.getCurrentPage)();
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 () {
@@ -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
- toast_1.contextRef.value = (0, utils_1.getCurrentPage)();
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
@@ -18,7 +18,7 @@ interface ToastOptions {
18
18
  width?: number;
19
19
  }
20
20
  export declare const contextRef: {
21
- value: ToastContext | null;
21
+ value: Record<string, ToastContext | null>;
22
22
  };
23
23
  declare function Toast(toastOptions: ToastOptions | ToastMessage): WechatMiniprogram.Component.TrivialInstance | undefined;
24
24
  declare namespace Toast {
@@ -36,12 +36,12 @@ function parseOptions(message) {
36
36
  return (0, validator_1.isObj)(message) ? message : { message: message };
37
37
  }
38
38
  exports.contextRef = {
39
- value: null,
39
+ value: {},
40
40
  };
41
41
  function Toast(toastOptions) {
42
42
  var options = __assign(__assign({}, currentOptions), parseOptions(toastOptions));
43
43
  var context = (typeof options.context === 'function' ? options.context() : options.context) ||
44
- exports.contextRef.value ||
44
+ exports.contextRef.value[options.selector] ||
45
45
  (0, utils_1.getCurrentPage)();
46
46
  var toast = context.selectComponent(options.selector);
47
47
  if (!toast) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-miniapp/smart-ui",
3
- "version": "2.2.0",
3
+ "version": "2.2.1-beta-1",
4
4
  "author": "MiniApp Team",
5
5
  "license": "MIT",
6
6
  "miniprogram": "lib",