@mailstep/design-system 0.7.47-beta.1 → 0.7.47-beta.11
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 +1 -1
- package/ui/Blocks/CommonGrid/CommonGrid.js +1 -1
- package/ui/Blocks/CommonGrid/CommonGridContainer.js +1 -1
- package/ui/Blocks/CommonGrid/HoC/withProps.d.ts +3 -0
- package/ui/Blocks/CommonGrid/HoC/withProps.js +21 -0
- package/ui/Blocks/CommonGrid/components/ActionHead/ActionHead.d.ts +2 -2
- package/ui/Blocks/CommonGrid/components/ActionHead/ActionHead.js +8 -10
- package/ui/Blocks/CommonGrid/components/ColumnFilterCell.d.ts +6 -2
- package/ui/Blocks/CommonGrid/components/ColumnFilterCell.js +2 -2
- package/ui/Blocks/CommonGrid/components/DataCell.d.ts +1 -0
- package/ui/Blocks/CommonGrid/components/DataCell.js +2 -2
- package/ui/Blocks/CommonGrid/components/DataRow.d.ts +2 -5
- package/ui/Blocks/CommonGrid/components/DataRow.js +12 -79
- package/ui/Blocks/CommonGrid/components/FilterRow.d.ts +2 -2
- package/ui/Blocks/CommonGrid/components/FilterRow.js +5 -27
- package/ui/Blocks/CommonGrid/components/Filters/ActionsFilter/ActionsFilter.d.ts +10 -0
- package/ui/Blocks/CommonGrid/components/Filters/ActionsFilter/ActionsFilter.js +14 -0
- package/ui/Blocks/CommonGrid/components/Filters/ActionsFilter/index.d.ts +2 -0
- package/ui/Blocks/CommonGrid/components/Filters/ActionsFilter/index.js +2 -0
- package/ui/Blocks/CommonGrid/components/HeadRow.d.ts +2 -2
- package/ui/Blocks/CommonGrid/components/HeadRow.js +5 -7
- package/ui/Blocks/CommonGrid/components/Table.d.ts +9 -0
- package/ui/Blocks/CommonGrid/components/gridCells/IconButtonInCell.js +4 -10
- package/ui/Blocks/CommonGrid/components/gridCells/RowActionsCell.d.ts +12 -5
- package/ui/Blocks/CommonGrid/components/gridCells/RowActionsCell.js +46 -19
- package/ui/Blocks/CommonGrid/hooks/useEditReadAsColumn.d.ts +1 -6
- package/ui/Blocks/CommonGrid/hooks/useEditReadAsColumn.js +38 -17
- package/ui/Blocks/CommonGrid/storybook/stories/complexWithPaginationAndRedux.stories.js +5 -4
- package/ui/Blocks/CommonGrid/storybook/utils/columnDefinition.js +0 -4
- package/ui/Blocks/CommonGrid/styles.js +1 -1
- package/ui/Blocks/CommonGrid/types.d.ts +2 -2
- package/ui/Blocks/CommonGrid/utils/index.d.ts +1 -1
- package/ui/Blocks/CommonGrid/utils/index.js +9 -7
- package/ui/Blocks/Modal/hooks/useModal.d.ts +2 -8
- package/ui/Blocks/Modal/hooks/useModal.js +5 -7
- package/ui/index.es.js +24653 -24712
- package/ui/index.umd.js +749 -781
- package/ui/Blocks/CommonGrid/components/ReadEditButtonCell/ReadEditButtonCell.d.ts +0 -6
- package/ui/Blocks/CommonGrid/components/ReadEditButtonCell/ReadEditButtonCell.js +0 -26
- package/ui/Blocks/CommonGrid/components/ReadEditButtonCell/index.d.ts +0 -2
- package/ui/Blocks/CommonGrid/components/ReadEditButtonCell/index.js +0 -2
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DropResult } from 'react-beautiful-dnd';
|
|
2
|
-
import { CommonGridProps, FiltersConfig, ColumnDefinition } from './types';
|
|
2
|
+
import type { CommonGridProps, FiltersConfig, ColumnDefinition } from './types';
|
|
3
3
|
type Props = CommonGridProps & {
|
|
4
4
|
filters?: FiltersConfig;
|
|
5
5
|
handleDragEnd: (item: DropResult) => void;
|
|
@@ -67,7 +67,7 @@ var CommonGrid = function (_a) {
|
|
|
67
67
|
displayColumnsDefinitions &&
|
|
68
68
|
rowsData.map(function (row, index) {
|
|
69
69
|
var rowIndex = rowsPerPage * page + (index + 1) - rowsPerPage;
|
|
70
|
-
return (_jsx(DataRow, { rowData: row, rowIndex: rowIndex, uxState: uxState, isEven: hasColouredRows && (index + 1) % 2 === 0, allowRowSelect: allowRowSelect, allowRowSelectOnAction: allowRowSelectOnAction, onRowAction: onRowAction, onUxChange: handleUxChange,
|
|
70
|
+
return (_jsx(DataRow, { rowData: row, rowIndex: rowIndex, uxState: uxState, isEven: hasColouredRows && (index + 1) % 2 === 0, allowRowSelect: allowRowSelect, allowRowSelectOnAction: allowRowSelectOnAction, onRowAction: onRowAction, onUxChange: handleUxChange, onRowClick: onRowClick, columns: displayColumnsDefinitions, displayColumnsWidth: displayColumnsWidth, groups: groups }, row.id));
|
|
71
71
|
}) })] }) }), floatingButtonProps && _jsx(FloatingButton, __assign({}, floatingButtonProps))] }));
|
|
72
72
|
};
|
|
73
73
|
export default CommonGrid;
|
|
@@ -66,6 +66,6 @@ var CommonGridContainer = function (props) {
|
|
|
66
66
|
onClose: onClose
|
|
67
67
|
}), columnsConfigValues = _j.columnsConfigValues, setColumnsConfigOptions = _j.setColumnsConfigOptions, onConfirmForm = _j.onConfirmForm, resetColumnConfig = _j.resetColumnConfig, handleDragEnd = _j.handleDragEnd, onCloseForm = _j.onCloseForm, displayColumnsDefinitions = _j.displayColumnsDefinitions, manageColumnsFormDefinitions = _j.manageColumnsFormDefinitions;
|
|
68
68
|
var _k = usePresetState(), isPresetsModalOpen = _k.isPresetsModalOpen, onClosePresetsModal = _k.onClosePresetsModal, onOpenPresetsModal = _k.onOpenPresetsModal, setSelectedPresetName = _k.setSelectedPresetName, selectedPresetName = _k.selectedPresetName;
|
|
69
|
-
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: extraControlButtons, gridActions: gridActions, gridSelectors: gridSelectors, quickFilter: quickFilter, displayColumnsDefinitions: displayColumnsDefinitions, filters: filters, setDisplayManageColumnButton: setDisplayManageColumnButton, displayManageColumnButton: displayManageColumnButton, openManageColumnForm: openManageColumnForm, onOpenPresetsModal: onOpenPresetsModal, selectedPresetName: selectedPresetName, withPresets: withPresets, gridName: gridName, withManageColumnButton: withManageColumnButton }) }) })), _jsx(CommonGridWithStyles, __assign({}, passDownProps, modifiedPassDownProps, { withButtonStrip: withButtonStrip, hasGroupsOrFilters: hasGroupsOrFilters, filters: filters, floatingButtonProps: floatingButtonProps, handleDragEnd: handleDragEnd(false), displayColumnsDefinitions: displayColumnsDefinitions, hasFilters: hasFilters, hasGroups: hasGroups, 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,
|
|
69
|
+
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: extraControlButtons, gridActions: gridActions, gridSelectors: gridSelectors, quickFilter: quickFilter, displayColumnsDefinitions: displayColumnsDefinitions, filters: filters, setDisplayManageColumnButton: setDisplayManageColumnButton, displayManageColumnButton: displayManageColumnButton, openManageColumnForm: openManageColumnForm, onOpenPresetsModal: onOpenPresetsModal, selectedPresetName: selectedPresetName, withPresets: withPresets, gridName: gridName, withManageColumnButton: withManageColumnButton }) }) })), _jsx(CommonGridWithStyles, __assign({}, passDownProps, modifiedPassDownProps, { withButtonStrip: withButtonStrip, hasGroupsOrFilters: hasGroupsOrFilters, filters: filters, floatingButtonProps: floatingButtonProps, handleDragEnd: handleDragEnd(false), displayColumnsDefinitions: displayColumnsDefinitions, hasFilters: hasFilters, hasGroups: hasGroups, 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 })), withPagination && (_jsxs(x.div, { display: "flex", justifyContent: "center", alignItems: "center", className: "paginatorWrapper", w: "100%", children: [_jsx(Pagination, { page: gridSelectors === null || gridSelectors === void 0 ? void 0 : gridSelectors.page, itemCount: passDownProps === null || passDownProps === void 0 ? void 0 : passDownProps.totalRowsCount, itemPerPage: (gridSelectors === null || gridSelectors === void 0 ? void 0 : gridSelectors.rowsPerPage) || 10, onPageChange: gridActions === null || gridActions === void 0 ? void 0 : gridActions.setPage, customPaginationHandler: customPaginationHandler, radius: window.innerWidth < 768 ? 3 : 5, rate: window.innerWidth < 768 ? 1 : 4 }), _jsx(TablePagination, { gridActions: gridActions, gridSelectors: gridSelectors, customPaginationHandler: customPaginationHandler, 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 })] }));
|
|
70
70
|
};
|
|
71
71
|
export default CommonGridContainer;
|
|
@@ -0,0 +1,21 @@
|
|
|
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 } from "react/jsx-runtime";
|
|
13
|
+
var withProps = function (input) {
|
|
14
|
+
return function (Component) {
|
|
15
|
+
return function ComponentWithProps(props) {
|
|
16
|
+
var additinalProps = typeof input === 'function' ? input(props) : input;
|
|
17
|
+
return _jsx(Component, __assign({}, props, additinalProps));
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export default withProps;
|
|
@@ -2,11 +2,11 @@ import { GridActionsType, GridSelectorsType, OnBatchActionFn, RowProps, ActionCo
|
|
|
2
2
|
type Props = {
|
|
3
3
|
gridActions: GridActionsType;
|
|
4
4
|
gridSelectors: GridSelectorsType;
|
|
5
|
-
|
|
5
|
+
actionOptions?: ActionColumn['actionOptions'];
|
|
6
6
|
onBatchAction?: OnBatchActionFn;
|
|
7
7
|
rowsData: RowProps[];
|
|
8
8
|
processCheckedValues?: () => void;
|
|
9
9
|
processCheckedValuesTitle?: string;
|
|
10
10
|
};
|
|
11
|
-
declare const ActionHead: ({ gridActions, gridSelectors,
|
|
11
|
+
declare const ActionHead: ({ gridActions, gridSelectors, actionOptions, onBatchAction, rowsData, processCheckedValues, processCheckedValuesTitle }: Props) => JSX.Element;
|
|
12
12
|
export default ActionHead;
|
|
@@ -17,12 +17,11 @@ var StyledText = styled.span(templateObject_3 || (templateObject_3 = __makeTempl
|
|
|
17
17
|
var ContentWrap = styled.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n display: flex;\n justify-content: space-between;\n align-items: center;\n"], ["\n display: flex;\n justify-content: space-between;\n align-items: center;\n"])));
|
|
18
18
|
var ButtonsWrap = styled.div(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n margin-left: 10px;\n\n & > * {\n margin-left: 10px;\n }\n"], ["\n display: flex;\n align-items: center;\n margin-left: 10px;\n\n & > * {\n margin-left: 10px;\n }\n"])));
|
|
19
19
|
var ActionHead = function (_a) {
|
|
20
|
-
var
|
|
21
|
-
var gridActions = _a.gridActions, gridSelectors = _a.gridSelectors, actionColumn = _a.actionColumn, onBatchAction = _a.onBatchAction, rowsData = _a.rowsData, processCheckedValues = _a.processCheckedValues, processCheckedValuesTitle = _a.processCheckedValuesTitle;
|
|
20
|
+
var gridActions = _a.gridActions, gridSelectors = _a.gridSelectors, actionOptions = _a.actionOptions, onBatchAction = _a.onBatchAction, rowsData = _a.rowsData, processCheckedValues = _a.processCheckedValues, processCheckedValuesTitle = _a.processCheckedValuesTitle;
|
|
22
21
|
var handleUxChange = (gridActions || {}).handleUxChange;
|
|
23
|
-
var
|
|
24
|
-
var
|
|
25
|
-
var
|
|
22
|
+
var _b = (gridSelectors || {}).uxState, uxState = _b === void 0 ? {} : _b;
|
|
23
|
+
var _c = useToggleAllCheckbox(rowsData, uxState, handleUxChange), checked = _c[0], toggleCheckbox = _c[1];
|
|
24
|
+
var _d = useGridActionTrigger(rowsData, uxState, actionOptions, onBatchAction), enabledActions = _d[0], onSubmit = _d[1];
|
|
26
25
|
var checkedRowsCount = Object.keys((uxState === null || uxState === void 0 ? void 0 : uxState.checkedRows) || []).length;
|
|
27
26
|
var checkAll = useCallback(function () {
|
|
28
27
|
if (!checked) {
|
|
@@ -30,21 +29,20 @@ var ActionHead = function (_a) {
|
|
|
30
29
|
}
|
|
31
30
|
}, [checked, toggleCheckbox]);
|
|
32
31
|
var actionsOptions = useMemo(function () {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return actionColumn.actionOptions.map(function (option) { return ({
|
|
32
|
+
if (actionOptions === null || actionOptions === void 0 ? void 0 : actionOptions.length) {
|
|
33
|
+
return actionOptions.map(function (option) { return ({
|
|
36
34
|
title: option.label,
|
|
37
35
|
onClick: function () { return onSubmit(option.value); },
|
|
38
36
|
link: '#'
|
|
39
37
|
}); });
|
|
40
38
|
}
|
|
41
39
|
return [];
|
|
42
|
-
}, [
|
|
40
|
+
}, [actionOptions, onSubmit]);
|
|
43
41
|
return (_jsx(Wrap, { children: checkedRowsCount > 0 && (_jsx(ActionsWrap, { children: _jsxs(ContentWrap, { children: [_jsx(StyledText, { children: i18n._({
|
|
44
42
|
id: 'dataGrid.checkedRowsCount',
|
|
45
43
|
message: "Selected {checkedRowsCount} items",
|
|
46
44
|
values: { checkedRowsCount: checkedRowsCount }
|
|
47
|
-
}) }), _jsxs(ButtonsWrap, { children: [_jsx(Button, { type: "button", onClick: checkAll, appearance: "secondary", variant: "default", "data-cy": "checkAllBtn", disabled: checked, children: _jsx(Trans, { id: "dataGrid.checkAll", message: "Check all" }) }), processCheckedValues && (_jsx(Button, { type: "button", onClick: processCheckedValues, appearance: "primary", variant: "default", "data-cy": "exportBtn", disabled: !rowsData.length, children: processCheckedValuesTitle
|
|
45
|
+
}) }), _jsxs(ButtonsWrap, { children: [_jsx(Button, { type: "button", onClick: checkAll, appearance: "secondary", variant: "default", "data-cy": "checkAllBtn", disabled: checked, children: _jsx(Trans, { id: "dataGrid.checkAll", message: "Check all" }) }), processCheckedValues && (_jsx(Button, { type: "button", onClick: processCheckedValues, appearance: "primary", variant: "default", "data-cy": "exportBtn", disabled: !rowsData.length, children: processCheckedValuesTitle || _jsx(Trans, { id: "dataGrid.actionOptions.export", message: "Export" }) })), (actionOptions === null || actionOptions === void 0 ? void 0 : actionOptions.length) && (_jsx(ButtonMore, { items: actionsOptions, disabled: !enabledActions.length || !rowsData.length, dropdownPosition: "top" }))] })] }) })) }));
|
|
48
46
|
};
|
|
49
47
|
export default ActionHead;
|
|
50
48
|
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ColumnDefinition, GridActionsType, FiltersConfig, CustomComparators, Group } from '../types';
|
|
1
|
+
import type { ColumnDefinition, GridActionsType, FiltersConfig, CustomComparators, Group, ActionColumn, UxState, RowProps } from '../types';
|
|
2
2
|
type Props = {
|
|
3
3
|
onChange: Required<GridActionsType>['addFilter'];
|
|
4
4
|
value?: any;
|
|
@@ -8,6 +8,10 @@ type Props = {
|
|
|
8
8
|
filters?: FiltersConfig;
|
|
9
9
|
group?: Group;
|
|
10
10
|
comparators?: CustomComparators;
|
|
11
|
+
actionColumn?: ActionColumn;
|
|
12
|
+
rowsData: RowProps[];
|
|
13
|
+
uxState: UxState;
|
|
14
|
+
handleUxChange: GridActionsType['handleUxChange'];
|
|
11
15
|
};
|
|
12
|
-
declare const ColumnFilterCell: ({ onChange, value, others, displayColumnWidth, filters, column: columnDefinition, group, comparators }: Props) => JSX.Element;
|
|
16
|
+
declare const ColumnFilterCell: ({ onChange, value, others, displayColumnWidth, filters, column: columnDefinition, group, comparators, actionColumn, rowsData, uxState, handleUxChange }: Props) => JSX.Element;
|
|
13
17
|
export default ColumnFilterCell;
|
|
@@ -17,7 +17,7 @@ import { x } from '@xstyled/styled-components';
|
|
|
17
17
|
import OverlayComponent from './FilterDropdown';
|
|
18
18
|
import { Cell } from './Table';
|
|
19
19
|
var ColumnFilterCell = function (_a) {
|
|
20
|
-
var onChange = _a.onChange, value = _a.value, others = _a.others, displayColumnWidth = _a.displayColumnWidth, filters = _a.filters, columnDefinition = _a.column, group = _a.group, comparators = _a.comparators;
|
|
20
|
+
var onChange = _a.onChange, value = _a.value, others = _a.others, displayColumnWidth = _a.displayColumnWidth, filters = _a.filters, columnDefinition = _a.column, group = _a.group, comparators = _a.comparators, actionColumn = _a.actionColumn, rowsData = _a.rowsData, uxState = _a.uxState, handleUxChange = _a.handleUxChange;
|
|
21
21
|
var cellSizeProps = getCellSizeProps(columnDefinition, displayColumnWidth);
|
|
22
22
|
var handleAddFilter = useAddFilter(onChange);
|
|
23
23
|
var handleChange = React.useCallback(function (event, others) {
|
|
@@ -35,6 +35,6 @@ var ColumnFilterCell = function (_a) {
|
|
|
35
35
|
console.error("ERROR, using unknown filter type ".concat(filterType));
|
|
36
36
|
return (_jsx(x.div, { children: _jsx("span", { children: "".concat(filterType, " filter") }) }));
|
|
37
37
|
}
|
|
38
|
-
return (_jsx(Cell, __assign({ className: cellClassName }, cellSizeProps, { children: _jsx(x.div, { children: _jsx(RenderComponent, __assign({ "data-test": columnDefinition.name, name: columnDefinition.name, onChange: handleChange, value: value, others: others, OverlayComponent: OverlayComponent, comparators: defaultComparators }, filterConfig === null || filterConfig === void 0 ? void 0 : filterConfig.defaultExtraProps, columnDefinition.filterExtraProps, (filterType == 'options' && { options: columnDefinition.filterOptions }))) }) })));
|
|
38
|
+
return (_jsx(Cell, __assign({ className: cellClassName }, cellSizeProps, { children: _jsx(x.div, { children: _jsx(RenderComponent, __assign({ "data-test": columnDefinition.name, name: columnDefinition.name, onChange: handleChange, value: value, others: others, OverlayComponent: OverlayComponent, comparators: defaultComparators, actionColumn: actionColumn, rowsData: rowsData, uxState: uxState, handleUxChange: handleUxChange }, filterConfig === null || filterConfig === void 0 ? void 0 : filterConfig.defaultExtraProps, columnDefinition.filterExtraProps, (filterType == 'options' && { options: columnDefinition.filterOptions }))) }) })));
|
|
39
39
|
};
|
|
40
40
|
export default ColumnFilterCell;
|
|
@@ -6,6 +6,7 @@ type DataCellPros = {
|
|
|
6
6
|
onRowAction?: (id: string, field: string, value: any, rowData?: RowProps) => void;
|
|
7
7
|
displayColumnWidth: number;
|
|
8
8
|
group: Group;
|
|
9
|
+
rowIndex: number;
|
|
9
10
|
};
|
|
10
11
|
declare const MemoDataCell: React.NamedExoticComponent<DataCellPros>;
|
|
11
12
|
export default MemoDataCell;
|
|
@@ -15,14 +15,14 @@ import get from 'lodash/fp/get';
|
|
|
15
15
|
import { TextCell } from './Table';
|
|
16
16
|
import { getCellSizeProps, getGroupClassNames, getStickyCollClassNames } from '../utils';
|
|
17
17
|
var DataCell = function (_a) {
|
|
18
|
-
var column = _a.column, group = _a.group, rowData = _a.rowData, onRowAction = _a.onRowAction, displayColumnWidth = _a.displayColumnWidth;
|
|
18
|
+
var column = _a.column, group = _a.group, rowData = _a.rowData, onRowAction = _a.onRowAction, displayColumnWidth = _a.displayColumnWidth, rowIndex = _a.rowIndex;
|
|
19
19
|
var Wrapper = column.fixedSize ? 'div' : TextCell;
|
|
20
20
|
var wrapperBaseProps = column.fixedSize
|
|
21
21
|
? { style: __assign(__assign({}, getCellSizeProps(column, displayColumnWidth)), { alignSelf: 'center' }) }
|
|
22
22
|
: getCellSizeProps(column, displayColumnWidth);
|
|
23
23
|
var cellClassName = "cell".concat(getStickyCollClassNames(!!column.sticky, column.stickTo), " ").concat(getGroupClassNames(group));
|
|
24
24
|
if (column.cellComponent) {
|
|
25
|
-
return (_jsx(Wrapper, __assign({ className: cellClassName }, wrapperBaseProps, { children: _jsx(column.cellComponent, { rowData: rowData, onRowAction: onRowAction, column: column }) })));
|
|
25
|
+
return (_jsx(Wrapper, __assign({ className: cellClassName }, wrapperBaseProps, { children: _jsx(column.cellComponent, { rowData: rowData, onRowAction: onRowAction, column: column, rowIndex: rowIndex }) })));
|
|
26
26
|
}
|
|
27
27
|
else {
|
|
28
28
|
return (_jsx(Wrapper, __assign({ className: cellClassName }, wrapperBaseProps, { children: column.formatRowValue ? column.formatRowValue(rowData) : get(column.name, rowData) })));
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import { ColumnDefinition,
|
|
1
|
+
import type { ColumnDefinition, RowProps, UxState, GridSelectorsType, Group } from '../types';
|
|
2
2
|
type DataRowProps = {
|
|
3
3
|
columns: ColumnDefinition[];
|
|
4
|
-
actionColumn?: ActionColumn;
|
|
5
4
|
rowData: RowProps;
|
|
6
5
|
rowIndex: number;
|
|
7
6
|
uxState: UxState;
|
|
8
7
|
allowRowSelect?: boolean;
|
|
9
8
|
allowRowSelectOnAction?: boolean;
|
|
10
9
|
onUxChange?: (uxKey: keyof UxState, uxValue: any) => void;
|
|
11
|
-
onRowEditClick?: (id: string, props: RowProps) => void;
|
|
12
|
-
onRowReadClick?: (id: string, props: RowProps) => void;
|
|
13
10
|
onRowClick?: (id: string, props: RowProps) => void;
|
|
14
11
|
onRowAction?: (id: string, field: string, value: any, rowData?: RowProps) => void;
|
|
15
12
|
createLink?: (params?: object) => string;
|
|
@@ -17,5 +14,5 @@ type DataRowProps = {
|
|
|
17
14
|
groups: Group[];
|
|
18
15
|
isEven?: boolean;
|
|
19
16
|
};
|
|
20
|
-
declare const DataRow: ({ columns,
|
|
17
|
+
declare const DataRow: ({ columns, rowData, rowIndex, uxState, allowRowSelect, allowRowSelectOnAction, onUxChange, onRowClick, onRowAction, displayColumnsWidth, groups, isEven }: DataRowProps) => JSX.Element;
|
|
21
18
|
export default DataRow;
|
|
@@ -1,75 +1,19 @@
|
|
|
1
|
-
|
|
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
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
-
var t = {};
|
|
14
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
-
t[p] = s[p];
|
|
16
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
-
t[p[i]] = s[p[i]];
|
|
20
|
-
}
|
|
21
|
-
return t;
|
|
22
|
-
};
|
|
23
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
2
|
import React from 'react';
|
|
25
|
-
import { Link } from 'react-router-dom';
|
|
26
|
-
import Button from '../../../Elements/Button/Button';
|
|
27
|
-
import Checkbox from '../../../Forms/Checkbox';
|
|
28
3
|
import { rowClassSymbol } from '../types';
|
|
29
|
-
import { getActionCellSizeProps } from '../utils';
|
|
30
|
-
import EditIcon from './icons/Edit';
|
|
31
|
-
import EyeOpenIcon from './icons/EyeOpen';
|
|
32
|
-
import { x } from '@xstyled/styled-components';
|
|
33
|
-
import { isFunction } from 'lodash/fp';
|
|
34
4
|
import MemoDataCell from './DataCell';
|
|
35
|
-
import {
|
|
5
|
+
import { StyledDataRow } from './Table';
|
|
36
6
|
import { useTimeMeasurement } from './utils';
|
|
37
|
-
var EmptySpan = function (_a) {
|
|
38
|
-
var children = _a.children, props = __rest(_a, ["children"]);
|
|
39
|
-
return _jsx("span", __assign({}, props, { children: children }));
|
|
40
|
-
};
|
|
41
7
|
var DataRow = function (_a) {
|
|
42
|
-
var _b
|
|
43
|
-
var columns = _a.columns,
|
|
8
|
+
var _b;
|
|
9
|
+
var columns = _a.columns, rowData = _a.rowData, rowIndex = _a.rowIndex, uxState = _a.uxState, allowRowSelect = _a.allowRowSelect, allowRowSelectOnAction = _a.allowRowSelectOnAction, onUxChange = _a.onUxChange, onRowClick = _a.onRowClick, onRowAction = _a.onRowAction, displayColumnsWidth = _a.displayColumnsWidth, groups = _a.groups, isEven = _a.isEven;
|
|
44
10
|
var isChecked = !!((_b = uxState.checkedRows) === null || _b === void 0 ? void 0 : _b[rowData.id]);
|
|
45
|
-
var onCheckboxChange = React.useCallback(function () {
|
|
46
|
-
var checkedRows = __assign({}, (uxState.checkedRows || {}));
|
|
47
|
-
if (!isChecked) {
|
|
48
|
-
checkedRows[rowData.id] = true;
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
delete checkedRows[rowData.id];
|
|
52
|
-
}
|
|
53
|
-
onUxChange && onUxChange('checkedRows', checkedRows);
|
|
54
|
-
}, [onUxChange, isChecked, uxState, rowData]);
|
|
55
|
-
var handleEditClick = React.useCallback(function () {
|
|
56
|
-
if (onRowEditClick)
|
|
57
|
-
onRowEditClick(rowData.id, rowData);
|
|
58
|
-
if (onUxChange && allowRowSelectOnAction)
|
|
59
|
-
onUxChange('selectedRow', rowData.id);
|
|
60
|
-
}, [onRowEditClick, rowData]);
|
|
61
|
-
var handleReadClick = React.useCallback(function () {
|
|
62
|
-
if (onRowReadClick)
|
|
63
|
-
onRowReadClick(rowData.id, rowData);
|
|
64
|
-
if (onUxChange && allowRowSelectOnAction)
|
|
65
|
-
onUxChange('selectedRow', rowData.id);
|
|
66
|
-
}, [onRowReadClick, rowData]);
|
|
67
11
|
var handleRowAction = React.useCallback(function (id, field, value, rowData) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}, [
|
|
12
|
+
onRowAction === null || onRowAction === void 0 ? void 0 : onRowAction(id, field, value, rowData);
|
|
13
|
+
if (allowRowSelectOnAction) {
|
|
14
|
+
onUxChange === null || onUxChange === void 0 ? void 0 : onUxChange('selectedRow', id);
|
|
15
|
+
}
|
|
16
|
+
}, [onRowAction, allowRowSelectOnAction, onUxChange]);
|
|
73
17
|
var handleRowClick = React.useCallback(function (e) {
|
|
74
18
|
// test whether I should trigger event or not (because of possible button/link/input/etc in cell)
|
|
75
19
|
var classes = Object.values(e.target.classList);
|
|
@@ -82,29 +26,18 @@ var DataRow = function (_a) {
|
|
|
82
26
|
},
|
|
83
27
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
84
28
|
[onRowClick, onUxChange, rowData]);
|
|
85
|
-
var
|
|
86
|
-
var RowActionComponent = ((actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.createLink) ? Link : EmptySpan);
|
|
87
|
-
var rowActionProps = React.useCallback(function (mode) {
|
|
88
|
-
var _a;
|
|
89
|
-
return (actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.createLink)
|
|
90
|
-
? { to: (_a = actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.createLink) === null || _a === void 0 ? void 0 : _a.call(actionColumn, { mode: mode, id: rowData.id }) }
|
|
91
|
-
: { onClick: { read: handleReadClick, edit: handleEditClick }[mode] };
|
|
92
|
-
}, [actionColumn, handleReadClick, handleEditClick]);
|
|
29
|
+
var _c = useTimeMeasurement({ handleRowClick: handleRowClick }), handleMouseDown = _c.handleMouseDown, handleMouseUp = _c.handleMouseUp;
|
|
93
30
|
var rowClassName = React.useMemo(function () {
|
|
94
31
|
var classes = ['dataRow'];
|
|
95
32
|
if (isChecked)
|
|
96
33
|
classes.push('checked');
|
|
97
|
-
if (uxState.selectedRow
|
|
34
|
+
if (uxState.selectedRow === rowData.id && (allowRowSelect || allowRowSelectOnAction))
|
|
98
35
|
classes.push('selected');
|
|
99
36
|
if (rowData[rowClassSymbol])
|
|
100
37
|
classes.push(rowData[rowClassSymbol] || '');
|
|
101
38
|
return classes.join(' ');
|
|
102
39
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
103
40
|
}, [isChecked, uxState, rowData]);
|
|
104
|
-
|
|
105
|
-
return actionColumn ? __assign({}, getActionCellSizeProps(actionColumn)) : {};
|
|
106
|
-
}, [actionColumn]);
|
|
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)); })] }));
|
|
41
|
+
return (_jsx(StyledDataRow, { className: rowClassName, hasRowClick: !!onRowClick, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, isEven: !!isEven, children: columns.map(function (column, key) { return (_jsx(MemoDataCell, { column: column, rowData: rowData, rowIndex: rowIndex, onRowAction: handleRowAction, displayColumnWidth: displayColumnsWidth[column.name], group: groups === null || groups === void 0 ? void 0 : groups[key] }, column.name)); }) }));
|
|
109
42
|
};
|
|
110
43
|
export default DataRow;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Settings, ColumnDefinition as ColumnDefinitionType, ActionColumn, GridActionsType, GridSelectorsType, Group, CustomComparators, FiltersConfig, UxState, RowProps } from '../types';
|
|
1
|
+
import type { Settings, ColumnDefinition as ColumnDefinitionType, ActionColumn, GridActionsType, GridSelectorsType, Group, CustomComparators, FiltersConfig, UxState, RowProps } from '../types';
|
|
2
2
|
type Props = {
|
|
3
3
|
columns: ColumnDefinitionType[];
|
|
4
4
|
actionColumn?: ActionColumn;
|
|
@@ -12,5 +12,5 @@ type Props = {
|
|
|
12
12
|
rowsData: RowProps[];
|
|
13
13
|
uxState: UxState;
|
|
14
14
|
};
|
|
15
|
-
declare const FilterRow: ({ columns, groups, actionColumn, onChange, filterValues, displayColumnsWidth, filters, comparators, handleUxChange, rowsData, uxState
|
|
15
|
+
declare const FilterRow: ({ columns, groups, actionColumn, onChange, filterValues, displayColumnsWidth, filters, comparators, handleUxChange, rowsData, uxState }: Props) => JSX.Element;
|
|
16
16
|
export default FilterRow;
|
|
@@ -1,34 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 React from 'react';
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { getFilterName } from '../utils';
|
|
14
3
|
import get from 'lodash/fp/get';
|
|
15
4
|
import throttle from 'lodash/throttle';
|
|
16
5
|
import ColumnFilterCell from './ColumnFilterCell';
|
|
17
|
-
import { Row
|
|
18
|
-
import { getActionCellSizeProps, getFilterName } from '../utils';
|
|
19
|
-
import { useToggleAllCheckbox } from '../hooks/useToggleAllCheckbox';
|
|
20
|
-
import Checkbox from '../../../Forms/Checkbox';
|
|
6
|
+
import { Row } from './Table';
|
|
21
7
|
var FilterRow = function (_a) {
|
|
22
|
-
var _b,
|
|
23
|
-
var columns = _a.columns, groups = _a.groups, actionColumn = _a.actionColumn, onChange = _a.onChange, _d = _a.filterValues, filterValues = _d === void 0 ? {} : _d, displayColumnsWidth = _a.displayColumnsWidth, filters = _a.filters, comparators = _a.comparators, handleUxChange = _a.handleUxChange, rowsData = _a.rowsData, uxState = _a.uxState;
|
|
8
|
+
var columns = _a.columns, groups = _a.groups, actionColumn = _a.actionColumn, onChange = _a.onChange, _b = _a.filterValues, filterValues = _b === void 0 ? {} : _b, displayColumnsWidth = _a.displayColumnsWidth, filters = _a.filters, comparators = _a.comparators, handleUxChange = _a.handleUxChange, rowsData = _a.rowsData, uxState = _a.uxState;
|
|
24
9
|
var handleOnChange = throttle(onChange, 500);
|
|
25
|
-
|
|
26
|
-
return actionColumn ? __assign({}, getActionCellSizeProps(actionColumn)) : {};
|
|
27
|
-
}, [actionColumn]);
|
|
28
|
-
var _e = useToggleAllCheckbox(rowsData, uxState, handleUxChange), allChecked = _e[0], toggleCheckbox = _e[1];
|
|
29
|
-
var displayCheckbox = (actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.checkAllPosition) === 'top' && (((_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.forceCheckboxes));
|
|
30
|
-
var displayRowNumberLabel = actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.addRowNumbers;
|
|
31
|
-
var rowsNumberLabel = (_c = actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.addRowNumbersLabel) !== null && _c !== void 0 ? _c : '#';
|
|
32
|
-
return (_jsxs(Row, { className: "filterRow", children: [displayCheckbox && (_jsx(Cell, { className: "cell", style: actionColumnStyle, children: _jsx(Checkbox, { checked: allChecked, onChange: toggleCheckbox, label: "" }, "check-all") })), displayRowNumberLabel && (_jsx(Cell, { className: "cell", style: actionColumnStyle, children: _jsx("div", { children: rowsNumberLabel }) })), !!(!displayCheckbox && !displayRowNumberLabel && actionColumn) && (_jsx(Cell, { className: "cell", style: actionColumnStyle }, 'actions')), columns.map(function (column, index) { return (_jsx(ColumnFilterCell, { column: column, onChange: handleOnChange, value: get([getFilterName(column), 'value'], filterValues), others: get([getFilterName(column), 'others'], filterValues), displayColumnWidth: displayColumnsWidth[column.name], filters: filters, comparators: comparators, group: groups === null || groups === void 0 ? void 0 : groups[index] }, index)); })] }));
|
|
10
|
+
return (_jsx(Row, { className: "filterRow", children: columns.map(function (column, index) { return (_jsx(ColumnFilterCell, { column: column, actionColumn: actionColumn, rowsData: rowsData, uxState: uxState, handleUxChange: handleUxChange, onChange: handleOnChange, value: get([getFilterName(column), 'value'], filterValues), others: get([getFilterName(column), 'others'], filterValues), displayColumnWidth: displayColumnsWidth[column.name], filters: filters, comparators: comparators, group: groups === null || groups === void 0 ? void 0 : groups[index] }, index)); }) }));
|
|
33
11
|
};
|
|
34
12
|
export default FilterRow;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import type { ActionColumn, GridActionsType, RowProps, UxState } from '../../../types';
|
|
3
|
+
type Props = {
|
|
4
|
+
actionColumn?: ActionColumn;
|
|
5
|
+
rowsData?: RowProps[];
|
|
6
|
+
uxState?: UxState;
|
|
7
|
+
handleUxChange?: GridActionsType['handleUxChange'];
|
|
8
|
+
};
|
|
9
|
+
declare const ActionFilter: FC<Props>;
|
|
10
|
+
export default ActionFilter;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Checkbox from '../../../../../Forms/Checkbox';
|
|
3
|
+
import { useToggleAllCheckbox } from '../../../hooks/useToggleAllCheckbox';
|
|
4
|
+
import { x } from '@xstyled/styled-components';
|
|
5
|
+
var ActionFilter = function (_a) {
|
|
6
|
+
var _b, _c;
|
|
7
|
+
var actionColumn = _a.actionColumn, rowsData = _a.rowsData, uxState = _a.uxState, handleUxChange = _a.handleUxChange;
|
|
8
|
+
var _d = useToggleAllCheckbox(rowsData || [], uxState || {}, handleUxChange), allChecked = _d[0], toggleCheckbox = _d[1];
|
|
9
|
+
var displayRowNumberLabel = actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.addRowNumbers;
|
|
10
|
+
var rowsNumberLabel = (_b = actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.addRowNumbersLabel) !== null && _b !== void 0 ? _b : '#';
|
|
11
|
+
var displayCheckbox = ((_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.forceCheckboxes);
|
|
12
|
+
return (_jsxs(_Fragment, { children: [displayCheckbox && (_jsx(x.div, { pl: "8px", children: _jsx(Checkbox, { checked: allChecked, onChange: toggleCheckbox, label: "" }, "check-all") })), displayRowNumberLabel && _jsx("div", { children: rowsNumberLabel })] }));
|
|
13
|
+
};
|
|
14
|
+
export default ActionFilter;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DropResult } from 'react-beautiful-dnd';
|
|
2
|
-
import { Settings, ColumnDefinition, ActionColumn, GridSelectorsType, Group, CommonGridProps, GridActionsType } from '../types';
|
|
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
4
|
actionColumn?: ActionColumn;
|
|
5
5
|
columns: ColumnDefinition[];
|
|
@@ -19,32 +19,30 @@ import { Row, Cell } from './Table';
|
|
|
19
19
|
var getStickyComponent = function (columns, stickyTo, displayColumnsWidth) {
|
|
20
20
|
var _a;
|
|
21
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)
|
|
22
|
+
var cellClassName = "cell".concat(getStickyCollClassNames(!!column.sticky, column.stickTo));
|
|
23
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
24
|
});
|
|
25
25
|
};
|
|
26
26
|
var HeadRow = function (_a) {
|
|
27
|
-
var _b;
|
|
28
|
-
var
|
|
29
|
-
var _d = useState(false), showUIElements = _d[0], setShowUIElements = _d[1];
|
|
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;
|
|
28
|
+
var _c = useState(false), showUIElements = _c[0], setShowUIElements = _c[1];
|
|
30
29
|
useEffect(function () {
|
|
31
30
|
setShowUIElements(true);
|
|
32
31
|
}, []);
|
|
33
|
-
var
|
|
32
|
+
var _d = useState(false), isDragDisabled = _d[0], setIsDragDisabled = _d[1];
|
|
34
33
|
var onResizeOver = React.useCallback(function () {
|
|
35
34
|
setIsDragDisabled(true);
|
|
36
35
|
}, [setIsDragDisabled]);
|
|
37
36
|
var onResizeOut = React.useCallback(function () {
|
|
38
37
|
setIsDragDisabled(false);
|
|
39
38
|
}, [setIsDragDisabled]);
|
|
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);
|
|
41
39
|
var onResize = React.useCallback(function (name) { return function (width) {
|
|
42
40
|
handleResizeDrag === null || handleResizeDrag === void 0 ? void 0 : handleResizeDrag(name, width);
|
|
43
41
|
}; }, [handleResizeDrag]);
|
|
44
42
|
var onSetSort = React.useCallback(function (name, systemName) { return function (value) {
|
|
45
43
|
onAddSort && onAddSort(systemName || name, value);
|
|
46
44
|
}; }, [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: [
|
|
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: [(actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.addRowNumbers) && (_jsx(_Fragment, { children: _jsx(Cell, { className: "cell", style: Object.assign(__assign({}, getActionCellSizeProps(actionColumn))) }) })), getStickyComponent(columns, 'left', displayColumnsWidth), columns
|
|
48
46
|
.filter(function (item) { return !item.sticky; })
|
|
49
47
|
.map(function (column, index) { return (_jsx(Draggable, { draggableId: column.name, index: index, isDragDisabled: isDragDisabled || column.sticky, children: function (_a) {
|
|
50
48
|
var _b;
|
|
@@ -5,6 +5,9 @@ export declare const Row: import("styled-components").StyledComponent<"div", imp
|
|
|
5
5
|
}, never>;
|
|
6
6
|
export declare const Cell: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
|
|
7
7
|
align?: string | undefined;
|
|
8
|
+
flexBasis?: number | undefined;
|
|
9
|
+
flexGrow?: number | undefined;
|
|
10
|
+
flexShrink?: number | undefined;
|
|
8
11
|
}, never>;
|
|
9
12
|
export declare const StyledDataRow: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
|
|
10
13
|
hasRowClick?: boolean | undefined;
|
|
@@ -15,9 +18,15 @@ export declare const StyledDataRow: import("styled-components").StyledComponent<
|
|
|
15
18
|
}, never>;
|
|
16
19
|
export declare const TextCell: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
|
|
17
20
|
align?: string | undefined;
|
|
21
|
+
flexBasis?: number | undefined;
|
|
22
|
+
flexGrow?: number | undefined;
|
|
23
|
+
flexShrink?: number | undefined;
|
|
18
24
|
}, never>;
|
|
19
25
|
export declare const MessageCell: import("styled-components").StyledComponent<"div", import("@xstyled/system").Theme, {
|
|
20
26
|
align?: string | undefined;
|
|
27
|
+
flexBasis?: number | undefined;
|
|
28
|
+
flexGrow?: number | undefined;
|
|
29
|
+
flexShrink?: number | undefined;
|
|
21
30
|
} & {
|
|
22
31
|
width: number;
|
|
23
32
|
}, never>;
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
-
return cooked;
|
|
4
|
-
};
|
|
5
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
-
import styled from '@xstyled/styled-components';
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
7
2
|
import { Link as ReactLink } from 'react-router-dom';
|
|
8
|
-
import Spinner from '../../../../Elements/Spinner/Spinner';
|
|
9
3
|
import Icon from '../../../../Elements/Icon/Icon';
|
|
10
|
-
|
|
4
|
+
import Spinner from '../../../../Elements/Spinner/Spinner';
|
|
5
|
+
import { x } from '@xstyled/styled-components';
|
|
11
6
|
export var IconButtonInCell = function (_a) {
|
|
12
7
|
var icon = _a.icon, isLoading = _a.isLoading, onClick = _a.onClick, linkTo = _a.linkTo;
|
|
13
|
-
return (_jsx(
|
|
8
|
+
return (_jsx(_Fragment, { children: isLoading ? (_jsx(Spinner, { variant: "sm" })) : linkTo ? (_jsx(ReactLink, { to: linkTo, "data-cy": "".concat(icon, "IconBtn"), children: _jsx(Icon, { icon: icon || 'warning', size: "16px", fill: "blue2" }) })) : (_jsx(x.span, { onClick: onClick, "data-cy": "".concat(icon, "IconBtn"), cursor: "pointer", h: "100%", w: "100%", display: "flex", alignItems: "center", justifyContent: "center", children: _jsx(Icon, { icon: icon || 'warning', size: "16px", fill: "blue2" }) })) }));
|
|
14
9
|
};
|
|
15
|
-
var templateObject_1;
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
-
type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import type { DataCellProps, ActionColumn, UxState, GridActionsType } from '../../types';
|
|
3
|
+
type Props = DataCellProps<{
|
|
4
|
+
id: string;
|
|
5
|
+
}> & {
|
|
6
|
+
addRowNumbers?: boolean;
|
|
7
|
+
rowIndex?: number;
|
|
8
|
+
actionColumnDefinition?: ActionColumn;
|
|
9
|
+
uxState?: UxState;
|
|
10
|
+
onUxChange?: GridActionsType['handleUxChange'];
|
|
11
|
+
withCheckboxes?: boolean;
|
|
5
12
|
};
|
|
6
|
-
export declare const RowActionsCell:
|
|
13
|
+
export declare const RowActionsCell: FC<Props>;
|
|
7
14
|
export {};
|