@uxf/data-grid 11.12.1 → 11.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -0
- package/_api/index.d.ts +8 -0
- package/_api/index.js +12 -0
- package/_generator/cli.js +3 -2
- package/_generator/index.js +38 -10
- package/_store/reducer.js +26 -6
- package/_story-utils/schema.js +13 -11
- package/components.d.ts +5 -0
- package/components.js +5 -0
- package/filter-handler/boolean-select.d.ts +4 -0
- package/filter-handler/boolean-select.js +23 -0
- package/filter-handler/checkbox.d.ts +4 -0
- package/filter-handler/checkbox.js +19 -0
- package/filter-handler/date.d.ts +6 -2
- package/filter-handler/date.js +25 -22
- package/filter-handler/datetime.d.ts +7 -0
- package/filter-handler/datetime.js +34 -0
- package/filter-handler/entity-multi-select.d.ts +5 -0
- package/filter-handler/entity-multi-select.js +22 -0
- package/filter-handler/entity-select.d.ts +5 -0
- package/filter-handler/entity-select.js +22 -0
- package/filter-handler/index.d.ts +1 -1
- package/filter-handler/index.js +20 -13
- package/filter-handler/interval.d.ts +7 -0
- package/filter-handler/interval.js +45 -0
- package/filter-handler/multi-select.d.ts +4 -2
- package/filter-handler/multi-select.js +13 -16
- package/filter-handler/select.d.ts +5 -0
- package/filter-handler/{select-filter.js → select.js} +6 -6
- package/filter-handler/string.d.ts +4 -0
- package/filter-handler/{text-filter.js → string.js} +9 -7
- package/filter-handler/types.d.ts +5 -6
- package/filter-list/filter-list.js +6 -9
- package/filters/filters.js +4 -7
- package/package.json +4 -2
- package/styles.css +3 -1
- package/table-v2/hooks/use-resizable-columns.d.ts +9 -0
- package/table-v2/hooks/use-resizable-columns.js +68 -0
- package/table-v2/index.d.ts +1 -0
- package/table-v2/index.js +17 -0
- package/table-v2/no-rows-fallback.d.ts +7 -0
- package/table-v2/no-rows-fallback.js +15 -0
- package/table-v2/styles.css +62 -0
- package/table-v2/table-v2.d.ts +3 -0
- package/table-v2/table-v2.js +46 -0
- package/table-v2/table-v2.stories.d.ts +2 -0
- package/table-v2/table-v2.stories.js +22 -0
- package/table-v2/types.d.ts +24 -0
- package/table-v2/types.js +2 -0
- package/table-v2/utils/get-grid-template-rows.d.ts +2 -0
- package/table-v2/utils/get-grid-template-rows.js +15 -0
- package/types/api.d.ts +0 -1
- package/types/components.d.ts +5 -5
- package/types/schema.d.ts +5 -7
- package/use-data-grid-control/actions-factory.d.ts +4 -2
- package/use-data-grid-control/actions-factory.js +3 -1
- package/use-data-grid-control/use-data-grid-control.d.ts +3 -1
- package/use-data-grid-fetching/loader.js +2 -4
- package/utils/create-filter-component-props.d.ts +4 -0
- package/utils/create-filter-component-props.js +16 -0
- package/_store/actions.d.ts +0 -45
- package/_store/actions.js +0 -47
- package/filter-handler/bool-filter.d.ts +0 -3
- package/filter-handler/bool-filter.js +0 -20
- package/filter-handler/boolean-filter.d.ts +0 -3
- package/filter-handler/boolean-filter.js +0 -16
- package/filter-handler/interval-filter.d.ts +0 -3
- package/filter-handler/interval-filter.js +0 -50
- package/filter-handler/select-filter.d.ts +0 -3
- package/filter-handler/text-filter.d.ts +0 -3
package/README.md
CHANGED
|
@@ -43,6 +43,18 @@ const { state, actions } = useDataGridControl({
|
|
|
43
43
|
});
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
+
## Supported FilterHandlers
|
|
47
|
+
|
|
48
|
+
- `bool` - Select (yes / no / null)
|
|
49
|
+
- `checkbox`, `boolean` - Checkbox (is sent only if checkbox is checked)
|
|
50
|
+
- `date`
|
|
51
|
+
- `datetime`
|
|
52
|
+
- `entityMultiSelect`
|
|
53
|
+
- `entitySelect`
|
|
54
|
+
- `interval`
|
|
55
|
+
- `multiSelect`
|
|
56
|
+
- `select`
|
|
57
|
+
- `string`, `text`
|
|
46
58
|
|
|
47
59
|
## Examples
|
|
48
60
|
|
package/_api/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Request, Response } from "../types/api";
|
|
2
|
+
export declare function dataGridGetResult(gridName: string, request: Request): Promise<Response>;
|
|
3
|
+
type Option = {
|
|
4
|
+
id: number | string;
|
|
5
|
+
label: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function dataGridAutocomplete(name: string, term: string): Promise<Option[]>;
|
|
8
|
+
export {};
|
package/_api/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dataGridAutocomplete = exports.dataGridGetResult = void 0;
|
|
4
|
+
const qs_1 = require("qs");
|
|
5
|
+
function dataGridGetResult(gridName, request) {
|
|
6
|
+
return fetch(`/api/cms/datagrid/${gridName}?${(0, qs_1.stringify)(request)}`).then((response) => response.json());
|
|
7
|
+
}
|
|
8
|
+
exports.dataGridGetResult = dataGridGetResult;
|
|
9
|
+
function dataGridAutocomplete(name, term) {
|
|
10
|
+
return fetch(`/api/cms/autocomplete/${name}?${(0, qs_1.stringify)({ term })}`).then((response) => response.json());
|
|
11
|
+
}
|
|
12
|
+
exports.dataGridAutocomplete = dataGridAutocomplete;
|
package/_generator/cli.js
CHANGED
|
@@ -12,17 +12,18 @@ Usage:
|
|
|
12
12
|
.option("o", { alias: "outputDirectory", type: "string" })
|
|
13
13
|
.option("l", { alias: "requiredLoader", type: "boolean" })
|
|
14
14
|
.option("h", { alias: "help", group: "Options" })
|
|
15
|
+
.option("t", { alias: "columnTypes", type: "string" })
|
|
15
16
|
.strict(false)
|
|
16
17
|
.exitProcess(false);
|
|
17
18
|
|
|
18
19
|
try {
|
|
19
|
-
const { help, schemaDirectory, outputDirectory, requiredLoader } = cli.parse(argv.slice(2));
|
|
20
|
+
const { help, schemaDirectory, outputDirectory, requiredLoader, columnTypes } = cli.parse(argv.slice(2));
|
|
20
21
|
|
|
21
22
|
if (Boolean(help)) {
|
|
22
23
|
return 0;
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
await require("./index")(schemaDirectory, outputDirectory, requiredLoader);
|
|
26
|
+
await require("./index")(schemaDirectory, outputDirectory, requiredLoader, columnTypes);
|
|
26
27
|
} catch (e) {
|
|
27
28
|
console.error(e);
|
|
28
29
|
return 1;
|
package/_generator/index.js
CHANGED
|
@@ -14,23 +14,51 @@ function writeFile(filename, value) {
|
|
|
14
14
|
writeFileSync(filename, value);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
function
|
|
18
|
-
return `
|
|
19
|
-
import json from "${schemaRelativeImport}";
|
|
20
|
-
|
|
21
|
-
type DataGrid_${camelize(gridName)} = {
|
|
17
|
+
function generateGridType(gridName, schema) {
|
|
18
|
+
return `type DataGrid_${camelize(gridName)} = {
|
|
22
19
|
columns: {
|
|
23
20
|
${schema.columns.map((column) => `"${column.name}": "${column.type}",`).join("\n ")}
|
|
24
21
|
},
|
|
25
22
|
filters: {
|
|
26
23
|
${schema.filters.map((filter) => `"${filter.name}": "${filter.type}",`).join("\n ")}
|
|
27
24
|
}
|
|
25
|
+
}`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function generateRowType(gridName, schema, columnTypes) {
|
|
29
|
+
if (!columnTypes) {
|
|
30
|
+
return "";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return `export type DataGridRow_${camelize(gridName)} = {
|
|
34
|
+
${schema.columns.map((column) => `"${column.name}": ColumnTypes["${column.type}"]`).join("\n ")}
|
|
35
|
+
}`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function generateGridSchema(gridName) {
|
|
39
|
+
return `export const dataGridSchema_${camelize(gridName)}: Schema<DataGrid_${camelize(gridName)}> = json as any;`;
|
|
28
40
|
}
|
|
29
41
|
|
|
30
|
-
|
|
42
|
+
function generateSchemaFile(gridName, schema, schemaRelativeImport, columnTypes) {
|
|
43
|
+
const imports = [
|
|
44
|
+
'import { Schema } from "@uxf/data-grid";',
|
|
45
|
+
`import json from "${schemaRelativeImport}";`,
|
|
46
|
+
!!columnTypes && `import { ColumnTypes } from "${columnTypes}";`,
|
|
47
|
+
]
|
|
48
|
+
.filter(Boolean)
|
|
49
|
+
.join("\n");
|
|
50
|
+
|
|
51
|
+
return [
|
|
52
|
+
imports,
|
|
53
|
+
!!columnTypes && generateRowType(gridName, schema, columnTypes),
|
|
54
|
+
generateGridType(gridName, schema),
|
|
55
|
+
generateGridSchema(gridName),
|
|
56
|
+
]
|
|
57
|
+
.filter(Boolean)
|
|
58
|
+
.join("\n\n");
|
|
31
59
|
}
|
|
32
60
|
|
|
33
|
-
function generate(schema, filename, outputDirectory) {
|
|
61
|
+
function generate(schema, filename, outputDirectory, columnTypes) {
|
|
34
62
|
const gridName = parse(filename).name;
|
|
35
63
|
const generatedPath = join(process.cwd(), outputDirectory, gridName);
|
|
36
64
|
|
|
@@ -38,12 +66,12 @@ function generate(schema, filename, outputDirectory) {
|
|
|
38
66
|
|
|
39
67
|
writeFile(
|
|
40
68
|
generatedSchemaFilename,
|
|
41
|
-
generateSchemaFile(gridName, schema, relative(dirname(generatedSchemaFilename), filename)),
|
|
69
|
+
generateSchemaFile(gridName, schema, relative(dirname(generatedSchemaFilename), filename), columnTypes),
|
|
42
70
|
);
|
|
43
71
|
}
|
|
44
72
|
|
|
45
|
-
module.exports = (schemaDirectory, outputDirectory, requiredLoader) => {
|
|
73
|
+
module.exports = (schemaDirectory, outputDirectory, requiredLoader, columnTypes) => {
|
|
46
74
|
globSync(schemaDirectory + "/*.json")
|
|
47
75
|
.map((path) => process.cwd() + "/" + path)
|
|
48
|
-
.forEach((filename) => generate(JSON.parse(readFileSync(filename)), filename, outputDirectory,
|
|
76
|
+
.forEach((filename) => generate(JSON.parse(readFileSync(filename)), filename, outputDirectory, columnTypes));
|
|
49
77
|
};
|
package/_store/reducer.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.debugReducer = exports.reducer = exports.getInitialState = void 0;
|
|
4
7
|
const is_nil_1 = require("@uxf/core/utils/is-nil");
|
|
8
|
+
const deepmerge_1 = __importDefault(require("deepmerge"));
|
|
5
9
|
const utils_1 = require("../utils");
|
|
6
10
|
function getInitialState(schema, init, initialUserConfig) {
|
|
7
11
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
@@ -48,15 +52,28 @@ const reducer = (state, action) => {
|
|
|
48
52
|
};
|
|
49
53
|
case "FILTER":
|
|
50
54
|
// eslint-disable-next-line no-case-declarations
|
|
51
|
-
const
|
|
55
|
+
const name = action.name;
|
|
56
|
+
// eslint-disable-next-line no-case-declarations
|
|
57
|
+
const value = action.value;
|
|
58
|
+
// eslint-disable-next-line no-case-declarations
|
|
59
|
+
const op = action.op;
|
|
52
60
|
return {
|
|
53
61
|
...state,
|
|
54
62
|
request: {
|
|
55
63
|
...state.request,
|
|
56
64
|
page: 0,
|
|
57
|
-
f: state.request.f.find((f) => f.name ===
|
|
58
|
-
? state.request.f.map((f) => (f.name ===
|
|
59
|
-
: [...state.request.f,
|
|
65
|
+
f: state.request.f.find((f) => f.name === name)
|
|
66
|
+
? state.request.f.map((f) => (f.name === name ? { value, name, op } : f))
|
|
67
|
+
: [...state.request.f, { value, name, op }],
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
case "FILTER_CLEAR":
|
|
71
|
+
return {
|
|
72
|
+
...state,
|
|
73
|
+
request: {
|
|
74
|
+
...state.request,
|
|
75
|
+
page: 0,
|
|
76
|
+
f: state.request.f.filter((filter) => filter.name !== action.name),
|
|
60
77
|
},
|
|
61
78
|
};
|
|
62
79
|
case "FILTER_RESET":
|
|
@@ -131,7 +148,6 @@ const reducer = (state, action) => {
|
|
|
131
148
|
columns: {
|
|
132
149
|
...state.userConfig.columns,
|
|
133
150
|
[action.name]: {
|
|
134
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
135
151
|
...((_k = (_j = state.userConfig.columns) === null || _j === void 0 ? void 0 : _j[action.name]) !== null && _k !== void 0 ? _k : {}),
|
|
136
152
|
isHidden: true,
|
|
137
153
|
},
|
|
@@ -146,13 +162,17 @@ const reducer = (state, action) => {
|
|
|
146
162
|
columns: {
|
|
147
163
|
...state.userConfig.columns,
|
|
148
164
|
[action.name]: {
|
|
149
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
150
165
|
...((_m = (_l = state.userConfig.columns) === null || _l === void 0 ? void 0 : _l[action.name]) !== null && _m !== void 0 ? _m : {}),
|
|
151
166
|
isHidden: false,
|
|
152
167
|
},
|
|
153
168
|
},
|
|
154
169
|
},
|
|
155
170
|
};
|
|
171
|
+
case "UPDATE_USER_CONFIG":
|
|
172
|
+
return {
|
|
173
|
+
...state,
|
|
174
|
+
userConfig: (0, deepmerge_1.default)(state.userConfig, action.userConfig),
|
|
175
|
+
};
|
|
156
176
|
default:
|
|
157
177
|
// eslint-disable-next-line no-console
|
|
158
178
|
console.warn("Unknown datagrid action.", action);
|
package/_story-utils/schema.js
CHANGED
|
@@ -15,17 +15,17 @@ exports.schema = {
|
|
|
15
15
|
filters: [
|
|
16
16
|
{ name: "text", type: "text", label: "Text" },
|
|
17
17
|
{ name: "bool", type: "boolean", label: "Boolean" },
|
|
18
|
-
{ name: "
|
|
18
|
+
{ name: "interval", type: "interval", label: "Super interval" },
|
|
19
19
|
{ name: "mail", type: "string", label: "E-mail" },
|
|
20
20
|
{ name: "date", type: "date", label: "Date" },
|
|
21
|
+
{ name: "datetime", type: "datetime", label: "Datetime" },
|
|
21
22
|
{ name: "tel", type: "string", label: "Phone" },
|
|
22
23
|
{ name: "link", type: "string", label: "Link" },
|
|
23
24
|
{
|
|
24
|
-
name: "
|
|
25
|
+
name: "select",
|
|
25
26
|
type: "select",
|
|
26
27
|
label: "Select",
|
|
27
28
|
options: [
|
|
28
|
-
{ id: "", label: "" },
|
|
29
29
|
{ id: 1, label: "A" },
|
|
30
30
|
{ id: 2, label: "B" },
|
|
31
31
|
],
|
|
@@ -42,14 +42,16 @@ exports.schema = {
|
|
|
42
42
|
],
|
|
43
43
|
},
|
|
44
44
|
{
|
|
45
|
-
name: "
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
45
|
+
name: "entitySelect",
|
|
46
|
+
label: "Entity select",
|
|
47
|
+
type: "entitySelect",
|
|
48
|
+
autocomplete: "user",
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: "entityMultiSelect",
|
|
52
|
+
label: "Entity multi select",
|
|
53
|
+
type: "entityMultiSelect",
|
|
54
|
+
autocomplete: "user",
|
|
53
55
|
},
|
|
54
56
|
],
|
|
55
57
|
tabs: [
|
package/components.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import * as rowCountsStories from "./row-counts/row-counts.stories";
|
|
|
11
11
|
import * as rowsPerPageSelectStories from "./rows-per-page-select/rows-per-page-select.stories";
|
|
12
12
|
import * as selectedRowsToolbarStories from "./selected-rows-toolbar/selected-rows-toolbar.stories";
|
|
13
13
|
import * as tableStories from "./table/table.stories";
|
|
14
|
+
import * as tableV2Stories from "./table-v2/table-v2.stories";
|
|
14
15
|
import * as toolbarControlStories from "./toolbar-control/toolbar-control.stories";
|
|
15
16
|
import * as toolbarCustomsStories from "./toolbar-customs/toolbar-customs.stories";
|
|
16
17
|
import * as toolbarTabsStories from "./toolbar-tabs/toolbar-tabs.stories";
|
|
@@ -67,6 +68,10 @@ export declare const components: {
|
|
|
67
68
|
readonly title: "Table";
|
|
68
69
|
readonly stories: typeof tableStories;
|
|
69
70
|
};
|
|
71
|
+
readonly "table-v2": {
|
|
72
|
+
readonly title: "TableV2";
|
|
73
|
+
readonly stories: typeof tableV2Stories;
|
|
74
|
+
};
|
|
70
75
|
readonly "toolbar-control": {
|
|
71
76
|
readonly title: "ToolbarControl";
|
|
72
77
|
readonly stories: typeof toolbarControlStories;
|
package/components.js
CHANGED
|
@@ -38,6 +38,7 @@ const rowCountsStories = __importStar(require("./row-counts/row-counts.stories")
|
|
|
38
38
|
const rowsPerPageSelectStories = __importStar(require("./rows-per-page-select/rows-per-page-select.stories"));
|
|
39
39
|
const selectedRowsToolbarStories = __importStar(require("./selected-rows-toolbar/selected-rows-toolbar.stories"));
|
|
40
40
|
const tableStories = __importStar(require("./table/table.stories"));
|
|
41
|
+
const tableV2Stories = __importStar(require("./table-v2/table-v2.stories"));
|
|
41
42
|
const toolbarControlStories = __importStar(require("./toolbar-control/toolbar-control.stories"));
|
|
42
43
|
const toolbarCustomsStories = __importStar(require("./toolbar-customs/toolbar-customs.stories"));
|
|
43
44
|
const toolbarTabsStories = __importStar(require("./toolbar-tabs/toolbar-tabs.stories"));
|
|
@@ -94,6 +95,10 @@ exports.components = {
|
|
|
94
95
|
title: "Table",
|
|
95
96
|
stories: tableStories
|
|
96
97
|
},
|
|
98
|
+
"table-v2": {
|
|
99
|
+
title: "TableV2",
|
|
100
|
+
stories: tableV2Stories
|
|
101
|
+
},
|
|
97
102
|
"toolbar-control": {
|
|
98
103
|
title: "ToolbarControl",
|
|
99
104
|
stories: toolbarControlStories
|
|
@@ -0,0 +1,23 @@
|
|
|
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 chip_1 = require("@uxf/ui/chip");
|
|
7
|
+
const select_1 = require("@uxf/ui/select");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const filterHandler = {
|
|
10
|
+
Input(props) {
|
|
11
|
+
return (react_1.default.createElement(select_1.Select, { options: [
|
|
12
|
+
{ id: 1, label: "Ano" },
|
|
13
|
+
{ id: 0, label: "Ne" },
|
|
14
|
+
], label: props.filter.label, value: props.value, onChange: (value) => props.onChange(value), isClearable: true, name: props.filter.name }));
|
|
15
|
+
},
|
|
16
|
+
ListItem(props) {
|
|
17
|
+
return (react_1.default.createElement(chip_1.Chip, { onClose: props.onClear },
|
|
18
|
+
props.filter.label,
|
|
19
|
+
":\u00A0",
|
|
20
|
+
props.value ? "Ano" : "Ne"));
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
exports.default = filterHandler;
|
|
@@ -0,0 +1,19 @@
|
|
|
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 checkbox_input_1 = require("@uxf/ui/checkbox-input");
|
|
7
|
+
const chip_1 = require("@uxf/ui/chip");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const filterHandler = {
|
|
10
|
+
Input(props) {
|
|
11
|
+
var _a;
|
|
12
|
+
return (react_1.default.createElement(checkbox_input_1.CheckboxInput, { label: props.filter.label, value: (_a = props.value) !== null && _a !== void 0 ? _a : false, onChange: (value) => props.onChange(value ? value : undefined), name: props.filter.name }));
|
|
13
|
+
},
|
|
14
|
+
ListItem: (props) => (react_1.default.createElement(chip_1.Chip, { onClose: props.onClear },
|
|
15
|
+
props.filter.label,
|
|
16
|
+
":\u00A0",
|
|
17
|
+
props.value ? "Ano" : "Ne")),
|
|
18
|
+
};
|
|
19
|
+
exports.default = filterHandler;
|
package/filter-handler/date.d.ts
CHANGED
package/filter-handler/date.js
CHANGED
|
@@ -9,35 +9,38 @@ const chip_1 = require("@uxf/ui/chip");
|
|
|
9
9
|
const date_picker_input_1 = require("@uxf/ui/date-picker-input");
|
|
10
10
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
11
11
|
const react_1 = __importDefault(require("react"));
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
var _a, _b;
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
const filterHandler = {
|
|
13
|
+
Input(props) {
|
|
14
|
+
var _a, _b, _c, _d, _e, _f;
|
|
15
|
+
const onChangeFrom = (value) => {
|
|
16
|
+
var _a;
|
|
17
|
+
return (0, is_nil_1.isNil)(value) && (0, is_nil_1.isNil)((_a = props.value) === null || _a === void 0 ? void 0 : _a.to)
|
|
18
|
+
? props.onChange(undefined)
|
|
19
|
+
: props.onChange({ ...props.value, from: value !== null && value !== void 0 ? value : undefined });
|
|
20
|
+
};
|
|
21
|
+
const onChangeTo = (value) => {
|
|
22
|
+
var _a;
|
|
23
|
+
return (0, is_nil_1.isNil)(value) && (0, is_nil_1.isNil)((_a = props.value) === null || _a === void 0 ? void 0 : _a.from)
|
|
24
|
+
? props.onChange(undefined)
|
|
25
|
+
: props.onChange({ ...props.value, to: value !== null && value !== void 0 ? value : undefined });
|
|
26
|
+
};
|
|
18
27
|
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:
|
|
20
|
-
|
|
21
|
-
value: { ...initializedValue.value, from: changedValue },
|
|
22
|
-
}), label: `${props.filter.label} (od)`, name: props.filter.name }),
|
|
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)`, name: props.filter.name })));
|
|
28
|
+
react_1.default.createElement(date_picker_input_1.DatePickerInput, { value: (_b = (_a = props.value) === null || _a === void 0 ? void 0 : _a.from) !== null && _b !== void 0 ? _b : null, onChange: onChangeFrom, label: `${props.filter.label} (od)`, name: props.filter.name, maxDate: (_c = props.value) === null || _c === void 0 ? void 0 : _c.to, isClearable: true }),
|
|
29
|
+
react_1.default.createElement(date_picker_input_1.DatePickerInput, { value: (_e = (_d = props.value) === null || _d === void 0 ? void 0 : _d.to) !== null && _e !== void 0 ? _e : null, onChange: onChangeTo, label: `${props.filter.label} (do)`, name: props.filter.name, minDate: (_f = props.value) === null || _f === void 0 ? void 0 : _f.from, isClearable: true })));
|
|
24
30
|
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
const value = props.value.value;
|
|
30
|
-
if ((0, is_nil_1.isNil)(value.from) && (0, is_nil_1.isNil)(value.to)) {
|
|
31
|
+
ListItem: function (props) {
|
|
32
|
+
var _a, _b;
|
|
33
|
+
if ((0, is_nil_1.isNil)((_a = props.value) === null || _a === void 0 ? void 0 : _a.from) && (0, is_nil_1.isNil)((_b = props.value) === null || _b === void 0 ? void 0 : _b.to)) {
|
|
31
34
|
return null;
|
|
32
35
|
}
|
|
33
36
|
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") :
|
|
37
|
+
props.value.from ? "od " + (0, dayjs_1.default)(props.value.from).format("l") : null,
|
|
38
|
+
props.value.to ? "do " + (0, dayjs_1.default)(props.value.to).format("l") : null,
|
|
36
39
|
];
|
|
37
|
-
return (react_1.default.createElement(chip_1.Chip, { onClose:
|
|
40
|
+
return (react_1.default.createElement(chip_1.Chip, { onClose: props.onClear },
|
|
38
41
|
props.filter.label,
|
|
39
|
-
" ",
|
|
42
|
+
": ",
|
|
40
43
|
(0, filter_nullish_1.filterNullish)(formatDate).join(" ")));
|
|
41
44
|
},
|
|
42
45
|
};
|
|
43
|
-
exports.default =
|
|
46
|
+
exports.default = filterHandler;
|
|
@@ -0,0 +1,34 @@
|
|
|
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 datetime_picker_input_1 = require("@uxf/ui/datetime-picker-input");
|
|
10
|
+
const dayjs_1 = __importDefault(require("dayjs"));
|
|
11
|
+
const react_1 = __importDefault(require("react"));
|
|
12
|
+
const filterHandler = {
|
|
13
|
+
Input(props) {
|
|
14
|
+
var _a, _b, _c, _d, _e, _f;
|
|
15
|
+
return (react_1.default.createElement("div", { className: "uxf-data-grid__filter uxf-data-grid__filter--datetime" },
|
|
16
|
+
react_1.default.createElement(datetime_picker_input_1.DatetimePickerInput, { value: (_b = (_a = props.value) === null || _a === void 0 ? void 0 : _a.from) !== null && _b !== void 0 ? _b : null, onChange: (value) => props.onChange({ ...props.value, from: value !== null && value !== void 0 ? value : undefined }), label: `${props.filter.label} (od)`, name: props.filter.name, maxDate: (_c = props.value) === null || _c === void 0 ? void 0 : _c.to, isClearable: true }),
|
|
17
|
+
react_1.default.createElement(datetime_picker_input_1.DatetimePickerInput, { value: (_e = (_d = props.value) === null || _d === void 0 ? void 0 : _d.to) !== null && _e !== void 0 ? _e : null, onChange: (value) => props.onChange({ ...props.value, to: value !== null && value !== void 0 ? value : undefined }), label: `${props.filter.label} (do)`, name: props.filter.name, minDate: (_f = props.value) === null || _f === void 0 ? void 0 : _f.from, isClearable: true })));
|
|
18
|
+
},
|
|
19
|
+
ListItem: function (props) {
|
|
20
|
+
var _a, _b;
|
|
21
|
+
if ((0, is_nil_1.isNil)((_a = props.value) === null || _a === void 0 ? void 0 : _a.from) && (0, is_nil_1.isNil)((_b = props.value) === null || _b === void 0 ? void 0 : _b.to)) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const formatDate = [
|
|
25
|
+
props.value.from ? "od " + (0, dayjs_1.default)(props.value.from).format("l LT") : null,
|
|
26
|
+
props.value.to ? "do " + (0, dayjs_1.default)(props.value.to).format("l LT") : null,
|
|
27
|
+
];
|
|
28
|
+
return (react_1.default.createElement(chip_1.Chip, { onClose: props.onClear },
|
|
29
|
+
props.filter.label,
|
|
30
|
+
": ",
|
|
31
|
+
(0, filter_nullish_1.filterNullish)(formatDate).join(" ")));
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
exports.default = filterHandler;
|
|
@@ -0,0 +1,22 @@
|
|
|
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 chip_1 = require("@uxf/ui/chip");
|
|
7
|
+
const multi_combobox_1 = require("@uxf/ui/multi-combobox");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const _api_1 = require("../_api");
|
|
10
|
+
const filterHandler = {
|
|
11
|
+
Input(props) {
|
|
12
|
+
return (react_1.default.createElement(multi_combobox_1.MultiCombobox, { loadOptions: (term) => { var _a; return (0, _api_1.dataGridAutocomplete)((_a = props.filter.autocomplete) !== null && _a !== void 0 ? _a : "", term); }, label: props.filter.label, value: props.value, onChange: (value) => props.onChange(value), name: props.filter.name }));
|
|
13
|
+
},
|
|
14
|
+
ListItem(props) {
|
|
15
|
+
var _a;
|
|
16
|
+
return (react_1.default.createElement(chip_1.Chip, { onClose: props.onClear },
|
|
17
|
+
props.filter.label,
|
|
18
|
+
":\u00A0", (_a = props.value) === null || _a === void 0 ? void 0 :
|
|
19
|
+
_a.map((item) => item.label).join(", ")));
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
exports.default = filterHandler;
|
|
@@ -0,0 +1,22 @@
|
|
|
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 chip_1 = require("@uxf/ui/chip");
|
|
7
|
+
const combobox_1 = require("@uxf/ui/combobox");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const _api_1 = require("../_api");
|
|
10
|
+
const filterHandler = {
|
|
11
|
+
Input(props) {
|
|
12
|
+
return (react_1.default.createElement(combobox_1.Combobox, { loadOptions: (term) => { var _a; return (0, _api_1.dataGridAutocomplete)((_a = props.filter.autocomplete) !== null && _a !== void 0 ? _a : "", term); }, label: props.filter.label, value: props.value, onChange: (value) => props.onChange(value), isClearable: true, name: props.filter.name }));
|
|
13
|
+
},
|
|
14
|
+
ListItem(props) {
|
|
15
|
+
var _a;
|
|
16
|
+
return (react_1.default.createElement(chip_1.Chip, { onClose: props.onClear },
|
|
17
|
+
props.filter.label,
|
|
18
|
+
":\u00A0", (_a = props.value) === null || _a === void 0 ? void 0 :
|
|
19
|
+
_a.label));
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
exports.default = filterHandler;
|
package/filter-handler/index.js
CHANGED
|
@@ -18,22 +18,29 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
20
|
exports.defaultFilterHandlers = void 0;
|
|
21
|
-
const
|
|
22
|
-
const
|
|
21
|
+
const boolean_select_1 = __importDefault(require("./boolean-select"));
|
|
22
|
+
const checkbox_1 = __importDefault(require("./checkbox"));
|
|
23
23
|
const date_1 = __importDefault(require("./date"));
|
|
24
|
-
const
|
|
24
|
+
const datetime_1 = __importDefault(require("./datetime"));
|
|
25
|
+
const entity_multi_select_1 = __importDefault(require("./entity-multi-select"));
|
|
26
|
+
const entity_select_1 = __importDefault(require("./entity-select"));
|
|
27
|
+
const interval_1 = __importDefault(require("./interval"));
|
|
25
28
|
const multi_select_1 = __importDefault(require("./multi-select"));
|
|
26
|
-
const
|
|
27
|
-
const
|
|
29
|
+
const select_1 = __importDefault(require("./select"));
|
|
30
|
+
const string_1 = __importDefault(require("./string"));
|
|
28
31
|
__exportStar(require("./types"), exports);
|
|
29
32
|
exports.defaultFilterHandlers = {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
bool: boolean_select_1.default, // TODO smazat
|
|
34
|
+
boolean: checkbox_1.default, // TODO smazat
|
|
35
|
+
text: string_1.default, // TODO smazat
|
|
36
|
+
date: // TODO smazat
|
|
37
|
+
date_1.default,
|
|
38
|
+
datetime: datetime_1.default,
|
|
39
|
+
entityMultiSelect: entity_multi_select_1.default,
|
|
40
|
+
entitySelect: entity_select_1.default,
|
|
41
|
+
checkbox: checkbox_1.default,
|
|
42
|
+
interval: interval_1.default,
|
|
37
43
|
multiSelect: multi_select_1.default,
|
|
38
|
-
select:
|
|
44
|
+
select: select_1.default,
|
|
45
|
+
string: string_1.default,
|
|
39
46
|
};
|
|
@@ -0,0 +1,45 @@
|
|
|
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_empty_1 = require("@uxf/core/utils/is-empty");
|
|
8
|
+
const is_nil_1 = require("@uxf/core/utils/is-nil");
|
|
9
|
+
const is_not_nil_1 = require("@uxf/core/utils/is-not-nil");
|
|
10
|
+
const chip_1 = require("@uxf/ui/chip");
|
|
11
|
+
const text_input_1 = require("@uxf/ui/text-input");
|
|
12
|
+
const react_1 = __importDefault(require("react"));
|
|
13
|
+
const filterHandler = {
|
|
14
|
+
Input(props) {
|
|
15
|
+
var _a, _b, _c, _d, _e, _f;
|
|
16
|
+
const onChangeFrom = (value) => props.onChange({
|
|
17
|
+
...props.value,
|
|
18
|
+
from: (0, is_not_nil_1.isNotNil)(value) && !(0, is_empty_1.isEmpty)(value) ? parseInt(value, 10) : null,
|
|
19
|
+
});
|
|
20
|
+
const onChangeTo = (value) => props.onChange({
|
|
21
|
+
...props.value,
|
|
22
|
+
to: (0, is_not_nil_1.isNotNil)(value) && !(0, is_empty_1.isEmpty)(value) ? parseInt(value, 10) : null,
|
|
23
|
+
});
|
|
24
|
+
return (react_1.default.createElement("div", { key: props.filter.name },
|
|
25
|
+
react_1.default.createElement("div", { className: "uxf-data-grid__filter uxf-data-grid__filter--interval" },
|
|
26
|
+
react_1.default.createElement(text_input_1.TextInput, { label: `${props.filter.label} od:`, value: (_c = (_b = (_a = props.value) === null || _a === void 0 ? void 0 : _a.from) === null || _b === void 0 ? void 0 : _b.toString()) !== null && _c !== void 0 ? _c : "", onChange: onChangeFrom, name: props.filter.name }),
|
|
27
|
+
react_1.default.createElement("div", { className: "uxf-data-grid__filter-gap" }, "\u2013"),
|
|
28
|
+
react_1.default.createElement(text_input_1.TextInput, { label: `${props.filter.label} do:`, value: (_f = (_e = (_d = props.value) === null || _d === void 0 ? void 0 : _d.to) === null || _e === void 0 ? void 0 : _e.toString()) !== null && _f !== void 0 ? _f : "", onChange: onChangeTo, name: props.filter.name }))));
|
|
29
|
+
},
|
|
30
|
+
ListItem(props) {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
if ((0, is_nil_1.isNil)((_a = props.value) === null || _a === void 0 ? void 0 : _a.from) && (0, is_nil_1.isNil)((_b = props.value) === null || _b === void 0 ? void 0 : _b.to)) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
const formatInterval = [
|
|
36
|
+
props.value.from ? "od " + props.value.from : null,
|
|
37
|
+
props.value.to ? "do " + props.value.to : null,
|
|
38
|
+
];
|
|
39
|
+
return (react_1.default.createElement(chip_1.Chip, { onClose: props.onClear },
|
|
40
|
+
props.filter.label,
|
|
41
|
+
" ",
|
|
42
|
+
(0, filter_nullish_1.filterNullish)(formatInterval).join(" ")));
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
exports.default = filterHandler;
|