asma-ui-core 3.108.2 → 3.108.3
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/asma-ui-core.css +1 -1
- package/dist/components/feedback/dialog/StyledDialog.js +139 -96
- package/dist/components/feedback/minimizable-dialog/MinimizableDialog.js +180 -171
- package/dist/components/feedback/minimizable-dialog/v2/MinimizableDialogV2.js +115 -106
- package/dist/datetime/components/date-picker/StyledDatePicker.js +15 -19
- package/dist/datetime/components/time-picker/StyledTimePicker.js +56 -62
- package/dist/hooks/useBackCloses.hook.js +100 -0
- package/dist/src/components/feedback/dialog/StyledDialog.d.ts +6 -1
- package/dist/src/hooks/useBackCloses.hook.d.ts +101 -0
- package/dist/src/hooks/useBackCloses.hook.test.d.ts +1 -0
- package/package.json +1 -1
- package/dist/datetime/hooks/useBackNavigationClose.hook.js +0 -10
- package/dist/src/datetime/hooks/useBackNavigationClose.hook.d.ts +0 -4
|
@@ -1,167 +1,210 @@
|
|
|
1
|
-
import { cn as
|
|
2
|
-
import { resolveSx as
|
|
3
|
-
import { registerOpenModalDialog as
|
|
4
|
-
import { CloseIcon as
|
|
5
|
-
import { DialogBusyContext as
|
|
6
|
-
import { StyledButton as
|
|
7
|
-
import { useMobileMediaQuery as
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
1
|
+
import { cn as B } from "../../../helpers/cn.js";
|
|
2
|
+
import { resolveSx as K } from "../../../helpers/sx.js";
|
|
3
|
+
import { registerOpenModalDialog as ve } from "../../../hooks/useTopLayer.hook.js";
|
|
4
|
+
import { CloseIcon as xe } from "../../icons/close-icon/CloseIcon.js";
|
|
5
|
+
import { DialogBusyContext as ye, useDialogBusyBoundary as pe } from "./DialogBusyContext.js";
|
|
6
|
+
import { StyledButton as we } from "../../inputs/button/StyledButton.js";
|
|
7
|
+
import { useMobileMediaQuery as ge } from "../../../hooks/useMediaQuery.hook.js";
|
|
8
|
+
import { OverlayBackOwnerContext as be, isOverlayBackEnabled as T, requestCloseTopOverlayBack as D, useBackCloses as ke } from "../../../hooks/useBackCloses.hook.js";
|
|
9
|
+
import { warnUnnamedDialog as Ce } from "../../../helpers/warnUnnamedDialog.js";
|
|
10
|
+
import Ee from "./StyledDialog.module.js";
|
|
11
|
+
import { StyledDialogTitleContext as Be } from "./dialogTitleContext.js";
|
|
12
|
+
import { useEffect as a, useId as I, useLayoutEffect as U, useMemo as De, useRef as l, useState as X } from "react";
|
|
13
|
+
import { jsx as i, jsxs as d } from "react/jsx-runtime";
|
|
14
|
+
var Ie = {
|
|
14
15
|
xs: 444,
|
|
15
16
|
sm: 600,
|
|
16
17
|
md: 900,
|
|
17
18
|
lg: 1200,
|
|
18
19
|
xl: 1536
|
|
19
|
-
},
|
|
20
|
-
const
|
|
21
|
-
titleId:
|
|
22
|
-
setTitleId:
|
|
23
|
-
}), [
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
}, Fe = ({ open: t, onClose: R, children: S, dataTest: u, maxWidth: N = "sm", fullWidth: G, fullScreen: Q, scroll: V = "paper", disableEscapeKeyDown: H, className: $, style: J, sx: Y, classes: O, PaperProps: Z, slotProps: f, busyReason: ee, locale: te = "en", onCloseText: q, showCloseIcon: M = !0, dialogLabel: m, dialogTitle: h, dialogHeaderNode: re, ariaLabel: g }) => {
|
|
21
|
+
const v = I(), P = I(), [ne, oe] = X(), le = De(() => ({
|
|
22
|
+
titleId: v,
|
|
23
|
+
setTitleId: oe
|
|
24
|
+
}), [v]), x = h ? v : ne ?? (m ? P : void 0), ie = ge(), s = l(null), b = l(null), k = l(!1), C = l(!1), c = l(!1), _ = l(t);
|
|
25
|
+
a(() => {
|
|
26
|
+
_.current = t;
|
|
27
|
+
}, [t]);
|
|
28
|
+
const L = l(t), y = Q ?? ie, { busy: p, busyReason: se, contextValue: ae } = pe(ee, te), j = I(), [w, ce] = X(), W = l(!1);
|
|
29
|
+
U(() => {
|
|
30
|
+
const e = s.current, r = !!x || !!g, n = e && t && !r ? e.querySelector('h1, h2, h3, h4, h5, h6, [role="heading"]') : null;
|
|
31
|
+
n && !n.id && (n.id = j);
|
|
32
|
+
const o = n?.id;
|
|
33
|
+
o !== w && ce(o), e && t && !r && !n && !W.current && (W.current = !0, Ce(u));
|
|
29
34
|
}, [
|
|
30
35
|
t,
|
|
31
|
-
|
|
36
|
+
x,
|
|
37
|
+
g,
|
|
38
|
+
S,
|
|
32
39
|
w,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
]),
|
|
38
|
-
|
|
39
|
-
}, [t, s]), P(() => {
|
|
40
|
-
const e = l.current;
|
|
40
|
+
j,
|
|
41
|
+
u
|
|
42
|
+
]), a(() => {
|
|
43
|
+
L.current && !t && f?.transition?.onExited?.(), L.current = t;
|
|
44
|
+
}, [t, f]), U(() => {
|
|
45
|
+
const e = s.current;
|
|
41
46
|
if (!e || !t) return;
|
|
42
|
-
e.open || (
|
|
43
|
-
const
|
|
47
|
+
e.open || (b.current = document.activeElement instanceof HTMLElement ? document.activeElement : null, e.showModal(), e.focus({ preventScroll: !0 }), requestAnimationFrame(() => e.open && e.focus({ preventScroll: !0 })));
|
|
48
|
+
const r = ve(e);
|
|
44
49
|
return () => {
|
|
45
|
-
|
|
50
|
+
r(), b.current?.isConnected && b.current.focus({ preventScroll: !0 });
|
|
46
51
|
};
|
|
47
|
-
}, [t]),
|
|
52
|
+
}, [t]), a(() => {
|
|
48
53
|
if (!t) return;
|
|
49
|
-
const e = document.body.style.overflow,
|
|
54
|
+
const e = document.body.style.overflow, r = document.documentElement.style.overflow;
|
|
50
55
|
return document.body.style.overflow = "hidden", document.documentElement.style.overflow = "hidden", () => {
|
|
51
|
-
document.body.style.overflow = e, document.documentElement.style.overflow =
|
|
56
|
+
document.body.style.overflow = e, document.documentElement.style.overflow = r;
|
|
52
57
|
};
|
|
53
58
|
}, [t]);
|
|
54
|
-
const
|
|
55
|
-
...
|
|
56
|
-
...
|
|
57
|
-
},
|
|
58
|
-
p ||
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
const E = {
|
|
60
|
+
...Z,
|
|
61
|
+
...f?.paper
|
|
62
|
+
}, z = N === !1 ? void 0 : Ie[N], { className: de, style: ue, onClick: fe, ...me } = f?.backdrop ?? {}, A = (e, r) => {
|
|
63
|
+
if (p || c.current) return;
|
|
64
|
+
const n = R?.(e, r);
|
|
65
|
+
if (n && typeof n.then == "function") {
|
|
66
|
+
c.current = !0;
|
|
67
|
+
const o = () => {
|
|
68
|
+
c.current = !1;
|
|
69
|
+
};
|
|
70
|
+
n.then(o, o);
|
|
71
|
+
}
|
|
72
|
+
return n;
|
|
73
|
+
}, F = (e) => k.current ? !1 : (k.current = !0, window.setTimeout(() => {
|
|
74
|
+
k.current = !1;
|
|
75
|
+
}, 0), A(e, "escapeKeyDown"));
|
|
76
|
+
ke({
|
|
77
|
+
active: t,
|
|
78
|
+
requestClose: (e) => !R || H || p || c.current ? !1 : F(e ?? new Event("overlayBack")),
|
|
79
|
+
ownerRef: s
|
|
80
|
+
});
|
|
81
|
+
const he = (e) => {
|
|
82
|
+
e.cancelable && e.preventDefault(), !C.current && T() && D();
|
|
63
83
|
};
|
|
64
|
-
return
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
84
|
+
return a(() => {
|
|
85
|
+
const e = s.current;
|
|
86
|
+
if (!e || !t) return;
|
|
87
|
+
let r = !1;
|
|
88
|
+
const n = () => {
|
|
89
|
+
requestAnimationFrame(() => {
|
|
90
|
+
r = !1, _.current && e.isConnected && !e.open && (e.showModal(), e.focus({ preventScroll: !0 }));
|
|
91
|
+
});
|
|
92
|
+
}, o = () => {
|
|
93
|
+
r || (r = !0, T() && !c.current && D(), n());
|
|
94
|
+
};
|
|
95
|
+
return e.addEventListener("close", o), () => e.removeEventListener("close", o);
|
|
96
|
+
}, [t]), a(() => {
|
|
97
|
+
if (!t || H) return;
|
|
98
|
+
const e = (r) => {
|
|
99
|
+
r.key !== "Escape" || r.defaultPrevented || (r.preventDefault(), r.stopImmediatePropagation(), D(r));
|
|
70
100
|
};
|
|
71
101
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
72
|
-
}),
|
|
73
|
-
|
|
102
|
+
}), a(() => {
|
|
103
|
+
if (!t) return;
|
|
104
|
+
const e = (r) => {
|
|
105
|
+
r.key === "Escape" && (C.current = !0, window.setTimeout(() => {
|
|
106
|
+
C.current = !1;
|
|
107
|
+
}, 0));
|
|
108
|
+
};
|
|
109
|
+
return window.addEventListener("keydown", e, !0), () => window.removeEventListener("keydown", e, !0);
|
|
110
|
+
}, [t]), t ? /* @__PURE__ */ d("dialog", {
|
|
111
|
+
ref: s,
|
|
74
112
|
tabIndex: -1,
|
|
75
|
-
"data-testid":
|
|
76
|
-
"aria-labelledby":
|
|
77
|
-
"aria-label":
|
|
78
|
-
onCancel:
|
|
113
|
+
"data-testid": u,
|
|
114
|
+
"aria-labelledby": x ?? w,
|
|
115
|
+
"aria-label": x || w ? void 0 : g,
|
|
116
|
+
onCancel: he,
|
|
79
117
|
onKeyDown: (e) => {
|
|
80
|
-
!p || e.key !== "Escape" || e.target.closest("dialog[open]") ===
|
|
118
|
+
!p || e.key !== "Escape" || e.target.closest("dialog[open]") === s.current && e.preventDefault();
|
|
81
119
|
},
|
|
82
|
-
className:
|
|
120
|
+
className: B(Ee.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", V === "body" && "overflow-y-auto", $, O?.root),
|
|
83
121
|
style: {
|
|
84
122
|
zIndex: 999,
|
|
85
|
-
...
|
|
86
|
-
...
|
|
123
|
+
...K(Y),
|
|
124
|
+
...J
|
|
87
125
|
},
|
|
88
|
-
children: [/* @__PURE__ */
|
|
89
|
-
...
|
|
90
|
-
className:
|
|
91
|
-
style:
|
|
126
|
+
children: [/* @__PURE__ */ i("div", {
|
|
127
|
+
...me,
|
|
128
|
+
className: B("absolute inset-0 bg-[#626e7eb2]", de),
|
|
129
|
+
style: ue,
|
|
92
130
|
onClick: (e) => {
|
|
93
|
-
|
|
131
|
+
fe?.(e), e.defaultPrevented || A(e, "backdropClick");
|
|
94
132
|
}
|
|
95
133
|
}), /* @__PURE__ */ d("div", {
|
|
96
|
-
className:
|
|
134
|
+
className: B("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]", y && "rounded-none", E.className, O?.paper),
|
|
97
135
|
style: {
|
|
98
136
|
minWidth: 0,
|
|
99
137
|
minHeight: 0,
|
|
100
|
-
...!
|
|
101
|
-
...
|
|
138
|
+
...!y && z ? { maxWidth: z } : {},
|
|
139
|
+
...y ? {
|
|
102
140
|
width: "100%",
|
|
103
141
|
maxWidth: "100%",
|
|
104
142
|
height: "100%",
|
|
105
143
|
maxHeight: "100%"
|
|
106
144
|
} : {
|
|
107
|
-
width:
|
|
145
|
+
width: G ? "calc(100% - 64px)" : "auto",
|
|
108
146
|
maxHeight: "100%"
|
|
109
147
|
},
|
|
110
|
-
...
|
|
111
|
-
...
|
|
112
|
-
...
|
|
148
|
+
...K(E.sx),
|
|
149
|
+
...E.style,
|
|
150
|
+
...y ? {
|
|
113
151
|
width: "100%",
|
|
114
152
|
maxWidth: "100%",
|
|
115
153
|
height: "100%",
|
|
116
154
|
maxHeight: "100%"
|
|
117
155
|
} : { maxHeight: "calc(100% - 64px)" }
|
|
118
156
|
},
|
|
119
|
-
children: [(!!
|
|
157
|
+
children: [(!!m || !!h || M) && /* @__PURE__ */ d("div", {
|
|
120
158
|
className: "box-border flex w-full min-w-0 max-w-full justify-between px-4 pt-4",
|
|
121
159
|
children: [/* @__PURE__ */ d("div", {
|
|
122
160
|
className: "flex min-w-0 flex-1 flex-col justify-start gap-0.5",
|
|
123
|
-
children: [
|
|
124
|
-
id:
|
|
161
|
+
children: [m && /* @__PURE__ */ i("div", {
|
|
162
|
+
id: P,
|
|
125
163
|
className: "flex h-8 items-center text-sm font-normal leading-5 text-delta-600",
|
|
126
|
-
children:
|
|
127
|
-
}),
|
|
128
|
-
id:
|
|
164
|
+
children: m
|
|
165
|
+
}), h && /* @__PURE__ */ i("div", {
|
|
166
|
+
id: v,
|
|
129
167
|
className: "flex text-2xl font-semibold leading-8 text-delta-800",
|
|
130
|
-
children:
|
|
168
|
+
children: h
|
|
131
169
|
})]
|
|
132
|
-
}),
|
|
170
|
+
}), M && /* @__PURE__ */ d("div", {
|
|
133
171
|
className: "flex min-w-0 max-w-full shrink-0 justify-end gap-2",
|
|
134
|
-
children: [
|
|
135
|
-
dataTest: `close-button-${
|
|
136
|
-
"aria-label":
|
|
172
|
+
children: [re, /* @__PURE__ */ i(we, {
|
|
173
|
+
dataTest: `close-button-${u}`,
|
|
174
|
+
"aria-label": q ? void 0 : "Close",
|
|
137
175
|
variant: "textGray",
|
|
138
176
|
size: "small",
|
|
139
|
-
endIcon: /* @__PURE__ */
|
|
177
|
+
endIcon: /* @__PURE__ */ i(xe, {
|
|
140
178
|
width: 20,
|
|
141
179
|
height: 20
|
|
142
180
|
}),
|
|
143
181
|
className: "max-w-full shrink-0 whitespace-nowrap",
|
|
144
182
|
disabled: p,
|
|
145
|
-
disabledReason:
|
|
146
|
-
onClick: (e) =>
|
|
183
|
+
disabledReason: se,
|
|
184
|
+
onClick: (e) => {
|
|
185
|
+
F(e);
|
|
186
|
+
},
|
|
147
187
|
style: {
|
|
148
188
|
color: "var(--colors-delta-800)",
|
|
149
189
|
paddingRight: "6px",
|
|
150
190
|
paddingLeft: "6px"
|
|
151
191
|
},
|
|
152
|
-
children:
|
|
192
|
+
children: q
|
|
153
193
|
})]
|
|
154
194
|
})]
|
|
155
|
-
}), /* @__PURE__ */
|
|
156
|
-
value:
|
|
157
|
-
children: /* @__PURE__ */
|
|
158
|
-
value:
|
|
159
|
-
children:
|
|
195
|
+
}), /* @__PURE__ */ i(be.Provider, {
|
|
196
|
+
value: s,
|
|
197
|
+
children: /* @__PURE__ */ i(Be.Provider, {
|
|
198
|
+
value: le,
|
|
199
|
+
children: /* @__PURE__ */ i(ye.Provider, {
|
|
200
|
+
value: ae,
|
|
201
|
+
children: S
|
|
202
|
+
})
|
|
160
203
|
})
|
|
161
204
|
})]
|
|
162
205
|
})]
|
|
163
206
|
}) : null;
|
|
164
207
|
};
|
|
165
208
|
export {
|
|
166
|
-
|
|
209
|
+
Fe as StyledDialog
|
|
167
210
|
};
|