@uxf/data-grid 11.34.1 → 11.36.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 CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as dataGridStories from "./data-grid.stories";
2
2
  import * as dataGridCustomExampleStories from "./data-grid-custom-example.stories";
3
+ import * as dataGridV2Stories from "./data-grid-v2.stories";
3
4
  import * as exportButtonStories from "./export-button/export-button.stories";
4
5
  import * as filterListStories from "./filter-list/filter-list.stories";
5
6
  import * as filtersStories from "./filters/filters.stories";
@@ -25,6 +26,10 @@ export declare const components: {
25
26
  readonly title: "DataGridCustomExample";
26
27
  readonly stories: typeof dataGridCustomExampleStories;
27
28
  };
29
+ readonly "data-grid-v2": {
30
+ readonly title: "DataGridV2";
31
+ readonly stories: typeof dataGridV2Stories;
32
+ };
28
33
  readonly "export-button": {
29
34
  readonly title: "ExportButton";
30
35
  readonly stories: typeof exportButtonStories;
package/components.js CHANGED
@@ -27,6 +27,7 @@ exports.components = void 0;
27
27
  // generated file
28
28
  const dataGridStories = __importStar(require("./data-grid.stories"));
29
29
  const dataGridCustomExampleStories = __importStar(require("./data-grid-custom-example.stories"));
30
+ const dataGridV2Stories = __importStar(require("./data-grid-v2.stories"));
30
31
  const exportButtonStories = __importStar(require("./export-button/export-button.stories"));
31
32
  const filterListStories = __importStar(require("./filter-list/filter-list.stories"));
32
33
  const filtersStories = __importStar(require("./filters/filters.stories"));
@@ -52,6 +53,10 @@ exports.components = {
52
53
  title: "DataGridCustomExample",
53
54
  stories: dataGridCustomExampleStories
54
55
  },
56
+ "data-grid-v2": {
57
+ title: "DataGridV2",
58
+ stories: dataGridV2Stories
59
+ },
55
60
  "export-button": {
56
61
  title: "ExportButton",
57
62
  stories: exportButtonStories
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ import { BaseGridType, DataGridProps } from "./types";
3
+ export declare function DataGridV2<GridType extends BaseGridType, R = any>(props: DataGridProps<GridType, R>): React.JSX.Element;
@@ -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,2 @@
1
+ import React from "react";
2
+ export declare function Default(): React.JSX.Element;
@@ -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
  }
@@ -85,7 +85,7 @@ function Default() {
85
85
  schema: schema_1.schema,
86
86
  state,
87
87
  });
