@uxf/data-grid 11.0.0-beta.2 → 11.0.0-beta.20
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/_generator/cli.js +29 -0
- package/_generator/index.js +40 -0
- package/_store/reducer.d.ts +2 -2
- package/_store/reducer.js +32 -19
- package/_story-utils/grid-type.d.ts +2 -0
- package/_story-utils/loader.js +1 -1
- package/_story-utils/schema.js +12 -0
- package/bin/uxf-data-grid-generator.js +8 -0
- package/data-grid.js +7 -8
- package/data-grid.stories.js +34 -3
- package/filter-handler/date.d.ts +3 -0
- package/filter-handler/date.js +43 -0
- package/filter-handler/index.js +4 -0
- package/filter-handler/multi-select.d.ts +3 -0
- package/filter-handler/multi-select.js +29 -0
- package/hidden-columns/hidden-columns.js +2 -4
- package/package.json +8 -3
- package/pagination/pagination.d.ts +1 -1
- package/pagination/pagination.js +2 -2
- package/pagination/pagination.stories.js +1 -1
- package/row-counts/row-counts.d.ts +1 -0
- package/row-counts/row-counts.js +7 -1
- package/row-counts/row-counts.stories.js +1 -1
- package/selected-rows-toolbar/selected-rows-toolbar.js +1 -1
- package/selected-rows-toolbar/selected-rows-toolbar.stories.js +4 -1
- package/styles.css +605 -0
- package/table/components/action-cell-wrapper.d.ts +2 -0
- package/table/components/{action-cell-base.js → action-cell-wrapper.js} +3 -29
- package/table/components/action-cell.d.ts +7 -0
- package/table/components/action-cell.js +14 -0
- package/{hooks → table/hooks}/use-rdg-visuals.d.ts +2 -2
- package/{hooks → table/hooks}/use-rdg-visuals.js +2 -2
- package/table/hooks/use-react-data-grid-columns.d.ts +2 -1
- package/table/hooks/use-react-data-grid-columns.js +21 -29
- package/table/index.d.ts +2 -0
- package/table/index.js +2 -0
- package/table/table.d.ts +1 -1
- package/table/table.js +15 -7
- package/table/table.stories.js +1 -1
- package/table/types.d.ts +10 -12
- package/toolbar-control/toolbar-control.js +2 -2
- package/types/components.d.ts +0 -5
- package/types/data-grid-props.d.ts +13 -12
- package/types/index.d.ts +0 -1
- package/types/index.js +0 -1
- package/types/state.d.ts +6 -3
- package/use-data-grid-control/use-data-grid-control.d.ts +3 -1
- package/use-data-grid-control/use-data-grid-control.js +1 -1
- package/use-data-grid-fetching/use-data-grid-fetching.d.ts +7 -1
- package/use-data-grid-fetching/use-data-grid-fetching.js +3 -1
- package/table/components/action-cell-base.d.ts +0 -4
- package/types/ui-components.d.ts +0 -18
- package/types/ui-components.js +0 -2
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const { argv, env } = require("process");
|
|
2
|
+
|
|
3
|
+
module.exports = async () => {
|
|
4
|
+
const cli = require("yargs")
|
|
5
|
+
.command("$0", "UXF DataGrid generator", (yargs) => {
|
|
6
|
+
yargs.demandCommand(0, 0).usage(`
|
|
7
|
+
Usage:
|
|
8
|
+
uxf-data-grid-generator [options]
|
|
9
|
+
`);
|
|
10
|
+
})
|
|
11
|
+
.option("s", { alias: "schemaDirectory" })
|
|
12
|
+
.option("o", { alias: "outputDirectory" })
|
|
13
|
+
.option("h", { alias: "help", group: "Options" })
|
|
14
|
+
.strict(false)
|
|
15
|
+
.exitProcess(false);
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
const { help, schemaDirectory, outputDirectory } = cli.parse(argv.slice(2));
|
|
19
|
+
|
|
20
|
+
if (Boolean(help)) {
|
|
21
|
+
return 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
await require("./index")(schemaDirectory, outputDirectory);
|
|
25
|
+
} catch (e) {
|
|
26
|
+
console.error(e);
|
|
27
|
+
return 1;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const { globSync } = require("fast-glob");
|
|
2
|
+
const { readFileSync, writeFileSync, mkdirSync } = require("fs");
|
|
3
|
+
const { dirname, relative, parse, join } = require("path");
|
|
4
|
+
|
|
5
|
+
function camelize(value) {
|
|
6
|
+
return value
|
|
7
|
+
.split("-")
|
|
8
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
9
|
+
.join("");
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function writeFile(filename, value) {
|
|
13
|
+
mkdirSync(dirname(filename), { recursive: true });
|
|
14
|
+
writeFileSync(filename, value);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function generateSchemaFile(gridName, schemaRelativeImport) {
|
|
18
|
+
return `import { Schema } from "@uxf/data-grid";
|
|
19
|
+
import json from "${schemaRelativeImport}";
|
|
20
|
+
|
|
21
|
+
export const dataGridSchema_${camelize(gridName)}: Schema<any> = json as any;`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function generate(jsonSchema, filename, outputDirectory) {
|
|
25
|
+
const gridName = parse(filename).name;
|
|
26
|
+
const generatedPath = join(process.cwd(), outputDirectory, gridName);
|
|
27
|
+
|
|
28
|
+
const generatedSchemaFilename = `${generatedPath}/schema.ts`;
|
|
29
|
+
|
|
30
|
+
writeFile(
|
|
31
|
+
generatedSchemaFilename,
|
|
32
|
+
generateSchemaFile(gridName, relative(dirname(generatedSchemaFilename), filename)),
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
module.exports = (schemaDirectory, outputDirectory) => {
|
|
37
|
+
globSync(schemaDirectory + "/*.json")
|
|
38
|
+
.map((path) => process.cwd() + "/" + path)
|
|
39
|
+
.forEach((filename) => generate(readFileSync(filename), filename, outputDirectory));
|
|
40
|
+
};
|
package/_store/reducer.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Nullish } from "@uxf/core/types";
|
|
|
2
2
|
import { Reducer } from "react";
|
|
3
3
|
import { Request } from "../types/api";
|
|
4
4
|
import { Schema } from "../types/schema";
|
|
5
|
-
import { DataGridState } from "../types/state";
|
|
6
|
-
export declare const getInitialState: (schema: Schema<any>, init?: Request | string | Nullish) => DataGridState;
|
|
5
|
+
import { DataGridState, DataGridUserConfig } from "../types/state";
|
|
6
|
+
export declare const getInitialState: (schema: Schema<any>, init?: Request | string | Nullish, initialUserConfig?: DataGridUserConfig | Nullish) => DataGridState;
|
|
7
7
|
export declare const reducer: Reducer<DataGridState, any>;
|
|
8
8
|
export declare const debugReducer: Reducer<DataGridState, any>;
|
package/_store/reducer.js
CHANGED
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.debugReducer = exports.reducer = exports.getInitialState = void 0;
|
|
4
4
|
const is_nil_1 = require("@uxf/core/utils/is-nil");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
|
-
const getInitialState = (schema, init) => {
|
|
7
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
6
|
+
const getInitialState = (schema, init, initialUserConfig) => {
|
|
7
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
8
8
|
const initialState = (0, is_nil_1.isNil)(init) ? {} : typeof init === "string" ? (_a = (0, utils_1.decodeFilter)(init)) !== null && _a !== void 0 ? _a : {} : init;
|
|
9
9
|
return {
|
|
10
10
|
request: {
|
|
@@ -12,18 +12,21 @@ const getInitialState = (schema, init) => {
|
|
|
12
12
|
page: (_c = initialState.page) !== null && _c !== void 0 ? _c : 0,
|
|
13
13
|
dir: (_d = initialState.dir) !== null && _d !== void 0 ? _d : schema.dir,
|
|
14
14
|
sort: (_e = initialState.sort) !== null && _e !== void 0 ? _e : schema.sort,
|
|
15
|
-
perPage: (_f = initialState.perPage) !== null && _f !== void 0 ? _f : schema.perPage,
|
|
16
|
-
tab: (
|
|
17
|
-
search: "",
|
|
15
|
+
perPage: (_g = (_f = initialState.perPage) !== null && _f !== void 0 ? _f : initialUserConfig === null || initialUserConfig === void 0 ? void 0 : initialUserConfig.perPage) !== null && _g !== void 0 ? _g : schema.perPage,
|
|
16
|
+
tab: (_l = (_h = initialState.tab) !== null && _h !== void 0 ? _h : (_k = (_j = schema.tabs) === null || _j === void 0 ? void 0 : _j[0]) === null || _k === void 0 ? void 0 : _k.name) !== null && _l !== void 0 ? _l : null,
|
|
17
|
+
search: (_m = initialState.search) !== null && _m !== void 0 ? _m : "",
|
|
18
|
+
},
|
|
19
|
+
userConfig: {
|
|
20
|
+
columns: (_o = initialUserConfig === null || initialUserConfig === void 0 ? void 0 : initialUserConfig.columns) !== null && _o !== void 0 ? _o : {},
|
|
21
|
+
perPage: (_p = initialUserConfig === null || initialUserConfig === void 0 ? void 0 : initialUserConfig.perPage) !== null && _p !== void 0 ? _p : schema.perPage,
|
|
18
22
|
},
|
|
19
|
-
columnConfig: {},
|
|
20
23
|
tabRequests: {},
|
|
21
24
|
};
|
|
22
25
|
};
|
|
23
26
|
exports.getInitialState = getInitialState;
|
|
24
27
|
// eslint-disable-next-line complexity
|
|
25
28
|
const reducer = (state, action) => {
|
|
26
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
29
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
27
30
|
switch (action.type) {
|
|
28
31
|
case "CHANGE_PAGE":
|
|
29
32
|
return {
|
|
@@ -40,6 +43,10 @@ const reducer = (state, action) => {
|
|
|
40
43
|
...state.request,
|
|
41
44
|
perPage: action.perPage,
|
|
42
45
|
},
|
|
46
|
+
userConfig: {
|
|
47
|
+
...state.userConfig,
|
|
48
|
+
perPage: action.perPage,
|
|
49
|
+
},
|
|
43
50
|
};
|
|
44
51
|
case "FILTER":
|
|
45
52
|
// eslint-disable-next-line no-case-declarations
|
|
@@ -121,24 +128,30 @@ const reducer = (state, action) => {
|
|
|
121
128
|
case "HIDE_COLUMN":
|
|
122
129
|
return {
|
|
123
130
|
...state,
|
|
124
|
-
|
|
125
|
-
...state.
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
131
|
+
userConfig: {
|
|
132
|
+
...state.userConfig,
|
|
133
|
+
columns: {
|
|
134
|
+
...state.userConfig.columns,
|
|
135
|
+
[action.name]: {
|
|
136
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
137
|
+
...((_k = (_j = state.userConfig.columns) === null || _j === void 0 ? void 0 : _j[action.name]) !== null && _k !== void 0 ? _k : {}),
|
|
138
|
+
isHidden: true,
|
|
139
|
+
},
|
|
130
140
|
},
|
|
131
141
|
},
|
|
132
142
|
};
|
|
133
143
|
case "SHOW_COLUMN":
|
|
134
144
|
return {
|
|
135
145
|
...state,
|
|
136
|
-
|
|
137
|
-
...state.
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
146
|
+
userConfig: {
|
|
147
|
+
...state.userConfig,
|
|
148
|
+
columns: {
|
|
149
|
+
...state.userConfig.columns,
|
|
150
|
+
[action.name]: {
|
|
151
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
152
|
+
...((_m = (_l = state.userConfig.columns) === null || _l === void 0 ? void 0 : _l[action.name]) !== null && _m !== void 0 ? _m : {}),
|
|
153
|
+
isHidden: false,
|
|
154
|
+
},
|
|
142
155
|
},
|
|
143
156
|
},
|
|
144
157
|
};
|
|
@@ -12,11 +12,13 @@ export type GridType = {
|
|
|
12
12
|
filters: {
|
|
13
13
|
text: "text";
|
|
14
14
|
bool: "boolean";
|
|
15
|
+
date: "date";
|
|
15
16
|
ival: "interval";
|
|
16
17
|
tel: "string";
|
|
17
18
|
mail: "string";
|
|
18
19
|
link: "string";
|
|
19
20
|
sele: "select";
|
|
20
21
|
seleBool: "select";
|
|
22
|
+
multiSelect: "multiSelect";
|
|
21
23
|
};
|
|
22
24
|
};
|
package/_story-utils/loader.js
CHANGED
|
@@ -29,7 +29,7 @@ const loader = async (_, request) => {
|
|
|
29
29
|
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
30
30
|
return {
|
|
31
31
|
count: filteredData.length,
|
|
32
|
-
totalCount:
|
|
32
|
+
totalCount: data_1.data.length,
|
|
33
33
|
result: filteredData.slice(page * perPage, page * perPage + perPage),
|
|
34
34
|
};
|
|
35
35
|
};
|
package/_story-utils/schema.js
CHANGED
|
@@ -18,6 +18,7 @@ exports.schema = {
|
|
|
18
18
|
{ name: "bool", type: "boolean", label: "Boolean" },
|
|
19
19
|
{ name: "ival", type: "interval", label: "Super interval" },
|
|
20
20
|
{ name: "mail", type: "string", label: "E-mail" },
|
|
21
|
+
{ name: "date", type: "date", label: "Date" },
|
|
21
22
|
{ name: "tel", type: "string", label: "Phone" },
|
|
22
23
|
{ name: "link", type: "string", label: "Link" },
|
|
23
24
|
{
|
|
@@ -30,6 +31,17 @@ exports.schema = {
|
|
|
30
31
|
{ id: 2, label: "B" },
|
|
31
32
|
],
|
|
32
33
|
},
|
|
34
|
+
{
|
|
35
|
+
name: "multiSelect",
|
|
36
|
+
label: "Multi select",
|
|
37
|
+
type: "multiSelect",
|
|
38
|
+
options: [
|
|
39
|
+
{ label: "Option 1", id: "option-1" },
|
|
40
|
+
{ label: "Option 2", id: "option-2" },
|
|
41
|
+
{ label: "Option 3", id: "option-3" },
|
|
42
|
+
{ label: "Option 4", id: "option-4" },
|
|
43
|
+
],
|
|
44
|
+
},
|
|
33
45
|
{
|
|
34
46
|
name: "seleBool",
|
|
35
47
|
type: "select",
|
package/data-grid.js
CHANGED
|
@@ -15,7 +15,6 @@ const row_counts_1 = require("./row-counts");
|
|
|
15
15
|
const rows_per_page_select_1 = require("./rows-per-page-select");
|
|
16
16
|
const selected_rows_toolbar_1 = require("./selected-rows-toolbar");
|
|
17
17
|
const table_1 = require("./table");
|
|
18
|
-
const action_cell_base_1 = require("./table/components/action-cell-base");
|
|
19
18
|
const no_rows_fallback_1 = require("./table/no-rows-fallback");
|
|
20
19
|
const toolbar_control_1 = require("./toolbar-control");
|
|
21
20
|
const toolbar_customs_1 = require("./toolbar-customs");
|
|
@@ -23,20 +22,20 @@ const toolbar_tabs_1 = require("./toolbar-tabs");
|
|
|
23
22
|
const classes_1 = require("./utils/classes");
|
|
24
23
|
const DefaultSelectedRowsToolbarActions = () => null;
|
|
25
24
|
function DataGrid(props) {
|
|
26
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o
|
|
25
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
27
26
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
28
27
|
react_1.default.createElement("div", { className: (0, cx_1.cx)("uxf-data-grid", props.noBorder && classes_1.NO_BORDER_CLASS, props.className) },
|
|
29
28
|
react_1.default.createElement("div", { className: (0, cx_1.cx)("uxf-data-grid__toolbar", props.noBorder && classes_1.NO_BORDER_CLASS) },
|
|
30
29
|
react_1.default.createElement(toolbar_tabs_1.ToolbarTabs, { state: props.state, actions: props.actions, schema: props.schema }),
|
|
31
|
-
react_1.default.createElement(toolbar_control_1.ToolbarControl, { state: props.state, actions: props.actions, gridName: props.gridName, filterHandlers: (
|
|
30
|
+
react_1.default.createElement(toolbar_control_1.ToolbarControl, { state: props.state, actions: props.actions, gridName: props.gridName, filterHandlers: (_a = props.filterHandlers) !== null && _a !== void 0 ? _a : filter_handler_1.defaultFilterHandlers, schema: props.schema, onCsvDownload: props.onCsvDownload }),
|
|
32
31
|
react_1.default.createElement(toolbar_customs_1.ToolbarCustoms, { buttons: props.customActions })),
|
|
33
32
|
react_1.default.createElement(linear_progress_1.LinearProgress, { isLoading: props.isLoading }),
|
|
34
|
-
react_1.default.createElement(filter_list_1.FilterList, { state: props.state, actions: props.actions, schema: props.schema, gridName: props.gridName, filterHandlers: (
|
|
35
|
-
react_1.default.createElement(table_1.Table, { state: props.state, actions: props.actions, schema: props.schema, data: (
|
|
33
|
+
react_1.default.createElement(filter_list_1.FilterList, { state: props.state, actions: props.actions, schema: props.schema, gridName: props.gridName, filterHandlers: (_b = props.filterHandlers) !== null && _b !== void 0 ? _b : filter_handler_1.defaultFilterHandlers, className: props.noBorder ? classes_1.NO_BORDER_CLASS : undefined }),
|
|
34
|
+
react_1.default.createElement(table_1.Table, { state: props.state, actions: props.actions, schema: props.schema, data: (_d = (_c = props.data) === null || _c === void 0 ? void 0 : _c.result) !== null && _d !== void 0 ? _d : [], isLoading: props.isLoading, error: props.error, rowClass: props.rowClass, keyExtractor: props.keyExtractor, rowHeight: props.rowHeight, headerRowHeight: props.headerRowHeight, bodyCells: (_e = props.bodyCells) !== null && _e !== void 0 ? _e : body_cell_1.BodyCells, NoRowsFallback: (_f = props.NoRowsFallback) !== null && _f !== void 0 ? _f : no_rows_fallback_1.NoRowsFallback, actionCell: props.actionCell, onReload: props.onReload, isRowSelectable: props.isRowSelectable }),
|
|
36
35
|
react_1.default.createElement("div", { className: (0, cx_1.cx)("uxf-data-grid__footer", props.noBorder && classes_1.NO_BORDER_CLASS) },
|
|
37
36
|
react_1.default.createElement(rows_per_page_select_1.RowsPerPageSelect, { state: props.state, actions: props.actions }),
|
|
38
|
-
react_1.default.createElement(row_counts_1.RowCounts, { state: props.state,
|
|
39
|
-
react_1.default.createElement(pagination_1.Pagination, { state: props.state, actions: props.actions,
|
|
40
|
-
react_1.default.createElement(selected_rows_toolbar_1.SelectedRowsToolbar, { state: props.state, actions: props.actions, Actions: (
|
|
37
|
+
react_1.default.createElement(row_counts_1.RowCounts, { state: props.state, count: (_h = (_g = props.data) === null || _g === void 0 ? void 0 : _g.count) !== null && _h !== void 0 ? _h : 0, totalCount: (_k = (_j = props.data) === null || _j === void 0 ? void 0 : _j.totalCount) !== null && _k !== void 0 ? _k : 0 }),
|
|
38
|
+
react_1.default.createElement(pagination_1.Pagination, { state: props.state, actions: props.actions, count: (_m = (_l = props.data) === null || _l === void 0 ? void 0 : _l.count) !== null && _m !== void 0 ? _m : 0 }))),
|
|
39
|
+
react_1.default.createElement(selected_rows_toolbar_1.SelectedRowsToolbar, { state: props.state, actions: props.actions, Actions: (_o = props.SelectedRowsToolbarActions) !== null && _o !== void 0 ? _o : DefaultSelectedRowsToolbarActions })));
|
|
41
40
|
}
|
|
42
41
|
exports.DataGrid = DataGrid;
|
package/data-grid.stories.js
CHANGED
|
@@ -24,21 +24,52 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.Default = void 0;
|
|
27
|
+
const buildArray_1 = require("@uxf/core/utils/buildArray");
|
|
27
28
|
const json_renderer_1 = require("@uxf/example/src/components/json-renderer");
|
|
28
29
|
const toggle_1 = require("@uxf/ui/toggle");
|
|
29
30
|
const react_1 = __importStar(require("react"));
|
|
30
31
|
const loader_1 = require("./_story-utils/loader");
|
|
31
32
|
const schema_1 = require("./_story-utils/schema");
|
|
32
33
|
const data_grid_1 = require("./data-grid");
|
|
34
|
+
const table_1 = require("./table");
|
|
33
35
|
const use_data_grid_control_1 = require("./use-data-grid-control");
|
|
34
36
|
const use_data_grid_fetching_1 = require("./use-data-grid-fetching");
|
|
35
37
|
function Default() {
|
|
36
38
|
const [noBorder, setNoBorder] = (0, react_1.useState)(false);
|
|
37
|
-
const { state, actions } = (0, use_data_grid_control_1.useDataGridControl)({
|
|
38
|
-
|
|
39
|
+
const { state, actions } = (0, use_data_grid_control_1.useDataGridControl)({
|
|
40
|
+
schema: schema_1.schema,
|
|
41
|
+
});
|
|
42
|
+
const { isLoading, error, data, onReload } = (0, use_data_grid_fetching_1.useDataGridFetching)({
|
|
43
|
+
loader: loader_1.loader,
|
|
44
|
+
schema: schema_1.schema,
|
|
45
|
+
gridName: "grid-name",
|
|
46
|
+
state,
|
|
47
|
+
});
|
|
39
48
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
40
49
|
react_1.default.createElement(toggle_1.Toggle, { label: "No border", value: noBorder, onChange: (value) => setNoBorder(!!value) }),
|
|
41
|
-
react_1.default.createElement(data_grid_1.DataGrid, { onReload: onReload, state: state, actions: actions, data: data, isLoading: isLoading, error: error, schema: schema_1.schema, onCsvDownload: console.log, noBorder: noBorder,
|
|
50
|
+
react_1.default.createElement(data_grid_1.DataGrid, { onReload: onReload, state: state, actions: actions, data: data, isLoading: isLoading, error: error, schema: schema_1.schema, onCsvDownload: console.log, noBorder: noBorder, isRowSelectable: true, actionCell: {
|
|
51
|
+
width: 100,
|
|
52
|
+
Component: () => {
|
|
53
|
+
const actionCellActions = (0, buildArray_1.buildArray)()
|
|
54
|
+
.add({
|
|
55
|
+
icon: "arrow-right",
|
|
56
|
+
isIconButton: true,
|
|
57
|
+
href: "https://www.uxf.cz",
|
|
58
|
+
target: "_blank",
|
|
59
|
+
})
|
|
60
|
+
.add({
|
|
61
|
+
icon: "file",
|
|
62
|
+
label: "Download",
|
|
63
|
+
onClick: console.log,
|
|
64
|
+
})
|
|
65
|
+
.add({
|
|
66
|
+
icon: "cloud",
|
|
67
|
+
label: "Reload",
|
|
68
|
+
onClick: console.log,
|
|
69
|
+
});
|
|
70
|
+
return react_1.default.createElement(table_1.ActionCell, { buttons: actionCellActions, visibleButtonsCount: 1 });
|
|
71
|
+
},
|
|
72
|
+
} }),
|
|
42
73
|
react_1.default.createElement(json_renderer_1.JsonRenderer, { value: state })));
|
|
43
74
|
}
|
|
44
75
|
exports.Default = Default;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const filter_nullish_1 = require("@uxf/core/utils/filter-nullish");
|
|
7
|
+
const is_nil_1 = require("@uxf/core/utils/is-nil");
|
|
8
|
+
const chip_1 = require("@uxf/ui/chip");
|
|
9
|
+
const date_picker_input_1 = require("@uxf/ui/date-picker-input");
|
|
10
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
11
|
+
const react_1 = __importDefault(require("react"));
|
|
12
|
+
const date = {
|
|
13
|
+
input: function (props) {
|
|
14
|
+
var _a, _b;
|
|
15
|
+
const initializedValue = typeof ((_a = props.value.value) === null || _a === void 0 ? void 0 : _a.from) !== "undefined" && typeof ((_b = props.value.value) === null || _b === void 0 ? void 0 : _b.to) !== "undefined"
|
|
16
|
+
? props.value
|
|
17
|
+
: { name: props.filter.name, value: { from: null, to: null } };
|
|
18
|
+
return (react_1.default.createElement("div", { className: "uxf-data-grid__filter uxf-data-grid__filter--date" },
|
|
19
|
+
react_1.default.createElement(date_picker_input_1.DatePickerInput, { value: initializedValue.value.from, onChange: (changedValue) => props.onFilter({
|
|
20
|
+
...initializedValue,
|
|
21
|
+
value: { ...initializedValue.value, from: changedValue },
|
|
22
|
+
}), label: `${props.filter.label} (od)` }),
|
|
23
|
+
react_1.default.createElement(date_picker_input_1.DatePickerInput, { value: initializedValue.value.to, onChange: (changedValue) => props.onFilter({ ...initializedValue, value: { ...initializedValue.value, to: changedValue } }), label: `${props.filter.label} (do)` })));
|
|
24
|
+
},
|
|
25
|
+
listItem: function (props) {
|
|
26
|
+
if ((0, is_nil_1.isNil)(props.value.value)) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
const value = props.value.value;
|
|
30
|
+
if ((0, is_nil_1.isNil)(value.from) && (0, is_nil_1.isNil)(value.to)) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
const formatDate = [
|
|
34
|
+
value.from ? "od " + (0, dayjs_1.default)(value.from).format("l") : "",
|
|
35
|
+
value.to ? "do " + (0, dayjs_1.default)(value.to).format("l") : "",
|
|
36
|
+
];
|
|
37
|
+
return (react_1.default.createElement(chip_1.Chip, { onClose: () => props.onFilter({ ...props.value, value: undefined }) },
|
|
38
|
+
props.filter.label,
|
|
39
|
+
" ",
|
|
40
|
+
(0, filter_nullish_1.filterNullish)(formatDate).join(" ")));
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
exports.default = date;
|
package/filter-handler/index.js
CHANGED
|
@@ -20,16 +20,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
20
20
|
exports.defaultFilterHandlers = void 0;
|
|
21
21
|
const bool_filter_1 = __importDefault(require("./bool-filter"));
|
|
22
22
|
const boolean_filter_1 = __importDefault(require("./boolean-filter"));
|
|
23
|
+
const date_1 = __importDefault(require("./date"));
|
|
23
24
|
const interval_filter_1 = __importDefault(require("./interval-filter"));
|
|
25
|
+
const multi_select_1 = __importDefault(require("./multi-select"));
|
|
24
26
|
const select_filter_1 = __importDefault(require("./select-filter"));
|
|
25
27
|
const text_filter_1 = __importDefault(require("./text-filter"));
|
|
26
28
|
__exportStar(require("./types"), exports);
|
|
27
29
|
exports.defaultFilterHandlers = {
|
|
28
30
|
text: text_filter_1.default,
|
|
29
31
|
string: text_filter_1.default,
|
|
32
|
+
date: date_1.default,
|
|
30
33
|
bool: bool_filter_1.default,
|
|
31
34
|
boolean: boolean_filter_1.default,
|
|
32
35
|
checkbox: boolean_filter_1.default,
|
|
33
36
|
interval: interval_filter_1.default,
|
|
37
|
+
multiSelect: multi_select_1.default,
|
|
34
38
|
select: select_filter_1.default,
|
|
35
39
|
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const is_nil_1 = require("@uxf/core/utils/is-nil");
|
|
7
|
+
const chip_1 = require("@uxf/ui/chip");
|
|
8
|
+
const multi_select_1 = require("@uxf/ui/multi-select");
|
|
9
|
+
const react_1 = __importDefault(require("react"));
|
|
10
|
+
const multiSelect = {
|
|
11
|
+
input: (props) => {
|
|
12
|
+
var _a, _b;
|
|
13
|
+
return (react_1.default.createElement(multi_select_1.MultiSelect, { options: (_a = props.filter.options) !== null && _a !== void 0 ? _a : [], label: props.filter.label, value: (_b = props.value.value) === null || _b === void 0 ? void 0 : _b.map((id) => { var _a; return (_a = props.filter.options) === null || _a === void 0 ? void 0 : _a.find((option) => option.id === id); }), onChange: (value) => {
|
|
14
|
+
props.onFilter({
|
|
15
|
+
...props.value,
|
|
16
|
+
value: (0, is_nil_1.isNil)(value) || value.length === 0 ? null : value.map((item) => item.id),
|
|
17
|
+
});
|
|
18
|
+
} }));
|
|
19
|
+
},
|
|
20
|
+
listItem: (props) => {
|
|
21
|
+
return (react_1.default.createElement(chip_1.Chip, { onClose: props.onClear },
|
|
22
|
+
props.filter.label,
|
|
23
|
+
":\u00A0",
|
|
24
|
+
props.value.value
|
|
25
|
+
.map((id) => { var _a, _b; return (_b = (_a = props.filter.options) === null || _a === void 0 ? void 0 : _a.find((option) => option.id === id)) === null || _b === void 0 ? void 0 : _b.label; })
|
|
26
|
+
.join(", ")));
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
exports.default = multiSelect;
|
|
@@ -8,10 +8,8 @@ const toggle_1 = require("@uxf/ui/toggle");
|
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
9
|
function HiddenColumns(props) {
|
|
10
10
|
return (react_1.default.createElement("div", { className: "uxf-data-grid__toolbar-control-columns" }, props.schema.columns.map((column) => {
|
|
11
|
-
var _a;
|
|
12
|
-
return (react_1.default.createElement(toggle_1.Toggle, { key: column.name, label: typeof column.label === "string" ? column.label : "",
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
14
|
-
value: !((_a = props.state.columnConfig[column.name]) === null || _a === void 0 ? void 0 : _a.isHidden), onChange: (value) => value ? props.actions.showColumn(column.name) : props.actions.hideColumn(column.name) }));
|
|
11
|
+
var _a, _b;
|
|
12
|
+
return (react_1.default.createElement(toggle_1.Toggle, { key: column.name, label: typeof column.label === "string" ? column.label : "", value: !((_b = (_a = props.state.userConfig.columns) === null || _a === void 0 ? void 0 : _a[column.name]) === null || _b === void 0 ? void 0 : _b.isHidden), onChange: (value) => value ? props.actions.showColumn(column.name) : props.actions.hideColumn(column.name) }));
|
|
15
13
|
})));
|
|
16
14
|
}
|
|
17
15
|
exports.HiddenColumns = HiddenColumns;
|
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uxf/data-grid",
|
|
3
|
-
"version": "11.0.0-beta.
|
|
3
|
+
"version": "11.0.0-beta.20",
|
|
4
4
|
"description": "UXF DataGrid",
|
|
5
5
|
"homepage": "https://gitlab.com/uxf-npm/data-grid#readme",
|
|
6
6
|
"main": "index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"uxf-data-grid-generator": "bin/uxf-data-grid-generator.js"
|
|
9
|
+
},
|
|
7
10
|
"typings": "index.d.ts",
|
|
8
11
|
"publishConfig": {
|
|
9
12
|
"access": "public"
|
|
@@ -27,9 +30,11 @@
|
|
|
27
30
|
"typecheck": "tsc --noEmit --skipLibCheck"
|
|
28
31
|
},
|
|
29
32
|
"dependencies": {
|
|
30
|
-
"@uxf/ui": "
|
|
33
|
+
"@uxf/ui": "11.0.0-beta.17",
|
|
31
34
|
"dayjs": "1.11.10",
|
|
32
|
-
"
|
|
35
|
+
"fast-glob": "^3.3.2",
|
|
36
|
+
"react-data-grid": "7.0.0-beta.39",
|
|
37
|
+
"yargs": "^17.7.2"
|
|
33
38
|
},
|
|
34
39
|
"peerDependencies": {
|
|
35
40
|
"react": ">=18.2.0",
|
|
@@ -2,7 +2,7 @@ import { Nullish } from "@uxf/core/types";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { DataGridControl } from "../use-data-grid-control";
|
|
4
4
|
interface PaginationProps extends DataGridControl {
|
|
5
|
-
|
|
5
|
+
count: number | Nullish;
|
|
6
6
|
}
|
|
7
7
|
export declare function Pagination(props: PaginationProps): React.JSX.Element;
|
|
8
8
|
export {};
|
package/pagination/pagination.js
CHANGED
|
@@ -8,8 +8,8 @@ const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
|
|
|
8
8
|
const pagination_1 = require("@uxf/ui/pagination");
|
|
9
9
|
const react_1 = __importDefault(require("react"));
|
|
10
10
|
function Pagination(props) {
|
|
11
|
-
const pageCount = (0, is_not_nil_1.isNotNil)(props.
|
|
12
|
-
? Math.max(Math.ceil(props.
|
|
11
|
+
const pageCount = (0, is_not_nil_1.isNotNil)(props.count) && props.count > 0
|
|
12
|
+
? Math.max(Math.ceil(props.count / props.state.request.perPage), 1)
|
|
13
13
|
: 1;
|
|
14
14
|
return (react_1.default.createElement(pagination_1.Pagination, { count: pageCount, page: props.state.request.page + 1, onPageChange: (value) => props.actions.changePage(value - 1) }));
|
|
15
15
|
}
|
|
@@ -12,7 +12,7 @@ const pagination_1 = require("./pagination");
|
|
|
12
12
|
function Default() {
|
|
13
13
|
const { state, actions } = (0, use_data_grid_control_1.useDataGridControl)({ schema: schema_1.schema });
|
|
14
14
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
15
|
-
react_1.default.createElement(pagination_1.Pagination, { state: state, actions: actions,
|
|
15
|
+
react_1.default.createElement(pagination_1.Pagination, { state: state, actions: actions, count: 100 }),
|
|
16
16
|
react_1.default.createElement(json_renderer_1.JsonRenderer, { value: state })));
|
|
17
17
|
}
|
|
18
18
|
exports.Default = Default;
|
package/row-counts/row-counts.js
CHANGED
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.RowCounts = void 0;
|
|
7
|
+
const show_1 = require("@uxf/core/components/show");
|
|
7
8
|
const react_1 = __importDefault(require("react"));
|
|
8
9
|
function RowCounts(props) {
|
|
9
10
|
const fromNumber = props.state.request.page * props.state.request.perPage + 1;
|
|
@@ -13,6 +14,11 @@ function RowCounts(props) {
|
|
|
13
14
|
"-",
|
|
14
15
|
toNumber,
|
|
15
16
|
" z ",
|
|
16
|
-
props.
|
|
17
|
+
props.count,
|
|
18
|
+
" ",
|
|
19
|
+
react_1.default.createElement(show_1.Show, { when: props.count !== props.totalCount },
|
|
20
|
+
"(celkem ",
|
|
21
|
+
props.totalCount,
|
|
22
|
+
")")));
|
|
17
23
|
}
|
|
18
24
|
exports.RowCounts = RowCounts;
|
|
@@ -10,6 +10,6 @@ const use_data_grid_control_1 = require("../use-data-grid-control");
|
|
|
10
10
|
const row_counts_1 = require("./row-counts");
|
|
11
11
|
function Default() {
|
|
12
12
|
const { state } = (0, use_data_grid_control_1.useDataGridControl)({ schema: schema_1.schema });
|
|
13
|
-
return react_1.default.createElement(row_counts_1.RowCounts, { state: state, totalCount: 150 });
|
|
13
|
+
return react_1.default.createElement(row_counts_1.RowCounts, { state: state, totalCount: 150, count: 100 });
|
|
14
14
|
}
|
|
15
15
|
exports.Default = Default;
|
|
@@ -27,6 +27,6 @@ function SelectedRowsToolbar(props) {
|
|
|
27
27
|
react_1.default.createElement("p", null, getText(props.state.selectedRows.length)),
|
|
28
28
|
react_1.default.createElement("div", { className: "uxf-data-grid__selected-rows-toolbar-actions" },
|
|
29
29
|
props.Actions && (react_1.default.createElement(props.Actions, { state: props.state, actions: props.actions, reload: () => { var _a; return (_a = props.onReload) === null || _a === void 0 ? void 0 : _a.call(props); } })),
|
|
30
|
-
react_1.default.createElement(button_1.Button, { onClick: () => props.actions.setSelectedRows([]) }, "
|
|
30
|
+
react_1.default.createElement(button_1.Button, { onClick: () => props.actions.setSelectedRows([]) }, "Zru\u0161it v\u00FDb\u011Br")))));
|
|
31
31
|
}
|
|
32
32
|
exports.SelectedRowsToolbar = SelectedRowsToolbar;
|
|
@@ -25,6 +25,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.Default = void 0;
|
|
27
27
|
const json_renderer_1 = require("@uxf/example/src/components/json-renderer");
|
|
28
|
+
const button_1 = require("@uxf/ui/button");
|
|
29
|
+
const icon_1 = require("@uxf/ui/icon");
|
|
28
30
|
const react_1 = __importStar(require("react"));
|
|
29
31
|
const schema_1 = require("../_story-utils/schema");
|
|
30
32
|
const use_data_grid_control_1 = require("../use-data-grid-control");
|
|
@@ -35,7 +37,8 @@ function Default() {
|
|
|
35
37
|
actions.setSelectedRows([{ id: 1 }, { id: 2 }]);
|
|
36
38
|
}, [actions]);
|
|
37
39
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
38
|
-
react_1.default.createElement(selected_rows_toolbar_1.SelectedRowsToolbar, { state: state, actions: actions
|
|
40
|
+
react_1.default.createElement(selected_rows_toolbar_1.SelectedRowsToolbar, { state: state, actions: actions, Actions: () => (react_1.default.createElement(button_1.Button, { isIconButton: true },
|
|
41
|
+
react_1.default.createElement(icon_1.Icon, { name: "camera" }))) }),
|
|
39
42
|
react_1.default.createElement(json_renderer_1.JsonRenderer, { value: state })));
|
|
40
43
|
}
|
|
41
44
|
exports.Default = Default;
|