@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
@@ -0,0 +1,350 @@
1
+ // Copied by `vantage add ui delta`. This file is yours to edit.
2
+ // Generated from @squadbase/squadkit registry/components/delta.tsx by `pnpm run registry` (in Vantage, edit packages/squadkit, not registry/).
3
+ "use client"
4
+
5
+ /**
6
+ * Delta — the change of a value against a comparison, rendered as arrow + signed
7
+ * change + comparison label ("↑ +12.4% vs. prior month"; ja: "↑ +12.4% 前月比") on one line, in the page's
8
+ * language (`<html lang>`) unless `locale` is given.
9
+ *
10
+ * Direction, rate, colour and wording are all derived here from `value` and
11
+ * `comparison` (via `computeComparison`); none of them can be passed in, so they
12
+ * cannot contradict each other. Colour is never the only signal: the arrow and
13
+ * the sign always accompany it. Set `betterWhen="down"` for metrics
14
+ * where a rise is bad (churn, error rate).
15
+ *
16
+ * - A flat change (inside `neutralBand`) uses a right arrow (→), never a minus-like dash, so it cannot
17
+ * read as "− +0.19pt".
18
+ * - The label comes from `comparison.vs` and `comparison.grain`: a monthly
19
+ * `prior-period` reads "前月比", `prior-year` "前年同月比".
20
+ * - Pass the metric's `format`: a `percent` metric (a rate) shows the difference
21
+ * in percentage points ("−0.5pt") instead of a relative change ("−19.2%"). A minus is
22
+ * always U+2212, and the digits of a relative change / points are fixed (default 1:
23
+ * "+14.0%" beside "+11.9%"); `digits` sets the same count for every card in a group.
24
+ * - A running total (YTD / MTD) sets `comparison.toDate`: `prior-year` then reads
25
+ * "前年同期比" instead of "前年比" whatever the grain.
26
+ * - When the values cannot be compared (a null value, no previous one), it shows a single muted
27
+ * "—" with no arrow (and the label, so "— 前年同月比" says which comparison is missing). The
28
+ * screen-reader text says "比較できません".
29
+ *
30
+ * @example
31
+ * import { Delta } from "@/components/delta"
32
+ * // Vantage: import { Delta } from "@squadbase/vantage/components"
33
+ *
34
+ * <Delta value={48_200_000} comparison={{ previous: 42_900_000, vs: "prior-period", grain: "month" }} />
35
+ * <Delta value={0.021} format="percent" betterWhen="down"
36
+ * comparison={{ previous: 0.026, vs: "prior-year", grain: "month" }} />
37
+ */
38
+ import { forwardRef, type HTMLAttributes } from "react"
39
+ import { ArrowDown, ArrowRight, ArrowUp } from "lucide-react"
40
+ import { cva, type VariantProps } from "class-variance-authority"
41
+
42
+ import { cn } from "@squadbase/vantage/ui"
43
+ import {
44
+ computeComparison,
45
+ defaultChangeDisplay,
46
+ formatChange,
47
+ formatChangeAmount,
48
+ type ChangeDisplay,
49
+ type Comparison,
50
+ type ComparisonResult,
51
+ type Polarity,
52
+ } from "@squadbase/vantage/components"
53
+ import { EMPTY_VALUE, type ValueFormat } from "@squadbase/vantage/components"
54
+ import { useSyncExternalStore } from "react"
55
+
56
+ /* ---------- inlined from @squadbase/squadkit registry/lib/locale.ts (internal to @squadbase/vantage) ---------- */
57
+
58
+ /**
59
+ * The display language of the parts and the defaults that follow it.
60
+ *
61
+ * The language comes from `<html lang>`: a tag starting with `ja` reads Japanese, anything else English.
62
+ * Without a usable `lang` (missing, invalid, or no `document` — SSR, Node) the locale is `FALLBACK_LOCALE`
63
+ * (`en-US`). A `locale` passed explicitly (a prop, an argument) always wins.
64
+ *
65
+ * Parts read the locale through `useLocale` (`hooks/use-locale`) and pass it down; the pure helpers here
66
+ * and in `format` / `comparison` / `chart-*` take it as an argument and fall back to `documentLocale()`.
67
+ */
68
+
69
+ /** The language of the built-in wording: Japanese or English. */
70
+ type UiLanguage = "ja" | "en"
71
+
72
+ /** The locale used when `<html lang>` gives none (and on the server). */
73
+ const FALLBACK_LOCALE = "en-US"
74
+
75
+ /** `"ja"` when `locale` starts with `ja` (`ja`, `ja-JP`), else `"en"`. A missing locale is `"en"`. */
76
+ function uiLanguage(locale: string | null | undefined): UiLanguage {
77
+ return typeof locale === "string" && locale.trim().toLowerCase().startsWith("ja") ? "ja" : "en"
78
+ }
79
+
80
+ /** A BCP 47 tag in its canonical form (`en-gb` → `en-GB`), or `FALLBACK_LOCALE` when it is empty or invalid. */
81
+ function normalizeLocale(tag: string | null | undefined): string {
82
+ const value = tag?.trim()
83
+ if (!value) return FALLBACK_LOCALE
84
+ try {
85
+ return Intl.getCanonicalLocales(value)[0] ?? FALLBACK_LOCALE
86
+ } catch {
87
+ return FALLBACK_LOCALE
88
+ }
89
+ }
90
+
91
+ /**
92
+ * The locale of the page: `document.documentElement.lang`, canonicalized. `FALLBACK_LOCALE` when it is empty or
93
+ * invalid, or there is no `document`. Parts read it through `useLocale`, never while rendering.
94
+ */
95
+ function documentLocale(): string {
96
+ if (typeof document === "undefined") return FALLBACK_LOCALE
97
+ return normalizeLocale(document.documentElement?.getAttribute("lang"))
98
+ }
99
+
100
+ /** `locale` when given, else the page's locale (`documentLocale()`). */
101
+ function resolveLocale(locale?: string | null): string {
102
+ return locale || documentLocale()
103
+ }
104
+
105
+ /** Picks the wording table of the locale's language. */
106
+ function pickLocale<T>(table: { ja: T; en: T }, locale?: string | null): T {
107
+ return table[uiLanguage(resolveLocale(locale))]
108
+ }
109
+
110
+ /** The currency `format="currency"` uses without a `currency`: JPY for Japanese, USD otherwise. */
111
+ function defaultCurrency(locale?: string | null): string {
112
+ return uiLanguage(resolveLocale(locale)) === "ja" ? "JPY" : "USD"
113
+ }
114
+
115
+ /** The month a fiscal year starts in (1–12) when none is given: April for Japanese, January otherwise. */
116
+ function defaultFiscalYearStartMonth(locale?: string | null): number {
117
+ return uiLanguage(resolveLocale(locale)) === "ja" ? 4 : 1
118
+ }
119
+
120
+ /** A day of the week, 0 = Sunday … 6 = Saturday (the `Date#getDay` / date-fns numbering). */
121
+ type WeekDay = 0 | 1 | 2 | 3 | 4 | 5 | 6
122
+
123
+ /** Locales whose week starts on Sunday when the runtime has no week data. */
124
+ const SUNDAY_FIRST = new Set(["en", "en-US", "en-CA"])
125
+
126
+ /**
127
+ * The first day of the week: Monday for Japanese; otherwise the locale's convention from `Intl.Locale`
128
+ * (`en-US` Sunday, `en-GB` Monday). Without week data in the runtime: Sunday for `en` / `en-US` / `en-CA`,
129
+ * Monday for the rest.
130
+ */
131
+ function weekStartsOn(locale?: string | null): WeekDay {
132
+ const tag = normalizeLocale(resolveLocale(locale))
133
+ if (uiLanguage(tag) === "ja") return 1
134
+ try {
135
+ const info = new Intl.Locale(tag) as Intl.Locale & {
136
+ getWeekInfo?: () => { firstDay: number }
137
+ weekInfo?: { firstDay: number }
138
+ }
139
+ const firstDay = info.getWeekInfo?.().firstDay ?? info.weekInfo?.firstDay
140
+ if (typeof firstDay === "number" && firstDay >= 1 && firstDay <= 7) return (firstDay % 7) as WeekDay
141
+ } catch {
142
+ // Fall through to the table below.
143
+ }
144
+ return SUNDAY_FIRST.has(tag) ? 0 : 1
145
+ }
146
+
147
+ /* ---------- inlined from @squadbase/squadkit registry/hooks/use-locale.ts (internal to @squadbase/vantage) ---------- */
148
+
149
+ const listeners = new Set<() => void>()
150
+ let observer: MutationObserver | null = null
151
+
152
+ /** One observer on `<html lang>` for every subscribed part. */
153
+ function subscribe(onChange: () => void): () => void {
154
+ if (typeof document === "undefined" || typeof MutationObserver === "undefined") return () => {}
155
+ listeners.add(onChange)
156
+ if (!observer) {
157
+ observer = new MutationObserver(() => {
158
+ for (const listener of [...listeners]) listener()
159
+ })
160
+ observer.observe(document.documentElement, { attributes: true, attributeFilter: ["lang"] })
161
+ }
162
+ return () => {
163
+ listeners.delete(onChange)
164
+ if (listeners.size === 0 && observer) {
165
+ observer.disconnect()
166
+ observer = null
167
+ }
168
+ }
169
+ }
170
+
171
+ const serverLocale = () => FALLBACK_LOCALE
172
+
173
+ /**
174
+ * The page's locale (`<html lang>`), following changes made while the page runs. On the server and during
175
+ * hydration it is `FALLBACK_LOCALE` (`en-US`), so the markup matches; it switches right after.
176
+ */
177
+ function useDocumentLocale(): string {
178
+ return useSyncExternalStore(subscribe, documentLocale, serverLocale)
179
+ }
180
+
181
+ /** The locale a part renders in: its `locale` prop when given, else the page's (`useDocumentLocale`). */
182
+ function useLocale(locale?: string | null): string {
183
+ const page = useDocumentLocale()
184
+ return locale || page
185
+ }
186
+
187
+ /* ---------- end of inlined code ---------- */
188
+
189
+ const deltaVariants = cva(
190
+ "inline-flex w-fit shrink-0 items-center gap-1 font-medium whitespace-nowrap tabular-nums",
191
+ {
192
+ variants: {
193
+ variant: {
194
+ badge: "h-5 rounded-md border px-2 py-0.5 text-xs font-medium [&>svg]:size-3",
195
+ inline: "text-sm [&>svg]:size-3.5",
196
+ },
197
+ sentiment: {
198
+ positive: "text-positive",
199
+ negative: "text-negative",
200
+ neutral: "text-neutral",
201
+ },
202
+ },
203
+ compoundVariants: [
204
+ { variant: "badge", sentiment: "positive", className: "border-positive/20 bg-positive-subtle dark:border-positive/25" },
205
+ { variant: "badge", sentiment: "negative", className: "border-negative/20 bg-negative-subtle dark:border-negative/25" },
206
+ { variant: "badge", sentiment: "neutral", className: "border-neutral/20 bg-neutral-subtle dark:border-neutral/25" },
207
+ ],
208
+ defaultVariants: {
209
+ variant: "badge",
210
+ sentiment: "neutral",
211
+ },
212
+ },
213
+ )
214
+
215
+ export interface DeltaProps
216
+ extends
217
+ Omit<HTMLAttributes<HTMLSpanElement>, "children">,
218
+ Pick<VariantProps<typeof deltaVariants>, "variant"> {
219
+ /** The current value. The previous one comes from `comparison`. */
220
+ value: number | null | undefined
221
+ /** What the value is compared against. Required so the delta always carries its label. */
222
+ comparison: Comparison
223
+ /** Which direction is good: `"up"` (default) or `"down"` (churn, error rate). Wins over `polarity`. */
224
+ betterWhen?: "up" | "down"
225
+ /** @deprecated Older name of `betterWhen` (`"higher-is-better"` / `"lower-is-better"`); `"neutral"` is only reachable here. `betterWhen` wins if both are given. */
226
+ polarity?: Polarity
227
+ /** Absolute ratio below which the change reads as flat (0.01 = 1%). Default 0.01. */
228
+ neutralBand?: number
229
+ /** Format of the metric itself; a `percent` metric shows its change in points. */
230
+ format?: ValueFormat
231
+ /**
232
+ * `"relative"` ("+12.4%"), `"points"` ("-0.5pt") or `"difference"` (the absolute difference in the
233
+ * metric's own `format`, "+¥530万"). Default: points for a `percent` format, else relative.
234
+ */
235
+ change?: ChangeDisplay
236
+ /**
237
+ * 変化(`"relative"` の率・`"points"` の pt)の小数桁数。固定で、末尾の 0 も出す。例: `digits={2}` → "+0.14pt"。
238
+ * 同じカード群で桁がばらつかないよう、全部に同じ値を渡す。未指定は 1 桁("+14.0%")。`"points"` は未指定のとき `format.digits` に従う。
239
+ */
240
+ digits?: number
241
+ /** Locale for the change and its label. Default: the page's (`<html lang>`, else `"en-US"`). */
242
+ locale?: string
243
+ /** Show the comparison label ("前月比") after the change. Default true. */
244
+ showLabel?: boolean
245
+ }
246
+
247
+ /** Text shown when the values cannot be compared (no previous value, or a zero baseline): the same "—" as every missing value. */
248
+ export const DELTA_NOT_COMPARABLE = EMPTY_VALUE
249
+
250
+ const ARIA_TEXT = {
251
+ ja: {
252
+ none: (label: string) => `${label} 比較できません`,
253
+ flat: (label: string) => `${label} 横ばい`,
254
+ points: " ポイント",
255
+ change: (label: string, amount: string, up: boolean) => `${label} ${amount} ${up ? "増加" : "減少"}`,
256
+ },
257
+ en: {
258
+ none: (label: string) => `${label}: not comparable`,
259
+ flat: (label: string) => `Flat ${label}`,
260
+ points: " points",
261
+ change: (label: string, amount: string, up: boolean) => `${up ? "Up" : "Down"} ${amount} ${label}`,
262
+ },
263
+ }
264
+
265
+ /**
266
+ * Screen-reader text, e.g. "Up 12.4% vs. prior month" / "Down 0.5 points vs. prior month" / "Flat vs. prior month" /
267
+ * "vs. prior month: not comparable" (ja: "前月比 12.4% 増加" / "前月比 0.5 ポイント 減少" / "前月比 横ばい" / "前月比 比較できません").
268
+ * The amount carries no sign, since the verb already says the direction ("−0.5 ポイント 減少" would negate twice).
269
+ * `locale` defaults to the page's (`<html lang>`).
270
+ */
271
+ export function deltaAriaLabel(
272
+ result: ComparisonResult,
273
+ locale?: string,
274
+ change: ChangeDisplay = "relative",
275
+ format?: ValueFormat,
276
+ digits?: number,
277
+ ): string {
278
+ const resolved = resolveLocale(locale)
279
+ const t = ARIA_TEXT[uiLanguage(resolved)]
280
+ const { label, direction, ratio } = result
281
+ if (direction === "none" || ratio === null) return t.none(label)
282
+ if (direction === "flat") return t.flat(label)
283
+ const amount = formatChangeAmount(result, change, resolved, format, digits)
284
+ if (amount === null) return t.none(label)
285
+ return t.change(label, change === "points" ? amount.replace(/pt$/, t.points) : amount, direction === "up")
286
+ }
287
+
288
+ export const Delta = forwardRef<HTMLSpanElement, DeltaProps>(
289
+ (
290
+ {
291
+ value,
292
+ comparison,
293
+ betterWhen,
294
+ polarity,
295
+ neutralBand,
296
+ format,
297
+ change,
298
+ digits,
299
+ locale: localeProp,
300
+ showLabel = true,
301
+ variant = "badge",
302
+ className,
303
+ ...props
304
+ },
305
+ ref,
306
+ ) => {
307
+ const locale = useLocale(localeProp)
308
+ // Nothing to compare against yet (a draft fills props in steps).
309
+ if (!comparison) return null
310
+ const result = computeComparison(value, comparison, {
311
+ polarity: betterWhen ? (betterWhen === "down" ? "lower-is-better" : "higher-is-better") : polarity,
312
+ neutralBand,
313
+ locale,
314
+ })
315
+ const display = change ?? defaultChangeDisplay(format)
316
+ const formatDigits = typeof format === "object" && format !== null && "digits" in format ? format.digits : undefined
317
+ const changeDigits = display === "points" ? (digits ?? formatDigits) : digits
318
+ const comparable = result.direction !== "none"
319
+ const Icon = result.direction === "up" ? ArrowUp : result.direction === "down" ? ArrowDown : ArrowRight
320
+ const text = formatChange(result, display, locale, format, changeDigits)
321
+
322
+ return (
323
+ <span
324
+ ref={ref}
325
+ role="img"
326
+ data-slot="delta"
327
+ data-direction={result.direction}
328
+ data-sentiment={result.sentiment}
329
+ aria-label={deltaAriaLabel(result, locale, display, format, changeDigits)}
330
+ className={cn(
331
+ deltaVariants({ variant, sentiment: result.sentiment }),
332
+ !comparable && "text-muted-foreground",
333
+ className,
334
+ )}
335
+ {...props}
336
+ >
337
+ {comparable && <Icon aria-hidden="true" />}
338
+ <span aria-hidden="true">{text ?? DELTA_NOT_COMPARABLE}</span>
339
+ {showLabel && (
340
+ <span aria-hidden="true" className="font-normal text-muted-foreground">
341
+ {result.label}
342
+ </span>
343
+ )}
344
+ </span>
345
+ )
346
+ },
347
+ )
348
+ Delta.displayName = "Delta"
349
+
350
+ export { deltaVariants }
@@ -1,5 +1,7 @@
1
1
  // Copied by `vantage add ui dialog`. This file is yours to edit.
2
- // Generated from @squadbase/vantage src/ui/dialog.tsx by `npm run registry` (in Vantage, edit src/, not registry/).
2
+ // Generated from @squadbase/squadkit registry/ui/dialog.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
  import { Dialog as DialogPrimitive } from "@base-ui/react/dialog"
5
7
 
@@ -31,7 +33,7 @@ function DialogOverlay({
31
33
  <DialogPrimitive.Backdrop
32
34
  data-slot="dialog-overlay"
33
35
  className={cn(
34
- "fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",
36
+ "fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in motion-reduce:animate-none! data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",
35
37
  className
36
38
  )}
37
39
  {...props}
@@ -53,7 +55,7 @@ function DialogContent({
53
55
  <DialogPrimitive.Popup
54
56
  data-slot="dialog-content"
55
57
  className={cn(
56
- "fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
58
+ "fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in motion-reduce:animate-none! data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
57
59
  className
58
60
  )}
59
61
  {...props}