@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,468 @@
|
|
|
1
|
+
import { ArcDeltaDirection, ArcDeltaMode } from "../../lib/vega/formatters.js";
|
|
2
|
+
//#region src/components/TargetCard/TargetCard.model.d.ts
|
|
3
|
+
/** What the consumer's transport reports. */
|
|
4
|
+
type TargetCardStatus = "loading" | "ready" | "error";
|
|
5
|
+
/**
|
|
6
|
+
* What the card actually shows, derived from `status`, the value, the target
|
|
7
|
+
* and `filtered`. Stamped on the root as `data-state`.
|
|
8
|
+
*/
|
|
9
|
+
type TargetCardState = "loading" | "refreshing" | "ready" | "empty" | "no-match" | "error";
|
|
10
|
+
/**
|
|
11
|
+
* Which way the target is reached: `up` — reach at least the target (a quota,
|
|
12
|
+
* a goal); `down` — stay at or under it (a budget, an error cap). A plan value
|
|
13
|
+
* that is neither is MetricCard's `goodDirection="none"` with a `target`.
|
|
14
|
+
*/
|
|
15
|
+
type TargetGoodDirection = "up" | "down";
|
|
16
|
+
/** How a change reads once `goodDirection` is applied. Stamped as `data-polarity`. */
|
|
17
|
+
type TargetPolarity = "positive" | "negative" | "neutral";
|
|
18
|
+
type TargetDeltaMode = ArcDeltaMode;
|
|
19
|
+
type TargetCardSize = "sm" | "md" | "lg";
|
|
20
|
+
/** What the big number is: the attainment percentage (default) or the reading itself. Stamped as `data-headline`. */
|
|
21
|
+
type TargetHeadline = "attainment" | "value";
|
|
22
|
+
/**
|
|
23
|
+
* The judgement the card reaches, stamped as `data-track`: `achieved` (the
|
|
24
|
+
* target is met — at once for an `up` target, once the period has ended within
|
|
25
|
+
* it for a `down` one), `missed` (the period ended short of an `up` target, or
|
|
26
|
+
* a `down` target was exceeded), and the pace verdicts while the period runs —
|
|
27
|
+
* `on-track` (at or better than the plan expects by now), `at-risk` (behind by
|
|
28
|
+
* no more than `tolerance` of the target) and `off-track`.
|
|
29
|
+
*/
|
|
30
|
+
type TargetTrack = "achieved" | "on-track" | "at-risk" | "off-track" | "missed";
|
|
31
|
+
/** The reading against what the plan expects by now, after `goodDirection`: better, worse, or equal. */
|
|
32
|
+
type TargetPaceStatus = "ahead" | "behind" | "on";
|
|
33
|
+
/** The bar's hue: the emphasis hue while the target is open, the positive hue once achieved, the negative hue once missed. */
|
|
34
|
+
type TargetTone = "primary" | "positive" | "negative";
|
|
35
|
+
/**
|
|
36
|
+
* The goal period. `start` and `end` are inclusive calendar dates when given
|
|
37
|
+
* as date-only ISO strings (`"2026-09-01"` – `"2026-09-30"` is the whole of
|
|
38
|
+
* September, midnight to midnight in the card's `timeZone`), or exact
|
|
39
|
+
* instants when given as `Date`s, timestamps or date-times. `label` names the
|
|
40
|
+
* period (`September 2026`, `Q3 FY26`) for the period line.
|
|
41
|
+
*/
|
|
42
|
+
interface TargetPeriod {
|
|
43
|
+
start: Date | string | number;
|
|
44
|
+
end: Date | string | number;
|
|
45
|
+
label?: string;
|
|
46
|
+
}
|
|
47
|
+
/** The period as instants: `[start, end)` in epoch milliseconds. */
|
|
48
|
+
interface TargetPeriodBounds {
|
|
49
|
+
start: number;
|
|
50
|
+
end: number;
|
|
51
|
+
label?: string;
|
|
52
|
+
/** Both bounds were calendar dates, so the period line shows them as a date range rather than instants. */
|
|
53
|
+
dateOnly: boolean;
|
|
54
|
+
}
|
|
55
|
+
/** How far the period has run at the card's `updatedAt`. */
|
|
56
|
+
interface TargetElapsed {
|
|
57
|
+
/** Elapsed share of the period, clamped to `[0, 1]`. */
|
|
58
|
+
fraction: number;
|
|
59
|
+
/** The unclamped share — below 0 before the period, above 1 after it. */
|
|
60
|
+
rawFraction: number;
|
|
61
|
+
started: boolean;
|
|
62
|
+
ended: boolean;
|
|
63
|
+
/** `fraction` as text — `61%`. */
|
|
64
|
+
percentText: string;
|
|
65
|
+
}
|
|
66
|
+
/** A change between two readings in the card's `deltaMode`, with polarity resolved through `goodDirection`. */
|
|
67
|
+
interface TargetDelta {
|
|
68
|
+
direction: ArcDeltaDirection;
|
|
69
|
+
polarity: TargetPolarity;
|
|
70
|
+
/** Signed, formatted change: `+6.4%`, `-฿152K`, `-0.3 pp`. */
|
|
71
|
+
text: string;
|
|
72
|
+
renderedMode: ArcDeltaMode;
|
|
73
|
+
/** The same change in the other form, or `null` when it does not exist (a zero reference has no percent). */
|
|
74
|
+
secondaryText: string | null;
|
|
75
|
+
}
|
|
76
|
+
/** The reading against what the plan expects by now. */
|
|
77
|
+
interface TargetPace {
|
|
78
|
+
/** The value the plan expects by `updatedAt` — an explicit `expected`, else `target × elapsed`. */
|
|
79
|
+
expected: number;
|
|
80
|
+
expectedRatio: number;
|
|
81
|
+
expectedText: string;
|
|
82
|
+
/** `expectedRatio` as text — `61%`. */
|
|
83
|
+
expectedPercentText: string;
|
|
84
|
+
/** The reading against the expectation in the card's `deltaMode`. */
|
|
85
|
+
delta: TargetDelta;
|
|
86
|
+
/** The same gap in percentage points of the target — `+3.9 pp`. */
|
|
87
|
+
pointsText: string;
|
|
88
|
+
status: TargetPaceStatus;
|
|
89
|
+
/** Whether the pace came from the period (`linear`) or from an explicit `expected` (`explicit`). */
|
|
90
|
+
source: "linear" | "explicit";
|
|
91
|
+
}
|
|
92
|
+
/** Where the reading lands at the period's end. */
|
|
93
|
+
interface TargetProjection {
|
|
94
|
+
value: number;
|
|
95
|
+
ratio: number;
|
|
96
|
+
text: string;
|
|
97
|
+
percentText: string;
|
|
98
|
+
/** Whether the projection came from the run rate (`linear`) or from an explicit `projected` (`explicit`). */
|
|
99
|
+
source: "linear" | "explicit";
|
|
100
|
+
/** The projection reaches beyond the reading (away from zero), so the plot extends the bar to it. */
|
|
101
|
+
extends: boolean;
|
|
102
|
+
}
|
|
103
|
+
/** The plot's x domain — always spanning zero, the target and every marker. */
|
|
104
|
+
interface TargetBounds {
|
|
105
|
+
min: number;
|
|
106
|
+
max: number;
|
|
107
|
+
}
|
|
108
|
+
/** Everything the card derives from the reading and the target. */
|
|
109
|
+
interface TargetProgress {
|
|
110
|
+
value: number;
|
|
111
|
+
target: number;
|
|
112
|
+
/** `value / target`, unclamped — 1.1 is 110% of target, -0.24 is a loss against a profit target. */
|
|
113
|
+
ratio: number;
|
|
114
|
+
valueText: string;
|
|
115
|
+
targetText: string;
|
|
116
|
+
/** `ratio` as text — `65%`. */
|
|
117
|
+
percentText: string;
|
|
118
|
+
/** The reading is at or beyond the target in the good direction — an `up` target reached, a `down` one still within. */
|
|
119
|
+
withinTarget: boolean;
|
|
120
|
+
/** The reading is past the target: `over` — else `remaining` (the distance still to go, or the headroom left under a cap). */
|
|
121
|
+
gapKind: "remaining" | "over";
|
|
122
|
+
/** `|target − value|`, formatted. */
|
|
123
|
+
gapText: string;
|
|
124
|
+
/** The reading against the target itself in the card's `deltaMode` — the badge when there is no pace. */
|
|
125
|
+
targetDelta: TargetDelta;
|
|
126
|
+
elapsed: TargetElapsed | null;
|
|
127
|
+
pace: TargetPace | null;
|
|
128
|
+
projection: TargetProjection | null;
|
|
129
|
+
track: TargetTrack | null;
|
|
130
|
+
tone: TargetTone;
|
|
131
|
+
bounds: TargetBounds;
|
|
132
|
+
}
|
|
133
|
+
/** Every string the card renders or announces, so a product can localise it. Sentences are functions. */
|
|
134
|
+
interface TargetCardLabels {
|
|
135
|
+
/** After the attainment percentage — `65% of target`. */
|
|
136
|
+
ofTarget: string;
|
|
137
|
+
/**
|
|
138
|
+
* Joins the reading and the target once they share a symbol and a magnitude
|
|
139
|
+
* — `฿2.6/4M`, `187/200 ms`, `2.7/3%`. Default `/`.
|
|
140
|
+
*/
|
|
141
|
+
pairSeparator: string;
|
|
142
|
+
/** The line under an attainment headline when the pair cannot be collapsed — `฿850K of ฿4M`. */
|
|
143
|
+
readingLine: (value: string, target: string) => string;
|
|
144
|
+
/** The line under a value headline — `65% of ฿4M`. */
|
|
145
|
+
attainmentLine: (percent: string, target: string) => string;
|
|
146
|
+
target: string;
|
|
147
|
+
/** The reading's name in the legend, tooltip and table — `Reached`. */
|
|
148
|
+
reached: string;
|
|
149
|
+
/** The distance still to go, or the headroom under a cap. */
|
|
150
|
+
remaining: string;
|
|
151
|
+
/** The amount past the target. */
|
|
152
|
+
overBy: string;
|
|
153
|
+
expectedByNow: string;
|
|
154
|
+
/** Comparison line and table row when the reading beats the plan — `ahead of pace` for a goal, `under pace` for a budget. */
|
|
155
|
+
aheadOfPace: (direction: TargetGoodDirection) => string;
|
|
156
|
+
/** … and when it trails the plan — `behind pace`, `over pace`. */
|
|
157
|
+
behindPace: (direction: TargetGoodDirection) => string;
|
|
158
|
+
onPace: string;
|
|
159
|
+
/** Comparison line under the badge when there is no pace — the badge then compares the reading with the target. */
|
|
160
|
+
vsTarget: string;
|
|
161
|
+
aboveTarget: string;
|
|
162
|
+
belowTarget: string;
|
|
163
|
+
onTarget: string;
|
|
164
|
+
projected: string;
|
|
165
|
+
period: string;
|
|
166
|
+
/** Names a week-shaped period. `year` is that week's year, already formatted in the card's locale and calendar. */
|
|
167
|
+
week: (weekNumber: number, year: string) => string;
|
|
168
|
+
/** Names a quarter-shaped period — `Q3 2026`. */
|
|
169
|
+
quarter: (quarter: number, year: string) => string;
|
|
170
|
+
/** The elapsed share, on its own line under the period's name — `62% elapsed`. */
|
|
171
|
+
elapsed: (percent: string) => string;
|
|
172
|
+
/** The table row naming the elapsed share. */
|
|
173
|
+
elapsedRow: string;
|
|
174
|
+
/** The table row naming how much of the period has gone in whole days. */
|
|
175
|
+
daysRow: string;
|
|
176
|
+
/** Whole days elapsed against the period's own length — `18 of 30`. */
|
|
177
|
+
days: (elapsed: number, total: number) => string;
|
|
178
|
+
/** The status chip's words per verdict. */
|
|
179
|
+
trackNames: Record<TargetTrack, string>;
|
|
180
|
+
/** The table row naming the verdict. */
|
|
181
|
+
trackRow: string;
|
|
182
|
+
/** Spoken direction words for the badge glyph. */
|
|
183
|
+
increase: string;
|
|
184
|
+
decrease: string;
|
|
185
|
+
unchanged: string;
|
|
186
|
+
/** Suffix for a percentage-point delta. */
|
|
187
|
+
percentagePoints: string;
|
|
188
|
+
noData: string;
|
|
189
|
+
noMatch: string;
|
|
190
|
+
clearFilters: string;
|
|
191
|
+
error: string;
|
|
192
|
+
retry: string;
|
|
193
|
+
/** Caption in the plot's place when a reading exists but no target does. */
|
|
194
|
+
noTarget: string;
|
|
195
|
+
stale: string;
|
|
196
|
+
asOf: string;
|
|
197
|
+
tableItem: string;
|
|
198
|
+
tableValue: string;
|
|
199
|
+
/** Column headers of the change's two forms in the explanation rows. */
|
|
200
|
+
changePercent: string;
|
|
201
|
+
changeAmount: string;
|
|
202
|
+
markNames: {
|
|
203
|
+
actual: string;
|
|
204
|
+
pace: string;
|
|
205
|
+
target: string;
|
|
206
|
+
projection: string;
|
|
207
|
+
};
|
|
208
|
+
showTable: (name: string) => string;
|
|
209
|
+
hideTable: (name: string) => string;
|
|
210
|
+
about: (name: string) => string;
|
|
211
|
+
loading: (name: string) => string;
|
|
212
|
+
tableCaption: (name: string) => string;
|
|
213
|
+
/** Accessible name of the badge stack — `Revenue against its target`. */
|
|
214
|
+
progressGroup: (name: string) => string;
|
|
215
|
+
/** Accessible name of the status chip — `Revenue status`. */
|
|
216
|
+
trackGroup: (name: string) => string;
|
|
217
|
+
/** Accessible name of the AI mark beside the insight sentence. */
|
|
218
|
+
insightMark: string;
|
|
219
|
+
/** Compact label/value rows explaining the badge — the reading, the reference it is measured against and the change in both forms. */
|
|
220
|
+
explanation: (input: TargetExplanationInput) => readonly (readonly [label: string, value: string])[];
|
|
221
|
+
/** The description's attainment sentence — `Revenue: 65% of target (฿2.61M of ฿4M).` */
|
|
222
|
+
attainmentSentence: (input: {
|
|
223
|
+
name: string;
|
|
224
|
+
percent: string;
|
|
225
|
+
value: string;
|
|
226
|
+
target: string;
|
|
227
|
+
}) => string;
|
|
228
|
+
/** The description's gap sentence — `Remaining ฿1.39M.` / `Over by ฿150K.` */
|
|
229
|
+
gapSentence: (input: {
|
|
230
|
+
kind: "remaining" | "over";
|
|
231
|
+
amount: string;
|
|
232
|
+
}) => string;
|
|
233
|
+
/** The description's pace sentence. `primary` is the unsigned change (empty when on pace), `secondary` its other form or `null`. */
|
|
234
|
+
paceSentence: (input: {
|
|
235
|
+
word: string;
|
|
236
|
+
primary: string;
|
|
237
|
+
secondary: string | null;
|
|
238
|
+
expectedPercent: string;
|
|
239
|
+
elapsedPercent: string | null;
|
|
240
|
+
}) => string;
|
|
241
|
+
/** The description's projection sentence — `Projected ฿4.24M (106% of target).` */
|
|
242
|
+
projectionSentence: (input: {
|
|
243
|
+
value: string;
|
|
244
|
+
percent: string;
|
|
245
|
+
}) => string;
|
|
246
|
+
/**
|
|
247
|
+
* The description's period sentence — `Period Sep 2026 (Sep 1 – 30, 2026).`
|
|
248
|
+
* `name` is what the footer shows; `range` spells the bounds out, and is
|
|
249
|
+
* dropped when the name already is the range.
|
|
250
|
+
*/
|
|
251
|
+
periodSentence: (input: {
|
|
252
|
+
name: string;
|
|
253
|
+
range: string;
|
|
254
|
+
}) => string;
|
|
255
|
+
/** The plot's own `aria-label`. */
|
|
256
|
+
chartDescription: (input: {
|
|
257
|
+
name: string;
|
|
258
|
+
value: string;
|
|
259
|
+
percent: string;
|
|
260
|
+
target: string;
|
|
261
|
+
expected: string | null;
|
|
262
|
+
expectedPercent: string | null;
|
|
263
|
+
projected: string | null;
|
|
264
|
+
projectedPercent: string | null;
|
|
265
|
+
}) => string;
|
|
266
|
+
}
|
|
267
|
+
/** What the badge explanation and the popover rows are built from. */
|
|
268
|
+
interface TargetExplanationInput {
|
|
269
|
+
/** `pace` when the badge compares the reading with the plan's expectation, `target` when with the target itself. */
|
|
270
|
+
kind: "pace" | "target";
|
|
271
|
+
direction: TargetGoodDirection;
|
|
272
|
+
valueText: string;
|
|
273
|
+
percentText: string;
|
|
274
|
+
targetText: string;
|
|
275
|
+
gapKind: "remaining" | "over";
|
|
276
|
+
gapText: string;
|
|
277
|
+
expectedText: string | null;
|
|
278
|
+
expectedPercentText: string | null;
|
|
279
|
+
delta: TargetDelta;
|
|
280
|
+
paceStatus: TargetPaceStatus | null;
|
|
281
|
+
}
|
|
282
|
+
declare const DEFAULT_TARGET_LABELS: TargetCardLabels;
|
|
283
|
+
declare function resolveTargetLabels(overrides?: Partial<TargetCardLabels>): TargetCardLabels;
|
|
284
|
+
interface DeriveTargetStateInput {
|
|
285
|
+
status: TargetCardStatus;
|
|
286
|
+
/** A finite reading exists. */
|
|
287
|
+
hasValue: boolean;
|
|
288
|
+
/** Anything is on screen already — a reading or a target — so a reload is a refresh, not a first load. */
|
|
289
|
+
hasData: boolean;
|
|
290
|
+
filtered: boolean;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* The state machine. Error wins; loading over existing data is a refresh (the
|
|
294
|
+
* previous render stays under the veil); a missing reading is `no-match` when
|
|
295
|
+
* the consumer's filter caused it and `empty` otherwise. A reading without a
|
|
296
|
+
* target is `ready` — the card then shows the reading and says no target is
|
|
297
|
+
* set (`data-insufficient`).
|
|
298
|
+
*/
|
|
299
|
+
declare function deriveTargetState({ status, hasValue, hasData, filtered }: DeriveTargetStateInput): TargetCardState;
|
|
300
|
+
/**
|
|
301
|
+
* The period as instants in the card's time zone. A date-only bound is a
|
|
302
|
+
* whole calendar day: `start` opens at its midnight and `end` closes at the
|
|
303
|
+
* midnight after it, so `"2026-09-01"` – `"2026-09-30"` is all of September
|
|
304
|
+
* (30 days, not 29). Any other form is the exact instant. `null` when a bound
|
|
305
|
+
* cannot be parsed or the period has no length.
|
|
306
|
+
*/
|
|
307
|
+
declare function resolvePeriod(period: TargetPeriod | undefined, timeZone?: string): TargetPeriodBounds | null;
|
|
308
|
+
/**
|
|
309
|
+
* How far the period has run at `asOf`. The fraction is clamped for the
|
|
310
|
+
* plan's expectation (nothing is expected before the start, everything by the
|
|
311
|
+
* end); `rawFraction` keeps the overshoot so a reading after the end knows
|
|
312
|
+
* the period is over. `null` when `asOf` is missing or unparseable.
|
|
313
|
+
*/
|
|
314
|
+
declare function deriveElapsed(bounds: TargetPeriodBounds | null | undefined, asOf: Date | string | number | null | undefined, locale?: string): TargetElapsed | null;
|
|
315
|
+
/** The whole days a date-only period spans. */
|
|
316
|
+
declare function periodDays(bounds: TargetPeriodBounds): number;
|
|
317
|
+
/** How much of the period has gone in whole days, against its own length. */
|
|
318
|
+
interface TargetDays {
|
|
319
|
+
/** Whole days between the period's first day and the day `asOf` falls on, clamped to the period. */
|
|
320
|
+
elapsed: number;
|
|
321
|
+
total: number;
|
|
322
|
+
}
|
|
323
|
+
interface TargetTextFormatters {
|
|
324
|
+
formatValue: (value: number | null | undefined) => string;
|
|
325
|
+
/** A ratio of the target as a whole percentage — `65%`. */
|
|
326
|
+
formatPercent: (ratio: number | null | undefined) => string;
|
|
327
|
+
}
|
|
328
|
+
/** The formatters every text surface shares — headline, badge, plot tooltip, table, descriptions. */
|
|
329
|
+
declare function createTargetFormatters({ format, locale, formatValue }: {
|
|
330
|
+
format: string;
|
|
331
|
+
locale?: string;
|
|
332
|
+
formatValue?: (value: number) => string;
|
|
333
|
+
}): TargetTextFormatters;
|
|
334
|
+
/**
|
|
335
|
+
* Joins a reading and its target into one compact pair — `฿2.6M` and `฿4M`
|
|
336
|
+
* become `฿2.6/4M`, `187 ms` and `200 ms` become `187/200 ms`, `2.7%` and `3%`
|
|
337
|
+
* become `2.7/3%` — by lifting out the symbol they both start with and the
|
|
338
|
+
* magnitude they both end with. A leading sign stays on the reading
|
|
339
|
+
* (`-฿120/500K`).
|
|
340
|
+
*
|
|
341
|
+
* Returns `null` whenever the two cannot share their parts — `฿850K` against
|
|
342
|
+
* `฿4M` is not `฿850/4M`, and a locale or formatter this heuristic does not
|
|
343
|
+
* recognise must not be guessed at — so the caller falls back to the full
|
|
344
|
+
* `X of Y` line rather than printing something untrue.
|
|
345
|
+
*/
|
|
346
|
+
declare function formatValuePair(valueText: string, targetText: string, separator?: string): string | null;
|
|
347
|
+
interface DeriveTargetDeltaOptions {
|
|
348
|
+
deltaMode: TargetDeltaMode;
|
|
349
|
+
goodDirection: TargetGoodDirection;
|
|
350
|
+
format: string;
|
|
351
|
+
locale?: string;
|
|
352
|
+
percentagePoints: string;
|
|
353
|
+
}
|
|
354
|
+
/** The reading against a reference (the target, or the plan's expectation), with polarity resolved through `goodDirection`. */
|
|
355
|
+
declare function deriveTargetDelta(value: number, reference: number, { deltaMode, goodDirection, format, locale, percentagePoints }: DeriveTargetDeltaOptions): TargetDelta;
|
|
356
|
+
interface DeriveTargetProgressInput extends DeriveTargetDeltaOptions {
|
|
357
|
+
value: number | null | undefined;
|
|
358
|
+
target: number | null | undefined;
|
|
359
|
+
formatters: TargetTextFormatters;
|
|
360
|
+
/** How far behind the plan, as a share of the target, still counts as at risk rather than off track. */
|
|
361
|
+
tolerance: number;
|
|
362
|
+
elapsed: TargetElapsed | null;
|
|
363
|
+
/** The plan's own expectation by now; `undefined` derives it from `elapsed`, `null` disables pace. */
|
|
364
|
+
expected?: number | null;
|
|
365
|
+
/** The consumer's own forecast; `undefined` derives the run rate from `elapsed`, `null` disables the projection. */
|
|
366
|
+
projected?: number | null;
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Attainment, pace, projection and verdict — `null` without a finite reading
|
|
370
|
+
* and a finite, non-zero target (a zero target has no ratio).
|
|
371
|
+
*
|
|
372
|
+
* Pace is `target × elapsed` unless the product supplies its own `expected`
|
|
373
|
+
* (a seasonal plan curve); the projection is the linear run rate
|
|
374
|
+
* `value / elapsed` unless the product supplies `projected` — both are
|
|
375
|
+
* declared as such in `source`, and a run rate is only projected while the
|
|
376
|
+
* period is still running with some of it elapsed. The verdict: an `up`
|
|
377
|
+
* target is achieved the moment the reading reaches it and missed once the
|
|
378
|
+
* period ends short of it; a `down` target is missed the moment the reading
|
|
379
|
+
* exceeds it and achieved once the period ends within it. While the period
|
|
380
|
+
* runs, the gap to the plan's expectation in points of the target decides
|
|
381
|
+
* between on track, at risk (behind by no more than `tolerance`) and off
|
|
382
|
+
* track. Without a period or an `expected` there is no pace and no verdict
|
|
383
|
+
* short of achieved or missed.
|
|
384
|
+
*/
|
|
385
|
+
declare function deriveTargetProgress({ value, target, formatters, tolerance, elapsed, expected, projected, ...deltaOptions }: DeriveTargetProgressInput): TargetProgress | null;
|
|
386
|
+
/** The word the pace badge's comparison line and explanation use for the reading's standing against the plan. */
|
|
387
|
+
declare function paceWord(pace: TargetPace, direction: TargetGoodDirection, labels: TargetCardLabels): string;
|
|
388
|
+
/** The rows behind the badge: the reading against the plan's expectation when there is a pace, else against the target. */
|
|
389
|
+
declare function buildTargetExplanation(progress: TargetProgress, direction: TargetGoodDirection, labels: TargetCardLabels): readonly (readonly [label: string, value: string])[];
|
|
390
|
+
/** One row of the details table — the table twin of the bullet graph. `tone` colours a change; `mark` keys the row to a mark in the plot. */
|
|
391
|
+
interface TargetDetailRow {
|
|
392
|
+
key: string;
|
|
393
|
+
label: string;
|
|
394
|
+
value: string;
|
|
395
|
+
tone?: TargetPolarity;
|
|
396
|
+
mark?: keyof TargetCardLabels["markNames"];
|
|
397
|
+
}
|
|
398
|
+
interface BuildTargetDetailRowsInput {
|
|
399
|
+
progress: TargetProgress;
|
|
400
|
+
direction: TargetGoodDirection;
|
|
401
|
+
periodText: string | null;
|
|
402
|
+
/** Whole days elapsed and the period's length, from `deriveDays`. */
|
|
403
|
+
days?: TargetDays | null;
|
|
404
|
+
labels: TargetCardLabels;
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Every value the card shows, as label/value rows: target, reading, the gap,
|
|
408
|
+
* the plan's expectation and the pace against it, the elapsed share, the
|
|
409
|
+
* projection, the period and the verdict — the popover's table, so nothing
|
|
410
|
+
* lives only in the plot or on hover.
|
|
411
|
+
*/
|
|
412
|
+
declare function buildTargetDetailRows({ progress, direction, periodText, days, labels }: BuildTargetDetailRowsInput): TargetDetailRow[];
|
|
413
|
+
/** The period as text — the label, the date range, or both — for the period line and the descriptions. */
|
|
414
|
+
/**
|
|
415
|
+
* What calendar unit the period actually is, read off its own bounds — a goal
|
|
416
|
+
* set for a week, a month, a quarter or a year names itself the way the
|
|
417
|
+
* business does (`Week 32`, `Sep 2026`, `Q3 2026`, `2026`) instead of
|
|
418
|
+
* repeating a date range, and anything else is `custom`.
|
|
419
|
+
*/
|
|
420
|
+
type TargetPeriodShape = "week" | "month" | "quarter" | "year" | "custom";
|
|
421
|
+
/** The period as the footer and the descriptions speak it. */
|
|
422
|
+
interface TargetPeriodText {
|
|
423
|
+
/** The consumer's `label` when it named the period, else the name its shape earns. */
|
|
424
|
+
name: string;
|
|
425
|
+
shape: TargetPeriodShape;
|
|
426
|
+
/** Whether `name` came from the consumer's `label`. */
|
|
427
|
+
labelled: boolean;
|
|
428
|
+
/** The bounds spelled out — `Sep 1 – 30, 2026` — for the popover table and the description. */
|
|
429
|
+
range: string;
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Names the period and spells out its bounds. The name is the consumer's
|
|
433
|
+
* `label` when it gave one; otherwise the period's own shape supplies it
|
|
434
|
+
* (`Week 32`, `Sep 2026`, `Q3 2026`, `2026`), and a shape the calendar has no
|
|
435
|
+
* word for falls back to the range itself. Every part goes through `Intl` in
|
|
436
|
+
* the card's locale and zone, so a Thai card on the Buddhist calendar reads
|
|
437
|
+
* `ก.ย. 2569` while the arithmetic stays Gregorian.
|
|
438
|
+
*/
|
|
439
|
+
declare function formatPeriod(bounds: TargetPeriodBounds | null, { locale, timeZone, labels }: {
|
|
440
|
+
locale?: string;
|
|
441
|
+
timeZone?: string;
|
|
442
|
+
labels?: TargetCardLabels;
|
|
443
|
+
}): TargetPeriodText | null;
|
|
444
|
+
interface BuildTargetDescriptionInput {
|
|
445
|
+
name: string;
|
|
446
|
+
state: TargetCardState;
|
|
447
|
+
/** The formatted reading, for a card that has one but no target. */
|
|
448
|
+
valueText: string;
|
|
449
|
+
progress: TargetProgress | null;
|
|
450
|
+
direction: TargetGoodDirection;
|
|
451
|
+
periodText: TargetPeriodText | null;
|
|
452
|
+
asOfText?: string;
|
|
453
|
+
labels: TargetCardLabels;
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* The card's text equivalent (Amy Cesal's alt-text formula: what it is, what
|
|
457
|
+
* it shows, why it is here, when it was true) — the figure's accessible
|
|
458
|
+
* description, and the summary a screen reader gets before the parts.
|
|
459
|
+
*/
|
|
460
|
+
declare function buildTargetDescription({ name, state, valueText, progress, direction, periodText, asOfText, labels }: BuildTargetDescriptionInput): string;
|
|
461
|
+
/** The bullet graph's own `description` — the `aria-label` Vega stamps on the `graphics-document`. */
|
|
462
|
+
declare function buildTargetChartDescription({ name, progress, labels }: {
|
|
463
|
+
name: string;
|
|
464
|
+
progress: TargetProgress;
|
|
465
|
+
labels: TargetCardLabels;
|
|
466
|
+
}): string;
|
|
467
|
+
//#endregion
|
|
468
|
+
export { BuildTargetDescriptionInput, BuildTargetDetailRowsInput, DEFAULT_TARGET_LABELS, DeriveTargetDeltaOptions, DeriveTargetProgressInput, DeriveTargetStateInput, TargetBounds, TargetCardLabels, TargetCardSize, TargetCardState, TargetCardStatus, TargetDays, TargetDelta, TargetDeltaMode, TargetDetailRow, TargetElapsed, TargetExplanationInput, TargetGoodDirection, TargetHeadline, TargetPace, TargetPaceStatus, TargetPeriod, TargetPeriodBounds, TargetPeriodShape, TargetPeriodText, TargetPolarity, TargetProgress, TargetProjection, TargetTextFormatters, TargetTone, TargetTrack, buildTargetChartDescription, buildTargetDescription, buildTargetDetailRows, buildTargetExplanation, createTargetFormatters, deriveElapsed, deriveTargetDelta, deriveTargetProgress, deriveTargetState, formatPeriod, formatValuePair, paceWord, periodDays, resolvePeriod, resolveTargetLabels };
|