@inbeat/ui 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/CHANGELOG.md +76 -0
  2. package/package.json +100 -0
  3. package/src/components/alert-dialog.tsx +246 -0
  4. package/src/components/alert.tsx +66 -0
  5. package/src/components/app-nav.tsx +55 -0
  6. package/src/components/app-shell.tsx +95 -0
  7. package/src/components/avatar.tsx +73 -0
  8. package/src/components/badge.tsx +42 -0
  9. package/src/components/breadcrumb.tsx +109 -0
  10. package/src/components/button.tsx +75 -0
  11. package/src/components/calendar.tsx +220 -0
  12. package/src/components/carousel.tsx +83 -0
  13. package/src/components/checkbox.tsx +29 -0
  14. package/src/components/collapsible-section.tsx +88 -0
  15. package/src/components/combobox.tsx +351 -0
  16. package/src/components/data-table-shell.tsx +6 -0
  17. package/src/components/data-table-sortable-header.tsx +29 -0
  18. package/src/components/data-table.tsx +141 -0
  19. package/src/components/destructive-action-dialog.tsx +108 -0
  20. package/src/components/dialog.tsx +187 -0
  21. package/src/components/dropdown-menu.tsx +228 -0
  22. package/src/components/empty-state.tsx +55 -0
  23. package/src/components/field.tsx +248 -0
  24. package/src/components/icon-button.tsx +51 -0
  25. package/src/components/input-group.tsx +170 -0
  26. package/src/components/input.tsx +22 -0
  27. package/src/components/label.tsx +24 -0
  28. package/src/components/labeled-field.tsx +18 -0
  29. package/src/components/load-more-sentinel.tsx +12 -0
  30. package/src/components/member-avatar-stack.tsx +44 -0
  31. package/src/components/multi-select-popover.tsx +202 -0
  32. package/src/components/nav-user.tsx +71 -0
  33. package/src/components/number-dot.tsx +13 -0
  34. package/src/components/person-identity.tsx +52 -0
  35. package/src/components/platform-disclaimer.tsx +70 -0
  36. package/src/components/popover.tsx +92 -0
  37. package/src/components/portal-container.tsx +21 -0
  38. package/src/components/progress.tsx +23 -0
  39. package/src/components/search-input.tsx +57 -0
  40. package/src/components/select.tsx +232 -0
  41. package/src/components/separator.tsx +28 -0
  42. package/src/components/sheet.tsx +147 -0
  43. package/src/components/sidebar.tsx +471 -0
  44. package/src/components/skeleton.tsx +13 -0
  45. package/src/components/sonner.tsx +46 -0
  46. package/src/components/spinner.tsx +21 -0
  47. package/src/components/table.tsx +92 -0
  48. package/src/components/tabs.tsx +62 -0
  49. package/src/components/textarea.tsx +18 -0
  50. package/src/components/toggle-pills.tsx +32 -0
  51. package/src/components/tooltip.tsx +67 -0
  52. package/src/hooks/use-mobile.ts +21 -0
  53. package/src/lib/easing.ts +5 -0
  54. package/src/lib/initials.ts +12 -0
  55. package/src/lib/utils.ts +6 -0
  56. package/theme.css +141 -0
