@justanarthur/modo-ui 2.3.0 → 2.4.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/components/data-display/diff/index.tsx +19 -3
- package/components/inputs/choice-list/index.tsx +4 -3
- package/components/navigation/sidebar/menu-scope.tsx +142 -53
- package/components/navigation/sidebar/sidebar-menu-actions.tsx +5 -5
- package/components/navigation/sidebar/sidebar-menu-button.tsx +4 -7
- package/components/navigation/sidebar/sidebar-menu-item.tsx +39 -36
- package/components/navigation/sidebar/sidebar-menu-sub.tsx +3 -2
- package/components/overlays/command/index.tsx +70 -12
- package/components/overlays/dropdown/menu-popup.tsx +11 -2
- package/components/overlays/tooltip/index.tsx +9 -1
- package/dist/blocks/desktop-shell/index.js +10 -10
- package/dist/blocks/sidebar-app/index.js +13 -13
- package/dist/components/actions/copy/index.js +3 -3
- package/dist/components/containers/accordion/index.js +5 -5
- package/dist/components/containers/card/index.js +4 -4
- package/dist/components/data-display/diff/index.d.ts +1 -1
- package/dist/components/data-display/diff/index.js +1 -1
- package/dist/components/data-display/markdown/index.js +5 -5
- package/dist/components/data-display/table/index.js +4 -4
- package/dist/components/inputs/checkbox/index.js +6 -6
- package/dist/components/inputs/choice-list/index.js +5 -5
- package/dist/components/inputs/color-picker/index.js +7 -7
- package/dist/components/inputs/combobox/index.js +6 -6
- package/dist/components/inputs/date-time/calendar/index.js +5 -5
- package/dist/components/inputs/date-time/date-picker/index.js +12 -12
- package/dist/components/inputs/date-time/date-range-picker/index.js +12 -12
- package/dist/components/inputs/date-time/duration-picker/index.js +11 -11
- package/dist/components/inputs/date-time/month-picker/index.js +10 -10
- package/dist/components/inputs/date-time/time-picker/index.js +11 -11
- package/dist/components/inputs/input/index.js +2 -2
- package/dist/components/inputs/key-value/index.js +3 -3
- package/dist/components/inputs/number-input/index.js +3 -3
- package/dist/components/inputs/radio/index.js +5 -5
- package/dist/components/inputs/search/index.js +7 -7
- package/dist/components/inputs/select/index.js +6 -6
- package/dist/components/inputs/switch/index.js +4 -4
- package/dist/components/navigation/breadcrumb/index.js +8 -8
- package/dist/components/navigation/navigation-menu/index.js +6 -6
- package/dist/components/navigation/pagination/index.js +5 -5
- package/dist/components/navigation/sidebar/index.js +9 -9
- package/dist/components/navigation/tabs/index.js +4 -4
- package/dist/components/navigation/tree/index.js +5 -5
- package/dist/components/overlays/alert-dialog/index.js +3 -3
- package/dist/components/overlays/command/index.d.ts +6 -3
- package/dist/components/overlays/command/index.js +6 -6
- package/dist/components/overlays/context-menu/index.js +8 -8
- package/dist/components/overlays/dialog/index.js +2 -2
- package/dist/components/overlays/dropdown/index.js +7 -7
- package/dist/components/overlays/popover/index.js +2 -2
- package/dist/components/overlays/preview-card/index.js +2 -2
- package/dist/components/overlays/sheet/index.js +3 -3
- package/dist/components/overlays/tooltip/index.js +2 -2
- package/dist/docs/index.js +10 -10
- package/dist/index.d.ts +12 -6
- package/dist/index.js +53 -53
- package/dist/lib/fluid-hover-highlight.js +3 -2
- package/dist/lib/focus-ring.d.ts +5 -2
- package/dist/lib/focus-ring.js +2 -1
- package/dist/lib/goo-indicator.d.ts +5 -2
- package/dist/lib/goo-indicator.js +2 -1
- package/dist/lib/overlay.d.ts +8 -1
- package/dist/lib/overlay.js +3 -1
- package/dist/lib/scroll-column.js +4 -4
- package/dist/lib/use-fluid-hover.d.ts +3 -1
- package/dist/lib/use-fluid-hover.js +3 -1
- package/dist/lib/use-merge-split.js +3 -2
- package/dist/primitives/systems/fluid-hover/index.js +4 -4
- package/dist/shared/{components-m7d7r3r8.js → components-0bvxny7s.js} +2 -2
- package/dist/shared/{components-7xc2dne4.js → components-0ep66sg9.js} +5 -5
- package/dist/shared/{components-agjpst9b.js → components-0v4jxw7z.js} +1 -1
- package/dist/shared/{components-a3brpprb.js → components-1qw8hqwq.js} +7 -7
- package/dist/shared/{components-7c4a0egq.js → components-21hcwp85.js} +78 -43
- package/dist/shared/{components-kz6ak6kj.js → components-3qcgeay1.js} +2 -2
- package/dist/shared/{components-e52xgvd9.js → components-4fay97sm.js} +7 -7
- package/dist/shared/{components-fxw1122w.js → components-4fhjk3jz.js} +2 -2
- package/dist/shared/{components-czvraaw9.js → components-4m9stj7d.js} +10 -10
- package/dist/shared/{components-c515d6xr.js → components-5wykqxph.js} +6 -1
- package/dist/shared/{components-8e0fjgm9.js → components-7rn454aq.js} +11 -2
- package/dist/shared/{components-2tw25pk6.js → components-895m1f3s.js} +7 -7
- package/dist/shared/{components-b7p1pjcm.js → components-8m5e493q.js} +1 -1
- package/dist/shared/{components-rzy6h7s4.js → components-8nnhzeb3.js} +5 -5
- package/dist/shared/{components-1hga6pkn.js → components-8xe4h118.js} +5 -5
- package/dist/shared/{components-83jn0raj.js → components-9am5511q.js} +3 -3
- package/dist/shared/{components-g35n8tzm.js → components-9b2m90st.js} +1 -1
- package/dist/shared/{components-2bq4ng4d.js → components-9yrajpy0.js} +1 -1
- package/dist/shared/{components-mvwf8ckh.js → components-ac0x7zpq.js} +2 -2
- package/dist/shared/{components-q7zk70tx.js → components-af44r4y9.js} +1 -1
- package/dist/shared/{components-ex2xtqv7.js → components-br6t88cb.js} +1 -1
- package/dist/shared/{components-z0kz9rxj.js → components-bxqmbcz2.js} +6 -2
- package/dist/shared/{components-2v4mmw1s.js → components-cc9kfhkb.js} +169 -113
- package/dist/shared/{components-e7zxwja1.js → components-d4gkhy26.js} +1 -1
- package/dist/shared/{components-w1ysefg1.js → components-eawe4nxm.js} +1 -1
- package/dist/shared/{components-1sbnbq6a.js → components-fpgfs01m.js} +1 -1
- package/dist/shared/{components-tcm3k3wj.js → components-ft5dgjg6.js} +9 -2
- package/dist/shared/{components-h8v9nh5r.js → components-fv9y76b0.js} +15 -3
- package/dist/shared/{components-6g8a5nrs.js → components-fymenepq.js} +7 -7
- package/dist/shared/{components-8ybvpebx.js → components-greka6z2.js} +58 -18
- package/dist/shared/{components-k2gg1agj.js → components-gzve0nkp.js} +4 -4
- package/dist/shared/{components-fjg4j430.js → components-hjdv4y8d.js} +2 -2
- package/dist/shared/{components-k25zw9g8.js → components-hjk6dwsp.js} +1 -1
- package/dist/shared/{components-4fswe4kh.js → components-mb80a9wg.js} +1 -1
- package/dist/shared/{components-nh05qz8b.js → components-mzdbtgvz.js} +8 -8
- package/dist/shared/{components-x5v7e0fz.js → components-nmbcfwx8.js} +7 -7
- package/dist/shared/{components-9rebr89j.js → components-pw6gzev8.js} +1 -1
- package/dist/shared/{components-01e24999.js → components-pwsqp2np.js} +20 -10
- package/dist/shared/{components-eebf7f9c.js → components-qmkfpcw0.js} +8 -8
- package/dist/shared/{components-etgpz4zk.js → components-qrtcc8aw.js} +3 -3
- package/dist/shared/{components-nred2e6g.js → components-rgdspnth.js} +2 -2
- package/dist/shared/{components-gnsvnejm.js → components-rtwfh1gc.js} +2 -2
- package/dist/shared/{components-z87sanbc.js → components-s0megs1g.js} +4 -4
- package/dist/shared/{components-7g2q2ccp.js → components-sh8j39z3.js} +6 -6
- package/dist/shared/{components-vykcfb5r.js → components-v1zzr668.js} +3 -3
- package/dist/shared/{components-5vezp3e5.js → components-vcmky8ns.js} +6 -6
- package/dist/shared/{components-6xtntksc.js → components-xq8j9c2f.js} +8 -8
- package/dist/shared/{components-27fatggq.js → components-y9se9mx5.js} +3 -3
- package/dist/shared/{components-9ca0c92a.js → components-yfx0skxc.js} +1 -1
- package/dist/shared/{components-ta4e10mx.js → components-zckgawt6.js} +5 -5
- package/dist/styles.css +1 -1
- package/lib/focus-ring.tsx +15 -8
- package/lib/goo-indicator.tsx +20 -8
- package/lib/overlay.tsx +22 -1
- package/lib/use-fluid-hover.ts +96 -72
- package/package.json +1 -1
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
} from "./components-xnp09586.js";
|
|
12
12
|
import {
|
|
13
13
|
usePortalContainer2
|
|
14
|
-
} from "./components-
|
|
14
|
+
} from "./components-ft5dgjg6.js";
|
|
15
15
|
import {
|
|
16
16
|
useShape2
|
|
17
17
|
} from "./components-kxpcj2ry.js";
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
DialogTitle2,
|
|
28
28
|
DialogDescription2,
|
|
29
29
|
DialogState2
|
|
30
|
-
} from "./components-
|
|
30
|
+
} from "./components-br6t88cb.js";
|
|
31
31
|
|
|
32
32
|
// components/overlays/sheet/index.tsx
|
|
33
33
|
import { Drawer as DrawerPrimitive } from "@base-ui/react/drawer";
|
|
@@ -6,6 +6,9 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
spring2
|
|
8
8
|
} from "./components-45r18egt.js";
|
|
9
|
+
import {
|
|
10
|
+
sameRect2
|
|
11
|
+
} from "./components-21hcwp85.js";
|
|
9
12
|
import {
|
|
10
13
|
GOO_MATRIX2,
|
|
11
14
|
GOO_BLUR_RATIO2
|
|
@@ -16,7 +19,7 @@ import {
|
|
|
16
19
|
|
|
17
20
|
// lib/goo-indicator.tsx
|
|
18
21
|
import { animate, motion, useMotionValue } from "motion/react";
|
|
19
|
-
import { useId, useLayoutEffect, useRef, useState } from "react";
|
|
22
|
+
import { memo, useId, useLayoutEffect, useRef, useState } from "react";
|
|
20
23
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
21
24
|
var COVERAGE = "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 0";
|
|
22
25
|
var NECK = 0.5;
|
|
@@ -123,7 +126,7 @@ function GooLayer2({ active, blur, box, fill, children }) {
|
|
|
123
126
|
]
|
|
124
127
|
});
|
|
125
128
|
}
|
|
126
|
-
function
|
|
129
|
+
function GooIndicatorBase({
|
|
127
130
|
rect,
|
|
128
131
|
from,
|
|
129
132
|
className,
|
|
@@ -214,4 +217,5 @@ function GooIndicator2({
|
|
|
214
217
|
]
|
|
215
218
|
});
|
|
216
219
|
}
|
|
220
|
+
var GooIndicator2 = memo(GooIndicatorBase, (a, b) => sameRect2(a.rect, b.rect) && sameRect2(a.from, b.from) && a.className === b.className && a.shadow === b.shadow && a.transition === b.transition && a.opacity === b.opacity);
|
|
217
221
|
export { union2, GooLayer2, GooIndicator2 };
|
|
@@ -46,19 +46,20 @@ import {
|
|
|
46
46
|
} from "./components-ycwhrqe1.js";
|
|
47
47
|
import {
|
|
48
48
|
Sheet2
|
|
49
|
-
} from "./components-
|
|
49
|
+
} from "./components-ac0x7zpq.js";
|
|
50
|
+
import {
|
|
51
|
+
sameRect2,
|
|
52
|
+
useFluidHover2
|
|
53
|
+
} from "./components-21hcwp85.js";
|
|
50
54
|
import {
|
|
51
55
|
GooIndicator2
|
|
52
|
-
} from "./components-
|
|
56
|
+
} from "./components-bxqmbcz2.js";
|
|
53
57
|
import {
|
|
54
58
|
FluidHoverHighlight2
|
|
55
|
-
} from "./components-
|
|
59
|
+
} from "./components-9b2m90st.js";
|
|
56
60
|
import {
|
|
57
61
|
FocusRing2
|
|
58
|
-
} from "./components-
|
|
59
|
-
import {
|
|
60
|
-
useFluidHover2
|
|
61
|
-
} from "./components-7c4a0egq.js";
|
|
62
|
+
} from "./components-5wykqxph.js";
|
|
62
63
|
import {
|
|
63
64
|
useIsoLayoutEffect2
|
|
64
65
|
} from "./components-v2j3jx89.js";
|
|
@@ -79,7 +80,7 @@ import {
|
|
|
79
80
|
} from "./components-8wp8d8q1.js";
|
|
80
81
|
import {
|
|
81
82
|
Tooltip2
|
|
82
|
-
} from "./components-
|
|
83
|
+
} from "./components-7rn454aq.js";
|
|
83
84
|
|
|
84
85
|
// components/navigation/sidebar/index.tsx
|
|
85
86
|
import {
|
|
@@ -92,10 +93,13 @@ import {
|
|
|
92
93
|
import { AnimatePresence, motion } from "motion/react";
|
|
93
94
|
import {
|
|
94
95
|
createContext,
|
|
96
|
+
memo,
|
|
95
97
|
useCallback,
|
|
98
|
+
useContext,
|
|
96
99
|
useMemo,
|
|
97
100
|
useRef,
|
|
98
|
-
useState
|
|
101
|
+
useState,
|
|
102
|
+
useSyncExternalStore
|
|
99
103
|
} from "react";
|
|
100
104
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
101
105
|
/*!
|
|
@@ -107,7 +111,29 @@ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
|
107
111
|
var MenuScopeContext = createContext(null);
|
|
108
112
|
var SidebarSelection2 = createContext(null);
|
|
109
113
|
var MenuItemContext = createContext(null);
|
|
114
|
+
var MenuRowContext = createContext(null);
|
|
110
115
|
var MenuActionsClusterContext = createContext(false);
|
|
116
|
+
var NO_SUBSCRIPTION = () => () => {};
|
|
117
|
+
var HOVERED = 1;
|
|
118
|
+
var ACTIVE = 2;
|
|
119
|
+
var TAB_STOP = 4;
|
|
120
|
+
function useRowState(rowRef) {
|
|
121
|
+
const scope = useContext(MenuScopeContext);
|
|
122
|
+
const flags = useSyncExternalStore(scope?.subscribe ?? NO_SUBSCRIPTION, () => {
|
|
123
|
+
const row = rowRef?.current;
|
|
124
|
+
if (!scope || !row)
|
|
125
|
+
return 0;
|
|
126
|
+
const { hovered, active, first } = scope.getSnapshot();
|
|
127
|
+
const isActive = active.includes(row);
|
|
128
|
+
const tabStop = active.length > 0 ? isActive : row === first;
|
|
129
|
+
return (row === hovered ? HOVERED : 0) | (isActive ? ACTIVE : 0) | (tabStop ? TAB_STOP : 0);
|
|
130
|
+
}, () => 0);
|
|
131
|
+
return {
|
|
132
|
+
isHovered: (flags & HOVERED) !== 0,
|
|
133
|
+
isActiveRow: (flags & ACTIVE) !== 0,
|
|
134
|
+
isTabStop: (flags & TAB_STOP) !== 0
|
|
135
|
+
};
|
|
136
|
+
}
|
|
111
137
|
function rowHidden(el) {
|
|
112
138
|
return el.closest('[data-sidebar="menu-sub"][data-state="closed"]') !== null;
|
|
113
139
|
}
|
|
@@ -152,6 +178,24 @@ function gutterVars(item) {
|
|
|
152
178
|
const rest = item?.actionsShowOnHover ? rowGutter(0, item.hasBadge) : hover;
|
|
153
179
|
return { "--row-gutter": `${rest}px`, "--row-gutter-hover": `${hover}px` };
|
|
154
180
|
}
|
|
181
|
+
function sameBackgrounds(a, b) {
|
|
182
|
+
return a.length === b.length && a.every((x, i) => x.key === b[i]?.key && x.rowChanged === b[i]?.rowChanged && sameRect2(x.rect, b[i]?.rect));
|
|
183
|
+
}
|
|
184
|
+
var ActiveBackgrounds = memo(function ActiveBackgrounds({ items, className }) {
|
|
185
|
+
return /* @__PURE__ */ jsx(AnimatePresence, {
|
|
186
|
+
children: items.map(({ key, rect, rowChanged }) => /* @__PURE__ */ jsx(motion.div, {
|
|
187
|
+
className: "pointer-events-none absolute top-0 left-0",
|
|
188
|
+
initial: false,
|
|
189
|
+
animate: { opacity: 1 },
|
|
190
|
+
exit: { opacity: 0, transition: spring2.moderate.exit },
|
|
191
|
+
children: /* @__PURE__ */ jsx(GooIndicator2, {
|
|
192
|
+
rect,
|
|
193
|
+
className,
|
|
194
|
+
transition: rowChanged ? spring2.moderate : false
|
|
195
|
+
})
|
|
196
|
+
}, key))
|
|
197
|
+
});
|
|
198
|
+
}, (a, b) => a.className === b.className && sameBackgrounds(a.items, b.items));
|
|
155
199
|
function useMenuScope(containerRef, { focusRing = true } = {}) {
|
|
156
200
|
const { activeIndex, setActiveIndex, itemRects, isMeasured, sessionRef, handlers, registerItem } = useFluidHover2(containerRef, { isItemDisabled: rowSkipped });
|
|
157
201
|
const rowsRef = useRef(new Set);
|
|
@@ -159,54 +203,72 @@ function useMenuScope(containerRef, { focusRing = true } = {}) {
|
|
|
159
203
|
const activeMapRef = useRef(new Map);
|
|
160
204
|
const [orderedRows, setOrderedRows] = useState([]);
|
|
161
205
|
const orderedRowsRef = useRef(orderedRows);
|
|
162
|
-
orderedRowsRef.current = orderedRows;
|
|
163
206
|
const registeredCountRef = useRef(0);
|
|
164
207
|
const [activeRows, setActiveRows] = useState([]);
|
|
165
208
|
const [focusedRowEl, setFocusedRowEl] = useState(null);
|
|
166
|
-
const recomputeActive = useCallback(() => {
|
|
167
|
-
const next = orderedRowsRef.current.filter((el) => activeMapRef.current.get(el) && !rowSkipped(el));
|
|
168
|
-
setActiveRows((prev) => sameElements(prev, next) ? prev : next);
|
|
169
|
-
}, []);
|
|
170
209
|
const rowButton = useCallback((row) => rowButtonsRef.current.get(row) ?? row.querySelector(':scope > [data-sidebar="menu-button"], :scope > [data-sidebar="menu-sub-button"]'), []);
|
|
210
|
+
const staleRef = useRef(false);
|
|
171
211
|
const syncRows = useCallback(() => {
|
|
212
|
+
staleRef.current = false;
|
|
172
213
|
const sorted = [...rowsRef.current].sort(byDomOrder);
|
|
173
|
-
orderedRowsRef.current
|
|
174
|
-
|
|
214
|
+
if (!sameElements(orderedRowsRef.current, sorted)) {
|
|
215
|
+
orderedRowsRef.current = sorted;
|
|
216
|
+
setOrderedRows(sorted);
|
|
217
|
+
}
|
|
175
218
|
for (const [i, el] of sorted.entries())
|
|
176
219
|
registerItem(i, rowButton(el) ?? el);
|
|
177
220
|
for (let i = sorted.length;i < registeredCountRef.current; i++)
|
|
178
221
|
registerItem(i, null);
|
|
179
222
|
registeredCountRef.current = sorted.length;
|
|
180
|
-
|
|
181
|
-
|
|
223
|
+
const active = sorted.filter((el) => activeMapRef.current.get(el) && !rowSkipped(el));
|
|
224
|
+
setActiveRows((prev) => sameElements(prev, active) ? prev : active);
|
|
225
|
+
}, [registerItem, rowButton]);
|
|
226
|
+
const rows = useCallback(() => {
|
|
227
|
+
if (staleRef.current)
|
|
228
|
+
syncRows();
|
|
229
|
+
return orderedRowsRef.current;
|
|
230
|
+
}, [syncRows]);
|
|
231
|
+
const invalidate = useCallback(() => {
|
|
232
|
+
if (staleRef.current)
|
|
233
|
+
return;
|
|
234
|
+
staleRef.current = true;
|
|
235
|
+
queueMicrotask(() => {
|
|
236
|
+
if (staleRef.current)
|
|
237
|
+
syncRows();
|
|
238
|
+
});
|
|
239
|
+
}, [syncRows]);
|
|
182
240
|
const registerRow = useCallback((el) => {
|
|
183
241
|
rowsRef.current.add(el);
|
|
184
|
-
|
|
242
|
+
invalidate();
|
|
185
243
|
return () => {
|
|
186
244
|
rowsRef.current.delete(el);
|
|
187
245
|
rowButtonsRef.current.delete(el);
|
|
188
246
|
activeMapRef.current.delete(el);
|
|
189
|
-
|
|
247
|
+
invalidate();
|
|
190
248
|
};
|
|
191
|
-
}, [
|
|
249
|
+
}, [invalidate]);
|
|
192
250
|
const setRowButton = useCallback((row, button) => {
|
|
193
251
|
if (button)
|
|
194
252
|
rowButtonsRef.current.set(row, button);
|
|
195
253
|
else
|
|
196
254
|
rowButtonsRef.current.delete(row);
|
|
197
|
-
|
|
198
|
-
}, [
|
|
255
|
+
invalidate();
|
|
256
|
+
}, [invalidate]);
|
|
199
257
|
const setRowActive = useCallback((row, active) => {
|
|
258
|
+
if (activeMapRef.current.get(row) === active)
|
|
259
|
+
return;
|
|
200
260
|
activeMapRef.current.set(row, active);
|
|
201
|
-
|
|
202
|
-
}, [
|
|
261
|
+
invalidate();
|
|
262
|
+
}, [invalidate]);
|
|
203
263
|
const refreshVisibility = useCallback(() => {
|
|
204
|
-
|
|
264
|
+
const ordered = rows();
|
|
265
|
+
const active = ordered.filter((el) => activeMapRef.current.get(el) && !rowSkipped(el));
|
|
266
|
+
setActiveRows((prev) => sameElements(prev, active) ? prev : active);
|
|
205
267
|
setActiveIndex((prev) => {
|
|
206
|
-
const row = prev !== null ?
|
|
268
|
+
const row = prev !== null ? ordered[prev] : undefined;
|
|
207
269
|
return row && rowSkipped(row) ? null : prev;
|
|
208
270
|
});
|
|
209
|
-
}, [
|
|
271
|
+
}, [rows, setActiveIndex]);
|
|
210
272
|
const overlayRect = useCallback((row) => {
|
|
211
273
|
if (!row)
|
|
212
274
|
return null;
|
|
@@ -235,12 +297,12 @@ function useMenuScope(containerRef, { focusRing = true } = {}) {
|
|
|
235
297
|
const row = target.closest('[data-sidebar="menu-item"],[data-sidebar="menu-sub-item"]');
|
|
236
298
|
if (!row)
|
|
237
299
|
return;
|
|
238
|
-
const idx =
|
|
300
|
+
const idx = rows().indexOf(row);
|
|
239
301
|
if (idx === -1)
|
|
240
302
|
return;
|
|
241
303
|
setActiveIndex(idx);
|
|
242
304
|
setFocusedRowEl(target.matches(":focus-visible") ? row : null);
|
|
243
|
-
}, [setActiveIndex]);
|
|
305
|
+
}, [rows, setActiveIndex]);
|
|
244
306
|
const onBlur = useCallback((e) => {
|
|
245
307
|
if (containerRef.current?.contains(e.relatedTarget))
|
|
246
308
|
return;
|
|
@@ -269,16 +331,28 @@ function useMenuScope(containerRef, { focusRing = true } = {}) {
|
|
|
269
331
|
}
|
|
270
332
|
}, [containerRef]);
|
|
271
333
|
const hoveredRowEl = activeIndex !== null ? orderedRows[activeIndex] ?? null : null;
|
|
334
|
+
const snapshotRef = useRef({ hovered: null, active: [], first: null });
|
|
335
|
+
const listenersRef = useRef(new Set);
|
|
336
|
+
const firstRowEl = orderedRows[0] ?? null;
|
|
337
|
+
useIsoLayoutEffect2(() => {
|
|
338
|
+
const prev = snapshotRef.current;
|
|
339
|
+
if (prev.hovered === hoveredRowEl && prev.active === activeRows && prev.first === firstRowEl)
|
|
340
|
+
return;
|
|
341
|
+
snapshotRef.current = { hovered: hoveredRowEl, active: activeRows, first: firstRowEl };
|
|
342
|
+
for (const listener of listenersRef.current)
|
|
343
|
+
listener();
|
|
344
|
+
}, [hoveredRowEl, activeRows, firstRowEl]);
|
|
272
345
|
const value = useMemo(() => ({
|
|
273
346
|
registerRow,
|
|
274
347
|
setRowButton,
|
|
275
348
|
setRowActive,
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
349
|
+
refreshVisibility,
|
|
350
|
+
subscribe: (listener) => {
|
|
351
|
+
listenersRef.current.add(listener);
|
|
352
|
+
return () => listenersRef.current.delete(listener);
|
|
353
|
+
},
|
|
354
|
+
getSnapshot: () => snapshotRef.current
|
|
355
|
+
}), [registerRow, setRowButton, setRowActive, refreshVisibility]);
|
|
282
356
|
const shape = useShape2();
|
|
283
357
|
const rowLevel = useCallback((row) => row.closest('[data-sidebar="menu-sub"]') ?? containerRef.current, [containerRef]);
|
|
284
358
|
const prevTargetsRef = useRef({ hover: null, focus: null, actives: new Map });
|
|
@@ -315,18 +389,9 @@ function useMenuScope(containerRef, { focusRing = true } = {}) {
|
|
|
315
389
|
const hoverAnchorRect = hoverAnchorRow ? overlayRect(hoverAnchorRow) : null;
|
|
316
390
|
const overlays = isMeasured ? /* @__PURE__ */ jsxs(Fragment, {
|
|
317
391
|
children: [
|
|
318
|
-
/* @__PURE__ */ jsx(
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
initial: false,
|
|
322
|
-
animate: { opacity: 1 },
|
|
323
|
-
exit: { opacity: 0, transition: spring2.moderate.exit },
|
|
324
|
-
children: /* @__PURE__ */ jsx(GooIndicator2, {
|
|
325
|
-
rect,
|
|
326
|
-
className: cn2("bg-active", shape.bg),
|
|
327
|
-
transition: rowChanged ? spring2.moderate : false
|
|
328
|
-
})
|
|
329
|
-
}, key))
|
|
392
|
+
/* @__PURE__ */ jsx(ActiveBackgrounds, {
|
|
393
|
+
items: activeRects,
|
|
394
|
+
className: cn2("bg-active", shape.bg)
|
|
330
395
|
}),
|
|
331
396
|
/* @__PURE__ */ jsx(FluidHoverHighlight2, {
|
|
332
397
|
rect: hoverRect,
|
|
@@ -358,7 +423,7 @@ function useMenuScope(containerRef, { focusRing = true } = {}) {
|
|
|
358
423
|
}
|
|
359
424
|
|
|
360
425
|
// components/navigation/sidebar/sidebar-context.tsx
|
|
361
|
-
import { createContext as createContext2, useContext } from "react";
|
|
426
|
+
import { createContext as createContext2, useContext as useContext2 } from "react";
|
|
362
427
|
/*!
|
|
363
428
|
* Ported from Fluid Functionalism — github.com/mickadesign/fluid-functionalism
|
|
364
429
|
* `registry/default/sidebar-core.tsx` @ b3587bdbd83fc66c2a6aae3817ffb856cb09260b
|
|
@@ -375,7 +440,7 @@ var SIDEBAR_MIN_WIDTH2 = 160;
|
|
|
375
440
|
var SIDEBAR_MAX_WIDTH2 = 360;
|
|
376
441
|
var SidebarContext = createContext2(null);
|
|
377
442
|
function useSidebar2() {
|
|
378
|
-
const ctx =
|
|
443
|
+
const ctx = useContext2(SidebarContext);
|
|
379
444
|
if (!ctx)
|
|
380
445
|
throw new Error("useSidebar must be used within a SidebarProvider");
|
|
381
446
|
return ctx;
|
|
@@ -391,7 +456,7 @@ import {
|
|
|
391
456
|
createContext as createContext3,
|
|
392
457
|
forwardRef,
|
|
393
458
|
isValidElement,
|
|
394
|
-
useContext as
|
|
459
|
+
useContext as useContext3,
|
|
395
460
|
useEffect,
|
|
396
461
|
useId,
|
|
397
462
|
useMemo as useMemo2,
|
|
@@ -559,7 +624,7 @@ var SidebarGroup2 = forwardRef(({ className, collapsible = false, open: openProp
|
|
|
559
624
|
SidebarGroup2.displayName = "SidebarGroup";
|
|
560
625
|
var SidebarGroupLabel2 = forwardRef(({ className, render, asChild, children, ...props }, ref) => {
|
|
561
626
|
const size = useSize2();
|
|
562
|
-
const group =
|
|
627
|
+
const group = useContext3(SidebarGroupContext);
|
|
563
628
|
const shape = useShape2();
|
|
564
629
|
const ChevronRightIcon = useIcon2("chevron-right");
|
|
565
630
|
const { template, content } = resolveSlotTemplate2(render, asChild, children);
|
|
@@ -616,7 +681,7 @@ var GroupActionsContext = createContext3(false);
|
|
|
616
681
|
var SidebarGroupAction2 = forwardRef(({ className, render, asChild, children, style, ...props }, ref) => {
|
|
617
682
|
const shape = useShape2();
|
|
618
683
|
const size = useSize2();
|
|
619
|
-
const inCluster =
|
|
684
|
+
const inCluster = useContext3(GroupActionsContext);
|
|
620
685
|
const { template, content } = resolveSlotTemplate2(render, asChild, children);
|
|
621
686
|
return slotElement2(template, "button", {
|
|
622
687
|
ref,
|
|
@@ -651,7 +716,7 @@ SidebarGroupContent2.displayName = "SidebarGroupContent";
|
|
|
651
716
|
import {
|
|
652
717
|
Children as Children3,
|
|
653
718
|
forwardRef as forwardRef2,
|
|
654
|
-
useContext as
|
|
719
|
+
useContext as useContext4,
|
|
655
720
|
useId as useId2
|
|
656
721
|
} from "react";
|
|
657
722
|
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
@@ -664,8 +729,8 @@ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
|
664
729
|
var SidebarMenuAction2 = forwardRef2(({ className, showOnHover = false, render, asChild, children, onClick, style, ...props }, ref) => {
|
|
665
730
|
const shape = useShape2();
|
|
666
731
|
const size = useSize2();
|
|
667
|
-
const item =
|
|
668
|
-
const inCluster =
|
|
732
|
+
const item = useContext4(MenuRowContext);
|
|
733
|
+
const inCluster = useContext4(MenuActionsClusterContext);
|
|
669
734
|
const { template, content } = resolveSlotTemplate2(render, asChild, children);
|
|
670
735
|
const setActions = item?.setActions;
|
|
671
736
|
useIsoLayoutEffect2(() => {
|
|
@@ -690,7 +755,7 @@ var SidebarMenuAction2 = forwardRef2(({ className, showOnHover = false, render,
|
|
|
690
755
|
});
|
|
691
756
|
SidebarMenuAction2.displayName = "SidebarMenuAction";
|
|
692
757
|
var SidebarMenuActions2 = forwardRef2(({ className, showOnHover = false, children, ...props }, ref) => {
|
|
693
|
-
const item =
|
|
758
|
+
const item = useContext4(MenuRowContext);
|
|
694
759
|
const size = useSize2();
|
|
695
760
|
const count = Children3.count(children);
|
|
696
761
|
const setActions = item?.setActions;
|
|
@@ -711,9 +776,9 @@ var SidebarMenuActions2 = forwardRef2(({ className, showOnHover = false, childre
|
|
|
711
776
|
});
|
|
712
777
|
SidebarMenuActions2.displayName = "SidebarMenuActions";
|
|
713
778
|
var SidebarMenuBadge2 = forwardRef2(({ className, ...props }, ref) => {
|
|
714
|
-
const item =
|
|
779
|
+
const item = useContext4(MenuRowContext);
|
|
715
780
|
const size = useSize2();
|
|
716
|
-
const lit = item?.isActiveRow
|
|
781
|
+
const lit = useRowState(item?.rowRef).isActiveRow;
|
|
717
782
|
const setHasBadge = item?.setHasBadge;
|
|
718
783
|
useIsoLayoutEffect2(() => {
|
|
719
784
|
setHasBadge?.(true);
|
|
@@ -759,7 +824,7 @@ import { cva } from "class-variance-authority";
|
|
|
759
824
|
import { motion as motion3 } from "motion/react";
|
|
760
825
|
import {
|
|
761
826
|
forwardRef as forwardRef3,
|
|
762
|
-
useContext as
|
|
827
|
+
useContext as useContext5,
|
|
763
828
|
useRef as useRef3
|
|
764
829
|
} from "react";
|
|
765
830
|
import { jsx as jsx5, jsxs as jsxs5, Fragment as Fragment4 } from "react/jsx-runtime";
|
|
@@ -794,9 +859,8 @@ var SidebarMenuButton2 = forwardRef3(({
|
|
|
794
859
|
children,
|
|
795
860
|
...props
|
|
796
861
|
}, ref) => {
|
|
797
|
-
const
|
|
798
|
-
const
|
|
799
|
-
const selection = useContext4(SidebarSelection2);
|
|
862
|
+
const item = useContext5(MenuItemContext);
|
|
863
|
+
const selection = useContext5(SidebarSelection2);
|
|
800
864
|
const shape = useShape2();
|
|
801
865
|
const sizeClasses = useSize2(size);
|
|
802
866
|
const buttonRef = useRef3(null);
|
|
@@ -815,9 +879,9 @@ var SidebarMenuButton2 = forwardRef3(({
|
|
|
815
879
|
return () => setButtonEl?.(null);
|
|
816
880
|
}, [setButtonEl]);
|
|
817
881
|
const resolvedDot = dot ?? (status ? status === "idle" ? "ring" : "filled" : undefined);
|
|
818
|
-
const
|
|
819
|
-
const
|
|
820
|
-
const tabIdx = effectiveActive
|
|
882
|
+
const row = useRowState(item?.rowRef);
|
|
883
|
+
const lit = effectiveActive || row.isHovered;
|
|
884
|
+
const tabIdx = effectiveActive || row.isTabStop ? 0 : -1;
|
|
821
885
|
const { template, content } = resolveSlotTemplate2(render, asChild, children);
|
|
822
886
|
const inner = /* @__PURE__ */ jsxs5(Fragment4, {
|
|
823
887
|
children: [
|
|
@@ -890,7 +954,7 @@ SidebarMenuButton2.displayName = "SidebarMenuButton";
|
|
|
890
954
|
import {
|
|
891
955
|
forwardRef as forwardRef4,
|
|
892
956
|
useCallback as useCallback2,
|
|
893
|
-
useContext as
|
|
957
|
+
useContext as useContext6,
|
|
894
958
|
useMemo as useMemo3,
|
|
895
959
|
useRef as useRef4,
|
|
896
960
|
useState as useState4
|
|
@@ -926,7 +990,7 @@ var SidebarMenu2 = forwardRef4(({ className, size, focusRing, children, ...props
|
|
|
926
990
|
});
|
|
927
991
|
SidebarMenu2.displayName = "SidebarMenu";
|
|
928
992
|
function useMenuRow(rowRef, isSubRow, sub) {
|
|
929
|
-
const scope =
|
|
993
|
+
const scope = useContext6(MenuScopeContext);
|
|
930
994
|
const registerRow = scope?.registerRow;
|
|
931
995
|
const setRowButton = scope?.setRowButton;
|
|
932
996
|
const setRowActive = scope?.setRowActive;
|
|
@@ -951,19 +1015,16 @@ function useMenuRow(rowRef, isSubRow, sub) {
|
|
|
951
1015
|
if (rowRef.current && setRowButton)
|
|
952
1016
|
setRowButton(rowRef.current, el);
|
|
953
1017
|
}, [setRowButton, rowRef]);
|
|
954
|
-
const isHovered = rowRef.current !== null && scope?.hoveredRowEl === rowRef.current;
|
|
955
|
-
const isActiveRow = rowRef.current !== null && (scope?.activeRows.includes(rowRef.current) ?? false);
|
|
956
1018
|
const [trailing, setTrailing] = useState4({ actionCount: 0, actionsShowOnHover: false, hasBadge: false });
|
|
957
1019
|
const setActions = useCallback2((count, showOnHover) => setTrailing((prev) => prev.actionCount === count && prev.actionsShowOnHover === showOnHover ? prev : { ...prev, actionCount: count, actionsShowOnHover: showOnHover }), []);
|
|
958
1020
|
const setHasBadge = useCallback2((hasBadge) => setTrailing((prev) => prev.hasBadge === hasBadge ? prev : { ...prev, hasBadge }), []);
|
|
959
1021
|
const [open, setOpen] = useControllableState2(sub?.open, sub?.defaultOpen ?? false, sub?.onOpenChange);
|
|
960
1022
|
const subOpen = sub?.collapsible ? open : undefined;
|
|
961
1023
|
const toggleSub = useCallback2(() => setOpen((prev) => !prev), [setOpen]);
|
|
962
|
-
|
|
1024
|
+
const row = useMemo3(() => ({ rowRef, isSubRow, setActions, setHasBadge }), [rowRef, isSubRow, setActions, setHasBadge]);
|
|
1025
|
+
const item = useMemo3(() => ({
|
|
963
1026
|
rowRef,
|
|
964
1027
|
attachRow,
|
|
965
|
-
isHovered,
|
|
966
|
-
isActiveRow,
|
|
967
1028
|
isSubRow,
|
|
968
1029
|
setActive,
|
|
969
1030
|
setButtonEl,
|
|
@@ -972,49 +1033,43 @@ function useMenuRow(rowRef, isSubRow, sub) {
|
|
|
972
1033
|
setHasBadge,
|
|
973
1034
|
subOpen,
|
|
974
1035
|
toggleSub
|
|
975
|
-
}), [
|
|
976
|
-
|
|
977
|
-
attachRow,
|
|
978
|
-
isHovered,
|
|
979
|
-
isActiveRow,
|
|
980
|
-
isSubRow,
|
|
981
|
-
setActive,
|
|
982
|
-
setButtonEl,
|
|
983
|
-
trailing,
|
|
984
|
-
setActions,
|
|
985
|
-
setHasBadge,
|
|
986
|
-
subOpen,
|
|
987
|
-
toggleSub
|
|
988
|
-
]);
|
|
1036
|
+
}), [rowRef, attachRow, isSubRow, setActive, setButtonEl, trailing, setActions, setHasBadge, subOpen, toggleSub]);
|
|
1037
|
+
return { item, row };
|
|
989
1038
|
}
|
|
990
1039
|
var SidebarMenuItem2 = forwardRef4(({ collapsible, open, defaultOpen, onOpenChange, className, children, ...props }, ref) => {
|
|
991
1040
|
const rowRef = useRef4(null);
|
|
992
|
-
const item = useMenuRow(rowRef, false, { collapsible, open, defaultOpen, onOpenChange });
|
|
993
|
-
const
|
|
994
|
-
return /* @__PURE__ */ jsx6(
|
|
995
|
-
value:
|
|
996
|
-
children: /* @__PURE__ */ jsx6(
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1041
|
+
const { item, row } = useMenuRow(rowRef, false, { collapsible, open, defaultOpen, onOpenChange });
|
|
1042
|
+
const attach = useMergeRefs2(item.attachRow, ref);
|
|
1043
|
+
return /* @__PURE__ */ jsx6(MenuRowContext.Provider, {
|
|
1044
|
+
value: row,
|
|
1045
|
+
children: /* @__PURE__ */ jsx6(MenuItemContext.Provider, {
|
|
1046
|
+
value: item,
|
|
1047
|
+
children: /* @__PURE__ */ jsx6("li", {
|
|
1048
|
+
ref: attach,
|
|
1049
|
+
"data-sidebar": "menu-item",
|
|
1050
|
+
className: cn2("group/menu-item relative", className),
|
|
1051
|
+
...props,
|
|
1052
|
+
children
|
|
1053
|
+
})
|
|
1002
1054
|
})
|
|
1003
1055
|
});
|
|
1004
1056
|
});
|
|
1005
1057
|
SidebarMenuItem2.displayName = "SidebarMenuItem";
|
|
1006
1058
|
var SidebarMenuSubItem2 = forwardRef4(({ className, children, ...props }, ref) => {
|
|
1007
1059
|
const rowRef = useRef4(null);
|
|
1008
|
-
const item = useMenuRow(rowRef, true);
|
|
1009
|
-
const
|
|
1010
|
-
return /* @__PURE__ */ jsx6(
|
|
1011
|
-
value:
|
|
1012
|
-
children: /* @__PURE__ */ jsx6(
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1060
|
+
const { item, row } = useMenuRow(rowRef, true);
|
|
1061
|
+
const attach = useMergeRefs2(item.attachRow, ref);
|
|
1062
|
+
return /* @__PURE__ */ jsx6(MenuRowContext.Provider, {
|
|
1063
|
+
value: row,
|
|
1064
|
+
children: /* @__PURE__ */ jsx6(MenuItemContext.Provider, {
|
|
1065
|
+
value: item,
|
|
1066
|
+
children: /* @__PURE__ */ jsx6("li", {
|
|
1067
|
+
ref: attach,
|
|
1068
|
+
"data-sidebar": "menu-sub-item",
|
|
1069
|
+
className: cn2("group/menu-sub-item relative", className),
|
|
1070
|
+
...props,
|
|
1071
|
+
children
|
|
1072
|
+
})
|
|
1018
1073
|
})
|
|
1019
1074
|
});
|
|
1020
1075
|
});
|
|
@@ -1024,7 +1079,7 @@ SidebarMenuSubItem2.displayName = "SidebarMenuSubItem";
|
|
|
1024
1079
|
import { motion as motion4 } from "motion/react";
|
|
1025
1080
|
import {
|
|
1026
1081
|
forwardRef as forwardRef5,
|
|
1027
|
-
useContext as
|
|
1082
|
+
useContext as useContext7,
|
|
1028
1083
|
useRef as useRef5
|
|
1029
1084
|
} from "react";
|
|
1030
1085
|
import { jsx as jsx7, jsxs as jsxs7, Fragment as Fragment5 } from "react/jsx-runtime";
|
|
@@ -1035,9 +1090,9 @@ import { jsx as jsx7, jsxs as jsxs7, Fragment as Fragment5 } from "react/jsx-run
|
|
|
1035
1090
|
* Local changes: see PORTING.md.
|
|
1036
1091
|
*/
|
|
1037
1092
|
var SidebarMenuSub2 = forwardRef5(({ className, open: openProp, children, ...props }, ref) => {
|
|
1038
|
-
const row =
|
|
1093
|
+
const row = useContext7(MenuItemContext);
|
|
1039
1094
|
const open = openProp ?? row?.subOpen ?? true;
|
|
1040
|
-
const refreshVisibility =
|
|
1095
|
+
const refreshVisibility = useContext7(MenuScopeContext)?.refreshVisibility;
|
|
1041
1096
|
useIsoLayoutEffect2(() => {
|
|
1042
1097
|
refreshVisibility?.();
|
|
1043
1098
|
}, [open, refreshVisibility]);
|
|
@@ -1073,8 +1128,8 @@ var SidebarMenuSubButton2 = forwardRef5(({
|
|
|
1073
1128
|
children,
|
|
1074
1129
|
...props
|
|
1075
1130
|
}, ref) => {
|
|
1076
|
-
const item =
|
|
1077
|
-
const selection =
|
|
1131
|
+
const item = useContext7(MenuItemContext);
|
|
1132
|
+
const selection = useContext7(SidebarSelection2);
|
|
1078
1133
|
const isActive = isActiveProp || value !== undefined && selection?.value === value;
|
|
1079
1134
|
const shape = useShape2();
|
|
1080
1135
|
const sizeClasses = useSize2(size);
|
|
@@ -1089,7 +1144,8 @@ var SidebarMenuSubButton2 = forwardRef5(({
|
|
|
1089
1144
|
setButtonEl?.(buttonRef.current);
|
|
1090
1145
|
return () => setButtonEl?.(null);
|
|
1091
1146
|
}, [setButtonEl]);
|
|
1092
|
-
const
|
|
1147
|
+
const { isHovered } = useRowState(item?.rowRef);
|
|
1148
|
+
const lit = isActive || isHovered;
|
|
1093
1149
|
const { template, content } = resolveSlotTemplate2(render, asChild, children);
|
|
1094
1150
|
const asButton = !template && value !== undefined && props.href === undefined;
|
|
1095
1151
|
return slotElement2(template, asButton ? "button" : "a", {
|
|
@@ -35,7 +35,7 @@ import {
|
|
|
35
35
|
} from "./components-nwa2a9tq.js";
|
|
36
36
|
import {
|
|
37
37
|
Tooltip2
|
|
38
|
-
} from "./components-
|
|
38
|
+
} from "./components-7rn454aq.js";
|
|
39
39
|
|
|
40
40
|
// components/actions/copy/index.tsx
|
|
41
41
|
import { AnimatePresence, animate, motion, useMotionValue } from "motion/react";
|
|
@@ -17,7 +17,8 @@ import {
|
|
|
17
17
|
createContext,
|
|
18
18
|
useCallback,
|
|
19
19
|
useContext,
|
|
20
|
-
useMemo
|
|
20
|
+
useMemo,
|
|
21
|
+
useState
|
|
21
22
|
} from "react";
|
|
22
23
|
import { jsx } from "react/jsx-runtime";
|
|
23
24
|
var OverlayContext2 = createContext(null);
|
|
@@ -38,6 +39,12 @@ function useOverlay2(part) {
|
|
|
38
39
|
throw new Error(`${part} must be inside its overlay's root.`);
|
|
39
40
|
return state;
|
|
40
41
|
}
|
|
42
|
+
function useOpenedOnce2(open) {
|
|
43
|
+
const [opened, setOpened] = useState(open);
|
|
44
|
+
if (open && !opened)
|
|
45
|
+
setOpened(true);
|
|
46
|
+
return opened || open;
|
|
47
|
+
}
|
|
41
48
|
function positionerProps2({
|
|
42
49
|
side,
|
|
43
50
|
align,
|
|
@@ -71,4 +78,4 @@ function usePortalContainer2(container) {
|
|
|
71
78
|
const scoped = useContext(PortalContainerContext);
|
|
72
79
|
return container ?? scoped ?? undefined;
|
|
73
80
|
}
|
|
74
|
-
export { OverlayContext2, useOverlayRoot2, useOverlay2, positionerProps2, PortalContainer2, usePortalContainer2 };
|
|
81
|
+
export { OverlayContext2, useOverlayRoot2, useOverlay2, useOpenedOnce2, positionerProps2, PortalContainer2, usePortalContainer2 };
|