@tamagui/toast 3.0.0-beta.924.1 → 3.0.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.
- package/dist/cjs/ToastComposable.cjs +61 -68
- package/dist/cjs/ToastComposable.native.cjs +80 -94
- package/dist/cjs/ToastComposable.native.js +80 -94
- package/dist/cjs/ToastComposable.native.js.map +1 -1
- package/dist/cjs/ToastItemFrame.cjs +4 -3
- package/dist/cjs/ToastItemFrame.native.cjs +4 -3
- package/dist/cjs/ToastItemFrame.native.js +4 -3
- package/dist/cjs/ToastItemFrame.native.js.map +1 -1
- package/dist/cjs/ToastState.cjs +1 -0
- package/dist/cjs/ToastState.native.cjs +3 -13
- package/dist/cjs/ToastState.native.js +3 -13
- package/dist/cjs/ToastState.native.js.map +1 -1
- package/dist/esm/ToastComposable.mjs +62 -69
- package/dist/esm/ToastComposable.mjs.map +1 -1
- package/dist/esm/ToastComposable.native.js +81 -95
- package/dist/esm/ToastComposable.native.js.map +1 -1
- package/dist/esm/ToastItemFrame.mjs +4 -3
- package/dist/esm/ToastItemFrame.mjs.map +1 -1
- package/dist/esm/ToastItemFrame.native.js +4 -3
- package/dist/esm/ToastItemFrame.native.js.map +1 -1
- package/dist/esm/ToastState.mjs +1 -0
- package/dist/esm/ToastState.mjs.map +1 -1
- package/dist/esm/ToastState.native.js +3 -13
- package/dist/esm/ToastState.native.js.map +1 -1
- package/dist/jsx/ToastComposable.mjs +62 -69
- package/dist/jsx/ToastComposable.mjs.map +1 -1
- package/dist/jsx/ToastComposable.native.cjs +80 -94
- package/dist/jsx/ToastComposable.native.js +80 -94
- package/dist/jsx/ToastComposable.native.js.map +1 -1
- package/dist/jsx/ToastItemFrame.mjs +4 -3
- package/dist/jsx/ToastItemFrame.mjs.map +1 -1
- package/dist/jsx/ToastItemFrame.native.cjs +4 -3
- package/dist/jsx/ToastItemFrame.native.js +4 -3
- package/dist/jsx/ToastItemFrame.native.js.map +1 -1
- package/dist/jsx/ToastState.mjs +1 -0
- package/dist/jsx/ToastState.mjs.map +1 -1
- package/dist/jsx/ToastState.native.cjs +3 -13
- package/dist/jsx/ToastState.native.js +3 -13
- package/dist/jsx/ToastState.native.js.map +1 -1
- package/package.json +22 -20
- package/src/ToastComposable.tsx +107 -113
- package/src/ToastItemFrame.tsx +7 -3
- package/src/ToastState.ts +4 -1
- package/src/useToastAnimations.ts +3 -4
- package/types/ToastComposable.d.ts +32 -72
- package/types/ToastComposable.d.ts.map +1 -1
- package/types/ToastItemFrame.d.ts +12 -36
- package/types/ToastItemFrame.d.ts.map +1 -1
- package/types/ToastState.d.ts.map +1 -1
- package/types/useAnimatedDragGesture.native.d.ts +1 -1
- package/types/useToastAnimations.d.ts +2 -3
- package/types/useToastAnimations.d.ts.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToastItemFrame.native.js","names":[],"sources":["cjs/ToastItemFrame.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar ToastItemFrame_exports = {};\n__export(ToastItemFrame_exports, {\n DefaultCloseIcon: () => DefaultCloseIcon,\n ToastActionFrame: () => ToastActionFrame,\n ToastCloseFrame: () => ToastCloseFrame,\n ToastItemFrame: () => ToastItemFrame,\n ToastPositionWrapper: () => ToastPositionWrapper\n});\nmodule.exports = __toCommonJS(ToastItemFrame_exports);\nvar import_jsx_runtime = require(\"react/jsx-runtime\");\nvar import_core = require(\"@tamagui/core\");\nvar import_stacks = require(\"@tamagui/stacks\");\nvar import_text = require(\"@tamagui/text\");\nvar ToastPositionWrapper = (0, import_core.styled)(import_stacks.YStack, {\n displayName: \"ToastPositionWrapper\",\n pointerEvents: \"auto\",\n position: \"absolute\",\n left: 0,\n right: 0,\n opacity: 1,\n scale: 1,\n y: 0,\n x: 0\n});\nvar ToastItemFrame = (0, import_core.styled)(import_stacks.YStack, {\n displayName: \"ToastItem\",\n userSelect: \"none\",\n cursor: \"default\",\n tabIndex: 0\n});\nvar ToastCloseFrame = (0, import_core.styled)(import_stacks.XStack, {\n displayName: \"ToastClose\",\n render: \"button\",\n alignItems: \"center\",\n justifyContent: \"center\",\n cursor: \"pointer\",\n width:
|
|
1
|
+
{"version":3,"file":"ToastItemFrame.native.js","names":[],"sources":["cjs/ToastItemFrame.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar ToastItemFrame_exports = {};\n__export(ToastItemFrame_exports, {\n DefaultCloseIcon: () => DefaultCloseIcon,\n ToastActionFrame: () => ToastActionFrame,\n ToastCloseFrame: () => ToastCloseFrame,\n ToastItemFrame: () => ToastItemFrame,\n ToastPositionWrapper: () => ToastPositionWrapper\n});\nmodule.exports = __toCommonJS(ToastItemFrame_exports);\nvar import_jsx_runtime = require(\"react/jsx-runtime\");\nvar import_core = require(\"@tamagui/core\");\nvar import_stacks = require(\"@tamagui/stacks\");\nvar import_text = require(\"@tamagui/text\");\nvar ToastPositionWrapper = (0, import_core.styled)(import_stacks.YStack, {\n displayName: \"ToastPositionWrapper\",\n pointerEvents: \"auto\",\n position: \"absolute\",\n left: 0,\n right: 0,\n opacity: 1,\n scale: 1,\n y: 0,\n x: 0\n});\nvar ToastItemFrame = (0, import_core.styled)(import_stacks.YStack, {\n displayName: \"ToastItem\",\n userSelect: \"none\",\n cursor: \"default\",\n tabIndex: 0\n});\nvar ToastCloseFrame = (0, import_core.styled)(import_stacks.XStack, {\n displayName: \"ToastClose\",\n render: \"button\",\n alignItems: \"center\",\n justifyContent: \"center\",\n cursor: \"pointer\",\n width: 24,\n height: 24\n});\nvar ToastActionFrame = (0, import_core.styled)(import_stacks.XStack, {\n displayName: \"ToastAction\",\n render: \"button\",\n alignItems: \"center\",\n justifyContent: \"center\",\n cursor: \"pointer\",\n height: 24\n});\nvar DefaultCloseIcon = function() {\n return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_text.SizableText, {\n size: \"5\",\n lineHeight: \"1\",\n children: \"\\u2715\"\n });\n};\n//# sourceMappingURL=ToastItemFrame.js.map\n"],"mappings":";;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBA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AAG,CAAE,YAAY,aAAa;EAC1E,MAAM;EACN,YAAY;EACZ,UAAU;CACZ,CAAC;AACH"}
|
package/dist/cjs/ToastState.cjs
CHANGED
|
@@ -44,17 +44,6 @@ function _define_property(obj, key, value) {
|
|
|
44
44
|
}
|
|
45
45
|
return obj;
|
|
46
46
|
}
|
|
47
|
-
function _instanceof(left, right) {
|
|
48
|
-
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
49
|
-
return !!right[Symbol.hasInstance](left);
|
|
50
|
-
} else {
|
|
51
|
-
return left instanceof right;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
function _type_of(obj) {
|
|
55
|
-
"@swc/helpers - typeof";
|
|
56
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
57
|
-
}
|
|
58
47
|
var toastsCounter = 1;
|
|
59
48
|
var Observer = function Observer2() {
|
|
60
49
|
"use strict";
|
|
@@ -126,6 +115,7 @@ var Observer = function Observer2() {
|
|
|
126
115
|
if (id !== void 0) {
|
|
127
116
|
_this.dismissedToasts.add(id);
|
|
128
117
|
requestAnimationFrame(function() {
|
|
118
|
+
if (!_this.dismissedToasts.has(id)) return;
|
|
129
119
|
_this.subscribers.forEach(function(subscriber) {
|
|
130
120
|
return subscriber({
|
|
131
121
|
id,
|
|
@@ -201,7 +191,7 @@ var Observer = function Observer2() {
|
|
|
201
191
|
duration: Number.POSITIVE_INFINITY
|
|
202
192
|
});
|
|
203
193
|
}
|
|
204
|
-
var p = Promise.resolve(
|
|
194
|
+
var p = Promise.resolve(promise instanceof Function ? promise() : promise);
|
|
205
195
|
var shouldDismiss = id !== void 0;
|
|
206
196
|
var result;
|
|
207
197
|
var originalPromise = p.then(async function(response) {
|
|
@@ -281,7 +271,7 @@ var Observer = function Observer2() {
|
|
|
281
271
|
});
|
|
282
272
|
};
|
|
283
273
|
function isHttpResponse(data) {
|
|
284
|
-
return data &&
|
|
274
|
+
return data && typeof data === "object" && "ok" in data && typeof data.ok === "boolean" && "status" in data && typeof data.status === "number";
|
|
285
275
|
}
|
|
286
276
|
var ToastState = new Observer();
|
|
287
277
|
var toastFunction = function(title, data) {
|
|
@@ -44,17 +44,6 @@ function _define_property(obj, key, value) {
|
|
|
44
44
|
}
|
|
45
45
|
return obj;
|
|
46
46
|
}
|
|
47
|
-
function _instanceof(left, right) {
|
|
48
|
-
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
49
|
-
return !!right[Symbol.hasInstance](left);
|
|
50
|
-
} else {
|
|
51
|
-
return left instanceof right;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
function _type_of(obj) {
|
|
55
|
-
"@swc/helpers - typeof";
|
|
56
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
57
|
-
}
|
|
58
47
|
var toastsCounter = 1;
|
|
59
48
|
var Observer = function Observer2() {
|
|
60
49
|
"use strict";
|
|
@@ -126,6 +115,7 @@ var Observer = function Observer2() {
|
|
|
126
115
|
if (id !== void 0) {
|
|
127
116
|
_this.dismissedToasts.add(id);
|
|
128
117
|
requestAnimationFrame(function() {
|
|
118
|
+
if (!_this.dismissedToasts.has(id)) return;
|
|
129
119
|
_this.subscribers.forEach(function(subscriber) {
|
|
130
120
|
return subscriber({
|
|
131
121
|
id,
|
|
@@ -201,7 +191,7 @@ var Observer = function Observer2() {
|
|
|
201
191
|
duration: Number.POSITIVE_INFINITY
|
|
202
192
|
});
|
|
203
193
|
}
|
|
204
|
-
var p = Promise.resolve(
|
|
194
|
+
var p = Promise.resolve(promise instanceof Function ? promise() : promise);
|
|
205
195
|
var shouldDismiss = id !== void 0;
|
|
206
196
|
var result;
|
|
207
197
|
var originalPromise = p.then(async function(response) {
|
|
@@ -281,7 +271,7 @@ var Observer = function Observer2() {
|
|
|
281
271
|
});
|
|
282
272
|
};
|
|
283
273
|
function isHttpResponse(data) {
|
|
284
|
-
return data &&
|
|
274
|
+
return data && typeof data === "object" && "ok" in data && typeof data.ok === "boolean" && "status" in data && typeof data.status === "number";
|
|
285
275
|
}
|
|
286
276
|
var ToastState = new Observer();
|
|
287
277
|
var toastFunction = function(title, data) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToastState.native.js","names":[],"sources":["cjs/ToastState.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar ToastState_exports = {};\n__export(ToastState_exports, {\n ToastState: () => ToastState,\n toast: () => toast\n});\nmodule.exports = __toCommonJS(ToastState_exports);\nfunction _class_call_check(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n}\nfunction _define_property(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n return obj;\n}\nfunction _instanceof(left, right) {\n if (right != null && typeof Symbol !== \"undefined\" && right[Symbol.hasInstance]) {\n return !!right[Symbol.hasInstance](left);\n } else {\n return left instanceof right;\n }\n}\nfunction _type_of(obj) {\n \"@swc/helpers - typeof\";\n return obj && typeof Symbol !== \"undefined\" && obj.constructor === Symbol ? \"symbol\" : typeof obj;\n}\nvar toastsCounter = 1;\nvar Observer = function Observer2() {\n \"use strict\";\n var _this = this;\n _class_call_check(this, Observer2);\n _define_property(this, \"subscribers\", []);\n _define_property(this, \"toasts\", []);\n _define_property(this, \"dismissedToasts\", /* @__PURE__ */ new Set());\n _define_property(this, \"subscribe\", function(subscriber) {\n _this.subscribers.push(subscriber);\n return function() {\n var index = _this.subscribers.indexOf(subscriber);\n if (index > -1) {\n _this.subscribers.splice(index, 1);\n }\n };\n });\n _define_property(this, \"publish\", function(data) {\n _this.subscribers.forEach(function(subscriber) {\n return subscriber(data);\n });\n });\n _define_property(this, \"addToast\", function(data) {\n _this.publish(data);\n _this.toasts = [\n ..._this.toasts,\n data\n ];\n });\n _define_property(this, \"create\", function(data) {\n var { title, ...rest } = data;\n var id = typeof (data === null || data === void 0 ? void 0 : data.id) === \"number\" || typeof (data === null || data === void 0 ? void 0 : data.id) === \"string\" && data.id.length > 0 ? data.id : toastsCounter++;\n var alreadyExists = _this.toasts.find(function(toast2) {\n return toast2.id === id;\n });\n var _data_dismissible;\n var dismissible = (_data_dismissible = data.dismissible) !== null && _data_dismissible !== void 0 ? _data_dismissible : true;\n if (_this.dismissedToasts.has(id)) {\n _this.dismissedToasts.delete(id);\n }\n if (alreadyExists) {\n _this.toasts = _this.toasts.map(function(toast2) {\n if (toast2.id === id) {\n _this.publish({\n ...toast2,\n ...data,\n id,\n title,\n dismissible\n });\n return {\n ...toast2,\n ...data,\n id,\n title,\n dismissible\n };\n }\n return toast2;\n });\n } else {\n _this.addToast({\n title,\n ...rest,\n dismissible,\n id\n });\n }\n return id;\n });\n _define_property(this, \"dismiss\", function(id) {\n if (id !== void 0) {\n _this.dismissedToasts.add(id);\n requestAnimationFrame(function() {\n _this.subscribers.forEach(function(subscriber) {\n return subscriber({\n id,\n dismiss: true\n });\n });\n });\n } else {\n _this.toasts.forEach(function(toast2) {\n _this.subscribers.forEach(function(subscriber) {\n return subscriber({\n id: toast2.id,\n dismiss: true\n });\n });\n });\n }\n return id;\n });\n _define_property(this, \"message\", function(title, data) {\n return _this.create({\n ...data,\n title,\n type: \"default\"\n });\n });\n _define_property(this, \"success\", function(title, data) {\n return _this.create({\n ...data,\n title,\n type: \"success\"\n });\n });\n _define_property(this, \"error\", function(title, data) {\n return _this.create({\n ...data,\n title,\n type: \"error\"\n });\n });\n _define_property(this, \"warning\", function(title, data) {\n return _this.create({\n ...data,\n title,\n type: \"warning\"\n });\n });\n _define_property(this, \"info\", function(title, data) {\n return _this.create({\n ...data,\n title,\n type: \"info\"\n });\n });\n _define_property(this, \"loading\", function(title, data) {\n return _this.create({\n ...data,\n title,\n type: \"loading\"\n });\n });\n _define_property(this, \"promise\", function(promise, data) {\n if (!data) {\n return;\n }\n var id = void 0;\n if (data.loading !== void 0) {\n id = _this.create({\n promise,\n type: \"loading\",\n title: data.loading,\n description: typeof data.description !== \"function\" ? data.description : void 0,\n // loading toasts shouldn't auto-dismiss\n duration: Number.POSITIVE_INFINITY\n });\n }\n var p = Promise.resolve(_instanceof(promise, Function) ? promise() : promise);\n var shouldDismiss = id !== void 0;\n var result;\n var originalPromise = p.then(async function(response) {\n result = [\n \"resolve\",\n response\n ];\n if (isHttpResponse(response) && !response.ok) {\n shouldDismiss = false;\n var errorMsg = typeof data.error === \"function\" ? await data.error(`HTTP error! status: ${response.status}`) : data.error;\n var description = typeof data.description === \"function\" ? await data.description(`HTTP error! status: ${response.status}`) : data.description;\n _this.create({\n id,\n type: \"error\",\n title: errorMsg,\n description\n });\n } else if (data.success !== void 0) {\n shouldDismiss = false;\n var successMsg = typeof data.success === \"function\" ? await data.success(response) : data.success;\n var description1 = typeof data.description === \"function\" ? await data.description(response) : data.description;\n _this.create({\n id,\n type: \"success\",\n title: successMsg,\n description: description1\n });\n }\n }).catch(async function(error) {\n result = [\n \"reject\",\n error\n ];\n if (data.error !== void 0) {\n shouldDismiss = false;\n var errorMsg = typeof data.error === \"function\" ? await data.error(error) : data.error;\n var description = typeof data.description === \"function\" ? await data.description(error) : data.description;\n _this.create({\n id,\n type: \"error\",\n title: errorMsg,\n description\n });\n }\n }).finally(function() {\n var _data_finally;\n if (shouldDismiss) {\n _this.dismiss(id);\n id = void 0;\n }\n (_data_finally = data.finally) === null || _data_finally === void 0 ? void 0 : _data_finally.call(data);\n });\n var unwrap = function() {\n return new Promise(function(resolve, reject) {\n return originalPromise.then(function() {\n return result[0] === \"reject\" ? reject(result[1]) : resolve(result[1]);\n }).catch(reject);\n });\n };\n if (typeof id !== \"string\" && typeof id !== \"number\") {\n return {\n unwrap\n };\n } else {\n return Object.assign(id, {\n unwrap\n });\n }\n });\n _define_property(this, \"custom\", function(jsx, data) {\n var _data_id;\n var id = (_data_id = data === null || data === void 0 ? void 0 : data.id) !== null && _data_id !== void 0 ? _data_id : toastsCounter++;\n _this.create({\n jsx: jsx(id),\n ...data,\n id\n });\n return id;\n });\n _define_property(this, \"getActiveToasts\", function() {\n return _this.toasts.filter(function(toast2) {\n return !_this.dismissedToasts.has(toast2.id);\n });\n });\n _define_property(this, \"getHistory\", function() {\n return _this.toasts;\n });\n};\nfunction isHttpResponse(data) {\n return data && (typeof data === \"undefined\" ? \"undefined\" : _type_of(data)) === \"object\" && \"ok\" in data && typeof data.ok === \"boolean\" && \"status\" in data && typeof data.status === \"number\";\n}\nvar ToastState = new Observer();\nvar toastFunction = function(title, data) {\n return ToastState.create({\n ...data,\n title\n });\n};\nvar getHistory = function() {\n return ToastState.getHistory();\n};\nvar getToasts = function() {\n return ToastState.getActiveToasts();\n};\nvar toast = Object.assign(toastFunction, {\n success: ToastState.success,\n error: ToastState.error,\n warning: ToastState.warning,\n info: ToastState.info,\n loading: ToastState.loading,\n promise: ToastState.promise,\n custom: ToastState.custom,\n dismiss: ToastState.dismiss,\n message: ToastState.message,\n getHistory,\n getToasts\n});\n//# sourceMappingURL=ToastState.js.map\n"],"mappings":";;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,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C;EACD,OAAO;CACT,CAAC;CACD,iBAAiB,MAAM,mBAAmB,WAAW;EACnD,OAAO,MAAM,OAAO,OAAO,SAAS,QAAQ;GAC1C,OAAO,CAAC,MAAM,gBAAgB,IAAI,OAAO,EAAE;EAC7C,CAAC;CACH,CAAC;CACD,iBAAiB,MAAM,cAAc,WAAW;EAC9C,OAAO,MAAM;CACf,CAAC;AACH;AACA,SAAS,eAAe,MAAM;CAC5B,OAAO,SAAS,OAAO,SAAS,cAAc,cAAc,SAAS,IAAI,OAAO,YAAY,QAAQ,QAAQ,OAAO,KAAK,OAAO,aAAa,YAAY,QAAQ,OAAO,KAAK,WAAW;AACzL;AACA,IAAI,aAAa,IAAI,SAAS;AAC9B,IAAI,gBAAgB,SAAS,OAAO,MAAM;CACxC,OAAO,WAAW,OAAO;EACvB,GAAG;EACH;CACF,CAAC;AACH;AACA,IAAI,aAAa,WAAW;CAC1B,OAAO,WAAW,WAAW;AAC/B;AACA,IAAI,YAAY,WAAW;CACzB,OAAO,WAAW,gBAAgB;AACpC;AACA,IAAI,QAAQ,OAAO,OAAO,eAAe;CACvC,SAAS,WAAW;CACpB,OAAO,WAAW;CAClB,SAAS,WAAW;CACpB,MAAM,WAAW;CACjB,SAAS,WAAW;CACpB,SAAS,WAAW;CACpB,QAAQ,WAAW;CACnB,SAAS,WAAW;CACpB,SAAS,WAAW;CACpB;CACA;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"ToastState.native.js","names":[],"sources":["cjs/ToastState.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar ToastState_exports = {};\n__export(ToastState_exports, {\n ToastState: () => ToastState,\n toast: () => toast\n});\nmodule.exports = __toCommonJS(ToastState_exports);\nfunction _class_call_check(instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n}\nfunction _define_property(obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n return obj;\n}\nvar toastsCounter = 1;\nvar Observer = function Observer2() {\n \"use strict\";\n var _this = this;\n _class_call_check(this, Observer2);\n _define_property(this, \"subscribers\", []);\n _define_property(this, \"toasts\", []);\n _define_property(this, \"dismissedToasts\", /* @__PURE__ */ new Set());\n _define_property(this, \"subscribe\", function(subscriber) {\n _this.subscribers.push(subscriber);\n return function() {\n var index = _this.subscribers.indexOf(subscriber);\n if (index > -1) {\n _this.subscribers.splice(index, 1);\n }\n };\n });\n _define_property(this, \"publish\", function(data) {\n _this.subscribers.forEach(function(subscriber) {\n return subscriber(data);\n });\n });\n _define_property(this, \"addToast\", function(data) {\n _this.publish(data);\n _this.toasts = [\n ..._this.toasts,\n data\n ];\n });\n _define_property(this, \"create\", function(data) {\n var { title, ...rest } = data;\n var id = typeof (data === null || data === void 0 ? void 0 : data.id) === \"number\" || typeof (data === null || data === void 0 ? void 0 : data.id) === \"string\" && data.id.length > 0 ? data.id : toastsCounter++;\n var alreadyExists = _this.toasts.find(function(toast2) {\n return toast2.id === id;\n });\n var _data_dismissible;\n var dismissible = (_data_dismissible = data.dismissible) !== null && _data_dismissible !== void 0 ? _data_dismissible : true;\n if (_this.dismissedToasts.has(id)) {\n _this.dismissedToasts.delete(id);\n }\n if (alreadyExists) {\n _this.toasts = _this.toasts.map(function(toast2) {\n if (toast2.id === id) {\n _this.publish({\n ...toast2,\n ...data,\n id,\n title,\n dismissible\n });\n return {\n ...toast2,\n ...data,\n id,\n title,\n dismissible\n };\n }\n return toast2;\n });\n } else {\n _this.addToast({\n title,\n ...rest,\n dismissible,\n id\n });\n }\n return id;\n });\n _define_property(this, \"dismiss\", function(id) {\n if (id !== void 0) {\n _this.dismissedToasts.add(id);\n requestAnimationFrame(function() {\n if (!_this.dismissedToasts.has(id)) return;\n _this.subscribers.forEach(function(subscriber) {\n return subscriber({\n id,\n dismiss: true\n });\n });\n });\n } else {\n _this.toasts.forEach(function(toast2) {\n _this.subscribers.forEach(function(subscriber) {\n return subscriber({\n id: toast2.id,\n dismiss: true\n });\n });\n });\n }\n return id;\n });\n _define_property(this, \"message\", function(title, data) {\n return _this.create({\n ...data,\n title,\n type: \"default\"\n });\n });\n _define_property(this, \"success\", function(title, data) {\n return _this.create({\n ...data,\n title,\n type: \"success\"\n });\n });\n _define_property(this, \"error\", function(title, data) {\n return _this.create({\n ...data,\n title,\n type: \"error\"\n });\n });\n _define_property(this, \"warning\", function(title, data) {\n return _this.create({\n ...data,\n title,\n type: \"warning\"\n });\n });\n _define_property(this, \"info\", function(title, data) {\n return _this.create({\n ...data,\n title,\n type: \"info\"\n });\n });\n _define_property(this, \"loading\", function(title, data) {\n return _this.create({\n ...data,\n title,\n type: \"loading\"\n });\n });\n _define_property(this, \"promise\", function(promise, data) {\n if (!data) {\n return;\n }\n var id = void 0;\n if (data.loading !== void 0) {\n id = _this.create({\n promise,\n type: \"loading\",\n title: data.loading,\n description: typeof data.description !== \"function\" ? data.description : void 0,\n // loading toasts shouldn't auto-dismiss\n duration: Number.POSITIVE_INFINITY\n });\n }\n var p = Promise.resolve(promise instanceof Function ? promise() : promise);\n var shouldDismiss = id !== void 0;\n var result;\n var originalPromise = p.then(async function(response) {\n result = [\n \"resolve\",\n response\n ];\n if (isHttpResponse(response) && !response.ok) {\n shouldDismiss = false;\n var errorMsg = typeof data.error === \"function\" ? await data.error(`HTTP error! status: ${response.status}`) : data.error;\n var description = typeof data.description === \"function\" ? await data.description(`HTTP error! status: ${response.status}`) : data.description;\n _this.create({\n id,\n type: \"error\",\n title: errorMsg,\n description\n });\n } else if (data.success !== void 0) {\n shouldDismiss = false;\n var successMsg = typeof data.success === \"function\" ? await data.success(response) : data.success;\n var description1 = typeof data.description === \"function\" ? await data.description(response) : data.description;\n _this.create({\n id,\n type: \"success\",\n title: successMsg,\n description: description1\n });\n }\n }).catch(async function(error) {\n result = [\n \"reject\",\n error\n ];\n if (data.error !== void 0) {\n shouldDismiss = false;\n var errorMsg = typeof data.error === \"function\" ? await data.error(error) : data.error;\n var description = typeof data.description === \"function\" ? await data.description(error) : data.description;\n _this.create({\n id,\n type: \"error\",\n title: errorMsg,\n description\n });\n }\n }).finally(function() {\n var _data_finally;\n if (shouldDismiss) {\n _this.dismiss(id);\n id = void 0;\n }\n (_data_finally = data.finally) === null || _data_finally === void 0 ? void 0 : _data_finally.call(data);\n });\n var unwrap = function() {\n return new Promise(function(resolve, reject) {\n return originalPromise.then(function() {\n return result[0] === \"reject\" ? reject(result[1]) : resolve(result[1]);\n }).catch(reject);\n });\n };\n if (typeof id !== \"string\" && typeof id !== \"number\") {\n return {\n unwrap\n };\n } else {\n return Object.assign(id, {\n unwrap\n });\n }\n });\n _define_property(this, \"custom\", function(jsx, data) {\n var _data_id;\n var id = (_data_id = data === null || data === void 0 ? void 0 : data.id) !== null && _data_id !== void 0 ? _data_id : toastsCounter++;\n _this.create({\n jsx: jsx(id),\n ...data,\n id\n });\n return id;\n });\n _define_property(this, \"getActiveToasts\", function() {\n return _this.toasts.filter(function(toast2) {\n return !_this.dismissedToasts.has(toast2.id);\n });\n });\n _define_property(this, \"getHistory\", function() {\n return _this.toasts;\n });\n};\nfunction isHttpResponse(data) {\n return data && typeof data === \"object\" && \"ok\" in data && typeof data.ok === \"boolean\" && \"status\" in data && typeof data.status === \"number\";\n}\nvar ToastState = new Observer();\nvar toastFunction = function(title, data) {\n return ToastState.create({\n ...data,\n title\n });\n};\nvar getHistory = function() {\n return ToastState.getHistory();\n};\nvar getToasts = function() {\n return ToastState.getActiveToasts();\n};\nvar toast = Object.assign(toastFunction, {\n success: ToastState.success,\n error: ToastState.error,\n warning: ToastState.warning,\n info: ToastState.info,\n loading: ToastState.loading,\n promise: ToastState.promise,\n custom: ToastState.custom,\n dismiss: ToastState.dismiss,\n message: ToastState.message,\n getHistory,\n getToasts\n});\n//# sourceMappingURL=ToastState.js.map\n"],"mappings":";;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,qBAAqB,CAAC;AAC1B,SAAS,oBAAoB;CAC3B,kBAAkB;CAClB,aAAa;AACf,CAAC;AACD,OAAO,UAAU,aAAa,kBAAkB;AAChD,SAAS,kBAAkB,UAAU,aAAa;CAChD,IAAI,EAAE,oBAAoB,cAAc;EACtC,MAAM,IAAI,UAAU,mCA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iBAAiB,MAAM,UAAU,SAAS,KAAK,MAAM;EACnD,IAAI;EACJ,IAAI,MAAM,WAAW,SAAS,QAAQ,SAAS,KAAK,IAAI,KAAK,IAAI,KAAK,QAAQ,QAAQ,aAAa,KAAK,IAAI,WAAW;EACvH,MAAM,OAAO;GACX,KAAK,IAAI,EAAE;GACX,GAAG;GACH;EACF,CAAC;EACD,OAAO;CACT,CAAC;CACD,iBAAiB,MAAM,mBAAmB,WAAW;EACnD,OAAO,MAAM,OAAO,OAAO,SAAS,QAAQ;GAC1C,OAAO,CAAC,MAAM,gBAAgB,IAAI,OAAO,EAAE;EAC7C,CAAC;CACH,CAAC;CACD,iBAAiB,MAAM,cAAc,WAAW;EAC9C,OAAO,MAAM;CACf,CAAC;AACH;AACA,SAAS,eAAe,MAAM;CAC5B,OAAO,QAAQ,OAAO,SAAS,YAAY,QAAQ,QAAQ,OAAO,KAAK,OAAO,aAAa,YAAY,QAAQ,OAAO,KAAK,WAAW;AACxI;AACA,IAAI,aAAa,IAAI,SAAS;AAC9B,IAAI,gBAAgB,SAAS,OAAO,MAAM;CACxC,OAAO,WAAW,OAAO;EACvB,GAAG;EACH;CACF,CAAC;AACH;AACA,IAAI,aAAa,WAAW;CAC1B,OAAO,WAAW,WAAW;AAC/B;AACA,IAAI,YAAY,WAAW;CACzB,OAAO,WAAW,gBAAgB;AACpC;AACA,IAAI,QAAQ,OAAO,OAAO,eAAe;CACvC,SAAS,WAAW;CACpB,OAAO,WAAW;CAClB,SAAS,WAAW;CACpB,MAAM,WAAW;CACjB,SAAS,WAAW;CACpB,SAAS,WAAW;CACpB,QAAQ,WAAW;CACnB,SAAS,WAAW;CACpB,SAAS,WAAW;CACpB;CACA;AACF,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { View, createRefComponent, createStyledContext, createStyledHOC, styled, useEvent } from "@tamagui/core";
|
|
2
2
|
import { AnimatePresence } from "@tamagui/animate-presence";
|
|
3
3
|
import { isWeb } from "@tamagui/constants";
|
|
4
4
|
import { getGestureHandler } from "@tamagui/native";
|
|
@@ -53,7 +53,7 @@ function resolveSwipeDirection(direction, position) {
|
|
|
53
53
|
return "horizontal";
|
|
54
54
|
}
|
|
55
55
|
const ToastRoot = createRefComponent(function ToastRoot2(props, _ref) {
|
|
56
|
-
const { children, toasterId, position = "bottom-right", duration = TOAST_LIFETIME, gap = TOAST_GAP, visibleToasts = VISIBLE_TOASTS_AMOUNT, swipeDirection: swipeDirectionProp = "auto", swipeThreshold = 50, toastHeight = FIXED_TOAST_HEIGHT, closeButton = false, expand = false,
|
|
56
|
+
const { children, toasterId, position = "bottom-right", duration = TOAST_LIFETIME, gap = TOAST_GAP, visibleToasts = VISIBLE_TOASTS_AMOUNT, swipeDirection: swipeDirectionProp = "auto", swipeThreshold = 50, toastHeight = FIXED_TOAST_HEIGHT, closeButton = false, expand = false, reducedMotion: reducedMotionProp, native = false, burntOptions, notificationOptions, icons } = props;
|
|
57
57
|
const reducedMotion = useReducedMotion(reducedMotionProp);
|
|
58
58
|
const [toasts, setToasts] = React.useState([]);
|
|
59
59
|
const [heights, setHeights] = React.useState({});
|
|
@@ -139,7 +139,8 @@ const ToastRoot = createRefComponent(function ToastRoot2(props, _ref) {
|
|
|
139
139
|
...toasts2.slice(0, idx),
|
|
140
140
|
{
|
|
141
141
|
...toasts2[idx],
|
|
142
|
-
...toast
|
|
142
|
+
...toast,
|
|
143
|
+
delete: false
|
|
143
144
|
},
|
|
144
145
|
...toasts2.slice(idx + 1)
|
|
145
146
|
];
|
|
@@ -171,8 +172,6 @@ const ToastRoot = createRefComponent(function ToastRoot2(props, _ref) {
|
|
|
171
172
|
});
|
|
172
173
|
}, []);
|
|
173
174
|
const swipeDirection = resolveSwipeDirection(swipeDirectionProp, position);
|
|
174
|
-
const currentTheme = useThemeName();
|
|
175
|
-
const resolvedTheme = themeProp === "system" || !themeProp ? currentTheme?.includes("dark") ? "dark" : "light" : themeProp;
|
|
176
175
|
const contextValue = {
|
|
177
176
|
toasts,
|
|
178
177
|
heights,
|
|
@@ -201,10 +200,7 @@ const ToastRoot = createRefComponent(function ToastRoot2(props, _ref) {
|
|
|
201
200
|
};
|
|
202
201
|
return /* @__PURE__ */ jsx(ToastContext.Provider, {
|
|
203
202
|
...contextValue,
|
|
204
|
-
children
|
|
205
|
-
name: resolvedTheme,
|
|
206
|
-
children
|
|
207
|
-
})
|
|
203
|
+
children
|
|
208
204
|
});
|
|
209
205
|
});
|
|
210
206
|
const ToastViewportFrame = styled(View, {
|
|
@@ -225,39 +221,36 @@ const ToastViewport = createStyledHOC(ToastViewportFrame, function ToastViewport
|
|
|
225
221
|
const deferredCollapseRef = React.useRef(null);
|
|
226
222
|
const mouseInsideRef = React.useRef(false);
|
|
227
223
|
const [yPosition, xPosition] = ctx.position.split("-");
|
|
228
|
-
const
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
yPosition,
|
|
259
|
-
xPosition
|
|
260
|
-
]);
|
|
224
|
+
const defaultOffset = typeof offset === "number" ? offset : VIEWPORT_OFFSET;
|
|
225
|
+
const offsetObj = typeof offset === "object" ? offset : {
|
|
226
|
+
top: defaultOffset,
|
|
227
|
+
right: defaultOffset,
|
|
228
|
+
bottom: defaultOffset,
|
|
229
|
+
left: defaultOffset
|
|
230
|
+
};
|
|
231
|
+
const edgeProps = yPosition === "top" ? {
|
|
232
|
+
top: "safe",
|
|
233
|
+
marginTop: offsetObj.top ?? defaultOffset
|
|
234
|
+
} : {
|
|
235
|
+
bottom: "safe",
|
|
236
|
+
marginBottom: offsetObj.bottom ?? defaultOffset
|
|
237
|
+
};
|
|
238
|
+
const sideProps = isWeb ? xPosition === "left" ? {
|
|
239
|
+
left: "safe",
|
|
240
|
+
marginLeft: offsetObj.left ?? defaultOffset
|
|
241
|
+
} : xPosition === "right" ? {
|
|
242
|
+
right: "safe",
|
|
243
|
+
marginRight: offsetObj.right ?? defaultOffset
|
|
244
|
+
} : null : {
|
|
245
|
+
left: "safe",
|
|
246
|
+
marginLeft: offsetObj.left ?? defaultOffset,
|
|
247
|
+
right: "safe",
|
|
248
|
+
marginRight: offsetObj.right ?? defaultOffset
|
|
249
|
+
};
|
|
250
|
+
const centerStyle = isWeb && xPosition === "center" ? {
|
|
251
|
+
left: "50%",
|
|
252
|
+
transform: "translateX(-50%)"
|
|
253
|
+
} : null;
|
|
261
254
|
React.useEffect(() => {
|
|
262
255
|
if (!isWeb) return;
|
|
263
256
|
const handleKeyDown = (event) => {
|
|
@@ -277,7 +270,9 @@ const ToastViewport = createStyledHOC(ToastViewportFrame, function ToastViewport
|
|
|
277
270
|
"aria-label": `${label} ${hotkeyLabel}`,
|
|
278
271
|
tabIndex: -1,
|
|
279
272
|
"aria-live": "polite",
|
|
280
|
-
|
|
273
|
+
...edgeProps,
|
|
274
|
+
...sideProps,
|
|
275
|
+
...centerStyle ? { style: centerStyle } : null,
|
|
281
276
|
"data-y-position": yPosition,
|
|
282
277
|
"data-x-position": xPosition,
|
|
283
278
|
...isWeb ? {
|
|
@@ -548,13 +543,16 @@ const ToastItemInner = createStyledHOC(ToastItemFrame, function ToastItem(props,
|
|
|
548
543
|
setMounted(true);
|
|
549
544
|
}, []);
|
|
550
545
|
React.useEffect(() => {
|
|
551
|
-
if (toast.delete) {
|
|
552
|
-
setRemoved(
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
546
|
+
if (!toast.delete) {
|
|
547
|
+
setRemoved(false);
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
setRemoved(true);
|
|
551
|
+
if (isExpandedRef.current) {
|
|
552
|
+
setOffsetBeforeRemove(expandedOffsetRef.current);
|
|
557
553
|
}
|
|
554
|
+
const timer = setTimeout(() => ctx.removeToast(toast), TIME_BEFORE_UNMOUNT);
|
|
555
|
+
return () => clearTimeout(timer);
|
|
558
556
|
}, [
|
|
559
557
|
toast.delete,
|
|
560
558
|
toast,
|
|
@@ -601,9 +599,8 @@ const ToastItemInner = createStyledHOC(ToastItemFrame, function ToastItem(props,
|
|
|
601
599
|
}
|
|
602
600
|
});
|
|
603
601
|
const handleLayout = React.useCallback((event) => {
|
|
604
|
-
if (!isWeb) return;
|
|
605
602
|
if (removed) return;
|
|
606
|
-
if (!ctx.expanded && index !== 0) return;
|
|
603
|
+
if ((!isWeb || !ctx.expanded) && index !== 0) return;
|
|
607
604
|
const { height } = event.nativeEvent.layout;
|
|
608
605
|
ctx.setToastHeight(toast.id, height);
|
|
609
606
|
}, [
|
|
@@ -614,7 +611,6 @@ const ToastItemInner = createStyledHOC(ToastItemFrame, function ToastItem(props,
|
|
|
614
611
|
removed
|
|
615
612
|
]);
|
|
616
613
|
React.useEffect(() => {
|
|
617
|
-
if (!isWeb) return;
|
|
618
614
|
return () => {
|
|
619
615
|
ctx.removeToastHeight(toast.id);
|
|
620
616
|
};
|
|
@@ -639,13 +635,11 @@ const ToastItemInner = createStyledHOC(ToastItemFrame, function ToastItem(props,
|
|
|
639
635
|
handleClose
|
|
640
636
|
}), [toast, handleClose]);
|
|
641
637
|
let frontToastHeight = -1;
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
break;
|
|
648
|
-
}
|
|
638
|
+
for (const t of ctx.toasts) {
|
|
639
|
+
const h = ctx.heights[t.id];
|
|
640
|
+
if (h != null && h > 0) {
|
|
641
|
+
frontToastHeight = h;
|
|
642
|
+
break;
|
|
649
643
|
}
|
|
650
644
|
}
|
|
651
645
|
const stackScale = !ctx.expanded && !isFront ? 1 - index * .05 : 1;
|
|
@@ -653,7 +647,8 @@ const ToastItemInner = createStyledHOC(ToastItemFrame, function ToastItem(props,
|
|
|
653
647
|
const stackY = ctx.expanded ? isTop ? activeExpandedOffset : -activeExpandedOffset : isFront ? 0 : isTop ? ctx.gap * index : -ctx.gap * index;
|
|
654
648
|
const computedOpacity = removed && !swipeOut ? 0 : index >= ctx.visibleToasts ? 0 : 1;
|
|
655
649
|
const computedZIndex = removed ? 0 : ctx.visibleToasts - index + 1;
|
|
656
|
-
const
|
|
650
|
+
const collapsedHeight = !isFront && frontToastHeight > 0 ? frontToastHeight : void 0;
|
|
651
|
+
const computedHeight = ctx.expanded ? isWeb ? ctx.heights[toast.id] || void 0 : void 0 : collapsedHeight;
|
|
657
652
|
const computedPointerEvents = index >= ctx.visibleToasts ? "none" : "auto";
|
|
658
653
|
const gapFillerHeight = ctx.expanded ? ctx.gap + 1 : 0;
|
|
659
654
|
const dataAttributes = {
|
|
@@ -669,10 +664,12 @@ const ToastItemInner = createStyledHOC(ToastItemFrame, function ToastItem(props,
|
|
|
669
664
|
return /* @__PURE__ */ jsx(ToastPositionWrapper, {
|
|
670
665
|
ref,
|
|
671
666
|
testID: rest.testID,
|
|
672
|
-
"aria-label": rest["aria-label"],
|
|
673
667
|
...dataAttributes,
|
|
674
|
-
transition: isDragging || ctx.reducedMotion ? void 0 :
|
|
675
|
-
|
|
668
|
+
transition: isDragging || ctx.reducedMotion ? void 0 : {
|
|
669
|
+
duration: removed ? 200 : 400,
|
|
670
|
+
properties: isWeb ? "transform, opacity, height" : "transform, opacity"
|
|
671
|
+
},
|
|
672
|
+
y: ctx.reducedMotion ? stackY : `${stackY}px enter:${isTop ? -80 : 80}px exit:${swipeOut ? swipeExitYRef.current ?? stackY : stackY}px`,
|
|
676
673
|
scale: stackScale,
|
|
677
674
|
opacity: `${computedOpacity} enter:0 exit:0`,
|
|
678
675
|
zIndex: computedZIndex,
|
|
@@ -681,12 +678,7 @@ const ToastItemInner = createStyledHOC(ToastItemFrame, function ToastItem(props,
|
|
|
681
678
|
pointerEvents: computedPointerEvents,
|
|
682
679
|
top: isTop ? 0 : void 0,
|
|
683
680
|
bottom: isTop ? void 0 : 0,
|
|
684
|
-
|
|
685
|
-
animateOnly: isWeb ? [
|
|
686
|
-
"transform",
|
|
687
|
-
"opacity",
|
|
688
|
-
"height"
|
|
689
|
-
] : ["transform", "opacity"],
|
|
681
|
+
...!isFront && { style: { transformOrigin: isTop ? "top center" : "bottom center" } },
|
|
690
682
|
children: /* @__PURE__ */ jsx(DragWrapper, {
|
|
691
683
|
animatedStyle,
|
|
692
684
|
gestureHandlers,
|
|
@@ -713,6 +705,7 @@ const ToastItemInner = createStyledHOC(ToastItemFrame, function ToastItem(props,
|
|
|
713
705
|
handleClose();
|
|
714
706
|
}
|
|
715
707
|
} },
|
|
708
|
+
...!isWeb && computedHeight != null && { flex: 1 },
|
|
716
709
|
...rest,
|
|
717
710
|
children: [ctx.expanded && gapFillerHeight > 0 && /* @__PURE__ */ jsx(View, {
|
|
718
711
|
position: "absolute",
|