@multicomma/arkcn 0.1.2 → 0.1.3
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/package.json +1 -1
- package/registry/index.json +1 -1
- package/registry/items/accordion.json +302 -0
- package/registry/items/activity-feed.json +408 -0
- package/registry/items/alert-dialog.json +676 -0
- package/registry/items/alert.json +113 -0
- package/registry/items/angle-slider.json +378 -0
- package/registry/items/app-shell.json +2654 -1
- package/registry/items/aspect-ratio.json +36 -0
- package/registry/items/attachment.json +299 -1
- package/registry/items/avatar.json +213 -0
- package/registry/items/badge.json +44 -0
- package/registry/items/breadcrumb.json +191 -0
- package/registry/items/bubble.json +146 -0
- package/registry/items/button-group.json +110 -0
- package/registry/items/button.json +52 -0
- package/registry/items/calendar.json +499 -1
- package/registry/items/canvas.json +446 -1
- package/registry/items/card.json +192 -0
- package/registry/items/carousel.json +208 -1
- package/registry/items/cascader.json +797 -1
- package/registry/items/chart.json +1764 -1
- package/registry/items/chat.json +993 -0
- package/registry/items/checkbox.json +503 -0
- package/registry/items/clipboard.json +308 -0
- package/registry/items/collapsible.json +226 -0
- package/registry/items/color-picker.json +1261 -0
- package/registry/items/combobox.json +1123 -1
- package/registry/items/command.json +837 -1
- package/registry/items/comment-thread.json +952 -1
- package/registry/items/context-menu.json +1344 -1
- package/registry/items/data-grid.json +449 -1
- package/registry/items/data-table.json +1310 -1
- package/registry/items/date-input.json +476 -0
- package/registry/items/dialog.json +592 -0
- package/registry/items/direction.json +29 -1
- package/registry/items/drawer.json +797 -0
- package/registry/items/dropdown-menu.json +1311 -1
- package/registry/items/editable.json +503 -0
- package/registry/items/empty.json +166 -0
- package/registry/items/field.json +286 -1
- package/registry/items/file-upload.json +638 -0
- package/registry/items/floating-panel.json +720 -0
- package/registry/items/floating-toolbar.json +43 -0
- package/registry/items/format.json +109 -0
- package/registry/items/gantt.json +773 -1
- package/registry/items/hooks/use-mobile.json +1 -0
- package/registry/items/hotkeys.json +99 -1
- package/registry/items/hover-card.json +357 -0
- package/registry/items/image-cropper.json +431 -0
- package/registry/items/input-group.json +189 -0
- package/registry/items/input-otp.json +181 -0
- package/registry/items/input.json +28 -0
- package/registry/items/item.json +308 -0
- package/registry/items/json-tree-view.json +336 -0
- package/registry/items/kanban.json +624 -1
- package/registry/items/kbd.json +54 -0
- package/registry/items/label.json +28 -0
- package/registry/items/lib/controllable.json +1 -0
- package/registry/items/lib/data-table-adapter.json +1 -0
- package/registry/items/lib/drag-preview.json +1 -0
- package/registry/items/lib/form.json +1 -0
- package/registry/items/lib/history.json +1 -0
- package/registry/items/lib/row-layout.json +1 -0
- package/registry/items/lib/table.json +1 -0
- package/registry/items/lib/time.json +1 -0
- package/registry/items/lib/utils.json +1 -0
- package/registry/items/live-region.json +43 -0
- package/registry/items/marker.json +96 -0
- package/registry/items/marquee.json +300 -0
- package/registry/items/menubar.json +1282 -1
- package/registry/items/message.json +166 -0
- package/registry/items/navigation-menu.json +561 -1
- package/registry/items/node-graph.json +1037 -1
- package/registry/items/number-input.json +519 -0
- package/registry/items/pagination.json +244 -1
- package/registry/items/password-input.json +311 -0
- package/registry/items/popconfirm.json +566 -0
- package/registry/items/popover.json +615 -0
- package/registry/items/progress.json +516 -0
- package/registry/items/qr-code.json +249 -0
- package/registry/items/query-builder.json +1368 -1
- package/registry/items/radio-group.json +362 -0
- package/registry/items/rating-group.json +304 -0
- package/registry/items/resizable.json +242 -1
- package/registry/items/rich-text-editor.json +934 -1
- package/registry/items/scheduler.json +1013 -1
- package/registry/items/scroll-area.json +227 -0
- package/registry/items/segment-group.json +363 -0
- package/registry/items/select.json +956 -0
- package/registry/items/separator.json +45 -1
- package/registry/items/sheet.json +592 -0
- package/registry/items/sidebar.json +785 -1
- package/registry/items/signature-pad.json +330 -0
- package/registry/items/skeleton.json +28 -0
- package/registry/items/slider.json +799 -0
- package/registry/items/sonner.json +135 -0
- package/registry/items/spinner.json +28 -0
- package/registry/items/steps.json +483 -0
- package/registry/items/swap.json +107 -0
- package/registry/items/switch.json +362 -0
- package/registry/items/table.json +210 -0
- package/registry/items/tabs.json +326 -0
- package/registry/items/tags-input.json +640 -0
- package/registry/items/textarea.json +28 -0
- package/registry/items/timer.json +289 -0
- package/registry/items/toc.json +372 -0
- package/registry/items/toggle-group.json +214 -1
- package/registry/items/toggle.json +124 -0
- package/registry/items/tooltip.json +417 -0
- package/registry/items/tour.json +498 -0
- package/registry/items/transfer-list.json +609 -1
- package/registry/items/tree-select.json +742 -1
- package/registry/items/tree-view.json +794 -0
- package/registry/items/virtual-list.json +214 -1
- package/src/components/ui/app-shell.tsx +11 -0
- package/src/components/ui/attachment.tsx +1 -0
- package/src/components/ui/calendar.tsx +1 -0
- package/src/components/ui/canvas.tsx +8 -0
- package/src/components/ui/carousel.tsx +3 -0
- package/src/components/ui/cascader.tsx +1 -0
- package/src/components/ui/chart.tsx +10 -0
- package/src/components/ui/combobox.tsx +3 -0
- package/src/components/ui/command.tsx +1 -0
- package/src/components/ui/comment-thread.tsx +11 -0
- package/src/components/ui/context-menu.tsx +6 -0
- package/src/components/ui/data-grid.tsx +8 -0
- package/src/components/ui/data-table.tsx +6 -0
- package/src/components/ui/direction.tsx +2 -0
- package/src/components/ui/dropdown-menu.tsx +6 -0
- package/src/components/ui/field.tsx +1 -0
- package/src/components/ui/gantt.tsx +15 -0
- package/src/components/ui/hotkeys.tsx +3 -0
- package/src/components/ui/kanban.tsx +3 -0
- package/src/components/ui/menubar.tsx +6 -0
- package/src/components/ui/navigation-menu.tsx +1 -0
- package/src/components/ui/node-graph.tsx +23 -0
- package/src/components/ui/pagination.tsx +1 -0
- package/src/components/ui/query-builder.tsx +7 -0
- package/src/components/ui/resizable.tsx +1 -0
- package/src/components/ui/rich-text-editor.tsx +54 -0
- package/src/components/ui/scheduler.tsx +26 -0
- package/src/components/ui/separator.tsx +1 -0
- package/src/components/ui/sidebar.tsx +5 -0
- package/src/components/ui/toggle-group.tsx +3 -0
- package/src/components/ui/transfer-list.tsx +11 -0
- package/src/components/ui/tree-select.tsx +5 -0
- package/src/components/ui/virtual-list.tsx +7 -0
|
@@ -33,6 +33,1315 @@
|
|
|
33
33
|
"useDataTable",
|
|
34
34
|
"useDataTableContext"
|
|
35
35
|
],
|
|
36
|
+
"parts": [
|
|
37
|
+
{
|
|
38
|
+
"name": "DataTable",
|
|
39
|
+
"props": [
|
|
40
|
+
{
|
|
41
|
+
"name": "table",
|
|
42
|
+
"type": "DataTableInstance<TData>",
|
|
43
|
+
"required": true,
|
|
44
|
+
"description": "The table instance, when not read from context.",
|
|
45
|
+
"from": "arkcn"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"name": "children",
|
|
49
|
+
"type": "ReactNode",
|
|
50
|
+
"required": false,
|
|
51
|
+
"description": "Content rendered inside the part.",
|
|
52
|
+
"from": "@types/react"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"name": "className",
|
|
56
|
+
"type": "string",
|
|
57
|
+
"required": false,
|
|
58
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
59
|
+
"from": "@types/react"
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"name": "style",
|
|
63
|
+
"type": "CSSProperties",
|
|
64
|
+
"required": false,
|
|
65
|
+
"description": "Inline styles applied to the rendered element.",
|
|
66
|
+
"from": "@types/react"
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"name": "DataTableBody",
|
|
72
|
+
"props": [
|
|
73
|
+
{
|
|
74
|
+
"name": "children",
|
|
75
|
+
"type": "(row: DataTableRow<TData>) => ReactNode",
|
|
76
|
+
"required": true,
|
|
77
|
+
"description": "Content rendered inside the part.",
|
|
78
|
+
"from": "arkcn"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"name": "empty",
|
|
82
|
+
"type": "ReactNode",
|
|
83
|
+
"required": false,
|
|
84
|
+
"default": "\"No results.\"",
|
|
85
|
+
"description": "Content shown when there are no rows.",
|
|
86
|
+
"from": "arkcn"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"name": "table",
|
|
90
|
+
"type": "DataTableInstance<TData>",
|
|
91
|
+
"required": false,
|
|
92
|
+
"description": "The table instance, when not read from context.",
|
|
93
|
+
"from": "arkcn"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"name": "className",
|
|
97
|
+
"type": "string",
|
|
98
|
+
"required": false,
|
|
99
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
100
|
+
"from": "@types/react"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"name": "style",
|
|
104
|
+
"type": "CSSProperties",
|
|
105
|
+
"required": false,
|
|
106
|
+
"description": "Inline styles applied to the rendered element.",
|
|
107
|
+
"from": "@types/react"
|
|
108
|
+
}
|
|
109
|
+
]
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"name": "DataTableBulkActionTrigger",
|
|
113
|
+
"props": [
|
|
114
|
+
{
|
|
115
|
+
"name": "label",
|
|
116
|
+
"type": "string",
|
|
117
|
+
"required": true,
|
|
118
|
+
"description": "Accessible label.",
|
|
119
|
+
"from": "arkcn"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"name": "asChild",
|
|
123
|
+
"type": "boolean",
|
|
124
|
+
"required": false,
|
|
125
|
+
"description": "Render the child element instead of the default one, merging props and behaviour onto it.",
|
|
126
|
+
"from": "arkcn"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
"name": "size",
|
|
130
|
+
"type": "\"default\" | \"xs\" | \"sm\" | \"lg\" | \"icon\" | \"icon-xs\" | \"icon-sm\" | \"icon-lg\" | null",
|
|
131
|
+
"required": false,
|
|
132
|
+
"description": "Size variant; sets a `data-size` attribute.",
|
|
133
|
+
"from": "arkcn"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"name": "variant",
|
|
137
|
+
"type": "\"link\" | \"default\" | \"outline\" | \"secondary\" | \"ghost\" | \"destructive\" | null",
|
|
138
|
+
"required": false,
|
|
139
|
+
"description": "Visual variant, styled with `cva`; sets a `data-variant` attribute.",
|
|
140
|
+
"from": "arkcn"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"name": "children",
|
|
144
|
+
"type": "ReactNode",
|
|
145
|
+
"required": false,
|
|
146
|
+
"description": "Content rendered inside the part.",
|
|
147
|
+
"from": "@types/react"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"name": "className",
|
|
151
|
+
"type": "string",
|
|
152
|
+
"required": false,
|
|
153
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
154
|
+
"from": "@types/react"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"name": "style",
|
|
158
|
+
"type": "CSSProperties",
|
|
159
|
+
"required": false,
|
|
160
|
+
"description": "Inline styles applied to the rendered element.",
|
|
161
|
+
"from": "@types/react"
|
|
162
|
+
}
|
|
163
|
+
]
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
"name": "DataTableBulkActions",
|
|
167
|
+
"props": [
|
|
168
|
+
{
|
|
169
|
+
"name": "entityName",
|
|
170
|
+
"type": "string",
|
|
171
|
+
"required": false,
|
|
172
|
+
"default": "\"row\"",
|
|
173
|
+
"description": "Noun used in the selection announcement, e.g. `task`.",
|
|
174
|
+
"from": "arkcn"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
"name": "table",
|
|
178
|
+
"type": "DataTableInstance<TData>",
|
|
179
|
+
"required": false,
|
|
180
|
+
"description": "The table instance, when not read from context.",
|
|
181
|
+
"from": "arkcn"
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"name": "children",
|
|
185
|
+
"type": "ReactNode",
|
|
186
|
+
"required": false,
|
|
187
|
+
"description": "Content rendered inside the part.",
|
|
188
|
+
"from": "@types/react"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"name": "className",
|
|
192
|
+
"type": "string",
|
|
193
|
+
"required": false,
|
|
194
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
195
|
+
"from": "@types/react"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"name": "style",
|
|
199
|
+
"type": "CSSProperties",
|
|
200
|
+
"required": false,
|
|
201
|
+
"description": "Inline styles applied to the rendered element.",
|
|
202
|
+
"from": "@types/react"
|
|
203
|
+
}
|
|
204
|
+
]
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
"name": "DataTableBulkActionsClear",
|
|
208
|
+
"props": [
|
|
209
|
+
{
|
|
210
|
+
"name": "asChild",
|
|
211
|
+
"type": "boolean",
|
|
212
|
+
"required": false,
|
|
213
|
+
"description": "Render the child element instead of the default one, merging props and behaviour onto it.",
|
|
214
|
+
"from": "arkcn"
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
"name": "size",
|
|
218
|
+
"type": "\"default\" | \"xs\" | \"sm\" | \"lg\" | \"icon\" | \"icon-xs\" | \"icon-sm\" | \"icon-lg\" | null",
|
|
219
|
+
"required": false,
|
|
220
|
+
"description": "Size variant; sets a `data-size` attribute.",
|
|
221
|
+
"from": "arkcn"
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
"name": "table",
|
|
225
|
+
"type": "DataTableInstance<TData>",
|
|
226
|
+
"required": false,
|
|
227
|
+
"description": "The table instance, when not read from context.",
|
|
228
|
+
"from": "arkcn"
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
"name": "variant",
|
|
232
|
+
"type": "\"link\" | \"default\" | \"outline\" | \"secondary\" | \"ghost\" | \"destructive\" | null",
|
|
233
|
+
"required": false,
|
|
234
|
+
"description": "Visual variant, styled with `cva`; sets a `data-variant` attribute.",
|
|
235
|
+
"from": "arkcn"
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
"name": "children",
|
|
239
|
+
"type": "ReactNode",
|
|
240
|
+
"required": false,
|
|
241
|
+
"description": "Content rendered inside the part.",
|
|
242
|
+
"from": "@types/react"
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
"name": "className",
|
|
246
|
+
"type": "string",
|
|
247
|
+
"required": false,
|
|
248
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
249
|
+
"from": "@types/react"
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
"name": "style",
|
|
253
|
+
"type": "CSSProperties",
|
|
254
|
+
"required": false,
|
|
255
|
+
"description": "Inline styles applied to the rendered element.",
|
|
256
|
+
"from": "@types/react"
|
|
257
|
+
}
|
|
258
|
+
]
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
"name": "DataTableBulkActionsCount",
|
|
262
|
+
"props": [
|
|
263
|
+
{
|
|
264
|
+
"name": "entityName",
|
|
265
|
+
"type": "string",
|
|
266
|
+
"required": false,
|
|
267
|
+
"default": "\"row\"",
|
|
268
|
+
"description": "Noun used in the selection announcement, e.g. `task`.",
|
|
269
|
+
"from": "arkcn"
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
"name": "table",
|
|
273
|
+
"type": "DataTableInstance<TData>",
|
|
274
|
+
"required": false,
|
|
275
|
+
"description": "The table instance, when not read from context.",
|
|
276
|
+
"from": "arkcn"
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
"name": "children",
|
|
280
|
+
"type": "ReactNode",
|
|
281
|
+
"required": false,
|
|
282
|
+
"description": "Content rendered inside the part.",
|
|
283
|
+
"from": "@types/react"
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
"name": "className",
|
|
287
|
+
"type": "string",
|
|
288
|
+
"required": false,
|
|
289
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
290
|
+
"from": "@types/react"
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
"name": "style",
|
|
294
|
+
"type": "CSSProperties",
|
|
295
|
+
"required": false,
|
|
296
|
+
"description": "Inline styles applied to the rendered element.",
|
|
297
|
+
"from": "@types/react"
|
|
298
|
+
}
|
|
299
|
+
]
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
"name": "DataTableCell",
|
|
303
|
+
"props": [
|
|
304
|
+
{
|
|
305
|
+
"name": "column",
|
|
306
|
+
"type": "string",
|
|
307
|
+
"required": false,
|
|
308
|
+
"description": "Id of the column this part belongs to.",
|
|
309
|
+
"from": "arkcn"
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
"name": "table",
|
|
313
|
+
"type": "DataTableInstance<TData>",
|
|
314
|
+
"required": false,
|
|
315
|
+
"description": "The table instance, when not read from context.",
|
|
316
|
+
"from": "arkcn"
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
"name": "children",
|
|
320
|
+
"type": "ReactNode",
|
|
321
|
+
"required": false,
|
|
322
|
+
"description": "Content rendered inside the part.",
|
|
323
|
+
"from": "@types/react"
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
"name": "className",
|
|
327
|
+
"type": "string",
|
|
328
|
+
"required": false,
|
|
329
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
330
|
+
"from": "@types/react"
|
|
331
|
+
},
|
|
332
|
+
{
|
|
333
|
+
"name": "style",
|
|
334
|
+
"type": "CSSProperties",
|
|
335
|
+
"required": false,
|
|
336
|
+
"description": "Inline styles applied to the rendered element.",
|
|
337
|
+
"from": "@types/react"
|
|
338
|
+
}
|
|
339
|
+
]
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
"name": "DataTableHead",
|
|
343
|
+
"props": [
|
|
344
|
+
{
|
|
345
|
+
"name": "column",
|
|
346
|
+
"type": "string",
|
|
347
|
+
"required": false,
|
|
348
|
+
"description": "Id of the column this part belongs to.",
|
|
349
|
+
"from": "arkcn"
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
"name": "table",
|
|
353
|
+
"type": "DataTableInstance<TData>",
|
|
354
|
+
"required": false,
|
|
355
|
+
"description": "The table instance, when not read from context.",
|
|
356
|
+
"from": "arkcn"
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
"name": "children",
|
|
360
|
+
"type": "ReactNode",
|
|
361
|
+
"required": false,
|
|
362
|
+
"description": "Content rendered inside the part.",
|
|
363
|
+
"from": "@types/react"
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
"name": "className",
|
|
367
|
+
"type": "string",
|
|
368
|
+
"required": false,
|
|
369
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
370
|
+
"from": "@types/react"
|
|
371
|
+
},
|
|
372
|
+
{
|
|
373
|
+
"name": "style",
|
|
374
|
+
"type": "CSSProperties",
|
|
375
|
+
"required": false,
|
|
376
|
+
"description": "Inline styles applied to the rendered element.",
|
|
377
|
+
"from": "@types/react"
|
|
378
|
+
}
|
|
379
|
+
]
|
|
380
|
+
},
|
|
381
|
+
{
|
|
382
|
+
"name": "DataTableContainer",
|
|
383
|
+
"props": [
|
|
384
|
+
{
|
|
385
|
+
"name": "children",
|
|
386
|
+
"type": "ReactNode",
|
|
387
|
+
"required": false,
|
|
388
|
+
"description": "Content rendered inside the part.",
|
|
389
|
+
"from": "@types/react"
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
"name": "className",
|
|
393
|
+
"type": "string",
|
|
394
|
+
"required": false,
|
|
395
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
396
|
+
"from": "@types/react"
|
|
397
|
+
},
|
|
398
|
+
{
|
|
399
|
+
"name": "style",
|
|
400
|
+
"type": "CSSProperties",
|
|
401
|
+
"required": false,
|
|
402
|
+
"description": "Inline styles applied to the rendered element.",
|
|
403
|
+
"from": "@types/react"
|
|
404
|
+
}
|
|
405
|
+
]
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
"name": "DataTableEmpty",
|
|
409
|
+
"props": [
|
|
410
|
+
{
|
|
411
|
+
"name": "table",
|
|
412
|
+
"type": "DataTableInstance<TData>",
|
|
413
|
+
"required": false,
|
|
414
|
+
"description": "The table instance, when not read from context.",
|
|
415
|
+
"from": "arkcn"
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
"name": "children",
|
|
419
|
+
"type": "ReactNode",
|
|
420
|
+
"required": false,
|
|
421
|
+
"description": "Content rendered inside the part.",
|
|
422
|
+
"from": "@types/react"
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
"name": "className",
|
|
426
|
+
"type": "string",
|
|
427
|
+
"required": false,
|
|
428
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
429
|
+
"from": "@types/react"
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
"name": "style",
|
|
433
|
+
"type": "CSSProperties",
|
|
434
|
+
"required": false,
|
|
435
|
+
"description": "Inline styles applied to the rendered element.",
|
|
436
|
+
"from": "@types/react"
|
|
437
|
+
}
|
|
438
|
+
]
|
|
439
|
+
},
|
|
440
|
+
{
|
|
441
|
+
"name": "DataTableFacetedFilter",
|
|
442
|
+
"props": [
|
|
443
|
+
{
|
|
444
|
+
"name": "options",
|
|
445
|
+
"type": "FacetOption[]",
|
|
446
|
+
"required": true,
|
|
447
|
+
"description": "Facet options as `{ value, label, icon? }`.",
|
|
448
|
+
"from": "arkcn"
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
"name": "column",
|
|
452
|
+
"type": "DataTableColumn<TData, TValue>",
|
|
453
|
+
"required": false,
|
|
454
|
+
"description": "Id of the column this part belongs to.",
|
|
455
|
+
"from": "arkcn"
|
|
456
|
+
},
|
|
457
|
+
{
|
|
458
|
+
"name": "columnId",
|
|
459
|
+
"type": "string",
|
|
460
|
+
"required": false,
|
|
461
|
+
"description": "Id of the column this filter applies to.",
|
|
462
|
+
"from": "arkcn"
|
|
463
|
+
},
|
|
464
|
+
{
|
|
465
|
+
"name": "table",
|
|
466
|
+
"type": "DataTableInstance<TData>",
|
|
467
|
+
"required": false,
|
|
468
|
+
"description": "The table instance, when not read from context.",
|
|
469
|
+
"from": "arkcn"
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
"name": "title",
|
|
473
|
+
"type": "string",
|
|
474
|
+
"required": false,
|
|
475
|
+
"description": "Title text.",
|
|
476
|
+
"from": "arkcn"
|
|
477
|
+
}
|
|
478
|
+
]
|
|
479
|
+
},
|
|
480
|
+
{
|
|
481
|
+
"name": "DataTableHeader",
|
|
482
|
+
"props": [
|
|
483
|
+
{
|
|
484
|
+
"name": "children",
|
|
485
|
+
"type": "ReactNode",
|
|
486
|
+
"required": false,
|
|
487
|
+
"description": "Content rendered inside the part.",
|
|
488
|
+
"from": "@types/react"
|
|
489
|
+
},
|
|
490
|
+
{
|
|
491
|
+
"name": "className",
|
|
492
|
+
"type": "string",
|
|
493
|
+
"required": false,
|
|
494
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
495
|
+
"from": "@types/react"
|
|
496
|
+
},
|
|
497
|
+
{
|
|
498
|
+
"name": "style",
|
|
499
|
+
"type": "CSSProperties",
|
|
500
|
+
"required": false,
|
|
501
|
+
"description": "Inline styles applied to the rendered element.",
|
|
502
|
+
"from": "@types/react"
|
|
503
|
+
}
|
|
504
|
+
]
|
|
505
|
+
},
|
|
506
|
+
{
|
|
507
|
+
"name": "DataTablePageInfo",
|
|
508
|
+
"props": [
|
|
509
|
+
{
|
|
510
|
+
"name": "table",
|
|
511
|
+
"type": "DataTableInstance<TData>",
|
|
512
|
+
"required": false,
|
|
513
|
+
"description": "The table instance, when not read from context.",
|
|
514
|
+
"from": "arkcn"
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
"name": "children",
|
|
518
|
+
"type": "ReactNode",
|
|
519
|
+
"required": false,
|
|
520
|
+
"description": "Content rendered inside the part.",
|
|
521
|
+
"from": "@types/react"
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
"name": "className",
|
|
525
|
+
"type": "string",
|
|
526
|
+
"required": false,
|
|
527
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
528
|
+
"from": "@types/react"
|
|
529
|
+
},
|
|
530
|
+
{
|
|
531
|
+
"name": "style",
|
|
532
|
+
"type": "CSSProperties",
|
|
533
|
+
"required": false,
|
|
534
|
+
"description": "Inline styles applied to the rendered element.",
|
|
535
|
+
"from": "@types/react"
|
|
536
|
+
}
|
|
537
|
+
]
|
|
538
|
+
},
|
|
539
|
+
{
|
|
540
|
+
"name": "DataTablePageNav",
|
|
541
|
+
"props": [
|
|
542
|
+
{
|
|
543
|
+
"name": "showEdges",
|
|
544
|
+
"type": "boolean",
|
|
545
|
+
"required": false,
|
|
546
|
+
"default": "true",
|
|
547
|
+
"description": "Show the first and last page buttons.",
|
|
548
|
+
"from": "arkcn"
|
|
549
|
+
},
|
|
550
|
+
{
|
|
551
|
+
"name": "table",
|
|
552
|
+
"type": "DataTableInstance<TData>",
|
|
553
|
+
"required": false,
|
|
554
|
+
"description": "The table instance, when not read from context.",
|
|
555
|
+
"from": "arkcn"
|
|
556
|
+
},
|
|
557
|
+
{
|
|
558
|
+
"name": "children",
|
|
559
|
+
"type": "ReactNode",
|
|
560
|
+
"required": false,
|
|
561
|
+
"description": "Content rendered inside the part.",
|
|
562
|
+
"from": "@types/react"
|
|
563
|
+
},
|
|
564
|
+
{
|
|
565
|
+
"name": "className",
|
|
566
|
+
"type": "string",
|
|
567
|
+
"required": false,
|
|
568
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
569
|
+
"from": "@types/react"
|
|
570
|
+
},
|
|
571
|
+
{
|
|
572
|
+
"name": "style",
|
|
573
|
+
"type": "CSSProperties",
|
|
574
|
+
"required": false,
|
|
575
|
+
"description": "Inline styles applied to the rendered element.",
|
|
576
|
+
"from": "@types/react"
|
|
577
|
+
}
|
|
578
|
+
]
|
|
579
|
+
},
|
|
580
|
+
{
|
|
581
|
+
"name": "DataTablePageSize",
|
|
582
|
+
"props": [
|
|
583
|
+
{
|
|
584
|
+
"name": "children",
|
|
585
|
+
"type": "ReactNode",
|
|
586
|
+
"required": false,
|
|
587
|
+
"description": "Content rendered inside the part.",
|
|
588
|
+
"from": "arkcn"
|
|
589
|
+
},
|
|
590
|
+
{
|
|
591
|
+
"name": "className",
|
|
592
|
+
"type": "string",
|
|
593
|
+
"required": false,
|
|
594
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
595
|
+
"from": "arkcn"
|
|
596
|
+
},
|
|
597
|
+
{
|
|
598
|
+
"name": "pageSizes",
|
|
599
|
+
"type": "number[]",
|
|
600
|
+
"required": false,
|
|
601
|
+
"default": "defaultPageSizes",
|
|
602
|
+
"description": "Choices offered in the page size select.",
|
|
603
|
+
"from": "arkcn"
|
|
604
|
+
},
|
|
605
|
+
{
|
|
606
|
+
"name": "table",
|
|
607
|
+
"type": "DataTableInstance<TData>",
|
|
608
|
+
"required": false,
|
|
609
|
+
"description": "The table instance, when not read from context.",
|
|
610
|
+
"from": "arkcn"
|
|
611
|
+
}
|
|
612
|
+
]
|
|
613
|
+
},
|
|
614
|
+
{
|
|
615
|
+
"name": "DataTablePagination",
|
|
616
|
+
"props": [
|
|
617
|
+
{
|
|
618
|
+
"name": "children",
|
|
619
|
+
"type": "ReactNode",
|
|
620
|
+
"required": false,
|
|
621
|
+
"description": "Content rendered inside the part.",
|
|
622
|
+
"from": "@types/react"
|
|
623
|
+
},
|
|
624
|
+
{
|
|
625
|
+
"name": "className",
|
|
626
|
+
"type": "string",
|
|
627
|
+
"required": false,
|
|
628
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
629
|
+
"from": "@types/react"
|
|
630
|
+
},
|
|
631
|
+
{
|
|
632
|
+
"name": "style",
|
|
633
|
+
"type": "CSSProperties",
|
|
634
|
+
"required": false,
|
|
635
|
+
"description": "Inline styles applied to the rendered element.",
|
|
636
|
+
"from": "@types/react"
|
|
637
|
+
}
|
|
638
|
+
]
|
|
639
|
+
},
|
|
640
|
+
{
|
|
641
|
+
"name": "DataTableResetFilters",
|
|
642
|
+
"props": [
|
|
643
|
+
{
|
|
644
|
+
"name": "asChild",
|
|
645
|
+
"type": "boolean",
|
|
646
|
+
"required": false,
|
|
647
|
+
"description": "Render the child element instead of the default one, merging props and behaviour onto it.",
|
|
648
|
+
"from": "arkcn"
|
|
649
|
+
},
|
|
650
|
+
{
|
|
651
|
+
"name": "size",
|
|
652
|
+
"type": "\"default\" | \"xs\" | \"sm\" | \"lg\" | \"icon\" | \"icon-xs\" | \"icon-sm\" | \"icon-lg\" | null",
|
|
653
|
+
"required": false,
|
|
654
|
+
"description": "Size variant; sets a `data-size` attribute.",
|
|
655
|
+
"from": "arkcn"
|
|
656
|
+
},
|
|
657
|
+
{
|
|
658
|
+
"name": "table",
|
|
659
|
+
"type": "DataTableInstance<TData>",
|
|
660
|
+
"required": false,
|
|
661
|
+
"description": "The table instance, when not read from context.",
|
|
662
|
+
"from": "arkcn"
|
|
663
|
+
},
|
|
664
|
+
{
|
|
665
|
+
"name": "variant",
|
|
666
|
+
"type": "\"link\" | \"default\" | \"outline\" | \"secondary\" | \"ghost\" | \"destructive\" | null",
|
|
667
|
+
"required": false,
|
|
668
|
+
"description": "Visual variant, styled with `cva`; sets a `data-variant` attribute.",
|
|
669
|
+
"from": "arkcn"
|
|
670
|
+
},
|
|
671
|
+
{
|
|
672
|
+
"name": "children",
|
|
673
|
+
"type": "ReactNode",
|
|
674
|
+
"required": false,
|
|
675
|
+
"description": "Content rendered inside the part.",
|
|
676
|
+
"from": "@types/react"
|
|
677
|
+
},
|
|
678
|
+
{
|
|
679
|
+
"name": "className",
|
|
680
|
+
"type": "string",
|
|
681
|
+
"required": false,
|
|
682
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
683
|
+
"from": "@types/react"
|
|
684
|
+
},
|
|
685
|
+
{
|
|
686
|
+
"name": "style",
|
|
687
|
+
"type": "CSSProperties",
|
|
688
|
+
"required": false,
|
|
689
|
+
"description": "Inline styles applied to the rendered element.",
|
|
690
|
+
"from": "@types/react"
|
|
691
|
+
}
|
|
692
|
+
]
|
|
693
|
+
},
|
|
694
|
+
{
|
|
695
|
+
"name": "DataTableRow",
|
|
696
|
+
"props": [
|
|
697
|
+
{
|
|
698
|
+
"name": "row",
|
|
699
|
+
"type": "DataTableRow<TData>",
|
|
700
|
+
"required": true,
|
|
701
|
+
"description": "The row this part belongs to.",
|
|
702
|
+
"from": "arkcn"
|
|
703
|
+
},
|
|
704
|
+
{
|
|
705
|
+
"name": "children",
|
|
706
|
+
"type": "ReactNode",
|
|
707
|
+
"required": false,
|
|
708
|
+
"description": "Content rendered inside the part.",
|
|
709
|
+
"from": "@types/react"
|
|
710
|
+
},
|
|
711
|
+
{
|
|
712
|
+
"name": "className",
|
|
713
|
+
"type": "string",
|
|
714
|
+
"required": false,
|
|
715
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
716
|
+
"from": "@types/react"
|
|
717
|
+
},
|
|
718
|
+
{
|
|
719
|
+
"name": "style",
|
|
720
|
+
"type": "CSSProperties",
|
|
721
|
+
"required": false,
|
|
722
|
+
"description": "Inline styles applied to the rendered element.",
|
|
723
|
+
"from": "@types/react"
|
|
724
|
+
}
|
|
725
|
+
]
|
|
726
|
+
},
|
|
727
|
+
{
|
|
728
|
+
"name": "DataTableRowActions",
|
|
729
|
+
"props": [
|
|
730
|
+
{
|
|
731
|
+
"name": "className",
|
|
732
|
+
"type": "string",
|
|
733
|
+
"required": false,
|
|
734
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
735
|
+
"from": "arkcn"
|
|
736
|
+
},
|
|
737
|
+
{
|
|
738
|
+
"name": "trigger",
|
|
739
|
+
"type": "ReactElement<unknown, string | JSXElementConstructor<any>>",
|
|
740
|
+
"required": false,
|
|
741
|
+
"description": "Replace the default ellipsis button with your own element.",
|
|
742
|
+
"from": "arkcn"
|
|
743
|
+
},
|
|
744
|
+
{
|
|
745
|
+
"name": "anchorPoint",
|
|
746
|
+
"type": "Point | null",
|
|
747
|
+
"required": false,
|
|
748
|
+
"description": "The positioning point for the menu. Can be set by the context menu trigger or the button trigger.",
|
|
749
|
+
"from": "@zag-js/menu"
|
|
750
|
+
},
|
|
751
|
+
{
|
|
752
|
+
"name": "aria-label",
|
|
753
|
+
"type": "string",
|
|
754
|
+
"required": false,
|
|
755
|
+
"description": "The accessibility label for the menu",
|
|
756
|
+
"from": "@zag-js/menu"
|
|
757
|
+
},
|
|
758
|
+
{
|
|
759
|
+
"name": "children",
|
|
760
|
+
"type": "ReactNode",
|
|
761
|
+
"required": false,
|
|
762
|
+
"description": "Content rendered inside the part.",
|
|
763
|
+
"from": "@ark-ui/react"
|
|
764
|
+
},
|
|
765
|
+
{
|
|
766
|
+
"name": "closeOnSelect",
|
|
767
|
+
"type": "boolean",
|
|
768
|
+
"required": false,
|
|
769
|
+
"default": "true",
|
|
770
|
+
"description": "Whether to close the menu when an option is selected",
|
|
771
|
+
"from": "@zag-js/menu"
|
|
772
|
+
},
|
|
773
|
+
{
|
|
774
|
+
"name": "composite",
|
|
775
|
+
"type": "boolean",
|
|
776
|
+
"required": false,
|
|
777
|
+
"default": "true",
|
|
778
|
+
"description": "Whether the menu is a composed with other composite widgets like a combobox or tabs",
|
|
779
|
+
"from": "@zag-js/menu"
|
|
780
|
+
},
|
|
781
|
+
{
|
|
782
|
+
"name": "defaultHighlightedValue",
|
|
783
|
+
"type": "string | null",
|
|
784
|
+
"required": false,
|
|
785
|
+
"description": "The initial highlighted value of the menu item when rendered.\nUse when you don't need to control the highlighted value of the menu item.",
|
|
786
|
+
"from": "@zag-js/menu"
|
|
787
|
+
},
|
|
788
|
+
{
|
|
789
|
+
"name": "defaultOpen",
|
|
790
|
+
"type": "boolean",
|
|
791
|
+
"required": false,
|
|
792
|
+
"description": "The initial open state of the menu when rendered.\nUse when you don't need to control the open state of the menu.",
|
|
793
|
+
"from": "@zag-js/menu"
|
|
794
|
+
},
|
|
795
|
+
{
|
|
796
|
+
"name": "defaultTriggerValue",
|
|
797
|
+
"type": "string | null",
|
|
798
|
+
"required": false,
|
|
799
|
+
"description": "The initial trigger value when rendered.\nUse when you don't need to control the trigger value.",
|
|
800
|
+
"from": "@zag-js/menu"
|
|
801
|
+
},
|
|
802
|
+
{
|
|
803
|
+
"name": "hideMode",
|
|
804
|
+
"type": "HideMode",
|
|
805
|
+
"required": false,
|
|
806
|
+
"default": "'display-none'",
|
|
807
|
+
"description": "How to hide content when mounted but not present.\n- `'display-none'`: HTML `hidden` attribute. Effects stay alive.\n- `'activity'`: React 19 `<Activity mode=\"hidden\">`. Effects pause. Requires React 19+.",
|
|
808
|
+
"from": "@ark-ui/react"
|
|
809
|
+
},
|
|
810
|
+
{
|
|
811
|
+
"name": "highlightedValue",
|
|
812
|
+
"type": "string | null",
|
|
813
|
+
"required": false,
|
|
814
|
+
"description": "The controlled highlighted value of the menu item.",
|
|
815
|
+
"from": "@zag-js/menu"
|
|
816
|
+
},
|
|
817
|
+
{
|
|
818
|
+
"name": "id",
|
|
819
|
+
"type": "string",
|
|
820
|
+
"required": false,
|
|
821
|
+
"description": "The unique identifier of the machine.",
|
|
822
|
+
"from": "@zag-js/types"
|
|
823
|
+
},
|
|
824
|
+
{
|
|
825
|
+
"name": "ids",
|
|
826
|
+
"type": "ElementIds",
|
|
827
|
+
"required": false,
|
|
828
|
+
"description": "The ids of the elements in the menu. Useful for composition.",
|
|
829
|
+
"from": "@zag-js/menu"
|
|
830
|
+
},
|
|
831
|
+
{
|
|
832
|
+
"name": "immediate",
|
|
833
|
+
"type": "boolean",
|
|
834
|
+
"required": false,
|
|
835
|
+
"description": "Whether to synchronize the present change immediately or defer it to the next frame",
|
|
836
|
+
"from": "@zag-js/presence"
|
|
837
|
+
},
|
|
838
|
+
{
|
|
839
|
+
"name": "lazyMount",
|
|
840
|
+
"type": "boolean",
|
|
841
|
+
"required": false,
|
|
842
|
+
"default": "false",
|
|
843
|
+
"description": "Whether to enable lazy mounting",
|
|
844
|
+
"from": "@ark-ui/react"
|
|
845
|
+
},
|
|
846
|
+
{
|
|
847
|
+
"name": "loopFocus",
|
|
848
|
+
"type": "boolean",
|
|
849
|
+
"required": false,
|
|
850
|
+
"default": "false",
|
|
851
|
+
"description": "Whether to loop the keyboard navigation.",
|
|
852
|
+
"from": "@zag-js/menu"
|
|
853
|
+
},
|
|
854
|
+
{
|
|
855
|
+
"name": "navigate",
|
|
856
|
+
"type": "((details: NavigateDetails) => void) | null",
|
|
857
|
+
"required": false,
|
|
858
|
+
"description": "Function to navigate to the selected item if it's an anchor element",
|
|
859
|
+
"from": "@zag-js/menu"
|
|
860
|
+
},
|
|
861
|
+
{
|
|
862
|
+
"name": "onEnterComplete",
|
|
863
|
+
"type": "VoidFunction",
|
|
864
|
+
"required": false,
|
|
865
|
+
"description": "Function called when the animation ends in the open state",
|
|
866
|
+
"from": "@zag-js/presence"
|
|
867
|
+
},
|
|
868
|
+
{
|
|
869
|
+
"name": "onEscapeKeyDown",
|
|
870
|
+
"type": "((event: KeyboardEvent) => void)",
|
|
871
|
+
"required": false,
|
|
872
|
+
"description": "Function called when the escape key is pressed",
|
|
873
|
+
"from": "@zag-js/dismissable"
|
|
874
|
+
},
|
|
875
|
+
{
|
|
876
|
+
"name": "onExitComplete",
|
|
877
|
+
"type": "VoidFunction",
|
|
878
|
+
"required": false,
|
|
879
|
+
"description": "Function called when the animation ends in the closed state",
|
|
880
|
+
"from": "@zag-js/presence"
|
|
881
|
+
},
|
|
882
|
+
{
|
|
883
|
+
"name": "onFocusOutside",
|
|
884
|
+
"type": "((event: FocusOutsideEvent) => void)",
|
|
885
|
+
"required": false,
|
|
886
|
+
"description": "Function called when the focus is moved outside the component",
|
|
887
|
+
"from": "@zag-js/interact-outside"
|
|
888
|
+
},
|
|
889
|
+
{
|
|
890
|
+
"name": "onHighlightChange",
|
|
891
|
+
"type": "((details: HighlightChangeDetails) => void)",
|
|
892
|
+
"required": false,
|
|
893
|
+
"description": "Function called when the highlighted menu item changes.",
|
|
894
|
+
"from": "@zag-js/menu"
|
|
895
|
+
},
|
|
896
|
+
{
|
|
897
|
+
"name": "onInteractOutside",
|
|
898
|
+
"type": "((event: InteractOutsideEvent) => void)",
|
|
899
|
+
"required": false,
|
|
900
|
+
"description": "Function called when an interaction happens outside the component",
|
|
901
|
+
"from": "@zag-js/interact-outside"
|
|
902
|
+
},
|
|
903
|
+
{
|
|
904
|
+
"name": "onOpenChange",
|
|
905
|
+
"type": "((details: OpenChangeDetails) => void)",
|
|
906
|
+
"required": false,
|
|
907
|
+
"description": "Function called when the menu opens or closes",
|
|
908
|
+
"from": "@zag-js/menu"
|
|
909
|
+
},
|
|
910
|
+
{
|
|
911
|
+
"name": "onPointerDownOutside",
|
|
912
|
+
"type": "((event: PointerDownOutsideEvent) => void)",
|
|
913
|
+
"required": false,
|
|
914
|
+
"description": "Function called when the pointer is pressed down outside the component",
|
|
915
|
+
"from": "@zag-js/interact-outside"
|
|
916
|
+
},
|
|
917
|
+
{
|
|
918
|
+
"name": "onRequestDismiss",
|
|
919
|
+
"type": "((event: LayerDismissEvent) => void)",
|
|
920
|
+
"required": false,
|
|
921
|
+
"description": "Function called when this layer is closed due to a parent layer being closed",
|
|
922
|
+
"from": "@zag-js/dismissable"
|
|
923
|
+
},
|
|
924
|
+
{
|
|
925
|
+
"name": "onSelect",
|
|
926
|
+
"type": "((details: SelectionDetails) => void)",
|
|
927
|
+
"required": false,
|
|
928
|
+
"description": "Function called when a menu item is selected.",
|
|
929
|
+
"from": "@zag-js/menu"
|
|
930
|
+
},
|
|
931
|
+
{
|
|
932
|
+
"name": "onTriggerValueChange",
|
|
933
|
+
"type": "((details: TriggerValueChangeDetails) => void)",
|
|
934
|
+
"required": false,
|
|
935
|
+
"description": "Function called when the trigger value changes.",
|
|
936
|
+
"from": "@zag-js/menu"
|
|
937
|
+
},
|
|
938
|
+
{
|
|
939
|
+
"name": "open",
|
|
940
|
+
"type": "boolean",
|
|
941
|
+
"required": false,
|
|
942
|
+
"description": "The controlled open state of the menu",
|
|
943
|
+
"from": "@zag-js/menu"
|
|
944
|
+
},
|
|
945
|
+
{
|
|
946
|
+
"name": "positioning",
|
|
947
|
+
"type": "PositioningOptions",
|
|
948
|
+
"required": false,
|
|
949
|
+
"description": "The options used to dynamically position the menu",
|
|
950
|
+
"from": "@zag-js/menu"
|
|
951
|
+
},
|
|
952
|
+
{
|
|
953
|
+
"name": "present",
|
|
954
|
+
"type": "boolean",
|
|
955
|
+
"required": false,
|
|
956
|
+
"description": "Whether the node is present (controlled by the user)",
|
|
957
|
+
"from": "@zag-js/presence"
|
|
958
|
+
},
|
|
959
|
+
{
|
|
960
|
+
"name": "skipAnimationOnMount",
|
|
961
|
+
"type": "boolean",
|
|
962
|
+
"required": false,
|
|
963
|
+
"default": "false",
|
|
964
|
+
"description": "Whether to allow the initial presence animation.",
|
|
965
|
+
"from": "@ark-ui/react"
|
|
966
|
+
},
|
|
967
|
+
{
|
|
968
|
+
"name": "triggerValue",
|
|
969
|
+
"type": "string | null",
|
|
970
|
+
"required": false,
|
|
971
|
+
"description": "The controlled trigger value",
|
|
972
|
+
"from": "@zag-js/menu"
|
|
973
|
+
},
|
|
974
|
+
{
|
|
975
|
+
"name": "typeahead",
|
|
976
|
+
"type": "boolean",
|
|
977
|
+
"required": false,
|
|
978
|
+
"default": "true",
|
|
979
|
+
"description": "Whether the pressing printable characters should trigger typeahead navigation",
|
|
980
|
+
"from": "@zag-js/menu"
|
|
981
|
+
},
|
|
982
|
+
{
|
|
983
|
+
"name": "unmountOnExit",
|
|
984
|
+
"type": "boolean",
|
|
985
|
+
"required": false,
|
|
986
|
+
"default": "false",
|
|
987
|
+
"description": "Whether to unmount on exit.",
|
|
988
|
+
"from": "@ark-ui/react"
|
|
989
|
+
}
|
|
990
|
+
]
|
|
991
|
+
},
|
|
992
|
+
{
|
|
993
|
+
"name": "DataTableSearch",
|
|
994
|
+
"props": [
|
|
995
|
+
{
|
|
996
|
+
"name": "columnId",
|
|
997
|
+
"type": "string",
|
|
998
|
+
"required": false,
|
|
999
|
+
"description": "Filter a single column instead of the global filter.",
|
|
1000
|
+
"from": "arkcn"
|
|
1001
|
+
},
|
|
1002
|
+
{
|
|
1003
|
+
"name": "table",
|
|
1004
|
+
"type": "DataTableInstance<TData>",
|
|
1005
|
+
"required": false,
|
|
1006
|
+
"description": "The table instance, when not read from context.",
|
|
1007
|
+
"from": "arkcn"
|
|
1008
|
+
},
|
|
1009
|
+
{
|
|
1010
|
+
"name": "children",
|
|
1011
|
+
"type": "ReactNode",
|
|
1012
|
+
"required": false,
|
|
1013
|
+
"description": "Content rendered inside the part.",
|
|
1014
|
+
"from": "@types/react"
|
|
1015
|
+
},
|
|
1016
|
+
{
|
|
1017
|
+
"name": "className",
|
|
1018
|
+
"type": "string",
|
|
1019
|
+
"required": false,
|
|
1020
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
1021
|
+
"from": "@types/react"
|
|
1022
|
+
},
|
|
1023
|
+
{
|
|
1024
|
+
"name": "style",
|
|
1025
|
+
"type": "CSSProperties",
|
|
1026
|
+
"required": false,
|
|
1027
|
+
"description": "Inline styles applied to the rendered element.",
|
|
1028
|
+
"from": "@types/react"
|
|
1029
|
+
}
|
|
1030
|
+
]
|
|
1031
|
+
},
|
|
1032
|
+
{
|
|
1033
|
+
"name": "DataTableSelectAll",
|
|
1034
|
+
"props": [
|
|
1035
|
+
{
|
|
1036
|
+
"name": "table",
|
|
1037
|
+
"type": "DataTableInstance<TData>",
|
|
1038
|
+
"required": true,
|
|
1039
|
+
"description": "The table instance, when not read from context.",
|
|
1040
|
+
"from": "arkcn"
|
|
1041
|
+
},
|
|
1042
|
+
{
|
|
1043
|
+
"name": "asChild",
|
|
1044
|
+
"type": "boolean",
|
|
1045
|
+
"required": false,
|
|
1046
|
+
"description": "Use the provided child element as the default rendered element, combining their props and behavior.",
|
|
1047
|
+
"from": "@ark-ui/react"
|
|
1048
|
+
},
|
|
1049
|
+
{
|
|
1050
|
+
"name": "children",
|
|
1051
|
+
"type": "ReactNode",
|
|
1052
|
+
"required": false,
|
|
1053
|
+
"description": "Content rendered inside the part.",
|
|
1054
|
+
"from": "@types/react"
|
|
1055
|
+
},
|
|
1056
|
+
{
|
|
1057
|
+
"name": "className",
|
|
1058
|
+
"type": "string",
|
|
1059
|
+
"required": false,
|
|
1060
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
1061
|
+
"from": "@types/react"
|
|
1062
|
+
},
|
|
1063
|
+
{
|
|
1064
|
+
"name": "defaultChecked",
|
|
1065
|
+
"type": "CheckedState",
|
|
1066
|
+
"required": false,
|
|
1067
|
+
"description": "The initial checked state of the checkbox when rendered.\nUse when you don't need to control the checked state of the checkbox.",
|
|
1068
|
+
"from": "@zag-js/checkbox"
|
|
1069
|
+
},
|
|
1070
|
+
{
|
|
1071
|
+
"name": "disabled",
|
|
1072
|
+
"type": "boolean",
|
|
1073
|
+
"required": false,
|
|
1074
|
+
"description": "Whether the checkbox is disabled",
|
|
1075
|
+
"from": "@zag-js/checkbox"
|
|
1076
|
+
},
|
|
1077
|
+
{
|
|
1078
|
+
"name": "form",
|
|
1079
|
+
"type": "string",
|
|
1080
|
+
"required": false,
|
|
1081
|
+
"description": "The id of the form that the checkbox belongs to.",
|
|
1082
|
+
"from": "@zag-js/checkbox"
|
|
1083
|
+
},
|
|
1084
|
+
{
|
|
1085
|
+
"name": "ids",
|
|
1086
|
+
"type": "ElementIds",
|
|
1087
|
+
"required": false,
|
|
1088
|
+
"description": "The ids of the elements in the checkbox. Useful for composition.",
|
|
1089
|
+
"from": "@zag-js/checkbox"
|
|
1090
|
+
},
|
|
1091
|
+
{
|
|
1092
|
+
"name": "invalid",
|
|
1093
|
+
"type": "boolean",
|
|
1094
|
+
"required": false,
|
|
1095
|
+
"description": "Whether the checkbox is invalid",
|
|
1096
|
+
"from": "@zag-js/checkbox"
|
|
1097
|
+
},
|
|
1098
|
+
{
|
|
1099
|
+
"name": "name",
|
|
1100
|
+
"type": "string",
|
|
1101
|
+
"required": false,
|
|
1102
|
+
"description": "The name of the input field in a checkbox.\nUseful for form submission.",
|
|
1103
|
+
"from": "@zag-js/checkbox"
|
|
1104
|
+
},
|
|
1105
|
+
{
|
|
1106
|
+
"name": "readOnly",
|
|
1107
|
+
"type": "boolean",
|
|
1108
|
+
"required": false,
|
|
1109
|
+
"description": "Whether the checkbox is read-only",
|
|
1110
|
+
"from": "@zag-js/checkbox"
|
|
1111
|
+
},
|
|
1112
|
+
{
|
|
1113
|
+
"name": "required",
|
|
1114
|
+
"type": "boolean",
|
|
1115
|
+
"required": false,
|
|
1116
|
+
"description": "Whether the checkbox is required",
|
|
1117
|
+
"from": "@zag-js/checkbox"
|
|
1118
|
+
},
|
|
1119
|
+
{
|
|
1120
|
+
"name": "style",
|
|
1121
|
+
"type": "CSSProperties",
|
|
1122
|
+
"required": false,
|
|
1123
|
+
"description": "Inline styles applied to the rendered element.",
|
|
1124
|
+
"from": "@types/react"
|
|
1125
|
+
},
|
|
1126
|
+
{
|
|
1127
|
+
"name": "value",
|
|
1128
|
+
"type": "string",
|
|
1129
|
+
"required": false,
|
|
1130
|
+
"default": "\"on\"",
|
|
1131
|
+
"description": "The value of checkbox input. Useful for form submission.",
|
|
1132
|
+
"from": "@zag-js/checkbox"
|
|
1133
|
+
}
|
|
1134
|
+
]
|
|
1135
|
+
},
|
|
1136
|
+
{
|
|
1137
|
+
"name": "DataTableSelectRow",
|
|
1138
|
+
"props": [
|
|
1139
|
+
{
|
|
1140
|
+
"name": "row",
|
|
1141
|
+
"type": "DataTableRow<TData>",
|
|
1142
|
+
"required": true,
|
|
1143
|
+
"description": "The row this part belongs to.",
|
|
1144
|
+
"from": "arkcn"
|
|
1145
|
+
},
|
|
1146
|
+
{
|
|
1147
|
+
"name": "asChild",
|
|
1148
|
+
"type": "boolean",
|
|
1149
|
+
"required": false,
|
|
1150
|
+
"description": "Use the provided child element as the default rendered element, combining their props and behavior.",
|
|
1151
|
+
"from": "@ark-ui/react"
|
|
1152
|
+
},
|
|
1153
|
+
{
|
|
1154
|
+
"name": "children",
|
|
1155
|
+
"type": "ReactNode",
|
|
1156
|
+
"required": false,
|
|
1157
|
+
"description": "Content rendered inside the part.",
|
|
1158
|
+
"from": "@types/react"
|
|
1159
|
+
},
|
|
1160
|
+
{
|
|
1161
|
+
"name": "className",
|
|
1162
|
+
"type": "string",
|
|
1163
|
+
"required": false,
|
|
1164
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
1165
|
+
"from": "@types/react"
|
|
1166
|
+
},
|
|
1167
|
+
{
|
|
1168
|
+
"name": "defaultChecked",
|
|
1169
|
+
"type": "CheckedState",
|
|
1170
|
+
"required": false,
|
|
1171
|
+
"description": "The initial checked state of the checkbox when rendered.\nUse when you don't need to control the checked state of the checkbox.",
|
|
1172
|
+
"from": "@zag-js/checkbox"
|
|
1173
|
+
},
|
|
1174
|
+
{
|
|
1175
|
+
"name": "disabled",
|
|
1176
|
+
"type": "boolean",
|
|
1177
|
+
"required": false,
|
|
1178
|
+
"description": "Whether the checkbox is disabled",
|
|
1179
|
+
"from": "@zag-js/checkbox"
|
|
1180
|
+
},
|
|
1181
|
+
{
|
|
1182
|
+
"name": "form",
|
|
1183
|
+
"type": "string",
|
|
1184
|
+
"required": false,
|
|
1185
|
+
"description": "The id of the form that the checkbox belongs to.",
|
|
1186
|
+
"from": "@zag-js/checkbox"
|
|
1187
|
+
},
|
|
1188
|
+
{
|
|
1189
|
+
"name": "ids",
|
|
1190
|
+
"type": "ElementIds",
|
|
1191
|
+
"required": false,
|
|
1192
|
+
"description": "The ids of the elements in the checkbox. Useful for composition.",
|
|
1193
|
+
"from": "@zag-js/checkbox"
|
|
1194
|
+
},
|
|
1195
|
+
{
|
|
1196
|
+
"name": "invalid",
|
|
1197
|
+
"type": "boolean",
|
|
1198
|
+
"required": false,
|
|
1199
|
+
"description": "Whether the checkbox is invalid",
|
|
1200
|
+
"from": "@zag-js/checkbox"
|
|
1201
|
+
},
|
|
1202
|
+
{
|
|
1203
|
+
"name": "name",
|
|
1204
|
+
"type": "string",
|
|
1205
|
+
"required": false,
|
|
1206
|
+
"description": "The name of the input field in a checkbox.\nUseful for form submission.",
|
|
1207
|
+
"from": "@zag-js/checkbox"
|
|
1208
|
+
},
|
|
1209
|
+
{
|
|
1210
|
+
"name": "readOnly",
|
|
1211
|
+
"type": "boolean",
|
|
1212
|
+
"required": false,
|
|
1213
|
+
"description": "Whether the checkbox is read-only",
|
|
1214
|
+
"from": "@zag-js/checkbox"
|
|
1215
|
+
},
|
|
1216
|
+
{
|
|
1217
|
+
"name": "required",
|
|
1218
|
+
"type": "boolean",
|
|
1219
|
+
"required": false,
|
|
1220
|
+
"description": "Whether the checkbox is required",
|
|
1221
|
+
"from": "@zag-js/checkbox"
|
|
1222
|
+
},
|
|
1223
|
+
{
|
|
1224
|
+
"name": "style",
|
|
1225
|
+
"type": "CSSProperties",
|
|
1226
|
+
"required": false,
|
|
1227
|
+
"description": "Inline styles applied to the rendered element.",
|
|
1228
|
+
"from": "@types/react"
|
|
1229
|
+
},
|
|
1230
|
+
{
|
|
1231
|
+
"name": "value",
|
|
1232
|
+
"type": "string",
|
|
1233
|
+
"required": false,
|
|
1234
|
+
"default": "\"on\"",
|
|
1235
|
+
"description": "The value of checkbox input. Useful for form submission.",
|
|
1236
|
+
"from": "@zag-js/checkbox"
|
|
1237
|
+
}
|
|
1238
|
+
]
|
|
1239
|
+
},
|
|
1240
|
+
{
|
|
1241
|
+
"name": "DataTableTable",
|
|
1242
|
+
"props": [
|
|
1243
|
+
{
|
|
1244
|
+
"name": "children",
|
|
1245
|
+
"type": "ReactNode",
|
|
1246
|
+
"required": false,
|
|
1247
|
+
"description": "Content rendered inside the part.",
|
|
1248
|
+
"from": "@types/react"
|
|
1249
|
+
},
|
|
1250
|
+
{
|
|
1251
|
+
"name": "className",
|
|
1252
|
+
"type": "string",
|
|
1253
|
+
"required": false,
|
|
1254
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
1255
|
+
"from": "@types/react"
|
|
1256
|
+
},
|
|
1257
|
+
{
|
|
1258
|
+
"name": "style",
|
|
1259
|
+
"type": "CSSProperties",
|
|
1260
|
+
"required": false,
|
|
1261
|
+
"description": "Inline styles applied to the rendered element.",
|
|
1262
|
+
"from": "@types/react"
|
|
1263
|
+
}
|
|
1264
|
+
]
|
|
1265
|
+
},
|
|
1266
|
+
{
|
|
1267
|
+
"name": "DataTableToolbar",
|
|
1268
|
+
"props": [
|
|
1269
|
+
{
|
|
1270
|
+
"name": "children",
|
|
1271
|
+
"type": "ReactNode",
|
|
1272
|
+
"required": false,
|
|
1273
|
+
"description": "Content rendered inside the part.",
|
|
1274
|
+
"from": "@types/react"
|
|
1275
|
+
},
|
|
1276
|
+
{
|
|
1277
|
+
"name": "className",
|
|
1278
|
+
"type": "string",
|
|
1279
|
+
"required": false,
|
|
1280
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
1281
|
+
"from": "@types/react"
|
|
1282
|
+
},
|
|
1283
|
+
{
|
|
1284
|
+
"name": "style",
|
|
1285
|
+
"type": "CSSProperties",
|
|
1286
|
+
"required": false,
|
|
1287
|
+
"description": "Inline styles applied to the rendered element.",
|
|
1288
|
+
"from": "@types/react"
|
|
1289
|
+
}
|
|
1290
|
+
]
|
|
1291
|
+
},
|
|
1292
|
+
{
|
|
1293
|
+
"name": "DataTableToolbarGroup",
|
|
1294
|
+
"props": [
|
|
1295
|
+
{
|
|
1296
|
+
"name": "children",
|
|
1297
|
+
"type": "ReactNode",
|
|
1298
|
+
"required": false,
|
|
1299
|
+
"description": "Content rendered inside the part.",
|
|
1300
|
+
"from": "@types/react"
|
|
1301
|
+
},
|
|
1302
|
+
{
|
|
1303
|
+
"name": "className",
|
|
1304
|
+
"type": "string",
|
|
1305
|
+
"required": false,
|
|
1306
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
1307
|
+
"from": "@types/react"
|
|
1308
|
+
},
|
|
1309
|
+
{
|
|
1310
|
+
"name": "style",
|
|
1311
|
+
"type": "CSSProperties",
|
|
1312
|
+
"required": false,
|
|
1313
|
+
"description": "Inline styles applied to the rendered element.",
|
|
1314
|
+
"from": "@types/react"
|
|
1315
|
+
}
|
|
1316
|
+
]
|
|
1317
|
+
},
|
|
1318
|
+
{
|
|
1319
|
+
"name": "DataTableViewOptions",
|
|
1320
|
+
"props": [
|
|
1321
|
+
{
|
|
1322
|
+
"name": "children",
|
|
1323
|
+
"type": "ReactNode",
|
|
1324
|
+
"required": false,
|
|
1325
|
+
"description": "Content rendered inside the part.",
|
|
1326
|
+
"from": "arkcn"
|
|
1327
|
+
},
|
|
1328
|
+
{
|
|
1329
|
+
"name": "className",
|
|
1330
|
+
"type": "string",
|
|
1331
|
+
"required": false,
|
|
1332
|
+
"description": "Extra classes merged into the part's own classes with `cn`.",
|
|
1333
|
+
"from": "arkcn"
|
|
1334
|
+
},
|
|
1335
|
+
{
|
|
1336
|
+
"name": "table",
|
|
1337
|
+
"type": "DataTableInstance<TData>",
|
|
1338
|
+
"required": false,
|
|
1339
|
+
"description": "The table instance, when not read from context.",
|
|
1340
|
+
"from": "arkcn"
|
|
1341
|
+
}
|
|
1342
|
+
]
|
|
1343
|
+
}
|
|
1344
|
+
],
|
|
36
1345
|
"dependencies": {
|
|
37
1346
|
"lucide-react": "^1.41.0"
|
|
38
1347
|
},
|
|
@@ -57,7 +1366,7 @@
|
|
|
57
1366
|
"files": [
|
|
58
1367
|
{
|
|
59
1368
|
"path": "components/ui/data-table.tsx",
|
|
60
|
-
"content": "\"use client\"\n\nimport * as React from \"react\"\nimport {\n type ColumnDef,\n type ColumnFiltersState,\n type PaginationState,\n type Row,\n type RowSelectionState,\n type SortingState,\n type TableOptions,\n type VisibilityState,\n useTable,\n} from \"@/lib/table\"\nimport {\n type DataTableColumn,\n type DataTableInstance,\n type DataTableRow as DataTableRowInstance,\n} from \"@/lib/data-table-adapter\"\nimport {\n ArrowDownIcon,\n ArrowUpIcon,\n CheckIcon,\n ChevronLeftIcon,\n ChevronRightIcon,\n ChevronsLeftIcon,\n ChevronsRightIcon,\n ChevronsUpDownIcon,\n EllipsisIcon,\n EyeOffIcon,\n PlusCircleIcon,\n Settings2Icon,\n XIcon,\n} from \"lucide-react\"\nimport { cn } from \"@/lib/utils\"\nimport { LiveRegion, useLiveRegion } from \"@/components/ui/live-region\"\n\nimport { Badge } from \"@/components/ui/badge\"\nimport { Button } from \"@/components/ui/button\"\nimport { Checkbox } from \"@/components/ui/checkbox\"\nimport {\n Command,\n CommandEmpty,\n CommandGroup,\n CommandInput,\n CommandItem,\n CommandList,\n CommandSeparator,\n useFilter,\n useListCollection,\n} from \"@/components/ui/command\"\nimport {\n DropdownMenu,\n DropdownMenuCheckboxItem,\n DropdownMenuContent,\n DropdownMenuGroup,\n DropdownMenuItem,\n DropdownMenuLabel,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n} from \"@/components/ui/dropdown-menu\"\nimport { Input } from \"@/components/ui/input\"\nimport { Popover, PopoverContent, PopoverTrigger } from \"@/components/ui/popover\"\nimport {\n Select,\n SelectContent,\n SelectControl,\n SelectItem,\n SelectTrigger,\n SelectValue,\n createListCollection,\n} from \"@/components/ui/select\"\nimport { FloatingToolbar } from \"@/components/ui/floating-toolbar\"\nimport { Separator } from \"@/components/ui/separator\"\nimport { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from \"@/components/ui/table\"\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"@/components/ui/tooltip\"\n\n/* -------------------------------------------------------------------------- */\n/* Hook */\n/* -------------------------------------------------------------------------- */\n\n/**\n * The built-in adapter: the dependency-free engine from `@/lib/table`. Its\n * instance satisfies `DataTableInstance`, so it can be passed to `<DataTable>`\n * directly. Any other object implementing `DataTableInstance` works the same way.\n */\nfunction useDataTable<TData>(options: TableOptions<TData>) {\n return useTable<TData>(options)\n}\n\n/* -------------------------------------------------------------------------- */\n/* Context */\n/* -------------------------------------------------------------------------- */\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst DataTableContext = React.createContext<DataTableInstance<any> | null>(null)\n\nfunction useDataTableContext<TData>(explicit?: DataTableInstance<TData>): DataTableInstance<TData> {\n const fromContext = React.useContext(DataTableContext)\n const table = explicit ?? fromContext\n if (!table) {\n throw new Error(\"Data table parts must be rendered inside <DataTable> or receive a `table` prop.\")\n }\n return table\n}\n\nfunction DataTable<TData>({\n table,\n className,\n ...props\n}: React.ComponentProps<\"div\"> & { table: DataTableInstance<TData> }) {\n return (\n <DataTableContext.Provider value={table}>\n <div data-slot=\"data-table\" className={cn(\"flex flex-1 flex-col gap-4\", className)} {...props} />\n </DataTableContext.Provider>\n )\n}\n\n/* -------------------------------------------------------------------------- */\n/* Toolbar */\n/* -------------------------------------------------------------------------- */\n\nfunction DataTableToolbar({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"data-table-toolbar\"\n className={cn(\"flex items-center justify-between gap-2\", className)}\n {...props}\n />\n )\n}\n\nfunction DataTableToolbarGroup({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"data-table-toolbar-group\"\n className={cn(\"flex flex-1 flex-col-reverse items-start gap-2 sm:flex-row sm:items-center\", className)}\n {...props}\n />\n )\n}\n\nfunction DataTableSearch<TData>({\n table: tableProp,\n columnId,\n className,\n ...props\n}: Omit<React.ComponentProps<typeof Input>, \"value\" | \"onChange\"> & {\n table?: DataTableInstance<TData>\n /** Filter a single column instead of the global filter. */\n columnId?: string\n}) {\n const table = useDataTableContext(tableProp)\n const column = columnId ? table.getColumn(columnId) : undefined\n const value = columnId\n ? ((column?.getFilterValue() as string) ?? \"\")\n : ((table.getState().globalFilter as string) ?? \"\")\n return (\n <Input\n data-slot=\"data-table-search\"\n value={value}\n onChange={(event) =>\n columnId ? column?.setFilterValue(event.target.value) : table.setGlobalFilter(event.target.value)\n }\n className={cn(\"h-8 w-37.5 lg:w-62.5\", className)}\n {...props}\n />\n )\n}\n\nfunction DataTableResetFilters<TData>({\n table: tableProp,\n className,\n children,\n asChild,\n ...props\n}: React.ComponentProps<typeof Button> & { table?: DataTableInstance<TData> }) {\n const table = useDataTableContext(tableProp)\n const isFiltered = table.getState().columnFilters.length > 0 || !!table.getState().globalFilter\n if (!isFiltered) return null\n return (\n <Button\n data-slot=\"data-table-reset-filters\"\n variant=\"ghost\"\n size=\"sm\"\n asChild={asChild}\n onClick={() => {\n table.resetColumnFilters()\n table.setGlobalFilter(\"\")\n }}\n className={cn(\"h-8 px-2 lg:px-3\", className)}\n {...props}\n >\n {asChild\n ? children\n : (children ?? (\n <>\n Reset\n <XIcon />\n </>\n ))}\n </Button>\n )\n}\n\n/* -------------------------------------------------------------------------- */\n/* Faceted filter */\n/* -------------------------------------------------------------------------- */\n\ntype FacetOption = {\n label: string\n value: string\n icon?: React.ComponentType<{ className?: string }>\n}\n\nfunction DataTableFacetedFilter<TData, TValue>({\n table: tableProp,\n columnId,\n column: columnProp,\n title,\n options,\n}: {\n table?: DataTableInstance<TData>\n columnId?: string\n column?: DataTableColumn<TData, TValue>\n title?: string\n options: FacetOption[]\n}) {\n const table = useDataTableContext(tableProp)\n const column = columnProp ?? (columnId ? table.getColumn(columnId) : undefined)\n const facets = column?.getFacetedUniqueValues()\n const selectedValues = new Set((column?.getFilterValue() as string[]) ?? [])\n\n const { contains } = useFilter({ sensitivity: \"base\" })\n const { collection, filter } = useListCollection<FacetOption>({\n initialItems: options,\n itemToString: (item) => item.label,\n itemToValue: (item) => item.value,\n filter: contains,\n })\n\n const toggle = (value: string) => {\n const next = new Set(selectedValues)\n if (next.has(value)) next.delete(value)\n else next.add(value)\n const values = Array.from(next)\n column?.setFilterValue(values.length ? values : undefined)\n }\n\n return (\n <Popover positioning={{ placement: \"bottom-start\" }}>\n <PopoverTrigger asChild>\n <Button data-slot=\"data-table-faceted-filter-trigger\" variant=\"outline\" size=\"sm\" className=\"h-8 border-dashed\">\n <PlusCircleIcon />\n {title}\n {selectedValues.size > 0 && (\n <>\n <Separator orientation=\"vertical\" className=\"mx-1 h-4\" />\n <Badge variant=\"secondary\" className=\"rounded-sm px-1 font-normal lg:hidden\">\n {selectedValues.size}\n </Badge>\n <div className=\"hidden gap-1 lg:flex\">\n {selectedValues.size > 2 ? (\n <Badge variant=\"secondary\" className=\"rounded-sm px-1 font-normal\">\n {selectedValues.size} selected\n </Badge>\n ) : (\n options\n .filter((option) => selectedValues.has(option.value))\n .map((option) => (\n <Badge key={option.value} variant=\"secondary\" className=\"rounded-sm px-1 font-normal\">\n {option.label}\n </Badge>\n ))\n )}\n </div>\n </>\n )}\n </Button>\n </PopoverTrigger>\n <PopoverContent data-slot=\"data-table-faceted-filter-content\" className=\"w-50 p-0\">\n <Command collection={collection} value={[]} onSelect={({ value }) => toggle(value)}>\n <CommandInput placeholder={title} onValueChange={filter} />\n <CommandList>\n <CommandEmpty>No results found.</CommandEmpty>\n <CommandGroup>\n {collection.items.map((option) => {\n const isSelected = selectedValues.has(option.value)\n return (\n <CommandItem\n key={option.value}\n item={option}\n className=\"**:data-[slot=command-item-indicator]:hidden\"\n >\n <div\n className={cn(\n \"flex size-4 items-center justify-center rounded-sm border border-primary\",\n isSelected ? \"bg-primary text-primary-foreground\" : \"opacity-50 [&_svg]:invisible\"\n )}\n >\n <CheckIcon className=\"size-3.5\" />\n </div>\n {option.icon && <option.icon className=\"size-4 text-muted-foreground\" />}\n <span>{option.label}</span>\n {facets?.get(option.value) ? (\n <span className=\"ml-auto flex size-4 items-center justify-center font-mono text-xs\">\n {facets.get(option.value)}\n </span>\n ) : null}\n </CommandItem>\n )\n })}\n </CommandGroup>\n {selectedValues.size > 0 && (\n <>\n <CommandSeparator />\n <CommandGroup>\n <CommandItem\n item={{ label: \"Clear filters\", value: \"__clear__\" }}\n onSelect={() => column?.setFilterValue(undefined)}\n className=\"justify-center text-center **:data-[slot=command-item-indicator]:hidden\"\n >\n Clear filters\n </CommandItem>\n </CommandGroup>\n </>\n )}\n </CommandList>\n </Command>\n </PopoverContent>\n </Popover>\n )\n}\n\n/* -------------------------------------------------------------------------- */\n/* View options */\n/* -------------------------------------------------------------------------- */\n\nfunction DataTableViewOptions<TData>({\n table: tableProp,\n className,\n children,\n}: {\n table?: DataTableInstance<TData>\n className?: string\n children?: React.ReactNode\n}) {\n const table = useDataTableContext(tableProp)\n return (\n <DropdownMenu positioning={{ placement: \"bottom-end\" }}>\n <DropdownMenuTrigger asChild>\n <Button\n data-slot=\"data-table-view-options-trigger\"\n variant=\"outline\"\n size=\"sm\"\n className={cn(\"ml-auto hidden h-8 lg:flex\", className)}\n >\n <Settings2Icon />\n {children ?? \"View\"}\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent data-slot=\"data-table-view-options-content\" className=\"w-37.5\">\n <DropdownMenuGroup>\n <DropdownMenuLabel>Toggle columns</DropdownMenuLabel>\n <DropdownMenuSeparator />\n {table\n .getAllColumns()\n .filter((column) => typeof column.accessorFn !== \"undefined\" && column.getCanHide())\n .map((column) => (\n <DropdownMenuCheckboxItem\n key={column.id}\n value={column.id}\n className=\"capitalize\"\n checked={column.getIsVisible()}\n onCheckedChange={(value) => column.toggleVisibility(!!value)}\n closeOnSelect={false}\n >\n {column.label ?? column.id}\n </DropdownMenuCheckboxItem>\n ))}\n </DropdownMenuGroup>\n </DropdownMenuContent>\n </DropdownMenu>\n )\n}\n\n/* -------------------------------------------------------------------------- */\n/* Column header */\n/* -------------------------------------------------------------------------- */\n\n/**\n * A header cell bound to a column id. Sortable columns get the sort/hide menu\n * with `children` as the title; hidden columns render nothing.\n */\nfunction DataTableHead<TData>({\n column: columnId,\n table: tableProp,\n className,\n children,\n ...props\n}: React.ComponentProps<typeof TableHead> & { column?: string; table?: DataTableInstance<TData> }) {\n const table = useDataTableContext(tableProp)\n const column = columnId ? table.getColumn(columnId) : undefined\n if (column && !column.getIsVisible()) return null\n if (!column?.getCanSort()) {\n return (\n <TableHead data-slot=\"data-table-head\" data-column={columnId} className={className} {...props}>\n {children}\n </TableHead>\n )\n }\n const sorted = column.getIsSorted()\n return (\n <TableHead data-slot=\"data-table-head\" data-column={columnId} className={className} {...props}>\n <DropdownMenu positioning={{ placement: \"bottom-start\" }}>\n <DropdownMenuTrigger asChild>\n <Button variant=\"ghost\" size=\"sm\" className=\"-ml-2.5 h-8 data-open:bg-accent\">\n <span>{children}</span>\n {sorted === \"desc\" ? <ArrowDownIcon /> : sorted === \"asc\" ? <ArrowUpIcon /> : <ChevronsUpDownIcon />}\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent>\n <DropdownMenuItem value=\"asc\" onSelect={() => column.toggleSorting(false)}>\n <ArrowUpIcon className=\"text-muted-foreground/70\" />\n Asc\n </DropdownMenuItem>\n <DropdownMenuItem value=\"desc\" onSelect={() => column.toggleSorting(true)}>\n <ArrowDownIcon className=\"text-muted-foreground/70\" />\n Desc\n </DropdownMenuItem>\n {column.getCanHide() && (\n <>\n <DropdownMenuSeparator />\n <DropdownMenuItem value=\"hide\" onSelect={() => column.toggleVisibility(false)}>\n <EyeOffIcon className=\"text-muted-foreground/70\" />\n Hide\n </DropdownMenuItem>\n </>\n )}\n </DropdownMenuContent>\n </DropdownMenu>\n </TableHead>\n )\n}\n\n/* -------------------------------------------------------------------------- */\n/* Selection cells */\n/* -------------------------------------------------------------------------- */\n\nfunction DataTableSelectAll<TData>({\n table,\n className,\n ...props\n}: Omit<React.ComponentProps<typeof Checkbox>, \"checked\" | \"onCheckedChange\"> & {\n table: DataTableInstance<TData>\n}) {\n return (\n <Checkbox\n data-slot=\"data-table-select-all\"\n checked={table.getIsAllPageRowsSelected() || (table.getIsSomePageRowsSelected() && \"indeterminate\")}\n onCheckedChange={({ checked }) => table.toggleAllPageRowsSelected(checked === true)}\n aria-label=\"Select all\"\n className={cn(\"translate-y-0.5\", className)}\n {...props}\n />\n )\n}\n\nfunction DataTableSelectRow<TData>({\n row,\n className,\n ...props\n}: Omit<React.ComponentProps<typeof Checkbox>, \"checked\" | \"onCheckedChange\"> & {\n row: DataTableRowInstance<TData>\n}) {\n return (\n <Checkbox\n data-slot=\"data-table-select-row\"\n checked={row.getIsSelected()}\n onCheckedChange={({ checked }) => row.toggleSelected(checked === true)}\n aria-label=\"Select row\"\n className={cn(\"translate-y-0.5\", className)}\n {...props}\n />\n )\n}\n\n/* -------------------------------------------------------------------------- */\n/* Row actions */\n/* -------------------------------------------------------------------------- */\n\nfunction DataTableRowActions({\n children,\n className,\n trigger,\n ...props\n}: React.ComponentProps<typeof DropdownMenu> & {\n className?: string\n /** Replace the default ellipsis button with your own element. */\n trigger?: React.ReactElement\n}) {\n return (\n <DropdownMenu positioning={{ placement: \"bottom-end\" }} {...props}>\n <DropdownMenuTrigger asChild>\n {trigger ?? (\n <Button\n data-slot=\"data-table-row-actions-trigger\"\n variant=\"ghost\"\n size=\"icon\"\n className={cn(\"size-8 data-open:bg-muted\", className)}\n >\n <EllipsisIcon />\n <span className=\"sr-only\">Open menu</span>\n </Button>\n )}\n </DropdownMenuTrigger>\n <DropdownMenuContent data-slot=\"data-table-row-actions-content\" className=\"w-40\">\n {children}\n </DropdownMenuContent>\n </DropdownMenu>\n )\n}\n\n/* -------------------------------------------------------------------------- */\n/* Table rendering */\n/* -------------------------------------------------------------------------- */\n\nfunction DataTableContainer({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div data-slot=\"data-table-container\" className={cn(\"overflow-hidden rounded-md border\", className)} {...props} />\n )\n}\n\n/** The header row. Put `DataTableHead` cells inside, one per column, in display order. */\nfunction DataTableHeader({ className, children, ...props }: React.ComponentProps<typeof TableHeader>) {\n return (\n <TableHeader data-slot=\"data-table-header\" className={className} {...props}>\n <TableRow>{children}</TableRow>\n </TableHeader>\n )\n}\n\n/** A body row bound to a row instance; carries the selected state. */\nfunction DataTableRow<TData>({\n row,\n className,\n ...props\n}: React.ComponentProps<typeof TableRow> & { row: DataTableRowInstance<TData> }) {\n return (\n <TableRow\n data-slot=\"data-table-row\"\n data-state={row.getIsSelected() ? \"selected\" : undefined}\n className={cn(\"group/row\", className)}\n {...props}\n />\n )\n}\n\n/** A body cell bound to a column id; hidden columns render nothing. */\nfunction DataTableCell<TData>({\n column: columnId,\n table: tableProp,\n className,\n ...props\n}: React.ComponentProps<typeof TableCell> & { column?: string; table?: DataTableInstance<TData> }) {\n const table = useDataTableContext(tableProp)\n const column = columnId ? table.getColumn(columnId) : undefined\n if (column && !column.getIsVisible()) return null\n return <TableCell data-slot=\"data-table-cell\" data-column={columnId} className={className} {...props} />\n}\n\n/**\n * Renders the current page of rows. `children` receives each row and returns\n * its cells (wrap them in `DataTableRow`, or return a fragment of cells to get\n * a default row). Shows `empty` when there are no rows.\n */\nfunction DataTableBody<TData>({\n table: tableProp,\n empty = \"No results.\",\n children,\n ...props\n}: Omit<React.ComponentProps<typeof TableBody>, \"children\"> & {\n table?: DataTableInstance<TData>\n empty?: React.ReactNode\n children: (row: DataTableRowInstance<TData>) => React.ReactNode\n}) {\n const table = useDataTableContext(tableProp)\n const rows = table.getRowModel().rows\n return (\n <TableBody data-slot=\"data-table-body\" {...props}>\n {rows.length ? (\n rows.map((row) => {\n const content = children(row)\n return React.isValidElement(content) && content.type === DataTableRow ? (\n <React.Fragment key={row.id}>{content}</React.Fragment>\n ) : (\n <DataTableRow key={row.id} row={row}>\n {content}\n </DataTableRow>\n )\n })\n ) : (\n <DataTableEmpty table={table}>{empty}</DataTableEmpty>\n )}\n </TableBody>\n )\n}\n\n/** A single full-width row for the empty state; spans the visible columns. */\nfunction DataTableEmpty<TData>({\n table: tableProp,\n colSpan,\n className,\n ...props\n}: React.ComponentProps<typeof TableCell> & { table?: DataTableInstance<TData>; colSpan?: number }) {\n const table = useDataTableContext(tableProp)\n const span = colSpan ?? Math.max(1, table.getAllColumns().filter((c) => c.getIsVisible()).length)\n return (\n <TableRow data-slot=\"data-table-empty\">\n <TableCell colSpan={span} className={cn(\"h-24 text-center\", className)} {...props} />\n </TableRow>\n )\n}\n\n/** The scrolling, bordered table. Compose `DataTableHeader` and `DataTableBody` inside. */\nfunction DataTableTable({ className, ...props }: React.ComponentProps<typeof Table>) {\n return (\n <DataTableContainer>\n <Table data-slot=\"data-table-table\" className={cn(\"min-w-xl\", className)} {...props} />\n </DataTableContainer>\n )\n}\n\n/* -------------------------------------------------------------------------- */\n/* Pagination */\n/* -------------------------------------------------------------------------- */\n\nfunction getPageNumbers(currentPage: number, totalPages: number) {\n const maxVisiblePages = 5\n const range: Array<number | \"...\"> = []\n if (totalPages <= maxVisiblePages) {\n for (let i = 1; i <= totalPages; i++) range.push(i)\n } else {\n range.push(1)\n if (currentPage <= 3) {\n for (let i = 2; i <= 4; i++) range.push(i)\n range.push(\"...\", totalPages)\n } else if (currentPage >= totalPages - 2) {\n range.push(\"...\")\n for (let i = totalPages - 3; i <= totalPages; i++) range.push(i)\n } else {\n range.push(\"...\")\n for (let i = currentPage - 1; i <= currentPage + 1; i++) range.push(i)\n range.push(\"...\", totalPages)\n }\n }\n return range\n}\n\nfunction DataTablePagination({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"data-table-pagination\"\n className={cn(\"flex flex-col-reverse items-center justify-between gap-4 px-2 md:flex-row\", className)}\n {...props}\n />\n )\n}\n\nconst defaultPageSizes = [10, 20, 30, 40, 50]\n\nfunction DataTablePageSize<TData>({\n table: tableProp,\n pageSizes = defaultPageSizes,\n className,\n children,\n}: {\n table?: DataTableInstance<TData>\n pageSizes?: number[]\n className?: string\n children?: React.ReactNode\n}) {\n const table = useDataTableContext(tableProp)\n const collection = React.useMemo(() => createListCollection({ items: pageSizes.map(String) }), [pageSizes])\n const pageSize = table.getState().pagination.pageSize\n return (\n <div data-slot=\"data-table-page-size\" className={cn(\"flex items-center gap-2\", className)}>\n <Select\n collection={collection}\n value={[String(pageSize)]}\n onValueChange={({ value }) => table.setPageSize(Number(value[0]))}\n positioning={{ placement: \"top\", sameWidth: true }}\n >\n <SelectControl>\n <SelectTrigger className=\"h-8 w-17.5\">\n <SelectValue placeholder={String(pageSize)} />\n </SelectTrigger>\n </SelectControl>\n <SelectContent className=\"min-w-0\">\n {collection.items.map((size) => (\n <SelectItem key={size} item={size}>\n {size}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n <p className=\"hidden text-sm font-medium sm:block\">{children ?? \"Rows per page\"}</p>\n </div>\n )\n}\n\nfunction DataTablePageInfo<TData>({\n table: tableProp,\n className,\n ...props\n}: React.ComponentProps<\"div\"> & { table?: DataTableInstance<TData> }) {\n const table = useDataTableContext(tableProp)\n const currentPage = table.getState().pagination.pageIndex + 1\n const totalPages = Math.max(table.getPageCount(), 1)\n return (\n <div\n data-slot=\"data-table-page-info\"\n className={cn(\"flex w-25 items-center justify-center text-sm font-medium\", className)}\n {...props}\n >\n Page {currentPage} of {totalPages}\n </div>\n )\n}\n\nfunction DataTablePageNav<TData>({\n table: tableProp,\n className,\n showEdges = true,\n ...props\n}: React.ComponentProps<\"div\"> & {\n table?: DataTableInstance<TData>\n /** Show the first and last page buttons. */\n showEdges?: boolean\n}) {\n const table = useDataTableContext(tableProp)\n const currentPage = table.getState().pagination.pageIndex + 1\n const totalPages = table.getPageCount()\n const pageNumbers = getPageNumbers(currentPage, totalPages)\n return (\n <div data-slot=\"data-table-page-nav\" className={cn(\"flex items-center gap-2\", className)} {...props}>\n {showEdges && (\n <Button\n variant=\"outline\"\n size=\"icon\"\n className=\"hidden size-8 md:inline-flex\"\n onClick={() => table.setPageIndex(0)}\n disabled={!table.getCanPreviousPage()}\n >\n <span className=\"sr-only\">Go to first page</span>\n <ChevronsLeftIcon />\n </Button>\n )}\n <Button\n variant=\"outline\"\n size=\"icon\"\n className=\"size-8\"\n onClick={() => table.previousPage()}\n disabled={!table.getCanPreviousPage()}\n >\n <span className=\"sr-only\">Go to previous page</span>\n <ChevronLeftIcon />\n </Button>\n {pageNumbers.map((pageNumber, index) =>\n pageNumber === \"...\" ? (\n <span key={`ellipsis-${index}`} className=\"px-1 text-sm text-muted-foreground\">\n ...\n </span>\n ) : (\n <Button\n key={pageNumber}\n variant={currentPage === pageNumber ? \"default\" : \"outline\"}\n size=\"sm\"\n className=\"h-8 min-w-8 px-2\"\n onClick={() => table.setPageIndex(pageNumber - 1)}\n aria-current={currentPage === pageNumber ? \"page\" : undefined}\n >\n <span className=\"sr-only\">Go to page </span>\n {pageNumber}\n </Button>\n )\n )}\n <Button\n variant=\"outline\"\n size=\"icon\"\n className=\"size-8\"\n onClick={() => table.nextPage()}\n disabled={!table.getCanNextPage()}\n >\n <span className=\"sr-only\">Go to next page</span>\n <ChevronRightIcon />\n </Button>\n {showEdges && (\n <Button\n variant=\"outline\"\n size=\"icon\"\n className=\"hidden size-8 md:inline-flex\"\n onClick={() => table.setPageIndex(table.getPageCount() - 1)}\n disabled={!table.getCanNextPage()}\n >\n <span className=\"sr-only\">Go to last page</span>\n <ChevronsRightIcon />\n </Button>\n )}\n </div>\n )\n}\n\n/* -------------------------------------------------------------------------- */\n/* Bulk actions */\n/* -------------------------------------------------------------------------- */\n\nfunction DataTableBulkActions<TData>({\n table: tableProp,\n entityName = \"row\",\n className,\n children,\n ...props\n}: React.ComponentProps<\"div\"> & {\n table?: DataTableInstance<TData>\n entityName?: string\n}) {\n const table = useDataTableContext(tableProp)\n const selectedCount = table.getFilteredSelectedRowModel().rows.length\n const { message: announcement, announce } = useLiveRegion({ clearAfter: 3000 })\n const plural = selectedCount > 1 ? \"s\" : \"\"\n\n React.useEffect(() => {\n if (selectedCount === 0) return\n announce(`${selectedCount} ${entityName}${plural} selected. Bulk actions toolbar is available.`)\n }, [selectedCount, entityName, plural, announce])\n\n return (\n <>\n <LiveRegion data-slot=\"data-table-live-region\" message={announcement} />\n <FloatingToolbar\n open={selectedCount > 0}\n data-slot=\"data-table-bulk-actions\"\n aria-label={`Bulk actions for ${selectedCount} selected ${entityName}${plural}`}\n onEscape={() => table.resetRowSelection()}\n className={className}\n {...props}\n >\n <DataTableBulkActionsClear table={table} />\n <Separator orientation=\"vertical\" className=\"h-5\" aria-hidden />\n <DataTableBulkActionsCount table={table} entityName={entityName} />\n <Separator orientation=\"vertical\" className=\"h-5\" aria-hidden />\n {children}\n </FloatingToolbar>\n </>\n )\n}\n\nfunction DataTableBulkActionsClear<TData>({\n table: tableProp,\n className,\n asChild,\n children,\n ...props\n}: React.ComponentProps<typeof Button> & { table?: DataTableInstance<TData> }) {\n const table = useDataTableContext(tableProp)\n return (\n <Tooltip>\n <TooltipTrigger asChild>\n <Button\n data-slot=\"data-table-bulk-actions-clear\"\n variant=\"outline\"\n size=\"icon\"\n asChild={asChild}\n onClick={() => table.resetRowSelection()}\n className={cn(\"size-6 rounded-full\", className)}\n aria-label=\"Clear selection\"\n {...props}\n >\n {asChild ? children : (children ?? <XIcon />)}\n </Button>\n </TooltipTrigger>\n <TooltipContent>Clear selection (Escape)</TooltipContent>\n </Tooltip>\n )\n}\n\nfunction DataTableBulkActionsCount<TData>({\n table: tableProp,\n entityName = \"row\",\n className,\n ...props\n}: React.ComponentProps<\"div\"> & {\n table?: DataTableInstance<TData>\n entityName?: string\n}) {\n const table = useDataTableContext(tableProp)\n const count = table.getFilteredSelectedRowModel().rows.length\n return (\n <div\n data-slot=\"data-table-bulk-actions-count\"\n className={cn(\"flex items-center gap-1 text-sm\", className)}\n {...props}\n >\n <Badge className=\"min-w-8 justify-center rounded-lg\" aria-label={`${count} selected`}>\n {count}\n </Badge>{\" \"}\n <span className=\"hidden sm:inline\">\n {entityName}\n {count > 1 ? \"s\" : \"\"}\n </span>{\" \"}\n selected\n </div>\n )\n}\n\nfunction DataTableBulkActionTrigger({\n label,\n className,\n children,\n asChild,\n ...props\n}: React.ComponentProps<typeof Button> & { label: string }) {\n return (\n <Tooltip>\n <TooltipTrigger asChild>\n <Button\n data-slot=\"data-table-bulk-action-trigger\"\n variant=\"outline\"\n size=\"icon\"\n asChild={asChild}\n className={cn(\"size-8\", className)}\n aria-label={label}\n {...props}\n >\n {asChild ? (\n children\n ) : (\n <>\n {children}\n <span className=\"sr-only\">{label}</span>\n </>\n )}\n </Button>\n </TooltipTrigger>\n <TooltipContent>{label}</TooltipContent>\n </Tooltip>\n )\n}\n\nexport {\n DataTable,\n DataTableBody,\n DataTableBulkActionTrigger,\n DataTableBulkActions,\n DataTableBulkActionsClear,\n DataTableBulkActionsCount,\n DataTableCell,\n DataTableHead,\n DataTableContainer,\n DataTableEmpty,\n DataTableFacetedFilter,\n DataTableHeader,\n DataTablePageInfo,\n DataTablePageNav,\n DataTablePageSize,\n DataTablePagination,\n DataTableResetFilters,\n DataTableRow,\n DataTableRowActions,\n DataTableSearch,\n DataTableSelectAll,\n DataTableSelectRow,\n DataTableTable,\n DataTableToolbar,\n DataTableToolbarGroup,\n DataTableViewOptions,\n getPageNumbers,\n useDataTable,\n useDataTableContext,\n type ColumnDef,\n type ColumnFiltersState,\n type FacetOption,\n type PaginationState,\n type Row,\n type RowSelectionState,\n type SortingState,\n type DataTableColumn,\n type DataTableInstance,\n type DataTableRowInstance,\n type TableOptions,\n type VisibilityState,\n}\n"
|
|
1369
|
+
"content": "\"use client\"\n\nimport * as React from \"react\"\nimport {\n type ColumnDef,\n type ColumnFiltersState,\n type PaginationState,\n type Row,\n type RowSelectionState,\n type SortingState,\n type TableOptions,\n type VisibilityState,\n useTable,\n} from \"@/lib/table\"\nimport {\n type DataTableColumn,\n type DataTableInstance,\n type DataTableRow as DataTableRowInstance,\n} from \"@/lib/data-table-adapter\"\nimport {\n ArrowDownIcon,\n ArrowUpIcon,\n CheckIcon,\n ChevronLeftIcon,\n ChevronRightIcon,\n ChevronsLeftIcon,\n ChevronsRightIcon,\n ChevronsUpDownIcon,\n EllipsisIcon,\n EyeOffIcon,\n PlusCircleIcon,\n Settings2Icon,\n XIcon,\n} from \"lucide-react\"\nimport { cn } from \"@/lib/utils\"\nimport { LiveRegion, useLiveRegion } from \"@/components/ui/live-region\"\n\nimport { Badge } from \"@/components/ui/badge\"\nimport { Button } from \"@/components/ui/button\"\nimport { Checkbox } from \"@/components/ui/checkbox\"\nimport {\n Command,\n CommandEmpty,\n CommandGroup,\n CommandInput,\n CommandItem,\n CommandList,\n CommandSeparator,\n useFilter,\n useListCollection,\n} from \"@/components/ui/command\"\nimport {\n DropdownMenu,\n DropdownMenuCheckboxItem,\n DropdownMenuContent,\n DropdownMenuGroup,\n DropdownMenuItem,\n DropdownMenuLabel,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n} from \"@/components/ui/dropdown-menu\"\nimport { Input } from \"@/components/ui/input\"\nimport { Popover, PopoverContent, PopoverTrigger } from \"@/components/ui/popover\"\nimport {\n Select,\n SelectContent,\n SelectControl,\n SelectItem,\n SelectTrigger,\n SelectValue,\n createListCollection,\n} from \"@/components/ui/select\"\nimport { FloatingToolbar } from \"@/components/ui/floating-toolbar\"\nimport { Separator } from \"@/components/ui/separator\"\nimport { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from \"@/components/ui/table\"\nimport { Tooltip, TooltipContent, TooltipTrigger } from \"@/components/ui/tooltip\"\n\n/* -------------------------------------------------------------------------- */\n/* Hook */\n/* -------------------------------------------------------------------------- */\n\n/**\n * The built-in adapter: the dependency-free engine from `@/lib/table`. Its\n * instance satisfies `DataTableInstance`, so it can be passed to `<DataTable>`\n * directly. Any other object implementing `DataTableInstance` works the same way.\n */\nfunction useDataTable<TData>(options: TableOptions<TData>) {\n return useTable<TData>(options)\n}\n\n/* -------------------------------------------------------------------------- */\n/* Context */\n/* -------------------------------------------------------------------------- */\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst DataTableContext = React.createContext<DataTableInstance<any> | null>(null)\n\nfunction useDataTableContext<TData>(explicit?: DataTableInstance<TData>): DataTableInstance<TData> {\n const fromContext = React.useContext(DataTableContext)\n const table = explicit ?? fromContext\n if (!table) {\n throw new Error(\"Data table parts must be rendered inside <DataTable> or receive a `table` prop.\")\n }\n return table\n}\n\nfunction DataTable<TData>({\n table,\n className,\n ...props\n}: React.ComponentProps<\"div\"> & { table: DataTableInstance<TData> }) {\n return (\n <DataTableContext.Provider value={table}>\n <div data-slot=\"data-table\" className={cn(\"flex flex-1 flex-col gap-4\", className)} {...props} />\n </DataTableContext.Provider>\n )\n}\n\n/* -------------------------------------------------------------------------- */\n/* Toolbar */\n/* -------------------------------------------------------------------------- */\n\nfunction DataTableToolbar({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"data-table-toolbar\"\n className={cn(\"flex items-center justify-between gap-2\", className)}\n {...props}\n />\n )\n}\n\nfunction DataTableToolbarGroup({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"data-table-toolbar-group\"\n className={cn(\"flex flex-1 flex-col-reverse items-start gap-2 sm:flex-row sm:items-center\", className)}\n {...props}\n />\n )\n}\n\nfunction DataTableSearch<TData>({\n table: tableProp,\n columnId,\n className,\n ...props\n}: Omit<React.ComponentProps<typeof Input>, \"value\" | \"onChange\"> & {\n table?: DataTableInstance<TData>\n /** Filter a single column instead of the global filter. */\n columnId?: string\n}) {\n const table = useDataTableContext(tableProp)\n const column = columnId ? table.getColumn(columnId) : undefined\n const value = columnId\n ? ((column?.getFilterValue() as string) ?? \"\")\n : ((table.getState().globalFilter as string) ?? \"\")\n return (\n <Input\n data-slot=\"data-table-search\"\n value={value}\n onChange={(event) =>\n columnId ? column?.setFilterValue(event.target.value) : table.setGlobalFilter(event.target.value)\n }\n className={cn(\"h-8 w-37.5 lg:w-62.5\", className)}\n {...props}\n />\n )\n}\n\nfunction DataTableResetFilters<TData>({\n table: tableProp,\n className,\n children,\n asChild,\n ...props\n}: React.ComponentProps<typeof Button> & { table?: DataTableInstance<TData> }) {\n const table = useDataTableContext(tableProp)\n const isFiltered = table.getState().columnFilters.length > 0 || !!table.getState().globalFilter\n if (!isFiltered) return null\n return (\n <Button\n data-slot=\"data-table-reset-filters\"\n variant=\"ghost\"\n size=\"sm\"\n asChild={asChild}\n onClick={() => {\n table.resetColumnFilters()\n table.setGlobalFilter(\"\")\n }}\n className={cn(\"h-8 px-2 lg:px-3\", className)}\n {...props}\n >\n {asChild\n ? children\n : (children ?? (\n <>\n Reset\n <XIcon />\n </>\n ))}\n </Button>\n )\n}\n\n/* -------------------------------------------------------------------------- */\n/* Faceted filter */\n/* -------------------------------------------------------------------------- */\n\ntype FacetOption = {\n label: string\n value: string\n icon?: React.ComponentType<{ className?: string }>\n}\n\nfunction DataTableFacetedFilter<TData, TValue>({\n table: tableProp,\n columnId,\n column: columnProp,\n title,\n options,\n}: {\n table?: DataTableInstance<TData>\n /** Id of the column this filter applies to. */\n columnId?: string\n column?: DataTableColumn<TData, TValue>\n title?: string\n /** Facet options as `{ value, label, icon? }`. */\n options: FacetOption[]\n}) {\n const table = useDataTableContext(tableProp)\n const column = columnProp ?? (columnId ? table.getColumn(columnId) : undefined)\n const facets = column?.getFacetedUniqueValues()\n const selectedValues = new Set((column?.getFilterValue() as string[]) ?? [])\n\n const { contains } = useFilter({ sensitivity: \"base\" })\n const { collection, filter } = useListCollection<FacetOption>({\n initialItems: options,\n itemToString: (item) => item.label,\n itemToValue: (item) => item.value,\n filter: contains,\n })\n\n const toggle = (value: string) => {\n const next = new Set(selectedValues)\n if (next.has(value)) next.delete(value)\n else next.add(value)\n const values = Array.from(next)\n column?.setFilterValue(values.length ? values : undefined)\n }\n\n return (\n <Popover positioning={{ placement: \"bottom-start\" }}>\n <PopoverTrigger asChild>\n <Button data-slot=\"data-table-faceted-filter-trigger\" variant=\"outline\" size=\"sm\" className=\"h-8 border-dashed\">\n <PlusCircleIcon />\n {title}\n {selectedValues.size > 0 && (\n <>\n <Separator orientation=\"vertical\" className=\"mx-1 h-4\" />\n <Badge variant=\"secondary\" className=\"rounded-sm px-1 font-normal lg:hidden\">\n {selectedValues.size}\n </Badge>\n <div className=\"hidden gap-1 lg:flex\">\n {selectedValues.size > 2 ? (\n <Badge variant=\"secondary\" className=\"rounded-sm px-1 font-normal\">\n {selectedValues.size} selected\n </Badge>\n ) : (\n options\n .filter((option) => selectedValues.has(option.value))\n .map((option) => (\n <Badge key={option.value} variant=\"secondary\" className=\"rounded-sm px-1 font-normal\">\n {option.label}\n </Badge>\n ))\n )}\n </div>\n </>\n )}\n </Button>\n </PopoverTrigger>\n <PopoverContent data-slot=\"data-table-faceted-filter-content\" className=\"w-50 p-0\">\n <Command collection={collection} value={[]} onSelect={({ value }) => toggle(value)}>\n <CommandInput placeholder={title} onValueChange={filter} />\n <CommandList>\n <CommandEmpty>No results found.</CommandEmpty>\n <CommandGroup>\n {collection.items.map((option) => {\n const isSelected = selectedValues.has(option.value)\n return (\n <CommandItem\n key={option.value}\n item={option}\n className=\"**:data-[slot=command-item-indicator]:hidden\"\n >\n <div\n className={cn(\n \"flex size-4 items-center justify-center rounded-sm border border-primary\",\n isSelected ? \"bg-primary text-primary-foreground\" : \"opacity-50 [&_svg]:invisible\"\n )}\n >\n <CheckIcon className=\"size-3.5\" />\n </div>\n {option.icon && <option.icon className=\"size-4 text-muted-foreground\" />}\n <span>{option.label}</span>\n {facets?.get(option.value) ? (\n <span className=\"ml-auto flex size-4 items-center justify-center font-mono text-xs\">\n {facets.get(option.value)}\n </span>\n ) : null}\n </CommandItem>\n )\n })}\n </CommandGroup>\n {selectedValues.size > 0 && (\n <>\n <CommandSeparator />\n <CommandGroup>\n <CommandItem\n item={{ label: \"Clear filters\", value: \"__clear__\" }}\n onSelect={() => column?.setFilterValue(undefined)}\n className=\"justify-center text-center **:data-[slot=command-item-indicator]:hidden\"\n >\n Clear filters\n </CommandItem>\n </CommandGroup>\n </>\n )}\n </CommandList>\n </Command>\n </PopoverContent>\n </Popover>\n )\n}\n\n/* -------------------------------------------------------------------------- */\n/* View options */\n/* -------------------------------------------------------------------------- */\n\nfunction DataTableViewOptions<TData>({\n table: tableProp,\n className,\n children,\n}: {\n table?: DataTableInstance<TData>\n className?: string\n children?: React.ReactNode\n}) {\n const table = useDataTableContext(tableProp)\n return (\n <DropdownMenu positioning={{ placement: \"bottom-end\" }}>\n <DropdownMenuTrigger asChild>\n <Button\n data-slot=\"data-table-view-options-trigger\"\n variant=\"outline\"\n size=\"sm\"\n className={cn(\"ml-auto hidden h-8 lg:flex\", className)}\n >\n <Settings2Icon />\n {children ?? \"View\"}\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent data-slot=\"data-table-view-options-content\" className=\"w-37.5\">\n <DropdownMenuGroup>\n <DropdownMenuLabel>Toggle columns</DropdownMenuLabel>\n <DropdownMenuSeparator />\n {table\n .getAllColumns()\n .filter((column) => typeof column.accessorFn !== \"undefined\" && column.getCanHide())\n .map((column) => (\n <DropdownMenuCheckboxItem\n key={column.id}\n value={column.id}\n className=\"capitalize\"\n checked={column.getIsVisible()}\n onCheckedChange={(value) => column.toggleVisibility(!!value)}\n closeOnSelect={false}\n >\n {column.label ?? column.id}\n </DropdownMenuCheckboxItem>\n ))}\n </DropdownMenuGroup>\n </DropdownMenuContent>\n </DropdownMenu>\n )\n}\n\n/* -------------------------------------------------------------------------- */\n/* Column header */\n/* -------------------------------------------------------------------------- */\n\n/**\n * A header cell bound to a column id. Sortable columns get the sort/hide menu\n * with `children` as the title; hidden columns render nothing.\n */\nfunction DataTableHead<TData>({\n column: columnId,\n table: tableProp,\n className,\n children,\n ...props\n}: React.ComponentProps<typeof TableHead> & { column?: string; table?: DataTableInstance<TData> }) {\n const table = useDataTableContext(tableProp)\n const column = columnId ? table.getColumn(columnId) : undefined\n if (column && !column.getIsVisible()) return null\n if (!column?.getCanSort()) {\n return (\n <TableHead data-slot=\"data-table-head\" data-column={columnId} className={className} {...props}>\n {children}\n </TableHead>\n )\n }\n const sorted = column.getIsSorted()\n return (\n <TableHead data-slot=\"data-table-head\" data-column={columnId} className={className} {...props}>\n <DropdownMenu positioning={{ placement: \"bottom-start\" }}>\n <DropdownMenuTrigger asChild>\n <Button variant=\"ghost\" size=\"sm\" className=\"-ml-2.5 h-8 data-open:bg-accent\">\n <span>{children}</span>\n {sorted === \"desc\" ? <ArrowDownIcon /> : sorted === \"asc\" ? <ArrowUpIcon /> : <ChevronsUpDownIcon />}\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent>\n <DropdownMenuItem value=\"asc\" onSelect={() => column.toggleSorting(false)}>\n <ArrowUpIcon className=\"text-muted-foreground/70\" />\n Asc\n </DropdownMenuItem>\n <DropdownMenuItem value=\"desc\" onSelect={() => column.toggleSorting(true)}>\n <ArrowDownIcon className=\"text-muted-foreground/70\" />\n Desc\n </DropdownMenuItem>\n {column.getCanHide() && (\n <>\n <DropdownMenuSeparator />\n <DropdownMenuItem value=\"hide\" onSelect={() => column.toggleVisibility(false)}>\n <EyeOffIcon className=\"text-muted-foreground/70\" />\n Hide\n </DropdownMenuItem>\n </>\n )}\n </DropdownMenuContent>\n </DropdownMenu>\n </TableHead>\n )\n}\n\n/* -------------------------------------------------------------------------- */\n/* Selection cells */\n/* -------------------------------------------------------------------------- */\n\nfunction DataTableSelectAll<TData>({\n table,\n className,\n ...props\n}: Omit<React.ComponentProps<typeof Checkbox>, \"checked\" | \"onCheckedChange\"> & {\n table: DataTableInstance<TData>\n}) {\n return (\n <Checkbox\n data-slot=\"data-table-select-all\"\n checked={table.getIsAllPageRowsSelected() || (table.getIsSomePageRowsSelected() && \"indeterminate\")}\n onCheckedChange={({ checked }) => table.toggleAllPageRowsSelected(checked === true)}\n aria-label=\"Select all\"\n className={cn(\"translate-y-0.5\", className)}\n {...props}\n />\n )\n}\n\nfunction DataTableSelectRow<TData>({\n row,\n className,\n ...props\n}: Omit<React.ComponentProps<typeof Checkbox>, \"checked\" | \"onCheckedChange\"> & {\n row: DataTableRowInstance<TData>\n}) {\n return (\n <Checkbox\n data-slot=\"data-table-select-row\"\n checked={row.getIsSelected()}\n onCheckedChange={({ checked }) => row.toggleSelected(checked === true)}\n aria-label=\"Select row\"\n className={cn(\"translate-y-0.5\", className)}\n {...props}\n />\n )\n}\n\n/* -------------------------------------------------------------------------- */\n/* Row actions */\n/* -------------------------------------------------------------------------- */\n\nfunction DataTableRowActions({\n children,\n className,\n trigger,\n ...props\n}: React.ComponentProps<typeof DropdownMenu> & {\n className?: string\n /** Replace the default ellipsis button with your own element. */\n trigger?: React.ReactElement\n}) {\n return (\n <DropdownMenu positioning={{ placement: \"bottom-end\" }} {...props}>\n <DropdownMenuTrigger asChild>\n {trigger ?? (\n <Button\n data-slot=\"data-table-row-actions-trigger\"\n variant=\"ghost\"\n size=\"icon\"\n className={cn(\"size-8 data-open:bg-muted\", className)}\n >\n <EllipsisIcon />\n <span className=\"sr-only\">Open menu</span>\n </Button>\n )}\n </DropdownMenuTrigger>\n <DropdownMenuContent data-slot=\"data-table-row-actions-content\" className=\"w-40\">\n {children}\n </DropdownMenuContent>\n </DropdownMenu>\n )\n}\n\n/* -------------------------------------------------------------------------- */\n/* Table rendering */\n/* -------------------------------------------------------------------------- */\n\nfunction DataTableContainer({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div data-slot=\"data-table-container\" className={cn(\"overflow-hidden rounded-md border\", className)} {...props} />\n )\n}\n\n/** The header row. Put `DataTableHead` cells inside, one per column, in display order. */\nfunction DataTableHeader({ className, children, ...props }: React.ComponentProps<typeof TableHeader>) {\n return (\n <TableHeader data-slot=\"data-table-header\" className={className} {...props}>\n <TableRow>{children}</TableRow>\n </TableHeader>\n )\n}\n\n/** A body row bound to a row instance; carries the selected state. */\nfunction DataTableRow<TData>({\n row,\n className,\n ...props\n}: React.ComponentProps<typeof TableRow> & { row: DataTableRowInstance<TData> }) {\n return (\n <TableRow\n data-slot=\"data-table-row\"\n data-state={row.getIsSelected() ? \"selected\" : undefined}\n className={cn(\"group/row\", className)}\n {...props}\n />\n )\n}\n\n/** A body cell bound to a column id; hidden columns render nothing. */\nfunction DataTableCell<TData>({\n column: columnId,\n table: tableProp,\n className,\n ...props\n}: React.ComponentProps<typeof TableCell> & { column?: string; table?: DataTableInstance<TData> }) {\n const table = useDataTableContext(tableProp)\n const column = columnId ? table.getColumn(columnId) : undefined\n if (column && !column.getIsVisible()) return null\n return <TableCell data-slot=\"data-table-cell\" data-column={columnId} className={className} {...props} />\n}\n\n/**\n * Renders the current page of rows. `children` receives each row and returns\n * its cells (wrap them in `DataTableRow`, or return a fragment of cells to get\n * a default row). Shows `empty` when there are no rows.\n */\nfunction DataTableBody<TData>({\n table: tableProp,\n empty = \"No results.\",\n children,\n ...props\n}: Omit<React.ComponentProps<typeof TableBody>, \"children\"> & {\n table?: DataTableInstance<TData>\n /** Content shown when there are no rows. */\n empty?: React.ReactNode\n children: (row: DataTableRowInstance<TData>) => React.ReactNode\n}) {\n const table = useDataTableContext(tableProp)\n const rows = table.getRowModel().rows\n return (\n <TableBody data-slot=\"data-table-body\" {...props}>\n {rows.length ? (\n rows.map((row) => {\n const content = children(row)\n return React.isValidElement(content) && content.type === DataTableRow ? (\n <React.Fragment key={row.id}>{content}</React.Fragment>\n ) : (\n <DataTableRow key={row.id} row={row}>\n {content}\n </DataTableRow>\n )\n })\n ) : (\n <DataTableEmpty table={table}>{empty}</DataTableEmpty>\n )}\n </TableBody>\n )\n}\n\n/** A single full-width row for the empty state; spans the visible columns. */\nfunction DataTableEmpty<TData>({\n table: tableProp,\n colSpan,\n className,\n ...props\n}: React.ComponentProps<typeof TableCell> & { table?: DataTableInstance<TData>; colSpan?: number }) {\n const table = useDataTableContext(tableProp)\n const span = colSpan ?? Math.max(1, table.getAllColumns().filter((c) => c.getIsVisible()).length)\n return (\n <TableRow data-slot=\"data-table-empty\">\n <TableCell colSpan={span} className={cn(\"h-24 text-center\", className)} {...props} />\n </TableRow>\n )\n}\n\n/** The scrolling, bordered table. Compose `DataTableHeader` and `DataTableBody` inside. */\nfunction DataTableTable({ className, ...props }: React.ComponentProps<typeof Table>) {\n return (\n <DataTableContainer>\n <Table data-slot=\"data-table-table\" className={cn(\"min-w-xl\", className)} {...props} />\n </DataTableContainer>\n )\n}\n\n/* -------------------------------------------------------------------------- */\n/* Pagination */\n/* -------------------------------------------------------------------------- */\n\nfunction getPageNumbers(currentPage: number, totalPages: number) {\n const maxVisiblePages = 5\n const range: Array<number | \"...\"> = []\n if (totalPages <= maxVisiblePages) {\n for (let i = 1; i <= totalPages; i++) range.push(i)\n } else {\n range.push(1)\n if (currentPage <= 3) {\n for (let i = 2; i <= 4; i++) range.push(i)\n range.push(\"...\", totalPages)\n } else if (currentPage >= totalPages - 2) {\n range.push(\"...\")\n for (let i = totalPages - 3; i <= totalPages; i++) range.push(i)\n } else {\n range.push(\"...\")\n for (let i = currentPage - 1; i <= currentPage + 1; i++) range.push(i)\n range.push(\"...\", totalPages)\n }\n }\n return range\n}\n\nfunction DataTablePagination({ className, ...props }: React.ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"data-table-pagination\"\n className={cn(\"flex flex-col-reverse items-center justify-between gap-4 px-2 md:flex-row\", className)}\n {...props}\n />\n )\n}\n\nconst defaultPageSizes = [10, 20, 30, 40, 50]\n\nfunction DataTablePageSize<TData>({\n table: tableProp,\n pageSizes = defaultPageSizes,\n className,\n children,\n}: {\n table?: DataTableInstance<TData>\n /** Choices offered in the page size select. */\n pageSizes?: number[]\n className?: string\n children?: React.ReactNode\n}) {\n const table = useDataTableContext(tableProp)\n const collection = React.useMemo(() => createListCollection({ items: pageSizes.map(String) }), [pageSizes])\n const pageSize = table.getState().pagination.pageSize\n return (\n <div data-slot=\"data-table-page-size\" className={cn(\"flex items-center gap-2\", className)}>\n <Select\n collection={collection}\n value={[String(pageSize)]}\n onValueChange={({ value }) => table.setPageSize(Number(value[0]))}\n positioning={{ placement: \"top\", sameWidth: true }}\n >\n <SelectControl>\n <SelectTrigger className=\"h-8 w-17.5\">\n <SelectValue placeholder={String(pageSize)} />\n </SelectTrigger>\n </SelectControl>\n <SelectContent className=\"min-w-0\">\n {collection.items.map((size) => (\n <SelectItem key={size} item={size}>\n {size}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n <p className=\"hidden text-sm font-medium sm:block\">{children ?? \"Rows per page\"}</p>\n </div>\n )\n}\n\nfunction DataTablePageInfo<TData>({\n table: tableProp,\n className,\n ...props\n}: React.ComponentProps<\"div\"> & { table?: DataTableInstance<TData> }) {\n const table = useDataTableContext(tableProp)\n const currentPage = table.getState().pagination.pageIndex + 1\n const totalPages = Math.max(table.getPageCount(), 1)\n return (\n <div\n data-slot=\"data-table-page-info\"\n className={cn(\"flex w-25 items-center justify-center text-sm font-medium\", className)}\n {...props}\n >\n Page {currentPage} of {totalPages}\n </div>\n )\n}\n\nfunction DataTablePageNav<TData>({\n table: tableProp,\n className,\n showEdges = true,\n ...props\n}: React.ComponentProps<\"div\"> & {\n table?: DataTableInstance<TData>\n /** Show the first and last page buttons. */\n showEdges?: boolean\n}) {\n const table = useDataTableContext(tableProp)\n const currentPage = table.getState().pagination.pageIndex + 1\n const totalPages = table.getPageCount()\n const pageNumbers = getPageNumbers(currentPage, totalPages)\n return (\n <div data-slot=\"data-table-page-nav\" className={cn(\"flex items-center gap-2\", className)} {...props}>\n {showEdges && (\n <Button\n variant=\"outline\"\n size=\"icon\"\n className=\"hidden size-8 md:inline-flex\"\n onClick={() => table.setPageIndex(0)}\n disabled={!table.getCanPreviousPage()}\n >\n <span className=\"sr-only\">Go to first page</span>\n <ChevronsLeftIcon />\n </Button>\n )}\n <Button\n variant=\"outline\"\n size=\"icon\"\n className=\"size-8\"\n onClick={() => table.previousPage()}\n disabled={!table.getCanPreviousPage()}\n >\n <span className=\"sr-only\">Go to previous page</span>\n <ChevronLeftIcon />\n </Button>\n {pageNumbers.map((pageNumber, index) =>\n pageNumber === \"...\" ? (\n <span key={`ellipsis-${index}`} className=\"px-1 text-sm text-muted-foreground\">\n ...\n </span>\n ) : (\n <Button\n key={pageNumber}\n variant={currentPage === pageNumber ? \"default\" : \"outline\"}\n size=\"sm\"\n className=\"h-8 min-w-8 px-2\"\n onClick={() => table.setPageIndex(pageNumber - 1)}\n aria-current={currentPage === pageNumber ? \"page\" : undefined}\n >\n <span className=\"sr-only\">Go to page </span>\n {pageNumber}\n </Button>\n )\n )}\n <Button\n variant=\"outline\"\n size=\"icon\"\n className=\"size-8\"\n onClick={() => table.nextPage()}\n disabled={!table.getCanNextPage()}\n >\n <span className=\"sr-only\">Go to next page</span>\n <ChevronRightIcon />\n </Button>\n {showEdges && (\n <Button\n variant=\"outline\"\n size=\"icon\"\n className=\"hidden size-8 md:inline-flex\"\n onClick={() => table.setPageIndex(table.getPageCount() - 1)}\n disabled={!table.getCanNextPage()}\n >\n <span className=\"sr-only\">Go to last page</span>\n <ChevronsRightIcon />\n </Button>\n )}\n </div>\n )\n}\n\n/* -------------------------------------------------------------------------- */\n/* Bulk actions */\n/* -------------------------------------------------------------------------- */\n\nfunction DataTableBulkActions<TData>({\n table: tableProp,\n entityName = \"row\",\n className,\n children,\n ...props\n}: React.ComponentProps<\"div\"> & {\n table?: DataTableInstance<TData>\n /** Noun used in the selection announcement, e.g. `task`. */\n entityName?: string\n}) {\n const table = useDataTableContext(tableProp)\n const selectedCount = table.getFilteredSelectedRowModel().rows.length\n const { message: announcement, announce } = useLiveRegion({ clearAfter: 3000 })\n const plural = selectedCount > 1 ? \"s\" : \"\"\n\n React.useEffect(() => {\n if (selectedCount === 0) return\n announce(`${selectedCount} ${entityName}${plural} selected. Bulk actions toolbar is available.`)\n }, [selectedCount, entityName, plural, announce])\n\n return (\n <>\n <LiveRegion data-slot=\"data-table-live-region\" message={announcement} />\n <FloatingToolbar\n open={selectedCount > 0}\n data-slot=\"data-table-bulk-actions\"\n aria-label={`Bulk actions for ${selectedCount} selected ${entityName}${plural}`}\n onEscape={() => table.resetRowSelection()}\n className={className}\n {...props}\n >\n <DataTableBulkActionsClear table={table} />\n <Separator orientation=\"vertical\" className=\"h-5\" aria-hidden />\n <DataTableBulkActionsCount table={table} entityName={entityName} />\n <Separator orientation=\"vertical\" className=\"h-5\" aria-hidden />\n {children}\n </FloatingToolbar>\n </>\n )\n}\n\nfunction DataTableBulkActionsClear<TData>({\n table: tableProp,\n className,\n asChild,\n children,\n ...props\n}: React.ComponentProps<typeof Button> & { table?: DataTableInstance<TData> }) {\n const table = useDataTableContext(tableProp)\n return (\n <Tooltip>\n <TooltipTrigger asChild>\n <Button\n data-slot=\"data-table-bulk-actions-clear\"\n variant=\"outline\"\n size=\"icon\"\n asChild={asChild}\n onClick={() => table.resetRowSelection()}\n className={cn(\"size-6 rounded-full\", className)}\n aria-label=\"Clear selection\"\n {...props}\n >\n {asChild ? children : (children ?? <XIcon />)}\n </Button>\n </TooltipTrigger>\n <TooltipContent>Clear selection (Escape)</TooltipContent>\n </Tooltip>\n )\n}\n\nfunction DataTableBulkActionsCount<TData>({\n table: tableProp,\n entityName = \"row\",\n className,\n ...props\n}: React.ComponentProps<\"div\"> & {\n table?: DataTableInstance<TData>\n /** Noun used in the selection announcement, e.g. `task`. */\n entityName?: string\n}) {\n const table = useDataTableContext(tableProp)\n const count = table.getFilteredSelectedRowModel().rows.length\n return (\n <div\n data-slot=\"data-table-bulk-actions-count\"\n className={cn(\"flex items-center gap-1 text-sm\", className)}\n {...props}\n >\n <Badge className=\"min-w-8 justify-center rounded-lg\" aria-label={`${count} selected`}>\n {count}\n </Badge>{\" \"}\n <span className=\"hidden sm:inline\">\n {entityName}\n {count > 1 ? \"s\" : \"\"}\n </span>{\" \"}\n selected\n </div>\n )\n}\n\nfunction DataTableBulkActionTrigger({\n label,\n className,\n children,\n asChild,\n ...props\n}: React.ComponentProps<typeof Button> & { label: string }) {\n return (\n <Tooltip>\n <TooltipTrigger asChild>\n <Button\n data-slot=\"data-table-bulk-action-trigger\"\n variant=\"outline\"\n size=\"icon\"\n asChild={asChild}\n className={cn(\"size-8\", className)}\n aria-label={label}\n {...props}\n >\n {asChild ? (\n children\n ) : (\n <>\n {children}\n <span className=\"sr-only\">{label}</span>\n </>\n )}\n </Button>\n </TooltipTrigger>\n <TooltipContent>{label}</TooltipContent>\n </Tooltip>\n )\n}\n\nexport {\n DataTable,\n DataTableBody,\n DataTableBulkActionTrigger,\n DataTableBulkActions,\n DataTableBulkActionsClear,\n DataTableBulkActionsCount,\n DataTableCell,\n DataTableHead,\n DataTableContainer,\n DataTableEmpty,\n DataTableFacetedFilter,\n DataTableHeader,\n DataTablePageInfo,\n DataTablePageNav,\n DataTablePageSize,\n DataTablePagination,\n DataTableResetFilters,\n DataTableRow,\n DataTableRowActions,\n DataTableSearch,\n DataTableSelectAll,\n DataTableSelectRow,\n DataTableTable,\n DataTableToolbar,\n DataTableToolbarGroup,\n DataTableViewOptions,\n getPageNumbers,\n useDataTable,\n useDataTableContext,\n type ColumnDef,\n type ColumnFiltersState,\n type FacetOption,\n type PaginationState,\n type Row,\n type RowSelectionState,\n type SortingState,\n type DataTableColumn,\n type DataTableInstance,\n type DataTableRowInstance,\n type TableOptions,\n type VisibilityState,\n}\n"
|
|
61
1370
|
}
|
|
62
1371
|
],
|
|
63
1372
|
"docs": "## Data table\n`src/lib/table.ts` is a dependency-free headless table engine (columns, sorting, global +\ncolumn filters with faceted counts, pagination, row selection, visibility). Column config is\ndata only: `{ id | accessorKey | accessorFn, label, enableSorting, enableHiding, filterFn,\nsortingFn }`. No render functions and no markup in column definitions.\n`src/components/ui/data-table.tsx` builds compositional parts on the source-agnostic\n`DataTableInstance` contract in `src/lib/data-table-adapter.ts`: toolbar, search, faceted\nfilter, reset, view options, `DataTableTable` > `DataTableHeader` (one `DataTableHead\ncolumn=\"id\"` per column; sortable columns get the sort/hide menu with `children` as the title)\n+ `DataTableBody` (`children` is `(row) => cells`; wrap in `DataTableRow` or return a fragment\nof `DataTableCell column=\"id\"` cells), `DataTableEmpty`, select-all/select-row cells, row\nactions, pagination pieces, bulk actions. Heads and cells keyed by a hidden column render\nnothing, so visibility toggles need no extra wiring. The toolkit must not know about specific\ntable libraries (no TanStack). `src/demo/tasks/` and `src/demo/users/` are the reference\nconsumers: `columns.tsx` is pure config, `*-table.tsx` composes the markup."
|