@siyahi/ui 0.1.9-next.22 → 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 +3 -2
- package/agents/examples/accordion.tsx +7 -7
- package/agents/examples/alert.tsx +16 -15
- package/agents/examples/badge.tsx +20 -12
- package/agents/examples/bar-list-labels.tsx +6 -6
- package/agents/examples/bar-list-sides.tsx +8 -8
- package/agents/examples/bar-list.tsx +8 -8
- package/agents/examples/breadcrumb.tsx +3 -3
- package/agents/examples/callout.tsx +15 -15
- package/agents/examples/card.tsx +3 -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 +4 -2
- package/agents/examples/command.tsx +6 -6
- package/agents/examples/context-menu.tsx +2 -2
- 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 +15 -15
- package/agents/examples/dropdown-menu.tsx +2 -2
- package/agents/examples/heatmap-calendar.tsx +6 -6
- package/agents/examples/heatmap-status.tsx +1 -1
- package/agents/examples/heatmap-weekday.tsx +7 -7
- 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 +3 -3
- 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 +18 -18
- 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 -18
- package/agents/examples/tabs.tsx +7 -7
- package/agents/examples/target-rows.tsx +25 -23
- package/agents/examples/tooltip.tsx +2 -2
- package/agents/examples/treemap.tsx +27 -24
- package/agents/manifest.json +15 -15
- package/dist/components/registry/charts/bar-chart-card.d.ts +1 -1
- 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/siyahi/callout.d.ts +5 -12
- package/dist/components/siyahi/callout.js +5 -11
- 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 +2 -2
- 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/tone.d.ts +36 -0
- package/dist/lib/tone.js +35 -0
- package/package.json +1 -1
- 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
|
@@ -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
11
|
<CollapsibleContent>
|
|
12
|
-
<p className="text-muted-foreground">
|
|
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,5 +1,5 @@
|
|
|
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 (
|
|
@@ -10,16 +10,16 @@ export default function CommandExample() {
|
|
|
10
10
|
<CommandEmpty>No page matches.</CommandEmpty>
|
|
11
11
|
<CommandGroup heading="Pages">
|
|
12
12
|
<CommandItem>
|
|
13
|
-
<
|
|
14
|
-
|
|
13
|
+
<PackageIcon />
|
|
14
|
+
Orders
|
|
15
15
|
</CommandItem>
|
|
16
16
|
<CommandItem>
|
|
17
17
|
<ChartLineIcon />
|
|
18
|
-
|
|
18
|
+
Revenue
|
|
19
19
|
</CommandItem>
|
|
20
20
|
<CommandItem>
|
|
21
|
-
<
|
|
22
|
-
|
|
21
|
+
<UsersIcon />
|
|
22
|
+
Customers
|
|
23
23
|
</CommandItem>
|
|
24
24
|
</CommandGroup>
|
|
25
25
|
</CommandList>
|
|
@@ -9,8 +9,8 @@ export default function ContextMenuExample() {
|
|
|
9
9
|
</div>
|
|
10
10
|
</ContextMenuTrigger>
|
|
11
11
|
<ContextMenuContent>
|
|
12
|
-
<ContextMenuItem>Copy
|
|
13
|
-
<ContextMenuItem>Open
|
|
12
|
+
<ContextMenuItem>Copy order number</ContextMenuItem>
|
|
13
|
+
<ContextMenuItem>Open order</ContextMenuItem>
|
|
14
14
|
</ContextMenuContent>
|
|
15
15
|
</ContextMenu>
|
|
16
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>
|
|
@@ -18,21 +18,22 @@ 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
|
-
{
|
|
34
|
-
{
|
|
35
|
-
{
|
|
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 },
|
|
35
|
+
{ product: "Kids chair", category: "Seating", units: 200, revenue: 258000, change: 0.022 },
|
|
36
|
+
{ product: "Desk lamp", category: "Lighting", units: 900, revenue: 255600, change: 0.009 },
|
|
36
37
|
];
|
|
37
38
|
|
|
38
39
|
// One click sorts largest (or Z) first; the title comes from meta.label.
|
|
@@ -42,22 +43,22 @@ function Money({ amount }: { amount: number }) {
|
|
|
42
43
|
return useFormat().money(amount);
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
const columns: DataTableColumnDef<
|
|
46
|
-
{ accessorKey: "
|
|
47
|
-
{ accessorKey: "
|
|
48
|
-
{ accessorKey: "
|
|
46
|
+
const columns: DataTableColumnDef<Product>[] = [
|
|
47
|
+
{ accessorKey: "product", header, size: 140, meta: { label: "Product" } },
|
|
48
|
+
{ accessorKey: "category", header, size: 120, meta: { label: "Category" } },
|
|
49
|
+
{ accessorKey: "units", header, size: 100, meta: { label: "Units", variant: "number" } },
|
|
49
50
|
{
|
|
50
|
-
accessorKey: "
|
|
51
|
+
accessorKey: "revenue",
|
|
51
52
|
header,
|
|
52
53
|
size: 140,
|
|
53
|
-
meta: { label: "
|
|
54
|
-
cell: ({ row }) => <Money amount={row.original.
|
|
54
|
+
meta: { label: "Revenue", variant: "number" },
|
|
55
|
+
cell: ({ row }) => <Money amount={row.original.revenue} />,
|
|
55
56
|
},
|
|
56
57
|
{
|
|
57
58
|
accessorKey: "change",
|
|
58
59
|
header,
|
|
59
60
|
size: 110,
|
|
60
|
-
meta: { label: "
|
|
61
|
+
meta: { label: "Week", variant: "number" },
|
|
61
62
|
cell: ({ row }) => <Delta value={row.original.change} />,
|
|
62
63
|
},
|
|
63
64
|
];
|
|
@@ -66,28 +67,28 @@ export default function DataTableExample() {
|
|
|
66
67
|
return (
|
|
67
68
|
<Card>
|
|
68
69
|
<CardHeader>
|
|
69
|
-
<CardTitle>
|
|
70
|
+
<CardTitle>Products</CardTitle>
|
|
70
71
|
<CardDescription>
|
|
71
|
-
Search every column, filter by
|
|
72
|
-
scrolls in wide panels. In narrow panels every column scrolls, leaving room for the
|
|
72
|
+
Search every column, filter by category, sort any column in one click; the product stays put when the table
|
|
73
|
+
scrolls in wide panels. In narrow panels every column scrolls, leaving room for the figures
|
|
73
74
|
</CardDescription>
|
|
74
75
|
</CardHeader>
|
|
75
76
|
<CardContent>
|
|
76
77
|
<DataTableRoot
|
|
77
|
-
data={
|
|
78
|
+
data={products}
|
|
78
79
|
columns={columns}
|
|
79
|
-
initialState={{ columnPinning: { start: ["
|
|
80
|
+
initialState={{ columnPinning: { start: ["product"], end: [] } }}
|
|
80
81
|
>
|
|
81
82
|
<DataTableToolbarSection>
|
|
82
83
|
<DataTableSearchFilter
|
|
83
|
-
placeholder="Search
|
|
84
|
-
label="Filter
|
|
84
|
+
placeholder="Search products…"
|
|
85
|
+
label="Filter products"
|
|
85
86
|
className="flex-none sm:w-64"
|
|
86
87
|
/>
|
|
87
|
-
<DataTableFacetedFilter accessorKey="
|
|
88
|
-
<DataTableRowCount unit="
|
|
88
|
+
<DataTableFacetedFilter accessorKey="category" title="Category" />
|
|
89
|
+
<DataTableRowCount unit="products" />
|
|
89
90
|
</DataTableToolbarSection>
|
|
90
|
-
<DataTable aria-label="
|
|
91
|
+
<DataTable aria-label="Products">
|
|
91
92
|
<DataTableHeader />
|
|
92
93
|
<DataTableBody />
|
|
93
94
|
</DataTable>
|
|
@@ -13,11 +13,11 @@ import {
|
|
|
13
13
|
export default function DialogExample() {
|
|
14
14
|
return (
|
|
15
15
|
<Dialog>
|
|
16
|
-
<DialogTrigger render={<Button variant="outline" className="w-fit" />}>Show
|
|
16
|
+
<DialogTrigger render={<Button variant="outline" className="w-fit" />}>Show parcels</DialogTrigger>
|
|
17
17
|
<DialogContent>
|
|
18
18
|
<DialogHeader>
|
|
19
|
-
<DialogTitle>
|
|
20
|
-
<DialogDescription>Each
|
|
19
|
+
<DialogTitle>Parcels for this order</DialogTitle>
|
|
20
|
+
<DialogDescription>Each parcel this order was split into, earliest first.</DialogDescription>
|
|
21
21
|
</DialogHeader>
|
|
22
22
|
<DialogFooter>
|
|
23
23
|
<DialogClose render={<Button variant="outline" />}>Close</DialogClose>
|