@fecp/mobile 1.0.1 → 1.0.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.
@@ -37,7 +37,8 @@ function parseOptions(message) {
37
37
  }
38
38
  function createInstance() {
39
39
  const {
40
- instance
40
+ instance,
41
+ unmount
41
42
  } = mountComponent({
42
43
  setup() {
43
44
  const message = ref("");
@@ -48,6 +49,10 @@ function createInstance() {
48
49
  toggle
49
50
  } = usePopupState();
50
51
  const onClosed = () => {
52
+ if (allowMultiple) {
53
+ queue = queue.filter((item) => item !== instance);
54
+ unmount();
55
+ }
51
56
  };
52
57
  const render = () => {
53
58
  const attrs = {
@@ -85,6 +90,35 @@ function showToast(options = {}) {
85
90
  toast.open(extend({}, currentOptions, defaultOptionsMap.get(parsedOptions.type || currentOptions.type), parsedOptions));
86
91
  return toast;
87
92
  }
93
+ const createMethod = (type) => (options) => showToast(extend({
94
+ type
95
+ }, parseOptions(options)));
96
+ const showLoadingToast = createMethod("loading");
97
+ const showSuccessToast = createMethod("success");
98
+ const showFailToast = createMethod("fail");
99
+ const closeToast = (all) => {
100
+ var _a;
101
+ if (queue.length) {
102
+ if (all) {
103
+ queue.forEach((toast) => {
104
+ toast.close();
105
+ });
106
+ queue = [];
107
+ } else if (!allowMultiple) {
108
+ queue[0].close();
109
+ } else {
110
+ (_a = queue.shift()) == null ? void 0 : _a.close();
111
+ }
112
+ }
113
+ };
114
+ const allowMultipleToast = (value = true) => {
115
+ allowMultiple = value;
116
+ };
88
117
  export {
118
+ allowMultipleToast,
119
+ closeToast,
120
+ showFailToast,
121
+ showLoadingToast,
122
+ showSuccessToast,
89
123
  showToast
90
124
  };
@@ -52,6 +52,7 @@ import { MobileTabs } from "./src/components/navigation/tabs/index.mjs";
52
52
  import { MobileTabbar } from "./src/components/navigation/tabbar/index.mjs";
53
53
  import { MobileTabbarItem } from "./src/components/navigation/tabbarItem/index.mjs";
54
54
  import { MobileTreeSelect } from "./src/components/navigation/treeSelect/index.mjs";
55
+ import { allowMultipleToast, closeToast, showFailToast, showLoadingToast, showSuccessToast, showToast } from "../../node_modules/.pnpm/vant@4.9.17_vue@3.5.13_typescript@5.7.3_/node_modules/vant/es/toast/function-call.mjs";
55
56
  const index = {
56
57
  install: (app) => {
57
58
  for (let c in all) {
@@ -113,5 +114,11 @@ export {
113
114
  MobileTimePicker,
114
115
  MobileTreeSelect,
115
116
  MobileUploader,
116
- index as default
117
+ allowMultipleToast,
118
+ closeToast,
119
+ index as default,
120
+ showFailToast,
121
+ showLoadingToast,
122
+ showSuccessToast,
123
+ showToast
117
124
  };
@@ -39,7 +39,8 @@ function parseOptions(message) {
39
39
  }
40
40
  function createInstance() {
41
41
  const {
42
- instance
42
+ instance,
43
+ unmount
43
44
  } = mountComponent.mountComponent({
44
45
  setup() {
45
46
  const message = vue.ref("");
@@ -50,6 +51,10 @@ function createInstance() {
50
51
  toggle
51
52
  } = mountComponent.usePopupState();
52
53
  const onClosed = () => {
54
+ if (allowMultiple) {
55
+ queue = queue.filter((item) => item !== instance);
56
+ unmount();
57
+ }
53
58
  };
54
59
  const render = () => {
55
60
  const attrs = {
@@ -87,4 +92,33 @@ function showToast(options = {}) {
87
92
  toast.open(basic.extend({}, currentOptions, defaultOptionsMap.get(parsedOptions.type || currentOptions.type), parsedOptions));
88
93
  return toast;
89
94
  }
95
+ const createMethod = (type) => (options) => showToast(basic.extend({
96
+ type
97
+ }, parseOptions(options)));
98
+ const showLoadingToast = createMethod("loading");
99
+ const showSuccessToast = createMethod("success");
100
+ const showFailToast = createMethod("fail");
101
+ const closeToast = (all) => {
102
+ var _a;
103
+ if (queue.length) {
104
+ if (all) {
105
+ queue.forEach((toast) => {
106
+ toast.close();
107
+ });
108
+ queue = [];
109
+ } else if (!allowMultiple) {
110
+ queue[0].close();
111
+ } else {
112
+ (_a = queue.shift()) == null ? void 0 : _a.close();
113
+ }
114
+ }
115
+ };
116
+ const allowMultipleToast = (value = true) => {
117
+ allowMultiple = value;
118
+ };
119
+ exports.allowMultipleToast = allowMultipleToast;
120
+ exports.closeToast = closeToast;
121
+ exports.showFailToast = showFailToast;
122
+ exports.showLoadingToast = showLoadingToast;
123
+ exports.showSuccessToast = showSuccessToast;
90
124
  exports.showToast = showToast;
@@ -54,6 +54,7 @@ const index$O = require("./src/components/navigation/tabs/index.js");
54
54
  const index$P = require("./src/components/navigation/tabbar/index.js");
55
55
  const index$Q = require("./src/components/navigation/tabbarItem/index.js");
56
56
  const index$R = require("./src/components/navigation/treeSelect/index.js");
57
+ const functionCall = require("../../node_modules/.pnpm/vant@4.9.17_vue@3.5.13_typescript@5.7.3_/node_modules/vant/es/toast/function-call.js");
57
58
  const index = {
58
59
  install: (app) => {
59
60
  for (let c in all) {
@@ -114,4 +115,10 @@ exports.MobileTabs = index$O.MobileTabs;
114
115
  exports.MobileTabbar = index$P.MobileTabbar;
115
116
  exports.MobileTabbarItem = index$Q.MobileTabbarItem;
116
117
  exports.MobileTreeSelect = index$R.MobileTreeSelect;
118
+ exports.allowMultipleToast = functionCall.allowMultipleToast;
119
+ exports.closeToast = functionCall.closeToast;
120
+ exports.showFailToast = functionCall.showFailToast;
121
+ exports.showLoadingToast = functionCall.showLoadingToast;
122
+ exports.showSuccessToast = functionCall.showSuccessToast;
123
+ exports.showToast = functionCall.showToast;
117
124
  exports.default = index;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fecp/mobile",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "main": "lib/packages/mobile/index.js",
5
5
  "module": "es/packages/mobile/index.mjs",
6
6
  "files": [