asma-ui-core 3.109.0 → 3.111.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.
Files changed (59) hide show
  1. package/dist/asma-ui-core.css +1 -1
  2. package/dist/components/feedback/minimizable-dialog/MinimizableDialog.js +41 -39
  3. package/dist/components/feedback/minimizable-dialog/v2/MinimizableDialogV2.js +62 -60
  4. package/dist/components/inputs/dynamic-select/components/DynamicInteractiveChipGroup.js +61 -58
  5. package/dist/components/inputs/dynamic-select/components/DynamicSelectAutocomplete.js +74 -71
  6. package/dist/components/inputs/dynamic-select/components/DynamicSelectReadOnlyValue.js +13 -10
  7. package/dist/components/inputs/field-styles.js +16 -6
  8. package/dist/components/inputs/form-layout/StyledFieldPair.js +22 -0
  9. package/dist/components/inputs/form-layout/StyledFieldPair.module.js +8 -0
  10. package/dist/components/inputs/form-layout/StyledFormColumn.js +13 -0
  11. package/dist/components/inputs/input-field/StyledInputField.js +235 -198
  12. package/dist/components/inputs/phone-field/StyledPhoneField.js +41 -39
  13. package/dist/components/inputs/search-field/StyledSearchField.js +22 -20
  14. package/dist/components/inputs/select/StyledSelect.js +110 -108
  15. package/dist/components/inputs/select-autocomplete/StyledSelectAutocomplete.js +111 -108
  16. package/dist/components/inputs/slider/StyledSlider.js +2 -2
  17. package/dist/components/inputs/textarea/StyledTextarea.js +50 -52
  18. package/dist/components/inputs/textarea/StyledTextarea.module.js +3 -3
  19. package/dist/components/miscellaneous/StyledFormControl.js +29 -25
  20. package/dist/components/miscellaneous/StyledInputLabel.js +28 -18
  21. package/dist/datetime/components/date-picker/components/BaseDatePickerInput.js +137 -122
  22. package/dist/datetime/components/date-picker/components/DatePickerInputRangeCompact.js +17 -15
  23. package/dist/datetime/components/date-picker/components/DatePickerInputRangeCompact.module.js +2 -2
  24. package/dist/datetime/components/date-picker/components/DatePickerInputSingle.js +9 -8
  25. package/dist/datetime/components/date-picker/components/StyledCalendarPickerSelectMonth.js +17 -14
  26. package/dist/datetime/components/date-picker/components/StyledCalendarPickerSelectYear.js +14 -9
  27. package/dist/datetime/components/time-picker/StyledTimePicker.js +78 -74
  28. package/dist/datetime/components/time-picker/TimePickerInput.js +43 -41
  29. package/dist/datetime/components/time-picker/helpers/timePickerWidth.js +12 -0
  30. package/dist/helpers/CharacterCounter.js +21 -0
  31. package/dist/hooks/useBackCloses.hook.js +67 -38
  32. package/dist/hooks/useTopLayer.hook.js +30 -26
  33. package/dist/index.js +284 -273
  34. package/dist/src/components/inputs/dynamic-select/components/DynamicSelectReadOnlyValue.d.ts +2 -2
  35. package/dist/src/components/inputs/dynamic-select/types.d.ts +3 -0
  36. package/dist/src/components/inputs/field-styles.d.ts +22 -0
  37. package/dist/src/components/inputs/form-layout/StyledFieldPair.d.ts +18 -0
  38. package/dist/src/components/inputs/form-layout/StyledFormColumn.d.ts +12 -0
  39. package/dist/src/components/inputs/form-layout/index.d.ts +4 -0
  40. package/dist/src/components/inputs/input-field/StyledInputField.d.ts +19 -4
  41. package/dist/src/components/inputs/select/StyledSelect.d.ts +7 -2
  42. package/dist/src/components/inputs/select-autocomplete/StyledSelectAutocomplete.d.ts +5 -1
  43. package/dist/src/components/inputs/textarea/StyledTextarea.d.ts +6 -0
  44. package/dist/src/components/miscellaneous/StyledFormControl.d.ts +5 -2
  45. package/dist/src/components/miscellaneous/StyledInputLabel.d.ts +7 -5
  46. package/dist/src/datetime/components/date-picker/components/BaseDatePickerInput.d.ts +2 -0
  47. package/dist/src/datetime/components/date-picker/types.d.ts +3 -0
  48. package/dist/src/datetime/components/time-picker/helpers/timePickerWidth.d.ts +7 -0
  49. package/dist/src/datetime/components/time-picker/types.d.ts +3 -1
  50. package/dist/src/helpers/CharacterCounter.d.ts +16 -0
  51. package/dist/src/helpers/CharacterCounter.test.d.ts +1 -0
  52. package/dist/src/hooks/useBackCloses.hook.d.ts +47 -2
  53. package/dist/src/hooks/useTopLayer.hook.d.ts +6 -0
  54. package/dist/src/index.d.ts +2 -0
  55. package/dist/tailwind.config.d.ts +14 -0
  56. package/package.json +1 -1
  57. package/src/styles/fieldWidthTokens.css +8 -0
  58. package/src/styles/index.css +1 -0
  59. package/tw-configs/twConfigs.json +14 -0
