@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.
Files changed (295) hide show
  1. package/dist/{build-MFWRPYKW.js → build-U7GO26HR.js} +7 -7
  2. package/dist/{build-MFWRPYKW.js.map → build-U7GO26HR.js.map} +1 -1
  3. package/dist/{check-ZBIH422T.js → check-MRVAIHG5.js} +5 -5
  4. package/dist/{check-ZBIH422T.js.map → check-MRVAIHG5.js.map} +1 -1
  5. package/dist/chunk-2IAPIOPS.js +152 -0
  6. package/dist/chunk-2IAPIOPS.js.map +1 -0
  7. package/dist/chunk-3RJEOP3J.js +174 -0
  8. package/dist/chunk-3RJEOP3J.js.map +1 -0
  9. package/dist/chunk-77CISBMG.js +7581 -0
  10. package/dist/chunk-77CISBMG.js.map +1 -0
  11. package/dist/{chunk-V3LF7BE7.js → chunk-ANZLVSEP.js} +4 -5
  12. package/dist/chunk-ANZLVSEP.js.map +1 -0
  13. package/dist/{chunk-XQUSGIDG.js → chunk-CKWPK4RO.js} +10 -3
  14. package/dist/chunk-CKWPK4RO.js.map +1 -0
  15. package/dist/chunk-EG4PX726.js +678 -0
  16. package/dist/chunk-EG4PX726.js.map +1 -0
  17. package/dist/chunk-NZ5QIIG4.js +74 -0
  18. package/dist/chunk-NZ5QIIG4.js.map +1 -0
  19. package/dist/{chunk-7DZGJQ3P.js → chunk-PJ4SPXHS.js} +23 -6
  20. package/dist/chunk-PJ4SPXHS.js.map +1 -0
  21. package/dist/{chunk-OB6UBJXF.js → chunk-QNOX7WLZ.js} +127 -36
  22. package/dist/chunk-QNOX7WLZ.js.map +1 -0
  23. package/dist/{chunk-PXRX5PEC.js → chunk-ROHNXP7J.js} +73 -4
  24. package/dist/chunk-ROHNXP7J.js.map +1 -0
  25. package/dist/{chunk-CEXAQQ5W.js → chunk-S5MDTHH7.js} +180 -18
  26. package/dist/chunk-S5MDTHH7.js.map +1 -0
  27. package/dist/{chunk-IBGOCWJB.js → chunk-SDJTTMLK.js} +247 -86
  28. package/dist/chunk-SDJTTMLK.js.map +1 -0
  29. package/dist/{chunk-QEWCYW3I.js → chunk-SHZM3EXB.js} +29 -8
  30. package/dist/chunk-SHZM3EXB.js.map +1 -0
  31. package/dist/chunk-TRMHNMMZ.js +61 -0
  32. package/dist/chunk-TRMHNMMZ.js.map +1 -0
  33. package/dist/{chunk-A2UUGASH.js → chunk-U736PVHY.js} +2 -2
  34. package/dist/chunk-U736PVHY.js.map +1 -0
  35. package/dist/{chunk-JKLLFVEU.js → chunk-UWSQUHX6.js} +4 -99
  36. package/dist/chunk-UWSQUHX6.js.map +1 -0
  37. package/dist/cli.js +6 -6
  38. package/dist/client/index.d.ts +2 -0
  39. package/dist/client/index.js +8 -2
  40. package/dist/client/index.js.map +1 -1
  41. package/dist/components/index.d.ts +1617 -101
  42. package/dist/components/index.js +7 -4
  43. package/dist/delta-text-CbrOaW83.d.ts +17 -0
  44. package/dist/{dev-DCTOHQ6W.js → dev-O42JFQ64.js} +7 -7
  45. package/dist/{dev-DCTOHQ6W.js.map → dev-O42JFQ64.js.map} +1 -1
  46. package/dist/doc/index.d.ts +215 -2
  47. package/dist/doc/index.js +423 -5
  48. package/dist/doc/index.js.map +1 -1
  49. package/dist/{doctor-5E2VEZPK.js → doctor-YD3XAAOT.js} +5 -5
  50. package/dist/{doctor-5E2VEZPK.js.map → doctor-YD3XAAOT.js.map} +1 -1
  51. package/dist/format-DihQkL1N.d.ts +249 -0
  52. package/dist/markdown/index.js +1 -1
  53. package/dist/markdown/index.js.map +1 -1
  54. package/dist/query/index.js +2 -2
  55. package/dist/{routes-3SGAFDMC.js → routes-PVKNT777.js} +4 -4
  56. package/dist/{routes-3SGAFDMC.js.map → routes-PVKNT777.js.map} +1 -1
  57. package/dist/slide/index.d.ts +272 -1
  58. package/dist/slide/index.js +1025 -4
  59. package/dist/slide/index.js.map +1 -1
  60. package/dist/table/index.js +11 -8
  61. package/dist/table/index.js.map +1 -1
  62. package/dist/ui/index.d.ts +8 -2
  63. package/dist/ui/index.js +22 -112
  64. package/dist/ui/index.js.map +1 -1
  65. package/dist/{upgrade-DBBE6GIR.js → upgrade-6DT7ADRP.js} +4 -4
  66. package/dist/{upgrade-DBBE6GIR.js.map → upgrade-6DT7ADRP.js.map} +1 -1
  67. package/dist/vite/index.js +3 -3
  68. package/docs/en/agent-skills.md +1 -1
  69. package/docs/en/changelog.md +2 -0
  70. package/docs/en/components.md +42 -17
  71. package/docs/en/doc/delta-text.md +40 -0
  72. package/docs/en/doc/doc-action-items.md +49 -0
  73. package/docs/en/doc/doc-callout.md +38 -0
  74. package/docs/en/doc/doc-data-table.md +60 -0
  75. package/docs/en/doc/doc-executive-summary.md +64 -0
  76. package/docs/en/doc/doc-figure.md +56 -0
  77. package/docs/en/doc/doc-key-findings.md +61 -0
  78. package/docs/en/doc/doc-kpi-scorecard.md +80 -0
  79. package/docs/en/doc/doc-notes-and-sources.md +43 -0
  80. package/docs/en/doc/doc-report-header.md +46 -0
  81. package/docs/en/pages-and-metadata.md +15 -0
  82. package/docs/en/parts/area-chart.md +99 -0
  83. package/docs/en/parts/bar-chart.md +91 -0
  84. package/docs/en/parts/bar-list.md +50 -0
  85. package/docs/en/parts/category-bar.md +37 -0
  86. package/docs/en/parts/chart-frame.md +39 -0
  87. package/docs/en/parts/data-table.md +22 -0
  88. package/docs/en/parts/delta.md +51 -0
  89. package/docs/en/parts/donut-chart.md +72 -0
  90. package/docs/en/parts/format.md +43 -0
  91. package/docs/en/parts/funnel-steps.md +2 -1
  92. package/docs/en/parts/heatmap.md +53 -0
  93. package/docs/en/parts/kpi-card.md +58 -0
  94. package/docs/en/parts/legend.md +35 -0
  95. package/docs/en/parts/line-chart.md +94 -0
  96. package/docs/en/parts/metric-value.md +3 -2
  97. package/docs/en/parts/progress-circle.md +33 -0
  98. package/docs/en/parts/sample-data.md +39 -0
  99. package/docs/en/parts/scatter-chart.md +56 -0
  100. package/docs/en/parts/sparkline.md +1 -1
  101. package/docs/en/parts/tracker.md +36 -0
  102. package/docs/en/parts/trend-indicator.md +17 -1
  103. package/docs/en/parts/updated-at.md +30 -0
  104. package/docs/en/parts/waterfall-chart.md +56 -0
  105. package/docs/en/slide/slide-chart-full.md +48 -0
  106. package/docs/en/slide/slide-chart-insight.md +52 -0
  107. package/docs/en/slide/slide-columns.md +46 -0
  108. package/docs/en/slide/slide-comparison.md +68 -0
  109. package/docs/en/slide/slide-cover.md +39 -0
  110. package/docs/en/slide/slide-exec-summary.md +47 -0
  111. package/docs/en/slide/slide-heading.md +38 -0
  112. package/docs/en/slide/slide-kpi-grid.md +55 -0
  113. package/docs/en/slide/slide-kpi-hero.md +58 -0
  114. package/docs/en/slide/slide-next-actions.md +49 -0
  115. package/docs/en/slide/slide-scorecard-table.md +54 -0
  116. package/docs/en/slide/slide-section.md +44 -0
  117. package/docs/en/slide/slide-source-line.md +34 -0
  118. package/docs/en/ui/alert-dialog.md +42 -0
  119. package/docs/en/ui/avatar.md +31 -0
  120. package/docs/en/ui/combobox.md +74 -0
  121. package/docs/en/ui/drawer.md +41 -0
  122. package/docs/en/ui/empty.md +1 -1
  123. package/docs/en/ui/error-state.md +4 -3
  124. package/docs/en/ui/field.md +42 -0
  125. package/docs/en/ui/hover-card.md +21 -0
  126. package/docs/en/ui/kbd.md +17 -0
  127. package/docs/en/ui/loading.md +1 -1
  128. package/docs/en/ui/pagination.md +36 -0
  129. package/docs/en/ui/radio-group.md +21 -0
  130. package/docs/en/ui/toast.md +44 -0
  131. package/docs/en/ui/toggle-group.md +4 -3
  132. package/docs/en/ui-and-theming.md +1 -1
  133. package/docs/index.json +917 -77
  134. package/docs/ja/agent-skills.md +1 -1
  135. package/docs/ja/changelog.md +2 -0
  136. package/docs/ja/components.md +39 -16
  137. package/docs/ja/doc/delta-text.md +40 -0
  138. package/docs/ja/doc/doc-action-items.md +49 -0
  139. package/docs/ja/doc/doc-callout.md +38 -0
  140. package/docs/ja/doc/doc-data-table.md +60 -0
  141. package/docs/ja/doc/doc-executive-summary.md +64 -0
  142. package/docs/ja/doc/doc-figure.md +56 -0
  143. package/docs/ja/doc/doc-key-findings.md +61 -0
  144. package/docs/ja/doc/doc-kpi-scorecard.md +80 -0
  145. package/docs/ja/doc/doc-notes-and-sources.md +43 -0
  146. package/docs/ja/doc/doc-report-header.md +46 -0
  147. package/docs/ja/page-types/slide.md +1 -0
  148. package/docs/ja/pages-and-metadata.md +15 -0
  149. package/docs/ja/parts/area-chart.md +49 -25
  150. package/docs/ja/parts/bar-chart.md +50 -24
  151. package/docs/ja/parts/bar-list.md +31 -8
  152. package/docs/ja/parts/chart-frame.md +36 -0
  153. package/docs/ja/parts/data-table.md +22 -0
  154. package/docs/ja/parts/delta.md +51 -0
  155. package/docs/ja/parts/donut-chart.md +45 -26
  156. package/docs/ja/parts/format.md +44 -0
  157. package/docs/ja/parts/funnel-steps.md +27 -8
  158. package/docs/ja/parts/heatmap.md +45 -0
  159. package/docs/ja/parts/kpi-card.md +56 -0
  160. package/docs/ja/parts/legend.md +36 -0
  161. package/docs/ja/parts/line-chart.md +48 -22
  162. package/docs/ja/parts/metric-value.md +3 -2
  163. package/docs/ja/parts/sample-data.md +61 -0
  164. package/docs/ja/parts/scatter-chart.md +69 -0
  165. package/docs/ja/parts/sparkline.md +1 -1
  166. package/docs/ja/parts/trend-indicator.md +17 -1
  167. package/docs/ja/parts/updated-at.md +27 -0
  168. package/docs/ja/parts/waterfall-chart.md +61 -0
  169. package/docs/ja/slide/slide-chart-full.md +48 -0
  170. package/docs/ja/slide/slide-chart-insight.md +52 -0
  171. package/docs/ja/slide/slide-columns.md +46 -0
  172. package/docs/ja/slide/slide-comparison.md +68 -0
  173. package/docs/ja/slide/slide-cover.md +39 -0
  174. package/docs/ja/slide/slide-exec-summary.md +47 -0
  175. package/docs/ja/slide/slide-heading.md +38 -0
  176. package/docs/ja/slide/slide-kpi-grid.md +55 -0
  177. package/docs/ja/slide/slide-kpi-hero.md +58 -0
  178. package/docs/ja/slide/slide-next-actions.md +49 -0
  179. package/docs/ja/slide/slide-scorecard-table.md +54 -0
  180. package/docs/ja/slide/slide-section.md +44 -0
  181. package/docs/ja/slide/slide-source-line.md +34 -0
  182. package/docs/ja/ui/empty.md +1 -1
  183. package/docs/ja/ui/error-state.md +4 -3
  184. package/docs/ja/ui/loading.md +1 -1
  185. package/docs/ja/ui/toggle-group.md +4 -3
  186. package/docs/ja/ui-and-theming.md +2 -2
  187. package/package.json +26 -24
  188. package/registry/ui/accordion.tsx +4 -2
  189. package/registry/ui/alert-dialog.tsx +3 -3
  190. package/registry/ui/alert.tsx +3 -1
  191. package/registry/ui/app-shell.tsx +145 -2
  192. package/registry/ui/area-chart.tsx +3111 -166
  193. package/registry/ui/attention-list.tsx +465 -0
  194. package/registry/ui/avatar.tsx +1 -1
  195. package/registry/ui/badge.tsx +3 -1
  196. package/registry/ui/bar-chart.tsx +3105 -164
  197. package/registry/ui/bar-list.tsx +3877 -181
  198. package/registry/ui/box-plot-chart.tsx +4214 -0
  199. package/registry/ui/breadcrumb.tsx +3 -1
  200. package/registry/ui/button.tsx +3 -1
  201. package/registry/ui/calendar.tsx +3 -1
  202. package/registry/ui/card.tsx +4 -2
  203. package/registry/ui/category-bar.tsx +1233 -16
  204. package/registry/ui/chart-frame.tsx +1604 -0
  205. package/registry/ui/checkbox.tsx +3 -1
  206. package/registry/ui/collapsible.tsx +3 -1
  207. package/registry/ui/combobox.tsx +2 -2
  208. package/registry/ui/command.tsx +3 -1
  209. package/registry/ui/dashboard-card.tsx +71 -28
  210. package/registry/ui/data-table.tsx +882 -68
  211. package/registry/ui/date-range-picker.tsx +400 -65
  212. package/registry/ui/delta.tsx +350 -0
  213. package/registry/ui/dialog.tsx +5 -3
  214. package/registry/ui/donut-chart.tsx +3184 -182
  215. package/registry/ui/drawer.tsx +1 -1
  216. package/registry/ui/dropdown-menu.tsx +5 -3
  217. package/registry/ui/echart.tsx +761 -69
  218. package/registry/ui/field.tsx +1 -1
  219. package/registry/ui/filter-bar.tsx +212 -26
  220. package/registry/ui/funnel-steps.tsx +3622 -53
  221. package/registry/ui/heatmap.tsx +2027 -0
  222. package/registry/ui/histogram-chart.tsx +4284 -0
  223. package/registry/ui/hover-card.tsx +2 -2
  224. package/registry/ui/input-group.tsx +3 -1
  225. package/registry/ui/input.tsx +3 -1
  226. package/registry/ui/kbd.tsx +3 -1
  227. package/registry/ui/kpi-card.tsx +905 -0
  228. package/registry/ui/label.tsx +3 -1
  229. package/registry/ui/legend.tsx +3817 -0
  230. package/registry/ui/line-chart.tsx +3109 -158
  231. package/registry/ui/metric-value.tsx +9 -1
  232. package/registry/ui/multi-select.tsx +170 -14
  233. package/registry/ui/page-shell.tsx +244 -51
  234. package/registry/ui/pagination.tsx +3 -1
  235. package/registry/ui/paired-chart.tsx +4086 -0
  236. package/registry/ui/placeholder.tsx +8 -2
  237. package/registry/ui/popover.tsx +4 -2
  238. package/registry/ui/progress-circle.tsx +773 -12
  239. package/registry/ui/progress.tsx +3 -1
  240. package/registry/ui/radio-group.tsx +1 -1
  241. package/registry/ui/sample-data.tsx +230 -0
  242. package/registry/ui/scatter-chart.tsx +4503 -0
  243. package/registry/ui/scroll-area.tsx +3 -2
  244. package/registry/ui/searchable-select.tsx +153 -10
  245. package/registry/ui/section-header.tsx +5 -3
  246. package/registry/ui/segmented-control.tsx +7 -2
  247. package/registry/ui/select.tsx +4 -2
  248. package/registry/ui/separator.tsx +3 -1
  249. package/registry/ui/sheet.tsx +4 -2
  250. package/registry/ui/sidebar.tsx +4 -2
  251. package/registry/ui/skeleton.tsx +4 -2
  252. package/registry/ui/slider.tsx +4 -2
  253. package/registry/ui/sparkline.tsx +84 -9
  254. package/registry/ui/spinner.tsx +3 -1
  255. package/registry/ui/states.tsx +194 -8
  256. package/registry/ui/status-badge.tsx +246 -39
  257. package/registry/ui/switch.tsx +3 -1
  258. package/registry/ui/table.tsx +4 -2
  259. package/registry/ui/tabs.tsx +5 -3
  260. package/registry/ui/textarea.tsx +3 -1
  261. package/registry/ui/toast.tsx +2 -2
  262. package/registry/ui/toggle-group.tsx +3 -1
  263. package/registry/ui/toggle.tsx +3 -1
  264. package/registry/ui/tooltip.tsx +10 -4
  265. package/registry/ui/tracker.tsx +798 -19
  266. package/registry/ui/trend-indicator.tsx +164 -9
  267. package/registry/ui/updated-at.tsx +276 -0
  268. package/registry/ui/waterfall-chart.tsx +4561 -0
  269. package/skills/vantage-add-feature/SKILL.md +5 -0
  270. package/skills/vantage-design/SKILL.md +60 -52
  271. package/skills/vantage-design/references/extract.md +26 -27
  272. package/skills/vantage-design/references/format.md +12 -172
  273. package/skills/vantage-design/references/presets.md +50 -110
  274. package/skills/vantage-pitfalls/SKILL.md +5 -0
  275. package/skills/vantage-slide/SKILL.md +54 -36
  276. package/templates/AGENTS.md +45 -16
  277. package/templates/agents/api.md +7 -0
  278. package/templates/agents/doc.md +48 -0
  279. package/templates/agents/page.md +69 -2
  280. package/templates/agents/slide.md +77 -3
  281. package/theme.css +247 -149
  282. package/dist/chunk-5ZOP4SQR.js +0 -47
  283. package/dist/chunk-5ZOP4SQR.js.map +0 -1
  284. package/dist/chunk-7DZGJQ3P.js.map +0 -1
  285. package/dist/chunk-A2UUGASH.js.map +0 -1
  286. package/dist/chunk-AG6RZ2RR.js +0 -3208
  287. package/dist/chunk-AG6RZ2RR.js.map +0 -1
  288. package/dist/chunk-CEXAQQ5W.js.map +0 -1
  289. package/dist/chunk-IBGOCWJB.js.map +0 -1
  290. package/dist/chunk-JKLLFVEU.js.map +0 -1
  291. package/dist/chunk-OB6UBJXF.js.map +0 -1
  292. package/dist/chunk-PXRX5PEC.js.map +0 -1
  293. package/dist/chunk-QEWCYW3I.js.map +0 -1
  294. package/dist/chunk-V3LF7BE7.js.map +0 -1
  295. package/dist/chunk-XQUSGIDG.js.map +0 -1
