@uxf/data-grid 11.15.1 → 11.15.3
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 +22 -18
- package/{icons-config/index.js → icons-config.js} +16 -1
- package/package.json +2 -2
- package/table-v2/components/action-cell.d.ts +2 -0
- package/table-v2/components/action-cell.js +11 -0
- package/table-v2/components/body.d.ts +2 -0
- package/table-v2/components/body.js +11 -0
- package/table-v2/components/cell.d.ts +2 -0
- package/table-v2/components/cell.js +11 -0
- package/table-v2/components/header-action-cell.d.ts +2 -0
- package/table-v2/components/header-action-cell.js +11 -0
- package/table-v2/components/header-cell.d.ts +10 -0
- package/table-v2/components/header-cell.js +47 -0
- package/table-v2/components/header.d.ts +2 -0
- package/table-v2/components/header.js +11 -0
- package/table-v2/components/index.d.ts +16 -0
- package/table-v2/components/index.js +20 -0
- package/table-v2/components/root.d.ts +7 -0
- package/table-v2/components/root.js +31 -0
- package/table-v2/components/row.d.ts +2 -0
- package/table-v2/components/row.js +11 -0
- package/table-v2/styles.css +70 -18
- package/table-v2/table-v2.js +18 -15
- package/table-v2/table-v2.stories.js +1 -1
- package/use-data-grid-control/actions-factory.d.ts +1 -1
- package/use-data-grid-control/actions-factory.js +1 -1
- package/use-data-grid-control/use-data-grid-control.d.ts +1 -1
package/_store/reducer.js
CHANGED
|
@@ -28,7 +28,7 @@ function getInitialState(schema, init, initialUserConfig) {
|
|
|
28
28
|
exports.getInitialState = getInitialState;
|
|
29
29
|
// eslint-disable-next-line complexity
|
|
30
30
|
const reducer = (state, action) => {
|
|
31
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
31
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
32
32
|
switch (action.type) {
|
|
33
33
|
case "CHANGE_PAGE":
|
|
34
34
|
return {
|
|
@@ -86,16 +86,20 @@ const reducer = (state, action) => {
|
|
|
86
86
|
},
|
|
87
87
|
};
|
|
88
88
|
case "SORT":
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
dir: action.direction,
|
|
89
|
+
if (((_a = state.request.s) === null || _a === void 0 ? void 0 : _a.name) === action.columnName) {
|
|
90
|
+
return (0, deepmerge_1.default)(state, {
|
|
91
|
+
request: {
|
|
92
|
+
s: {
|
|
93
|
+
dir: ((_b = state.request.s) === null || _b === void 0 ? void 0 : _b.dir) === "asc" ? "desc" : "asc",
|
|
94
|
+
},
|
|
96
95
|
},
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
return (0, deepmerge_1.default)(state, {
|
|
99
|
+
request: {
|
|
100
|
+
s: { name: action.columnName, dir: (_c = action.direction) !== null && _c !== void 0 ? _c : "asc" },
|
|
97
101
|
},
|
|
98
|
-
};
|
|
102
|
+
});
|
|
99
103
|
case "SORT_CLEAR":
|
|
100
104
|
return {
|
|
101
105
|
...state,
|
|
@@ -115,24 +119,24 @@ const reducer = (state, action) => {
|
|
|
115
119
|
};
|
|
116
120
|
case "CHANGE_TAB":
|
|
117
121
|
// eslint-disable-next-line no-case-declarations,@typescript-eslint/no-unnecessary-condition
|
|
118
|
-
const tabHistory = (
|
|
122
|
+
const tabHistory = (_d = state.tabRequests[action.tab.name]) !== null && _d !== void 0 ? _d : {};
|
|
119
123
|
return {
|
|
120
124
|
...state,
|
|
121
125
|
request: {
|
|
122
126
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
123
|
-
f: (
|
|
124
|
-
s: (
|
|
127
|
+
f: (_e = tabHistory.f) !== null && _e !== void 0 ? _e : [],
|
|
128
|
+
s: (_g = (_f = tabHistory.s) !== null && _f !== void 0 ? _f : action.tab.s) !== null && _g !== void 0 ? _g : state.request.s,
|
|
125
129
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
126
|
-
search: (
|
|
130
|
+
search: (_h = tabHistory.search) !== null && _h !== void 0 ? _h : "",
|
|
127
131
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
128
|
-
page: (
|
|
132
|
+
page: (_j = tabHistory.page) !== null && _j !== void 0 ? _j : 0,
|
|
129
133
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
130
|
-
perPage: (
|
|
134
|
+
perPage: (_k = tabHistory.perPage) !== null && _k !== void 0 ? _k : state.request.perPage,
|
|
131
135
|
tab: action.tab.name,
|
|
132
136
|
},
|
|
133
137
|
tabRequests: {
|
|
134
138
|
...state.tabRequests,
|
|
135
|
-
[(
|
|
139
|
+
[(_l = state.request.tab) !== null && _l !== void 0 ? _l : "__DEFAULT_TAB__"]: state.request,
|
|
136
140
|
},
|
|
137
141
|
};
|
|
138
142
|
case "SET_SELECTED_ROWS":
|
|
@@ -148,7 +152,7 @@ const reducer = (state, action) => {
|
|
|
148
152
|
columns: {
|
|
149
153
|
...state.userConfig.columns,
|
|
150
154
|
[action.name]: {
|
|
151
|
-
...((
|
|
155
|
+
...((_o = (_m = state.userConfig.columns) === null || _m === void 0 ? void 0 : _m[action.name]) !== null && _o !== void 0 ? _o : {}),
|
|
152
156
|
isHidden: true,
|
|
153
157
|
},
|
|
154
158
|
},
|
|
@@ -162,7 +166,7 @@ const reducer = (state, action) => {
|
|
|
162
166
|
columns: {
|
|
163
167
|
...state.userConfig.columns,
|
|
164
168
|
[action.name]: {
|
|
165
|
-
...((
|
|
169
|
+
...((_q = (_p = state.userConfig.columns) === null || _p === void 0 ? void 0 : _p[action.name]) !== null && _q !== void 0 ? _q : {}),
|
|
166
170
|
isHidden: false,
|
|
167
171
|
},
|
|
168
172
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const uiIcons = require("@uxf/ui/
|
|
1
|
+
const uiIcons = require("@uxf/ui/icons-config");
|
|
2
2
|
|
|
3
3
|
/** @type {import('@uxf/icons-generator/types').Config['icons']} */
|
|
4
4
|
module.exports = {
|
|
@@ -56,6 +56,21 @@ module.exports = {
|
|
|
56
56
|
height: 512,
|
|
57
57
|
data: `<path d="M424 80C437.3 80 448 90.75 448 104C448 117.3 437.3 128 424 128H412.4L388.4 452.7C385.9 486.1 358.1 512 324.6 512H123.4C89.92 512 62.09 486.1 59.61 452.7L35.56 128H24C10.75 128 0 117.3 0 104C0 90.75 10.75 80 24 80H93.82L130.5 24.94C140.9 9.357 158.4 0 177.1 0H270.9C289.6 0 307.1 9.358 317.5 24.94L354.2 80H424zM177.1 48C174.5 48 171.1 49.34 170.5 51.56L151.5 80H296.5L277.5 51.56C276 49.34 273.5 48 270.9 48H177.1zM364.3 128H83.69L107.5 449.2C108.1 457.5 115.1 464 123.4 464H324.6C332.9 464 339.9 457.5 340.5 449.2L364.3 128z" fill="currentColor"/>`,
|
|
58
58
|
},
|
|
59
|
+
sort: {
|
|
60
|
+
width: 320,
|
|
61
|
+
height: 512,
|
|
62
|
+
data: `<path d="M70.6 176H249.4L160 86.6 70.6 176zm112-134.6l128 128c9.2 9.2 11.9 22.9 6.9 34.9s-16.6 19.8-29.6 19.8H32c-12.9 0-24.6-7.8-29.6-19.8s-2.2-25.7 6.9-34.9l128-128c12.5-12.5 32.8-12.5 45.3 0zM70.6 336L160 425.4 249.4 336H70.6zm112 134.6c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-9.2-9.2-11.9-22.9-6.9-34.9s16.6-19.8 29.6-19.8H288c12.9 0 24.6 7.8 29.6 19.8s2.2 25.7-6.9 34.9l-128 128z" fill="currentColor"/>`,
|
|
63
|
+
},
|
|
64
|
+
"sort-up": {
|
|
65
|
+
width: 320,
|
|
66
|
+
height: 512,
|
|
67
|
+
data: `<path d="M160 86.6L70.6 176H249.4L160 86.6zM137.4 41.4c12.5-12.5 32.8-12.5 45.3 0l128 128c9.2 9.2 11.9 22.9 6.9 34.9s-16.6 19.8-29.6 19.8H32c-12.9 0-24.6-7.8-29.6-19.8s-2.2-25.7 6.9-34.9l128-128z" fill="currentColor"/>`,
|
|
68
|
+
},
|
|
69
|
+
"sort-down": {
|
|
70
|
+
width: 320,
|
|
71
|
+
height: 512,
|
|
72
|
+
data: `<path d="M160 425.4L70.6 336H249.4L160 425.4zm-22.6 45.3c12.5 12.5 32.8 12.5 45.3 0l128-128c9.2-9.2 11.9-22.9 6.9-34.9s-16.6-19.8-29.6-19.8H32c-12.9 0-24.6 7.8-29.6 19.8s-2.2 25.7 6.9 34.9l128 128z" fill="currentColor"/>`,
|
|
73
|
+
},
|
|
59
74
|
warning: {
|
|
60
75
|
width: 512,
|
|
61
76
|
height: 512,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uxf/data-grid",
|
|
3
|
-
"version": "11.15.
|
|
3
|
+
"version": "11.15.3",
|
|
4
4
|
"description": "UXF DataGrid",
|
|
5
5
|
"homepage": "https://gitlab.com/uxf-npm/data-grid#readme",
|
|
6
6
|
"main": "index.js",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@uxf/core": "11.11.3",
|
|
35
|
-
"@uxf/ui": "11.15.
|
|
35
|
+
"@uxf/ui": "11.15.3",
|
|
36
36
|
"dayjs": "1.11.10",
|
|
37
37
|
"deepmerge": "4.3.1",
|
|
38
38
|
"fast-glob": "3.3.2",
|
|
@@ -0,0 +1,11 @@
|
|
|
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.ActionCell = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
function ActionCell(props) {
|
|
9
|
+
return react_1.default.createElement("div", { className: "uxf-dg-table__action-cell" }, props.children);
|
|
10
|
+
}
|
|
11
|
+
exports.ActionCell = ActionCell;
|
|
@@ -0,0 +1,11 @@
|
|
|
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.Body = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
function Body(props) {
|
|
9
|
+
return react_1.default.createElement("div", { className: "uxf-dg-table__body" }, props.children);
|
|
10
|
+
}
|
|
11
|
+
exports.Body = Body;
|
|
@@ -0,0 +1,11 @@
|
|
|
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.Cell = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
function Cell(props) {
|
|
9
|
+
return react_1.default.createElement("div", { className: "uxf-dg-table__cell" }, props.children);
|
|
10
|
+
}
|
|
11
|
+
exports.Cell = Cell;
|
|
@@ -0,0 +1,11 @@
|
|
|
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.HeaderActionCell = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
function HeaderActionCell() {
|
|
9
|
+
return react_1.default.createElement("div", { className: "uxf-dg-table__action-cell uxf-dg-table__action-cell--header" });
|
|
10
|
+
}
|
|
11
|
+
exports.HeaderActionCell = HeaderActionCell;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Nullish } from "@uxf/core/types";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { Column, DataGridSort } from "../../types";
|
|
4
|
+
export interface HeaderCellProps {
|
|
5
|
+
column: Column<any, any>;
|
|
6
|
+
onResizeStart: () => void;
|
|
7
|
+
sort: DataGridSort | Nullish;
|
|
8
|
+
onClick?: () => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const HeaderCell: React.ForwardRefExoticComponent<HeaderCellProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,47 @@
|
|
|
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.HeaderCell = void 0;
|
|
27
|
+
const cx_1 = require("@uxf/core/utils/cx");
|
|
28
|
+
const icon_1 = require("@uxf/ui/icon");
|
|
29
|
+
const react_1 = __importStar(require("react"));
|
|
30
|
+
function HeaderCellComponent(props, ref) {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
const iconName = !props.column.sort
|
|
33
|
+
? null
|
|
34
|
+
: ((_a = props.sort) === null || _a === void 0 ? void 0 : _a.dir) === "asc"
|
|
35
|
+
? "sort-up"
|
|
36
|
+
: ((_b = props.sort) === null || _b === void 0 ? void 0 : _b.dir) === "desc"
|
|
37
|
+
? "sort-down"
|
|
38
|
+
: "sort";
|
|
39
|
+
return (
|
|
40
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
|
|
41
|
+
react_1.default.createElement("div", { ref: ref, className: (0, cx_1.cx)("uxf-dg-table__cell uxf-dg-table__cell--header", props.column.sort && "is-sortable"), onClick: props.onClick },
|
|
42
|
+
props.column.label,
|
|
43
|
+
iconName && react_1.default.createElement(icon_1.Icon, { name: iconName, className: "ml-auto" }),
|
|
44
|
+
react_1.default.createElement("button", { className: "uxf-dg-table__column-resize-handle", onMouseDown: props.onResizeStart, onClick: (event) => event.stopPropagation() })));
|
|
45
|
+
}
|
|
46
|
+
exports.HeaderCell = (0, react_1.forwardRef)(HeaderCellComponent);
|
|
47
|
+
exports.HeaderCell.displayName = "HeaderCell";
|
|
@@ -0,0 +1,11 @@
|
|
|
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.Header = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
function Header(props) {
|
|
9
|
+
return react_1.default.createElement("div", { className: "uxf-dg-table__header" }, props.children);
|
|
10
|
+
}
|
|
11
|
+
exports.Header = Header;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ActionCell } from "./action-cell";
|
|
3
|
+
import { Body } from "./body";
|
|
4
|
+
import { Cell } from "./cell";
|
|
5
|
+
import { Header } from "./header";
|
|
6
|
+
import { HeaderActionCell } from "./header-action-cell";
|
|
7
|
+
import { Row } from "./row";
|
|
8
|
+
export declare const Table: import("react").ForwardRefExoticComponent<import("./root").RootProps & import("react").RefAttributes<HTMLDivElement>> & {
|
|
9
|
+
Body: typeof Body;
|
|
10
|
+
Row: typeof Row;
|
|
11
|
+
HeaderCell: import("react").ForwardRefExoticComponent<import("./header-cell").HeaderCellProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
12
|
+
Cell: typeof Cell;
|
|
13
|
+
ActionCell: typeof ActionCell;
|
|
14
|
+
HeaderActionCell: typeof HeaderActionCell;
|
|
15
|
+
Header: typeof Header;
|
|
16
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Table = void 0;
|
|
4
|
+
const action_cell_1 = require("./action-cell");
|
|
5
|
+
const body_1 = require("./body");
|
|
6
|
+
const cell_1 = require("./cell");
|
|
7
|
+
const header_1 = require("./header");
|
|
8
|
+
const header_action_cell_1 = require("./header-action-cell");
|
|
9
|
+
const header_cell_1 = require("./header-cell");
|
|
10
|
+
const root_1 = require("./root");
|
|
11
|
+
const row_1 = require("./row");
|
|
12
|
+
exports.Table = Object.assign(root_1.Root, {
|
|
13
|
+
Body: body_1.Body,
|
|
14
|
+
Row: row_1.Row,
|
|
15
|
+
HeaderCell: header_cell_1.HeaderCell,
|
|
16
|
+
Cell: cell_1.Cell,
|
|
17
|
+
ActionCell: action_cell_1.ActionCell,
|
|
18
|
+
HeaderActionCell: header_action_cell_1.HeaderActionCell,
|
|
19
|
+
Header: header_1.Header,
|
|
20
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
export interface RootProps {
|
|
3
|
+
gridTemplateColumns: string;
|
|
4
|
+
gridTemplateRows?: string;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare const Root: React.ForwardRefExoticComponent<RootProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,31 @@
|
|
|
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.Root = void 0;
|
|
27
|
+
const react_1 = __importStar(require("react"));
|
|
28
|
+
function RootComponent(props, ref) {
|
|
29
|
+
return (react_1.default.createElement("div", { className: "uxf-dg-table", ref: ref, style: { gridTemplateColumns: props.gridTemplateColumns, gridTemplateRows: props.gridTemplateRows } }, props.children));
|
|
30
|
+
}
|
|
31
|
+
exports.Root = (0, react_1.forwardRef)(RootComponent);
|
|
@@ -0,0 +1,11 @@
|
|
|
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.Row = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
function Row(props) {
|
|
9
|
+
return react_1.default.createElement("div", { className: "uxf-dg-table__row" }, props.children);
|
|
10
|
+
}
|
|
11
|
+
exports.Row = Row;
|
package/table-v2/styles.css
CHANGED
|
@@ -1,40 +1,92 @@
|
|
|
1
|
-
|
|
1
|
+
:root {
|
|
2
|
+
--uxf-dg-table-font-size: theme("fontSize.sm");
|
|
3
|
+
--uxf-dg-table-cell-padding: theme("spacing.2");
|
|
4
|
+
--uxf-dg-table-action-cell-bg-color: theme("colors.white");
|
|
5
|
+
--uxf-dg-table-action-cell-left-divider-color: theme("colors.lightBorder");
|
|
6
|
+
--uxf-dg-table-action-cell-left-divider-size: 1px;
|
|
7
|
+
--uxf-dg-table-row-divider-size: 1px;
|
|
8
|
+
--uxf-dg-table-row-divider-color: theme("colors.lightBorder");
|
|
9
|
+
--uxf-dg-table-row-bg-color-odd: theme("colors.white");
|
|
10
|
+
--uxf-dg-table-row-bg-color-even: theme("colors.white");
|
|
11
|
+
--uxf-dg-table-header-action-cell-bg-color: theme("colors.neutral.50");
|
|
12
|
+
--uxf-dg-table-header-bg-color: theme("colors.neutral.50");
|
|
13
|
+
--uxf-dg-table-header-color: theme("colors.neutral.400");
|
|
14
|
+
--uxf-dg-table-header-divider-size: var(--uxf-dg-table-row-divider-size);
|
|
15
|
+
--uxf-dg-table-header-divider-color: var(--uxf-dg-table-row-divider-color);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.uxf-dg-table {
|
|
2
19
|
display: grid;
|
|
3
|
-
font-size:
|
|
20
|
+
font-size: var(--uxf-dg-table-font-size);
|
|
4
21
|
overflow-x: auto;
|
|
5
22
|
width: 100%;
|
|
6
23
|
|
|
7
|
-
|
|
24
|
+
&__row {
|
|
25
|
+
display: contents;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&__header {
|
|
8
29
|
display: contents;
|
|
9
30
|
}
|
|
10
31
|
|
|
11
|
-
|
|
32
|
+
&__body {
|
|
33
|
+
display: contents;
|
|
34
|
+
|
|
35
|
+
.uxf-dg-table__row {
|
|
36
|
+
&:nth-child(odd) {
|
|
37
|
+
.uxf-dg-table__cell,
|
|
38
|
+
.uxf-dg-table__action-cell {
|
|
39
|
+
background-color: var(--uxf-dg-table-row-bg-color-odd);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&:nth-child(even) {
|
|
44
|
+
.uxf-dg-table__cell,
|
|
45
|
+
.uxf-dg-table__action-cell {
|
|
46
|
+
background-color: var(--uxf-dg-table-row-bg-color-even);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
&__cell {
|
|
12
53
|
align-items: center;
|
|
13
|
-
border-top:
|
|
54
|
+
border-top: var(--uxf-dg-table-row-divider-size) solid var(--uxf-dg-table-row-divider-color);
|
|
14
55
|
display: flex;
|
|
15
|
-
padding:
|
|
16
|
-
|
|
56
|
+
padding: var(--uxf-dg-table-cell-padding);
|
|
57
|
+
|
|
58
|
+
&--header {
|
|
59
|
+
background-color: var(--uxf-dg-table-header-bg-color);
|
|
60
|
+
color: var(--uxf-dg-table-header-color);
|
|
61
|
+
position: relative;
|
|
62
|
+
user-select: none;
|
|
17
63
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
64
|
+
&.is-sortable {
|
|
65
|
+
cursor: pointer;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.uxf-icon {
|
|
69
|
+
margin-left: auto;
|
|
70
|
+
width: 12px;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
23
73
|
}
|
|
24
74
|
|
|
25
|
-
|
|
26
|
-
background-color:
|
|
27
|
-
border-left:
|
|
75
|
+
&__action-cell {
|
|
76
|
+
background-color: var(--uxf-dg-table-action-cell-bg-color);
|
|
77
|
+
border-left: var(--uxf-dg-table-action-cell-left-divider-size) solid
|
|
78
|
+
var(--uxf-dg-table-action-cell-left-divider-color);
|
|
79
|
+
border-top: var(--uxf-dg-table-row-divider-size) solid var(--uxf-dg-table-row-divider-color);
|
|
28
80
|
position: sticky;
|
|
29
81
|
right: 0;
|
|
30
82
|
|
|
31
|
-
|
|
32
|
-
background-color:
|
|
83
|
+
&--header {
|
|
84
|
+
background-color: var(--uxf-dg-table-header-action-cell-bg-color);
|
|
33
85
|
z-index: 2;
|
|
34
86
|
}
|
|
35
87
|
}
|
|
36
88
|
|
|
37
|
-
|
|
89
|
+
&__column-resize-handle {
|
|
38
90
|
bottom: 0;
|
|
39
91
|
cursor: col-resize;
|
|
40
92
|
position: absolute;
|
package/table-v2/table-v2.js
CHANGED
|
@@ -4,13 +4,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.TableV2 = void 0;
|
|
7
|
+
const show_1 = require("@uxf/core/components/show");
|
|
7
8
|
const is_nil_1 = require("@uxf/core/utils/is-nil");
|
|
8
9
|
const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
|
|
9
10
|
const rem_1 = require("@uxf/styles/units/rem");
|
|
10
11
|
const react_1 = __importDefault(require("react"));
|
|
12
|
+
const components_1 = require("./components");
|
|
11
13
|
const use_resizable_columns_1 = require("./hooks/use-resizable-columns");
|
|
12
14
|
const get_grid_template_rows_1 = require("./utils/get-grid-template-rows");
|
|
13
15
|
const defaultKeyExtractor = (r) => r.id;
|
|
16
|
+
const DefaultBodyCell = () => null;
|
|
14
17
|
function TableV2(props) {
|
|
15
18
|
var _a, _b, _c, _d;
|
|
16
19
|
const keyExtractor = (_a = props.keyExtractor) !== null && _a !== void 0 ? _a : defaultKeyExtractor;
|
|
@@ -24,23 +27,23 @@ function TableV2(props) {
|
|
|
24
27
|
const gridTemplateColumns = (0, is_nil_1.isNil)((_d = props.actionCell) === null || _d === void 0 ? void 0 : _d.width)
|
|
25
28
|
? gridTemplateColumnsWithoutAction
|
|
26
29
|
: `${gridTemplateColumnsWithoutAction} ${(0, rem_1.rem)(props.actionCell.width)}`;
|
|
27
|
-
return (react_1.default.createElement(
|
|
28
|
-
react_1.default.createElement(
|
|
29
|
-
|
|
30
|
-
column
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
return (react_1.default.createElement(components_1.Table, { ref: tableRef, gridTemplateColumns: gridTemplateColumns, gridTemplateRows: gridTemplateRows },
|
|
31
|
+
react_1.default.createElement(components_1.Table.Header, null,
|
|
32
|
+
react_1.default.createElement(components_1.Table.Row, null,
|
|
33
|
+
visibleColumns.map((column, index) => {
|
|
34
|
+
var _a;
|
|
35
|
+
return (react_1.default.createElement(components_1.Table.HeaderCell, { key: column.name, ref: (el) => (columnRefs.current[index] = el), column: column, onResizeStart: () => onResizeStart(index), sort: ((_a = props.state.request.s) === null || _a === void 0 ? void 0 : _a.name) === column.name ? props.state.request.s : null, onClick: column.sort ? () => props.actions.sort(column.name) : undefined }));
|
|
36
|
+
}),
|
|
37
|
+
react_1.default.createElement(show_1.Show, { when: (0, is_not_nil_1.isNotNil)(props.actionCell) },
|
|
38
|
+
react_1.default.createElement(components_1.Table.HeaderActionCell, null)))),
|
|
39
|
+
react_1.default.createElement(components_1.Table.Body, null, props.data.map((row) => (react_1.default.createElement(components_1.Table.Row, { key: keyExtractor(row) },
|
|
34
40
|
visibleColumns.map((column) => {
|
|
35
|
-
var _a, _b, _c;
|
|
36
|
-
const BodyCell = (_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;
|
|
37
|
-
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
return (react_1.default.createElement("div", { className: "uxf-data-grid__cell", key: column.name },
|
|
41
|
+
var _a, _b, _c, _d;
|
|
42
|
+
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;
|
|
43
|
+
return (react_1.default.createElement(components_1.Table.Cell, { key: column.name },
|
|
41
44
|
react_1.default.createElement(BodyCell, { column: column, row: row, value: row[column.name], reload: () => { var _a; return (_a = props.onReload) === null || _a === void 0 ? void 0 : _a.call(props); } })));
|
|
42
45
|
}),
|
|
43
|
-
(0, is_not_nil_1.isNotNil)(props.actionCell) && (react_1.default.createElement(
|
|
44
|
-
react_1.default.createElement(props.actionCell.Component, { row: row, reload: () => { var _a; return (_a = props.onReload) === null || _a === void 0 ? void 0 : _a.call(props); } }))))))));
|
|
46
|
+
(0, is_not_nil_1.isNotNil)(props.actionCell) && (react_1.default.createElement(components_1.Table.ActionCell, null,
|
|
47
|
+
react_1.default.createElement(props.actionCell.Component, { row: row, reload: () => { var _a; return (_a = props.onReload) === null || _a === void 0 ? void 0 : _a.call(props); } })))))))));
|
|
45
48
|
}
|
|
46
49
|
exports.TableV2 = TableV2;
|
|
@@ -13,7 +13,7 @@ const hidden_columns_button_1 = require("../hidden-columns-button");
|
|
|
13
13
|
const use_data_grid_control_1 = require("../use-data-grid-control");
|
|
14
14
|
const table_v2_1 = require("./table-v2");
|
|
15
15
|
function Default() {
|
|
16
|
-
const { state, actions } = (0, use_data_grid_control_1.useDataGridControl)({ schema: schema_1.schema });
|
|
16
|
+
const { state, actions } = (0, use_data_grid_control_1.useDataGridControl)({ schema: schema_1.schema, isDebug: true });
|
|
17
17
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
18
18
|
react_1.default.createElement(hidden_columns_button_1.HiddenColumnsButton, { schema: schema_1.schema, state: state, actions: actions }),
|
|
19
19
|
react_1.default.createElement(table_v2_1.TableV2, { state: state, actions: actions, data: data_1.data, isLoading: true, error: undefined, schema: schema_1.schema, bodyCells: body_cell_1.BodyCells, isRowSelectable: true, actionCell: { width: 150, Component: () => react_1.default.createElement("div", null, "ActionCell") } }),
|
|
@@ -6,7 +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
|
-
sort: (columnName: string, direction
|
|
9
|
+
sort: (columnName: string, direction?: string | null) => void;
|
|
10
10
|
sortClear: () => void;
|
|
11
11
|
search: (search: string) => void;
|
|
12
12
|
changeTab: (tab: Tab) => void;
|
|
@@ -7,7 +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
|
-
sort: (columnName, direction) => dispatch({ type: "SORT", columnName, direction }),
|
|
10
|
+
sort: (columnName, direction = null) => dispatch({ type: "SORT", columnName, direction }),
|
|
11
11
|
sortClear: () => dispatch({ type: "SORT_CLEAR" }),
|
|
12
12
|
search: (search) => dispatch({ type: "FULLTEXT", search }),
|
|
13
13
|
changeTab: (tab) => dispatch({ type: "CHANGE_TAB", tab }),
|
|
@@ -15,7 +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
|
-
sort: (columnName: string, direction
|
|
18
|
+
sort: (columnName: string, direction?: string | null) => void;
|
|
19
19
|
sortClear: () => void;
|
|
20
20
|
search: (search: string) => void;
|
|
21
21
|
changeTab: (tab: import("../types/schema").Tab) => void;
|