vs-datatable 1.2.6 → 1.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,18 +0,0 @@
1
- import VsDataTableExportDropdown from './VsDataTableExportDropdown.vue';
2
- import { useDataTableExport } from './useDataTableExport';
3
- /**
4
- * Export Plugin for VsDataTable
5
- *
6
- * This plugin adds optional CSV/Excel export functionality.
7
- * You can either:
8
- * - Use `app.use(VsDataTableExport)` to register the dropdown globally
9
- * - Or import `useDataTableExport()` composable manually
10
- */
11
- export default {
12
- install(app) {
13
- // Register the dropdown component globally
14
- app.component('VsDataTableExportDropdown', VsDataTableExportDropdown);
15
- },
16
- };
17
- // Named exports for manual usage
18
- export { VsDataTableExportDropdown, useDataTableExport };
@@ -1,26 +0,0 @@
1
- export function useDataTableExport(rows, columns) {
2
- /** Export as CSV */
3
- const exportToCSV = (filename = 'table.csv') => {
4
- const headers = columns.map(col => col.label);
5
- const data = rows.value.map(row => columns.map(col => JSON.stringify(row[col.field] ?? '')).join(','));
6
- const csvContent = [headers.join(','), ...data].join('\n');
7
- const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
8
- const url = URL.createObjectURL(blob);
9
- const link = document.createElement('a');
10
- link.href = url;
11
- link.setAttribute('download', filename);
12
- document.body.appendChild(link);
13
- link.click();
14
- document.body.removeChild(link);
15
- };
16
- /** Export as Excel */
17
- const exportToExcel = async (filename = 'table.xlsx') => {
18
- const { utils, writeFile } = await import('xlsx'); // lazy import (only loads if used)
19
- const data = rows.value.map(row => Object.fromEntries(columns.map(col => [col.label, row[col.field]])));
20
- const worksheet = utils.json_to_sheet(data);
21
- const workbook = utils.book_new();
22
- utils.book_append_sheet(workbook, worksheet, 'Sheet1');
23
- writeFile(workbook, filename);
24
- };
25
- return { exportToCSV, exportToExcel };
26
- }