@mailstep/design-system 0.7.47-beta.10 → 0.7.47-beta.12
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 +1 -2
- package/ui/Blocks/CommonGrid/components/ColumnFilterCell.d.ts +6 -2
- package/ui/Blocks/CommonGrid/components/ColumnFilterCell.js +2 -2
- package/ui/Blocks/CommonGrid/components/DataCell.d.ts +1 -0
- package/ui/Blocks/CommonGrid/components/DataCell.js +2 -2
- package/ui/Blocks/CommonGrid/components/DataRow.d.ts +2 -3
- package/ui/Blocks/CommonGrid/components/DataRow.js +4 -21
- package/ui/Blocks/CommonGrid/components/FilterRow.d.ts +1 -1
- package/ui/Blocks/CommonGrid/components/FilterRow.js +5 -29
- package/ui/Blocks/CommonGrid/components/Filters/ActionsFilter/ActionsFilter.d.ts +10 -0
- package/ui/Blocks/CommonGrid/components/Filters/ActionsFilter/ActionsFilter.js +14 -0
- package/ui/Blocks/CommonGrid/components/Filters/ActionsFilter/index.d.ts +2 -0
- package/ui/Blocks/CommonGrid/components/Filters/ActionsFilter/index.js +2 -0
- package/ui/Blocks/CommonGrid/components/gridCells/RowActionsCell.d.ts +2 -0
- package/ui/Blocks/CommonGrid/components/gridCells/RowActionsCell.js +2 -3
- package/ui/Blocks/CommonGrid/hooks/useEditReadAsColumn.js +6 -3
- package/ui/Blocks/CommonGrid/storybook/stories/complexWithPaginationAndRedux.stories.js +4 -1
- package/ui/Blocks/CommonGrid/types.d.ts +2 -1
- package/ui/Blocks/CommonGrid/utils/index.d.ts +1 -1
- package/ui/Blocks/CommonGrid/utils/index.js +9 -7
- package/ui/index.es.js +20445 -20435
- package/ui/index.umd.js +654 -654
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DropResult } from 'react-beautiful-dnd';
|
|
2
|
-
import { CommonGridProps, FiltersConfig, ColumnDefinition } from './types';
|
|
2
|
+
import type { CommonGridProps, FiltersConfig, ColumnDefinition } from './types';
|
|
3
3
|
type Props = CommonGridProps & {
|
|
4
4
|
filters?: FiltersConfig;
|
|
5
5
|
handleDragEnd: (item: DropResult) => void;
|
|
@@ -62,13 +62,12 @@ var CommonGrid = function (_a) {
|
|
|
62
62
|
var commonGridRef = React.useCallback(function (node) {
|
|
63
63
|
gridBoxRef.current = node;
|
|
64
64
|
}, []);
|
|
65
|
-
console.log(actionColumnDefinition);
|
|
66
65
|
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: [hasGroups && (_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 }), 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 &&
|
|
67
66
|
rowsData &&
|
|
68
67
|
displayColumnsDefinitions &&
|
|
69
68
|
rowsData.map(function (row, index) {
|
|
70
69
|
var rowIndex = rowsPerPage * page + (index + 1) - rowsPerPage;
|
|
71
|
-
return (_jsx(DataRow, { rowData: row, rowIndex: rowIndex, uxState: uxState, isEven: hasColouredRows && (index + 1) % 2 === 0, allowRowSelect: allowRowSelect, allowRowSelectOnAction: allowRowSelectOnAction, onRowAction: onRowAction, onUxChange: handleUxChange, onRowClick: onRowClick, columns: displayColumnsDefinitions,
|
|
70
|
+
return (_jsx(DataRow, { rowData: row, rowIndex: rowIndex, uxState: uxState, isEven: hasColouredRows && (index + 1) % 2 === 0, allowRowSelect: allowRowSelect, allowRowSelectOnAction: allowRowSelectOnAction, onRowAction: onRowAction, onUxChange: handleUxChange, onRowClick: onRowClick, columns: displayColumnsDefinitions, displayColumnsWidth: displayColumnsWidth, groups: groups }, row.id));
|
|
72
71
|
}) })] }) }), floatingButtonProps && _jsx(FloatingButton, __assign({}, floatingButtonProps))] }));
|
|
73
72
|
};
|
|
74
73
|
export default CommonGrid;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ColumnDefinition, GridActionsType, FiltersConfig, CustomComparators, Group } from '../types';
|
|
1
|
+
import type { ColumnDefinition, GridActionsType, FiltersConfig, CustomComparators, Group, ActionColumn, UxState, RowProps } from '../types';
|
|
2
2
|
type Props = {
|
|
3
3
|
onChange: Required<GridActionsType>['addFilter'];
|
|
4
4
|
value?: any;
|
|
@@ -8,6 +8,10 @@ type Props = {
|
|
|
8
8
|
filters?: FiltersConfig;
|
|
9
9
|
group?: Group;
|
|
10
10
|
comparators?: CustomComparators;
|
|
11
|
+
actionColumn?: ActionColumn;
|
|
12
|
+
rowsData: RowProps[];
|
|
13
|
+
uxState: UxState;
|
|
14
|
+
handleUxChange: GridActionsType['handleUxChange'];
|
|
11
15
|
};
|
|
12
|
-
declare const ColumnFilterCell: ({ onChange, value, others, displayColumnWidth, filters, column: columnDefinition, group, comparators }: Props) => JSX.Element;
|
|
16
|
+
declare const ColumnFilterCell: ({ onChange, value, others, displayColumnWidth, filters, column: columnDefinition, group, comparators, actionColumn, rowsData, uxState, handleUxChange }: Props) => JSX.Element;
|
|
13
17
|
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;
|
|
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;
|
|
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 }, 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({ "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 }))) }) })));
|
|
39
39
|
};
|
|
40
40
|
export default ColumnFilterCell;
|
|
@@ -6,6 +6,7 @@ type DataCellPros = {
|
|
|
6
6
|
onRowAction?: (id: string, field: string, value: any, rowData?: RowProps) => void;
|
|
7
7
|
displayColumnWidth: number;
|
|
8
8
|
group: Group;
|
|
9
|
+
rowIndex: number;
|
|
9
10
|
};
|
|
10
11
|
declare const MemoDataCell: React.NamedExoticComponent<DataCellPros>;
|
|
11
12
|
export default MemoDataCell;
|
|
@@ -15,14 +15,14 @@ import get from 'lodash/fp/get';
|
|
|
15
15
|
import { TextCell } from './Table';
|
|
16
16
|
import { getCellSizeProps, getGroupClassNames, getStickyCollClassNames } from '../utils';
|
|
17
17
|
var DataCell = function (_a) {
|
|
18
|
-
var column = _a.column, group = _a.group, rowData = _a.rowData, onRowAction = _a.onRowAction, displayColumnWidth = _a.displayColumnWidth;
|
|
18
|
+
var column = _a.column, group = _a.group, rowData = _a.rowData, onRowAction = _a.onRowAction, displayColumnWidth = _a.displayColumnWidth, rowIndex = _a.rowIndex;
|
|
19
19
|
var Wrapper = column.fixedSize ? 'div' : TextCell;
|
|
20
20
|
var wrapperBaseProps = column.fixedSize
|
|
21
21
|
? { style: __assign(__assign({}, getCellSizeProps(column, displayColumnWidth)), { alignSelf: 'center' }) }
|
|
22
22
|
: getCellSizeProps(column, displayColumnWidth);
|
|
23
23
|
var cellClassName = "cell".concat(getStickyCollClassNames(!!column.sticky, column.stickTo), " ").concat(getGroupClassNames(group));
|
|
24
24
|
if (column.cellComponent) {
|
|
25
|
-
return (_jsx(Wrapper, __assign({ className: cellClassName }, wrapperBaseProps, { children: _jsx(column.cellComponent, { rowData: rowData, onRowAction: onRowAction, column: column }) })));
|
|
25
|
+
return (_jsx(Wrapper, __assign({ className: cellClassName }, wrapperBaseProps, { children: _jsx(column.cellComponent, { rowData: rowData, onRowAction: onRowAction, column: column, rowIndex: rowIndex }) })));
|
|
26
26
|
}
|
|
27
27
|
else {
|
|
28
28
|
return (_jsx(Wrapper, __assign({ className: cellClassName }, wrapperBaseProps, { children: column.formatRowValue ? column.formatRowValue(rowData) : get(column.name, rowData) })));
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { ColumnDefinition,
|
|
1
|
+
import type { ColumnDefinition, RowProps, UxState, GridSelectorsType, Group } from '../types';
|
|
2
2
|
type DataRowProps = {
|
|
3
3
|
columns: ColumnDefinition[];
|
|
4
|
-
actionColumn?: ActionColumn;
|
|
5
4
|
rowData: RowProps;
|
|
6
5
|
rowIndex: number;
|
|
7
6
|
uxState: UxState;
|
|
@@ -15,5 +14,5 @@ type DataRowProps = {
|
|
|
15
14
|
groups: Group[];
|
|
16
15
|
isEven?: boolean;
|
|
17
16
|
};
|
|
18
|
-
declare const DataRow: ({ columns,
|
|
17
|
+
declare const DataRow: ({ columns, rowData, rowIndex, uxState, allowRowSelect, allowRowSelectOnAction, onUxChange, onRowClick, onRowAction, displayColumnsWidth, groups, isEven }: DataRowProps) => JSX.Element;
|
|
19
18
|
export default DataRow;
|
|
@@ -1,25 +1,12 @@
|
|
|
1
|
-
|
|
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 { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
2
|
import React from 'react';
|
|
14
3
|
import { rowClassSymbol } from '../types';
|
|
15
|
-
import { getActionCellSizeProps } from '../utils';
|
|
16
|
-
import { x } from '@xstyled/styled-components';
|
|
17
4
|
import MemoDataCell from './DataCell';
|
|
18
|
-
import {
|
|
5
|
+
import { StyledDataRow } from './Table';
|
|
19
6
|
import { useTimeMeasurement } from './utils';
|
|
20
7
|
var DataRow = function (_a) {
|
|
21
8
|
var _b;
|
|
22
|
-
var columns = _a.columns,
|
|
9
|
+
var columns = _a.columns, rowData = _a.rowData, rowIndex = _a.rowIndex, uxState = _a.uxState, allowRowSelect = _a.allowRowSelect, allowRowSelectOnAction = _a.allowRowSelectOnAction, onUxChange = _a.onUxChange, onRowClick = _a.onRowClick, onRowAction = _a.onRowAction, displayColumnsWidth = _a.displayColumnsWidth, groups = _a.groups, isEven = _a.isEven;
|
|
23
10
|
var isChecked = !!((_b = uxState.checkedRows) === null || _b === void 0 ? void 0 : _b[rowData.id]);
|
|
24
11
|
var handleRowAction = React.useCallback(function (id, field, value, rowData) {
|
|
25
12
|
onRowAction === null || onRowAction === void 0 ? void 0 : onRowAction(id, field, value, rowData);
|
|
@@ -51,10 +38,6 @@ var DataRow = function (_a) {
|
|
|
51
38
|
return classes.join(' ');
|
|
52
39
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
53
40
|
}, [isChecked, uxState, rowData]);
|
|
54
|
-
|
|
55
|
-
var actionColumnStyle = React.useMemo(function () {
|
|
56
|
-
return actionColumn ? __assign({}, getActionCellSizeProps(actionColumn)) : {};
|
|
57
|
-
}, [actionColumn]);
|
|
58
|
-
return (_jsxs(StyledDataRow, { className: rowClassName, hasRowClick: !!onRowClick, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, isEven: !!isEven, children: [actionColumn && (_jsx(_Fragment, { children: (actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.addRowNumbers) && (_jsx(Cell, { className: "cell", style: actionColumnStyle, children: _jsx(x.div, { children: rowIndex }) })) })), columns.map(function (column, key) { return (_jsx(MemoDataCell, { column: column, rowData: rowData, onRowAction: handleRowAction, displayColumnWidth: displayColumnsWidth[column.name], group: groups === null || groups === void 0 ? void 0 : groups[key] }, column.name)); })] }));
|
|
41
|
+
return (_jsx(StyledDataRow, { className: rowClassName, hasRowClick: !!onRowClick, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, isEven: !!isEven, children: columns.map(function (column, key) { return (_jsx(MemoDataCell, { column: column, rowData: rowData, rowIndex: rowIndex, onRowAction: handleRowAction, displayColumnWidth: displayColumnsWidth[column.name], group: groups === null || groups === void 0 ? void 0 : groups[key] }, column.name)); }) }));
|
|
59
42
|
};
|
|
60
43
|
export default DataRow;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Settings, ColumnDefinition as ColumnDefinitionType, ActionColumn, GridActionsType, GridSelectorsType, Group, CustomComparators, FiltersConfig, UxState, RowProps } from '../types';
|
|
1
|
+
import type { 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;
|
|
@@ -1,36 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import React from 'react';
|
|
14
|
-
import Checkbox from '../../../Forms/Checkbox';
|
|
15
|
-
import { useToggleAllCheckbox } from '../hooks/useToggleAllCheckbox';
|
|
16
|
-
import { getActionCellSizeProps, getFilterName } from '../utils';
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { getFilterName } from '../utils';
|
|
17
3
|
import get from 'lodash/fp/get';
|
|
18
4
|
import throttle from 'lodash/throttle';
|
|
19
5
|
import ColumnFilterCell from './ColumnFilterCell';
|
|
20
|
-
import { Row
|
|
6
|
+
import { Row } from './Table';
|
|
21
7
|
var FilterRow = function (_a) {
|
|
22
|
-
var _b,
|
|
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;
|
|
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;
|
|
24
9
|
var handleOnChange = throttle(onChange, 500);
|
|
25
|
-
|
|
26
|
-
return actionColumn ? __assign({}, getActionCellSizeProps(actionColumn)) : {};
|
|
27
|
-
}, [actionColumn]);
|
|
28
|
-
var _e = useToggleAllCheckbox(rowsData, uxState, handleUxChange), allChecked = _e[0], toggleCheckbox = _e[1];
|
|
29
|
-
var displayCheckbox = ((_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
|
-
var displayRowNumberLabel = actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.addRowNumbers;
|
|
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 sticky sticky-left", 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 sticky sticky-left", style: actionColumnStyle })), columns
|
|
33
|
-
.filter(function (column) { return !column.sticky; })
|
|
34
|
-
.map(function (column, index) { return (_jsx(ColumnFilterCell, { column: column, 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] }, index)); }) }));
|
|
35
11
|
};
|
|
36
12
|
export default FilterRow;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import type { ActionColumn, GridActionsType, RowProps, UxState } from '../../../types';
|
|
3
|
+
type Props = {
|
|
4
|
+
actionColumn?: ActionColumn;
|
|
5
|
+
rowsData?: RowProps[];
|
|
6
|
+
uxState?: UxState;
|
|
7
|
+
handleUxChange?: GridActionsType['handleUxChange'];
|
|
8
|
+
};
|
|
9
|
+
declare const ActionFilter: FC<Props>;
|
|
10
|
+
export default ActionFilter;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Checkbox from '../../../../../Forms/Checkbox';
|
|
3
|
+
import { useToggleAllCheckbox } from '../../../hooks/useToggleAllCheckbox';
|
|
4
|
+
import { x } from '@xstyled/styled-components';
|
|
5
|
+
var ActionFilter = function (_a) {
|
|
6
|
+
var _b, _c;
|
|
7
|
+
var actionColumn = _a.actionColumn, rowsData = _a.rowsData, uxState = _a.uxState, handleUxChange = _a.handleUxChange;
|
|
8
|
+
var _d = useToggleAllCheckbox(rowsData || [], uxState || {}, handleUxChange), allChecked = _d[0], toggleCheckbox = _d[1];
|
|
9
|
+
var displayRowNumberLabel = actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.addRowNumbers;
|
|
10
|
+
var rowsNumberLabel = (_b = actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.addRowNumbersLabel) !== null && _b !== void 0 ? _b : '#';
|
|
11
|
+
var displayCheckbox = ((_c = actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.actionOptions) === null || _c === void 0 ? void 0 : _c.length) || (actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.forceCheckboxes);
|
|
12
|
+
return (_jsxs(x.div, { display: "flex", alignItems: "center", justifyContent: "space-between", gap: "16px", children: [displayCheckbox && (_jsx(x.div, { pl: "8px", children: _jsx(Checkbox, { checked: allChecked, onChange: toggleCheckbox, label: "" }, "check-all") })), displayRowNumberLabel && _jsx(x.div, { pr: "8px", children: rowsNumberLabel })] }));
|
|
13
|
+
};
|
|
14
|
+
export default ActionFilter;
|
|
@@ -3,6 +3,8 @@ import type { DataCellProps, ActionColumn, UxState, GridActionsType } from '../.
|
|
|
3
3
|
type Props = DataCellProps<{
|
|
4
4
|
id: string;
|
|
5
5
|
}> & {
|
|
6
|
+
addRowNumbers?: boolean;
|
|
7
|
+
rowIndex?: number;
|
|
6
8
|
actionColumnDefinition?: ActionColumn;
|
|
7
9
|
uxState?: UxState;
|
|
8
10
|
onUxChange?: GridActionsType['handleUxChange'];
|
|
@@ -16,10 +16,9 @@ import { x } from '@xstyled/styled-components';
|
|
|
16
16
|
import { isFunction } from 'lodash/fp';
|
|
17
17
|
import { IconButtonInCell } from './IconButtonInCell';
|
|
18
18
|
export var RowActionsCell = function (_a) {
|
|
19
|
-
var actionColumnDefinition = _a.actionColumnDefinition, rowData = _a.rowData, uxState = _a.uxState, withCheckboxes = _a.withCheckboxes, onUxChange = _a.onUxChange, onRowAction = _a.onRowAction;
|
|
19
|
+
var actionColumnDefinition = _a.actionColumnDefinition, rowData = _a.rowData, addRowNumbers = _a.addRowNumbers, rowIndex = _a.rowIndex, uxState = _a.uxState, withCheckboxes = _a.withCheckboxes, onUxChange = _a.onUxChange, onRowAction = _a.onRowAction;
|
|
20
20
|
var rowDataId = rowData === null || rowData === void 0 ? void 0 : rowData.id;
|
|
21
21
|
// @TODO this should be in parent component
|
|
22
|
-
console.log('uxState', uxState);
|
|
23
22
|
var checkedRows = uxState === null || uxState === void 0 ? void 0 : uxState.checkedRows;
|
|
24
23
|
var canEdit = isFunction(actionColumnDefinition === null || actionColumnDefinition === void 0 ? void 0 : actionColumnDefinition.canRowEdit)
|
|
25
24
|
? actionColumnDefinition === null || actionColumnDefinition === void 0 ? void 0 : actionColumnDefinition.canRowEdit(rowData)
|
|
@@ -54,5 +53,5 @@ export var RowActionsCell = function (_a) {
|
|
|
54
53
|
onClick();
|
|
55
54
|
}
|
|
56
55
|
}, [onClick]);
|
|
57
|
-
return (_jsxs(x.div, { w: "100%", display: "flex",
|
|
56
|
+
return (_jsxs(x.div, { w: "100%", display: "flex", gap: "16px", pl: "8px", pr: "8px", children: [withCheckboxes && (_jsx(x.div, { w: "100%", children: _jsx(Checkbox, { checked: isChecked, onChange: onCheckboxChange, label: "" }) })), addRowNumbers && (_jsx(x.div, { display: "flex", alignItems: "center", children: rowIndex })), canEdit && _jsx(IconButtonInCell, { icon: "pen", onClick: handleOnClick, linkTo: linkTo }, "edit"), !canEdit && canRead && _jsx(IconButtonInCell, { icon: "chevronRight", onClick: handleOnClick, linkTo: linkTo }, "read")] }));
|
|
58
57
|
};
|
|
@@ -14,6 +14,7 @@ import { EditReadPosition } from '../types';
|
|
|
14
14
|
var useEditReadAsColumn = function (props) {
|
|
15
15
|
var _a;
|
|
16
16
|
var onRowAction = props.onRowAction, actionColumnDefinition = props.actionColumnDefinition, columnsDefinitions = props.columnsDefinitions, gridSelectors = props.gridSelectors, gridActions = props.gridActions, onRowEditClick = props.onRowEditClick, onRowReadClick = props.onRowReadClick;
|
|
17
|
+
// @TODO delete this but check actionOptions before
|
|
17
18
|
var modifiedActionColumnDefinition = useMemo(function () {
|
|
18
19
|
var _a;
|
|
19
20
|
if ((actionColumnDefinition === null || actionColumnDefinition === void 0 ? void 0 : actionColumnDefinition.forceCheckboxes) || ((_a = actionColumnDefinition === null || actionColumnDefinition === void 0 ? void 0 : actionColumnDefinition.actionOptions) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
@@ -42,8 +43,8 @@ var useEditReadAsColumn = function (props) {
|
|
|
42
43
|
return onRowAction(id, field, value, rowData);
|
|
43
44
|
}
|
|
44
45
|
}, [onRowAction, onRowEditClick, onRowReadClick]);
|
|
45
|
-
var canRowEdit =
|
|
46
|
-
var canRowRead =
|
|
46
|
+
var canRowEdit = actionColumnDefinition === null || actionColumnDefinition === void 0 ? void 0 : actionColumnDefinition.canRowEdit;
|
|
47
|
+
var canRowRead = actionColumnDefinition === null || actionColumnDefinition === void 0 ? void 0 : actionColumnDefinition.canRowRead;
|
|
47
48
|
var stickTo = (actionColumnDefinition === null || actionColumnDefinition === void 0 ? void 0 : actionColumnDefinition.stickTo) || 'left';
|
|
48
49
|
var flexBasis = (actionColumnDefinition === null || actionColumnDefinition === void 0 ? void 0 : actionColumnDefinition.flexBasis) || 88;
|
|
49
50
|
var withCheckboxes = !!((_a = actionColumnDefinition === null || actionColumnDefinition === void 0 ? void 0 : actionColumnDefinition.actionOptions) === null || _a === void 0 ? void 0 : _a.length) || (actionColumnDefinition === null || actionColumnDefinition === void 0 ? void 0 : actionColumnDefinition.forceCheckboxes);
|
|
@@ -52,7 +53,8 @@ var useEditReadAsColumn = function (props) {
|
|
|
52
53
|
var editReadColumnDefinition = {
|
|
53
54
|
name: 'sticky',
|
|
54
55
|
flexBasis: flexBasis,
|
|
55
|
-
filtering:
|
|
56
|
+
filtering: withCheckboxes,
|
|
57
|
+
filteringType: 'actions',
|
|
56
58
|
sorting: false,
|
|
57
59
|
sticky: true,
|
|
58
60
|
stickTo: stickTo,
|
|
@@ -60,6 +62,7 @@ var useEditReadAsColumn = function (props) {
|
|
|
60
62
|
cellComponent: withProps({
|
|
61
63
|
actionColumnDefinition: actionColumnDefinition,
|
|
62
64
|
withCheckboxes: withCheckboxes,
|
|
65
|
+
addRowNumbers: actionColumnDefinition === null || actionColumnDefinition === void 0 ? void 0 : actionColumnDefinition.addRowNumbers,
|
|
63
66
|
uxState: gridSelectors === null || gridSelectors === void 0 ? void 0 : gridSelectors.uxState,
|
|
64
67
|
onUxChange: gridActions === null || gridActions === void 0 ? void 0 : gridActions.handleUxChange
|
|
65
68
|
})(RowActionsCell)
|
|
@@ -10,7 +10,10 @@ import { ReduxGrid, createRandomData, enumValues, gridDummyActions } from '../ut
|
|
|
10
10
|
import withRedux from '../utils/withRedux';
|
|
11
11
|
var ActionColumnButtons = {
|
|
12
12
|
flexBasis: 80,
|
|
13
|
-
forceCheckboxes: true
|
|
13
|
+
forceCheckboxes: true,
|
|
14
|
+
addRowNumbers: true,
|
|
15
|
+
canRowEdit: false,
|
|
16
|
+
canRowRead: false
|
|
14
17
|
};
|
|
15
18
|
var FilterSetter = function (_a) {
|
|
16
19
|
var gridActions = _a.gridActions;
|
|
@@ -106,7 +106,7 @@ export type ColumnDefinition<ColumnName extends string = string> = ColumnBasePro
|
|
|
106
106
|
systemFilter?: string;
|
|
107
107
|
title?: string | JSX.Element;
|
|
108
108
|
filtering?: boolean;
|
|
109
|
-
filteringType?: 'number' | 'text' | 'date' | 'flag' | 'options';
|
|
109
|
+
filteringType?: 'number' | 'text' | 'date' | 'flag' | 'options' | 'actions';
|
|
110
110
|
disableRowTouch?: boolean;
|
|
111
111
|
filterExtraProps?: {
|
|
112
112
|
isMulti?: boolean;
|
|
@@ -164,6 +164,7 @@ export type DataCellProps<T> = {
|
|
|
164
164
|
onRowAction?: (id: string, field: string, value: any, rowData?: T) => void | Promise<any>;
|
|
165
165
|
column: ColumnDefinition;
|
|
166
166
|
children?: React.ReactNode;
|
|
167
|
+
rowIndex: number;
|
|
167
168
|
};
|
|
168
169
|
type SingleColumnConfig = {
|
|
169
170
|
isHidden?: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColumnDefinition, ActionColumn, ColumnConfig, FilterProps, Group, StickTo, FiltersConfig } from '../types';
|
|
1
|
+
import type { ColumnDefinition, ActionColumn, ColumnConfig, FilterProps, Group, StickTo, FiltersConfig } from '../types';
|
|
2
2
|
export declare const getActionCellSizeProps: (column: ActionColumn) => object;
|
|
3
3
|
export declare const getCellSizeProps: (column: ColumnDefinition, columnWidth: number) => object;
|
|
4
4
|
export declare const getSortName: (column: ColumnDefinition) => string;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import TextRange from '../components/Filters/TextRange';
|
|
3
|
-
import DatePickerRange from '../components/Filters/DatePickerRange';
|
|
1
|
+
import ActionsFilter from '../components/Filters/ActionsFilter';
|
|
4
2
|
import BooleanSelect from '../components/Filters/BooleanSelect';
|
|
3
|
+
import DatePickerRange from '../components/Filters/DatePickerRange';
|
|
5
4
|
import GridSelect from '../components/Filters/GridSelect';
|
|
5
|
+
import NumberRange from '../components/Filters/NumberRange';
|
|
6
|
+
import TextRange from '../components/Filters/TextRange';
|
|
6
7
|
var isDefined = function (val) { return typeof val !== 'undefined'; };
|
|
7
8
|
export var getActionCellSizeProps = function (column) {
|
|
8
9
|
return {
|
|
9
10
|
flexBasis: column.flexBasis,
|
|
10
11
|
flexGrow: 0,
|
|
11
|
-
flexShrink: 0
|
|
12
|
+
flexShrink: 0
|
|
12
13
|
};
|
|
13
14
|
};
|
|
14
15
|
export var getCellSizeProps = function (column, columnWidth) {
|
|
@@ -19,7 +20,7 @@ export var getCellSizeProps = function (column, columnWidth) {
|
|
|
19
20
|
flexBasis: columnWidth,
|
|
20
21
|
flexGrow: fixedSize ? 0 : isDefined(flexGrow) ? flexGrow : 1,
|
|
21
22
|
flexShrink: isDefined(flexShrink) ? flexShrink : 1,
|
|
22
|
-
maxWidth: sticky ? columnWidth : 'auto'
|
|
23
|
+
maxWidth: sticky ? columnWidth : 'auto'
|
|
23
24
|
};
|
|
24
25
|
};
|
|
25
26
|
export var getSortName = function (column) {
|
|
@@ -42,7 +43,7 @@ export var isColumnOn = function (column, columnConfig) {
|
|
|
42
43
|
};
|
|
43
44
|
export var calculatePaginator = function (page, rowsPerPage) { return ({
|
|
44
45
|
offset: rowsPerPage ? rowsPerPage * (page - 1) : rowsPerPage,
|
|
45
|
-
limit: rowsPerPage
|
|
46
|
+
limit: rowsPerPage
|
|
46
47
|
}); };
|
|
47
48
|
export var createFilterType = function (columnDefinition) {
|
|
48
49
|
if (columnDefinition.filterOptions)
|
|
@@ -56,7 +57,7 @@ export var getGroups = function (columns) {
|
|
|
56
57
|
return {
|
|
57
58
|
name: column.group,
|
|
58
59
|
start: !!(column.group && (!previousGroup || (previousGroup && previousGroup !== column.group))),
|
|
59
|
-
end: !!(column.group && (!columns[key + 1] || columns[key + 1].group !== column.group))
|
|
60
|
+
end: !!(column.group && (!columns[key + 1] || columns[key + 1].group !== column.group))
|
|
60
61
|
};
|
|
61
62
|
});
|
|
62
63
|
};
|
|
@@ -73,6 +74,7 @@ export var getFilters = function (optimizeFilters) {
|
|
|
73
74
|
date: { CellComponent: DatePickerRange },
|
|
74
75
|
flag: { CellComponent: BooleanSelect },
|
|
75
76
|
options: { CellComponent: GridSelect },
|
|
77
|
+
actions: { CellComponent: ActionsFilter }
|
|
76
78
|
};
|
|
77
79
|
if (optimizeFilters) {
|
|
78
80
|
filters.text.defaultExtraProps = { defaultComparator: 'eq' };
|