@paybutton/react 5.1.0 → 5.2.0

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.
@@ -60,9 +60,11 @@ export interface PaymentDialogProps extends ButtonProps {
60
60
  newTxs?: Transaction[];
61
61
  autoClose?: boolean | number | string;
62
62
  disableSound?: boolean;
63
- transactionText?: string;
64
63
  donationAddress?: string;
65
64
  donationRate?: number;
65
+ transactionText?: string;
66
+ convertedCurrencyObj?: CurrencyObject;
67
+ setConvertedCurrencyObj?: Function;
66
68
  }
67
- export declare const PaymentDialog: ({ to, amount, setAmount, opReturn, paymentId, disablePaymentId, currency, currencyObj, setCurrencyObj, cryptoAmount, price, successText, animation, randomSatoshis, hideToasts, onClose, onSuccess, onTransaction, goalAmount, disableEnforceFocus, editable, dialogOpen, setDialogOpen, container, wsBaseUrl, apiBaseUrl, hoverText, disableAltpayment, contributionOffset, autoClose, useAltpayment, setUseAltpayment, setTxsSocket, txsSocket, setAltpaymentSocket, altpaymentSocket, setCoins, coins, setCoinPair, coinPair, setLoadingPair, loadingPair, setAltpaymentShift, altpaymentShift, setLoadingShift, loadingShift, setAltpaymentError, altpaymentError, addressType, newTxs, setNewTxs, setAddressType, disableSound, transactionText, disabled, theme: themeProp, donationAddress, donationRate }: PaymentDialogProps) => React.ReactElement;
69
+ export declare const PaymentDialog: ({ to, amount, setAmount, opReturn, paymentId, disablePaymentId, currency, currencyObj, setCurrencyObj, cryptoAmount, price, successText, animation, randomSatoshis, hideToasts, onClose, onSuccess, onTransaction, goalAmount, disableEnforceFocus, editable, dialogOpen, setDialogOpen, container, wsBaseUrl, apiBaseUrl, hoverText, disableAltpayment, contributionOffset, autoClose, useAltpayment, setUseAltpayment, setTxsSocket, txsSocket, setAltpaymentSocket, altpaymentSocket, setCoins, coins, setCoinPair, coinPair, setLoadingPair, loadingPair, setAltpaymentShift, altpaymentShift, setLoadingShift, loadingShift, setAltpaymentError, altpaymentError, addressType, newTxs, setNewTxs, setAddressType, disableSound, transactionText, disabled, convertedCurrencyObj, setConvertedCurrencyObj, theme: themeProp, donationAddress, donationRate }: PaymentDialogProps) => React.ReactElement;
68
70
  export default PaymentDialog;
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { PaymentDialogProps } from './PaymentDialog';
3
3
  declare const _default: {
4
4
  title: string;
5
- component: ({ to, amount, setAmount, opReturn, paymentId, disablePaymentId, currency, currencyObj, setCurrencyObj, cryptoAmount, price, successText, animation, randomSatoshis, hideToasts, onClose, onSuccess, onTransaction, goalAmount, disableEnforceFocus, editable, dialogOpen, setDialogOpen, container, wsBaseUrl, apiBaseUrl, hoverText, disableAltpayment, contributionOffset, autoClose, useAltpayment, setUseAltpayment, setTxsSocket, txsSocket, setAltpaymentSocket, altpaymentSocket, setCoins, coins, setCoinPair, coinPair, setLoadingPair, loadingPair, setAltpaymentShift, altpaymentShift, setLoadingShift, loadingShift, setAltpaymentError, altpaymentError, addressType, newTxs, setNewTxs, setAddressType, disableSound, transactionText, disabled, theme: themeProp, donationAddress, donationRate }: PaymentDialogProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
5
+ component: ({ to, amount, setAmount, opReturn, paymentId, disablePaymentId, currency, currencyObj, setCurrencyObj, cryptoAmount, price, successText, animation, randomSatoshis, hideToasts, onClose, onSuccess, onTransaction, goalAmount, disableEnforceFocus, editable, dialogOpen, setDialogOpen, container, wsBaseUrl, apiBaseUrl, hoverText, disableAltpayment, contributionOffset, autoClose, useAltpayment, setUseAltpayment, setTxsSocket, txsSocket, setAltpaymentSocket, altpaymentSocket, setCoins, coins, setCoinPair, coinPair, setLoadingPair, loadingPair, setAltpaymentShift, altpaymentShift, setLoadingShift, loadingShift, setAltpaymentError, altpaymentError, addressType, newTxs, setNewTxs, setAddressType, disableSound, transactionText, disabled, convertedCurrencyObj, setConvertedCurrencyObj, theme: themeProp, donationAddress, donationRate }: PaymentDialogProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
6
6
  decorators: ((Story: import("@storybook/types").AnnotatedStoryFn<import("@storybook/react/dist/types-0fc72a6d").R, import("@storybook/types").Args>) => JSX.Element)[];
7
7
  argTypes: {
8
8
  onClick: {
@@ -14,11 +14,11 @@ export interface WidgetProps {
14
14
  disablePaymentId?: boolean;
15
15
  text?: string;
16
16
  ButtonComponent?: React.ComponentType;
17
- success: boolean;
17
+ success?: boolean;
18
18
  successText?: string;
19
19
  theme?: ThemeName | Theme;
20
20
  foot?: React.ReactNode;
21
- disabled: boolean;
21
+ disabled?: boolean;
22
22
  goalAmount?: number | string | null;
23
23
  currency?: Currency;
24
24
  animation?: animation;
@@ -28,7 +28,7 @@ export interface WidgetProps {
28
28
  price?: number | undefined;
29
29
  usdPrice?: number | undefined;
30
30
  editable?: boolean;
31
- setNewTxs: Function;
31
+ setNewTxs?: Function;
32
32
  newTxs?: Transaction[];
33
33
  wsBaseUrl?: string;
34
34
  apiBaseUrl?: string;
@@ -45,6 +45,8 @@ export interface WidgetProps {
45
45
  altpaymentSocket?: Socket;
46
46
  setAltpaymentSocket?: Function;
47
47
  shiftCompleted?: boolean;
48
+ donationAddress?: string;
49
+ donationRate?: number;
48
50
  setShiftCompleted?: Function;
49
51
  setCoins?: Function;
50
52
  coins?: AltpaymentCoin[];
@@ -60,8 +62,9 @@ export interface WidgetProps {
60
62
  setAddressType?: Function;
61
63
  newTxText?: string;
62
64
  transactionText?: string;
63
- donationAddress?: string;
64
- donationRate?: number;
65
+ convertedCurrencyObj?: CurrencyObject;
66
+ setConvertedCurrencyObj?: Function;
67
+ setPaymentId?: Function;
65
68
  }
66
69
  export declare const Widget: React.FunctionComponent<WidgetProps>;
67
70
  export default Widget;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { Currency, CurrencyObject, Transaction } from '../../util';
3
3
  import { WidgetProps } from './Widget';
4
- export interface WidgetContainerProps extends Omit<WidgetProps, 'success' | 'setCurrencyObject' | 'shiftCompleted' | 'setShiftCompleted'> {
4
+ export interface WidgetContainerProps extends Omit<WidgetProps, 'success' | 'setCurrencyObject' | 'shiftCompleted' | 'setShiftCompleted' | 'setPaymentId'> {
5
5
  active?: boolean;
6
6
  amount?: number;
7
7
  opReturn?: string;
@@ -30,6 +30,7 @@ export interface WidgetContainerProps extends Omit<WidgetProps, 'success' | 'set
30
30
  transactionText?: string;
31
31
  donationAddress?: string;
32
32
  donationRate?: number;
33
+ convertedCurrencyObj?: CurrencyObject;
33
34
  }
34
35
  export interface Output {
35
36
  index: number;
@@ -6,6 +6,7 @@ export declare const getBchFiatPrice: (currency: Currency, rootUrl?: string) =>
6
6
  export declare const getXecFiatPrice: (currency: Currency, rootUrl?: string) => Promise<PriceData>;
7
7
  export declare const getFiatPrice: (currency: string, to: string, apiBaseUrl?: string) => Promise<number | null>;
8
8
  export declare const getTransactionDetails: (txid: string, rootUrl?: string) => Promise<TransactionDetails>;
9
+ export declare const createPayment: (amount: string | number | undefined, address: string, rootUrl?: string) => Promise<string | undefined>;
9
10
  declare const _default: {
10
11
  getAddressDetails: (address: string, rootUrl?: string) => Promise<Transaction[]>;
11
12
  getTransactionDetails: (txid: string, rootUrl?: string) => Promise<TransactionDetails>;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Converts a hex color to RGB values
3
+ */
4
+ export declare const hexToRgb: (hex: string) => {
5
+ r: number;
6
+ g: number;
7
+ b: number;
8
+ } | null;
9
+ /**
10
+ * Normalizes any CSS color value to a hex code using the browser's canvas API
11
+ * Handles hex codes, named colors (e.g., "navy"), rgb(), hsl(), etc.
12
+ */
13
+ export declare const normalizeColorToHex: (color: string) => string | null;
14
+ /**
15
+ * Calculates the relative luminance of a color
16
+ * Based on WCAG 2.0 formula: https://www.w3.org/TR/WCAG20/#relativeluminancedef
17
+ * Returns a value between 0 (black) and 1 (white)
18
+ */
19
+ export declare const getLuminance: (color: string) => number;
20
+ /**
21
+ * Determines if dark mode should be used based on the color
22
+ * Dark mode is enabled when the color is light (luminance > 0.5)
23
+ * This threshold can be adjusted based on needs
24
+ */
25
+ export declare const darkMode: (color: string, threshold?: number) => boolean;
@@ -3,8 +3,12 @@ export declare const CRYPTO_CURRENCIES: string[];
3
3
  export declare const DECIMALS: {
4
4
  [key: string]: number;
5
5
  };
6
+ export declare const MAX_AMOUNT: {
7
+ [key: string]: number;
8
+ };
6
9
  export declare const AUTO_CLOSE_DEFAULT_MS = 2000;
7
10
  export declare const CURRENCY_PREFIXES_MAP: Record<typeof CRYPTO_CURRENCIES[number], string>;
11
+ export declare const CURRENCY_TYPES_MAP: Record<typeof CRYPTO_CURRENCIES[number], string>;
8
12
  export type ButtonSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | "extrasmall" | "small" | "medium" | "large" | "extralarge" | undefined;
9
13
  export declare const DEFAULT_DONATION_RATE = 2;
10
14
  export declare const DONATION_RATE_STORAGE_KEY = "paybutton_donation_rate";
@@ -1,6 +1,7 @@
1
1
  export * from './address';
2
2
  export * from './api-client';
3
3
  export * from './cashtab';
4
+ export * from './color';
4
5
  export * from './constants';
5
6
  export * from './format';
6
7
  export * from './opReturn';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paybutton/react",
3
- "version": "5.1.0",
3
+ "version": "5.2.0",
4
4
  "description": "The easiest way to accept eCash online",
5
5
  "author": "Blockchain Ventures Corp.",
6
6
  "license": "MIT",
@@ -88,7 +88,6 @@
88
88
  "dependencies": {
89
89
  "@emotion/react": "^11.14.0",
90
90
  "@emotion/styled": "^11.14.1",
91
- "@mui/lab": "^7.0.1-beta.18",
92
91
  "@mui/material": "^7.3.4",
93
92
  "@types/crypto-js": "^4.2.1",
94
93
  "@types/jest": "^29.5.11",
@@ -104,7 +103,7 @@
104
103
  "lodash": "4.17.21",
105
104
  "notistack": "3.0.0",
106
105
  "qrcode.react": "3",
107
- "react-jss": "10.10.0",
106
+ "react-number-format": "^5.4.4",
108
107
  "socket.io-client": "4.7.4",
109
108
  "ts-jest": "^29.4.5",
110
109
  "xecaddrjs": "^0.0.1"