asma-ui-core 3.87.2 → 3.87.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,123 +1,128 @@
|
|
|
1
|
-
import { cn as
|
|
1
|
+
import { cn as h } from "../../../helpers/cn.js";
|
|
2
2
|
import { resolveSx as S } from "../../../helpers/sx.js";
|
|
3
|
-
import { CloseIcon as
|
|
4
|
-
import { registerOpenModalDialog as
|
|
5
|
-
import { StyledButton as
|
|
6
|
-
import { useMobileMediaQuery as
|
|
7
|
-
import
|
|
8
|
-
import { useEffect as
|
|
3
|
+
import { CloseIcon as X } from "../../icons/close-icon/CloseIcon.js";
|
|
4
|
+
import { registerOpenModalDialog as B } from "../../../hooks/useTopLayer.hook.js";
|
|
5
|
+
import { StyledButton as G } from "../../inputs/button/StyledButton.js";
|
|
6
|
+
import { useMobileMediaQuery as Q } from "../../../hooks/useMediaQuery.hook.js";
|
|
7
|
+
import $ from "./StyledDialog.module.js";
|
|
8
|
+
import { useEffect as w, useLayoutEffect as J, useRef as a } from "react";
|
|
9
9
|
import { jsx as r, jsxs as l } from "react/jsx-runtime";
|
|
10
|
-
var
|
|
10
|
+
var U = {
|
|
11
11
|
xs: 444,
|
|
12
12
|
sm: 600,
|
|
13
13
|
md: 900,
|
|
14
14
|
lg: 1200,
|
|
15
15
|
xl: 1536
|
|
16
|
-
},
|
|
17
|
-
const z =
|
|
18
|
-
|
|
19
|
-
k.current && !t &&
|
|
20
|
-
}, [t,
|
|
21
|
-
const e =
|
|
16
|
+
}, oe = ({ open: t, onClose: c, children: C, dataTest: d, maxWidth: y = "sm", fullWidth: D, fullScreen: H, scroll: _ = "paper", disableEscapeKeyDown: M, className: j, style: O, sx: R, classes: v, PaperProps: W, slotProps: o, onCloseText: b, showCloseIcon: g = !0, dialogLabel: s, dialogTitle: m, dialogHeaderNode: I }) => {
|
|
17
|
+
const z = Q(), u = a(null), f = a(null), p = a(!1), k = a(t), i = H ?? z;
|
|
18
|
+
w(() => {
|
|
19
|
+
k.current && !t && o?.transition?.onExited?.(), k.current = t;
|
|
20
|
+
}, [t, o]), J(() => {
|
|
21
|
+
const e = u.current;
|
|
22
22
|
if (!e || !t) return;
|
|
23
|
-
e.open || (
|
|
24
|
-
const
|
|
23
|
+
e.open || (f.current = document.activeElement instanceof HTMLElement ? document.activeElement : null, e.showModal(), e.focus({ preventScroll: !0 }), requestAnimationFrame(() => e.open && e.focus({ preventScroll: !0 })));
|
|
24
|
+
const n = B(e);
|
|
25
25
|
return () => {
|
|
26
|
-
|
|
26
|
+
n(), f.current?.isConnected && f.current.focus({ preventScroll: !0 });
|
|
27
27
|
};
|
|
28
|
-
}, [t]),
|
|
28
|
+
}, [t]), w(() => {
|
|
29
29
|
if (!t) return;
|
|
30
|
-
const e = document.body.style.overflow,
|
|
30
|
+
const e = document.body.style.overflow, n = document.documentElement.style.overflow;
|
|
31
31
|
return document.body.style.overflow = "hidden", document.documentElement.style.overflow = "hidden", () => {
|
|
32
|
-
document.body.style.overflow = e, document.documentElement.style.overflow =
|
|
32
|
+
document.body.style.overflow = e, document.documentElement.style.overflow = n;
|
|
33
33
|
};
|
|
34
34
|
}, [t]);
|
|
35
|
-
const
|
|
35
|
+
const x = {
|
|
36
36
|
...W,
|
|
37
|
-
...
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}, 0),
|
|
42
|
-
},
|
|
43
|
-
e.preventDefault()
|
|
37
|
+
...o?.paper
|
|
38
|
+
}, E = y === !1 ? void 0 : U[y], { className: L, style: q, onClick: A, ...F } = o?.backdrop ?? {}, K = (e) => {
|
|
39
|
+
p.current || (p.current = !0, window.setTimeout(() => {
|
|
40
|
+
p.current = !1;
|
|
41
|
+
}, 0), c?.(e, "escapeKeyDown"));
|
|
42
|
+
}, P = (e) => {
|
|
43
|
+
e.preventDefault();
|
|
44
44
|
};
|
|
45
|
-
return
|
|
46
|
-
|
|
45
|
+
return w(() => {
|
|
46
|
+
if (!t || M) return;
|
|
47
|
+
const e = (n) => {
|
|
48
|
+
if (n.key !== "Escape" || n.defaultPrevented) return;
|
|
49
|
+
const N = document.activeElement;
|
|
50
|
+
N instanceof Element && N.closest("dialog[open]") !== u.current || K(n);
|
|
51
|
+
};
|
|
52
|
+
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
53
|
+
}), t ? /* @__PURE__ */ l("dialog", {
|
|
54
|
+
ref: u,
|
|
47
55
|
tabIndex: -1,
|
|
48
|
-
"data-testid":
|
|
49
|
-
"aria-label":
|
|
50
|
-
onCancel:
|
|
51
|
-
|
|
52
|
-
e.key !== "Escape" || y || (e.preventDefault(), E(e));
|
|
53
|
-
},
|
|
54
|
-
className: p(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", M === "body" && "overflow-y-auto", j, w?.root),
|
|
56
|
+
"data-testid": d,
|
|
57
|
+
"aria-label": d,
|
|
58
|
+
onCancel: P,
|
|
59
|
+
className: h($.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", _ === "body" && "overflow-y-auto", j, v?.root),
|
|
55
60
|
style: {
|
|
56
61
|
zIndex: 999,
|
|
57
|
-
...S(
|
|
58
|
-
...
|
|
62
|
+
...S(R),
|
|
63
|
+
...O
|
|
59
64
|
},
|
|
60
65
|
children: [/* @__PURE__ */ r("div", {
|
|
61
|
-
...
|
|
62
|
-
className:
|
|
63
|
-
style:
|
|
66
|
+
...F,
|
|
67
|
+
className: h("absolute inset-0 bg-[#626e7eb2]", L),
|
|
68
|
+
style: q,
|
|
64
69
|
onClick: (e) => {
|
|
65
|
-
|
|
70
|
+
A?.(e), e.defaultPrevented || c?.(e, "backdropClick");
|
|
66
71
|
}
|
|
67
72
|
}), /* @__PURE__ */ l("div", {
|
|
68
|
-
className:
|
|
73
|
+
className: h("relative z-[1] flex flex-col overflow-hidden rounded-lg border-0 bg-white p-0 text-delta-800 shadow-[0px_4px_40px_0px_#22213366]", i && "rounded-none", x.className, v?.paper),
|
|
69
74
|
style: {
|
|
70
75
|
minWidth: 0,
|
|
71
76
|
minHeight: 0,
|
|
72
|
-
...!
|
|
73
|
-
...
|
|
77
|
+
...!i && E ? { maxWidth: E } : {},
|
|
78
|
+
...i ? {
|
|
74
79
|
width: "100%",
|
|
75
80
|
maxWidth: "100%",
|
|
76
81
|
height: "100%",
|
|
77
82
|
maxHeight: "100%"
|
|
78
83
|
} : {
|
|
79
|
-
width:
|
|
84
|
+
width: D ? "calc(100% - 64px)" : "auto",
|
|
80
85
|
maxHeight: "100%"
|
|
81
86
|
},
|
|
82
|
-
...S(
|
|
83
|
-
...
|
|
84
|
-
...
|
|
87
|
+
...S(x.sx),
|
|
88
|
+
...x.style,
|
|
89
|
+
...i ? {
|
|
85
90
|
width: "100%",
|
|
86
91
|
maxWidth: "100%",
|
|
87
92
|
height: "100%",
|
|
88
93
|
maxHeight: "100%"
|
|
89
94
|
} : { maxHeight: "calc(100% - 64px)" }
|
|
90
95
|
},
|
|
91
|
-
children: [(!!
|
|
96
|
+
children: [(!!s || !!m || g) && /* @__PURE__ */ l("div", {
|
|
92
97
|
className: "box-border flex w-full min-w-0 max-w-full justify-between px-4 pt-4",
|
|
93
98
|
children: [/* @__PURE__ */ l("div", {
|
|
94
99
|
className: "flex min-w-0 flex-1 flex-col justify-start gap-0.5",
|
|
95
|
-
children: [
|
|
100
|
+
children: [s && /* @__PURE__ */ r("div", {
|
|
96
101
|
className: "flex h-8 items-center text-sm font-normal leading-5 text-delta-600",
|
|
97
|
-
children: d
|
|
98
|
-
}), s && /* @__PURE__ */ r("div", {
|
|
99
|
-
className: "flex text-2xl font-semibold leading-8 text-delta-800",
|
|
100
102
|
children: s
|
|
103
|
+
}), m && /* @__PURE__ */ r("div", {
|
|
104
|
+
className: "flex text-2xl font-semibold leading-8 text-delta-800",
|
|
105
|
+
children: m
|
|
101
106
|
})]
|
|
102
|
-
}),
|
|
107
|
+
}), g && /* @__PURE__ */ l("div", {
|
|
103
108
|
className: "flex min-w-0 max-w-full shrink-0 justify-end gap-2",
|
|
104
|
-
children: [I, /* @__PURE__ */ r(
|
|
105
|
-
dataTest: `close-button-${
|
|
106
|
-
"aria-label":
|
|
109
|
+
children: [I, /* @__PURE__ */ r(G, {
|
|
110
|
+
dataTest: `close-button-${d}`,
|
|
111
|
+
"aria-label": b ? void 0 : "Close",
|
|
107
112
|
variant: "textGray",
|
|
108
113
|
size: "small",
|
|
109
|
-
endIcon: /* @__PURE__ */ r(
|
|
114
|
+
endIcon: /* @__PURE__ */ r(X, {
|
|
110
115
|
width: 20,
|
|
111
116
|
height: 20
|
|
112
117
|
}),
|
|
113
118
|
className: "max-w-full shrink-0 whitespace-nowrap",
|
|
114
|
-
onClick: (e) =>
|
|
119
|
+
onClick: (e) => c?.(e, "escapeKeyDown"),
|
|
115
120
|
style: {
|
|
116
121
|
color: "var(--colors-delta-800)",
|
|
117
122
|
paddingRight: "6px",
|
|
118
123
|
paddingLeft: "6px"
|
|
119
124
|
},
|
|
120
|
-
children:
|
|
125
|
+
children: b
|
|
121
126
|
})]
|
|
122
127
|
})]
|
|
123
128
|
}), C]
|
|
@@ -125,5 +130,5 @@ var J = {
|
|
|
125
130
|
}) : null;
|
|
126
131
|
};
|
|
127
132
|
export {
|
|
128
|
-
|
|
133
|
+
oe as StyledDialog
|
|
129
134
|
};
|
|
@@ -11,26 +11,26 @@ import { planToolbarActions as D } from "../../../custom/module/header-layout/pl
|
|
|
11
11
|
import { ToolbarActionButton as G } from "../../../custom/module/header-layout/ToolbarActionGroup.js";
|
|
12
12
|
import { useToolbarTranslations as U } from "../../../custom/module/header-layout/useTranslations.js";
|
|
13
13
|
import { useMemo as C, useState as X } from "react";
|
|
14
|
-
import { Fragment as _, jsx as r, jsxs as
|
|
15
|
-
var Y = 470, V = 8, k = "dialog-footer-right", N = "dialog-footer-more", I = (
|
|
16
|
-
function ce({ leftActions:
|
|
17
|
-
const W = U(E), { ref: R, widthPx: c } = F(), { register: m, widths:
|
|
14
|
+
import { Fragment as _, jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
15
|
+
var Y = 470, V = 8, k = "dialog-footer-right", N = "dialog-footer-more", I = (t, n) => `dialog-footer-action:${t}:${n ? "label" : "icon"}`;
|
|
16
|
+
function ce({ leftActions: t = [], leadingSlot: n, secondaryAction: a, primaryAction: s, fixed: P = !1, rounded: B = !0, locale: E = "en", className: M, dataTest: d = "styled-dialog-footer" }) {
|
|
17
|
+
const W = U(E), { ref: R, widthPx: c } = F(), { register: m, widths: o } = H(), [p, h] = X(null), g = c > 0 && c < Y, S = g ? 8 : 16, u = C(() => t.filter((e) => !e.hidden).map((e) => e.icon == null && e.canHideLabel == null ? {
|
|
18
18
|
...e,
|
|
19
19
|
canHideLabel: !1
|
|
20
|
-
} : e), [
|
|
20
|
+
} : e), [t]), A = o[k] ?? 0, x = a != null || s != null, v = Math.max(0, c - S * 2 - A - (x ? V : 0)), f = C(() => D({
|
|
21
21
|
actions: u,
|
|
22
22
|
availableWidth: v,
|
|
23
23
|
collapseLabels: !0,
|
|
24
|
-
resolveActionWidth: (e,
|
|
25
|
-
moreButtonWidthPx:
|
|
24
|
+
resolveActionWidth: (e, l) => o[I(e.id, l)],
|
|
25
|
+
moreButtonWidthPx: o[N]
|
|
26
26
|
}), [
|
|
27
27
|
u,
|
|
28
28
|
v,
|
|
29
|
-
|
|
30
|
-
]), b = (e,
|
|
29
|
+
o
|
|
30
|
+
]), b = (e, l, L) => {
|
|
31
31
|
const y = /* @__PURE__ */ r(w, {
|
|
32
32
|
dataTest: e.dataTest ?? `${d}-${L}`,
|
|
33
|
-
variant: e.variant ??
|
|
33
|
+
variant: e.variant ?? l,
|
|
34
34
|
error: e.tone === "danger",
|
|
35
35
|
size: "medium",
|
|
36
36
|
type: e.type ?? "button",
|
|
@@ -54,20 +54,20 @@ function ce({ leftActions: o = [], leadingSlot: t, secondaryAction: a, primaryAc
|
|
|
54
54
|
})
|
|
55
55
|
}) : y;
|
|
56
56
|
};
|
|
57
|
-
return /* @__PURE__ */
|
|
57
|
+
return /* @__PURE__ */ i("div", {
|
|
58
58
|
ref: R,
|
|
59
59
|
"data-testid": d,
|
|
60
|
-
className: T("flex items-center justify-end border-0 border-t border-solid border-delta-200 bg-white", g ? "gap-2 p-2" : "gap-4 p-4", B && "rounded-b-lg", P && "sticky bottom-0 z-[1] shadow-[0_0_16px_0_rgba(34,33,51,0.2)]", M),
|
|
60
|
+
className: T("flex items-center justify-end self-stretch border-0 border-t border-solid border-delta-200 bg-white", g ? "gap-2 p-2" : "gap-4 p-4", B && "rounded-b-lg", P && "sticky bottom-0 z-[1] shadow-[0_0_16px_0_rgba(34,33,51,0.2)]", M),
|
|
61
61
|
children: [/* @__PURE__ */ r("div", {
|
|
62
62
|
className: "flex shrink-0 flex-nowrap items-center gap-2",
|
|
63
|
-
children:
|
|
64
|
-
ref: m(I(e.id,
|
|
63
|
+
children: n ?? /* @__PURE__ */ i(_, { children: [f.inlineActions.map(({ action: e, showLabel: l }) => /* @__PURE__ */ r("span", {
|
|
64
|
+
ref: m(I(e.id, l)),
|
|
65
65
|
className: "inline-flex shrink-0",
|
|
66
66
|
children: /* @__PURE__ */ r(G, {
|
|
67
67
|
action: e,
|
|
68
|
-
showLabel:
|
|
68
|
+
showLabel: l
|
|
69
69
|
})
|
|
70
|
-
}, e.id)), f.showMoreMenu && /* @__PURE__ */
|
|
70
|
+
}, e.id)), f.showMoreMenu && /* @__PURE__ */ i(_, { children: [/* @__PURE__ */ r("span", {
|
|
71
71
|
ref: m(N),
|
|
72
72
|
className: "inline-flex shrink-0",
|
|
73
73
|
children: /* @__PURE__ */ r(w, {
|
|
@@ -101,7 +101,7 @@ function ce({ leftActions: o = [], leadingSlot: t, secondaryAction: a, primaryAc
|
|
|
101
101
|
onClick: () => {
|
|
102
102
|
h(null), e.onClick();
|
|
103
103
|
},
|
|
104
|
-
children: /* @__PURE__ */
|
|
104
|
+
children: /* @__PURE__ */ i("div", {
|
|
105
105
|
className: T("flex items-center gap-2", e.tone === "danger" ? "text-beta-500" : "text-delta-700"),
|
|
106
106
|
children: [e.icon, /* @__PURE__ */ r("span", { children: e.label })]
|
|
107
107
|
})
|
|
@@ -109,7 +109,7 @@ function ce({ leftActions: o = [], leadingSlot: t, secondaryAction: a, primaryAc
|
|
|
109
109
|
})] })] })
|
|
110
110
|
}), x && /* @__PURE__ */ r("span", {
|
|
111
111
|
className: "flex min-w-px flex-1 flex-nowrap items-center justify-end",
|
|
112
|
-
children: /* @__PURE__ */
|
|
112
|
+
children: /* @__PURE__ */ i("span", {
|
|
113
113
|
ref: m(k),
|
|
114
114
|
className: "flex shrink-0 flex-nowrap items-center gap-2",
|
|
115
115
|
children: [a && b(a, "outlined", "secondary"), s && b(s, "contained", "primary")]
|