@nkhang1902/strapi-plugin-export-import-clsx 1.6.1 → 1.6.2

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,11 +1,11 @@
1
- import { useState, useRef } from "react";
1
+ import { useState } from "react";
2
2
  import {
3
3
  Button,
4
4
  } from "@strapi/design-system";
5
- import { Download, Upload } from "@strapi/icons";
5
+ import { Download } from "@strapi/icons";
6
6
  import { useNotification } from "@strapi/strapi/admin";
7
7
 
8
- const ExportButtonsEditView = (props) => {
8
+ const ExportParticipantListButton = (props) => {
9
9
  const [isExporting, setIsExporting] = useState(false);
10
10
  const { toggleNotification } = useNotification();
11
11
  const allowedContentTypes = [
@@ -136,4 +136,4 @@ const ExportButtonsEditView = (props) => {
136
136
  );
137
137
  };
138
138
 
139
- export default ExportButtonsEditView;
139
+ export default ExportParticipantListButton;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nkhang1902/strapi-plugin-export-import-clsx",
3
- "version": "1.6.1",
3
+ "version": "1.6.2",
4
4
  "description": "A powerful Strapi plugin for exporting and importing data with Excel support and advanced filtering",
5
5
  "main": "./strapi-server.js",
6
6
  "scripts": {
@@ -1,5 +1,58 @@
1
1
  const XLSX = require("xlsx");
2
2
 
3
+ function styleWorksheet(worksheet, data, options = {}) {
4
+ const {
5
+ headerHeight = 24,
6
+ rowHeight = 18,
7
+ minColWidth = 15,
8
+ headerColWidthPadding = 2,
9
+ headerAlign = 'center',
10
+ } = options;
11
+
12
+ if (!data?.length) return worksheet;
13
+
14
+ const headers = Object.keys(data[0]);
15
+ const range = XLSX.utils.decode_range(worksheet['!ref']);
16
+
17
+ // column widths
18
+ worksheet['!cols'] = headers.map((h) => ({
19
+ wch: Math.max(h.length + headerColWidthPadding, minColWidth),
20
+ }));
21
+
22
+ // row heights
23
+ worksheet['!rows'] = [
24
+ { hpt: headerHeight },
25
+ ...Array(range.e.r).fill({ hpt: rowHeight }),
26
+ ];
27
+
28
+ // styles (header + borders)
29
+ for (let r = range.s.r; r <= range.e.r; r++) {
30
+ for (let c = range.s.c; c <= range.e.c; c++) {
31
+ const cellAddress = XLSX.utils.encode_cell({ r, c });
32
+ const cell = worksheet[cellAddress];
33
+ if (!cell) continue;
34
+
35
+ const isHeader = r === 0;
36
+
37
+ cell.s = {
38
+ font: isHeader ? { bold: true } : undefined,
39
+ alignment: {
40
+ vertical: 'center',
41
+ horizontal: isHeader ? headerAlign : 'left',
42
+ },
43
+ border: {
44
+ top: { style: 'thin' },
45
+ bottom: { style: 'thin' },
46
+ left: { style: 'thin' },
47
+ right: { style: 'thin' },
48
+ },
49
+ };
50
+ }
51
+ }
52
+
53
+ return worksheet;
54
+ }
55
+
3
56
  module.exports = ({ strapi }) => ({
4
57
  async exportData(format = "json", contentType = null, rawFilters = {}, mode = '') {
5
58
  // Normalize content type - handle both content-manager and event-manager formats
@@ -391,6 +444,7 @@ module.exports = ({ strapi }) => ({
391
444
  flattenForXLSX(entry)
392
445
  );
393
446
  const worksheet = XLSX.utils.json_to_sheet(cleanedFlat);
447
+ styleWorksheet(worksheet, cleanedFlat);
394
448
  XLSX.utils.book_append_sheet(workbook, worksheet, sheetName);
395
449
  } else {
396
450
  // Create empty sheet with headers if no data
@@ -440,6 +494,7 @@ module.exports = ({ strapi }) => ({
440
494
  }));
441
495
 
442
496
  const worksheet = XLSX.utils.json_to_sheet(data);
497
+ styleWorksheet(worksheet, data);
443
498
  XLSX.utils.book_append_sheet(
444
499
  workbook,
445
500
  worksheet,