@mailstep/design-system 0.6.88 → 0.6.89-beta.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 +1 -1
- package/ui/Blocks/CommonGrid/CommonGrid.d.ts +1 -1
- package/ui/Blocks/CommonGrid/CommonGrid.js +2 -2
- package/ui/Blocks/CommonGrid/CommonGridContainer.js +3 -3
- package/ui/Blocks/CommonGrid/components/ColumnFilterCell.d.ts +3 -2
- package/ui/Blocks/CommonGrid/components/ColumnFilterCell.js +3 -3
- package/ui/Blocks/CommonGrid/components/FilterRow.d.ts +3 -2
- package/ui/Blocks/CommonGrid/components/FilterRow.js +2 -2
- package/ui/Blocks/CommonGrid/components/{DatePickerRange → Filters/DatePickerRange}/DatePickerRange.d.ts +1 -1
- package/ui/Blocks/CommonGrid/components/{DatePickerRange → Filters/DatePickerRange}/DatePickerRange.js +3 -3
- package/ui/Blocks/CommonGrid/components/{GridSelect → Filters/GridSelect}/GridSelect.d.ts +1 -1
- package/ui/Blocks/CommonGrid/components/{GridSelect → Filters/GridSelect}/GridSelect.js +2 -2
- package/ui/Blocks/CommonGrid/components/{NumberRange → Filters/NumberRange}/NumberRange.js +4 -4
- package/ui/Blocks/CommonGrid/components/{NumberRange → Filters/NumberRange}/types.d.ts +1 -1
- package/ui/Blocks/CommonGrid/components/{TextRange → Filters/TextRange}/TextRange.js +7 -5
- package/ui/Blocks/CommonGrid/components/{TextRange → Filters/TextRange}/types.d.ts +1 -1
- package/ui/Blocks/CommonGrid/storybook/stories/complexWithPaginationAndRedux.stories.js +4 -1
- package/ui/Blocks/CommonGrid/styles.d.ts +1 -1
- package/ui/Blocks/CommonGrid/types.d.ts +4 -1
- package/ui/Blocks/CommonGrid/utils/index.d.ts +1 -1
- package/ui/Blocks/CommonGrid/utils/index.js +14 -14
- package/ui/index.es.js +8911 -8907
- package/ui/index.umd.js +385 -385
- /package/ui/Blocks/CommonGrid/components/{BooleanSelect → Filters/BooleanSelect}/BooleanSelect.d.ts +0 -0
- /package/ui/Blocks/CommonGrid/components/{BooleanSelect → Filters/BooleanSelect}/BooleanSelect.js +0 -0
- /package/ui/Blocks/CommonGrid/components/{BooleanSelect → Filters/BooleanSelect}/index.d.ts +0 -0
- /package/ui/Blocks/CommonGrid/components/{BooleanSelect → Filters/BooleanSelect}/index.js +0 -0
- /package/ui/Blocks/CommonGrid/components/{DatePickerRange → Filters/DatePickerRange}/index.d.ts +0 -0
- /package/ui/Blocks/CommonGrid/components/{DatePickerRange → Filters/DatePickerRange}/index.js +0 -0
- /package/ui/Blocks/CommonGrid/components/{DatePickerRange → Filters/DatePickerRange}/utils/sameDate.d.ts +0 -0
- /package/ui/Blocks/CommonGrid/components/{DatePickerRange → Filters/DatePickerRange}/utils/sameDate.js +0 -0
- /package/ui/Blocks/CommonGrid/components/{GridSelect → Filters/GridSelect}/index.d.ts +0 -0
- /package/ui/Blocks/CommonGrid/components/{GridSelect → Filters/GridSelect}/index.js +0 -0
- /package/ui/Blocks/CommonGrid/components/{NumberRange → Filters/NumberRange}/NumberRange.d.ts +0 -0
- /package/ui/Blocks/CommonGrid/components/{NumberRange → Filters/NumberRange}/index.d.ts +0 -0
- /package/ui/Blocks/CommonGrid/components/{NumberRange → Filters/NumberRange}/index.js +0 -0
- /package/ui/Blocks/CommonGrid/components/{NumberRange → Filters/NumberRange}/types.js +0 -0
- /package/ui/Blocks/CommonGrid/components/{TextRange → Filters/TextRange}/TextRange.d.ts +0 -0
- /package/ui/Blocks/CommonGrid/components/{TextRange → Filters/TextRange}/index.d.ts +0 -0
- /package/ui/Blocks/CommonGrid/components/{TextRange → Filters/TextRange}/index.js +0 -0
- /package/ui/Blocks/CommonGrid/components/{TextRange → Filters/TextRange}/types.js +0 -0
package/package.json
CHANGED
|
@@ -5,5 +5,5 @@ type Props = CommonGridProps & {
|
|
|
5
5
|
handleDragEnd: (item: DropResult) => void;
|
|
6
6
|
displayColumnsDefinitions: ColumnDefinition[];
|
|
7
7
|
};
|
|
8
|
-
declare const CommonGrid: ({ filters, handleDragEnd, gridSelectors, gridActions, isLoading, rowsData, hasColouredRows, columnsDefinitions, actionColumnDefinition, allowRowSelect, allowRowSelectOnAction, onRowAction, onRowEditClick, onRowReadClick, onRowClick, columnLayout, displayColumnsDefinitions, className, gridRef, minColumnWidth, errorMessage, floatingButtonProps, }: Props) => JSX.Element;
|
|
8
|
+
declare const CommonGrid: ({ filters, comparators, handleDragEnd, gridSelectors, gridActions, isLoading, rowsData, hasColouredRows, columnsDefinitions, actionColumnDefinition, allowRowSelect, allowRowSelectOnAction, onRowAction, onRowEditClick, onRowReadClick, onRowClick, columnLayout, displayColumnsDefinitions, className, gridRef, minColumnWidth, errorMessage, floatingButtonProps, }: Props) => JSX.Element;
|
|
9
9
|
export default CommonGrid;
|
|
@@ -36,7 +36,7 @@ var defaultVoidFunction = function () {
|
|
|
36
36
|
var defaultUxState = initialState.uxState;
|
|
37
37
|
var defaultColumnsWidth = {};
|
|
38
38
|
var CommonGrid = function (_a) {
|
|
39
|
-
var filters = _a.filters, handleDragEnd = _a.handleDragEnd,
|
|
39
|
+
var filters = _a.filters, comparators = _a.comparators, handleDragEnd = _a.handleDragEnd,
|
|
40
40
|
// redux props
|
|
41
41
|
gridSelectors = _a.gridSelectors, gridActions = _a.gridActions,
|
|
42
42
|
// input props
|
|
@@ -63,7 +63,7 @@ var CommonGrid = function (_a) {
|
|
|
63
63
|
gridBoxRef.current = node;
|
|
64
64
|
!!gridRef && (gridRef.current = node);
|
|
65
65
|
}, []);
|
|
66
|
-
return (_jsxs(_Fragment, { children: [_jsx(x.div, { className: className || '', children: _jsxs(OversizedScroll, { columnLayout: columnLayout, isLoading: isLoading, totalColumnsWidth: totalColumnsWidth, floatingChildren: GridMessage && (_jsx(Row, { className: "dataRow", align: "center", children: _jsx(MessageCell, { align: "center", className: "gridMessage ".concat(messageClass), width: window.innerWidth, children: GridMessage }) })), ref: commonGridRef, children: [_jsxs("div", { className: "gridHead", children: [columnsDefinitions.find(function (col) { return col.group; }) && (_jsx(GroupRow, { actionColumn: actionColumnDefinition, columns: displayColumnsDefinitions, displayColumnsWidth: displayColumnsWidth, groups: groups })), _jsx(HeadRow, { columns: displayColumnsDefinitions, actionColumn: actionColumnDefinition, onAddSort: addSorting, columnLayout: columnLayout, sortingValues: sorting, displayColumnsWidth: displayColumnsWidth, handleResizeDrag: handleResizeDrag, groups: groups, handleDragEnd: handleDragEnd }), columnsDefinitions.find(function (col) { return col.filtering; }) && (_jsx(FilterRow, { filters: filters, 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 &&
|
|
66
|
+
return (_jsxs(_Fragment, { children: [_jsx(x.div, { className: className || '', children: _jsxs(OversizedScroll, { columnLayout: columnLayout, isLoading: isLoading, totalColumnsWidth: totalColumnsWidth, floatingChildren: GridMessage && (_jsx(Row, { className: "dataRow", align: "center", children: _jsx(MessageCell, { align: "center", className: "gridMessage ".concat(messageClass), width: window.innerWidth, children: GridMessage }) })), ref: commonGridRef, children: [_jsxs("div", { className: "gridHead", children: [columnsDefinitions.find(function (col) { return col.group; }) && (_jsx(GroupRow, { actionColumn: actionColumnDefinition, columns: displayColumnsDefinitions, displayColumnsWidth: displayColumnsWidth, groups: groups })), _jsx(HeadRow, { columns: displayColumnsDefinitions, actionColumn: actionColumnDefinition, onAddSort: addSorting, columnLayout: columnLayout, sortingValues: sorting, displayColumnsWidth: displayColumnsWidth, handleResizeDrag: handleResizeDrag, groups: groups, handleDragEnd: handleDragEnd }), columnsDefinitions.find(function (col) { return col.filtering; }) && (_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 &&
|
|
67
67
|
rowsData &&
|
|
68
68
|
displayColumnsDefinitions &&
|
|
69
69
|
rowsData.map(function (row, index) {
|
|
@@ -39,7 +39,7 @@ import { CommonGridWithStyles, BottomWrapper, CommonGridWrap, ContentContainer,
|
|
|
39
39
|
import { getFilters, GRID_MIN_ROWS, rowHeight } from './utils';
|
|
40
40
|
var CommonGridContainer = function (props) {
|
|
41
41
|
var _a;
|
|
42
|
-
var _b = props.optimizeFilters, optimizeFilters = _b === void 0 ? false : _b, extraControlButtons = props.extraControlButtons, onBatchAction = props.onBatchAction, processCheckedValues = props.processCheckedValues, processCheckedValuesTitle = props.processCheckedValuesTitle, hideControlButtons = props.hideControlButtons, quickFilter = props.quickFilter, floatingButtonProps = props.floatingButtonProps, queryRowsParam = props.queryRowsParam, customPaginationHandler = props.customPaginationHandler, _c = props.autoHeight, autoHeight = _c === void 0 ? true : _c,
|
|
42
|
+
var _b = props.optimizeFilters, optimizeFilters = _b === void 0 ? false : _b, extraControlButtons = props.extraControlButtons, onBatchAction = props.onBatchAction, processCheckedValues = props.processCheckedValues, processCheckedValuesTitle = props.processCheckedValuesTitle, hideControlButtons = props.hideControlButtons, quickFilter = props.quickFilter, floatingButtonProps = props.floatingButtonProps, queryRowsParam = props.queryRowsParam, customPaginationHandler = props.customPaginationHandler, _c = props.autoHeight, autoHeight = _c === void 0 ? true : _c, passDownProps = __rest(props, ["optimizeFilters", "extraControlButtons", "onBatchAction", "processCheckedValues", "processCheckedValuesTitle", "hideControlButtons", "quickFilter", "floatingButtonProps", "queryRowsParam", "customPaginationHandler", "autoHeight"]);
|
|
43
43
|
var gridActions = passDownProps.gridActions, gridSelectors = passDownProps.gridSelectors, rowsData = passDownProps.rowsData, actionColumnDefinition = passDownProps.actionColumnDefinition;
|
|
44
44
|
var _d = useState(false), displayManageColumnButton = _d[0], setDisplayManageColumnButton = _d[1];
|
|
45
45
|
var _e = useGetGridHeight(), gridHeight = _e.gridHeight, gridRef = _e.gridRef, paginationRef = _e.paginationRef;
|
|
@@ -54,7 +54,7 @@ var CommonGridContainer = function (props) {
|
|
|
54
54
|
}
|
|
55
55
|
}, [gridHeight, gridActions, queryRowsParam]);
|
|
56
56
|
var modifiedPassDownProps = useEditReadAsColumn(passDownProps);
|
|
57
|
-
var
|
|
57
|
+
var filters = useMemo(function () { return getFilters(optimizeFilters); }, [optimizeFilters]);
|
|
58
58
|
var columns = modifiedPassDownProps.columnsDefinitions;
|
|
59
59
|
var _f = useModal(), openManageColumnForm = _f.onOpen, manageColumnFormVisible = _f.isOpen, onClose = _f.onClose;
|
|
60
60
|
var _g = useManageColumn({
|
|
@@ -63,6 +63,6 @@ var CommonGridContainer = function (props) {
|
|
|
63
63
|
gridSelectors: gridSelectors,
|
|
64
64
|
onClose: onClose
|
|
65
65
|
}), columnsConfigValues = _g.columnsConfigValues, setColumnsConfigOptions = _g.setColumnsConfigOptions, onConfirmForm = _g.onConfirmForm, resetColumnConfig = _g.resetColumnConfig, handleDragEnd = _g.handleDragEnd, onCloseForm = _g.onCloseForm, displayColumnsDefinitions = _g.displayColumnsDefinitions, manageColumnsFormDefinitions = _g.manageColumnsFormDefinitions;
|
|
66
|
-
return (_jsxs(ContentContainer, { children: [_jsxs(CommonGridWrap, { children: [_jsx(HidePrint, { children: _jsx(StyledButtonStrip, { className: "buttonsStrip", children: _jsx(ControlButtons, { hideControlButtons: hideControlButtons, extraControlButtons: extraControlButtons, gridActions: gridActions, gridSelectors: gridSelectors, quickFilter: quickFilter, displayColumnsDefinitions: displayColumnsDefinitions, filters:
|
|
66
|
+
return (_jsxs(ContentContainer, { children: [_jsxs(CommonGridWrap, { children: [_jsx(HidePrint, { children: _jsx(StyledButtonStrip, { className: "buttonsStrip", children: _jsx(ControlButtons, { hideControlButtons: hideControlButtons, extraControlButtons: extraControlButtons, gridActions: gridActions, gridSelectors: gridSelectors, quickFilter: quickFilter, displayColumnsDefinitions: displayColumnsDefinitions, filters: filters, setDisplayManageColumnButton: setDisplayManageColumnButton, displayManageColumnButton: displayManageColumnButton, openManageColumnForm: openManageColumnForm }) }) }), _jsx(CommonGridWithStyles, __assign({}, passDownProps, modifiedPassDownProps, { filters: filters, gridRef: gridRef, height: gridHeight, floatingButtonProps: floatingButtonProps, handleDragEnd: handleDragEnd(false), displayColumnsDefinitions: displayColumnsDefinitions, hasColouredRows: true }))] }), _jsx(HidePrint, { children: _jsxs(BottomWrapper, { ref: paginationRef, isFixed: !!gridHeight, children: [(processCheckedValues || !!((_a = actionColumnDefinition === null || actionColumnDefinition === void 0 ? void 0 : actionColumnDefinition.actionOptions) === null || _a === void 0 ? void 0 : _a.length)) && (_jsx(ActionHead, { rowsData: rowsData, onBatchAction: onBatchAction, gridActions: gridActions, gridSelectors: gridSelectors, actionColumn: actionColumnDefinition, processCheckedValues: processCheckedValues, processCheckedValuesTitle: processCheckedValuesTitle })), _jsxs(x.div, { display: "flex", justifyContent: "center", alignItems: "center", className: "paginatorWrapper", w: "100%", h: window.innerWidth > 1204 ? '60px' : '32px', children: [_jsx(Pagination, { page: gridSelectors === null || gridSelectors === void 0 ? void 0 : gridSelectors.page, itemCount: passDownProps === null || passDownProps === void 0 ? void 0 : passDownProps.totalRowsCount, itemPerPage: (gridSelectors === null || gridSelectors === void 0 ? void 0 : gridSelectors.rowsPerPage) || 10, onPageChange: gridActions === null || gridActions === void 0 ? void 0 : gridActions.setPage, customPaginationHandler: customPaginationHandler, radius: window.innerWidth < 768 ? 3 : 5, rate: window.innerWidth < 768 ? 1 : 4 }), _jsx(TablePagination, { gridActions: gridActions, gridSelectors: gridSelectors, customPaginationHandler: customPaginationHandler })] })] }) }), manageColumnFormVisible && (_jsx(Modal, { title: _jsx(Trans, { id: "manageColumn.title", message: "Manage columns" }), onClose: onCloseForm, onCancel: onCloseForm, onExtraAction: resetColumnConfig, onConfirm: onConfirmForm, width: "auto", minWidth: "350px", hasFooter: true, extraActionLabel: _jsx(Trans, { id: "dataGrid.buttonClearConfig", message: "Reset config" }), cancelLabel: _jsx(Trans, { id: "form.buttonCancel", message: "Cancel" }), confirmLabel: _jsx(Trans, { id: "form.buttonConfirm", message: "Confirm" }), children: _jsx(ManageColumnForm, { columns: manageColumnsFormDefinitions, columnsConfigValues: columnsConfigValues, setColumnsConfigOptions: setColumnsConfigOptions, handleDragEnd: handleDragEnd(true) }) }))] }));
|
|
67
67
|
};
|
|
68
68
|
export default CommonGridContainer;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColumnDefinition, GridActionsType, FiltersConfig, Group } from '../types';
|
|
1
|
+
import { ColumnDefinition, GridActionsType, FiltersConfig, CustomComparators, Group } from '../types';
|
|
2
2
|
type Props = {
|
|
3
3
|
onChange: Required<GridActionsType>['addFilter'];
|
|
4
4
|
value?: any;
|
|
@@ -6,6 +6,7 @@ type Props = {
|
|
|
6
6
|
displayColumnWidth: number;
|
|
7
7
|
filters?: FiltersConfig;
|
|
8
8
|
group?: Group;
|
|
9
|
+
comparators?: CustomComparators;
|
|
9
10
|
};
|
|
10
|
-
declare const ColumnFilterCell: ({ onChange, value, displayColumnWidth, filters, column: columnDefinition, group, }: Props) => JSX.Element;
|
|
11
|
+
declare const ColumnFilterCell: ({ onChange, value, displayColumnWidth, filters, column: columnDefinition, group, comparators, }: Props) => JSX.Element;
|
|
11
12
|
export default ColumnFilterCell;
|
|
@@ -18,7 +18,7 @@ import { createFilterType, getStickyCollClassNames } from '../utils';
|
|
|
18
18
|
import { getCellSizeProps, getGroupClassNames } from '../utils';
|
|
19
19
|
import OverlayComponent from './FilterDropdown';
|
|
20
20
|
var ColumnFilterCell = function (_a) {
|
|
21
|
-
var onChange = _a.onChange, value = _a.value, displayColumnWidth = _a.displayColumnWidth, filters = _a.filters, columnDefinition = _a.column, group = _a.group;
|
|
21
|
+
var onChange = _a.onChange, value = _a.value, displayColumnWidth = _a.displayColumnWidth, filters = _a.filters, columnDefinition = _a.column, group = _a.group, comparators = _a.comparators;
|
|
22
22
|
var cellSizeProps = getCellSizeProps(columnDefinition, displayColumnWidth);
|
|
23
23
|
var handleAddFilter = useAddFilter(onChange);
|
|
24
24
|
var handleChange = React.useCallback(function (event) {
|
|
@@ -30,12 +30,12 @@ var ColumnFilterCell = function (_a) {
|
|
|
30
30
|
}
|
|
31
31
|
var filterType = createFilterType(columnDefinition);
|
|
32
32
|
var filterConfig = filters === null || filters === void 0 ? void 0 : filters[filterType];
|
|
33
|
+
var defaultComparators = comparators === null || comparators === void 0 ? void 0 : comparators[filterType];
|
|
33
34
|
var RenderComponent = filterConfig === null || filterConfig === void 0 ? void 0 : filterConfig.CellComponent;
|
|
34
35
|
if (!RenderComponent) {
|
|
35
36
|
console.error("ERROR, using unknown filter type ".concat(filterType));
|
|
36
37
|
return (_jsx(x.div, { children: _jsx("span", { children: "".concat(filterType, " filter") }) }));
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
-
return (_jsx(Cell, __assign({ className: cellClassName }, cellSizeProps, { children: _jsx(x.div, { className: "test", children: _jsx(RenderComponent, __assign({ "data-test": columnDefinition.name, name: columnDefinition.name, onChange: handleChange, value: value, OverlayComponent: OverlayComponent }, passProps)) }) })));
|
|
39
|
+
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, OverlayComponent: OverlayComponent, comparators: defaultComparators }, filterConfig === null || filterConfig === void 0 ? void 0 : filterConfig.defaultExtraProps, columnDefinition.filterExtraProps, (filterType == 'options' && { options: columnDefinition.filterOptions }))) }) })));
|
|
40
40
|
};
|
|
41
41
|
export default ColumnFilterCell;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Settings, ColumnDefinition as ColumnDefinitionType, ActionColumn, GridActionsType, GridSelectorsType, Group, FiltersConfig, UxState, RowProps } from '../types';
|
|
1
|
+
import { Settings, ColumnDefinition as ColumnDefinitionType, ActionColumn, GridActionsType, GridSelectorsType, Group, CustomComparators, FiltersConfig, UxState, RowProps } from '../types';
|
|
2
2
|
type Props = {
|
|
3
3
|
columns: ColumnDefinitionType[];
|
|
4
4
|
actionColumn?: ActionColumn;
|
|
@@ -6,10 +6,11 @@ type Props = {
|
|
|
6
6
|
filterValues?: Settings['filter'];
|
|
7
7
|
displayColumnsWidth: Required<GridSelectorsType>['columnsWidth'];
|
|
8
8
|
filters?: FiltersConfig;
|
|
9
|
+
comparators?: CustomComparators;
|
|
9
10
|
groups?: Group[];
|
|
10
11
|
handleUxChange?: GridActionsType['handleUxChange'];
|
|
11
12
|
rowsData: RowProps[];
|
|
12
13
|
uxState: UxState;
|
|
13
14
|
};
|
|
14
|
-
declare const FilterRow: ({ columns, groups, actionColumn, onChange, filterValues, displayColumnsWidth, filters, handleUxChange, rowsData, uxState, }: Props) => JSX.Element;
|
|
15
|
+
declare const FilterRow: ({ columns, groups, actionColumn, onChange, filterValues, displayColumnsWidth, filters, comparators, handleUxChange, rowsData, uxState, }: Props) => JSX.Element;
|
|
15
16
|
export default FilterRow;
|
|
@@ -20,7 +20,7 @@ import { useToggleAllCheckbox } from '../hooks/useToggleAllCheckbox';
|
|
|
20
20
|
import Checkbox from '../../../Forms/Checkbox';
|
|
21
21
|
var FilterRow = function (_a) {
|
|
22
22
|
var _b, _c;
|
|
23
|
-
var columns = _a.columns, groups = _a.groups, actionColumn = _a.actionColumn, onChange = _a.onChange, _d = _a.filterValues, filterValues = _d === void 0 ? {} : _d, displayColumnsWidth = _a.displayColumnsWidth, filters = _a.filters, handleUxChange = _a.handleUxChange, rowsData = _a.rowsData, uxState = _a.uxState;
|
|
23
|
+
var columns = _a.columns, groups = _a.groups, actionColumn = _a.actionColumn, onChange = _a.onChange, _d = _a.filterValues, filterValues = _d === void 0 ? {} : _d, displayColumnsWidth = _a.displayColumnsWidth, filters = _a.filters, comparators = _a.comparators, handleUxChange = _a.handleUxChange, rowsData = _a.rowsData, uxState = _a.uxState;
|
|
24
24
|
var handleOnChange = throttle(onChange, 500);
|
|
25
25
|
var actionColumnStyle = React.useMemo(function () {
|
|
26
26
|
return actionColumn ? __assign({}, getActionCellSizeProps(actionColumn)) : {};
|
|
@@ -29,6 +29,6 @@ var FilterRow = function (_a) {
|
|
|
29
29
|
var displayCheckbox = (actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.checkAllPosition) === 'top' && (((_b = actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.actionOptions) === null || _b === void 0 ? void 0 : _b.length) || (actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.forceCheckboxes));
|
|
30
30
|
var displayRowNumberLabel = actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.addRowNumbers;
|
|
31
31
|
var rowsNumberLabel = (_c = actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.addRowNumbersLabel) !== null && _c !== void 0 ? _c : '#';
|
|
32
|
-
return (_jsxs(Row, { className: "filterRow", children: [displayCheckbox && (_jsx(Cell, { className: "cell", style: actionColumnStyle, children: _jsx(Checkbox, { checked: allChecked, onChange: toggleCheckbox, label: "" }, "check-all") })), displayRowNumberLabel && (_jsx(Cell, { className: "cell", style: actionColumnStyle, children: _jsx("div", { children: rowsNumberLabel }) })), !!(!displayCheckbox && !displayRowNumberLabel && actionColumn) && (_jsx(Cell, { className: "cell", style: actionColumnStyle }, 'actions')), columns.map(function (column, index) { return (_jsx(ColumnFilterCell, { column: column, onChange: handleOnChange, value: get([getFilterName(column), 'value'], filterValues), displayColumnWidth: displayColumnsWidth[column.name], filters: filters, group: groups === null || groups === void 0 ? void 0 : groups[index] }, index)); })] }));
|
|
32
|
+
return (_jsxs(Row, { className: "filterRow", children: [displayCheckbox && (_jsx(Cell, { className: "cell", style: actionColumnStyle, children: _jsx(Checkbox, { checked: allChecked, onChange: toggleCheckbox, label: "" }, "check-all") })), displayRowNumberLabel && (_jsx(Cell, { className: "cell", style: actionColumnStyle, children: _jsx("div", { children: rowsNumberLabel }) })), !!(!displayCheckbox && !displayRowNumberLabel && actionColumn) && (_jsx(Cell, { className: "cell", style: actionColumnStyle }, 'actions')), columns.map(function (column, index) { return (_jsx(ColumnFilterCell, { column: column, onChange: handleOnChange, value: get([getFilterName(column), 'value'], filterValues), displayColumnWidth: displayColumnsWidth[column.name], filters: filters, comparators: comparators, group: groups === null || groups === void 0 ? void 0 : groups[index] }, index)); })] }));
|
|
33
33
|
};
|
|
34
34
|
export default FilterRow;
|
|
@@ -29,9 +29,9 @@ import React, { useState, useCallback, useMemo } from 'react';
|
|
|
29
29
|
import { DateTime } from 'luxon';
|
|
30
30
|
import styled from '@xstyled/styled-components';
|
|
31
31
|
import { sameDate } from './utils/sameDate';
|
|
32
|
-
import { useClickOutside } from '
|
|
33
|
-
import DatePicker from '
|
|
34
|
-
import Input from '
|
|
32
|
+
import { useClickOutside } from '../../../../Modal/hooks/useClickOutside';
|
|
33
|
+
import DatePicker from '../../../../../Elements/DatePicker';
|
|
34
|
+
import Input from '../../../../../Forms/Input';
|
|
35
35
|
import { i18n } from '@lingui/core';
|
|
36
36
|
var RangeWrapper = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: inline-flex;\n margin-right: 20px;\n"], ["\n display: inline-flex;\n margin-right: 20px;\n"
|
|
37
37
|
// User readable date range.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
|
-
import MultiSelect from '
|
|
4
|
-
import SingleSelect from '
|
|
3
|
+
import MultiSelect from '../../../../../Elements/MultiSelect';
|
|
4
|
+
import SingleSelect from '../../../../../Elements/SingleSelect';
|
|
5
5
|
import isArray from 'lodash/isArray';
|
|
6
6
|
var emptyValue = [];
|
|
7
7
|
var SelectFilter = function (_a) {
|
|
@@ -22,10 +22,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
22
22
|
};
|
|
23
23
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
24
|
import { useCallback, useState } from 'react';
|
|
25
|
-
import { Input } from '
|
|
26
|
-
import { useClickOutside } from '
|
|
27
|
-
import { useEvent } from '
|
|
28
|
-
import IconList from '
|
|
25
|
+
import { Input } from '../../../../../Forms/Input/Input';
|
|
26
|
+
import { useClickOutside } from '../../../../Modal/hooks/useClickOutside';
|
|
27
|
+
import { useEvent } from '../../../hooks/useEvent';
|
|
28
|
+
import IconList from '../../IconList';
|
|
29
29
|
import { i18n } from '@lingui/core';
|
|
30
30
|
var OverlayComponentDefault = function (_a) {
|
|
31
31
|
var children = _a.children;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Comparator, FilterComponentProps } from '
|
|
1
|
+
import { Comparator, FilterComponentProps } from '../../../types';
|
|
2
2
|
export type ComparatorValue = 'eq' | 'neq' | 'lt' | 'lte' | 'gt' | 'gte';
|
|
3
3
|
export type NumberRangeValue = {
|
|
4
4
|
comparator?: ComparatorValue;
|
|
@@ -22,10 +22,10 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
22
22
|
};
|
|
23
23
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
24
|
import { useCallback, useState } from 'react';
|
|
25
|
-
import { Input } from '
|
|
26
|
-
import { useClickOutside } from '
|
|
27
|
-
import { useEvent } from '
|
|
28
|
-
import IconList from '
|
|
25
|
+
import { Input } from '../../../../../Forms/Input/Input';
|
|
26
|
+
import { useClickOutside } from '../../../../Modal/hooks/useClickOutside';
|
|
27
|
+
import { useEvent } from '../../../hooks/useEvent';
|
|
28
|
+
import IconList from '../../IconList/IconList';
|
|
29
29
|
import { i18n } from '@lingui/core';
|
|
30
30
|
import { Trans } from '@lingui/react';
|
|
31
31
|
var OverlayComponentDefault = function (_a) {
|
|
@@ -57,7 +57,9 @@ var validations = {
|
|
|
57
57
|
};
|
|
58
58
|
var TextRange = function (props) {
|
|
59
59
|
var _a;
|
|
60
|
-
var name = props.name, _b = props.value, value = _b === void 0 ? {} : _b, label = props.label, onChange = props.onChange, className = props.className, _c = props.OverlayComponent, OverlayComponent = _c === void 0 ? OverlayComponentDefault : _c, eqOnly = props.eqOnly, isPresent = props.isPresent, isEqual = props.isEqual, defaultComparator = props.defaultComparator,
|
|
60
|
+
var name = props.name, _b = props.value, value = _b === void 0 ? {} : _b, label = props.label, onChange = props.onChange, className = props.className, _c = props.OverlayComponent, OverlayComponent = _c === void 0 ? OverlayComponentDefault : _c, eqOnly = props.eqOnly, isPresent = props.isPresent, isEqual = props.isEqual, defaultComparator = props.defaultComparator, // from filterExtraProps
|
|
61
|
+
comparators = props.comparators, // from filterExtraProps or customComparators
|
|
62
|
+
validationKey = props.validation, rest = __rest(props, ["name", "value", "label", "onChange", "className", "OverlayComponent", "eqOnly", "isPresent", "isEqual", "defaultComparator", "comparators", "validation"]);
|
|
61
63
|
var eqOnlyTxt = i18n._({ id: 'dataGrid.filterTxtEqWarning', message: 'This filter can only do exact match' });
|
|
62
64
|
var _d = useState(false), isOpen = _d[0], setOpen = _d[1];
|
|
63
65
|
var textComparators = createTextComparators();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FilterComponentProps, Comparator } from '
|
|
1
|
+
import { FilterComponentProps, Comparator } from '../../../types';
|
|
2
2
|
export type TextRangeComparator = 'like' | 'notLike' | 'eq' | 'neq' | 'startsWith' | 'endsWith' | 'contains';
|
|
3
3
|
export type TextRangeValue = {
|
|
4
4
|
comparator?: TextRangeComparator;
|
|
@@ -30,11 +30,14 @@ var extraControlButtons = [
|
|
|
30
30
|
onClick: alert
|
|
31
31
|
}
|
|
32
32
|
];
|
|
33
|
+
var comparators = {
|
|
34
|
+
text: [{ label: 'yellow', value: 'Yell' }, { label: 'blue', value: 'Blue' }]
|
|
35
|
+
};
|
|
33
36
|
export default {
|
|
34
37
|
title: 'Blocks/CommonGrid',
|
|
35
38
|
decorators: [withRedux]
|
|
36
39
|
};
|
|
37
|
-
export var ComplexWithPaginationAndRedux = function () { return (_jsxs(LinguiContainer, { children: [_jsx(ConnectedFilterSetter, { gridActions: gridDummyActions }), _jsx(ReduxGrid, { columnsDefinitions: columnDefinitions, actionColumnDefinition: ActionColumnButtons, rowsData: createRandomData(10), onRowAction: onRowAction, onRowReadClick: onRowReadClick, onRowEditClick: onRowEditClick, totalRowsCount: 200, onBatchAction: onBatchAction, quickFilter: "productSku", extraControlButtons: extraControlButtons,
|
|
40
|
+
export var ComplexWithPaginationAndRedux = function () { return (_jsxs(LinguiContainer, { children: [_jsx(ConnectedFilterSetter, { gridActions: gridDummyActions }), _jsx(ReduxGrid, { columnsDefinitions: columnDefinitions, actionColumnDefinition: ActionColumnButtons, rowsData: createRandomData(10), onRowAction: onRowAction, onRowReadClick: onRowReadClick, onRowEditClick: onRowEditClick, totalRowsCount: 200, onBatchAction: onBatchAction, quickFilter: "productSku", extraControlButtons: extraControlButtons, comparators: comparators })] })); };
|
|
38
41
|
ComplexWithPaginationAndRedux.story = {
|
|
39
42
|
name: 'Complex, with pagination and redux'
|
|
40
43
|
};
|
|
@@ -5,7 +5,7 @@ export declare const BottomWrapper: import("styled-components").StyledComponent<
|
|
|
5
5
|
export declare const ContentContainer: import("styled-components").StyledComponent<(props: Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "color">) => import("react").ReactElement<any, "div">, import("@xstyled/system").Theme, import("@xstyled/system").SystemProps<import("@xstyled/system").Theme>, "color">;
|
|
6
6
|
export declare const CommonGridWrap: import("styled-components").StyledComponent<(props: Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "color">) => import("react").ReactElement<any, "div">, import("@xstyled/system").Theme, import("@xstyled/system").SystemProps<import("@xstyled/system").Theme>, "color">;
|
|
7
7
|
export declare const StyledButtonStrip: import("styled-components").StyledComponent<(props: Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "color">) => import("react").ReactElement<any, "div">, import("@xstyled/system").Theme, import("@xstyled/system").SystemProps<import("@xstyled/system").Theme>, "color">;
|
|
8
|
-
export declare const CommonGridWithStyles: import("styled-components").StyledComponent<({ filters, handleDragEnd, gridSelectors, gridActions, isLoading, rowsData, hasColouredRows, columnsDefinitions, actionColumnDefinition, allowRowSelect, allowRowSelectOnAction, onRowAction, onRowEditClick, onRowReadClick, onRowClick, columnLayout, displayColumnsDefinitions, className, gridRef, minColumnWidth, errorMessage, floatingButtonProps, }: import("./types").CommonGridProps & {
|
|
8
|
+
export declare const CommonGridWithStyles: import("styled-components").StyledComponent<({ filters, comparators, handleDragEnd, gridSelectors, gridActions, isLoading, rowsData, hasColouredRows, columnsDefinitions, actionColumnDefinition, allowRowSelect, allowRowSelectOnAction, onRowAction, onRowEditClick, onRowReadClick, onRowClick, columnLayout, displayColumnsDefinitions, className, gridRef, minColumnWidth, errorMessage, floatingButtonProps, }: import("./types").CommonGridProps & {
|
|
9
9
|
filters?: import("./types").FiltersConfig | undefined;
|
|
10
10
|
handleDragEnd: (item: import("react-beautiful-dnd").DropResult) => void;
|
|
11
11
|
displayColumnsDefinitions: import("./types").ColumnDefinition[];
|
|
@@ -57,6 +57,9 @@ export type ComponentsProps = {
|
|
|
57
57
|
Paginator: React.ComponentType<PaginatorProps>;
|
|
58
58
|
ColumnTitle?: ColumnTitleComponentType;
|
|
59
59
|
};
|
|
60
|
+
export type CustomComparators = {
|
|
61
|
+
[name: string]: Comparator[];
|
|
62
|
+
};
|
|
60
63
|
export type FiltersConfig = {
|
|
61
64
|
[name: string]: {
|
|
62
65
|
CellComponent: React.ComponentType<FilterComponentProps<any>>;
|
|
@@ -252,7 +255,6 @@ export type CommonGridProps<TData extends RowProps = RowProps> = {
|
|
|
252
255
|
totalRowsCount?: number;
|
|
253
256
|
allowRowSelect?: boolean;
|
|
254
257
|
allowRowSelectOnAction?: boolean;
|
|
255
|
-
filters?: FiltersConfig;
|
|
256
258
|
onRowAction?: (id: string, field: string, value: any, rowData?: RowProps) => void;
|
|
257
259
|
onRowEditClick?: (id: string, props: TData) => void;
|
|
258
260
|
onRowReadClick?: (id: string, props: TData) => void;
|
|
@@ -269,6 +271,7 @@ export type CommonGridProps<TData extends RowProps = RowProps> = {
|
|
|
269
271
|
perPageOptions?: number[];
|
|
270
272
|
floatingButtonProps?: FloatingButtonProps;
|
|
271
273
|
editReadPosition?: EditReadPosition;
|
|
274
|
+
comparators?: CustomComparators;
|
|
272
275
|
};
|
|
273
276
|
export declare enum EditReadPosition {
|
|
274
277
|
Left = "left",
|
|
@@ -17,5 +17,5 @@ export declare const getGroupClassNames: (group?: Group) => string;
|
|
|
17
17
|
export declare const getStickyCollClassNames: (sticky: boolean, stickTo?: StickTo) => string;
|
|
18
18
|
export declare const GRID_MIN_ROWS = 6;
|
|
19
19
|
export declare const rowHeight = 40;
|
|
20
|
-
export declare const getFilters: (optimizeFilters: boolean
|
|
20
|
+
export declare const getFilters: (optimizeFilters: boolean) => FiltersConfig;
|
|
21
21
|
export declare const checksColumnsOrder: (colsOrder: string[], columnsDefinitions: ColumnDefinition[]) => void;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import NumberRange from '../components/NumberRange';
|
|
2
|
-
import TextRange from '../components/TextRange';
|
|
3
|
-
import DatePickerRange from '../components/DatePickerRange';
|
|
4
|
-
import BooleanSelect from '../components/BooleanSelect';
|
|
5
|
-
import GridSelect from '../components/GridSelect';
|
|
1
|
+
import NumberRange from '../components/Filters/NumberRange';
|
|
2
|
+
import TextRange from '../components/Filters/TextRange';
|
|
3
|
+
import DatePickerRange from '../components/Filters/DatePickerRange';
|
|
4
|
+
import BooleanSelect from '../components/Filters/BooleanSelect';
|
|
5
|
+
import GridSelect from '../components/Filters/GridSelect';
|
|
6
6
|
var isDefined = function (val) { return typeof val !== 'undefined'; };
|
|
7
7
|
export var getActionCellSizeProps = function (column) {
|
|
8
8
|
return {
|
|
@@ -68,18 +68,18 @@ export var getStickyCollClassNames = function (sticky, stickTo) {
|
|
|
68
68
|
};
|
|
69
69
|
export var GRID_MIN_ROWS = 6;
|
|
70
70
|
export var rowHeight = 40;
|
|
71
|
-
export var getFilters = function (optimizeFilters
|
|
72
|
-
var
|
|
73
|
-
number:
|
|
74
|
-
text:
|
|
75
|
-
date:
|
|
76
|
-
flag:
|
|
77
|
-
options:
|
|
71
|
+
export var getFilters = function (optimizeFilters) {
|
|
72
|
+
var filters = {
|
|
73
|
+
number: { CellComponent: NumberRange },
|
|
74
|
+
text: { CellComponent: TextRange },
|
|
75
|
+
date: { CellComponent: DatePickerRange },
|
|
76
|
+
flag: { CellComponent: BooleanSelect },
|
|
77
|
+
options: { CellComponent: GridSelect },
|
|
78
78
|
};
|
|
79
79
|
if (optimizeFilters) {
|
|
80
|
-
|
|
80
|
+
filters.text.defaultExtraProps = { defaultComparator: 'eq' };
|
|
81
81
|
}
|
|
82
|
-
return
|
|
82
|
+
return filters;
|
|
83
83
|
};
|
|
84
84
|
export var checksColumnsOrder = function (colsOrder, columnsDefinitions) {
|
|
85
85
|
var stickyRightColls = columnsDefinitions.filter(function (col) { return col.sticky === true && col.stickTo === 'right'; });
|