@tap-payments/os-micro-frontend-shared 0.1.436 → 0.1.437

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.
@@ -0,0 +1,7 @@
1
+ import { AuthenticationModeType } from '../../constants/index.js';
2
+ import { Filters } from './type';
3
+ export declare const AUTHENTICATION_MODES: {
4
+ label: string;
5
+ value: AuthenticationModeType;
6
+ }[];
7
+ export declare const AuthenticationMode: ({ filters, setFilters }: Filters) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,59 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import { useCallback, useMemo, useState } from 'react';
14
+ import { AuthenticationModeBadge } from '../TableCells';
15
+ import Menu from '../Menu';
16
+ import { AUTHENTICATION_LABEL, AuthenticationModeType, rightArrow } from '../../constants/index.js';
17
+ import MenuItem from '../MenuItem';
18
+ import { MenuItemStyled } from './style';
19
+ export const AUTHENTICATION_MODES = [
20
+ { label: AUTHENTICATION_LABEL[AuthenticationModeType.Challenge], value: AuthenticationModeType.Challenge },
21
+ { label: AUTHENTICATION_LABEL[AuthenticationModeType.Frictionless], value: AuthenticationModeType.Frictionless },
22
+ ];
23
+ export const AuthenticationMode = ({ filters, setFilters }) => {
24
+ var _a;
25
+ const [authenticationModeEl, setAuthenticationModeEl] = useState(null);
26
+ const open = Boolean(authenticationModeEl);
27
+ const filterAuthMode = (_a = filters === null || filters === void 0 ? void 0 : filters.auth_mode) !== null && _a !== void 0 ? _a : [];
28
+ const onOpen = (e) => {
29
+ if (!open)
30
+ setAuthenticationModeEl(e.currentTarget);
31
+ };
32
+ const onClose = () => {
33
+ if (open)
34
+ setAuthenticationModeEl(null);
35
+ };
36
+ const authModeAll = useMemo(() => AUTHENTICATION_MODES.map((mode) => mode.value), []);
37
+ const isSelected = useMemo(() => AUTHENTICATION_MODES.length === filterAuthMode.length && filterAuthMode.length > 0, [filterAuthMode.length, authModeAll === null || authModeAll === void 0 ? void 0 : authModeAll.length]);
38
+ const isIndeterminate = useMemo(() => !isSelected && filterAuthMode.length > 0, [filterAuthMode.length, isSelected]);
39
+ const onClick = () => {
40
+ if (isSelected) {
41
+ const { auth_mode } = filters, resetFilters = __rest(filters, ["auth_mode"]);
42
+ setFilters(resetFilters);
43
+ return;
44
+ }
45
+ setFilters(Object.assign(Object.assign({}, filters), { auth_mode: authModeAll }));
46
+ };
47
+ const isSelectedAuthMode = useCallback((selectedAuthMode) => { var _a; return (_a = filterAuthMode.includes(selectedAuthMode)) !== null && _a !== void 0 ? _a : false; }, [filterAuthMode.length]);
48
+ const onClickAuthMode = (e, selectedAuthMode) => {
49
+ var _a;
50
+ e.stopPropagation();
51
+ if (isSelectedAuthMode(selectedAuthMode)) {
52
+ setFilters(Object.assign(Object.assign({}, filters), { auth_mode: (_a = filterAuthMode === null || filterAuthMode === void 0 ? void 0 : filterAuthMode.filter((authMode) => authMode !== selectedAuthMode)) !== null && _a !== void 0 ? _a : [] }));
53
+ }
54
+ else {
55
+ setFilters(Object.assign(Object.assign({}, filters), { auth_mode: [...(filterAuthMode !== null && filterAuthMode !== void 0 ? filterAuthMode : []), selectedAuthMode] }));
56
+ }
57
+ };
58
+ return (_jsxs(MenuItemStyled, Object.assign({ isSelected: isSelected, isIndeterminate: isIndeterminate, onMouseEnter: onOpen, onMouseLeave: onClose, onClick: onClick }, { children: [_jsx("span", Object.assign({ className: "label" }, { children: "Authentication Mode" })), _jsx("img", { src: rightArrow, alt: "arrow", style: { height: 12 } }), _jsx(Menu, Object.assign({ open: open, anchorEl: authenticationModeEl, placement: "right-start" }, { children: AUTHENTICATION_MODES.map((mode) => (_jsxs(MenuItem, Object.assign({ isSelected: isSelectedAuthMode(mode.value), onClick: (e) => onClickAuthMode(e, mode.value) }, { children: [_jsx(AuthenticationModeBadge, { mode: mode.value }), mode.label] }), mode.value))) }))] })));
59
+ };
@@ -2,4 +2,5 @@ export { default as PaymentSourceFilter } from './PaymentSourceFilter';
2
2
  export { default as PaymentMethods } from './PaymentMethods';
3
3
  export { default as PaymentSchemes } from './PaymentSchemes';
4
4
  export { default as PaymentInitiated } from './PaymentInitiated';
5
+ export { AuthenticationMode } from './AuthenticationMode';
5
6
  export * from './type';
@@ -2,4 +2,5 @@ export { default as PaymentSourceFilter } from './PaymentSourceFilter';
2
2
  export { default as PaymentMethods } from './PaymentMethods';
3
3
  export { default as PaymentSchemes } from './PaymentSchemes';
4
4
  export { default as PaymentInitiated } from './PaymentInitiated';
5
+ export { AuthenticationMode } from './AuthenticationMode';
5
6
  export * from './type';
