@zag-js/toast 2.0.0-next.2 → 2.0.0-next.4

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 (45) 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 +82 -103
  8. package/dist/toast-group.connect.mjs +77 -67
  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 +295 -290
  12. package/dist/toast-group.machine.mjs +290 -254
  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 +176 -160
  20. package/dist/toast.connect.mjs +171 -124
  21. package/dist/toast.dom.d.mts +21 -14
  22. package/dist/toast.dom.d.ts +21 -14
  23. package/dist/toast.dom.js +50 -48
  24. package/dist/toast.dom.mjs +35 -17
  25. package/dist/toast.machine.d.mts +2 -8
  26. package/dist/toast.machine.d.ts +2 -8
  27. package/dist/toast.machine.js +404 -288
  28. package/dist/toast.machine.mjs +400 -253
  29. package/dist/toast.store.d.mts +2 -8
  30. package/dist/toast.store.d.ts +2 -8
  31. package/dist/toast.store.js +345 -263
  32. package/dist/toast.store.mjs +341 -238
  33. package/dist/toast.types.d.mts +460 -427
  34. package/dist/toast.types.d.ts +460 -427
  35. package/dist/toast.types.js +4 -18
  36. package/dist/toast.types.mjs +1 -0
  37. package/dist/toast.utils.d.mts +10 -13
  38. package/dist/toast.utils.d.ts +10 -13
  39. package/dist/toast.utils.js +185 -198
  40. package/dist/toast.utils.mjs +175 -168
  41. package/dist/utils/swipe.d.mts +16 -0
  42. package/dist/utils/swipe.d.ts +16 -0
  43. package/dist/utils/swipe.js +100 -0
  44. package/dist/utils/swipe.mjs +93 -0
  45. package/package.json +8 -8
@@ -1,128 +1,175 @@
1
- // src/toast.connect.ts
2
- import { dataAttr } from "@zag-js/dom-query";
3
- import { mergeWithDefault } from "@zag-js/utils";
4
1
  import { parts } from "./toast.anatomy.mjs";
5
- import * as dom from "./toast.dom.mjs";
2
+ import { getDescriptionId, getTitleId } from "./toast.dom.mjs";
6
3
  import { getGhostAfterStyle, getGhostBeforeStyle, getPlacementStyle } from "./toast.utils.mjs";
