@emara/ui 1.1.0
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/components/ui/.gitkeep +0 -0
- package/components/ui/accordion.stories.tsx +231 -0
- package/components/ui/accordion.tsx +250 -0
- package/components/ui/app-shell.stories.tsx +270 -0
- package/components/ui/app-shell.tsx +491 -0
- package/components/ui/avatar.stories.tsx +174 -0
- package/components/ui/avatar.tsx +257 -0
- package/components/ui/badge.stories.tsx +127 -0
- package/components/ui/badge.tsx +146 -0
- package/components/ui/breadcrumb.stories.tsx +92 -0
- package/components/ui/breadcrumb.tsx +302 -0
- package/components/ui/button.stories.tsx +186 -0
- package/components/ui/button.tsx +128 -0
- package/components/ui/card.stories.tsx +279 -0
- package/components/ui/card.tsx +250 -0
- package/components/ui/checkbox.stories.tsx +93 -0
- package/components/ui/checkbox.tsx +131 -0
- package/components/ui/combobox.stories.tsx +489 -0
- package/components/ui/combobox.tsx +874 -0
- package/components/ui/context-menu.stories.tsx +202 -0
- package/components/ui/context-menu.tsx +309 -0
- package/components/ui/data-table.stories.tsx +227 -0
- package/components/ui/data-table.tsx +539 -0
- package/components/ui/date-picker.stories.tsx +225 -0
- package/components/ui/date-picker.tsx +597 -0
- package/components/ui/dialog.stories.tsx +193 -0
- package/components/ui/dialog.tsx +262 -0
- package/components/ui/divider.stories.tsx +84 -0
- package/components/ui/divider.tsx +135 -0
- package/components/ui/drawer.stories.tsx +218 -0
- package/components/ui/drawer.tsx +329 -0
- package/components/ui/dropdown-menu.stories.tsx +270 -0
- package/components/ui/dropdown-menu.tsx +353 -0
- package/components/ui/empty-state.stories.tsx +121 -0
- package/components/ui/empty-state.tsx +289 -0
- package/components/ui/field-group.stories.tsx +201 -0
- package/components/ui/field-group.tsx +276 -0
- package/components/ui/form.stories.tsx +219 -0
- package/components/ui/form.tsx +542 -0
- package/components/ui/input.stories.tsx +154 -0
- package/components/ui/input.tsx +208 -0
- package/components/ui/label.stories.tsx +84 -0
- package/components/ui/label.tsx +98 -0
- package/components/ui/page-header.stories.tsx +136 -0
- package/components/ui/page-header.tsx +315 -0
- package/components/ui/pagination.stories.tsx +136 -0
- package/components/ui/pagination.tsx +427 -0
- package/components/ui/popover.stories.tsx +212 -0
- package/components/ui/popover.tsx +167 -0
- package/components/ui/radio-group.stories.tsx +96 -0
- package/components/ui/radio-group.tsx +250 -0
- package/components/ui/select.stories.tsx +203 -0
- package/components/ui/select.tsx +318 -0
- package/components/ui/sidebar.stories.tsx +186 -0
- package/components/ui/sidebar.tsx +623 -0
- package/components/ui/skeleton.stories.tsx +131 -0
- package/components/ui/skeleton.tsx +311 -0
- package/components/ui/switch.stories.tsx +74 -0
- package/components/ui/switch.tsx +186 -0
- package/components/ui/table.stories.tsx +107 -0
- package/components/ui/table.tsx +285 -0
- package/components/ui/tabs.stories.tsx +222 -0
- package/components/ui/tabs.tsx +287 -0
- package/components/ui/textarea.stories.tsx +96 -0
- package/components/ui/textarea.tsx +182 -0
- package/components/ui/toast.stories.tsx +169 -0
- package/components/ui/toast.tsx +250 -0
- package/components/ui/tooltip.stories.tsx +146 -0
- package/components/ui/tooltip.tsx +156 -0
- package/components/ui/top-bar.stories.tsx +182 -0
- package/components/ui/top-bar.tsx +155 -0
- package/dist/components/ui/accordion.d.ts +45 -0
- package/dist/components/ui/accordion.d.ts.map +1 -0
- package/dist/components/ui/accordion.js +99 -0
- package/dist/components/ui/accordion.js.map +1 -0
- package/dist/components/ui/app-shell.d.ts +70 -0
- package/dist/components/ui/app-shell.d.ts.map +1 -0
- package/dist/components/ui/app-shell.js +199 -0
- package/dist/components/ui/app-shell.js.map +1 -0
- package/dist/components/ui/avatar.d.ts +41 -0
- package/dist/components/ui/avatar.d.ts.map +1 -0
- package/dist/components/ui/avatar.js +104 -0
- package/dist/components/ui/avatar.js.map +1 -0
- package/dist/components/ui/badge.d.ts +27 -0
- package/dist/components/ui/badge.d.ts.map +1 -0
- package/dist/components/ui/badge.js +65 -0
- package/dist/components/ui/badge.js.map +1 -0
- package/dist/components/ui/breadcrumb.d.ts +35 -0
- package/dist/components/ui/breadcrumb.d.ts.map +1 -0
- package/dist/components/ui/breadcrumb.js +88 -0
- package/dist/components/ui/breadcrumb.js.map +1 -0
- package/dist/components/ui/button.d.ts +26 -0
- package/dist/components/ui/button.d.ts.map +1 -0
- package/dist/components/ui/button.js +73 -0
- package/dist/components/ui/button.js.map +1 -0
- package/dist/components/ui/card.d.ts +52 -0
- package/dist/components/ui/card.d.ts.map +1 -0
- package/dist/components/ui/card.js +96 -0
- package/dist/components/ui/card.js.map +1 -0
- package/dist/components/ui/checkbox.d.ts +18 -0
- package/dist/components/ui/checkbox.d.ts.map +1 -0
- package/dist/components/ui/checkbox.js +59 -0
- package/dist/components/ui/checkbox.js.map +1 -0
- package/dist/components/ui/combobox.d.ts +194 -0
- package/dist/components/ui/combobox.d.ts.map +1 -0
- package/dist/components/ui/combobox.js +361 -0
- package/dist/components/ui/combobox.js.map +1 -0
- package/dist/components/ui/context-menu.d.ts +46 -0
- package/dist/components/ui/context-menu.d.ts.map +1 -0
- package/dist/components/ui/context-menu.js +95 -0
- package/dist/components/ui/context-menu.js.map +1 -0
- package/dist/components/ui/data-table.d.ts +53 -0
- package/dist/components/ui/data-table.d.ts.map +1 -0
- package/dist/components/ui/data-table.js +163 -0
- package/dist/components/ui/data-table.js.map +1 -0
- package/dist/components/ui/date-picker.d.ts +103 -0
- package/dist/components/ui/date-picker.d.ts.map +1 -0
- package/dist/components/ui/date-picker.js +306 -0
- package/dist/components/ui/date-picker.js.map +1 -0
- package/dist/components/ui/dialog.d.ts +40 -0
- package/dist/components/ui/dialog.d.ts.map +1 -0
- package/dist/components/ui/dialog.js +110 -0
- package/dist/components/ui/dialog.js.map +1 -0
- package/dist/components/ui/divider.d.ts +30 -0
- package/dist/components/ui/divider.d.ts.map +1 -0
- package/dist/components/ui/divider.js +62 -0
- package/dist/components/ui/divider.js.map +1 -0
- package/dist/components/ui/drawer.d.ts +56 -0
- package/dist/components/ui/drawer.d.ts.map +1 -0
- package/dist/components/ui/drawer.js +147 -0
- package/dist/components/ui/drawer.js.map +1 -0
- package/dist/components/ui/dropdown-menu.d.ts +63 -0
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -0
- package/dist/components/ui/dropdown-menu.js +116 -0
- package/dist/components/ui/dropdown-menu.js.map +1 -0
- package/dist/components/ui/empty-state.d.ts +43 -0
- package/dist/components/ui/empty-state.d.ts.map +1 -0
- package/dist/components/ui/empty-state.js +128 -0
- package/dist/components/ui/empty-state.js.map +1 -0
- package/dist/components/ui/field-group.d.ts +38 -0
- package/dist/components/ui/field-group.d.ts.map +1 -0
- package/dist/components/ui/field-group.js +107 -0
- package/dist/components/ui/field-group.js.map +1 -0
- package/dist/components/ui/form.d.ts +67 -0
- package/dist/components/ui/form.d.ts.map +1 -0
- package/dist/components/ui/form.js +286 -0
- package/dist/components/ui/form.js.map +1 -0
- package/dist/components/ui/input.d.ts +36 -0
- package/dist/components/ui/input.d.ts.map +1 -0
- package/dist/components/ui/input.js +99 -0
- package/dist/components/ui/input.js.map +1 -0
- package/dist/components/ui/label.d.ts +37 -0
- package/dist/components/ui/label.d.ts.map +1 -0
- package/dist/components/ui/label.js +34 -0
- package/dist/components/ui/label.js.map +1 -0
- package/dist/components/ui/page-header.d.ts +65 -0
- package/dist/components/ui/page-header.d.ts.map +1 -0
- package/dist/components/ui/page-header.js +140 -0
- package/dist/components/ui/page-header.js.map +1 -0
- package/dist/components/ui/pagination.d.ts +67 -0
- package/dist/components/ui/pagination.d.ts.map +1 -0
- package/dist/components/ui/pagination.js +109 -0
- package/dist/components/ui/pagination.js.map +1 -0
- package/dist/components/ui/popover.d.ts +28 -0
- package/dist/components/ui/popover.d.ts.map +1 -0
- package/dist/components/ui/popover.js +85 -0
- package/dist/components/ui/popover.js.map +1 -0
- package/dist/components/ui/radio-group.d.ts +35 -0
- package/dist/components/ui/radio-group.d.ts.map +1 -0
- package/dist/components/ui/radio-group.js +103 -0
- package/dist/components/ui/radio-group.js.map +1 -0
- package/dist/components/ui/select.d.ts +42 -0
- package/dist/components/ui/select.d.ts.map +1 -0
- package/dist/components/ui/select.js +86 -0
- package/dist/components/ui/select.js.map +1 -0
- package/dist/components/ui/sidebar.d.ts +59 -0
- package/dist/components/ui/sidebar.d.ts.map +1 -0
- package/dist/components/ui/sidebar.js +189 -0
- package/dist/components/ui/sidebar.js.map +1 -0
- package/dist/components/ui/skeleton.d.ts +77 -0
- package/dist/components/ui/skeleton.d.ts.map +1 -0
- package/dist/components/ui/skeleton.js +115 -0
- package/dist/components/ui/skeleton.js.map +1 -0
- package/dist/components/ui/switch.d.ts +26 -0
- package/dist/components/ui/switch.d.ts.map +1 -0
- package/dist/components/ui/switch.js +84 -0
- package/dist/components/ui/switch.js.map +1 -0
- package/dist/components/ui/table.d.ts +52 -0
- package/dist/components/ui/table.d.ts.map +1 -0
- package/dist/components/ui/table.js +109 -0
- package/dist/components/ui/table.js.map +1 -0
- package/dist/components/ui/tabs.d.ts +42 -0
- package/dist/components/ui/tabs.d.ts.map +1 -0
- package/dist/components/ui/tabs.js +163 -0
- package/dist/components/ui/tabs.js.map +1 -0
- package/dist/components/ui/textarea.d.ts +26 -0
- package/dist/components/ui/textarea.d.ts.map +1 -0
- package/dist/components/ui/textarea.js +96 -0
- package/dist/components/ui/textarea.js.map +1 -0
- package/dist/components/ui/toast.d.ts +77 -0
- package/dist/components/ui/toast.d.ts.map +1 -0
- package/dist/components/ui/toast.js +141 -0
- package/dist/components/ui/toast.js.map +1 -0
- package/dist/components/ui/tooltip.d.ts +31 -0
- package/dist/components/ui/tooltip.d.ts.map +1 -0
- package/dist/components/ui/tooltip.js +71 -0
- package/dist/components/ui/tooltip.js.map +1 -0
- package/dist/components/ui/top-bar.d.ts +30 -0
- package/dist/components/ui/top-bar.d.ts.map +1 -0
- package/dist/components/ui/top-bar.js +64 -0
- package/dist/components/ui/top-bar.js.map +1 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +6 -0
- package/dist/lib/utils.js.map +1 -0
- package/lib/utils.ts +6 -0
- package/package.json +112 -0
- package/styles/globals.css +685 -0
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
import { useMemo, useState } from "react";
|
|
3
|
+
import type { ColumnDef } from "@tanstack/react-table";
|
|
4
|
+
|
|
5
|
+
import { Badge } from "./badge";
|
|
6
|
+
import { Button } from "./button";
|
|
7
|
+
import { DataTable } from "./data-table";
|
|
8
|
+
|
|
9
|
+
interface Charge {
|
|
10
|
+
id: string;
|
|
11
|
+
customer: string;
|
|
12
|
+
amount: number;
|
|
13
|
+
status: "paid" | "pending" | "failed" | "refunded";
|
|
14
|
+
date: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const SAMPLE: Charge[] = [
|
|
18
|
+
{ id: "ch_001", customer: "Alice Lavoie", amount: 1250.0, status: "paid", date: "2026-04-12" },
|
|
19
|
+
{ id: "ch_002", customer: "Bilal Othmani", amount: 49.99, status: "pending", date: "2026-04-13" },
|
|
20
|
+
{ id: "ch_003", customer: "Catherine Lee", amount: 320.0, status: "failed", date: "2026-04-14" },
|
|
21
|
+
{ id: "ch_004", customer: "Dan Park", amount: 89.5, status: "paid", date: "2026-04-14" },
|
|
22
|
+
{ id: "ch_005", customer: "Elena Costa", amount: 1500.0, status: "refunded", date: "2026-04-15" },
|
|
23
|
+
{ id: "ch_006", customer: "Fadi Younis", amount: 220.0, status: "paid", date: "2026-04-16" },
|
|
24
|
+
{ id: "ch_007", customer: "Gloria Reyes", amount: 75.0, status: "pending", date: "2026-04-17" },
|
|
25
|
+
{ id: "ch_008", customer: "Hassan Demir", amount: 425.5, status: "paid", date: "2026-04-18" },
|
|
26
|
+
{ id: "ch_009", customer: "Iris Aoki", amount: 1100.0, status: "failed", date: "2026-04-19" },
|
|
27
|
+
{ id: "ch_010", customer: "Joel Munoz", amount: 360.0, status: "paid", date: "2026-04-20" },
|
|
28
|
+
{ id: "ch_011", customer: "Karim Ouali", amount: 95.0, status: "paid", date: "2026-04-21" },
|
|
29
|
+
{ id: "ch_012", customer: "Lina Sato", amount: 1820.0, status: "refunded", date: "2026-04-22" },
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
function StatusBadge({ status }: { status: Charge["status"] }) {
|
|
33
|
+
const v =
|
|
34
|
+
status === "paid"
|
|
35
|
+
? "success"
|
|
36
|
+
: status === "pending"
|
|
37
|
+
? "warning"
|
|
38
|
+
: status === "failed"
|
|
39
|
+
? "destructive"
|
|
40
|
+
: "secondary";
|
|
41
|
+
return (
|
|
42
|
+
<Badge size="sm" variant={v}>
|
|
43
|
+
{status}
|
|
44
|
+
</Badge>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function buildColumns(): ColumnDef<Charge, unknown>[] {
|
|
49
|
+
return [
|
|
50
|
+
{
|
|
51
|
+
accessorKey: "id",
|
|
52
|
+
header: "Charge",
|
|
53
|
+
meta: { width: 120 },
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
accessorKey: "customer",
|
|
57
|
+
header: "Customer",
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
accessorKey: "amount",
|
|
61
|
+
header: "Amount",
|
|
62
|
+
cell: ({ getValue }) =>
|
|
63
|
+
`$${(getValue<number>() ?? 0).toLocaleString(undefined, {
|
|
64
|
+
minimumFractionDigits: 2,
|
|
65
|
+
})}`,
|
|
66
|
+
meta: { align: "end" },
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
accessorKey: "status",
|
|
70
|
+
header: "Status",
|
|
71
|
+
cell: ({ getValue }) => <StatusBadge status={getValue<Charge["status"]>()} />,
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
accessorKey: "date",
|
|
75
|
+
header: "Date",
|
|
76
|
+
meta: { align: "end" },
|
|
77
|
+
},
|
|
78
|
+
];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const meta: Meta<typeof DataTable<Charge>> = {
|
|
82
|
+
title: "Data/DataTable",
|
|
83
|
+
parameters: { layout: "padded" },
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export default meta;
|
|
87
|
+
type Story = StoryObj<typeof meta>;
|
|
88
|
+
|
|
89
|
+
export const Static: Story = {
|
|
90
|
+
render: () => <DataTable<Charge> data={SAMPLE} columns={buildColumns()} />,
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export const Sortable: Story = {
|
|
94
|
+
render: () => (
|
|
95
|
+
<DataTable<Charge>
|
|
96
|
+
data={SAMPLE}
|
|
97
|
+
columns={buildColumns()}
|
|
98
|
+
enableSorting
|
|
99
|
+
enableMultiSort
|
|
100
|
+
hoverable
|
|
101
|
+
/>
|
|
102
|
+
),
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export const GlobalSearch: Story = {
|
|
106
|
+
render: () => (
|
|
107
|
+
<DataTable<Charge>
|
|
108
|
+
data={SAMPLE}
|
|
109
|
+
columns={buildColumns()}
|
|
110
|
+
enableSorting
|
|
111
|
+
enableGlobalSearch
|
|
112
|
+
hoverable
|
|
113
|
+
/>
|
|
114
|
+
),
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export const Selection: Story = {
|
|
118
|
+
render: () => {
|
|
119
|
+
function Demo() {
|
|
120
|
+
const [selected, setSelected] = useState<Charge[]>([]);
|
|
121
|
+
return (
|
|
122
|
+
<div className="space-y-3">
|
|
123
|
+
<div className="text-sm text-muted-foreground">
|
|
124
|
+
{selected.length} selected
|
|
125
|
+
</div>
|
|
126
|
+
<DataTable<Charge>
|
|
127
|
+
data={SAMPLE}
|
|
128
|
+
columns={buildColumns()}
|
|
129
|
+
enableSorting
|
|
130
|
+
enableSelection="multi"
|
|
131
|
+
onSelectionChange={setSelected}
|
|
132
|
+
getRowId={(row) => row.id}
|
|
133
|
+
hoverable
|
|
134
|
+
/>
|
|
135
|
+
</div>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
return <Demo />;
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export const ColumnVisibility: Story = {
|
|
143
|
+
render: () => (
|
|
144
|
+
<DataTable<Charge>
|
|
145
|
+
data={SAMPLE}
|
|
146
|
+
columns={buildColumns()}
|
|
147
|
+
enableSorting
|
|
148
|
+
enableGlobalSearch
|
|
149
|
+
enableColumnVisibility
|
|
150
|
+
hoverable
|
|
151
|
+
/>
|
|
152
|
+
),
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export const WithPagination: Story = {
|
|
156
|
+
render: () => {
|
|
157
|
+
function Demo() {
|
|
158
|
+
const data = useMemo(
|
|
159
|
+
() =>
|
|
160
|
+
Array.from({ length: 153 }, (_, i) => ({
|
|
161
|
+
...SAMPLE[i % SAMPLE.length]!,
|
|
162
|
+
id: `ch_${String(i + 1).padStart(4, "0")}`,
|
|
163
|
+
})),
|
|
164
|
+
[],
|
|
165
|
+
);
|
|
166
|
+
return (
|
|
167
|
+
<DataTable<Charge>
|
|
168
|
+
data={data}
|
|
169
|
+
columns={buildColumns()}
|
|
170
|
+
enableSorting
|
|
171
|
+
enableGlobalSearch
|
|
172
|
+
enableColumnVisibility
|
|
173
|
+
enablePagination
|
|
174
|
+
pageSize={10}
|
|
175
|
+
hoverable
|
|
176
|
+
/>
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
return <Demo />;
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
export const RowExpand: Story = {
|
|
184
|
+
render: () => (
|
|
185
|
+
<DataTable<Charge>
|
|
186
|
+
data={SAMPLE.slice(0, 5)}
|
|
187
|
+
columns={buildColumns()}
|
|
188
|
+
enableRowExpand
|
|
189
|
+
renderExpandedRow={(row) => (
|
|
190
|
+
<div className="text-sm">
|
|
191
|
+
<div className="font-medium">Charge details</div>
|
|
192
|
+
<pre className="mt-2 rounded bg-background p-2 text-xs">
|
|
193
|
+
{JSON.stringify(row, null, 2)}
|
|
194
|
+
</pre>
|
|
195
|
+
</div>
|
|
196
|
+
)}
|
|
197
|
+
hoverable
|
|
198
|
+
/>
|
|
199
|
+
),
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
export const Loading: Story = {
|
|
203
|
+
render: () => (
|
|
204
|
+
<DataTable<Charge> data={[]} columns={buildColumns()} loading pageSize={5} hoverable />
|
|
205
|
+
),
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
export const Empty: Story = {
|
|
209
|
+
render: () => <DataTable<Charge> data={[]} columns={buildColumns()} />,
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
export const ErrorState: Story = {
|
|
213
|
+
render: () => (
|
|
214
|
+
<DataTable<Charge>
|
|
215
|
+
data={[]}
|
|
216
|
+
columns={buildColumns()}
|
|
217
|
+
error={
|
|
218
|
+
<div className="text-sm text-destructive">
|
|
219
|
+
Failed to load charges.{" "}
|
|
220
|
+
<Button variant="link" className="px-0">
|
|
221
|
+
Retry
|
|
222
|
+
</Button>
|
|
223
|
+
</div>
|
|
224
|
+
}
|
|
225
|
+
/>
|
|
226
|
+
),
|
|
227
|
+
};
|