@toptal/picasso-table 1.1.21 → 2.0.1
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/dist-package/src/Table/Table.d.ts.map +1 -1
- package/dist-package/src/Table/Table.js +2 -8
- package/dist-package/src/Table/Table.js.map +1 -1
- package/dist-package/src/TableBody/TableBody.d.ts.map +1 -1
- package/dist-package/src/TableBody/TableBody.js +1 -6
- package/dist-package/src/TableBody/TableBody.js.map +1 -1
- package/dist-package/src/TableCell/TableCell.d.ts.map +1 -1
- package/dist-package/src/TableCell/TableCell.js +9 -13
- package/dist-package/src/TableCell/TableCell.js.map +1 -1
- package/dist-package/src/TableExpandableRow/TableExpandableRow.d.ts +1 -1
- package/dist-package/src/TableExpandableRow/TableExpandableRow.d.ts.map +1 -1
- package/dist-package/src/TableExpandableRow/TableExpandableRow.js +5 -13
- package/dist-package/src/TableExpandableRow/TableExpandableRow.js.map +1 -1
- package/dist-package/src/TableFooter/TableFooter.d.ts.map +1 -1
- package/dist-package/src/TableFooter/TableFooter.js +2 -8
- package/dist-package/src/TableFooter/TableFooter.js.map +1 -1
- package/dist-package/src/TableHead/TableHead.d.ts.map +1 -1
- package/dist-package/src/TableHead/TableHead.js +2 -6
- package/dist-package/src/TableHead/TableHead.js.map +1 -1
- package/dist-package/src/TableRow/TableRow.d.ts.map +1 -1
- package/dist-package/src/TableRow/TableRow.js +2 -10
- package/dist-package/src/TableRow/TableRow.js.map +1 -1
- package/dist-package/src/TableSectionHead/TableSectionHead.d.ts.map +1 -1
- package/dist-package/src/TableSectionHead/TableSectionHead.js +2 -8
- package/dist-package/src/TableSectionHead/TableSectionHead.js.map +1 -1
- package/package.json +11 -9
- package/src/Table/Table.tsx +7 -13
- package/src/Table/__snapshots__/test.tsx.snap +13 -16
- package/src/TableBody/TableBody.tsx +2 -15
- package/src/TableBody/__snapshots__/test.tsx.snap +5 -7
- package/src/TableCell/TableCell.tsx +24 -26
- package/src/TableCell/__snapshots__/test.tsx.snap +15 -21
- package/src/TableExpandableRow/TableExpandableRow.tsx +10 -17
- package/src/TableFooter/TableFooter.tsx +7 -13
- package/src/TableFooter/__snapshots__/test.tsx.snap +5 -5
- package/src/TableHead/TableHead.tsx +7 -11
- package/src/TableHead/__snapshots__/test.tsx.snap +5 -6
- package/src/TableRow/TableRow.tsx +11 -21
- package/src/TableRow/__snapshots__/test.tsx.snap +5 -7
- package/src/TableSectionHead/TableSectionHead.tsx +9 -11
- package/src/TableSectionHead/__snapshots__/test.tsx.snap +7 -9
- package/src/TableSortableCell/__snapshots__/test.tsx.snap +6 -6
- package/dist-package/src/Table/styles.d.ts +0 -3
- package/dist-package/src/Table/styles.d.ts.map +0 -1
- package/dist-package/src/Table/styles.js +0 -5
- package/dist-package/src/Table/styles.js.map +0 -1
- package/dist-package/src/TableBody/styles.d.ts +0 -3
- package/dist-package/src/TableBody/styles.d.ts.map +0 -1
- package/dist-package/src/TableBody/styles.js +0 -5
- package/dist-package/src/TableBody/styles.js.map +0 -1
- package/dist-package/src/TableCell/styles.d.ts +0 -3
- package/dist-package/src/TableCell/styles.d.ts.map +0 -1
- package/dist-package/src/TableCell/styles.js +0 -22
- package/dist-package/src/TableCell/styles.js.map +0 -1
- package/dist-package/src/TableExpandableRow/styles.d.ts +0 -4
- package/dist-package/src/TableExpandableRow/styles.d.ts.map +0 -1
- package/dist-package/src/TableExpandableRow/styles.js +0 -15
- package/dist-package/src/TableExpandableRow/styles.js.map +0 -1
- package/dist-package/src/TableFooter/styles.d.ts +0 -4
- package/dist-package/src/TableFooter/styles.d.ts.map +0 -1
- package/dist-package/src/TableFooter/styles.js +0 -7
- package/dist-package/src/TableFooter/styles.js.map +0 -1
- package/dist-package/src/TableHead/styles.d.ts +0 -4
- package/dist-package/src/TableHead/styles.d.ts.map +0 -1
- package/dist-package/src/TableHead/styles.js +0 -9
- package/dist-package/src/TableHead/styles.js.map +0 -1
- package/dist-package/src/TableRow/styles.d.ts +0 -4
- package/dist-package/src/TableRow/styles.d.ts.map +0 -1
- package/dist-package/src/TableRow/styles.js +0 -30
- package/dist-package/src/TableRow/styles.js.map +0 -1
- package/dist-package/src/TableSectionHead/styles.d.ts +0 -4
- package/dist-package/src/TableSectionHead/styles.d.ts.map +0 -1
- package/dist-package/src/TableSectionHead/styles.js +0 -16
- package/dist-package/src/TableSectionHead/styles.js.map +0 -1
- package/src/Table/styles.ts +0 -6
- package/src/TableBody/styles.ts +0 -6
- package/src/TableCell/styles.ts +0 -39
- package/src/TableExpandableRow/styles.ts +0 -17
- package/src/TableFooter/styles.ts +0 -9
- package/src/TableHead/styles.ts +0 -12
- package/src/TableRow/styles.ts +0 -35
- package/src/TableSectionHead/styles.ts +0 -18
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import type { HTMLAttributes, ReactNode } from 'react'
|
|
2
2
|
import React, { forwardRef, useContext } from 'react'
|
|
3
|
-
import type { Theme } from '@material-ui/core/styles'
|
|
4
|
-
import { makeStyles } from '@material-ui/core/styles'
|
|
5
|
-
import { TableCell as MUITableCell } from '@material-ui/core'
|
|
6
3
|
import type {
|
|
7
4
|
BaseProps,
|
|
8
5
|
ColorType,
|
|
@@ -10,11 +7,9 @@ import type {
|
|
|
10
7
|
TextLabelProps,
|
|
11
8
|
} from '@toptal/picasso-shared'
|
|
12
9
|
import { useTitleCase } from '@toptal/picasso-shared'
|
|
13
|
-
import cx from 'classnames'
|
|
14
|
-
import { toTitleCase } from '@toptal/picasso-utils'
|
|
15
10
|
import { Typography } from '@toptal/picasso-typography'
|
|
11
|
+
import { twMerge } from '@toptal/picasso-tailwind-merge'
|
|
16
12
|
|
|
17
|
-
import styles from './styles'
|
|
18
13
|
import { TableContext, TableSectionContext, TableSection } from '../Table'
|
|
19
14
|
|
|
20
15
|
type AlignType = 'inherit' | 'left' | 'center' | 'right' | 'justify'
|
|
@@ -32,8 +27,6 @@ export interface Props
|
|
|
32
27
|
adornment?: ReactNode
|
|
33
28
|
}
|
|
34
29
|
|
|
35
|
-
const useStyles = makeStyles<Theme>(styles, { name: 'PicassoTableCell' })
|
|
36
|
-
|
|
37
30
|
type TypographySettings = {
|
|
38
31
|
color: ColorType
|
|
39
32
|
size: SizeType<'xsmall' | 'small'>
|
|
@@ -78,35 +71,40 @@ export const TableCell = forwardRef<HTMLTableCellElement, Props>(
|
|
|
78
71
|
...rest
|
|
79
72
|
} = props
|
|
80
73
|
|
|
81
|
-
const {
|
|
82
|
-
compact: compactClass,
|
|
83
|
-
narrow: narrowClass,
|
|
84
|
-
...muiClasses
|
|
85
|
-
} = useStyles()
|
|
86
74
|
const { spacing } = useContext(TableContext)
|
|
87
75
|
const tableSection = useContext(TableSectionContext)
|
|
88
76
|
const isHead = tableSection === TableSection.HEAD
|
|
89
77
|
const titleCase = useTitleCase(propsTitleCase)
|
|
90
78
|
|
|
91
|
-
const renderChildren = () =>
|
|
92
|
-
isHead && titleCase ? toTitleCase(children) : children
|
|
93
|
-
|
|
94
79
|
const tooltipWithChildren = (
|
|
95
|
-
<Typography
|
|
96
|
-
{
|
|
80
|
+
<Typography
|
|
81
|
+
align={align}
|
|
82
|
+
as='div'
|
|
83
|
+
titleCase={isHead && titleCase}
|
|
84
|
+
{...getTypographySettings(tableSection)}
|
|
85
|
+
>
|
|
86
|
+
{children}
|
|
97
87
|
</Typography>
|
|
98
88
|
)
|
|
99
89
|
|
|
90
|
+
const Component = isHead ? 'th' : 'td'
|
|
91
|
+
|
|
92
|
+
const spacingClasses = {
|
|
93
|
+
narrow: '',
|
|
94
|
+
regular: 'px-4',
|
|
95
|
+
compact: 'h-6 py-[1px] last:pr-3',
|
|
96
|
+
}
|
|
97
|
+
|
|
100
98
|
return (
|
|
101
|
-
<
|
|
99
|
+
<Component
|
|
102
100
|
{...rest}
|
|
103
101
|
ref={ref}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
102
|
+
className={twMerge(
|
|
103
|
+
'h-10 px-2 py-2 border-none last:pr-6',
|
|
104
|
+
spacingClasses[spacing],
|
|
105
|
+
isHead && 'text-left',
|
|
106
|
+
className
|
|
107
|
+
)}
|
|
110
108
|
style={style}
|
|
111
109
|
colSpan={colSpan}
|
|
112
110
|
rowSpan={rowSpan}
|
|
@@ -119,7 +117,7 @@ export const TableCell = forwardRef<HTMLTableCellElement, Props>(
|
|
|
119
117
|
) : (
|
|
120
118
|
tooltipWithChildren
|
|
121
119
|
)}
|
|
122
|
-
</
|
|
120
|
+
</Component>
|
|
123
121
|
)
|
|
124
122
|
}
|
|
125
123
|
)
|
|
@@ -6,19 +6,17 @@ exports[`TableCell renders 1`] = `
|
|
|
6
6
|
class="Picasso-root"
|
|
7
7
|
>
|
|
8
8
|
<table
|
|
9
|
-
class="
|
|
9
|
+
class="w-full border-collapse border-spacing"
|
|
10
10
|
>
|
|
11
|
-
<tbody
|
|
12
|
-
class="MuiTableBody-root"
|
|
13
|
-
>
|
|
11
|
+
<tbody>
|
|
14
12
|
<tr
|
|
15
|
-
class="
|
|
13
|
+
class="border-0 border-solid border-b border-gray"
|
|
16
14
|
>
|
|
17
15
|
<td
|
|
18
|
-
class="
|
|
16
|
+
class="h-10 py-2 border-none last:pr-6 px-4"
|
|
19
17
|
>
|
|
20
18
|
<div
|
|
21
|
-
class="m-0 text-sm text-graphite font-inherit"
|
|
19
|
+
class="m-0 text-sm text-graphite font-inherit text-align"
|
|
22
20
|
>
|
|
23
21
|
Cell
|
|
24
22
|
</div>
|
|
@@ -36,19 +34,17 @@ exports[`TableCell renders compact 1`] = `
|
|
|
36
34
|
class="Picasso-root"
|
|
37
35
|
>
|
|
38
36
|
<table
|
|
39
|
-
class="
|
|
37
|
+
class="w-full border-collapse border-spacing"
|
|
40
38
|
>
|
|
41
|
-
<tbody
|
|
42
|
-
class="MuiTableBody-root"
|
|
43
|
-
>
|
|
39
|
+
<tbody>
|
|
44
40
|
<tr
|
|
45
|
-
class="
|
|
41
|
+
class="border-0 border-solid border-b border-gray"
|
|
46
42
|
>
|
|
47
43
|
<td
|
|
48
|
-
class="
|
|
44
|
+
class="h-10 py-2 border-none last:pr-6 px-4"
|
|
49
45
|
>
|
|
50
46
|
<div
|
|
51
|
-
class="m-0 text-sm text-graphite font-inherit"
|
|
47
|
+
class="m-0 text-sm text-graphite font-inherit text-align"
|
|
52
48
|
>
|
|
53
49
|
Cell
|
|
54
50
|
</div>
|
|
@@ -66,19 +62,17 @@ exports[`TableCell renders narrow 1`] = `
|
|
|
66
62
|
class="Picasso-root"
|
|
67
63
|
>
|
|
68
64
|
<table
|
|
69
|
-
class="
|
|
65
|
+
class="w-full border-collapse border-spacing"
|
|
70
66
|
>
|
|
71
|
-
<tbody
|
|
72
|
-
class="MuiTableBody-root"
|
|
73
|
-
>
|
|
67
|
+
<tbody>
|
|
74
68
|
<tr
|
|
75
|
-
class="
|
|
69
|
+
class="border-0 border-solid border-b border-gray"
|
|
76
70
|
>
|
|
77
71
|
<td
|
|
78
|
-
class="
|
|
72
|
+
class="h-10 py-2 border-none last:pr-6 px-4"
|
|
79
73
|
>
|
|
80
74
|
<div
|
|
81
|
-
class="m-0 text-sm text-graphite font-inherit"
|
|
75
|
+
class="m-0 text-sm text-graphite font-inherit text-align"
|
|
82
76
|
>
|
|
83
77
|
Cell
|
|
84
78
|
</div>
|
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
import type { ReactNode, HTMLAttributes } from 'react'
|
|
2
2
|
import React, { forwardRef, useRef, useEffect } from 'react'
|
|
3
|
-
import
|
|
4
|
-
import type
|
|
5
|
-
import {
|
|
6
|
-
import { Collapse as MUICollapse } from '@material-ui/core'
|
|
7
|
-
import type { BaseProps } from '@toptal/picasso-shared'
|
|
3
|
+
import { Collapse } from '@toptal/picasso-collapse'
|
|
4
|
+
import { type BaseProps } from '@toptal/picasso-shared'
|
|
5
|
+
import { twJoin } from '@toptal/picasso-tailwind-merge'
|
|
8
6
|
|
|
9
7
|
import { TableRow } from '../TableRow'
|
|
10
8
|
import { TableCell } from '../TableCell'
|
|
11
|
-
import styles from './styles'
|
|
12
9
|
|
|
13
10
|
const MAX_COL_SPAN = 100
|
|
14
11
|
|
|
15
|
-
const useStyles = makeStyles<Theme>(styles, {
|
|
16
|
-
name: 'PicassoTableExpandableRow',
|
|
17
|
-
})
|
|
18
|
-
|
|
19
12
|
export interface Props extends BaseProps, HTMLAttributes<HTMLTableRowElement> {
|
|
20
13
|
/** Should be valid `<tr>` children such as `Table.Cell`. */
|
|
21
14
|
children: ReactNode
|
|
@@ -41,7 +34,6 @@ export const TableExpandableRow = forwardRef<HTMLTableRowElement, Props>(
|
|
|
41
34
|
style,
|
|
42
35
|
...rest
|
|
43
36
|
} = props
|
|
44
|
-
const classes = useStyles()
|
|
45
37
|
|
|
46
38
|
const wasExpandedOnce = useRef(false)
|
|
47
39
|
const shouldTransition = !defaultExpanded || wasExpandedOnce.current
|
|
@@ -69,15 +61,16 @@ export const TableExpandableRow = forwardRef<HTMLTableRowElement, Props>(
|
|
|
69
61
|
{row}
|
|
70
62
|
{expanded && (
|
|
71
63
|
<TableRow
|
|
72
|
-
className={
|
|
73
|
-
|
|
74
|
-
|
|
64
|
+
className={twJoin(
|
|
65
|
+
className,
|
|
66
|
+
stripeEven && 'bg-gray-200 bg-opacity-[32]'
|
|
67
|
+
)}
|
|
75
68
|
style={style}
|
|
76
69
|
>
|
|
77
|
-
<TableCell className=
|
|
78
|
-
<
|
|
70
|
+
<TableCell className='p-0 last:pr-0' colSpan={MAX_COL_SPAN}>
|
|
71
|
+
<Collapse appear={shouldTransition} in>
|
|
79
72
|
{content}
|
|
80
|
-
</
|
|
73
|
+
</Collapse>
|
|
81
74
|
</TableCell>
|
|
82
75
|
</TableRow>
|
|
83
76
|
)}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import type { Theme } from '@material-ui/core/styles'
|
|
2
|
-
import { makeStyles } from '@material-ui/core/styles'
|
|
3
|
-
import { TableFooter as MUITableFooter } from '@material-ui/core'
|
|
4
1
|
import type { ReactNode, HTMLAttributes } from 'react'
|
|
5
2
|
import React, { forwardRef } from 'react'
|
|
6
3
|
import type { BaseProps } from '@toptal/picasso-shared'
|
|
4
|
+
import { twMerge } from '@toptal/picasso-tailwind-merge'
|
|
7
5
|
|
|
8
|
-
import styles from './styles'
|
|
9
6
|
import { TableSection, TableSectionContext } from '../Table'
|
|
10
7
|
|
|
11
8
|
export interface Props
|
|
@@ -15,26 +12,23 @@ export interface Props
|
|
|
15
12
|
children: ReactNode
|
|
16
13
|
}
|
|
17
14
|
|
|
18
|
-
const useStyles = makeStyles<Theme>(styles, {
|
|
19
|
-
name: 'PicassoTableFooter',
|
|
20
|
-
})
|
|
21
|
-
|
|
22
15
|
export const TableFooter = forwardRef<HTMLTableSectionElement, Props>(
|
|
23
16
|
function TableFooter(props, ref) {
|
|
24
17
|
const { className, style, children, ...rest } = props
|
|
25
|
-
const classes = useStyles()
|
|
26
18
|
|
|
27
19
|
return (
|
|
28
20
|
<TableSectionContext.Provider value={TableSection.FOOTER}>
|
|
29
|
-
<
|
|
21
|
+
<tfoot
|
|
30
22
|
{...rest}
|
|
31
23
|
ref={ref}
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
className={twMerge(
|
|
25
|
+
'border-0 border-solid border-t border-gray-200',
|
|
26
|
+
className
|
|
27
|
+
)}
|
|
34
28
|
style={style}
|
|
35
29
|
>
|
|
36
30
|
{children}
|
|
37
|
-
</
|
|
31
|
+
</tfoot>
|
|
38
32
|
</TableSectionContext.Provider>
|
|
39
33
|
)
|
|
40
34
|
}
|
|
@@ -6,19 +6,19 @@ exports[`TableFooter renders 1`] = `
|
|
|
6
6
|
class="Picasso-root"
|
|
7
7
|
>
|
|
8
8
|
<table
|
|
9
|
-
class="
|
|
9
|
+
class="w-full border-collapse border-spacing"
|
|
10
10
|
>
|
|
11
11
|
<tfoot
|
|
12
|
-
class="
|
|
12
|
+
class="border-0 border-solid border-t border-gray"
|
|
13
13
|
>
|
|
14
14
|
<tr
|
|
15
|
-
class="
|
|
15
|
+
class="border-0 border-solid border-b border-gray"
|
|
16
16
|
>
|
|
17
17
|
<td
|
|
18
|
-
class="
|
|
18
|
+
class="h-10 py-2 border-none last:pr-6 px-4"
|
|
19
19
|
>
|
|
20
20
|
<div
|
|
21
|
-
class="m-0 text-sm text-black font-semibold"
|
|
21
|
+
class="m-0 text-sm text-black font-semibold text-align"
|
|
22
22
|
>
|
|
23
23
|
Footer test
|
|
24
24
|
</div>
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import type { ReactNode, HTMLAttributes } from 'react'
|
|
2
2
|
import React, { forwardRef } from 'react'
|
|
3
|
-
import type { Theme } from '@material-ui/core/styles'
|
|
4
|
-
import { makeStyles } from '@material-ui/core/styles'
|
|
5
|
-
import { TableHead as MUITableHead } from '@material-ui/core'
|
|
6
3
|
import type { BaseProps } from '@toptal/picasso-shared'
|
|
4
|
+
import { twMerge } from '@toptal/picasso-tailwind-merge'
|
|
7
5
|
|
|
8
|
-
import styles from './styles'
|
|
9
6
|
import { TableSectionContext, TableSection } from '../Table'
|
|
10
7
|
|
|
11
8
|
export interface Props
|
|
@@ -15,24 +12,23 @@ export interface Props
|
|
|
15
12
|
children: ReactNode
|
|
16
13
|
}
|
|
17
14
|
|
|
18
|
-
const useStyles = makeStyles<Theme>(styles, { name: 'PicassoTableHead' })
|
|
19
|
-
|
|
20
15
|
export const TableHead = forwardRef<HTMLTableSectionElement, Props>(
|
|
21
16
|
function TableHead(props, ref) {
|
|
22
17
|
const { className, style, children, ...rest } = props
|
|
23
|
-
const classes = useStyles()
|
|
24
18
|
|
|
25
19
|
return (
|
|
26
20
|
<TableSectionContext.Provider value={TableSection.HEAD}>
|
|
27
|
-
<
|
|
21
|
+
<thead
|
|
28
22
|
{...rest}
|
|
29
23
|
ref={ref}
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
className={twMerge(
|
|
25
|
+
'border-0 border-solid border-b border-gray-200',
|
|
26
|
+
className
|
|
27
|
+
)}
|
|
32
28
|
style={style}
|
|
33
29
|
>
|
|
34
30
|
{children}
|
|
35
|
-
</
|
|
31
|
+
</thead>
|
|
36
32
|
</TableSectionContext.Provider>
|
|
37
33
|
)
|
|
38
34
|
}
|
|
@@ -6,20 +6,19 @@ exports[`TableHead renders 1`] = `
|
|
|
6
6
|
class="Picasso-root"
|
|
7
7
|
>
|
|
8
8
|
<table
|
|
9
|
-
class="
|
|
9
|
+
class="w-full border-collapse border-spacing"
|
|
10
10
|
>
|
|
11
11
|
<thead
|
|
12
|
-
class="
|
|
12
|
+
class="border-0 border-solid border-b border-gray"
|
|
13
13
|
>
|
|
14
14
|
<tr
|
|
15
|
-
class="
|
|
15
|
+
class="border-0 border-solid border-b border-gray"
|
|
16
16
|
>
|
|
17
17
|
<th
|
|
18
|
-
class="
|
|
19
|
-
scope="col"
|
|
18
|
+
class="h-10 py-2 border-none last:pr-6 px-4 text-left"
|
|
20
19
|
>
|
|
21
20
|
<div
|
|
22
|
-
class="m-0 text-xxs text-graphite font-semibold"
|
|
21
|
+
class="m-0 text-xxs text-graphite font-semibold text-align"
|
|
23
22
|
>
|
|
24
23
|
Head test
|
|
25
24
|
</div>
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import type { ReactNode, MouseEvent, HTMLAttributes } from 'react'
|
|
2
2
|
import React, { forwardRef, useContext } from 'react'
|
|
3
|
-
import cx from 'classnames'
|
|
4
|
-
import type { Theme } from '@material-ui/core/styles'
|
|
5
|
-
import { makeStyles } from '@material-ui/core/styles'
|
|
6
|
-
import { TableRow as MUITableRow } from '@material-ui/core'
|
|
7
3
|
import type { BaseProps } from '@toptal/picasso-shared'
|
|
4
|
+
import { twMerge } from '@toptal/picasso-tailwind-merge'
|
|
8
5
|
|
|
9
|
-
import styles from './styles'
|
|
10
6
|
import { TableContext } from '../Table'
|
|
11
7
|
|
|
12
8
|
export interface Props extends BaseProps, HTMLAttributes<HTMLTableRowElement> {
|
|
@@ -22,8 +18,6 @@ export interface Props extends BaseProps, HTMLAttributes<HTMLTableRowElement> {
|
|
|
22
18
|
stripeEven?: boolean
|
|
23
19
|
}
|
|
24
20
|
|
|
25
|
-
const useStyles = makeStyles<Theme>(styles, { name: 'PicassoTableRow' })
|
|
26
|
-
|
|
27
21
|
export const TableRow = forwardRef<HTMLTableRowElement, Props>(
|
|
28
22
|
function TableRow(props, ref) {
|
|
29
23
|
const {
|
|
@@ -36,30 +30,26 @@ export const TableRow = forwardRef<HTMLTableRowElement, Props>(
|
|
|
36
30
|
onClick,
|
|
37
31
|
...rest
|
|
38
32
|
} = props
|
|
39
|
-
|
|
40
|
-
stripeEven: stripeEvenClass,
|
|
41
|
-
bordered: borderedClass,
|
|
42
|
-
...muiClasses
|
|
43
|
-
} = useStyles()
|
|
33
|
+
|
|
44
34
|
const { variant } = useContext(TableContext)
|
|
45
35
|
const isBordered = variant === 'bordered' || variant === 'striped'
|
|
46
36
|
|
|
47
37
|
return (
|
|
48
|
-
<
|
|
38
|
+
<tr
|
|
49
39
|
{...rest}
|
|
50
40
|
ref={ref}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
41
|
+
className={twMerge(
|
|
42
|
+
isBordered && 'border-0 border-solid border-b border-gray-200',
|
|
43
|
+
stripeEven && 'bg-gray-100',
|
|
44
|
+
hover && 'hover:bg-blue-100 transition-colors',
|
|
45
|
+
selected && 'bg-blue-100',
|
|
46
|
+
className
|
|
47
|
+
)}
|
|
56
48
|
style={style}
|
|
57
|
-
hover={hover}
|
|
58
|
-
selected={selected}
|
|
59
49
|
onClick={onClick}
|
|
60
50
|
>
|
|
61
51
|
{children}
|
|
62
|
-
</
|
|
52
|
+
</tr>
|
|
63
53
|
)
|
|
64
54
|
}
|
|
65
55
|
)
|
|
@@ -6,19 +6,17 @@ exports[`TableRow renders 1`] = `
|
|
|
6
6
|
class="Picasso-root"
|
|
7
7
|
>
|
|
8
8
|
<table
|
|
9
|
-
class="
|
|
9
|
+
class="w-full border-collapse border-spacing"
|
|
10
10
|
>
|
|
11
|
-
<tbody
|
|
12
|
-
class="MuiTableBody-root"
|
|
13
|
-
>
|
|
11
|
+
<tbody>
|
|
14
12
|
<tr
|
|
15
|
-
class="
|
|
13
|
+
class="border-0 border-solid border-b border-gray"
|
|
16
14
|
>
|
|
17
15
|
<td
|
|
18
|
-
class="
|
|
16
|
+
class="h-10 py-2 border-none last:pr-6 px-4"
|
|
19
17
|
>
|
|
20
18
|
<div
|
|
21
|
-
class="m-0 text-sm text-graphite font-inherit"
|
|
19
|
+
class="m-0 text-sm text-graphite font-inherit text-align"
|
|
22
20
|
>
|
|
23
21
|
Row test
|
|
24
22
|
</div>
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import type { ReactElement, HTMLAttributes, FunctionComponent } from 'react'
|
|
2
2
|
import React, { forwardRef } from 'react'
|
|
3
3
|
import type { BaseProps } from '@toptal/picasso-shared'
|
|
4
|
-
import type { Theme } from '@material-ui/core/styles'
|
|
5
|
-
import { makeStyles } from '@material-ui/core/styles'
|
|
6
4
|
|
|
7
5
|
import { TableSection, TableSectionContext } from '../Table'
|
|
8
6
|
import { TableCell } from '../TableCell'
|
|
9
7
|
import { TableRow } from '../TableRow'
|
|
10
8
|
import { TableBody } from '../TableBody'
|
|
11
|
-
import styles from './styles'
|
|
12
9
|
|
|
13
10
|
const MAX_COL_SPAN = 100
|
|
14
11
|
|
|
@@ -19,24 +16,25 @@ export interface Props
|
|
|
19
16
|
icon?: ReactElement
|
|
20
17
|
}
|
|
21
18
|
|
|
22
|
-
const useStyles = makeStyles<Theme>(styles, {
|
|
23
|
-
name: 'PicassoTableSectionHead',
|
|
24
|
-
})
|
|
25
|
-
|
|
26
19
|
export const TableSectionHead: FunctionComponent<Props> = forwardRef<
|
|
27
20
|
HTMLTableSectionElement,
|
|
28
21
|
Props
|
|
29
22
|
>(function TableSectionHead(props, ref) {
|
|
30
23
|
const { colSpan, icon, children, style } = props
|
|
31
24
|
|
|
32
|
-
const classes = useStyles()
|
|
33
|
-
|
|
34
25
|
return (
|
|
35
26
|
<TableBody ref={ref}>
|
|
36
|
-
<TableRow
|
|
27
|
+
<TableRow
|
|
28
|
+
className='min-h-10 border-y border-solid border-gray-200'
|
|
29
|
+
style={style}
|
|
30
|
+
>
|
|
37
31
|
<TableSectionContext.Provider value={TableSection.HEAD}>
|
|
38
32
|
<TableCell colSpan={colSpan}>
|
|
39
|
-
{icon &&
|
|
33
|
+
{icon && (
|
|
34
|
+
<span className='inline-block align-middle mr-3 -mt-[1px]'>
|
|
35
|
+
{icon}
|
|
36
|
+
</span>
|
|
37
|
+
)}
|
|
40
38
|
{children}
|
|
41
39
|
</TableCell>
|
|
42
40
|
</TableSectionContext.Provider>
|
|
@@ -6,24 +6,22 @@ exports[`TableSectionHead renders 1`] = `
|
|
|
6
6
|
class="Picasso-root"
|
|
7
7
|
>
|
|
8
8
|
<table
|
|
9
|
-
class="
|
|
9
|
+
class="w-full border-collapse border-spacing"
|
|
10
10
|
>
|
|
11
|
-
<tbody
|
|
12
|
-
class="MuiTableBody-root"
|
|
13
|
-
>
|
|
11
|
+
<tbody>
|
|
14
12
|
<tr
|
|
15
|
-
class="
|
|
13
|
+
class="border-0 min-h border-y border-solid border-gray"
|
|
16
14
|
>
|
|
17
|
-
<
|
|
18
|
-
class="
|
|
15
|
+
<th
|
|
16
|
+
class="h-10 py-2 border-none last:pr-6 px-4 text-left"
|
|
19
17
|
colspan="100"
|
|
20
18
|
>
|
|
21
19
|
<div
|
|
22
|
-
class="m-0 text-xxs text-graphite font-semibold"
|
|
20
|
+
class="m-0 text-xxs text-graphite font-semibold text-align"
|
|
23
21
|
>
|
|
24
22
|
Test
|
|
25
23
|
</div>
|
|
26
|
-
</
|
|
24
|
+
</th>
|
|
27
25
|
</tr>
|
|
28
26
|
</tbody>
|
|
29
27
|
</table>
|
|
@@ -9,13 +9,13 @@ exports[`TableCell sort direction is asc renders with a sort button in the right
|
|
|
9
9
|
<tbody>
|
|
10
10
|
<tr>
|
|
11
11
|
<td
|
|
12
|
-
class="
|
|
12
|
+
class="h-10 py-2 border-none last:pr-6 px-4 group hover:bg-gray"
|
|
13
13
|
>
|
|
14
14
|
<div
|
|
15
15
|
class="flex items-center"
|
|
16
16
|
>
|
|
17
17
|
<div
|
|
18
|
-
class="m-0 text-sm text-graphite font-inherit"
|
|
18
|
+
class="m-0 text-sm text-graphite font-inherit text-align"
|
|
19
19
|
>
|
|
20
20
|
Cell
|
|
21
21
|
</div>
|
|
@@ -28,7 +28,7 @@ exports[`TableCell sort direction is asc renders with a sort button in the right
|
|
|
28
28
|
type="button"
|
|
29
29
|
>
|
|
30
30
|
<span
|
|
31
|
-
class="
|
|
31
|
+
class="items-center inline-flex font-semibold whitespace-nowrap text-button"
|
|
32
32
|
>
|
|
33
33
|
<svg
|
|
34
34
|
class="PicassoSvgArrowLongUp16-root text-[1.2em] flex-1"
|
|
@@ -59,13 +59,13 @@ exports[`TableCell sort direction is desc renders with a sort button in the righ
|
|
|
59
59
|
<tbody>
|
|
60
60
|
<tr>
|
|
61
61
|
<td
|
|
62
|
-
class="
|
|
62
|
+
class="h-10 py-2 border-none last:pr-6 px-4 group hover:bg-gray"
|
|
63
63
|
>
|
|
64
64
|
<div
|
|
65
65
|
class="flex items-center"
|
|
66
66
|
>
|
|
67
67
|
<div
|
|
68
|
-
class="m-0 text-sm text-graphite font-inherit"
|
|
68
|
+
class="m-0 text-sm text-graphite font-inherit text-align"
|
|
69
69
|
/>
|
|
70
70
|
<button
|
|
71
71
|
aria-disabled="false"
|
|
@@ -76,7 +76,7 @@ exports[`TableCell sort direction is desc renders with a sort button in the righ
|
|
|
76
76
|
type="button"
|
|
77
77
|
>
|
|
78
78
|
<span
|
|
79
|
-
class="
|
|
79
|
+
class="items-center inline-flex font-semibold whitespace-nowrap text-button"
|
|
80
80
|
>
|
|
81
81
|
<svg
|
|
82
82
|
class="PicassoSvgArrowLongDown16-root text-[1.2em] flex-1"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/Table/styles.ts"],"names":[],"mappings":";AAKA,wBAAqC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/Table/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAE1D,eAAe,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AAEpC,eAAe,GAAG,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/TableBody/styles.ts"],"names":[],"mappings":";AAKA,wBAAqC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/TableBody/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAE1D,eAAe,CAAC,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AAEpC,eAAe,GAAG,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/TableCell/styles.ts"],"names":[],"mappings":";AAiCA,wBAKI"}
|