basalt-ui 2.28.0 → 2.29.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/CHANGELOG.md +461 -401
- package/MIGRATING.md +202 -12
- package/agent/skills/basalt-app/SKILL.md +3 -3
- package/agent/skills/basalt-charts/SKILL.md +1 -1
- package/agent/skills/basalt-design/SKILL.md +11 -5
- package/agent/skills/basalt-design/references/catalogue.md +3 -1
- package/agent/skills/basalt-design/references/recipes.md +1 -1
- package/agent/skills/basalt-design/references/states.md +1 -1
- package/configs/oxlint-plugin.js +2 -1
- package/configs/oxlint.json +1 -0
- package/dist/charts/ChartCard.d.ts +9 -5
- package/dist/charts/ChartCard.d.ts.map +1 -1
- package/dist/charts/ChartCard.js +68 -12
- package/dist/charts/Sparkline.d.ts +5 -0
- package/dist/charts/Sparkline.d.ts.map +1 -1
- package/dist/charts/Sparkline.js +53 -5
- package/dist/charts/chart-box.module.css +9 -2
- package/dist/charts/chart-card.module.css +16 -13
- package/dist/charts/chart-card.module.css.d.ts +2 -0
- package/dist/charts/compile.d.ts +1 -1
- package/dist/charts/compile.d.ts.map +1 -1
- package/dist/charts/compile.js +18 -9
- package/dist/charts/ref-label.d.ts +6 -0
- package/dist/charts/ref-label.d.ts.map +1 -1
- package/dist/charts/ref-label.js +19 -5
- package/dist/charts/sparkline.module.css +44 -0
- package/dist/charts/sparkline.module.css.d.ts +3 -0
- package/dist/charts/state.d.ts +1 -1
- package/dist/charts/state.d.ts.map +1 -1
- package/dist/charts/state.js +3 -3
- package/dist/cli/doctor-upgrade.d.ts +11 -0
- package/dist/cli/doctor-upgrade.d.ts.map +1 -1
- package/dist/cli/doctor-upgrade.js +54 -0
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli/doctor.js +32 -0
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +8 -3
- package/dist/cli/index.d.ts +13 -13
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +36 -2
- package/dist/cli/init.d.ts +6 -0
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +118 -27
- package/dist/cli/router-wiring.d.ts +3 -0
- package/dist/cli/router-wiring.d.ts.map +1 -1
- package/dist/cli/router-wiring.js +2 -0
- package/dist/cli/shot/capture.d.ts +28 -1
- package/dist/cli/shot/capture.d.ts.map +1 -1
- package/dist/cli/shot/capture.js +77 -7
- package/dist/cli/shot/detect.d.ts +4 -1
- package/dist/cli/shot/detect.d.ts.map +1 -1
- package/dist/cli/shot/detect.js +38 -16
- package/dist/cli/shot/index.d.ts.map +1 -1
- package/dist/cli/shot/index.js +9 -2
- package/dist/cli/shot/measure.d.ts.map +1 -1
- package/dist/cli/shot/measure.js +11 -2
- package/dist/cli/shot/types.d.ts +4 -1
- package/dist/cli/shot/types.d.ts.map +1 -1
- package/dist/cli/sync.d.ts.map +1 -1
- package/dist/cli/sync.js +10 -2
- package/dist/common/could-not-load.d.ts +13 -0
- package/dist/common/could-not-load.d.ts.map +1 -0
- package/dist/common/could-not-load.js +14 -0
- package/dist/common/index.d.ts +1 -0
- package/dist/common/index.d.ts.map +1 -1
- package/dist/common/index.js +3 -0
- package/dist/common/props.d.ts +20 -0
- package/dist/common/props.d.ts.map +1 -1
- package/dist/common/props.js +13 -1
- package/dist/common/retry-button.module.css +7 -3
- package/dist/dashboard/bar-list.d.ts +4 -4
- package/dist/dashboard/bar-list.d.ts.map +1 -1
- package/dist/dashboard/bar-list.js +10 -7
- package/dist/dashboard/bar-list.module.css +21 -3
- package/dist/dashboard/board.d.ts +2 -2
- package/dist/dashboard/board.d.ts.map +1 -1
- package/dist/dashboard/board.js +31 -12
- package/dist/dashboard/board.module.css +19 -0
- package/dist/dashboard/board.module.css.d.ts +2 -0
- package/dist/dashboard/empty-state.d.ts +3 -3
- package/dist/dashboard/empty-state.d.ts.map +1 -1
- package/dist/dashboard/empty-state.js +4 -2
- package/dist/dashboard/event-list-model.d.ts +3 -0
- package/dist/dashboard/event-list-model.d.ts.map +1 -1
- package/dist/dashboard/event-list-model.js +5 -1
- package/dist/dashboard/event-list-rows.d.ts.map +1 -1
- package/dist/dashboard/event-list-rows.js +2 -6
- package/dist/dashboard/event-list-scroll.d.ts +32 -4
- package/dist/dashboard/event-list-scroll.d.ts.map +1 -1
- package/dist/dashboard/event-list-scroll.js +117 -4
- package/dist/dashboard/event-list-skeleton.d.ts.map +1 -1
- package/dist/dashboard/event-list-skeleton.js +2 -4
- package/dist/dashboard/event-list.d.ts +4 -4
- package/dist/dashboard/event-list.d.ts.map +1 -1
- package/dist/dashboard/event-list.js +53 -23
- package/dist/dashboard/event-list.module.css +90 -37
- package/dist/dashboard/event-list.module.css.d.ts +1 -0
- package/dist/dashboard/meter-model.d.ts +6 -3
- package/dist/dashboard/meter-model.d.ts.map +1 -1
- package/dist/dashboard/meter-model.js +9 -4
- package/dist/dashboard/meter-parts.d.ts +3 -0
- package/dist/dashboard/meter-parts.d.ts.map +1 -1
- package/dist/dashboard/meter-parts.js +32 -4
- package/dist/dashboard/meter.d.ts +3 -3
- package/dist/dashboard/meter.d.ts.map +1 -1
- package/dist/dashboard/meter.js +10 -2
- package/dist/dashboard/meter.module.css +18 -11
- package/dist/dashboard/meter.module.css.d.ts +0 -1
- package/dist/dashboard/page-summary.d.ts +3 -3
- package/dist/dashboard/page-summary.d.ts.map +1 -1
- package/dist/dashboard/page-summary.js +7 -2
- package/dist/dashboard/page-summary.module.css +5 -2
- package/dist/dashboard/query-state.d.ts +9 -8
- package/dist/dashboard/query-state.d.ts.map +1 -1
- package/dist/dashboard/query-state.js +28 -10
- package/dist/dashboard/section.d.ts +11 -3
- package/dist/dashboard/section.d.ts.map +1 -1
- package/dist/dashboard/section.js +34 -7
- package/dist/dashboard/settings-section.d.ts +4 -4
- package/dist/dashboard/settings-section.d.ts.map +1 -1
- package/dist/dashboard/settings-section.js +11 -7
- package/dist/dashboard/settings-section.module.css +6 -0
- package/dist/dashboard/settings-section.module.css.d.ts +1 -0
- package/dist/dashboard/stat-card.d.ts +3 -3
- package/dist/dashboard/stat-card.d.ts.map +1 -1
- package/dist/dashboard/stat-card.js +24 -8
- package/dist/dashboard/stat-card.module.css +11 -0
- package/dist/dashboard/stat-group.d.ts +2 -2
- package/dist/dashboard/stat-group.d.ts.map +1 -1
- package/dist/dashboard/stat-group.js +10 -3
- package/dist/dashboard/stat-strip.d.ts +5 -4
- package/dist/dashboard/stat-strip.d.ts.map +1 -1
- package/dist/dashboard/stat-strip.js +41 -31
- package/dist/dashboard/stat-strip.module.css +4 -5
- package/dist/dashboard/visual-slot.d.ts +4 -0
- package/dist/dashboard/visual-slot.d.ts.map +1 -1
- package/dist/dashboard/visual-slot.js +2 -0
- package/dist/dashboard/widget-header.d.ts +6 -6
- package/dist/dashboard/widget-header.d.ts.map +1 -1
- package/dist/dashboard/widget-header.js +4 -2
- package/dist/dashboard/widget-header.module.css +6 -25
- package/dist/format/shared.d.ts.map +1 -1
- package/dist/format/shared.js +24 -1
- package/dist/guard/index.d.ts +1 -1
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +2 -1
- package/dist/styles.css +23 -0
- package/dist/table/cell-kinds.d.ts +10 -7
- package/dist/table/cell-kinds.d.ts.map +1 -1
- package/dist/table/cell-kinds.js +18 -7
- package/dist/table/data-table-fold.d.ts +13 -5
- package/dist/table/data-table-fold.d.ts.map +1 -1
- package/dist/table/data-table-fold.js +48 -16
- package/dist/table/data-table.d.ts +2 -2
- package/dist/table/data-table.d.ts.map +1 -1
- package/dist/table/data-table.js +16 -9
- package/dist/table/data-table.module.css +74 -2
- package/dist/table/data-table.module.css.d.ts +4 -0
- package/dist/theme/controls.module.css +23 -2
- package/llms.txt +263 -2
- package/package.json +1 -1
- package/src/charts/ChartCard.tsx +98 -16
- package/src/charts/Sparkline.tsx +84 -5
- package/src/charts/chart-box.module.css +9 -2
- package/src/charts/chart-card.module.css +16 -13
- package/src/charts/chart-card.module.css.d.ts +2 -0
- package/src/charts/compile.ts +37 -15
- package/src/charts/ref-label.ts +36 -9
- package/src/charts/sparkline.module.css +44 -0
- package/src/charts/sparkline.module.css.d.ts +3 -0
- package/src/charts/state.tsx +4 -3
- package/src/cli/doctor-upgrade.ts +75 -0
- package/src/cli/doctor.ts +36 -0
- package/src/cli/help.ts +16 -6
- package/src/cli/index.ts +73 -67
- package/src/cli/init.ts +157 -36
- package/src/cli/router-wiring.ts +2 -2
- package/src/cli/shot/capture.ts +109 -10
- package/src/cli/shot/detect.ts +46 -22
- package/src/cli/shot/index.ts +8 -2
- package/src/cli/shot/measure.ts +11 -2
- package/src/cli/shot/types.ts +4 -1
- package/src/cli/sync.ts +12 -2
- package/src/common/could-not-load.ts +22 -0
- package/src/common/index.ts +1 -0
- package/src/common/props.ts +30 -0
- package/src/common/retry-button.module.css +7 -3
- package/src/dashboard/bar-list.module.css +21 -3
- package/src/dashboard/bar-list.tsx +46 -41
- package/src/dashboard/board.module.css +19 -0
- package/src/dashboard/board.module.css.d.ts +2 -0
- package/src/dashboard/board.tsx +69 -48
- package/src/dashboard/empty-state.tsx +5 -2
- package/src/dashboard/event-list-model.ts +13 -1
- package/src/dashboard/event-list-rows.tsx +3 -6
- package/src/dashboard/event-list-scroll.ts +154 -8
- package/src/dashboard/event-list-skeleton.tsx +5 -1
- package/src/dashboard/event-list.module.css +90 -37
- package/src/dashboard/event-list.module.css.d.ts +1 -0
- package/src/dashboard/event-list.tsx +92 -65
- package/src/dashboard/meter-model.ts +16 -7
- package/src/dashboard/meter-parts.tsx +45 -13
- package/src/dashboard/meter.module.css +18 -11
- package/src/dashboard/meter.module.css.d.ts +0 -1
- package/src/dashboard/meter.tsx +36 -18
- package/src/dashboard/page-summary.module.css +5 -2
- package/src/dashboard/page-summary.tsx +13 -6
- package/src/dashboard/query-state.tsx +54 -29
- package/src/dashboard/section.tsx +83 -41
- package/src/dashboard/settings-section.module.css +6 -0
- package/src/dashboard/settings-section.module.css.d.ts +1 -0
- package/src/dashboard/settings-section.tsx +11 -6
- package/src/dashboard/stat-card.module.css +11 -0
- package/src/dashboard/stat-card.tsx +31 -8
- package/src/dashboard/stat-group.tsx +22 -14
- package/src/dashboard/stat-strip.module.css +4 -5
- package/src/dashboard/stat-strip.tsx +29 -20
- package/src/dashboard/visual-slot.ts +5 -0
- package/src/dashboard/widget-header.module.css +6 -25
- package/src/dashboard/widget-header.tsx +8 -5
- package/src/format/shared.ts +30 -1
- package/src/guard/index.ts +5 -1
- package/src/styles.css +23 -0
- package/src/table/cell-kinds.tsx +42 -13
- package/src/table/data-table-fold.tsx +65 -12
- package/src/table/data-table.module.css +74 -2
- package/src/table/data-table.module.css.d.ts +4 -0
- package/src/table/data-table.tsx +34 -13
- package/src/theme/controls.module.css +23 -2
package/llms.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# basalt-ui v2.
|
|
1
|
+
# basalt-ui v2.29.0
|
|
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.
|
|
16
|
+
Version: 2.29.0
|
|
17
17
|
|
|
18
18
|
## basalt-ui
|
|
19
19
|
Import: import { ... } from 'basalt-ui'
|
|
@@ -187,6 +187,7 @@ Signature: Section(props: SectionProps): JSX.Element
|
|
|
187
187
|
actions?: SectionActions
|
|
188
188
|
query?: QueryStateLike<unknown>
|
|
189
189
|
empty?: QueryEmptyCopy
|
|
190
|
+
loadingHeight?: number
|
|
190
191
|
tabs?: ReactNode
|
|
191
192
|
collapsible?: boolean
|
|
192
193
|
persistKey?: string
|
|
@@ -324,6 +325,70 @@ Signature: unwrap(response: R): UnwrapResult<R>
|
|
|
324
325
|
Signature: useBasaltNav(): { currentPath: string; isActive: (href: string, opts?: { exact?: bool…
|
|
325
326
|
Signature: useCoarsePointer(): boolean
|
|
326
327
|
Signature: useSizeClass(): "compact" | "medium" | "expanded"
|
|
328
|
+
Type: AnyNavGroup = NavGroupMeta & { items: ReadonlyArray<AnyNavItem>; }
|
|
329
|
+
Type: BarAction = BarActionItem | BarActionMenu | BarActionCustom
|
|
330
|
+
Type: BarListItem = { label: string, value: number, secondary?: ReactNode, key?: string, max?: number, tick?: number, tickLabel?: string }
|
|
331
|
+
Type: BasaltAccountProps = { state: BasaltAccountState, actions?: BasaltAccountActions, showEmail?: boolean }
|
|
332
|
+
Type: BuildPaletteOpts = {
|
|
333
|
+
groups?: readonly SeriesGroup[]
|
|
334
|
+
derived?: string[]
|
|
335
|
+
scheme?: ColorSchemeSelector
|
|
336
|
+
defaultScheme?: 'dark' | 'light' | 'none'
|
|
337
|
+
mediaFallback?: boolean
|
|
338
|
+
only?: 'core' | 'all'
|
|
339
|
+
}
|
|
340
|
+
Type: CreateBasaltThemeOptions = {
|
|
341
|
+
derive?: Partial<DeriveConfig>
|
|
342
|
+
fonts?: BasaltFontsConfig
|
|
343
|
+
radius?: BasaltRadiusLevel
|
|
344
|
+
density?: BasaltDensityLevel
|
|
345
|
+
}
|
|
346
|
+
Type: GlobalAction = { key: string, node: ReactNode, mobile?: 'bar' | 'more' | 'hidden' }
|
|
347
|
+
Type: MeterSegment = { value: number, label: string, color?: string, tone?: 'muted', forecast?: boolean }
|
|
348
|
+
Type: MeterTick = { at: number, label?: string, caption?: string }
|
|
349
|
+
Type: MeterZone = { from: number, to: number, label: string, tone?: 'muted', short?: string, color?: string }
|
|
350
|
+
Type: NavConfig<G extends ReadonlyArray<AnyNavGroup>, T extends ReadonlyArray<NavTabId<G>>> = {
|
|
351
|
+
groups: G
|
|
352
|
+
mobile?: { tabs?: T; maxTabs?: number; menuMax?: number; moreLabel?: string; }
|
|
353
|
+
}
|
|
354
|
+
Type: NavSectionMobile = { tab?: true, label?: string, icon?: ReactNode }
|
|
355
|
+
Type: PageBarActions = [ PrimaryBarAction ] | [ PrimaryBarAction, MoreBarAction ] | [ PrimaryBarAction, MoreBarAction, MoreBarAction ] | [ PrimaryBarAction, MoreBarAction, MoreBarAction, MoreBarAction ] | [ PrimaryBarAction, MoreBarAction, MoreBarAction, MoreBarAction, MoreBarAction ]
|
|
356
|
+
Type: QueryEmptyCopy = { title: string, description?: string, icon?: ReactNode, action?: ReactNode }
|
|
357
|
+
Type: QueryStateLike<TData> = {
|
|
358
|
+
data: TData | undefined
|
|
359
|
+
isError: boolean
|
|
360
|
+
error: unknown
|
|
361
|
+
fetchStatus: 'fetching' | 'paused' | 'idle'
|
|
362
|
+
refetch: () => unknown
|
|
363
|
+
}
|
|
364
|
+
Type: SectionActions = [ ] | [ BarAction ] | [ BarAction, BarAction ] | [ BarAction, BarAction, BarAction ]
|
|
365
|
+
Type: SettingsMenuItem = {
|
|
366
|
+
key: string
|
|
367
|
+
label: string
|
|
368
|
+
icon?: ReactNode
|
|
369
|
+
onClick?: (e: MouseEvent) => void
|
|
370
|
+
Anchor?: NavAnchor
|
|
371
|
+
active?: boolean
|
|
372
|
+
current?: 'selection' | 'page'
|
|
373
|
+
}
|
|
374
|
+
Type: SidebarBlock = SidebarListBlock | SidebarProgressBlock | SidebarCustomBlock
|
|
375
|
+
Type: StatCardBreakdownRow = { readonly label: string, readonly value: string, readonly tone?: Tone }
|
|
376
|
+
Type: StatStripCell = {
|
|
377
|
+
key: string
|
|
378
|
+
caption: string
|
|
379
|
+
qualifier?: string
|
|
380
|
+
action?: ReactNode
|
|
381
|
+
info?: string
|
|
382
|
+
value?: string | null
|
|
383
|
+
unit?: string
|
|
384
|
+
delta?: ReactNode
|
|
385
|
+
visual?: ReactNode
|
|
386
|
+
footer?: ReactNode
|
|
387
|
+
rows?: readonly StatStripRow[]
|
|
388
|
+
tone?: Tone
|
|
389
|
+
… +4 more
|
|
390
|
+
}
|
|
391
|
+
Type: StatStripFooterEntry = { key: string, content: ReactNode, under?: string, shotAbsent?: readonly StatStripShotState[] }
|
|
327
392
|
OptionalPeers: remark-gfm@^4.0.1, rehype-sanitize@^6.0.0, remend@1.4.0, shiki@^4.5.0, beautiful-mermaid@^1.1.0, @tanstack/react-router-devtools@^1.166.13
|
|
328
393
|
|
|
329
394
|
## basalt-ui/charts
|
|
@@ -535,6 +600,7 @@ Signature: Sparkline(props: SparklineProps): ReactElement<unknown, string | JSXE
|
|
|
535
600
|
band?: { from: number; to: number; }
|
|
536
601
|
format?: ((value: number) => string)
|
|
537
602
|
labels?: readonly string[]
|
|
603
|
+
window?: string | false
|
|
538
604
|
Signature: StackedArea(props: StackedAreaProps<T, X>): ReactElement<unknown, string | JSXElementConstructor<any>>
|
|
539
605
|
className?: string
|
|
540
606
|
style?: CSSProperties
|
|
@@ -559,6 +625,97 @@ Signature: StackedArea(props: StackedAreaProps<T, X>): ReactElement<unknown, str
|
|
|
559
625
|
Signature: chartCursor(group: string): ChartCursorController<ChartValue, ChartValue>
|
|
560
626
|
Signature: chartCurve(name: CurveName): ChartCurve
|
|
561
627
|
Signature: foldBands(data: readonly T[], cap: number, merge: (group: T[]) => T): T[]
|
|
628
|
+
Type: AxisConfig<T> = {
|
|
629
|
+
domain?: readonly [ number, number ] | 'auto' | ((data: readonly T[], visible: readonly ChartSeries<T>[]) => readonly [ number, number ]) | undefined
|
|
630
|
+
autoMaxFloor?: number | undefined
|
|
631
|
+
autoMinCeil?: number | undefined
|
|
632
|
+
autoPad?: number | undefined
|
|
633
|
+
ticks?: number | readonly number[] | undefined
|
|
634
|
+
format?: ((v: number) => string) | undefined
|
|
635
|
+
grid?: boolean | undefined
|
|
636
|
+
nice?: boolean | undefined
|
|
637
|
+
scale?: 'linear' | 'log' | undefined
|
|
638
|
+
}
|
|
639
|
+
Type: BandFold<T> = { minBandPx?: number | undefined, merge: (group: T[]) => T }
|
|
640
|
+
Type: BarsBar<T> = Pick<ChartSeries<T>, 'key' | 'label' | 'color' | 'getValue' | 'formatValue' | 'tooltip' | 'legend' | 'role' | 'note'> & { fillOpacity?: number | undefined; }
|
|
641
|
+
Type: BarsLine<T> = Pick<ChartSeries<T>, 'key' | 'label' | 'color' | 'getValue' | 'formatValue' | 'tooltip' | 'legend' | 'role' | 'note' | 'axis' | 'dash' | 'curve' | 'strokeWidth' | 'strokeOpacity'>
|
|
642
|
+
Type: ChartFact = {
|
|
643
|
+
value: ReactNode
|
|
644
|
+
unit?: string | undefined
|
|
645
|
+
comparison?: ReactNode
|
|
646
|
+
period?: string | readonly string[] | undefined
|
|
647
|
+
tone?: ChartFactTone | undefined
|
|
648
|
+
}
|
|
649
|
+
Type: ChartLegendConfig = { placement?: 'top' | 'bottom' | 'header' | undefined, groups?: boolean | undefined, toggle?: boolean | undefined }
|
|
650
|
+
Type: ChartSeries<T> = {
|
|
651
|
+
key: string
|
|
652
|
+
label: string
|
|
653
|
+
color: string
|
|
654
|
+
getValue: (d: T) => number | null
|
|
655
|
+
mark?: 'line' | 'bar' | 'area' | undefined
|
|
656
|
+
dash?: 'solid' | 'dashed' | undefined
|
|
657
|
+
curve?: CurveName | undefined
|
|
658
|
+
strokeWidth?: number | undefined
|
|
659
|
+
gaps?: 'break' | 'connect' | undefined
|
|
660
|
+
strokeOpacity?: number | undefined
|
|
661
|
+
fillOpacity?: number | undefined
|
|
662
|
+
area?: boolean | 'zones' | (string & {}) | undefined
|
|
663
|
+
… +9 more
|
|
664
|
+
}
|
|
665
|
+
Type: ChartState = { pending?: boolean | undefined, error?: unknown, empty?: boolean | string | undefined }
|
|
666
|
+
Type: ChartTooltipConfig<T, X extends ChartX = ChartX> = {
|
|
667
|
+
formatHeader?: ((x: X, d: T) => string) | undefined
|
|
668
|
+
rows?: ((d: T, ctx: { visible: readonly ChartSeries<T>[]; hidden: readonly ChartSeries<T>[]; }) => readonly ChartTooltipRow[]) | undefined
|
|
669
|
+
onFollow?: boolean | undefined
|
|
670
|
+
}
|
|
671
|
+
Type: DonutDatum<K extends string = string> = { key: K, value: number }
|
|
672
|
+
Type: DualPanelBar<T> = {
|
|
673
|
+
label: string
|
|
674
|
+
getValue: (d: T) => number | null
|
|
675
|
+
positive: string
|
|
676
|
+
negative: string
|
|
677
|
+
format: (v: number) => string
|
|
678
|
+
tooltipFormat?: ((v: number) => string) | undefined
|
|
679
|
+
formatValue?: ((v: number, d: T) => string) | undefined
|
|
680
|
+
domain?: readonly [ number, number ] | 'auto' | undefined
|
|
681
|
+
maxAbsFloor?: number | undefined
|
|
682
|
+
}
|
|
683
|
+
Type: DualPanelLine<T> = Pick<ChartSeries<T>, 'key' | 'label' | 'color' | 'getValue' | 'formatValue' | 'tooltip' | 'legend' | 'role' | 'note' | 'dash' | 'curve' | 'strokeWidth' | 'strokeOpacity' | 'getMarker'>
|
|
684
|
+
Type: HeatmapState<K extends string = string> = Omit<NamedChartState, 'key' | 'tooltip' | 'color'> & { key: K; color?: string | undefined; }
|
|
685
|
+
Type: MirroredBarPane = {
|
|
686
|
+
key: string
|
|
687
|
+
max?: number | 'auto' | undefined
|
|
688
|
+
autoMaxFloor?: number | undefined
|
|
689
|
+
ticks?: number | undefined
|
|
690
|
+
format: (v: number) => string
|
|
691
|
+
}
|
|
692
|
+
Type: MirroredBarsSeries<T, K extends string = string> = Pick<ChartSeries<T>, 'label' | 'color' | 'getValue' | 'formatValue' | 'tooltip' | 'legend' | 'role' | 'note'> & { key: K; fillOpacity?: number | undefined; }
|
|
693
|
+
Type: RefLine = {
|
|
694
|
+
value: number
|
|
695
|
+
color: string
|
|
696
|
+
dashed?: boolean | undefined
|
|
697
|
+
axis?: 'left' | 'right' | undefined
|
|
698
|
+
label?: string | undefined
|
|
699
|
+
labelPosition?: RefLabelPosition | undefined
|
|
700
|
+
legend?: { label: string; mark?: 'line' | 'bar' | undefined; } | undefined
|
|
701
|
+
}
|
|
702
|
+
Type: ResponsiveChartHeight = { base: number, regular?: number | undefined, wide?: number | undefined }
|
|
703
|
+
Type: StackedAreaBand<T> = Pick<ChartSeries<T>, 'key' | 'label' | 'color' | 'getValue' | 'formatValue' | 'tooltip' | 'legend' | 'role' | 'note'> & { fillOpacity?: number | undefined; }
|
|
704
|
+
Type: XZoneSpec<X extends ChartX = ChartX> = {
|
|
705
|
+
from?: X | undefined
|
|
706
|
+
to?: X | undefined
|
|
707
|
+
fill: string
|
|
708
|
+
align?: 'center' | 'edge' | undefined
|
|
709
|
+
edge?: ZoneEdge<'start' | 'end'> | undefined
|
|
710
|
+
}
|
|
711
|
+
Type: ZoneSpec = {
|
|
712
|
+
from: number
|
|
713
|
+
to: number
|
|
714
|
+
fill: string
|
|
715
|
+
axisSide?: 'left' | 'right' | undefined
|
|
716
|
+
legend?: { label: string; mark?: 'line' | 'bar' | undefined; color?: string | undefined; } | undefined
|
|
717
|
+
edge?: ZoneEdge<'top' | 'bottom'> | undefined
|
|
718
|
+
}
|
|
562
719
|
Install: bun add @tanstack/charts@1.1.0 d3-scale@4.0.2
|
|
563
720
|
|
|
564
721
|
## basalt-ui/tokens
|
|
@@ -589,6 +746,8 @@ Signature: defineSeries(map: T): T
|
|
|
589
746
|
Signature: groupTokens(name: string, map: T): { readonly [K in keyof T]: GroupRef; }
|
|
590
747
|
Signature: p(fam: readonly string[], light: number, dark: number): ColorPair
|
|
591
748
|
Signature: seriesTokens(map: T, prefix: string): { [K in keyof T]: string; }
|
|
749
|
+
Type: ColorSchemeSelector = { attribute?: string, darkValue?: string, lightValue?: string }
|
|
750
|
+
Type: SeriesGroup = { readonly [key: string]: GroupRef }
|
|
592
751
|
|
|
593
752
|
## basalt-ui/vite
|
|
594
753
|
Import: import { ... } from 'basalt-ui/vite'
|
|
@@ -619,6 +778,13 @@ Signature: basaltViteConfig(opts: BasaltViteOptions): UserConfig
|
|
|
619
778
|
basaltSrc?: string
|
|
620
779
|
version?: string
|
|
621
780
|
enforcementNotice?: boolean
|
|
781
|
+
Type: BasaltAppIcon = {
|
|
782
|
+
src: string
|
|
783
|
+
sizes?: string
|
|
784
|
+
type?: string
|
|
785
|
+
purpose?: string
|
|
786
|
+
rel?: 'icon' | 'shortcut icon' | 'apple-touch-icon' | 'mask-icon'
|
|
787
|
+
}
|
|
622
788
|
Install: bun add 'vite@^7 || ^8'
|
|
623
789
|
OptionalPeers: vite-plugin-pwa@^1.3.0
|
|
624
790
|
|
|
@@ -644,6 +810,18 @@ Signature: percent(value: Numeric, options: PercentOptions): string
|
|
|
644
810
|
Signature: relativeTime(value: DateInput, options: RelativeTimeOptions): string
|
|
645
811
|
Signature: time(value: DateInput, options: DateOptions): string
|
|
646
812
|
Signature: weekday(value: string | number | Date, options: WeekdayOptions): string
|
|
813
|
+
Type: BytesOptions = LocaleOption & { digits?: number; }
|
|
814
|
+
Type: CompactOptions = LocaleOption & { digits?: number; }
|
|
815
|
+
Type: DateOptions = LocaleOption & { format?: 'short' | 'medium' | 'long'; timeZone?: string; }
|
|
816
|
+
Type: DeltaOptions = LocaleOption & { digits?: number; }
|
|
817
|
+
Type: DurationOptions = LocaleOption & { style?: 'clock' | 'compact' | 'long'; largest?: 'day' | 'hour' | 'minute'; }
|
|
818
|
+
Type: KcalOptions = LocaleOption & { digits?: number; }
|
|
819
|
+
Type: KmOptions = LocaleOption & { digits?: number; }
|
|
820
|
+
Type: LocaleOption = { locale?: string | undefined }
|
|
821
|
+
Type: MoneyOptions = LocaleOption & { currency: string; compact?: boolean; digits?: number; }
|
|
822
|
+
Type: PercentOptions = LocaleOption & { digits?: number; input?: 'ratio' | 'percent'; }
|
|
823
|
+
Type: RelativeTimeOptions = LocaleOption & { style?: 'long' | 'short' | 'narrow'; numeric?: 'auto' | 'always'; now?: number; }
|
|
824
|
+
Type: WeekdayOptions = LocaleOption & { format?: 'short' | 'long' | 'narrow'; }
|
|
647
825
|
|
|
648
826
|
## basalt-ui/forms
|
|
649
827
|
Import: import { ... } from 'basalt-ui/forms'
|
|
@@ -655,6 +833,7 @@ Signature: inputProps(form: UseFormReturnType<Values>, path: Path): InputProps
|
|
|
655
833
|
Signature: useBasaltForm(opts: UseBasaltFormOptions<Values>): UseFormReturnType<Values>
|
|
656
834
|
mode?: "controlled" | "uncontrolled"
|
|
657
835
|
schema?: StandardSchemaV1<unknown, Values>
|
|
836
|
+
Type: StandardSchemaV1<Input = unknown, Output = Input> = { readonly '~standard': StandardSchemaV1.Props<Input, Output> }
|
|
658
837
|
Install: bun add @mantine/form@^9.7.0
|
|
659
838
|
|
|
660
839
|
## basalt-ui/commands
|
|
@@ -728,6 +907,25 @@ Signature: BasaltDataTable(props: BasaltDataTableProps<T>): JSX.Element
|
|
|
728
907
|
initialPagination?: PaginationState
|
|
729
908
|
… +14 more
|
|
730
909
|
Signature: createColumnHelper(): ColumnHelper<{ rowSortingFeature: TableFeature; columnFilteringFeatur…
|
|
910
|
+
Type: BarAction = BarActionItem | BarActionMenu | BarActionCustom
|
|
911
|
+
Type: DataTableColumnPinning<T = unknown> = { start?: DataTableColumnId<T>[], end?: DataTableColumnId<T>[] }
|
|
912
|
+
Type: DataTableFacet<T = unknown> = { columnId: DataTableColumnId<T>, label: string, options: DataTableFacetOption[], multiple?: boolean }
|
|
913
|
+
Type: DataTableRowAction<T = unknown> = {
|
|
914
|
+
key: string
|
|
915
|
+
label: string
|
|
916
|
+
icon?: ReactNode
|
|
917
|
+
onClick: (row: T) => void
|
|
918
|
+
danger?: boolean
|
|
919
|
+
disabled?: (row: T) => boolean
|
|
920
|
+
loading?: (row: T) => boolean
|
|
921
|
+
}
|
|
922
|
+
Type: QueryStateLike<TData> = {
|
|
923
|
+
data: TData | undefined
|
|
924
|
+
isError: boolean
|
|
925
|
+
error: unknown
|
|
926
|
+
fetchStatus: 'fetching' | 'paused' | 'idle'
|
|
927
|
+
refetch: () => unknown
|
|
928
|
+
}
|
|
731
929
|
Install: bun add @tanstack/react-table@9.2.8
|
|
732
930
|
|
|
733
931
|
## basalt-ui/agent
|
|
@@ -812,6 +1010,57 @@ Signature: useAgentThreadRuns(props: UseAgentThreadRunsArgs<TPart>): UseAgentThr
|
|
|
812
1010
|
onError?: ((info: { readonly threadId: string; readonly error: unknow…
|
|
813
1011
|
throttle?: number
|
|
814
1012
|
telemetry?: Telemetry
|
|
1013
|
+
Type: AgentThread<TPart = AgentPart> = {
|
|
1014
|
+
readonly id: string
|
|
1015
|
+
readonly messages: ChatMessage<TPart>[]
|
|
1016
|
+
readonly outcome: AgentOutcome | null
|
|
1017
|
+
readonly status: ThreadStatus
|
|
1018
|
+
readonly read: boolean
|
|
1019
|
+
readonly createdAt: number
|
|
1020
|
+
readonly updatedAt: number
|
|
1021
|
+
readonly resumeToken?: string | undefined
|
|
1022
|
+
readonly meta?: Record<string, unknown> | undefined
|
|
1023
|
+
}
|
|
1024
|
+
Type: AgentTransport<TPart = AgentPartDraft, TInput = string> = {
|
|
1025
|
+
stream: (input: TInput, signal?: AbortSignal, ctx?: AgentStreamContext) => AsyncGenerator<TPart>
|
|
1026
|
+
resume?: ((resumeToken: string, signal?: AbortSignal) => AsyncGenerator<TPart>) | undefined
|
|
1027
|
+
}
|
|
1028
|
+
Type: ChatMessage<TPart = AgentPart> = {
|
|
1029
|
+
readonly id: string
|
|
1030
|
+
readonly role: 'user' | 'assistant'
|
|
1031
|
+
readonly parts: TPart[]
|
|
1032
|
+
readonly createdAt: number
|
|
1033
|
+
readonly finish?: 'complete' | 'stopped' | 'error' | undefined
|
|
1034
|
+
}
|
|
1035
|
+
Type: ComposerAttachment = { readonly id: string, readonly name: string, readonly mediaType: string, readonly size: number, readonly url: string }
|
|
1036
|
+
Type: MessageAffordances = {
|
|
1037
|
+
readonly timestamp?: 'relative' | 'absolute' | 'none' | undefined
|
|
1038
|
+
readonly copy?: boolean | undefined
|
|
1039
|
+
readonly onRegenerate?: ((messageId: string) => void) | undefined
|
|
1040
|
+
readonly actions?: ((ctx: { readonly message: ChatMessage<TranscriptPart>; }) => ReactNode) | undefined
|
|
1041
|
+
}
|
|
1042
|
+
Type: ThreadsStore<TPart = AgentPart> = {
|
|
1043
|
+
readonly threads: AgentThread<TPart>[]
|
|
1044
|
+
readonly activeId: string | null
|
|
1045
|
+
readonly select: (id: string | null) => void
|
|
1046
|
+
readonly create: (opts?: { readonly meta?: Record<string, unknown> | undefined; }) => string
|
|
1047
|
+
readonly appendMessage: (id: string, message: ChatMessage<TPart>) => void
|
|
1048
|
+
readonly setOutcome: (id: string, outcome: AgentOutcome) => void
|
|
1049
|
+
readonly setStatus: (id: string, status: ThreadStatus) => void
|
|
1050
|
+
readonly setResumeToken: (id: string, token: string | undefined) => void
|
|
1051
|
+
readonly markRead: (id: string) => void
|
|
1052
|
+
readonly remove: (id: string) => void
|
|
1053
|
+
readonly clear: () => void
|
|
1054
|
+
readonly hydrated: boolean
|
|
1055
|
+
… +1 more
|
|
1056
|
+
}
|
|
1057
|
+
Type: ToolCallPart = (Identified & { readonly state: 'input-streaming'; readonly input?: unknown; }) | (Identified & { readonly state: 'input-available'; readonly input: unknown; }) | (Identified & { readonly state: 'approval-requested'; readonly input: unknown; readonly approval: ToolApproval & { readonly approved?: never; readonly reas…
|
|
1058
|
+
Type: TranscriptPart = AgentPart | ForeignPart
|
|
1059
|
+
Type: VirtualizeOptions = {
|
|
1060
|
+
readonly overscan?: number | undefined
|
|
1061
|
+
readonly estimateSize?: number | undefined
|
|
1062
|
+
readonly initialScroll?: 'end' | 'start' | undefined
|
|
1063
|
+
}
|
|
815
1064
|
Install: bun add ai@^7.0.137 @ai-sdk/provider@^4.0.26 motion@^14.1.0
|
|
816
1065
|
OptionalPeers: use-stick-to-bottom@^1.1.6, @tanstack/react-virtual@>=3.14.0 <4
|
|
817
1066
|
|
|
@@ -890,6 +1139,15 @@ Signature: mergeSanitizeSchema(base: SanitizeSchemaInput, extensions: readonly (
|
|
|
890
1139
|
strip?: readonly string[] | null
|
|
891
1140
|
tagNames?: readonly string[] | null
|
|
892
1141
|
Signature: settledOnly(render: FenceRenderer): FenceRenderer
|
|
1142
|
+
Type: ArticleLayoutMeta = { readonly title: string, readonly description?: string, readonly date?: string, readonly readingTime?: number }
|
|
1143
|
+
Type: ArticleNavTarget = { readonly label: string, readonly href: string, readonly description?: string }
|
|
1144
|
+
Type: SanitizeSchemaExtension = {
|
|
1145
|
+
readonly tagNames?: readonly string[]
|
|
1146
|
+
readonly attributes?: Readonly<Record<string, readonly SanitizePropertyDefinition[]>>
|
|
1147
|
+
readonly protocols?: Readonly<Record<string, readonly string[]>>
|
|
1148
|
+
readonly clobberPrefix?: string
|
|
1149
|
+
}
|
|
1150
|
+
Type: TocItem = { readonly id: string, readonly label: string, readonly level: number }
|
|
893
1151
|
Install: bun add react-markdown@^10.1.0
|
|
894
1152
|
OptionalPeers: shiki@^4.5.0, @shikijs/langs@^4.5.0, @shikijs/themes@^4.5.0, beautiful-mermaid@^1.1.0, remark-gfm@^4.0.1, rehype-sanitize@^6.0.0, remend@1.4.0
|
|
895
1153
|
|
|
@@ -1015,6 +1273,7 @@ Signature: ViewTabs(props: ViewTabsProps<T>): ReactNode
|
|
|
1015
1273
|
field: FieldHandle<EnumField<T>>
|
|
1016
1274
|
options?: readonly ViewTabsOption<T>[]
|
|
1017
1275
|
label?: string
|
|
1276
|
+
Type: FilterOption<V extends string | number = string> = { readonly value: V, readonly label: string, readonly disabled?: boolean }
|
|
1018
1277
|
|
|
1019
1278
|
## basalt-ui/controls-dates
|
|
1020
1279
|
Import: import { ... } from 'basalt-ui/controls-dates'
|
|
@@ -1052,6 +1311,8 @@ Signature: externalField(o: { values: readonly T[]; fallback: NoInfer<T>; labels
|
|
|
1052
1311
|
labels?: Partial<Record<T, string>>
|
|
1053
1312
|
store: ExternalStore<T>
|
|
1054
1313
|
Signature: field: { enum, multi, range, number, boolean, string }
|
|
1314
|
+
Type: ExternalStore<T> = { get: () => T, set: (next: T) => void, subscribe: (onChange: () => void) => () => void }
|
|
1315
|
+
Type: StandardSchemaV1<Input = unknown, Output = Input> = { readonly '~standard': StandardSchemaV1.Props<Input, Output> }
|
|
1055
1316
|
|
|
1056
1317
|
## basalt-ui/styles.css
|
|
1057
1318
|
Asset: basalt-ui/styles.css
|
package/package.json
CHANGED
package/src/charts/ChartCard.tsx
CHANGED
|
@@ -11,8 +11,10 @@
|
|
|
11
11
|
import { Children, isValidElement, useRef, useState } from 'react'
|
|
12
12
|
import type { CSSProperties, ReactElement, ReactNode } from 'react'
|
|
13
13
|
import { useIsomorphicLayoutEffect } from '../common/isomorphic-layout-effect'
|
|
14
|
-
import {
|
|
15
|
-
import
|
|
14
|
+
import { HostTitleContext } from '../common/could-not-load'
|
|
15
|
+
import { cx, splitDataAttributes } from '../common/props'
|
|
16
|
+
import type { BasaltProps, DataAttributes, SlotStylesProps } from '../common/props'
|
|
17
|
+
import { DeltaBadge } from '../dashboard/delta-badge'
|
|
16
18
|
import type { DeltaPolarity } from '../dashboard/delta-badge'
|
|
17
19
|
import { WidgetHeader } from '../dashboard/widget-header'
|
|
18
20
|
import { VX } from '../tokens'
|
|
@@ -30,6 +32,9 @@ import type { ChartState, ResponsiveChartHeight } from './types'
|
|
|
30
32
|
const cardStyle: CSSProperties = {
|
|
31
33
|
display: 'flex',
|
|
32
34
|
flexDirection: 'column',
|
|
35
|
+
// Fills its grid cell (or a `h="100%"` anchor wrapper): two cards in one row end together, with
|
|
36
|
+
// no wrapper background under the shorter one. In an auto-height parent it resolves to auto.
|
|
37
|
+
height: '100%',
|
|
33
38
|
minHeight: 0,
|
|
34
39
|
containerType: 'inline-size',
|
|
35
40
|
containerName: 'basalt-card',
|
|
@@ -104,6 +109,28 @@ function periodText(period: string | readonly string[], afterUnit: boolean): str
|
|
|
104
109
|
return afterUnit && !text.startsWith(PERIOD_SEPARATOR.trim()) ? PERIOD_SEPARATOR + text : text
|
|
105
110
|
}
|
|
106
111
|
|
|
112
|
+
/** A comparison that renders something: `cond && <DeltaBadge />` leaves `false`, `null` or `''`. */
|
|
113
|
+
const hasComparison = (node: ReactNode): boolean =>
|
|
114
|
+
node !== undefined && node !== null && node !== false && node !== ''
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* A plain-text comparison with a leading sign ("+0.3", "-4%") reads as a delta: the sign becomes
|
|
118
|
+
* DeltaBadge's direction glyph (▲/▼). Any other node (a `DeltaBadge`, which carries its own) is as is.
|
|
119
|
+
*/
|
|
120
|
+
function Comparison({ node }: { node: ReactNode }): ReactNode {
|
|
121
|
+
if (typeof node !== 'string') return node
|
|
122
|
+
const sign = /^\s*([+\-−])\s*(.+)$/.exec(node)
|
|
123
|
+
if (sign === null) return node
|
|
124
|
+
return (
|
|
125
|
+
<>
|
|
126
|
+
<span aria-hidden="true" className={classes.factGlyph}>
|
|
127
|
+
{sign[1] === '+' ? '▲' : '▼'}
|
|
128
|
+
</span>
|
|
129
|
+
{sign[2]}
|
|
130
|
+
</>
|
|
131
|
+
)
|
|
132
|
+
}
|
|
133
|
+
|
|
107
134
|
/** One headline figure: the value is the hero, then its unit, a comparison node and the period. */
|
|
108
135
|
export type ChartFact = {
|
|
109
136
|
value: ReactNode
|
|
@@ -113,7 +140,9 @@ export type ChartFact = {
|
|
|
113
140
|
/** Plain text the figure covers, e.g. `last 30 d`. A list is joined by ` · ` (`['last entry 3 d
|
|
114
141
|
* ago', '12 entries']`) and, behind a `unit`, led by one. */
|
|
115
142
|
period?: string | readonly string[] | undefined
|
|
116
|
-
/** Ink for the
|
|
143
|
+
/** Ink for the comparison, with its direction glyph (text only, never a fill): an off-target
|
|
144
|
+
* change reads `warn`. A fact with no comparison inks its value instead. A `DeltaBadge` comparison keeps
|
|
145
|
+
* its own polarity ink (it is inline), so `tone` is for plain-text comparisons. */
|
|
117
146
|
tone?: ChartFactTone | undefined
|
|
118
147
|
}
|
|
119
148
|
|
|
@@ -124,6 +153,7 @@ export type ChartFactTone = 'good' | 'warn' | 'bad' | 'muted'
|
|
|
124
153
|
export type ChartCardSlot = 'root' | 'header' | 'body'
|
|
125
154
|
|
|
126
155
|
type ChartCardBaseProps = BasaltProps &
|
|
156
|
+
DataAttributes &
|
|
127
157
|
SlotStylesProps<ChartCardSlot> & {
|
|
128
158
|
title?: string | undefined
|
|
129
159
|
icon?: ReactNode
|
|
@@ -163,7 +193,9 @@ type ChartCardBaseProps = BasaltProps &
|
|
|
163
193
|
ghost?: 'bars' | 'line' | 'band' | number | undefined
|
|
164
194
|
/** Placeholder data is showing: the facts row dims with the plot (a strip cell's `stale`). */
|
|
165
195
|
stale?: boolean | undefined
|
|
166
|
-
/** What an errored `state` names: "Could not load {stateNoun}". Default:
|
|
196
|
+
/** What an errored `state` names: "Could not load {stateNoun}". Default: the card's `title`; with
|
|
197
|
+
* neither, the title is a bare "Could not load". A leading capital is lowercased unless the next
|
|
198
|
+
* character is a capital or a non-letter ("Revenue" → "revenue", "KPI" and "2024 sales" stay). */
|
|
167
199
|
stateNoun?: string | undefined
|
|
168
200
|
/** An errored `state` shows the shared Retry button (the one `ErrorState` renders). */
|
|
169
201
|
onRetry?: (() => void) | undefined
|
|
@@ -192,6 +224,29 @@ export type ChartCardProps = ChartCardBaseProps &
|
|
|
192
224
|
| { facts?: undefined }
|
|
193
225
|
)
|
|
194
226
|
|
|
227
|
+
/** The legacy `value`/`delta` hero as the one fact the headline row draws. */
|
|
228
|
+
function legacyFact(header: {
|
|
229
|
+
value?: string | undefined
|
|
230
|
+
delta?: number | undefined
|
|
231
|
+
deltaPeriod?: string | undefined
|
|
232
|
+
deltaPolarity?: DeltaPolarity | undefined
|
|
233
|
+
}): ChartFact | undefined {
|
|
234
|
+
const { value, delta, deltaPeriod, deltaPolarity } = header
|
|
235
|
+
if (value === undefined && delta === undefined) return undefined
|
|
236
|
+
return {
|
|
237
|
+
value: value ?? null,
|
|
238
|
+
...(delta !== undefined && {
|
|
239
|
+
comparison: (
|
|
240
|
+
<DeltaBadge
|
|
241
|
+
value={delta}
|
|
242
|
+
period={deltaPeriod}
|
|
243
|
+
{...(deltaPolarity !== undefined && { polarity: deltaPolarity })}
|
|
244
|
+
/>
|
|
245
|
+
),
|
|
246
|
+
}),
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
195
250
|
/** Drops explicit `undefined`s: `WidgetHeader` is exact-optional, this props type is not. */
|
|
196
251
|
const definedOnly = <T extends object>(o: T): { [K in keyof T]?: Exclude<T[K], undefined> } =>
|
|
197
252
|
Object.fromEntries(Object.entries(o).filter(([, v]) => v !== undefined)) as {
|
|
@@ -227,11 +282,28 @@ function Facts({
|
|
|
227
282
|
{...(f.tone !== undefined && { 'data-tone': f.tone })}
|
|
228
283
|
className={classes.fact}
|
|
229
284
|
>
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
285
|
+
{f.value !== null && f.value !== undefined && f.value !== '' && (
|
|
286
|
+
<span
|
|
287
|
+
data-basalt-fact-value=""
|
|
288
|
+
{...(!hasComparison(f.comparison) && { 'data-basalt-fact-tone': '' })}
|
|
289
|
+
className={cx(
|
|
290
|
+
classes.factValue,
|
|
291
|
+
!hasComparison(f.comparison) && classes.factTone,
|
|
292
|
+
)}
|
|
293
|
+
>
|
|
294
|
+
{f.value}
|
|
295
|
+
</span>
|
|
296
|
+
)}
|
|
233
297
|
{f.unit !== undefined && <span className={classes.factUnit}>{f.unit}</span>}
|
|
234
|
-
{f.comparison
|
|
298
|
+
{hasComparison(f.comparison) && (
|
|
299
|
+
<span
|
|
300
|
+
data-basalt-fact-delta=""
|
|
301
|
+
data-basalt-fact-tone=""
|
|
302
|
+
className={classes.factTone}
|
|
303
|
+
>
|
|
304
|
+
<Comparison node={f.comparison} />
|
|
305
|
+
</span>
|
|
306
|
+
)}
|
|
235
307
|
{period !== '' && <span className={classes.factPeriod}>{period}</span>}
|
|
236
308
|
</span>
|
|
237
309
|
)
|
|
@@ -324,29 +396,39 @@ export function ChartCard({
|
|
|
324
396
|
style,
|
|
325
397
|
children,
|
|
326
398
|
facts,
|
|
327
|
-
...
|
|
399
|
+
...headerAndData
|
|
328
400
|
}: ChartCardProps): ReactElement {
|
|
401
|
+
const { data, rest: header } = splitDataAttributes(headerAndData)
|
|
329
402
|
const { ref, short } = useShortCard()
|
|
330
403
|
const resolved = resolveChartState(state)
|
|
404
|
+
// The noun an error names: `stateNoun`, else the card's own title ("Revenue" → "revenue").
|
|
405
|
+
const noun = stateNoun ?? header.title
|
|
331
406
|
const kind = resolved === 'pending' ? bodyKindOf(children) : undefined
|
|
332
407
|
const plotGhost = ghost ?? kind?.ghost
|
|
333
408
|
// `ghost` changes the shape only: the wrapped strip's height still sizes the pending box.
|
|
334
409
|
const pendingHeight = placeholderHeight ?? kind?.height
|
|
335
|
-
|
|
336
|
-
|
|
410
|
+
// One headline anatomy: the legacy `value`/`delta` hero is drawn as a fact (title, then value, delta
|
|
411
|
+
// and period in one baseline group), never pushed to the far edge of the title row.
|
|
412
|
+
const headline = facts ?? legacyFact(header)
|
|
413
|
+
const showFacts = headline !== undefined && resolved === null
|
|
414
|
+
const skeletonFacts = headline !== undefined && resolved === 'pending'
|
|
337
415
|
const hasHeader =
|
|
338
416
|
actions !== undefined ||
|
|
339
417
|
showFacts ||
|
|
340
418
|
skeletonFacts ||
|
|
341
419
|
HEADER_TRIGGERS.some((k) => header[k] !== undefined)
|
|
342
420
|
// With facts the subtitle is the basis line after them, not WidgetHeader's foldable row.
|
|
343
|
-
|
|
344
|
-
const
|
|
421
|
+
// The hero props are drawn by the facts row below, so `WidgetHeader` never sees them.
|
|
422
|
+
const { subtitle, value: _v, delta: _d, deltaPeriod: _p, deltaPolarity: _pol, ...rest } = header
|
|
423
|
+
const headerProps = headline === undefined ? header : rest
|
|
424
|
+
|
|
425
|
+
const hostBody = <HostTitleContext value={header.title}>{children}</HostTitleContext>
|
|
345
426
|
|
|
346
427
|
return (
|
|
347
428
|
<ChartCardContext.Provider value>
|
|
348
429
|
<div
|
|
349
430
|
ref={ref}
|
|
431
|
+
{...data}
|
|
350
432
|
data-basalt-chart-card=""
|
|
351
433
|
className={cx(classNames?.root, className)}
|
|
352
434
|
style={{ ...cardStyle, ...style }}
|
|
@@ -363,7 +445,7 @@ export function ChartCard({
|
|
|
363
445
|
actions: <span data-basalt-tier="widget">{actions}</span>,
|
|
364
446
|
})}
|
|
365
447
|
/>
|
|
366
|
-
{showFacts && <Facts facts={
|
|
448
|
+
{showFacts && <Facts facts={headline} basis={subtitle} stale={stale} />}
|
|
367
449
|
{skeletonFacts && <FactsSkeleton basis={subtitle !== undefined} />}
|
|
368
450
|
</div>
|
|
369
451
|
)}
|
|
@@ -372,13 +454,13 @@ export function ChartCard({
|
|
|
372
454
|
style={bodyClipStyle}
|
|
373
455
|
>
|
|
374
456
|
{resolved === null || (resolved === 'pending' && placeholderHeight === 'content')
|
|
375
|
-
?
|
|
457
|
+
? hostBody
|
|
376
458
|
: reserveLegend(
|
|
377
459
|
kind?.legend === true,
|
|
378
460
|
<ChartPlaceholder
|
|
379
461
|
state={state}
|
|
380
462
|
{...(pendingHeight !== undefined && { height: pendingHeight })}
|
|
381
|
-
{...(
|
|
463
|
+
{...(noun !== undefined && { noun })}
|
|
382
464
|
{...(plotGhost !== undefined && { ghost: plotGhost })}
|
|
383
465
|
{...(onRetry !== undefined && { onRetry })}
|
|
384
466
|
{...(retrying !== undefined && { retrying })}
|