pivotkit-react 0.5.0 → 0.6.1
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/CHANGELOG.md +118 -2
- package/README.md +4 -1
- package/dist/chunks/{chunk-2AT72SLA.js → chunk-3LDE2GPG.js} +58 -34
- package/dist/chunks/{chunk-RIOSIYGC.js → chunk-JOWAEZAD.js} +6 -4
- package/dist/chunks/{chunk-U5Q5I2D5.js → chunk-TR2HROIK.js} +10 -3
- package/dist/chunks/chunk-W2KIPREL.js +36 -0
- package/dist/chunks/{chunk-3WUGQPWV.js → chunk-XN5HNKJ2.js} +10 -95
- package/dist/chunks/{chunk-4RS72AAA.js → chunk-YXLANLGL.js} +8 -2
- package/dist/chunks/{chunk-3E4NB5RZ.js → chunk-ZK5RVCHP.js} +21 -3
- package/dist/import-ui.js +68 -174
- package/dist/index.js +75 -28
- package/dist/labels.js +4 -4
- package/dist/menu-texts-de.js +1 -1
- package/dist/menus.js +338 -82
- package/dist/styles.css +1 -1
- package/package.json +3 -3
- package/types/drill-export.d.ts +3 -2
- package/types/drill-panel.d.ts +4 -2
- package/types/export-run.d.ts +8 -3
- package/types/export-scope.d.ts +47 -0
- package/types/field-info.d.ts +3 -10
- package/types/import-host.d.ts +37 -8
- package/types/import-labels.d.ts +20 -3
- package/types/import-module.d.ts +1 -1
- package/types/import-run.d.ts +0 -8
- package/types/import-steps.d.ts +8 -0
- package/types/import-ui.d.ts +21 -4
- package/types/index.d.ts +59 -12
- package/types/labels.d.ts +2 -22
- package/types/menu-fields.d.ts +9 -0
- package/types/menu-labels.d.ts +6 -0
- package/types/menu-ops.d.ts +28 -3
- package/types/names.d.ts +22 -8
- package/types/share-actions.d.ts +14 -0
- package/types/sheet-views.d.ts +60 -0
- package/types/templates.d.ts +21 -1
- package/types/toolbar-panels.d.ts +13 -6
- package/types/use-export.d.ts +2 -2
- package/types/view-history.d.ts +15 -0
- package/types/view-save.d.ts +10 -6
- package/types/view-store.d.ts +21 -11
- package/types/import-source.d.ts +0 -32
|
@@ -9,9 +9,11 @@ var de = {
|
|
|
9
9
|
along: "Die Richtung der Berechnung: Zeilen geht die Zeilen jeder Spalte hinunter, Spalten \xFCber die Spalten jeder Zeile. Eine laufende Summe addiert entlang, eine Differenz vergleicht mit dem Eintrag davor.",
|
|
10
10
|
showAs: "Zeigt jeden Wert als Anteil, Differenz, laufende Summe oder Rang statt der Zahl selbst. Bei Prozenten sagt ein Tipp \xFCber dem Ergebnis, was 100 % ist.",
|
|
11
11
|
exportXlsx: "Jede Zahl mit allen Nachkommastellen, Formate bleiben, bereit zum Rechnen.",
|
|
12
|
-
exportCsv: "
|
|
12
|
+
exportCsv: "Die Tabelle wie angezeigt, mit ihren Summen und Prozenten, als reiner Text. Nicht die Zeilen dahinter: Das sind die Quelldaten, unten.",
|
|
13
13
|
exportHtml: "Eine Seite mit der Tabelle wie angezeigt, dem Diagramm, wenn es angezeigt wird, und den Filtern: \xF6ffnet in jedem Browser, druckt gut.",
|
|
14
14
|
exportPrint: "Derselbe Bericht im Druckdialog des Browsers: drucken oder dort Als PDF speichern w\xE4hlen.",
|
|
15
|
+
exportDataCsv: "Alle urspr\xFCnglichen Zeilen hinter dem Bericht, vor Gruppierung, Filtern und Summen, mit jedem Feld. F\xFCr eigene Auswertungen oder um den Bericht mit seiner Ansicht (Ansichten \u2192 Ansicht herunterladen) anderswo neu zu erstellen. In Excel mit Dezimalkomma: \xFCber Daten \u2192 Aus Text/CSV \xF6ffnen.",
|
|
16
|
+
exportDataJson: "Dieselben Zeilen als JSON, f\xFCr ein Programm: Zahlen als Zahlen, Text als Text, ein leerer Wert als null.",
|
|
15
17
|
copyTable: "Die Tabelle wie angezeigt, mit \xDCberschriften und Summen: tabulatorgetrennt, wird in Excel oder Google Sheets in Spalten eingef\xFCgt.",
|
|
16
18
|
copyDataJson: "Die Zahlen der Tabelle mit ihren Beschriftungen als JSON, f\xFCr ein Programm. Nicht die Ansicht selbst: Das ist Ansichten \u2192 Ansicht als JSON kopieren.",
|
|
17
19
|
drillCopy: "Die Zeilen wie im Bereich angezeigt, mit einer \xDCberschriftenzeile: tabulatorgetrennt, wird in Excel oder Google Sheets in Spalten eingef\xFCgt.",
|
|
@@ -167,6 +169,7 @@ var de = {
|
|
|
167
169
|
storeTooLarge: "die Ansichten br\xE4uchten mehr als {max} Zeichen",
|
|
168
170
|
storeRefused: "dieser Browser hat sie nicht behalten (Speicher gesperrt oder voll)",
|
|
169
171
|
storeChanged: "die Ansichten wurden in einem anderen Tab ge\xE4ndert; das Men\xFC neu \xF6ffnen",
|
|
172
|
+
viewSheet: "Blatt \u201E{sheet}\u201C",
|
|
170
173
|
toastSaved: "Ansicht \u201E{name}\u201C gespeichert",
|
|
171
174
|
toastDeleted: "Ansicht \u201E{name}\u201C gel\xF6scht",
|
|
172
175
|
toastPublished: "Ansicht \u201E{name}\u201C ver\xF6ffentlicht",
|
|
@@ -273,7 +276,7 @@ var de = {
|
|
|
273
276
|
exportDownload: "Herunterladen",
|
|
274
277
|
exportCopy: "Kopieren",
|
|
275
278
|
exportXlsx: "Excel-Arbeitsmappe (.xlsx)",
|
|
276
|
-
exportCsv: "CSV
|
|
279
|
+
exportCsv: "Tabelle als CSV (.csv)",
|
|
277
280
|
exportPng: "Diagramm als Bild (.png)",
|
|
278
281
|
exportSvg: "Diagramm als Bild (.svg)",
|
|
279
282
|
exportHtml: "HTML-Bericht (.html)",
|
|
@@ -281,6 +284,9 @@ var de = {
|
|
|
281
284
|
exportPrint: "Drucken oder als PDF speichern\u2026",
|
|
282
285
|
exportPngNeedsChart: "Zuerst zum Diagramm wechseln.",
|
|
283
286
|
exportNeedsField: "Zuerst ein Feld hinzuf\xFCgen.",
|
|
287
|
+
exportDataGroup: "Quelldaten",
|
|
288
|
+
exportDataCsv: "Alle Zeilen als CSV (.csv)",
|
|
289
|
+
exportDataJson: "Alle Zeilen als JSON (.json)",
|
|
284
290
|
copyTable: "Tabelle kopieren",
|
|
285
291
|
copyDataJson: "Daten als JSON kopieren",
|
|
286
292
|
toastTableCopied: "Tabelle kopiert: tabulatorgetrennt, wird in Excel oder Google Sheets in Spalten eingef\xFCgt",
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
mergeLabels,
|
|
5
5
|
messageOf,
|
|
6
6
|
plural
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-XN5HNKJ2.js";
|
|
8
8
|
|
|
9
9
|
// src/import-labels.js
|
|
10
10
|
var en = {
|
|
@@ -47,8 +47,18 @@ var en = {
|
|
|
47
47
|
overLimit: "it has more than {max} {what} ({key}): load a smaller extract of it, or a host can raise this limit",
|
|
48
48
|
// the limits a reader stops a file at (archiveEntries and unpackedBytes: pivotkit-xlsx's ZIP checks)
|
|
49
49
|
limitWhat: { rows: "rows", columns: "columns", fileBytes: "bytes", importCells: "values (rows x columns)", archiveEntries: "parts in its ZIP directory", unpackedBytes: "bytes unpacked" },
|
|
50
|
+
// importCells reached by a workbook's shared strings and formats (pivotkit-xlsx's details.what),
|
|
51
|
+
// not by its rows x columns
|
|
52
|
+
workbookCells: "different texts and formats",
|
|
50
53
|
sourceLine: "{name}, only in this browser",
|
|
51
54
|
sourceSheet: "{name}, sheet \u201C{sheet}\u201D, only in this browser",
|
|
55
|
+
// a saved view made on a workbook's sheet that the workbook loaded now does not have (it loads on the sheet shown)
|
|
56
|
+
sheetMissing: "\u201C{name}\u201D was made for the sheet \u201C{sheet}\u201D, which {file} does not have.",
|
|
57
|
+
// the host refused the sheet a saved view was made on (onDataLoad): the view is not opened
|
|
58
|
+
sheetRefused: "\u201C{name}\u201D was not opened: the sheet \u201C{sheet}\u201D was not loaded.",
|
|
59
|
+
// the preview of a sheet a saved view needs: which view and sheet; another sheet loaded there does not open the view
|
|
60
|
+
sheetForView: "Opening \u201C{name}\u201D needs the sheet \u201C{sheet}\u201D.",
|
|
61
|
+
sheetOther: "\u201C{name}\u201D was not opened: it was made for the sheet \u201C{sheet}\u201D.",
|
|
52
62
|
notes: {
|
|
53
63
|
ENCODING: "Read as {encoding}.",
|
|
54
64
|
SEPARATOR: "Values separated by {name}.",
|
|
@@ -109,8 +119,13 @@ var de = {
|
|
|
109
119
|
refused: "{name} wurde nicht geladen: {message}",
|
|
110
120
|
overLimit: "sie hat mehr als {max} {what} ({key}): eine kleinere Auswahl daraus laden, oder eine Anwendung kann diese Grenze anheben",
|
|
111
121
|
limitWhat: { rows: "Zeilen", columns: "Spalten", fileBytes: "Bytes", importCells: "Werte (Zeilen x Spalten)", archiveEntries: "Teile in ihrem ZIP-Verzeichnis", unpackedBytes: "entpackte Bytes" },
|
|
122
|
+
workbookCells: "verschiedene Texte und Formate",
|
|
112
123
|
sourceLine: "{name}, nur in diesem Browser",
|
|
113
124
|
sourceSheet: "{name}, Blatt \u201E{sheet}\u201C, nur in diesem Browser",
|
|
125
|
+
sheetMissing: "\u201E{name}\u201C wurde f\xFCr das Blatt \u201E{sheet}\u201C gemacht, das {file} nicht hat.",
|
|
126
|
+
sheetRefused: "\u201E{name}\u201C wurde nicht ge\xF6ffnet: das Blatt \u201E{sheet}\u201C wurde nicht geladen.",
|
|
127
|
+
sheetForView: "Zum \xD6ffnen von \u201E{name}\u201C wird das Blatt \u201E{sheet}\u201C gebraucht.",
|
|
128
|
+
sheetOther: "\u201E{name}\u201C wurde nicht ge\xF6ffnet: es wurde f\xFCr das Blatt \u201E{sheet}\u201C gemacht.",
|
|
114
129
|
notes: {
|
|
115
130
|
ENCODING: "Gelesen als {encoding}.",
|
|
116
131
|
SEPARATOR: "Werte getrennt durch {name}.",
|
|
@@ -192,10 +207,13 @@ function errorText(error, name, texts, where) {
|
|
|
192
207
|
);
|
|
193
208
|
const d = e && typeof e === "object" && e.code === "LIMIT_EXCEEDED" && e.details && typeof e.details === "object" ? e.details : null;
|
|
194
209
|
if (d && typeof d.limit === "string" && Object.hasOwn(texts.limitWhat, d.limit) && typeof d.max === "number") {
|
|
195
|
-
|
|
210
|
+
const counted = typeof d.what === "string" ? d.what : "";
|
|
211
|
+
const strings = d.limit === "importCells" && /shared strings/i.test(counted);
|
|
212
|
+
const what = strings ? texts.workbookCells : (
|
|
196
213
|
/** @type {any} */
|
|
197
214
|
texts.limitWhat[d.limit]
|
|
198
|
-
)
|
|
215
|
+
);
|
|
216
|
+
return fill(texts.overLimit, { max: d.max.toLocaleString(where.locale), what, key: `limits.${d.limit}` });
|
|
199
217
|
}
|
|
200
218
|
const text = messageOf(error);
|
|
201
219
|
for (const prefix of [`"${name}": `, `"${name}" `]) {
|
package/dist/import-ui.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
sheetPlan
|
|
3
|
+
} from "./chunks/chunk-W2KIPREL.js";
|
|
1
4
|
import {
|
|
2
5
|
Group,
|
|
3
6
|
Icon,
|
|
@@ -7,17 +10,17 @@ import {
|
|
|
7
10
|
useFormName,
|
|
8
11
|
useModal,
|
|
9
12
|
useTopLayer
|
|
10
|
-
} from "./chunks/chunk-
|
|
13
|
+
} from "./chunks/chunk-JOWAEZAD.js";
|
|
11
14
|
import {
|
|
12
15
|
errorText,
|
|
13
16
|
importLabels,
|
|
14
17
|
noteText
|
|
15
|
-
} from "./chunks/chunk-
|
|
18
|
+
} from "./chunks/chunk-ZK5RVCHP.js";
|
|
16
19
|
import {
|
|
17
20
|
fill,
|
|
18
21
|
messageOf,
|
|
19
22
|
plural
|
|
20
|
-
} from "./chunks/chunk-
|
|
23
|
+
} from "./chunks/chunk-XN5HNKJ2.js";
|
|
21
24
|
|
|
22
25
|
// src/import-host.jsx
|
|
23
26
|
import React2 from "react";
|
|
@@ -26,7 +29,7 @@ import React2 from "react";
|
|
|
26
29
|
import React, { useContext, useEffect, useId, useMemo, useRef, useState } from "react";
|
|
27
30
|
import { createPortal } from "react-dom";
|
|
28
31
|
import { encode } from "pivotkit-core";
|
|
29
|
-
import { IMPORT_TYPES, fileName, retype } from "pivotkit-core/import";
|
|
32
|
+
import { IMPORT_TYPES, fileName, retype, shownName, sourceIdOf } from "pivotkit-core/import";
|
|
30
33
|
|
|
31
34
|
// src/import-run.js
|
|
32
35
|
import { PivotkitError } from "pivotkit-core";
|
|
@@ -44,18 +47,6 @@ function acceptOf(plugins) {
|
|
|
44
47
|
}
|
|
45
48
|
var formatsOf = (plugins, names = {}) => [...plugins, ...BUILT_IN_READERS].map((p) => typeof p?.name === "string" && Object.hasOwn(names, p.name) ? names[p.name] : typeof p?.label === "string" ? p.label.trim().slice(0, 100) : "").filter((t, i, all) => t && all.indexOf(t) === i);
|
|
46
49
|
var WORKER_READY_MS = 1e4;
|
|
47
|
-
function completeTable(table) {
|
|
48
|
-
const n = table.data[0]?.length ?? 0;
|
|
49
|
-
const same = (list) => Array.isArray(list) && list.length === table.columns.length;
|
|
50
|
-
return {
|
|
51
|
-
...table,
|
|
52
|
-
rowCount: Number.isInteger(table.rowCount) && table.rowCount >= 0 ? table.rowCount : n,
|
|
53
|
-
raw: same(table.raw) && table.raw.every((c) => Array.isArray(c) && c.length === n) ? table.raw : table.data,
|
|
54
|
-
detected: same(table.detected) ? table.detected : table.types,
|
|
55
|
-
hints: table.hints && typeof table.hints === "object" ? table.hints : { decimal: ".", dateOrder: "dmy" },
|
|
56
|
-
notes: table.notes.filter((x) => x && typeof x.code === "string").map((x) => ({ code: x.code, params: x.params && typeof x.params === "object" ? x.params : {}, message: String(x.message ?? x.code) }))
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
50
|
var isTable = (t) => t !== null && typeof t === "object" && Array.isArray(t.columns) && Array.isArray(t.types) && Array.isArray(t.data) && Array.isArray(t.notes);
|
|
60
51
|
var aborted = (signal) => signal?.reason ?? new DOMException("The read was cancelled", "AbortError");
|
|
61
52
|
var UNAVAILABLE = /* @__PURE__ */ Symbol("worker unavailable");
|
|
@@ -138,11 +129,11 @@ async function readImport(file, { plugins = [], worker, sheet, locale, limits, s
|
|
|
138
129
|
if (worker && reader && BUILT_IN_READERS.includes(reader)) {
|
|
139
130
|
const table = await inWorker(worker, file, plain, signal, onProgress, readyMs);
|
|
140
131
|
if (table !== UNAVAILABLE) {
|
|
141
|
-
return
|
|
132
|
+
return table;
|
|
142
133
|
}
|
|
143
134
|
}
|
|
144
135
|
signal?.throwIfAborted();
|
|
145
|
-
return
|
|
136
|
+
return readFile(file, { ...plain, plugins, signal, onProgress });
|
|
146
137
|
}
|
|
147
138
|
async function sheetsOf(file, { plugins = [], limits, signal } = {}) {
|
|
148
139
|
const reader = readerFor(file, plugins);
|
|
@@ -157,148 +148,6 @@ async function sheetsOf(file, { plugins = [], limits, signal } = {}) {
|
|
|
157
148
|
return Array.isArray(list) ? list.filter((s) => s && typeof s.name === "string" && Number.isInteger(s.index)) : [];
|
|
158
149
|
}
|
|
159
150
|
|
|
160
|
-
// src/import-source.js
|
|
161
|
-
var SHOWN_MAX = 120;
|
|
162
|
-
function shownName(name) {
|
|
163
|
-
if (name.length <= SHOWN_MAX) {
|
|
164
|
-
return name;
|
|
165
|
-
}
|
|
166
|
-
let cut = SHOWN_MAX - 3;
|
|
167
|
-
const code = name.charCodeAt(cut - 1);
|
|
168
|
-
if (code >= 55296 && code <= 56319) {
|
|
169
|
-
cut -= 1;
|
|
170
|
-
}
|
|
171
|
-
return `${name.slice(0, cut)}...`;
|
|
172
|
-
}
|
|
173
|
-
var K = new Uint32Array([
|
|
174
|
-
1116352408,
|
|
175
|
-
1899447441,
|
|
176
|
-
3049323471,
|
|
177
|
-
3921009573,
|
|
178
|
-
961987163,
|
|
179
|
-
1508970993,
|
|
180
|
-
2453635748,
|
|
181
|
-
2870763221,
|
|
182
|
-
3624381080,
|
|
183
|
-
310598401,
|
|
184
|
-
607225278,
|
|
185
|
-
1426881987,
|
|
186
|
-
1925078388,
|
|
187
|
-
2162078206,
|
|
188
|
-
2614888103,
|
|
189
|
-
3248222580,
|
|
190
|
-
3835390401,
|
|
191
|
-
4022224774,
|
|
192
|
-
264347078,
|
|
193
|
-
604807628,
|
|
194
|
-
770255983,
|
|
195
|
-
1249150122,
|
|
196
|
-
1555081692,
|
|
197
|
-
1996064986,
|
|
198
|
-
2554220882,
|
|
199
|
-
2821834349,
|
|
200
|
-
2952996808,
|
|
201
|
-
3210313671,
|
|
202
|
-
3336571891,
|
|
203
|
-
3584528711,
|
|
204
|
-
113926993,
|
|
205
|
-
338241895,
|
|
206
|
-
666307205,
|
|
207
|
-
773529912,
|
|
208
|
-
1294757372,
|
|
209
|
-
1396182291,
|
|
210
|
-
1695183700,
|
|
211
|
-
1986661051,
|
|
212
|
-
2177026350,
|
|
213
|
-
2456956037,
|
|
214
|
-
2730485921,
|
|
215
|
-
2820302411,
|
|
216
|
-
3259730800,
|
|
217
|
-
3345764771,
|
|
218
|
-
3516065817,
|
|
219
|
-
3600352804,
|
|
220
|
-
4094571909,
|
|
221
|
-
275423344,
|
|
222
|
-
430227734,
|
|
223
|
-
506948616,
|
|
224
|
-
659060556,
|
|
225
|
-
883997877,
|
|
226
|
-
958139571,
|
|
227
|
-
1322822218,
|
|
228
|
-
1537002063,
|
|
229
|
-
1747873779,
|
|
230
|
-
1955562222,
|
|
231
|
-
2024104815,
|
|
232
|
-
2227730452,
|
|
233
|
-
2361852424,
|
|
234
|
-
2428436474,
|
|
235
|
-
2756734187,
|
|
236
|
-
3204031479,
|
|
237
|
-
3329325298
|
|
238
|
-
]);
|
|
239
|
-
function sha256Bytes(bytes) {
|
|
240
|
-
const bits = bytes.length * 8;
|
|
241
|
-
const padded = new Uint8Array(Math.ceil((bytes.length + 9) / 64) * 64);
|
|
242
|
-
padded.set(bytes);
|
|
243
|
-
padded[bytes.length] = 128;
|
|
244
|
-
const view = new DataView(padded.buffer);
|
|
245
|
-
view.setUint32(padded.length - 8, Math.floor(bits / 2 ** 32));
|
|
246
|
-
view.setUint32(padded.length - 4, bits >>> 0);
|
|
247
|
-
const h = new Uint32Array([1779033703, 3144134277, 1013904242, 2773480762, 1359893119, 2600822924, 528734635, 1541459225]);
|
|
248
|
-
const w = new Uint32Array(64);
|
|
249
|
-
const rotr = (x, n) => x >>> n | x << 32 - n;
|
|
250
|
-
for (let at = 0; at < padded.length; at += 64) {
|
|
251
|
-
for (let i = 0; i < 16; i++) {
|
|
252
|
-
w[i] = view.getUint32(at + i * 4);
|
|
253
|
-
}
|
|
254
|
-
for (let i = 16; i < 64; i++) {
|
|
255
|
-
const s0 = rotr(w[i - 15], 7) ^ rotr(w[i - 15], 18) ^ w[i - 15] >>> 3;
|
|
256
|
-
const s1 = rotr(w[i - 2], 17) ^ rotr(w[i - 2], 19) ^ w[i - 2] >>> 10;
|
|
257
|
-
w[i] = w[i - 16] + s0 + w[i - 7] + s1 >>> 0;
|
|
258
|
-
}
|
|
259
|
-
let [a, b, c, d, e, f, g, hh] = h;
|
|
260
|
-
for (let i = 0; i < 64; i++) {
|
|
261
|
-
const t1 = hh + (rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25)) + (e & f ^ ~e & g) + K[i] + w[i] >>> 0;
|
|
262
|
-
const t2 = (rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22)) + (a & b ^ a & c ^ b & c) >>> 0;
|
|
263
|
-
hh = g;
|
|
264
|
-
g = f;
|
|
265
|
-
f = e;
|
|
266
|
-
e = d + t1 >>> 0;
|
|
267
|
-
d = c;
|
|
268
|
-
c = b;
|
|
269
|
-
b = a;
|
|
270
|
-
a = t1 + t2 >>> 0;
|
|
271
|
-
}
|
|
272
|
-
h[0] += a;
|
|
273
|
-
h[1] += b;
|
|
274
|
-
h[2] += c;
|
|
275
|
-
h[3] += d;
|
|
276
|
-
h[4] += e;
|
|
277
|
-
h[5] += f;
|
|
278
|
-
h[6] += g;
|
|
279
|
-
h[7] += hh;
|
|
280
|
-
}
|
|
281
|
-
const out = new Uint8Array(32);
|
|
282
|
-
const outView = new DataView(out.buffer);
|
|
283
|
-
h.forEach((v, i) => outView.setUint32(i * 4, v));
|
|
284
|
-
return out;
|
|
285
|
-
}
|
|
286
|
-
async function sha256Hex(text, options = {}) {
|
|
287
|
-
const bytes = new TextEncoder().encode(text);
|
|
288
|
-
const subtle = options.subtle !== void 0 ? options.subtle : globalThis.crypto?.subtle;
|
|
289
|
-
let digest;
|
|
290
|
-
try {
|
|
291
|
-
digest = subtle ? new Uint8Array(await subtle.digest("SHA-256", bytes)) : sha256Bytes(bytes);
|
|
292
|
-
} catch {
|
|
293
|
-
digest = sha256Bytes(bytes);
|
|
294
|
-
}
|
|
295
|
-
return [...digest].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
296
|
-
}
|
|
297
|
-
async function sourceIdOf(name, columns, options) {
|
|
298
|
-
const hex = await sha256Hex([name, ...columns].join("\0"), options);
|
|
299
|
-
return `${shownName(name)}#${hex.slice(0, 16)}`;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
151
|
// src/import-ui.jsx
|
|
303
152
|
var PREVIEW_ROWS = 8;
|
|
304
153
|
var PREVIEW_COLUMNS = 60;
|
|
@@ -381,15 +230,15 @@ function ImportDialog({ job, labels, locale, plugins, worker, limits, timeZone,
|
|
|
381
230
|
const file = job.file;
|
|
382
231
|
const name = useMemo(() => fileName(file, {}), [file]);
|
|
383
232
|
const [sheet, setSheet] = useState(
|
|
384
|
-
/** @type {number | undefined} */
|
|
385
|
-
|
|
233
|
+
/** @type {number | string | undefined} */
|
|
234
|
+
job.sheet
|
|
386
235
|
);
|
|
387
236
|
const [sheets, setSheets] = useState(
|
|
388
237
|
/** @type {import("pivotkit-core/import").SheetInfo[]} */
|
|
389
238
|
[]
|
|
390
239
|
);
|
|
391
240
|
const [read, setRead] = useState(
|
|
392
|
-
/** @type {{ table: import("pivotkit-core/import").ImportTable, sheet: number | undefined } | null} */
|
|
241
|
+
/** @type {{ table: import("pivotkit-core/import").ImportTable, sheet: number | string | undefined } | null} */
|
|
393
242
|
null
|
|
394
243
|
);
|
|
395
244
|
const [types, setTypes] = useState(
|
|
@@ -406,7 +255,7 @@ function ImportDialog({ job, labels, locale, plugins, worker, limits, timeZone,
|
|
|
406
255
|
);
|
|
407
256
|
const [busy, setBusy] = useState(false);
|
|
408
257
|
const [failed, setFailed] = useState(
|
|
409
|
-
/** @type {number | undefined | null} */
|
|
258
|
+
/** @type {number | string | undefined | null} */
|
|
410
259
|
null
|
|
411
260
|
);
|
|
412
261
|
const current = read && read.sheet === sheet ? read : null;
|
|
@@ -510,7 +359,7 @@ function ImportDialog({ job, labels, locale, plugins, worker, limits, timeZone,
|
|
|
510
359
|
const n = shown?.notes.find((x) => x.code === "SHEET");
|
|
511
360
|
return n && n.params?.sheet !== void 0 ? String(n.params.sheet) : null;
|
|
512
361
|
})();
|
|
513
|
-
const sheetIndex = sheet
|
|
362
|
+
const sheetIndex = typeof sheet === "number" ? sheet : sheets.find((s) => s.name === sheetName)?.index ?? 0;
|
|
514
363
|
const apply = async () => {
|
|
515
364
|
if (!shown || busy) {
|
|
516
365
|
return;
|
|
@@ -528,6 +377,8 @@ function ImportDialog({ job, labels, locale, plugins, worker, limits, timeZone,
|
|
|
528
377
|
source: { id, name: shownName(name) },
|
|
529
378
|
file: { name, size: file.size, type: file.type },
|
|
530
379
|
sheet: sheetName,
|
|
380
|
+
sheets: sheets.map((s) => s.name),
|
|
381
|
+
blob: file,
|
|
531
382
|
rows: shown.rowCount,
|
|
532
383
|
columns: shown.columns.map((c, i) => ({ name: c, type: shown.types[i] })),
|
|
533
384
|
notes: shown.notes.map((n) => ({ code: n.code, params: { ...n.params }, message: n.message }))
|
|
@@ -539,6 +390,13 @@ function ImportDialog({ job, labels, locale, plugins, worker, limits, timeZone,
|
|
|
539
390
|
}
|
|
540
391
|
}
|
|
541
392
|
};
|
|
393
|
+
const autoDone = useRef(false);
|
|
394
|
+
useEffect(() => {
|
|
395
|
+
if (job.auto && sheet === job.sheet && ready && shown && shown.rowCount > 0 && !typed.error && shown.notes.every((n) => n.code === "SHEET") && !autoDone.current) {
|
|
396
|
+
autoDone.current = true;
|
|
397
|
+
void apply();
|
|
398
|
+
}
|
|
399
|
+
});
|
|
542
400
|
if (!layer) {
|
|
543
401
|
return null;
|
|
544
402
|
}
|
|
@@ -555,7 +413,7 @@ function ImportDialog({ job, labels, locale, plugins, worker, limits, timeZone,
|
|
|
555
413
|
const percent = progress && progress.total > 0 ? Math.min(100, Math.round(progress.done / progress.total * 100)) : null;
|
|
556
414
|
const meta = shown && !reading ? `${plural(t.rows, shown.rowCount, where)} \xB7 ${plural(t.columns, shown.columns.length, where)} \xB7 ${sizeText(file.size, locale)}` : sizeText(file.size, locale);
|
|
557
415
|
return createPortal(
|
|
558
|
-
/* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { ref: scrim, ...inTop, className: "pk-scrim pk-import-scrim", "aria-hidden": "true" }), /* @__PURE__ */ React.createElement("div", { ref: box, ...inTop, className: "pk-import", role: "dialog", "aria-modal": "true", "aria-labelledby": titleId, "aria-describedby": shown && shown.notes.length ? `${metaId} ${notesId}` : metaId, "aria-busy": reading || void 0, tabIndex: -1, onKeyDown, "data-testid": "import-dialog" }, /* @__PURE__ */ React.createElement("div", { className: "pk-drill-head" }, /* @__PURE__ */ React.createElement("div", { className: "pk-drill-heading" }, /* @__PURE__ */ React.createElement("h2", { id: titleId }, fill(t.previewTitle, { name })), /* @__PURE__ */ React.createElement("p", { id: metaId, className: "pk-hint", role: "status", "data-testid": "import-meta" }, meta))), /* @__PURE__ */ React.createElement("div", { className: "pk-import-body" }, sheets.length > 1 ? /* @__PURE__ */ React.createElement("label", { className: "pk-inline-form" }, t.sheet, /* @__PURE__ */ React.createElement("select", { name: `${formName}-sheet`, value: sheetIndex, onChange: (e) => {
|
|
416
|
+
/* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { ref: scrim, ...inTop, className: "pk-scrim pk-import-scrim", "aria-hidden": "true" }), /* @__PURE__ */ React.createElement("div", { ref: box, ...inTop, className: "pk-import", role: "dialog", "aria-modal": "true", "aria-labelledby": titleId, "aria-describedby": shown && shown.notes.length ? `${metaId} ${notesId}` : metaId, "aria-busy": reading || void 0, tabIndex: -1, onKeyDown, "data-testid": "import-dialog" }, /* @__PURE__ */ React.createElement("div", { className: "pk-drill-head" }, /* @__PURE__ */ React.createElement("div", { className: "pk-drill-heading" }, /* @__PURE__ */ React.createElement("h2", { id: titleId }, fill(t.previewTitle, { name })), /* @__PURE__ */ React.createElement("p", { id: metaId, className: "pk-hint", role: "status", "data-testid": "import-meta" }, meta))), /* @__PURE__ */ React.createElement("div", { className: "pk-import-body" }, job.view && job.sheet ? /* @__PURE__ */ React.createElement("p", { className: "pk-hint", "data-testid": "import-for-view" }, fill(t.sheetForView, { name: job.view, sheet: job.sheet })) : null, sheets.length > 1 ? /* @__PURE__ */ React.createElement("label", { className: "pk-inline-form" }, t.sheet, /* @__PURE__ */ React.createElement("select", { name: `${formName}-sheet`, value: sheetIndex, onChange: (e) => {
|
|
559
417
|
setProgress(null);
|
|
560
418
|
setError(null);
|
|
561
419
|
setFailed(null);
|
|
@@ -638,7 +496,7 @@ function tell(ctx, detail) {
|
|
|
638
496
|
}
|
|
639
497
|
}
|
|
640
498
|
function loadData(ctx, loaded) {
|
|
641
|
-
const data = { key: ++keys, encoded: loaded.encoded, source: loaded.source, sheet: loaded.sheet, file: loaded.file };
|
|
499
|
+
const data = { key: ++keys, encoded: loaded.encoded, source: loaded.source, sheet: loaded.sheet, sheets: loaded.sheets, blob: loaded.blob, file: loaded.file };
|
|
642
500
|
const t = importLabels(ctx.labels);
|
|
643
501
|
const told = tell(ctx, describe(ctx, data, "load", loaded.notes));
|
|
644
502
|
if (told.refused) {
|
|
@@ -694,17 +552,46 @@ function sayError(api, text) {
|
|
|
694
552
|
}
|
|
695
553
|
}
|
|
696
554
|
function startFiles(api, files) {
|
|
697
|
-
|
|
698
|
-
if (typeof dismiss === "function") {
|
|
699
|
-
(shownErrors.get(dismiss) ?? []).forEach((id) => dismiss(id));
|
|
700
|
-
shownErrors.delete(dismiss);
|
|
701
|
-
}
|
|
555
|
+
closeErrors(api);
|
|
702
556
|
if (files.length === 1) {
|
|
703
557
|
api.setJob({ file: files[0], n: ++jobs });
|
|
704
558
|
} else if (files.length > 1) {
|
|
705
559
|
sayError(api, importLabels(api.labels).dropOne);
|
|
706
560
|
}
|
|
707
561
|
}
|
|
562
|
+
function loadSheet(api, sheet, view, done) {
|
|
563
|
+
const file = api.imported?.blob;
|
|
564
|
+
if (!file) {
|
|
565
|
+
done(false);
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
closeErrors(api);
|
|
569
|
+
api.setJob({ file, n: ++jobs, sheet, auto: true, view, done });
|
|
570
|
+
}
|
|
571
|
+
function openOnSheet(api, made, name, then) {
|
|
572
|
+
const shown = api.imported;
|
|
573
|
+
const plan = sheetPlan(made, { id: shown?.source.id, sheet: shown?.sheet ?? null, sheets: shown?.sheets ?? [] });
|
|
574
|
+
const t = importLabels(api.labels);
|
|
575
|
+
if (plan.kind === "switch") {
|
|
576
|
+
api.afterData(null);
|
|
577
|
+
loadSheet(api, plan.sheet, name, (loaded, refused, other) => {
|
|
578
|
+
api.afterData(loaded ? then : null);
|
|
579
|
+
if (refused || other) {
|
|
580
|
+
sayError(api, fill(refused ? t.sheetRefused : t.sheetOther, { name, sheet: plan.sheet }));
|
|
581
|
+
}
|
|
582
|
+
});
|
|
583
|
+
} else if (plan.kind === "missing") {
|
|
584
|
+
sayError(api, fill(t.sheetMissing, { name, sheet: plan.sheet, file: shown?.file.name ?? "" }));
|
|
585
|
+
}
|
|
586
|
+
return plan.kind;
|
|
587
|
+
}
|
|
588
|
+
function closeErrors(api) {
|
|
589
|
+
const dismiss = api.dismiss;
|
|
590
|
+
if (typeof dismiss === "function") {
|
|
591
|
+
(shownErrors.get(dismiss) ?? []).forEach((id) => dismiss(id));
|
|
592
|
+
shownErrors.delete(dismiss);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
708
595
|
function pickFile(input) {
|
|
709
596
|
if (input) {
|
|
710
597
|
input.value = "";
|
|
@@ -739,10 +626,15 @@ function ImportLayer({ api, input }) {
|
|
|
739
626
|
limits: api.limits,
|
|
740
627
|
timeZone: api.timeZone,
|
|
741
628
|
announce: (text, extra) => extra?.tone === "error" ? sayError(api, text) : api.announce(text, extra),
|
|
742
|
-
onClose: () =>
|
|
629
|
+
onClose: () => {
|
|
630
|
+
api.setJob((j) => j === job ? null : j);
|
|
631
|
+
job.done?.(false);
|
|
632
|
+
},
|
|
743
633
|
onApply: (loaded) => {
|
|
744
|
-
loadData(api, loaded);
|
|
634
|
+
const ok = loadData(api, loaded);
|
|
745
635
|
api.setJob((j) => j === job ? null : j);
|
|
636
|
+
const asked = job.sheet === void 0 || loaded.sheet === job.sheet;
|
|
637
|
+
job.done?.(ok && asked, !ok, ok && !asked);
|
|
746
638
|
}
|
|
747
639
|
}
|
|
748
640
|
) : null);
|
|
@@ -758,7 +650,9 @@ export {
|
|
|
758
650
|
DataMenuPanel,
|
|
759
651
|
ImportLayer,
|
|
760
652
|
SourceLine2 as SourceLine,
|
|
653
|
+
loadSheet,
|
|
761
654
|
moveData,
|
|
655
|
+
openOnSheet,
|
|
762
656
|
pickFile,
|
|
763
657
|
restoreData,
|
|
764
658
|
startFiles
|