@tap-payments/os-micro-frontend-shared 0.1.376-test.1-test.2-test.3-test.4-test.5 → 0.1.376-test.1-test.2-test.3-test.4-test.5-test.6

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.
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import type { IVirtualTable } from '../../../types/index.js';
3
- declare function VirtualTable({ columns, rows, threshold, showHeader, headerProps, rowProps, footerProps, isLoading, error, columnsSorting, onColumnSort, loadMoreItems, isFetchingNextPage, triggerDataRefetch, scrollToIndex, areAllRowsLoaded, tableBodyStyles, tableMode, tableTitle, onStartDrag, isSheetView, isMinimized, footerComponent, customNoDataComponent, }: Readonly<IVirtualTable>): import("react/jsx-runtime").JSX.Element;
3
+ declare function VirtualTable({ columns, rows, threshold, showHeader, headerProps, rowProps, footerProps, isLoading, error, columnsSorting, onColumnSort, loadMoreItems, isFetchingNextPage, triggerDataRefetch, scrollToIndex, areAllRowsLoaded, tableBodyStyles, tableMode, tableTitle, onStartDrag, isSheetView, isMinimized, footerComponent, customNoDataComponent, defaultSkeleton, }: Readonly<IVirtualTable>): import("react/jsx-runtime").JSX.Element;
4
4
  declare const _default: import("react").MemoExoticComponent<typeof VirtualTable>;
5
5
  export default _default;
@@ -15,7 +15,7 @@ import AutoSizer from 'react-virtualized-auto-sizer';
15
15
  import InfiniteLoader from 'react-window-infinite-loader';
16
16
  import { TABLE_ROW_HEIGHT, TABLE_THRESHOLD, TABLE_LIST_OVER_SCAN, SHEET_VIEW_TABLE_ROW_HEIGHT } from '../../../constants/index.js';
17
17
  import { useDelayToSetValue } from '../../../hooks/index.js';
18
- import { isHeightNotFullyFilledByRows, isNotFoundError, isTimeoutError, hasError } from '../../../utils/index.js';
18
+ import { isHeightNotFullyFilledByRows, isNotFoundError, isTimeoutError, hasError, getProcessedColumns } from '../../../utils/index.js';
19
19
  import TableFooter from '../components/TableFooter/TableFooter';
20
20
  import TableHeader from '../components/TableHeader';
21
21
  import TableLastItem from '../components/TableLastItem';
@@ -34,7 +34,7 @@ const createItemData = memoize((columns, isLoading, rows, rowProps, scrollToInde
34
34
  areAllRowsLoaded,
35
35
  isSheetView,
36
36
  }));