@@ -1,9 +1,13 @@
1
1
  // Copied by `vantage add ui trend-indicator`. This file is yours to edit.
2
- // Generated from @squadbase/vantage src/components/trend-indicator.tsx by `npm run registry` (in Vantage, edit src/, not registry/).
2
+ // Generated from @squadbase/squadkit registry/components/trend-indicator.tsx by `pnpm run registry` (in Vantage, edit packages/squadkit, not registry/).
3
+ "use client"
4
+
3
5
  /**
4
6
  * TrendIndicator — an arrow plus percentage change. Colour tracks *sentiment*,
5
7
  * not direction: set `positiveIsGood={false}` for metrics where going up is bad
6
8
  * (churn, error rate) and a rise renders as negative.
9
+ *
10
+ * @deprecated 新規は Delta を使う。value/direction を別々に受けるため食い違える(C4)。
7
11
  */
8
12
  import { forwardRef } from "react"
9
13
  import { ArrowDown, ArrowUp, Minus } from "lucide-react"
@@ -11,12 +15,159 @@ import { cva } from "class-variance-authority"
11
15
 
12
16
  import { cn } from "@squadbase/vantage/ui"
13
17
  import type { TrendDirection } from "@squadbase/vantage/components"
18
+ import { useSyncExternalStore } from "react"
19
+
20
+ /* ---------- inlined from @squadbase/squadkit registry/lib/locale.ts (internal to @squadbase/vantage) ---------- */
21
+
22
+ /**
23
+ * The display language of the parts and the defaults that follow it.
24
+ *
25
+ * The language comes from `<html lang>`: a tag starting with `ja` reads Japanese, anything else English.
26
+ * Without a usable `lang` (missing, invalid, or no `document` — SSR, Node) the locale is `FALLBACK_LOCALE`
27
+ * (`en-US`). A `locale` passed explicitly (a prop, an argument) always wins.
28
+ *
29
+ * Parts read the locale through `useLocale` (`hooks/use-locale`) and pass it down; the pure helpers here
30
+ * and in `format` / `comparison` / `chart-*` take it as an argument and fall back to `documentLocale()`.
31
+ */
32
+
33
+ /** The language of the built-in wording: Japanese or English. */
34
+ type UiLanguage = "ja" | "en"
35
+
36
+ /** The locale used when `<html lang>` gives none (and on the server). */
37
+ const FALLBACK_LOCALE = "en-US"
38
+
39
+ /** `"ja"` when `locale` starts with `ja` (`ja`, `ja-JP`), else `"en"`. A missing locale is `"en"`. */
40
+ function uiLanguage(locale: string | null | undefined): UiLanguage {
41
+ return typeof locale === "string" && locale.trim().toLowerCase().startsWith("ja") ? "ja" : "en"
42
+ }
43
+
44
+ /** A BCP 47 tag in its canonical form (`en-gb` → `en-GB`), or `FALLBACK_LOCALE` when it is empty or invalid. */
45
+ function normalizeLocale(tag: string | null | undefined): string {
46
+ const value = tag?.trim()
47
+ if (!value) return FALLBACK_LOCALE
48
+ try {
49
+ return Intl.getCanonicalLocales(value)[0] ?? FALLBACK_LOCALE
50
+ } catch {
51
+ return FALLBACK_LOCALE
52
+ }
53
+ }
54
+
55
+ /**
56
+ * The locale of the page: `document.documentElement.lang`, canonicalized. `FALLBACK_LOCALE` when it is empty or
57
+ * invalid, or there is no `document`. Parts read it through `useLocale`, never while rendering.
58
+ */
59
+ function documentLocale(): string {
60
+ if (typeof document === "undefined") return FALLBACK_LOCALE
61
+ return normalizeLocale(document.documentElement?.getAttribute("lang"))
62
+ }
63
+
64
+ /** `locale` when given, else the page's locale (`documentLocale()`). */
65
+ function resolveLocale(locale?: string | null): string {
66
+ return locale || documentLocale()
67
+ }
68
+
69
+ /** Picks the wording table of the locale's language. */
70
+ function pickLocale<T>(table: { ja: T; en: T }, locale?: string | null): T {
71
+ return table[uiLanguage(resolveLocale(locale))]
72
+ }
73
+
74
+ /** The currency `format="currency"` uses without a `currency`: JPY for Japanese, USD otherwise. */
75
+ function defaultCurrency(locale?: string | null): string {
76
+ return uiLanguage(resolveLocale(locale)) === "ja" ? "JPY" : "USD"
77
+ }
78
+
79
+ /** The month a fiscal year starts in (1–12) when none is given: April for Japanese, January otherwise. */
80
+ function defaultFiscalYearStartMonth(locale?: string | null): number {
81
+ return uiLanguage(resolveLocale(locale)) === "ja" ? 4 : 1
82
+ }
83
+
84
+ /** A day of the week, 0 = Sunday … 6 = Saturday (the `Date#getDay` / date-fns numbering). */
85
+ type WeekDay = 0 | 1 | 2 | 3 | 4 | 5 | 6
86
+
87
+ /** Locales whose week starts on Sunday when the runtime has no week data. */
88
+ const SUNDAY_FIRST = new Set(["en", "en-US", "en-CA"])
89
+
90
+ /**
91
+ * The first day of the week: Monday for Japanese; otherwise the locale's convention from `Intl.Locale`
92
+ * (`en-US` Sunday, `en-GB` Monday). Without week data in the runtime: Sunday for `en` / `en-US` / `en-CA`,
93
+ * Monday for the rest.
94
+ */
95
+ function weekStartsOn(locale?: string | null): WeekDay {
96
+ const tag = normalizeLocale(resolveLocale(locale))
97
+ if (uiLanguage(tag) === "ja") return 1
98
+ try {
99
+ const info = new Intl.Locale(tag) as Intl.Locale & {
100
+ getWeekInfo?: () => { firstDay: number }
101
+ weekInfo?: { firstDay: number }
102
+ }
103
+ const firstDay = info.getWeekInfo?.().firstDay ?? info.weekInfo?.firstDay
104
+ if (typeof firstDay === "number" && firstDay >= 1 && firstDay <= 7) return (firstDay % 7) as WeekDay
105
+ } catch {
106
+ // Fall through to the table below.
107
+ }
108
+ return SUNDAY_FIRST.has(tag) ? 0 : 1
109
+ }
110
+
111
+ /* ---------- inlined from @squadbase/squadkit registry/hooks/use-locale.ts (internal to @squadbase/vantage) ---------- */
112
+
113
+ const listeners = new Set<() => void>()
114
+ let observer: MutationObserver | null = null
115
+
116
+ /** One observer on `<html lang>` for every subscribed part. */
117
+ function subscribe(onChange: () => void): () => void {
118
+ if (typeof document === "undefined" || typeof MutationObserver === "undefined") return () => {}
119
+ listeners.add(onChange)
120
+ if (!observer) {
121
+ observer = new MutationObserver(() => {
122
+ for (const listener of [...listeners]) listener()
123
+ })
124
+ observer.observe(document.documentElement, { attributes: true, attributeFilter: ["lang"] })
125
+ }
126
+ return () => {
127
+ listeners.delete(onChange)
128
+ if (listeners.size === 0 && observer) {
129
+ observer.disconnect()
130
+ observer = null
131
+ }
132
+ }
133
+ }
134
+
135
+ const serverLocale = () => FALLBACK_LOCALE
136
+
137
+ /**
138
+ * The page's locale (`<html lang>`), following changes made while the page runs. On the server and during
139
+ * hydration it is `FALLBACK_LOCALE` (`en-US`), so the markup matches; it switches right after.
140
+ */
141
+ function useDocumentLocale(): string {
142
+ return useSyncExternalStore(subscribe, documentLocale, serverLocale)
143
+ }
144
+
145
+ /** The locale a part renders in: its `locale` prop when given, else the page's (`useDocumentLocale`). */
146
+ function useLocale(locale?: string | null): string {
147
+ const page = useDocumentLocale()
148
+ return locale || page
149
+ }
150
+
151
+ /* ---------- end of inlined code ---------- */
152
+
153
+ const TEXT = {
154
+ ja: {
155
+ flat: (value: number) => `変化なし ${value}%`,
156
+ up: (value: number) => `${value}% 増加`,
157
+ down: (value: number) => `${value}% 減少`,
158
+ },
159
+ en: {
160
+ flat: (value: number) => `No change ${value}%`,
161
+ up: (value: number) => `Up ${value}%`,
162
+ down: (value: number) => `Down ${value}%`,
163
+ },
164
+ }
14
165
 