@@ -1,115 +1,119 @@
1
- import { isOverlayBackEnabled as I, useBackCloses as j } from "../../../hooks/useBackCloses.hook.js";
2
- import { useIsMobileView as M } from "../../hooks/useWindowWidthSize.hook.js";
3
- import { StyledDrawer as A } from "../../../components/navigation/drawer/StyledDrawer.js";
4
- import { useBackNavigationClose as q } from "../../hooks/useBackNavigationClose.hook.js";
5
- import { usePopupState as F } from "../../../hooks/usePopupState.js";
6
- import { ClickAwayListener as K } from "../../../components/mui-compat/ClickAwayListener.js";
7
- import { isBeforeMinTime as E } from "./helpers/minTime.js";
8
- import { TimePickerPanel as z } from "./components/TimePickerPanel.js";
9
- import { TimePickerPopper as G } from "./TimePickerPopper.js";
10
- import { getTimeFromValue as g } from "./helpers/getTimeFromValue.js";
11
- import { TimePickerInput as J } from "./TimePickerInput.js";
12
- import { useEffect as Q, useState as V } from "react";
13
- import { jsx as r, jsxs as B } from "react/jsx-runtime";
14
- import { format as w, isBefore as R, isValid as U } from "date-fns";
15
- var le = (i) => {
16
- const { value: s, onSelect: n, notBeforeTime: d, minTime: c } = i, o = F({
1
+ import { cn as g } from "../../../helpers/cn.js";
2
+ import { isOverlayBackEnabled as M, useBackCloses as A } from "../../../hooks/useBackCloses.hook.js";
3
+ import { useIsMobileView as q } from "../../hooks/useWindowWidthSize.hook.js";
4
+ import { StyledDrawer as F } from "../../../components/navigation/drawer/StyledDrawer.js";
5
+ import { useBackNavigationClose as K } from "../../hooks/useBackNavigationClose.hook.js";
6
+ import { usePopupState as W } from "../../../hooks/usePopupState.js";
7
+ import { ClickAwayListener as z } from "../../../components/mui-compat/ClickAwayListener.js";
8
+ import { isBeforeMinTime as w } from "./helpers/minTime.js";
9
+ import { TimePickerPanel as G } from "./components/TimePickerPanel.js";
10
+ import { TimePickerPopper as J } from "./TimePickerPopper.js";
11
+ import { getTimeFromValue as B } from "./helpers/getTimeFromValue.js";
12
+ import { timePickerWidthProps as O } from "./helpers/timePickerWidth.js";
13
+ import { TimePickerInput as Q } from "./TimePickerInput.js";
14
+ import { useEffect as R, useState as E } from "react";
15
+ import { jsx as r, jsxs as D } from "react/jsx-runtime";
16
+ import { format as V, isBefore as U, isValid as X } from "date-fns";
17
+ var fe = (o) => {
18
+ const { value: l, onSelect: n, notBeforeTime: d, minTime: c } = o, t = W({
17
19
  variant: "popper",
18
20
  popupId: "time-picker-popper"
19
- }), m = M();
20
- j({
21
- active: o.isOpen,
22
- requestClose: o.close
23
- }), q({
24
- open: m && o.isOpen && !I(),
25
- onClose: o.close
21
+ }), m = q();
22
+ A({
23
+ active: t.isOpen,
24
+ requestClose: t.close
25
+ }), K({
26
+ open: m && t.isOpen && !M(),
27
+ onClose: t.close
26
28
  });
27
- const { isOpen: x, anchorEl: C, close: h } = o;
28
- Q(() => {
29
- if (!x || m) return;
30
- const e = (t) => {
31
- C?.contains(document.activeElement) && (t.key === "Escape" ? (t.preventDefault(), t.stopPropagation(), h()) : t.key === "Tab" && h());
29
+ const { isOpen: P, anchorEl: x, close: h } = t;
30
+ R(() => {
31
+ if (!P || m) return;
32
+ const e = (i) => {
33
+ x?.contains(document.activeElement) && (i.key === "Escape" ? (i.preventDefault(), i.stopPropagation(), h()) : i.key === "Tab" && h());
32
34
  };
33
35
  return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
34
36
  }, [
37
+ P,
35
38
  x,
36
- C,
37
39
  h,
38
40
  m
39
41
  ]);
40
- const P = s ? w(s, "HH:mm") : "", [O, u] = V(P), [T, a] = V(!1), [D, l] = V(!0), v = T ? O : P, k = (e) => !e || !d || !U(d) || !R(e, d), f = v.length === 5 ? g(v, s) : null, H = f ? k(f) : !0, L = (e) => {
41
- const t = e.target.value;
42
- if (a(!0), u(t), t.length !== 5) {
43
- l(!1);
42
+ const C = l ? V(l, "HH:mm") : "", [H, u] = E(C), [b, a] = E(!1), [L, s] = E(!0), v = b ? H : C, k = (e) => !e || !d || !X(d) || !U(e, d), f = v.length === 5 ? B(v, l) : null, N = f ? k(f) : !0, I = (e) => {
43
+ const i = e.target.value;
44
+ if (a(!0), u(i), i.length !== 5) {
45
+ s(!1);
44
46
  return;
45
47
  }
46
- const p = g(t, s);
48
+ const p = B(i, l);
47
49
  if (!p) {
48
- n(void 0), l(!1);
50
+ n(void 0), s(!1);
49
51
  return;
50
52
  }
51
- l(!0), !E(p, c) && (k(p) ? (n(p), a(!1), o.close()) : n(void 0));
52
- }, S = (e) => {
53
- if (!(e && E(e, c))) {
54
- if (l(!0), k(e)) {
55
- n(e), u(e ? w(e, "HH:mm") : ""), a(!1);
53
+ s(!0), !w(p, c) && (k(p) ? (n(p), a(!1), t.close()) : n(void 0));
54
+ }, T = (e) => {
55
+ if (!(e && w(e, c))) {
56
+ if (s(!0), k(e)) {
57
+ n(e), u(e ? V(e, "HH:mm") : ""), a(!1);
56
58
  return;
57
59
  }
58
- n(void 0), u(e ? w(e, "HH:mm") : ""), a(!0);
60
+ n(void 0), u(e ? V(e, "HH:mm") : ""), a(!0);
59
61
  }
60
- }, N = () => {
61
- T && f && E(f, c) && a(!1);
62
- }, b = () => {
63
- n(void 0), u(""), a(!1), l(!0);
64
- }, y = /* @__PURE__ */ r(J, {
65
- ...i,
66
- popupState: o,
62
+ }, j = () => {
63
+ b && f && w(f, c) && a(!1);
64
+ }, S = () => {
65
+ n(void 0), u(""), a(!1), s(!0);
66
+ }, y = /* @__PURE__ */ r(Q, {
67
+ ...o,
68
+ popupState: t,
67
69
  localValue: v,
68
- isValidTime: D,
69
- isValidEndTime: H,
70
- handleChange: L,
71
- handleBlur: N
70
+ isValidTime: L,
71
+ isValidEndTime: N,
72
+ handleChange: I,
73
+ handleBlur: j
72
74
  });
73
- return i.disabled || i.readOnly ? y : m ? /* @__PURE__ */ B("div", {
74
- className: "relative h-auto w-auto",
75
+ return o.disabled || o.readOnly ? y : m ? /* @__PURE__ */ D("div", {
76
+ className: g("relative h-auto", typeof o.width == "number" && "w-auto"),
77
+ ...O(o.width),
75
78
  children: [/* @__PURE__ */ r("div", {
76
79
  className: "m-0 flex h-fit items-center justify-center p-0",
77
80
  children: y
78
- }), /* @__PURE__ */ r(A, {
81
+ }), /* @__PURE__ */ r(F, {
79
82
  anchor: "bottom",
80
- open: o.isOpen,
81
- onClose: o.close,
82
- anchorEl: o.anchorEl,
83
+ open: t.isOpen,
84
+ onClose: t.close,
85
+ anchorEl: t.anchorEl,
83
86
  registerBackClose: !1,
84
87
  children: /* @__PURE__ */ r("div", {
85
88
  className: "mx-auto w-full max-w-[360px] px-4 pb-[max(1rem,env(safe-area-inset-bottom))] pt-2",
86
- children: /* @__PURE__ */ r(z, {
87
- dataTest: i.dataTest,
88
- value: s,
89
+ children: /* @__PURE__ */ r(G, {
90
+ dataTest: o.dataTest,
91
+ value: l,
89
92
  minTime: c,
90
- onSelect: S,
91
- handleClear: b,
92
- onConfirm: o.close
93
+ onSelect: T,
94
+ handleClear: S,
95
+ onConfirm: t.close
93
96
  })
94
97
  })
95
98
  })]
96
- }) : /* @__PURE__ */ r(K, {
99
+ }) : /* @__PURE__ */ r(z, {
97
100
  mouseEvent: "onMouseDown",
98
- onClickAway: o.close,
99
- children: /* @__PURE__ */ B("div", {
100
- className: "relative h-auto w-auto",
101
+ onClickAway: t.close,
102
+ children: /* @__PURE__ */ D("div", {
103
+ className: g("relative h-auto", typeof o.width == "number" && "w-auto"),
104
+ ...O(o.width),
101
105
  children: [/* @__PURE__ */ r("div", {
102
106
  className: "m-0 flex h-fit items-center justify-center p-0",
103
107
  children: y
104
- }), o.isOpen && /* @__PURE__ */ r(G, {
105
- ...i,
106
- popupState: o,
107
- handleClear: b,
108
- onSelect: S
108
+ }), t.isOpen && /* @__PURE__ */ r(J, {
109
+ ...o,
110
+ popupState: t,
111
+ handleClear: S,
112
+ onSelect: T
109
113
  })]
110
114
  })
111
115
  });
112
116
  };
113
117
  export {
114
- le as StyledTimePicker
118
+ fe as StyledTimePicker
115
119
  };
@@ -1,61 +1,63 @@
1
- import { ClockOutlineIcon as P } from "../../../components/icons/clock-outline-icon/ClockOutlineIcon.js";
1
+ import { ClockOutlineIcon as E } from "../../../components/icons/clock-outline-icon/ClockOutlineIcon.js";
2
+ import { fieldLabelAboveClass as N } from "../../../components/inputs/field-styles.js";
2
3
  import { StyledInputField as y } from "../../../components/inputs/input-field/StyledInputField.js";
3
- import { getTitleLabelling as R } from "../../helpers/getTitleLabelling.js";
4
- import { useInputMask as v } from "../../../helpers/inputMask.js";
5
- import { HelperText as w, defaultTimePickerHelperMessages as A } from "./components/HelperText.js";
6
- import { useEffect as H, useId as M, useRef as V } from "react";
7
- import { jsx as l, jsxs as j } from "react/jsx-runtime";
8
- var q = (x) => {
9
- const { placeholder: f, disabled: e, inputClassName: h, dataTest: p, width: o, error: g, helperText: T, label: m, locale: k = "en", popupState: i, handleChange: C, handleBlur: I, isValidTime: d, isValidEndTime: c, localValue: b, title: a, readOnly: t, inputAriaProps: E } = x, N = v({
4
+ import { getTitleLabelling as A } from "../../helpers/getTitleLabelling.js";
5
+ import { useInputMask as R } from "../../../helpers/inputMask.js";
6
+ import { HelperText as w, defaultTimePickerHelperMessages as H } from "./components/HelperText.js";
7
+ import { timePickerWidthProps as M } from "./helpers/timePickerWidth.js";
8
+ import { useEffect as V, useId as W, useRef as j } from "react";
9
+ import { jsx as o, jsxs as z } from "react/jsx-runtime";
10
+ var K = (f) => {
11
+ const { placeholder: h, disabled: e, inputClassName: x, dataTest: m, width: t, error: g, helperText: k, label: p, locale: T = "en", popupState: i, handleChange: C, handleBlur: I, isValidTime: d, isValidEndTime: c, localValue: P, title: l, readOnly: a, inputAriaProps: b } = f, v = R({
10
12
  mask: "xx:xx",
11
13
  maskChar: "x",
12
14
  showMask: !1
13
- }), s = !d || !c || !!g, n = V(null), u = M();
14
- return H(() => {
15
+ }), s = !d || !c || !!g, n = j(null), u = W();
16
+ return V(() => {
15
17
  n.current && i.setAnchorEl(n.current);
16
- }, []), /* @__PURE__ */ j("div", {
17
- style: { height: t ? "40px" : "75px" },
18
- children: [a && /* @__PURE__ */ l("div", {
18
+ }, []), /* @__PURE__ */ z("div", {
19
+ ...M(t),
20
+ children: [l && /* @__PURE__ */ o("div", {
19
21
  id: u,
20
- className: "pb-1 font-roboto font-semibold text-delta-800",
21
- children: a
22
- }), /* @__PURE__ */ l(y, {
23
- inputRef: N,
22
+ className: N({ disabled: e }),
23
+ children: l
24
+ }), /* @__PURE__ */ o(y, {
25
+ inputRef: v,
24
26
  autoComplete: "off",
25
27
  type: "text",
26
- dataTest: p,
27
- "data-testid": p,
28
- placeholder: f,
28
+ dataTest: m,
29
+ "data-testid": m,
30
+ placeholder: h,
29
31
  size: "small",
30
32
  error: s,
31
- helperText: /* @__PURE__ */ l(w, {
33
+ helperText: /* @__PURE__ */ o(w, {
32
34
  isValidTime: d,
33
35
  isValidEndTime: c,
34
36
  error: s,
35
- localization: k,
36
- helperText: T,
37
- messages: A
37
+ localization: T,
38
+ helperText: k,
39
+ messages: H
38
40
  }),
39
41
  onChange: C,
40
42
  onBlur: I,
41
43
  slotProps: {
42
- htmlInput: R({
43
- title: a,
44
+ htmlInput: A({
45
+ title: l,
44
46
  titleId: u,
45
- label: m,
46
- inputAriaProps: E
47
+ label: p,
48
+ inputAriaProps: b
47
49
  }),
48
50
  input: {
49
51
  ref: n,
50
52
  onClick: (r) => {
51
- !e && !t && i.open(r);
53
+ !e && !a && i.open(r);
52
54
  },
53
- endAdornment: /* @__PURE__ */ l(P, {
55
+ endAdornment: /* @__PURE__ */ o(E, {
54
56
  width: 24,
55
57
  height: 24,
56
58
  className: e ? "text-delta-300" : "text-delta-700",
57
59
  onClick: (r) => {
58
- r.stopPropagation(), !e && !t && i.open(r);
60
+ r.stopPropagation(), !e && !a && i.open(r);
59
61
  }
60
62
  })
61
63
  },
@@ -64,19 +66,19 @@ var q = (x) => {
64
66
  hideErrorIcon: !0
65
67
  }
66
68
  },
67
- value: b,
68
- sx: {
69
- maxWidth: o ?? 130,
70
- width: o,
71
- minWidth: o
72
- },
69
+ value: P,
70
+ sx: typeof t == "number" ? {
71
+ maxWidth: t,
72
+ width: t,
73
+ minWidth: t
74
+ } : void 0,
73
75
  disabled: e,
74
- readOnly: t,
75
- className: h,
76
- label: m
76
+ readOnly: a,
77
+ className: x,
78
+ label: p
77
79
  })]
78
80
  });
79
81
  };
80
82
  export {
81
- q as TimePickerInput
83
+ K as TimePickerInput
82
84
  };
@@ -0,0 +1,12 @@
1
+ import { fieldWidthStyle as r } from "../../../../components/inputs/field-styles.js";
2
+ var o = (t) => {
3
+ if (typeof t == "number") return {};
4
+ const e = t ?? "xs";
5
+ return {
6
+ "data-field-width": e,
7
+ style: r(e)
8
+ };
9
+ };
10
+ export {
11
+ o as timePickerWidthProps
12
+ };
@@ -0,0 +1,21 @@
1
+ import { cn as c } from "./cn.js";
2
+ import { Fragment as i, jsx as n, jsxs as h } from "react/jsx-runtime";
3
+ var m = {
4
+ en: (r, a) => `${r} of ${a} characters`,
5
+ no: (r, a) => `${r} av ${a} tegn`
6
+ }, l = (r, a) => a - r <= Math.max(1, Math.min(10, Math.ceil(a * 0.2))), p = ({ id: r, length: a, limit: e, locale: o = "en", className: s }) => {
7
+ const t = m[o](a, e);
8
+ return /* @__PURE__ */ h(i, { children: [/* @__PURE__ */ n("span", {
9
+ id: r,
10
+ "aria-hidden": "true",
11
+ className: c("font-roboto text-sm leading-5 text-delta-600", s),
12
+ children: t
13
+ }), /* @__PURE__ */ n("span", {
14
+ "aria-live": "polite",
15
+ className: "sr-only",
16
+ children: l(a, e) ? t : ""
17
+ })] });
18
+ };
19
+ export {
20
+ p as CharacterCounter
21
+ };
@@ -1,91 +1,119 @@
1
- import { createContext as v, useContext as y, useEffect as p, useRef as O } from "react";
2
- function _() {
1
+ import { findTopmostConnectedModalDialog as w } from "./useTopLayer.hook.js";
2
+ import { createContext as O, useContext as k, useEffect as p, useRef as B } from "react";
3
+ function v() {
3
4
  return {
4
5
  version: 1,
5
6
  entries: [],
6
7
  adapter: { unregister: null }
7
8
  };
8
9
  }
9
- function a() {
10
+ function s() {
10
11
  if (!(typeof window > "u"))
11
12
  return window.rawWindow ?? document.defaultView ?? window;
12
13
  }
13
- function l() {
14
- const e = a();
15
- return e ? e.__asmaOverlayBackRegistry__ ??= _() : k ??= _();
14
+ function c() {
15
+ const e = s(), n = e ? e.__asmaOverlayBackRegistry__ ??= v() : h ??= v();
16
+ return n.entries = A(n.entries), n;
16
17
  }
17
- var k, B = (e) => typeof e == "object" && e !== null && typeof e.then == "function";
18
+ var h, L = (e) => typeof e == "object" && e !== null && typeof e.then == "function";
18
19
  function d(e, n) {
19
20
  if (e.parentOwnerRef && e.parentOwnerRef === n.ownerRef) return !0;
20
21
  const t = e.parentOwnerRef?.current ?? e.parentOwner, i = n.ownerRef?.current ?? n.owner;
21
22
  return !!t && !!i && (t === i || i.contains(t));
22
23
  }
23
- function w(e) {
24
- if (e.adapter.unregister) return;
25
- const n = a()?.__ASMA__SHELL__?.overlayBack;
26
- n?.v !== 1 || typeof n.register != "function" || (e.adapter.unregister = n.register(() => S()));
24
+ function S(e) {
25
+ return c().entries.some((n) => (n.ownerRef?.current ?? n.owner) === e);
27
26
  }
27
+ var _ = /* @__PURE__ */ new WeakSet();
28
28
  function A(e) {
29
+ if (_.has(e)) return e;
30
+ _.add(e);
31
+ const n = e.reduce.bind(e);
32
+ return Object.defineProperty(e, "reduce", {
33
+ configurable: !0,
34
+ value(t, i) {
35
+ return n((o, r, u, f) => y(r) ? o : t(o, r, u, f), i);
36
+ }
37
+ }), e;
38
+ }
39
+ function y(e) {
40
+ const n = w((i) => i.open || S(i));
41
+ if (!n) return !1;
42
+ const t = e.ownerRef?.current ?? e.owner;
43
+ return !t || n.contains(t) ? !1 : !E(t);
44
+ }
45
+ function E(e) {
46
+ return !(e instanceof HTMLElement) || typeof e.showPopover != "function" ? !1 : e.matches(":popover-open");
47
+ }
48
+ function R(e) {
49
+ if (e.adapter.unregister) return;
50
+ const n = s()?.__ASMA__SHELL__?.overlayBack;
51
+ n?.v !== 1 || typeof n.register != "function" || (e.adapter.unregister = n.register(() => b()));
52
+ }
53
+ function m(e) {
29
54
  e.adapter.unregister && Promise.resolve().then(() => {
30
55
  if (e.entries.length > 0) return;
31
56
  const n = e.adapter.unregister;
32
57
  e.adapter.unregister = null, n?.();
33
58
  });
34
59
  }
35
- function L(e, n = null, t = null, i, o) {
36
- const r = l(), s = {
60
+ function C(e, n = null, t = null, i, o) {
61
+ const r = c(), u = {
37
62
  requestClose: e,
38
63
  pending: !1,
39
64
  owner: n,
40
65
  parentOwner: t,
41
66
  ownerRef: i,
42
67
  parentOwnerRef: o
43
- }, c = n || i ? r.entries.findIndex((u) => i !== void 0 && u.parentOwnerRef === i || n !== null && u.parentOwner === n || n !== null && u.owner !== null && n.contains(u.owner)) : -1;
44
- r.entries.splice(c === -1 ? r.entries.length : c, 0, s), r.entries.length === 1 && w(r);
45
- let f = !1;
68
+ }, f = n || i ? r.entries.findIndex((a) => i !== void 0 && a.parentOwnerRef === i || n !== null && a.parentOwner === n || n !== null && a.owner !== null && n.contains(a.owner)) : -1;
69
+ r.entries.splice(f === -1 ? r.entries.length : f, 0, u), r.entries.length === 1 && R(r);
70
+ let l = !1;
46
71
  return () => {
47
- if (f) return;
48
- f = !0;
49
- const u = r.entries.indexOf(s);
50
- if (u !== -1 && r.entries.splice(u, 1), r.entries.length === 0) {
51
- A(r);
72
+ if (l) return;
73
+ l = !0;
74
+ const a = r.entries.indexOf(u);
75
+ if (a !== -1 && r.entries.splice(a, 1), r.entries.length === 0) {
76
+ m(r);
52
77
  return;
53
78
  }
54
79
  queueMicrotask(() => {
55
- const g = a()?.__ASMA__SHELL__?.overlayBack;
80
+ const g = s()?.__ASMA__SHELL__?.overlayBack;
56
81
  r.entries.length > 0 && g?.pendingNavigation && g.continuePendingNavigation?.();
57
82
  });
58
83
  };
59
84
  }
60
- var R = v(void 0);
61
- function S(e) {
62
- const { entries: n } = l(), t = n.reduce((o, r) => !o || d(r, o) ? r : d(o, r) ? o : r, void 0);
63
- if (!t) return;
85
+ var M = O(void 0);
86
+ function b(e) {
87
+ const { entries: n } = c(), t = n.reduce((o, r) => y(r) ? o : !o || d(r, o) ? r : d(o, r) ? o : r, void 0);
88
+ if (!t) return n.length > 0 ? !1 : void 0;
64
89
  if (t.pending) return !1;
65
90
  const i = t.requestClose(e);
66
- if (B(i)) {
91
+ if (L(i)) {
67
92
  t.pending = !0;
68
93
  const o = () => {
69
94
  t.pending = !1, globalThis.setTimeout(() => {
70
- const r = l(), s = a()?.__ASMA__SHELL__?.overlayBack;
71
- r.entries.includes(t) && s?.pendingNavigation && s.failOpenPendingNavigation?.();
95
+ const r = c(), u = s()?.__ASMA__SHELL__?.overlayBack;
96
+ r.entries.includes(t) && u?.pendingNavigation && u.failOpenPendingNavigation?.();
72
97
  }, 0);
73
98
  };
74
99
  i.then(o, o);
75
100
  }
76
101
  return i;
77
102
  }
78
- function E() {
79
- const e = a()?.__ASMA__SHELL__?.overlayBack;
103
+ function I() {
104
+ return s()?.__ASMA__SHELL__?.overlayBack?.pendingNavigation === !0;
105
+ }
106
+ function N() {
107
+ const e = s()?.__ASMA__SHELL__?.overlayBack;
80
108
  return e?.v === 1 && e.enabled === !0;
81
109
  }
82
- function m({ active: e, requestClose: n, ownerRef: t }) {
83
- const i = y(R), o = O(n);
110
+ function T({ active: e, requestClose: n, ownerRef: t }) {
111
+ const i = k(M), o = B(n);
84
112
  p(() => {
85
113
  o.current = n;
86
114
  }, [n]), p(() => {
87
115
  if (e)
88
- return L((r) => o.current(r), t?.current ?? null, i?.current ?? null, t, i);
116
+ return C((r) => o.current(r), t?.current ?? null, i?.current ?? null, t, i);
89
117
  }, [
90
118
  e,
91
119
  t,
@@ -93,8 +121,9 @@ function m({ active: e, requestClose: n, ownerRef: t }) {
93
121
  ]);
94
122
  }
95
123
  export {
96
- R as OverlayBackOwnerContext,
97
- E as isOverlayBackEnabled,
98
- S as requestCloseTopOverlayBack,
99
- m as useBackCloses
124
+ M as OverlayBackOwnerContext,
125
+ N as isOverlayBackEnabled,
126
+ I as isOverlayBackNavigationPending,
127
+ b as requestCloseTopOverlayBack,
128
+ T as useBackCloses
100
129
  };
@@ -1,15 +1,15 @@
1
- import { useCallback as r, useSyncExternalStore as s } from "react";
2
- var c = { popover: "manual" }, p = {
1
+ import { useCallback as s, useSyncExternalStore as a } from "react";
2
+ var p = { popover: "manual" }, g = {
3
3
  margin: 0,
4
4
  inset: "auto"
5
5
  };
6
- function f(e) {
6
+ function w(e) {
7
7
  if (!(e instanceof Element)) return;
8
8
  const o = e.closest("dialog");
9
9
  return o instanceof HTMLDialogElement && o.open ? o : void 0;
10
10
  }
11
11
  function t() {
12
- if (typeof window > "u") return a ??= {
12
+ if (typeof window > "u") return l ??= {
13
13
  dialogs: [],
14
14
  listeners: /* @__PURE__ */ new Set()
15
15
  };
@@ -19,34 +19,37 @@ function t() {
19
19
  listeners: /* @__PURE__ */ new Set()
20
20
  };
21
21
  }
22
- var a, i = () => {
22
+ var l, r = () => {
23
23
  for (const e of [...t().listeners]) e();
24
24
  };
25
- function g(e) {
26
- return t().dialogs.push(e), i(), () => {
25
+ function v(e) {
26
+ return t().dialogs.push(e), r(), () => {
27
27
  const { dialogs: o } = t(), n = o.indexOf(e);
28
- n !== -1 && (o.splice(n, 1), i());
28
+ n !== -1 && (o.splice(n, 1), r());
29
29
  };
30
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;
31
+ function u(e) {
32
+ const { dialogs: o } = t();
33
+ for (let n = o.length - 1; n >= 0; n -= 1) {
34
+ const i = o[n];
35
+ if (i?.isConnected && e(i)) return i;
36
36
  }
37
37
  }
38
- var u = (e) => (t().listeners.add(e), () => {
38
+ function d() {
39
+ return u((e) => e.open);
40
+ }
41
+ var c = (e) => (t().listeners.add(e), () => {
39
42
  t().listeners.delete(e);
40
43
  });
41
- function w() {
42
- return s(u, l, () => {
44
+ function m() {
45
+ return a(c, d, () => {
43
46
  });
44
47
  }
45
- function v(e) {
48
+ function O(e) {
46
49
  return e == null;
47
50
  }
48
- function O(e, o = !0) {
49
- return r((n) => {
51
+ function T(e, o = !0) {
52
+ return s((n) => {
50
53
  if (e(n), !(!n || !o))
51
54
  try {
52
55
  typeof n.showPopover == "function" && !n.matches(":popover-open") && n.showPopover();
@@ -55,11 +58,12 @@ function O(e, o = !0) {
55
58
  }, [e, o]);
56
59
  }
57
60
  export {
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
61
+ p as TOP_LAYER_PROPS,
62
+ g as TOP_LAYER_RESET_STYLE,
63
+ u as findTopmostConnectedModalDialog,
64
+ w as getOpenModalDialogAncestor,
65
+ v as registerOpenModalDialog,
66
+ O as shouldUsePopoverTopLayer,
67
+ T as useTopLayerRef,
68
+ m as useTopmostOpenModalDialog
65
69
  };