7
- var defaultTranslations = {
8
- closeTriggerLabel: "Dismiss notification"
9
- };
4
+ import { dataAttr, getEventTarget } from "@zag-js/dom-query";
5
+ import { mergeWithDefault } from "@zag-js/utils";
6
+ // src/toast.connect.ts
7
+ const defaultTranslations = { closeTriggerLabel: "Dismiss notification" };
8
+ const SWIPE_IGNORE_SELECTOR = "button,a,input,textarea,select,[role=\"button\"],[data-swipe-ignore]";
10
9
  function connect(service, normalize) {
11
- const { state, send, prop, scope, context, computed } = service;
12
- const translations = mergeWithDefault(defaultTranslations, prop("translations"));
13
- const visible = state.hasTag("visible");
14
- const paused = state.hasTag("paused");
15
- const mounted = context.get("mounted");
16
- const frontmost = computed("frontmost");
17
- const placement = prop("parent").computed("placement");
18
- const type = prop("type");
19
- const stacked = prop("stacked");
20
- const title = prop("title");
21
- const description = prop("description");
22
- const action = prop("action");
23
- const [side, align = "center"] = placement.split("-");
24
- function getRootState() {
25
- return { visible, paused, mounted, frontmost, stacked: !!stacked, type, placement, side, align };
26
- }
27
- return {
28
- type,
29
- title,
30
- description,
31
- placement,
32
- visible,
33
- paused,
34
- closable: !!prop("closable"),
35
- pause() {
36
- send({ type: "PAUSE" });
37
- },
38
- resume() {
39
- send({ type: "RESUME" });
40
- },
41
- dismiss() {
42
- send({ type: "DISMISS", src: "programmatic" });
43
- },
44
- getRootState,
45
- getRootProps() {
46
- const rootState = getRootState();
47
- return normalize.element({
48
- ...parts.root.attrs(scope.id),
49
- dir: prop("dir"),
50
- "data-state": rootState.visible ? "open" : "closed",
51
- "data-type": rootState.type,
52
- "data-placement": rootState.placement,
53
- "data-align": rootState.align,
54
- "data-side": rootState.side,
55
- "data-mounted": dataAttr(rootState.mounted),
56
- "data-paused": dataAttr(rootState.paused),
57
- "data-first": dataAttr(rootState.frontmost),
58
- "data-sibling": dataAttr(!rootState.frontmost),
59
- "data-stack": dataAttr(rootState.stacked),
60
- "data-overlap": dataAttr(!rootState.stacked),
61
- role: "status",
62
- "aria-atomic": "true",
63
- "aria-describedby": description ? dom.getDescriptionId(scope) : void 0,
64
- "aria-labelledby": title ? dom.getTitleId(scope) : void 0,
65
- tabIndex: 0,
66
- style: getPlacementStyle(service, visible),
67
- onKeyDown(event) {
68
- if (event.defaultPrevented) return;
69
- if (event.key == "Escape") {
70
- send({ type: "DISMISS", src: "keyboard" });
71
- event.preventDefault();
72
- }
73
- }
74
- });
75
- },
76
- /* Leave a ghost div to avoid setting hover to false when transitioning out */
77
- getGhostBeforeProps() {
78
- return normalize.element({
79
- "data-ghost": "before",
80
- style: getGhostBeforeStyle(service, visible)
81
- });
82
- },
83
- /* Needed to avoid setting hover to false when in between toasts */
84
- getGhostAfterProps() {
85
- return normalize.element({
86
- "data-ghost": "after",
87
- style: getGhostAfterStyle()
88
- });
89
- },
90
- getTitleProps() {
91
- return normalize.element({
92
- ...parts.title.attrs(scope.id),
93
- id: dom.getTitleId(scope)
94
- });
95
- },
96
- getDescriptionProps() {
97
- return normalize.element({
98
- ...parts.description.attrs(scope.id),
99
- id: dom.getDescriptionId(scope)
100
- });
101
- },
102
- getActionTriggerProps() {
103
- return normalize.button({
104
- ...parts.actionTrigger.attrs(scope.id),
105
- type: "button",
106
- onClick(event) {
107
- if (event.defaultPrevented) return;
108
- action?.onClick?.();
109
- send({ type: "DISMISS", src: "user" });
110
- }
111
- });
112
- },
113
- getCloseTriggerProps() {
114
- return normalize.button({
115
- ...parts.closeTrigger.attrs(scope.id),
116
- type: "button",
117
- "aria-label": translations?.closeTriggerLabel,
118
- onClick(event) {
119
- if (event.defaultPrevented) return;
120
- send({ type: "DISMISS", src: "user" });
121
- }
122
- });
123
- }
124
- };
10
+ const { state, send, prop, scope, context, computed } = service;
11
+ const translations = mergeWithDefault(defaultTranslations, prop("translations"));
12
+ const visible = state.hasTag("visible");
13
+ const paused = state.hasTag("paused");
14
+ const mounted = context.get("mounted");
15
+ const rendered = context.get("rendered");
16
+ const frontmost = computed("frontmost");
17
+ const placement = prop("parent").computed("placement");
18
+ const type = prop("type");
19
+ const stacked = prop("parent").state.matches("stack");
20
+ const title = prop("title");
21
+ const description = prop("description");
22
+ const action = prop("action");
23
+ const [side, align = "center"] = placement.split("-");
24
+ const swiping = state.matches("visible:swiping");
25
+ const swipeDirection = context.get("swipeDirection");
26
+ function getRootState() {
27
+ return {
28
+ visible,
29
+ paused,
30
+ mounted,
31
+ frontmost,
32
+ stacked: !!stacked,
33
+ type,
34
+ placement,
35
+ side,
36
+ align,
37
+ swiping,
38
+ swipeDirection
39
+ };
40
+ }
41
+ return {
42
+ type,
43
+ title,
44
+ description,
45
+ placement,
46
+ visible,
47
+ paused,
48
+ closable: !!prop("closable"),
49
+ pause() {
50
+ prop("parent").prop("store").pause(prop("id"));
51
+ },
52
+ resume() {
53
+ prop("parent").prop("store").resume(prop("id"));
54
+ },
55
+ dismiss() {
56
+ send({
57
+ type: "DISMISS",
58
+ src: "programmatic"
59
+ });
60
+ },
61
+ getRootState,
62
+ getRootProps() {
63
+ const rootState = getRootState();
64
+ return normalize.element({
65
+ ...parts.root.attrs(scope.id),
66
+ dir: prop("dir"),
67
+ "data-state": rootState.visible ? "open" : "closed",
68
+ "data-type": rootState.type,
69
+ "data-placement": rootState.placement,
70
+ "data-align": rootState.align,
71
+ "data-side": rootState.side,
72
+ "data-mounted": dataAttr(rootState.mounted),
73
+ "data-paused": dataAttr(rootState.paused),
74
+ "data-first": dataAttr(rootState.frontmost),
75
+ "data-sibling": dataAttr(!rootState.frontmost),
76
+ "data-stack": dataAttr(rootState.stacked),
77
+ "data-overlap": dataAttr(!rootState.stacked),
78
+ "data-swiping": dataAttr(rootState.swiping),
79
+ "data-swipe-direction": rootState.swipeDirection ?? void 0,
80
+ role: "status",
81
+ "aria-atomic": "true",
82
+ "aria-describedby": description && rendered.description ? getDescriptionId(scope) : void 0,
83
+ "aria-labelledby": title && rendered.title ? getTitleId(scope) : void 0,
84
+ tabIndex: 0,
85
+ style: getPlacementStyle(service, visible),
86
+ onKeyDown(event) {
87
+ if (event.defaultPrevented) return;
88
+ if (event.key == "Escape") {
89
+ send({
90
+ type: "DISMISS",
91
+ src: "keyboard"
92
+ });
93
+ event.preventDefault();
94
+ }
95
+ },
96
+ onPointerDown(event) {
97
+ if (event.defaultPrevented || event.button !== 0) return;
98
+ if (getEventTarget(event)?.closest(SWIPE_IGNORE_SELECTOR)) return;
99
+ send({
100
+ type: "SWIPE.START",
101
+ point: {
102
+ x: event.clientX,
103
+ y: event.clientY
104
+ },
105
+ pointerId: event.pointerId
106
+ });
107
+ }
108
+ });
109
+ },
110
+ getContentProps() {
111
+ const rootState = getRootState();
112
+ return normalize.element({
113
+ ...parts.content.attrs(scope.id),
114
+ "data-state": rootState.visible ? "open" : "closed",
115
+ "data-first": dataAttr(rootState.frontmost),
116
+ "data-sibling": dataAttr(!rootState.frontmost),
117
+ "data-stack": dataAttr(rootState.stacked),
118
+ "data-overlap": dataAttr(!rootState.stacked)
119
+ });
120
+ },
121
+ getGhostBeforeProps() {
122
+ return normalize.element({
123
+ "data-ghost": "before",
124
+ style: getGhostBeforeStyle(service, visible)
125
+ });
126
+ },
127
+ getGhostAfterProps() {
128
+ return normalize.element({
129
+ "data-ghost": "after",
130
+ style: getGhostAfterStyle()
131
+ });
132
+ },
133
+ getTitleProps() {
134
+ return normalize.element({
135
+ ...parts.title.attrs(scope.id),
136
+ id: getTitleId(scope)
137
+ });
138
+ },
139
+ getDescriptionProps() {
140
+ return normalize.element({
141
+ ...parts.description.attrs(scope.id),
142
+ id: getDescriptionId(scope)
143
+ });
144
+ },
145
+ getActionTriggerProps() {
146
+ return normalize.button({
147
+ ...parts.actionTrigger.attrs(scope.id),
148
+ type: "button",
149
+ onClick(event) {
150
+ if (event.defaultPrevented) return;
151
+ action?.onClick?.();
152
+ send({
153
+ type: "DISMISS",
154
+ src: "user"
155
+ });
156
+ }
157
+ });
158
+ },
159
+ getCloseTriggerProps() {
160
+ return normalize.button({
161
+ ...parts.closeTrigger.attrs(scope.id),
162
+ type: "button",
163
+ "aria-label": translations?.closeTriggerLabel,
164
+ onClick(event) {
165
+ if (event.defaultPrevented) return;
166
+ send({
167
+ type: "DISMISS",
168
+ src: "user"
169
+ });
170
+ }
171
+ });
172
+ }
173
+ };
125
174
  }
