@tap-payments/os-micro-frontend-shared 0.1.135 → 0.1.136-test.2

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.
Files changed (109) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +12 -12
  3. package/build/components/BackgroundAnimation/BackgroundAnimation.js +28 -0
  4. package/build/components/BackgroundAnimation/Blob/Blob.js +2 -0
  5. package/build/components/Chip/style.js +1 -0
  6. package/build/components/ColorPicker/HexaFields.js +4 -0
  7. package/build/components/ColorPicker/style.js +1 -1
  8. package/build/components/Dialog/style.js +1 -0
  9. package/build/components/Dropdown2/style.js +2 -0
  10. package/build/components/HeatMap/constant.js +1 -1
  11. package/build/components/InputBase/AmountInputBase/CurrencyList/style.js +3 -0
  12. package/build/components/InputBase/PhoneInputBase/CountriesList/style.js +3 -0
  13. package/build/components/InputBase/SelectBase/SelectBase.js +1 -0
  14. package/build/components/InputBase/SelectBase/SelectBaseMultiple.js +3 -0
  15. package/build/components/InputBase/SelectBase/style.js +3 -2
  16. package/build/components/InputNumber/InputNumber.js +2 -0
  17. package/build/components/Inputs/Input/style.js +6 -2
  18. package/build/components/Inputs/Select/Select.js +1 -0
  19. package/build/components/Inputs/Select/style.js +3 -2
  20. package/build/components/JSONViewer/JSONViewer.js +10 -2
  21. package/build/components/JSONViewer/context/Provider.js +2 -0
  22. package/build/components/LeftPeekRightExpandingChip/LeftPeekRightExpandingChip.d.ts +10 -0
  23. package/build/components/LeftPeekRightExpandingChip/LeftPeekRightExpandingChip.js +14 -1
  24. package/build/components/LeftPeekRightExpandingChip/style.js +1 -0
  25. package/build/components/LeftPeekRightExpandingChip/useLeftPeekRightExpandingChip.js +30 -2
  26. package/build/components/MultiSelectStatusButton/MultiSelectStatusButton.js +3 -0
  27. package/build/components/NestedDropdown/Dropdown.js +3 -0
  28. package/build/components/RFH/Inputs/FormInput/FormInput.js +1 -0
  29. package/build/components/RFH/Inputs/MultiSelect/MultiSelect.js +1 -0
  30. package/build/components/RangeCalender/RangeCalender.js +1 -0
  31. package/build/components/RangeCalender/components/RangeDatepicker/RangeDatepicker.js +3 -1
  32. package/build/components/RightLeftExpandingCenterChip/RightLeftExpandingCenterChip.d.ts +32 -0
  33. package/build/components/RightLeftExpandingCenterChip/RightLeftExpandingCenterChip.js +36 -2
  34. package/build/components/RightLeftExpandingCenterChip/style.js +25 -4
  35. package/build/components/RightLeftExpandingCenterChip/useRightLeftExpandingCenterChip.d.ts +5 -0
  36. package/build/components/RightLeftExpandingCenterChip/useRightLeftExpandingCenterChip.js +53 -1
  37. package/build/components/ScrollLoader/ScrollLoader.js +2 -1
  38. package/build/components/StatusButton/StatusButton.js +11 -3
  39. package/build/components/StatusButton/constant.js +3 -1
  40. package/build/components/StatusButton/style.d.ts +2 -1
  41. package/build/components/StatusButton/type.d.ts +13 -1
  42. package/build/components/StatusIcons/AuthIcons/constants.js +5 -0
  43. package/build/components/StatusIcons/AuthorizationAutoIcons/CaptureAutoIcon.js +11 -0
  44. package/build/components/StatusIcons/AuthorizationAutoIcons/VoidAutoIcon.js +11 -0
  45. package/build/components/TableCells/CustomCells/ApplicationStatusCell/ApplicationStatusCell.js +3 -1
  46. package/build/components/TableCells/CustomCells/BrandCell/BrandCell.js +1 -0
  47. package/build/components/TableCells/CustomCells/ReferenceCell/ReferenceCell.js +3 -1
  48. package/build/components/TableCells/CustomCells/RefundStatusCell/components/RefundStateIcon.js +1 -0
  49. package/build/components/TableCells/CustomCells/SegmentsCell/SegmentsCell.js +3 -1
  50. package/build/components/TableCells/CustomCells/SourceMergedCell/SourceMergedCell.js +7 -1
  51. package/build/components/TableCells/CustomCells/StatusCell/StatusCell.js +1 -0
  52. package/build/components/TableView/CustomViews.js +2 -0
  53. package/build/components/TableView/TableView.js +1 -0
  54. package/build/components/Timepicker/Timepicker.js +1 -0
  55. package/build/components/Timepicker/utils.js +9 -5
  56. package/build/components/VirtualTables/SheetViewVirtualTable/SheetViewVirtualTable.js +16 -3
  57. package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableHeaderCell.js +2 -0
  58. package/build/components/VirtualTables/SheetViewVirtualTable/components/SheetViewTableLoading.js +5 -2
  59. package/build/components/VirtualTables/SheetViewVirtualTable/components/VirtualTable.js +6 -2
  60. package/build/components/VirtualTables/SheetViewVirtualTable/hooks/index.d.ts +1 -0
  61. package/build/components/VirtualTables/SheetViewVirtualTable/hooks/index.js +1 -0
  62. package/build/components/VirtualTables/SheetViewVirtualTable/hooks/usePerformanceOptimizations.d.ts +11 -0
  63. package/build/components/VirtualTables/SheetViewVirtualTable/hooks/usePerformanceOptimizations.js +107 -0
  64. package/build/components/VirtualTables/SheetViewVirtualTable/hooks/usePinnedColumns.js +2 -0
  65. package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useTableData.js +1 -0
  66. package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useTableState.js +3 -0
  67. package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useVirtualTableContainer.d.ts +1 -23
  68. package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useVirtualTableContainer.js +25 -21
  69. package/build/components/VirtualTables/SheetViewVirtualTable/style.js +1 -1
  70. package/build/components/VirtualTables/VirtualTable/VirtualTable.js +12 -2
  71. package/build/components/VirtualTables/VirtualTableWithCard/VirtualTableWithCard.js +6 -1
  72. package/build/components/VirtualTables/components/ColumnFilter/Inputs/Inputs.js +1 -0
  73. package/build/components/VirtualTables/components/TableFooter/TableFooter.js +9 -0
  74. package/build/components/VirtualTables/components/TableRow.js +25 -18
  75. package/build/components/VirtualTables/components/virtualScroll/ListItemWrapper.js +3 -1
  76. package/build/components/VirtualTables/components/virtualScroll/ListItemWrapperWithCard.js +2 -0
  77. package/build/components/VirtualTables/components/virtualScroll/VirtualScrollList.js +16 -1
  78. package/build/components/Widget/style.js +1 -0
  79. package/build/components/Window/style.js +1 -0
  80. package/build/components/index.d.ts +8 -2
  81. package/build/components/index.js +11 -2
  82. package/build/constants/assets.js +4 -0
  83. package/build/constants/server.js +1 -0
  84. package/build/constants/table.d.ts +1 -1
  85. package/build/constants/table.js +1 -1
  86. package/build/hooks/useCountdown.js +4 -0
  87. package/build/hooks/useStickyHeaderShadow.js +6 -0
  88. package/build/utils/api.js +3 -0
  89. package/build/utils/array.js +5 -1
  90. package/build/utils/billing.js +1 -0
  91. package/build/utils/country.js +1 -0
  92. package/build/utils/currency.js +6 -0
  93. package/build/utils/date.d.ts +5 -0
  94. package/build/utils/date.js +31 -3
  95. package/build/utils/encrypt.js +3 -1
  96. package/build/utils/error.js +2 -0
  97. package/build/utils/freshdesk.js +2 -0
  98. package/build/utils/geography.js +1 -1
  99. package/build/utils/localStorage.js +7 -0
  100. package/build/utils/merchant.js +3 -0
  101. package/build/utils/number.js +1 -0
  102. package/build/utils/segment.js +1 -0
  103. package/build/utils/string.d.ts +7 -0
  104. package/build/utils/string.js +10 -0
  105. package/build/utils/style.d.ts +13 -2
  106. package/build/utils/style.js +30 -2
  107. package/build/utils/table.js +1 -1
  108. package/build/utils/url.js +2 -0
  109. package/package.json +3 -3
