laif-ds 0.1.29 → 0.1.31
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/ui/app-multiple-select-dropdown.js +77 -69
- package/dist/components/ui/data-cross-table.js +145 -172
- package/dist/components/ui/dropdown-menu.js +131 -0
- package/dist/components/ui/table.js +3 -10
- package/dist/index.d.ts +18 -3
- package/dist/index.js +168 -161
- package/dist/node_modules/@radix-ui/react-dropdown-menu/dist/index.js +217 -0
- package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-arrow/dist/index.js +25 -0
- package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-collection/dist/index.js +49 -0
- package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-dismissable-layer/dist/index.js +128 -0
- package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-focus-scope/dist/index.js +138 -0
- package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-menu/dist/index.js +625 -0
- package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-popper/dist/index.js +221 -0
- package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-portal/dist/index.js +17 -0
- package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-primitive/dist/index.js +37 -0
- package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-roving-focus/dist/index.js +184 -0
- package/dist/node_modules/@radix-ui/react-dropdown-menu/node_modules/@radix-ui/react-use-controllable-state/dist/index.js +55 -0
- package/dist/styles.v3.css +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as s from "react";
|
|
3
|
+
import { useFloating as xe, offset as Pe, shift as ye, flip as Ae, size as ve, arrow as Ce, hide as be, limitShift as Se } from "../../../../../../@floating-ui/react-dom/dist/floating-ui.react-dom.js";
|
|
4
|
+
import { Root as Oe } from "../../react-arrow/dist/index.js";
|
|
5
|
+
import { useComposedRefs as j } from "../../../../../react-compose-refs/dist/index.js";
|
|
6
|
+
import { createContextScope as Re } from "../../../../../react-context/dist/index.js";
|
|
7
|
+
import { Primitive as z } from "../../react-primitive/dist/index.js";
|
|
8
|
+
import { useCallbackRef as Ee } from "../../../../../react-use-callback-ref/dist/index.js";
|
|
9
|
+
import { useLayoutEffect as T } from "../../../../../react-use-layout-effect/dist/index.js";
|
|
10
|
+
import { useSize as Ne } from "../../../../../react-use-size/dist/index.js";
|
|
11
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
12
|
+
import { autoUpdate as _e } from "../../../../../../@floating-ui/dom/dist/floating-ui.dom.js";
|
|
13
|
+
var N = "Popper", [L, Ue] = Re(N), [$e, Z] = L(N), U = (e) => {
|
|
14
|
+
const { __scopePopper: i, children: n } = e, [t, a] = s.useState(null);
|
|
15
|
+
return /* @__PURE__ */ f($e, { scope: i, anchor: t, onAnchorChange: a, children: n });
|
|
16
|
+
};
|
|
17
|
+
U.displayName = N;
|
|
18
|
+
var q = "PopperAnchor", G = s.forwardRef(
|
|
19
|
+
(e, i) => {
|
|
20
|
+
const { __scopePopper: n, virtualRef: t, ...a } = e, r = Z(q, n), o = s.useRef(null), w = j(i, o);
|
|
21
|
+
return s.useEffect(() => {
|
|
22
|
+
r.onAnchorChange((t == null ? void 0 : t.current) || o.current);
|
|
23
|
+
}), t ? null : /* @__PURE__ */ f(z.div, { ...a, ref: w });
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
G.displayName = q;
|
|
27
|
+
var _ = "PopperContent", [He, We] = L(_), J = s.forwardRef(
|
|
28
|
+
(e, i) => {
|
|
29
|
+
var Y, M, X, D, F, k;
|
|
30
|
+
const {
|
|
31
|
+
__scopePopper: n,
|
|
32
|
+
side: t = "bottom",
|
|
33
|
+
sideOffset: a = 0,
|
|
34
|
+
align: r = "center",
|
|
35
|
+
alignOffset: o = 0,
|
|
36
|
+
arrowPadding: w = 0,
|
|
37
|
+
avoidCollisions: p = !0,
|
|
38
|
+
collisionBoundary: c = [],
|
|
39
|
+
collisionPadding: x = 0,
|
|
40
|
+
sticky: m = "partial",
|
|
41
|
+
hideWhenDetached: y = !1,
|
|
42
|
+
updatePositionStrategy: A = "optimized",
|
|
43
|
+
onPlaced: l,
|
|
44
|
+
...d
|
|
45
|
+
} = e, v = Z(_, n), [h, C] = s.useState(null), ee = j(i, (P) => C(P)), [E, te] = s.useState(null), g = Ne(E), re = (g == null ? void 0 : g.width) ?? 0, $ = (g == null ? void 0 : g.height) ?? 0, oe = t + (r !== "center" ? "-" + r : ""), ne = typeof x == "number" ? x : { top: 0, right: 0, bottom: 0, left: 0, ...x }, H = Array.isArray(c) ? c : [c], ae = H.length > 0, b = {
|
|
46
|
+
padding: ne,
|
|
47
|
+
boundary: H.filter(Ye),
|
|
48
|
+
// with `strategy: 'fixed'`, this is the only way to get it to respect boundaries
|
|
49
|
+
altBoundary: ae
|
|
50
|
+
}, { refs: ie, floatingStyles: W, placement: se, isPositioned: S, middlewareData: u } = xe({
|
|
51
|
+
// default to `fixed` strategy so users don't have to pick and we also avoid focus scroll issues
|
|
52
|
+
strategy: "fixed",
|
|
53
|
+
placement: oe,
|
|
54
|
+
whileElementsMounted: (...P) => _e(...P, {
|
|
55
|
+
animationFrame: A === "always"
|
|
56
|
+
}),
|
|
57
|
+
elements: {
|
|
58
|
+
reference: v.anchor
|
|
59
|
+
},
|
|
60
|
+
middleware: [
|
|
61
|
+
Pe({ mainAxis: a + $, alignmentAxis: o }),
|
|
62
|
+
p && ye({
|
|
63
|
+
mainAxis: !0,
|
|
64
|
+
crossAxis: !1,
|
|
65
|
+
limiter: m === "partial" ? Se() : void 0,
|
|
66
|
+
...b
|
|
67
|
+
}),
|
|
68
|
+
p && Ae({ ...b }),
|
|
69
|
+
ve({
|
|
70
|
+
...b,
|
|
71
|
+
apply: ({ elements: P, rects: B, availableWidth: he, availableHeight: ge }) => {
|
|
72
|
+
const { width: ue, height: we } = B.reference, R = P.floating.style;
|
|
73
|
+
R.setProperty("--radix-popper-available-width", `${he}px`), R.setProperty("--radix-popper-available-height", `${ge}px`), R.setProperty("--radix-popper-anchor-width", `${ue}px`), R.setProperty("--radix-popper-anchor-height", `${we}px`);
|
|
74
|
+
}
|
|
75
|
+
}),
|
|
76
|
+
E && Ce({ element: E, padding: w }),
|
|
77
|
+
Me({ arrowWidth: re, arrowHeight: $ }),
|
|
78
|
+
y && be({ strategy: "referenceHidden", ...b })
|
|
79
|
+
]
|
|
80
|
+
}), [I, pe] = V(se), O = Ee(l);
|
|
81
|
+
T(() => {
|
|
82
|
+
S && (O == null || O());
|
|
83
|
+
}, [S, O]);
|
|
84
|
+
const ce = (Y = u.arrow) == null ? void 0 : Y.x, de = (M = u.arrow) == null ? void 0 : M.y, le = ((X = u.arrow) == null ? void 0 : X.centerOffset) !== 0, [fe, me] = s.useState();
|
|
85
|
+
return T(() => {
|
|
86
|
+
h && me(window.getComputedStyle(h).zIndex);
|
|
87
|
+
}, [h]), /* @__PURE__ */ f(
|
|
88
|
+
"div",
|
|
89
|
+
{
|
|
90
|
+
ref: ie.setFloating,
|
|
91
|
+
"data-radix-popper-content-wrapper": "",
|
|
92
|
+
style: {
|
|
93
|
+
...W,
|
|
94
|
+
transform: S ? W.transform : "translate(0, -200%)",
|
|
95
|
+
// keep off the page when measuring
|
|
96
|
+
minWidth: "max-content",
|
|
97
|
+
zIndex: fe,
|
|
98
|
+
"--radix-popper-transform-origin": [
|
|
99
|
+
(D = u.transformOrigin) == null ? void 0 : D.x,
|
|
100
|
+
(F = u.transformOrigin) == null ? void 0 : F.y
|
|
101
|
+
].join(" "),
|
|
102
|
+
// hide the content if using the hide middleware and should be hidden
|
|
103
|
+
// set visibility to hidden and disable pointer events so the UI behaves
|
|
104
|
+
// as if the PopperContent isn't there at all
|
|
105
|
+
...((k = u.hide) == null ? void 0 : k.referenceHidden) && {
|
|
106
|
+
visibility: "hidden",
|
|
107
|
+
pointerEvents: "none"
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
dir: e.dir,
|
|
111
|
+
children: /* @__PURE__ */ f(
|
|
112
|
+
He,
|
|
113
|
+
{
|
|
114
|
+
scope: n,
|
|
115
|
+
placedSide: I,
|
|
116
|
+
onArrowChange: te,
|
|
117
|
+
arrowX: ce,
|
|
118
|
+
arrowY: de,
|
|
119
|
+
shouldHideArrow: le,
|
|
120
|
+
children: /* @__PURE__ */ f(
|
|
121
|
+
z.div,
|
|
122
|
+
{
|
|
123
|
+
"data-side": I,
|
|
124
|
+
"data-align": pe,
|
|
125
|
+
...d,
|
|
126
|
+
ref: ee,
|
|
127
|
+
style: {
|
|
128
|
+
...d.style,
|
|
129
|
+
// if the PopperContent hasn't been placed yet (not all measurements done)
|
|
130
|
+
// we prevent animations so that users's animation don't kick in too early referring wrong sides
|
|
131
|
+
animation: S ? void 0 : "none"
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
)
|
|
135
|
+
}
|
|
136
|
+
)
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
);
|
|
141
|
+
J.displayName = _;
|
|
142
|
+
var K = "PopperArrow", Ie = {
|
|
143
|
+
top: "bottom",
|
|
144
|
+
right: "left",
|
|
145
|
+
bottom: "top",
|
|
146
|
+
left: "right"
|
|
147
|
+
}, Q = s.forwardRef(function(i, n) {
|
|
148
|
+
const { __scopePopper: t, ...a } = i, r = We(K, t), o = Ie[r.placedSide];
|
|
149
|
+
return (
|
|
150
|
+
// we have to use an extra wrapper because `ResizeObserver` (used by `useSize`)
|
|
151
|
+
// doesn't report size as we'd expect on SVG elements.
|
|
152
|
+
// it reports their bounding box which is effectively the largest path inside the SVG.
|
|
153
|
+
/* @__PURE__ */ f(
|
|
154
|
+
"span",
|
|
155
|
+
{
|
|
156
|
+
ref: r.onArrowChange,
|
|
157
|
+
style: {
|
|
158
|
+
position: "absolute",
|
|
159
|
+
left: r.arrowX,
|
|
160
|
+
top: r.arrowY,
|
|
161
|
+
[o]: 0,
|
|
162
|
+
transformOrigin: {
|
|
163
|
+
top: "",
|
|
164
|
+
right: "0 0",
|
|
165
|
+
bottom: "center 0",
|
|
166
|
+
left: "100% 0"
|
|
167
|
+
}[r.placedSide],
|
|
168
|
+
transform: {
|
|
169
|
+
top: "translateY(100%)",
|
|
170
|
+
right: "translateY(50%) rotate(90deg) translateX(-50%)",
|
|
171
|
+
bottom: "rotate(180deg)",
|
|
172
|
+
left: "translateY(50%) rotate(-90deg) translateX(50%)"
|
|
173
|
+
}[r.placedSide],
|
|
174
|
+
visibility: r.shouldHideArrow ? "hidden" : void 0
|
|
175
|
+
},
|
|
176
|
+
children: /* @__PURE__ */ f(
|
|
177
|
+
Oe,
|
|
178
|
+
{
|
|
179
|
+
...a,
|
|
180
|
+
ref: n,
|
|
181
|
+
style: {
|
|
182
|
+
...a.style,
|
|
183
|
+
// ensures the element can be measured correctly (mostly for if SVG)
|
|
184
|
+
display: "block"
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
)
|
|
188
|
+
}
|
|
189
|
+
)
|
|
190
|
+
);
|
|
191
|
+
});
|
|
192
|
+
Q.displayName = K;
|
|
193
|
+
function Ye(e) {
|
|
194
|
+
return e !== null;
|
|
195
|
+
}
|
|
196
|
+
var Me = (e) => ({
|
|
197
|
+
name: "transformOrigin",
|
|
198
|
+
options: e,
|
|
199
|
+
fn(i) {
|
|
200
|
+
var v, h, C;
|
|
201
|
+
const { placement: n, rects: t, middlewareData: a } = i, o = ((v = a.arrow) == null ? void 0 : v.centerOffset) !== 0, w = o ? 0 : e.arrowWidth, p = o ? 0 : e.arrowHeight, [c, x] = V(n), m = { start: "0%", center: "50%", end: "100%" }[x], y = (((h = a.arrow) == null ? void 0 : h.x) ?? 0) + w / 2, A = (((C = a.arrow) == null ? void 0 : C.y) ?? 0) + p / 2;
|
|
202
|
+
let l = "", d = "";
|
|
203
|
+
return c === "bottom" ? (l = o ? m : `${y}px`, d = `${-p}px`) : c === "top" ? (l = o ? m : `${y}px`, d = `${t.floating.height + p}px`) : c === "right" ? (l = `${-p}px`, d = o ? m : `${A}px`) : c === "left" && (l = `${t.floating.width + p}px`, d = o ? m : `${A}px`), { data: { x: l, y: d } };
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
function V(e) {
|
|
207
|
+
const [i, n = "center"] = e.split("-");
|
|
208
|
+
return [i, n];
|
|
209
|
+
}
|
|
210
|
+
var qe = U, Ge = G, Je = J, Ke = Q;
|
|
211
|
+
export {
|
|
212
|
+
Ge as Anchor,
|
|
213
|
+
Ke as Arrow,
|
|
214
|
+
Je as Content,
|
|
215
|
+
U as Popper,
|
|
216
|
+
G as PopperAnchor,
|
|
217
|
+
Q as PopperArrow,
|
|
218
|
+
J as PopperContent,
|
|
219
|
+
qe as Root,
|
|
220
|
+
Ue as createPopperScope
|
|
221
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as r from "react";
|
|
3
|
+
import m from "react-dom";
|
|
4
|
+
import { Primitive as c } from "../../react-primitive/dist/index.js";
|
|
5
|
+
import { useLayoutEffect as u } from "../../../../../react-use-layout-effect/dist/index.js";
|
|
6
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
7
|
+
var p = "Portal", d = r.forwardRef((e, a) => {
|
|
8
|
+
var o;
|
|
9
|
+
const { container: i, ...n } = e, [s, f] = r.useState(!1);
|
|
10
|
+
u(() => f(!0), []);
|
|
11
|
+
const t = i || s && ((o = globalThis == null ? void 0 : globalThis.document) == null ? void 0 : o.body);
|
|
12
|
+
return t ? m.createPortal(/* @__PURE__ */ l(c.div, { ...n, ref: a }), t) : null;
|
|
13
|
+
});
|
|
14
|
+
d.displayName = p;
|
|
15
|
+
export {
|
|
16
|
+
d as Portal
|
|
17
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as c from "react";
|
|
3
|
+
import * as f from "react-dom";
|
|
4
|
+
import { createSlot as p } from "../../../../../react-slot/dist/index.js";
|
|
5
|
+
import { jsx as l } from "react/jsx-runtime";
|
|
6
|
+
var u = [
|
|
7
|
+
"a",
|
|
8
|
+
"button",
|
|
9
|
+
"div",
|
|
10
|
+
"form",
|
|
11
|
+
"h2",
|
|
12
|
+
"h3",
|
|
13
|
+
"img",
|
|
14
|
+
"input",
|
|
15
|
+
"label",
|
|
16
|
+
"li",
|
|
17
|
+
"nav",
|
|
18
|
+
"ol",
|
|
19
|
+
"p",
|
|
20
|
+
"select",
|
|
21
|
+
"span",
|
|
22
|
+
"svg",
|
|
23
|
+
"ul"
|
|
24
|
+
], h = u.reduce((t, i) => {
|
|
25
|
+
const e = p(`Primitive.${i}`), r = c.forwardRef((o, s) => {
|
|
26
|
+
const { asChild: m, ...a } = o, n = m ? e : i;
|
|
27
|
+
return typeof window < "u" && (window[Symbol.for("radix-ui")] = !0), /* @__PURE__ */ l(n, { ...a, ref: s });
|
|
28
|
+
});
|
|
29
|
+
return r.displayName = `Primitive.${i}`, { ...t, [i]: r };
|
|
30
|
+
}, {});
|
|
31
|
+
function w(t, i) {
|
|
32
|
+
t && f.flushSync(() => t.dispatchEvent(i));
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
h as Primitive,
|
|
36
|
+
w as dispatchDiscreteCustomEvent
|
|
37
|
+
};
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as c from "react";
|
|
3
|
+
import { composeEventHandlers as p } from "../../../../../primitive/dist/index.js";
|
|
4
|
+
import { createCollection as V } from "../../react-collection/dist/index.js";
|
|
5
|
+
import { useComposedRefs as j } from "../../../../../react-compose-refs/dist/index.js";
|
|
6
|
+
import { createContextScope as z } from "../../../../../react-context/dist/index.js";
|
|
7
|
+
import { useId as q } from "../../../../../react-id/dist/index.js";
|
|
8
|
+
import { Primitive as x } from "../../react-primitive/dist/index.js";
|
|
9
|
+
import { useCallbackRef as J } from "../../../../../react-use-callback-ref/dist/index.js";
|
|
10
|
+
import { useControllableState as Q } from "../../react-use-controllable-state/dist/index.js";
|
|
11
|
+
import { useDirection as W } from "../../../../../react-direction/dist/index.js";
|
|
12
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
13
|
+
var _ = "rovingFocusGroup.onEntryFocus", X = { bubbles: !1, cancelable: !0 }, I = "RovingFocusGroup", [y, G, Z] = V(I), [$, Fe] = z(
|
|
14
|
+
I,
|
|
15
|
+
[Z]
|
|
16
|
+
), [ee, oe] = $(I), N = c.forwardRef(
|
|
17
|
+
(e, r) => /* @__PURE__ */ d(y.Provider, { scope: e.__scopeRovingFocusGroup, children: /* @__PURE__ */ d(y.Slot, { scope: e.__scopeRovingFocusGroup, children: /* @__PURE__ */ d(te, { ...e, ref: r }) }) })
|
|
18
|
+
);
|
|
19
|
+
N.displayName = I;
|
|
20
|
+
var te = c.forwardRef((e, r) => {
|
|
21
|
+
const {
|
|
22
|
+
__scopeRovingFocusGroup: s,
|
|
23
|
+
orientation: o,
|
|
24
|
+
loop: E = !1,
|
|
25
|
+
dir: w,
|
|
26
|
+
currentTabStopId: v,
|
|
27
|
+
defaultCurrentTabStopId: C,
|
|
28
|
+
onCurrentTabStopIdChange: T,
|
|
29
|
+
onEntryFocus: m,
|
|
30
|
+
preventScrollOnEntryFocus: u = !1,
|
|
31
|
+
...b
|
|
32
|
+
} = e, F = c.useRef(null), g = j(r, F), R = W(w), [t, l] = Q({
|
|
33
|
+
prop: v,
|
|
34
|
+
defaultProp: C ?? null,
|
|
35
|
+
onChange: T,
|
|
36
|
+
caller: I
|
|
37
|
+
}), [S, i] = c.useState(!1), a = J(m), k = G(s), h = c.useRef(!1), [L, D] = c.useState(0);
|
|
38
|
+
return c.useEffect(() => {
|
|
39
|
+
const n = F.current;
|
|
40
|
+
if (n)
|
|
41
|
+
return n.addEventListener(_, a), () => n.removeEventListener(_, a);
|
|
42
|
+
}, [a]), /* @__PURE__ */ d(
|
|
43
|
+
ee,
|
|
44
|
+
{
|
|
45
|
+
scope: s,
|
|
46
|
+
orientation: o,
|
|
47
|
+
dir: R,
|
|
48
|
+
loop: E,
|
|
49
|
+
currentTabStopId: t,
|
|
50
|
+
onItemFocus: c.useCallback(
|
|
51
|
+
(n) => l(n),
|
|
52
|
+
[l]
|
|
53
|
+
),
|
|
54
|
+
onItemShiftTab: c.useCallback(() => i(!0), []),
|
|
55
|
+
onFocusableItemAdd: c.useCallback(
|
|
56
|
+
() => D((n) => n + 1),
|
|
57
|
+
[]
|
|
58
|
+
),
|
|
59
|
+
onFocusableItemRemove: c.useCallback(
|
|
60
|
+
() => D((n) => n - 1),
|
|
61
|
+
[]
|
|
62
|
+
),
|
|
63
|
+
children: /* @__PURE__ */ d(
|
|
64
|
+
x.div,
|
|
65
|
+
{
|
|
66
|
+
tabIndex: S || L === 0 ? -1 : 0,
|
|
67
|
+
"data-orientation": o,
|
|
68
|
+
...b,
|
|
69
|
+
ref: g,
|
|
70
|
+
style: { outline: "none", ...e.style },
|
|
71
|
+
onMouseDown: p(e.onMouseDown, () => {
|
|
72
|
+
h.current = !0;
|
|
73
|
+
}),
|
|
74
|
+
onFocus: p(e.onFocus, (n) => {
|
|
75
|
+
const U = !h.current;
|
|
76
|
+
if (n.target === n.currentTarget && U && !S) {
|
|
77
|
+
const P = new CustomEvent(_, X);
|
|
78
|
+
if (n.currentTarget.dispatchEvent(P), !P.defaultPrevented) {
|
|
79
|
+
const A = k().filter((f) => f.focusable), B = A.find((f) => f.active), Y = A.find((f) => f.id === t), H = [B, Y, ...A].filter(
|
|
80
|
+
Boolean
|
|
81
|
+
).map((f) => f.ref.current);
|
|
82
|
+
M(H, u);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
h.current = !1;
|
|
86
|
+
}),
|
|
87
|
+
onBlur: p(e.onBlur, () => i(!1))
|
|
88
|
+
}
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
}), O = "RovingFocusGroupItem", K = c.forwardRef(
|
|
93
|
+
(e, r) => {
|
|
94
|
+
const {
|
|
95
|
+
__scopeRovingFocusGroup: s,
|
|
96
|
+
focusable: o = !0,
|
|
97
|
+
active: E = !1,
|
|
98
|
+
tabStopId: w,
|
|
99
|
+
children: v,
|
|
100
|
+
...C
|
|
101
|
+
} = e, T = q(), m = w || T, u = oe(O, s), b = u.currentTabStopId === m, F = G(s), { onFocusableItemAdd: g, onFocusableItemRemove: R } = u;
|
|
102
|
+
return c.useEffect(() => {
|
|
103
|
+
if (o)
|
|
104
|
+
return g(), () => R();
|
|
105
|
+
}, [o, g, R]), /* @__PURE__ */ d(
|
|
106
|
+
y.ItemSlot,
|
|
107
|
+
{
|
|
108
|
+
scope: s,
|
|
109
|
+
id: m,
|
|
110
|
+
focusable: o,
|
|
111
|
+
active: E,
|
|
112
|
+
children: /* @__PURE__ */ d(
|
|
113
|
+
x.span,
|
|
114
|
+
{
|
|
115
|
+
tabIndex: b ? 0 : -1,
|
|
116
|
+
"data-orientation": u.orientation,
|
|
117
|
+
...C,
|
|
118
|
+
ref: r,
|
|
119
|
+
onMouseDown: p(e.onMouseDown, (t) => {
|
|
120
|
+
o ? u.onItemFocus(m) : t.preventDefault();
|
|
121
|
+
}),
|
|
122
|
+
onFocus: p(e.onFocus, () => u.onItemFocus(m)),
|
|
123
|
+
onKeyDown: p(e.onKeyDown, (t) => {
|
|
124
|
+
if (t.key === "Tab" && t.shiftKey) {
|
|
125
|
+
u.onItemShiftTab();
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
if (t.target !== t.currentTarget) return;
|
|
129
|
+
const l = ce(t, u.orientation, u.dir);
|
|
130
|
+
if (l !== void 0) {
|
|
131
|
+
if (t.metaKey || t.ctrlKey || t.altKey || t.shiftKey) return;
|
|
132
|
+
t.preventDefault();
|
|
133
|
+
let i = F().filter((a) => a.focusable).map((a) => a.ref.current);
|
|
134
|
+
if (l === "last") i.reverse();
|
|
135
|
+
else if (l === "prev" || l === "next") {
|
|
136
|
+
l === "prev" && i.reverse();
|
|
137
|
+
const a = i.indexOf(t.currentTarget);
|
|
138
|
+
i = u.loop ? se(i, a + 1) : i.slice(a + 1);
|
|
139
|
+
}
|
|
140
|
+
setTimeout(() => M(i));
|
|
141
|
+
}
|
|
142
|
+
}),
|
|
143
|
+
children: typeof v == "function" ? v({ isCurrentTabStop: b }) : v
|
|
144
|
+
}
|
|
145
|
+
)
|
|
146
|
+
}
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
);
|
|
150
|
+
K.displayName = O;
|
|
151
|
+
var re = {
|
|
152
|
+
ArrowLeft: "prev",
|
|
153
|
+
ArrowUp: "prev",
|
|
154
|
+
ArrowRight: "next",
|
|
155
|
+
ArrowDown: "next",
|
|
156
|
+
PageUp: "first",
|
|
157
|
+
Home: "first",
|
|
158
|
+
PageDown: "last",
|
|
159
|
+
End: "last"
|
|
160
|
+
};
|
|
161
|
+
function ne(e, r) {
|
|
162
|
+
return r !== "rtl" ? e : e === "ArrowLeft" ? "ArrowRight" : e === "ArrowRight" ? "ArrowLeft" : e;
|
|
163
|
+
}
|
|
164
|
+
function ce(e, r, s) {
|
|
165
|
+
const o = ne(e.key, s);
|
|
166
|
+
if (!(r === "vertical" && ["ArrowLeft", "ArrowRight"].includes(o)) && !(r === "horizontal" && ["ArrowUp", "ArrowDown"].includes(o)))
|
|
167
|
+
return re[o];
|
|
168
|
+
}
|
|
169
|
+
function M(e, r = !1) {
|
|
170
|
+
const s = document.activeElement;
|
|
171
|
+
for (const o of e)
|
|
172
|
+
if (o === s || (o.focus({ preventScroll: r }), document.activeElement !== s)) return;
|
|
173
|
+
}
|
|
174
|
+
function se(e, r) {
|
|
175
|
+
return e.map((s, o) => e[(r + o) % e.length]);
|
|
176
|
+
}
|
|
177
|
+
var ge = N, Re = K;
|
|
178
|
+
export {
|
|
179
|
+
Re as Item,
|
|
180
|
+
ge as Root,
|
|
181
|
+
N as RovingFocusGroup,
|
|
182
|
+
K as RovingFocusGroupItem,
|
|
183
|
+
Fe as createRovingFocusGroupScope
|
|
184
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import * as n from "react";
|
|
3
|
+
import { useLayoutEffect as v } from "../../../../../react-use-layout-effect/dist/index.js";
|
|
4
|
+
var E = n[" useInsertionEffect ".trim().toString()] || v;
|
|
5
|
+
function y({
|
|
6
|
+
prop: t,
|
|
7
|
+
defaultProp: u,
|
|
8
|
+
onChange: e = () => {
|
|
9
|
+
},
|
|
10
|
+
caller: i
|
|
11
|
+
}) {
|
|
12
|
+
const [l, o, r] = w({
|
|
13
|
+
defaultProp: u,
|
|
14
|
+
onChange: e
|
|
15
|
+
}), c = t !== void 0, a = c ? t : l;
|
|
16
|
+
{
|
|
17
|
+
const s = n.useRef(t !== void 0);
|
|
18
|
+
n.useEffect(() => {
|
|
19
|
+
const f = s.current;
|
|
20
|
+
f !== c && console.warn(
|
|
21
|
+
`${i} is changing from ${f ? "controlled" : "uncontrolled"} to ${c ? "controlled" : "uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`
|
|
22
|
+
), s.current = c;
|
|
23
|
+
}, [c, i]);
|
|
24
|
+
}
|
|
25
|
+
const m = n.useCallback(
|
|
26
|
+
(s) => {
|
|
27
|
+
var f;
|
|
28
|
+
if (c) {
|
|
29
|
+
const d = R(s) ? s(t) : s;
|
|
30
|
+
d !== t && ((f = r.current) == null || f.call(r, d));
|
|
31
|
+
} else
|
|
32
|
+
o(s);
|
|
33
|
+
},
|
|
34
|
+
[c, t, o, r]
|
|
35
|
+
);
|
|
36
|
+
return [a, m];
|
|
37
|
+
}
|
|
38
|
+
function w({
|
|
39
|
+
defaultProp: t,
|
|
40
|
+
onChange: u
|
|
41
|
+
}) {
|
|
42
|
+
const [e, i] = n.useState(t), l = n.useRef(e), o = n.useRef(u);
|
|
43
|
+
return E(() => {
|
|
44
|
+
o.current = u;
|
|
45
|
+
}, [u]), n.useEffect(() => {
|
|
46
|
+
var r;
|
|
47
|
+
l.current !== e && ((r = o.current) == null || r.call(o, e), l.current = e);
|
|
48
|
+
}, [e, l]), [e, i, o];
|
|
49
|
+
}
|
|
50
|
+
function R(t) {
|
|
51
|
+
return typeof t == "function";
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
y as useControllableState
|
|
55
|
+
};
|