vs-datatable 1.0.0 → 1.1.0

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.
@@ -0,0 +1,37 @@
1
+ // src/composables/useDataTableExport.ts
2
+ import type { Ref } from 'vue'
3
+
4
+ export function useDataTableExport<T extends Record<string, any>>(rows: Ref<T[]>, columns: any[]) {
5
+ /** Export as CSV */
6
+ const exportToCSV = (filename = 'table.csv') => {
7
+ const headers = columns.map(col => col.label)
8
+ const data = rows.value.map(row =>
9
+ columns.map(col => JSON.stringify(row[col.field] ?? '')).join(',')
10
+ )
11
+ const csvContent = [headers.join(','), ...data].join('\n')
12
+
13
+ const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' })
14
+ const url = URL.createObjectURL(blob)
15
+
16
+ const link = document.createElement('a')
17
+ link.href = url
18
+ link.setAttribute('download', filename)
19
+ document.body.appendChild(link)
20
+ link.click()
21
+ document.body.removeChild(link)
22
+ }
23
+
24
+ /** Export as Excel */
25
+ const exportToExcel = async (filename = 'table.xlsx') => {
26
+ const { utils, writeFile } = await import('xlsx') // lazy import (only loads if used)
27
+ const data = rows.value.map(row =>
28
+ Object.fromEntries(columns.map(col => [col.label, row[col.field]]))
29
+ )
30
+ const worksheet = utils.json_to_sheet(data)
31
+ const workbook = utils.book_new()
32
+ utils.book_append_sheet(workbook, worksheet, 'Sheet1')
33
+ writeFile(workbook, filename)
34
+ }
35
+
36
+ return { exportToCSV, exportToExcel }
37
+ }
@@ -1,2 +0,0 @@
1
- declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
- export default _default;
@@ -1 +0,0 @@
1
- export declare function fetchPaymentMethods(): Promise<string[]>;
@@ -1 +0,0 @@
1
- export declare function fetchPaymentStatuses(): Promise<string[]>;
@@ -1,2 +0,0 @@
1
- declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
2
- export default _default;
@@ -1,3 +0,0 @@
1
- import '@/styles/vs-layout.css';
2
- declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
3
- export default _default;