@zag-js/toast 1.47.0 → 1.48.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.
Files changed (41) hide show
  1. package/dist/index.d.mts +10 -17
  2. package/dist/index.d.ts +10 -17
  3. package/dist/index.js +18 -45
  4. package/dist/index.mjs +5 -11
  5. package/dist/toast-group.connect.d.mts +4 -8
  6. package/dist/toast-group.connect.d.ts +4 -8
  7. package/dist/toast-group.connect.js +73 -97
  8. package/dist/toast-group.connect.mjs +68 -61
  9. package/dist/toast-group.machine.d.mts +2 -8
  10. package/dist/toast-group.machine.d.ts +2 -8
  11. package/dist/toast-group.machine.js +292 -346
  12. package/dist/toast-group.machine.mjs +287 -310
  13. package/dist/toast.anatomy.d.mts +2 -6
  14. package/dist/toast.anatomy.d.ts +2 -6
  15. package/dist/toast.anatomy.js +8 -40
  16. package/dist/toast.anatomy.mjs +4 -14
  17. package/dist/toast.connect.d.mts +4 -8
  18. package/dist/toast.connect.d.ts +4 -8
  19. package/dist/toast.connect.js +133 -158
  20. package/dist/toast.connect.mjs +128 -122
  21. package/dist/toast.dom.d.mts +19 -23
  22. package/dist/toast.dom.d.ts +19 -23
  23. package/dist/toast.dom.js +54 -83
  24. package/dist/toast.dom.mjs +39 -47
  25. package/dist/toast.machine.d.mts +2 -8
  26. package/dist/toast.machine.d.ts +2 -8
  27. package/dist/toast.machine.js +272 -300
  28. package/dist/toast.machine.mjs +267 -264
  29. package/dist/toast.store.d.mts +2 -8
  30. package/dist/toast.store.d.ts +2 -8
  31. package/dist/toast.store.js +344 -306
  32. package/dist/toast.store.mjs +340 -281
  33. package/dist/toast.types.d.mts +372 -374
  34. package/dist/toast.types.d.ts +372 -374
  35. package/dist/toast.types.js +4 -18
  36. package/dist/toast.types.mjs +1 -0
  37. package/dist/toast.utils.d.mts +10 -14
  38. package/dist/toast.utils.d.ts +10 -14
  39. package/dist/toast.utils.js +167 -217
  40. package/dist/toast.utils.mjs +157 -186
  41. package/package.json +9 -9
@@ -1,25 +1,21 @@
1
- import { Scope } from '@zag-js/core';
2
- import { Placement } from './toast.types.mjs';
3
- import '@zag-js/types';
4
- import '@zag-js/dom-query';
5
-
6
- declare const getRegionId: (placement: Placement) => string;
7
- declare const getRegionEl: (ctx: Scope, placement: Placement) => HTMLElement | null;
8
- declare const getToastEls: (ctx: Scope, placement: Placement) => HTMLElement[];
9
- declare const getRootId: (ctx: Scope) => string;
10
- declare const getRootEl: (ctx: Scope) => HTMLElement | null;
11
- declare const getTitleId: (ctx: Scope) => string;
12
- declare const getDescriptionId: (ctx: Scope) => string;
13
- declare const getTitleEl: (ctx: Scope) => HTMLElement | null;
14
- declare const getDescriptionEl: (ctx: Scope) => HTMLElement | null;
15
- declare const getCloseTriggerId: (ctx: Scope) => string;
1
+ import { Placement } from "./toast.types.mjs";
2
+ import { Scope } from "@zag-js/core";
3
+ export declare const getRegionId: (placement: Placement) => string;
4
+ export declare const getRegionEl: (ctx: Scope, placement: Placement) => HTMLElement | null;
5
+ export declare const getToastEls: (ctx: Scope, placement: Placement) => HTMLElement[];
6
+ export declare const getRootId: (ctx: Scope) => string;
7
+ export declare const getRootEl: (ctx: Scope) => HTMLElement | null;
8
+ export declare const getTitleId: (ctx: Scope) => string;
9
+ export declare const getDescriptionId: (ctx: Scope) => string;
10
+ export declare const getTitleEl: (ctx: Scope) => HTMLElement | null;
11
+ export declare const getDescriptionEl: (ctx: Scope) => HTMLElement | null;
12
+ export declare const getCloseTriggerId: (ctx: Scope) => string;
16
13
  interface ObserveContentOptions {
17
- filter?: ((el: Element) => boolean) | undefined;
18
- /** Called when the content's size may have changed */
19
- onChange: VoidFunction;
20
- /** Called when the content's DOM changes */
21
- onMutate?: VoidFunction | undefined;
14
+ filter?: ((el: Element) => boolean) | undefined;
15
+ /** Called when the content's size may have changed */
16
+ onChange: VoidFunction;
17
+ /** Called when the content's DOM changes */
18
+ onMutate?: VoidFunction | undefined;
22
19
  }
