@coveord/plasma-mantine 47.9.2 → 48.0.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 +7 -7
- package/dist/.tsbuildinfo +1 -1
- package/dist/cjs/__tests__/Utils.js.map +1 -1
- package/dist/cjs/components/blank-slate/BlankSlate.js.map +1 -1
- package/dist/cjs/components/collection/CollectionItem.js.map +1 -1
- package/dist/cjs/components/date-range-picker/index.js +1 -0
- package/dist/cjs/components/date-range-picker/index.js.map +1 -1
- package/dist/cjs/components/header/Header.js.map +1 -1
- package/dist/cjs/components/inline-confirm/InlineConfirm.js.map +1 -1
- package/dist/cjs/components/modal-wizard/ModalWizardStep.js.map +1 -1
- package/dist/cjs/components/prompt/PromptFooter.js.map +1 -1
- package/dist/cjs/components/sticky-footer/StickyFooter.js.map +1 -1
- package/dist/cjs/components/table/Table.js +45 -39
- package/dist/cjs/components/table/Table.js.map +1 -1
- package/dist/cjs/components/table/TableFooter.js.map +1 -1
- package/dist/cjs/components/table/TableHeader.js.map +1 -1
- package/dist/cjs/theme/Plasmantine.js.map +1 -1
- package/dist/definitions/__tests__/Utils.d.ts.map +1 -1
- package/dist/definitions/components/blank-slate/BlankSlate.d.ts +2 -2
- package/dist/definitions/components/blank-slate/BlankSlate.d.ts.map +1 -1
- package/dist/definitions/components/collection/CollectionItem.d.ts +2 -2
- package/dist/definitions/components/collection/CollectionItem.d.ts.map +1 -1
- package/dist/definitions/components/date-range-picker/index.d.ts +1 -0
- package/dist/definitions/components/date-range-picker/index.d.ts.map +1 -1
- package/dist/definitions/components/header/Header.d.ts +2 -2
- package/dist/definitions/components/header/Header.d.ts.map +1 -1
- package/dist/definitions/components/inline-confirm/InlineConfirm.d.ts +2 -2
- package/dist/definitions/components/inline-confirm/InlineConfirm.d.ts.map +1 -1
- package/dist/definitions/components/modal-wizard/ModalWizardStep.d.ts +2 -2
- package/dist/definitions/components/modal-wizard/ModalWizardStep.d.ts.map +1 -1
- package/dist/definitions/components/prompt/PromptFooter.d.ts +2 -2
- package/dist/definitions/components/prompt/PromptFooter.d.ts.map +1 -1
- package/dist/definitions/components/sticky-footer/StickyFooter.d.ts +2 -2
- package/dist/definitions/components/sticky-footer/StickyFooter.d.ts.map +1 -1
- package/dist/definitions/components/table/Table.d.ts.map +1 -1
- package/dist/definitions/components/table/TableFooter.d.ts +2 -2
- package/dist/definitions/components/table/TableFooter.d.ts.map +1 -1
- package/dist/definitions/components/table/TableHeader.d.ts +2 -2
- package/dist/definitions/components/table/TableHeader.d.ts.map +1 -1
- package/dist/definitions/theme/Plasmantine.d.ts +2 -2
- package/dist/definitions/theme/Plasmantine.d.ts.map +1 -1
- package/dist/esm/__tests__/Utils.js.map +1 -1
- package/dist/esm/components/blank-slate/BlankSlate.js.map +1 -1
- package/dist/esm/components/collection/CollectionItem.js.map +1 -1
- package/dist/esm/components/date-range-picker/index.js +1 -0
- package/dist/esm/components/date-range-picker/index.js.map +1 -1
- package/dist/esm/components/header/Header.js.map +1 -1
- package/dist/esm/components/inline-confirm/InlineConfirm.js.map +1 -1
- package/dist/esm/components/modal-wizard/ModalWizardStep.js.map +1 -1
- package/dist/esm/components/prompt/PromptFooter.js.map +1 -1
- package/dist/esm/components/sticky-footer/StickyFooter.js.map +1 -1
- package/dist/esm/components/table/Table.js +47 -41
- package/dist/esm/components/table/Table.js.map +1 -1
- package/dist/esm/components/table/TableFooter.js.map +1 -1
- package/dist/esm/components/table/TableHeader.js.map +1 -1
- package/dist/esm/theme/Plasmantine.js.map +1 -1
- package/package.json +19 -20
- package/src/__tests__/Utils.tsx +2 -2
- package/src/components/blank-slate/BlankSlate.tsx +2 -2
- package/src/components/collection/CollectionItem.tsx +9 -5
- package/src/components/date-range-picker/index.tsx +1 -0
- package/src/components/header/Header.tsx +2 -2
- package/src/components/inline-confirm/InlineConfirm.tsx +2 -2
- package/src/components/modal-wizard/ModalWizardStep.tsx +4 -2
- package/src/components/modal-wizard/__tests__/ModalWizard.spec.tsx +1 -1
- package/src/components/prompt/PromptFooter.tsx +2 -2
- package/src/components/sticky-footer/StickyFooter.tsx +6 -2
- package/src/components/table/Table.tsx +42 -36
- package/src/components/table/TableFooter.tsx +2 -2
- package/src/components/table/TableHeader.tsx +2 -2
- package/src/components/table/__tests__/Table.spec.tsx +27 -0
- package/src/components/table/__tests__/Th.spec.tsx +2 -1
- package/src/hooks/__tests__/useControlledList.spec.tsx +1 -1
- package/src/theme/Plasmantine.tsx +2 -2
|
@@ -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
|
|
46
|
+
const ModalWizardStep: FunctionComponent<PropsWithChildren<ModalWizardStepProps>> = ({children}) => (
|
|
47
|
+
<div>{children}</div>
|
|
48
|
+
);
|
|
47
49
|
|
|
48
50
|
ModalWizardStep.defaultProps = {
|
|
49
51
|
showProgressBar: true,
|
|
@@ -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
|
|
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
|
|
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
|
-
<
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
<
|
|
261
|
-
{
|
|
262
|
-
|
|
263
|
-
{headerGroup.
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
rows
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
<
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
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:
|
|
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,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>
|