88
- return (react_1.default.createElement(react_1.default.Fragment, null,
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,55 +1,55 @@
1
1
  {
2
- "name": "@uxf/data-grid",
3
- "version": "11.34.1",
4
- "description": "UXF DataGrid",
5
- "homepage": "https://gitlab.com/uxf-npm/data-grid#readme",
6
- "main": "index.js",
7
- "bin": {
8
- "uxf-data-grid-generator": "bin/uxf-data-grid-generator.js"
9
- },
10
- "typings": "index.d.ts",
11
- "publishConfig": {
12
- "access": "public"
13
- },
14
- "repository": {
15
- "type": "git",
16
- "url": "git+https://gitlab.com/uxf-npm/data-grid.git"
17
- },
18
- "license": "MIT",
19
- "keywords": [
20
- "data-table",
21
- "data-grid",
22
- "uxf"
23
- ],
24
- "scripts": {
25
- "dev": "next dev",
26
- "build": "tsc -P tsconfig.json",
27
- "gen:icons": "icons-gen",
28
- "gen:data-grid": "node bin/uxf-data-grid-generator.js -s _generator/__generator_tests__/data-grid-schema -o _generator/__generator_tests__/data-grid --requiredLoader",
29
- "lint": "./node_modules/.bin/eslint -c .eslintrc.js \"./**/*.ts*\"",
30
- "test": "npm run-script typecheck",
31
- "typecheck": "tsc --noEmit --skipLibCheck"
32
- },
33
- "dependencies": {
34
- "@uxf/core": "11.32.0",
35
- "@uxf/core-react": "11.33.0",
36
- "@uxf/ui": "11.34.1",
37
- "dayjs": "1.11.13",
38
- "deepmerge": "4.3.1",
39
- "fast-glob": "3.3.2",
40
- "qs": "6.13.0",
41
- "react-data-grid": "7.0.0-beta.39",
42
- "yargs": "17.7.2"
43
- },
44
- "peerDependencies": {
45
- "react": ">=18.2.0",
46
- "react-dom": ">=18.2.0"
47
- },
48
- "devDependencies": {
49
- "@types/react": "18.3.5",
50
- "@types/react-dom": "18.3.0",
51
- "react": "18.3.1",
52
- "react-dom": "18.3.1"
53
- },
54
- "gitHead": "e4f21a15c3d50fb6614d70cdaf36685232de87e7"
55
- }
2
+ "name": "@uxf/data-grid",
3
+ "version": "11.36.0",
4
+ "description": "UXF DataGrid",
5
+ "homepage": "https://gitlab.com/uxf-npm/data-grid#readme",
6
+ "main": "index.js",
7
+ "bin": {
8
+ "uxf-data-grid-generator": "bin/uxf-data-grid-generator.js"
9
+ },
10
+ "typings": "index.d.ts",
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://gitlab.com/uxf-npm/data-grid.git"
17
+ },
18
+ "license": "MIT",
19
+ "keywords": [
20
+ "data-table",
21
+ "data-grid",
22
+ "uxf"
23
+ ],
24
+ "scripts": {
25
+ "dev": "next dev",
26
+ "build": "tsc -P tsconfig.json",
27
+ "gen:icons": "icons-gen",
28
+ "gen:data-grid": "node bin/uxf-data-grid-generator.js -s _generator/__generator_tests__/data-grid-schema -o _generator/__generator_tests__/data-grid --requiredLoader",
29
+ "lint": "./node_modules/.bin/eslint -c .eslintrc.js \"./**/*.ts*\"",
30
+ "test": "npm run-script typecheck",
31
+ "typecheck": "tsc --noEmit --skipLibCheck"
32
+ },
33
+ "dependencies": {
34
+ "@uxf/core": "11.35.0",
35
+ "@uxf/core-react": "11.36.0",
36
+ "@uxf/ui": "11.36.0",
37
+ "dayjs": "1.11.13",
38
+ "deepmerge": "4.3.1",
39
+ "fast-glob": "3.3.2",
40
+ "qs": "6.13.0",
41
+ "react-data-grid": "7.0.0-beta.39",
42
+ "yargs": "17.7.2"
43
+ },
44
+ "peerDependencies": {
45
+ "react": ">=18.2.0",
46
+ "react-dom": ">=18.2.0"
47
+ },
48
+ "devDependencies": {
49
+ "@types/react": "18.3.5",
50
+ "@types/react-dom": "18.3.0",
51
+ "react": "18.3.1",
52
+ "react-dom": "18.3.1"
53
+ },
54
+ "gitHead": "e4f21a15c3d50fb6614d70cdaf36685232de87e7"
55
+ }
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: 1;
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
 
@@ -494,17 +489,17 @@
494
489
  }
495
490
 
496
491
  &__hidden-columns-empty-box {
497
- background-color: var(--uxf-color-warning-surface-muted);
498
- border: theme("borderWidth.DEFAULT") solid var(--uxf-color-warning-border);
492
+ background-color: theme("colors.warning_surface_muted");
493
+ border: theme("borderWidth.DEFAULT") solid theme("colors.warning_border");
499
494
  border-radius: theme("borderRadius.lg");
500
- color: var(--uxf-color-base-text-high-emphasis);
495
+ color: theme("colors.base_text_high_emphasis");
501
496
  display: flex;
502
497
  gap: 12px;
503
498
  margin: 8px 0;
504
499
  padding: 8px 16px;
505
500
 
506
501
  .uxf-icon {
507
- color: var(--uxf-color-warning-icon-on-muted);
502
+ color: theme("colors.warning_icon_on_muted");
508
503
  margin-top: 4px;
509
504
  }
510
505
  }