15
166
  const trendIndicatorVariants = cva("inline-flex items-center gap-0.5 text-sm font-medium", {
16
167
  variants: {
17
168
  sentiment: {
18
- positive: "text-chart-1",
19
- negative: "text-primary",
169
+ positive: "text-positive",
170
+ negative: "text-negative",
20
171
  neutral: "text-muted-foreground",
21
172
  },
22
173
  },
@@ -25,6 +176,9 @@ const trendIndicatorVariants = cva("inline-flex items-center gap-0.5 text-sm fon
25
176
  },
26
177
  })
27
178
 
179
+ /**
180
+ * @deprecated 新規は Delta を使う。value/direction を別々に受けるため食い違える(C4)。
181
+ */
28
182
  export interface TrendIndicatorProps {
29
183
  value: number
30
184
  direction: TrendDirection
@@ -32,6 +186,11 @@ export interface TrendIndicatorProps {
32
186
  className?: string
33
187
  }
34
188
 
189
+ /**
190
+ * Arrow plus percentage change.
191
+ *
192
+ * @deprecated 新規は Delta を使う。value/direction を別々に受けるため食い違える(C4)。
193
+ */
35
194
  export const TrendIndicator = forwardRef<HTMLSpanElement, TrendIndicatorProps>(
36
195
  ({ value, direction, positiveIsGood = true, className }, ref) => {
37
196
  const isGood = direction === "neutral" ? null : (direction === "up") === positiveIsGood
@@ -39,12 +198,8 @@ export const TrendIndicator = forwardRef<HTMLSpanElement, TrendIndicatorProps>(
39
198
 
40
199
  const Icon = direction === "up" ? ArrowUp : direction === "down" ? ArrowDown : Minus
41
200
 
42
- const ariaLabel =
43
- direction === "neutral"
44
- ? `変化なし ${value}%`
45
- : direction === "up"
46
- ? `${value}% 増加`
47
- : `${value}% 減少`
201
+ const t = TEXT[uiLanguage(useLocale())]
202
+ const ariaLabel = direction === "neutral" ? t.flat(value) : direction === "up" ? t.up(value) : t.down(value)
48
203
 
49
204
  return (
50
205
  <span
@@ -0,0 +1,276 @@
1
+ // Copied by `vantage add ui updated-at`. This file is yours to edit.
2
+ // Generated from @squadbase/squadkit registry/components/updated-at.tsx by `pnpm run registry` (in Vantage, edit packages/squadkit, not registry/).
3
+ "use client"
4
+
5
+ /**
6
+ * UpdatedAt — freshness label. Renders a `<time>` whose `dateTime` is the ISO
7
+ * instant, with the absolute time and zone ("2026/10/20 16:41 JST") in both a
8
+ * tooltip and the `title` attribute.
9
+ *
10
+ * `variant="relative"` (default) reads "Updated 23 minutes ago" (ja: "23 分前に更新"); `"absolute-first"` reads
11
+ * "Updated 16:41 (23 minutes ago)" (ja: "16:41 更新(23 分前)") (the date is added when it is not today).
12
+ * The language and date format follow the page (`<html lang>`).
13
+ *
14
+ * Hydration-safe: the first render (server and client) is an empty `<time>`
15
+ * carrying only the ISO `dateTime`, because the text depends on the clock and
16
+ * time zone of whoever renders. After mount it shows the label and refreshes
17
+ * every 60 seconds; the interval is cleared on unmount. `now` pins the clock
18
+ * (tests, fixtures) and skips the timer; `timeZone` pins the zone. The `<time>`
19
+ * sets `suppressHydrationWarning` so sample data built from `Date.now()` at
20
+ * module load (which differs between server and client) does not warn.
21
+ */
22
+ import { forwardRef, useEffect, useState } from "react"
23
+
24
+ import { EMPTY_VALUE, formatDate } from "@squadbase/vantage/components"
25
+ import { formatRelativeTime } from "@squadbase/vantage/components"
26
+ import { cn } from "@squadbase/vantage/ui"
27
+ import { Tooltip, TooltipContent, TooltipTrigger } from "@squadbase/vantage/ui"
28
+ import { useSyncExternalStore } from "react"
29
+
30
+ /* ---------- inlined from @squadbase/squadkit registry/lib/locale.ts (internal to @squadbase/vantage) ---------- */
31
+
32
+ /**
33
+ * The display language of the parts and the defaults that follow it.
34
+ *
35
+ * The language comes from `<html lang>`: a tag starting with `ja` reads Japanese, anything else English.
36
+ * Without a usable `lang` (missing, invalid, or no `document` — SSR, Node) the locale is `FALLBACK_LOCALE`
37
+ * (`en-US`). A `locale` passed explicitly (a prop, an argument) always wins.
38
+ *
39
+ * Parts read the locale through `useLocale` (`hooks/use-locale`) and pass it down; the pure helpers here
40
+ * and in `format` / `comparison` / `chart-*` take it as an argument and fall back to `documentLocale()`.
41
+ */
42
+
43
+ /** The language of the built-in wording: Japanese or English. */
44
+ type UiLanguage = "ja" | "en"
45
+
46
+ /** The locale used when `<html lang>` gives none (and on the server). */
47
+ const FALLBACK_LOCALE = "en-US"
48
+
49
+ /** `"ja"` when `locale` starts with `ja` (`ja`, `ja-JP`), else `"en"`. A missing locale is `"en"`. */
50
+ function uiLanguage(locale: string | null | undefined): UiLanguage {
51
+ return typeof locale === "string" && locale.trim().toLowerCase().startsWith("ja") ? "ja" : "en"
52
+ }
53
+
54
+ /** A BCP 47 tag in its canonical form (`en-gb` → `en-GB`), or `FALLBACK_LOCALE` when it is empty or invalid. */
55
+ function normalizeLocale(tag: string | null | undefined): string {
56
+ const value = tag?.trim()
57
+ if (!value) return FALLBACK_LOCALE
58
+ try {
59
+ return Intl.getCanonicalLocales(value)[0] ?? FALLBACK_LOCALE
60
+ } catch {
61
+ return FALLBACK_LOCALE
62
+ }
63
+ }
64
+
65
+ /**
66
+ * The locale of the page: `document.documentElement.lang`, canonicalized. `FALLBACK_LOCALE` when it is empty or
67
+ * invalid, or there is no `document`. Parts read it through `useLocale`, never while rendering.
68
+ */
69
+ function documentLocale(): string {
70
+ if (typeof document === "undefined") return FALLBACK_LOCALE
71
+ return normalizeLocale(document.documentElement?.getAttribute("lang"))
72
+ }
73
+
74
+ /** `locale` when given, else the page's locale (`documentLocale()`). */
75
+ function resolveLocale(locale?: string | null): string {
76
+ return locale || documentLocale()
77
+ }
78
+
79
+ /** Picks the wording table of the locale's language. */
80
+ function pickLocale<T>(table: { ja: T; en: T }, locale?: string | null): T {
81
+ return table[uiLanguage(resolveLocale(locale))]
82
+ }
83
+
84
+ /** The currency `format="currency"` uses without a `currency`: JPY for Japanese, USD otherwise. */
85
+ function defaultCurrency(locale?: string | null): string {
86
+ return uiLanguage(resolveLocale(locale)) === "ja" ? "JPY" : "USD"
87
+ }
88
+
89
+ /** The month a fiscal year starts in (1–12) when none is given: April for Japanese, January otherwise. */
90
+ function defaultFiscalYearStartMonth(locale?: string | null): number {
91
+ return uiLanguage(resolveLocale(locale)) === "ja" ? 4 : 1
92
+ }
93
+
94
+ /** A day of the week, 0 = Sunday … 6 = Saturday (the `Date#getDay` / date-fns numbering). */
95
+ type WeekDay = 0 | 1 | 2 | 3 | 4 | 5 | 6
96
+
97
+ /** Locales whose week starts on Sunday when the runtime has no week data. */
98
+ const SUNDAY_FIRST = new Set(["en", "en-US", "en-CA"])
99
+
100
+ /**
101
+ * The first day of the week: Monday for Japanese; otherwise the locale's convention from `Intl.Locale`
102
+ * (`en-US` Sunday, `en-GB` Monday). Without week data in the runtime: Sunday for `en` / `en-US` / `en-CA`,
103
+ * Monday for the rest.
104
+ */
105
+ function weekStartsOn(locale?: string | null): WeekDay {
106
+ const tag = normalizeLocale(resolveLocale(locale))
107
+ if (uiLanguage(tag) === "ja") return 1
108
+ try {
109
+ const info = new Intl.Locale(tag) as Intl.Locale & {
110
+ getWeekInfo?: () => { firstDay: number }
111
+ weekInfo?: { firstDay: number }
112
+ }
113
+ const firstDay = info.getWeekInfo?.().firstDay ?? info.weekInfo?.firstDay
114
+ if (typeof firstDay === "number" && firstDay >= 1 && firstDay <= 7) return (firstDay % 7) as WeekDay
115
+ } catch {
116
+ // Fall through to the table below.
117
+ }
118
+ return SUNDAY_FIRST.has(tag) ? 0 : 1
119
+ }
120
+
121
+ /* ---------- inlined from @squadbase/squadkit registry/hooks/use-locale.ts (internal to @squadbase/vantage) ---------- */
122
+
123
+ const listeners = new Set<() => void>()
124
+ let observer: MutationObserver | null = null
125
+
126
+ /** One observer on `<html lang>` for every subscribed part. */
127
+ function subscribe(onChange: () => void): () => void {
128
+ if (typeof document === "undefined" || typeof MutationObserver === "undefined") return () => {}
129
+ listeners.add(onChange)
130
+ if (!observer) {
131
+ observer = new MutationObserver(() => {
132
+ for (const listener of [...listeners]) listener()
133
+ })
134
+ observer.observe(document.documentElement, { attributes: true, attributeFilter: ["lang"] })
135
+ }
136
+ return () => {
137
+ listeners.delete(onChange)
138
+ if (listeners.size === 0 && observer) {
139
+ observer.disconnect()
140
+ observer = null
141
+ }
142
+ }
143
+ }
144
+
145
+ const serverLocale = () => FALLBACK_LOCALE
146
+
147
+ /**
148
+ * The page's locale (`<html lang>`), following changes made while the page runs. On the server and during
149
+ * hydration it is `FALLBACK_LOCALE` (`en-US`), so the markup matches; it switches right after.
150
+ */
151
+ function useDocumentLocale(): string {
152
+ return useSyncExternalStore(subscribe, documentLocale, serverLocale)
153
+ }
154
+
155
+ /** The locale a part renders in: its `locale` prop when given, else the page's (`useDocumentLocale`). */
156
+ function useLocale(locale?: string | null): string {
157
+ const page = useDocumentLocale()
158
+ return locale || page
159
+ }
160
+
161
+ /* ---------- end of inlined code ---------- */
162
+
163
+ const REFRESH_MS = 60_000
164
+
165
+ const TEXT = {
166
+ ja: {
167
+ justNow: "たった今",
168
+ relative: (relative: string) => `${relative}に更新`,
169
+ absoluteFirst: (shown: string, relative: string) => `${shown} 更新(${relative})`,
170
+ },
171
+ en: {
172
+ justNow: "just now",
173
+ relative: (relative: string) => `Updated ${relative}`,
174
+ absoluteFirst: (shown: string, relative: string) => `Updated ${shown} (${relative})`,
175
+ },
176
+ }
177
+
178
+ export interface UpdatedAtProps {
179
+ /** When the data was last updated. */
180
+ at: Date | string | number
181
+ /** `"relative"` (default): "23 分前に更新". `"absolute-first"`: "16:41 更新(23 分前)" — for pages where "now" matters. */
182
+ variant?: "relative" | "absolute-first"
183
+ /** IANA time zone (e.g. `"Asia/Tokyo"`) for the absolute time. Defaults to the runtime's zone. */
184
+ timeZone?: string
185
+ /** Text placed before the label, e.g. `"売上データ: "`. */
186
+ prefix?: string
187
+ /** Fixed "current time" for tests and fixtures. Disables the 60 s refresh. */
188
+ now?: Date | number
189
+ className?: string
190
+ }
191
+
192
+ const toMs = (value: Date | string | number) =>
193
+ value instanceof Date ? value.getTime() : new Date(value).getTime()
194
+
195
+ function relative(at: number, now: number, locale: string): string {
196
+ if (now - at < REFRESH_MS && now - at > -REFRESH_MS) return TEXT[uiLanguage(locale)].justNow
197
+ return formatRelativeTime(at, { now, locale })
198
+ }
199
+
200
+ /** "2026/10/20 16:41 JST" */
201
+ function absolute(at: number, locale: string, timeZone?: string): string | undefined {
202
+ if (!Number.isFinite(at)) return undefined
203
+ const zone = new Intl.DateTimeFormat(locale, { timeZone, timeZoneName: "short" })
204
+ .formatToParts(at)
205
+ .find((part) => part.type === "timeZoneName")?.value
206
+ const text = formatDate(at, "datetime", locale, { timeZone })
207
+ return zone ? `${text} ${zone}` : text
208
+ }
209
+
210
+ function label(at: number, now: number, variant: "relative" | "absolute-first", locale: string, timeZone?: string): string {
211
+ if (!Number.isFinite(at) || !Number.isFinite(now)) return EMPTY_VALUE
212
+ const t = TEXT[uiLanguage(locale)]
213
+ if (variant === "relative") {
214
+ return now - at < REFRESH_MS && now - at > -REFRESH_MS
215
+ ? uiLanguage(locale) === "ja"
216
+ ? t.justNow
217
+ : t.relative(t.justNow)
218
+ : t.relative(relative(at, now, locale))
219
+ }
220
+ const today = formatDate(at, "date", locale, { timeZone }) === formatDate(now, "date", locale, { timeZone })
221
+ const when = formatDate(at, "datetime", locale, { timeZone })
222
+ // "2026/10/20 16:41" -> time only when it is today (the time is always the last 5 characters: hourCycle h23).
223
+ const shown = today ? when.slice(-5) : when
224
+ return t.absoluteFirst(shown, relative(at, now, locale))
225
+ }
226
+
227
+ export const UpdatedAt = forwardRef<HTMLTimeElement, UpdatedAtProps>(
228
+ ({ at, variant = "relative", timeZone, prefix, now, className }, ref) => {
229
+ const locale = useLocale()
230
+ const atMs = toMs(at)
231
+ const [current, setCurrent] = useState<number | null>(null)
232
+ const fixed = now === undefined ? undefined : toMs(now as Date | number)
233
+
234
+ useEffect(() => {
235
+ if (fixed !== undefined) return
236
+ setCurrent(Date.now())
237
+ const id = setInterval(() => setCurrent(Date.now()), REFRESH_MS)
238
+ return () => clearInterval(id)
239
+ }, [fixed])
240
+
241
+ const clock = fixed ?? current
242
+ const ready = clock !== null
243
+ const dateTime = Number.isFinite(atMs) ? new Date(atMs).toISOString() : undefined
244
+ const full = ready ? absolute(atMs, locale, timeZone) : undefined
245
+ const classes = cn("text-sm text-muted-foreground tabular-nums", className)
246
+ const text = ready ? `${prefix ?? ""}${label(atMs, clock, variant, locale, timeZone)}` : null
247
+
248
+ if (!full) {
249
+ return (
250
+ <time ref={ref} data-slot="updated-at" dateTime={dateTime} className={classes} suppressHydrationWarning>
251
+ {text}
252
+ </time>
253
+ )
254
+ }
255
+ return (
256
+ <Tooltip>
257
+ <TooltipTrigger
258
+ render={
259
+ <time
260
+ ref={ref}
261
+ data-slot="updated-at"
262
+ dateTime={dateTime}
263
+ title={full}
264
+ className={classes}
265
+ suppressHydrationWarning
266
+ />
267
+ }
268
+ >
269
+ {text}
270
+ </TooltipTrigger>
271
+ <TooltipContent className="tabular-nums">{full}</TooltipContent>
272
+ </Tooltip>
273
+ )
274
+ },
275
+ )
276
+ UpdatedAt.displayName = "UpdatedAt"