@coveord/plasma-mantine 52.24.1 → 52.25.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.
- package/.turbo/turbo-build.log +3 -3
- package/.turbo/turbo-test.log +31 -31
- package/dist/.tsbuildinfo +1 -1
- package/dist/cjs/components/table/layouts/RowLayout.styles.d.ts.map +1 -1
- package/dist/cjs/components/table/layouts/RowLayout.styles.js +0 -3
- package/dist/cjs/components/table/layouts/RowLayout.styles.js.map +1 -1
- package/dist/cjs/components/table/table-header/Th.d.ts +1 -1
- package/dist/cjs/components/table/table-header/Th.d.ts.map +1 -1
- package/dist/cjs/components/table/table-header/Th.js +38 -35
- package/dist/cjs/components/table/table-header/Th.js.map +1 -1
- package/dist/cjs/components/table/table-header/Th.styles.d.ts +4 -3
- package/dist/cjs/components/table/table-header/Th.styles.d.ts.map +1 -1
- package/dist/cjs/components/table/table-header/Th.styles.js +16 -13
- package/dist/cjs/components/table/table-header/Th.styles.js.map +1 -1
- package/dist/cjs/components/table/table-header/Th.types.d.ts +6 -1
- package/dist/cjs/components/table/table-header/Th.types.d.ts.map +1 -1
- package/dist/esm/components/table/layouts/RowLayout.styles.d.ts.map +1 -1
- package/dist/esm/components/table/layouts/RowLayout.styles.js +0 -3
- package/dist/esm/components/table/layouts/RowLayout.styles.js.map +1 -1
- package/dist/esm/components/table/table-header/Th.d.ts +1 -1
- package/dist/esm/components/table/table-header/Th.d.ts.map +1 -1
- package/dist/esm/components/table/table-header/Th.js +39 -36
- package/dist/esm/components/table/table-header/Th.js.map +1 -1
- package/dist/esm/components/table/table-header/Th.styles.d.ts +4 -3
- package/dist/esm/components/table/table-header/Th.styles.d.ts.map +1 -1
- package/dist/esm/components/table/table-header/Th.styles.js +16 -13
- package/dist/esm/components/table/table-header/Th.styles.js.map +1 -1
- package/dist/esm/components/table/table-header/Th.types.d.ts +6 -1
- package/dist/esm/components/table/table-header/Th.types.d.ts.map +1 -1
- package/dist/esm/components/table/table-header/Th.types.js.map +1 -1
- package/package.json +3 -3
- package/src/components/table/__tests__/Th.spec.tsx +4 -6
- package/src/components/table/layouts/RowLayout.styles.ts +0 -4
- package/src/components/table/table-header/Th.styles.ts +23 -12
- package/src/components/table/table-header/Th.tsx +31 -26
- package/src/components/table/table-header/Th.types.ts +7 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coveord/plasma-mantine",
|
|
3
|
-
"version": "52.
|
|
3
|
+
"version": "52.25.0",
|
|
4
4
|
"description": "A Plasma flavoured Mantine theme",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"plasma",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"lodash.debounce": "4.0.8",
|
|
42
42
|
"lodash.defaultsdeep": "4.6.1",
|
|
43
43
|
"monaco-editor": "0.41.0",
|
|
44
|
-
"@coveord/plasma-
|
|
45
|
-
"@coveord/plasma-
|
|
44
|
+
"@coveord/plasma-react-icons": "52.23.1",
|
|
45
|
+
"@coveord/plasma-tokens": "52.23.1"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@emotion/react": "11.11.1",
|
|
@@ -22,9 +22,7 @@ describe('Th', () => {
|
|
|
22
22
|
];
|
|
23
23
|
render(<Table data={data} columns={columns} />);
|
|
24
24
|
|
|
25
|
-
const headers = screen.getAllByRole('
|
|
26
|
-
expect(headers.length).toBe(2);
|
|
27
|
-
|
|
25
|
+
const headers = screen.getAllByRole('columnheader');
|
|
28
26
|
expect(headers[0]).toHaveAccessibleName(/name doubleArrowHead/i);
|
|
29
27
|
expect(headers[1]).toHaveAccessibleName(/type doubleArrowHead/i);
|
|
30
28
|
});
|
|
@@ -38,17 +36,17 @@ describe('Th', () => {
|
|
|
38
36
|
const onChange = vi.fn();
|
|
39
37
|
render(<Table data={data} columns={columns} onChange={onChange} />);
|
|
40
38
|
|
|
41
|
-
await user.click(screen.getByRole('
|
|
39
|
+
await user.click(screen.getByRole('columnheader', {name: /name doubleArrowHead/i}));
|
|
42
40
|
await waitFor(() => {
|
|
43
41
|
expect(onChange).toHaveBeenCalledWith(expect.objectContaining({sorting: [{id: 'name', desc: false}]}));
|
|
44
42
|
});
|
|
45
43
|
|
|
46
|
-
await user.click(screen.getByRole('
|
|
44
|
+
await user.click(screen.getByRole('columnheader', {name: /name arrowUp/i}));
|
|
47
45
|
await waitFor(() => {
|
|
48
46
|
expect(onChange).toHaveBeenCalledWith(expect.objectContaining({sorting: [{id: 'name', desc: true}]}));
|
|
49
47
|
});
|
|
50
48
|
|
|
51
|
-
await user.click(screen.getByRole('
|
|
49
|
+
await user.click(screen.getByRole('columnheader', {name: /name arrowDown/i}));
|
|
52
50
|
await waitFor(() => {
|
|
53
51
|
expect(onChange).toHaveBeenCalledWith(expect.objectContaining({sorting: [{id: 'name', desc: false}]}));
|
|
54
52
|
});
|
|
@@ -10,10 +10,6 @@ export default createStyles<string, RowLayoutStylesParams>((theme, {multiRowSele
|
|
|
10
10
|
const border = `${rem(1)} solid ${theme.colorScheme === 'dark' ? theme.colors.dark[4] : theme.colors.gray[3]}`;
|
|
11
11
|
return {
|
|
12
12
|
headerColumns: {
|
|
13
|
-
'& th:first-of-type > *': {
|
|
14
|
-
paddingLeft: '40px',
|
|
15
|
-
},
|
|
16
|
-
|
|
17
13
|
'& input[type=checkbox]': {
|
|
18
14
|
backgroundColor: disableRowSelection ? `${theme.colors.gray[2]}` : undefined,
|
|
19
15
|
borderColor: disableRowSelection ? `${theme.colors.gray[3]}` : `${theme.colors.gray[4]}`,
|
|
@@ -1,25 +1,36 @@
|
|
|
1
1
|
import {createStyles} from '@mantine/core';
|
|
2
2
|
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
export interface ThStyleParams {
|
|
4
|
+
size: number;
|
|
5
|
+
minSize: number;
|
|
6
|
+
maxSize: number;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export default createStyles((theme, {maxSize, minSize, size}: ThStyleParams) => ({
|
|
10
|
+
root: {
|
|
11
|
+
padding: `${theme.spacing.xs} ${theme.spacing.sm}`,
|
|
7
12
|
verticalAlign: 'middle',
|
|
8
13
|
whiteSpace: 'nowrap',
|
|
9
14
|
textAlign: 'left',
|
|
10
15
|
color: theme.colors.gray[6],
|
|
11
16
|
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.gray[8] : theme.colors.gray[0],
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
height: theme.spacing.xl,
|
|
18
|
+
width: size ?? 'auto',
|
|
19
|
+
minWidth: minSize,
|
|
20
|
+
maxWidth: maxSize,
|
|
21
|
+
fontWeight: 500,
|
|
22
|
+
fontSize: theme.fontSizes.xs,
|
|
23
|
+
|
|
24
|
+
'&:first-of-type': {
|
|
25
|
+
paddingLeft: theme.spacing.xl,
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
'&:last-of-type': {
|
|
29
|
+
paddingRight: theme.spacing.xl,
|
|
30
|
+
},
|
|
15
31
|
},
|
|
16
32
|
|
|
17
33
|
control: {
|
|
18
|
-
color: 'inherit',
|
|
19
|
-
whiteSpace: 'inherit',
|
|
20
|
-
fontWeight: 'inherit',
|
|
21
|
-
width: '100%',
|
|
22
|
-
padding: `${theme.spacing.xs} ${theme.spacing.sm}`,
|
|
23
34
|
'&:hover': {
|
|
24
35
|
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.gray[7] : theme.colors.gray[1],
|
|
25
36
|
},
|
|
@@ -1,22 +1,33 @@
|
|
|
1
1
|
import {ArrowDownSize16Px, ArrowUpSize16Px, DoubleArrowHeadVSize16Px} from '@coveord/plasma-react-icons';
|
|
2
|
-
import {
|
|
2
|
+
import {Group, UnstyledButton, useComponentDefaultProps} from '@mantine/core';
|
|
3
3
|
import {defaultColumnSizing, flexRender} from '@tanstack/react-table';
|
|
4
|
+
import {AriaAttributes} from 'react';
|
|
4
5
|
import useStyles from './Th.styles';
|
|
5
|
-
import {ThProps} from './Th.types';
|
|
6
|
+
import {SortState, ThProps} from './Th.types';
|
|
6
7
|
|
|
7
|
-
const SortingIcons = {
|
|
8
|
+
const SortingIcons: ThProps['sortingIcons'] = {
|
|
8
9
|
asc: ArrowUpSize16Px,
|
|
9
10
|
desc: ArrowDownSize16Px,
|
|
10
11
|
none: DoubleArrowHeadVSize16Px,
|
|
11
12
|
};
|
|
12
13
|
|
|
13
|
-
const SortingLabels = {
|
|
14
|
+
const SortingLabels: Record<SortState, AriaAttributes['aria-sort']> = {
|
|
14
15
|
asc: 'ascending',
|
|
15
16
|
desc: 'descending',
|
|
16
17
|
none: 'none',
|
|
17
18
|
} as const;
|
|
18
19
|
|
|
19
|
-
|
|
20
|
+
const defaultProps: Partial<ThProps> = {
|
|
21
|
+
sortingIcons: SortingIcons,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const Th = <T,>(props: ThProps<T>) => {
|
|
25
|
+
const {header, classNames, styles, unstyled, sortingIcons, ...others} = useComponentDefaultProps(
|
|
26
|
+
'PlasmaTableColumnHeader',
|
|
27
|
+
defaultProps as Partial<ThProps<T>>,
|
|
28
|
+
props,
|
|
29
|
+
);
|
|
30
|
+
|
|
20
31
|
const columnSizing = {
|
|
21
32
|
...defaultColumnSizing,
|
|
22
33
|
size: header.column.columnDef.size,
|
|
@@ -24,38 +35,32 @@ export const Th = <T,>({header}: ThProps<T>) => {
|
|
|
24
35
|
maxSize: header.column.columnDef.maxSize,
|
|
25
36
|
};
|
|
26
37
|
|
|
27
|
-
const {classes} = useStyles(columnSizing);
|
|
38
|
+
const {classes, cx} = useStyles(columnSizing, {name: 'PlasmaTableColumnHeader', classNames, styles, unstyled});
|
|
28
39
|
|
|
29
40
|
if (header.isPlaceholder) {
|
|
30
41
|
return null;
|
|
31
42
|
}
|
|
32
43
|
|
|
33
44
|
if (!header.column.getCanSort()) {
|
|
34
|
-
return (
|
|
35
|
-
<th className={classes.th}>
|
|
36
|
-
<Text size="xs" py="xs" px="sm" fw={500}>
|
|
37
|
-
{flexRender(header.column.columnDef.header, header.getContext())}
|
|
38
|
-
</Text>
|
|
39
|
-
</th>
|
|
40
|
-
);
|
|
45
|
+
return <th className={classes.root}>{flexRender(header.column.columnDef.header, header.getContext())}</th>;
|
|
41
46
|
}
|
|
42
47
|
|
|
43
48
|
const onSort = header.column.getToggleSortingHandler();
|
|
44
49
|
const sortingOrder = header.column.getIsSorted() || 'none';
|
|
45
|
-
const Icon =
|
|
50
|
+
const Icon = sortingIcons[sortingOrder];
|
|
46
51
|
|
|
47
52
|
return (
|
|
48
|
-
<
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
</
|
|
59
|
-
</
|
|
53
|
+
<UnstyledButton
|
|
54
|
+
component="th"
|
|
55
|
+
onClick={onSort}
|
|
56
|
+
className={cx(classes.root, classes.control)}
|
|
57
|
+
aria-sort={SortingLabels[sortingOrder]}
|
|
58
|
+
{...others}
|
|
59
|
+
>
|
|
60
|
+
<Group noWrap spacing="xs">
|
|
61
|
+
{flexRender(header.column.columnDef.header, header.getContext())}
|
|
62
|
+
<Icon height={16} width={16} />
|
|
63
|
+
</Group>
|
|
64
|
+
</UnstyledButton>
|
|
60
65
|
);
|
|
61
66
|
};
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
import {DefaultProps, Selectors} from '@mantine/core';
|
|
1
2
|
import {Header} from '@tanstack/react-table';
|
|
3
|
+
import {ComponentType, SVGProps} from 'react';
|
|
4
|
+
import useStyles from './Th.styles';
|
|
2
5
|
|
|
3
|
-
export
|
|
6
|
+
export type SortState = 'asc' | 'desc' | 'none';
|
|
7
|
+
|
|
8
|
+
export interface ThProps<T = unknown> extends DefaultProps<Selectors<typeof useStyles>> {
|
|
4
9
|
header: Header<T, unknown>;
|
|
10
|
+
sortingIcons?: Record<SortState, ComponentType<SVGProps<SVGSVGElement>>>;
|
|
5
11
|
}
|