@coveord/plasma-mantine 49.3.5 → 49.4.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 +29 -29
- package/dist/.tsbuildinfo +1 -1
- package/dist/cjs/components/table/Table.js +8 -10
- package/dist/cjs/components/table/Table.js.map +1 -1
- package/dist/cjs/components/table/Table.types.js +6 -0
- package/dist/cjs/components/table/Table.types.js.map +1 -0
- package/dist/cjs/components/table/TableActions.js +3 -3
- package/dist/cjs/components/table/TableActions.js.map +1 -1
- package/dist/cjs/components/table/TableContext.js +18 -3
- package/dist/cjs/components/table/TableContext.js.map +1 -1
- package/dist/cjs/components/table/TableDateRangePicker.js +2 -2
- package/dist/cjs/components/table/TableDateRangePicker.js.map +1 -1
- package/dist/cjs/components/table/TableFilter.js +2 -2
- package/dist/cjs/components/table/TableFilter.js.map +1 -1
- package/dist/cjs/components/table/TableHeader.js +2 -2
- package/dist/cjs/components/table/TableHeader.js.map +1 -1
- package/dist/cjs/components/table/TablePagination.js +2 -2
- package/dist/cjs/components/table/TablePagination.js.map +1 -1
- package/dist/cjs/components/table/TablePerPage.js +2 -2
- package/dist/cjs/components/table/TablePerPage.js.map +1 -1
- package/dist/cjs/components/table/TablePredicate.js +2 -2
- package/dist/cjs/components/table/TablePredicate.js.map +1 -1
- package/dist/cjs/components/table/index.js +7 -1
- package/dist/cjs/components/table/index.js.map +1 -1
- package/dist/cjs/components/table/useRowSelection.js +27 -17
- package/dist/cjs/components/table/useRowSelection.js.map +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/definitions/components/table/Table.d.ts +1 -98
- package/dist/definitions/components/table/Table.d.ts.map +1 -1
- package/dist/definitions/components/table/Table.types.d.ts +177 -0
- package/dist/definitions/components/table/Table.types.d.ts.map +1 -0
- package/dist/definitions/components/table/TableActions.d.ts.map +1 -1
- package/dist/definitions/components/table/TableContext.d.ts +4 -71
- package/dist/definitions/components/table/TableContext.d.ts.map +1 -1
- package/dist/definitions/components/table/TableFilter.d.ts.map +1 -1
- package/dist/definitions/components/table/TablePagination.d.ts.map +1 -1
- package/dist/definitions/components/table/TablePerPage.d.ts.map +1 -1
- package/dist/definitions/components/table/TablePredicate.d.ts.map +1 -1
- package/dist/definitions/components/table/index.d.ts +2 -2
- package/dist/definitions/components/table/index.d.ts.map +1 -1
- package/dist/definitions/components/table/useRowSelection.d.ts +4 -1
- package/dist/definitions/components/table/useRowSelection.d.ts.map +1 -1
- package/dist/definitions/index.d.ts +1 -1
- package/dist/definitions/index.d.ts.map +1 -1
- package/dist/esm/components/table/Table.js +9 -11
- package/dist/esm/components/table/Table.js.map +1 -1
- package/dist/esm/components/table/Table.types.js +3 -0
- package/dist/esm/components/table/Table.types.js.map +1 -0
- package/dist/esm/components/table/TableActions.js +2 -2
- package/dist/esm/components/table/TableActions.js.map +1 -1
- package/dist/esm/components/table/TableContext.js +8 -1
- package/dist/esm/components/table/TableContext.js.map +1 -1
- package/dist/esm/components/table/TableDateRangePicker.js +1 -1
- package/dist/esm/components/table/TableDateRangePicker.js.map +1 -1
- package/dist/esm/components/table/TableFilter.js +1 -1
- package/dist/esm/components/table/TableFilter.js.map +1 -1
- package/dist/esm/components/table/TableHeader.js +1 -1
- package/dist/esm/components/table/TableHeader.js.map +1 -1
- package/dist/esm/components/table/TablePagination.js +1 -1
- package/dist/esm/components/table/TablePagination.js.map +1 -1
- package/dist/esm/components/table/TablePerPage.js +1 -1
- package/dist/esm/components/table/TablePerPage.js.map +1 -1
- package/dist/esm/components/table/TablePredicate.js +2 -2
- package/dist/esm/components/table/TablePredicate.js.map +1 -1
- package/dist/esm/components/table/index.js +1 -1
- package/dist/esm/components/table/index.js.map +1 -1
- package/dist/esm/components/table/useRowSelection.js +26 -17
- package/dist/esm/components/table/useRowSelection.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/package.json +5 -4
- package/src/components/table/Table.tsx +16 -117
- package/src/components/table/Table.types.ts +203 -0
- package/src/components/table/TableActions.tsx +10 -3
- package/src/components/table/TableContext.tsx +9 -70
- package/src/components/table/TableDateRangePicker.tsx +1 -1
- package/src/components/table/TableFilter.tsx +2 -3
- package/src/components/table/TableHeader.tsx +1 -1
- package/src/components/table/TablePagination.tsx +3 -3
- package/src/components/table/TablePerPage.tsx +2 -3
- package/src/components/table/TablePredicate.tsx +3 -2
- package/src/components/table/__tests__/Table.spec.tsx +59 -22
- package/src/components/table/index.ts +2 -2
- package/src/components/table/useRowSelection.ts +36 -21
- package/src/index.ts +2 -0
- package/dist/cjs/components/table/useTable.js +0 -21
- package/dist/cjs/components/table/useTable.js.map +0 -1
- package/dist/definitions/components/table/useTable.d.ts +0 -16
- package/dist/definitions/components/table/useTable.d.ts.map +0 -1
- package/dist/esm/components/table/useTable.js +0 -11
- package/dist/esm/components/table/useTable.js.map +0 -1
- package/src/components/table/useTable.tsx +0 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/table/useRowSelection.ts"],"sourcesContent":["import {functionalUpdate, Table} from '@tanstack/table-core';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/table/useRowSelection.ts"],"sourcesContent":["import {useClickOutside} from '@mantine/hooks';\nimport {functionalUpdate, RowSelectionState, Table} from '@tanstack/table-core';\nimport isEqual from 'fast-deep-equal';\n\nimport {RowSelectionWithData, TableProps, TableState} from './Table.types';\n\nexport const useRowSelection = <T>(\n table: Table<T>,\n {multiRowSelectionEnabled}: Pick<TableProps<T>, 'multiRowSelectionEnabled'>\n) => {\n const outsideClickRef = useClickOutside(() => {\n if (!multiRowSelectionEnabled) {\n clearSelection();\n }\n });\n\n table.setOptions((prev) => ({\n ...prev,\n onRowSelectionChange: (rowSelectionUpdater) => {\n table.setState((old) => {\n const newRowSelection = functionalUpdate(\n rowSelectionUpdater,\n old['rowSelection']\n ) as RowSelectionWithData<T>;\n\n if (isEqual(old['rowSelection'], newRowSelection)) {\n return old;\n }\n\n const rows = table.getRowModel().rowsById;\n\n Object.keys(newRowSelection).forEach((rowId) => {\n if (newRowSelection[rowId] === true) {\n if (!rows[rowId]) {\n console.error(\n 'The table was not initialized properly, the rowSelection state should contain an object of type Record<string, TData>.'\n );\n }\n newRowSelection[rowId] = rows[rowId]?.original ?? (true as T);\n }\n });\n\n return {\n ...old,\n rowSelection: newRowSelection as RowSelectionState,\n };\n });\n },\n }));\n\n const clearSelection = () => {\n table.resetRowSelection(true);\n };\n\n const getSelectedRows = () => Object.values((table.getState() as TableState<T>).rowSelection);\n\n const getSelectedRow = () => getSelectedRows()[0] ?? null;\n\n return {clearSelection, getSelectedRow, getSelectedRows, outsideClickRef};\n};\n"],"names":["useRowSelection","table","multiRowSelectionEnabled","outsideClickRef","useClickOutside","clearSelection","setOptions","prev","onRowSelectionChange","rowSelectionUpdater","setState","old","newRowSelection","functionalUpdate","isEqual","rows","getRowModel","rowsById","Object","keys","forEach","rowId","console","error","original","rowSelection","resetRowSelection","getSelectedRows","values","getState","getSelectedRow"],"mappings":";;;;+BAMaA;;;eAAAA;;;;;;qBANiB;yBAC2B;kEACrC;AAIb,IAAMA,kBAAkB,SAC3BC,cAEC;QADAC,iCAAAA;IAED,IAAMC,kBAAkBC,IAAAA,sBAAe,EAAC,WAAM;QAC1C,IAAI,CAACF,0BAA0B;YAC3BG;QACJ,CAAC;IACL;IAEAJ,MAAMK,UAAU,CAAC,SAACC;QAAU,OAAA,qCACrBA;YACHC,sBAAsB,SAACC,qBAAwB;gBAC3CR,MAAMS,QAAQ,CAAC,SAACC,KAAQ;oBACpB,IAAMC,kBAAkBC,IAAAA,2BAAgB,EACpCJ,qBACAE,GAAG,CAAC,eAAe;oBAGvB,IAAIG,IAAAA,sBAAO,EAACH,GAAG,CAAC,eAAe,EAAEC,kBAAkB;wBAC/C,OAAOD;oBACX,CAAC;oBAED,IAAMI,OAAOd,MAAMe,WAAW,GAAGC,QAAQ;oBAEzCC,OAAOC,IAAI,CAACP,iBAAiBQ,OAAO,CAAC,SAACC,OAAU;wBAC5C,IAAIT,eAAe,CAACS,MAAM,KAAK,IAAI,EAAE;gCAMRN;4BALzB,IAAI,CAACA,IAAI,CAACM,MAAM,EAAE;gCACdC,QAAQC,KAAK,CACT;4BAER,CAAC;gCACwBR;4BAAzBH,eAAe,CAACS,MAAM,GAAGN,CAAAA,uBAAAA,CAAAA,cAAAA,IAAI,CAACM,MAAM,cAAXN,yBAAAA,KAAAA,IAAAA,YAAaS,QAAQ,cAArBT,kCAAAA,uBAA0B,IAAI,AAAM;wBACjE,CAAC;oBACL;oBAEA,OAAO,qCACAJ;wBACHc,cAAcb;;gBAEtB;YACJ;;;IAGJ,IAAMP,iBAAiB,WAAM;QACzBJ,MAAMyB,iBAAiB,CAAC,IAAI;IAChC;IAEA,IAAMC,kBAAkB;eAAMT,OAAOU,MAAM,CAAC,AAAC3B,MAAM4B,QAAQ,GAAqBJ,YAAY;;QAE/DE;IAA7B,IAAMG,iBAAiB;eAAMH,CAAAA,oBAAAA,iBAAiB,CAAC,EAAE,cAApBA,+BAAAA,oBAAwB,IAAI;;IAEzD,OAAO;QAACtB,gBAAAA;QAAgByB,gBAAAA;QAAgBH,iBAAAA;QAAiBxB,iBAAAA;IAAe;AAC5E"}
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import {Tuple} from '@mantine/core';\n\nimport {PlasmaColors} from './theme/PlasmaColors';\n\nexport * from '@mantine/carousel';\nexport * from '@mantine/core';\nexport type {FormValidateInput} from '@mantine/form/lib/types';\nexport * from '@mantine/hooks';\nexport * from '@tanstack/table-core';\nexport * from './components';\nexport * from '@mantine/form';\nexport {Pagination} from '@mantine/core';\n// explicitly overriding mantine components\nexport {\n Header,\n Table,\n type TableProps,\n type HeaderProps,\n Modal,\n Button,\n type ButtonProps,\n Menu,\n type MenuItemProps,\n} from './components';\nexport {useForm, createFormContext} from './form';\n\nexport * from './theme';\n\ndeclare module '@mantine/core' {\n export interface MantineThemeColorsOverride {\n // eslint-disable-next-line @typescript-eslint/ban-types\n colors: Record<keyof typeof PlasmaColors | (string & {}), Tuple<string, 10>>;\n }\n}\n"],"names":["Pagination","Header","Table","Modal","Button","Menu","useForm","createFormContext"],"mappings":";;;;;;;;;;;IAWQA,UAAU;eAAVA,gBAAU;;IAGdC,MAAM;eAANA,kBAAM;;IACNC,KAAK;eAALA,iBAAK;;
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts"],"sourcesContent":["import {Tuple} from '@mantine/core';\n\nimport {PlasmaColors} from './theme/PlasmaColors';\n\nexport * from '@mantine/carousel';\nexport * from '@mantine/core';\nexport type {FormValidateInput} from '@mantine/form/lib/types';\nexport * from '@mantine/hooks';\nexport * from '@tanstack/table-core';\nexport * from './components';\nexport * from '@mantine/form';\nexport {Pagination} from '@mantine/core';\n// explicitly overriding mantine components\nexport {\n Header,\n Table,\n type TableProps,\n type TableState,\n type InitialTableState,\n type HeaderProps,\n Modal,\n Button,\n type ButtonProps,\n Menu,\n type MenuItemProps,\n} from './components';\nexport {useForm, createFormContext} from './form';\n\nexport * from './theme';\n\ndeclare module '@mantine/core' {\n export interface MantineThemeColorsOverride {\n // eslint-disable-next-line @typescript-eslint/ban-types\n colors: Record<keyof typeof PlasmaColors | (string & {}), Tuple<string, 10>>;\n }\n}\n"],"names":["Pagination","Header","Table","Modal","Button","Menu","useForm","createFormContext"],"mappings":";;;;;;;;;;;IAWQA,UAAU;eAAVA,gBAAU;;IAGdC,MAAM;eAANA,kBAAM;;IACNC,KAAK;eAALA,iBAAK;;IAKLC,KAAK;eAALA,iBAAK;;IACLC,MAAM;eAANA,kBAAM;;IAENC,IAAI;eAAJA,gBAAI;;IAGAC,OAAO;eAAPA,aAAO;;IAAEC,iBAAiB;eAAjBA,uBAAiB;;;;oBAtBpB;gCACA;oBAEA;oBACA;sCACA;oBACA;oBAgB2B;oBAE3B"}
|
|
@@ -1,100 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CoreOptions, InitialTableState, TableOptions } from '@tanstack/table-core';
|
|
3
|
-
import { ReactElement, ReactNode } from 'react';
|
|
4
|
-
import { TableActions } from './TableActions';
|
|
5
|
-
import { TableAccordionColumn, TableCollapsibleColumn } from './TableCollapsibleColumn';
|
|
6
|
-
import { onTableChangeEvent, TableFormType } from './TableContext';
|
|
7
|
-
import { TableDateRangePicker } from './TableDateRangePicker';
|
|
8
|
-
import { TableFilter } from './TableFilter';
|
|
9
|
-
import { TableFooter } from './TableFooter';
|
|
10
|
-
import { TableHeader } from './TableHeader';
|
|
11
|
-
import { TablePagination } from './TablePagination';
|
|
12
|
-
import { TablePerPage } from './TablePerPage';
|
|
13
|
-
import { TablePredicate } from './TablePredicate';
|
|
14
|
-
export interface TableProps<T> {
|
|
15
|
-
/**
|
|
16
|
-
* Data to display in the table
|
|
17
|
-
*/
|
|
18
|
-
data: T[];
|
|
19
|
-
/**
|
|
20
|
-
* Defines how each row is uniquely identified. It is highly recommended that you specify this prop to an ID that makes sense.
|
|
21
|
-
*/
|
|
22
|
-
getRowId?: CoreOptions<T>['getRowId'];
|
|
23
|
-
/**
|
|
24
|
-
* Columns to display in the table.
|
|
25
|
-
*
|
|
26
|
-
* @see https://tanstack.com/table/v8/docs/guide/column-defs
|
|
27
|
-
*/
|
|
28
|
-
columns: Array<ColumnDef<T>>;
|
|
29
|
-
/**
|
|
30
|
-
* Function called when the table mounts
|
|
31
|
-
*
|
|
32
|
-
* @param state the state of the table
|
|
33
|
-
*/
|
|
34
|
-
onMount?: onTableChangeEvent;
|
|
35
|
-
/**
|
|
36
|
-
* Function called when the table should update
|
|
37
|
-
*
|
|
38
|
-
* @param state the state of the table
|
|
39
|
-
*/
|
|
40
|
-
onChange?: onTableChangeEvent;
|
|
41
|
-
/**
|
|
42
|
-
* Function that generates the expandable content of a row
|
|
43
|
-
* Return null for rows that don't need to be expandable
|
|
44
|
-
*
|
|
45
|
-
* @param datum the row for which the children should be generated.
|
|
46
|
-
*/
|
|
47
|
-
getExpandChildren?: (datum: T) => ReactNode;
|
|
48
|
-
/**
|
|
49
|
-
* React children to show when the table has no rows to show. You can leverage useTable to get the state of the table
|
|
50
|
-
*/
|
|
51
|
-
noDataChildren?: ReactNode;
|
|
52
|
-
/**
|
|
53
|
-
* Whether the table is loading or not
|
|
54
|
-
*
|
|
55
|
-
* @default false
|
|
56
|
-
*/
|
|
57
|
-
loading?: boolean;
|
|
58
|
-
/**
|
|
59
|
-
* Childrens to display in the table. They need to be wrap in either `Table.Header` or `Table.Footer`
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* <Table ...>
|
|
63
|
-
* <Table.Header>
|
|
64
|
-
* <div>Hello</div>
|
|
65
|
-
* </Table.Header>
|
|
66
|
-
* </Table>
|
|
67
|
-
*/
|
|
68
|
-
children?: ReactNode;
|
|
69
|
-
/**
|
|
70
|
-
* Initial state of the table
|
|
71
|
-
*/
|
|
72
|
-
initialState?: InitialTableState & Partial<TableFormType>;
|
|
73
|
-
/**
|
|
74
|
-
* Action passed when user double clicks on a row
|
|
75
|
-
*/
|
|
76
|
-
doubleClickAction?: (datum: T) => void;
|
|
77
|
-
/**
|
|
78
|
-
* Whether the user can select multiple rows in order to perform actions in bulk
|
|
79
|
-
*
|
|
80
|
-
* @default false
|
|
81
|
-
*/
|
|
82
|
-
multiRowSelectionEnabled?: boolean;
|
|
83
|
-
options?: Omit<Partial<TableOptions<T>>, 'initialState' | 'data' | 'columns' | 'manualPagination' | 'enableMultiRowSelection' | 'getRowId' | 'getRowCanExpand' | 'enableRowSelection'>;
|
|
84
|
-
}
|
|
85
|
-
interface TableType {
|
|
86
|
-
<T>(props: TableProps<T>): ReactElement;
|
|
87
|
-
Actions: typeof TableActions;
|
|
88
|
-
Filter: typeof TableFilter;
|
|
89
|
-
Footer: typeof TableFooter;
|
|
90
|
-
Header: typeof TableHeader;
|
|
91
|
-
Pagination: typeof TablePagination;
|
|
92
|
-
PerPage: typeof TablePerPage;
|
|
93
|
-
Predicate: typeof TablePredicate;
|
|
94
|
-
DateRangePicker: typeof TableDateRangePicker;
|
|
95
|
-
CollapsibleColumn: typeof TableCollapsibleColumn;
|
|
96
|
-
AccordionColumn: typeof TableAccordionColumn;
|
|
97
|
-
}
|
|
1
|
+
import { TableType } from './Table.types';
|
|
98
2
|
export declare const Table: TableType;
|
|
99
|
-
export {};
|
|
100
3
|
//# sourceMappingURL=Table.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../../../src/components/table/Table.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../../../src/components/table/Table.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAwC,SAAS,EAAC,MAAM,eAAe,CAAC;AAe/E,eAAO,MAAM,KAAK,EAAE,SAsLnB,CAAC"}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { DateRangePickerValue } from '@mantine/dates';
|
|
2
|
+
import { UseFormReturnType } from '@mantine/form';
|
|
3
|
+
import { ColumnDef, CoreOptions, InitialTableState as TanstackInitialTableState, TableOptions, TableState as TanstackTableState } from '@tanstack/table-core';
|
|
4
|
+
import { Dispatch, ReactElement, ReactNode, RefObject } from 'react';
|
|
5
|
+
import { TableActions } from './TableActions';
|
|
6
|
+
import { TableAccordionColumn, TableCollapsibleColumn } from './TableCollapsibleColumn';
|
|
7
|
+
import { TableDateRangePicker } from './TableDateRangePicker';
|
|
8
|
+
import { TableFilter } from './TableFilter';
|
|
9
|
+
import { TableFooter } from './TableFooter';
|
|
10
|
+
import { TableHeader } from './TableHeader';
|
|
11
|
+
import { TablePagination } from './TablePagination';
|
|
12
|
+
import { TablePerPage } from './TablePerPage';
|
|
13
|
+
import { TablePredicate } from './TablePredicate';
|
|
14
|
+
export type RowSelectionWithData<TData> = Record<string, TData>;
|
|
15
|
+
export interface RowSelectionState<TData> {
|
|
16
|
+
rowSelection: RowSelectionWithData<TData>;
|
|
17
|
+
}
|
|
18
|
+
export interface TableState<TData> extends Omit<TanstackTableState, 'rowSelection'>, RowSelectionState<TData> {
|
|
19
|
+
}
|
|
20
|
+
export interface InitialTableState<TData> extends Omit<TanstackInitialTableState, 'rowSelection'>, Partial<RowSelectionState<TData>>, Partial<TableFormType> {
|
|
21
|
+
}
|
|
22
|
+
export type onTableChangeEvent<TData> = (params: TableState<TData> & TableFormType) => void;
|
|
23
|
+
export type TableFormType = {
|
|
24
|
+
/**
|
|
25
|
+
* Object containing the table predicates and their selected values
|
|
26
|
+
*
|
|
27
|
+
* @example {type: "LONG", origin: "system"}
|
|
28
|
+
*/
|
|
29
|
+
predicates: Record<string, string>;
|
|
30
|
+
/**
|
|
31
|
+
* Selected date range in the table
|
|
32
|
+
*
|
|
33
|
+
* @example [new Date(2022, 0, 1), new Date(2022, 0, 31)]
|
|
34
|
+
*/
|
|
35
|
+
dateRange: DateRangePickerValue;
|
|
36
|
+
};
|
|
37
|
+
export type TableContextType<TData> = {
|
|
38
|
+
/**
|
|
39
|
+
* Function to call when the table needs an update
|
|
40
|
+
*/
|
|
41
|
+
onChange: () => void;
|
|
42
|
+
/**
|
|
43
|
+
* Internal state of the table
|
|
44
|
+
*
|
|
45
|
+
* @see https://tanstack.com/table/v8/docs/api/core/table#state
|
|
46
|
+
*/
|
|
47
|
+
state: TableState<TData>;
|
|
48
|
+
/**
|
|
49
|
+
* Function to update the table state
|
|
50
|
+
*/
|
|
51
|
+
setState: Dispatch<(prevState: TableState<TData>) => TableState<TData>>;
|
|
52
|
+
/**
|
|
53
|
+
* Whether the table currently as any kind of filter applied.
|
|
54
|
+
* Useful to determine if the noDataChildren is an empty state or just the result of a filter
|
|
55
|
+
*/
|
|
56
|
+
isFiltered: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Function that clears the filter and predicates
|
|
59
|
+
*/
|
|
60
|
+
clearFilters: () => void;
|
|
61
|
+
/**
|
|
62
|
+
* Function that returns the selected row if any.
|
|
63
|
+
*/
|
|
64
|
+
getSelectedRow: () => TData | null;
|
|
65
|
+
/**
|
|
66
|
+
* Function that returns an array of the selected rows. Most useful when multi row selection is enabled.
|
|
67
|
+
*/
|
|
68
|
+
getSelectedRows: () => TData[];
|
|
69
|
+
/**
|
|
70
|
+
* Function that clear the selected row
|
|
71
|
+
*/
|
|
72
|
+
clearSelection: () => void;
|
|
73
|
+
/**
|
|
74
|
+
* Form used to handle predicates and dateRange
|
|
75
|
+
*/
|
|
76
|
+
form: UseFormReturnType<TableFormType>;
|
|
77
|
+
/**
|
|
78
|
+
* Table container ref
|
|
79
|
+
*/
|
|
80
|
+
containerRef: RefObject<HTMLDivElement>;
|
|
81
|
+
/**
|
|
82
|
+
* Whether multi row selection is activated
|
|
83
|
+
*/
|
|
84
|
+
multiRowSelectionEnabled: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Function that returns the number of pages
|
|
87
|
+
*/
|
|
88
|
+
getPageCount: () => number;
|
|
89
|
+
};
|
|
90
|
+
export interface TableProps<T> {
|
|
91
|
+
/**
|
|
92
|
+
* Data to display in the table
|
|
93
|
+
*/
|
|
94
|
+
data: T[];
|
|
95
|
+
/**
|
|
96
|
+
* Defines how each row is uniquely identified. It is highly recommended that you specify this prop to an ID that makes sense.
|
|
97
|
+
*/
|
|
98
|
+
getRowId?: CoreOptions<T>['getRowId'];
|
|
99
|
+
/**
|
|
100
|
+
* Columns to display in the table.
|
|
101
|
+
*
|
|
102
|
+
* @see https://tanstack.com/table/v8/docs/guide/column-defs
|
|
103
|
+
*/
|
|
104
|
+
columns: Array<ColumnDef<T>>;
|
|
105
|
+
/**
|
|
106
|
+
* Function called when the table mounts
|
|
107
|
+
*
|
|
108
|
+
* @param state the state of the table
|
|
109
|
+
*/
|
|
110
|
+
onMount?: onTableChangeEvent<T>;
|
|
111
|
+
/**
|
|
112
|
+
* Function called when the table should update
|
|
113
|
+
*
|
|
114
|
+
* @param state the state of the table
|
|
115
|
+
*/
|
|
116
|
+
onChange?: onTableChangeEvent<T>;
|
|
117
|
+
/**
|
|
118
|
+
* Function that generates the expandable content of a row
|
|
119
|
+
* Return null for rows that don't need to be expandable
|
|
120
|
+
*
|
|
121
|
+
* @param datum the row for which the children should be generated.
|
|
122
|
+
*/
|
|
123
|
+
getExpandChildren?: (datum: T) => ReactNode;
|
|
124
|
+
/**
|
|
125
|
+
* React children to show when the table has no rows to show. You can leverage useTable to get the state of the table
|
|
126
|
+
*/
|
|
127
|
+
noDataChildren?: ReactNode;
|
|
128
|
+
/**
|
|
129
|
+
* Whether the table is loading or not
|
|
130
|
+
*
|
|
131
|
+
* @default false
|
|
132
|
+
*/
|
|
133
|
+
loading?: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* Childrens to display in the table. They need to be wrap in either `Table.Header` or `Table.Footer`
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* <Table ...>
|
|
139
|
+
* <Table.Header>
|
|
140
|
+
* <div>Hello</div>
|
|
141
|
+
* </Table.Header>
|
|
142
|
+
* </Table>
|
|
143
|
+
*/
|
|
144
|
+
children?: ReactNode;
|
|
145
|
+
/**
|
|
146
|
+
* Initial state of the table
|
|
147
|
+
*/
|
|
148
|
+
initialState?: InitialTableState<T>;
|
|
149
|
+
/**
|
|
150
|
+
* Action passed when user double clicks on a row
|
|
151
|
+
*/
|
|
152
|
+
doubleClickAction?: (datum: T) => void;
|
|
153
|
+
/**
|
|
154
|
+
* Whether the user can select multiple rows in order to perform actions in bulk
|
|
155
|
+
*
|
|
156
|
+
* @default false
|
|
157
|
+
*/
|
|
158
|
+
multiRowSelectionEnabled?: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Additional options that can be passed to the table
|
|
161
|
+
*/
|
|
162
|
+
options?: Omit<Partial<TableOptions<T>>, 'initialState' | 'data' | 'columns' | 'manualPagination' | 'enableMultiRowSelection' | 'getRowId' | 'getRowCanExpand' | 'enableRowSelection' | 'onRowSelectionChange'>;
|
|
163
|
+
}
|
|
164
|
+
export interface TableType {
|
|
165
|
+
<T>(props: TableProps<T>): ReactElement;
|
|
166
|
+
Actions: typeof TableActions;
|
|
167
|
+
Filter: typeof TableFilter;
|
|
168
|
+
Footer: typeof TableFooter;
|
|
169
|
+
Header: typeof TableHeader;
|
|
170
|
+
Pagination: typeof TablePagination;
|
|
171
|
+
PerPage: typeof TablePerPage;
|
|
172
|
+
Predicate: typeof TablePredicate;
|
|
173
|
+
DateRangePicker: typeof TableDateRangePicker;
|
|
174
|
+
CollapsibleColumn: typeof TableCollapsibleColumn;
|
|
175
|
+
AccordionColumn: typeof TableAccordionColumn;
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=Table.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Table.types.d.ts","sourceRoot":"","sources":["../../../../src/components/table/Table.types.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableActions.d.ts","sourceRoot":"","sources":["../../../../src/components/table/TableActions.tsx"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAE,SAAS,EAAC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"TableActions.d.ts","sourceRoot":"","sources":["../../../../src/components/table/TableActions.tsx"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAE,SAAS,EAAC,MAAM,OAAO,CAAC;AAI9C,UAAU,iBAAiB,CAAC,CAAC;IACzB;;;;;;;;;;;;;;;;;;OAkBG;IACH,QAAQ,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC;CACpE;AAED,eAAO,MAAM,YAAY,6CAA2C,YAenE,CAAC"}
|
|
@@ -1,72 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export type onTableChangeEvent = (params: TableState & TableFormType) => void;
|
|
6
|
-
export type TableFormType = {
|
|
7
|
-
/**
|
|
8
|
-
* Object containing the table predicates and their selected values
|
|
9
|
-
*
|
|
10
|
-
* @example {type: "LONG", origin: "system"}
|
|
11
|
-
*/
|
|
12
|
-
predicates: Record<string, string>;
|
|
13
|
-
/**
|
|
14
|
-
* Selected date range in the table
|
|
15
|
-
*
|
|
16
|
-
* @example [new Date(2022, 0, 1), new Date(2022, 0, 31)]
|
|
17
|
-
*/
|
|
18
|
-
dateRange: DateRangePickerValue;
|
|
19
|
-
};
|
|
20
|
-
type TableContextType = {
|
|
21
|
-
/**
|
|
22
|
-
* Function to call when the table needs an update
|
|
23
|
-
*/
|
|
24
|
-
onChange: () => void;
|
|
25
|
-
/**
|
|
26
|
-
* Internal state of the table
|
|
27
|
-
*
|
|
28
|
-
* @see https://tanstack.com/table/v8/docs/api/core/table#state
|
|
29
|
-
*/
|
|
30
|
-
state: TableState;
|
|
31
|
-
/**
|
|
32
|
-
* Function to update the table state
|
|
33
|
-
*/
|
|
34
|
-
setState: Dispatch<(prevState: TableState) => TableState>;
|
|
35
|
-
/**
|
|
36
|
-
* Whether the table currently as any kind of filter applied.
|
|
37
|
-
* Useful to determine if the noDataChildren is an empty state or just the result of a filter
|
|
38
|
-
*/
|
|
39
|
-
isFiltered: boolean;
|
|
40
|
-
/**
|
|
41
|
-
* Function that clears the filter and predicates
|
|
42
|
-
*/
|
|
43
|
-
clearFilters: () => void;
|
|
44
|
-
/**
|
|
45
|
-
* Function that returns the selected row if any.
|
|
46
|
-
*/
|
|
47
|
-
getSelectedRow: () => any | null;
|
|
48
|
-
/**
|
|
49
|
-
* Function that returns an array of the selected rows. Most useful when multi row selection is enabled.
|
|
50
|
-
*/
|
|
51
|
-
getSelectedRows: () => any[];
|
|
52
|
-
/**
|
|
53
|
-
* Function that clear the selected row
|
|
54
|
-
*/
|
|
55
|
-
clearSelection: () => void;
|
|
56
|
-
/**
|
|
57
|
-
* Form used to handle predicates and dateRange
|
|
58
|
-
*/
|
|
59
|
-
form: UseFormReturnType<TableFormType>;
|
|
60
|
-
/**
|
|
61
|
-
* Table container ref
|
|
62
|
-
*/
|
|
63
|
-
containerRef: RefObject<HTMLDivElement>;
|
|
64
|
-
multiRowSelectionEnabled: boolean;
|
|
65
|
-
/**
|
|
66
|
-
* Function that returns the number of pages
|
|
67
|
-
*/
|
|
68
|
-
getPageCount: () => number;
|
|
69
|
-
};
|
|
70
|
-
export declare const TableContext: import("react").Context<TableContextType>;
|
|
71
|
-
export {};
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TableContextType } from './Table.types';
|
|
3
|
+
export declare const TableContext: import("react").Context<TableContextType<any>>;
|
|
4
|
+
export declare const useTable: <T>() => TableContextType<T>;
|
|
72
5
|
//# sourceMappingURL=TableContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableContext.d.ts","sourceRoot":"","sources":["../../../../src/components/table/TableContext.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TableContext.d.ts","sourceRoot":"","sources":["../../../../src/components/table/TableContext.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAC,gBAAgB,EAAC,MAAM,eAAe,CAAC;AAE/C,eAAO,MAAM,YAAY,gDAAoD,CAAC;AAE9E,eAAO,MAAM,QAAQ,8BAOpB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableFilter.d.ts","sourceRoot":"","sources":["../../../../src/components/table/TableFilter.tsx"],"names":[],"mappings":"AACA,OAAO,EAA2B,YAAY,EAAE,SAAS,EAAY,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"TableFilter.d.ts","sourceRoot":"","sources":["../../../../src/components/table/TableFilter.tsx"],"names":[],"mappings":"AACA,OAAO,EAA2B,YAAY,EAAE,SAAS,EAAY,MAAM,eAAe,CAAC;AAC3F,OAAO,EAAqB,iBAAiB,EAAoB,MAAM,OAAO,CAAC;AAI/E,QAAA,MAAM,SAAS;;;;CAOZ,CAAC;AAEJ,KAAK,sBAAsB,GAAG,SAAS,CAAC,OAAO,SAAS,CAAC,CAAC;AAC1D,UAAU,gBAAiB,SAAQ,YAAY,CAAC,sBAAsB,CAAC;IACnE;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,eAAO,MAAM,WAAW,EAAE,iBAAiB,CAAC,gBAAgB,CAgD3D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TablePagination.d.ts","sourceRoot":"","sources":["../../../../src/components/table/TablePagination.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TablePagination.d.ts","sourceRoot":"","sources":["../../../../src/components/table/TablePagination.tsx"],"names":[],"mappings":"AACA,OAAO,EAAC,iBAAiB,EAAC,MAAM,OAAO,CAAC;AAIxC,UAAU,oBAAoB;IAC1B;;OAEG;IACH,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,eAAO,MAAM,eAAe,EAAE,iBAAiB,CAAC,oBAAoB,CA+BnE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TablePerPage.d.ts","sourceRoot":"","sources":["../../../../src/components/table/TablePerPage.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"TablePerPage.d.ts","sourceRoot":"","sources":["../../../../src/components/table/TablePerPage.tsx"],"names":[],"mappings":"AACA,OAAO,EAAC,iBAAiB,EAAC,MAAM,OAAO,CAAC;AAIxC,UAAU,iBAAiB;IACvB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,eAAO,MAAM,YAAY,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,GAAG;IAAC,YAAY,EAAE,MAAM,CAAA;CAyBtF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TablePredicate.d.ts","sourceRoot":"","sources":["../../../../src/components/table/TablePredicate.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"TablePredicate.d.ts","sourceRoot":"","sources":["../../../../src/components/table/TablePredicate.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgB,UAAU,EAAO,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAC,iBAAiB,EAAC,MAAM,OAAO,CAAC;AAIxC,UAAU,mBAAmB;IACzB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,cAAc,EAAE,iBAAiB,CAAC,mBAAmB,CAqBjE,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export * from './Table';
|
|
2
|
-
export {
|
|
3
|
-
export
|
|
2
|
+
export { useTable } from './TableContext';
|
|
3
|
+
export { type onTableChangeEvent, type InitialTableState, type TableState, type TableProps } from './Table.types';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/table/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/table/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,OAAO,EAAC,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAC,KAAK,kBAAkB,EAAE,KAAK,iBAAiB,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAC,MAAM,eAAe,CAAC"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { Table } from '@tanstack/table-core';
|
|
2
|
-
|
|
3
|
+
import { TableProps } from './Table.types';
|
|
4
|
+
export declare const useRowSelection: <T>(table: Table<T>, { multiRowSelectionEnabled }: Pick<TableProps<T>, "multiRowSelectionEnabled">) => {
|
|
3
5
|
clearSelection: () => void;
|
|
4
6
|
getSelectedRow: () => T;
|
|
5
7
|
getSelectedRows: () => T[];
|
|
8
|
+
outsideClickRef: import("react").MutableRefObject<any>;
|
|
6
9
|
};
|
|
7
10
|
//# sourceMappingURL=useRowSelection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRowSelection.d.ts","sourceRoot":"","sources":["../../../../src/components/table/useRowSelection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useRowSelection.d.ts","sourceRoot":"","sources":["../../../../src/components/table/useRowSelection.ts"],"names":[],"mappings":";AACA,OAAO,EAAsC,KAAK,EAAC,MAAM,sBAAsB,CAAC;AAGhF,OAAO,EAAuB,UAAU,EAAa,MAAM,eAAe,CAAC;AAE3E,eAAO,MAAM,eAAe;;;;;CAqD3B,CAAC"}
|
|
@@ -8,7 +8,7 @@ export * from '@tanstack/table-core';
|
|
|
8
8
|
export * from './components';
|
|
9
9
|
export * from '@mantine/form';
|
|
10
10
|
export { Pagination } from '@mantine/core';
|
|
11
|
-
export { Header, Table, type TableProps, type HeaderProps, Modal, Button, type ButtonProps, Menu, type MenuItemProps, } from './components';
|
|
11
|
+
export { Header, Table, type TableProps, type TableState, type InitialTableState, type HeaderProps, Modal, Button, type ButtonProps, Menu, type MenuItemProps, } from './components';
|
|
12
12
|
export { useForm, createFormContext } from './form';
|
|
13
13
|
export * from './theme';
|
|
14
14
|
declare module '@mantine/core' {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,eAAe,CAAC;AAEpC,OAAO,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAElD,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,YAAY,EAAC,iBAAiB,EAAC,MAAM,yBAAyB,CAAC;AAC/D,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAEzC,OAAO,EACH,MAAM,EACN,KAAK,EACL,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,EACL,MAAM,EACN,KAAK,WAAW,EAChB,IAAI,EACJ,KAAK,aAAa,GACrB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,OAAO,EAAE,iBAAiB,EAAC,MAAM,QAAQ,CAAC;AAElD,cAAc,SAAS,CAAC;AAExB,OAAO,QAAQ,eAAe,CAAC;IAC3B,UAAiB,0BAA0B;QAEvC,MAAM,EAAE,MAAM,CAAC,MAAM,OAAO,YAAY,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,EAAE,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC;KAChF;CACJ"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,eAAe,CAAC;AAEpC,OAAO,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAElD,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,YAAY,EAAC,iBAAiB,EAAC,MAAM,yBAAyB,CAAC;AAC/D,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AAEzC,OAAO,EACH,MAAM,EACN,KAAK,EACL,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,EACL,MAAM,EACN,KAAK,WAAW,EAChB,IAAI,EACJ,KAAK,aAAa,GACrB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAC,OAAO,EAAE,iBAAiB,EAAC,MAAM,QAAQ,CAAC;AAElD,cAAc,SAAS,CAAC;AAExB,OAAO,QAAQ,eAAe,CAAC;IAC3B,UAAiB,0BAA0B;QAEvC,MAAM,EAAE,MAAM,CAAC,MAAM,OAAO,YAAY,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,EAAE,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC;KAChF;CACJ"}
|
|
@@ -6,7 +6,7 @@ import _sliced_to_array from "@swc/helpers/src/_sliced_to_array.mjs";
|
|
|
6
6
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
7
7
|
import { Box, Center, Collapse, Loader, Skeleton, Table as MantineTable } from "@mantine/core";
|
|
8
8
|
import { useForm } from "@mantine/form";
|
|
9
|
-
import {
|
|
9
|
+
import { useDidUpdate } from "@mantine/hooks";
|
|
10
10
|
import { defaultColumnSizing, flexRender, getCoreRowModel, useReactTable } from "@tanstack/react-table";
|
|
11
11
|
import debounce from "lodash.debounce";
|
|
12
12
|
import defaultsDeep from "lodash.defaultsdeep";
|
|
@@ -80,7 +80,9 @@ export var Table = function(param) {
|
|
|
80
80
|
onStateChange: setState
|
|
81
81
|
});
|
|
82
82
|
});
|
|
83
|
-
var _useRowSelection = useRowSelection(table
|
|
83
|
+
var _useRowSelection = useRowSelection(table, {
|
|
84
|
+
multiRowSelectionEnabled: multiRowSelectionEnabled
|
|
85
|
+
}), clearSelection = _useRowSelection.clearSelection, getSelectedRow = _useRowSelection.getSelectedRow, getSelectedRows = _useRowSelection.getSelectedRows, outsideClickRef = _useRowSelection.outsideClickRef;
|
|
84
86
|
var _form_values_predicates;
|
|
85
87
|
var isFiltered = !!state.globalFilter || Object.keys((_form_values_predicates = (_form_values = form.values) === null || _form_values === void 0 ? void 0 : _form_values.predicates) !== null && _form_values_predicates !== void 0 ? _form_values_predicates : {}).some(function(predicate) {
|
|
86
88
|
return !!form.values.predicates[predicate];
|
|
@@ -114,11 +116,6 @@ export var Table = function(param) {
|
|
|
114
116
|
});
|
|
115
117
|
});
|
|
116
118
|
}, []);
|
|
117
|
-
var outsideClickRef = useClickOutside(function() {
|
|
118
|
-
if (!multiRowSelectionEnabled) {
|
|
119
|
-
clearSelection();
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
119
|
if (!data) {
|
|
123
120
|
return /*#__PURE__*/ _jsx(Center, {
|
|
124
121
|
sx: {
|
|
@@ -130,6 +127,7 @@ export var Table = function(param) {
|
|
|
130
127
|
var rows = table.getRowModel().rows.map(function(row) {
|
|
131
128
|
var _getExpandChildren;
|
|
132
129
|
var rowChildren = (_getExpandChildren = getExpandChildren === null || getExpandChildren === void 0 ? void 0 : getExpandChildren(row.original)) !== null && _getExpandChildren !== void 0 ? _getExpandChildren : null;
|
|
130
|
+
var isSelected = !!row.getIsSelected();
|
|
133
131
|
return /*#__PURE__*/ _jsxs(Fragment, {
|
|
134
132
|
children: [
|
|
135
133
|
/*#__PURE__*/ _jsx("tr", {
|
|
@@ -139,8 +137,8 @@ export var Table = function(param) {
|
|
|
139
137
|
onDoubleClick: function() {
|
|
140
138
|
return doubleClickAction === null || doubleClickAction === void 0 ? void 0 : doubleClickAction(row.original);
|
|
141
139
|
},
|
|
142
|
-
className: cx(classes.row, _define_property({}, classes.rowSelected,
|
|
143
|
-
"aria-selected":
|
|
140
|
+
className: cx(classes.row, _define_property({}, classes.rowSelected, isSelected)),
|
|
141
|
+
"aria-selected": isSelected,
|
|
144
142
|
children: row.getVisibleCells().map(function(cell) {
|
|
145
143
|
var size = cell.column.getSize();
|
|
146
144
|
var width = size !== defaultColumnSizing.size ? size : undefined;
|
|
@@ -161,7 +159,7 @@ export var Table = function(param) {
|
|
|
161
159
|
}),
|
|
162
160
|
rowChildren ? /*#__PURE__*/ _jsx("tr", {
|
|
163
161
|
children: /*#__PURE__*/ _jsx("td", {
|
|
164
|
-
colSpan:
|
|
162
|
+
colSpan: table.getAllColumns().length,
|
|
165
163
|
style: {
|
|
166
164
|
padding: 0,
|
|
167
165
|
borderTop: row.getIsExpanded() ? undefined : "none",
|
|
@@ -221,7 +219,7 @@ export var Table = function(param) {
|
|
|
221
219
|
/*#__PURE__*/ _jsx("tbody", {
|
|
222
220
|
children: rows.length ? rows : /*#__PURE__*/ _jsx("tr", {
|
|
223
221
|
children: /*#__PURE__*/ _jsx("td", {
|
|
224
|
-
colSpan:
|
|
222
|
+
colSpan: table.getAllColumns().length,
|
|
225
223
|
children: noDataChildren
|
|
226
224
|
})
|
|
227
225
|
})
|