@siyahi/ui 0.1.9-next.21 → 0.1.9-next.23

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 (93) hide show
  1. package/DESIGN.md +16 -3
  2. package/agents/examples/accordion.tsx +7 -7
  3. package/agents/examples/alert.tsx +16 -15
  4. package/agents/examples/app-sidebar.tsx +3 -1
  5. package/agents/examples/badge.tsx +20 -12
  6. package/agents/examples/bar-list-labels.tsx +6 -6
  7. package/agents/examples/bar-list-sides.tsx +18 -16
  8. package/agents/examples/bar-list.tsx +8 -8
  9. package/agents/examples/breadcrumb.tsx +3 -3
  10. package/agents/examples/calendar.tsx +3 -7
  11. package/agents/examples/callout.tsx +15 -15
  12. package/agents/examples/card.tsx +5 -3
  13. package/agents/examples/change-bar.tsx +21 -21
  14. package/agents/examples/chart-area.tsx +11 -11
  15. package/agents/examples/chart-bar-flows.tsx +1 -1
  16. package/agents/examples/chart-bar-hourly.tsx +1 -1
  17. package/agents/examples/chart-bar-losses.tsx +3 -3
  18. package/agents/examples/chart-bar-teams.tsx +72 -0
  19. package/agents/examples/chart-bar-years.tsx +5 -5
  20. package/agents/examples/chart-bar.tsx +10 -10
  21. package/agents/examples/chart-category-ticks.tsx +6 -6
  22. package/agents/examples/chart-line.tsx +17 -17
  23. package/agents/examples/collapsible.tsx +5 -3
  24. package/agents/examples/command.tsx +23 -21
  25. package/agents/examples/context-menu.tsx +6 -4
  26. package/agents/examples/data-bar.tsx +32 -45
  27. package/agents/examples/data-table-compact.tsx +31 -30
  28. package/agents/examples/data-table-filters.tsx +20 -20
  29. package/agents/examples/data-table.tsx +31 -30
  30. package/agents/examples/dialog.tsx +3 -3
  31. package/agents/examples/distribution-bar-tug.tsx +36 -34
  32. package/agents/examples/dropdown-menu.tsx +2 -2
  33. package/agents/examples/heatmap-calendar.tsx +12 -10
  34. package/agents/examples/heatmap-status.tsx +11 -9
  35. package/agents/examples/heatmap-weekday.tsx +27 -30
  36. package/agents/examples/input-states.tsx +9 -9
  37. package/agents/examples/input.tsx +3 -3
  38. package/agents/examples/local-time.tsx +1 -1
  39. package/agents/examples/metric-strip.tsx +8 -8
  40. package/agents/examples/page-hero.tsx +2 -2
  41. package/agents/examples/popover.tsx +3 -3
  42. package/agents/examples/price-chart.tsx +5 -5
  43. package/agents/examples/progress-tone.tsx +10 -9
  44. package/agents/examples/progress.tsx +1 -1
  45. package/agents/examples/range-position-table.tsx +31 -31
  46. package/agents/examples/range-position.tsx +31 -29
  47. package/agents/examples/scroll-area.tsx +12 -10
  48. package/agents/examples/section-cards-select.tsx +11 -10
  49. package/agents/examples/section-cards-trend.tsx +4 -4
  50. package/agents/examples/section-cards.tsx +13 -13
  51. package/agents/examples/select.tsx +9 -9
  52. package/agents/examples/separator.tsx +3 -3
  53. package/agents/examples/sheet.tsx +1 -1
  54. package/agents/examples/slider.tsx +1 -1
  55. package/agents/examples/surfaces.tsx +16 -16
  56. package/agents/examples/tabs.tsx +7 -7
  57. package/agents/examples/target-rows.tsx +31 -27
  58. package/agents/examples/tooltip.tsx +2 -2
  59. package/agents/examples/treemap.tsx +38 -33
  60. package/agents/manifest.json +15 -15
  61. package/dist/components/registry/charts/bar-chart-card.d.ts +1 -1
  62. package/dist/components/registry/charts/bar-chart-card.js +6 -2
  63. package/dist/components/registry/charts/line-chart-card.d.ts +1 -1
  64. package/dist/components/registry/charts/line-chart-card.js +1 -1
  65. package/dist/components/registry/dashboard-01/section-cards.js +1 -1
  66. package/dist/components/registry/dashboardcn/distribution-bar.js +5 -3
  67. package/dist/components/registry/heatmap/status-heatmap.js +1 -1
  68. package/dist/components/siyahi/callout.d.ts +5 -12
  69. package/dist/components/siyahi/callout.js +5 -11
  70. package/dist/components/siyahi/delta.d.ts +5 -1
  71. package/dist/components/siyahi/delta.js +14 -9
  72. package/dist/components/siyahi/status-alert.d.ts +15 -0
  73. package/dist/components/siyahi/status-alert.js +29 -0
  74. package/dist/components/siyahi/status-badge.d.ts +15 -0
  75. package/dist/components/siyahi/status-badge.js +24 -0
  76. package/dist/components/siyahi/tone-progress.d.ts +1 -1
  77. package/dist/components/siyahi/tone-progress.js +1 -1
  78. package/dist/components/siyahi/treemap.d.ts +4 -4
  79. package/dist/components/siyahi/treemap.js +5 -5
  80. package/dist/index.d.ts +5 -4
  81. package/dist/index.js +3 -2
  82. package/dist/lib/chart-frame.js +1 -1
  83. package/dist/lib/chart-series.d.ts +1 -1
  84. package/dist/lib/format.d.ts +1 -1
  85. package/dist/lib/format.js +1 -1
  86. package/dist/lib/tone.d.ts +36 -0
  87. package/dist/lib/tone.js +35 -0
  88. package/package.json +1 -1
  89. package/report.css +14 -14
  90. package/styles/siyahi.css +92 -20
  91. package/agents/examples/chart-bar-sectors.tsx +0 -72
  92. package/dist/components/siyahi/warning-alert.d.ts +0 -10
  93. package/dist/components/siyahi/warning-alert.js +0 -20