23
- declare function observeContent(rootEl: HTMLElement, options: ObserveContentOptions): () => void;
24
-
25
- export { getCloseTriggerId, getDescriptionEl, getDescriptionId, getRegionEl, getRegionId, getRootEl, getRootId, getTitleEl, getTitleId, getToastEls, observeContent };
20
+ export declare function observeContent(rootEl: HTMLElement, options: ObserveContentOptions): () => void;
21
+ export {};
@@ -1,25 +1,21 @@
1
- import { Scope } from '@zag-js/core';
2
- import { Placement } from './toast.types.js';
3
- import '@zag-js/types';
4
- import '@zag-js/dom-query';
5
-
6
- declare const getRegionId: (placement: Placement) => string;
7
- declare const getRegionEl: (ctx: Scope, placement: Placement) => HTMLElement | null;
8
- declare const getToastEls: (ctx: Scope, placement: Placement) => HTMLElement[];
9
- declare const getRootId: (ctx: Scope) => string;
10
- declare const getRootEl: (ctx: Scope) => HTMLElement | null;
11
- declare const getTitleId: (ctx: Scope) => string;
12
- declare const getDescriptionId: (ctx: Scope) => string;
13
- declare const getTitleEl: (ctx: Scope) => HTMLElement | null;
14
- declare const getDescriptionEl: (ctx: Scope) => HTMLElement | null;
15
- declare const getCloseTriggerId: (ctx: Scope) => string;
1
+ import { Placement } from "./toast.types.js";
2
+ import { Scope } from "@zag-js/core";
3
+ export declare const getRegionId: (placement: Placement) => string;
4
+ export declare const getRegionEl: (ctx: Scope, placement: Placement) => HTMLElement | null;
5
+ export declare const getToastEls: (ctx: Scope, placement: Placement) => HTMLElement[];
6
+ export declare const getRootId: (ctx: Scope) => string;
7
+ export declare const getRootEl: (ctx: Scope) => HTMLElement | null;
8
+ export declare const getTitleId: (ctx: Scope) => string;
9
+ export declare const getDescriptionId: (ctx: Scope) => string;
10
+ export declare const getTitleEl: (ctx: Scope) => HTMLElement | null;
11
+ export declare const getDescriptionEl: (ctx: Scope) => HTMLElement | null;
12
+ export declare const getCloseTriggerId: (ctx: Scope) => string;
16
13
  interface ObserveContentOptions {
17
- filter?: ((el: Element) => boolean) | undefined;
18
- /** Called when the content's size may have changed */
19
- onChange: VoidFunction;
20
- /** Called when the content's DOM changes */
21
- onMutate?: VoidFunction | undefined;
14
+ filter?: ((el: Element) => boolean) | undefined;
15
+ /** Called when the content's size may have changed */
16
+ onChange: VoidFunction;
17
+ /** Called when the content's DOM changes */
18
+ onMutate?: VoidFunction | undefined;
22
19
  }
