@mailstep/design-system 0.6.86-beta-jja.1 → 0.6.86-beta-jja.3
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 -2
- package/ui/Blocks/CommonGrid/CommonGridContainer.d.ts +2 -2
- package/ui/Blocks/CommonGrid/CommonGridContainer.js +2 -2
- package/ui/Blocks/CommonGrid/components/ControlButtons/ControlButtons.d.ts +0 -1
- package/ui/Blocks/CommonGrid/components/ControlButtons/ControlButtons.js +3 -8
- package/ui/Blocks/CommonGrid/components/ControlButtons/styles.d.ts +2 -0
- package/ui/Blocks/CommonGrid/components/ControlButtons/styles.js +8 -0
- package/ui/Blocks/CommonGrid/hooks/useEditReadAsColumn.js +19 -13
- package/ui/Blocks/CommonGrid/storybook/stories/complexWithPaginationAndRedux.stories.js +2 -1
- package/ui/Blocks/CommonGrid/types.d.ts +6 -0
- package/ui/Blocks/CommonGrid/types.js +5 -0
- package/ui/index.es.js +4036 -4031
- package/ui/index.umd.js +303 -301
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mailstep/design-system",
|
|
3
|
-
"version": "0.6.86-beta-jja.
|
|
3
|
+
"version": "0.6.86-beta-jja.3",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./ui/index.js",
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
"@babel/preset-env": "^7.22.4",
|
|
26
26
|
"@babel/preset-react": "^7.22.3",
|
|
27
27
|
"@babel/preset-typescript": "^7.23.3",
|
|
28
|
-
"@chromatic-com/storybook": "^1",
|
|
29
28
|
"@fortawesome/fontawesome-svg-core": "^6.3.0",
|
|
30
29
|
"@fortawesome/free-brands-svg-icons": "^6.1.1",
|
|
31
30
|
"@fortawesome/pro-duotone-svg-icons": "^6.0.0",
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { GridProps } from './types';
|
|
2
|
-
declare const
|
|
3
|
-
export default
|
|
2
|
+
declare const CommonGridContainer: (props: GridProps) => JSX.Element;
|
|
3
|
+
export default CommonGridContainer;
|
|
@@ -39,7 +39,7 @@ import Modal from '../Modal';
|
|
|
39
39
|
import ManageColumnForm from './components/ManageColumnForm';
|
|
40
40
|
import { Trans } from '@lingui/react';
|
|
41
41
|
import { Settings2 } from '../../Elements/Icon/icons/Settings2';
|
|
42
|
-
var
|
|
42
|
+
var CommonGridContainer = function (props) {
|
|
43
43
|
var _a = props.optimizeFilters, optimizeFilters = _a === void 0 ? false : _a, 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, passDownProps = __rest(props, ["optimizeFilters", "extraControlButtons", "onBatchAction", "processCheckedValues", "processCheckedValuesTitle", "hideControlButtons", "quickFilter", "floatingButtonProps", "queryRowsParam", "customPaginationHandler"]);
|
|
44
44
|
var gridActions = passDownProps.gridActions, gridSelectors = passDownProps.gridSelectors, rowsData = passDownProps.rowsData, actionColumnDefinition = passDownProps.actionColumnDefinition;
|
|
45
45
|
var _b = useState(false), displayManageColumnButton = _b[0], setDisplayManageColumnButton = _b[1];
|
|
@@ -64,4 +64,4 @@ var StyledCommonGrid = function (props) {
|
|
|
64
64
|
}), columnsConfigValues = _e.columnsConfigValues, setColumnsConfigOptions = _e.setColumnsConfigOptions, onConfirmForm = _e.onConfirmForm, resetColumnConfig = _e.resetColumnConfig, handleDragEnd = _e.handleDragEnd, onCloseForm = _e.onCloseForm, displayColumnsDefinitions = _e.displayColumnsDefinitions, manageColumnsFormDefinitions = _e.manageColumnsFormDefinitions;
|
|
65
65
|
return (_jsxs(ContentContainer, { children: [_jsxs(CommonGridWrap, { children: [_jsx(HidePrint, { children: _jsxs(StyledButtonStrip, { className: "buttonsStrip", children: [!hideControlButtons && (_jsx(ControlButtons, { extraControlButtons: extraControlButtons, gridActions: gridActions, gridSelectors: gridSelectors, quickFilter: quickFilter, displayColumnsDefinitions: displayColumnsDefinitions, filters: filters, setDisplayManageColumnButton: setDisplayManageColumnButton })), displayManageColumnButton && (_jsx(StyledColumnButton, { type: "button", variant: "ghost", appearance: "primary", iconLeft: _jsx(Settings2, {}), onClick: openManageColumnForm, children: _jsx(H6, { variant: "semiBold", mt: 0, mb: 0, children: _jsx(Trans, { id: "manageColumn.title", message: "Manage column" }) }) }))] }) }), _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 && (_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) }) }))] }));
|
|
66
66
|
};
|
|
67
|
-
export default
|
|
67
|
+
export default CommonGridContainer;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Dispatch } from 'react';
|
|
2
2
|
import { CommonGridProps, GridActionsType, GridSelectorsType, ColumnDefinition, FiltersConfig } from '../../types';
|
|
3
|
-
export declare const Row: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {}, never>;
|
|
4
3
|
type Props = {
|
|
5
4
|
extraControlButtons: CommonGridProps['extraControlButtons'];
|
|
6
5
|
gridActions: GridActionsType;
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
-
return cooked;
|
|
4
|
-
};
|
|
5
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
2
|
import { useEffect } from 'react';
|
|
7
3
|
import Button from '../../../../Elements/Button/Button';
|
|
@@ -11,8 +7,8 @@ import ExtraControlButtons from '../ExtraControlButtons';
|
|
|
11
7
|
import QuickFilter from '../QuickFilter';
|
|
12
8
|
import { i18n } from '@lingui/core';
|
|
13
9
|
import { Trans } from '@lingui/react';
|
|
14
|
-
import
|
|
15
|
-
|
|
10
|
+
import { x } from '@xstyled/styled-components';
|
|
11
|
+
import { ControlButtonsContainer, Left } from './styles';
|
|
16
12
|
var ControlButtons = function (_a) {
|
|
17
13
|
var extraControlButtons = _a.extraControlButtons, gridActions = _a.gridActions, gridSelectors = _a.gridSelectors, _b = _a.quickFilter, quickFilter = _b === void 0 ? '' : _b, displayColumnsDefinitions = _a.displayColumnsDefinitions, filters = _a.filters, setDisplayManageColumnButton = _a.setDisplayManageColumnButton;
|
|
18
14
|
var _c = useQuickFilter({
|
|
@@ -26,11 +22,10 @@ var ControlButtons = function (_a) {
|
|
|
26
22
|
setDisplayManageColumnButton(!isMobileInputView);
|
|
27
23
|
}, [isMobileInputView, setDisplayManageColumnButton]);
|
|
28
24
|
var filtersOn = !!filter && Object.values(filter).some(function (item) { var _a; return ((_a = item.value) === null || _a === void 0 ? void 0 : _a.value) !== '' && item.value !== ''; });
|
|
29
|
-
return (_jsxs(
|
|
25
|
+
return (_jsxs(ControlButtonsContainer, { children: [_jsxs(Left, { children: [quickFilter && (_jsx(QuickFilter, { searchedValue: searchedValue, placeholderText: i18n._({
|
|
30
26
|
id: 'controlButtons.searchPlaceholder',
|
|
31
27
|
message: "Search ".concat(translatedValue, " ..."),
|
|
32
28
|
values: { translatedValue: translatedValue }
|
|
33
29
|
}), onChange: onChangeInputValue, onClear: onClear, onClick: onDisplayInput, displayInput: displayInput, isMobileInputView: isMobileInputView, alwaysShowClear: isMobile })), _jsx(ExtraControlButtons, { extraControlButtons: extraControlButtons, targetPosition: ExtraControlButtonPosition.TopLeft }), _jsx(x.div, { children: filtersOn && (_jsx(Button, { type: "button", onClick: onResetFilters, variant: "default", appearance: "secondary", "data-cy": "resetFiltersBtn", children: _jsx(Trans, { id: "dataGrid.buttonClearSettings", message: "Reset filters" }) })) })] }), _jsx(ExtraControlButtons, { extraControlButtons: extraControlButtons, targetPosition: ExtraControlButtonPosition.TopRight })] }));
|
|
34
30
|
};
|
|
35
31
|
export default ControlButtons;
|
|
36
|
-
var templateObject_1;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
import styled from '@xstyled/styled-components';
|
|
6
|
+
export var ControlButtonsContainer = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n position: sticky;\n justify-content: space-between;\n flex: 1;\n left: 20px;\n"], ["\n display: flex;\n position: sticky;\n justify-content: space-between;\n flex: 1;\n left: 20px;\n"])));
|
|
7
|
+
export var Left = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n"], ["\n display: flex;\n"])));
|
|
8
|
+
var templateObject_1, templateObject_2;
|
|
@@ -9,6 +9,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
9
9
|
};
|
|
10
10
|
import { useCallback, useMemo } from 'react';
|
|
11
11
|
import getReadEditButtonCell from '../components/ReadEditButtonCell';
|
|
12
|
+
import { EditReadPosition } from '../types';
|
|
12
13
|
/**
|
|
13
14
|
* Because in new design we are displaying lot of the controlls differently, including read and edit buttons in grid,
|
|
14
15
|
* easiest way to make all the definition changes is to just overwrite the here once, instead of modifying every single grid (33 instances atm).
|
|
@@ -44,18 +45,23 @@ var useEditReadAsColumn = function (props) {
|
|
|
44
45
|
var CellComponent = useMemo(function () { return getReadEditButtonCell(actionColumnDefinition); }, [actionColumnDefinition]);
|
|
45
46
|
var modifiedColumnsDefinitions = useMemo(function () {
|
|
46
47
|
if ((actionColumnDefinition === null || actionColumnDefinition === void 0 ? void 0 : actionColumnDefinition.canRowEdit) !== undefined || (actionColumnDefinition === null || actionColumnDefinition === void 0 ? void 0 : actionColumnDefinition.canRowRead) !== undefined) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
48
|
+
var stickTo = actionColumnDefinition.stickTo || 'right';
|
|
49
|
+
var editReadColumnDefinition = {
|
|
50
|
+
name: 'sticky',
|
|
51
|
+
flexBasis: 88,
|
|
52
|
+
filtering: false,
|
|
53
|
+
sorting: false,
|
|
54
|
+
sticky: true,
|
|
55
|
+
stickTo: stickTo,
|
|
56
|
+
alwaysOn: true,
|
|
57
|
+
cellComponent: CellComponent
|
|
58
|
+
};
|
|
59
|
+
if (stickTo === EditReadPosition.Left) {
|
|
60
|
+
return __spreadArray([editReadColumnDefinition], columnsDefinitions, true);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
return __spreadArray(__spreadArray([], columnsDefinitions, true), [editReadColumnDefinition], false);
|
|
64
|
+
}
|
|
59
65
|
}
|
|
60
66
|
else {
|
|
61
67
|
return columnsDefinitions;
|
|
@@ -64,7 +70,7 @@ var useEditReadAsColumn = function (props) {
|
|
|
64
70
|
return {
|
|
65
71
|
columnsDefinitions: modifiedColumnsDefinitions,
|
|
66
72
|
actionColumnDefinition: modifiedActionColumnDefinition,
|
|
67
|
-
onRowAction: modifiedOnRowAction
|
|
73
|
+
onRowAction: modifiedOnRowAction
|
|
68
74
|
};
|
|
69
75
|
};
|
|
70
76
|
export default useEditReadAsColumn;
|
|
@@ -10,6 +10,7 @@ import { LinguiContainer } from '../../../../utils/LinguiContainer';
|
|
|
10
10
|
var ActionColumnButtons = {
|
|
11
11
|
flexBasis: 160,
|
|
12
12
|
canRowRead: true,
|
|
13
|
+
stickTo: 'left',
|
|
13
14
|
canRowEdit: function (row) { return row.enumColumn !== 'option C'; }
|
|
14
15
|
};
|
|
15
16
|
var FilterSetter = function (_a) {
|
|
@@ -25,7 +26,7 @@ export default {
|
|
|
25
26
|
title: 'Blocks/CommonGrid',
|
|
26
27
|
decorators: [withRedux]
|
|
27
28
|
};
|
|
28
|
-
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, confirmOnReset: function () { return window.confirm('Are you sure you want to reset grid?'); } })] })); };
|
|
29
|
+
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", confirmOnReset: function () { return window.confirm('Are you sure you want to reset grid?'); } })] })); };
|
|
29
30
|
ComplexWithPaginationAndRedux.story = {
|
|
30
31
|
name: 'Complex, with pagination and redux'
|
|
31
32
|
};
|
|
@@ -145,6 +145,7 @@ export type ActionColumn = ColumnBaseProps & {
|
|
|
145
145
|
createLink?: (params?: object) => string;
|
|
146
146
|
forceCheckboxes?: boolean;
|
|
147
147
|
checkAllPosition?: 'top' | 'bottom';
|
|
148
|
+
stickTo?: StickTo;
|
|
148
149
|
addRowNumbers?: boolean;
|
|
149
150
|
addRowNumbersLabel?: string;
|
|
150
151
|
};
|
|
@@ -265,7 +266,12 @@ export type CommonGridProps<TData extends RowProps = RowProps> = {
|
|
|
265
266
|
extraControlButtons?: ExtraControlButton[];
|
|
266
267
|
perPageOptions?: number[];
|
|
267
268
|
floatingButtonProps?: FloatingButtonProps;
|
|
269
|
+
editReadPosition?: EditReadPosition;
|
|
268
270
|
};
|
|
271
|
+
export declare enum EditReadPosition {
|
|
272
|
+
Left = "left",
|
|
273
|
+
Right = "right"
|
|
274
|
+
}
|
|
269
275
|
export declare enum ExtraControlButtonPosition {
|
|
270
276
|
TopLeft = "top-left",
|
|
271
277
|
TopRight = "top-right",
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
export var rowClassSymbol = Symbol();
|
|
2
|
+
export var EditReadPosition;
|
|
3
|
+
(function (EditReadPosition) {
|
|
4
|
+
EditReadPosition["Left"] = "left";
|
|
5
|
+
EditReadPosition["Right"] = "right";
|
|
6
|
+
})(EditReadPosition || (EditReadPosition = {}));
|
|
2
7
|
export var ExtraControlButtonPosition;
|
|
3
8
|
(function (ExtraControlButtonPosition) {
|
|
4
9
|
ExtraControlButtonPosition["TopLeft"] = "top-left";
|