pivotkit-react 0.3.0 → 0.4.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.
- package/CHANGELOG.md +121 -1
- package/README.md +1 -1
- package/dist/chunks/{chunk-32Z33U6S.js → chunk-6MDAL3IO.js} +28 -3
- package/dist/chunks/{chunk-APB4NW4O.js → chunk-LEN5RPBM.js} +3 -6
- package/dist/chunks/{chunk-7CC4JHDY.js → chunk-WB4GKWFQ.js} +1 -4
- package/dist/chunks/chunk-XN55BQ4M.js +618 -0
- package/dist/chunks/{chunk-IOPAM4JD.js → chunk-YITKWZ4L.js} +48 -492
- package/dist/chunks/chunk-ZYEYZSYL.js +187 -0
- package/dist/import-ui.js +769 -0
- package/dist/import-worker.js +20 -0
- package/dist/index.js +599 -175
- package/dist/labels.js +14 -10
- package/dist/menu-texts-de.js +1 -1
- package/dist/menus.js +132 -68
- package/dist/styles.css +116 -8
- package/package.json +3 -2
- package/types/data-history.d.ts +85 -0
- package/types/data-keep.d.ts +51 -0
- package/types/data-menu.d.ts +11 -0
- package/types/dom.d.ts +40 -7
- package/types/field-info.d.ts +32 -0
- package/types/import-host.d.ts +53 -0
- package/types/import-labels.d.ts +360 -0
- package/types/import-module.d.ts +2 -0
- package/types/import-run.d.ts +73 -0
- package/types/import-source.d.ts +32 -0
- package/types/import-steps.d.ts +121 -0
- package/types/import-ui.d.ts +108 -0
- package/types/import-worker.d.ts +1 -0
- package/types/index.d.ts +56 -4
- package/types/labels.d.ts +26 -2
- package/types/lazy-import.d.ts +4 -0
- package/types/lazy-menus.d.ts +2 -2
- package/types/levels.d.ts +3 -2
- package/types/menu-labels.d.ts +0 -3
- package/types/menu-topics.d.ts +2 -4
- package/types/menus.d.ts +1 -0
- package/types/overflow.d.ts +29 -17
- package/types/popover.d.ts +47 -5
- package/types/section.d.ts +2 -2
- package/types/toasts.d.ts +1 -1
- package/types/toolbar-panels.d.ts +6 -5
- package/types/unused-keep.d.ts +20 -0
- package/types/unused.d.ts +1 -0
- package/types/use-view-history.d.ts +12 -4
- package/types/virtual.d.ts +15 -0
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
export declare const en: {
|
|
2
|
+
dataSource: string;
|
|
3
|
+
hostData: string;
|
|
4
|
+
rows: {
|
|
5
|
+
one: string;
|
|
6
|
+
other: string;
|
|
7
|
+
};
|
|
8
|
+
columns: {
|
|
9
|
+
one: string;
|
|
10
|
+
other: string;
|
|
11
|
+
};
|
|
12
|
+
fromFile: string;
|
|
13
|
+
load: string;
|
|
14
|
+
loadFile: string;
|
|
15
|
+
backToOriginal: string;
|
|
16
|
+
backHint: string;
|
|
17
|
+
dropHint: string;
|
|
18
|
+
formats: string;
|
|
19
|
+
formatNames: {
|
|
20
|
+
csv: string;
|
|
21
|
+
json: string;
|
|
22
|
+
xlsx: string;
|
|
23
|
+
};
|
|
24
|
+
dropTitle: string;
|
|
25
|
+
dropOne: string;
|
|
26
|
+
reading: string;
|
|
27
|
+
phases: {
|
|
28
|
+
read: string;
|
|
29
|
+
unpack: string;
|
|
30
|
+
parse: string;
|
|
31
|
+
type: string;
|
|
32
|
+
};
|
|
33
|
+
cancel: string;
|
|
34
|
+
previewTitle: string;
|
|
35
|
+
sheet: string;
|
|
36
|
+
hiddenSheet: string;
|
|
37
|
+
firstRows: string;
|
|
38
|
+
someColumns: string;
|
|
39
|
+
typeOf: string;
|
|
40
|
+
types: {
|
|
41
|
+
string: string;
|
|
42
|
+
number: string;
|
|
43
|
+
date: string;
|
|
44
|
+
boolean: string;
|
|
45
|
+
};
|
|
46
|
+
yes: string;
|
|
47
|
+
no: string;
|
|
48
|
+
noRows: string;
|
|
49
|
+
notesTitle: {
|
|
50
|
+
one: string;
|
|
51
|
+
other: string;
|
|
52
|
+
};
|
|
53
|
+
apply: string;
|
|
54
|
+
loaded: string;
|
|
55
|
+
stepLoaded: string;
|
|
56
|
+
originalShown: string;
|
|
57
|
+
failed: string;
|
|
58
|
+
refused: string;
|
|
59
|
+
sourceLine: string;
|
|
60
|
+
sourceSheet: string;
|
|
61
|
+
notes: {
|
|
62
|
+
ENCODING: string;
|
|
63
|
+
SEPARATOR: string;
|
|
64
|
+
LINES_SKIPPED: {
|
|
65
|
+
one: string;
|
|
66
|
+
other: string;
|
|
67
|
+
};
|
|
68
|
+
COLUMN_RENAMED: string;
|
|
69
|
+
COLUMN_UNNAMED: string;
|
|
70
|
+
COLUMNS_RENAMED_MORE: {
|
|
71
|
+
one: string;
|
|
72
|
+
other: string;
|
|
73
|
+
};
|
|
74
|
+
COLUMN_DROPPED: string;
|
|
75
|
+
COLUMNS_ADDED: {
|
|
76
|
+
one: string;
|
|
77
|
+
other: string;
|
|
78
|
+
};
|
|
79
|
+
ROWS_EMPTY: {
|
|
80
|
+
one: string;
|
|
81
|
+
other: string;
|
|
82
|
+
};
|
|
83
|
+
TEXT_CUT: {
|
|
84
|
+
one: string;
|
|
85
|
+
other: string;
|
|
86
|
+
};
|
|
87
|
+
CHARACTERS_REMOVED: {
|
|
88
|
+
one: string;
|
|
89
|
+
other: string;
|
|
90
|
+
};
|
|
91
|
+
DATE_ORDER: string;
|
|
92
|
+
VALUES_NOT_CONVERTED: {
|
|
93
|
+
one: string;
|
|
94
|
+
other: string;
|
|
95
|
+
};
|
|
96
|
+
JSON_PROPERTY: string;
|
|
97
|
+
JSON_FLATTENED: string;
|
|
98
|
+
SHEET: string;
|
|
99
|
+
SHEETS: string;
|
|
100
|
+
USED_RANGE: string;
|
|
101
|
+
ERROR_CELLS: {
|
|
102
|
+
one: string;
|
|
103
|
+
other: string;
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
dateOrders: {
|
|
107
|
+
dmy: string;
|
|
108
|
+
mdy: string;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
export type ImportTexts = typeof en;
|
|
112
|
+
/** @typedef {typeof en} ImportTexts */
|
|
113
|
+
/** @type {ImportTexts} */
|
|
114
|
+
export declare const de: ImportTexts;
|
|
115
|
+
/** The import texts of each language. */
|
|
116
|
+
export declare const IMPORT_TEXTS: Readonly<{
|
|
117
|
+
en: {
|
|
118
|
+
dataSource: string;
|
|
119
|
+
hostData: string;
|
|
120
|
+
rows: {
|
|
121
|
+
one: string;
|
|
122
|
+
other: string;
|
|
123
|
+
};
|
|
124
|
+
columns: {
|
|
125
|
+
one: string;
|
|
126
|
+
other: string;
|
|
127
|
+
};
|
|
128
|
+
fromFile: string;
|
|
129
|
+
load: string;
|
|
130
|
+
loadFile: string;
|
|
131
|
+
backToOriginal: string;
|
|
132
|
+
backHint: string;
|
|
133
|
+
dropHint: string;
|
|
134
|
+
formats: string;
|
|
135
|
+
formatNames: {
|
|
136
|
+
csv: string;
|
|
137
|
+
json: string;
|
|
138
|
+
xlsx: string;
|
|
139
|
+
};
|
|
140
|
+
dropTitle: string;
|
|
141
|
+
dropOne: string;
|
|
142
|
+
reading: string;
|
|
143
|
+
phases: {
|
|
144
|
+
read: string;
|
|
145
|
+
unpack: string;
|
|
146
|
+
parse: string;
|
|
147
|
+
type: string;
|
|
148
|
+
};
|
|
149
|
+
cancel: string;
|
|
150
|
+
previewTitle: string;
|
|
151
|
+
sheet: string;
|
|
152
|
+
hiddenSheet: string;
|
|
153
|
+
firstRows: string;
|
|
154
|
+
someColumns: string;
|
|
155
|
+
typeOf: string;
|
|
156
|
+
types: {
|
|
157
|
+
string: string;
|
|
158
|
+
number: string;
|
|
159
|
+
date: string;
|
|
160
|
+
boolean: string;
|
|
161
|
+
};
|
|
162
|
+
yes: string;
|
|
163
|
+
no: string;
|
|
164
|
+
noRows: string;
|
|
165
|
+
notesTitle: {
|
|
166
|
+
one: string;
|
|
167
|
+
other: string;
|
|
168
|
+
};
|
|
169
|
+
apply: string;
|
|
170
|
+
loaded: string;
|
|
171
|
+
stepLoaded: string;
|
|
172
|
+
originalShown: string;
|
|
173
|
+
failed: string;
|
|
174
|
+
refused: string;
|
|
175
|
+
sourceLine: string;
|
|
176
|
+
sourceSheet: string;
|
|
177
|
+
notes: {
|
|
178
|
+
ENCODING: string;
|
|
179
|
+
SEPARATOR: string;
|
|
180
|
+
LINES_SKIPPED: {
|
|
181
|
+
one: string;
|
|
182
|
+
other: string;
|
|
183
|
+
};
|
|
184
|
+
COLUMN_RENAMED: string;
|
|
185
|
+
COLUMN_UNNAMED: string;
|
|
186
|
+
COLUMNS_RENAMED_MORE: {
|
|
187
|
+
one: string;
|
|
188
|
+
other: string;
|
|
189
|
+
};
|
|
190
|
+
COLUMN_DROPPED: string;
|
|
191
|
+
COLUMNS_ADDED: {
|
|
192
|
+
one: string;
|
|
193
|
+
other: string;
|
|
194
|
+
};
|
|
195
|
+
ROWS_EMPTY: {
|
|
196
|
+
one: string;
|
|
197
|
+
other: string;
|
|
198
|
+
};
|
|
199
|
+
TEXT_CUT: {
|
|
200
|
+
one: string;
|
|
201
|
+
other: string;
|
|
202
|
+
};
|
|
203
|
+
CHARACTERS_REMOVED: {
|
|
204
|
+
one: string;
|
|
205
|
+
other: string;
|
|
206
|
+
};
|
|
207
|
+
DATE_ORDER: string;
|
|
208
|
+
VALUES_NOT_CONVERTED: {
|
|
209
|
+
one: string;
|
|
210
|
+
other: string;
|
|
211
|
+
};
|
|
212
|
+
JSON_PROPERTY: string;
|
|
213
|
+
JSON_FLATTENED: string;
|
|
214
|
+
SHEET: string;
|
|
215
|
+
SHEETS: string;
|
|
216
|
+
USED_RANGE: string;
|
|
217
|
+
ERROR_CELLS: {
|
|
218
|
+
one: string;
|
|
219
|
+
other: string;
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
dateOrders: {
|
|
223
|
+
dmy: string;
|
|
224
|
+
mdy: string;
|
|
225
|
+
};
|
|
226
|
+
};
|
|
227
|
+
de: {
|
|
228
|
+
dataSource: string;
|
|
229
|
+
hostData: string;
|
|
230
|
+
rows: {
|
|
231
|
+
one: string;
|
|
232
|
+
other: string;
|
|
233
|
+
};
|
|
234
|
+
columns: {
|
|
235
|
+
one: string;
|
|
236
|
+
other: string;
|
|
237
|
+
};
|
|
238
|
+
fromFile: string;
|
|
239
|
+
load: string;
|
|
240
|
+
loadFile: string;
|
|
241
|
+
backToOriginal: string;
|
|
242
|
+
backHint: string;
|
|
243
|
+
dropHint: string;
|
|
244
|
+
formats: string;
|
|
245
|
+
formatNames: {
|
|
246
|
+
csv: string;
|
|
247
|
+
json: string;
|
|
248
|
+
xlsx: string;
|
|
249
|
+
};
|
|
250
|
+
dropTitle: string;
|
|
251
|
+
dropOne: string;
|
|
252
|
+
reading: string;
|
|
253
|
+
phases: {
|
|
254
|
+
read: string;
|
|
255
|
+
unpack: string;
|
|
256
|
+
parse: string;
|
|
257
|
+
type: string;
|
|
258
|
+
};
|
|
259
|
+
cancel: string;
|
|
260
|
+
previewTitle: string;
|
|
261
|
+
sheet: string;
|
|
262
|
+
hiddenSheet: string;
|
|
263
|
+
firstRows: string;
|
|
264
|
+
someColumns: string;
|
|
265
|
+
typeOf: string;
|
|
266
|
+
types: {
|
|
267
|
+
string: string;
|
|
268
|
+
number: string;
|
|
269
|
+
date: string;
|
|
270
|
+
boolean: string;
|
|
271
|
+
};
|
|
272
|
+
yes: string;
|
|
273
|
+
no: string;
|
|
274
|
+
noRows: string;
|
|
275
|
+
notesTitle: {
|
|
276
|
+
one: string;
|
|
277
|
+
other: string;
|
|
278
|
+
};
|
|
279
|
+
apply: string;
|
|
280
|
+
loaded: string;
|
|
281
|
+
stepLoaded: string;
|
|
282
|
+
originalShown: string;
|
|
283
|
+
failed: string;
|
|
284
|
+
refused: string;
|
|
285
|
+
sourceLine: string;
|
|
286
|
+
sourceSheet: string;
|
|
287
|
+
notes: {
|
|
288
|
+
ENCODING: string;
|
|
289
|
+
SEPARATOR: string;
|
|
290
|
+
LINES_SKIPPED: {
|
|
291
|
+
one: string;
|
|
292
|
+
other: string;
|
|
293
|
+
};
|
|
294
|
+
COLUMN_RENAMED: string;
|
|
295
|
+
COLUMN_UNNAMED: string;
|
|
296
|
+
COLUMNS_RENAMED_MORE: {
|
|
297
|
+
one: string;
|
|
298
|
+
other: string;
|
|
299
|
+
};
|
|
300
|
+
COLUMN_DROPPED: string;
|
|
301
|
+
COLUMNS_ADDED: {
|
|
302
|
+
one: string;
|
|
303
|
+
other: string;
|
|
304
|
+
};
|
|
305
|
+
ROWS_EMPTY: {
|
|
306
|
+
one: string;
|
|
307
|
+
other: string;
|
|
308
|
+
};
|
|
309
|
+
TEXT_CUT: {
|
|
310
|
+
one: string;
|
|
311
|
+
other: string;
|
|
312
|
+
};
|
|
313
|
+
CHARACTERS_REMOVED: {
|
|
314
|
+
one: string;
|
|
315
|
+
other: string;
|
|
316
|
+
};
|
|
317
|
+
DATE_ORDER: string;
|
|
318
|
+
VALUES_NOT_CONVERTED: {
|
|
319
|
+
one: string;
|
|
320
|
+
other: string;
|
|
321
|
+
};
|
|
322
|
+
JSON_PROPERTY: string;
|
|
323
|
+
JSON_FLATTENED: string;
|
|
324
|
+
SHEET: string;
|
|
325
|
+
SHEETS: string;
|
|
326
|
+
USED_RANGE: string;
|
|
327
|
+
ERROR_CELLS: {
|
|
328
|
+
one: string;
|
|
329
|
+
other: string;
|
|
330
|
+
};
|
|
331
|
+
};
|
|
332
|
+
dateOrders: {
|
|
333
|
+
dmy: string;
|
|
334
|
+
mdy: string;
|
|
335
|
+
};
|
|
336
|
+
};
|
|
337
|
+
}>;
|
|
338
|
+
/**
|
|
339
|
+
* The import texts of the report's language (English for a language of a host's own), a host's own
|
|
340
|
+
* texts (`labels.dataImport`, kept aside by resolveLabels) merged over them.
|
|
341
|
+
* @param {import("./labels.js").UiLabels} labels
|
|
342
|
+
* @returns {ImportTexts}
|
|
343
|
+
*/
|
|
344
|
+
export declare function importLabels(labels: import("./labels.js").UiLabels): ImportTexts;
|
|
345
|
+
/**
|
|
346
|
+
* A reader's note in the report's language: the text of its code with its params (numbers in the
|
|
347
|
+
* locale's digits, a count in its plural form), else the reader's own English message (a plugin's
|
|
348
|
+
* code this version has no text for). Params come from the file: text, never markup.
|
|
349
|
+
* @param {{ code: string, params?: Record<string, unknown>, message?: string }} note
|
|
350
|
+
* @param {ImportTexts} texts
|
|
351
|
+
* @param {{ lang: string, locale: string }} where
|
|
352
|
+
*/
|
|
353
|
+
export declare function noteText(note: {
|
|
354
|
+
code: string;
|
|
355
|
+
params?: Record<string, unknown>;
|
|
356
|
+
message?: string;
|
|
357
|
+
}, texts: ImportTexts, where: {
|
|
358
|
+
lang: string;
|
|
359
|
+
locale: string;
|
|
360
|
+
}): string;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The accept attribute of the file input: every extension and media type the readers take, the
|
|
3
|
+
* host's plugins first. Plugins that fail validatePlugin are left out (the read says why).
|
|
4
|
+
* @param {readonly any[]} plugins
|
|
5
|
+
*/
|
|
6
|
+
export declare function acceptOf(plugins: readonly any[]): string;
|
|
7
|
+
/**
|
|
8
|
+
* The names of the formats the report reads, for "CSV or text, JSON, Excel workbook": a reader's name
|
|
9
|
+
* in the report's language where `names` has it (the built-in readers and pivotkit-xlsx), else the
|
|
10
|
+
* plugin's own label.
|
|
11
|
+
* @param {readonly any[]} plugins
|
|
12
|
+
* @param {Record<string, string>} [names] by the reader's `name`
|
|
13
|
+
*/
|
|
14
|
+
export declare const formatsOf: (plugins: readonly any[], names?: Record<string, string>) => any[];
|
|
15
|
+
/** How long a worker may take to say it is ready before the page reads the file itself (ms). */
|
|
16
|
+
export declare const WORKER_READY_MS = 10000;
|
|
17
|
+
/**
|
|
18
|
+
* A reader's table as the import UI uses it: what checkTable of pivotkit-core does not ask for, but
|
|
19
|
+
* retype and the preview need, filled in from what is there (a plugin may return the minimal shape),
|
|
20
|
+
* and notes that are no `{ code, params }` left out.
|
|
21
|
+
* @param {any} table
|
|
22
|
+
* @returns {import("pivotkit-core/import").ImportTable}
|
|
23
|
+
*/
|
|
24
|
+
export declare function completeTable(table: any): import("pivotkit-core/import").ImportTable;
|
|
25
|
+
export type ImportRead = {
|
|
26
|
+
/**
|
|
27
|
+
* the host's reader plugins
|
|
28
|
+
*/
|
|
29
|
+
plugins?: any[];
|
|
30
|
+
/**
|
|
31
|
+
* starts the host's import worker
|
|
32
|
+
*/
|
|
33
|
+
worker?: (() => Worker) | undefined;
|
|
34
|
+
sheet?: string | number;
|
|
35
|
+
locale?: string;
|
|
36
|
+
limits?: object;
|
|
37
|
+
signal?: AbortSignal;
|
|
38
|
+
onProgress?: (p: import("pivotkit-core/import").ImportProgress) => void;
|
|
39
|
+
/**
|
|
40
|
+
* how long the worker may take to start (WORKER_READY_MS; tests)
|
|
41
|
+
*/
|
|
42
|
+
readyMs?: number;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* @typedef {object} ImportRead
|
|
46
|
+
* @property {any[]} [plugins] the host's reader plugins
|
|
47
|
+
* @property {(() => Worker) | undefined} [worker] starts the host's import worker
|
|
48
|
+
* @property {string | number} [sheet]
|
|
49
|
+
* @property {string} [locale]
|
|
50
|
+
* @property {object} [limits]
|
|
51
|
+
* @property {AbortSignal} [signal]
|
|
52
|
+
* @property {(p: import("pivotkit-core/import").ImportProgress) => void} [onProgress]
|
|
53
|
+
* @property {number} [readyMs] how long the worker may take to start (WORKER_READY_MS; tests)
|
|
54
|
+
*/
|
|
55
|
+
/**
|
|
56
|
+
* Reads a file into pivotkit-core/import's table: in the host's worker when the reader is a built-in
|
|
57
|
+
* one and the worker starts, else on the page.
|
|
58
|
+
* @param {File} file
|
|
59
|
+
* @param {ImportRead} options
|
|
60
|
+
* @returns {Promise<import("pivotkit-core/import").ImportTable>}
|
|
61
|
+
*/
|
|
62
|
+
export declare function readImport(file: File, { plugins, worker, sheet, locale, limits, signal, onProgress, readyMs }?: ImportRead): Promise<import("pivotkit-core/import").ImportTable>;
|
|
63
|
+
/**
|
|
64
|
+
* The sheets of a file whose reader has several (a workbook), or [] for one table.
|
|
65
|
+
* @param {File} file
|
|
66
|
+
* @param {{ plugins?: any[], limits?: object, signal?: AbortSignal }} options
|
|
67
|
+
* @returns {Promise<import("pivotkit-core/import").SheetInfo[]>}
|
|
68
|
+
*/
|
|
69
|
+
export declare function sheetsOf(file: File, { plugins, limits, signal }?: {
|
|
70
|
+
plugins?: any[];
|
|
71
|
+
limits?: object;
|
|
72
|
+
signal?: AbortSignal;
|
|
73
|
+
}): Promise<import("pivotkit-core/import").SheetInfo[]>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** Characters of a file name in the source id and the report's source line. */
|
|
2
|
+
export declare const SHOWN_MAX = 120;
|
|
3
|
+
/**
|
|
4
|
+
* The name as the report shows it: at most SHOWN_MAX characters, cut with "...".
|
|
5
|
+
* @param {string} name
|
|
6
|
+
*/
|
|
7
|
+
export declare function shownName(name: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* SHA-256 of bytes, in JavaScript (where crypto.subtle is missing).
|
|
10
|
+
* @param {Uint8Array} bytes
|
|
11
|
+
* @returns {Uint8Array}
|
|
12
|
+
*/
|
|
13
|
+
export declare function sha256Bytes(bytes: Uint8Array): Uint8Array;
|
|
14
|
+
/**
|
|
15
|
+
* SHA-256 of a text (UTF-8) as lower-case hex: the browser's crypto.subtle where there is one.
|
|
16
|
+
* @param {string} text
|
|
17
|
+
* @param {{ subtle?: SubtleCrypto | null }} [options] `subtle: null` uses the own implementation (tests)
|
|
18
|
+
* @returns {Promise<string>}
|
|
19
|
+
*/
|
|
20
|
+
export declare function sha256Hex(text: string, options?: {
|
|
21
|
+
subtle?: SubtleCrypto | null;
|
|
22
|
+
}): Promise<string>;
|
|
23
|
+
/**
|
|
24
|
+
* The source id of a loaded file: its shown name, "#" and 16 hex digits of the SHA-256 of its whole
|
|
25
|
+
* name and its column names in their order, joined with U+0000.
|
|
26
|
+
* @param {string} name
|
|
27
|
+
* @param {readonly string[]} columns
|
|
28
|
+
* @param {{ subtle?: SubtleCrypto | null }} [options]
|
|
29
|
+
*/
|
|
30
|
+
export declare function sourceIdOf(name: string, columns: readonly string[], options?: {
|
|
31
|
+
subtle?: SubtleCrypto | null;
|
|
32
|
+
}): Promise<string>;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
export type ShownData = {
|
|
2
|
+
/**
|
|
3
|
+
* names the data set for the view history (use-view-history.js: dataKey)
|
|
4
|
+
*/
|
|
5
|
+
key: number;
|
|
6
|
+
encoded: import("pivotkit-core").Encoded;
|
|
7
|
+
source: {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
};
|
|
11
|
+
sheet: string | null;
|
|
12
|
+
file: {
|
|
13
|
+
name: string;
|
|
14
|
+
size: number;
|
|
15
|
+
type: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export type ImportContext = {
|
|
19
|
+
/**
|
|
20
|
+
* the file's data shown, null for the host's
|
|
21
|
+
*/
|
|
22
|
+
imported: ShownData | null;
|
|
23
|
+
steps: import("./data-history.js").DataSteps;
|
|
24
|
+
setSteps: (steps: import("./data-history.js").DataSteps) => void;
|
|
25
|
+
setImported: (data: ShownData | null) => void;
|
|
26
|
+
history: {
|
|
27
|
+
snapshot: () => any;
|
|
28
|
+
replace: (state: any) => void;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* the host's data
|
|
32
|
+
*/
|
|
33
|
+
hostEncoded: import("pivotkit-core").Encoded;
|
|
34
|
+
/**
|
|
35
|
+
* the host's `source`
|
|
36
|
+
*/
|
|
37
|
+
hostSource: {
|
|
38
|
+
id: string;
|
|
39
|
+
name?: string;
|
|
40
|
+
} | undefined;
|
|
41
|
+
onDataLoad: ((detail: DataLoad) => unknown) | undefined;
|
|
42
|
+
labels: any;
|
|
43
|
+
locale: string;
|
|
44
|
+
announce: (text: string, extra?: {
|
|
45
|
+
action?: {
|
|
46
|
+
label: string;
|
|
47
|
+
run: () => void;
|
|
48
|
+
};
|
|
49
|
+
tone?: "error";
|
|
50
|
+
}) => void;
|
|
51
|
+
/**
|
|
52
|
+
* the report's Undo, for the status note's action
|
|
53
|
+
*/
|
|
54
|
+
undo: () => void;
|
|
55
|
+
};
|
|
56
|
+
export type DataLoad = {
|
|
57
|
+
/**
|
|
58
|
+
* a file loaded (refuse it with false), the host's data shown again, Undo or Redo of one of those, or a file's data shown again by a report mounted again (data-keep.js)
|
|
59
|
+
*/
|
|
60
|
+
cause: "load" | "original" | "undo" | "redo" | "restore";
|
|
61
|
+
/**
|
|
62
|
+
* the data shown now: the file's (its id names its saved views), or the host's `source`
|
|
63
|
+
*/
|
|
64
|
+
source: {
|
|
65
|
+
id?: string;
|
|
66
|
+
name?: string;
|
|
67
|
+
} | null;
|
|
68
|
+
/**
|
|
69
|
+
* the file, for "load" and when a step shows a file's data
|
|
70
|
+
*/
|
|
71
|
+
file: {
|
|
72
|
+
name: string;
|
|
73
|
+
size: number;
|
|
74
|
+
type: string;
|
|
75
|
+
} | null;
|
|
76
|
+
/**
|
|
77
|
+
* the sheet of a workbook
|
|
78
|
+
*/
|
|
79
|
+
sheet: string | null;
|
|
80
|
+
rows: number;
|
|
81
|
+
columns: Array<{
|
|
82
|
+
name: string;
|
|
83
|
+
type: string;
|
|
84
|
+
}>;
|
|
85
|
+
/**
|
|
86
|
+
* the readers' notes ("load" only)
|
|
87
|
+
*/
|
|
88
|
+
notes: Array<{
|
|
89
|
+
code: string;
|
|
90
|
+
params: Record<string, unknown>;
|
|
91
|
+
message: string;
|
|
92
|
+
}>;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* "Load data" in the preview: the host may refuse it (onDataLoad returns false); else the file's data
|
|
96
|
+
* is shown, a step Undo takes back. Returns whether it was loaded.
|
|
97
|
+
* @param {ImportContext} ctx
|
|
98
|
+
* @param {import("./import-ui.jsx").LoadedData} loaded
|
|
99
|
+
*/
|
|
100
|
+
export declare function loadData(ctx: ImportContext, loaded: import("./import-ui.jsx").LoadedData): boolean;
|
|
101
|
+
/**
|
|
102
|
+
* "Back to original data": the host's data with the view it had when it was left (its own steps
|
|
103
|
+
* stay behind: Undo brings the file back first), a step Undo takes back.
|
|
104
|
+
* @param {ImportContext} ctx
|
|
105
|
+
*/
|
|
106
|
+
export declare function backToOriginal(ctx: ImportContext): void;
|
|
107
|
+
/**
|
|
108
|
+
* Undo (`back`) or Redo of a data step: the data and view history it kept. The note of the step, or
|
|
109
|
+
* null when there is none.
|
|
110
|
+
* @param {ImportContext} ctx
|
|
111
|
+
* @param {boolean} back
|
|
112
|
+
* @returns {string | null}
|
|
113
|
+
*/
|
|
114
|
+
export declare function moveData(ctx: ImportContext, back: boolean): string | null;
|
|
115
|
+
/**
|
|
116
|
+
* A report mounted again shows the file's data it kept (data-keep.js): the host is told, as for the
|
|
117
|
+
* other steps, so a host that follows the data shown (and controls the view) knows the view that
|
|
118
|
+
* comes next is the file's.
|
|
119
|
+
* @param {ImportContext} ctx
|
|
120
|
+
*/
|
|
121
|
+
export declare function restoreData(ctx: ImportContext): void;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
/** Rows and columns the preview shows. */
|
|
3
|
+
export declare const PREVIEW_ROWS = 8;
|
|
4
|
+
export declare const PREVIEW_COLUMNS = 60;
|
|
5
|
+
/**
|
|
6
|
+
* The Data menu: where the data shown comes from, and loading.
|
|
7
|
+
* @param {{ labels: any, locale: string, source: { name: string | null, rows: number, columns: number, imported: boolean },
|
|
8
|
+
* plugins: any[], onPick: () => void, onBack: () => void, close: () => void }} props
|
|
9
|
+
*/
|
|
10
|
+
export declare function DataPanel({ labels, locale, source, plugins, onPick, onBack, close }: {
|
|
11
|
+
labels: any;
|
|
12
|
+
locale: string;
|
|
13
|
+
source: {
|
|
14
|
+
name: string | null;
|
|
15
|
+
rows: number;
|
|
16
|
+
columns: number;
|
|
17
|
+
imported: boolean;
|
|
18
|
+
};
|
|
19
|
+
plugins: any[];
|
|
20
|
+
onPick: () => void;
|
|
21
|
+
onBack: () => void;
|
|
22
|
+
close: () => void;
|
|
23
|
+
}): React.JSX.Element;
|
|
24
|
+
/**
|
|
25
|
+
* Over the whole report while a file is dragged over it: where to let go, and what it reads. In the
|
|
26
|
+
* top layer like the menus, placed on the part of the report on screen; it takes no pointer events,
|
|
27
|
+
* so the report's drop handlers get them.
|
|
28
|
+
* @param {{ labels: any, locale: string, plugins: any[], box: () => DOMRect | undefined }} props `box`: the report's
|
|
29
|
+
*/
|
|
30
|
+
export declare function DropOverlay({ labels, locale, plugins, box: boxOf }: {
|
|
31
|
+
labels: any;
|
|
32
|
+
locale: string;
|
|
33
|
+
plugins: any[];
|
|
34
|
+
box: () => DOMRect | undefined;
|
|
35
|
+
}): React.ReactPortal | null;
|
|
36
|
+
/**
|
|
37
|
+
* Where the data shown comes from, under the result while a file's data is shown.
|
|
38
|
+
* @param {{ labels: any, source: { name: string, sheet?: string | null } }} props
|
|
39
|
+
*/
|
|
40
|
+
export declare function SourceLine({ labels, source }: {
|
|
41
|
+
labels: any;
|
|
42
|
+
source: {
|
|
43
|
+
name: string;
|
|
44
|
+
sheet?: string | null;
|
|
45
|
+
};
|
|
46
|
+
}): React.JSX.Element;
|
|
47
|
+
export type LoadedData = {
|
|
48
|
+
encoded: import("pivotkit-core").Encoded;
|
|
49
|
+
/**
|
|
50
|
+
* the id for the saved views (import-source.js), the name shown
|
|
51
|
+
*/
|
|
52
|
+
source: {
|
|
53
|
+
id: string;
|
|
54
|
+
name: string;
|
|
55
|
+
};
|
|
56
|
+
file: {
|
|
57
|
+
name: string;
|
|
58
|
+
size: number;
|
|
59
|
+
type: string;
|
|
60
|
+
};
|
|
61
|
+
sheet: string | null;
|
|
62
|
+
rows: number;
|
|
63
|
+
columns: Array<{
|
|
64
|
+
name: string;
|
|
65
|
+
type: string;
|
|
66
|
+
}>;
|
|
67
|
+
notes: Array<{
|
|
68
|
+
code: string;
|
|
69
|
+
params: Record<string, unknown>;
|
|
70
|
+
message: string;
|
|
71
|
+
}>;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* @typedef {object} LoadedData what "Load data" hands the report
|
|
75
|
+
* @property {import("pivotkit-core").Encoded} encoded
|
|
76
|
+
* @property {{ id: string, name: string }} source the id for the saved views (import-source.js), the name shown
|
|
77
|
+
* @property {{ name: string, size: number, type: string }} file
|
|
78
|
+
* @property {string | null} sheet
|
|
79
|
+
* @property {number} rows
|
|
80
|
+
* @property {Array<{ name: string, type: string }>} columns
|
|
81
|
+
* @property {Array<{ code: string, params: Record<string, unknown>, message: string }>} notes
|
|
82
|
+
*/
|
|
83
|
+
/**
|
|
84
|
+
* Reads a file (progress, Cancel) and shows it before it replaces the data: the sheet, the first
|
|
85
|
+
* rows with a type per column, the readers' notes; "Load data" or Cancel. Modal, in the top layer:
|
|
86
|
+
* the focus moves in, Tab stays inside, Escape cancels, the focus goes back to where it was. A file
|
|
87
|
+
* that cannot be read closes it with a note; the report's data stays.
|
|
88
|
+
* @param {{ job: { file: File, n: number }, labels: any, locale: string, plugins: any[], worker?: () => Worker,
|
|
89
|
+
* limits?: object, timeZone?: string, onApply: (data: LoadedData) => void, onClose: () => void,
|
|
90
|
+
* announce: (text: string, extra?: { tone?: "error" }) => void }} props
|
|
91
|
+
*/
|
|
92
|
+
export declare function ImportDialog({ job, labels, locale, plugins, worker, limits, timeZone, onApply, onClose, announce }: {
|
|
93
|
+
job: {
|
|
94
|
+
file: File;
|
|
95
|
+
n: number;
|
|
96
|
+
};
|
|
97
|
+
labels: any;
|
|
98
|
+
locale: string;
|
|
99
|
+
plugins: any[];
|
|
100
|
+
worker?: () => Worker;
|
|
101
|
+
limits?: object;
|
|
102
|
+
timeZone?: string;
|
|
103
|
+
onApply: (data: LoadedData) => void;
|
|
104
|
+
onClose: () => void;
|
|
105
|
+
announce: (text: string, extra?: {
|
|
106
|
+
tone?: "error";
|
|
107
|
+
}) => void;
|
|
108
|
+
}): React.ReactPortal | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|