@tap-payments/os-micro-frontend-shared 0.0.180-alpha.3 → 0.0.180-alpha.5
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/TableCells/CustomCells/ActionCell/ActionCell.d.ts +1 -1
- package/build/components/TableCells/CustomCells/ActionCell/ActionCell.js +13 -13
- package/build/components/TableCells/CustomCells/ActionCell/hooks/useActionCell.d.ts +3 -1
- package/build/components/TableCells/CustomCells/ActionCell/hooks/useActionCell.js +3 -2
- package/build/components/TableCells/CustomCells/type.d.ts +1 -0
- package/package.json +1 -1
|
@@ -5,6 +5,6 @@ type Props = Readonly<ActionCellProps> & {
|
|
|
5
5
|
onJsonViewClick?: () => void;
|
|
6
6
|
tableMode?: TableMode;
|
|
7
7
|
};
|
|
8
|
-
declare function ActionCell({ flag, actions, flagTooltip, flagsCount, dropdownAction, onCloseDropdown, isDropdownShown, row, showJsonViewer, isTextShown, showIdButton, rowId, onJsonViewClick, tableMode, ...props }: Props): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
declare function ActionCell({ flag, actions, flagTooltip, flagsCount, dropdownAction, onCloseDropdown, isDropdownShown, row, showJsonViewer, isTextShown, showIdButton, rowId, onJsonViewClick, tableMode, renderDropdown, ...props }: Props): import("react/jsx-runtime").JSX.Element;
|
|
9
9
|
declare const _default: React.MemoExoticComponent<typeof ActionCell>;
|
|
10
10
|
export default _default;
|
|
@@ -27,9 +27,9 @@ import { BadgeWrapper, IdButtonContainer, TextLabel, TransparentButton } from '.
|
|
|
27
27
|
import SheetViewIDButton from '../SheetViewIDButton/SheetViewIDButton';
|
|
28
28
|
function ActionCell(_a) {
|
|
29
29
|
var _b, _c;
|
|
30
|
-
var { flag, actions, flagTooltip, flagsCount, dropdownAction, onCloseDropdown, isDropdownShown = true, row, showJsonViewer = true, isTextShown, showIdButton = true, rowId, onJsonViewClick, tableMode } = _a, props = __rest(_a, ["flag", "actions", "flagTooltip", "flagsCount", "dropdownAction", "onCloseDropdown", "isDropdownShown", "row", "showJsonViewer", "isTextShown", "showIdButton", "rowId", "onJsonViewClick", "tableMode"]);
|
|
30
|
+
var { flag, actions, flagTooltip, flagsCount, dropdownAction, onCloseDropdown, isDropdownShown = true, row, showJsonViewer = true, isTextShown, showIdButton = true, rowId, onJsonViewClick, tableMode, renderDropdown } = _a, props = __rest(_a, ["flag", "actions", "flagTooltip", "flagsCount", "dropdownAction", "onCloseDropdown", "isDropdownShown", "row", "showJsonViewer", "isTextShown", "showIdButton", "rowId", "onJsonViewClick", "tableMode", "renderDropdown"]);
|
|
31
31
|
const { t } = useTranslation();
|
|
32
|
-
const { open, anchorEl, filteredActions, isAnyActionLoading, isAnyActionHasError, isAnyActionSuccessful, areThereAnyShownActions, handleClick, handleClose, } = useActionCell({ actions, isDropdownShown, onCloseDropdown });
|
|
32
|
+
const { open, anchorEl, filteredActions, isAnyActionLoading, isAnyActionHasError, isAnyActionSuccessful, areThereAnyShownActions, handleClick, handleClose, setAnchorEl, } = useActionCell({ actions, isDropdownShown, onCloseDropdown, renderDropdown });
|
|
33
33
|
return (_jsx(TableCell, Object.assign({}, props, { sx: {
|
|
34
34
|
overflow: 'visible',
|
|
35
35
|
} }, { children: _jsxs(ActionCellContainer, Object.assign({ "data-testid": "ActionCell_ActionCellContainer", tableMode: tableMode }, { children: [flag && (_jsx(_Fragment, { children: isTextShown ? (_jsx(Tooltip, Object.assign({ title: flagTooltip }, { children: _jsx(TextLabel, Object.assign({ "data-testid": "ActionCell_FlagLabel", sx: {
|
|
@@ -81,16 +81,16 @@ function ActionCell(_a) {
|
|
|
81
81
|
pointerEvents: 'none',
|
|
82
82
|
})) }, { children: [_jsx(TransparentButton, Object.assign({ onClick: handleClick, "data-testid": "ActionCell_ActionsIconContainer_TransparentButton", "data-is-active": areThereAnyShownActions, sx: Object.assign({}, (!areThereAnyShownActions && {
|
|
83
83
|
pointerEvents: 'none',
|
|
84
|
-
})) }, { children: _jsx(AnimatePresence, Object.assign({ mode: "wait" }, { children: _jsx(ActionIconsVariants, { isAnyActionLoading: isAnyActionLoading, isAnyActionHasError: isAnyActionHasError, isAnyActionSuccessful: isAnyActionSuccessful, areThereAnyShownActions: areThereAnyShownActions }) })) })), dropdownAction, areThereAnyShownActions && (_jsx(Dropdown, { style: { zIndex: 2000 }, open: open, onClose: handleClose, anchorEl: anchorEl, menuItems: filteredActions.map((action) => (Object.assign(Object.assign({}, action), { onClick: (e) => {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
84
|
+
})) }, { children: _jsx(AnimatePresence, Object.assign({ mode: "wait" }, { children: _jsx(ActionIconsVariants, { isAnyActionLoading: isAnyActionLoading, isAnyActionHasError: isAnyActionHasError, isAnyActionSuccessful: isAnyActionSuccessful, areThereAnyShownActions: areThereAnyShownActions }) })) })), renderDropdown ? (renderDropdown(anchorEl, setAnchorEl)) : (_jsxs(_Fragment, { children: [dropdownAction, areThereAnyShownActions && (_jsx(Dropdown, { style: { zIndex: 2000 }, open: open, onClose: handleClose, anchorEl: anchorEl, menuItems: filteredActions.map((action) => (Object.assign(Object.assign({}, action), { onClick: (e) => {
|
|
85
|
+
var _a;
|
|
86
|
+
(_a = action === null || action === void 0 ? void 0 : action.onClick) === null || _a === void 0 ? void 0 : _a.call(action, e);
|
|
87
|
+
if (!action.hasActionMenu) {
|
|
88
|
+
handleClose();
|
|
89
|
+
}
|
|
90
|
+
}, onRightClick: (e) => {
|
|
91
|
+
var _a;
|
|
92
|
+
(_a = action === null || action === void 0 ? void 0 : action.onRightClick) === null || _a === void 0 ? void 0 : _a.call(action, e);
|
|
93
|
+
handleClose();
|
|
94
|
+
}, icon: (_jsx(ActionIcon, { icon: action.icon, src: actionIcons[action.icon], initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 } }, `action.label-${action.label.trim()}`)) }))) }))] }))] }))] }))] })) })));
|
|
95
95
|
}
|
|
96
96
|
export default memo(ActionCell);
|
|
@@ -4,8 +4,9 @@ interface UseActionCellProps {
|
|
|
4
4
|
actions: ActionCellProps['actions'];
|
|
5
5
|
isDropdownShown?: ActionCellProps['isDropdownShown'];
|
|
6
6
|
onCloseDropdown?: ActionCellProps['onCloseDropdown'];
|
|
7
|
+
renderDropdown?: ActionCellProps['renderDropdown'];
|
|
7
8
|
}
|
|
8
|
-
export declare function useActionCell({ actions, isDropdownShown, onCloseDropdown }: Readonly<UseActionCellProps>): {
|
|
9
|
+
export declare function useActionCell({ actions, isDropdownShown, onCloseDropdown, renderDropdown }: Readonly<UseActionCellProps>): {
|
|
9
10
|
anchorEl: HTMLElement | null;
|
|
10
11
|
open: boolean;
|
|
11
12
|
filteredActions: {
|
|
@@ -25,5 +26,6 @@ export declare function useActionCell({ actions, isDropdownShown, onCloseDropdow
|
|
|
25
26
|
areThereAnyShownActions: boolean;
|
|
26
27
|
handleClick: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
27
28
|
handleClose: () => void;
|
|
29
|
+
setAnchorEl: React.Dispatch<React.SetStateAction<HTMLElement | null>>;
|
|
28
30
|
};
|
|
29
31
|
export {};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
|
-
export function useActionCell({ actions, isDropdownShown, onCloseDropdown }) {
|
|
2
|
+
export function useActionCell({ actions, isDropdownShown, onCloseDropdown, renderDropdown }) {
|
|
3
3
|
const [anchorEl, setAnchorEl] = useState(null);
|
|
4
4
|
const open = Boolean(anchorEl);
|
|
5
5
|
const filteredActions = actions.filter((a) => a.isShown !== false);
|
|
6
6
|
const isAnyActionLoading = filteredActions.some((a) => a.isLoading);
|
|
7
7
|
const isAnyActionHasError = filteredActions.some((a) => a.isError);
|
|
8
8
|
const isAnyActionSuccessful = filteredActions.some((a) => a.isSuccess);
|
|
9
|
-
const areThereAnyShownActions = filteredActions.length > 0;
|
|
9
|
+
const areThereAnyShownActions = filteredActions.length > 0 || !!renderDropdown;
|
|
10
10
|
const handleClick = (event) => {
|
|
11
11
|
if (isAnyActionLoading || !areThereAnyShownActions) {
|
|
12
12
|
return;
|
|
@@ -32,5 +32,6 @@ export function useActionCell({ actions, isDropdownShown, onCloseDropdown }) {
|
|
|
32
32
|
areThereAnyShownActions,
|
|
33
33
|
handleClick,
|
|
34
34
|
handleClose,
|
|
35
|
+
setAnchorEl,
|
|
35
36
|
};
|
|
36
37
|
}
|
|
@@ -109,6 +109,7 @@ export interface ActionCellProps extends TableCellProps {
|
|
|
109
109
|
showJsonViewer?: boolean;
|
|
110
110
|
isTextShown?: boolean;
|
|
111
111
|
showIdButton?: boolean;
|
|
112
|
+
renderDropdown?: (anchorEl: HTMLElement | null, setAnchorEl: (anchorEl: HTMLElement | null) => void) => React.ReactNode;
|
|
112
113
|
}
|
|
113
114
|
export interface DeviceCellProps extends TableCellProps {
|
|
114
115
|
deviceType?: 'DESKTOP' | 'PHONE' | 'TABLET';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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.0.180-alpha.
|
|
4
|
+
"version": "0.0.180-alpha.5",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "build/index.js",
|
|
7
7
|
"module": "build/index.js",
|