@mailstep/design-system 0.7.60 → 0.7.61-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/components/DataRow.js +5 -1
- package/ui/Blocks/CommonGrid/components/gridCells/EnumInCell.d.ts +1 -1
- package/ui/Blocks/CommonGrid/components/gridCells/EnumInCell.js +2 -2
- package/ui/Blocks/CommonGrid/storybook/components/ComplexCell.d.ts +4 -0
- package/ui/Blocks/CommonGrid/storybook/components/ComplexCell.js +13 -0
- package/ui/Blocks/CommonGrid/storybook/components/EnumCellExample.d.ts +6 -0
- package/ui/Blocks/CommonGrid/storybook/components/EnumCellExample.js +16 -0
- package/ui/Blocks/CommonGrid/storybook/stories/complexWithPaginationAndRedux.stories.js +2 -2
- package/ui/Blocks/CommonGrid/storybook/utils/actions.d.ts +1 -0
- package/ui/Blocks/CommonGrid/storybook/utils/actions.js +1 -0
- package/ui/Blocks/CommonGrid/storybook/utils/columnDefinition.d.ts +1 -2
- package/ui/Blocks/CommonGrid/storybook/utils/columnDefinition.js +6 -13
- package/ui/index.es.js +6721 -6723
- package/ui/index.umd.js +349 -349
package/package.json
CHANGED
|
@@ -15,9 +15,13 @@ var DataRow = function (_a) {
|
|
|
15
15
|
}
|
|
16
16
|
}, [onRowAction, allowRowSelectOnAction, onUxChange]);
|
|
17
17
|
var handleRowClick = React.useCallback(function (e) {
|
|
18
|
+
var _a;
|
|
18
19
|
// test whether I should trigger event or not (because of possible button/link/input/etc in cell)
|
|
19
20
|
var classes = Object.values(e.target.classList);
|
|
20
|
-
|
|
21
|
+
// find children of parent that has propagation attribute
|
|
22
|
+
var parent = e.target.closest('.cell');
|
|
23
|
+
var canPropagation = ((_a = parent === null || parent === void 0 ? void 0 : parent.querySelectorAll('[data-propagation="true"]')) === null || _a === void 0 ? void 0 : _a.length) > 0;
|
|
24
|
+
if (!classes.includes('dataRow') && !classes.includes('cell') && !canPropagation)
|
|
21
25
|
return;
|
|
22
26
|
if (onUxChange && allowRowSelect)
|
|
23
27
|
onUxChange('selectedRow', rowData.id);
|
|
@@ -15,8 +15,8 @@ var __assign = (this && this.__assign) || function () {
|
|
|
15
15
|
};
|
|
16
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
17
|
import { useMemo } from 'react';
|
|
18
|
-
import styled from '@xstyled/styled-components';
|
|
19
18
|
import HighlightBox from '../../../../Elements/HighlightBox';
|
|
19
|
+
import styled from '@xstyled/styled-components';
|
|
20
20
|
var Center = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n justify-content: flex-start;\n width: 100%;\n"], ["\n display: flex;\n justify-content: flex-start;\n width: 100%;\n"])));
|
|
21
21
|
export var EnumInCell = function (_a) {
|
|
22
22
|
var value = _a.value, enumObj = _a.enumObj, appearanceMap = _a.appearanceMap, size = _a.size;
|
|
@@ -28,6 +28,6 @@ export var EnumInCell = function (_a) {
|
|
|
28
28
|
}, [appearanceMap, value]);
|
|
29
29
|
if (!finalLabel)
|
|
30
30
|
return null;
|
|
31
|
-
return (_jsx(Center, { children: _jsx(HighlightBox, __assign({}, coloringProp, { size: size, prefix: "grid", children: finalLabel })) }));
|
|
31
|
+
return (_jsx(Center, { "data-propagation": "true", children: _jsx(HighlightBox, __assign({}, coloringProp, { size: size, prefix: "grid", children: finalLabel })) }));
|
|
32
32
|
};
|
|
33
33
|
var templateObject_1;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
export var ComplexCell = function (props) {
|
|
4
|
+
var handleActionClick = useCallback(function () {
|
|
5
|
+
var _a;
|
|
6
|
+
if (props.onRowAction) {
|
|
7
|
+
(_a = props.onRowAction(props.rowData.id, 'get_invoice', null)) === null || _a === void 0 ? void 0 : _a.catch(function (error) {
|
|
8
|
+
console.error(error);
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
}, [props]);
|
|
12
|
+
return _jsxs("button", { onClick: handleActionClick, children: [" download ", props.rowData.id, " "] });
|
|
13
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { EnumInCell } from '../../components/gridCells/EnumInCell';
|
|
3
|
+
var packagingTypeAppearance = {
|
|
4
|
+
'option A': 'neutralSubtle',
|
|
5
|
+
'option B': 'orangeSubtle',
|
|
6
|
+
'option C': 'greenSubtle'
|
|
7
|
+
};
|
|
8
|
+
var PackagingTypeTrans = {
|
|
9
|
+
'option A': function () { return 'option A'; },
|
|
10
|
+
'option B': function () { return 'option B'; },
|
|
11
|
+
'option C': function () { return 'option C'; }
|
|
12
|
+
};
|
|
13
|
+
export var EnumCellExample = function (_a) {
|
|
14
|
+
var rowData = _a.rowData;
|
|
15
|
+
return _jsx(EnumInCell, { value: rowData.enumColumn, enumObj: PackagingTypeTrans, appearanceMap: packagingTypeAppearance });
|
|
16
|
+
};
|
|
@@ -4,7 +4,7 @@ import { LinguiContainer } from '../../../../utils/LinguiContainer';
|
|
|
4
4
|
import withReduxActions from '../../HoC/withReduxActions';
|
|
5
5
|
import { useAddFilter } from '../../hooks/useAddFilter';
|
|
6
6
|
import { ExtraControlButtonPosition } from '../../types';
|
|
7
|
-
import { onRowEditClick, onRowReadClick, onRowAction, onBatchAction } from '../utils/actions';
|
|
7
|
+
import { onRowEditClick, onRowReadClick, onRowAction, onRowClick, onBatchAction } from '../utils/actions';
|
|
8
8
|
import { columnDefinitions, enumColumn } from '../utils/columnDefinition';
|
|
9
9
|
import { ReduxGrid, createRandomData, enumValues, gridDummyActions } from '../utils/utils';
|
|
10
10
|
import withRedux from '../utils/withRedux';
|
|
@@ -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, 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, quickFilter: "textColumn", extraControlButtons: extraControlButtons, comparators: comparators, gridName: "gridName" })] })); };
|
|
51
51
|
ComplexWithPaginationAndRedux.story = {
|
|
52
52
|
name: 'Complex, with pagination and redux'
|
|
53
53
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const onRowEditClick: (id: string, props: object) => void;
|
|
2
2
|
export declare const onRowReadClick: (id: string, props: object) => void;
|
|
3
3
|
export declare const onRowAction: (id: string, field: string, value: string | boolean) => void;
|
|
4
|
+
export declare const onRowClick: (id: string, field: string, value: string | boolean) => void;
|
|
4
5
|
export declare const onBatchAction: (action: string, affectedRows: object[]) => void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export var onRowEditClick = function (id, props) { return console.log('onRowEditClick', id, props); };
|
|
2
2
|
export var onRowReadClick = function (id, props) { return console.log('onRowReadClick', id, props); };
|
|
3
3
|
export var onRowAction = function (id, field, value) { return console.log('onRowAction', id, field, value); };
|
|
4
|
+
export var onRowClick = function (id, field, value) { return console.log('onRowClick', id, field, value); };
|
|
4
5
|
export var onBatchAction = function (action, affectedRows) {
|
|
5
6
|
console.log('onBatchAction called', action, affectedRows);
|
|
6
7
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { ColumnDefinition } from '../../types';
|
|
1
|
+
import type { ColumnDefinition } from '../../types';
|
|
2
2
|
export declare const oversizedArrayColumns = 25;
|
|
3
|
-
export declare const enumValues: string[];
|
|
4
3
|
export declare const oversizedColumnDefinition: {
|
|
5
4
|
name: string;
|
|
6
5
|
title: string;
|
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { ComplexCell } from '../components/ComplexCell';
|
|
2
|
+
import { EnumCellExample } from '../components/EnumCellExample';
|
|
3
|
+
import { enumValues } from './utils';
|
|
3
4
|
export var oversizedArrayColumns = 25;
|
|
4
|
-
export var enumValues = ['option A', 'option B', 'option C'];
|
|
5
|
-
var ComplexCell = function (props) {
|
|
6
|
-
var handleActionClick = React.useCallback(function () {
|
|
7
|
-
if (props.onRowAction)
|
|
8
|
-
props.onRowAction(props.rowData.id, 'get_invoice', null);
|
|
9
|
-
// // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
10
|
-
}, [props.rowData, props.onRowAction]);
|
|
11
|
-
return _jsxs("button", { onClick: handleActionClick, children: [" download ", props.rowData.id, " "] });
|
|
12
|
-
};
|
|
13
5
|
export var oversizedColumnDefinition = new Array(oversizedArrayColumns).fill(null).map(function (unused, index) { return ({
|
|
14
6
|
name: "column_".concat(index),
|
|
15
7
|
title: "column_".concat(index),
|
|
@@ -22,7 +14,8 @@ export var enumColumn = {
|
|
|
22
14
|
filterOptions: enumValues.map(function (v) { return ({ value: v, label: v }); }),
|
|
23
15
|
filterExtraProps: { isMulti: true, checkAllButton: true },
|
|
24
16
|
filtering: true,
|
|
25
|
-
sorting: false
|
|
17
|
+
sorting: false,
|
|
18
|
+
cellComponent: EnumCellExample
|
|
26
19
|
};
|
|
27
20
|
export var columnDefinitions = [
|
|
28
21
|
{
|
|
@@ -92,7 +85,7 @@ export var columnDefinitions = [
|
|
|
92
85
|
},
|
|
93
86
|
{
|
|
94
87
|
name: 'complexColumn',
|
|
95
|
-
title: '
|
|
88
|
+
title: 'Custom Cell Component Column1',
|
|
96
89
|
flexBasis: 350,
|
|
97
90
|
cellComponent: ComplexCell
|
|
98
91
|
},
|