@uxf/data-grid 11.112.1 → 11.114.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/_store/reducer.js +0 -1
- package/data-grid.js +1 -1
- package/filters/filters.js +0 -1
- package/package.json +11 -11
- package/table-v2/hooks/use-resizable-columns.d.ts +1 -1
- package/table-v2/hooks/use-resizable-columns.js +3 -3
- package/table-v2/no-rows-fallback.d.ts +1 -1
- package/table-v2/no-rows-fallback.js +2 -1
- package/table-v2/styles.css +4 -0
- package/table-v2/table-v2.js +19 -18
- package/table-v2/types.d.ts +0 -1
- package/table-v2/utils/get-grid-template-rows.d.ts +1 -1
- package/table-v2/utils/get-grid-template-rows.js +3 -3
- package/types/data-grid-props.d.ts +0 -1
package/_store/reducer.js
CHANGED
|
@@ -118,7 +118,6 @@ const reducer = (state, action) => {
|
|
|
118
118
|
},
|
|
119
119
|
};
|
|
120
120
|
case "CHANGE_TAB": {
|
|
121
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
122
121
|
const tabHistory = (_d = state.tabRequests[action.tab.name]) !== null && _d !== void 0 ? _d : empty_object_1.EMPTY_OBJECT;
|
|
123
122
|
return {
|
|
124
123
|
...state,
|
package/data-grid.js
CHANGED
|
@@ -32,7 +32,7 @@ function DataGrid(props) {
|
|
|
32
32
|
react_1.default.createElement(toolbar_customs_1.DataGridToolbarCustoms, { buttons: props.customActions })),
|
|
33
33
|
react_1.default.createElement(linear_progress_1.DataGridLinearProgress, { isLoading: props.isLoading }),
|
|
34
34
|
react_1.default.createElement(filter_list_1.DataGridFilterList, { actions: props.actions, filterHandlers: (_c = props.filterHandlers) !== null && _c !== void 0 ? _c : filter_handler_1.defaultFilterHandlers, schema: props.schema, state: props.state }),
|
|
35
|
-
react_1.default.createElement(table_v2_1.DataGridTableV2, { NoRowsFallback: props.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, hasStickyHeader: props.hasStickyHeader,
|
|
35
|
+
react_1.default.createElement(table_v2_1.DataGridTableV2, { NoRowsFallback: props.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, hasStickyHeader: props.hasStickyHeader, isLoading: props.isLoading, isRowSelectDisabled: props.isRowSelectDisabled, isRowsSelectable: props.isRowsSelectable, keyExtractor: props.keyExtractor, reload: props.reload, rowAccent: props.rowAccent, rowClassName: props.rowClassName, rowHeight: props.rowHeight, schema: props.schema, state: props.state }),
|
|
36
36
|
react_1.default.createElement(footer_1.DataGridFooter, null,
|
|
37
37
|
react_1.default.createElement(rows_per_page_select_1.DataGridRowsPerPageSelect, { actions: props.actions, state: props.state }),
|
|
38
38
|
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/filters/filters.js
CHANGED
|
@@ -10,7 +10,6 @@ function DataGridFilters(props) {
|
|
|
10
10
|
return (react_1.default.createElement("div", { className: "uxf-data-grid__filters" }, props.schema.filters.map((filter) => {
|
|
11
11
|
const filterHandler = props.filterHandlers[filter.type];
|
|
12
12
|
const FilterInput = filterHandler === null || filterHandler === void 0 ? void 0 : filterHandler.Input;
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
14
13
|
if (!FilterInput) {
|
|
15
14
|
// eslint-disable-next-line no-console
|
|
16
15
|
console.warn(`Unknown filter "${filter.type}".`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uxf/data-grid",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.114.0",
|
|
4
4
|
"description": "UXF DataGrid",
|
|
5
5
|
"homepage": "https://gitlab.com/uxf-npm/data-grid#readme",
|
|
6
6
|
"main": "index.js",
|
|
@@ -41,11 +41,11 @@
|
|
|
41
41
|
"@dnd-kit/core": "^6.3.1",
|
|
42
42
|
"@dnd-kit/sortable": "^10.0.0",
|
|
43
43
|
"@dnd-kit/utilities": "^3.2.2",
|
|
44
|
-
"@uxf/core": "11.
|
|
45
|
-
"@uxf/core-react": "11.
|
|
46
|
-
"@uxf/localize": "11.
|
|
47
|
-
"@uxf/styles": "11.
|
|
48
|
-
"@uxf/ui": "11.
|
|
44
|
+
"@uxf/core": "11.114.0",
|
|
45
|
+
"@uxf/core-react": "11.114.0",
|
|
46
|
+
"@uxf/localize": "11.114.0",
|
|
47
|
+
"@uxf/styles": "11.114.0",
|
|
48
|
+
"@uxf/ui": "11.114.0",
|
|
49
49
|
"dayjs": "^1.11.19",
|
|
50
50
|
"react": ">=18.2.0",
|
|
51
51
|
"react-dom": ">=18.2.0"
|
|
@@ -56,11 +56,11 @@
|
|
|
56
56
|
"@dnd-kit/utilities": "^3.2.2",
|
|
57
57
|
"@types/react": "18.3.27",
|
|
58
58
|
"@types/react-dom": "18.3.7",
|
|
59
|
-
"@uxf/core": "11.
|
|
60
|
-
"@uxf/core-react": "11.
|
|
61
|
-
"@uxf/localize": "11.
|
|
62
|
-
"@uxf/styles": "11.
|
|
63
|
-
"@uxf/ui": "11.
|
|
59
|
+
"@uxf/core": "11.114.0",
|
|
60
|
+
"@uxf/core-react": "11.114.0",
|
|
61
|
+
"@uxf/localize": "11.114.0",
|
|
62
|
+
"@uxf/styles": "11.114.0",
|
|
63
|
+
"@uxf/ui": "11.114.0",
|
|
64
64
|
"dayjs": "^1.11.19",
|
|
65
65
|
"react": "18.3.1",
|
|
66
66
|
"react-dom": "18.3.1"
|
|
@@ -2,7 +2,7 @@ import { Nullish } from "@uxf/core/types";
|
|
|
2
2
|
import { BaseGridType, Column } from "../../types";
|
|
3
3
|
import { DataGridControl } from "../../use-data-grid-control";
|
|
4
4
|
import { DataGridTableProps } from "../types";
|
|
5
|
-
export declare function useResizableColumns<GridType extends BaseGridType>(columns: Column[], actionCell: DataGridTableProps<GridType>["actionCell"], actions: DataGridControl["actions"], selectRowsCellWidth: number | Nullish): {
|
|
5
|
+
export declare function useResizableColumns<GridType extends BaseGridType>(columns: Column[], actionCell: DataGridTableProps<GridType>["actionCell"], actions: DataGridControl["actions"], selectRowsCellWidth: number | Nullish, hasStickyHeader: boolean): {
|
|
6
6
|
tableRef: import("react").RefObject<HTMLDivElement>;
|
|
7
7
|
headerRef: import("react").RefObject<HTMLDivElement>;
|
|
8
8
|
bodyRef: import("react").RefObject<HTMLDivElement>;
|
|
@@ -7,7 +7,7 @@ const react_1 = require("react");
|
|
|
7
7
|
const get_grid_template_columns_1 = require("../utils/get-grid-template-columns");
|
|
8
8
|
const COLUMN_ABSOLUTE_MIN_WIDTH = 50;
|
|
9
9
|
const COLUMN_PADDING = 24;
|
|
10
|
-
function useResizableColumns(columns, actionCell, actions, selectRowsCellWidth) {
|
|
10
|
+
function useResizableColumns(columns, actionCell, actions, selectRowsCellWidth, hasStickyHeader) {
|
|
11
11
|
const [activeIndex, setActiveIndex] = (0, react_1.useState)(null);
|
|
12
12
|
const tableRef = (0, react_1.useRef)(null);
|
|
13
13
|
const headerRef = (0, react_1.useRef)(null);
|
|
@@ -23,7 +23,7 @@ function useResizableColumns(columns, actionCell, actions, selectRowsCellWidth)
|
|
|
23
23
|
const columnMinWidth = (_b = (_a = column.config) === null || _a === void 0 ? void 0 : _a.minWidth) !== null && _b !== void 0 ? _b : COLUMN_ABSOLUTE_MIN_WIDTH;
|
|
24
24
|
if (i === activeIndex) {
|
|
25
25
|
const tableScrollLeft = (_d = (_c = headerRef.current) === null || _c === void 0 ? void 0 : _c.scrollLeft) !== null && _d !== void 0 ? _d : 0;
|
|
26
|
-
const columnOffsetLeft = ((_e = columnRef === null || columnRef === void 0 ? void 0 : columnRef.offsetLeft) !== null && _e !== void 0 ? _e : 0) + ((_g = (_f = tableRef.current) === null || _f === void 0 ? void 0 : _f.offsetLeft) !== null && _g !== void 0 ? _g : 0);
|
|
26
|
+
const columnOffsetLeft = ((_e = columnRef === null || columnRef === void 0 ? void 0 : columnRef.offsetLeft) !== null && _e !== void 0 ? _e : 0) + (hasStickyHeader ? ((_g = (_f = tableRef.current) === null || _f === void 0 ? void 0 : _f.offsetLeft) !== null && _g !== void 0 ? _g : 0) : 0);
|
|
27
27
|
const clickPositionX = e.clientX + tableScrollLeft;
|
|
28
28
|
const width = clickPositionX - columnOffsetLeft;
|
|
29
29
|
return width >= columnMinWidth ? width : columnMinWidth;
|
|
@@ -71,7 +71,7 @@ function useResizableColumns(columns, actionCell, actions, selectRowsCellWidth)
|
|
|
71
71
|
window.removeEventListener("mousemove", onMouseMove);
|
|
72
72
|
window.removeEventListener("mouseup", onMouseUp);
|
|
73
73
|
};
|
|
74
|
-
}, [columns, actions, actionCellWidth, activeIndex, selectRowsCellWidth]);
|
|
74
|
+
}, [columns, actions, actionCellWidth, activeIndex, selectRowsCellWidth, hasStickyHeader]);
|
|
75
75
|
const onAutoSize = (index) => {
|
|
76
76
|
var _a, _b;
|
|
77
77
|
const table = tableRef.current;
|
|
@@ -6,11 +6,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.NoRowsFallback = NoRowsFallback;
|
|
7
7
|
const translations_1 = require("@uxf/core-react/translations");
|
|
8
8
|
const cx_1 = require("@uxf/core/utils/cx");
|
|
9
|
+
const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
|
|
9
10
|
const icon_1 = require("@uxf/ui/icon");
|
|
10
11
|
const react_1 = __importDefault(require("react"));
|
|
11
12
|
function NoRowsFallback(props) {
|
|
12
13
|
const t = (0, translations_1.useUxfTranslation)();
|
|
13
|
-
return (react_1.default.createElement("div", { className: (0, cx_1.cx)("uxf-dg-table__no-rows-fallback", props.isLoading && "is-loading", props.error && "is-error") }, props.isLoading ? (react_1.default.createElement(react_1.default.Fragment, null, t("uxf-data-grid-no-rows-fallback:loading"))) : props.error ? (react_1.default.createElement(react_1.default.Fragment, null,
|
|
14
|
+
return (react_1.default.createElement("div", { className: (0, cx_1.cx)("uxf-dg-table__no-rows-fallback", props.isLoading && "is-loading", (0, is_not_nil_1.isNotNil)(props.error) && "is-error") }, props.isLoading ? (react_1.default.createElement(react_1.default.Fragment, null, t("uxf-data-grid-no-rows-fallback:loading"))) : (0, is_not_nil_1.isNotNil)(props.error) ? (react_1.default.createElement(react_1.default.Fragment, null,
|
|
14
15
|
react_1.default.createElement(icon_1.Icon, { name: "warning", size: 24 }),
|
|
15
16
|
react_1.default.createElement("p", null, t("uxf-data-grid-no-rows-fallback:error")))) : (react_1.default.createElement(react_1.default.Fragment, null, t("uxf-data-grid-no-rows-fallback:no-records")))));
|
|
16
17
|
}
|
package/table-v2/styles.css
CHANGED
package/table-v2/table-v2.js
CHANGED
|
@@ -9,6 +9,7 @@ const compose_refs_1 = require("@uxf/core-react/utils/compose-refs");
|
|
|
9
9
|
const empty_array_1 = require("@uxf/core/constants/empty-array");
|
|
10
10
|
const is_empty_1 = require("@uxf/core/utils/is-empty");
|
|
11
11
|
const is_nil_1 = require("@uxf/core/utils/is-nil");
|
|
12
|
+
const is_not_empty_1 = require("@uxf/core/utils/is-not-empty");
|
|
12
13
|
const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
|
|
13
14
|
const format_css_value_1 = require("@uxf/styles/units/format-css-value");
|
|
14
15
|
const rem_1 = require("@uxf/styles/units/rem");
|
|
@@ -35,8 +36,8 @@ function DataGridTableV2(props) {
|
|
|
35
36
|
props.state.userConfig.columnsOrder.indexOf(b.name)
|
|
36
37
|
: 0);
|
|
37
38
|
const selectedRowColumnWidth = props.isRowsSelectable ? SELECT_ROWS_CELL_WIDTH : null;
|
|
38
|
-
const { tableRef, headerRef, bodyRef, columnRefs, onResizeStart, onAutoSize } = (0, use_resizable_columns_1.useResizableColumns)(visibleColumns, props.actionCell, props.actions, selectedRowColumnWidth);
|
|
39
|
-
const gridTemplateRows = (0, get_grid_template_rows_1.getGridTemplateRows)(props.data, (
|
|
39
|
+
const { tableRef, headerRef, bodyRef, columnRefs, onResizeStart, onAutoSize } = (0, use_resizable_columns_1.useResizableColumns)(visibleColumns, props.actionCell, props.actions, selectedRowColumnWidth, (_b = props.hasStickyHeader) !== null && _b !== void 0 ? _b : false);
|
|
40
|
+
const gridTemplateRows = (0, get_grid_template_rows_1.getGridTemplateRows)(props.data, (_c = props.rowHeight) !== null && _c !== void 0 ? _c : 44);
|
|
40
41
|
const gridTemplateBasicColumns = visibleColumns
|
|
41
42
|
.map((column) => {
|
|
42
43
|
var _a;
|
|
@@ -79,20 +80,20 @@ function DataGridTableV2(props) {
|
|
|
79
80
|
}),
|
|
80
81
|
react_1.default.createElement(show_1.Show, { when: (0, is_not_nil_1.isNotNil)(props.actionCell) },
|
|
81
82
|
react_1.default.createElement(components_1.Table.HeaderActionCell, null)))),
|
|
82
|
-
react_1.default.createElement(components_1.Table.Body, { gridTemplateColumns: gridTemplateColumns, gridTemplateRows: gridTemplateRows, ref: (0, compose_refs_1.composeRefs)(syncedScrollRef, bodyRef) }, (0,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
react_1.default.createElement(
|
|
86
|
-
react_1.default.createElement(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
83
|
+
react_1.default.createElement(components_1.Table.Body, { gridTemplateColumns: gridTemplateColumns, gridTemplateRows: gridTemplateRows, ref: (0, compose_refs_1.composeRefs)(syncedScrollRef, bodyRef) }, (0, is_not_empty_1.isNotEmpty)(props.data) &&
|
|
84
|
+
props.data.map((row) => {
|
|
85
|
+
var _a, _b;
|
|
86
|
+
return (react_1.default.createElement(components_1.Table.Row, { className: `${(0, is_not_nil_1.isNotNil)(props.rowAccent) ? "uxf-dg-table__row--" + props.rowAccent(row) : ""} ${(_b = (_a = props.rowClassName) === null || _a === void 0 ? void 0 : _a.call(props, row)) !== null && _b !== void 0 ? _b : ""}`, key: keyExtractor(row) },
|
|
87
|
+
react_1.default.createElement(show_1.Show, { when: Boolean(props.isRowsSelectable) },
|
|
88
|
+
react_1.default.createElement(select_row_checkbox_1.SelectRowCheckbox, { isRowSelectDisabled: props.isRowSelectDisabled ? props.isRowSelectDisabled(row) : false, isRowSelected: selectedRows.find((r) => keyExtractor(r) === keyExtractor(row)), onSelectRowChange: selectRowHandler(keyExtractor(row)) })),
|
|
89
|
+
visibleColumns.map((column) => {
|
|
90
|
+
var _a, _b, _c, _d;
|
|
91
|
+
const BodyCell = (_d = (_b = (_a = props.bodyCells) === null || _a === void 0 ? void 0 : _a[column.type]) !== null && _b !== void 0 ? _b : (_c = props.bodyCells) === null || _c === void 0 ? void 0 : _c.default) !== null && _d !== void 0 ? _d : DefaultBodyCell;
|
|
92
|
+
return (react_1.default.createElement(components_1.Table.Cell, { column: column, key: column.name },
|
|
93
|
+
react_1.default.createElement(BodyCell, { column: column, reload: props.reload, row: row, value: row[column.name] })));
|
|
94
|
+
}),
|
|
95
|
+
(0, is_not_nil_1.isNotNil)(props.actionCell) && (react_1.default.createElement(components_1.Table.ActionCellWrapper, null,
|
|
96
|
+
react_1.default.createElement(props.actionCell.Component, { reload: props.reload, row: row })))));
|
|
97
|
+
})),
|
|
98
|
+
(0, is_empty_1.isEmpty)(props.data) && react_1.default.createElement(NoRowsFallback, { error: props.error, isLoading: Boolean(props.isLoading) })));
|
|
98
99
|
}
|
package/table-v2/types.d.ts
CHANGED
|
@@ -9,7 +9,6 @@ export interface DataGridTableProps<GridType extends BaseGridType> extends DataG
|
|
|
9
9
|
error?: unknown | Nullish;
|
|
10
10
|
reload: () => Promise<any>;
|
|
11
11
|
rowHeight?: number | ((row: InferDataGridRow<Schema<GridType>>) => number) | "auto";
|
|
12
|
-
headerRowHeight?: number;
|
|
13
12
|
rowAccent?: (row: InferDataGridRow<Schema<GridType>>) => RowAccent;
|
|
14
13
|
rowClassName?: (row: InferDataGridRow<Schema<GridType>>) => string | Nullish;
|
|
15
14
|
keyExtractor?: KeyExtractor;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { BaseGridType } from "../../types";
|
|
2
2
|
import { DataGridTableProps } from "../types";
|
|
3
|
-
export declare function getGridTemplateRows<GridType extends BaseGridType>(rows: any[],
|
|
3
|
+
export declare function getGridTemplateRows<GridType extends BaseGridType>(rows: any[], rowHeight: DataGridTableProps<GridType>["rowHeight"]): string | undefined;
|
|
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getGridTemplateRows = getGridTemplateRows;
|
|
4
4
|
const is_nil_1 = require("@uxf/core/utils/is-nil");
|
|
5
5
|
const rem_1 = require("@uxf/styles/units/rem");
|
|
6
|
-
function getGridTemplateRows(rows,
|
|
6
|
+
function getGridTemplateRows(rows, rowHeight) {
|
|
7
7
|
if (rowHeight === "auto" || (0, is_nil_1.isNil)(rowHeight)) {
|
|
8
8
|
return undefined;
|
|
9
9
|
}
|
|
10
10
|
if (typeof rowHeight === "number") {
|
|
11
|
-
return
|
|
11
|
+
return `repeat(${rows.length}, ${(0, rem_1.rem)(rowHeight)})`;
|
|
12
12
|
}
|
|
13
|
-
return `${
|
|
13
|
+
return `${rows.map(rowHeight).join(" ")}`;
|
|
14
14
|
}
|
|
@@ -30,7 +30,6 @@ export type DataGridBaseProps<GridType extends BaseGridType> = {
|
|
|
30
30
|
getCsvDownloadUrl?: CsvDownloadGetUrl;
|
|
31
31
|
gridName?: string;
|
|
32
32
|
hasStickyHeader?: boolean;
|
|
33
|
-
headerRowHeight?: number;
|
|
34
33
|
isDebug?: boolean;
|
|
35
34
|
isHiddenColumnsSortable?: boolean;
|
|
36
35
|
isRowSelectDisabled?: (row: InferDataGridRow<Schema<GridType>>) => boolean;
|