@tap-payments/os-micro-frontend-shared 0.1.30-test.3 → 0.1.31-test.10

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 (47) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +12 -12
  3. package/build/components/MaskedText/MaskedText.d.ts +1 -1
  4. package/build/components/MaskedText/MaskedText.js +3 -3
  5. package/build/components/MaskedText/type.d.ts +2 -1
  6. package/build/components/RightLeftExpandingCenterChip/RightLeftExpandingCenterChip.d.ts +3 -0
  7. package/build/components/RightLeftExpandingCenterChip/RightLeftExpandingCenterChip.js +43 -0
  8. package/build/components/RightLeftExpandingCenterChip/index.d.ts +2 -0
  9. package/build/components/RightLeftExpandingCenterChip/index.js +2 -0
  10. package/build/components/RightLeftExpandingCenterChip/style.d.ts +3415 -0
  11. package/build/components/RightLeftExpandingCenterChip/style.js +104 -0
  12. package/build/components/RightLeftExpandingCenterChip/type.d.ts +10 -0
  13. package/build/components/RightLeftExpandingCenterChip/type.js +1 -0
  14. package/build/components/RightLeftExpandingCenterChip/useRightLeftExpandingCenterChip.d.ts +31 -0
  15. package/build/components/RightLeftExpandingCenterChip/useRightLeftExpandingCenterChip.js +156 -0
  16. package/build/components/StatusChip/StatusChip.d.ts +1 -1
  17. package/build/components/StatusChip/StatusChip.js +37 -4
  18. package/build/components/StatusChip/style.d.ts +10 -3
  19. package/build/components/StatusChip/style.js +14 -36
  20. package/build/components/StatusChip/type.d.ts +2 -0
  21. package/build/components/StatusChipWithCopy/StatusChipWithCopy.d.ts +11 -0
  22. package/build/components/StatusChipWithCopy/StatusChipWithCopy.js +12 -0
  23. package/build/components/StatusChipWithCopy/index.d.ts +4 -0
  24. package/build/components/StatusChipWithCopy/index.js +4 -0
  25. package/build/components/StatusChipWithCopy/utils.d.ts +4 -0
  26. package/build/components/StatusChipWithCopy/utils.js +4 -0
  27. package/build/components/StatusGroupChips/style.d.ts +2 -0
  28. package/build/components/StatusGroupChips/type.d.ts +2 -0
  29. package/build/components/TableCells/CustomCells/DestinationCell/DestinationCell.d.ts +1 -1
  30. package/build/components/TableCells/CustomCells/DestinationCell/DestinationCell.js +12 -11
  31. package/build/components/TableCells/CustomCells/type.d.ts +2 -2
  32. package/build/components/VirtualTables/SheetViewVirtualTable/SheetViewVirtualTable.js +3 -1
  33. package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useTableState.d.ts +2 -0
  34. package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useTableState.js +19 -0
  35. package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useVirtualTableContainer.d.ts +7 -3
  36. package/build/components/VirtualTables/SheetViewVirtualTable/hooks/useVirtualTableContainer.js +5 -3
  37. package/build/components/VirtualTables/components/TableRow.d.ts +4 -2
  38. package/build/components/VirtualTables/components/TableRow.js +11 -5
  39. package/build/components/VirtualTables/components/virtualScroll/ListItemWrapper.js +1 -1
  40. package/build/components/index.d.ts +1 -0
  41. package/build/components/index.js +1 -0
  42. package/build/constants/assets.d.ts +1 -0
  43. package/build/constants/assets.js +1 -0
  44. package/build/types/table.d.ts +10 -0
  45. package/build/utils/style.d.ts +6 -0
  46. package/build/utils/style.js +1 -1
  47. package/package.json +2 -2
