@mailstep/design-system 0.6.91 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/ui/Blocks/CommonGrid/CommonGrid.d.ts +2 -2
- package/ui/Blocks/CommonGrid/CommonGrid.js +10 -10
- package/ui/Blocks/CommonGrid/components/ColumnTitle.d.ts +1 -1
- package/ui/Blocks/CommonGrid/components/DataRow.d.ts +1 -1
- package/ui/Blocks/CommonGrid/components/DataRow.js +8 -8
- package/ui/Blocks/CommonGrid/components/Filters/NumberRange/NumberRange.js +0 -1
- package/ui/Blocks/CommonGrid/components/GridModals/index.js +1 -1
- package/ui/Blocks/CommonGrid/components/HeadRow.js +20 -7
- package/ui/Blocks/CommonGrid/components/ManageColumnForm/ManageColumnForm.js +11 -2
- package/ui/Blocks/CommonGrid/components/ManageColumnForm/components/ActionRow.d.ts +2 -6
- package/ui/Blocks/CommonGrid/components/ManageColumnForm/components/ActionRow.js +7 -26
- package/ui/Blocks/CommonGrid/components/ManageColumnForm/styles.d.ts +3 -0
- package/ui/Blocks/CommonGrid/components/ManageColumnForm/styles.js +10 -0
- package/ui/Blocks/CommonGrid/components/ManageColumnForm/utils.d.ts +2 -0
- package/ui/Blocks/CommonGrid/components/ManageColumnForm/utils.js +10 -0
- package/ui/Blocks/CommonGrid/components/PresetsModalBody/index.js +1 -1
- package/ui/Blocks/CommonGrid/components/Table.d.ts +18 -7
- package/ui/Blocks/CommonGrid/components/Table.js +2 -16
- package/ui/Blocks/CommonGrid/components/utils.d.ts +3 -2
- package/ui/Blocks/CommonGrid/hooks/useManageColumn.js +1 -1
- package/ui/Blocks/CommonGrid/hooks/useQuickFilter.js +6 -11
- package/ui/Blocks/CommonGrid/hooks/useSelectPreset.js +4 -14
- package/ui/Blocks/CommonGrid/styles.d.ts +1 -1
- package/ui/Blocks/CommonGrid/types.d.ts +1 -1
- package/ui/ThemeProvider/themes/mailwise.js +13 -13
- package/ui/index.es.js +21150 -24851
- package/ui/index.umd.js +655 -683
- package/ui/Blocks/CommonGrid/components/HeadCell.d.ts +0 -27
- package/ui/Blocks/CommonGrid/components/HeadCell.js +0 -42
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { CommonGridProps, FiltersConfig, ColumnDefinition } from './types';
|
|
2
1
|
import { DropResult } from 'react-beautiful-dnd';
|
|
2
|
+
import { CommonGridProps, FiltersConfig, ColumnDefinition } from './types';
|
|
3
3
|
type Props = CommonGridProps & {
|
|
4
4
|
filters?: FiltersConfig;
|
|
5
5
|
handleDragEnd: (item: DropResult) => void;
|
|
6
6
|
displayColumnsDefinitions: ColumnDefinition[];
|
|
7
7
|
};
|
|
8
|
-
declare const CommonGrid: ({ filters, comparators, handleDragEnd, gridSelectors, gridActions, isLoading, rowsData, hasColouredRows, columnsDefinitions, actionColumnDefinition, allowRowSelect, allowRowSelectOnAction, onRowAction, onRowEditClick, onRowReadClick, onRowClick, columnLayout, displayColumnsDefinitions, className, gridRef, minColumnWidth, errorMessage, floatingButtonProps
|
|
8
|
+
declare const CommonGrid: ({ filters, comparators, handleDragEnd, gridSelectors, gridActions, isLoading, rowsData, hasColouredRows, columnsDefinitions, actionColumnDefinition, allowRowSelect, allowRowSelectOnAction, onRowAction, onRowEditClick, onRowReadClick, onRowClick, columnLayout, displayColumnsDefinitions, className, gridRef, minColumnWidth, errorMessage, floatingButtonProps }: Props) => JSX.Element;
|
|
9
9
|
export default CommonGrid;
|
|
@@ -11,20 +11,20 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
13
|
import React from 'react';
|
|
14
|
-
import { x } from '@xstyled/styled-components';
|
|
15
|
-
import { Row, MessageCell } from './components/Table';
|
|
16
|
-
import OversizedScroll from './components/OversizedScroll';
|
|
17
|
-
import GroupRow from './components/GroupRow';
|
|
18
|
-
import FilterRow from './components/FilterRow';
|
|
19
14
|
import DataRow from './components/DataRow';
|
|
15
|
+
import FilterRow from './components/FilterRow';
|
|
16
|
+
import FloatingButton from './components/FloatingButton/FloatingButton';
|
|
17
|
+
import GroupRow from './components/GroupRow';
|
|
20
18
|
import HeadRow from './components/HeadRow';
|
|
21
|
-
import
|
|
22
|
-
import
|
|
19
|
+
import OversizedScroll from './components/OversizedScroll';
|
|
20
|
+
import { Row, MessageCell } from './components/Table';
|
|
23
21
|
import useColumnSizes from './hooks/useColumnSizes';
|
|
24
|
-
import
|
|
25
|
-
import
|
|
22
|
+
import useRowsKeyControls from './hooks/useRowsKeyControls';
|
|
23
|
+
import useUxReset from './hooks/useUxReset';
|
|
26
24
|
import { Trans } from '@lingui/react';
|
|
27
|
-
import
|
|
25
|
+
import { x } from '@xstyled/styled-components';
|
|
26
|
+
import { initialState } from './store';
|
|
27
|
+
import { getGroups } from './utils';
|
|
28
28
|
var rowsStyles = { outline: 'none' };
|
|
29
29
|
var defaultVoidFunction = function () {
|
|
30
30
|
var args = [];
|
|
@@ -3,7 +3,7 @@ import { SortingValueType } from '../types';
|
|
|
3
3
|
declare const _default: React.NamedExoticComponent<{
|
|
4
4
|
title?: string | JSX.Element | undefined;
|
|
5
5
|
isSortable: boolean;
|
|
6
|
-
onSetSort
|
|
6
|
+
onSetSort?: ((value: SortingValueType) => void) | undefined;
|
|
7
7
|
sortValue: SortingValueType;
|
|
8
8
|
}>;
|
|
9
9
|
export default _default;
|
|
@@ -17,5 +17,5 @@ type DataRowProps = {
|
|
|
17
17
|
groups: Group[];
|
|
18
18
|
isEven?: boolean;
|
|
19
19
|
};
|
|
20
|
-
declare const DataRow: ({ columns, actionColumn, rowData, rowIndex, uxState, allowRowSelect, allowRowSelectOnAction, onUxChange, onRowEditClick, onRowReadClick, onRowClick, onRowAction, displayColumnsWidth, groups, isEven
|
|
20
|
+
declare const DataRow: ({ columns, actionColumn, rowData, rowIndex, uxState, allowRowSelect, allowRowSelectOnAction, onUxChange, onRowEditClick, onRowReadClick, onRowClick, onRowAction, displayColumnsWidth, groups, isEven }: DataRowProps) => JSX.Element;
|
|
21
21
|
export default DataRow;
|
|
@@ -22,18 +22,18 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
22
22
|
};
|
|
23
23
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
24
24
|
import React from 'react';
|
|
25
|
-
import { x } from '@xstyled/styled-components';
|
|
26
25
|
import { Link } from 'react-router-dom';
|
|
27
|
-
import
|
|
28
|
-
import
|
|
26
|
+
import Button from '../../../Elements/Button/Button';
|
|
27
|
+
import Checkbox from '../../../Forms/Checkbox';
|
|
28
|
+
import { rowClassSymbol } from '../types';
|
|
29
|
+
import { getActionCellSizeProps } from '../utils';
|
|
29
30
|
import EditIcon from './icons/Edit';
|
|
30
31
|
import EyeOpenIcon from './icons/EyeOpen';
|
|
31
|
-
import {
|
|
32
|
-
import { rowClassSymbol } from '../types';
|
|
32
|
+
import { x } from '@xstyled/styled-components';
|
|
33
33
|
import { isFunction } from 'lodash/fp';
|
|
34
|
+
import MemoDataCell from './DataCell';
|
|
35
|
+
import { Cell, StyledDataRow } from './Table';
|
|
34
36
|
import { useTimeMeasurement } from './utils';
|
|
35
|
-
import Checkbox from '../../../Forms/Checkbox';
|
|
36
|
-
import Button from '../../../Elements/Button/Button';
|
|
37
37
|
var EmptySpan = function (_a) {
|
|
38
38
|
var children = _a.children, props = __rest(_a, ["children"]);
|
|
39
39
|
return _jsx("span", __assign({}, props, { children: children }));
|
|
@@ -105,6 +105,6 @@ var DataRow = function (_a) {
|
|
|
105
105
|
return actionColumn ? __assign({}, getActionCellSizeProps(actionColumn)) : {};
|
|
106
106
|
}, [actionColumn]);
|
|
107
107
|
var displayReadEditCell = ((_c = actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.actionOptions) === null || _c === void 0 ? void 0 : _c.length) || (actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.canRowEdit) || (actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.canRowRead) || (actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.forceCheckboxes);
|
|
108
|
-
return (_jsxs(StyledDataRow, { className: rowClassName, hasRowClick: !!onRowClick, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, isEven: isEven, children: [actionColumn && (_jsxs(_Fragment, { children: [displayReadEditCell && (_jsxs(Cell, { className: "cell", style: actionColumnStyle, children: [((_d = actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.actionOptions) === null || _d === void 0 ? void 0 : _d.length) || (actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.forceCheckboxes) ? (_jsx(Checkbox, { checked: isChecked, onChange: onCheckboxChange, label: "" })) : null, _jsxs(x.div, { children: [(isFunction(actionColumn.canRowRead) ? actionColumn.canRowRead(rowData) : actionColumn.canRowRead) && (_jsx(RowActionComponent, __assign({}, rowActionProps('read'), { children: _jsx(Button, { type: "button", variant: "default", appearance: "primary", children: _jsx(EyeOpenIcon, { width: "16px", height: "16px" }) }) }))), (isFunction(actionColumn.canRowEdit) ? actionColumn.canRowEdit(rowData) : actionColumn.canRowEdit) && (_jsx(RowActionComponent, __assign({}, rowActionProps('edit'), { children: _jsx(Button, { type: "button", variant: "default", appearance: "primary", children: _jsx(EditIcon, { width: "16px", height: "16px" }) }) })))] })] })), (actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.addRowNumbers) && (_jsx(Cell, { className: "cell", style: actionColumnStyle, children: _jsx(x.div, { children: rowIndex }) }))] })), columns.map(function (column, key) { return (_jsx(MemoDataCell, { column: column, rowData: rowData, onRowAction: handleRowAction, displayColumnWidth: displayColumnsWidth[column.name], group: groups === null || groups === void 0 ? void 0 : groups[key] }, column.name)); })] }));
|
|
108
|
+
return (_jsxs(StyledDataRow, { className: rowClassName, hasRowClick: !!onRowClick, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, isEven: !!isEven, children: [actionColumn && (_jsxs(_Fragment, { children: [displayReadEditCell && (_jsxs(Cell, { className: "cell", style: actionColumnStyle, children: [((_d = actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.actionOptions) === null || _d === void 0 ? void 0 : _d.length) || (actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.forceCheckboxes) ? (_jsx(Checkbox, { checked: isChecked, onChange: onCheckboxChange, label: "" })) : null, _jsxs(x.div, { children: [(isFunction(actionColumn.canRowRead) ? actionColumn.canRowRead(rowData) : actionColumn.canRowRead) && (_jsx(RowActionComponent, __assign({}, rowActionProps('read'), { children: _jsx(Button, { type: "button", variant: "default", appearance: "primary", children: _jsx(EyeOpenIcon, { width: "16px", height: "16px" }) }) }))), (isFunction(actionColumn.canRowEdit) ? actionColumn.canRowEdit(rowData) : actionColumn.canRowEdit) && (_jsx(RowActionComponent, __assign({}, rowActionProps('edit'), { children: _jsx(Button, { type: "button", variant: "default", appearance: "primary", children: _jsx(EditIcon, { width: "16px", height: "16px" }) }) })))] })] })), (actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.addRowNumbers) && (_jsx(Cell, { className: "cell", style: actionColumnStyle, children: _jsx(x.div, { children: rowIndex }) }))] })), columns.map(function (column, key) { return (_jsx(MemoDataCell, { column: column, rowData: rowData, onRowAction: handleRowAction, displayColumnWidth: displayColumnsWidth[column.name], group: groups === null || groups === void 0 ? void 0 : groups[key] }, column.name)); })] }));
|
|
109
109
|
};
|
|
110
110
|
export default DataRow;
|
|
@@ -86,7 +86,6 @@ var NumberRange = function (props) {
|
|
|
86
86
|
}
|
|
87
87
|
// two values for between comparation
|
|
88
88
|
if (values.length === 2) {
|
|
89
|
-
console.log('TRTEEEEEST', values);
|
|
90
89
|
var normalizedValues = values.map(function (value) { return normalizeValue(value, 0); });
|
|
91
90
|
onChange({ comparator: comparator, value: normalizedValues.join(',') });
|
|
92
91
|
return;
|
|
@@ -23,5 +23,5 @@ export var GridModals = function (_a) {
|
|
|
23
23
|
gridName: gridName,
|
|
24
24
|
setGridPresets: setGridPresets
|
|
25
25
|
}), fileInputRef = _e.fileInputRef, handleImportPresets = _e.handleImportPresets, handleExportPresets = _e.handleExportPresets, handleImportButtonClick = _e.handleImportButtonClick;
|
|
26
|
-
return (_jsxs(_Fragment, { children: [
|
|
26
|
+
return (_jsxs(_Fragment, { children: [_jsx(Modal, { title: _jsx(Trans, { id: "manageColumn.title", message: "Manage columns" }), onClose: onCloseForm, onCancel: onCloseForm, onExtraAction: resetColumnConfig, onConfirm: onConfirmForm, isShown: manageColumnFormVisible, width: "auto", minWidth: "350px", hasFooter: true, extraActionLabel: _jsx(Trans, { id: "dataGrid.buttonClearConfig", message: "Reset config" }), cancelLabel: _jsx(Trans, { id: "form.buttonCancel", message: "Cancel" }), confirmLabel: _jsx(Trans, { id: "form.buttonConfirm", message: "Confirm" }), children: _jsx(ManageColumnForm, { columns: manageColumnsFormDefinitions, columnsConfigValues: columnsConfigValues, setColumnsConfigOptions: setColumnsConfigOptions, handleDragEnd: handleDragEnd }) }), _jsx(Modal, { isShown: isPresetsModalOpen, title: _jsx(Trans, { id: "dataGrid.presets.title", message: "Presets" }), onClose: onClosePresetsModal, width: "narrow", children: _jsx(PresetsModalBody, { onOpenCreatePresetModal: onOpenCreatePresetModal, gridPresets: gridPresets, handleSelectPreset: handleSelectPreset, handleOpenDeletePresetModal: handleOpenDeletePresetModal, selectedPresetName: selectedPresetName, handleExportPresets: handleExportPresets, handleImportPresets: handleImportPresets, handleImportButtonClick: handleImportButtonClick, fileInputRef: fileInputRef, filters: gridSelectors.filter }) }), _jsx(Modal, { isShown: isCreatePresetModalOpen, title: _jsx(Trans, { id: "dataGrid.createPreset.title", message: "Create preset" }), onCancel: handleCloseCreatePresetModal, onConfirm: handleCreatePreset, isConfirmDisabled: !presetName, width: "narrow", children: _jsx(Input, { type: "text", onChange: handleChangePresetName, value: presetName, label: _jsx(Trans, { id: "dataGrid.createPreset.title", message: "Preset name" }) }) }), _jsx(Modal, { isShown: isDeletePresetModalOpen, title: _jsx(Trans, { id: "dataGrid.deletePreset.title", message: "Delete preset" }), onCancel: onCloseDeletePresetModal, onConfirm: handleDeletePreset, isConfirmDisabled: !presetNameToDelete, width: "narrow", children: _jsxs(_Fragment, { children: [_jsx(Trans, { id: "dataGrid.deletePreset.confirm", message: "Are you sure you want to delete preset" }), " \"", presetNameToDelete, "\" ?"] }) })] }));
|
|
27
27
|
};
|
|
@@ -12,12 +12,16 @@ 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 React, { useEffect, useState } from 'react';
|
|
14
14
|
import { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd';
|
|
15
|
-
import { getActionCellSizeProps, getCellSizeProps, getSortName } from '../utils';
|
|
16
|
-
import
|
|
15
|
+
import { getActionCellSizeProps, getCellSizeProps, getGroupClassNames, getSortName, getStickyCollClassNames } from '../utils';
|
|
16
|
+
import ColumnTitle from './ColumnTitle';
|
|
17
|
+
import Resize from './Resize';
|
|
17
18
|
import { Row, Cell } from './Table';
|
|
18
19
|
var getStickyComponent = function (columns, stickyTo, displayColumnsWidth) {
|
|
19
20
|
var _a;
|
|
20
|
-
return (_a = columns === null || columns === void 0 ? void 0 : columns.filter(function (item) { return item.sticky && item.stickTo === stickyTo; })) === null || _a === void 0 ? void 0 : _a.map(function (column) {
|
|
21
|
+
return (_a = columns === null || columns === void 0 ? void 0 : columns.filter(function (item) { return item.sticky && item.stickTo === stickyTo; })) === null || _a === void 0 ? void 0 : _a.map(function (column) {
|
|
22
|
+
var cellClassName = "cell".concat(getStickyCollClassNames(!!column.sticky, column.stickTo), "}");
|
|
23
|
+
return (_jsx(Cell, __assign({}, getCellSizeProps(column, displayColumnsWidth[column.name]), { className: cellClassName, children: _jsx(ColumnTitle, { title: column === null || column === void 0 ? void 0 : column.title, isSortable: false, sortValue: null }) }), column.name));
|
|
24
|
+
});
|
|
21
25
|
};
|
|
22
26
|
var HeadRow = function (_a) {
|
|
23
27
|
var _b;
|
|
@@ -34,11 +38,20 @@ var HeadRow = function (_a) {
|
|
|
34
38
|
setIsDragDisabled(false);
|
|
35
39
|
}, [setIsDragDisabled]);
|
|
36
40
|
var displayReadEditCell = ((_b = actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.actionOptions) === null || _b === void 0 ? void 0 : _b.length) || (actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.canRowEdit) || (actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.canRowRead) || (actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.forceCheckboxes);
|
|
37
|
-
|
|
41
|
+
var onResize = React.useCallback(function (name) { return function (width) {
|
|
42
|
+
handleResizeDrag === null || handleResizeDrag === void 0 ? void 0 : handleResizeDrag(name, width);
|
|
43
|
+
}; }, [handleResizeDrag]);
|
|
44
|
+
var onSetSort = React.useCallback(function (name, systemName) { return function (value) {
|
|
45
|
+
onAddSort && onAddSort(systemName || name, value);
|
|
46
|
+
}; }, [onAddSort]);
|
|
47
|
+
return (_jsx(_Fragment, { children: showUIElements && (_jsx(DragDropContext, { onDragEnd: handleDragEnd, children: _jsx(Droppable, { droppableId: "droppable", direction: "horizontal", isDropDisabled: isDragDisabled, isCombineEnabled: false, ignoreContainerClipping: false, children: function (droppableProvided) { return (_jsxs(Row, __assign({ className: "headRow", accountForScrollbar: false, ref: droppableProvided.innerRef }, droppableProvided.droppableProps, { children: [actionColumn && (_jsxs(_Fragment, { children: [displayReadEditCell && (_jsx(Cell, { className: "cell", style: Object.assign(__assign({}, getActionCellSizeProps(actionColumn))) })), (actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.addRowNumbers) && (_jsx(Cell, { className: "cell", style: Object.assign(__assign({}, getActionCellSizeProps(actionColumn))) }))] })), getStickyComponent(columns, 'left', displayColumnsWidth), columns
|
|
38
48
|
.filter(function (item) { return !item.sticky; })
|
|
39
|
-
.map(function (column,
|
|
40
|
-
var
|
|
41
|
-
|
|
49
|
+
.map(function (column, index) { return (_jsx(Draggable, { draggableId: column.name, index: index, isDragDisabled: isDragDisabled || column.sticky, children: function (_a) {
|
|
50
|
+
var _b;
|
|
51
|
+
var innerRef = _a.innerRef, draggableProps = _a.draggableProps, dragHandleProps = _a.dragHandleProps;
|
|
52
|
+
var hasResize = columnLayout == 'normal' || !!columns[index + 1];
|
|
53
|
+
var cellClassName = "cell".concat(getStickyCollClassNames(!!(column === null || column === void 0 ? void 0 : column.sticky), column === null || column === void 0 ? void 0 : column.stickTo), " ").concat(getGroupClassNames(groups[index]));
|
|
54
|
+
return (_jsxs(Cell, __assign({}, getCellSizeProps(column, displayColumnsWidth[column.name]), draggableProps, dragHandleProps, { ref: innerRef, className: cellClassName, children: [_jsx(ColumnTitle, { title: column === null || column === void 0 ? void 0 : column.title, isSortable: !!column.sorting, onSetSort: onSetSort(column.name, column.systemName), sortValue: ((_b = sortingValues.find(function (sorting) { return sorting.column == getSortName(column); })) === null || _b === void 0 ? void 0 : _b.direction) || null }), hasResize && onResizeOut && onResizeOver && (_jsx(Resize, { onResize: onResize(column.name), onResizeOver: onResizeOver, onResizeOut: onResizeOut }))] })));
|
|
42
55
|
} }, column.name)); }), getStickyComponent(columns, 'right', displayColumnsWidth), droppableProvided.placeholder] }))); } }) })) }));
|
|
43
56
|
};
|
|
44
57
|
export default HeadRow;
|
|
@@ -16,6 +16,8 @@ import { Input } from '../../../../Forms/Input/Input';
|
|
|
16
16
|
import { ActionRow } from './components/ActionRow';
|
|
17
17
|
import { i18n } from '@lingui/core';
|
|
18
18
|
import { x } from '@xstyled/styled-components';
|
|
19
|
+
import { RowLayout } from './styles';
|
|
20
|
+
import { getTranslatedValue } from './utils';
|
|
19
21
|
var ManageColumnForm = function (_a) {
|
|
20
22
|
var columns = _a.columns, columnsConfigValues = _a.columnsConfigValues, setColumnsConfigOptions = _a.setColumnsConfigOptions, handleDragEnd = _a.handleDragEnd;
|
|
21
23
|
var _b = useState(''), searchedValue = _b[0], setSearchedValue = _b[1];
|
|
@@ -25,8 +27,15 @@ var ManageColumnForm = function (_a) {
|
|
|
25
27
|
var clear = useCallback(function () {
|
|
26
28
|
setSearchedValue('');
|
|
27
29
|
}, [setSearchedValue]);
|
|
28
|
-
return (_jsxs(x.div, { children: [_jsx(Input, { icon: "search", type: "text", value: searchedValue, placeholder: i18n._({ id: 'manageColumn.searchPlaceholder', message: 'Find column...' }), onChange: onChangeInputValue, onClear: clear, variant: "gray" }), _jsx(DragDropContext, { onDragEnd: handleDragEnd, children: _jsx(Droppable, { droppableId: "droppable", direction: "vertical", isCombineEnabled: false, ignoreContainerClipping: false, children: function (droppableProvided) { return (_jsx(x.div, __assign({ h: "400px", overflowY: "scroll", mt: "20px", ref: droppableProvided.innerRef }, droppableProvided.droppableProps, { children: columns === null || columns === void 0 ? void 0 : columns.map(function (column, index) {
|
|
29
|
-
|
|
30
|
+
return (_jsxs(x.div, { children: [_jsx(Input, { icon: "search", type: "text", value: searchedValue, placeholder: i18n._({ id: 'manageColumn.searchPlaceholder', message: 'Find column...' }), onChange: onChangeInputValue, onClear: clear, variant: "gray" }), _jsx(DragDropContext, { onDragEnd: handleDragEnd, children: _jsx(Droppable, { droppableId: "droppable", direction: "vertical", isCombineEnabled: false, ignoreContainerClipping: false, isDropDisabled: !!searchedValue, children: function (droppableProvided) { return (_jsx(x.div, __assign({ h: "400px", overflowY: "scroll", mt: "20px", ref: droppableProvided.innerRef }, droppableProvided.droppableProps, { children: columns === null || columns === void 0 ? void 0 : columns.map(function (column, index) {
|
|
31
|
+
var translatedValue = getTranslatedValue(column);
|
|
32
|
+
var isVisible = translatedValue &&
|
|
33
|
+
translatedValue.toLocaleLowerCase().includes(searchedValue.toLocaleLowerCase()) &&
|
|
34
|
+
!column.alwaysOn;
|
|
35
|
+
return (_jsx(Draggable, { draggableId: column.name, index: index, isDragDisabled: !!searchedValue, children: function (_a) {
|
|
36
|
+
var innerRef = _a.innerRef, draggableProps = _a.draggableProps, dragHandleProps = _a.dragHandleProps;
|
|
37
|
+
return (_jsx(RowLayout, __assign({ "$isVisible": isVisible }, draggableProps, { ref: innerRef }, dragHandleProps, { children: _jsx(ActionRow, { column: column, columnsConfigValues: columnsConfigValues, setColumnsConfigOptions: setColumnsConfigOptions, translatedValue: translatedValue }, index) })));
|
|
38
|
+
} }, column.name));
|
|
30
39
|
}) }))); } }) })] }));
|
|
31
40
|
};
|
|
32
41
|
export default ManageColumnForm;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { DraggableProps, DraggableProvidedDragHandleProps } from 'react-beautiful-dnd';
|
|
3
2
|
import { ColumnConfig, ColumnDefinition } from '../../../types';
|
|
4
3
|
type ActionRowProps = {
|
|
5
4
|
column: ColumnDefinition;
|
|
@@ -7,10 +6,7 @@ type ActionRowProps = {
|
|
|
7
6
|
setColumnsConfigOptions: (value: React.SetStateAction<{
|
|
8
7
|
[x: string]: ColumnConfig | {};
|
|
9
8
|
}>) => void;
|
|
10
|
-
|
|
11
|
-
innerRef?: Function;
|
|
12
|
-
draggableProps?: DraggableProps | any;
|
|
13
|
-
dragHandleProps?: DraggableProvidedDragHandleProps | null;
|
|
9
|
+
translatedValue: string;
|
|
14
10
|
};
|
|
15
|
-
export declare const ActionRow: ({ column, columnsConfigValues, setColumnsConfigOptions,
|
|
11
|
+
export declare const ActionRow: ({ column, columnsConfigValues, setColumnsConfigOptions, translatedValue }: ActionRowProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
12
|
export {};
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
-
return cooked;
|
|
4
|
-
};
|
|
5
1
|
var __assign = (this && this.__assign) || function () {
|
|
6
2
|
__assign = Object.assign || function(t) {
|
|
7
3
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -13,30 +9,16 @@ var __assign = (this && this.__assign) || function () {
|
|
|
13
9
|
};
|
|
14
10
|
return __assign.apply(this, arguments);
|
|
15
11
|
};
|
|
16
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
-
import { useCallback,
|
|
18
|
-
import { isObject } from 'lodash';
|
|
19
|
-
import styled from 'styled-components';
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
+
import { useCallback, useState } from 'react';
|
|
20
14
|
import { Group } from '../../../../../Elements/Icon/icons/Group';
|
|
21
15
|
import Toggle from '../../../../../Elements/Toggle/Toggle';
|
|
22
16
|
import { H6 } from '../../../../../Elements/Typography/Typography';
|
|
23
|
-
import {
|
|
24
|
-
import { x, th } from '@xstyled/styled-components';
|
|
25
|
-
var RowLayout = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: ", ";\n align-items: center;\n justify-content: space-between;\n padding: 16px;\n height: 52px;\n background-color: white;\n border: 1px solid ", ";\n border-radius: 8px;\n margin-bottom: 15px;\n"], ["\n display: ", ";\n align-items: center;\n justify-content: space-between;\n padding: 16px;\n height: 52px;\n background-color: white;\n border: 1px solid ", ";\n border-radius: 8px;\n margin-bottom: 15px;\n"])), function (_a) {
|
|
26
|
-
var $isVisible = _a.$isVisible;
|
|
27
|
-
return ($isVisible ? 'flex' : 'none');
|
|
28
|
-
}, th.color('lightGray6'));
|
|
17
|
+
import { x } from '@xstyled/styled-components';
|
|
29
18
|
export var ActionRow = function (_a) {
|
|
30
|
-
var _b
|
|
31
|
-
var column = _a.column, columnsConfigValues = _a.columnsConfigValues, setColumnsConfigOptions = _a.setColumnsConfigOptions,
|
|
32
|
-
var
|
|
33
|
-
var style = useMemo(function () { return (__assign({}, draggableProps === null || draggableProps === void 0 ? void 0 : draggableProps.style)); }, [draggableProps]);
|
|
34
|
-
var translatedValue = (isObject(column === null || column === void 0 ? void 0 : column.title) &&
|
|
35
|
-
'props' in column.title &&
|
|
36
|
-
((_c = column.title) === null || _c === void 0 ? void 0 : _c.props) &&
|
|
37
|
-
i18n._({ id: (_e = (_d = column.title) === null || _d === void 0 ? void 0 : _d.props) === null || _e === void 0 ? void 0 : _e.id, message: (_f = column.title) === null || _f === void 0 ? void 0 : _f.props.message })) ||
|
|
38
|
-
(column === null || column === void 0 ? void 0 : column.title);
|
|
39
|
-
var isVisible = translatedValue && translatedValue.toLocaleLowerCase().includes(searchedValue.toLocaleLowerCase()) && !column.alwaysOn;
|
|
19
|
+
var _b;
|
|
20
|
+
var column = _a.column, columnsConfigValues = _a.columnsConfigValues, setColumnsConfigOptions = _a.setColumnsConfigOptions, translatedValue = _a.translatedValue;
|
|
21
|
+
var _c = useState((_b = columnsConfigValues === null || columnsConfigValues === void 0 ? void 0 : columnsConfigValues.includes(column.name)) !== null && _b !== void 0 ? _b : false), isSelected = _c[0], setIsSelected = _c[1];
|
|
40
22
|
var handleToggleChange = useCallback(function () {
|
|
41
23
|
setColumnsConfigOptions(function (prevOptions) {
|
|
42
24
|
var _a;
|
|
@@ -44,6 +26,5 @@ export var ActionRow = function (_a) {
|
|
|
44
26
|
});
|
|
45
27
|
setIsSelected(!isSelected);
|
|
46
28
|
}, [setColumnsConfigOptions, isSelected, column.name]);
|
|
47
|
-
return (_jsxs(
|
|
29
|
+
return (_jsxs(_Fragment, { children: [_jsxs(x.div, { display: "flex", alignItems: "center", children: [_jsx(x.div, { w: "28px", children: _jsx(Toggle, { name: "", variant: "grid", onChange: handleToggleChange, spaceAround: false, checked: isSelected }) }), _jsx(H6, { variant: "medium", ml: "8px", children: translatedValue })] }), _jsx(Group, {})] }));
|
|
48
30
|
};
|
|
49
|
-
var templateObject_1;
|
|
@@ -0,0 +1,10 @@
|
|
|
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, { th } from '@xstyled/styled-components';
|
|
6
|
+
export var RowLayout = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: ", ";\n align-items: center;\n justify-content: space-between;\n padding: 16px;\n height: 52px;\n background-color: white;\n border: 1px solid ", ";\n border-radius: 8px;\n margin-bottom: 15px;\n"], ["\n display: ", ";\n align-items: center;\n justify-content: space-between;\n padding: 16px;\n height: 52px;\n background-color: white;\n border: 1px solid ", ";\n border-radius: 8px;\n margin-bottom: 15px;\n"])), function (_a) {
|
|
7
|
+
var $isVisible = _a.$isVisible;
|
|
8
|
+
return ($isVisible ? 'flex' : 'none');
|
|
9
|
+
}, th.color('lightGray6'));
|
|
10
|
+
var templateObject_1;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { i18n } from '@lingui/core';
|
|
2
|
+
import isObject from 'lodash/isObject';
|
|
3
|
+
export var getTranslatedValue = function (column) {
|
|
4
|
+
var _a, _b, _c, _d;
|
|
5
|
+
return column && isObject(column === null || column === void 0 ? void 0 : column.title)
|
|
6
|
+
? 'props' in column.title &&
|
|
7
|
+
((_a = column.title) === null || _a === void 0 ? void 0 : _a.props) &&
|
|
8
|
+
i18n._({ id: (_c = (_b = column.title) === null || _b === void 0 ? void 0 : _b.props) === null || _c === void 0 ? void 0 : _c.id, message: (_d = column.title) === null || _d === void 0 ? void 0 : _d.props.message })
|
|
9
|
+
: column === null || column === void 0 ? void 0 : column.title;
|
|
10
|
+
};
|
|
@@ -23,7 +23,7 @@ export var PresetsModalBody = function (_a) {
|
|
|
23
23
|
var onOpenCreatePresetModal = _a.onOpenCreatePresetModal, gridPresets = _a.gridPresets, handleSelectPreset = _a.handleSelectPreset, handleOpenDeletePresetModal = _a.handleOpenDeletePresetModal, selectedPresetName = _a.selectedPresetName, handleExportPresets = _a.handleExportPresets, handleImportButtonClick = _a.handleImportButtonClick, handleImportPresets = _a.handleImportPresets, fileInputRef = _a.fileInputRef, filters = _a.filters;
|
|
24
24
|
var presets = useMemo(function () { return Object.entries(gridPresets || {}); }, [gridPresets]);
|
|
25
25
|
var hasPresets = !!(presets === null || presets === void 0 ? void 0 : presets.length);
|
|
26
|
-
return (_jsxs(x.div, { children: [_jsx(x.div, { display: "flex", rowGap: "12px", children: hasPresets ? (presets === null || presets === void 0 ? void 0 : presets.map(function (_a, index) {
|
|
26
|
+
return (_jsxs(x.div, { children: [_jsx(x.div, { display: "flex", rowGap: "12px", flexWrap: "wrap", children: hasPresets ? (presets === null || presets === void 0 ? void 0 : presets.map(function (_a, index) {
|
|
27
27
|
var presetName = _a[0], filters = _a[1];
|
|
28
28
|
var isSelected = presetName === selectedPresetName;
|
|
29
29
|
return (_jsxs(Tag, __assign({ size: "big", onClick: handleSelectPreset(presetName, filters) }, (isSelected ? palletes.redWhite : palletes.redRed), { pointer: true, children: [_jsx(H6, { mt: 0, mb: 0, variant: "semiBold", children: presetName }), _jsx(x.div, { ml: "12px", h: "fit-content", onClick: handleOpenDeletePresetModal(presetName), children: _jsx(Cancel, { fill: isSelected ? 'white' : '#DB2B19' }) })] }), "".concat(presetName, "_").concat(index)));
|
|
@@ -1,12 +1,23 @@
|
|
|
1
|
-
export declare const
|
|
2
|
-
hasRowClick
|
|
1
|
+
export declare const Row: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
|
|
2
|
+
hasRowClick?: boolean | undefined;
|
|
3
|
+
accountForScrollbar?: boolean | undefined;
|
|
4
|
+
align?: string | undefined;
|
|
3
5
|
}, never>;
|
|
4
|
-
export declare const
|
|
5
|
-
|
|
6
|
+
export declare const Cell: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
|
|
7
|
+
align?: string | undefined;
|
|
8
|
+
}, never>;
|
|
9
|
+
export declare const StyledDataRow: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
|
|
10
|
+
hasRowClick?: boolean | undefined;
|
|
11
|
+
accountForScrollbar?: boolean | undefined;
|
|
12
|
+
align?: string | undefined;
|
|
13
|
+
} & {
|
|
6
14
|
isEven: boolean;
|
|
7
15
|
}, never>;
|
|
8
|
-
export declare const
|
|
9
|
-
|
|
10
|
-
|
|
16
|
+
export declare const TextCell: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
|
|
17
|
+
align?: string | undefined;
|
|
18
|
+
}, never>;
|
|
19
|
+
export declare const MessageCell: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
|
|
20
|
+
align?: string | undefined;
|
|
21
|
+
} & {
|
|
11
22
|
width: number;
|
|
12
23
|
}, never>;
|
|
@@ -2,24 +2,10 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
|
|
2
2
|
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
3
|
return cooked;
|
|
4
4
|
};
|
|
5
|
-
var __assign = (this && this.__assign) || function () {
|
|
6
|
-
__assign = Object.assign || function(t) {
|
|
7
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
-
s = arguments[i];
|
|
9
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
-
t[p] = s[p];
|
|
11
|
-
}
|
|
12
|
-
return t;
|
|
13
|
-
};
|
|
14
|
-
return __assign.apply(this, arguments);
|
|
15
|
-
};
|
|
16
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
5
|
import styled, { system, th } from '@xstyled/styled-components';
|
|
18
|
-
export var
|
|
19
|
-
export var
|
|
20
|
-
var StyledCell = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n ", ";\n display: flex;\n overflow: hidden;\n align-items: center;\n justify-content: ", ";\n"], ["\n ", ";\n display: flex;\n overflow: hidden;\n align-items: center;\n justify-content: ", ";\n"])), system, function (props) { return props.align; });
|
|
6
|
+
export var Row = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n ", ";\n display: flex;\n min-height: 32px;\n border-bottom: 1px solid rgb(228, 231, 235);\n cursor: ", ";\n"], ["\n ", ";\n display: flex;\n min-height: 32px;\n border-bottom: 1px solid rgb(228, 231, 235);\n cursor: ", ";\n"])), system, function (props) { return (props.hasRowClick ? 'pointer' : 'cursor'); });
|
|
7
|
+
export var Cell = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n ", ";\n display: flex;\n overflow: hidden;\n align-items: center;\n justify-content: ", ";\n"], ["\n ", ";\n display: flex;\n overflow: hidden;\n align-items: center;\n justify-content: ", ";\n"])), system, function (props) { return props.align; });
|
|
21
8
|
export var StyledDataRow = styled(Row)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n background-color: ", ";\n"], ["\n background-color: ", ";\n"])), function (props) { return (props.isEven ? th('colors.bgLightGray') : 'white'); });
|
|
22
|
-
export var Cell = function (props) { return _jsx(StyledCell, __assign({ ref: props.innerRef }, props)); };
|
|
23
9
|
export var TextCell = styled(Cell)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n text-overflow: ellipsis;\n white-space: nowrap;\n"], ["\n text-overflow: ellipsis;\n white-space: nowrap;\n"])));
|
|
24
10
|
export var MessageCell = styled(Cell)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n width: ", "px;\n position: sticky;\n left: 0;\n"], ["\n width: ", "px;\n position: sticky;\n left: 0;\n"])), function (props) { return props.width; });
|
|
25
11
|
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { MouseEvent } from 'react';
|
|
1
2
|
type Props = {
|
|
2
|
-
handleRowClick: (e: MouseEvent) => void;
|
|
3
|
+
handleRowClick: (e: MouseEvent<HTMLDivElement>) => void;
|
|
3
4
|
};
|
|
4
5
|
export declare const useTimeMeasurement: ({ handleRowClick }: Props) => {
|
|
5
6
|
handleMouseDown: () => void;
|
|
6
|
-
handleMouseUp: (e: MouseEvent) => void;
|
|
7
|
+
handleMouseUp: (e: MouseEvent<HTMLDivElement>) => void;
|
|
7
8
|
};
|
|
8
9
|
export {};
|
|
@@ -80,7 +80,7 @@ var useManageColumn = function (_a) {
|
|
|
80
80
|
if (to === from || !destination) {
|
|
81
81
|
return;
|
|
82
82
|
}
|
|
83
|
-
var columns = isManageModal ? manageColumnsFormDefinitions : displayColumnsDefinitions;
|
|
83
|
+
var columns = isManageModal ? manageColumnsFormDefinitions : displayColumnsDefinitions.filter(function (item) { return !item.sticky; });
|
|
84
84
|
var newOrderColumns = __spreadArray([], (isManageModal ? updatedColumnsOrder : columnsOrderValue), true);
|
|
85
85
|
var fromIndex = newOrderColumns.findIndex(function (column) { return columns[from].name === column; });
|
|
86
86
|
var toIndex = newOrderColumns.findIndex(function (column) { return columns[to !== null && to !== void 0 ? to : 0].name === column; });
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
-
import { isObject } from 'lodash';
|
|
3
2
|
import { useCheckDeviceWidth } from '../../../utils/CheckDeviceWidth/checkDeviceWidth';
|
|
3
|
+
import { getTranslatedValue } from '../components/ManageColumnForm/utils';
|
|
4
4
|
import { createFilterType } from '../utils';
|
|
5
|
-
import { i18n } from '@lingui/core';
|
|
6
5
|
import { useAddFilter } from './useAddFilter';
|
|
7
6
|
var defaultVoidFunction = function () {
|
|
8
7
|
var args = [];
|
|
@@ -12,13 +11,13 @@ var defaultVoidFunction = function () {
|
|
|
12
11
|
return null;
|
|
13
12
|
};
|
|
14
13
|
var useQuickFilter = function (_a) {
|
|
15
|
-
var _b, _c
|
|
14
|
+
var _b, _c;
|
|
16
15
|
var gridActions = _a.gridActions, gridSelectors = _a.gridSelectors, quickFilter = _a.quickFilter, displayColumnsDefinitions = _a.displayColumnsDefinitions, filters = _a.filters;
|
|
17
|
-
var resetFilters = gridActions.resetFilters,
|
|
16
|
+
var resetFilters = gridActions.resetFilters, _d = gridActions.addFilter, addFilter = _d === void 0 ? defaultVoidFunction : _d;
|
|
18
17
|
var filter = gridSelectors.filter;
|
|
19
18
|
var isMobile = useCheckDeviceWidth().isMobile;
|
|
20
|
-
var
|
|
21
|
-
var
|
|
19
|
+
var _e = useState(''), searchedValue = _e[0], setSearchedValue = _e[1];
|
|
20
|
+
var _f = useState(false), displayInput = _f[0], setDisplayInput = _f[1];
|
|
22
21
|
var handleAddFilter = useAddFilter(addFilter);
|
|
23
22
|
var quickFilterValues = quickFilter ? (_b = filter === null || filter === void 0 ? void 0 : filter[quickFilter]) === null || _b === void 0 ? void 0 : _b.value : undefined;
|
|
24
23
|
var searchedColumnsDefinitions = (displayColumnsDefinitions === null || displayColumnsDefinitions === void 0 ? void 0 : displayColumnsDefinitions.find(function (item) { return item.name === quickFilter; })) || null;
|
|
@@ -67,11 +66,7 @@ var useQuickFilter = function (_a) {
|
|
|
67
66
|
resetFilters === null || resetFilters === void 0 ? void 0 : resetFilters();
|
|
68
67
|
setSearchedValue === null || setSearchedValue === void 0 ? void 0 : setSearchedValue('');
|
|
69
68
|
}, [resetFilters, setSearchedValue]);
|
|
70
|
-
var translatedValue =
|
|
71
|
-
? 'props' in (searchedColumnsDefinitions === null || searchedColumnsDefinitions === void 0 ? void 0 : searchedColumnsDefinitions.title) &&
|
|
72
|
-
((_d = searchedColumnsDefinitions.title) === null || _d === void 0 ? void 0 : _d.props) &&
|
|
73
|
-
i18n._({ id: (_f = (_e = searchedColumnsDefinitions.title) === null || _e === void 0 ? void 0 : _e.props) === null || _f === void 0 ? void 0 : _f.id, message: (_g = searchedColumnsDefinitions.title) === null || _g === void 0 ? void 0 : _g.props.message })
|
|
74
|
-
: searchedColumnsDefinitions === null || searchedColumnsDefinitions === void 0 ? void 0 : searchedColumnsDefinitions.title;
|
|
69
|
+
var translatedValue = getTranslatedValue(searchedColumnsDefinitions);
|
|
75
70
|
return {
|
|
76
71
|
searchedValue: searchedValue,
|
|
77
72
|
translatedValue: translatedValue,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
-
import { isEqual } from 'lodash';
|
|
3
2
|
import { presetsLocalStorageKey } from '../utils/constants';
|
|
3
|
+
import isEqual from 'lodash/isEqual';
|
|
4
4
|
var getInitialPresets = function (gridName) {
|
|
5
5
|
var _a;
|
|
6
6
|
if (!gridName)
|
|
@@ -16,21 +16,13 @@ var getInitialPresets = function (gridName) {
|
|
|
16
16
|
};
|
|
17
17
|
export var useSelectPreset = function (_a) {
|
|
18
18
|
var gridName = _a.gridName, gridActions = _a.gridActions, setSelectedPresetName = _a.setSelectedPresetName, onClosePresetsModal = _a.onClosePresetsModal, filters = _a.filters;
|
|
19
|
-
var _b = useState(
|
|
20
|
-
var _c = useState(getInitialPresets(gridName)), gridPresets = _c[0], setGridPresets = _c[1];
|
|
19
|
+
var _b = useState(getInitialPresets(gridName)), gridPresets = _b[0], setGridPresets = _b[1];
|
|
21
20
|
var handleSelectPreset = useCallback(function (presetName, filters) { return function () {
|
|
22
21
|
var _a;
|
|
23
22
|
setSelectedPresetName(presetName);
|
|
24
23
|
(_a = gridActions.setFilters) === null || _a === void 0 ? void 0 : _a.call(gridActions, filters);
|
|
25
24
|
onClosePresetsModal();
|
|
26
|
-
setIsFilterChangeFromButton(true);
|
|
27
25
|
}; }, [gridActions]);
|
|
28
|
-
useEffect(function () {
|
|
29
|
-
if (!isFilterChangeFromButton) {
|
|
30
|
-
setSelectedPresetName('');
|
|
31
|
-
}
|
|
32
|
-
setIsFilterChangeFromButton(false);
|
|
33
|
-
}, [filters]);
|
|
34
26
|
useEffect(function () {
|
|
35
27
|
var _a;
|
|
36
28
|
if (!gridName || !gridPresets)
|
|
@@ -39,9 +31,7 @@ export var useSelectPreset = function (_a) {
|
|
|
39
31
|
var presetName = _a[0], presetFilters = _a[1];
|
|
40
32
|
return isEqual(presetFilters, filters);
|
|
41
33
|
});
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
}, []);
|
|
34
|
+
activePreset ? setSelectedPresetName(activePreset[0]) : setSelectedPresetName('');
|
|
35
|
+
}, [filters]);
|
|
46
36
|
return { gridPresets: gridPresets, setGridPresets: setGridPresets, handleSelectPreset: handleSelectPreset };
|
|
47
37
|
};
|
|
@@ -5,7 +5,7 @@ export declare const BottomWrapper: import("styled-components").StyledComponent<
|
|
|
5
5
|
export declare const ContentContainer: import("styled-components").StyledComponent<(props: Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "color">) => import("react").ReactElement<any, "div">, import("@xstyled/system").Theme, import("@xstyled/system").SystemProps<import("@xstyled/system").Theme>, "color">;
|
|
6
6
|
export declare const CommonGridWrap: import("styled-components").StyledComponent<(props: Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "color">) => import("react").ReactElement<any, "div">, import("@xstyled/system").Theme, import("@xstyled/system").SystemProps<import("@xstyled/system").Theme>, "color">;
|
|
7
7
|
export declare const StyledButtonStrip: import("styled-components").StyledComponent<(props: Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "color">) => import("react").ReactElement<any, "div">, import("@xstyled/system").Theme, import("@xstyled/system").SystemProps<import("@xstyled/system").Theme>, "color">;
|
|
8
|
-
export declare const CommonGridWithStyles: import("styled-components").StyledComponent<({ filters, comparators, handleDragEnd, gridSelectors, gridActions, isLoading, rowsData, hasColouredRows, columnsDefinitions, actionColumnDefinition, allowRowSelect, allowRowSelectOnAction, onRowAction, onRowEditClick, onRowReadClick, onRowClick, columnLayout, displayColumnsDefinitions, className, gridRef, minColumnWidth, errorMessage, floatingButtonProps
|
|
8
|
+
export declare const CommonGridWithStyles: import("styled-components").StyledComponent<({ filters, comparators, handleDragEnd, gridSelectors, gridActions, isLoading, rowsData, hasColouredRows, columnsDefinitions, actionColumnDefinition, allowRowSelect, allowRowSelectOnAction, onRowAction, onRowEditClick, onRowReadClick, onRowClick, columnLayout, displayColumnsDefinitions, className, gridRef, minColumnWidth, errorMessage, floatingButtonProps }: import("./types").CommonGridProps & {
|
|
9
9
|
filters?: import("./types").FiltersConfig | undefined;
|
|
10
10
|
handleDragEnd: (item: import("react-beautiful-dnd").DropResult) => void;
|
|
11
11
|
displayColumnsDefinitions: import("./types").ColumnDefinition[];
|
|
@@ -46,7 +46,7 @@ export type FilterComponentProps<VT> = {
|
|
|
46
46
|
export type ColumnTitleComponentType = React.ComponentType<{
|
|
47
47
|
title?: string | JSX.Element;
|
|
48
48
|
isSortable: boolean;
|
|
49
|
-
onSetSort
|
|
49
|
+
onSetSort?: (value: SortingValueType) => void;
|
|
50
50
|
sortValue: SortingValueType;
|
|
51
51
|
}>;
|
|
52
52
|
export type ComponentsProps = {
|