asma-ui-core 3.136.0 → 3.136.2

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