|
1
|
import React from "react" |
|
2
|
import { Table as UiTable } from "@medusajs/ui" |
|
3
|
import clsx from "clsx" |
|
4
|
|
|
5
|
type RootProps = React.HTMLAttributes<HTMLTableElement> |
|
6
|
|
|
7
|
const Root = ({ className, ...props }: RootProps) => { |
|
8
|
return ( |
|
9
|
<UiTable |
|
10
|
className={clsx( |
|
11
|
className, |
|
12
|
"table-fixed mb-docs_1", |
|
13
|
"[&_pre_span]:!max-w-full [&_pre_span]:!break-words [&_pre_span]:!whitespace-break-spaces", |
|
14
|
"[&_pre>div]:mt-docs_1", |
|
15
|
"shadow-elevation-card-rest dark:shadow-elevation-card-rest-dark", |
|
16
|
"rounded-docs_DEFAULT" |
|
17
|
)} |
|
18
|
{...props} |
|
19
|
/> |
|
20
|
) |
|
21
|
} |
|
22
|
|
|
23
|
type HeaderProps = React.HTMLAttributes<HTMLTableSectionElement> |
|
24
|
|
|
25
|
const Header = ({ className, ...props }: HeaderProps) => { |
|
26
|
return ( |
|
27
|
<UiTable.Header |
|
28
|
className={clsx( |
|
29
|
className, |
|
30
|
"!border-0 bg-medusa-bg-component [&_tr]:!bg-medusa-bg-component", |
|
31
|
"rounded-docs_DEFAULT [&_tr]:rounded-docs_DEFAULT" |
|
32
|
)} |
|
33
|
{...props} |
|
34
|
/> |
|
35
|
) |
|
36
|
} |
|
37
|
|
|
38
|
type HeaderCellProps = React.HTMLAttributes<HTMLTableCellElement> |
|
39
|
|
|
40
|
const HeaderCell = ({ className, ...props }: HeaderCellProps) => { |
|
41
|
return ( |
|
42
|
<UiTable.HeaderCell |
|
43
|
className={clsx( |
|
44
|
className, |
|
45
|
"text-left !px-docs_0.75 py-docs_0.5 break-words", |
|
46
|
"!text-compact-small-plus text-medusa-fg-subtle", |
|
47
|
"first:rounded-tl-docs_DEFAULT last:rounded-tr-docs_DEFAULT" |
|
48
|
)} |
|
49
|
{...props} |
|
50
|
/> |
|
51
|
) |
|
52
|
} |
|
53
|
|
|
54
|
type CellProps = React.HTMLAttributes<HTMLTableCellElement> |
|
55
|
|
|
56
|
const Cell = ({ className, ...props }: CellProps) => { |
|
57
|
return ( |
|
58
|
<UiTable.Cell |
|
59
|
className={clsx( |
|
60
|
className, |
|
61
|
"!px-docs_0.75 py-docs_0.5 break-words align-top" |
|
62
|
)} |
|
63
|
{...props} |
|
64
|
/> |
|
65
|
) |
|
66
|
} |
|
67
|
|
|
68
|
type BodyProps = React.HTMLAttributes<HTMLTableSectionElement> |
|
69
|
|
|
70
|
const Body = ({ className, ...props }: BodyProps) => { |
|
71
|
return ( |
|
72
|
<UiTable.Body |
|
73
|
className={clsx(className, "[&_tr:last-child]:border-b-0 border-b-0")} |
|
74
|
{...props} |
|
75
|
/> |
|
76
|
) |
|
77
|
} |
|
78
|
|
|
79
|
const Table = Object.assign(Root, { |
|
80
|
Row: UiTable.Row, |
|
81
|
Cell, |
|
82
|
Header, |
|
83
|
HeaderCell, |
|
84
|
Body, |
|
85
|
}) |
|
86
|
|
|
87
|
export { Table } |