ExportPopup
Portal-mounted popup that collects export options and emits an ExportRequest on submit. Includes built-in tabs for PDF, PNG, and XLSX. Custom shallow or rich tabs add other formats.
The component lives in a separate package:
import { ExportPopup } from "@svar-ui/vue-export-popup";
Usage
// Props
title?: string; // header text (not localized). Default: ""
tabs?: TabSpec[]; // ordered tabs. Default: ["pdf", "png"]; an empty array uses the default
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; // Default: the DOM parent of the mount point
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.
Seed defaults
Fields missing from initial start with these values:
| Seed | Default |
|---|---|
skin | "light" |
paper.size | "auto"; a custom size starts at 210×297 mm |
paper.scale | 1 |
paper.margins | 10 mm on each side |
paper.header | ""; plain text without < is wrapped in the default centered header HTML |
paper.footer | built-in page N / M HTML, used when the footer toggle is turned on |
excel.visual | false |
ExportRequest
The object emitted by onexport:
| Field | Type | Description |
|---|---|---|
format | string | Tab id: "pdf", "png", "xlsx", or custom |
fileName | string | Suggested file name |
data | unknown | Arbitrary data from rich tabs |
skin | ExportAppearance | "light", "dark", "print", or "bw" |
paper | PaperConfig | Page settings (PDF/PNG only) |
excel | ExcelConfig | Spreadsheet settings (XLSX only) |
In Kanban export, the "light" skin renders with the Willow theme.
PaperConfig
| Field | Type | Description |
|---|---|---|
size | SizeSpec | Paper size id or { width, height } in mm |
landscape | boolean | Landscape orientation |
pageMode | PageMode | "single", "poster", or "booklet" |
fitSize | boolean | Fit content to page |
scale | number | Scale factor |
margins | RequestMargins | { top, bottom, left, right } in mm |
header | string | Page header text (empty string when off) |
footer | string | Page footer text (empty string when off) |
styles | string[] | Extra CSS URLs passed through |
Paper rules:
fitSize: trueis sent only forpageMode: "single"with fit on and a size other than"auto".scaleis omitted when fit is on.- For PDF with a non-empty header or footer and no custom margins,
marginsdefaults to{ top: 12, right: 10, bottom: 10, left: 10 }. - PNG never writes
margins,header, orfooter.stylesis sent only when non-empty.
ExcelConfig
| Field | Type | Description |
|---|---|---|
visual | boolean | Timeline vs simple mode |
columns | ExcelColumn[] | Column definitions with id, label, optional hidden |
dateFormat | string | Date serialization format |
sheetNames | string[] | Sheet name(s) |
indent | "native" | "spaces" | Indent style |
The XLSX tab forwards only { visual, columns }. Other initial.excel fields (dateFormat, sheetNames, indent) aren't included in the request.
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 }onlyField Type Description idstringUnique tab id labelstringTab label titlestringDisplay-only fileNamestringDisplay-only -
Rich tab (
RichTab) - renders a custom component with its own settingsField Type Description idstringUnique tab id labelstringTab label componentComponentVue component receiving { value, onchange, _ }accessorTabAccessorSeeds and writes custom data into the request
Styling
ExportPopup has no css or class prop. Its root has the .wx-export-popup class. Scoped styles don't reach it, so overrides need higher specificity. The popup is portal-mounted, so overrides must use global CSS:
<style>
:global(body .wx-export-popup.wx-export-popup) {
width: 600px;
}
</style>
Example
Open from a button and forward the request to export-data:
<script setup>
import { Kanban } from "@svar-ui/vue-kanban";
import { ExportPopup } from "@svar-ui/vue-export-popup";
import { ref } from "vue";
const api = ref();
const anchor = ref();
const open = ref(false);
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 doExport(request) {
api.value.exec("export-data", { url, ...request });
open.value = false;
}
</script>
<template>
<button ref="anchor" :onclick="() => (open = true)">Export</button>
<Kanban ref="api" :cards="cards" :columns="columns" />
<ExportPopup
v-if="open"
:tabs="['pdf', 'png', 'xlsx']"
:parent="anchor"
:initial="{ format: 'pdf', paper: { landscape: true } }"
:onexport="doExport"
:onclose="() => (open = false)"
/>
</template>
Adding a shallow custom tab:
<template>
<ExportPopup
:tabs="[
'pdf',
'png',
{ id: 'mspx', label: 'MS Project XML', fileName: 'project.xml' },
]"
:initial="{ format: 'mspx' }"
:onexport="doExport"
:onclose="() => (open = false)"
/>
</template>
Related
- Export and import guide - PDF, PNG, xlsx export workflows
- export-data - the action that receives the popup's export request