@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.
- package/DESIGN.md +16 -3
- package/agents/examples/accordion.tsx +7 -7
- package/agents/examples/alert.tsx +16 -15
- package/agents/examples/app-sidebar.tsx +3 -1
- package/agents/examples/badge.tsx +20 -12
- package/agents/examples/bar-list-labels.tsx +6 -6
- package/agents/examples/bar-list-sides.tsx +18 -16
- package/agents/examples/bar-list.tsx +8 -8
- package/agents/examples/breadcrumb.tsx +3 -3
- package/agents/examples/calendar.tsx +3 -7
- package/agents/examples/callout.tsx +15 -15
- package/agents/examples/card.tsx +5 -3
- package/agents/examples/change-bar.tsx +21 -21
- package/agents/examples/chart-area.tsx +11 -11
- package/agents/examples/chart-bar-flows.tsx +1 -1
- package/agents/examples/chart-bar-hourly.tsx +1 -1
- package/agents/examples/chart-bar-losses.tsx +3 -3
- package/agents/examples/chart-bar-teams.tsx +72 -0
- package/agents/examples/chart-bar-years.tsx +5 -5
- package/agents/examples/chart-bar.tsx +10 -10
- package/agents/examples/chart-category-ticks.tsx +6 -6
- package/agents/examples/chart-line.tsx +17 -17
- package/agents/examples/collapsible.tsx +5 -3
- package/agents/examples/command.tsx +23 -21
- package/agents/examples/context-menu.tsx +6 -4
- package/agents/examples/data-bar.tsx +32 -45
- package/agents/examples/data-table-compact.tsx +31 -30
- package/agents/examples/data-table-filters.tsx +20 -20
- package/agents/examples/data-table.tsx +31 -30
- package/agents/examples/dialog.tsx +3 -3
- package/agents/examples/distribution-bar-tug.tsx +36 -34
- package/agents/examples/dropdown-menu.tsx +2 -2
- package/agents/examples/heatmap-calendar.tsx +12 -10
- package/agents/examples/heatmap-status.tsx +11 -9
- package/agents/examples/heatmap-weekday.tsx +27 -30
- package/agents/examples/input-states.tsx +9 -9
- package/agents/examples/input.tsx +3 -3
- package/agents/examples/local-time.tsx +1 -1
- package/agents/examples/metric-strip.tsx +8 -8
- package/agents/examples/page-hero.tsx +2 -2
- package/agents/examples/popover.tsx +3 -3
- package/agents/examples/price-chart.tsx +5 -5
- package/agents/examples/progress-tone.tsx +10 -9
- package/agents/examples/progress.tsx +1 -1
- package/agents/examples/range-position-table.tsx +31 -31
- package/agents/examples/range-position.tsx +31 -29
- package/agents/examples/scroll-area.tsx +12 -10
- package/agents/examples/section-cards-select.tsx +11 -10
- package/agents/examples/section-cards-trend.tsx +4 -4
- package/agents/examples/section-cards.tsx +13 -13
- package/agents/examples/select.tsx +9 -9
- package/agents/examples/separator.tsx +3 -3
- package/agents/examples/sheet.tsx +1 -1
- package/agents/examples/slider.tsx +1 -1
- package/agents/examples/surfaces.tsx +16 -16
- package/agents/examples/tabs.tsx +7 -7
- package/agents/examples/target-rows.tsx +31 -27
- package/agents/examples/tooltip.tsx +2 -2
- package/agents/examples/treemap.tsx +38 -33
- package/agents/manifest.json +15 -15
- package/dist/components/registry/charts/bar-chart-card.d.ts +1 -1
- package/dist/components/registry/charts/bar-chart-card.js +6 -2
- package/dist/components/registry/charts/line-chart-card.d.ts +1 -1
- package/dist/components/registry/charts/line-chart-card.js +1 -1
- package/dist/components/registry/dashboard-01/section-cards.js +1 -1
- package/dist/components/registry/dashboardcn/distribution-bar.js +5 -3
- package/dist/components/registry/heatmap/status-heatmap.js +1 -1
- package/dist/components/siyahi/callout.d.ts +5 -12
- package/dist/components/siyahi/callout.js +5 -11
- package/dist/components/siyahi/delta.d.ts +5 -1
- package/dist/components/siyahi/delta.js +14 -9
- package/dist/components/siyahi/status-alert.d.ts +15 -0
- package/dist/components/siyahi/status-alert.js +29 -0
- package/dist/components/siyahi/status-badge.d.ts +15 -0
- package/dist/components/siyahi/status-badge.js +24 -0
- package/dist/components/siyahi/tone-progress.d.ts +1 -1
- package/dist/components/siyahi/tone-progress.js +1 -1
- package/dist/components/siyahi/treemap.d.ts +4 -4
- package/dist/components/siyahi/treemap.js +5 -5
- package/dist/index.d.ts +5 -4
- package/dist/index.js +3 -2
- package/dist/lib/chart-frame.js +1 -1
- package/dist/lib/chart-series.d.ts +1 -1
- package/dist/lib/format.d.ts +1 -1
- package/dist/lib/format.js +1 -1
- package/dist/lib/tone.d.ts +36 -0
- package/dist/lib/tone.js +35 -0
- package/package.json +1 -1
- package/report.css +14 -14
- package/styles/siyahi.css +92 -20
- package/agents/examples/chart-bar-sectors.tsx +0 -72
- package/dist/components/siyahi/warning-alert.d.ts +0 -10
- 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
|
|
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
|
|
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 ? "
|
|
22
|
+
const signed = (v: number) => `${v < 0 ? "\u2212" : "+"}${moneyCompact(Math.abs(v))}`;
|
|
23
23
|
return (
|
|
24
24
|
<BarChartCard
|
|
25
|
-
title="
|
|
25
|
+
title="Profit by financial year"
|
|
26
26
|
description={
|
|
27
|
-
year ? `${year} picked; click it again for every year` : "April to March,
|
|
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",
|
|
6
|
-
{ quarter: "Q2",
|
|
7
|
-
{ quarter: "Q3",
|
|
8
|
-
{ quarter: "Q4",
|
|
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: "
|
|
15
|
-
{ key: "
|
|
16
|
-
{ key: "
|
|
17
|
-
{ key: "
|
|
18
|
-
{ key: "
|
|
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="
|
|
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
|
|
33
|
+
title="Orders by category"
|
|
34
34
|
description="Demo orders; one long category label on a narrow chart"
|
|
35
35
|
data={[
|
|
36
|
-
{
|
|
37
|
-
{
|
|
38
|
-
{
|
|
36
|
+
{ category: "Home Appliances and Kitchen Equipment", orders: 100 },
|
|
37
|
+
{ category: "Other", orders: 50 },
|
|
38
|
+
{ category: "Third", orders: 70 },
|
|
39
39
|
]}
|
|
40
|
-
xKey="
|
|
41
|
-
xTicks={["
|
|
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",
|
|
6
|
-
{ month: "Jun",
|
|
7
|
-
{ month: "Jul",
|
|
8
|
-
{ month: "Aug",
|
|
9
|
-
{ month: "Sep",
|
|
10
|
-
{ month: "Oct",
|
|
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",
|
|
15
|
-
{ month: "Jun",
|
|
16
|
-
{ month: "Jul",
|
|
17
|
-
{ month: "Aug",
|
|
18
|
-
{ month: "Sep",
|
|
19
|
-
{ month: "Oct",
|
|
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: "
|
|
24
|
-
{ key: "
|
|
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="
|
|
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
|
|
46
|
-
<ToggleGroupItem value="monthly">Monthly
|
|
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
|
|
9
|
+
How refunds are counted
|
|
10
10
|
</CollapsibleTrigger>
|
|
11
|
-
<CollapsibleContent
|
|
12
|
-
|
|
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,
|
|
2
|
+
import { ChartLineIcon, PackageIcon, UsersIcon } from "lucide-react";
|
|
3
3
|
|
|
4
4
|
export default function CommandExample() {
|
|
5
5
|
return (
|
|
6
|
-
<
|
|
7
|
-
<
|
|
8
|
-
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
<
|
|
12
|
-
<
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
<
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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="
|
|
7
|
-
|
|
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
|
|
11
|
-
<ContextMenuItem>Open
|
|
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
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
|
27
|
-
{
|
|
28
|
-
{
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
|
47
|
-
const
|
|
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<
|
|
56
|
-
{ accessorKey: "
|
|
46
|
+
const columns: DataTableColumnDef<Store>[] = [
|
|
47
|
+
{ accessorKey: "store", header, size: 120, meta: { label: "Store" } },
|
|
57
48
|
{
|
|
58
|
-
accessorKey: "
|
|
49
|
+
accessorKey: "sales",
|
|
59
50
|
header,
|
|
60
51
|
size: 170,
|
|
61
|
-
meta: { label: "
|
|
52
|
+
meta: { label: "Sales", variant: "number" },
|
|
62
53
|
cell: ({ row }) => (
|
|
63
|
-
<DataBar value={row.original.
|
|
64
|
-
<Money amount={row.original.
|
|
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: "
|
|
60
|
+
accessorKey: "change",
|
|
70
61
|
header,
|
|
71
62
|
size: 170,
|
|
72
|
-
meta: { label: "
|
|
63
|
+
meta: { label: "vs last month", variant: "number" },
|
|
73
64
|
cell: ({ row }) => (
|
|
74
|
-
<DataBar value={row.original.
|
|
75
|
-
<Money amount={row.original.
|
|
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: "
|
|
71
|
+
id: "daily",
|
|
81
72
|
header: "10 days",
|
|
82
73
|
size: 110,
|
|
83
74
|
enableSorting: false,
|
|
84
75
|
cell: ({ row }) => {
|
|
85
|
-
const {
|
|
86
|
-
const rising = (
|
|
76
|
+
const { daily } = row.original;
|
|
77
|
+
const rising = (daily.at(-1) ?? 0) >= (daily[0] ?? 0);
|
|
87
78
|
return (
|
|
88
79
|
<Sparkline
|
|
89
|
-
data={
|
|
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>
|
|
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
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
|
30
|
-
{
|
|
31
|
-
{
|
|
32
|
-
{
|
|
33
|
-
{
|
|
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
|
|
39
|
-
function
|
|
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<
|
|
42
|
-
if (!compactColumns?.hidden.has("change")) return format.money(
|
|
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(
|
|
46
|
-
<Delta value={
|
|
46
|
+
{format.money(product.revenue)}
|
|
47
|
+
<Delta value={product.change} />
|
|
47
48
|
</div>
|
|
48
49
|
);
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
const columns: DataTableColumnDef<
|
|
52
|
-
{ accessorKey: "
|
|
53
|
-
{ accessorKey: "
|
|
54
|
-
{ accessorKey: "
|
|
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: "
|
|
57
|
+
accessorKey: "revenue",
|
|
57
58
|
header,
|
|
58
59
|
size: 140,
|
|
59
|
-
meta: { label: "
|
|
60
|
-
cell: ({ row }) => <
|
|
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: "
|
|
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>
|
|
76
|
+
<CardTitle>Products on a phone</CardTitle>
|
|
76
77
|
<CardDescription>
|
|
77
|
-
|
|
78
|
-
|
|
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={
|
|
83
|
+
<DataTableRoot data={products} columns={columns}>
|
|
83
84
|
<DataTableToolbarSection>
|
|
84
85
|
<DataTableCompactColumnsToggle />
|
|
85
|
-
<DataTableRowCount unit="
|
|
86
|
+
<DataTableRowCount unit="products" />
|
|
86
87
|
</DataTableToolbarSection>
|
|
87
|
-
<DataTable aria-label="
|
|
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
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
interface Order {
|
|
30
|
+
order: string;
|
|
31
|
+
status: string;
|
|
32
|
+
warehouse: string;
|
|
33
33
|
}
|
|
34
|
-
const data:
|
|
35
|
-
{
|
|
36
|
-
{
|
|
37
|
-
{
|
|
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<
|
|
41
|
-
{ accessorKey: "
|
|
42
|
-
{ accessorKey: "
|
|
43
|
-
{ accessorKey: "
|
|
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<
|
|
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="
|
|
52
|
-
<DataTableFacetedFilter accessorKey="
|
|
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>
|
|
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>
|
|
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
|
|
89
|
+
placeholder="Search orders…"
|
|
90
90
|
className="w-full flex-none sm:w-64"
|
|
91
91
|
/>
|
|
92
92
|
<Filters />
|
|
93
|
-
<DataTableRowCount unit="
|
|
93
|
+
<DataTableRowCount unit="orders" />
|
|
94
94
|
</DataTableToolbarSection>
|
|
95
|
-
<DataTable aria-label="
|
|
95
|
+
<DataTable aria-label="Orders with compact filters">
|
|
96
96
|
<DataTableHeader />
|
|
97
97
|
<DataTableBody />
|
|
98
98
|
</DataTable>
|