23
- declare function observeContent(rootEl: HTMLElement, options: ObserveContentOptions): () => void;
24
-
25
- export { getCloseTriggerId, getDescriptionEl, getDescriptionId, getRegionEl, getRegionId, getRootEl, getRootId, getTitleEl, getTitleId, getToastEls, observeContent };
20
+ export declare function observeContent(rootEl: HTMLElement, options: ObserveContentOptions): () => void;
21
+ export {};
package/dist/toast.dom.js CHANGED
@@ -1,86 +1,57 @@
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
- getCloseTriggerId: () => getCloseTriggerId,
24
- getDescriptionEl: () => getDescriptionEl,
25
- getDescriptionId: () => getDescriptionId,
26
- getRegionEl: () => getRegionEl,
27
- getRegionId: () => getRegionId,
28
- getRootEl: () => getRootEl,
29
- getRootId: () => getRootId,
30
- getTitleEl: () => getTitleEl,
31
- getTitleId: () => getTitleId,
32
- getToastEls: () => getToastEls,
33
- observeContent: () => observeContent
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
34
4
  });
35
- module.exports = __toCommonJS(toast_dom_exports);
36
- var import_dom_query = require("@zag-js/dom-query");
37
- var import_utils = require("@zag-js/utils");
38
- var getRegionId = (placement) => `toast-group:${placement}`;
39
- var getRegionEl = (ctx, placement) => ctx.getById(`toast-group:${placement}`);
40
- var getToastEls = (ctx, placement) => (0, import_dom_query.queryAll)(getRegionEl(ctx, placement), "[data-scope=toast][data-part=root]");
41
- var getRootId = (ctx) => `toast:${ctx.id}`;
42
- var getRootEl = (ctx) => ctx.getById(getRootId(ctx));
43
- var getTitleId = (ctx) => `toast:${ctx.id}:title`;
44
- var getDescriptionId = (ctx) => `toast:${ctx.id}:description`;
45
- var getTitleEl = (ctx) => ctx.getById(getTitleId(ctx));
46
- var getDescriptionEl = (ctx) => ctx.getById(getDescriptionId(ctx));
47
- var getCloseTriggerId = (ctx) => `toast${ctx.id}:close`;
5
+ let _zag_js_dom_query = require("@zag-js/dom-query");
6
+ let _zag_js_utils = require("@zag-js/utils");
7
+ // src/toast.dom.ts
8
+ const getRegionId = (placement) => `toast-group:${placement}`;
9
+ const getRegionEl = (ctx, placement) => ctx.getById(`toast-group:${placement}`);
10
+ const getToastEls = (ctx, placement) => (0, _zag_js_dom_query.queryAll)(getRegionEl(ctx, placement), "[data-scope=toast][data-part=root]");
11
+ const getRootId = (ctx) => `toast:${ctx.id}`;
12
+ const getRootEl = (ctx) => ctx.getById(getRootId(ctx));
13
+ const getTitleId = (ctx) => `toast:${ctx.id}:title`;
14
+ const getDescriptionId = (ctx) => `toast:${ctx.id}:description`;
15
+ const getTitleEl = (ctx) => ctx.getById(getTitleId(ctx));
16
+ const getDescriptionEl = (ctx) => ctx.getById(getDescriptionId(ctx));
17
+ const getCloseTriggerId = (ctx) => `toast${ctx.id}:close`;
48
18
  function observeContent(rootEl, options) {
49
- const { filter = () => true, onChange, onMutate } = options;
50
- const win = (0, import_dom_query.getWindow)(rootEl);
51
- const frame = import_dom_query.AnimationFrame.create();
52
- const notify = () => frame.request(onChange);
53
- let stopObservingChildren;
54
- const observeChildren = () => {
55
- stopObservingChildren?.();
56
- const children = Array.from(rootEl.children).filter(filter);
57
- stopObservingChildren = (0, import_utils.callAll)(...children.map((child) => import_dom_query.resizeObserverBorderBox.observe(child, notify)));
58
- };
59
- observeChildren();
60
- const mutationObserver = new win.MutationObserver(() => {
61
- frame.cancel();
62
- onChange();
63
- onMutate?.();
64
- observeChildren();
65
- });
66
- mutationObserver.observe(rootEl, { childList: true, subtree: true, characterData: true });
67
- return () => {
68
- mutationObserver.disconnect();
69
- stopObservingChildren?.();
70
- frame.cancel();
71
- };
19
+ const { filter = () => true, onChange, onMutate } = options;
20
+ const win = (0, _zag_js_dom_query.getWindow)(rootEl);
21
+ const frame = _zag_js_dom_query.AnimationFrame.create();
22
+ const notify = () => frame.request(onChange);
23
+ let stopObservingChildren;
24
+ const observeChildren = () => {
25
+ stopObservingChildren?.();
26
+ const children = Array.from(rootEl.children).filter(filter);
27
+ stopObservingChildren = (0, _zag_js_utils.callAll)(...children.map((child) => _zag_js_dom_query.resizeObserverBorderBox.observe(child, notify)));
28
+ };
29
+ observeChildren();
30
+ const mutationObserver = new win.MutationObserver(() => {
31
+ frame.cancel();
32
+ onChange();
33
+ onMutate?.();
34
+ observeChildren();
35
+ });
36
+ mutationObserver.observe(rootEl, {
37
+ childList: true,
38
+ subtree: true,
39
+ characterData: true
40
+ });
41
+ return () => {
42
+ mutationObserver.disconnect();
43
+ stopObservingChildren?.();
44
+ frame.cancel();
45
+ };
72
46
  }
