@tap-payments/os-micro-frontend-shared 0.1.96-test.1 → 0.1.96-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.
@@ -7,7 +7,10 @@ interface ISheetViewTableLoadingProps {
7
7
  isLoading?: boolean;
8
8
  rowsCount?: number;
9
9
  isPinned?: boolean;
10
+ tableType?: string;
11
+ containerHeight?: number;
12
+ isCompact?: boolean;
10
13
  }
11
- declare function SheetViewTableLoading({ columns, isLoaded, animationType, isLoading, rowsCount, isPinned, }: ISheetViewTableLoadingProps): import("react/jsx-runtime").JSX.Element;
14
+ declare function SheetViewTableLoading({ columns, isLoaded, animationType, isLoading, rowsCount, isPinned, tableType, containerHeight, isCompact, }: ISheetViewTableLoadingProps): import("react/jsx-runtime").JSX.Element;
12
15
  declare const _default: import("react").MemoExoticComponent<typeof SheetViewTableLoading>;
13
16
  export default _default;
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { memo } from 'react';
3
3
  import { styled } from '@mui/material/styles';
4
4
  import uniqueId from 'lodash/uniqueId';
5
- import { calculateMaxAllowedRows } from '../../../../utils/index.js';
5
+ import { calculateSheetViewMaxRows, getSheetViewRowHeight } from '../../../../utils/index.js';
6
6
  import SheetViewTableRowLoading from './SheetViewTableRowLoading';
7
7
  const Wrapper = styled('section')(({ isLoaded = false, isPinned = false }) => ({
8
8
  overflow: 'hidden',
@@ -11,9 +11,11 @@ const Wrapper = styled('section')(({ isLoaded = false, isPinned = false }) => ({
11
11
  filter: isLoaded && !isPinned ? 'blur(8px)' : 'none',
12
12
  marginTop: isLoaded && !isPinned ? '1rem' : '0',
13
13
  }));
14
- function SheetViewTableLoading({ columns, isLoaded = false, animationType, isLoading = false, rowsCount, isPinned = false, }) {
15
- let maxAllowedRows = rowsCount || calculateMaxAllowedRows(isLoaded, isLoading);
16
- maxAllowedRows = rowsCount || Math.max(maxAllowedRows, 25);
14
+ function SheetViewTableLoading({ columns, isLoaded = false, animationType, isLoading = false, rowsCount, isPinned = false, tableType = 'default', containerHeight, isCompact = false, }) {
15
+ const availableHeight = containerHeight || window.innerHeight * 0.8;
16
+ const rowHeight = getSheetViewRowHeight();
17
+ const maxAllowedRows = calculateSheetViewMaxRows(availableHeight, rowHeight);
18
+ console.log({ maxAllowedRows, availableHeight, rowHeight, tableType, isCompact, containerHeight });
17
19
  return (_jsx(Wrapper, Object.assign({ isLoaded: isLoaded, isPinned: isPinned, "data-testid": "SheetViewTableLoading" }, { children: [...Array(maxAllowedRows)].map((_, index) => (_jsx(SheetViewTableRowLoading, { columns: columns, animationType: animationType, rowIndex: index, useTableBackground: !isPinned }, `i-${uniqueId('SheetViewTableLoadingRow_')}`))) })));
18
20
  }
19
21
  export default memo(SheetViewTableLoading);
@@ -6,4 +6,9 @@ export declare const getColumnWidthPercentage: (widthInPx: number, options?: {
6
6
  export declare const getCellWidth: ({ table, cellID, tableMode }: TableCellWidthProps) => string;
7
7
  export declare const calculateMaxAllowedRows: (isLoaded: boolean, isLoading: boolean) => number;
8
8
  export declare const isHeightNotFullyFilledByRows: (totalRows: number) => boolean;
9
+ export declare const calculateSheetViewHeight: (totalRows: number, rowHeight?: number) => number;
10
+ export declare const calculateSheetViewMaxRows: (availableHeight: number, rowHeight?: number) => number;
11
+ export declare const isSheetViewScrollable: (totalRows: number, containerHeight: number, rowHeight?: number) => boolean;
12
+ export declare const getSheetViewRowHeight: () => number;
13
+ export declare const calculateSheetViewOptimalHeight: (totalRows: number, tableType: string, maxHeightPercentage?: number) => number;
9
14
  export declare const isTableDefaultMode: (tableMode?: TableMode) => boolean;
@@ -73,6 +73,38 @@ export const isHeightNotFullyFilledByRows = (totalRows) => {
73
73
  const allowedRows = maxRowsThatFit();
74
74
  return totalRows < allowedRows + 1;
75
75
  };
76
+ export const calculateSheetViewHeight = (totalRows, rowHeight = TABLE_CONTENT_ROW_HEIGHT) => {
77
+ const headerHeight = 56;
78
+ const padding = 16;
79
+ const calculatedHeight = headerHeight + totalRows * rowHeight + padding;
80
+ const minHeight = 200;
81
+ const maxHeight = window.innerHeight * 0.8;
82
+ return Math.max(minHeight, Math.min(calculatedHeight, maxHeight));
83
+ };
84
+ export const calculateSheetViewMaxRows = (availableHeight, rowHeight = TABLE_CONTENT_ROW_HEIGHT) => {
85
+ const headerHeight = 56;
86
+ const padding = 16;
87
+ const availableContentHeight = availableHeight - headerHeight - padding;
88
+ return Math.floor(availableContentHeight / rowHeight);
89
+ };
90
+ export const isSheetViewScrollable = (totalRows, containerHeight, rowHeight = TABLE_CONTENT_ROW_HEIGHT) => {
91
+ const headerHeight = 56;
92
+ const padding = 16;
93
+ const contentHeight = headerHeight + totalRows * rowHeight + padding;
94
+ return contentHeight > containerHeight;
95
+ };
96
+ export const getSheetViewRowHeight = () => {
97
+ const baseRowHeight = TABLE_CONTENT_ROW_HEIGHT;
98
+ return baseRowHeight * 0.8;
99
+ };
100
+ export const calculateSheetViewOptimalHeight = (totalRows, tableType, maxHeightPercentage = 0.8) => {
101
+ const rowHeight = getSheetViewRowHeight();
102
+ const headerHeight = 56;
103
+ const padding = 16;
104
+ const calculatedHeight = headerHeight + totalRows * rowHeight + padding;
105
+ const maxHeight = window.innerHeight * maxHeightPercentage;
106
+ return Math.min(calculatedHeight, maxHeight);
107
+ };
76
108
  export const isTableDefaultMode = (tableMode = 'default') => {
77
109
  return tableMode === 'default';
78
110
  };
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@tap-payments/os-micro-frontend-shared",
3
3
  "description": "Shared components and utilities for Tap Payments micro frontends",
4
- "version": "0.1.96-test.1",
5
- "testVersion": 1,
4
+ "version": "0.1.96-test.2",
5
+ "testVersion": 2,
6
6
  "type": "module",
7
7
  "main": "build/index.js",
8
8
  "module": "build/index.js",