UNPKG

@funkit/connect

Version:

Funkit Connect SDK elevates DeFi apps via web2 sign-ins and one-click checkouts.

71 lines (70 loc) 2.86 kB
import type { TFunction } from 'i18next'; import { type ReactNode } from 'react'; export interface SourceGroup { /** Section header. Omit to render the group's body without a header. */ label?: string; /** * Optional tooltip surfaced via an info icon next to the label. * Only renders when `showLabels` and `label` are both set. */ labelTooltip?: string; children: ReactNode; } interface BuildSourceGroupsArgs { /** Customer identity — used to dispatch to per-customer section composition. */ apiKey: string; preferred: ReactNode[]; moreSources: ReactNode[]; unavailable: ReactNode[]; isFallback: boolean; isSwappedEnabled: boolean; enableSourceGroupLabels: boolean; t: TFunction; /** * Pre-rendered Native fast-path row. Caller resolves the customer's * native asset, looks up the wallet holding, and constructs the row * component; this function decides where in the Aave section * structure it belongs. Only the Aave branch consumes it; the * default branch ignores it. */ nativeRow?: ReactNode; } export type BuildSourceGroupsResult = { layout: 'flat'; groups: SourceGroup[]; } | { layout: 'grouped'; groups: SourceGroup[]; showLabels: boolean; }; /** * Composes source-list sections from `usePaymentSources` buckets + * the relevant Statsig flags + the customer identity. Returns a * discriminated layout shape; the composer (`SourceList`) dispatches * to the matching layout primitive. * * **Default branch** (most customers) mirrors SourceList's prior * output: * - `isSwappedEnabled=false` → flat layout. One group for `preferred` * (if any), one combined group for `moreSources + unavailable` (if * any), with a single divider between them. (`SourceList` places * `<PayPal />` as the flat footer.) * - `isSwappedEnabled=true` → grouped layout. Same two groups, but * rendered in separate boxes with `showLabels` toggling the section * headers ("Connected" / "Most popular" / "More options"). The * "More options" header is suppressed when no preferred group * precedes it. * * **Aave branch** (per Figma, [ENG-3743](https://linear.app/funxyz/issue/ENG-3743) * + [ENG-3747](https://linear.app/funxyz/issue/ENG-3747) * + [ENG-3755](https://linear.app/funxyz/issue/ENG-3755)): * - "Native" section with the user's underlying-asset row when * `nativeRow` is provided. * - Second section flattens preferred + moreSources + unavailable * into "Use other assets" (with native present) or "Use any asset" * (without). Header carries a tooltip via `labelTooltip`. * - Layout is always `grouped` with `showLabels=true` for Aave so the * section headers render. */ export declare function buildSourceGroups(args: BuildSourceGroupsArgs): BuildSourceGroupsResult; export {};