@squadbase/vantage 0.6.2-dev1.42c4e48 → 0.6.2-dev1.51e401a
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-U7GO26HR.js} +7 -7
- package/dist/{build-MFWRPYKW.js.map → build-U7GO26HR.js.map} +1 -1
- package/dist/{check-ZBIH422T.js → check-MRVAIHG5.js} +5 -5
- package/dist/{check-ZBIH422T.js.map → check-MRVAIHG5.js.map} +1 -1
- package/dist/chunk-2IAPIOPS.js +152 -0
- package/dist/chunk-2IAPIOPS.js.map +1 -0
- package/dist/chunk-3RJEOP3J.js +174 -0
- package/dist/chunk-3RJEOP3J.js.map +1 -0
- package/dist/chunk-77CISBMG.js +7581 -0
- package/dist/chunk-77CISBMG.js.map +1 -0
- package/dist/{chunk-V3LF7BE7.js → chunk-ANZLVSEP.js} +4 -5
- package/dist/chunk-ANZLVSEP.js.map +1 -0
- package/dist/{chunk-XQUSGIDG.js → chunk-CKWPK4RO.js} +10 -3
- package/dist/chunk-CKWPK4RO.js.map +1 -0
- package/dist/chunk-EG4PX726.js +678 -0
- package/dist/chunk-EG4PX726.js.map +1 -0
- package/dist/chunk-NZ5QIIG4.js +74 -0
- package/dist/chunk-NZ5QIIG4.js.map +1 -0
- package/dist/{chunk-7DZGJQ3P.js → chunk-PJ4SPXHS.js} +23 -6
- package/dist/chunk-PJ4SPXHS.js.map +1 -0
- package/dist/{chunk-OB6UBJXF.js → chunk-QNOX7WLZ.js} +127 -36
- package/dist/chunk-QNOX7WLZ.js.map +1 -0
- package/dist/{chunk-PXRX5PEC.js → chunk-ROHNXP7J.js} +73 -4
- package/dist/chunk-ROHNXP7J.js.map +1 -0
- package/dist/{chunk-CEXAQQ5W.js → chunk-S5MDTHH7.js} +180 -18
- package/dist/chunk-S5MDTHH7.js.map +1 -0
- package/dist/{chunk-IBGOCWJB.js → chunk-SDJTTMLK.js} +247 -86
- package/dist/chunk-SDJTTMLK.js.map +1 -0
- package/dist/{chunk-QEWCYW3I.js → chunk-SHZM3EXB.js} +29 -8
- package/dist/chunk-SHZM3EXB.js.map +1 -0
- package/dist/chunk-TRMHNMMZ.js +61 -0
- package/dist/chunk-TRMHNMMZ.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-JKLLFVEU.js → chunk-UWSQUHX6.js} +4 -99
- package/dist/chunk-UWSQUHX6.js.map +1 -0
- package/dist/cli.js +6 -6
- package/dist/client/index.d.ts +2 -0
- package/dist/client/index.js +8 -2
- package/dist/client/index.js.map +1 -1
- package/dist/components/index.d.ts +1617 -101
- package/dist/components/index.js +7 -4
- package/dist/delta-text-CbrOaW83.d.ts +17 -0
- package/dist/{dev-DCTOHQ6W.js → dev-O42JFQ64.js} +7 -7
- package/dist/{dev-DCTOHQ6W.js.map → dev-O42JFQ64.js.map} +1 -1
- package/dist/doc/index.d.ts +215 -2
- package/dist/doc/index.js +423 -5
- package/dist/doc/index.js.map +1 -1
- package/dist/{doctor-5E2VEZPK.js → doctor-YD3XAAOT.js} +5 -5
- package/dist/{doctor-5E2VEZPK.js.map → doctor-YD3XAAOT.js.map} +1 -1
- package/dist/format-DihQkL1N.d.ts +249 -0
- package/dist/markdown/index.js +1 -1
- package/dist/markdown/index.js.map +1 -1
- package/dist/query/index.js +2 -2
- package/dist/{routes-3SGAFDMC.js → routes-PVKNT777.js} +4 -4
- package/dist/{routes-3SGAFDMC.js.map → routes-PVKNT777.js.map} +1 -1
- package/dist/slide/index.d.ts +272 -1
- package/dist/slide/index.js +1025 -4
- package/dist/slide/index.js.map +1 -1
- package/dist/table/index.js +11 -8
- package/dist/table/index.js.map +1 -1
- package/dist/ui/index.d.ts +8 -2
- package/dist/ui/index.js +22 -112
- package/dist/ui/index.js.map +1 -1
- package/dist/{upgrade-DBBE6GIR.js → upgrade-6DT7ADRP.js} +4 -4
- package/dist/{upgrade-DBBE6GIR.js.map → upgrade-6DT7ADRP.js.map} +1 -1
- package/dist/vite/index.js +3 -3
- package/docs/en/agent-skills.md +1 -1
- package/docs/en/changelog.md +2 -0
- package/docs/en/components.md +42 -17
- package/docs/en/doc/delta-text.md +40 -0
- package/docs/en/doc/doc-action-items.md +49 -0
- package/docs/en/doc/doc-callout.md +38 -0
- package/docs/en/doc/doc-data-table.md +60 -0
- package/docs/en/doc/doc-executive-summary.md +64 -0
- package/docs/en/doc/doc-figure.md +56 -0
- package/docs/en/doc/doc-key-findings.md +61 -0
- package/docs/en/doc/doc-kpi-scorecard.md +80 -0
- package/docs/en/doc/doc-notes-and-sources.md +43 -0
- package/docs/en/doc/doc-report-header.md +46 -0
- package/docs/en/pages-and-metadata.md +15 -0
- package/docs/en/parts/area-chart.md +99 -0
- package/docs/en/parts/bar-chart.md +91 -0
- package/docs/en/parts/bar-list.md +50 -0
- package/docs/en/parts/category-bar.md +37 -0
- package/docs/en/parts/chart-frame.md +39 -0
- package/docs/en/parts/data-table.md +22 -0
- package/docs/en/parts/delta.md +51 -0
- package/docs/en/parts/donut-chart.md +72 -0
- package/docs/en/parts/format.md +43 -0
- package/docs/en/parts/funnel-steps.md +2 -1
- package/docs/en/parts/heatmap.md +53 -0
- package/docs/en/parts/kpi-card.md +58 -0
- package/docs/en/parts/legend.md +35 -0
- package/docs/en/parts/line-chart.md +94 -0
- package/docs/en/parts/metric-value.md +3 -2
- package/docs/en/parts/progress-circle.md +33 -0
- package/docs/en/parts/sample-data.md +39 -0
- package/docs/en/parts/scatter-chart.md +56 -0
- package/docs/en/parts/sparkline.md +1 -1
- package/docs/en/parts/tracker.md +36 -0
- package/docs/en/parts/trend-indicator.md +17 -1
- package/docs/en/parts/updated-at.md +30 -0
- package/docs/en/parts/waterfall-chart.md +56 -0
- package/docs/en/slide/slide-chart-full.md +48 -0
- package/docs/en/slide/slide-chart-insight.md +52 -0
- package/docs/en/slide/slide-columns.md +46 -0
- package/docs/en/slide/slide-comparison.md +68 -0
- package/docs/en/slide/slide-cover.md +39 -0
- package/docs/en/slide/slide-exec-summary.md +47 -0
- package/docs/en/slide/slide-heading.md +38 -0
- package/docs/en/slide/slide-kpi-grid.md +55 -0
- package/docs/en/slide/slide-kpi-hero.md +58 -0
- package/docs/en/slide/slide-next-actions.md +49 -0
- package/docs/en/slide/slide-scorecard-table.md +54 -0
- package/docs/en/slide/slide-section.md +44 -0
- package/docs/en/slide/slide-source-line.md +34 -0
- package/docs/en/ui/alert-dialog.md +42 -0
- package/docs/en/ui/avatar.md +31 -0
- package/docs/en/ui/combobox.md +74 -0
- package/docs/en/ui/drawer.md +41 -0
- package/docs/en/ui/empty.md +1 -1
- package/docs/en/ui/error-state.md +4 -3
- package/docs/en/ui/field.md +42 -0
- package/docs/en/ui/hover-card.md +21 -0
- package/docs/en/ui/kbd.md +17 -0
- package/docs/en/ui/loading.md +1 -1
- package/docs/en/ui/pagination.md +36 -0
- package/docs/en/ui/radio-group.md +21 -0
- package/docs/en/ui/toast.md +44 -0
- package/docs/en/ui/toggle-group.md +4 -3
- package/docs/en/ui-and-theming.md +1 -1
- package/docs/index.json +917 -77
- package/docs/ja/agent-skills.md +1 -1
- package/docs/ja/changelog.md +2 -0
- package/docs/ja/components.md +39 -16
- package/docs/ja/doc/delta-text.md +40 -0
- package/docs/ja/doc/doc-action-items.md +49 -0
- package/docs/ja/doc/doc-callout.md +38 -0
- package/docs/ja/doc/doc-data-table.md +60 -0
- package/docs/ja/doc/doc-executive-summary.md +64 -0
- package/docs/ja/doc/doc-figure.md +56 -0
- package/docs/ja/doc/doc-key-findings.md +61 -0
- package/docs/ja/doc/doc-kpi-scorecard.md +80 -0
- package/docs/ja/doc/doc-notes-and-sources.md +43 -0
- package/docs/ja/doc/doc-report-header.md +46 -0
- package/docs/ja/page-types/slide.md +1 -0
- package/docs/ja/pages-and-metadata.md +15 -0
- package/docs/ja/parts/area-chart.md +49 -25
- package/docs/ja/parts/bar-chart.md +50 -24
- package/docs/ja/parts/bar-list.md +31 -8
- package/docs/ja/parts/chart-frame.md +36 -0
- package/docs/ja/parts/data-table.md +22 -0
- package/docs/ja/parts/delta.md +51 -0
- package/docs/ja/parts/donut-chart.md +45 -26
- package/docs/ja/parts/format.md +44 -0
- package/docs/ja/parts/funnel-steps.md +27 -8
- package/docs/ja/parts/heatmap.md +45 -0
- package/docs/ja/parts/kpi-card.md +56 -0
- package/docs/ja/parts/legend.md +36 -0
- package/docs/ja/parts/line-chart.md +48 -22
- package/docs/ja/parts/metric-value.md +3 -2
- package/docs/ja/parts/sample-data.md +61 -0
- package/docs/ja/parts/scatter-chart.md +69 -0
- package/docs/ja/parts/sparkline.md +1 -1
- package/docs/ja/parts/trend-indicator.md +17 -1
- package/docs/ja/parts/updated-at.md +27 -0
- package/docs/ja/parts/waterfall-chart.md +61 -0
- package/docs/ja/slide/slide-chart-full.md +48 -0
- package/docs/ja/slide/slide-chart-insight.md +52 -0
- package/docs/ja/slide/slide-columns.md +46 -0
- package/docs/ja/slide/slide-comparison.md +68 -0
- package/docs/ja/slide/slide-cover.md +39 -0
- package/docs/ja/slide/slide-exec-summary.md +47 -0
- package/docs/ja/slide/slide-heading.md +38 -0
- package/docs/ja/slide/slide-kpi-grid.md +55 -0
- package/docs/ja/slide/slide-kpi-hero.md +58 -0
- package/docs/ja/slide/slide-next-actions.md +49 -0
- package/docs/ja/slide/slide-scorecard-table.md +54 -0
- package/docs/ja/slide/slide-section.md +44 -0
- package/docs/ja/slide/slide-source-line.md +34 -0
- package/docs/ja/ui/empty.md +1 -1
- package/docs/ja/ui/error-state.md +4 -3
- package/docs/ja/ui/loading.md +1 -1
- package/docs/ja/ui/toggle-group.md +4 -3
- package/docs/ja/ui-and-theming.md +2 -2
- package/package.json +26 -24
- 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 +145 -2
- package/registry/ui/area-chart.tsx +3111 -166
- package/registry/ui/attention-list.tsx +465 -0
- package/registry/ui/avatar.tsx +1 -1
- package/registry/ui/badge.tsx +3 -1
- package/registry/ui/bar-chart.tsx +3105 -164
- package/registry/ui/bar-list.tsx +3877 -181
- package/registry/ui/box-plot-chart.tsx +4214 -0
- 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 +1233 -16
- package/registry/ui/chart-frame.tsx +1604 -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 +71 -28
- package/registry/ui/data-table.tsx +882 -68
- package/registry/ui/date-range-picker.tsx +400 -65
- package/registry/ui/delta.tsx +350 -0
- package/registry/ui/dialog.tsx +5 -3
- package/registry/ui/donut-chart.tsx +3184 -182
- package/registry/ui/drawer.tsx +1 -1
- package/registry/ui/dropdown-menu.tsx +5 -3
- package/registry/ui/echart.tsx +761 -69
- package/registry/ui/field.tsx +1 -1
- package/registry/ui/filter-bar.tsx +212 -26
- package/registry/ui/funnel-steps.tsx +3622 -53
- package/registry/ui/heatmap.tsx +2027 -0
- package/registry/ui/histogram-chart.tsx +4284 -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 +905 -0
- package/registry/ui/label.tsx +3 -1
- package/registry/ui/legend.tsx +3817 -0
- package/registry/ui/line-chart.tsx +3109 -158
- package/registry/ui/metric-value.tsx +9 -1
- package/registry/ui/multi-select.tsx +170 -14
- package/registry/ui/page-shell.tsx +244 -51
- package/registry/ui/pagination.tsx +3 -1
- package/registry/ui/paired-chart.tsx +4086 -0
- package/registry/ui/placeholder.tsx +8 -2
- package/registry/ui/popover.tsx +4 -2
- package/registry/ui/progress-circle.tsx +773 -12
- package/registry/ui/progress.tsx +3 -1
- package/registry/ui/radio-group.tsx +1 -1
- package/registry/ui/sample-data.tsx +230 -0
- package/registry/ui/scatter-chart.tsx +4503 -0
- package/registry/ui/scroll-area.tsx +3 -2
- package/registry/ui/searchable-select.tsx +153 -10
- package/registry/ui/section-header.tsx +5 -3
- 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 +4 -2
- package/registry/ui/sparkline.tsx +84 -9
- package/registry/ui/spinner.tsx +3 -1
- package/registry/ui/states.tsx +194 -8
- package/registry/ui/status-badge.tsx +246 -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 +10 -4
- package/registry/ui/tracker.tsx +798 -19
- package/registry/ui/trend-indicator.tsx +164 -9
- package/registry/ui/updated-at.tsx +276 -0
- package/registry/ui/waterfall-chart.tsx +4561 -0
- package/skills/vantage-add-feature/SKILL.md +5 -0
- package/skills/vantage-design/SKILL.md +60 -52
- package/skills/vantage-design/references/extract.md +26 -27
- package/skills/vantage-design/references/format.md +12 -172
- package/skills/vantage-design/references/presets.md +50 -110
- package/skills/vantage-pitfalls/SKILL.md +5 -0
- package/skills/vantage-slide/SKILL.md +54 -36
- package/templates/AGENTS.md +45 -16
- package/templates/agents/api.md +7 -0
- package/templates/agents/doc.md +48 -0
- package/templates/agents/page.md +69 -2
- package/templates/agents/slide.md +77 -3
- package/theme.css +247 -149
- package/dist/chunk-5ZOP4SQR.js +0 -47
- package/dist/chunk-5ZOP4SQR.js.map +0 -1
- package/dist/chunk-7DZGJQ3P.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-CEXAQQ5W.js.map +0 -1
- package/dist/chunk-IBGOCWJB.js.map +0 -1
- package/dist/chunk-JKLLFVEU.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/chunk-V3LF7BE7.js.map +0 -1
- package/dist/chunk-XQUSGIDG.js.map +0 -1
package/registry/ui/states.tsx
CHANGED
|
@@ -1,21 +1,194 @@
|
|
|
1
1
|
// Copied by `vantage add ui states`. This file is yours to edit.
|
|
2
|
-
// Generated from @squadbase/
|
|
2
|
+
// Generated from @squadbase/squadkit registry/ui/states.tsx by `pnpm run registry` (in Vantage, edit packages/squadkit, not registry/).
|
|
3
|
+
"use client"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Loading / Empty / ErrorState — the three non-data states of a panel, worded for
|
|
7
|
+
* business users. Defaults follow the page language (`<html lang>`: Japanese for `ja`, else
|
|
8
|
+
* English) and say what is happening, not why the system failed: keep raw errors
|
|
9
|
+
* ("upstream timeout after 30s") in `details`, which stays folded behind "Show details" (ja: "詳細を表示").
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* import { ErrorState } from "@/components/ui/states"
|
|
13
|
+
* // Vantage: import { ErrorState } from "@squadbase/vantage/ui"
|
|
14
|
+
*
|
|
15
|
+
* <ErrorState
|
|
16
|
+
* title="売上を読み込めませんでした"
|
|
17
|
+
* message="データソースから時間内に応答がありませんでした。しばらくしてから再試行してください。"
|
|
18
|
+
* details={error.message}
|
|
19
|
+
* action={<Button variant="outline" onClick={retry}>再試行する</Button>}
|
|
20
|
+
* />
|
|
21
|
+
*/
|
|
3
22
|
import type { ReactNode } from "react"
|
|
4
23
|
import { cn } from "@squadbase/vantage/ui"
|
|
24
|
+
import { useSyncExternalStore } from "react"
|
|
25
|
+
|
|
26
|
+
/* ---------- inlined from @squadbase/squadkit registry/lib/locale.ts (internal to @squadbase/vantage) ---------- */
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* The display language of the parts and the defaults that follow it.
|
|
30
|
+
*
|
|
31
|
+
* The language comes from `<html lang>`: a tag starting with `ja` reads Japanese, anything else English.
|
|
32
|
+
* Without a usable `lang` (missing, invalid, or no `document` — SSR, Node) the locale is `FALLBACK_LOCALE`
|
|
33
|
+
* (`en-US`). A `locale` passed explicitly (a prop, an argument) always wins.
|
|
34
|
+
*
|
|
35
|
+
* Parts read the locale through `useLocale` (`hooks/use-locale`) and pass it down; the pure helpers here
|
|
36
|
+
* and in `format` / `comparison` / `chart-*` take it as an argument and fall back to `documentLocale()`.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/** The language of the built-in wording: Japanese or English. */
|
|
40
|
+
type UiLanguage = "ja" | "en"
|
|
41
|
+
|
|
42
|
+
/** The locale used when `<html lang>` gives none (and on the server). */
|
|
43
|
+
const FALLBACK_LOCALE = "en-US"
|
|
44
|
+
|
|
45
|
+
/** `"ja"` when `locale` starts with `ja` (`ja`, `ja-JP`), else `"en"`. A missing locale is `"en"`. */
|
|
46
|
+
function uiLanguage(locale: string | null | undefined): UiLanguage {
|
|
47
|
+
return typeof locale === "string" && locale.trim().toLowerCase().startsWith("ja") ? "ja" : "en"
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** A BCP 47 tag in its canonical form (`en-gb` → `en-GB`), or `FALLBACK_LOCALE` when it is empty or invalid. */
|
|
51
|
+
function normalizeLocale(tag: string | null | undefined): string {
|
|
52
|
+
const value = tag?.trim()
|
|
53
|
+
if (!value) return FALLBACK_LOCALE
|
|
54
|
+
try {
|
|
55
|
+
return Intl.getCanonicalLocales(value)[0] ?? FALLBACK_LOCALE
|
|
56
|
+
} catch {
|
|
57
|
+
return FALLBACK_LOCALE
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The locale of the page: `document.documentElement.lang`, canonicalized. `FALLBACK_LOCALE` when it is empty or
|
|
63
|
+
* invalid, or there is no `document`. Parts read it through `useLocale`, never while rendering.
|
|
64
|
+
*/
|
|
65
|
+
function documentLocale(): string {
|
|
66
|
+
if (typeof document === "undefined") return FALLBACK_LOCALE
|
|
67
|
+
return normalizeLocale(document.documentElement?.getAttribute("lang"))
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** `locale` when given, else the page's locale (`documentLocale()`). */
|
|
71
|
+
function resolveLocale(locale?: string | null): string {
|
|
72
|
+
return locale || documentLocale()
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Picks the wording table of the locale's language. */
|
|
76
|
+
function pickLocale<T>(table: { ja: T; en: T }, locale?: string | null): T {
|
|
77
|
+
return table[uiLanguage(resolveLocale(locale))]
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** The currency `format="currency"` uses without a `currency`: JPY for Japanese, USD otherwise. */
|
|
81
|
+
function defaultCurrency(locale?: string | null): string {
|
|
82
|
+
return uiLanguage(resolveLocale(locale)) === "ja" ? "JPY" : "USD"
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** The month a fiscal year starts in (1–12) when none is given: April for Japanese, January otherwise. */
|
|
86
|
+
function defaultFiscalYearStartMonth(locale?: string | null): number {
|
|
87
|
+
return uiLanguage(resolveLocale(locale)) === "ja" ? 4 : 1
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** A day of the week, 0 = Sunday … 6 = Saturday (the `Date#getDay` / date-fns numbering). */
|
|
91
|
+
type WeekDay = 0 | 1 | 2 | 3 | 4 | 5 | 6
|
|
92
|
+
|
|
93
|
+
/** Locales whose week starts on Sunday when the runtime has no week data. */
|
|
94
|
+
const SUNDAY_FIRST = new Set(["en", "en-US", "en-CA"])
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The first day of the week: Monday for Japanese; otherwise the locale's convention from `Intl.Locale`
|
|
98
|
+
* (`en-US` Sunday, `en-GB` Monday). Without week data in the runtime: Sunday for `en` / `en-US` / `en-CA`,
|
|
99
|
+
* Monday for the rest.
|
|
100
|
+
*/
|
|
101
|
+
function weekStartsOn(locale?: string | null): WeekDay {
|
|
102
|
+
const tag = normalizeLocale(resolveLocale(locale))
|
|
103
|
+
if (uiLanguage(tag) === "ja") return 1
|
|
104
|
+
try {
|
|
105
|
+
const info = new Intl.Locale(tag) as Intl.Locale & {
|
|
106
|
+
getWeekInfo?: () => { firstDay: number }
|
|
107
|
+
weekInfo?: { firstDay: number }
|
|
108
|
+
}
|
|
109
|
+
const firstDay = info.getWeekInfo?.().firstDay ?? info.weekInfo?.firstDay
|
|
110
|
+
if (typeof firstDay === "number" && firstDay >= 1 && firstDay <= 7) return (firstDay % 7) as WeekDay
|
|
111
|
+
} catch {
|
|
112
|
+
// Fall through to the table below.
|
|
113
|
+
}
|
|
114
|
+
return SUNDAY_FIRST.has(tag) ? 0 : 1
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/* ---------- inlined from @squadbase/squadkit registry/hooks/use-locale.ts (internal to @squadbase/vantage) ---------- */
|
|
118
|
+
|
|
119
|
+
const listeners = new Set<() => void>()
|
|
120
|
+
let observer: MutationObserver | null = null
|
|
121
|
+
|
|
122
|
+
/** One observer on `<html lang>` for every subscribed part. */
|
|
123
|
+
function subscribe(onChange: () => void): () => void {
|
|
124
|
+
if (typeof document === "undefined" || typeof MutationObserver === "undefined") return () => {}
|
|
125
|
+
listeners.add(onChange)
|
|
126
|
+
if (!observer) {
|
|
127
|
+
observer = new MutationObserver(() => {
|
|
128
|
+
for (const listener of [...listeners]) listener()
|
|
129
|
+
})
|
|
130
|
+
observer.observe(document.documentElement, { attributes: true, attributeFilter: ["lang"] })
|
|
131
|
+
}
|
|
132
|
+
return () => {
|
|
133
|
+
listeners.delete(onChange)
|
|
134
|
+
if (listeners.size === 0 && observer) {
|
|
135
|
+
observer.disconnect()
|
|
136
|
+
observer = null
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const serverLocale = () => FALLBACK_LOCALE
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* The page's locale (`<html lang>`), following changes made while the page runs. On the server and during
|
|
145
|
+
* hydration it is `FALLBACK_LOCALE` (`en-US`), so the markup matches; it switches right after.
|
|
146
|
+
*/
|
|
147
|
+
function useDocumentLocale(): string {
|
|
148
|
+
return useSyncExternalStore(subscribe, documentLocale, serverLocale)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** The locale a part renders in: its `locale` prop when given, else the page's (`useDocumentLocale`). */
|
|
152
|
+
function useLocale(locale?: string | null): string {
|
|
153
|
+
const page = useDocumentLocale()
|
|
154
|
+
return locale || page
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/* ---------- end of inlined code ---------- */
|
|
158
|
+
|
|
159
|
+
const TEXT = {
|
|
160
|
+
ja: {
|
|
161
|
+
loading: "読み込んでいます…",
|
|
162
|
+
empty: "表示できるデータがありません",
|
|
163
|
+
errorTitle: "データを読み込めませんでした",
|
|
164
|
+
errorMessage: "時間をおいて再試行してください。解決しない場合は管理者にお問い合わせください。",
|
|
165
|
+
details: "詳細を表示",
|
|
166
|
+
},
|
|
167
|
+
en: {
|
|
168
|
+
loading: "Loading…",
|
|
169
|
+
empty: "No data to display",
|
|
170
|
+
errorTitle: "Couldn't load the data",
|
|
171
|
+
errorMessage: "Try again in a moment. If the problem continues, contact your administrator.",
|
|
172
|
+
details: "Show details",
|
|
173
|
+
},
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const useText = () => TEXT[uiLanguage(useLocale())]
|
|
5
177
|
|
|
6
|
-
export function Loading({ label
|
|
178
|
+
export function Loading({ label, className }: { label?: string; className?: string }) {
|
|
179
|
+
const t = useText()
|
|
7
180
|
return (
|
|
8
181
|
<div className={cn("flex min-h-[30vh] items-center justify-center", className)} role="status" aria-live="polite">
|
|
9
182
|
<div className="flex items-center gap-3 text-sm text-muted-foreground">
|
|
10
183
|
<span className="h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent" />
|
|
11
|
-
{label}
|
|
184
|
+
{label ?? t.loading}
|
|
12
185
|
</div>
|
|
13
186
|
</div>
|
|
14
187
|
)
|
|
15
188
|
}
|
|
16
189
|
|
|
17
190
|
export function Empty({
|
|
18
|
-
title
|
|
191
|
+
title,
|
|
19
192
|
description,
|
|
20
193
|
icon,
|
|
21
194
|
action,
|
|
@@ -27,10 +200,11 @@ export function Empty({
|
|
|
27
200
|
action?: ReactNode
|
|
28
201
|
className?: string
|
|
29
202
|
}) {
|
|
203
|
+
const t = useText()
|
|
30
204
|
return (
|
|
31
205
|
<div className={cn("flex flex-col items-center justify-center gap-2 p-10 text-center", className)}>
|
|
32
206
|
{icon ? <div className="text-3xl text-muted-foreground">{icon}</div> : null}
|
|
33
|
-
<p className="font-medium">{title}</p>
|
|
207
|
+
<p className="font-medium">{title ?? t.empty}</p>
|
|
34
208
|
{description ? <p className="max-w-sm text-sm text-muted-foreground">{description}</p> : null}
|
|
35
209
|
{action ? <div className="mt-2">{action}</div> : null}
|
|
36
210
|
</div>
|
|
@@ -38,23 +212,35 @@ export function Empty({
|
|
|
38
212
|
}
|
|
39
213
|
|
|
40
214
|
export function ErrorState({
|
|
41
|
-
title
|
|
215
|
+
title,
|
|
42
216
|
message,
|
|
217
|
+
details,
|
|
43
218
|
action,
|
|
44
219
|
className,
|
|
45
220
|
}: {
|
|
46
221
|
title?: string
|
|
222
|
+
/** What happened and what to do next, in plain words. */
|
|
47
223
|
message?: ReactNode
|
|
224
|
+
/** Technical detail (error message, status code), folded behind "Show details" (ja: "詳細を表示"). */
|
|
225
|
+
details?: ReactNode
|
|
48
226
|
action?: ReactNode
|
|
49
227
|
className?: string
|
|
50
228
|
}) {
|
|
229
|
+
const t = useText()
|
|
230
|
+
const shownMessage = message === undefined ? t.errorMessage : message
|
|
51
231
|
return (
|
|
52
232
|
<div
|
|
53
233
|
className={cn("rounded-xl border border-destructive/30 bg-destructive/5 p-6", className)}
|
|
54
234
|
role="alert"
|
|
55
235
|
>
|
|
56
|
-
<p className="font-semibold text-destructive">{title}</p>
|
|
57
|
-
{
|
|
236
|
+
<p className="font-semibold text-destructive">{title ?? t.errorTitle}</p>
|
|
237
|
+
{shownMessage ? <p className="mt-1 text-sm text-muted-foreground">{shownMessage}</p> : null}
|
|
238
|
+
{details ? (
|
|
239
|
+
<details className="mt-2 text-xs text-muted-foreground">
|
|
240
|
+
<summary className="cursor-pointer select-none">{t.details}</summary>
|
|
241
|
+
<div className="mt-1 font-mono break-all">{details}</div>
|
|
242
|
+
</details>
|
|
243
|
+
) : null}
|
|
58
244
|
{action ? <div className="mt-3">{action}</div> : null}
|
|
59
245
|
</div>
|
|
60
246
|
)
|
|
@@ -1,55 +1,262 @@
|
|
|
1
1
|
// Copied by `vantage add ui status-badge`. This file is yours to edit.
|
|
2
|
-
// Generated from @squadbase/
|
|
2
|
+
// Generated from @squadbase/squadkit registry/components/status-badge.tsx by `pnpm run registry` (in Vantage, edit packages/squadkit, not registry/).
|
|
3
|
+
"use client"
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
|
-
* StatusBadge — a dot-plus-label badge for row/record status. Statuses map to
|
|
5
|
-
*
|
|
6
|
+
* StatusBadge — a dot-plus-label badge for row/record status. Statuses map to a
|
|
7
|
+
* tone through `defaultColorMap`; pass `colorMap` to extend or override it.
|
|
8
|
+
*
|
|
9
|
+
* Tones are the theme's semantic tokens — `positive` | `negative` | `warning` |
|
|
10
|
+
* `info` | `neutral` — drawn as a `--<tone>` dot and text on a `--<tone>-subtle`
|
|
11
|
+
* background. The legacy colour names `green` / `red` / `yellow` / `blue` /
|
|
12
|
+
* `gray` are still accepted and map to positive / negative / warning / info /
|
|
13
|
+
* neutral. Unknown statuses and tones fall back to `neutral`.
|
|
14
|
+
*
|
|
15
|
+
* The default label comes from `STATUS_VOCABULARY` (one table of status, label and tone; the label follows the
|
|
16
|
+
* page's language, `<html lang>`), so the same state is worded the same everywhere (Tracker legends import it too):
|
|
17
|
+
*
|
|
18
|
+
* | status | ラベル(ja / en) | 色調 |
|
|
19
|
+
* |---|---|---|
|
|
20
|
+
* | `success` | 正常 / Healthy | positive |
|
|
21
|
+
* | `partial` | 一部失敗 / Partially failed | warning |
|
|
22
|
+
* | `failed` | 失敗 / Failed | negative |
|
|
23
|
+
* | `delayed` | 遅延 / Delayed | warning |
|
|
24
|
+
* | `running` | 実行中 / Running | info |
|
|
25
|
+
* | `stopped` | 停止中 / Stopped | neutral |
|
|
26
|
+
* | `active` / `inactive` | 有効 / 無効、Active / Inactive | positive / neutral |
|
|
27
|
+
* | `warning` / `error` / `pending` | 警告 / エラー / 保留中、Warning / Error / Pending | warning / negative / info |
|
|
6
28
|
*/
|
|
7
29
|
import { forwardRef } from "react"
|
|
8
30
|
|
|
9
31
|
import { cn } from "@squadbase/vantage/ui"
|
|
10
32
|
import { Badge } from "@squadbase/vantage/ui"
|
|
33
|
+
import { useSyncExternalStore } from "react"
|
|
34
|
+
|
|
35
|
+
/* ---------- inlined from @squadbase/squadkit registry/lib/locale.ts (internal to @squadbase/vantage) ---------- */
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The display language of the parts and the defaults that follow it.
|
|
39
|
+
*
|
|
40
|
+
* The language comes from `<html lang>`: a tag starting with `ja` reads Japanese, anything else English.
|
|
41
|
+
* Without a usable `lang` (missing, invalid, or no `document` — SSR, Node) the locale is `FALLBACK_LOCALE`
|
|
42
|
+
* (`en-US`). A `locale` passed explicitly (a prop, an argument) always wins.
|
|
43
|
+
*
|
|
44
|
+
* Parts read the locale through `useLocale` (`hooks/use-locale`) and pass it down; the pure helpers here
|
|
45
|
+
* and in `format` / `comparison` / `chart-*` take it as an argument and fall back to `documentLocale()`.
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
/** The language of the built-in wording: Japanese or English. */
|
|
49
|
+
type UiLanguage = "ja" | "en"
|
|
50
|
+
|
|
51
|
+
/** The locale used when `<html lang>` gives none (and on the server). */
|
|
52
|
+
const FALLBACK_LOCALE = "en-US"
|
|
11
53
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
warning: "yellow",
|
|
16
|
-
error: "red",
|
|
17
|
-
pending: "blue",
|
|
54
|
+
/** `"ja"` when `locale` starts with `ja` (`ja`, `ja-JP`), else `"en"`. A missing locale is `"en"`. */
|
|
55
|
+
function uiLanguage(locale: string | null | undefined): UiLanguage {
|
|
56
|
+
return typeof locale === "string" && locale.trim().toLowerCase().startsWith("ja") ? "ja" : "en"
|
|
18
57
|
}
|
|
19
58
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
59
|
+
/** A BCP 47 tag in its canonical form (`en-gb` → `en-GB`), or `FALLBACK_LOCALE` when it is empty or invalid. */
|
|
60
|
+
function normalizeLocale(tag: string | null | undefined): string {
|
|
61
|
+
const value = tag?.trim()
|
|
62
|
+
if (!value) return FALLBACK_LOCALE
|
|
63
|
+
try {
|
|
64
|
+
return Intl.getCanonicalLocales(value)[0] ?? FALLBACK_LOCALE
|
|
65
|
+
} catch {
|
|
66
|
+
return FALLBACK_LOCALE
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The locale of the page: `document.documentElement.lang`, canonicalized. `FALLBACK_LOCALE` when it is empty or
|
|
72
|
+
* invalid, or there is no `document`. Parts read it through `useLocale`, never while rendering.
|
|
73
|
+
*/
|
|
74
|
+
function documentLocale(): string {
|
|
75
|
+
if (typeof document === "undefined") return FALLBACK_LOCALE
|
|
76
|
+
return normalizeLocale(document.documentElement?.getAttribute("lang"))
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** `locale` when given, else the page's locale (`documentLocale()`). */
|
|
80
|
+
function resolveLocale(locale?: string | null): string {
|
|
81
|
+
return locale || documentLocale()
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Picks the wording table of the locale's language. */
|
|
85
|
+
function pickLocale<T>(table: { ja: T; en: T }, locale?: string | null): T {
|
|
86
|
+
return table[uiLanguage(resolveLocale(locale))]
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** The currency `format="currency"` uses without a `currency`: JPY for Japanese, USD otherwise. */
|
|
90
|
+
function defaultCurrency(locale?: string | null): string {
|
|
91
|
+
return uiLanguage(resolveLocale(locale)) === "ja" ? "JPY" : "USD"
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** The month a fiscal year starts in (1–12) when none is given: April for Japanese, January otherwise. */
|
|
95
|
+
function defaultFiscalYearStartMonth(locale?: string | null): number {
|
|
96
|
+
return uiLanguage(resolveLocale(locale)) === "ja" ? 4 : 1
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** A day of the week, 0 = Sunday … 6 = Saturday (the `Date#getDay` / date-fns numbering). */
|
|
100
|
+
type WeekDay = 0 | 1 | 2 | 3 | 4 | 5 | 6
|
|
101
|
+
|
|
102
|
+
/** Locales whose week starts on Sunday when the runtime has no week data. */
|
|
103
|
+
const SUNDAY_FIRST = new Set(["en", "en-US", "en-CA"])
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* The first day of the week: Monday for Japanese; otherwise the locale's convention from `Intl.Locale`
|
|
107
|
+
* (`en-US` Sunday, `en-GB` Monday). Without week data in the runtime: Sunday for `en` / `en-US` / `en-CA`,
|
|
108
|
+
* Monday for the rest.
|
|
109
|
+
*/
|
|
110
|
+
function weekStartsOn(locale?: string | null): WeekDay {
|
|
111
|
+
const tag = normalizeLocale(resolveLocale(locale))
|
|
112
|
+
if (uiLanguage(tag) === "ja") return 1
|
|
113
|
+
try {
|
|
114
|
+
const info = new Intl.Locale(tag) as Intl.Locale & {
|
|
115
|
+
getWeekInfo?: () => { firstDay: number }
|
|
116
|
+
weekInfo?: { firstDay: number }
|
|
117
|
+
}
|
|
118
|
+
const firstDay = info.getWeekInfo?.().firstDay ?? info.weekInfo?.firstDay
|
|
119
|
+
if (typeof firstDay === "number" && firstDay >= 1 && firstDay <= 7) return (firstDay % 7) as WeekDay
|
|
120
|
+
} catch {
|
|
121
|
+
// Fall through to the table below.
|
|
122
|
+
}
|
|
123
|
+
return SUNDAY_FIRST.has(tag) ? 0 : 1
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/* ---------- inlined from @squadbase/squadkit registry/hooks/use-locale.ts (internal to @squadbase/vantage) ---------- */
|
|
127
|
+
|
|
128
|
+
const listeners = new Set<() => void>()
|
|
129
|
+
let observer: MutationObserver | null = null
|
|
130
|
+
|
|
131
|
+
/** One observer on `<html lang>` for every subscribed part. */
|
|
132
|
+
function subscribe(onChange: () => void): () => void {
|
|
133
|
+
if (typeof document === "undefined" || typeof MutationObserver === "undefined") return () => {}
|
|
134
|
+
listeners.add(onChange)
|
|
135
|
+
if (!observer) {
|
|
136
|
+
observer = new MutationObserver(() => {
|
|
137
|
+
for (const listener of [...listeners]) listener()
|
|
138
|
+
})
|
|
139
|
+
observer.observe(document.documentElement, { attributes: true, attributeFilter: ["lang"] })
|
|
140
|
+
}
|
|
141
|
+
return () => {
|
|
142
|
+
listeners.delete(onChange)
|
|
143
|
+
if (listeners.size === 0 && observer) {
|
|
144
|
+
observer.disconnect()
|
|
145
|
+
observer = null
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const serverLocale = () => FALLBACK_LOCALE
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* The page's locale (`<html lang>`), following changes made while the page runs. On the server and during
|
|
154
|
+
* hydration it is `FALLBACK_LOCALE` (`en-US`), so the markup matches; it switches right after.
|
|
155
|
+
*/
|
|
156
|
+
function useDocumentLocale(): string {
|
|
157
|
+
return useSyncExternalStore(subscribe, documentLocale, serverLocale)
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** The locale a part renders in: its `locale` prop when given, else the page's (`useDocumentLocale`). */
|
|
161
|
+
function useLocale(locale?: string | null): string {
|
|
162
|
+
const page = useDocumentLocale()
|
|
163
|
+
return locale || page
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/* ---------- end of inlined code ---------- */
|
|
167
|
+
|
|
168
|
+
type StatusTone = "positive" | "negative" | "warning" | "info" | "neutral"
|
|
169
|
+
|
|
170
|
+
const STATUS_LABELS = {
|
|
171
|
+
ja: {
|
|
172
|
+
success: "正常",
|
|
173
|
+
partial: "一部失敗",
|
|
174
|
+
failed: "失敗",
|
|
175
|
+
delayed: "遅延",
|
|
176
|
+
running: "実行中",
|
|
177
|
+
stopped: "停止中",
|
|
178
|
+
active: "有効",
|
|
179
|
+
inactive: "無効",
|
|
180
|
+
warning: "警告",
|
|
181
|
+
error: "エラー",
|
|
182
|
+
pending: "保留中",
|
|
40
183
|
},
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
184
|
+
en: {
|
|
185
|
+
success: "Healthy",
|
|
186
|
+
partial: "Partially failed",
|
|
187
|
+
failed: "Failed",
|
|
188
|
+
delayed: "Delayed",
|
|
189
|
+
running: "Running",
|
|
190
|
+
stopped: "Stopped",
|
|
191
|
+
active: "Active",
|
|
192
|
+
inactive: "Inactive",
|
|
193
|
+
warning: "Warning",
|
|
194
|
+
error: "Error",
|
|
195
|
+
pending: "Pending",
|
|
45
196
|
},
|
|
197
|
+
} as const
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* 状態の語彙の正本: status → ラベルと色調。StatusBadge の既定の表示と、Tracker の凡例など
|
|
201
|
+
* 同じ状態を語る他の場所が、同じ語を使うためにここから参照する。`label` は英語(フォールバック)で、
|
|
202
|
+
* ページの言語に合わせた語は `statusLabel(status, locale)` で引く。
|
|
203
|
+
*/
|
|
204
|
+
export const STATUS_VOCABULARY = {
|
|
205
|
+
success: { label: STATUS_LABELS.en.success, tone: "positive" },
|
|
206
|
+
partial: { label: STATUS_LABELS.en.partial, tone: "warning" },
|
|
207
|
+
failed: { label: STATUS_LABELS.en.failed, tone: "negative" },
|
|
208
|
+
delayed: { label: STATUS_LABELS.en.delayed, tone: "warning" },
|
|
209
|
+
running: { label: STATUS_LABELS.en.running, tone: "info" },
|
|
210
|
+
stopped: { label: STATUS_LABELS.en.stopped, tone: "neutral" },
|
|
211
|
+
active: { label: STATUS_LABELS.en.active, tone: "positive" },
|
|
212
|
+
inactive: { label: STATUS_LABELS.en.inactive, tone: "neutral" },
|
|
213
|
+
warning: { label: STATUS_LABELS.en.warning, tone: "warning" },
|
|
214
|
+
error: { label: STATUS_LABELS.en.error, tone: "negative" },
|
|
215
|
+
pending: { label: STATUS_LABELS.en.pending, tone: "info" },
|
|
216
|
+
} as const satisfies Record<string, { label: string; tone: StatusTone }>
|
|
217
|
+
|
|
218
|
+
export type StatusKey = keyof typeof STATUS_VOCABULARY
|
|
219
|
+
|
|
220
|
+
/** 状態のラベル(`locale` の言語。既定はページのロケール)。語彙に無い status は渡された文字列のまま返す。 */
|
|
221
|
+
export function statusLabel(status: string, locale?: string): string {
|
|
222
|
+
return Object.hasOwn(STATUS_VOCABULARY, status) ? STATUS_LABELS[uiLanguage(resolveLocale(locale))][status as StatusKey] : status
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
const defaultColorMap: Record<string, string> = Object.fromEntries(
|
|
226
|
+
Object.entries(STATUS_VOCABULARY).map(([key, { tone }]) => [key, tone]),
|
|
227
|
+
)
|
|
228
|
+
|
|
229
|
+
/** Legacy colour names → tones. */
|
|
230
|
+
const legacyColorTones: Record<string, StatusTone> = {
|
|
231
|
+
green: "positive",
|
|
232
|
+
gray: "neutral",
|
|
233
|
+
yellow: "warning",
|
|
234
|
+
red: "negative",
|
|
235
|
+
blue: "info",
|
|
46
236
|
}
|
|
47
237
|
|
|
48
|
-
|
|
238
|
+
/**
|
|
239
|
+
* One literal class set per tone — Tailwind only emits classes it can see
|
|
240
|
+
* literally in the source.
|
|
241
|
+
*/
|
|
242
|
+
const toneStyles: Record<StatusTone, { dot: string; bg: string; text: string; border: string }> = {
|
|
243
|
+
positive: { dot: "bg-positive", bg: "bg-positive-subtle", text: "text-positive", border: "border-positive/20 dark:border-positive/25" },
|
|
244
|
+
negative: { dot: "bg-negative", bg: "bg-negative-subtle", text: "text-negative", border: "border-negative/20 dark:border-negative/25" },
|
|
245
|
+
warning: { dot: "bg-warning", bg: "bg-warning-subtle", text: "text-warning", border: "border-warning/20 dark:border-warning/25" },
|
|
246
|
+
info: { dot: "bg-info", bg: "bg-info-subtle", text: "text-info", border: "border-info/20 dark:border-info/25" },
|
|
247
|
+
neutral: { dot: "bg-neutral", bg: "bg-neutral-subtle", text: "text-neutral", border: "border-neutral/20 dark:border-neutral/25" },
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
const resolveTone = (color: string | undefined): StatusTone => {
|
|
251
|
+
if (color === undefined) return "neutral"
|
|
252
|
+
if (Object.hasOwn(toneStyles, color)) return color as StatusTone
|
|
253
|
+
return legacyColorTones[color] ?? "neutral"
|
|
254
|
+
}
|
|
49
255
|
|
|
50
256
|
export interface StatusBadgeProps {
|
|
51
257
|
status: string
|
|
52
258
|
label?: string
|
|
259
|
+
/** status → tone (`positive` | `negative` | `warning` | `info` | `neutral`) or legacy colour name. */
|
|
53
260
|
colorMap?: Partial<Record<string, string>>
|
|
54
261
|
className?: string
|
|
55
262
|
}
|
|
@@ -58,20 +265,20 @@ export const StatusBadge = forwardRef<HTMLSpanElement, StatusBadgeProps>(functio
|
|
|
58
265
|
{ status, label, colorMap, className },
|
|
59
266
|
ref,
|
|
60
267
|
) {
|
|
268
|
+
const locale = useLocale()
|
|
61
269
|
const mergedColorMap = { ...defaultColorMap, ...colorMap }
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
const displayLabel = label ?? status
|
|
270
|
+
const style = toneStyles[resolveTone(mergedColorMap[status])]
|
|
271
|
+
const displayLabel = label ?? statusLabel(status, locale)
|
|
65
272
|
|
|
66
273
|
return (
|
|
67
274
|
<Badge
|
|
68
275
|
ref={ref}
|
|
69
276
|
data-slot="status-badge"
|
|
70
277
|
variant="outline"
|
|
71
|
-
className={cn("gap-1.5
|
|
278
|
+
className={cn("gap-1.5 rounded-md", style.border, style.bg, style.text, className)}
|
|
72
279
|
aria-label={displayLabel}
|
|
73
280
|
>
|
|
74
|
-
<span className={cn("inline-block size-
|
|
281
|
+
<span className={cn("inline-block size-1.5 rounded-full", style.dot)} aria-hidden="true" />
|
|
75
282
|
{displayLabel}
|
|
76
283
|
</Badge>
|
|
77
284
|
)
|
package/registry/ui/switch.tsx
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// Copied by `vantage add ui switch`. This file is yours to edit.
|
|
2
|
-
// Generated from @squadbase/
|
|
2
|
+
// Generated from @squadbase/squadkit registry/ui/switch.tsx by `pnpm run registry` (in Vantage, edit packages/squadkit, not registry/).
|
|
3
|
+
"use client"
|
|
4
|
+
|
|
3
5
|
import { Switch as SwitchPrimitive } from "@base-ui/react/switch"
|
|
4
6
|
|
|
5
7
|
import { cn } from "@squadbase/vantage/ui"
|
package/registry/ui/table.tsx
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// Copied by `vantage add ui table`. This file is yours to edit.
|
|
2
|
-
// Generated from @squadbase/
|
|
2
|
+
// Generated from @squadbase/squadkit registry/ui/table.tsx by `pnpm run registry` (in Vantage, edit packages/squadkit, not registry/).
|
|
3
|
+
"use client"
|
|
4
|
+
|
|
3
5
|
import * as React from "react"
|
|
4
6
|
|
|
5
7
|
import { cn } from "@squadbase/vantage/ui"
|
|
@@ -70,7 +72,7 @@ function TableHead({ className, ...props }: React.ComponentProps<"th">) {
|
|
|
70
72
|
<th
|
|
71
73
|
data-slot="table-head"
|
|
72
74
|
className={cn(
|
|
73
|
-
"h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0",
|
|
75
|
+
"h-10 px-2 text-left align-middle text-xs font-medium whitespace-nowrap text-muted-foreground [&:has([role=checkbox])]:pr-0",
|
|
74
76
|
className
|
|
75
77
|
)}
|
|
76
78
|
{...props}
|
package/registry/ui/tabs.tsx
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// Copied by `vantage add ui tabs`. This file is yours to edit.
|
|
2
|
-
// Generated from @squadbase/
|
|
2
|
+
// Generated from @squadbase/squadkit registry/ui/tabs.tsx by `pnpm run registry` (in Vantage, edit packages/squadkit, not registry/).
|
|
3
|
+
"use client"
|
|
4
|
+
|
|
3
5
|
import { Tabs as TabsPrimitive } from "@base-ui/react/tabs"
|
|
4
6
|
import { cva, type VariantProps } from "class-variance-authority"
|
|
5
7
|
|
|
@@ -58,7 +60,7 @@ function TabsTrigger({ className, ...props }: TabsPrimitive.Tab.Props) {
|
|
|
58
60
|
<TabsPrimitive.Tab
|
|
59
61
|
data-slot="tabs-trigger"
|
|
60
62
|
className={cn(
|
|
61
|
-
"relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-
|
|
63
|
+
"relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-[color,background-color,border-color,box-shadow] group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
62
64
|
"group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent",
|
|
63
65
|
"data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground",
|
|
64
66
|
"after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100",
|
|
@@ -73,7 +75,7 @@ function TabsContent({ className, ...props }: TabsPrimitive.Panel.Props) {
|
|
|
73
75
|
return (
|
|
74
76
|
<TabsPrimitive.Panel
|
|
75
77
|
data-slot="tabs-content"
|
|
76
|
-
className={cn("flex-1 text-sm outline-none", className)}
|
|
78
|
+
className={cn("flex-1 text-sm outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50", className)}
|
|
77
79
|
{...props}
|
|
78
80
|
/>
|
|
79
81
|
)
|
package/registry/ui/textarea.tsx
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// Copied by `vantage add ui textarea`. This file is yours to edit.
|
|
2
|
-
// Generated from @squadbase/
|
|
2
|
+
// Generated from @squadbase/squadkit registry/ui/textarea.tsx by `pnpm run registry` (in Vantage, edit packages/squadkit, not registry/).
|
|
3
|
+
"use client"
|
|
4
|
+
|
|
3
5
|
import * as React from "react"
|
|
4
6
|
|
|
5
7
|
import { cn } from "@squadbase/vantage/ui"
|
package/registry/ui/toast.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Copied by `vantage add ui toast`. This file is yours to edit.
|
|
2
|
-
// Generated from @squadbase/
|
|
2
|
+
// Generated from @squadbase/squadkit registry/ui/toast.tsx by `pnpm run registry` (in Vantage, edit packages/squadkit, not registry/).
|
|
3
3
|
"use client"
|
|
4
4
|
|
|
5
5
|
import * as React from "react"
|
|
@@ -39,7 +39,7 @@ function Toast({ className, ...props }: ToastPrimitive.Root.Props) {
|
|
|
39
39
|
className={cn(
|
|
40
40
|
"group/toast pointer-events-auto absolute right-0 bottom-0 z-[calc(1000-var(--toast-index))] w-full origin-bottom rounded-2xl border bg-popover text-popover-foreground shadow-lg will-change-transform outline-none select-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50",
|
|
41
41
|
"[--gap:0.75rem] [--height:var(--toast-frontmost-height,var(--toast-height))] [--offset-y:calc(var(--toast-offset-y)*-1+calc(var(--toast-index)*var(--gap)*-1)+var(--toast-swipe-movement-y))] [--peek:0.75rem] [--scale:calc(max(0,1-(var(--toast-index)*0.1)))] [--shrink:calc(1-var(--scale))]",
|
|
42
|
-
"h-(--height) [transform:translateX(var(--toast-swipe-movement-x))_translateY(calc(var(--toast-swipe-movement-y)-(var(--toast-index)*var(--peek))-(var(--shrink)*var(--height))))_scale(var(--scale))] [transition:
|
|
42
|
+
"h-(--height) [transform:translateX(var(--toast-swipe-movement-x))_translateY(calc(var(--toast-swipe-movement-y)-(var(--toast-index)*var(--peek))-(var(--shrink)*var(--height))))_scale(var(--scale))] [transition:transform_400ms_cubic-bezier(0.22,1,0.36,1),opacity_400ms,height_150ms] data-ending-style:[transition-duration:200ms] motion-reduce:[transition:opacity_150ms]",
|
|
43
43
|
"after:absolute after:top-full after:left-0 after:h-[calc(var(--gap)+1px)] after:w-full after:content-['']",
|
|
44
44
|
"data-expanded:h-(--toast-height) data-expanded:[transform:translateX(var(--toast-swipe-movement-x))_translateY(var(--offset-y))]",
|
|
45
45
|
"data-limited:opacity-0 data-starting-style:[transform:translateY(150%)]",
|