@@ -57,11 +57,16 @@ function VirtualTableWithCard({ rows, threshold = TABLE_THRESHOLD, rowProps, foo
57
57
  setShowBackdrop(isVisible);
58
58
  };
59
59
  const handleOnLoadMoreItems = () => __awaiter(this, void 0, void 0, function* () {
60
+ // TODO: start index and stop index are not working as expected
61
+ // console.log('startIndex', startIndex, 'stopIndex', stopIndex,
62
+ // 'rows.length', rows.length)
60
63
  if (areAllRowsLoaded)
61
64
  return;
62
65
  yield (loadMoreItems === null || loadMoreItems === void 0 ? void 0 : loadMoreItems());
63
66
  });
64
- return (_jsx(InfiniteLoader, Object.assign({ "data-testid": "VirtualTable_InfiniteLoader", isItemLoaded: (index) => index !== lastItemIndex, itemCount: itemsCount, loadMoreItems: handleOnLoadMoreItems, threshold: threshold }, { children: ({ onItemsRendered, ref }) => (_jsx(Box, Object.assign({ sx: { height: `${tableHeight - (tableHeaderHeight !== null && tableHeaderHeight !== void 0 ? tableHeaderHeight : 0)}px` }, id: "auto-sizer-wrapper" }, { children: _jsx(AutoSizer, Object.assign({ ref: ref, "data-testid": "VirtualTable_AutoSizer" }, { children: ({ height: h, width: w }) => (_jsx(StyledVirtualList, Object.assign({ "data-testid": "VirtualTable_VirtualList", useIsScrolling: true, className: "list", itemData: itemData, height: h || 0, width: w || 0, itemCount: itemsCount, itemSize: () => rowHeight, onItemsRendered: onItemsRendered, setBackdropVisibility: setBackdropVisibility, areTotalRowsNotFillingHeight: areTotalRowsNotFillingHeight, scrollToIndex: scrollToIndex, overscanCount: TABLE_LIST_OVER_SCAN }, { children: ListItemWrapperWithCard }))) })) }))) })));
67
+ return (
68
+ // @ts-ignore
69
+ _jsx(InfiniteLoader, Object.assign({ "data-testid": "VirtualTable_InfiniteLoader", isItemLoaded: (index) => index !== lastItemIndex, itemCount: itemsCount, loadMoreItems: handleOnLoadMoreItems, threshold: threshold }, { children: ({ onItemsRendered, ref }) => (_jsx(Box, Object.assign({ sx: { height: `${tableHeight - (tableHeaderHeight !== null && tableHeaderHeight !== void 0 ? tableHeaderHeight : 0)}px` }, id: "auto-sizer-wrapper" }, { children: _jsx(AutoSizer, Object.assign({ ref: ref, "data-testid": "VirtualTable_AutoSizer" }, { children: ({ height: h, width: w }) => (_jsx(StyledVirtualList, Object.assign({ "data-testid": "VirtualTable_VirtualList", useIsScrolling: true, className: "list", itemData: itemData, height: h || 0, width: w || 0, itemCount: itemsCount, itemSize: () => rowHeight, onItemsRendered: onItemsRendered, setBackdropVisibility: setBackdropVisibility, areTotalRowsNotFillingHeight: areTotalRowsNotFillingHeight, scrollToIndex: scrollToIndex, overscanCount: TABLE_LIST_OVER_SCAN }, { children: ListItemWrapperWithCard }))) })) }))) })));
65
70
  }, [
66
71
  error,
67
72
  isLoading,
@@ -8,6 +8,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
10
  function Inputs({ onCloseDropdown, filter: { options = [], onConfirm, data, isOnlyOneFilter, onClearFilterFields, wrapperSx } }) {
11
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
12
  const [values, setValues] = useState({});
12
13
  useEffect(() => {
13
14
  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 : '' })); }, {}));
@@ -17,6 +17,15 @@ import { StyledFooter, Label, Title, ValueWrapper, EngravingLine } from './style
17
17
  function TableFooter(_a) {
18
18
  var { totalCount, showBackDrop = false, showSeparator, sandboxMode, maximized, children } = _a, other = __rest(_a, ["totalCount", "showBackDrop", "showSeparator", "sandboxMode", "maximized", "children"]);
19
19
  const { t } = useTranslation();
20
+ // const min = 10000
21
+ // const max = 50000
22
+ // const average = 30000
23
+ // const sum = 100000
24
+ // const currency = 'SAR'
25
+ // const { integerAmount: minIntegerAmount, decimalAmount: minDecimalAmount } = formatAmount(min)
26
+ // const { integerAmount: maxIntegerAmount, decimalAmount: maxDecimalAmount } = formatAmount(max)
27
+ // const { integerAmount: averageIntegerAmount, decimalAmount: averageDecimalAmount } = formatAmount(average)
28
+ // const { integerAmount: sumIntegerAmount, decimalAmount: sumDecimalAmount } = formatAmount(sum)
20
29
  return (_jsxs(StyledFooter, Object.assign({ component: "footer", "data-testid": "TableFooter", maximized: maximized !== null && maximized !== void 0 ? maximized : false, sandboxMode: sandboxMode, showBackDrop: showBackDrop, areTotalRowsNotFillingHeight: !!showSeparator }, other, { children: [showSeparator && _jsx(EngravingLine, {}), totalCount || totalCount === 0 ? (_jsxs(Label, Object.assign({ sx: { gap: '6px', cursor: 'text' } }, { children: [_jsx(Title, { children: t('count') }), _jsx(ValueWrapper, { children: formatNumber(totalCount || 0) })] }))) : null, children] })));
21
30
  }
