@coveord/plasma-mantine 47.9.3 → 48.1.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 (76) hide show
  1. package/.turbo/turbo-build.log +3 -3
  2. package/.turbo/turbo-test.log +8 -8
  3. package/dist/.tsbuildinfo +1 -1
  4. package/dist/cjs/__tests__/Utils.js.map +1 -1
  5. package/dist/cjs/components/blank-slate/BlankSlate.js.map +1 -1
  6. package/dist/cjs/components/collection/Collection.js +9 -4
  7. package/dist/cjs/components/collection/Collection.js.map +1 -1
  8. package/dist/cjs/components/collection/CollectionItem.js.map +1 -1
  9. package/dist/cjs/components/header/Header.js.map +1 -1
  10. package/dist/cjs/components/inline-confirm/InlineConfirm.js.map +1 -1
  11. package/dist/cjs/components/modal-wizard/ModalWizardStep.js.map +1 -1
  12. package/dist/cjs/components/prompt/PromptFooter.js.map +1 -1
  13. package/dist/cjs/components/sticky-footer/StickyFooter.js.map +1 -1
  14. package/dist/cjs/components/table/Table.js +45 -39
  15. package/dist/cjs/components/table/Table.js.map +1 -1
  16. package/dist/cjs/components/table/TableFooter.js.map +1 -1
  17. package/dist/cjs/components/table/TableHeader.js.map +1 -1
  18. package/dist/cjs/theme/Plasmantine.js.map +1 -1
  19. package/dist/definitions/__tests__/Utils.d.ts.map +1 -1
  20. package/dist/definitions/components/blank-slate/BlankSlate.d.ts +2 -2
  21. package/dist/definitions/components/blank-slate/BlankSlate.d.ts.map +1 -1
  22. package/dist/definitions/components/collection/Collection.d.ts +1 -0
  23. package/dist/definitions/components/collection/Collection.d.ts.map +1 -1
  24. package/dist/definitions/components/collection/CollectionItem.d.ts +2 -2
  25. package/dist/definitions/components/collection/CollectionItem.d.ts.map +1 -1
  26. package/dist/definitions/components/header/Header.d.ts +2 -2
  27. package/dist/definitions/components/header/Header.d.ts.map +1 -1
  28. package/dist/definitions/components/inline-confirm/InlineConfirm.d.ts +2 -2
  29. package/dist/definitions/components/inline-confirm/InlineConfirm.d.ts.map +1 -1
  30. package/dist/definitions/components/modal-wizard/ModalWizardStep.d.ts +2 -2
  31. package/dist/definitions/components/modal-wizard/ModalWizardStep.d.ts.map +1 -1
  32. package/dist/definitions/components/prompt/PromptFooter.d.ts +2 -2
  33. package/dist/definitions/components/prompt/PromptFooter.d.ts.map +1 -1
  34. package/dist/definitions/components/sticky-footer/StickyFooter.d.ts +2 -2
  35. package/dist/definitions/components/sticky-footer/StickyFooter.d.ts.map +1 -1
  36. package/dist/definitions/components/table/Table.d.ts.map +1 -1
  37. package/dist/definitions/components/table/TableFooter.d.ts +2 -2
  38. package/dist/definitions/components/table/TableFooter.d.ts.map +1 -1
  39. package/dist/definitions/components/table/TableHeader.d.ts +2 -2
  40. package/dist/definitions/components/table/TableHeader.d.ts.map +1 -1
  41. package/dist/definitions/theme/Plasmantine.d.ts +2 -2
  42. package/dist/definitions/theme/Plasmantine.d.ts.map +1 -1
  43. package/dist/esm/__tests__/Utils.js.map +1 -1
  44. package/dist/esm/components/blank-slate/BlankSlate.js.map +1 -1
  45. package/dist/esm/components/collection/Collection.js +9 -4
  46. package/dist/esm/components/collection/Collection.js.map +1 -1
  47. package/dist/esm/components/collection/CollectionItem.js.map +1 -1
  48. package/dist/esm/components/header/Header.js.map +1 -1
  49. package/dist/esm/components/inline-confirm/InlineConfirm.js.map +1 -1
  50. package/dist/esm/components/modal-wizard/ModalWizardStep.js.map +1 -1
  51. package/dist/esm/components/prompt/PromptFooter.js.map +1 -1
  52. package/dist/esm/components/sticky-footer/StickyFooter.js.map +1 -1
  53. package/dist/esm/components/table/Table.js +47 -41
  54. package/dist/esm/components/table/Table.js.map +1 -1
  55. package/dist/esm/components/table/TableFooter.js.map +1 -1
  56. package/dist/esm/components/table/TableHeader.js.map +1 -1
  57. package/dist/esm/theme/Plasmantine.js.map +1 -1
  58. package/package.json +19 -20
  59. package/src/__tests__/Utils.tsx +2 -2
  60. package/src/components/blank-slate/BlankSlate.tsx +2 -2
  61. package/src/components/collection/Collection.tsx +8 -1
  62. package/src/components/collection/CollectionItem.tsx +9 -5
  63. package/src/components/collection/__tests__/Collection.spec.tsx +27 -0
  64. package/src/components/header/Header.tsx +2 -2
  65. package/src/components/inline-confirm/InlineConfirm.tsx +2 -2
  66. package/src/components/modal-wizard/ModalWizardStep.tsx +4 -2
  67. package/src/components/modal-wizard/__tests__/ModalWizard.spec.tsx +1 -1
  68. package/src/components/prompt/PromptFooter.tsx +2 -2
  69. package/src/components/sticky-footer/StickyFooter.tsx +6 -2
  70. package/src/components/table/Table.tsx +42 -36
  71. package/src/components/table/TableFooter.tsx +2 -2
  72. package/src/components/table/TableHeader.tsx +2 -2
  73. package/src/components/table/__tests__/Table.spec.tsx +27 -0
  74. package/src/components/table/__tests__/Th.spec.tsx +2 -1
  75. package/src/hooks/__tests__/useControlledList.spec.tsx +1 -1
  76. package/src/theme/Plasmantine.tsx +2 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coveord/plasma-mantine",