@@ -8,7 +8,9 @@ export declare const useTableState: () => {
8
8
  selectedCell: string | null;
9
9
  selectedColumn: string | null;
10
10
  showBackDrop: boolean;
11
+ selectedChip: string | null;
11
12
  setShowBackdrop: import("react").Dispatch<import("react").SetStateAction<boolean>>;
13
+ handleChipClick: (rowIndex: number, columnIndex: number, event: React.MouseEvent, chipIndex: number, pinnedType?: 'start' | 'end') => void;
12
14
  handleCellClick: (rowIndex: number, columnIndex: number, event: React.MouseEvent, pinnedType?: 'start' | 'end') => void;
13
15
  handleColumnClick: (columnIndex: number, event: React.MouseEvent, pinnedType?: 'start' | 'end') => void;
14
16
  resetSelection: () => void;
@@ -2,28 +2,47 @@ import { useState, useCallback } from 'react';
2
2
  export const useTableState = () => {
3
3
  const [selectedCell, setSelectedCell] = useState(null);
4
4
  const [selectedColumn, setSelectedColumn] = useState(null);
5
+ const [selectedChip, setSelectedChip] = useState(null);
5
6
  const [showBackDrop, setShowBackdrop] = useState(false);
7
+ const handleChipClick = useCallback((rowIndex, columnIndex, event, chipIndex, pinnedType) => {
8
+ event.stopPropagation();
9
+ const chipKey = `${pinnedType !== null && pinnedType !== void 0 ? pinnedType : 'default'}-${rowIndex}-${columnIndex}-${chipIndex}`;
10
+ const cellKey = `${pinnedType !== null && pinnedType !== void 0 ? pinnedType : 'default'}-${rowIndex}-${columnIndex}`;
11
+ const isChipAlreadySelected = selectedChip === chipKey;
12
+ if (isChipAlreadySelected) {
13
+ setSelectedChip(null);
14
+ setSelectedCell(null);
15
+ return;
16
+ }
17
+ setSelectedChip(chipKey);
18
+ setSelectedCell(cellKey);
19
+ }, [selectedChip, setSelectedChip, setSelectedCell]);
6
20
  const handleCellClick = useCallback((rowIndex, columnIndex, event, pinnedType) => {
7
21
  event.stopPropagation();
8
22
  const cellKey = `${pinnedType !== null && pinnedType !== void 0 ? pinnedType : 'default'}-${rowIndex}-${columnIndex}`;
9
23
  setSelectedCell((prev) => (prev === cellKey ? null : cellKey));
10
24
  setSelectedColumn(null);
25
+ setSelectedChip(null);
11
26
  }, []);
12
27
  const handleColumnClick = useCallback((columnIndex, event, pinnedType) => {
13
28
  event.stopPropagation();
14
29
  const columnKey = `${pinnedType !== null && pinnedType !== void 0 ? pinnedType : 'default'}-${columnIndex}`;
15
30
  setSelectedColumn((prev) => (prev === columnKey ? null : columnKey));
16
31
  setSelectedCell(null);
32
+ setSelectedChip(null);
17
33
  }, []);
18
34
  const resetSelection = useCallback(() => {
19
35
  setSelectedCell(null);
20
36
  setSelectedColumn(null);
37
+ setSelectedChip(null);
21
38
  }, []);
22
39
  return {
23
40
  selectedCell,
24
41
  selectedColumn,
25
42
  showBackDrop,
43
+ selectedChip,
26
44
  setShowBackdrop,
45
+ handleChipClick,
27
46
  handleCellClick,
28
47
  handleColumnClick,
29
48
  resetSelection,
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
- import type { IColumnProps } from '../../../../types/index.js';
2
+ import type { IColumnProps, TableChipProps } from '../../../../types/index.js';
3
3
  import type { TableRowProps } from '@mui/material/TableRow';
4
- interface UseVirtualTableContainerProps<T = unknown> {
4
+ interface UseVirtualTableContainerProps<T = unknown> extends TableChipProps {
5
5
  rowHeight: number;
6
6
  areAllRowsLoaded?: boolean;
7
7
  rows: T[];
@@ -16,9 +16,11 @@ interface UseVirtualTableContainerProps<T = unknown> {
16
16
  isError: boolean;
17
17
  selectedCell: string | null;
18
18
  selectedColumn: string | null;
19
+ selectedChip: string | null;
19
20
  handleCellClick: (rowIndex: number, columnIndex: number, event: React.MouseEvent, pinnedType?: 'start' | 'end') => void;
21
+ handleChipClick: (rowIndex: number, columnIndex: number, event: React.MouseEvent, chipIndex: number, pinnedType?: 'start' | 'end') => void;
20
22
  }
21
- export declare const useVirtualTableContainer: <T = unknown>({ rowHeight, areAllRowsLoaded, rows, isDelayedFetchingNextPage, rowProps, scrollToIndex, footerProps, isError, selectedCell, selectedColumn, handleCellClick, }: UseVirtualTableContainerProps<T>) => {
23
+ export declare const useVirtualTableContainer: <T = unknown>({ rowHeight, areAllRowsLoaded, rows, isDelayedFetchingNextPage, rowProps, scrollToIndex, footerProps, isError, selectedCell, selectedColumn, selectedChip, handleCellClick, handleChipClick, }: UseVirtualTableContainerProps<T>) => {
22
24
  getItemSize: (index: number, height: number) => number;
23
25
  getItemDataForContainer: (columnsData: IColumnProps[], isPinnedColumn: boolean, height: number) => {
24
26
  columns: any;
@@ -36,7 +38,9 @@ export declare const useVirtualTableContainer: <T = unknown>({ rowHeight, areAll
36
38
  isPinned: any;
37
39
  selectedCell: any;
38
40
  selectedColumn: any;
41
+ selectedChip: any;
39
42
  onCellClick: any;
43
+ onChipClick: any;
40
44
  containerHeight: any;
41
45
  rowHeight: any;
42
46
  };
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useMemo } from 'react';
2
2
  import memoize from 'memoize-one';
3
- const createItemData = memoize((columns, isLoading, rows, rowProps, scrollToIndex, lastItemIndex, totalCount, isError, areAllRowsLoaded, isPinned, selectedCell, selectedColumn, onCellClick, containerHeight, rowHeight) => ({
3
+ const createItemData = memoize((columns, isLoading, rows, rowProps, scrollToIndex, lastItemIndex, totalCount, isError, areAllRowsLoaded, isPinned, selectedCell, selectedColumn, selectedChip, onCellClick, onChipClick, containerHeight, rowHeight) => ({
4
4
  columns,
5
5
  isLoading,
6
6
  rows,
@@ -16,11 +16,13 @@ const createItemData = memoize((columns, isLoading, rows, rowProps, scrollToInde
16
16
  isPinned,
17
17
  selectedCell,
18
18
  selectedColumn,
19
+ selectedChip,
19
20
  onCellClick,
21
+ onChipClick,
20
22
  containerHeight,
21
23
  rowHeight,
22
24
  }));
23
- export const useVirtualTableContainer = ({ rowHeight, areAllRowsLoaded, rows, isDelayedFetchingNextPage, rowProps, scrollToIndex, footerProps, isError, selectedCell, selectedColumn, handleCellClick, }) => {
25
+ export const useVirtualTableContainer = ({ rowHeight, areAllRowsLoaded, rows, isDelayedFetchingNextPage, rowProps, scrollToIndex, footerProps, isError, selectedCell, selectedColumn, selectedChip, handleCellClick, handleChipClick, }) => {
24
26
  const getItemSize = useCallback((index, height) => {
25
27
  const isLastRow = areAllRowsLoaded && index === rows.length;
26
28
  if (isLastRow) {
@@ -44,7 +46,7 @@ export const useVirtualTableContainer = ({ rowHeight, areAllRowsLoaded, rows, is
44
46
  areAllRowsLoaded,
45
47
  ];
46
48
  }, [isDelayedFetchingNextPage, rows, rowProps, scrollToIndex, footerProps === null || footerProps === void 0 ? void 0 : footerProps.totalCount, isError, areAllRowsLoaded]);
47
- const commonItemDataSuffix = useMemo(() => [selectedCell, selectedColumn, handleCellClick], [selectedCell, selectedColumn, handleCellClick]);
49
+ const commonItemDataSuffix = useMemo(() => [selectedCell, selectedColumn, selectedChip, handleCellClick, handleChipClick], [selectedCell, selectedColumn, selectedChip, handleCellClick, handleChipClick]);
48
50
  const getItemDataForContainer = useCallback((columnsData, isPinnedColumn, height) => createItemData(columnsData, ...commonItemDataParams, isPinnedColumn, ...commonItemDataSuffix, height, rowHeight), [commonItemDataParams, commonItemDataSuffix, rowHeight]);
49
51
  return {
50
52
  getItemSize,
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import type { TableRowProps } from '@mui/material';
2
+ import { type TableRowProps } from '@mui/material';
3
3
  import type { IColumnProps } from '../../../types/index.js';
4
4
  interface ITableRowProps<R = any> {
5
5
  row: R;
@@ -13,9 +13,11 @@ interface ITableRowProps<R = any> {
13
13
  isSheetView?: boolean;
14
14
  selectedCell?: string | null;
15
15
  selectedColumn?: string | null;
16
+ selectedChip?: string | null;
16
17
  onCellClick?: (rowIndex: number, columnIndex: number, event: React.MouseEvent, pinnedType?: 'start' | 'end') => void;
18
+ onChipClick?: (rowIndex: number, columnIndex: number, event: React.MouseEvent, chipIndex: number, pinnedType?: 'start' | 'end') => void;
17
19
  isLastRow?: boolean;
18
20
  }
19
- declare function TableRow({ row, columns, index, rowProps, isSheetView, selectedCell, selectedColumn, onCellClick, isLastRow, }: Readonly<ITableRowProps>): import("react/jsx-runtime").JSX.Element;
21
+ declare function TableRow({ row, columns, index, rowProps, isSheetView, selectedCell, selectedColumn, selectedChip, onCellClick, isLastRow, onChipClick, }: Readonly<ITableRowProps>): import("react/jsx-runtime").JSX.Element;
20
22
  declare const _default: import("react").MemoExoticComponent<typeof TableRow>;
21
23
  export default _default;
@@ -1,17 +1,21 @@
1
1
  import { createElement as _createElement } from "react";
2
2
  import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
3
3
  import { memo, useMemo } from 'react';
4
+ import { Box } from '@mui/material';
4
5
  import { areEqual } from 'react-window';
5
6
  import { StyledCell, StyledTableRow } from './style';
6
7
  import { getSelectionStyles } from '../../../utils/index.js';
7
- function TableRow({ row, columns, index, rowProps, isSheetView, selectedCell = null, selectedColumn = null, onCellClick, isLastRow = false, }) {
8
- const renderCell = (column) => {
8
+ function TableRow({ row, columns, index, rowProps, isSheetView, selectedCell = null, selectedColumn = null, selectedChip = null, onCellClick, isLastRow = false, onChipClick, }) {
9
+ const renderCell = (column, rowIndex, colIndex) => {
9
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);
13
+ };
10
14
  if (!(column === null || column === void 0 ? void 0 : column.id) || !row)
11
15
  return null;
12
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];
13
17
  const formattedValue = format ? format({ value, row, index }) : value;
14
- return render ? render({ row, column, index, value: row[column === null || column === void 0 ? void 0 : column.id] }) : _jsx(_Fragment, { children: formattedValue });
18
+ return render ? (render({ row, column, index, value: row[column === null || column === void 0 ? void 0 : column.id], chipSelection: { onChipClick: handleChipClick, rowIndex, colIndex, selectedChip } })) : (_jsx(_Fragment, { children: formattedValue }));
15
19
  };
16
20
  const content = useMemo(() => (_jsx(_Fragment, { children: columns.map((column, colIndex) => {
17
21
  var _a, _b;
@@ -34,8 +38,10 @@ function TableRow({ row, columns, index, rowProps, isSheetView, selectedCell = n
34
38
  effectiveFirst = isFirstColumn && column.pinned !== 'start';
35
39
  effectiveLast = isLastColumn && column.pinned !== 'end';
36
40
  }
37
- 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) => onCellClick === null || onCellClick === void 0 ? void 0 : onCellClick(index, colIndex, event, column.pinned), sx: Object.assign(Object.assign({ width: column.width, minWidth: column.width, textAlign: column.align, justifyContent: column.align === 'right' ? 'flex-end' : 'flex-start', cursor: onCellClick ? 'pointer' : 'default' }, selectionStyles), column.cellStyle), isSheetView: isSheetView, isSelected: isCellSelected }, { children: renderCell(column) }), `${column.id}-${colIndex}`));
38
- }) })), [columns, row, index, selectedCell, selectedColumn, onCellClick, isLastRow]);
41
+ 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) => {
42
+ onCellClick === null || onCellClick === void 0 ? void 0 : onCellClick(index, colIndex, event, column.pinned);
43
+ }, sx: Object.assign(Object.assign({ width: column.width, minWidth: column.width, textAlign: column.align, justifyContent: column.align === 'right' ? 'flex-end' : 'flex-start', cursor: onCellClick ? 'pointer' : 'default' }, selectionStyles), column.cellStyle), isSheetView: isSheetView, isSelected: isCellSelected }, { children: _jsx(Box, Object.assign({ sx: { position: 'relative', zIndex: 1, width: '100%' } }, { children: renderCell(column, index, colIndex) })) }), `${column.id}-${colIndex}`));
44
+ }) })), [columns, row, index, selectedCell, selectedColumn, onCellClick, isLastRow, selectedChip, isSheetView]);
39
45
  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));
40
46
  }
41
47
  export default memo(TableRow, areEqual);
@@ -57,7 +57,7 @@ function ListItemWrapper(_a) {
57
57
  const row = rows[index];
58
58
  const isLoadingRow = isLoading && index === lastItemIndex + 1;
59
59
  const isLoadedRow = index <= newLoadedRowsEndIndex;
60
- 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]);
60
+ 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]);
61
61
  const memoizedRowProps = React.useMemo(() => (Object.assign(Object.assign({ showShadowHighlight: scrollToIndex === index, showLoadedStyle: isLoadedRow }, rowProps), { onClick: rowClickHandler })), [scrollToIndex, index, isLoadedRow, rowProps, rowClickHandler]);
