import React from 'react'; export type MarkupNode = | { type: 'text'; content: string } | { type: 'newline' } | { type: 'important'; accessibilityLabel?: string; children: MarkupNode[] } | { type: 'positive'; accessibilityLabel?: string; children: MarkupNode[] } | { type: 'negative'; accessibilityLabel?: string; children: MarkupNode[] } | { type: 'strong'; accessibilityLabel?: string; children: MarkupNode[] } | { type: 'strikethrough'; accessibilityLabel?: string; children: MarkupNode[] } | { type: 'paragraph'; children: MarkupNode[] } | { type: 'link'; href?: string; action?: string; target?: string; accessibilityLabel?: string; children: MarkupNode[]; }; /** * Callback signature for the `onAction` prop. Receives the action name from * `` when clicked. */ export type MarkupActionHandler = (actionId: string) => void; /** * Per-prop Markup configuration that host components can accept via a `markupOptions` * prop keyed by their text prop names (e.g. `{ title?: MarkupTextOptions; description?: MarkupTextOptions }`). */ export type MarkupTextOptions = { data?: Record; allowLinks?: 'internal' | 'all' | 'none'; }; export interface MarkupProps { /** * Markup string to parse and render, or arbitrary JSX to pass through unchanged. * Parsing only occurs when children is a string. * */ children?: React.ReactNode; /** * Map of placeholder keys to plain-text values. Values are substituted into * `{{key}}` placeholders in text nodes and are never parsed as markup. * */ data?: Record; /** * Controls which link destinations are allowed to render as clickable links. * Non-matching hrefs degrade to plain text. This is an additional restriction * on top of built-in protocol/host sanitisation — it never bypasses it. * - `'internal'` (default) — root-relative paths (`/*`) and `https://wise.com` URLs * - `'all'` — any href that passes base sanitisation (including external HTTPS domains) * - `'none'` — all href-based links render as plain text * */ allowLinks?: 'internal' | 'all' | 'none'; /** * Callback invoked when a `` button-mode link is clicked. * Receives the action name as argument. * */ onAction?: MarkupActionHandler; /** * Wrapper element. Defaults to `div` when the parsed tree contains `` nodes, * `span` otherwise. Set explicitly to override auto-detection. * When passing a custom React component, it must accept a `className` prop. * */ as?: React.ElementType; className?: string; /** * When using a custom React component via `as`, it must also accept a `data-testid` prop. * */ 'data-testid'?: string; }