73
- // Annotate the CommonJS export names for ESM import in node:
74
- 0 && (module.exports = {
75
- getCloseTriggerId,
76
- getDescriptionEl,
77
- getDescriptionId,
78
- getRegionEl,
79
- getRegionId,
80
- getRootEl,
81
- getRootId,
82
- getTitleEl,
83
- getTitleId,
84
- getToastEls,
85
- observeContent
86
- });
47
+ exports.getCloseTriggerId = getCloseTriggerId;
48
+ exports.getDescriptionEl = getDescriptionEl;
49
+ exports.getDescriptionId = getDescriptionId;
50
+ exports.getRegionEl = getRegionEl;
51
+ exports.getRegionId = getRegionId;
52
+ exports.getRootEl = getRootEl;
53
+ exports.getRootId = getRootId;
54
+ exports.getTitleEl = getTitleEl;
55
+ exports.getTitleId = getTitleId;
56
+ exports.getToastEls = getToastEls;
57
+ exports.observeContent = observeContent;
@@ -1,51 +1,43 @@
1
- // src/toast.dom.ts
2
1
  import { AnimationFrame, getWindow, queryAll, resizeObserverBorderBox } from "@zag-js/dom-query";
3
2
  import { callAll } from "@zag-js/utils";
4
- var getRegionId = (placement) => `toast-group:${placement}`;
5
- var getRegionEl = (ctx, placement) => ctx.getById(`toast-group:${placement}`);
6
- var getToastEls = (ctx, placement) => queryAll(getRegionEl(ctx, placement), "[data-scope=toast][data-part=root]");
7
- var getRootId = (ctx) => `toast:${ctx.id}`;
8
- var getRootEl = (ctx) => ctx.getById(getRootId(ctx));
9
- var getTitleId = (ctx) => `toast:${ctx.id}:title`;
10
- var getDescriptionId = (ctx) => `toast:${ctx.id}:description`;
11
- var getTitleEl = (ctx) => ctx.getById(getTitleId(ctx));
12
- var getDescriptionEl = (ctx) => ctx.getById(getDescriptionId(ctx));
13
- var getCloseTriggerId = (ctx) => `toast${ctx.id}:close`;
3
+ // src/toast.dom.ts
4
+ const getRegionId = (placement) => `toast-group:${placement}`;
5
+ const getRegionEl = (ctx, placement) => ctx.getById(`toast-group:${placement}`);
6
+ const getToastEls = (ctx, placement) => queryAll(getRegionEl(ctx, placement), "[data-scope=toast][data-part=root]");
7
+ const getRootId = (ctx) => `toast:${ctx.id}`;
8
+ const getRootEl = (ctx) => ctx.getById(getRootId(ctx));
9
+ const getTitleId = (ctx) => `toast:${ctx.id}:title`;
10
+ const getDescriptionId = (ctx) => `toast:${ctx.id}:description`;
11
+ const getTitleEl = (ctx) => ctx.getById(getTitleId(ctx));
12
+ const getDescriptionEl = (ctx) => ctx.getById(getDescriptionId(ctx));
13
+ const getCloseTriggerId = (ctx) => `toast${ctx.id}:close`;
14
14
  function observeContent(rootEl, options) {
15
- const { filter = () => true, onChange, onMutate } = options;
16
- const win = getWindow(rootEl);
17
- const frame = AnimationFrame.create();
18
- const notify = () => frame.request(onChange);
19
- let stopObservingChildren;
20
- const observeChildren = () => {
21
- stopObservingChildren?.();
22
- const children = Array.from(rootEl.children).filter(filter);
23
- stopObservingChildren = callAll(...children.map((child) => resizeObserverBorderBox.observe(child, notify)));
24
- };
25
- observeChildren();
26
- const mutationObserver = new win.MutationObserver(() => {
27
- frame.cancel();
28
- onChange();
29
- onMutate?.();
30
- observeChildren();
31
- });
32
- mutationObserver.observe(rootEl, { childList: true, subtree: true, characterData: true });
33
- return () => {
34
- mutationObserver.disconnect();
35
- stopObservingChildren?.();
36
- frame.cancel();
37
- };
15
+ const { filter = () => true, onChange, onMutate } = options;
16
+ const win = getWindow(rootEl);
17
+ const frame = AnimationFrame.create();
18
+ const notify = () => frame.request(onChange);
19
+ let stopObservingChildren;
20
+ const observeChildren = () => {
21
+ stopObservingChildren?.();
22
+ const children = Array.from(rootEl.children).filter(filter);
23
+ stopObservingChildren = callAll(...children.map((child) => resizeObserverBorderBox.observe(child, notify)));
24
+ };
25
+ observeChildren();
26
+ const mutationObserver = new win.MutationObserver(() => {
27
+ frame.cancel();
28
+ onChange();
29
+ onMutate?.();
30
+ observeChildren();
31
+ });
32
+ mutationObserver.observe(rootEl, {
33
+ childList: true,
34
+ subtree: true,
35
+ characterData: true
36
+ });
37
+ return () => {
38
+ mutationObserver.disconnect();
39
+ stopObservingChildren?.();
40
+ frame.cancel();
41
+ };
38
42
  }
