@zag-js/toast 1.43.0 → 2.0.0-next.1
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/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/toast-group.connect.js +10 -4
- package/dist/toast-group.connect.mjs +10 -4
- package/dist/toast.connect.js +21 -18
- package/dist/toast.connect.mjs +21 -18
- package/dist/toast.dom.d.mts +2 -2
- package/dist/toast.dom.d.ts +2 -2
- package/dist/toast.dom.js +8 -7
- package/dist/toast.dom.mjs +8 -7
- package/dist/toast.types.d.mts +61 -1
- package/dist/toast.types.d.ts +61 -1
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _zag_js_core from '@zag-js/core';
|
|
2
2
|
import { ToastGroupSchema } from './toast.types.mjs';
|
|
3
|
-
export { ActionOptions, ToastApi as Api, ToastGroupApi as GroupApi, ToastGroupMachine as GroupMachine, ToastGroupProps as GroupProps, ToastGroupService as GroupService, IntlTranslations, ToastMachine as Machine, Options, Placement, PromiseOptions, ToastProps as Props, ToastService as Service, Status, StatusChangeDetails, ToastStore as Store, ToastStoreProps as StoreProps, ToastHeight, ToastQueuePriority, Type } from './toast.types.mjs';
|
|
3
|
+
export { ActionOptions, ToastApi as Api, ToastGroupApi as GroupApi, ToastGroupMachine as GroupMachine, ToastGroupProps as GroupProps, ToastGroupService as GroupService, GroupState, IntlTranslations, ToastMachine as Machine, Options, Placement, PromiseOptions, ToastProps as Props, RootState, ToastService as Service, Status, StatusChangeDetails, ToastStore as Store, ToastStoreProps as StoreProps, ToastHeight, ToastQueuePriority, Type } from './toast.types.mjs';
|
|
4
4
|
import { groupConnect } from './toast-group.connect.mjs';
|
|
5
5
|
export { anatomy } from './toast.anatomy.mjs';
|
|
6
6
|
export { connect } from './toast.connect.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _zag_js_core from '@zag-js/core';
|
|
2
2
|
import { ToastGroupSchema } from './toast.types.js';
|
|
3
|
-
export { ActionOptions, ToastApi as Api, ToastGroupApi as GroupApi, ToastGroupMachine as GroupMachine, ToastGroupProps as GroupProps, ToastGroupService as GroupService, IntlTranslations, ToastMachine as Machine, Options, Placement, PromiseOptions, ToastProps as Props, ToastService as Service, Status, StatusChangeDetails, ToastStore as Store, ToastStoreProps as StoreProps, ToastHeight, ToastQueuePriority, Type } from './toast.types.js';
|
|
3
|
+
export { ActionOptions, ToastApi as Api, ToastGroupApi as GroupApi, ToastGroupMachine as GroupMachine, ToastGroupProps as GroupProps, ToastGroupService as GroupService, GroupState, IntlTranslations, ToastMachine as Machine, Options, Placement, PromiseOptions, ToastProps as Props, RootState, ToastService as Service, Status, StatusChangeDetails, ToastStore as Store, ToastStoreProps as StoreProps, ToastHeight, ToastQueuePriority, Type } from './toast.types.js';
|
|
4
4
|
import { groupConnect } from './toast-group.connect.js';
|
|
5
5
|
export { anatomy } from './toast.anatomy.js';
|
|
6
6
|
export { connect } from './toast.connect.js';
|
|
@@ -38,7 +38,12 @@ var import_toast = require("./toast.anatomy.js");
|
|
|
38
38
|
var dom = __toESM(require("./toast.dom.js"));
|
|
39
39
|
var import_toast2 = require("./toast.utils.js");
|
|
40
40
|
function groupConnect(service, normalize) {
|
|
41
|
-
const { context, prop, send, refs, computed } = service;
|
|
41
|
+
const { context, prop, send, refs, computed, scope } = service;
|
|
42
|
+
function getGroupState() {
|
|
43
|
+
const placement = computed("placement");
|
|
44
|
+
const [side, align = "center"] = placement.split("-");
|
|
45
|
+
return { placement, side, align };
|
|
46
|
+
}
|
|
42
47
|
return {
|
|
43
48
|
getCount() {
|
|
44
49
|
return context.get("toasts").length;
|
|
@@ -46,14 +51,15 @@ function groupConnect(service, normalize) {
|
|
|
46
51
|
getToasts() {
|
|
47
52
|
return context.get("toasts");
|
|
48
53
|
},
|
|
54
|
+
getGroupState,
|
|
49
55
|
getGroupProps(options = {}) {
|
|
50
56
|
const { label = "Notifications" } = options;
|
|
51
57
|
const { hotkey } = prop("store").attrs;
|
|
52
58
|
const hotkeyLabel = hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, "");
|
|
53
|
-
const
|
|
54
|
-
const
|
|
59
|
+
const groupState = getGroupState();
|
|
60
|
+
const { placement, side, align } = groupState;
|
|
55
61
|
return normalize.element({
|
|
56
|
-
...import_toast.parts.group.attrs,
|
|
62
|
+
...import_toast.parts.group.attrs(scope.id),
|
|
57
63
|
dir: prop("dir"),
|
|
58
64
|
tabIndex: -1,
|
|
59
65
|
role: "region",
|
|
@@ -4,7 +4,12 @@ import { parts } from "./toast.anatomy.mjs";
|
|
|
4
4
|
import * as dom from "./toast.dom.mjs";
|
|
5
5
|
import { getGroupPlacementStyle } from "./toast.utils.mjs";
|
|
6
6
|
function groupConnect(service, normalize) {
|
|
7
|
-
const { context, prop, send, refs, computed } = service;
|
|
7
|
+
const { context, prop, send, refs, computed, scope } = service;
|
|
8
|
+
function getGroupState() {
|
|
9
|
+
const placement = computed("placement");
|
|
10
|
+
const [side, align = "center"] = placement.split("-");
|
|
11
|
+
return { placement, side, align };
|
|
12
|
+
}
|
|
8
13
|
return {
|
|
9
14
|
getCount() {
|
|
10
15
|
return context.get("toasts").length;
|
|
@@ -12,14 +17,15 @@ function groupConnect(service, normalize) {
|
|
|
12
17
|
getToasts() {
|
|
13
18
|
return context.get("toasts");
|
|
14
19
|
},
|
|
20
|
+
getGroupState,
|
|
15
21
|
getGroupProps(options = {}) {
|
|
16
22
|
const { label = "Notifications" } = options;
|
|
17
23
|
const { hotkey } = prop("store").attrs;
|
|
18
24
|
const hotkeyLabel = hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, "");
|
|
19
|
-
const
|
|
20
|
-
const
|
|
25
|
+
const groupState = getGroupState();
|
|
26
|
+
const { placement, side, align } = groupState;
|
|
21
27
|
return normalize.element({
|
|
22
|
-
...parts.group.attrs,
|
|
28
|
+
...parts.group.attrs(scope.id),
|
|
23
29
|
dir: prop("dir"),
|
|
24
30
|
tabIndex: -1,
|
|
25
31
|
role: "region",
|
package/dist/toast.connect.js
CHANGED
|
@@ -51,6 +51,9 @@ function connect(service, normalize) {
|
|
|
51
51
|
const description = prop("description");
|
|
52
52
|
const action = prop("action");
|
|
53
53
|
const [side, align = "center"] = placement.split("-");
|
|
54
|
+
function getRootState() {
|
|
55
|
+
return { visible, paused, mounted, frontmost, stacked: !!stacked, type, placement, side, align };
|
|
56
|
+
}
|
|
54
57
|
return {
|
|
55
58
|
type,
|
|
56
59
|
title,
|
|
@@ -68,22 +71,23 @@ function connect(service, normalize) {
|
|
|
68
71
|
dismiss() {
|
|
69
72
|
send({ type: "DISMISS", src: "programmatic" });
|
|
70
73
|
},
|
|
74
|
+
getRootState,
|
|
71
75
|
getRootProps() {
|
|
76
|
+
const rootState = getRootState();
|
|
72
77
|
return normalize.element({
|
|
73
|
-
...import_toast.parts.root.attrs,
|
|
78
|
+
...import_toast.parts.root.attrs(scope.id),
|
|
74
79
|
dir: prop("dir"),
|
|
75
|
-
|
|
76
|
-
"data-
|
|
77
|
-
"data-
|
|
78
|
-
"data-
|
|
79
|
-
"data-
|
|
80
|
-
"data-
|
|
81
|
-
"data-
|
|
82
|
-
"data-
|
|
83
|
-
"data-
|
|
84
|
-
"data-
|
|
85
|
-
"data-
|
|
86
|
-
"data-overlap": (0, import_dom_query.dataAttr)(!stacked),
|
|
80
|
+
"data-state": rootState.visible ? "open" : "closed",
|
|
81
|
+
"data-type": rootState.type,
|
|
82
|
+
"data-placement": rootState.placement,
|
|
83
|
+
"data-align": rootState.align,
|
|
84
|
+
"data-side": rootState.side,
|
|
85
|
+
"data-mounted": (0, import_dom_query.dataAttr)(rootState.mounted),
|
|
86
|
+
"data-paused": (0, import_dom_query.dataAttr)(rootState.paused),
|
|
87
|
+
"data-first": (0, import_dom_query.dataAttr)(rootState.frontmost),
|
|
88
|
+
"data-sibling": (0, import_dom_query.dataAttr)(!rootState.frontmost),
|
|
89
|
+
"data-stack": (0, import_dom_query.dataAttr)(rootState.stacked),
|
|
90
|
+
"data-overlap": (0, import_dom_query.dataAttr)(!rootState.stacked),
|
|
87
91
|
role: "status",
|
|
88
92
|
"aria-atomic": "true",
|
|
89
93
|
"aria-describedby": description ? dom.getDescriptionId(scope) : void 0,
|
|
@@ -115,19 +119,19 @@ function connect(service, normalize) {
|
|
|
115
119
|
},
|
|
116
120
|
getTitleProps() {
|
|
117
121
|
return normalize.element({
|
|
118
|
-
...import_toast.parts.title.attrs,
|
|
122
|
+
...import_toast.parts.title.attrs(scope.id),
|
|
119
123
|
id: dom.getTitleId(scope)
|
|
120
124
|
});
|
|
121
125
|
},
|
|
122
126
|
getDescriptionProps() {
|
|
123
127
|
return normalize.element({
|
|
124
|
-
...import_toast.parts.description.attrs,
|
|
128
|
+
...import_toast.parts.description.attrs(scope.id),
|
|
125
129
|
id: dom.getDescriptionId(scope)
|
|
126
130
|
});
|
|
127
131
|
},
|
|
128
132
|
getActionTriggerProps() {
|
|
129
133
|
return normalize.button({
|
|
130
|
-
...import_toast.parts.actionTrigger.attrs,
|
|
134
|
+
...import_toast.parts.actionTrigger.attrs(scope.id),
|
|
131
135
|
type: "button",
|
|
132
136
|
onClick(event) {
|
|
133
137
|
if (event.defaultPrevented) return;
|
|
@@ -138,8 +142,7 @@ function connect(service, normalize) {
|
|
|
138
142
|
},
|
|
139
143
|
getCloseTriggerProps() {
|
|
140
144
|
return normalize.button({
|
|
141
|
-
|
|
142
|
-
...import_toast.parts.closeTrigger.attrs,
|
|
145
|
+
...import_toast.parts.closeTrigger.attrs(scope.id),
|
|
143
146
|
type: "button",
|
|
144
147
|
"aria-label": translations?.closeTriggerLabel,
|
|
145
148
|
onClick(event) {
|
package/dist/toast.connect.mjs
CHANGED
|
@@ -17,6 +17,9 @@ function connect(service, normalize) {
|
|
|
17
17
|
const description = prop("description");
|
|
18
18
|
const action = prop("action");
|
|
19
19
|
const [side, align = "center"] = placement.split("-");
|
|
20
|
+
function getRootState() {
|
|
21
|
+
return { visible, paused, mounted, frontmost, stacked: !!stacked, type, placement, side, align };
|
|
22
|
+
}
|
|
20
23
|
return {
|
|
21
24
|
type,
|
|
22
25
|
title,
|
|
@@ -34,22 +37,23 @@ function connect(service, normalize) {
|
|
|
34
37
|
dismiss() {
|
|
35
38
|
send({ type: "DISMISS", src: "programmatic" });
|
|
36
39
|
},
|
|
40
|
+
getRootState,
|
|
37
41
|
getRootProps() {
|
|
42
|
+
const rootState = getRootState();
|
|
38
43
|
return normalize.element({
|
|
39
|
-
...parts.root.attrs,
|
|
44
|
+
...parts.root.attrs(scope.id),
|
|
40
45
|
dir: prop("dir"),
|
|
41
|
-
|
|
42
|
-
"data-
|
|
43
|
-
"data-
|
|
44
|
-
"data-
|
|
45
|
-
"data-
|
|
46
|
-
"data-
|
|
47
|
-
"data-
|
|
48
|
-
"data-
|
|
49
|
-
"data-
|
|
50
|
-
"data-
|
|
51
|
-
"data-
|
|
52
|
-
"data-overlap": dataAttr(!stacked),
|
|
46
|
+
"data-state": rootState.visible ? "open" : "closed",
|
|
47
|
+
"data-type": rootState.type,
|
|
48
|
+
"data-placement": rootState.placement,
|
|
49
|
+
"data-align": rootState.align,
|
|
50
|
+
"data-side": rootState.side,
|
|
51
|
+
"data-mounted": dataAttr(rootState.mounted),
|
|
52
|
+
"data-paused": dataAttr(rootState.paused),
|
|
53
|
+
"data-first": dataAttr(rootState.frontmost),
|
|
54
|
+
"data-sibling": dataAttr(!rootState.frontmost),
|
|
55
|
+
"data-stack": dataAttr(rootState.stacked),
|
|
56
|
+
"data-overlap": dataAttr(!rootState.stacked),
|
|
53
57
|
role: "status",
|
|
54
58
|
"aria-atomic": "true",
|
|
55
59
|
"aria-describedby": description ? dom.getDescriptionId(scope) : void 0,
|
|
@@ -81,19 +85,19 @@ function connect(service, normalize) {
|
|
|
81
85
|
},
|
|
82
86
|
getTitleProps() {
|
|
83
87
|
return normalize.element({
|
|
84
|
-
...parts.title.attrs,
|
|
88
|
+
...parts.title.attrs(scope.id),
|
|
85
89
|
id: dom.getTitleId(scope)
|
|
86
90
|
});
|
|
87
91
|
},
|
|
88
92
|
getDescriptionProps() {
|
|
89
93
|
return normalize.element({
|
|
90
|
-
...parts.description.attrs,
|
|
94
|
+
...parts.description.attrs(scope.id),
|
|
91
95
|
id: dom.getDescriptionId(scope)
|
|
92
96
|
});
|
|
93
97
|
},
|
|
94
98
|
getActionTriggerProps() {
|
|
95
99
|
return normalize.button({
|
|
96
|
-
...parts.actionTrigger.attrs,
|
|
100
|
+
...parts.actionTrigger.attrs(scope.id),
|
|
97
101
|
type: "button",
|
|
98
102
|
onClick(event) {
|
|
99
103
|
if (event.defaultPrevented) return;
|
|
@@ -104,8 +108,7 @@ function connect(service, normalize) {
|
|
|
104
108
|
},
|
|
105
109
|
getCloseTriggerProps() {
|
|
106
110
|
return normalize.button({
|
|
107
|
-
|
|
108
|
-
...parts.closeTrigger.attrs,
|
|
111
|
+
...parts.closeTrigger.attrs(scope.id),
|
|
109
112
|
type: "button",
|
|
110
113
|
"aria-label": translations?.closeTriggerLabel,
|
|
111
114
|
onClick(event) {
|
package/dist/toast.dom.d.mts
CHANGED
|
@@ -4,11 +4,11 @@ import '@zag-js/types';
|
|
|
4
4
|
import '@zag-js/dom-query';
|
|
5
5
|
|
|
6
6
|
declare const getRegionId: (placement: Placement) => string;
|
|
7
|
-
declare const getRegionEl: (ctx: Scope, placement: Placement) => HTMLElement | null;
|
|
8
7
|
declare const getRootId: (ctx: Scope) => string;
|
|
9
|
-
declare const getRootEl: (ctx: Scope) => HTMLElement | null;
|
|
10
8
|
declare const getTitleId: (ctx: Scope) => string;
|
|
11
9
|
declare const getDescriptionId: (ctx: Scope) => string;
|
|
12
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
13
|
|
|
14
14
|
export { getCloseTriggerId, getDescriptionId, getRegionEl, getRegionId, getRootEl, getRootId, getTitleId };
|
package/dist/toast.dom.d.ts
CHANGED
|
@@ -4,11 +4,11 @@ import '@zag-js/types';
|
|
|
4
4
|
import '@zag-js/dom-query';
|
|
5
5
|
|
|
6
6
|
declare const getRegionId: (placement: Placement) => string;
|
|
7
|
-
declare const getRegionEl: (ctx: Scope, placement: Placement) => HTMLElement | null;
|
|
8
7
|
declare const getRootId: (ctx: Scope) => string;
|
|
9
|
-
declare const getRootEl: (ctx: Scope) => HTMLElement | null;
|
|
10
8
|
declare const getTitleId: (ctx: Scope) => string;
|
|
11
9
|
declare const getDescriptionId: (ctx: Scope) => string;
|
|
12
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
13
|
|
|
14
14
|
export { getCloseTriggerId, getDescriptionId, getRegionEl, getRegionId, getRootEl, getRootId, getTitleId };
|
package/dist/toast.dom.js
CHANGED
|
@@ -29,13 +29,14 @@ __export(toast_dom_exports, {
|
|
|
29
29
|
getTitleId: () => getTitleId
|
|
30
30
|
});
|
|
31
31
|
module.exports = __toCommonJS(toast_dom_exports);
|
|
32
|
-
var
|
|
33
|
-
var
|
|
34
|
-
var getRootId = (ctx) =>
|
|
35
|
-
var
|
|
36
|
-
var
|
|
37
|
-
var
|
|
38
|
-
var
|
|
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));
|
|
39
40
|
// Annotate the CommonJS export names for ESM import in node:
|
|
40
41
|
0 && (module.exports = {
|
|
41
42
|
getCloseTriggerId,
|
package/dist/toast.dom.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
// src/toast.dom.ts
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var getRootId = (ctx) =>
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
2
|
+
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));
|
|
9
10
|
export {
|
|
10
11
|
getCloseTriggerId,
|
|
11
12
|
getDescriptionId,
|
package/dist/toast.types.d.mts
CHANGED
|
@@ -26,6 +26,44 @@ interface ToastHeight {
|
|
|
26
26
|
*/
|
|
27
27
|
height: number;
|
|
28
28
|
}
|
|
29
|
+
interface RootState {
|
|
30
|
+
/**
|
|
31
|
+
* Whether the toast is visible
|
|
32
|
+
*/
|
|
33
|
+
visible: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Whether the toast is paused
|
|
36
|
+
*/
|
|
37
|
+
paused: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Whether the toast has mounted into the DOM
|
|
40
|
+
*/
|
|
41
|
+
mounted: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Whether the toast is the frontmost (topmost) toast in the group
|
|
44
|
+
*/
|
|
45
|
+
frontmost: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Whether the toasts in the group are stacked instead of overlapping
|
|
48
|
+
*/
|
|
49
|
+
stacked: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* The type of the toast
|
|
52
|
+
*/
|
|
53
|
+
type: Type;
|
|
54
|
+
/**
|
|
55
|
+
* The placement of the toast
|
|
56
|
+
*/
|
|
57
|
+
placement: Placement;
|
|
58
|
+
/**
|
|
59
|
+
* The side of the toast placement
|
|
60
|
+
*/
|
|
61
|
+
side: string;
|
|
62
|
+
/**
|
|
63
|
+
* The horizontal alignment of the toast placement
|
|
64
|
+
*/
|
|
65
|
+
align: string;
|
|
66
|
+
}
|
|
29
67
|
interface ActionOptions {
|
|
30
68
|
/**
|
|
31
69
|
* The label of the action
|
|
@@ -317,6 +355,20 @@ interface GroupProps {
|
|
|
317
355
|
*/
|
|
318
356
|
label?: string | undefined;
|
|
319
357
|
}
|
|
358
|
+
interface GroupState {
|
|
359
|
+
/**
|
|
360
|
+
* The placement of the toast group
|
|
361
|
+
*/
|
|
362
|
+
placement: Placement;
|
|
363
|
+
/**
|
|
364
|
+
* The side of the toast group placement
|
|
365
|
+
*/
|
|
366
|
+
side: string;
|
|
367
|
+
/**
|
|
368
|
+
* The horizontal alignment of the toast group placement
|
|
369
|
+
*/
|
|
370
|
+
align: string;
|
|
371
|
+
}
|
|
320
372
|
interface ToastGroupApi<T extends PropTypes = PropTypes, O = any> {
|
|
321
373
|
/**
|
|
322
374
|
* The total number of toasts
|
|
@@ -330,6 +382,10 @@ interface ToastGroupApi<T extends PropTypes = PropTypes, O = any> {
|
|
|
330
382
|
* Subscribe to the toast group
|
|
331
383
|
*/
|
|
332
384
|
subscribe: (callback: (toasts: Options<O>[]) => void) => VoidFunction;
|
|
385
|
+
/**
|
|
386
|
+
* Returns the state of the group
|
|
387
|
+
*/
|
|
388
|
+
getGroupState: () => GroupState;
|
|
333
389
|
getGroupProps: (options?: GroupProps) => T["element"];
|
|
334
390
|
}
|
|
335
391
|
interface ToastApi<T extends PropTypes = PropTypes, O = any> {
|
|
@@ -373,6 +429,10 @@ interface ToastApi<T extends PropTypes = PropTypes, O = any> {
|
|
|
373
429
|
* Function to instantly dismiss the toast.
|
|
374
430
|
*/
|
|
375
431
|
dismiss: VoidFunction;
|
|
432
|
+
/**
|
|
433
|
+
* Returns the state of the root
|
|
434
|
+
*/
|
|
435
|
+
getRootState: () => RootState;
|
|
376
436
|
getRootProps: () => T["element"];
|
|
377
437
|
getTitleProps: () => T["element"];
|
|
378
438
|
getGhostBeforeProps: () => T["element"];
|
|
@@ -382,4 +442,4 @@ interface ToastApi<T extends PropTypes = PropTypes, O = any> {
|
|
|
382
442
|
getActionTriggerProps: () => T["button"];
|
|
383
443
|
}
|
|
384
444
|
|
|
385
|
-
export type { ActionOptions, GroupProps, IntlTranslations, Options, Placement, PromiseOptions, Status, StatusChangeDetails, ToastApi, ToastGroupApi, ToastGroupMachine, ToastGroupProps, ToastGroupSchema, ToastGroupService, ToastHeight, ToastMachine, ToastProps, ToastQueuePriority, ToastSchema, ToastService, ToastStore, ToastStoreProps, Type };
|
|
445
|
+
export type { ActionOptions, GroupProps, GroupState, IntlTranslations, Options, Placement, PromiseOptions, RootState, Status, StatusChangeDetails, ToastApi, ToastGroupApi, ToastGroupMachine, ToastGroupProps, ToastGroupSchema, ToastGroupService, ToastHeight, ToastMachine, ToastProps, ToastQueuePriority, ToastSchema, ToastService, ToastStore, ToastStoreProps, Type };
|
package/dist/toast.types.d.ts
CHANGED
|
@@ -26,6 +26,44 @@ interface ToastHeight {
|
|
|
26
26
|
*/
|
|
27
27
|
height: number;
|
|
28
28
|
}
|
|
29
|
+
interface RootState {
|
|
30
|
+
/**
|
|
31
|
+
* Whether the toast is visible
|
|
32
|
+
*/
|
|
33
|
+
visible: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Whether the toast is paused
|
|
36
|
+
*/
|
|
37
|
+
paused: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Whether the toast has mounted into the DOM
|
|
40
|
+
*/
|
|
41
|
+
mounted: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Whether the toast is the frontmost (topmost) toast in the group
|
|
44
|
+
*/
|
|
45
|
+
frontmost: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Whether the toasts in the group are stacked instead of overlapping
|
|
48
|
+
*/
|
|
49
|
+
stacked: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* The type of the toast
|
|
52
|
+
*/
|
|
53
|
+
type: Type;
|
|
54
|
+
/**
|
|
55
|
+
* The placement of the toast
|
|
56
|
+
*/
|
|
57
|
+
placement: Placement;
|
|
58
|
+
/**
|
|
59
|
+
* The side of the toast placement
|
|
60
|
+
*/
|
|
61
|
+
side: string;
|
|
62
|
+
/**
|
|
63
|
+
* The horizontal alignment of the toast placement
|
|
64
|
+
*/
|
|
65
|
+
align: string;
|
|
66
|
+
}
|
|
29
67
|
interface ActionOptions {
|
|
30
68
|
/**
|
|
31
69
|
* The label of the action
|
|
@@ -317,6 +355,20 @@ interface GroupProps {
|
|
|
317
355
|
*/
|
|
318
356
|
label?: string | undefined;
|
|
319
357
|
}
|
|
358
|
+
interface GroupState {
|
|
359
|
+
/**
|
|
360
|
+
* The placement of the toast group
|
|
361
|
+
*/
|
|
362
|
+
placement: Placement;
|
|
363
|
+
/**
|
|
364
|
+
* The side of the toast group placement
|
|
365
|
+
*/
|
|
366
|
+
side: string;
|
|
367
|
+
/**
|
|
368
|
+
* The horizontal alignment of the toast group placement
|
|
369
|
+
*/
|
|
370
|
+
align: string;
|
|
371
|
+
}
|
|
320
372
|
interface ToastGroupApi<T extends PropTypes = PropTypes, O = any> {
|
|
321
373
|
/**
|
|
322
374
|
* The total number of toasts
|
|
@@ -330,6 +382,10 @@ interface ToastGroupApi<T extends PropTypes = PropTypes, O = any> {
|
|
|
330
382
|
* Subscribe to the toast group
|
|
331
383
|
*/
|
|
332
384
|
subscribe: (callback: (toasts: Options<O>[]) => void) => VoidFunction;
|
|
385
|
+
/**
|
|
386
|
+
* Returns the state of the group
|
|
387
|
+
*/
|
|
388
|
+
getGroupState: () => GroupState;
|
|
333
389
|
getGroupProps: (options?: GroupProps) => T["element"];
|
|
334
390
|
}
|
|
335
391
|
interface ToastApi<T extends PropTypes = PropTypes, O = any> {
|
|
@@ -373,6 +429,10 @@ interface ToastApi<T extends PropTypes = PropTypes, O = any> {
|
|
|
373
429
|
* Function to instantly dismiss the toast.
|
|
374
430
|
*/
|
|
375
431
|
dismiss: VoidFunction;
|
|
432
|
+
/**
|
|
433
|
+
* Returns the state of the root
|
|
434
|
+
*/
|
|
435
|
+
getRootState: () => RootState;
|
|
376
436
|
getRootProps: () => T["element"];
|
|
377
437
|
getTitleProps: () => T["element"];
|
|
378
438
|
getGhostBeforeProps: () => T["element"];
|
|
@@ -382,4 +442,4 @@ interface ToastApi<T extends PropTypes = PropTypes, O = any> {
|
|
|
382
442
|
getActionTriggerProps: () => T["button"];
|
|
383
443
|
}
|
|
384
444
|
|
|
385
|
-
export type { ActionOptions, GroupProps, IntlTranslations, Options, Placement, PromiseOptions, Status, StatusChangeDetails, ToastApi, ToastGroupApi, ToastGroupMachine, ToastGroupProps, ToastGroupSchema, ToastGroupService, ToastHeight, ToastMachine, ToastProps, ToastQueuePriority, ToastSchema, ToastService, ToastStore, ToastStoreProps, Type };
|
|
445
|
+
export type { ActionOptions, GroupProps, GroupState, IntlTranslations, Options, Placement, PromiseOptions, RootState, Status, StatusChangeDetails, ToastApi, ToastGroupApi, ToastGroupMachine, ToastGroupProps, ToastGroupSchema, ToastGroupService, ToastHeight, ToastMachine, ToastProps, ToastQueuePriority, ToastSchema, ToastService, ToastStore, ToastStoreProps, Type };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/toast",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-next.1",
|
|
4
4
|
"description": "Core logic for the toast widget implemented as a state machine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@zag-js/anatomy": "
|
|
33
|
-
"@zag-js/core": "
|
|
34
|
-
"@zag-js/dom-query": "
|
|
35
|
-
"@zag-js/dismissable": "
|
|
36
|
-
"@zag-js/
|
|
37
|
-
"@zag-js/
|
|
32
|
+
"@zag-js/anatomy": "2.0.0-next.1",
|
|
33
|
+
"@zag-js/core": "2.0.0-next.1",
|
|
34
|
+
"@zag-js/dom-query": "2.0.0-next.1",
|
|
35
|
+
"@zag-js/dismissable": "2.0.0-next.1",
|
|
36
|
+
"@zag-js/types": "2.0.0-next.1",
|
|
37
|
+
"@zag-js/utils": "2.0.0-next.1"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"clean-package": "2.2.0"
|