@uxf/data-grid 11.34.0 → 11.35.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/components.d.ts +9 -4
- package/components.js +30 -25
- package/data-grid-v2.d.ts +3 -0
- package/data-grid-v2.js +43 -0
- package/data-grid-v2.stories.d.ts +2 -0
- package/data-grid-v2.stories.js +92 -0
- package/data-grid.js +1 -1
- package/data-grid.stories.js +1 -1
- package/package.json +4 -4
- package/styles.css +3 -8
- package/table-v2/components/header-select-all-rows-checkbox.d.ts +8 -0
- package/table-v2/components/header-select-all-rows-checkbox.js +21 -0
- package/table-v2/components/index.d.ts +4 -0
- package/table-v2/components/index.js +4 -0
- package/table-v2/components/select-row-checkbox.d.ts +7 -0
- package/table-v2/components/select-row-checkbox.js +12 -0
- package/table-v2/hooks/use-resizable-columns.d.ts +3 -2
- package/table-v2/hooks/use-resizable-columns.js +8 -7
- package/table-v2/styles.css +57 -0
- package/table-v2/table-v2.js +22 -3
package/components.d.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import * as dataGridStories from "./data-grid.stories";
|
|
2
1
|
import * as dataGridCustomExampleStories from "./data-grid-custom-example.stories";
|
|
2
|
+
import * as dataGridV2Stories from "./data-grid-v2.stories";
|
|
3
|
+
import * as dataGridStories from "./data-grid.stories";
|
|
3
4
|
import * as exportButtonStories from "./export-button/export-button.stories";
|
|
4
5
|
import * as filterListStories from "./filter-list/filter-list.stories";
|
|
5
|
-
import * as filtersStories from "./filters/filters.stories";
|
|
6
6
|
import * as filtersButtonStories from "./filters-button/filters-button.stories";
|
|
7
|
+
import * as filtersStories from "./filters/filters.stories";
|
|
7
8
|
import * as fulltextInputStories from "./fulltext-input/fulltext-input.stories";
|
|
8
|
-
import * as hiddenColumnsStories from "./hidden-columns/hidden-columns.stories";
|
|
9
9
|
import * as hiddenColumnsButtonStories from "./hidden-columns-button/hidden-columns-button.stories";
|
|
10
|
+
import * as hiddenColumnsStories from "./hidden-columns/hidden-columns.stories";
|
|
10
11
|
import * as paginationStories from "./pagination/pagination.stories";
|
|
11
12
|
import * as rowCountsStories from "./row-counts/row-counts.stories";
|
|
12
13
|
import * as rowsPerPageSelectStories from "./rows-per-page-select/rows-per-page-select.stories";
|
|
13
14
|
import * as selectedRowsToolbarStories from "./selected-rows-toolbar/selected-rows-toolbar.stories";
|
|
14
|
-
import * as tableStories from "./table/table.stories";
|
|
15
15
|
import * as tableV2Stories from "./table-v2/table-v2.stories";
|
|
16
|
+
import * as tableStories from "./table/table.stories";
|
|
16
17
|
import * as toolbarControlStories from "./toolbar-control/toolbar-control.stories";
|
|
17
18
|
import * as toolbarCustomsStories from "./toolbar-customs/toolbar-customs.stories";
|
|
18
19
|
import * as toolbarTabsStories from "./toolbar-tabs/toolbar-tabs.stories";
|
|
@@ -21,6 +22,10 @@ export declare const components: {
|
|
|
21
22
|
readonly title: "DataGrid";
|
|
22
23
|
readonly stories: typeof dataGridStories;
|
|
23
24
|
};
|
|
25
|
+
readonly "data-grid-v2": {
|
|
26
|
+
readonly title: "DataGridV2";
|
|
27
|
+
readonly stories: typeof dataGridV2Stories;
|
|
28
|
+
};
|
|
24
29
|
readonly "data-grid-custom-example": {
|
|
25
30
|
readonly title: "DataGridCustomExample";
|
|
26
31
|
readonly stories: typeof dataGridCustomExampleStories;
|
package/components.js
CHANGED
|
@@ -25,95 +25,100 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.components = void 0;
|
|
27
27
|
// generated file
|
|
28
|
-
const dataGridStories = __importStar(require("./data-grid.stories"));
|
|
29
28
|
const dataGridCustomExampleStories = __importStar(require("./data-grid-custom-example.stories"));
|
|
29
|
+
const dataGridV2Stories = __importStar(require("./data-grid-v2.stories"));
|
|
30
|
+
const dataGridStories = __importStar(require("./data-grid.stories"));
|
|
30
31
|
const exportButtonStories = __importStar(require("./export-button/export-button.stories"));
|
|
31
32
|
const filterListStories = __importStar(require("./filter-list/filter-list.stories"));
|
|
32
|
-
const filtersStories = __importStar(require("./filters/filters.stories"));
|
|
33
33
|
const filtersButtonStories = __importStar(require("./filters-button/filters-button.stories"));
|
|
34
|
+
const filtersStories = __importStar(require("./filters/filters.stories"));
|
|
34
35
|
const fulltextInputStories = __importStar(require("./fulltext-input/fulltext-input.stories"));
|
|
35
|
-
const hiddenColumnsStories = __importStar(require("./hidden-columns/hidden-columns.stories"));
|
|
36
36
|
const hiddenColumnsButtonStories = __importStar(require("./hidden-columns-button/hidden-columns-button.stories"));
|
|
37
|
+
const hiddenColumnsStories = __importStar(require("./hidden-columns/hidden-columns.stories"));
|
|
37
38
|
const paginationStories = __importStar(require("./pagination/pagination.stories"));
|
|
38
39
|
const rowCountsStories = __importStar(require("./row-counts/row-counts.stories"));
|
|
39
40
|
const rowsPerPageSelectStories = __importStar(require("./rows-per-page-select/rows-per-page-select.stories"));
|
|
40
41
|
const selectedRowsToolbarStories = __importStar(require("./selected-rows-toolbar/selected-rows-toolbar.stories"));
|
|
41
|
-
const tableStories = __importStar(require("./table/table.stories"));
|
|
42
42
|
const tableV2Stories = __importStar(require("./table-v2/table-v2.stories"));
|
|
43
|
+
const tableStories = __importStar(require("./table/table.stories"));
|
|
43
44
|
const toolbarControlStories = __importStar(require("./toolbar-control/toolbar-control.stories"));
|
|
44
45
|
const toolbarCustomsStories = __importStar(require("./toolbar-customs/toolbar-customs.stories"));
|
|
45
46
|
const toolbarTabsStories = __importStar(require("./toolbar-tabs/toolbar-tabs.stories"));
|
|
46
47
|
exports.components = {
|
|
47
48
|
"data-grid": {
|
|
48
49
|
title: "DataGrid",
|
|
49
|
-
stories: dataGridStories
|
|
50
|
+
stories: dataGridStories,
|
|
51
|
+
},
|
|
52
|
+
"data-grid-v2": {
|
|
53
|
+
title: "DataGridV2",
|
|
54
|
+
stories: dataGridV2Stories,
|
|
50
55
|
},
|
|
51
56
|
"data-grid-custom-example": {
|
|
52
57
|
title: "DataGridCustomExample",
|
|
53
|
-
stories: dataGridCustomExampleStories
|
|
58
|
+
stories: dataGridCustomExampleStories,
|
|
54
59
|
},
|
|
55
60
|
"export-button": {
|
|
56
61
|
title: "ExportButton",
|
|
57
|
-
stories: exportButtonStories
|
|
62
|
+
stories: exportButtonStories,
|
|
58
63
|
},
|
|
59
64
|
"filter-list": {
|
|
60
65
|
title: "FilterList",
|
|
61
|
-
stories: filterListStories
|
|
66
|
+
stories: filterListStories,
|
|
62
67
|
},
|
|
63
|
-
|
|
68
|
+
filters: {
|
|
64
69
|
title: "Filters",
|
|
65
|
-
stories: filtersStories
|
|
70
|
+
stories: filtersStories,
|
|
66
71
|
},
|
|
67
72
|
"filters-button": {
|
|
68
73
|
title: "FiltersButton",
|
|
69
|
-
stories: filtersButtonStories
|
|
74
|
+
stories: filtersButtonStories,
|
|
70
75
|
},
|
|
71
76
|
"fulltext-input": {
|
|
72
77
|
title: "FulltextInput",
|
|
73
|
-
stories: fulltextInputStories
|
|
78
|
+
stories: fulltextInputStories,
|
|
74
79
|
},
|
|
75
80
|
"hidden-columns": {
|
|
76
81
|
title: "HiddenColumns",
|
|
77
|
-
stories: hiddenColumnsStories
|
|
82
|
+
stories: hiddenColumnsStories,
|
|
78
83
|
},
|
|
79
84
|
"hidden-columns-button": {
|
|
80
85
|
title: "HiddenColumnsButton",
|
|
81
|
-
stories: hiddenColumnsButtonStories
|
|
86
|
+
stories: hiddenColumnsButtonStories,
|
|
82
87
|
},
|
|
83
|
-
|
|
88
|
+
pagination: {
|
|
84
89
|
title: "Pagination",
|
|
85
|
-
stories: paginationStories
|
|
90
|
+
stories: paginationStories,
|
|
86
91
|
},
|
|
87
92
|
"row-counts": {
|
|
88
93
|
title: "RowCounts",
|
|
89
|
-
stories: rowCountsStories
|
|
94
|
+
stories: rowCountsStories,
|
|
90
95
|
},
|
|
91
96
|
"rows-per-page-select": {
|
|
92
97
|
title: "RowsPerPageSelect",
|
|
93
|
-
stories: rowsPerPageSelectStories
|
|
98
|
+
stories: rowsPerPageSelectStories,
|
|
94
99
|
},
|
|
95
100
|
"selected-rows-toolbar": {
|
|
96
101
|
title: "SelectedRowsToolbar",
|
|
97
|
-
stories: selectedRowsToolbarStories
|
|
102
|
+
stories: selectedRowsToolbarStories,
|
|
98
103
|
},
|
|
99
|
-
|
|
104
|
+
table: {
|
|
100
105
|
title: "Table",
|
|
101
|
-
stories: tableStories
|
|
106
|
+
stories: tableStories,
|
|
102
107
|
},
|
|
103
108
|
"table-v2": {
|
|
104
109
|
title: "TableV2",
|
|
105
|
-
stories: tableV2Stories
|
|
110
|
+
stories: tableV2Stories,
|
|
106
111
|
},
|
|
107
112
|
"toolbar-control": {
|
|
108
113
|
title: "ToolbarControl",
|
|
109
|
-
stories: toolbarControlStories
|
|
114
|
+
stories: toolbarControlStories,
|
|
110
115
|
},
|
|
111
116
|
"toolbar-customs": {
|
|
112
117
|
title: "ToolbarCustoms",
|
|
113
|
-
stories: toolbarCustomsStories
|
|
118
|
+
stories: toolbarCustomsStories,
|
|
114
119
|
},
|
|
115
120
|
"toolbar-tabs": {
|
|
116
121
|
title: "ToolbarTabs",
|
|
117
|
-
stories: toolbarTabsStories
|
|
122
|
+
stories: toolbarTabsStories,
|
|
118
123
|
},
|
|
119
124
|
};
|
package/data-grid-v2.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.DataGridV2 = DataGridV2;
|
|
7
|
+
const empty_array_1 = require("@uxf/core/constants/empty-array");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const body_cell_1 = require("./body-cell");
|
|
10
|
+
const filter_handler_1 = require("./filter-handler");
|
|
11
|
+
const filter_list_1 = require("./filter-list");
|
|
12
|
+
const footer_1 = require("./footer");
|
|
13
|
+
const linear_progress_1 = require("./linear-progress");
|
|
14
|
+
const pagination_1 = require("./pagination");
|
|
15
|
+
const root_1 = require("./root");
|
|
16
|
+
const row_counts_1 = require("./row-counts");
|
|
17
|
+
const rows_per_page_select_1 = require("./rows-per-page-select");
|
|
18
|
+
const selected_rows_toolbar_1 = require("./selected-rows-toolbar");
|
|
19
|
+
const table_v2_1 = require("./table-v2");
|
|
20
|
+
const no_rows_fallback_1 = require("./table/no-rows-fallback");
|
|
21
|
+
const toolbar_1 = require("./toolbar");
|
|
22
|
+
const toolbar_control_1 = require("./toolbar-control");
|
|
23
|
+
const toolbar_customs_1 = require("./toolbar-customs");
|
|
24
|
+
const toolbar_tabs_1 = require("./toolbar-tabs");
|
|
25
|
+
const classes_1 = require("./utils/classes");
|
|
26
|
+
const DefaultSelectedRowsToolbarActions = () => null;
|
|
27
|
+
function DataGridV2(props) {
|
|
28
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
29
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
30
|
+
react_1.default.createElement(root_1.DataGridRoot, { className: props.className, noBorder: props.noBorder },
|
|
31
|
+
react_1.default.createElement(toolbar_1.DataGridToolbar, { noBorder: props.noBorder },
|
|
32
|
+
react_1.default.createElement(toolbar_tabs_1.DataGridToolbarTabs, { actions: props.actions, schema: props.schema, state: props.state }),
|
|
33
|
+
react_1.default.createElement(toolbar_control_1.DataGridToolbarControl, { actions: props.actions, filterHandlers: (_a = props.filterHandlers) !== null && _a !== void 0 ? _a : filter_handler_1.defaultFilterHandlers, onCsvDownload: props.onCsvDownload, schema: props.schema, state: props.state }),
|
|
34
|
+
react_1.default.createElement(toolbar_customs_1.DataGridToolbarCustoms, { buttons: props.customActions })),
|
|
35
|
+
react_1.default.createElement(linear_progress_1.DataGridLinearProgress, { isLoading: props.isLoading }),
|
|
36
|
+
react_1.default.createElement(filter_list_1.DataGridFilterList, { actions: props.actions, className: props.noBorder ? classes_1.NO_BORDER_CLASS : undefined, filterHandlers: (_b = props.filterHandlers) !== null && _b !== void 0 ? _b : filter_handler_1.defaultFilterHandlers, schema: props.schema, state: props.state }),
|
|
37
|
+
react_1.default.createElement(table_v2_1.DataGridTableV2, { NoRowsFallback: (_c = props.NoRowsFallback) !== null && _c !== void 0 ? _c : no_rows_fallback_1.NoRowsFallback, actionCell: props.actionCell, actions: props.actions, bodyCells: (_d = props.bodyCells) !== null && _d !== void 0 ? _d : body_cell_1.BodyCells, data: (_f = (_e = props.data) === null || _e === void 0 ? void 0 : _e.result) !== null && _f !== void 0 ? _f : empty_array_1.EMPTY_ARRAY, error: props.error, headerRowHeight: props.headerRowHeight, isLoading: props.isLoading, isRowSelectable: props.isRowSelectable, keyExtractor: props.keyExtractor, onReload: props.onReload, rowClass: props.rowClass, rowHeight: props.rowHeight, schema: props.schema, state: props.state }),
|
|
38
|
+
react_1.default.createElement(footer_1.DataGridFooter, { noBorder: props.noBorder },
|
|
39
|
+
react_1.default.createElement(rows_per_page_select_1.DataGridRowsPerPageSelect, { actions: props.actions, state: props.state }),
|
|
40
|
+
react_1.default.createElement(row_counts_1.DataGridRowCounts, { count: (_h = (_g = props.data) === null || _g === void 0 ? void 0 : _g.count) !== null && _h !== void 0 ? _h : 0, state: props.state, totalCount: (_k = (_j = props.data) === null || _j === void 0 ? void 0 : _j.totalCount) !== null && _k !== void 0 ? _k : 0 }),
|
|
41
|
+
react_1.default.createElement(pagination_1.DataGridPagination, { actions: props.actions, count: (_m = (_l = props.data) === null || _l === void 0 ? void 0 : _l.count) !== null && _m !== void 0 ? _m : 0, showFirstButton: true, showLastButton: true, size: "sm", state: props.state }))),
|
|
42
|
+
react_1.default.createElement(selected_rows_toolbar_1.DataGridSelectedRowsToolbar, { Actions: (_o = props.SelectedRowsToolbarActions) !== null && _o !== void 0 ? _o : DefaultSelectedRowsToolbarActions, actions: props.actions, state: props.state })));
|
|
43
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.Default = Default;
|
|
27
|
+
const buildArray_1 = require("@uxf/core/utils/buildArray");
|
|
28
|
+
const toggle_1 = require("@uxf/ui/toggle");
|
|
29
|
+
const react_1 = __importStar(require("react"));
|
|
30
|
+
const json_renderer_1 = require("./_story-utils/json-renderer");
|
|
31
|
+
const loader_1 = require("./_story-utils/loader");
|
|
32
|
+
const schema_1 = require("./_story-utils/schema");
|
|
33
|
+
const data_grid_v2_1 = require("./data-grid-v2");
|
|
34
|
+
const table_1 = require("./table");
|
|
35
|
+
const use_data_grid_control_1 = require("./use-data-grid-control");
|
|
36
|
+
const use_data_grid_fetching_1 = require("./use-data-grid-fetching");
|
|
37
|
+
const merge_schema_with_config_1 = require("./utils/merge-schema-with-config");
|
|
38
|
+
const actionCell = {
|
|
39
|
+
width: 100,
|
|
40
|
+
Component: () => {
|
|
41
|
+
const actionCellActions = (0, buildArray_1.buildArray)()
|
|
42
|
+
.add({
|
|
43
|
+
icon: "arrow-right",
|
|
44
|
+
isIconButton: true,
|
|
45
|
+
href: "https://www.uxf.cz",
|
|
46
|
+
target: "_blank",
|
|
47
|
+
})
|
|
48
|
+
.add({
|
|
49
|
+
icon: "file",
|
|
50
|
+
label: "Download",
|
|
51
|
+
onClick: console.log,
|
|
52
|
+
})
|
|
53
|
+
.add({
|
|
54
|
+
icon: "cloud",
|
|
55
|
+
label: "Reload",
|
|
56
|
+
onClick: console.log,
|
|
57
|
+
});
|
|
58
|
+
return react_1.default.createElement(table_1.ActionCell, { buttons: actionCellActions, visibleButtonsCount: 1 });
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
const schemaWithFrontendConfig = (0, merge_schema_with_config_1.mergeSchemaWithConfig)(schema_1.schema, {
|
|
62
|
+
perPage: 100,
|
|
63
|
+
columns: {
|
|
64
|
+
bool: { width: 80 },
|
|
65
|
+
},
|
|
66
|
+
filters: {
|
|
67
|
+
text: { placeholder: "Custom placeholder ..." },
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
function Default() {
|
|
71
|
+
const [noBorder, setNoBorder] = (0, react_1.useState)(false);
|
|
72
|
+
const { state, actions } = (0, use_data_grid_control_1.useDataGridControl)({
|
|
73
|
+
schema: schema_1.schema,
|
|
74
|
+
initialUserConfig: {
|
|
75
|
+
columns: {
|
|
76
|
+
id: { width: 100 },
|
|
77
|
+
text: { minWidth: 300 },
|
|
78
|
+
mail: { minWidth: 300 },
|
|
79
|
+
tel: { minWidth: 300 },
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
const { isLoading, error, data, onReload } = (0, use_data_grid_fetching_1.useDataGridFetching)({
|
|
84
|
+
loader: loader_1.loader,
|
|
85
|
+
schema: schema_1.schema,
|
|
86
|
+
state,
|
|
87
|
+
});
|
|
88
|
+
return (react_1.default.createElement("div", { className: "p-10" },
|
|
89
|
+
react_1.default.createElement(toggle_1.Toggle, { label: "No border", name: "noBorder", onChange: (value) => setNoBorder(Boolean(value)), value: noBorder }),
|
|
90
|
+
react_1.default.createElement(data_grid_v2_1.DataGridV2, { actionCell: actionCell, actions: actions, data: data, error: error, isLoading: isLoading, isRowSelectable: true, noBorder: noBorder, onCsvDownload: console.log, onReload: onReload, schema: schemaWithFrontendConfig, state: state }),
|
|
91
|
+
react_1.default.createElement(json_renderer_1.JsonRenderer, { value: state })));
|
|
92
|
+
}
|
package/data-grid.js
CHANGED
|
@@ -38,6 +38,6 @@ function DataGrid(props) {
|
|
|
38
38
|
react_1.default.createElement(footer_1.DataGridFooter, { noBorder: props.noBorder },
|
|
39
39
|
react_1.default.createElement(rows_per_page_select_1.DataGridRowsPerPageSelect, { actions: props.actions, state: props.state }),
|
|
40
40
|
react_1.default.createElement(row_counts_1.DataGridRowCounts, { count: (_h = (_g = props.data) === null || _g === void 0 ? void 0 : _g.count) !== null && _h !== void 0 ? _h : 0, state: props.state, totalCount: (_k = (_j = props.data) === null || _j === void 0 ? void 0 : _j.totalCount) !== null && _k !== void 0 ? _k : 0 }),
|
|
41
|
-
react_1.default.createElement(pagination_1.DataGridPagination, { actions: props.actions, count: (_m = (_l = props.data) === null || _l === void 0 ? void 0 : _l.count) !== null && _m !== void 0 ? _m : 0, state: props.state }))),
|
|
41
|
+
react_1.default.createElement(pagination_1.DataGridPagination, { actions: props.actions, count: (_m = (_l = props.data) === null || _l === void 0 ? void 0 : _l.count) !== null && _m !== void 0 ? _m : 0, showFirstButton: true, showLastButton: true, size: "sm", state: props.state }))),
|
|
42
42
|
react_1.default.createElement(selected_rows_toolbar_1.DataGridSelectedRowsToolbar, { Actions: (_o = props.SelectedRowsToolbarActions) !== null && _o !== void 0 ? _o : DefaultSelectedRowsToolbarActions, actions: props.actions, state: props.state })));
|
|
43
43
|
}
|
package/data-grid.stories.js
CHANGED
|
@@ -85,7 +85,7 @@ function Default() {
|
|
|
85
85
|
schema: schema_1.schema,
|
|
86
86
|
state,
|
|
87
87
|
});
|
|
88
|
-
return (react_1.default.createElement(
|
|
88
|
+
return (react_1.default.createElement("div", { className: "p-10" },
|
|
89
89
|
react_1.default.createElement(toggle_1.Toggle, { label: "No border", name: "noBorder", onChange: (value) => setNoBorder(Boolean(value)), value: noBorder }),
|
|
90
90
|
react_1.default.createElement(data_grid_1.DataGrid, { actionCell: actionCell, actions: actions, data: data, error: error, isLoading: isLoading, isRowSelectable: true, noBorder: noBorder, onCsvDownload: console.log, onReload: onReload, schema: schemaWithFrontendConfig, state: state }),
|
|
91
91
|
react_1.default.createElement(json_renderer_1.JsonRenderer, { value: state })));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uxf/data-grid",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.35.0",
|
|
4
4
|
"description": "UXF DataGrid",
|
|
5
5
|
"homepage": "https://gitlab.com/uxf-npm/data-grid#readme",
|
|
6
6
|
"main": "index.js",
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
"typecheck": "tsc --noEmit --skipLibCheck"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@uxf/core": "11.
|
|
35
|
-
"@uxf/core-react": "11.
|
|
36
|
-
"@uxf/ui": "11.
|
|
34
|
+
"@uxf/core": "11.35.0",
|
|
35
|
+
"@uxf/core-react": "11.35.0",
|
|
36
|
+
"@uxf/ui": "11.35.0",
|
|
37
37
|
"dayjs": "1.11.13",
|
|
38
38
|
"deepmerge": "4.3.1",
|
|
39
39
|
"fast-glob": "3.3.2",
|
package/styles.css
CHANGED
|
@@ -165,10 +165,6 @@
|
|
|
165
165
|
gap: theme("spacing.4");
|
|
166
166
|
justify-content: flex-end;
|
|
167
167
|
padding: theme("spacing.2");
|
|
168
|
-
|
|
169
|
-
&.no-border {
|
|
170
|
-
padding-inline: 0;
|
|
171
|
-
}
|
|
172
168
|
}
|
|
173
169
|
|
|
174
170
|
&__linear-progress {
|
|
@@ -178,7 +174,7 @@
|
|
|
178
174
|
overflow: hidden;
|
|
179
175
|
position: absolute;
|
|
180
176
|
right: 0;
|
|
181
|
-
z-index:
|
|
177
|
+
z-index: 5;
|
|
182
178
|
|
|
183
179
|
&.is-loading::before {
|
|
184
180
|
animation: datagridlineanim 1s linear infinite;
|
|
@@ -295,6 +291,8 @@
|
|
|
295
291
|
}
|
|
296
292
|
|
|
297
293
|
&__table {
|
|
294
|
+
margin-top: 1px;
|
|
295
|
+
|
|
298
296
|
&::-webkit-scrollbar {
|
|
299
297
|
height: 8px;
|
|
300
298
|
width: 8px;
|
|
@@ -317,7 +315,6 @@
|
|
|
317
315
|
|
|
318
316
|
&__toolbar {
|
|
319
317
|
align-items: center;
|
|
320
|
-
border-bottom: 1px solid theme("colors.lightBorder");
|
|
321
318
|
display: flex;
|
|
322
319
|
flex-wrap: wrap;
|
|
323
320
|
gap: theme("spacing.2");
|
|
@@ -374,8 +371,6 @@
|
|
|
374
371
|
|
|
375
372
|
&-nav {
|
|
376
373
|
&--desktop {
|
|
377
|
-
@apply space-x-4;
|
|
378
|
-
|
|
379
374
|
display: none;
|
|
380
375
|
margin-bottom: -1px;
|
|
381
376
|
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { KeyExtractor } from "../../types";
|
|
3
|
+
import { DataGridTableProps } from "../types";
|
|
4
|
+
interface SelectRowCheckboxProps extends Pick<DataGridTableProps<any>, "state" | "data" | "actions"> {
|
|
5
|
+
keyExtractor: KeyExtractor;
|
|
6
|
+
}
|
|
7
|
+
export declare function HeaderSelectAllRowsCheckbox(props: SelectRowCheckboxProps): React.JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.HeaderSelectAllRowsCheckbox = HeaderSelectAllRowsCheckbox;
|
|
7
|
+
const empty_array_1 = require("@uxf/core/constants/empty-array");
|
|
8
|
+
const is_not_empty_1 = require("@uxf/core/utils/is-not-empty");
|
|
9
|
+
const checkbox_input_1 = require("@uxf/ui/checkbox-input");
|
|
10
|
+
const react_1 = __importDefault(require("react"));
|
|
11
|
+
function HeaderSelectAllRowsCheckbox(props) {
|
|
12
|
+
var _a;
|
|
13
|
+
const selectedRows = (_a = props.state.selectedRows) !== null && _a !== void 0 ? _a : empty_array_1.EMPTY_ARRAY;
|
|
14
|
+
const isAllRowsSelected = props.data.every((row) => selectedRows.find((selectedRow) => props.keyExtractor(row) === props.keyExtractor(selectedRow)));
|
|
15
|
+
const isIndeterminate = !isAllRowsSelected && (0, is_not_empty_1.isNotEmpty)(selectedRows);
|
|
16
|
+
const selectAllRowsHandler = () => {
|
|
17
|
+
props.actions.setSelectedRows(isAllRowsSelected ? [] : props.data);
|
|
18
|
+
};
|
|
19
|
+
return (react_1.default.createElement("div", { className: "uxf-dg-table__cell uxf-dg-table__cell--header uxf-dg-table__select-all-rows-cell" },
|
|
20
|
+
react_1.default.createElement(checkbox_input_1.CheckboxInput, { hiddenLabel: true, indeterminate: isIndeterminate, label: "Vybrat v\u0161e", name: "select-all-rows", onChange: selectAllRowsHandler, value: isAllRowsSelected })));
|
|
21
|
+
}
|
|
@@ -3,7 +3,9 @@ import { Body } from "./body";
|
|
|
3
3
|
import { Cell } from "./cell";
|
|
4
4
|
import { Header } from "./header";
|
|
5
5
|
import { HeaderActionCell } from "./header-action-cell";
|
|
6
|
+
import { HeaderSelectAllRowsCheckbox } from "./header-select-all-rows-checkbox";
|
|
6
7
|
import { Row } from "./row";
|
|
8
|
+
import { SelectRowCheckbox } from "./select-row-checkbox";
|
|
7
9
|
export declare const Table: import("react").ForwardRefExoticComponent<import("./root").RootProps & import("react").RefAttributes<HTMLDivElement>> & {
|
|
8
10
|
Body: typeof Body;
|
|
9
11
|
Row: typeof Row;
|
|
@@ -12,4 +14,6 @@ export declare const Table: import("react").ForwardRefExoticComponent<import("./
|
|
|
12
14
|
ActionCell: typeof ActionCell;
|
|
13
15
|
HeaderActionCell: typeof HeaderActionCell;
|
|
14
16
|
Header: typeof Header;
|
|
17
|
+
SelectRowCheckbox: typeof SelectRowCheckbox;
|
|
18
|
+
HeaderSelectAllRowsCheckbox: typeof HeaderSelectAllRowsCheckbox;
|
|
15
19
|
};
|
|
@@ -7,8 +7,10 @@ const cell_1 = require("./cell");
|
|
|
7
7
|
const header_1 = require("./header");
|
|
8
8
|
const header_action_cell_1 = require("./header-action-cell");
|
|
9
9
|
const header_cell_1 = require("./header-cell");
|
|
10
|
+
const header_select_all_rows_checkbox_1 = require("./header-select-all-rows-checkbox");
|
|
10
11
|
const root_1 = require("./root");
|
|
11
12
|
const row_1 = require("./row");
|
|
13
|
+
const select_row_checkbox_1 = require("./select-row-checkbox");
|
|
12
14
|
exports.Table = Object.assign(root_1.Root, {
|
|
13
15
|
Body: body_1.Body,
|
|
14
16
|
Row: row_1.Row,
|
|
@@ -17,4 +19,6 @@ exports.Table = Object.assign(root_1.Root, {
|
|
|
17
19
|
ActionCell: action_cell_1.ActionCell,
|
|
18
20
|
HeaderActionCell: header_action_cell_1.HeaderActionCell,
|
|
19
21
|
Header: header_1.Header,
|
|
22
|
+
SelectRowCheckbox: select_row_checkbox_1.SelectRowCheckbox,
|
|
23
|
+
HeaderSelectAllRowsCheckbox: header_select_all_rows_checkbox_1.HeaderSelectAllRowsCheckbox,
|
|
20
24
|
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SelectRowCheckbox = SelectRowCheckbox;
|
|
7
|
+
const checkbox_input_1 = require("@uxf/ui/checkbox-input");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
function SelectRowCheckbox(props) {
|
|
10
|
+
return (react_1.default.createElement("div", { className: "uxf-dg-table__cell uxf-dg-table__select-row-cell" },
|
|
11
|
+
react_1.default.createElement(checkbox_input_1.CheckboxInput, { className: "*:mt-0", hiddenLabel: true, label: "Vybrat", name: "select-row", onChange: props.onSelectRowChange, value: props.isRowSelected })));
|
|
12
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { Nullish } from "@uxf/core/types";
|
|
1
2
|
import { Column } from "../../types";
|
|
2
3
|
import { DataGridControl } from "../../use-data-grid-control";
|
|
3
|
-
import {
|
|
4
|
-
export declare function useResizableColumns(columns: Column<any, any>[], actionCell:
|
|
4
|
+
import { DataGridTableProps } from "../types";
|
|
5
|
+
export declare function useResizableColumns(columns: Column<any, any>[], actionCell: DataGridTableProps<any>["actionCell"], actions: DataGridControl["actions"], selectRowsCellWidth: number | Nullish): {
|
|
5
6
|
tableRef: import("react").RefObject<HTMLDivElement>;
|
|
6
7
|
columnRefs: import("react").MutableRefObject<(HTMLDivElement | null)[]>;
|
|
7
8
|
onResizeStart(index: number): void;
|
|
@@ -6,13 +6,14 @@ const is_nil_1 = require("@uxf/core/utils/is-nil");
|
|
|
6
6
|
const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
|
|
7
7
|
const rem_1 = require("@uxf/styles/units/rem");
|
|
8
8
|
const react_1 = require("react");
|
|
9
|
-
function mapColumnSizesToGridTemplateColumns(columnSizes, actionCellWidth) {
|
|
9
|
+
function mapColumnSizesToGridTemplateColumns(columnSizes, actionCellWidth, selectRowCheckboxWidth) {
|
|
10
10
|
const normalizedColumnSizes = columnSizes.map((size) => ((0, is_not_nil_1.isNotNil)(size) ? (0, rem_1.rem)(size) : "1fr"));
|
|
11
|
-
|
|
12
|
-
? `${normalizedColumnSizes.join(" ")}`
|
|
13
|
-
:
|
|
11
|
+
const columnSizesWithSelectRows = (0, is_not_nil_1.isNotNil)(selectRowCheckboxWidth)
|
|
12
|
+
? `${(0, rem_1.rem)(selectRowCheckboxWidth)} ${normalizedColumnSizes.join(" ")}`
|
|
13
|
+
: normalizedColumnSizes.join(" ");
|
|
14
|
+
return (0, is_nil_1.isNil)(actionCellWidth) ? columnSizesWithSelectRows : `${columnSizesWithSelectRows} ${(0, rem_1.rem)(actionCellWidth)}`;
|
|
14
15
|
}
|
|
15
|
-
function useResizableColumns(columns, actionCell, actions) {
|
|
16
|
+
function useResizableColumns(columns, actionCell, actions, selectRowsCellWidth) {
|
|
16
17
|
const [activeIndex, setActiveIndex] = (0, react_1.useState)(null);
|
|
17
18
|
const tableRef = (0, react_1.useRef)(null);
|
|
18
19
|
const columnRefs = (0, react_1.useRef)([]);
|
|
@@ -35,7 +36,7 @@ function useResizableColumns(columns, actionCell, actions) {
|
|
|
35
36
|
// TODO @vejvis - jak tohle udělat lépe??
|
|
36
37
|
tempColumnSizes = gridColumns;
|
|
37
38
|
if (tableRef.current) {
|
|
38
|
-
tableRef.current.style.gridTemplateColumns = mapColumnSizesToGridTemplateColumns(gridColumns, actionCellWidth);
|
|
39
|
+
tableRef.current.style.gridTemplateColumns = mapColumnSizesToGridTemplateColumns(gridColumns, actionCellWidth, selectRowsCellWidth);
|
|
39
40
|
}
|
|
40
41
|
};
|
|
41
42
|
const onMouseUp = () => {
|
|
@@ -56,7 +57,7 @@ function useResizableColumns(columns, actionCell, actions) {
|
|
|
56
57
|
window.removeEventListener("mousemove", onMouseMove);
|
|
57
58
|
window.removeEventListener("mouseup", onMouseUp);
|
|
58
59
|
};
|
|
59
|
-
}, [columns, actions, actionCellWidth, activeIndex]);
|
|
60
|
+
}, [columns, actions, actionCellWidth, activeIndex, selectRowsCellWidth]);
|
|
60
61
|
return {
|
|
61
62
|
tableRef,
|
|
62
63
|
columnRefs,
|
package/table-v2/styles.css
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
:root {
|
|
2
2
|
--uxf-dg-table-font-size: theme("fontSize.sm");
|
|
3
3
|
--uxf-dg-table-cell-padding: theme("spacing.2");
|
|
4
|
+
--uxf-dg-table-cell-padding-first-cell: theme("spacing.4");
|
|
5
|
+
--uxf-dg-table-cell-padding-last-cell: theme("spacing.4");
|
|
4
6
|
--uxf-dg-table-action-cell-left-divider-size: 1px;
|
|
5
7
|
--uxf-dg-table-row-divider-size: 1px;
|
|
6
8
|
}
|
|
7
9
|
|
|
8
10
|
.uxf-dg-table {
|
|
9
11
|
--uxf-dg-table-text-color: var(--uxf-color-base-text-high-emphasis);
|
|
12
|
+
--uxf-dg-table-border-color: var(--uxf-color-base-border-border);
|
|
10
13
|
--uxf-dg-table-action-cell-left-divider-color: var(--uxf-color-base-border-border);
|
|
11
14
|
--uxf-dg-table-row-divider-color: var(--uxf-color-base-border-border);
|
|
12
15
|
--uxf-dg-table-action-cell-bg-color: var(--uxf-color-base-surface-main);
|
|
@@ -18,12 +21,33 @@
|
|
|
18
21
|
--uxf-dg-table-header-divider-size: var(--uxf-dg-table-row-divider-size);
|
|
19
22
|
--uxf-dg-table-header-divider-color: var(--uxf-dg-table-row-divider-color);
|
|
20
23
|
|
|
24
|
+
border: 1px solid var(--uxf-dg-table-border-color);
|
|
25
|
+
border-top-color: transparent;
|
|
21
26
|
color: var(--uxf-dg-table-text-color);
|
|
22
27
|
display: grid;
|
|
23
28
|
font-size: var(--uxf-dg-table-font-size);
|
|
24
29
|
overflow-x: auto;
|
|
25
30
|
width: 100%;
|
|
26
31
|
|
|
32
|
+
&::-webkit-scrollbar {
|
|
33
|
+
height: 8px;
|
|
34
|
+
width: 8px;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
&::-webkit-scrollbar-track {
|
|
38
|
+
background-color: transparent;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&::-webkit-scrollbar-thumb,
|
|
42
|
+
&::-webkit-scrollbar-thumb:hover {
|
|
43
|
+
background-color: theme("colors.lightLow");
|
|
44
|
+
border-radius: 999px;
|
|
45
|
+
|
|
46
|
+
:root .dark & {
|
|
47
|
+
background-color: theme("colors.darkLow");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
27
51
|
&__row {
|
|
28
52
|
display: contents;
|
|
29
53
|
}
|
|
@@ -58,6 +82,14 @@
|
|
|
58
82
|
display: flex;
|
|
59
83
|
padding: var(--uxf-dg-table-cell-padding);
|
|
60
84
|
|
|
85
|
+
&:first-child {
|
|
86
|
+
padding-left: var(--uxf-dg-table-cell-padding-first-cell);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
&:nth-last-child(1 of .uxf-dg-table__cell) {
|
|
90
|
+
padding-right: var(--uxf-dg-table-cell-padding-last-cell);
|
|
91
|
+
}
|
|
92
|
+
|
|
61
93
|
&--header {
|
|
62
94
|
background-color: var(--uxf-dg-table-header-bg-color);
|
|
63
95
|
color: var(--uxf-dg-table-header-color);
|
|
@@ -79,6 +111,31 @@
|
|
|
79
111
|
}
|
|
80
112
|
}
|
|
81
113
|
|
|
114
|
+
&__select-all-rows-cell {
|
|
115
|
+
position: relative;
|
|
116
|
+
|
|
117
|
+
&::before {
|
|
118
|
+
background-color: var(--uxf-color-base-border-border);
|
|
119
|
+
bottom: 0;
|
|
120
|
+
content: "";
|
|
121
|
+
position: absolute;
|
|
122
|
+
right: 0;
|
|
123
|
+
top: 0;
|
|
124
|
+
width: 1px;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.uxf-icon {
|
|
128
|
+
margin-left: 0;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
&__select-all-rows-cell,
|
|
133
|
+
&__select-row-cell {
|
|
134
|
+
.uxf-checkbox-input {
|
|
135
|
+
margin-top: 0;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
82
139
|
&__action-cell {
|
|
83
140
|
background-color: var(--uxf-dg-table-action-cell-bg-color);
|
|
84
141
|
border-left: var(--uxf-dg-table-action-cell-left-divider-size) solid
|
package/table-v2/table-v2.js
CHANGED
|
@@ -6,34 +6,51 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.DataGridTableV2 = void 0;
|
|
7
7
|
exports.TableV2 = TableV2;
|
|
8
8
|
const show_1 = require("@uxf/core-react/components/show");
|
|
9
|
+
const empty_array_1 = require("@uxf/core/constants/empty-array");
|
|
9
10
|
const is_nil_1 = require("@uxf/core/utils/is-nil");
|
|
10
11
|
const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
|
|
11
12
|
const rem_1 = require("@uxf/styles/units/rem");
|
|
12
13
|
const react_1 = __importDefault(require("react"));
|
|
13
14
|
const components_1 = require("./components");
|
|
15
|
+
const header_select_all_rows_checkbox_1 = require("./components/header-select-all-rows-checkbox");
|
|
16
|
+
const select_row_checkbox_1 = require("./components/select-row-checkbox");
|
|
14
17
|
const use_resizable_columns_1 = require("./hooks/use-resizable-columns");
|
|
15
18
|
const get_grid_template_rows_1 = require("./utils/get-grid-template-rows");
|
|
19
|
+
const SELECT_ROWS_CELL_WIDTH = 40;
|
|
16
20
|
const defaultKeyExtractor = (r) => r.id;
|
|
17
21
|
const DefaultBodyCell = () => "Unknown body cell.";
|
|
18
22
|
/** @deprecated Use DataGridTableV2 */
|
|
19
23
|
function TableV2(props) {
|
|
20
|
-
var _a, _b, _c, _d;
|
|
24
|
+
var _a, _b, _c, _d, _e;
|
|
21
25
|
const keyExtractor = (_a = props.keyExtractor) !== null && _a !== void 0 ? _a : defaultKeyExtractor;
|
|
22
26
|
const visibleColumns = props.schema.columns
|
|
23
27
|
.filter((column) => !column.hidden)
|
|
24
28
|
.filter((column) => { var _a, _b, _c, _d; return !((_c = (_b = (_a = props.state.userConfig.columns) === null || _a === void 0 ? void 0 : _a[column.name]) === null || _b === void 0 ? void 0 : _b.isHidden) !== null && _c !== void 0 ? _c : (_d = column.config) === null || _d === void 0 ? void 0 : _d.isHidden); });
|
|
25
|
-
const { tableRef, columnRefs, onResizeStart } = (0, use_resizable_columns_1.useResizableColumns)(visibleColumns, props.actionCell, props.actions);
|
|
29
|
+
const { tableRef, columnRefs, onResizeStart } = (0, use_resizable_columns_1.useResizableColumns)(visibleColumns, props.actionCell, props.actions, props.isRowSelectable ? SELECT_ROWS_CELL_WIDTH : null);
|
|
26
30
|
const gridTemplateRows = (0, get_grid_template_rows_1.getGridTemplateRows)(props.data, (_b = props.headerRowHeight) !== null && _b !== void 0 ? _b : 36, (_c = props.rowHeight) !== null && _c !== void 0 ? _c : 44);
|
|
27
31
|
const gridTemplateColumnsWithoutAction = visibleColumns
|
|
28
32
|
.map((column) => { var _a, _b, _c, _d; return (_c = (_b = (_a = props.state.userConfig.columns) === null || _a === void 0 ? void 0 : _a[column.name]) === null || _b === void 0 ? void 0 : _b.width) !== null && _c !== void 0 ? _c : (_d = column.config) === null || _d === void 0 ? void 0 : _d.width; })
|
|
29
33
|
.map((width) => ((0, is_nil_1.isNil)(width) ? "1fr" : (0, rem_1.rem)(width)))
|
|
30
34
|
.join(" ");
|
|
31
|
-
const
|
|
35
|
+
const gridTemplateColumnsWithoutSelectable = (0, is_nil_1.isNil)((_d = props.actionCell) === null || _d === void 0 ? void 0 : _d.width)
|
|
32
36
|
? gridTemplateColumnsWithoutAction
|
|
33
37
|
: `${gridTemplateColumnsWithoutAction} ${(0, rem_1.rem)(props.actionCell.width)}`;
|
|
38
|
+
const gridTemplateColumns = props.isRowSelectable
|
|
39
|
+
? `${(0, rem_1.rem)(SELECT_ROWS_CELL_WIDTH)} ${gridTemplateColumnsWithoutSelectable}`
|
|
40
|
+
: gridTemplateColumnsWithoutSelectable;
|
|
41
|
+
const selectedRows = (_e = props.state.selectedRows) !== null && _e !== void 0 ? _e : empty_array_1.EMPTY_ARRAY;
|
|
42
|
+
const selectRowHandler = (rowId) => () => {
|
|
43
|
+
const isRowSelected = selectedRows.find((r) => keyExtractor(r) === rowId);
|
|
44
|
+
const newSelectedRows = isRowSelected
|
|
45
|
+
? selectedRows.filter((row) => keyExtractor(row) !== rowId)
|
|
46
|
+
: [...selectedRows, props.data.find((row) => keyExtractor(row) === rowId)];
|
|
47
|
+
props.actions.setSelectedRows(newSelectedRows);
|
|
48
|
+
};
|
|
34
49
|
return (react_1.default.createElement(components_1.Table, { gridTemplateColumns: gridTemplateColumns, gridTemplateRows: gridTemplateRows, ref: tableRef },
|
|
35
50
|
react_1.default.createElement(components_1.Table.Header, null,
|
|
36
51
|
react_1.default.createElement(components_1.Table.Row, null,
|
|
52
|
+
react_1.default.createElement(show_1.Show, { when: Boolean(props.isRowSelectable) },
|
|
53
|
+
react_1.default.createElement(header_select_all_rows_checkbox_1.HeaderSelectAllRowsCheckbox, { actions: props.actions, data: props.data, keyExtractor: keyExtractor, state: props.state })),
|
|
37
54
|
visibleColumns.map((column, index) => {
|
|
38
55
|
var _a;
|
|
39
56
|
return (react_1.default.createElement(components_1.Table.HeaderCell, { column: column, key: column.name, onClick: column.sort ? () => props.actions.sort(column.name) : undefined, onResizeStart: () => onResizeStart(index), ref: (el) => {
|
|
@@ -43,6 +60,8 @@ function TableV2(props) {
|
|
|
43
60
|
react_1.default.createElement(show_1.Show, { when: (0, is_not_nil_1.isNotNil)(props.actionCell) },
|
|
44
61
|
react_1.default.createElement(components_1.Table.HeaderActionCell, null)))),
|
|
45
62
|
react_1.default.createElement(components_1.Table.Body, null, props.data.map((row) => (react_1.default.createElement(components_1.Table.Row, { key: keyExtractor(row) },
|
|
63
|
+
react_1.default.createElement(show_1.Show, { when: Boolean(props.isRowSelectable) },
|
|
64
|
+
react_1.default.createElement(select_row_checkbox_1.SelectRowCheckbox, { isRowSelected: selectedRows.find((r) => keyExtractor(r) === keyExtractor(row)), onSelectRowChange: selectRowHandler(keyExtractor(row)) })),
|
|
46
65
|
visibleColumns.map((column) => {
|
|
47
66
|
var _a, _b, _c, _d;
|
|
48
67
|
const BodyCell =
|