@squadbase/vantage-template 0.2.0 → 0.2.1-dev1.18b684b

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 (31) hide show
  1. package/base-template/AGENTS.md +8 -4
  2. package/base-template/agents/page.md +5 -4
  3. package/base-template/bun.lock +10 -12
  4. package/base-template/package.json +2 -2
  5. package/base-template/src/index.tsx +53 -62
  6. package/package.json +2 -2
  7. package/ui-templates/CLAUDE.md +13 -12
  8. package/ui-templates/chart-grid/lib/mock-data.ts +0 -3
  9. package/ui-templates/chart-grid/lib/types.ts +6 -6
  10. package/ui-templates/chart-grid/pages/index.tsx +11 -161
  11. package/ui-templates/chart-grid-ja/lib/mock-data.ts +0 -3
  12. package/ui-templates/chart-grid-ja/lib/types.ts +6 -6
  13. package/ui-templates/chart-grid-ja/pages/index.tsx +11 -161
  14. package/ui-templates/funnel/lib/types.ts +2 -2
  15. package/ui-templates/funnel/pages/index.tsx +10 -88
  16. package/ui-templates/funnel-ja/lib/types.ts +2 -2
  17. package/ui-templates/funnel-ja/pages/index.tsx +10 -87
  18. package/ui-templates/kpi-chart-advanced/lib/mock-data.ts +6 -6
  19. package/ui-templates/kpi-chart-advanced/lib/types.ts +6 -7
  20. package/ui-templates/kpi-chart-advanced/pages/index.tsx +6 -117
  21. package/ui-templates/kpi-chart-advanced-ja/lib/mock-data.ts +6 -6
  22. package/ui-templates/kpi-chart-advanced-ja/lib/types.ts +6 -7
  23. package/ui-templates/kpi-chart-advanced-ja/pages/index.tsx +6 -117
  24. package/ui-templates/kpi-chart-simple/lib/types.ts +4 -4
  25. package/ui-templates/kpi-chart-simple/pages/index.tsx +4 -42
  26. package/ui-templates/kpi-chart-simple-ja/lib/types.ts +4 -4
  27. package/ui-templates/kpi-chart-simple-ja/pages/index.tsx +4 -40
  28. package/ui-templates/table-focus/lib/types.ts +3 -3
  29. package/ui-templates/table-focus/pages/index.tsx +3 -45
  30. package/ui-templates/table-focus-ja/lib/types.ts +3 -3
  31. package/ui-templates/table-focus-ja/pages/index.tsx +3 -45
