@arcfusionz/arc-analytic-ui 0.0.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/_virtual/_rolldown/runtime.js +13 -0
- package/dist/components/AnomalyCard/AnomalyCard.chart.d.ts +64 -0
- package/dist/components/AnomalyCard/AnomalyCard.chart.js +341 -0
- package/dist/components/AnomalyCard/AnomalyCard.d.ts +169 -0
- package/dist/components/AnomalyCard/AnomalyCard.js +1019 -0
- package/dist/components/AnomalyCard/AnomalyCard.model.d.ts +508 -0
- package/dist/components/AnomalyCard/AnomalyCard.model.js +553 -0
- package/dist/components/AnomalyCard/index.d.ts +4 -0
- package/dist/components/AnomalyCard/index.js +4 -0
- package/dist/components/ChartCard/ChartCard.chart.d.ts +72 -0
- package/dist/components/ChartCard/ChartCard.chart.js +1333 -0
- package/dist/components/ChartCard/ChartCard.d.ts +206 -0
- package/dist/components/ChartCard/ChartCard.js +718 -0
- package/dist/components/ChartCard/ChartCard.model.d.ts +452 -0
- package/dist/components/ChartCard/ChartCard.model.js +1223 -0
- package/dist/components/ChartCard/index.d.ts +4 -0
- package/dist/components/ChartCard/index.js +4 -0
- package/dist/components/ComparisonCard/ComparisonCard.chart.d.ts +80 -0
- package/dist/components/ComparisonCard/ComparisonCard.chart.js +337 -0
- package/dist/components/ComparisonCard/ComparisonCard.d.ts +200 -0
- package/dist/components/ComparisonCard/ComparisonCard.js +1325 -0
- package/dist/components/ComparisonCard/ComparisonCard.model.d.ts +309 -0
- package/dist/components/ComparisonCard/ComparisonCard.model.js +263 -0
- package/dist/components/ComparisonCard/index.d.ts +4 -0
- package/dist/components/ComparisonCard/index.js +4 -0
- package/dist/components/ForecastCard/ForecastCard.chart.d.ts +82 -0
- package/dist/components/ForecastCard/ForecastCard.chart.js +416 -0
- package/dist/components/ForecastCard/ForecastCard.d.ts +148 -0
- package/dist/components/ForecastCard/ForecastCard.js +1029 -0
- package/dist/components/ForecastCard/ForecastCard.model.d.ts +497 -0
- package/dist/components/ForecastCard/ForecastCard.model.js +554 -0
- package/dist/components/ForecastCard/index.d.ts +4 -0
- package/dist/components/ForecastCard/index.js +4 -0
- package/dist/components/HighlightCard/HighlightCard.chart.d.ts +122 -0
- package/dist/components/HighlightCard/HighlightCard.chart.js +660 -0
- package/dist/components/HighlightCard/HighlightCard.d.ts +202 -0
- package/dist/components/HighlightCard/HighlightCard.js +1286 -0
- package/dist/components/HighlightCard/HighlightCard.model.d.ts +692 -0
- package/dist/components/HighlightCard/HighlightCard.model.js +875 -0
- package/dist/components/HighlightCard/index.d.ts +4 -0
- package/dist/components/HighlightCard/index.js +4 -0
- package/dist/components/InsightCard/InsightCard.chart.d.ts +91 -0
- package/dist/components/InsightCard/InsightCard.chart.js +471 -0
- package/dist/components/InsightCard/InsightCard.d.ts +161 -0
- package/dist/components/InsightCard/InsightCard.js +961 -0
- package/dist/components/InsightCard/InsightCard.model.d.ts +405 -0
- package/dist/components/InsightCard/InsightCard.model.js +421 -0
- package/dist/components/InsightCard/index.d.ts +4 -0
- package/dist/components/InsightCard/index.js +4 -0
- package/dist/components/MetricCard/MetricCard.chart.d.ts +79 -0
- package/dist/components/MetricCard/MetricCard.chart.js +435 -0
- package/dist/components/MetricCard/MetricCard.d.ts +227 -0
- package/dist/components/MetricCard/MetricCard.js +1293 -0
- package/dist/components/MetricCard/MetricCard.model.d.ts +521 -0
- package/dist/components/MetricCard/MetricCard.model.js +627 -0
- package/dist/components/MetricCard/index.d.ts +4 -0
- package/dist/components/MetricCard/index.js +4 -0
- package/dist/components/ProfileCard/ProfileCard.chart.d.ts +64 -0
- package/dist/components/ProfileCard/ProfileCard.chart.js +427 -0
- package/dist/components/ProfileCard/ProfileCard.d.ts +140 -0
- package/dist/components/ProfileCard/ProfileCard.js +735 -0
- package/dist/components/ProfileCard/ProfileCard.model.d.ts +279 -0
- package/dist/components/ProfileCard/ProfileCard.model.js +244 -0
- package/dist/components/ProfileCard/index.d.ts +4 -0
- package/dist/components/ProfileCard/index.js +4 -0
- package/dist/components/ProgressCard/ProgressCard.chart.d.ts +73 -0
- package/dist/components/ProgressCard/ProgressCard.chart.js +373 -0
- package/dist/components/ProgressCard/ProgressCard.d.ts +137 -0
- package/dist/components/ProgressCard/ProgressCard.js +908 -0
- package/dist/components/ProgressCard/ProgressCard.model.d.ts +385 -0
- package/dist/components/ProgressCard/ProgressCard.model.js +389 -0
- package/dist/components/ProgressCard/index.d.ts +4 -0
- package/dist/components/ProgressCard/index.js +4 -0
- package/dist/components/ReportCard/ReportCard.chart.d.ts +45 -0
- package/dist/components/ReportCard/ReportCard.chart.js +231 -0
- package/dist/components/ReportCard/ReportCard.d.ts +153 -0
- package/dist/components/ReportCard/ReportCard.js +1118 -0
- package/dist/components/ReportCard/ReportCard.model.d.ts +392 -0
- package/dist/components/ReportCard/ReportCard.model.js +399 -0
- package/dist/components/ReportCard/index.d.ts +4 -0
- package/dist/components/ReportCard/index.js +4 -0
- package/dist/components/SankeyCard/SankeyCard.chart.d.ts +75 -0
- package/dist/components/SankeyCard/SankeyCard.chart.js +249 -0
- package/dist/components/SankeyCard/SankeyCard.d.ts +185 -0
- package/dist/components/SankeyCard/SankeyCard.js +788 -0
- package/dist/components/SankeyCard/SankeyCard.model.d.ts +501 -0
- package/dist/components/SankeyCard/SankeyCard.model.js +789 -0
- package/dist/components/SankeyCard/index.d.ts +4 -0
- package/dist/components/SankeyCard/index.js +4 -0
- package/dist/components/StatusCard/StatusCard.chart.d.ts +60 -0
- package/dist/components/StatusCard/StatusCard.chart.js +188 -0
- package/dist/components/StatusCard/StatusCard.d.ts +176 -0
- package/dist/components/StatusCard/StatusCard.js +989 -0
- package/dist/components/StatusCard/StatusCard.model.d.ts +555 -0
- package/dist/components/StatusCard/StatusCard.model.js +776 -0
- package/dist/components/StatusCard/index.d.ts +4 -0
- package/dist/components/StatusCard/index.js +4 -0
- package/dist/components/TableCard/TableCard.chart.d.ts +53 -0
- package/dist/components/TableCard/TableCard.chart.js +192 -0
- package/dist/components/TableCard/TableCard.d.ts +140 -0
- package/dist/components/TableCard/TableCard.js +811 -0
- package/dist/components/TableCard/TableCard.model.d.ts +381 -0
- package/dist/components/TableCard/TableCard.model.js +475 -0
- package/dist/components/TableCard/index.d.ts +4 -0
- package/dist/components/TableCard/index.js +4 -0
- package/dist/components/TargetCard/TargetCard.chart.d.ts +52 -0
- package/dist/components/TargetCard/TargetCard.chart.js +273 -0
- package/dist/components/TargetCard/TargetCard.d.ts +143 -0
- package/dist/components/TargetCard/TargetCard.js +910 -0
- package/dist/components/TargetCard/TargetCard.model.d.ts +468 -0
- package/dist/components/TargetCard/TargetCard.model.js +581 -0
- package/dist/components/TargetCard/index.d.ts +4 -0
- package/dist/components/TargetCard/index.js +4 -0
- package/dist/components/TreeCard/TreeCard.chart.d.ts +80 -0
- package/dist/components/TreeCard/TreeCard.chart.js +178 -0
- package/dist/components/TreeCard/TreeCard.d.ts +182 -0
- package/dist/components/TreeCard/TreeCard.js +1187 -0
- package/dist/components/TreeCard/TreeCard.model.d.ts +330 -0
- package/dist/components/TreeCard/TreeCard.model.js +401 -0
- package/dist/components/TreeCard/index.d.ts +4 -0
- package/dist/components/TreeCard/index.js +4 -0
- package/dist/components/TrendCard/TrendCard.chart.d.ts +75 -0
- package/dist/components/TrendCard/TrendCard.chart.js +393 -0
- package/dist/components/TrendCard/TrendCard.d.ts +224 -0
- package/dist/components/TrendCard/TrendCard.js +1053 -0
- package/dist/components/TrendCard/TrendCard.model.d.ts +545 -0
- package/dist/components/TrendCard/TrendCard.model.js +623 -0
- package/dist/components/TrendCard/index.d.ts +4 -0
- package/dist/components/TrendCard/index.js +4 -0
- package/dist/index.d.ts +76 -0
- package/dist/index.js +57 -0
- package/dist/lib/vega/ArcVegaChart.d.ts +24 -0
- package/dist/lib/vega/ArcVegaChart.js +42 -0
- package/dist/lib/vega/ArcVegaSurface.d.ts +13 -0
- package/dist/lib/vega/ArcVegaSurface.js +38 -0
- package/dist/lib/vega/axisTicks.js +156 -0
- package/dist/lib/vega/config.d.ts +29 -0
- package/dist/lib/vega/config.js +113 -0
- package/dist/lib/vega/embed.d.ts +29 -0
- package/dist/lib/vega/embed.js +29 -0
- package/dist/lib/vega/engine.d.ts +10 -0
- package/dist/lib/vega/engine.js +6 -0
- package/dist/lib/vega/formatters.d.ts +125 -0
- package/dist/lib/vega/formatters.js +277 -0
- package/dist/lib/vega/index.d.ts +11 -0
- package/dist/lib/vega/load.d.ts +13 -0
- package/dist/lib/vega/load.js +21 -0
- package/dist/lib/vega/time.d.ts +45 -0
- package/dist/lib/vega/time.js +105 -0
- package/dist/lib/vega/tokens.d.ts +73 -0
- package/dist/lib/vega/tokens.js +137 -0
- package/dist/lib/vega/tooltip.d.ts +45 -0
- package/dist/lib/vega/tooltip.js +124 -0
- package/dist/lib/vega/useArcVega.d.ts +43 -0
- package/dist/lib/vega/useArcVega.js +121 -0
- package/package.json +60 -0
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
import { ArcDeltaDirection, ArcDeltaMode, ArcTimeGranularity } from "../../lib/vega/formatters.js";
|
|
2
|
+
//#region src/components/TableCard/TableCard.model.d.ts
|
|
3
|
+
/** What the consumer's transport reports. */
|
|
4
|
+
type TableCardStatus = "loading" | "ready" | "error";
|
|
5
|
+
/**
|
|
6
|
+
* What the card actually shows, derived from `status`, the rows and
|
|
7
|
+
* `filtered`. Stamped on the root as `data-state`.
|
|
8
|
+
*/
|
|
9
|
+
type TableCardState = "loading" | "refreshing" | "ready" | "empty" | "no-match" | "error";
|
|
10
|
+
type TableCardSortDirection = "asc" | "desc";
|
|
11
|
+
/** The active column order. `field` is the column's `id` (which defaults to its `field`); `direction` is which end leads. */
|
|
12
|
+
interface TableCardSort {
|
|
13
|
+
field: string;
|
|
14
|
+
direction: TableCardSortDirection;
|
|
15
|
+
}
|
|
16
|
+
/** Which way is good for a change: revenue up, cost per acquisition down, headcount neutral. */
|
|
17
|
+
type TableCardGoodDirection = "up" | "down" | "none";
|
|
18
|
+
/** How a delta reads once `goodDirection` is applied. */
|
|
19
|
+
type TableCardPolarity = "positive" | "negative" | "neutral";
|
|
20
|
+
/** Cell alignment. Numbers align to their end so digits line up; names read from the start. */
|
|
21
|
+
type TableCardAlign = "start" | "end";
|
|
22
|
+
/**
|
|
23
|
+
* What a column encodes. `text` is identity, `number` is the exact reading,
|
|
24
|
+
* `bar` adds magnitude on the column's own shared scale, `delta` is the
|
|
25
|
+
* change against a baseline, `trend` is the shape over time, `badge` is a
|
|
26
|
+
* category.
|
|
27
|
+
*/
|
|
28
|
+
type TableCardColumnKind = "text" | "number" | "bar" | "delta" | "trend" | "badge";
|
|
29
|
+
/** A footer total. `sum` only for additive measures — a rate, a ratio or an average must never be summed. */
|
|
30
|
+
type TableCardTotal = "sum" | "mean" | "max" | "min";
|
|
31
|
+
/** A badge cell's meaning. `neutral` is the default because a category is not good or bad. */
|
|
32
|
+
type TableCardTone = "neutral" | "positive" | "negative" | "warning" | "info";
|
|
33
|
+
/** How a trend cell draws. A line may crop; an area and bars keep a zero baseline. */
|
|
34
|
+
type TableCardTrendMark = "line" | "area" | "bar";
|
|
35
|
+
type TableCardSize = "sm" | "md" | "lg";
|
|
36
|
+
/** One reading of a trend cell's series. `x` labels it in the tooltip; omit it and the index is used. */
|
|
37
|
+
interface TableCardTrendPoint {
|
|
38
|
+
x: string | number;
|
|
39
|
+
y: number | null;
|
|
40
|
+
}
|
|
41
|
+
/** A row: field values by column `field`, plus whatever else the consumer carries. */
|
|
42
|
+
type TableCardRow = Readonly<Record<string, unknown>>;
|
|
43
|
+
interface TableCardColumnShared {
|
|
44
|
+
/** The field each row is read at. */
|
|
45
|
+
field: string;
|
|
46
|
+
/**
|
|
47
|
+
* The column's identity — what `sort` names, what `data-column` stamps, and
|
|
48
|
+
* the key its cell is filed under. Defaults to `field`, and only needs
|
|
49
|
+
* setting when two columns read the same field: a value beside its own bar,
|
|
50
|
+
* or a reading beside the change in it.
|
|
51
|
+
*/
|
|
52
|
+
id?: string;
|
|
53
|
+
/** Column heading — plain text, so it can name the sort control, the footer cell and the generated description. */
|
|
54
|
+
header: string;
|
|
55
|
+
/** Unit or qualifier shown muted beside the heading (`THB`, `per day`, `7d`). */
|
|
56
|
+
unit?: string;
|
|
57
|
+
/** Cell alignment. Default: `start` for `text` and `badge`, `end` for `number`, `bar` and `delta`, `start` for `trend`. */
|
|
58
|
+
align?: TableCardAlign;
|
|
59
|
+
/** Offer this column's order. Default `true`; a `trend` column sorts by the change across its series. */
|
|
60
|
+
sortable?: boolean;
|
|
61
|
+
/** Column width as a CSS length — obeyed because the table lays out `fixed`. */
|
|
62
|
+
width?: string;
|
|
63
|
+
/** Drop this column when the card is narrower than this many pixels — the responsive degradation ladder. */
|
|
64
|
+
hideBelow?: number;
|
|
65
|
+
/**
|
|
66
|
+
* Footer aggregate for this column. Omitted means no footer cell, which is
|
|
67
|
+
* the default: only the consumer knows whether a measure is additive, and a
|
|
68
|
+
* summed rate is a lie (rule 14 — totals reconcile with parts).
|
|
69
|
+
*/
|
|
70
|
+
total?: TableCardTotal;
|
|
71
|
+
/** What the column means, shown in a tooltip behind an info control in the heading and read as that control's description. */
|
|
72
|
+
hint?: string;
|
|
73
|
+
}
|
|
74
|
+
interface TableCardTextColumn extends TableCardColumnShared {
|
|
75
|
+
kind: "text";
|
|
76
|
+
/** Secondary field rendered muted under the label — an id, a channel, a parent. */
|
|
77
|
+
captionField?: string;
|
|
78
|
+
}
|
|
79
|
+
interface TableCardNumberColumn extends TableCardColumnShared {
|
|
80
|
+
kind: "number";
|
|
81
|
+
/** `arcNumber` grammar (`compact`, `percent:1`, `currency:THB:compact`). Default `number`. */
|
|
82
|
+
format?: string;
|
|
83
|
+
}
|
|
84
|
+
interface TableCardBarColumn extends TableCardColumnShared {
|
|
85
|
+
kind: "bar";
|
|
86
|
+
/** `arcNumber` grammar for the number beside the bar. Default `compact`. */
|
|
87
|
+
format?: string;
|
|
88
|
+
/**
|
|
89
|
+
* Upper bound of the column's shared length scale: `max` (default) makes the
|
|
90
|
+
* largest row a full bar so rows are comparable down the column, `total`
|
|
91
|
+
* makes each bar that row's share of the column sum, and a number pins the
|
|
92
|
+
* scale so the same column is comparable across cards. Bars always start at
|
|
93
|
+
* zero (Wilke's proportional ink).
|
|
94
|
+
*/
|
|
95
|
+
domain?: number | "max" | "total";
|
|
96
|
+
/** Show the formatted number beside the bar. Default `true` — a bar alone is not a value. */
|
|
97
|
+
showValue?: boolean;
|
|
98
|
+
}
|
|
99
|
+
interface TableCardDeltaColumn extends TableCardColumnShared {
|
|
100
|
+
kind: "delta";
|
|
101
|
+
/** `arcNumber` grammar of the underlying measure — it decides whether an absolute delta reads in units or percentage points. Default `number`. */
|
|
102
|
+
format?: string;
|
|
103
|
+
/**
|
|
104
|
+
* Field holding the earlier reading. With it, `field` is the current reading
|
|
105
|
+
* and the change is computed; without it, `field` is read as an
|
|
106
|
+
* already-computed relative change (`0.124` → `+12.4%`).
|
|
107
|
+
*/
|
|
108
|
+
previousField?: string;
|
|
109
|
+
/** Relative (`percent`, default) or in the measure's own units (`absolute`). */
|
|
110
|
+
mode?: ArcDeltaMode;
|
|
111
|
+
/** Which direction is good, so the cell can colour the change. Default `up`. */
|
|
112
|
+
goodDirection?: TableCardGoodDirection;
|
|
113
|
+
}
|
|
114
|
+
interface TableCardTrendColumn extends TableCardColumnShared {
|
|
115
|
+
kind: "trend";
|
|
116
|
+
/** `arcNumber` grammar for the readings in the tooltip and the cell's sentence. Default `compact`. */
|
|
117
|
+
format?: string;
|
|
118
|
+
/** Default `line`. An `area` or `bar` keeps a zero baseline whatever the readings do. */
|
|
119
|
+
mark?: TableCardTrendMark;
|
|
120
|
+
/** `arcTime` granularity for a temporal `x` in the tooltip. Omit for index or category x. */
|
|
121
|
+
granularity?: ArcTimeGranularity;
|
|
122
|
+
}
|
|
123
|
+
interface TableCardBadgeColumn extends TableCardColumnShared {
|
|
124
|
+
kind: "badge";
|
|
125
|
+
/**
|
|
126
|
+
* Tone per value — the one place a status hue may touch this table, because
|
|
127
|
+
* there the value itself means good or bad. Anything unlisted stays
|
|
128
|
+
* `neutral`; the word is always in the badge, so the hue is never the only
|
|
129
|
+
* carrier.
|
|
130
|
+
*/
|
|
131
|
+
tones?: Readonly<Record<string, TableCardTone>>;
|
|
132
|
+
}
|
|
133
|
+
type TableCardColumn = TableCardTextColumn | TableCardNumberColumn | TableCardBarColumn | TableCardDeltaColumn | TableCardTrendColumn | TableCardBadgeColumn;
|
|
134
|
+
/** A column after resolution: defaults applied, and the scale and total this data gives it. */
|
|
135
|
+
interface TableCardColumnModel {
|
|
136
|
+
column: TableCardColumn;
|
|
137
|
+
/** The column's identity — `column.id ?? column.field`. */
|
|
138
|
+
id: string;
|
|
139
|
+
/** The field it reads on each row. */
|
|
140
|
+
field: string;
|
|
141
|
+
kind: TableCardColumnKind;
|
|
142
|
+
header: string;
|
|
143
|
+
align: TableCardAlign;
|
|
144
|
+
sortable: boolean;
|
|
145
|
+
/** `bar` columns: the resolved upper bound of the length scale. `null` when no row has a value. */
|
|
146
|
+
domainMax: number | null;
|
|
147
|
+
/** The aggregate the footer shows, already formatted. `null` when the column declares none. */
|
|
148
|
+
totalText: string | null;
|
|
149
|
+
/** The raw aggregate, for tests and for the generated sentences. */
|
|
150
|
+
totalValue: number | null;
|
|
151
|
+
/** `true` once any row in this column has no reading — the description says so. */
|
|
152
|
+
hasMissing: boolean;
|
|
153
|
+
}
|
|
154
|
+
interface TableCardCellDelta {
|
|
155
|
+
direction: ArcDeltaDirection;
|
|
156
|
+
polarity: TableCardPolarity;
|
|
157
|
+
/** Signed change: `+12.4%`, `-0.8 pp`, `+฿24K`. */
|
|
158
|
+
text: string;
|
|
159
|
+
renderedMode: ArcDeltaMode;
|
|
160
|
+
/** The change as a number, for sorting. */
|
|
161
|
+
value: number;
|
|
162
|
+
}
|
|
163
|
+
/** What a trend cell's series says, in numbers — the basis of its sort order and its sentence. */
|
|
164
|
+
interface TableCardTrendSummary {
|
|
165
|
+
first: number | null;
|
|
166
|
+
last: number | null;
|
|
167
|
+
min: number | null;
|
|
168
|
+
max: number | null;
|
|
169
|
+
/** Readings with a value. */
|
|
170
|
+
count: number;
|
|
171
|
+
/** Readings that are null — drawn as gaps, never as zero. */
|
|
172
|
+
gaps: number;
|
|
173
|
+
/** `last - first`, or `null` when either end is missing. */
|
|
174
|
+
change: number | null;
|
|
175
|
+
direction: ArcDeltaDirection | null;
|
|
176
|
+
}
|
|
177
|
+
interface TableCardCell {
|
|
178
|
+
/** The column's identity — what `byField` files this cell under. */
|
|
179
|
+
id: string;
|
|
180
|
+
/** The row field it was read from. Two cells in a row may share it. */
|
|
181
|
+
field: string;
|
|
182
|
+
kind: TableCardColumnKind;
|
|
183
|
+
/** The formatted text the cell shows. `MISSING_VALUE` when there is no reading. */
|
|
184
|
+
text: string;
|
|
185
|
+
/** What this cell sorts by: a number for every numeric kind, the string for `text` and `badge`, `null` when missing. */
|
|
186
|
+
sortValue: number | string | null;
|
|
187
|
+
/** The raw numeric reading, for the footer aggregates. */
|
|
188
|
+
value: number | null;
|
|
189
|
+
/** `bar` cells: 0–1 of the column's domain, clamped. `null` when there is no reading. */
|
|
190
|
+
share: number | null;
|
|
191
|
+
/** `delta` cells. */
|
|
192
|
+
delta: TableCardCellDelta | null;
|
|
193
|
+
/** `trend` cells: the normalised series. */
|
|
194
|
+
points: readonly TableCardTrendPoint[] | null;
|
|
195
|
+
/** `trend` cells: what the series says. */
|
|
196
|
+
trend: TableCardTrendSummary | null;
|
|
197
|
+
/** `badge` cells. */
|
|
198
|
+
tone: TableCardTone | null;
|
|
199
|
+
/** `text` cells: the muted second line. */
|
|
200
|
+
caption: string | null;
|
|
201
|
+
/**
|
|
202
|
+
* The sentence assistive technology hears when the visual form is not text —
|
|
203
|
+
* a trend cell's shape, a bar's share. `null` when `text` already says
|
|
204
|
+
* everything.
|
|
205
|
+
*/
|
|
206
|
+
detail: string | null;
|
|
207
|
+
}
|
|
208
|
+
interface TableCardRowModel {
|
|
209
|
+
key: string;
|
|
210
|
+
/** The row's identifying text — its first `text` column, else its key. */
|
|
211
|
+
label: string;
|
|
212
|
+
/** 1-based place in the current order, ties shared. `null` when the table is unsorted. */
|
|
213
|
+
rank: number | null;
|
|
214
|
+
cells: TableCardCell[];
|
|
215
|
+
byField: Readonly<Record<string, TableCardCell>>;
|
|
216
|
+
}
|
|
217
|
+
interface TableCardSummary {
|
|
218
|
+
rows: TableCardRowModel[];
|
|
219
|
+
columns: TableCardColumnModel[];
|
|
220
|
+
/** Rows shown. */
|
|
221
|
+
count: number;
|
|
222
|
+
/** Rows behind the table — `totalRows` when the consumer paged or filtered upstream, else the input length. */
|
|
223
|
+
total: number;
|
|
224
|
+
/** Rows `maxRows` cut off. */
|
|
225
|
+
truncated: number;
|
|
226
|
+
/** The resolved sorted column, `null` when unsorted. */
|
|
227
|
+
sortColumn: TableCardColumnModel | null;
|
|
228
|
+
/** First and last row of the current order — what the insight names. */
|
|
229
|
+
leader: TableCardRowModel | null;
|
|
230
|
+
trailer: TableCardRowModel | null;
|
|
231
|
+
/** Any `trend` column is present, so the engine chunk is needed. */
|
|
232
|
+
hasTrend: boolean;
|
|
233
|
+
/** One row where the order is the point — a ranking of one is not a ranking. */
|
|
234
|
+
insufficient: boolean;
|
|
235
|
+
}
|
|
236
|
+
/** Every string the card renders or announces, so a product can localise it. Sentences are functions. */
|
|
237
|
+
interface TableCardLabels {
|
|
238
|
+
/** Accessible name of a column's sort control. */
|
|
239
|
+
sortBy: (header: string) => string;
|
|
240
|
+
/** Accessible name that reverses the active order. */
|
|
241
|
+
sortDescending: (header: string) => string;
|
|
242
|
+
sortAscending: (header: string) => string;
|
|
243
|
+
/** Announced once after the reader re-sorts. */
|
|
244
|
+
sortedBy: (header: string, direction: TableCardSortDirection) => string;
|
|
245
|
+
ascending: string;
|
|
246
|
+
descending: string;
|
|
247
|
+
/** Accessible prefix for a row's ordinal, so "1." is unambiguous. */
|
|
248
|
+
rank: (place: number) => string;
|
|
249
|
+
/** Footer row heading. */
|
|
250
|
+
total: string;
|
|
251
|
+
/** Caption under the table when `maxRows` cut the tail off. */
|
|
252
|
+
showingTopOf: (shown: number, total: number) => string;
|
|
253
|
+
showAll: string;
|
|
254
|
+
/** The generated takeaway when the leader stands above the median of the sorted column. */
|
|
255
|
+
insightAboveMedian: (leader: string, header: string, value: string, share: string, rows: number) => string;
|
|
256
|
+
/** …and below it — possible when the order is ascending. */
|
|
257
|
+
insightBelowMedian: (leader: string, header: string, value: string, share: string, rows: number) => string;
|
|
258
|
+
/** …and exactly at it. */
|
|
259
|
+
insightAtMedian: (leader: string, header: string, value: string, rows: number) => string;
|
|
260
|
+
/** A trend cell's sentence: `4.2K to 5.1K, up 21%`. */
|
|
261
|
+
trendSentence: (first: string, last: string, change: string) => string;
|
|
262
|
+
/** A trend cell with one or no readings. */
|
|
263
|
+
trendInsufficient: string;
|
|
264
|
+
/** A bar cell's share, appended to its value. */
|
|
265
|
+
shareOf: (share: string) => string;
|
|
266
|
+
increase: string;
|
|
267
|
+
decrease: string;
|
|
268
|
+
unchanged: string;
|
|
269
|
+
/** Suffix for a percentage-point delta. */
|
|
270
|
+
percentagePoints: string;
|
|
271
|
+
noData: string;
|
|
272
|
+
noMatch: string;
|
|
273
|
+
clearFilters: string;
|
|
274
|
+
error: string;
|
|
275
|
+
retry: string;
|
|
276
|
+
/** Caption note when a ranked table has a single row. */
|
|
277
|
+
insufficient: string;
|
|
278
|
+
stale: string;
|
|
279
|
+
asOf: string;
|
|
280
|
+
about: (name: string) => string;
|
|
281
|
+
/** Accessible name of a row's drill control. */
|
|
282
|
+
openRow: (label: string) => string;
|
|
283
|
+
/** The table's own caption, when the consumer passes none. */
|
|
284
|
+
caption: (name: string) => string;
|
|
285
|
+
}
|
|
286
|
+
declare const DEFAULT_TABLE_LABELS: TableCardLabels;
|
|
287
|
+
/** Merges a partial override over the defaults. */
|
|
288
|
+
declare function resolveTableLabels(labels?: Partial<TableCardLabels>): TableCardLabels;
|
|
289
|
+
/**
|
|
290
|
+
* Normalises a trend field: a bare array of readings becomes indexed points,
|
|
291
|
+
* `{ x, y }` records pass through, and anything else becomes an empty series.
|
|
292
|
+
* Nulls survive as nulls — a gap is not a zero.
|
|
293
|
+
*/
|
|
294
|
+
declare function normalizeTrendPoints(value: unknown): TableCardTrendPoint[];
|
|
295
|
+
/** What a trend cell's series says: its ends, its extremes, its gaps, and the change across it. */
|
|
296
|
+
declare function summarizeTrend(points: readonly TableCardTrendPoint[]): TableCardTrendSummary;
|
|
297
|
+
/** How a change reads once `goodDirection` is applied: up is not always good. */
|
|
298
|
+
declare function deltaPolarity(direction: ArcDeltaDirection, goodDirection: TableCardGoodDirection): TableCardPolarity;
|
|
299
|
+
/** A column's identity: its own `id`, else the field it reads. */
|
|
300
|
+
declare function columnId(column: TableCardColumn): string;
|
|
301
|
+
interface NormalizeTableInput {
|
|
302
|
+
columns: readonly TableCardColumn[];
|
|
303
|
+
rows: readonly TableCardRow[];
|
|
304
|
+
/** Field naming each row. Default: the first `text` column's field, then the row index. */
|
|
305
|
+
rowKey?: string;
|
|
306
|
+
sort?: TableCardSort | null;
|
|
307
|
+
/** Cap the rows shown. The tail is cut off and counted, never folded — a summed rate is a lie. */
|
|
308
|
+
maxRows?: number;
|
|
309
|
+
/** The true row count behind the table when the consumer already paged or capped upstream. */
|
|
310
|
+
totalRows?: number;
|
|
311
|
+
/** Number the rows in the current order. */
|
|
312
|
+
showRank?: boolean;
|
|
313
|
+
locale?: string;
|
|
314
|
+
timeZone?: string;
|
|
315
|
+
labels?: TableCardLabels;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Turns the consumer's columns and records into the model the card renders:
|
|
319
|
+
* every column resolved (alignment, sortability, its own length scale and its
|
|
320
|
+
* footer aggregate), every cell formatted once and given the single number it
|
|
321
|
+
* sorts by, the rows ordered, capped and ranked.
|
|
322
|
+
*
|
|
323
|
+
* Missing readings sort last in both directions — "no reading" is not the
|
|
324
|
+
* smallest reading — and a capped tail is reported in `truncated` rather than
|
|
325
|
+
* folded into an "Other" row: a table's columns are not all additive, so
|
|
326
|
+
* summing them would invent numbers.
|
|
327
|
+
*/
|
|
328
|
+
declare function normalizeTable(input: NormalizeTableInput): TableCardSummary;
|
|
329
|
+
interface DeriveTableStateInput {
|
|
330
|
+
status: TableCardStatus;
|
|
331
|
+
/** Rows the card was handed. */
|
|
332
|
+
rowCount: number;
|
|
333
|
+
/** A filter is active, so no rows means "excluded", not "none". */
|
|
334
|
+
filtered?: boolean;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* The state machine: `loading` with nothing to show, `refreshing` when a
|
|
338
|
+
* reload arrives over a rendered table (the previous render stays under the
|
|
339
|
+
* veil rather than collapsing to a skeleton), `error`, then `empty` or
|
|
340
|
+
* `no-match` — different messages, because "there is no data" and "your
|
|
341
|
+
* filters exclude all of it" call for different actions (Cloudscape's
|
|
342
|
+
* `empty` / `noMatch` split).
|
|
343
|
+
*/
|
|
344
|
+
declare function deriveTableState({ status, rowCount, filtered }: DeriveTableStateInput): TableCardState;
|
|
345
|
+
interface BuildTableDescriptionInput {
|
|
346
|
+
name: string;
|
|
347
|
+
summary: TableCardSummary;
|
|
348
|
+
labels: TableCardLabels;
|
|
349
|
+
sort?: TableCardSort | null;
|
|
350
|
+
updatedAt?: string | number | Date;
|
|
351
|
+
updatedAtFormat?: ArcTimeGranularity;
|
|
352
|
+
locale?: string;
|
|
353
|
+
timeZone?: string;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* The card's accessible description (Amy Cesal's alt-text formula: what form,
|
|
357
|
+
* what data, why it is here, as of when) — what the table holds, how it is
|
|
358
|
+
* ordered, which measures it carries, and whether it is capped.
|
|
359
|
+
*/
|
|
360
|
+
declare function buildTableDescription({ name, summary, labels, sort, updatedAt, updatedAtFormat, locale, timeZone }: BuildTableDescriptionInput): string;
|
|
361
|
+
interface BuildTableInsightInput {
|
|
362
|
+
summary: TableCardSummary;
|
|
363
|
+
labels: TableCardLabels;
|
|
364
|
+
locale?: string;
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* The takeaway, as one visible sentence (Chartability's "title, summary,
|
|
368
|
+
* context"): how far the leader stands above the middle of the sorted column,
|
|
369
|
+
* because "who is on top" is already visible and "by how much" is the part a
|
|
370
|
+
* reader has to compute. `null` when the table is unsorted or too short for
|
|
371
|
+
* the comparison to mean anything.
|
|
372
|
+
*/
|
|
373
|
+
declare function buildTableInsight({ summary, labels, locale }: BuildTableInsightInput): string | null;
|
|
374
|
+
/** The `arcTime` grammar string for a trend cell's tooltip x, built from the card's locale and zone. */
|
|
375
|
+
declare function trendTimeFormat(granularity: ArcTimeGranularity | undefined, locale?: string, timeZone?: string): string;
|
|
376
|
+
/** The `arcNumber` grammar string for a column, with the card's locale appended. */
|
|
377
|
+
declare function columnValueFormat(column: TableCardColumn, locale?: string): string;
|
|
378
|
+
/** Flips a column's order: a fresh click on a numeric column leads with the largest, on a name with A. */
|
|
379
|
+
declare function nextSort(current: TableCardSort | null, column: TableCardColumnModel): TableCardSort;
|
|
380
|
+
//#endregion
|
|
381
|
+
export { BuildTableDescriptionInput, BuildTableInsightInput, DEFAULT_TABLE_LABELS, DeriveTableStateInput, NormalizeTableInput, TableCardAlign, TableCardBadgeColumn, TableCardBarColumn, TableCardCell, TableCardCellDelta, TableCardColumn, TableCardColumnKind, TableCardColumnModel, TableCardDeltaColumn, TableCardGoodDirection, TableCardLabels, TableCardNumberColumn, TableCardPolarity, TableCardRow, TableCardRowModel, TableCardSize, TableCardSort, TableCardSortDirection, TableCardState, TableCardStatus, TableCardSummary, TableCardTextColumn, TableCardTone, TableCardTotal, TableCardTrendColumn, TableCardTrendMark, TableCardTrendPoint, TableCardTrendSummary, buildTableDescription, buildTableInsight, columnId, columnValueFormat, deltaPolarity, deriveTableState, nextSort, normalizeTable, normalizeTrendPoints, resolveTableLabels, summarizeTrend, trendTimeFormat };
|