@binopartner/pay-sdk 0.1.1 → 0.3.1
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/README.md +145 -2
- package/dist/core/api-base.d.ts +49 -0
- package/dist/core/api-base.js +196 -0
- package/dist/core/appearance.d.ts +17 -0
- package/dist/core/appearance.js +122 -0
- package/dist/core/auth.d.ts +32 -0
- package/dist/core/auth.js +233 -0
- package/dist/core/client.d.ts +71 -0
- package/dist/core/client.js +307 -0
- package/dist/core/clock.d.ts +7 -0
- package/dist/core/clock.js +17 -0
- package/dist/core/errors.d.ts +29 -0
- package/dist/core/errors.js +87 -0
- package/dist/core/events.d.ts +50 -0
- package/dist/core/events.js +1 -0
- package/dist/core/flows/deposit.d.ts +63 -0
- package/dist/core/flows/deposit.js +502 -0
- package/dist/core/flows/withdraw.d.ts +51 -0
- package/dist/core/flows/withdraw.js +413 -0
- package/dist/core/i18n/ar.d.ts +2 -0
- package/dist/core/i18n/ar.js +314 -0
- package/dist/core/i18n/base.d.ts +14 -0
- package/dist/core/i18n/base.js +86 -0
- package/dist/core/i18n/cs.d.ts +2 -0
- package/dist/core/i18n/cs.js +314 -0
- package/dist/core/i18n/de.d.ts +2 -0
- package/dist/core/i18n/de.js +314 -0
- package/dist/core/i18n/en-ui.d.ts +39 -0
- package/dist/core/i18n/en-ui.js +39 -0
- package/dist/core/i18n/en.d.ts +316 -0
- package/dist/core/i18n/en.js +280 -0
- package/dist/core/i18n/es.d.ts +2 -0
- package/dist/core/i18n/es.js +314 -0
- package/dist/core/i18n/fr.d.ts +2 -0
- package/dist/core/i18n/fr.js +314 -0
- package/dist/core/i18n/hi.d.ts +2 -0
- package/dist/core/i18n/hi.js +314 -0
- package/dist/core/i18n/index.d.ts +16 -0
- package/dist/core/i18n/index.js +39 -0
- package/dist/core/i18n/it.d.ts +2 -0
- package/dist/core/i18n/it.js +314 -0
- package/dist/core/i18n/ru.d.ts +2 -0
- package/dist/core/i18n/ru.js +314 -0
- package/dist/core/i18n/tr.d.ts +2 -0
- package/dist/core/i18n/tr.js +314 -0
- package/dist/core/i18n/ua.d.ts +2 -0
- package/dist/core/i18n/ua.js +314 -0
- package/dist/core/index.d.ts +37 -0
- package/dist/core/index.js +19 -0
- package/dist/core/intent.d.ts +13 -0
- package/dist/core/intent.js +45 -0
- package/dist/core/money.d.ts +22 -0
- package/dist/core/money.js +178 -0
- package/dist/core/poll.d.ts +16 -0
- package/dist/core/poll.js +100 -0
- package/dist/core/requisites-frame.d.ts +32 -0
- package/dist/core/requisites-frame.js +202 -0
- package/dist/core/rules/address.d.ts +3 -0
- package/dist/core/rules/address.js +29 -0
- package/dist/core/rules/limits.d.ts +17 -0
- package/dist/core/rules/limits.js +19 -0
- package/dist/core/rules/paying.d.ts +10 -0
- package/dist/core/rules/paying.js +32 -0
- package/dist/core/rules/receipt.d.ts +6 -0
- package/dist/core/rules/receipt.js +40 -0
- package/dist/core/rules/requisites.d.ts +42 -0
- package/dist/core/rules/requisites.js +68 -0
- package/dist/core/rules/slippage.d.ts +1 -0
- package/dist/core/rules/slippage.js +7 -0
- package/dist/core/store.d.ts +15 -0
- package/dist/core/store.js +53 -0
- package/dist/core/types.d.ts +244 -0
- package/dist/core/types.js +1 -0
- package/dist/core/wire.d.ts +178 -0
- package/dist/core/wire.js +602 -0
- package/dist/elements/Root.d.ts +37 -0
- package/dist/elements/Root.js +143 -0
- package/dist/elements/chains.d.ts +1 -0
- package/dist/elements/chains.js +1 -0
- package/dist/elements/components/Qr.d.ts +17 -0
- package/dist/elements/components/Qr.js +28 -0
- package/dist/elements/components/basic.d.ts +42 -0
- package/dist/elements/components/basic.js +129 -0
- package/dist/elements/components/deposit.d.ts +61 -0
- package/dist/elements/components/deposit.js +272 -0
- package/dist/elements/components/inputs.d.ts +24 -0
- package/dist/elements/components/inputs.js +92 -0
- package/dist/elements/components/pickers.d.ts +32 -0
- package/dist/elements/components/pickers.js +267 -0
- package/dist/elements/components/status.d.ts +25 -0
- package/dist/elements/components/status.js +221 -0
- package/dist/elements/context.d.ts +47 -0
- package/dist/elements/context.js +33 -0
- package/dist/elements/hooks/deposit.d.ts +52 -0
- package/dist/elements/hooks/deposit.js +215 -0
- package/dist/elements/hooks/root.d.ts +70 -0
- package/dist/elements/hooks/root.js +125 -0
- package/dist/elements/hooks/withdraw.d.ts +30 -0
- package/dist/elements/hooks/withdraw.js +145 -0
- package/dist/elements/index.d.ts +28 -0
- package/dist/elements/index.js +14 -0
- package/dist/elements/part.d.ts +2 -0
- package/dist/elements/part.js +1 -0
- package/dist/elements/presets/DepositForm.d.ts +32 -0
- package/dist/elements/presets/DepositForm.js +97 -0
- package/dist/elements/presets/WithdrawForm.d.ts +25 -0
- package/dist/elements/presets/WithdrawForm.js +44 -0
- package/dist/elements/presets/focus.d.ts +2 -0
- package/dist/elements/presets/focus.js +26 -0
- package/dist/elements.css +2777 -0
- package/dist/fonts.css +31 -0
- package/dist/frame.d.ts +1 -0
- package/dist/frame.js +37 -6
- package/dist/types.d.ts +1 -0
- package/dist/ui/chains.d.ts +3 -0
- package/dist/ui/chains.js +42 -0
- package/dist/ui/context.d.ts +51 -0
- package/dist/ui/context.js +63 -0
- package/dist/ui/crypto.d.ts +67 -0
- package/dist/ui/crypto.js +68 -0
- package/dist/ui/entry.d.ts +25 -0
- package/dist/ui/entry.js +26 -0
- package/dist/ui/fiat.d.ts +94 -0
- package/dist/ui/fiat.js +149 -0
- package/dist/ui/fields.d.ts +76 -0
- package/dist/ui/fields.js +71 -0
- package/dist/ui/fonts.d.ts +4 -0
- package/dist/ui/fonts.js +31 -0
- package/dist/ui/icons.d.ts +39 -0
- package/dist/ui/icons.js +116 -0
- package/dist/ui/index.d.ts +31 -0
- package/dist/ui/index.js +17 -0
- package/dist/ui/layout.d.ts +36 -0
- package/dist/ui/layout.js +44 -0
- package/dist/ui/logos.d.ts +14 -0
- package/dist/ui/logos.js +61 -0
- package/dist/ui/part.d.ts +32 -0
- package/dist/ui/part.js +33 -0
- package/dist/ui/pickers.d.ts +71 -0
- package/dist/ui/pickers.js +167 -0
- package/dist/ui/qr-encode.d.ts +30 -0
- package/dist/ui/qr-encode.js +340 -0
- package/dist/ui/summary.d.ts +31 -0
- package/dist/ui/summary.js +36 -0
- package/dist/ui/types.d.ts +67 -0
- package/dist/ui/types.js +1 -0
- package/dist/ui/urls.d.ts +4 -0
- package/dist/ui/urls.js +41 -0
- package/dist/ui/withdraw.d.ts +38 -0
- package/dist/ui/withdraw.js +30 -0
- package/dist/ui.css +2699 -0
- package/dist/widget-url.d.ts +1 -0
- package/dist/widget-url.js +16 -0
- package/package.json +46 -5
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type ButtonHTMLAttributes, type HTMLAttributes, type ReactNode } from "react";
|
|
2
|
+
import { type PartStyleProps } from "./part.js";
|
|
3
|
+
type DivProps = Omit<HTMLAttributes<HTMLDivElement>, "className" | "style" | "children" | "title"> & PartStyleProps;
|
|
4
|
+
export declare const CloseButton: import("react").ForwardRefExoticComponent<Omit<ButtonHTMLAttributes<HTMLButtonElement>, "style" | "className"> & PartStyleProps & {
|
|
5
|
+
label?: string;
|
|
6
|
+
} & import("react").RefAttributes<HTMLButtonElement>>;
|
|
7
|
+
export declare const BackButton: import("react").ForwardRefExoticComponent<Omit<ButtonHTMLAttributes<HTMLButtonElement>, "style" | "className"> & PartStyleProps & {
|
|
8
|
+
label?: string;
|
|
9
|
+
} & import("react").RefAttributes<HTMLButtonElement>>;
|
|
10
|
+
export interface PayHeaderProps extends DivProps {
|
|
11
|
+
title?: ReactNode;
|
|
12
|
+
subtitle?: ReactNode;
|
|
13
|
+
back?: ReactNode;
|
|
14
|
+
close?: ReactNode;
|
|
15
|
+
onBack?: () => void;
|
|
16
|
+
onClose?: () => void;
|
|
17
|
+
logo?: ReactNode;
|
|
18
|
+
variant?: "deposit" | "withdraw";
|
|
19
|
+
}
|
|
20
|
+
export declare const PayHeader: import("react").ForwardRefExoticComponent<PayHeaderProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
21
|
+
export interface PayCardProps extends PayHeaderProps {
|
|
22
|
+
embedded?: boolean;
|
|
23
|
+
header?: ReactNode;
|
|
24
|
+
children?: ReactNode;
|
|
25
|
+
}
|
|
26
|
+
export declare const PayCard: import("react").ForwardRefExoticComponent<PayCardProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
27
|
+
export declare const BrandLogo: import("react").ForwardRefExoticComponent<PartStyleProps & {
|
|
28
|
+
src: string;
|
|
29
|
+
alt?: string;
|
|
30
|
+
} & import("react").RefAttributes<HTMLImageElement>>;
|
|
31
|
+
export declare const PayBody: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLDivElement>, "style" | "title" | "children" | "className"> & PartStyleProps & {
|
|
32
|
+
children?: ReactNode;
|
|
33
|
+
variant?: "deposit" | "withdraw" | "address" | "paying";
|
|
34
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
35
|
+
export declare const Divider: ({ className, style, unstyled }: PartStyleProps) => import("react").JSX.Element;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef } from "react";
|
|
4
|
+
import { useClasses } from "./context.js";
|
|
5
|
+
import { BackIcon, CloseIcon } from "./icons.js";
|
|
6
|
+
import { partProps } from "./part.js";
|
|
7
|
+
export const CloseButton = forwardRef(function CloseButton({ label, type = "button", className, style, unstyled, children, ...rest }, ref) {
|
|
8
|
+
const { ui, off } = useClasses(unstyled);
|
|
9
|
+
return (_jsx("button", { type: type, "aria-label": label ?? ui.t("common.close"), ...rest, ref: ref, ...partProps("close", { className, style, unstyled }, off), children: children ?? _jsx(CloseIcon, {}) }));
|
|
10
|
+
});
|
|
11
|
+
export const BackButton = forwardRef(function BackButton({ label, type = "button", className, style, unstyled, children, ...rest }, ref) {
|
|
12
|
+
const { ui, off } = useClasses(unstyled);
|
|
13
|
+
return (_jsx("button", { type: type, "aria-label": label ?? ui.t("common.back"), ...rest, ref: ref, ...partProps("back", { className, style, unstyled }, off), children: children ?? _jsx(BackIcon, {}) }));
|
|
14
|
+
});
|
|
15
|
+
export const PayHeader = forwardRef(function PayHeader({ title, subtitle, back, close, onBack, onClose, logo, variant = "deposit", className, style, unstyled, ...rest }, ref) {
|
|
16
|
+
const { c, off } = useClasses(unstyled);
|
|
17
|
+
const backNode = back ?? (onBack ? _jsx(BackButton, { onClick: onBack, unstyled: unstyled }) : null);
|
|
18
|
+
const closeNode = close ?? (onClose ? _jsx(CloseButton, { onClick: onClose, unstyled: unstyled }) : null);
|
|
19
|
+
return (_jsxs("div", { ...rest, ref: ref, ...partProps("header", { className, style, unstyled }, off), "data-variant": variant, children: [closeNode, _jsxs("div", { className: c("header-left"), children: [backNode, _jsxs("div", { className: c("header-text"), children: [title !== undefined && title !== null && title !== "" && (_jsx("h2", { className: c("header-title"), "data-binodex-pay": "title", children: title })), subtitle !== undefined && subtitle !== null && subtitle !== "" && (_jsx("p", { className: c("header-subtitle"), "data-binodex-pay": "subtitle", children: subtitle }))] })] }), logo && _jsx("div", { className: c("header-right"), children: logo })] }));
|
|
20
|
+
});
|
|
21
|
+
export const PayCard = forwardRef(function PayCard({ title, subtitle, back, close, onBack, onClose, logo, variant = "deposit", embedded = false, header, children, className, style, unstyled, ...rest }, ref) {
|
|
22
|
+
const { c, off } = useClasses(unstyled);
|
|
23
|
+
const showHeader = header !== undefined ||
|
|
24
|
+
title !== undefined ||
|
|
25
|
+
subtitle !== undefined ||
|
|
26
|
+
back !== undefined ||
|
|
27
|
+
close !== undefined ||
|
|
28
|
+
!!onBack ||
|
|
29
|
+
!!onClose;
|
|
30
|
+
return (_jsx("div", { ...rest, ref: ref, ...partProps("card", { className, style, unstyled }, off), "data-embedded": embedded ? "" : undefined, "data-variant": variant, children: _jsxs("div", { className: c("card-scroll"), children: [header ??
|
|
31
|
+
(showHeader && (_jsx(PayHeader, { title: title, subtitle: subtitle, back: back, close: close, onBack: onBack, onClose: onClose, logo: logo, variant: variant, unstyled: unstyled }))), children] }) }));
|
|
32
|
+
});
|
|
33
|
+
export const BrandLogo = forwardRef(function BrandLogo({ src, alt = "", className, style, unstyled }, ref) {
|
|
34
|
+
const { off } = useClasses(unstyled);
|
|
35
|
+
return _jsx("img", { ref: ref, src: src, alt: alt, referrerPolicy: "no-referrer", ...partProps("brand", { className, style, unstyled }, off) });
|
|
36
|
+
});
|
|
37
|
+
export const PayBody = forwardRef(function PayBody({ variant = "deposit", className, style, unstyled, children, ...rest }, ref) {
|
|
38
|
+
const { off } = useClasses(unstyled);
|
|
39
|
+
return (_jsx("div", { ...rest, ref: ref, ...partProps("body", { className, style, unstyled }, off), "data-variant": variant, children: children }));
|
|
40
|
+
});
|
|
41
|
+
export const Divider = ({ className, style, unstyled }) => {
|
|
42
|
+
const { off } = useClasses(unstyled);
|
|
43
|
+
return _jsx("div", { "aria-hidden": "true", ...partProps("divider", { className, style, unstyled }, off) });
|
|
44
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface MethodLogo {
|
|
2
|
+
imgPath: string | null;
|
|
3
|
+
initial: string;
|
|
4
|
+
background: string;
|
|
5
|
+
color: string;
|
|
6
|
+
badge?: "qr" | "pdf";
|
|
7
|
+
}
|
|
8
|
+
export declare const METHOD_LOGOS: Record<string, MethodLogo>;
|
|
9
|
+
export declare const FALLBACK_LOGO: MethodLogo;
|
|
10
|
+
export declare const getMethodLogo: (methodId: string) => MethodLogo;
|
|
11
|
+
export declare const assetUrl: (base: string, path: string) => string;
|
|
12
|
+
export declare const COUNTRY_CODES: readonly ["AD", "AE", "AF", "AI", "AL", "AM", "AO", "AR", "AT", "AU", "AW", "AZ", "BA", "BB", "BD", "BE", "BG", "BH", "BM", "BN", "BO", "BR", "BS", "BT", "BY", "BZ", "CA", "CD", "CH", "CI", "CK", "CL", "CN", "CO", "CR", "CU", "CV", "CY", "CZ", "DE", "DK", "DM", "DO", "DZ", "EC", "EE", "EG", "ES", "ET", "FI", "FO", "FR", "GA", "GB", "GE", "GG", "GH", "GI", "GL", "GP", "GR", "GT", "GU", "GY", "HK", "HN", "HR", "HU", "ID", "IE", "IL", "IM", "IN", "IQ", "IR", "IS", "IT", "JE", "JM", "JO", "JP", "KE", "KG", "KH", "KR", "KW", "KY", "KZ", "LA", "LB", "LC", "LI", "LK", "LT", "LU", "LV", "LY", "MA", "MC", "MD", "ME", "MG", "MK", "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", "NC", "NG", "NI", "NL", "NO", "NP", "NZ", "OM", "PA", "PE", "PF", "PH", "PK", "PL", "PM", "PR", "PS", "PT", "PW", "PY", "QA", "RE", "RO", "RS", "RU", "RW", "SA", "SC", "SD", "SE", "SG", "SI", "SK", "SL", "SM", "SN", "SR", "ST", "SV", "SX", "SY", "SZ", "TG", "TH", "TJ", "TM", "TN", "TR", "TT", "TW", "TZ", "UA", "US", "UY", "UZ", "VC", "VE", "VI", "VN", "XK", "YT", "ZA", "ZM", "ZW"];
|
|
13
|
+
export declare const countryFlagPath: (code: string) => string;
|
|
14
|
+
export declare const isSupportedCountry: (code: string) => boolean;
|
package/dist/ui/logos.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const logo = (imgPath, initial, background, color = "#FFFFFF", badge) => (badge ? { imgPath, initial, background, color, badge } : { imgPath, initial, background, color });
|
|
2
|
+
export const METHOD_LOGOS = {
|
|
3
|
+
tinkoff: logo("/img/banks/tinkoff.webp", "Т", "#FFDD2D", "#000000"),
|
|
4
|
+
sberbank: logo("/img/banks/sberbank.webp", "С", "#21A038"),
|
|
5
|
+
sber_qr: logo("/img/banks/sberbank.webp", "С", "#21A038", "#FFFFFF", "qr"),
|
|
6
|
+
alfa: logo("/img/banks/alfa.webp", "А", "#EF3124"),
|
|
7
|
+
otp: logo("/img/banks/otp.webp", "О", "#52AE30"),
|
|
8
|
+
psb: logo("/img/banks/psb.webp", "П", "#F58220"),
|
|
9
|
+
gazprom: logo("/img/banks/gazprom.webp", "Г", "#0079C1"),
|
|
10
|
+
yoomoney: logo("/img/banks/yoomoney.webp", "Ю", "#8B3FFD"),
|
|
11
|
+
vtb_qr: logo("/img/banks/vtb.webp", "В", "#009FDF", "#FFFFFF", "qr"),
|
|
12
|
+
vtb_transgran: logo("/img/banks/vtb.webp", "В", "#009FDF"),
|
|
13
|
+
sbp: logo("/img/banks/sbp.webp", "С", "#00A0E3", "#FFFFFF", "pdf"),
|
|
14
|
+
nspk: logo("/img/banks/sbp.webp", "С", "#00A0E3", "#FFFFFF", "qr"),
|
|
15
|
+
c2c: logo("/img/banks/cards.png", "#", "#2E3A59", "#FFFFFF", "pdf"),
|
|
16
|
+
trans_mezhbank: logo("/img/banks/trans_mezhbank.webp", "М", "#3A4A6B"),
|
|
17
|
+
trans_sbp: logo("/img/banks/trans_sbp.webp", "С", "#00A0E3"),
|
|
18
|
+
p2p: logo("/img/banks/cards.png", "₴", "#2E3A59"),
|
|
19
|
+
qr_mono: logo("/img/banks/monobank.webp", "M", "#000000", "#FFFFFF", "qr"),
|
|
20
|
+
qr_privat: logo("/img/banks/privatbank.webp", "П", "#61A60E", "#FFFFFF", "qr"),
|
|
21
|
+
quasi: logo("/img/banks/cards.png", "#", "#2E3A59"),
|
|
22
|
+
alfa_qr: logo("/img/banks/alfa.webp", "А", "#EF3124", "#FFFFFF", "qr"),
|
|
23
|
+
ozon_qr: logo("/img/banks/ozon.webp", "O", "#005BFF", "#FFFFFF", "qr"),
|
|
24
|
+
any_qr: logo("/img/badges/qr.svg", "QR", "#2E3A59", "#FFFFFF", "pdf"),
|
|
25
|
+
trans_tj: logo("/img/banks/cards.png", "ТГ", "#3A4A6B"),
|
|
26
|
+
alfa_transgran: logo("/img/banks/alfa.webp", "А", "#EF3124", "#FFFFFF", "pdf"),
|
|
27
|
+
m2_c2c_kz: logo("/img/banks/cards.png", "₸", "#2E3A59"),
|
|
28
|
+
upi: logo("/img/deposit-bank/banks/in/imps.svg", "₹", "#FFFFFF", "#097939"),
|
|
29
|
+
};
|
|
30
|
+
export const FALLBACK_LOGO = logo(null, "?", "#475271");
|
|
31
|
+
export const getMethodLogo = (methodId) => METHOD_LOGOS[methodId] ?? FALLBACK_LOGO;
|
|
32
|
+
export const assetUrl = (base, path) => `${base}${path}`;
|
|
33
|
+
export const COUNTRY_CODES = [
|
|
34
|
+
"AD", "AE", "AF", "AI", "AL", "AM", "AO", "AR", "AT", "AU", "AW", "AZ", "BA",
|
|
35
|
+
"BB", "BD", "BE", "BG", "BH", "BM", "BN", "BO", "BR", "BS", "BT", "BY", "BZ",
|
|
36
|
+
"CA", "CD", "CH", "CI", "CK", "CL", "CN", "CO", "CR", "CU", "CV", "CY", "CZ",
|
|
37
|
+
"DE", "DK", "DM", "DO", "DZ", "EC", "EE", "EG", "ES", "ET", "FI", "FO", "FR",
|
|
38
|
+
"GA", "GB", "GE", "GG", "GH", "GI", "GL", "GP", "GR", "GT", "GU", "GY", "HK",
|
|
39
|
+
"HN", "HR", "HU", "ID", "IE", "IL", "IM", "IN", "IQ", "IR", "IS", "IT", "JE",
|
|
40
|
+
"JM", "JO", "JP", "KE", "KG", "KH", "KR", "KW", "KY", "KZ", "LA", "LB", "LC",
|
|
41
|
+
"LI", "LK", "LT", "LU", "LV", "LY", "MA", "MC", "MD", "ME", "MG", "MK", "ML",
|
|
42
|
+
"MM", "MN", "MO", "MP", "MQ", "MR", "MT", "MU", "MV", "MW", "MX", "MY", "MZ",
|
|
43
|
+
"NA", "NC", "NG", "NI", "NL", "NO", "NP", "NZ", "OM", "PA", "PE", "PF", "PH",
|
|
44
|
+
"PK", "PL", "PM", "PR", "PS", "PT", "PW", "PY", "QA", "RE", "RO", "RS", "RU",
|
|
45
|
+
"RW", "SA", "SC", "SD", "SE", "SG", "SI", "SK", "SL", "SM", "SN", "SR", "ST",
|
|
46
|
+
"SV", "SX", "SY", "SZ", "TG", "TH", "TJ", "TM", "TN", "TR", "TT", "TW", "TZ",
|
|
47
|
+
"UA", "US", "UY", "UZ", "VC", "VE", "VI", "VN", "XK", "YT", "ZA", "ZM", "ZW",
|
|
48
|
+
];
|
|
49
|
+
const LEGACY_FLAG_FILES = {
|
|
50
|
+
DE: "de",
|
|
51
|
+
FR: "fr",
|
|
52
|
+
IN: "hi",
|
|
53
|
+
RU: "ru",
|
|
54
|
+
SA: "sa",
|
|
55
|
+
ES: "sp",
|
|
56
|
+
TR: "tr",
|
|
57
|
+
UA: "ua",
|
|
58
|
+
US: "us",
|
|
59
|
+
};
|
|
60
|
+
export const countryFlagPath = (code) => `/img/trade/flags/${LEGACY_FLAG_FILES[code] ?? code.toLowerCase()}.svg`;
|
|
61
|
+
export const isSupportedCountry = (code) => COUNTRY_CODES.includes(code.toUpperCase());
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { CSSProperties, Ref } from "react";
|
|
2
|
+
export interface PartStyleProps {
|
|
3
|
+
className?: string;
|
|
4
|
+
style?: CSSProperties;
|
|
5
|
+
unstyled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export type DataAttributes = {
|
|
8
|
+
[key: `data-${string}`]: string | undefined;
|
|
9
|
+
};
|
|
10
|
+
export declare const SENSITIVE_PROPS: {
|
|
11
|
+
readonly "data-hj-suppress": "";
|
|
12
|
+
readonly "data-sentry-mask": "";
|
|
13
|
+
readonly "data-private": "";
|
|
14
|
+
};
|
|
15
|
+
export declare const SENSITIVE_CLASS = "ym-hide-content";
|
|
16
|
+
export declare const cx: (...names: (string | false | null | undefined)[]) => string | undefined;
|
|
17
|
+
export declare const partProps: (part: string, props: PartStyleProps, rootUnstyled: boolean, options?: {
|
|
18
|
+
sensitive?: boolean;
|
|
19
|
+
}) => {
|
|
20
|
+
"data-binodex-pay": string;
|
|
21
|
+
className: string | undefined;
|
|
22
|
+
style: CSSProperties | undefined;
|
|
23
|
+
};
|
|
24
|
+
export declare const viewProps: (part: string, base: string, props: PartStyleProps, rootUnstyled: boolean, options?: {
|
|
25
|
+
sensitive?: boolean;
|
|
26
|
+
}) => {
|
|
27
|
+
"data-binodex-pay": string;
|
|
28
|
+
className: string | undefined;
|
|
29
|
+
style: CSSProperties | undefined;
|
|
30
|
+
};
|
|
31
|
+
export declare const classes: (unstyled: boolean) => (...names: (string | false | null | undefined)[]) => string | undefined;
|
|
32
|
+
export declare const assignRef: <T>(ref: Ref<T> | undefined, value: T | null) => void;
|
package/dist/ui/part.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export const SENSITIVE_PROPS = {
|
|
2
|
+
"data-hj-suppress": "",
|
|
3
|
+
"data-sentry-mask": "",
|
|
4
|
+
"data-private": "",
|
|
5
|
+
};
|
|
6
|
+
export const SENSITIVE_CLASS = "ym-hide-content";
|
|
7
|
+
export const cx = (...names) => {
|
|
8
|
+
const value = names.filter(Boolean).join(" ");
|
|
9
|
+
return value || undefined;
|
|
10
|
+
};
|
|
11
|
+
export const partProps = (part, props, rootUnstyled, options = {}) => {
|
|
12
|
+
const unstyled = props.unstyled ?? rootUnstyled;
|
|
13
|
+
return {
|
|
14
|
+
"data-binodex-pay": part,
|
|
15
|
+
className: cx(!unstyled && `bp-${part}`, options.sensitive && SENSITIVE_CLASS, props.className),
|
|
16
|
+
style: props.style,
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export const viewProps = (part, base, props, rootUnstyled, options = {}) => {
|
|
20
|
+
const unstyled = props.unstyled ?? rootUnstyled;
|
|
21
|
+
return {
|
|
22
|
+
"data-binodex-pay": part,
|
|
23
|
+
className: cx(!unstyled && `bp-${base}`, !unstyled && part !== base && `bp-${part}`, options.sensitive && SENSITIVE_CLASS, props.className),
|
|
24
|
+
style: props.style,
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export const classes = (unstyled) => (...names) => unstyled ? undefined : cx(...names.map((name) => (name ? `bp-${name}` : name)));
|
|
28
|
+
export const assignRef = (ref, value) => {
|
|
29
|
+
if (typeof ref === "function")
|
|
30
|
+
ref(value);
|
|
31
|
+
else if (ref)
|
|
32
|
+
ref.current = value;
|
|
33
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReactNode } from "react";
|
|
2
|
+
import { type PartStyleProps } from "./part.js";
|
|
3
|
+
import type { MethodOption, RouteOption } from "./types.js";
|
|
4
|
+
type DivProps = Omit<HTMLAttributes<HTMLDivElement>, "className" | "style" | "children" | "onChange" | "onSelect"> & PartStyleProps;
|
|
5
|
+
export interface FieldProps extends DivProps {
|
|
6
|
+
label?: ReactNode;
|
|
7
|
+
htmlFor?: string;
|
|
8
|
+
children?: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
export declare const Field: import("react").ForwardRefExoticComponent<FieldProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
11
|
+
export declare const MethodsNotice: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLDivElement>, "style" | "children" | "className" | "onChange" | "onSelect"> & PartStyleProps & {
|
|
12
|
+
variant: "loading" | "empty";
|
|
13
|
+
children?: ReactNode;
|
|
14
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
15
|
+
export interface MethodGridProps extends DivProps {
|
|
16
|
+
methods: MethodOption[];
|
|
17
|
+
selectedId: string | null;
|
|
18
|
+
onSelect: (id: string) => void;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
badgeTitles?: {
|
|
21
|
+
qr?: string;
|
|
22
|
+
pdf?: string;
|
|
23
|
+
};
|
|
24
|
+
ariaLabel?: string;
|
|
25
|
+
}
|
|
26
|
+
export declare const MethodGrid: import("react").ForwardRefExoticComponent<MethodGridProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
27
|
+
export declare const RouteGrid: import("react").ForwardRefExoticComponent<Omit<HTMLAttributes<HTMLDivElement>, "style" | "children" | "className" | "onChange" | "onSelect"> & PartStyleProps & {
|
|
28
|
+
children?: ReactNode;
|
|
29
|
+
} & import("react").RefAttributes<HTMLDivElement>>;
|
|
30
|
+
export interface RouteColumnProps extends DivProps {
|
|
31
|
+
label: ReactNode;
|
|
32
|
+
labelRight?: ReactNode;
|
|
33
|
+
value: RouteOption | null;
|
|
34
|
+
options: RouteOption[];
|
|
35
|
+
onSelect: (value: string) => void;
|
|
36
|
+
part?: string;
|
|
37
|
+
optionPart?: string;
|
|
38
|
+
listLabel?: string;
|
|
39
|
+
}
|
|
40
|
+
export declare const RouteColumn: import("react").ForwardRefExoticComponent<RouteColumnProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
41
|
+
export interface RoutePickerProps extends DivProps {
|
|
42
|
+
coins: RouteOption[];
|
|
43
|
+
networks: RouteOption[];
|
|
44
|
+
value: {
|
|
45
|
+
currency: string | null;
|
|
46
|
+
network: string | null;
|
|
47
|
+
};
|
|
48
|
+
onChange: (next: {
|
|
49
|
+
currency: string | null;
|
|
50
|
+
network: string | null;
|
|
51
|
+
}, changed: "currency" | "network") => void;
|
|
52
|
+
minLabel?: ReactNode;
|
|
53
|
+
labels?: {
|
|
54
|
+
token?: ReactNode;
|
|
55
|
+
network?: ReactNode;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export declare const RoutePicker: import("react").ForwardRefExoticComponent<RoutePickerProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
59
|
+
export interface CountrySelectProps extends DivProps {
|
|
60
|
+
value: string;
|
|
61
|
+
onChange: (code: string) => void;
|
|
62
|
+
countries?: readonly string[];
|
|
63
|
+
pinned?: readonly string[];
|
|
64
|
+
labels?: {
|
|
65
|
+
label?: ReactNode;
|
|
66
|
+
search?: string;
|
|
67
|
+
empty?: ReactNode;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
export declare const CountrySelect: import("react").ForwardRefExoticComponent<CountrySelectProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
71
|
+
export {};
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, forwardRef, useCallback, useContext, useEffect, useId, useMemo, useRef, useState, } from "react";
|
|
4
|
+
import { useClasses } from "./context.js";
|
|
5
|
+
import { BadgeIcon, CheckIcon, ChevronIcon, RowCheckIcon } from "./icons.js";
|
|
6
|
+
import { COUNTRY_CODES, countryFlagPath, getMethodLogo } from "./logos.js";
|
|
7
|
+
import { partProps, viewProps } from "./part.js";
|
|
8
|
+
const useClickAway = (open, close, ...refs) => {
|
|
9
|
+
const latest = useRef(close);
|
|
10
|
+
latest.current = close;
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (!open || typeof document === "undefined")
|
|
13
|
+
return;
|
|
14
|
+
const onDown = (event) => {
|
|
15
|
+
const target = event.target;
|
|
16
|
+
if (target && refs.some((ref) => ref.current?.contains(target)))
|
|
17
|
+
return;
|
|
18
|
+
latest.current();
|
|
19
|
+
};
|
|
20
|
+
const onKey = (event) => {
|
|
21
|
+
if (event.key === "Escape")
|
|
22
|
+
latest.current();
|
|
23
|
+
};
|
|
24
|
+
document.addEventListener("mousedown", onDown);
|
|
25
|
+
document.addEventListener("keydown", onKey);
|
|
26
|
+
return () => {
|
|
27
|
+
document.removeEventListener("mousedown", onDown);
|
|
28
|
+
document.removeEventListener("keydown", onKey);
|
|
29
|
+
};
|
|
30
|
+
}, [open]);
|
|
31
|
+
};
|
|
32
|
+
export const Field = forwardRef(function Field({ label, htmlFor, children, className, style, unstyled, ...rest }, ref) {
|
|
33
|
+
const { c, off } = useClasses(unstyled);
|
|
34
|
+
return (_jsxs("div", { ...rest, ref: ref, ...partProps("field", { className, style, unstyled }, off), children: [label !== undefined &&
|
|
35
|
+
(htmlFor ? (_jsx("label", { className: c("field-label"), htmlFor: htmlFor, "data-binodex-pay": "label", children: label })) : (_jsx("span", { className: c("field-label"), "data-binodex-pay": "label", children: label }))), children] }));
|
|
36
|
+
});
|
|
37
|
+
export const MethodsNotice = forwardRef(function MethodsNotice({ variant, children, className, style, unstyled, ...rest }, ref) {
|
|
38
|
+
const { off } = useClasses(unstyled);
|
|
39
|
+
return (_jsx("div", { role: variant === "loading" ? "status" : undefined, ...rest, ref: ref, ...partProps("methods-notice", { className, style, unstyled }, off), "data-variant": variant, children: children }));
|
|
40
|
+
});
|
|
41
|
+
function MethodLogoView({ option, unstyled }) {
|
|
42
|
+
const { ui, c } = useClasses(unstyled);
|
|
43
|
+
const logo = getMethodLogo(option.logoKey ?? option.id);
|
|
44
|
+
const [failed, setFailed] = useState(false);
|
|
45
|
+
const showImage = logo.imgPath !== null && !failed;
|
|
46
|
+
return (_jsx("span", { className: c("method-logo"), style: { background: logo.background, color: logo.color }, children: showImage ? (_jsx("img", { className: c("method-logo-img"), src: `${ui.assetBaseUrl}${logo.imgPath}`, alt: "", referrerPolicy: "no-referrer", onError: () => setFailed(true) })) : (logo.initial) }));
|
|
47
|
+
}
|
|
48
|
+
export const MethodGrid = forwardRef(function MethodGrid({ methods, selectedId, onSelect, disabled = false, badgeTitles, ariaLabel, className, style, unstyled, ...rest }, ref) {
|
|
49
|
+
const { c, off } = useClasses(unstyled);
|
|
50
|
+
return (_jsx("div", { role: "radiogroup", "aria-label": ariaLabel, ...rest, ref: ref, ...partProps("method-grid", { className, style, unstyled }, off), children: methods.map((method) => {
|
|
51
|
+
const selected = method.id === selectedId;
|
|
52
|
+
const logo = getMethodLogo(method.logoKey ?? method.id);
|
|
53
|
+
return (_jsxs("button", { type: "button", role: "radio", "aria-checked": selected, disabled: disabled || method.disabled, className: c("method-card", selected && "method-card-selected"), "data-binodex-pay": "method-card", "data-selected": selected ? "" : undefined, onClick: () => onSelect(method.id), ...method.attrs, children: [_jsxs("span", { className: c("method-logo-wrap"), "aria-hidden": "true", children: [_jsx(MethodLogoView, { option: method, unstyled: unstyled }, method.logoKey ?? method.id), logo.badge && (_jsx("span", { className: c("method-badge"), title: badgeTitles?.[logo.badge], "data-badge": logo.badge, children: _jsx(BadgeIcon, { badge: logo.badge, className: c("method-badge-icon") }) }))] }), _jsxs("span", { className: c("method-text"), children: [_jsx("span", { className: c("method-label"), "data-binodex-pay": "option-label", children: method.label }), method.subtitle && (_jsx("span", { className: c("method-subtitle"), "data-binodex-pay": "option-subtitle", children: method.subtitle })), method.minLabel && (_jsx("span", { className: c("method-min"), "data-binodex-pay": "option-min", children: method.minLabel }))] })] }, method.id));
|
|
54
|
+
}) }));
|
|
55
|
+
});
|
|
56
|
+
const RouteGroupContext = createContext(null);
|
|
57
|
+
export const RouteGrid = forwardRef(function RouteGrid({ children, className, style, unstyled, ...rest }, ref) {
|
|
58
|
+
const { off } = useClasses(unstyled);
|
|
59
|
+
const [open, setOpen] = useState(null);
|
|
60
|
+
const value = useMemo(() => ({ open, setOpen }), [open]);
|
|
61
|
+
return (_jsx("div", { ...rest, ref: ref, ...partProps("route-grid", { className, style, unstyled }, off), children: _jsx(RouteGroupContext.Provider, { value: value, children: children }) }));
|
|
62
|
+
});
|
|
63
|
+
export const RouteColumn = forwardRef(function RouteColumn({ label, labelRight, value, options, onSelect, part = "route-column", optionPart = "route-option", listLabel, className, style, unstyled, ...rest }, ref) {
|
|
64
|
+
const { c, off } = useClasses(unstyled);
|
|
65
|
+
const id = useId();
|
|
66
|
+
const group = useContext(RouteGroupContext);
|
|
67
|
+
const [ownOpen, setOwnOpen] = useState(false);
|
|
68
|
+
const open = group ? group.open === id : ownOpen;
|
|
69
|
+
const setOpen = useCallback((next) => {
|
|
70
|
+
if (group)
|
|
71
|
+
group.setOpen(next ? id : null);
|
|
72
|
+
else
|
|
73
|
+
setOwnOpen(next);
|
|
74
|
+
}, [group, id]);
|
|
75
|
+
const column = useRef(null);
|
|
76
|
+
useClickAway(open, () => setOpen(false), column);
|
|
77
|
+
return (_jsxs("div", { ...rest, ref: (element) => {
|
|
78
|
+
column.current = element;
|
|
79
|
+
if (typeof ref === "function")
|
|
80
|
+
ref(element);
|
|
81
|
+
else if (ref)
|
|
82
|
+
ref.current = element;
|
|
83
|
+
}, ...viewProps(part, "route-column", { className, style, unstyled }, off), "data-open": open ? "" : undefined, children: [_jsxs("div", { className: c("route-label-row"), children: [_jsx("span", { className: c("route-label"), "data-binodex-pay": "label", children: label }), labelRight && (_jsx("span", { className: c("route-label-right"), "data-binodex-pay": "label-right", children: labelRight }))] }), _jsx("button", { type: "button", className: c("route-trigger-button"), "data-binodex-pay": "route-trigger", "aria-haspopup": "listbox", "aria-expanded": open, onClick: () => setOpen(!open), children: _jsxs("span", { className: c("route-trigger", !value && "route-trigger-disabled"), children: [_jsxs("span", { className: c("route-trigger-left"), children: [value?.icon ?? _jsx("span", { className: c("route-icon-placeholder") }), _jsx("span", { className: c("route-trigger-label"), children: value?.label ?? "—" })] }), _jsx(ChevronIcon, { className: c("route-chevron") })] }) }), open && (_jsx("div", { role: "listbox", "aria-label": listLabel, className: c("route-dropdown"), "data-binodex-pay": "route-list", children: options.map((option) => {
|
|
84
|
+
const selected = option.value === value?.value;
|
|
85
|
+
return (_jsxs("button", { type: "button", role: "option", "aria-selected": selected, disabled: option.disabled, className: c("route-row", selected && "route-row-selected"), "data-binodex-pay": optionPart, "data-value": option.value, "data-selected": selected ? "" : undefined, onClick: () => {
|
|
86
|
+
setOpen(false);
|
|
87
|
+
onSelect(option.value);
|
|
88
|
+
}, ...option.attrs, children: [option.icon ?? _jsx("span", { className: c("route-icon-placeholder") }), _jsx("span", { className: c("route-row-label"), children: option.label }), option.hint && _jsx("span", { className: c("route-row-hint"), children: option.hint }), selected && _jsx(RowCheckIcon, { className: c("route-row-check") })] }, option.value));
|
|
89
|
+
}) }))] }));
|
|
90
|
+
});
|
|
91
|
+
export const RoutePicker = forwardRef(function RoutePicker({ coins, networks, value, onChange, minLabel, labels, className, style, unstyled, ...rest }, ref) {
|
|
92
|
+
const { ui } = useClasses(unstyled);
|
|
93
|
+
const coin = coins.find((entry) => entry.value === value.currency) ?? null;
|
|
94
|
+
const network = networks.find((entry) => entry.value === value.network) ?? null;
|
|
95
|
+
return (_jsxs(RouteGrid, { ...rest, ref: ref, className: className, style: style, unstyled: unstyled, children: [_jsx(RouteColumn, { label: labels?.token ?? ui.t("route.token"), value: coin, options: coins, part: "currency-picker", optionPart: "currency-option", onSelect: (currency) => onChange({ currency, network: value.network }, "currency"), unstyled: unstyled }), _jsx(RouteColumn, { label: labels?.network ?? ui.t("route.network"), labelRight: minLabel, value: network, options: networks, part: "network-picker", optionPart: "network-option", onSelect: (next) => onChange({ currency: value.currency, network: next }, "network"), unstyled: unstyled })] }));
|
|
96
|
+
});
|
|
97
|
+
const displayNames = (locale) => {
|
|
98
|
+
try {
|
|
99
|
+
const names = new Intl.DisplayNames([locale, "en"], { type: "region" });
|
|
100
|
+
return (code) => names.of(code) ?? code;
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
return (code) => code;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
function Flag({ code, lazy = false, unstyled }) {
|
|
107
|
+
const { ui, c } = useClasses(unstyled);
|
|
108
|
+
const [failed, setFailed] = useState(false);
|
|
109
|
+
return (_jsx("span", { className: c("flag"), "aria-hidden": "true", children: !failed && (_jsx("img", { className: c("flag-img"), src: `${ui.assetBaseUrl}${countryFlagPath(code)}`, alt: "", loading: lazy ? "lazy" : undefined, referrerPolicy: "no-referrer", onError: () => setFailed(true) })) }));
|
|
110
|
+
}
|
|
111
|
+
export const CountrySelect = forwardRef(function CountrySelect({ value, onChange, countries = COUNTRY_CODES, pinned = ["RU"], labels, className, style, unstyled, ...rest }, ref) {
|
|
112
|
+
const { ui, c, off } = useClasses(unstyled);
|
|
113
|
+
const [open, setOpen] = useState(false);
|
|
114
|
+
const [query, setQuery] = useState("");
|
|
115
|
+
const wrap = useRef(null);
|
|
116
|
+
const input = useRef(null);
|
|
117
|
+
const listId = useId();
|
|
118
|
+
const nameOf = useMemo(() => displayNames(ui.intl), [ui.intl]);
|
|
119
|
+
const list = useMemo(() => {
|
|
120
|
+
const entries = countries.map((code) => ({ code, name: nameOf(code) }));
|
|
121
|
+
const rank = (code) => {
|
|
122
|
+
const index = pinned.indexOf(code);
|
|
123
|
+
return index === -1 ? pinned.length : index;
|
|
124
|
+
};
|
|
125
|
+
entries.sort((a, b) => rank(a.code) - rank(b.code) || a.name.localeCompare(b.name, ui.intl));
|
|
126
|
+
return entries;
|
|
127
|
+
}, [countries, pinned, nameOf, ui.intl]);
|
|
128
|
+
const filtered = useMemo(() => {
|
|
129
|
+
const q = query.trim().toLowerCase();
|
|
130
|
+
if (!q)
|
|
131
|
+
return list;
|
|
132
|
+
return list.filter((entry) => entry.name.toLowerCase().includes(q) || entry.code.toLowerCase().includes(q));
|
|
133
|
+
}, [list, query]);
|
|
134
|
+
const selected = list.find((entry) => entry.code === value) ?? null;
|
|
135
|
+
const close = useCallback(() => {
|
|
136
|
+
setOpen(false);
|
|
137
|
+
setQuery("");
|
|
138
|
+
}, []);
|
|
139
|
+
useClickAway(open, close, wrap);
|
|
140
|
+
useEffect(() => {
|
|
141
|
+
if (!open)
|
|
142
|
+
return;
|
|
143
|
+
const handle = setTimeout(() => input.current?.focus(), 30);
|
|
144
|
+
return () => clearTimeout(handle);
|
|
145
|
+
}, [open]);
|
|
146
|
+
const pick = (code) => {
|
|
147
|
+
onChange(code);
|
|
148
|
+
close();
|
|
149
|
+
};
|
|
150
|
+
const search = labels?.search ?? ui.t("country.search");
|
|
151
|
+
return (_jsxs("div", { ...rest, ref: (element) => {
|
|
152
|
+
wrap.current = element;
|
|
153
|
+
if (typeof ref === "function")
|
|
154
|
+
ref(element);
|
|
155
|
+
else if (ref)
|
|
156
|
+
ref.current = element;
|
|
157
|
+
}, ...partProps("country-select", { className, style, unstyled }, off), "data-open": open ? "" : undefined, children: [open ? (_jsxs("div", { className: c("country-trigger", "country-trigger-open"), children: [selected && _jsx(Flag, { code: selected.code, unstyled: unstyled }), _jsx("input", { ref: input, className: c("country-search"), "data-binodex-pay": "country-search", value: query, onChange: (event) => setQuery(event.target.value), placeholder: selected?.name ?? search, "aria-label": search, "aria-controls": listId, type: "text" }), _jsx("span", { className: c("country-chevron", "country-chevron-up"), "aria-hidden": "true" })] })) : (_jsxs("button", { type: "button", className: c("country-trigger"), "data-binodex-pay": "country-trigger", onClick: () => setOpen(true), "aria-haspopup": "listbox", "aria-expanded": false, children: [_jsxs("span", { className: c("country-label"), children: [labels?.label ?? ui.t("country.label"), ":"] }), selected && _jsx(Flag, { code: selected.code, unstyled: unstyled }), _jsx("span", { className: c("country-name"), "data-binodex-pay": "country-name", children: selected?.name ?? "—" }), _jsx("span", { className: c("country-chevron"), "aria-hidden": "true" })] })), open && (_jsx("div", { className: c("country-panel"), role: "listbox", id: listId, "data-binodex-pay": "country-list", children: _jsxs("div", { className: c("country-list"), children: [filtered.length === 0 && (_jsx("div", { className: c("country-empty"), children: labels?.empty ?? ui.t("country.empty") })), filtered.map((entry) => {
|
|
158
|
+
const active = entry.code === value;
|
|
159
|
+
return (_jsxs("button", { type: "button", role: "option", "aria-selected": active, className: c("country-option", active && "country-option-active"), "data-binodex-pay": "country-option", "data-country": entry.code, onMouseDown: (event) => {
|
|
160
|
+
event.preventDefault();
|
|
161
|
+
pick(entry.code);
|
|
162
|
+
}, onClick: (event) => {
|
|
163
|
+
if (event.detail === 0)
|
|
164
|
+
pick(entry.code);
|
|
165
|
+
}, children: [_jsx(Flag, { code: entry.code, lazy: true, unstyled: unstyled }), _jsx("span", { className: c("country-option-name"), children: entry.name }), active && (_jsx("span", { className: c("country-check"), "aria-hidden": "true", children: _jsx(CheckIcon, { size: 12 }) }))] }, entry.code));
|
|
166
|
+
})] }) }))] }));
|
|
167
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export type QrEcc = "L" | "M" | "Q" | "H";
|
|
2
|
+
export interface QrMatrix {
|
|
3
|
+
version: number;
|
|
4
|
+
size: number;
|
|
5
|
+
mask: number;
|
|
6
|
+
ecc: QrEcc;
|
|
7
|
+
modules: boolean[][];
|
|
8
|
+
}
|
|
9
|
+
export declare const ECC_CODEWORDS_PER_BLOCK: Record<QrEcc, readonly number[]>;
|
|
10
|
+
export declare const NUM_ERROR_CORRECTION_BLOCKS: Record<QrEcc, readonly number[]>;
|
|
11
|
+
export declare const numRawDataModules: (version: number) => number;
|
|
12
|
+
export declare const numDataCodewords: (version: number, ecc: QrEcc) => number;
|
|
13
|
+
export declare const alignmentPositions: (version: number) => number[];
|
|
14
|
+
export declare const gfMultiply: (x: number, y: number) => number;
|
|
15
|
+
declare class Grid {
|
|
16
|
+
readonly size: number;
|
|
17
|
+
readonly modules: boolean[][];
|
|
18
|
+
readonly isFunction: boolean[][];
|
|
19
|
+
constructor(size: number);
|
|
20
|
+
setFunction(x: number, y: number, dark: boolean): void;
|
|
21
|
+
}
|
|
22
|
+
export declare const functionPatternGrid: (version: number, ecc?: QrEcc) => Grid;
|
|
23
|
+
export declare const zigzagOrder: (grid: {
|
|
24
|
+
size: number;
|
|
25
|
+
isFunction: boolean[][];
|
|
26
|
+
}) => [number, number][];
|
|
27
|
+
export declare const maskApplies: (mask: number, x: number, y: number) => boolean;
|
|
28
|
+
export declare const encodeQr: (text: string, ecc?: QrEcc) => QrMatrix;
|
|
29
|
+
export declare const qrPath: (matrix: QrMatrix, quietZone?: number) => string;
|
|
30
|
+
export {};
|