import{type TemplateResult,type PropertyValues}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';import{type LyraAppearance,type LyraSize}from'../../../internal/variants.js';import{type LyraCsvColumn}from'./csv.js';export type LyraExportFormat='csv'|'json'; /** The export trigger's compact treatments. Unset preserves its established chrome. */ export type LyraExportButtonAppearance=Extract |'quiet';export interface LyraExportFormatDescriptor{ /** Stable format id carried through `lr-export`. */ readonly formatId:string; /** Consumer-supplied, already-localized menu label. */ readonly label:string; /** Optional consumer-supplied secondary menu text. */ readonly description?:string; /** Optional metadata for the external export handler. */ readonly extension?:string;}export type LyraExportFormatOption=LyraExportFormat|LyraExportFormatDescriptor;export interface LyraExportButtonEventMap{'lr-export':CustomEvent<{readonly format:string;}>;'lr-export-complete':CustomEvent<{readonly format:LyraExportFormat;}>;'lr-export-error':CustomEvent<{readonly format:LyraExportFormat;readonly error:unknown;}>;'lr-show':CustomEvent;'lr-hide':CustomEvent;} /** * `` — a CSV/JSON download button, single-format or a * format-choice menu. First-party invention; consolidates the ad-hoc * "export CSV" button pattern common across dashboard UIs. * Format ids are unique, nonempty occurrence identities. Malformed options and later duplicate * ids are omitted before menu state, focus reconciliation, or export events; the first wins. * * Data reaches a built-in CSV/JSON download two ways, both resolved at download time rather than * at assignment time: the eager `rows` property (read after the cancelable `lr-export` event, so a * listener may assign it from inside its own handler) and the lazy `getRows` callback, which * replaces `rows` for that download and lets a consumer export a collection it already holds -- * an ``'s `viewRows`, for instance -- without materializing a second copy here. * * @customElement lr-export-button * @event lr-export - `detail: { format }`, cancelable — call `preventDefault()` * to substitute the built-in client-side download with a server-generated one. A listener that * lets the built-in download proceed may still supply its data from inside the handler: the rows * are read *after* this dispatch, so assigning `.rows` here is honoured, and a `getRows` * callback is consulted at the same point. * @event lr-export-complete - Fired after a non-cancelled download completes. * @event lr-export-error - Fired when a built-in CSV/JSON export cannot be serialized or * downloaded. `detail: { format, error }`. The same failure is also announced through the * shared light-DOM live region and marks the trigger with the `trigger-error` part token, so a * screen-reader user and a sighted user both learn the export failed without needing to listen * for this event. * @event lr-show - The format menu is about to open, however `open` became true. Cancelable — * `preventDefault()` leaves it closed. Not fired for markup that renders open from the start. * @event lr-hide - The format menu is about to close. Cancelable on the same terms as `lr-show`. * A close this component imposes on itself (disablement, `loading`, or a format list collapsing * to one entry) emits no lifecycle event and therefore offers no veto point. * @csspart trigger - The button that triggers the export (or opens the format menu). * @csspart trigger-error - Present alongside `trigger` after a built-in CSV/JSON export fails, * until the next export attempt. Style with `::part(trigger-error)`. * @csspart menu - The format-choice menu, shown when more than one format is configured. * @csspart menu-item - A single format option inside the menu. * @csspart format-label - A format option's primary label. * @csspart format-description - A custom format option's optional secondary text. * @cssprop [--lr-overlay-surface=var(--lr-color-surface-overlay)] - Shared floating-surface fill, * on the menu popup. * @cssprop [--lr-overlay-border=var(--lr-color-border)] - Shared floating-surface edge colour, on * the menu popup. * @cssprop [--lr-overlay-radius=var(--lr-radius)] - Shared floating-surface corner radius, on * the menu popup. * @cssprop [--lr-overlay-shadow-anchored=var(--lr-shadow-m)] - Elevation of the anchored surface. * @cssprop --lr-positioning-strategy - Cascading `absolute`/`fixed` override for the format * menu's `fixed` default, read from computed style when it is (re)positioned. Set it once on * `:root`, a theme, or one clipping ancestor to change every unset export button beneath it; an * unrecognized value falls back to `fixed`. * @cssprop --lr-export-button-background - Trigger fill at rest. Overrides whatever the current * `appearance` resolves to, leaving every other paint untouched. * @cssprop --lr-export-button-color - Trigger label and icon colour at rest. The escape hatch for * `appearance="outlined"`, which paints the label `--lr-color-brand` and has no `variant` of its * own to return it to neutral text. * @cssprop --lr-export-button-border - Trigger edge colour at rest. * @cssprop --lr-export-button-hover-background - Trigger fill on hover. * @cssprop --lr-export-button-hover-color - Trigger label and icon colour on hover. * @cssprop --lr-export-button-hover-border - Trigger edge colour on hover. * @cssprop --lr-export-button-active-background - Trigger fill while pressed. * @cssprop --lr-export-button-active-color - Trigger label and icon colour while pressed. * @cssprop --lr-export-button-active-border - Trigger edge colour while pressed. * @property size - Optional density on the shared `2xs` through `xl` ladder, including the * `small`/`medium`/`large` aliases. It changes the trigger and menu-row typography and padding; * the 40px default hit-area floor remains in place. Unset preserves the established geometry. * @property appearance - Optional `outlined` or `quiet` trigger treatment. Unset preserves the * established surface, border, and text colors. * @status stable * @since 4.0.0 */ export declare class LyraExportButton extends LyraElement{static styles:import("lit").CSSResultGroup[];static properties:{rows:{attribute:boolean;noAccessor:boolean;};columns:{attribute:boolean;noAccessor:boolean;};formats:{attribute:boolean;noAccessor:boolean;};};private _rows; /** Shallow frozen row snapshots. Nested cell values remain caller-owned opaque data. * * Read late, not early: the built-in download serializes whatever this holds *after* the * cancelable `lr-export` event has been dispatched, so a listener may assign `.rows` * synchronously inside its own handler and that assignment is the data that gets downloaded. * A consumer that would rather not keep an eagerly-materialized copy in the element at all * sets {@link getRows} instead, which is consulted at the same point. */ get rows():readonly Readonly>[];set rows(next:readonly Readonly>[]); /** Column allow-list (and CSV header labels) for both export formats. Left * at its default empty array, both formats fall back to the union of the * rows' own keys instead (see `effectiveColumns()`), rather than CSV * degrading to a blank file while only JSON had a fallback. */ private _columns;get columns():readonly Readonly[];set columns(next:readonly LyraCsvColumn[]); /** Lazy row source, consulted only when a built-in CSV/JSON download is actually about to be * built -- after the cancelable `lr-export` event was not prevented, and never for a custom * format this component does not serialize itself. When set, it fully replaces {@link rows} * for that download (the eager property is not merged into or read alongside it), so a * consumer holding a large or derived collection elsewhere -- an ``'s `viewRows`, * say -- can export exactly what is on screen without copying it into this element first and * keeping it live there: * * ```ts * exportButton.getRows = () => table.viewRows as readonly Record[]; * ``` * * A non-array return is treated as no rows, matching how `rows` normalizes one. A callback * that throws is reported through `lr-export-error` and the shared failure announcement, the * same as any other export that could not be produced -- an export whose data could not be * collected has failed, and silently downloading an empty file would hide that. */ getRows?:()=>readonly Record[];filename:string; /** Prepends a UTF-8 byte-order mark (U+FEFF) to the built-in CSV download only. Excel on * Windows ignores a downloaded file's MIME charset and decodes a BOM-less CSV with the * system ANSI code page, so accented, Arabic, CJK, and typographic characters render as * mojibake; the BOM makes Excel detect UTF-8 and decode correctly. Google Sheets, * LibreOffice, and Numbers already sniff UTF-8 correctly with or without it. Never applies to * the built-in JSON download -- RFC 8259 forbids a BOM there. */ bom:boolean;private _formats; /** Format choices keyed by unique, nonempty `formatId`; the first duplicate wins. An empty or * fully rejected list disables the trigger because there is no export action to perform. */ get formats():readonly LyraExportFormatOption[];set formats(next:readonly LyraExportFormatOption[]);private _size?; /** Optional density tier on the shared ladder. Omission preserves the original trigger geometry. */ get size():LyraSize|undefined;set size(next:LyraSize|undefined); /** Optional compact trigger treatment. Omission preserves the original trigger chrome. */ get appearance():LyraExportButtonAppearance|undefined;set appearance(next:LyraExportButtonAppearance|undefined);private _appearance?;disabled:boolean; /** Controlled busy state for async/server-generated exports. */ loading:boolean; /** Visible trigger button text. It also feeds the format menu's `aria-label` when no host * `aria-label` supplies a more specific name. `undefined` uses the localized default; every * supplied string, including `''` and `'Export'`, is caller-owned visible copy. An empty or * whitespace-only visible label retains the localized default as the trigger's accessible name. */ label?:string; /** Accessible name forwarded from the host to the native trigger button. * When unset, a nonempty visible `label` provides the name; an empty visible label uses the * localized default. An explicit empty `aria-label` remains authoritative by presence. */ accessibleLabel:string|null;open:boolean;private triggerEl?;private menuEl?; /** True from a failed built-in CSV/JSON export until the next export attempt starts; drives * the visible `trigger-error` part token. */ private exportFailed; /** Handle on the shared light-DOM live region export outcomes announce through -- a region * rendered inside this shadow root is not reliably announced. Acquired on connect, not on the * first failure, so assistive tech is already observing before any text arrives. */ private sink?;private readonly menuId;private cleanup?;private overlay?;private menuPositioned;private pointerDocument?;private connectionGeneration;private connectedDocument?;private pendingDisconnectDocument?;private _isFirstUpdate;private openVetoed; /** Which menu item to focus the next time `open` flips true; reset after use. */ private pendingMenuFocusIndex;private formatsFocusSnapshot?;private forcedMenuClose?; /** Tracks only the temporary focus-rescue tabindex this component added itself. */ private injectedHostTabIndex;private restoreFocusOnMenuClose;connectedCallback():void;disconnectedCallback():void;adoptedCallback():void;private bindDocumentPointer;private unbindDocumentPointer;private onDocPointer;private openMenu;private closeMenu;private activateMenuOverlay;private deactivateMenuOverlay;private syncMenuOverlay;private menuItemEls; /** Focuses the menu item at `index` (clamped), if the menu is already open and rendered. */ private focusMenuItem; /** Opens the menu (if closed) and focuses `index`, or moves focus there directly if already open. */ private focusMenuItemOnOpen;private onKeyDown;protected firstUpdated(changed:PropertyValues):void;protected willUpdate(changed:PropertyValues):void; /** * Emits the cancelable `lr-show`/`lr-hide` veto point for this update's `open` transition. * * It runs at the end of `willUpdate()` -- after the forced closes above, and still ahead of * render and attribute reflection -- so restoring `open` on a veto leaves the menu, the * reflected attribute and the property agreeing without a visible open-then-close flash. A close * this component imposed on itself (disablement, loading, or a format list collapsing to one * entry) is never offered as a veto: no listener may hold a menu open that has nothing to show. */ private announceMenuTransition;protected updated(changed:PropertyValues):void; /** Falls back to the union of the rows' own keys when `columns` is left at * its default empty array, so an unconfigured export still produces a * proper header + data file instead of blank lines. Both `rowsForExport()` * and the CSV branch of `doExport()` share this same fallback, rather than * only the JSON path having one. Takes the rows the current download resolved rather than * reading `this.rows`, so a lazy `getRows` source derives its own header row instead of one * built from a stale eager property. */ private effectiveColumns; /** The rows one download serializes: the lazy {@link getRows} source when set, otherwise the * eagerly-assigned {@link rows}. Called from inside `doExport()`'s try block, so a throwing * callback lands on the existing `lr-export-error` path rather than escaping the click * handler. A non-array return normalizes to no rows exactly as the `rows` setter does. */ private rowsToExport; /** Applies the same `columns` allow-list CSV exports use, so JSON can't leak fields CSV hides. */ private rowsForExport;private formatId;private formatLabel;private doExport;private onTriggerClick; /** Focuses the native trigger button. */ focus(options?:FocusOptions):void; /** Removes focus from the native trigger button. */ blur():void; /** Activates the native trigger button. */ click():void; /** Resolves `label`'s effective text: an explicit override wins verbatim; left at the * built-in default it instead routes through `this.localize()` so a locale/`.strings` * override applies without requiring `label` itself to be set. */ private get effectiveLabel();render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-export-button':LyraExportButton;}}