basalt-ui 2.11.0 → 2.12.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/AGENTS.md +1 -1
- package/CHANGELOG.md +26 -0
- package/MIGRATING.md +33 -12
- package/README.md +2 -0
- package/agent/rules/basalt-mantine.md +1 -1
- package/agent/skills/basalt-app/SKILL.md +1 -1
- package/agent/skills/basalt-charts/SKILL.md +1 -1
- package/dist/charts/DualPanel.d.ts.map +1 -1
- package/dist/charts/DualPanel.js +1 -0
- package/dist/charts/Lines.d.ts.map +1 -1
- package/dist/charts/Lines.js +7 -45
- package/dist/charts/MirroredBars.js +2 -2
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +21 -5
- package/dist/charts/labels.d.ts +34 -0
- package/dist/charts/labels.d.ts.map +1 -0
- package/dist/charts/labels.js +63 -0
- package/dist/charts/marks.d.ts +7 -0
- package/dist/charts/marks.d.ts.map +1 -1
- package/dist/charts/marks.js +22 -0
- package/dist/charts/scales.d.ts +4 -1
- package/dist/charts/scales.d.ts.map +1 -1
- package/dist/charts/scales.js +5 -3
- package/dist/charts/ticks.d.ts +12 -0
- package/dist/charts/ticks.d.ts.map +1 -0
- package/dist/charts/ticks.js +42 -0
- package/dist/charts/types.d.ts +11 -3
- package/dist/charts/types.d.ts.map +1 -1
- package/dist/cli/doctor-upgrade.d.ts +2 -3
- package/dist/cli/doctor-upgrade.d.ts.map +1 -1
- package/dist/cli/doctor-upgrade.js +71 -26
- package/dist/cli/index.d.ts +3 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +3 -1
- package/dist/cli/sync.d.ts.map +1 -1
- package/dist/cli/sync.js +2 -1
- package/dist/commands/command-stash.d.ts +15 -0
- package/dist/commands/command-stash.d.ts.map +1 -0
- package/dist/commands/command-stash.js +31 -0
- package/dist/commands/define-commands.d.ts +2 -3
- package/dist/commands/define-commands.d.ts.map +1 -1
- package/dist/commands/define-commands.js +9 -7
- package/dist/commands/define-overlays.d.ts +6 -12
- package/dist/commands/define-overlays.d.ts.map +1 -1
- package/dist/commands/define-overlays.js +28 -34
- package/dist/commands/projectors.js +1 -1
- package/dist/provider/hotkeys.d.ts +2 -6
- package/dist/provider/hotkeys.d.ts.map +1 -1
- package/dist/provider/hotkeys.js +10 -15
- package/dist/provider/index.d.ts +5 -3
- package/dist/provider/index.d.ts.map +1 -1
- package/dist/provider/index.js +12 -35
- package/dist/provider/modals-mount.d.ts +16 -0
- package/dist/provider/modals-mount.d.ts.map +1 -0
- package/dist/provider/modals-mount.js +42 -0
- package/dist/provider/notifier.d.ts +22 -0
- package/dist/provider/notifier.d.ts.map +1 -0
- package/dist/provider/notifier.js +36 -0
- package/dist/provider/route-transition.d.ts +1 -1
- package/dist/provider/route-transition.d.ts.map +1 -1
- package/dist/provider/route-transition.js +1 -1
- package/dist/provider/slots.d.ts +25 -0
- package/dist/provider/slots.d.ts.map +1 -0
- package/dist/provider/slots.js +29 -0
- package/dist/provider/spotlight-actions.d.ts +1 -1
- package/dist/provider/spotlight-actions.d.ts.map +1 -1
- package/dist/provider/spotlight-actions.js +2 -3
- package/dist/provider/spotlight-mount.d.ts +3 -0
- package/dist/provider/spotlight-mount.d.ts.map +1 -0
- package/dist/provider/spotlight-mount.js +26 -0
- package/dist/router-tanstack/nav-stash.d.ts +24 -0
- package/dist/router-tanstack/nav-stash.d.ts.map +1 -0
- package/dist/router-tanstack/nav-stash.js +23 -0
- package/dist/router-tanstack/nav.d.ts +5 -15
- package/dist/router-tanstack/nav.d.ts.map +1 -1
- package/dist/router-tanstack/nav.js +6 -16
- package/dist/router-tanstack/use-nav.js +1 -1
- package/dist/surfaces.d.ts +1 -1
- package/dist/surfaces.js +1 -1
- package/llms.txt +4 -4
- package/package.json +2 -2
- package/src/charts/DualPanel.tsx +1 -0
- package/src/charts/Lines.tsx +11 -57
- package/src/charts/MirroredBars.tsx +2 -2
- package/src/charts/compile.ts +34 -6
- package/src/charts/labels.ts +118 -0
- package/src/charts/marks.ts +41 -0
- package/src/charts/scales.ts +9 -7
- package/src/charts/ticks.ts +61 -0
- package/src/charts/types.ts +11 -3
- package/src/cli/doctor-upgrade.ts +101 -35
- package/src/cli/index.ts +5 -3
- package/src/cli/sync.ts +2 -2
- package/src/commands/command-stash.ts +44 -0
- package/src/commands/define-commands.ts +10 -17
- package/src/commands/define-overlays.ts +40 -68
- package/src/commands/projectors.ts +1 -1
- package/src/provider/hotkeys.ts +14 -22
- package/src/provider/index.tsx +28 -52
- package/src/provider/modals-mount.tsx +66 -0
- package/src/provider/notifier.ts +52 -0
- package/src/provider/route-transition.ts +1 -1
- package/src/provider/slots.ts +59 -0
- package/src/provider/spotlight-actions.tsx +3 -4
- package/src/provider/spotlight-mount.tsx +33 -0
- package/src/router-tanstack/nav-stash.ts +41 -0
- package/src/router-tanstack/nav.ts +11 -31
- package/src/router-tanstack/use-nav.ts +1 -1
- package/src/surfaces.ts +1 -1
|
@@ -1,22 +1,11 @@
|
|
|
1
1
|
import { missingLayer } from "../common/errors.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return modalsPromise;
|
|
6
|
-
}
|
|
7
|
-
let mountedModalsProviders = 0;
|
|
8
|
-
function registerModalsProvider() {
|
|
9
|
-
mountedModalsProviders++;
|
|
10
|
-
let released = false;
|
|
11
|
-
return () => {
|
|
12
|
-
if (released) return;
|
|
13
|
-
released = true;
|
|
14
|
-
mountedModalsProviders--;
|
|
15
|
-
};
|
|
16
|
-
}
|
|
2
|
+
import { modals } from "@mantine/modals";
|
|
3
|
+
import { ensureModalsMount, registerModalsMount } from "../provider/modals-mount.js";
|
|
4
|
+
let closeGeneration = 0;
|
|
17
5
|
let activeOverlays = {};
|
|
18
6
|
function defineOverlays(spec) {
|
|
19
7
|
activeOverlays = spec;
|
|
8
|
+
registerModalsMount();
|
|
20
9
|
return spec;
|
|
21
10
|
}
|
|
22
11
|
function defineOverlay(overlay) {
|
|
@@ -32,17 +21,13 @@ async function confirm(options) {
|
|
|
32
21
|
onConfirm,
|
|
33
22
|
onCancel
|
|
34
23
|
} = options;
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"@mantine/modals",
|
|
41
|
-
"install the @mantine/modals peer and mount <BasaltProvider>"
|
|
42
|
-
)
|
|
43
|
-
);
|
|
24
|
+
const startedAt = closeGeneration;
|
|
25
|
+
const live = await ensureModalsMount();
|
|
26
|
+
if (startedAt !== closeGeneration) {
|
|
27
|
+
onCancel?.();
|
|
28
|
+
return false;
|
|
44
29
|
}
|
|
45
|
-
if (
|
|
30
|
+
if (!live) {
|
|
46
31
|
throw new Error(
|
|
47
32
|
missingLayer(
|
|
48
33
|
"overlays.confirm",
|
|
@@ -107,12 +92,21 @@ const overlays = {
|
|
|
107
92
|
console.warn(`[basalt] overlays.open: no overlay registered for "${String(key)}"`);
|
|
108
93
|
return;
|
|
109
94
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
95
|
+
const startedAt = closeGeneration;
|
|
96
|
+
void ensureModalsMount().then((live) => {
|
|
97
|
+
if (startedAt !== closeGeneration) return;
|
|
98
|
+
if (!live) {
|
|
99
|
+
if (process.env.NODE_ENV !== "production") {
|
|
100
|
+
console.warn("[basalt] overlays.open: no mounted <BasaltProvider> to show the overlay");
|
|
101
|
+
}
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
modals.open({ title: spec.title, children: spec.render(props) });
|
|
106
|
+
} catch (error) {
|
|
107
|
+
if (process.env.NODE_ENV !== "production") console.error("[basalt] overlay failed", error);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
116
110
|
},
|
|
117
111
|
/**
|
|
118
112
|
* Open a confirm dialog and resolve to the answer — see {@link confirm}.
|
|
@@ -135,12 +129,12 @@ const overlays = {
|
|
|
135
129
|
* overlays.close()
|
|
136
130
|
*/
|
|
137
131
|
close() {
|
|
138
|
-
|
|
132
|
+
closeGeneration++;
|
|
133
|
+
modals.closeAll();
|
|
139
134
|
}
|
|
140
135
|
};
|
|
141
136
|
export {
|
|
142
137
|
defineOverlay,
|
|
143
138
|
defineOverlays,
|
|
144
|
-
overlays
|
|
145
|
-
registerModalsProvider
|
|
139
|
+
overlays
|
|
146
140
|
};
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type { Command } from '../commands/define-commands.js';
|
|
2
|
-
/**
|
|
3
|
-
* Runs a command, swallowing a sync throw or async rejection so a failing command never becomes an
|
|
4
|
-
* unhandled rejection (which the provider would report as a `window.error`). Dev logs it.
|
|
5
|
-
*/
|
|
6
|
-
export declare function runCommandSafely(cmd: Command): void;
|
|
7
1
|
export declare function useRegistryHotkeys(): void;
|
|
2
|
+
/** The `hotkeys` slot mount: renders nothing, binds the registry's shortcuts. */
|
|
3
|
+
export declare function HotkeyBinder(): null;
|
|
8
4
|
//# sourceMappingURL=hotkeys.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hotkeys.d.ts","sourceRoot":"","sources":["../../src/provider/hotkeys.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hotkeys.d.ts","sourceRoot":"","sources":["../../src/provider/hotkeys.ts"],"names":[],"mappings":"AAYA,wBAAgB,kBAAkB,IAAI,IAAI,CA2CzC;AAED,iFAAiF;AACjF,wBAAgB,YAAY,IAAI,IAAI,CAGnC"}
|
package/dist/provider/hotkeys.js
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
import { useEffect } from "react";
|
|
2
|
-
import { getActiveCommands } from "../commands/
|
|
3
|
-
function runCommandSafely(cmd) {
|
|
4
|
-
const report = (error) => {
|
|
5
|
-
if (process.env.NODE_ENV !== "production") console.error("[basalt] command failed", error);
|
|
6
|
-
};
|
|
7
|
-
try {
|
|
8
|
-
Promise.resolve(cmd.run()).catch(report);
|
|
9
|
-
} catch (error) {
|
|
10
|
-
report(error);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
1
|
+
import { useEffect, useSyncExternalStore } from "react";
|
|
2
|
+
import { getActiveCommands, runCommandSafely, subscribeCommands } from "../commands/command-stash.js";
|
|
13
3
|
function useRegistryHotkeys() {
|
|
4
|
+
const registry = useSyncExternalStore(subscribeCommands, getActiveCommands, getActiveCommands);
|
|
14
5
|
useEffect(() => {
|
|
15
|
-
const commands = Object.values(
|
|
6
|
+
const commands = Object.values(registry).filter((c) => c.shortcut !== void 0);
|
|
16
7
|
if (commands.length === 0) return;
|
|
17
8
|
let cancelled = false;
|
|
18
9
|
const handles = [];
|
|
@@ -42,9 +33,13 @@ function useRegistryHotkeys() {
|
|
|
42
33
|
cancelled = true;
|
|
43
34
|
for (const handle of handles) handle.unregister();
|
|
44
35
|
};
|
|
45
|
-
}, []);
|
|
36
|
+
}, [registry]);
|
|
37
|
+
}
|
|
38
|
+
function HotkeyBinder() {
|
|
39
|
+
useRegistryHotkeys();
|
|
40
|
+
return null;
|
|
46
41
|
}
|
|
47
42
|
export {
|
|
48
|
-
|
|
43
|
+
HotkeyBinder,
|
|
49
44
|
useRegistryHotkeys
|
|
50
45
|
};
|
package/dist/provider/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { BuildPaletteOpts } from '../tokens/core.js';
|
|
|
5
5
|
import type { SizeClass } from '../shell/use-size-class.js';
|
|
6
6
|
import type { Telemetry } from '../telemetry.js';
|
|
7
7
|
import type { BasaltRouter } from './create-router.js';
|
|
8
|
-
import type { FlatNavItem } from '../router-tanstack/nav.js';
|
|
8
|
+
import type { FlatNavItem } from '../router-tanstack/nav-stash.js';
|
|
9
9
|
type BasaltProviderCommonProps = {
|
|
10
10
|
/** Theme override merged onto the Basalt base. Defaults to `createBasaltTheme()`. */
|
|
11
11
|
theme?: MantineProviderProps['theme'];
|
|
@@ -47,8 +47,10 @@ type BasaltProviderCommonProps = {
|
|
|
47
47
|
*/
|
|
48
48
|
navCommandLabel?: (item: FlatNavItem) => string;
|
|
49
49
|
/**
|
|
50
|
-
* Mount Basalt's `<Spotlight>` (Cmd+K) with the generated nav + command actions. Default `true
|
|
51
|
-
*
|
|
50
|
+
* Mount Basalt's `<Spotlight>` (Cmd+K) with the generated nav + command actions. Default `true`, and
|
|
51
|
+
* it mounts only when the app calls `defineNav` or `defineCommands` (nav entries and commands are
|
|
52
|
+
* what it lists). Set `false` when the app owns its own palette: neither the component nor its
|
|
53
|
+
* action wiring mounts.
|
|
52
54
|
*/
|
|
53
55
|
spotlight?: boolean;
|
|
54
56
|
} & Omit<MantineProviderProps, 'children' | 'theme' | 'defaultColorScheme' | 'cssVariablesResolver'>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/provider/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/provider/index.tsx"],"names":[],"mappings":"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"}
|
package/dist/provider/index.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { MantineProvider, useMantineColorScheme, useMantineTheme } from "@mantine/core";
|
|
3
|
-
import { ModalsProvider } from "@mantine/modals";
|
|
4
3
|
import { Notifications } from "@mantine/notifications";
|
|
5
|
-
import { Spotlight } from "@mantine/spotlight";
|
|
6
4
|
import { QueryClientProvider } from "@tanstack/react-query";
|
|
7
5
|
import { RouterProvider, useRouter } from "@tanstack/react-router";
|
|
8
|
-
import { Component, Suspense, lazy,
|
|
6
|
+
import { Component, Suspense, lazy, useEffect, useMemo, useRef, useState } from "react";
|
|
9
7
|
import fallbackClasses from "./error-fallback.module.css";
|
|
10
8
|
import { cssVariablesResolver } from "../theme/index.js";
|
|
11
9
|
import { useLabTheme } from "./lab-theme.js";
|
|
@@ -13,7 +11,6 @@ import { buildDensityCss, buildFontsCss, buildPaletteCss, buildRadiusCss } from
|
|
|
13
11
|
import { isDefaultDeriveConfig } from "../tokens/derive.js";
|
|
14
12
|
import { buildPaletteData } from "../tokens/palette.js";
|
|
15
13
|
import { useMediaQuery } from "../common/use-media-query.js";
|
|
16
|
-
import { registerModalsProvider } from "../commands/define-overlays.js";
|
|
17
14
|
import { registerColorSchemeSetter } from "../commands/shell-bridge.js";
|
|
18
15
|
import { useIsomorphicLayoutEffect } from "../common/isomorphic-layout-effect.js";
|
|
19
16
|
import { PageTitle } from "../shell/page-title.js";
|
|
@@ -25,8 +22,7 @@ import {
|
|
|
25
22
|
errorName,
|
|
26
23
|
now
|
|
27
24
|
} from "../telemetry.js";
|
|
28
|
-
import {
|
|
29
|
-
import { buildSpotlightActions } from "./spotlight-actions.js";
|
|
25
|
+
import { trackProvider, useSlots } from "./slots.js";
|
|
30
26
|
function DefaultErrorFallback() {
|
|
31
27
|
return /* @__PURE__ */ jsxs("div", { className: fallbackClasses.root, children: [
|
|
32
28
|
/* @__PURE__ */ jsx(
|
|
@@ -272,21 +268,15 @@ function BasaltProvider({
|
|
|
272
268
|
});
|
|
273
269
|
const emit = useMemo(() => createLiveEmitter(() => sinkRef.current), []);
|
|
274
270
|
useWindowErrors(emit);
|
|
275
|
-
|
|
276
|
-
useEffect(
|
|
271
|
+
const slots = useSlots();
|
|
272
|
+
useEffect(trackProvider, []);
|
|
277
273
|
const router = useEffectiveRouter(mountedRouter);
|
|
278
274
|
const client = readQueryClient(router);
|
|
279
275
|
useDataTelemetry(router, client, emit);
|
|
280
276
|
const [devTool, setDevTool] = useState(null);
|
|
281
|
-
const [actions, setActions] = useState([]);
|
|
282
|
-
const refreshActions = useCallback(
|
|
283
|
-
() => setActions(buildSpotlightActions(router, setDevTool, navCommandLabel)),
|
|
284
|
-
[router, navCommandLabel]
|
|
285
|
-
);
|
|
286
|
-
useEffect(() => {
|
|
287
|
-
if (spotlight) refreshActions();
|
|
288
|
-
}, [spotlight, refreshActions]);
|
|
289
277
|
const resolvedTheme = useLabTheme(theme);
|
|
278
|
+
const { modals: Modals, hotkeys: Hotkeys, spotlight: Spotlight } = slots;
|
|
279
|
+
const slotProps = { router, navCommandLabel, openDevTool: setDevTool };
|
|
290
280
|
return (
|
|
291
281
|
// `...rest` spreads FIRST so a consumer's `MantineProviderProps` can never shadow the three
|
|
292
282
|
// values that follow it — `cssVariablesResolver` in particular is the resolver the package
|
|
@@ -299,27 +289,14 @@ function BasaltProvider({
|
|
|
299
289
|
cssVariablesResolver,
|
|
300
290
|
defaultColorScheme,
|
|
301
291
|
children: /* @__PURE__ */ jsx(RootBoundary, { emit, fallback, children: /* @__PURE__ */ jsx(BasaltBridge, { injectPalette, paletteOptions, nonce, children: /* @__PURE__ */ jsx(TelemetryContext.Provider, { value: emit, children: /* @__PURE__ */ jsxs(SizeClassHintContext.Provider, { value: sizeClassHint, children: [
|
|
302
|
-
/* @__PURE__ */
|
|
292
|
+
/* @__PURE__ */ jsxs(QueryClientProvider, { client, children: [
|
|
303
293
|
mountedRouter === void 0 ? children : /* @__PURE__ */ jsx(RouterProvider, { router: mountedRouter }),
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
tool: devTool,
|
|
308
|
-
onClose: () => setDevTool(null),
|
|
309
|
-
router
|
|
310
|
-
}
|
|
311
|
-
) })
|
|
312
|
-
] }) }),
|
|
294
|
+
Modals !== void 0 && /* @__PURE__ */ jsx(Modals, { ...slotProps }),
|
|
295
|
+
LazyDevDock !== null && /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(LazyDevDock, { tool: devTool, onClose: () => setDevTool(null), router }) })
|
|
296
|
+
] }),
|
|
313
297
|
/* @__PURE__ */ jsx(Notifications, { position: "bottom-right", autoClose: 4e3, limit: 5 }),
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
{
|
|
317
|
-
actions,
|
|
318
|
-
onSpotlightOpen: refreshActions,
|
|
319
|
-
shortcut: "mod + K",
|
|
320
|
-
maxHeight: 420
|
|
321
|
-
}
|
|
322
|
-
)
|
|
298
|
+
Hotkeys !== void 0 && /* @__PURE__ */ jsx(Hotkeys, { ...slotProps }),
|
|
299
|
+
spotlight && Spotlight !== void 0 && /* @__PURE__ */ jsx(Spotlight, { ...slotProps })
|
|
323
300
|
] }) }) }) })
|
|
324
301
|
}
|
|
325
302
|
)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal — `ModalsMount` declares its `ModalsProvider` live for as long as it is mounted and gets
|
|
3
|
+
* back the retraction. There is no way to detect the provider from outside React (its context is only
|
|
4
|
+
* readable through `useModals()`, and the overlay calls are imperative), so the registration is explicit.
|
|
5
|
+
* Exported for the confirm tests, which mount their own host.
|
|
6
|
+
*/
|
|
7
|
+
export declare const registerModalsProvider: () => () => void;
|
|
8
|
+
/** @internal — put the modals mount in the provider's slots; synchronous, nothing awaited. */
|
|
9
|
+
export declare function registerModalsMount(): void;
|
|
10
|
+
/**
|
|
11
|
+
* @internal — register the mount, then wait for it to go live: up to 5 s when a `BasaltProvider` is
|
|
12
|
+
* mounted (it commits the slot), 500 ms when none is. `false` means no dialog layer will serve the call.
|
|
13
|
+
*/
|
|
14
|
+
export declare function ensureModalsMount(): Promise<boolean>;
|
|
15
|
+
export declare function ModalsMount(): import("react").JSX.Element;
|
|
16
|
+
//# sourceMappingURL=modals-mount.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modals-mount.d.ts","sourceRoot":"","sources":["../../src/provider/modals-mount.tsx"],"names":[],"mappings":"AAiBA;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,kBAAwB,CAAA;AAyB3D,8FAA8F;AAC9F,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC,CAGpD;AAED,wBAAgB,WAAW,gCAG1B"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ModalsProvider } from "@mantine/modals";
|
|
3
|
+
import { useEffect } from "react";
|
|
4
|
+
import { createLiveCounter } from "./notifier.js";
|
|
5
|
+
import { hasMountedProvider, registerSlot } from "./slots.js";
|
|
6
|
+
const liveProviders = createLiveCounter();
|
|
7
|
+
const registerModalsProvider = liveProviders.acquire;
|
|
8
|
+
const COMMIT_WAIT_MS = 5e3;
|
|
9
|
+
const NO_PROVIDER_WAIT_MS = 500;
|
|
10
|
+
function whenModalsLive(timeoutMs) {
|
|
11
|
+
if (liveProviders.count() > 0) return Promise.resolve(true);
|
|
12
|
+
return new Promise((resolve) => {
|
|
13
|
+
let timer;
|
|
14
|
+
let unsubscribe;
|
|
15
|
+
const finish = (isLive) => {
|
|
16
|
+
clearTimeout(timer);
|
|
17
|
+
unsubscribe?.();
|
|
18
|
+
resolve(isLive);
|
|
19
|
+
};
|
|
20
|
+
timer = setTimeout(() => finish(false), timeoutMs);
|
|
21
|
+
unsubscribe = liveProviders.subscribe(() => {
|
|
22
|
+
if (liveProviders.count() > 0) finish(true);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function registerModalsMount() {
|
|
27
|
+
registerSlot("modals", ModalsMount);
|
|
28
|
+
}
|
|
29
|
+
function ensureModalsMount() {
|
|
30
|
+
registerModalsMount();
|
|
31
|
+
return whenModalsLive(hasMountedProvider() ? COMMIT_WAIT_MS : NO_PROVIDER_WAIT_MS);
|
|
32
|
+
}
|
|
33
|
+
function ModalsMount() {
|
|
34
|
+
useEffect(() => registerModalsProvider(), []);
|
|
35
|
+
return /* @__PURE__ */ jsx(ModalsProvider, { children: null });
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
ModalsMount,
|
|
39
|
+
ensureModalsMount,
|
|
40
|
+
registerModalsMount,
|
|
41
|
+
registerModalsProvider
|
|
42
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one subscribe/notify pair behind every module-level store here (slots, the command stash, the
|
|
3
|
+
* modals-live waiters) — shaped for `useSyncExternalStore`. A leaf: no React, nothing at import.
|
|
4
|
+
*/
|
|
5
|
+
export type Notifier = {
|
|
6
|
+
subscribe: (listener: () => void) => () => void;
|
|
7
|
+
notify: () => void;
|
|
8
|
+
};
|
|
9
|
+
export declare function createNotifier(): Notifier;
|
|
10
|
+
export type LiveCounter = {
|
|
11
|
+
count: () => number;
|
|
12
|
+
/** Count one more live thing, notify subscribers, and return its retraction (idempotent). */
|
|
13
|
+
acquire: () => () => void;
|
|
14
|
+
subscribe: Notifier['subscribe'];
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* A COUNTER of live things — not a flag: two overlapping mounts are normal (a route swap mounts the
|
|
18
|
+
* next one before unmounting the previous), and a last-write-wins boolean would report the OLD one's
|
|
19
|
+
* teardown as "none live" while the new one serves.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createLiveCounter(): LiveCounter;
|
|
22
|
+
//# sourceMappingURL=notifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notifier.d.ts","sourceRoot":"","sources":["../../src/provider/notifier.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG;IAAE,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,IAAI,CAAA;CAAE,CAAA;AAE9F,wBAAgB,cAAc,IAAI,QAAQ,CAYzC;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,MAAM,CAAA;IACnB,6FAA6F;IAC7F,OAAO,EAAE,MAAM,MAAM,IAAI,CAAA;IACzB,SAAS,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAA;CACjC,CAAA;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,WAAW,CAmB/C"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
function createNotifier() {
|
|
2
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
3
|
+
return {
|
|
4
|
+
subscribe(listener) {
|
|
5
|
+
listeners.add(listener);
|
|
6
|
+
return () => void listeners.delete(listener);
|
|
7
|
+
},
|
|
8
|
+
// Deleting from a Set mid-iteration is safe, so a listener may unsubscribe itself here.
|
|
9
|
+
notify() {
|
|
10
|
+
for (const listener of listeners) listener();
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function createLiveCounter() {
|
|
15
|
+
let live = 0;
|
|
16
|
+
const changes = createNotifier();
|
|
17
|
+
return {
|
|
18
|
+
count: () => live,
|
|
19
|
+
subscribe: changes.subscribe,
|
|
20
|
+
acquire() {
|
|
21
|
+
live++;
|
|
22
|
+
changes.notify();
|
|
23
|
+
let released = false;
|
|
24
|
+
return () => {
|
|
25
|
+
if (released) return;
|
|
26
|
+
released = true;
|
|
27
|
+
live--;
|
|
28
|
+
changes.notify();
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
createLiveCounter,
|
|
35
|
+
createNotifier
|
|
36
|
+
};
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* so `ready` and `finished` are dropped on the floor.
|
|
9
9
|
*/
|
|
10
10
|
import type { AnyRouter } from '@tanstack/react-router';
|
|
11
|
-
import { flattenNav, getActiveNav } from '../router-tanstack/nav.js';
|
|
11
|
+
import { flattenNav, getActiveNav } from '../router-tanstack/nav-stash.js';
|
|
12
12
|
/** The three `:active-view-transition-type()` names `styles.css` animates. Namespaced: a consumer's own cannot collide. */
|
|
13
13
|
export declare const ROUTE_TRANSITION_TYPES: {
|
|
14
14
|
readonly forward: "basalt-forward";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route-transition.d.ts","sourceRoot":"","sources":["../../src/provider/route-transition.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"route-transition.d.ts","sourceRoot":"","sources":["../../src/provider/route-transition.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAEvE,2HAA2H;AAC3H,eAAO,MAAM,sBAAsB;;;;CAIzB,CAAA;AAEV,uFAAuF;AACvF,KAAK,oBAAoB,GAAG,UAAU,CACpC,OAAO,CACL,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,uBAAuB,CAAC,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,EACvE,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,CAC9B,CACF,CAAC,CAAC,CAAC,CAAA;AAEJ,sFAAsF;AACtF,KAAK,cAAc,GAAG,IAAI,CAAC,oBAAoB,EAAE,aAAa,CAAC,GAAG;IAChE,YAAY,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC,EAAE,UAAU,CAAC,CAAA;IAClF,UAAU,EAAE,IAAI,CAAC,oBAAoB,CAAC,YAAY,CAAC,EAAE,UAAU,CAAC,CAAA;CACjE,CAAA;AAED,KAAK,SAAS,GAAG,WAAW,CAAC,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC,CAAA;AAC7D,KAAK,OAAO,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAA;AAoDpD;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,aAAa,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAejF;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,EAAE,cAAc,EACzD,GAAG,EAAE,SAAS,GAAG,SAAS,GACzB,MAAM,EAAE,GAAG,KAAK,CAQlB;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,IAAI,OAAO,CAIrD;AAED,6EAA6E;AAC7E,eAAO,MAAM,mBAAmB;oBACd,cAAc;CAC/B,CAAA;AAqBD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,6BAA6B,IAAI,IAAI,CAYpD"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import type { AnyRouter } from '@tanstack/react-router';
|
|
3
|
+
import type { BasaltDevDockTool } from '../dev-dock.js';
|
|
4
|
+
import type { FlatNavItem } from '../router-tanstack/nav-stash.js';
|
|
5
|
+
/** What the provider hands every mount; a mount that needs none of it ignores it. */
|
|
6
|
+
export type SlotProps = {
|
|
7
|
+
router: AnyRouter;
|
|
8
|
+
navCommandLabel: ((item: FlatNavItem) => string) | undefined;
|
|
9
|
+
openDevTool: (tool: BasaltDevDockTool) => void;
|
|
10
|
+
};
|
|
11
|
+
export type SlotName = 'hotkeys' | 'spotlight' | 'modals';
|
|
12
|
+
export type Slots = {
|
|
13
|
+
readonly [K in SlotName]?: ComponentType<SlotProps>;
|
|
14
|
+
};
|
|
15
|
+
/** @internal — idempotent: re-registering the same component is a no-op (no notify, no new snapshot). */
|
|
16
|
+
export declare function registerSlot(name: SlotName, component: ComponentType<SlotProps>): void;
|
|
17
|
+
/** @internal — test isolation only. */
|
|
18
|
+
export declare function resetSlots(): void;
|
|
19
|
+
/** @internal — the registered mounts, read by `BasaltProvider`. */
|
|
20
|
+
export declare function useSlots(): Slots;
|
|
21
|
+
/** @internal — `BasaltProvider` declares itself mounted; returns the retraction. */
|
|
22
|
+
export declare const trackProvider: () => () => void;
|
|
23
|
+
/** @internal — whether a `BasaltProvider` is mounted to commit a slot registered right now. */
|
|
24
|
+
export declare function hasMountedProvider(): boolean;
|
|
25
|
+
//# sourceMappingURL=slots.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slots.d.ts","sourceRoot":"","sources":["../../src/provider/slots.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAG/D,qFAAqF;AACrF,MAAM,MAAM,SAAS,GAAG;IACtB,MAAM,EAAE,SAAS,CAAA;IACjB,eAAe,EAAE,CAAC,CAAC,IAAI,EAAE,WAAW,KAAK,MAAM,CAAC,GAAG,SAAS,CAAA;IAC5D,WAAW,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,CAAA;CAC/C,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAA;AACzD,MAAM,MAAM,KAAK,GAAG;IAAE,QAAQ,EAAE,CAAC,IAAI,QAAQ,CAAC,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC;CAAE,CAAA;AAK3E,yGAAyG;AACzG,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,CAAC,SAAS,CAAC,GAAG,IAAI,CAItF;AAED,uCAAuC;AACvC,wBAAgB,UAAU,IAAI,IAAI,CAGjC;AAID,mEAAmE;AACnE,wBAAgB,QAAQ,IAAI,KAAK,CAEhC;AAMD,oFAAoF;AACpF,eAAO,MAAM,aAAa,kBAAoB,CAAA;AAE9C,+FAA+F;AAC/F,wBAAgB,kBAAkB,IAAI,OAAO,CAE5C"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useSyncExternalStore } from "react";
|
|
2
|
+
import { createLiveCounter, createNotifier } from "./notifier.js";
|
|
3
|
+
let slots = {};
|
|
4
|
+
const store = createNotifier();
|
|
5
|
+
function registerSlot(name, component) {
|
|
6
|
+
if (slots[name] === component) return;
|
|
7
|
+
slots = { ...slots, [name]: component };
|
|
8
|
+
store.notify();
|
|
9
|
+
}
|
|
10
|
+
function resetSlots() {
|
|
11
|
+
slots = {};
|
|
12
|
+
store.notify();
|
|
13
|
+
}
|
|
14
|
+
const getSlots = () => slots;
|
|
15
|
+
function useSlots() {
|
|
16
|
+
return useSyncExternalStore(store.subscribe, getSlots, getSlots);
|
|
17
|
+
}
|
|
18
|
+
const providers = createLiveCounter();
|
|
19
|
+
const trackProvider = providers.acquire;
|
|
20
|
+
function hasMountedProvider() {
|
|
21
|
+
return providers.count() > 0;
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
hasMountedProvider,
|
|
25
|
+
registerSlot,
|
|
26
|
+
resetSlots,
|
|
27
|
+
trackProvider,
|
|
28
|
+
useSlots
|
|
29
|
+
};
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { SpotlightActionData } from '@mantine/spotlight';
|
|
7
7
|
import type { AnyRouter } from '@tanstack/react-router';
|
|
8
|
-
import type { FlatNavItem } from '../router-tanstack/nav.js';
|
|
8
|
+
import type { FlatNavItem } from '../router-tanstack/nav-stash.js';
|
|
9
9
|
import type { BasaltDevDockTool } from '../dev-dock.js';
|
|
10
10
|
export declare function buildSpotlightActions(router: AnyRouter, openDevTool: (tool: BasaltDevDockTool) => void, navCommandLabel?: (item: FlatNavItem) => string): SpotlightActionData[];
|
|
11
11
|
//# sourceMappingURL=spotlight-actions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spotlight-actions.d.ts","sourceRoot":"","sources":["../../src/provider/spotlight-actions.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAIvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"spotlight-actions.d.ts","sourceRoot":"","sources":["../../src/provider/spotlight-actions.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAIvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAC/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAQpD,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,SAAS,EACjB,WAAW,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,EAC9C,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,MAAM,GAC9C,mBAAmB,EAAE,CAiDvB"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { getActiveCommands } from "../commands/
|
|
1
|
+
import { getActiveCommands, runCommandSafely } from "../commands/command-stash.js";
|
|
2
2
|
import { detectMac, formatShortcutDisplay } from "../commands/shortcut-format.js";
|
|
3
|
-
import { flattenNav, getActiveNav } from "../router-tanstack/nav.js";
|
|
4
|
-
import { runCommandSafely } from "./hotkeys.js";
|
|
3
|
+
import { flattenNav, getActiveNav } from "../router-tanstack/nav-stash.js";
|
|
5
4
|
const DEV_TOOLS = [
|
|
6
5
|
{ tool: "router", label: "Router devtools" },
|
|
7
6
|
{ tool: "query", label: "Query devtools" },
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spotlight-mount.d.ts","sourceRoot":"","sources":["../../src/provider/spotlight-mount.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAExC,wBAAgB,cAAc,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,WAAW,EAAE,EAAE,SAAS,+BAqBjF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Spotlight } from "@mantine/spotlight";
|
|
3
|
+
import { useCallback, useEffect, useState } from "react";
|
|
4
|
+
import { buildSpotlightActions } from "./spotlight-actions.js";
|
|
5
|
+
function SpotlightMount({ router, navCommandLabel, openDevTool }) {
|
|
6
|
+
const [actions, setActions] = useState([]);
|
|
7
|
+
const refreshActions = useCallback(
|
|
8
|
+
() => setActions(buildSpotlightActions(router, openDevTool, navCommandLabel)),
|
|
9
|
+
[router, openDevTool, navCommandLabel]
|
|
10
|
+
);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
refreshActions();
|
|
13
|
+
}, [refreshActions]);
|
|
14
|
+
return /* @__PURE__ */ jsx(
|
|
15
|
+
Spotlight,
|
|
16
|
+
{
|
|
17
|
+
actions,
|
|
18
|
+
onSpotlightOpen: refreshActions,
|
|
19
|
+
shortcut: "mod + K",
|
|
20
|
+
maxHeight: 420
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
SpotlightMount
|
|
26
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The nav definition's runtime stash and its flatten reader, as a leaf (types only from `./nav`):
|
|
3
|
+
* `defineNav` fills it; Spotlight's action builder, the route transitions and the provider read it.
|
|
4
|
+
* Kept apart from `nav.ts` so no reader imports the module that registers the Spotlight mount.
|
|
5
|
+
*/
|
|
6
|
+
import type { AnyNavGroup, AnyNavItem } from './nav.js';
|
|
7
|
+
/** @internal */
|
|
8
|
+
export declare function getActiveNav(): {
|
|
9
|
+
groups: ReadonlyArray<AnyNavGroup>;
|
|
10
|
+
} | undefined;
|
|
11
|
+
/** @internal — `defineNav` only. The last call wins. */
|
|
12
|
+
export declare function setActiveNav(nav: {
|
|
13
|
+
groups: ReadonlyArray<AnyNavGroup>;
|
|
14
|
+
}): void;
|
|
15
|
+
/** A flattened destination, tagged with the group it was declared in. */
|
|
16
|
+
export type FlatNavItem = AnyNavItem & {
|
|
17
|
+
groupId: string;
|
|
18
|
+
groupLabel: string;
|
|
19
|
+
};
|
|
20
|
+
/** Depth-first flatten, parent then children — the leaf every other surface reads. */
|
|
21
|
+
export declare function flattenNav(config: {
|
|
22
|
+
groups: ReadonlyArray<AnyNavGroup>;
|
|
23
|
+
}): FlatNavItem[];
|
|
24
|
+
//# sourceMappingURL=nav-stash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nav-stash.d.ts","sourceRoot":"","sources":["../../src/router-tanstack/nav-stash.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAWpD,gBAAgB;AAChB,wBAAgB,YAAY,IAAI;IAAE,MAAM,EAAE,aAAa,CAAC,WAAW,CAAC,CAAA;CAAE,GAAG,SAAS,CAEjF;AAED,wDAAwD;AACxD,wBAAgB,YAAY,CAAC,GAAG,EAAE;IAAE,MAAM,EAAE,aAAa,CAAC,WAAW,CAAC,CAAA;CAAE,GAAG,IAAI,CAE9E;AAED,yEAAyE;AACzE,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAA;AAE9E,sFAAsF;AACtF,wBAAgB,UAAU,CAAC,MAAM,EAAE;IAAE,MAAM,EAAE,aAAa,CAAC,WAAW,CAAC,CAAA;CAAE,GAAG,WAAW,EAAE,CAUxF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
let activeNav;
|
|
2
|
+
function getActiveNav() {
|
|
3
|
+
return activeNav;
|
|
4
|
+
}
|
|
5
|
+
function setActiveNav(nav) {
|
|
6
|
+
activeNav = nav;
|
|
7
|
+
}
|
|
8
|
+
function flattenNav(config) {
|
|
9
|
+
const out = [];
|
|
10
|
+
const walk = (items, groupId, groupLabel) => {
|
|
11
|
+
for (const item of items) {
|
|
12
|
+
out.push({ ...item, groupId, groupLabel });
|
|
13
|
+
if (item.children) walk(item.children, groupId, groupLabel);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
for (const g of config.groups) walk(g.items, g.id, g.label);
|
|
17
|
+
return out;
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
flattenNav,
|
|
21
|
+
getActiveNav,
|
|
22
|
+
setActiveNav
|
|
23
|
+
};
|