@zag-js/toast 0.2.6 → 0.2.8

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.
@@ -0,0 +1,10 @@
1
+ import {
2
+ groupMachine
3
+ } from "./chunk-LOTG5P4K.mjs";
4
+ import "./chunk-KJLVUGML.mjs";
5
+ import "./chunk-YVYADWQR.mjs";
6
+ import "./chunk-LOJTIJID.mjs";
7
+ import "./chunk-SMQXX7JA.mjs";
8
+ export {
9
+ groupMachine
10
+ };
@@ -0,0 +1,6 @@
1
+ import * as _zag_js_anatomy from '@zag-js/anatomy';
2
+
3
+ declare const anatomy: _zag_js_anatomy.AnatomyInstance<"group" | "title" | "root" | "description" | "closeTrigger">;
4
+ declare const parts: Record<"group" | "title" | "root" | "description" | "closeTrigger", _zag_js_anatomy.AnatomyPart>;
5
+
6
+ export { anatomy, parts };
@@ -0,0 +1,34 @@
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.anatomy.ts
21
+ var toast_anatomy_exports = {};
22
+ __export(toast_anatomy_exports, {
23
+ anatomy: () => anatomy,
24
+ parts: () => parts
25
+ });
26
+ module.exports = __toCommonJS(toast_anatomy_exports);
27
+ var import_anatomy = require("@zag-js/anatomy");
28
+ var anatomy = (0, import_anatomy.createAnatomy)("toast").parts("group", "root", "title", "description", "closeTrigger");
29
+ var parts = anatomy.build();
30
+ // Annotate the CommonJS export names for ESM import in node:
31
+ 0 && (module.exports = {
32
+ anatomy,
33
+ parts
34
+ });
@@ -0,0 +1,8 @@
1
+ import {
2
+ anatomy,
3
+ parts
4
+ } from "./chunk-GQHI2OMI.mjs";
5
+ export {
6
+ anatomy,
7
+ parts
8
+ };
@@ -0,0 +1,23 @@
1
+ import { State, Send, Type, Placement } from './toast.types.js';
2
+ import { PropTypes, NormalizeProps } from '@zag-js/types';
3
+ import '@zag-js/core';
4
+
5
+ declare function connect<T extends PropTypes>(state: State, send: Send, normalize: NormalizeProps<T>): {
6
+ type: Type;
7
+ title: string | undefined;
8
+ description: string | undefined;
9
+ placement: Placement;
10
+ isVisible: boolean;
11
+ isPaused: boolean;
12
+ isRtl: boolean;
13
+ pause(): void;
14
+ resume(): void;
15
+ dismiss(): void;
16
+ rootProps: T["element"];
17
+ titleProps: T["element"];
18
+ descriptionProps: T["element"];
19
+ closeTriggerProps: T["button"];
20
+ render(): any;
21
+ };
22
+
23
+ export { connect };
@@ -0,0 +1,194 @@
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.connect.ts
21
+ var toast_connect_exports = {};
22
+ __export(toast_connect_exports, {
23
+ connect: () => connect
24
+ });
25
+ module.exports = __toCommonJS(toast_connect_exports);
26
+
27
+ // ../../utilities/dom/src/attrs.ts
28
+ var dataAttr = (guard) => {
29
+ return guard ? "" : void 0;
30
+ };
31
+
32
+ // ../../utilities/dom/src/query.ts
33
+ function isDocument(el) {
34
+ return el.nodeType === Node.DOCUMENT_NODE;
35
+ }
36
+ function isWindow(value) {
37
+ return (value == null ? void 0 : value.toString()) === "[object Window]";
38
+ }
39
+ function getDocument(el) {
40
+ var _a;
41
+ if (isWindow(el))
42
+ return el.document;
43
+ if (isDocument(el))
44
+ return el;
45
+ return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
46
+ }
47
+ function defineDomHelpers(helpers) {
48
+ const dom2 = {
49
+ getRootNode: (ctx) => {
50
+ var _a, _b;
51
+ return (_b = (_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) != null ? _b : document;
52
+ },
53
+ getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
54
+ getWin: (ctx) => {
55
+ var _a;
56
+ return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
57
+ },
58
+ getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
59
+ getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
60
+ };
61
+ return {
62
+ ...dom2,
63
+ ...helpers
64
+ };
65
+ }
66
+
67
+ // src/toast.anatomy.ts
68
+ var import_anatomy = require("@zag-js/anatomy");
69
+ var anatomy = (0, import_anatomy.createAnatomy)("toast").parts("group", "root", "title", "description", "closeTrigger");
70
+ var parts = anatomy.build();
71
+
72
+ // src/toast.dom.ts
73
+ var dom = defineDomHelpers({
74
+ getGroupId: (placement) => `toast-group:${placement}`,
75
+ getRootId: (ctx) => `toast:${ctx.id}`,
76
+ getTitleId: (ctx) => `toast:${ctx.id}:title`,
77
+ getDescriptionId: (ctx) => `toast:${ctx.id}:description`,
78
+ getCloseTriggerId: (ctx) => `toast${ctx.id}:close`,
79
+ getPortalId: (ctx) => `toast-portal:${ctx.id}`,
80
+ getPortalEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getPortalId(ctx)),
81
+ createPortalEl: (ctx) => {
82
+ const existing = dom.getPortalEl(ctx);
83
+ if (existing)
84
+ return existing;
85
+ const portal = dom.getDoc(ctx).createElement("toast-portal");
86
+ portal.id = dom.getPortalId(ctx);
87
+ return portal;
88
+ }
89
+ });
90
+
91
+ // src/toast.connect.ts
92
+ function connect(state, send, normalize) {
93
+ const isVisible = state.hasTag("visible");
94
+ const isPaused = state.hasTag("paused");
95
+ const pauseOnInteraction = state.context.pauseOnInteraction;
96
+ const placement = state.context.placement;
97
+ return {
98
+ type: state.context.type,
99
+ title: state.context.title,
100
+ description: state.context.description,
101
+ placement,
102
+ isVisible,
103
+ isPaused,
104
+ isRtl: state.context.dir === "rtl",
105
+ pause() {
106
+ send("PAUSE");
107
+ },
108
+ resume() {
109
+ send("RESUME");
110
+ },
111
+ dismiss() {
112
+ send("DISMISS");
113
+ },
114
+ rootProps: normalize.element({
115
+ ...parts.root.attrs,
116
+ dir: state.context.dir,
117
+ id: dom.getRootId(state.context),
118
+ "data-open": dataAttr(isVisible),
119
+ "data-type": state.context.type,
120
+ "data-placement": placement,
121
+ role: "status",
122
+ "aria-atomic": "true",
123
+ tabIndex: 0,
124
+ style: {
125
+ position: "relative",
126
+ pointerEvents: "auto",
127
+ margin: "calc(var(--toast-gutter) / 2)",
128
+ "--remove-delay": `${state.context.removeDelay}ms`,
129
+ "--duration": `${state.context.duration}ms`
130
+ },
131
+ onKeyDown(event) {
132
+ if (event.key == "Escape") {
133
+ send("DISMISS");
134
+ event.preventDefault();
135
+ }
136
+ },
137
+ onFocus() {
138
+ if (pauseOnInteraction) {
139
+ send("PAUSE");
140
+ }
141
+ },
142
+ onBlur() {
143
+ if (pauseOnInteraction) {
144
+ send("RESUME");
145
+ }
146
+ },
147
+ onPointerEnter() {
148
+ if (pauseOnInteraction) {
149
+ send("PAUSE");
150
+ }
151
+ },
152
+ onPointerLeave() {
153
+ if (pauseOnInteraction) {
154
+ send("RESUME");
155
+ }
156
+ }
157
+ }),
158
+ titleProps: normalize.element({
159
+ ...parts.title.attrs,
160
+ id: dom.getTitleId(state.context)
161
+ }),
162
+ descriptionProps: normalize.element({
163
+ ...parts.description.attrs,
164
+ id: dom.getDescriptionId(state.context)
165
+ }),
166
+ closeTriggerProps: normalize.button({
167
+ id: dom.getCloseTriggerId(state.context),
168
+ ...parts.closeTrigger.attrs,
169
+ type: "button",
170
+ "aria-label": "Dismiss notification",
171
+ onClick() {
172
+ send("DISMISS");
173
+ }
174
+ }),
175
+ render() {
176
+ var _a, _b;
177
+ return (_b = (_a = state.context).render) == null ? void 0 : _b.call(_a, {
178
+ id: state.context.id,
179
+ type: state.context.type,
180
+ duration: state.context.duration,
181
+ title: state.context.title,
182
+ placement: state.context.placement,
183
+ description: state.context.description,
184
+ dismiss() {
185
+ send("DISMISS");
186
+ }
187
+ });
188
+ }
189
+ };
190
+ }
191
+ // Annotate the CommonJS export names for ESM import in node:
192
+ 0 && (module.exports = {
193
+ connect
194
+ });
@@ -0,0 +1,8 @@
1
+ import {
2
+ connect
3
+ } from "./chunk-EMY6MMVS.mjs";
4
+ import "./chunk-GQHI2OMI.mjs";
5
+ import "./chunk-SMQXX7JA.mjs";
6
+ export {
7
+ connect
8
+ };
@@ -0,0 +1,32 @@
1
+ import { Placement, MachineContext, GroupMachineContext } from './toast.types.js';
2
+ import '@zag-js/core';
3
+ import '@zag-js/types';
4
+
5
+ declare const dom: {
6
+ getRootNode: (ctx: {
7
+ getRootNode?: (() => Node | Document | ShadowRoot) | undefined;
8
+ }) => Document | ShadowRoot;
9
+ getDoc: (ctx: {
10
+ getRootNode?: (() => Node | Document | ShadowRoot) | undefined;
11
+ }) => Document;
12
+ getWin: (ctx: {
13
+ getRootNode?: (() => Node | Document | ShadowRoot) | undefined;
14
+ }) => Window & typeof globalThis;
15
+ getActiveElement: (ctx: {
16
+ getRootNode?: (() => Node | Document | ShadowRoot) | undefined;
17
+ }) => HTMLElement | null;
18
+ getById: <T = HTMLElement>(ctx: {
19
+ getRootNode?: (() => Node | Document | ShadowRoot) | undefined;
20
+ }, id: string) => T | null;
21
+ } & {
22
+ getGroupId: (placement: Placement) => string;
23
+ getRootId: (ctx: MachineContext) => string;
24
+ getTitleId: (ctx: MachineContext) => string;
25
+ getDescriptionId: (ctx: MachineContext) => string;
26
+ getCloseTriggerId: (ctx: MachineContext) => string;
27
+ getPortalId: (ctx: GroupMachineContext) => string;
28
+ getPortalEl: (ctx: GroupMachineContext) => HTMLElement | null;
29
+ createPortalEl: (ctx: GroupMachineContext) => HTMLElement;
30
+ };
31
+
32
+ export { dom };
@@ -0,0 +1,83 @@
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.dom.ts
21
+ var toast_dom_exports = {};
22
+ __export(toast_dom_exports, {
23
+ dom: () => dom
24
+ });
25
+ module.exports = __toCommonJS(toast_dom_exports);
26
+
27
+ // ../../utilities/dom/src/query.ts
28
+ function isDocument(el) {
29
+ return el.nodeType === Node.DOCUMENT_NODE;
30
+ }
31
+ function isWindow(value) {
32
+ return (value == null ? void 0 : value.toString()) === "[object Window]";
33
+ }
34
+ function getDocument(el) {
35
+ var _a;
36
+ if (isWindow(el))
37
+ return el.document;
38
+ if (isDocument(el))
39
+ return el;
40
+ return (_a = el == null ? void 0 : el.ownerDocument) != null ? _a : document;
41
+ }
42
+ function defineDomHelpers(helpers) {
43
+ const dom2 = {
44
+ getRootNode: (ctx) => {
45
+ var _a, _b;
46
+ return (_b = (_a = ctx.getRootNode) == null ? void 0 : _a.call(ctx)) != null ? _b : document;
47
+ },
48
+ getDoc: (ctx) => getDocument(dom2.getRootNode(ctx)),
49
+ getWin: (ctx) => {
50
+ var _a;
51
+ return (_a = dom2.getDoc(ctx).defaultView) != null ? _a : window;
52
+ },
53
+ getActiveElement: (ctx) => dom2.getDoc(ctx).activeElement,
54
+ getById: (ctx, id) => dom2.getRootNode(ctx).getElementById(id)
55
+ };
56
+ return {
57
+ ...dom2,
58
+ ...helpers
59
+ };
60
+ }
61
+
62
+ // src/toast.dom.ts
63
+ var dom = defineDomHelpers({
64
+ getGroupId: (placement) => `toast-group:${placement}`,
65
+ getRootId: (ctx) => `toast:${ctx.id}`,
66
+ getTitleId: (ctx) => `toast:${ctx.id}:title`,
67
+ getDescriptionId: (ctx) => `toast:${ctx.id}:description`,
68
+ getCloseTriggerId: (ctx) => `toast${ctx.id}:close`,
69
+ getPortalId: (ctx) => `toast-portal:${ctx.id}`,
70
+ getPortalEl: (ctx) => dom.getDoc(ctx).getElementById(dom.getPortalId(ctx)),
71
+ createPortalEl: (ctx) => {
72
+ const existing = dom.getPortalEl(ctx);
73
+ if (existing)
74
+ return existing;
75
+ const portal = dom.getDoc(ctx).createElement("toast-portal");
76
+ portal.id = dom.getPortalId(ctx);
77
+ return portal;
78
+ }
79
+ });
80
+ // Annotate the CommonJS export names for ESM import in node:
81
+ 0 && (module.exports = {
82
+ dom
83
+ });
@@ -0,0 +1,6 @@
1
+ import {
2
+ dom
3
+ } from "./chunk-SMQXX7JA.mjs";
4
+ export {
5
+ dom
6
+ };
@@ -0,0 +1,7 @@
1
+ import * as _zag_js_core from '@zag-js/core';
2
+ import { Options, MachineContext, MachineState } from './toast.types.js';
3
+ import '@zag-js/types';
4
+
5
+ declare function createToastMachine(options?: Options): _zag_js_core.Machine<MachineContext, MachineState, _zag_js_core.StateMachine.AnyEventObject>;
6
+
7
+ export { createToastMachine };