@uxf/data-grid 10.5.0 → 11.0.0-beta.10
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/_store/reducer.d.ts +8 -0
- package/{store → _store}/reducer.js +50 -23
- package/_story-utils/data.d.ts +12 -0
- package/_story-utils/data.js +115 -0
- package/_story-utils/grid-type.d.ts +22 -0
- package/_story-utils/grid-type.js +2 -0
- package/_story-utils/loader.d.ts +2 -0
- package/_story-utils/loader.js +36 -0
- package/_story-utils/schema.d.ts +3 -0
- package/_story-utils/schema.js +53 -0
- package/{tailwindui/body-cell → body-cell}/body-cell-boolean.d.ts +1 -1
- package/{tailwindui/body-cell → body-cell}/body-cell-date.d.ts +1 -1
- package/{tailwindui/body-cell → body-cell}/body-cell-datetime.d.ts +1 -1
- package/{tailwindui/body-cell → body-cell}/body-cell-default.d.ts +1 -1
- package/{tailwindui/body-cell → body-cell}/body-cell-email.d.ts +1 -1
- package/{tailwindui/body-cell → body-cell}/body-cell-phone.d.ts +1 -1
- package/{tailwindui/body-cell → body-cell}/body-cell-to-many.d.ts +1 -1
- package/{tailwindui/body-cell → body-cell}/body-cell-to-one.d.ts +1 -1
- package/{tailwindui/body-cell → body-cell}/body-cell-url.d.ts +1 -1
- package/{tailwindui/body-cell → body-cell}/index.d.ts +1 -1
- package/data-grid.d.ts +1 -1
- package/data-grid.js +34 -120
- package/data-grid.stories.d.ts +0 -5
- package/data-grid.stories.js +21 -216
- package/export-button/export-button.d.ts +10 -0
- package/export-button/export-button.js +15 -0
- package/export-button/export-button.stories.d.ts +2 -0
- package/export-button/export-button.stories.js +18 -0
- package/export-button/index.d.ts +1 -0
- package/{tailwindui → export-button}/index.js +1 -3
- package/{tailwindui/filter-handler → filter-handler}/bool-filter.d.ts +1 -1
- package/{tailwindui/filter-handler → filter-handler}/boolean-filter.d.ts +1 -1
- package/filter-handler/index.d.ts +4 -0
- package/{tailwindui/filter-handler → filter-handler}/index.js +15 -0
- package/{tailwindui/filter-handler → filter-handler}/interval-filter.d.ts +1 -1
- package/{tailwindui/filter-handler → filter-handler}/interval-filter.js +2 -2
- package/{tailwindui/filter-handler → filter-handler}/select-filter.d.ts +1 -1
- package/{tailwindui/filter-handler → filter-handler}/text-filter.d.ts +1 -1
- package/filter-handler/types.d.ts +8 -0
- package/filter-handler/types.js +2 -0
- package/filter-list/filter-list.d.ts +11 -0
- package/{tailwindui/components → filter-list}/filter-list.js +7 -6
- package/filter-list/filter-list.stories.d.ts +2 -0
- package/filter-list/filter-list.stories.js +19 -0
- package/filter-list/index.d.ts +1 -0
- package/filter-list/index.js +17 -0
- package/filters/filters.d.ts +11 -0
- package/filters/filters.js +25 -0
- package/filters/filters.stories.d.ts +2 -0
- package/filters/filters.stories.js +19 -0
- package/filters/index.d.ts +1 -0
- package/filters/index.js +17 -0
- package/filters-button/filters-button.d.ts +11 -0
- package/{tailwindui/show.js → filters-button/filters-button.js} +15 -6
- package/filters-button/filters-button.stories.d.ts +2 -0
- package/filters-button/filters-button.stories.js +19 -0
- package/filters-button/index.d.ts +1 -0
- package/filters-button/index.js +17 -0
- package/fulltext-input/fulltext-input.d.ts +5 -0
- package/fulltext-input/fulltext-input.js +13 -0
- package/fulltext-input/fulltext-input.stories.d.ts +2 -0
- package/fulltext-input/fulltext-input.stories.js +18 -0
- package/fulltext-input/index.d.ts +1 -0
- package/fulltext-input/index.js +17 -0
- package/hidden-columns/hidden-columns.d.ts +8 -0
- package/hidden-columns/hidden-columns.js +15 -0
- package/hidden-columns/hidden-columns.stories.d.ts +2 -0
- package/hidden-columns/hidden-columns.stories.js +18 -0
- package/hidden-columns/index.d.ts +1 -0
- package/hidden-columns/index.js +17 -0
- package/hidden-columns-button/hidden-columns-button.d.ts +8 -0
- package/{tailwindui/data-grid.js → hidden-columns-button/hidden-columns-button.js} +14 -10
- package/hidden-columns-button/hidden-columns-button.stories.d.ts +2 -0
- package/hidden-columns-button/hidden-columns-button.stories.js +18 -0
- package/hidden-columns-button/index.d.ts +1 -0
- package/hidden-columns-button/index.js +17 -0
- package/linear-progress/index.d.ts +1 -0
- package/linear-progress/index.js +17 -0
- package/linear-progress/linear-progress.d.ts +5 -0
- package/{tailwindui/components → linear-progress}/linear-progress.js +4 -4
- package/package.json +2 -2
- package/pagination/index.d.ts +1 -0
- package/pagination/index.js +17 -0
- package/pagination/pagination.d.ts +8 -0
- package/pagination/pagination.js +16 -0
- package/pagination/pagination.stories.d.ts +2 -0
- package/pagination/pagination.stories.js +18 -0
- package/row-counts/index.d.ts +1 -0
- package/row-counts/index.js +17 -0
- package/row-counts/row-counts.d.ts +7 -0
- package/row-counts/row-counts.js +18 -0
- package/row-counts/row-counts.stories.d.ts +2 -0
- package/row-counts/row-counts.stories.js +15 -0
- package/rows-per-page-select/index.d.ts +1 -0
- package/rows-per-page-select/index.js +17 -0
- package/rows-per-page-select/rows-per-page-select.d.ts +3 -0
- package/{tailwindui/components/pagination-rows-per-page-select.js → rows-per-page-select/rows-per-page-select.js} +5 -5
- package/rows-per-page-select/rows-per-page-select.stories.d.ts +2 -0
- package/rows-per-page-select/rows-per-page-select.stories.js +18 -0
- package/selected-rows-toolbar/index.d.ts +1 -0
- package/selected-rows-toolbar/index.js +17 -0
- package/selected-rows-toolbar/selected-rows-toolbar.d.ts +11 -0
- package/{tailwindui/components → selected-rows-toolbar}/selected-rows-toolbar.js +9 -6
- package/selected-rows-toolbar/selected-rows-toolbar.stories.d.ts +2 -0
- package/{tailwindui/components/select-row-checkbox.js → selected-rows-toolbar/selected-rows-toolbar.stories.js} +18 -14
- package/{tailwindui/styles.css → styles.css} +6 -2
- package/table/components/select-row-checkbox.d.ts +3 -0
- package/table/components/select-row-checkbox.js +20 -0
- package/table/hooks/use-react-data-grid-columns.d.ts +4 -0
- package/table/hooks/use-react-data-grid-columns.js +99 -0
- package/table/index.d.ts +1 -0
- package/table/index.js +17 -0
- package/table/no-rows-fallback.d.ts +7 -0
- package/{tailwindui/components → table}/no-rows-fallback.js +4 -4
- package/table/table.d.ts +3 -0
- package/table/table.js +83 -0
- package/table/table.stories.d.ts +2 -0
- package/table/table.stories.js +20 -0
- package/table/types.d.ts +26 -0
- package/table/types.js +2 -0
- package/toolbar-control/index.d.ts +1 -0
- package/toolbar-control/index.js +17 -0
- package/toolbar-control/toolbar-control.d.ts +13 -0
- package/toolbar-control/toolbar-control.js +22 -0
- package/toolbar-control/toolbar-control.stories.d.ts +2 -0
- package/toolbar-control/toolbar-control.stories.js +20 -0
- package/toolbar-customs/index.d.ts +1 -0
- package/toolbar-customs/index.js +17 -0
- package/toolbar-customs/toolbar-customs.d.ts +10 -0
- package/{tailwindui/components → toolbar-customs}/toolbar-customs.js +2 -2
- package/toolbar-customs/toolbar-customs.stories.d.ts +2 -0
- package/toolbar-customs/toolbar-customs.stories.js +16 -0
- package/toolbar-tabs/index.d.ts +1 -0
- package/toolbar-tabs/index.js +17 -0
- package/toolbar-tabs/toolbar-tabs.d.ts +7 -0
- package/{tailwindui/components → toolbar-tabs}/toolbar-tabs.js +10 -10
- package/toolbar-tabs/toolbar-tabs.stories.d.ts +2 -0
- package/toolbar-tabs/toolbar-tabs.stories.js +18 -0
- package/types/components.d.ts +5 -160
- package/types/data-grid-props.d.ts +16 -23
- package/types/state.d.ts +12 -5
- package/types/ui-components.d.ts +7 -16
- package/use-data-grid-control/actions-factory.d.ts +14 -0
- package/use-data-grid-control/actions-factory.js +18 -0
- package/use-data-grid-control/index.d.ts +1 -0
- package/use-data-grid-control/index.js +17 -0
- package/use-data-grid-control/use-data-grid-control.d.ts +27 -0
- package/use-data-grid-control/use-data-grid-control.js +12 -0
- package/use-data-grid-fetching/index.d.ts +1 -0
- package/use-data-grid-fetching/index.js +17 -0
- package/use-data-grid-fetching/use-data-grid-fetching.d.ts +22 -0
- package/use-data-grid-fetching/use-data-grid-fetching.js +39 -0
- package/utils/classes.d.ts +1 -0
- package/utils/classes.js +4 -0
- package/utils.d.ts +4 -5
- package/utils.js +9 -60
- package/hooks/useColumns.d.ts +0 -3
- package/hooks/useColumns.js +0 -97
- package/store/reducer.d.ts +0 -5
- package/tailwindui/components/container.d.ts +0 -2
- package/tailwindui/components/container.js +0 -13
- package/tailwindui/components/filter-list.d.ts +0 -2
- package/tailwindui/components/footer.d.ts +0 -2
- package/tailwindui/components/footer.js +0 -12
- package/tailwindui/components/linear-progress.d.ts +0 -2
- package/tailwindui/components/no-rows-fallback.d.ts +0 -2
- package/tailwindui/components/pagination-counts.d.ts +0 -2
- package/tailwindui/components/pagination-counts.js +0 -18
- package/tailwindui/components/pagination-rows-per-page-select.d.ts +0 -2
- package/tailwindui/components/select-row-checkbox.d.ts +0 -2
- package/tailwindui/components/selected-rows-toolbar.d.ts +0 -2
- package/tailwindui/components/toolbar-control.d.ts +0 -2
- package/tailwindui/components/toolbar-control.js +0 -86
- package/tailwindui/components/toolbar-customs.d.ts +0 -2
- package/tailwindui/components/toolbar-tabs.d.ts +0 -2
- package/tailwindui/components/toolbar.d.ts +0 -2
- package/tailwindui/components/toolbar.js +0 -12
- package/tailwindui/data-grid.d.ts +0 -6
- package/tailwindui/filter-handler/index.d.ts +0 -2
- package/tailwindui/index.d.ts +0 -3
- package/tailwindui/show.d.ts +0 -7
- package/tailwindui/ui.d.ts +0 -2
- package/tailwindui/ui.js +0 -38
- /package/{tailwindui/components → _components}/drawer.d.ts +0 -0
- /package/{tailwindui/components → _components}/drawer.js +0 -0
- /package/{store → _store}/actions.d.ts +0 -0
- /package/{store → _store}/actions.js +0 -0
- /package/{tailwindui/body-cell → body-cell}/body-cell-boolean.js +0 -0
- /package/{tailwindui/body-cell → body-cell}/body-cell-date.js +0 -0
- /package/{tailwindui/body-cell → body-cell}/body-cell-datetime.js +0 -0
- /package/{tailwindui/body-cell → body-cell}/body-cell-default.js +0 -0
- /package/{tailwindui/body-cell → body-cell}/body-cell-email.js +0 -0
- /package/{tailwindui/body-cell → body-cell}/body-cell-phone.js +0 -0
- /package/{tailwindui/body-cell → body-cell}/body-cell-to-many.js +0 -0
- /package/{tailwindui/body-cell → body-cell}/body-cell-to-one.js +0 -0
- /package/{tailwindui/body-cell → body-cell}/body-cell-url.js +0 -0
- /package/{tailwindui/body-cell → body-cell}/index.js +0 -0
- /package/{tailwindui/filter-handler → filter-handler}/bool-filter.js +0 -0
- /package/{tailwindui/filter-handler → filter-handler}/boolean-filter.js +0 -0
- /package/{tailwindui/filter-handler → filter-handler}/select-filter.js +0 -0
- /package/{tailwindui/filter-handler → filter-handler}/text-filter.js +0 -0
- /package/{tailwindui → table}/components/action-cell-base.d.ts +0 -0
- /package/{tailwindui → table}/components/action-cell-base.js +0 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Nullish } from "@uxf/core/types";
|
|
2
|
+
import { Reducer } from "react";
|
|
3
|
+
import { Request } from "../types/api";
|
|
4
|
+
import { Schema } from "../types/schema";
|
|
5
|
+
import { DataGridState, DataGridUserConfig } from "../types/state";
|
|
6
|
+
export declare const getInitialState: (schema: Schema<any>, init?: Request | string | Nullish, initialUserConfig?: DataGridUserConfig | Nullish) => DataGridState;
|
|
7
|
+
export declare const reducer: Reducer<DataGridState, any>;
|
|
8
|
+
export declare const debugReducer: Reducer<DataGridState, any>;
|
|
@@ -1,45 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.debugReducer = exports.reducer = exports.getInitialState = void 0;
|
|
4
|
+
const is_nil_1 = require("@uxf/core/utils/is-nil");
|
|
4
5
|
const utils_1 = require("../utils");
|
|
5
|
-
const getInitialState = (schema, init) => {
|
|
6
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
7
|
-
const initialState = init
|
|
6
|
+
const getInitialState = (schema, init, initialUserConfig) => {
|
|
7
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
8
|
+
const initialState = (0, is_nil_1.isNil)(init) ? {} : typeof init === "string" ? (_a = (0, utils_1.decodeFilter)(init)) !== null && _a !== void 0 ? _a : {} : init;
|
|
8
9
|
return {
|
|
9
10
|
request: {
|
|
10
11
|
f: (_b = initialState.f) !== null && _b !== void 0 ? _b : [],
|
|
11
12
|
page: (_c = initialState.page) !== null && _c !== void 0 ? _c : 0,
|
|
12
13
|
dir: (_d = initialState.dir) !== null && _d !== void 0 ? _d : schema.dir,
|
|
13
14
|
sort: (_e = initialState.sort) !== null && _e !== void 0 ? _e : schema.sort,
|
|
14
|
-
perPage: (_f = initialState.perPage) !== null && _f !== void 0 ? _f : schema.perPage,
|
|
15
|
-
tab: (
|
|
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: (_k = (_j = (_h = schema.tabs) === null || _h === void 0 ? void 0 : _h[0]) === null || _j === void 0 ? void 0 : _j.name) !== null && _k !== void 0 ? _k : null,
|
|
16
17
|
search: "",
|
|
17
18
|
},
|
|
19
|
+
userConfig: {
|
|
20
|
+
columns: (_l = initialUserConfig === null || initialUserConfig === void 0 ? void 0 : initialUserConfig.columns) !== null && _l !== void 0 ? _l : {},
|
|
21
|
+
perPage: (_m = initialUserConfig === null || initialUserConfig === void 0 ? void 0 : initialUserConfig.perPage) !== null && _m !== void 0 ? _m : schema.perPage,
|
|
22
|
+
},
|
|
18
23
|
tabRequests: {},
|
|
19
24
|
};
|
|
20
25
|
};
|
|
21
26
|
exports.getInitialState = getInitialState;
|
|
22
27
|
// eslint-disable-next-line complexity
|
|
23
28
|
const reducer = (state, action) => {
|
|
24
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
29
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
25
30
|
switch (action.type) {
|
|
26
|
-
case "RELOAD":
|
|
27
|
-
return {
|
|
28
|
-
...state,
|
|
29
|
-
loading: true,
|
|
30
|
-
};
|
|
31
|
-
case "RELOAD_DONE":
|
|
32
|
-
return {
|
|
33
|
-
...state,
|
|
34
|
-
loading: false,
|
|
35
|
-
response: action.response,
|
|
36
|
-
};
|
|
37
|
-
case "RELOAD_FAILED":
|
|
38
|
-
return {
|
|
39
|
-
...state,
|
|
40
|
-
loading: false,
|
|
41
|
-
error: action.error,
|
|
42
|
-
};
|
|
43
31
|
case "CHANGE_PAGE":
|
|
44
32
|
return {
|
|
45
33
|
...state,
|
|
@@ -55,6 +43,10 @@ const reducer = (state, action) => {
|
|
|
55
43
|
...state.request,
|
|
56
44
|
perPage: action.perPage,
|
|
57
45
|
},
|
|
46
|
+
userConfig: {
|
|
47
|
+
...state.userConfig,
|
|
48
|
+
perPage: action.perPage,
|
|
49
|
+
},
|
|
58
50
|
};
|
|
59
51
|
case "FILTER":
|
|
60
52
|
// eslint-disable-next-line no-case-declarations
|
|
@@ -128,6 +120,41 @@ const reducer = (state, action) => {
|
|
|
128
120
|
[(_h = state.request.tab) !== null && _h !== void 0 ? _h : "__DEFAULT_TAB__"]: state.request,
|
|
129
121
|
},
|
|
130
122
|
};
|
|
123
|
+
case "SET_SELECTED_ROWS":
|
|
124
|
+
return {
|
|
125
|
+
...state,
|
|
126
|
+
selectedRows: action.rows,
|
|
127
|
+
};
|
|
128
|
+
case "HIDE_COLUMN":
|
|
129
|
+
return {
|
|
130
|
+
...state,
|
|
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
|
+
},
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
case "SHOW_COLUMN":
|
|
144
|
+
return {
|
|
145
|
+
...state,
|
|
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
|
+
},
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
};
|
|
131
158
|
default:
|
|
132
159
|
// eslint-disable-next-line no-console
|
|
133
160
|
console.warn("Unknown datagrid action.", action);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
interface Row {
|
|
2
|
+
id: number;
|
|
3
|
+
text: string | null | undefined;
|
|
4
|
+
bool: boolean | null | undefined;
|
|
5
|
+
tel: string | null | undefined;
|
|
6
|
+
mail: string | null | undefined;
|
|
7
|
+
link: string | null | undefined;
|
|
8
|
+
day: string | null | undefined;
|
|
9
|
+
dayAndTime: string | null | undefined;
|
|
10
|
+
}
|
|
11
|
+
export declare const data: Row[];
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.data = void 0;
|
|
4
|
+
exports.data = [
|
|
5
|
+
{
|
|
6
|
+
id: 1,
|
|
7
|
+
text: "Red",
|
|
8
|
+
bool: undefined,
|
|
9
|
+
tel: null,
|
|
10
|
+
mail: "dev@uxf.cz",
|
|
11
|
+
link: null,
|
|
12
|
+
day: "1998-09-15",
|
|
13
|
+
dayAndTime: null,
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
id: 2,
|
|
17
|
+
text: "Blue",
|
|
18
|
+
bool: null,
|
|
19
|
+
tel: undefined,
|
|
20
|
+
mail: "dev@uxf.cz",
|
|
21
|
+
link: undefined,
|
|
22
|
+
day: "2023-01-05",
|
|
23
|
+
dayAndTime: null,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: 3,
|
|
27
|
+
text: "Green",
|
|
28
|
+
bool: true,
|
|
29
|
+
tel: "777888999",
|
|
30
|
+
mail: undefined,
|
|
31
|
+
link: null,
|
|
32
|
+
day: "1998-09-15",
|
|
33
|
+
dayAndTime: undefined,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: 4,
|
|
37
|
+
text: "Gray",
|
|
38
|
+
bool: false,
|
|
39
|
+
tel: "555777888",
|
|
40
|
+
mail: "dev@uxf.cz",
|
|
41
|
+
link: "https://www.uxf.cz",
|
|
42
|
+
day: "2023-01-05",
|
|
43
|
+
dayAndTime: undefined,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: 5,
|
|
47
|
+
text: "Pink",
|
|
48
|
+
bool: false,
|
|
49
|
+
tel: "45654412",
|
|
50
|
+
mail: undefined,
|
|
51
|
+
link: undefined,
|
|
52
|
+
day: "2023-01-05",
|
|
53
|
+
dayAndTime: "2000-10-31T01:30:00.000-05:00",
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
id: 6,
|
|
57
|
+
text: "Yellow",
|
|
58
|
+
bool: false,
|
|
59
|
+
tel: null,
|
|
60
|
+
mail: "root@uxf.cz",
|
|
61
|
+
link: "https://www.uxf.cz",
|
|
62
|
+
day: undefined,
|
|
63
|
+
dayAndTime: "2000-10-31T01:30:00.000-05:00",
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
id: 7,
|
|
67
|
+
text: "Black",
|
|
68
|
+
bool: true,
|
|
69
|
+
tel: null,
|
|
70
|
+
mail: "dev@uxf.cz",
|
|
71
|
+
link: null,
|
|
72
|
+
day: "1998-09-15",
|
|
73
|
+
dayAndTime: "2012-08-10T00:00:00.000-13:00",
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
id: 8,
|
|
77
|
+
text: "White",
|
|
78
|
+
bool: false,
|
|
79
|
+
tel: undefined,
|
|
80
|
+
mail: null,
|
|
81
|
+
link: "https://www.uxf.cz",
|
|
82
|
+
day: undefined,
|
|
83
|
+
dayAndTime: "2000-10-31T01:30:00.000-05:00",
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
id: 9,
|
|
87
|
+
text: "Liberty",
|
|
88
|
+
bool: false,
|
|
89
|
+
tel: "999888777",
|
|
90
|
+
mail: "dev@uxf.cz",
|
|
91
|
+
link: "https://google.com",
|
|
92
|
+
day: null,
|
|
93
|
+
dayAndTime: "2012-08-10T00:00:00.000-13:00",
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
id: 10,
|
|
97
|
+
text: "Blue",
|
|
98
|
+
bool: false,
|
|
99
|
+
tel: "777888999",
|
|
100
|
+
mail: "root@uxf.cz",
|
|
101
|
+
link: "https://google.com",
|
|
102
|
+
day: null,
|
|
103
|
+
dayAndTime: "2012-08-10T00:00:00.000-13:00",
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
id: 11,
|
|
107
|
+
text: "Purple",
|
|
108
|
+
bool: false,
|
|
109
|
+
tel: "777888999",
|
|
110
|
+
mail: null,
|
|
111
|
+
link: "https://google.com",
|
|
112
|
+
day: null,
|
|
113
|
+
dayAndTime: "2000-12-31T01:00:00.000-07:30",
|
|
114
|
+
},
|
|
115
|
+
];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type GridType = {
|
|
2
|
+
columns: {
|
|
3
|
+
id: "number";
|
|
4
|
+
text: "string";
|
|
5
|
+
bool: "boolean";
|
|
6
|
+
tel: "phone";
|
|
7
|
+
mail: "email";
|
|
8
|
+
link: "url";
|
|
9
|
+
day: "date";
|
|
10
|
+
dayAndTime: "datetime";
|
|
11
|
+
};
|
|
12
|
+
filters: {
|
|
13
|
+
text: "text";
|
|
14
|
+
bool: "boolean";
|
|
15
|
+
ival: "interval";
|
|
16
|
+
tel: "string";
|
|
17
|
+
mail: "string";
|
|
18
|
+
link: "string";
|
|
19
|
+
sele: "select";
|
|
20
|
+
seleBool: "select";
|
|
21
|
+
};
|
|
22
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loader = void 0;
|
|
4
|
+
const data_1 = require("./data");
|
|
5
|
+
const loader = async (_, request) => {
|
|
6
|
+
const { page = 1, perPage = 10, tab, sort, dir, f } = request;
|
|
7
|
+
// eslint-disable-next-line no-console
|
|
8
|
+
console.log("filter", f === null || f === void 0 ? void 0 : f.length);
|
|
9
|
+
const filteredData = data_1.data
|
|
10
|
+
.filter((item) => tab !== "only-odd-ids" || item.id % 2 === 0)
|
|
11
|
+
.filter((item) => { var _a; return (request.search ? (_a = item.text) === null || _a === void 0 ? void 0 : _a.match(new RegExp(request.search, "i")) : true); })
|
|
12
|
+
.sort((a, b) => {
|
|
13
|
+
if (!sort || !dir) {
|
|
14
|
+
return 1;
|
|
15
|
+
}
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
const first = a[sort];
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
const second = b[sort];
|
|
22
|
+
if (typeof first === "number") {
|
|
23
|
+
return dir === "asc" ? first - second : second - first;
|
|
24
|
+
}
|
|
25
|
+
return dir === "asc" ? first.localeCompare(second) : second.localeCompare(first);
|
|
26
|
+
});
|
|
27
|
+
// eslint-disable-next-line no-console
|
|
28
|
+
console.log("loader", request);
|
|
29
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
30
|
+
return {
|
|
31
|
+
count: filteredData.length,
|
|
32
|
+
totalCount: filteredData.length,
|
|
33
|
+
result: filteredData.slice(page * perPage, page * perPage + perPage),
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
exports.loader = loader;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.schema = void 0;
|
|
4
|
+
const types_1 = require("../types");
|
|
5
|
+
exports.schema = {
|
|
6
|
+
columns: [
|
|
7
|
+
{ name: "id", type: "number", label: "Id", sort: true },
|
|
8
|
+
{ name: "text", type: "string", label: "Text", sort: true },
|
|
9
|
+
{ name: "bool", type: "boolean", label: "Boolean" },
|
|
10
|
+
{ name: "mail", type: "email", label: "E-mail" },
|
|
11
|
+
{ name: "tel", type: "phone", label: "Phone" },
|
|
12
|
+
{ name: "link", type: "url", label: "Link" },
|
|
13
|
+
{ name: "day", type: "date", label: "Date" },
|
|
14
|
+
{ name: "dayAndTime", type: "datetime", label: "Datetime" },
|
|
15
|
+
],
|
|
16
|
+
filters: [
|
|
17
|
+
{ name: "text", type: "text", label: "Text" },
|
|
18
|
+
{ name: "bool", type: "boolean", label: "Boolean" },
|
|
19
|
+
{ name: "ival", type: "interval", label: "Super interval" },
|
|
20
|
+
{ name: "mail", type: "string", label: "E-mail" },
|
|
21
|
+
{ name: "tel", type: "string", label: "Phone" },
|
|
22
|
+
{ name: "link", type: "string", label: "Link" },
|
|
23
|
+
{
|
|
24
|
+
name: "sele",
|
|
25
|
+
type: "select",
|
|
26
|
+
label: "Select",
|
|
27
|
+
options: [
|
|
28
|
+
{ id: "", label: "" },
|
|
29
|
+
{ id: 1, label: "A" },
|
|
30
|
+
{ id: 2, label: "B" },
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: "seleBool",
|
|
35
|
+
type: "select",
|
|
36
|
+
label: "Select Boolean",
|
|
37
|
+
options: [
|
|
38
|
+
{ id: "", label: "" },
|
|
39
|
+
{ id: 1, label: "Ano" },
|
|
40
|
+
{ id: 0, label: "Ne" },
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
tabs: [
|
|
45
|
+
{ name: "all", label: "All" },
|
|
46
|
+
{ name: "only-odd-ids", label: "Only odd ids blablabla" },
|
|
47
|
+
// { name: "only-odd-ids", label: "Only odd ids" },
|
|
48
|
+
],
|
|
49
|
+
dir: types_1.DataGridSortDir.Asc,
|
|
50
|
+
sort: "id",
|
|
51
|
+
perPage: 10,
|
|
52
|
+
fullText: true,
|
|
53
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { BodyCellComponent } from "
|
|
1
|
+
import { BodyCellComponent } from "../types";
|
|
2
2
|
export declare const BodyCellBoolean: BodyCellComponent<any, any>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { BodyCellComponent } from "
|
|
1
|
+
import { BodyCellComponent } from "../types";
|
|
2
2
|
export declare const BodyCellDate: BodyCellComponent<any, any>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { BodyCellComponent } from "
|
|
1
|
+
import { BodyCellComponent } from "../types";
|
|
2
2
|
export declare const BodyCellDateTime: BodyCellComponent<any, any>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { BodyCellComponent } from "
|
|
1
|
+
import { BodyCellComponent } from "../types";
|
|
2
2
|
export declare const BodyCellDefault: BodyCellComponent<any, any>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { BodyCellComponent } from "
|
|
1
|
+
import { BodyCellComponent } from "../types";
|
|
2
2
|
export declare const BodyCellEmail: BodyCellComponent<any, any>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { BodyCellComponent } from "
|
|
1
|
+
import { BodyCellComponent } from "../types";
|
|
2
2
|
export declare const BodyCellPhone: BodyCellComponent<any, any>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { BodyCellComponent } from "
|
|
1
|
+
import { BodyCellComponent } from "../types";
|
|
2
2
|
export declare const BodyCellToMany: BodyCellComponent<any, any>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { BodyCellComponent } from "
|
|
1
|
+
import { BodyCellComponent } from "../types";
|
|
2
2
|
export declare const BodyCellToOne: BodyCellComponent<any, any>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { BodyCellComponent } from "
|
|
1
|
+
import { BodyCellComponent } from "../types";
|
|
2
2
|
export declare const BodyCellUrl: BodyCellComponent<any, any>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { BodyCellComponents } from "
|
|
1
|
+
import { BodyCellComponents } from "../types";
|
|
2
2
|
export declare const BodyCells: BodyCellComponents<any, any>;
|
package/data-grid.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { BaseGridType, DataGridProps } from "./types";
|
|
3
|
-
export declare
|
|
3
|
+
export declare function DataGrid<GridType extends BaseGridType, R = any>(props: DataGridProps<GridType, R>): React.JSX.Element;
|
package/data-grid.js
CHANGED
|
@@ -1,128 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
4
|
};
|
|
28
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
6
|
exports.DataGrid = void 0;
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const loader = props.loader;
|
|
51
|
-
const onReload = (0, react_1.useCallback)(async () => {
|
|
52
|
-
try {
|
|
53
|
-
await dispatch(actions_1.dataGridActions.reload());
|
|
54
|
-
const request = (0, utils_1.createRequest)(state, schema.sort, schema.dir);
|
|
55
|
-
const response = await loader(gridName, request, (0, utils_1.encodeFilter)(request));
|
|
56
|
-
await dispatch(actions_1.dataGridActions.reloadDone(response));
|
|
57
|
-
}
|
|
58
|
-
catch (e) {
|
|
59
|
-
await dispatch(actions_1.dataGridActions.reloadFailed(e));
|
|
60
|
-
// eslint-disable-next-line no-console
|
|
61
|
-
console.error(e);
|
|
62
|
-
}
|
|
63
|
-
}, [state, schema, gridName, loader]);
|
|
64
|
-
if (props.callbackRef) {
|
|
65
|
-
props.callbackRef.current = {
|
|
66
|
-
reload: onReload,
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
(0, react_1.useEffect)(() => {
|
|
70
|
-
onReload();
|
|
71
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
72
|
-
}, [
|
|
73
|
-
state.request.dir,
|
|
74
|
-
state.request.sort,
|
|
75
|
-
state.request.perPage,
|
|
76
|
-
state.request.page,
|
|
77
|
-
state.request.f,
|
|
78
|
-
state.request.search,
|
|
79
|
-
state.request.tab,
|
|
80
|
-
]);
|
|
81
|
-
const onFilter = (0, react_1.useCallback)((value) => {
|
|
82
|
-
dispatch(actions_1.dataGridActions.filter(value));
|
|
83
|
-
}, [dispatch]);
|
|
84
|
-
const rows = (_b = (_a = state.response) === null || _a === void 0 ? void 0 : _a.result) !== null && _b !== void 0 ? _b : [];
|
|
85
|
-
const columns = (0, useColumns_1.useColumns)(props, onReload);
|
|
86
|
-
const components = (0, react_1.useMemo)(() => {
|
|
87
|
-
return {
|
|
88
|
-
renderCheckbox: (args) => react_1.default.createElement(SelectRowCheckbox, { ...args }),
|
|
89
|
-
noRowsFallback: react_1.default.createElement(NoRowsFallback, { error: state.error, loading: !!state.loading }),
|
|
90
|
-
};
|
|
91
|
-
}, [SelectRowCheckbox, NoRowsFallback, state.error, state.loading]);
|
|
92
|
-
const sortColumns = state.request.sort && state.request.dir
|
|
93
|
-
? [{ columnKey: state.request.sort, direction: state.request.dir.toUpperCase() }]
|
|
94
|
-
: [];
|
|
95
|
-
// TODO @vejvis podívat se na onSortColumnChange metodu
|
|
96
|
-
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
97
|
-
const onSortColumnChange = (sortColumns) => {
|
|
98
|
-
if (sortColumns.length > 0) {
|
|
99
|
-
const sc = sortColumns[0];
|
|
100
|
-
dispatch(actions_1.dataGridActions.sort(sc.columnKey, sc.direction.toLowerCase()));
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
dispatch(actions_1.dataGridActions.sortClear());
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
const rdgVisuals = (0, use_rdg_visuals_1.useRdgVisuals)({
|
|
107
|
-
headerRowHeight: props.headerRowHeight,
|
|
108
|
-
mode: props.mode,
|
|
109
|
-
rowHeight: props.rowHeight,
|
|
110
|
-
rows,
|
|
111
|
-
});
|
|
7
|
+
const cx_1 = require("@uxf/core/utils/cx");
|
|
8
|
+
const react_1 = __importDefault(require("react"));
|
|
9
|
+
const body_cell_1 = require("./body-cell");
|
|
10
|
+
const filter_handler_1 = require("./filter-handler");
|
|
11
|
+
const filter_list_1 = require("./filter-list");
|
|
12
|
+
const linear_progress_1 = require("./linear-progress");
|
|
13
|
+
const pagination_1 = require("./pagination");
|
|
14
|
+
const row_counts_1 = require("./row-counts");
|
|
15
|
+
const rows_per_page_select_1 = require("./rows-per-page-select");
|
|
16
|
+
const selected_rows_toolbar_1 = require("./selected-rows-toolbar");
|
|
17
|
+
const table_1 = require("./table");
|
|
18
|
+
const action_cell_base_1 = require("./table/components/action-cell-base");
|
|
19
|
+
const no_rows_fallback_1 = require("./table/no-rows-fallback");
|
|
20
|
+
const toolbar_control_1 = require("./toolbar-control");
|
|
21
|
+
const toolbar_customs_1 = require("./toolbar-customs");
|
|
22
|
+
const toolbar_tabs_1 = require("./toolbar-tabs");
|
|
23
|
+
const classes_1 = require("./utils/classes");
|
|
24
|
+
const DefaultSelectedRowsToolbarActions = () => null;
|
|
25
|
+
function DataGrid(props) {
|
|
26
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
112
27
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
113
|
-
react_1.default.createElement(
|
|
114
|
-
react_1.default.createElement(
|
|
115
|
-
react_1.default.createElement(ToolbarTabs, {
|
|
116
|
-
react_1.default.createElement(ToolbarControl, {
|
|
117
|
-
react_1.default.createElement(ToolbarCustoms, { buttons: props.customActions })),
|
|
118
|
-
react_1.default.createElement(LinearProgress, {
|
|
119
|
-
react_1.default.createElement(FilterList, {
|
|
120
|
-
react_1.default.createElement(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
react_1.default.createElement(
|
|
124
|
-
react_1.default.createElement(
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
};
|
|
28
|
+
react_1.default.createElement("div", { className: (0, cx_1.cx)("uxf-data-grid", props.noBorder && classes_1.NO_BORDER_CLASS, props.className) },
|
|
29
|
+
react_1.default.createElement("div", { className: (0, cx_1.cx)("uxf-data-grid__toolbar", props.noBorder && classes_1.NO_BORDER_CLASS) },
|
|
30
|
+
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: (_b = (_a = props.ui) === null || _a === void 0 ? void 0 : _a.FilterHandlers) !== null && _b !== void 0 ? _b : filter_handler_1.defaultFilterHandlers, schema: props.schema, onCsvDownload: props.onCsvDownload }),
|
|
32
|
+
react_1.default.createElement(toolbar_customs_1.ToolbarCustoms, { buttons: props.customActions })),
|
|
33
|
+
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: (_d = (_c = props.ui) === null || _c === void 0 ? void 0 : _c.FilterHandlers) !== null && _d !== void 0 ? _d : filter_handler_1.defaultFilterHandlers, className: props.noBorder ? classes_1.NO_BORDER_CLASS : undefined }),
|
|
35
|
+
react_1.default.createElement(table_1.Table, { state: props.state, actions: props.actions, schema: props.schema, data: (_f = (_e = props.data) === null || _e === void 0 ? void 0 : _e.result) !== null && _f !== void 0 ? _f : [], isLoading: props.isLoading, error: props.error, rowClass: props.rowClass, keyExtractor: props.keyExtractor, rowHeight: props.rowHeight, headerRowHeight: props.headerRowHeight, BodyCells: (_h = (_g = props.ui) === null || _g === void 0 ? void 0 : _g.BodyCells) !== null && _h !== void 0 ? _h : body_cell_1.BodyCells, NoRowsFallback: (_k = (_j = props.ui) === null || _j === void 0 ? void 0 : _j.NoRowsFallback) !== null && _k !== void 0 ? _k : no_rows_fallback_1.NoRowsFallback, ActionCell: (_m = (_l = props.ui) === null || _l === void 0 ? void 0 : _l.ActionCell) !== null && _m !== void 0 ? _m : action_cell_base_1.ActionCellBase, onRemove: props.onRemove, onEdit: props.onEdit, getEditUrl: props.getEditUrl, onOpen: props.onOpen, getOpenUrl: props.getOpenUrl, onReload: props.onReload, isRowSelectable: props.isRowSelectable }),
|
|
36
|
+
react_1.default.createElement("div", { className: (0, cx_1.cx)("uxf-data-grid__footer", props.noBorder && classes_1.NO_BORDER_CLASS) },
|
|
37
|
+
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, totalCount: (_p = (_o = props.data) === null || _o === void 0 ? void 0 : _o.totalCount) !== null && _p !== void 0 ? _p : 0 }),
|
|
39
|
+
react_1.default.createElement(pagination_1.Pagination, { state: props.state, actions: props.actions, totalCount: (_r = (_q = props.data) === null || _q === void 0 ? void 0 : _q.totalCount) !== null && _r !== void 0 ? _r : 0 }))),
|
|
40
|
+
react_1.default.createElement(selected_rows_toolbar_1.SelectedRowsToolbar, { state: props.state, actions: props.actions, Actions: (_t = (_s = props.ui) === null || _s === void 0 ? void 0 : _s.SelectedRowsToolbarActions) !== null && _t !== void 0 ? _t : DefaultSelectedRowsToolbarActions })));
|
|
41
|
+
}
|
|
128
42
|
exports.DataGrid = DataGrid;
|
package/data-grid.stories.d.ts
CHANGED
|
@@ -1,7 +1,2 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
declare const _default: {
|
|
3
|
-
title: string;
|
|
4
|
-
component: <GridType_1 extends import("./").BaseGridType, R = any>(props: import("./tailwindui").DataGridProps<GridType_1, R>) => React.JSX.Element;
|
|
5
|
-
};
|
|
6
|
-
export default _default;
|
|
7
2
|
export declare function Default(): React.JSX.Element;
|