@mailstep/design-system 0.6.91-beta.0.0 → 0.6.91-beta.jja.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 -2
- package/ui/Blocks/CommonGrid/CommonGridContainer.js +11 -11
- package/ui/Blocks/CommonGrid/HoC/withReduxActions.js +1 -2
- package/ui/Blocks/CommonGrid/components/ControlButtons/ControlButtons.d.ts +1 -5
- package/ui/Blocks/CommonGrid/components/ControlButtons/ControlButtons.js +6 -19
- package/ui/Blocks/CommonGrid/components/ControlButtons/styles.js +1 -1
- package/ui/Blocks/CommonGrid/components/HeadCell.d.ts +1 -1
- package/ui/Blocks/CommonGrid/components/HeadCell.js +4 -6
- package/ui/Blocks/CommonGrid/components/HeadRow.d.ts +1 -1
- package/ui/Blocks/CommonGrid/components/HeadRow.js +4 -4
- package/ui/Blocks/CommonGrid/components/ManageColumnForm/ManageColumnForm.d.ts +2 -2
- package/ui/Blocks/CommonGrid/components/ManageColumnForm/ManageColumnForm.js +4 -4
- package/ui/Blocks/CommonGrid/store/index.d.ts +1 -3
- package/ui/Blocks/CommonGrid/store/index.js +89 -89
- package/ui/Blocks/CommonGrid/storybook/stories/complexWithPaginationAndRedux.stories.js +1 -1
- package/ui/Blocks/CommonGrid/types.d.ts +0 -3
- package/ui/Elements/Tag/palletes.js +0 -3
- package/ui/Elements/Text/types.d.ts +0 -1
- package/ui/index.es.js +16183 -16526
- package/ui/index.umd.js +622 -621
- package/ui/utils/translations.js +1 -1
- package/ui/Blocks/CommonGrid/components/GridModals/index.d.ts +0 -22
- package/ui/Blocks/CommonGrid/components/GridModals/index.js +0 -27
- package/ui/Blocks/CommonGrid/components/PresetsModalBody/index.d.ts +0 -16
- package/ui/Blocks/CommonGrid/components/PresetsModalBody/index.js +0 -31
- package/ui/Blocks/CommonGrid/hooks/useCreatePreset.d.ts +0 -19
- package/ui/Blocks/CommonGrid/hooks/useCreatePreset.js +0 -52
- package/ui/Blocks/CommonGrid/hooks/useDeletePreset.d.ts +0 -17
- package/ui/Blocks/CommonGrid/hooks/useDeletePreset.js +0 -45
- package/ui/Blocks/CommonGrid/hooks/usePresetFileHandlers.d.ts +0 -13
- package/ui/Blocks/CommonGrid/hooks/usePresetFileHandlers.js +0 -68
- package/ui/Blocks/CommonGrid/hooks/usePresetsState.d.ts +0 -9
- package/ui/Blocks/CommonGrid/hooks/usePresetsState.js +0 -13
- package/ui/Blocks/CommonGrid/hooks/useSelectPreset.d.ts +0 -15
- package/ui/Blocks/CommonGrid/hooks/useSelectPreset.js +0 -47
- package/ui/Blocks/CommonGrid/utils/constants.d.ts +0 -1
- package/ui/Blocks/CommonGrid/utils/constants.js +0 -1
- package/ui/Elements/BarChartSymbol/BarChartSymbol.d.ts +0 -8
- package/ui/Elements/BarChartSymbol/BarChartSymbol.js +0 -7
- package/ui/Elements/BarChartSymbol/index.d.ts +0 -1
- package/ui/Elements/BarChartSymbol/index.js +0 -1
- package/ui/Elements/BarChartSymbol/stories/BarChartSymbol.stories.d.ts +0 -13
- package/ui/Elements/BarChartSymbol/stories/BarChartSymbol.stories.js +0 -26
- package/ui/Elements/BarChartSymbol/styles.d.ts +0 -7
- package/ui/Elements/BarChartSymbol/styles.js +0 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mailstep/design-system",
|
|
3
|
-
"version": "0.6.91-beta.
|
|
3
|
+
"version": "0.6.91-beta.jja.0",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./ui/index.js",
|
|
@@ -62,7 +62,6 @@
|
|
|
62
62
|
"babel-loader": "^9.1.3",
|
|
63
63
|
"babel-plugin-macros": "^3.1.0",
|
|
64
64
|
"babel-plugin-named-exports-order": "^0.0.2",
|
|
65
|
-
"chromatic": "^11.3.5",
|
|
66
65
|
"eslint": "^8.41.0",
|
|
67
66
|
"eslint-config-prettier": "^8.8.0",
|
|
68
67
|
"eslint-config-standard-with-typescript": "^34.0.1",
|
|
@@ -20,28 +20,29 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
20
|
}
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
23
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
24
|
import { useEffect, useMemo, useState } from 'react';
|
|
25
25
|
import { Pagination } from '../../Elements/Pagination';
|
|
26
26
|
import HidePrint from '../HidePrint/HidePrint';
|
|
27
|
+
import Modal from '../Modal';
|
|
27
28
|
import { useModal } from '../Modal/hooks/useModal';
|
|
28
29
|
import ActionHead from './components/ActionHead';
|
|
29
30
|
import ControlButtons from './components/ControlButtons';
|
|
30
|
-
import
|
|
31
|
+
import ManageColumnForm from './components/ManageColumnForm';
|
|
31
32
|
import TablePagination from './components/TablePagination';
|
|
32
33
|
import useEditReadAsColumn from './hooks/useEditReadAsColumn';
|
|
33
34
|
import useGetGridHeight from './hooks/useGetGridHeight';
|
|
34
35
|
import useManageColumn from './hooks/useManageColumn';
|
|
35
|
-
import {
|
|
36
|
+
import { Trans } from '@lingui/react';
|
|
36
37
|
import { x } from '@xstyled/styled-components';
|
|
37
38
|
import { CommonGridWithStyles, BottomWrapper, CommonGridWrap, ContentContainer, StyledButtonStrip } from './styles';
|
|
38
39
|
import { getFilters, GRID_MIN_ROWS, rowHeight } from './utils';
|
|
39
40
|
var CommonGridContainer = function (props) {
|
|
40
41
|
var _a;
|
|
41
|
-
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"]);
|
|
42
43
|
var gridActions = passDownProps.gridActions, gridSelectors = passDownProps.gridSelectors, rowsData = passDownProps.rowsData, actionColumnDefinition = passDownProps.actionColumnDefinition;
|
|
43
|
-
var
|
|
44
|
-
var
|
|
44
|
+
var _d = useState(false), displayManageColumnButton = _d[0], setDisplayManageColumnButton = _d[1];
|
|
45
|
+
var _e = useGetGridHeight(), gridHeight = _e.gridHeight, gridRef = _e.gridRef, paginationRef = _e.paginationRef;
|
|
45
46
|
useEffect(function () {
|
|
46
47
|
var _a;
|
|
47
48
|
if (!queryRowsParam && gridHeight && gridHeight > 0) {
|
|
@@ -55,14 +56,13 @@ var CommonGridContainer = function (props) {
|
|
|
55
56
|
var modifiedPassDownProps = useEditReadAsColumn(passDownProps);
|
|
56
57
|
var filters = useMemo(function () { return getFilters(optimizeFilters); }, [optimizeFilters]);
|
|
57
58
|
var columns = modifiedPassDownProps.columnsDefinitions;
|
|
58
|
-
var
|
|
59
|
-
var
|
|
59
|
+
var _f = useModal(), openManageColumnForm = _f.onOpen, manageColumnFormVisible = _f.isOpen, onClose = _f.onClose;
|
|
60
|
+
var _g = useManageColumn({
|
|
60
61
|
columns: columns,
|
|
61
62
|
gridActions: gridActions,
|
|
62
63
|
gridSelectors: gridSelectors,
|
|
63
64
|
onClose: onClose
|
|
64
|
-
}), columnsConfigValues =
|
|
65
|
-
|
|
66
|
-
return (_jsxs(_Fragment, { children: [_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, onOpenPresetsModal: onOpenPresetsModal, selectedPresetName: selectedPresetName, withPresets: withPresets, gridName: gridName }) }) }), _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 })] })] }) })] }), _jsx(GridModals, { manageColumnFormVisible: manageColumnFormVisible, onCloseForm: onCloseForm, resetColumnConfig: resetColumnConfig, onConfirmForm: onConfirmForm, manageColumnsFormDefinitions: manageColumnsFormDefinitions, columnsConfigValues: columnsConfigValues, setColumnsConfigOptions: setColumnsConfigOptions, handleDragEnd: handleDragEnd(true), gridName: gridName, gridActions: gridActions, gridSelectors: gridSelectors, onClosePresetsModal: onClosePresetsModal, isPresetsModalOpen: isPresetsModalOpen, selectedPresetName: selectedPresetName, setSelectedPresetName: setSelectedPresetName })] }));
|
|
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: 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;
|
|
@@ -23,13 +23,12 @@ var withReduxActions = function (gridName, prefix) {
|
|
|
23
23
|
setPage: actions.setPage,
|
|
24
24
|
setRowsPerPage: actions.setRowsPerPage,
|
|
25
25
|
addFilter: actions.addFilter,
|
|
26
|
-
setFilters: actions.setFilters,
|
|
27
26
|
resetFilters: actions.resetFilters,
|
|
28
27
|
addSorting: actions.addSorting,
|
|
29
28
|
clearSettings: actions.clearSettings,
|
|
30
29
|
setColumnWidth: actions.setColumnWidth,
|
|
31
30
|
resetGrid: actions.resetGrid,
|
|
32
|
-
setColumnsOrder: actions.setColumnsOrder
|
|
31
|
+
setColumnsOrder: actions.setColumnsOrder,
|
|
33
32
|
}, dispatch),
|
|
34
33
|
_a);
|
|
35
34
|
});
|
|
@@ -11,10 +11,6 @@ type Props = {
|
|
|
11
11
|
displayManageColumnButton?: boolean;
|
|
12
12
|
openManageColumnForm?: () => void;
|
|
13
13
|
setDisplayManageColumnButton: Dispatch<React.SetStateAction<boolean>>;
|
|
14
|
-
onOpenPresetsModal: () => void;
|
|
15
|
-
gridName?: string;
|
|
16
|
-
selectedPresetName: string;
|
|
17
|
-
withPresets?: boolean;
|
|
18
14
|
};
|
|
19
|
-
declare const ControlButtons: ({ extraControlButtons, gridActions, gridSelectors, quickFilter, displayColumnsDefinitions, filters, hideControlButtons, displayManageColumnButton, openManageColumnForm, setDisplayManageColumnButton
|
|
15
|
+
declare const ControlButtons: ({ extraControlButtons, gridActions, gridSelectors, quickFilter, displayColumnsDefinitions, filters, hideControlButtons, displayManageColumnButton, openManageColumnForm, setDisplayManageColumnButton }: Props) => JSX.Element;
|
|
20
16
|
export default ControlButtons;
|
|
@@ -1,21 +1,8 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
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
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
2
|
import { useEffect } from 'react';
|
|
14
3
|
import Button from '../../../../Elements/Button/Button';
|
|
15
4
|
import { Settings2 } from '../../../../Elements/Icon/icons/Settings2';
|
|
16
5
|
import { H6 } from '../../../../Elements/Typography';
|
|
17
|
-
import Tag from '../../../../Elements/Tag/Tag';
|
|
18
|
-
import { palletes } from '../../../../Elements/Tag/palletes';
|
|
19
6
|
import useQuickFilter from '../../hooks/useQuickFilter';
|
|
20
7
|
import { ExtraControlButtonPosition } from '../../types';
|
|
21
8
|
import ExtraControlButtons from '../ExtraControlButtons';
|
|
@@ -25,7 +12,7 @@ import { Trans } from '@lingui/react';
|
|
|
25
12
|
import { x } from '@xstyled/styled-components';
|
|
26
13
|
import { ControlButtonsContainer, Left, Right, StyledColumnButton } from './styles';
|
|
27
14
|
var ControlButtons = function (_a) {
|
|
28
|
-
var extraControlButtons = _a.extraControlButtons, gridActions = _a.gridActions, gridSelectors = _a.gridSelectors, _b = _a.quickFilter, quickFilter = _b === void 0 ? '' : _b, displayColumnsDefinitions = _a.displayColumnsDefinitions, filters = _a.filters, hideControlButtons = _a.hideControlButtons, displayManageColumnButton = _a.displayManageColumnButton, openManageColumnForm = _a.openManageColumnForm, setDisplayManageColumnButton = _a.setDisplayManageColumnButton
|
|
15
|
+
var extraControlButtons = _a.extraControlButtons, gridActions = _a.gridActions, gridSelectors = _a.gridSelectors, _b = _a.quickFilter, quickFilter = _b === void 0 ? '' : _b, displayColumnsDefinitions = _a.displayColumnsDefinitions, filters = _a.filters, hideControlButtons = _a.hideControlButtons, displayManageColumnButton = _a.displayManageColumnButton, openManageColumnForm = _a.openManageColumnForm, setDisplayManageColumnButton = _a.setDisplayManageColumnButton;
|
|
29
16
|
var _c = useQuickFilter({
|
|
30
17
|
gridActions: gridActions,
|
|
31
18
|
gridSelectors: gridSelectors,
|
|
@@ -37,10 +24,10 @@ var ControlButtons = function (_a) {
|
|
|
37
24
|
setDisplayManageColumnButton(!isMobileInputView);
|
|
38
25
|
}, [isMobileInputView, setDisplayManageColumnButton]);
|
|
39
26
|
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 !== ''; });
|
|
40
|
-
return (_jsxs(ControlButtonsContainer, { children: [
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
27
|
+
return (_jsxs(ControlButtonsContainer, { children: [_jsx(Left, { children: !hideControlButtons && (_jsxs(_Fragment, { children: [quickFilter && (_jsx(QuickFilter, { searchedValue: searchedValue, placeholderText: i18n._({
|
|
28
|
+
id: 'controlButtons.searchPlaceholder',
|
|
29
|
+
message: "Search ".concat(translatedValue, " ..."),
|
|
30
|
+
values: { translatedValue: translatedValue }
|
|
31
|
+
}), 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" }) })) })] })) }), _jsxs(Right, { children: [_jsx(ExtraControlButtons, { extraControlButtons: extraControlButtons, targetPosition: ExtraControlButtonPosition.TopRight }), 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" }) }) }))] })] }));
|
|
45
32
|
};
|
|
46
33
|
export default ControlButtons;
|
|
@@ -8,5 +8,5 @@ import { th } from '@xstyled/system';
|
|
|
8
8
|
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"])));
|
|
9
9
|
export var Left = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n margin-right: 10px;\n"], ["\n display: flex;\n margin-right: 10px;\n"])));
|
|
10
10
|
export var Right = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n display: flex;\n"], ["\n display: flex;\n"])));
|
|
11
|
-
export var StyledColumnButton = styled(Button)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n position: sticky;\n right: 20px;\n > span > svg {\n stroke: ", ";\n width: 18px;\n height: 18px;\n }\n > span > H6 {\n display: none;\n }\n @media (min-width: 1024px) {\n > span > H6 {\n display: flex;\n margin-left: 5px;\n }\n }\n"], ["\n position: sticky;\n right: 20px;\n > span > svg {\n stroke: ", ";\n width: 18px;\n height: 18px;\n }\n > span > H6 {\n display: none;\n }\n @media (min-width: 1024px) {\n > span > H6 {\n display: flex;\n margin-left: 5px;\n }\n }\n"])), th('colors.blue2'));
|
|
11
|
+
export var StyledColumnButton = styled(Button)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n position: sticky;\n right: 20px;\n background-color: white;\n > span > svg {\n stroke: ", ";\n width: 18px;\n height: 18px;\n }\n > span > H6 {\n display: none;\n }\n @media (min-width: 1024px) {\n > span > H6 {\n display: flex;\n margin-left: 5px;\n }\n }\n"], ["\n position: sticky;\n right: 20px;\n background-color: white;\n > span > svg {\n stroke: ", ";\n width: 18px;\n height: 18px;\n }\n > span > H6 {\n display: none;\n }\n @media (min-width: 1024px) {\n > span > H6 {\n display: flex;\n margin-left: 5px;\n }\n }\n"])), th('colors.blue2'));
|
|
12
12
|
var templateObject_1, templateObject_2, templateObject_3, templateObject_4;
|
|
@@ -23,5 +23,5 @@ type Props = {
|
|
|
23
23
|
sticky?: boolean;
|
|
24
24
|
stickTo?: StickTo;
|
|
25
25
|
};
|
|
26
|
-
declare const _default: React.MemoExoticComponent<({ title, name, isSortable, systemName, onAddSort, sortValue, hasResize, onResizeOver, onResizeOut, innerRef, isDragging, draggableProps, dragHandleProps, flexBasis, flexGrow, flexShrink, handleResizeDrag, group, sticky, stickTo }: Props) => JSX.Element>;
|
|
26
|
+
declare const _default: React.MemoExoticComponent<({ title, name, isSortable, systemName, onAddSort, sortValue, hasResize, onResizeOver, onResizeOut, innerRef, isDragging, draggableProps, dragHandleProps, flexBasis, flexGrow, flexShrink, handleResizeDrag, group, sticky, stickTo, }: Props) => JSX.Element>;
|
|
27
27
|
export default _default;
|
|
@@ -15,11 +15,11 @@ var __assign = (this && this.__assign) || function () {
|
|
|
15
15
|
};
|
|
16
16
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
17
|
import React from 'react';
|
|
18
|
-
import { getGroupClassNames, getStickyCollClassNames } from '../utils';
|
|
19
18
|
import styled from '@xstyled/styled-components';
|
|
19
|
+
import { Cell } from './Table';
|
|
20
20
|
import ColumnTitle from './ColumnTitle';
|
|
21
21
|
import Resize from './Resize';
|
|
22
|
-
import {
|
|
22
|
+
import { getGroupClassNames, getStickyCollClassNames } from '../utils';
|
|
23
23
|
var DraggableCell = styled(Cell)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n background-color: ", ";\n"], ["\n background-color: ", ";\n"])), function (_a) {
|
|
24
24
|
var $isDragging = _a.$isDragging;
|
|
25
25
|
return ($isDragging ? 'transparentRed' : 'transparent');
|
|
@@ -29,14 +29,12 @@ var HeadCell = function (_a) {
|
|
|
29
29
|
var onResize = React.useCallback(function (width) {
|
|
30
30
|
handleResizeDrag === null || handleResizeDrag === void 0 ? void 0 : handleResizeDrag(name, width);
|
|
31
31
|
}, [handleResizeDrag, name]);
|
|
32
|
-
var style = React.useMemo(function () { return (__assign({}, draggableProps === null || draggableProps === void 0 ? void 0 : draggableProps.style
|
|
33
|
-
// position: 'relative', // this is needed so that resizer is visible. TODO solve in better way (adjusting width of headers and moving resizer one level up ??)
|
|
34
|
-
)); }, [draggableProps]);
|
|
32
|
+
var style = React.useMemo(function () { return (__assign({}, draggableProps === null || draggableProps === void 0 ? void 0 : draggableProps.style)); }, [draggableProps]);
|
|
35
33
|
var onSetSort = React.useCallback(function (value) {
|
|
36
34
|
onAddSort && onAddSort(systemName || name, value);
|
|
37
35
|
}, [onAddSort, systemName, name]);
|
|
38
36
|
var cellClassName = "cell".concat(getStickyCollClassNames(!!sticky, stickTo), " ").concat(getGroupClassNames(group));
|
|
39
|
-
return (_jsxs(DraggableCell, __assign({}, draggableProps, dragHandleProps, { style: style, flexBasis: flexBasis, flexGrow: flexGrow, flexShrink: flexShrink,
|
|
37
|
+
return (_jsxs(DraggableCell, __assign({}, draggableProps, dragHandleProps, { style: style, flexBasis: flexBasis, flexGrow: flexGrow, flexShrink: flexShrink, innerRef: innerRef, "$isDragging": isDragging, className: cellClassName, children: [_jsx(ColumnTitle, { title: title, isSortable: isSortable, onSetSort: onSetSort, sortValue: sortValue }), hasResize && onResizeOut && onResizeOver && (_jsx(Resize, { onResize: onResize, onResizeOver: onResizeOver, onResizeOut: onResizeOut }))] })));
|
|
40
38
|
};
|
|
41
39
|
export default React.memo(HeadCell);
|
|
42
40
|
var templateObject_1;
|
|
@@ -11,5 +11,5 @@ type HeadRowProps = {
|
|
|
11
11
|
handleDragEnd: (item: DropResult) => void;
|
|
12
12
|
groups: Group[];
|
|
13
13
|
};
|
|
14
|
-
declare const HeadRow: ({ columns, actionColumn, onAddSort, handleDragEnd, sortingValues, displayColumnsWidth, columnLayout, handleResizeDrag, groups }: HeadRowProps) => JSX.Element;
|
|
14
|
+
declare const HeadRow: ({ columns, actionColumn, onAddSort, handleDragEnd, sortingValues, displayColumnsWidth, columnLayout, handleResizeDrag, groups, }: HeadRowProps) => JSX.Element;
|
|
15
15
|
export default HeadRow;
|
|
@@ -11,10 +11,10 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import React, { useEffect, useState } from 'react';
|
|
14
|
-
import { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd';
|
|
15
|
-
import { getActionCellSizeProps, getCellSizeProps, getSortName } from '../utils';
|
|
16
|
-
import HeadCell from './HeadCell';
|
|
14
|
+
import { DragDropContext, Droppable, Draggable, } from 'react-beautiful-dnd';
|
|
17
15
|
import { Row, Cell } from './Table';
|
|
16
|
+
import HeadCell from './HeadCell';
|
|
17
|
+
import { getActionCellSizeProps, getCellSizeProps, getSortName } from '../utils';
|
|
18
18
|
var getStickyComponent = function (columns, stickyTo, displayColumnsWidth) {
|
|
19
19
|
var _a;
|
|
20
20
|
return (_a = columns === null || columns === void 0 ? void 0 : columns.filter(function (item) { return item.sticky && item.stickTo === stickyTo; })) === null || _a === void 0 ? void 0 : _a.map(function (column) { return (_jsx(HeadCell, __assign({ name: column.name, systemName: column.systemName, isSortable: false, hasResize: false, isDragging: false, sortValue: null }, getCellSizeProps(column, displayColumnsWidth[column.name]), { title: column.title, sticky: column.sticky, stickTo: column.stickTo }), column.name)); });
|
|
@@ -34,7 +34,7 @@ var HeadRow = function (_a) {
|
|
|
34
34
|
setIsDragDisabled(false);
|
|
35
35
|
}, [setIsDragDisabled]);
|
|
36
36
|
var displayReadEditCell = ((_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.canRowEdit) || (actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.canRowRead) || (actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.forceCheckboxes);
|
|
37
|
-
return (_jsx(_Fragment, { children: showUIElements && (_jsx(DragDropContext, { onDragEnd: handleDragEnd, children: _jsx(Droppable, { droppableId: "droppable", direction: "horizontal", isDropDisabled: isDragDisabled,
|
|
37
|
+
return (_jsx(_Fragment, { children: showUIElements && (_jsx(DragDropContext, { onDragEnd: handleDragEnd, children: _jsx(Droppable, { droppableId: "droppable", direction: "horizontal", isDropDisabled: isDragDisabled, children: function (droppableProvided) { return (_jsxs(Row, __assign({ className: "headRow", accountForScrollbar: false, innerRef: droppableProvided.innerRef }, droppableProvided.droppableProps, { children: [actionColumn && (_jsxs(_Fragment, { children: [displayReadEditCell && (_jsx(Cell, { className: "cell", style: Object.assign(__assign({}, getActionCellSizeProps(actionColumn))) })), (actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.addRowNumbers) && (_jsx(Cell, { className: "cell", style: Object.assign(__assign({}, getActionCellSizeProps(actionColumn))) }))] })), getStickyComponent(columns, 'left', displayColumnsWidth), columns
|
|
38
38
|
.filter(function (item) { return !item.sticky; })
|
|
39
39
|
.map(function (column, key) { return (_jsx(Draggable, { draggableId: column.name, index: key, isDragDisabled: isDragDisabled || column.sticky, children: function (draggableProvided, snapshot) {
|
|
40
40
|
var _a;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { DropResult } from 'react-beautiful-dnd';
|
|
3
2
|
import { ColumnConfig, CommonGridProps } from '../../types';
|
|
3
|
+
import { DropResult } from 'react-beautiful-dnd';
|
|
4
4
|
type ManageColumnProps = {
|
|
5
5
|
columns?: CommonGridProps['columnsDefinitions'];
|
|
6
6
|
columnsConfigValues?: string[];
|
|
@@ -9,5 +9,5 @@ type ManageColumnProps = {
|
|
|
9
9
|
}>) => void;
|
|
10
10
|
handleDragEnd: (item: DropResult) => void;
|
|
11
11
|
};
|
|
12
|
-
declare const ManageColumnForm: ({ columns, columnsConfigValues, setColumnsConfigOptions, handleDragEnd }: ManageColumnProps) => JSX.Element;
|
|
12
|
+
declare const ManageColumnForm: ({ columns, columnsConfigValues, setColumnsConfigOptions, handleDragEnd, }: ManageColumnProps) => JSX.Element;
|
|
13
13
|
export default ManageColumnForm;
|
|
@@ -11,11 +11,11 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { useCallback, useState } from 'react';
|
|
14
|
-
import {
|
|
15
|
-
import { Input } from '../../../../Forms/Input/Input';
|
|
14
|
+
import { x } from '@xstyled/styled-components';
|
|
16
15
|
import { ActionRow } from './components/ActionRow';
|
|
16
|
+
import { Input } from '../../../../Forms/Input/Input';
|
|
17
17
|
import { i18n } from '@lingui/core';
|
|
18
|
-
import {
|
|
18
|
+
import { DragDropContext, Draggable, Droppable, } from 'react-beautiful-dnd';
|
|
19
19
|
var ManageColumnForm = function (_a) {
|
|
20
20
|
var columns = _a.columns, columnsConfigValues = _a.columnsConfigValues, setColumnsConfigOptions = _a.setColumnsConfigOptions, handleDragEnd = _a.handleDragEnd;
|
|
21
21
|
var _b = useState(''), searchedValue = _b[0], setSearchedValue = _b[1];
|
|
@@ -25,7 +25,7 @@ var ManageColumnForm = function (_a) {
|
|
|
25
25
|
var clear = useCallback(function () {
|
|
26
26
|
setSearchedValue('');
|
|
27
27
|
}, [setSearchedValue]);
|
|
28
|
-
return (_jsxs(x.div, { children: [_jsx(Input, { icon: "search", type: "text", value: searchedValue, placeholder: i18n._({ id: 'manageColumn.searchPlaceholder', message: 'Find column...' }), onChange: onChangeInputValue, onClear: clear, variant: "gray" }), _jsx(DragDropContext, { onDragEnd: handleDragEnd, children: _jsx(Droppable, { droppableId: "droppable", direction: "vertical",
|
|
28
|
+
return (_jsxs(x.div, { children: [_jsx(Input, { icon: "search", type: "text", value: searchedValue, placeholder: i18n._({ id: 'manageColumn.searchPlaceholder', message: 'Find column...' }), onChange: onChangeInputValue, onClear: clear, variant: "gray" }), _jsx(DragDropContext, { onDragEnd: handleDragEnd, children: _jsx(Droppable, { droppableId: "droppable", direction: "vertical", children: function (droppableProvided) { return (_jsx(x.div, __assign({ h: "400px", overflowY: "scroll", mt: "20px", ref: droppableProvided.innerRef }, droppableProvided.droppableProps, { children: columns === null || columns === void 0 ? void 0 : columns.map(function (column, index) {
|
|
29
29
|
return (_jsx(Draggable, { draggableId: column.name, index: index, isDragDisabled: !!searchedValue, children: function (draggableProvided, snapshot) { return (_jsx(ActionRow, { column: column, innerRef: draggableProvided.innerRef, columnsConfigValues: columnsConfigValues, setColumnsConfigOptions: setColumnsConfigOptions, searchedValue: searchedValue, draggableProps: draggableProvided.draggableProps, dragHandleProps: draggableProvided.dragHandleProps }, index)); } }, column.name));
|
|
30
30
|
}) }))); } }) })] }));
|
|
31
31
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FilterProps, SortingValueType, InitProps, GridState, GridSelectorsType, ColumnConfig
|
|
1
|
+
import { FilterProps, SortingValueType, InitProps, GridState, GridSelectorsType, ColumnConfig } from '../types';
|
|
2
2
|
type DefaultRootState = {};
|
|
3
3
|
export type MultiState = {
|
|
4
4
|
[key: string]: GridState;
|
|
@@ -16,7 +16,6 @@ export declare const actionTypes: {
|
|
|
16
16
|
setRowsPerPage: string;
|
|
17
17
|
resetFilters: string;
|
|
18
18
|
addFilter: string;
|
|
19
|
-
setFilters: string;
|
|
20
19
|
addSorting: string;
|
|
21
20
|
clearSettings: string;
|
|
22
21
|
resetGrid: string;
|
|
@@ -41,7 +40,6 @@ export declare const createActions: (gridName: string) => {
|
|
|
41
40
|
setRowsPerPage: (rowsPerPage: number) => Action;
|
|
42
41
|
resetFilters: () => Action;
|
|
43
42
|
addFilter: (column: string, value: any, filterProps: FilterProps) => Action;
|
|
44
|
-
setFilters: (filters: Filtering) => Action;
|
|
45
43
|
addSorting: (column: string, direction: SortingValueType) => Action;
|
|
46
44
|
clearSettings: () => Action;
|
|
47
45
|
};
|
|
@@ -10,9 +10,9 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import produce from 'immer';
|
|
13
|
-
import { createSelector } from 'reselect';
|
|
14
13
|
import getOr from 'lodash/fp/getOr';
|
|
15
14
|
import migrateState from './migrateState';
|
|
15
|
+
import { createSelector } from 'reselect';
|
|
16
16
|
export var initialState = {
|
|
17
17
|
page: 1,
|
|
18
18
|
rowsPerPage: 10,
|
|
@@ -20,13 +20,13 @@ export var initialState = {
|
|
|
20
20
|
isConfigFormOpen: false,
|
|
21
21
|
uxState: {
|
|
22
22
|
selectedRow: null,
|
|
23
|
-
checkedRows: {}
|
|
23
|
+
checkedRows: {},
|
|
24
24
|
},
|
|
25
25
|
columnConfig: {},
|
|
26
26
|
filter: {},
|
|
27
27
|
columnsWidth: {},
|
|
28
28
|
columnsOrder: [],
|
|
29
|
-
defaultSorting: []
|
|
29
|
+
defaultSorting: [],
|
|
30
30
|
};
|
|
31
31
|
export var actionPrefix = '@store/CommonGrid';
|
|
32
32
|
export var actionTypes = {
|
|
@@ -40,12 +40,11 @@ export var actionTypes = {
|
|
|
40
40
|
setRowsPerPage: "".concat(actionPrefix, "/setRowsPerPage"),
|
|
41
41
|
resetFilters: "".concat(actionPrefix, "/resetFilters"),
|
|
42
42
|
addFilter: "".concat(actionPrefix, "/addFilter"),
|
|
43
|
-
setFilters: "".concat(actionPrefix, "/setFilters"),
|
|
44
43
|
addSorting: "".concat(actionPrefix, "/addSorting"),
|
|
45
44
|
clearSettings: "".concat(actionPrefix, "/clearSettings"),
|
|
46
45
|
resetGrid: "".concat(actionPrefix, "/resetGrid"),
|
|
47
46
|
setColumnWidth: "".concat(actionPrefix, "/setColumnWidth"),
|
|
48
|
-
setColumnsOrder: "".concat(actionPrefix, "/setColumnsOrder")
|
|
47
|
+
setColumnsOrder: "".concat(actionPrefix, "/setColumnsOrder"),
|
|
49
48
|
};
|
|
50
49
|
var migrationChecked = false;
|
|
51
50
|
export default (function (state, action) {
|
|
@@ -65,81 +64,81 @@ export default (function (state, action) {
|
|
|
65
64
|
// if this grid is not yet in store, initialize
|
|
66
65
|
draft[gridName] = __assign({}, initialState);
|
|
67
66
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
67
|
+
if (action.type === actionTypes.init) {
|
|
68
|
+
var defaultSorting = action.initProps.defaultSorting;
|
|
69
|
+
draft[gridName].page = 1;
|
|
70
|
+
if (defaultSorting) {
|
|
71
|
+
draft[gridName].defaultSorting = defaultSorting;
|
|
72
|
+
draft[gridName].sorting = ((_c = draft[gridName].sorting) === null || _c === void 0 ? void 0 : _c.length) ? draft[gridName].sorting : defaultSorting;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
else if (action.type === actionTypes.clearUxState) {
|
|
76
|
+
draft[gridName].uxState = initialState.uxState;
|
|
77
|
+
}
|
|
78
|
+
else if (action.type === actionTypes.handleUxChange) {
|
|
79
|
+
// for a specific row id (action.id) append uxState from action
|
|
80
|
+
draft[gridName].uxState = __assign(__assign({}, draft[gridName].uxState), (_a = {}, _a[action.uxKey] = action.uxValue, _a));
|
|
81
|
+
}
|
|
82
|
+
else if (action.type === actionTypes.openConfigForm) {
|
|
83
|
+
draft[gridName].isConfigFormOpen = true;
|
|
84
|
+
}
|
|
85
|
+
else if (action.type === actionTypes.closeConfigForm) {
|
|
86
|
+
draft[gridName].isConfigFormOpen = false;
|
|
87
|
+
}
|
|
88
|
+
else if (action.type === actionTypes.setColumnConfig) {
|
|
89
|
+
draft[gridName].columnConfig = action.columnConfig;
|
|
90
|
+
draft[gridName].isConfigFormOpen = false;
|
|
91
|
+
}
|
|
92
|
+
else if (action.type === actionTypes.resetFilters) {
|
|
93
|
+
draft[gridName].filter = {};
|
|
94
|
+
}
|
|
95
|
+
else if (action.type === actionTypes.addFilter) {
|
|
96
|
+
// append desired filter for specific column to existing filters
|
|
97
|
+
var column = action.column, value = action.value, filterProps = action.filterProps;
|
|
98
|
+
var currentFilterState = (_b = {}, _b[column] = { value: value, filterProps: filterProps }, _b);
|
|
99
|
+
draft[gridName].filter = __assign(__assign({}, draft[gridName].filter), currentFilterState);
|
|
100
|
+
draft[gridName].page = 1;
|
|
101
|
+
}
|
|
102
|
+
else if (action.type === actionTypes.addSorting) {
|
|
103
|
+
// append desired sorting for specific column to existing sortings
|
|
104
|
+
var direction = action.direction;
|
|
105
|
+
var column = action.column;
|
|
106
|
+
if (((_f = (_e = (_d = draft[gridName]) === null || _d === void 0 ? void 0 : _d.defaultSorting) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.column) === column && direction === null) {
|
|
107
|
+
// default column cannot unset itself. it would be stuck on 'desc'
|
|
108
|
+
direction = 'asc';
|
|
109
|
+
}
|
|
110
|
+
var sorting = [{ column: column, direction: direction }];
|
|
111
|
+
if (direction === null) {
|
|
112
|
+
sorting = ((_g = draft[gridName]) === null || _g === void 0 ? void 0 : _g.defaultSorting) || [];
|
|
113
|
+
}
|
|
114
|
+
draft[gridName].sorting = sorting;
|
|
115
|
+
}
|
|
116
|
+
else if (action.type === actionTypes.clearSettings) {
|
|
117
|
+
// clear grid for reuse
|
|
118
|
+
draft[gridName].page = initialState.page;
|
|
119
|
+
draft[gridName].filter = initialState.filter;
|
|
120
|
+
draft[gridName].uxState = initialState.uxState;
|
|
121
|
+
}
|
|
122
|
+
else if (action.type === actionTypes.setPage) {
|
|
123
|
+
draft[gridName].page = action.page;
|
|
124
|
+
}
|
|
125
|
+
else if (action.type === actionTypes.setRowsPerPage) {
|
|
126
|
+
draft[gridName].rowsPerPage = action.rowsPerPage;
|
|
127
|
+
}
|
|
128
|
+
else if (action.type === actionTypes.resetGrid) {
|
|
129
|
+
draft[gridName] = __assign(__assign({}, initialState), { rowsPerPage: draft[gridName].rowsPerPage });
|
|
130
|
+
}
|
|
131
|
+
else if (action.type === actionTypes.setColumnWidth) {
|
|
132
|
+
if (action.columnsWidth === null) {
|
|
133
|
+
draft[gridName].columnsWidth = initialState.columnsWidth;
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
draft[gridName].columnsWidth = __assign(__assign({}, draft[gridName].columnsWidth), action.columnsWidth);
|
|
137
|
+
}
|
|
138
|
+
draft[gridName].columnsWidthVariant = action.columnLayout;
|
|
139
|
+
}
|
|
140
|
+
else if (action.type === actionTypes.setColumnsOrder) {
|
|
141
|
+
draft[gridName].columnsOrder = action.columnsOrder;
|
|
143
142
|
}
|
|
144
143
|
return draft;
|
|
145
144
|
});
|
|
@@ -151,7 +150,7 @@ export var createActions = function (gridName) { return ({
|
|
|
151
150
|
gridName: gridName,
|
|
152
151
|
type: actionTypes.handleUxChange,
|
|
153
152
|
uxKey: uxKey,
|
|
154
|
-
uxValue: uxValue
|
|
153
|
+
uxValue: uxValue,
|
|
155
154
|
}); },
|
|
156
155
|
openConfigForm: function () { return ({ gridName: gridName, type: actionTypes.openConfigForm }); },
|
|
157
156
|
closeConfigForm: function () { return ({ gridName: gridName, type: actionTypes.closeConfigForm }); },
|
|
@@ -161,13 +160,13 @@ export var createActions = function (gridName) { return ({
|
|
|
161
160
|
gridName: gridName,
|
|
162
161
|
type: actionTypes.setColumnWidth,
|
|
163
162
|
columnsWidth: columnsWidth,
|
|
164
|
-
columnLayout: columnLayout
|
|
163
|
+
columnLayout: columnLayout,
|
|
165
164
|
}); },
|
|
166
165
|
resetGrid: function () { return ({ gridName: gridName, type: actionTypes.resetGrid }); },
|
|
167
166
|
setColumnsOrder: function (columnsOrder) { return ({
|
|
168
167
|
gridName: gridName,
|
|
169
168
|
type: actionTypes.setColumnsOrder,
|
|
170
|
-
columnsOrder: columnsOrder
|
|
169
|
+
columnsOrder: columnsOrder,
|
|
171
170
|
}); },
|
|
172
171
|
setRowsPerPage: function (rowsPerPage) { return ({ gridName: gridName, type: actionTypes.setRowsPerPage, rowsPerPage: rowsPerPage }); },
|
|
173
172
|
resetFilters: function () { return ({ gridName: gridName, type: actionTypes.resetFilters }); },
|
|
@@ -176,16 +175,15 @@ export var createActions = function (gridName) { return ({
|
|
|
176
175
|
type: actionTypes.addFilter,
|
|
177
176
|
column: column,
|
|
178
177
|
value: value,
|
|
179
|
-
filterProps: filterProps
|
|
178
|
+
filterProps: filterProps,
|
|
180
179
|
}); },
|
|
181
|
-
setFilters: function (filters) { return ({ gridName: gridName, type: actionTypes.setFilters, filters: filters }); },
|
|
182
180
|
addSorting: function (column, direction) { return ({
|
|
183
181
|
gridName: gridName,
|
|
184
182
|
type: actionTypes.addSorting,
|
|
185
183
|
column: column,
|
|
186
|
-
direction: direction
|
|
184
|
+
direction: direction,
|
|
187
185
|
}); },
|
|
188
|
-
clearSettings: function () { return ({ gridName: gridName, type: actionTypes.clearSettings }); }
|
|
186
|
+
clearSettings: function () { return ({ gridName: gridName, type: actionTypes.clearSettings }); },
|
|
189
187
|
}); };
|
|
190
188
|
export var createSelectors = function (gridName) { return ({
|
|
191
189
|
getUxState: function (state) {
|
|
@@ -211,7 +209,9 @@ export var createSelectors = function (gridName) { return ({
|
|
|
211
209
|
getColumnsWidthVariant: function (state) {
|
|
212
210
|
return getOr(undefined, "commonGrid.".concat(gridName, ".columnsWidthVariant"), state);
|
|
213
211
|
},
|
|
214
|
-
getColumnsOrder: function (state) {
|
|
212
|
+
getColumnsOrder: function (state) {
|
|
213
|
+
return getOr([], "commonGrid.".concat(gridName, ".columnsOrder"), state);
|
|
214
|
+
},
|
|
215
215
|
}); };
|
|
216
216
|
export var createFullSelector = function (gridName) {
|
|
217
217
|
var selectors = createSelectors(gridName);
|
|
@@ -225,6 +225,6 @@ export var createFullSelector = function (gridName) {
|
|
|
225
225
|
sorting: sorting,
|
|
226
226
|
columnsWidth: columnsWidth,
|
|
227
227
|
columnsWidthVariant: columnsWidthVariant,
|
|
228
|
-
columnsOrder: columnsOrder
|
|
228
|
+
columnsOrder: columnsOrder,
|
|
229
229
|
}); });
|
|
230
230
|
};
|
|
@@ -41,7 +41,7 @@ export default {
|
|
|
41
41
|
title: 'Blocks/CommonGrid',
|
|
42
42
|
decorators: [withRedux]
|
|
43
43
|
};
|
|
44
|
-
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
|
|
44
|
+
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 })] })); };
|
|
45
45
|
ComplexWithPaginationAndRedux.story = {
|
|
46
46
|
name: 'Complex, with pagination and redux'
|
|
47
47
|
};
|