@uxf/data-grid 11.23.2 → 11.24.1
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/grid-type.d.ts +1 -0
- package/_story-utils/schema.js +1 -0
- package/data-grid.stories.js +24 -23
- package/hidden-columns/hidden-columns.js +3 -1
- package/package.json +2 -2
- package/table/hooks/use-react-data-grid-columns.js +3 -0
- package/table/table.js +3 -2
- package/table/types.d.ts +2 -5
- package/table-v2/table-v2.js +3 -1
- package/types/components.d.ts +4 -0
- package/types/schema.d.ts +1 -0
package/_story-utils/schema.js
CHANGED
|
@@ -11,6 +11,7 @@ exports.schema = {
|
|
|
11
11
|
{ name: "link", type: "url", label: "Link" },
|
|
12
12
|
{ name: "day", type: "date", label: "Date" },
|
|
13
13
|
{ name: "dayAndTime", type: "datetime", label: "Datetime" },
|
|
14
|
+
{ name: "hidden", type: "hidden", label: "Hidden", hidden: true },
|
|
14
15
|
],
|
|
15
16
|
filters: [
|
|
16
17
|
{ name: "text", type: "text", label: "Text" },
|
package/data-grid.stories.js
CHANGED
|
@@ -34,6 +34,29 @@ const data_grid_1 = require("./data-grid");
|
|
|
34
34
|
const table_1 = require("./table");
|
|
35
35
|
const use_data_grid_control_1 = require("./use-data-grid-control");
|
|
36
36
|
const use_data_grid_fetching_1 = require("./use-data-grid-fetching");
|
|
37
|
+
const actionCell = {
|
|
38
|
+
width: 100,
|
|
39
|
+
Component: () => {
|
|
40
|
+
const actionCellActions = (0, buildArray_1.buildArray)()
|
|
41
|
+
.add({
|
|
42
|
+
icon: "arrow-right",
|
|
43
|
+
isIconButton: true,
|
|
44
|
+
href: "https://www.uxf.cz",
|
|
45
|
+
target: "_blank",
|
|
46
|
+
})
|
|
47
|
+
.add({
|
|
48
|
+
icon: "file",
|
|
49
|
+
label: "Download",
|
|
50
|
+
onClick: console.log,
|
|
51
|
+
})
|
|
52
|
+
.add({
|
|
53
|
+
icon: "cloud",
|
|
54
|
+
label: "Reload",
|
|
55
|
+
onClick: console.log,
|
|
56
|
+
});
|
|
57
|
+
return react_1.default.createElement(table_1.ActionCell, { buttons: actionCellActions, visibleButtonsCount: 1 });
|
|
58
|
+
},
|
|
59
|
+
};
|
|
37
60
|
function Default() {
|
|
38
61
|
const [noBorder, setNoBorder] = (0, react_1.useState)(false);
|
|
39
62
|
const { state, actions } = (0, use_data_grid_control_1.useDataGridControl)({
|
|
@@ -54,29 +77,7 @@ function Default() {
|
|
|
54
77
|
});
|
|
55
78
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
56
79
|
react_1.default.createElement(toggle_1.Toggle, { label: "No border", value: noBorder, onChange: (value) => setNoBorder(!!value), name: "noBorder" }),
|
|
57
|
-
react_1.default.createElement(data_grid_1.DataGrid, { onReload: onReload, state: state, actions: actions, data: data, isLoading: isLoading, error: error, schema: schema_1.schema, onCsvDownload: console.log,
|
|
58
|
-
width: 100,
|
|
59
|
-
Component: () => {
|
|
60
|
-
const actionCellActions = (0, buildArray_1.buildArray)()
|
|
61
|
-
.add({
|
|
62
|
-
icon: "arrow-right",
|
|
63
|
-
isIconButton: true,
|
|
64
|
-
href: "https://www.uxf.cz",
|
|
65
|
-
target: "_blank",
|
|
66
|
-
})
|
|
67
|
-
.add({
|
|
68
|
-
icon: "file",
|
|
69
|
-
label: "Download",
|
|
70
|
-
onClick: console.log,
|
|
71
|
-
})
|
|
72
|
-
.add({
|
|
73
|
-
icon: "cloud",
|
|
74
|
-
label: "Reload",
|
|
75
|
-
onClick: console.log,
|
|
76
|
-
});
|
|
77
|
-
return react_1.default.createElement(table_1.ActionCell, { buttons: actionCellActions, visibleButtonsCount: 1 });
|
|
78
|
-
},
|
|
79
|
-
} }),
|
|
80
|
+
react_1.default.createElement(data_grid_1.DataGrid, { onReload: onReload, state: state, actions: actions, data: data, isLoading: isLoading, error: error, schema: schema_1.schema, onCsvDownload: console.log, isRowSelectable: true, actionCell: actionCell }),
|
|
80
81
|
react_1.default.createElement(json_renderer_1.JsonRenderer, { value: state })));
|
|
81
82
|
}
|
|
82
83
|
exports.Default = Default;
|
|
@@ -8,7 +8,9 @@ const toggle_1 = require("@uxf/ui/toggle");
|
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
9
|
/** @deprecated Use DataGridHiddenColumns */
|
|
10
10
|
function HiddenColumns(props) {
|
|
11
|
-
return (react_1.default.createElement("div", { className: "uxf-data-grid__toolbar-control-columns" }, props.schema.columns
|
|
11
|
+
return (react_1.default.createElement("div", { className: "uxf-data-grid__toolbar-control-columns" }, props.schema.columns
|
|
12
|
+
.filter((column) => !column.hidden)
|
|
13
|
+
.map((column) => {
|
|
12
14
|
var _a, _b, _c, _d;
|
|
13
15
|
return (react_1.default.createElement(toggle_1.Toggle, { key: column.name, label: typeof column.label === "string" ? column.label : "", value: !((_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), onChange: (value) => value ? props.actions.showColumn(column.name) : props.actions.hideColumn(column.name), name: column.name }));
|
|
14
16
|
})));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uxf/data-grid",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.24.1",
|
|
4
4
|
"description": "UXF DataGrid",
|
|
5
5
|
"homepage": "https://gitlab.com/uxf-npm/data-grid#readme",
|
|
6
6
|
"main": "index.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@uxf/core": "11.22.0",
|
|
35
35
|
"@uxf/core-react": "11.22.0",
|
|
36
|
-
"@uxf/ui": "11.
|
|
36
|
+
"@uxf/ui": "11.24.0",
|
|
37
37
|
"dayjs": "1.11.10",
|
|
38
38
|
"deepmerge": "4.3.1",
|
|
39
39
|
"fast-glob": "3.3.2",
|
|
@@ -37,6 +37,9 @@ function useReactDataGridColumns(props, state) {
|
|
|
37
37
|
columns.push(react_data_grid_1.SelectColumn);
|
|
38
38
|
}
|
|
39
39
|
for (const schemaColumn of schema.columns) {
|
|
40
|
+
if (schemaColumn.hidden) {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
40
43
|
const isHidden = (_b = (_a = userConfigColumns === null || userConfigColumns === void 0 ? void 0 : userConfigColumns[schemaColumn.name]) === null || _a === void 0 ? void 0 : _a.isHidden) !== null && _b !== void 0 ? _b : (_c = schemaColumn.config) === null || _c === void 0 ? void 0 : _c.isHidden;
|
|
41
44
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
42
45
|
if (isHidden) {
|
package/table/table.js
CHANGED
|
@@ -34,8 +34,9 @@ const react_data_grid_1 = __importDefault(require("react-data-grid"));
|
|
|
34
34
|
const select_row_checkbox_1 = require("./components/select-row-checkbox");
|
|
35
35
|
const use_rdg_visuals_1 = require("./hooks/use-rdg-visuals");
|
|
36
36
|
const use_react_data_grid_columns_1 = require("./hooks/use-react-data-grid-columns");
|
|
37
|
+
const no_rows_fallback_1 = require("./no-rows-fallback");
|
|
37
38
|
const defaultKeyExtractor = (r) => r.id;
|
|
38
|
-
const DefaultNoRowsFallback =
|
|
39
|
+
const DefaultNoRowsFallback = no_rows_fallback_1.NoRowsFallback;
|
|
39
40
|
/** @deprecated will be remove, use DataGridTableV2 */
|
|
40
41
|
function Table(props) {
|
|
41
42
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
@@ -84,7 +85,7 @@ function Table(props) {
|
|
|
84
85
|
rows: props.data,
|
|
85
86
|
});
|
|
86
87
|
return (react_1.default.createElement(show_1.Show, { when: isMounted },
|
|
87
|
-
react_1.default.createElement(react_data_grid_1.default, {
|
|
88
|
+
react_1.default.createElement(react_data_grid_1.default, { className: rdgVisuals.className, columns: columns, enableVirtualization: false, headerRowHeight: rdgVisuals.headerRowHeight, onSelectedRowsChange: onSelectRows, onSortColumnsChange: onSortColumnChange, ref: rdgVisuals.ref, renderers: components, rowClass: props.rowClass, rowHeight: rdgVisuals.rowHeight, rowKeyGetter: (_e = props.keyExtractor) !== null && _e !== void 0 ? _e : defaultKeyExtractor, rows: props.data, selectedRows: new Set((_g = (_f = props.state.selectedRows) === null || _f === void 0 ? void 0 : _f.map(keyExtractor)) !== null && _g !== void 0 ? _g : []), sortColumns: sortColumns, style: reactDataGridStyles })));
|
|
88
89
|
}
|
|
89
90
|
exports.Table = Table;
|
|
90
91
|
/** @deprecated will be remove, use DataGridTableV2 */
|
package/table/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Nullish } from "@uxf/core/types";
|
|
2
|
-
import {
|
|
2
|
+
import { BodyCellComponents, DataGridActionCell } from "../types/components";
|
|
3
3
|
import { KeyExtractor } from "../types/core";
|
|
4
4
|
import { Schema } from "../types/schema";
|
|
5
5
|
import { DataGridControl } from "../use-data-grid-control";
|
|
@@ -16,10 +16,7 @@ export interface TableProps<Row> extends DataGridControl {
|
|
|
16
16
|
rowClass?: (row: Row) => "success" | "warning" | "error" | "primary" | "secondary" | string | null | undefined;
|
|
17
17
|
keyExtractor?: KeyExtractor;
|
|
18
18
|
bodyCells?: BodyCellComponents<any, any>;
|
|
19
|
-
actionCell?:
|
|
20
|
-
width: number;
|
|
21
|
-
Component: ActionCellComponent<Row>;
|
|
22
|
-
};
|
|
19
|
+
actionCell?: DataGridActionCell<Row>;
|
|
23
20
|
NoRowsFallback?: NoRowsFallbackComponent;
|
|
24
21
|
isRowSelectable?: boolean;
|
|
25
22
|
}
|
package/table-v2/table-v2.js
CHANGED
|
@@ -18,7 +18,9 @@ const DefaultBodyCell = () => "Unknown body cell.";
|
|
|
18
18
|
function TableV2(props) {
|
|
19
19
|
var _a, _b, _c, _d;
|
|
20
20
|
const keyExtractor = (_a = props.keyExtractor) !== null && _a !== void 0 ? _a : defaultKeyExtractor;
|
|
21
|
-
const visibleColumns = props.schema.columns
|
|
21
|
+
const visibleColumns = props.schema.columns
|
|
22
|
+
.filter((column) => !column.hidden)
|
|
23
|
+
.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); });
|
|
22
24
|
const { tableRef, columnRefs, onResizeStart } = (0, use_resizable_columns_1.useResizableColumns)(visibleColumns, props.actionCell, props.actions);
|
|
23
25
|
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);
|
|
24
26
|
const gridTemplateColumnsWithoutAction = visibleColumns
|
package/types/components.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { ComponentType, FC } from "react";
|
|
2
2
|
import { BaseGridType, Columns, Filter } from "./schema";
|
|
3
|
+
export type DataGridActionCell<Row> = {
|
|
4
|
+
width: number;
|
|
5
|
+
Component: ActionCellComponent<Row>;
|
|
6
|
+
};
|
|
3
7
|
export interface ActionCellProps<R> {
|
|
4
8
|
row: R;
|
|
5
9
|
reload: () => void;
|