@ozguraltan/strapi-content-input 1.0.26 → 1.0.27

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,12 +1,11 @@
1
1
  import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
2
  import React, { useState, useRef, useEffect, useMemo, useCallback } from "react";
3
3
  import { createPortal } from "react-dom";
4
- import { u as uid, a as useEditorTranslator, R as ROW_PRESETS, g as getRowPresetLabel, W as WIDGET_DEFINITIONS, b as getWidgetLabel, C as CIColorField, c as createWidget, d as createBlock, e as createRow, f as getWidgetDefinition, S as StrapiMediaPicker, D as DEVICES, r as resolveAdminMediaUrl, h as useStrapiLocales, i as useOptionalEditorContext, j as resolveCanvasMediaUrl, k as DEVICE_INDEX_MAP, l as useEditorContext, m as getDevice, n as rowCanvasClasses, o as nodeCanvasStyles, p as extractResponsiveProp, q as blockCanvasClasses, s as useColorCodes, t as getDeviceLabel, v as WIDTH_PRESETS, Z as ZOOM_OPTIONS, w as ColorCodesModal, x as getWidgetDescription, y as WIDGET_CATEGORIES, z as normalizeLocalizedRecord, A as normalizeOptionListByLocales, B as getDeviceTooltip, E as SurveyWidgetEditor, F as setResponsiveProp, G as getClipboard, H as copyToClipboard, I as EditorProvider, J as ensureIds } from "./SurveyWidgetEditor-GKRT3eHj.mjs";
5
- import { M as MaterialIcon } from "./index-DSDcG4QW.mjs";
4
+ import { u as uid, a as useEditorTranslator, R as ROW_PRESETS, g as getRowPresetLabel, W as WIDGET_DEFINITIONS, b as getWidgetLabel, C as CIColorField, c as createWidget, d as createBlock, e as createRow, f as getWidgetDefinition, S as StrapiMediaPicker, D as DEVICES, r as resolveAdminMediaUrl, h as useStrapiLocales, i as useOptionalEditorContext, j as resolveCanvasMediaUrl, k as DEVICE_INDEX_MAP, l as useEditorContext, m as getDevice, n as rowCanvasClasses, o as nodeCanvasStyles, p as extractResponsiveProp, q as blockCanvasClasses, s as useColorCodes, t as getDeviceLabel, v as WIDTH_PRESETS, Z as ZOOM_OPTIONS, w as ColorCodesModal, x as getWidgetDescription, y as WIDGET_CATEGORIES, z as normalizeLocalizedRecord, A as normalizeOptionListByLocales, B as getDeviceTooltip, E as SurveyWidgetEditor, F as setResponsiveProp, G as getClipboard, H as copyToClipboard, I as EditorProvider, J as ensureIds } from "./SurveyWidgetEditor-BZHyY2eb.mjs";
5
+ import { M as MaterialIcon } from "./index-CStmbvTw.mjs";
6
6
  import { Swiper, SwiperSlide } from "swiper/react";
7
7
  import { Navigation, Pagination, Autoplay, Parallax, EffectFade, EffectCreative, EffectCoverflow, EffectCube, EffectFlip, Mousewheel } from "swiper/modules";
8
8
  import { useFetchClient, useStrapiApp } from "@strapi/strapi/admin";
