@uxf/data-grid 10.0.0-beta.7 → 10.0.0-beta.70
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 +12 -20
- 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/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 +366 -129
- 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,11 +81,8 @@ 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
|
checkboxFormatter: SelectRowCheckbox,
|
|
@@ -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.70",
|
|
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;
|
|
@@ -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
|
+
--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
|
+
--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,393 @@
|
|
|
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
|
+
position: fixed;
|
|
295
|
+
right: 0;
|
|
169
296
|
}
|
|
170
297
|
|
|
171
298
|
&__selected-rows-toolbar {
|
|
172
|
-
@apply text-
|
|
299
|
+
@apply text-sm drop-shadow-xl;
|
|
300
|
+
|
|
301
|
+
align-items: center;
|
|
302
|
+
background-color: theme("colors.dataGridPrimary");
|
|
303
|
+
border: 1px solid theme("colors.lightBorder");
|
|
304
|
+
border-radius: 999px;
|
|
305
|
+
color: theme("colors.white");
|
|
306
|
+
display: flex;
|
|
307
|
+
justify-content: center;
|
|
308
|
+
padding: theme("spacing.2") theme("spacing.6");
|
|
309
|
+
|
|
310
|
+
:root .dark & {
|
|
311
|
+
border-color: theme("colors.darkBorder");
|
|
312
|
+
}
|
|
173
313
|
}
|
|
174
314
|
|
|
175
315
|
&__selected-rows-toolbar-actions {
|
|
176
|
-
@apply
|
|
316
|
+
@apply space-x-2;
|
|
317
|
+
|
|
318
|
+
padding-left: theme("spacing.4");
|
|
177
319
|
}
|
|
178
320
|
|
|
179
321
|
&__table {
|
|
180
|
-
|
|
322
|
+
overflow-y: hidden;
|
|
323
|
+
|
|
324
|
+
&::-webkit-scrollbar {
|
|
325
|
+
height: 8px;
|
|
326
|
+
width: 8px;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
&::-webkit-scrollbar-track {
|
|
330
|
+
background-color: transparent;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
&::-webkit-scrollbar-thumb,
|
|
334
|
+
&::-webkit-scrollbar-thumb:hover {
|
|
335
|
+
background-color: theme("colors.lightLow");
|
|
336
|
+
border-radius: 999px;
|
|
337
|
+
|
|
338
|
+
:root .dark & {
|
|
339
|
+
background-color: theme("colors.darkLow");
|
|
340
|
+
}
|
|
341
|
+
}
|
|
181
342
|
}
|
|
182
343
|
|
|
183
344
|
&__toolbar {
|
|
184
|
-
|
|
345
|
+
align-items: center;
|
|
346
|
+
border-bottom: 1px solid theme("colors.lightBorder");
|
|
347
|
+
display: flex;
|
|
348
|
+
flex-wrap: wrap;
|
|
349
|
+
gap: theme("spacing.2");
|
|
350
|
+
justify-content: flex-end;
|
|
351
|
+
padding: theme("spacing.2");
|
|
352
|
+
|
|
353
|
+
:root .dark & {
|
|
354
|
+
border-bottom-color: theme("colors.darkBorder");
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
@screen md {
|
|
358
|
+
padding-block: 0;
|
|
359
|
+
padding-left: 0;
|
|
360
|
+
}
|
|
185
361
|
}
|
|
186
362
|
|
|
187
363
|
&__toolbar-tab {
|
|
188
|
-
@apply
|
|
364
|
+
@apply text-sm;
|
|
365
|
+
|
|
366
|
+
align-items: center;
|
|
367
|
+
border-bottom: 2px solid transparent;
|
|
368
|
+
color: theme("colors.lightMedium");
|
|
369
|
+
display: inline-flex;
|
|
370
|
+
font-weight: theme("fontWeight.medium");
|
|
371
|
+
padding: theme("spacing.4");
|
|
372
|
+
white-space: nowrap;
|
|
373
|
+
|
|
374
|
+
:root .dark & {
|
|
375
|
+
color: theme("colors.darkMedium");
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
&:hover {
|
|
379
|
+
color: theme("colors.lightHigh");
|
|
380
|
+
|
|
381
|
+
:root .dark & {
|
|
382
|
+
color: theme("colors.darkHigh");
|
|
383
|
+
}
|
|
384
|
+
}
|
|
189
385
|
|
|
190
386
|
&.is-active {
|
|
191
|
-
|
|
387
|
+
border-bottom-color: currentcolor;
|
|
388
|
+
color: theme("colors.dataGridPrimary");
|
|
192
389
|
}
|
|
193
390
|
}
|
|
194
391
|
|
|
195
392
|
&__toolbar-tabs {
|
|
196
|
-
|
|
393
|
+
align-self: stretch;
|
|
394
|
+
display: flex;
|
|
395
|
+
flex: 1;
|
|
197
396
|
|
|
198
397
|
&-nav {
|
|
199
398
|
&--desktop {
|
|
200
|
-
@apply
|
|
399
|
+
@apply space-x-4;
|
|
201
400
|
|
|
202
|
-
|
|
203
|
-
|
|
401
|
+
display: none;
|
|
402
|
+
margin-bottom: -1px;
|
|
403
|
+
|
|
404
|
+
@screen md {
|
|
405
|
+
display: flex;
|
|
204
406
|
}
|
|
205
407
|
}
|
|
206
408
|
|
|
207
409
|
&--mobile {
|
|
208
|
-
|
|
410
|
+
align-items: center;
|
|
411
|
+
display: flex;
|
|
412
|
+
width: max-content;
|
|
413
|
+
z-index: theme("zIndex.10");
|
|
209
414
|
|
|
210
|
-
@
|
|
211
|
-
|
|
415
|
+
@screen md {
|
|
416
|
+
display: none;
|
|
212
417
|
}
|
|
213
418
|
|
|
214
419
|
.uxf-data-grid__toolbar-tabs-button {
|
|
215
|
-
|
|
420
|
+
align-items: center;
|
|
421
|
+
display: flex;
|
|
422
|
+
margin: 0;
|
|
216
423
|
|
|
217
424
|
&-icon {
|
|
218
|
-
|
|
425
|
+
color: theme("colors.lightHigh");
|
|
426
|
+
margin-left: theme("spacing.1");
|
|
427
|
+
|
|
428
|
+
:root .dark & {
|
|
429
|
+
color: theme("colors.darkHigh");
|
|
430
|
+
}
|
|
219
431
|
}
|
|
220
432
|
}
|
|
221
433
|
}
|
|
222
434
|
|
|
223
435
|
&-text {
|
|
224
|
-
|
|
436
|
+
color: theme("colors.lightHigh");
|
|
437
|
+
|
|
438
|
+
:root .dark & {
|
|
439
|
+
color: theme("colors.darkHigh");
|
|
440
|
+
}
|
|
225
441
|
}
|
|
226
442
|
}
|
|
227
443
|
|
|
228
444
|
&-modal-content {
|
|
229
|
-
@apply
|
|
445
|
+
@apply divide-y divide-lightBorder dark:divide-darkBorder;
|
|
446
|
+
|
|
447
|
+
align-items: flex-start;
|
|
448
|
+
display: flex;
|
|
449
|
+
flex-direction: column;
|
|
450
|
+
padding-bottom: theme("spacing.4");
|
|
451
|
+
padding-top: theme("spacing.1");
|
|
452
|
+
text-align: left;
|
|
230
453
|
}
|
|
231
454
|
|
|
232
455
|
&-modal-button {
|
|
233
|
-
|
|
456
|
+
border-radius: 0;
|
|
457
|
+
justify-content: flex-start;
|
|
458
|
+
width: 100%;
|
|
234
459
|
}
|
|
235
460
|
|
|
236
461
|
&-modal-button-text {
|
|
237
|
-
|
|
462
|
+
color: theme("colors.lightHigh");
|
|
463
|
+
|
|
464
|
+
:root .dark & {
|
|
465
|
+
color: theme("colors.darkHigh");
|
|
466
|
+
}
|
|
238
467
|
}
|
|
239
468
|
|
|
240
469
|
&-modal-active-tab-icon {
|
|
241
|
-
|
|
470
|
+
color: theme("colors.lightMedium");
|
|
471
|
+
margin-right: theme("spacing.3");
|
|
472
|
+
|
|
473
|
+
:root .dark & {
|
|
474
|
+
color: theme("colors.darkMedium");
|
|
475
|
+
}
|
|
242
476
|
}
|
|
243
477
|
}
|
|
244
478
|
|
|
245
479
|
&__toolbar-control {
|
|
246
|
-
|
|
480
|
+
align-items: center;
|
|
481
|
+
display: flex;
|
|
482
|
+
flex-direction: row;
|
|
483
|
+
gap: theme("spacing.2");
|
|
484
|
+
justify-content: space-between;
|
|
485
|
+
order: 3;
|
|
486
|
+
width: 100%;
|
|
487
|
+
|
|
488
|
+
@screen xs {
|
|
489
|
+
order: 2;
|
|
490
|
+
width: auto;
|
|
491
|
+
}
|
|
247
492
|
}
|
|
248
493
|
|
|
249
494
|
&__toolbar-customs {
|
|
250
|
-
|
|
495
|
+
align-items: center;
|
|
496
|
+
display: flex;
|
|
497
|
+
flex-direction: row;
|
|
498
|
+
gap: theme("spacing.2");
|
|
499
|
+
order: 2;
|
|
500
|
+
|
|
501
|
+
@screen xs {
|
|
502
|
+
order: 2;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
@screen md {
|
|
506
|
+
margin-block: theme("spacing.2");
|
|
507
|
+
}
|
|
251
508
|
|
|
252
509
|
&-mobile {
|
|
253
|
-
|
|
510
|
+
display: flex;
|
|
511
|
+
|
|
512
|
+
@screen md {
|
|
513
|
+
display: none;
|
|
514
|
+
}
|
|
254
515
|
}
|
|
255
516
|
|
|
256
517
|
&-desktop {
|
|
257
|
-
|
|
518
|
+
display: none;
|
|
519
|
+
|
|
520
|
+
@screen md {
|
|
521
|
+
display: flex;
|
|
522
|
+
gap: theme("spacing.2");
|
|
523
|
+
}
|
|
258
524
|
}
|
|
259
525
|
}
|
|
260
526
|
}
|
|
261
527
|
|
|
262
528
|
.rdg-cell.action {
|
|
263
|
-
text-align: right;
|
|
264
|
-
border-right: 0;
|
|
265
529
|
align-items: center;
|
|
530
|
+
border-right: 0;
|
|
531
|
+
box-shadow: -3px 0 15px rgba(221 221 221 / 50%);
|
|
266
532
|
display: flex;
|
|
267
533
|
justify-content: center;
|
|
268
534
|
position: sticky;
|
|
269
|
-
box-shadow: -3px 0 15px rgba(221 221 221 / 50%);
|
|
270
535
|
right: 0;
|
|
536
|
+
text-align: right;
|
|
271
537
|
}
|
|
272
538
|
|
|
273
539
|
.rdg-header-row {
|
|
274
|
-
|
|
540
|
+
color: theme("colors.lightLow");
|
|
541
|
+
font-weight: theme("fontWeight.normal");
|
|
542
|
+
|
|
543
|
+
:root .dark & {
|
|
544
|
+
color: theme("colors.darkLow");
|
|
545
|
+
}
|
|
275
546
|
|
|
276
547
|
.rdg-cell {
|
|
277
|
-
|
|
548
|
+
background-color: var(--rdg-header-background-color);
|
|
278
549
|
|
|
279
|
-
|
|
280
|
-
|
|
550
|
+
:root .dark & {
|
|
551
|
+
color: theme("colors.darkMedium");
|
|
552
|
+
}
|
|
281
553
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
}
|
|
554
|
+
&:not(:first-child) {
|
|
555
|
+
border-inline-start: 1px solid var(--rdg-border-color);
|
|
285
556
|
}
|
|
286
557
|
}
|
|
287
558
|
}
|
|
288
559
|
|
|
289
560
|
.rdg-header-sort-name + span {
|
|
290
|
-
display: flex;
|
|
291
561
|
align-items: center;
|
|
562
|
+
display: flex;
|
|
292
563
|
}
|
|
293
564
|
|
|
294
565
|
.rdg-cell {
|
|
566
|
+
border-block-end-width: 1px;
|
|
567
|
+
border-color: var(--rdg-border-color);
|
|
295
568
|
border-inline-end: none;
|
|
296
569
|
|
|
297
570
|
&.rdg-cell-frozen {
|
|
298
571
|
box-shadow: none;
|
|
299
572
|
}
|
|
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
573
|
}
|
|
337
574
|
|
|
338
575
|
@keyframes datagridlineanim {
|
|
@@ -349,4 +586,4 @@
|
|
|
349
586
|
left: 100%;
|
|
350
587
|
width: 100%;
|
|
351
588
|
}
|
|
352
|
-
}
|
|
589
|
+
}
|
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;
|