@addsign/moje-agenda-shared-lib 2.0.11 → 2.0.13
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/Dialog-4hkwYHTJ.js +424 -0
- package/dist/Dialog-4hkwYHTJ.js.map +1 -0
- package/dist/Dialog-CrRXl-G2.js +424 -0
- package/dist/Dialog-CrRXl-G2.js.map +1 -0
- package/dist/Dialog-D9rsAQnn.js +424 -0
- package/dist/Dialog-D9rsAQnn.js.map +1 -0
- package/dist/Dialog-v5zgZE_G.js +424 -0
- package/dist/Dialog-v5zgZE_G.js.map +1 -0
- package/dist/assets/style.css +192 -0
- package/dist/components/datatable/DataTable.js +2 -1
- package/dist/components/datatable/DataTable.js.map +1 -1
- package/dist/components/datatable/DataTableServer.js +2 -1
- package/dist/components/datatable/DataTableServer.js.map +1 -1
- package/dist/components/form/AutocompleteSearchBar.js +2 -1
- package/dist/components/form/AutocompleteSearchBar.js.map +1 -1
- package/dist/components/form/AutocompleteSearchBarServer.js +2 -1
- package/dist/components/form/AutocompleteSearchBarServer.js.map +1 -1
- package/dist/components/form/FileInput.js +3 -2
- package/dist/components/form/FileInput.js.map +1 -1
- package/dist/components/form/FileInputMultiple.js +5 -3
- package/dist/components/form/FileInputMultiple.js.map +1 -1
- package/dist/components/form/FormField.js +2 -1
- package/dist/components/form/FormField.js.map +1 -1
- package/dist/components/form/PositionsSelectorSingle.js +2 -1
- package/dist/components/form/PositionsSelectorSingle.js.map +1 -1
- package/dist/components/form/SelectField.js +2 -1
- package/dist/components/form/SelectField.js.map +1 -1
- package/dist/components/layout/CollapsibleSection.d.ts +11 -0
- package/dist/components/layout/CollapsibleSection.js +35 -0
- package/dist/components/layout/CollapsibleSection.js.map +1 -0
- package/dist/components/profiles/ProfileOverview.js +2 -1
- package/dist/components/profiles/ProfileOverview.js.map +1 -1
- package/dist/components/ui/Combobox.js +1 -1
- package/dist/components/ui/DateTimePicker.js +35 -28
- package/dist/components/ui/DateTimePicker.js.map +1 -1
- package/dist/components/ui/Dialog.js +1 -1
- package/dist/components/ui/ScrollArea.js +1 -1
- package/dist/components/ui/checkbox.js +1 -1
- package/dist/components/ui/command.js +2 -2
- package/dist/components/ui/datepicker.js +1 -1
- package/dist/components/ui/label.js +1 -1
- package/dist/components/ui/popover.js +7 -314
- package/dist/components/ui/popover.js.map +1 -1
- package/dist/components/ui/radioGroup.js +1 -1
- package/dist/components/ui/select.js +7 -5
- package/dist/components/ui/select.js.map +1 -1
- package/dist/components/ui/separator.js +1 -1
- package/dist/components/ui/sonner.d.ts +5 -0
- package/dist/components/ui/sonner.js +27 -0
- package/dist/components/ui/sonner.js.map +1 -0
- package/dist/components/ui/toast.d.ts +15 -0
- package/dist/components/ui/toast.js +742 -0
- package/dist/components/ui/toast.js.map +1 -0
- package/dist/components/ui/tooltip.js +4 -4
- package/dist/index-B4D9tlF2.js +37 -0
- package/dist/index-B4D9tlF2.js.map +1 -0
- package/dist/index-BIGXjoju.js +1162 -0
- package/dist/index-BIGXjoju.js.map +1 -0
- package/dist/index-BM2wqH4l.js +270 -0
- package/dist/index-BM2wqH4l.js.map +1 -0
- package/dist/index-BkUJPEGE.js +43 -0
- package/dist/index-BkUJPEGE.js.map +1 -0
- package/dist/index-BqfaqJMm.js +43 -0
- package/dist/index-BqfaqJMm.js.map +1 -0
- package/dist/index-BvG0B6Se.js +43 -0
- package/dist/index-BvG0B6Se.js.map +1 -0
- package/dist/index-ByYhNx4V.js +2204 -0
- package/dist/index-ByYhNx4V.js.map +1 -0
- package/dist/index-C1NhngpB.js +2212 -0
- package/dist/index-C1NhngpB.js.map +1 -0
- package/dist/index-C5uX_8yI.js +36 -0
- package/dist/index-C5uX_8yI.js.map +1 -0
- package/dist/index-CEVipgcd.js +234 -0
- package/dist/index-CEVipgcd.js.map +1 -0
- package/dist/index-CFdw_5ue.js +2204 -0
- package/dist/index-CFdw_5ue.js.map +1 -0
- package/dist/index-CQ3u2ZB9.js +28845 -0
- package/dist/index-CQ3u2ZB9.js.map +1 -0
- package/dist/index-CcUZ0rsE.js +2397 -0
- package/dist/index-CcUZ0rsE.js.map +1 -0
- package/dist/index-CmEWEow1.js +304 -0
- package/dist/index-CmEWEow1.js.map +1 -0
- package/dist/index-CwJgIvMz.js +43 -0
- package/dist/index-CwJgIvMz.js.map +1 -0
- package/dist/index-CxRvlMsQ.js +1162 -0
- package/dist/index-CxRvlMsQ.js.map +1 -0
- package/dist/index-Cxv2lY-3.js +234 -0
- package/dist/index-Cxv2lY-3.js.map +1 -0
- package/dist/index-CzU-7Pp-.js +1162 -0
- package/dist/index-CzU-7Pp-.js.map +1 -0
- package/dist/index-D2vw2lEy.js +2266 -0
- package/dist/index-D2vw2lEy.js.map +1 -0
- package/dist/index-D71KqwUL.js +28839 -0
- package/dist/index-D71KqwUL.js.map +1 -0
- package/dist/index-DVCdWg5e.js +36 -0
- package/dist/index-DVCdWg5e.js.map +1 -0
- package/dist/index-DWPKrsrN.js +234 -0
- package/dist/index-DWPKrsrN.js.map +1 -0
- package/dist/index-DiJxz9_S.js +36 -0
- package/dist/index-DiJxz9_S.js.map +1 -0
- package/dist/index-DjS0QG2f.js +28845 -0
- package/dist/index-DjS0QG2f.js.map +1 -0
- package/dist/index-FMLr5tN7.js +19 -0
- package/dist/index-FMLr5tN7.js.map +1 -0
- package/dist/index-GT3w9A2i.js +19 -0
- package/dist/index-GT3w9A2i.js.map +1 -0
- package/dist/index-Gbap2fMl.js +304 -0
- package/dist/index-Gbap2fMl.js.map +1 -0
- package/dist/index-R1AkuSsS.js +2204 -0
- package/dist/index-R1AkuSsS.js.map +1 -0
- package/dist/index-VCw-BbEd.js +36 -0
- package/dist/index-VCw-BbEd.js.map +1 -0
- package/dist/index-WjZKx4Rq.js +2266 -0
- package/dist/index-WjZKx4Rq.js.map +1 -0
- package/dist/index-XoubH6QK.js +19 -0
- package/dist/index-XoubH6QK.js.map +1 -0
- package/dist/index-cAAySw6z.js +19 -0
- package/dist/index-cAAySw6z.js.map +1 -0
- package/dist/index-eb1oES0O.js +234 -0
- package/dist/index-eb1oES0O.js.map +1 -0
- package/dist/index-efRbPAF9.js +304 -0
- package/dist/index-efRbPAF9.js.map +1 -0
- package/dist/index-g4PMBWfd.js +1162 -0
- package/dist/index-g4PMBWfd.js.map +1 -0
- package/dist/index-kx4d2yA2.js +2204 -0
- package/dist/index-kx4d2yA2.js.map +1 -0
- package/dist/index-tDQ16jIS.js +304 -0
- package/dist/index-tDQ16jIS.js.map +1 -0
- package/dist/index-u7IL3f7h.js +28811 -0
- package/dist/index-u7IL3f7h.js.map +1 -0
- package/dist/index.es-CORXX5Cy.js +9594 -0
- package/dist/index.es-CORXX5Cy.js.map +1 -0
- package/dist/jspdf.plugin.autotable-f-NQ-KEg.js +11475 -0
- package/dist/jspdf.plugin.autotable-f-NQ-KEg.js.map +1 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +21 -15
- package/dist/main.js.map +1 -1
- package/dist/popover-BtPiVBn9.js +319 -0
- package/dist/popover-BtPiVBn9.js.map +1 -0
- package/dist/types.d.ts +1 -0
- package/dist/types.js.map +1 -1
- package/dist/utils/handleErrors.js +2 -1
- package/dist/utils/handleErrors.js.map +1 -1
- package/lib/components/form/FileInputMultiple.tsx +1 -0
- package/lib/components/layout/CollapsibleSection.tsx +48 -0
- package/lib/components/ui/DateTimePicker.tsx +50 -37
- package/lib/components/ui/sonner.tsx +31 -0
- package/lib/components/ui/toast.tsx +129 -0
- package/lib/main.ts +5 -0
- package/lib/types.ts +1 -0
- package/lib/utils/handleErrors.ts +2 -1
- package/package.json +4 -1
|
@@ -0,0 +1,742 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { r as reactDomExports } from "../../index-CQ3u2ZB9.js";
|
|
4
|
+
import { c as createContextScope, a as useCallbackRef, b as composeEventHandlers, u as useLayoutEffect2 } from "../../index-CDCkSjVs.js";
|
|
5
|
+
import { u as useComposedRefs } from "../../index-D9mvqz1C.js";
|
|
6
|
+
import { c as createCollection } from "../../index-E5yk6fTE.js";
|
|
7
|
+
import { B as Branch, R as Root } from "../../index-CEVipgcd.js";
|
|
8
|
+
import { P as Portal } from "../../index-cAAySw6z.js";
|
|
9
|
+
import { P as Presence } from "../../index-CA2QNu6z.js";
|
|
10
|
+
import { P as Primitive, d as dispatchDiscreteCustomEvent } from "../../index-BkUJPEGE.js";
|
|
11
|
+
import { u as useControllableState } from "../../index-DFSwSCB0.js";
|
|
12
|
+
import { V as VisuallyHidden } from "../../index-DiJxz9_S.js";
|
|
13
|
+
import { c as cva } from "../../index-udNDzvjB.js";
|
|
14
|
+
import { cn } from "../../utils/utils.js";
|
|
15
|
+
import { X } from "../../x-DciOkaU0.js";
|
|
16
|
+
var PROVIDER_NAME = "ToastProvider";
|
|
17
|
+
var [Collection, useCollection, createCollectionScope] = createCollection("Toast");
|
|
18
|
+
var [createToastContext, createToastScope] = createContextScope("Toast", [createCollectionScope]);
|
|
19
|
+
var [ToastProviderProvider, useToastProviderContext] = createToastContext(PROVIDER_NAME);
|
|
20
|
+
var ToastProvider$1 = (props) => {
|
|
21
|
+
const {
|
|
22
|
+
__scopeToast,
|
|
23
|
+
label = "Notification",
|
|
24
|
+
duration = 5e3,
|
|
25
|
+
swipeDirection = "right",
|
|
26
|
+
swipeThreshold = 50,
|
|
27
|
+
children
|
|
28
|
+
} = props;
|
|
29
|
+
const [viewport, setViewport] = React.useState(null);
|
|
30
|
+
const [toastCount, setToastCount] = React.useState(0);
|
|
31
|
+
const isFocusedToastEscapeKeyDownRef = React.useRef(false);
|
|
32
|
+
const isClosePausedRef = React.useRef(false);
|
|
33
|
+
if (!label.trim()) {
|
|
34
|
+
console.error(
|
|
35
|
+
`Invalid prop \`label\` supplied to \`${PROVIDER_NAME}\`. Expected non-empty \`string\`.`
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
return /* @__PURE__ */ jsx(Collection.Provider, { scope: __scopeToast, children: /* @__PURE__ */ jsx(
|
|
39
|
+
ToastProviderProvider,
|
|
40
|
+
{
|
|
41
|
+
scope: __scopeToast,
|
|
42
|
+
label,
|
|
43
|
+
duration,
|
|
44
|
+
swipeDirection,
|
|
45
|
+
swipeThreshold,
|
|
46
|
+
toastCount,
|
|
47
|
+
viewport,
|
|
48
|
+
onViewportChange: setViewport,
|
|
49
|
+
onToastAdd: React.useCallback(() => setToastCount((prevCount) => prevCount + 1), []),
|
|
50
|
+
onToastRemove: React.useCallback(() => setToastCount((prevCount) => prevCount - 1), []),
|
|
51
|
+
isFocusedToastEscapeKeyDownRef,
|
|
52
|
+
isClosePausedRef,
|
|
53
|
+
children
|
|
54
|
+
}
|
|
55
|
+
) });
|
|
56
|
+
};
|
|
57
|
+
ToastProvider$1.displayName = PROVIDER_NAME;
|
|
58
|
+
var VIEWPORT_NAME = "ToastViewport";
|
|
59
|
+
var VIEWPORT_DEFAULT_HOTKEY = ["F8"];
|
|
60
|
+
var VIEWPORT_PAUSE = "toast.viewportPause";
|
|
61
|
+
var VIEWPORT_RESUME = "toast.viewportResume";
|
|
62
|
+
var ToastViewport$1 = React.forwardRef(
|
|
63
|
+
(props, forwardedRef) => {
|
|
64
|
+
const {
|
|
65
|
+
__scopeToast,
|
|
66
|
+
hotkey = VIEWPORT_DEFAULT_HOTKEY,
|
|
67
|
+
label = "Notifications ({hotkey})",
|
|
68
|
+
...viewportProps
|
|
69
|
+
} = props;
|
|
70
|
+
const context = useToastProviderContext(VIEWPORT_NAME, __scopeToast);
|
|
71
|
+
const getItems = useCollection(__scopeToast);
|
|
72
|
+
const wrapperRef = React.useRef(null);
|
|
73
|
+
const headFocusProxyRef = React.useRef(null);
|
|
74
|
+
const tailFocusProxyRef = React.useRef(null);
|
|
75
|
+
const ref = React.useRef(null);
|
|
76
|
+
const composedRefs = useComposedRefs(forwardedRef, ref, context.onViewportChange);
|
|
77
|
+
const hotkeyLabel = hotkey.join("+").replace(/Key/g, "").replace(/Digit/g, "");
|
|
78
|
+
const hasToasts = context.toastCount > 0;
|
|
79
|
+
React.useEffect(() => {
|
|
80
|
+
const handleKeyDown = (event) => {
|
|
81
|
+
var _a;
|
|
82
|
+
const isHotkeyPressed = hotkey.length !== 0 && hotkey.every((key) => event[key] || event.code === key);
|
|
83
|
+
if (isHotkeyPressed)
|
|
84
|
+
(_a = ref.current) == null ? void 0 : _a.focus();
|
|
85
|
+
};
|
|
86
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
87
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
88
|
+
}, [hotkey]);
|
|
89
|
+
React.useEffect(() => {
|
|
90
|
+
const wrapper = wrapperRef.current;
|
|
91
|
+
const viewport = ref.current;
|
|
92
|
+
if (hasToasts && wrapper && viewport) {
|
|
93
|
+
const handlePause = () => {
|
|
94
|
+
if (!context.isClosePausedRef.current) {
|
|
95
|
+
const pauseEvent = new CustomEvent(VIEWPORT_PAUSE);
|
|
96
|
+
viewport.dispatchEvent(pauseEvent);
|
|
97
|
+
context.isClosePausedRef.current = true;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
const handleResume = () => {
|
|
101
|
+
if (context.isClosePausedRef.current) {
|
|
102
|
+
const resumeEvent = new CustomEvent(VIEWPORT_RESUME);
|
|
103
|
+
viewport.dispatchEvent(resumeEvent);
|
|
104
|
+
context.isClosePausedRef.current = false;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
const handleFocusOutResume = (event) => {
|
|
108
|
+
const isFocusMovingOutside = !wrapper.contains(event.relatedTarget);
|
|
109
|
+
if (isFocusMovingOutside)
|
|
110
|
+
handleResume();
|
|
111
|
+
};
|
|
112
|
+
const handlePointerLeaveResume = () => {
|
|
113
|
+
const isFocusInside = wrapper.contains(document.activeElement);
|
|
114
|
+
if (!isFocusInside)
|
|
115
|
+
handleResume();
|
|
116
|
+
};
|
|
117
|
+
wrapper.addEventListener("focusin", handlePause);
|
|
118
|
+
wrapper.addEventListener("focusout", handleFocusOutResume);
|
|
119
|
+
wrapper.addEventListener("pointermove", handlePause);
|
|
120
|
+
wrapper.addEventListener("pointerleave", handlePointerLeaveResume);
|
|
121
|
+
window.addEventListener("blur", handlePause);
|
|
122
|
+
window.addEventListener("focus", handleResume);
|
|
123
|
+
return () => {
|
|
124
|
+
wrapper.removeEventListener("focusin", handlePause);
|
|
125
|
+
wrapper.removeEventListener("focusout", handleFocusOutResume);
|
|
126
|
+
wrapper.removeEventListener("pointermove", handlePause);
|
|
127
|
+
wrapper.removeEventListener("pointerleave", handlePointerLeaveResume);
|
|
128
|
+
window.removeEventListener("blur", handlePause);
|
|
129
|
+
window.removeEventListener("focus", handleResume);
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
}, [hasToasts, context.isClosePausedRef]);
|
|
133
|
+
const getSortedTabbableCandidates = React.useCallback(
|
|
134
|
+
({ tabbingDirection }) => {
|
|
135
|
+
const toastItems = getItems();
|
|
136
|
+
const tabbableCandidates = toastItems.map((toastItem) => {
|
|
137
|
+
const toastNode = toastItem.ref.current;
|
|
138
|
+
const toastTabbableCandidates = [toastNode, ...getTabbableCandidates(toastNode)];
|
|
139
|
+
return tabbingDirection === "forwards" ? toastTabbableCandidates : toastTabbableCandidates.reverse();
|
|
140
|
+
});
|
|
141
|
+
return (tabbingDirection === "forwards" ? tabbableCandidates.reverse() : tabbableCandidates).flat();
|
|
142
|
+
},
|
|
143
|
+
[getItems]
|
|
144
|
+
);
|
|
145
|
+
React.useEffect(() => {
|
|
146
|
+
const viewport = ref.current;
|
|
147
|
+
if (viewport) {
|
|
148
|
+
const handleKeyDown = (event) => {
|
|
149
|
+
var _a, _b, _c;
|
|
150
|
+
const isMetaKey = event.altKey || event.ctrlKey || event.metaKey;
|
|
151
|
+
const isTabKey = event.key === "Tab" && !isMetaKey;
|
|
152
|
+
if (isTabKey) {
|
|
153
|
+
const focusedElement = document.activeElement;
|
|
154
|
+
const isTabbingBackwards = event.shiftKey;
|
|
155
|
+
const targetIsViewport = event.target === viewport;
|
|
156
|
+
if (targetIsViewport && isTabbingBackwards) {
|
|
157
|
+
(_a = headFocusProxyRef.current) == null ? void 0 : _a.focus();
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const tabbingDirection = isTabbingBackwards ? "backwards" : "forwards";
|
|
161
|
+
const sortedCandidates = getSortedTabbableCandidates({ tabbingDirection });
|
|
162
|
+
const index = sortedCandidates.findIndex((candidate) => candidate === focusedElement);
|
|
163
|
+
if (focusFirst(sortedCandidates.slice(index + 1))) {
|
|
164
|
+
event.preventDefault();
|
|
165
|
+
} else {
|
|
166
|
+
isTabbingBackwards ? (_b = headFocusProxyRef.current) == null ? void 0 : _b.focus() : (_c = tailFocusProxyRef.current) == null ? void 0 : _c.focus();
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
viewport.addEventListener("keydown", handleKeyDown);
|
|
171
|
+
return () => viewport.removeEventListener("keydown", handleKeyDown);
|
|
172
|
+
}
|
|
173
|
+
}, [getItems, getSortedTabbableCandidates]);
|
|
174
|
+
return /* @__PURE__ */ jsxs(
|
|
175
|
+
Branch,
|
|
176
|
+
{
|
|
177
|
+
ref: wrapperRef,
|
|
178
|
+
role: "region",
|
|
179
|
+
"aria-label": label.replace("{hotkey}", hotkeyLabel),
|
|
180
|
+
tabIndex: -1,
|
|
181
|
+
style: { pointerEvents: hasToasts ? void 0 : "none" },
|
|
182
|
+
children: [
|
|
183
|
+
hasToasts && /* @__PURE__ */ jsx(
|
|
184
|
+
FocusProxy,
|
|
185
|
+
{
|
|
186
|
+
ref: headFocusProxyRef,
|
|
187
|
+
onFocusFromOutsideViewport: () => {
|
|
188
|
+
const tabbableCandidates = getSortedTabbableCandidates({
|
|
189
|
+
tabbingDirection: "forwards"
|
|
190
|
+
});
|
|
191
|
+
focusFirst(tabbableCandidates);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
),
|
|
195
|
+
/* @__PURE__ */ jsx(Collection.Slot, { scope: __scopeToast, children: /* @__PURE__ */ jsx(Primitive.ol, { tabIndex: -1, ...viewportProps, ref: composedRefs }) }),
|
|
196
|
+
hasToasts && /* @__PURE__ */ jsx(
|
|
197
|
+
FocusProxy,
|
|
198
|
+
{
|
|
199
|
+
ref: tailFocusProxyRef,
|
|
200
|
+
onFocusFromOutsideViewport: () => {
|
|
201
|
+
const tabbableCandidates = getSortedTabbableCandidates({
|
|
202
|
+
tabbingDirection: "backwards"
|
|
203
|
+
});
|
|
204
|
+
focusFirst(tabbableCandidates);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
)
|
|
208
|
+
]
|
|
209
|
+
}
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
);
|
|
213
|
+
ToastViewport$1.displayName = VIEWPORT_NAME;
|
|
214
|
+
var FOCUS_PROXY_NAME = "ToastFocusProxy";
|
|
215
|
+
var FocusProxy = React.forwardRef(
|
|
216
|
+
(props, forwardedRef) => {
|
|
217
|
+
const { __scopeToast, onFocusFromOutsideViewport, ...proxyProps } = props;
|
|
218
|
+
const context = useToastProviderContext(FOCUS_PROXY_NAME, __scopeToast);
|
|
219
|
+
return /* @__PURE__ */ jsx(
|
|
220
|
+
VisuallyHidden,
|
|
221
|
+
{
|
|
222
|
+
"aria-hidden": true,
|
|
223
|
+
tabIndex: 0,
|
|
224
|
+
...proxyProps,
|
|
225
|
+
ref: forwardedRef,
|
|
226
|
+
style: { position: "fixed" },
|
|
227
|
+
onFocus: (event) => {
|
|
228
|
+
var _a;
|
|
229
|
+
const prevFocusedElement = event.relatedTarget;
|
|
230
|
+
const isFocusFromOutsideViewport = !((_a = context.viewport) == null ? void 0 : _a.contains(prevFocusedElement));
|
|
231
|
+
if (isFocusFromOutsideViewport)
|
|
232
|
+
onFocusFromOutsideViewport();
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
);
|
|
238
|
+
FocusProxy.displayName = FOCUS_PROXY_NAME;
|
|
239
|
+
var TOAST_NAME = "Toast";
|
|
240
|
+
var TOAST_SWIPE_START = "toast.swipeStart";
|
|
241
|
+
var TOAST_SWIPE_MOVE = "toast.swipeMove";
|
|
242
|
+
var TOAST_SWIPE_CANCEL = "toast.swipeCancel";
|
|
243
|
+
var TOAST_SWIPE_END = "toast.swipeEnd";
|
|
244
|
+
var Toast$1 = React.forwardRef(
|
|
245
|
+
(props, forwardedRef) => {
|
|
246
|
+
const { forceMount, open: openProp, defaultOpen, onOpenChange, ...toastProps } = props;
|
|
247
|
+
const [open = true, setOpen] = useControllableState({
|
|
248
|
+
prop: openProp,
|
|
249
|
+
defaultProp: defaultOpen,
|
|
250
|
+
onChange: onOpenChange
|
|
251
|
+
});
|
|
252
|
+
return /* @__PURE__ */ jsx(Presence, { present: forceMount || open, children: /* @__PURE__ */ jsx(
|
|
253
|
+
ToastImpl,
|
|
254
|
+
{
|
|
255
|
+
open,
|
|
256
|
+
...toastProps,
|
|
257
|
+
ref: forwardedRef,
|
|
258
|
+
onClose: () => setOpen(false),
|
|
259
|
+
onPause: useCallbackRef(props.onPause),
|
|
260
|
+
onResume: useCallbackRef(props.onResume),
|
|
261
|
+
onSwipeStart: composeEventHandlers(props.onSwipeStart, (event) => {
|
|
262
|
+
event.currentTarget.setAttribute("data-swipe", "start");
|
|
263
|
+
}),
|
|
264
|
+
onSwipeMove: composeEventHandlers(props.onSwipeMove, (event) => {
|
|
265
|
+
const { x, y } = event.detail.delta;
|
|
266
|
+
event.currentTarget.setAttribute("data-swipe", "move");
|
|
267
|
+
event.currentTarget.style.setProperty("--radix-toast-swipe-move-x", `${x}px`);
|
|
268
|
+
event.currentTarget.style.setProperty("--radix-toast-swipe-move-y", `${y}px`);
|
|
269
|
+
}),
|
|
270
|
+
onSwipeCancel: composeEventHandlers(props.onSwipeCancel, (event) => {
|
|
271
|
+
event.currentTarget.setAttribute("data-swipe", "cancel");
|
|
272
|
+
event.currentTarget.style.removeProperty("--radix-toast-swipe-move-x");
|
|
273
|
+
event.currentTarget.style.removeProperty("--radix-toast-swipe-move-y");
|
|
274
|
+
event.currentTarget.style.removeProperty("--radix-toast-swipe-end-x");
|
|
275
|
+
event.currentTarget.style.removeProperty("--radix-toast-swipe-end-y");
|
|
276
|
+
}),
|
|
277
|
+
onSwipeEnd: composeEventHandlers(props.onSwipeEnd, (event) => {
|
|
278
|
+
const { x, y } = event.detail.delta;
|
|
279
|
+
event.currentTarget.setAttribute("data-swipe", "end");
|
|
280
|
+
event.currentTarget.style.removeProperty("--radix-toast-swipe-move-x");
|
|
281
|
+
event.currentTarget.style.removeProperty("--radix-toast-swipe-move-y");
|
|
282
|
+
event.currentTarget.style.setProperty("--radix-toast-swipe-end-x", `${x}px`);
|
|
283
|
+
event.currentTarget.style.setProperty("--radix-toast-swipe-end-y", `${y}px`);
|
|
284
|
+
setOpen(false);
|
|
285
|
+
})
|
|
286
|
+
}
|
|
287
|
+
) });
|
|
288
|
+
}
|
|
289
|
+
);
|
|
290
|
+
Toast$1.displayName = TOAST_NAME;
|
|
291
|
+
var [ToastInteractiveProvider, useToastInteractiveContext] = createToastContext(TOAST_NAME, {
|
|
292
|
+
onClose() {
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
var ToastImpl = React.forwardRef(
|
|
296
|
+
(props, forwardedRef) => {
|
|
297
|
+
const {
|
|
298
|
+
__scopeToast,
|
|
299
|
+
type = "foreground",
|
|
300
|
+
duration: durationProp,
|
|
301
|
+
open,
|
|
302
|
+
onClose,
|
|
303
|
+
onEscapeKeyDown,
|
|
304
|
+
onPause,
|
|
305
|
+
onResume,
|
|
306
|
+
onSwipeStart,
|
|
307
|
+
onSwipeMove,
|
|
308
|
+
onSwipeCancel,
|
|
309
|
+
onSwipeEnd,
|
|
310
|
+
...toastProps
|
|
311
|
+
} = props;
|
|
312
|
+
const context = useToastProviderContext(TOAST_NAME, __scopeToast);
|
|
313
|
+
const [node, setNode] = React.useState(null);
|
|
314
|
+
const composedRefs = useComposedRefs(forwardedRef, (node2) => setNode(node2));
|
|
315
|
+
const pointerStartRef = React.useRef(null);
|
|
316
|
+
const swipeDeltaRef = React.useRef(null);
|
|
317
|
+
const duration = durationProp || context.duration;
|
|
318
|
+
const closeTimerStartTimeRef = React.useRef(0);
|
|
319
|
+
const closeTimerRemainingTimeRef = React.useRef(duration);
|
|
320
|
+
const closeTimerRef = React.useRef(0);
|
|
321
|
+
const { onToastAdd, onToastRemove } = context;
|
|
322
|
+
const handleClose = useCallbackRef(() => {
|
|
323
|
+
var _a;
|
|
324
|
+
const isFocusInToast = node == null ? void 0 : node.contains(document.activeElement);
|
|
325
|
+
if (isFocusInToast)
|
|
326
|
+
(_a = context.viewport) == null ? void 0 : _a.focus();
|
|
327
|
+
onClose();
|
|
328
|
+
});
|
|
329
|
+
const startTimer = React.useCallback(
|
|
330
|
+
(duration2) => {
|
|
331
|
+
if (!duration2 || duration2 === Infinity)
|
|
332
|
+
return;
|
|
333
|
+
window.clearTimeout(closeTimerRef.current);
|
|
334
|
+
closeTimerStartTimeRef.current = (/* @__PURE__ */ new Date()).getTime();
|
|
335
|
+
closeTimerRef.current = window.setTimeout(handleClose, duration2);
|
|
336
|
+
},
|
|
337
|
+
[handleClose]
|
|
338
|
+
);
|
|
339
|
+
React.useEffect(() => {
|
|
340
|
+
const viewport = context.viewport;
|
|
341
|
+
if (viewport) {
|
|
342
|
+
const handleResume = () => {
|
|
343
|
+
startTimer(closeTimerRemainingTimeRef.current);
|
|
344
|
+
onResume == null ? void 0 : onResume();
|
|
345
|
+
};
|
|
346
|
+
const handlePause = () => {
|
|
347
|
+
const elapsedTime = (/* @__PURE__ */ new Date()).getTime() - closeTimerStartTimeRef.current;
|
|
348
|
+
closeTimerRemainingTimeRef.current = closeTimerRemainingTimeRef.current - elapsedTime;
|
|
349
|
+
window.clearTimeout(closeTimerRef.current);
|
|
350
|
+
onPause == null ? void 0 : onPause();
|
|
351
|
+
};
|
|
352
|
+
viewport.addEventListener(VIEWPORT_PAUSE, handlePause);
|
|
353
|
+
viewport.addEventListener(VIEWPORT_RESUME, handleResume);
|
|
354
|
+
return () => {
|
|
355
|
+
viewport.removeEventListener(VIEWPORT_PAUSE, handlePause);
|
|
356
|
+
viewport.removeEventListener(VIEWPORT_RESUME, handleResume);
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
}, [context.viewport, duration, onPause, onResume, startTimer]);
|
|
360
|
+
React.useEffect(() => {
|
|
361
|
+
if (open && !context.isClosePausedRef.current)
|
|
362
|
+
startTimer(duration);
|
|
363
|
+
}, [open, duration, context.isClosePausedRef, startTimer]);
|
|
364
|
+
React.useEffect(() => {
|
|
365
|
+
onToastAdd();
|
|
366
|
+
return () => onToastRemove();
|
|
367
|
+
}, [onToastAdd, onToastRemove]);
|
|
368
|
+
const announceTextContent = React.useMemo(() => {
|
|
369
|
+
return node ? getAnnounceTextContent(node) : null;
|
|
370
|
+
}, [node]);
|
|
371
|
+
if (!context.viewport)
|
|
372
|
+
return null;
|
|
373
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
374
|
+
announceTextContent && /* @__PURE__ */ jsx(
|
|
375
|
+
ToastAnnounce,
|
|
376
|
+
{
|
|
377
|
+
__scopeToast,
|
|
378
|
+
role: "status",
|
|
379
|
+
"aria-live": type === "foreground" ? "assertive" : "polite",
|
|
380
|
+
"aria-atomic": true,
|
|
381
|
+
children: announceTextContent
|
|
382
|
+
}
|
|
383
|
+
),
|
|
384
|
+
/* @__PURE__ */ jsx(ToastInteractiveProvider, { scope: __scopeToast, onClose: handleClose, children: reactDomExports.createPortal(
|
|
385
|
+
/* @__PURE__ */ jsx(Collection.ItemSlot, { scope: __scopeToast, children: /* @__PURE__ */ jsx(
|
|
386
|
+
Root,
|
|
387
|
+
{
|
|
388
|
+
asChild: true,
|
|
389
|
+
onEscapeKeyDown: composeEventHandlers(onEscapeKeyDown, () => {
|
|
390
|
+
if (!context.isFocusedToastEscapeKeyDownRef.current)
|
|
391
|
+
handleClose();
|
|
392
|
+
context.isFocusedToastEscapeKeyDownRef.current = false;
|
|
393
|
+
}),
|
|
394
|
+
children: /* @__PURE__ */ jsx(
|
|
395
|
+
Primitive.li,
|
|
396
|
+
{
|
|
397
|
+
role: "status",
|
|
398
|
+
"aria-live": "off",
|
|
399
|
+
"aria-atomic": true,
|
|
400
|
+
tabIndex: 0,
|
|
401
|
+
"data-state": open ? "open" : "closed",
|
|
402
|
+
"data-swipe-direction": context.swipeDirection,
|
|
403
|
+
...toastProps,
|
|
404
|
+
ref: composedRefs,
|
|
405
|
+
style: { userSelect: "none", touchAction: "none", ...props.style },
|
|
406
|
+
onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
|
|
407
|
+
if (event.key !== "Escape")
|
|
408
|
+
return;
|
|
409
|
+
onEscapeKeyDown == null ? void 0 : onEscapeKeyDown(event.nativeEvent);
|
|
410
|
+
if (!event.nativeEvent.defaultPrevented) {
|
|
411
|
+
context.isFocusedToastEscapeKeyDownRef.current = true;
|
|
412
|
+
handleClose();
|
|
413
|
+
}
|
|
414
|
+
}),
|
|
415
|
+
onPointerDown: composeEventHandlers(props.onPointerDown, (event) => {
|
|
416
|
+
if (event.button !== 0)
|
|
417
|
+
return;
|
|
418
|
+
pointerStartRef.current = { x: event.clientX, y: event.clientY };
|
|
419
|
+
}),
|
|
420
|
+
onPointerMove: composeEventHandlers(props.onPointerMove, (event) => {
|
|
421
|
+
if (!pointerStartRef.current)
|
|
422
|
+
return;
|
|
423
|
+
const x = event.clientX - pointerStartRef.current.x;
|
|
424
|
+
const y = event.clientY - pointerStartRef.current.y;
|
|
425
|
+
const hasSwipeMoveStarted = Boolean(swipeDeltaRef.current);
|
|
426
|
+
const isHorizontalSwipe = ["left", "right"].includes(context.swipeDirection);
|
|
427
|
+
const clamp = ["left", "up"].includes(context.swipeDirection) ? Math.min : Math.max;
|
|
428
|
+
const clampedX = isHorizontalSwipe ? clamp(0, x) : 0;
|
|
429
|
+
const clampedY = !isHorizontalSwipe ? clamp(0, y) : 0;
|
|
430
|
+
const moveStartBuffer = event.pointerType === "touch" ? 10 : 2;
|
|
431
|
+
const delta = { x: clampedX, y: clampedY };
|
|
432
|
+
const eventDetail = { originalEvent: event, delta };
|
|
433
|
+
if (hasSwipeMoveStarted) {
|
|
434
|
+
swipeDeltaRef.current = delta;
|
|
435
|
+
handleAndDispatchCustomEvent(TOAST_SWIPE_MOVE, onSwipeMove, eventDetail, {
|
|
436
|
+
discrete: false
|
|
437
|
+
});
|
|
438
|
+
} else if (isDeltaInDirection(delta, context.swipeDirection, moveStartBuffer)) {
|
|
439
|
+
swipeDeltaRef.current = delta;
|
|
440
|
+
handleAndDispatchCustomEvent(TOAST_SWIPE_START, onSwipeStart, eventDetail, {
|
|
441
|
+
discrete: false
|
|
442
|
+
});
|
|
443
|
+
event.target.setPointerCapture(event.pointerId);
|
|
444
|
+
} else if (Math.abs(x) > moveStartBuffer || Math.abs(y) > moveStartBuffer) {
|
|
445
|
+
pointerStartRef.current = null;
|
|
446
|
+
}
|
|
447
|
+
}),
|
|
448
|
+
onPointerUp: composeEventHandlers(props.onPointerUp, (event) => {
|
|
449
|
+
const delta = swipeDeltaRef.current;
|
|
450
|
+
const target = event.target;
|
|
451
|
+
if (target.hasPointerCapture(event.pointerId)) {
|
|
452
|
+
target.releasePointerCapture(event.pointerId);
|
|
453
|
+
}
|
|
454
|
+
swipeDeltaRef.current = null;
|
|
455
|
+
pointerStartRef.current = null;
|
|
456
|
+
if (delta) {
|
|
457
|
+
const toast = event.currentTarget;
|
|
458
|
+
const eventDetail = { originalEvent: event, delta };
|
|
459
|
+
if (isDeltaInDirection(delta, context.swipeDirection, context.swipeThreshold)) {
|
|
460
|
+
handleAndDispatchCustomEvent(TOAST_SWIPE_END, onSwipeEnd, eventDetail, {
|
|
461
|
+
discrete: true
|
|
462
|
+
});
|
|
463
|
+
} else {
|
|
464
|
+
handleAndDispatchCustomEvent(
|
|
465
|
+
TOAST_SWIPE_CANCEL,
|
|
466
|
+
onSwipeCancel,
|
|
467
|
+
eventDetail,
|
|
468
|
+
{
|
|
469
|
+
discrete: true
|
|
470
|
+
}
|
|
471
|
+
);
|
|
472
|
+
}
|
|
473
|
+
toast.addEventListener("click", (event2) => event2.preventDefault(), {
|
|
474
|
+
once: true
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
})
|
|
478
|
+
}
|
|
479
|
+
)
|
|
480
|
+
}
|
|
481
|
+
) }),
|
|
482
|
+
context.viewport
|
|
483
|
+
) })
|
|
484
|
+
] });
|
|
485
|
+
}
|
|
486
|
+
);
|
|
487
|
+
var ToastAnnounce = (props) => {
|
|
488
|
+
const { __scopeToast, children, ...announceProps } = props;
|
|
489
|
+
const context = useToastProviderContext(TOAST_NAME, __scopeToast);
|
|
490
|
+
const [renderAnnounceText, setRenderAnnounceText] = React.useState(false);
|
|
491
|
+
const [isAnnounced, setIsAnnounced] = React.useState(false);
|
|
492
|
+
useNextFrame(() => setRenderAnnounceText(true));
|
|
493
|
+
React.useEffect(() => {
|
|
494
|
+
const timer = window.setTimeout(() => setIsAnnounced(true), 1e3);
|
|
495
|
+
return () => window.clearTimeout(timer);
|
|
496
|
+
}, []);
|
|
497
|
+
return isAnnounced ? null : /* @__PURE__ */ jsx(Portal, { asChild: true, children: /* @__PURE__ */ jsx(VisuallyHidden, { ...announceProps, children: renderAnnounceText && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
498
|
+
context.label,
|
|
499
|
+
" ",
|
|
500
|
+
children
|
|
501
|
+
] }) }) });
|
|
502
|
+
};
|
|
503
|
+
var TITLE_NAME = "ToastTitle";
|
|
504
|
+
var ToastTitle$1 = React.forwardRef(
|
|
505
|
+
(props, forwardedRef) => {
|
|
506
|
+
const { __scopeToast, ...titleProps } = props;
|
|
507
|
+
return /* @__PURE__ */ jsx(Primitive.div, { ...titleProps, ref: forwardedRef });
|
|
508
|
+
}
|
|
509
|
+
);
|
|
510
|
+
ToastTitle$1.displayName = TITLE_NAME;
|
|
511
|
+
var DESCRIPTION_NAME = "ToastDescription";
|
|
512
|
+
var ToastDescription$1 = React.forwardRef(
|
|
513
|
+
(props, forwardedRef) => {
|
|
514
|
+
const { __scopeToast, ...descriptionProps } = props;
|
|
515
|
+
return /* @__PURE__ */ jsx(Primitive.div, { ...descriptionProps, ref: forwardedRef });
|
|
516
|
+
}
|
|
517
|
+
);
|
|
518
|
+
ToastDescription$1.displayName = DESCRIPTION_NAME;
|
|
519
|
+
var ACTION_NAME = "ToastAction";
|
|
520
|
+
var ToastAction$1 = React.forwardRef(
|
|
521
|
+
(props, forwardedRef) => {
|
|
522
|
+
const { altText, ...actionProps } = props;
|
|
523
|
+
if (!altText.trim()) {
|
|
524
|
+
console.error(
|
|
525
|
+
`Invalid prop \`altText\` supplied to \`${ACTION_NAME}\`. Expected non-empty \`string\`.`
|
|
526
|
+
);
|
|
527
|
+
return null;
|
|
528
|
+
}
|
|
529
|
+
return /* @__PURE__ */ jsx(ToastAnnounceExclude, { altText, asChild: true, children: /* @__PURE__ */ jsx(ToastClose$1, { ...actionProps, ref: forwardedRef }) });
|
|
530
|
+
}
|
|
531
|
+
);
|
|
532
|
+
ToastAction$1.displayName = ACTION_NAME;
|
|
533
|
+
var CLOSE_NAME = "ToastClose";
|
|
534
|
+
var ToastClose$1 = React.forwardRef(
|
|
535
|
+
(props, forwardedRef) => {
|
|
536
|
+
const { __scopeToast, ...closeProps } = props;
|
|
537
|
+
const interactiveContext = useToastInteractiveContext(CLOSE_NAME, __scopeToast);
|
|
538
|
+
return /* @__PURE__ */ jsx(ToastAnnounceExclude, { asChild: true, children: /* @__PURE__ */ jsx(
|
|
539
|
+
Primitive.button,
|
|
540
|
+
{
|
|
541
|
+
type: "button",
|
|
542
|
+
...closeProps,
|
|
543
|
+
ref: forwardedRef,
|
|
544
|
+
onClick: composeEventHandlers(props.onClick, interactiveContext.onClose)
|
|
545
|
+
}
|
|
546
|
+
) });
|
|
547
|
+
}
|
|
548
|
+
);
|
|
549
|
+
ToastClose$1.displayName = CLOSE_NAME;
|
|
550
|
+
var ToastAnnounceExclude = React.forwardRef((props, forwardedRef) => {
|
|
551
|
+
const { __scopeToast, altText, ...announceExcludeProps } = props;
|
|
552
|
+
return /* @__PURE__ */ jsx(
|
|
553
|
+
Primitive.div,
|
|
554
|
+
{
|
|
555
|
+
"data-radix-toast-announce-exclude": "",
|
|
556
|
+
"data-radix-toast-announce-alt": altText || void 0,
|
|
557
|
+
...announceExcludeProps,
|
|
558
|
+
ref: forwardedRef
|
|
559
|
+
}
|
|
560
|
+
);
|
|
561
|
+
});
|
|
562
|
+
function getAnnounceTextContent(container) {
|
|
563
|
+
const textContent = [];
|
|
564
|
+
const childNodes = Array.from(container.childNodes);
|
|
565
|
+
childNodes.forEach((node) => {
|
|
566
|
+
if (node.nodeType === node.TEXT_NODE && node.textContent)
|
|
567
|
+
textContent.push(node.textContent);
|
|
568
|
+
if (isHTMLElement(node)) {
|
|
569
|
+
const isHidden = node.ariaHidden || node.hidden || node.style.display === "none";
|
|
570
|
+
const isExcluded = node.dataset.radixToastAnnounceExclude === "";
|
|
571
|
+
if (!isHidden) {
|
|
572
|
+
if (isExcluded) {
|
|
573
|
+
const altText = node.dataset.radixToastAnnounceAlt;
|
|
574
|
+
if (altText)
|
|
575
|
+
textContent.push(altText);
|
|
576
|
+
} else {
|
|
577
|
+
textContent.push(...getAnnounceTextContent(node));
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
});
|
|
582
|
+
return textContent;
|
|
583
|
+
}
|
|
584
|
+
function handleAndDispatchCustomEvent(name, handler, detail, { discrete }) {
|
|
585
|
+
const currentTarget = detail.originalEvent.currentTarget;
|
|
586
|
+
const event = new CustomEvent(name, { bubbles: true, cancelable: true, detail });
|
|
587
|
+
if (handler)
|
|
588
|
+
currentTarget.addEventListener(name, handler, { once: true });
|
|
589
|
+
if (discrete) {
|
|
590
|
+
dispatchDiscreteCustomEvent(currentTarget, event);
|
|
591
|
+
} else {
|
|
592
|
+
currentTarget.dispatchEvent(event);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
var isDeltaInDirection = (delta, direction, threshold = 0) => {
|
|
596
|
+
const deltaX = Math.abs(delta.x);
|
|
597
|
+
const deltaY = Math.abs(delta.y);
|
|
598
|
+
const isDeltaX = deltaX > deltaY;
|
|
599
|
+
if (direction === "left" || direction === "right") {
|
|
600
|
+
return isDeltaX && deltaX > threshold;
|
|
601
|
+
} else {
|
|
602
|
+
return !isDeltaX && deltaY > threshold;
|
|
603
|
+
}
|
|
604
|
+
};
|
|
605
|
+
function useNextFrame(callback = () => {
|
|
606
|
+
}) {
|
|
607
|
+
const fn = useCallbackRef(callback);
|
|
608
|
+
useLayoutEffect2(() => {
|
|
609
|
+
let raf1 = 0;
|
|
610
|
+
let raf2 = 0;
|
|
611
|
+
raf1 = window.requestAnimationFrame(() => raf2 = window.requestAnimationFrame(fn));
|
|
612
|
+
return () => {
|
|
613
|
+
window.cancelAnimationFrame(raf1);
|
|
614
|
+
window.cancelAnimationFrame(raf2);
|
|
615
|
+
};
|
|
616
|
+
}, [fn]);
|
|
617
|
+
}
|
|
618
|
+
function isHTMLElement(node) {
|
|
619
|
+
return node.nodeType === node.ELEMENT_NODE;
|
|
620
|
+
}
|
|
621
|
+
function getTabbableCandidates(container) {
|
|
622
|
+
const nodes = [];
|
|
623
|
+
const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
|
|
624
|
+
acceptNode: (node) => {
|
|
625
|
+
const isHiddenInput = node.tagName === "INPUT" && node.type === "hidden";
|
|
626
|
+
if (node.disabled || node.hidden || isHiddenInput)
|
|
627
|
+
return NodeFilter.FILTER_SKIP;
|
|
628
|
+
return node.tabIndex >= 0 ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
|
|
629
|
+
}
|
|
630
|
+
});
|
|
631
|
+
while (walker.nextNode())
|
|
632
|
+
nodes.push(walker.currentNode);
|
|
633
|
+
return nodes;
|
|
634
|
+
}
|
|
635
|
+
function focusFirst(candidates) {
|
|
636
|
+
const previouslyFocusedElement = document.activeElement;
|
|
637
|
+
return candidates.some((candidate) => {
|
|
638
|
+
if (candidate === previouslyFocusedElement)
|
|
639
|
+
return true;
|
|
640
|
+
candidate.focus();
|
|
641
|
+
return document.activeElement !== previouslyFocusedElement;
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
var Provider = ToastProvider$1;
|
|
645
|
+
var Viewport = ToastViewport$1;
|
|
646
|
+
var Root2 = Toast$1;
|
|
647
|
+
var Title = ToastTitle$1;
|
|
648
|
+
var Description = ToastDescription$1;
|
|
649
|
+
var Action = ToastAction$1;
|
|
650
|
+
var Close = ToastClose$1;
|
|
651
|
+
const ToastProvider = Provider;
|
|
652
|
+
const ToastViewport = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
653
|
+
Viewport,
|
|
654
|
+
{
|
|
655
|
+
ref,
|
|
656
|
+
className: cn(
|
|
657
|
+
"fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",
|
|
658
|
+
className
|
|
659
|
+
),
|
|
660
|
+
...props
|
|
661
|
+
}
|
|
662
|
+
));
|
|
663
|
+
ToastViewport.displayName = Viewport.displayName;
|
|
664
|
+
const toastVariants = cva(
|
|
665
|
+
"group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",
|
|
666
|
+
{
|
|
667
|
+
variants: {
|
|
668
|
+
variant: {
|
|
669
|
+
default: "border bg-background text-foreground",
|
|
670
|
+
destructive: "destructive group border-destructive bg-destructive text-destructive-foreground"
|
|
671
|
+
}
|
|
672
|
+
},
|
|
673
|
+
defaultVariants: {
|
|
674
|
+
variant: "default"
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
);
|
|
678
|
+
const Toast = React.forwardRef(({ className, variant, ...props }, ref) => {
|
|
679
|
+
return /* @__PURE__ */ jsx(
|
|
680
|
+
Root2,
|
|
681
|
+
{
|
|
682
|
+
ref,
|
|
683
|
+
className: cn(toastVariants({ variant }), className),
|
|
684
|
+
...props
|
|
685
|
+
}
|
|
686
|
+
);
|
|
687
|
+
});
|
|
688
|
+
Toast.displayName = Root2.displayName;
|
|
689
|
+
const ToastAction = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
690
|
+
Action,
|
|
691
|
+
{
|
|
692
|
+
ref,
|
|
693
|
+
className: cn(
|
|
694
|
+
"inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",
|
|
695
|
+
className
|
|
696
|
+
),
|
|
697
|
+
...props
|
|
698
|
+
}
|
|
699
|
+
));
|
|
700
|
+
ToastAction.displayName = Action.displayName;
|
|
701
|
+
const ToastClose = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
702
|
+
Close,
|
|
703
|
+
{
|
|
704
|
+
ref,
|
|
705
|
+
className: cn(
|
|
706
|
+
"absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",
|
|
707
|
+
className
|
|
708
|
+
),
|
|
709
|
+
"toast-close": "",
|
|
710
|
+
...props,
|
|
711
|
+
children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
|
|
712
|
+
}
|
|
713
|
+
));
|
|
714
|
+
ToastClose.displayName = Close.displayName;
|
|
715
|
+
const ToastTitle = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
716
|
+
Title,
|
|
717
|
+
{
|
|
718
|
+
ref,
|
|
719
|
+
className: cn("text-sm font-semibold", className),
|
|
720
|
+
...props
|
|
721
|
+
}
|
|
722
|
+
));
|
|
723
|
+
ToastTitle.displayName = Title.displayName;
|
|
724
|
+
const ToastDescription = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
725
|
+
Description,
|
|
726
|
+
{
|
|
727
|
+
ref,
|
|
728
|
+
className: cn("text-sm opacity-90", className),
|
|
729
|
+
...props
|
|
730
|
+
}
|
|
731
|
+
));
|
|
732
|
+
ToastDescription.displayName = Description.displayName;
|
|
733
|
+
export {
|
|
734
|
+
Toast,
|
|
735
|
+
ToastAction,
|
|
736
|
+
ToastClose,
|
|
737
|
+
ToastDescription,
|
|
738
|
+
ToastProvider,
|
|
739
|
+
ToastTitle,
|
|
740
|
+
ToastViewport
|
|
741
|
+
};
|
|
742
|
+
//# sourceMappingURL=toast.js.map
|