9
- import * as XLSXNs from "xlsx";
10
9
  function buildRichSampleRows(locale = "en") {
11
10
  const tr = locale === "tr";
12
11
  return [
@@ -11732,6 +11731,427 @@ const HeroSliderStudioModal = ({
11732
11731
  document.body
11733
11732
  );
11734
11733
  };
11734
+ const MAX_ARCHIVE_BYTES = 20 * 1024 * 1024;
11735
+ const MAX_ENTRIES = 128;
11736
+ const MAX_UNCOMPRESSED_BYTES = 25 * 1024 * 1024;
11737
+ function normalizeZipPath(rawPath) {
11738
+ const cleaned = String(rawPath || "").replace(/\\/g, "/").replace(/^\/+/, "");
11739
+ if (!cleaned || cleaned.includes("\0") || cleaned.split("/").includes("..")) {
11740
+ throw new Error("Unsafe archive entry path detected in .xlsx file.");
11741
+ }
11742
+ return cleaned;
11743
+ }
11744
+ function resolveRelativeZipTarget(baseFile, target) {
11745
+ const cleanTarget = String(target || "").replace(/\\/g, "/");
11746
+ if (cleanTarget.startsWith("/")) {
11747
+ return normalizeZipPath(cleanTarget.slice(1));
11748
+ }
11749
+ const baseParts = baseFile.split("/");
11750
+ baseParts.pop();
11751
+ for (const seg of cleanTarget.split("/")) {
11752
+ if (!seg || seg === ".") continue;
11753
+ if (seg === "..") {
11754
+ baseParts.pop();
11755
+ } else {
11756
+ baseParts.push(seg);
11757
+ }
11758
+ }
11759
+ return normalizeZipPath(baseParts.join("/"));
11760
+ }
11761
+ function parseCentralDirectory(buf) {
11762
+ if (buf.byteLength < 22) {
11763
+ throw new Error("Invalid or empty spreadsheet file.");
11764
+ }
11765
+ if (buf.byteLength > MAX_ARCHIVE_BYTES) {
11766
+ throw new Error("Excel (.xlsx) file exceeds maximum allowed size (20 MB).");
11767
+ }
11768
+ const view = new DataView(buf);
11769
+ const magic = view.getUint32(0, false);
11770
+ if (magic === 3503231456) {
11771
+ throw new Error(
11772
+ "Legacy Excel 97-2003 (.xls) binary format is not supported. Please save as .xlsx or .csv."
11773
+ );
11774
+ }
11775
+ const minEocdOffset = Math.max(0, buf.byteLength - 65557);
11776
+ let eocdOffset = -1;
11777
+ for (let pos = buf.byteLength - 22; pos >= minEocdOffset; pos--) {
11778
+ if (view.getUint32(pos, true) === 101010256) {
11779
+ eocdOffset = pos;
11780
+ break;
11781
+ }
11782
+ }
11783
+ if (eocdOffset < 0) {
11784
+ throw new Error("Invalid .xlsx archive (ZIP End of Central Directory not found).");
11785
+ }
11786
+ const totalEntries = view.getUint16(eocdOffset + 10, true);
11787
+ if (totalEntries > MAX_ENTRIES) {
11788
+ throw new Error(
11789
+ `Archive contains too many internal files (${totalEntries} > ${MAX_ENTRIES}).`
11790
+ );
11791
+ }
11792
+ const cdSize = view.getUint32(eocdOffset + 12, true);
11793
+ const cdOffset = view.getUint32(eocdOffset + 16, true);
11794
+ if (cdOffset + cdSize > buf.byteLength) {
11795
+ throw new Error("Corrupted .xlsx ZIP Central Directory bounds.");
11796
+ }
11797
+ const dec = new TextDecoder("utf-8");
11798
+ const entries = /* @__PURE__ */ new Map();
11799
+ let ptr = cdOffset;
11800
+ for (let i = 0; i < totalEntries; i++) {
11801
+ if (ptr + 46 > buf.byteLength || view.getUint32(ptr, true) !== 33639248) {
11802
+ throw new Error("Corrupted .xlsx Central Directory header.");
11803
+ }
11804
+ const compressionMethod = view.getUint16(ptr + 10, true);
11805
+ const compressedSize = view.getUint32(ptr + 20, true);
11806
+ const uncompressedSize = view.getUint32(ptr + 24, true);
11807
+ const nameLen = view.getUint16(ptr + 28, true);
11808
+ const extraLen = view.getUint16(ptr + 30, true);
11809
+ const commentLen = view.getUint16(ptr + 32, true);
11810
+ const localHeaderOffset = view.getUint32(ptr + 42, true);
11811
+ if (ptr + 46 + nameLen > buf.byteLength) {
11812
+ throw new Error("Truncated filename in .xlsx Central Directory.");
11813
+ }
11814
+ if (uncompressedSize > MAX_UNCOMPRESSED_BYTES) {
11815
+ throw new Error("Uncompressed entry size exceeds 25 MB safety limit.");
11816
+ }
11817
+ const rawName = dec.decode(new Uint8Array(buf, ptr + 46, nameLen));
11818
+ const path = normalizeZipPath(rawName);
11819
+ entries.set(path, {
11820
+ path,
11821
+ compressionMethod,
11822
+ compressedSize,
11823
+ uncompressedSize,
11824
+ localHeaderOffset
11825
+ });
11826
+ ptr += 46 + nameLen + extraLen + commentLen;
11827
+ }
11828
+ return entries;
11829
+ }
11830
+ async function extractEntryUtf8(buf, entry, budget) {
11831
+ const view = new DataView(buf);
11832
+ const lhPos = entry.localHeaderOffset;
11833
+ if (lhPos + 30 > buf.byteLength || view.getUint32(lhPos, true) !== 67324752) {
11834
+ throw new Error(`Corrupted local ZIP header for ${entry.path}`);
11835
+ }
11836
+ const nameLen = view.getUint16(lhPos + 26, true);
11837
+ const extraLen = view.getUint16(lhPos + 28, true);
11838
+ const dataOffset = lhPos + 30 + nameLen + extraLen;
11839
+ if (dataOffset + entry.compressedSize > buf.byteLength) {
11840
+ throw new Error(`Truncated compressed payload for ${entry.path}`);
11841
+ }
11842
+ const rawSlice = new Uint8Array(buf, dataOffset, entry.compressedSize);
11843
+ const dec = new TextDecoder("utf-8");
11844
+ if (entry.compressionMethod === 0) {
11845
+ budget.totalBytes += rawSlice.byteLength;
11846
+ if (budget.totalBytes > MAX_UNCOMPRESSED_BYTES) {
11847
+ throw new Error("Decompressed .xlsx content exceeds 25 MB safety limit.");
11848
+ }
11849
+ return dec.decode(rawSlice);
11850
+ }
11851
+ if (entry.compressionMethod === 8) {
11852
+ if (typeof DecompressionStream === "undefined") {
11853
+ throw new Error("Browser does not support DecompressionStream for DEFLATE .xlsx files.");
11854
+ }
11855
+ const ds = new DecompressionStream("deflate-raw");
11856
+ const writer = ds.writable.getWriter();
11857
+ const writePromise = writer.write(rawSlice).then(() => writer.close());
11858
+ const reader = ds.readable.getReader();
11859
+ const chunks = [];
11860
+ let entryBytes = 0;
11861
+ while (true) {
11862
+ const { value, done } = await reader.read();
11863
+ if (done) break;
11864
+ if (value) {
11865
+ entryBytes += value.byteLength;
11866
+ budget.totalBytes += value.byteLength;
11867
+ if (budget.totalBytes > MAX_UNCOMPRESSED_BYTES) {
11868
+ try {
11869
+ await reader.cancel();
11870
+ } catch {
11871
+ }
11872
+ throw new Error("Decompressed .xlsx content exceeds 25 MB safety limit.");
11873
+ }
11874
+ chunks.push(value);
11875
+ }
11876
+ }
11877
+ await writePromise;
11878
+ const merged = new Uint8Array(entryBytes);
11879
+ let pos = 0;
11880
+ for (const ch of chunks) {
11881
+ merged.set(ch, pos);
11882
+ pos += ch.byteLength;
11883
+ }
11884
+ return dec.decode(merged);
11885
+ }
11886
+ throw new Error(
11887
+ `Unsupported ZIP compression method (${entry.compressionMethod}) in ${entry.path}.`
11888
+ );
11889
+ }
11890
+ function parseXmlDoc(xml) {
11891
+ if (typeof DOMParser === "undefined") {
11892
+ throw new Error("DOMParser is required to parse .xlsx XML documents.");
11893
+ }
11894
+ const doc = new DOMParser().parseFromString(xml, "application/xml");
11895
+ const parserErr = doc.getElementsByTagName("parsererror")[0];
11896
+ if (parserErr) {
11897
+ throw new Error("Malformed XML inside .xlsx archive.");
11898
+ }
11899
+ return doc;
11900
+ }
11901
+ function descendantsByLocal(root, localName) {
11902
+ const out = [];
11903
+ const all = root.getElementsByTagName("*");
11904
+ for (let i = 0; i < all.length; i++) {
11905
+ const el = all[i];
11906
+ if (el.localName === localName) {
11907
+ out.push(el);
11908
+ }
11909
+ }
11910
+ return out;
11911
+ }
11912
+ function childrenByLocal(parent, localName) {
11913
+ if (!parent) return [];
11914
+ const out = [];
11915
+ const ch = parent.children;
11916
+ for (let i = 0; i < ch.length; i++) {
11917
+ if (ch[i].localName === localName) {
11918
+ out.push(ch[i]);
11919
+ }
11920
+ }
11921
+ return out;
11922
+ }
11923
+ function firstChildByLocal(parent, localName) {
11924
+ if (!parent) return null;
11925
+ const ch = parent.children;
11926
+ for (let i = 0; i < ch.length; i++) {
11927
+ if (ch[i].localName === localName) return ch[i];
11928
+ }
11929
+ return null;
11930
+ }
11931
+ function extractRichOrPlainText(container) {
11932
+ const parts = [];
11933
+ const walk = (node) => {
11934
+ if (node.localName === "rPh") return;
11935
+ if (node.localName === "t") {
11936
+ parts.push(node.textContent || "");
11937
+ return;
11938
+ }
11939
+ const ch = node.children;
11940
+ for (let i = 0; i < ch.length; i++) {
11941
+ walk(ch[i]);
11942
+ }
11943
+ };
11944
+ walk(container);
11945
+ return parts.join("");
11946
+ }
11947
+ function isBuiltInDateNumFmt(id) {
11948
+ return id >= 14 && id <= 22 || id >= 27 && id <= 36 || id >= 45 && id <= 47 || id >= 50 && id <= 58;
11949
+ }
11950
+ function isCustomDateFormatCode(code) {
11951
+ const cleaned = String(code || "").replace(/"[^"]*"/g, "").replace(/\[[^\]]*\]/g, "").replace(/\\./g, "").toLowerCase();
11952
+ if (!cleaned || /[0#?]/.test(cleaned)) return false;
11953
+ return /[ymdhs]/.test(cleaned);
11954
+ }
11955
+ function parseDateStyleFlags(stylesXml) {
11956
+ if (!stylesXml) return [];
11957
+ const doc = parseXmlDoc(stylesXml);
11958
+ const customFmtMap = /* @__PURE__ */ new Map();
11959
+ for (const nf of descendantsByLocal(doc, "numFmt")) {
11960
+ const id = Number(nf.getAttribute("numFmtId"));
11961
+ const code = nf.getAttribute("formatCode") || "";
11962
+ if (!Number.isNaN(id)) {
11963
+ customFmtMap.set(id, code);
11964
+ }
11965
+ }
11966
+ const cellXfs = descendantsByLocal(doc, "cellXfs")[0];
11967
+ if (!cellXfs) return [];
11968
+ return childrenByLocal(cellXfs, "xf").map((xf) => {
11969
+ const fmtId = Number(xf.getAttribute("numFmtId") || "0");
11970
+ if (isBuiltInDateNumFmt(fmtId)) return true;
11971
+ const custom = customFmtMap.get(fmtId);
11972
+ return custom ? isCustomDateFormatCode(custom) : false;
11973
+ });
11974
+ }
11975
+ function excelSerialToIsoString(serial) {
11976
+ const utcMs = Math.round((serial - 25569) * 86400 * 1e3);
11977
+ const dt = new Date(utcMs);
11978
+ if (Number.isNaN(dt.getTime())) return String(serial);
11979
+ const iso = dt.toISOString();
11980
+ const frac = Math.abs(serial - Math.floor(serial));
11981
+ return frac > 1e-4 ? iso.slice(0, 16).replace("T", " ") : iso.slice(0, 10);
11982
+ }
11983
+ function parseColIndexFromRef(cellRef) {
11984
+ let col = 0;
11985
+ let hasLetters = false;
11986
+ for (let i = 0; i < cellRef.length; i++) {
11987
+ const code = cellRef.charCodeAt(i);
11988
+ if (code >= 65 && code <= 90) {
11989
+ col = col * 26 + (code - 64);
11990
+ hasLetters = true;
11991
+ } else if (code >= 97 && code <= 122) {
11992
+ col = col * 26 + (code - 96);
11993
+ hasLetters = true;
11994
+ } else {
11995
+ break;
11996
+ }
11997
+ }
11998
+ return hasLetters ? col - 1 : -1;
11999
+ }
12000
+ function sanitizeHeaderKey(rawHeader, colIdx, used) {
12001
+ let base = String(rawHeader ?? "").trim();
12002
+ if (!base) base = `Column ${colIdx + 1}`;
12003
+ if (base === "__proto__" || base === "constructor" || base === "prototype") {
12004
+ base = `_${base}`;
12005
+ }
12006
+ let candidate = base;
12007
+ let suffix = 1;
12008
+ while (used.has(candidate)) {
12009
+ candidate = `${base}_${suffix}`;
12010
+ suffix += 1;
12011
+ }
12012
+ used.add(candidate);
12013
+ return candidate;
12014
+ }
12015
+ function parseWorksheetRows(sheetXml, sharedStrings, dateStyles) {
12016
+ const doc = parseXmlDoc(sheetXml);
12017
+ const sheetData = descendantsByLocal(doc, "sheetData")[0];
12018
+ if (!sheetData) return [];
12019
+ const rawAoA = [];
12020
+ let maxColCount = 0;
12021
+ for (const rowEl of childrenByLocal(sheetData, "row")) {
12022
+ const rowArr = [];
12023
+ let nextCol = 0;
12024
+ let hasNonEmpty = false;
12025
+ for (const cEl of childrenByLocal(rowEl, "c")) {
12026
+ const refAttr = cEl.getAttribute("r") || "";
12027
+ const parsedCol = refAttr ? parseColIndexFromRef(refAttr) : -1;
12028
+ const colIdx = parsedCol >= 0 ? parsedCol : nextCol;
12029
+ nextCol = colIdx + 1;
12030
+ const tAttr = cEl.getAttribute("t") || "";
12031
+ const sAttr = Number(cEl.getAttribute("s") || "-1");
12032
+ const vEl = firstChildByLocal(cEl, "v");
12033
+ const isEl = firstChildByLocal(cEl, "is");
12034
+ const vText = vEl?.textContent ?? "";
12035
+ let cellVal = "";
12036
+ if (tAttr === "s") {
12037
+ const ssIdx = Number(vText);
12038
+ cellVal = !Number.isNaN(ssIdx) && ssIdx >= 0 && ssIdx < sharedStrings.length ? sharedStrings[ssIdx] : "";
12039
+ } else if (tAttr === "inlineStr") {
12040
+ cellVal = isEl ? extractRichOrPlainText(isEl) : "";
12041
+ } else if (tAttr === "b") {
12042
+ cellVal = vText === "1" || vText.toLowerCase() === "true";
12043
+ } else if (tAttr === "str" || tAttr === "e") {
12044
+ cellVal = vText;
12045
+ } else if (vText !== "") {
12046
+ const num = Number(vText);
12047
+ if (!Number.isNaN(num) && Number.isFinite(num)) {
12048
+ cellVal = sAttr >= 0 && dateStyles[sAttr] ? excelSerialToIsoString(num) : num;
12049
+ } else {
12050
+ cellVal = vText;
12051
+ }
12052
+ }
12053
+ if (cellVal !== "" && cellVal !== null && cellVal !== void 0) {
12054
+ hasNonEmpty = true;
12055
+ }
12056
+ rowArr[colIdx] = cellVal;
12057
+ }
12058
+ if (hasNonEmpty) {
12059
+ if (rowArr.length > maxColCount) maxColCount = rowArr.length;
12060
+ rawAoA.push(rowArr);
12061
+ }
12062
+ }
12063
+ if (rawAoA.length === 0 || maxColCount === 0) return [];
12064
+ const countPopulated = (arr) => arr.reduce(
12065
+ (acc, v) => v !== void 0 && v !== null && String(v).trim() !== "" ? acc + 1 : acc,
12066
+ 0
12067
+ );
12068
+ let headerRowIdx = 0;
12069
+ if (countPopulated(rawAoA[0]) <= 1 && maxColCount >= 2) {
12070
+ const scanLimit = Math.min(rawAoA.length, 5);
12071
+ for (let idx = 1; idx < scanLimit; idx++) {
12072
+ if (countPopulated(rawAoA[idx]) >= 2) {
12073
+ headerRowIdx = idx;
12074
+ break;
12075
+ }
12076
+ }
12077
+ }
12078
+ const headerRow = rawAoA[headerRowIdx];
12079
+ const colTotal = Math.max(maxColCount, headerRow.length);
12080
+ const usedHeaders = /* @__PURE__ */ new Set();
12081
+ const headers = [];
12082
+ for (let c = 0; c < colTotal; c++) {
12083
+ headers.push(sanitizeHeaderKey(headerRow[c], c, usedHeaders));
12084
+ }
12085
+ const records = [];
12086
+ for (let r = headerRowIdx + 1; r < rawAoA.length; r++) {
12087
+ const rowVals = rawAoA[r];
12088
+ const rec = {};
12089
+ for (let c = 0; c < headers.length; c++) {
12090
+ const val = rowVals[c] !== void 0 && rowVals[c] !== null ? rowVals[c] : "";
12091
+ Object.defineProperty(rec, headers[c], {
12092
+ value: val,
12093
+ enumerable: true,
12094
+ writable: true,
12095
+ configurable: true
12096
+ });
12097
+ }
12098
+ records.push(rec);
12099
+ }
12100
+ return records;
12101
+ }
12102
+ async function readXlsxWorkbookFromBuffer(buf) {
12103
+ const entries = parseCentralDirectory(buf);
12104
+ const budget = { totalBytes: 0 };
12105
+ const wbEntry = entries.get("xl/workbook.xml");
12106
+ if (!wbEntry) {
12107
+ throw new Error("Invalid .xlsx file: xl/workbook.xml is missing.");
12108
+ }
12109
+ const wbXml = await extractEntryUtf8(buf, wbEntry, budget);
12110
+ const wbDoc = parseXmlDoc(wbXml);
12111
+ const relMap = /* @__PURE__ */ new Map();
12112
+ const wbRelsEntry = entries.get("xl/_rels/workbook.xml.rels");
12113
+ if (wbRelsEntry) {
12114
+ const relsXml = await extractEntryUtf8(buf, wbRelsEntry, budget);
12115
+ const relsDoc = parseXmlDoc(relsXml);
12116
+ for (const relEl of descendantsByLocal(relsDoc, "Relationship")) {
12117
+ const id = relEl.getAttribute("Id") || "";
12118
+ const target = relEl.getAttribute("Target") || "";
12119
+ if (id && target) {
12120
+ relMap.set(id, resolveRelativeZipTarget("xl/workbook.xml", target));
12121
+ }
12122
+ }
12123
+ }
12124
+ const sharedStrings = [];
12125
+ const ssEntry = entries.get("xl/sharedStrings.xml");
12126
+ if (ssEntry) {
12127
+ const ssXml = await extractEntryUtf8(buf, ssEntry, budget);
12128
+ const ssDoc = parseXmlDoc(ssXml);
12129
+ for (const si of descendantsByLocal(ssDoc, "si")) {
12130
+ sharedStrings.push(extractRichOrPlainText(si));
12131
+ }
12132
+ }
12133
+ const stylesEntry = entries.get("xl/styles.xml");
12134
+ const stylesXml = stylesEntry ? await extractEntryUtf8(buf, stylesEntry, budget) : null;
12135
+ const dateStyles = parseDateStyleFlags(stylesXml);
12136
+ const SheetNames = [];
12137
+ const Sheets = {};
12138
+ const sheetEls = descendantsByLocal(wbDoc, "sheet");
12139
+ for (let idx = 0; idx < sheetEls.length; idx++) {
12140
+ const shEl = sheetEls[idx];
12141
+ const name = shEl.getAttribute("name") || `Sheet${idx + 1}`;
12142
+ const rId = shEl.getAttribute("r:id") || shEl.getAttributeNS(
12143
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
12144
+ "id"
12145
+ ) || "";
12146
+ const targetPath = rId && relMap.get(rId) || `xl/worksheets/sheet${idx + 1}.xml`;
12147
+ const wsEntry = entries.get(targetPath);
12148
+ if (!wsEntry) continue;
12149
+ const wsXml = await extractEntryUtf8(buf, wsEntry, budget);
12150
+ SheetNames.push(name);
12151
+ Sheets[name] = parseWorksheetRows(wsXml, sharedStrings, dateStyles);
12152
+ }
12153
+ return { SheetNames, Sheets };
12154
+ }
11735
12155
  function createDefaultDataTableData() {
11736
12156
  return {
11737
12157
  title: {
@@ -12265,12 +12685,8 @@ const DataTableStudioModal = ({
12265
12685
  }
12266
12686
  };
12267
12687
  const importFromWorkbookSheet = (wb, sheetName, fileName) => {
12268
- const ws = wb.Sheets[sheetName];
12269
- if (!ws) return;
12270
- const jsonRows = XLSXNs.utils.sheet_to_json(ws, {
12271
- defval: "",
12272
- raw: true
12273
- });
12688
+ const jsonRows = wb.Sheets[sheetName];
12689
+ if (!jsonRows) return;
12274
12690
  setActiveSheetName(sheetName);
12275
12691
  buildColumnsAndRowsFromRecords(
12276
12692
  jsonRows,
@@ -12343,10 +12759,10 @@ const DataTableStudioModal = ({
12343
12759
  return;
12344
12760
  }
12345
12761
  const reader = new FileReader();
12346
- reader.onload = () => {
12762
+ reader.onload = async () => {
12347
12763
  try {
12348
12764
  const buf = reader.result;
12349
- const wb = XLSXNs.read(buf, { type: "array", cellDates: true });
12765
+ const wb = await readXlsxWorkbookFromBuffer(buf);
12350
12766
  workbookRef.current = wb;
12351
12767
  const names = Array.isArray(wb.SheetNames) ? wb.SheetNames : [];
12352
12768
  setSheetNames(names);