basalt-ui 2.13.1 → 2.13.3
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/CHANGELOG.md +19 -0
- package/MIGRATING.md +25 -12
- package/README.md +1 -1
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +6 -5
- package/dist/charts/cursor.d.ts +33 -7
- package/dist/charts/cursor.d.ts.map +1 -1
- package/dist/charts/cursor.js +31 -10
- package/dist/charts/legend.d.ts +19 -3
- package/dist/charts/legend.d.ts.map +1 -1
- package/dist/charts/legend.js +33 -15
- package/dist/charts/marks.d.ts.map +1 -1
- package/dist/charts/marks.js +24 -28
- package/dist/charts/panel.d.ts.map +1 -1
- package/dist/charts/panel.js +4 -4
- package/dist/charts/types.d.ts +3 -2
- package/dist/charts/types.d.ts.map +1 -1
- package/dist/provider/create-router.d.ts +9 -4
- package/dist/provider/create-router.d.ts.map +1 -1
- package/dist/provider/create-router.js +1 -19
- package/dist/provider/error-fallback.module.css +4 -15
- package/dist/provider/error-fallback.module.css.d.ts +0 -1
- package/dist/provider/fallback.module.css +37 -0
- package/dist/provider/fallback.module.css.d.ts +11 -0
- package/dist/provider/index.d.ts.map +1 -1
- package/dist/provider/index.js +2 -1
- package/dist/provider/route-defaults.d.ts +10 -0
- package/dist/provider/route-defaults.d.ts.map +1 -0
- package/dist/provider/route-defaults.js +25 -0
- package/dist/provider/route-defaults.module.css +39 -0
- package/dist/provider/route-defaults.module.css.d.ts +10 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +4 -1
- package/llms.txt +2 -2
- package/package.json +1 -1
- package/src/charts/compile.ts +8 -10
- package/src/charts/cursor.ts +69 -19
- package/src/charts/legend.tsx +40 -19
- package/src/charts/marks.ts +28 -29
- package/src/charts/panel.tsx +4 -4
- package/src/charts/types.ts +3 -2
- package/src/provider/create-router.tsx +2 -36
- package/src/provider/error-fallback.module.css +4 -15
- package/src/provider/error-fallback.module.css.d.ts +0 -1
- package/src/provider/fallback.module.css +37 -0
- package/src/provider/fallback.module.css.d.ts +11 -0
- package/src/provider/index.tsx +2 -1
- package/src/provider/route-defaults.module.css +39 -0
- package/src/provider/route-defaults.module.css.d.ts +10 -0
- package/src/provider/route-defaults.tsx +39 -0
- package/src/theme/__snapshots__/plain-theme.test.ts.snap +2 -0
- package/src/theme/index.ts +4 -1
|
@@ -1,7 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `basaltRouterOptions` / `createBasaltRouter` — the router + QueryClient wiring (V2-SPEC § 2). One
|
|
3
|
+
* `QueryClient` per call (so an SSR entry gets one per request), carried on `context.queryClient`,
|
|
4
|
+
* plus the router defaults basalt owns: intent preloading with Query-owned freshness, scroll restoration, the
|
|
5
|
+
* pending / error / not-found components, and the route view transition (direction from the
|
|
6
|
+
* `BasaltShell` nav order, V2-SPEC § 5).
|
|
7
|
+
*/
|
|
1
8
|
import type { QueryClient, QueryClientConfig } from '@tanstack/react-query';
|
|
2
9
|
import { Router } from '@tanstack/react-router';
|
|
3
|
-
import type { AnyRoute,
|
|
10
|
+
import type { AnyRoute, RouterHistory } from '@tanstack/react-router';
|
|
4
11
|
import type { RouterHook } from '../telemetry.js';
|
|
12
|
+
import { ErrorComponent, NotFoundComponent, PendingComponent } from './route-defaults.js';
|
|
5
13
|
import { routeViewTransition } from './route-transition.js';
|
|
6
14
|
/** The root route's context: `createRootRouteWithContext<BasaltRouterContext>()`. */
|
|
7
15
|
export type BasaltRouterContext = {
|
|
@@ -22,9 +30,6 @@ declare const basaltRouterBrand: unique symbol;
|
|
|
22
30
|
export type BasaltRouter<TRouteTree extends AnyRoute = any> = BasaltRouterBase<TRouteTree> & {
|
|
23
31
|
readonly [basaltRouterBrand]: true;
|
|
24
32
|
};
|
|
25
|
-
declare function PendingComponent(): import("react").JSX.Element;
|
|
26
|
-
declare function ErrorComponent({ error, reset }: ErrorComponentProps): import("react").JSX.Element;
|
|
27
|
-
declare function NotFoundComponent(): import("react").JSX.Element;
|
|
28
33
|
/** The options `createBasaltRouter` owns. Each is `never` on it: basalt's, not a consumer knob. */
|
|
29
34
|
type ManagedKeys = Exclude<keyof BasaltRouterOptions, 'context'>;
|
|
30
35
|
/** `queryClient` and `__basalt` are basalt's: a consumer's would be replaced, so the type rejects them. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-router.d.ts","sourceRoot":"","sources":["../../src/provider/create-router.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-router.d.ts","sourceRoot":"","sources":["../../src/provider/create-router.tsx"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAC3E,OAAO,EAAE,MAAM,EAAgB,MAAM,wBAAwB,CAAA;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAErE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AACtF,OAAO,EAEL,mBAAmB,EAEpB,MAAM,oBAAoB,CAAA;AAE3B,qFAAqF;AACrF,MAAM,MAAM,mBAAmB,GAAG;IAChC,WAAW,EAAE,WAAW,CAAA;IACxB,+FAA+F;IAC/F,QAAQ,CAAC,EAAE,UAAU,CAAA;CACtB,CAAA;AAED,KAAK,gBAAgB,CAAC,UAAU,SAAS,QAAQ,IAAI,MAAM,CACzD,UAAU,EACV,OAAO,EACP,KAAK,EACL,aAAa,EACb,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CACpB,CAAA;AAED,OAAO,CAAC,MAAM,iBAAiB,EAAE,OAAO,MAAM,CAAA;AAE9C;;;;;;;GAOG;AACH,MAAM,MAAM,YAAY,CACtB,UAAU,SAAS,QAAQ,GAAG,GAAG,IAC/B,gBAAgB,C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,SAAS,MAAM,EACzD,OAAO,EAAE,kBAAkB,CAAC,QAAQ,CAAC,GAAG;IAAE,OAAO,EAAE,QAAQ,GAAG,YAAY,CAAA;CAAE,GAC3E,mBAAmB,CAAC,QAAQ,CAAC,CAAA;AAwChC,KAAK,iBAAiB,CAAC,UAAU,SAAS,QAAQ,IAAI;IACpD,SAAS,EAAE,UAAU,CAAA;IACrB,OAAO,CAAC,EAAE,aAAa,CAAA;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,GAAG;KAAG,CAAC,IAAI,WAAW,CAAC,CAAC,EAAE,KAAK;CAAE,CAAA;AAElC;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,SAAS,QAAQ,EAC5D,OAAO,EAAE,iBAAiB,CAAC,UAAU,CAAC,GAAG,kBAAkB,CAAC,SAAS,CAAC,GACrE,YAAY,CAAC,UAAU,CAAC,CAAA;AAC3B,wBAAgB,kBAAkB,CAAC,UAAU,SAAS,QAAQ,EAAE,QAAQ,SAAS,MAAM,EACrF,OAAO,EAAE,iBAAiB,CAAC,UAAU,CAAC,GACpC,kBAAkB,CAAC,QAAQ,CAAC,GAAG;IAAE,OAAO,EAAE,QAAQ,GAAG,YAAY,CAAA;CAAE,GACpE,YAAY,CAAC,UAAU,CAAC,CAAA"}
|
|
@@ -1,29 +1,11 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Button, Center, Loader, Stack, Text } from "@mantine/core";
|
|
3
1
|
import { Router, createRouter } from "@tanstack/react-router";
|
|
4
|
-
import { toErrorMessage } from "../common/errors.js";
|
|
5
2
|
import { makeQueryClient } from "../query-client.js";
|
|
3
|
+
import { ErrorComponent, NotFoundComponent, PendingComponent } from "./route-defaults.js";
|
|
6
4
|
import {
|
|
7
5
|
guardViewTransitionRejections,
|
|
8
6
|
routeViewTransition,
|
|
9
7
|
supportsViewTransitionTypes
|
|
10
8
|
} from "./route-transition.js";
|
|
11
|
-
function PendingComponent() {
|
|
12
|
-
return /* @__PURE__ */ jsx(Center, { py: "xl", children: /* @__PURE__ */ jsx(Loader, { size: "sm" }) });
|
|
13
|
-
}
|
|
14
|
-
function ErrorComponent({ error, reset }) {
|
|
15
|
-
return /* @__PURE__ */ jsxs(Stack, { align: "flex-start", gap: "xs", p: "md", children: [
|
|
16
|
-
/* @__PURE__ */ jsx(Text, { fw: 600, children: "Something went wrong" }),
|
|
17
|
-
/* @__PURE__ */ jsx(Text, { c: "dimmed", size: "sm", children: toErrorMessage(error) }),
|
|
18
|
-
/* @__PURE__ */ jsx(Button, { size: "compact-sm", variant: "default", onClick: reset, children: "Try again" })
|
|
19
|
-
] });
|
|
20
|
-
}
|
|
21
|
-
function NotFoundComponent() {
|
|
22
|
-
return /* @__PURE__ */ jsxs(Stack, { gap: 4, p: "md", children: [
|
|
23
|
-
/* @__PURE__ */ jsx(Text, { fw: 600, children: "Page not found" }),
|
|
24
|
-
/* @__PURE__ */ jsx(Text, { c: "dimmed", size: "sm", children: "This address does not match any page." })
|
|
25
|
-
] });
|
|
26
|
-
}
|
|
27
9
|
function basaltRouterOptions(options = {}) {
|
|
28
10
|
return buildRouterOptions(options);
|
|
29
11
|
}
|
|
@@ -1,21 +1,10 @@
|
|
|
1
|
-
/* The boundary renders ABOVE MantineProvider, so its fallback is plain HTML styled here
|
|
2
|
-
Mantine primitive, no inline style object (hidden-inline-style).
|
|
1
|
+
/* The boundary renders ABOVE MantineProvider, so its fallback is plain HTML styled here and in the
|
|
2
|
+
shared fallback.module.css — no Mantine primitive, no inline style object (hidden-inline-style). */
|
|
3
3
|
.root {
|
|
4
4
|
max-width: 32rem;
|
|
5
5
|
margin: 0 auto;
|
|
6
|
-
padding: var(--vx-space-stack-xl);
|
|
6
|
+
padding: var(--vx-space-stack-xl, 2rem);
|
|
7
7
|
display: flex;
|
|
8
8
|
flex-direction: column;
|
|
9
|
-
gap: var(--vx-space-stack-md);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
.reload {
|
|
13
|
-
align-self: flex-start;
|
|
14
|
-
font: inherit;
|
|
15
|
-
cursor: pointer;
|
|
16
|
-
padding: var(--vx-space-stack-xs) var(--vx-space-stack-md);
|
|
17
|
-
border: 1px solid var(--vx-divider);
|
|
18
|
-
border-radius: var(--vx-radius-ctrl);
|
|
19
|
-
background: transparent;
|
|
20
|
-
color: inherit;
|
|
9
|
+
gap: var(--vx-space-stack-md, 1rem);
|
|
21
10
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/* The plain-HTML fallback vocabulary shared by RootBoundary's fallback and the router's default
|
|
2
|
+
screens: both render where Mantine may be absent, so neither can use a Mantine primitive. Every
|
|
3
|
+
--vx-* read carries a literal fallback, so they look right with the provider, with only
|
|
4
|
+
tokens.css, or with nothing. */
|
|
5
|
+
.stack {
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
align-items: flex-start;
|
|
9
|
+
gap: var(--vx-space-stack-xs, 0.5rem);
|
|
10
|
+
padding: var(--vx-space-stack-md, 1rem);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.title {
|
|
14
|
+
margin: 0;
|
|
15
|
+
font-weight: 600;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.text {
|
|
19
|
+
margin: 0;
|
|
20
|
+
font-size: var(--vx-text-sm, 0.875rem);
|
|
21
|
+
color: var(--vx-ink2, inherit);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.action {
|
|
25
|
+
align-self: flex-start;
|
|
26
|
+
min-width: 2.75rem;
|
|
27
|
+
min-height: 2.75rem;
|
|
28
|
+
font: inherit;
|
|
29
|
+
font-size: var(--vx-text-sm, 0.875rem);
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
padding: 0.25rem var(--vx-space-stack-md, 0.75rem);
|
|
32
|
+
border: 1px solid currentColor;
|
|
33
|
+
border: 1px solid var(--vx-divider, color-mix(in srgb, currentColor 25%, transparent));
|
|
34
|
+
border-radius: var(--vx-radius-ctrl, 6px);
|
|
35
|
+
background: transparent;
|
|
36
|
+
color: inherit;
|
|
37
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed CSS-module declaration (the S4 CSS-modules path). Named string props — not an index
|
|
3
|
+
* signature — so dot access stays verbatim under the package's strict flags.
|
|
4
|
+
*/
|
|
5
|
+
declare const classes: {
|
|
6
|
+
readonly stack: string
|
|
7
|
+
readonly title: string
|
|
8
|
+
readonly text: string
|
|
9
|
+
readonly action: string
|
|
10
|
+
}
|
|
11
|
+
export default classes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/provider/index.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AAMzD,OAAO,EAAE,SAAS,EAAwD,MAAM,OAAO,CAAA;AACvF,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/provider/index.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AAMzD,OAAO,EAAE,SAAS,EAAwD,MAAM,OAAO,CAAA;AACvF,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAMjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAQtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAUxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C,OAAO,KAAK,EAAE,YAAY,EAAuB,MAAM,iBAAiB,CAAA;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAI/D,KAAK,yBAAyB,GAAG;IAC/B,qFAAqF;I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1D,mGAAmG;AACnG,qBAAa,YAAa,SAAQ,SAAS,CAAC,iBAAiB,EAAE,aAAa,CAAC;gBAC/D,KAAK,EAAE,iBAAiB;IAKpC,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa;IAIrD,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI;IAczD,MAAM,IAAI,SAAS;CAO7B;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,MAAM,CAER;AAYD;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAmBvC;AAuOD,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,SAAS,EACT,QAAQ,EACR,aAAoB,EACpB,cAAc,EACd,kBAA2B,EAC3B,KAAK,EACL,aAAyB,EACzB,eAAe,EACf,SAAgB,EAChB,MAAM,EAAE,aAAa,EACrB,QAAQ,EACR,GAAG,IAAI,EACR,EAAE,mBAAmB,+BA+DrB"}
|
package/dist/provider/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import { QueryClientProvider } from "@tanstack/react-query";
|
|
|
5
5
|
import { RouterProvider, useRouter } from "@tanstack/react-router";
|
|
6
6
|
import { Component, Suspense, lazy, useEffect, useMemo, useRef, useState } from "react";
|
|
7
7
|
import fallbackClasses from "./error-fallback.module.css";
|
|
8
|
+
import sharedFallback from "./fallback.module.css";
|
|
8
9
|
import { cssVariablesResolver } from "../theme/index.js";
|
|
9
10
|
import { useLabTheme } from "./lab-theme.js";
|
|
10
11
|
import { buildDensityCss, buildFontsCss, buildPaletteCss, buildRadiusCss } from "../tokens/core.js";
|
|
@@ -38,7 +39,7 @@ function DefaultErrorFallback() {
|
|
|
38
39
|
"button",
|
|
39
40
|
{
|
|
40
41
|
type: "button",
|
|
41
|
-
className:
|
|
42
|
+
className: sharedFallback.action,
|
|
42
43
|
onClick: () => window.location.reload(),
|
|
43
44
|
children: "Reload page"
|
|
44
45
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The router's default pending / error / not-found screens. Provider-free on purpose: a route's
|
|
3
|
+
* screen renders at the route that failed, which can sit above `BasaltProvider` (a root-level error,
|
|
4
|
+
* or a pathless-layout provider), so no Mantine primitive. Wired by `createBasaltRouter`.
|
|
5
|
+
*/
|
|
6
|
+
import type { ErrorComponentProps } from '@tanstack/react-router';
|
|
7
|
+
export declare function PendingComponent(): import("react").JSX.Element;
|
|
8
|
+
export declare function ErrorComponent({ error, reset }: ErrorComponentProps): import("react").JSX.Element;
|
|
9
|
+
export declare function NotFoundComponent(): import("react").JSX.Element;
|
|
10
|
+
//# sourceMappingURL=route-defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route-defaults.d.ts","sourceRoot":"","sources":["../../src/provider/route-defaults.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAKjE,wBAAgB,gBAAgB,gCAM/B;AAGD,wBAAgB,cAAc,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,mBAAmB,+BAUnE;AAED,wBAAgB,iBAAiB,gCAOhC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { toErrorMessage } from "../common/errors.js";
|
|
3
|
+
import fallback from "./fallback.module.css";
|
|
4
|
+
import classes from "./route-defaults.module.css";
|
|
5
|
+
function PendingComponent() {
|
|
6
|
+
return /* @__PURE__ */ jsx("div", { className: classes.center, children: /* @__PURE__ */ jsx("output", { className: classes.spinner, "aria-label": "Loading" }) });
|
|
7
|
+
}
|
|
8
|
+
function ErrorComponent({ error, reset }) {
|
|
9
|
+
return /* @__PURE__ */ jsxs("div", { className: fallback.stack, role: "alert", children: [
|
|
10
|
+
/* @__PURE__ */ jsx("p", { className: fallback.title, children: "Something went wrong" }),
|
|
11
|
+
/* @__PURE__ */ jsx("p", { className: fallback.text, children: toErrorMessage(error) }),
|
|
12
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: fallback.action, onClick: reset, children: "Try again" })
|
|
13
|
+
] });
|
|
14
|
+
}
|
|
15
|
+
function NotFoundComponent() {
|
|
16
|
+
return /* @__PURE__ */ jsxs("div", { className: classes.notFound, children: [
|
|
17
|
+
/* @__PURE__ */ jsx("p", { className: fallback.title, children: "Page not found" }),
|
|
18
|
+
/* @__PURE__ */ jsx("p", { className: fallback.text, children: "This address does not match any page." })
|
|
19
|
+
] });
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
ErrorComponent,
|
|
23
|
+
NotFoundComponent,
|
|
24
|
+
PendingComponent
|
|
25
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/* The router's default screens render at the route that failed, which can be ABOVE BasaltProvider.
|
|
2
|
+
Shared stack/title/text/action live in fallback.module.css; same literal-fallback rule. */
|
|
3
|
+
.center {
|
|
4
|
+
display: flex;
|
|
5
|
+
justify-content: center;
|
|
6
|
+
padding: var(--vx-space-stack-xl, 2rem) 0;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.spinner {
|
|
10
|
+
width: 1.25rem;
|
|
11
|
+
height: 1.25rem;
|
|
12
|
+
border: 2px solid currentColor;
|
|
13
|
+
border-top-color: currentColor;
|
|
14
|
+
border: 2px solid color-mix(in srgb, currentColor 20%, transparent);
|
|
15
|
+
border-top-color: var(--vx-accent, currentColor);
|
|
16
|
+
border-radius: 50%;
|
|
17
|
+
animation: spin 0.8s linear infinite;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@keyframes spin {
|
|
21
|
+
to {
|
|
22
|
+
transform: rotate(360deg);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/* A static ring is still a loading mark; the aria-label carries the state. */
|
|
27
|
+
@media (prefers-reduced-motion: reduce) {
|
|
28
|
+
.spinner {
|
|
29
|
+
animation: none;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* Not-found is a statement, not an error with an action: its own column, no flex-start alignment. */
|
|
34
|
+
.notFound {
|
|
35
|
+
display: flex;
|
|
36
|
+
flex-direction: column;
|
|
37
|
+
gap: 4px;
|
|
38
|
+
padding: var(--vx-space-stack-md, 1rem);
|
|
39
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed CSS-module declaration (the S4 CSS-modules path). Named string props — not an index
|
|
3
|
+
* signature — so dot access stays verbatim under the package's strict flags.
|
|
4
|
+
*/
|
|
5
|
+
declare const classes: {
|
|
6
|
+
readonly center: string
|
|
7
|
+
readonly spinner: string
|
|
8
|
+
readonly notFound: string
|
|
9
|
+
}
|
|
10
|
+
export default classes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/theme/index.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EA0CV,oBAAoB,EAGpB,oBAAoB,EAErB,MAAM,eAAe,CAAA;AAStB,OAAO,KAAK,EAAe,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAE/E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAGpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AASvD;;;;;GAKG;AACH,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAIvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAMvD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAA;AAenE,OAAO,QAAQ,eAAe,CAAC;IAC7B,UAAU,iBAAiB;Q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AkB,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AAsF7D;;8FAE8F;AAC9F,eAAO,MAAM,oBAAoB,EAAE,oBACc,CAAA;AAEjD,kEAAkE;AAClE,MAAM,MAAM,wBAAwB,GAAG;IACrC;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAA;IAE9B;;;;;;;;;;;;;;;;OAgBG;IACH,KAAK,CAAC,EAAE,iBAAiB,CAAA;IAEzB;;;;;;;;;;;;;;;;OAgBG;IACH,MAAM,CAAC,EAAE,iBAAiB,CAAA;IAE1B;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,OAAO,CAAC,EAAE,kBAAkB,CAAA;CAC7B,CAAA;AAYD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,CAAC,EAAE,IAAI,CAAC,oBAAoB,EAAE,aAAa,CAAC,EACrD,OAAO,CAAC,EAAE,wBAAwB,GACjC,oBAAoB,CAiCtB"}
|
package/dist/theme/index.js
CHANGED
|
@@ -693,7 +693,10 @@ function buildTheme(data, options = {}) {
|
|
|
693
693
|
// behind it. Title = head font; close button = the ghost idiom (floating.module.css). Below the
|
|
694
694
|
// `medium` size class the Modal is a bottom sheet (floating.module.css `sheet*`).
|
|
695
695
|
Modal: ext({
|
|
696
|
-
defaultProps: {
|
|
696
|
+
defaultProps: {
|
|
697
|
+
radius: radius.floating,
|
|
698
|
+
closeButtonProps: { ...HIT_ATTR, "aria-label": "Close" }
|
|
699
|
+
},
|
|
697
700
|
classNames: {
|
|
698
701
|
close: floatingClasses.closeButton,
|
|
699
702
|
inner: floatingClasses.sheetInner,
|
package/llms.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# basalt-ui v2.13.
|
|
1
|
+
# basalt-ui v2.13.3
|
|
2
2
|
# Opinionated framework for Mantine-based React apps — theme, app shell, TanStack Charts, toolchain presets
|
|
3
3
|
#
|
|
4
4
|
# Entry points: use the exact import specifier below; do not guess.
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
# A subpath's `Install:` line is its required peers; `OptionalPeers:` are import()-only, install on use.
|
|
14
14
|
|
|
15
15
|
Package: basalt-ui
|
|
16
|
-
Version: 2.13.
|
|
16
|
+
Version: 2.13.3
|
|
17
17
|
|
|
18
18
|
## basalt-ui
|
|
19
19
|
Import: import { ... } from 'basalt-ui'
|
package/package.json
CHANGED
package/src/charts/compile.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `compileCartesian` — basalt's chart spec in, a TanStack definition out (`docs/V2-SPEC.md` § 9.2).
|
|
3
3
|
* Pure and React-free: the host memoizes it, the tests call it directly. It owns the scales and
|
|
4
|
-
* domains, the theme bridge, zones / x-zones / reference lines, the crosshair,
|
|
5
|
-
*
|
|
4
|
+
* domains, the theme bridge, zones / x-zones / reference lines, the crosshair, the shared cursor
|
|
5
|
+
* binding, the tooltip content, and the container-class guide ladder.
|
|
6
6
|
* TanStack owns margins (measured), layout, focus and keyboard, the tooltip surface and SSR.
|
|
7
7
|
*/
|
|
8
8
|
import { crosshair } from '@tanstack/charts/crosshair'
|
|
@@ -11,7 +11,6 @@ import { rect } from '@tanstack/charts/rect'
|
|
|
11
11
|
import { ruleX, ruleY } from '@tanstack/charts/rule'
|
|
12
12
|
import { scaleLinear } from '@tanstack/charts/scales/linear'
|
|
13
13
|
import { scaleUtc } from 'd3-scale'
|
|
14
|
-
import { tooltip as tooltipHost } from '@tanstack/charts/tooltip'
|
|
15
14
|
import { portal } from '@tanstack/charts/tooltip/portal'
|
|
16
15
|
import type {
|
|
17
16
|
ChartBuildContext,
|
|
@@ -27,7 +26,7 @@ import { SHORT_CHART_HEIGHT } from './box'
|
|
|
27
26
|
import { fmtCompact } from '../format/number'
|
|
28
27
|
import { VX } from '../tokens'
|
|
29
28
|
import type { ContainerClass } from '../tokens/size-classes'
|
|
30
|
-
import { cursorBinding,
|
|
29
|
+
import { cursorBinding, followerOptions, quietWhileFollowing } from './cursor'
|
|
31
30
|
import { cursorDots } from './marks'
|
|
32
31
|
import { bucketTicks, strideEvery } from './ticks'
|
|
33
32
|
import { MAIN_PANE, plotAccess, plotContext } from './plot-context'
|
|
@@ -805,7 +804,8 @@ function tooltipSpec<T, X extends ChartX>(opts: {
|
|
|
805
804
|
(s) => s.tooltip !== false,
|
|
806
805
|
)
|
|
807
806
|
return {
|
|
808
|
-
use:
|
|
807
|
+
use: quietWhileFollowing,
|
|
808
|
+
...followerOptions(input.tooltip, input.cursorGroup, input.chartId),
|
|
809
809
|
portal,
|
|
810
810
|
anchor: 'group-center',
|
|
811
811
|
content: (points: readonly ChartPoint[]) => {
|
|
@@ -909,11 +909,9 @@ export function compileCartesian<T, X extends ChartX>(
|
|
|
909
909
|
...(labelsInside(cls, height) && { margin: { left: 0, ...(axes.right && { right: 0 }) } }),
|
|
910
910
|
}
|
|
911
911
|
},
|
|
912
|
-
// Followers
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
? 'group-x'
|
|
916
|
-
: sourceOnlyFocus(input.cursorGroup, input.chartId),
|
|
912
|
+
// Followers resolve the leader's group, so they draw its dots; `quietWhileFollowing` mutes the
|
|
913
|
+
// tooltip unless the chart opts into following tooltips.
|
|
914
|
+
focus: 'group-x',
|
|
917
915
|
maxFocusDistance: Number.POSITIVE_INFINITY,
|
|
918
916
|
cursor: cursorBinding({
|
|
919
917
|
group: input.cursorGroup,
|
package/src/charts/cursor.ts
CHANGED
|
@@ -15,12 +15,9 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import { createChartCursor, cursorHost } from '@tanstack/charts/cursor'
|
|
17
17
|
import type { ChartCursorController } from '@tanstack/charts/cursor'
|
|
18
|
-
import {
|
|
19
|
-
import type {
|
|
20
|
-
|
|
21
|
-
ChartFocusStrategy,
|
|
22
|
-
ChartValue,
|
|
23
|
-
} from '@tanstack/charts/types/core'
|
|
18
|
+
import { tooltip } from '@tanstack/charts/tooltip'
|
|
19
|
+
import type { ChartTooltipExtension } from '@tanstack/charts/tooltip'
|
|
20
|
+
import type { ChartCursorBinding, ChartValue } from '@tanstack/charts/types/core'
|
|
24
21
|
import type { ChartX, CursorResolution } from './types'
|
|
25
22
|
|
|
26
23
|
type CursorState = ReturnType<ChartCursorController['getState']>
|
|
@@ -244,20 +241,73 @@ export function chartCursorView(
|
|
|
244
241
|
}
|
|
245
242
|
|
|
246
243
|
/**
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
* focus strategy. Wrapping `group-x` so it groups nothing while a FOREIGN state is current leaves a
|
|
250
|
-
* follower with the crosshair (painted from the cursor presentation, not from focus) and nothing
|
|
251
|
-
* else.
|
|
244
|
+
* The extra key a chart puts on its tooltip options to name itself to {@link quietWhileFollowing}.
|
|
245
|
+
* Absent, the tooltip paints for followers too.
|
|
252
246
|
*/
|
|
253
|
-
export
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
247
|
+
export type TooltipFollowerOptions = {
|
|
248
|
+
readonly follower?: { readonly group: string | undefined; readonly chartId: string } | undefined
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const isFollowerOptions = (options: unknown): options is TooltipFollowerOptions => {
|
|
252
|
+
if (typeof options !== 'object' || options === null || !('follower' in options)) return false
|
|
253
|
+
const { follower } = options
|
|
254
|
+
return (
|
|
255
|
+
follower === undefined ||
|
|
256
|
+
(typeof follower === 'object' &&
|
|
257
|
+
follower !== null &&
|
|
258
|
+
'group' in follower &&
|
|
259
|
+
'chartId' in follower &&
|
|
260
|
+
typeof follower.chartId === 'string')
|
|
261
|
+
)
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* The tooltip options a chart spreads next to `use: quietWhileFollowing`: its identity, unless the
|
|
266
|
+
* chart opted into following tooltips (`tooltip.onFollow`). The one place `onFollow` is read for
|
|
267
|
+
* this, shared by `compileCartesian` and the panel rung.
|
|
268
|
+
*/
|
|
269
|
+
export function followerOptions(
|
|
270
|
+
tooltip: { onFollow?: boolean | undefined } | false | null | undefined,
|
|
271
|
+
group: string | undefined,
|
|
272
|
+
chartId: string,
|
|
273
|
+
): TooltipFollowerOptions {
|
|
274
|
+
const onFollow = typeof tooltip === 'object' && tooltip !== null && tooltip.onFollow === true
|
|
275
|
+
return onFollow ? {} : ({ follower: { group, chartId } } satisfies TooltipFollowerOptions)
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* The engine's DOM tooltip host, silent while this chart FOLLOWS another's cursor. A follower
|
|
280
|
+
* resolves the leader's focus group (so the engine draws the same dots at the shared x); the host
|
|
281
|
+
* would then paint a tooltip and fill its `role="status"` live region. Whenever `isForeign` holds,
|
|
282
|
+
* this wrapper calls the host's `hide()` instead of `paint()`: a follower that has never led never
|
|
283
|
+
* creates the element, and one that has led keeps it in the DOM, hidden. Otherwise (leader, no
|
|
284
|
+
* `follower` option, or after the leader clears) it defers to the host.
|
|
285
|
+
*
|
|
286
|
+
* The chart's identity arrives only through `update` (the engine calls it before every `paint`);
|
|
287
|
+
* a `paint` before the first `update` has nothing to tell it who is leading, so it hides.
|
|
288
|
+
*
|
|
289
|
+
* It wraps `create`/`update`/`paint` of the engine's tooltip host, whose lifecycle is undocumented:
|
|
290
|
+
* re-check this wrapper, the live region included, on every `@tanstack/charts` upgrade.
|
|
291
|
+
*/
|
|
292
|
+
export const quietWhileFollowing: ChartTooltipExtension = {
|
|
293
|
+
...tooltip,
|
|
294
|
+
create: (context) => {
|
|
295
|
+
const host = tooltip.create(context)
|
|
296
|
+
let configured = false
|
|
297
|
+
let follower: TooltipFollowerOptions['follower']
|
|
298
|
+
return {
|
|
299
|
+
...host,
|
|
300
|
+
update: (options) => {
|
|
301
|
+
configured = true
|
|
302
|
+
follower = isFollowerOptions(options) ? options.follower : undefined
|
|
303
|
+
host.update(options)
|
|
304
|
+
},
|
|
305
|
+
paint: (paint) => {
|
|
306
|
+
if (!configured || (follower && isForeign(follower.group, follower.chartId))) host.hide()
|
|
307
|
+
else host.paint(paint)
|
|
308
|
+
},
|
|
309
|
+
}
|
|
310
|
+
},
|
|
261
311
|
}
|
|
262
312
|
|
|
263
313
|
export function cursorBinding(opts: {
|
package/src/charts/legend.tsx
CHANGED
|
@@ -11,9 +11,10 @@ import type { ChartSeries } from './types'
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* `auto` renders both swatches and lets the container decide: none, dots or chips (CSS). The
|
|
14
|
-
* swatch SHAPE follows the mode, signed split included: below 480px a dot (8px
|
|
15
|
-
* a chip (10px square) — so one `DualPanel` bar legend is a split circle on a
|
|
16
|
-
* split square on a wide one.
|
|
14
|
+
* swatch SHAPE follows the mode for a filled mark, signed split included: below 480px a dot (8px
|
|
15
|
+
* circle), from 480px a chip (10px square) — so one `DualPanel` bar legend is a split circle on a
|
|
16
|
+
* narrow card and a split square on a wide one. A LINE series swaps a short stroke for a shorter
|
|
17
|
+
* one instead, dash included, so it is never a dot. Not a per-chart prop.
|
|
17
18
|
*/
|
|
18
19
|
export type LegendMode = 'dots' | 'chips' | 'auto'
|
|
19
20
|
|
|
@@ -105,6 +106,41 @@ type SwatchStyle = Pick<
|
|
|
105
106
|
const swatchFill = (s: SwatchStyle): string =>
|
|
106
107
|
s.colorNegative ? `linear-gradient(90deg, ${s.color} 50%, ${s.colorNegative} 50%)` : s.color
|
|
107
108
|
|
|
109
|
+
/**
|
|
110
|
+
* A line series' key: a short stroke with its dash, compact below 480px and wide from 480px. A
|
|
111
|
+
* dashed swatch has BUTT caps: a round cap grows each dash by half the stroke width per end and
|
|
112
|
+
* would close the gap.
|
|
113
|
+
*/
|
|
114
|
+
export const LINE_SWATCH = {
|
|
115
|
+
compact: { width: 8, dash: '2.5 2' },
|
|
116
|
+
wide: { width: 12, dash: '4 3' },
|
|
117
|
+
} as const
|
|
118
|
+
|
|
119
|
+
function LineSwatch({ s, compact }: { s: SwatchStyle; compact: boolean }): ReactElement {
|
|
120
|
+
const { width, dash } = compact ? LINE_SWATCH.compact : LINE_SWATCH.wide
|
|
121
|
+
return (
|
|
122
|
+
<svg
|
|
123
|
+
aria-hidden
|
|
124
|
+
className={compact ? classes.dot : classes.chip}
|
|
125
|
+
width={width}
|
|
126
|
+
height={8}
|
|
127
|
+
style={{ flex: 'none' }}
|
|
128
|
+
>
|
|
129
|
+
<line
|
|
130
|
+
x1={1}
|
|
131
|
+
x2={width - 1}
|
|
132
|
+
y1={4}
|
|
133
|
+
y2={4}
|
|
134
|
+
stroke={s.color}
|
|
135
|
+
strokeWidth={2}
|
|
136
|
+
strokeLinecap={s.dash === 'dashed' ? 'butt' : 'round'}
|
|
137
|
+
strokeOpacity={s.strokeOpacity ?? 1}
|
|
138
|
+
{...(s.dash === 'dashed' && { strokeDasharray: dash })}
|
|
139
|
+
/>
|
|
140
|
+
</svg>
|
|
141
|
+
)
|
|
142
|
+
}
|
|
143
|
+
|
|
108
144
|
function Swatch({ s, mode }: { s: SwatchStyle; mode: LegendMode }): ReactElement {
|
|
109
145
|
if (mode === 'auto')
|
|
110
146
|
return (
|
|
@@ -113,6 +149,7 @@ function Swatch({ s, mode }: { s: SwatchStyle; mode: LegendMode }): ReactElement
|
|
|
113
149
|
<Swatch s={s} mode="chips" />
|
|
114
150
|
</>
|
|
115
151
|
)
|
|
152
|
+
if ((s.mark ?? 'line') === 'line') return <LineSwatch s={s} compact={mode === 'dots'} />
|
|
116
153
|
if (mode === 'dots')
|
|
117
154
|
return (
|
|
118
155
|
<span
|
|
@@ -129,22 +166,6 @@ function Swatch({ s, mode }: { s: SwatchStyle; mode: LegendMode }): ReactElement
|
|
|
129
166
|
}}
|
|
130
167
|
/>
|
|
131
168
|
)
|
|
132
|
-
if ((s.mark ?? 'line') === 'line')
|
|
133
|
-
return (
|
|
134
|
-
<svg aria-hidden className={classes.chip} width={16} height={8} style={{ flex: 'none' }}>
|
|
135
|
-
<line
|
|
136
|
-
x1={1}
|
|
137
|
-
x2={15}
|
|
138
|
-
y1={4}
|
|
139
|
-
y2={4}
|
|
140
|
-
stroke={s.color}
|
|
141
|
-
strokeWidth={2}
|
|
142
|
-
strokeLinecap="round"
|
|
143
|
-
strokeOpacity={s.strokeOpacity ?? 1}
|
|
144
|
-
{...(s.dash === 'dashed' && { strokeDasharray: '4 3' })}
|
|
145
|
-
/>
|
|
146
|
-
</svg>
|
|
147
|
-
)
|
|
148
169
|
return (
|
|
149
170
|
<span
|
|
150
171
|
aria-hidden
|
package/src/charts/marks.ts
CHANGED
|
@@ -156,38 +156,37 @@ export function cursorDots<T, X extends ChartX>(
|
|
|
156
156
|
rows: readonly PlotRow<T, X>[],
|
|
157
157
|
yScale: 'y2' | undefined,
|
|
158
158
|
): ChartMarks {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
159
|
+
const { getMarker } = s
|
|
160
|
+
// `dot.fill` is constant but a state style's is not: one mark whose focused fill is the datum's
|
|
161
|
+
// own `getMarker` colour, resolved once per row here rather than on every focus repaint. The map
|
|
162
|
+
// is keyed by the row OBJECT: the engine hands the same objects back as the state context's datum.
|
|
163
|
+
const colors = getMarker
|
|
164
|
+
? new Map(rows.map((r) => [r, getMarker(r.datum)?.color ?? s.color]))
|
|
165
|
+
: undefined
|
|
166
|
+
const focused = {
|
|
167
|
+
fillOpacity: 1,
|
|
168
|
+
strokeOpacity: 1,
|
|
169
|
+
...(colors && {
|
|
170
|
+
fill: ({ datum }: { datum: PlotRow<T, X> }): string => colors.get(datum) ?? s.color,
|
|
171
|
+
}),
|
|
166
172
|
}
|
|
167
|
-
return [
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
:
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
states: [{ when: { focus: 'x' }, style: { fillOpacity: 1, strokeOpacity: 1 } }],
|
|
183
|
-
...(yScale !== undefined && { yScale }),
|
|
184
|
-
}),
|
|
185
|
-
],
|
|
186
|
-
)
|
|
173
|
+
return [
|
|
174
|
+
dot(rows, {
|
|
175
|
+
id: `${s.key}-cursor`,
|
|
176
|
+
x: rowX,
|
|
177
|
+
y: 'y',
|
|
178
|
+
r: VX.dotR,
|
|
179
|
+
fill: s.color,
|
|
180
|
+
fillOpacity: 0,
|
|
181
|
+
stroke: VX.surface.panel,
|
|
182
|
+
strokeWidth: 1.5,
|
|
183
|
+
strokeOpacity: 0,
|
|
184
|
+
states: [{ when: { focus: 'x' }, style: focused }],
|
|
185
|
+
...(yScale !== undefined && { yScale }),
|
|
186
|
+
}),
|
|
187
|
+
]
|
|
187
188
|
}
|
|
188
189
|
|
|
189
|
-
const colorSlug = (color: string): string => color.replaceAll(/[^\w-]+/g, '_')
|
|
190
|
-
|
|
191
190
|
/**
|
|
192
191
|
* A single-series `barY`. The engine stacks every `barY` that has no explicit extent, and a row with
|
|
193
192
|
* no `z`/`color` channel is its own series: an N-by-N matrix (a 5k-row `DualPanel` took 10 s). So
|