@@ -1,4 +1,4 @@
1
- import { authenticationAttemptedIcon, authenticationFailedIcon, authenticationPendingIcon, authenticationUnavailableIcon, authenticationExemptedWithTransactionIcon, authenticationExemptedWithoutTransactionIcon, authenticationWithTransactionIcon, authenticationWithoutTransactionIcon, authenticatedSuccessIcon, authenticationDeclinedIcon, authenticationUndeterminedIcon, authenticationNoAuthIcon, } from '../../../../constants/index.js';
1
+ import { authenticationAttemptedIcon, authenticationFailedIcon, authenticationPendingIcon, authenticationUnavailableIcon, authenticationExemptedWithTransactionIcon, authenticationExemptedWithoutTransactionIcon, authenticationWithTransactionIcon, authenticatedSuccessIcon, authenticationDeclinedIcon, authenticationUndeterminedIcon, authenticationNoAuthIcon, } from '../../../../constants/index.js';
2
2
  import { statusIcons } from '../../../TableCells/CustomCells/StatusCell/constant';
3
3
  export const authenticationStatusIcons = {
4
4
  FAILED: authenticationFailedIcon,
@@ -14,7 +14,7 @@ export const authenticationStatusIcons = {
14
14
  SUCCESS: authenticatedSuccessIcon,
15
15
  AUTHENTICATED: authenticationWithTransactionIcon,
16
16
  AUTHENTICATED_WITH_TRANSACTION: authenticationWithTransactionIcon,
17
- AUTHENTICATED_WITHOUT_TRANSACTION: authenticationWithoutTransactionIcon,
17
+ AUTHENTICATED_WITHOUT_TRANSACTION: authenticationWithTransactionIcon,
18
18
  AUTHENTICATED_AUTHORIZE_FAILED: authenticationFailedIcon,
19
19
  };
20
20
  export const chargeStatusIcons = statusIcons;
@@ -1,6 +1,6 @@
1
- import { AuthenticationMode } from './constant';
1
+ import { AuthenticationModeType } from '../../../../../../constants/index.js';
2
2
  interface AuthenticationModeBadgeProps {
3
- mode: AuthenticationMode;
3
+ mode: AuthenticationModeType;
4
4
  }
5
5
  export declare const AuthenticationModeBadge: ({ mode }: AuthenticationModeBadgeProps) => import("react/jsx-runtime").JSX.Element | null;
6
6
  export {};
@@ -1,10 +1,9 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import Box from '@mui/material/Box';
3
3
  import Tooltip from '../../../../../Tooltip';
4
- import { ChallengeIcon, FrictionlessIcon } from '../../../../../../constants/index.js';
5
- import { AuthenticationMode, AUTHENTICATION_LABEL } from './constant';
4
+ import { ChallengeIcon, FrictionlessIcon, AuthenticationModeType, AUTHENTICATION_LABEL } from '../../../../../../constants/index.js';
6
5
  export const AuthenticationModeBadge = ({ mode }) => {
7
6
  if (!mode)
8
7
  return null;
9
- return (_jsx(Tooltip, Object.assign({ title: AUTHENTICATION_LABEL[mode] }, { children: _jsx(Box, { component: "img", src: mode === AuthenticationMode.Challenge ? ChallengeIcon : FrictionlessIcon }) })));
8
+ return (_jsx(Tooltip, Object.assign({ title: AUTHENTICATION_LABEL[mode] }, { children: _jsx(Box, { component: "img", src: mode === AuthenticationModeType.Challenge ? ChallengeIcon : FrictionlessIcon }) })));
10
9
  };
@@ -1,2 +1 @@
1
1
  export * from './AuthenticationMode';
2
- export * from './constant';
@@ -1,2 +1 @@
1
1
  export * from './AuthenticationMode';
2
- export * from './constant';
@@ -1,2 +1,7 @@
1
1
  export declare const unAuthenticatedStatuses: string[];
2
2
  export declare const allAuthenticationStatuses: string[];
3
+ export declare enum AuthenticationModeType {
4
+ Challenge = "C",
5
+ Frictionless = "F"
6
+ }
7
+ export declare const AUTHENTICATION_LABEL: Record<AuthenticationModeType, string>;
@@ -12,3 +12,12 @@ export const unAuthenticatedStatuses = [
12
12
  'INITIATED',
13
13
  ];
14
14
  export const allAuthenticationStatuses = [...authenticationStatuses, ...unAuthenticatedStatuses];
15
+ export var AuthenticationModeType;
16
+ (function (AuthenticationModeType) {
17
+ AuthenticationModeType["Challenge"] = "C";
18
+ AuthenticationModeType["Frictionless"] = "F";
19
+ })(AuthenticationModeType || (AuthenticationModeType = {}));
20
+ export const AUTHENTICATION_LABEL = {
21
+ [AuthenticationModeType.Challenge]: 'Challenge',
22
+ [AuthenticationModeType.Frictionless]: 'Frictionless',
23
+ };
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.1.436",
4
+ "version": "0.1.437",
5
5
  "testVersion": 0,
6
6
  "type": "module",
7
7
  "main": "build/index.js",
@@ -1,5 +0,0 @@
1
- export declare enum AuthenticationMode {
2
- Challenge = "C",
3
- Frictionless = "F"
4
- }
5
- export declare const AUTHENTICATION_LABEL: Record<AuthenticationMode, string>;
@@ -1,9 +0,0 @@
1
- export var AuthenticationMode;
2
- (function (AuthenticationMode) {
3
- AuthenticationMode["Challenge"] = "C";
4
- AuthenticationMode["Frictionless"] = "F";
5
- })(AuthenticationMode || (AuthenticationMode = {}));
6
- export const AUTHENTICATION_LABEL = {
7
- [AuthenticationMode.Challenge]: 'Challenge',
8
- [AuthenticationMode.Frictionless]: 'Frictionless',
9
- };