@mailstep/design-system 0.7.53 → 0.7.54
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 +3 -4
- package/ui/Blocks/CommonGrid/CommonGrid.d.ts +2 -2
- package/ui/Blocks/CommonGrid/CommonGrid.js +1 -1
- package/ui/Blocks/CommonGrid/components/GridModals/index.d.ts +3 -3
- package/ui/Blocks/CommonGrid/components/HeadRow.d.ts +5 -4
- package/ui/Blocks/CommonGrid/components/HeadRow.js +13 -12
- package/ui/Blocks/CommonGrid/components/ManageColumnForm/ManageColumnForm.d.ts +8 -7
- package/ui/Blocks/CommonGrid/components/ManageColumnForm/ManageColumnForm.js +25 -10
- package/ui/Blocks/CommonGrid/components/ManageColumnForm/components/ActionRow.d.ts +12 -0
- package/ui/Blocks/CommonGrid/components/ManageColumnForm/components/ActionRow.js +30 -0
- package/ui/Blocks/CommonGrid/components/ManageColumnForm/styles.d.ts +0 -2
- package/ui/Blocks/CommonGrid/components/ManageColumnForm/styles.js +2 -8
- package/ui/Blocks/CommonGrid/components/Table.d.ts +2 -6
- package/ui/Blocks/CommonGrid/components/Table.js +1 -1
- package/ui/Blocks/CommonGrid/hooks/useManageColumn.d.ts +2 -2
- package/ui/Blocks/CommonGrid/hooks/useManageColumn.js +12 -11
- package/ui/Blocks/CommonGrid/storybook/utils/columnDefinition.js +13 -21
- package/ui/Blocks/CommonGrid/storybook/utils/withRedux.d.ts +0 -1
- package/ui/Blocks/CommonGrid/storybook/utils/withRedux.js +3 -5
- package/ui/Blocks/CommonGrid/styles.d.ts +1 -1
- package/ui/Elements/ErrorMessage/ErrorMessage.js +1 -1
- package/ui/index.es.js +27169 -23951
- package/ui/index.umd.js +822 -653
- package/ui/Blocks/CommonGrid/components/HeadCell.d.ts +0 -16
- package/ui/Blocks/CommonGrid/components/HeadCell.js +0 -29
- package/ui/Blocks/CommonGrid/components/ManageColumnForm/components/ManageColumnRow.d.ts +0 -11
- package/ui/Blocks/CommonGrid/components/ManageColumnForm/components/ManageColumnRow.js +0 -41
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mailstep/design-system",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.54",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./ui/index.js",
|
|
@@ -84,6 +84,7 @@
|
|
|
84
84
|
"moment": "^2.30.1",
|
|
85
85
|
"prettier": "2.8.8",
|
|
86
86
|
"react": "^18.2.0",
|
|
87
|
+
"react-beautiful-dnd": "^13.0.0",
|
|
87
88
|
"react-dom": "^18.2.0",
|
|
88
89
|
"react-helmet": "^6.1.0",
|
|
89
90
|
"react-image": "^4.1.0",
|
|
@@ -109,9 +110,6 @@
|
|
|
109
110
|
"webpack": "^5.82.1"
|
|
110
111
|
},
|
|
111
112
|
"peerDependencies": {
|
|
112
|
-
"@dnd-kit/core": "^6.3.1",
|
|
113
|
-
"@dnd-kit/modifiers": "^9.0.0",
|
|
114
|
-
"@dnd-kit/sortable": "^10.0.0",
|
|
115
113
|
"@fortawesome/fontawesome-svg-core": "^6.3.0",
|
|
116
114
|
"@fortawesome/free-brands-svg-icons": "^6.1.1",
|
|
117
115
|
"@fortawesome/pro-duotone-svg-icons": "^6.0.0",
|
|
@@ -129,6 +127,7 @@
|
|
|
129
127
|
"luxon": "^3.4.4",
|
|
130
128
|
"moment": "^2.30.1",
|
|
131
129
|
"react": "^18.2.0",
|
|
130
|
+
"react-beautiful-dnd": "^13.0.0",
|
|
132
131
|
"react-dom": "^18.2.0",
|
|
133
132
|
"react-helmet": "^6.1.0",
|
|
134
133
|
"react-image": "^4.1.0",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { DropResult } from 'react-beautiful-dnd';
|
|
2
2
|
import type { CommonGridProps, FiltersConfig, ColumnDefinition } from './types';
|
|
3
3
|
type Props = CommonGridProps & {
|
|
4
4
|
filters?: FiltersConfig;
|
|
5
|
-
handleDragEnd: (item:
|
|
5
|
+
handleDragEnd: (item: DropResult) => void;
|
|
6
6
|
displayColumnsDefinitions: ColumnDefinition[];
|
|
7
7
|
hasGroups: boolean;
|
|
8
8
|
hasFilters: boolean;
|
|
@@ -62,7 +62,7 @@ var CommonGrid = function (_a) {
|
|
|
62
62
|
var commonGridRef = React.useCallback(function (node) {
|
|
63
63
|
gridBoxRef.current = node;
|
|
64
64
|
}, []);
|
|
65
|
-
return (_jsxs(_Fragment, { children: [_jsx(x.div, { className: className || '', children: _jsxs(OversizedScroll, { columnLayout: columnLayout, isLoading: isLoading, totalColumnsWidth: totalColumnsWidth, floatingChildren: GridMessage && (_jsx(Row, { className: "dataRow", align: "center", children: _jsx(MessageCell, { align: "center", className: "gridMessage ".concat(messageClass), width: window.innerWidth, children: GridMessage }) })), ref: commonGridRef, children: [_jsxs("div", { className: "gridHead", children: [hasGroups && (_jsx(GroupRow, { actionColumn: actionColumnDefinition, columns: displayColumnsDefinitions, displayColumnsWidth: displayColumnsWidth, groups: groups })), _jsx(HeadRow, { columns: displayColumnsDefinitions, onAddSort: addSorting, columnLayout: columnLayout, sortingValues: sorting, displayColumnsWidth: displayColumnsWidth, handleResizeDrag: handleResizeDrag, groups: groups, handleDragEnd: handleDragEnd }), hasFilters && (_jsx(FilterRow, { filters: filters, comparators: comparators, columns: displayColumnsDefinitions, actionColumn: actionColumnDefinition, onChange: addFilter, filterValues: filter, displayColumnsWidth: displayColumnsWidth, groups: groups, rowsData: rowsData, uxState: uxState, handleUxChange: handleUxChange }))] }), _jsx("div", { className: "body flx_1", style: rowsStyles, tabIndex: -1, onKeyDown: handleRowsKeyDown, children: !isLoading &&
|
|
65
|
+
return (_jsxs(_Fragment, { children: [_jsx(x.div, { className: className || '', children: _jsxs(OversizedScroll, { columnLayout: columnLayout, isLoading: isLoading, totalColumnsWidth: totalColumnsWidth, floatingChildren: GridMessage && (_jsx(Row, { className: "dataRow", align: "center", children: _jsx(MessageCell, { align: "center", className: "gridMessage ".concat(messageClass), width: window.innerWidth, children: GridMessage }) })), ref: commonGridRef, children: [_jsxs("div", { className: "gridHead", children: [hasGroups && (_jsx(GroupRow, { actionColumn: actionColumnDefinition, columns: displayColumnsDefinitions, displayColumnsWidth: displayColumnsWidth, groups: groups })), _jsx(HeadRow, { columns: displayColumnsDefinitions, actionColumn: actionColumnDefinition, onAddSort: addSorting, columnLayout: columnLayout, sortingValues: sorting, displayColumnsWidth: displayColumnsWidth, handleResizeDrag: handleResizeDrag, groups: groups, handleDragEnd: handleDragEnd }), hasFilters && (_jsx(FilterRow, { filters: filters, comparators: comparators, columns: displayColumnsDefinitions, actionColumn: actionColumnDefinition, onChange: addFilter, filterValues: filter, displayColumnsWidth: displayColumnsWidth, groups: groups, rowsData: rowsData, uxState: uxState, handleUxChange: handleUxChange }))] }), _jsx("div", { className: "body flx_1", style: rowsStyles, tabIndex: -1, onKeyDown: handleRowsKeyDown, children: !isLoading &&
|
|
66
66
|
rowsData &&
|
|
67
67
|
displayColumnsDefinitions &&
|
|
68
68
|
rowsData.map(function (row, index) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { type FC } from 'react';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import { DropResult } from 'react-beautiful-dnd';
|
|
3
|
+
import { ColumnConfig, ColumnDefinition, GridActionsType, GridSelectorsType } from '../../types';
|
|
4
4
|
type ModalsProps = {
|
|
5
5
|
manageColumnFormVisible: boolean;
|
|
6
6
|
onCloseForm: () => void;
|
|
@@ -9,7 +9,7 @@ type ModalsProps = {
|
|
|
9
9
|
manageColumnsFormDefinitions: ColumnDefinition[];
|
|
10
10
|
columnsConfigValues: string[];
|
|
11
11
|
setColumnsConfigOptions: (value: React.SetStateAction<Record<string, ColumnConfig | {}>>) => void;
|
|
12
|
-
handleDragEnd: (item:
|
|
12
|
+
handleDragEnd: (item: DropResult) => void;
|
|
13
13
|
gridName?: string;
|
|
14
14
|
gridSelectors: GridSelectorsType;
|
|
15
15
|
gridActions: GridActionsType;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { DropResult } from 'react-beautiful-dnd';
|
|
2
|
+
import type { Settings, ColumnDefinition, ActionColumn, GridSelectorsType, Group, CommonGridProps, GridActionsType } from '../types';
|
|
3
3
|
type HeadRowProps = {
|
|
4
|
+
actionColumn?: ActionColumn;
|
|
4
5
|
columns: ColumnDefinition[];
|
|
5
6
|
onAddSort: GridActionsType['addSorting'];
|
|
6
7
|
sortingValues?: Settings['sorting'];
|
|
7
8
|
displayColumnsWidth: Required<GridSelectorsType>['columnsWidth'];
|
|
8
9
|
columnLayout: Required<CommonGridProps>['columnLayout'];
|
|
9
10
|
handleResizeDrag: (column: string, width: number) => void;
|
|
10
|
-
handleDragEnd: (
|
|
11
|
+
handleDragEnd: (item: DropResult) => void;
|
|
11
12
|
groups: Group[];
|
|
12
13
|
};
|
|
13
|
-
declare const HeadRow: ({ columns, onAddSort, handleDragEnd, sortingValues, displayColumnsWidth, columnLayout, handleResizeDrag, groups }: HeadRowProps) => JSX.Element;
|
|
14
|
+
declare const HeadRow: ({ columns, actionColumn, onAddSort, handleDragEnd, sortingValues, displayColumnsWidth, columnLayout, handleResizeDrag, groups }: HeadRowProps) => JSX.Element;
|
|
14
15
|
export default HeadRow;
|
|
@@ -11,11 +11,10 @@ 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, { useEffect, useState } from 'react';
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import { SortableContext, horizontalListSortingStrategy } from '@dnd-kit/sortable';
|
|
14
|
+
import { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd';
|
|
15
|
+
import { getCellSizeProps, getGroupClassNames, getSortName, getStickyCollClassNames } from '../utils';
|
|
17
16
|
import ColumnTitle from './ColumnTitle';
|
|
18
|
-
import
|
|
17
|
+
import Resize from './Resize';
|
|
19
18
|
import { Row, Cell } from './Table';
|
|
20
19
|
var getStickyComponent = function (columns, stickyTo, displayColumnsWidth) {
|
|
21
20
|
var _a;
|
|
@@ -25,7 +24,7 @@ var getStickyComponent = function (columns, stickyTo, displayColumnsWidth) {
|
|
|
25
24
|
});
|
|
26
25
|
};
|
|
27
26
|
var HeadRow = function (_a) {
|
|
28
|
-
var columns = _a.columns, onAddSort = _a.onAddSort, handleDragEnd = _a.handleDragEnd, _b = _a.sortingValues, sortingValues = _b === void 0 ? [] : _b, displayColumnsWidth = _a.displayColumnsWidth, columnLayout = _a.columnLayout, handleResizeDrag = _a.handleResizeDrag, groups = _a.groups;
|
|
27
|
+
var columns = _a.columns, actionColumn = _a.actionColumn, onAddSort = _a.onAddSort, handleDragEnd = _a.handleDragEnd, _b = _a.sortingValues, sortingValues = _b === void 0 ? [] : _b, displayColumnsWidth = _a.displayColumnsWidth, columnLayout = _a.columnLayout, handleResizeDrag = _a.handleResizeDrag, groups = _a.groups;
|
|
29
28
|
var _c = useState(false), showUIElements = _c[0], setShowUIElements = _c[1];
|
|
30
29
|
useEffect(function () {
|
|
31
30
|
setShowUIElements(true);
|
|
@@ -41,14 +40,16 @@ var HeadRow = function (_a) {
|
|
|
41
40
|
handleResizeDrag === null || handleResizeDrag === void 0 ? void 0 : handleResizeDrag(name, width);
|
|
42
41
|
}; }, [handleResizeDrag]);
|
|
43
42
|
var onSetSort = React.useCallback(function (name, systemName) { return function (value) {
|
|
44
|
-
onAddSort
|
|
43
|
+
onAddSort && onAddSort(systemName || name, value);
|
|
45
44
|
}; }, [onAddSort]);
|
|
46
|
-
|
|
47
|
-
return (_jsx(_Fragment, { children: showUIElements && (_jsx(DndContext, { sensors: sensors, collisionDetection: closestCenter, onDragEnd: handleDragEnd, children: _jsx(SortableContext, { items: columns.map(function (_a) {
|
|
48
|
-
var name = _a.name;
|
|
49
|
-
return name;
|
|
50
|
-
}), strategy: horizontalListSortingStrategy, children: _jsxs(Row, { className: "headRow", children: [getStickyComponent(columns, 'left', displayColumnsWidth), columns
|
|
45
|
+
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: [getStickyComponent(columns, 'left', displayColumnsWidth), columns
|
|
51
46
|
.filter(function (item) { return !item.sticky; })
|
|
52
|
-
.map(function (column, index) { return (_jsx(
|
|
47
|
+
.map(function (column, index) { return (_jsx(Draggable, { draggableId: column.name, index: index, isDragDisabled: isDragDisabled || column.sticky, children: function (_a) {
|
|
48
|
+
var _b;
|
|
49
|
+
var innerRef = _a.innerRef, draggableProps = _a.draggableProps, dragHandleProps = _a.dragHandleProps;
|
|
50
|
+
var hasResize = columnLayout == 'normal' || !!columns[index + 1];
|
|
51
|
+
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]));
|
|
52
|
+
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 }))] })));
|
|
53
|
+
} }, column.name)); }), getStickyComponent(columns, 'right', displayColumnsWidth), droppableProvided.placeholder] }))); } }) })) }));
|
|
53
54
|
};
|
|
54
55
|
export default HeadRow;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import type { DragEndEvent } from '@dnd-kit/core';
|
|
2
|
+
import { DropResult } from 'react-beautiful-dnd';
|
|
3
|
+
import { ColumnConfig, CommonGridProps } from '../../types';
|
|
5
4
|
type ManageColumnProps = {
|
|
6
|
-
columns
|
|
5
|
+
columns?: CommonGridProps['columnsDefinitions'];
|
|
7
6
|
columnsConfigValues?: string[];
|
|
8
|
-
setColumnsConfigOptions: (value: React.SetStateAction<
|
|
9
|
-
|
|
7
|
+
setColumnsConfigOptions: (value: React.SetStateAction<{
|
|
8
|
+
[x: string]: ColumnConfig | {};
|
|
9
|
+
}>) => void;
|
|
10
|
+
handleDragEnd: (item: DropResult) => void;
|
|
10
11
|
};
|
|
11
|
-
declare const ManageColumnForm:
|
|
12
|
+
declare const ManageColumnForm: ({ columns, columnsConfigValues, setColumnsConfigOptions, handleDragEnd }: ManageColumnProps) => JSX.Element;
|
|
12
13
|
export default ManageColumnForm;
|
|
@@ -1,13 +1,23 @@
|
|
|
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
|
+
};
|
|
1
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
13
|
import { useCallback, useState } from 'react';
|
|
14
|
+
import { DragDropContext, Draggable, Droppable } from 'react-beautiful-dnd';
|
|
3
15
|
import { Input } from '../../../../Forms/Input/Input';
|
|
4
|
-
import {
|
|
5
|
-
import { closestCenter, useSensor, useSensors, DndContext, PointerSensor } from '@dnd-kit/core';
|
|
6
|
-
import { restrictToVerticalAxis } from '@dnd-kit/modifiers';
|
|
7
|
-
import { SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable';
|
|
16
|
+
import { ActionRow } from './components/ActionRow';
|
|
8
17
|
import { i18n } from '@lingui/core';
|
|
9
18
|
import { x } from '@xstyled/styled-components';
|
|
10
|
-
|
|
19
|
+
import { RowLayout } from './styles';
|
|
20
|
+
import { getTranslatedValue } from './utils';
|
|
11
21
|
var ManageColumnForm = function (_a) {
|
|
12
22
|
var columns = _a.columns, columnsConfigValues = _a.columnsConfigValues, setColumnsConfigOptions = _a.setColumnsConfigOptions, handleDragEnd = _a.handleDragEnd;
|
|
13
23
|
var _b = useState(''), searchedValue = _b[0], setSearchedValue = _b[1];
|
|
@@ -17,10 +27,15 @@ var ManageColumnForm = function (_a) {
|
|
|
17
27
|
var clear = useCallback(function () {
|
|
18
28
|
setSearchedValue('');
|
|
19
29
|
}, [setSearchedValue]);
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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));
|
|
39
|
+
}) }))); } }) })] }));
|
|
25
40
|
};
|
|
26
41
|
export default ManageColumnForm;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ColumnConfig, ColumnDefinition } from '../../../types';
|
|
3
|
+
type ActionRowProps = {
|
|
4
|
+
column: ColumnDefinition;
|
|
5
|
+
columnsConfigValues: string[] | undefined;
|
|
6
|
+
setColumnsConfigOptions: (value: React.SetStateAction<{
|
|
7
|
+
[x: string]: ColumnConfig | {};
|
|
8
|
+
}>) => void;
|
|
9
|
+
translatedValue: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const ActionRow: ({ column, columnsConfigValues, setColumnsConfigOptions, translatedValue }: ActionRowProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
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, Fragment as _Fragment } from "react/jsx-runtime";
|
|
13
|
+
import { useCallback, useState } from 'react';
|
|
14
|
+
import { Group } from '../../../../../Elements/Icon/icons/Group';
|
|
15
|
+
import Toggle from '../../../../../Elements/Toggle/Toggle';
|
|
16
|
+
import { H6 } from '../../../../../Elements/Typography/Typography';
|
|
17
|
+
import { x } from '@xstyled/styled-components';
|
|
18
|
+
export var ActionRow = function (_a) {
|
|
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];
|
|
22
|
+
var handleToggleChange = useCallback(function () {
|
|
23
|
+
setColumnsConfigOptions(function (prevOptions) {
|
|
24
|
+
var _a;
|
|
25
|
+
return __assign(__assign({}, prevOptions), (_a = {}, _a[column.name] = !isSelected ? {} : { isHidden: true }, _a));
|
|
26
|
+
});
|
|
27
|
+
setIsSelected(!isSelected);
|
|
28
|
+
}, [setColumnsConfigOptions, isSelected, column.name]);
|
|
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, {})] }));
|
|
30
|
+
};
|
|
@@ -3,14 +3,8 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
|
|
3
3
|
return cooked;
|
|
4
4
|
};
|
|
5
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
|
|
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
7
|
var $isVisible = _a.$isVisible;
|
|
8
8
|
return ($isVisible ? 'flex' : 'none');
|
|
9
|
-
}, th.color('lightGray6')
|
|
10
|
-
var transition = _a.transition;
|
|
11
|
-
return transition;
|
|
12
|
-
}, function (_a) {
|
|
13
|
-
var transform = _a.transform;
|
|
14
|
-
return transform;
|
|
15
|
-
});
|
|
9
|
+
}, th.color('lightGray6'));
|
|
16
10
|
var templateObject_1;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const Row: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
|
|
2
2
|
hasRowClick?: boolean | undefined;
|
|
3
|
+
accountForScrollbar?: boolean | undefined;
|
|
3
4
|
align?: string | undefined;
|
|
4
5
|
}, never>;
|
|
5
6
|
export declare const Cell: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
|
|
@@ -7,11 +8,10 @@ export declare const Cell: import("styled-components").StyledComponent<"div", im
|
|
|
7
8
|
flexBasis?: number | undefined;
|
|
8
9
|
flexGrow?: number | undefined;
|
|
9
10
|
flexShrink?: number | undefined;
|
|
10
|
-
transition?: string | undefined;
|
|
11
|
-
transform?: string | undefined;
|
|
12
11
|
}, never>;
|
|
13
12
|
export declare const StyledDataRow: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
|
|
14
13
|
hasRowClick?: boolean | undefined;
|
|
14
|
+
accountForScrollbar?: boolean | undefined;
|
|
15
15
|
align?: string | undefined;
|
|
16
16
|
} & {
|
|
17
17
|
isEven: boolean;
|
|
@@ -21,16 +21,12 @@ export declare const TextCell: import("styled-components").StyledComponent<"div"
|
|
|
21
21
|
flexBasis?: number | undefined;
|
|
22
22
|
flexGrow?: number | undefined;
|
|
23
23
|
flexShrink?: number | undefined;
|
|
24
|
-
transition?: string | undefined;
|
|
25
|
-
transform?: string | undefined;
|
|
26
24
|
}, never>;
|
|
27
25
|
export declare const MessageCell: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
|
|
28
26
|
align?: string | undefined;
|
|
29
27
|
flexBasis?: number | undefined;
|
|
30
28
|
flexGrow?: number | undefined;
|
|
31
29
|
flexShrink?: number | undefined;
|
|
32
|
-
transition?: string | undefined;
|
|
33
|
-
transform?: string | undefined;
|
|
34
30
|
} & {
|
|
35
31
|
width: number;
|
|
36
32
|
}, never>;
|
|
@@ -4,7 +4,7 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
|
|
4
4
|
};
|
|
5
5
|
import styled, { system, th } from '@xstyled/styled-components';
|
|
6
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' : 'auto'); });
|
|
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
|
|
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; });
|
|
8
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'); });
|
|
9
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"])));
|
|
10
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; });
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
2
|
+
import { DropResult } from 'react-beautiful-dnd';
|
|
3
3
|
import { CommonGridProps, GridActionsType, GridSelectorsType, ColumnDefinition } from '../types';
|
|
4
4
|
type Props = {
|
|
5
5
|
columns: CommonGridProps['columnsDefinitions'];
|
|
@@ -16,7 +16,7 @@ declare const useManageColumn: ({ columns, gridSelectors, gridActions, onClose }
|
|
|
16
16
|
}>>;
|
|
17
17
|
onConfirmForm: () => void;
|
|
18
18
|
resetColumnConfig: () => void;
|
|
19
|
-
handleDragEnd: (isManageModal?: boolean) => (
|
|
19
|
+
handleDragEnd: (isManageModal?: boolean) => (item: DropResult) => void;
|
|
20
20
|
onCloseForm: () => void;
|
|
21
21
|
displayColumnsDefinitions: ColumnDefinition<string>[];
|
|
22
22
|
manageColumnsFormDefinitions: ColumnDefinition<string>[];
|
|
@@ -64,10 +64,6 @@ var useManageColumn = function (_a) {
|
|
|
64
64
|
var sortFunction = function (col1, col2) {
|
|
65
65
|
var i = (orderValues || []).indexOf(col1.name);
|
|
66
66
|
var j = (orderValues || []).indexOf(col2.name);
|
|
67
|
-
// if orderValues is defined but the column is not in the order list, keep the default position by column definition
|
|
68
|
-
if (orderValues && (orderValues === null || orderValues === void 0 ? void 0 : orderValues.length) > 0 && i === -1) {
|
|
69
|
-
return 0;
|
|
70
|
-
}
|
|
71
67
|
return i > j ? 1 : i < j ? -1 : 0;
|
|
72
68
|
};
|
|
73
69
|
var sortedList = __spreadArray([], list, true).sort(sortFunction);
|
|
@@ -77,16 +73,21 @@ var useManageColumn = function (_a) {
|
|
|
77
73
|
var manageColumnsFormDefinitions = useMemo(function () { return getSortedColumns(updatedColumnsOrder, true); }, [updatedColumnsOrder]);
|
|
78
74
|
var handleDragEnd = useCallback(function (isManageModal) {
|
|
79
75
|
if (isManageModal === void 0) { isManageModal = false; }
|
|
80
|
-
return function (
|
|
81
|
-
var
|
|
82
|
-
|
|
76
|
+
return function (item) {
|
|
77
|
+
var destination = item.destination, source = item.source;
|
|
78
|
+
var to = destination === null || destination === void 0 ? void 0 : destination.index;
|
|
79
|
+
var from = source === null || source === void 0 ? void 0 : source.index;
|
|
80
|
+
if (to === from || !destination) {
|
|
83
81
|
return;
|
|
84
82
|
}
|
|
85
|
-
var
|
|
86
|
-
var
|
|
87
|
-
var
|
|
83
|
+
var columns = isManageModal ? manageColumnsFormDefinitions : displayColumnsDefinitions.filter(function (item) { return !item.sticky; });
|
|
84
|
+
var newOrderColumns = __spreadArray([], (isManageModal ? updatedColumnsOrder : columnsOrderValue), true);
|
|
85
|
+
var fromIndex = newOrderColumns.findIndex(function (column) { return columns[from].name === column; });
|
|
86
|
+
var toIndex = newOrderColumns.findIndex(function (column) { return columns[to !== null && to !== void 0 ? to : 0].name === column; });
|
|
87
|
+
// move column from a position to the new position
|
|
88
|
+
var column = newOrderColumns[fromIndex];
|
|
88
89
|
newOrderColumns.splice(fromIndex, 1);
|
|
89
|
-
newOrderColumns.splice(toIndex === -1 ? 0 : toIndex, 0,
|
|
90
|
+
newOrderColumns.splice(toIndex === -1 ? 0 : toIndex, 0, column);
|
|
90
91
|
if (!isManageModal) {
|
|
91
92
|
setColumnsOrder === null || setColumnsOrder === void 0 ? void 0 : setColumnsOrder(newOrderColumns);
|
|
92
93
|
}
|
|
@@ -13,7 +13,7 @@ var ComplexCell = function (props) {
|
|
|
13
13
|
export var oversizedColumnDefinition = new Array(oversizedArrayColumns).fill(null).map(function (unused, index) { return ({
|
|
14
14
|
name: "column_".concat(index),
|
|
15
15
|
title: "column_".concat(index),
|
|
16
|
-
flexBasis: 120
|
|
16
|
+
flexBasis: 120,
|
|
17
17
|
}); });
|
|
18
18
|
export var enumColumn = {
|
|
19
19
|
name: 'enumColumn',
|
|
@@ -22,23 +22,15 @@ export var enumColumn = {
|
|
|
22
22
|
filterOptions: enumValues.map(function (v) { return ({ value: v, label: v }); }),
|
|
23
23
|
filterExtraProps: { isMulti: true, checkAllButton: true },
|
|
24
24
|
filtering: true,
|
|
25
|
-
sorting: false
|
|
25
|
+
sorting: false,
|
|
26
26
|
};
|
|
27
27
|
export var columnDefinitions = [
|
|
28
|
-
{
|
|
29
|
-
name: 'hiddenColumn',
|
|
30
|
-
title: 'Hidden column',
|
|
31
|
-
flexBasis: 160,
|
|
32
|
-
filtering: true,
|
|
33
|
-
sorting: true,
|
|
34
|
-
defaultHidden: true
|
|
35
|
-
},
|
|
36
28
|
{
|
|
37
29
|
name: 'textColumn',
|
|
38
30
|
title: 'Text column',
|
|
39
31
|
flexBasis: 160,
|
|
40
32
|
filtering: true,
|
|
41
|
-
sorting: true
|
|
33
|
+
sorting: true,
|
|
42
34
|
},
|
|
43
35
|
enumColumn,
|
|
44
36
|
{
|
|
@@ -47,7 +39,7 @@ export var columnDefinitions = [
|
|
|
47
39
|
flexBasis: 160,
|
|
48
40
|
filtering: true,
|
|
49
41
|
filteringType: 'number',
|
|
50
|
-
sorting: true
|
|
42
|
+
sorting: true,
|
|
51
43
|
},
|
|
52
44
|
{
|
|
53
45
|
name: 'numberFloatColumn',
|
|
@@ -57,8 +49,8 @@ export var columnDefinitions = [
|
|
|
57
49
|
filteringType: 'number',
|
|
58
50
|
sorting: true,
|
|
59
51
|
filterExtraProps: {
|
|
60
|
-
isFloat: true
|
|
61
|
-
}
|
|
52
|
+
isFloat: true,
|
|
53
|
+
},
|
|
62
54
|
},
|
|
63
55
|
{
|
|
64
56
|
name: 'dateColumn',
|
|
@@ -68,8 +60,8 @@ export var columnDefinitions = [
|
|
|
68
60
|
filteringType: 'date',
|
|
69
61
|
sorting: true,
|
|
70
62
|
filterExtraProps: {
|
|
71
|
-
filterTime: true
|
|
72
|
-
}
|
|
63
|
+
filterTime: true,
|
|
64
|
+
},
|
|
73
65
|
},
|
|
74
66
|
{
|
|
75
67
|
name: 'boolColumn',
|
|
@@ -80,7 +72,7 @@ export var columnDefinitions = [
|
|
|
80
72
|
sorting: true,
|
|
81
73
|
formatRowValue: function (row) {
|
|
82
74
|
return row.boolColumn ? 'Yes' : 'No';
|
|
83
|
-
}
|
|
75
|
+
},
|
|
84
76
|
},
|
|
85
77
|
{
|
|
86
78
|
name: 'advancedColumn',
|
|
@@ -88,13 +80,13 @@ export var columnDefinitions = [
|
|
|
88
80
|
flexBasis: 160,
|
|
89
81
|
formatRowValue: function (row) {
|
|
90
82
|
return "".concat((row.numberColumn / 4) * row.textColumn.length);
|
|
91
|
-
}
|
|
83
|
+
},
|
|
92
84
|
},
|
|
93
85
|
{
|
|
94
86
|
name: 'complexColumn',
|
|
95
87
|
title: 'Complex Column',
|
|
96
88
|
flexBasis: 350,
|
|
97
|
-
cellComponent: ComplexCell
|
|
89
|
+
cellComponent: ComplexCell,
|
|
98
90
|
},
|
|
99
91
|
{
|
|
100
92
|
name: 'stickyColumn',
|
|
@@ -102,6 +94,6 @@ export var columnDefinitions = [
|
|
|
102
94
|
flexBasis: 160,
|
|
103
95
|
alwaysOn: true,
|
|
104
96
|
sticky: true,
|
|
105
|
-
stickTo: 'right'
|
|
106
|
-
}
|
|
97
|
+
stickTo: 'right',
|
|
98
|
+
},
|
|
107
99
|
];
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Provider } from 'react-redux';
|
|
3
|
-
import { combineReducers, createStore
|
|
3
|
+
import { combineReducers, createStore } from 'redux';
|
|
4
4
|
import commonGridReducer from '../../store';
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
export var reduxComposeEnhancer = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
|
|
7
5
|
export var withProvider = function (story) {
|
|
8
6
|
var reducers = combineReducers({
|
|
9
|
-
commonGrid: commonGridReducer
|
|
7
|
+
commonGrid: commonGridReducer,
|
|
10
8
|
});
|
|
11
|
-
var store = createStore(reducers
|
|
9
|
+
var store = createStore(reducers);
|
|
12
10
|
return _jsx(Provider, { store: store, children: story() });
|
|
13
11
|
};
|
|
14
12
|
export default withProvider;
|
|
@@ -9,7 +9,7 @@ export declare const CommonGridWrap: import("styled-components").StyledComponent
|
|
|
9
9
|
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">;
|
|
10
10
|
export declare const CommonGridWithStyles: import("styled-components").StyledComponent<({ filters, comparators, handleDragEnd, gridSelectors, gridActions, isLoading, rowsData, hasColouredRows, actionColumnDefinition, allowRowSelect, allowRowSelectOnAction, onRowAction, onRowClick, columnLayout, displayColumnsDefinitions, className, minColumnWidth, errorMessage, floatingButtonProps, hasGroups, hasFilters }: import("./types").CommonGridProps & {
|
|
11
11
|
filters?: import("./types").FiltersConfig | undefined;
|
|
12
|
-
handleDragEnd: (item: import("
|
|
12
|
+
handleDragEnd: (item: import("react-beautiful-dnd").DropResult) => void;
|
|
13
13
|
displayColumnsDefinitions: import("./types").ColumnDefinition[];
|
|
14
14
|
hasGroups: boolean;
|
|
15
15
|
hasFilters: boolean;
|
|
@@ -10,7 +10,7 @@ var ErrorWrap = styled.div(templateObject_2 || (templateObject_2 = __makeTemplat
|
|
|
10
10
|
var StyledWrapper = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n .inline {\n margin-top: 1;\n }\n .tooltip {\n ", "\n }\n"], ["\n .inline {\n margin-top: 1;\n }\n .tooltip {\n ", "\n }\n"])), tooltip);
|
|
11
11
|
var ErrorMessage = function (_a) {
|
|
12
12
|
var children = _a.children, appearance = _a.appearance;
|
|
13
|
-
return (_jsx(StyledWrapper, { children: _jsx(ErrorWrap, { className: appearance, children: _jsx("span", { children: children }) }) }));
|
|
13
|
+
return (_jsx(StyledWrapper, { children: _jsx(ErrorWrap, { className: appearance, children: _jsx("span", { "data-testid": "error-message", children: children }) }) }));
|
|
14
14
|
};
|
|
15
15
|
export default ErrorMessage;
|
|
16
16
|
var templateObject_1, templateObject_2, templateObject_3;
|