@uxf/data-grid 11.25.1 → 11.27.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 +31 -0
- package/data-grid.stories.js +11 -1
- package/export-button/export-button.js +1 -1
- package/filter-handler/boolean-select.js +2 -1
- package/filter-handler/date.js +3 -3
- package/filter-handler/datetime.js +3 -3
- package/filter-handler/entity-multi-select.js +2 -1
- package/filter-handler/entity-select.js +2 -1
- package/filter-handler/interval.js +2 -1
- package/filter-handler/multi-select.js +2 -2
- package/filter-handler/select.js +2 -2
- package/filter-handler/string.js +2 -2
- package/filters-button/filters-button.js +1 -1
- package/hidden-columns-button/hidden-columns-button.js +1 -1
- package/index.d.ts +1 -0
- package/index.js +3 -1
- package/package.json +3 -3
- package/table/components/action-cell.js +1 -1
- package/toolbar-customs/toolbar-customs.js +1 -1
- package/toolbar-customs/toolbar-customs.stories.js +1 -1
- package/types/schema.d.ts +6 -2
- package/types/state.d.ts +4 -7
- package/utils/merge-schema-with-config.d.ts +3 -0
- package/utils/merge-schema-with-config.js +31 -0
- package/utils/merge-schema-with-config.test.d.ts +1 -0
- package/utils/merge-schema-with-config.test.js +57 -0
package/README.md
CHANGED
|
@@ -90,3 +90,34 @@ function BasicExample() {
|
|
|
90
90
|
);
|
|
91
91
|
}
|
|
92
92
|
```
|
|
93
|
+
|
|
94
|
+
### FrontendConfig
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
import { useDataGridControl } from "@uxf/data-grid/use-data-grid-control";
|
|
98
|
+
import { mergeSchemaWithConfig } from "@uxf/data-grid";
|
|
99
|
+
|
|
100
|
+
const schema = mergeSchemaWithConfig(
|
|
101
|
+
dataGridSchema_ExampleGrid,
|
|
102
|
+
{
|
|
103
|
+
columns: {
|
|
104
|
+
id: { width: 100, isHidden: true },
|
|
105
|
+
},
|
|
106
|
+
filters: {
|
|
107
|
+
id: { placeholder: "Hledejte podle ID..." }
|
|
108
|
+
},
|
|
109
|
+
perPage: 100,
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
function Example_1(props) {
|
|
114
|
+
const { state, actions } = useDataGridControl({
|
|
115
|
+
schema,
|
|
116
|
+
initialUserConfig: props.userConfig,
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
return <Table schema={schema}/>
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
|
package/data-grid.stories.js
CHANGED
|
@@ -34,6 +34,7 @@ const data_grid_1 = require("./data-grid");
|
|
|
34
34
|
const table_1 = require("./table");
|
|
35
35
|
const use_data_grid_control_1 = require("./use-data-grid-control");
|
|
36
36
|
const use_data_grid_fetching_1 = require("./use-data-grid-fetching");
|
|
37
|
+
const merge_schema_with_config_1 = require("./utils/merge-schema-with-config");
|
|
37
38
|
const actionCell = {
|
|
38
39
|
width: 100,
|
|
39
40
|
Component: () => {
|
|
@@ -57,6 +58,15 @@ const actionCell = {
|
|
|
57
58
|
return react_1.default.createElement(table_1.ActionCell, { buttons: actionCellActions, visibleButtonsCount: 1 });
|
|
58
59
|
},
|
|
59
60
|
};
|
|
61
|
+
const schemaWithFrontendConfig = (0, merge_schema_with_config_1.mergeSchemaWithConfig)(schema_1.schema, {
|
|
62
|
+
perPage: 100,
|
|
63
|
+
columns: {
|
|
64
|
+
bool: { width: 80 },
|
|
65
|
+
},
|
|
66
|
+
filters: {
|
|
67
|
+
text: { placeholder: "Custom placeholder ..." },
|
|
68
|
+
},
|
|
69
|
+
});
|
|
60
70
|
function Default() {
|
|
61
71
|
const [noBorder, setNoBorder] = (0, react_1.useState)(false);
|
|
62
72
|
const { state, actions } = (0, use_data_grid_control_1.useDataGridControl)({
|
|
@@ -77,7 +87,7 @@ function Default() {
|
|
|
77
87
|
});
|
|
78
88
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
79
89
|
react_1.default.createElement(toggle_1.Toggle, { label: "No border", value: noBorder, onChange: (value) => setNoBorder(!!value), name: "noBorder" }),
|
|
80
|
-
react_1.default.createElement(data_grid_1.DataGrid, { onReload: onReload, state: state, actions: actions, data: data, isLoading: isLoading, error: error, schema:
|
|
90
|
+
react_1.default.createElement(data_grid_1.DataGrid, { onReload: onReload, state: state, actions: actions, data: data, isLoading: isLoading, error: error, schema: schemaWithFrontendConfig, onCsvDownload: console.log, isRowSelectable: true, actionCell: actionCell }),
|
|
81
91
|
react_1.default.createElement(json_renderer_1.JsonRenderer, { value: state })));
|
|
82
92
|
}
|
|
83
93
|
exports.Default = Default;
|
|
@@ -10,7 +10,7 @@ const react_1 = __importDefault(require("react"));
|
|
|
10
10
|
const utils_1 = require("../utils");
|
|
11
11
|
/** @deprecated Use DataGridExportButton */
|
|
12
12
|
function ExportButton(props) {
|
|
13
|
-
return (react_1.default.createElement(button_1.Button, { isIconButton: true, variant: "
|
|
13
|
+
return (react_1.default.createElement(button_1.Button, { isIconButton: true, variant: "secondary", onClick: () => props.onCsvDownload((0, utils_1.createRequest)(props.state.request)), title: "St\u00E1hnout CSV", className: "uxf-data-grid__plugin-button" },
|
|
14
14
|
react_1.default.createElement(icon_1.Icon, { name: "file-arrow-down" })));
|
|
15
15
|
}
|
|
16
16
|
exports.ExportButton = ExportButton;
|
|
@@ -8,10 +8,11 @@ const select_1 = require("@uxf/ui/select");
|
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
9
|
const filterHandler = {
|
|
10
10
|
Input(props) {
|
|
11
|
+
var _a;
|
|
11
12
|
return (react_1.default.createElement(select_1.Select, { options: [
|
|
12
13
|
{ id: 1, label: "Ano" },
|
|
13
14
|
{ id: 0, label: "Ne" },
|
|
14
|
-
], label: props.filter.label, value: props.value, onChange: (value) => props.onChange(value), isClearable: true, name: props.filter.name }));
|
|
15
|
+
], label: props.filter.label, value: props.value, onChange: (value) => props.onChange(value), isClearable: true, name: props.filter.name, placeholder: (_a = props.filter.config) === null || _a === void 0 ? void 0 : _a.placeholder }));
|
|
15
16
|
},
|
|
16
17
|
ListItem(props) {
|
|
17
18
|
return (react_1.default.createElement(chip_1.Chip, { onClose: props.onClear },
|
package/filter-handler/date.js
CHANGED
|
@@ -11,7 +11,7 @@ const dayjs_1 = __importDefault(require("dayjs"));
|
|
|
11
11
|
const react_1 = __importDefault(require("react"));
|
|
12
12
|
const filterHandler = {
|
|
13
13
|
Input(props) {
|
|
14
|
-
var _a, _b, _c, _d, _e, _f;
|
|
14
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
15
15
|
const onChangeFrom = (value) => {
|
|
16
16
|
var _a;
|
|
17
17
|
return (0, is_nil_1.isNil)(value) && (0, is_nil_1.isNil)((_a = props.value) === null || _a === void 0 ? void 0 : _a.to)
|
|
@@ -25,8 +25,8 @@ const filterHandler = {
|
|
|
25
25
|
: props.onChange({ ...props.value, to: value !== null && value !== void 0 ? value : undefined });
|
|
26
26
|
};
|
|
27
27
|
return (react_1.default.createElement("div", { className: "uxf-data-grid__filter uxf-data-grid__filter--date" },
|
|
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: (
|
|
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, placeholder: (_d = props.filter.config) === null || _d === void 0 ? void 0 : _d.placeholder, isClearable: true }),
|
|
29
|
+
react_1.default.createElement(date_picker_input_1.DatePickerInput, { value: (_f = (_e = props.value) === null || _e === void 0 ? void 0 : _e.to) !== null && _f !== void 0 ? _f : null, onChange: onChangeTo, label: `${props.filter.label} (do)`, name: props.filter.name, minDate: (_g = props.value) === null || _g === void 0 ? void 0 : _g.from, placeholder: (_h = props.filter.config) === null || _h === void 0 ? void 0 : _h.placeholder, isClearable: true })));
|
|
30
30
|
},
|
|
31
31
|
ListItem: function (props) {
|
|
32
32
|
var _a, _b;
|
|
@@ -11,10 +11,10 @@ const dayjs_1 = __importDefault(require("dayjs"));
|
|
|
11
11
|
const react_1 = __importDefault(require("react"));
|
|
12
12
|
const filterHandler = {
|
|
13
13
|
Input(props) {
|
|
14
|
-
var _a, _b, _c, _d, _e, _f;
|
|
14
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
15
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: (
|
|
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, placeholder: (_d = props.filter.config) === null || _d === void 0 ? void 0 : _d.placeholder, isClearable: true }),
|
|
17
|
+
react_1.default.createElement(datetime_picker_input_1.DatetimePickerInput, { value: (_f = (_e = props.value) === null || _e === void 0 ? void 0 : _e.to) !== null && _f !== void 0 ? _f : 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: (_g = props.value) === null || _g === void 0 ? void 0 : _g.from, placeholder: (_h = props.filter.config) === null || _h === void 0 ? void 0 : _h.placeholder, isClearable: true })));
|
|
18
18
|
},
|
|
19
19
|
ListItem: function (props) {
|
|
20
20
|
var _a, _b;
|
|
@@ -11,7 +11,8 @@ const react_1 = __importDefault(require("react"));
|
|
|
11
11
|
const _api_1 = require("../_api");
|
|
12
12
|
const filterHandler = {
|
|
13
13
|
Input(props) {
|
|
14
|
-
|
|
14
|
+
var _a;
|
|
15
|
+
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, placeholder: (_a = props.filter.config) === null || _a === void 0 ? void 0 : _a.placeholder }));
|
|
15
16
|
},
|
|
16
17
|
ListItem(props) {
|
|
17
18
|
if ((0, is_nil_1.isNil)(props.value) || (0, is_empty_1.isEmpty)(props.value)) {
|
|
@@ -9,7 +9,8 @@ const react_1 = __importDefault(require("react"));
|
|
|
9
9
|
const _api_1 = require("../_api");
|
|
10
10
|
const filterHandler = {
|
|
11
11
|
Input(props) {
|
|
12
|
-
|
|
12
|
+
var _a;
|
|
13
|
+
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), name: props.filter.name, placeholder: (_a = props.filter.config) === null || _a === void 0 ? void 0 : _a.placeholder, isClearable: true }));
|
|
13
14
|
},
|
|
14
15
|
ListItem(props) {
|
|
15
16
|
var _a;
|
|
@@ -9,10 +9,11 @@ const date_range_picker_input_1 = require("@uxf/ui/date-range-picker-input");
|
|
|
9
9
|
const react_1 = __importDefault(require("react"));
|
|
10
10
|
const filterHandler = {
|
|
11
11
|
Input(props) {
|
|
12
|
+
var _a;
|
|
12
13
|
const onChange = (value) => props.onChange(value !== null && value !== void 0 ? value : "");
|
|
13
14
|
return (react_1.default.createElement("div", { key: props.filter.name },
|
|
14
15
|
react_1.default.createElement("div", { className: "uxf-data-grid__filter uxf-data-grid__filter--interval" },
|
|
15
|
-
react_1.default.createElement(date_range_picker_input_1.DateRangePickerInput, { label: props.filter.label, name: props.filter.name, onChange: onChange, value: props.value }))));
|
|
16
|
+
react_1.default.createElement(date_range_picker_input_1.DateRangePickerInput, { label: props.filter.label, name: props.filter.name, onChange: onChange, value: props.value, placeholder: (_a = props.filter.config) === null || _a === void 0 ? void 0 : _a.placeholder }))));
|
|
16
17
|
},
|
|
17
18
|
ListItem(props) {
|
|
18
19
|
if ((0, is_nil_1.isNil)(props.value)) {
|
|
@@ -9,11 +9,11 @@ const multi_select_1 = require("@uxf/ui/multi-select");
|
|
|
9
9
|
const react_1 = __importDefault(require("react"));
|
|
10
10
|
const filterHandler = {
|
|
11
11
|
Input(props) {
|
|
12
|
-
var _a;
|
|
12
|
+
var _a, _b;
|
|
13
13
|
const onChange = (value) => {
|
|
14
14
|
props.onChange(Array.isArray(value) && !(0, is_empty_1.isEmpty)(value) ? value : null);
|
|
15
15
|
};
|
|
16
|
-
return (react_1.default.createElement(multi_select_1.MultiSelect, { options: (_a = props.filter.options) !== null && _a !== void 0 ? _a : [], label: props.filter.label, value: props.value, onChange: onChange, name: props.filter.name }));
|
|
16
|
+
return (react_1.default.createElement(multi_select_1.MultiSelect, { options: (_a = props.filter.options) !== null && _a !== void 0 ? _a : [], label: props.filter.label, value: props.value, onChange: onChange, name: props.filter.name, placeholder: (_b = props.filter.config) === null || _b === void 0 ? void 0 : _b.placeholder }));
|
|
17
17
|
},
|
|
18
18
|
ListItem(props) {
|
|
19
19
|
var _a;
|
package/filter-handler/select.js
CHANGED
|
@@ -8,8 +8,8 @@ const select_1 = require("@uxf/ui/select");
|
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
9
|
const filterHandler = {
|
|
10
10
|
Input(props) {
|
|
11
|
-
var _a;
|
|
12
|
-
return (react_1.default.createElement(select_1.Select, { options: (_a = props.filter.options) !== null && _a !== void 0 ? _a : [], label: props.filter.label, value: props.value, onChange: (value) => props.onChange(value), isClearable: true, name: props.filter.name }));
|
|
11
|
+
var _a, _b;
|
|
12
|
+
return (react_1.default.createElement(select_1.Select, { options: (_a = props.filter.options) !== null && _a !== void 0 ? _a : [], label: props.filter.label, value: props.value, onChange: (value) => props.onChange(value), isClearable: true, name: props.filter.name, placeholder: (_b = props.filter.config) === null || _b === void 0 ? void 0 : _b.placeholder }));
|
|
13
13
|
},
|
|
14
14
|
ListItem(props) {
|
|
15
15
|
var _a, _b, _c;
|
package/filter-handler/string.js
CHANGED
|
@@ -10,8 +10,8 @@ const text_input_1 = require("@uxf/ui/text-input");
|
|
|
10
10
|
const react_1 = __importDefault(require("react"));
|
|
11
11
|
const filterHandler = {
|
|
12
12
|
Input(props) {
|
|
13
|
-
var _a;
|
|
14
|
-
return (react_1.default.createElement(text_input_1.TextInput, { label: props.filter.label, value: (_a = props.value) !== null && _a !== void 0 ? _a : "", onChange: (value) => props.onChange(value), name: props.filter.name }));
|
|
13
|
+
var _a, _b;
|
|
14
|
+
return (react_1.default.createElement(text_input_1.TextInput, { label: props.filter.label, value: (_a = props.value) !== null && _a !== void 0 ? _a : "", onChange: (value) => props.onChange(value), name: props.filter.name, placeholder: (_b = props.filter.config) === null || _b === void 0 ? void 0 : _b.placeholder }));
|
|
15
15
|
},
|
|
16
16
|
ListItem(props) {
|
|
17
17
|
if ((0, is_nil_1.isNil)(props.value) || (0, is_empty_1.isEmpty)(props.value)) {
|
|
@@ -36,7 +36,7 @@ function FiltersButton(props) {
|
|
|
36
36
|
return null;
|
|
37
37
|
}
|
|
38
38
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
39
|
-
react_1.default.createElement(button_1.Button, { isIconButton: true, variant: "
|
|
39
|
+
react_1.default.createElement(button_1.Button, { isIconButton: true, variant: "secondary", size: "sm", onClick: () => setIsOpen(true), title: "Filtrovat", className: "uxf-data-grid__plugin-button" },
|
|
40
40
|
react_1.default.createElement(icon_1.Icon, { name: "filter" })),
|
|
41
41
|
react_1.default.createElement(drawer_1.Drawer, { open: isOpen, onClose: () => setIsOpen(false) },
|
|
42
42
|
react_1.default.createElement(filters_1.DataGridFilters, { state: props.state, actions: props.actions, schema: props.schema, filterHandlers: props.filterHandlers }))));
|
|
@@ -33,7 +33,7 @@ const hidden_columns_1 = require("../hidden-columns");
|
|
|
33
33
|
function HiddenColumnsButton(props) {
|
|
34
34
|
const [isOpen, setIsOpen] = (0, react_1.useState)(false);
|
|
35
35
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
36
|
-
react_1.default.createElement(button_1.Button, { isIconButton: true, variant: "
|
|
36
|
+
react_1.default.createElement(button_1.Button, { isIconButton: true, variant: "secondary", size: "sm", onClick: () => setIsOpen(true), title: "Nastaven\u00ED sloupc\u016F", className: "uxf-data-grid__plugin-button" },
|
|
37
37
|
react_1.default.createElement(icon_1.Icon, { name: "table-columns" })),
|
|
38
38
|
react_1.default.createElement(drawer_1.Drawer, { open: isOpen, onClose: () => setIsOpen(false), title: "Nastaven\u00ED sloupc\u016F" },
|
|
39
39
|
react_1.default.createElement(hidden_columns_1.HiddenColumns, { state: props.state, actions: props.actions, schema: props.schema }))));
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -14,10 +14,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.encodeFilter = exports.decodeFilter = void 0;
|
|
17
|
+
exports.mergeSchemaWithConfig = exports.encodeFilter = exports.decodeFilter = void 0;
|
|
18
18
|
__exportStar(require("./data-grid"), exports);
|
|
19
19
|
__exportStar(require("./hooks/useCallbackRef"), exports);
|
|
20
20
|
__exportStar(require("./types"), exports);
|
|
21
21
|
var utils_1 = require("./utils");
|
|
22
22
|
Object.defineProperty(exports, "decodeFilter", { enumerable: true, get: function () { return utils_1.decodeFilter; } });
|
|
23
23
|
Object.defineProperty(exports, "encodeFilter", { enumerable: true, get: function () { return utils_1.encodeFilter; } });
|
|
24
|
+
var merge_schema_with_config_1 = require("./utils/merge-schema-with-config");
|
|
25
|
+
Object.defineProperty(exports, "mergeSchemaWithConfig", { enumerable: true, get: function () { return merge_schema_with_config_1.mergeSchemaWithConfig; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uxf/data-grid",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.27.0",
|
|
4
4
|
"description": "UXF DataGrid",
|
|
5
5
|
"homepage": "https://gitlab.com/uxf-npm/data-grid#readme",
|
|
6
6
|
"main": "index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dev": "next dev",
|
|
26
26
|
"build": "tsc -P tsconfig.json",
|
|
27
27
|
"gen:icons": "icons-gen",
|
|
28
|
-
"gen:data-grid": "node bin/uxf-data-grid-generator.js -s _generator/
|
|
28
|
+
"gen:data-grid": "node bin/uxf-data-grid-generator.js -s _generator/__generator_tests__/data-grid-schema -o _generator/__generator_tests__/data-grid --requiredLoader",
|
|
29
29
|
"lint": "./node_modules/.bin/eslint -c .eslintrc.js \"./**/*.ts*\"",
|
|
30
30
|
"test": "npm run-script typecheck",
|
|
31
31
|
"typecheck": "tsc --noEmit --skipLibCheck"
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@uxf/core": "11.22.0",
|
|
35
35
|
"@uxf/core-react": "11.22.0",
|
|
36
|
-
"@uxf/ui": "11.
|
|
36
|
+
"@uxf/ui": "11.27.0",
|
|
37
37
|
"dayjs": "1.11.10",
|
|
38
38
|
"deepmerge": "4.3.1",
|
|
39
39
|
"fast-glob": "3.3.2",
|
|
@@ -9,6 +9,6 @@ const react_1 = __importDefault(require("react"));
|
|
|
9
9
|
const action_cell_wrapper_1 = require("./action-cell-wrapper");
|
|
10
10
|
function ActionCell(props) {
|
|
11
11
|
return (react_1.default.createElement(action_cell_wrapper_1.ActionCellWrapper, null,
|
|
12
|
-
react_1.default.createElement(button_list_1.ButtonList, { buttons: props.buttons, visibleButtonsCount: props.visibleButtonsCount, variant: "
|
|
12
|
+
react_1.default.createElement(button_list_1.ButtonList, { buttons: props.buttons, visibleButtonsCount: props.visibleButtonsCount, variant: "secondary", size: "sm" })));
|
|
13
13
|
}
|
|
14
14
|
exports.ActionCell = ActionCell;
|
|
@@ -13,7 +13,7 @@ function ToolbarCustoms(props) {
|
|
|
13
13
|
return null;
|
|
14
14
|
}
|
|
15
15
|
return (react_1.default.createElement("div", { className: "uxf-data-grid__toolbar-customs" },
|
|
16
|
-
react_1.default.createElement("div", { className: "uxf-data-grid__toolbar-customs-mobile" }, props.buttons.length === 1 ? (react_1.default.createElement(button_1.Button, { href: props.buttons[0].href, onClick: props.buttons[0].onClick, size: "sm", variant: props.buttons[0].variant }, props.buttons[0].label)) : (react_1.default.createElement(button_list_1.ButtonList, { buttons: props.buttons, visibleButtonsCount: 1, size: "sm", openButton: { variant: "
|
|
16
|
+
react_1.default.createElement("div", { className: "uxf-data-grid__toolbar-customs-mobile" }, props.buttons.length === 1 ? (react_1.default.createElement(button_1.Button, { href: props.buttons[0].href, onClick: props.buttons[0].onClick, size: "sm", variant: props.buttons[0].variant }, props.buttons[0].label)) : (react_1.default.createElement(button_list_1.ButtonList, { buttons: props.buttons, visibleButtonsCount: 1, size: "sm", openButton: { variant: "secondary" } }))),
|
|
17
17
|
react_1.default.createElement("div", { className: "uxf-data-grid__toolbar-customs-desktop" }, props.buttons.map((button, index) => (react_1.default.createElement(button_1.Button, { key: index, href: button.href, onClick: button.onClick, size: "sm", variant: button.variant }, button.label))))));
|
|
18
18
|
}
|
|
19
19
|
exports.ToolbarCustoms = ToolbarCustoms;
|
|
@@ -10,7 +10,7 @@ function Default() {
|
|
|
10
10
|
return (react_1.default.createElement(toolbar_customs_1.DataGridToolbarCustoms, { buttons: [
|
|
11
11
|
{ label: "Default", href: "/", variant: "default" },
|
|
12
12
|
{ label: "Text", href: "/", variant: "text" },
|
|
13
|
-
{ label: "Outlined", href: "/", variant: "
|
|
13
|
+
{ label: "Outlined", href: "/", variant: "secondary" },
|
|
14
14
|
] }));
|
|
15
15
|
}
|
|
16
16
|
exports.Default = Default;
|
package/types/schema.d.ts
CHANGED
|
@@ -26,6 +26,9 @@ export type Column<Name, Type> = {
|
|
|
26
26
|
hidden?: boolean;
|
|
27
27
|
config?: ColumnConfig;
|
|
28
28
|
};
|
|
29
|
+
export type FilterConfig = {
|
|
30
|
+
placeholder?: string;
|
|
31
|
+
};
|
|
29
32
|
export type ColumnConfig = {
|
|
30
33
|
isHidden?: boolean;
|
|
31
34
|
width?: number;
|
|
@@ -44,10 +47,11 @@ export interface Filter {
|
|
|
44
47
|
type: string;
|
|
45
48
|
options?: FilterOption[];
|
|
46
49
|
autocomplete?: string | null;
|
|
50
|
+
config?: FilterConfig;
|
|
47
51
|
}
|
|
48
|
-
export interface Schema<
|
|
52
|
+
export interface Schema<GridType extends BaseGridType> {
|
|
49
53
|
name?: string;
|
|
50
|
-
columns: Columns<
|
|
54
|
+
columns: Columns<GridType["columns"]>[];
|
|
51
55
|
filters: Filter[];
|
|
52
56
|
tabs?: Tab[];
|
|
53
57
|
s: DataGridSort;
|
package/types/state.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RequestFilter } from "./api";
|
|
2
|
-
import { BaseGridType, DataGridSort } from "./schema";
|
|
2
|
+
import { BaseGridType, ColumnConfig, DataGridSort, FilterConfig } from "./schema";
|
|
3
3
|
export type GridRequest = {
|
|
4
4
|
f: RequestFilter[];
|
|
5
5
|
s: DataGridSort | null;
|
|
@@ -8,15 +8,13 @@ export type GridRequest = {
|
|
|
8
8
|
search: string;
|
|
9
9
|
tab: string | null;
|
|
10
10
|
};
|
|
11
|
-
interface ColumnConfig {
|
|
12
|
-
isHidden?: boolean;
|
|
13
|
-
width?: number;
|
|
14
|
-
minWidth?: number;
|
|
15
|
-
}
|
|
16
11
|
export interface DataGridUserConfig<GridType extends BaseGridType> {
|
|
17
12
|
columns?: Partial<Record<keyof GridType["columns"], ColumnConfig>>;
|
|
18
13
|
perPage?: number;
|
|
19
14
|
}
|
|
15
|
+
export interface DataGridFrontendConfig<GridType extends BaseGridType> extends DataGridUserConfig<GridType> {
|
|
16
|
+
filters?: Partial<Record<keyof GridType["filters"], FilterConfig>>;
|
|
17
|
+
}
|
|
20
18
|
export interface DataGridState<GridType extends BaseGridType> {
|
|
21
19
|
request: GridRequest;
|
|
22
20
|
selectedRows?: any[];
|
|
@@ -25,4 +23,3 @@ export interface DataGridState<GridType extends BaseGridType> {
|
|
|
25
23
|
[tab: string]: GridRequest;
|
|
26
24
|
};
|
|
27
25
|
}
|
|
28
|
-
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { BaseGridType, Schema } from "../types/schema";
|
|
2
|
+
import { DataGridFrontendConfig } from "../types/state";
|
|
3
|
+
export declare function mergeSchemaWithConfig<GridType extends BaseGridType>(schema: Schema<GridType>, frontendConfig: DataGridFrontendConfig<GridType>): Schema<GridType>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mergeSchemaWithConfig = void 0;
|
|
4
|
+
function mergeSchemaWithConfig(schema, frontendConfig) {
|
|
5
|
+
var _a;
|
|
6
|
+
return {
|
|
7
|
+
...schema,
|
|
8
|
+
perPage: (_a = frontendConfig.perPage) !== null && _a !== void 0 ? _a : schema.perPage,
|
|
9
|
+
columns: schema.columns.map((column) => {
|
|
10
|
+
var _a;
|
|
11
|
+
return ({
|
|
12
|
+
...column,
|
|
13
|
+
config: {
|
|
14
|
+
...column.config,
|
|
15
|
+
...(_a = frontendConfig.columns) === null || _a === void 0 ? void 0 : _a[column.name],
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
}),
|
|
19
|
+
filters: schema.filters.map((filter) => {
|
|
20
|
+
var _a;
|
|
21
|
+
return ({
|
|
22
|
+
...filter,
|
|
23
|
+
config: {
|
|
24
|
+
...filter.config,
|
|
25
|
+
...(_a = frontendConfig.filters) === null || _a === void 0 ? void 0 : _a[filter.name],
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
exports.mergeSchemaWithConfig = mergeSchemaWithConfig;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const merge_schema_with_config_1 = require("./merge-schema-with-config");
|
|
4
|
+
const schema = {
|
|
5
|
+
name: "test",
|
|
6
|
+
columns: [
|
|
7
|
+
{ name: "id", type: "integer", label: "ID", config: { width: 50, isHidden: true } },
|
|
8
|
+
{ name: "name", type: "string", label: "Name", config: {} },
|
|
9
|
+
],
|
|
10
|
+
filters: [{ name: "id", type: "integer", label: "ID", config: { placeholder: "Placeholder" } }],
|
|
11
|
+
tabs: [],
|
|
12
|
+
s: { name: "id", dir: "asc" },
|
|
13
|
+
fullText: false,
|
|
14
|
+
perPage: 10,
|
|
15
|
+
};
|
|
16
|
+
test("merge perPage", () => {
|
|
17
|
+
expect((0, merge_schema_with_config_1.mergeSchemaWithConfig)(schema, { perPage: 100 })).toStrictEqual({
|
|
18
|
+
name: "test",
|
|
19
|
+
columns: [
|
|
20
|
+
{ name: "id", type: "integer", label: "ID", config: { width: 50, isHidden: true } },
|
|
21
|
+
{ name: "name", type: "string", label: "Name", config: {} },
|
|
22
|
+
],
|
|
23
|
+
filters: [{ name: "id", type: "integer", label: "ID", config: { placeholder: "Placeholder" } }],
|
|
24
|
+
tabs: [],
|
|
25
|
+
s: { name: "id", dir: "asc" },
|
|
26
|
+
fullText: false,
|
|
27
|
+
perPage: 100,
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
test("merge columns", () => {
|
|
31
|
+
expect((0, merge_schema_with_config_1.mergeSchemaWithConfig)(schema, { columns: { id: { width: 100 } } })).toStrictEqual({
|
|
32
|
+
name: "test",
|
|
33
|
+
columns: [
|
|
34
|
+
{ name: "id", type: "integer", label: "ID", config: { width: 100, isHidden: true } },
|
|
35
|
+
{ name: "name", type: "string", label: "Name", config: {} },
|
|
36
|
+
],
|
|
37
|
+
filters: [{ name: "id", type: "integer", label: "ID", config: { placeholder: "Placeholder" } }],
|
|
38
|
+
tabs: [],
|
|
39
|
+
s: { name: "id", dir: "asc" },
|
|
40
|
+
fullText: false,
|
|
41
|
+
perPage: 10,
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
test("merge filters", () => {
|
|
45
|
+
expect((0, merge_schema_with_config_1.mergeSchemaWithConfig)(schema, { filters: { id: { placeholder: "CHANGED Placeholder" } } })).toStrictEqual({
|
|
46
|
+
name: "test",
|
|
47
|
+
columns: [
|
|
48
|
+
{ name: "id", type: "integer", label: "ID", config: { width: 50, isHidden: true } },
|
|
49
|
+
{ name: "name", type: "string", label: "Name", config: {} },
|
|
50
|
+
],
|
|
51
|
+
filters: [{ name: "id", type: "integer", label: "ID", config: { placeholder: "CHANGED Placeholder" } }],
|
|
52
|
+
tabs: [],
|
|
53
|
+
s: { name: "id", dir: "asc" },
|
|
54
|
+
fullText: false,
|
|
55
|
+
perPage: 10,
|
|
56
|
+
});
|
|
57
|
+
});
|