@@ -0,0 +1,88 @@
1
+ "use client";
2
+
3
+ import { AnimatePresence, motion } from "motion/react";
4
+ import { Slot } from "radix-ui";
5
+ import { createContext, useContext, useState } from "react";
6
+ import { EASING_FUNCTION } from "../lib/easing";
7
+ import { cn } from "../lib/utils";
8
+
9
+ type CollapsibleContextValue = {
10
+ open: boolean;
11
+ toggle: () => void;
12
+ };
13
+
14
+ const CollapsibleContext = createContext<CollapsibleContextValue | null>(null);
15
+
16
+ function useCollapsible() {
17
+ const context = useContext(CollapsibleContext);
18
+ if (!context) {
19
+ throw new Error("CollapsibleTrigger/Content must be used within CollapsibleSection");
20
+ }
21
+ return context;
22
+ }
23
+
24
+ interface CollapsibleSectionProps {
25
+ children: React.ReactNode;
26
+ defaultOpen?: boolean;
27
+ className?: string;
28
+ }
29
+
30
+ export function CollapsibleSection({
31
+ children,
32
+ defaultOpen = false,
33
+ className,
34
+ }: CollapsibleSectionProps) {
35
+ const [open, setOpen] = useState(defaultOpen);
36
+ const toggle = () => setOpen((o) => !o);
37
+
38
+ return (
39
+ <CollapsibleContext.Provider value={{ open, toggle }}>
40
+ <div className={cn("rounded-lg border border-border overflow-hidden", className)}>
41
+ {children}
42
+ </div>
43
+ </CollapsibleContext.Provider>
44
+ );
45
+ }
46
+
47
+ interface CollapsibleTriggerProps {
48
+ children: React.ReactNode;
49
+ asChild?: boolean;
50
+ }
51
+
52
+ export function CollapsibleTrigger({ children, asChild }: CollapsibleTriggerProps) {
53
+ const { toggle } = useCollapsible();
54
+ const Comp = asChild ? Slot.Root : "button";
55
+
56
+ return (
57
+ <Comp type={asChild ? undefined : "button"} onClick={toggle}>
58
+ {children}
59
+ </Comp>
60
+ );
61
+ }
62
+
63
+ interface CollapsibleContentProps {
64
+ children: React.ReactNode;
65
+ className?: string;
66
+ }
67
+
68
+ export function CollapsibleContent({ children, className }: CollapsibleContentProps) {
69
+ const { open } = useCollapsible();
70
+
71
+ return (
72
+ <AnimatePresence initial={false}>
73
+ {open && (
74
+ <motion.div
75
+ initial={{ height: 0, opacity: 0 }}
76
+ animate={{ height: "auto", opacity: 1 }}
77
+ exit={{ height: 0, opacity: 0 }}
78
+ transition={{ duration: 0.2, ease: EASING_FUNCTION.exponential }}
79
+ className={cn("border-t border-border overflow-hidden", className)}
80
+ >
81
+ {children}
82
+ </motion.div>
83
+ )}
84
+ </AnimatePresence>
85
+ );
86
+ }
87
+
88
+ export { useCollapsible };
@@ -0,0 +1,351 @@
1
+ "use client"
2
+
3
+ import * as React from "react"
4
+ import { Combobox as ComboboxPrimitive } from "@base-ui/react"
5
+ import { CheckIcon, ChevronDownIcon, XIcon } from "lucide-react"
6
+
7
+ import { cn } from "../lib/utils"
8
+ import { Button } from "./button"
9
+ import {
10
+ InputGroup,
11
+ InputGroupAddon,
12
+ InputGroupButton,
13
+ InputGroupInput,
14
+ } from "./input-group"
15
+ import { usePortalContainer } from "./portal-container"
16
+
17
+ const Combobox = ComboboxPrimitive.Root
18
+ const VISIBLE_CHIP_LIMIT = 3
19
+
20
+ function ComboboxValue({ ...props }: ComboboxPrimitive.Value.Props) {
21
+ return <ComboboxPrimitive.Value data-slot="combobox-value" {...props} />
22
+ }
23
+
24
+ function ComboboxTrigger({
25
+ className,
26
+ children,
27
+ ...props
28
+ }: ComboboxPrimitive.Trigger.Props) {
29
+ return (
30
+ <ComboboxPrimitive.Trigger
31
+ data-slot="combobox-trigger"
32
+ className={cn("[&_svg:not([class*='size-'])]:size-4", className)}
33
+ {...props}
34
+ >
35
+ {children}
36
+ <ChevronDownIcon
37
+ data-slot="combobox-trigger-icon"
38
+ className="pointer-events-none size-4 text-muted-foreground"
39
+ />
40
+ </ComboboxPrimitive.Trigger>
41
+ )
42
+ }
43
+
44
+ function ComboboxSelectTrigger({ children }: { children: React.ReactNode }) {
45
+ return (
46
+ <ComboboxTrigger
47
+ render={
48
+ <button
49
+ type="button"
50
+ className="flex h-9 min-w-36 w-full items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent px-3 py-1 text-sm font-normal whitespace-nowrap outline-none transition-all duration-50 focus-visible:border-ring focus-visible:ring-[1px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 dark:bg-input/30 **:data-[slot=combobox-trigger-icon]:size-3.5 **:data-[slot=combobox-trigger-icon]:opacity-50"
51
+ />
52
+ }
53
+ >
54
+ {children}
55
+ </ComboboxTrigger>
56
+ )
57
+ }
58
+
59
+ function ComboboxClear({ className, ...props }: ComboboxPrimitive.Clear.Props) {
60
+ return (
61
+ <ComboboxPrimitive.Clear
62
+ data-slot="combobox-clear"
63
+ render={<InputGroupButton variant="ghost" size="icon-xs" />}
64
+ className={cn(className)}
65
+ {...props}
66
+ >
67
+ <XIcon className="pointer-events-none" />
68
+ </ComboboxPrimitive.Clear>
69
+ )
70
+ }
71
+
72
+ function ComboboxInput({
73
+ className,
74
+ children,
75
+ disabled = false,
76
+ showTrigger = true,
77
+ showClear = false,
78
+ ...props
79
+ }: ComboboxPrimitive.Input.Props & {
80
+ showTrigger?: boolean
81
+ showClear?: boolean
82
+ }) {
83
+ return (
84
+ <InputGroup className={cn("w-auto", className)}>
85
+ <ComboboxPrimitive.Input
86
+ render={<InputGroupInput disabled={disabled} />}
87
+ {...props}
88
+ />
89
+ <InputGroupAddon align="inline-end">
90
+ {showTrigger && (
91
+ <InputGroupButton
92
+ size="icon-xs"
93
+ variant="ghost"
94
+ asChild
95
+ data-slot="input-group-button"
96
+ className="group-has-data-[slot=combobox-clear]/input-group:hidden data-pressed:bg-transparent"
97
+ disabled={disabled}
98
+ >
99
+ <ComboboxTrigger />
100
+ </InputGroupButton>
101
+ )}
102
+ {showClear && <ComboboxClear disabled={disabled} />}
103
+ </InputGroupAddon>
104
+ {children}
105
+ </InputGroup>
106
+ )
107
+ }
108
+
109
+ function ComboboxContent({
110
+ className,
111
+ side = "bottom",
112
+ sideOffset = 6,
113
+ align = "start",
114
+ alignOffset = 0,
115
+ anchor,
116
+ ...props
117
+ }: ComboboxPrimitive.Popup.Props &
118
+ Pick<
119
+ ComboboxPrimitive.Positioner.Props,
120
+ "side" | "align" | "sideOffset" | "alignOffset" | "anchor"
121
+ >) {
122
+ const portalContainer = usePortalContainer()
123
+
124
+ return (
125
+ <ComboboxPrimitive.Portal container={portalContainer ?? undefined}>
126
+ <ComboboxPrimitive.Positioner
127
+ side={side}
128
+ sideOffset={sideOffset}
129
+ align={align}
130
+ alignOffset={alignOffset}
131
+ anchor={anchor}
132
+ className="isolate z-50"
133
+ >
134
+ <ComboboxPrimitive.Popup
135
+ data-slot="combobox-content"
136
+ data-chips={!!anchor}
137
+ className={cn(
138
+ "group/combobox-content relative max-h-96 w-(--anchor-width) max-w-(--available-width) min-w-[calc(var(--anchor-width)+--spacing(7))] origin-(--transform-origin) overflow-hidden rounded-md bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[chips=true]:min-w-(--anchor-width) data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 *:data-[slot=input-group]:m-1 *:data-[slot=input-group]:mb-0 *:data-[slot=input-group]:h-8 *:data-[slot=input-group]:border-input/30 *:data-[slot=input-group]:bg-input/30 *:data-[slot=input-group]:shadow-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
139
+ className
140
+ )}
141
+ {...props}
142
+ />
143
+ </ComboboxPrimitive.Positioner>
144
+ </ComboboxPrimitive.Portal>
145
+ )
146
+ }
147
+
148
+ function ComboboxList({ className, ...props }: ComboboxPrimitive.List.Props) {
149
+ return (
150
+ <ComboboxPrimitive.List
151
+ data-slot="combobox-list"
152
+ className={cn(
153
+ "max-h-[min(calc(--spacing(96)---spacing(9)),calc(var(--available-height)---spacing(9)))] scroll-py-1 overflow-y-auto p-1 data-empty:hidden",
154
+ className
155
+ )}
156
+ {...props}
157
+ />
158
+ )
159
+ }
160
+
161
+ function ComboboxItem({
162
+ className,
163
+ children,
164
+ ...props
165
+ }: ComboboxPrimitive.Item.Props) {
166
+ return (
167
+ <ComboboxPrimitive.Item
168
+ data-slot="combobox-item"
169
+ className={cn(
170
+ "relative flex w-full items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
171
+ className
172
+ )}
173
+ {...props}
174
+ >
175
+ {children}
176
+ <ComboboxPrimitive.ItemIndicator
177
+ data-slot="combobox-item-indicator"
178
+ render={
179
+ <span className="pointer-events-none absolute right-2 flex size-4 items-center justify-center" />
180
+ }
181
+ >
182
+ <CheckIcon className="pointer-events-none size-4 pointer-coarse:size-5" />
183
+ </ComboboxPrimitive.ItemIndicator>
184
+ </ComboboxPrimitive.Item>
185
+ )
186
+ }
187
+
188
+ function ComboboxGroup({ className, ...props }: ComboboxPrimitive.Group.Props) {
189
+ return (
190
+ <ComboboxPrimitive.Group
191
+ data-slot="combobox-group"
192
+ className={cn(className)}
193
+ {...props}
194
+ />
195
+ )
196
+ }
197
+
198
+ function ComboboxLabel({
199
+ className,
200
+ ...props
201
+ }: ComboboxPrimitive.GroupLabel.Props) {
202
+ return (
203
+ <ComboboxPrimitive.GroupLabel
204
+ data-slot="combobox-label"
205
+ className={cn(
206
+ "px-2 py-1.5 text-xs text-muted-foreground pointer-coarse:px-3 pointer-coarse:py-2 pointer-coarse:text-sm",
207
+ className
208
+ )}
209
+ {...props}
210
+ />
211
+ )
212
+ }
213
+
214
+ function ComboboxCollection({ ...props }: ComboboxPrimitive.Collection.Props) {
215
+ return (
216
+ <ComboboxPrimitive.Collection data-slot="combobox-collection" {...props} />
217
+ )
218
+ }
219
+
220
+ function ComboboxEmpty({ className, ...props }: ComboboxPrimitive.Empty.Props) {
221
+ return (
222
+ <ComboboxPrimitive.Empty
223
+ data-slot="combobox-empty"
224
+ className={cn(
225
+ "flex w-full justify-center py-2 text-center text-sm text-muted-foreground empty:hidden",
226
+ className
227
+ )}
228
+ {...props}
229
+ />
230
+ )
231
+ }
232
+
233
+ function ComboboxSeparator({
234
+ className,
235
+ ...props
236
+ }: ComboboxPrimitive.Separator.Props) {
237
+ return (
238
+ <ComboboxPrimitive.Separator
239
+ data-slot="combobox-separator"
240
+ className={cn("-mx-1 my-1 h-px bg-border", className)}
241
+ {...props}
242
+ />
243
+ )
244
+ }
245
+
246
+ function ComboboxChips({
247
+ className,
248
+ ...props
249
+ }: React.ComponentPropsWithRef<typeof ComboboxPrimitive.Chips> &
250
+ ComboboxPrimitive.Chips.Props) {
251
+ return (
252
+ <ComboboxPrimitive.Chips
253
+ data-slot="combobox-chips"
254
+ className={cn(
255
+ "flex min-h-9 flex-wrap items-center gap-1.5 rounded-md border border-input bg-transparent bg-clip-padding px-2.5 py-1.5 text-sm shadow-xs transition-[color,box-shadow] focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/50 has-aria-invalid:border-destructive has-aria-invalid:ring-[3px] has-aria-invalid:ring-destructive/20 has-data-[slot=combobox-chip]:px-1.5 dark:bg-input/30 dark:has-aria-invalid:border-destructive/50 dark:has-aria-invalid:ring-destructive/40",
256
+ className
257
+ )}
258
+ {...props}
259
+ />
260
+ )
261
+ }
262
+
263
+ function ComboboxChip({
264
+ className,
265
+ children,
266
+ showRemove = true,
267
+ ...props
268
+ }: ComboboxPrimitive.Chip.Props & {
269
+ showRemove?: boolean
270
+ }) {
271
+ return (
272
+ <ComboboxPrimitive.Chip
273
+ data-slot="combobox-chip"
274
+ className={cn(
275
+ "flex h-[calc(--spacing(5.5))] w-fit items-center justify-center gap-1 rounded-sm bg-muted px-1.5 text-xs font-medium whitespace-nowrap text-foreground has-disabled:pointer-events-none has-disabled:cursor-not-allowed has-disabled:opacity-50 has-data-[slot=combobox-chip-remove]:pr-0",
276
+ className
277
+ )}
278
+ {...props}
279
+ >
280
+ {children}
281
+ {showRemove && (
282
+ <ComboboxPrimitive.ChipRemove
283
+ render={<Button variant="ghost" size="icon-xs" />}
284
+ className="-ml-1 opacity-50 hover:opacity-100"
285
+ data-slot="combobox-chip-remove"
286
+ >
287
+ <XIcon className="pointer-events-none" />
288
+ </ComboboxPrimitive.ChipRemove>
289
+ )}
290
+ </ComboboxPrimitive.Chip>
291
+ )
292
+ }
293
+
294
+ function ComboboxChipsInput({
295
+ className,
296
+ children,
297
+ ...props
298
+ }: ComboboxPrimitive.Input.Props) {
299
+ return (
300
+ <ComboboxPrimitive.Input
301
+ data-slot="combobox-chip-input"
302
+ className={cn("min-w-16 flex-1 outline-none", className)}
303
+ {...props}
304
+ />
305
+ )
306
+ }
307
+
308
+ function ComboboxLimitedValue({
309
+ values,
310
+ limit = VISIBLE_CHIP_LIMIT,
311
+ }: {
312
+ values: string[]
313
+ limit?: number
314
+ }) {
315
+ const visibleValues = values.slice(0, limit)
316
+ const hiddenCount = values.length - visibleValues.length
317
+
318
+ return (
319
+ <ComboboxValue>
320
+ {visibleValues.map((value) => (
321
+ <ComboboxChip key={value}>{value}</ComboboxChip>
322
+ ))}
323
+ {hiddenCount > 0 && <ComboboxChip showRemove={false}>+{hiddenCount}</ComboboxChip>}
324
+ </ComboboxValue>
325
+ )
326
+ }
327
+
328
+ function useComboboxAnchor() {
329
+ return React.useRef<HTMLDivElement | null>(null)
330
+ }
331
+
332
+ export {
333
+ Combobox,
334
+ ComboboxInput,
335
+ ComboboxContent,
336
+ ComboboxList,
337
+ ComboboxItem,
338
+ ComboboxGroup,
339
+ ComboboxLabel,
340
+ ComboboxCollection,
341
+ ComboboxEmpty,
342
+ ComboboxSeparator,
343
+ ComboboxChips,
344
+ ComboboxChip,
345
+ ComboboxChipsInput,
346
+ ComboboxLimitedValue,
347
+ ComboboxSelectTrigger,
348
+ ComboboxTrigger,
349
+ ComboboxValue,
350
+ useComboboxAnchor,
351
+ }
@@ -0,0 +1,6 @@
1
+ import type { ComponentProps } from "react";
2
+ import { cn } from "../lib/utils";
3
+
4
+ export function DataTableShell({ className, ...props }: ComponentProps<"div">) {
5
+ return <div className={cn("min-h-0 min-w-0 overflow-auto pb-6 pr-4", className)} {...props} />;
6
+ }
@@ -0,0 +1,29 @@
1
+ "use client";
2
+
3
+ import type { Column } from "@tanstack/react-table";
4
+ import { ArrowDownIcon, ArrowUpIcon } from "lucide-react";
5
+ import { Button } from "./button";
6
+
7
+ type DataTableSortableHeaderProps<TData, TValue> = {
8
+ label: string;
9
+ column: Column<TData, TValue>;
10
+ };
11
+
12
+ export function DataTableSortableHeader<TData, TValue>({
13
+ label,
14
+ column,
15
+ }: DataTableSortableHeaderProps<TData, TValue>) {
16
+ const isAscending = column.getIsSorted() === "asc";
17
+
18
+ return (
19
+ <Button
20
+ type="button"
21
+ variant="ghost"
22
+ size="xs"
23
+ onClick={() => column.toggleSorting(isAscending)}
24
+ >
25
+ {label}
26
+ {isAscending ? <ArrowUpIcon className="size-3.5" /> : <ArrowDownIcon className="size-3.5" />}
27
+ </Button>
28
+ );
29
+ }
@@ -0,0 +1,141 @@
1
+ "use client";
2
+
3
+ import {
4
+ type ColumnDef,
5
+ flexRender,
6
+ getCoreRowModel,
7
+ type Row,
8
+ type RowData,
9
+ type TableOptions,
10
+ useReactTable,
11
+ } from "@tanstack/react-table";
12
+ import type { ComponentProps } from "react";
13
+
14
+ import {
15
+ Table,
16
+ TableBody,
17
+ TableCell,
18
+ TableHead,
19
+ TableHeader,
20
+ TableRow,
21
+ } from "./table";
22
+ import { cn } from "../lib/utils";
23
+
24
+ // Declared here rather than in a sibling .d.ts: consumers type-check this source from node_modules
25
+ // and never load the .d.ts, so `meta.headerClassName` would not exist for them.
26
+ declare module "@tanstack/react-table" {
27
+ // biome-ignore lint/correctness/noUnusedVariables: parameters must match the library declaration
28
+ interface ColumnMeta<TData extends RowData, TValue> {
29
+ headerClassName?: string;
30
+ cellClassName?: string;
31
+ }
32
+ }
33
+
34
+ const interactiveRowClassName = "cursor-pointer focus-visible:outline-none";
35
+
36
+ export type DataTableProps<TData, TValue = unknown> = {
37
+ columns: ColumnDef<TData, TValue>[];
38
+ data: TData[];
39
+ emptyMessage?: string;
40
+ hideHeader?: boolean;
41
+ tableOptions?: Omit<Partial<TableOptions<TData>>, "data" | "columns" | "getCoreRowModel">;
42
+ wrapperClassName?: string;
43
+ tableClassName?: string;
44
+ tableHeaderClassName?: string;
45
+ tableHeaderRowClassName?: string;
46
+ headerCellClassName?: string;
47
+ bodyCellClassName?: string;
48
+ getRowProps?: (row: Row<TData>) => Omit<ComponentProps<"tr">, "children">;
49
+ };
50
+
51
+ export function DataTable<TData, TValue = unknown>({
52
+ columns,
53
+ data,
54
+ emptyMessage = "No results.",
55
+ hideHeader = false,
56
+ tableOptions,
57
+ wrapperClassName,
58
+ tableClassName,
59
+ tableHeaderClassName,
60
+ tableHeaderRowClassName,
61
+ headerCellClassName,
62
+ bodyCellClassName,
63
+ getRowProps,
64
+ }: DataTableProps<TData, TValue>) {
65
+ const table = useReactTable({
66
+ ...tableOptions,
67
+ data,
68
+ columns,
69
+ getCoreRowModel: getCoreRowModel(),
70
+ });
71
+
72
+ const rowModel = table.getRowModel().rows;
73
+ const isEmpty = rowModel.length === 0;
74
+
75
+ const tableInner = (
76
+ <Table className={tableClassName}>
77
+ {!hideHeader ? (
78
+ <TableHeader className={tableHeaderClassName}>
79
+ {table.getHeaderGroups().map((headerGroup) => (
80
+ <TableRow key={headerGroup.id} className={tableHeaderRowClassName}>
81
+ {headerGroup.headers.map((header) => (
82
+ <TableHead
83
+ key={header.id}
84
+ className={cn(
85
+ headerCellClassName,
86
+ header.column.columnDef.meta?.headerClassName,
87
+ )}
88
+ >
89
+ {header.isPlaceholder
90
+ ? null
91
+ : flexRender(header.column.columnDef.header, header.getContext())}
92
+ </TableHead>
93
+ ))}
94
+ </TableRow>
95
+ ))}
96
+ </TableHeader>
97
+ ) : null}
98
+ <TableBody>
99
+ {isEmpty ? null : (
100
+ rowModel.map((row) => {
101
+ const extra = getRowProps?.(row);
102
+ const { className: rowClassName, ...restExtra } = extra ?? {};
103
+ return (
104
+ <TableRow
105
+ key={row.id}
106
+ data-state={row.getIsSelected() && "selected"}
107
+ {...restExtra}
108
+ className={cn(
109
+ getRowProps ? interactiveRowClassName : undefined,
110
+ rowClassName,
111
+ )}
112
+ >
113
+ {row.getVisibleCells().map((cell) => (
114
+ <TableCell
115
+ key={cell.id}
116
+ className={cn(bodyCellClassName, cell.column.columnDef.meta?.cellClassName)}
117
+ >
118
+ {flexRender(cell.column.columnDef.cell, cell.getContext())}
119
+ </TableCell>
120
+ ))}
121
+ </TableRow>
122
+ );
123
+ })
124
+ )}
125
+ </TableBody>
126
+ </Table>
127
+ );
128
+
129
+ return wrapperClassName || isEmpty ? (
130
+ <div className={cn("overflow-hidden", isEmpty && "flex flex-col", wrapperClassName)}>
131
+ {tableInner}
132
+ {isEmpty ? (
133
+ <div className="flex min-h-24 flex-1 items-center justify-center rounded-xl border border-dashed px-4 py-8 text-center text-sm text-muted-foreground">
134
+ {emptyMessage}
135
+ </div>
136
+ ) : null}
137
+ </div>
138
+ ) : (
139
+ tableInner
140
+ );
141
+ }