@schemavaults/ui 0.109.2 → 0.111.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/dist/components/layout/dashboard-layout/DashboardLayoutProps.d.ts +26 -1
- package/dist/components/layout/dashboard-layout/dashboard-layout.d.ts +1 -1
- package/dist/components/layout/dashboard-layout/dashboard-layout.js +4 -3
- package/dist/components/layout/dashboard-layout/dashboard-layout.js.map +1 -1
- package/dist/components/layout/dashboard-layout/dashboard-sidebar/dashboard-sidebar-active-item-context.d.ts +24 -0
- package/dist/components/layout/dashboard-layout/dashboard-sidebar/dashboard-sidebar-active-item-context.js +32 -0
- package/dist/components/layout/dashboard-layout/dashboard-sidebar/dashboard-sidebar-active-item-context.js.map +1 -0
- package/dist/components/layout/dashboard-layout/dashboard-sidebar/dashboard-sidebar-active-item-indicator.d.ts +21 -0
- package/dist/components/layout/dashboard-layout/dashboard-sidebar/dashboard-sidebar-active-item-indicator.js +64 -0
- package/dist/components/layout/dashboard-layout/dashboard-sidebar/dashboard-sidebar-active-item-indicator.js.map +1 -0
- package/dist/components/layout/dashboard-layout/dashboard-sidebar/dashboard-sidebar-active-item.d.ts +32 -0
- package/dist/components/layout/dashboard-layout/dashboard-sidebar/dashboard-sidebar-active-item.js +62 -0
- package/dist/components/layout/dashboard-layout/dashboard-sidebar/dashboard-sidebar-active-item.js.map +1 -0
- package/dist/components/layout/dashboard-layout/dashboard-sidebar/dashboard-sidebar-item-renderer.js +32 -8
- package/dist/components/layout/dashboard-layout/dashboard-sidebar/dashboard-sidebar-item-renderer.js.map +1 -1
- package/dist/components/layout/dashboard-layout/dashboard-sidebar/index.d.ts +2 -0
- package/dist/components/layout/dashboard-layout/dashboard-sidebar/index.js +2 -0
- package/dist/components/layout/dashboard-layout/dashboard-sidebar/index.js.map +1 -1
- package/dist/components/layout/dashboard-layout/index.d.ts +1 -0
- package/dist/components/layout/dashboard-layout/index.js +1 -0
- package/dist/components/layout/dashboard-layout/index.js.map +1 -1
- package/dist/components/ui/index.d.ts +2 -0
- package/dist/components/ui/index.js +1 -0
- package/dist/components/ui/index.js.map +1 -1
- package/dist/components/ui/treemap/index.d.ts +3 -0
- package/dist/components/ui/treemap/index.js +3 -0
- package/dist/components/ui/treemap/index.js.map +1 -0
- package/dist/components/ui/treemap/treemap.d.ts +162 -0
- package/dist/components/ui/treemap/treemap.js +382 -0
- package/dist/components/ui/treemap/treemap.js.map +1 -0
- package/dist/types/Link.d.ts +6 -0
- package/package.json +2 -2
|
@@ -31,9 +31,34 @@ export interface DashboardLayoutProps extends PropsWithChildren {
|
|
|
31
31
|
/**
|
|
32
32
|
* Optional `usePathname` hook (e.g. from `next/navigation`). When provided,
|
|
33
33
|
* the mobile sidebar will automatically close whenever the pathname
|
|
34
|
-
* changes
|
|
34
|
+
* changes, and the sidebar item for the current page is marked active (see
|
|
35
|
+
* `activeHref`). Pass the hook itself, not its return value.
|
|
35
36
|
*/
|
|
36
37
|
usePathname?: () => string;
|
|
38
|
+
/**
|
|
39
|
+
* The pathname of the page currently being viewed, for marking its sidebar
|
|
40
|
+
* item as active. Takes precedence over `usePathname`; use it when the
|
|
41
|
+
* router does not expose a `usePathname`-style hook, or to pin the active
|
|
42
|
+
* item explicitly.
|
|
43
|
+
*
|
|
44
|
+
* An item is active when the current path equals its `url` or is nested
|
|
45
|
+
* beneath it (`/settings/billing` is within `/settings`). When several
|
|
46
|
+
* items match, the longest `url` wins, so only the most specific item
|
|
47
|
+
* lights up. The query string and fragment are ignored, and only
|
|
48
|
+
* root-relative `url`s (starting with `/`) take part.
|
|
49
|
+
*
|
|
50
|
+
* The active item gets a gradient wash, a glowing gradient bar down its
|
|
51
|
+
* left edge and a bold gradient label, running between the
|
|
52
|
+
* `--sidebar-active-start` and `--sidebar-active-end` tokens of
|
|
53
|
+
* `@schemavaults/theme`, which default to the SchemaVaults brand blue and
|
|
54
|
+
* brand red. Re-theme a deployment through the theme's overrides
|
|
55
|
+
* (`--sv-theme-light-sidebar-active-start`, `THEME_DARK_SIDEBAR_ACTIVE_END`,
|
|
56
|
+
* ...), or set the two tokens on an ancestor of the layout to re-colour
|
|
57
|
+
* just that subtree. Rows in an `adminOnly` group keep their red label and
|
|
58
|
+
* icon. The active link also gets
|
|
59
|
+
* `aria-current="page"` and its `<li>` `data-active="true"`.
|
|
60
|
+
*/
|
|
61
|
+
activeHref?: string;
|
|
37
62
|
/**
|
|
38
63
|
* When `true`, the dashboard "chrome" (the left sidebar and the top header
|
|
39
64
|
* bar) is hidden from printed output via `@media print`, so the system print
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ReactElement } from "react";
|
|
2
2
|
import type { DashboardLayoutProps } from "./DashboardLayoutProps";
|
|
3
3
|
export type { DashboardLayoutProps };
|
|
4
|
-
export declare function DashboardLayout({ children, wordmark, logo, Link, brandHref, topBarTitle, usePathname, printHidden, sidebarOpenWidth, reducedMotion, ...props }: DashboardLayoutProps): ReactElement;
|
|
4
|
+
export declare function DashboardLayout({ children, wordmark, logo, Link, brandHref, topBarTitle, usePathname, activeHref, printHidden, sidebarOpenWidth, reducedMotion, ...props }: DashboardLayoutProps): ReactElement;
|
|
5
5
|
export default DashboardLayout;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import DashboardSidebar, { DashboardLayoutSidebarTrigger, DashboardSidebarContextProvider, useCloseDashboardSidebarOnRouteChange, useDashboardSidebarOpenState, useDashboardSidebarSizing, DASHBOARD_SIDEBAR_OPEN_WIDTH_CSS_VARIABLE, } from "./dashboard-sidebar";
|
|
3
|
+
import DashboardSidebar, { DashboardLayoutSidebarTrigger, DashboardSidebarActiveItemFromPathnameHookProvider, DashboardSidebarActiveItemProvider, DashboardSidebarContextProvider, useCloseDashboardSidebarOnRouteChange, useDashboardSidebarOpenState, useDashboardSidebarSizing, DASHBOARD_SIDEBAR_OPEN_WIDTH_CSS_VARIABLE, } from "./dashboard-sidebar";
|
|
4
4
|
import { Separator } from "../../ui/separator";
|
|
5
5
|
import DashboardLayoutMainContentContainer from "./dashboard-layout-main-content-container";
|
|
6
6
|
import { cn } from "../../../lib/utils";
|
|
@@ -21,7 +21,7 @@ function AutoCloseSidebarOnNavigation({ usePathname, }) {
|
|
|
21
21
|
useCloseDashboardSidebarOnRouteChange(usePathname);
|
|
22
22
|
return null;
|
|
23
23
|
}
|
|
24
|
-
export function DashboardLayout({ children, wordmark, logo, Link, brandHref, topBarTitle, usePathname, printHidden = false, sidebarOpenWidth, reducedMotion, ...props }) {
|
|
24
|
+
export function DashboardLayout({ children, wordmark, logo, Link, brandHref, topBarTitle, usePathname, activeHref, printHidden = false, sidebarOpenWidth, reducedMotion, ...props }) {
|
|
25
25
|
const size = useDashboardSidebarSizing();
|
|
26
26
|
// Resolved once, here, and published on the subtree through `MotionConfig`
|
|
27
27
|
// below. Everything the layout animates — in CSS or in Framer Motion —
|
|
@@ -47,6 +47,7 @@ export function DashboardLayout({ children, wordmark, logo, Link, brandHref, top
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
const TopBarButtonsComponent = props.topBarButtons;
|
|
50
|
+
const sidebar = (_jsx(DashboardSidebar, { wordmark: wordmark, Link: Link, brandHref: brandHref, logo: logo, sidebarFooterContent: props.sidebarFooterContent, className: cn(printHidden && "print:hidden") }));
|
|
50
51
|
return (
|
|
51
52
|
// Hands the resolved preference to every Framer Motion element inside the
|
|
52
53
|
// layout — the sidebar's own `m.*` elements, and any the consumer renders
|
|
@@ -57,7 +58,7 @@ export function DashboardLayout({ children, wordmark, logo, Link, brandHref, top
|
|
|
57
58
|
// When hiding chrome for print, let the container grow to fit all
|
|
58
59
|
// page content across printed pages instead of clamping to the
|
|
59
60
|
// on-screen viewport height.
|
|
60
|
-
printHidden && "print:h-auto print:min-h-0"), style: containerStyle, children: [_jsx(
|
|
61
|
+
printHidden && "print:h-auto print:min-h-0"), style: containerStyle, children: [typeof usePathname === "function" ? (_jsx(DashboardSidebarActiveItemFromPathnameHookProvider, { usePathname: usePathname, currentPathname: activeHref, children: sidebar })) : (_jsx(DashboardSidebarActiveItemProvider, { currentPathname: activeHref, children: sidebar })), _jsxs(DashboardLayoutMainContentContainer, { printHidden: printHidden, children: [_jsx("header", { id: "dashboard-layout-main-content-header", className: cn("sticky top-0", "flex shrink-0 items-center gap-2", "transition-[width,height] ease-linear", reducedMotionClassName(reducedMotionSetting), "bg-background", "border-b border-border", size.sidebar_and_header_z_index_classname, printHidden && "print:hidden"), style: {
|
|
61
62
|
height: size.header_height,
|
|
62
63
|
}, children: _jsxs("div", { className: "flex flex-row justify-between items-center gap-2 px-4 w-full", children: [_jsx(DashboardLayoutSidebarTrigger, {}), _jsx(Separator, { orientation: "vertical", className: "mr-2 data-[orientation=vertical]:h-4" }), _jsx(HeaderBarPageIdentifierComponent, {}), _jsx("div", { role: "none", className: "grow" }), typeof TopBarButtonsComponent === "function" && (_jsx(TopBarButtonsComponent, { useDashboardSidebarSizing: useDashboardSidebarSizing, useDashboardSidebarOpenState: useDashboardSidebarOpenState, Link: Link }))] }) }), children] })] })] }) }));
|
|
63
64
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dashboard-layout.js","sourceRoot":"","sources":["../../../../src/components/layout/dashboard-layout/dashboard-layout.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,gBAAgB,EAAE,EACvB,6BAA6B,EAC7B,+BAA+B,EAC/B,qCAAqC,EACrC,4BAA4B,EAC5B,yBAAyB,EACzB,yCAAyC,GAC1C,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,mCAAmC,MAAM,2CAA2C,CAAC;AAE5F,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO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AAC;IAED,MAAM,sBAAsB,GAEZ,KAAK,CAAC,aAAa,CAAC;IAEpC,OAAO;IACL,0EAA0E;IAC1E,0EAA0E;IAC1E,2EAA2E;IAC3E,wEAAwE;IACxE,+DAA+D;IAC/D,KAAC,YAAY,IAAC,aAAa,EAAE,oBAAoB,YAC/C,MAAC,+BAA+B,IAC9B,YAAY,EAAE,KAAK,CAAC,YAAY,EAChC,MAAM,EAAE,KAAK,CAAC,MAAM,EACpB,gBAAgB,EAAE,gBAAgB,EAClC,aAAa,EAAE,KAAK,CAAC,aAAa,EAClC,cAAc,EAAE,KAAK,CAAC,cAAc,aAEnC,OAAO,WAAW,KAAK,UAAU,IAAI,CACpC,KAAC,4BAA4B,IAAC,WAAW,EAAE,WAAW,GAAI,CAC3D,EACD,eACE,EAAE,EAAC,4BAA4B,EAC/B,SAAS,EAAE,EAAE,CACX,wBAAwB;oBACxB,kEAAkE;oBAClE,+DAA+D;oBAC/D,6BAA6B;oBAC7B,WAAW,IAAI,4BAA4B,CAC5C,EACD,KAAK,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"dashboard-layout.js","sourceRoot":"","sources":["../../../../src/components/layout/dashboard-layout/dashboard-layout.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,gBAAgB,EAAE,EACvB,6BAA6B,EAC7B,kDAAkD,EAClD,kCAAkC,EAClC,+BAA+B,EAC/B,qCAAqC,EACrC,4BAA4B,EAC5B,yBAAyB,EACzB,yCAAyC,GAC1C,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,mCAAmC,MAAM,2CAA2C,CAAC;AAE5F,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EACL,sBAAsB,GAEvB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,8CAA8C,EAAE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CAAC,oBAAoB,CAAC,EAC5C,eAAe,EACf,wBAAwB,EACxB,IAAI,CAAC,oCAAoC,EACzC,WAAW,IAAI,cAAc,CAC9B,EACD,KAAK,EAAE;wCACL,MAAM,EAAE,IAAI,CAAC,aAAa;qCAC3B,YAED,eAAK,SAAS,EAAC,8DAA8D,aAC3E,KAAC,6BAA6B,KAAG,EACjC,KAAC,SAAS,IACR,WAAW,EAAC,UAAU,EACtB,SAAS,EAAC,sCAAsC,GAChD,EACF,KAAC,gCAAgC,KAAG,EACpC,cAAK,IAAI,EAAC,MAAM,EAAC,SAAS,EAAC,MAAM,GAAG,EACnC,OAAO,sBAAsB,KAAK,UAAU,IAAI,CAC/C,KAAC,sBAAsB,IACrB,yBAAyB,EAAE,yBAAyB,EACpD,4BAA4B,EAAE,4BAA4B,EAC1D,IAAI,EAAE,IAAI,GACV,CACH,IACG,GACC,EACR,QAAQ,IAC2B,IAClC,IAC0B,GACrB,CAChB,CAAC;AACJ,CAAC;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type PropsWithChildren, type ReactElement } from "react";
|
|
2
|
+
import type { DashboardSidebarItemDefinition } from "./dashboard-sidebar-item-definition";
|
|
3
|
+
/**
|
|
4
|
+
* The normalized path of the menu item for the current page, or `null` when
|
|
5
|
+
* the current page is unknown or matches no item.
|
|
6
|
+
*/
|
|
7
|
+
export declare const DashboardSidebarActiveItemContext: import("react").Context<string | null>;
|
|
8
|
+
export interface DashboardSidebarActiveItemProviderProps extends PropsWithChildren {
|
|
9
|
+
/** The current page's pathname (or full href). */
|
|
10
|
+
currentPathname?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function DashboardSidebarActiveItemProvider({ currentPathname, children, }: DashboardSidebarActiveItemProviderProps): ReactElement;
|
|
13
|
+
export interface DashboardSidebarActiveItemFromPathnameHookProviderProps extends DashboardSidebarActiveItemProviderProps {
|
|
14
|
+
usePathname: () => string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Reads the current page from the consumer's `usePathname` hook. Kept as its
|
|
18
|
+
* own component so `DashboardLayout` can choose between this and the plain
|
|
19
|
+
* provider without calling a hook conditionally. An explicit
|
|
20
|
+
* `currentPathname` still wins over the hook's value.
|
|
21
|
+
*/
|
|
22
|
+
export declare function DashboardSidebarActiveItemFromPathnameHookProvider({ usePathname, currentPathname, children, }: DashboardSidebarActiveItemFromPathnameHookProviderProps): ReactElement;
|
|
23
|
+
/** Whether `item` is the menu item for the page currently being viewed. */
|
|
24
|
+
export declare function useIsDashboardSidebarItemActive(item: DashboardSidebarItemDefinition): boolean;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext, useMemo, } from "react";
|
|
4
|
+
import { normalizeDashboardSidebarPath, resolveActiveDashboardSidebarItemPath, } from "./dashboard-sidebar-active-item";
|
|
5
|
+
import { DashboardSidebarItemsAndGroupsContext, } from "./dashboard-sidebar-items-and-groups-context";
|
|
6
|
+
/**
|
|
7
|
+
* The normalized path of the menu item for the current page, or `null` when
|
|
8
|
+
* the current page is unknown or matches no item.
|
|
9
|
+
*/
|
|
10
|
+
export const DashboardSidebarActiveItemContext = createContext(null);
|
|
11
|
+
export function DashboardSidebarActiveItemProvider({ currentPathname, children, }) {
|
|
12
|
+
const sidebarItems = useContext(DashboardSidebarItemsAndGroupsContext);
|
|
13
|
+
const activePath = useMemo(() => resolveActiveDashboardSidebarItemPath(sidebarItems, currentPathname), [sidebarItems, currentPathname]);
|
|
14
|
+
return (_jsx(DashboardSidebarActiveItemContext.Provider, { value: activePath, children: children }));
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Reads the current page from the consumer's `usePathname` hook. Kept as its
|
|
18
|
+
* own component so `DashboardLayout` can choose between this and the plain
|
|
19
|
+
* provider without calling a hook conditionally. An explicit
|
|
20
|
+
* `currentPathname` still wins over the hook's value.
|
|
21
|
+
*/
|
|
22
|
+
export function DashboardSidebarActiveItemFromPathnameHookProvider({ usePathname, currentPathname, children, }) {
|
|
23
|
+
const pathname = usePathname();
|
|
24
|
+
return (_jsx(DashboardSidebarActiveItemProvider, { currentPathname: currentPathname ?? pathname, children: children }));
|
|
25
|
+
}
|
|
26
|
+
/** Whether `item` is the menu item for the page currently being viewed. */
|
|
27
|
+
export function useIsDashboardSidebarItemActive(item) {
|
|
28
|
+
const activePath = useContext(DashboardSidebarActiveItemContext);
|
|
29
|
+
return (activePath !== null &&
|
|
30
|
+
normalizeDashboardSidebarPath(item.url) === activePath);
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=dashboard-sidebar-active-item-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboard-sidebar-active-item-context.js","sourceRoot":"","sources":["../../../../../src/components/layout/dashboard-layout/dashboard-sidebar/dashboard-sidebar-active-item-context.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EACL,aAAa,EACb,UAAU,EACV,OAAO,GAGR,MAAM,OAAO,CAAC;AACf,OAAO,EACL,6BAA6B,EAC7B,qCAAqC,GACtC,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,qCAAqC,GAEtC,MAAM,8CAA8C,CAAC;AAGtD;;;GAGG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,aAAa,CAC5D,IAAI,CACL,CAAC;AAQF,MAAM,UAAU,kCAAkC,CAAC,EACjD,eAAe,EACf,QAAQ,GACgC;IACxC,MAAM,YAAY,GAA8C,UAAU,CACxE,qCAAqC,CACtC,CAAC;IACF,MAAM,UAAU,GAAkB,OAAO,CACvC,GAAkB,EAAE,CAClB,qCAAqC,CAAC,YAAY,EAAE,eAAe,CAAC,EACtE,CAAC,YAAY,EAAE,eAAe,CAAC,CAChC,CAAC;IACF,OAAO,CACL,KAAC,iCAAiC,CAAC,QAAQ,IAAC,KAAK,EAAE,UAAU,YAC1D,QAAQ,GACkC,CAC9C,CAAC;AACJ,CAAC;AAOD;;;;;GAKG;AACH,MAAM,UAAU,kDAAkD,CAAC,EACjE,WAAW,EACX,eAAe,EACf,QAAQ,GACgD;IACxD,MAAM,QAAQ,GAAW,WAAW,EAAE,CAAC;IACvC,OAAO,CACL,KAAC,kCAAkC,IACjC,eAAe,EAAE,eAAe,IAAI,QAAQ,YAE3C,QAAQ,GAC0B,CACtC,CAAC;AACJ,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,+BAA+B,CAC7C,IAAoC;IAEpC,MAAM,UAAU,GAAkB,UAAU,CAC1C,iCAAiC,CAClC,CAAC;IACF,OAAO,CACL,UAAU,KAAK,IAAI;QACnB,6BAA6B,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,UAAU,CACvD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { CSSProperties, ReactElement } from "react";
|
|
2
|
+
/** Colour for the active row's icon, which draws in `currentColor`. */
|
|
3
|
+
export declare const DASHBOARD_SIDEBAR_ACTIVE_ICON_STYLE: CSSProperties;
|
|
4
|
+
/** The active row's label: bold, with the gradient clipped to its glyphs. */
|
|
5
|
+
export declare const DASHBOARD_SIDEBAR_ACTIVE_LABEL_CLASSNAME: string;
|
|
6
|
+
export declare const DASHBOARD_SIDEBAR_ACTIVE_LABEL_STYLE: CSSProperties;
|
|
7
|
+
export interface DashboardSidebarActiveItemIndicatorProps {
|
|
8
|
+
reducedMotion: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The decoration painted behind the active row's icon and label: a gradient
|
|
12
|
+
* wash across the row and a glowing gradient bar on its left edge. The bar
|
|
13
|
+
* grows in from its centre and the wash fades in when a row becomes active.
|
|
14
|
+
*
|
|
15
|
+
* Render it as the first child of the row's link. Both layers are absolutely
|
|
16
|
+
* positioned with a negative z-index, so the link must be `relative isolate`:
|
|
17
|
+
* they then sit above the link's own hover background but beneath its
|
|
18
|
+
* content, and never shift the icon column or the label.
|
|
19
|
+
*/
|
|
20
|
+
export declare function DashboardSidebarActiveItemIndicator({ reducedMotion, }: DashboardSidebarActiveItemIndicatorProps): ReactElement;
|
|
21
|
+
export default DashboardSidebarActiveItemIndicator;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { m } from "../../../../framer-motion";
|
|
4
|
+
import { cn } from "../../../../lib/utils";
|
|
5
|
+
/**
|
|
6
|
+
* The two accent colours of the active row's gradient: the
|
|
7
|
+
* `--sidebar-active-start` / `--sidebar-active-end` tokens from
|
|
8
|
+
* `@schemavaults/theme` 0.30.0+. They default to the brand blue and red, and a
|
|
9
|
+
* deployment re-themes them with `--sv-theme-{light,dark}-sidebar-active-*`
|
|
10
|
+
* or the matching `THEME_*` environment variables. The brand-colour fallbacks
|
|
11
|
+
* keep the gradient intact in an application whose `globals.css` still comes
|
|
12
|
+
* from an older theme.
|
|
13
|
+
*/
|
|
14
|
+
const ACTIVE_START_COLOR = "var(--sidebar-active-start, var(--schemavaults-brand-blue))";
|
|
15
|
+
const ACTIVE_END_COLOR = "var(--sidebar-active-end, var(--schemavaults-brand-red))";
|
|
16
|
+
/**
|
|
17
|
+
* An accent made safe for text and icons. The accents are picked for
|
|
18
|
+
* vibrancy, not legibility — the default brand blue is 2.5:1 on white — so
|
|
19
|
+
* text uses each one mixed 60/40 with the page foreground. That darkens it on
|
|
20
|
+
* a light background and lightens it on a dark one: the default pair reads at
|
|
21
|
+
* 5.6:1 or better on the tinted row in both modes.
|
|
22
|
+
*/
|
|
23
|
+
function legibleAccent(accent) {
|
|
24
|
+
return `color-mix(in oklab, ${accent} 60%, hsl(var(--foreground)))`;
|
|
25
|
+
}
|
|
26
|
+
/** Colour for the active row's icon, which draws in `currentColor`. */
|
|
27
|
+
export const DASHBOARD_SIDEBAR_ACTIVE_ICON_STYLE = {
|
|
28
|
+
color: legibleAccent(ACTIVE_START_COLOR),
|
|
29
|
+
};
|
|
30
|
+
/** The active row's label: bold, with the gradient clipped to its glyphs. */
|
|
31
|
+
export const DASHBOARD_SIDEBAR_ACTIVE_LABEL_CLASSNAME = "font-semibold bg-clip-text text-transparent";
|
|
32
|
+
export const DASHBOARD_SIDEBAR_ACTIVE_LABEL_STYLE = {
|
|
33
|
+
backgroundImage: `linear-gradient(90deg, ${legibleAccent(ACTIVE_START_COLOR)}, ${legibleAccent(ACTIVE_END_COLOR)})`,
|
|
34
|
+
};
|
|
35
|
+
// How strongly the fill is tinted. Set per mode by the classes on the fill: a
|
|
36
|
+
// dark background needs more of the accent for the same visible wash.
|
|
37
|
+
const TINT = "var(--dashboard-sidebar-active-tint)";
|
|
38
|
+
// A wash of the start colour that shades into the end colour and fades out
|
|
39
|
+
// before the row's right edge.
|
|
40
|
+
const FILL_STYLE = {
|
|
41
|
+
backgroundImage: `linear-gradient(90deg, color-mix(in oklab, ${ACTIVE_START_COLOR} ${TINT}, transparent), color-mix(in oklab, ${ACTIVE_END_COLOR} calc(${TINT} * 0.75), transparent) 70%, transparent)`,
|
|
42
|
+
};
|
|
43
|
+
// A pill down the left edge running from one accent to the other, with a soft
|
|
44
|
+
// glow of each around it.
|
|
45
|
+
const BAR_STYLE = {
|
|
46
|
+
backgroundImage: `linear-gradient(180deg, ${ACTIVE_START_COLOR}, ${ACTIVE_END_COLOR})`,
|
|
47
|
+
boxShadow: `0 -2px 10px color-mix(in oklab, ${ACTIVE_START_COLOR} 55%, transparent), 0 4px 12px color-mix(in oklab, ${ACTIVE_END_COLOR} 40%, transparent)`,
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* The decoration painted behind the active row's icon and label: a gradient
|
|
51
|
+
* wash across the row and a glowing gradient bar on its left edge. The bar
|
|
52
|
+
* grows in from its centre and the wash fades in when a row becomes active.
|
|
53
|
+
*
|
|
54
|
+
* Render it as the first child of the row's link. Both layers are absolutely
|
|
55
|
+
* positioned with a negative z-index, so the link must be `relative isolate`:
|
|
56
|
+
* they then sit above the link's own hover background but beneath its
|
|
57
|
+
* content, and never shift the icon column or the label.
|
|
58
|
+
*/
|
|
59
|
+
export function DashboardSidebarActiveItemIndicator({ reducedMotion, }) {
|
|
60
|
+
const duration = reducedMotion ? 0 : 0.3;
|
|
61
|
+
return (_jsxs(_Fragment, { children: [_jsx(m.span, { "aria-hidden": "true", "data-slot": "dashboard-sidebar-active-item-wash", className: cn("absolute inset-0 -z-10 pointer-events-none", "[--dashboard-sidebar-active-tint:16%] dark:[--dashboard-sidebar-active-tint:24%]"), style: FILL_STYLE, initial: { opacity: 0 }, animate: { opacity: 1 }, transition: { duration } }), _jsx(m.span, { "aria-hidden": "true", "data-slot": "dashboard-sidebar-active-item-bar", className: "absolute inset-y-1 left-0 w-1 -z-10 rounded-r-full pointer-events-none", style: BAR_STYLE, initial: { scaleY: 0 }, animate: { scaleY: 1 }, transition: { duration, ease: "easeOut" } })] }));
|
|
62
|
+
}
|
|
63
|
+
export default DashboardSidebarActiveItemIndicator;
|
|
64
|
+
//# sourceMappingURL=dashboard-sidebar-active-item-indicator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboard-sidebar-active-item-indicator.js","sourceRoot":"","sources":["../../../../../src/components/layout/dashboard-layout/dashboard-sidebar/dashboard-sidebar-active-item-indicator.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,OAAO,EAAE,CAAC,EAAE,MAAM,iBAAiB,CAAC;AACpC,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC;;;;;;;;GAQG;AACH,MAAM,kBAAkB,GACtB,6DAA6D,CAAC;AAChE,MAAM,gBAAgB,GACpB,0DAA0D,CAAC;AAE7D;;;;;;GAMG;AACH,SAAS,aAAa,CAAC,MAAc;IACnC,OAAO,uBAAuB,MAAM,+BAA+B,CAAC;AACtE,CAAC;AAED,uEAAuE;AACvE,M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C,wEAAwE,EAClF,KAAK,EAAE,SAAS,EAChB,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,EACtB,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,EACtB,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,GACzC,IACD,CACJ,CAAC;AACJ,CAAC;AAED,eAAe,mCAAmC,CAAC"}
|
package/dist/components/layout/dashboard-layout/dashboard-sidebar/dashboard-sidebar-active-item.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { DashboardSidebarItemDefinition } from "./dashboard-sidebar-item-definition";
|
|
2
|
+
import type { DashboardSidebarItemGroupDefinition } from "./dashboard-sidebar-item-group";
|
|
3
|
+
/**
|
|
4
|
+
* Reduce an href to the path the sidebar compares on: the query string and
|
|
5
|
+
* fragment are dropped, and trailing slashes are trimmed so `/settings/` and
|
|
6
|
+
* `/settings` are the same page.
|
|
7
|
+
*
|
|
8
|
+
* Only root-relative paths take part in matching. Anything else — `#`, an
|
|
9
|
+
* empty string, a relative path, or an absolute URL to another site — returns
|
|
10
|
+
* `null` and is never marked active: the layout only knows the pathname of
|
|
11
|
+
* the current page, not its origin, so it cannot tell whether such a link
|
|
12
|
+
* points here.
|
|
13
|
+
*/
|
|
14
|
+
export declare function normalizeDashboardSidebarPath(href: string): string | null;
|
|
15
|
+
/**
|
|
16
|
+
* Whether `currentPath` is the page at `itemPath` or a page nested beneath
|
|
17
|
+
* it, e.g. `/settings/billing` is within `/settings`. The root path `/` only
|
|
18
|
+
* matches itself; otherwise a "Home" item would claim every page.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isDashboardSidebarPathWithin(itemPath: string, currentPath: string): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Pick the single sidebar path that best describes the current page: the
|
|
23
|
+
* longest item path that the current path equals or is nested beneath.
|
|
24
|
+
* Longest-wins means that with both `/settings` and `/settings/billing` in
|
|
25
|
+
* the menu, only "Billing" lights up on `/settings/billing`, while
|
|
26
|
+
* `/settings/profile` (not in the menu) still falls back to "Settings".
|
|
27
|
+
*
|
|
28
|
+
* Returns the normalized path rather than an item, so that every item
|
|
29
|
+
* pointing at that page is marked — a link can legitimately appear in two
|
|
30
|
+
* groups.
|
|
31
|
+
*/
|
|
32
|
+
export declare function resolveActiveDashboardSidebarItemPath(entries: readonly (DashboardSidebarItemDefinition | DashboardSidebarItemGroupDefinition)[], currentHref: string | null | undefined): string | null;
|
package/dist/components/layout/dashboard-layout/dashboard-sidebar/dashboard-sidebar-active-item.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reduce an href to the path the sidebar compares on: the query string and
|
|
3
|
+
* fragment are dropped, and trailing slashes are trimmed so `/settings/` and
|
|
4
|
+
* `/settings` are the same page.
|
|
5
|
+
*
|
|
6
|
+
* Only root-relative paths take part in matching. Anything else — `#`, an
|
|
7
|
+
* empty string, a relative path, or an absolute URL to another site — returns
|
|
8
|
+
* `null` and is never marked active: the layout only knows the pathname of
|
|
9
|
+
* the current page, not its origin, so it cannot tell whether such a link
|
|
10
|
+
* points here.
|
|
11
|
+
*/
|
|
12
|
+
export function normalizeDashboardSidebarPath(href) {
|
|
13
|
+
const path = href.split("#")[0].split("?")[0];
|
|
14
|
+
if (!path.startsWith("/") || path.startsWith("//")) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
const trimmed = path.replace(/\/+$/, "");
|
|
18
|
+
return trimmed.length > 0 ? trimmed : "/";
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Whether `currentPath` is the page at `itemPath` or a page nested beneath
|
|
22
|
+
* it, e.g. `/settings/billing` is within `/settings`. The root path `/` only
|
|
23
|
+
* matches itself; otherwise a "Home" item would claim every page.
|
|
24
|
+
*/
|
|
25
|
+
export function isDashboardSidebarPathWithin(itemPath, currentPath) {
|
|
26
|
+
if (currentPath === itemPath) {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
return itemPath !== "/" && currentPath.startsWith(`${itemPath}/`);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Pick the single sidebar path that best describes the current page: the
|
|
33
|
+
* longest item path that the current path equals or is nested beneath.
|
|
34
|
+
* Longest-wins means that with both `/settings` and `/settings/billing` in
|
|
35
|
+
* the menu, only "Billing" lights up on `/settings/billing`, while
|
|
36
|
+
* `/settings/profile` (not in the menu) still falls back to "Settings".
|
|
37
|
+
*
|
|
38
|
+
* Returns the normalized path rather than an item, so that every item
|
|
39
|
+
* pointing at that page is marked — a link can legitimately appear in two
|
|
40
|
+
* groups.
|
|
41
|
+
*/
|
|
42
|
+
export function resolveActiveDashboardSidebarItemPath(entries, currentHref) {
|
|
43
|
+
if (typeof currentHref !== "string") {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
const currentPath = normalizeDashboardSidebarPath(currentHref);
|
|
47
|
+
if (currentPath === null) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
const items = entries.flatMap((entry) => entry.type === "dashboard-sidebar-item-group" ? entry.items : [entry]);
|
|
51
|
+
let best = null;
|
|
52
|
+
for (const item of items) {
|
|
53
|
+
const itemPath = normalizeDashboardSidebarPath(item.url);
|
|
54
|
+
if (itemPath !== null &&
|
|
55
|
+
isDashboardSidebarPathWithin(itemPath, currentPath) &&
|
|
56
|
+
(best === null || itemPath.length > best.length)) {
|
|
57
|
+
best = itemPath;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return best;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=dashboard-sidebar-active-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dashboard-sidebar-active-item.js","sourceRoot":"","sources":["../../../../../src/components/layout/dashboard-layout/dashboard-sidebar/dashboard-sidebar-active-item.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,6BAA6B,CAAC,IAA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I,CAAC;IAC/B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,QAAQ,GAAkB,6BAA6B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACxE,IACE,QAAQ,KAAK,IAAI;YACjB,4BAA4B,CAAC,QAAQ,EAAE,WAAW,CAAC;YACnD,CAAC,IAAI,KAAK,IAAI,IAAI,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,EAChD,CAAC;YACD,IAAI,GAAG,QAAQ,CAAC;QAClB,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/components/layout/dashboard-layout/dashboard-sidebar/dashboard-sidebar-item-renderer.js
CHANGED
|
@@ -11,6 +11,8 @@ import { DashboardSidebarAdminOnlyItemsContext } from "./dashboard-sidebar-admin
|
|
|
11
11
|
import { Tooltip, TooltipContent, TooltipTrigger, TooltipArrow, } from "../../../ui";
|
|
12
12
|
import useDashboardSidebarOpenStateDispatch from "./useDashboardSidebarOpenStateDispatch";
|
|
13
13
|
import useDebug from "../../../hooks/use-debug";
|
|
14
|
+
import { useIsDashboardSidebarItemActive } from "./dashboard-sidebar-active-item-context";
|
|
15
|
+
import { DASHBOARD_SIDEBAR_ACTIVE_ICON_STYLE, DASHBOARD_SIDEBAR_ACTIVE_LABEL_CLASSNAME, DASHBOARD_SIDEBAR_ACTIVE_LABEL_STYLE, DashboardSidebarActiveItemIndicator, } from "./dashboard-sidebar-active-item-indicator";
|
|
14
16
|
export function DashboardSidebarItemRenderer({ item, Link, }) {
|
|
15
17
|
const debug = useDebug();
|
|
16
18
|
const { open, mobile } = useDashboardSidebarOpenState();
|
|
@@ -23,12 +25,29 @@ export function DashboardSidebarItemRenderer({ item, Link, }) {
|
|
|
23
25
|
// over values this component already has.
|
|
24
26
|
const transitionTime = useToggleDashboardLayoutCollapsedTransitionTime();
|
|
25
27
|
const showItemLabel = mobile || open;
|
|
28
|
+
const active = useIsDashboardSidebarItemActive(item);
|
|
26
29
|
const IconComponent = item.icon;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
+
// The active row takes the gradient's accents on its icon and label. Admin
|
|
31
|
+
// rows keep their red instead, active or not: red is what marks them as
|
|
32
|
+
// admin-only, and the row's gradient backdrop already says "active".
|
|
33
|
+
const showActiveAccents = active && !isAdminItemGroup;
|
|
34
|
+
let iconClassName;
|
|
35
|
+
let labelClassName;
|
|
36
|
+
if (isAdminItemGroup) {
|
|
37
|
+
iconClassName = "text-red-500";
|
|
38
|
+
labelClassName = cn("text-red-500", active && "font-semibold");
|
|
39
|
+
}
|
|
40
|
+
else if (active) {
|
|
41
|
+
// No colour class: the icon inherits the accent from its wrapper below.
|
|
42
|
+
iconClassName = "";
|
|
43
|
+
labelClassName = DASHBOARD_SIDEBAR_ACTIVE_LABEL_CLASSNAME;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
iconClassName = "text-foreground";
|
|
47
|
+
labelClassName = "text-foreground";
|
|
48
|
+
}
|
|
30
49
|
function SidebarMenuItemTitle() {
|
|
31
|
-
return (_jsx(m.span, { className: cn(
|
|
50
|
+
return (_jsx(m.span, { className: cn(labelClassName, "text-nowrap"), style: showActiveAccents ? DASHBOARD_SIDEBAR_ACTIVE_LABEL_STYLE : undefined, initial: {
|
|
32
51
|
opacity: 1,
|
|
33
52
|
scale: 1,
|
|
34
53
|
transitionEnd: {
|
|
@@ -54,7 +73,7 @@ export function DashboardSidebarItemRenderer({ item, Link, }) {
|
|
|
54
73
|
// which have always had it. Without it, ungrouped rows snapped into
|
|
55
74
|
// place while grouped rows glided. Under reduced motion every row
|
|
56
75
|
// snaps instead, which is the point.
|
|
57
|
-
layout: !reducedMotion, className: cn("w-full", sizes.sidebar_menu_item_height_classname,
|
|
76
|
+
layout: !reducedMotion, "data-active": active ? "true" : undefined, className: cn("w-full", sizes.sidebar_menu_item_height_classname,
|
|
58
77
|
// The menu <nav> is a flex column with a definite height (it grows
|
|
59
78
|
// inside an h-screen sidebar) and its own scrollbar. Flex children
|
|
60
79
|
// shrink by default, so once the menu overflowed, rows squashed
|
|
@@ -63,10 +82,15 @@ export function DashboardSidebarItemRenderer({ item, Link, }) {
|
|
|
63
82
|
// the ungrouped rows collapsed. That is the "different spacing"
|
|
64
83
|
// between plain and grouped links. Opt out of shrinking, like the
|
|
65
84
|
// sidebar header and footer already do.
|
|
66
|
-
"flex-shrink-0"), children: _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { className: cn("w-full h-full"), children: _jsxs(Link, { href: item.url, className: cn("flex flex-row flex-nowrap", "justify-start items-center", "w-full h-full",
|
|
85
|
+
"flex-shrink-0"), children: _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { className: cn("w-full h-full"), children: _jsxs(Link, { href: item.url, "aria-current": active ? "page" : undefined, className: cn("flex flex-row flex-nowrap", "justify-start items-center", "w-full h-full",
|
|
67
86
|
// Theme token rather than a hardcoded gray: bg-gray-200 was
|
|
68
87
|
// near-invisible against a dark background.
|
|
69
|
-
"hover:bg-accent transition-colors"
|
|
88
|
+
"hover:bg-accent transition-colors",
|
|
89
|
+
// Positioning context for the active indicator below. `isolate`
|
|
90
|
+
// makes the link its own stacking context, so the indicator's
|
|
91
|
+
// negative z-index puts it above the link's hover background
|
|
92
|
+
// but beneath the icon and label.
|
|
93
|
+
"relative isolate"), onClick: () => {
|
|
70
94
|
if (debug) {
|
|
71
95
|
console.log("[DashboardSidebarItemRenderer] onClick(item), where item = ", item);
|
|
72
96
|
}
|
|
@@ -86,7 +110,7 @@ export function DashboardSidebarItemRenderer({ item, Link, }) {
|
|
|
86
110
|
if (mobile) {
|
|
87
111
|
setSidebarOpen(false);
|
|
88
112
|
}
|
|
89
|
-
}, children: [_jsx(m.div, { className: cn("flex-shrink-0", sizes.desktop_collapsed_width_classname, "flex items-center justify-center"), children: _jsx(IconComponent, { className: cn("h-6 w-6",
|
|
113
|
+
}, children: [active && (_jsx(DashboardSidebarActiveItemIndicator, { reducedMotion: reducedMotion })), _jsx(m.div, { className: cn("flex-shrink-0", sizes.desktop_collapsed_width_classname, "flex items-center justify-center"), style: showActiveAccents ? DASHBOARD_SIDEBAR_ACTIVE_ICON_STYLE : undefined, children: _jsx(IconComponent, { className: cn("h-6 w-6", iconClassName) }) }), _jsx(AnimatePresence, { children: showItemLabel && _jsx(SidebarMenuItemTitle, {}, item.title) })] }) }), _jsxs(TooltipContent, { side: "right", children: [item.tooltip ?? item.title, _jsx(TooltipArrow, {})] })] }) }, item.title));
|
|
90
114
|
}
|
|
91
115
|
export default DashboardSidebarItemRenderer;
|
|
92
116
|
//# sourceMappingURL=dashboard-sidebar-item-renderer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dashboard-sidebar-item-renderer.js","sourceRoot":"","sources":["../../../../../src/components/layout/dashboard-layout/dashboard-sidebar/dashboard-sidebar-item-renderer.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,UAAU,EAAqB,MAAM,OAAO,CAAC;AAGtD,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,+CAA+C,MAAM,oDAAoD,CAAC;AACjH,OAAO,+BAA+B,MAAM,oCAAoC,CAAC;AACjF,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,4BAA4B,MAAM,gCAAgC,CAAC;AAC1E,OAAO,yBAAyB,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,qCAAqC,EAAE,MAAM,8CAA8C,CAAC;AACrG,OAAO,EACL,OAAO,EACP,cAAc,EACd,cAAc,EACd,YAAY,GACb,MAAM,iBAAiB,CAAC;AAEzB,OAAO,oCAAoC,MAAM,wCAAwC,CAAC;AAC1F,OAAO,QAAQ,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"dashboard-sidebar-item-renderer.js","sourceRoot":"","sources":["../../../../../src/components/layout/dashboard-layout/dashbo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B,IAAI,MAAM,EAAE,CAAC;gCACX,cAAc,CAAC,KAAK,CAAC,CAAC;4BACxB,CAAC;wBACH,CAAC,aAEA,MAAM,IAAI,CACT,KAAC,mCAAmC,IAClC,aAAa,EAAE,aAAa,GAC5B,CACH,EACD,KAAC,CAAC,CAAC,GAAG,IACJ,SAAS,EAAE,EAAE,CACX,eAAe,EACf,KAAK,CAAC,iCAAiC,EACvC,kCAAkC,CACnC,EACD,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,mCAAmC,CAAC,CAAC,CAAC,SAAS,YAE1E,KAAC,aAAa,IAAC,SAAS,EAAE,EAAE,CAAC,SAAS,EAAE,aAAa,CAAC,GAAI,GACpD,EAER,KAAC,eAAe,cACb,aAAa,IAAI,KAAC,oBAAoB,MAAM,IAAI,CAAC,KAAK,CAAI,GAC3C,IACb,GACQ,EACjB,MAAC,cAAc,IAAC,IAAI,EAAC,OAAO,aACzB,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,KAAK,EAC3B,KAAC,YAAY,KAAG,IACD,IACT,IA1FL,IAAI,CAAC,KAAK,CA2FV,CACR,CAAC;AACJ,CAAC;AAED,eAAe,4BAA4B,CAAC"}
|
|
@@ -11,3 +11,5 @@ export type { DashboardSidebarItemsAndGroupsDefinitions } from "./dashboard-side
|
|
|
11
11
|
export type { DashboardLayoutSidebarSizing } from "./dashboard-sidebar-sizing";
|
|
12
12
|
export { DASHBOARD_SIDEBAR_OPEN_WIDTH_CSS_VARIABLE, DEFAULT_DASHBOARD_SIDEBAR_OPEN_WIDTH, DEFAULT_LEADING_SIDEBAR_MENU_GROUP_LABEL_TOP_PADDING, } from "./dashboard-sidebar-sizing";
|
|
13
13
|
export type { IDashboardSidebarOpenStateContextType } from "./dashboard-sidebar-open-state";
|
|
14
|
+
export { resolveActiveDashboardSidebarItemPath } from "./dashboard-sidebar-active-item";
|
|
15
|
+
export { DashboardSidebarActiveItemProvider, DashboardSidebarActiveItemFromPathnameHookProvider, } from "./dashboard-sidebar-active-item-context";
|
|
@@ -6,4 +6,6 @@ export { useDashboardSidebarOpenStateDispatch } from "./useDashboardSidebarOpenS
|
|
|
6
6
|
export { useCloseDashboardSidebarOnRouteChange } from "./useCloseDashboardSidebarOnRouteChange";
|
|
7
7
|
export { DashboardSidebarContextProvider } from "./dashboard-sidebar-context-provider";
|
|
8
8
|
export { DASHBOARD_SIDEBAR_OPEN_WIDTH_CSS_VARIABLE, DEFAULT_DASHBOARD_SIDEBAR_OPEN_WIDTH, DEFAULT_LEADING_SIDEBAR_MENU_GROUP_LABEL_TOP_PADDING, } from "./dashboard-sidebar-sizing";
|
|
9
|
+
export { resolveActiveDashboardSidebarItemPath } from "./dashboard-sidebar-active-item";
|
|
10
|
+
export { DashboardSidebarActiveItemProvider, DashboardSidebarActiveItemFromPathnameHookProvider, } from "./dashboard-sidebar-active-item-context";
|
|
9
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/components/layout/dashboard-layout/dashboard-sidebar/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,gBAAgB,IAAI,OAAO,GAC5B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAEnF,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,oCAAoC,EAAE,MAAM,wCAAwC,CAAC;AAC9F,OAAO,EAAE,qCAAqC,EAAE,MAAM,yCAAyC,CAAC;AAEhG,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AAMvF,OAAO,EACL,yCAAyC,EACzC,oCAAoC,EACpC,oDAAoD,GACrD,MAAM,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/components/layout/dashboard-layout/dashboard-sidebar/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,gBAAgB,IAAI,OAAO,GAC5B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAEnF,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,oCAAoC,EAAE,MAAM,wCAAwC,CAAC;AAC9F,OAAO,EAAE,qCAAqC,EAAE,MAAM,yCAAyC,CAAC;AAEhG,OAAO,EAAE,+BAA+B,EAAE,MAAM,sCAAsC,CAAC;AAMvF,OAAO,EACL,yCAAyC,EACzC,oCAAoC,EACpC,oDAAoD,GACrD,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,qCAAqC,EAAE,MAAM,iCAAiC,CAAC;AACxF,OAAO,EACL,kCAAkC,EAClC,kDAAkD,GACnD,MAAM,yCAAyC,CAAC"}
|
|
@@ -7,4 +7,5 @@ export { DEFAULT_DASHBOARD_LAYOUT_REDUCED_MOTION_SETTING } from "./dashboard-lay
|
|
|
7
7
|
export { useDashboardLayoutReducedMotion } from "./useDashboardLayoutReducedMotion";
|
|
8
8
|
export { useDashboardSidebarOpenState, useDashboardSidebarOpenStateDispatch, useCloseDashboardSidebarOnRouteChange, } from "./dashboard-sidebar";
|
|
9
9
|
export type { DashboardSidebarItemDefinition, DashboardSidebarItemGroupDefinition, DashboardSidebarItemsAndGroupsDefinitions, } from "./dashboard-sidebar";
|
|
10
|
+
export { resolveActiveDashboardSidebarItemPath } from "./dashboard-sidebar";
|
|
10
11
|
export { DASHBOARD_SIDEBAR_OPEN_WIDTH_CSS_VARIABLE, DEFAULT_DASHBOARD_SIDEBAR_OPEN_WIDTH, DEFAULT_LEADING_SIDEBAR_MENU_GROUP_LABEL_TOP_PADDING, } from "./dashboard-sidebar";
|
|
@@ -5,5 +5,6 @@ export { DEFAULT_DASHBOARD_LAYOUT_REDUCED_MOTION_SETTING } from "./dashboard-lay
|
|
|
5
5
|
// the motion of the layout chrome they are rendered into.
|
|
6
6
|
export { useDashboardLayoutReducedMotion } from "./useDashboardLayoutReducedMotion";
|
|
7
7
|
export { useDashboardSidebarOpenState, useDashboardSidebarOpenStateDispatch, useCloseDashboardSidebarOnRouteChange, } from "./dashboard-sidebar";
|
|
8
|
+
export { resolveActiveDashboardSidebarItemPath } from "./dashboard-sidebar";
|
|
8
9
|
export { DASHBOARD_SIDEBAR_OPEN_WIDTH_CSS_VARIABLE, DEFAULT_DASHBOARD_SIDEBAR_OPEN_WIDTH, DEFAULT_LEADING_SIDEBAR_MENU_GROUP_LABEL_TOP_PADDING, } from "./dashboard-sidebar";
|
|
9
10
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/layout/dashboard-layout/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AAEnC,OAAO,EAAE,eAAe,IAAI,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAKhE,OAAO,EAAE,+CAA+C,EAAE,MAAM,mCAAmC,CAAC;AACpG,8EAA8E;AAC9E,0DAA0D;AAC1D,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AAEpF,OAAO,EACL,4BAA4B,EAC5B,oCAAoC,EACpC,qCAAqC,GACtC,MAAM,qBAAqB,CAAC;AAM7B,OAAO,EACL,yCAAyC,EACzC,oCAAoC,EACpC,oDAAoD,GACrD,MAAM,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/layout/dashboard-layout/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AAEnC,OAAO,EAAE,eAAe,IAAI,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAKhE,OAAO,EAAE,+CAA+C,EAAE,MAAM,mCAAmC,CAAC;AACpG,8EAA8E;AAC9E,0DAA0D;AAC1D,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AAEpF,OAAO,EACL,4BAA4B,EAC5B,oCAAoC,EACpC,qCAAqC,GACtC,MAAM,qBAAqB,CAAC;AAM7B,OAAO,EAAE,qCAAqC,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EACL,yCAAyC,EACzC,oCAAoC,EACpC,oDAAoD,GACrD,MAAM,qBAAqB,CAAC"}
|
|
@@ -206,6 +206,8 @@ export * from "./histogram";
|
|
|
206
206
|
export type * from "./histogram";
|
|
207
207
|
export * from "./bar-list";
|
|
208
208
|
export type * from "./bar-list";
|
|
209
|
+
export * from "./treemap";
|
|
210
|
+
export type * from "./treemap";
|
|
209
211
|
export * from "./comparison-slider";
|
|
210
212
|
export type * from "./comparison-slider";
|
|
211
213
|
export * from "./theme-selector";
|
|
@@ -102,6 +102,7 @@ export * from "./funnel-chart";
|
|
|
102
102
|
export * from "./scatter-plot";
|
|
103
103
|
export * from "./histogram";
|
|
104
104
|
export * from "./bar-list";
|
|
105
|
+
export * from "./treemap";
|
|
105
106
|
export * from "./comparison-slider";
|
|
106
107
|
export * from "./theme-selector";
|
|
107
108
|
export * from "./tree-view";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/ui/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AAGzB,cAAc,uBAAuB,CAAC;AAGtC,cAAc,aAAa,CAAC;AAG5B,cAAc,eAAe,CAAC;AAG9B,cAAc,SAAS,CAAC;AAGxB,cAAc,WAAW,CAAC;AAG1B,cAAc,cAAc,CAAC;AAG7B,cAAc,SAAS,CAAC;AAGxB,cAAc,mBAAmB,CAAC;AAGlC,cAAc,0BAA0B,CAAC;AAGzC,cAAc,UAAU,CAAC;AAGzB,cAAc,SAAS,CAAC;AAGxB,cAAc,kBAAkB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B,CAAC;AAGpC,cAAc,iBAAiB,CAAC;AAGhC,cAAc,kBAAkB,CAAC;AAGjC,cAAc,gBAAgB,CAAC;AAG/B,cAAc,eAAe,CAAC;AAG9B,cAAc,gBAAgB,CAAC;AAG/B,cAAc,UAAU,CAAC;AAGzB,cAAc,WAAW,CAAC;AAG1B,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/ui/treemap/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,eAAe,EACf,cAAc,EACd,eAAe,EACf,iBAAiB,GAClB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { type VariantProps } from "class-variance-authority";
|
|
2
|
+
import type { HTMLAttributes, KeyboardEvent, MouseEvent, ReactElement, ReactNode, Ref } from "react";
|
|
3
|
+
export declare const treeMapSizeIds: ["sm", "md", "lg", "xl"];
|
|
4
|
+
export type TreeMapSizeId = (typeof treeMapSizeIds)[number];
|
|
5
|
+
export declare const treeMapColorIds: ["default", "primary", "positive", "warning", "destructive", "muted"];
|
|
6
|
+
export type TreeMapColorId = (typeof treeMapColorIds)[number];
|
|
7
|
+
/**
|
|
8
|
+
* How a tile is painted.
|
|
9
|
+
*
|
|
10
|
+
* - `"soft"` — translucent fill behind a solid border. The default; labels sit
|
|
11
|
+
* on a near-background surface, so they keep full `foreground` contrast.
|
|
12
|
+
* - `"solid"` — full-strength fill. Labels get a `background`-colored halo
|
|
13
|
+
* (`paint-order: stroke`) so they stay legible on top of saturated brand
|
|
14
|
+
* colors in both light and dark mode.
|
|
15
|
+
* - `"outline"` — border only, no fill. Useful when the treemap is layered
|
|
16
|
+
* over an existing surface, or when the tiles are annotations rather than
|
|
17
|
+
* the primary subject of the chart.
|
|
18
|
+
*/
|
|
19
|
+
export declare const treeMapVariantIds: ["soft", "solid", "outline"];
|
|
20
|
+
export type TreeMapVariantId = (typeof treeMapVariantIds)[number];
|
|
21
|
+
export declare const treeMapVariants: (props?: ({
|
|
22
|
+
size?: "sm" | "lg" | "xl" | "md" | null | undefined;
|
|
23
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
24
|
+
export interface TreeMapNode {
|
|
25
|
+
/** Stable identifier. Used as the React key and in the click payload. */
|
|
26
|
+
id: string;
|
|
27
|
+
/** Human-readable name rendered inside the tile, when it fits. */
|
|
28
|
+
label?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Magnitude of this node. Ignored when `children` is non-empty — a branch is
|
|
31
|
+
* always worth the sum of its children. Negative and non-finite values are
|
|
32
|
+
* treated as `0`, and zero-valued nodes are omitted from the layout.
|
|
33
|
+
*/
|
|
34
|
+
value?: number;
|
|
35
|
+
/** Child nodes, laid out inside this node's tile. */
|
|
36
|
+
children?: ReadonlyArray<TreeMapNode>;
|
|
37
|
+
/**
|
|
38
|
+
* Preset color id from the chart palette. Inherited by descendants that
|
|
39
|
+
* don't set their own. Ignored if `fill` is provided.
|
|
40
|
+
*/
|
|
41
|
+
color?: TreeMapColorId;
|
|
42
|
+
/**
|
|
43
|
+
* Override the fill and border with a raw CSS color (e.g. `"#ff0080"` or
|
|
44
|
+
* `"hsl(var(--chart-1))"`). Takes precedence over `color`, and is *not*
|
|
45
|
+
* inherited by descendants.
|
|
46
|
+
*/
|
|
47
|
+
fill?: string;
|
|
48
|
+
/** Extra classes applied to this node's `<rect>`. */
|
|
49
|
+
className?: string;
|
|
50
|
+
/** Fired when this tile is clicked or activated via keyboard. */
|
|
51
|
+
onClick?: (node: TreeMapNode, event: MouseEvent<SVGRectElement> | KeyboardEvent<SVGRectElement>) => void;
|
|
52
|
+
}
|
|
53
|
+
export interface TreeMapTileContext {
|
|
54
|
+
node: TreeMapNode;
|
|
55
|
+
/** The node's own value, or the sum of its subtree for a branch. */
|
|
56
|
+
value: number;
|
|
57
|
+
/** Share of the chart total, in the range 0–1. */
|
|
58
|
+
fraction: number;
|
|
59
|
+
/** Nesting level; top-level nodes are `0`. */
|
|
60
|
+
depth: number;
|
|
61
|
+
/** Ancestor ids, root-first, ending with this node's own id. */
|
|
62
|
+
path: ReadonlyArray<string>;
|
|
63
|
+
/** `true` when this node has rendered children inside it. */
|
|
64
|
+
isBranch: boolean;
|
|
65
|
+
/** Tile width in SVG user units. */
|
|
66
|
+
width: number;
|
|
67
|
+
/** Tile height in SVG user units. */
|
|
68
|
+
height: number;
|
|
69
|
+
}
|
|
70
|
+
export interface TreeMapProps extends Omit<HTMLAttributes<HTMLDivElement>, "onClick">, VariantProps<typeof treeMapVariants> {
|
|
71
|
+
/** Nodes to render. Nest via each node's `children`. */
|
|
72
|
+
nodes: ReadonlyArray<TreeMapNode>;
|
|
73
|
+
/** Accessible label describing what the treemap represents. */
|
|
74
|
+
label: string;
|
|
75
|
+
/** Tile paint style. Defaults to `"soft"`. */
|
|
76
|
+
variant?: TreeMapVariantId;
|
|
77
|
+
/** Override the rendered canvas width in pixels (defaults are size-aware). */
|
|
78
|
+
width?: number;
|
|
79
|
+
/** Override the rendered canvas height in pixels (defaults are size-aware). */
|
|
80
|
+
height?: number;
|
|
81
|
+
/**
|
|
82
|
+
* Denominator for every tile's `fraction`. Defaults to the sum of all node
|
|
83
|
+
* values. Useful for pinning several treemaps to a shared scale, or for
|
|
84
|
+
* showing a subset as a share of some known whole.
|
|
85
|
+
*/
|
|
86
|
+
total?: number;
|
|
87
|
+
/**
|
|
88
|
+
* Deepest nesting level to render, 0-based. Nodes below it are collapsed
|
|
89
|
+
* into their deepest rendered ancestor, which keeps its aggregate value.
|
|
90
|
+
* Defaults to rendering the whole tree.
|
|
91
|
+
*/
|
|
92
|
+
maxDepth?: number;
|
|
93
|
+
/**
|
|
94
|
+
* Sort siblings by descending value before laying them out. Defaults to
|
|
95
|
+
* `true`, which is what makes the squarified layout produce compact,
|
|
96
|
+
* near-square tiles. Set to `false` to preserve the input order.
|
|
97
|
+
*/
|
|
98
|
+
sort?: boolean;
|
|
99
|
+
/** Gap between sibling tiles, in pixels. Defaults to `2`. */
|
|
100
|
+
tileGap?: number;
|
|
101
|
+
/** Inner padding between a branch tile and its children. Defaults to `4`. */
|
|
102
|
+
groupPadding?: number;
|
|
103
|
+
/**
|
|
104
|
+
* Height of the band reserved at the top of a labelled branch for its own
|
|
105
|
+
* name. Defaults to `16`. The band is dropped when the branch is too short
|
|
106
|
+
* to spare it.
|
|
107
|
+
*/
|
|
108
|
+
groupHeaderHeight?: number;
|
|
109
|
+
/** Corner radius of every tile, in pixels. Defaults to `3`. */
|
|
110
|
+
cornerRadius?: number;
|
|
111
|
+
/** Render each tile's `label` when it fits. Defaults to `true`. */
|
|
112
|
+
showLabels?: boolean;
|
|
113
|
+
/** Render each tile's value under its label when it fits. Defaults to `true`. */
|
|
114
|
+
showValues?: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Smallest tile width, in SVG units, that may carry a label. Narrower tiles
|
|
117
|
+
* render unlabelled rather than overflowing. Defaults to `48`.
|
|
118
|
+
*/
|
|
119
|
+
minLabelWidth?: number;
|
|
120
|
+
/**
|
|
121
|
+
* Smallest *leaf* tile height, in SVG units, that may carry a label. Shorter
|
|
122
|
+
* leaves render unlabelled. Defaults to `18`. A branch's name lives in its
|
|
123
|
+
* header band instead, which is governed by `groupHeaderHeight`.
|
|
124
|
+
*/
|
|
125
|
+
minLabelHeight?: number;
|
|
126
|
+
/**
|
|
127
|
+
* Fill opacity of a top-level tile, overriding the variant default
|
|
128
|
+
* (`0.18` for `"soft"`, `0.9` for `"solid"`, `0` for `"outline"`).
|
|
129
|
+
*/
|
|
130
|
+
tileFillOpacity?: number;
|
|
131
|
+
/**
|
|
132
|
+
* How much of the parent's fill opacity each nesting level keeps, so nested
|
|
133
|
+
* tiles read as shades of one family. Defaults to `0.55`.
|
|
134
|
+
*/
|
|
135
|
+
depthFillFalloff?: number;
|
|
136
|
+
/** Customize the tile-label text. Return `null` to skip a tile's label. */
|
|
137
|
+
labelFormatter?: (context: TreeMapTileContext) => string | null;
|
|
138
|
+
/**
|
|
139
|
+
* Customize the value text. Return `null` to skip it. Defaults to the
|
|
140
|
+
* locale-formatted value.
|
|
141
|
+
*/
|
|
142
|
+
valueFormatter?: (context: TreeMapTileContext) => string | null;
|
|
143
|
+
/**
|
|
144
|
+
* Fallback handler invoked for any tile that doesn't have its own `onClick`.
|
|
145
|
+
*/
|
|
146
|
+
onNodeClick?: (node: TreeMapNode, event: MouseEvent<SVGRectElement> | KeyboardEvent<SVGRectElement>) => void;
|
|
147
|
+
/** Optional content overlaid on top of the plot area. */
|
|
148
|
+
children?: ReactNode;
|
|
149
|
+
/** Extra classes for the overlay content wrapper. */
|
|
150
|
+
overlayClassName?: string;
|
|
151
|
+
/** Extra classes applied to every tile-label `<text>` element. */
|
|
152
|
+
labelClassName?: string;
|
|
153
|
+
/** Extra classes applied to every value-label `<text>` element. */
|
|
154
|
+
valueClassName?: string;
|
|
155
|
+
/** Optional ref forwarded to the wrapper element. */
|
|
156
|
+
ref?: Ref<HTMLDivElement>;
|
|
157
|
+
}
|
|
158
|
+
declare function TreeMap({ nodes, label, variant, size, width, height, total, maxDepth, sort, tileGap, groupPadding, groupHeaderHeight, cornerRadius, showLabels, showValues, minLabelWidth, minLabelHeight, tileFillOpacity, depthFillFalloff, labelFormatter, valueFormatter, onNodeClick, children, className, overlayClassName, labelClassName, valueClassName, ref, ...props }: TreeMapProps): ReactElement;
|
|
159
|
+
declare namespace TreeMap {
|
|
160
|
+
var displayName: string;
|
|
161
|
+
}
|
|
162
|
+
export { TreeMap };
|
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cva } from "class-variance-authority";
|
|
4
|
+
import { useId } from "react";
|
|
5
|
+
import { cn } from "../../../lib/utils";
|
|
6
|
+
export const treeMapSizeIds = [
|
|
7
|
+
"sm",
|
|
8
|
+
"md",
|
|
9
|
+
"lg",
|
|
10
|
+
"xl",
|
|
11
|
+
];
|
|
12
|
+
export const treeMapColorIds = [
|
|
13
|
+
"default",
|
|
14
|
+
"primary",
|
|
15
|
+
"positive",
|
|
16
|
+
"warning",
|
|
17
|
+
"destructive",
|
|
18
|
+
"muted",
|
|
19
|
+
];
|
|
20
|
+
/**
|
|
21
|
+
* How a tile is painted.
|
|
22
|
+
*
|
|
23
|
+
* - `"soft"` — translucent fill behind a solid border. The default; labels sit
|
|
24
|
+
* on a near-background surface, so they keep full `foreground` contrast.
|
|
25
|
+
* - `"solid"` — full-strength fill. Labels get a `background`-colored halo
|
|
26
|
+
* (`paint-order: stroke`) so they stay legible on top of saturated brand
|
|
27
|
+
* colors in both light and dark mode.
|
|
28
|
+
* - `"outline"` — border only, no fill. Useful when the treemap is layered
|
|
29
|
+
* over an existing surface, or when the tiles are annotations rather than
|
|
30
|
+
* the primary subject of the chart.
|
|
31
|
+
*/
|
|
32
|
+
export const treeMapVariantIds = [
|
|
33
|
+
"soft",
|
|
34
|
+
"solid",
|
|
35
|
+
"outline",
|
|
36
|
+
];
|
|
37
|
+
/** Default canvas dimensions per size. Either axis can be overridden via the
|
|
38
|
+
* `width` / `height` props. */
|
|
39
|
+
const SIZE_TO_CANVAS = {
|
|
40
|
+
sm: { width: 260, height: 180 },
|
|
41
|
+
md: { width: 380, height: 260 },
|
|
42
|
+
lg: { width: 520, height: 340 },
|
|
43
|
+
xl: { width: 680, height: 440 },
|
|
44
|
+
};
|
|
45
|
+
const FILL_CLASSES = {
|
|
46
|
+
default: "fill-schemavaults-brand-blue",
|
|
47
|
+
primary: "fill-primary",
|
|
48
|
+
positive: "fill-emerald-500 dark:fill-emerald-400",
|
|
49
|
+
warning: "fill-warning",
|
|
50
|
+
destructive: "fill-destructive",
|
|
51
|
+
muted: "fill-muted-foreground",
|
|
52
|
+
};
|
|
53
|
+
const STROKE_CLASSES = {
|
|
54
|
+
default: "stroke-schemavaults-brand-blue",
|
|
55
|
+
primary: "stroke-primary",
|
|
56
|
+
positive: "stroke-emerald-500 dark:stroke-emerald-400",
|
|
57
|
+
warning: "stroke-warning",
|
|
58
|
+
destructive: "stroke-destructive",
|
|
59
|
+
muted: "stroke-muted-foreground",
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Fallback color rotation when a top-level node doesn't specify its own color.
|
|
63
|
+
* Index is the node's position among its siblings, modulo the palette length.
|
|
64
|
+
* Descendants inherit their ancestor's color unless they override it, so each
|
|
65
|
+
* branch of the tree reads as one family.
|
|
66
|
+
*/
|
|
67
|
+
const DEFAULT_COLOR_ROTATION = [
|
|
68
|
+
"default",
|
|
69
|
+
"positive",
|
|
70
|
+
"warning",
|
|
71
|
+
"destructive",
|
|
72
|
+
"primary",
|
|
73
|
+
"muted",
|
|
74
|
+
];
|
|
75
|
+
/** Base fill opacity per variant, before the per-depth falloff is applied. */
|
|
76
|
+
const VARIANT_BASE_FILL_OPACITY = {
|
|
77
|
+
soft: 0.18,
|
|
78
|
+
solid: 0.9,
|
|
79
|
+
outline: 0,
|
|
80
|
+
};
|
|
81
|
+
export const treeMapVariants = cva("relative inline-flex shrink-0 items-center justify-center", {
|
|
82
|
+
variants: {
|
|
83
|
+
size: {
|
|
84
|
+
sm: "text-[10px]",
|
|
85
|
+
md: "text-[11px]",
|
|
86
|
+
lg: "text-xs",
|
|
87
|
+
xl: "text-sm",
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
defaultVariants: {
|
|
91
|
+
size: "md",
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
function sanitizeValue(value) {
|
|
95
|
+
if (!Number.isFinite(value) || value < 0)
|
|
96
|
+
return 0;
|
|
97
|
+
return value;
|
|
98
|
+
}
|
|
99
|
+
/** Aggregate value of a subtree, used when `maxDepth` collapses a branch. */
|
|
100
|
+
function subtreeValue(node) {
|
|
101
|
+
const children = node.children ?? [];
|
|
102
|
+
if (children.length === 0)
|
|
103
|
+
return sanitizeValue(node.value ?? 0);
|
|
104
|
+
let sum = 0;
|
|
105
|
+
for (const child of children)
|
|
106
|
+
sum += subtreeValue(child);
|
|
107
|
+
return sum;
|
|
108
|
+
}
|
|
109
|
+
function measure(node, depth, maxDepth) {
|
|
110
|
+
const children = node.children ?? [];
|
|
111
|
+
if (children.length === 0 || depth >= maxDepth) {
|
|
112
|
+
return { node, value: subtreeValue(node), children: [] };
|
|
113
|
+
}
|
|
114
|
+
const measured = children
|
|
115
|
+
.map((child) => measure(child, depth + 1, maxDepth))
|
|
116
|
+
.filter((child) => child.value > 0);
|
|
117
|
+
let sum = 0;
|
|
118
|
+
for (const child of measured)
|
|
119
|
+
sum += child.value;
|
|
120
|
+
return { node, value: sum, children: measured };
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Worst (largest) aspect ratio produced by laying `values[start..end]` out as
|
|
124
|
+
* one row of thickness `rowArea / side` across a side of length `side`.
|
|
125
|
+
*/
|
|
126
|
+
function worstAspect(values, start, end, scale, side) {
|
|
127
|
+
let rowValue = 0;
|
|
128
|
+
for (let i = start; i <= end; i++)
|
|
129
|
+
rowValue += values[i];
|
|
130
|
+
const rowArea = rowValue * scale;
|
|
131
|
+
if (rowArea <= 0 || side <= 0)
|
|
132
|
+
return Number.POSITIVE_INFINITY;
|
|
133
|
+
const thickness = rowArea / side;
|
|
134
|
+
let worst = 0;
|
|
135
|
+
for (let i = start; i <= end; i++) {
|
|
136
|
+
const length = (values[i] * scale) / thickness;
|
|
137
|
+
if (length <= 0)
|
|
138
|
+
return Number.POSITIVE_INFINITY;
|
|
139
|
+
worst = Math.max(worst, thickness / length, length / thickness);
|
|
140
|
+
}
|
|
141
|
+
return worst;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Squarified treemap layout (Bruls, Huizing & van Wijk, 2000).
|
|
145
|
+
*
|
|
146
|
+
* Fills `rect` with one rectangle per entry in `values`, each with an area
|
|
147
|
+
* proportional to its value. Rows are grown greedily while they keep improving
|
|
148
|
+
* the worst aspect ratio, which is what keeps the tiles close to square and
|
|
149
|
+
* therefore comparable by eye. `values` is expected to be sorted descending
|
|
150
|
+
* (the caller does that unless `sort` is off); an unsorted input still lays out
|
|
151
|
+
* correctly, just with less square tiles.
|
|
152
|
+
*/
|
|
153
|
+
function squarify(values, rect) {
|
|
154
|
+
const out = values.map(() => ({
|
|
155
|
+
x: rect.x,
|
|
156
|
+
y: rect.y,
|
|
157
|
+
w: 0,
|
|
158
|
+
h: 0,
|
|
159
|
+
}));
|
|
160
|
+
const live = values
|
|
161
|
+
.map((_, index) => index)
|
|
162
|
+
.filter((index) => values[index] > 0);
|
|
163
|
+
if (live.length === 0)
|
|
164
|
+
return out;
|
|
165
|
+
const liveValues = live.map((index) => values[index]);
|
|
166
|
+
let remaining = 0;
|
|
167
|
+
for (const value of liveValues)
|
|
168
|
+
remaining += value;
|
|
169
|
+
let free = { ...rect };
|
|
170
|
+
let cursor = 0;
|
|
171
|
+
while (cursor < liveValues.length && remaining > 0) {
|
|
172
|
+
if (free.w <= 0 || free.h <= 0)
|
|
173
|
+
break;
|
|
174
|
+
// Rows run along the shorter side of the free rectangle; that is the
|
|
175
|
+
// choice that keeps the aspect ratios low.
|
|
176
|
+
const stacked = free.w >= free.h;
|
|
177
|
+
const side = stacked ? free.h : free.w;
|
|
178
|
+
const scale = (free.w * free.h) / remaining;
|
|
179
|
+
let count = 1;
|
|
180
|
+
let best = worstAspect(liveValues, cursor, cursor, scale, side);
|
|
181
|
+
while (cursor + count < liveValues.length) {
|
|
182
|
+
const next = worstAspect(liveValues, cursor, cursor + count, scale, side);
|
|
183
|
+
if (next > best)
|
|
184
|
+
break;
|
|
185
|
+
best = next;
|
|
186
|
+
count += 1;
|
|
187
|
+
}
|
|
188
|
+
let rowValue = 0;
|
|
189
|
+
for (let i = cursor; i < cursor + count; i++)
|
|
190
|
+
rowValue += liveValues[i];
|
|
191
|
+
// Clamp against the long side so floating-point drift can't push the last
|
|
192
|
+
// row past the edge of the free rectangle.
|
|
193
|
+
const thickness = Math.min(stacked ? free.w : free.h, (rowValue * scale) / side);
|
|
194
|
+
let offset = 0;
|
|
195
|
+
for (let i = cursor; i < cursor + count; i++) {
|
|
196
|
+
const area = liveValues[i] * scale;
|
|
197
|
+
const length = thickness > 0 ? Math.min(side - offset, area / thickness) : 0;
|
|
198
|
+
out[live[i]] = stacked
|
|
199
|
+
? { x: free.x, y: free.y + offset, w: thickness, h: length }
|
|
200
|
+
: { x: free.x + offset, y: free.y, w: length, h: thickness };
|
|
201
|
+
offset += length;
|
|
202
|
+
}
|
|
203
|
+
free = stacked
|
|
204
|
+
? { x: free.x + thickness, y: free.y, w: free.w - thickness, h: free.h }
|
|
205
|
+
: { x: free.x, y: free.y + thickness, w: free.w, h: free.h - thickness };
|
|
206
|
+
remaining -= rowValue;
|
|
207
|
+
cursor += count;
|
|
208
|
+
}
|
|
209
|
+
return out;
|
|
210
|
+
}
|
|
211
|
+
/** Shrink a rectangle by `inset` on every side, never past zero. */
|
|
212
|
+
function deflate(rect, inset) {
|
|
213
|
+
const w = Math.max(0, rect.w - inset * 2);
|
|
214
|
+
const h = Math.max(0, rect.h - inset * 2);
|
|
215
|
+
return {
|
|
216
|
+
x: rect.x + (rect.w - w) / 2,
|
|
217
|
+
y: rect.y + (rect.h - h) / 2,
|
|
218
|
+
w,
|
|
219
|
+
h,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
function layoutInto(siblings, rect, depth, parentPath, parentKey, inheritedColor, options, out) {
|
|
223
|
+
if (siblings.length === 0 || rect.w <= 0 || rect.h <= 0)
|
|
224
|
+
return;
|
|
225
|
+
const ordered = options.sort
|
|
226
|
+
? [...siblings].sort((a, b) => b.value - a.value)
|
|
227
|
+
: siblings;
|
|
228
|
+
const rects = squarify(ordered.map((child) => child.value), rect);
|
|
229
|
+
ordered.forEach((measured, index) => {
|
|
230
|
+
const raw = rects[index];
|
|
231
|
+
const tileRect = deflate(raw, options.tileGap / 2);
|
|
232
|
+
if (tileRect.w <= 0 || tileRect.h <= 0)
|
|
233
|
+
return;
|
|
234
|
+
const color = measured.node.color ??
|
|
235
|
+
inheritedColor ??
|
|
236
|
+
DEFAULT_COLOR_ROTATION[index % DEFAULT_COLOR_ROTATION.length];
|
|
237
|
+
const isBranch = measured.children.length > 0;
|
|
238
|
+
const path = [...parentPath, measured.node.id];
|
|
239
|
+
const key = `${parentKey}/${measured.node.id}:${index}`;
|
|
240
|
+
// A branch only earns a header band if it is labelled and tall enough to
|
|
241
|
+
// give one up without squashing its children.
|
|
242
|
+
const wantsHeader = isBranch &&
|
|
243
|
+
Boolean(measured.node.label) &&
|
|
244
|
+
tileRect.h > options.groupHeaderHeight * 2.2;
|
|
245
|
+
const headerHeight = wantsHeader ? options.groupHeaderHeight : 0;
|
|
246
|
+
out.push({
|
|
247
|
+
node: measured.node,
|
|
248
|
+
key,
|
|
249
|
+
index: out.length,
|
|
250
|
+
path,
|
|
251
|
+
depth,
|
|
252
|
+
value: measured.value,
|
|
253
|
+
fraction: options.total > 0 ? measured.value / options.total : 0,
|
|
254
|
+
rect: tileRect,
|
|
255
|
+
isBranch,
|
|
256
|
+
headerHeight,
|
|
257
|
+
color,
|
|
258
|
+
fill: measured.node.fill,
|
|
259
|
+
fillOpacity: options.variantFillOpacity *
|
|
260
|
+
Math.pow(options.depthFillFalloff, depth) *
|
|
261
|
+
(isBranch ? 0.6 : 1),
|
|
262
|
+
});
|
|
263
|
+
if (!isBranch)
|
|
264
|
+
return;
|
|
265
|
+
const inner = deflate({
|
|
266
|
+
x: tileRect.x,
|
|
267
|
+
y: tileRect.y + headerHeight,
|
|
268
|
+
w: tileRect.w,
|
|
269
|
+
h: Math.max(0, tileRect.h - headerHeight),
|
|
270
|
+
}, options.groupPadding);
|
|
271
|
+
layoutInto(measured.children, inner, depth + 1, path, key, measured.node.fill ? undefined : color, options, out);
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
function defaultValueText({ value }) {
|
|
275
|
+
return value.toLocaleString();
|
|
276
|
+
}
|
|
277
|
+
function TreeMap({ nodes, label, variant = "soft", size, width, height, total, maxDepth = Number.POSITIVE_INFINITY, sort = true, tileGap = 2, groupPadding = 4, groupHeaderHeight = 16, cornerRadius = 3, showLabels = true, showValues = true, minLabelWidth = 48, minLabelHeight = 18, tileFillOpacity, depthFillFalloff = 0.55, labelFormatter, valueFormatter, onNodeClick, children, className, overlayClassName, labelClassName, valueClassName, ref, ...props }) {
|
|
278
|
+
const resolvedSize = size ?? "md";
|
|
279
|
+
const canvas = SIZE_TO_CANVAS[resolvedSize];
|
|
280
|
+
const W = width ?? canvas.width;
|
|
281
|
+
const H = height ?? canvas.height;
|
|
282
|
+
const titleId = useId();
|
|
283
|
+
const clipIdPrefix = useId();
|
|
284
|
+
const measured = nodes
|
|
285
|
+
.map((node) => measure(node, 0, maxDepth))
|
|
286
|
+
.filter((node) => node.value > 0);
|
|
287
|
+
let measuredTotal = 0;
|
|
288
|
+
for (const node of measured)
|
|
289
|
+
measuredTotal += node.value;
|
|
290
|
+
const scaleTotal = total ?? measuredTotal;
|
|
291
|
+
const tiles = [];
|
|
292
|
+
layoutInto(measured, { x: 0, y: 0, w: W, h: H }, 0, [], "root", undefined, {
|
|
293
|
+
total: scaleTotal,
|
|
294
|
+
sort,
|
|
295
|
+
tileGap: Math.max(0, tileGap),
|
|
296
|
+
groupPadding: Math.max(0, groupPadding),
|
|
297
|
+
groupHeaderHeight: Math.max(0, groupHeaderHeight),
|
|
298
|
+
variantFillOpacity: tileFillOpacity ?? VARIANT_BASE_FILL_OPACITY[variant],
|
|
299
|
+
depthFillFalloff: Math.max(0, Math.min(1, depthFillFalloff)),
|
|
300
|
+
}, tiles);
|
|
301
|
+
// Labels sitting on a saturated fill need a halo to stay readable in both
|
|
302
|
+
// brightness themes; `soft` and `outline` tiles are close enough to the page
|
|
303
|
+
// background that plain foreground text is already high-contrast.
|
|
304
|
+
const haloed = variant === "solid";
|
|
305
|
+
function contextFor(tile) {
|
|
306
|
+
return {
|
|
307
|
+
node: tile.node,
|
|
308
|
+
value: tile.value,
|
|
309
|
+
fraction: tile.fraction,
|
|
310
|
+
depth: tile.depth,
|
|
311
|
+
path: tile.path,
|
|
312
|
+
isBranch: tile.isBranch,
|
|
313
|
+
width: tile.rect.w,
|
|
314
|
+
height: tile.rect.h,
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
return (_jsxs("div", { ref: ref, role: "img", "aria-labelledby": titleId, "data-slot": "treemap", "data-variant": variant, className: cn(treeMapVariants({ size }), className), style: { width: W, height: H }, ...props, children: [_jsxs("svg", { width: W, height: H, viewBox: `0 0 ${W} ${H}`, "aria-hidden": children ? "true" : undefined, className: "h-full w-full", children: [_jsx("title", { id: titleId, children: label }), tiles.length === 0 ? (_jsx("text", { x: W / 2, y: H / 2, textAnchor: "middle", dominantBaseline: "central", className: "fill-muted-foreground", children: "No data" })) : null, tiles.length > 0 ? (_jsx("defs", { children: tiles.map((tile) => (_jsx("clipPath", { id: `${clipIdPrefix}-${tile.index}`, children: _jsx("rect", { x: tile.rect.x, y: tile.rect.y, width: tile.rect.w, height: tile.rect.h, rx: cornerRadius }) }, tile.key))) })) : null, tiles.map((tile) => {
|
|
318
|
+
const handler = tile.node.onClick ?? onNodeClick;
|
|
319
|
+
const isInteractive = typeof handler === "function";
|
|
320
|
+
const name = tile.node.label ?? tile.node.id;
|
|
321
|
+
return (_jsx("rect", { x: tile.rect.x, y: tile.rect.y, width: tile.rect.w, height: tile.rect.h, rx: cornerRadius, "data-slot": tile.isBranch ? "treemap-group" : "treemap-tile", "data-node-id": tile.node.id, "data-depth": tile.depth, fill: tile.fill, fillOpacity: tile.fillOpacity, stroke: tile.fill, strokeWidth: variant === "outline" ? 1.5 : 1, strokeOpacity: variant === "solid" && !tile.isBranch ? 0 : 1, role: isInteractive ? "button" : undefined, tabIndex: isInteractive ? 0 : undefined, "aria-label": `${name}: ${tile.value}`, onClick: isInteractive
|
|
322
|
+
? (event) => {
|
|
323
|
+
handler(tile.node, event);
|
|
324
|
+
}
|
|
325
|
+
: undefined, onKeyDown: isInteractive
|
|
326
|
+
? (event) => {
|
|
327
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
328
|
+
event.preventDefault();
|
|
329
|
+
handler(tile.node, event);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
: undefined, className: cn("transition-opacity", tile.fill === undefined && FILL_CLASSES[tile.color], tile.fill === undefined && STROKE_CLASSES[tile.color], isInteractive &&
|
|
333
|
+
"cursor-pointer hover:opacity-80 focus:outline-none focus-visible:opacity-80", tile.node.className) }, tile.key));
|
|
334
|
+
}), showLabels || showValues ? (_jsx("g", { "aria-hidden": "true", "data-slot": "treemap-labels", className: "pointer-events-none select-none", children: tiles.map((tile) => {
|
|
335
|
+
const context = contextFor(tile);
|
|
336
|
+
const name = showLabels
|
|
337
|
+
? labelFormatter
|
|
338
|
+
? labelFormatter(context)
|
|
339
|
+
: (tile.node.label ?? tile.node.id)
|
|
340
|
+
: null;
|
|
341
|
+
const value = showValues
|
|
342
|
+
? (valueFormatter ?? defaultValueText)(context)
|
|
343
|
+
: null;
|
|
344
|
+
if (!name && !value)
|
|
345
|
+
return null;
|
|
346
|
+
// A branch prints its name in its header band; a leaf centers
|
|
347
|
+
// its name (and value) in the middle of the tile.
|
|
348
|
+
const band = tile.isBranch
|
|
349
|
+
? tile.headerHeight
|
|
350
|
+
: tile.rect.h;
|
|
351
|
+
if (band <= 0)
|
|
352
|
+
return null;
|
|
353
|
+
if (tile.rect.w < minLabelWidth)
|
|
354
|
+
return null;
|
|
355
|
+
// `minLabelHeight` is about a leaf having room for centered
|
|
356
|
+
// text. A branch's band is already sized by `groupHeaderHeight`
|
|
357
|
+
// and only exists when the branch was tall enough to spare it,
|
|
358
|
+
// so applying the leaf threshold here would silently drop every
|
|
359
|
+
// group name whenever `groupHeaderHeight < minLabelHeight`.
|
|
360
|
+
if (!tile.isBranch && band < minLabelHeight)
|
|
361
|
+
return null;
|
|
362
|
+
const showBoth = Boolean(name) &&
|
|
363
|
+
Boolean(value) &&
|
|
364
|
+
!tile.isBranch &&
|
|
365
|
+
band >= minLabelHeight * 2;
|
|
366
|
+
const centerX = tile.rect.x + tile.rect.w / 2;
|
|
367
|
+
const centerY = tile.isBranch
|
|
368
|
+
? tile.rect.y + tile.headerHeight / 2
|
|
369
|
+
: tile.rect.y + tile.rect.h / 2;
|
|
370
|
+
const anchorX = tile.isBranch
|
|
371
|
+
? tile.rect.x + 6
|
|
372
|
+
: centerX;
|
|
373
|
+
const textAnchor = tile.isBranch
|
|
374
|
+
? "start"
|
|
375
|
+
: "middle";
|
|
376
|
+
const haloClasses = haloed && "[paint-order:stroke] stroke-background stroke-[3px]";
|
|
377
|
+
return (_jsxs("g", { clipPath: `url(#${clipIdPrefix}-${tile.index})`, children: [name ? (_jsx("text", { x: anchorX, y: centerY, dy: showBoth ? "-0.25em" : 0, textAnchor: textAnchor, dominantBaseline: "central", className: cn("fill-foreground font-medium", haloClasses, labelClassName), children: name })) : null, value && (showBoth || !name) ? (_jsx("text", { x: anchorX, y: centerY, dy: showBoth ? "1.1em" : 0, textAnchor: textAnchor, dominantBaseline: "central", className: cn("fill-muted-foreground tabular-nums", haloClasses, valueClassName), children: value })) : null] }, `${tile.key}-label`));
|
|
378
|
+
}) })) : null] }), children ? (_jsx("div", { className: cn("pointer-events-none absolute inset-0 flex items-center justify-center text-center", overlayClassName), children: children })) : null] }));
|
|
379
|
+
}
|
|
380
|
+
TreeMap.displayName = "TreeMap";
|
|
381
|
+
export { TreeMap };
|
|
382
|
+
//# sourceMappingURL=treemap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"treemap.js","sourceRoot":"","sources":["../../../../src/components/ui/treemap/treemap.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,GAAG,EAAqB,MAAM,0BAA0B,CAAC;AASlE,OAAO,EAAE,K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,UAAU,EAAE,UAAU,EACtB,gBAAgB,EAAC,SAAS,EAC1B,SAAS,EAAE,EAAE,CACX,6BAA6B,EAC7B,WAAW,EACX,cAAc,CACf,YAEA,IAAI,GACA,CACR,CAAC,CAAC,CAAC,IAAI,EACP,KAAK,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAC9B,eACE,CAAC,EAAE,OAAO,EACV,CAAC,EAAE,OAAO,EACV,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAC1B,UAAU,EAAE,UAAU,EACtB,gBAAgB,EAAC,SAAS,EAC1B,SAAS,EAAE,EAAE,CACX,oCAAoC,EACpC,WAAW,EACX,cAAc,CACf,YAEA,KAAK,GACD,CACR,CAAC,CAAC,CAAC,IAAI,KAlCH,GAAG,IAAI,CAAC,GAAG,QAAQ,CAmCtB,CACL,CAAC;wBACJ,CAAC,CAAC,GACA,CACL,CAAC,CAAC,CAAC,IAAI,IACJ,EACL,QAAQ,CAAC,CAAC,CAAC,CACV,cACE,SAAS,EAAE,EAAE,CACX,mFAAmF,EACnF,gBAAgB,CACjB,YAEA,QAAQ,GACL,CACP,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,CAAC;AACJ,CAAC;AACD,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;AAEhC,OAAO,EAAE,OAAO,EAAE,CAAC"}
|
package/dist/types/Link.d.ts
CHANGED
|
@@ -3,6 +3,12 @@ export interface LinkComponentProps extends PropsWithChildren<{
|
|
|
3
3
|
href: string;
|
|
4
4
|
className?: string;
|
|
5
5
|
onClick?: (e: MouseEvent) => void;
|
|
6
|
+
/**
|
|
7
|
+
* Set to `"page"` on the dashboard sidebar link for the page currently
|
|
8
|
+
* being viewed. Forward it to the rendered `<a>` so assistive technology
|
|
9
|
+
* announces the link as the current page.
|
|
10
|
+
*/
|
|
11
|
+
"aria-current"?: "page";
|
|
6
12
|
}> {
|
|
7
13
|
}
|
|
8
14
|
export type LinkComponentType = (props: LinkComponentProps) => ReactElement;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schemavaults/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.111.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "React.js UI components for SchemaVaults frontend applications",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@radix-ui/react-toast": "1.2.14",
|
|
37
37
|
"@radix-ui/react-tooltip": "1.2.7",
|
|
38
38
|
"@radix-ui/react-visually-hidden": "1.2.3",
|
|
39
|
-
"@schemavaults/theme": "0.
|
|
39
|
+
"@schemavaults/theme": "0.30.0",
|
|
40
40
|
"@tanstack/react-table": "8.20.1",
|
|
41
41
|
"class-variance-authority": "0.7.1",
|
|
42
42
|
"clsx": "2.1.1",
|