@tap-payments/os-micro-frontend-shared 0.0.209 → 0.0.212
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/build/components/AppServices/AppServices.js +2 -4
- package/build/components/RangeCalender/RangeCalender.d.ts +6 -1
- package/build/components/RangeCalender/RangeCalender.js +3 -3
- package/build/components/Routes/PrivateRoute.js +1 -1
- package/build/components/VirtualTable/SheetView/SheetViewTableHeader.d.ts +2 -2
- package/build/components/VirtualTable/SheetView/SheetViewTableHeader.js +2 -2
- package/build/components/VirtualTable/SheetView/SheetViewVirtualTable.js +16 -44
- package/build/components/VirtualTable/components/ColumnFilter/Inputs/Inputs.d.ts +1 -1
- package/build/components/VirtualTable/components/ColumnFilter/Inputs/Inputs.js +2 -1
- package/build/components/VirtualTable/components/TableRow.d.ts +3 -3
- package/build/components/VirtualTable/components/TableRow.js +5 -5
- package/build/components/VirtualTable/components/virtualScroll/ListItemWrapper.js +1 -1
- package/build/hooks/useCheckUserLoggedIn.js +1 -1
- package/build/types/table.d.ts +1 -0
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import React, { memo, useEffect, useRef, useState, useMemo } from 'react';
|
|
3
3
|
import { Box } from '@mui/material';
|
|
4
4
|
import { useTranslation } from 'react-i18next';
|
|
5
|
-
import {
|
|
5
|
+
import { useLocation } from 'react-router';
|
|
6
6
|
import { StyledIconForDropDown, StyledMenuTitle, StyledOption, StyledSelect, StyledSelectComponent } from '../index.js';
|
|
7
7
|
import { APP_CODES, blackHeadingDownArrow, blueHeadingDropdownArrow } from '../../constants/index.js';
|
|
8
8
|
import { getNameText } from '../../utils/index.js';
|
|
@@ -17,7 +17,6 @@ function AppServices({ appInfo, userApp, onChangeAppServiceCode, onClickServiceI
|
|
|
17
17
|
const [selectedOption, setSelectedOption] = useState('');
|
|
18
18
|
const servicesRef = useRef(null);
|
|
19
19
|
const [openDropdown, setOpenDropdown] = React.useState(false);
|
|
20
|
-
const navigate = useNavigate();
|
|
21
20
|
const pathname = useLocation();
|
|
22
21
|
const { i18n } = useTranslation();
|
|
23
22
|
const services = useMemo(() => {
|
|
@@ -50,12 +49,11 @@ function AppServices({ appInfo, userApp, onChangeAppServiceCode, onClickServiceI
|
|
|
50
49
|
useEffect(() => {
|
|
51
50
|
setIsDropdown(Number(appInfo === null || appInfo === void 0 ? void 0 : appInfo.dimensions.width) < initServicesWidth + 10);
|
|
52
51
|
}, [appInfo === null || appInfo === void 0 ? void 0 : appInfo.dimensions.width]);
|
|
53
|
-
const renderValue = (selected) => _jsx(StyledSelectComponent, { children: selected });
|
|
54
52
|
const navigateToService = (serviceCode) => {
|
|
55
|
-
navigate(`${appInfo.appCode.toLowerCase()}/${serviceCode.toLowerCase()}`);
|
|
56
53
|
onChangeAppServiceCode === null || onChangeAppServiceCode === void 0 ? void 0 : onChangeAppServiceCode(serviceCode);
|
|
57
54
|
setOpenDropdown(false);
|
|
58
55
|
};
|
|
56
|
+
const renderValue = (selected) => _jsx(StyledSelectComponent, { children: selected });
|
|
59
57
|
return (_jsxs(Wrapper, Object.assign({ maximized: appInfo.isMaximized }, { children: [services.length && !isDropdown && (_jsx(Box, Object.assign({ ref: servicesRef, display: "flex", gap: "8px", flexDirection: "row", sx: { userSelect: 'none' } }, { children: services.map((service, idx) => (_jsx(ServiceItem, { appInfo: appInfo, onClickServiceItem: onClickServiceItem, navigateToMenuItem: navigateToService, name: getNameText(service.name, i18n.language) || '', code: service.code }, `service-item-${service.code}-${idx}`))) }))), services.length && isDropdown && (_jsx(StyledSelect, Object.assign({ open: openDropdown, onClick: handleOpenDropdown, displayEmpty: true, inputProps: { 'aria-label': 'Without label' }, MenuProps: {
|
|
60
58
|
anchorOrigin: {
|
|
61
59
|
vertical: 40,
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { MouseEvent } from 'react';
|
|
1
2
|
import type { CalenderMode, Timezone } from '../../types/index.js';
|
|
3
|
+
import { SxProps } from '@mui/system';
|
|
2
4
|
interface RangeCalendarProps {
|
|
3
5
|
defaultDate: [Date, Date];
|
|
4
6
|
onDateChange: (date: [Date, Date], timezoneOffset?: number) => void;
|
|
@@ -15,6 +17,9 @@ interface RangeCalendarProps {
|
|
|
15
17
|
onChangeTimezone?: (timezone: Timezone) => void;
|
|
16
18
|
defaultTimezone: Timezone;
|
|
17
19
|
browserTimezone: string;
|
|
20
|
+
calendarPopperSx?: SxProps;
|
|
21
|
+
renderCalendarButton?: (open: boolean, onOpenCalender: (event: MouseEvent<HTMLElement>) => void) => React.ReactNode;
|
|
22
|
+
mainSx?: SxProps;
|
|
18
23
|
}
|
|
19
|
-
declare function RangeCalender({ defaultDate, onDateChange, mode, onCalendarModeSwitch, numberOfMonths, noTimezone, noQuickFilter, maxDateRange, onCalendarGroupChange, groupBy, timezone, onChangeTimezoneHistory, onChangeTimezone, defaultTimezone, browserTimezone, }: RangeCalendarProps): import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
declare function RangeCalender({ defaultDate, onDateChange, mode, onCalendarModeSwitch, numberOfMonths, noTimezone, noQuickFilter, maxDateRange, onCalendarGroupChange, groupBy, timezone, onChangeTimezoneHistory, onChangeTimezone, defaultTimezone, browserTimezone, calendarPopperSx, renderCalendarButton, mainSx, }: RangeCalendarProps): import("react/jsx-runtime").JSX.Element;
|
|
20
25
|
export default RangeCalender;
|
|
@@ -13,7 +13,7 @@ import QuickFilters from './components/QuickFilters';
|
|
|
13
13
|
import RangeDatePicker from './components/RangeDatepicker';
|
|
14
14
|
import CustomTimezone from './components/Timezone';
|
|
15
15
|
import { ButtonsWrapper, CalenderWrapper, CancelButton, FiltersArea, Footer, Main, OkayButton, SelectedDate, TimeZone, Settings } from './style';
|
|
16
|
-
function RangeCalender({ defaultDate, onDateChange, mode = 'gregorian', onCalendarModeSwitch, numberOfMonths, noTimezone, noQuickFilter, maxDateRange, onCalendarGroupChange, groupBy, timezone, onChangeTimezoneHistory, onChangeTimezone, defaultTimezone, browserTimezone, }) {
|
|
16
|
+
function RangeCalender({ defaultDate, onDateChange, mode = 'gregorian', onCalendarModeSwitch, numberOfMonths, noTimezone, noQuickFilter, maxDateRange, onCalendarGroupChange, groupBy, timezone, onChangeTimezoneHistory, onChangeTimezone, defaultTimezone, browserTimezone, calendarPopperSx, renderCalendarButton, mainSx, }) {
|
|
17
17
|
const [dates, setDates] = useState([new DateObject(defaultDate[0]), new DateObject(defaultDate[1])]);
|
|
18
18
|
const [values, setValues] = useState(dates);
|
|
19
19
|
const [selectedTimezone, setSelectedTimezone] = useState(timezone);
|
|
@@ -82,10 +82,10 @@ function RangeCalender({ defaultDate, onDateChange, mode = 'gregorian', onCalend
|
|
|
82
82
|
if (calendarRef.current)
|
|
83
83
|
calendarRef.current.set({ date: newValues[0] });
|
|
84
84
|
};
|
|
85
|
-
return (_jsxs(Main, Object.assign({ "data-testid": "RangeCalender" }, { children: [_jsx(SelectedDate, Object.assign({ onClick: onOpenCalender, open: open }, { children: (dates[0] || dates[1]) && getSelectedDate() })), open && (_jsx(CustomBackdrop, { onClick: (e) => {
|
|
85
|
+
return (_jsxs(Main, Object.assign({ "data-testid": "RangeCalender", sx: mainSx }, { children: [renderCalendarButton ? (renderCalendarButton(open, onOpenCalender)) : (_jsx(SelectedDate, Object.assign({ onClick: onOpenCalender, open: open }, { children: (dates[0] || dates[1]) && getSelectedDate() }))), open && (_jsx(CustomBackdrop, { onClick: (e) => {
|
|
86
86
|
e.stopPropagation();
|
|
87
87
|
onCloseCalender();
|
|
88
|
-
} })), _jsx(Popper, Object.assign({ open: open, anchorEl: anchorEl, placement: "bottom-end", sx: { zIndex: 3 } }, { children: _jsxs(CalenderWrapper, { children: [!noQuickFilter && (_jsxs(FiltersArea, { children: [_jsx(QuickFilters, { onChange: onChangeQuickFilter, isHijri: isHijri }), _jsxs(Settings, { children: [groupBy && (_jsx(GroupBy, { groupBy: selectedGroupBy, isCalenderOpen: open, onUpdate: (group) => {
|
|
88
|
+
} })), _jsx(Popper, Object.assign({ open: open, anchorEl: anchorEl, placement: "bottom-end", sx: Object.assign({ zIndex: 3 }, calendarPopperSx) }, { children: _jsxs(CalenderWrapper, { children: [!noQuickFilter && (_jsxs(FiltersArea, { children: [_jsx(QuickFilters, { onChange: onChangeQuickFilter, isHijri: isHijri }), _jsxs(Settings, { children: [groupBy && (_jsx(GroupBy, { groupBy: selectedGroupBy, isCalenderOpen: open, onUpdate: (group) => {
|
|
89
89
|
setSelectedGroupBy(group);
|
|
90
90
|
} })), _jsx(Hijri, { isHijri: isHijri, onCalendarModeSwitch: onCalendarModeSwitch })] })] })), _jsxs(Box, Object.assign({ sx: { display: 'flex', flexDirection: 'column', justifyContent: 'space-between' } }, { children: [_jsx(RangeDatePicker, { values: values, onChange: onChange, isHijri: isHijri, ref: calendarRef, numberOfMonths: numberOfMonths }), _jsx(Collapse, Object.assign({ in: isError && Boolean(maxDateRange) }, { children: _jsx(Error, { error: t('dateRangeError', { number: maxDateRange }), sx: { marginInline: '16px', marginBottom: '16px' } }) })), _jsxs(Footer, Object.assign({ sx: { borderBottomLeftRadius: '8px' } }, { children: [!noTimezone ? (_jsx(TimeZone, { children: _jsx(CustomTimezone, { onChange: setSelectedTimezone, selectedTimezone: selectedTimezone, defaultTimezone: defaultTimezone, browserTimezone: browserTimezone }, String(open)) })) : (_jsx("div", {})), _jsxs(ButtonsWrapper, { children: [_jsx(CancelButton, Object.assign({ variant: "contained", onClick: onCloseCalender }, { children: t('cancel') })), _jsx(OkayButton, Object.assign({ variant: "contained", onClick: submitDate }, { children: t('okay') }))] })] }))] }))] }) }))] })));
|
|
91
91
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { memo, Suspense } from 'react';
|
|
3
|
-
import { Navigate } from 'react-router
|
|
3
|
+
import { Navigate } from 'react-router';
|
|
4
4
|
function PrivateRoute({ children, isLoggedIn }) {
|
|
5
5
|
if (!isLoggedIn) {
|
|
6
6
|
return _jsx(Navigate, { to: "/login" });
|
|
@@ -11,9 +11,9 @@ interface SheetViewTableHeaderProps {
|
|
|
11
11
|
onColumnPin?: (columnId: string, position: 'start' | 'end' | 'unpin') => void;
|
|
12
12
|
isPinnable?: boolean;
|
|
13
13
|
lastColumnId?: string | null;
|
|
14
|
-
|
|
14
|
+
selectedColumn?: string | null;
|
|
15
15
|
onColumnClick?: (columnId: string, event: React.MouseEvent) => void;
|
|
16
16
|
}
|
|
17
|
-
declare function SheetViewTableHeader({ columns, headerProps, showBackDrop, onColumnSort, columnsSorting, pinnedColumns, onColumnPin, isPinnable, lastColumnId,
|
|
17
|
+
declare function SheetViewTableHeader({ columns, headerProps, showBackDrop, onColumnSort, columnsSorting, pinnedColumns, onColumnPin, isPinnable, lastColumnId, selectedColumn, onColumnClick, }: SheetViewTableHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
18
18
|
declare const _default: import("react").MemoExoticComponent<typeof SheetViewTableHeader>;
|
|
19
19
|
export default _default;
|
|
@@ -6,7 +6,7 @@ import { columnIcon, pinIcon, sortAzIcon, sortZaIcon, unpinIcon } from '../../..
|
|
|
6
6
|
import ColumnFilter from '../components/ColumnFilter';
|
|
7
7
|
import { StyledCell } from '../style';
|
|
8
8
|
import { ActionIcon, ColumnIcon, PinIconContainer, StyledHeader, StyledMUITableRow } from './style';
|
|
9
|
-
function SheetViewTableHeader({ columns, headerProps, showBackDrop, onColumnSort, columnsSorting, pinnedColumns = [], onColumnPin, isPinnable = false, lastColumnId,
|
|
9
|
+
function SheetViewTableHeader({ columns, headerProps, showBackDrop, onColumnSort, columnsSorting, pinnedColumns = [], onColumnPin, isPinnable = false, lastColumnId, selectedColumn = null, onColumnClick, }) {
|
|
10
10
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
11
11
|
const open = Boolean(anchorEl);
|
|
12
12
|
const theme = useTheme();
|
|
@@ -44,7 +44,7 @@ function SheetViewTableHeader({ columns, headerProps, showBackDrop, onColumnSort
|
|
|
44
44
|
const isLast = id === columns[columns.length - 1].id;
|
|
45
45
|
const isPinned = pinnedColumns.includes(id);
|
|
46
46
|
const isDefaultPinned = !!column.isDefaultPinned;
|
|
47
|
-
const isSelected =
|
|
47
|
+
const isSelected = selectedColumn === id;
|
|
48
48
|
return (_jsxs(StyledCell, Object.assign({ "data-id": id, component: "div", "data-testid": "SheetViewVirtualTable_TableHeader_StyledCell", "data-column-id": column.id, "data-column-width": column.width, "data-column-width-used": column.width, "data-column-align": column.align, "data-column-order": column.order, "data-column-header": typeof column.header === 'string' ? column.header : 'component', "data-column-sortable": !!column.sortable, "data-column-filterable": !!column.filter, "data-column-pinned": isPinned, isFirst: isFirst, isLast: isLast, isSheetView: true, onClick: (event) => onColumnClick === null || onColumnClick === void 0 ? void 0 : onColumnClick(id, event), sx: Object.assign({ display: 'flex', gap: theme.spacing(0.5), alignItems: 'center', justifyContent: align === 'right' ? 'flex-end' : 'flex-start', width: column.width, textAlign: align, overflow: 'unset', cursor: 'pointer', boxSizing: 'border-box', border: isSelected ? '1px solid #1F88D0' : '1px solid #F2F2F2', backgroundColor: isSelected ? '#e3f2fd' : '#FCFCFC', height: isSelected ? '100%' : 'auto', minHeight: isSelected ? '28px' : 'auto' }, headerStyle) }, { children: [typeof header === 'function' ? (header()) : (_jsx(Box, Object.assign({ "data-testid": "SheetViewTableHeader_columns_header", sx: { maxWidth: '100%', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' } }, { children: header && (_jsx("span", Object.assign({ style: { textOverflow: 'ellipsis', width: '80%', overflow: 'hidden' }, "data-testid": "SheetViewVirtualTable_TableHeader_StyledCell_header_text" }, { children: header }))) }))), filter && _jsx(ColumnFilter, Object.assign({}, filter)), sortable && _jsx(ColumnIcon, { onClick: sortable ? handleClick : undefined, src: columnIcon, alt: "column-icon", "data-id": id }), isPinnable && pinnable && !isDefaultPinned && (_jsx(PinIconContainer, Object.assign({ isPinned: isPinned, onClick: (event) => {
|
|
49
49
|
event.stopPropagation();
|
|
50
50
|
handlePinClick(id);
|
|
@@ -25,7 +25,7 @@ import SheetViewTableHeader from './SheetViewTableHeader';
|
|
|
25
25
|
import AutoSizer from 'react-virtualized-auto-sizer';
|
|
26
26
|
import { usePinnedColumns } from './hooks/usePinnedColumns';
|
|
27
27
|
import { useSynchronizedScroll } from './hooks/useSynchronizedScroll';
|
|
28
|
-
const createItemData = memoize((columns, isLoading, rows, rowProps, scrollToIndex, lastItemIndex, totalCount, isError, areAllRowsLoaded, isPinned,
|
|
28
|
+
const createItemData = memoize((columns, isLoading, rows, rowProps, scrollToIndex, lastItemIndex, totalCount, isError, areAllRowsLoaded, isPinned, selectedCell, selectedColumn, onCellClick) => ({
|
|
29
29
|
columns,
|
|
30
30
|
isLoading,
|
|
31
31
|
rows,
|
|
@@ -39,8 +39,8 @@ const createItemData = memoize((columns, isLoading, rows, rowProps, scrollToInde
|
|
|
39
39
|
newLoadedRowsEndIndex: lastItemIndex,
|
|
40
40
|
isSheetView: true,
|
|
41
41
|
isPinned,
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
selectedCell,
|
|
43
|
+
selectedColumn,
|
|
44
44
|
onCellClick,
|
|
45
45
|
}));
|
|
46
46
|
function SheetViewVirtualTable({ columns, rows, threshold = TABLE_THRESHOLD, showHeader, headerProps, rowProps, footerProps, rowHeight = 28, isLoading, error, columnsSorting, onColumnSort, loadMoreItems, isFetchingNextPage, triggerDataRefetch, scrollToIndex, showBackgroundColor, areAllRowsLoaded = false, tableBodyStyles, tableTitle, dragControls, onColumnPin, clearBackdropVisibilityTimeout = 100, isPinnable = false, tableMode, }) {
|
|
@@ -48,46 +48,18 @@ function SheetViewVirtualTable({ columns, rows, threshold = TABLE_THRESHOLD, sho
|
|
|
48
48
|
const theme = useTheme();
|
|
49
49
|
const { pinnedStartColumns, pinnedEndColumns, handleColumnPin, pinnedStartColumnsData, pinnedEndColumnsData, unpinnedColumnsData, orderedColumns, lastColumnId, } = usePinnedColumns(columns, isPinnable, onColumnPin);
|
|
50
50
|
const { pinnedStartVirtualListRef, scrollableVirtualListRef, pinnedEndVirtualListRef, handleScroll } = useSynchronizedScroll();
|
|
51
|
-
const [
|
|
52
|
-
const [
|
|
51
|
+
const [selectedCell, setSelectedCell] = useState(null);
|
|
52
|
+
const [selectedColumn, setSelectedColumn] = useState(null);
|
|
53
53
|
const handleCellClick = useCallback((rowIndex, columnId, event) => {
|
|
54
54
|
event.stopPropagation();
|
|
55
55
|
const cellKey = `${rowIndex}-${columnId}`;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if (newSelected.has(cellKey)) {
|
|
59
|
-
newSelected.delete(cellKey);
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
if (!event.ctrlKey && !event.metaKey) {
|
|
63
|
-
newSelected.clear();
|
|
64
|
-
}
|
|
65
|
-
newSelected.add(cellKey);
|
|
66
|
-
}
|
|
67
|
-
return newSelected;
|
|
68
|
-
});
|
|
69
|
-
if (!event.ctrlKey && !event.metaKey) {
|
|
70
|
-
setSelectedColumns(new Set());
|
|
71
|
-
}
|
|
56
|
+
setSelectedCell((prev) => (prev === cellKey ? null : cellKey));
|
|
57
|
+
setSelectedColumn(null);
|
|
72
58
|
}, []);
|
|
73
59
|
const handleColumnClick = useCallback((columnId, event) => {
|
|
74
60
|
event.stopPropagation();
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (newSelected.has(columnId)) {
|
|
78
|
-
newSelected.delete(columnId);
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
if (!event.ctrlKey && !event.metaKey) {
|
|
82
|
-
newSelected.clear();
|
|
83
|
-
}
|
|
84
|
-
newSelected.add(columnId);
|
|
85
|
-
}
|
|
86
|
-
return newSelected;
|
|
87
|
-
});
|
|
88
|
-
if (!event.ctrlKey && !event.metaKey) {
|
|
89
|
-
setSelectedCells(new Set());
|
|
90
|
-
}
|
|
61
|
+
setSelectedColumn((prev) => (prev === columnId ? null : columnId));
|
|
62
|
+
setSelectedCell(null);
|
|
91
63
|
}, []);
|
|
92
64
|
const onPointerDown = (e) => {
|
|
93
65
|
dragControls === null || dragControls === void 0 ? void 0 : dragControls.start(e);
|
|
@@ -105,9 +77,9 @@ function SheetViewVirtualTable({ columns, rows, threshold = TABLE_THRESHOLD, sho
|
|
|
105
77
|
const lastItemIndex = rows.length - 1;
|
|
106
78
|
const areTotalRowsNotFillingHeight = isHeightNotFullyFilledByRows(rows.length) && !tableLoading;
|
|
107
79
|
const itemsCount = isDelayedFetchingNextPage || (areAllRowsLoaded && !areTotalRowsNotFillingHeight) ? rows.length + 1 : rows.length;
|
|
108
|
-
const pinnedStartItemData = createItemData(pinnedStartColumnsData, isDelayedFetchingNextPage, rows, rowProps, scrollToIndex, lastItemIndex, (_a = footerProps === null || footerProps === void 0 ? void 0 : footerProps.totalCount) !== null && _a !== void 0 ? _a : 0, isError, areAllRowsLoaded && !areTotalRowsNotFillingHeight, true,
|
|
109
|
-
const pinnedEndItemData = createItemData(pinnedEndColumnsData, isDelayedFetchingNextPage, rows, rowProps, scrollToIndex, lastItemIndex, (_b = footerProps === null || footerProps === void 0 ? void 0 : footerProps.totalCount) !== null && _b !== void 0 ? _b : 0, isError, areAllRowsLoaded && !areTotalRowsNotFillingHeight, true,
|
|
110
|
-
const unpinnedItemData = createItemData(unpinnedColumnsData, isDelayedFetchingNextPage, rows, rowProps, scrollToIndex, lastItemIndex, (_c = footerProps === null || footerProps === void 0 ? void 0 : footerProps.totalCount) !== null && _c !== void 0 ? _c : 0, isError, areAllRowsLoaded && !areTotalRowsNotFillingHeight, false,
|
|
80
|
+
const pinnedStartItemData = createItemData(pinnedStartColumnsData, isDelayedFetchingNextPage, rows, rowProps, scrollToIndex, lastItemIndex, (_a = footerProps === null || footerProps === void 0 ? void 0 : footerProps.totalCount) !== null && _a !== void 0 ? _a : 0, isError, areAllRowsLoaded && !areTotalRowsNotFillingHeight, true, selectedCell, selectedColumn, handleCellClick);
|
|
81
|
+
const pinnedEndItemData = createItemData(pinnedEndColumnsData, isDelayedFetchingNextPage, rows, rowProps, scrollToIndex, lastItemIndex, (_b = footerProps === null || footerProps === void 0 ? void 0 : footerProps.totalCount) !== null && _b !== void 0 ? _b : 0, isError, areAllRowsLoaded && !areTotalRowsNotFillingHeight, true, selectedCell, selectedColumn, handleCellClick);
|
|
82
|
+
const unpinnedItemData = createItemData(unpinnedColumnsData, isDelayedFetchingNextPage, rows, rowProps, scrollToIndex, lastItemIndex, (_c = footerProps === null || footerProps === void 0 ? void 0 : footerProps.totalCount) !== null && _c !== void 0 ? _c : 0, isError, areAllRowsLoaded && !areTotalRowsNotFillingHeight, false, selectedCell, selectedColumn, handleCellClick);
|
|
111
83
|
const createVirtualTableContainer = useCallback((columnsToRender, containerKey, isPinned = false, fixedWidth) => {
|
|
112
84
|
const tableItemsCount = itemsCount;
|
|
113
85
|
const handleOnLoadMoreItems = () => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -138,8 +110,8 @@ function SheetViewVirtualTable({ columns, rows, threshold = TABLE_THRESHOLD, sho
|
|
|
138
110
|
handleScroll,
|
|
139
111
|
scrollToIndex,
|
|
140
112
|
areTotalRowsNotFillingHeight,
|
|
141
|
-
|
|
142
|
-
|
|
113
|
+
selectedCell,
|
|
114
|
+
selectedColumn,
|
|
143
115
|
handleCellClick,
|
|
144
116
|
]);
|
|
145
117
|
const showNoDataView = tableLoading || tableError || tableEmpty || hasTimeoutError;
|
|
@@ -156,12 +128,12 @@ function SheetViewVirtualTable({ columns, rows, threshold = TABLE_THRESHOLD, sho
|
|
|
156
128
|
const containerKey = position === 'start' ? 'pinnedStart' : 'pinnedEnd';
|
|
157
129
|
if (columnsData.length === 0)
|
|
158
130
|
return null;
|
|
159
|
-
return (_jsx(Wrapper, Object.assign({ width: columnsWidth }, { children: _jsxs(StyledTableBox, Object.assign({ as: "main", id: "sheet-table-box-container", "aria-labelledby": "sheet-table-box-container", "data-testid": "SheetViewVirtualTable_StyledTableBox", "data-title": tableTitle, "data-direction": theme.direction, "data-are-all-rows-loaded": !!areAllRowsLoaded, "data-is-fetching-next-page": !!isFetchingNextPage, "data-scroll-to-index": scrollToIndex, "data-is-loading": !!isLoading, "data-is-error": !!isError, "data-is-error-timeout": !!hasTimeoutError, "data-show-background-color": !!showBackgroundColor, "data-table-mode": tableMode, height: "100%", dir: theme.direction, showBackgroundColor: showBackgroundColor, showNoDataView: showNoDataView }, { children: [showHeader && (_jsx(SheetViewTableHeader, { "data-testid": "SheetViewVirtualTable_PinnedTableHeader", columnsSorting: columnsSorting, onColumnSort: onColumnSort, columns: columnsData, headerProps: headerProps, showBackDrop: showBackDrop, pinnedColumns: pinnedColumnsList, onColumnPin: handleColumnPin, isPinnable: isPinnable, lastColumnId: lastColumnId,
|
|
131
|
+
return (_jsx(Wrapper, Object.assign({ width: columnsWidth }, { children: _jsxs(StyledTableBox, Object.assign({ as: "main", id: "sheet-table-box-container", "aria-labelledby": "sheet-table-box-container", "data-testid": "SheetViewVirtualTable_StyledTableBox", "data-title": tableTitle, "data-direction": theme.direction, "data-are-all-rows-loaded": !!areAllRowsLoaded, "data-is-fetching-next-page": !!isFetchingNextPage, "data-scroll-to-index": scrollToIndex, "data-is-loading": !!isLoading, "data-is-error": !!isError, "data-is-error-timeout": !!hasTimeoutError, "data-show-background-color": !!showBackgroundColor, "data-table-mode": tableMode, height: "100%", dir: theme.direction, showBackgroundColor: showBackgroundColor, showNoDataView: showNoDataView }, { children: [showHeader && (_jsx(SheetViewTableHeader, { "data-testid": "SheetViewVirtualTable_PinnedTableHeader", columnsSorting: columnsSorting, onColumnSort: onColumnSort, columns: columnsData, headerProps: headerProps, showBackDrop: showBackDrop, pinnedColumns: pinnedColumnsList, onColumnPin: handleColumnPin, isPinnable: isPinnable, lastColumnId: lastColumnId, selectedColumn: selectedColumn, onColumnClick: handleColumnClick })), _jsx(TableWrapper, Object.assign({ "data-testid": "VirtualTable_TableWrapper", sx: {
|
|
160
132
|
width: '100%',
|
|
161
133
|
minWidth: 'fit-content',
|
|
162
134
|
} }, { children: _jsx(StyledBox, Object.assign({ "data-testid": "SheetViewVirtualTable_PinnedStyledBox", hidePadding: true, className: "list-wrapper" }, { children: createVirtualTableContainer(columnsData, containerKey, true, columnsWidth) })) }))] })) })));
|
|
163
135
|
};
|
|
164
|
-
return (_jsxs(_Fragment, { children: [_jsxs(TableContainer, { children: [showNoDataView ? (_jsx(StyledTableBox, Object.assign({ as: "main", id: "sheet-table-box-container", "aria-labelledby": "sheet-table-box-container", "data-testid": "SheetViewVirtualTable_StyledTableBox", "data-title": tableTitle, "data-direction": theme.direction, "data-are-all-rows-loaded": !!areAllRowsLoaded, "data-is-fetching-next-page": !!isFetchingNextPage, "data-scroll-to-index": scrollToIndex, "data-is-loading": !!isLoading, "data-is-error": !!isError, "data-is-error-timeout": !!hasTimeoutError, "data-show-background-color": !!showBackgroundColor, "data-table-mode": tableMode, height: "100%", dir: theme.direction, showBackgroundColor: showBackgroundColor, showNoDataView: showNoDataView }, { children: _jsx(TableWrapper, Object.assign({ isSheetView: true, "data-testid": "SheetViewVirtualTable_TableWrapper", showNoDataView: showNoDataView, sx: tableBodyStyles }, { children: _jsx(TableNoData, { error: error, tableEmpty: tableEmpty, isTimeoutError: hasTimeoutError, tableError: tableError, tableLoading: tableLoading, orderedColumns: orderedColumns, triggerDataRefetch: triggerDataRefetch, footerProps: footerProps }) })) }))) : (_jsxs(SheetViewVirtualTableWrapper, { children: [renderPinnedColumn('start', pinnedStartColumnsData, pinnedStartColumnsWidth, pinnedStartColumns), _jsx(MainTableWrapper, Object.assign({ hasPinnedStart: pinnedStartColumnsData.length > 0, hasPinnedEnd: pinnedEndColumnsData.length > 0 }, { children: _jsx(StyledTableBox, Object.assign({ as: "main", id: "sheet-table-box-container", "aria-labelledby": "sheet-table-box-container", "data-testid": "SheetViewVirtualTable_StyledTableBox", "data-title": tableTitle, "data-direction": theme.direction, "data-are-all-rows-loaded": !!areAllRowsLoaded, "data-is-fetching-next-page": !!isFetchingNextPage, "data-scroll-to-index": scrollToIndex, "data-is-loading": !!isLoading, "data-is-error": !!isError, "data-is-error-timeout": !!hasTimeoutError, "data-show-background-color": !!showBackgroundColor, "data-table-mode": tableMode, height: "100%", dir: theme.direction, showBackgroundColor: showBackgroundColor, showNoDataView: showNoDataView, scrollable: true }, { children: _jsxs(TableWrapper, Object.assign({ "data-testid": "SheetViewVirtualTable_TableWrapper", showNoDataView: showNoDataView, sx: Object.assign(Object.assign({}, tableBodyStyles), { display: 'flex', flexDirection: 'column', height: '100%' }) }, { children: [showHeader && (_jsx(UnpinnedTableHeaderWrapper, { children: _jsx(SheetViewTableHeader, { "data-testid": "SheetViewVirtualTable_UnpinnedTableHeader", columnsSorting: columnsSorting, onColumnSort: onColumnSort, columns: unpinnedColumnsData, headerProps: headerProps, showBackDrop: showBackDrop, pinnedColumns: [...pinnedStartColumns, ...pinnedEndColumns], onColumnPin: handleColumnPin, isPinnable: isPinnable, lastColumnId: lastColumnId,
|
|
136
|
+
return (_jsxs(_Fragment, { children: [_jsxs(TableContainer, { children: [showNoDataView ? (_jsx(StyledTableBox, Object.assign({ as: "main", id: "sheet-table-box-container", "aria-labelledby": "sheet-table-box-container", "data-testid": "SheetViewVirtualTable_StyledTableBox", "data-title": tableTitle, "data-direction": theme.direction, "data-are-all-rows-loaded": !!areAllRowsLoaded, "data-is-fetching-next-page": !!isFetchingNextPage, "data-scroll-to-index": scrollToIndex, "data-is-loading": !!isLoading, "data-is-error": !!isError, "data-is-error-timeout": !!hasTimeoutError, "data-show-background-color": !!showBackgroundColor, "data-table-mode": tableMode, height: "100%", dir: theme.direction, showBackgroundColor: showBackgroundColor, showNoDataView: showNoDataView }, { children: _jsx(TableWrapper, Object.assign({ isSheetView: true, "data-testid": "SheetViewVirtualTable_TableWrapper", showNoDataView: showNoDataView, sx: tableBodyStyles }, { children: _jsx(TableNoData, { error: error, tableEmpty: tableEmpty, isTimeoutError: hasTimeoutError, tableError: tableError, tableLoading: tableLoading, orderedColumns: orderedColumns, triggerDataRefetch: triggerDataRefetch, footerProps: footerProps }) })) }))) : (_jsxs(SheetViewVirtualTableWrapper, { children: [renderPinnedColumn('start', pinnedStartColumnsData, pinnedStartColumnsWidth, pinnedStartColumns), _jsx(MainTableWrapper, Object.assign({ hasPinnedStart: pinnedStartColumnsData.length > 0, hasPinnedEnd: pinnedEndColumnsData.length > 0 }, { children: _jsx(StyledTableBox, Object.assign({ as: "main", id: "sheet-table-box-container", "aria-labelledby": "sheet-table-box-container", "data-testid": "SheetViewVirtualTable_StyledTableBox", "data-title": tableTitle, "data-direction": theme.direction, "data-are-all-rows-loaded": !!areAllRowsLoaded, "data-is-fetching-next-page": !!isFetchingNextPage, "data-scroll-to-index": scrollToIndex, "data-is-loading": !!isLoading, "data-is-error": !!isError, "data-is-error-timeout": !!hasTimeoutError, "data-show-background-color": !!showBackgroundColor, "data-table-mode": tableMode, height: "100%", dir: theme.direction, showBackgroundColor: showBackgroundColor, showNoDataView: showNoDataView, scrollable: true }, { children: _jsxs(TableWrapper, Object.assign({ "data-testid": "SheetViewVirtualTable_TableWrapper", showNoDataView: showNoDataView, sx: Object.assign(Object.assign({}, tableBodyStyles), { display: 'flex', flexDirection: 'column', height: '100%' }) }, { children: [showHeader && (_jsx(UnpinnedTableHeaderWrapper, { children: _jsx(SheetViewTableHeader, { "data-testid": "SheetViewVirtualTable_UnpinnedTableHeader", columnsSorting: columnsSorting, onColumnSort: onColumnSort, columns: unpinnedColumnsData, headerProps: headerProps, showBackDrop: showBackDrop, pinnedColumns: [...pinnedStartColumns, ...pinnedEndColumns], onColumnPin: handleColumnPin, isPinnable: isPinnable, lastColumnId: lastColumnId, selectedColumn: selectedColumn, onColumnClick: handleColumnClick }) })), _jsx(TableWrapper, Object.assign({ "data-testid": "VirtualTable_TableWrapper", sx: {
|
|
165
137
|
width: '100%',
|
|
166
138
|
minWidth: 'fit-content',
|
|
167
139
|
} }, { children: _jsx(StyledBox, Object.assign({ "data-testid": "SheetViewVirtualTable_ScrollableStyledBox", hidePadding: true, className: "list-wrapper" }, { children: createVirtualTableContainer(unpinnedColumnsData, 'scrollable', false) })) }))] })) })) })), renderPinnedColumn('end', pinnedEndColumnsData, pinnedEndColumnsWidth, [...pinnedStartColumns, ...pinnedEndColumns])] })), !showNoDataView && areTotalRowsNotFillingHeight && !isFetchingNextPage && (_jsx(TableLastItem, { height: (itemsCount + 1) * TABLE_ROW_HEIGHT, sandboxMode: footerProps === null || footerProps === void 0 ? void 0 : footerProps.sandboxMode, "data-testid": "SheetViewVirtualTable_TableLastItem" }))] }), _jsx(TableFooter, Object.assign({ "data-testid": "SheetViewVirtualTable_TableFooter", showSeparator: true, showBackDrop: showBackDrop, onPointerDown: onPointerDown }, footerProps))] }));
|
|
@@ -3,5 +3,5 @@ interface InputsI {
|
|
|
3
3
|
onCloseDropdown: () => void;
|
|
4
4
|
filter: IColumnFilter & IColumnFilterInputs;
|
|
5
5
|
}
|
|
6
|
-
declare function Inputs({ onCloseDropdown, filter: { options, onConfirm, data, isOnlyOneFilter } }: InputsI): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
declare function Inputs({ onCloseDropdown, filter: { options, onConfirm, data, isOnlyOneFilter, onColumnFilterClearClick } }: InputsI): import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
export default Inputs;
|
|
@@ -7,7 +7,7 @@ import { useTranslation } from 'react-i18next';
|
|
|
7
7
|
import { grayCloseIcon, searchIcon } from '../../../../../constants/index.js';
|
|
8
8
|
import { Wrapper, Text, InputStyled, InputsWrapper, ClearButton, ClearWrapper } from './style';
|
|
9
9
|
import { CancelButton, Footer, OkayButton } from '../style';
|
|
10
|
-
function Inputs({ onCloseDropdown, filter: { options = [], onConfirm, data, isOnlyOneFilter } }) {
|
|
10
|
+
function Inputs({ onCloseDropdown, filter: { options = [], onConfirm, data, isOnlyOneFilter, onColumnFilterClearClick } }) {
|
|
11
11
|
const [values, setValues] = useState({});
|
|
12
12
|
useEffect(() => {
|
|
13
13
|
setValues((options || []).reduce((acc, { apiKey }) => { var _a; return (Object.assign(Object.assign({}, acc), { [apiKey]: (_a = data === null || data === void 0 ? void 0 : data[apiKey]) !== null && _a !== void 0 ? _a : '' })); }, {}));
|
|
@@ -21,6 +21,7 @@ function Inputs({ onCloseDropdown, filter: { options = [], onConfirm, data, isOn
|
|
|
21
21
|
onCloseDropdown();
|
|
22
22
|
};
|
|
23
23
|
const onClickClear = () => {
|
|
24
|
+
onColumnFilterClearClick === null || onColumnFilterClearClick === void 0 ? void 0 : onColumnFilterClearClick();
|
|
24
25
|
setValues(options.reduce((acc, { apiKey }) => (Object.assign(Object.assign({}, acc), { [apiKey]: '' })), {}));
|
|
25
26
|
};
|
|
26
27
|
const isInputHasValue = (key) => values[key] !== undefined && values[key].length > 0;
|
|
@@ -11,11 +11,11 @@ interface ITableRowProps<R = any> {
|
|
|
11
11
|
showLoadedStyle?: boolean;
|
|
12
12
|
};
|
|
13
13
|
isSheetView?: boolean;
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
selectedCell?: string | null;
|
|
15
|
+
selectedColumn?: string | null;
|
|
16
16
|
onCellClick?: (rowIndex: number, columnId: string, event: React.MouseEvent) => void;
|
|
17
17
|
isLastRow?: boolean;
|
|
18
18
|
}
|
|
19
|
-
declare function TableRow({ row, columns, index, rowProps, isSheetView,
|
|
19
|
+
declare function TableRow({ row, columns, index, rowProps, isSheetView, selectedCell, selectedColumn, onCellClick, isLastRow, }: Readonly<ITableRowProps>): import("react/jsx-runtime").JSX.Element;
|
|
20
20
|
declare const _default: import("react").MemoExoticComponent<typeof TableRow>;
|
|
21
21
|
export default _default;
|
|
@@ -4,7 +4,7 @@ import { memo, useMemo } from 'react';
|
|
|
4
4
|
import { areEqual } from 'react-window';
|
|
5
5
|
import { StyledCell, StyledTableRow } from '../style';
|
|
6
6
|
import { getBorderStyle } from '../utils/getBorderStyle';
|
|
7
|
-
function TableRow({ row, columns, index, rowProps, isSheetView,
|
|
7
|
+
function TableRow({ row, columns, index, rowProps, isSheetView, selectedCell = null, selectedColumn = null, onCellClick, isLastRow = false, }) {
|
|
8
8
|
const renderCell = (column) => {
|
|
9
9
|
const { render, format, selector } = column;
|
|
10
10
|
if (!(column === null || column === void 0 ? void 0 : column.id) || !row)
|
|
@@ -16,8 +16,8 @@ function TableRow({ row, columns, index, rowProps, isSheetView, selectedCells =
|
|
|
16
16
|
const content = useMemo(() => (_jsx(_Fragment, { children: columns.map((column, colIndex) => {
|
|
17
17
|
const columnIdStr = String(column.id);
|
|
18
18
|
const cellKey = `${index}-${columnIdStr}`;
|
|
19
|
-
const isCellSelected =
|
|
20
|
-
const isColumnSelected =
|
|
19
|
+
const isCellSelected = selectedCell === cellKey;
|
|
20
|
+
const isColumnSelected = selectedColumn === columnIdStr;
|
|
21
21
|
const isSelected = isCellSelected || isColumnSelected;
|
|
22
22
|
const borderStyle = getBorderStyle({
|
|
23
23
|
isSelected,
|
|
@@ -25,8 +25,8 @@ function TableRow({ row, columns, index, rowProps, isSheetView, selectedCells =
|
|
|
25
25
|
isColumnSelected,
|
|
26
26
|
isLastRow,
|
|
27
27
|
});
|
|
28
|
-
return (_jsx(StyledCell, Object.assign({ component: "div", "data-testid": "
|
|
29
|
-
}) })), [columns, row, index,
|
|
28
|
+
return (_jsx(StyledCell, Object.assign({ component: "div", "data-testid": "TableRow_TableCell", "data-column-id": column.id, "data-column-width": column.width, "data-column-width-used": column.width, "data-column-align": column.align, "data-column-order": column.order, "data-column-header": typeof column.header === 'string' ? column.header : 'component', "data-column-sortable": !!column.sortable, "data-column-filterable": !!column.filter, isFirst: column.id === columns[0].id, isLast: column.id === columns[columns.length - 1].id, onClick: (event) => onCellClick === null || onCellClick === void 0 ? void 0 : onCellClick(index, columnIdStr, event), sx: Object.assign(Object.assign({ width: column.width, minWidth: column.width, textAlign: column.align, justifyContent: column.align === 'right' ? 'flex-end' : 'flex-start', cursor: 'pointer' }, borderStyle), column.cellStyle), isSheetView: isSheetView }, { children: renderCell(column) }), `${column.id}-${colIndex}`));
|
|
29
|
+
}) })), [columns, row, index, selectedCell, selectedColumn, onCellClick, isLastRow]);
|
|
30
30
|
return (_createElement(StyledTableRow, Object.assign({ "data-testid": "TableRow", onClick: rowProps === null || rowProps === void 0 ? void 0 : rowProps.onRowClick, showShadowHighlight: rowProps === null || rowProps === void 0 ? void 0 : rowProps.showShadowHighlight, showLoadedStyle: rowProps === null || rowProps === void 0 ? void 0 : rowProps.showLoadedStyle, component: "article" }, rowProps, { key: index, isSheetView: isSheetView }), content));
|
|
31
31
|
}
|
|
32
32
|
export default memo(TableRow, areEqual);
|
|
@@ -68,7 +68,7 @@ function ListItemWrapper(_a) {
|
|
|
68
68
|
height: '100%',
|
|
69
69
|
} }, { children: isError ? _jsx(RowErrorState, {}) : lastRowContent })) })));
|
|
70
70
|
}
|
|
71
|
-
return (_jsx(TableRow, { index: index, row: row, columns: columns, rowProps: memoizedRowProps, isSheetView: isSheetView,
|
|
71
|
+
return (_jsx(TableRow, { index: index, row: row, columns: columns, rowProps: memoizedRowProps, isSheetView: isSheetView, selectedCell: restData.selectedCell, selectedColumn: restData.selectedColumn, onCellClick: restData.onCellClick, isLastRow: index === rows.length - 1 }, `row-${index}`));
|
|
72
72
|
}, [restData, index, row, columns, memoizedRowProps, isSheetView]);
|
|
73
73
|
return (_jsx("div", Object.assign({ "data-testid": "ListItemWrapper", style: Object.assign(Object.assign({}, style), { top: Number(style.top) - ((_b = renderedScrollTopRef === null || renderedScrollTopRef === void 0 ? void 0 : renderedScrollTopRef.current) !== null && _b !== void 0 ? _b : 0), willChange: 'top' }) }, { children: _jsx(StyledItemWrapper, Object.assign({ "data-testid": "ListItemWrapper_StyledItemWrapper" }, { children: memoizedListItemComponent })) })));
|
|
74
74
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useLayoutEffect } from 'react';
|
|
2
|
-
import { useLocation } from 'react-router
|
|
2
|
+
import { useLocation } from 'react-router';
|
|
3
3
|
import { isUserLoggedInAndJwtTokenExistsAndNotExpired } from '../utils/index.js';
|
|
4
4
|
export const useCheckUserLoggedIn = () => {
|
|
5
5
|
const { pathname } = useLocation();
|
package/build/types/table.d.ts
CHANGED
|
@@ -134,6 +134,7 @@ export type ColumnFilterValues = Record<string, string | string[] | {
|
|
|
134
134
|
export type IColumnFilter = ({
|
|
135
135
|
onConfirm?: (filterValues: ColumnFilterValues) => void;
|
|
136
136
|
onClear: (apiKeys: string[]) => void;
|
|
137
|
+
onColumnFilterClearClick?: () => void;
|
|
137
138
|
data?: ColumnFilterValues;
|
|
138
139
|
isOnlyOneFilter?: boolean;
|
|
139
140
|
} & (IColumnFilterList | IColumnFilterInputs | IColumnFilterCustom));
|
package/package.json
CHANGED