@uxf/data-grid 11.45.0 → 11.46.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/_story-utils/schema.js +1 -1
- package/data-grid-v2.stories.js +7 -12
- package/data-grid.js +1 -1
- package/package.json +4 -4
- package/table/hooks/use-rdg-visuals.d.ts +2 -3
- package/table-v2/components/header-select-all-rows-checkbox.js +2 -1
- package/table-v2/hooks/use-resizable-columns.js +12 -8
- package/table-v2/table-v2.js +5 -2
- package/table-v2/types.d.ts +1 -3
- package/table-v2/utils/get-grid-template-columns.d.ts +4 -1
- package/table-v2/utils/get-grid-template-columns.js +1 -1
- package/types/data-grid-props.d.ts +1 -1
package/_story-utils/schema.js
CHANGED
|
@@ -15,7 +15,7 @@ exports.schema = {
|
|
|
15
15
|
{ name: "chip", type: "chip", label: "Chip" },
|
|
16
16
|
{ name: "chips", type: "chips", label: "Chips" },
|
|
17
17
|
{ name: "money", type: "money", label: "Money" },
|
|
18
|
-
{ name: "toOne", type: "toOne", label: "
|
|
18
|
+
{ name: "toOne", type: "toOne", label: "ToOne" },
|
|
19
19
|
{ name: "toMany", type: "toMany", label: "To many" },
|
|
20
20
|
{ name: "hidden", type: "hidden", label: "Hidden", hidden: true },
|
|
21
21
|
],
|
package/data-grid-v2.stories.js
CHANGED
|
@@ -61,7 +61,12 @@ const actionCell = {
|
|
|
61
61
|
const schemaWithFrontendConfig = (0, merge_schema_with_config_1.mergeSchemaWithConfig)(schema_1.schema, {
|
|
62
62
|
perPage: 100,
|
|
63
63
|
columns: {
|
|
64
|
+
text: { width: 200 },
|
|
65
|
+
tel: { minWidth: 160, width: 600 },
|
|
66
|
+
mail: { minWidth: 200 },
|
|
64
67
|
bool: { width: 80 },
|
|
68
|
+
chips: { minWidth: 200 },
|
|
69
|
+
toMany: { minWidth: 200 },
|
|
65
70
|
},
|
|
66
71
|
filters: {
|
|
67
72
|
text: { placeholder: "Custom placeholder ..." },
|
|
@@ -74,17 +79,7 @@ const FILTER_BEHAVIOR_OPTIONS = [
|
|
|
74
79
|
];
|
|
75
80
|
function Default() {
|
|
76
81
|
const [filterBehavior, setFilterBehavior] = (0, react_1.useState)("filtersPerTab");
|
|
77
|
-
const { state, actions } = (0, use_data_grid_control_1.useDataGridControl)({
|
|
78
|
-
schema: schema_1.schema,
|
|
79
|
-
initialUserConfig: {
|
|
80
|
-
columns: {
|
|
81
|
-
id: { width: 100 },
|
|
82
|
-
text: { minWidth: 300 },
|
|
83
|
-
mail: { minWidth: 300 },
|
|
84
|
-
tel: { minWidth: 300 },
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
});
|
|
82
|
+
const { state, actions } = (0, use_data_grid_control_1.useDataGridControl)({ schema: schema_1.schema });
|
|
88
83
|
const { isLoading, error, data, onReload } = (0, use_data_grid_fetching_1.useDataGridFetching)({
|
|
89
84
|
loader: loader_1.loader,
|
|
90
85
|
schema: schema_1.schema,
|
|
@@ -92,6 +87,6 @@ function Default() {
|
|
|
92
87
|
});
|
|
93
88
|
return (react_1.default.createElement("div", { className: "p-10" },
|
|
94
89
|
react_1.default.createElement(radio_group_1.RadioGroup, { label: "Chov\u00E1n\u00ED p\u0159ep\u00EDn\u00E1n\u00ED tab\u016F", name: "filterBehavior", onChange: (value) => setFilterBehavior(value), options: FILTER_BEHAVIOR_OPTIONS, value: filterBehavior }),
|
|
95
|
-
react_1.default.createElement(data_grid_v2_1.DataGridV2, { actionCell: actionCell, actions: actions, changeTabFilterBehavior: filterBehavior !== null && filterBehavior !== void 0 ? filterBehavior : "filtersPerTab", data: data, error: error, isLoading: isLoading, isRowSelectable: true, onCsvDownload: console.log, onReload: onReload, schema: schemaWithFrontendConfig, state: state }),
|
|
90
|
+
react_1.default.createElement(data_grid_v2_1.DataGridV2, { actionCell: actionCell, actions: actions, changeTabFilterBehavior: filterBehavior !== null && filterBehavior !== void 0 ? filterBehavior : "filtersPerTab", data: data, error: error, isLoading: isLoading, isRowSelectable: true, onCsvDownload: console.log, onReload: onReload, rowHeight: "auto", schema: schemaWithFrontendConfig, state: state }),
|
|
96
91
|
react_1.default.createElement(json_renderer_1.JsonRenderer, { value: state })));
|
|
97
92
|
}
|
package/data-grid.js
CHANGED
|
@@ -33,7 +33,7 @@ function DataGrid(props) {
|
|
|
33
33
|
react_1.default.createElement(toolbar_customs_1.DataGridToolbarCustoms, { buttons: props.customActions })),
|
|
34
34
|
react_1.default.createElement(linear_progress_1.DataGridLinearProgress, { isLoading: props.isLoading }),
|
|
35
35
|
react_1.default.createElement(filter_list_1.DataGridFilterList, { actions: props.actions, filterHandlers: (_b = props.filterHandlers) !== null && _b !== void 0 ? _b : filter_handler_1.defaultFilterHandlers, schema: props.schema, state: props.state }),
|
|
36
|
-
react_1.default.createElement(table_1.DataGridTable, { 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 }),
|
|
36
|
+
react_1.default.createElement(table_1.DataGridTable, { 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 === "auto" ? undefined : props.rowHeight, schema: props.schema, state: props.state }),
|
|
37
37
|
react_1.default.createElement(footer_1.DataGridFooter, null,
|
|
38
38
|
react_1.default.createElement(rows_per_page_select_1.DataGridRowsPerPageSelect, { actions: props.actions, state: props.state }),
|
|
39
39
|
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 }),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uxf/data-grid",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.46.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.46.0",
|
|
35
|
+
"@uxf/core-react": "11.46.0",
|
|
36
|
+
"@uxf/ui": "11.46.0",
|
|
37
37
|
"dayjs": "1.11.13",
|
|
38
38
|
"deepmerge": "4.3.1",
|
|
39
39
|
"fast-glob": "3.3.2",
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { DataGridHandle } from "react-data-grid";
|
|
2
|
-
import { DataGridBaseProps } from "../../types
|
|
3
|
-
import { BaseGridType } from "../../types/schema";
|
|
2
|
+
import { BaseGridType, DataGridBaseProps } from "../../types";
|
|
4
3
|
export declare function useRdgVisuals(props: {
|
|
5
4
|
headerRowHeight?: DataGridBaseProps<BaseGridType, any>["headerRowHeight"];
|
|
6
|
-
rowHeight?: DataGridBaseProps<BaseGridType, any>["rowHeight"]
|
|
5
|
+
rowHeight?: Exclude<DataGridBaseProps<BaseGridType, any>["rowHeight"], "auto">;
|
|
7
6
|
rows: any[];
|
|
8
7
|
}): {
|
|
9
8
|
className: string;
|
|
@@ -11,7 +11,8 @@ const react_1 = __importDefault(require("react"));
|
|
|
11
11
|
function HeaderSelectAllRowsCheckbox(props) {
|
|
12
12
|
var _a;
|
|
13
13
|
const selectedRows = (_a = props.state.selectedRows) !== null && _a !== void 0 ? _a : empty_array_1.EMPTY_ARRAY;
|
|
14
|
-
const isAllRowsSelected =
|
|
14
|
+
const isAllRowsSelected = (0, is_not_empty_1.isNotEmpty)(props.data) &&
|
|
15
|
+
props.data.every((row) => selectedRows.find((selectedRow) => props.keyExtractor(row) === props.keyExtractor(selectedRow)));
|
|
15
16
|
const isIndeterminate = !isAllRowsSelected && (0, is_not_empty_1.isNotEmpty)(selectedRows);
|
|
16
17
|
const selectAllRowsHandler = () => {
|
|
17
18
|
props.actions.setSelectedRows(isAllRowsSelected ? [] : props.data);
|
|
@@ -2,10 +2,10 @@
|
|
|
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_not_nil_1 = require("@uxf/core/utils/is-not-nil");
|
|
6
5
|
const rem_1 = require("@uxf/styles/units/rem");
|
|
7
6
|
const react_1 = require("react");
|
|
8
7
|
const get_grid_template_columns_1 = require("../utils/get-grid-template-columns");
|
|
8
|
+
const COLUMN_ABSOLUTE_MIN_WIDTH = 50;
|
|
9
9
|
function useResizableColumns(columns, actionCell, actions, selectRowsCellWidth) {
|
|
10
10
|
const [activeIndex, setActiveIndex] = (0, react_1.useState)(null);
|
|
11
11
|
const tableRef = (0, react_1.useRef)(null);
|
|
@@ -14,24 +14,28 @@ function useResizableColumns(columns, actionCell, actions, selectRowsCellWidth)
|
|
|
14
14
|
(0, react_1.useEffect)(() => {
|
|
15
15
|
let tempColumnSizes = [];
|
|
16
16
|
const onMouseMove = (e) => {
|
|
17
|
-
const gridColumns = columns.map((
|
|
18
|
-
var _a, _b, _c, _d;
|
|
17
|
+
const gridColumns = columns.map((column, i) => {
|
|
18
|
+
var _a, _b, _c, _d, _e, _f;
|
|
19
19
|
const columnRef = columnRefs.current[i];
|
|
20
|
+
const columnMinWidth = (_b = (_a = column.config) === null || _a === void 0 ? void 0 : _a.minWidth) !== null && _b !== void 0 ? _b : COLUMN_ABSOLUTE_MIN_WIDTH;
|
|
20
21
|
if (i === activeIndex) {
|
|
21
|
-
const tableScrollLeft = (
|
|
22
|
-
const columnOffsetLeft = (
|
|
22
|
+
const tableScrollLeft = (_d = (_c = tableRef.current) === null || _c === void 0 ? void 0 : _c.scrollLeft) !== null && _d !== void 0 ? _d : 0;
|
|
23
|
+
const columnOffsetLeft = (_e = columnRef === null || columnRef === void 0 ? void 0 : columnRef.offsetLeft) !== null && _e !== void 0 ? _e : 0;
|
|
23
24
|
const clickPositionX = e.clientX + tableScrollLeft;
|
|
24
25
|
const width = clickPositionX - columnOffsetLeft;
|
|
25
|
-
return width >=
|
|
26
|
+
return width >= columnMinWidth ? width : columnMinWidth;
|
|
26
27
|
}
|
|
27
|
-
return (
|
|
28
|
+
return (_f = columnRef === null || columnRef === void 0 ? void 0 : columnRef.offsetWidth) !== null && _f !== void 0 ? _f : columnMinWidth;
|
|
28
29
|
});
|
|
29
30
|
// TODO @vejvis - jak tohle udělat lépe??
|
|
30
31
|
tempColumnSizes = gridColumns;
|
|
31
32
|
if (tableRef.current) {
|
|
32
33
|
tableRef.current.style.gridTemplateColumns = (0, get_grid_template_columns_1.getGridTemplateColumns)({
|
|
33
34
|
actionColumnWidth: actionCellWidth,
|
|
34
|
-
columns: gridColumns.map((size) => (
|
|
35
|
+
columns: gridColumns.map((size) => ({
|
|
36
|
+
width: (0, rem_1.rem)(size),
|
|
37
|
+
minWidth: null,
|
|
38
|
+
})),
|
|
35
39
|
selectRowColumnWidth: selectRowsCellWidth,
|
|
36
40
|
});
|
|
37
41
|
}
|
package/table-v2/table-v2.js
CHANGED
|
@@ -29,8 +29,11 @@ function DataGridTableV2(props) {
|
|
|
29
29
|
const { tableRef, columnRefs, onResizeStart } = (0, use_resizable_columns_1.useResizableColumns)(visibleColumns, props.actionCell, props.actions, selectedRowColumnWidth);
|
|
30
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);
|
|
31
31
|
const gridTemplateBasicColumns = visibleColumns
|
|
32
|
-
.map((column) => { var _a, _b
|
|
33
|
-
.map((
|
|
32
|
+
.map((column) => { var _a, _b; return (_b = (_a = props.state.userConfig.columns) === null || _a === void 0 ? void 0 : _a[column.name]) !== null && _b !== void 0 ? _b : column.config; })
|
|
33
|
+
.map((columnConfig) => ({
|
|
34
|
+
width: (0, is_nil_1.isNil)(columnConfig === null || columnConfig === void 0 ? void 0 : columnConfig.width) ? "1fr" : (0, rem_1.rem)(columnConfig.width),
|
|
35
|
+
minWidth: (0, is_nil_1.isNil)(columnConfig === null || columnConfig === void 0 ? void 0 : columnConfig.minWidth) ? null : (0, rem_1.rem)(columnConfig.minWidth),
|
|
36
|
+
}));
|
|
34
37
|
const gridTemplateColumns = (0, get_grid_template_columns_1.getGridTemplateColumns)({
|
|
35
38
|
columns: gridTemplateBasicColumns,
|
|
36
39
|
selectRowColumnWidth: selectedRowColumnWidth,
|
package/table-v2/types.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { Nullish } from "@uxf/core/types";
|
|
2
|
-
import { ActionCellComponent, BodyCellComponents } from "../types
|
|
3
|
-
import { KeyExtractor } from "../types/core";
|
|
4
|
-
import { Schema } from "../types/schema";
|
|
2
|
+
import { ActionCellComponent, BodyCellComponents, KeyExtractor, Schema } from "../types";
|
|
5
3
|
import { DataGridControl } from "../use-data-grid-control";
|
|
6
4
|
import { NoRowsFallbackComponent } from "./no-rows-fallback";
|
|
7
5
|
export interface DataGridTableProps<Row> extends DataGridControl {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Nullish } from "@uxf/core/types";
|
|
2
2
|
export declare function getGridTemplateColumns(config: {
|
|
3
|
-
columns:
|
|
3
|
+
columns: {
|
|
4
|
+
width: string;
|
|
5
|
+
minWidth: string | null;
|
|
6
|
+
}[];
|
|
4
7
|
selectRowColumnWidth: number | Nullish;
|
|
5
8
|
actionColumnWidth: number | Nullish;
|
|
6
9
|
}): string;
|
|
@@ -8,7 +8,7 @@ function getGridTemplateColumns(config) {
|
|
|
8
8
|
var _a, _b;
|
|
9
9
|
return (0, buildArray_1.buildArray)()
|
|
10
10
|
.when((0, is_not_nil_1.isNotNil)(config.selectRowColumnWidth), (0, rem_1.rem)((_a = config.selectRowColumnWidth) !== null && _a !== void 0 ? _a : 0))
|
|
11
|
-
.add(config.columns.join(" "))
|
|
11
|
+
.add(config.columns.map((col) => (col.minWidth ? `minmax(${col.minWidth},${col.width})` : col.width)).join(" "))
|
|
12
12
|
.when((0, is_not_nil_1.isNotNil)(config.actionColumnWidth), `minmax(${(0, rem_1.rem)((_b = config.actionColumnWidth) !== null && _b !== void 0 ? _b : 0)}, auto)`)
|
|
13
13
|
.join(" ");
|
|
14
14
|
}
|
|
@@ -15,7 +15,7 @@ export type DataGridBaseProps<GridType extends BaseGridType, Row> = {
|
|
|
15
15
|
gridName?: string;
|
|
16
16
|
keyExtractor?: KeyExtractor;
|
|
17
17
|
onCsvDownload?: CsvDownloadHandler;
|
|
18
|
-
rowHeight?: number | ((row: Row) => number);
|
|
18
|
+
rowHeight?: number | ((row: Row) => number) | "auto";
|
|
19
19
|
headerRowHeight?: number;
|
|
20
20
|
rowClass?: (row: Row) => "success" | "warning" | "error" | "primary" | "secondary" | string | null | undefined;
|
|
21
21
|
className?: string;
|