@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.
Files changed (218) hide show
  1. package/components/ui/.gitkeep +0 -0
  2. package/components/ui/accordion.stories.tsx +231 -0
  3. package/components/ui/accordion.tsx +250 -0
  4. package/components/ui/app-shell.stories.tsx +270 -0
  5. package/components/ui/app-shell.tsx +491 -0
  6. package/components/ui/avatar.stories.tsx +174 -0
  7. package/components/ui/avatar.tsx +257 -0
  8. package/components/ui/badge.stories.tsx +127 -0
  9. package/components/ui/badge.tsx +146 -0
  10. package/components/ui/breadcrumb.stories.tsx +92 -0
  11. package/components/ui/breadcrumb.tsx +302 -0
  12. package/components/ui/button.stories.tsx +186 -0
  13. package/components/ui/button.tsx +128 -0
  14. package/components/ui/card.stories.tsx +279 -0
  15. package/components/ui/card.tsx +250 -0
  16. package/components/ui/checkbox.stories.tsx +93 -0
  17. package/components/ui/checkbox.tsx +131 -0
  18. package/components/ui/combobox.stories.tsx +489 -0
  19. package/components/ui/combobox.tsx +874 -0
  20. package/components/ui/context-menu.stories.tsx +202 -0
  21. package/components/ui/context-menu.tsx +309 -0
  22. package/components/ui/data-table.stories.tsx +227 -0
  23. package/components/ui/data-table.tsx +539 -0
  24. package/components/ui/date-picker.stories.tsx +225 -0
  25. package/components/ui/date-picker.tsx +597 -0
  26. package/components/ui/dialog.stories.tsx +193 -0
  27. package/components/ui/dialog.tsx +262 -0
  28. package/components/ui/divider.stories.tsx +84 -0
  29. package/components/ui/divider.tsx +135 -0
  30. package/components/ui/drawer.stories.tsx +218 -0
  31. package/components/ui/drawer.tsx +329 -0
  32. package/components/ui/dropdown-menu.stories.tsx +270 -0
  33. package/components/ui/dropdown-menu.tsx +353 -0
  34. package/components/ui/empty-state.stories.tsx +121 -0
  35. package/components/ui/empty-state.tsx +289 -0
  36. package/components/ui/field-group.stories.tsx +201 -0
  37. package/components/ui/field-group.tsx +276 -0
  38. package/components/ui/form.stories.tsx +219 -0
  39. package/components/ui/form.tsx +542 -0
  40. package/components/ui/input.stories.tsx +154 -0
  41. package/components/ui/input.tsx +208 -0
  42. package/components/ui/label.stories.tsx +84 -0
  43. package/components/ui/label.tsx +98 -0
  44. package/components/ui/page-header.stories.tsx +136 -0
  45. package/components/ui/page-header.tsx +315 -0
  46. package/components/ui/pagination.stories.tsx +136 -0
  47. package/components/ui/pagination.tsx +427 -0
  48. package/components/ui/popover.stories.tsx +212 -0
  49. package/components/ui/popover.tsx +167 -0
  50. package/components/ui/radio-group.stories.tsx +96 -0
  51. package/components/ui/radio-group.tsx +250 -0
  52. package/components/ui/select.stories.tsx +203 -0
  53. package/components/ui/select.tsx +318 -0
  54. package/components/ui/sidebar.stories.tsx +186 -0
  55. package/components/ui/sidebar.tsx +623 -0
  56. package/components/ui/skeleton.stories.tsx +131 -0
  57. package/components/ui/skeleton.tsx +311 -0
  58. package/components/ui/switch.stories.tsx +74 -0
  59. package/components/ui/switch.tsx +186 -0
  60. package/components/ui/table.stories.tsx +107 -0
  61. package/components/ui/table.tsx +285 -0
  62. package/components/ui/tabs.stories.tsx +222 -0
  63. package/components/ui/tabs.tsx +287 -0
  64. package/components/ui/textarea.stories.tsx +96 -0
  65. package/components/ui/textarea.tsx +182 -0
  66. package/components/ui/toast.stories.tsx +169 -0
  67. package/components/ui/toast.tsx +250 -0
  68. package/components/ui/tooltip.stories.tsx +146 -0
  69. package/components/ui/tooltip.tsx +156 -0
  70. package/components/ui/top-bar.stories.tsx +182 -0
  71. package/components/ui/top-bar.tsx +155 -0
  72. package/dist/components/ui/accordion.d.ts +45 -0
  73. package/dist/components/ui/accordion.d.ts.map +1 -0
  74. package/dist/components/ui/accordion.js +99 -0
  75. package/dist/components/ui/accordion.js.map +1 -0
  76. package/dist/components/ui/app-shell.d.ts +70 -0
  77. package/dist/components/ui/app-shell.d.ts.map +1 -0
  78. package/dist/components/ui/app-shell.js +199 -0
  79. package/dist/components/ui/app-shell.js.map +1 -0
  80. package/dist/components/ui/avatar.d.ts +41 -0
  81. package/dist/components/ui/avatar.d.ts.map +1 -0
  82. package/dist/components/ui/avatar.js +104 -0
  83. package/dist/components/ui/avatar.js.map +1 -0
  84. package/dist/components/ui/badge.d.ts +27 -0
  85. package/dist/components/ui/badge.d.ts.map +1 -0
  86. package/dist/components/ui/badge.js +65 -0
  87. package/dist/components/ui/badge.js.map +1 -0
  88. package/dist/components/ui/breadcrumb.d.ts +35 -0
  89. package/dist/components/ui/breadcrumb.d.ts.map +1 -0
  90. package/dist/components/ui/breadcrumb.js +88 -0
  91. package/dist/components/ui/breadcrumb.js.map +1 -0
  92. package/dist/components/ui/button.d.ts +26 -0
  93. package/dist/components/ui/button.d.ts.map +1 -0
  94. package/dist/components/ui/button.js +73 -0
  95. package/dist/components/ui/button.js.map +1 -0
  96. package/dist/components/ui/card.d.ts +52 -0
  97. package/dist/components/ui/card.d.ts.map +1 -0
  98. package/dist/components/ui/card.js +96 -0
  99. package/dist/components/ui/card.js.map +1 -0
  100. package/dist/components/ui/checkbox.d.ts +18 -0
  101. package/dist/components/ui/checkbox.d.ts.map +1 -0
  102. package/dist/components/ui/checkbox.js +59 -0
  103. package/dist/components/ui/checkbox.js.map +1 -0
  104. package/dist/components/ui/combobox.d.ts +194 -0
  105. package/dist/components/ui/combobox.d.ts.map +1 -0
  106. package/dist/components/ui/combobox.js +361 -0
  107. package/dist/components/ui/combobox.js.map +1 -0
  108. package/dist/components/ui/context-menu.d.ts +46 -0
  109. package/dist/components/ui/context-menu.d.ts.map +1 -0
  110. package/dist/components/ui/context-menu.js +95 -0
  111. package/dist/components/ui/context-menu.js.map +1 -0
  112. package/dist/components/ui/data-table.d.ts +53 -0
  113. package/dist/components/ui/data-table.d.ts.map +1 -0
  114. package/dist/components/ui/data-table.js +163 -0
  115. package/dist/components/ui/data-table.js.map +1 -0
  116. package/dist/components/ui/date-picker.d.ts +103 -0
  117. package/dist/components/ui/date-picker.d.ts.map +1 -0
  118. package/dist/components/ui/date-picker.js +306 -0
  119. package/dist/components/ui/date-picker.js.map +1 -0
  120. package/dist/components/ui/dialog.d.ts +40 -0
  121. package/dist/components/ui/dialog.d.ts.map +1 -0
  122. package/dist/components/ui/dialog.js +110 -0
  123. package/dist/components/ui/dialog.js.map +1 -0
  124. package/dist/components/ui/divider.d.ts +30 -0
  125. package/dist/components/ui/divider.d.ts.map +1 -0
  126. package/dist/components/ui/divider.js +62 -0
  127. package/dist/components/ui/divider.js.map +1 -0
  128. package/dist/components/ui/drawer.d.ts +56 -0
  129. package/dist/components/ui/drawer.d.ts.map +1 -0
  130. package/dist/components/ui/drawer.js +147 -0
  131. package/dist/components/ui/drawer.js.map +1 -0
  132. package/dist/components/ui/dropdown-menu.d.ts +63 -0
  133. package/dist/components/ui/dropdown-menu.d.ts.map +1 -0
  134. package/dist/components/ui/dropdown-menu.js +116 -0
  135. package/dist/components/ui/dropdown-menu.js.map +1 -0
  136. package/dist/components/ui/empty-state.d.ts +43 -0
  137. package/dist/components/ui/empty-state.d.ts.map +1 -0
  138. package/dist/components/ui/empty-state.js +128 -0
  139. package/dist/components/ui/empty-state.js.map +1 -0
  140. package/dist/components/ui/field-group.d.ts +38 -0
  141. package/dist/components/ui/field-group.d.ts.map +1 -0
  142. package/dist/components/ui/field-group.js +107 -0
  143. package/dist/components/ui/field-group.js.map +1 -0
  144. package/dist/components/ui/form.d.ts +67 -0
  145. package/dist/components/ui/form.d.ts.map +1 -0
  146. package/dist/components/ui/form.js +286 -0
  147. package/dist/components/ui/form.js.map +1 -0
  148. package/dist/components/ui/input.d.ts +36 -0
  149. package/dist/components/ui/input.d.ts.map +1 -0
  150. package/dist/components/ui/input.js +99 -0
  151. package/dist/components/ui/input.js.map +1 -0
  152. package/dist/components/ui/label.d.ts +37 -0
  153. package/dist/components/ui/label.d.ts.map +1 -0
  154. package/dist/components/ui/label.js +34 -0
  155. package/dist/components/ui/label.js.map +1 -0
  156. package/dist/components/ui/page-header.d.ts +65 -0
  157. package/dist/components/ui/page-header.d.ts.map +1 -0
  158. package/dist/components/ui/page-header.js +140 -0
  159. package/dist/components/ui/page-header.js.map +1 -0
  160. package/dist/components/ui/pagination.d.ts +67 -0
  161. package/dist/components/ui/pagination.d.ts.map +1 -0
  162. package/dist/components/ui/pagination.js +109 -0
  163. package/dist/components/ui/pagination.js.map +1 -0
  164. package/dist/components/ui/popover.d.ts +28 -0
  165. package/dist/components/ui/popover.d.ts.map +1 -0
  166. package/dist/components/ui/popover.js +85 -0
  167. package/dist/components/ui/popover.js.map +1 -0
  168. package/dist/components/ui/radio-group.d.ts +35 -0
  169. package/dist/components/ui/radio-group.d.ts.map +1 -0
  170. package/dist/components/ui/radio-group.js +103 -0
  171. package/dist/components/ui/radio-group.js.map +1 -0
  172. package/dist/components/ui/select.d.ts +42 -0
  173. package/dist/components/ui/select.d.ts.map +1 -0
  174. package/dist/components/ui/select.js +86 -0
  175. package/dist/components/ui/select.js.map +1 -0
  176. package/dist/components/ui/sidebar.d.ts +59 -0
  177. package/dist/components/ui/sidebar.d.ts.map +1 -0
  178. package/dist/components/ui/sidebar.js +189 -0
  179. package/dist/components/ui/sidebar.js.map +1 -0
  180. package/dist/components/ui/skeleton.d.ts +77 -0
  181. package/dist/components/ui/skeleton.d.ts.map +1 -0
  182. package/dist/components/ui/skeleton.js +115 -0
  183. package/dist/components/ui/skeleton.js.map +1 -0
  184. package/dist/components/ui/switch.d.ts +26 -0
  185. package/dist/components/ui/switch.d.ts.map +1 -0
  186. package/dist/components/ui/switch.js +84 -0
  187. package/dist/components/ui/switch.js.map +1 -0
  188. package/dist/components/ui/table.d.ts +52 -0
  189. package/dist/components/ui/table.d.ts.map +1 -0
  190. package/dist/components/ui/table.js +109 -0
  191. package/dist/components/ui/table.js.map +1 -0
  192. package/dist/components/ui/tabs.d.ts +42 -0
  193. package/dist/components/ui/tabs.d.ts.map +1 -0
  194. package/dist/components/ui/tabs.js +163 -0
  195. package/dist/components/ui/tabs.js.map +1 -0
  196. package/dist/components/ui/textarea.d.ts +26 -0
  197. package/dist/components/ui/textarea.d.ts.map +1 -0
  198. package/dist/components/ui/textarea.js +96 -0
  199. package/dist/components/ui/textarea.js.map +1 -0
  200. package/dist/components/ui/toast.d.ts +77 -0
  201. package/dist/components/ui/toast.d.ts.map +1 -0
  202. package/dist/components/ui/toast.js +141 -0
  203. package/dist/components/ui/toast.js.map +1 -0
  204. package/dist/components/ui/tooltip.d.ts +31 -0
  205. package/dist/components/ui/tooltip.d.ts.map +1 -0
  206. package/dist/components/ui/tooltip.js +71 -0
  207. package/dist/components/ui/tooltip.js.map +1 -0
  208. package/dist/components/ui/top-bar.d.ts +30 -0
  209. package/dist/components/ui/top-bar.d.ts.map +1 -0
  210. package/dist/components/ui/top-bar.js +64 -0
  211. package/dist/components/ui/top-bar.js.map +1 -0
  212. package/dist/lib/utils.d.ts +3 -0
  213. package/dist/lib/utils.d.ts.map +1 -0
  214. package/dist/lib/utils.js +6 -0
  215. package/dist/lib/utils.js.map +1 -0
  216. package/lib/utils.ts +6 -0
  217. package/package.json +112 -0
  218. 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
+ };