import { ReactNode } from 'react'; import { AthenaTableFlatRow } from '../hooks/use-athena-query.js'; export declare function stringifyValue(value: unknown): string; export declare function isImageLikeValue(value: unknown): boolean; export declare function buildTemplateValue(template: string, row: AthenaTableFlatRow, sourceValue: unknown): string; /** * Triggers a client-side text file download. * Useful for "download" actions in tables. * * @example * downloadText("hello world", "greeting.txt") */ export declare function downloadText(content: string, filename?: string, mimeType?: string): void; /** * Copies text to the clipboard. * Safe no-op if clipboard API is unavailable. * * @example * copyText("hello world") */ export declare function copyText(text: string): void; /** * Opens a URL (typically from a templated row value) . * Respects new tab preference. * * @example * openLink(resolvedValue, action.openInNewTab) */ export declare function openLink(url: string, openInNewTab?: boolean): void; /** HeroUI Chip color tokens used by Athena table status/chip helpers. */ export type StatusColorVariant = "accent" | "danger" | "default" | "success" | "warning"; /** * Maps boolean-like values to chip colors: * - false / "false" / 0 / "no" / "off" → danger (red) * - true / "true" / 1 / "yes" / "on" / other non-false values → success (green) * - null / undefined / "" → default */ export declare function resolveBooleanColor(value: unknown): StatusColorVariant; /** * Generic fallback only. * Domain UIs should resolve StatusPresentation instead. * * Resolves a status value to a HeroUI-compatible Chip color variant for * portable AthenaTable builders and user-configured tables. First-party * Billing, Auth, and Storage screens must not call this. * * @example * import { resolveStatusColor } from "@xylex-group/athena-auth-ui/tables" * * resolveStatusColor("shipped", { shipped: "success" }) */ export declare function resolveStatusColor(status: string | null | undefined | boolean | number, overrides?: Partial>): StatusColorVariant; /** * Builds a stable string identifier for use as `tableId` (or similar scoping keys). * * Joins non-empty parts with ":" after stringifying. * Perfect for complex dashboard selection contexts, filtered table instances, etc. * * @example * // Replaces ad-hoc getSelectionTableId switches * const tableId = createTableId( * "admin-dashboard-selection", * selection.kind, * // depending on kind... * "status" in selection ? selection.status : undefined, * "priority" in selection ? selection.priority : undefined * ) */ export declare function createTableId(...parts: ReadonlyArray): string; export interface HasMorePaginationInput { /** Number of items returned for the current page */ currentPageItemCount: number; hasMore: boolean; /** 1-based current page number */ page: number; pageSize: number; } /** * Computes a synthetic totalItems value to feed into useDataTablePagination * (and WorkspacePagination) when your data source only tells you `hasMore` * instead of an exact count. * * Mirrors common consumer logic: * hasMore ? currentPage * pageSize + 1 : actual items so far on page */ export declare function computeHasMoreTotalItems(input: HasMorePaginationInput): number; /** * Computes the 1-based end index of items on the current page for "Showing X-Y" displays. * * deliveries.length === 0 ? 0 : pageStart + deliveries.length - 1 */ export declare function computeCurrentPageEndIndex(input: { page: number; pageSize: number; currentPageItemCount: number; }): number; /** * Decides whether a pagination footer/controls should be rendered. * Common rule: show if we have items, or user navigated past page 1, or there is more data. */ export declare function shouldShowPagination(params: { currentPageItemCount: number; currentPage: number; hasMore?: boolean; }): boolean; export type AthenaTableChipVariant = "primary" | "secondary" | "tertiary" | "soft"; export type AthenaTableChipSize = "sm" | "md" | "lg"; /** * Tailwind tone classes for Athena table chips. * * Applied in addition to HeroUI `color` / `variant` props so status colors stay * distinct even when Chip BEM compound selectors (`.chip--success.chip--soft`) * lose the cascade or fail to load in a consumer stylesheet. */ export declare function resolveAthenaTableChipToneClassName(color: StatusColorVariant, variant?: AthenaTableChipVariant): string; export interface AthenaTableChipOptions { className?: string; /** * Custom color for the chip. Can be a static HeroUI color or a function * based on the (original) value. Falls back to resolveStatusColor(value). */ color?: StatusColorVariant | ((value: unknown, row: Row) => StatusColorVariant); /** * If true, clicking the chip will copy the label/value to clipboard. */ copyable?: boolean; /** * Custom label/text to display inside the chip. * Defaults to a stringified version of the value. */ label?: ReactNode | ((value: unknown, row: Row) => ReactNode); size?: AthenaTableChipSize; variant?: AthenaTableChipVariant; } /** * When to show a multi-chip item. Default is `"always"`. * Evaluated against the item's resolved field value. */ export type AthenaTableChipWhen = "always" | "truthy" | "falsy" | { eq: string | number | boolean | null; } | { neq: string | number | boolean | null; }; /** * One chip in a multi-chip group (`chip.items`). * JSON-serializable for the table builder / portable configs. */ export interface AthenaTableChipItemConfig { className?: string; color?: StatusColorVariant | "status" | "boolean"; colorMap?: Partial>; copyable?: boolean; /** Static label (wins over labelMap / stringify). */ label?: string; labelMap?: Partial>; size?: AthenaTableChipSize; /** Row field for this chip; falls back to column valueKey/id when omitted. */ valueKey?: string; variant?: AthenaTableChipVariant; /** Visibility predicate on this item's value. Default: always show. */ when?: AthenaTableChipWhen; } /** * Declarative (JSON-serializable) chip config for AthenaTable columns. * * Convenience only: when a column also sets `render`, `render` always wins. */ export interface AthenaTableChipConfig { className?: string; /** * Static color, or `"status"` / `"boolean"` smart modes. */ color?: StatusColorVariant | "status" | "boolean"; /** Map of raw string values → HeroUI color variants. */ colorMap?: Partial>; copyable?: boolean; /** * Wrapper classes for multi-chip layout when `items` is set. * Default: `flex flex-wrap gap-2`. */ groupClassName?: string; /** * Multi-chip group. When non-empty, renders a flex wrap of chips. * Root size/variant/copyable/className/color* act as defaults per item. */ items?: AthenaTableChipItemConfig[]; /** Map of raw string values → display labels. */ labelMap?: Partial>; size?: AthenaTableChipSize; variant?: AthenaTableChipVariant; } /** Resolved chip ready for rendering (pure, unit-testable). */ export interface AthenaTableChipDescriptor { className?: string; color: StatusColorVariant; copyable: boolean; /** Stable key for React lists (valueKey or label + color). */ key: string; label: string; size: AthenaTableChipSize; variant: AthenaTableChipVariant; } export interface ResolveAthenaTableChipDescriptorsContext { columnId: string; /** Primary column value (from valueKey/id). Used when an item omits valueKey. */ getColumnValue?: () => unknown; valueKey?: string; } /** * Whether a chip item should render for the given field value. */ export declare function matchesChipWhen(value: unknown, when?: AthenaTableChipWhen): boolean; /** * Pure resolution of which chips to show for a row (no JSX). * Used by multi-chip rendering and unit tests. */ export declare function resolveAthenaTableChipDescriptors(row: unknown, config: AthenaTableChipConfig, context: ResolveAthenaTableChipDescriptorsContext): AthenaTableChipDescriptor[]; /** * Default chip configs for builder / model layering. */ export declare function createDefaultAthenaTableChipConfig(mode?: "status" | "boolean" | StatusColorVariant): AthenaTableChipConfig; /** * Normalize portable chip config from import (camelCase or snake_case). * Arrays are treated as multi-chip `items` sugar. * Returns undefined when empty / invalid. */ export declare function normalizeAthenaTableChipConfig(raw: unknown): AthenaTableChipConfig | undefined; /** * Portable chip payload for export (camelCase + snake_case aliases for maps). */ export declare function serializeAthenaTableChipConfig(chip: AthenaTableChipConfig): Record; /** * Builds chip options from a declarative (JSON-friendly) config. */ export declare function chipConfigToOptions(config: AthenaTableChipConfig): AthenaTableChipOptions; export interface CreateChipRendererFromConfigContext { columnId?: string; valueKey?: string; } /** * Creates a chip column renderer from a JSON-serializable config. * Single-chip when `items` is omitted; multi/conditional when `items` is set. */ export declare function createChipRendererFromConfig(getValue: (row: Row) => unknown, config?: AthenaTableChipConfig, context?: CreateChipRendererFromConfigContext): (row: Row, index: number) => ReactNode; /** * Creates a reusable column renderer that displays the value inside a HeroUI Chip. * * This is the primary "adapter" for chip-based display in AthenaTable columns. * It takes the original column value (via getValue) and renders it idiomatically * as a Chip, with smart defaults for colors (via resolveStatusColor), labels, etc. * * Fully reusable: you can create named adapters for your domain (statusChip, priorityChip, etc.) * and reuse across tables. * * @example * const statusChip = createChipRenderer( * (row) => row.status, * { variant: 'soft', copyable: true } * ) * * const columns: AthenaTableColumn[] = [ * { id: 'status', label: 'Status', render: statusChip } * ] */ export declare function createChipRenderer(getValue: (row: Row) => unknown, options?: AthenaTableChipOptions): (row: Row, index: number) => ReactNode; /** * Convenience helper to render a single value as a Chip (outside of column renderers). * Useful for manual use or inside custom render functions. * * @example * render: (row) => renderChip(row.priority, { color: row.priority === 'high' ? 'danger' : 'warning' }) */ export declare function renderChip(value: unknown, options?: Omit, "getValue">): ReactNode; /** * Pre-built adapter for common "status-like" values. * Uses resolveStatusColor + sensible soft chip defaults. * * @example * { id: 'status', label: 'Status', render: statusChipRenderer((row) => row.status) } */ export declare function statusChipRenderer(getValue: (row: Row) => unknown): (row: Row, index: number) => ReactNode; export type FileThumbnailSize = "sm" | "md"; export interface FileThumbnailSource { fileName?: string | null; mimeType?: string | null; name?: string | null; proxyUrl?: string | null; publicUrl?: string | null; url?: string | null; } export interface FileThumbnailProps { alt?: string; className?: string; fileName?: string | null; mimeType?: string | null; size?: FileThumbnailSize; src?: string | null; } export interface AthenaTableThumbnailOptions { className?: string; size?: FileThumbnailSize; } export declare function isImageMimeOrName(mimeType?: string | null, fileName?: string | null): boolean; export declare function isVideoMimeOrName(mimeType?: string | null, fileName?: string | null): boolean; export declare function isPdfMimeOrName(mimeType?: string | null, fileName?: string | null): boolean; /** * Resolves a preview/open URL from common file-record shapes. */ export declare function resolveFileThumbnailUrl(source: FileThumbnailSource | null | undefined): string | undefined; /** * Small file preview cell for AthenaTable / storage lists. * Images with an openable URL render as a thumbnail; others use typed icons. */ export declare function FileThumbnail({ alt, className, fileName, mimeType, size, src }: FileThumbnailProps): import("react").JSX.Element; /** * Creates an AthenaTable column renderer that shows a file thumbnail. * * @example * { * id: "preview", * label: "Preview", * render: createThumbnailRenderer((row) => ({ * fileName: row.fileName, * mimeType: row.mimeType, * url: row.url, * })), * } */ export declare function createThumbnailRenderer(getSource: (row: Row) => FileThumbnailSource, options?: AthenaTableThumbnailOptions): (row: Row, index: number) => ReactNode;