asma-ui-core 3.108.3 → 3.108.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,104 +1,115 @@
1
- import { useIsMobileView as j } from "../../hooks/useWindowWidthSize.hook.js";
2
- import { StyledDrawer as B } from "../../../components/navigation/drawer/StyledDrawer.js";
3
- import { usePopupState as M } from "../../../hooks/usePopupState.js";
4
- import { ClickAwayListener as A } from "../../../components/mui-compat/ClickAwayListener.js";
5
- import { isBeforeMinTime as k } from "./helpers/minTime.js";
6
- import { TimePickerPanel as F } from "./components/TimePickerPanel.js";
7
- import { TimePickerPopper as K } from "./TimePickerPopper.js";
8
- import { getTimeFromValue as C } from "./helpers/getTimeFromValue.js";
9
- import { TimePickerInput as q } from "./TimePickerInput.js";
10
- import { useEffect as z, useState as w } from "react";
11
- import { jsx as r, jsxs as D } from "react/jsx-runtime";
12
- import { format as E, isBefore as G, isValid as J } from "date-fns";
13
- var re = (i) => {
14
- const { value: l, onSelect: n, notBeforeTime: p, minTime: c } = i, t = M({
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({
15
17
  variant: "popper",
16
18
  popupId: "time-picker-popper"
17
- }), d = j(), { isOpen: x, anchorEl: P, close: h } = t;
18
- z(() => {
19
- if (!x || d) return;
20
- const e = (o) => {
21
- P?.contains(document.activeElement) && (o.key === "Escape" ? (o.preventDefault(), o.stopPropagation(), h()) : o.key === "Tab" && h());
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
26
+ });
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());
22
32
  };
23
33
  return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
24
34
  }, [
25
35
  x,
26
- P,
36
+ C,
27
37
  h,
28
- d
38
+ m
29
39
  ]);
30
- const T = l ? E(l, "HH:mm") : "", [H, m] = w(T), [S, a] = w(!1), [L, s] = w(!0), v = S ? H : T, y = (e) => !e || !p || !J(p) || !G(e, p), u = v.length === 5 ? C(v, l) : null, I = u ? y(u) : !0, N = (e) => {
31
- const o = e.target.value;
32
- if (a(!0), m(o), o.length !== 5) {
33
- s(!1);
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);
34
44
  return;
35
45
  }
36
- const f = C(o, l);
37
- if (!f) {
38
- n(void 0), s(!1);
46
+ const p = g(t, s);
47
+ if (!p) {
48
+ n(void 0), l(!1);
39
49
  return;
40
50
  }
41
- s(!0), !k(f, c) && (y(f) ? (n(f), a(!1), t.close()) : n(void 0));
42
- }, b = (e) => {
43
- if (!(e && k(e, c))) {
44
- if (s(!0), y(e)) {
45
- n(e), m(e ? E(e, "HH:mm") : ""), a(!1);
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);
46
56
  return;
47
57
  }
48
- n(void 0), m(e ? E(e, "HH:mm") : ""), a(!0);
58
+ n(void 0), u(e ? w(e, "HH:mm") : ""), a(!0);
49
59
  }