@@ -7,7 +7,7 @@ import {
7
7
  DashboardCardHeader,
8
8
  DashboardCardPreset,
9
9
  DashboardCardTitle,
10
- EChart,
10
+ AreaChart,
11
11
  PageShell,
12
12
  PageShellContent,
13
13
  PageShellDescription,
@@ -19,13 +19,13 @@ import {
19
19
  SegmentedControl,
20
20
  Sparkline,
21
21
  } from "@squadbase/vantage/components"
22
- import type { EChartsOption, SegmentOption } from "@squadbase/vantage/components"
22
+ import type { SegmentOption } from "@squadbase/vantage/components"
23
23
  import { Button, ErrorState, Loading } from "@squadbase/vantage/ui"
24
24
  import { useApiQuery } from "@squadbase/vantage/query"
25
25
  import { useSearchParam } from "@squadbase/vantage/router"
26
26
 
27
27
  import { TopItemsTable } from "./components/kpi-chart-simple/top-items-table"
28
- import type { KpiId, KpiSummary, TrendPoint } from "./lib/kpi-chart-simple/types"
28
+ import type { KpiId, KpiSummary } from "./lib/kpi-chart-simple/types"
29
29
 
30
30
  export const page = definePage({
31
31
  title: "KPI + Chart (Simple)",
@@ -35,14 +35,6 @@ export const page = definePage({
35
35
 
36
36
  // ── formatting ───────────────────────────────────────────────────────────────
37
37
 
38
- function formatNumber(n: number): string {
39
- const sign = n < 0 ? "-" : ""
40
- const abs = Math.abs(n)
41
- if (abs >= 1_000_000) return `${sign}${(abs / 1_000_000).toFixed(1)}M`
42
- if (abs >= 1_000) return `${sign}${(abs / 1_000).toFixed(1)}K`
43
- return n.toLocaleString("en-US")
44
- }
45
-
46
38
  function formatCurrency(n: number): string {
47
39
  const sign = n < 0 ? "-" : ""
48
40
  const abs = Math.abs(n)
@@ -51,36 +43,6 @@ function formatCurrency(n: number): string {
51
43
  return `${sign}$${abs.toFixed(0)}`
52
44
  }
53
45
 
54
- // ── chart options ────────────────────────────────────────────────────────────
55
-
56
- function trendOption(data: TrendPoint[]): EChartsOption {
57
- return {
58
- tooltip: { trigger: "axis" },
59
- legend: { bottom: 0 },
60
- grid: { left: "3%", right: "4%", bottom: "10%", containLabel: true },
61
- xAxis: {
62
- type: "category",
63
- data: data.map((d) => d.date),
64
- boundaryGap: false,
65
- axisLabel: { formatter: (value: string) => value.slice(5) },
66
- },
67
- yAxis: {
68
- type: "value",
69
- axisLabel: { formatter: (v: number) => formatNumber(v) },
70
- },
71
- series: [
72
- {
73
- name: "Series A",
74
- type: "line",
75
- smooth: true,
76
- showSymbol: false,
77
- data: data.map((d) => d.revenue),
78
- areaStyle: { opacity: 0.18 },
79
- },
80
- ],
81
- }
82
- }
83
-
84
46
  // ── page ─────────────────────────────────────────────────────────────────────
85
47
 
86
48
  /** Display labels live here, not in the payload the API returns. */
@@ -189,7 +151,7 @@ function DashboardBody({ data }: { data: KpiSummary }) {
189
151
  </div>
190
152
 
191
153
  <DashboardCardPreset data-sq-ref="trend" title="Trend" description="Values over the selected period">
192
- <EChart option={trendOption(data.trend)} height="320px" />
154
+ <AreaChart data={data.trend} index="date" categories={["revenue"]} labels={{ revenue: "Series A" }} height="320px" />
193
155
  </DashboardCardPreset>
194
156
 
195
157
  <DashboardCardPreset data-sq-ref="top-items" title="Top items" description="Ranked by value">
@@ -11,7 +11,7 @@ export type RangeKey = "7d" | "30d" | "90d"
11
11
  export type KpiId = "total-revenue" | "active-users" | "conversion-rate" | "aov"
12
12
 
13
13
  /** Raw numbers only — labels and formatting belong to the page. */
14
- export interface KpiItem {
14
+ export type KpiItem = {
15
15
  id: KpiId
16
16
  value: number
17
17
  /** Percent change against the preceding window of the same length. */
@@ -19,14 +19,14 @@ export interface KpiItem {
19
19
  sparklineData: number[]
20
20
  }
21
21
 
22
- export interface TrendPoint {
22
+ export type TrendPoint = {
23
23
  date: string
24
24
  revenue: number
25
25
  orders: number
26
26
  visitors: number
27
27
  }
28
28
 
29
- export interface TopItemRow {
29
+ export type TopItemRow = {
30
30
  id: string
31
31
  name: string
32
32
  category: string
@@ -36,7 +36,7 @@ export interface TopItemRow {
36
36
  }
37
37
 
38
38
  /** The payload `GET /api/kpi-summary` returns. */
39
- export interface KpiSummary {
39
+ export type KpiSummary = {
40
40
  range: RangeKey
41
41
  kpis: KpiItem[]
42
42
  trend: TrendPoint[]
@@ -7,7 +7,7 @@ import {
7
7
  DashboardCardHeader,
8
8
  DashboardCardPreset,
9
9
  DashboardCardTitle,
10
- EChart,
10
+ AreaChart,
11
11
  PageShell,
12
12
  PageShellContent,
13
13
  PageShellDescription,
@@ -19,13 +19,13 @@ import {
19
19
  SegmentedControl,
20
20
  Sparkline,
21
21
  } from "@squadbase/vantage/components"
22
- import type { EChartsOption, SegmentOption } from "@squadbase/vantage/components"
22
+ import type { SegmentOption } from "@squadbase/vantage/components"
23
23
  import { Button, ErrorState, Loading } from "@squadbase/vantage/ui"
24
24
  import { useApiQuery } from "@squadbase/vantage/query"
25
25
  import { useSearchParam } from "@squadbase/vantage/router"
26
26
 
27
27
  import { TopItemsTable } from "./components/kpi-chart-simple/top-items-table"
28
- import type { KpiId, KpiSummary, TrendPoint } from "./lib/kpi-chart-simple/types"
28
+ import type { KpiId, KpiSummary } from "./lib/kpi-chart-simple/types"
29
29
 
30
30
  export const page = definePage({
31
31
  title: "KPI + チャート (シンプル)",
@@ -35,14 +35,6 @@ export const page = definePage({
35
35
 
36
36
  // ── 表示フォーマット ─────────────────────────────────────────────────────────
37
37
 
38
- function formatNumber(n: number): string {
39
- const sign = n < 0 ? "-" : ""
40
- const abs = Math.abs(n)
41
- if (abs >= 1_000_000) return `${sign}${(abs / 1_000_000).toFixed(1)}M`
42
- if (abs >= 1_000) return `${sign}${(abs / 1_000).toFixed(1)}K`
43
- return n.toLocaleString("ja-JP")
44
- }
45
-
46
38
  function formatCurrency(n: number): string {
47
39
  const sign = n < 0 ? "-" : ""
48
40
  const abs = Math.abs(n)
@@ -53,34 +45,6 @@ function formatCurrency(n: number): string {
53
45
 
54
46
  // ── チャートオプション ───────────────────────────────────────────────────────
55
47
 
56
- function trendOption(data: TrendPoint[]): EChartsOption {
57
- return {
58
- tooltip: { trigger: "axis" },
59
- legend: { bottom: 0 },
60
- grid: { left: "3%", right: "4%", bottom: "10%", containLabel: true },
61
- xAxis: {
62
- type: "category",
63
- data: data.map((d) => d.date),
64
- boundaryGap: false,
65
- axisLabel: { formatter: (value: string) => value.slice(5) },
66
- },
67
- yAxis: {
68
- type: "value",
69
- axisLabel: { formatter: (v: number) => formatNumber(v) },
70
- },
71
- series: [
72
- {
73
- name: "系列A",
74
- type: "line",
75
- smooth: true,
76
- showSymbol: false,
77
- data: data.map((d) => d.revenue),
78
- areaStyle: { opacity: 0.18 },
79
- },
80
- ],
81
- }
82
- }
83
-
84
48
  // ── ページ ───────────────────────────────────────────────────────────────────
85
49
 
86
50
  /** 表示ラベルは API のレスポンスではなく描画側に置く。 */
@@ -189,7 +153,7 @@ function DashboardBody({ data }: { data: KpiSummary }) {
189
153
  </div>
190
154
 
191
155
  <DashboardCardPreset data-sq-ref="trend" title="トレンド" description="選択期間の値">
192
- <EChart option={trendOption(data.trend)} height="320px" />
156
+ <AreaChart data={data.trend} index="date" categories={["revenue"]} labels={{ revenue: "系列A" }} height="320px" />
193
157
  </DashboardCardPreset>
194
158
 
195
159
  <DashboardCardPreset data-sq-ref="top-items" title="上位項目" description="値で並べ替え">
@@ -1,4 +1,4 @@
1
- export interface DetailRow {
1
+ export type DetailRow = {
2
2
  id: string
3
3
  name: string
4
4
  owner: string
@@ -10,7 +10,7 @@ export interface DetailRow {
10
10
  updated: string
11
11
  }
12
12
 
13
- export interface SummaryRow {
13
+ export type SummaryRow = {
14
14
  segment: string
15
15
  count: number
16
16
  revenue: number
@@ -18,7 +18,7 @@ export interface SummaryRow {
18
18
  share: number
19
19
  }
20
20
 
21
- export interface TrendPoint {
21
+ export type TrendPoint = {
22
22
  date: string
23
23
  value: number
24
24
  }
@@ -4,7 +4,7 @@ import { Download, Search } from "lucide-react"
4
4
  import { definePage } from "@squadbase/vantage"
5
5
  import {
6
6
  DashboardCardPreset,
7
- EChart,
7
+ AreaChart,
8
8
  PageShell,
9
9
  PageShellContent,
10
10
  PageShellDescription,
@@ -13,7 +13,6 @@ import {
13
13
  PageShellHeading,
14
14
  PageShellTitle,
15
15
  Placeholder,
16
- type EChartsOption,
17
16
  } from "@squadbase/vantage/components"
18
17
  import { Button, Input, ToggleGroup, ToggleGroupItem } from "@squadbase/vantage/ui"
19
18
 
@@ -23,7 +22,7 @@ import {
23
22
  summaryRows,
24
23
  trendSeries,
25
24
  } from "./components/table-focus/mock-data"
26
- import type { DetailRow, TrendPoint } from "./components/table-focus/types"
25
+ import type { DetailRow } from "./components/table-focus/types"
27
26
 
28
27
  export const page = definePage({
29
28
  title: "Records",
@@ -31,47 +30,6 @@ export const page = definePage({
31
30
  "Workbench layout: header search + Export, status filter chips, a sortable detail table as the main element, with a trend chart and segment breakdown in a right sidebar.",
32
31
  })
33
32
 
34
- // ── chart helpers ───────────────────────────────────────────────────────────
35
-
36
- function getBaseGrid() {
37
- return { left: "3%", right: "4%", bottom: "10%", containLabel: true }
38
- }
39
-
40
- function formatNumber(n: number): string {
41
- const sign = n < 0 ? "-" : ""
42
- const abs = Math.abs(n)
43
- if (abs >= 1_000_000) return `${sign}${(abs / 1_000_000).toFixed(1)}M`
44
- if (abs >= 1_000) return `${sign}${(abs / 1_000).toFixed(1)}K`
45
- return n.toLocaleString("en-US")
46
- }
47
-
48
- // ── chart options ────────────────────────────────────────────────────────────
49
-
50
- function trendOption(data: TrendPoint[]): EChartsOption {
51
- return {
52
- tooltip: { trigger: "axis" },
53
- legend: { bottom: 0 },
54
- grid: getBaseGrid(),
55
- xAxis: {
56
- type: "category",
57
- data: data.map((d) => d.date),
58
- boundaryGap: false,
59
- axisLabel: { formatter: (v: string) => v.slice(5) },
60
- },
61
- yAxis: { type: "value", axisLabel: { formatter: (v: number) => formatNumber(v) } },
62
- series: [
63
- {
64
- name: "Series A",
65
- type: "line",
66
- smooth: true,
67
- showSymbol: false,
68
- data: data.map((d) => d.value),
69
- areaStyle: { opacity: 0.18 },
70
- },
71
- ],
72
- }
73
- }
74
-
75
33
  // ── page ─────────────────────────────────────────────────────────────────────
76
34
 
77
35
  type StatusFilter = "all" | DetailRow["status"]
@@ -150,7 +108,7 @@ export default function HomePage() {
150
108
  title="Trend"
151
109
  description="Values over the selected period"
152
110
  >
153
- <EChart option={trendOption(trendSeries)} height="220px" />
111
+ <AreaChart data={trendSeries} index="date" categories={["value"]} labels={{ value: "Series A" }} height="220px" />
154
112
  </DashboardCardPreset>
155
113
  <DashboardCardPreset title="By segment" description="Share of total">
156
114
  <div className="space-y-3">
@@ -1,4 +1,4 @@
1
- export interface DetailRow {
1
+ export type DetailRow = {
2
2
  id: string
3
3
  name: string
4
4
  owner: string
@@ -10,7 +10,7 @@ export interface DetailRow {
10
10
  updated: string
11
11
  }
12
12
 
13
- export interface SummaryRow {
13
+ export type SummaryRow = {
14
14
  segment: string
15
15
  count: number
16
16
  revenue: number
@@ -18,7 +18,7 @@ export interface SummaryRow {
18
18
  share: number
19
19
  }
20
20
 
21
- export interface TrendPoint {
21
+ export type TrendPoint = {
22
22
  date: string
23
23
  value: number
24
24
  }
@@ -4,7 +4,7 @@ import { Download, Search } from "lucide-react"
4
4
  import { definePage } from "@squadbase/vantage"
5
5
  import {
6
6
  DashboardCardPreset,
7
- EChart,
7
+ AreaChart,
8
8
  PageShell,
9
9
  PageShellContent,
10
10
  PageShellDescription,
@@ -13,7 +13,6 @@ import {
13
13
  PageShellHeading,
14
14
  PageShellTitle,
15
15
  Placeholder,
16
- type EChartsOption,
17
16
  } from "@squadbase/vantage/components"
18
17
  import { Button, Input, ToggleGroup, ToggleGroupItem } from "@squadbase/vantage/ui"
19
18
 
@@ -23,7 +22,7 @@ import {
23
22
  summaryRows,
24
23
  trendSeries,
25
24
  } from "./components/table-focus/mock-data"
26
- import type { DetailRow, TrendPoint } from "./components/table-focus/types"
25
+ import type { DetailRow } from "./components/table-focus/types"
27
26
 
28
27
  export const page = definePage({
29
28
  title: "レコード",
@@ -31,47 +30,6 @@ export const page = definePage({
31
30
  "ヘッダーに検索+エクスポート、ステータスフィルタチップ、ソート可能な詳細テーブルを主役とし、右サイドにトレンドチャートとセグメント内訳を配置する作業画面構成。",
32
31
  })
33
32
 
34
- // ── chart helpers ───────────────────────────────────────────────────────────
35
-
36
- function getBaseGrid() {
37
- return { left: "3%", right: "4%", bottom: "10%", containLabel: true }
38
- }
39
-
40
- function formatNumber(n: number): string {
41
- const sign = n < 0 ? "-" : ""
42
- const abs = Math.abs(n)
43
- if (abs >= 100_000_000) return `${sign}${(abs / 100_000_000).toFixed(1)}億`
44
- if (abs >= 10_000) return `${sign}${(abs / 10_000).toFixed(0)}万`
45
- return n.toLocaleString("ja-JP")
46
- }
47
-
48
- // ── chart options ────────────────────────────────────────────────────────────
49
-
50
- function trendOption(data: TrendPoint[]): EChartsOption {
51
- return {
52
- tooltip: { trigger: "axis" },
53
- legend: { bottom: 0 },
54
- grid: getBaseGrid(),
55
- xAxis: {
56
- type: "category",
57
- data: data.map((d) => d.date),
58
- boundaryGap: false,
59
- axisLabel: { formatter: (v: string) => v.slice(5) },
60
- },
61
- yAxis: { type: "value", axisLabel: { formatter: (v: number) => formatNumber(v) } },
62
- series: [
63
- {
64
- name: "系列A",
65
- type: "line",
66
- smooth: true,
67
- showSymbol: false,
68
- data: data.map((d) => d.value),
69
- areaStyle: { opacity: 0.18 },
70
- },
71
- ],
72
- }
73
- }
74
-
75
33
  // ── page ─────────────────────────────────────────────────────────────────────
76
34
 
77
35
  type StatusFilter = "all" | DetailRow["status"]
@@ -150,7 +108,7 @@ export default function HomePage() {
150
108
  title="トレンド"
151
109
  description="選択期間の値"
152
110
  >
153
- <EChart option={trendOption(trendSeries)} height="220px" />
111
+ <AreaChart data={trendSeries} index="date" categories={["value"]} labels={{ value: "系列A" }} height="220px" />
154
112
  </DashboardCardPreset>
155
113
  <DashboardCardPreset title="セグメント別" description="全体に占める割合">
156
114
  <div className="space-y-3">