@mailstep/design-system 0.7.78-beta.1 → 0.7.79-beta.1
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 +1 -1
- package/ui/Blocks/CommonGrid/CommonGrid.js +2 -2
- package/ui/Blocks/CommonGrid/components/ColumnFilterCell.d.ts +1 -0
- package/ui/Blocks/CommonGrid/components/ColumnFilterCell.js +2 -2
- package/ui/Blocks/CommonGrid/components/FilterRow.d.ts +1 -0
- package/ui/Blocks/CommonGrid/components/FilterRow.js +2 -2
- package/ui/Blocks/CommonGrid/components/Filters/GridSelect/GridSelect.d.ts +5 -2
- package/ui/Blocks/CommonGrid/components/Filters/GridSelect/GridSelect.js +61 -6
- package/ui/Blocks/CommonGrid/components/Filters/NumberRange/NumberRange.js +0 -2
- package/ui/Blocks/CommonGrid/storybook/stories/complexWithPaginationAndRedux.stories.js +2 -2
- package/ui/Blocks/CommonGrid/storybook/utils/columnDefinition.js +9 -0
- package/ui/Blocks/CommonGrid/storybook/utils/utils.d.ts +4 -0
- package/ui/Blocks/CommonGrid/storybook/utils/utils.js +8 -0
- package/ui/Blocks/CommonGrid/types.d.ts +2 -0
- package/ui/Blocks/CommonGrid/utils/index.d.ts +1 -4
- package/ui/Blocks/CommonGrid/utils/index.js +1 -1
- package/ui/index.es.js +9303 -9296
- package/ui/index.umd.js +361 -361
package/package.json
CHANGED
|
@@ -39,7 +39,7 @@ var CommonGrid = function (_a) {
|
|
|
39
39
|
// redux props
|
|
40
40
|
gridSelectors = _a.gridSelectors, gridActions = _a.gridActions,
|
|
41
41
|
// input props
|
|
42
|
-
isLoading = _a.isLoading, rowsData = _a.rowsData, hasColouredRows = _a.hasColouredRows, actionColumnDefinition = _a.actionColumnDefinition, allowRowSelect = _a.allowRowSelect, allowRowSelectOnAction = _a.allowRowSelectOnAction, onRowAction = _a.onRowAction, onRowClick = _a.onRowClick, _b = _a.columnLayout, columnLayout = _b === void 0 ? 'normal' : _b, displayColumnsDefinitions = _a.displayColumnsDefinitions, className = _a.className, minColumnWidth = _a.minColumnWidth, errorMessage = _a.errorMessage, floatingButtonProps = _a.floatingButtonProps, hasGroups = _a.hasGroups, hasFilters = _a.hasFilters, isSortTerminated = _a.isSortTerminated;
|
|
42
|
+
isLoading = _a.isLoading, rowsData = _a.rowsData, hasColouredRows = _a.hasColouredRows, actionColumnDefinition = _a.actionColumnDefinition, allowRowSelect = _a.allowRowSelect, allowRowSelectOnAction = _a.allowRowSelectOnAction, onRowAction = _a.onRowAction, onRowClick = _a.onRowClick, onAsyncLoadFilterOptions = _a.onAsyncLoadFilterOptions, _b = _a.columnLayout, columnLayout = _b === void 0 ? 'normal' : _b, displayColumnsDefinitions = _a.displayColumnsDefinitions, className = _a.className, minColumnWidth = _a.minColumnWidth, errorMessage = _a.errorMessage, floatingButtonProps = _a.floatingButtonProps, hasGroups = _a.hasGroups, hasFilters = _a.hasFilters, isSortTerminated = _a.isSortTerminated;
|
|
43
43
|
var _c = gridSelectors.uxState, uxState = _c === void 0 ? defaultUxState : _c, _d = gridSelectors.columnsWidth, columnsWidth = _d === void 0 ? defaultColumnsWidth : _d, columnsWidthVariant = gridSelectors.columnsWidthVariant, _e = gridSelectors.page, page = _e === void 0 ? 1 : _e, filter = gridSelectors.filter, sorting = gridSelectors.sorting, _f = gridSelectors.rowsPerPage, rowsPerPage = _f === void 0 ? 10 : _f;
|
|
44
44
|
var clearUxState = gridActions.clearUxState, handleUxChange = gridActions.handleUxChange, _g = gridActions.addFilter, addFilter = _g === void 0 ? defaultVoidFunction : _g, _h = gridActions.addSorting, addSorting = _h === void 0 ? defaultVoidFunction : _h, _j = gridActions.setColumnWidth, setColumnWidth = _j === void 0 ? defaultVoidFunction : _j;
|
|
45
45
|
var handleRowsKeyDown = useRowsKeyControls(rowsData, uxState, handleUxChange);
|
|
@@ -53,7 +53,7 @@ var CommonGrid = function (_a) {
|
|
|
53
53
|
}, []);
|
|
54
54
|
var isEmpty = !isLoading && !errorMessage && (!rowsData || rowsData.length < 1);
|
|
55
55
|
var hasFloatingChildren = isLoading || errorMessage || isEmpty;
|
|
56
|
-
return (_jsxs(_Fragment, { children: [_jsx(x.div, { className: className || '', children: _jsxs(OversizedScroll, { columnLayout: columnLayout, totalColumnsWidth: totalColumnsWidth, floatingChildren: hasFloatingChildren && _jsx(GridStatus, { isLoading: isLoading, isEmpty: isEmpty, errorMessage: errorMessage }), ref: commonGridRef, children: [_jsxs("div", { className: "gridHead", children: [hasGroups && (_jsx(GroupRow, { actionColumn: actionColumnDefinition, columns: displayColumnsDefinitions, displayColumnsWidth: displayColumnsWidth, groups: groups })), _jsx(HeadRow, { columns: displayColumnsDefinitions, onAddSort: addSorting, columnLayout: columnLayout, sortingValues: sorting, displayColumnsWidth: displayColumnsWidth, handleResizeDrag: handleResizeDrag, groups: groups, handleDragEnd: handleDragEnd, isSortTerminated: isSortTerminated }), hasFilters && (_jsx(FilterRow, { filters: filters, comparators: comparators, columns: displayColumnsDefinitions, actionColumn: actionColumnDefinition, onChange: addFilter, filterValues: filter, displayColumnsWidth: displayColumnsWidth, groups: groups, rowsData: rowsData, uxState: uxState, handleUxChange: handleUxChange }))] }), _jsx("div", { className: "body flx_1", style: rowsStyles, tabIndex: -1, onKeyDown: handleRowsKeyDown, children: !isLoading &&
|
|
56
|
+
return (_jsxs(_Fragment, { children: [_jsx(x.div, { className: className || '', children: _jsxs(OversizedScroll, { columnLayout: columnLayout, totalColumnsWidth: totalColumnsWidth, floatingChildren: hasFloatingChildren && _jsx(GridStatus, { isLoading: isLoading, isEmpty: isEmpty, errorMessage: errorMessage }), ref: commonGridRef, children: [_jsxs("div", { className: "gridHead", children: [hasGroups && (_jsx(GroupRow, { actionColumn: actionColumnDefinition, columns: displayColumnsDefinitions, displayColumnsWidth: displayColumnsWidth, groups: groups })), _jsx(HeadRow, { columns: displayColumnsDefinitions, onAddSort: addSorting, columnLayout: columnLayout, sortingValues: sorting, displayColumnsWidth: displayColumnsWidth, handleResizeDrag: handleResizeDrag, groups: groups, handleDragEnd: handleDragEnd, isSortTerminated: isSortTerminated }), hasFilters && (_jsx(FilterRow, { filters: filters, comparators: comparators, columns: displayColumnsDefinitions, actionColumn: actionColumnDefinition, onChange: addFilter, filterValues: filter, displayColumnsWidth: displayColumnsWidth, groups: groups, rowsData: rowsData, uxState: uxState, handleUxChange: handleUxChange, onAsyncLoadFilterOptions: onAsyncLoadFilterOptions }))] }), _jsx("div", { className: "body flx_1", style: rowsStyles, tabIndex: -1, onKeyDown: handleRowsKeyDown, children: !isLoading &&
|
|
57
57
|
rowsData &&
|
|
58
58
|
displayColumnsDefinitions &&
|
|
59
59
|
rowsData.map(function (row, index) {
|
|
@@ -14,6 +14,7 @@ type Props = {
|
|
|
14
14
|
rowsData: RowProps[];
|
|
15
15
|
uxState: UxState;
|
|
16
16
|
handleUxChange: GridActionsType['handleUxChange'];
|
|
17
|
+
onAsyncLoadFilterOptions?: (key: string, value: string) => void;
|
|
17
18
|
};
|
|
18
19
|
declare const ColumnFilterCell: FC<Props>;
|
|
19
20
|
export default ColumnFilterCell;
|
|
@@ -17,7 +17,7 @@ import { x } from '@xstyled/styled-components';
|
|
|
17
17
|
import OverlayComponent from './FilterDropdown';
|
|
18
18
|
import { Cell } from './Table';
|
|
19
19
|
var ColumnFilterCell = function (_a) {
|
|
20
|
-
var onChange = _a.onChange, value = _a.value, others = _a.others, displayColumnWidth = _a.displayColumnWidth, filters = _a.filters, columnDefinition = _a.column, group = _a.group, comparators = _a.comparators, actionColumn = _a.actionColumn, rowsData = _a.rowsData, uxState = _a.uxState, handleUxChange = _a.handleUxChange;
|
|
20
|
+
var onChange = _a.onChange, value = _a.value, others = _a.others, displayColumnWidth = _a.displayColumnWidth, filters = _a.filters, columnDefinition = _a.column, group = _a.group, comparators = _a.comparators, actionColumn = _a.actionColumn, rowsData = _a.rowsData, uxState = _a.uxState, handleUxChange = _a.handleUxChange, onAsyncLoadFilterOptions = _a.onAsyncLoadFilterOptions;
|
|
21
21
|
var cellSizeProps = getCellSizeProps(columnDefinition, displayColumnWidth);
|
|
22
22
|
var handleAddFilter = useAddFilter(onChange);
|
|
23
23
|
var handleChange = React.useCallback(function (event, others) {
|
|
@@ -35,6 +35,6 @@ var ColumnFilterCell = function (_a) {
|
|
|
35
35
|
console.error("ERROR, using unknown filter type ".concat(filterType));
|
|
36
36
|
return (_jsx(x.div, { children: _jsx("span", { children: "".concat(filterType, " filter") }) }));
|
|
37
37
|
}
|
|
38
|
-
return (_jsx(Cell, __assign({ className: cellClassName }, cellSizeProps, { children: _jsx(x.div, { children: _jsx(RenderComponent, __assign({ "data-test": columnDefinition.name, name: columnDefinition.name, onChange: handleChange, value: value, others: others, OverlayComponent: OverlayComponent, comparators: defaultComparators, actionColumn: actionColumn, rowsData: rowsData, uxState: uxState, handleUxChange: handleUxChange }, filterConfig === null || filterConfig === void 0 ? void 0 : filterConfig.defaultExtraProps, columnDefinition.filterExtraProps, (filterType == 'options' && { options: columnDefinition.filterOptions }))) }) })));
|
|
38
|
+
return (_jsx(Cell, __assign({ className: cellClassName }, cellSizeProps, { children: _jsx(x.div, { children: _jsx(RenderComponent, __assign({ asyncLoadKey: columnDefinition.asyncLoadKey, "data-test": columnDefinition.name, name: columnDefinition.name, onChange: handleChange, value: value, others: others, OverlayComponent: OverlayComponent, comparators: defaultComparators, actionColumn: actionColumn, rowsData: rowsData, uxState: uxState, handleUxChange: handleUxChange, onAsyncLoadFilterOptions: onAsyncLoadFilterOptions }, filterConfig === null || filterConfig === void 0 ? void 0 : filterConfig.defaultExtraProps, columnDefinition.filterExtraProps, (filterType == 'options' && { options: columnDefinition.filterOptions }))) }) })));
|
|
39
39
|
};
|
|
40
40
|
export default ColumnFilterCell;
|
|
@@ -5,8 +5,8 @@ import throttle from 'lodash/throttle';
|
|
|
5
5
|
import ColumnFilterCell from './ColumnFilterCell';
|
|
6
6
|
import { Row } from './Table';
|
|
7
7
|
var FilterRow = function (_a) {
|
|
8
|
-
var columns = _a.columns, groups = _a.groups, actionColumn = _a.actionColumn, onChange = _a.onChange, _b = _a.filterValues, filterValues = _b === void 0 ? {} : _b, displayColumnsWidth = _a.displayColumnsWidth, filters = _a.filters, comparators = _a.comparators, handleUxChange = _a.handleUxChange, rowsData = _a.rowsData, uxState = _a.uxState;
|
|
8
|
+
var columns = _a.columns, groups = _a.groups, actionColumn = _a.actionColumn, onChange = _a.onChange, _b = _a.filterValues, filterValues = _b === void 0 ? {} : _b, displayColumnsWidth = _a.displayColumnsWidth, filters = _a.filters, comparators = _a.comparators, handleUxChange = _a.handleUxChange, onAsyncLoadFilterOptions = _a.onAsyncLoadFilterOptions, rowsData = _a.rowsData, uxState = _a.uxState;
|
|
9
9
|
var handleOnChange = throttle(onChange, 500);
|
|
10
|
-
return (_jsx(Row, { className: "filterRow", children: columns.map(function (column, index) { return (_jsx(ColumnFilterCell, { column: column, actionColumn: actionColumn, rowsData: rowsData, uxState: uxState, handleUxChange: handleUxChange, onChange: handleOnChange, value: get([getFilterName(column), 'value'], filterValues), others: get([getFilterName(column), 'others'], filterValues), displayColumnWidth: displayColumnsWidth[column.name], filters: filters, comparators: comparators, group: groups === null || groups === void 0 ? void 0 : groups[index] }, index)); }) }));
|
|
10
|
+
return (_jsx(Row, { className: "filterRow", children: columns.map(function (column, index) { return (_jsx(ColumnFilterCell, { column: column, actionColumn: actionColumn, rowsData: rowsData, uxState: uxState, handleUxChange: handleUxChange, onChange: handleOnChange, value: get([getFilterName(column), 'value'], filterValues), others: get([getFilterName(column), 'others'], filterValues), displayColumnWidth: displayColumnsWidth[column.name], filters: filters, comparators: comparators, group: groups === null || groups === void 0 ? void 0 : groups[index], onAsyncLoadFilterOptions: onAsyncLoadFilterOptions }, index)); }) }));
|
|
11
11
|
};
|
|
12
12
|
export default FilterRow;
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Option } from '../../../../../Elements/Select/types';
|
|
3
|
+
import { CommonGridProps } from '../../../types';
|
|
3
4
|
|
|
4
5
|
type Props = {
|
|
5
6
|
onChange: (data: any) => void;
|
|
7
|
+
onAsyncLoadFilterOptions?: CommonGridProps['onAsyncLoadFilterOptions'];
|
|
6
8
|
isMulti?: boolean;
|
|
7
|
-
options?:
|
|
9
|
+
options?: Option[];
|
|
8
10
|
value?: string | string[];
|
|
9
11
|
checkAllButton?: boolean;
|
|
12
|
+
asyncLoadKey?: string;
|
|
10
13
|
};
|
|
11
14
|
declare const SelectFilter: FC<Props>;
|
|
12
15
|
export default SelectFilter;
|
|
@@ -1,19 +1,74 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
1
37
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback } from 'react';
|
|
38
|
+
import { useCallback, useState } from 'react';
|
|
3
39
|
import MultiSelect from '../../../../../Elements/MultiSelect';
|
|
4
40
|
import SingleSelect from '../../../../../Elements/SingleSelect';
|
|
41
|
+
import { i18n } from '@lingui/core';
|
|
5
42
|
import isArray from 'lodash/isArray';
|
|
6
43
|
var emptyValue = [];
|
|
7
44
|
var SelectFilter = function (_a) {
|
|
8
|
-
var onChange = _a.onChange, isMulti = _a.isMulti, value = _a.value, options = _a.options, checkAllButton = _a.checkAllButton;
|
|
45
|
+
var onChange = _a.onChange, isMulti = _a.isMulti, value = _a.value, options = _a.options, checkAllButton = _a.checkAllButton, asyncLoadKey = _a.asyncLoadKey, onAsyncLoadFilterOptions = _a.onAsyncLoadFilterOptions;
|
|
46
|
+
var _b = useState([]), asyncOptions = _b[0], setAsyncOptions = _b[1];
|
|
9
47
|
var handleOnMultiChange = useCallback(function (options) {
|
|
48
|
+
console.log('options', options);
|
|
10
49
|
onChange === null || onChange === void 0 ? void 0 : onChange(!isArray(options) || !(options === null || options === void 0 ? void 0 : options.length) ? null : options.map(function (option) { return option.value; }));
|
|
11
50
|
}, [onChange]);
|
|
51
|
+
var isAsync = !!asyncLoadKey;
|
|
52
|
+
var handleLoadOptions = useCallback(function (fulltext) { return __awaiter(void 0, void 0, void 0, function () {
|
|
53
|
+
var data;
|
|
54
|
+
return __generator(this, function (_a) {
|
|
55
|
+
switch (_a.label) {
|
|
56
|
+
case 0:
|
|
57
|
+
data = [];
|
|
58
|
+
if (!asyncLoadKey) return [3 /*break*/, 2];
|
|
59
|
+
return [4 /*yield*/, (onAsyncLoadFilterOptions === null || onAsyncLoadFilterOptions === void 0 ? void 0 : onAsyncLoadFilterOptions(asyncLoadKey, fulltext))];
|
|
60
|
+
case 1:
|
|
61
|
+
data = (_a.sent()) || [];
|
|
62
|
+
_a.label = 2;
|
|
63
|
+
case 2:
|
|
64
|
+
setAsyncOptions(data);
|
|
65
|
+
return [2 /*return*/, data];
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}); }, [options]);
|
|
12
69
|
if (isMulti) {
|
|
13
|
-
return (_jsx(MultiSelect, { maxMenuHeight: 250, onChange: handleOnMultiChange, value: value || emptyValue, options: options, checkAllButton: checkAllButton, style: "gridFilter" }));
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
return _jsx(SingleSelect, { maxMenuHeight: 250, onChange: onChange, value: value, options: options, style: "gridFilter" });
|
|
70
|
+
return (_jsx(MultiSelect, { maxMenuHeight: 250, onChange: handleOnMultiChange, value: value || emptyValue, options: isAsync ? asyncOptions : options, checkAllButton: !isAsync && checkAllButton, style: "gridFilter", loadOptions: isAsync ? handleLoadOptions : undefined, placeholder: isAsync ? i18n._({ id: 'dataGrid.filterCell', message: 'Type to filter' }) : undefined }));
|
|
17
71
|
}
|
|
72
|
+
return (_jsx(SingleSelect, { maxMenuHeight: 250, onChange: onChange, value: value, options: options, style: "gridFilter", loadOptions: isAsync ? handleLoadOptions : undefined, placeholder: isAsync ? i18n._({ id: 'dataGrid.filterCell', message: 'Type to filter' }) : undefined }));
|
|
18
73
|
};
|
|
19
74
|
export default SelectFilter;
|
|
@@ -99,9 +99,7 @@ var NumberRange = function (props) {
|
|
|
99
99
|
return;
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
|
-
console.log('event.target.value', event.target.value);
|
|
103
102
|
var number = normalizeValue(event.target.value, isFloat, decimals);
|
|
104
|
-
console.log('number', number);
|
|
105
103
|
var isValid = number || number === 0;
|
|
106
104
|
onChange({ comparator: comparator, value: isValid ? number : '' });
|
|
107
105
|
});
|
|
@@ -6,7 +6,7 @@ import { useAddFilter } from '../../hooks/useAddFilter';
|
|
|
6
6
|
import { ExtraControlButtonPosition } from '../../types';
|
|
7
7
|
import { onRowEditClick, onRowReadClick, onRowAction, onRowClick, onBatchAction } from '../utils/actions';
|
|
8
8
|
import { columnDefinitions, enumColumn } from '../utils/columnDefinition';
|
|
9
|
-
import { ReduxGrid, createRandomData, enumValues, gridDummyActions } from '../utils/utils';
|
|
9
|
+
import { ReduxGrid, createRandomData, enumValues, gridDummyActions, onAsyncLoadFilterOptions } from '../utils/utils';
|
|
10
10
|
import withRedux from '../utils/withRedux';
|
|
11
11
|
var ActionColumnButtons = {
|
|
12
12
|
flexBasis: 80,
|
|
@@ -47,7 +47,7 @@ export default {
|
|
|
47
47
|
title: 'Blocks/CommonGrid',
|
|
48
48
|
decorators: [withRedux]
|
|
49
49
|
};
|
|
50
|
-
export var ComplexWithPaginationAndRedux = function () { return (_jsxs(LinguiContainer, { children: [_jsx(ConnectedFilterSetter, { gridActions: gridDummyActions }), _jsx(ReduxGrid, { columnsDefinitions: columnDefinitions, actionColumnDefinition: ActionColumnButtons, rowsData: createRandomData(10), onRowAction: onRowAction, onRowClick: onRowClick, onRowReadClick: onRowReadClick, onRowEditClick: onRowEditClick, totalRowsCount: 200, onBatchAction: onBatchAction, getRowsPerPage: getRowsPerPage, quickFilter: "textColumn", extraControlButtons: extraControlButtons, comparators: comparators, gridName: "gridName" })] })); };
|
|
50
|
+
export var ComplexWithPaginationAndRedux = function () { return (_jsxs(LinguiContainer, { children: [_jsx(ConnectedFilterSetter, { gridActions: gridDummyActions }), _jsx(ReduxGrid, { columnsDefinitions: columnDefinitions, actionColumnDefinition: ActionColumnButtons, rowsData: createRandomData(10), onRowAction: onRowAction, onRowClick: onRowClick, onRowReadClick: onRowReadClick, onRowEditClick: onRowEditClick, totalRowsCount: 200, onBatchAction: onBatchAction, getRowsPerPage: getRowsPerPage, onAsyncLoadFilterOptions: onAsyncLoadFilterOptions, quickFilter: "textColumn", extraControlButtons: extraControlButtons, comparators: comparators, gridName: "gridName" })] })); };
|
|
51
51
|
ComplexWithPaginationAndRedux.story = {
|
|
52
52
|
name: 'Complex, with pagination and redux'
|
|
53
53
|
};
|
|
@@ -34,6 +34,15 @@ export var columnDefinitions = [
|
|
|
34
34
|
sorting: true
|
|
35
35
|
},
|
|
36
36
|
enumColumn,
|
|
37
|
+
{
|
|
38
|
+
name: 'enumColumnAsync',
|
|
39
|
+
title: 'Enum Column Async',
|
|
40
|
+
flexBasis: 160,
|
|
41
|
+
filterExtraProps: { isMulti: false },
|
|
42
|
+
filtering: true,
|
|
43
|
+
sorting: true,
|
|
44
|
+
asyncLoadKey: 'enumColumnAsync'
|
|
45
|
+
},
|
|
37
46
|
{
|
|
38
47
|
name: 'numberColumn',
|
|
39
48
|
title: 'Number Column',
|
|
@@ -18,3 +18,7 @@ export declare const gridDummyActions: Required<GridActionsType>;
|
|
|
18
18
|
export declare const createOversizedRandomData: (count: number) => any[];
|
|
19
19
|
export declare const ReduxGrid: FC<any>;
|
|
20
20
|
export declare const extraControlButtons: ExtraControlButton[];
|
|
21
|
+
export declare const onAsyncLoadFilterOptions: (key: string, value: string) => Promise<{
|
|
22
|
+
label: string;
|
|
23
|
+
value: string;
|
|
24
|
+
}[]>;
|
|
@@ -72,3 +72,11 @@ export var extraControlButtons = [
|
|
|
72
72
|
{ label: 'Reload', position: ExtraControlButtonPosition.TopLeft },
|
|
73
73
|
{ label: 'Export all', position: ExtraControlButtonPosition.TopRight }
|
|
74
74
|
];
|
|
75
|
+
export var onAsyncLoadFilterOptions = function (key, value) {
|
|
76
|
+
return Promise.resolve([
|
|
77
|
+
{ label: 'test1', value: 'test1' },
|
|
78
|
+
{ label: 'test2', value: 'test2' },
|
|
79
|
+
{ label: 'test3', value: 'test3' },
|
|
80
|
+
{ label: 'test4', value: 'test4' },
|
|
81
|
+
]);
|
|
82
|
+
};
|
|
@@ -92,6 +92,7 @@ type ColumnBaseProps = {
|
|
|
92
92
|
};
|
|
93
93
|
export type RowValueType = string | React.ReactNode | number | void;
|
|
94
94
|
export type ColumnDefinition<ColumnName extends string = string> = ColumnBaseProps & {
|
|
95
|
+
asyncLoadKey?: string;
|
|
95
96
|
name: ColumnName;
|
|
96
97
|
group?: Group['name'];
|
|
97
98
|
systemName?: string;
|
|
@@ -248,6 +249,7 @@ export type CommonGridProps<TData extends RowProps = RowProps> = {
|
|
|
248
249
|
onRowReadClick?: (id: string, props: TData) => void;
|
|
249
250
|
onRowClick?: (id: string, props: TData) => void;
|
|
250
251
|
onBatchAction?: OnBatchActionFn;
|
|
252
|
+
onAsyncLoadFilterOptions?: (key: string, value: string) => Promise<Option[]>;
|
|
251
253
|
columnLayout?: ColumnLayout;
|
|
252
254
|
quickFilter?: string;
|
|
253
255
|
confirmOnReset?: () => boolean;
|
|
@@ -8,10 +8,7 @@ export declare const calculatePaginator: (page: number, rowsPerPage: number) =>
|
|
|
8
8
|
offset: number;
|
|
9
9
|
limit: number;
|
|
10
10
|
};
|
|
11
|
-
export declare const createFilterType: (columnDefinition:
|
|
12
|
-
filterOptions?: ColumnDefinition["filterOptions"];
|
|
13
|
-
filteringType?: ColumnDefinition["filteringType"];
|
|
14
|
-
}) => FilterProps["type"];
|
|
11
|
+
export declare const createFilterType: (columnDefinition: ColumnDefinition) => FilterProps["type"];
|
|
15
12
|
export declare const getGroups: (columns: ColumnDefinition[]) => Group[];
|
|
16
13
|
export declare const getGroupClassNames: (group?: Group) => string;
|
|
17
14
|
export declare const getStickyCollClassNames: (sticky: boolean, stickTo?: StickTo) => string;
|
|
@@ -39,7 +39,7 @@ export var calculatePaginator = function (page, rowsPerPage) { return ({
|
|
|
39
39
|
limit: rowsPerPage
|
|
40
40
|
}); };
|
|
41
41
|
export var createFilterType = function (columnDefinition) {
|
|
42
|
-
if (columnDefinition.filterOptions)
|
|
42
|
+
if (columnDefinition.filterOptions || columnDefinition.asyncLoadKey)
|
|
43
43
|
return 'options';
|
|
44
44
|
else
|
|
45
45
|
return columnDefinition.filteringType || 'text';
|