react-tiling-workspace 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +147 -2
- package/dist/components/LayoutPickerDialog-C-Sb3uOl.cjs +517 -0
- package/dist/components/LayoutPickerDialog-C-Sb3uOl.cjs.map +1 -0
- package/dist/components/LayoutPickerDialog-STglqYFI.mjs +500 -0
- package/dist/components/LayoutPickerDialog-STglqYFI.mjs.map +1 -0
- package/dist/components/icons-0kjsH_LJ.cjs +144 -0
- package/dist/components/icons-0kjsH_LJ.cjs.map +1 -0
- package/dist/components/icons-BgtEPXL8.mjs +97 -0
- package/dist/components/icons-BgtEPXL8.mjs.map +1 -0
- package/dist/components/layout-picker.cjs +5 -0
- package/dist/components/layout-picker.d.cts +22 -0
- package/dist/components/layout-picker.d.mts +22 -0
- package/dist/components/layout-picker.mjs +2 -0
- package/dist/components/mobile.cjs +575 -0
- package/dist/components/mobile.cjs.map +1 -0
- package/dist/components/mobile.d.cts +42 -0
- package/dist/components/mobile.d.mts +42 -0
- package/dist/components/mobile.mjs +574 -0
- package/dist/components/mobile.mjs.map +1 -0
- package/dist/components/topbar.cjs +94 -0
- package/dist/components/topbar.cjs.map +1 -0
- package/dist/components/topbar.d.cts +38 -0
- package/dist/components/topbar.d.mts +38 -0
- package/dist/components/topbar.mjs +93 -0
- package/dist/components/topbar.mjs.map +1 -0
- package/dist/components/types-DkwWFcD5.d.mts +32 -0
- package/dist/components/types-qsXC_48o.d.cts +32 -0
- package/dist/index.cjs +3336 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +243 -0
- package/dist/index.d.mts +243 -0
- package/dist/index.mjs +3320 -0
- package/dist/index.mjs.map +1 -0
- package/dist/server/server.cjs +104 -0
- package/dist/server/server.cjs.map +1 -0
- package/dist/server/server.d.cts +71 -0
- package/dist/server/server.d.mts +71 -0
- package/dist/server/server.mjs +95 -0
- package/dist/server/server.mjs.map +1 -0
- package/dist/server/shortcuts.cjs +32 -0
- package/dist/server/shortcuts.cjs.map +1 -0
- package/dist/server/shortcuts.d.cts +6 -0
- package/dist/server/shortcuts.d.mts +6 -0
- package/dist/server/shortcuts.mjs +31 -0
- package/dist/server/shortcuts.mjs.map +1 -0
- package/dist/theme.css +119 -0
- package/package.json +113 -4
|
@@ -0,0 +1,575 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
let react = require("react");
|
|
4
|
+
const require_icons = require("./icons-0kjsH_LJ.cjs");
|
|
5
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
6
|
+
// src/components/MobileBottomBar.tsx
|
|
7
|
+
const NAV_HEIGHT_PX = 64;
|
|
8
|
+
const NAV_BORDER_PX = 1;
|
|
9
|
+
const MAX_SLOTS = 5;
|
|
10
|
+
const KNOB_RADIUS_PX = 18;
|
|
11
|
+
const TAB_KNOB_START_PX = 9;
|
|
12
|
+
const FILLET_PX = 26;
|
|
13
|
+
const PANEL_GAP_PX = 10;
|
|
14
|
+
const PANEL_PAD_X_PX = 6;
|
|
15
|
+
const PANEL_PAD_Y_PX = 4;
|
|
16
|
+
const PANEL_EDGE_PX = 10;
|
|
17
|
+
const PANEL_CORNER_PX = 18;
|
|
18
|
+
const ITEM_WIDTH_PX = 76;
|
|
19
|
+
const ITEM_HEIGHT_PX = 48;
|
|
20
|
+
const ITEM_GAP_PX = 4;
|
|
21
|
+
const EASE_OUT = "ease-[cubic-bezier(0.22,1,0.36,1)]";
|
|
22
|
+
const clamp = (value, min, max) => Math.min(Math.max(value, min), Math.max(min, max));
|
|
23
|
+
const clamp01 = (value) => Math.min(1, Math.max(0, value));
|
|
24
|
+
const lerp = (a, b, t) => a + (b - a) * t;
|
|
25
|
+
const roundHalf = (value) => Math.round(value * 2) / 2;
|
|
26
|
+
const f = (value) => Math.round(value * 100) / 100;
|
|
27
|
+
/**
|
|
28
|
+
* One continuous outline: a rounded pill, two concave fillets, and a circular knob.
|
|
29
|
+
* `p` is the morph progress: at 0 the shape is only the knob, at 1 the pill has
|
|
30
|
+
* been pushed up out of it with the neck stretched between the two. It can go a
|
|
31
|
+
* touch past 1 (spring overshoot), which gives the liquid feel.
|
|
32
|
+
*/
|
|
33
|
+
function buildMorphPath(g, rawP) {
|
|
34
|
+
const p = Math.max(0, rawP);
|
|
35
|
+
const pw = Math.min(1, p * 1.08);
|
|
36
|
+
const { cx, ky, kr, pillH } = g;
|
|
37
|
+
const k = lerp(g.knobFrom, kr, clamp01(p * 4));
|
|
38
|
+
const knobL = cx - k;
|
|
39
|
+
const knobR = cx + k;
|
|
40
|
+
const L = lerp(knobL, g.left, pw);
|
|
41
|
+
const R = lerp(knobR, g.right, pw);
|
|
42
|
+
const T = ky * (1 - p);
|
|
43
|
+
const B = ky - (ky - pillH) * p;
|
|
44
|
+
const h = B - T;
|
|
45
|
+
const rt = Math.min(g.corner, h / 2, (R - L) / 2);
|
|
46
|
+
const K = .5523;
|
|
47
|
+
const reach = FILLET_PX * pw;
|
|
48
|
+
const edgeThreshold = rt + 6;
|
|
49
|
+
const rightRoom = R - knobR;
|
|
50
|
+
const mergeRight = rightRoom < edgeThreshold;
|
|
51
|
+
let rightSideCmds;
|
|
52
|
+
if (mergeRight) {
|
|
53
|
+
const joinY = Math.max(T + rt, B - (edgeThreshold - rightRoom) * .85 * pw);
|
|
54
|
+
const midY = (joinY + ky) / 2;
|
|
55
|
+
rightSideCmds = [`L ${f(R)} ${f(joinY)}`, `C ${f(R)} ${f(midY)} ${f(knobR)} ${f(midY)} ${f(knobR)} ${f(ky)}`];
|
|
56
|
+
} else {
|
|
57
|
+
const rbR = Math.min(rt, Math.max(rightRoom - 6, 4));
|
|
58
|
+
const filletR = Math.min(R - rbR, knobR + reach);
|
|
59
|
+
const neckY = ky - (ky - B) * K;
|
|
60
|
+
rightSideCmds = [
|
|
61
|
+
`L ${f(R)} ${f(B - rbR)}`,
|
|
62
|
+
`Q ${f(R)} ${f(B)} ${f(R - rbR)} ${f(B)}`,
|
|
63
|
+
`L ${f(filletR)} ${f(B)}`,
|
|
64
|
+
`C ${f(filletR + (knobR - filletR) * K)} ${f(B)} ${f(knobR)} ${f(neckY)} ${f(knobR)} ${f(ky)}`
|
|
65
|
+
];
|
|
66
|
+
}
|
|
67
|
+
const leftRoom = knobL - L;
|
|
68
|
+
const mergeLeft = leftRoom < edgeThreshold;
|
|
69
|
+
let leftSideCmds;
|
|
70
|
+
if (mergeLeft) {
|
|
71
|
+
const joinY = Math.max(T + rt, B - (edgeThreshold - leftRoom) * .85 * pw);
|
|
72
|
+
const midY = (joinY + ky) / 2;
|
|
73
|
+
leftSideCmds = [`C ${f(knobL)} ${f(midY)} ${f(L)} ${f(midY)} ${f(L)} ${f(joinY)}`];
|
|
74
|
+
} else {
|
|
75
|
+
const rbL = Math.min(rt, Math.max(leftRoom - 6, 4));
|
|
76
|
+
const filletL = Math.max(L + rbL, knobL - reach);
|
|
77
|
+
const neckY = ky - (ky - B) * K;
|
|
78
|
+
leftSideCmds = [
|
|
79
|
+
`C ${f(knobL)} ${f(neckY)} ${f(filletL + (knobL - filletL) * K)} ${f(B)} ${f(filletL)} ${f(B)}`,
|
|
80
|
+
`L ${f(L + rbL)} ${f(B)}`,
|
|
81
|
+
`Q ${f(L)} ${f(B)} ${f(L)} ${f(B - rbL)}`
|
|
82
|
+
];
|
|
83
|
+
}
|
|
84
|
+
return [
|
|
85
|
+
`M ${f(L + rt)} ${f(T)}`,
|
|
86
|
+
`L ${f(R - rt)} ${f(T)}`,
|
|
87
|
+
`Q ${f(R)} ${f(T)} ${f(R)} ${f(T + rt)}`,
|
|
88
|
+
...rightSideCmds,
|
|
89
|
+
`A ${f(k)} ${f(k)} 0 1 1 ${f(knobL)} ${f(ky)}`,
|
|
90
|
+
...leftSideCmds,
|
|
91
|
+
`L ${f(L)} ${f(T + rt)}`,
|
|
92
|
+
`Q ${f(L)} ${f(T)} ${f(L + rt)} ${f(T)}`,
|
|
93
|
+
"Z"
|
|
94
|
+
].join(" ");
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Mobile bottom navigation.
|
|
98
|
+
*
|
|
99
|
+
* - A soft pill glides behind the active tab.
|
|
100
|
+
* - A submenu pops out of whichever slot opens it: the trigger becomes a circular
|
|
101
|
+
* knob, and the submenu is one fluid shape fused to it with smooth concave
|
|
102
|
+
* curves, in the same colour. The shape is morphed on a spring, so it truly
|
|
103
|
+
* stretches up out of the button instead of just scaling in.
|
|
104
|
+
* - `action` slots get a quiet filled well, `accent` is a circular accent button.
|
|
105
|
+
* Everything stays inside the bar.
|
|
106
|
+
* - Colours come from `--rtw-*` CSS variables so the host theme stays in control.
|
|
107
|
+
*/
|
|
108
|
+
function MobileBottomBar({ items, activeId, onSelect, ariaLabel = "Mobile navigation", zIndexClassName = "z-30" }) {
|
|
109
|
+
const navRef = (0, react.useRef)(null);
|
|
110
|
+
const panelRef = (0, react.useRef)(null);
|
|
111
|
+
const pathRef = (0, react.useRef)(null);
|
|
112
|
+
const triggerRef = (0, react.useRef)(null);
|
|
113
|
+
const geometryRef = (0, react.useRef)(null);
|
|
114
|
+
const lastDrawnGeometryRef = (0, react.useRef)(null);
|
|
115
|
+
const switchTweenRef = (0, react.useRef)(null);
|
|
116
|
+
const phaseRef = (0, react.useRef)("closed");
|
|
117
|
+
const menuIdRef = (0, react.useRef)(null);
|
|
118
|
+
const pendingRef = (0, react.useRef)(null);
|
|
119
|
+
const openedByKeyboardRef = (0, react.useRef)(false);
|
|
120
|
+
const progressRef = (0, react.useRef)(0);
|
|
121
|
+
const velocityRef = (0, react.useRef)(0);
|
|
122
|
+
const targetRef = (0, react.useRef)(0);
|
|
123
|
+
const rafRef = (0, react.useRef)(null);
|
|
124
|
+
const lastFrameRef = (0, react.useRef)(0);
|
|
125
|
+
const finishCloseRef = (0, react.useRef)(() => {});
|
|
126
|
+
const closeMenuRef = (0, react.useRef)(() => {});
|
|
127
|
+
const submenuId = (0, react.useId)();
|
|
128
|
+
const [mountedMenuId, setMountedMenuId] = (0, react.useState)(null);
|
|
129
|
+
const [isOpen, setIsOpen] = (0, react.useState)(false);
|
|
130
|
+
const [navWidth, setNavWidth] = (0, react.useState)(375);
|
|
131
|
+
const [anchor, setAnchor] = (0, react.useState)({
|
|
132
|
+
x: 187,
|
|
133
|
+
y: 25
|
|
134
|
+
});
|
|
135
|
+
const [pill, setPill] = (0, react.useState)({
|
|
136
|
+
x: 0,
|
|
137
|
+
width: 0,
|
|
138
|
+
visible: false,
|
|
139
|
+
instant: true
|
|
140
|
+
});
|
|
141
|
+
const accentItem = items.find((item) => item.variant === "accent") ?? null;
|
|
142
|
+
const otherItems = items.filter((item) => item.variant !== "accent");
|
|
143
|
+
const maxOthers = accentItem ? 4 : MAX_SLOTS;
|
|
144
|
+
const needsOverflow = otherItems.length > maxOthers;
|
|
145
|
+
const visibleItems = needsOverflow ? otherItems.slice(0, maxOthers - 1) : otherItems;
|
|
146
|
+
const overflowItems = needsOverflow ? otherItems.slice(maxOthers - 1) : [];
|
|
147
|
+
const moreItem = needsOverflow ? {
|
|
148
|
+
id: "__overflow__",
|
|
149
|
+
label: "More",
|
|
150
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_icons.MenuIcon, {}),
|
|
151
|
+
variant: "submenu",
|
|
152
|
+
active: overflowItems.some((item) => activeId === item.id || item.active),
|
|
153
|
+
subItems: overflowItems.map((item) => ({
|
|
154
|
+
id: item.id,
|
|
155
|
+
label: item.label,
|
|
156
|
+
icon: item.icon,
|
|
157
|
+
active: activeId === item.id || Boolean(item.active),
|
|
158
|
+
onSelect: () => {
|
|
159
|
+
if (item.onClick) item.onClick();
|
|
160
|
+
else onSelect?.(item.id);
|
|
161
|
+
}
|
|
162
|
+
}))
|
|
163
|
+
} : null;
|
|
164
|
+
const row = moreItem ? [...visibleItems, moreItem] : visibleItems;
|
|
165
|
+
const centerIndex = Math.ceil(row.length / 2);
|
|
166
|
+
const slots = accentItem ? [
|
|
167
|
+
...row.slice(0, centerIndex),
|
|
168
|
+
accentItem,
|
|
169
|
+
...row.slice(centerIndex)
|
|
170
|
+
] : row;
|
|
171
|
+
const menuItem = slots.find((item) => item.id === mountedMenuId) ?? null;
|
|
172
|
+
const subItems = menuItem?.subItems ?? [];
|
|
173
|
+
const openMenuId = isOpen ? mountedMenuId : null;
|
|
174
|
+
let geometry = null;
|
|
175
|
+
let panel = {
|
|
176
|
+
left: 0,
|
|
177
|
+
width: 0,
|
|
178
|
+
top: 0,
|
|
179
|
+
height: 0,
|
|
180
|
+
svgHeight: 0
|
|
181
|
+
};
|
|
182
|
+
if (menuItem && subItems.length > 0) {
|
|
183
|
+
const cols = Math.min(4, subItems.length);
|
|
184
|
+
const rows = Math.ceil(subItems.length / cols);
|
|
185
|
+
const pillH = rows * ITEM_HEIGHT_PX + (rows - 1) * ITEM_GAP_PX + 8;
|
|
186
|
+
const layoutCols = Math.max(cols, 2);
|
|
187
|
+
const idealWidth = layoutCols * ITEM_WIDTH_PX + (layoutCols - 1) * ITEM_GAP_PX + 12;
|
|
188
|
+
const width = Math.min(idealWidth, navWidth - 20);
|
|
189
|
+
const left = clamp(anchor.x - width / 2, PANEL_EDGE_PX, navWidth - width - PANEL_EDGE_PX);
|
|
190
|
+
const ky = pillH + PANEL_GAP_PX + anchor.y;
|
|
191
|
+
geometry = {
|
|
192
|
+
cx: anchor.x,
|
|
193
|
+
ky,
|
|
194
|
+
kr: KNOB_RADIUS_PX,
|
|
195
|
+
knobFrom: menuItem.variant === "accent" ? KNOB_RADIUS_PX : TAB_KNOB_START_PX,
|
|
196
|
+
left: Math.min(left, anchor.x - KNOB_RADIUS_PX),
|
|
197
|
+
right: Math.max(left + width, anchor.x + KNOB_RADIUS_PX),
|
|
198
|
+
pillH,
|
|
199
|
+
corner: PANEL_CORNER_PX
|
|
200
|
+
};
|
|
201
|
+
panel = {
|
|
202
|
+
left,
|
|
203
|
+
width,
|
|
204
|
+
top: anchor.y - NAV_BORDER_PX - ky,
|
|
205
|
+
height: pillH,
|
|
206
|
+
svgHeight: ky + KNOB_RADIUS_PX + 2
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
const gridCols = Math.min(4, Math.max(1, subItems.length));
|
|
210
|
+
const prefersReducedMotion = (0, react.useCallback)(() => typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, []);
|
|
211
|
+
const draw = (0, react.useCallback)((progress, now = performance.now()) => {
|
|
212
|
+
const path = pathRef.current;
|
|
213
|
+
const targetG = geometryRef.current;
|
|
214
|
+
if (!path || !targetG) return;
|
|
215
|
+
let g = targetG;
|
|
216
|
+
const tween = switchTweenRef.current;
|
|
217
|
+
if (tween) {
|
|
218
|
+
const rawT = clamp01((now - tween.startTime) / tween.duration);
|
|
219
|
+
const t = 1 - Math.pow(1 - rawT, 3);
|
|
220
|
+
g = {
|
|
221
|
+
cx: lerp(tween.from.cx, targetG.cx, t),
|
|
222
|
+
ky: lerp(tween.from.ky, targetG.ky, t),
|
|
223
|
+
kr: lerp(tween.from.kr, targetG.kr, t),
|
|
224
|
+
knobFrom: lerp(tween.from.knobFrom, targetG.knobFrom, t),
|
|
225
|
+
left: lerp(tween.from.left, targetG.left, t),
|
|
226
|
+
right: lerp(tween.from.right, targetG.right, t),
|
|
227
|
+
pillH: lerp(tween.from.pillH, targetG.pillH, t),
|
|
228
|
+
corner: lerp(tween.from.corner, targetG.corner, t)
|
|
229
|
+
};
|
|
230
|
+
if (rawT >= 1) switchTweenRef.current = null;
|
|
231
|
+
}
|
|
232
|
+
lastDrawnGeometryRef.current = g;
|
|
233
|
+
path.setAttribute("d", buildMorphPath(g, progress));
|
|
234
|
+
}, []);
|
|
235
|
+
const tick = (0, react.useCallback)((now) => {
|
|
236
|
+
const dt = clamp((now - lastFrameRef.current) / 1e3, .001, .032);
|
|
237
|
+
lastFrameRef.current = now;
|
|
238
|
+
const target = targetRef.current;
|
|
239
|
+
const opening = target === 1;
|
|
240
|
+
const stiffness = opening ? 340 : 880;
|
|
241
|
+
const damping = opening ? 26 : 58;
|
|
242
|
+
let p = progressRef.current;
|
|
243
|
+
let v = velocityRef.current;
|
|
244
|
+
const h = dt / 2;
|
|
245
|
+
for (let i = 0; i < 2; i += 1) {
|
|
246
|
+
v += (stiffness * (target - p) - damping * v) * h;
|
|
247
|
+
p += v * h;
|
|
248
|
+
}
|
|
249
|
+
if (!opening && p < 0) {
|
|
250
|
+
p = 0;
|
|
251
|
+
v = 0;
|
|
252
|
+
}
|
|
253
|
+
progressRef.current = p;
|
|
254
|
+
velocityRef.current = v;
|
|
255
|
+
draw(p, now);
|
|
256
|
+
if (Math.abs(target - p) < .001 && Math.abs(v) < .02 && switchTweenRef.current === null) {
|
|
257
|
+
progressRef.current = target;
|
|
258
|
+
velocityRef.current = 0;
|
|
259
|
+
draw(target, now);
|
|
260
|
+
rafRef.current = null;
|
|
261
|
+
if (target === 0) finishCloseRef.current();
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
rafRef.current = window.requestAnimationFrame(tick);
|
|
265
|
+
}, [draw]);
|
|
266
|
+
const animateTo = (0, react.useCallback)((target) => {
|
|
267
|
+
targetRef.current = target;
|
|
268
|
+
if (prefersReducedMotion()) {
|
|
269
|
+
if (rafRef.current !== null) window.cancelAnimationFrame(rafRef.current);
|
|
270
|
+
rafRef.current = null;
|
|
271
|
+
progressRef.current = target;
|
|
272
|
+
velocityRef.current = 0;
|
|
273
|
+
draw(target);
|
|
274
|
+
if (target === 0) finishCloseRef.current();
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
if (rafRef.current === null) {
|
|
278
|
+
lastFrameRef.current = performance.now();
|
|
279
|
+
rafRef.current = window.requestAnimationFrame(tick);
|
|
280
|
+
}
|
|
281
|
+
}, [
|
|
282
|
+
draw,
|
|
283
|
+
prefersReducedMotion,
|
|
284
|
+
tick
|
|
285
|
+
]);
|
|
286
|
+
(0, react.useEffect)(() => () => {
|
|
287
|
+
if (rafRef.current !== null) window.cancelAnimationFrame(rafRef.current);
|
|
288
|
+
}, []);
|
|
289
|
+
const measure = (0, react.useCallback)(() => {
|
|
290
|
+
const nav = navRef.current;
|
|
291
|
+
if (!nav) return;
|
|
292
|
+
const navRect = nav.getBoundingClientRect();
|
|
293
|
+
setNavWidth((prev) => prev === navRect.width ? prev : navRect.width);
|
|
294
|
+
const trigger = triggerRef.current;
|
|
295
|
+
if (trigger?.isConnected && nav.contains(trigger)) {
|
|
296
|
+
const rect = (trigger.querySelector("[data-anchor]") ?? trigger).getBoundingClientRect();
|
|
297
|
+
const x = roundHalf(rect.left - navRect.left + rect.width / 2);
|
|
298
|
+
const y = roundHalf(rect.top - navRect.top + rect.height / 2);
|
|
299
|
+
setAnchor((prev) => prev.x === x && prev.y === y ? prev : {
|
|
300
|
+
x,
|
|
301
|
+
y
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
const pillTarget = nav.querySelector("[data-pill-target=\"true\"]");
|
|
305
|
+
if (pillTarget) {
|
|
306
|
+
const rect = pillTarget.getBoundingClientRect();
|
|
307
|
+
const x = roundHalf(rect.left - navRect.left);
|
|
308
|
+
const width = roundHalf(rect.width);
|
|
309
|
+
setPill((prev) => {
|
|
310
|
+
const next = {
|
|
311
|
+
x,
|
|
312
|
+
width,
|
|
313
|
+
visible: true,
|
|
314
|
+
instant: !prev.visible
|
|
315
|
+
};
|
|
316
|
+
return prev.x === next.x && prev.width === next.width && prev.visible === next.visible && prev.instant === next.instant ? prev : next;
|
|
317
|
+
});
|
|
318
|
+
} else setPill((prev) => prev.visible ? {
|
|
319
|
+
...prev,
|
|
320
|
+
visible: false,
|
|
321
|
+
instant: false
|
|
322
|
+
} : prev);
|
|
323
|
+
}, []);
|
|
324
|
+
(0, react.useLayoutEffect)(() => {
|
|
325
|
+
measure();
|
|
326
|
+
geometryRef.current = geometry;
|
|
327
|
+
if (geometry) draw(progressRef.current);
|
|
328
|
+
});
|
|
329
|
+
(0, react.useLayoutEffect)(() => {
|
|
330
|
+
const nav = navRef.current;
|
|
331
|
+
if (!nav) return;
|
|
332
|
+
window.addEventListener("resize", measure);
|
|
333
|
+
window.addEventListener("orientationchange", measure);
|
|
334
|
+
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(measure);
|
|
335
|
+
observer?.observe(nav);
|
|
336
|
+
return () => {
|
|
337
|
+
window.removeEventListener("resize", measure);
|
|
338
|
+
window.removeEventListener("orientationchange", measure);
|
|
339
|
+
observer?.disconnect();
|
|
340
|
+
};
|
|
341
|
+
}, [measure]);
|
|
342
|
+
function openMenu(id, trigger, viaKeyboard) {
|
|
343
|
+
const isSwitching = phaseRef.current !== "closed" && menuIdRef.current !== id;
|
|
344
|
+
if (isSwitching && !prefersReducedMotion() && lastDrawnGeometryRef.current) switchTweenRef.current = {
|
|
345
|
+
from: lastDrawnGeometryRef.current,
|
|
346
|
+
startTime: performance.now(),
|
|
347
|
+
duration: 220
|
|
348
|
+
};
|
|
349
|
+
else if (!isSwitching) switchTweenRef.current = null;
|
|
350
|
+
pendingRef.current = null;
|
|
351
|
+
openedByKeyboardRef.current = viaKeyboard;
|
|
352
|
+
triggerRef.current = trigger;
|
|
353
|
+
measure();
|
|
354
|
+
if (phaseRef.current === "closed") {
|
|
355
|
+
progressRef.current = 0;
|
|
356
|
+
velocityRef.current = 0;
|
|
357
|
+
}
|
|
358
|
+
phaseRef.current = "open";
|
|
359
|
+
menuIdRef.current = id;
|
|
360
|
+
setMountedMenuId(id);
|
|
361
|
+
setIsOpen(true);
|
|
362
|
+
animateTo(1);
|
|
363
|
+
}
|
|
364
|
+
function closeMenu(restoreFocus = false) {
|
|
365
|
+
if (phaseRef.current === "closed") return;
|
|
366
|
+
const trigger = triggerRef.current;
|
|
367
|
+
if (restoreFocus && trigger?.isConnected) trigger.focus({ preventScroll: true });
|
|
368
|
+
else if (panelRef.current?.contains(document.activeElement)) document.activeElement.blur();
|
|
369
|
+
if (phaseRef.current === "closing") return;
|
|
370
|
+
phaseRef.current = "closing";
|
|
371
|
+
setIsOpen(false);
|
|
372
|
+
animateTo(0);
|
|
373
|
+
}
|
|
374
|
+
function finishClose() {
|
|
375
|
+
phaseRef.current = "closed";
|
|
376
|
+
menuIdRef.current = null;
|
|
377
|
+
triggerRef.current = null;
|
|
378
|
+
setMountedMenuId(null);
|
|
379
|
+
const pending = pendingRef.current;
|
|
380
|
+
if (pending && pending.trigger.isConnected) {
|
|
381
|
+
pendingRef.current = null;
|
|
382
|
+
openMenu(pending.id, pending.trigger, pending.viaKeyboard);
|
|
383
|
+
}
|
|
384
|
+
pendingRef.current = null;
|
|
385
|
+
}
|
|
386
|
+
finishCloseRef.current = finishClose;
|
|
387
|
+
closeMenuRef.current = closeMenu;
|
|
388
|
+
(0, react.useEffect)(() => {
|
|
389
|
+
if (!mountedMenuId) return;
|
|
390
|
+
function onKeyDown(event) {
|
|
391
|
+
if (event.key === "Escape") {
|
|
392
|
+
event.preventDefault();
|
|
393
|
+
closeMenuRef.current(true);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
window.addEventListener("keydown", onKeyDown);
|
|
397
|
+
return () => window.removeEventListener("keydown", onKeyDown);
|
|
398
|
+
}, [mountedMenuId]);
|
|
399
|
+
(0, react.useEffect)(() => {
|
|
400
|
+
if (!isOpen || !openedByKeyboardRef.current) return;
|
|
401
|
+
openedByKeyboardRef.current = false;
|
|
402
|
+
panelRef.current?.querySelector("[role=\"menuitem\"]")?.focus({ preventScroll: true });
|
|
403
|
+
}, [isOpen, mountedMenuId]);
|
|
404
|
+
function handleSlotClick(item, event) {
|
|
405
|
+
if (item.subItems && item.subItems.length > 0) {
|
|
406
|
+
if (mountedMenuId === item.id && phaseRef.current === "open") closeMenu();
|
|
407
|
+
else openMenu(item.id, event.currentTarget, event.detail === 0);
|
|
408
|
+
return;
|
|
409
|
+
}
|
|
410
|
+
if (mountedMenuId) closeMenu();
|
|
411
|
+
if (item.onClick) item.onClick();
|
|
412
|
+
else onSelect?.(item.id);
|
|
413
|
+
}
|
|
414
|
+
function handleMenuKeyDown(event) {
|
|
415
|
+
if (event.key === "Tab") {
|
|
416
|
+
closeMenu();
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
const entries = Array.from(event.currentTarget.querySelectorAll("[role=\"menuitem\"]"));
|
|
420
|
+
const current = entries.indexOf(document.activeElement);
|
|
421
|
+
let next = -1;
|
|
422
|
+
if (event.key === "ArrowRight") next = (current + 1) % entries.length;
|
|
423
|
+
else if (event.key === "ArrowLeft") next = (current - 1 + entries.length) % entries.length;
|
|
424
|
+
else if (event.key === "Home") next = 0;
|
|
425
|
+
else if (event.key === "End") next = entries.length - 1;
|
|
426
|
+
if (next >= 0) {
|
|
427
|
+
event.preventDefault();
|
|
428
|
+
entries[next]?.focus();
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
function renderSlot(item) {
|
|
432
|
+
const hasSubmenu = Boolean(item.subItems && item.subItems.length > 0);
|
|
433
|
+
const isAccent = item.variant === "accent";
|
|
434
|
+
const isAction = item.variant === "action";
|
|
435
|
+
const isMenuMounted = mountedMenuId === item.id;
|
|
436
|
+
const isMenuOpen = openMenuId === item.id;
|
|
437
|
+
const isTabActive = !isAction && !isAccent && (activeId === item.id || Boolean(item.active));
|
|
438
|
+
const isPillTarget = isTabActive && !isMenuOpen;
|
|
439
|
+
const wellShape = isAccent ? "-my-1 size-9" : "h-7 w-12";
|
|
440
|
+
const wellTone = isAccent ? "bg-[var(--rtw-accent,#6366f1)] text-[var(--rtw-accent-foreground,#ffffff)]" : isMenuOpen ? "text-[var(--rtw-accent-foreground,#ffffff)]" : isAction ? "bg-[var(--rtw-surface-subtle,#edf1f7)] text-[var(--rtw-text-strong,#0f172a)] group-hover/slot:bg-[var(--rtw-border,#dfe5ef)]" : isTabActive ? "text-[var(--rtw-accent,#6366f1)]" : "text-[var(--rtw-text-subtle,#64748b)] group-hover/slot:text-[var(--rtw-text-strong,#0f172a)]";
|
|
441
|
+
const labelTone = isAccent || isMenuOpen || isTabActive ? "text-[var(--rtw-accent,#6366f1)]" : isAction ? "text-[var(--rtw-text-strong,#0f172a)]" : "text-[var(--rtw-text-subtle,#64748b)] group-hover/slot:text-[var(--rtw-text-strong,#0f172a)]";
|
|
442
|
+
const glyphMotion = `transition-[transform,opacity] duration-[280ms] ${EASE_OUT} motion-reduce:transition-none`;
|
|
443
|
+
let glyph;
|
|
444
|
+
if (item.loading) glyph = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_icons.LoaderIcon, { className: "size-5 animate-spin" });
|
|
445
|
+
else if (isAccent) glyph = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
446
|
+
"aria-hidden": "true",
|
|
447
|
+
style: { transform: isMenuOpen ? "rotate(135deg)" : "rotate(0deg)" },
|
|
448
|
+
className: `flex size-[22px] items-center justify-center transition-transform duration-[260ms] ${EASE_OUT} motion-reduce:!transition-none [&>svg]:size-[22px]`,
|
|
449
|
+
children: item.icon
|
|
450
|
+
});
|
|
451
|
+
else if (hasSubmenu) glyph = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
452
|
+
className: "relative flex size-5 items-center justify-center",
|
|
453
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
454
|
+
"aria-hidden": "true",
|
|
455
|
+
className: `absolute inset-0 flex items-center justify-center [&>svg]:size-5 ${glyphMotion} ${isMenuOpen ? "scale-50 -rotate-90 opacity-0" : "scale-100 rotate-0 opacity-100"}`,
|
|
456
|
+
children: item.icon
|
|
457
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_icons.CloseIcon, {
|
|
458
|
+
"aria-hidden": "true",
|
|
459
|
+
className: `absolute size-[19px] ${glyphMotion} ${isMenuOpen ? "scale-100 rotate-0 opacity-100" : "scale-50 rotate-90 opacity-0"}`
|
|
460
|
+
})]
|
|
461
|
+
});
|
|
462
|
+
else glyph = /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
463
|
+
"aria-hidden": "true",
|
|
464
|
+
className: "flex size-5 items-center justify-center [&>svg]:size-5",
|
|
465
|
+
children: item.icon
|
|
466
|
+
});
|
|
467
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
468
|
+
type: "button",
|
|
469
|
+
"data-pill-target": isPillTarget ? "true" : void 0,
|
|
470
|
+
onClick: (event) => handleSlotClick(item, event),
|
|
471
|
+
"aria-haspopup": hasSubmenu ? "menu" : void 0,
|
|
472
|
+
"aria-controls": hasSubmenu && isMenuMounted ? submenuId : void 0,
|
|
473
|
+
"aria-expanded": hasSubmenu ? isMenuOpen : void 0,
|
|
474
|
+
"aria-current": isTabActive ? "page" : void 0,
|
|
475
|
+
className: "group/slot relative flex min-w-0 flex-1 cursor-pointer select-none flex-col items-center gap-[5px] pt-2.5 outline-none [-webkit-tap-highlight-color:transparent]",
|
|
476
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
477
|
+
"data-anchor": "true",
|
|
478
|
+
className: `relative flex items-center justify-center rounded-full transition-[background-color,color] duration-200 group-focus-visible/slot:ring-2 group-focus-visible/slot:ring-[var(--rtw-accent,#6366f1)]/60 motion-reduce:transition-none ${wellShape} ${wellTone}`,
|
|
479
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
480
|
+
className: "flex items-center justify-center transition-transform duration-150 group-active/slot:scale-90 motion-reduce:transition-none",
|
|
481
|
+
children: glyph
|
|
482
|
+
}), item.badge !== void 0 && item.badge !== 0 && !isMenuOpen && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
483
|
+
className: "absolute left-1/2 top-0 ml-1 min-w-4 -translate-y-0.5 rounded-full bg-[var(--rtw-accent,#6366f1)] px-1 text-center text-[9px] font-semibold leading-4 text-[var(--rtw-accent-foreground,#ffffff)]",
|
|
484
|
+
children: item.badge
|
|
485
|
+
})]
|
|
486
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
487
|
+
className: `max-w-full truncate text-[10px] font-medium leading-[10px] transition-colors duration-200 motion-reduce:transition-none ${labelTone}`,
|
|
488
|
+
children: item.renderLabel ? item.renderLabel() : item.label
|
|
489
|
+
})]
|
|
490
|
+
}, item.id);
|
|
491
|
+
}
|
|
492
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [mountedMenuId && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
493
|
+
"aria-hidden": "true",
|
|
494
|
+
onClick: () => closeMenu(),
|
|
495
|
+
className: `fixed inset-0 bg-[var(--rtw-scrim,rgba(15,23,42,0.18))] transition-opacity motion-reduce:transition-none lg:hidden ${zIndexClassName} ${isOpen ? "pointer-events-auto duration-200 opacity-100" : "pointer-events-none duration-120 opacity-0"}`
|
|
496
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("nav", {
|
|
497
|
+
ref: navRef,
|
|
498
|
+
"aria-label": ariaLabel,
|
|
499
|
+
style: { height: `calc(${NAV_HEIGHT_PX}px + env(safe-area-inset-bottom))` },
|
|
500
|
+
className: `fixed inset-x-0 bottom-0 flex items-stretch border-t border-[var(--rtw-border,#dfe5ef)] bg-[var(--rtw-surface,#ffffff)]/90 pb-[env(safe-area-inset-bottom)] backdrop-blur-xl lg:hidden ${zIndexClassName}`,
|
|
501
|
+
children: [
|
|
502
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
503
|
+
"aria-hidden": "true",
|
|
504
|
+
style: {
|
|
505
|
+
transform: `translateX(${pill.x}px)`,
|
|
506
|
+
opacity: pill.visible ? 1 : 0,
|
|
507
|
+
top: 0,
|
|
508
|
+
width: pill.width
|
|
509
|
+
},
|
|
510
|
+
className: `pointer-events-none absolute left-0 z-10 h-[2.5px] rounded-b-full bg-[var(--rtw-accent,#6366f1)] motion-reduce:transition-none ${pill.instant ? "transition-opacity duration-200" : `transition-[transform,width,opacity] duration-[320ms] ${EASE_OUT}`}`
|
|
511
|
+
}),
|
|
512
|
+
geometry && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
513
|
+
"aria-hidden": "true",
|
|
514
|
+
width: navWidth,
|
|
515
|
+
height: panel.svgHeight,
|
|
516
|
+
viewBox: `0 0 ${navWidth} ${panel.svgHeight}`,
|
|
517
|
+
style: { top: panel.top },
|
|
518
|
+
className: "pointer-events-none absolute left-0 z-[1] overflow-visible drop-shadow-[0_8px_20px_rgba(15,23,42,0.2)]",
|
|
519
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
520
|
+
ref: pathRef,
|
|
521
|
+
fill: "var(--rtw-accent, #6366f1)"
|
|
522
|
+
})
|
|
523
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
524
|
+
id: submenuId,
|
|
525
|
+
ref: panelRef,
|
|
526
|
+
role: "menu",
|
|
527
|
+
"aria-label": `${menuItem?.label ?? ""} options`,
|
|
528
|
+
"aria-hidden": !isOpen,
|
|
529
|
+
onKeyDown: handleMenuKeyDown,
|
|
530
|
+
style: {
|
|
531
|
+
top: panel.top,
|
|
532
|
+
left: panel.left,
|
|
533
|
+
width: panel.width,
|
|
534
|
+
height: panel.height,
|
|
535
|
+
padding: `${PANEL_PAD_Y_PX}px ${PANEL_PAD_X_PX}px`,
|
|
536
|
+
gap: ITEM_GAP_PX,
|
|
537
|
+
gridTemplateColumns: `repeat(${gridCols}, minmax(0, 1fr))`
|
|
538
|
+
},
|
|
539
|
+
className: `absolute z-20 grid items-center transition-[left,width,top,height] duration-[220ms] ${EASE_OUT} motion-reduce:transition-none ${isOpen ? "pointer-events-auto" : "pointer-events-none"}`,
|
|
540
|
+
children: subItems.map((sub, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
541
|
+
type: "button",
|
|
542
|
+
role: "menuitem",
|
|
543
|
+
tabIndex: isOpen ? 0 : -1,
|
|
544
|
+
onClick: () => {
|
|
545
|
+
closeMenu(true);
|
|
546
|
+
sub.onSelect();
|
|
547
|
+
},
|
|
548
|
+
className: `flex h-12 min-w-0 cursor-pointer items-center justify-center rounded-2xl px-1 text-[var(--rtw-accent-foreground,#ffffff)] outline-none transition-[background-color,transform] duration-150 [-webkit-tap-highlight-color:transparent] active:scale-95 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--rtw-accent-foreground,#ffffff)]/70 motion-reduce:transition-none ${sub.active ? "bg-[var(--rtw-accent-foreground,#ffffff)]/18" : "hover:bg-[var(--rtw-accent-foreground,#ffffff)]/10"}`,
|
|
549
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
550
|
+
style: {
|
|
551
|
+
transitionDelay: isOpen ? `${65 + index * 22}ms` : "0ms",
|
|
552
|
+
transitionDuration: isOpen ? "200ms" : "50ms"
|
|
553
|
+
},
|
|
554
|
+
className: `flex min-w-0 flex-col items-center gap-1 transition-[opacity,transform] ${EASE_OUT} motion-reduce:transition-none ${isOpen ? "translate-y-0 opacity-100" : "translate-y-2 opacity-0"}`,
|
|
555
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
556
|
+
"aria-hidden": "true",
|
|
557
|
+
className: "flex size-5 items-center justify-center [&>svg]:size-5",
|
|
558
|
+
children: sub.icon
|
|
559
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
560
|
+
className: "max-w-full truncate text-[10px] font-medium leading-[10px]",
|
|
561
|
+
children: sub.label
|
|
562
|
+
})]
|
|
563
|
+
})
|
|
564
|
+
}, sub.id))
|
|
565
|
+
})] }),
|
|
566
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
567
|
+
className: "relative z-10 flex min-w-0 flex-1 items-stretch",
|
|
568
|
+
children: slots.map(renderSlot)
|
|
569
|
+
})
|
|
570
|
+
]
|
|
571
|
+
})] });
|
|
572
|
+
}
|
|
573
|
+
exports.MobileBottomBar = MobileBottomBar;
|
|
574
|
+
|
|
575
|
+
//# sourceMappingURL=mobile.cjs.map
|