@coveord/plasma-mantine 49.3.4 → 49.3.6
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/collection/CollectionItem.js +6 -0
- package/dist/cjs/components/collection/CollectionItem.js.map +1 -1
- package/dist/cjs/components/table/Table.js +10 -53
- package/dist/cjs/components/table/Table.js.map +1 -1
- package/dist/cjs/components/table/Table.styles.js +56 -0
- package/dist/cjs/components/table/Table.styles.js.map +1 -0
- 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.styles.d.ts +11 -0
- package/dist/definitions/components/table/Table.styles.d.ts.map +1 -0
- 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/collection/CollectionItem.js +6 -0
- package/dist/esm/components/collection/CollectionItem.js.map +1 -1
- package/dist/esm/components/table/Table.js +11 -54
- package/dist/esm/components/table/Table.js.map +1 -1
- package/dist/esm/components/table/Table.styles.js +46 -0
- package/dist/esm/components/table/Table.styles.js.map +1 -0
- 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 +6 -5
- package/src/components/collection/CollectionItem.tsx +2 -2
- package/src/components/table/Table.styles.ts +58 -0
- package/src/components/table/Table.tsx +18 -173
- 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/TablePagination.tsx"],"sourcesContent":["import {Pagination} from '@mantine/core';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/table/TablePagination.tsx"],"sourcesContent":["import {Pagination} from '@mantine/core';\nimport {FunctionComponent} from 'react';\n\nimport {useTable} from './TableContext';\n\ninterface TablePaginationProps {\n /**\n * The total number of page. Use null only if your table is paginated client side\n */\n totalPages: number | null;\n}\n\nexport const TablePagination: FunctionComponent<TablePaginationProps> = ({totalPages}) => {\n const {state, setState, containerRef, getPageCount} = useTable();\n const updatePage = (newPage: number) => {\n setState((prevState) => ({\n ...prevState,\n pagination: {...prevState.pagination, pageIndex: newPage - 1},\n }));\n containerRef.current.scrollIntoView({behavior: 'smooth'});\n };\n\n const total = totalPages === null ? getPageCount() : totalPages;\n\n return (\n <Pagination\n page={state.pagination.pageIndex + 1}\n onChange={updatePage}\n total={total}\n boundaries={0}\n size=\"md\"\n getItemAriaLabel={(label) => {\n switch (label) {\n case 'prev':\n return 'previous page';\n case 'next':\n return 'next page';\n default:\n return `${label}`;\n }\n }}\n />\n );\n};\n"],"names":["Pagination","useTable","TablePagination","totalPages","state","setState","containerRef","getPageCount","updatePage","newPage","prevState","pagination","pageIndex","current","scrollIntoView","behavior","total","page","onChange","boundaries","size","getItemAriaLabel","label"],"mappings":";;;AAAA,SAAQA,UAAU,QAAO,gBAAgB;AAGzC,SAAQC,QAAQ,QAAO,iBAAiB;AASxC,OAAO,IAAMC,kBAA2D,gBAAkB;QAAhBC,mBAAAA;IACtE,IAAsDF,YAAAA,YAA/CG,QAA+CH,UAA/CG,OAAOC,WAAwCJ,UAAxCI,UAAUC,eAA8BL,UAA9BK,cAAcC,eAAgBN,UAAhBM;IACtC,IAAMC,aAAa,SAACC,SAAoB;QACpCJ,SAAS,SAACK;mBAAe,wCAClBA;gBACHC,YAAY,wCAAID,UAAUC,UAAU;oBAAEC,WAAWH,UAAU;;;;QAE/DH,aAAaO,OAAO,CAACC,cAAc,CAAC;YAACC,UAAU;QAAQ;IAC3D;IAEA,IAAMC,QAAQb,eAAe,IAAI,GAAGI,iBAAiBJ,UAAU;IAE/D,qBACI,KAACH;QACGiB,MAAMb,MAAMO,UAAU,CAACC,SAAS,GAAG;QACnCM,UAAUV;QACVQ,OAAOA;QACPG,YAAY;QACZC,MAAK;QACLC,kBAAkB,SAACC,OAAU;YACzB,OAAQA;gBACJ,KAAK;oBACD,OAAO;gBACX,KAAK;oBACD,OAAO;gBACX;oBACI,OAAO,AAAC,GAAQ,OAANA;YAClB;QACJ;;AAGZ,EAAE"}
|
|
@@ -2,7 +2,7 @@ import _object_spread from "@swc/helpers/src/_object_spread.mjs";
|
|
|
2
2
|
import _object_spread_props from "@swc/helpers/src/_object_spread_props.mjs";
|
|
3
3
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
4
|
import { Group, SegmentedControl, Text } from "@mantine/core";
|
|
5
|
-
import { useTable } from "./
|
|
5
|
+
import { useTable } from "./TableContext";
|
|
6
6
|
export var TablePerPage = function(param) {
|
|
7
7
|
var _param_label = param.label, label = _param_label === void 0 ? "Results per page" : _param_label, _param_values = param.values, values = _param_values === void 0 ? [
|
|
8
8
|
25,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/table/TablePerPage.tsx"],"sourcesContent":["import {Group, SegmentedControl, Text} from '@mantine/core';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/table/TablePerPage.tsx"],"sourcesContent":["import {Group, SegmentedControl, Text} from '@mantine/core';\nimport {FunctionComponent} from 'react';\n\nimport {useTable} from './TableContext';\n\ninterface TablePerPageProps {\n /**\n * The label displayed before the control\n *\n * @default Results per page\n */\n label?: string;\n /**\n * The per page choices to display\n *\n * @default [25, 50, 100]\n */\n values?: number[];\n}\n\nexport const TablePerPage: FunctionComponent<TablePerPageProps> & {DEFAULT_SIZE: number} = ({\n label = 'Results per page',\n values = [25, 50, 100],\n}) => {\n const {state, setState} = useTable();\n\n const updatePerPage = (newPerPage: string) => {\n setState((prevState) => ({\n ...prevState,\n pagination: {pageIndex: 0, pageSize: parseInt(newPerPage, 10)},\n }));\n };\n\n return (\n <Group>\n <Text>{label}</Text>\n <SegmentedControl\n value={state.pagination.pageSize.toString() ?? values?.[1].toString()}\n onChange={updatePerPage}\n data={values.map((value) => value.toString())}\n color=\"action\"\n size=\"md\"\n />\n </Group>\n );\n};\n\nTablePerPage.DEFAULT_SIZE = 50;\n"],"names":["Group","SegmentedControl","Text","useTable","TablePerPage","label","values","state","setState","updatePerPage","newPerPage","prevState","pagination","pageIndex","pageSize","parseInt","value","toString","onChange","data","map","color","size","DEFAULT_SIZE"],"mappings":";;;AAAA,SAAQA,KAAK,EAAEC,gBAAgB,EAAEC,IAAI,QAAO,gBAAgB;AAG5D,SAAQC,QAAQ,QAAO,iBAAiB;AAiBxC,OAAO,IAAMC,eAA8E,gBAGrF;6BAFFC,OAAAA,kCAAQ,yDACRC,QAAAA,oCAAS;QAAC;QAAI;QAAI;KAAI;IAEtB,IAA0BH,YAAAA,YAAnBI,QAAmBJ,UAAnBI,OAAOC,WAAYL,UAAZK;IAEd,IAAMC,gBAAgB,SAACC,YAAuB;QAC1CF,SAAS,SAACG;mBAAe,wCAClBA;gBACHC,YAAY;oBAACC,WAAW;oBAAGC,UAAUC,SAASL,YAAY;gBAAG;;;IAErE;QAMmBH;IAJnB,qBACI,MAACP;;0BACG,KAACE;0BAAMG;;0BACP,KAACJ;gBACGe,OAAOT,CAAAA,sCAAAA,MAAMK,UAAU,CAACE,QAAQ,CAACG,QAAQ,gBAAlCV,iDAAAA,sCAAwCD,mBAAAA,oBAAAA,KAAAA,IAAAA,MAAQ,CAAC,EAAE,CAACW,QAAQ,EAAE;gBACrEC,UAAUT;gBACVU,MAAMb,OAAOc,GAAG,CAAC,SAACJ;2BAAUA,MAAMC,QAAQ;;gBAC1CI,OAAM;gBACNC,MAAK;;;;AAIrB,EAAE;AAEFlB,aAAamB,YAAY,GAAG"}
|
|
@@ -2,8 +2,8 @@ import _define_property from "@swc/helpers/src/_define_property.mjs";
|
|
|
2
2
|
import _object_spread from "@swc/helpers/src/_object_spread.mjs";
|
|
3
3
|
import _object_spread_props from "@swc/helpers/src/_object_spread_props.mjs";
|
|
4
4
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
-
import {
|
|
6
|
-
import { useTable } from "./
|
|
5
|
+
import { Group, Select, Text } from "@mantine/core";
|
|
6
|
+
import { useTable } from "./TableContext";
|
|
7
7
|
export var TablePredicate = function(param) {
|
|
8
8
|
var id = param.id, data = param.data, label = param.label;
|
|
9
9
|
var _useTable = useTable(), onChange = _useTable.onChange, form = _useTable.form;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/table/TablePredicate.tsx"],"sourcesContent":["import {Select, SelectItem,
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/table/TablePredicate.tsx"],"sourcesContent":["import {Group, Select, SelectItem, Text} from '@mantine/core';\nimport {FunctionComponent} from 'react';\n\nimport {useTable} from './TableContext';\n\ninterface TablePredicateProps {\n /**\n * Unique identifier for this predicate. Will be used to access the selected value in the table state\n */\n id: string;\n /**\n * The values to display in the predicate\n */\n data: SelectItem[];\n /**\n * Input label (not displayed for now)\n *\n * @default default to the predicate id\n */\n label?: string;\n}\n\nexport const TablePredicate: FunctionComponent<TablePredicateProps> = ({id, data, label}) => {\n const {onChange, form} = useTable();\n\n const onUpdate = (newValue: string) => {\n form.setFieldValue('predicates', {...form.values.predicates, [id]: newValue});\n onChange?.();\n };\n\n return (\n <Group spacing=\"xs\">\n {label ? <Text>{label}:</Text> : null}\n <Select\n withinPortal\n value={form.values.predicates[id]}\n onChange={onUpdate}\n data={data}\n aria-label={label ?? id}\n searchable={data.length > 7}\n />\n </Group>\n );\n};\n"],"names":["Group","Select","Text","useTable","TablePredicate","id","data","label","onChange","form","onUpdate","newValue","setFieldValue","values","predicates","spacing","withinPortal","value","aria-label","searchable","length"],"mappings":";;;;AAAA,SAAQA,KAAK,EAAEC,MAAM,EAAcC,IAAI,QAAO,gBAAgB;AAG9D,SAAQC,QAAQ,QAAO,iBAAiB;AAmBxC,OAAO,IAAMC,iBAAyD,gBAAuB;QAArBC,WAAAA,IAAIC,aAAAA,MAAMC,cAAAA;IAC9E,IAAyBJ,YAAAA,YAAlBK,WAAkBL,UAAlBK,UAAUC,OAAQN,UAARM;IAEjB,IAAMC,WAAW,SAACC,UAAqB;QACnCF,KAAKG,aAAa,CAAC,cAAc,wCAAIH,KAAKI,MAAM,CAACC,UAAU,GAAE,qBAACT,IAAKM;QACnEH,qBAAAA,sBAAAA,KAAAA,IAAAA;IACJ;IAEA,qBACI,MAACR;QAAMe,SAAQ;;YACVR,sBAAQ,MAACL;;oBAAMK;oBAAM;;iBAAW,IAAI;0BACrC,KAACN;gBACGe,YAAY;gBACZC,OAAOR,KAAKI,MAAM,CAACC,UAAU,CAACT,GAAG;gBACjCG,UAAUE;gBACVJ,MAAMA;gBACNY,cAAYX,kBAAAA,mBAAAA,QAASF,EAAE;gBACvBc,YAAYb,KAAKc,MAAM,GAAG;;;;AAI1C,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/table/index.ts"],"sourcesContent":["export * from './Table';\nexport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/table/index.ts"],"sourcesContent":["export * from './Table';\nexport {useTable} from './TableContext';\nexport {type onTableChangeEvent, type InitialTableState, type TableState, type TableProps} from './Table.types';\n"],"names":["useTable"],"mappings":"AAAA,cAAc,UAAU;AACxB,SAAQA,QAAQ,QAAO,iBAAiB"}
|
|
@@ -1,28 +1,36 @@
|
|
|
1
1
|
import _object_spread from "@swc/helpers/src/_object_spread.mjs";
|
|
2
2
|
import _object_spread_props from "@swc/helpers/src/_object_spread_props.mjs";
|
|
3
|
-
import
|
|
3
|
+
import { useClickOutside } from "@mantine/hooks";
|
|
4
4
|
import { functionalUpdate } from "@tanstack/table-core";
|
|
5
|
-
import
|
|
6
|
-
export var useRowSelection = function(table) {
|
|
7
|
-
var
|
|
5
|
+
import isEqual from "fast-deep-equal";
|
|
6
|
+
export var useRowSelection = function(table, param) {
|
|
7
|
+
var multiRowSelectionEnabled = param.multiRowSelectionEnabled;
|
|
8
|
+
var outsideClickRef = useClickOutside(function() {
|
|
9
|
+
if (!multiRowSelectionEnabled) {
|
|
10
|
+
clearSelection();
|
|
11
|
+
}
|
|
12
|
+
});
|
|
8
13
|
table.setOptions(function(prev) {
|
|
9
14
|
return _object_spread_props(_object_spread({}, prev), {
|
|
10
15
|
onRowSelectionChange: function(rowSelectionUpdater) {
|
|
11
16
|
table.setState(function(old) {
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
var newRowSelection = functionalUpdate(rowSelectionUpdater, old["rowSelection"]);
|
|
18
|
+
if (isEqual(old["rowSelection"], newRowSelection)) {
|
|
19
|
+
return old;
|
|
20
|
+
}
|
|
21
|
+
var rows = table.getRowModel().rowsById;
|
|
22
|
+
Object.keys(newRowSelection).forEach(function(rowId) {
|
|
23
|
+
if (newRowSelection[rowId] === true) {
|
|
24
|
+
var _rows_rowId;
|
|
25
|
+
if (!rows[rowId]) {
|
|
26
|
+
console.error("The table was not initialized properly, the rowSelection state should contain an object of type Record<string, TData>.");
|
|
20
27
|
}
|
|
21
|
-
|
|
22
|
-
|
|
28
|
+
var _rows_rowId_original;
|
|
29
|
+
newRowSelection[rowId] = (_rows_rowId_original = (_rows_rowId = rows[rowId]) === null || _rows_rowId === void 0 ? void 0 : _rows_rowId.original) !== null && _rows_rowId_original !== void 0 ? _rows_rowId_original : true;
|
|
30
|
+
}
|
|
23
31
|
});
|
|
24
32
|
return _object_spread_props(_object_spread({}, old), {
|
|
25
|
-
rowSelection:
|
|
33
|
+
rowSelection: newRowSelection
|
|
26
34
|
});
|
|
27
35
|
});
|
|
28
36
|
}
|
|
@@ -32,7 +40,7 @@ export var useRowSelection = function(table) {
|
|
|
32
40
|
table.resetRowSelection(true);
|
|
33
41
|
};
|
|
34
42
|
var getSelectedRows = function() {
|
|
35
|
-
return Object.values(rowSelection);
|
|
43
|
+
return Object.values(table.getState().rowSelection);
|
|
36
44
|
};
|
|
37
45
|
var _getSelectedRows_;
|
|
38
46
|
var getSelectedRow = function() {
|
|
@@ -41,7 +49,8 @@ export var useRowSelection = function(table) {
|
|
|
41
49
|
return {
|
|
42
50
|
clearSelection: clearSelection,
|
|
43
51
|
getSelectedRow: getSelectedRow,
|
|
44
|
-
getSelectedRows: getSelectedRows
|
|
52
|
+
getSelectedRows: getSelectedRows,
|
|
53
|
+
outsideClickRef: outsideClickRef
|
|
45
54
|
};
|
|
46
55
|
};
|
|
47
56
|
|
|
@@ -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":["useClickOutside","functionalUpdate","isEqual","useRowSelection","table","multiRowSelectionEnabled","outsideClickRef","clearSelection","setOptions","prev","onRowSelectionChange","rowSelectionUpdater","setState","old","newRowSelection","rows","getRowModel","rowsById","Object","keys","forEach","rowId","console","error","original","rowSelection","resetRowSelection","getSelectedRows","values","getState","getSelectedRow"],"mappings":";;AAAA,SAAQA,eAAe,QAAO,iBAAiB;AAC/C,SAAQC,gBAAgB,QAAiC,uBAAuB;AAChF,OAAOC,aAAa,kBAAkB;AAItC,OAAO,IAAMC,kBAAkB,SAC3BC,cAEC;QADAC,iCAAAA;IAED,IAAMC,kBAAkBN,gBAAgB,WAAM;QAC1C,IAAI,CAACK,0BAA0B;YAC3BE;QACJ,CAAC;IACL;IAEAH,MAAMI,UAAU,CAAC,SAACC;QAAU,OAAA,wCACrBA;YACHC,sBAAsB,SAACC,qBAAwB;gBAC3CP,MAAMQ,QAAQ,CAAC,SAACC,KAAQ;oBACpB,IAAMC,kBAAkBb,iBACpBU,qBACAE,GAAG,CAAC,eAAe;oBAGvB,IAAIX,QAAQW,GAAG,CAAC,eAAe,EAAEC,kBAAkB;wBAC/C,OAAOD;oBACX,CAAC;oBAED,IAAME,OAAOX,MAAMY,WAAW,GAAGC,QAAQ;oBAEzCC,OAAOC,IAAI,CAACL,iBAAiBM,OAAO,CAAC,SAACC,OAAU;wBAC5C,IAAIP,eAAe,CAACO,MAAM,KAAK,IAAI,EAAE;gCAMRN;4BALzB,IAAI,CAACA,IAAI,CAACM,MAAM,EAAE;gCACdC,QAAQC,KAAK,CACT;4BAER,CAAC;gCACwBR;4BAAzBD,eAAe,CAACO,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,wCACAF;wBACHY,cAAcX;;gBAEtB;YACJ;;;IAGJ,IAAMP,iBAAiB,WAAM;QACzBH,MAAMsB,iBAAiB,CAAC,IAAI;IAChC;IAEA,IAAMC,kBAAkB;eAAMT,OAAOU,MAAM,CAAC,AAACxB,MAAMyB,QAAQ,GAAqBJ,YAAY;;QAE/DE;IAA7B,IAAMG,iBAAiB;eAAMH,CAAAA,oBAAAA,iBAAiB,CAAC,EAAE,cAApBA,+BAAAA,oBAAwB,IAAI;;IAEzD,OAAO;QAACpB,gBAAAA;QAAgBuB,gBAAAA;QAAgBH,iBAAAA;QAAiBrB,iBAAAA;IAAe;AAC5E,EAAE"}
|
package/dist/esm/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":"AAIA,cAAc,oBAAoB;AAClC,cAAc,gBAAgB;AAE9B,cAAc,iBAAiB;AAC/B,cAAc,uBAAuB;AACrC,cAAc,eAAe;AAC7B,cAAc,gBAAgB;AAC9B,SAAQA,UAAU,QAAO,gBAAgB;AACzC,2CAA2C;AAC3C,SACIC,MAAM,EACNC,KAAK,
|
|
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":"AAIA,cAAc,oBAAoB;AAClC,cAAc,gBAAgB;AAE9B,cAAc,iBAAiB;AAC/B,cAAc,uBAAuB;AACrC,cAAc,eAAe;AAC7B,cAAc,gBAAgB;AAC9B,SAAQA,UAAU,QAAO,gBAAgB;AACzC,2CAA2C;AAC3C,SACIC,MAAM,EACNC,KAAK,EAKLC,KAAK,EACLC,MAAM,EAENC,IAAI,QAED,eAAe;AACtB,SAAQC,OAAO,EAAEC,iBAAiB,QAAO,SAAS;AAElD,cAAc,UAAU"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coveord/plasma-mantine",
|
|
3
|
-
"version": "49.3.
|
|
3
|
+
"version": "49.3.6",
|
|
4
4
|
"description": "A Plasma flavoured Mantine theme",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"plasma",
|
|
@@ -20,12 +20,13 @@
|
|
|
20
20
|
"@tanstack/react-table": "8.7.9",
|
|
21
21
|
"@tanstack/table-core": "8.7.9",
|
|
22
22
|
"dayjs": "1.11.3",
|
|
23
|
+
"fast-deep-equal": "3.1.3",
|
|
23
24
|
"lodash.debounce": "4.0.8",
|
|
24
25
|
"lodash.defaultsdeep": "4.6.1",
|
|
25
26
|
"monaco-editor": "0.34.0",
|
|
26
27
|
"react-beautiful-dnd": "13.1.1",
|
|
27
|
-
"@coveord/plasma-react-icons": "49.
|
|
28
|
-
"@coveord/plasma-tokens": "
|
|
28
|
+
"@coveord/plasma-react-icons": "49.3.6",
|
|
29
|
+
"@coveord/plasma-tokens": "49.3.6"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
32
|
"@emotion/react": "11.10.5",
|
|
@@ -35,8 +36,8 @@
|
|
|
35
36
|
"@mantine/form": "5.9.2",
|
|
36
37
|
"@mantine/hooks": "5.9.2",
|
|
37
38
|
"@mantine/modals": "5.9.2",
|
|
38
|
-
"@swc/cli": "0.1.
|
|
39
|
-
"@swc/core": "1.3.
|
|
39
|
+
"@swc/cli": "0.1.61",
|
|
40
|
+
"@swc/core": "1.3.35",
|
|
40
41
|
"@swc/jest": "0.2.23",
|
|
41
42
|
"@testing-library/dom": "8.18.1",
|
|
42
43
|
"@testing-library/jest-dom": "5.16.5",
|
|
@@ -19,7 +19,7 @@ interface CollectionItemSharedProps extends DefaultProps<Selectors<typeof useSty
|
|
|
19
19
|
const RemoveButton: FunctionComponent<{
|
|
20
20
|
onClick: React.MouseEventHandler<HTMLButtonElement>;
|
|
21
21
|
}> = ({onClick}) => (
|
|
22
|
-
<ActionIcon variant="subtle" onClick={onClick} color="action">
|
|
22
|
+
<ActionIcon sx={{alignSelf: 'center'}} variant="subtle" onClick={onClick} color="action">
|
|
23
23
|
<RemoveSize16Px height={16} />
|
|
24
24
|
</ActionIcon>
|
|
25
25
|
);
|
|
@@ -69,7 +69,7 @@ const DraggableCollectionItem: FunctionComponent<PropsWithChildren<CollectionIte
|
|
|
69
69
|
{...provided.draggableProps}
|
|
70
70
|
className={cx(classes.item, {[classes.itemDragging]: isDragging})}
|
|
71
71
|
>
|
|
72
|
-
<div {...provided.dragHandleProps}>
|
|
72
|
+
<div {...provided.dragHandleProps} style={{alignSelf: 'center'}}>
|
|
73
73
|
<DragAndDropSize16Px height={16} />
|
|
74
74
|
</div>
|
|
75
75
|
{children}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {createStyles} from '@mantine/core';
|
|
2
|
+
|
|
3
|
+
interface TableStylesParams {
|
|
4
|
+
hasHeader: boolean;
|
|
5
|
+
multiRowSelectionEnabled: boolean;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const useStyles = createStyles<string, TableStylesParams>((theme, {hasHeader, multiRowSelectionEnabled}) => {
|
|
9
|
+
const rowBackgroundColor =
|
|
10
|
+
theme.colorScheme === 'dark'
|
|
11
|
+
? theme.fn.rgba(theme.colors[theme.primaryColor][7], 0.2)
|
|
12
|
+
: theme.colors[theme.primaryColor][0];
|
|
13
|
+
return {
|
|
14
|
+
table: {
|
|
15
|
+
width: '100%',
|
|
16
|
+
'& td:first-of-type, th:first-of-type > *': {
|
|
17
|
+
paddingLeft: theme.spacing.xl,
|
|
18
|
+
},
|
|
19
|
+
'& tbody td': {
|
|
20
|
+
verticalAlign: 'top',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
header: {
|
|
25
|
+
position: 'sticky',
|
|
26
|
+
top: hasHeader ? 69 : 0,
|
|
27
|
+
backgroundColor: theme.colorScheme === 'dark' ? theme.black : theme.white,
|
|
28
|
+
transition: 'box-shadow 150ms ease',
|
|
29
|
+
zIndex: 12, // skeleton is 11
|
|
30
|
+
|
|
31
|
+
'&::after': {
|
|
32
|
+
content: '""',
|
|
33
|
+
position: 'absolute',
|
|
34
|
+
left: 0,
|
|
35
|
+
right: 0,
|
|
36
|
+
bottom: 0,
|
|
37
|
+
borderBottom: `1px solid ${theme.colors.gray[2]}`,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
rowSelected: {
|
|
42
|
+
backgroundColor: multiRowSelectionEnabled ? undefined : rowBackgroundColor,
|
|
43
|
+
},
|
|
44
|
+
|
|
45
|
+
rowCollapsibleButtonCell: {
|
|
46
|
+
textAlign: 'right',
|
|
47
|
+
padding: `${theme.spacing.xs / 2}px ${theme.spacing.sm}px !important`,
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
row: {
|
|
51
|
+
'&:hover': {
|
|
52
|
+
backgroundColor: rowBackgroundColor,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
export default useStyles;
|
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
import {Box, Center, Collapse,
|
|
1
|
+
import {Box, Center, Collapse, Loader, Skeleton, Table as MantineTable} from '@mantine/core';
|
|
2
2
|
import {useForm} from '@mantine/form';
|
|
3
|
-
import {
|
|
3
|
+
import {useDidUpdate} from '@mantine/hooks';
|
|
4
4
|
import {
|
|
5
5
|
ColumnDef,
|
|
6
6
|
defaultColumnSizing,
|
|
7
7
|
flexRender,
|
|
8
8
|
getCoreRowModel,
|
|
9
9
|
Row,
|
|
10
|
-
TableState,
|
|
10
|
+
TableState as TanstackTableState,
|
|
11
11
|
useReactTable,
|
|
12
12
|
} from '@tanstack/react-table';
|
|
13
|
-
import {CoreOptions, InitialTableState, TableOptions} from '@tanstack/table-core';
|
|
14
13
|
import debounce from 'lodash.debounce';
|
|
15
14
|
import defaultsDeep from 'lodash.defaultsdeep';
|
|
16
|
-
import {Children, Fragment, ReactElement,
|
|
15
|
+
import {Children, Dispatch, Fragment, ReactElement, useCallback, useEffect, useState} from 'react';
|
|
17
16
|
|
|
17
|
+
import useStyles from './Table.styles';
|
|
18
|
+
import {TableFormType, TableProps, TableState, TableType} from './Table.types';
|
|
18
19
|
import {TableActions} from './TableActions';
|
|
19
20
|
import {TableAccordionColumn, TableCollapsibleColumn} from './TableCollapsibleColumn';
|
|
20
|
-
import {
|
|
21
|
+
import {TableContext} from './TableContext';
|
|
21
22
|
import {TableDateRangePicker} from './TableDateRangePicker';
|
|
22
23
|
import {TableFilter} from './TableFilter';
|
|
23
24
|
import {TableFooter} from './TableFooter';
|
|
@@ -29,159 +30,6 @@ import {TableSelectableColumn} from './TableSelectableColumn';
|
|
|
29
30
|
import {Th} from './Th';
|
|
30
31
|
import {useRowSelection} from './useRowSelection';
|
|
31
32
|
|
|
32
|
-
interface TableStylesParams {
|
|
33
|
-
hasHeader: boolean;
|
|
34
|
-
multiRowSelectionEnabled: boolean;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const useStyles = createStyles<string, TableStylesParams>((theme, {hasHeader, multiRowSelectionEnabled}) => {
|
|
38
|
-
const rowBackgroundColor =
|
|
39
|
-
theme.colorScheme === 'dark'
|
|
40
|
-
? theme.fn.rgba(theme.colors[theme.primaryColor][7], 0.2)
|
|
41
|
-
: theme.colors[theme.primaryColor][0];
|
|
42
|
-
return {
|
|
43
|
-
table: {
|
|
44
|
-
width: '100%',
|
|
45
|
-
'& td:first-of-type, th:first-of-type > *': {
|
|
46
|
-
paddingLeft: theme.spacing.xl,
|
|
47
|
-
},
|
|
48
|
-
'& tbody td': {
|
|
49
|
-
verticalAlign: 'top',
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
header: {
|
|
54
|
-
position: 'sticky',
|
|
55
|
-
top: hasHeader ? 69 : 0,
|
|
56
|
-
backgroundColor: theme.colorScheme === 'dark' ? theme.black : theme.white,
|
|
57
|
-
transition: 'box-shadow 150ms ease',
|
|
58
|
-
zIndex: 12, // skeleton is 11
|
|
59
|
-
|
|
60
|
-
'&::after': {
|
|
61
|
-
content: '""',
|
|
62
|
-
position: 'absolute',
|
|
63
|
-
left: 0,
|
|
64
|
-
right: 0,
|
|
65
|
-
bottom: 0,
|
|
66
|
-
borderBottom: `1px solid ${theme.colors.gray[2]}`,
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
rowSelected: {
|
|
71
|
-
backgroundColor: multiRowSelectionEnabled ? undefined : rowBackgroundColor,
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
rowCollapsibleButtonCell: {
|
|
75
|
-
textAlign: 'right',
|
|
76
|
-
padding: `${theme.spacing.xs / 2}px ${theme.spacing.sm}px !important`,
|
|
77
|
-
},
|
|
78
|
-
|
|
79
|
-
row: {
|
|
80
|
-
'&:hover': {
|
|
81
|
-
backgroundColor: rowBackgroundColor,
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
export interface TableProps<T> {
|
|
88
|
-
/**
|
|
89
|
-
* Data to display in the table
|
|
90
|
-
*/
|
|
91
|
-
data: T[];
|
|
92
|
-
/**
|
|
93
|
-
* Defines how each row is uniquely identified. It is highly recommended that you specify this prop to an ID that makes sense.
|
|
94
|
-
*/
|
|
95
|
-
getRowId?: CoreOptions<T>['getRowId'];
|
|
96
|
-
/**
|
|
97
|
-
* Columns to display in the table.
|
|
98
|
-
*
|
|
99
|
-
* @see https://tanstack.com/table/v8/docs/guide/column-defs
|
|
100
|
-
*/
|
|
101
|
-
columns: Array<ColumnDef<T>>;
|
|
102
|
-
/**
|
|
103
|
-
* Function called when the table mounts
|
|
104
|
-
*
|
|
105
|
-
* @param state the state of the table
|
|
106
|
-
*/
|
|
107
|
-
onMount?: onTableChangeEvent;
|
|
108
|
-
/**
|
|
109
|
-
* Function called when the table should update
|
|
110
|
-
*
|
|
111
|
-
* @param state the state of the table
|
|
112
|
-
*/
|
|
113
|
-
onChange?: onTableChangeEvent;
|
|
114
|
-
/**
|
|
115
|
-
* Function that generates the expandable content of a row
|
|
116
|
-
* Return null for rows that don't need to be expandable
|
|
117
|
-
*
|
|
118
|
-
* @param datum the row for which the children should be generated.
|
|
119
|
-
*/
|
|
120
|
-
getExpandChildren?: (datum: T) => ReactNode;
|
|
121
|
-
/**
|
|
122
|
-
* React children to show when the table has no rows to show. You can leverage useTable to get the state of the table
|
|
123
|
-
*/
|
|
124
|
-
noDataChildren?: ReactNode;
|
|
125
|
-
/**
|
|
126
|
-
* Whether the table is loading or not
|
|
127
|
-
*
|
|
128
|
-
* @default false
|
|
129
|
-
*/
|
|
130
|
-
loading?: boolean;
|
|
131
|
-
/**
|
|
132
|
-
* Childrens to display in the table. They need to be wrap in either `Table.Header` or `Table.Footer`
|
|
133
|
-
*
|
|
134
|
-
* @example
|
|
135
|
-
* <Table ...>
|
|
136
|
-
* <Table.Header>
|
|
137
|
-
* <div>Hello</div>
|
|
138
|
-
* </Table.Header>
|
|
139
|
-
* </Table>
|
|
140
|
-
*/
|
|
141
|
-
children?: ReactNode;
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Initial state of the table
|
|
145
|
-
*/
|
|
146
|
-
initialState?: InitialTableState & Partial<TableFormType>;
|
|
147
|
-
/**
|
|
148
|
-
* Action passed when user double clicks on a row
|
|
149
|
-
*/
|
|
150
|
-
doubleClickAction?: (datum: T) => void;
|
|
151
|
-
/**
|
|
152
|
-
* Whether the user can select multiple rows in order to perform actions in bulk
|
|
153
|
-
*
|
|
154
|
-
* @default false
|
|
155
|
-
*/
|
|
156
|
-
multiRowSelectionEnabled?: boolean;
|
|
157
|
-
|
|
158
|
-
options?: Omit<
|
|
159
|
-
Partial<TableOptions<T>>,
|
|
160
|
-
| 'initialState'
|
|
161
|
-
| 'data'
|
|
162
|
-
| 'columns'
|
|
163
|
-
| 'manualPagination'
|
|
164
|
-
| 'enableMultiRowSelection'
|
|
165
|
-
| 'getRowId'
|
|
166
|
-
| 'getRowCanExpand'
|
|
167
|
-
| 'enableRowSelection'
|
|
168
|
-
>;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
interface TableType {
|
|
172
|
-
<T>(props: TableProps<T>): ReactElement;
|
|
173
|
-
Actions: typeof TableActions;
|
|
174
|
-
Filter: typeof TableFilter;
|
|
175
|
-
Footer: typeof TableFooter;
|
|
176
|
-
Header: typeof TableHeader;
|
|
177
|
-
Pagination: typeof TablePagination;
|
|
178
|
-
PerPage: typeof TablePerPage;
|
|
179
|
-
Predicate: typeof TablePredicate;
|
|
180
|
-
DateRangePicker: typeof TableDateRangePicker;
|
|
181
|
-
CollapsibleColumn: typeof TableCollapsibleColumn;
|
|
182
|
-
AccordionColumn: typeof TableAccordionColumn;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
33
|
export const Table: TableType = <T,>({
|
|
186
34
|
data,
|
|
187
35
|
getRowId,
|
|
@@ -219,13 +67,15 @@ export const Table: TableType = <T,>({
|
|
|
219
67
|
enableRowSelection: !loading,
|
|
220
68
|
...options,
|
|
221
69
|
});
|
|
222
|
-
const [state, setState] = useState<TableState
|
|
70
|
+
const [state, setState] = useState<TableState<T>>(table.initialState as TableState<T>);
|
|
223
71
|
table.setOptions((prev) => ({
|
|
224
72
|
...prev,
|
|
225
|
-
state,
|
|
226
|
-
onStateChange: setState
|
|
73
|
+
state: state as TanstackTableState,
|
|
74
|
+
onStateChange: setState as Dispatch<React.SetStateAction<TanstackTableState>>,
|
|
227
75
|
}));
|
|
228
|
-
const {clearSelection, getSelectedRow, getSelectedRows} = useRowSelection(table
|
|
76
|
+
const {clearSelection, getSelectedRow, getSelectedRows, outsideClickRef} = useRowSelection(table, {
|
|
77
|
+
multiRowSelectionEnabled,
|
|
78
|
+
});
|
|
229
79
|
const isFiltered =
|
|
230
80
|
!!state.globalFilter ||
|
|
231
81
|
Object.keys(form.values?.predicates ?? {}).some((predicate) => !!form.values.predicates[predicate]) ||
|
|
@@ -253,12 +103,6 @@ export const Table: TableType = <T,>({
|
|
|
253
103
|
setState((prevState) => ({...prevState, globalFilter: ''}));
|
|
254
104
|
}, []);
|
|
255
105
|
|
|
256
|
-
const outsideClickRef = useClickOutside(() => {
|
|
257
|
-
if (!multiRowSelectionEnabled) {
|
|
258
|
-
clearSelection();
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
|
-
|
|
262
106
|
if (!data) {
|
|
263
107
|
return (
|
|
264
108
|
<Center sx={{flexGrow: 1}}>
|
|
@@ -269,14 +113,15 @@ export const Table: TableType = <T,>({
|
|
|
269
113
|
|
|
270
114
|
const rows = table.getRowModel().rows.map((row) => {
|
|
271
115
|
const rowChildren = getExpandChildren?.(row.original) ?? null;
|
|
116
|
+
const isSelected = !!row.getIsSelected();
|
|
272
117
|
|
|
273
118
|
return (
|
|
274
119
|
<Fragment key={row.id}>
|
|
275
120
|
<tr
|
|
276
121
|
onClick={() => row.toggleSelected()}
|
|
277
122
|
onDoubleClick={() => doubleClickAction?.(row.original)}
|
|
278
|
-
className={cx(classes.row, {[classes.rowSelected]:
|
|
279
|
-
aria-selected={
|
|
123
|
+
className={cx(classes.row, {[classes.rowSelected]: isSelected})}
|
|
124
|
+
aria-selected={isSelected}
|
|
280
125
|
>
|
|
281
126
|
{row.getVisibleCells().map((cell) => {
|
|
282
127
|
const size = cell.column.getSize();
|
|
@@ -299,7 +144,7 @@ export const Table: TableType = <T,>({
|
|
|
299
144
|
{rowChildren ? (
|
|
300
145
|
<tr>
|
|
301
146
|
<td
|
|
302
|
-
colSpan={
|
|
147
|
+
colSpan={table.getAllColumns().length}
|
|
303
148
|
style={{
|
|
304
149
|
padding: 0,
|
|
305
150
|
borderTop: row.getIsExpanded() ? undefined : 'none',
|
|
@@ -356,7 +201,7 @@ export const Table: TableType = <T,>({
|
|
|
356
201
|
rows
|
|
357
202
|
) : (
|
|
358
203
|
<tr>
|
|
359
|
-
<td colSpan={
|
|
204
|
+
<td colSpan={table.getAllColumns().length}>{noDataChildren}</td>
|
|
360
205
|
</tr>
|
|
361
206
|
)}
|
|
362
207
|
</tbody>
|