22
31
  export default React.memo(TableFooter);
@@ -6,23 +6,25 @@ import { areEqual } from 'react-window';
6
6
  import { StyledCell, StyledTableRow } from './style';
7
7
  import { getSelectionStyles, getRowSelectionBorderStyles } from '../../../utils/index.js';
8
8
  function TableRow({ row, columns, index, rowProps, isSheetView, selectedCell = null, selectedColumn = null, selectedRow = null, selectedChip = null, onCellClick, isLastRow = false, onChipClick, }) {
9
- const renderCell = (column, rowIndex, colIndex) => {
10
- const { render, format, selector } = column;
11
- const handleChipClick = (event, chipIndex) => {
12
- onChipClick === null || onChipClick === void 0 ? void 0 : onChipClick(rowIndex, colIndex, event, chipIndex, column.pinned);
9
+ const renderCell = useMemo(() => {
10
+ return (column, rowIndex, colIndex) => {
11
+ const { render, format, selector } = column;
12
+ const handleChipClick = (event, chipIndex) => {
13
+ onChipClick === null || onChipClick === void 0 ? void 0 : onChipClick(rowIndex, colIndex, event, chipIndex, column.pinned);
14
+ };
15
+ if (!(column === null || column === void 0 ? void 0 : column.id) || !row)
16
+ return null;
17
+ const value = selector ? selector({ row, index, value: row[column === null || column === void 0 ? void 0 : column.id] }) : row[column === null || column === void 0 ? void 0 : column.id];
18
+ const formattedValue = format ? format({ value, row, index }) : value;
19
+ return render ? (render({
20
+ row,
21
+ column,
22
+ index,
23
+ value: row[column === null || column === void 0 ? void 0 : column.id],
24
+ selectionProps: { onClick: handleChipClick, rowIndex, colIndex, selectedId: selectedChip },
25
+ })) : (_jsx(_Fragment, { children: formattedValue }));
13
26
  };
14
- if (!(column === null || column === void 0 ? void 0 : column.id) || !row)
15
- return null;
16
- const value = selector ? selector({ row, index, value: row[column === null || column === void 0 ? void 0 : column.id] }) : row[column === null || column === void 0 ? void 0 : column.id];
17
- const formattedValue = format ? format({ value, row, index }) : value;
18
- return render ? (render({
19
- row,
20
- column,
21
- index,
22
- value: row[column === null || column === void 0 ? void 0 : column.id],
23
- selectionProps: { onClick: handleChipClick, rowIndex, colIndex, selectedId: selectedChip },
24
- })) : (_jsx(_Fragment, { children: formattedValue }));
25
- };
27
+ }, [row, index, selectedChip, onChipClick]);
26
28
  const content = useMemo(() => (_jsx(_Fragment, { children: columns.map((column, colIndex) => {
27
29
  var _a, _b;
28
30
  const cellKey = `${(_a = column.pinned) !== null && _a !== void 0 ? _a : 'default'}-${index}-${colIndex}`;
@@ -38,17 +40,22 @@ function TableRow({ row, columns, index, rowProps, isSheetView, selectedCell = n
38
40
  isRowSelected,
39
41
  isLastRow,
40
42
  });
43
+ // Determine if this cell should be treated as first/last for border radius
41
44
  const isFirstColumn = column.id === columns[0].id;
42
45
  const isLastColumn = column.id === columns[columns.length - 1].id;
46
+ // For scrollable table, adjust first/last based on pinned tables
43
47
  let effectiveFirst = isFirstColumn;
44
48
  let effectiveLast = isLastColumn;
45
49
  if (!column.pinned) {
50
+ // If there are pinned start columns, scrollable table shouldn't have left border radius
46
51
  effectiveFirst = isFirstColumn && column.pinned !== 'start';
52
+ // If there are pinned end columns, scrollable table shouldn't have right border radius
47
53
  effectiveLast = isLastColumn && column.pinned !== 'end';
48
54
  }
55
+ // Handle border styling for row selection
49
56
  const rowSelectionBorderStyles = isRowSelected
50
57
  ? getRowSelectionBorderStyles({
51
- effectiveFirst,
58
+ isFirstColumn,
52
59
  isPinnedStart: column.pinned === 'start',
53
60
  isPinnedEnd: column.pinned === 'end',
54
61
  })
@@ -57,7 +64,7 @@ function TableRow({ row, columns, index, rowProps, isSheetView, selectedCell = n
57
64
  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: effectiveFirst, isLast: effectiveLast, onClick: (event) => {
58
65
  onCellClick === null || onCellClick === void 0 ? void 0 : onCellClick(index, colIndex, event, column.pinned);
59
66
  }, sx: Object.assign(Object.assign(Object.assign({ width: column.width, minWidth: column.width, textAlign: column.align, justifyContent: isIndexColumn ? 'center' : column.align === 'right' ? 'flex-end' : 'flex-start', cursor: onCellClick ? 'pointer' : 'default' }, selectionStyles), rowSelectionBorderStyles), column.cellStyle), isSheetView: isSheetView, isSelected: isCellSelected }, { children: isSheetView ? (_jsx(Box, Object.assign({ sx: { position: 'relative', zIndex: 1 } }, { children: renderCell(column, index, colIndex) }))) : (_jsx(_Fragment, { children: renderCell(column, index, colIndex) })) }), `${column.id}-${colIndex}`));
60
- }) })), [columns, row, index, selectedCell, selectedColumn, selectedRow, onCellClick, isLastRow, selectedChip, isSheetView]);
67
+ }) })), [columns, index, selectedCell, selectedColumn, selectedRow, onCellClick, isLastRow, isSheetView, renderCell]);
61
68
  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));
62
69
  }
63
70
  export default memo(TableRow, areEqual);
@@ -39,6 +39,7 @@ export const LastRowContent = React.memo(({ isLoadingRow, isSheetView, columns,
39
39
  }
40
40
  return _jsx(StyledParagraph, Object.assign({ "data-testid": "ListItemWrapper_lastRowContent" }, { children: t('allRecordsHaveBeenSuccessfullyLoaded') }));
41
41
  });
