@squadbase/vantage 0.6.2-dev1.d7c0911 → 0.6.2-dev1.e30f2cc
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/{build-X5NVCQKT.js → build-A23M4GCH.js} +7 -7
- package/dist/{build-X5NVCQKT.js.map → build-A23M4GCH.js.map} +1 -1
- package/dist/{check-ZBIH422T.js → check-FBHT6W6J.js} +5 -5
- package/dist/{check-ZBIH422T.js.map → check-FBHT6W6J.js.map} +1 -1
- package/dist/chunk-2IAPIOPS.js +152 -0
- package/dist/chunk-2IAPIOPS.js.map +1 -0
- package/dist/chunk-57GHR5LN.js +163 -0
- package/dist/chunk-57GHR5LN.js.map +1 -0
- package/dist/{chunk-7DZGJQ3P.js → chunk-5C2SEDPH.js} +21 -4
- package/dist/chunk-5C2SEDPH.js.map +1 -0
- package/dist/chunk-6OTTGAPO.js +44 -0
- package/dist/chunk-6OTTGAPO.js.map +1 -0
- package/dist/{chunk-XPQSTZUU.js → chunk-7S52M2SL.js} +4 -3
- package/dist/chunk-7S52M2SL.js.map +1 -0
- package/dist/{chunk-V3LF7BE7.js → chunk-ANZLVSEP.js} +4 -5
- package/dist/chunk-ANZLVSEP.js.map +1 -0
- package/dist/{chunk-XQUSGIDG.js → chunk-CKWPK4RO.js} +10 -3
- package/dist/chunk-CKWPK4RO.js.map +1 -0
- package/dist/chunk-JXFCSF3K.js +673 -0
- package/dist/chunk-JXFCSF3K.js.map +1 -0
- package/dist/{chunk-WRSX2MDK.js → chunk-QOXXOFGL.js} +115 -930
- package/dist/chunk-QOXXOFGL.js.map +1 -0
- package/dist/{chunk-CEXAQQ5W.js → chunk-S5MDTHH7.js} +180 -18
- package/dist/chunk-S5MDTHH7.js.map +1 -0
- package/dist/{chunk-2ICNHUG6.js → chunk-SDJTTMLK.js} +64 -7
- package/dist/chunk-SDJTTMLK.js.map +1 -0
- package/dist/{chunk-WAMZWZJB.js → chunk-SHZM3EXB.js} +19 -8
- package/dist/chunk-SHZM3EXB.js.map +1 -0
- package/dist/{chunk-JKLLFVEU.js → chunk-UWSQUHX6.js} +4 -99
- package/dist/chunk-UWSQUHX6.js.map +1 -0
- package/dist/cli.js +6 -6
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.js +8 -2
- package/dist/client/index.js.map +1 -1
- package/dist/components/index.d.ts +13 -249
- package/dist/components/index.js +5 -2
- package/dist/delta-text-CvwBGJ95.d.ts +15 -0
- package/dist/{dev-4XEDTELV.js → dev-H4I2JL63.js} +7 -7
- package/dist/{dev-4XEDTELV.js.map → dev-H4I2JL63.js.map} +1 -1
- package/dist/doc/index.d.ts +215 -2
- package/dist/doc/index.js +307 -3
- package/dist/doc/index.js.map +1 -1
- package/dist/{doctor-5E2VEZPK.js → doctor-B2O3GJDU.js} +5 -5
- package/dist/{doctor-5E2VEZPK.js.map → doctor-B2O3GJDU.js.map} +1 -1
- package/dist/format-U0cQl069.d.ts +243 -0
- package/dist/query/index.js +2 -2
- package/dist/{routes-3SGAFDMC.js → routes-PVKNT777.js} +4 -4
- package/dist/{routes-3SGAFDMC.js.map → routes-PVKNT777.js.map} +1 -1
- package/dist/slide/index.d.ts +272 -1
- package/dist/slide/index.js +974 -4
- package/dist/slide/index.js.map +1 -1
- package/dist/table/index.js +8 -5
- package/dist/table/index.js.map +1 -1
- package/dist/ui/index.d.ts +4 -1
- package/dist/ui/index.js +3 -3
- package/dist/ui/index.js.map +1 -1
- package/dist/{upgrade-JHXZBGQS.js → upgrade-6DT7ADRP.js} +4 -4
- package/dist/{upgrade-JHXZBGQS.js.map → upgrade-6DT7ADRP.js.map} +1 -1
- package/dist/vite/index.js +3 -3
- package/docs/en/changelog.md +2 -0
- package/docs/en/components.md +13 -2
- package/docs/en/doc/delta-text.md +40 -0
- package/docs/en/doc/doc-action-items.md +49 -0
- package/docs/en/doc/doc-callout.md +38 -0
- package/docs/en/doc/doc-data-table.md +60 -0
- package/docs/en/doc/doc-executive-summary.md +64 -0
- package/docs/en/doc/doc-figure.md +56 -0
- package/docs/en/doc/doc-key-findings.md +61 -0
- package/docs/en/doc/doc-kpi-scorecard.md +80 -0
- package/docs/en/doc/doc-notes-and-sources.md +43 -0
- package/docs/en/doc/doc-report-header.md +46 -0
- package/docs/en/pages-and-metadata.md +15 -0
- package/docs/en/parts/area-chart.md +99 -0
- package/docs/en/parts/bar-chart.md +91 -0
- package/docs/en/parts/bar-list.md +50 -0
- package/docs/en/parts/category-bar.md +37 -0
- package/docs/en/parts/chart-frame.md +39 -0
- package/docs/en/parts/delta.md +4 -3
- package/docs/en/parts/donut-chart.md +72 -0
- package/docs/en/parts/funnel-steps.md +2 -1
- package/docs/en/parts/heatmap.md +53 -0
- package/docs/en/parts/kpi-card.md +2 -1
- package/docs/en/parts/legend.md +35 -0
- package/docs/en/parts/line-chart.md +94 -0
- package/docs/en/parts/progress-circle.md +33 -0
- package/docs/en/parts/sample-data.md +39 -0
- package/docs/en/parts/scatter-chart.md +56 -0
- package/docs/en/parts/tracker.md +36 -0
- package/docs/en/parts/updated-at.md +30 -0
- package/docs/en/parts/waterfall-chart.md +56 -0
- package/docs/en/slide/slide-chart-full.md +48 -0
- package/docs/en/slide/slide-chart-insight.md +52 -0
- package/docs/en/slide/slide-columns.md +46 -0
- package/docs/en/slide/slide-comparison.md +68 -0
- package/docs/en/slide/slide-cover.md +39 -0
- package/docs/en/slide/slide-exec-summary.md +47 -0
- package/docs/en/slide/slide-heading.md +38 -0
- package/docs/en/slide/slide-kpi-grid.md +55 -0
- package/docs/en/slide/slide-kpi-hero.md +58 -0
- package/docs/en/slide/slide-next-actions.md +49 -0
- package/docs/en/slide/slide-scorecard-table.md +54 -0
- package/docs/en/slide/slide-section.md +44 -0
- package/docs/en/slide/slide-source-line.md +34 -0
- package/docs/en/ui/alert-dialog.md +42 -0
- package/docs/en/ui/avatar.md +31 -0
- package/docs/en/ui/combobox.md +74 -0
- package/docs/en/ui/drawer.md +41 -0
- package/docs/en/ui/empty.md +1 -1
- package/docs/en/ui/error-state.md +4 -3
- package/docs/en/ui/field.md +42 -0
- package/docs/en/ui/hover-card.md +21 -0
- package/docs/en/ui/kbd.md +17 -0
- package/docs/en/ui/loading.md +1 -1
- package/docs/en/ui/pagination.md +36 -0
- package/docs/en/ui/radio-group.md +21 -0
- package/docs/en/ui/toast.md +44 -0
- package/docs/en/ui/toggle-group.md +4 -3
- package/docs/index.json +857 -77
- package/docs/ja/changelog.md +2 -0
- package/docs/ja/components.md +12 -1
- package/docs/ja/doc/delta-text.md +40 -0
- package/docs/ja/doc/doc-action-items.md +49 -0
- package/docs/ja/doc/doc-callout.md +38 -0
- package/docs/ja/doc/doc-data-table.md +60 -0
- package/docs/ja/doc/doc-executive-summary.md +64 -0
- package/docs/ja/doc/doc-figure.md +56 -0
- package/docs/ja/doc/doc-key-findings.md +61 -0
- package/docs/ja/doc/doc-kpi-scorecard.md +80 -0
- package/docs/ja/doc/doc-notes-and-sources.md +43 -0
- package/docs/ja/doc/doc-report-header.md +46 -0
- package/docs/ja/page-types/slide.md +1 -0
- package/docs/ja/pages-and-metadata.md +15 -0
- package/docs/ja/parts/area-chart.md +49 -25
- package/docs/ja/parts/bar-chart.md +50 -24
- package/docs/ja/parts/bar-list.md +31 -8
- package/docs/ja/parts/chart-frame.md +36 -0
- package/docs/ja/parts/delta.md +5 -4
- package/docs/ja/parts/donut-chart.md +45 -26
- package/docs/ja/parts/funnel-steps.md +27 -8
- package/docs/ja/parts/heatmap.md +45 -0
- package/docs/ja/parts/kpi-card.md +2 -1
- package/docs/ja/parts/legend.md +36 -0
- package/docs/ja/parts/line-chart.md +48 -22
- package/docs/ja/parts/sample-data.md +61 -0
- package/docs/ja/parts/scatter-chart.md +69 -0
- package/docs/ja/parts/updated-at.md +27 -0
- package/docs/ja/parts/waterfall-chart.md +61 -0
- package/docs/ja/slide/slide-chart-full.md +48 -0
- package/docs/ja/slide/slide-chart-insight.md +52 -0
- package/docs/ja/slide/slide-columns.md +46 -0
- package/docs/ja/slide/slide-comparison.md +68 -0
- package/docs/ja/slide/slide-cover.md +39 -0
- package/docs/ja/slide/slide-exec-summary.md +47 -0
- package/docs/ja/slide/slide-heading.md +38 -0
- package/docs/ja/slide/slide-kpi-grid.md +55 -0
- package/docs/ja/slide/slide-kpi-hero.md +58 -0
- package/docs/ja/slide/slide-next-actions.md +49 -0
- package/docs/ja/slide/slide-scorecard-table.md +54 -0
- package/docs/ja/slide/slide-section.md +44 -0
- package/docs/ja/slide/slide-source-line.md +34 -0
- package/docs/ja/ui/empty.md +1 -1
- package/docs/ja/ui/error-state.md +4 -3
- package/docs/ja/ui/loading.md +1 -1
- package/docs/ja/ui/toggle-group.md +4 -3
- package/package.json +26 -25
- package/registry/ui/accordion.tsx +1 -1
- package/registry/ui/alert-dialog.tsx +1 -1
- package/registry/ui/alert.tsx +1 -1
- package/registry/ui/app-shell.tsx +1 -1
- package/registry/ui/area-chart.tsx +89 -27
- package/registry/ui/attention-list.tsx +303 -0
- package/registry/ui/avatar.tsx +1 -1
- package/registry/ui/badge.tsx +1 -1
- package/registry/ui/bar-chart.tsx +89 -27
- package/registry/ui/bar-list.tsx +88 -25
- package/registry/ui/box-plot-chart.tsx +3906 -0
- package/registry/ui/breadcrumb.tsx +1 -1
- package/registry/ui/button.tsx +1 -1
- package/registry/ui/calendar.tsx +1 -1
- package/registry/ui/card.tsx +1 -1
- package/registry/ui/category-bar.tsx +55 -20
- package/registry/ui/chart-frame.tsx +57 -22
- package/registry/ui/checkbox.tsx +1 -1
- package/registry/ui/collapsible.tsx +1 -1
- package/registry/ui/combobox.tsx +1 -1
- package/registry/ui/command.tsx +1 -1
- package/registry/ui/dashboard-card.tsx +5 -5
- package/registry/ui/data-table.tsx +1 -1
- package/registry/ui/date-range-picker.tsx +1 -1
- package/registry/ui/delta.tsx +12 -9
- package/registry/ui/dialog.tsx +1 -1
- package/registry/ui/donut-chart.tsx +90 -27
- package/registry/ui/drawer.tsx +1 -1
- package/registry/ui/dropdown-menu.tsx +1 -1
- package/registry/ui/echart.tsx +195 -45
- package/registry/ui/field.tsx +1 -1
- package/registry/ui/filter-bar.tsx +1 -1
- package/registry/ui/funnel-steps.tsx +34 -6
- package/registry/ui/heatmap.tsx +56 -22
- package/registry/ui/histogram-chart.tsx +3986 -0
- package/registry/ui/hover-card.tsx +1 -1
- package/registry/ui/input-group.tsx +1 -1
- package/registry/ui/input.tsx +1 -1
- package/registry/ui/kbd.tsx +1 -1
- package/registry/ui/kpi-card.tsx +42 -15
- package/registry/ui/label.tsx +1 -1
- package/registry/ui/legend.tsx +88 -25
- package/registry/ui/line-chart.tsx +89 -27
- package/registry/ui/metric-value.tsx +1 -1
- package/registry/ui/multi-select.tsx +1 -1
- package/registry/ui/page-shell.tsx +11 -11
- package/registry/ui/pagination.tsx +1 -1
- package/registry/ui/paired-chart.tsx +3827 -0
- package/registry/ui/placeholder.tsx +1 -1
- package/registry/ui/popover.tsx +1 -1
- package/registry/ui/progress-circle.tsx +1 -1
- package/registry/ui/progress.tsx +1 -1
- package/registry/ui/radio-group.tsx +1 -1
- package/registry/ui/sample-data.tsx +2 -2
- package/registry/ui/scatter-chart.tsx +89 -27
- package/registry/ui/scroll-area.tsx +1 -1
- package/registry/ui/searchable-select.tsx +1 -1
- package/registry/ui/section-header.tsx +3 -3
- package/registry/ui/segmented-control.tsx +1 -1
- package/registry/ui/select.tsx +1 -1
- package/registry/ui/separator.tsx +1 -1
- package/registry/ui/sheet.tsx +1 -1
- package/registry/ui/sidebar.tsx +1 -1
- package/registry/ui/skeleton.tsx +1 -1
- package/registry/ui/slider.tsx +2 -2
- package/registry/ui/sparkline.tsx +1 -1
- package/registry/ui/spinner.tsx +1 -1
- package/registry/ui/states.tsx +1 -1
- package/registry/ui/status-badge.tsx +9 -9
- package/registry/ui/switch.tsx +1 -1
- package/registry/ui/table.tsx +1 -1
- package/registry/ui/tabs.tsx +1 -1
- package/registry/ui/textarea.tsx +1 -1
- package/registry/ui/toast.tsx +1 -1
- package/registry/ui/toggle-group.tsx +1 -1
- package/registry/ui/toggle.tsx +1 -1
- package/registry/ui/tooltip.tsx +7 -3
- package/registry/ui/tracker.tsx +10 -4
- package/registry/ui/trend-indicator.tsx +3 -3
- package/registry/ui/updated-at.tsx +1 -1
- package/registry/ui/waterfall-chart.tsx +89 -27
- package/skills/vantage-design/SKILL.md +34 -24
- package/skills/vantage-design/references/extract.md +16 -14
- package/skills/vantage-design/references/format.md +6 -5
- package/skills/vantage-design/references/presets.md +60 -110
- package/skills/vantage-pitfalls/SKILL.md +5 -0
- package/skills/vantage-slide/SKILL.md +54 -36
- package/templates/AGENTS.md +4 -2
- package/templates/agents/doc.md +48 -0
- package/templates/agents/page.md +32 -1
- package/templates/agents/slide.md +70 -2
- package/theme.css +32 -24
- package/dist/chunk-2ICNHUG6.js.map +0 -1
- package/dist/chunk-7DZGJQ3P.js.map +0 -1
- package/dist/chunk-CEXAQQ5W.js.map +0 -1
- package/dist/chunk-JKLLFVEU.js.map +0 -1
- package/dist/chunk-V3LF7BE7.js.map +0 -1
- package/dist/chunk-WAMZWZJB.js.map +0 -1
- package/dist/chunk-WRSX2MDK.js.map +0 -1
- package/dist/chunk-XPQSTZUU.js.map +0 -1
- package/dist/chunk-XQUSGIDG.js.map +0 -1
package/registry/ui/heatmap.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Copied by `vantage add ui heatmap`. This file is yours to edit.
|
|
2
|
-
// Generated from @squadbase/squadkit registry/charts/heatmap.tsx by `
|
|
2
|
+
// Generated from @squadbase/squadkit registry/charts/heatmap.tsx by `pnpm run registry` (in Vantage, edit packages/squadkit, not registry/).
|
|
3
3
|
"use client"
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -27,7 +27,7 @@ import { ChartFrame } from "@squadbase/vantage/components"
|
|
|
27
27
|
import { EChart } from "@squadbase/vantage/components"
|
|
28
28
|
import { EMPTY_VALUE, type ValueFormat } from "@squadbase/vantage/components"
|
|
29
29
|
import type { ChartActionsOptions, ChartEmptyState, ChartRootAttributes, ChartSeriesColor, ValueFormatter } from "@squadbase/vantage/components"
|
|
30
|
-
import { createContext, useCallback, useEffect, useRef, useState } from "react"
|
|
30
|
+
import { createContext, useCallback, useEffect, useRef, useState, type RefObject } from "react"
|
|
31
31
|
import type { ChartTone } from "@squadbase/vantage/components"
|
|
32
32
|
import { DEFAULT_LOCALE, formatValue, toValueFormatter } from "@squadbase/vantage/components"
|
|
33
33
|
import type { ChartColor, ChartColors } from "@squadbase/vantage/components"
|
|
@@ -56,6 +56,8 @@ const SERIES_TOKENS = ["--chart-1", "--chart-2", "--chart-3", "--chart-4", "--ch
|
|
|
56
56
|
interface ChartTokens {
|
|
57
57
|
/** Resolved `--chart-1..5`, in order. */
|
|
58
58
|
series: string[]
|
|
59
|
+
/** Computed `font-family` of the container, so canvas text matches the DOM. Optional. */
|
|
60
|
+
fontFamily?: string
|
|
59
61
|
/** Body text: titles and the default `textStyle`. */
|
|
60
62
|
foreground: string | null
|
|
61
63
|
/** Secondary text: axis labels, legend, subtitles. */
|
|
@@ -64,10 +66,23 @@ interface ChartTokens {
|
|
|
64
66
|
border: string | null
|
|
65
67
|
/** Tooltip surface. */
|
|
66
68
|
popover: string | null
|
|
69
|
+
/** Semantic and surface dependencies used by typed chart options. Optional for hand-built tokens. */
|
|
70
|
+
colors?: Record<string, string>
|
|
71
|
+
/** Actual inherited painting surface (may change without a token changing). */
|
|
72
|
+
surface?: string | null
|
|
67
73
|
/** Tooltip text. */
|
|
68
74
|
popoverForeground: string | null
|
|
69
75
|
}
|
|
70
76
|
|
|
77
|
+
// Keep scope out of the public token shape. A resolved snapshot remembers where arbitrary
|
|
78
|
+
// var(--token) expressions must be read, without retaining unmounted charts globally.
|
|
79
|
+
const tokenScopes = new WeakMap<ChartTokens, Element>()
|
|
80
|
+
const OPTION_COLOR_TOKENS = [
|
|
81
|
+
"--background", "--card", "--muted", "--primary", "--destructive",
|
|
82
|
+
...["positive", "negative", "warning", "neutral", "info"].flatMap((tone) =>
|
|
83
|
+
["", "-fill", "-subtle"].map((suffix) => `--${tone}${suffix}`)),
|
|
84
|
+
]
|
|
85
|
+
|
|
71
86
|
let normalizeContext: CanvasRenderingContext2D | null | undefined
|
|
72
87
|
|
|
73
88
|
/** The forms `fillStyle` serializes legacy colours to, and zrender can parse. */
|
|
@@ -123,14 +138,19 @@ function readChartTokens(el?: Element | null): ChartTokens | null {
|
|
|
123
138
|
const color = read(token)
|
|
124
139
|
if (color) series.push(color)
|
|
125
140
|
}
|
|
126
|
-
|
|
141
|
+
const tokens: ChartTokens = {
|
|
127
142
|
series,
|
|
143
|
+
colors: Object.fromEntries(OPTION_COLOR_TOKENS.map((name) => [name, styles.getPropertyValue(name).trim()])),
|
|
144
|
+
surface: readChartSurface(target),
|
|
145
|
+
...(styles.fontFamily ? { fontFamily: styles.fontFamily } : {}),
|
|
128
146
|
foreground: read("--foreground"),
|
|
129
147
|
mutedForeground: read("--muted-foreground"),
|
|
130
148
|
border: read("--border"),
|
|
131
149
|
popover: read("--popover"),
|
|
132
150
|
popoverForeground: read("--popover-foreground"),
|
|
133
151
|
}
|
|
152
|
+
tokenScopes.set(tokens, target)
|
|
153
|
+
return tokens
|
|
134
154
|
}
|
|
135
155
|
|
|
136
156
|
/** Structural equality, so a theme toggle that changes nothing doesn't re-init. */
|
|
@@ -138,8 +158,13 @@ function sameChartTokens(a: ChartTokens | null, b: ChartTokens | null): boolean
|
|
|
138
158
|
if (a === b) return true
|
|
139
159
|
if (!a || !b) return false
|
|
140
160
|
return (
|
|
161
|
+
tokenScopes.get(a) === tokenScopes.get(b) &&
|
|
162
|
+
a.surface === b.surface &&
|
|
163
|
+
Object.keys(a.colors ?? {}).length === Object.keys(b.colors ?? {}).length &&
|
|
164
|
+
Object.entries(a.colors ?? {}).every(([name, value]) => b.colors?.[name] === value) &&
|
|
141
165
|
a.series.length === b.series.length &&
|
|
142
166
|
a.series.every((color, i) => color === b.series[i]) &&
|
|
167
|
+
a.fontFamily === b.fontFamily &&
|
|
143
168
|
a.foreground === b.foreground &&
|
|
144
169
|
a.mutedForeground === b.mutedForeground &&
|
|
145
170
|
a.border === b.border &&
|
|
@@ -162,7 +187,7 @@ function sameChartTokens(a: ChartTokens | null, b: ChartTokens | null): boolean
|
|
|
162
187
|
* attributes alone leaves the chart painted in the previous palette until a
|
|
163
188
|
* reload — the tokens in the DOM are new, the canvas is not.
|
|
164
189
|
*/
|
|
165
|
-
function watchChartTokens(onChange: () => void): () => void {
|
|
190
|
+
function watchChartTokens(onChange: () => void, scope?: Element | null): () => void {
|
|
166
191
|
if (typeof document === "undefined") return () => {}
|
|
167
192
|
// Style edits arrive as bursts of mutations; coalesce them into one read, and
|
|
168
193
|
// take it after the next frame so a swapped stylesheet has been applied.
|
|
@@ -177,8 +202,11 @@ function watchChartTokens(onChange: () => void): () => void {
|
|
|
177
202
|
|
|
178
203
|
const themeObserver = new MutationObserver(schedule)
|
|
179
204
|
const attributeFilter = ["class", "style", "data-theme"]
|
|
180
|
-
|
|
181
|
-
|
|
205
|
+
// Only the chart and its ancestors can change its inherited theme. Never observe
|
|
206
|
+
// the document subtree: canvas/tooltip/rendering mutations would trigger every chart.
|
|
207
|
+
for (let node: Element | null = scope ?? document.body ?? document.documentElement; node; node = node.parentElement) {
|
|
208
|
+
themeObserver.observe(node, { attributes: true, attributeFilter })
|
|
209
|
+
}
|
|
182
210
|
|
|
183
211
|
const styleObserver = new MutationObserver(schedule)
|
|
184
212
|
if (document.head) {
|
|
@@ -234,7 +262,7 @@ function buildChartTheme(tokens: ChartTokens): Record<string, unknown> {
|
|
|
234
262
|
// Let the page background show through: charts sit on cards, not on a canvas.
|
|
235
263
|
backgroundColor: "transparent",
|
|
236
264
|
...(tokens.series.length > 0 ? { color: tokens.series } : {}),
|
|
237
|
-
textStyle: { color: text },
|
|
265
|
+
textStyle: { color: text, ...(tokens.fontFamily ? { fontFamily: tokens.fontFamily } : {}) },
|
|
238
266
|
title: { textStyle: { color: text }, subtextStyle: { color: muted } },
|
|
239
267
|
legend: { textStyle: { color: muted } },
|
|
240
268
|
categoryAxis: axisTheme(tokens, false),
|
|
@@ -250,7 +278,11 @@ function buildChartTheme(tokens: ChartTokens): Record<string, unknown> {
|
|
|
250
278
|
padding: [8, 12],
|
|
251
279
|
// Rounded card with a soft shadow; in dark mode the shadow barely shows, so the border carries the edge.
|
|
252
280
|
extraCssText: "border-radius:8px;box-shadow:var(--shadow-card, 0 4px 12px rgb(0 0 0 / 0.08));",
|
|
253
|
-
textStyle: {
|
|
281
|
+
textStyle: {
|
|
282
|
+
color: tokens.popoverForeground ?? undefined,
|
|
283
|
+
fontSize: 12,
|
|
284
|
+
...(tokens.fontFamily ? { fontFamily: tokens.fontFamily } : {}),
|
|
285
|
+
},
|
|
254
286
|
axisPointer: { lineStyle: { color: line }, crossStyle: { color: line } },
|
|
255
287
|
},
|
|
256
288
|
}
|
|
@@ -262,22 +294,23 @@ function buildChartTheme(tokens: ChartTokens): Record<string, unknown> {
|
|
|
262
294
|
* components that build an ECharts option from token colours themselves (the
|
|
263
295
|
* typed charts), so their palette follows light/dark like `EChart`'s theme.
|
|
264
296
|
*/
|
|
265
|
-
function useChartTokens(): ChartTokens | null {
|
|
297
|
+
function useChartTokens(scope?: Element | null | RefObject<Element | null>): ChartTokens | null {
|
|
266
298
|
const [tokens, setTokens] = useState<ChartTokens | null>(() => readChartTokens())
|
|
267
299
|
// Compared here, not inside a `setTokens` updater: an updater that reads the DOM is
|
|
268
300
|
// replayed by React on every rebase and returns a fresh object each time, so the state
|
|
269
301
|
// never settles ("Maximum update depth exceeded" once the tokens change after mount).
|
|
270
302
|
const tokensRef = useRef(tokens)
|
|
271
303
|
useEffect(() => {
|
|
304
|
+
const target = scope && "current" in scope ? scope.current : scope
|
|
272
305
|
const sync = () => {
|
|
273
|
-
const next = readChartTokens()
|
|
306
|
+
const next = readChartTokens(target)
|
|
274
307
|
if (sameChartTokens(tokensRef.current, next)) return
|
|
275
308
|
tokensRef.current = next
|
|
276
309
|
setTokens(next)
|
|
277
310
|
}
|
|
278
311
|
sync()
|
|
279
|
-
return watchChartTokens(sync)
|
|
280
|
-
}, [])
|
|
312
|
+
return watchChartTokens(sync, target)
|
|
313
|
+
}, [scope])
|
|
281
314
|
return tokens
|
|
282
315
|
}
|
|
283
316
|
|
|
@@ -289,7 +322,7 @@ const EMBEDDED_VAR_RE = /var\(\s*(--[\w-]+)\s*\)/g
|
|
|
289
322
|
/**
|
|
290
323
|
* Turn chart colours into canvas-safe strings. `"chart-1"`〜`"chart-5"` come from
|
|
291
324
|
* the resolved series tokens; `"positive"` / `"warning"` / `"negative"` / `"neutral"` (and the area
|
|
292
|
-
* variants `"positive-fill"`, …) are read
|
|
325
|
+
* variants `"positive-fill"`, …) are read in the snapshot's inherited scope (`--positive`, …); `var(--token)` uses the same scope; any
|
|
293
326
|
* other CSS colour is normalized like the tokens are. A colour that can't be
|
|
294
327
|
* resolved comes back as `""`, which ECharts treats as "use the palette".
|
|
295
328
|
*/
|
|
@@ -300,12 +333,13 @@ function resolveChartColors(colors: readonly string[], tokens: ChartTokens | nul
|
|
|
300
333
|
// Meaning colours are the theme tokens of the same name: same path as `var(--positive)`.
|
|
301
334
|
if (TONE_NAME_RE.test(color.trim())) {
|
|
302
335
|
if (typeof document === "undefined") return ""
|
|
303
|
-
|
|
336
|
+
const target = (tokens && tokenScopes.get(tokens)) ?? document.documentElement
|
|
337
|
+
return toCanvasColor(getComputedStyle(target).getPropertyValue(`--${color.trim()}`)) ?? ""
|
|
304
338
|
}
|
|
305
339
|
if (typeof document === "undefined") return color
|
|
306
340
|
let value = color.trim()
|
|
307
341
|
const cssVar = CSS_VAR_RE.exec(value)
|
|
308
|
-
const styles = getComputedStyle(document.documentElement)
|
|
342
|
+
const styles = getComputedStyle((tokens && tokenScopes.get(tokens)) ?? document.documentElement)
|
|
309
343
|
if (cssVar) {
|
|
310
344
|
value = styles.getPropertyValue(cssVar[1]!).trim() || (cssVar[2] ?? "").trim()
|
|
311
345
|
} else if (value.includes("var(")) {
|
|
@@ -351,7 +385,7 @@ function readChartSurface(el: Element | null): string | null {
|
|
|
351
385
|
if (color) return color
|
|
352
386
|
}
|
|
353
387
|
}
|
|
354
|
-
return toCanvasColor(getComputedStyle(document.documentElement).getPropertyValue("--background"))
|
|
388
|
+
return toCanvasColor(getComputedStyle(el ?? document.documentElement).getPropertyValue("--background"))
|
|
355
389
|
}
|
|
356
390
|
|
|
357
391
|
/** Widths are bucketed so a resize only rebuilds the option when the label budget can change. */
|
|
@@ -365,9 +399,10 @@ const WIDTH_BUCKET = 40
|
|
|
365
399
|
*/
|
|
366
400
|
function useChartSurface<E extends Element>(
|
|
367
401
|
forwarded: ForwardedRef<E>,
|
|
368
|
-
tokens
|
|
369
|
-
): { ref: (el: E | null) => void; surface: string | undefined; width: number | undefined } {
|
|
402
|
+
tokens?: ChartTokens | null,
|
|
403
|
+
): { ref: (el: E | null) => void; surface: string | undefined; width: number | undefined; tokens: ChartTokens | null } {
|
|
370
404
|
const [node, setNode] = useState<E | null>(null)
|
|
405
|
+
const scopedTokens = useChartTokens(node)
|
|
371
406
|
const [surface, setSurface] = useState<string | undefined>(undefined)
|
|
372
407
|
const [width, setWidth] = useState<number | undefined>(undefined)
|
|
373
408
|
const ref = useCallback(
|
|
@@ -381,7 +416,7 @@ function useChartSurface<E extends Element>(
|
|
|
381
416
|
useEffect(() => {
|
|
382
417
|
if (!node) return
|
|
383
418
|
setSurface(readChartSurface(node) ?? undefined)
|
|
384
|
-
}, [node, tokens])
|
|
419
|
+
}, [node, tokens, scopedTokens])
|
|
385
420
|
useEffect(() => {
|
|
386
421
|
if (!node || typeof ResizeObserver === "undefined") return
|
|
387
422
|
const update = (w: number) => setWidth(Math.floor(w / WIDTH_BUCKET) * WIDTH_BUCKET)
|
|
@@ -390,7 +425,7 @@ function useChartSurface<E extends Element>(
|
|
|
390
425
|
observer.observe(node)
|
|
391
426
|
return () => observer.disconnect()
|
|
392
427
|
}, [node])
|
|
393
|
-
return { ref, surface, width }
|
|
428
|
+
return { ref, surface, width, tokens: scopedTokens }
|
|
394
429
|
}
|
|
395
430
|
|
|
396
431
|
/* ---------- inlined from @squadbase/squadkit registry/lib/chart-utils.ts (internal to @squadbase/vantage) ---------- */
|
|
@@ -1657,8 +1692,7 @@ function HeatmapImpl<T extends Record<string, unknown>>(
|
|
|
1657
1692
|
}: HeatmapProps<T>,
|
|
1658
1693
|
ref: ForwardedRef<HTMLDivElement>,
|
|
1659
1694
|
) {
|
|
1660
|
-
const tokens =
|
|
1661
|
-
const { ref: frameRef, surface, width: plotWidth } = useChartSurface(ref, tokens)
|
|
1695
|
+
const { ref: frameRef, surface, width: plotWidth, tokens } = useChartSurface(ref)
|
|
1662
1696
|
const formatter = useMemo(() => resolveValueFormatter(valueFormatter, format ?? "number"), [valueFormatter, format])
|
|
1663
1697
|
const model = useMemo(
|
|
1664
1698
|
() => buildHeatmapModel({ data, x, y, value, xLabels, yLabels, flag, scale, minValue, maxValue }),
|