@mailstep/design-system 0.8.11-beta.2 → 0.8.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/CommonGridContainer.js +10 -3
- package/ui/Blocks/CommonGrid/HoC/withReduxActions.js +1 -0
- package/ui/Blocks/CommonGrid/components/ControlButtons/ControlButtons.d.ts +3 -1
- package/ui/Blocks/CommonGrid/components/ControlButtons/ControlButtons.js +14 -7
- package/ui/Blocks/CommonGrid/components/ExtraControlButtons/ExtraControlButtons.d.ts +1 -0
- package/ui/Blocks/CommonGrid/components/ExtraControlButtons/ExtraControlButtons.js +27 -7
- package/ui/Blocks/CommonGrid/components/Filters/DatePickerRange/DatePickerRange.d.ts +1 -0
- package/ui/Blocks/CommonGrid/components/Filters/DatePickerRange/DatePickerRange.js +17 -5
- package/ui/Blocks/CommonGrid/components/GridInfo/index.js +2 -0
- package/ui/Blocks/CommonGrid/components/MobileFilterDropdown.d.ts +4 -0
- package/ui/Blocks/CommonGrid/components/MobileFilterDropdown.js +13 -0
- package/ui/Blocks/CommonGrid/components/MobileFilterModal.d.ts +20 -0
- package/ui/Blocks/CommonGrid/components/MobileFilterModal.js +69 -0
- package/ui/Blocks/CommonGrid/components/MobileSortModal.d.ts +13 -0
- package/ui/Blocks/CommonGrid/components/MobileSortModal.js +34 -0
- package/ui/Blocks/CommonGrid/components/QuickFilter/QuickFilter.d.ts +1 -1
- package/ui/Blocks/CommonGrid/components/QuickFilter/QuickFilter.js +2 -2
- package/ui/Blocks/CommonGrid/hooks/useManageColumn.js +1 -1
- package/ui/Blocks/CommonGrid/hooks/useQuickFilter.d.ts +2 -2
- package/ui/Blocks/CommonGrid/hooks/useQuickFilter.js +2 -2
- package/ui/Blocks/CommonGrid/store/index.d.ts +4 -6
- package/ui/Blocks/CommonGrid/store/index.js +9 -2
- package/ui/Blocks/CommonGrid/storybook/stories/complexWithPaginationAndRedux.stories.d.ts +18 -0
- package/ui/Blocks/CommonGrid/storybook/stories/complexWithPaginationAndRedux.stories.js +37 -9
- package/ui/Blocks/CommonGrid/storybook/utils/columnDefinition.d.ts +2 -0
- package/ui/Blocks/CommonGrid/storybook/utils/columnDefinition.js +18 -14
- package/ui/Blocks/CommonGrid/styles.d.ts +1 -0
- package/ui/Blocks/CommonGrid/styles.js +6 -3
- package/ui/Blocks/CommonGrid/types.d.ts +1 -1
- package/ui/Blocks/CommonGrid/utils/index.d.ts +2 -0
- package/ui/Blocks/CommonGrid/utils/index.js +10 -2
- package/ui/Elements/DropdownMenu/components/MenuItem.js +1 -1
- package/ui/Elements/Icon/icons/Filter.d.ts +4 -0
- package/ui/Elements/Icon/icons/Filter.js +13 -0
- package/ui/Elements/Icon/icons/Sort.d.ts +4 -0
- package/ui/Elements/Icon/icons/Sort.js +13 -0
- package/ui/Elements/Icon/icons/index.d.ts +2 -0
- package/ui/Elements/Icon/icons/index.js +2 -0
- package/ui/index.es.js +16902 -16074
- package/ui/index.umd.js +494 -454
- package/ui/utils/translations.js +1 -1
package/package.json
CHANGED
|
@@ -23,12 +23,15 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
23
23
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
24
24
|
import { useRef, useMemo, useState } from 'react';
|
|
25
25
|
import { Pagination } from '../../Elements/Pagination';
|
|
26
|
+
import { useCheckDeviceWidth } from '../../utils/CheckDeviceWidth/checkDeviceWidth';
|
|
26
27
|
import HidePrint from '../HidePrint/HidePrint';
|
|
27
28
|
import { useModal } from '../Modal/hooks/useModal';
|
|
28
29
|
import ActionHead from './components/ActionHead';
|
|
29
30
|
import ControlButtons from './components/ControlButtons';
|
|
30
31
|
import { GridInfo } from './components/GridInfo';
|
|
31
32
|
import { GridModals } from './components/GridModals';
|
|
33
|
+
import MobileFilterModal from './components/MobileFilterModal';
|
|
34
|
+
import MobileSortModal from './components/MobileSortModal';
|
|
32
35
|
import TablePagination from './components/TablePagination';
|
|
33
36
|
import useEditReadAsColumn from './hooks/useEditReadAsColumn';
|
|
34
37
|
import { useGridAutoRowsPerPage } from './hooks/useGridAutoRowsPerPage';
|
|
@@ -50,8 +53,10 @@ var CommonGridContainer = function (props) {
|
|
|
50
53
|
var withButtonStrip = !!(extendedExtraControlButtons === null || extendedExtraControlButtons === void 0 ? void 0 : extendedExtraControlButtons.length) || !hideControlButtons || !!withPresets || !!withManageColumnButton;
|
|
51
54
|
var hasGroups = !!props.columnsDefinitions.find(function (col) { return col.group; });
|
|
52
55
|
var hasFilters = !!props.columnsDefinitions.find(function (col) { return col.filtering; });
|
|
56
|
+
var hasSortableColumns = !!props.columnsDefinitions.find(function (col) { return col.sorting; });
|
|
53
57
|
var hasGroupsOrFilters = hasGroups || hasFilters;
|
|
54
58
|
var autoRowsPerPage = getRowsPerPage(gridRef, withPagination, withButtonStrip, hasGroupsOrFilters);
|
|
59
|
+
var isMobile = useCheckDeviceWidth().isMobile;
|
|
55
60
|
useGridAutoRowsPerPage({
|
|
56
61
|
autoHeight: autoHeight,
|
|
57
62
|
gridActions: gridActions,
|
|
@@ -70,10 +75,12 @@ var CommonGridContainer = function (props) {
|
|
|
70
75
|
onClose: onClose
|
|
71
76
|
}), columnsConfigValues = _j.columnsConfigValues, setColumnsConfigOptions = _j.setColumnsConfigOptions, onConfirmForm = _j.onConfirmForm, resetColumnConfig = _j.resetColumnConfig, handleDragEnd = _j.handleDragEnd, onCloseForm = _j.onCloseForm, displayColumnsDefinitions = _j.displayColumnsDefinitions, manageColumnsFormDefinitions = _j.manageColumnsFormDefinitions;
|
|
72
77
|
var _k = usePresetState(), isPresetsModalOpen = _k.isPresetsModalOpen, onClosePresetsModal = _k.onClosePresetsModal, onOpenPresetsModal = _k.onOpenPresetsModal, setSelectedPresetName = _k.setSelectedPresetName, selectedPresetName = _k.selectedPresetName;
|
|
73
|
-
var _l =
|
|
78
|
+
var _l = useModal(), isMobileFilterOpen = _l.isOpen, openMobileFilter = _l.onOpen, closeMobileFilter = _l.onClose;
|
|
79
|
+
var _m = useModal(), isMobileSortOpen = _m.isOpen, openMobileSort = _m.onOpen, closeMobileSort = _m.onClose;
|
|
80
|
+
var _o = hasSortTerminated({
|
|
74
81
|
allowSortingOnlyUnderTotalRows: allowSortingOnlyUnderTotalRows,
|
|
75
82
|
totalRowsCount: passDownProps === null || passDownProps === void 0 ? void 0 : passDownProps.totalRowsCount
|
|
76
|
-
}), isSortTerminatedAppeal =
|
|
77
|
-
return (_jsxs(_Fragment, { children: [_jsxs(ContentContainer, { ref: gridRef, children: [_jsxs(CommonGridWrap, { withPagination: withPagination, children: [withButtonStrip && (_jsx(HidePrint, { children: _jsx(StyledButtonStrip, { className: "buttonsStrip", children: _jsx(ControlButtons, { hideControlButtons: hideControlButtons, extraControlButtons: extendedExtraControlButtons, gridActions: gridActions, gridSelectors: gridSelectors, quickFilter: quickFilter,
|
|
83
|
+
}), isSortTerminatedAppeal = _o.isSortTerminatedAppeal, isSortTerminated = _o.isSortTerminated;
|
|
84
|
+
return (_jsxs(_Fragment, { children: [_jsxs(ContentContainer, { ref: gridRef, children: [_jsxs(CommonGridWrap, { withPagination: withPagination, children: [withButtonStrip && (_jsx(HidePrint, { children: _jsx(StyledButtonStrip, { className: "buttonsStrip", children: _jsx(ControlButtons, { hideControlButtons: hideControlButtons, extraControlButtons: extendedExtraControlButtons, gridActions: gridActions, gridSelectors: gridSelectors, quickFilter: quickFilter, displayColumnsDefinitions: displayColumnsDefinitions, filters: filters, setDisplayManageColumnButton: setDisplayManageColumnButton, displayManageColumnButton: displayManageColumnButton, openManageColumnForm: openManageColumnForm, onOpenPresetsModal: onOpenPresetsModal, selectedPresetName: selectedPresetName, withPresets: withPresets, gridName: gridName, withManageColumnButton: withManageColumnButton, onOpenMobileFilters: hasFilters ? openMobileFilter : undefined, onOpenMobileSorting: hasSortableColumns ? openMobileSort : undefined }) }) })), _jsx(CommonGridWithStyles, __assign({}, passDownProps, modifiedPassDownProps, { withButtonStrip: withButtonStrip, hasGroupsOrFilters: hasGroupsOrFilters, filters: filters, floatingButtonProps: floatingButtonProps, handleDragEnd: handleDragEnd(false), displayColumnsDefinitions: displayColumnsDefinitions, hasFilters: hasFilters, hasGroups: hasGroups, isSortTerminated: isSortTerminated, hasColouredRows: true }))] }), _jsxs(BottomWrapper, { withPagination: withPagination, 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, actionOptions: actionColumnDefinition === null || actionColumnDefinition === void 0 ? void 0 : actionColumnDefinition.actionOptions, processCheckedValues: processCheckedValues, processCheckedValuesTitle: processCheckedValuesTitle })), _jsxs(x.div, { display: "flex", justifyContent: "space-between", alignItems: "center", w: "100%", children: [!isMobile && _jsx(GridInfo, { isSortTerminatedAppeal: isSortTerminatedAppeal, isSortTerminated: isSortTerminated }), withPagination && (_jsxs(x.div, { display: "flex", alignItems: "center", className: "paginatorWrapper", w: "100%", justifyContent: "flex-end", gap: "16px", 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: isMobile ? 3 : 5, rate: isMobile ? 1 : 4 }), _jsx(TablePagination, { gridActions: gridActions, gridSelectors: gridSelectors, customPaginationHandler: customPaginationHandler, autoRowsPerPage: autoRowsPerPage })] }))] })] })] }), _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 }), isMobileFilterOpen && gridActions.setFilters && (_jsx(MobileFilterModal, { isShown: isMobileFilterOpen, onClose: closeMobileFilter, columns: displayColumnsDefinitions, filters: filters, comparators: passDownProps.comparators, filterValues: gridSelectors.filter, setFilters: gridActions.setFilters, rowsData: rowsData, uxState: gridSelectors.uxState || {}, handleUxChange: gridActions.handleUxChange, onAsyncLoadFilterOptions: passDownProps.onAsyncLoadFilterOptions, actionColumn: actionColumnDefinition, onClearSettings: gridActions.clearSettings })), isMobileSortOpen && gridActions.addSorting && (_jsx(MobileSortModal, { isShown: isMobileSortOpen, onClose: closeMobileSort, columns: displayColumnsDefinitions, sortingValues: gridSelectors.sorting, onAddSorting: gridActions.addSorting, onResetSorting: gridActions.resetSorting }))] }));
|
|
78
85
|
};
|
|
79
86
|
export default CommonGridContainer;
|
|
@@ -29,6 +29,7 @@ var withReduxActions = function (gridName, prefix) {
|
|
|
29
29
|
setFilters: actions.setFilters,
|
|
30
30
|
resetFilters: actions.resetFilters,
|
|
31
31
|
addSorting: actions.addSorting,
|
|
32
|
+
resetSorting: actions.resetSorting,
|
|
32
33
|
clearSettings: actions.clearSettings,
|
|
33
34
|
setColumnWidth: actions.setColumnWidth,
|
|
34
35
|
resetGrid: actions.resetGrid,
|
|
@@ -6,7 +6,7 @@ type Props = {
|
|
|
6
6
|
gridActions: GridActionsType;
|
|
7
7
|
gridSelectors: GridSelectorsType;
|
|
8
8
|
quickFilter?: CommonGridProps['quickFilter'];
|
|
9
|
-
|
|
9
|
+
displayColumnsDefinitions?: Array<ColumnDefinition<string>>;
|
|
10
10
|
filters?: FiltersConfig;
|
|
11
11
|
hideControlButtons?: boolean;
|
|
12
12
|
displayManageColumnButton?: boolean;
|
|
@@ -17,6 +17,8 @@ type Props = {
|
|
|
17
17
|
selectedPresetName: string;
|
|
18
18
|
withPresets?: boolean;
|
|
19
19
|
withManageColumnButton?: boolean;
|
|
20
|
+
onOpenMobileFilters?: () => void;
|
|
21
|
+
onOpenMobileSorting?: () => void;
|
|
20
22
|
};
|
|
21
23
|
declare const ControlButtons: FC<Props>;
|
|
22
24
|
export default ControlButtons;
|
|
@@ -12,12 +12,15 @@ var __assign = (this && this.__assign) || function () {
|
|
|
12
12
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { useEffect } from 'react';
|
|
14
14
|
import Button from '../../../../Elements/Button/Button';
|
|
15
|
+
import { Filter } from '../../../../Elements/Icon/icons/Filter';
|
|
15
16
|
import { Settings2 } from '../../../../Elements/Icon/icons/Settings2';
|
|
17
|
+
import { Sort } from '../../../../Elements/Icon/icons/Sort';
|
|
16
18
|
import Tag from '../../../../Elements/Tag/Tag';
|
|
17
19
|
import { palettes } from '../../../../Elements/Tag/palettes';
|
|
18
20
|
import { H6 } from '../../../../Elements/Typography';
|
|
19
21
|
import useQuickFilter from '../../hooks/useQuickFilter';
|
|
20
22
|
import { ExtraControlButtonPosition } from '../../types';
|
|
23
|
+
import { isFilterActive } from '../../utils';
|
|
21
24
|
import ExtraControlButtons from '../ExtraControlButtons';
|
|
22
25
|
import QuickFilter from '../QuickFilter';
|
|
23
26
|
import { i18n } from '@lingui/core';
|
|
@@ -25,22 +28,26 @@ import { Trans } from '@lingui/react';
|
|
|
25
28
|
import { x } from '@xstyled/styled-components';
|
|
26
29
|
import { ControlButtonsContainer, Left, Right, StyledColumnButton } from './styles';
|
|
27
30
|
var ControlButtons = function (_a) {
|
|
28
|
-
var
|
|
29
|
-
var
|
|
31
|
+
var _b, _c;
|
|
32
|
+
var extraControlButtons = _a.extraControlButtons, gridActions = _a.gridActions, gridSelectors = _a.gridSelectors, _d = _a.quickFilter, quickFilter = _d === void 0 ? '' : _d, displayColumnsDefinitions = _a.displayColumnsDefinitions, filters = _a.filters, hideControlButtons = _a.hideControlButtons, displayManageColumnButton = _a.displayManageColumnButton, openManageColumnForm = _a.openManageColumnForm, setDisplayManageColumnButton = _a.setDisplayManageColumnButton, onOpenPresetsModal = _a.onOpenPresetsModal, gridName = _a.gridName, selectedPresetName = _a.selectedPresetName, withPresets = _a.withPresets, withManageColumnButton = _a.withManageColumnButton, onOpenMobileFilters = _a.onOpenMobileFilters, onOpenMobileSorting = _a.onOpenMobileSorting;
|
|
33
|
+
var _e = useQuickFilter({
|
|
30
34
|
gridActions: gridActions,
|
|
31
35
|
gridSelectors: gridSelectors,
|
|
32
36
|
quickFilter: quickFilter,
|
|
33
|
-
|
|
37
|
+
displayColumnsDefinitions: displayColumnsDefinitions,
|
|
34
38
|
filters: filters
|
|
35
|
-
}), searchedValue =
|
|
39
|
+
}), searchedValue = _e.searchedValue, translatedValue = _e.translatedValue, onChangeInputValue = _e.onChangeInputValue, onClear = _e.onClear, onClearSettings = _e.onClearSettings, onDisplayInput = _e.onDisplayInput, displayInput = _e.displayInput, isMobileInputView = _e.isMobileInputView, isMobile = _e.isMobile, filter = _e.filter;
|
|
36
40
|
useEffect(function () {
|
|
37
41
|
setDisplayManageColumnButton(!isMobileInputView && !!withManageColumnButton);
|
|
38
42
|
}, [isMobileInputView, withManageColumnButton, setDisplayManageColumnButton]);
|
|
39
|
-
var
|
|
40
|
-
|
|
43
|
+
var filtersCount = filter ? Object.values(filter).filter(function (item) { return isFilterActive(item.value); }).length : 0;
|
|
44
|
+
var hasFilters = !!(displayColumnsDefinitions === null || displayColumnsDefinitions === void 0 ? void 0 : displayColumnsDefinitions.some(function (col) { return col.filtering; }));
|
|
45
|
+
var hasSortableColumns = !!(displayColumnsDefinitions === null || displayColumnsDefinitions === void 0 ? void 0 : displayColumnsDefinitions.some(function (col) { return col.sorting; }));
|
|
46
|
+
var sortCount = (_c = (_b = gridSelectors.sorting) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0;
|
|
47
|
+
return (_jsxs(ControlButtonsContainer, { children: [_jsxs(Left, { children: [!hideControlButtons && (_jsxs(_Fragment, { children: [quickFilter && !isMobile && (_jsx(QuickFilter, { searchedValue: searchedValue, placeholderText: i18n._({
|
|
41
48
|
id: 'controlButtons.searchPlaceholder',
|
|
42
49
|
message: "Search ".concat(translatedValue, " ..."),
|
|
43
50
|
values: { translatedValue: translatedValue }
|
|
44
|
-
}), onChange: onChangeInputValue, onClear: onClear, onClick: onDisplayInput, displayInput: displayInput, isMobileInputView: isMobileInputView
|
|
51
|
+
}), onChange: onChangeInputValue, onClear: onClear, onClick: onDisplayInput, displayInput: displayInput, isMobileInputView: isMobileInputView })), _jsx(ExtraControlButtons, { extraControlButtons: extraControlButtons, targetPosition: ExtraControlButtonPosition.TopLeft, isMobile: isMobile }), _jsx(x.div, { children: !!filtersCount && !isMobile && (_jsx(Button, { type: "button", onClick: onClearSettings, variant: "default", appearance: "secondary", "data-cy": "resetFiltersBtn", children: _jsx(Trans, { id: "dataGrid.buttonClearSettings", message: "Reset" }) })) })] })), isMobile && hasFilters && (_jsxs(Button, { type: "button", appearance: filtersCount ? 'primary' : 'tertiary', onClick: onOpenMobileFilters, "data-cy": "mobileFilterBtn", children: [_jsx(Filter, { fill: filtersCount ? 'white' : '#DB2B19' }), _jsxs(H6, { variant: "semiBold", mt: 0, mb: 0, ml: "6px", children: [_jsx(Trans, { id: "dataGrid.filter", message: "Filter" }), " ", filtersCount > 0 && "(".concat(filtersCount, ")")] })] })), isMobile && hasSortableColumns && (_jsx(x.div, { ml: "10px", children: _jsxs(Button, { type: "button", appearance: sortCount ? 'primary' : 'tertiary', onClick: onOpenMobileSorting, "data-cy": "mobileSortBtn", children: [_jsx(Sort, { stroke: sortCount ? 'white' : '#DB2B19' }), _jsxs(H6, { variant: "semiBold", mt: 0, mb: 0, ml: "6px", children: [_jsx(Trans, { id: "dataGrid.sort", message: "Sort" }), " ", sortCount > 0 && "(".concat(sortCount, ")")] })] }) })), withPresets && gridName && !isMobile && (_jsxs(_Fragment, { children: [_jsx(x.div, { mx: "12px", children: _jsx(Button, { onClick: onOpenPresetsModal, type: "button", variant: "default", appearance: "tertiary", children: _jsx(Trans, { id: "dataGrid.presets.title", message: "Presets" }) }) }), selectedPresetName && (_jsx(Tag, __assign({ size: "medium" }, palettes.redWhite, { children: _jsx(H6, { mt: 0, mb: 0, variant: "semiBold", children: selectedPresetName }) })))] }))] }), _jsxs(Right, { children: [_jsx(ExtraControlButtons, { extraControlButtons: extraControlButtons, targetPosition: ExtraControlButtonPosition.TopRight, isMobile: isMobile }), displayManageColumnButton && !isMobile && (_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
52
|
};
|
|
46
53
|
export default ControlButtons;
|
|
@@ -5,6 +5,7 @@ export declare const Row: import('styled-components').StyledComponent<"div", imp
|
|
|
5
5
|
type Props = {
|
|
6
6
|
extraControlButtons: CommonGridProps['extraControlButtons'];
|
|
7
7
|
targetPosition: ExtraControlButton['position'];
|
|
8
|
+
isMobile?: boolean;
|
|
8
9
|
};
|
|
9
10
|
declare const ExtraControlButtons: FC<Props>;
|
|
10
11
|
export default ExtraControlButtons;
|
|
@@ -16,6 +16,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
16
16
|
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
17
17
|
import Button from '../../../../Elements/Button/Button';
|
|
18
18
|
import DropdownSelect from '../../../../Elements/DropdownSelect';
|
|
19
|
+
import ButtonMore from '../ButtonMore/ButtonMore';
|
|
19
20
|
import styled, { x } from '@xstyled/styled-components';
|
|
20
21
|
export var Row = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n & > * {\n margin-right: 12px;\n }\n z-index: 2;\n"], ["\n display: flex;\n & > * {\n margin-right: 12px;\n }\n z-index: 2;\n"])));
|
|
21
22
|
var StyledButton = styled(Button)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: none;\n\n @media (min-width: 1024px) {\n display: block;\n }\n"], ["\n display: none;\n\n @media (min-width: 1024px) {\n display: block;\n }\n"])));
|
|
@@ -34,13 +35,32 @@ var ControlButton = function (_a) {
|
|
|
34
35
|
}
|
|
35
36
|
};
|
|
36
37
|
var ExtraControlButtons = function (_a) {
|
|
37
|
-
var extraControlButtons = _a.extraControlButtons, targetPosition = _a.targetPosition;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
var extraControlButtons = _a.extraControlButtons, targetPosition = _a.targetPosition, isMobile = _a.isMobile;
|
|
39
|
+
var buttons = (extraControlButtons || []).filter(function (_a) {
|
|
40
|
+
var position = _a.position, hide = _a.hide;
|
|
41
|
+
return position === targetPosition && !hide;
|
|
42
|
+
});
|
|
43
|
+
if (isMobile && buttons.length > 0) {
|
|
44
|
+
var items = buttons.flatMap(function (_a) {
|
|
45
|
+
var onSelect = _a.onSelect, onClick = _a.onClick, options = _a.options, label = _a.label;
|
|
46
|
+
if (options && onSelect) {
|
|
47
|
+
return options.map(function (option) { return ({
|
|
48
|
+
title: option.label,
|
|
49
|
+
onClick: function () {
|
|
50
|
+
onSelect(option.value);
|
|
51
|
+
}
|
|
52
|
+
}); });
|
|
53
|
+
}
|
|
54
|
+
if (label && onClick) {
|
|
55
|
+
return [{ title: label, onClick: onClick }];
|
|
56
|
+
}
|
|
57
|
+
return [];
|
|
58
|
+
});
|
|
59
|
+
if (items.length === 0)
|
|
60
|
+
return null;
|
|
61
|
+
return _jsx(ButtonMore, { items: items });
|
|
62
|
+
}
|
|
63
|
+
return (_jsx(Row, { children: buttons.map(function (button, idx) { return (_jsx(x.div, { children: _jsx(ControlButton, __assign({}, button)) }, idx)); }) }));
|
|
44
64
|
};
|
|
45
65
|
export default ExtraControlButtons;
|
|
46
66
|
var templateObject_1, templateObject_2;
|
|
@@ -11,6 +11,7 @@ type DatePickerRangeProps = FilterComponentProps<Date[]> & {
|
|
|
11
11
|
type DateRangeProps = DatePickerRangeProps & {
|
|
12
12
|
error?: string;
|
|
13
13
|
label?: string;
|
|
14
|
+
compact?: boolean;
|
|
14
15
|
};
|
|
15
16
|
declare const DatePickerRange: FC<DateRangeProps>;
|
|
16
17
|
export default DatePickerRange;
|
|
@@ -33,15 +33,27 @@ import { useClickOutside } from '../../../../Modal/hooks/useClickOutside';
|
|
|
33
33
|
import { getCleanValues } from './utils/getCleanValues';
|
|
34
34
|
import { pickerRangeToString } from './utils/pickerRangeToString';
|
|
35
35
|
import { i18n } from '@lingui/core';
|
|
36
|
-
import styled from '@xstyled/styled-components';
|
|
37
|
-
var RangeWrapper = styled.div(
|
|
36
|
+
import styled, { css } from '@xstyled/styled-components';
|
|
37
|
+
var RangeWrapper = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: ", ";\n flex-direction: ", ";\n margin-right: ", ";\n\n ", "\n"], ["\n display: ", ";\n flex-direction: ", ";\n margin-right: ", ";\n\n ", "\n"])), function (_a) {
|
|
38
|
+
var $compact = _a.$compact;
|
|
39
|
+
return ($compact ? 'flex' : 'inline-flex');
|
|
40
|
+
}, function (_a) {
|
|
41
|
+
var $compact = _a.$compact;
|
|
42
|
+
return ($compact ? 'column' : 'row');
|
|
43
|
+
}, function (_a) {
|
|
44
|
+
var $compact = _a.$compact;
|
|
45
|
+
return ($compact ? '0' : '20px');
|
|
46
|
+
}, function (_a) {
|
|
47
|
+
var $compact = _a.$compact;
|
|
48
|
+
return $compact && css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n .rdtPicker {\n min-width: unset;\n width: 100%;\n box-sizing: border-box;\n padding: 0.5rem 0.5rem;\n }\n .rdtPicker .rdtDays {\n min-width: unset;\n }\n .rdtPicker td {\n padding: 0 0.2rem;\n }\n "], ["\n .rdtPicker {\n min-width: unset;\n width: 100%;\n box-sizing: border-box;\n padding: 0.5rem 0.5rem;\n }\n .rdtPicker .rdtDays {\n min-width: unset;\n }\n .rdtPicker td {\n padding: 0 0.2rem;\n }\n "])));
|
|
49
|
+
});
|
|
38
50
|
var OverlayComponentDefault = function (_a) {
|
|
39
51
|
var children = _a.children;
|
|
40
52
|
return _jsx("div", { children: children });
|
|
41
53
|
};
|
|
42
54
|
var DatePickerRange = function (props) {
|
|
43
55
|
var _a, _b, _c;
|
|
44
|
-
var onChange = props.onChange, error = props.error, label = props.label, value = props.value, others = props.others, filterTime = props.filterTime, initialView = props.initialView, _d = props.OverlayComponent, OverlayComponent = _d === void 0 ? OverlayComponentDefault : _d, rest = __rest(props, ["onChange", "error", "label", "value", "others", "filterTime", "initialView", "OverlayComponent"]);
|
|
56
|
+
var onChange = props.onChange, error = props.error, label = props.label, value = props.value, others = props.others, filterTime = props.filterTime, initialView = props.initialView, compact = props.compact, _d = props.OverlayComponent, OverlayComponent = _d === void 0 ? OverlayComponentDefault : _d, rest = __rest(props, ["onChange", "error", "label", "value", "others", "filterTime", "initialView", "compact", "OverlayComponent"]);
|
|
45
57
|
var _e = useState((_a = value === null || value === void 0 ? void 0 : value[0]) !== null && _a !== void 0 ? _a : undefined), startRangeValue = _e[0], setStartRangeValue = _e[1];
|
|
46
58
|
var _f = useState((_b = value === null || value === void 0 ? void 0 : value[1]) !== null && _b !== void 0 ? _b : undefined), endRangeValue = _f[0], setEndRangeValue = _f[1];
|
|
47
59
|
var timeFormat = filterTime ? 'HH:mm' : false;
|
|
@@ -94,7 +106,7 @@ var DatePickerRange = function (props) {
|
|
|
94
106
|
// Check if the second value is not selected and the first value is the same as the initial value
|
|
95
107
|
var secondDatePickerValue = cleanValue[1] === null ? cleanValue[0] : cleanValue[1];
|
|
96
108
|
var ref = useClickOutside({ onClose: onClose });
|
|
97
|
-
return (_jsxs("div", { ref: ref, children: [_jsx(Input, { name: props.name, placeholder: placeholder, type: "text", icon: "calendar", value: pickerRangeToString(cleanValue, others), label: props.label, onFocus: openPicker, iconOnClick: openPicker, onClear: clear, error: error, readOnly: true }), _jsx(OverlayComponent, { children: _jsx(_Fragment, { children: isOpen && (_jsxs(RangeWrapper, { className: "ignore-element-for-closing-hook", children: [_jsx(DatePicker, __assign({}, rest, { timeFormat: timeFormat, value: (_c = cleanValue[0]) !== null && _c !== void 0 ? _c : '', initialViewDate: initialViewDate[0], secondValue: endRangeValue, onChange: setDateFrom, others: others === null || others === void 0 ? void 0 : others[0], onChangeOthers: handleOthersChangeFrom, icon: false, label: isOpen && i18n._({ id: 'dataGrid.filterCell.from', message: 'From' }), isValidDate: isValidDateFrom, input: false, spaceAround:
|
|
109
|
+
return (_jsxs("div", { ref: ref, children: [_jsx(Input, { name: props.name, placeholder: placeholder, type: "text", icon: "calendar", value: pickerRangeToString(cleanValue, others), label: props.label, onFocus: openPicker, iconOnClick: openPicker, onClear: clear, error: error, readOnly: true }), _jsx(OverlayComponent, { children: _jsx(_Fragment, { children: isOpen && (_jsxs(RangeWrapper, { "$compact": compact, className: "ignore-element-for-closing-hook", children: [_jsx(DatePicker, __assign({}, rest, { timeFormat: timeFormat, value: (_c = cleanValue[0]) !== null && _c !== void 0 ? _c : '', initialViewDate: initialViewDate[0], secondValue: endRangeValue, onChange: setDateFrom, others: others === null || others === void 0 ? void 0 : others[0], onChangeOthers: handleOthersChangeFrom, icon: false, label: isOpen && i18n._({ id: 'dataGrid.filterCell.from', message: 'From' }), isValidDate: isValidDateFrom, input: false, spaceAround: !compact, open: true })), _jsx(DatePicker, __assign({}, rest, { timeFormat: timeFormat, value: secondDatePickerValue, initialViewDate: initialViewDate[1], secondValue: startRangeValue, onChange: setDateTo, others: others === null || others === void 0 ? void 0 : others[1], onChangeOthers: handleOthersChangeTo, icon: false, label: isOpen && i18n._({ id: 'dataGrid.filterCell.to', message: 'To' }), isValidDate: isValidDateTo, input: false, spaceAround: !compact, open: true, isSecondDatePicker: true }))] })) }) })] }));
|
|
98
110
|
};
|
|
99
111
|
export default DatePickerRange;
|
|
100
|
-
var templateObject_1;
|
|
112
|
+
var templateObject_1, templateObject_2;
|
|
@@ -4,5 +4,7 @@ import { Trans } from '@lingui/react';
|
|
|
4
4
|
import { x } from '@xstyled/styled-components';
|
|
5
5
|
export var GridInfo = function (_a) {
|
|
6
6
|
var isSortTerminatedAppeal = _a.isSortTerminatedAppeal, isSortTerminated = _a.isSortTerminated;
|
|
7
|
+
if (!isSortTerminatedAppeal)
|
|
8
|
+
return null;
|
|
7
9
|
return (_jsxs(x.span, { ml: "8px", fontSize: "12px", display: "flex", gap: "8px", alignItems: "center", children: [isSortTerminatedAppeal && !isSortTerminated && (_jsxs(_Fragment, { children: [_jsx(Icon, { icon: "circleTriangle", size: "20px", fill: "yellow70" }), _jsx(Trans, { id: "dataGrid.sortingTerminatedAppeal", message: "Too many results, please set a filter" })] })), isSortTerminated && (_jsxs(_Fragment, { children: [_jsx(Icon, { icon: "circleTriangle", size: "20px", fill: "dangerColor" }), _jsx(Trans, { id: "dataGrid.sortingTerminated", message: "Too many results, sorting cannot be used" })] }))] }));
|
|
8
10
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
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 { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
import styled from '@xstyled/styled-components';
|
|
7
|
+
var OverlayWrapper = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: absolute;\n z-index: 10;\n top: 100%;\n left: 0;\n right: 0;\n background-color: white;\n border-radius: 4px;\n box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);\n"], ["\n position: absolute;\n z-index: 10;\n top: 100%;\n left: 0;\n right: 0;\n background-color: white;\n border-radius: 4px;\n box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);\n"])));
|
|
8
|
+
var MobileFilterDropdown = function (_a) {
|
|
9
|
+
var children = _a.children;
|
|
10
|
+
return _jsx(OverlayWrapper, { children: children });
|
|
11
|
+
};
|
|
12
|
+
export default MobileFilterDropdown;
|
|
13
|
+
var templateObject_1;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ColumnDefinition, GridActionsType, FiltersConfig, CustomComparators, ActionColumn, UxState, RowProps, GridSelectorsType } from '../types';
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
isShown: boolean;
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
columns: ColumnDefinition[];
|
|
8
|
+
actionColumn?: ActionColumn;
|
|
9
|
+
filters?: FiltersConfig;
|
|
10
|
+
comparators?: CustomComparators;
|
|
11
|
+
filterValues?: GridSelectorsType['filter'];
|
|
12
|
+
setFilters: Required<GridActionsType>['setFilters'];
|
|
13
|
+
rowsData: RowProps[];
|
|
14
|
+
uxState: UxState;
|
|
15
|
+
handleUxChange?: GridActionsType['handleUxChange'];
|
|
16
|
+
onAsyncLoadFilterOptions?: (key: string, value: string) => void;
|
|
17
|
+
onClearSettings?: () => void;
|
|
18
|
+
};
|
|
19
|
+
declare const MobileFilterModal: FC<Props>;
|
|
20
|
+
export default MobileFilterModal;
|
|
@@ -0,0 +1,69 @@
|
|
|
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
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
14
|
+
import { H6 } from '../../../Elements/Typography';
|
|
15
|
+
import { Modal } from '../../Modal/Modal';
|
|
16
|
+
import { createFilterType, getFilterName, isFilterActive } from '../utils';
|
|
17
|
+
import { Trans } from '@lingui/react';
|
|
18
|
+
import { x } from '@xstyled/styled-components';
|
|
19
|
+
import get from 'lodash/fp/get';
|
|
20
|
+
import OverlayComponent from './MobileFilterDropdown';
|
|
21
|
+
var MobileFilterModal = function (_a) {
|
|
22
|
+
var isShown = _a.isShown, onClose = _a.onClose, columns = _a.columns, filters = _a.filters, comparators = _a.comparators, _b = _a.filterValues, filterValues = _b === void 0 ? {} : _b, setFilters = _a.setFilters, rowsData = _a.rowsData, uxState = _a.uxState, handleUxChange = _a.handleUxChange, onAsyncLoadFilterOptions = _a.onAsyncLoadFilterOptions, actionColumn = _a.actionColumn, onClearSettings = _a.onClearSettings;
|
|
23
|
+
var filterableColumns = columns.filter(function (col) { return col.filtering; });
|
|
24
|
+
var _c = useState(filterValues !== null && filterValues !== void 0 ? filterValues : {}), localFilterValues = _c[0], setLocalFilterValues = _c[1];
|
|
25
|
+
// Re-sync local state whenever the modal is opened
|
|
26
|
+
useEffect(function () {
|
|
27
|
+
if (isShown) {
|
|
28
|
+
setLocalFilterValues(filterValues !== null && filterValues !== void 0 ? filterValues : {});
|
|
29
|
+
}
|
|
30
|
+
}, [isShown]);
|
|
31
|
+
var hasActiveFilters = Object.values(localFilterValues).some(function (item) { return isFilterActive(item.value); });
|
|
32
|
+
var handleChange = useCallback(function (column) {
|
|
33
|
+
return function (event, extraOthers) {
|
|
34
|
+
var value = (event === null || event === void 0 ? void 0 : event.target) ? event.target.value : event;
|
|
35
|
+
setLocalFilterValues(function (prev) {
|
|
36
|
+
var _a;
|
|
37
|
+
return (__assign(__assign({}, prev), (_a = {}, _a[getFilterName(column)] = {
|
|
38
|
+
value: value,
|
|
39
|
+
filterProps: {
|
|
40
|
+
type: createFilterType(column),
|
|
41
|
+
filterExtraProps: column.filterExtraProps || {},
|
|
42
|
+
computedValue: column.getFilterCriteria ? column.getFilterCriteria(value) : null
|
|
43
|
+
},
|
|
44
|
+
others: extraOthers
|
|
45
|
+
}, _a)));
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
}, []);
|
|
49
|
+
var handleApplyFilters = useCallback(function (close) {
|
|
50
|
+
setFilters(localFilterValues);
|
|
51
|
+
close();
|
|
52
|
+
}, [localFilterValues, setFilters]);
|
|
53
|
+
var handleReset = useCallback(function () {
|
|
54
|
+
setLocalFilterValues({});
|
|
55
|
+
onClearSettings === null || onClearSettings === void 0 ? void 0 : onClearSettings();
|
|
56
|
+
}, [onClearSettings]);
|
|
57
|
+
return (_jsx(Modal, { isShown: isShown, onClose: onClose, title: _jsx(Trans, { id: "dataGrid.filter", message: "Filter" }), onCancel: handleReset, cancelLabel: _jsx(Trans, { id: "dataGrid.buttonClearSettings", message: "Reset" }), onConfirm: handleApplyFilters, confirmLabel: _jsx(Trans, { id: "dataGrid.filter", message: "Filter" }), hasFooter: hasActiveFilters, width: "narrow", children: _jsx(x.div, { display: "flex", flexDirection: "column", gap: "16px", p: "8px 4px", children: filterableColumns.map(function (column) {
|
|
58
|
+
var filterType = createFilterType(column);
|
|
59
|
+
var filterConfig = filters === null || filters === void 0 ? void 0 : filters[filterType];
|
|
60
|
+
var defaultComparators = comparators === null || comparators === void 0 ? void 0 : comparators[filterType];
|
|
61
|
+
var value = get([getFilterName(column), 'value'], localFilterValues);
|
|
62
|
+
var others = get([getFilterName(column), 'others'], localFilterValues);
|
|
63
|
+
if (!(filterConfig === null || filterConfig === void 0 ? void 0 : filterConfig.CellComponent))
|
|
64
|
+
return null;
|
|
65
|
+
var RenderComponent = filterConfig.CellComponent;
|
|
66
|
+
return (_jsxs(x.div, { display: "flex", flexDirection: "column", gap: "6px", position: "relative", children: [column.title && (_jsx(H6, { mt: 0, mb: 0, variant: "semiBold", children: column.title })), _jsx(RenderComponent, __assign({ asyncLoadKey: column.asyncLoadKey, "data-test": column.name, name: column.name, onChange: handleChange(column), value: value, others: others, OverlayComponent: OverlayComponent, comparators: defaultComparators, actionColumn: actionColumn, rowsData: rowsData, uxState: uxState, handleUxChange: handleUxChange, onAsyncLoadFilterOptions: onAsyncLoadFilterOptions }, (filterType === 'date' && { compact: true }), (filterType === 'options' && { options: column.filterOptions }), filterConfig === null || filterConfig === void 0 ? void 0 : filterConfig.defaultExtraProps, column.filterExtraProps))] }, column.name));
|
|
67
|
+
}) }) }));
|
|
68
|
+
};
|
|
69
|
+
export default MobileFilterModal;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ColumnDefinition, GridActionsType, GridSelectorsType } from '../types';
|
|
3
|
+
|
|
4
|
+
type Props = {
|
|
5
|
+
isShown: boolean;
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
columns: ColumnDefinition[];
|
|
8
|
+
sortingValues?: GridSelectorsType['sorting'];
|
|
9
|
+
onAddSorting: Required<GridActionsType>['addSorting'];
|
|
10
|
+
onResetSorting?: GridActionsType['resetSorting'];
|
|
11
|
+
};
|
|
12
|
+
declare const MobileSortModal: FC<Props>;
|
|
13
|
+
export default MobileSortModal;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import Button from '../../../Elements/Button';
|
|
4
|
+
import { Modal } from '../../Modal/Modal';
|
|
5
|
+
import { getSortName } from '../utils';
|
|
6
|
+
import { SortingUp, SortingDown } from './icons/Sorting';
|
|
7
|
+
import { Trans } from '@lingui/react';
|
|
8
|
+
import { x } from '@xstyled/styled-components';
|
|
9
|
+
var AscIcon = _jsx(SortingUp, { width: "16", fill: "white" });
|
|
10
|
+
var DescIcon = _jsx(SortingDown, { width: "16", fill: "white" });
|
|
11
|
+
var SortRow = function (_a) {
|
|
12
|
+
var column = _a.column, currentDirection = _a.currentDirection, onCycle = _a.onCycle;
|
|
13
|
+
var handleClick = useCallback(function () {
|
|
14
|
+
onCycle(column);
|
|
15
|
+
}, [column, onCycle]);
|
|
16
|
+
var icon = currentDirection === 'asc' ? AscIcon : currentDirection === 'desc' ? DescIcon : null;
|
|
17
|
+
return (_jsx(Button, { type: "button", onClick: handleClick, appearance: currentDirection ? 'primary' : 'secondary', iconRight: icon, fullWidth: true, children: column.title }));
|
|
18
|
+
};
|
|
19
|
+
var MobileSortModal = function (_a) {
|
|
20
|
+
var isShown = _a.isShown, onClose = _a.onClose, columns = _a.columns, _b = _a.sortingValues, sortingValues = _b === void 0 ? [] : _b, onAddSorting = _a.onAddSorting, onResetSorting = _a.onResetSorting;
|
|
21
|
+
var sortableColumns = columns.filter(function (col) { return col.sorting; });
|
|
22
|
+
var getCurrentDirection = useCallback(function (column) { var _a; return ((_a = sortingValues.find(function (s) { return s.column === getSortName(column); })) === null || _a === void 0 ? void 0 : _a.direction) || null; }, [sortingValues]);
|
|
23
|
+
var activeSortedColumn = sortableColumns.find(function (col) { return getCurrentDirection(col) !== null; });
|
|
24
|
+
var handleCycle = useCallback(function (column) {
|
|
25
|
+
var current = getCurrentDirection(column);
|
|
26
|
+
var next = current ? (current === 'asc' ? 'desc' : null) : 'asc';
|
|
27
|
+
onAddSorting(getSortName(column), next);
|
|
28
|
+
}, [getCurrentDirection, onAddSorting]);
|
|
29
|
+
var handleClearSort = useCallback(function () {
|
|
30
|
+
onResetSorting === null || onResetSorting === void 0 ? void 0 : onResetSorting();
|
|
31
|
+
}, [onResetSorting]);
|
|
32
|
+
return (_jsx(Modal, { isShown: isShown, onClose: onClose, title: _jsx(Trans, { id: "dataGrid.sort", message: "Sort" }), onConfirm: activeSortedColumn ? handleClearSort : undefined, confirmLabel: _jsx(Trans, { id: "dataGrid.buttonClearSettings", message: "Reset" }), width: "narrow", children: _jsx(x.div, { display: "flex", flexDirection: "column", gap: "8px", p: "8px 4px", children: sortableColumns.map(function (column) { return (_jsx(SortRow, { column: column, currentDirection: getCurrentDirection(column), onCycle: handleCycle }, column.name)); }) }) }));
|
|
33
|
+
};
|
|
34
|
+
export default MobileSortModal;
|
|
@@ -10,5 +10,5 @@ type QuickFilterProps = {
|
|
|
10
10
|
isMobileInputView?: boolean;
|
|
11
11
|
alwaysShowClear?: boolean;
|
|
12
12
|
};
|
|
13
|
-
declare const QuickFilter: ({ searchedValue, placeholderText, onChange, onClick, displayInput, onClear, isMobileInputView, alwaysShowClear
|
|
13
|
+
declare const QuickFilter: ({ searchedValue, placeholderText, onChange, onClick, displayInput, onClear, isMobileInputView, alwaysShowClear }: QuickFilterProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
14
|
export default QuickFilter;
|
|
@@ -3,9 +3,9 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
|
|
3
3
|
return cooked;
|
|
4
4
|
};
|
|
5
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
import Button from '../../../../Elements/Button';
|
|
6
7
|
import Input from '../../../../Forms/Input';
|
|
7
8
|
import styled, { x } from '@xstyled/styled-components';
|
|
8
|
-
import Button from '../../../../Elements/Button';
|
|
9
9
|
var StyledInput = styled(Input)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: ", ";\n z-index: ", ";\n width: ", ";\n"], ["\n position: ", ";\n z-index: ", ";\n width: ", ";\n"])), function (_a) {
|
|
10
10
|
var isMobileInputView = _a.isMobileInputView;
|
|
11
11
|
return (isMobileInputView ? 'absolute' : 'relative');
|
|
@@ -14,7 +14,7 @@ var StyledInput = styled(Input)(templateObject_1 || (templateObject_1 = __makeTe
|
|
|
14
14
|
return (isMobileInputView ? '3' : '1');
|
|
15
15
|
}, function (_a) {
|
|
16
16
|
var isMobileInputView = _a.isMobileInputView;
|
|
17
|
-
return (isMobileInputView ? '
|
|
17
|
+
return (isMobileInputView ? 'auto' : 'auto');
|
|
18
18
|
});
|
|
19
19
|
var QuickFilter = function (_a) {
|
|
20
20
|
var searchedValue = _a.searchedValue, placeholderText = _a.placeholderText, onChange = _a.onChange, onClick = _a.onClick, displayInput = _a.displayInput, onClear = _a.onClear, isMobileInputView = _a.isMobileInputView, alwaysShowClear = _a.alwaysShowClear;
|
|
@@ -60,7 +60,7 @@ var useManageColumn = function (_a) {
|
|
|
60
60
|
setColumnsConfigOptions(columnConfig || {});
|
|
61
61
|
}, [columnsOrderValue, onClose]);
|
|
62
62
|
var getSortedColumns = useCallback(function (orderValues, isManageModal) {
|
|
63
|
-
var list = columns.filter(function (column) { return
|
|
63
|
+
var list = !isManageModal ? columns.filter(function (column) { return isColumnOn(column, columnsConfigOptions); }) : columns;
|
|
64
64
|
var sortFunction = function (col1, col2) {
|
|
65
65
|
var i = (orderValues || []).indexOf(col1.name);
|
|
66
66
|
var j = (orderValues || []).indexOf(col2.name);
|
|
@@ -6,10 +6,10 @@ type Props = {
|
|
|
6
6
|
gridSelectors: GridSelectorsType;
|
|
7
7
|
quickFilter?: CommonGridProps['quickFilter'];
|
|
8
8
|
filter?: CommonGridProps['gridSelectors']['filter'];
|
|
9
|
-
|
|
9
|
+
displayColumnsDefinitions?: ColumnDefinition<string>[];
|
|
10
10
|
filters?: FiltersConfig;
|
|
11
11
|
};
|
|
12
|
-
declare const useQuickFilter: ({ gridActions, gridSelectors, quickFilter,
|
|
12
|
+
declare const useQuickFilter: ({ gridActions, gridSelectors, quickFilter, displayColumnsDefinitions, filters }: Props) => {
|
|
13
13
|
searchedValue: string;
|
|
14
14
|
translatedValue: import('react').ReactNode;
|
|
15
15
|
onChangeInputValue: (e: ChangeEvent<HTMLInputElement>) => void;
|
|
@@ -12,7 +12,7 @@ var defaultVoidFunction = function () {
|
|
|
12
12
|
};
|
|
13
13
|
var useQuickFilter = function (_a) {
|
|
14
14
|
var _b, _c;
|
|
15
|
-
var gridActions = _a.gridActions, gridSelectors = _a.gridSelectors, quickFilter = _a.quickFilter,
|
|
15
|
+
var gridActions = _a.gridActions, gridSelectors = _a.gridSelectors, quickFilter = _a.quickFilter, displayColumnsDefinitions = _a.displayColumnsDefinitions, filters = _a.filters;
|
|
16
16
|
var _d = gridActions.addFilter, addFilter = _d === void 0 ? defaultVoidFunction : _d, _e = gridActions.clearSettings, clearSettings = _e === void 0 ? defaultVoidFunction : _e;
|
|
17
17
|
var filter = gridSelectors.filter;
|
|
18
18
|
var isMobile = useCheckDeviceWidth().isMobile;
|
|
@@ -20,7 +20,7 @@ var useQuickFilter = function (_a) {
|
|
|
20
20
|
var _g = useState(false), displayInput = _g[0], setDisplayInput = _g[1];
|
|
21
21
|
var handleAddFilter = useAddFilter(addFilter);
|
|
22
22
|
var quickFilterValues = quickFilter ? (_b = filter === null || filter === void 0 ? void 0 : filter[quickFilter]) === null || _b === void 0 ? void 0 : _b.value : undefined;
|
|
23
|
-
var searchedColumnsDefinitions = (
|
|
23
|
+
var searchedColumnsDefinitions = (displayColumnsDefinitions === null || displayColumnsDefinitions === void 0 ? void 0 : displayColumnsDefinitions.find(function (item) { return item.name === quickFilter; })) || null;
|
|
24
24
|
var filterType = createFilterType(searchedColumnsDefinitions || {});
|
|
25
25
|
var filtersDefaultComparator = ((_c = filters === null || filters === void 0 ? void 0 : filters[filterType].defaultExtraProps) === null || _c === void 0 ? void 0 : _c.defaultComparator) || 'eq';
|
|
26
26
|
var searchComparator = (quickFilterValues && quickFilterValues.comparator) || filtersDefaultComparator;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { FilterProps, SortingValueType, InitProps, GridState, GridSelectorsType, ColumnConfig, Filtering, GridPresets } from '../types';
|
|
2
2
|
|
|
3
3
|
type DefaultRootState = {};
|
|
4
|
-
export type MultiState =
|
|
5
|
-
[key: string]: GridState;
|
|
6
|
-
};
|
|
4
|
+
export type MultiState = Record<string, GridState>;
|
|
7
5
|
export declare const initialState: GridState;
|
|
8
6
|
export declare const actionPrefix = "@store/CommonGrid";
|
|
9
7
|
export declare const actionTypes: {
|
|
@@ -22,6 +20,7 @@ export declare const actionTypes: {
|
|
|
22
20
|
addFilter: string;
|
|
23
21
|
setFilters: string;
|
|
24
22
|
addSorting: string;
|
|
23
|
+
resetSorting: string;
|
|
25
24
|
clearSettings: string;
|
|
26
25
|
resetGrid: string;
|
|
27
26
|
setColumnWidth: string;
|
|
@@ -40,9 +39,7 @@ export declare const createActions: (gridName: string) => {
|
|
|
40
39
|
setPresets: (presets: GridPresets) => Action;
|
|
41
40
|
createPreset: (presetName: string, filters: Filtering) => Action;
|
|
42
41
|
deletePreset: (presetName: string) => Action;
|
|
43
|
-
setColumnWidth: (columnsWidth: null |
|
|
44
|
-
[anyKey: string]: number;
|
|
45
|
-
}, columnLayout: "normal" | "no-scroll" | "sticky") => Action;
|
|
42
|
+
setColumnWidth: (columnsWidth: null | Record<string, number>, columnLayout: "normal" | "no-scroll" | "sticky") => Action;
|
|
46
43
|
resetGrid: () => Action;
|
|
47
44
|
setColumnsOrder: (columnsOrder: string[]) => Action;
|
|
48
45
|
setRowsPerPage: (rowsPerPage: number) => Action;
|
|
@@ -50,6 +47,7 @@ export declare const createActions: (gridName: string) => {
|
|
|
50
47
|
addFilter: (column: string, value: any, filterProps: FilterProps, others?: any) => Action;
|
|
51
48
|
setFilters: (filters: Filtering) => Action;
|
|
52
49
|
addSorting: (column: string, direction: SortingValueType) => Action;
|
|
50
|
+
resetSorting: () => Action;
|
|
53
51
|
clearSettings: () => Action;
|
|
54
52
|
};
|
|
55
53
|
export declare const createSelectors: (gridName: string) => {
|
|
@@ -46,6 +46,7 @@ export var actionTypes = {
|
|
|
46
46
|
addFilter: "".concat(actionPrefix, "/addFilter"),
|
|
47
47
|
setFilters: "".concat(actionPrefix, "/setFilters"),
|
|
48
48
|
addSorting: "".concat(actionPrefix, "/addSorting"),
|
|
49
|
+
resetSorting: "".concat(actionPrefix, "/resetSorting"),
|
|
49
50
|
clearSettings: "".concat(actionPrefix, "/clearSettings"),
|
|
50
51
|
resetGrid: "".concat(actionPrefix, "/resetGrid"),
|
|
51
52
|
setColumnWidth: "".concat(actionPrefix, "/setColumnWidth"),
|
|
@@ -56,7 +57,7 @@ export default (function (state, action) {
|
|
|
56
57
|
if (state === void 0) { state = {}; }
|
|
57
58
|
return produce(state, function (draft) {
|
|
58
59
|
var _a, _b, _c;
|
|
59
|
-
var _d, _e, _f, _g, _h;
|
|
60
|
+
var _d, _e, _f, _g, _h, _j;
|
|
60
61
|
// version migrations
|
|
61
62
|
if (!migrationChecked && state && Object.keys(state).length > 0) {
|
|
62
63
|
draft = migrateState(draft);
|
|
@@ -118,6 +119,9 @@ export default (function (state, action) {
|
|
|
118
119
|
}
|
|
119
120
|
draft[gridName].sorting = sorting;
|
|
120
121
|
break;
|
|
122
|
+
case actionTypes.resetSorting:
|
|
123
|
+
draft[gridName].sorting = ((_j = draft[gridName].defaultSorting) === null || _j === void 0 ? void 0 : _j.length) ? draft[gridName].defaultSorting : initialState.sorting;
|
|
124
|
+
break;
|
|
121
125
|
case actionTypes.clearSettings:
|
|
122
126
|
draft[gridName].page = initialState.page;
|
|
123
127
|
draft[gridName].filter = initialState.filter;
|
|
@@ -211,6 +215,7 @@ export var createActions = function (gridName) { return ({
|
|
|
211
215
|
column: column,
|
|
212
216
|
direction: direction
|
|
213
217
|
}); },
|
|
218
|
+
resetSorting: function () { return ({ gridName: gridName, type: actionTypes.resetSorting }); },
|
|
214
219
|
clearSettings: function () { return ({ gridName: gridName, type: actionTypes.clearSettings }); }
|
|
215
220
|
}); };
|
|
216
221
|
export var createSelectors = function (gridName) { return ({
|
|
@@ -224,7 +229,9 @@ export var createSelectors = function (gridName) { return ({
|
|
|
224
229
|
return getOr(initialState.columnConfig, "commonGrid.".concat(gridName, ".columnConfig"), state);
|
|
225
230
|
},
|
|
226
231
|
getPage: function (state) { return getOr(initialState.page, "commonGrid.".concat(gridName, ".page"), state); },
|
|
227
|
-
getPresets: function (state) {
|
|
232
|
+
getPresets: function (state) {
|
|
233
|
+
return getOr(initialState.presets, "commonGrid.".concat(gridName, ".presets"), state);
|
|
234
|
+
},
|
|
228
235
|
getRowsPerPage: function (state) {
|
|
229
236
|
return getOr(initialState.rowsPerPage, "commonGrid.".concat(gridName, ".rowsPerPage"), state);
|
|
230
237
|
},
|