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/vue-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
    componentComponentVue component receiving { value, onchange, _ }
    accessorTabAccessorSeeds and writes custom data into the request

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>