Skip to main content

ExportPopup

Portal-mounted popup that collects export options and emits an ExportRequest on submit. Ships built-in tabs for PDF, PNG, and XLSX; supports custom shallow or rich tabs for additional formats.

Imported from a separate package:

import { ExportPopup } from "@svar-ui/react-export-popup";

Usage

// Props
title?: string; // header text (not localized). Default: ""
tabs?: TabSpec[]; // ordered tabs. Default: ["pdf", "png"]
initial?: Partial<ExportRequest>; // one-shot UI seed, read once at mount
excelTimeline?: boolean; // show Simple/Timeline toggle on xlsx tab. Default: false
sizeOptions?: SizeOption[]; // size dropdown entries
htmlSize?: HtmlSize; // content measurements for page-count hint
statusText?: string; // footer info text

// Positioning (forwarded to inner Popup)
parent?: HTMLElement;
at?: TPosition; // Default: "bottom"
left?: number; // Default: 0
top?: number; // Default: 0

// Events
onExport?: (request: ExportRequest) => void;
onClose?: () => void;

Neither onExport nor onClose closes the popup - the caller unmounts it.

ExportRequest

The object emitted by onExport:

FieldTypeDescription
formatstringTab id: "pdf", "png", "xlsx", or custom
fileNamestringSuggested file name
dataunknownArbitrary data from rich tabs
skinExportAppearance"light", "dark", "print", or "bw"
paperPaperConfigPage settings (PDF/PNG only)
excelExcelConfigSpreadsheet settings (XLSX only)

PaperConfig

FieldTypeDescription
sizeSizeSpecPaper size id or { width, height } in mm
landscapebooleanLandscape orientation
pageModePageMode"single", "poster", or "booklet"
fitSizebooleanFit content to page
scalenumberScale factor
marginsRequestMargins{ top, bottom, left, right } in mm
headerstringPage header text (empty string when off)
footerstringPage footer text (empty string when off)
stylesstring[]Extra CSS URLs passed through

ExcelConfig

FieldTypeDescription
visualbooleanTimeline vs simple mode
columnsExcelColumn[]Column definitions with id, label, optional hidden
dateFormatstringDate serialization format
sheetNamesstring[]Sheet name(s)
indent"native" | "spaces"Indent style

TabSpec

Each entry in tabs is either a built-in format string or an extra tab object:

  • Built-in - "pdf", "png", or "xlsx"

  • Shallow tab (ShallowTab) - settingless placeholder; exports { format, skin } only

    FieldTypeDescription
    idstringUnique tab id
    labelstringTab label
    titlestringDisplay-only
    fileNamestringDisplay-only
  • Rich tab (RichTab) - renders a custom component with its own settings

    FieldTypeDescription
    idstringUnique tab id
    labelstringTab label
    componentComponentReact component receiving { value, onChange, _ }
    accessorTabAccessorSeeds and writes custom data into the request

Example

Open from a button and forward the request to export-data:

import { useState, useRef } from "react";
import { Kanban } from "@svar-ui/react-kanban";
import { ExportPopup } from "@svar-ui/react-export-popup";

const columns = [
{ id: "new", label: "New" },
{ id: "done", label: "Done" },
];
const cards = [
{ id: 1, label: "Task A", column: "new" },
{ id: 2, label: "Task B", column: "done" },
];

const url = "https://export.example.com";

function App() {
const [open, setOpen] = useState(false);
const api = useRef(null);
const anchor = useRef(null);

const doExport = (request) => {
api.current.exec("export-data", { url, ...request });
setOpen(false);
};

return (
<>
<button ref={anchor} onClick={() => setOpen(true)}>Export</button>

<Kanban ref={api} cards={cards} columns={columns} />

{open && (
<ExportPopup
tabs={["pdf", "png", "xlsx"]}
parent={anchor.current}
initial={{ format: "pdf", paper: { landscape: true } }}
onExport={doExport}
onClose={() => setOpen(false)}
/>
)}
</>
);
}

Adding a shallow custom tab:

<ExportPopup
tabs={[
"pdf",
"png",
{ id: "mspx", label: "MS Project XML", fileName: "project.xml" },
]}
initial={{ format: "mspx" }}
onExport={doExport}
onClose={() => setOpen(false)}
/>