@mailstep/design-system 0.8.15-beta.1 → 0.8.16-beta.1
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 +9 -3
- package/ui/Blocks/CommonGrid/HoC/withReduxActions.js +1 -0
- package/ui/Blocks/CommonGrid/components/ControlButtons/ControlButtons.d.ts +3 -0
- package/ui/Blocks/CommonGrid/components/ControlButtons/ControlButtons.js +16 -8
- package/ui/Blocks/CommonGrid/components/ControlButtons/styles.d.ts +1 -0
- package/ui/Blocks/CommonGrid/components/ExtraControlButtons/ExtraControlButtons.d.ts +1 -0
- package/ui/Blocks/CommonGrid/components/ExtraControlButtons/ExtraControlButtons.js +29 -10
- 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/Filters/GridSelect/GridSelect.js +2 -2
- package/ui/Blocks/CommonGrid/components/GridInfo/index.js +3 -1
- package/ui/Blocks/CommonGrid/components/IconList/IconList.d.ts +1 -1
- package/ui/Blocks/CommonGrid/components/ManageColumnForm/styles.d.ts +2 -2
- package/ui/Blocks/CommonGrid/components/MobileFilterModal.d.ts +20 -0
- package/ui/Blocks/CommonGrid/components/MobileFilterModal.js +69 -0
- package/ui/Blocks/CommonGrid/components/MobileOverlayWrapper.d.ts +1 -0
- package/ui/Blocks/CommonGrid/components/MobileOverlayWrapper.js +7 -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/components/Table.d.ts +28 -28
- package/ui/Blocks/CommonGrid/hooks/useAddFilter.d.ts +1 -1
- package/ui/Blocks/CommonGrid/hooks/useColumnSizes.d.ts +1 -1
- package/ui/Blocks/CommonGrid/hooks/useEvent.d.ts +1 -1
- package/ui/Blocks/CommonGrid/hooks/useGridActionTrigger.d.ts +1 -1
- package/ui/Blocks/CommonGrid/hooks/useManageColumn.d.ts +1 -1
- package/ui/Blocks/CommonGrid/hooks/useRowsKeyControls.d.ts +1 -1
- package/ui/Blocks/CommonGrid/hooks/useToggleAllCheckbox.d.ts +1 -1
- package/ui/Blocks/CommonGrid/hooks/useUxReset.d.ts +1 -1
- package/ui/Blocks/CommonGrid/store/index.d.ts +17 -19
- package/ui/Blocks/CommonGrid/store/index.js +9 -2
- package/ui/Blocks/CommonGrid/storybook/stories/complexWithPaginationAndRedux.stories.d.ts +30 -0
- package/ui/Blocks/CommonGrid/storybook/stories/complexWithPaginationAndRedux.stories.js +59 -9
- package/ui/Blocks/CommonGrid/storybook/utils/columnDefinition.d.ts +2 -0
- package/ui/Blocks/CommonGrid/storybook/utils/columnDefinition.js +19 -9
- package/ui/Blocks/CommonGrid/styles.d.ts +7 -5
- package/ui/Blocks/CommonGrid/styles.js +6 -3
- package/ui/Blocks/CommonGrid/types.d.ts +1 -0
- package/ui/Blocks/CommonGrid/utils/index.d.ts +3 -1
- package/ui/Blocks/CommonGrid/utils/index.js +10 -0
- package/ui/Blocks/Header/components/MenuItems/styles.d.ts +1 -1
- package/ui/Blocks/Header/stories/Header.stories.d.ts +16 -16
- package/ui/Blocks/ImageList/components/AddPhoto/index.js +2 -2
- package/ui/Blocks/ImageList/components/AddPhoto/styles.d.ts +2 -2
- package/ui/Blocks/ImageList/components/CloseButton/styles.d.ts +1 -1
- package/ui/Blocks/ImageList/components/ImageElement/styles.d.ts +1 -1
- package/ui/Blocks/ImageList/styles.d.ts +2 -2
- package/ui/Blocks/LanguageSwitch/styles.d.ts +3 -3
- package/ui/Blocks/LoginPage/stories/LoginPage.stories.js +2 -2
- package/ui/Blocks/LoginPage/styles.d.ts +2 -3
- package/ui/Blocks/Modal/styles.d.ts +7 -7
- package/ui/Blocks/Scheduler/components/Groups/styles.d.ts +1 -1
- package/ui/Blocks/Scheduler/components/TimeSlots/styles.d.ts +1 -1
- package/ui/Blocks/SideMenu/components/Footer.d.ts +1 -1
- package/ui/Blocks/SideMenu/stories/SideMenu.stories.d.ts +1 -0
- package/ui/Blocks/SideMenu/styles.d.ts +15 -15
- package/ui/Blocks/Stepper/components/StepCircle/styles.d.ts +2 -2
- package/ui/Blocks/Stepper/components/StepItem/styles.d.ts +3 -3
- package/ui/Blocks/Table/stories/Table.stories.d.ts +3 -2
- package/ui/Blocks/Tabs/styles.d.ts +6 -5
- package/ui/Elements/Alert/styles.d.ts +18 -17
- package/ui/Elements/AsyncSelect/stories/AsyncSelect.stories.d.ts +2 -1
- package/ui/Elements/AsyncSelect/stories/AsyncSelect.stories.js +2 -2
- package/ui/Elements/BarChartSymbol/styles.d.ts +2 -2
- package/ui/Elements/BorderedBox/types.d.ts +1 -0
- package/ui/Elements/Button/styles.d.ts +6 -5
- package/ui/Elements/Card/styles.d.ts +2 -2
- package/ui/Elements/Card/types.d.ts +1 -0
- package/ui/Elements/CheckedCircle/storries/CheckedCircle.stories.d.ts +2 -2
- package/ui/Elements/DatePicker/Datetime/components/FooterRow.d.ts +1 -1
- package/ui/Elements/DatePicker/Datetime/views/DaysView.js +1 -1
- package/ui/Elements/DatePicker/styles.d.ts +2 -1
- package/ui/Elements/DropdownMenu/components/MenuItem.js +1 -1
- package/ui/Elements/Icon/Icon.js +6 -6
- package/ui/Elements/Icon/icons/ArrowsLeftRight.js +1 -1
- package/ui/Elements/Icon/icons/ArrowsUpDown.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/Weight.js +1 -1
- package/ui/Elements/Icon/icons/index.d.ts +2 -0
- package/ui/Elements/Icon/icons/index.js +2 -0
- package/ui/Elements/Icon/stories/BadgeIcon.stories.d.ts +1 -1
- package/ui/Elements/Label/Label.d.ts +1 -1
- package/ui/Elements/Label/stories/Label.stories.d.ts +1 -1
- package/ui/Elements/Link/stories/Link.stories.d.ts +12 -12
- package/ui/Elements/Logo/Logo.js +2 -2
- package/ui/Elements/Pagination/styled.d.ts +2 -1
- package/ui/Elements/ProgressBar/stories/ProgressBar.stories.d.ts +5 -5
- package/ui/Elements/ProgressBar/styles.d.ts +1 -1
- package/ui/Elements/Select/Select.js +2 -2
- package/ui/Elements/Select/components/SimplifiedOption.d.ts +1 -0
- package/ui/Elements/Select/themes/index.d.ts +1 -1
- package/ui/Elements/Select/themes/selectStyles.d.ts +1 -1
- package/ui/Elements/SingleSelect/SingleSelect.js +2 -2
- package/ui/Elements/SpaceAround/types.d.ts +1 -0
- package/ui/Elements/Spinner/styles.d.ts +1 -1
- package/ui/Elements/Tag/types.d.ts +1 -0
- package/ui/Elements/Toast/styles.d.ts +1 -1
- package/ui/Forms/Checkbox/styles.d.ts +2 -1
- package/ui/Forms/Input/styles.d.ts +3 -3
- package/ui/Forms/TextArea/styles.d.ts +5 -5
- package/ui/ThemeProvider/themes/default.js +1 -1
- package/ui/ThemeProvider/themes/mailwise.js +1 -1
- package/ui/index.es.js +15257 -15069
- package/ui/index.umd.js +498 -460
- 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';
|
|
@@ -52,6 +55,7 @@ var CommonGridContainer = function (props) {
|
|
|
52
55
|
var hasFilters = !!props.columnsDefinitions.find(function (col) { return col.filtering; });
|
|
53
56
|
var hasGroupsOrFilters = hasGroups || hasFilters;
|
|
54
57
|
var autoRowsPerPage = getRowsPerPage(gridRef, withPagination, withButtonStrip, hasGroupsOrFilters);
|
|
58
|
+
var isMobile = useCheckDeviceWidth().isMobile;
|
|
55
59
|
useGridAutoRowsPerPage({
|
|
56
60
|
autoHeight: autoHeight,
|
|
57
61
|
gridActions: gridActions,
|
|
@@ -70,10 +74,12 @@ var CommonGridContainer = function (props) {
|
|
|
70
74
|
onClose: onClose
|
|
71
75
|
}), 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
76
|
var _k = usePresetState(), isPresetsModalOpen = _k.isPresetsModalOpen, onClosePresetsModal = _k.onClosePresetsModal, onOpenPresetsModal = _k.onOpenPresetsModal, setSelectedPresetName = _k.setSelectedPresetName, selectedPresetName = _k.selectedPresetName;
|
|
73
|
-
var _l =
|
|
77
|
+
var _l = useModal(), isMobileFilterOpen = _l.isOpen, onOpenMobileFilter = _l.onOpen, closeMobileFilter = _l.onClose;
|
|
78
|
+
var _m = useModal(), isMobileSortOpen = _m.isOpen, onOpenMobileSort = _m.onOpen, closeMobileSort = _m.onClose;
|
|
79
|
+
var _o = hasSortTerminated({
|
|
74
80
|
allowSortingOnlyUnderTotalRows: allowSortingOnlyUnderTotalRows,
|
|
75
81
|
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, columns: columns, filters: filters, setDisplayManageColumnButton: setDisplayManageColumnButton, displayManageColumnButton: displayManageColumnButton, openManageColumnForm: openManageColumnForm, onOpenPresetsModal: onOpenPresetsModal, selectedPresetName: selectedPresetName, withPresets: withPresets, gridName: gridName, withManageColumnButton: withManageColumnButton }) }) })), _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: [_jsx(GridInfo, { isSortTerminatedAppeal: isSortTerminatedAppeal, isSortTerminated: isSortTerminated }), withPagination && (_jsxs(x.div, { display: "flex", alignItems: "center", className: "paginatorWrapper", 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:
|
|
82
|
+
}), isSortTerminatedAppeal = _o.isSortTerminatedAppeal, isSortTerminated = _o.isSortTerminated;
|
|
83
|
+
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, columns: columns, filters: filters, setDisplayManageColumnButton: setDisplayManageColumnButton, displayManageColumnButton: displayManageColumnButton, openManageColumnForm: openManageColumnForm, onOpenPresetsModal: onOpenPresetsModal, selectedPresetName: selectedPresetName, withPresets: withPresets, gridName: gridName, withManageColumnButton: withManageColumnButton, onOpenMobileFilters: onOpenMobileFilter, onOpenMobileSorting: onOpenMobileSort, isSortTerminated: isSortTerminated }) }) })), _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
84
|
};
|
|
79
85
|
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,
|
|
@@ -17,6 +17,9 @@ type Props = {
|
|
|
17
17
|
selectedPresetName: string;
|
|
18
18
|
withPresets?: boolean;
|
|
19
19
|
withManageColumnButton?: boolean;
|
|
20
|
+
onOpenMobileFilters?: () => void;
|
|
21
|
+
onOpenMobileSorting?: () => void;
|
|
22
|
+
isSortTerminated: boolean;
|
|
20
23
|
};
|
|
21
24
|
declare const ControlButtons: FC<Props>;
|
|
22
25
|
export default ControlButtons;
|
|
@@ -10,37 +10,45 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import { useEffect } from 'react';
|
|
13
|
+
import { useEffect, useMemo } 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';
|
|
24
27
|
import { Trans } from '@lingui/react';
|
|
25
|
-
import { x } from '@xstyled/styled-components';
|
|
28
|
+
import { useColor, 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, columns = _a.columns, 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, isSortTerminated = _a.isSortTerminated;
|
|
33
|
+
var _e = useQuickFilter({
|
|
30
34
|
gridActions: gridActions,
|
|
31
35
|
gridSelectors: gridSelectors,
|
|
32
36
|
quickFilter: quickFilter,
|
|
33
37
|
columns: columns,
|
|
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 red = useColor('red1');
|
|
44
|
+
var filtersCount = useMemo(function () { return (filter ? Object.values(filter).filter(function (item) { return isFilterActive(item.value); }).length : 0); }, [filter]);
|
|
45
|
+
var hasFilterableColumns = !!(columns === null || columns === void 0 ? void 0 : columns.some(function (col) { return col.filtering; }));
|
|
46
|
+
var hasSortableColumns = !!(columns === null || columns === void 0 ? void 0 : columns.some(function (col) { return col.sorting; }));
|
|
47
|
+
var sortCount = (_c = (_b = gridSelectors.sorting) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0;
|
|
48
|
+
return (_jsxs(ControlButtonsContainer, { children: [_jsxs(Left, { children: [!hideControlButtons && (_jsxs(_Fragment, { children: [quickFilter && !isMobile && (_jsx(QuickFilter, { searchedValue: searchedValue, placeholderText: i18n._({
|
|
41
49
|
id: 'controlButtons.searchPlaceholder',
|
|
42
50
|
message: "Search ".concat(translatedValue, " ..."),
|
|
43
51
|
values: { translatedValue: translatedValue }
|
|
44
|
-
}), onChange: onChangeInputValue, onClear: onClear, onClick: onDisplayInput, displayInput: displayInput, isMobileInputView: isMobileInputView
|
|
52
|
+
}), onChange: onChangeInputValue, onClear: onClear, onClick: onDisplayInput, displayInput: displayInput, isMobileInputView: isMobileInputView })), _jsx(ExtraControlButtons, { extraControlButtons: extraControlButtons, targetPosition: ExtraControlButtonPosition.TopLeft }), _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 && hasFilterableColumns && (_jsxs(Button, { type: "button", appearance: filtersCount ? 'primary' : 'tertiary', onClick: onOpenMobileFilters, "data-cy": "mobileFilterBtn", children: [_jsx(Filter, { fill: filtersCount ? 'white' : red }), _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, disabled: isSortTerminated, "data-cy": "mobileSortBtn", children: [_jsx(Sort, { stroke: sortCount ? 'white' : red }), _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
53
|
};
|
|
46
54
|
export default ControlButtons;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
export declare const ControlButtonsContainer: import('styled-components').StyledComponent<"div", import('@xstyled/system').Theme, {}, never>;
|
|
2
3
|
export declare const Left: import('styled-components').StyledComponent<"div", import('@xstyled/system').Theme, {}, never>;
|
|
3
4
|
export declare const Right: import('styled-components').StyledComponent<"div", import('@xstyled/system').Theme, {}, never>;
|
|
@@ -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,9 +16,9 @@ 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
|
-
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"])));
|
|
22
22
|
var ControlButton = function (_a) {
|
|
23
23
|
var hide = _a.hide, node = _a.node, label = _a.label, appearance = _a.appearance, variant = _a.variant, disabled = _a.disabled, onClick = _a.onClick, onSelect = _a.onSelect, options = _a.options, hideChevron = _a.hideChevron, iconLeft = _a.iconLeft, buttonProps = _a.buttonProps;
|
|
24
24
|
if (hide) {
|
|
@@ -30,17 +30,36 @@ var ControlButton = function (_a) {
|
|
|
30
30
|
return (_jsx(DropdownSelect, { label: label || '', appearance: appearance || 'secondary', variant: variant || 'default', options: options, showChevron: !hideChevron, onSelect: onSelect, disabled: disabled }));
|
|
31
31
|
}
|
|
32
32
|
else {
|
|
33
|
-
return (_jsx(
|
|
33
|
+
return (_jsx(Button, __assign({ type: "button", onClick: onClick, disabled: disabled, variant: variant || 'default', appearance: appearance || 'primary', iconLeft: iconLeft }, buttonProps, { children: label })));
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
var ExtraControlButtons = function (_a) {
|
|
37
|
-
var extraControlButtons = _a.extraControlButtons, targetPosition = _a.targetPosition;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
var extraControlButtons = _a.extraControlButtons, targetPosition = _a.targetPosition, isMobile = _a.isMobile;
|
|
38
|
+
var buttons = (extraControlButtons || []).filter(function (_a) {
|
|
39
|
+
var position = _a.position, hide = _a.hide;
|
|
40
|
+
return position === targetPosition && !hide;
|
|
41
|
+
});
|
|
42
|
+
if (isMobile && buttons.length > 0) {
|
|
43
|
+
var items = buttons.flatMap(function (_a) {
|
|
44
|
+
var onSelect = _a.onSelect, onClick = _a.onClick, options = _a.options, label = _a.label;
|
|
45
|
+
if (options && onSelect) {
|
|
46
|
+
return options.map(function (option) { return ({
|
|
47
|
+
title: typeof label === 'string' && !option.label.startsWith(String(label)) ? "".concat(label, ": ").concat(option.label) : option.label,
|
|
48
|
+
onClick: function () {
|
|
49
|
+
onSelect(option.value);
|
|
50
|
+
}
|
|
51
|
+
}); });
|
|
52
|
+
}
|
|
53
|
+
if (label && onClick) {
|
|
54
|
+
return [{ title: label, onClick: onClick }];
|
|
55
|
+
}
|
|
56
|
+
return [];
|
|
57
|
+
});
|
|
58
|
+
if (items.length === 0)
|
|
59
|
+
return null;
|
|
60
|
+
return _jsx(ButtonMore, { items: items });
|
|
61
|
+
}
|
|
62
|
+
return (_jsx(Row, { children: buttons.map(function (button, idx) { return (_jsx(x.div, { children: _jsx(ControlButton, __assign({}, button)) }, idx)); }) }));
|
|
44
63
|
};
|
|
45
64
|
export default ExtraControlButtons;
|
|
46
|
-
var templateObject_1
|
|
65
|
+
var templateObject_1;
|
|
@@ -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;
|
|
@@ -19,8 +19,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
19
19
|
});
|
|
20
20
|
};
|
|
21
21
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g
|
|
23
|
-
return g
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
24
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
25
|
function step(op) {
|
|
26
26
|
if (f) throw new TypeError("Generator is already executing.");
|
|
@@ -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
|
-
|
|
7
|
+
if (!isSortTerminatedAppeal)
|
|
8
|
+
return null;
|
|
9
|
+
return (_jsxs(x.span, { w: "100%", 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
|
};
|
|
@@ -3,7 +3,7 @@ import { FC } from 'react';
|
|
|
3
3
|
export declare const List: import('styled-components').StyledComponent<"ul", import('@xstyled/system').Theme, {}, never>;
|
|
4
4
|
export declare const ListItem: import('styled-components').StyledComponent<"li", import('@xstyled/system').Theme, {}, never>;
|
|
5
5
|
export declare const ListItemContent: import('styled-components').StyledComponent<"span", import('@xstyled/system').Theme, {
|
|
6
|
-
selected?: boolean;
|
|
6
|
+
selected?: boolean | undefined;
|
|
7
7
|
}, never>;
|
|
8
8
|
export declare const ListItemIcon: import('styled-components').StyledComponent<"span", import('@xstyled/system').Theme, {}, never>;
|
|
9
9
|
type Item = {
|
|
@@ -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 { MobileOverlayWrapper } from './MobileOverlayWrapper';
|
|
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 && col.title; });
|
|
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: MobileOverlayWrapper, 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 @@
|
|
|
1
|
+
export declare const MobileOverlayWrapper: import('styled-components').StyledComponent<"div", import('@xstyled/system').Theme, {}, never>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
import styled from '@xstyled/styled-components';
|
|
6
|
+
export var MobileOverlayWrapper = 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"])));
|
|
7
|
+
var templateObject_1;
|
|
@@ -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;
|
|
@@ -1,48 +1,48 @@
|
|
|
1
1
|
export declare const Row: import('styled-components').StyledComponent<"div", import('@xstyled/system').Theme, {
|
|
2
|
-
hasRowClick?: boolean;
|
|
3
|
-
align?: string;
|
|
2
|
+
hasRowClick?: boolean | undefined;
|
|
3
|
+
align?: string | undefined;
|
|
4
4
|
}, never>;
|
|
5
5
|
export declare const Cell: import('styled-components').StyledComponent<"div", import('@xstyled/system').Theme, {
|
|
6
|
-
align?: string;
|
|
7
|
-
flexBasis?: number;
|
|
8
|
-
flexGrow?: number;
|
|
9
|
-
flexShrink?: number;
|
|
10
|
-
transition?: string;
|
|
11
|
-
transform?: string;
|
|
6
|
+
align?: string | undefined;
|
|
7
|
+
flexBasis?: number | undefined;
|
|
8
|
+
flexGrow?: number | undefined;
|
|
9
|
+
flexShrink?: number | undefined;
|
|
10
|
+
transition?: string | undefined;
|
|
11
|
+
transform?: string | undefined;
|
|
12
12
|
}, never>;
|
|
13
13
|
export declare const StyledDataRow: import('styled-components').StyledComponent<"div", import('@xstyled/system').Theme, {
|
|
14
|
-
hasRowClick?: boolean;
|
|
15
|
-
align?: string;
|
|
14
|
+
hasRowClick?: boolean | undefined;
|
|
15
|
+
align?: string | undefined;
|
|
16
16
|
} & {
|
|
17
17
|
isEven: boolean;
|
|
18
18
|
}, never>;
|
|
19
19
|
export declare const TextCell: import('styled-components').StyledComponent<"div", import('@xstyled/system').Theme, {
|
|
20
|
-
align?: string;
|
|
21
|
-
flexBasis?: number;
|
|
22
|
-
flexGrow?: number;
|
|
23
|
-
flexShrink?: number;
|
|
24
|
-
transition?: string;
|
|
25
|
-
transform?: string;
|
|
20
|
+
align?: string | undefined;
|
|
21
|
+
flexBasis?: number | undefined;
|
|
22
|
+
flexGrow?: number | undefined;
|
|
23
|
+
flexShrink?: number | undefined;
|
|
24
|
+
transition?: string | undefined;
|
|
25
|
+
transform?: string | undefined;
|
|
26
26
|
}, never>;
|
|
27
27
|
export declare const MessageCell: import('styled-components').StyledComponent<"div", import('@xstyled/system').Theme, {
|
|
28
|
-
align?: string;
|
|
29
|
-
flexBasis?: number;
|
|
30
|
-
flexGrow?: number;
|
|
31
|
-
flexShrink?: number;
|
|
32
|
-
transition?: string;
|
|
33
|
-
transform?: string;
|
|
28
|
+
align?: string | undefined;
|
|
29
|
+
flexBasis?: number | undefined;
|
|
30
|
+
flexGrow?: number | undefined;
|
|
31
|
+
flexShrink?: number | undefined;
|
|
32
|
+
transition?: string | undefined;
|
|
33
|
+
transform?: string | undefined;
|
|
34
34
|
}, never>;
|
|
35
35
|
declare const variantColors: {
|
|
36
36
|
error: (props: import('@xstyled/util').Props<import('@xstyled/system').Theme>) => import('@xstyled/system').CSSScalar;
|
|
37
37
|
info: (props: import('@xstyled/util').Props<import('@xstyled/system').Theme>) => import('@xstyled/system').CSSScalar;
|
|
38
38
|
};
|
|
39
39
|
export declare const MessageCellBody: import('styled-components').StyledComponent<"div", import('@xstyled/system').Theme, {
|
|
40
|
-
align?: string;
|
|
41
|
-
flexBasis?: number;
|
|
42
|
-
flexGrow?: number;
|
|
43
|
-
flexShrink?: number;
|
|
44
|
-
transition?: string;
|
|
45
|
-
transform?: string;
|
|
40
|
+
align?: string | undefined;
|
|
41
|
+
flexBasis?: number | undefined;
|
|
42
|
+
flexGrow?: number | undefined;
|
|
43
|
+
flexShrink?: number | undefined;
|
|
44
|
+
transition?: string | undefined;
|
|
45
|
+
transform?: string | undefined;
|
|
46
46
|
} & {
|
|
47
47
|
variant: keyof typeof variantColors;
|
|
48
48
|
}, never>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GridActionsType, ColumnDefinition } from '../types';
|
|
2
2
|
|
|
3
3
|
type AddFilterRet = (value: any, column: ColumnDefinition, others?: any) => void;
|
|
4
|
-
export declare const useAddFilter: (onChange: Required<GridActionsType>[
|
|
4
|
+
export declare const useAddFilter: (onChange: Required<GridActionsType>['addFilter']) => AddFilterRet;
|
|
5
5
|
export {};
|