@zag-js/toast 0.2.6 → 0.2.7
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/chunk-2E56V7D3.mjs +104 -0
- package/dist/chunk-6MVNQK7B.mjs +144 -0
- package/dist/chunk-GQHI2OMI.mjs +9 -0
- package/dist/chunk-IEPKBUZZ.mjs +116 -0
- package/dist/chunk-KHVXQ4ZE.mjs +75 -0
- package/dist/chunk-LOJTIJID.mjs +66 -0
- package/dist/chunk-YVNTR4MK.mjs +202 -0
- package/dist/chunk-YVYADWQR.mjs +19 -0
- package/dist/index.d.ts +11 -1043
- package/dist/index.js +44 -32
- package/dist/index.mjs +23 -656
- package/dist/toast-group.connect.d.ts +28 -0
- package/dist/toast-group.connect.js +296 -0
- package/dist/toast-group.connect.mjs +12 -0
- package/dist/toast-group.machine.d.ts +7 -0
- package/dist/toast-group.machine.js +401 -0
- package/dist/toast-group.machine.mjs +10 -0
- package/dist/toast.anatomy.d.ts +6 -0
- package/dist/toast.anatomy.js +34 -0
- package/dist/toast.anatomy.mjs +8 -0
- package/dist/toast.connect.d.ts +23 -0
- package/dist/toast.connect.js +212 -0
- package/dist/toast.connect.mjs +8 -0
- package/dist/toast.dom.d.ts +36 -0
- package/dist/toast.dom.js +101 -0
- package/dist/toast.dom.mjs +6 -0
- package/dist/toast.machine.d.ts +7 -0
- package/dist/toast.machine.js +305 -0
- package/dist/toast.machine.mjs +9 -0
- package/dist/toast.types.d.ts +150 -0
- package/dist/toast.types.js +18 -0
- package/dist/toast.types.mjs +0 -0
- package/dist/toast.utils.d.ts +10 -0
- package/dist/toast.utils.js +93 -0
- package/dist/toast.utils.mjs +12 -0
- package/package.json +21 -11
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/toast.utils.ts
|
|
21
|
+
var toast_utils_exports = {};
|
|
22
|
+
__export(toast_utils_exports, {
|
|
23
|
+
defaultTimeouts: () => defaultTimeouts,
|
|
24
|
+
getGroupPlacementStyle: () => getGroupPlacementStyle,
|
|
25
|
+
getToastDuration: () => getToastDuration,
|
|
26
|
+
getToastsByPlacement: () => getToastsByPlacement
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(toast_utils_exports);
|
|
29
|
+
function getToastsByPlacement(toasts) {
|
|
30
|
+
const result = {};
|
|
31
|
+
for (const toast of toasts) {
|
|
32
|
+
const placement = toast.state.context.placement;
|
|
33
|
+
result[placement] || (result[placement] = []);
|
|
34
|
+
result[placement].push(toast);
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
var defaultTimeouts = {
|
|
39
|
+
info: 5e3,
|
|
40
|
+
error: 5e3,
|
|
41
|
+
success: 2e3,
|
|
42
|
+
loading: Infinity,
|
|
43
|
+
custom: 5e3
|
|
44
|
+
};
|
|
45
|
+
function getToastDuration(duration, type) {
|
|
46
|
+
return duration != null ? duration : defaultTimeouts[type];
|
|
47
|
+
}
|
|
48
|
+
function getGroupPlacementStyle(ctx, placement) {
|
|
49
|
+
const offset = ctx.offsets;
|
|
50
|
+
const __offset = typeof offset === "string" ? { left: offset, right: offset, bottom: offset, top: offset } : offset;
|
|
51
|
+
const rtl = ctx.dir === "rtl";
|
|
52
|
+
const __placement = placement.replace("-start", rtl ? "-right" : "-left").replace("-end", rtl ? "-left" : "-right");
|
|
53
|
+
const isRighty = __placement.includes("right");
|
|
54
|
+
const isLefty = __placement.includes("left");
|
|
55
|
+
const styles = {
|
|
56
|
+
position: "fixed",
|
|
57
|
+
pointerEvents: ctx.count > 0 ? void 0 : "none",
|
|
58
|
+
display: "flex",
|
|
59
|
+
flexDirection: "column",
|
|
60
|
+
"--toast-gutter": ctx.gutter,
|
|
61
|
+
zIndex: ctx.zIndex
|
|
62
|
+
};
|
|
63
|
+
let alignItems = "center";
|
|
64
|
+
if (isRighty)
|
|
65
|
+
alignItems = "flex-end";
|
|
66
|
+
if (isLefty)
|
|
67
|
+
alignItems = "flex-start";
|
|
68
|
+
styles.alignItems = alignItems;
|
|
69
|
+
if (__placement.includes("top")) {
|
|
70
|
+
const offset2 = __offset.top;
|
|
71
|
+
styles.top = `calc(env(safe-area-inset-top, 0px) + ${offset2})`;
|
|
72
|
+
}
|
|
73
|
+
if (__placement.includes("bottom")) {
|
|
74
|
+
const offset2 = __offset.bottom;
|
|
75
|
+
styles.bottom = `calc(env(safe-area-inset-bottom, 0px) + ${offset2})`;
|
|
76
|
+
}
|
|
77
|
+
if (!__placement.includes("left")) {
|
|
78
|
+
const offset2 = __offset.right;
|
|
79
|
+
styles.right = `calc(env(safe-area-inset-right, 0px) + ${offset2})`;
|
|
80
|
+
}
|
|
81
|
+
if (!__placement.includes("right")) {
|
|
82
|
+
const offset2 = __offset.left;
|
|
83
|
+
styles.left = `calc(env(safe-area-inset-left, 0px) + ${offset2})`;
|
|
84
|
+
}
|
|
85
|
+
return styles;
|
|
86
|
+
}
|
|
87
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
88
|
+
0 && (module.exports = {
|
|
89
|
+
defaultTimeouts,
|
|
90
|
+
getGroupPlacementStyle,
|
|
91
|
+
getToastDuration,
|
|
92
|
+
getToastsByPlacement
|
|
93
|
+
});
|
package/package.json
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/toast",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
4
4
|
"description": "Core logic for the toast widget implemented as a state machine",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"module": "dist/index.mjs",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
8
5
|
"keywords": [
|
|
9
6
|
"js",
|
|
10
7
|
"machine",
|
|
@@ -29,18 +26,31 @@
|
|
|
29
26
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
30
27
|
},
|
|
31
28
|
"dependencies": {
|
|
32
|
-
"@zag-js/
|
|
33
|
-
"@zag-js/
|
|
34
|
-
"@zag-js/
|
|
29
|
+
"@zag-js/anatomy": "0.1.3",
|
|
30
|
+
"@zag-js/core": "0.2.4",
|
|
31
|
+
"@zag-js/types": "0.3.2"
|
|
35
32
|
},
|
|
36
33
|
"devDependencies": {
|
|
37
|
-
"
|
|
38
|
-
"@zag-js/utils": "0.
|
|
34
|
+
"clean-package": "2.2.0",
|
|
35
|
+
"@zag-js/dom-utils": "0.2.2",
|
|
36
|
+
"@zag-js/utils": "0.3.2"
|
|
37
|
+
},
|
|
38
|
+
"clean-package": "../../../clean-package.config.json",
|
|
39
|
+
"main": "dist/index.js",
|
|
40
|
+
"module": "dist/index.mjs",
|
|
41
|
+
"types": "dist/index.d.ts",
|
|
42
|
+
"exports": {
|
|
43
|
+
".": {
|
|
44
|
+
"types": "./dist/index.d.ts",
|
|
45
|
+
"import": "./dist/index.mjs",
|
|
46
|
+
"require": "./dist/index.js"
|
|
47
|
+
},
|
|
48
|
+
"./package.json": "./package.json"
|
|
39
49
|
},
|
|
40
50
|
"scripts": {
|
|
41
|
-
"build-fast": "tsup src
|
|
51
|
+
"build-fast": "tsup src",
|
|
42
52
|
"start": "pnpm build --watch",
|
|
43
|
-
"build": "tsup src
|
|
53
|
+
"build": "tsup src --dts",
|
|
44
54
|
"test": "jest --config ../../../jest.config.js --rootDir . --passWithNoTests",
|
|
45
55
|
"lint": "eslint src --ext .ts,.tsx",
|
|
46
56
|
"test-ci": "pnpm test --ci --runInBand",
|