@toclocoinc/lattice-grid 1.29.0 → 1.31.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/lattice-grid.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Lattice Grid 1.29.0, type declarations
2
+ * Lattice Grid 1.31.0, type declarations
3
3
  * Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
4
4
  * https://latticegrid.dev
5
5
  */
@@ -712,6 +712,36 @@ export interface Column {
712
712
  * value comes from a sketch and is stamped by a `windowApproximate` column.
713
713
  */
714
714
  q?: number;
715
+ /**
716
+ * For a seasonal-decomposition kind (`tsTrend`/`tsSeasonal`/`tsResidual`/
717
+ * `tsCoverage`, BACKLOG-0000873), the season length — **required**, since
718
+ * there is no auto-detection in v1: 7 for a weekly cycle in daily data, 12
719
+ * for a monthly cycle in monthly data. An integer of at least 2.
720
+ */
721
+ period?: number;
722
+ /**
723
+ * For a decomposition kind, the classical model: additive by default, or
724
+ * `multiplicative` (which is undefined on a non-positive series, so those
725
+ * rows report null and the caller is warned).
726
+ */
727
+ decomposition?: 'additive' | 'multiplicative';
728
+ /**
729
+ * For an exponential-smoothing kind (`tsSmoothed`/`tsSmoothingAlpha`/
730
+ * `tsSmoothingBeta`, BACKLOG-0000873), the model: single exponential
731
+ * smoothing (`ses`, the default) or Holt's level+trend (`holt`).
732
+ */
733
+ smoothing?: 'ses' | 'holt';
734
+ /**
735
+ * For a smoothing kind, the level factor in `[0, 1]`. Omit to fit it by
736
+ * minimising in-sample SSE; the chosen value is reported by a
737
+ * `tsSmoothingAlpha` column.
738
+ */
739
+ alpha?: number;
740
+ /**
741
+ * For `smoothing: 'holt'`, the trend factor in `[0, 1]`. Omit to fit it;
742
+ * reported by a `tsSmoothingBeta` column.
743
+ */
744
+ beta?: number;
715
745
  /**
716
746
  * For a `fit*` kind (BACKLOG-0000812), the regression model the shadow reads
717
747
  * — predictors, response, method and confidence. Its predictors/response may
@@ -2193,6 +2223,12 @@ export interface GridState {
2193
2223
  */
2194
2224
  pivotView?: { rowsCollapsed: string[]; columnsCollapsed: string[] };
2195
2225
  formatting?: Record<string, FormattingRule[]>;
2226
+ /**
2227
+ * Durable annotation marks (BACKLOG-0000813): seeded from here on first paint,
2228
+ * and written back by `getState` so a host can persist and restore them. In
2229
+ * content coordinates, so they track scroll and resize.
2230
+ */
2231
+ annotations?: AnnotationMark[];
2196
2232
  expanded?: string[];
2197
2233
  selection?: string[];
2198
2234
  scroll?: { top: number; left: number };
@@ -2555,6 +2591,22 @@ export interface StatisticsApi {
2555
2591
  * families refuse. Null on degenerate input (BACKLOG-0000792).
2556
2592
  */
2557
2593
  regressionModel(spec: RegressionSpec): RegressionModel | null;
2594
+ /**
2595
+ * The Augmented Dickey-Fuller stationarity test over the `of` series in
2596
+ * `orderBy` order (BACKLOG-0000873), constant+trend form with the lag order
2597
+ * chosen by AIC up to an optional cap. Returns the statistic, the lag used,
2598
+ * MacKinnon's critical values, an approximate (interpolated) p-value and a
2599
+ * plain-language verdict at the 5% level — a scalar readout, not a column.
2600
+ */
2601
+ adf(spec: { of: string; orderBy: string; maxlag?: number }): AdfResult | null;
2602
+ /**
2603
+ * The autocorrelation (ACF) and partial autocorrelation (PACF) of the `of`
2604
+ * series in `orderBy` order out to `maxlag` (BACKLOG-0000873), with the
2605
+ * approximate ±1.96/√n band. A short-series readout; feed the arrays to a bar
2606
+ * chart over explicit points with the band as reference lines. The lag-1
2607
+ * autocorrelation matches `series(...).autocorrelation`.
2608
+ */
2609
+ acf(spec: { of: string; orderBy: string; maxlag?: number }): AcfResult | null;
2558
2610
  /** Spearman's rank correlation, which one outlier cannot drag. */
2559
2611
  spearman(a: string, b: string): number | null;
2560
2612
  /** Kendall's tau-b. Null past 5,000 rows: it is quadratic. */
@@ -2803,6 +2855,26 @@ export type ShadowKind =
2803
2855
  * sketched quantile is never presented as exact.
2804
2856
  */
2805
2857
  | 'rollingQuantile' | 'windowApproximate'
2858
+ /**
2859
+ * Classical seasonal decomposition over a declared `period` (BACKLOG-0000873),
2860
+ * matching `statsmodels.seasonal_decompose`: `tsTrend` is the centred
2861
+ * moving-average trend, `tsSeasonal` the repeating seasonal index, `tsResidual`
2862
+ * what the two leave behind, and `tsCoverage` the stamp (1 for an interior row,
2863
+ * 0 for a partial edge where the centred window runs off the end, so an edge is
2864
+ * never emitted as full). Additive by default; `decomposition: 'multiplicative'`
2865
+ * is a declared option, undefined on a non-positive series.
2866
+ */
2867
+ | 'tsTrend' | 'tsSeasonal' | 'tsResidual' | 'tsCoverage'
2868
+ /**
2869
+ * Exponential smoothing over the `orderBy` series (BACKLOG-0000873):
2870
+ * `tsSmoothed` is the fitted level from single exponential smoothing (`ses`) or
2871
+ * Holt's level+trend (`holt`) — the signal with the noise removed, not a
2872
+ * forecast. The smoothing factor(s) are caller-set or fit by minimising
2873
+ * in-sample SSE, and reported by the `tsSmoothingAlpha` / `tsSmoothingBeta`
2874
+ * companion columns. Holt-Winters (seasonal) smoothing is deferred; seasonality
2875
+ * is covered by decomposition.
2876
+ */
2877
+ | 'tsSmoothed' | 'tsSmoothingAlpha' | 'tsSmoothingBeta'
2806
2878
  /**
2807
2879
  * Model-backed regression shadows (BACKLOG-0000812): the predicted value, the
2808
2880
  * residual, and a Cook's-distance influence flag for the row, read from the
@@ -2886,6 +2958,44 @@ export interface Heteroscedasticity {
2886
2958
  heteroscedastic: boolean;
2887
2959
  }
2888
2960
 
2961
+ /** The Augmented Dickey-Fuller stationarity test result (BACKLOG-0000873). */
2962
+ export interface AdfResult {
2963
+ /** The ADF t-statistic on the lagged level. */
2964
+ statistic: number;
2965
+ /** The number of augmenting lags chosen by AIC. */
2966
+ usedLag: number;
2967
+ /** The observations the final regression used. */
2968
+ nobs: number;
2969
+ /** MacKinnon's constant+trend critical values at the 1%, 5% and 10% levels. */
2970
+ criticalValues: { '1%': number; '5%': number; '10%': number };
2971
+ /** An approximate p-value, interpolated across the critical-value ladder. */
2972
+ pValue: number;
2973
+ /** Always true: the p-value is an interpolation, not the MacKinnon surface. */
2974
+ pApproximate: boolean;
2975
+ /** Whether the series is stationary at the 5% level. */
2976
+ stationary: boolean;
2977
+ /** The plain-language verdict: `'stationary'` or `'non-stationary'`. */
2978
+ verdict: string;
2979
+ /** The regression form used — always `'ct'` (constant + trend) in v1. */
2980
+ regression: 'ct';
2981
+ }
2982
+
2983
+ /** Autocorrelation (ACF) and partial autocorrelation (PACF) arrays (BACKLOG-0000873). */
2984
+ export interface AcfResult {
2985
+ /** The autocorrelation at each lag; index 0 is lag 0 and is always 1. */
2986
+ acf: number[];
2987
+ /** The partial autocorrelation at each lag; index 0 is 1, and `pacf[1] === acf[1]`. */
2988
+ pacf: number[];
2989
+ /** The approximate ±1.96/√n white-noise confidence band. */
2990
+ bounds: { upper: number; lower: number };
2991
+ /** The series length the ACF/PACF were computed over. */
2992
+ n: number;
2993
+ /** The maximum lag. */
2994
+ nlags: number;
2995
+ /** Always true: the ±1.96/√n band is an approximation. */
2996
+ approximate: boolean;
2997
+ }
2998
+
2889
2999
  /** A fitted multi-predictor linear model and its diagnostics (BACKLOG-0000792). */
2890
3000
  export interface RegressionModel {
2891
3001
  method: string;
@@ -3329,6 +3439,8 @@ export type EventName =
3329
3439
  /* Comparison and time */
3330
3440
  | 'diff:changed' | 'diff:swapped'
3331
3441
  | 'timeline:attached' | 'timeline:detached' | 'timeline:seek' | 'timeline:seeking'
3442
+ /* Annotations */
3443
+ | 'annotation:changed'
3332
3444
  /* Export */
3333
3445
  | 'export:progress'
3334
3446
  /* Every event at once, for logging and debugging. */
@@ -3822,10 +3934,47 @@ export interface CaptureOptions {
3822
3934
  * they stay with the cells they annotate when the grid scrolls, and are
3823
3935
  * cleared when a presentation ends.
3824
3936
  */
3937
+ /**
3938
+ * A durable annotation mark descriptor (BACKLOG-0000813) — the shape a host
3939
+ * seeds through `state.annotations`, adds through {@link AnnotationApi.add}, and
3940
+ * reads back through {@link AnnotationApi.list} and `getState`.
3941
+ *
3942
+ * `points` are in **content coordinates** (the same space user-drawn marks are
3943
+ * stored in), so a mark tracks scroll and resize rather than hanging over the
3944
+ * viewport. A `freehand` mark is a trail of points; `arrow` and `rect` are their
3945
+ * two endpoints. A `text` mark is a label anchored at a single content point,
3946
+ * carrying its `text` string and an optional basic style (BACKLOG-0000875).
3947
+ * `pen` is accepted as an alias for `freehand` on input; `list()` reports
3948
+ * `freehand`.
3949
+ */
3950
+ export interface AnnotationMark {
3951
+ type: 'freehand' | 'arrow' | 'rect' | 'highlight' | 'text';
3952
+ /**
3953
+ * Content coordinates. A `text` mark carries a single anchor point; `arrow`
3954
+ * and `rect` carry their two corners, and `freehand` a trail.
3955
+ */
3956
+ points: { x: number; y: number }[];
3957
+ colour?: string;
3958
+ /** The label of a `text` mark. Required for `text`, ignored for other types. */
3959
+ text?: string;
3960
+ /** A `text` mark's font size in content pixels (before presentation scale). Defaults to 14. */
3961
+ fontSize?: number;
3962
+ /** An optional backing colour drawn behind a `text` mark's label. */
3963
+ background?: string;
3964
+ }
3965
+
3825
3966
  export interface AnnotationApi {
3826
3967
  readonly tool: 'pen' | 'arrow' | 'rect' | 'highlight' | null;
3827
3968
  readonly count: number;
3828
3969
  use(tool: 'pen' | 'arrow' | 'rect' | 'highlight' | null, opts?: { colour?: string }): string | null;
3970
+ /**
3971
+ * Add a durable mark from a descriptor, without synthesising pointer input
3972
+ * (BACKLOG-0000813). The mark is painted, survives a presentation ending, and
3973
+ * round-trips through `getState`. Returns the mark count.
3974
+ */
3975
+ add(mark: AnnotationMark): number;
3976
+ /** Every mark on the layer, as descriptors — the shape `getState` persists. */
3977
+ list(): AnnotationMark[];
3829
3978
  undo(): number;
3830
3979
  clear(): void;
3831
3980
  redraw(): void;
@@ -5799,6 +5948,82 @@ declare module 'lattice-grid/modules/angular' {
5799
5948
  export default createLatticeGrid;
5800
5949
  }
5801
5950
 
5951
+ declare module 'lattice-grid/modules/data-router' {
5952
+ /**
5953
+ * A record routed through a data router: any object. Its partition comes from
5954
+ * the router's `key` and its identity within a grid from `rowKey`.
5955
+ */
5956
+ type RouterRecord = Record<string, unknown>;
5957
+
5958
+ /** A per-route diff summary returned by `load`. */
5959
+ interface RouteDiff { added: number; updated: number; removed: number }
5960
+
5961
+ /** A predicate: a property value (`row[key] === value`) or a `fn(row)`. */
5962
+ type RoutePredicate = unknown | ((row: RouterRecord) => boolean);
5963
+
5964
+ /**
5965
+ * A cross-grid selection relation (v2, BACKLOG-0000880): a key map (target
5966
+ * rows whose `to` value is among the selected source rows' `from` values — an
5967
+ * IN set), or a function handed the selected source rows that returns a
5968
+ * target-row predicate.
5969
+ */
5970
+ type SelectionRelation =
5971
+ | { from: string; to: string }
5972
+ | ((selected: RouterRecord[]) => ((row: RouterRecord) => boolean));
5973
+
5974
+ /**
5975
+ * A data router: one arriving stream, partitioned by a property (or composite
5976
+ * predicate), fanned out to a grid per partition (BACKLOG-0000879). Each grid
5977
+ * sees only its slice, updated by keyed diff through the public
5978
+ * `grid.rows.apply` path — no grid-core change, no cross-references between
5979
+ * grids. Snapshots apply keyed diffs (unchanged rows never repaint); deltas add,
5980
+ * update or remove in place by `rowKey`, preserving selection and scroll.
5981
+ */
5982
+ interface DataRouter {
5983
+ /** Attach a grid behind a predicate; `rowKey` overrides the router default. */
5984
+ attach(grid: unknown, predicate: RoutePredicate, opts?: { rowKey?: (string | ((row: RouterRecord) => unknown)) }): DataRouter;
5985
+ /** Attach the "rest" sink for records no explicit route matched. */
5986
+ attachDefault(grid: unknown, opts?: { rowKey?: (string | ((row: RouterRecord) => unknown)) }): DataRouter;
5987
+ /** Detach a grid; the host still owns and destroys it. */
5988
+ detach(grid: unknown): DataRouter;
5989
+ /** Apply a full snapshot as a keyed diff per grid; returns per-route counts. */
5990
+ load(snapshot: RouterRecord[]): RouteDiff[];
5991
+ /** Apply incremental deltas, routed and applied in place by `rowKey`. */
5992
+ apply(deltas: { op: 'upsert' | 'delete'; row: RouterRecord }[]): void;
5993
+ /**
5994
+ * Link a source grid's selection to what a target grid receives (v2,
5995
+ * BACKLOG-0000880): the target shows the subset of its partition the
5996
+ * `relation` admits, re-pushed through the keyed-diff path. No selection
5997
+ * shows the full partition; changes are debounced.
5998
+ */
5999
+ link(source: unknown, target: unknown, relation: SelectionRelation): DataRouter;
6000
+ /** Apply any debounced selection refilter synchronously (for tests/determinism). */
6001
+ flush(): DataRouter;
6002
+ /** How many records matched no route. */
6003
+ readonly unrouted: number;
6004
+ /** Detach every grid and drop every link (the host destroys the grids themselves). */
6005
+ destroy(): void;
6006
+ }
6007
+
6008
+ /**
6009
+ * Create a data router that partitions one stream to many grids.
6010
+ *
6011
+ * `key` is the partition property or `fn(row)`; `rowKey` is the identity within
6012
+ * a grid; `overlap` fans a record to every matching route (default: first match
6013
+ * wins); `onUnrouted` receives records that match none; `selectionDebounce` is
6014
+ * the debounce in ms for cross-grid selection refilters (default 16; `0` is
6015
+ * synchronous).
6016
+ */
6017
+ export function createDataRouter(opts: {
6018
+ key: (string | ((row: RouterRecord) => unknown));
6019
+ rowKey?: (string | ((row: RouterRecord) => unknown));
6020
+ overlap?: boolean;
6021
+ onUnrouted?: (item: unknown) => void;
6022
+ selectionDebounce?: number;
6023
+ }): DataRouter;
6024
+ export default createDataRouter;
6025
+ }
6026
+
5802
6027
  declare module 'lattice-grid/modules/webcomponent' {
5803
6028
  /**
5804
6029
  * Register `<lattice-grid>`.