@mailstep/design-system 0.4.21 → 0.5.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/package.json +17 -4
- package/ui/Blocks/CommonGrid/CommonGrid.d.ts +3 -0
- package/ui/Blocks/CommonGrid/CommonGrid.js +115 -0
- package/ui/Blocks/CommonGrid/CommonGridContext.d.ts +12 -0
- package/ui/Blocks/CommonGrid/CommonGridContext.js +45 -0
- package/ui/Blocks/CommonGrid/HoC/withReduxActions.d.ts +2 -0
- package/ui/Blocks/CommonGrid/HoC/withReduxActions.js +36 -0
- package/ui/Blocks/CommonGrid/components/ActionColumnHead.d.ts +4 -0
- package/ui/Blocks/CommonGrid/components/ActionColumnHead.js +16 -0
- package/ui/Blocks/CommonGrid/components/ButtonStrip.d.ts +7 -0
- package/ui/Blocks/CommonGrid/components/ButtonStrip.js +35 -0
- package/ui/Blocks/CommonGrid/components/ColumnFilterCell.d.ts +11 -0
- package/ui/Blocks/CommonGrid/components/ColumnFilterCell.js +41 -0
- package/ui/Blocks/CommonGrid/components/ColumnTitle.d.ts +9 -0
- package/ui/Blocks/CommonGrid/components/ColumnTitle.js +20 -0
- package/ui/Blocks/CommonGrid/components/ConfigForm.d.ts +9 -0
- package/ui/Blocks/CommonGrid/components/ConfigForm.js +58 -0
- package/ui/Blocks/CommonGrid/components/DataCell.d.ts +11 -0
- package/ui/Blocks/CommonGrid/components/DataCell.js +52 -0
- package/ui/Blocks/CommonGrid/components/DataRow.d.ts +21 -0
- package/ui/Blocks/CommonGrid/components/DataRow.js +110 -0
- package/ui/Blocks/CommonGrid/components/DefaultPaginator.d.ts +3 -0
- package/ui/Blocks/CommonGrid/components/DefaultPaginator.js +11 -0
- package/ui/Blocks/CommonGrid/components/Dialog.d.ts +11 -0
- package/ui/Blocks/CommonGrid/components/Dialog.js +19 -0
- package/ui/Blocks/CommonGrid/components/DropdownMenu.d.ts +21 -0
- package/ui/Blocks/CommonGrid/components/DropdownMenu.js +59 -0
- package/ui/Blocks/CommonGrid/components/DropdownSelect.d.ts +15 -0
- package/ui/Blocks/CommonGrid/components/DropdownSelect.js +35 -0
- package/ui/Blocks/CommonGrid/components/FilterDropdown.d.ts +3 -0
- package/ui/Blocks/CommonGrid/components/FilterDropdown.js +36 -0
- package/ui/Blocks/CommonGrid/components/FilterRow.d.ts +15 -0
- package/ui/Blocks/CommonGrid/components/FilterRow.js +35 -0
- package/ui/Blocks/CommonGrid/components/FloatingButton.d.ts +6 -0
- package/ui/Blocks/CommonGrid/components/FloatingButton.js +13 -0
- package/ui/Blocks/CommonGrid/components/GroupRow.d.ts +9 -0
- package/ui/Blocks/CommonGrid/components/GroupRow.js +27 -0
- package/ui/Blocks/CommonGrid/components/HeadCell.d.ts +27 -0
- package/ui/Blocks/CommonGrid/components/HeadCell.js +43 -0
- package/ui/Blocks/CommonGrid/components/HeadRow.d.ts +15 -0
- package/ui/Blocks/CommonGrid/components/HeadRow.js +69 -0
- package/ui/Blocks/CommonGrid/components/OversizedScroll.d.ts +11 -0
- package/ui/Blocks/CommonGrid/components/OversizedScroll.js +24 -0
- package/ui/Blocks/CommonGrid/components/Resize.d.ts +7 -0
- package/ui/Blocks/CommonGrid/components/Resize.js +33 -0
- package/ui/Blocks/CommonGrid/components/Table.d.ts +16 -0
- package/ui/Blocks/CommonGrid/components/Table.js +30 -0
- package/ui/Blocks/CommonGrid/components/icons/ArrowSimple.d.ts +2 -0
- package/ui/Blocks/CommonGrid/components/icons/ArrowSimple.js +14 -0
- package/ui/Blocks/CommonGrid/components/icons/Edit.d.ts +2 -0
- package/ui/Blocks/CommonGrid/components/icons/Edit.js +14 -0
- package/ui/Blocks/CommonGrid/components/icons/EyeOpen.d.ts +2 -0
- package/ui/Blocks/CommonGrid/components/icons/EyeOpen.js +14 -0
- package/ui/Blocks/CommonGrid/components/icons/Sorting.d.ts +2 -0
- package/ui/Blocks/CommonGrid/components/icons/Sorting.js +14 -0
- package/ui/Blocks/CommonGrid/components/utils.d.ts +8 -0
- package/ui/Blocks/CommonGrid/components/utils.js +22 -0
- package/ui/Blocks/CommonGrid/hooks/useColumnSizes.d.ts +12 -0
- package/ui/Blocks/CommonGrid/hooks/useColumnSizes.js +83 -0
- package/ui/Blocks/CommonGrid/hooks/useControlButtons.d.ts +10 -0
- package/ui/Blocks/CommonGrid/hooks/useControlButtons.js +64 -0
- package/ui/Blocks/CommonGrid/hooks/useRowsKeyControls.d.ts +4 -0
- package/ui/Blocks/CommonGrid/hooks/useRowsKeyControls.js +21 -0
- package/ui/Blocks/CommonGrid/hooks/useUxReset.d.ts +3 -0
- package/ui/Blocks/CommonGrid/hooks/useUxReset.js +15 -0
- package/ui/Blocks/CommonGrid/index.d.ts +7 -0
- package/ui/Blocks/CommonGrid/index.js +7 -0
- package/ui/Blocks/CommonGrid/store/index.d.ts +58 -0
- package/ui/Blocks/CommonGrid/store/index.js +230 -0
- package/ui/Blocks/CommonGrid/store/migrateState.d.ts +3 -0
- package/ui/Blocks/CommonGrid/store/migrateState.js +14 -0
- package/ui/Blocks/CommonGrid/storybook/stories/complexWithPaginationAndRedux.stories.d.ts +11 -0
- package/ui/Blocks/CommonGrid/storybook/stories/complexWithPaginationAndRedux.stories.js +31 -0
- package/ui/Blocks/CommonGrid/storybook/stories/customControllButtons.stories.d.ts +13 -0
- package/ui/Blocks/CommonGrid/storybook/stories/customControllButtons.stories.js +49 -0
- package/ui/Blocks/CommonGrid/storybook/stories/default.stories.d.ts +6 -0
- package/ui/Blocks/CommonGrid/storybook/stories/default.stories.js +14 -0
- package/ui/Blocks/CommonGrid/storybook/stories/loading.stories.d.ts +10 -0
- package/ui/Blocks/CommonGrid/storybook/stories/loading.stories.js +11 -0
- package/ui/Blocks/CommonGrid/storybook/stories/manyColumnsNoScrollLayout.stories.d.ts +10 -0
- package/ui/Blocks/CommonGrid/storybook/stories/manyColumnsNoScrollLayout.stories.js +12 -0
- package/ui/Blocks/CommonGrid/storybook/stories/manyColumnsNormalLayout.stories.d.ts +10 -0
- package/ui/Blocks/CommonGrid/storybook/stories/manyColumnsNormalLayout.stories.js +12 -0
- package/ui/Blocks/CommonGrid/storybook/stories/styledCommonGrid.stories.d.ts +6 -0
- package/ui/Blocks/CommonGrid/storybook/stories/styledCommonGrid.stories.js +15 -0
- package/ui/Blocks/CommonGrid/storybook/stories/withCustomGridActions.stories.d.ts +10 -0
- package/ui/Blocks/CommonGrid/storybook/stories/withCustomGridActions.stories.js +15 -0
- package/ui/Blocks/CommonGrid/storybook/stories/withForcedCheckboxes.stories.d.ts +14 -0
- package/ui/Blocks/CommonGrid/storybook/stories/withForcedCheckboxes.stories.js +24 -0
- package/ui/Blocks/CommonGrid/storybook/utils/actions.d.ts +4 -0
- package/ui/Blocks/CommonGrid/storybook/utils/actions.js +6 -0
- package/ui/Blocks/CommonGrid/storybook/utils/columnDefinition.d.ts +10 -0
- package/ui/Blocks/CommonGrid/storybook/utils/columnDefinition.js +97 -0
- package/ui/Blocks/CommonGrid/storybook/utils/filters.d.ts +2 -0
- package/ui/Blocks/CommonGrid/storybook/utils/filters.js +23 -0
- package/ui/Blocks/CommonGrid/storybook/utils/utils.d.ts +17 -0
- package/ui/Blocks/CommonGrid/storybook/utils/utils.js +66 -0
- package/ui/Blocks/CommonGrid/storybook/utils/withRedux.d.ts +2 -0
- package/ui/Blocks/CommonGrid/storybook/utils/withRedux.js +12 -0
- package/ui/Blocks/CommonGrid/storybook/utils/withRouter.d.ts +2 -0
- package/ui/Blocks/CommonGrid/storybook/utils/withRouter.js +4 -0
- package/ui/Blocks/CommonGrid/storybook/utils/withTheme.d.ts +2 -0
- package/ui/Blocks/CommonGrid/storybook/utils/withTheme.js +18 -0
- package/ui/Blocks/CommonGrid/types.d.ts +299 -0
- package/ui/Blocks/CommonGrid/types.js +8 -0
- package/ui/Blocks/CommonGrid/utils/index.d.ts +17 -0
- package/ui/Blocks/CommonGrid/utils/index.js +60 -0
- package/ui/Blocks/CommonGrid/utils/public.d.ts +16 -0
- package/ui/Blocks/CommonGrid/utils/public.js +52 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import produce from 'immer';
|
|
13
|
+
import getOr from 'lodash/fp/getOr';
|
|
14
|
+
import migrateState from './migrateState';
|
|
15
|
+
import { createSelector } from 'reselect';
|
|
16
|
+
export var initialState = {
|
|
17
|
+
page: 1,
|
|
18
|
+
rowsPerPage: 10,
|
|
19
|
+
sorting: [],
|
|
20
|
+
isConfigFormOpen: false,
|
|
21
|
+
uxState: {
|
|
22
|
+
selectedRow: null,
|
|
23
|
+
checkedRows: {},
|
|
24
|
+
},
|
|
25
|
+
columnConfig: {},
|
|
26
|
+
filter: {},
|
|
27
|
+
columnsWidth: {},
|
|
28
|
+
columnsOrder: [],
|
|
29
|
+
defaultSorting: [],
|
|
30
|
+
};
|
|
31
|
+
export var actionPrefix = '@store/CommonGrid';
|
|
32
|
+
export var actionTypes = {
|
|
33
|
+
init: "".concat(actionPrefix, "/init"),
|
|
34
|
+
clearUxState: "".concat(actionPrefix, "/clearUxState"),
|
|
35
|
+
handleUxChange: "".concat(actionPrefix, "/handleUxChange"),
|
|
36
|
+
openConfigForm: "".concat(actionPrefix, "/openConfigForm"),
|
|
37
|
+
closeConfigForm: "".concat(actionPrefix, "/closeConfigForm"),
|
|
38
|
+
setColumnConfig: "".concat(actionPrefix, "/setColumnConfig"),
|
|
39
|
+
setPage: "".concat(actionPrefix, "/setPage"),
|
|
40
|
+
setRowsPerPage: "".concat(actionPrefix, "/setRowsPerPage"),
|
|
41
|
+
resetFilters: "".concat(actionPrefix, "/resetFilters"),
|
|
42
|
+
addFilter: "".concat(actionPrefix, "/addFilter"),
|
|
43
|
+
addSorting: "".concat(actionPrefix, "/addSorting"),
|
|
44
|
+
clearSettings: "".concat(actionPrefix, "/clearSettings"),
|
|
45
|
+
resetGrid: "".concat(actionPrefix, "/resetGrid"),
|
|
46
|
+
setColumnWidth: "".concat(actionPrefix, "/setColumnWidth"),
|
|
47
|
+
setColumnsOrder: "".concat(actionPrefix, "/setColumnsOrder"),
|
|
48
|
+
};
|
|
49
|
+
var migrationChecked = false;
|
|
50
|
+
export default (function (state, action) {
|
|
51
|
+
if (state === void 0) { state = {}; }
|
|
52
|
+
return produce(state, function (draft) {
|
|
53
|
+
var _a, _b;
|
|
54
|
+
var _c, _d, _e, _f, _g;
|
|
55
|
+
// version migrations
|
|
56
|
+
if (!migrationChecked && state && Object.keys(state).length > 0) {
|
|
57
|
+
draft = migrateState(draft);
|
|
58
|
+
migrationChecked = true;
|
|
59
|
+
}
|
|
60
|
+
var gridName = action.gridName;
|
|
61
|
+
if (!gridName)
|
|
62
|
+
return draft; // action does not contains gridName, skip immediatelly
|
|
63
|
+
if (!draft[gridName]) {
|
|
64
|
+
// if this grid is not yet in store, initialize
|
|
65
|
+
draft[gridName] = __assign({}, initialState);
|
|
66
|
+
}
|
|
67
|
+
if (action.type === actionTypes.init) {
|
|
68
|
+
var defaultSorting = action.initProps.defaultSorting;
|
|
69
|
+
draft[gridName].page = 1;
|
|
70
|
+
if (defaultSorting) {
|
|
71
|
+
draft[gridName].defaultSorting = defaultSorting;
|
|
72
|
+
draft[gridName].sorting = ((_c = draft[gridName].sorting) === null || _c === void 0 ? void 0 : _c.length) ? draft[gridName].sorting : defaultSorting;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else if (action.type === actionTypes.clearUxState) {
|
|
76
|
+
draft[gridName].uxState = initialState.uxState;
|
|
77
|
+
}
|
|
78
|
+
else if (action.type === actionTypes.handleUxChange) {
|
|
79
|
+
// for a specific row id (action.id) append uxState from action
|
|
80
|
+
draft[gridName].uxState = __assign(__assign({}, draft[gridName].uxState), (_a = {}, _a[action.uxKey] = action.uxValue, _a));
|
|
81
|
+
}
|
|
82
|
+
else if (action.type === actionTypes.openConfigForm) {
|
|
83
|
+
draft[gridName].isConfigFormOpen = true;
|
|
84
|
+
}
|
|
85
|
+
else if (action.type === actionTypes.closeConfigForm) {
|
|
86
|
+
draft[gridName].isConfigFormOpen = false;
|
|
87
|
+
}
|
|
88
|
+
else if (action.type === actionTypes.setColumnConfig) {
|
|
89
|
+
draft[gridName].columnConfig = action.columnConfig;
|
|
90
|
+
draft[gridName].isConfigFormOpen = false;
|
|
91
|
+
}
|
|
92
|
+
else if (action.type === actionTypes.resetFilters) {
|
|
93
|
+
draft[gridName].filter = {};
|
|
94
|
+
}
|
|
95
|
+
else if (action.type === actionTypes.addFilter) {
|
|
96
|
+
// append desired filter for specific column to existing filters
|
|
97
|
+
var column = action.column, value = action.value, filterProps = action.filterProps;
|
|
98
|
+
var currentFilterState = (_b = {}, _b[column] = { value: value, filterProps: filterProps }, _b);
|
|
99
|
+
draft[gridName].filter = __assign(__assign({}, draft[gridName].filter), currentFilterState);
|
|
100
|
+
draft[gridName].page = 1;
|
|
101
|
+
}
|
|
102
|
+
else if (action.type === actionTypes.addSorting) {
|
|
103
|
+
// append desired sorting for specific column to existing sortings
|
|
104
|
+
var direction = action.direction;
|
|
105
|
+
var column = action.column;
|
|
106
|
+
if (((_f = (_e = (_d = draft[gridName]) === null || _d === void 0 ? void 0 : _d.defaultSorting) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.column) === column && direction === null) {
|
|
107
|
+
// default column cannot unset itself. it would be stuck on 'desc'
|
|
108
|
+
direction = 'asc';
|
|
109
|
+
}
|
|
110
|
+
var sorting = [{ column: column, direction: direction }];
|
|
111
|
+
if (direction === null) {
|
|
112
|
+
sorting = ((_g = draft[gridName]) === null || _g === void 0 ? void 0 : _g.defaultSorting) || [];
|
|
113
|
+
}
|
|
114
|
+
draft[gridName].sorting = sorting;
|
|
115
|
+
}
|
|
116
|
+
else if (action.type === actionTypes.clearSettings) {
|
|
117
|
+
// clear grid for reuse
|
|
118
|
+
draft[gridName].page = initialState.page;
|
|
119
|
+
draft[gridName].filter = initialState.filter;
|
|
120
|
+
draft[gridName].uxState = initialState.uxState;
|
|
121
|
+
}
|
|
122
|
+
else if (action.type === actionTypes.setPage) {
|
|
123
|
+
draft[gridName].page = action.page;
|
|
124
|
+
}
|
|
125
|
+
else if (action.type === actionTypes.setRowsPerPage) {
|
|
126
|
+
draft[gridName].rowsPerPage = action.rowsPerPage;
|
|
127
|
+
}
|
|
128
|
+
else if (action.type === actionTypes.resetGrid) {
|
|
129
|
+
draft[gridName] = __assign(__assign({}, initialState), { rowsPerPage: draft[gridName].rowsPerPage });
|
|
130
|
+
}
|
|
131
|
+
else if (action.type === actionTypes.setColumnWidth) {
|
|
132
|
+
if (action.columnsWidth === null) {
|
|
133
|
+
draft[gridName].columnsWidth = initialState.columnsWidth;
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
draft[gridName].columnsWidth = __assign(__assign({}, draft[gridName].columnsWidth), action.columnsWidth);
|
|
137
|
+
}
|
|
138
|
+
draft[gridName].columnsWidthVariant = action.columnLayout;
|
|
139
|
+
}
|
|
140
|
+
else if (action.type === actionTypes.setColumnsOrder) {
|
|
141
|
+
draft[gridName].columnsOrder = action.columnsOrder;
|
|
142
|
+
}
|
|
143
|
+
return draft;
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
export var createActions = function (gridName) { return ({
|
|
147
|
+
init: function (initProps) { return ({ gridName: gridName, type: actionTypes.init, initProps: initProps }); },
|
|
148
|
+
clearUxState: function () { return ({ gridName: gridName, type: actionTypes.clearUxState }); },
|
|
149
|
+
handleUxChange: function (uxKey, uxValue) { return ({
|
|
150
|
+
gridName: gridName,
|
|
151
|
+
type: actionTypes.handleUxChange,
|
|
152
|
+
uxKey: uxKey,
|
|
153
|
+
uxValue: uxValue,
|
|
154
|
+
}); },
|
|
155
|
+
openConfigForm: function () { return ({ gridName: gridName, type: actionTypes.openConfigForm }); },
|
|
156
|
+
closeConfigForm: function () { return ({ gridName: gridName, type: actionTypes.closeConfigForm }); },
|
|
157
|
+
setColumnConfig: function (columnConfig) { return ({ gridName: gridName, type: actionTypes.setColumnConfig, columnConfig: columnConfig }); },
|
|
158
|
+
setPage: function (page) { return ({ gridName: gridName, type: actionTypes.setPage, page: page }); },
|
|
159
|
+
setColumnWidth: function (columnsWidth, columnLayout) { return ({
|
|
160
|
+
gridName: gridName,
|
|
161
|
+
type: actionTypes.setColumnWidth,
|
|
162
|
+
columnsWidth: columnsWidth,
|
|
163
|
+
columnLayout: columnLayout,
|
|
164
|
+
}); },
|
|
165
|
+
resetGrid: function () { return ({ gridName: gridName, type: actionTypes.resetGrid }); },
|
|
166
|
+
setColumnsOrder: function (columnsOrder) { return ({
|
|
167
|
+
gridName: gridName,
|
|
168
|
+
type: actionTypes.setColumnsOrder,
|
|
169
|
+
columnsOrder: columnsOrder,
|
|
170
|
+
}); },
|
|
171
|
+
setRowsPerPage: function (rowsPerPage) { return ({ gridName: gridName, type: actionTypes.setRowsPerPage, rowsPerPage: rowsPerPage }); },
|
|
172
|
+
resetFilters: function () { return ({ gridName: gridName, type: actionTypes.resetFilters }); },
|
|
173
|
+
addFilter: function (column, value, filterProps) { return ({
|
|
174
|
+
gridName: gridName,
|
|
175
|
+
type: actionTypes.addFilter,
|
|
176
|
+
column: column,
|
|
177
|
+
value: value,
|
|
178
|
+
filterProps: filterProps,
|
|
179
|
+
}); },
|
|
180
|
+
addSorting: function (column, direction) { return ({
|
|
181
|
+
gridName: gridName,
|
|
182
|
+
type: actionTypes.addSorting,
|
|
183
|
+
column: column,
|
|
184
|
+
direction: direction,
|
|
185
|
+
}); },
|
|
186
|
+
clearSettings: function () { return ({ gridName: gridName, type: actionTypes.clearSettings }); },
|
|
187
|
+
}); };
|
|
188
|
+
export var createSelectors = function (gridName) { return ({
|
|
189
|
+
getUxState: function (state) {
|
|
190
|
+
return getOr(initialState.uxState, "commonGrid.".concat(gridName, ".uxState"), state);
|
|
191
|
+
},
|
|
192
|
+
isConfigFormOpen: function (state) {
|
|
193
|
+
return getOr(initialState.isConfigFormOpen, "commonGrid.".concat(gridName, ".isConfigFormOpen"), state);
|
|
194
|
+
},
|
|
195
|
+
getColumnConfig: function (state) {
|
|
196
|
+
return getOr(initialState.columnConfig, "commonGrid.".concat(gridName, ".columnConfig"), state);
|
|
197
|
+
},
|
|
198
|
+
getPage: function (state) { return getOr(initialState.page, "commonGrid.".concat(gridName, ".page"), state); },
|
|
199
|
+
getRowsPerPage: function (state) {
|
|
200
|
+
return getOr(initialState.rowsPerPage, "commonGrid.".concat(gridName, ".rowsPerPage"), state);
|
|
201
|
+
},
|
|
202
|
+
getFilter: function (state) { return getOr(initialState.filter, "commonGrid.".concat(gridName, ".filter"), state); },
|
|
203
|
+
getSorting: function (state) {
|
|
204
|
+
return getOr(initialState.sorting, "commonGrid.".concat(gridName, ".sorting"), state);
|
|
205
|
+
},
|
|
206
|
+
getColumnsWidth: function (state) {
|
|
207
|
+
return getOr(null, "commonGrid.".concat(gridName, ".columnsWidth"), state);
|
|
208
|
+
},
|
|
209
|
+
getColumnsWidthVariant: function (state) {
|
|
210
|
+
return getOr(undefined, "commonGrid.".concat(gridName, ".columnsWidthVariant"), state);
|
|
211
|
+
},
|
|
212
|
+
getColumnsOrder: function (state) {
|
|
213
|
+
return getOr([], "commonGrid.".concat(gridName, ".columnsOrder"), state);
|
|
214
|
+
},
|
|
215
|
+
}); };
|
|
216
|
+
export var createFullSelector = function (gridName) {
|
|
217
|
+
var selectors = createSelectors(gridName);
|
|
218
|
+
return createSelector(function (state) { return selectors.getUxState(state); }, function (state) { return selectors.isConfigFormOpen(state); }, function (state) { return selectors.getColumnConfig(state); }, function (state) { return selectors.getPage(state); }, function (state) { return selectors.getRowsPerPage(state); }, function (state) { return selectors.getFilter(state); }, function (state) { return selectors.getSorting(state); }, function (state) { return selectors.getColumnsWidth(state); }, function (state) { return selectors.getColumnsWidthVariant(state); }, function (state) { return selectors.getColumnsOrder(state); }, function (uxState, isConfigFormOpen, columnConfig, page, rowsPerPage, filter, sorting, columnsWidth, columnsWidthVariant, columnsOrder) { return ({
|
|
219
|
+
uxState: uxState,
|
|
220
|
+
isConfigFormOpen: isConfigFormOpen,
|
|
221
|
+
columnConfig: columnConfig,
|
|
222
|
+
page: page,
|
|
223
|
+
rowsPerPage: rowsPerPage,
|
|
224
|
+
filter: filter,
|
|
225
|
+
sorting: sorting,
|
|
226
|
+
columnsWidth: columnsWidth,
|
|
227
|
+
columnsWidthVariant: columnsWidthVariant,
|
|
228
|
+
columnsOrder: columnsOrder,
|
|
229
|
+
}); });
|
|
230
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// v1 to v2
|
|
2
|
+
var v2 = function (draft) {
|
|
3
|
+
Object.keys(draft).forEach(function (gridName) {
|
|
4
|
+
if (draft[gridName].columnConfig && Array.isArray(draft[gridName].columnConfig)) {
|
|
5
|
+
draft[gridName].columnConfig = {};
|
|
6
|
+
}
|
|
7
|
+
});
|
|
8
|
+
return draft;
|
|
9
|
+
};
|
|
10
|
+
// migration management
|
|
11
|
+
export default (function (draft) {
|
|
12
|
+
draft = v2(draft);
|
|
13
|
+
return draft;
|
|
14
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
title: string;
|
|
3
|
+
decorators: ((story: Function) => JSX.Element)[];
|
|
4
|
+
};
|
|
5
|
+
export default _default;
|
|
6
|
+
export declare const ComplexWithPaginationAndRedux: {
|
|
7
|
+
(): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
story: {
|
|
9
|
+
name: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ReduxGrid, createRandomData, enumValues, gridDummyActions } from '../utils/utils';
|
|
4
|
+
import { onRowEditClick, onRowReadClick, onRowAction, onBatchAction } from '../utils/actions';
|
|
5
|
+
import { filters } from '../utils/filters';
|
|
6
|
+
import { useAddFilter } from '../../utils/public';
|
|
7
|
+
import withReduxActions from '../../HoC/withReduxActions';
|
|
8
|
+
import { columnDefinitions, enumColumn } from '../utils/columnDefinition';
|
|
9
|
+
import withRedux from '../utils/withRedux';
|
|
10
|
+
var ActionColumnButtons = {
|
|
11
|
+
flexBasis: 160,
|
|
12
|
+
canRowRead: true,
|
|
13
|
+
canRowEdit: function (row) { return row.enumColumn !== 'option C'; },
|
|
14
|
+
};
|
|
15
|
+
var FilterSetter = function (_a) {
|
|
16
|
+
var gridActions = _a.gridActions;
|
|
17
|
+
var handleAddFilter = useAddFilter(gridActions === null || gridActions === void 0 ? void 0 : gridActions.addFilter);
|
|
18
|
+
React.useEffect(function () {
|
|
19
|
+
handleAddFilter(enumValues[1], enumColumn);
|
|
20
|
+
}, []);
|
|
21
|
+
return null;
|
|
22
|
+
};
|
|
23
|
+
var ConnectedFilterSetter = withReduxActions('testGrid')(FilterSetter);
|
|
24
|
+
export default {
|
|
25
|
+
title: '@Blocks/CommonGrid',
|
|
26
|
+
decorators: [withRedux],
|
|
27
|
+
};
|
|
28
|
+
export var ComplexWithPaginationAndRedux = function () { return (_jsxs(_Fragment, { children: [_jsx(ConnectedFilterSetter, { gridActions: gridDummyActions }), _jsx(ReduxGrid, { filters: filters, columnsDefinitions: columnDefinitions, actionColumnDefinition: ActionColumnButtons, rowsData: createRandomData(10), onRowAction: onRowAction, onRowReadClick: onRowReadClick, onRowEditClick: onRowEditClick, totalRowsCount: 200, onBatchAction: onBatchAction, confirmOnReset: function () { return window.confirm('Are you sure you want to reset grid?'); } })] })); };
|
|
29
|
+
ComplexWithPaginationAndRedux.story = {
|
|
30
|
+
name: 'Complex, with pagination and redux',
|
|
31
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ExtraControlButton } from '../../types';
|
|
2
|
+
export declare const extraControlButtons: ExtraControlButton[];
|
|
3
|
+
declare const _default: {
|
|
4
|
+
title: string;
|
|
5
|
+
excludeStories: string[];
|
|
6
|
+
};
|
|
7
|
+
export default _default;
|
|
8
|
+
export declare const CustomControllButtons: {
|
|
9
|
+
(): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
story: {
|
|
11
|
+
name: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import CommonGrid from '../../CommonGrid';
|
|
3
|
+
import { createRandomData, gridSelectors, gridDummyActions } from '../utils/utils';
|
|
4
|
+
import { oversizedColumnDefinition } from '../utils/columnDefinition';
|
|
5
|
+
import { ExtraControlButtonPosition } from '../../types';
|
|
6
|
+
export var extraControlButtons = [
|
|
7
|
+
{
|
|
8
|
+
label: _jsx(_Fragment, { children: "default left" }),
|
|
9
|
+
onClick: function () { return alert('test ok'); },
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
label: _jsx(_Fragment, { children: "right button" }),
|
|
13
|
+
onClick: function () { return alert('test ok'); },
|
|
14
|
+
position: ExtraControlButtonPosition.TopRight,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
label: _jsx(_Fragment, { children: "bottom left button" }),
|
|
18
|
+
onClick: function () { return alert('test ok'); },
|
|
19
|
+
position: ExtraControlButtonPosition.BottomLeft,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
label: _jsx(_Fragment, { children: "right options" }),
|
|
23
|
+
onClick: function () { return alert('test ok'); },
|
|
24
|
+
onSelect: function (value) { return alert(value); },
|
|
25
|
+
position: ExtraControlButtonPosition.TopRight,
|
|
26
|
+
options: [
|
|
27
|
+
{
|
|
28
|
+
label: 'Label A',
|
|
29
|
+
value: 'A',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
label: 'Label B',
|
|
33
|
+
value: 'B',
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
node: (_jsxs("span", { style: { marginLeft: '15px' }, children: [_jsx("span", { children: "custom node with btn - " }), _jsx("button", { onClick: function () { return alert('test ok'); }, children: "btn" })] })),
|
|
39
|
+
position: ExtraControlButtonPosition.TopRight,
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
export default {
|
|
43
|
+
title: '@Blocks/CommonGrid',
|
|
44
|
+
excludeStories: ['extraControlButtons'],
|
|
45
|
+
};
|
|
46
|
+
export var CustomControllButtons = function () { return (_jsx(CommonGrid, { rowsData: createRandomData(10), columnsDefinitions: oversizedColumnDefinition, extraControlButtons: extraControlButtons, hideColumnConfig: true, gridSelectors: gridSelectors, gridActions: gridDummyActions })); };
|
|
47
|
+
CustomControllButtons.story = {
|
|
48
|
+
name: 'custom controll buttons',
|
|
49
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import CommonGrid from '../../CommonGrid';
|
|
3
|
+
import { createRandomData, gridSelectors, gridDummyActions } from '../utils/utils';
|
|
4
|
+
import { columnDefinitions } from '../utils/columnDefinition';
|
|
5
|
+
import withTheme from '../utils/withTheme';
|
|
6
|
+
import withRouter from '../utils/withRouter';
|
|
7
|
+
import withRedux from '../utils/withRedux';
|
|
8
|
+
export default {
|
|
9
|
+
title: '@Blocks/CommonGrid',
|
|
10
|
+
decorators: [withTheme, withRouter, withRedux],
|
|
11
|
+
};
|
|
12
|
+
export var Default = function () {
|
|
13
|
+
return (_jsx(CommonGrid, { columnsDefinitions: columnDefinitions, rowsData: createRandomData(10), gridActions: gridDummyActions, gridSelectors: gridSelectors }));
|
|
14
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import CommonGrid from '../../CommonGrid';
|
|
3
|
+
import { createRandomData, gridSelectors, gridDummyActions } from '../utils/utils';
|
|
4
|
+
import { columnDefinitions } from '../utils/columnDefinition';
|
|
5
|
+
export default {
|
|
6
|
+
title: '@Blocks/CommonGrid',
|
|
7
|
+
};
|
|
8
|
+
export var LoadingState = function () { return (_jsx(CommonGrid, { columnsDefinitions: columnDefinitions, rowsData: createRandomData(10), gridSelectors: gridSelectors, gridActions: gridDummyActions, isLoading: true, hideColumnConfig: true })); };
|
|
9
|
+
LoadingState.story = {
|
|
10
|
+
name: 'Loading state',
|
|
11
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import CommonGrid from '../../CommonGrid';
|
|
3
|
+
import { createOversizedRandomData, gridSelectors, gridDummyActions } from '../utils/utils';
|
|
4
|
+
import { oversizedColumnDefinition } from '../utils/columnDefinition';
|
|
5
|
+
import { filters } from '../utils/filters';
|
|
6
|
+
export default {
|
|
7
|
+
title: '@Blocks/CommonGrid',
|
|
8
|
+
};
|
|
9
|
+
export var ManyColumnsNoScrollLayout = function () { return (_jsx(CommonGrid, { rowsData: createOversizedRandomData(5), filters: filters, columnsDefinitions: oversizedColumnDefinition, columnLayout: "no-scroll", hideColumnConfig: true, gridSelectors: gridSelectors, gridActions: gridDummyActions })); };
|
|
10
|
+
ManyColumnsNoScrollLayout.story = {
|
|
11
|
+
name: 'many columns no-scroll layout',
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import CommonGrid from '../../CommonGrid';
|
|
3
|
+
import { createOversizedRandomData, gridSelectors, gridDummyActions } from '../utils/utils';
|
|
4
|
+
import { oversizedColumnDefinition } from '../utils/columnDefinition';
|
|
5
|
+
import { filters } from '../utils/filters';
|
|
6
|
+
export default {
|
|
7
|
+
title: '@Blocks/CommonGrid',
|
|
8
|
+
};
|
|
9
|
+
export var ManyColumnsNormalLayoutANoControls = function () { return (_jsx(CommonGrid, { rowsData: createOversizedRandomData(5), filters: filters, columnsDefinitions: oversizedColumnDefinition, hideColumnConfig: true, gridSelectors: gridSelectors, gridActions: gridDummyActions, hideAllControls: true })); };
|
|
10
|
+
ManyColumnsNormalLayoutANoControls.story = {
|
|
11
|
+
name: 'many columns normal layout a no controls',
|
|
12
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ReduxGrid, createRandomData, gridSelectors, gridDummyActions } from '../utils/utils';
|
|
3
|
+
import { filters } from '../utils/filters';
|
|
4
|
+
import { onRowAction } from '../utils/actions';
|
|
5
|
+
import { columnDefinitions } from '../utils/columnDefinition';
|
|
6
|
+
import withTheme from '../utils/withTheme';
|
|
7
|
+
import withRouter from '../utils/withRouter';
|
|
8
|
+
import withRedux from '../utils/withRedux';
|
|
9
|
+
export default {
|
|
10
|
+
title: '@Blocks/CommonGrid',
|
|
11
|
+
decorators: [withTheme, withRouter, withRedux],
|
|
12
|
+
};
|
|
13
|
+
export var Styled = function () {
|
|
14
|
+
return (_jsx("div", { className: "styled", children: _jsx(ReduxGrid, { filters: filters, columnsDefinitions: columnDefinitions, rowsData: createRandomData(10), onRowAction: onRowAction, gridActions: gridDummyActions, gridSelectors: gridSelectors }) }));
|
|
15
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import CommonGrid from '../../CommonGrid';
|
|
3
|
+
import { createRandomData, gridSelectors, gridDummyActions } from '../utils/utils';
|
|
4
|
+
import { columnDefinitions } from '../utils/columnDefinition';
|
|
5
|
+
import { onRowAction } from '../utils/actions';
|
|
6
|
+
import { filters } from '../utils/filters';
|
|
7
|
+
export default {
|
|
8
|
+
title: '@Blocks/CommonGrid',
|
|
9
|
+
};
|
|
10
|
+
export var WithCustomGridActions = function () {
|
|
11
|
+
return (_jsx(CommonGrid, { filters: filters, columnsDefinitions: columnDefinitions, rowsData: createRandomData(10), onRowAction: onRowAction, gridSelectors: gridSelectors, gridActions: gridDummyActions, hideColumnConfig: true }));
|
|
12
|
+
};
|
|
13
|
+
WithCustomGridActions.story = {
|
|
14
|
+
name: 'With custom grid actions',
|
|
15
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ActionColumn } from '../../types';
|
|
2
|
+
export declare const ActionColumnCheckboxes: ActionColumn;
|
|
3
|
+
declare const _default: {
|
|
4
|
+
title: string;
|
|
5
|
+
decorators: ((story: Function) => JSX.Element)[];
|
|
6
|
+
excludeStories: string[];
|
|
7
|
+
};
|
|
8
|
+
export default _default;
|
|
9
|
+
export declare const WithForcedCheckboxesAndCustomTitle: {
|
|
10
|
+
(): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
story: {
|
|
12
|
+
name: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ReduxGrid, createRandomData } from '../utils/utils';
|
|
3
|
+
import { onRowEditClick, onRowReadClick, onRowAction } from '../utils/actions';
|
|
4
|
+
import { columnDefinitions } from '../utils/columnDefinition';
|
|
5
|
+
import withRedux from '../utils/withRedux';
|
|
6
|
+
export var ActionColumnCheckboxes = {
|
|
7
|
+
flexBasis: 160,
|
|
8
|
+
forceCheckboxes: true,
|
|
9
|
+
};
|
|
10
|
+
var components = {
|
|
11
|
+
ColumnTitle: function (_a) {
|
|
12
|
+
var title = _a.title, isSortable = _a.isSortable;
|
|
13
|
+
return _jsx("div", { children: "".concat(title, " is ").concat(isSortable ? '' : 'NOT', " sortable") });
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
export default {
|
|
17
|
+
title: '@Blocks/CommonGrid',
|
|
18
|
+
decorators: [withRedux],
|
|
19
|
+
excludeStories: ['ActionColumnCheckboxes'],
|
|
20
|
+
};
|
|
21
|
+
export var WithForcedCheckboxesAndCustomTitle = function () { return (_jsx(ReduxGrid, { columnsDefinitions: columnDefinitions, actionColumnDefinition: ActionColumnCheckboxes, rowsData: createRandomData(10), onRowAction: onRowAction, onRowReadClick: onRowReadClick, onRowEditClick: onRowEditClick, totalRowsCount: 200, components: components })); };
|
|
22
|
+
WithForcedCheckboxesAndCustomTitle.story = {
|
|
23
|
+
name: 'With forced checkboxes and custom title',
|
|
24
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const onRowEditClick: (id: string, props: object) => void;
|
|
2
|
+
export declare const onRowReadClick: (id: string, props: object) => void;
|
|
3
|
+
export declare const onRowAction: (id: string, field: string, value: string | boolean) => void;
|
|
4
|
+
export declare const onBatchAction: (action: string, affectedRows: object[]) => void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export var onRowEditClick = function (id, props) { return console.log('onRowEditClick', id, props); };
|
|
2
|
+
export var onRowReadClick = function (id, props) { return console.log('onRowReadClick', id, props); };
|
|
3
|
+
export var onRowAction = function (id, field, value) { return console.log('onRowAction', id, field, value); };
|
|
4
|
+
export var onBatchAction = function (action, affectedRows) {
|
|
5
|
+
console.log('onBatchAction called', action, affectedRows);
|
|
6
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ColumnDefinition } from '../../types';
|
|
2
|
+
export declare const oversizedArrayColumns = 25;
|
|
3
|
+
export declare const enumValues: string[];
|
|
4
|
+
export declare const oversizedColumnDefinition: {
|
|
5
|
+
name: string;
|
|
6
|
+
title: string;
|
|
7
|
+
flexBasis: number;
|
|
8
|
+
}[];
|
|
9
|
+
export declare const enumColumn: ColumnDefinition;
|
|
10
|
+
export declare const columnDefinitions: ColumnDefinition[];
|