126
- export {
127
- connect
128
- };
175
+ export { connect };
@@ -1,14 +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 getRootId: (ctx: Scope) => string;
8
- declare const getTitleId: (ctx: Scope) => string;
9
- declare const getDescriptionId: (ctx: Scope) => string;
10
- declare const getCloseTriggerId: (ctx: Scope) => string;
11
- declare const getRegionEl: (ctx: Scope, placement: Placement) => HTMLElement | null;
12
- declare const getRootEl: (ctx: Scope) => HTMLElement | null;
13
-
14
- export { getCloseTriggerId, getDescriptionId, getRegionEl, getRegionId, getRootEl, getRootId, getTitleId };
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 getRootId: (ctx: Scope) => string;
5
+ export declare const getTitleId: (ctx: Scope) => string;
6
+ export declare const getDescriptionId: (ctx: Scope) => string;
7
+ export declare const getCloseTriggerId: (ctx: Scope) => string;
8
+ export declare const getRegionEl: (ctx: Scope, placement: Placement) => HTMLElement | null;
9
+ export declare const getToastEls: (ctx: Scope, placement: Placement) => HTMLElement[];
10
+ export declare const getRootEl: (ctx: Scope) => HTMLElement | null;
11
+ export declare const getContentEl: (ctx: Scope) => HTMLElement | null;
12
+ export declare const getTitleEl: (ctx: Scope) => HTMLElement | null;
13
+ export declare const getDescriptionEl: (ctx: Scope) => HTMLElement | null;
14
+ interface ObserveContentOptions {
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;
19
+ }
20
+ export declare function observeContent(contentEl: HTMLElement, options: ObserveContentOptions): () => void;
21
+ export {};
@@ -1,14 +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 getRootId: (ctx: Scope) => string;
8
- declare const getTitleId: (ctx: Scope) => string;
9
- declare const getDescriptionId: (ctx: Scope) => string;
10
- declare const getCloseTriggerId: (ctx: Scope) => string;
11
- declare const getRegionEl: (ctx: Scope, placement: Placement) => HTMLElement | null;
12
- declare const getRootEl: (ctx: Scope) => HTMLElement | null;
13
-
14
- export { getCloseTriggerId, getDescriptionId, getRegionEl, getRegionId, getRootEl, getRootId, getTitleId };
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 getRootId: (ctx: Scope) => string;
5
+ export declare const getTitleId: (ctx: Scope) => string;
6
+ export declare const getDescriptionId: (ctx: Scope) => string;
7
+ export declare const getCloseTriggerId: (ctx: Scope) => string;
8
+ export declare const getRegionEl: (ctx: Scope, placement: Placement) => HTMLElement | null;
9
+ export declare const getToastEls: (ctx: Scope, placement: Placement) => HTMLElement[];
10
+ export declare const getRootEl: (ctx: Scope) => HTMLElement | null;
11
+ export declare const getContentEl: (ctx: Scope) => HTMLElement | null;
12
+ export declare const getTitleEl: (ctx: Scope) => HTMLElement | null;
13
+ export declare const getDescriptionEl: (ctx: Scope) => HTMLElement | null;
14
+ interface ObserveContentOptions {
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;
19
+ }
20
+ export declare function observeContent(contentEl: HTMLElement, options: ObserveContentOptions): () => void;
21
+ export {};
package/dist/toast.dom.js CHANGED
@@ -1,49 +1,51 @@
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
- getDescriptionId: () => getDescriptionId,
25
- getRegionEl: () => getRegionEl,
26
- getRegionId: () => getRegionId,
27
- getRootEl: () => getRootEl,
28
- getRootId: () => getRootId,
29
- getTitleId: () => getTitleId
30
- });
31
- module.exports = __toCommonJS(toast_dom_exports);
32
- var import_toast = require("./toast.anatomy.js");
33
- var getRegionId = (placement) => `toast-group-${placement}`;
34
- var getRootId = (ctx) => `${ctx.id}`;
35
- var getTitleId = (ctx) => `${ctx.id}:title`;
36
- var getDescriptionId = (ctx) => `${ctx.id}:description`;
37
- var getCloseTriggerId = (ctx) => `${ctx.id}:close`;
38
- var getRegionEl = (ctx, placement) => ctx.getById(`toast-group-${placement}`);
39
- var getRootEl = (ctx) => ctx.query(ctx.selector(import_toast.parts.root));
40
- // Annotate the CommonJS export names for ESM import in node:
41
- 0 && (module.exports = {
42
- getCloseTriggerId,
43
- getDescriptionId,
44
- getRegionEl,
45
- getRegionId,
46
- getRootEl,
47
- getRootId,
48
- getTitleId
1
+ Object.defineProperties(exports, {
2
+ __esModule: { value: true },
3
+ [Symbol.toStringTag]: { value: "Module" }
49
4
  });
5
+ const require_toast_anatomy = require("./toast.anatomy.js");
6
+ let _zag_js_dom_query = require("@zag-js/dom-query");
7
+ // src/toast.dom.ts
8
+ const getRegionId = (placement) => `toast-group-${placement}`;
9
+ const getRootId = (ctx) => `${ctx.id}`;
10
+ const getTitleId = (ctx) => `${ctx.id}:title`;
11
+ const getDescriptionId = (ctx) => `${ctx.id}:description`;
12
+ const getCloseTriggerId = (ctx) => `${ctx.id}:close`;
13
+ const getRegionEl = (ctx, placement) => ctx.getById(`toast-group-${placement}`);
14
+ const getToastEls = (ctx, placement) => (0, _zag_js_dom_query.queryAll)(getRegionEl(ctx, placement), `[${require_toast_anatomy.parts.root.attr}]`);
15
+ const getRootEl = (ctx) => ctx.query(ctx.selector(require_toast_anatomy.parts.root));
16
+ const getContentEl = (ctx) => ctx.query(ctx.selector(require_toast_anatomy.parts.content));
17
+ const getTitleEl = (ctx) => ctx.query(ctx.selector(require_toast_anatomy.parts.title));
18
+ const getDescriptionEl = (ctx) => ctx.query(ctx.selector(require_toast_anatomy.parts.description));
19
+ function observeContent(contentEl, options) {
20
+ const { onChange, onMutate } = options;
21
+ const win = (0, _zag_js_dom_query.getWindow)(contentEl);
22
+ const frame = _zag_js_dom_query.AnimationFrame.create();
23
+ const stopResizeObserver = _zag_js_dom_query.resizeObserverBorderBox.observe(contentEl, () => frame.request(onChange));
24
+ const mutationObserver = new win.MutationObserver(() => {
25
+ frame.cancel();
26
+ onChange();
27
+ onMutate?.();
28
+ });
29
+ mutationObserver.observe(contentEl, {
30
+ childList: true,
31
+ subtree: true,
32
+ characterData: true
33
+ });
34
+ return () => {
35
+ mutationObserver.disconnect();
36
+ stopResizeObserver();
37
+ frame.cancel();
38
+ };
39
+ }
40
+ exports.getCloseTriggerId = getCloseTriggerId;
41
+ exports.getContentEl = getContentEl;
42
+ exports.getDescriptionEl = getDescriptionEl;
43
+ exports.getDescriptionId = getDescriptionId;
44
+ exports.getRegionEl = getRegionEl;
45
+ exports.getRegionId = getRegionId;
46
+ exports.getRootEl = getRootEl;
47
+ exports.getRootId = getRootId;
48
+ exports.getTitleEl = getTitleEl;
49
+ exports.getTitleId = getTitleId;
50
+ exports.getToastEls = getToastEls;
51
+ exports.observeContent = observeContent;
@@ -1,18 +1,36 @@
1
- // src/toast.dom.ts
2
1
  import { parts } from "./toast.anatomy.mjs";
3
- var getRegionId = (placement) => `toast-group-${placement}`;
4
- var getRootId = (ctx) => `${ctx.id}`;
5
- var getTitleId = (ctx) => `${ctx.id}:title`;
6
- var getDescriptionId = (ctx) => `${ctx.id}:description`;
7
- var getCloseTriggerId = (ctx) => `${ctx.id}:close`;
8
- var getRegionEl = (ctx, placement) => ctx.getById(`toast-group-${placement}`);
9
- var getRootEl = (ctx) => ctx.query(ctx.selector(parts.root));
10
- export {
11
- getCloseTriggerId,
12
- getDescriptionId,
13
- getRegionEl,
14
- getRegionId,
15
- getRootEl,
16
- getRootId,
17
- getTitleId
18
- };
2
+ import { AnimationFrame, getWindow, queryAll, resizeObserverBorderBox } from "@zag-js/dom-query";
3
+ // src/toast.dom.ts
4
+ const getRegionId = (placement) => `toast-group-${placement}`;
5
+ const getRootId = (ctx) => `${ctx.id}`;
6
+ const getTitleId = (ctx) => `${ctx.id}:title`;
7
+ const getDescriptionId = (ctx) => `${ctx.id}:description`;
8
+ const getCloseTriggerId = (ctx) => `${ctx.id}:close`;
9
+ const getRegionEl = (ctx, placement) => ctx.getById(`toast-group-${placement}`);
10
+ const getToastEls = (ctx, placement) => queryAll(getRegionEl(ctx, placement), `[${parts.root.attr}]`);
11
+ const getRootEl = (ctx) => ctx.query(ctx.selector(parts.root));
12
+ const getContentEl = (ctx) => ctx.query(ctx.selector(parts.content));
13
+ const getTitleEl = (ctx) => ctx.query(ctx.selector(parts.title));
14
+ const getDescriptionEl = (ctx) => ctx.query(ctx.selector(parts.description));
15
+ function observeContent(contentEl, options) {
16
+ const { onChange, onMutate } = options;
17
+ const win = getWindow(contentEl);
18
+ const frame = AnimationFrame.create();
19
+ const stopResizeObserver = resizeObserverBorderBox.observe(contentEl, () => frame.request(onChange));
20
+ const mutationObserver = new win.MutationObserver(() => {
21
+ frame.cancel();
22
+ onChange();
23
+ onMutate?.();
24
+ });
25
+ mutationObserver.observe(contentEl, {
26
+ childList: true,
27
+ subtree: true,
28
+ characterData: true
29
+ });
30
+ return () => {
31
+ mutationObserver.disconnect();
32
+ stopResizeObserver();
33
+ frame.cancel();
34
+ };
35
+ }
36
+ export { getCloseTriggerId, getContentEl, 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>;