@@ -0,0 +1,72 @@
1
+ import { useState } from "react";
2
+ import { BarChartCard, ToggleGroup, ToggleGroupItem, useFormat, type ChartSeries } from "@siyahi/ui";
3
+
4
+ // Each team's share of this year's spend against a comparison; made-up figures.
5
+ const SHARES = {
6
+ Plan: [
7
+ { team: "Engineering and Infrastructure", actual: 0.34, comparison: 0.37 },
8
+ { team: "Sales and Business Development", actual: 0.21, comparison: 0.13 },
9
+ { team: "Finance, Legal & Compliance", actual: 0.06, comparison: 0.1 },
10
+ { team: "Marketing and Communications", actual: 0.12, comparison: 0.08 },
11
+ { team: "Customer Support and Success", actual: 0.09, comparison: 0.07 },
12
+ { team: "Operations", actual: 0.08, comparison: 0.04 },
13
+ ],
14
+ "Last year": [
15
+ { team: "Engineering and Infrastructure", actual: 0.34, comparison: 0.31 },
16
+ { team: "Sales and Business Development", actual: 0.21, comparison: 0.1 },
17
+ { team: "Finance, Legal & Compliance", actual: 0.06, comparison: 0.08 },
18
+ { team: "Marketing and Communications", actual: 0.12, comparison: 0.07 },
19
+ { team: "Customer Support and Success", actual: 0.09, comparison: 0.07 },
20
+ { team: "Operations", actual: 0.08, comparison: 0.06 },
21
+ ],
22
+ };
23
+ type Comparison = keyof typeof SHARES;
24
+ type Row = (typeof SHARES)[Comparison][number];
25
+
26
+ export default function ChartBarTeamsExample() {
27
+ const { pct } = useFormat();
28
+ const [comparison, setComparison] = useState<Comparison>("Plan");
29
+ const rows = SHARES[comparison];
30
+ const series: ChartSeries<Row> = [
31
+ { key: "actual", label: "This year", color: "var(--chart-1)" },
32
+ { key: "comparison", label: comparison, color: "var(--chart-2)" },
33
+ ];
34
+ const gap = (row: Row) => {
35
+ const points = Math.abs(row.actual - row.comparison) * 100;
36
+ return row.actual >= row.comparison ? `+${points.toFixed(1)} pts over` : `\u2212${points.toFixed(1)} pts under`;
37
+ };
38
+ return (
39
+ <BarChartCard
40
+ title="Spend by team against plan or last year"
41
+ description="Each team's share of this year's spend and of the comparison"
42
+ action={
43
+ <ToggleGroup
44
+ value={[comparison]}
45
+ onValueChange={([next]) => {
46
+ // Pressing the selected comparison again would leave none selected; keep it.
47
+ if (next) setComparison(next as Comparison);
48
+ }}
49
+ variant="outline"
50
+ size="sm"
51
+ aria-label="Compare with"
52
+ >
53
+ <ToggleGroupItem value="Plan">Plan</ToggleGroupItem>
54
+ <ToggleGroupItem value="Last year">Last year</ToggleGroupItem>
55
+ </ToggleGroup>
56
+ }
57
+ horizontal
58
+ data={rows}
59
+ xKey="team"
60
+ xTickDetail={(row) => `${pct(row.actual)} vs ${pct(row.comparison)} · ${gap(row)}`}
61
+ series={series}
62
+ valueFormatter={(v) => pct(v)}
63
+ // A tick format puts the value axis along the bottom of the sideways bars.
64
+ yTickFormatter={(v) => pct(v, 0)}
65
+ // Sideways, y is still the value: the axis runs 0 to 40% and the cap is a value level.
66
+ yDomain={[0, 0.4]}
67
+ referenceLines={[{ y: 0.3, label: "cap 30%", labelPosition: "insideBottomRight" }]}
68
+ height={rows.length * 56 + 48}
69
+ footer={<p className="text-muted-foreground">Salaries are left out; they are budgeted separately.</p>}
70
+ />
71
+ );
72
+ }
@@ -1,7 +1,7 @@
1
1
  import { useState } from "react";
