@uxf/data-grid 10.0.0-beta.7 → 10.0.0-beta.71
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/data-grid.js +13 -21
- package/data-grid.stories.js +9 -2
- package/hooks/use-rdg-visuals.d.ts +18 -0
- package/hooks/use-rdg-visuals.js +47 -0
- package/hooks/useColumns.js +2 -2
- package/package.json +3 -2
- package/store/actions.d.ts +3 -3
- package/tailwindui/components/action-cell-base.js +4 -2
- package/tailwindui/components/drawer.js +15 -8
- package/tailwindui/components/select-row-checkbox.js +4 -5
- package/tailwindui/components/toolbar-control.js +24 -6
- package/tailwindui/filter-handler/boolean-filter.js +1 -1
- package/tailwindui/filter-handler/index.js +1 -0
- package/tailwindui/styles.css +371 -131
- package/types/api.d.ts +2 -2
- package/types/components.d.ts +7 -6
- package/types/core.d.ts +1 -0
- package/types/data-grid-props.d.ts +3 -2
- package/types/schema.d.ts +5 -2
- package/types/schema.js +6 -0
- package/types/state.d.ts +2 -2
- package/utils.d.ts +2 -2
package/data-grid.js
CHANGED
|
@@ -35,20 +35,15 @@ const useColumns_1 = require("./hooks/useColumns");
|
|
|
35
35
|
const footer_1 = require("./tailwindui/components/footer");
|
|
36
36
|
const show_1 = require("./tailwindui/show");
|
|
37
37
|
const actions_1 = require("./store/actions");
|
|
38
|
+
const use_rdg_visuals_1 = require("./hooks/use-rdg-visuals");
|
|
38
39
|
const defaultKeyExtractor = (r) => {
|
|
39
40
|
return r.id;
|
|
40
41
|
};
|
|
41
42
|
// eslint-disable-next-line react/require-optimization
|
|
42
43
|
const DataGrid = (props) => {
|
|
43
|
-
var _a, _b, _c
|
|
44
|
-
const rowHeight = (_a = props.rowHeight) !== null && _a !== void 0 ? _a : 44;
|
|
45
|
-
const headerRowHeight = (_b = props.headerRowHeight) !== null && _b !== void 0 ? _b : 36;
|
|
44
|
+
var _a, _b, _c;
|
|
46
45
|
const { LinearProgress, Container, FilterList, Pagination, PaginationCounts, PaginationRowsPerPageSelect, SelectedRowsToolbar, NoRowsFallback, SelectRowCheckbox, Toolbar, ToolbarControl, ToolbarCustoms, ToolbarTabs, } = props.ui;
|
|
47
46
|
const [state, dispatch] = (0, react_1.useReducer)(props.debug ? reducer_1.debugReducer : reducer_1.reducer, (0, reducer_1.getInitialState)(props.schema, props.initialState));
|
|
48
|
-
const [mounted, setMounted] = (0, react_1.useState)(false);
|
|
49
|
-
(0, react_1.useEffect)(() => {
|
|
50
|
-
setMounted(true);
|
|
51
|
-
}, []);
|
|
52
47
|
// TODO @vejvis - tady vyřešit problém se závislostma v useCallbacku
|
|
53
48
|
const schema = props.schema;
|
|
54
49
|
const gridName = props.gridName;
|
|
@@ -86,14 +81,11 @@ const DataGrid = (props) => {
|
|
|
86
81
|
const onFilter = (0, react_1.useCallback)((value) => {
|
|
87
82
|
dispatch(actions_1.dataGridActions.filter(value));
|
|
88
83
|
}, [dispatch]);
|
|
89
|
-
const rows = (
|
|
84
|
+
const rows = (_b = (_a = state.response) === null || _a === void 0 ? void 0 : _a.result) !== null && _b !== void 0 ? _b : [];
|
|
90
85
|
const columns = (0, useColumns_1.useColumns)(props, onReload);
|
|
91
|
-
const contentHeight = typeof rowHeight === "function"
|
|
92
|
-
? rows.reduce((prev, curr) => prev + rowHeight({ type: "ROW", row: curr }))
|
|
93
|
-
: (rowHeight + 1) * rows.length;
|
|
94
86
|
const components = (0, react_1.useMemo)(() => {
|
|
95
87
|
return {
|
|
96
|
-
|
|
88
|
+
renderCheckbox: (args) => react_1.default.createElement(SelectRowCheckbox, { ...args }),
|
|
97
89
|
noRowsFallback: react_1.default.createElement(NoRowsFallback, { error: state.error, loading: !!state.loading }),
|
|
98
90
|
};
|
|
99
91
|
}, [SelectRowCheckbox, NoRowsFallback, state.error, state.loading]);
|
|
@@ -111,22 +103,22 @@ const DataGrid = (props) => {
|
|
|
111
103
|
dispatch(actions_1.dataGridActions.sortClear());
|
|
112
104
|
}
|
|
113
105
|
};
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
};
|
|
106
|
+
const rdgVisuals = (0, use_rdg_visuals_1.useRdgVisuals)({
|
|
107
|
+
headerRowHeight: props.headerRowHeight,
|
|
108
|
+
mode: props.mode,
|
|
109
|
+
rowHeight: props.rowHeight,
|
|
110
|
+
rows,
|
|
111
|
+
});
|
|
120
112
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
121
113
|
react_1.default.createElement(Container, { noBorder: props.noBorder, className: props.className },
|
|
122
114
|
react_1.default.createElement(Toolbar, { noBorder: props.noBorder },
|
|
123
115
|
react_1.default.createElement(ToolbarTabs, { activeTab: state.request.tab, onChange: (tab) => dispatch(actions_1.dataGridActions.changeTab(tab)), schema: props.schema }),
|
|
124
|
-
react_1.default.createElement(ToolbarControl, { gridName: props.gridName, dispatch: dispatch, filterHandlers: props.ui.FilterHandlers, noBorder: props.noBorder, schema: props.schema,
|
|
116
|
+
react_1.default.createElement(ToolbarControl, { gridName: props.gridName, dispatch: dispatch, filterHandlers: props.ui.FilterHandlers, noBorder: props.noBorder, schema: props.schema, onFulltextChange: (value) => dispatch(actions_1.dataGridActions.search(value)), showFulltext: props.schema.fullText, hiddenColumns: props.hiddenColumns, onChangeHiddenColumns: props.onChangeHiddenColumns, onCsvDownload: props.onCsvDownload, state: state }),
|
|
125
117
|
react_1.default.createElement(ToolbarCustoms, { buttons: props.customActions })),
|
|
126
118
|
react_1.default.createElement(LinearProgress, { loading: !!state.loading }),
|
|
127
119
|
react_1.default.createElement(FilterList, { gridName: props.gridName, onFilter: onFilter, filters: props.schema.filters, filtersData: state.request.f, filterHandlers: props.ui.FilterHandlers, noBorder: props.noBorder }),
|
|
128
|
-
react_1.default.createElement(show_1.Show, { when:
|
|
129
|
-
react_1.default.createElement(react_data_grid_1.default, {
|
|
120
|
+
react_1.default.createElement(show_1.Show, { when: rdgVisuals.ready },
|
|
121
|
+
react_1.default.createElement(react_data_grid_1.default, { className: rdgVisuals.className, columns: columns, enableVirtualization: false, headerRowHeight: rdgVisuals.headerRowHeight, onSelectedRowsChange: props.onChangeSelectedRows, onSortColumnsChange: onSortColumnChange, ref: rdgVisuals.ref, renderers: components, rowClass: props.rowClass, rowHeight: rdgVisuals.rowHeight, rowKeyGetter: (_c = props.keyExtractor) !== null && _c !== void 0 ? _c : defaultKeyExtractor, rows: rows, selectedRows: props.selectedRows, sortColumns: sortColumns, style: rdgVisuals.style })),
|
|
130
122
|
react_1.default.createElement(footer_1.Footer, { noBorder: props.noBorder },
|
|
131
123
|
react_1.default.createElement(PaginationRowsPerPageSelect, { value: state.request.perPage, onChange: (value) => dispatch(actions_1.dataGridActions.changePerPage(value)) }),
|
|
132
124
|
react_1.default.createElement(PaginationCounts, { page: state.request.page, perPage: state.request.perPage, response: state.response }),
|
package/data-grid.stories.js
CHANGED
|
@@ -75,7 +75,7 @@ const schema = {
|
|
|
75
75
|
{ name: "only-odd-ids", label: "Only odd ids blablabla" },
|
|
76
76
|
// { name: "only-odd-ids", label: "Only odd ids" },
|
|
77
77
|
],
|
|
78
|
-
dir:
|
|
78
|
+
dir: _1.DataGridSortDir.Asc,
|
|
79
79
|
sort: "id",
|
|
80
80
|
perPage: 10,
|
|
81
81
|
fullText: true,
|
|
@@ -223,12 +223,19 @@ const loader = async (_, request) => {
|
|
|
223
223
|
result: filteredData.slice(page * perPage, page * perPage + perPage),
|
|
224
224
|
};
|
|
225
225
|
};
|
|
226
|
+
const onCsvDownload = (request) => {
|
|
227
|
+
// eslint-disable-next-line no-console
|
|
228
|
+
console.log(request);
|
|
229
|
+
};
|
|
226
230
|
function Default() {
|
|
227
231
|
const [hiddenColumns, setHiddenColumns] = (0, react_1.useState)([]);
|
|
228
232
|
const [selectedRows, setSelectedRows] = (0, react_1.useState)(new Set());
|
|
229
233
|
const callbackRef = (0, _1.useCallbackRef)();
|
|
230
234
|
return (react_1.default.createElement("div", { className: "min-h-screen bg-gray-50 p-4 dark:bg-gray-950" },
|
|
231
|
-
react_1.default.createElement(tailwindui_1.DataGrid, { callbackRef: callbackRef, schema: schema, title: "Test", noBorder: false, loader: loader, onChangeHiddenColumns: setHiddenColumns, hiddenColumns: hiddenColumns, onChangeSelectedRows: setSelectedRows, selectedRows: selectedRows, getOpenUrl: (row) => `https://www.uxf.cz/item-${row.id}`, onEdit: console.log, onRemove:
|
|
235
|
+
react_1.default.createElement(tailwindui_1.DataGrid, { callbackRef: callbackRef, schema: schema, title: "Test", noBorder: false, loader: loader, onChangeHiddenColumns: setHiddenColumns, hiddenColumns: hiddenColumns, onChangeSelectedRows: setSelectedRows, selectedRows: selectedRows, getOpenUrl: (row) => `https://www.uxf.cz/item-${row.id}`, onEdit: console.log, onRemove: (row, reload) => {
|
|
236
|
+
console.log(row, reload);
|
|
237
|
+
reload();
|
|
238
|
+
}, initialState: "eyJzb3J0IjoiaWQiLCJkaXIiOiJhc2MiLCJwZXJQYWdlIjoxMCwicGFnZSI6MCwiZiI6W3sibmFtZSI6ImNvZGUiLCJ2YWx1ZSI6IkNaIn1dfQ==", onCsvDownload: onCsvDownload, defaultConfig: {
|
|
232
239
|
columns: {
|
|
233
240
|
id: { width: 50, hidden: true },
|
|
234
241
|
text: {},
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { DataGridHandle } from "react-data-grid";
|
|
3
|
+
import { BaseGridType, DataGridBaseProps } from "../types";
|
|
4
|
+
export declare function useRdgVisuals(props: {
|
|
5
|
+
headerRowHeight?: DataGridBaseProps<BaseGridType, any>["headerRowHeight"];
|
|
6
|
+
mode?: DataGridBaseProps<BaseGridType, any>["mode"];
|
|
7
|
+
rowHeight?: DataGridBaseProps<BaseGridType, any>["rowHeight"];
|
|
8
|
+
rows: any[];
|
|
9
|
+
}): {
|
|
10
|
+
className: string;
|
|
11
|
+
headerRowHeight: number;
|
|
12
|
+
ready: boolean;
|
|
13
|
+
ref: import("react").RefObject<DataGridHandle>;
|
|
14
|
+
rowHeight: number | ((row: any) => number);
|
|
15
|
+
style: {
|
|
16
|
+
height: number | undefined;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useRdgVisuals = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
function useRdgVisuals(props) {
|
|
6
|
+
var _a, _b;
|
|
7
|
+
const [mounted, setMounted] = (0, react_1.useState)(false);
|
|
8
|
+
(0, react_1.useEffect)(() => setMounted(true), []);
|
|
9
|
+
const rowHeight = (_a = props.rowHeight) !== null && _a !== void 0 ? _a : 44;
|
|
10
|
+
const headerRowHeight = (_b = props.headerRowHeight) !== null && _b !== void 0 ? _b : 36;
|
|
11
|
+
const contentHeight = typeof rowHeight === "function"
|
|
12
|
+
? props.rows.reduce((prev, curr) => prev + rowHeight({ type: "ROW", row: curr }))
|
|
13
|
+
: rowHeight * props.rows.length;
|
|
14
|
+
const ref = (0, react_1.useRef)(null);
|
|
15
|
+
const size = {
|
|
16
|
+
contentHeight,
|
|
17
|
+
headerRowHeight,
|
|
18
|
+
rowsCount: props.rows.length,
|
|
19
|
+
};
|
|
20
|
+
const storedSize = (0, react_1.useRef)(size);
|
|
21
|
+
storedSize.current = size;
|
|
22
|
+
const [height, setHeight] = (0, react_1.useState)();
|
|
23
|
+
(0, react_1.useEffect)(() => {
|
|
24
|
+
var _a;
|
|
25
|
+
const node = (_a = ref.current) === null || _a === void 0 ? void 0 : _a.element;
|
|
26
|
+
if (!(mounted && node)) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const observer = new MutationObserver((mutations) => mutations.forEach(() => {
|
|
30
|
+
const currentSize = storedSize.current;
|
|
31
|
+
const scrollbarHeight = node.scrollWidth > node.clientWidth ? 8 : 0;
|
|
32
|
+
const emptyRowHeight = currentSize.rowsCount === 0 ? 44 : 0;
|
|
33
|
+
setHeight(currentSize.headerRowHeight + currentSize.contentHeight + emptyRowHeight + scrollbarHeight);
|
|
34
|
+
}));
|
|
35
|
+
observer.observe(node, { attributes: true, attributeFilter: ["style"] });
|
|
36
|
+
return () => observer.disconnect();
|
|
37
|
+
}, [mounted, storedSize]);
|
|
38
|
+
return {
|
|
39
|
+
className: `uxf-data-grid__table ${props.mode === "light" ? "rdg-light" : props.mode === "dark" ? "rdg-dark" : ""}`,
|
|
40
|
+
headerRowHeight,
|
|
41
|
+
ready: mounted,
|
|
42
|
+
ref,
|
|
43
|
+
rowHeight,
|
|
44
|
+
style: { height },
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
exports.useRdgVisuals = useRdgVisuals;
|
package/hooks/useColumns.js
CHANGED
|
@@ -47,7 +47,7 @@ const useColumns = (props, reload) => {
|
|
|
47
47
|
width: props.ui.ActionCell !== action_cell_base_1.ActionCellBase
|
|
48
48
|
? actionCellWidth
|
|
49
49
|
: [onRemove, onEdit !== null && onEdit !== void 0 ? onEdit : getEditUrl, onOpen !== null && onOpen !== void 0 ? onOpen : getOpenUrl].filter((i) => i).length * 40 + 8 * 2,
|
|
50
|
-
|
|
50
|
+
renderCell: (p) => {
|
|
51
51
|
if (!props.ui.ActionCell) {
|
|
52
52
|
return null;
|
|
53
53
|
}
|
|
@@ -71,7 +71,7 @@ const useColumns = (props, reload) => {
|
|
|
71
71
|
minWidth: (_c = c.minWidth) !== null && _c !== void 0 ? _c : (_d = defaultConfig === null || defaultConfig === void 0 ? void 0 : defaultConfig.columns[c.name]) === null || _d === void 0 ? void 0 : _d.minWidth,
|
|
72
72
|
maxWidth: (_e = c.maxWidth) !== null && _e !== void 0 ? _e : (_f = defaultConfig === null || defaultConfig === void 0 ? void 0 : defaultConfig.columns[c.name]) === null || _f === void 0 ? void 0 : _f.maxWidth,
|
|
73
73
|
cellClass: (0, utils_1.cx)("uxf-data-grid__cell", `uxf-data-grid__cell--type-${c.type}`, `uxf-data-grid__cell--name-${c.name}`),
|
|
74
|
-
|
|
74
|
+
renderCell: (p) => {
|
|
75
75
|
var _a;
|
|
76
76
|
const columnType = c.type;
|
|
77
77
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uxf/data-grid",
|
|
3
|
-
"version": "10.0.0-beta.
|
|
3
|
+
"version": "10.0.0-beta.71",
|
|
4
4
|
"description": "UXF DataGrid",
|
|
5
5
|
"homepage": "https://gitlab.com/uxf-npm/data-grid#readme",
|
|
6
6
|
"main": "index.js",
|
|
@@ -30,12 +30,13 @@
|
|
|
30
30
|
"node": ">=8.9"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
+
"@uxf/ui": "10.0.0-beta.69",
|
|
33
34
|
"react": "^18.0.0",
|
|
34
35
|
"react-dom": "^18.0.0",
|
|
35
36
|
"dayjs": "^1.11.7"
|
|
36
37
|
},
|
|
37
38
|
"dependencies": {
|
|
38
|
-
"react-data-grid": "7.0.0-beta.
|
|
39
|
+
"react-data-grid": "7.0.0-beta.39"
|
|
39
40
|
},
|
|
40
41
|
"devDependencies": {},
|
|
41
42
|
"gitHead": "e4f21a15c3d50fb6614d70cdaf36685232de87e7"
|
package/store/actions.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RequestFilter, Response
|
|
1
|
+
import { DataGridSortDir, RequestFilter, Response } from "../types";
|
|
2
2
|
export declare const dataGridActions: {
|
|
3
3
|
filter: (filterValue: RequestFilter) => {
|
|
4
4
|
type: string;
|
|
@@ -34,10 +34,10 @@ export declare const dataGridActions: {
|
|
|
34
34
|
type: string;
|
|
35
35
|
search: string;
|
|
36
36
|
};
|
|
37
|
-
sort: (columnName: string, direction:
|
|
37
|
+
sort: (columnName: string, direction: DataGridSortDir) => {
|
|
38
38
|
type: string;
|
|
39
39
|
columnName: string;
|
|
40
|
-
direction:
|
|
40
|
+
direction: DataGridSortDir;
|
|
41
41
|
};
|
|
42
42
|
sortClear: () => {
|
|
43
43
|
type: string;
|
|
@@ -74,9 +74,11 @@ const Button = (props) => {
|
|
|
74
74
|
return null;
|
|
75
75
|
};
|
|
76
76
|
const ActionCellBase = (props) => {
|
|
77
|
+
const onRemove = props.onRemove;
|
|
78
|
+
const handleRemove = onRemove ? () => onRemove(props.row, props.reload) : undefined;
|
|
77
79
|
return (react_1.default.createElement(exports.ActionCellWrapper, null,
|
|
78
|
-
react_1.default.createElement(Button, { row: props.row, onClick: props.
|
|
80
|
+
react_1.default.createElement(Button, { row: props.row, onClick: props.onOpen, getUrl: props.getOpenUrl, icon: "circle-info", title: "Detail" }),
|
|
79
81
|
react_1.default.createElement(Button, { row: props.row, onClick: props.onEdit, getUrl: props.getEditUrl, icon: "pen", title: "Upravit" }),
|
|
80
|
-
react_1.default.createElement(Button, { row: props.row, onClick:
|
|
82
|
+
react_1.default.createElement(Button, { row: props.row, onClick: handleRemove, getUrl: undefined, icon: "trash", title: "Smazat" })));
|
|
81
83
|
};
|
|
82
84
|
exports.ActionCellBase = ActionCellBase;
|
|
@@ -7,14 +7,21 @@ exports.Drawer = void 0;
|
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const icon_1 = require("@uxf/ui/icon");
|
|
9
9
|
const button_1 = require("@uxf/ui/button");
|
|
10
|
+
const react_2 = require("@floating-ui/react");
|
|
11
|
+
const useIsMounted_1 = require("@uxf/core/hooks/useIsMounted");
|
|
10
12
|
const Drawer = (props) => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
const isMounted = (0, useIsMounted_1.useIsMounted)();
|
|
14
|
+
if (!isMounted) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
return (react_1.default.createElement(react_2.FloatingPortal, null,
|
|
18
|
+
react_1.default.createElement("div", { className: `uxf-data-grid__drawer uxf-data-grid__drawer--${props.open ? "open" : "closed"}` },
|
|
19
|
+
react_1.default.createElement("div", { className: `uxf-data-grid__drawer-body-wrapper ${props.open ? "uxf-data-grid__drawer-body-wrapper--open" : ""}` },
|
|
20
|
+
react_1.default.createElement("div", { className: "uxf-data-grid__drawer-body" },
|
|
21
|
+
react_1.default.createElement(button_1.Button, { isIconButton: true, onClick: props.onClose, variant: "text", className: "uxf-data-grid__drawer-close-button" },
|
|
22
|
+
react_1.default.createElement(icon_1.Icon, { name: "xmarkLarge" })),
|
|
23
|
+
react_1.default.createElement("header", { className: "uxf-data-grid__drawer-header" }, props.title),
|
|
24
|
+
react_1.default.createElement("div", { className: "uxf-data-grid__drawer-content" }, props.children))),
|
|
25
|
+
react_1.default.createElement("section", { className: "uxf-data-grid__drawer-backdrop", onClick: props.onClose }))));
|
|
19
26
|
};
|
|
20
27
|
exports.Drawer = Drawer;
|
|
@@ -26,16 +26,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.SelectRowCheckbox = void 0;
|
|
27
27
|
const react_1 = __importStar(require("react"));
|
|
28
28
|
const checkbox_1 = require("@uxf/ui/checkbox");
|
|
29
|
-
const SelectRowComponent = (props
|
|
29
|
+
const SelectRowComponent = (props) => {
|
|
30
30
|
var _a;
|
|
31
31
|
const handleChange = (value, e) => {
|
|
32
|
-
var _a;
|
|
33
32
|
if (typeof value !== "undefined") {
|
|
34
|
-
|
|
35
|
-
props.onChange(value,
|
|
33
|
+
const shiftKey = (e === null || e === void 0 ? void 0 : e.nativeEvent) && e.nativeEvent instanceof MouseEvent ? e.nativeEvent.shiftKey : false;
|
|
34
|
+
props.onChange(value, shiftKey);
|
|
36
35
|
}
|
|
37
36
|
};
|
|
38
37
|
return (react_1.default.createElement("div", { className: "uxf-data-grid__select-row-checkbox-wrapper" },
|
|
39
|
-
react_1.default.createElement(checkbox_1.Checkbox, {
|
|
38
|
+
react_1.default.createElement(checkbox_1.Checkbox, { ...props, value: (_a = props.checked) !== null && _a !== void 0 ? _a : false, onChange: handleChange })));
|
|
40
39
|
};
|
|
41
40
|
exports.SelectRowCheckbox = (0, react_1.forwardRef)(SelectRowComponent);
|
|
@@ -32,6 +32,7 @@ const drawer_1 = require("./drawer");
|
|
|
32
32
|
const toggle_1 = require("@uxf/ui/toggle");
|
|
33
33
|
const actions_1 = require("../../store/actions");
|
|
34
34
|
const show_1 = require("../show");
|
|
35
|
+
const utils_1 = require("../../utils");
|
|
35
36
|
function Filters(props) {
|
|
36
37
|
return (react_1.default.createElement("div", { className: "uxf-data-grid__filters" }, props.schema.filters.map((filter) => {
|
|
37
38
|
var _a, _b;
|
|
@@ -47,21 +48,38 @@ function Filters(props) {
|
|
|
47
48
|
})));
|
|
48
49
|
}
|
|
49
50
|
function Columns(props) {
|
|
50
|
-
|
|
51
|
+
const onHideColumn = (columnName) => {
|
|
52
|
+
var _a, _b;
|
|
53
|
+
(_a = props.onChangeHiddenColumns) === null || _a === void 0 ? void 0 : _a.call(props, [...((_b = props.hiddenColumns) !== null && _b !== void 0 ? _b : []), columnName]);
|
|
54
|
+
};
|
|
55
|
+
const onShowColumn = (columnName) => {
|
|
56
|
+
var _a, _b;
|
|
57
|
+
(_a = props.onChangeHiddenColumns) === null || _a === void 0 ? void 0 : _a.call(props, [...((_b = props.hiddenColumns) !== null && _b !== void 0 ? _b : [])].filter((v) => v !== columnName));
|
|
58
|
+
};
|
|
59
|
+
return (react_1.default.createElement("div", { className: "uxf-data-grid__toolbar-control-columns" }, props.schema.columns.map((column) => {
|
|
60
|
+
var _a;
|
|
61
|
+
return (react_1.default.createElement(toggle_1.Toggle, { key: column.name, label: typeof column.label === "string" ? column.label : "", value: !((_a = props.hiddenColumns) === null || _a === void 0 ? void 0 : _a.includes(column.name)), onChange: (value) => (value ? onShowColumn(column.name) : onHideColumn(column.name)) }));
|
|
62
|
+
})));
|
|
51
63
|
}
|
|
52
64
|
const ToolbarControl = (props) => {
|
|
53
65
|
const [isFiltersOpen, setFiltersOpen] = (0, react_1.useState)(false);
|
|
54
66
|
const [isColumnsOpen, setColumnsOpen] = (0, react_1.useState)(false);
|
|
67
|
+
const fulltextValue = props.state.request.search;
|
|
68
|
+
const filtersData = props.state.request.f;
|
|
55
69
|
return (react_1.default.createElement("div", { className: "uxf-data-grid__toolbar-control" },
|
|
56
70
|
react_1.default.createElement(show_1.Show, { when: props.showFulltext },
|
|
57
|
-
react_1.default.createElement(text_input_1.TextInput, { value:
|
|
58
|
-
react_1.default.createElement(
|
|
59
|
-
react_1.default.createElement(
|
|
71
|
+
react_1.default.createElement(text_input_1.TextInput, { value: fulltextValue, onChange: props.onFulltextChange, placeholder: "Pi\u0161te pro hled\u00E1n\u00ED", className: "uxf-data-grid__plugin-fulltext", size: "small", leftElement: react_1.default.createElement(icon_1.Icon, { name: "search", size: 16 }), label: "Vyhled\u00E1v\u00E1n\u00ED", hiddenLabel: true })),
|
|
72
|
+
react_1.default.createElement(show_1.Show, { when: props.schema.filters.length !== 0 },
|
|
73
|
+
react_1.default.createElement(button_1.Button, { isIconButton: true, variant: "white", size: "sm", onClick: () => setFiltersOpen(true), title: "Filtrovat", className: "uxf-data-grid__plugin-button" },
|
|
74
|
+
react_1.default.createElement(icon_1.Icon, { name: "filter" }))),
|
|
60
75
|
react_1.default.createElement(show_1.Show, { when: props.onChangeHiddenColumns && props.hiddenColumns },
|
|
61
|
-
react_1.default.createElement(button_1.Button, { isIconButton: true, variant: "white", size: "sm", onClick: () => setColumnsOpen(true), title: "Nastaven\u00ED sloupc\u016F" },
|
|
76
|
+
react_1.default.createElement(button_1.Button, { isIconButton: true, variant: "white", size: "sm", onClick: () => setColumnsOpen(true), title: "Nastaven\u00ED sloupc\u016F", className: "uxf-data-grid__plugin-button" },
|
|
62
77
|
react_1.default.createElement(icon_1.Icon, { name: "table-columns" }))),
|
|
78
|
+
react_1.default.createElement(show_1.Show, { when: props.onCsvDownload },
|
|
79
|
+
react_1.default.createElement(button_1.Button, { isIconButton: true, variant: "white", size: "sm", onClick: () => { var _a; return (_a = props.onCsvDownload) === null || _a === void 0 ? void 0 : _a.call(props, (0, utils_1.createRequest)(props.state, props.schema.sort, props.schema.dir)); }, title: "St\u00E1hnout CSV", className: "uxf-data-grid__plugin-button" },
|
|
80
|
+
react_1.default.createElement(icon_1.Icon, { name: "file-arrow-down" }))),
|
|
63
81
|
react_1.default.createElement(drawer_1.Drawer, { open: isFiltersOpen, onClose: () => setFiltersOpen(false), title: "Filtry" },
|
|
64
|
-
react_1.default.createElement(Filters, { gridName: props.gridName, schema: props.schema, dispatch: props.dispatch, filtersData:
|
|
82
|
+
react_1.default.createElement(Filters, { gridName: props.gridName, schema: props.schema, dispatch: props.dispatch, filtersData: filtersData, filterHandlers: props.filterHandlers, noBorder: props.noBorder })),
|
|
65
83
|
react_1.default.createElement(drawer_1.Drawer, { open: isColumnsOpen, onClose: () => setColumnsOpen(false), title: "Nastaven\u00ED sloupc\u016F" },
|
|
66
84
|
react_1.default.createElement(Columns, { schema: props.schema, onChangeHiddenColumns: props.onChangeHiddenColumns, hiddenColumns: props.hiddenColumns }))));
|
|
67
85
|
};
|
|
@@ -7,7 +7,7 @@ const react_1 = __importDefault(require("react"));
|
|
|
7
7
|
const chip_1 = require("@uxf/ui/chip");
|
|
8
8
|
const checkbox_input_1 = require("@uxf/ui/checkbox-input");
|
|
9
9
|
const BooleanFilterHandler = {
|
|
10
|
-
input: (props) => (react_1.default.createElement(checkbox_input_1.CheckboxInput, { label: props.filter.label, value: props.value.value, onChange: (value) => props.onFilter({ ...props.value, value }) })),
|
|
10
|
+
input: (props) => (react_1.default.createElement(checkbox_input_1.CheckboxInput, { label: props.filter.label, value: props.value.value, onChange: (value) => props.onFilter({ ...props.value, value: value === true ? value : undefined }) })),
|
|
11
11
|
listItem: (props) => (react_1.default.createElement(chip_1.Chip, { onClose: props.onClear },
|
|
12
12
|
props.filter.label,
|
|
13
13
|
":\u00A0",
|
package/tailwindui/styles.css
CHANGED
|
@@ -1,86 +1,179 @@
|
|
|
1
|
+
@import url("react-data-grid/lib/styles.css");
|
|
2
|
+
|
|
3
|
+
@layer rdg.Root {
|
|
4
|
+
.uxf-data-grid__table {
|
|
5
|
+
--rdg-color-scheme: light;
|
|
6
|
+
--rdg-color: theme("colors.lightHigh");
|
|
7
|
+
--rdg-border-color: theme("colors.lightBorder");
|
|
8
|
+
--rdg-summary-border-color: theme("colors.lightBorder");
|
|
9
|
+
--rdg-background-color: theme("colors.white");
|
|
10
|
+
--rdg-header-background-color: theme("colors.gray.50");
|
|
11
|
+
--rdg-row-hover-background-color: theme("colors.gray.50");
|
|
12
|
+
--rdg-row-selected-background-color: theme("colors.gray.100/.75");
|
|
13
|
+
--rdg-row-selected-hover-background-color: theme("colors.gray.200/.75");
|
|
14
|
+
--rdg-selection-color: theme("colors.lightBorder");
|
|
15
|
+
--rdg-font-size: 14px;
|
|
16
|
+
|
|
17
|
+
:root .dark & {
|
|
18
|
+
--rdg-color-scheme: dark;
|
|
19
|
+
--rdg-color: theme("colors.darkHigh");
|
|
20
|
+
--rdg-border-color: theme("colors.darkBorder");
|
|
21
|
+
--rdg-summary-border-color: theme("colors.darkBorder");
|
|
22
|
+
--rdg-background-color: theme("colors.gray.950");
|
|
23
|
+
--rdg-header-background-color: theme("colors.gray.900");
|
|
24
|
+
--rdg-row-hover-background-color: theme("colors.gray.950");
|
|
25
|
+
--rdg-row-selected-background-color: theme("colors.gray.900/.75");
|
|
26
|
+
--rdg-row-selected-hover-background-color: theme("colors.gray.800/.75");
|
|
27
|
+
--rdg-selection-color: theme("colors.darkBorder");
|
|
28
|
+
--rdg-font-size: 14px;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
1
33
|
.uxf-data-grid {
|
|
2
|
-
|
|
34
|
+
border: 1px solid var(--rdg-border-color);
|
|
35
|
+
border-radius: theme("borderRadius.DEFAULT");
|
|
3
36
|
|
|
4
37
|
&.no-border {
|
|
5
|
-
|
|
38
|
+
border-style: none;
|
|
6
39
|
}
|
|
7
40
|
|
|
8
41
|
&__action-cell {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
:root .dark & {
|
|
14
|
-
border-inline-start: 1px solid theme("colors.gray.700");
|
|
15
|
-
}
|
|
42
|
+
background-color: var(--rdg-background-color);
|
|
43
|
+
border-inline-start: 1px solid var(--rdg-border-color);
|
|
44
|
+
position: sticky;
|
|
45
|
+
right: 0;
|
|
16
46
|
}
|
|
17
47
|
|
|
18
48
|
&__action-cell-wrapper {
|
|
19
|
-
@apply
|
|
49
|
+
@apply space-x-2;
|
|
50
|
+
|
|
51
|
+
align-items: center;
|
|
52
|
+
display: flex;
|
|
53
|
+
height: 100%;
|
|
54
|
+
justify-content: center;
|
|
55
|
+
text-align: center;
|
|
56
|
+
width: 100%;
|
|
20
57
|
|
|
21
58
|
.uxf-icon {
|
|
22
|
-
|
|
59
|
+
color: theme("colors.lightMedium");
|
|
60
|
+
|
|
61
|
+
:root .dark & {
|
|
62
|
+
color: theme("colors.darkMedium");
|
|
63
|
+
}
|
|
23
64
|
}
|
|
24
65
|
}
|
|
25
66
|
|
|
26
67
|
&__body-cell {
|
|
27
68
|
&--boolean {
|
|
28
|
-
|
|
69
|
+
align-items: center;
|
|
70
|
+
display: flex;
|
|
71
|
+
height: 100%;
|
|
72
|
+
width: 100%;
|
|
29
73
|
}
|
|
30
74
|
}
|
|
31
75
|
|
|
32
76
|
&__drawer {
|
|
33
|
-
@apply
|
|
77
|
+
@apply ease-in-out;
|
|
78
|
+
|
|
79
|
+
background-color: theme("colors.gray.900/.25");
|
|
80
|
+
inset: 0;
|
|
81
|
+
overflow: hidden;
|
|
82
|
+
position: fixed;
|
|
83
|
+
z-index: theme("zIndex.modal");
|
|
84
|
+
|
|
85
|
+
:root .dark & {
|
|
86
|
+
background-color: theme("colors.gray.900/.75");
|
|
87
|
+
}
|
|
34
88
|
|
|
35
89
|
&--open {
|
|
36
|
-
@apply transition-opacity
|
|
90
|
+
@apply transition-opacity duration-500;
|
|
91
|
+
|
|
92
|
+
opacity: 100;
|
|
93
|
+
transform: translateX(0);
|
|
37
94
|
}
|
|
38
95
|
|
|
39
96
|
&--closed {
|
|
40
|
-
@apply transition-all delay-500
|
|
97
|
+
@apply transition-all delay-500;
|
|
98
|
+
|
|
99
|
+
opacity: 0;
|
|
100
|
+
transform: translateX(100%);
|
|
41
101
|
}
|
|
42
102
|
|
|
43
103
|
&-body-wrapper {
|
|
44
|
-
@apply
|
|
104
|
+
@apply transition-all duration-500 ease-in-out;
|
|
105
|
+
|
|
106
|
+
background-color: theme("colors.white");
|
|
107
|
+
box-shadow: theme("boxShadow.xl");
|
|
108
|
+
height: 100%;
|
|
109
|
+
max-width: theme("maxWidth.sm");
|
|
110
|
+
position: absolute;
|
|
111
|
+
right: 0;
|
|
112
|
+
transform: translateX(100%);
|
|
113
|
+
width: theme("width.11/12");
|
|
45
114
|
|
|
46
115
|
&--open {
|
|
47
|
-
|
|
116
|
+
transform: translateX(0);
|
|
48
117
|
}
|
|
49
118
|
}
|
|
50
119
|
|
|
51
120
|
&-body {
|
|
52
|
-
|
|
121
|
+
display: flex;
|
|
122
|
+
flex-direction: column;
|
|
123
|
+
height: 100%;
|
|
124
|
+
max-width: theme("maxWidth.sm");
|
|
125
|
+
overflow-y: scroll;
|
|
126
|
+
padding-bottom: theme("spacing.10");
|
|
127
|
+
position: relative;
|
|
128
|
+
width: 100%;
|
|
129
|
+
|
|
130
|
+
:root .dark & {
|
|
131
|
+
background-color: theme("colors.gray.950");
|
|
132
|
+
color: theme("colors.gray.100");
|
|
133
|
+
}
|
|
53
134
|
}
|
|
54
135
|
|
|
55
136
|
&-close-button {
|
|
56
|
-
|
|
137
|
+
margin-left: auto;
|
|
138
|
+
margin-right: theme("spacing.4");
|
|
139
|
+
margin-top: theme("spacing.4") !important;
|
|
57
140
|
}
|
|
58
141
|
|
|
59
142
|
&-header {
|
|
60
|
-
|
|
143
|
+
font-weight: theme("fontWeight.bold");
|
|
144
|
+
padding: theme("spacing.8") theme("spacing.4") theme("spacing.4");
|
|
61
145
|
}
|
|
62
146
|
|
|
63
147
|
&-content {
|
|
64
|
-
|
|
148
|
+
padding: theme("spacing.4");
|
|
65
149
|
}
|
|
66
150
|
|
|
67
151
|
&-backdrop {
|
|
68
|
-
|
|
152
|
+
cursor: pointer;
|
|
153
|
+
height: 100%;
|
|
154
|
+
width: 100vw;
|
|
69
155
|
}
|
|
70
156
|
}
|
|
71
157
|
|
|
72
158
|
&__fallback {
|
|
159
|
+
align-items: center;
|
|
160
|
+
color: theme("colors.gray.600"); /* ?? */
|
|
161
|
+
display: flex;
|
|
73
162
|
grid-column: 1/-1;
|
|
74
|
-
|
|
75
|
-
|
|
163
|
+
justify-content: center;
|
|
164
|
+
text-align: center;
|
|
76
165
|
}
|
|
77
166
|
|
|
78
167
|
&__filter {
|
|
79
168
|
&--interval {
|
|
80
|
-
|
|
169
|
+
display: grid;
|
|
170
|
+
gap: theme("spacing.4");
|
|
171
|
+
grid-template-columns: 1fr min-content 1fr;
|
|
81
172
|
|
|
82
173
|
.uxf-data-grid__filter-gap {
|
|
83
|
-
|
|
174
|
+
align-items: center;
|
|
175
|
+
display: flex;
|
|
176
|
+
padding-top: theme("spacing.5");
|
|
84
177
|
}
|
|
85
178
|
}
|
|
86
179
|
}
|
|
@@ -90,249 +183,396 @@
|
|
|
90
183
|
}
|
|
91
184
|
|
|
92
185
|
&__filter-list {
|
|
93
|
-
@apply
|
|
186
|
+
@apply space-x-2;
|
|
187
|
+
|
|
188
|
+
padding: theme("spacing.2");
|
|
94
189
|
}
|
|
95
190
|
|
|
96
191
|
&__footer {
|
|
97
|
-
|
|
192
|
+
align-items: center;
|
|
193
|
+
display: flex;
|
|
194
|
+
flex-wrap: wrap;
|
|
195
|
+
gap: theme("spacing.4");
|
|
196
|
+
justify-content: flex-end;
|
|
197
|
+
padding: theme("spacing.2");
|
|
98
198
|
|
|
99
199
|
&.no-border {
|
|
100
|
-
|
|
200
|
+
padding-inline: 0;
|
|
101
201
|
}
|
|
102
202
|
}
|
|
103
203
|
|
|
104
204
|
&__linear-progress {
|
|
105
|
-
|
|
106
|
-
|
|
205
|
+
border-radius: 20px;
|
|
206
|
+
height: 3px;
|
|
107
207
|
left: 0;
|
|
108
|
-
right: 0;
|
|
109
208
|
overflow: hidden;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
-
|
|
113
|
-
border-radius: 20px;
|
|
209
|
+
position: absolute;
|
|
210
|
+
right: 0;
|
|
211
|
+
z-index: 1;
|
|
114
212
|
|
|
115
213
|
&.is-loading::before {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
214
|
+
animation: datagridlineanim 1s linear infinite;
|
|
215
|
+
background-color: theme("colors.dataGridSecondary");
|
|
216
|
+
border-radius: inherit;
|
|
217
|
+
content: "";
|
|
119
218
|
height: 3px;
|
|
219
|
+
left: -50%;
|
|
220
|
+
position: absolute;
|
|
120
221
|
width: 40%;
|
|
121
|
-
background-color: theme("colors.dataGridSecondary");
|
|
122
|
-
-webkit-animation: datagridlineanim 1s linear infinite;
|
|
123
|
-
-moz-animation: datagridlineanim 1s linear infinite;
|
|
124
|
-
animation: datagridlineanim 1s linear infinite;
|
|
125
|
-
-webkit-border-radius: 20px;
|
|
126
|
-
-moz-border-radius: 20px;
|
|
127
|
-
border-radius: 20px;
|
|
128
222
|
}
|
|
129
223
|
}
|
|
130
224
|
|
|
131
225
|
&__linear-progress-wrapper {
|
|
132
|
-
|
|
226
|
+
position: relative;
|
|
133
227
|
}
|
|
134
228
|
|
|
135
229
|
&__pagination-counts {
|
|
136
|
-
@apply text-sm
|
|
230
|
+
@apply text-sm;
|
|
231
|
+
|
|
232
|
+
color: theme("colors.lightLow");
|
|
137
233
|
}
|
|
138
234
|
|
|
139
235
|
&__plugin-fulltext {
|
|
140
|
-
|
|
236
|
+
color: theme("colors.gray.400");
|
|
237
|
+
margin: theme("spacing.2") 0;
|
|
238
|
+
width: 100%;
|
|
239
|
+
|
|
240
|
+
@screen sm {
|
|
241
|
+
width: auto;
|
|
242
|
+
}
|
|
141
243
|
|
|
142
244
|
.uxf-icon {
|
|
143
|
-
|
|
245
|
+
color: theme("colors.lightMedium");
|
|
246
|
+
|
|
247
|
+
:root .dark & {
|
|
248
|
+
color: theme("colors.darkMedium");
|
|
249
|
+
}
|
|
144
250
|
}
|
|
145
251
|
}
|
|
146
252
|
|
|
147
|
-
&__plugin-
|
|
148
|
-
|
|
253
|
+
&__plugin-button {
|
|
254
|
+
flex-shrink: 0;
|
|
255
|
+
margin: theme("spacing.2") 0;
|
|
149
256
|
|
|
150
257
|
.uxf-icon {
|
|
151
|
-
|
|
258
|
+
color: theme("colors.lightMedium");
|
|
259
|
+
|
|
260
|
+
:root .dark & {
|
|
261
|
+
color: theme("colors.darkMedium");
|
|
262
|
+
}
|
|
152
263
|
}
|
|
153
264
|
}
|
|
154
265
|
|
|
155
266
|
&__rows-per-page {
|
|
156
|
-
@apply
|
|
267
|
+
@apply text-sm;
|
|
268
|
+
|
|
269
|
+
align-items: center;
|
|
270
|
+
color: theme("colors.lightLow");
|
|
271
|
+
display: flex;
|
|
272
|
+
flex-wrap: wrap;
|
|
273
|
+
gap: theme("spacing.2");
|
|
157
274
|
|
|
158
275
|
.uxf-select {
|
|
159
|
-
|
|
276
|
+
width: theme("width.28");
|
|
160
277
|
}
|
|
161
278
|
}
|
|
162
279
|
|
|
163
280
|
&__select-row-checkbox-wrapper {
|
|
164
|
-
|
|
281
|
+
align-items: center;
|
|
282
|
+
color: theme("colors.white");
|
|
283
|
+
display: flex;
|
|
284
|
+
height: 100%;
|
|
285
|
+
justify-content: center;
|
|
286
|
+
width: 100%;
|
|
165
287
|
}
|
|
166
288
|
|
|
167
289
|
&__selected-rows-toolbar-wrapper {
|
|
168
|
-
|
|
290
|
+
align-items: center;
|
|
291
|
+
bottom: theme("spacing.8");
|
|
292
|
+
display: flex;
|
|
293
|
+
justify-content: center;
|
|
294
|
+
left: 0;
|
|
295
|
+
position: fixed;
|
|
296
|
+
right: 0;
|
|
169
297
|
}
|
|
170
298
|
|
|
171
299
|
&__selected-rows-toolbar {
|
|
172
|
-
@apply text-
|
|
300
|
+
@apply text-sm drop-shadow-xl;
|
|
301
|
+
|
|
302
|
+
align-items: center;
|
|
303
|
+
background-color: theme("colors.dataGridPrimary");
|
|
304
|
+
border: 1px solid theme("colors.lightBorder");
|
|
305
|
+
border-radius: 999px;
|
|
306
|
+
color: theme("colors.white");
|
|
307
|
+
display: flex;
|
|
308
|
+
justify-content: center;
|
|
309
|
+
padding: theme("spacing.2") theme("spacing.6");
|
|
310
|
+
|
|
311
|
+
:root .dark & {
|
|
312
|
+
border-color: theme("colors.darkBorder");
|
|
313
|
+
}
|
|
173
314
|
}
|
|
174
315
|
|
|
175
316
|
&__selected-rows-toolbar-actions {
|
|
176
|
-
@apply
|
|
317
|
+
@apply space-x-2;
|
|
318
|
+
|
|
319
|
+
padding-left: theme("spacing.4");
|
|
177
320
|
}
|
|
178
321
|
|
|
179
322
|
&__table {
|
|
180
|
-
|
|
323
|
+
overflow-y: hidden;
|
|
324
|
+
|
|
325
|
+
&::-webkit-scrollbar {
|
|
326
|
+
height: 8px;
|
|
327
|
+
width: 8px;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
&::-webkit-scrollbar-track {
|
|
331
|
+
background-color: transparent;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
&::-webkit-scrollbar-thumb,
|
|
335
|
+
&::-webkit-scrollbar-thumb:hover {
|
|
336
|
+
background-color: theme("colors.lightLow");
|
|
337
|
+
border-radius: 999px;
|
|
338
|
+
|
|
339
|
+
:root .dark & {
|
|
340
|
+
background-color: theme("colors.darkLow");
|
|
341
|
+
}
|
|
342
|
+
}
|
|
181
343
|
}
|
|
182
344
|
|
|
183
345
|
&__toolbar {
|
|
184
|
-
|
|
346
|
+
align-items: center;
|
|
347
|
+
border-bottom: 1px solid theme("colors.lightBorder");
|
|
348
|
+
display: flex;
|
|
349
|
+
flex-wrap: wrap;
|
|
350
|
+
gap: theme("spacing.2");
|
|
351
|
+
justify-content: flex-end;
|
|
352
|
+
padding: theme("spacing.2");
|
|
353
|
+
|
|
354
|
+
:root .dark & {
|
|
355
|
+
border-bottom-color: theme("colors.darkBorder");
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
@screen md {
|
|
359
|
+
padding-block: 0;
|
|
360
|
+
padding-left: 0;
|
|
361
|
+
}
|
|
185
362
|
}
|
|
186
363
|
|
|
187
364
|
&__toolbar-tab {
|
|
188
|
-
@apply
|
|
365
|
+
@apply text-sm;
|
|
366
|
+
|
|
367
|
+
align-items: center;
|
|
368
|
+
border-bottom: 2px solid transparent;
|
|
369
|
+
color: theme("colors.lightMedium");
|
|
370
|
+
display: inline-flex;
|
|
371
|
+
font-weight: theme("fontWeight.medium");
|
|
372
|
+
padding: theme("spacing.4");
|
|
373
|
+
white-space: nowrap;
|
|
374
|
+
|
|
375
|
+
:root .dark & {
|
|
376
|
+
color: theme("colors.darkMedium");
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
&:hover {
|
|
380
|
+
color: theme("colors.lightHigh");
|
|
381
|
+
|
|
382
|
+
:root .dark & {
|
|
383
|
+
color: theme("colors.darkHigh");
|
|
384
|
+
}
|
|
385
|
+
}
|
|
189
386
|
|
|
190
387
|
&.is-active {
|
|
191
|
-
|
|
388
|
+
border-bottom-color: currentcolor;
|
|
389
|
+
color: theme("colors.dataGridPrimary");
|
|
192
390
|
}
|
|
193
391
|
}
|
|
194
392
|
|
|
195
393
|
&__toolbar-tabs {
|
|
196
|
-
|
|
394
|
+
align-self: stretch;
|
|
395
|
+
display: flex;
|
|
396
|
+
flex: 1;
|
|
197
397
|
|
|
198
398
|
&-nav {
|
|
199
399
|
&--desktop {
|
|
200
|
-
@apply
|
|
400
|
+
@apply space-x-4;
|
|
201
401
|
|
|
202
|
-
|
|
203
|
-
|
|
402
|
+
display: none;
|
|
403
|
+
margin-bottom: -1px;
|
|
404
|
+
|
|
405
|
+
@screen md {
|
|
406
|
+
display: flex;
|
|
204
407
|
}
|
|
205
408
|
}
|
|
206
409
|
|
|
207
410
|
&--mobile {
|
|
208
|
-
|
|
411
|
+
align-items: center;
|
|
412
|
+
display: flex;
|
|
413
|
+
width: max-content;
|
|
414
|
+
z-index: theme("zIndex.10");
|
|
209
415
|
|
|
210
|
-
@
|
|
211
|
-
|
|
416
|
+
@screen md {
|
|
417
|
+
display: none;
|
|
212
418
|
}
|
|
213
419
|
|
|
214
420
|
.uxf-data-grid__toolbar-tabs-button {
|
|
215
|
-
|
|
421
|
+
align-items: center;
|
|
422
|
+
display: flex;
|
|
423
|
+
margin: 0;
|
|
216
424
|
|
|
217
425
|
&-icon {
|
|
218
|
-
|
|
426
|
+
color: theme("colors.lightHigh");
|
|
427
|
+
margin-left: theme("spacing.1");
|
|
428
|
+
|
|
429
|
+
:root .dark & {
|
|
430
|
+
color: theme("colors.darkHigh");
|
|
431
|
+
}
|
|
219
432
|
}
|
|
220
433
|
}
|
|
221
434
|
}
|
|
222
435
|
|
|
223
436
|
&-text {
|
|
224
|
-
|
|
437
|
+
color: theme("colors.lightHigh");
|
|
438
|
+
|
|
439
|
+
:root .dark & {
|
|
440
|
+
color: theme("colors.darkHigh");
|
|
441
|
+
}
|
|
225
442
|
}
|
|
226
443
|
}
|
|
227
444
|
|
|
228
445
|
&-modal-content {
|
|
229
|
-
@apply
|
|
446
|
+
@apply divide-y divide-lightBorder dark:divide-darkBorder;
|
|
447
|
+
|
|
448
|
+
align-items: flex-start;
|
|
449
|
+
display: flex;
|
|
450
|
+
flex-direction: column;
|
|
451
|
+
padding-bottom: theme("spacing.4");
|
|
452
|
+
padding-top: theme("spacing.1");
|
|
453
|
+
text-align: left;
|
|
230
454
|
}
|
|
231
455
|
|
|
232
456
|
&-modal-button {
|
|
233
|
-
|
|
457
|
+
border-radius: 0;
|
|
458
|
+
justify-content: flex-start;
|
|
459
|
+
width: 100%;
|
|
234
460
|
}
|
|
235
461
|
|
|
236
462
|
&-modal-button-text {
|
|
237
|
-
|
|
463
|
+
color: theme("colors.lightHigh");
|
|
464
|
+
|
|
465
|
+
:root .dark & {
|
|
466
|
+
color: theme("colors.darkHigh");
|
|
467
|
+
}
|
|
238
468
|
}
|
|
239
469
|
|
|
240
470
|
&-modal-active-tab-icon {
|
|
241
|
-
|
|
471
|
+
color: theme("colors.lightMedium");
|
|
472
|
+
margin-right: theme("spacing.3");
|
|
473
|
+
|
|
474
|
+
:root .dark & {
|
|
475
|
+
color: theme("colors.darkMedium");
|
|
476
|
+
}
|
|
242
477
|
}
|
|
243
478
|
}
|
|
244
479
|
|
|
245
480
|
&__toolbar-control {
|
|
246
|
-
|
|
481
|
+
align-items: center;
|
|
482
|
+
display: flex;
|
|
483
|
+
flex-direction: row;
|
|
484
|
+
gap: theme("spacing.2");
|
|
485
|
+
justify-content: space-between;
|
|
486
|
+
order: 3;
|
|
487
|
+
width: 100%;
|
|
488
|
+
|
|
489
|
+
@screen xs {
|
|
490
|
+
order: 2;
|
|
491
|
+
width: auto;
|
|
492
|
+
}
|
|
247
493
|
}
|
|
248
494
|
|
|
249
495
|
&__toolbar-customs {
|
|
250
|
-
|
|
496
|
+
align-items: center;
|
|
497
|
+
display: flex;
|
|
498
|
+
flex-direction: row;
|
|
499
|
+
gap: theme("spacing.2");
|
|
500
|
+
order: 2;
|
|
501
|
+
|
|
502
|
+
@screen xs {
|
|
503
|
+
order: 2;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
@screen md {
|
|
507
|
+
margin-block: theme("spacing.2");
|
|
508
|
+
}
|
|
251
509
|
|
|
252
510
|
&-mobile {
|
|
253
|
-
|
|
511
|
+
display: flex;
|
|
512
|
+
|
|
513
|
+
@screen md {
|
|
514
|
+
display: none;
|
|
515
|
+
}
|
|
254
516
|
}
|
|
255
517
|
|
|
256
518
|
&-desktop {
|
|
257
|
-
|
|
519
|
+
display: none;
|
|
520
|
+
|
|
521
|
+
@screen md {
|
|
522
|
+
display: flex;
|
|
523
|
+
gap: theme("spacing.2");
|
|
524
|
+
}
|
|
258
525
|
}
|
|
259
526
|
}
|
|
260
527
|
}
|
|
261
528
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
529
|
+
/* TODO: tohle je imo k ničemu, že Vejvis? */
|
|
530
|
+
|
|
531
|
+
/* .rdg-cell.action {
|
|
265
532
|
align-items: center;
|
|
533
|
+
border-right: 0;
|
|
534
|
+
box-shadow: -3px 0 15px rgba(221 221 221 / 50%);
|
|
266
535
|
display: flex;
|
|
267
536
|
justify-content: center;
|
|
268
537
|
position: sticky;
|
|
269
|
-
box-shadow: -3px 0 15px rgba(221 221 221 / 50%);
|
|
270
538
|
right: 0;
|
|
271
|
-
|
|
539
|
+
text-align: right;
|
|
540
|
+
} */
|
|
272
541
|
|
|
273
542
|
.rdg-header-row {
|
|
274
|
-
|
|
543
|
+
color: theme("colors.lightLow");
|
|
544
|
+
font-weight: theme("fontWeight.normal");
|
|
545
|
+
|
|
546
|
+
:root .dark & {
|
|
547
|
+
color: theme("colors.darkLow");
|
|
548
|
+
}
|
|
275
549
|
|
|
276
550
|
.rdg-cell {
|
|
277
|
-
|
|
551
|
+
background-color: var(--rdg-header-background-color);
|
|
278
552
|
|
|
279
|
-
|
|
280
|
-
|
|
553
|
+
:root .dark & {
|
|
554
|
+
color: theme("colors.darkMedium");
|
|
555
|
+
}
|
|
281
556
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
}
|
|
557
|
+
&:not(:first-child) {
|
|
558
|
+
border-inline-start: 1px solid var(--rdg-border-color);
|
|
285
559
|
}
|
|
286
560
|
}
|
|
287
561
|
}
|
|
288
562
|
|
|
289
563
|
.rdg-header-sort-name + span {
|
|
290
|
-
display: flex;
|
|
291
564
|
align-items: center;
|
|
565
|
+
display: flex;
|
|
292
566
|
}
|
|
293
567
|
|
|
294
568
|
.rdg-cell {
|
|
569
|
+
border-block-end-width: 1px;
|
|
570
|
+
border-color: var(--rdg-border-color);
|
|
295
571
|
border-inline-end: none;
|
|
296
572
|
|
|
297
573
|
&.rdg-cell-frozen {
|
|
298
574
|
box-shadow: none;
|
|
299
575
|
}
|
|
300
|
-
|
|
301
|
-
&[aria-selected="true"] {
|
|
302
|
-
outline-color: theme("colors.gray.300");
|
|
303
|
-
|
|
304
|
-
:root .dark & {
|
|
305
|
-
outline-color: theme("colors.gray.700");
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
.rdg-row[aria-selected="true"] {
|
|
311
|
-
@apply bg-gray-100/75 dark:bg-gray-900/75;
|
|
312
|
-
|
|
313
|
-
.uxf-data-grid__action-cell {
|
|
314
|
-
background-color: white;
|
|
315
|
-
|
|
316
|
-
:root .dark & {
|
|
317
|
-
background-color: theme("colors.gray.900");
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
.rdg-row:hover {
|
|
323
|
-
@apply bg-gray-50 dark:bg-gray-950;
|
|
324
|
-
|
|
325
|
-
.uxf-data-grid__action-cell {
|
|
326
|
-
background-color: white;
|
|
327
|
-
|
|
328
|
-
:root .dark & {
|
|
329
|
-
background-color: theme("colors.gray.950");
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
.rdg-row[aria-selected="true"]:hover {
|
|
335
|
-
@apply bg-gray-200/75 dark:bg-gray-800/75;
|
|
336
576
|
}
|
|
337
577
|
|
|
338
578
|
@keyframes datagridlineanim {
|
|
@@ -349,4 +589,4 @@
|
|
|
349
589
|
left: 100%;
|
|
350
590
|
width: 100%;
|
|
351
591
|
}
|
|
352
|
-
}
|
|
592
|
+
}
|
package/types/api.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DataGridSortDir } from "./schema";
|
|
2
2
|
export type ResultItem = any;
|
|
3
3
|
export interface RequestFilter<T = any> {
|
|
4
4
|
name: string;
|
|
@@ -9,7 +9,7 @@ export interface RequestFilter<T = any> {
|
|
|
9
9
|
export interface Request {
|
|
10
10
|
f?: RequestFilter[];
|
|
11
11
|
sort?: string;
|
|
12
|
-
dir?:
|
|
12
|
+
dir?: DataGridSortDir;
|
|
13
13
|
page?: number;
|
|
14
14
|
perPage?: number;
|
|
15
15
|
search?: string;
|
package/types/components.d.ts
CHANGED
|
@@ -2,8 +2,9 @@ import React, { ComponentType, FC, ReactElement, ReactNode } from "react";
|
|
|
2
2
|
import { BaseGridType, Columns, Filter, Filters, Schema } from "./schema";
|
|
3
3
|
import { RequestFilter, Response } from "./api";
|
|
4
4
|
import { PaginationProps } from "@uxf/ui/pagination/pagination";
|
|
5
|
-
import {
|
|
6
|
-
import { ChangeHiddenColumnsHandler } from "./core";
|
|
5
|
+
import { RenderCheckboxProps } from "react-data-grid";
|
|
6
|
+
import { ChangeHiddenColumnsHandler, CsvDownloadHandler } from "./core";
|
|
7
|
+
import { DataGridState } from "./state";
|
|
7
8
|
/**
|
|
8
9
|
* Action cell
|
|
9
10
|
*/
|
|
@@ -13,7 +14,7 @@ export interface ActionCellProps<R> {
|
|
|
13
14
|
getOpenUrl?: (row: R) => string | null | undefined;
|
|
14
15
|
onEdit?: (row: R) => void;
|
|
15
16
|
getEditUrl?: (row: R) => string | null | undefined;
|
|
16
|
-
onRemove?: (row: R) => void;
|
|
17
|
+
onRemove?: (row: R, reload: () => void) => void;
|
|
17
18
|
reload: () => Promise<void>;
|
|
18
19
|
}
|
|
19
20
|
export type ActionCellComponent<R> = FC<ActionCellProps<R>>;
|
|
@@ -127,7 +128,7 @@ export type SelectedRowsToolbarComponent = FC<SelectedRowsToolbarProps>;
|
|
|
127
128
|
/**
|
|
128
129
|
* Select row checkbox
|
|
129
130
|
*/
|
|
130
|
-
export type SelectRowCheckboxComponent = React.FC<
|
|
131
|
+
export type SelectRowCheckboxComponent = React.FC<RenderCheckboxProps>;
|
|
131
132
|
/**
|
|
132
133
|
* Selected rows toolbar actions
|
|
133
134
|
*/
|
|
@@ -152,14 +153,14 @@ export interface ToolbarControlProps {
|
|
|
152
153
|
gridName: string | undefined;
|
|
153
154
|
schema: Schema<any>;
|
|
154
155
|
dispatch: (action: any) => void;
|
|
155
|
-
filtersData: RequestFilter[];
|
|
156
156
|
filterHandlers: FilterHandlers;
|
|
157
|
-
fulltextValue: string;
|
|
158
157
|
onFulltextChange: (value: string) => void;
|
|
159
158
|
noBorder: boolean | null | undefined;
|
|
160
159
|
onChangeHiddenColumns?: ChangeHiddenColumnsHandler;
|
|
160
|
+
onCsvDownload?: CsvDownloadHandler;
|
|
161
161
|
hiddenColumns?: string[];
|
|
162
162
|
showFulltext?: boolean;
|
|
163
|
+
state: DataGridState;
|
|
163
164
|
}
|
|
164
165
|
export type ToolbarControlComponent = React.FC<ToolbarControlProps>;
|
|
165
166
|
/**
|
package/types/core.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Request, Response, ResultItem } from "./api";
|
|
|
2
2
|
import { BaseGridType } from "./schema";
|
|
3
3
|
export type KeyExtractor = (row: ResultItem) => number;
|
|
4
4
|
export type ChangeHiddenColumnsHandler = (hiddenColumns: string[]) => void;
|
|
5
|
+
export type CsvDownloadHandler = (request: Request) => void;
|
|
5
6
|
export type Loader = (gridName: string | undefined, request: Request, encodedRequest: string) => Promise<Response>;
|
|
6
7
|
export type CallbackRef = {
|
|
7
8
|
reload: () => Promise<void>;
|
|
@@ -4,7 +4,7 @@ import { Request } from "./api";
|
|
|
4
4
|
import { DataGridProps as RDGProps } from "react-data-grid";
|
|
5
5
|
import { ToolbarCustomsProps } from "./components";
|
|
6
6
|
import { UIComponents } from "./ui-components";
|
|
7
|
-
import { CallbackRef, ChangeHiddenColumnsHandler, Config, KeyExtractor, Loader } from "./core";
|
|
7
|
+
import { CallbackRef, ChangeHiddenColumnsHandler, Config, CsvDownloadHandler, KeyExtractor, Loader } from "./core";
|
|
8
8
|
export type DataGridBaseProps<GridType extends BaseGridType, R> = {
|
|
9
9
|
callbackRef?: MutableRefObject<CallbackRef | undefined>;
|
|
10
10
|
schema: Schema<GridType>;
|
|
@@ -14,6 +14,7 @@ export type DataGridBaseProps<GridType extends BaseGridType, R> = {
|
|
|
14
14
|
keyExtractor?: KeyExtractor;
|
|
15
15
|
initialState?: Request | string;
|
|
16
16
|
onChangeHiddenColumns?: ChangeHiddenColumnsHandler;
|
|
17
|
+
onCsvDownload?: CsvDownloadHandler;
|
|
17
18
|
hiddenColumns?: string[];
|
|
18
19
|
onChangeSelectedRows?: (selectedRows: Set<number>) => void;
|
|
19
20
|
selectedRows?: Set<number>;
|
|
@@ -21,7 +22,7 @@ export type DataGridBaseProps<GridType extends BaseGridType, R> = {
|
|
|
21
22
|
getOpenUrl?: (row: R) => string | null | undefined;
|
|
22
23
|
onEdit?: (row: R) => void;
|
|
23
24
|
getEditUrl?: (row: R) => string | null | undefined;
|
|
24
|
-
onRemove?: (row: R) => void;
|
|
25
|
+
onRemove?: (row: R, reload: () => void) => void;
|
|
25
26
|
noBorder?: boolean;
|
|
26
27
|
rowHeight?: RDGProps<any>["rowHeight"];
|
|
27
28
|
headerRowHeight?: RDGProps<any>["headerRowHeight"];
|
package/types/schema.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { ReactElement } from "react";
|
|
2
|
-
export
|
|
2
|
+
export declare enum DataGridSortDir {
|
|
3
|
+
Asc = "asc",
|
|
4
|
+
Desc = "desc"
|
|
5
|
+
}
|
|
3
6
|
export interface Tab {
|
|
4
7
|
name: string;
|
|
5
8
|
label: string;
|
|
@@ -42,7 +45,7 @@ export interface Schema<GritType extends BaseGridType> {
|
|
|
42
45
|
filters: Filters<GritType["filters"]>[];
|
|
43
46
|
tabs?: Tab[];
|
|
44
47
|
sort: string;
|
|
45
|
-
dir:
|
|
48
|
+
dir: DataGridSortDir;
|
|
46
49
|
perPage: number;
|
|
47
50
|
fullText?: boolean;
|
|
48
51
|
}
|
package/types/schema.js
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DataGridSortDir = void 0;
|
|
4
|
+
var DataGridSortDir;
|
|
5
|
+
(function (DataGridSortDir) {
|
|
6
|
+
DataGridSortDir["Asc"] = "asc";
|
|
7
|
+
DataGridSortDir["Desc"] = "desc";
|
|
8
|
+
})(DataGridSortDir || (exports.DataGridSortDir = DataGridSortDir = {}));
|
package/types/state.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { RequestFilter, Response } from "./api";
|
|
2
|
-
import {
|
|
2
|
+
import { DataGridSortDir } from "./schema";
|
|
3
3
|
type GridRequest = {
|
|
4
4
|
f: RequestFilter[];
|
|
5
5
|
sort: string | null;
|
|
6
|
-
dir:
|
|
6
|
+
dir: DataGridSortDir | null;
|
|
7
7
|
page: number;
|
|
8
8
|
perPage: number;
|
|
9
9
|
search: string;
|
package/utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { DataGridState, Request
|
|
1
|
+
import { DataGridSortDir, DataGridState, Request } from "./types";
|
|
2
2
|
export declare function decodeFilter(filterString: string): null | Request;
|
|
3
3
|
export declare function encodeFilter(request: Request): string;
|
|
4
|
-
export declare function createRequest(state: DataGridState, defaultSort: string, defaultDir:
|
|
4
|
+
export declare function createRequest(state: DataGridState, defaultSort: string, defaultDir: DataGridSortDir): Request;
|
|
5
5
|
export type ClassArray = ClassValue[];
|
|
6
6
|
export type ClassValue = ClassArray | Record<string, any> | string | number | null | boolean | undefined;
|
|
7
7
|
export declare function cx(...classes: ClassValue[]): string;
|