@updog/data-editor 0.1.81 → 0.1.83
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.
- package/README.md +5 -6
- package/THIRD_PARTY_NOTICES.txt +16 -12
- package/{errors-ClynUKkF.js → errors-QjijTHhG.js} +6 -6
- package/index.css +1 -1
- package/index.d.ts +252 -897
- package/index.js +13610 -14645
- package/package.json +9 -9
- package/{parsers-Ba4gcvlF.js → parsers-DZBqyDgS.js} +19 -19
- package/serializers-CeWMwlJg.js +51 -0
- package/sheetWorkerSource.generated-BAJMh23Y.js +4 -0
- package/serializers-5crNcEYa.js +0 -51
- package/sheetWorkerSource.generated-LkZmDPiq.js +0 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@updog/data-editor",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.83",
|
|
4
4
|
"description": "Client-side CSV importer and spreadsheet editor for React. Import CSV, Excel, JSON, TSV, and XML, match columns, validate, and edit 1M+ rows entirely in the browser.",
|
|
5
5
|
"author": "Mikhail Kutateladze <admin@updog.tech>",
|
|
6
6
|
"homepage": "https://updog.tech",
|
|
@@ -33,15 +33,15 @@
|
|
|
33
33
|
"THIRD_PARTY_NOTICES.txt"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@floating-ui/react": "^0.27.
|
|
37
|
-
"@lexical/react": "^0.
|
|
38
|
-
"chardet": "^2.
|
|
36
|
+
"@floating-ui/react": "^0.27.20",
|
|
37
|
+
"@lexical/react": "^0.49.0",
|
|
38
|
+
"chardet": "^2.2.0",
|
|
39
39
|
"clsx": "^2.1.1",
|
|
40
|
-
"lexical": "^0.
|
|
41
|
-
"lucide-react": "^
|
|
42
|
-
"papaparse": "^5.
|
|
43
|
-
"react-dropzone": "^
|
|
44
|
-
"uuid": "^
|
|
40
|
+
"lexical": "^0.49.0",
|
|
41
|
+
"lucide-react": "^1.31.0",
|
|
42
|
+
"papaparse": "^5.6.0",
|
|
43
|
+
"react-dropzone": "^20.1.0",
|
|
44
|
+
"uuid": "^14.0.1"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": "^18.0.0 || ^19.0.0",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
//#region src/core/
|
|
4
|
-
var a = async ({ file:
|
|
5
|
-
let { text:
|
|
1
|
+
import { i as e, r as t, t as n } from "./errors-QjijTHhG.js";
|
|
2
|
+
import r from "papaparse";
|
|
3
|
+
//#region src/core/encoding/stripSepDirective.ts
|
|
4
|
+
var i = /^sep=.$/i, a = (e, t) => e.length > 0 && i.test(e[0].join(t)) ? e.slice(1) : e, o = async ({ file: n }) => {
|
|
5
|
+
let { text: i, delimiter: o } = await t(n), s = r.parse(i, {
|
|
6
6
|
header: !1,
|
|
7
7
|
skipEmptyLines: !1,
|
|
8
8
|
delimiter: o
|
|
@@ -14,11 +14,11 @@ var a = async ({ file: r }) => {
|
|
|
14
14
|
}));
|
|
15
15
|
return {
|
|
16
16
|
kind: "rows",
|
|
17
|
-
rows:
|
|
17
|
+
rows: a(c, o),
|
|
18
18
|
delimiter: o,
|
|
19
19
|
errors: l
|
|
20
20
|
};
|
|
21
|
-
},
|
|
21
|
+
}, s = async ({ file: n }) => {
|
|
22
22
|
let { text: r } = await t(n), i = JSON.parse(r).map((t) => {
|
|
23
23
|
let n = {};
|
|
24
24
|
for (let r of Object.keys(t)) n[e(r)] = t[r];
|
|
@@ -38,23 +38,23 @@ var a = async ({ file: r }) => {
|
|
|
38
38
|
return n;
|
|
39
39
|
})
|
|
40
40
|
};
|
|
41
|
-
},
|
|
41
|
+
}, c = 2e3, l = () => new Promise((e) => {
|
|
42
42
|
setTimeout(e, 0);
|
|
43
|
-
}),
|
|
44
|
-
if (e?.aborted) throw new
|
|
45
|
-
},
|
|
46
|
-
csv:
|
|
47
|
-
json:
|
|
43
|
+
}), u = (e) => {
|
|
44
|
+
if (e?.aborted) throw new n("File parse cancelled", "CANCELLED");
|
|
45
|
+
}, d = {
|
|
46
|
+
csv: o,
|
|
47
|
+
json: s,
|
|
48
48
|
xml: async ({ file: n, signal: r }) => {
|
|
49
49
|
let { text: i } = await t(n);
|
|
50
|
-
|
|
50
|
+
u(r);
|
|
51
51
|
let a = new DOMParser().parseFromString(i, "application/xml");
|
|
52
52
|
if (a.querySelector("parsererror")) throw Error("Failed to parse XML file");
|
|
53
|
-
let o = Array.from(a.documentElement.children),
|
|
54
|
-
for (let e of o) for (let t of Array.from(e.children))
|
|
55
|
-
let d = Array.from(
|
|
53
|
+
let o = Array.from(a.documentElement.children), s = /* @__PURE__ */ new Set();
|
|
54
|
+
for (let e of o) for (let t of Array.from(e.children)) s.add(t.tagName);
|
|
55
|
+
let d = Array.from(s), f = [];
|
|
56
56
|
for (let t = 0; t < o.length; t++) {
|
|
57
|
-
t > 0 && t %
|
|
57
|
+
t > 0 && t % c === 0 && (await l(), u(r));
|
|
58
58
|
let n = /* @__PURE__ */ new Map();
|
|
59
59
|
for (let e of Array.from(o[t].children)) n.has(e.tagName) || n.set(e.tagName, e.textContent ?? "");
|
|
60
60
|
let i = {};
|
|
@@ -69,4 +69,4 @@ var a = async ({ file: r }) => {
|
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
71
|
//#endregion
|
|
72
|
-
export {
|
|
72
|
+
export { d as PARSERS };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
//#region src/core/io/serializers/text.ts
|
|
2
|
+
var e = /^[=@+\-\t\r]/, t = /^[+-][\d.,'\s ]*$/, n = (e) => e === void 0 ? "" : String(e);
|
|
3
|
+
function r(n) {
|
|
4
|
+
return !e.test(n) || t.test(n) ? n : `'${n}`;
|
|
5
|
+
}
|
|
6
|
+
function i(e) {
|
|
7
|
+
let t = r(e);
|
|
8
|
+
return t.includes(",") || t.includes("\"") || t.includes("\n") || t.includes("\r") ? `"${t.replace(/"/g, "\"\"")}"` : t;
|
|
9
|
+
}
|
|
10
|
+
function a(e, t) {
|
|
11
|
+
let r = t ?? (e.length > 0 ? Object.keys(e[0]) : []);
|
|
12
|
+
if (r.length === 0) return new Blob([""], { type: "text/csv" });
|
|
13
|
+
let a = r.map(i).join(","), o = e.map((e) => r.map((t) => i(n(e[t]))).join(",")), s = o.length > 0 ? `${a}\n${o.join("\n")}` : `${a}\n`;
|
|
14
|
+
return new Blob([`${s}`], { type: "text/csv;charset=utf-8" });
|
|
15
|
+
}
|
|
16
|
+
function o(e) {
|
|
17
|
+
let t = r(e);
|
|
18
|
+
return t.includes(" ") || t.includes("\"") || t.includes("\n") || t.includes("\r") ? `"${t.replace(/"/g, "\"\"")}"` : t;
|
|
19
|
+
}
|
|
20
|
+
function s(e, t) {
|
|
21
|
+
let r = t ?? (e.length > 0 ? Object.keys(e[0]) : []);
|
|
22
|
+
if (r.length === 0) return new Blob([""], { type: "text/tab-separated-values" });
|
|
23
|
+
let i = r.map(o).join(" "), a = e.map((e) => r.map((t) => o(n(e[t]))).join(" ")), s = a.length > 0 ? `${i}\n${a.join("\n")}` : `${i}\n`;
|
|
24
|
+
return new Blob([`${s}`], { type: "text/tab-separated-values;charset=utf-8" });
|
|
25
|
+
}
|
|
26
|
+
function c(e) {
|
|
27
|
+
return new Blob([JSON.stringify(e, null, 2)], { type: "application/json;charset=utf-8" });
|
|
28
|
+
}
|
|
29
|
+
function l(e) {
|
|
30
|
+
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
31
|
+
}
|
|
32
|
+
function u(e, t) {
|
|
33
|
+
let r = t ?? (e.length > 0 ? Object.keys(e[0]) : []), i = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rows>\n";
|
|
34
|
+
for (let t of e) {
|
|
35
|
+
i += " <row>\n";
|
|
36
|
+
for (let e of r) {
|
|
37
|
+
let r = e.replace(/\s+/g, "_");
|
|
38
|
+
i += ` <${r}>${l(n(t[e]))}</${r}>\n`;
|
|
39
|
+
}
|
|
40
|
+
i += " </row>\n";
|
|
41
|
+
}
|
|
42
|
+
return i += "</rows>", new Blob([i], { type: "application/xml;charset=utf-8" });
|
|
43
|
+
}
|
|
44
|
+
var d = (e) => e.columns.map((e) => e.title), f = {
|
|
45
|
+
csv: (e) => a(e.rows, d(e)),
|
|
46
|
+
tsv: (e) => s(e.rows, d(e)),
|
|
47
|
+
json: (e) => c(e.rows),
|
|
48
|
+
xml: (e) => u(e.rows, d(e))
|
|
49
|
+
};
|
|
50
|
+
//#endregion
|
|
51
|
+
export { f as SERIALIZERS };
|