asma-ui-core 3.61.3 → 3.62.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/components/data-display/tooltip/StyledTooltip.js +45 -45
- package/dist/components/feedback/dialog/StyledDialog.js +1 -1
- package/dist/components/inputs/select/StyledSelect.js +87 -87
- package/dist/components/inputs/select-autocomplete/StyledSelectAutocomplete.js +86 -86
- package/dist/components/mui-compat/Popper.js +31 -31
- package/dist/components/navigation/drawer/StyledDrawer.js +32 -46
- package/dist/components/utils/popover/StyledPopover.js +47 -43
- package/dist/hooks/useTopLayer.hook.js +19 -15
- package/dist/src/components/data-display/tooltip/StyledTooltip.d.ts +1 -1
- package/dist/src/components/feedback/dialog/StyledDialog.d.ts +1 -0
- package/dist/src/components/mui-compat/Popper.d.ts +3 -3
- package/dist/src/components/navigation/drawer/StyledDrawer.d.ts +3 -0
- package/dist/src/components/utils/popover/StyledPopover.d.ts +4 -2
- package/dist/src/hooks/useTopLayer.hook.d.ts +28 -18
- package/package.json +1 -1
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
import { cn as
|
|
2
|
-
import { resolveSx as
|
|
3
|
-
import { TOP_LAYER_PROPS as
|
|
4
|
-
import { cloneElement as
|
|
5
|
-
import { Fragment as
|
|
6
|
-
import { FloatingArrow as
|
|
7
|
-
var
|
|
8
|
-
const [w,
|
|
9
|
-
|
|
10
|
-
}, { refs:
|
|
11
|
-
open:
|
|
12
|
-
onOpenChange:
|
|
13
|
-
placement:
|
|
1
|
+
import { cn as S } from "../../../helpers/cn.js";
|
|
2
|
+
import { resolveSx as M } from "../../../helpers/sx.js";
|
|
3
|
+
import { TOP_LAYER_PROPS as U, TOP_LAYER_RESET_STYLE as Y, getOpenModalDialogAncestor as j, shouldUsePopoverTopLayer as k, useTopLayerRef as C } from "../../../hooks/useTopLayer.hook.js";
|
|
4
|
+
import { cloneElement as D, useRef as H, useState as I } from "react";
|
|
5
|
+
import { Fragment as N, jsx as f, jsxs as g } from "react/jsx-runtime";
|
|
6
|
+
import { FloatingArrow as z, FloatingPortal as B, arrow as G, autoUpdate as W, flip as q, offset as J, shift as K, useDismiss as Q, useFloating as V, useFocus as X, useHover as Z, useInteractions as $, useMergeRefs as ee, useRole as oe } from "@floating-ui/react";
|
|
7
|
+
var te = "#363E4A", pe = (e) => !e.title && e.title !== 0 ? e.children : /* @__PURE__ */ f(re, { ...e }), re = ({ title: e, children: t, placement: u = "top", arrow: r = !1, enterDelay: x = 500, leaveDelay: R = 0, open: p, onOpen: v, onClose: y, disableHoverListener: h, disableFocusListener: F, offsetDistance: T, className: _, slotProps: n }) => {
|
|
8
|
+
const [w, E] = I(!1), s = p !== void 0, l = p ?? w, c = H(null), O = (m) => {
|
|
9
|
+
s || E(m), m ? v?.() : y?.();
|
|
10
|
+
}, { refs: a, floatingStyles: P, context: o } = V({
|
|
11
|
+
open: l,
|
|
12
|
+
onOpenChange: O,
|
|
13
|
+
placement: u,
|
|
14
14
|
strategy: "fixed",
|
|
15
|
-
whileElementsMounted:
|
|
15
|
+
whileElementsMounted: W,
|
|
16
16
|
middleware: [
|
|
17
|
-
|
|
18
|
-
G({ padding: 8 }),
|
|
17
|
+
J(T ?? (r ? 8 : 6)),
|
|
19
18
|
q({ padding: 8 }),
|
|
20
|
-
|
|
19
|
+
K({ padding: 8 }),
|
|
20
|
+
...r ? [G({ element: c })] : []
|
|
21
21
|
]
|
|
22
|
-
}), { getReferenceProps:
|
|
23
|
-
|
|
24
|
-
enabled: !
|
|
22
|
+
}), { getReferenceProps: b, getFloatingProps: A } = $([
|
|
23
|
+
Z(o, {
|
|
24
|
+
enabled: !s && !h,
|
|
25
25
|
delay: {
|
|
26
|
-
open:
|
|
27
|
-
close:
|
|
26
|
+
open: x,
|
|
27
|
+
close: R
|
|
28
28
|
},
|
|
29
29
|
move: !1
|
|
30
30
|
}),
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
]),
|
|
35
|
-
return /* @__PURE__ */
|
|
36
|
-
ref:
|
|
37
|
-
...
|
|
38
|
-
})),
|
|
39
|
-
root:
|
|
40
|
-
children: /* @__PURE__ */
|
|
41
|
-
ref:
|
|
42
|
-
...
|
|
43
|
-
...
|
|
31
|
+
X(o, { enabled: !s && !F }),
|
|
32
|
+
Q(o),
|
|
33
|
+
oe(o, { role: "tooltip" })
|
|
34
|
+
]), d = l ? j(a.reference.current) : void 0, i = k(d), L = C(a.setFloating, i);
|
|
35
|
+
return /* @__PURE__ */ g(N, { children: [D(t, b({
|
|
36
|
+
ref: ee([a.setReference, t.ref]),
|
|
37
|
+
...t.props
|
|
38
|
+
})), l && /* @__PURE__ */ f(B, {
|
|
39
|
+
root: d,
|
|
40
|
+
children: /* @__PURE__ */ g("div", {
|
|
41
|
+
ref: L,
|
|
42
|
+
...i ? U : {},
|
|
43
|
+
...A(),
|
|
44
44
|
style: {
|
|
45
|
-
...Y,
|
|
46
|
-
...
|
|
45
|
+
...i ? Y : {},
|
|
46
|
+
...P,
|
|
47
47
|
fontFamily: "Roboto, Helvetica, Arial, sans-serif",
|
|
48
|
-
...
|
|
49
|
-
...
|
|
48
|
+
...n?.tooltip?.style,
|
|
49
|
+
...M(n?.tooltip?.sx)
|
|
50
50
|
},
|
|
51
|
-
className:
|
|
52
|
-
children: [e,
|
|
53
|
-
ref:
|
|
54
|
-
context:
|
|
55
|
-
fill:
|
|
51
|
+
className: S("z-[1500] block max-w-[320px] whitespace-normal break-words rounded-[3px] bg-[#363E4A] px-2 py-1 text-sm leading-5 text-white shadow-[0px_1px_6px_0px_rgba(0,0,0,0.15)]", _, n?.tooltip?.className),
|
|
52
|
+
children: [e, r && /* @__PURE__ */ f(z, {
|
|
53
|
+
ref: c,
|
|
54
|
+
context: o,
|
|
55
|
+
fill: te
|
|
56
56
|
})]
|
|
57
57
|
})
|
|
58
58
|
})] });
|
|
59
59
|
};
|
|
60
60
|
export {
|
|
61
|
-
|
|
61
|
+
pe as StyledTooltip
|
|
62
62
|
};
|
|
@@ -13,7 +13,7 @@ var $ = {
|
|
|
13
13
|
lg: 1200,
|
|
14
14
|
xl: 1536
|
|
15
15
|
}, te = ({ open: t, onClose: a, children: _, dataTest: i, maxWidth: x = "sm", fullWidth: C, fullScreen: E, scroll: p = "paper", disableEscapeKeyDown: h, className: H, style: j, sx: M, classes: y, PaperProps: R, slotProps: o, onCloseText: w, showCloseIcon: v = !0, dialogLabel: d, dialogTitle: s, dialogHeaderNode: W }) => {
|
|
16
|
-
const I = G(), b = u(null), c = u(!1), g = u(t), n =
|
|
16
|
+
const I = G(), b = u(null), c = u(!1), g = u(t), n = E ?? I;
|
|
17
17
|
D(() => {
|
|
18
18
|
g.current && !t && o?.transition?.onExited?.(), g.current = t;
|
|
19
19
|
}, [t, o]), Q(() => {
|
|
@@ -1,186 +1,186 @@
|
|
|
1
1
|
import { cn as f } from "../../../helpers/cn.js";
|
|
2
|
-
import { resolveSx as
|
|
3
|
-
import { ChevronDownIcon as
|
|
4
|
-
import { CloseIcon as
|
|
5
|
-
import { ErrorOutlineIcon as
|
|
6
|
-
import { TOP_LAYER_PROPS as
|
|
7
|
-
import { outlineClass as
|
|
8
|
-
import { useFormControlContext as
|
|
9
|
-
import { StyledFormHelperText as
|
|
10
|
-
import { Children as
|
|
11
|
-
import { jsx as
|
|
12
|
-
import { FloatingPortal as
|
|
13
|
-
var
|
|
14
|
-
const i =
|
|
2
|
+
import { resolveSx as he } from "../../../helpers/sx.js";
|
|
3
|
+
import { ChevronDownIcon as we } from "../../icons/chevron-down-icon/ChevronDownIcon.js";
|
|
4
|
+
import { CloseIcon as Ae } from "../../icons/close-icon/CloseIcon.js";
|
|
5
|
+
import { ErrorOutlineIcon as ve } from "../../icons/error-outline-icon/ErrorOutlineIcon.js";
|
|
6
|
+
import { TOP_LAYER_PROPS as Re, TOP_LAYER_RESET_STYLE as ke, getOpenModalDialogAncestor as Fe, shouldUsePopoverTopLayer as De, useTopLayerRef as Se } from "../../../hooks/useTopLayer.hook.js";
|
|
7
|
+
import { outlineClass as Ce } from "../field-styles.js";
|
|
8
|
+
import { useFormControlContext as Ee } from "../../miscellaneous/FormControlContext.js";
|
|
9
|
+
import { StyledFormHelperText as Ne } from "../../miscellaneous/StyledFormHelperText.js";
|
|
10
|
+
import { Children as E, cloneElement as Pe, isValidElement as N, useEffect as P, useMemo as _e, useRef as H, useState as _ } from "react";
|
|
11
|
+
import { jsx as n, jsxs as h } from "react/jsx-runtime";
|
|
12
|
+
import { FloatingPortal as qe, autoUpdate as Te, flip as Le, offset as Ue, shift as Ve, size as je, useClick as Be, useDismiss as Ie, useFloating as Ke, useInteractions as Me, useMergeRefs as Y, useRole as Oe } from "@floating-ui/react";
|
|
13
|
+
var rt = ({ dataTest: q, value: T, defaultValue: z, onChange: L, error: W, errorText: $, allowClear: U, disabled: G, readOnly: c, name: m, placeholder: w, displayEmpty: A, multiple: u, renderValue: V, fullWidth: J, className: Q, style: X, sx: Z, variant: ee, children: v, MenuProps: te, onFocus: re, onBlur: oe, labelId: p }) => {
|
|
14
|
+
const i = Ee(), j = `${q}-listbox`, g = ee === "standard", B = W ?? i?.error ?? !1, s = G ?? i?.disabled ?? !1, [o, y] = _(!1), [x, R] = _(!1), [se, I] = _(z), k = T !== void 0, r = k ? T : se, a = Array.isArray(r) ? r.length > 0 : r !== void 0 && r !== "" && r !== null, l = H(null), K = H(null), ne = (e) => {
|
|
15
15
|
if (y(e), e) return;
|
|
16
16
|
const t = document.activeElement;
|
|
17
|
-
t && t !== document.body && !
|
|
18
|
-
}, { refs: d, floatingStyles:
|
|
17
|
+
t && t !== document.body && !l.current?.contains(t) || K.current?.focus();
|
|
18
|
+
}, { refs: d, floatingStyles: ae, context: F } = Ke({
|
|
19
19
|
open: o,
|
|
20
|
-
onOpenChange:
|
|
20
|
+
onOpenChange: ne,
|
|
21
21
|
placement: "bottom-start",
|
|
22
22
|
strategy: "fixed",
|
|
23
|
-
whileElementsMounted:
|
|
23
|
+
whileElementsMounted: Te,
|
|
24
24
|
middleware: [
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
Ue(4),
|
|
26
|
+
Le({ padding: 8 }),
|
|
27
27
|
Ve({ padding: 8 }),
|
|
28
28
|
je({ apply({ rects: e, elements: t }) {
|
|
29
29
|
t.floating.style.minWidth = `${e.reference.width + 20}px`;
|
|
30
30
|
} })
|
|
31
31
|
]
|
|
32
|
-
}), { getReferenceProps:
|
|
33
|
-
Be(F, { enabled: !
|
|
32
|
+
}), { getReferenceProps: le, getFloatingProps: ie } = Me([
|
|
33
|
+
Be(F, { enabled: !s && !c }),
|
|
34
34
|
Ie(F),
|
|
35
|
-
|
|
36
|
-
]),
|
|
37
|
-
|
|
35
|
+
Oe(F, { role: "listbox" })
|
|
36
|
+
]), ce = Y([d.setReference, K]), M = _e(() => o ? Fe(d.reference.current) : void 0, [o, d]), D = De(M), ue = Y([Se(d.setFloating, D), l]);
|
|
37
|
+
P(() => i?.setFocused(o || x), [
|
|
38
38
|
o,
|
|
39
39
|
x,
|
|
40
40
|
i
|
|
41
|
-
]),
|
|
42
|
-
|
|
41
|
+
]), P(() => i?.setFilled(a || !!w || !!A), [
|
|
42
|
+
a,
|
|
43
43
|
w,
|
|
44
44
|
A,
|
|
45
45
|
i
|
|
46
|
-
]),
|
|
46
|
+
]), P(() => {
|
|
47
47
|
if (!o) return;
|
|
48
48
|
const e = requestAnimationFrame(() => {
|
|
49
|
-
const t =
|
|
49
|
+
const t = l.current?.querySelector('[role="option"][aria-selected="true"]');
|
|
50
50
|
t && (t.scrollIntoView({ block: "nearest" }), t.focus());
|
|
51
51
|
});
|
|
52
52
|
return () => cancelAnimationFrame(e);
|
|
53
53
|
}, [o]);
|
|
54
|
-
const
|
|
55
|
-
const b = u ? Array.isArray(r) && r.includes(e) ? r.filter((
|
|
56
|
-
k ||
|
|
54
|
+
const de = (e, t) => {
|
|
55
|
+
const b = u ? Array.isArray(r) && r.includes(e) ? r.filter((C) => C !== e) : [...Array.isArray(r) ? r : [], e] : e;
|
|
56
|
+
k || I(b), L?.({ target: {
|
|
57
57
|
value: b,
|
|
58
58
|
name: m
|
|
59
59
|
} }, t), u || (y(!1), requestAnimationFrame(() => d.domReference.current?.focus()));
|
|
60
|
-
},
|
|
60
|
+
}, O = () => {
|
|
61
61
|
const e = u ? [] : "";
|
|
62
|
-
k ||
|
|
62
|
+
k || I(e), L?.({ target: {
|
|
63
63
|
value: e,
|
|
64
64
|
name: m
|
|
65
65
|
} }, null), y(!1), R(!1);
|
|
66
|
-
},
|
|
67
|
-
if (!
|
|
66
|
+
}, fe = E.map(v, (e) => {
|
|
67
|
+
if (!N(e)) return e;
|
|
68
68
|
const t = e.props.value;
|
|
69
|
-
return
|
|
69
|
+
return Pe(e, {
|
|
70
70
|
selected: u ? Array.isArray(r) && r.includes(t) : t === r,
|
|
71
|
-
onClick: () =>
|
|
71
|
+
onClick: () => de(t, e.props.children)
|
|
72
72
|
});
|
|
73
|
-
}),
|
|
73
|
+
}), me = E.toArray(v).find((e) => N(e) && e.props.value === r), pe = V ? V(r) : u && Array.isArray(r) ? E.toArray(v).filter((e) => N(e) && r.includes(e.props.value)).map((e) => {
|
|
74
74
|
const t = e.props.children;
|
|
75
75
|
return typeof t == "string" || typeof t == "number" ? String(t) : "";
|
|
76
|
-
}).join(", ") :
|
|
77
|
-
if ((e.key === "Backspace" || e.key === "Delete") &&
|
|
78
|
-
e.preventDefault(),
|
|
76
|
+
}).join(", ") : me?.props.children, ge = (e) => {
|
|
77
|
+
if ((e.key === "Backspace" || e.key === "Delete") && U && a && !s && !c) {
|
|
78
|
+
e.preventDefault(), O();
|
|
79
79
|
return;
|
|
80
80
|
}
|
|
81
|
-
e.key !== "ArrowDown" && e.key !== "ArrowUp" ||
|
|
82
|
-
if (
|
|
83
|
-
const t =
|
|
81
|
+
e.key !== "ArrowDown" && e.key !== "ArrowUp" || s || c || (e.preventDefault(), y(!0), requestAnimationFrame(() => {
|
|
82
|
+
if (l.current?.querySelector('[role="option"][aria-selected="true"]')) return;
|
|
83
|
+
const t = l.current?.querySelectorAll('[role="option"]:not([aria-disabled="true"])');
|
|
84
84
|
t?.length && t[e.key === "ArrowUp" ? t.length - 1 : 0]?.focus();
|
|
85
85
|
}));
|
|
86
|
-
},
|
|
87
|
-
const t =
|
|
86
|
+
}, ye = (e) => {
|
|
87
|
+
const t = l.current ? Array.from(l.current.querySelectorAll('[role="option"]:not([aria-disabled="true"])')) : [];
|
|
88
88
|
if (t.length === 0) return;
|
|
89
|
-
const b = t.findIndex((
|
|
89
|
+
const b = t.findIndex((C) => C === document.activeElement);
|
|
90
90
|
e.key === "ArrowDown" || e.key === "ArrowUp" ? (e.preventDefault(), t[(b + (e.key === "ArrowDown" ? 1 : -1) + t.length) % t.length]?.focus()) : (e.key === "Enter" || e.key === " ") && (e.preventDefault(), document.activeElement?.click());
|
|
91
|
-
},
|
|
91
|
+
}, S = g && (o || x), xe = s ? "text-delta-300" : S ? "text-gama-500" : "text-delta-800", be = s ? "text-delta-300" : "text-delta-700";
|
|
92
92
|
return /* @__PURE__ */ h("div", {
|
|
93
|
-
className: f("group relative inline-flex flex-col",
|
|
93
|
+
className: f("group relative inline-flex flex-col", J && "w-full", Q),
|
|
94
94
|
style: {
|
|
95
95
|
fontFamily: "Roboto, Helvetica, Arial, sans-serif",
|
|
96
|
-
...
|
|
97
|
-
...
|
|
96
|
+
...he(Z),
|
|
97
|
+
...X
|
|
98
98
|
},
|
|
99
99
|
children: [
|
|
100
100
|
/* @__PURE__ */ h("button", {
|
|
101
|
-
ref:
|
|
101
|
+
ref: ce,
|
|
102
102
|
type: "button",
|
|
103
103
|
"data-testid": q,
|
|
104
|
-
...
|
|
104
|
+
...le({ onKeyDown: ge }),
|
|
105
105
|
role: "combobox",
|
|
106
106
|
"aria-haspopup": "listbox",
|
|
107
107
|
"aria-expanded": o,
|
|
108
|
-
"aria-controls":
|
|
108
|
+
"aria-controls": j,
|
|
109
109
|
"aria-labelledby": p,
|
|
110
110
|
"aria-label": p ? void 0 : m,
|
|
111
|
-
"aria-disabled":
|
|
112
|
-
disabled:
|
|
111
|
+
"aria-disabled": s ? !0 : void 0,
|
|
112
|
+
disabled: s,
|
|
113
113
|
onFocus: (e) => {
|
|
114
|
-
R(!0),
|
|
114
|
+
R(!0), re?.(e);
|
|
115
115
|
},
|
|
116
116
|
onBlur: (e) => {
|
|
117
|
-
R(!1),
|
|
117
|
+
R(!1), oe?.(e);
|
|
118
118
|
},
|
|
119
|
-
style: { minWidth:
|
|
120
|
-
className: f("relative flex w-full items-center justify-between text-left outline-none", "h-10 rounded-lg border-0 px-3 text-base transition-colors",
|
|
119
|
+
style: { minWidth: a && !g ? 105 : void 0 },
|
|
120
|
+
className: f("relative flex w-full items-center justify-between text-left outline-none", "h-10 rounded-lg border-0 px-3 text-base transition-colors", S ? "bg-gama-50" : "bg-transparent", xe, g && "min-w-0", s && "cursor-not-allowed", c && "pointer-events-none"),
|
|
121
121
|
children: [
|
|
122
|
-
/* @__PURE__ */
|
|
123
|
-
className: f("min-w-0 flex-1 truncate", !
|
|
124
|
-
children:
|
|
122
|
+
/* @__PURE__ */ n("span", {
|
|
123
|
+
className: f("min-w-0 flex-1 truncate", !a && "text-delta-500"),
|
|
124
|
+
children: a || A ? pe : w
|
|
125
125
|
}),
|
|
126
126
|
/* @__PURE__ */ h("span", {
|
|
127
127
|
className: "flex items-center gap-1",
|
|
128
|
-
children: [
|
|
128
|
+
children: [U && a && !s && /* @__PURE__ */ n("span", {
|
|
129
129
|
"aria-hidden": "true",
|
|
130
130
|
"data-testid": "select-clear-button",
|
|
131
131
|
className: "flex items-center justify-center rounded-full p-[2px] hover:bg-gama-100",
|
|
132
132
|
onClick: (e) => {
|
|
133
|
-
e.stopPropagation(),
|
|
133
|
+
e.stopPropagation(), O();
|
|
134
134
|
},
|
|
135
|
-
children: /* @__PURE__ */
|
|
135
|
+
children: /* @__PURE__ */ n(Ae, {
|
|
136
136
|
width: 18,
|
|
137
137
|
height: 18
|
|
138
138
|
})
|
|
139
|
-
}), /* @__PURE__ */
|
|
139
|
+
}), /* @__PURE__ */ n(we, {
|
|
140
140
|
width: 24,
|
|
141
141
|
height: 24,
|
|
142
|
-
className: f("shrink-0 transition-transform",
|
|
142
|
+
className: f("shrink-0 transition-transform", S ? "text-gama-500" : be, o && "rotate-180")
|
|
143
143
|
})]
|
|
144
144
|
}),
|
|
145
|
-
/* @__PURE__ */
|
|
145
|
+
/* @__PURE__ */ n("div", { className: Ce({
|
|
146
146
|
focused: o || x,
|
|
147
|
-
error:
|
|
148
|
-
disabled:
|
|
147
|
+
error: B,
|
|
148
|
+
disabled: s,
|
|
149
149
|
readOnly: c,
|
|
150
150
|
borderless: g
|
|
151
151
|
}) })
|
|
152
152
|
]
|
|
153
153
|
}),
|
|
154
|
-
o && /* @__PURE__ */
|
|
155
|
-
root:
|
|
156
|
-
children: /* @__PURE__ */
|
|
157
|
-
ref:
|
|
158
|
-
id:
|
|
154
|
+
o && /* @__PURE__ */ n(qe, {
|
|
155
|
+
root: M,
|
|
156
|
+
children: /* @__PURE__ */ n("ul", {
|
|
157
|
+
ref: ue,
|
|
158
|
+
id: j,
|
|
159
159
|
role: "listbox",
|
|
160
160
|
"aria-labelledby": p,
|
|
161
161
|
"aria-label": p ? void 0 : m,
|
|
162
|
-
...
|
|
162
|
+
...D ? Re : {},
|
|
163
163
|
style: {
|
|
164
|
-
...
|
|
165
|
-
...
|
|
164
|
+
...D ? ke : {},
|
|
165
|
+
...ae,
|
|
166
166
|
fontFamily: "Roboto, Helvetica, Arial, sans-serif"
|
|
167
167
|
},
|
|
168
|
-
...
|
|
169
|
-
onKeyDown:
|
|
170
|
-
className: f("z-[1300] m-0 max-h-72 list-none overflow-auto rounded-lg border border-solid border-delta-300 bg-white px-0 py-1 shadow-[0px_2px_4px_0px_rgba(34,33,51,0.15)]",
|
|
171
|
-
children:
|
|
168
|
+
...ie(),
|
|
169
|
+
onKeyDown: ye,
|
|
170
|
+
className: f("z-[1300] m-0 max-h-72 list-none overflow-auto rounded-lg border border-solid border-delta-300 bg-white px-0 py-1 shadow-[0px_2px_4px_0px_rgba(34,33,51,0.15)]", te?.className),
|
|
171
|
+
children: fe
|
|
172
172
|
})
|
|
173
173
|
}),
|
|
174
|
-
|
|
174
|
+
B && /* @__PURE__ */ h(Ne, {
|
|
175
175
|
className: "m-0 flex items-center gap-1 pt-1 text-sm text-error-500",
|
|
176
|
-
children: [/* @__PURE__ */
|
|
176
|
+
children: [/* @__PURE__ */ n(ve, {
|
|
177
177
|
width: 20,
|
|
178
178
|
height: 20
|
|
179
|
-
}),
|
|
179
|
+
}), $ ?? "Required"]
|
|
180
180
|
})
|
|
181
181
|
]
|
|
182
182
|
});
|
|
183
183
|
};
|
|
184
184
|
export {
|
|
185
|
-
|
|
185
|
+
rt as StyledSelect
|
|
186
186
|
};
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { cn as
|
|
1
|
+
import { cn as L } from "../../../helpers/cn.js";
|
|
2
2
|
import { ChevronDownIcon as He } from "../../icons/chevron-down-icon/ChevronDownIcon.js";
|
|
3
|
-
import { CloseIcon as
|
|
4
|
-
import { CheckIcon as
|
|
5
|
-
import { PlusIconCircle as
|
|
6
|
-
import { StyledChip as
|
|
7
|
-
import { StyledCheckbox as
|
|
8
|
-
import { TOP_LAYER_PROPS as
|
|
9
|
-
import { LoadingIcon as
|
|
10
|
-
import
|
|
11
|
-
import { useEffect as
|
|
3
|
+
import { CloseIcon as Ye } from "../../icons/close-icon/CloseIcon.js";
|
|
4
|
+
import { CheckIcon as Oe } from "../../icons/check-icon/CheckIcon.js";
|
|
5
|
+
import { PlusIconCircle as Be } from "../../icons/plus-icon-circle/PlusIconCircle.js";
|
|
6
|
+
import { StyledChip as qe } from "../../data-display/chip/StyledChip.js";
|
|
7
|
+
import { StyledCheckbox as J } from "../checkbox/base-ui/StyledCheckbox.js";
|
|
8
|
+
import { TOP_LAYER_PROPS as Ge, TOP_LAYER_RESET_STYLE as Je, getOpenModalDialogAncestor as Qe, shouldUsePopoverTopLayer as Xe, useTopLayerRef as Ze } from "../../../hooks/useTopLayer.hook.js";
|
|
9
|
+
import { LoadingIcon as Ke } from "../../../table/shared-components/LoadingIcon.js";
|
|
10
|
+
import Q from "./StyledSelectAutocomplete.module.js";
|
|
11
|
+
import { useEffect as et, useMemo as _, useRef as X, useState as w } from "react";
|
|
12
12
|
import { jsx as s, jsxs as y } from "react/jsx-runtime";
|
|
13
|
-
import { FloatingPortal as
|
|
14
|
-
var
|
|
15
|
-
function
|
|
16
|
-
const o =
|
|
17
|
-
e && (m || D) || (
|
|
18
|
-
}, [
|
|
19
|
-
S === void 0 && V(t),
|
|
20
|
-
}, [b,
|
|
21
|
-
|
|
22
|
-
S !== void 0 || o || V(
|
|
13
|
+
import { FloatingPortal as tt, autoUpdate as rt, flip as lt, offset as st, shift as ot, size as at, useDismiss as nt, useFloating as ct, useInteractions as it, useMergeRefs as Z, useRole as dt } from "@floating-ui/react";
|
|
14
|
+
var ut = (l) => typeof l == "object" && l !== null && "label" in l ? String(l.label) : String(l), K = (l) => typeof l == "object" && l !== null && "disabled" in l && !!l.disabled;
|
|
15
|
+
function St({ dataTest: l, options: p, renderInput: ee, value: v, onChange: N, getOptionLabel: te, getOptionKey: R, isOptionEqualToValue: E, renderOption: j, renderValue: z, filterOptions: $, loading: F, loadingText: re = "Loading…", noOptionsText: le = "No options", disabled: D, readOnly: m, size: se = "small", disableClearable: oe, disableCloseOnSelect: ae, popupIcon: ne, autoHeight: ce, multiple: ie, allowSelectAll: de, selectAllLabel: W = "Select all", fullWidth: ue, classes: pe, inputValue: S, onInputChange: me, open: U, onOpen: fe, onClose: he, className: ge, wrapperClassName: be, getOptionDisabled: xe, slotProps: T }) {
|
|
16
|
+
const o = ie === !0, n = te ?? ut, C = (e, t) => E ? E(e, t) : e === t, [we, ye] = w(!1), a = U ?? we, f = (e) => {
|
|
17
|
+
e && (m || D) || (U === void 0 && ye(e), e ? fe?.() : he?.());
|
|
18
|
+
}, [ve, V] = w(""), h = S ?? ve, P = (e, t, r) => {
|
|
19
|
+
S === void 0 && V(t), me?.(e, t, r);
|
|
20
|
+
}, [b, k] = w(null), Ne = X([]), H = X(null), [Re, De] = w(null), [Se, Ce] = w(null), c = o ? Array.isArray(v) ? v : [] : [], g = o ? null : v ?? null, Y = !o && g !== null ? n(g) : "";
|
|
21
|
+
et(() => {
|
|
22
|
+
S !== void 0 || o || V(Y);
|
|
23
23
|
}, [
|
|
24
24
|
S,
|
|
25
25
|
o,
|
|
26
|
-
|
|
26
|
+
Y
|
|
27
27
|
]);
|
|
28
|
-
const
|
|
28
|
+
const O = (e) => o ? c.some((t) => C(e, t)) : g !== null && C(e, g), B = _(() => {
|
|
29
29
|
const e = [...p];
|
|
30
|
-
if (
|
|
30
|
+
if ($) return $(e, { inputValue: h });
|
|
31
31
|
const t = !o && g !== null ? n(g).toLowerCase() : null;
|
|
32
32
|
if (!h || h.toLowerCase() === t) return e;
|
|
33
33
|
const r = h.toLowerCase();
|
|
@@ -35,60 +35,60 @@ function Rt({ dataTest: l, options: p, renderInput: Z, value: v, onChange: N, ge
|
|
|
35
35
|
}, [
|
|
36
36
|
p,
|
|
37
37
|
h,
|
|
38
|
-
|
|
38
|
+
$,
|
|
39
39
|
v
|
|
40
|
-
]), i =
|
|
40
|
+
]), i = _(() => B.slice(0, 100), [B]), { refs: A, floatingStyles: Pe, context: q } = ct({
|
|
41
41
|
open: a,
|
|
42
42
|
onOpenChange: f,
|
|
43
43
|
placement: "bottom-start",
|
|
44
44
|
strategy: "fixed",
|
|
45
|
-
whileElementsMounted:
|
|
45
|
+
whileElementsMounted: rt,
|
|
46
46
|
middleware: [
|
|
47
|
-
|
|
48
|
-
tt({ padding: 8 }),
|
|
47
|
+
st(4),
|
|
49
48
|
lt({ padding: 8 }),
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
ot({ padding: 8 }),
|
|
50
|
+
at({ apply({ rects: e, availableHeight: t }) {
|
|
51
|
+
De(e.reference.width), Ce(ce ? t - 8 : Math.min(t - 8, 320));
|
|
52
52
|
} })
|
|
53
53
|
]
|
|
54
|
-
}), { getReferenceProps:
|
|
54
|
+
}), { getReferenceProps: Ae, getFloatingProps: Le, getItemProps: $e } = it([nt(q), dt(q, { role: "listbox" })]), ke = Z([A.setReference]), G = _(() => a ? Qe(A.reference.current) : void 0, [a, A]), I = Xe(G), Ie = Z([Ze(A.setFloating, I)]), M = (e, t) => {
|
|
55
55
|
if (o) {
|
|
56
56
|
const r = c.some((u) => C(t, u)), d = r ? c.filter((u) => !C(t, u)) : [...c, t];
|
|
57
|
-
N?.(e, d, r ? "removeOption" : "selectOption", { option: t }),
|
|
57
|
+
N?.(e, d, r ? "removeOption" : "selectOption", { option: t }), P(e, "", "reset"), ae || f(!1);
|
|
58
58
|
} else
|
|
59
|
-
N?.(e, t, "selectOption", { option: t }),
|
|
59
|
+
N?.(e, t, "selectOption", { option: t }), P(e, n(t), "reset"), f(!1);
|
|
60
60
|
}, Me = (e) => {
|
|
61
|
-
N?.(e, o ? [] : null, "clear", void 0),
|
|
62
|
-
},
|
|
61
|
+
N?.(e, o ? [] : null, "clear", void 0), P(e, "", "clear");
|
|
62
|
+
}, _e = (e) => {
|
|
63
63
|
if (e.key === "Enter" && a && b != null && i[b] != null) {
|
|
64
64
|
e.preventDefault();
|
|
65
65
|
const t = i[b];
|
|
66
|
-
|
|
66
|
+
K(t) || M(e, t);
|
|
67
67
|
} else if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
68
68
|
if (e.preventDefault(), !a) {
|
|
69
|
-
|
|
69
|
+
k(null), f(!0);
|
|
70
70
|
return;
|
|
71
71
|
}
|
|
72
72
|
if (i.length === 0) return;
|
|
73
73
|
const t = e.key === "ArrowDown" ? 1 : -1;
|
|
74
|
-
|
|
74
|
+
k((r) => r == null ? t > 0 ? 0 : i.length - 1 : (r + t + i.length) % i.length);
|
|
75
75
|
}
|
|
76
|
-
},
|
|
76
|
+
}, Ee = !oe && !m && !D && (o ? c.length > 0 : g !== null), je = (e) => {
|
|
77
77
|
e.preventDefault(), !(D || m) && (H.current?.focus(), f(!a));
|
|
78
|
-
},
|
|
78
|
+
}, ze = o ? z ? z(c, ({ index: e }) => ({ "data-index": e })) : c.map((e, t) => /* @__PURE__ */ s(qe, {
|
|
79
79
|
dataTest: `selected-chip-${n(e)}`,
|
|
80
80
|
label: n(e),
|
|
81
81
|
readOnly: m,
|
|
82
82
|
onDelete: m ? void 0 : (r) => M(r, e)
|
|
83
|
-
}, R ? R(e) : `${n(e)}-${t}`)) : void 0,
|
|
83
|
+
}, R ? R(e) : `${n(e)}-${t}`)) : void 0, Fe = /* @__PURE__ */ y("span", {
|
|
84
84
|
className: "flex items-center gap-1",
|
|
85
85
|
children: [
|
|
86
|
-
|
|
86
|
+
F && /* @__PURE__ */ s(Ke, {
|
|
87
87
|
width: 20,
|
|
88
88
|
height: 20,
|
|
89
89
|
className: "animate-spin"
|
|
90
90
|
}),
|
|
91
|
-
|
|
91
|
+
Ee && /* @__PURE__ */ s("button", {
|
|
92
92
|
type: "button",
|
|
93
93
|
"aria-label": "Clear",
|
|
94
94
|
"data-testid": `${l}-clear`,
|
|
@@ -96,7 +96,7 @@ function Rt({ dataTest: l, options: p, renderInput: Z, value: v, onChange: N, ge
|
|
|
96
96
|
onMouseDown: (e) => {
|
|
97
97
|
e.preventDefault(), Me(e);
|
|
98
98
|
},
|
|
99
|
-
children: /* @__PURE__ */ s(
|
|
99
|
+
children: /* @__PURE__ */ s(Ye, {
|
|
100
100
|
width: 20,
|
|
101
101
|
height: 20,
|
|
102
102
|
className: "text-delta-700"
|
|
@@ -108,30 +108,30 @@ function Rt({ dataTest: l, options: p, renderInput: Z, value: v, onChange: N, ge
|
|
|
108
108
|
"aria-expanded": a,
|
|
109
109
|
"data-testid": `${l}-popup-indicator`,
|
|
110
110
|
className: "flex cursor-pointer items-center border-0 bg-transparent",
|
|
111
|
-
onMouseDown:
|
|
112
|
-
children:
|
|
111
|
+
onMouseDown: je,
|
|
112
|
+
children: ne ?? (o ? /* @__PURE__ */ s(Be, {
|
|
113
113
|
width: 24,
|
|
114
114
|
height: 24,
|
|
115
115
|
className: "text-delta-700"
|
|
116
116
|
}) : /* @__PURE__ */ s(He, {
|
|
117
117
|
width: 24,
|
|
118
118
|
height: 24,
|
|
119
|
-
className:
|
|
119
|
+
className: L(Q["select-custom-icon"], "text-delta-700 transition-transform", a && "rotate-180")
|
|
120
120
|
}))
|
|
121
121
|
})
|
|
122
122
|
]
|
|
123
|
-
}),
|
|
123
|
+
}), We = {
|
|
124
124
|
disabled: D,
|
|
125
|
-
size:
|
|
125
|
+
size: se,
|
|
126
126
|
fullWidth: !0,
|
|
127
127
|
value: h,
|
|
128
128
|
onChange: (e) => {
|
|
129
|
-
|
|
129
|
+
P(e, e.target.value, "input"), a || f(!0);
|
|
130
130
|
},
|
|
131
|
-
onKeyDown:
|
|
131
|
+
onKeyDown: _e,
|
|
132
132
|
slotProps: {
|
|
133
133
|
htmlInput: {
|
|
134
|
-
...
|
|
134
|
+
...Ae(),
|
|
135
135
|
ref: H,
|
|
136
136
|
onClick: () => f(!0),
|
|
137
137
|
role: "combobox",
|
|
@@ -142,16 +142,16 @@ function Rt({ dataTest: l, options: p, renderInput: Z, value: v, onChange: N, ge
|
|
|
142
142
|
readOnly: m
|
|
143
143
|
},
|
|
144
144
|
input: {
|
|
145
|
-
ref:
|
|
146
|
-
startAdornment:
|
|
147
|
-
endAdornment:
|
|
145
|
+
ref: ke,
|
|
146
|
+
startAdornment: ze,
|
|
147
|
+
endAdornment: Fe
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
|
-
},
|
|
150
|
+
}, Ue = L("box-border flex min-h-10 cursor-pointer items-center gap-x-3 px-3 py-1.5 text-base text-delta-700 first:-mt-1", "aria-selected:bg-gama-50 data-[active]:bg-gama-50 data-[active]:text-delta-800", "aria-disabled:cursor-default aria-disabled:!bg-transparent aria-disabled:text-delta-300", o && "border-0 border-b border-solid border-delta-200"), Te = (e, t, r) => {
|
|
151
151
|
const { key: d, ...u } = e;
|
|
152
152
|
return /* @__PURE__ */ y("li", {
|
|
153
153
|
...u,
|
|
154
|
-
children: [o ? /* @__PURE__ */ s(
|
|
154
|
+
children: [o ? /* @__PURE__ */ s(J, {
|
|
155
155
|
dataTest: `${l}-${n(t)}-checkbox`,
|
|
156
156
|
checked: r.selected,
|
|
157
157
|
size: "small",
|
|
@@ -159,7 +159,7 @@ function Rt({ dataTest: l, options: p, renderInput: Z, value: v, onChange: N, ge
|
|
|
159
159
|
decorative: !0
|
|
160
160
|
}) : /* @__PURE__ */ s("span", {
|
|
161
161
|
className: "w-5",
|
|
162
|
-
children: r.selected && /* @__PURE__ */ s(
|
|
162
|
+
children: r.selected && /* @__PURE__ */ s(Oe, {
|
|
163
163
|
width: 20,
|
|
164
164
|
height: 20,
|
|
165
165
|
className: "text-gama-500"
|
|
@@ -170,54 +170,54 @@ function Rt({ dataTest: l, options: p, renderInput: Z, value: v, onChange: N, ge
|
|
|
170
170
|
})]
|
|
171
171
|
}, d);
|
|
172
172
|
}, Ve = (e, t) => {
|
|
173
|
-
const r =
|
|
174
|
-
|
|
173
|
+
const r = xe?.(e) ?? K(e), d = {
|
|
174
|
+
...$e({
|
|
175
175
|
onMouseDown: (x) => x.preventDefault(),
|
|
176
176
|
onClick: (x) => {
|
|
177
177
|
r || M(x, e);
|
|
178
178
|
},
|
|
179
|
-
onMouseMove: () =>
|
|
179
|
+
onMouseMove: () => k(r ? null : t)
|
|
180
180
|
}),
|
|
181
181
|
key: R ? String(R(e)) : `${n(e)}-${t}`,
|
|
182
182
|
ref: (x) => {
|
|
183
|
-
|
|
183
|
+
Ne.current[t] = x;
|
|
184
184
|
},
|
|
185
185
|
role: "option",
|
|
186
186
|
id: `${l}-option-${t}`,
|
|
187
|
-
"aria-selected":
|
|
187
|
+
"aria-selected": O(e),
|
|
188
188
|
"aria-disabled": r || void 0,
|
|
189
189
|
"data-active": b === t ? "" : void 0,
|
|
190
|
-
className:
|
|
190
|
+
className: Ue
|
|
191
191
|
}, u = {
|
|
192
|
-
selected:
|
|
192
|
+
selected: O(e),
|
|
193
193
|
index: t,
|
|
194
194
|
inputValue: h
|
|
195
195
|
};
|
|
196
|
-
return
|
|
196
|
+
return j ? j(d, e, u) : Te(d, e, u);
|
|
197
197
|
};
|
|
198
198
|
return /* @__PURE__ */ y("div", {
|
|
199
|
-
className:
|
|
200
|
-
children: [
|
|
201
|
-
root:
|
|
199
|
+
className: L(Q.styledSelectAutocompleteWrapper, !ue && "w-auto", be, ge),
|
|
200
|
+
children: [ee(We), a && /* @__PURE__ */ s(tt, {
|
|
201
|
+
root: G,
|
|
202
202
|
children: /* @__PURE__ */ y("ul", {
|
|
203
|
-
ref:
|
|
204
|
-
...
|
|
203
|
+
ref: Ie,
|
|
204
|
+
...I ? Ge : {},
|
|
205
205
|
style: {
|
|
206
|
-
...
|
|
207
|
-
...
|
|
208
|
-
width:
|
|
209
|
-
maxHeight:
|
|
206
|
+
...I ? Je : {},
|
|
207
|
+
...Pe,
|
|
208
|
+
width: Re ?? void 0,
|
|
209
|
+
maxHeight: Se ?? void 0,
|
|
210
210
|
fontFamily: "Roboto, Helvetica, Arial, sans-serif",
|
|
211
|
-
...
|
|
211
|
+
...T?.popper?.style
|
|
212
212
|
},
|
|
213
|
-
...
|
|
214
|
-
className:
|
|
215
|
-
children: [
|
|
213
|
+
...Le(),
|
|
214
|
+
className: L("z-[1300] m-0 list-none overflow-auto rounded-lg border border-solid border-delta-300 bg-white p-0 shadow-[0px_2px_4px_0px_rgba(34,33,51,0.15)]", pe?.listbox, T?.popper?.className),
|
|
215
|
+
children: [de && o && /* @__PURE__ */ y("div", {
|
|
216
216
|
role: "group",
|
|
217
217
|
className: "flex min-h-12 items-center gap-x-1 border-0 border-b border-solid border-delta-200 px-4 text-sm text-delta-700",
|
|
218
|
-
children: [/* @__PURE__ */ s(
|
|
218
|
+
children: [/* @__PURE__ */ s(J, {
|
|
219
219
|
dataTest: `${l}-select-all`,
|
|
220
|
-
"aria-label":
|
|
220
|
+
"aria-label": W,
|
|
221
221
|
checked: p.length > 0 && c.length === p.length,
|
|
222
222
|
size: "small",
|
|
223
223
|
hideWrapper: !0,
|
|
@@ -228,21 +228,21 @@ function Rt({ dataTest: l, options: p, renderInput: Z, value: v, onChange: N, ge
|
|
|
228
228
|
}
|
|
229
229
|
}), /* @__PURE__ */ s("span", {
|
|
230
230
|
className: "flex-1 truncate py-2",
|
|
231
|
-
children:
|
|
231
|
+
children: W
|
|
232
232
|
})]
|
|
233
|
-
}),
|
|
233
|
+
}), F ? /* @__PURE__ */ s("li", {
|
|
234
234
|
role: "presentation",
|
|
235
235
|
className: "px-3 py-2 text-sm text-delta-600",
|
|
236
|
-
children:
|
|
236
|
+
children: re
|
|
237
237
|
}) : i.length === 0 ? /* @__PURE__ */ s("li", {
|
|
238
238
|
role: "presentation",
|
|
239
239
|
className: "px-3 py-2 text-sm text-delta-600",
|
|
240
|
-
children:
|
|
240
|
+
children: le
|
|
241
241
|
}) : i.map(Ve)]
|
|
242
242
|
})
|
|
243
243
|
})]
|
|
244
244
|
});
|
|
245
245
|
}
|
|
246
246
|
export {
|
|
247
|
-
|
|
247
|
+
St as StyledSelectAutocomplete
|
|
248
248
|
};
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import { TOP_LAYER_PROPS as
|
|
2
|
-
import { useState as
|
|
1
|
+
import { TOP_LAYER_PROPS as T, TOP_LAYER_RESET_STYLE as _, getOpenModalDialogAncestor as y, shouldUsePopoverTopLayer as L, useTopLayerRef as x } from "../../hooks/useTopLayer.hook.js";
|
|
2
|
+
import { useState as S } from "react";
|
|
3
3
|
import { jsx as l } from "react/jsx-runtime";
|
|
4
|
-
import { FloatingPortal as
|
|
5
|
-
var
|
|
6
|
-
...
|
|
4
|
+
import { FloatingPortal as A, autoUpdate as O, flip as b, shift as Y, useFloating as w, useMergeRefs as F } from "@floating-ui/react";
|
|
5
|
+
var M = {
|
|
6
|
+
..._,
|
|
7
7
|
background: "transparent",
|
|
8
8
|
border: 0,
|
|
9
9
|
overflow: "visible",
|
|
10
10
|
padding: 0
|
|
11
|
-
}, k = ({ open:
|
|
12
|
-
const [n,
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
open:
|
|
16
|
-
placement:
|
|
17
|
-
strategy:
|
|
18
|
-
whileElementsMounted:
|
|
11
|
+
}, k = ({ open: e = !1, anchorEl: r, id: d, placement: f = "bottom", transition: p, disablePortal: m, className: u, style: c, children: t }) => {
|
|
12
|
+
const [n, s] = S(!0);
|
|
13
|
+
e && n && s(!1);
|
|
14
|
+
const a = y(r), o = L(a), { refs: g, floatingStyles: P, placement: E } = w({
|
|
15
|
+
open: e,
|
|
16
|
+
placement: f,
|
|
17
|
+
strategy: "fixed",
|
|
18
|
+
whileElementsMounted: O,
|
|
19
19
|
elements: { reference: r ?? void 0 },
|
|
20
|
-
middleware: [
|
|
21
|
-
}),
|
|
22
|
-
if (!(
|
|
23
|
-
const
|
|
20
|
+
middleware: [b({ padding: 8 }), Y({ padding: 8 })]
|
|
21
|
+
}), R = F([x(g.setFloating, o)]);
|
|
22
|
+
if (!(e || p && !n)) return null;
|
|
23
|
+
const v = typeof t == "function" ? t({
|
|
24
24
|
TransitionProps: {
|
|
25
|
-
in:
|
|
26
|
-
onExited: () =>
|
|
25
|
+
in: e,
|
|
26
|
+
onExited: () => s(!0)
|
|
27
27
|
},
|
|
28
|
-
placement:
|
|
29
|
-
}) :
|
|
30
|
-
ref:
|
|
31
|
-
id:
|
|
32
|
-
...
|
|
28
|
+
placement: E
|
|
29
|
+
}) : t, i = /* @__PURE__ */ l("div", {
|
|
30
|
+
ref: R,
|
|
31
|
+
id: d,
|
|
32
|
+
...o ? T : {},
|
|
33
33
|
style: {
|
|
34
|
-
...
|
|
35
|
-
...
|
|
34
|
+
...o ? M : {},
|
|
35
|
+
...P,
|
|
36
36
|
...c
|
|
37
37
|
},
|
|
38
|
-
className:
|
|
39
|
-
children:
|
|
38
|
+
className: u,
|
|
39
|
+
children: v
|
|
40
40
|
});
|
|
41
|
-
return m ?
|
|
42
|
-
root:
|
|
43
|
-
children:
|
|
41
|
+
return m ? i : /* @__PURE__ */ l(A, {
|
|
42
|
+
root: a,
|
|
43
|
+
children: i
|
|
44
44
|
});
|
|
45
45
|
};
|
|
46
46
|
export {
|
|
@@ -1,65 +1,51 @@
|
|
|
1
|
-
import { cn as
|
|
2
|
-
import { resolveSx as
|
|
3
|
-
import {
|
|
4
|
-
import { useFocusTrap as
|
|
5
|
-
import { useEffect as
|
|
6
|
-
import { jsx as
|
|
7
|
-
import { FloatingPortal as
|
|
8
|
-
var
|
|
1
|
+
import { cn as n } from "../../../helpers/cn.js";
|
|
2
|
+
import { resolveSx as f } from "../../../helpers/sx.js";
|
|
3
|
+
import { getOpenModalDialogAncestor as w } from "../../../hooks/useTopLayer.hook.js";
|
|
4
|
+
import { useFocusTrap as h } from "../../../hooks/useFocusTrap.hook.js";
|
|
5
|
+
import { useEffect as b, useRef as k } from "react";
|
|
6
|
+
import { jsx as m, jsxs as E } from "react/jsx-runtime";
|
|
7
|
+
import { FloatingPortal as S } from "@floating-ui/react";
|
|
8
|
+
var _ = {
|
|
9
9
|
left: "inset-y-0 left-0 h-full",
|
|
10
10
|
right: "inset-y-0 right-0 h-full",
|
|
11
11
|
top: "inset-x-0 top-0 w-full",
|
|
12
12
|
bottom: "inset-x-0 bottom-0 w-full"
|
|
13
|
-
},
|
|
13
|
+
}, D = {
|
|
14
14
|
left: "-translate-x-full",
|
|
15
15
|
right: "translate-x-full",
|
|
16
16
|
top: "-translate-y-full",
|
|
17
17
|
bottom: "translate-y-full"
|
|
18
|
-
},
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return m(() => {
|
|
25
|
-
if (!e || !r) return;
|
|
26
|
-
const t = (f) => {
|
|
27
|
-
f.key === "Escape" && n?.(f, "escapeKeyDown");
|
|
18
|
+
}, T = ({ open: t = !1, onClose: o, anchor: l = "left", variant: u = "temporary", hideBackdrop: d, className: c, sx: p, PaperProps: a, ModalProps: x, anchorEl: y, children: v }) => {
|
|
19
|
+
const e = u === "temporary", g = w(y), i = k(null);
|
|
20
|
+
return b(() => {
|
|
21
|
+
if (!t || !e) return;
|
|
22
|
+
const r = (s) => {
|
|
23
|
+
s.key === "Escape" && o?.(s, "escapeKeyDown");
|
|
28
24
|
};
|
|
29
|
-
return document.addEventListener("keydown",
|
|
25
|
+
return document.addEventListener("keydown", r), () => document.removeEventListener("keydown", r);
|
|
30
26
|
}, [
|
|
27
|
+
t,
|
|
31
28
|
e,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const t = l.current;
|
|
37
|
-
if (!(!t || typeof t.showPopover != "function"))
|
|
38
|
-
try {
|
|
39
|
-
t.matches(":popover-open") || t.showPopover();
|
|
40
|
-
} catch {
|
|
41
|
-
}
|
|
42
|
-
}, [e, o]), r && !e && !E?.keepMounted ? null : /* @__PURE__ */ D(P, {
|
|
43
|
-
root: s,
|
|
44
|
-
children: [r && !v && e && /* @__PURE__ */ d("div", {
|
|
29
|
+
o
|
|
30
|
+
]), h(t && e, i), e && !t && !x?.keepMounted ? null : /* @__PURE__ */ E(S, {
|
|
31
|
+
root: g,
|
|
32
|
+
children: [e && !d && t && /* @__PURE__ */ m("div", {
|
|
45
33
|
className: "fixed inset-0 z-[1200] bg-[#626e7eb2]",
|
|
46
|
-
onClick: (
|
|
47
|
-
}), /* @__PURE__ */
|
|
48
|
-
ref:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"aria-
|
|
52
|
-
"
|
|
53
|
-
className: u("fixed z-[1200] overflow-auto bg-white transition-transform duration-300", e && "shadow-[0px_4px_40px_0px_#22213366]", O[a], !e && u(A[a], "pointer-events-none"), y, i?.className),
|
|
34
|
+
onClick: (r) => o?.(r, "backdropClick")
|
|
35
|
+
}), /* @__PURE__ */ m("div", {
|
|
36
|
+
ref: i,
|
|
37
|
+
role: e ? "dialog" : void 0,
|
|
38
|
+
"aria-modal": e && t ? !0 : void 0,
|
|
39
|
+
"aria-hidden": !t,
|
|
40
|
+
className: n("fixed z-[1200] overflow-auto bg-white transition-transform duration-300", t && "shadow-[0px_4px_40px_0px_#22213366]", _[l], !t && n(D[l], "pointer-events-none"), c, a?.className),
|
|
54
41
|
style: {
|
|
55
|
-
...
|
|
56
|
-
...
|
|
57
|
-
...c(i?.sx)
|
|
42
|
+
...f(p),
|
|
43
|
+
...f(a?.sx)
|
|
58
44
|
},
|
|
59
|
-
children:
|
|
45
|
+
children: v
|
|
60
46
|
})]
|
|
61
47
|
});
|
|
62
48
|
};
|
|
63
49
|
export {
|
|
64
|
-
|
|
50
|
+
T as StyledDrawer
|
|
65
51
|
};
|
|
@@ -1,41 +1,44 @@
|
|
|
1
|
-
import { cn as
|
|
2
|
-
import { resolveSx as
|
|
3
|
-
import { TOP_LAYER_PROPS as
|
|
4
|
-
import { useEffect as
|
|
5
|
-
import { jsx as
|
|
6
|
-
import { FloatingPortal as
|
|
7
|
-
var
|
|
1
|
+
import { cn as E } from "../../../helpers/cn.js";
|
|
2
|
+
import { resolveSx as d } from "../../../helpers/sx.js";
|
|
3
|
+
import { TOP_LAYER_PROPS as M, TOP_LAYER_RESET_STYLE as z, getOpenModalDialogAncestor as D, shouldUsePopoverTopLayer as N, useTopLayerRef as U } from "../../../hooks/useTopLayer.hook.js";
|
|
4
|
+
import { useEffect as k, useMemo as C, useState as m } from "react";
|
|
5
|
+
import { jsx as v } from "react/jsx-runtime";
|
|
6
|
+
import { FloatingPortal as Y, autoUpdate as H, flip as K, offset as $, shift as j, useDismiss as I, useFloating as q, useInteractions as B, useMergeRefs as G } from "@floating-ui/react";
|
|
7
|
+
var J = {
|
|
8
8
|
vertical: "bottom",
|
|
9
9
|
horizontal: "left"
|
|
10
|
-
},
|
|
10
|
+
}, Q = {
|
|
11
11
|
vertical: "top",
|
|
12
12
|
horizontal: "left"
|
|
13
|
-
},
|
|
14
|
-
const
|
|
15
|
-
e && !
|
|
16
|
-
const
|
|
17
|
-
o &&
|
|
18
|
-
const { refs:
|
|
13
|
+
}, V = (e, o) => `${o.vertical === "bottom" ? "top" : o.vertical === "top" ? "bottom" : e.vertical === "top" ? "top" : "bottom"}${e.horizontal === "left" ? "-start" : e.horizontal === "right" ? "-end" : ""}`, re = ({ open: e, anchorEl: o, onClose: g, anchorOrigin: f = J, transformOrigin: c = Q, id: y, className: h, sx: P, slotProps: a, onClick: R, children: _, keepMounted: x = !1 }) => {
|
|
14
|
+
const T = C(() => V(f, c), [f, c]), [u, w] = m(e);
|
|
15
|
+
e && !u && w(!0);
|
|
16
|
+
const i = e || x && u, n = D(o), [l, L] = m(n);
|
|
17
|
+
o && l !== n && L(n);
|
|
18
|
+
const { refs: p, floatingStyles: S, context: b } = q({
|
|
19
19
|
open: e,
|
|
20
|
-
placement:
|
|
20
|
+
placement: T,
|
|
21
21
|
strategy: "fixed",
|
|
22
|
-
whileElementsMounted:
|
|
22
|
+
whileElementsMounted: H,
|
|
23
23
|
elements: { reference: o ?? void 0 },
|
|
24
24
|
middleware: [
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
$(4),
|
|
26
|
+
K({ padding: 8 }),
|
|
27
|
+
j({ padding: 8 })
|
|
28
28
|
],
|
|
29
|
-
onOpenChange: (t,
|
|
30
|
-
t ||
|
|
29
|
+
onOpenChange: (t, s, O) => {
|
|
30
|
+
t || g?.(s ?? {}, O === "escape-key" ? "escapeKeyDown" : "backdropClick");
|
|
31
31
|
}
|
|
32
|
-
}), { getFloatingProps:
|
|
33
|
-
outsidePress:
|
|
32
|
+
}), { getFloatingProps: A } = B([I(b, {
|
|
33
|
+
outsidePress: (t) => {
|
|
34
|
+
const s = t.target;
|
|
35
|
+
return !(o instanceof Element && s instanceof Node && o.contains(s));
|
|
36
|
+
},
|
|
34
37
|
escapeKey: !0
|
|
35
|
-
})]),
|
|
36
|
-
return
|
|
37
|
-
if (!
|
|
38
|
-
const t =
|
|
38
|
+
})]), r = N(l), F = G([U(p.setFloating, r)]);
|
|
39
|
+
return k(() => {
|
|
40
|
+
if (!i || !r) return;
|
|
41
|
+
const t = p.floating.current;
|
|
39
42
|
if (!(!t || typeof t.showPopover != "function"))
|
|
40
43
|
try {
|
|
41
44
|
e && !t.matches(":popover-open") && t.showPopover(), !e && t.matches(":popover-open") && t.hidePopover();
|
|
@@ -43,28 +46,29 @@ var B = {
|
|
|
43
46
|
}
|
|
44
47
|
}, [
|
|
45
48
|
e,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
i,
|
|
50
|
+
r,
|
|
51
|
+
p.floating
|
|
52
|
+
]), i ? /* @__PURE__ */ v(Y, {
|
|
53
|
+
root: l,
|
|
54
|
+
children: /* @__PURE__ */ v("div", {
|
|
55
|
+
ref: F,
|
|
56
|
+
id: y,
|
|
57
|
+
...r ? M : {},
|
|
54
58
|
style: {
|
|
55
|
-
...
|
|
59
|
+
...r ? z : {},
|
|
56
60
|
...e ? S : {},
|
|
57
|
-
...
|
|
58
|
-
...
|
|
59
|
-
...
|
|
61
|
+
...d(P),
|
|
62
|
+
...d(a?.paper?.sx),
|
|
63
|
+
...a?.paper?.style,
|
|
60
64
|
...e ? null : { display: "none" }
|
|
61
65
|
},
|
|
62
|
-
...e ?
|
|
63
|
-
className:
|
|
64
|
-
children:
|
|
66
|
+
...e ? A({ onClick: R }) : {},
|
|
67
|
+
className: E("z-[1300] overflow-auto rounded bg-white shadow-[0px_1px_12px_0px_rgba(0,0,0,0.15)]", h ?? "my-1", a?.paper?.className),
|
|
68
|
+
children: _
|
|
65
69
|
})
|
|
66
70
|
}) : null;
|
|
67
71
|
};
|
|
68
72
|
export {
|
|
69
|
-
|
|
73
|
+
re as StyledPopover
|
|
70
74
|
};
|
|
@@ -1,25 +1,29 @@
|
|
|
1
|
-
import { useCallback as
|
|
2
|
-
var
|
|
1
|
+
import { useCallback as t } from "react";
|
|
2
|
+
var a = { popover: "manual" }, i = {
|
|
3
3
|
margin: 0,
|
|
4
4
|
inset: "auto"
|
|
5
5
|
};
|
|
6
|
-
function
|
|
7
|
-
if (!(
|
|
8
|
-
const
|
|
9
|
-
return
|
|
6
|
+
function u(o) {
|
|
7
|
+
if (!(o instanceof Element)) return;
|
|
8
|
+
const r = o.closest("dialog");
|
|
9
|
+
return r instanceof HTMLDialogElement && r.open ? r : void 0;
|
|
10
10
|
}
|
|
11
|
-
function p(
|
|
12
|
-
return
|
|
13
|
-
|
|
11
|
+
function p(o) {
|
|
12
|
+
return o == null;
|
|
13
|
+
}
|
|
14
|
+
function c(o, r = !0) {
|
|
15
|
+
return t((e) => {
|
|
16
|
+
if (o(e), !(!e || !r))
|
|
14
17
|
try {
|
|
15
|
-
typeof
|
|
18
|
+
typeof e.showPopover == "function" && !e.matches(":popover-open") && e.showPopover();
|
|
16
19
|
} catch {
|
|
17
20
|
}
|
|
18
|
-
}, [
|
|
21
|
+
}, [o, r]);
|
|
19
22
|
}
|
|
20
23
|
export {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
p as
|
|
24
|
+
a as TOP_LAYER_PROPS,
|
|
25
|
+
i as TOP_LAYER_RESET_STYLE,
|
|
26
|
+
u as getOpenModalDialogAncestor,
|
|
27
|
+
p as shouldUsePopoverTopLayer,
|
|
28
|
+
c as useTopLayerRef
|
|
25
29
|
};
|
|
@@ -20,6 +20,7 @@ export interface IStyledDialogProps {
|
|
|
20
20
|
dataTest: string;
|
|
21
21
|
maxWidth?: DialogMaxWidth;
|
|
22
22
|
fullWidth?: boolean;
|
|
23
|
+
/** Defaults to `true` on mobile (≤743px); pass `false` to keep the windowed paper there too. */
|
|
23
24
|
fullScreen?: boolean;
|
|
24
25
|
scroll?: 'paper' | 'body';
|
|
25
26
|
disableEscapeKeyDown?: boolean;
|
|
@@ -25,9 +25,9 @@ export interface PopperProps {
|
|
|
25
25
|
* `TransitionProps` (`in`/`onExited`) so a child `Fade` can animate and unmount. Public props
|
|
26
26
|
* preserved (DEC-003). TASK-403.
|
|
27
27
|
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
28
|
+
* Body-portalled instances join the browser **top layer** (nested under a filter `StyledPopover`
|
|
29
|
+
* otherwise paints under it). When `anchorEl` sits inside an open modal `<dialog>`, portal into
|
|
30
|
+
* that dialog and skip the Popover API — see `shouldUsePopoverTopLayer`.
|
|
31
31
|
*/
|
|
32
32
|
export declare const Popper: ({ open, anchorEl, id, placement, transition, disablePortal, className, style, children, }: PopperProps) => JSX.Element | null;
|
|
33
33
|
export {};
|
|
@@ -28,6 +28,9 @@ export interface DrawerProps {
|
|
|
28
28
|
* Sliding edge panel (replaces MUI `Drawer`). Portalled, slides from `anchor`, temporary variant
|
|
29
29
|
* shows a backdrop and closes on backdrop-click / Escape. Public props preserved (DEC-003). TASK-304.
|
|
30
30
|
*
|
|
31
|
+
* When the trigger is inside a modal `<dialog>`, portals into that dialog (inertness) and stacks with
|
|
32
|
+
* z-index — no nested Popover API (mobile Safari stacks nested `showPopover` under the dialog).
|
|
33
|
+
*
|
|
31
34
|
* @figmaNode none — no dedicated Figma drawer/side-sheet. As a modal edge-panel it reuses the DS
|
|
32
35
|
* **modal family** tokens established by `StyledDialog`: overlay `bg/modal` #626e7eb2 (delta-600 @70%)
|
|
33
36
|
* + Dialogue-popup elevation (#22213366, 0 4 40). Edge panels are flush (no radius); content is
|
|
@@ -35,8 +35,10 @@ export interface StyledPopoverProps {
|
|
|
35
35
|
* so the base paper uses the DS floating-surface defaults: white, radius **4** (Figma `menus`/
|
|
36
36
|
* `text-field` radius token), and the **Float** elevation (drop-shadow `0 1 12 rgba(0,0,0,.15)`).
|
|
37
37
|
* Styled consumers override the paper — `StyledMenu` adds the delta-300 border + Menus shadow
|
|
38
|
-
* (`0 2 4 rgba(34,33,51,.15)`), the date-picker calendar keeps this base.
|
|
39
|
-
* **top layer** (see `useTopLayerRef`)
|
|
38
|
+
* (`0 2 4 rgba(34,33,51,.15)`), the date-picker calendar keeps this base. Body-portalled instances
|
|
39
|
+
* join the browser **top layer** (see `useTopLayerRef`); when the anchor is inside a modal
|
|
40
|
+
* `<dialog>`, we portal into that dialog and skip the Popover API (mobile Safari nested top-layer
|
|
41
|
+
* bug — see `shouldUsePopoverTopLayer`).
|
|
40
42
|
*
|
|
41
43
|
* Positions against `anchorEl`, flips/shifts on collision, portalled, closes on outside-press/escape
|
|
42
44
|
* mapping to MUI's `onClose(event, reason)`. `anchorOrigin`/`transformOrigin`/`slotProps.paper`
|
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
import { CSSProperties } from 'react';
|
|
2
2
|
/**
|
|
3
3
|
* Promote a Floating UI element into the browser **top layer** so it paints above a native modal
|
|
4
|
-
* `<dialog
|
|
4
|
+
* `<dialog>` — but **only when the floating node is NOT already portalled into that dialog**.
|
|
5
5
|
*
|
|
6
6
|
* `StyledDialog` opens via `<dialog>.showModal()`, which puts the dialog in the top layer. The top
|
|
7
7
|
* layer sits above the entire normal stacking context, so a popover/menu/listbox portalled to
|
|
8
8
|
* `document.body` is occluded by the dialog **no matter how high its `z-index`** (and is `inert`
|
|
9
|
-
* while the modal is open).
|
|
10
|
-
* the native Popover API does. We give the floating element `popover="manual"` (manual = we drive
|
|
11
|
-
* open/close ourselves, no light-dismiss) and call `showPopover()` the moment it mounts; the top
|
|
12
|
-
* layer stacks by call order, so a popover shown after the dialog lands on top.
|
|
9
|
+
* while the modal is open).
|
|
13
10
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
11
|
+
* Two complementary fixes:
|
|
12
|
+
* 1. **Portal into the open modal `<dialog>`** (see {@link getOpenModalDialogAncestor}) — escapes
|
|
13
|
+
* `inert` and paints inside the dialog's own top-layer entry via normal z-index.
|
|
14
|
+
* 2. **Popover API** (`popover="manual"` + `showPopover()`) — only when portalling to `document.body`
|
|
15
|
+
* (e.g. nested under another top-layer `StyledPopover`). Nested `showPopover()` *inside* a modal
|
|
16
|
+
* dialog is unreliable on mobile Safari: it either no-ops (UA keeps
|
|
17
|
+
* `[popover]:not(:popover-open){display:none!important}` → looks like it never opened) or stacks
|
|
18
|
+
* the popover *under* the dialog. Use {@link shouldUsePopoverTopLayer} to gate (1) vs (2).
|
|
19
|
+
*
|
|
20
|
+
* Usage when body-portalled: spread {@link TOP_LAYER_PROPS}, put {@link TOP_LAYER_RESET_STYLE} before
|
|
21
|
+
* `...floatingStyles`, `strategy: 'fixed'`, and pass `refs.setFloating` to {@link useTopLayerRef}.
|
|
22
|
+
* Promoting on the ref callback (not a `useEffect`) runs the instant the node is connected.
|
|
19
23
|
*/
|
|
20
24
|
export declare const TOP_LAYER_PROPS: {
|
|
21
25
|
readonly popover: "manual";
|
|
@@ -33,17 +37,23 @@ export declare const TOP_LAYER_RESET_STYLE: CSSProperties;
|
|
|
33
37
|
* fine, even on top), but it is skipped by hit-testing: pointer clicks fall through to the dialog
|
|
34
38
|
* behind it and options can't be selected. Promoting to the top layer only fixes painting/z-order,
|
|
35
39
|
* NOT inertness. The one place a popover is both unclipped *and* interactive is **inside the modal
|
|
36
|
-
* dialog's own subtree** (
|
|
37
|
-
* dialog
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
40
|
+
* dialog's own subtree** (descendant of the dialog → not inert; dialog is already fullscreen
|
|
41
|
+
* `inset-0`, so in-dialog `position:fixed` + z-index clears the paper without a nested Popover API
|
|
42
|
+
* entry). Returns `undefined` for the non-dialog case (and for non-modal containers like
|
|
43
|
+
* `MinimizableDialog`, which are plain z-indexed `<div>`s), so the caller falls back to the default
|
|
44
|
+
* body portal.
|
|
41
45
|
*/
|
|
42
46
|
export declare function getOpenModalDialogAncestor(node: unknown): HTMLElement | undefined;
|
|
47
|
+
/**
|
|
48
|
+
* `true` when the floating node should join the top layer via the Popover API.
|
|
49
|
+
* `false` when it is (or will be) portalled into an open modal `<dialog>` — see hook docs.
|
|
50
|
+
*/
|
|
51
|
+
export declare function shouldUsePopoverTopLayer(portalRoot: HTMLElement | undefined | null): boolean;
|
|
43
52
|
type RefSetter = (node: HTMLElement | null) => void;
|
|
44
53
|
/**
|
|
45
|
-
* Returns a ref callback that wires the node into Floating UI (`setFloating`) and,
|
|
46
|
-
* promotes it to the top layer via the Popover API.
|
|
54
|
+
* Returns a ref callback that wires the node into Floating UI (`setFloating`) and, when `enabled`,
|
|
55
|
+
* promotes it to the top layer via the Popover API. Pass `enabled: false` inside a modal dialog
|
|
56
|
+
* (see {@link shouldUsePopoverTopLayer}). Degrades to plain z-index if unsupported.
|
|
47
57
|
*/
|
|
48
|
-
export declare function useTopLayerRef(setFloating: RefSetter): RefSetter;
|
|
58
|
+
export declare function useTopLayerRef(setFloating: RefSetter, enabled?: boolean): RefSetter;
|
|
49
59
|
export {};
|