@@ -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,7 @@
1
+ import React from "react";
2
+ interface SelectRowCheckboxProps {
3
+ isRowSelected: boolean;
4
+ onSelectRowChange: () => void;
5
+ }
6
+ export declare function SelectRowCheckbox(props: SelectRowCheckboxProps): React.JSX.Element;
7
+ export {};
@@ -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 { TableProps } from "../types";
4
- export declare function useResizableColumns(columns: Column<any, any>[], actionCell: TableProps<any>["actionCell"], actions: DataGridControl["actions"]): {
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;
@@ -2,17 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useResizableColumns = useResizableColumns;
4
4
  const is_empty_1 = require("@uxf/core/utils/is-empty");
5
- const is_nil_1 = require("@uxf/core/utils/is-nil");
6
5
  const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
7
6
  const rem_1 = require("@uxf/styles/units/rem");
8
7
  const react_1 = require("react");
9
- function mapColumnSizesToGridTemplateColumns(columnSizes, actionCellWidth) {
10
- const normalizedColumnSizes = columnSizes.map((size) => ((0, is_not_nil_1.isNotNil)(size) ? (0, rem_1.rem)(size) : "1fr"));
11
- return (0, is_nil_1.isNil)(actionCellWidth)
12
- ? `${normalizedColumnSizes.join(" ")}`
13
- : `${normalizedColumnSizes.join(" ")} ${(0, rem_1.rem)(actionCellWidth)}`;
14
- }
15
- function useResizableColumns(columns, actionCell, actions) {
8
+ const get_grid_template_columns_1 = require("../utils/get-grid-template-columns");
9
+ function useResizableColumns(columns, actionCell, actions, selectRowsCellWidth) {
16
10
  const [activeIndex, setActiveIndex] = (0, react_1.useState)(null);
17
11
  const tableRef = (0, react_1.useRef)(null);
18
12
  const columnRefs = (0, react_1.useRef)([]);
@@ -35,7 +29,7 @@ function useResizableColumns(columns, actionCell, actions) {
35
29
  // TODO @vejvis - jak tohle udělat lépe??
36
30
  tempColumnSizes = gridColumns;
37
31
  if (tableRef.current) {
38
- tableRef.current.style.gridTemplateColumns = mapColumnSizesToGridTemplateColumns(gridColumns, actionCellWidth);
32
+ tableRef.current.style.gridTemplateColumns = (0, get_grid_template_columns_1.getGridTemplateColumns)(gridColumns.map((size) => ((0, is_not_nil_1.isNotNil)(size) ? (0, rem_1.rem)(size) : "1fr")), actionCellWidth, selectRowsCellWidth);
39
33
  }
40
34
  };
41
35
  const onMouseUp = () => {
@@ -56,7 +50,7 @@ function useResizableColumns(columns, actionCell, actions) {
56
50
  window.removeEventListener("mousemove", onMouseMove);
57
51
  window.removeEventListener("mouseup", onMouseUp);
58
52
  };
59
- }, [columns, actions, actionCellWidth, activeIndex]);
53
+ }, [columns, actions, actionCellWidth, activeIndex, selectRowsCellWidth]);
60
54
  return {
61
55
  tableRef,
62
56
  columnRefs,
@@ -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,39 @@
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
+
51
+ /* TODO tohle by asi nemělo mít classu uxf-data-grid */
52
+ .uxf-data-grid__action-cell-wrapper {
53
+ justify-content: flex-end;
54
+ padding: 0 theme("spacing.2");
55
+ }
56
+
27
57
  &__row {
28
58
  display: contents;
29
59
  }
@@ -58,6 +88,14 @@
58
88
  display: flex;
59
89
  padding: var(--uxf-dg-table-cell-padding);
60
90
 
91
+ &:first-child {
92
+ padding-left: var(--uxf-dg-table-cell-padding-first-cell);
93
+ }
94
+
95
+ &:nth-last-child(1 of .uxf-dg-table__cell) {
96
+ padding-right: var(--uxf-dg-table-cell-padding-last-cell);
97
+ }
98
+
61
99
  &--header {
62
100
  background-color: var(--uxf-dg-table-header-bg-color);
63
101
  color: var(--uxf-dg-table-header-color);
@@ -79,6 +117,31 @@
79
117
  }
80
118
  }
81
119
 
