asma-ui-core 3.86.1 → 3.87.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.
- package/dist/asma-ui-core.css +1 -1
- package/dist/components/custom/pathfinder-card/PathfinderCard.js +28 -28
- package/dist/components/data-display/chip/StyledChip.js +33 -32
- package/dist/components/data-display/tooltip/StyledTooltip.js +76 -47
- package/dist/components/feedback/dialog/StyledDialog.js +62 -58
- package/dist/components/feedback/minimizable-dialog/MinimizableDialog.js +113 -105
- package/dist/components/feedback/minimizable-dialog/components/FullscreenBtn.js +10 -12
- package/dist/components/feedback/minimizable-dialog/v2/MinimizableDialogV2.js +75 -67
- package/dist/components/feedback/snack-bar/StyledSnackbar.js +12 -10
- package/dist/components/feedback/snack-bar/components/StyledInfoSnackbar.js +10 -10
- package/dist/components/inputs/dynamic-select/components/DynamicSelectAutocomplete.js +69 -71
- package/dist/components/inputs/input-field/StyledInputField.js +25 -24
- package/dist/components/inputs/phone-field/CountryCodeOptions.js +16 -15
- package/dist/components/inputs/phone-field/CountryCodeSelect.js +98 -85
- package/dist/components/inputs/phone-field/useCountryPicker.js +44 -24
- package/dist/components/inputs/search-field/StyledSearchField.js +10 -10
- package/dist/components/inputs/select/StyledSelect.js +16 -15
- package/dist/components/inputs/select/StyledSelectItem.js +9 -9
- package/dist/components/inputs/select-autocomplete/StyledSelectAutocomplete.js +202 -175
- package/dist/components/inputs/switch/base-ui/StyledSwitch.js +22 -22
- package/dist/components/navigation/link/StyledLink.js +8 -8
- package/dist/components/navigation/listbox/Listbox.js +105 -54
- package/dist/components/navigation/menu/StyledMenu.js +22 -18
- package/dist/components/navigation/menu/StyledMenuItem.js +6 -6
- package/dist/components/navigation/title-chevron/StyledTitleChevron.js +7 -7
- package/dist/components/utils/accordion/base-ui/StyledAccordionDetails.js +26 -22
- package/dist/components/utils/accordion/base-ui/StyledAccordionSummary.js +14 -14
- package/dist/components/utils/copy-wrapper/CopyWrapper.module.js +2 -2
- package/dist/components/utils/popover/StyledPopover.js +102 -52
- package/dist/datetime/components/date-picker/StyledDatePicker.js +40 -34
- package/dist/datetime/components/date-picker/components/StyledCalendarPicker.js +5 -4
- package/dist/datetime/components/time-picker/StyledTimePicker.js +69 -56
- package/dist/helpers/focusable.js +5 -0
- package/dist/hooks/useFocusTrap.hook.js +24 -19
- package/dist/src/components/data-display/chip/StyledChip.d.ts +2 -0
- package/dist/src/components/inputs/dynamic-select/StyledDynamicSelect.d.ts +3 -4
- package/dist/src/components/inputs/dynamic-select/components/DynamicSelectAutocomplete.test.d.ts +1 -0
- package/dist/src/components/inputs/phone-field/CountryCodeOptions.d.ts +1 -1
- package/dist/src/components/inputs/phone-field/useCountryPicker.d.ts +5 -2
- package/dist/src/components/navigation/listbox/Listbox.d.ts +3 -2
- package/dist/src/components/navigation/menu/StyledMenu.d.ts +3 -2
- package/dist/src/components/utils/accordion/base-ui/StyledAccordionDetails.d.ts +2 -1
- package/dist/src/components/utils/popover/StyledPopover.d.ts +9 -2
- package/dist/src/helpers/focusable.d.ts +8 -0
- package/dist/src/hooks/useFocusTrap.hook.d.ts +2 -1
- package/dist/table/components/columns/action-column/components/RowActionMenu.js +30 -34
- package/dist/table/components/table-footer/TablePagination.js +18 -17
- package/dist/table/components/table-footer/TableRowCountSelect.js +5 -4
- package/package.json +1 -1
- package/src/styles/touchHardening.interaction.test.tsx +269 -0
|
@@ -1,80 +1,131 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { cn as w } from "../../../helpers/cn.js";
|
|
2
|
+
import { tabbableWithin as $ } from "../../../helpers/focusable.js";
|
|
3
|
+
import { ClickAwayListener as C } from "../../mui-compat/ClickAwayListener.js";
|
|
4
|
+
import { Children as O, cloneElement as g, createContext as D, isValidElement as B, useCallback as N, useContext as S, useEffect as I, useId as M, useMemo as T, useRef as q, useState as k } from "react";
|
|
5
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
6
|
+
var A = D(null), y = () => {
|
|
7
|
+
const t = S(A);
|
|
6
8
|
if (!t) throw new Error("Listbox.Button/Options/Option must be rendered inside <Listbox>");
|
|
7
9
|
return t;
|
|
8
|
-
},
|
|
9
|
-
function
|
|
10
|
-
const [
|
|
11
|
-
|
|
10
|
+
}, h = (t, a) => typeof t == "function" ? t(a) : t;
|
|
11
|
+
function P({ value: t, onChange: a, children: u }) {
|
|
12
|
+
const [s, d] = k(!1), [n, o] = k(null), r = `listbox-${M()}`, p = q(null), l = N(() => {
|
|
13
|
+
d(!1), o(null);
|
|
14
|
+
}, []);
|
|
15
|
+
I(() => {
|
|
16
|
+
if (!s) return;
|
|
17
|
+
const i = (b) => {
|
|
18
|
+
if (b.key !== "Escape") return;
|
|
19
|
+
const e = p.current;
|
|
20
|
+
e?.contains(document.activeElement) && e.querySelector('[role="combobox"]')?.focus(), l();
|
|
21
|
+
};
|
|
22
|
+
return document.addEventListener("keydown", i), () => document.removeEventListener("keydown", i);
|
|
23
|
+
}, [s, l]);
|
|
24
|
+
const f = T(() => ({
|
|
25
|
+
open: s,
|
|
12
26
|
select: (i) => {
|
|
13
|
-
|
|
27
|
+
a(i), l();
|
|
14
28
|
},
|
|
15
|
-
setOpen:
|
|
29
|
+
setOpen: d,
|
|
30
|
+
setActiveIndex: o,
|
|
31
|
+
activeIndex: n,
|
|
32
|
+
listboxId: r,
|
|
16
33
|
value: t
|
|
17
34
|
}), [
|
|
18
|
-
|
|
35
|
+
s,
|
|
19
36
|
t,
|
|
20
|
-
|
|
37
|
+
a,
|
|
38
|
+
n,
|
|
39
|
+
r,
|
|
40
|
+
l
|
|
21
41
|
]);
|
|
22
|
-
return
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
42
|
+
return /* @__PURE__ */ m(A.Provider, {
|
|
43
|
+
value: f,
|
|
44
|
+
children: /* @__PURE__ */ m(C, {
|
|
45
|
+
onClickAway: l,
|
|
46
|
+
children: /* @__PURE__ */ m("div", {
|
|
47
|
+
ref: (i) => {
|
|
48
|
+
p.current = i;
|
|
49
|
+
},
|
|
50
|
+
onBlur: (i) => {
|
|
51
|
+
i.relatedTarget && !i.currentTarget.contains(i.relatedTarget) && l();
|
|
52
|
+
},
|
|
33
53
|
className: "relative w-full",
|
|
34
|
-
children:
|
|
54
|
+
children: u
|
|
35
55
|
})
|
|
36
56
|
})
|
|
37
57
|
});
|
|
38
58
|
}
|
|
39
|
-
var
|
|
40
|
-
const {
|
|
41
|
-
|
|
59
|
+
var R = ({ children: t, className: a, onClick: u, onKeyDown: s, ...d }) => {
|
|
60
|
+
const { activeIndex: n, listboxId: o, open: r, setActiveIndex: p, setOpen: l } = y(), f = () => Array.from(document.querySelectorAll(`#${CSS.escape(o)} [role="option"]:not([aria-disabled="true"])`)), i = (e) => {
|
|
61
|
+
const c = f();
|
|
62
|
+
if (c.length === 0) return;
|
|
63
|
+
const x = c.findIndex((L) => L.id === `${o}-option-${n}`), E = x === -1 ? e === 1 ? 0 : c.length - 1 : Math.min(Math.max(x + e, 0), c.length - 1);
|
|
64
|
+
p(Number(c[E].dataset.index));
|
|
65
|
+
}, b = (e) => {
|
|
66
|
+
if (s?.(e), !e.defaultPrevented)
|
|
67
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp")
|
|
68
|
+
e.preventDefault(), r ? i(e.key === "ArrowDown" ? 1 : -1) : (l(!0), requestAnimationFrame(() => i(e.key === "ArrowDown" ? 1 : -1)));
|
|
69
|
+
else if (r && (e.key === "Home" || e.key === "End")) {
|
|
70
|
+
e.preventDefault();
|
|
71
|
+
const c = f(), x = c[e.key === "Home" ? 0 : c.length - 1];
|
|
72
|
+
x && p(Number(x.dataset.index));
|
|
73
|
+
} else r && (e.key === "Enter" || e.key === " ") && (e.preventDefault(), f().find((c) => c.id === `${o}-option-${n}`)?.click());
|
|
74
|
+
};
|
|
75
|
+
return /* @__PURE__ */ m("button", {
|
|
76
|
+
...d,
|
|
42
77
|
type: "button",
|
|
43
|
-
className:
|
|
44
|
-
onClick: () =>
|
|
45
|
-
|
|
46
|
-
|
|
78
|
+
className: w("asma-pressable", a),
|
|
79
|
+
onClick: (e) => {
|
|
80
|
+
u?.(e), e.defaultPrevented || l(!r);
|
|
81
|
+
},
|
|
82
|
+
onKeyDown: b,
|
|
83
|
+
role: "combobox",
|
|
84
|
+
"aria-haspopup": "listbox",
|
|
85
|
+
"aria-expanded": r,
|
|
86
|
+
"aria-controls": r ? o : void 0,
|
|
87
|
+
"aria-activedescendant": r && n !== null ? `${o}-option-${n}` : void 0,
|
|
88
|
+
children: h(t, { open: r })
|
|
47
89
|
});
|
|
48
|
-
},
|
|
49
|
-
const { open:
|
|
50
|
-
return
|
|
90
|
+
}, V = ({ children: t, className: a }) => {
|
|
91
|
+
const { activeIndex: u, listboxId: s, open: d } = y();
|
|
92
|
+
return I(() => {
|
|
93
|
+
u !== null && document.getElementById(`${s}-option-${u}`)?.scrollIntoView({ block: "nearest" });
|
|
94
|
+
}, [u, s]), d ? /* @__PURE__ */ m("div", {
|
|
95
|
+
id: s,
|
|
51
96
|
role: "listbox",
|
|
52
|
-
className:
|
|
53
|
-
children:
|
|
97
|
+
className: a,
|
|
98
|
+
children: (() => {
|
|
99
|
+
let n = 0;
|
|
100
|
+
return O.toArray(t).map((o) => B(o) && o.type === v ? g(o, { optionIndex: n++ }) : o);
|
|
101
|
+
})()
|
|
54
102
|
}) : null;
|
|
55
103
|
};
|
|
56
|
-
function
|
|
57
|
-
const n =
|
|
58
|
-
|
|
104
|
+
function v({ value: t, disabled: a, children: u, className: s, optionIndex: d = 0 }) {
|
|
105
|
+
const n = y(), o = n.value === t, r = () => {
|
|
106
|
+
a || n.select(t);
|
|
59
107
|
};
|
|
60
|
-
return /* @__PURE__ */
|
|
108
|
+
return /* @__PURE__ */ m("div", {
|
|
109
|
+
id: `${n.listboxId}-option-${d}`,
|
|
61
110
|
role: "option",
|
|
62
|
-
"aria-selected":
|
|
63
|
-
"aria-disabled":
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
111
|
+
"aria-selected": o,
|
|
112
|
+
"aria-disabled": a,
|
|
113
|
+
"data-index": d,
|
|
114
|
+
tabIndex: -1,
|
|
115
|
+
className: w("asma-pressable", s),
|
|
116
|
+
onMouseDown: (p) => {
|
|
117
|
+
const l = p.target;
|
|
118
|
+
$(p.currentTarget).some((f) => f.contains(l)) || p.preventDefault();
|
|
69
119
|
},
|
|
70
|
-
|
|
120
|
+
onClick: r,
|
|
121
|
+
children: h(u, { selected: o })
|
|
71
122
|
});
|
|
72
123
|
}
|
|
73
|
-
var
|
|
74
|
-
Button:
|
|
75
|
-
Option:
|
|
76
|
-
Options:
|
|
124
|
+
var W = Object.assign(P, {
|
|
125
|
+
Button: R,
|
|
126
|
+
Option: v,
|
|
127
|
+
Options: V
|
|
77
128
|
});
|
|
78
129
|
export {
|
|
79
|
-
|
|
130
|
+
W as Listbox
|
|
80
131
|
};
|
|
@@ -1,30 +1,34 @@
|
|
|
1
|
-
import { cn as
|
|
2
|
-
import { StyledPopover as
|
|
3
|
-
import { StyledMenuList as
|
|
4
|
-
import { jsx as
|
|
5
|
-
var
|
|
1
|
+
import { cn as u } from "../../../helpers/cn.js";
|
|
2
|
+
import { StyledPopover as c } from "../../utils/popover/StyledPopover.js";
|
|
3
|
+
import { StyledMenuList as S } from "./StyledMenuList.js";
|
|
4
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
5
|
+
var N = {
|
|
6
6
|
border: "1px solid var(--colors-delta-300)",
|
|
7
7
|
boxShadow: "0px 2px 4px 0px rgba(34, 33, 51, 0.15)"
|
|
8
|
-
}, h = ({ open:
|
|
9
|
-
open:
|
|
10
|
-
anchorEl:
|
|
8
|
+
}, h = ({ open: p, anchorEl: m, onClose: t, anchorOrigin: l, transformOrigin: i, id: d, className: s, sx: x, classes: a, slotProps: e, autoFocus: n = !0, onClick: y, children: b, keepMounted: f }) => /* @__PURE__ */ o(c, {
|
|
9
|
+
open: p,
|
|
10
|
+
anchorEl: m,
|
|
11
11
|
onClose: t,
|
|
12
|
+
tabIntoContent: !1,
|
|
12
13
|
anchorOrigin: l,
|
|
13
|
-
transformOrigin:
|
|
14
|
+
transformOrigin: i,
|
|
14
15
|
id: d,
|
|
15
16
|
className: s,
|
|
16
17
|
sx: x,
|
|
17
|
-
keepMounted:
|
|
18
|
+
keepMounted: f,
|
|
18
19
|
slotProps: { paper: {
|
|
19
|
-
className:
|
|
20
|
-
sx: [
|
|
21
|
-
style:
|
|
20
|
+
className: u("rounded", a?.paper, e?.paper?.className),
|
|
21
|
+
sx: [N, e?.paper?.sx],
|
|
22
|
+
style: e?.paper?.style
|
|
22
23
|
} },
|
|
23
|
-
children: /* @__PURE__ */
|
|
24
|
-
autoFocus:
|
|
25
|
-
className:
|
|
26
|
-
onClick:
|
|
27
|
-
|
|
24
|
+
children: /* @__PURE__ */ o(S, {
|
|
25
|
+
autoFocus: n,
|
|
26
|
+
className: a?.list,
|
|
27
|
+
onClick: y,
|
|
28
|
+
onKeyDown: (r) => {
|
|
29
|
+
r.key === "Tab" && r.target.getAttribute("role") === "menuitem" && t?.(r, "tabKeyDown");
|
|
30
|
+
},
|
|
31
|
+
children: b
|
|
28
32
|
})
|
|
29
33
|
});
|
|
30
34
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { cn as r } from "../../../helpers/cn.js";
|
|
2
|
-
import { resolveSx as
|
|
2
|
+
import { resolveSx as c } from "../../../helpers/sx.js";
|
|
3
3
|
import { jsx as f } from "react/jsx-runtime";
|
|
4
|
-
var
|
|
4
|
+
var g = ({ children: n, onClick: o, onMouseDown: i, onMouseUp: s, disabled: e, selected: l, dense: m, className: d, classes: a, sx: u, "data-test": p, "data-testid": x, value: v }) => /* @__PURE__ */ f("li", {
|
|
5
5
|
role: "menuitem",
|
|
6
6
|
"aria-disabled": e ? !0 : void 0,
|
|
7
7
|
tabIndex: -1,
|
|
@@ -9,17 +9,17 @@ var D = ({ children: n, onClick: o, onMouseDown: i, onMouseUp: l, disabled: e, s
|
|
|
9
9
|
"data-testid": x,
|
|
10
10
|
onClick: e ? void 0 : o,
|
|
11
11
|
onMouseDown: e ? void 0 : i,
|
|
12
|
-
onMouseUp: e ? void 0 :
|
|
12
|
+
onMouseUp: e ? void 0 : s,
|
|
13
13
|
onKeyDown: (t) => {
|
|
14
14
|
e || (t.key === "Enter" || t.key === " ") && (t.preventDefault(), o?.(t));
|
|
15
15
|
},
|
|
16
|
-
className: r("box-border flex items-center px-4 text-base outline-none", m ? "min-h-8 py-1" : "min-h-10 py-2", "asma-pressable asma-touch-target", e ? "cursor-not-allowed text-delta-300 aria-disabled:text-delta-300" : "cursor-pointer text-delta-700 hover:bg-delta-50",
|
|
16
|
+
className: r("box-border flex items-center px-4 text-base outline-none focus-visible:shadow-[inset_3px_0_var(--colors-focus-ring)]", m ? "min-h-8 py-1" : "min-h-10 py-2", "asma-pressable asma-touch-target", e ? "cursor-not-allowed text-delta-300 aria-disabled:text-delta-300" : "cursor-pointer text-delta-700 hover:bg-delta-50", l && r("bg-gama-50", a?.selected), a?.root, d),
|
|
17
17
|
style: {
|
|
18
18
|
fontFamily: "Roboto, Helvetica, Arial, sans-serif",
|
|
19
|
-
...
|
|
19
|
+
...c(u)
|
|
20
20
|
},
|
|
21
21
|
children: n
|
|
22
22
|
});
|
|
23
23
|
export {
|
|
24
|
-
|
|
24
|
+
g as StyledMenuItem
|
|
25
25
|
};
|
|
@@ -5,22 +5,22 @@ var m = {
|
|
|
5
5
|
base: "text-sm",
|
|
6
6
|
medium: "text-base",
|
|
7
7
|
subtitle: "text-xl"
|
|
8
|
-
},
|
|
8
|
+
}, o = {
|
|
9
9
|
base: 20,
|
|
10
10
|
medium: 24,
|
|
11
11
|
subtitle: 28
|
|
12
|
-
}, f = ({ dataTest: e, children:
|
|
12
|
+
}, f = ({ dataTest: e, children: r, onClick: i, size: t = "base", className: s }) => /* @__PURE__ */ u("button", {
|
|
13
13
|
type: "button",
|
|
14
14
|
"data-test": e,
|
|
15
15
|
"data-testid": e,
|
|
16
|
-
onClick:
|
|
17
|
-
className: n("group flex min-h-11 w-full cursor-pointer items-center rounded border-0 bg-transparent p-0 text-left", "font-semibold text-delta-800 transition-colors duration-300", m[t], "hover:text-gama-500 focus-visible:text-gama-500 active:text-gama-600", "outline-gama-400 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2", s),
|
|
16
|
+
onClick: i,
|
|
17
|
+
className: n("group flex min-h-11 w-full cursor-pointer items-center rounded border-0 bg-transparent p-0 text-left", "font-semibold text-delta-800 transition-colors duration-300", m[t], "hover:text-gama-500 focus-visible:text-gama-500 active:text-gama-600", "asma-touch-ready", "outline-gama-400 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2", s),
|
|
18
18
|
children: [/* @__PURE__ */ a("span", {
|
|
19
19
|
className: "min-w-0 truncate",
|
|
20
|
-
children:
|
|
20
|
+
children: r
|
|
21
21
|
}), /* @__PURE__ */ a(l, {
|
|
22
|
-
width:
|
|
23
|
-
height:
|
|
22
|
+
width: o[t],
|
|
23
|
+
height: o[t],
|
|
24
24
|
"aria-hidden": !0,
|
|
25
25
|
className: "shrink-0 transition-transform duration-300 group-hover:translate-x-1 group-focus-visible:translate-x-1"
|
|
26
26
|
})]
|
|
@@ -1,27 +1,31 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useAccordionContext as
|
|
3
|
-
import { clsx as
|
|
4
|
-
import { useEffect as
|
|
5
|
-
import { jsx as
|
|
6
|
-
var C = ({ children:
|
|
7
|
-
const { open:
|
|
8
|
-
return
|
|
9
|
-
if (!
|
|
10
|
-
const t = () =>
|
|
1
|
+
import u from "./StyledAccordion.module.js";
|
|
2
|
+
import { useAccordionContext as h } from "./AccordionContext.js";
|
|
3
|
+
import { clsx as a } from "clsx";
|
|
4
|
+
import { useEffect as x, useLayoutEffect as y, useRef as c, useState as A } from "react";
|
|
5
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
6
|
+
var C = ({ children: s, className: f, contentClassName: m, ...p }) => {
|
|
7
|
+
const { open: e, panelId: g, triggerId: o } = h(), l = c(null), r = c(null), i = c(e), [v, b] = A(0);
|
|
8
|
+
return x(() => {
|
|
9
|
+
if (!r.current) return;
|
|
10
|
+
const t = () => b(r.current?.scrollHeight ?? 0);
|
|
11
11
|
t();
|
|
12
|
-
const
|
|
13
|
-
return
|
|
14
|
-
}, [
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
const n = new ResizeObserver(t);
|
|
13
|
+
return n.observe(r.current), () => n.disconnect();
|
|
14
|
+
}, [s]), y(() => {
|
|
15
|
+
const t = l.current, n = i.current && !e && t?.contains(document.activeElement);
|
|
16
|
+
t?.toggleAttribute("inert", !e), n && document.getElementById(o)?.focus({ preventScroll: !0 }), i.current = e;
|
|
17
|
+
}, [e, o]), /* @__PURE__ */ d("div", {
|
|
18
|
+
ref: l,
|
|
19
|
+
...p,
|
|
20
|
+
id: g,
|
|
17
21
|
role: "region",
|
|
18
|
-
"aria-labelledby":
|
|
19
|
-
className:
|
|
20
|
-
style: { "--accordion-panel-height":
|
|
21
|
-
children: /* @__PURE__ */
|
|
22
|
-
ref:
|
|
23
|
-
className:
|
|
24
|
-
children:
|
|
22
|
+
"aria-labelledby": o,
|
|
23
|
+
className: a(u.Panel, f),
|
|
24
|
+
style: { "--accordion-panel-height": e ? `${v}px` : "0px" },
|
|
25
|
+
children: /* @__PURE__ */ d("div", {
|
|
26
|
+
ref: r,
|
|
27
|
+
className: a(u.Content, m),
|
|
28
|
+
children: s
|
|
25
29
|
})
|
|
26
30
|
});
|
|
27
31
|
};
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import { ChevronDownIcon as
|
|
1
|
+
import { ChevronDownIcon as S } from "../../../icons/chevron-down-icon/ChevronDownIcon.js";
|
|
2
2
|
import e from "./StyledAccordion.module.js";
|
|
3
3
|
import { useAccordionContext as A } from "./AccordionContext.js";
|
|
4
4
|
import o from "clsx";
|
|
5
5
|
import "react";
|
|
6
6
|
import { Fragment as c, jsx as t, jsxs as l } from "react/jsx-runtime";
|
|
7
|
-
var _ = ({ size: d = "large", expandChevronRight:
|
|
8
|
-
const { open:
|
|
7
|
+
var _ = ({ size: d = "large", expandChevronRight: a, className: m, headerClassName: p, sx: g, children: i, onClick: x, ...h }) => {
|
|
8
|
+
const { open: n, toggle: u, disabled: f, triggerId: y, panelId: I } = A(), r = d === "small", b = {
|
|
9
9
|
"--trigger-height": r ? "48px" : "72px",
|
|
10
10
|
"--trigger-padding-x": r ? "8px" : "16px",
|
|
11
11
|
"--trigger-font-size": r ? "14px" : "18px",
|
|
12
12
|
"--chevron-size": r ? "20px" : "24px",
|
|
13
|
-
...
|
|
14
|
-
}, s = /* @__PURE__ */ t(
|
|
15
|
-
className: o(e.TriggerIcon,
|
|
13
|
+
...g
|
|
14
|
+
}, s = /* @__PURE__ */ t(S, {
|
|
15
|
+
className: o(e.TriggerIcon, a && e.TriggerIconRight),
|
|
16
16
|
"data-state-icon": !0
|
|
17
17
|
});
|
|
18
18
|
return /* @__PURE__ */ t("h3", {
|
|
19
|
-
className: o(e.Header,
|
|
19
|
+
className: o(e.Header, p),
|
|
20
20
|
children: /* @__PURE__ */ t("button", {
|
|
21
21
|
...h,
|
|
22
22
|
type: "button",
|
|
23
23
|
id: y,
|
|
24
|
-
"aria-expanded":
|
|
24
|
+
"aria-expanded": n,
|
|
25
25
|
"aria-controls": I,
|
|
26
26
|
disabled: f,
|
|
27
|
-
onClick: (
|
|
28
|
-
x?.(
|
|
27
|
+
onClick: (v) => {
|
|
28
|
+
x?.(v), u();
|
|
29
29
|
},
|
|
30
|
-
className: o(e.Trigger,
|
|
31
|
-
style:
|
|
32
|
-
"data-panel-open":
|
|
33
|
-
children:
|
|
30
|
+
className: o(e.Trigger, "asma-pressable", m),
|
|
31
|
+
style: b,
|
|
32
|
+
"data-panel-open": n ? "" : void 0,
|
|
33
|
+
children: a ? /* @__PURE__ */ l(c, { children: [i, s] }) : /* @__PURE__ */ l(c, { children: [s, i] })
|
|
34
34
|
})
|
|
35
35
|
});
|
|
36
36
|
};
|
|
@@ -1,74 +1,124 @@
|
|
|
1
|
-
import { cn as
|
|
2
|
-
import { resolveSx as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
1
|
+
import { cn as Y } from "../../../helpers/cn.js";
|
|
2
|
+
import { resolveSx as R } from "../../../helpers/sx.js";
|
|
3
|
+
import { tabbableWithin as y } from "../../../helpers/focusable.js";
|
|
4
|
+
import { TOP_LAYER_PROPS as W, TOP_LAYER_RESET_STYLE as $, getOpenModalDialogAncestor as j, shouldUsePopoverTopLayer as q, useTopLayerRef as B } from "../../../hooks/useTopLayer.hook.js";
|
|
5
|
+
import { useEffect as P, useMemo as G, useRef as J, useState as h } from "react";
|
|
6
|
+
import { jsx as T } from "react/jsx-runtime";
|
|
7
|
+
import { FloatingPortal as Q, autoUpdate as V, flip as X, offset as Z, shift as C, useDismiss as ee, useFloating as te, useInteractions as oe, useMergeRefs as ne } from "@floating-ui/react";
|
|
8
|
+
var re = {
|
|
8
9
|
vertical: "bottom",
|
|
9
10
|
horizontal: "left"
|
|
10
|
-
},
|
|
11
|
+
}, se = {
|
|
11
12
|
vertical: "top",
|
|
12
13
|
horizontal: "left"
|
|
13
|
-
},
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
const { refs:
|
|
19
|
-
open:
|
|
20
|
-
placement:
|
|
14
|
+
}, ie = (o, t) => `${t.vertical === "bottom" ? "top" : t.vertical === "top" ? "bottom" : o.vertical === "top" ? "top" : "bottom"}${o.horizontal === "left" ? "-start" : o.horizontal === "right" ? "-end" : ""}`, ve = ({ open: o, anchorEl: t, onClose: u, anchorOrigin: b = re, transformOrigin: L = se, id: x, className: D, sx: K, slotProps: l, onClick: S, children: _, keepMounted: E = !1, tabIntoContent: d = !0 }) => {
|
|
15
|
+
const F = G(() => ie(b, L), [b, L]), [w, O] = h(o), c = J(!1);
|
|
16
|
+
o && !w && O(!0);
|
|
17
|
+
const m = o || E && w, p = j(t), [v, k] = h(p);
|
|
18
|
+
t && v !== p && k(p);
|
|
19
|
+
const { refs: a, floatingStyles: M, context: A } = te({
|
|
20
|
+
open: o,
|
|
21
|
+
placement: F,
|
|
21
22
|
strategy: "fixed",
|
|
22
|
-
whileElementsMounted:
|
|
23
|
-
elements: { reference:
|
|
23
|
+
whileElementsMounted: V,
|
|
24
|
+
elements: { reference: t ?? void 0 },
|
|
24
25
|
middleware: [
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
Z(4),
|
|
27
|
+
X({ padding: 8 }),
|
|
28
|
+
C({ padding: 8 })
|
|
28
29
|
],
|
|
29
|
-
onOpenChange: (
|
|
30
|
-
|
|
30
|
+
onOpenChange: (e, r, n) => {
|
|
31
|
+
e || u?.(r ?? {}, n === "escape-key" ? "escapeKeyDown" : "backdropClick");
|
|
31
32
|
}
|
|
32
|
-
}), { getFloatingProps:
|
|
33
|
-
outsidePress: (
|
|
34
|
-
const
|
|
35
|
-
return !(
|
|
33
|
+
}), { getFloatingProps: N } = oe([ee(A, {
|
|
34
|
+
outsidePress: (e) => {
|
|
35
|
+
const r = e.target;
|
|
36
|
+
return !(t instanceof Element && r instanceof Node && t.contains(r));
|
|
36
37
|
},
|
|
37
38
|
escapeKey: !0
|
|
38
|
-
})]),
|
|
39
|
-
|
|
40
|
-
if (!
|
|
41
|
-
const t =
|
|
42
|
-
|
|
39
|
+
})]), f = q(v), z = ne([B(a.setFloating, f)]);
|
|
40
|
+
P(() => {
|
|
41
|
+
if (!o) return;
|
|
42
|
+
const e = t instanceof HTMLElement ? t : null, r = () => a.floating.current?.contains(document.activeElement) ?? !1;
|
|
43
|
+
let n = r();
|
|
44
|
+
const s = () => {
|
|
45
|
+
n = r();
|
|
46
|
+
};
|
|
47
|
+
return document.addEventListener("focusin", s), () => {
|
|
48
|
+
document.removeEventListener("focusin", s);
|
|
49
|
+
const i = document.activeElement, g = !i || i === document.body || r();
|
|
50
|
+
n && g && e?.isConnected && e.focus({ preventScroll: !0 });
|
|
51
|
+
};
|
|
52
|
+
}, [
|
|
53
|
+
o,
|
|
54
|
+
t,
|
|
55
|
+
a.floating
|
|
56
|
+
]), P(() => {
|
|
57
|
+
if (!o) return;
|
|
58
|
+
const e = (n) => {
|
|
59
|
+
if (c.current = n.key === "Tab", !d || !c.current || n.shiftKey || n.defaultPrevented) return;
|
|
60
|
+
const s = a.floating.current;
|
|
61
|
+
if (!s || !(t instanceof Element) || !t.contains(document.activeElement)) return;
|
|
62
|
+
const [i] = y(s);
|
|
63
|
+
i && (n.preventDefault(), i.focus({ preventScroll: !0 }), c.current = !1);
|
|
64
|
+
}, r = (n) => {
|
|
65
|
+
const s = n.target, i = s instanceof Node && ((a.floating.current?.contains(s) ?? !1) || t instanceof Element && t.contains(s));
|
|
66
|
+
c.current && !i && u?.(n, "tabKeyDown"), c.current = !1;
|
|
67
|
+
};
|
|
68
|
+
return document.addEventListener("keydown", e, !0), document.addEventListener("focusin", r), () => {
|
|
69
|
+
document.removeEventListener("keydown", e, !0), document.removeEventListener("focusin", r);
|
|
70
|
+
};
|
|
71
|
+
}, [
|
|
72
|
+
o,
|
|
73
|
+
t,
|
|
74
|
+
u,
|
|
75
|
+
a.floating,
|
|
76
|
+
d
|
|
77
|
+
]);
|
|
78
|
+
const H = o ? N({
|
|
79
|
+
onClick: S,
|
|
80
|
+
onKeyDown: (e) => {
|
|
81
|
+
if (e.key !== "Tab" || e.defaultPrevented || !(t instanceof HTMLElement)) return;
|
|
82
|
+
const r = e.currentTarget, n = y(r), s = n.indexOf(document.activeElement);
|
|
83
|
+
if (s === -1 || (e.shiftKey ? s !== 0 : s !== n.length - 1)) return;
|
|
84
|
+
e.preventDefault();
|
|
85
|
+
const i = y(document).filter((I) => !r.contains(I)), g = i[i.indexOf(t) + (e.shiftKey ? -1 : 1)], U = (d && e.shiftKey ? void 0 : g) ?? t;
|
|
86
|
+
c.current = !1, U.focus({ preventScroll: !0 }), u?.(e, "tabKeyDown");
|
|
87
|
+
}
|
|
88
|
+
}) : {};
|
|
89
|
+
return P(() => {
|
|
90
|
+
if (!m || !f) return;
|
|
91
|
+
const e = a.floating.current;
|
|
92
|
+
if (!(!e || typeof e.showPopover != "function"))
|
|
43
93
|
try {
|
|
44
|
-
|
|
94
|
+
o && !e.matches(":popover-open") && e.showPopover(), !o && e.matches(":popover-open") && e.hidePopover();
|
|
45
95
|
} catch {
|
|
46
96
|
}
|
|
47
97
|
}, [
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
]),
|
|
53
|
-
root:
|
|
54
|
-
children: /* @__PURE__ */
|
|
55
|
-
ref:
|
|
56
|
-
id:
|
|
57
|
-
...
|
|
98
|
+
o,
|
|
99
|
+
m,
|
|
100
|
+
f,
|
|
101
|
+
a.floating
|
|
102
|
+
]), m ? /* @__PURE__ */ T(Q, {
|
|
103
|
+
root: v,
|
|
104
|
+
children: /* @__PURE__ */ T("div", {
|
|
105
|
+
ref: z,
|
|
106
|
+
id: x,
|
|
107
|
+
...f ? W : {},
|
|
58
108
|
style: {
|
|
59
|
-
...
|
|
60
|
-
...
|
|
61
|
-
...
|
|
62
|
-
...
|
|
63
|
-
...
|
|
64
|
-
...
|
|
109
|
+
...f ? $ : {},
|
|
110
|
+
...o ? M : {},
|
|
111
|
+
...R(K),
|
|
112
|
+
...R(l?.paper?.sx),
|
|
113
|
+
...l?.paper?.style,
|
|
114
|
+
...o ? null : { display: "none" }
|
|
65
115
|
},
|
|
66
|
-
...
|
|
67
|
-
className:
|
|
116
|
+
...H,
|
|
117
|
+
className: Y("z-[1300] overflow-auto rounded bg-white shadow-[0px_1px_12px_0px_rgba(0,0,0,0.15)]", D ?? "my-1", l?.paper?.className),
|
|
68
118
|
children: _
|
|
69
119
|
})
|
|
70
120
|
}) : null;
|
|
71
121
|
};
|
|
72
122
|
export {
|
|
73
|
-
|
|
123
|
+
ve as StyledPopover
|
|
74
124
|
};
|