2
2
  import { BarChartCard, useFormat, type ChartSeries } from "@siyahi/ui";
3
3
 
4
- // Net realized gain per financial year (April to March); made-up figures.
4
+ // Net profit per financial year (April to March); made-up figures.
5
5
  const data = [
6
6
  { fy: "FY22", net: 142000 },
7
7
  { fy: "FY23", net: 186000 },
@@ -12,19 +12,19 @@ const data = [
12
12
 
13
13
  // A gain and a loss take the meaning colours; the arrow in each tick says the same without colour.
14
14
  const series: ChartSeries<(typeof data)[number]> = [
15
- { key: "net", label: "Net realized", color: "var(--positive)", negativeColor: "var(--negative)" },
15
+ { key: "net", label: "Net profit", color: "var(--positive)", negativeColor: "var(--negative)" },
16
16
  ];
17
17
 
18
18
  export default function ChartBarYearsExample() {
19
19
  const { money, moneyCompact } = useFormat();
20
20
  // The page owns the pick, so it can narrow the rest of the page to that year.
21
21
  const [year, setYear] = useState<string | null>(null);
22
- const signed = (v: number) => `${v < 0 ? "▼" : "▲"}${moneyCompact(Math.abs(v))}`;
22
+ const signed = (v: number) => `${v < 0 ? "\u2212" : "+"}${moneyCompact(Math.abs(v))}`;
23
23
  return (
24
24
  <BarChartCard
25
- title="Realized by financial year"
25
+ title="Profit by financial year"
26
26
  description={
27
- year ? `${year} picked; click it again for every year` : "April to March, gross. Click a year to pick it."
27
+ year ? `${year} picked; click it again for every year` : "April to March, before tax. Click a year to pick it."
28
28
  }
29
29
  data={data}
30
30
  xKey="fy"
@@ -2,20 +2,20 @@ import { useState } from "react";
2
2
  import { BarChartCard, ToggleGroup, ToggleGroupItem, useFormat, type ChartSeries } from "@siyahi/ui";
3
3
 
4
4
  const data = [
5
- { quarter: "Q1", equity: 120000, debt: 40000, gold: 15000, cash: 9000, reits: 4000 },
6
- { quarter: "Q2", equity: 95000, debt: 52000, gold: 20000, cash: 6000, reits: 3000 },
7
- { quarter: "Q3", equity: 140000, debt: 38000, gold: 12000, cash: 11000, reits: 5000 },
8
- { quarter: "Q4", equity: 160000, debt: 45000, gold: 25000, cash: 7000, reits: 2000 },
5
+ { quarter: "Q1", online: 120000, retail: 40000, wholesale: 15000, marketplace: 9000, events: 4000 },
6
+ { quarter: "Q2", online: 95000, retail: 52000, wholesale: 20000, marketplace: 6000, events: 3000 },
7
+ { quarter: "Q3", online: 140000, retail: 38000, wholesale: 12000, marketplace: 11000, events: 5000 },
8
+ { quarter: "Q4", online: 160000, retail: 45000, wholesale: 25000, marketplace: 7000, events: 2000 },
9
9
  ];
10
10
 
11
11
  // Series take the slots in order: neighbours differ in lightness, slots two
12
12
  // apart differ in hue.
13
13
  const series: ChartSeries<(typeof data)[number]> = [
14
- { key: "equity", label: "Equity", color: "var(--chart-1)" },
15
- { key: "debt", label: "Debt", color: "var(--chart-2)" },
16
- { key: "gold", label: "Gold", color: "var(--chart-3)" },
17
- { key: "cash", label: "Cash", color: "var(--chart-4)" },
18
- { key: "reits", label: "REITs", color: "var(--chart-5)" },
14
+ { key: "online", label: "Online", color: "var(--chart-1)" },
15
+ { key: "retail", label: "Retail", color: "var(--chart-2)" },
16
+ { key: "wholesale", label: "Wholesale", color: "var(--chart-3)" },
17
+ { key: "marketplace", label: "Marketplace", color: "var(--chart-4)" },
18
+ { key: "events", label: "Events", color: "var(--chart-5)" },
19
19
  ];
20
20
 
21
21
  export default function ChartBarExample() {
@@ -23,7 +23,7 @@ export default function ChartBarExample() {
23
23
  const [layout, setLayout] = useState("grouped");
24
24
  return (
25
25
  <BarChartCard
26
- title="Money invested by quarter"
26
+ title="Revenue by channel and quarter"
27
27
  description={
28
28
  layout === "grouped"
29
29
  ? "All five chart colours side by side, in series order"
@@ -30,15 +30,15 @@ export default function ChartCategoryTicksExample() {
30
30
  height={300}
31
31
  />
32
32
  <BarChartCard
33
- title="Orders by sector"
33
+ title="Orders by category"
34
34
  description="Demo orders; one long category label on a narrow chart"
35
35
  data={[
36
- { sector: "Information Technology and Services", orders: 100 },
37
- { sector: "Other", orders: 50 },
38
- { sector: "Third", orders: 70 },
36
+ { category: "Home Appliances and Kitchen Equipment", orders: 100 },
37
+ { category: "Other", orders: 50 },
38
+ { category: "Third", orders: 70 },
39
39
  ]}
40
- xKey="sector"
41
- xTicks={["Information Technology and Services"]}
40
+ xKey="category"
41
+ xTicks={["Home Appliances and Kitchen Equipment"]}
42
42
  series={[{ key: "orders", label: "Orders", color: "var(--chart-1)" }]}
43
43
  horizontal
44
44
  height={220}
@@ -2,26 +2,26 @@ import { useState } from "react";
2
2
  import { LineChartCard, ToggleGroup, ToggleGroupItem, useFormat, type ChartSeries } from "@siyahi/ui";
3
3
 
4
4
  const cumulative = [
5
- { month: "May", portfolio: 0.012, index: 0.008 },
6
- { month: "Jun", portfolio: 0.021, index: 0.015 },
7
- { month: "Jul", portfolio: 0.034, index: 0.029 },
8
- { month: "Aug", portfolio: -0.006, index: 0.004 },
9
- { month: "Sep", portfolio: 0.041, index: 0.031 },
10
- { month: "Oct", portfolio: 0.052, index: 0.036 },
5
+ { month: "May", store: 0.012, category: 0.008 },
6
+ { month: "Jun", store: 0.021, category: 0.015 },
7
+ { month: "Jul", store: 0.034, category: 0.029 },
8
+ { month: "Aug", store: -0.006, category: 0.004 },
9
+ { month: "Sep", store: 0.041, category: 0.031 },
10
+ { month: "Oct", store: 0.052, category: 0.036 },
11
11
  ];
12
12
 
13
13
  const monthly = [
14
- { month: "May", portfolio: 0.012, index: 0.008 },
15
- { month: "Jun", portfolio: 0.009, index: 0.007 },
16
- { month: "Jul", portfolio: 0.013, index: 0.014 },
17
- { month: "Aug", portfolio: -0.039, index: -0.024 },
18
- { month: "Sep", portfolio: 0.047, index: 0.027 },
19
- { month: "Oct", portfolio: 0.011, index: 0.005 },
14
+ { month: "May", store: 0.012, category: 0.008 },
15
+ { month: "Jun", store: 0.009, category: 0.007 },
16
+ { month: "Jul", store: 0.013, category: 0.014 },
17
+ { month: "Aug", store: -0.039, category: -0.024 },
18
+ { month: "Sep", store: 0.047, category: 0.027 },
19
+ { month: "Oct", store: 0.011, category: 0.005 },
20
20
  ];
21
21
 
22
22
  const series: ChartSeries<(typeof cumulative)[number]> = [
23
- { key: "portfolio", label: "Portfolio", color: "var(--chart-1)" },
24
- { key: "index", label: "Nifty 50", color: "var(--chart-2)" },
23
+ { key: "store", label: "Our store", color: "var(--chart-1)" },
24
+ { key: "category", label: "Category average", color: "var(--chart-2)" },
25
25
  ];
26
26
 
27
27
  export default function ChartLineExample() {
@@ -29,7 +29,7 @@ export default function ChartLineExample() {
29
29
  const [mode, setMode] = useState("cumulative");
30
30
  return (
31
31
  <LineChartCard
32
- title="Return against the index"
32
+ title="Sales growth against the category"
33
33
  description={mode === "cumulative" ? "Cumulative, from the start of May" : "Each month on its own"}
34
34
  action={
35
35
  <ToggleGroup
@@ -42,8 +42,8 @@ export default function ChartLineExample() {
42
42
  size="sm"
43
43
  aria-label="Mode"
44
44
  >
45
- <ToggleGroupItem value="cumulative">Cumulative return</ToggleGroupItem>
46
- <ToggleGroupItem value="monthly">Monthly return</ToggleGroupItem>
45
+ <ToggleGroupItem value="cumulative">Cumulative growth</ToggleGroupItem>
46
+ <ToggleGroupItem value="monthly">Monthly growth</ToggleGroupItem>
47
47
  </ToggleGroup>
48
48
  }
49
49
  data={mode === "cumulative" ? cumulative : monthly}
@@ -6,10 +6,12 @@ export default function CollapsibleExample() {
6
6
  <Collapsible className="flex max-w-sm flex-col gap-2">
7
7
  <CollapsibleTrigger render={<Button variant="outline" className="w-fit" />}>
8
8
  <ChevronsUpDownIcon />
9
- How lots are matched
9
+ How refunds are counted
10
10
  </CollapsibleTrigger>
11
- <CollapsibleContent className="text-muted-foreground">
12
- Sells are matched to the oldest buy first, as the tax rules require.
11
+ <CollapsibleContent>
12
+ <p className="text-muted-foreground">
13
+ A refund comes off the month the order was placed in, not the month it was paid.
14
+ </p>
13
15
  </CollapsibleContent>
14
16
  </Collapsible>
15
17
  );
@@ -1,27 +1,29 @@
1
1
  import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "@siyahi/ui";
2
- import { ChartLineIcon, LandmarkIcon, WalletIcon } from "lucide-react";
2
+ import { ChartLineIcon, PackageIcon, UsersIcon } from "lucide-react";
3
3
 
4
4
  export default function CommandExample() {
5
5
  return (
6
- <Command className="rounded-lg border">
7
- <CommandInput placeholder="Jump to a page" />
8
- <CommandList>
9
- <CommandEmpty>No page matches.</CommandEmpty>
10
- <CommandGroup heading="Pages">
11
- <CommandItem>
12
- <WalletIcon />
13
- Holdings
14
- </CommandItem>
15
- <CommandItem>
16
- <ChartLineIcon />
17
- Realized
18
- </CommandItem>
19
- <CommandItem>
20
- <LandmarkIcon />
21
- Cash flow
22
- </CommandItem>
23
- </CommandGroup>
24
- </CommandList>
25
- </Command>
6
+ <div className="overflow-hidden rounded-lg border">
7
+ <Command>
8
+ <CommandInput placeholder="Jump to a page" />
9
+ <CommandList>
10
+ <CommandEmpty>No page matches.</CommandEmpty>
11
+ <CommandGroup heading="Pages">
12
+ <CommandItem>
13
+ <PackageIcon />
14
+ Orders
15
+ </CommandItem>
16
+ <CommandItem>
17
+ <ChartLineIcon />
18
+ Revenue
19
+ </CommandItem>
20
+ <CommandItem>
21
+ <UsersIcon />
22
+ Customers
23
+ </CommandItem>
24
+ </CommandGroup>
25
+ </CommandList>
26
+ </Command>
27
+ </div>
26
28
  );
27
29
  }
@@ -3,12 +3,14 @@ import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuTrigger }
3
3
  export default function ContextMenuExample() {
4
4
  return (
5
5
  <ContextMenu>
6
- <ContextMenuTrigger className="flex h-24 w-full items-center justify-center rounded-lg border border-dashed text-muted-foreground">
7
- Right-click or long-press here
6
+ <ContextMenuTrigger className="w-full">
7
+ <div className="flex h-24 items-center justify-center rounded-lg border border-dashed text-muted-foreground">
8
+ Right-click or long-press here
9
+ </div>
8
10
  </ContextMenuTrigger>
9
11
  <ContextMenuContent>
10
- <ContextMenuItem>Copy symbol</ContextMenuItem>
11
- <ContextMenuItem>Open chart</ContextMenuItem>
12
+ <ContextMenuItem>Copy order number</ContextMenuItem>
13
+ <ContextMenuItem>Open order</ContextMenuItem>
12
14
  </ContextMenuContent>
13
15
  </ContextMenu>
14
16
  );
@@ -15,36 +15,27 @@ import {
15
15
  type DataTableColumnDef,
16
16
  } from "@siyahi/ui";
17
17
 
18
- interface Holding {
19
- symbol: string;
20
- value: number;
21
- gain: number;
22
- /** Closing prices over the last ten sessions, oldest first. */
23
- closes: number[];
18
+ interface Store {
19
+ store: string;
20
+ /** This month's sales, and their change on last month, in rupees; made-up figures. */
21
+ sales: number;
22
+ change: number;
23
+ /** Orders on each of the last ten days, oldest first. */
24
+ daily: number[];
24
25
  }
25
26
 
26
- const holdings: Holding[] = [
27
- { symbol: "ITC", value: 276000, gain: -18400, closes: [478, 474, 470, 471, 466, 463, 465, 461, 459, 460] },
28
- {
29
- symbol: "HDFCBANK",
30
- value: 262500,
31
- gain: 21300,
32
- closes: [1712, 1718, 1726, 1720, 1731, 1744, 1739, 1748, 1752, 1750],
33
- },
34
- {
35
- symbol: "ICICIBANK",
36
- value: 258000,
37
- gain: 44100,
38
- closes: [1250, 1262, 1258, 1271, 1266, 1280, 1284, 1279, 1288, 1290],
39
- },
40
- { symbol: "NIFTYBEES", value: 255600, gain: 12800, closes: [281, 282, 280, 283, 284, 283, 285, 284, 286, 284] },
41
- { symbol: "INFY", value: 224400, gain: 30900, closes: [1820, 1834, 1829, 1841, 1852, 1848, 1860, 1855, 1866, 1870] },
42
- { symbol: "TCS", value: 166000, gain: -2600, closes: [4180, 4172, 4165, 4170, 4158, 4150, 4161, 4155, 4148, 4150] },
27
+ const stores: Store[] = [
28
+ { store: "Delhi", sales: 276000, change: -18400, daily: [478, 474, 470, 471, 466, 463, 465, 461, 459, 460] },
29
+ { store: "Bengaluru", sales: 262500, change: 21300, daily: [312, 318, 326, 320, 331, 344, 339, 348, 352, 350] },
30
+ { store: "Chennai", sales: 258000, change: 44100, daily: [250, 262, 258, 271, 266, 280, 284, 279, 288, 290] },
31
+ { store: "Kolkata", sales: 255600, change: 12800, daily: [281, 282, 280, 283, 284, 283, 285, 284, 286, 284] },
32
+ { store: "Mumbai", sales: 224400, change: 30900, daily: [220, 234, 229, 241, 252, 248, 260, 255, 266, 270] },
33
+ { store: "Pune", sales: 166000, change: -2600, daily: [180, 172, 165, 170, 158, 150, 161, 155, 148, 150] },
43
34
  ];
44
35
 
45
36
  // Each bar is a share of its column's largest figure, so the rows draw to one scale.
46
- const largestValue = Math.max(...holdings.map((h) => h.value));
47
- const largestGain = Math.max(...holdings.map((h) => Math.abs(h.gain)));
37
+ const largestSales = Math.max(...stores.map((s) => s.sales));
38
+ const largestChange = Math.max(...stores.map((s) => Math.abs(s.change)));
48
39
 
49
40
  function Money({ amount }: { amount: number }) {
50
41
  return useFormat().money(amount);
@@ -52,41 +43,41 @@ function Money({ amount }: { amount: number }) {
52
43
 
53
44
  const header = () => <DataTableSortHeader />;
54
45
 
55
- const columns: DataTableColumnDef<Holding>[] = [
56
- { accessorKey: "symbol", header, size: 120, meta: { label: "Symbol" } },
46
+ const columns: DataTableColumnDef<Store>[] = [
47
+ { accessorKey: "store", header, size: 120, meta: { label: "Store" } },
57
48
  {
58
- accessorKey: "value",
49
+ accessorKey: "sales",
59
50
  header,
60
51
  size: 170,
61
- meta: { label: "Value", variant: "number" },
52
+ meta: { label: "Sales", variant: "number" },
62
53
  cell: ({ row }) => (
63
- <DataBar value={row.original.value} max={largestValue}>
64
- <Money amount={row.original.value} />
54
+ <DataBar value={row.original.sales} max={largestSales}>
55
+ <Money amount={row.original.sales} />
65
56
  </DataBar>
66
57
  ),
67
58
  },
68
59
  {
69
- accessorKey: "gain",
60
+ accessorKey: "change",
70
61
  header,
71
62
  size: 170,
72
- meta: { label: "Gain", variant: "number" },
63
+ meta: { label: "vs last month", variant: "number" },
73
64
  cell: ({ row }) => (
74
- <DataBar value={row.original.gain} max={largestGain} tone="sign">
75
- <Money amount={row.original.gain} />
65
+ <DataBar value={row.original.change} max={largestChange} tone="sign">
66
+ <Money amount={row.original.change} />
76
67
  </DataBar>
77
68
  ),
78
69
  },
79
70
  {
80
- id: "closes",
71
+ id: "daily",
81
72
  header: "10 days",
82
73
  size: 110,
83
74
  enableSorting: false,
84
75
  cell: ({ row }) => {
85
- const { closes } = row.original;
86
- const rising = (closes.at(-1) ?? 0) >= (closes[0] ?? 0);
76
+ const { daily } = row.original;
77
+ const rising = (daily.at(-1) ?? 0) >= (daily[0] ?? 0);
87
78
  return (
88
79
  <Sparkline
89
- data={closes}
80
+ data={daily}
90
81
  variant="line"
91
82
  color={rising ? "var(--positive)" : "var(--negative)"}
92
83
  animate={false}
@@ -101,15 +92,11 @@ export default function DataBarExample() {
101
92
  return (
102
93
  <Card>
103
94
  <CardHeader>
104
- <CardTitle>Holdings</CardTitle>
95
+ <CardTitle>Stores</CardTitle>
105
96
  <CardDescription>Bars give each figure's size against the column's largest</CardDescription>
106
97
  </CardHeader>
107
98
  <CardContent>
108
- <DataTableRoot
109
- data={holdings}
110
- columns={columns}
111
- initialState={{ columnPinning: { start: ["symbol"], end: [] } }}
112
- >
99
+ <DataTableRoot data={stores} columns={columns} initialState={{ columnPinning: { start: ["store"], end: [] } }}>
113
100
  <DataTable>
114
101
  <DataTableHeader />
115
102
  <DataTableBody />
@@ -18,52 +18,53 @@ import {
18
18
  type DataTableColumnDef,
19
19
  } from "@siyahi/ui";
20
20
 
21
- interface Holding {
22
- symbol: string;
23
- sector: string;
24
- quantity: number;
25
- value: number;
21
+ interface Product {
22
+ product: string;
23
+ category: string;
24
+ /** Units sold and revenue this month; change is the revenue against last week. Made-up figures. */
25
+ units: number;
26
+ revenue: number;
26
27
  change: number;
27
28
  }
28
29
 
29
- const holdings: Holding[] = [
30
- { symbol: "INFY", sector: "IT", quantity: 120, value: 224400, change: 0.018 },
31
- { symbol: "HDFCBANK", sector: "Banks", quantity: 150, value: 262500, change: -0.006 },
32
- { symbol: "TCS", sector: "IT", quantity: 40, value: 166000, change: 0.004 },
33
- { symbol: "ITC", sector: "Fast Moving Consumer Goods", quantity: 600, value: 276000, change: -0.012 },
30
+ const products: Product[] = [
31
+ { product: "Standing desk", category: "Furniture", units: 120, revenue: 224400, change: 0.018 },
32
+ { product: "Office chair", category: "Seating", units: 150, revenue: 262500, change: -0.006 },
33
+ { product: "Bookshelf", category: "Furniture", units: 40, revenue: 166000, change: 0.004 },
34
+ { product: "Dinner set", category: "Kitchen, Dining & Tableware", units: 600, revenue: 276000, change: -0.012 },
34
35
  ];
35
36
 
36
37
  const header = () => <DataTableSortHeader />;
37
38
 
38
- // While the Day column is hidden to fit, the day's move rides under the value it belongs to.
39
- function ValueCell({ holding }: { holding: Holding }) {
39
+ // While the Week column is hidden to fit, the week's change rides under the revenue it belongs to.
40
+ function RevenueCell({ product }: { product: Product }) {
40
41
  const format = useFormat();
41
- const { compactColumns } = useDataTable<Holding>();
42
- if (!compactColumns?.hidden.has("change")) return format.money(holding.value);
42
+ const { compactColumns } = useDataTable<Product>();
43
+ if (!compactColumns?.hidden.has("change")) return format.money(product.revenue);
43
44
  return (
44
45
  <div className="flex flex-col items-end">
45
- {format.money(holding.value)}
46
- <Delta value={holding.change} />
46
+ {format.money(product.revenue)}
47
+ <Delta value={product.change} />
47
48
  </div>
48
49
  );
49
50
  }
50
51
 
51
- const columns: DataTableColumnDef<Holding>[] = [
52
- { accessorKey: "symbol", header, size: 140, meta: { label: "Symbol", compact: true } },
53
- { accessorKey: "sector", header, size: 120, meta: { label: "Sector" } },
54
- { accessorKey: "quantity", header, size: 100, meta: { label: "Qty", variant: "number" } },
52
+ const columns: DataTableColumnDef<Product>[] = [
53
+ { accessorKey: "product", header, size: 140, meta: { label: "Product", compact: true } },
54
+ { accessorKey: "category", header, size: 120, meta: { label: "Category" } },
55
+ { accessorKey: "units", header, size: 100, meta: { label: "Units", variant: "number" } },
55
56
  {
56
- accessorKey: "value",
57
+ accessorKey: "revenue",
57
58
  header,
58
59
  size: 140,
59
- meta: { label: "Value", variant: "number", compact: true },
60
- cell: ({ row }) => <ValueCell holding={row.original} />,
60
+ meta: { label: "Revenue", variant: "number", compact: true },
61
+ cell: ({ row }) => <RevenueCell product={row.original} />,
61
62
  },
62
63
  {
63
64
  accessorKey: "change",
64
65
  header,
65
66
  size: 110,
66
- meta: { label: "Day", variant: "number" },
67
+ meta: { label: "Week", variant: "number" },
67
68
  cell: ({ row }) => <Delta value={row.original.change} />,
68
69
  },
69
70
  ];
@@ -72,19 +73,19 @@ export default function DataTableCompactExample() {
72
73
  return (
73
74
  <Card>
74
75
  <CardHeader>
75
- <CardTitle>Holdings on a phone</CardTitle>
76
+ <CardTitle>Products on a phone</CardTitle>
76
77
  <CardDescription>
77
- Symbol and value are the key columns. When the columns do not fit, the others hide from the right, and the
78
- day's move rides under the value once its column is gone; All columns brings back the rest
78
+ Product and revenue are the key columns. When the columns do not fit, the others hide from the right, and the
79
+ week's change rides under the revenue once its column is gone; All columns brings back the rest
79
80
  </CardDescription>
80
81
  </CardHeader>
81
82
  <CardContent>
82
- <DataTableRoot data={holdings} columns={columns}>
83
+ <DataTableRoot data={products} columns={columns}>
83
84
  <DataTableToolbarSection>
84
85
  <DataTableCompactColumnsToggle />
85
- <DataTableRowCount unit="holdings" />
86
+ <DataTableRowCount unit="products" />
86
87
  </DataTableToolbarSection>
87
- <DataTable aria-label="Holdings on a phone">
88
+ <DataTable aria-label="Products on a phone">
88
89
  <DataTableHeader />
89
90
  <DataTableBody />
90
91
  </DataTable>
@@ -26,30 +26,30 @@ import {
26
26
  type DataTableColumnDef,
27
27
  } from "@siyahi/ui";
28
28
 
29
- interface Holding {
30
- symbol: string;
31
- sector: string;
32
- broker: string;
29
+ interface Order {
30
+ order: string;
31
+ status: string;
32
+ warehouse: string;
33
33
  }
34
- const data: Holding[] = [
35
- { symbol: "INFY", sector: "Information technology", broker: "Kite" },
36
- { symbol: "HDFCBANK", sector: "Banks", broker: "Dhan" },
37
- { symbol: "TCS", sector: "Information technology", broker: "Dhan" },
34
+ const data: Order[] = [
35
+ { order: "ORD-1042", status: "Out for delivery", warehouse: "Bhiwandi" },
36
+ { order: "ORD-1043", status: "Packed", warehouse: "Hosur" },
37
+ { order: "ORD-1044", status: "Out for delivery", warehouse: "Hosur" },
38
38
  ];
39
39
  const header = () => <DataTableSortHeader />;
40
- const columns: DataTableColumnDef<Holding>[] = [
41
- { accessorKey: "symbol", header, size: 140, meta: { label: "Instrument" } },
42
- { accessorKey: "sector", header, meta: { label: "Sector" } },
43
- { accessorKey: "broker", header, meta: { label: "Broker" } },
40
+ const columns: DataTableColumnDef<Order>[] = [
41
+ { accessorKey: "order", header, size: 140, meta: { label: "Order" } },
42
+ { accessorKey: "status", header, meta: { label: "Status" } },
43
+ { accessorKey: "warehouse", header, meta: { label: "Warehouse" } },
44
44
  ];
45
45
 
46
46
  function Filters() {
47
- const { table, isCompact } = useDataTable<Holding>();
47
+ const { table, isCompact } = useDataTable<Order>();
48
48
  const active = table.state.columnFilters.length;
49
49
  const controls = (
50
50
  <div className="flex flex-wrap gap-2">
51
- <DataTableFacetedFilter accessorKey="sector" title="Sector" />
52
- <DataTableFacetedFilter accessorKey="broker" title="Broker" />
51
+ <DataTableFacetedFilter accessorKey="status" title="Status" />
52
+ <DataTableFacetedFilter accessorKey="warehouse" title="Warehouse" />
53
53
  </div>
54
54
  );
55
55
  if (!isCompact) return controls;
@@ -58,7 +58,7 @@ function Filters() {
58
58
  <SheetTrigger render={<Button variant="outline" size="sm" />}>Filters{active ? ` (${active})` : ""}</SheetTrigger>
59
59
  <SheetContent>
60
60
  <SheetHeader>
61
- <SheetTitle>Holding filters</SheetTitle>
61
+ <SheetTitle>Order filters</SheetTitle>
62
62
  <SheetDescription>Selections stay applied when this panel closes.</SheetDescription>
63
63
  </SheetHeader>
64
64
  <div className="overflow-y-auto px-4">{controls}</div>
@@ -77,7 +77,7 @@ export default function DataTableFiltersExample() {
77
77
  return (
78
78
  <Card>
79
79
  <CardHeader>
80
- <CardTitle>Holdings with compact filters</CardTitle>
80
+ <CardTitle>Orders with compact filters</CardTitle>
81
81
  <CardDescription>Search stays visible; secondary filters move into a panel in narrow space.</CardDescription>
82
82
  </CardHeader>
83
83
  <CardContent>
@@ -86,13 +86,13 @@ export default function DataTableFiltersExample() {
86
86
  <DataTableToolbarSection>
87
87
  <DataTableSearchFilter
88
88
  label="Search compact example"
89
- placeholder="Search holdings…"
89
+ placeholder="Search orders…"
90
90
  className="w-full flex-none sm:w-64"
91
91
  />
92
92
  <Filters />
93
- <DataTableRowCount unit="holdings" />
93
+ <DataTableRowCount unit="orders" />
94
94
  </DataTableToolbarSection>
95
- <DataTable aria-label="Holdings with compact filters">
95
+ <DataTable aria-label="Orders with compact filters">
96
96
  <DataTableHeader />
97
97
  <DataTableBody />
98
98
  </DataTable>