39
- export {
40
- getCloseTriggerId,
41
- getDescriptionEl,
42
- getDescriptionId,
43
- getRegionEl,
44
- getRegionId,
45
- getRootEl,
46
- getRootId,
47
- getTitleEl,
48
- getTitleId,
49
- getToastEls,
50
- observeContent
51
- };
43
+ export { getCloseTriggerId, getDescriptionEl, getDescriptionId, getRegionEl, getRegionId, getRootEl, getRootId, getTitleEl, getTitleId, getToastEls, observeContent };
@@ -1,8 +1,2 @@
1
- import * as _zag_js_core from '@zag-js/core';
2
- import { ToastSchema } from './toast.types.mjs';
3
- import '@zag-js/types';
4
- import '@zag-js/dom-query';
5
-
6
- declare const machine: _zag_js_core.Machine<ToastSchema>;
7
-
8
- export { machine };
1
+ import { ToastSchema } from "./toast.types.mjs";
2
+ export declare const machine: import("@zag-js/core").Machine<ToastSchema>;
@@ -1,8 +1,2 @@
1
- import * as _zag_js_core from '@zag-js/core';
2
- import { ToastSchema } from './toast.types.js';
3
- import '@zag-js/types';
4
- import '@zag-js/dom-query';
5
-
6
- declare const machine: _zag_js_core.Machine<ToastSchema>;
7
-
8
- export { machine };
1
+ import { ToastSchema } from "./toast.types.js";
2
+ export declare const machine: import("@zag-js/core").Machine<ToastSchema>;