@uxf/data-grid 11.23.0 → 11.24.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 +1 -1
- 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/types.d.ts +2 -5
- package/table-v2/table-v2.js +3 -1
- package/table-v2/types.d.ts +1 -1
- package/types/components.d.ts +4 -0
- package/types/schema.d.ts +1 -0
- package/use-data-grid-control/actions-factory.d.ts +1 -0
- package/use-data-grid-control/actions-factory.js +1 -0
- package/use-data-grid-control/use-data-grid-control.d.ts +1 -0
package/_store/reducer.js
CHANGED
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.0",
|
|
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/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<any>;
|
|
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/table-v2/types.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export interface TableProps<Row> extends DataGridControl {
|
|
|
18
18
|
bodyCells?: BodyCellComponents<any, any>;
|
|
19
19
|
actionCell?: {
|
|
20
20
|
width: number;
|
|
21
|
-
Component: ActionCellComponent<
|
|
21
|
+
Component: ActionCellComponent<Row>;
|
|
22
22
|
};
|
|
23
23
|
NoRowsFallback?: NoRowsFallbackComponent;
|
|
24
24
|
isRowSelectable?: boolean;
|
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;
|
package/types/schema.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export declare function createActions(dispatch: Dispatch<any>): {
|
|
|
6
6
|
changePerPage: (perPage: number) => void;
|
|
7
7
|
filter: (name: string, value: any, op?: string) => void;
|
|
8
8
|
filterClear: (name: string) => void;
|
|
9
|
+
filterClearAll: () => void;
|
|
9
10
|
sort: (columnName: string, direction?: string | null) => void;
|
|
10
11
|
sortClear: () => void;
|
|
11
12
|
search: (search: string) => void;
|
|
@@ -7,6 +7,7 @@ function createActions(dispatch) {
|
|
|
7
7
|
changePerPage: (perPage) => dispatch({ type: "CHANGE_PER_PAGE", perPage }),
|
|
8
8
|
filter: (name, value, op) => dispatch({ type: "FILTER", name, value, op }),
|
|
9
9
|
filterClear: (name) => dispatch({ type: "FILTER_CLEAR", name }),
|
|
10
|
+
filterClearAll: () => dispatch({ type: "FILTER_CLEAR_ALL" }),
|
|
10
11
|
sort: (columnName, direction = null) => dispatch({ type: "SORT", columnName, direction }),
|
|
11
12
|
sortClear: () => dispatch({ type: "SORT_CLEAR" }),
|
|
12
13
|
search: (search) => dispatch({ type: "FULLTEXT", search }),
|
|
@@ -15,6 +15,7 @@ export declare function useDataGridControl<T extends BaseGridType>(config: UseDa
|
|
|
15
15
|
changePerPage: (perPage: number) => void;
|
|
16
16
|
filter: (name: string, value: any, op?: string | undefined) => void;
|
|
17
17
|
filterClear: (name: string) => void;
|
|
18
|
+
filterClearAll: () => void;
|
|
18
19
|
sort: (columnName: string, direction?: string | null) => void;
|
|
19
20
|
sortClear: () => void;
|
|
20
21
|
search: (search: string) => void;
|