@dinofront/design_system 1.17.3 → 1.18.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.
|
@@ -40,6 +40,10 @@ export interface DropdownContentProps extends HTMLAttributes<HTMLDivElement>, Ba
|
|
|
40
40
|
matchTriggerWidth?: boolean;
|
|
41
41
|
/** Closes the menu when any ancestor scrolls. */
|
|
42
42
|
closeOnScroll?: boolean;
|
|
43
|
+
/** Focuses the first item when the menu opens (default `true`). Set `false` when
|
|
44
|
+
* the trigger lives inside another focus-sensitive widget — e.g. a `SelectV2`
|
|
45
|
+
* option's `actions`, whose menu closes as soon as its input loses focus. */
|
|
46
|
+
autoFocusFirstItem?: boolean;
|
|
43
47
|
}
|
|
44
48
|
export interface DropdownItemProps extends ButtonHTMLAttributes<HTMLButtonElement>, BaseProps {
|
|
45
49
|
children: ReactNode;
|
|
@@ -12,6 +12,11 @@ export interface SelectV2Option {
|
|
|
12
12
|
disabled?: boolean;
|
|
13
13
|
/** Group heading this option belongs under. */
|
|
14
14
|
group?: string;
|
|
15
|
+
/** Content pinned to the end of the option's row in the menu — e.g. a "⋯"
|
|
16
|
+
* button opening a per-option `DropdownMenu`. Not shown in the closed
|
|
17
|
+
* control's selected value. Clicks inside it never select the option or
|
|
18
|
+
* close the select, so the consumer owns what the interaction does. */
|
|
19
|
+
actions?: ReactNode;
|
|
15
20
|
}
|
|
16
21
|
/** react-select props SelectV2 already computes/owns internally and can't be
|
|
17
22
|
* overridden through passthrough without breaking its own logic. */
|
package/dist/index.js
CHANGED
|
@@ -1771,39 +1771,42 @@ var Bn = {
|
|
|
1771
1771
|
top: "-translate-y-full",
|
|
1772
1772
|
bottom: "translate-y-full"
|
|
1773
1773
|
}, Wn = a(function({ open: e, onClose: t, side: n = "right", size: r = "md", title: i, description: a, children: o, footer: s, closeOnOverlayClick: c = !0, showClose: u = !0, animated: d = !0, headerActions: f, className: m, dataTestId: h }, g) {
|
|
1774
|
-
let _ = p(null), { mounted:
|
|
1774
|
+
let _ = p(null), v = p(null), { mounted: y, state: b } = zn(e, d ? Ln.slow : 0), x = b === "entered";
|
|
1775
1775
|
if (l(() => {
|
|
1776
|
-
if (!
|
|
1777
|
-
let e =
|
|
1778
|
-
e.key === "Escape" && t();
|
|
1779
|
-
};
|
|
1780
|
-
document.addEventListener("keydown", e);
|
|
1781
|
-
let n = document.body.style.overflow;
|
|
1776
|
+
if (!y) return;
|
|
1777
|
+
let e = document.body.style.overflow;
|
|
1782
1778
|
return document.body.style.overflow = "hidden", () => {
|
|
1783
|
-
document.
|
|
1779
|
+
document.body.style.overflow = e;
|
|
1780
|
+
};
|
|
1781
|
+
}, [y]), l(() => {
|
|
1782
|
+
let e = _.current;
|
|
1783
|
+
if (!(!y || !e || e.open)) return e.showModal(), v.current?.focus(), () => {
|
|
1784
|
+
e.open && e.close();
|
|
1784
1785
|
};
|
|
1785
|
-
}, [
|
|
1786
|
+
}, [y]), l(() => {
|
|
1786
1787
|
if (!e) return;
|
|
1787
1788
|
let t = document.activeElement;
|
|
1788
|
-
return
|
|
1789
|
-
}, [e]), !
|
|
1790
|
-
let
|
|
1791
|
-
return _e(/* @__PURE__ */ J("
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1789
|
+
return v.current?.focus(), () => t?.focus?.();
|
|
1790
|
+
}, [e]), !y) return null;
|
|
1791
|
+
let S = n === "left" || n === "right", C = S ? Bn[r] : Vn[r];
|
|
1792
|
+
return _e(/* @__PURE__ */ J("dialog", {
|
|
1793
|
+
ref: _,
|
|
1794
|
+
onCancel: (e) => {
|
|
1795
|
+
e.preventDefault(), t();
|
|
1796
|
+
},
|
|
1797
|
+
"aria-hidden": b === "exiting" || void 0,
|
|
1795
1798
|
"aria-labelledby": i ? "drawer-title" : void 0,
|
|
1796
1799
|
"aria-describedby": a ? "drawer-desc" : void 0,
|
|
1797
|
-
className: "fixed inset-0 z-50",
|
|
1800
|
+
className: "fixed inset-0 z-50 m-0 h-full max-h-none w-full max-w-none overflow-hidden border-0 bg-transparent p-0 text-inherit backdrop:bg-transparent",
|
|
1798
1801
|
"data-test-id": h,
|
|
1799
1802
|
children: [/* @__PURE__ */ q("div", {
|
|
1800
|
-
className: Q("absolute inset-0 bg-black/50", d && "transition-opacity duration-200 motion-reduce:transition-none",
|
|
1803
|
+
className: Q("absolute inset-0 bg-black/50", d && "transition-opacity duration-200 motion-reduce:transition-none", x ? "opacity-100" : "opacity-0"),
|
|
1801
1804
|
onClick: () => c && t(),
|
|
1802
1805
|
"aria-hidden": !0
|
|
1803
1806
|
}), /* @__PURE__ */ J("div", {
|
|
1804
|
-
ref: Gt(g,
|
|
1807
|
+
ref: Gt(g, v),
|
|
1805
1808
|
tabIndex: -1,
|
|
1806
|
-
className: Q("absolute bg-bg-default shadow-z5 outline-none flex flex-col", Hn[n],
|
|
1809
|
+
className: Q("absolute bg-bg-default shadow-z5 outline-none flex flex-col", Hn[n], S ? `${C} h-full max-w-full` : `${C} w-full max-h-full`, "border-border-default", d && "transition-transform duration-300 ease-out motion-reduce:transition-none will-change-transform", x ? "translate-x-0 translate-y-0" : Un[n], m),
|
|
1807
1810
|
children: [
|
|
1808
1811
|
(i || u || f) && /* @__PURE__ */ J("div", {
|
|
1809
1812
|
className: "flex items-start justify-between gap-4 px-6 pt-6 pb-4 border-b border-border-default",
|
|
@@ -1942,13 +1945,13 @@ function Zn({ children: e }) {
|
|
|
1942
1945
|
"aria-expanded": t
|
|
1943
1946
|
});
|
|
1944
1947
|
}
|
|
1945
|
-
var Qn = "min-w-[200px] rounded-lg border border-border-default bg-bg-default shadow-z4 z-50 py-1", $n = a(function({ children: e, align: t = "start", strategy: n = "fixed", side: r = "bottom", sideOffset: i = 4, flip: a = !0, shift: o = !0, matchTriggerWidth: s = !1, closeOnScroll: c = !1,
|
|
1946
|
-
let { open:
|
|
1948
|
+
var Qn = "min-w-[200px] rounded-lg border border-border-default bg-bg-default shadow-z4 z-50 py-1", $n = a(function({ children: e, align: t = "start", strategy: n = "fixed", side: r = "bottom", sideOffset: i = 4, flip: a = !0, shift: o = !0, matchTriggerWidth: s = !1, closeOnScroll: c = !1, autoFocusFirstItem: u = !0, className: d, dataTestId: h, onClick: g, ..._ }, v) {
|
|
1949
|
+
let { open: y, setOpen: b, triggerRef: x, anchorRef: S } = Yn(), C = p(null), [w, T] = m(null), { style: E, resolvedSide: D } = Kn({
|
|
1947
1950
|
anchor: f(() => ({ get current() {
|
|
1948
|
-
return qn(
|
|
1949
|
-
} }), [
|
|
1950
|
-
panel:
|
|
1951
|
-
open:
|
|
1951
|
+
return qn(S) ?? x.current;
|
|
1952
|
+
} }), [S, x]),
|
|
1953
|
+
panel: w,
|
|
1954
|
+
open: y && n === "fixed",
|
|
1952
1955
|
side: r,
|
|
1953
1956
|
align: t,
|
|
1954
1957
|
offset: i,
|
|
@@ -1957,56 +1960,56 @@ var Qn = "min-w-[200px] rounded-lg border border-border-default bg-bg-default sh
|
|
|
1957
1960
|
matchAnchorWidth: s
|
|
1958
1961
|
});
|
|
1959
1962
|
if (l(() => {
|
|
1960
|
-
if (!
|
|
1963
|
+
if (!y) return;
|
|
1961
1964
|
let e = (e) => {
|
|
1962
1965
|
let t = e.target;
|
|
1963
|
-
|
|
1966
|
+
C.current?.contains(t) || x.current?.contains(t) || qn(S)?.contains(t) || b(!1);
|
|
1964
1967
|
};
|
|
1965
|
-
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
1968
|
+
return document.addEventListener("mousedown", e, !0), () => document.removeEventListener("mousedown", e, !0);
|
|
1966
1969
|
}, [
|
|
1967
|
-
v,
|
|
1968
1970
|
y,
|
|
1969
1971
|
b,
|
|
1970
|
-
x
|
|
1972
|
+
x,
|
|
1973
|
+
S
|
|
1971
1974
|
]), l(() => {
|
|
1972
|
-
if (!
|
|
1973
|
-
let e = () =>
|
|
1975
|
+
if (!y || !c) return;
|
|
1976
|
+
let e = () => b(!1);
|
|
1974
1977
|
return document.addEventListener("scroll", e, {
|
|
1975
1978
|
capture: !0,
|
|
1976
1979
|
passive: !0
|
|
1977
1980
|
}), () => document.removeEventListener("scroll", e, { capture: !0 });
|
|
1978
1981
|
}, [
|
|
1979
|
-
|
|
1982
|
+
y,
|
|
1980
1983
|
c,
|
|
1981
|
-
|
|
1984
|
+
b
|
|
1982
1985
|
]), l(() => {
|
|
1983
|
-
if (!
|
|
1986
|
+
if (!y || !u) return;
|
|
1984
1987
|
let e = requestAnimationFrame(() => {
|
|
1985
|
-
(
|
|
1988
|
+
(C.current?.querySelector("[role=\"menuitem\"]:not(:disabled)"))?.focus();
|
|
1986
1989
|
});
|
|
1987
1990
|
return () => cancelAnimationFrame(e);
|
|
1988
|
-
}, [
|
|
1989
|
-
let
|
|
1990
|
-
ref: Gt(
|
|
1991
|
+
}, [y, u]), !y) return null;
|
|
1992
|
+
let O = /* @__PURE__ */ q("div", {
|
|
1993
|
+
ref: Gt(v, C, n === "fixed" ? T : void 0),
|
|
1991
1994
|
role: "menu",
|
|
1992
|
-
"data-test-id":
|
|
1993
|
-
"data-side": n === "fixed" ?
|
|
1995
|
+
"data-test-id": h,
|
|
1996
|
+
"data-side": n === "fixed" ? D : void 0,
|
|
1994
1997
|
"data-align": t,
|
|
1995
1998
|
onKeyDown: (e) => {
|
|
1996
|
-
let t = Array.from(
|
|
1999
|
+
let t = Array.from(C.current?.querySelectorAll("[role=\"menuitem\"]:not(:disabled)") ?? []);
|
|
1997
2000
|
if (!t.length) return;
|
|
1998
2001
|
let n = t.indexOf(document.activeElement);
|
|
1999
|
-
e.key === "ArrowDown" ? (e.preventDefault(), t[(n + 1 + t.length) % t.length]?.focus()) : e.key === "ArrowUp" ? (e.preventDefault(), t[(n - 1 + t.length) % t.length]?.focus()) : e.key === "Home" ? (e.preventDefault(), t[0]?.focus()) : e.key === "End" && (e.preventDefault(), t
|
|
2002
|
+
e.key === "ArrowDown" ? (e.preventDefault(), t[(n + 1 + t.length) % t.length]?.focus()) : e.key === "ArrowUp" ? (e.preventDefault(), t[(n - 1 + t.length) % t.length]?.focus()) : e.key === "Home" ? (e.preventDefault(), t[0]?.focus()) : e.key === "End" && (e.preventDefault(), t.at(-1)?.focus());
|
|
2000
2003
|
},
|
|
2001
2004
|
onClick: (e) => {
|
|
2002
|
-
|
|
2005
|
+
g?.(e), e.stopPropagation();
|
|
2003
2006
|
},
|
|
2004
|
-
style: n === "fixed" ?
|
|
2005
|
-
className: Q(Qn, n === "absolute" && Q("absolute top-full mt-1", t === "end" ? "right-0" : "left-0"),
|
|
2006
|
-
...
|
|
2007
|
+
style: n === "fixed" ? E : void 0,
|
|
2008
|
+
className: Q(Qn, n === "absolute" && Q("absolute top-full mt-1", t === "end" ? "right-0" : "left-0"), d),
|
|
2009
|
+
..._,
|
|
2007
2010
|
children: e
|
|
2008
2011
|
});
|
|
2009
|
-
return n === "fixed" ? _e(
|
|
2012
|
+
return n === "fixed" ? _e(O, document.body) : O;
|
|
2010
2013
|
}), er = a(function({ children: e, onSelect: t, disabled: n, icon: r, shortcut: i, destructive: a, checked: o, meta: s, className: c, dataTestId: l, onClick: u, ...d }, f) {
|
|
2011
2014
|
let { setOpen: p } = Yn();
|
|
2012
2015
|
return /* @__PURE__ */ J("button", {
|
|
@@ -3243,16 +3246,34 @@ var hi = a(function(e, t) {
|
|
|
3243
3246
|
formatCreateLabel: a ? ae : void 0,
|
|
3244
3247
|
getOptionValue: (e) => String(e.value),
|
|
3245
3248
|
getOptionLabel: Yr,
|
|
3246
|
-
formatOptionLabel: (e, t) =>
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
className: "
|
|
3250
|
-
children:
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3249
|
+
formatOptionLabel: (e, t) => {
|
|
3250
|
+
if (t.context === "value") return e.label;
|
|
3251
|
+
let n = Me && e.description ? /* @__PURE__ */ J("span", {
|
|
3252
|
+
className: "flex flex-col min-w-0",
|
|
3253
|
+
children: [/* @__PURE__ */ q("span", {
|
|
3254
|
+
className: "truncate",
|
|
3255
|
+
children: e.label
|
|
3256
|
+
}), /* @__PURE__ */ q("span", {
|
|
3257
|
+
className: "truncate text-p-sm text-fg-secondary",
|
|
3258
|
+
children: e.description
|
|
3259
|
+
})]
|
|
3260
|
+
}) : e.label;
|
|
3261
|
+
return e.actions ? /* @__PURE__ */ J("span", {
|
|
3262
|
+
className: "flex min-w-0 flex-1 items-center gap-2",
|
|
3263
|
+
children: [/* @__PURE__ */ q("span", {
|
|
3264
|
+
className: "min-w-0 flex-1 truncate",
|
|
3265
|
+
children: n
|
|
3266
|
+
}), /* @__PURE__ */ q("span", {
|
|
3267
|
+
"data-test-id": ri({ dataTestId: F }, `option-${String(e.value)}-actions`),
|
|
3268
|
+
className: "ml-auto inline-flex shrink-0 items-center",
|
|
3269
|
+
onMouseDown: (e) => {
|
|
3270
|
+
e.preventDefault(), e.stopPropagation();
|
|
3271
|
+
},
|
|
3272
|
+
onClick: (e) => e.stopPropagation(),
|
|
3273
|
+
children: e.actions
|
|
3274
|
+
})]
|
|
3275
|
+
}) : n;
|
|
3276
|
+
},
|
|
3256
3277
|
isOptionDisabled: (e) => !!e.disabled,
|
|
3257
3278
|
placeholder: re,
|
|
3258
3279
|
isDisabled: te || T,
|