37
- function VirtualTable({ columns, rows, threshold = TABLE_THRESHOLD, showHeader, headerProps, rowProps, footerProps, isLoading, error, columnsSorting, onColumnSort, loadMoreItems, isFetchingNextPage, triggerDataRefetch, scrollToIndex, areAllRowsLoaded = false, tableBodyStyles, tableMode, tableTitle, onStartDrag, isSheetView = false, isMinimized, footerComponent, customNoDataComponent, }) {
37
+ function VirtualTable({ columns, rows, threshold = TABLE_THRESHOLD, showHeader, headerProps, rowProps, footerProps, isLoading, error, columnsSorting, onColumnSort, loadMoreItems, isFetchingNextPage, triggerDataRefetch, scrollToIndex, areAllRowsLoaded = false, tableBodyStyles, tableMode, tableTitle, onStartDrag, isSheetView = false, isMinimized, footerComponent, customNoDataComponent, defaultSkeleton = false, }) {
38
38
  var _a;
39
39
  const theme = useTheme();
40
40
  const onPointerDown = (e) => {
@@ -58,7 +58,9 @@ function VirtualTable({ columns, rows, threshold = TABLE_THRESHOLD, showHeader,
58
58
  const tableEmpty = !isLoading && rows.length === 0;
59
59
  const hasTimeoutError = isTimeoutError(error);
60
60
  const lastItemIndex = rows.length - 1;
61
- const shownColumns = useMemo(() => columns.filter((column) => !column.hidden), [columns]);
61
+ // Process columns: use skeleton columns if defaultSkeleton is enabled and loading
62
+ const processedColumns = useMemo(() => getProcessedColumns(columns, isLoading !== null && isLoading !== void 0 ? isLoading : false, defaultSkeleton), [columns, isLoading, defaultSkeleton]);
63
+ const shownColumns = useMemo(() => processedColumns.filter((column) => !column.hidden), [processedColumns]);
62
64
  const orderedColumns = useMemo(() => shownColumns.sort((a, b) => { var _a, _b; return ((_a = a === null || a === void 0 ? void 0 : a.order) !== null && _a !== void 0 ? _a : 1000000) - ((_b = b === null || b === void 0 ? void 0 : b.order) !== null && _b !== void 0 ? _b : 1000000); }), [shownColumns]);
63
65
  const areTotalRowsNotFillingHeight = isHeightNotFullyFilledByRows(rows.length) && !tableLoading;
64
66
  const itemsCount = isDelayedFetchingNextPage || (areAllRowsLoaded && !areTotalRowsNotFillingHeight) ? rows.length + 1 : rows.length;
@@ -116,6 +116,7 @@ export interface IVirtualTable<R = any> {
116
116
  headerProps?: TableHeadProps;
117
117
  isLoading?: boolean;
118
118
  isFetchingNextPage?: boolean;
119
+ defaultSkeleton?: boolean;
119
120
  rowProps?: TableRowProps & {
120
121
  onRowClick?: (row: R, index: number) => void;
121
122
  };
@@ -45,3 +45,4 @@ export * from './boolean';
45
45
  export * from './columnResizeStorage';
46
46
  export * from './timezone';
47
47
  export * from './merchantSource';
48
+ export * from './skeletonColumns';
@@ -45,3 +45,4 @@ export * from './boolean';
45
45
  export * from './columnResizeStorage';
46
46
  export * from './timezone';
47
47
  export * from './merchantSource';
48
+ export * from './skeletonColumns';
@@ -0,0 +1,19 @@
1
+ import type { IColumnProps } from '../types/index.js';
2
+ /**
3
+ * Default static widths for skeleton columns (10 columns with varied widths)
4
+ */
5
+ export declare const DEFAULT_SKELETON_WIDTHS: string[];
6
+ /**
7
+ * Generates skeleton columns with static widths for loading state
8
+ * @param staticWidths Optional array of static widths to use (defaults to DEFAULT_SKELETON_WIDTHS)
9
+ * @returns Array of skeleton column definitions
10
+ */
11
+ export declare const generateSkeletonColumns: (staticWidths?: string[]) => IColumnProps[];
12
+ /**
13
+ * Returns skeleton columns if loading with defaultSkeleton enabled, otherwise returns original columns
14
+ * @param columns Original columns array
15
+ * @param isLoading Loading state
16
+ * @param defaultSkeleton Whether to use default skeleton
17
+ * @returns Processed columns array
18
+ */
19
+ export declare const getProcessedColumns: <T = any>(columns: readonly IColumnProps<T>[], isLoading: boolean, defaultSkeleton: boolean) => IColumnProps<T>[];
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Default static widths for skeleton columns (10 columns with varied widths)
3
+ */
4
+ export const DEFAULT_SKELETON_WIDTHS = ['120px', '180px', '100px', '150px', '200px', '140px', '160px', '110px', '190px', '130px'];
5
+ /**
6
+ * Generates skeleton columns with static widths for loading state
7
+ * @param staticWidths Optional array of static widths to use (defaults to DEFAULT_SKELETON_WIDTHS)
8
+ * @returns Array of skeleton column definitions
9
+ */
10
+ export const generateSkeletonColumns = (staticWidths = DEFAULT_SKELETON_WIDTHS) => {
11
+ return staticWidths.map((width, index) => ({
12
+ id: `skeleton-col-${index}`,
13
+ header: '',
14
+ width,
15
+ order: index,
16
+ hidden: false,
17
+ sortable: false,
18
+ }));
19
+ };
20
+ /**
21
+ * Returns skeleton columns if loading with defaultSkeleton enabled, otherwise returns original columns
22
+ * @param columns Original columns array
23
+ * @param isLoading Loading state
24
+ * @param defaultSkeleton Whether to use default skeleton
25
+ * @returns Processed columns array
26
+ */
27
+ export const getProcessedColumns = (columns, isLoading, defaultSkeleton) => {
28
+ if (defaultSkeleton && isLoading) {
29
+ return generateSkeletonColumns();
30
+ }
31
+ return [...columns];
32
+ };
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.376-test.1-test.2-test.3-test.4-test.5",
5
- "testVersion": 5,
4
+ "version": "0.1.376-test.1-test.2-test.3-test.4-test.5-test.6",
5
+ "testVersion": 6,
6
6
  "type": "module",
7
7
  "main": "build/index.js",
8
8
  "module": "build/index.js",