50
- }, O = () => {
51
- S && u && k(u, c) && a(!1);
52
- }, g = () => {
53
- n(void 0), m(""), a(!1), s(!0);
54
- }, V = /* @__PURE__ */ r(q, {
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, {
55
65
  ...i,
56
- popupState: t,
66
+ popupState: o,
57
67
  localValue: v,
58
- isValidTime: L,
59
- isValidEndTime: I,
60
- handleChange: N,
61
- handleBlur: O
68
+ isValidTime: D,
69
+ isValidEndTime: H,
70
+ handleChange: L,
71
+ handleBlur: N
62
72
  });
63
- return i.disabled || i.readOnly ? V : d ? /* @__PURE__ */ D("div", {
73
+ return i.disabled || i.readOnly ? y : m ? /* @__PURE__ */ B("div", {
64
74
  className: "relative h-auto w-auto",
65
75
  children: [/* @__PURE__ */ r("div", {
66
76
  className: "m-0 flex h-fit items-center justify-center p-0",
67
- children: V
68
- }), /* @__PURE__ */ r(B, {
77
+ children: y
78
+ }), /* @__PURE__ */ r(A, {
69
79
  anchor: "bottom",
70
- open: t.isOpen,
71
- onClose: t.close,
72
- anchorEl: t.anchorEl,
80
+ open: o.isOpen,
81
+ onClose: o.close,
82
+ anchorEl: o.anchorEl,
83
+ registerBackClose: !1,
73
84
  children: /* @__PURE__ */ r("div", {
74
85
  className: "mx-auto w-full max-w-[360px] px-4 pb-[max(1rem,env(safe-area-inset-bottom))] pt-2",
75
- children: /* @__PURE__ */ r(F, {
86
+ children: /* @__PURE__ */ r(z, {
76
87
  dataTest: i.dataTest,
77
- value: l,
88
+ value: s,
78
89
  minTime: c,
79
- onSelect: b,
80
- handleClear: g,
81
- onConfirm: t.close
90
+ onSelect: S,
91
+ handleClear: b,
92
+ onConfirm: o.close
82
93
  })
83
94
  })
84
95
  })]
85
- }) : /* @__PURE__ */ r(A, {
96
+ }) : /* @__PURE__ */ r(K, {
86
97
  mouseEvent: "onMouseDown",
87
- onClickAway: t.close,
88
- children: /* @__PURE__ */ D("div", {
98
+ onClickAway: o.close,
99
+ children: /* @__PURE__ */ B("div", {
89
100
  className: "relative h-auto w-auto",
90
101
  children: [/* @__PURE__ */ r("div", {
91
102
  className: "m-0 flex h-fit items-center justify-center p-0",
92
- children: V
93
- }), t.isOpen && /* @__PURE__ */ r(K, {
103
+ children: y
104
+ }), o.isOpen && /* @__PURE__ */ r(G, {
94
105
  ...i,
95
- popupState: t,
96
- handleClear: g,
97
- onSelect: b
106
+ popupState: o,
107
+ handleClear: b,
108
+ onSelect: S
98
109
  })]
99
110
  })
100
111
  });
101
112
  };
102
113
  export {
103
- re as StyledTimePicker
114
+ le as StyledTimePicker
104
115
  };
@@ -0,0 +1,19 @@
1
+ import { useEffect as i, useRef as c } from "react";
2
+ var n = "__asmaPickerBack", u = ({ open: r, onClose: e }) => {
3
+ const o = c(e);
4
+ i(() => {
5
+ o.current = e;
6
+ }, [e]), i(() => {
7
+ if (!r) return;
8
+ const t = window.rawWindow ?? window, s = crypto.randomUUID(), a = () => o.current();
9
+ return t.history.pushState({
10
+ ...t.history.state,
11
+ [n]: s
12
+ }, "", t.location.href), t.addEventListener("popstate", a), () => {
13
+ t.removeEventListener("popstate", a), t.history.state?.[n] === s && t.history.back();
14
+ };
15
+ }, [r]);
16
+ };
17
+ export {
18
+ u as useBackNavigationClose
19
+ };
@@ -22,6 +22,8 @@ export interface DrawerProps {
22
22
  };
23
23
  /** Trigger element — when inside a modal `<dialog>`, portal into it so the sheet is interactive. */
24
24
  anchorEl?: Element | null;
25
+ /** Set `false` when a wrapper already owns the Back-close registration. */
26
+ registerBackClose?: boolean;
25
27
  children?: ReactNode;
26
28
  }
27
29
  /**
@@ -1,4 +1,4 @@
1
- import { ReactNode } from 'react';
1
+ import { ReactNode, RefObject } from 'react';
2
2
  import { PopoverSlot } from '../popover/PopoverSheet';
3
3
  export type BottomSheetCloseReason = 'closeButton' | 'scrim' | 'escape' | 'drag' | 'viewResults' | 'action';
4
4
  /** @figmaNode 9Q7C7JYPgnUSsrX1L8v40t#5354-169163 (Ad-Voca-concept · "_bottom sheet") */
@@ -41,6 +41,10 @@ export interface StyledBottomSheetProps {
41
41
  closeLabel?: string;
42
42
  /** @figmaProp none — style escape hatch, applied to the sheet container */
43
43
  className?: string;
44
+ /** Set `false` when a wrapper already owns the Back-close registration. */
45
+ registerBackClose?: boolean;
46
+ /** Logical owner supplied by a wrapper that must keep one identity across responsive variants. */
47
+ ownerRef?: RefObject<Element | null>;
44
48
  }
45
49
  /**
46
50
  * ASMA Design System **Bottom Sheet** (ASMA-8184) — the mobile (0–743px) form of the Action popover:
@@ -56,4 +60,4 @@ export interface StyledBottomSheetProps {
56
60
  * Focus moves to the sheet on open (so the title is announced first) and back to the trigger on
57
61
  * close. `PopoverSheet` with `variant='action'` renders this automatically below 744px.
58
62
  */
59
- export declare const StyledBottomSheet: ({ dataTest, id, open, onClose, title, ariaLabel, children, viewResultsAction, resetAction, footerActions, resultCount, closeLabel, className, }: StyledBottomSheetProps) => JSX.Element | null;
63
+ export declare const StyledBottomSheet: ({ dataTest, id, open, onClose, title, ariaLabel, children, viewResultsAction, resetAction, footerActions, resultCount, closeLabel, className, registerBackClose, ownerRef, }: StyledBottomSheetProps) => JSX.Element | null;
@@ -35,6 +35,8 @@ export interface StyledPopoverProps {
35
35
  * dialog in the same tick it opens.
36
36
  */
37
37
  keepMounted?: boolean;
38
+ /** Set `false` when a wrapper already owns the Back-close registration. */
39
+ registerBackClose?: boolean;
38
40
  }
39
41
  /**
40
42
  * @figmaNode none — no standalone Figma component
@@ -51,4 +53,4 @@ export interface StyledPopoverProps {
51
53
  * mapping to MUI's `onClose(event, reason)`. `anchorOrigin`/`transformOrigin`/`slotProps.paper`
52
54
  * preserved (DEC-003). TASK-302.
53
55
  */
54
- export declare const StyledPopover: ({ open, anchorEl, onClose, anchorOrigin, transformOrigin, id, className, sx, slotProps, onClick, children, keepMounted, tabIntoContent, }: StyledPopoverProps) => JSX.Element | null;
56
+ export declare const StyledPopover: ({ open, anchorEl, onClose, anchorOrigin, transformOrigin, id, className, sx, slotProps, onClick, children, keepMounted, tabIntoContent, registerBackClose, }: StyledPopoverProps) => JSX.Element | null;
@@ -0,0 +1,5 @@
1
+ /** Keeps the pre-adapter picker Back behavior while the host rollout flag is off. */
2
+ export declare const useBackNavigationClose: ({ open, onClose }: {
3
+ open: boolean;
4
+ onClose: () => void;
5
+ }) => void;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.108.3",
6
+ "version": "3.108.4",
7
7
  "type": "module",
8
8
  "sideEffects": [
9
9
  "**/*.css",