120
+ &__select-all-rows-cell {
121
+ position: relative;
122
+
123
+ &::before {
124
+ background-color: var(--uxf-color-base-border-border);
125
+ bottom: 0;
126
+ content: "";
127
+ position: absolute;
128
+ right: 0;
129
+ top: 0;
130
+ width: 1px;
131
+ }
132
+
133
+ .uxf-icon {
134
+ margin-left: 0;
135
+ }
136
+ }
137
+
138
+ &__select-all-rows-cell,
139
+ &__select-row-cell {
140
+ .uxf-checkbox-input {
141
+ margin-top: 0;
142
+ }
143
+ }
144
+
82
145
  &__action-cell {
83
146
  background-color: var(--uxf-dg-table-action-cell-bg-color);
84
147
  border-left: var(--uxf-dg-table-action-cell-left-divider-size) solid
@@ -6,34 +6,47 @@ 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");
18
+ const get_grid_template_columns_1 = require("./utils/get-grid-template-columns");
15
19
  const get_grid_template_rows_1 = require("./utils/get-grid-template-rows");
20
+ const SELECT_ROWS_CELL_WIDTH = 40;
16
21
  const defaultKeyExtractor = (r) => r.id;
17
22
  const DefaultBodyCell = () => "Unknown body cell.";
18
23
  /** @deprecated Use DataGridTableV2 */
19
24
  function TableV2(props) {
20
- var _a, _b, _c, _d;
25
+ var _a, _b, _c, _d, _e;
21
26
  const keyExtractor = (_a = props.keyExtractor) !== null && _a !== void 0 ? _a : defaultKeyExtractor;
22
27
  const visibleColumns = props.schema.columns
23
28
  .filter((column) => !column.hidden)
24
29
  .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);
30
+ const selectedRowColumnWidth = props.isRowSelectable ? SELECT_ROWS_CELL_WIDTH : null;
31
+ const { tableRef, columnRefs, onResizeStart } = (0, use_resizable_columns_1.useResizableColumns)(visibleColumns, props.actionCell, props.actions, selectedRowColumnWidth);
26
32
  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
- const gridTemplateColumnsWithoutAction = visibleColumns
33
+ const gridTemplateBasicColumns = visibleColumns
28
34
  .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
- .map((width) => ((0, is_nil_1.isNil)(width) ? "1fr" : (0, rem_1.rem)(width)))
30
- .join(" ");
31
- const gridTemplateColumns = (0, is_nil_1.isNil)((_d = props.actionCell) === null || _d === void 0 ? void 0 : _d.width)
32
- ? gridTemplateColumnsWithoutAction
33
- : `${gridTemplateColumnsWithoutAction} ${(0, rem_1.rem)(props.actionCell.width)}`;
35
+ .map((width) => ((0, is_nil_1.isNil)(width) ? "1fr" : (0, rem_1.rem)(width)));
36
+ const gridTemplateColumns = (0, get_grid_template_columns_1.getGridTemplateColumns)(gridTemplateBasicColumns, selectedRowColumnWidth, (_d = props.actionCell) === null || _d === void 0 ? void 0 : _d.width);
37
+ const selectedRows = (_e = props.state.selectedRows) !== null && _e !== void 0 ? _e : empty_array_1.EMPTY_ARRAY;
38
+ const selectRowHandler = (rowId) => () => {
39
+ const isRowSelected = selectedRows.find((r) => keyExtractor(r) === rowId);
40
+ const newSelectedRows = isRowSelected
41
+ ? selectedRows.filter((row) => keyExtractor(row) !== rowId)
42
+ : [...selectedRows, props.data.find((row) => keyExtractor(row) === rowId)];
43
+ props.actions.setSelectedRows(newSelectedRows);
44
+ };
34
45
  return (react_1.default.createElement(components_1.Table, { gridTemplateColumns: gridTemplateColumns, gridTemplateRows: gridTemplateRows, ref: tableRef },
35
46
  react_1.default.createElement(components_1.Table.Header, null,
36
47
  react_1.default.createElement(components_1.Table.Row, null,
48
+ react_1.default.createElement(show_1.Show, { when: Boolean(props.isRowSelectable) },
49
+ react_1.default.createElement(header_select_all_rows_checkbox_1.HeaderSelectAllRowsCheckbox, { actions: props.actions, data: props.data, keyExtractor: keyExtractor, state: props.state })),
37
50
  visibleColumns.map((column, index) => {
38
51
  var _a;
39
52
  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 +56,8 @@ function TableV2(props) {
43
56
  react_1.default.createElement(show_1.Show, { when: (0, is_not_nil_1.isNotNil)(props.actionCell) },
44
57
  react_1.default.createElement(components_1.Table.HeaderActionCell, null)))),
45
58
  react_1.default.createElement(components_1.Table.Body, null, props.data.map((row) => (react_1.default.createElement(components_1.Table.Row, { key: keyExtractor(row) },
59
+ react_1.default.createElement(show_1.Show, { when: Boolean(props.isRowSelectable) },
60
+ react_1.default.createElement(select_row_checkbox_1.SelectRowCheckbox, { isRowSelected: selectedRows.find((r) => keyExtractor(r) === keyExtractor(row)), onSelectRowChange: selectRowHandler(keyExtractor(row)) })),
46
61
  visibleColumns.map((column) => {
47
62
  var _a, _b, _c, _d;
48
63
  const BodyCell =
@@ -0,0 +1,2 @@
1
+ import { Nullish } from "@uxf/core/types";
2
+ export declare function getGridTemplateColumns(columns: string[], selectRowColumnWidth: number | Nullish, actionColumnWidth: number | Nullish): string;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getGridTemplateColumns = getGridTemplateColumns;
4
+ const buildArray_1 = require("@uxf/core/utils/buildArray");
5
+ const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
6
+ const rem_1 = require("@uxf/styles/units/rem");
7
+ function getGridTemplateColumns(columns, selectRowColumnWidth, actionColumnWidth) {
8
+ return (0, buildArray_1.buildArray)()
9
+ .when((0, is_not_nil_1.isNotNil)(selectRowColumnWidth), (0, rem_1.rem)(selectRowColumnWidth !== null && selectRowColumnWidth !== void 0 ? selectRowColumnWidth : 0))
10
+ .add(columns.join(" "))
11
+ .when((0, is_not_nil_1.isNotNil)(actionColumnWidth), `minmax(${(0, rem_1.rem)(actionColumnWidth !== null && actionColumnWidth !== void 0 ? actionColumnWidth : 0)}, auto)`)
12
+ .join(" ");
13
+ }