62
62
  const renderSheetViewLoadingRow = React.useCallback((lastRowContent) => {
63
63
  return (_jsx(Box, Object.assign({ sx: {
@@ -97,3 +97,4 @@ export { default as AppServices } from './AppServices';
97
97
  export { default as ScrollLoader } from './ScrollLoader';
98
98
  export * from './ScrollLoader';
99
99
  export * from './TooltipChip';
100
+ export * from './RightLeftExpandingCenterChip';
@@ -97,3 +97,4 @@ export { default as AppServices } from './AppServices';
97
97
  export { default as ScrollLoader } from './ScrollLoader';
98
98
  export * from './ScrollLoader';
99
99
  export * from './TooltipChip';
100
+ export * from './RightLeftExpandingCenterChip';
@@ -523,3 +523,4 @@ export declare const deactivatedCircle: string;
523
523
  export declare const exclamationOutlinedCircle: string;
524
524
  export declare const outlinedCircle: string;
525
525
  export declare const greenCheck2ACE00: string;
526
+ export declare const blueCopyIcon: string;
@@ -527,3 +527,4 @@ export const deactivatedCircle = `${lightUrl}/deactivatedCircle.svg`;
527
527
  export const exclamationOutlinedCircle = `${lightUrl}/exclamationOutlinedCircle.svg`;
528
528
  export const outlinedCircle = `${lightUrl}/outlinedCircle.svg`;
529
529
  export const greenCheck2ACE00 = `${lightUrl}/greenCheck2ACE00.svg`;
530
+ export const blueCopyIcon = `${lightUrl}/blueCopyIcon.svg`;
@@ -47,11 +47,21 @@ export interface TableFooterProps extends BoxProps {
47
47
  maximized?: boolean;
48
48
  children?: React.ReactNode;
49
49
  }
50
+ export interface TableChipProps {
51
+ onChipClick?: (rowIndex: number, columnIndex: number, event: React.MouseEvent, chipIndex: number, pinnedType?: 'start' | 'end') => void;
52
+ }
53
+ export interface ChipSelection {
54
+ onChipClick?: (event: React.MouseEvent, chipIndex: number) => void;
55
+ colIndex?: number;
56
+ rowIndex?: number;
57
+ selectedChip?: string | null;
58
+ }
50
59
  export interface IRenderAttr<R, C> {
51
60
  row: R;
52
61
  column: C;
53
62
  index: number;
54
63
  value: any;
64
+ chipSelection?: ChipSelection;
55
65
  }
56
66
  export interface IFormatAttr<R> {
57
67
  value: string | Record<string, any> | number;
@@ -1,3 +1,9 @@
1
+ export declare const SELECTION_COLORS: {
2
+ readonly primary: "#1F88D0";
3
+ readonly background: "white";
4
+ readonly border: "#F2F2F2";
5
+ readonly transparent: "transparent";
6
+ };
1
7
  interface GetSelectionStylesParams {
2
8
  isSelected: boolean;
3
9
  isCellSelected: boolean;
@@ -1,4 +1,4 @@
1
- const SELECTION_COLORS = {
1
+ export const SELECTION_COLORS = {
2
2
  primary: '#1F88D0',
3
3
  background: 'white',
4
4
  border: '#F2F2F2',
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.30-test.3",
5
- "testVersion": 3,
4
+ "version": "0.1.31-test.10",
5
+ "testVersion": 10,
6
6
  "type": "module",
7
7
  "main": "build/index.js",
8
8
  "module": "build/index.js",