@opendata-ai/openchart-core 8.7.0 → 8.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -480,6 +480,13 @@ interface ResolvedChrome {
480
480
  brand?: ResolvedChromeElement;
481
481
  /** Annotation footnotes generated by auto-thinning. Rendered as a numbered list above the source line. */
482
482
  footnotes?: AnnotationFootnote[];
483
+ /** Responsive series readout above source/methodology. */
484
+ seriesSummary?: Array<{
485
+ key: string;
486
+ text: string;
487
+ lines: string[];
488
+ color: string;
489
+ }>;
483
490
  /** Absolute y at which bottom-chrome relative offsets are anchored: area.y + area.height + x-axis extent. */
484
491
  bottomAnchorY?: number;
485
492
  }
@@ -1206,6 +1213,8 @@ interface ContinuousLegendTick {
1206
1213
  x: number;
1207
1214
  /** Horizontal text anchor for the label. */
1208
1215
  anchor: 'start' | 'middle' | 'end';
1216
+ /** Additional baseline offset for staggered class boundaries (pixels). */
1217
+ offsetY?: number;
1209
1218
  }
1210
1219
  /** A discrete class swatch in a binned continuous legend. */
1211
1220
  interface ContinuousLegendBin {
@@ -1431,6 +1440,8 @@ interface A11yMetadata {
1431
1440
  }
1432
1441
  /** One fully-resolved animation phase. */
1433
1442
  interface ResolvedAnimationPhase {
1443
+ /** Present for bounded spring mode; duration is its finite settling time. */
1444
+ spring?: SpringConfig;
1434
1445
  /** Duration in ms. */
1435
1446
  duration: number;
1436
1447
  /** Easing preset name. */
@@ -2404,6 +2415,8 @@ type MeasureTextFn = (text: string, fontSize: number, fontWeight?: number) => {
2404
2415
  * chrome, axes, and legend to compute the chart drawing area.
2405
2416
  */
2406
2417
  interface CompileOptions {
2418
+ /** Structured design review; emitted from the resolved chart geometry. */
2419
+ onDiagnostic?: (diagnostic: DesignDiagnostic) => void;
2407
2420
  /** Total available width in pixels. */
2408
2421
  width: number;
2409
2422
  /** Total available height in pixels. */
@@ -4103,6 +4116,14 @@ interface SeriesStyle {
4103
4116
  * Uses CSS linear() curves. Named 'ease' (not 'easing') to match Vega convention.
4104
4117
  */
4105
4118
  type AnimationEase = 'smooth' | 'snappy';
4119
+ /** Opt-in motion language. `legacy` preserves the v8 tween timing. */
4120
+ type AnimationPreset = 'fluid' | 'subtle' | 'legacy';
4121
+ /** Physical spring parameters. Quantitative motion is bounded at critical damping. */
4122
+ interface SpringConfig {
4123
+ stiffness?: number;
4124
+ damping?: number;
4125
+ mass?: number;
4126
+ }
4106
4127
  /** Stagger configuration for sequential element reveal. */
4107
4128
  interface AnimationStagger {
4108
4129
  /** Delay between each element in ms. Default: 80 */
@@ -4112,6 +4133,10 @@ interface AnimationStagger {
4112
4133
  }
4113
4134
  /** Fine-grained responsive behavior configuration. */
4114
4135
  interface ResponsiveConfig {
4136
+ /** Preserve the final temporal boundary before thinning interior ticks. */
4137
+ preserveEnd?: boolean;
4138
+ /** Move direct series labels into a keyed list when the inline column cannot fit. */
4139
+ labelSummary?: boolean;
4115
4140
  /**
4116
4141
  * Automatic annotation thinning at narrow widths. When true (default),
4117
4142
  * annotations that can't be placed without overlap are demoted to numbered
@@ -4125,6 +4150,8 @@ interface ResponsiveConfig {
4125
4150
  * Each phase can be true (use defaults) or a config object.
4126
4151
  */
4127
4152
  interface AnimationPhaseConfig {
4153
+ /** Spring mode. Cannot be combined with duration or ease in this phase. */
4154
+ spring?: SpringConfig;
4128
4155
  /** Duration in ms. Default: 500 for enter. */
4129
4156
  duration?: number;
4130
4157
  /** Easing preset. Default: 'smooth'. */
@@ -4151,6 +4178,8 @@ interface UpdatePhaseConfig extends AnimationPhaseConfig {
4151
4178
  * following Vega's encoding set model.
4152
4179
  */
4153
4180
  interface AnimationConfig {
4181
+ /** Base preset; explicit phase settings take precedence. */
4182
+ preset?: AnimationPreset;
4154
4183
  /** Entrance animation when chart first renders. */
4155
4184
  enter?: AnimationPhaseConfig | boolean;
4156
4185
  /** Transition animation when data updates. */
@@ -4166,7 +4195,7 @@ interface AnimationConfig {
4166
4195
  * - false/omitted: no animation (current behavior)
4167
4196
  * - AnimationConfig: full control via enter/update/exit phases
4168
4197
  */
4169
- type AnimationSpec = boolean | AnimationConfig;
4198
+ type AnimationSpec = boolean | AnimationPreset | AnimationConfig;
4170
4199
  /**
4171
4200
  * Chart display mode.
4172
4201
  * - `'full'` (default): standard chart with chrome, axes, legend, padding.
@@ -4417,6 +4446,8 @@ interface A11yConfig {
4417
4446
  * @internal
4418
4447
  */
4419
4448
  interface BaseChartSpec<TData extends DataRow = DataRow> {
4449
+ /** Optional authored measure, unit, provenance, and supplied interval metadata. */
4450
+ fields?: Record<string, FieldMetadata>;
4420
4451
  /**
4421
4452
  * Data array: each element is a row with field values.
4422
4453
  * The Vega-Lite object form `{ values: [...] }` is also accepted at runtime
@@ -4722,6 +4753,10 @@ type TableDensity = 'condensed' | 'regular' | 'relaxed';
4722
4753
  * heatmap coloring, inline sparklines, sorted columns, search, and pagination.
4723
4754
  */
4724
4755
  interface TableSpec {
4756
+ /** Compact layout. v8 defaults to cards; priority retains comparable columns with expandable details. */
4757
+ mobileLayout?: 'cards' | 'priority' | 'scroll';
4758
+ /** Optional authored measure, unit, provenance, and supplied interval metadata. */
4759
+ fields?: Record<string, FieldMetadata>;
4725
4760
  /** Discriminant: always "table". */
4726
4761
  type: 'table';
4727
4762
  /** Data array: each element is a row. */
@@ -5217,6 +5252,19 @@ type GeoMapFocus = string | number | Array<string | number> | {
5217
5252
  points: GeoMapPointsFocus;
5218
5253
  padding?: number;
5219
5254
  };
5255
+ /**
5256
+ * Reader zoom and pan for a map. Opt-in: maps without it stay static.
5257
+ *
5258
+ * `maxZoom` caps how far readers can zoom in, as a multiple of the full map
5259
+ * (the full map is 1, and readers can never zoom out past it). `controls`
5260
+ * shows the on-screen zoom in / zoom out / reset buttons.
5261
+ */
5262
+ interface GeoMapZoomConfig {
5263
+ /** Largest zoom factor, relative to the full map. Default 12, minimum 1. */
5264
+ maxZoom?: number;
5265
+ /** Show on-screen zoom in / zoom out / reset buttons. Default true. */
5266
+ controls?: boolean;
5267
+ }
5220
5268
  /** Geo configuration for map specs. */
5221
5269
  interface GeoMapGeo {
5222
5270
  /** TopoJSON topology object. User imports this from us-atlas, world-atlas, or their own source. */
@@ -5238,6 +5286,15 @@ interface GeoMapGeo {
5238
5286
  * story can pan between sub-clusters. null clears focus from a prior story step.
5239
5287
  */
5240
5288
  focus?: GeoMapFocus | null;
5289
+ /**
5290
+ * Let readers zoom and pan the map. Off by default. `true` enables it with
5291
+ * defaults; an object tunes the zoom ceiling and the on-screen buttons.
5292
+ * Gestures: ctrl/cmd + wheel or trackpad pinch zooms around the cursor (a
5293
+ * plain wheel scrolls the page), drag pans, double-click zooms in, two-finger
5294
+ * pinch zooms on touch, and +/-/arrows/0 work when the map has focus. One
5295
+ * finger scrolls the page until the reader has zoomed in, then pans the map.
5296
+ */
5297
+ zoom?: boolean | GeoMapZoomConfig;
5241
5298
  }
5242
5299
  /** Encoding channels specific to map visualizations. */
5243
5300
  interface GeoMapEncoding {
@@ -5269,6 +5326,8 @@ interface GeoMapPointsLayer {
5269
5326
  opacity?: number;
5270
5327
  }
5271
5328
  interface GeoMapSpec {
5329
+ /** Optional authored measure, unit, provenance, and supplied interval metadata. */
5330
+ fields?: Record<string, FieldMetadata>;
5272
5331
  /** Discriminant: always "map". */
5273
5332
  type: 'map';
5274
5333
  /** Geo configuration: TopoJSON features, join key, and projection. */
@@ -5678,6 +5737,81 @@ declare function isRefLineAnnotation(annotation: Annotation): annotation is RefL
5678
5737
  /** Human-readable display names for mark types (used in alt text, error messages). */
5679
5738
  declare const MARK_DISPLAY_NAMES: Record<MarkType, string>;
5680
5739
 
5740
+ /** Supplied semantics; the library never invents a measure or uncertainty. */
5741
+ interface FieldMetadata {
5742
+ /** Explicit imported field type; preserved with the portable document. */
5743
+ type?: 'text' | 'number' | 'date';
5744
+ /** Identifies an internal, persistent row identity column. */
5745
+ role?: 'identity';
5746
+ label?: string;
5747
+ unit?: string;
5748
+ measure?: string;
5749
+ provenance?: string;
5750
+ /** Percent is encoded 0–100; proportion is encoded 0–1. */
5751
+ representation?: 'number' | 'percent' | 'proportion';
5752
+ interval?: {
5753
+ lower: string;
5754
+ upper: string;
5755
+ };
5756
+ statusField?: string;
5757
+ }
5758
+ interface DesignDiagnostic {
5759
+ code: string;
5760
+ severity: 'info' | 'warning' | 'error';
5761
+ status: 'failed' | 'uncheckable';
5762
+ path: string;
5763
+ viewport: {
5764
+ width: number;
5765
+ height: number;
5766
+ };
5767
+ message: string;
5768
+ origin: 'author' | 'default';
5769
+ fix?: SpecPatch;
5770
+ }
5771
+ /** Atomic JSON-pointer edits guarded by the complete source document. */
5772
+ interface SpecPatch {
5773
+ label: string;
5774
+ /** Canonical source snapshot prevents stale fixes overwriting subsequent edits. */
5775
+ precondition: string;
5776
+ changes: Array<{
5777
+ path: string;
5778
+ value: unknown;
5779
+ }>;
5780
+ }
5781
+ type DesignQuestion = 'comparison' | 'change' | 'distribution' | 'composition' | 'geography' | 'relationships';
5782
+ interface CompositionRecommendation {
5783
+ id: string;
5784
+ title: string;
5785
+ reason: string;
5786
+ tradeoff: string;
5787
+ spec: VizSpec;
5788
+ }
5789
+ interface ObservationIdentity {
5790
+ observation: string;
5791
+ series?: string;
5792
+ persistent: boolean;
5793
+ }
5794
+ interface ReaderObservation extends ObservationIdentity {
5795
+ /** Aggregates are visible groups and never imply a raw-row selection. */
5796
+ kind?: 'row' | 'aggregate';
5797
+ datum: DataRow;
5798
+ previous?: DataRow;
5799
+ state: 'visible' | 'filtered';
5800
+ }
5801
+ interface ReaderSelection {
5802
+ preview: ReaderObservation | null;
5803
+ pinned: ReaderObservation[];
5804
+ announcement: string;
5805
+ }
5806
+ /** Explicit relationships; aggregate groups never masquerade as raw rows. */
5807
+ interface DatasetBinding {
5808
+ dataset: string;
5809
+ entityField: string;
5810
+ kind: 'row' | 'group';
5811
+ transform?: string;
5812
+ groupMembers?: Record<string, Array<string | number>>;
5813
+ }
5814
+
5681
5815
  /**
5682
5816
  * Per-mark-type encoding validation rules.
5683
5817
  *
@@ -6224,6 +6358,10 @@ declare const broadsheet: ThemeConfig;
6224
6358
  * siblings, the register a monitoring UI wants.
6225
6359
  */
6226
6360
  declare const terminal: ThemeConfig;
6361
+ /** Next-generation editorial composition; opt in during v8. */
6362
+ declare const clarity: ThemeConfig;
6363
+ /** Documented v8 typography. This does not freeze the layout engine. */
6364
+ declare const legacyEditorial: ThemeConfig;
6227
6365
 
6228
6366
  /**
6229
6367
  * Theme resolver: deep-merges user overrides onto default theme.
@@ -6956,6 +7094,30 @@ declare function tileMap(data: Record<string, number | string | null> | DataRow[
6956
7094
  */
6957
7095
  declare function deepMergeSpec(target: any, source: any): any;
6958
7096
 
7097
+ /** Deterministic, bounded motion shared by rendering and timestamp-based export. */
7098
+
7099
+ interface MotionPhase {
7100
+ duration: number;
7101
+ ease?: AnimationEase;
7102
+ spring?: SpringConfig;
7103
+ }
7104
+ interface MotionSample {
7105
+ /** Normalized progress; quantitative geometry never overshoots its endpoints. */
7106
+ position: number;
7107
+ /** Normalized distance per second. */
7108
+ velocity: number;
7109
+ settled: boolean;
7110
+ }
7111
+ declare const MOTION_REST_THRESHOLD = 0.001;
7112
+ declare const MAX_SPRING_DURATION = 1200;
7113
+ declare const FLUID_SPRING: Readonly<Required<SpringConfig>>;
7114
+ /** Resolve finite duration once, outside the frame loop. */
7115
+ declare function springDuration(config: SpringConfig): number;
7116
+ /** All callers, including exports, pass elapsed milliseconds explicitly. */
7117
+ declare function sampleMotion(phase: MotionPhase, elapsedMs: number): MotionSample;
7118
+ /** CSS samples use the same clock and evaluator as SVG, canvas, and export. */
7119
+ declare function motionCSS(phase: MotionPhase): string;
7120
+
6959
7121
  interface CssTokenDef {
6960
7122
  name: string;
6961
7123
  light: string;
@@ -6980,4 +7142,4 @@ declare const CSS_TOKEN_ROOT_SELECTORS: readonly string[];
6980
7142
  declare const CSS_TOKENS: readonly CssTokenDef[];
6981
7143
  declare function cssTokenDefault(name: string, mode: 'light' | 'dark'): string;
6982
7144
 
6983
- export { type A11yConfig, type A11yMetadata, ACHROMATIC_RAMP, AXIS_TITLE_GAP, AXIS_TITLE_OFFSET_COMPACT, AXIS_TITLE_OFFSET_DEFAULT, AXIS_TITLE_TRAILING_PAD, type AggregateOp, type AggregateTransform, type AnimationConfig, type AnimationEase, type AnimationPhaseConfig, type AnimationSpec, type AnimationStagger, type Annotation, type AnnotationAnchor, type AnnotationFootnote, type AnnotationOffset, type AnnotationPosition, type ArcEncoding, type ArcMark, type AreaEncoding, type AreaMark, type AxisConfig, type AxisLabelDensity, type AxisLayout, type AxisTick, BRAND_FONT_SIZE, BRAND_MIN_WIDTH, BRAND_RESERVE_WIDTH, BREAKPOINT_COMPACT_MAX, BREAKPOINT_MEDIUM_MAX, type BarColumnConfig, type BarEncoding, type BarListEncoding, type BarListLayout, type BarListRowMark, type BarListSpec, type BarListSpecWithoutData, type BarTableCell, type BaseLegendLayout, type BeeswarmEncoding, type BinParams, type BinTransform, type Breakpoint, CATEGORICAL_EXTENDED_PALETTE, CATEGORICAL_FILL_PALETTE, CATEGORICAL_FILL_PALETTE_DARK, CATEGORICAL_PALETTE, CATEGORICAL_PALETTE_DARK, COMPACT_MAX_X_TICKS, COMPACT_WIDTH, CSS_TOKENS, CSS_TOKEN_ROOT_SELECTORS, type CalculateExpression, type CalculateTransform, type CalendarEncoding, type CategoricalLegendLayout, type CategoricalPalette, type CategoryColorsConfig, type CategoryTableCell, type CellStyle, type ChannelRule, type ChartBuilderOptions, type ChartEventHandlers, type ChartLayout, type ChartSpec, type ChartSpecOverride, type ChartSpecWithoutData, type Chrome, type ChromeDefaults, type ChromeEconomy, type ChromeKey, type ChromeMode, type ChromeText, type ChromeTextStyle, type ChromeThemeOverride, type CircleEncoding, type ColorBlindnessType, type ColumnConfig, type CompileOptions, type CompileTableOptions, type CompileWarning, type Condition, type ConditionalValueDef, type ConnectorConfig, type ConnectorType, type ContinuousLegendBin, type ContinuousLegendLayout, type ContinuousLegendTick, type CssTokenDef, DEFAULT_THEME, DIVERGING_PALETTES, type DarkMode, type DataRow, type DateGranularity, type DeltaColumnConfig, type DeltaTableCell, type DensityEncoding, type DensityTransform, type Display, type DivergingPalette, EXTENDED_OFFSET_STRATEGIES, type ElementEdit, type ElementRef, type Encoding, type EncodingChannel, type EncodingRule, type EndpointLabelContent, type EndpointLabelEntry, type EndpointLabelsConfig, type EndpointLabelsLayout, FOOTNOTE_LINE_HEIGHT, type FacetChannel, type FacetLayout, type FacetPanelLayout, type FieldFormatContext, type FieldPredicate, type FieldRef, type FieldType, type FillPatternType, type FilterPredicate, type FilterTransform, type FlagTableCell, type FoldTransform, GRAPH_ENCODING_RULES, type GeoMapBorders, type GeoMapEncoding, type GeoMapFeatureMark, type GeoMapFocus, type GeoMapFocusLayout, type GeoMapGeo, type GeoMapLayout, type GeoMapPointMark, type GeoMapPointsLayer, type GeoMapProjection, type GeoMapSpec, type GeoMapSpecWithoutData, type GradientColorStop, type GradientDef, type GradientLegendLayout, type GradientStop, type GraphAnimationConfig, type GraphAnimationSpec, type GraphChannelRule, type GraphEdge, type GraphEdgeLayout, type GraphEncoding, type GraphEncodingChannel, type GraphInteractionConfig, type GraphLayout, type GraphLayoutConfig, type GraphNode, type GraphNodeLayout, type GraphSpec, type GraphSpecWithoutData, type Gridline, HEIGHT_CRAMPED_MAX, HEIGHT_MINIMAL_MAX, HEIGHT_NO_GRID_MAX, HEIGHT_SHORT_MAX, HPAD_COMPACT_FRACTION, HPAD_COMPACT_MIN, type HeatmapColumnConfig, type HeatmapTableCell, type HeightClass, type HistogramEncoding, type ImageColumnConfig, type ImageTableCell, type JoinAggregateTransform, LABEL_GAP_COMPACT, LABEL_GAP_DEFAULT, LABEL_GAP_NARROW_MAX, type LabelCandidate, type LabelConfig, type LabelDensity, type LabelMode, type LabelPriority, type LabelSpec, type LayerSpec, type LayoutStrategy, type LegendChannel, type LegendConfig, type LegendEntry, type LegendEntryPosition, type LegendLayout, type LegendPosition, type LineEncoding, type LineMark, type LinearGradient, type LogicalAnd, type LogicalNot, type LogicalOr, type LollipopEncoding, MARK_DISPLAY_NAMES, MARK_ENCODING_RULES, MARK_TYPES, MAX_LEFT_LABEL_FRACTION_COMPACT, MAX_LEFT_LABEL_FRACTION_DEFAULT, MAX_LEFT_LABEL_FRACTION_MEDIUM, MAX_LEFT_LABEL_FRACTION_MEDIUM_MAX, MAX_SR_TABLE_ROWS, type Margins, type Mark, type MarkAria, type MarkDef, type MarkEvent, type MarkType, type MeasureTextFn, type Metric, NARROW_VIEWPORT_MAX, type NeutralRamp, type NodeOverride, type NumberFormatter, OFFSET_STRATEGIES, type OffsetStrategy, type PaginationState, type ParliamentEncoding, type Point, type PointEncoding, type PointMark, type RadialGradient, type RangeAnnotation, type RangeEncoding, type Rect, type RectEncoding, type RectMark, type RefLineAnnotation, type RelativeTimeRef, type ResolveConfig, type ResolveMode, type ResolvedAnimation, type ResolvedAnimationPhase, type ResolvedAnnotation, type ResolvedChrome, type ResolvedChromeElement, type ResolvedChromeRule, type ResolvedColumn, type ResolvedFillPattern, type ResolvedLabel, type ResolvedMetricBar, type ResolvedMetricCell, type ResolvedSeriesSearch, type ResolvedTheme, type ResolvedThemeColors, type ResolvedYouDrawIt, type ResponsiveConfig, type RuleMarkLayout, SEQUENTIAL_PALETTES, SUPPORTED_SCHEME_NAMES, type SankeyEncoding, type SankeyLayout, type SankeyLinkColor, type SankeyLinkMark, type SankeyNodeAlign, type SankeyNodeMark, type SankeySpec, type SankeySpecWithoutData, type ScaleConfig, type ScaleInvert, type ScaleType, type SequentialPalette, type SeriesSearchConfig, type SeriesStrategy, type SeriesStyle, type SizeLegendCircle, type SizeLegendLayout, type SortByField, type SortState, type SparklineColumnConfig, type SparklineData, type SparklineTableCell, type StoredVizSpec, TICK_LABEL_OFFSET, TICK_LINE_HEIGHT_FACTOR, TOP_PAD_EXTRA_NARROW, TOP_PAD_NARROW_MAX, type TableBuilderOptions, type TableCell, type TableCellBase, type TableDensity, type TableLayout, type TableRow, type TableSpec, type TableSpecWithoutData, type TableTotalRow, type TextAnnotation, type TextEncoding, type TextMarkLayout, type TextStyle, type TextTableCell, type Theme, type ThemeChromeDefaults, type ThemeColors, type ThemeConfig, type ThemeFontSizes, type ThemeFontWeights, type ThemeFonts, type ThemeRule, type ThemeSpacing, type TickEncoding, type TickMarkLayout, type TileMapBuilderOptions, type TileMapEncoding, type TileMapLayout, type TileMapPalette, type TileMapSpec, type TileMapSpecWithoutData, type TileMapTileMark, type TimeUnit, type TimeUnitTransform, type TokenValue, type TooltipContent, type TooltipField, type Transform, type UpdatePhaseConfig, type ValueDef, type VizSpec, type WaffleEncoding, type WindowFieldDef, type WindowOp, type WindowSortField, type WindowTransform, type XAxisExtentInput, X_AXIS_BAND_HEIGHT, X_AXIS_ROTATED_EXTENT_CAP, X_AXIS_TITLE_BAND, X_AXIS_TITLE_BAND_ROTATED, type YouDrawItConfig, type YouDrawItSample, type YouDrawItYInvert, abbreviateNumber, adaptColorForDarkMode, adaptForLightLineStroke, adaptTheme, areaChart, axisTitleOffset, barChart, broadsheet, buildCompactStepFormatter, buildD3Formatter, buildTemporalFormatter, checkPaletteDistinguishability, columnChart, computeChrome, computeFieldFormatContext, computeLabelBounds, computeXAxisExtentFromLabels, contrastRatio, cssTokenDefault, dataTable, deepMergeSpec, defaultNumberFormatter, deriveNeutralRamp, detectCollision, donutChart, dotChart, editorial, elementRef, essay, estimateTextWidth, findAccessibleColor, footnoteBandHeight, formatCurrency, formatDate, formatNumber, formatOrdinal, formatPercent, generateAltText, generateAriaLabels, generateDataTable, getAxisTitleOffset, getBreakpoint, getHeightClass, getLayoutStrategy, getRepresentativeColor, heuristicMeasure, inferFieldType, isAxislessMark, isBarListSpec, isChartSpec, isConditionalDef, isEncodingChannel, isGeoMapSpec, isGradientDef, isGraphSpec, isLayerSpec, isOpaqueColor, isRangeAnnotation, isRefLineAnnotation, isSankeySpec, isTableSpec, isTextAnnotation, isTileMapSpec, isValueDef, isYearContext, lineChart, maxRotatedLabelWidth, meetsAA, overlapArea, pickLabelColor, pieChart, resolveChromeEconomy, resolveCollisions, resolveMarkDef, resolveMarkType, resolveMeasurer, resolveNumberFormatter, resolveSchemeName, resolveTheme, scatterChart, simulateColorBlindness, terminal, textAscent, tileMap, truncateRotatedLabel, truncateToWidth, wire, wrapText };
7145
+ export { type A11yConfig, type A11yMetadata, ACHROMATIC_RAMP, AXIS_TITLE_GAP, AXIS_TITLE_OFFSET_COMPACT, AXIS_TITLE_OFFSET_DEFAULT, AXIS_TITLE_TRAILING_PAD, type AggregateOp, type AggregateTransform, type AnimationConfig, type AnimationEase, type AnimationPhaseConfig, type AnimationPreset, type AnimationSpec, type AnimationStagger, type Annotation, type AnnotationAnchor, type AnnotationFootnote, type AnnotationOffset, type AnnotationPosition, type ArcEncoding, type ArcMark, type AreaEncoding, type AreaMark, type AxisConfig, type AxisLabelDensity, type AxisLayout, type AxisTick, BRAND_FONT_SIZE, BRAND_MIN_WIDTH, BRAND_RESERVE_WIDTH, BREAKPOINT_COMPACT_MAX, BREAKPOINT_MEDIUM_MAX, type BarColumnConfig, type BarEncoding, type BarListEncoding, type BarListLayout, type BarListRowMark, type BarListSpec, type BarListSpecWithoutData, type BarTableCell, type BaseLegendLayout, type BeeswarmEncoding, type BinParams, type BinTransform, type Breakpoint, CATEGORICAL_EXTENDED_PALETTE, CATEGORICAL_FILL_PALETTE, CATEGORICAL_FILL_PALETTE_DARK, CATEGORICAL_PALETTE, CATEGORICAL_PALETTE_DARK, COMPACT_MAX_X_TICKS, COMPACT_WIDTH, CSS_TOKENS, CSS_TOKEN_ROOT_SELECTORS, type CalculateExpression, type CalculateTransform, type CalendarEncoding, type CategoricalLegendLayout, type CategoricalPalette, type CategoryColorsConfig, type CategoryTableCell, type CellStyle, type ChannelRule, type ChartBuilderOptions, type ChartEventHandlers, type ChartLayout, type ChartSpec, type ChartSpecOverride, type ChartSpecWithoutData, type Chrome, type ChromeDefaults, type ChromeEconomy, type ChromeKey, type ChromeMode, type ChromeText, type ChromeTextStyle, type ChromeThemeOverride, type CircleEncoding, type ColorBlindnessType, type ColumnConfig, type CompileOptions, type CompileTableOptions, type CompileWarning, type CompositionRecommendation, type Condition, type ConditionalValueDef, type ConnectorConfig, type ConnectorType, type ContinuousLegendBin, type ContinuousLegendLayout, type ContinuousLegendTick, type CssTokenDef, DEFAULT_THEME, DIVERGING_PALETTES, type DarkMode, type DataRow, type DatasetBinding, type DateGranularity, type DeltaColumnConfig, type DeltaTableCell, type DensityEncoding, type DensityTransform, type DesignDiagnostic, type DesignQuestion, type Display, type DivergingPalette, EXTENDED_OFFSET_STRATEGIES, type ElementEdit, type ElementRef, type Encoding, type EncodingChannel, type EncodingRule, type EndpointLabelContent, type EndpointLabelEntry, type EndpointLabelsConfig, type EndpointLabelsLayout, FLUID_SPRING, FOOTNOTE_LINE_HEIGHT, type FacetChannel, type FacetLayout, type FacetPanelLayout, type FieldFormatContext, type FieldMetadata, type FieldPredicate, type FieldRef, type FieldType, type FillPatternType, type FilterPredicate, type FilterTransform, type FlagTableCell, type FoldTransform, GRAPH_ENCODING_RULES, type GeoMapBorders, type GeoMapEncoding, type GeoMapFeatureMark, type GeoMapFocus, type GeoMapFocusLayout, type GeoMapGeo, type GeoMapLayout, type GeoMapPointMark, type GeoMapPointsLayer, type GeoMapProjection, type GeoMapSpec, type GeoMapSpecWithoutData, type GeoMapZoomConfig, type GradientColorStop, type GradientDef, type GradientLegendLayout, type GradientStop, type GraphAnimationConfig, type GraphAnimationSpec, type GraphChannelRule, type GraphEdge, type GraphEdgeLayout, type GraphEncoding, type GraphEncodingChannel, type GraphInteractionConfig, type GraphLayout, type GraphLayoutConfig, type GraphNode, type GraphNodeLayout, type GraphSpec, type GraphSpecWithoutData, type Gridline, HEIGHT_CRAMPED_MAX, HEIGHT_MINIMAL_MAX, HEIGHT_NO_GRID_MAX, HEIGHT_SHORT_MAX, HPAD_COMPACT_FRACTION, HPAD_COMPACT_MIN, type HeatmapColumnConfig, type HeatmapTableCell, type HeightClass, type HistogramEncoding, type ImageColumnConfig, type ImageTableCell, type JoinAggregateTransform, LABEL_GAP_COMPACT, LABEL_GAP_DEFAULT, LABEL_GAP_NARROW_MAX, type LabelCandidate, type LabelConfig, type LabelDensity, type LabelMode, type LabelPriority, type LabelSpec, type LayerSpec, type LayoutStrategy, type LegendChannel, type LegendConfig, type LegendEntry, type LegendEntryPosition, type LegendLayout, type LegendPosition, type LineEncoding, type LineMark, type LinearGradient, type LogicalAnd, type LogicalNot, type LogicalOr, type LollipopEncoding, MARK_DISPLAY_NAMES, MARK_ENCODING_RULES, MARK_TYPES, MAX_LEFT_LABEL_FRACTION_COMPACT, MAX_LEFT_LABEL_FRACTION_DEFAULT, MAX_LEFT_LABEL_FRACTION_MEDIUM, MAX_LEFT_LABEL_FRACTION_MEDIUM_MAX, MAX_SPRING_DURATION, MAX_SR_TABLE_ROWS, MOTION_REST_THRESHOLD, type Margins, type Mark, type MarkAria, type MarkDef, type MarkEvent, type MarkType, type MeasureTextFn, type Metric, type MotionPhase, type MotionSample, NARROW_VIEWPORT_MAX, type NeutralRamp, type NodeOverride, type NumberFormatter, OFFSET_STRATEGIES, type ObservationIdentity, type OffsetStrategy, type PaginationState, type ParliamentEncoding, type Point, type PointEncoding, type PointMark, type RadialGradient, type RangeAnnotation, type RangeEncoding, type ReaderObservation, type ReaderSelection, type Rect, type RectEncoding, type RectMark, type RefLineAnnotation, type RelativeTimeRef, type ResolveConfig, type ResolveMode, type ResolvedAnimation, type ResolvedAnimationPhase, type ResolvedAnnotation, type ResolvedChrome, type ResolvedChromeElement, type ResolvedChromeRule, type ResolvedColumn, type ResolvedFillPattern, type ResolvedLabel, type ResolvedMetricBar, type ResolvedMetricCell, type ResolvedSeriesSearch, type ResolvedTheme, type ResolvedThemeColors, type ResolvedYouDrawIt, type ResponsiveConfig, type RuleMarkLayout, SEQUENTIAL_PALETTES, SUPPORTED_SCHEME_NAMES, type SankeyEncoding, type SankeyLayout, type SankeyLinkColor, type SankeyLinkMark, type SankeyNodeAlign, type SankeyNodeMark, type SankeySpec, type SankeySpecWithoutData, type ScaleConfig, type ScaleInvert, type ScaleType, type SequentialPalette, type SeriesSearchConfig, type SeriesStrategy, type SeriesStyle, type SizeLegendCircle, type SizeLegendLayout, type SortByField, type SortState, type SparklineColumnConfig, type SparklineData, type SparklineTableCell, type SpecPatch, type SpringConfig, type StoredVizSpec, TICK_LABEL_OFFSET, TICK_LINE_HEIGHT_FACTOR, TOP_PAD_EXTRA_NARROW, TOP_PAD_NARROW_MAX, type TableBuilderOptions, type TableCell, type TableCellBase, type TableDensity, type TableLayout, type TableRow, type TableSpec, type TableSpecWithoutData, type TableTotalRow, type TextAnnotation, type TextEncoding, type TextMarkLayout, type TextStyle, type TextTableCell, type Theme, type ThemeChromeDefaults, type ThemeColors, type ThemeConfig, type ThemeFontSizes, type ThemeFontWeights, type ThemeFonts, type ThemeRule, type ThemeSpacing, type TickEncoding, type TickMarkLayout, type TileMapBuilderOptions, type TileMapEncoding, type TileMapLayout, type TileMapPalette, type TileMapSpec, type TileMapSpecWithoutData, type TileMapTileMark, type TimeUnit, type TimeUnitTransform, type TokenValue, type TooltipContent, type TooltipField, type Transform, type UpdatePhaseConfig, type ValueDef, type VizSpec, type WaffleEncoding, type WindowFieldDef, type WindowOp, type WindowSortField, type WindowTransform, type XAxisExtentInput, X_AXIS_BAND_HEIGHT, X_AXIS_ROTATED_EXTENT_CAP, X_AXIS_TITLE_BAND, X_AXIS_TITLE_BAND_ROTATED, type YouDrawItConfig, type YouDrawItSample, type YouDrawItYInvert, abbreviateNumber, adaptColorForDarkMode, adaptForLightLineStroke, adaptTheme, areaChart, axisTitleOffset, barChart, broadsheet, buildCompactStepFormatter, buildD3Formatter, buildTemporalFormatter, checkPaletteDistinguishability, clarity, columnChart, computeChrome, computeFieldFormatContext, computeLabelBounds, computeXAxisExtentFromLabels, contrastRatio, cssTokenDefault, dataTable, deepMergeSpec, defaultNumberFormatter, deriveNeutralRamp, detectCollision, donutChart, dotChart, editorial, elementRef, essay, estimateTextWidth, findAccessibleColor, footnoteBandHeight, formatCurrency, formatDate, formatNumber, formatOrdinal, formatPercent, generateAltText, generateAriaLabels, generateDataTable, getAxisTitleOffset, getBreakpoint, getHeightClass, getLayoutStrategy, getRepresentativeColor, heuristicMeasure, inferFieldType, isAxislessMark, isBarListSpec, isChartSpec, isConditionalDef, isEncodingChannel, isGeoMapSpec, isGradientDef, isGraphSpec, isLayerSpec, isOpaqueColor, isRangeAnnotation, isRefLineAnnotation, isSankeySpec, isTableSpec, isTextAnnotation, isTileMapSpec, isValueDef, isYearContext, legacyEditorial, lineChart, maxRotatedLabelWidth, meetsAA, motionCSS, overlapArea, pickLabelColor, pieChart, resolveChromeEconomy, resolveCollisions, resolveMarkDef, resolveMarkType, resolveMeasurer, resolveNumberFormatter, resolveSchemeName, resolveTheme, sampleMotion, scatterChart, simulateColorBlindness, springDuration, terminal, textAscent, tileMap, truncateRotatedLabel, truncateToWidth, wire, wrapText };
package/dist/index.js CHANGED
@@ -1771,6 +1771,23 @@ var terminal = {
1771
1771
  borderRadius: 4,
1772
1772
  seriesStrategy: "accent-neutral"
1773
1773
  };
1774
+ var clarity = {
1775
+ colors: {
1776
+ background: { light: "#ffffff", dark: "#09090b" },
1777
+ axis: { light: "#52525b", dark: "#a1a1aa" }
1778
+ },
1779
+ fonts: { sizes: { title: 26, subtitle: 14, body: 13, small: 12, axisTick: 12 } },
1780
+ chrome: {
1781
+ eyebrow: { color: { light: "#0f766e", dark: "#5eead4" } },
1782
+ source: { fontSize: 12 },
1783
+ footer: { fontSize: 12 }
1784
+ },
1785
+ spacing: { chromeToChart: 16, chartToFooter: 12 }
1786
+ };
1787
+ var legacyEditorial = {
1788
+ fonts: { sizes: { title: 26, subtitle: 14, body: 13, small: 11, axisTick: 11 } },
1789
+ spacing: { padding: 20, chromeGap: 6, chromeToChart: 8, chartToFooter: 8 }
1790
+ };
1774
1791
 
1775
1792
  // src/theme/resolve.ts
1776
1793
  function deepMerge(target, source) {
@@ -3089,6 +3106,82 @@ function deepMergeSpec(target, source) {
3089
3106
  }
3090
3107
  return result;
3091
3108
  }
3109
+
3110
+ // src/motion/sample.ts
3111
+ var MOTION_REST_THRESHOLD = 1e-3;
3112
+ var MAX_SPRING_DURATION = 1200;
3113
+ var FLUID_SPRING = {
3114
+ stiffness: 320,
3115
+ damping: 36,
3116
+ mass: 1
3117
+ };
3118
+ function springState(timeMs, config) {
3119
+ const stiffness = config.stiffness ?? FLUID_SPRING.stiffness;
3120
+ const mass = config.mass ?? FLUID_SPRING.mass;
3121
+ const rootStiffness = Math.sqrt(stiffness);
3122
+ const rootMass = Math.sqrt(mass);
3123
+ const omega = rootStiffness / rootMass;
3124
+ const damping = config.damping ?? FLUID_SPRING.damping;
3125
+ const zeta = Math.max(1, damping / rootStiffness / rootMass / 2);
3126
+ const t = Math.max(0, timeMs) / 1e3;
3127
+ let remaining;
3128
+ let velocity;
3129
+ if (zeta - 1 < 1e-4) {
3130
+ const scaledTime = omega * t;
3131
+ const decay = Math.exp(-scaledTime);
3132
+ remaining = decay === 0 ? 0 : (1 + scaledTime) * decay;
3133
+ velocity = decay === 0 ? 0 : omega * (scaledTime * decay);
3134
+ } else {
3135
+ const inverseZeta = 1 / zeta;
3136
+ const q = damping / 2 * (1 + Math.sqrt(1 - inverseZeta * inverseZeta));
3137
+ const slow = -stiffness / q;
3138
+ const fast = -q / mass;
3139
+ const ratio = slow / fast;
3140
+ const slowDecay = Math.exp(slow * t);
3141
+ const fastDecay = Math.exp(fast * t);
3142
+ if (slowDecay === 0) {
3143
+ remaining = 0;
3144
+ velocity = 0;
3145
+ } else {
3146
+ remaining = (slowDecay - ratio * fastDecay) / (1 - ratio);
3147
+ velocity = -slow * ((slowDecay - fastDecay) / (1 - ratio));
3148
+ }
3149
+ }
3150
+ return {
3151
+ position: Math.min(1, Math.max(0, 1 - remaining)),
3152
+ velocity,
3153
+ settled: remaining <= MOTION_REST_THRESHOLD && Math.abs(velocity) <= MOTION_REST_THRESHOLD
3154
+ };
3155
+ }
3156
+ function springDuration(config) {
3157
+ for (const name of ["stiffness", "damping", "mass"]) {
3158
+ const value = config[name];
3159
+ if (value === void 0) continue;
3160
+ if (!Number.isFinite(value) || value <= 0)
3161
+ throw new Error(`spring.${name} must be finite and positive`);
3162
+ }
3163
+ for (let ms = 1; ms < MAX_SPRING_DURATION; ms++) {
3164
+ if (springState(ms, config).settled) return ms;
3165
+ }
3166
+ return MAX_SPRING_DURATION;
3167
+ }
3168
+ function sampleMotion(phase, elapsedMs) {
3169
+ if (phase.duration <= 0 || elapsedMs >= phase.duration) {
3170
+ return { position: 1, velocity: 0, settled: true };
3171
+ }
3172
+ if (elapsedMs <= 0) return { position: 0, velocity: 0, settled: false };
3173
+ if (phase.spring) return springState(elapsedMs, phase.spring);
3174
+ const t = elapsedMs / phase.duration;
3175
+ const power = phase.ease === "snappy" ? 5 : 3;
3176
+ return {
3177
+ position: 1 - (1 - t) ** power,
3178
+ velocity: power * (1 - t) ** (power - 1) * 1e3 / phase.duration,
3179
+ settled: false
3180
+ };
3181
+ }
3182
+ function motionCSS(phase) {
3183
+ return `linear(${Array.from({ length: 101 }, (_, i) => sampleMotion(phase, i * phase.duration / 100).position.toFixed(6)).join(",")})`;
3184
+ }
3092
3185
  export {
3093
3186
  ACHROMATIC_RAMP,
3094
3187
  AXIS_TITLE_GAP,
@@ -3112,6 +3205,7 @@ export {
3112
3205
  DEFAULT_THEME,
3113
3206
  DIVERGING_PALETTES,
3114
3207
  EXTENDED_OFFSET_STRATEGIES,
3208
+ FLUID_SPRING,
3115
3209
  FOOTNOTE_LINE_HEIGHT,
3116
3210
  GRAPH_ENCODING_RULES,
3117
3211
  HEIGHT_CRAMPED_MAX,
@@ -3130,7 +3224,9 @@ export {
3130
3224
  MAX_LEFT_LABEL_FRACTION_DEFAULT,
3131
3225
  MAX_LEFT_LABEL_FRACTION_MEDIUM,
3132
3226
  MAX_LEFT_LABEL_FRACTION_MEDIUM_MAX,
3227
+ MAX_SPRING_DURATION,
3133
3228
  MAX_SR_TABLE_ROWS,
3229
+ MOTION_REST_THRESHOLD,
3134
3230
  NARROW_VIEWPORT_MAX,
3135
3231
  OFFSET_STRATEGIES,
3136
3232
  SEQUENTIAL_PALETTES,
@@ -3155,6 +3251,7 @@ export {
3155
3251
  buildD3Formatter,
3156
3252
  buildTemporalFormatter,
3157
3253
  checkPaletteDistinguishability,
3254
+ clarity,
3158
3255
  columnChart,
3159
3256
  computeChrome,
3160
3257
  computeFieldFormatContext,
@@ -3208,9 +3305,11 @@ export {
3208
3305
  isTileMapSpec,
3209
3306
  isValueDef,
3210
3307
  isYearContext,
3308
+ legacyEditorial,
3211
3309
  lineChart,
3212
3310
  maxRotatedLabelWidth,
3213
3311
  meetsAA,
3312
+ motionCSS,
3214
3313
  overlapArea,
3215
3314
  pickLabelColor,
3216
3315
  pieChart,
@@ -3222,8 +3321,10 @@ export {
3222
3321
  resolveNumberFormatter,
3223
3322
  resolveSchemeName,
3224
3323
  resolveTheme,
3324
+ sampleMotion,
3225
3325
  scatterChart,
3226
3326
  simulateColorBlindness,
3327
+ springDuration,
3227
3328
  terminal,
3228
3329
  textAscent,
3229
3330
  tileMap,