@squadbase/vantage 0.6.2-dev1.ac99e02 → 0.6.2-dev1.d7c0911
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/{build-MFWRPYKW.js → build-X5NVCQKT.js} +4 -4
- package/dist/{build-MFWRPYKW.js.map → build-X5NVCQKT.js.map} +1 -1
- package/dist/{chunk-IBGOCWJB.js → chunk-2ICNHUG6.js} +186 -82
- package/dist/chunk-2ICNHUG6.js.map +1 -0
- package/dist/{chunk-5ZOP4SQR.js → chunk-2N72FKLB.js} +12 -7
- package/dist/chunk-2N72FKLB.js.map +1 -0
- package/dist/{chunk-PXRX5PEC.js → chunk-PDOBHMUQ.js} +3 -3
- package/dist/chunk-PDOBHMUQ.js.map +1 -0
- package/dist/{chunk-A2UUGASH.js → chunk-U736PVHY.js} +2 -2
- package/dist/chunk-U736PVHY.js.map +1 -0
- package/dist/{chunk-QEWCYW3I.js → chunk-WAMZWZJB.js} +13 -3
- package/dist/chunk-WAMZWZJB.js.map +1 -0
- package/dist/chunk-WRSX2MDK.js +7866 -0
- package/dist/chunk-WRSX2MDK.js.map +1 -0
- package/dist/{chunk-OB6UBJXF.js → chunk-XPQSTZUU.js} +125 -35
- package/dist/chunk-XPQSTZUU.js.map +1 -0
- package/dist/cli.js +3 -3
- package/dist/components/index.d.ts +1831 -99
- package/dist/components/index.js +4 -4
- package/dist/{dev-DCTOHQ6W.js → dev-4XEDTELV.js} +4 -4
- package/dist/{dev-DCTOHQ6W.js.map → dev-4XEDTELV.js.map} +1 -1
- package/dist/doc/index.js +2 -2
- package/dist/doc/index.js.map +1 -1
- package/dist/markdown/index.js +1 -1
- package/dist/markdown/index.js.map +1 -1
- package/dist/table/index.js +5 -5
- package/dist/table/index.js.map +1 -1
- package/dist/ui/index.d.ts +4 -1
- package/dist/ui/index.js +21 -111
- package/dist/ui/index.js.map +1 -1
- package/dist/{upgrade-DBBE6GIR.js → upgrade-JHXZBGQS.js} +3 -3
- package/dist/{upgrade-DBBE6GIR.js.map → upgrade-JHXZBGQS.js.map} +1 -1
- package/dist/vite/index.js +2 -2
- package/docs/en/components.md +29 -15
- package/docs/en/parts/data-table.md +22 -0
- package/docs/en/parts/delta.md +50 -0
- package/docs/en/parts/format.md +43 -0
- package/docs/en/parts/kpi-card.md +57 -0
- package/docs/en/parts/metric-value.md +3 -2
- package/docs/en/parts/sparkline.md +1 -1
- package/docs/en/parts/trend-indicator.md +17 -1
- package/docs/en/ui-and-theming.md +1 -1
- package/docs/index.json +92 -32
- package/docs/ja/changelog.md +5 -0
- package/docs/ja/components.md +27 -15
- package/docs/ja/parts/data-table.md +22 -0
- package/docs/ja/parts/delta.md +50 -0
- package/docs/ja/parts/format.md +44 -0
- package/docs/ja/parts/kpi-card.md +55 -0
- package/docs/ja/parts/metric-value.md +3 -2
- package/docs/ja/parts/sparkline.md +1 -1
- package/docs/ja/parts/trend-indicator.md +17 -1
- package/docs/ja/ui-and-theming.md +2 -2
- package/package.json +2 -1
- package/registry/ui/accordion.tsx +4 -2
- package/registry/ui/alert-dialog.tsx +3 -3
- package/registry/ui/alert.tsx +3 -1
- package/registry/ui/app-shell.tsx +7 -1
- package/registry/ui/area-chart.tsx +2781 -157
- package/registry/ui/avatar.tsx +1 -1
- package/registry/ui/badge.tsx +3 -1
- package/registry/ui/bar-chart.tsx +2780 -157
- package/registry/ui/bar-list.tsx +3471 -93
- package/registry/ui/breadcrumb.tsx +3 -1
- package/registry/ui/button.tsx +3 -1
- package/registry/ui/calendar.tsx +3 -1
- package/registry/ui/card.tsx +4 -2
- package/registry/ui/category-bar.tsx +990 -16
- package/registry/ui/chart-frame.tsx +1358 -0
- package/registry/ui/checkbox.tsx +3 -1
- package/registry/ui/collapsible.tsx +3 -1
- package/registry/ui/combobox.tsx +2 -2
- package/registry/ui/command.tsx +3 -1
- package/registry/ui/dashboard-card.tsx +69 -26
- package/registry/ui/data-table.tsx +678 -56
- package/registry/ui/date-range-picker.tsx +245 -64
- package/registry/ui/delta.tsx +188 -0
- package/registry/ui/dialog.tsx +5 -3
- package/registry/ui/donut-chart.tsx +2857 -173
- package/registry/ui/drawer.tsx +1 -1
- package/registry/ui/dropdown-menu.tsx +5 -3
- package/registry/ui/echart.tsx +448 -44
- package/registry/ui/field.tsx +1 -1
- package/registry/ui/filter-bar.tsx +33 -6
- package/registry/ui/funnel-steps.tsx +3316 -49
- package/registry/ui/heatmap.tsx +1752 -0
- package/registry/ui/hover-card.tsx +2 -2
- package/registry/ui/input-group.tsx +3 -1
- package/registry/ui/input.tsx +3 -1
- package/registry/ui/kbd.tsx +3 -1
- package/registry/ui/kpi-card.tsx +677 -0
- package/registry/ui/label.tsx +3 -1
- package/registry/ui/legend.tsx +3500 -0
- package/registry/ui/line-chart.tsx +2781 -151
- package/registry/ui/metric-value.tsx +9 -1
- package/registry/ui/multi-select.tsx +11 -5
- package/registry/ui/page-shell.tsx +104 -49
- package/registry/ui/pagination.tsx +3 -1
- package/registry/ui/placeholder.tsx +8 -2
- package/registry/ui/popover.tsx +4 -2
- package/registry/ui/progress-circle.tsx +607 -12
- package/registry/ui/progress.tsx +3 -1
- package/registry/ui/radio-group.tsx +1 -1
- package/registry/ui/sample-data.tsx +86 -0
- package/registry/ui/scatter-chart.tsx +4150 -0
- package/registry/ui/scroll-area.tsx +3 -2
- package/registry/ui/searchable-select.tsx +8 -3
- package/registry/ui/section-header.tsx +4 -2
- package/registry/ui/segmented-control.tsx +7 -2
- package/registry/ui/select.tsx +4 -2
- package/registry/ui/separator.tsx +3 -1
- package/registry/ui/sheet.tsx +4 -2
- package/registry/ui/sidebar.tsx +4 -2
- package/registry/ui/skeleton.tsx +4 -2
- package/registry/ui/slider.tsx +3 -1
- package/registry/ui/sparkline.tsx +84 -9
- package/registry/ui/spinner.tsx +3 -1
- package/registry/ui/states.tsx +34 -5
- package/registry/ui/status-badge.tsx +81 -39
- package/registry/ui/switch.tsx +3 -1
- package/registry/ui/table.tsx +4 -2
- package/registry/ui/tabs.tsx +5 -3
- package/registry/ui/textarea.tsx +3 -1
- package/registry/ui/toast.tsx +2 -2
- package/registry/ui/toggle-group.tsx +3 -1
- package/registry/ui/toggle.tsx +3 -1
- package/registry/ui/tooltip.tsx +4 -2
- package/registry/ui/tracker.tsx +624 -17
- package/registry/ui/trend-indicator.tsx +13 -1
- package/registry/ui/updated-at.tsx +122 -0
- package/registry/ui/waterfall-chart.tsx +4186 -0
- package/templates/AGENTS.md +13 -1
- package/theme.css +237 -136
- package/dist/chunk-5ZOP4SQR.js.map +0 -1
- package/dist/chunk-A2UUGASH.js.map +0 -1
- package/dist/chunk-AG6RZ2RR.js +0 -3208
- package/dist/chunk-AG6RZ2RR.js.map +0 -1
- package/dist/chunk-IBGOCWJB.js.map +0 -1
- package/dist/chunk-OB6UBJXF.js.map +0 -1
- package/dist/chunk-PXRX5PEC.js.map +0 -1
- package/dist/chunk-QEWCYW3I.js.map +0 -1
package/dist/vite/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { vantagePlugin } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
export { vantagePlugin } from '../chunk-2ICNHUG6.js';
|
|
2
|
+
import '../chunk-WAMZWZJB.js';
|
|
3
3
|
import '../chunk-CEXAQQ5W.js';
|
|
4
4
|
import '../chunk-RNTDBX6S.js';
|
|
5
5
|
import '../chunk-46QI6GFC.js';
|
package/docs/en/components.md
CHANGED
|
@@ -113,7 +113,12 @@ here they're grouped by what they're for.
|
|
|
113
113
|
|
|
114
114
|
## `@squadbase/vantage/components`
|
|
115
115
|
|
|
116
|
-
Dashboard parts composed from `ui/`.
|
|
116
|
+
Dashboard parts composed from `ui/`. Their source of truth is SquadKit; Vantage re-exports them.
|
|
117
|
+
|
|
118
|
+
Show a KPI with [`KpiCard`](parts/kpi-card) and a change with
|
|
119
|
+
[`Delta`](parts/delta) (pass `comparison` and `polarity`).
|
|
120
|
+
[`TrendIndicator`](parts/trend-indicator) is deprecated. Number formatting and the
|
|
121
|
+
change calculation live in [format / comparison](parts/format).
|
|
117
122
|
|
|
118
123
|
| Component | What it is |
|
|
119
124
|
| --- | --- |
|
|
@@ -130,8 +135,10 @@ Dashboard parts composed from `ui/`.
|
|
|
130
135
|
| [`SegmentedControl`](parts/segmented-control) | Single-choice segments |
|
|
131
136
|
| [`SearchableSelect`](parts/searchable-select) | Single choice with search |
|
|
132
137
|
| [`MultiSelect`](parts/multi-select) | Multiple choice with search |
|
|
138
|
+
| [`KpiCard`](parts/kpi-card) | One KPI as a card: value, change, previous actual, conclusion |
|
|
139
|
+
| [`Delta`](parts/delta) | The change against a comparison, derived from the values |
|
|
133
140
|
| [`MetricValue`](parts/metric-value) | A KPI's number and unit |
|
|
134
|
-
| [`TrendIndicator`](parts/trend-indicator) |
|
|
141
|
+
| [`TrendIndicator`](parts/trend-indicator) | Deprecated — use `Delta` |
|
|
135
142
|
| [`StatusBadge`](parts/status-badge) | A dot-and-label status badge |
|
|
136
143
|
| [`Placeholder`](parts/placeholder) | An inline marker for sample data |
|
|
137
144
|
|
|
@@ -154,9 +161,8 @@ import {
|
|
|
154
161
|
PageShellHeaderEnd,
|
|
155
162
|
PageShellActions,
|
|
156
163
|
PageShellContent,
|
|
164
|
+
KpiCard,
|
|
157
165
|
DashboardCardPreset,
|
|
158
|
-
MetricValue,
|
|
159
|
-
TrendIndicator,
|
|
160
166
|
EChart,
|
|
161
167
|
type EChartsOption,
|
|
162
168
|
} from "@squadbase/vantage/components";
|
|
@@ -184,17 +190,25 @@ export default function Overview() {
|
|
|
184
190
|
|
|
185
191
|
<PageShellContent>
|
|
186
192
|
<div className="grid gap-4 md:grid-cols-3">
|
|
187
|
-
<
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
193
|
+
<KpiCard
|
|
194
|
+
label="Revenue"
|
|
195
|
+
value={1_240_000}
|
|
196
|
+
format="currency"
|
|
197
|
+
comparison={{ previous: 1_103_000, vs: "prior-period" }}
|
|
198
|
+
/>
|
|
199
|
+
<KpiCard
|
|
200
|
+
label="New customers"
|
|
201
|
+
value={128}
|
|
202
|
+
format="number"
|
|
203
|
+
comparison={{ previous: 132, vs: "prior-period" }}
|
|
204
|
+
/>
|
|
205
|
+
<KpiCard
|
|
206
|
+
label="Churn"
|
|
207
|
+
value={0.021}
|
|
208
|
+
format={{ type: "percent", digits: 1 }}
|
|
209
|
+
comparison={{ previous: 0.026, vs: "prior-period" }}
|
|
210
|
+
polarity="lower-is-better"
|
|
211
|
+
/>
|
|
198
212
|
</div>
|
|
199
213
|
|
|
200
214
|
<DashboardCardPreset title="Monthly revenue" className="mt-4">
|
|
@@ -56,6 +56,28 @@ it.
|
|
|
56
56
|
|
|
57
57
|
`useDataTable()` gives a child component the TanStack `table` instance directly.
|
|
58
58
|
|
|
59
|
+
## Column formats and CSV export
|
|
60
|
+
|
|
61
|
+
A column without `cell` can format its number with `meta.format` (right-aligned, tabular-nums; null shows `meta.nullLabel`, default `—`). Pass a function when the currency changes per row. `DataTableExport` writes a BOM-prefixed UTF-8 CSV in the same sorted, filtered order as the screen; with `DataTablePreset`, `exportable` alone adds it to the toolbar.
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
const columns: ColumnDef<Row>[] = [
|
|
65
|
+
{ accessorKey: "month", header: "Month" },
|
|
66
|
+
{
|
|
67
|
+
accessorKey: "revenue",
|
|
68
|
+
header: "Revenue",
|
|
69
|
+
meta: { format: (row) => ({ type: "currency", currency: row.currency, notation: "standard" }) },
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
|
|
73
|
+
<DataTable columns={columns} data={rows}>
|
|
74
|
+
<DataTableToolbar toolbar={<DataTableExport fileName="sales.csv" />} />
|
|
75
|
+
<DataTableContent />
|
|
76
|
+
</DataTable>;
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
`values="raw"` exports raw values; `scope="page"` exports only the visible page. For server-side paging, `rowCount` (total rows), `manualSorting`, `manualFiltering` and `isLoading` are also available.
|
|
80
|
+
|
|
59
81
|
## Paginating on the server
|
|
60
82
|
|
|
61
83
|
Own `pagination` and `onPaginationChange`, and pass the total in `pageCount`.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Delta
|
|
2
|
+
|
|
3
|
+
> The change against a comparison — arrow, signed rate and label, all derived from the values.
|
|
4
|
+
|
|
5
|
+
Shows a change as one line: "↑ +12.4% 前期比". **Direction, rate, colour and wording are all computed
|
|
6
|
+
from `value` and `comparison`** and cannot be passed in, so the arrow and the colour can never disagree.
|
|
7
|
+
Colour is never the only signal — the arrow and the sign always accompany it. For metrics where a rise
|
|
8
|
+
is bad (churn, error rate), pass `polarity="lower-is-better"`.
|
|
9
|
+
|
|
10
|
+
It replaces the deprecated [`TrendIndicator`](parts/trend-indicator).
|
|
11
|
+
|
|
12
|
+
```tsx
|
|
13
|
+
import { Delta } from "@squadbase/vantage/components";
|
|
14
|
+
import type { DeltaProps, Comparison, Polarity } from "@squadbase/vantage/components";
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
| Prop | Type | Default | Description |
|
|
18
|
+
| --- | --- | --- | --- |
|
|
19
|
+
| `value` | `number \| null \| undefined` | | The current value. **Required.** The previous one comes from `comparison`. |
|
|
20
|
+
| `comparison` | `Comparison` | | What the value is compared against. **Required**, so the change always carries its label. See below. |
|
|
21
|
+
| `polarity` | `"higher-is-better" \| "lower-is-better"` | `"higher-is-better"` | Whether a rise is good. |
|
|
22
|
+
| `neutralBand` | `number` | `0.01` | Absolute ratio below which the change reads as flat. Default 1%. |
|
|
23
|
+
| `variant` | `"badge" \| "inline"` | `"badge"` | A bordered badge, or plain text for use inline. |
|
|
24
|
+
| `locale` | `string` | `"ja-JP"` | Locale for the percent. |
|
|
25
|
+
| `showLabel` | `boolean` | `true` | Show the comparison label ("前期比") after the percent. |
|
|
26
|
+
| `className` | `string` | | Classes to add. |
|
|
27
|
+
|
|
28
|
+
## Comparison
|
|
29
|
+
|
|
30
|
+
| Prop | Type | Description |
|
|
31
|
+
| --- | --- | --- |
|
|
32
|
+
| `previous` | `number \| null \| undefined` | The value compared against. `null` or `0` yields no rate, shown as "—". |
|
|
33
|
+
| `vs` | `"prior-period" \| "prior-year" \| "target"` | The kind of comparison. Default labels: 前期比 / 前年同期比 / 目標比. |
|
|
34
|
+
| `label` | `string` | Override the label (e.g. "vs last week"). |
|
|
35
|
+
|
|
36
|
+
## Migrating from TrendIndicator
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
// Before: direction and colour chosen by hand
|
|
40
|
+
<TrendIndicator value={12.4} direction="up" />
|
|
41
|
+
|
|
42
|
+
// After: pass the current and previous values
|
|
43
|
+
<Delta value={1_240_000} comparison={{ previous: 1_103_000, vs: "prior-period" }} />
|
|
44
|
+
|
|
45
|
+
// A metric where down is good
|
|
46
|
+
<Delta value={0.021} comparison={{ previous: 0.026, vs: "prior-period" }} polarity="lower-is-better" />
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The colours come from the `--positive` / `--negative` / `--neutral` tokens. To show a KPI as a whole
|
|
50
|
+
card, [`KpiCard`](parts/kpi-card) uses `Delta` inside.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# format / comparison
|
|
2
|
+
|
|
3
|
+
> The number formatting (formatValue) and change calculation (computeComparison) shared by KPIs, tables and charts.
|
|
4
|
+
|
|
5
|
+
The formatting and comparison logic that `KpiCard` / `Delta` use internally, exposed as functions. Use
|
|
6
|
+
them when a table cell or a chart's `valueFormatter` should match the KPIs. Shortening (e.g. "4.8億")
|
|
7
|
+
is left to `Intl.NumberFormat`; no unit strings are hard-coded.
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import {
|
|
11
|
+
formatValue,
|
|
12
|
+
formatDelta,
|
|
13
|
+
toValueFormatter,
|
|
14
|
+
computeComparison,
|
|
15
|
+
} from "@squadbase/vantage/components";
|
|
16
|
+
import type { ValueFormat, Comparison, ComparisonResult } from "@squadbase/vantage/components";
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## ValueFormat
|
|
20
|
+
|
|
21
|
+
One of `"number" | "compact" | "currency" | "percent" | "multiple"`, or `{ type, digits?, currency? }`.
|
|
22
|
+
The default format is `"compact"`, the default currency `JPY`, the default locale `"ja-JP"`. `percent`
|
|
23
|
+
takes a ratio (`0.124` → 12.4%). `null` / `undefined` / `NaN` format as "—".
|
|
24
|
+
|
|
25
|
+
| Prop | Type | Description |
|
|
26
|
+
| --- | --- | --- |
|
|
27
|
+
| `formatValue(value, format?, locale?)` | `string` | Format a value. |
|
|
28
|
+
| `formatDelta(value, format?, locale?)` | `string` | For differences: always signed except zero (`+12.4%`). |
|
|
29
|
+
| `toValueFormatter(format?, locale?)` | `(value) => string` | A one-argument formatter with the format and locale bound — fits a chart's `valueFormatter`. |
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
formatValue(48_200_000, "currency"); // "¥48,200,000"
|
|
33
|
+
formatValue(0.021, { type: "percent", digits: 1 }); // "2.1%"
|
|
34
|
+
<LineChart valueFormatter={toValueFormatter("compact")} … />
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## computeComparison
|
|
38
|
+
|
|
39
|
+
`computeComparison(current, comparison, { polarity?, neutralBand? })` returns
|
|
40
|
+
`{ current, previous, difference, ratio, direction, sentiment, label, vs }`. A rate is produced only
|
|
41
|
+
when the previous value is a non-zero number; moves inside `neutralBand` (default 0.01) give
|
|
42
|
+
`direction: "flat"`. `sentiment` (`"positive" | "negative" | "neutral"`) follows `polarity`. Leave the
|
|
43
|
+
rendering to [`Delta`](parts/delta) rather than building arrows and colours yourself.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# KpiCard
|
|
2
|
+
|
|
3
|
+
> One KPI as a card — value, change, previous actual and a one-line conclusion, all derived from numbers.
|
|
4
|
+
|
|
5
|
+
A card that shows one KPI. **Pass numbers and enums only**, and it lays out, top to bottom: the metric
|
|
6
|
+
name → the value → the change ([`Delta`](parts/delta)) → the previous actual → a
|
|
7
|
+
one-sentence conclusion. Direction, rate, colour, remaining-to-target, achievement and record highs are
|
|
8
|
+
all computed inside the card, so no two props can disagree. Reach for this before composing a KPI tile
|
|
9
|
+
from `DashboardCardPreset` + `MetricValue`.
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { KpiCard } from "@squadbase/vantage/components";
|
|
13
|
+
import type { KpiCardProps, KpiCardSource, Comparison, Polarity, ValueFormat } from "@squadbase/vantage/components";
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
| Prop | Type | Default | Description |
|
|
17
|
+
| --- | --- | --- | --- |
|
|
18
|
+
| `label` | `string` | | The metric name. **Required.** |
|
|
19
|
+
| `value` | `number \| null \| undefined` | | The current value. **Required.** `null` / `undefined` renders "—". |
|
|
20
|
+
| `format` | `ValueFormat` | `"compact"` | How the value is formatted (see the format / comparison page); also used for previous, target and remaining. |
|
|
21
|
+
| `locale` | `string` | `"ja-JP"` | The formatting locale. |
|
|
22
|
+
| `comparison` | `Comparison` | | What the value is compared against (`{ previous, vs, label? }`). Adds the change and the previous-actual line. |
|
|
23
|
+
| `polarity` | `"higher-is-better" \| "lower-is-better"` | `"higher-is-better"` | Whether a rise is good. Use `"lower-is-better"` for metrics like churn. |
|
|
24
|
+
| `neutralBand` | `number` | `0.01` | Absolute ratio below which the change reads as flat. |
|
|
25
|
+
| `showPrevious` | `boolean` | `true` | Show the previous actual ("前期 400"). Needs `comparison`. |
|
|
26
|
+
| `summary` | `string` | | The conclusion sentence, as a **template** whose placeholders (below) the card fills. |
|
|
27
|
+
| `target` | `number` | | Target for the current period; adds a remaining / achievement line. |
|
|
28
|
+
| `period` | `{ start: Date \| string \| number; end: Date \| string \| number }` | | The current period. With `target`, adds a pace projection (marked 見込み) while the period is in progress. |
|
|
29
|
+
| `history` | `ReadonlyArray<number \| null \| undefined>` | | Series ending at the current period (last point = `value`); adds a record badge. |
|
|
30
|
+
| `historyGrain` | `"day" \| "week" \| "month" \| "quarter" \| "year"` | `"month"` | The grain of `history`. |
|
|
31
|
+
| `source` | `{ period?: string; count?: number; name?: string }` | | A data-source footnote (period, row count, source name). |
|
|
32
|
+
| `updatedAt` | `Date \| string \| number` | | When the data was last refreshed; shown as relative time. |
|
|
33
|
+
| `now` | `Date \| number` | | Reference time for the projection and relative time (for deterministic rendering). |
|
|
34
|
+
| `isLoading` | `boolean` | `false` | Render a skeleton with the final shape instead of the values. |
|
|
35
|
+
| `className` | `string` | | Classes to add. |
|
|
36
|
+
|
|
37
|
+
## Summary placeholders
|
|
38
|
+
|
|
39
|
+
`{value}` `{delta}` `{difference}` `{previous}` `{label}` `{target}` `{achievement}` `{remaining}`.
|
|
40
|
+
Unknown placeholders are left as written; a known one whose value is missing becomes "—".
|
|
41
|
+
|
|
42
|
+
> [!WARNING]
|
|
43
|
+
> **Never put numbers in the template itself.** Insert every number through a placeholder, so the
|
|
44
|
+
> sentence can't go stale when the value changes.
|
|
45
|
+
|
|
46
|
+
```tsx
|
|
47
|
+
<KpiCard
|
|
48
|
+
label="Revenue"
|
|
49
|
+
value={48_200_000}
|
|
50
|
+
format="currency"
|
|
51
|
+
comparison={{ previous: 42_900_000, vs: "prior-period" }}
|
|
52
|
+
summary="{label} grew {difference} ({delta}) on last month."
|
|
53
|
+
/>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The card's built-in wording (labels such as 前期比 and 目標まであと) is Japanese. To place just the
|
|
57
|
+
change inside a table or tile, use [`Delta`](parts/delta) on its own.
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
> The KPI number, with MetricUnit for the unit.
|
|
4
4
|
|
|
5
|
-
A tight-tracking display for a KPI's number. Units and other trailing text go in `MetricUnit`.
|
|
5
|
+
A tight-tracking display for a KPI's number. Units and other trailing text go in `MetricUnit`. For a whole KPI
|
|
6
|
+
tile, consider [`KpiCard`](parts/kpi-card) first — it also shows the change and the previous actual.
|
|
6
7
|
|
|
7
8
|
```tsx
|
|
8
9
|
import { MetricValue, MetricUnit, metricValueVariants } from "@squadbase/vantage/components";
|
|
@@ -18,6 +19,6 @@ It carries vertical margin (`my-4`) by default. Inside a card, pass `className="
|
|
|
18
19
|
```tsx
|
|
19
20
|
<DashboardCardPreset title="Revenue">
|
|
20
21
|
<MetricValue className="my-0">$12,400</MetricValue>
|
|
21
|
-
<
|
|
22
|
+
<Delta value={12_400} comparison={{ previous: 11_030, vs: "prior-period" }} />
|
|
22
23
|
</DashboardCardPreset>
|
|
23
24
|
```
|
|
@@ -44,4 +44,4 @@ series. `Sparkline` conveys the *shape* of a series and nothing else — **no ti
|
|
|
44
44
|
> [!NOTE]
|
|
45
45
|
> It is `aria-hidden="true"`, so screen readers skip it. Put the actual number next to it as text —
|
|
46
46
|
> [`MetricValue`](parts/metric-value) or
|
|
47
|
-
> [`
|
|
47
|
+
> [`Delta`](parts/delta).
|
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
# TrendIndicator
|
|
2
2
|
|
|
3
|
-
> An arrow and a percentage
|
|
3
|
+
> Deprecated — use Delta for new code. An arrow and a percentage.
|
|
4
|
+
|
|
5
|
+
> [!WARNING]
|
|
6
|
+
> **Deprecated. Use [`Delta`](parts/delta) in new code.** `TrendIndicator` takes the
|
|
7
|
+
> direction and colour by hand, so the value and the arrow can disagree. `Delta` computes direction,
|
|
8
|
+
> rate, colour and label from the current and compared values. To show a KPI as a card, use
|
|
9
|
+
> [`KpiCard`](parts/kpi-card).
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
// Before
|
|
13
|
+
<TrendIndicator value={12.4} direction="up" />
|
|
14
|
+
<TrendIndicator value={0.4} direction="down" positiveIsGood={false} />
|
|
15
|
+
|
|
16
|
+
// After
|
|
17
|
+
<Delta value={1_240_000} comparison={{ previous: 1_103_000, vs: "prior-period" }} />
|
|
18
|
+
<Delta value={0.021} comparison={{ previous: 0.026, vs: "prior-period" }} polarity="lower-is-better" />
|
|
19
|
+
```
|
|
4
20
|
|
|
5
21
|
Shows a change as an arrow plus a percentage. **Up doesn't always mean good**, so the colour comes
|
|
6
22
|
from `direction` combined with `positiveIsGood` — pass `positiveIsGood={false}` for metrics like
|
|
@@ -36,7 +36,7 @@ In `/ui` (a selection): `Button`, `Card`, the `Table` primitives, `Tabs`, `Input
|
|
|
36
36
|
`DropdownMenu`, `Sidebar`, `Alert` / `Skeleton` / `Spinner`, `Loading` / `Empty` / `ErrorState`.
|
|
37
37
|
|
|
38
38
|
In `/components` (a selection): `PageShell`, `AppShell`, `DashboardCard`, `DataTable`, `EChart`,
|
|
39
|
-
`FunnelSteps`, `FilterBar`, `DateRangePicker`, `
|
|
39
|
+
`FunnelSteps`, `FilterBar`, `DateRangePicker`, `KpiCard`, `Delta`.
|
|
40
40
|
|
|
41
41
|
Props and usage for every component live in the [Components](components) tab.
|
|
42
42
|
|
package/docs/index.json
CHANGED
|
@@ -694,6 +694,16 @@
|
|
|
694
694
|
"file": "ja/parts/date-range-picker.md",
|
|
695
695
|
"order": 7
|
|
696
696
|
},
|
|
697
|
+
{
|
|
698
|
+
"slug": "parts/delta",
|
|
699
|
+
"lang": "ja",
|
|
700
|
+
"section": "components/parts",
|
|
701
|
+
"sectionTitle": "@squadbase/vantage/components",
|
|
702
|
+
"title": "Delta",
|
|
703
|
+
"description": "比較相手に対する増減。矢印・符号付きの率・比較ラベルを値から導く。",
|
|
704
|
+
"file": "ja/parts/delta.md",
|
|
705
|
+
"order": 8
|
|
706
|
+
},
|
|
697
707
|
{
|
|
698
708
|
"slug": "parts/donut-chart",
|
|
699
709
|
"lang": "ja",
|
|
@@ -702,7 +712,7 @@
|
|
|
702
712
|
"title": "DonutChart",
|
|
703
713
|
"description": "構成比を見せる型付きのドーナツ / 円グラフ。中央に合計を出す。",
|
|
704
714
|
"file": "ja/parts/donut-chart.md",
|
|
705
|
-
"order":
|
|
715
|
+
"order": 9
|
|
706
716
|
},
|
|
707
717
|
{
|
|
708
718
|
"slug": "parts/echart",
|
|
@@ -712,7 +722,7 @@
|
|
|
712
722
|
"title": "EChart",
|
|
713
723
|
"description": "Apache ECharts の薄いラッパー。配色はテーマトークンに追従する。",
|
|
714
724
|
"file": "ja/parts/echart.md",
|
|
715
|
-
"order":
|
|
725
|
+
"order": 10
|
|
716
726
|
},
|
|
717
727
|
{
|
|
718
728
|
"slug": "parts/filter-bar",
|
|
@@ -722,7 +732,17 @@
|
|
|
722
732
|
"title": "FilterBar",
|
|
723
733
|
"description": "フィルタ一式を 1 つの値オブジェクトで扱う行。",
|
|
724
734
|
"file": "ja/parts/filter-bar.md",
|
|
725
|
-
"order":
|
|
735
|
+
"order": 11
|
|
736
|
+
},
|
|
737
|
+
{
|
|
738
|
+
"slug": "parts/format",
|
|
739
|
+
"lang": "ja",
|
|
740
|
+
"section": "components/parts",
|
|
741
|
+
"sectionTitle": "@squadbase/vantage/components",
|
|
742
|
+
"title": "format / comparison",
|
|
743
|
+
"description": "KPI・表・グラフで共有する数値の書式(formatValue)と、増減の計算(computeComparison)。",
|
|
744
|
+
"file": "ja/parts/format.md",
|
|
745
|
+
"order": 12
|
|
726
746
|
},
|
|
727
747
|
{
|
|
728
748
|
"slug": "parts/funnel-steps",
|
|
@@ -732,7 +752,17 @@
|
|
|
732
752
|
"title": "FunnelSteps",
|
|
733
753
|
"description": "ファネルの各段を棒で示す。転換率も出せる。",
|
|
734
754
|
"file": "ja/parts/funnel-steps.md",
|
|
735
|
-
"order":
|
|
755
|
+
"order": 13
|
|
756
|
+
},
|
|
757
|
+
{
|
|
758
|
+
"slug": "parts/kpi-card",
|
|
759
|
+
"lang": "ja",
|
|
760
|
+
"section": "components/parts",
|
|
761
|
+
"sectionTitle": "@squadbase/vantage/components",
|
|
762
|
+
"title": "KpiCard",
|
|
763
|
+
"description": "KPI 1 つ分のカード。値・増減・前期実績・結論の 1 文までを数値から組み立てる。",
|
|
764
|
+
"file": "ja/parts/kpi-card.md",
|
|
765
|
+
"order": 14
|
|
736
766
|
},
|
|
737
767
|
{
|
|
738
768
|
"slug": "parts/line-chart",
|
|
@@ -742,7 +772,7 @@
|
|
|
742
772
|
"title": "LineChart",
|
|
743
773
|
"description": "推移を線で見せる型付きグラフ。行・x 軸の列・系列の列を渡すだけ。",
|
|
744
774
|
"file": "ja/parts/line-chart.md",
|
|
745
|
-
"order":
|
|
775
|
+
"order": 15
|
|
746
776
|
},
|
|
747
777
|
{
|
|
748
778
|
"slug": "parts/metric-value",
|
|
@@ -752,7 +782,7 @@
|
|
|
752
782
|
"title": "MetricValue",
|
|
753
783
|
"description": "KPI の数値。単位は MetricUnit で。",
|
|
754
784
|
"file": "ja/parts/metric-value.md",
|
|
755
|
-
"order":
|
|
785
|
+
"order": 16
|
|
756
786
|
},
|
|
757
787
|
{
|
|
758
788
|
"slug": "parts/multi-select",
|
|
@@ -762,7 +792,7 @@
|
|
|
762
792
|
"title": "MultiSelect",
|
|
763
793
|
"description": "検索できる複数選択。選択はチップで表示。",
|
|
764
794
|
"file": "ja/parts/multi-select.md",
|
|
765
|
-
"order":
|
|
795
|
+
"order": 17
|
|
766
796
|
},
|
|
767
797
|
{
|
|
768
798
|
"slug": "parts/page-shell",
|
|
@@ -772,7 +802,7 @@
|
|
|
772
802
|
"title": "PageShell",
|
|
773
803
|
"description": "ヘッダー帯・サマリー・本文からなるページ枠。",
|
|
774
804
|
"file": "ja/parts/page-shell.md",
|
|
775
|
-
"order":
|
|
805
|
+
"order": 18
|
|
776
806
|
},
|
|
777
807
|
{
|
|
778
808
|
"slug": "parts/placeholder",
|
|
@@ -782,7 +812,7 @@
|
|
|
782
812
|
"title": "Placeholder",
|
|
783
813
|
"description": "仮データであることを示す、インラインの目印。",
|
|
784
814
|
"file": "ja/parts/placeholder.md",
|
|
785
|
-
"order":
|
|
815
|
+
"order": 19
|
|
786
816
|
},
|
|
787
817
|
{
|
|
788
818
|
"slug": "parts/progress-circle",
|
|
@@ -792,7 +822,7 @@
|
|
|
792
822
|
"title": "ProgressCircle",
|
|
793
823
|
"description": "目標に対する達成率をリングで示す。中央に任意の内容を置ける。",
|
|
794
824
|
"file": "ja/parts/progress-circle.md",
|
|
795
|
-
"order":
|
|
825
|
+
"order": 20
|
|
796
826
|
},
|
|
797
827
|
{
|
|
798
828
|
"slug": "parts/searchable-select",
|
|
@@ -802,7 +832,7 @@
|
|
|
802
832
|
"title": "SearchableSelect",
|
|
803
833
|
"description": "検索できる単一選択。候補が多いときに。",
|
|
804
834
|
"file": "ja/parts/searchable-select.md",
|
|
805
|
-
"order":
|
|
835
|
+
"order": 21
|
|
806
836
|
},
|
|
807
837
|
{
|
|
808
838
|
"slug": "parts/section-header",
|
|
@@ -812,7 +842,7 @@
|
|
|
812
842
|
"title": "SectionHeader",
|
|
813
843
|
"description": "セクションの見出しとアクション。",
|
|
814
844
|
"file": "ja/parts/section-header.md",
|
|
815
|
-
"order":
|
|
845
|
+
"order": 22
|
|
816
846
|
},
|
|
817
847
|
{
|
|
818
848
|
"slug": "parts/segmented-control",
|
|
@@ -822,7 +852,7 @@
|
|
|
822
852
|
"title": "SegmentedControl",
|
|
823
853
|
"description": "単一選択のセグメント。ToggleGroup の配列を隠す。",
|
|
824
854
|
"file": "ja/parts/segmented-control.md",
|
|
825
|
-
"order":
|
|
855
|
+
"order": 23
|
|
826
856
|
},
|
|
827
857
|
{
|
|
828
858
|
"slug": "parts/sparkline",
|
|
@@ -832,7 +862,7 @@
|
|
|
832
862
|
"title": "Sparkline",
|
|
833
863
|
"description": "表のセルや KPI タイルに置く、インラインの推移グラフ。",
|
|
834
864
|
"file": "ja/parts/sparkline.md",
|
|
835
|
-
"order":
|
|
865
|
+
"order": 24
|
|
836
866
|
},
|
|
837
867
|
{
|
|
838
868
|
"slug": "parts/status-badge",
|
|
@@ -842,7 +872,7 @@
|
|
|
842
872
|
"title": "StatusBadge",
|
|
843
873
|
"description": "ドット付きのステータスバッジ。色は名前で決まる。",
|
|
844
874
|
"file": "ja/parts/status-badge.md",
|
|
845
|
-
"order":
|
|
875
|
+
"order": 25
|
|
846
876
|
},
|
|
847
877
|
{
|
|
848
878
|
"slug": "parts/tracker",
|
|
@@ -852,7 +882,7 @@
|
|
|
852
882
|
"title": "Tracker",
|
|
853
883
|
"description": "期間ごとの状態を小さなブロックの列で示す。稼働状況やバッチの結果に。",
|
|
854
884
|
"file": "ja/parts/tracker.md",
|
|
855
|
-
"order":
|
|
885
|
+
"order": 26
|
|
856
886
|
},
|
|
857
887
|
{
|
|
858
888
|
"slug": "parts/trend-indicator",
|
|
@@ -860,9 +890,9 @@
|
|
|
860
890
|
"section": "components/parts",
|
|
861
891
|
"sectionTitle": "@squadbase/vantage/components",
|
|
862
892
|
"title": "TrendIndicator",
|
|
863
|
-
"description": "
|
|
893
|
+
"description": "非推奨。新規は Delta を使う。増減の矢印と変化率。",
|
|
864
894
|
"file": "ja/parts/trend-indicator.md",
|
|
865
|
-
"order":
|
|
895
|
+
"order": 27
|
|
866
896
|
},
|
|
867
897
|
{
|
|
868
898
|
"slug": "markdown/markdown-renderer",
|
|
@@ -1476,6 +1506,16 @@
|
|
|
1476
1506
|
"file": "en/parts/date-range-picker.md",
|
|
1477
1507
|
"order": 3
|
|
1478
1508
|
},
|
|
1509
|
+
{
|
|
1510
|
+
"slug": "parts/delta",
|
|
1511
|
+
"lang": "en",
|
|
1512
|
+
"section": "components/parts",
|
|
1513
|
+
"sectionTitle": "@squadbase/vantage/components",
|
|
1514
|
+
"title": "Delta",
|
|
1515
|
+
"description": "The change against a comparison — arrow, signed rate and label, all derived from the values.",
|
|
1516
|
+
"file": "en/parts/delta.md",
|
|
1517
|
+
"order": 4
|
|
1518
|
+
},
|
|
1479
1519
|
{
|
|
1480
1520
|
"slug": "parts/echart",
|
|
1481
1521
|
"lang": "en",
|
|
@@ -1484,7 +1524,7 @@
|
|
|
1484
1524
|
"title": "EChart",
|
|
1485
1525
|
"description": "A thin Apache ECharts wrapper whose colours follow the theme tokens.",
|
|
1486
1526
|
"file": "en/parts/echart.md",
|
|
1487
|
-
"order":
|
|
1527
|
+
"order": 5
|
|
1488
1528
|
},
|
|
1489
1529
|
{
|
|
1490
1530
|
"slug": "parts/filter-bar",
|
|
@@ -1494,7 +1534,17 @@
|
|
|
1494
1534
|
"title": "FilterBar",
|
|
1495
1535
|
"description": "A row of filters driven by one value object.",
|
|
1496
1536
|
"file": "en/parts/filter-bar.md",
|
|
1497
|
-
"order":
|
|
1537
|
+
"order": 6
|
|
1538
|
+
},
|
|
1539
|
+
{
|
|
1540
|
+
"slug": "parts/format",
|
|
1541
|
+
"lang": "en",
|
|
1542
|
+
"section": "components/parts",
|
|
1543
|
+
"sectionTitle": "@squadbase/vantage/components",
|
|
1544
|
+
"title": "format / comparison",
|
|
1545
|
+
"description": "The number formatting (formatValue) and change calculation (computeComparison) shared by KPIs, tables and charts.",
|
|
1546
|
+
"file": "en/parts/format.md",
|
|
1547
|
+
"order": 7
|
|
1498
1548
|
},
|
|
1499
1549
|
{
|
|
1500
1550
|
"slug": "parts/funnel-steps",
|
|
@@ -1504,7 +1554,17 @@
|
|
|
1504
1554
|
"title": "FunnelSteps",
|
|
1505
1555
|
"description": "A funnel drawn as bars, with conversion rates.",
|
|
1506
1556
|
"file": "en/parts/funnel-steps.md",
|
|
1507
|
-
"order":
|
|
1557
|
+
"order": 8
|
|
1558
|
+
},
|
|
1559
|
+
{
|
|
1560
|
+
"slug": "parts/kpi-card",
|
|
1561
|
+
"lang": "en",
|
|
1562
|
+
"section": "components/parts",
|
|
1563
|
+
"sectionTitle": "@squadbase/vantage/components",
|
|
1564
|
+
"title": "KpiCard",
|
|
1565
|
+
"description": "One KPI as a card — value, change, previous actual and a one-line conclusion, all derived from numbers.",
|
|
1566
|
+
"file": "en/parts/kpi-card.md",
|
|
1567
|
+
"order": 9
|
|
1508
1568
|
},
|
|
1509
1569
|
{
|
|
1510
1570
|
"slug": "parts/metric-value",
|
|
@@ -1514,7 +1574,7 @@
|
|
|
1514
1574
|
"title": "MetricValue",
|
|
1515
1575
|
"description": "The KPI number, with MetricUnit for the unit.",
|
|
1516
1576
|
"file": "en/parts/metric-value.md",
|
|
1517
|
-
"order":
|
|
1577
|
+
"order": 10
|
|
1518
1578
|
},
|
|
1519
1579
|
{
|
|
1520
1580
|
"slug": "parts/multi-select",
|
|
@@ -1524,7 +1584,7 @@
|
|
|
1524
1584
|
"title": "MultiSelect",
|
|
1525
1585
|
"description": "Multiple choice with search; selections show as chips.",
|
|
1526
1586
|
"file": "en/parts/multi-select.md",
|
|
1527
|
-
"order":
|
|
1587
|
+
"order": 11
|
|
1528
1588
|
},
|
|
1529
1589
|
{
|
|
1530
1590
|
"slug": "parts/page-shell",
|
|
@@ -1534,7 +1594,7 @@
|
|
|
1534
1594
|
"title": "PageShell",
|
|
1535
1595
|
"description": "The page frame: header band, summary row, content.",
|
|
1536
1596
|
"file": "en/parts/page-shell.md",
|
|
1537
|
-
"order":
|
|
1597
|
+
"order": 12
|
|
1538
1598
|
},
|
|
1539
1599
|
{
|
|
1540
1600
|
"slug": "parts/placeholder",
|
|
@@ -1544,7 +1604,7 @@
|
|
|
1544
1604
|
"title": "Placeholder",
|
|
1545
1605
|
"description": "An inline marker for sample, not-yet-real data.",
|
|
1546
1606
|
"file": "en/parts/placeholder.md",
|
|
1547
|
-
"order":
|
|
1607
|
+
"order": 13
|
|
1548
1608
|
},
|
|
1549
1609
|
{
|
|
1550
1610
|
"slug": "parts/searchable-select",
|
|
@@ -1554,7 +1614,7 @@
|
|
|
1554
1614
|
"title": "SearchableSelect",
|
|
1555
1615
|
"description": "Single choice with search, for long option lists.",
|
|
1556
1616
|
"file": "en/parts/searchable-select.md",
|
|
1557
|
-
"order":
|
|
1617
|
+
"order": 14
|
|
1558
1618
|
},
|
|
1559
1619
|
{
|
|
1560
1620
|
"slug": "parts/section-header",
|
|
@@ -1564,7 +1624,7 @@
|
|
|
1564
1624
|
"title": "SectionHeader",
|
|
1565
1625
|
"description": "A section heading with its actions.",
|
|
1566
1626
|
"file": "en/parts/section-header.md",
|
|
1567
|
-
"order":
|
|
1627
|
+
"order": 15
|
|
1568
1628
|
},
|
|
1569
1629
|
{
|
|
1570
1630
|
"slug": "parts/segmented-control",
|
|
@@ -1574,7 +1634,7 @@
|
|
|
1574
1634
|
"title": "SegmentedControl",
|
|
1575
1635
|
"description": "Single-choice segments — it hides ToggleGroup's array.",
|
|
1576
1636
|
"file": "en/parts/segmented-control.md",
|
|
1577
|
-
"order":
|
|
1637
|
+
"order": 16
|
|
1578
1638
|
},
|
|
1579
1639
|
{
|
|
1580
1640
|
"slug": "parts/sparkline",
|
|
@@ -1584,7 +1644,7 @@
|
|
|
1584
1644
|
"title": "Sparkline",
|
|
1585
1645
|
"description": "An inline trend chart for table cells and KPI tiles.",
|
|
1586
1646
|
"file": "en/parts/sparkline.md",
|
|
1587
|
-
"order":
|
|
1647
|
+
"order": 17
|
|
1588
1648
|
},
|
|
1589
1649
|
{
|
|
1590
1650
|
"slug": "parts/status-badge",
|
|
@@ -1594,7 +1654,7 @@
|
|
|
1594
1654
|
"title": "StatusBadge",
|
|
1595
1655
|
"description": "A dot-and-label status badge, coloured by name.",
|
|
1596
1656
|
"file": "en/parts/status-badge.md",
|
|
1597
|
-
"order":
|
|
1657
|
+
"order": 18
|
|
1598
1658
|
},
|
|
1599
1659
|
{
|
|
1600
1660
|
"slug": "parts/trend-indicator",
|
|
@@ -1602,9 +1662,9 @@
|
|
|
1602
1662
|
"section": "components/parts",
|
|
1603
1663
|
"sectionTitle": "@squadbase/vantage/components",
|
|
1604
1664
|
"title": "TrendIndicator",
|
|
1605
|
-
"description": "An arrow and a percentage
|
|
1665
|
+
"description": "Deprecated — use Delta for new code. An arrow and a percentage.",
|
|
1606
1666
|
"file": "en/parts/trend-indicator.md",
|
|
1607
|
-
"order":
|
|
1667
|
+
"order": 19
|
|
1608
1668
|
},
|
|
1609
1669
|
{
|
|
1610
1670
|
"slug": "markdown/markdown-renderer",
|