asma-ui-core 3.61.4 → 3.63.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/components/feedback/dialog/StyledDialog.js +32 -30
- package/dist/components/feedback/snack-bar/SnackbarProvider.js +38 -24
- package/dist/components/feedback/snack-bar/StyledSnackbar.js +23 -18
- package/dist/hooks/useTopLayer.hook.js +54 -18
- package/dist/src/components/feedback/dialog/StyledDialog.d.ts +1 -0
- package/dist/src/hooks/useTopLayer.hook.d.ts +28 -0
- package/dist/src/hooks/useTopLayer.hook.test.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
import { cn as f } from "../../../helpers/cn.js";
|
|
2
|
-
import { resolveSx as
|
|
2
|
+
import { resolveSx as D } from "../../../helpers/sx.js";
|
|
3
3
|
import { CloseIcon as X } from "../../icons/close-icon/CloseIcon.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import P from "
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
|
|
4
|
+
import { registerOpenModalDialog as B } from "../../../hooks/useTopLayer.hook.js";
|
|
5
|
+
import { StyledButton as G } from "../../inputs/button/StyledButton.js";
|
|
6
|
+
import { useMobileMediaQuery as P } from "../../../hooks/useMediaQuery.hook.js";
|
|
7
|
+
import Q from "./StyledDialog.module.js";
|
|
8
|
+
import { useEffect as S, useLayoutEffect as $, useRef as u } from "react";
|
|
9
|
+
import { jsx as r, jsxs as l } from "react/jsx-runtime";
|
|
10
|
+
var J = {
|
|
10
11
|
xs: 444,
|
|
11
12
|
sm: 600,
|
|
12
13
|
md: 900,
|
|
13
14
|
lg: 1200,
|
|
14
15
|
xl: 1536
|
|
15
|
-
},
|
|
16
|
-
const
|
|
17
|
-
|
|
16
|
+
}, le = ({ open: t, onClose: a, children: _, dataTest: i, maxWidth: x = "sm", fullWidth: C, fullScreen: E, scroll: p = "paper", disableEscapeKeyDown: h, className: H, style: j, sx: M, classes: y, PaperProps: O, slotProps: o, onCloseText: w, showCloseIcon: v = !0, dialogLabel: d, dialogTitle: s, dialogHeaderNode: R }) => {
|
|
17
|
+
const W = P(), b = u(null), c = u(!1), g = u(t), n = E ?? W;
|
|
18
|
+
S(() => {
|
|
18
19
|
g.current && !t && o?.transition?.onExited?.(), g.current = t;
|
|
19
|
-
}, [t, o]),
|
|
20
|
+
}, [t, o]), $(() => {
|
|
20
21
|
const e = b.current;
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
if (!(!e || !t))
|
|
23
|
+
return e.open || (e.showModal(), e.focus({ preventScroll: !0 }), requestAnimationFrame(() => e.open && e.focus({ preventScroll: !0 }))), B(e);
|
|
24
|
+
}, [t]), S(() => {
|
|
23
25
|
if (!t) return;
|
|
24
26
|
const e = document.body.style.overflow, K = document.documentElement.style.overflow;
|
|
25
27
|
return document.body.style.overflow = "hidden", document.documentElement.style.overflow = "hidden", () => {
|
|
@@ -27,16 +29,16 @@ var $ = {
|
|
|
27
29
|
};
|
|
28
30
|
}, [t]);
|
|
29
31
|
const m = {
|
|
30
|
-
...
|
|
32
|
+
...O,
|
|
31
33
|
...o?.paper
|
|
32
|
-
}, k = x === !1 ? void 0 :
|
|
34
|
+
}, k = x === !1 ? void 0 : J[x], { className: I, style: z, onClick: q, ...A } = o?.backdrop ?? {}, N = (e) => {
|
|
33
35
|
c.current || (c.current = !0, window.setTimeout(() => {
|
|
34
36
|
c.current = !1;
|
|
35
37
|
}, 0), a?.(e, "escapeKeyDown"));
|
|
36
38
|
}, F = (e) => {
|
|
37
39
|
e.preventDefault(), h || N(e);
|
|
38
40
|
};
|
|
39
|
-
return t ? /* @__PURE__ */
|
|
41
|
+
return t ? /* @__PURE__ */ l("dialog", {
|
|
40
42
|
ref: b,
|
|
41
43
|
tabIndex: -1,
|
|
42
44
|
"data-testid": i,
|
|
@@ -45,20 +47,20 @@ var $ = {
|
|
|
45
47
|
onKeyDown: (e) => {
|
|
46
48
|
e.key !== "Escape" || h || (e.preventDefault(), N(e));
|
|
47
49
|
},
|
|
48
|
-
className: f(
|
|
50
|
+
className: f(Q.StyledDialog, "fixed inset-0 m-0 h-full max-h-none w-full max-w-none items-center justify-center overflow-hidden border-0 bg-transparent p-0 outline-none open:flex", p === "body" && "overflow-y-auto", H, y?.root),
|
|
49
51
|
style: {
|
|
50
52
|
zIndex: 999,
|
|
51
|
-
...
|
|
53
|
+
...D(M),
|
|
52
54
|
...j
|
|
53
55
|
},
|
|
54
|
-
children: [/* @__PURE__ */
|
|
56
|
+
children: [/* @__PURE__ */ r("div", {
|
|
55
57
|
...A,
|
|
56
|
-
className: f("absolute inset-0 bg-[#626e7eb2]",
|
|
58
|
+
className: f("absolute inset-0 bg-[#626e7eb2]", I),
|
|
57
59
|
style: z,
|
|
58
60
|
onClick: (e) => {
|
|
59
61
|
q?.(e), e.defaultPrevented || a?.(e, "backdropClick");
|
|
60
62
|
}
|
|
61
|
-
}), /* @__PURE__ */
|
|
63
|
+
}), /* @__PURE__ */ l("div", {
|
|
62
64
|
className: f("relative z-[1] flex overflow-hidden rounded-lg border-0 bg-white p-0 text-delta-800 shadow-[0px_4px_40px_0px_#22213366]", p === "paper" && "flex-col", n && "rounded-none", m.className, y?.paper),
|
|
63
65
|
style: {
|
|
64
66
|
minWidth: 0,
|
|
@@ -73,7 +75,7 @@ var $ = {
|
|
|
73
75
|
width: C ? "calc(100% - 64px)" : "auto",
|
|
74
76
|
maxHeight: "100%"
|
|
75
77
|
},
|
|
76
|
-
...
|
|
78
|
+
...D(m.sx),
|
|
77
79
|
...m.style,
|
|
78
80
|
...n ? {
|
|
79
81
|
width: "100%",
|
|
@@ -82,25 +84,25 @@ var $ = {
|
|
|
82
84
|
maxHeight: "100%"
|
|
83
85
|
} : { maxHeight: "calc(100% - 64px)" }
|
|
84
86
|
},
|
|
85
|
-
children: [(!!d || !!s || v) && /* @__PURE__ */
|
|
87
|
+
children: [(!!d || !!s || v) && /* @__PURE__ */ l("div", {
|
|
86
88
|
className: "box-border flex w-full min-w-0 max-w-full justify-between px-4 pt-4",
|
|
87
|
-
children: [/* @__PURE__ */
|
|
89
|
+
children: [/* @__PURE__ */ l("div", {
|
|
88
90
|
className: "flex min-w-0 flex-1 flex-col justify-start gap-0.5",
|
|
89
|
-
children: [d && /* @__PURE__ */
|
|
91
|
+
children: [d && /* @__PURE__ */ r("div", {
|
|
90
92
|
className: "flex h-8 items-center text-sm font-normal leading-5 text-delta-600",
|
|
91
93
|
children: d
|
|
92
|
-
}), s && /* @__PURE__ */
|
|
94
|
+
}), s && /* @__PURE__ */ r("div", {
|
|
93
95
|
className: "flex text-2xl font-semibold leading-8 text-delta-800",
|
|
94
96
|
children: s
|
|
95
97
|
})]
|
|
96
|
-
}), v && /* @__PURE__ */
|
|
98
|
+
}), v && /* @__PURE__ */ l("div", {
|
|
97
99
|
className: "flex min-w-0 max-w-full shrink-0 justify-end gap-2",
|
|
98
|
-
children: [
|
|
100
|
+
children: [R, /* @__PURE__ */ r(G, {
|
|
99
101
|
dataTest: `close-button-${i}`,
|
|
100
102
|
"aria-label": w ? void 0 : "Close",
|
|
101
103
|
variant: "textGray",
|
|
102
104
|
size: "small",
|
|
103
|
-
endIcon: /* @__PURE__ */
|
|
105
|
+
endIcon: /* @__PURE__ */ r(X, {
|
|
104
106
|
width: 20,
|
|
105
107
|
height: 20
|
|
106
108
|
}),
|
|
@@ -119,5 +121,5 @@ var $ = {
|
|
|
119
121
|
}) : null;
|
|
120
122
|
};
|
|
121
123
|
export {
|
|
122
|
-
|
|
124
|
+
le as StyledDialog
|
|
123
125
|
};
|
|
@@ -1,26 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
},
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
import { useTopmostOpenModalDialog as a } from "../../../hooks/useTopLayer.hook.js";
|
|
2
|
+
import { StyledAlertSnackbar as n } from "./StyledAlertSnackbar.js";
|
|
3
|
+
import { StyledDefaultSnackbar as i } from "./components/StyledDefaultSnackbar.js";
|
|
4
|
+
import { StyledInfoSnackbar as m } from "./components/StyledInfoSnackbar.js";
|
|
5
|
+
import { useLayoutEffect as e, useState as s } from "react";
|
|
6
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
7
|
+
import { SnackbarProvider as l } from "notistack";
|
|
8
|
+
var d = () => {
|
|
9
|
+
const [t] = s(() => {
|
|
10
|
+
const o = document.createElement("div");
|
|
11
|
+
return o.style.display = "contents", o.setAttribute("data-asma-snackbar-host", ""), o;
|
|
12
|
+
}), r = a();
|
|
13
|
+
return e(() => {
|
|
14
|
+
const o = r ?? document.body;
|
|
15
|
+
t.parentElement !== o && o.appendChild(t);
|
|
16
|
+
}, [t, r]), e(() => () => t.remove(), [t]), t;
|
|
17
|
+
}, v = (t) => {
|
|
18
|
+
const r = d();
|
|
19
|
+
return /* @__PURE__ */ c(l, {
|
|
20
|
+
...t,
|
|
21
|
+
Components: {
|
|
22
|
+
alert: n,
|
|
23
|
+
info: m,
|
|
24
|
+
default: i
|
|
25
|
+
},
|
|
26
|
+
autoHideDuration: 6e3,
|
|
27
|
+
anchorOrigin: {
|
|
28
|
+
vertical: "top",
|
|
29
|
+
horizontal: "right"
|
|
30
|
+
},
|
|
31
|
+
domRoot: r,
|
|
32
|
+
maxSnack: 3,
|
|
33
|
+
classes: { root: "min-w-fit flex justify-center" },
|
|
34
|
+
className: "w-fit min-w-fit max-w-fit",
|
|
35
|
+
children: t.children
|
|
36
|
+
});
|
|
37
|
+
};
|
|
24
38
|
export {
|
|
25
|
-
|
|
39
|
+
v as SnackbarProvider
|
|
26
40
|
};
|
|
@@ -1,36 +1,41 @@
|
|
|
1
1
|
import { cn as c } from "../../../helpers/cn.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
2
|
+
import { useTopmostOpenModalDialog as x } from "../../../hooks/useTopLayer.hook.js";
|
|
3
|
+
import { useEffect as d } from "react";
|
|
4
|
+
import { jsx as l, jsxs as h } from "react/jsx-runtime";
|
|
5
|
+
import { FloatingPortal as b } from "@floating-ui/react";
|
|
6
|
+
var g = {
|
|
6
7
|
"top-left": "top-6 left-6",
|
|
7
8
|
"top-center": "top-6 left-1/2 -translate-x-1/2",
|
|
8
9
|
"top-right": "top-6 right-6",
|
|
9
10
|
"bottom-left": "bottom-6 left-6",
|
|
10
11
|
"bottom-center": "bottom-6 left-1/2 -translate-x-1/2",
|
|
11
12
|
"bottom-right": "bottom-6 right-6"
|
|
12
|
-
},
|
|
13
|
+
}, N = ({ open: t = !1, autoHideDuration: e = 3e3, onClose: o, anchorOrigin: r = {
|
|
13
14
|
vertical: "bottom",
|
|
14
15
|
horizontal: "left"
|
|
15
|
-
}, message:
|
|
16
|
-
|
|
16
|
+
}, message: m, action: i, children: a, className: s }) => {
|
|
17
|
+
const f = x();
|
|
18
|
+
if (d(() => {
|
|
17
19
|
if (!t || e == null) return;
|
|
18
|
-
const
|
|
19
|
-
return () => clearTimeout(
|
|
20
|
+
const p = setTimeout(() => o?.(null, "timeout"), e);
|
|
21
|
+
return () => clearTimeout(p);
|
|
20
22
|
}, [
|
|
21
23
|
t,
|
|
22
24
|
e,
|
|
23
|
-
|
|
25
|
+
o
|
|
24
26
|
]), !t) return null;
|
|
25
|
-
const n =
|
|
26
|
-
return /* @__PURE__ */ l(
|
|
27
|
-
|
|
28
|
-
children:
|
|
29
|
-
className: "flex items-center gap-2
|
|
30
|
-
children:
|
|
27
|
+
const n = g[`${r.vertical}-${r.horizontal}`];
|
|
28
|
+
return /* @__PURE__ */ l(b, {
|
|
29
|
+
root: f,
|
|
30
|
+
children: /* @__PURE__ */ l("div", {
|
|
31
|
+
className: c("fixed z-[1400] flex items-center gap-2", n, s),
|
|
32
|
+
children: a ?? /* @__PURE__ */ h("div", {
|
|
33
|
+
className: "flex items-center gap-2 rounded bg-delta-800 px-4 py-3 text-sm text-white shadow-lg",
|
|
34
|
+
children: [m, i]
|
|
35
|
+
})
|
|
31
36
|
})
|
|
32
|
-
})
|
|
37
|
+
});
|
|
33
38
|
};
|
|
34
39
|
export {
|
|
35
|
-
|
|
40
|
+
N as StyledSnackbar
|
|
36
41
|
};
|
|
@@ -1,29 +1,65 @@
|
|
|
1
|
-
import { useCallback as
|
|
2
|
-
var
|
|
1
|
+
import { useCallback as r, useSyncExternalStore as s } from "react";
|
|
2
|
+
var c = { popover: "manual" }, p = {
|
|
3
3
|
margin: 0,
|
|
4
4
|
inset: "auto"
|
|
5
5
|
};
|
|
6
|
-
function
|
|
7
|
-
if (!(
|
|
8
|
-
const
|
|
9
|
-
return
|
|
6
|
+
function f(e) {
|
|
7
|
+
if (!(e instanceof Element)) return;
|
|
8
|
+
const o = e.closest("dialog");
|
|
9
|
+
return o instanceof HTMLDialogElement && o.open ? o : void 0;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
12
|
-
return
|
|
11
|
+
function t() {
|
|
12
|
+
if (typeof window > "u") return a ??= {
|
|
13
|
+
dialogs: [],
|
|
14
|
+
listeners: /* @__PURE__ */ new Set()
|
|
15
|
+
};
|
|
16
|
+
const e = window.rawWindow ?? document.defaultView ?? window;
|
|
17
|
+
return e.__asmaOpenModalDialogRegistry__ ??= {
|
|
18
|
+
dialogs: [],
|
|
19
|
+
listeners: /* @__PURE__ */ new Set()
|
|
20
|
+
};
|
|
13
21
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
22
|
+
var a, i = () => {
|
|
23
|
+
for (const e of [...t().listeners]) e();
|
|
24
|
+
};
|
|
25
|
+
function g(e) {
|
|
26
|
+
return t().dialogs.push(e), i(), () => {
|
|
27
|
+
const { dialogs: o } = t(), n = o.indexOf(e);
|
|
28
|
+
n !== -1 && (o.splice(n, 1), i());
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function l() {
|
|
32
|
+
const { dialogs: e } = t();
|
|
33
|
+
for (let o = e.length - 1; o >= 0; o -= 1) {
|
|
34
|
+
const n = e[o];
|
|
35
|
+
if (n?.isConnected && n.open) return n;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
var u = (e) => (t().listeners.add(e), () => {
|
|
39
|
+
t().listeners.delete(e);
|
|
40
|
+
});
|
|
41
|
+
function w() {
|
|
42
|
+
return s(u, l, () => {
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function v(e) {
|
|
46
|
+
return e == null;
|
|
47
|
+
}
|
|
48
|
+
function O(e, o = !0) {
|
|
49
|
+
return r((n) => {
|
|
50
|
+
if (e(n), !(!n || !o))
|
|
17
51
|
try {
|
|
18
|
-
typeof
|
|
52
|
+
typeof n.showPopover == "function" && !n.matches(":popover-open") && n.showPopover();
|
|
19
53
|
} catch {
|
|
20
54
|
}
|
|
21
|
-
}, [
|
|
55
|
+
}, [e, o]);
|
|
22
56
|
}
|
|
23
57
|
export {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
58
|
+
c as TOP_LAYER_PROPS,
|
|
59
|
+
p as TOP_LAYER_RESET_STYLE,
|
|
60
|
+
f as getOpenModalDialogAncestor,
|
|
61
|
+
g as registerOpenModalDialog,
|
|
62
|
+
v as shouldUsePopoverTopLayer,
|
|
63
|
+
O as useTopLayerRef,
|
|
64
|
+
w as useTopmostOpenModalDialog
|
|
29
65
|
};
|
|
@@ -20,6 +20,7 @@ export interface IStyledDialogProps {
|
|
|
20
20
|
dataTest: string;
|
|
21
21
|
maxWidth?: DialogMaxWidth;
|
|
22
22
|
fullWidth?: boolean;
|
|
23
|
+
/** Defaults to `true` on mobile (≤743px); pass `false` to keep the windowed paper there too. */
|
|
23
24
|
fullScreen?: boolean;
|
|
24
25
|
scroll?: 'paper' | 'body';
|
|
25
26
|
disableEscapeKeyDown?: boolean;
|
|
@@ -44,6 +44,34 @@ export declare const TOP_LAYER_RESET_STYLE: CSSProperties;
|
|
|
44
44
|
* body portal.
|
|
45
45
|
*/
|
|
46
46
|
export declare function getOpenModalDialogAncestor(node: unknown): HTMLElement | undefined;
|
|
47
|
+
declare global {
|
|
48
|
+
interface Window {
|
|
49
|
+
rawWindow?: Window;
|
|
50
|
+
__asmaOpenModalDialogRegistry__?: OpenModalDialogRegistry;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
interface OpenModalDialogRegistry {
|
|
54
|
+
dialogs: HTMLDialogElement[];
|
|
55
|
+
listeners: Set<() => void>;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Publish an open modal `<dialog>` as the current top-layer occupant. Call right after
|
|
59
|
+
* `showModal()`; the returned unregister must run before/as the dialog closes. `StyledDialog` wires
|
|
60
|
+
* this from the same layout effect that opens the dialog.
|
|
61
|
+
*/
|
|
62
|
+
export declare function registerOpenModalDialog(dialog: HTMLDialogElement): () => void;
|
|
63
|
+
/**
|
|
64
|
+
* The modal `<dialog>` currently at the top of the browser top layer, or `undefined` when no ui-core
|
|
65
|
+
* modal is open. Stale entries (a dialog torn down without its cleanup running) are skipped rather
|
|
66
|
+
* than trusted, so a missed unregister can never strand an overlay in a detached subtree.
|
|
67
|
+
*/
|
|
68
|
+
export declare function getTopmostOpenModalDialog(): HTMLDialogElement | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* Reactive {@link getTopmostOpenModalDialog} — re-renders the caller when a modal `<dialog>` opens or
|
|
71
|
+
* closes. Use as the portal root for an **anchorless** overlay that must clear an open modal
|
|
72
|
+
* (`SnackbarProvider`, `StyledSnackbar`); anchored overlays use {@link getOpenModalDialogAncestor}.
|
|
73
|
+
*/
|
|
74
|
+
export declare function useTopmostOpenModalDialog(): HTMLDialogElement | undefined;
|
|
47
75
|
/**
|
|
48
76
|
* `true` when the floating node should join the top layer via the Popover API.
|
|
49
77
|
* `false` when it is (or will be) portalled into an open modal `<dialog>` — see hook docs.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|