@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.
- package/dist/index.d.mts +10 -17
- package/dist/index.d.ts +10 -17
- package/dist/index.js +18 -45
- package/dist/index.mjs +5 -11
- package/dist/toast-group.connect.d.mts +4 -8
- package/dist/toast-group.connect.d.ts +4 -8
- package/dist/toast-group.connect.js +73 -97
- package/dist/toast-group.connect.mjs +68 -61
- package/dist/toast-group.machine.d.mts +2 -8
- package/dist/toast-group.machine.d.ts +2 -8
- package/dist/toast-group.machine.js +292 -346
- package/dist/toast-group.machine.mjs +287 -310
- package/dist/toast.anatomy.d.mts +2 -6
- package/dist/toast.anatomy.d.ts +2 -6
- package/dist/toast.anatomy.js +8 -40
- package/dist/toast.anatomy.mjs +4 -14
- package/dist/toast.connect.d.mts +4 -8
- package/dist/toast.connect.d.ts +4 -8
- package/dist/toast.connect.js +133 -158
- package/dist/toast.connect.mjs +128 -122
- package/dist/toast.dom.d.mts +19 -23
- package/dist/toast.dom.d.ts +19 -23
- package/dist/toast.dom.js +54 -83
- package/dist/toast.dom.mjs +39 -47
- package/dist/toast.machine.d.mts +2 -8
- package/dist/toast.machine.d.ts +2 -8
- package/dist/toast.machine.js +272 -300
- package/dist/toast.machine.mjs +267 -264
- package/dist/toast.store.d.mts +2 -8
- package/dist/toast.store.d.ts +2 -8
- package/dist/toast.store.js +344 -306
- package/dist/toast.store.mjs +340 -281
- package/dist/toast.types.d.mts +372 -374
- package/dist/toast.types.d.ts +372 -374
- package/dist/toast.types.js +4 -18
- package/dist/toast.types.mjs +1 -0
- package/dist/toast.utils.d.mts +10 -14
- package/dist/toast.utils.d.ts +10 -14
- package/dist/toast.utils.js +167 -217
- package/dist/toast.utils.mjs +157 -186
- package/package.json +9 -9
package/dist/toast.anatomy.js
CHANGED
|
@@ -1,41 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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(
|
|
29
|
-
"group",
|
|
30
|
-
"root",
|
|
31
|
-
"title",
|
|
32
|
-
"description",
|
|
33
|
-
"actionTrigger",
|
|
34
|
-
"closeTrigger"
|
|
35
|
-
);
|
|
36
|
-
var parts = anatomy.build();
|
|
37
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
-
0 && (module.exports = {
|
|
39
|
-
anatomy,
|
|
40
|
-
parts
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
41
4
|
});
|
|
5
|
+
// src/toast.anatomy.ts
|
|
6
|
+
const anatomy = (0, require("@zag-js/anatomy").createAnatomy)("toast").parts("group", "root", "title", "description", "actionTrigger", "closeTrigger");
|
|
7
|
+
const parts = anatomy.build();
|
|
8
|
+
exports.anatomy = anatomy;
|
|
9
|
+
exports.parts = parts;
|
package/dist/toast.anatomy.mjs
CHANGED
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
// src/toast.anatomy.ts
|
|
2
1
|
import { createAnatomy } from "@zag-js/anatomy";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
"description",
|
|
8
|
-
"actionTrigger",
|
|
9
|
-
"closeTrigger"
|
|
10
|
-
);
|
|
11
|
-
var parts = anatomy.build();
|
|
12
|
-
export {
|
|
13
|
-
anatomy,
|
|
14
|
-
parts
|
|
15
|
-
};
|
|
2
|
+
// src/toast.anatomy.ts
|
|
3
|
+
const anatomy = createAnatomy("toast").parts("group", "root", "title", "description", "actionTrigger", "closeTrigger");
|
|
4
|
+
const parts = anatomy.build();
|
|
5
|
+
export { anatomy, parts };
|
package/dist/toast.connect.d.mts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
declare function connect<T extends PropTypes, O>(service: Service<ToastSchema<O>>, normalize: NormalizeProps<T>): ToastApi<T, O>;
|
|
7
|
-
|
|
8
|
-
export { connect };
|
|
1
|
+
import { ToastApi, ToastSchema } from "./toast.types.mjs";
|
|
2
|
+
import { Service } from "@zag-js/core";
|
|
3
|
+
import { NormalizeProps, PropTypes } from "@zag-js/types";
|
|
4
|
+
export declare function connect<T extends PropTypes, O>(service: Service<ToastSchema<O>>, normalize: NormalizeProps<T>): ToastApi<T, O>;
|
package/dist/toast.connect.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
declare function connect<T extends PropTypes, O>(service: Service<ToastSchema<O>>, normalize: NormalizeProps<T>): ToastApi<T, O>;
|
|
7
|
-
|
|
8
|
-
export { connect };
|
|
1
|
+
import { ToastApi, ToastSchema } from "./toast.types.js";
|
|
2
|
+
import { NormalizeProps, PropTypes } from "@zag-js/types";
|
|
3
|
+
import { Service } from "@zag-js/core";
|
|
4
|
+
export declare function connect<T extends PropTypes, O>(service: Service<ToastSchema<O>>, normalize: NormalizeProps<T>): ToastApi<T, O>;
|
package/dist/toast.connect.js
CHANGED
|
@@ -1,161 +1,136 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/toast.connect.ts
|
|
31
|
-
var toast_connect_exports = {};
|
|
32
|
-
__export(toast_connect_exports, {
|
|
33
|
-
connect: () => connect
|
|
1
|
+
Object.defineProperties(exports, {
|
|
2
|
+
__esModule: { value: true },
|
|
3
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
34
4
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
closeTriggerLabel: "Dismiss notification"
|
|
43
|
-
};
|
|
5
|
+
const require_toast_anatomy = require("./toast.anatomy.js");
|
|
6
|
+
const require_toast_dom = require("./toast.dom.js");
|
|
7
|
+
const require_toast_utils = require("./toast.utils.js");
|
|
8
|
+
let _zag_js_dom_query = require("@zag-js/dom-query");
|
|
9
|
+
let _zag_js_utils = require("@zag-js/utils");
|
|
10
|
+
// src/toast.connect.ts
|
|
11
|
+
const defaultTranslations = { closeTriggerLabel: "Dismiss notification" };
|
|
44
12
|
function connect(service, normalize) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
13
|
+
const { state, send, prop, scope, context, computed } = service;
|
|
14
|
+
const translations = (0, _zag_js_utils.mergeWithDefault)(defaultTranslations, prop("translations"));
|
|
15
|
+
const visible = state.hasTag("visible");
|
|
16
|
+
const paused = state.hasTag("paused");
|
|
17
|
+
const mounted = context.get("mounted");
|
|
18
|
+
const rendered = context.get("rendered");
|
|
19
|
+
const frontmost = computed("frontmost");
|
|
20
|
+
const placement = prop("parent").computed("placement");
|
|
21
|
+
const type = prop("type");
|
|
22
|
+
const stacked = prop("parent").state.matches("stack");
|
|
23
|
+
const title = prop("title");
|
|
24
|
+
const description = prop("description");
|
|
25
|
+
const action = prop("action");
|
|
26
|
+
const [side, align = "center"] = placement.split("-");
|
|
27
|
+
return {
|
|
28
|
+
type,
|
|
29
|
+
title,
|
|
30
|
+
description,
|
|
31
|
+
placement,
|
|
32
|
+
visible,
|
|
33
|
+
paused,
|
|
34
|
+
closable: !!prop("closable"),
|
|
35
|
+
pause() {
|
|
36
|
+
prop("parent").prop("store").pause(prop("id"));
|
|
37
|
+
},
|
|
38
|
+
resume() {
|
|
39
|
+
prop("parent").prop("store").resume(prop("id"));
|
|
40
|
+
},
|
|
41
|
+
dismiss() {
|
|
42
|
+
send({
|
|
43
|
+
type: "DISMISS",
|
|
44
|
+
src: "programmatic"
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
getRootProps() {
|
|
48
|
+
return normalize.element({
|
|
49
|
+
...require_toast_anatomy.parts.root.attrs,
|
|
50
|
+
dir: prop("dir"),
|
|
51
|
+
id: require_toast_dom.getRootId(scope),
|
|
52
|
+
"data-state": visible ? "open" : "closed",
|
|
53
|
+
"data-type": type,
|
|
54
|
+
"data-placement": placement,
|
|
55
|
+
"data-align": align,
|
|
56
|
+
"data-side": side,
|
|
57
|
+
"data-mounted": (0, _zag_js_dom_query.dataAttr)(mounted),
|
|
58
|
+
"data-paused": (0, _zag_js_dom_query.dataAttr)(paused),
|
|
59
|
+
"data-first": (0, _zag_js_dom_query.dataAttr)(frontmost),
|
|
60
|
+
"data-sibling": (0, _zag_js_dom_query.dataAttr)(!frontmost),
|
|
61
|
+
"data-stack": (0, _zag_js_dom_query.dataAttr)(stacked),
|
|
62
|
+
"data-overlap": (0, _zag_js_dom_query.dataAttr)(!stacked),
|
|
63
|
+
role: "status",
|
|
64
|
+
"aria-atomic": "true",
|
|
65
|
+
"aria-describedby": description && rendered.description ? require_toast_dom.getDescriptionId(scope) : void 0,
|
|
66
|
+
"aria-labelledby": title && rendered.title ? require_toast_dom.getTitleId(scope) : void 0,
|
|
67
|
+
tabIndex: 0,
|
|
68
|
+
style: require_toast_utils.getPlacementStyle(service, visible),
|
|
69
|
+
onKeyDown(event) {
|
|
70
|
+
if (event.defaultPrevented) return;
|
|
71
|
+
if (event.key == "Escape") {
|
|
72
|
+
send({
|
|
73
|
+
type: "DISMISS",
|
|
74
|
+
src: "keyboard"
|
|
75
|
+
});
|
|
76
|
+
event.preventDefault();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
getGhostBeforeProps() {
|
|
82
|
+
return normalize.element({
|
|
83
|
+
"data-ghost": "before",
|
|
84
|
+
style: require_toast_utils.getGhostBeforeStyle(service, visible)
|
|
85
|
+
});
|
|
86
|
+
},
|
|
87
|
+
getGhostAfterProps() {
|
|
88
|
+
return normalize.element({
|
|
89
|
+
"data-ghost": "after",
|
|
90
|
+
style: require_toast_utils.getGhostAfterStyle()
|
|
91
|
+
});
|
|
92
|
+
},
|
|
93
|
+
getTitleProps() {
|
|
94
|
+
return normalize.element({
|
|
95
|
+
...require_toast_anatomy.parts.title.attrs,
|
|
96
|
+
id: require_toast_dom.getTitleId(scope)
|
|
97
|
+
});
|
|
98
|
+
},
|
|
99
|
+
getDescriptionProps() {
|
|
100
|
+
return normalize.element({
|
|
101
|
+
...require_toast_anatomy.parts.description.attrs,
|
|
102
|
+
id: require_toast_dom.getDescriptionId(scope)
|
|
103
|
+
});
|
|
104
|
+
},
|
|
105
|
+
getActionTriggerProps() {
|
|
106
|
+
return normalize.button({
|
|
107
|
+
...require_toast_anatomy.parts.actionTrigger.attrs,
|
|
108
|
+
type: "button",
|
|
109
|
+
onClick(event) {
|
|
110
|
+
if (event.defaultPrevented) return;
|
|
111
|
+
action?.onClick?.();
|
|
112
|
+
send({
|
|
113
|
+
type: "DISMISS",
|
|
114
|
+
src: "user"
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
},
|
|
119
|
+
getCloseTriggerProps() {
|
|
120
|
+
return normalize.button({
|
|
121
|
+
id: require_toast_dom.getCloseTriggerId(scope),
|
|
122
|
+
...require_toast_anatomy.parts.closeTrigger.attrs,
|
|
123
|
+
type: "button",
|
|
124
|
+
"aria-label": translations?.closeTriggerLabel,
|
|
125
|
+
onClick(event) {
|
|
126
|
+
if (event.defaultPrevented) return;
|
|
127
|
+
send({
|
|
128
|
+
type: "DISMISS",
|
|
129
|
+
src: "user"
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
};
|
|
157
135
|
}
|
|
158
|
-
|
|
159
|
-
0 && (module.exports = {
|
|
160
|
-
connect
|
|
161
|
-
});
|
|
136
|
+
exports.connect = connect;
|
package/dist/toast.connect.mjs
CHANGED
|
@@ -1,126 +1,132 @@
|
|
|
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
|
|
2
|
+
import { getCloseTriggerId, getDescriptionId, getRootId, getTitleId } from "./toast.dom.mjs";
|
|
6
3
|
import { getGhostAfterStyle, getGhostBeforeStyle, getPlacementStyle } from "./toast.utils.mjs";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
import { dataAttr } from "@zag-js/dom-query";
|
|
5
|
+
import { mergeWithDefault } from "@zag-js/utils";
|
|
6
|
+
// src/toast.connect.ts
|
|
7
|
+
const defaultTranslations = { closeTriggerLabel: "Dismiss notification" };
|
|
10
8
|
function connect(service, normalize) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
9
|
+
const { state, send, prop, scope, context, computed } = service;
|
|
10
|
+
const translations = mergeWithDefault(defaultTranslations, prop("translations"));
|
|
11
|
+
const visible = state.hasTag("visible");
|
|
12
|
+
const paused = state.hasTag("paused");
|
|
13
|
+
const mounted = context.get("mounted");
|
|
14
|
+
const rendered = context.get("rendered");
|
|
15
|
+
const frontmost = computed("frontmost");
|
|
16
|
+
const placement = prop("parent").computed("placement");
|
|
17
|
+
const type = prop("type");
|
|
18
|
+
const stacked = prop("parent").state.matches("stack");
|
|
19
|
+
const title = prop("title");
|
|
20
|
+
const description = prop("description");
|
|
21
|
+
const action = prop("action");
|
|
22
|
+
const [side, align = "center"] = placement.split("-");
|
|
23
|
+
return {
|
|
24
|
+
type,
|
|
25
|
+
title,
|
|
26
|
+
description,
|
|
27
|
+
placement,
|
|
28
|
+
visible,
|
|
29
|
+
paused,
|
|
30
|
+
closable: !!prop("closable"),
|
|
31
|
+
pause() {
|
|
32
|
+
prop("parent").prop("store").pause(prop("id"));
|
|
33
|
+
},
|
|
34
|
+
resume() {
|
|
35
|
+
prop("parent").prop("store").resume(prop("id"));
|
|
36
|
+
},
|
|
37
|
+
dismiss() {
|
|
38
|
+
send({
|
|
39
|
+
type: "DISMISS",
|
|
40
|
+
src: "programmatic"
|
|
41
|
+
});
|
|
42
|
+
},
|
|
43
|
+
getRootProps() {
|
|
44
|
+
return normalize.element({
|
|
45
|
+
...parts.root.attrs,
|
|
46
|
+
dir: prop("dir"),
|
|
47
|
+
id: getRootId(scope),
|
|
48
|
+
"data-state": visible ? "open" : "closed",
|
|
49
|
+
"data-type": type,
|
|
50
|
+
"data-placement": placement,
|
|
51
|
+
"data-align": align,
|
|
52
|
+
"data-side": side,
|
|
53
|
+
"data-mounted": dataAttr(mounted),
|
|
54
|
+
"data-paused": dataAttr(paused),
|
|
55
|
+
"data-first": dataAttr(frontmost),
|
|
56
|
+
"data-sibling": dataAttr(!frontmost),
|
|
57
|
+
"data-stack": dataAttr(stacked),
|
|
58
|
+
"data-overlap": dataAttr(!stacked),
|
|
59
|
+
role: "status",
|
|
60
|
+
"aria-atomic": "true",
|
|
61
|
+
"aria-describedby": description && rendered.description ? getDescriptionId(scope) : void 0,
|
|
62
|
+
"aria-labelledby": title && rendered.title ? getTitleId(scope) : void 0,
|
|
63
|
+
tabIndex: 0,
|
|
64
|
+
style: getPlacementStyle(service, visible),
|
|
65
|
+
onKeyDown(event) {
|
|
66
|
+
if (event.defaultPrevented) return;
|
|
67
|
+
if (event.key == "Escape") {
|
|
68
|
+
send({
|
|
69
|
+
type: "DISMISS",
|
|
70
|
+
src: "keyboard"
|
|
71
|
+
});
|
|
72
|
+
event.preventDefault();
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
},
|
|
77
|
+
getGhostBeforeProps() {
|
|
78
|
+
return normalize.element({
|
|
79
|
+
"data-ghost": "before",
|
|
80
|
+
style: getGhostBeforeStyle(service, visible)
|
|
81
|
+
});
|
|
82
|
+
},
|
|
83
|
+
getGhostAfterProps() {
|
|
84
|
+
return normalize.element({
|
|
85
|
+
"data-ghost": "after",
|
|
86
|
+
style: getGhostAfterStyle()
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
getTitleProps() {
|
|
90
|
+
return normalize.element({
|
|
91
|
+
...parts.title.attrs,
|
|
92
|
+
id: getTitleId(scope)
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
getDescriptionProps() {
|
|
96
|
+
return normalize.element({
|
|
97
|
+
...parts.description.attrs,
|
|
98
|
+
id: getDescriptionId(scope)
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
getActionTriggerProps() {
|
|
102
|
+
return normalize.button({
|
|
103
|
+
...parts.actionTrigger.attrs,
|
|
104
|
+
type: "button",
|
|
105
|
+
onClick(event) {
|
|
106
|
+
if (event.defaultPrevented) return;
|
|
107
|
+
action?.onClick?.();
|
|
108
|
+
send({
|
|
109
|
+
type: "DISMISS",
|
|
110
|
+
src: "user"
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
getCloseTriggerProps() {
|
|
116
|
+
return normalize.button({
|
|
117
|
+
id: getCloseTriggerId(scope),
|
|
118
|
+
...parts.closeTrigger.attrs,
|
|
119
|
+
type: "button",
|
|
120
|
+
"aria-label": translations?.closeTriggerLabel,
|
|
121
|
+
onClick(event) {
|
|
122
|
+
if (event.defaultPrevented) return;
|
|
123
|
+
send({
|
|
124
|
+
type: "DISMISS",
|
|
125
|
+
src: "user"
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
};
|
|
123
131
|
}
|
|
124
|
-
export {
|
|
125
|
-
connect
|
|
126
|
-
};
|
|
132
|
+
export { connect };
|