@tap-payments/os-micro-frontend-shared 0.1.402 → 0.1.403-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.
Files changed (52) hide show
  1. package/build/components/AnimatedSpinnerIcon/style.d.ts +0 -1
  2. package/build/components/Chip/style.d.ts +0 -1
  3. package/build/components/CountBadge/style.d.ts +0 -1
  4. package/build/components/Dialog/style.d.ts +0 -1
  5. package/build/components/FlippingCard/style.d.ts +0 -1
  6. package/build/components/IconWithHoverOverlays/IconWithHoverOverlays.js +1 -1
  7. package/build/components/ImageWrapper/ImageWrapper.d.ts +0 -1
  8. package/build/components/JSONViewer/style.d.ts +0 -1
  9. package/build/components/LeftPeekRightExpandingChip/style.d.ts +0 -1
  10. package/build/components/RightLeftExpandingCenterChip/style.d.ts +0 -1
  11. package/build/components/SearchButton/styles.d.ts +0 -1
  12. package/build/components/StatusIcons/AuthIcons/style.d.ts +0 -1
  13. package/build/components/StatusIcons/AuthorizationAutoIcons/style.d.ts +0 -1
  14. package/build/components/StatusIcons/ChargeStatusIcon/style.d.ts +0 -1
  15. package/build/components/StatusIcons/DestinationIcon/DestinationIcon.js +1 -1
  16. package/build/components/StatusIcons/SourceIcons/style.d.ts +0 -1
  17. package/build/components/TableCells/CustomCells/ActionCell/style.d.ts +0 -1
  18. package/build/components/TableCells/CustomCells/AgreementCell/style.d.ts +0 -1
  19. package/build/components/TableCells/CustomCells/ApplicationStatusCell/style.d.ts +0 -1
  20. package/build/components/TableCells/CustomCells/AuthenticationCell/style.d.ts +0 -1
  21. package/build/components/TableCells/CustomCells/AuthenticationStatusCell/style.d.ts +0 -1
  22. package/build/components/TableCells/CustomCells/AuthenticationTypeCell/style.d.ts +0 -1
  23. package/build/components/TableCells/CustomCells/BalanceCell/style.d.ts +0 -1
  24. package/build/components/TableCells/CustomCells/ChannelsCell/style.d.ts +0 -1
  25. package/build/components/TableCells/CustomCells/CheckoutStatusCell/style.d.ts +0 -1
  26. package/build/components/TableCells/CustomCells/DestinationStatusCell/style.d.ts +0 -1
  27. package/build/components/TableCells/CustomCells/DueDateCell/style.d.ts +0 -1
  28. package/build/components/TableCells/CustomCells/IDButton/style.d.ts +0 -1
  29. package/build/components/TableCells/CustomCells/IntentsStatusCell/style.d.ts +0 -1
  30. package/build/components/TableCells/CustomCells/InvoiceStatusCell/style.d.ts +0 -1
  31. package/build/components/TableCells/CustomCells/PayoutReportCell/style.d.ts +0 -1
  32. package/build/components/TableCells/CustomCells/PayoutStatusCell/style.d.ts +0 -1
  33. package/build/components/TableCells/CustomCells/ProductsCell/style.d.ts +0 -1
  34. package/build/components/TableCells/CustomCells/ReferenceCell/style.d.ts +0 -1
  35. package/build/components/TableCells/CustomCells/RefundChargeCell/style.d.ts +0 -1
  36. package/build/components/TableCells/CustomCells/RefundStatusCell/style.d.ts +0 -1
  37. package/build/components/TableCells/CustomCells/SalesChannelCell/style.d.ts +0 -1
  38. package/build/components/TableCells/CustomCells/SegmentsCell/style.d.ts +0 -1
  39. package/build/components/TableCells/CustomCells/StatusCell/style.d.ts +0 -1
  40. package/build/components/TableCells/CustomCells/TokenStatusCell/style.d.ts +0 -1
  41. package/build/components/TableCells/CustomCells/style.d.ts +0 -1
  42. package/build/components/TableReports/components/DownloadButton/style.d.ts +0 -1
  43. package/build/components/TableReports/style.d.ts +0 -1
  44. package/build/components/VirtualTables/components/style.d.ts +0 -1
  45. package/build/hooks/index.d.ts +1 -1
  46. package/build/hooks/index.js +1 -1
  47. package/build/hooks/useIsOnline.d.ts +14 -0
  48. package/build/hooks/useIsOnline.js +103 -0
  49. package/build/utils/string.js +2 -1
  50. package/package.json +4 -3
  51. package/build/hooks/useCheckInternetConnection.d.ts +0 -1
  52. package/build/hooks/useCheckInternetConnection.js +0 -17
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  type AnimatedSpinnerIconProps = {
4
3
  width?: string;
5
4
  height?: string;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  import { GetSourceAnimationFunction } from './type';
4
3
  export declare const ChipStyled: import("@emotion/styled").StyledComponent<import("react").RefAttributes<unknown> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
5
4
  variant?: import("./type").ChipVariant | undefined;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  export declare const AgreementImageWrapper: import("@emotion/styled").StyledComponent<{
4
3
  hidden?: boolean | undefined;
5
4
  color?: string | undefined;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  export declare const DialogWrapper: import("@emotion/styled").StyledComponent<{
4
3
  hidden?: boolean | undefined;
5
4
  color?: string | undefined;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  export declare const Wrapper: import("@emotion/styled").StyledComponent<{
4
3
  hidden?: boolean | undefined;
5
4
  color?: string | undefined;
@@ -3,7 +3,7 @@ import { useState, memo } from 'react';
3
3
  import Box from '@mui/material/Box';
4
4
  import { HoverContainer, IconWrapper, PlusBadgeWrapper } from './style';
5
5
  import Tooltip from '../Tooltip';
6
- import { startCase } from 'lodash';
6
+ import startCase from 'lodash/startCase';
7
7
  function IconWithHoverOverlays({ mainIcon, overlayIcons }) {
8
8
  const [isHovering, setIsHovering] = useState(false);
9
9
  const handleMouseEnter = () => {
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  declare const ImageWrapper: import("@emotion/styled").StyledComponent<{
4
3
  hidden?: boolean | undefined;
5
4
  color?: string | undefined;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  export declare const FOOTER_HEIGHT = 37;
4
3
  export declare const TITLE_BAR_HEIGHT = "32px";
5
4
  export declare const VIEWER_HEIGHT = 545;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  import type { SxProps, Theme } from '@mui/material/styles';
4
3
  export declare const CHIP_GAP = 3;
5
4
  export declare const DEFAULT_CHIP_MIN_WIDTH = 24;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  import { type Theme } from '@mui/material/styles';
4
3
  export declare const CHIP_GAP = 3;
5
4
  export declare const CenterIconWrapper: import("@emotion/styled").StyledComponent<{
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  export declare const StyledInput: import("@emotion/styled").StyledComponent<{
4
3
  width?: string | number | undefined;
5
4
  height?: string | number | undefined;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  export declare const StyledSourceCell: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
4
3
  export declare const StyledSourceImage: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
5
4
  export declare const PaymentSourcesContainer: import("@emotion/styled").StyledComponent<{
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  export declare const BalanceCellContainer: import("@emotion/styled").StyledComponent<{
4
3
  hidden?: boolean | undefined;
5
4
  color?: string | undefined;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  export declare const ErrorCodeLabel: import("@emotion/styled").StyledComponent<{
4
3
  hidden?: boolean | undefined;
5
4
  color?: string | undefined;
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { destinationStatusIcons } from './constant';
3
3
  import { StatusIcon, StatusIconWrapper, TextLabel } from './style';
4
4
  import Tooltip from '../../Tooltip';
5
- import { camelCase } from 'lodash';
5
+ import camelCase from 'lodash/camelCase';
6
6
  import { useTheme } from '@mui/material';
7
7
  import { t } from 'i18next';
8
8
  import StatusChipWithCopy from '../../StatusChipWithCopy';
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  export declare const StyledSourceCell: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
4
3
  export declare const StyledSourceImage: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
5
4
  export declare const PaymentSourcesContainer: import("@emotion/styled").StyledComponent<{
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  import { TableMode } from '../../../../types/index.js';
4
3
  export declare const ActionCellContainer: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
5
4
  tableMode?: TableMode | undefined;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  export declare const AgreementCellContainer: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
4
3
  export declare const StyledAgreementCardIcon: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
5
4
  export declare const CardContainer: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  export declare const StyledAppsCell: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
4
3
  export declare const AppsStatusContainer: import("@emotion/styled").StyledComponent<{
5
4
  hidden?: boolean | undefined;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  export declare const AuthIcon: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
4
3
  export declare const AuthCellContainer: import("@emotion/styled").StyledComponent<{
5
4
  hidden?: boolean | undefined;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  export declare const UnCapturedContainer: import("@emotion/styled").StyledComponent<{
4
3
  hidden?: boolean | undefined;
5
4
  color?: string | undefined;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  export declare const UnCapturedContainer: import("@emotion/styled").StyledComponent<{
4
3
  hidden?: boolean | undefined;
5
4
  color?: string | undefined;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  export declare const BalanceCellContainer: import("@emotion/styled").StyledComponent<{
4
3
  hidden?: boolean | undefined;
5
4
  color?: string | undefined;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  export declare const StyledSourceCell: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
4
3
  export declare const StyledSourceImage: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
5
4
  export declare const PaymentSourcesContainer: import("@emotion/styled").StyledComponent<{
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  export declare const DueDateCellContainer: import("@emotion/styled").StyledComponent<{
4
3
  hidden?: boolean | undefined;
5
4
  color?: string | undefined;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  export declare const UnCapturedContainer: import("@emotion/styled").StyledComponent<{
4
3
  hidden?: boolean | undefined;
5
4
  color?: string | undefined;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  export declare const DueDateCellContainer: import("@emotion/styled").StyledComponent<{
4
3
  hidden?: boolean | undefined;
5
4
  color?: string | undefined;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  export declare const Button: import("@emotion/styled").StyledComponent<{
4
3
  hidden?: boolean | undefined;
5
4
  color?: string | undefined;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  export declare const DueDateCellContainer: import("@emotion/styled").StyledComponent<{
4
3
  hidden?: boolean | undefined;
5
4
  color?: string | undefined;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  export declare const DueDateCellContainer: import("@emotion/styled").StyledComponent<{
4
3
  hidden?: boolean | undefined;
5
4
  color?: string | undefined;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  export declare const StyledDownloadFileImageWrapper: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme> & {
4
3
  isTextShown?: boolean | undefined;
5
4
  }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  export declare const UnCapturedContainer: import("@emotion/styled").StyledComponent<{
4
3
  hidden?: boolean | undefined;
5
4
  color?: string | undefined;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  export declare const ProductCellContainer: import("@emotion/styled").StyledComponent<{
4
3
  hidden?: boolean | undefined;
5
4
  color?: string | undefined;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  export declare const StyledSourceCell: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
4
3
  export declare const StyledSourceImage: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
5
4
  export declare const ReferenceSourcesContainer: import("@emotion/styled").StyledComponent<{
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  export declare const RefundChargeCellContainer: import("@emotion/styled").StyledComponent<{
4
3
  hidden?: boolean | undefined;
5
4
  color?: string | undefined;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  export declare const RefundCellContainer: import("@emotion/styled").StyledComponent<{
4
3
  hidden?: boolean | undefined;
5
4
  color?: string | undefined;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  export declare const StyledSourceCell: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
4
3
  export declare const StyledSourceImage: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, {}>;
5
4
  export declare const SalesChannelsContainer: import("@emotion/styled").StyledComponent<{
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  export declare const StyledSourceCell: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
4
3
  export declare const ReferenceSourcesContainer: import("@emotion/styled").StyledComponent<{
5
4
  hidden?: boolean | undefined;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  export declare const MultiRefundIcon: import("@emotion/styled").StyledComponent<{
4
3
  width?: string | number | undefined;
5
4
  height?: string | number | undefined;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  export declare const UnCapturedContainer: import("@emotion/styled").StyledComponent<{
4
3
  hidden?: boolean | undefined;
5
4
  color?: string | undefined;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  export declare const GeographyBox: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & {
4
3
  variant?: "Global" | "Regional" | "Local" | undefined;
5
4
  }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  export declare const Button: import("@emotion/styled").StyledComponent<{
4
3
  hidden?: boolean | undefined;
5
4
  color?: string | undefined;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  type ExportButtonProps = {
4
3
  notificationState?: {
5
4
  success: boolean;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- /// <reference types="react" />
3
2
  interface TableWrapperProps {
4
3
  showNoDataView?: boolean;
5
4
  }
@@ -3,7 +3,6 @@ export * from './useMouseState';
3
3
  export * from './useDelayToSetValue';
4
4
  export * from './useActionMenu';
5
5
  export * from './useBadgesCount';
6
- export * from './useCheckInternetConnection';
7
6
  export * from './useCheckUserLoggedIn';
8
7
  export * from './useIsParameterSelected';
9
8
  export * from './useStickyHeaderShadow';
@@ -15,3 +14,4 @@ export * from './useAppEventListener';
15
14
  export * from './useSelectedMerchantDetails';
16
15
  export * from './useToast';
17
16
  export * from './useScrolledTo';
17
+ export * from './useIsOnline';
@@ -3,7 +3,6 @@ export * from './useMouseState';
3
3
  export * from './useDelayToSetValue';
4
4
  export * from './useActionMenu';
5
5
  export * from './useBadgesCount';
6
- export * from './useCheckInternetConnection';
7
6
  export * from './useCheckUserLoggedIn';
8
7
  export * from './useIsParameterSelected';
9
8
  export * from './useStickyHeaderShadow';
@@ -15,3 +14,4 @@ export * from './useAppEventListener';
15
14
  export * from './useSelectedMerchantDetails';
16
15
  export * from './useToast';
17
16
  export * from './useScrolledTo';
17
+ export * from './useIsOnline';
@@ -0,0 +1,14 @@
1
+ interface UseIsOnlineOptions {
2
+ checkUrl?: string;
3
+ checkIntervalMs?: number;
4
+ debounceMs?: number;
5
+ timeoutMs?: number;
6
+ }
7
+ interface UseIsOnlineResult {
8
+ isOnline: boolean;
9
+ isOffline: boolean;
10
+ isChecking: boolean;
11
+ error: string | null;
12
+ }
13
+ export declare const useIsOnline: ({ checkUrl, checkIntervalMs, debounceMs, timeoutMs, }?: UseIsOnlineOptions) => UseIsOnlineResult;
14
+ export {};
@@ -0,0 +1,103 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { useCallback, useEffect, useRef, useState } from 'react';
11
+ export const useIsOnline = ({ checkUrl = '/status', // change to your own endpoint
12
+ checkIntervalMs = 30000, // periodic re-check
13
+ debounceMs = 800, // reduce flicker
14
+ timeoutMs = 5000, } = {}) => {
15
+ const isBrowser = typeof window !== 'undefined' && typeof navigator !== 'undefined';
16
+ const [isOnline, setIsOnline] = useState(isBrowser ? navigator.onLine : true);
17
+ const [isChecking, setIsChecking] = useState(false);
18
+ const [error, setError] = useState(null);
19
+ const debounceTimer = useRef(null);
20
+ const intervalId = useRef(null);
21
+ const applyStatusWithDebounce = useCallback((nextOnline) => {
22
+ if (debounceTimer.current !== null) {
23
+ window.clearTimeout(debounceTimer.current);
24
+ }
25
+ debounceTimer.current = window.setTimeout(() => {
26
+ setIsOnline(nextOnline);
27
+ debounceTimer.current = null;
28
+ }, debounceMs);
29
+ }, [debounceMs]);
30
+ useEffect(() => {
31
+ if (!isBrowser) {
32
+ return;
33
+ }
34
+ let abortController = null;
35
+ const checkConnectivity = () => __awaiter(void 0, void 0, void 0, function* () {
36
+ setIsChecking(true);
37
+ setError(null);
38
+ abortController === null || abortController === void 0 ? void 0 : abortController.abort();
39
+ abortController = new AbortController();
40
+ try {
41
+ const timeout = window.setTimeout(() => {
42
+ abortController === null || abortController === void 0 ? void 0 : abortController.abort();
43
+ }, timeoutMs);
44
+ const res = yield fetch(checkUrl, {
45
+ method: 'GET',
46
+ cache: 'no-store',
47
+ signal: abortController.signal,
48
+ });
49
+ window.clearTimeout(timeout);
50
+ const ok = res.ok;
51
+ applyStatusWithDebounce(ok);
52
+ if (!ok)
53
+ setError(`Health check failed with status ${res.status}`);
54
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
55
+ }
56
+ catch (_err) {
57
+ applyStatusWithDebounce(false);
58
+ setError('Unable to reach network');
59
+ }
60
+ finally {
61
+ setIsChecking(false);
62
+ }
63
+ });
64
+ const handleOnline = () => {
65
+ // Browser thinks we're online: verify with actual check
66
+ checkConnectivity();
67
+ };
68
+ const handleOffline = () => {
69
+ // Browser thinks we're offline: reflect that (debounced)
70
+ applyStatusWithDebounce(false);
71
+ };
72
+ window.addEventListener('online', handleOnline);
73
+ window.addEventListener('offline', handleOffline);
74
+ // Initial and periodic check
75
+ checkConnectivity();
76
+ intervalId.current = window.setInterval(checkConnectivity, checkIntervalMs);
77
+ return () => {
78
+ window.removeEventListener('online', handleOnline);
79
+ window.removeEventListener('offline', handleOffline);
80
+ if (debounceTimer.current !== null) {
81
+ window.clearTimeout(debounceTimer.current);
82
+ }
83
+ if (intervalId.current !== null) {
84
+ window.clearInterval(intervalId.current);
85
+ }
86
+ abortController === null || abortController === void 0 ? void 0 : abortController.abort();
87
+ };
88
+ }, [isBrowser, checkUrl, checkIntervalMs, debounceMs, timeoutMs, applyStatusWithDebounce]);
89
+ if (!isBrowser) {
90
+ return {
91
+ isOnline: false,
92
+ isOffline: false,
93
+ isChecking: false,
94
+ error: 'Online status is only available in a browser environment.',
95
+ };
96
+ }
97
+ return {
98
+ isOnline,
99
+ isOffline: !isOnline,
100
+ isChecking,
101
+ error,
102
+ };
103
+ };
@@ -1,4 +1,5 @@
1
- import { capitalize, startCase } from 'lodash';
1
+ import capitalize from 'lodash/capitalize';
2
+ import startCase from 'lodash/startCase';
2
3
  export const removePrefixFromString = (str, prefix) => {
3
4
  if (!prefix) {
4
5
  return str;
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.402",
5
- "testVersion": 0,
4
+ "version": "0.1.403-test.2",
5
+ "testVersion": 2,
6
6
  "type": "module",
7
7
  "main": "build/index.js",
8
8
  "module": "build/index.js",
@@ -127,6 +127,7 @@
127
127
  "typescript": "5.0.2",
128
128
  "typescript-eslint": "^8.18.2",
129
129
  "vite": "6.0.5",
130
+ "vite-plugin-dts": "^4.5.4",
130
131
  "vite-tsconfig-paths": "^4.2.0"
131
132
  },
132
133
  "peerDependencies": {
@@ -164,4 +165,4 @@
164
165
  "publishConfig": {
165
166
  "registry": "https://registry.npmjs.org/"
166
167
  }
167
- }
168
+ }
@@ -1 +0,0 @@
1
- export declare const useCheckInternetConnection: () => boolean;
@@ -1,17 +0,0 @@
1
- import { useState, useEffect } from 'react';
2
- export const useCheckInternetConnection = () => {
3
- const [isOnline, setIsOnline] = useState(navigator.onLine);
4
- useEffect(() => {
5
- const handleOnlineStatus = () => {
6
- setIsOnline(navigator.onLine);
7
- };
8
- window.addEventListener('online', handleOnlineStatus);
9
- window.addEventListener('offline', handleOnlineStatus);
10
- return () => {
11
- window.removeEventListener('online', handleOnlineStatus);
12
- window.removeEventListener('offline', handleOnlineStatus);
13
- };
14
- }, []);
15
- const isOffline = !isOnline;
16
- return isOffline;
17
- };