42
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
42
43
  const createRowClickHandler = (row, onRowClick) => (e) => {
43
44
  var _a;
44
45
  (_a = e === null || e === void 0 ? void 0 : e.stopPropagation) === null || _a === void 0 ? void 0 : _a.call(e);
@@ -58,6 +59,7 @@ function ListItemWrapper(_a) {
58
59
  const isLoadingRow = isLoading && index === lastItemIndex + 1;
59
60
  const isLoadedRow = index <= newLoadedRowsEndIndex;
60
61
  const rowClickHandler = React.useCallback(() => createRowClickHandler(row, rowProps === null || rowProps === void 0 ? void 0 : rowProps.onRowClick), [row, rowProps === null || rowProps === void 0 ? void 0 : rowProps.onRowClick]);
62
+ // Memoize the row props object
61
63
  const memoizedRowProps = React.useMemo(() => (Object.assign(Object.assign({ showShadowHighlight: scrollToIndex === index, showLoadedStyle: isLoadedRow }, rowProps), { onClick: rowClickHandler })), [scrollToIndex, index, isLoadedRow, rowProps, rowClickHandler]);
62
64
  const renderSheetViewLoadingRow = React.useCallback((lastRowContent) => {
63
65
  return (_jsx(Box, Object.assign({ sx: {
@@ -66,9 +68,9 @@ function ListItemWrapper(_a) {
66
68
  width: '100%',
67
69
  } }, { children: isError ? _jsx(RowErrorState, {}) : lastRowContent })));
68
70
  }, [isError]);
71
+ const isLastRow = React.useMemo(() => isLoadingRow || (areAllRowsLoaded && index === lastItemIndex + 1), [isLoadingRow, areAllRowsLoaded, index, lastItemIndex]);
69
72
  const memoizedListItemComponent = React.useMemo(() => {
70
73
  const lastRowContent = _jsx(LastRowContent, { isSheetView: isSheetView, isLoadingRow: isLoadingRow, columns: columns, currentRowCount: rows.length });
71
- const isLastRow = isLoadingRow || (areAllRowsLoaded && index === lastItemIndex + 1);
72
74
  if (isPinned && isLastRow) {
73
75
  if (isSheetView && isLoadingRow && columns && columns.length > 0) {
74
76
  return renderSheetViewLoadingRow(lastRowContent);
@@ -2,6 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import React from 'react';
3
3
  import { styled } from '@mui/material/styles';
4
4
  import TableRowWithCard from '../TableRowWithCard';
5
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
6
  const createRowClickHandler = (row, onRowClick) => (e) => {
6
7
  var _a;
7
8
  (_a = e === null || e === void 0 ? void 0 : e.stopPropagation) === null || _a === void 0 ? void 0 : _a.call(e);
@@ -19,6 +20,7 @@ function ListItemWrapperWithCard({ index, style, data: { renderedScrollTopRef, r
19
20
  const isLoadingRow = isLoading && index === lastItemIndex + 1;
20
21
  const isLoadedRow = index <= newLoadedRowsEndIndex;
21
22
  const rowClickHandler = React.useCallback(createRowClickHandler(row, rowProps === null || rowProps === void 0 ? void 0 : rowProps.onRowClick), [row, rowProps === null || rowProps === void 0 ? void 0 : rowProps.onRowClick]);
23
+ // Memoize the row props object
22
24
  const memoizedRowProps = React.useMemo(() => (Object.assign(Object.assign({ showShadowHighlight: scrollToIndex === index, showLoadedStyle: isLoadedRow }, rowProps), { onClick: rowClickHandler })), [scrollToIndex, index, isLoadedRow, rowProps, rowClickHandler, isLoadingRow, areAllRowsLoaded, lastItemIndex]);
23
25
  const memoizedListItemComponent = React.useMemo(() => _jsx(TableRowWithCard, { index: index, row: row, renderCardComponent: renderCardComponent, rowProps: memoizedRowProps }, `row-${index}`), [index, row, memoizedRowProps]);
24
26
  return (_jsx("div", Object.assign({ "data-testid": "ListCardWrapper", style: Object.assign(Object.assign({}, style), { top: Number(style.top) - renderedScrollTopRef.current, willChange: 'top' }) }, { children: _jsx(StyledItemWrapper, Object.assign({ "data-testid": "ListCardWrapper_StyledItemWrapper" }, { children: memoizedListItemComponent })) })));
@@ -22,10 +22,21 @@ const VirtualScrollList = React.forwardRef((_a, ref) => {
22
22
  setBackdropVisibility,
23
23
  clearBackdropVisibilityTimeout,
24
24
  });
25
+ // renderedScrollTopRef - when render is started (listRef.current.scrollTo is called)
26
+ // this ref holds scrollTop position which has been passed to scrollTo function
27
+ // scrollTopRef - this is scrollTop from last onScroll event.
28
+ // onScroll can be fired when render is still in progress. So scrollTop will be just saved
29
+ // When scroll will end, saved scrollTop will be used to start new render.
30
+ // Subsequent onScroll will overwrite this number, as we will not render intermediate scroll states
31
+ // scrollLocked - is true, when render has been started.
32
+ // This is used to now start several renders simulaneously
33
+ // listRef - VariableSizeList ref to call scrollTo method
25
34
  const renderedScrollTopRef = useRef(0);
26
35
  const scrollTopRef = useRef(undefined);
27
36
  const scrollLocked = useRef(false);
37
+ // Use external ref if provided, otherwise create local
28
38
  const internalListRef = useRef(null);
39
+ // If ref is provided, use it; else use externalListRef; else use internalListRef
29
40
  const listRef = ref || externalListRef || internalListRef;
30
41
  const scrollTo = useCallback(() => {
31
42
  var _a, _b;
@@ -59,6 +70,10 @@ const VirtualScrollList = React.forwardRef((_a, ref) => {
59
70
  onScroll === null || onScroll === void 0 ? void 0 : onScroll(props);
60
71
  scrollLocked.current = scrollTo();
61
72
  }, [scrollTo, onScroll]);
62
- return (_jsx(VirtualScrollOuterProvider, Object.assign({ value: handleScroll }, { children: _jsx(VariableSizeList, Object.assign({ ref: listRef, "data-testid": "VirtualScrollList", itemData: itemDataInternal, outerElementType: VirtualScrollOuter, innerElementType: VirtualScrollInner }, restProps, { onScroll: handleOnScroll }, { children: children })) })));
73
+ return (_jsx(VirtualScrollOuterProvider, Object.assign({ value: handleScroll }, { children: _jsx(VariableSizeList, Object.assign({ ref: listRef, "data-testid": "VirtualScrollList", itemData: itemDataInternal,
74
+ // @ts-ignore
75
+ outerElementType: VirtualScrollOuter,
76
+ // @ts-ignore
77
+ innerElementType: VirtualScrollInner }, restProps, { onScroll: handleOnScroll }, { children: children })) })));
63
78
  });
64
79
  export default VirtualScrollList;
@@ -43,6 +43,7 @@ export const ItemText = styled(Text)(({ theme }) => ({
43
43
  fontSize: '11px',
44
44
  fontWeight: 500,
45
45
  lineHeight: '13.2px',
46
+ // width: 110
46
47
  }));
47
48
  export const ItemTextWrapper = styled(Box)(() => ({
48
49
  display: 'flex',
@@ -19,6 +19,7 @@ export const contentStyle = {
19
19
  overflow: 'visible',
20
20
  borderRadius: '12px',
21
21
  };
22
+ // eslint-disable-next-line
22
23
  export const initalStyle = {
23
24
  width: 'inherit',
24
25
  height: 'inherit',
@@ -1,7 +1,10 @@
1
1
  export { default as AccordionAdapter } from './AccordionAdapter';
2
2
  export { default as ActionMenu, ActionMenuDropDown, ActionMenuItem, type ActionMenuProps } from './ActionMenu';
3
3
  export { default as ActivityAreaChart, type ActivityAreaChartProps, type ChartDataPoint, ChartTooltip, type ChartTooltipProps, LoadingChart, type PayloadItem, } from './ActivityAreaChart';
4
- export { default as AppWindowWrapper, type AccountHeaderProps, AccountHeaderTitle, AppWindowHeader, type AppWindowHeaderProps, type AppWindowHeaderBaseProps, AppWindow, type AccountHeaderTitleProps, type AppWindowProps, type WindowProps, AppWindowContext, AppWindowContextProvider, LEFT_SIDEBAR, RIGHT_SIDEBAR, VIEWER_HEIGHT, VIEWER_WIDTH, animationDuration, StyledFooter, StyledHideButton, StyledMenuLink, StyledSubmitButton, SubmitButtonWrapper, } from './AppWindowWrapper';
4
+ export { default as AppWindowWrapper, type AccountHeaderProps, AccountHeaderTitle, AppWindowHeader, type AppWindowHeaderProps, type AppWindowHeaderBaseProps, AppWindow, type AccountHeaderTitleProps, type AppWindowProps, type WindowProps, AppWindowContext, AppWindowContextProvider, LEFT_SIDEBAR, RIGHT_SIDEBAR, VIEWER_HEIGHT, VIEWER_WIDTH, animationDuration, StyledFooter, // used account , leads
5
+ StyledHideButton, StyledMenuLink, // used account only
6
+ StyledSubmitButton, // used account , leads
7
+ SubmitButtonWrapper, } from './AppWindowWrapper';
5
8
  export { default as BackgroundAnimation, type BlobGradient, type Blob } from './BackgroundAnimation';
6
9
  export { default as Button, PlusButton, StyledButton } from './Button';
7
10
  export { default as Calender, type CalenderProps, type DateObject } from './Calender';
@@ -12,7 +15,10 @@ export { default as Checkbox } from './Checkbox';
12
15
  export { default as Dialog, DialogToolbar } from './Dialog';
13
16
  export { default as Tooltip } from './Tooltip';
14
17
  export * from './RFH';
15
- export { VirtualTable, TableRowLoading, TableHeader as VirtualTableHeader, TableLastItem, TableLoading, TableLoadingWithCard, TableNoData, TableNoDataWithCard, LastRowContent, ListItemWrapperWithCard, RowErrorState, StyledItemWrapper, TableRow, TableRowLoadingWithCard, TableRowWithCard, VirtualScrollInner, VirtualScrollList, VirtualScrollOuter, VirtualTableWithCard, Inputs, List, ColumnFilter, StyledCell, TableFooter, TableError, } from './VirtualTables';
18
+ export { VirtualTable, TableRowLoading, TableHeader as VirtualTableHeader, // To not to be confused/conflicted with the other seperated `components/TableHeader`
19
+ TableLastItem, TableLoading, TableLoadingWithCard, TableNoData, TableNoDataWithCard, LastRowContent, // used src\features\shared\MerchantsDropdown\MerchantsDropdown.tsx only
20
+ ListItemWrapperWithCard, RowErrorState, StyledItemWrapper, TableRow, TableRowLoadingWithCard, TableRowWithCard, VirtualScrollInner, VirtualScrollList, VirtualScrollOuter, VirtualTableWithCard, Inputs, List, ColumnFilter, StyledCell, // used src\features\shared\Account\UserDetailsContent\components\TableCell\TableCell.tsx only
21
+ TableFooter, TableError, } from './VirtualTables';
16
22
  export { default as SheetViewVirtualTable } from './VirtualTables/SheetViewVirtualTable/SheetViewVirtualTable';
17
23
  export { default as Widget, ListItem, WidgetHeader, WidgetList } from './Widget';
18
24
  export { default as TapLogo } from './TapLogo';
@@ -1,7 +1,11 @@
1
1
  export { default as AccordionAdapter } from './AccordionAdapter';
2
2
  export { default as ActionMenu, ActionMenuDropDown, ActionMenuItem } from './ActionMenu';
3
3
  export { default as ActivityAreaChart, ChartTooltip, LoadingChart, } from './ActivityAreaChart';
4
- export { default as AppWindowWrapper, AccountHeaderTitle, AppWindowHeader, AppWindow, AppWindowContext, AppWindowContextProvider, LEFT_SIDEBAR, RIGHT_SIDEBAR, VIEWER_HEIGHT, VIEWER_WIDTH, animationDuration, StyledFooter, StyledHideButton, StyledMenuLink, StyledSubmitButton, SubmitButtonWrapper, } from './AppWindowWrapper';
4
+ export { default as AppWindowWrapper, AccountHeaderTitle, AppWindowHeader, AppWindow, AppWindowContext, AppWindowContextProvider, LEFT_SIDEBAR, RIGHT_SIDEBAR, VIEWER_HEIGHT, VIEWER_WIDTH, animationDuration, StyledFooter, // used account , leads
5
+ StyledHideButton, StyledMenuLink, // used account only
6
+ StyledSubmitButton, // used account , leads
7
+ SubmitButtonWrapper, // used account , leads
8
+ } from './AppWindowWrapper';
5
9
  export { default as BackgroundAnimation } from './BackgroundAnimation';
6
10
  export { default as Button, PlusButton, StyledButton } from './Button';
7
11
  export { default as Calender } from './Calender';
@@ -12,7 +16,10 @@ export { default as Checkbox } from './Checkbox';
12
16
  export { default as Dialog, DialogToolbar } from './Dialog';
13
17
  export { default as Tooltip } from './Tooltip';
14
18
  export * from './RFH';
15
- export { VirtualTable, TableRowLoading, TableHeader as VirtualTableHeader, TableLastItem, TableLoading, TableLoadingWithCard, TableNoData, TableNoDataWithCard, LastRowContent, ListItemWrapperWithCard, RowErrorState, StyledItemWrapper, TableRow, TableRowLoadingWithCard, TableRowWithCard, VirtualScrollInner, VirtualScrollList, VirtualScrollOuter, VirtualTableWithCard, Inputs, List, ColumnFilter, StyledCell, TableFooter, TableError, } from './VirtualTables';
19
+ export { VirtualTable, TableRowLoading, TableHeader as VirtualTableHeader, // To not to be confused/conflicted with the other seperated `components/TableHeader`
20
+ TableLastItem, TableLoading, TableLoadingWithCard, TableNoData, TableNoDataWithCard, LastRowContent, // used src\features\shared\MerchantsDropdown\MerchantsDropdown.tsx only
21
+ ListItemWrapperWithCard, RowErrorState, StyledItemWrapper, TableRow, TableRowLoadingWithCard, TableRowWithCard, VirtualScrollInner, VirtualScrollList, VirtualScrollOuter, VirtualTableWithCard, Inputs, List, ColumnFilter, StyledCell, // used src\features\shared\Account\UserDetailsContent\components\TableCell\TableCell.tsx only
22
+ TableFooter, TableError, } from './VirtualTables';
16
23
  export { default as SheetViewVirtualTable } from './VirtualTables/SheetViewVirtualTable/SheetViewVirtualTable';
17
24
  export { default as Widget, ListItem, WidgetHeader, WidgetList } from './Widget';
18
25
  export { default as TapLogo } from './TapLogo';
@@ -28,6 +35,7 @@ export { default as WindowSideBar, TITLE_BAR_HEIGHT } from './WindowSideBar';
28
35
  export { default as WindowAppIcon } from './WindowAppIcon';
29
36
  export { default as Window } from './Window';
30
37
  export * from './ToolbarIcon';
38
+ // StyledHeaderWrapper used src\features\AppWindow\components\AppWindowHeader\AppWindowHeader.tsx only
31
39
  export { default as Toolbar, StyledHeaderWrapper, StyledHeaderWrapperStyled } from './Toolbar';
32
40
  export { default as ToggleButtons } from './ToggleButtons';
33
41
  export { default as Text } from './Text';
@@ -58,6 +66,7 @@ export * from './Inputs';
58
66
  export { default as JSONViewer, FooterButton, JSONTitleBar, JsonViewerDialogContext, JSONViewerList, useJsonViewerContext, JsonViewerDialogContextProvider, } from './JSONViewer';
59
67
  export { default as Loader } from './Loader';
60
68
  export { default as MUIThemeProvider } from './MUIThemeProvider';
69
+ // ImageWrapper used src\features\shared\Account\BrandDetails\components\AppsIcons\AppsIcons.tsx only
61
70
  export { default as ImageWrapper } from './ImageWrapper';
62
71
  export { default as Input } from './Input';
63
72
  export { default as IconGallery } from './IconGallery';
@@ -2,6 +2,7 @@ const cdnUrl = 'https://cdn.tap.company/tap-assets';
2
2
  export const lightUrl = `${cdnUrl}/icons/dashboard/light`;
3
3
  export const appBaseUrl = `${lightUrl}/other`;
4
4
  export const functionBaseUrl = `${lightUrl}/function`;
5
+ // Icons getters
5
6
  export const getLightUrlIcon = (source) => `${lightUrl}/${source}.svg`;
6
7
  export const getPaymentMethodsIcon = (source) => `${lightUrl}/payment-method/v2/${source}.svg`;
7
8
  export const getPaymentIssuersIcon = (source) => `${lightUrl}/payment-issuer/${source}.svg`;
@@ -297,6 +298,7 @@ export const braveIcon = `${appBaseUrl}/braveBrowser.svg`;
297
298
  export const arcIcon = `${appBaseUrl}/arcBrowser.svg`;
298
299
  export const chromiumIcon = `${appBaseUrl}/chromiumBrowser.svg`;
299
300
  export const userIcon = `${appBaseUrl}/userIcon.svg`;
301
+ // table status icons
300
302
  export const abandonedTableIcon = `${lightUrl}/status/table/abandoned.svg`;
301
303
  export const cancelledTableIcon = `${lightUrl}/status/table/cancelled.svg`;
302
304
  export const capturedTableIcon = `${lightUrl}/status/table/captured.svg`;
@@ -397,6 +399,7 @@ export const windowEntityIcon = `${lightUrl}/window/entity.svg`;
397
399
  export const windowBankIcon = `${lightUrl}/window/bank.svg`;
398
400
  export const windowIndividualIcon = `${lightUrl}/window/individual.svg`;
399
401
  export const windowPasswordIcon = `${lightUrl}/window/password.svg`;
402
+ // New Invoice Icons
400
403
  export const actionsIcon = `${lightUrl}/actionsIcon.svg`;
401
404
  export const addItem = `${lightUrl}/addItem.svg`;
402
405
  export const attachIcon = `${lightUrl}/attachIcon.svg`;
@@ -494,6 +497,7 @@ export const rightLightArrowIcon = `${appBaseUrl}/rightLightArrow.svg`;
494
497
  export const segmentInstitutionIcon = `${appBaseUrl}/segmentInstitution.svg`;
495
498
  export const segmentTechnologyIcon = `${appBaseUrl}/segmentTechnology.svg`;
496
499
  export const segmentDevelopmentHouseIcon = `${appBaseUrl}/segmentDevelopmentHouse.svg`;
500
+ // Terminal App
497
501
  export const terminalAppIcon = `${appBaseUrl}/terminal.svg`;
498
502
  export const terminalWindowIcon = `${lightUrl}/window/terminal.svg`;
499
503
  export const terminalCardPhone = `${lightUrl}/terminalCardPhone.svg`;
@@ -1,4 +1,5 @@
1
1
  var _a;
2
+ // NOTE: This environment variables should be defined in .env file of the hosting server
2
3
  const isSAOCI = import.meta.env.VITE_DEPLOYMENT_REGION === 'sa-oci';
3
4
  export const BASE_URL = (_a = (isSAOCI ? 'https://mw-os.tap.com.sa' : import.meta.env.VITE_MW_BASE_URL)) !== null && _a !== void 0 ? _a : import.meta.env.VITE_BASE_URL;
4
5
  export const API_URL = `${BASE_URL}/api`;
@@ -3,6 +3,6 @@ export declare const TABLE_CONTENT_ROW_HEIGHT = 70;
3
3
  export declare const TABLE_ROW_HEIGHT = 57;
4
4
  export declare const TABLE_THRESHOLD = 200;
5
5
  export declare const TABLE_LIST_OVER_SCAN = 5;
6
- export declare const SHEET_VIEW_TABLE_LIST_OVER_SCAN = 50;
6
+ export declare const SHEET_VIEW_TABLE_LIST_OVER_SCAN = 20;
7
7
  export declare const SHEET_VIEW_TABLE_THRESHOLD = 20;
8
8
  export declare const SHEET_VIEW_TABLE_ROW_HEIGHT = 28;
@@ -3,6 +3,6 @@ export const TABLE_CONTENT_ROW_HEIGHT = 70;
3
3
  export const TABLE_ROW_HEIGHT = 57;
4
4
  export const TABLE_THRESHOLD = 200;
5
5
  export const TABLE_LIST_OVER_SCAN = 5;
6
- export const SHEET_VIEW_TABLE_LIST_OVER_SCAN = 50;
6
+ export const SHEET_VIEW_TABLE_LIST_OVER_SCAN = 20;
7
7
  export const SHEET_VIEW_TABLE_THRESHOLD = 20;
8
8
  export const SHEET_VIEW_TABLE_ROW_HEIGHT = 28;
@@ -4,16 +4,19 @@ export function useCountdown() {
4
4
  const [timer, setTimer] = useState(0);
5
5
  const timerInterval = useRef(null);
6
6
  const formattedTime = secondsToTimeString(timer);
7
+ // Stop the timer
7
8
  const stopTimer = () => {
8
9
  if (timerInterval.current) {
9
10
  clearInterval(timerInterval.current);
10
11
  timerInterval.current = null;
11
12
  }
12
13
  };
14
+ // Reset the timer
13
15
  const resetTimer = () => {
14
16
  stopTimer();
15
17
  setTimer(0);
16
18
  };
19
+ // Start the timer
17
20
  const startTimer = (expiryTime) => {
18
21
  if (expiryTime <= 0)
19
22
  return;
@@ -31,6 +34,7 @@ export function useCountdown() {
31
34
  });
32
35
  }, 1000);
33
36
  };
37
+ // Auto-stop and cleanup on unmount
34
38
  useEffect(() => {
35
39
  return () => {
36
40
  stopTimer();
@@ -1,4 +1,10 @@
1
1
  import { useEffect, useState } from 'react';
2
+ /* Usage: you will need to add an empty div before your sticky header and pass it's ref to this hook
3
+ Example:
4
+ <Box ref={interceptRef} />
5
+ <StickyHeader></StickyHeader>
6
+ */
7
+ // TODO: enhance the hook to take only the ref of the sticky bar and handle adding the interceptRef internally from the hook
2
8
  export const useStickyHeaderShadow = (interceptRef) => {
3
9
  const [showShadow, setShowShadow] = useState(false);
4
10
  useEffect(() => {
@@ -61,6 +61,7 @@ api.interceptors.request.use((config) => {
61
61
  }, 0);
62
62
  });
63
63
  });
64
+ // create interceptor to add token to all requests
64
65
  api.interceptors.request.use((config) => {
65
66
  config.headers.Authorization = getLoggedInUserJwtToken();
66
67
  const secretKey = getSecretKey();
@@ -81,7 +82,9 @@ export function setApiToken(token) {
81
82
  api.defaults.headers.common.Authorization = token;
82
83
  });
83
84
  }
85
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
84
86
  export function getHeaders(attrs) {
87
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
85
88
  const _a = attrs !== null && attrs !== void 0 ? attrs : {}, { sandboxMode, fixedSecretKey, applicationId, serviceId, functionId, userFunctionId, segmentId } = _a, rest = __rest(_a, ["sandboxMode", "fixedSecretKey", "applicationId", "serviceId", "functionId", "userFunctionId", "segmentId"]);
86
89
  return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, rest), { live_mode: sandboxMode ? 'false' : 'true' }), (!!fixedSecretKey && { 'x-test-secret': fixedSecretKey })), (!!applicationId && { application_id: applicationId })), (!!serviceId && { service_id: serviceId })), (!!functionId && { function_id: functionId })), (!!userFunctionId && { user_function_id: userFunctionId }));
87
90
  }
@@ -1,10 +1,14 @@
1
1
  import orderBy from 'lodash/orderBy';
2
2
  import get from 'lodash/get';
3
3
  export const generateArray = (length) => Array.from({ length }, (_, i) => i);
4
- export const groupBy = (arr, groupFn) => arr.reduce((grouped, obj) => (Object.assign(Object.assign({}, grouped), { [groupFn(obj)]: [...(grouped[groupFn(obj)] || []), obj] })), {});
4
+ // eslint-disable-next-line
5
+ export const groupBy = (arr, groupFn) => arr.reduce(
6
+ // eslint-disable-next-line
7
+ (grouped, obj) => (Object.assign(Object.assign({}, grouped), { [groupFn(obj)]: [...(grouped[groupFn(obj)] || []), obj] })), {});
5
8
  export function sortList({ list, sortBy, orders }) {
6
9
  return (sortBy === null || sortBy === void 0 ? void 0 : sortBy.length) && (orders === null || orders === void 0 ? void 0 : orders.length) ? orderBy(list, sortBy, orders) : list;
7
10
  }
11
+ // eslint-disable-next-line
8
12
  export const sortByString = (list = [], key) => {
9
13
  if (!list.length)
10
14
  return [];
@@ -28,5 +28,6 @@ export const getDefaultInvoiceInfo = () => ({
28
28
  isItemsNotValid: false,
29
29
  isAmountIsMissing: false,
30
30
  errors: [],
31
+ // eslint-disable-next-line
31
32
  brand: {},
32
33
  });
@@ -4,6 +4,7 @@ export function getCountryNameByISO(countryCode) {
4
4
  try {
5
5
  const regionNames = new Intl.DisplayNames(['en'], { type: 'region' });
6
6
  return regionNames.of(countryCode);
7
+ // eslint-disable-next-line
7
8
  }
8
9
  catch (error) {
9
10
  toast.error((_c = (_b = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.message);
@@ -22,6 +22,7 @@ export const intlCurrency = (charge, currencyType) => {
22
22
  minimumFractionDigits: currencyConfig[currencyType] ? 3 : 2,
23
23
  }).format(charge);
24
24
  return currency;
25
+ // eslint-disable-next-line
25
26
  }
26
27
  catch (error) {
27
28
  toast.error((_c = (_b = (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.error) === null || _c === void 0 ? void 0 : _c.message);
@@ -56,7 +57,9 @@ export const formatCurrencyWithInput = (charge, selectedCurrency) => {
56
57
  return chargeString;
57
58
  };
58
59
  export function formatAmount(amount, decimal = 2) {
60
+ // Ensure the input is a number
59
61
  const num = parseFloat(amount.toString());
62
+ // Check if it's a valid number
60
63
  if (isNaN(num)) {
61
64
  const [integerAmount, decimalAmount] = (0).toFixed(decimal).split('.');
62
65
  const fullAmount = `${integerAmount}.${decimalAmount}`;
@@ -66,8 +69,11 @@ export function formatAmount(amount, decimal = 2) {
66
69
  fullAmount,
67
70
  };
68
71
  }
72
+ // Use toFixed(limit) to limit to 2 decimal places
69
73
  const fixedNumber = num.toFixed(decimal);
74
+ // Split integer and decimal parts
70
75
  const [integerPart, decimalPart] = fixedNumber.split('.');
76
+ // Add commas to the integer part
71
77
  const formattedInteger = parseInt(integerPart).toLocaleString();
72
78
  return {
73
79
  integerAmount: formattedInteger,
@@ -2,6 +2,11 @@ export declare function getGreetingMessageId(userTimeHours: number): string;
2
2
  export declare function getDatePickerFormat(date: Date | [Date, Date], locale: string): string;
3
3
  export declare const getUTCOffset: (offsetStr?: string | number) => number;
4
4
  export declare const formatUTCOffset: (offset?: number) => string;
5
+ /**
6
+ * Get the default date range for the calendar
7
+ * @param startDay - Number of days to subtract from today, default value is 6 days to get the date range of the last 7 days including today
8
+ * @returns - Array of two dates [startDate, endDate]
9
+ */
5
10
  export declare const getDefaultDateRange: (startDay?: number) => [Date, Date];
6
11
  export declare const getUTCTimestamp: (date: Date | string | number) => number;
7
12
  export declare const getTimestampByTimezone: (date: Date | string | number, selectedTimezone?: string) => number;
@@ -34,6 +34,7 @@ export function getDatePickerFormat(date, locale) {
34
34
  month: locale === 'hijri' ? 'short' : 'short',
35
35
  day: 'numeric',
36
36
  });
37
+ // @ts-expect-error formatRange is not defined in the type
37
38
  return formatter.formatRange(startDate, endDate).replace('AH', '').trim().replace('–', ' – ');
38
39
  }
39
40
  const formatter = new Intl.DateTimeFormat(calendarMode, {
@@ -58,25 +59,41 @@ export const formatUTCOffset = (offset = 0) => {
58
59
  const paddedOffset = Math.abs(offset).toString().padStart(2, '0');
59
60
  return `UTC${sign}${paddedOffset}:00`;
60
61
  };
62
+ /**
63
+ * Get the default date range for the calendar
64
+ * @param startDay - Number of days to subtract from today, default value is 6 days to get the date range of the last 7 days including today
65
+ * @returns - Array of two dates [startDate, endDate]
66
+ */
61
67
  export const getDefaultDateRange = (startDay = 6) => {
62
68
  const monthDaysMinus = dayjs().subtract(startDay, 'day').hour(0).minute(0).second(0).toDate();
63
69
  const today = dayjs(new Date()).hour(23).minute(59).second(59).toDate();
64
70
  return [monthDaysMinus, today];
65
71
  };
66
72
  export const getUTCTimestamp = (date) => {
73
+ // Create a Date object with the local date string
67
74
  const localDate = new Date(date);
75
+ // Get the local timezone offset in minutes
68
76
  const localTimezoneOffset = localDate.getTimezoneOffset();
69
- const utcTimestamp = localDate.getTime() - localTimezoneOffset * 60000;
77
+ // Calculate the UTC timestamp by subtracting the local timezone offset
78
+ const utcTimestamp = localDate.getTime() - localTimezoneOffset * 60000; // Convert minutes to milliseconds
79
+ // Create a new Date object with the UTC timestamp
70
80
  const utcDate = new Date(utcTimestamp);
81
+ // Convert the UTC date to a string
71
82
  const utcDateString = utcDate.toISOString();
72
83
  return dayjs(utcDateString).valueOf();
73
84
  };
85
+ /*
86
+ * Convert local date to the selected timezone
87
+ * @param date - Date object, date string or timestamp
88
+ * @param selectedTimezone - Timezone string
89
+ * @returns - Milliseconds
90
+ */
74
91
  export const getTimestampByTimezone = (date, selectedTimezone = TIMEZONES.KW) => {
75
92
  const localDate = new Date(date);
76
93
  const localTimezoneOffset = localDate.getTimezoneOffset();
77
- const selectedTimezoneOffset = getUTCOffset(selectedTimezone) * 60;
94
+ const selectedTimezoneOffset = getUTCOffset(selectedTimezone) * 60; // Convert hours to minutes
78
95
  const timezoneDiff = selectedTimezoneOffset - localTimezoneOffset;
79
- const timezoneTimestamp = localDate.getTime() + timezoneDiff * 60000;
96
+ const timezoneTimestamp = localDate.getTime() + timezoneDiff * 60000; // Convert minutes to milliseconds
80
97
  const timezoneDate = new Date(timezoneTimestamp);
81
98
  const timezoneDateString = timezoneDate.toISOString();
82
99
  return dayjs(timezoneDateString).valueOf();
@@ -86,12 +103,23 @@ export const convertCalendarDateToUTC = (date, hoursOffset = 0) => {
86
103
  const adjustedDate = utcDate.subtract(hoursOffset, 'hour');
87
104
  return adjustedDate.valueOf();
88
105
  };
106
+ /*
107
+ * Convert UTC date to local date
108
+ * @param date - Date object, date string or timestamp
109
+ * @returns - Date object
110
+ */
89
111
  export const convertUTCtoLocalDate = (date) => {
90
112
  const localDate = new Date(date);
91
113
  const localTimezoneOffset = localDate.getTimezoneOffset();
92
114
  const localTimestamp = localDate.getTime() + localTimezoneOffset * 60000;
93
115
  return new Date(localTimestamp);
94
116
  };
117
+ /*
118
+ * Convert Local date to the selected timezone
119
+ * @param date - Date object, date string or timestamp
120
+ * @param selectedTimezone - Timezone string
121
+ * @returns - Date object
122
+ */
95
123
  export const changeDateTimezone = (date, { currentTimezone, targetTimezone }) => {
96
124
  if (!date) {
97
125
  return '';
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  function encryptWithPublicKey(publicKeyPem, text) {
11
11
  return __awaiter(this, void 0, void 0, function* () {
12
+ // Convert PEM to CryptoKey
12
13
  function importPublicKey(pem) {
13
14
  return __awaiter(this, void 0, void 0, function* () {
14
15
  const pemHeader = '-----BEGIN PUBLIC KEY-----';
@@ -18,7 +19,7 @@ function encryptWithPublicKey(publicKeyPem, text) {
18
19
  const binaryDer = Uint8Array.from(binaryDerString, (c) => c.charCodeAt(0));
19
20
  return yield window.crypto.subtle.importKey('spki', binaryDer.buffer, {
20
21
  name: 'RSA-OAEP',
21
- hash: 'SHA-1',
22
+ hash: 'SHA-1', // <-- Important: match Java's default OAEP hash
22
23
  }, true, ['encrypt']);
23
24
  });
24
25
  }
@@ -27,6 +28,7 @@ function encryptWithPublicKey(publicKeyPem, text) {
27
28
  const encryptedBuffer = yield window.crypto.subtle.encrypt({
28
29
  name: 'RSA-OAEP',
29
30
  }, key, encoder.encode(text));
31
+ // Convert to Base64 for safe transport
30
32
  const bytes = new Uint8Array(encryptedBuffer);
31
33
  let binary = '';
32
34
  for (let i = 0; i < bytes.byteLength; i++) {
@@ -4,10 +4,12 @@ export const isNetworkError = (error) => {
4
4
  export const hasError = (error) => {
5
5
  return Boolean(error);
6
6
  };
7
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
7
8
  export const isTimeoutError = (error) => {
8
9
  var _a, _b;
9
10
  return (_b = ((error === null || error === void 0 ? void 0 : error.code) === 'ECONNABORTED' || ((_a = error === null || error === void 0 ? void 0 : error.message) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes('timeout')))) !== null && _b !== void 0 ? _b : false;
10
11
  };
12
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
11
13
  export const isNotFoundError = (error) => {
12
14
  var _a, _b, _c, _d, _e, _f;
13
15
  if (((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status) === 404)
@@ -17,6 +17,7 @@ const prepareFreshDeskData = ({ individualDetails, activeSegment, language, }) =
17
17
  };
18
18
  };
19
19
  export const setFreshDeskProperties = ({ individualDetails, activeSegment, language, }) => {
20
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
21
  const fcWidgetObj = window.fcWidget;
21
22
  if (!fcWidgetObj) {
22
23
  return;
@@ -46,6 +47,7 @@ export const setFreshDeskProperties = ({ individualDetails, activeSegment, langu
46
47
  });
47
48
  };
48
49
  export const openFreshDeskChat = () => {
50
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
49
51
  const fcWidgetObj = window.fcWidget;
50
52
  if (!fcWidgetObj) {
51
53
  return;