3
- "version": "47.9.3",
3
+ "version": "48.1.0",
4
4
  "description": "A Plasma flavoured Mantine theme",
5
5
  "keywords": [
6
6
  "plasma",
@@ -21,7 +21,7 @@
21
21
  "module": "dist/esm/index.js",
22
22
  "types": "./dist/definitions/index.d.ts",
23
23
  "dependencies": {
24
- "@coveord/plasma-react-icons": "47.3.7",
24
+ "@coveord/plasma-react-icons": "48.0.0",
25
25
  "@coveord/plasma-tokens": "47.3.7",
26
26
  "@monaco-editor/react": "4.4.5",
27
27
  "@swc/helpers": "0.4.11",
@@ -30,7 +30,7 @@
30
30
  "dayjs": "1.11.3",
31
31
  "lodash.defaultsdeep": "4.6.1",
32
32
  "monaco-editor": "0.34.0",
33
- "react-beautiful-dnd": "13.1.0"
33
+ "react-beautiful-dnd": "13.1.1"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@emotion/react": "11.10.0",
@@ -42,31 +42,30 @@
42
42
  "@mantine/modals": "5.6.2",
43
43
  "@swc/cli": "0.1.57",
44
44
  "@swc/core": "1.3.3",
45
- "@swc/jest": "0.2.22",
46
- "@testing-library/dom": "8.13.0",
45
+ "@swc/jest": "0.2.23",
46
+ "@testing-library/dom": "8.18.1",
47
47
  "@testing-library/jest-dom": "5.16.5",
48
- "@testing-library/react": "11.2.7",
49
- "@testing-library/react-hooks": "8.0.1",
48
+ "@testing-library/react": "13.4.0",
50
49
  "@testing-library/user-event": "12.8.3",
51
- "@types/jest": "27.5.2",
50
+ "@types/jest": "29.1.2",
52
51
  "@types/lodash.defaultsdeep": "4.6.7",
53
- "@types/react": "17.0.44",
52
+ "@types/react": "18.0.21",
54
53
  "@types/react-beautiful-dnd": "13.1.2",
55
- "@types/react-dom": "17.0.15",
54
+ "@types/react-dom": "18.0.6",
56
55
  "@types/testing-library__jest-dom": "5.14.5",
57
56
  "embla-carousel-react": "7.0.4",
58
- "eslint-plugin-jest": "26.1.5",
59
- "eslint-plugin-testing-library": "5.5.1",
57
+ "eslint-plugin-jest": "27.1.1",
58
+ "eslint-plugin-testing-library": "5.7.2",
60
59
  "identity-obj-proxy": "3.0.0",
61
- "jest": "28.1.2",
62
- "jest-environment-jsdom": "28.1.2",
60
+ "jest": "29.2.1",
61
+ "jest-environment-jsdom": "29.1.2",
63
62
  "jest-junit": "13.2.0",
64
63
  "npm-run-all": "4.1.5",
65
- "react": "17.0.2",
66
- "react-dom": "17.0.2",
64
+ "react": "18.2.0",
65
+ "react-dom": "18.2.0",
67
66
  "rimraf": "3.0.2",
68
- "tslib": "2.3.1",
69
- "typescript": "4.6.4"
67
+ "tslib": "2.4.0",
68
+ "typescript": "4.7.4"
70
69
  },
71
70
  "peerDependencies": {
72
71
  "@emotion/react": "^11.10.0",
@@ -77,8 +76,8 @@
77
76
  "@mantine/hooks": "^5.6.2",
78
77
  "@mantine/modals": "^5.6.2",
79
78
  "embla-carousel-react": "7.0.4",
80
- "react": ">= 17.0.2",
81
- "react-dom": ">= 17.0.2"
79
+ "react": ">= 18.0.0",
80
+ "react-dom": ">= 18.0.0"
82
81
  },
83
82
  "scripts": {
84
83
  "build": "node ../../scripts/build",
@@ -1,11 +1,11 @@
1
1
  import {render, RenderOptions, RenderResult} from '@testing-library/react';
2
2
  import userEvent from '@testing-library/user-event';
3
- import {FunctionComponent, ReactElement} from 'react';
3
+ import {FunctionComponent, PropsWithChildren, ReactElement} from 'react';
4
4
 
5
5
  import {Plasmantine} from '../theme';
6
6
 
7
7
  const customRender = (ui: ReactElement, options?: Omit<RenderOptions, 'queries'>): RenderResult => {
8
- const TestWrapper: FunctionComponent = ({children}) => <Plasmantine>{children}</Plasmantine>;
8
+ const TestWrapper: FunctionComponent<PropsWithChildren> = ({children}) => <Plasmantine>{children}</Plasmantine>;
9
9
 
10
10
  return render(ui, {wrapper: TestWrapper, ...options});
11
11
  };
@@ -1,5 +1,5 @@
1
1
  import {Paper, Stack} from '@mantine/core';
2
- import {FunctionComponent} from 'react';
2
+ import {FunctionComponent, PropsWithChildren} from 'react';
3
3
 
4
4
  interface BlankSlateProps {
5
5
  /**
@@ -10,7 +10,7 @@ interface BlankSlateProps {
10
10
  withBorder?: boolean;
11
11
  }
12
12
 
13
- export const BlankSlate: FunctionComponent<BlankSlateProps> = ({children, withBorder = true}) => (
13
+ export const BlankSlate: FunctionComponent<PropsWithChildren<BlankSlateProps>> = ({children, withBorder = true}) => (
14
14
  <Paper shadow={withBorder && 'xs'} p="xl" withBorder={withBorder}>
15
15
  <Stack align="center">{children}</Stack>
16
16
  </Paper>
@@ -25,6 +25,7 @@ interface CollectionProps<T> extends DefaultProps<Selectors<typeof useStyles>> {
25
25
  value?: T[];
26
26
  onFocus?: () => void;
27
27
  onChange?: (value: T[]) => void;
28
+ onRemoveItem?: (itemIndex: number) => void;
28
29
  draggable?: boolean;
29
30
  disabled?: boolean;
30
31
  allowAdd?: (values: T[]) => boolean;
@@ -48,6 +49,7 @@ export const Collection = <T,>(props: CollectionProps<T>) => {
48
49
  value,
49
50
  defaultValue,
50
51
  onChange,
52
+ onRemoveItem,
51
53
  disabled,
52
54
  draggable,
53
55
  children,
@@ -71,13 +73,18 @@ export const Collection = <T,>(props: CollectionProps<T>) => {
71
73
 
72
74
  const [values, {append, remove, reorder}] = useControlledList({value, onChange, defaultValue});
73
75
  const hasOnlyOneItem = values.length === 1;
76
+ const removeItem = (index: number) => () => {
77
+ remove(index);
78
+ onRemoveItem?.(index);
79
+ };
80
+
74
81
  const items = values.map((item, index) => (
75
82
  <CollectionItem
76
83
  key={index}
77
84
  disabled={disabled}
78
85
  draggable={draggable}
79
86
  index={index}
80
- onRemove={() => remove(index)}
87
+ onRemove={removeItem(index)}
81
88
  styles={styles}
82
89
  removable={!(required && hasOnlyOneItem)}
83
90
  >
@@ -1,6 +1,6 @@
1
1
  import {DragAndDropSize16Px, RemoveSize16Px} from '@coveord/plasma-react-icons';
2
2
  import {ActionIcon, DefaultProps, Group, Selectors} from '@mantine/core';
3
- import {FunctionComponent} from 'react';
3
+ import {FunctionComponent, PropsWithChildren} from 'react';
4
4
  import {Draggable} from 'react-beautiful-dnd';
5
5
 
6
6
  import useStyles from './Colllection.styles';
@@ -26,7 +26,7 @@ const RemoveButton: FunctionComponent<{
26
26
 
27
27
  const RemoveButtonPlaceholder = () => <div style={{width: 28}} />;
28
28
 
29
- const StaticCollectionItem: FunctionComponent<CollectionItemSharedProps> = ({
29
+ const StaticCollectionItem: FunctionComponent<PropsWithChildren<CollectionItemSharedProps>> = ({
30
30
  onRemove,
31
31
  removable = true,
32
32
  styles,
@@ -43,12 +43,12 @@ const StaticCollectionItem: FunctionComponent<CollectionItemSharedProps> = ({
43
43
  );
44
44
  };
45
45
 
46
- const DisabledCollectionItem: FunctionComponent<CollectionItemSharedProps> = ({children}) => {
46
+ const DisabledCollectionItem: FunctionComponent<PropsWithChildren<CollectionItemSharedProps>> = ({children}) => {
47
47
  const {classes, cx} = useStyles();
48
48
  return <Group className={cx(classes.item)}>{children}</Group>;
49
49
  };
50
50
 
51
- const DraggableCollectionItem: FunctionComponent<CollectionItemSharedProps> = ({
51
+ const DraggableCollectionItem: FunctionComponent<PropsWithChildren<CollectionItemSharedProps>> = ({
52
52
  index,
53
53
  onRemove,
54
54
  removable = true,
@@ -77,7 +77,11 @@ const DraggableCollectionItem: FunctionComponent<CollectionItemSharedProps> = ({
77
77
  );
78
78
  };
79
79
 
80
- export const CollectionItem: FunctionComponent<CollectionItemProps> = ({draggable, disabled, ...otherProps}) => {
80
+ export const CollectionItem: FunctionComponent<PropsWithChildren<CollectionItemProps>> = ({
81
+ draggable,
82
+ disabled,
83
+ ...otherProps
84
+ }) => {
81
85
  if (disabled) {
82
86
  return <DisabledCollectionItem {...otherProps} />;
83
87
  }
@@ -51,6 +51,33 @@ describe('Collection', () => {
51
51
  expect(screen.getByTestId('form-state')).toHaveTextContent('{"fruits":["orange"]}');
52
52
  });
53
53
 
54
+ it('calls the onRemoveItem function when clicking on a remove button', async () => {
55
+ const onRemoveItemSpy = jest.fn();
56
+ const Fixture = () => {
57
+ const form = useForm({initialValues: {fruits: ['banana', 'orange']}});
58
+ return (
59
+ <Collection newItem="" {...form.getInputProps('fruits')} onRemoveItem={onRemoveItemSpy}>
60
+ {(name) => <span data-testid="item">{name}</span>}
61
+ </Collection>
62
+ );
63
+ };
64
+
65
+ render(<Fixture />);
66
+ let items = screen.getAllByTestId('item');
67
+ expect(items).toHaveLength(2);
68
+ /* eslint-disable-next-line testing-library/no-node-access */
69
+ const removeOrange = await within(items[1].parentElement).findByRole('button', {name: /remove/i});
70
+ userEvent.click(removeOrange);
71
+
72
+ expect(onRemoveItemSpy).toHaveBeenCalledWith(1);
73
+
74
+ items = screen.getAllByTestId('item');
75
+ const removeBanana = await within(items[0].parentElement).findByRole('button', {name: /remove/i});
76
+ userEvent.click(removeBanana);
77
+
78
+ expect(onRemoveItemSpy).toHaveBeenCalledWith(0);
79
+ });
80
+
54
81
  it('does not render the remove button when disabled', async () => {
55
82
  const Fixture = () => {
56
83
  const [disabled, setDisabled] = useState(false);
@@ -1,6 +1,6 @@
1
1
  import {QuestionSize24Px} from '@coveord/plasma-react-icons';
2
2
  import {Anchor, Breadcrumbs, DefaultProps, Divider, Group, Stack, Text, Title, Tooltip} from '@mantine/core';
3
- import {FunctionComponent, ReactNode} from 'react';
3
+ import {FunctionComponent, PropsWithChildren, ReactNode} from 'react';
4
4
 
5
5
  interface HeaderProps extends DefaultProps {
6
6
  description?: ReactNode;
@@ -10,7 +10,7 @@ interface HeaderProps extends DefaultProps {
10
10
  docLinkTooltipLabel?: string;
11
11
  }
12
12
 
13
- export const Header: FunctionComponent<HeaderProps> = ({
13
+ export const Header: FunctionComponent<PropsWithChildren<HeaderProps>> = ({
14
14
  description,
15
15
  actions,
16
16
  borderBottom,
@@ -1,10 +1,10 @@
1
- import {Children, FunctionComponent, ReactElement, useState} from 'react';
1
+ import {Children, FunctionComponent, PropsWithChildren, ReactElement, useState} from 'react';
2
2
 
3
3
  import {InlineConfirmButton} from './InlineConfirmButton';
4
4
  import {InlineConfirmContext} from './InlineConfirmContext';
5
5
  import {InlineConfirmPrompt} from './InlineConfirmPrompt';
6
6
 
7
- type InlineConfirmType = FunctionComponent & {
7
+ type InlineConfirmType = FunctionComponent<PropsWithChildren> & {
8
8
  Prompt: typeof InlineConfirmPrompt;
9
9
  Button: typeof InlineConfirmButton;
10
10
  };
@@ -1,4 +1,4 @@
1
- import {FunctionComponent, ReactElement} from 'react';
1
+ import {FunctionComponent, PropsWithChildren, ReactElement} from 'react';
2
2
 
3
3
  type DependsOnStep<T> = (currentStep: number, numberOfSteps: number) => T;
4
4
 
@@ -43,7 +43,9 @@ export interface ModalWizardStepProps {
43
43
  countsAsProgress?: boolean;
44
44
  }
45
45
 
46
- const ModalWizardStep: FunctionComponent<ModalWizardStepProps> = ({children}) => <div>{children}</div>;
46
+ const ModalWizardStep: FunctionComponent<PropsWithChildren<ModalWizardStepProps>> = ({children}) => (
47
+ <div>{children}</div>
48
+ );
47
49
 
48
50
  ModalWizardStep.defaultProps = {
49
51
  showProgressBar: true,
@@ -255,7 +255,7 @@ describe('ModalWizard', () => {
255
255
  });
256
256
 
257
257
  userEvent.click(finishButton);
258
- expect(onFinish).toBeCalledTimes(1);
258
+ expect(onFinish).toHaveBeenCalledTimes(1);
259
259
  });
260
260
 
261
261
  it('handle dirty state if user confirms close', () => {
@@ -1,8 +1,8 @@
1
- import {FunctionComponent} from 'react';
1
+ import {FunctionComponent, PropsWithChildren} from 'react';
2
2
  import {StickyFooter, StickyFooterProps} from '../sticky-footer';
3
3
 
4
4
  export interface PromptFooterProps extends StickyFooterProps {}
5
5
 
6
- export const PromptFooter: FunctionComponent<PromptFooterProps> = ({children, ...otherProps}) => (
6
+ export const PromptFooter: FunctionComponent<PropsWithChildren<PromptFooterProps>> = ({children, ...otherProps}) => (
7
7
  <StickyFooter {...otherProps}>{children}</StickyFooter>
8
8
  );
@@ -1,5 +1,5 @@
1
1
  import {createStyles, DefaultProps, Divider, Group, Paper} from '@mantine/core';
2
- import {FunctionComponent} from 'react';
2
+ import {FunctionComponent, PropsWithChildren} from 'react';
3
3
 
4
4
  export interface StickyFooterProps extends DefaultProps {
5
5
  /**
@@ -17,7 +17,11 @@ const useStyles = createStyles(() => ({
17
17
  },
18
18
  }));
19
19
 
20
- export const StickyFooter: FunctionComponent<StickyFooterProps> = ({borderTop, children, ...others}) => {
20
+ export const StickyFooter: FunctionComponent<PropsWithChildren<StickyFooterProps>> = ({
21
+ borderTop,
22
+ children,
23
+ ...others
24
+ }) => {
21
25
  const {classes} = useStyles();
22
26
 
23
27
  return (
@@ -1,6 +1,6 @@
1
- import {Center, Collapse, createStyles, Loader, Skeleton, Table as MantineTable} from '@mantine/core';
1
+ import {Box, Center, Collapse, createStyles, Loader, Skeleton, Table as MantineTable} from '@mantine/core';
2
2
  import {useForm} from '@mantine/form';
3
- import {useDidUpdate} from '@mantine/hooks';
3
+ import {useClickOutside, useDidUpdate} from '@mantine/hooks';
4
4
  import {
5
5
  ColumnDef,
6
6
  defaultColumnSizing,
@@ -175,6 +175,10 @@ export const Table: TableType = <T,>({
175
175
  onMount?.({...state, ...form.values});
176
176
  }, []);
177
177
 
178
+ const outsideClickRef = useClickOutside(() => {
179
+ table.resetRowSelection(true);
180
+ });
181
+
178
182
  useDidUpdate(() => {
179
183
  triggerChange();
180
184
  clearSelection();
@@ -244,40 +248,42 @@ export const Table: TableType = <T,>({
244
248
  });
245
249
 
246
250
  return (
247
- <TableContext.Provider
248
- value={{
249
- onChange: triggerChange,
250
- state,
251
- setState,
252
- clearFilters,
253
- getSelectedRow,
254
- clearSelection,
255
- form,
256
- }}
257
- >
258
- {header}
259
- <MantineTable className={classes.table} horizontalSpacing="sm" verticalSpacing="xs" pb="sm">
260
- <thead className={classes.header}>
261
- {table.getHeaderGroups().map((headerGroup) => (
262
- <tr key={headerGroup.id}>
263
- {headerGroup.headers.map((columnHeader) => (
264
- <Th key={columnHeader.id} header={columnHeader} />
265
- ))}
266
- </tr>
267
- ))}
268
- </thead>
269
- <tbody>
270
- {rows.length ? (
271
- rows
272
- ) : (
273
- <tr>
274
- <td colSpan={columns.length}>{noDataChildren}</td>
275
- </tr>
276
- )}
277
- </tbody>
278
- </MantineTable>
279
- {footer}
280
- </TableContext.Provider>
251
+ <Box ref={outsideClickRef}>
252
+ <TableContext.Provider
253
+ value={{
254
+ onChange: triggerChange,
255
+ state,
256
+ setState,
257
+ clearFilters,
258
+ getSelectedRow,
259
+ clearSelection,
260
+ form,
261
+ }}
262
+ >
263
+ {header}
264
+ <MantineTable className={classes.table} horizontalSpacing="sm" verticalSpacing="xs" pb="sm">
265
+ <thead className={classes.header}>
266
+ {table.getHeaderGroups().map((headerGroup) => (
267
+ <tr key={headerGroup.id}>
268
+ {headerGroup.headers.map((columnHeader) => (
269
+ <Th key={columnHeader.id} header={columnHeader} />
270
+ ))}
271
+ </tr>
272
+ ))}
273
+ </thead>
274
+ <tbody>
275
+ {rows.length ? (
276
+ rows
277
+ ) : (
278
+ <tr>
279
+ <td colSpan={columns.length}>{noDataChildren}</td>
280
+ </tr>
281
+ )}
282
+ </tbody>
283
+ </MantineTable>
284
+ {footer}
285
+ </TableContext.Provider>
286
+ </Box>
281
287
  );
282
288
  };
283
289
 
@@ -1,7 +1,7 @@
1
1
  import {Group} from '@mantine/core';
2
- import {FunctionComponent} from 'react';
2
+ import {FunctionComponent, PropsWithChildren} from 'react';
3
3
 
4
- export const TableFooter: FunctionComponent = ({children}) => (
4
+ export const TableFooter: FunctionComponent<PropsWithChildren> = ({children}) => (
5
5
  <Group position="apart" px="md" py="sm">
6
6
  {children}
7
7
  </Group>
@@ -1,5 +1,5 @@
1
1
  import {createStyles, Group} from '@mantine/core';
2
- import {FunctionComponent} from 'react';
2
+ import {FunctionComponent, PropsWithChildren} from 'react';
3
3
 
4
4
  const useStyles = createStyles((theme) => ({
5
5
  header: {
@@ -11,7 +11,7 @@ const useStyles = createStyles((theme) => ({
11
11
  },
12
12
  }));
13
13
 
14
- export const TableHeader: FunctionComponent = ({children}) => {
14
+ export const TableHeader: FunctionComponent<PropsWithChildren> = ({children}) => {
15
15
  const {classes} = useStyles();
16
16
  return (
17
17
  <Group position="right" spacing="lg" className={classes.header} px="md" py="sm">
@@ -125,4 +125,31 @@ describe('Table', () => {
125
125
  const allRows = screen.getAllByRole('button', {name: 'arrowHeadDown'});
126
126
  expect(allRows).toHaveLength(2);
127
127
  });
128
+
129
+ it('reset row selection when user click outside the table', () => {
130
+ render(
131
+ <div>
132
+ <div>I'm a header</div>
133
+ <Table
134
+ data={[
135
+ {firstName: 'first', lastName: 'last'},
136
+ {firstName: 'patate', lastName: 'king'},
137
+ ]}
138
+ columns={columns}
139
+ />
140
+ </div>
141
+ );
142
+
143
+ const row = screen.getByRole('row', {name: 'patate king'});
144
+
145
+ expect(row).not.toHaveClass('__mantine-ref-rowSelected');
146
+
147
+ userEvent.click(row);
148
+
149
+ expect(row).toHaveClass('__mantine-ref-rowSelected');
150
+
151
+ userEvent.click(screen.getByText(/i'm a header/i));
152
+
153
+ expect(row).not.toHaveClass('__mantine-ref-rowSelected');
154
+ });
128
155
  });
@@ -45,7 +45,7 @@ describe('Th', () => {
45
45
  await screen.findAllByRole('img', {name: 'arrowHeadDown'});
46
46
  await screen.findAllByRole('img', {name: 'arrowHeadUp'});
47
47
 
48
- userEvent.click(screen.getByRole('button', {name: 'name arrowHeadDown'}));
48
+ userEvent.click(screen.getByRole('button', {name: /name arrowheaddown/i}));
49
49
  await waitFor(() => {
50
50
  expect(onChange).toHaveBeenCalledWith(expect.objectContaining({sorting: [{id: 'name', desc: false}]}));
51
51
  });
@@ -55,6 +55,7 @@ describe('Th', () => {
55
55
  expect(onChange).toHaveBeenCalledWith(expect.objectContaining({sorting: [{id: 'name', desc: true}]}));
56
56
  });
57
57
 
58
+ await waitFor(() => expect(screen.queryByRole('button', {name: 'name arrowHeadUp'})).toBeVisible());
58
59
  userEvent.click(screen.getByRole('button', {name: 'name arrowHeadUp'}));
59
60
  await waitFor(() => {
60
61
  expect(onChange).toHaveBeenCalledWith(expect.objectContaining({sorting: [{id: 'name', desc: false}]}));
@@ -1,4 +1,4 @@
1
- import {renderHook} from '@testing-library/react-hooks';
1
+ import {renderHook} from '@testing-library/react';
2
2
 
3
3
  import {useControlledList} from '../useControlledList';
4
4
 
@@ -1,9 +1,9 @@
1
1
  import {MantineProvider} from '@mantine/core';
2
- import {FunctionComponent} from 'react';
2
+ import {FunctionComponent, PropsWithChildren} from 'react';
3
3
 
4
4
  import {plasmaTheme} from './Theme';
5
5
 
6
- export const Plasmantine: FunctionComponent = ({children}) => (
6
+ export const Plasmantine: FunctionComponent<PropsWithChildren> = ({children}) => (
7
7
  <MantineProvider withGlobalStyles withNormalizeCSS theme={plasmaTheme}>
8
8
  {children}
9
9
  </MantineProvider>