@toclocoinc/lattice-grid 1.7.1 → 1.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/lattice-grid.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Lattice Grid 1.7.1 — type declarations
2
+ * Lattice Grid 1.9.0 — type declarations
3
3
  * Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
4
4
  * https://latticegrid.dev
5
5
  */
@@ -542,6 +542,37 @@ export interface Column {
542
542
  group?: { enabled?: boolean; index?: number; explode?: boolean } | boolean;
543
543
  pivot?: { enabled?: boolean; index?: number } | boolean;
544
544
  total?: TotalName | TotalFn;
545
+ /**
546
+ * A value the grid maintains about this column's own history, rather than a
547
+ * field in the data. `{of: 'price', kind: 'delta'}`, or the bare kind to
548
+ * shadow the column it sits beside.
549
+ */
550
+ shadow?: ShadowKind | {
551
+ of?: string;
552
+ kind: ShadowKind;
553
+ depth?: number;
554
+ /**
555
+ * For a positional kind, what to rank against. `'all'` (the default) uses
556
+ * every tracked row, so a rank does not move when the grid is filtered;
557
+ * `'filtered'` ranks within what the filters left.
558
+ */
559
+ scope?: 'all' | 'filtered';
560
+ };
561
+ /**
562
+ * A running total down the grid **as it is currently ordered**.
563
+ *
564
+ * The one derived value that depends on the display order: sort differently
565
+ * and every value changes. That is why it is not a shadow kind — every shadow
566
+ * reads the same however the rows are arranged.
567
+ */
568
+ running?: 'total' | 'percent' | { of?: string; kind?: 'total' | 'percent' };
569
+ /**
570
+ * The customer's tolerance, for process capability and control charts.
571
+ * Declared here rather than passed to each call so the capability figures,
572
+ * a control chart and any rule marking an out-of-tolerance cell cannot
573
+ * disagree about what the tolerance is.
574
+ */
575
+ spec?: { lower?: number; upper?: number; target?: number };
545
576
  layout?: ColumnLayoutSpec | number;
546
577
  header?: ColumnHeaderSpec | string;
547
578
  export?: ColumnExportSpec;
@@ -1389,15 +1420,31 @@ export interface StateApplyReport {
1389
1420
  // ---------------------------------------------------------------------------
1390
1421
 
1391
1422
  export interface FormattingCondition {
1392
- op: Operator;
1423
+ /**
1424
+ * A filter operator compared against `value`, or a distribution operator
1425
+ * whose threshold comes from the column itself — `{op: 'topPercent', value: 10}`,
1426
+ * `{op: 'outlier'}`. Distribution thresholds are pinned when the rules
1427
+ * compile; `grid.formatting.restat()` moves them.
1428
+ */
1429
+ op: Operator | DistributionOp;
1393
1430
  value?: unknown;
1394
1431
  value2?: unknown;
1395
1432
  }
1396
1433
 
1397
1434
  export interface FormattingScale {
1398
- min: number;
1399
- max: number;
1435
+ /**
1436
+ * Where the bounds come from when `min` and `max` are not given.
1437
+ * `'minmax'` spans the data, `'quantile'` spans `low` to `high`
1438
+ * (5th to 95th percentile by default), `'stddev'` spans `deviations`
1439
+ * either side of the mean.
1440
+ */
1441
+ from?: 'minmax' | 'quantile' | 'stddev';
1442
+ min?: number;
1443
+ max?: number;
1400
1444
  mid?: number;
1445
+ low?: number;
1446
+ high?: number;
1447
+ deviations?: number;
1401
1448
  colours?: string[];
1402
1449
  }
1403
1450
 
@@ -1421,6 +1468,144 @@ export interface FormattingRule {
1421
1468
  /** A column id, or `'*'` for every column. */
1422
1469
  export type FormattingScope = string;
1423
1470
 
1471
+ export interface StatisticsApi {
1472
+ /** One shadow value for one row, by the column it shadows and the kind. */
1473
+ shadow(colId: string, kind: ShadowKind, rowKey: string, scope?: 'all' | 'filtered'): unknown;
1474
+ /** A running total at one row, down the grid as it is currently ordered. */
1475
+ running(colId: string, kind: 'total' | 'percent', rowKey: string): number | null;
1476
+ /** Make the current values the new baseline — "mark all". */
1477
+ rebase(colId?: string): void;
1478
+ /** What the shadow histories are costing. */
1479
+ tracking(): { columns: string[]; rows: number; forgotten: number };
1480
+ /** Reduce a column by a named kernel over the filtered rows. */
1481
+ reduce(colId: string, fn: string): unknown;
1482
+ /** Everything worth knowing about one column, in one pass each. */
1483
+ profile(colId: string): ColumnProfile | null;
1484
+ /** Pearson's correlation between two columns. */
1485
+ correlation(a: string, b: string): number | null;
1486
+ /** Covariance — a correlation before the scales are divided out. */
1487
+ covariance(a: string, b: string, opts?: { population?: boolean }): number | null;
1488
+ /** Least-squares fit of `b` on `a`: in finance, beta and alpha. */
1489
+ regression(a: string, b: string): RegressionFit | null;
1490
+ /** Spearman's rank correlation, which one outlier cannot drag. */
1491
+ spearman(a: string, b: string): number | null;
1492
+ /** Kendall's tau-b. Null past 5,000 rows: it is quadratic. */
1493
+ kendall(a: string, b: string): number | null;
1494
+ /** A quantile of one column weighted by another; the median by default. */
1495
+ weightedQuantile(colId: string, weightId: string, p?: number): number | null;
1496
+ /**
1497
+ * Process capability against the column's `spec`, with control limits and the
1498
+ * Western Electric rule breaks. `baseline` fixes the limits over the first N
1499
+ * readings, which is how a shift is found rather than hidden by the limits it
1500
+ * widened.
1501
+ */
1502
+ capability(colId: string, opts?: {
1503
+ lower?: number; upper?: number; target?: number; by?: string; baseline?: number;
1504
+ }): ProcessCapability | null;
1505
+ /**
1506
+ * How a column varies along an ordering. `by` is required and never guessed —
1507
+ * kernels see rows in the order they arrived, which is not the grid's sort.
1508
+ */
1509
+ series(colId: string, opts: { by: string; periodsPerYear?: number }): SeriesStats | null;
1510
+ /** A weighted average of one column by another. */
1511
+ weightedAverage(colId: string, weightId: string): number | null;
1512
+ /** The key a row's data resolves to. */
1513
+ keyOf(data: unknown): string | null;
1514
+ /** Which reductions can be maintained against a change, and which rescan. */
1515
+ readonly maintenance: Readonly<Record<string, 'maintained' | 'rescan'>>;
1516
+ }
1517
+
1518
+ export type ShadowKind =
1519
+ | 'updates' | 'updatedAt' | 'sinceUpdate' | 'delta' | 'deltaPercent'
1520
+ | 'rate' | 'history' | 'firstValue' | 'streak'
1521
+ /** Where the row sits among the others, over every tracked row. */
1522
+ | 'rank' | 'rankAsc' | 'rankChange' | 'percentile' | 'quartile'
1523
+ | 'zScore' | 'shareOfTotal';
1524
+
1525
+ export interface RegressionFit {
1526
+ slope: number;
1527
+ intercept: number;
1528
+ /** The square of Pearson's r: how much of the response the fit accounts for. */
1529
+ r2: number;
1530
+ /** Standard error of the slope, which is what says it differs from zero. */
1531
+ stdError: number;
1532
+ /** Pairs that survived pairwise deletion, not rows scanned. */
1533
+ n: number;
1534
+ }
1535
+
1536
+ export interface ProcessCapability {
1537
+ n: number;
1538
+ mean: number;
1539
+ lower: number | null;
1540
+ upper: number | null;
1541
+ target: number | null;
1542
+ /** Short-term variation, from the moving range: what Cp and Cpk use. */
1543
+ sigmaWithin: number | null;
1544
+ /** Overall variation: what Pp and Ppk use. */
1545
+ sigmaOverall: number | null;
1546
+ /** Potential capability. Null for a one-sided specification. */
1547
+ cp: number | null;
1548
+ /** Capability allowing for where the process is centred. */
1549
+ cpk: number | null;
1550
+ /** Cp over the overall spread — what the process actually delivered. */
1551
+ pp: number | null;
1552
+ /** Cpk over the overall spread. Well below Cpk means the process drifted. */
1553
+ ppk: number | null;
1554
+ outOfSpec: number;
1555
+ defectRate: number | null;
1556
+ /** Three sigma either side of the process mean, from the moving range. */
1557
+ limits: { centre: number; upper: number; lower: number; sigma: number } | null;
1558
+ /** How many leading readings set the limits. */
1559
+ baseline?: number;
1560
+ violations: { index: number; rule: number; description: string }[];
1561
+ }
1562
+
1563
+ export interface SeriesStats {
1564
+ n: number;
1565
+ first: number;
1566
+ last: number;
1567
+ change: number;
1568
+ changePercent: number | null;
1569
+ /** Standard deviation of period-on-period returns. */
1570
+ volatility: number | null;
1571
+ /** The same, times the root of `periodsPerYear`; null unless one was given. */
1572
+ annualisedVolatility: number | null;
1573
+ /** Compound growth per period, annualised when `periodsPerYear` is given. */
1574
+ growth: number | null;
1575
+ /** The largest peak-to-trough fall, as a fraction. */
1576
+ maxDrawdown: number | null;
1577
+ maxDrawdownFrom: number;
1578
+ maxDrawdownTo: number;
1579
+ /** Lag-1: positive is momentum, negative is mean reversion. */
1580
+ autocorrelation: number | null;
1581
+ upDays: number;
1582
+ downDays: number;
1583
+ }
1584
+
1585
+ export interface ColumnProfile {
1586
+ column: string;
1587
+ rows: number;
1588
+ present: number;
1589
+ missing: number;
1590
+ distinct: number;
1591
+ min: number | null;
1592
+ max: number | null;
1593
+ mean: number | null;
1594
+ median: number | null;
1595
+ q1: number | null;
1596
+ q3: number | null;
1597
+ iqr: number | null;
1598
+ stddev: number | null;
1599
+ outliers: number;
1600
+ histogram: HistogramBin[];
1601
+ }
1602
+
1603
+ export interface HistogramBin {
1604
+ from: number;
1605
+ to: number;
1606
+ count: number;
1607
+ }
1608
+
1424
1609
  export interface FormattingApi {
1425
1610
  list(scope?: FormattingScope): FormattingRule[];
1426
1611
  all(): Record<FormattingScope, FormattingRule[]>;
@@ -1433,24 +1618,91 @@ export interface FormattingApi {
1433
1618
  replaceAll(rules: Record<FormattingScope, FormattingRule[]>): void;
1434
1619
  clear(scope?: FormattingScope): void;
1435
1620
  styleFor(colId: string, value: unknown): CellStyle | null;
1621
+ /** Re-derive the thresholds of distribution rules from the data as it stands. */
1622
+ restat(): void;
1623
+ /** The five numbers a distribution rule resolves against for one column. */
1624
+ distribution(colId: string): ColumnDistribution | null;
1625
+ }
1626
+
1627
+ /** Operators that resolve against the column's own distribution (spec 8.12). */
1628
+ export type DistributionOp =
1629
+ | 'topPercent' | 'bottomPercent' | 'topN' | 'bottomN'
1630
+ | 'aboveMean' | 'belowMean' | 'aboveMedian' | 'belowMedian'
1631
+ | 'zAbove' | 'zBelow' | 'outlier';
1632
+
1633
+ export interface ColumnDistribution {
1634
+ n: number;
1635
+ min: number;
1636
+ max: number;
1637
+ mean: number;
1638
+ stddev: number;
1639
+ median: number;
1640
+ q1: number;
1641
+ q3: number;
1642
+ iqr: number;
1643
+ sorted: number[];
1436
1644
  }
1437
1645
 
1438
1646
  // ---------------------------------------------------------------------------
1439
1647
  // Events (spec 18.4)
1440
1648
  // ---------------------------------------------------------------------------
1441
1649
 
1650
+ /**
1651
+ * Every event the grid emits.
1652
+ *
1653
+ * Complete, and checked against the runtime by `tools/check.js` — an `emit()`
1654
+ * call with no entry here fails the build. It was not complete before: fifty-one
1655
+ * events were emitted and undeclared, so subscribing to any of them from
1656
+ * TypeScript was a compile error on an event the grid genuinely raises.
1657
+ *
1658
+ * Grouped by the subsystem that raises them, which is also how the reference
1659
+ * lists them.
1660
+ */
1442
1661
  export type EventName =
1443
- | 'ready' | 'destroy' | 'render:first' | 'model:changed' | 'rows:changed' | 'rows:queued'
1662
+ /* Lifecycle */
1663
+ | 'ready' | 'destroy' | 'render:first' | 'render:done' | 'config:changed'
1664
+ | 'licence:changed' | 'environment:changed'
1665
+ /* Data */
1666
+ | 'model:changed' | 'rows:changed' | 'rows:queued' | 'rows:deferred'
1667
+ | 'rows:paused' | 'rows:resumed' | 'row:received' | 'row:sent' | 'row:copied'
1668
+ | 'row:moved' | 'source:error' | 'stream:chunk' | 'stream:end' | 'stream:evicted'
1669
+ /* Cells and editing */
1444
1670
  | 'cell:changed' | 'cell:pending' | 'cell:confirmed' | 'cell:reverted'
1445
1671
  | 'cell:clicked' | 'cell:dblclicked' | 'cell:contextmenu'
1446
1672
  | 'cell:edit:start' | 'cell:edit:end' | 'row:edit:start' | 'row:edit:end'
1447
- | 'row:clicked' | 'row:dblclicked' | 'group:toggled'
1448
- | 'sort:changed' | 'filter:changed'
1673
+ | 'row:clicked' | 'row:dblclicked'
1674
+ | 'form:opened' | 'form:closed' | 'form:saved' | 'form:error'
1675
+ /* Query */
1676
+ | 'sort:changed' | 'filter:changed' | 'group:toggled'
1677
+ | 'facet:computed' | 'facet:filtered' | 'facet:expanded' | 'facet:failed'
1678
+ /* Columns */
1449
1679
  | 'column:moved' | 'column:resized' | 'column:visible' | 'column:pinned'
1450
- | 'column:grouped' | 'column:pivoted'
1451
- | 'selection:changed' | 'range:changed'
1680
+ | 'column:grouped' | 'column:pivoted' | 'column:filter:open' | 'column:menu:open'
1681
+ | 'columns:changed' | 'columns:tagged' | 'header:contextmenu'
1682
+ /* Selection and view */
1683
+ | 'selection:changed' | 'range:changed' | 'clipboard:copy'
1452
1684
  | 'page:changed' | 'scroll' | 'scroll:end' | 'size:changed'
1453
- | 'state:changed' | 'stream:chunk' | 'stream:end' | 'source:error'
1685
+ | 'detail:toggled' | 'toolpanel:focus' | 'highlight:changed'
1686
+ /* Tree data */
1687
+ | 'tree:loading' | 'tree:loaded' | 'tree:loadFailed' | 'tree:loadAborted'
1688
+ /* State, history and views */
1689
+ | 'state:changed' | 'state:reset' | 'history:changed' | 'history:applied'
1690
+ | 'views:changed' | 'view:applied' | 'view:saved' | 'view:removed'
1691
+ | 'view:renamed' | 'view:default'
1692
+ /* Formatting and presentation */
1693
+ | 'formatting:changed' | 'redaction:changed' | 'permissions:changed'
1694
+ | 'presentation:changed' | 'presentation:ended' | 'presentation:view'
1695
+ | 'presentation:scale' | 'presentation:spotlight' | 'presentation:captured'
1696
+ /* Collaboration */
1697
+ | 'comment:added' | 'comment:edited' | 'comment:deleted' | 'comment:failed'
1698
+ | 'comment:threadOpened' | 'comment:threadClosed' | 'comment:indexLoaded'
1699
+ | 'presence:published' | 'presence:left' | 'presence:failed' | 'presence:lockRefused'
1700
+ /* Comparison and time */
1701
+ | 'diff:changed' | 'diff:swapped'
1702
+ | 'timeline:attached' | 'timeline:detached' | 'timeline:seek' | 'timeline:seeking'
1703
+ /* Export */
1704
+ | 'export:progress'
1705
+ /* Every event at once, for logging and debugging. */
1454
1706
  | '*';
1455
1707
 
1456
1708
  export interface GridEvent {
@@ -1568,6 +1820,10 @@ export interface RowsApi {
1568
1820
  }
1569
1821
 
1570
1822
  export interface ColumnsApi {
1823
+ /** Set or clear a column's totals-row reduction. */
1824
+ setTotal(id: string, fn: TotalName | TotalFn | null): void;
1825
+ /** Every distinct value in a column, from the dictionary where there is one. */
1826
+ distinct(id: string): unknown[];
1571
1827
  get(id: string): ResolvedColumn | undefined;
1572
1828
  all(): ResolvedColumn[];
1573
1829
  visible(): ResolvedColumn[];
@@ -1618,6 +1874,15 @@ export interface DetailApi {
1618
1874
  }
1619
1875
 
1620
1876
  export interface SelectionApi {
1877
+ /** Drop every range, leaving the row and cell selection alone. */
1878
+ clearRange(): void;
1879
+ /**
1880
+ * Everything worth knowing about the selected cells — what `summary()`
1881
+ * reports plus median, quartiles, deviation, distinct and outliers. Over the
1882
+ * cells rather than a column, so a rectangle spanning three columns is one
1883
+ * set of numbers. Null with nothing selected.
1884
+ */
1885
+ statistics(): object | null;
1621
1886
  rows(): Row[];
1622
1887
  keys(): string[];
1623
1888
  set(keys: string[]): void;
@@ -1641,6 +1906,8 @@ export interface CellRange {
1641
1906
  }
1642
1907
 
1643
1908
  export interface FiltersApi {
1909
+ /** The quick filter's text and match mode, for restoring a control. */
1910
+ quickState(): { text: string; mode: string };
1644
1911
  get(): FilterSet;
1645
1912
  set(filters: FilterSet): void;
1646
1913
  clear(): void;
@@ -1681,6 +1948,8 @@ export interface ScrollApi {
1681
1948
  }
1682
1949
 
1683
1950
  export interface ExportApi {
1951
+ /** The selected range as tab-separated text, the shape a spreadsheet pastes. */
1952
+ rangeText(opts?: object): string;
1684
1953
  csv(opts?: CsvExportOptions): string | Promise<Blob>;
1685
1954
  excel(opts?: ExcelExportOptions): Promise<Blob>;
1686
1955
  clipboard(opts?: ClipboardOptions): Promise<void>;
@@ -2236,6 +2505,8 @@ export interface ViewsApi {
2236
2505
  }
2237
2506
 
2238
2507
  export interface DiffApi {
2508
+ /** Exchange the baseline and the current rows. Returns false with nothing to swap. */
2509
+ swap(): boolean;
2239
2510
  readonly enabled: boolean;
2240
2511
  /** Set the baseline every row is compared against. */
2241
2512
  setSnapshot(rows: unknown[] | null): void;
@@ -2430,6 +2701,7 @@ export interface Grid {
2430
2701
  readonly comments: CommentsApi;
2431
2702
  readonly presence: PresenceApi;
2432
2703
  readonly diagnostics: DiagnosticsApi;
2704
+ readonly statistics: StatisticsApi;
2433
2705
  readonly formatting: FormattingApi;
2434
2706
  readonly maximise?: MaximiseApi;
2435
2707
  /**
@@ -2553,3 +2825,252 @@ export function formatList(items: string[], locale?: string, type?: 'conjunction
2553
2825
  export function resolveLocale(configured: string | undefined, declared?: string, fallback?: string): string;
2554
2826
  /** Find the catalogue for a tag, falling back to the base language. */
2555
2827
  export function resolveCatalogue(tag?: string): Record<string, unknown> | null;
2828
+
2829
+ // ---------------------------------------------------------------------------
2830
+ // The optional modules (spec 20)
2831
+ // ---------------------------------------------------------------------------
2832
+
2833
+ /**
2834
+ * Declarations for everything under `lattice-grid/modules/`.
2835
+ *
2836
+ * The package exports these subpaths at runtime but declared none of them, so a
2837
+ * TypeScript caller importing the React adapter — or any other module — got an
2838
+ * implicit `any` and, under `strict`, an error. The grid advertises complete
2839
+ * declarations; these are the rest of them.
2840
+ *
2841
+ * Each module is declared where its subpath resolves. The `./modules/*` export
2842
+ * carries a `types` condition pointing back at this file, which is what lets
2843
+ * these blocks be found at all.
2844
+ */
2845
+
2846
+ /** One of the thirty chart types `createChart` accepts. */
2847
+ export type ChartType =
2848
+ | 'line' | 'step' | 'area' | 'rangeArea'
2849
+ | 'bar' | 'horizontalBar' | 'waterfall'
2850
+ | 'scatter' | 'bubble'
2851
+ | 'combo' | 'pareto'
2852
+ | 'histogram' | 'boxplot' | 'heatmap'
2853
+ | 'pie' | 'donut' | 'sunburst' | 'treemap'
2854
+ | 'radar' | 'gauge' | 'funnel' | 'candlestick' | 'geomap'
2855
+ | 'sankey' | 'chord' | 'network' | 'stream' | 'marimekko' | 'violin' | 'gantt';
2856
+
2857
+ /** A measure a chart reduces, when the chart is not given a bare `y`. */
2858
+ export interface ChartMeasure {
2859
+ col: string;
2860
+ /** A reduction name, as the totals row uses. */
2861
+ fn?: TotalName;
2862
+ /** The mark this measure draws with, on a combo chart. */
2863
+ type?: 'bar' | 'line' | 'area';
2864
+ /** Which axis it belongs to, on a combo chart. */
2865
+ axis?: 'left' | 'right';
2866
+ title?: string;
2867
+ }
2868
+
2869
+ /** Data labels beside each mark. */
2870
+ export interface ChartLabels {
2871
+ position?: 'outside' | 'inside' | 'auto';
2872
+ /** A format mask, or a function of the value. */
2873
+ format?: string | ((value: unknown, point?: unknown) => string);
2874
+ /** Pixels two labels must leave between them before both are kept. */
2875
+ minGap?: number;
2876
+ }
2877
+
2878
+ /**
2879
+ * What a chart draws and how.
2880
+ *
2881
+ * `grid` and `container` are required; everything else describes the chart.
2882
+ * A chart reads the grid's *filtered* rows, so it follows the grid without
2883
+ * being told to.
2884
+ */
2885
+ export interface ChartSpec {
2886
+ grid: Grid;
2887
+ container: Element | string;
2888
+ type: ChartType;
2889
+ /** The category column. */
2890
+ x?: string;
2891
+ /** The measure column, for the types that take one. */
2892
+ y?: string;
2893
+ /** Splits the measure into one series per distinct value. */
2894
+ series?: string;
2895
+ /** Several measures at once, for combo and candlestick. */
2896
+ measures?: ChartMeasure[];
2897
+ /** Endpoints, for sankey, chord and network. */
2898
+ source?: string;
2899
+ target?: string;
2900
+ /** Row label and dates, for gantt. */
2901
+ label?: string;
2902
+ start?: string;
2903
+ end?: string;
2904
+ title?: string;
2905
+ /** A named scheme, or an array of colours. */
2906
+ scheme?: string | string[];
2907
+ legend?: boolean | { position?: 'top' | 'bottom' | 'left' | 'right'; isolate?: boolean };
2908
+ labels?: boolean | ChartLabels;
2909
+ axis?: object;
2910
+ font?: object;
2911
+ margin?: number | { top?: number; right?: number; bottom?: number; left?: number };
2912
+ /** Horizontal reference lines. */
2913
+ reference?: { value: number; label?: string }[];
2914
+ /** Bins for a histogram; the default is twelve. */
2915
+ buckets?: number;
2916
+ /** A diverging colour ramp, for heatmap and geomap. */
2917
+ diverging?: boolean;
2918
+ /** Country outlines, for a geomap drawing countries rather than continents. */
2919
+ shapes?: unknown;
2920
+ codeProperty?: string;
2921
+ /** One chart per distinct value of this column. */
2922
+ multiples?: string;
2923
+ /** Draw to canvas past this many points. */
2924
+ canvas?: boolean | number;
2925
+ downsample?: number;
2926
+ emptyText?: string;
2927
+ }
2928
+
2929
+ /**
2930
+ * The events a chart raises.
2931
+ *
2932
+ * A chart's own, not the grid's: `grid.on` takes {@link EventName} and knows
2933
+ * nothing about these. `point:click` is the one most callers want — it is how a
2934
+ * click on a mark becomes a filter on the grid.
2935
+ */
2936
+ export type ChartEventName =
2937
+ | 'click' | 'hover' | 'leave' | 'focus'
2938
+ | 'draw' | 'drill' | 'brush' | 'legend';
2939
+
2940
+ /** A live chart. */
2941
+ export interface Chart {
2942
+ readonly element: SVGElement;
2943
+ /** Redraw now. */
2944
+ draw(): void;
2945
+ /** Change the spec and redraw; unnamed keys keep their values. */
2946
+ update(spec: Partial<ChartSpec>): void;
2947
+ /** The data the chart last bound. */
2948
+ data(): object | null;
2949
+ /** Go up one level, on a drillable hierarchy. */
2950
+ ascend(levels?: number): void;
2951
+ on(event: ChartEventName, handler: (payload: unknown) => void): () => void;
2952
+ emit(event: ChartEventName, payload?: unknown): void;
2953
+ toSVG(opts?: object): string;
2954
+ toPNG(opts?: { scale?: number; background?: string }): Promise<Blob>;
2955
+ toCSV(): string;
2956
+ destroy(): void;
2957
+ }
2958
+
2959
+ declare module 'lattice-grid/modules/charts' {
2960
+ /** Every type name `createChart` accepts. */
2961
+ export const TYPES: readonly ChartType[];
2962
+ /** The built-in colour schemes, by name. */
2963
+ export const SCHEMES: Readonly<Record<string, readonly string[]>>;
2964
+ export const PALETTE: readonly string[];
2965
+ export function createChart(spec: ChartSpec): Chart;
2966
+ export function registerScheme(name: string, colours: readonly string[]): void;
2967
+ export function resolveScheme(spec?: object): object;
2968
+ export function schemeNames(): string[];
2969
+ export function setDefaultScheme(name: string): void;
2970
+ export { Chart };
2971
+ }
2972
+
2973
+ declare module 'lattice-grid/modules/react' {
2974
+ /**
2975
+ * Build the React component.
2976
+ *
2977
+ * A factory rather than a component, because the adapter imports neither
2978
+ * React nor the grid — you pass both in. That is what keeps the package's
2979
+ * promise of no runtime dependencies, and what stops an adapter disagreeing
2980
+ * with the grid version already loaded.
2981
+ */
2982
+ export function createLatticeGrid(deps: { React: unknown; createGrid: unknown }): unknown;
2983
+ /** Every grid event, as the prop name a React caller writes. */
2984
+ export const EVENT_NAMES: readonly string[];
2985
+ export function handlerName(event: string): string;
2986
+ export default createLatticeGrid;
2987
+ }
2988
+
2989
+ declare module 'lattice-grid/modules/vue' {
2990
+ export function createLatticeGrid(deps: { Vue?: unknown; createGrid: unknown }): unknown;
2991
+ export const EVENT_NAMES: readonly string[];
2992
+ export function dashedName(event: string): string;
2993
+ export default createLatticeGrid;
2994
+ }
2995
+
2996
+ declare module 'lattice-grid/modules/svelte' {
2997
+ /** A Svelte action: `use:lattice={config}`. */
2998
+ export function createLatticeAction(deps: { createGrid: unknown }): unknown;
2999
+ export const EVENT_NAMES: readonly string[];
3000
+ export function dashedName(event: string): string;
3001
+ export default createLatticeAction;
3002
+ }
3003
+
3004
+ declare module 'lattice-grid/modules/webcomponent' {
3005
+ /**
3006
+ * Register `<lattice-grid>`.
3007
+ *
3008
+ * This module carries the grid inside it. Use it *or* `createGrid` in one
3009
+ * page, never both: two copies keep separate registries, and a renderer
3010
+ * registered through one will not appear in the other.
3011
+ */
3012
+ export function defineLatticeGrid(tag?: string): void;
3013
+ export function createLatticeGridElement(deps?: object): unknown;
3014
+ export const TAG_NAME: string;
3015
+ export const EVENT_PREFIX: string;
3016
+ export const ATTRIBUTE_CONFIG: Readonly<Record<string, unknown>>;
3017
+ export function observedAttributeNames(): string[];
3018
+ export function domEventName(event: string): string;
3019
+ export class GridElementController {}
3020
+ export default defineLatticeGrid;
3021
+ }
3022
+
3023
+ declare module 'lattice-grid/modules/htmx' {
3024
+ /**
3025
+ * The htmx integration, which re-exports the base API alongside its own —
3026
+ * a page using it imports this and never the base package as well.
3027
+ */
3028
+ export function createGrid(element: Element, config: GridConfig): Grid;
3029
+ export function autoInit(root?: ParentNode): Grid[];
3030
+ export function attach(element: Element, config?: GridConfig): Grid;
3031
+ export function initWithin(root: ParentNode): Grid[];
3032
+ export function destroyWithin(root: ParentNode): void;
3033
+ export function gridElementsWithin(root: ParentNode): Element[];
3034
+ export function hydrateTable(table: Element, config?: GridConfig): Grid;
3035
+ export function readTable(table: Element): { columns: Column[]; rows: unknown[] };
3036
+ export function rowsFromFragment(fragment: ParentNode): unknown[];
3037
+ export function rowsFromJson(text: string): unknown[];
3038
+ export function ingestResponse(grid: Grid, response: unknown): void;
3039
+ export function driveServerMode(grid: Grid, opts?: object): () => void;
3040
+ export function driveInfiniteScroll(grid: Grid, opts?: object): () => void;
3041
+ export function driveOobUpdates(grid: Grid, opts?: object): () => void;
3042
+ export function serialiseState(grid: Grid): string;
3043
+ export function restoreState(grid: Grid, state: string): void;
3044
+ export function saveStateWithin(root: ParentNode): void;
3045
+ export function restoreStateWithin(root: ParentNode): void;
3046
+ export function queryParams(grid: Grid): Record<string, string>;
3047
+ export function warnIfLargeHtmlPayload(rows: number): void;
3048
+ export const QUERY_CHANGED_EVENT: string;
3049
+ export const SCROLL_NEAR_END_EVENT: string;
3050
+ export const HTML_ROW_WARNING_THRESHOLD: number;
3051
+ }
3052
+
3053
+ declare module 'lattice-grid/modules/dhtmlx-compat' {
3054
+ /** A dhtmlx Grid-shaped API over Lattice, for migrating a piece at a time. */
3055
+ export class Grid {
3056
+ constructor(container: Element | string, config?: object);
3057
+ }
3058
+ export default Grid;
3059
+ }
3060
+
3061
+ declare module 'lattice-grid/modules/devtools' {
3062
+ /**
3063
+ * The devtools panel, including the accessibility checks.
3064
+ *
3065
+ * The grid is handed in rather than imported: a module may depend on nothing
3066
+ * in core, or the bundler inlines the whole grid into it.
3067
+ */
3068
+ export function createDevtools(opts: { grid: Grid; container?: Element }): {
3069
+ element: Element;
3070
+ refresh(): void;
3071
+ destroy(): void;
3072
+ };
3073
+ export function expose(grid: Grid, name?: string): void;
3074
+ export const CONSOLE_ACTIVATION: string;
3075
+ export default createDevtools;
3076
+ }