pivotkit-element 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 +50 -1
- package/dist/chunks/chunk-D2E6EFC7.js +6 -0
- package/dist/chunks/chunk-FUHQLTFM.js +1 -0
- package/dist/chunks/chunk-IBQE3N74.js +1 -0
- package/dist/chunks/chunk-O2TTHYGT.js +1 -0
- package/dist/chunks/chunk-VMHRXWK7.js +1 -0
- package/dist/chunks/chunk-WNTTPBZ5.js +9 -0
- package/dist/chunks/chunk-WXBFHMFX.js +1 -0
- package/dist/chunks/{export-GKVGFFWM.js → export-6ILXDVGS.js} +1 -1
- package/dist/chunks/import-csv-TPSP3I44.js +1 -0
- package/dist/chunks/import-json-NCJFIKAC.js +1 -0
- package/dist/chunks/import-ui-YBYWR3Q5.js +1 -0
- package/dist/chunks/menu-texts-de-YZIOIWPD.js +1 -0
- package/dist/chunks/menus-UWW77KFI.js +1 -0
- package/dist/element.js +1 -1
- package/dist/import-worker.js +1 -0
- package/dist/index.js +1 -1
- package/package.json +3 -3
- package/types/element.d.ts +69 -89
- package/types/events.d.ts +1 -0
- package/types/global.d.ts +3 -1
- package/types/jsx.d.ts +1 -1
- package/dist/chunks/chunk-FW54TETI.js +0 -9
- package/dist/chunks/chunk-J3NYMXAT.js +0 -6
- package/dist/chunks/chunk-RXM4LLDS.js +0 -1
- package/dist/chunks/menu-texts-de-X4IUO7W5.js +0 -1
- package/dist/chunks/menus-SYPZC2NE.js +0 -1
package/types/element.d.ts
CHANGED
|
@@ -171,6 +171,57 @@ export type SourceEntry = {
|
|
|
171
171
|
id: string;
|
|
172
172
|
name?: string;
|
|
173
173
|
};
|
|
174
|
+
export type DataLoad = {
|
|
175
|
+
/**
|
|
176
|
+
* a file loaded ("load": preventDefault()
|
|
177
|
+
* refuses it, the data stays), the page's data shown again, one of those undone or redone, or the
|
|
178
|
+
* file shown again by an element with storage-key put back into the page ("restore")
|
|
179
|
+
*/
|
|
180
|
+
cause: "load" | "original" | "undo" | "redo" | "restore";
|
|
181
|
+
/**
|
|
182
|
+
* the data shown now: the file's (its id names
|
|
183
|
+
* the views kept for it), or the element's source-id and source-name
|
|
184
|
+
*/
|
|
185
|
+
source: {
|
|
186
|
+
id?: string;
|
|
187
|
+
name?: string;
|
|
188
|
+
} | null;
|
|
189
|
+
file: {
|
|
190
|
+
name: string;
|
|
191
|
+
size: number;
|
|
192
|
+
type: string;
|
|
193
|
+
} | null;
|
|
194
|
+
/**
|
|
195
|
+
* the sheet of a workbook
|
|
196
|
+
*/
|
|
197
|
+
sheet: string | null;
|
|
198
|
+
rows: number;
|
|
199
|
+
columns: Array<{
|
|
200
|
+
name: string;
|
|
201
|
+
type: string;
|
|
202
|
+
}>;
|
|
203
|
+
/**
|
|
204
|
+
* the readers' notes ("load")
|
|
205
|
+
*/
|
|
206
|
+
notes: Array<{
|
|
207
|
+
code: string;
|
|
208
|
+
params: Record<string, unknown>;
|
|
209
|
+
message: string;
|
|
210
|
+
}>;
|
|
211
|
+
};
|
|
212
|
+
export type ReaderPlugin = {
|
|
213
|
+
apiVersion: 1;
|
|
214
|
+
kind: "reader";
|
|
215
|
+
name: string;
|
|
216
|
+
label: string;
|
|
217
|
+
accept: readonly string[];
|
|
218
|
+
load: () => Promise<unknown>;
|
|
219
|
+
};
|
|
220
|
+
export type ColumnarData = {
|
|
221
|
+
columns: string[];
|
|
222
|
+
types?: Array<"string" | "number" | "date" | "boolean" | null>;
|
|
223
|
+
data: unknown[][];
|
|
224
|
+
};
|
|
174
225
|
export type SourceSwitch = {
|
|
175
226
|
/**
|
|
176
227
|
* the entry of `sources`
|
|
@@ -185,92 +236,6 @@ export type SourceSwitch = {
|
|
|
185
236
|
*/
|
|
186
237
|
name?: string;
|
|
187
238
|
};
|
|
188
|
-
/**
|
|
189
|
-
* A view of pivotkit-core (the report template): plain JSON with field names only, normalized against
|
|
190
|
-
* the data by the report; anything unknown is dropped. The full type is pivotkit-core's `View`.
|
|
191
|
-
* @typedef {{ rows?: string[], cols?: string[], values?: Array<{ field?: string | null, agg?: string, format?: string | null, [key: string]: unknown }>, [key: string]: unknown }} PivotView
|
|
192
|
-
*/
|
|
193
|
-
/**
|
|
194
|
-
* @typedef {object} Template a saved view of the Views menu: a view, or a view file (its text or object)
|
|
195
|
-
* @property {string} [name] shown in the menu; default the view file's name
|
|
196
|
-
* @property {PivotView} [view]
|
|
197
|
-
* @property {Record<string, unknown> | string} [file] a view file ("pivotkit-view") instead of `view`
|
|
198
|
-
* @property {"shared" | "user"} [scope] the group: "Shared views" or "My views"; default "user"
|
|
199
|
-
* for a deletable entry, else "shared"
|
|
200
|
-
* @property {boolean} [deletable] offers a delete button (pivot-template-delete)
|
|
201
|
-
*/
|
|
202
|
-
/**
|
|
203
|
-
* @typedef {object} FieldDefaults the host's settings for a field, as pivotkit-react's
|
|
204
|
-
* @property {string} [agg] aggregator of a new value, when it fits the field's type ("average" for durations)
|
|
205
|
-
* @property {string} [format] a format of pivotkit-core ("duration:h", "currency:EUR") for a new value,
|
|
206
|
-
* and for the field's own numbers in the drill-down unless `drillFormat` is set
|
|
207
|
-
* @property {string} [drillFormat] the format of the field's values in the drill-down ("text": an identifier as it is)
|
|
208
|
-
* @property {Array<string | number | boolean | null>} [order] the field's own order of items on Rows or Columns
|
|
209
|
-
* @property {string} [label] the name shown for the field; views keep the field's own name
|
|
210
|
-
* @property {string} [description] plain text shown with an "i" next to the field, in its menu and on its headers
|
|
211
|
-
* @property {string} [href] an https link shown as "Learn more" with the description
|
|
212
|
-
* @property {"string" | "number" | "date" | "boolean"} [type] the type the field's column is read as
|
|
213
|
-
*/
|
|
214
|
-
/**
|
|
215
|
-
* @typedef {object} TipDismiss the detail of pivot-tip-dismiss
|
|
216
|
-
* @property {string | null} id the tip dismissed, "*" when every tip was switched off, null when tips came back
|
|
217
|
-
* @property {string[]} dismissed every dismissed id now: set it as `dismissedTips` next time
|
|
218
|
-
*/
|
|
219
|
-
/**
|
|
220
|
-
* @typedef {object} CellClick the detail of pivot-cell-click
|
|
221
|
-
* @property {any[]} row key path of the row ([] is the grand total)
|
|
222
|
-
* @property {any[]} col key path of the column
|
|
223
|
-
* @property {unknown} value the raw value of the cell
|
|
224
|
-
* @property {number | undefined} valueIndex
|
|
225
|
-
* @property {string | undefined} text the value as shown
|
|
226
|
-
* @property {number} count source rows behind the cell
|
|
227
|
-
* @property {object[]} rows the first `drillDownLimit` of them: the host's row objects
|
|
228
|
-
*/
|
|
229
|
-
/**
|
|
230
|
-
* @typedef {object} ExportFile the detail of pivot-export: a file before its download, or a text
|
|
231
|
-
* before it goes on the clipboard
|
|
232
|
-
* @property {"xlsx" | "csv" | "png" | "json" | "copy-table" | "copy-json" | "drill-copy" | "drill-json" | "drill-csv" | "drill-xlsx"} kind
|
|
233
|
-
* "json": the view file (Views, "Download view"); "copy-table", "copy-json": Export → Copy table,
|
|
234
|
-
* Copy data as JSON; "drill-*": the drill-down panel's Export menu
|
|
235
|
-
* @property {string} fileName with the extension ("pivot.xlsx"); for a copy the name it would have as a file
|
|
236
|
-
* @property {Blob} blob
|
|
237
|
-
* @property {string} [text] a copy's text
|
|
238
|
-
* @property {{ shown: number, count: number }} [rows] a drill-down export: the rows it holds and the rows behind the value
|
|
239
|
-
*/
|
|
240
|
-
/**
|
|
241
|
-
* @typedef {object} TemplateSave the detail of pivot-template-save
|
|
242
|
-
* @property {string} name
|
|
243
|
-
* @property {PivotView} view the normalized view to store
|
|
244
|
-
* @property {"shared" | "user"} scope where it goes: "user", the user's own views
|
|
245
|
-
* @property {(result: unknown) => void} respondWith call it in the listener with the promise of the
|
|
246
|
-
* host's save: "Saved" shows when it resolves, the error's message when it rejects
|
|
247
|
-
*/
|
|
248
|
-
/**
|
|
249
|
-
* @typedef {object} TemplateDelete the detail of pivot-template-delete
|
|
250
|
-
* @property {string} name
|
|
251
|
-
* @property {"shared" | "user"} scope the entry's group
|
|
252
|
-
* @property {(result: unknown) => void} respondWith as for pivot-template-save: the entry goes when
|
|
253
|
-
* the promise resolves (the host then sets `templates` without it)
|
|
254
|
-
*/
|
|
255
|
-
/**
|
|
256
|
-
* @typedef {object} TemplatePublish the detail of pivot-template-publish (with `can-publish`)
|
|
257
|
-
* @property {string} name
|
|
258
|
-
* @property {PivotView} view the user's view to publish as a shared view
|
|
259
|
-
* @property {(result: unknown) => void} respondWith as for pivot-template-save: "Published" shows
|
|
260
|
-
* when the promise resolves (the host then sets `templates` with the new shared entry)
|
|
261
|
-
*/
|
|
262
|
-
/**
|
|
263
|
-
* @typedef {object} SourceEntry data the page can show (`sources`), as the report names it
|
|
264
|
-
* @property {string} id
|
|
265
|
-
* @property {string} [name]
|
|
266
|
-
*/
|
|
267
|
-
/**
|
|
268
|
-
* @typedef {object} SourceSwitch the detail of pivot-source-switch: the user chose to switch to the
|
|
269
|
-
* data a loaded view was made for; show that data and set `defaultView` to `view`
|
|
270
|
-
* @property {SourceEntry} source the entry of `sources`
|
|
271
|
-
* @property {PivotView} view the view as the file has it (made for that data, not normalized here)
|
|
272
|
-
* @property {string} [name] the view's name in the file
|
|
273
|
-
*/
|
|
274
239
|
/** The tag the package defines. */
|
|
275
240
|
export declare const TAG = "pivot-report";
|
|
276
241
|
declare const Base: typeof HTMLElement;
|
|
@@ -372,6 +337,12 @@ export declare class PivotReportElement extends Base {
|
|
|
372
337
|
/** The name of the data shown, for people ("Sales 2026"); with source-id. */
|
|
373
338
|
get sourceName(): string | undefined;
|
|
374
339
|
set sourceName(value: string | undefined);
|
|
340
|
+
/**
|
|
341
|
+
* People may load a file into the report (attribute allow-import): a Data button with "Load
|
|
342
|
+
* data…", a file dropped onto the report, a preview first. Read in the browser, nothing uploaded.
|
|
343
|
+
*/
|
|
344
|
+
get allowImport(): boolean;
|
|
345
|
+
set allowImport(value: boolean);
|
|
375
346
|
/** The page is loading the data: the report shows its skeleton (attribute loading). */
|
|
376
347
|
get loading(): boolean;
|
|
377
348
|
set loading(value: boolean);
|
|
@@ -384,9 +355,12 @@ export declare class PivotReportElement extends Base {
|
|
|
384
355
|
*/
|
|
385
356
|
get defaultView(): PivotView | undefined;
|
|
386
357
|
set defaultView(value: PivotView | undefined);
|
|
387
|
-
/**
|
|
388
|
-
|
|
389
|
-
|
|
358
|
+
/**
|
|
359
|
+
* The rows: an array of objects, or columnar data ({ columns, types, data }, one array per column);
|
|
360
|
+
* encoded once per array or object, or once per `dataKey`.
|
|
361
|
+
*/
|
|
362
|
+
get data(): object[] | ColumnarData | undefined;
|
|
363
|
+
set data(value: object[] | ColumnarData | undefined);
|
|
390
364
|
/** The identity of `data`: a new array with the same key is not encoded again. */
|
|
391
365
|
get dataKey(): string | number | undefined;
|
|
392
366
|
set dataKey(value: string | number | undefined);
|
|
@@ -414,6 +388,12 @@ export declare class PivotReportElement extends Base {
|
|
|
414
388
|
*/
|
|
415
389
|
get sources(): SourceEntry[] | undefined;
|
|
416
390
|
set sources(value: SourceEntry[] | undefined);
|
|
391
|
+
/**
|
|
392
|
+
* Reader plugins for more formats with allow-import (pivotkit-xlsx for Excel workbooks); CSV, TSV,
|
|
393
|
+
* text and JSON are built in.
|
|
394
|
+
*/
|
|
395
|
+
get plugins(): ReaderPlugin[] | undefined;
|
|
396
|
+
set plugins(value: ReaderPlugin[] | undefined);
|
|
417
397
|
/** pivotkit-core's limits (rows, cells, ...). */
|
|
418
398
|
get limits(): Record<string, number> | undefined;
|
|
419
399
|
set limits(value: Record<string, number> | undefined);
|
package/types/events.d.ts
CHANGED
package/types/global.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// PivotReportElement, and addEventListener("pivot-view-change", ...) on it (or on a parent: the events
|
|
3
3
|
// bubble and are composed) knows the event's detail. Copied next to the generated declarations by
|
|
4
4
|
// types.js; written by hand because JSDoc cannot augment global interfaces.
|
|
5
|
-
import type { CellClick, ExportFile, PivotReportElement, PivotView, SourceSwitch, TemplateDelete, TemplatePublish, TemplateSave, TipDismiss } from "./element.js";
|
|
5
|
+
import type { CellClick, DataLoad, ExportFile, PivotReportElement, PivotView, SourceSwitch, TemplateDelete, TemplatePublish, TemplateSave, TipDismiss } from "./element.js";
|
|
6
6
|
|
|
7
7
|
/** The events of <pivot-report>. */
|
|
8
8
|
export interface PivotReportEventMap {
|
|
@@ -22,6 +22,8 @@ export interface PivotReportEventMap {
|
|
|
22
22
|
"pivot-tip-dismiss": CustomEvent<TipDismiss>;
|
|
23
23
|
/** "Switch to <name> and load" for a view made for other data (one of `sources`): show that data with `detail.view`. */
|
|
24
24
|
"pivot-source-switch": CustomEvent<SourceSwitch>;
|
|
25
|
+
/** The data shown changed (with `allow-import`): a file loaded (`preventDefault()` refuses it), the page's data again, or one of those undone or redone. */
|
|
26
|
+
"pivot-data-load": CustomEvent<DataLoad>;
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
declare global {
|
package/types/jsx.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type { DetailedHTMLProps, HTMLAttributes } from "react";
|
|
|
8
8
|
import type { PivotReportElement } from "./element.js";
|
|
9
9
|
import type { PivotReportEventMap } from "./global.js";
|
|
10
10
|
|
|
11
|
-
type Settable = "data" | "dataKey" | "view" | "defaultView" | "templates" | "labels" | "fieldDefaults" | "limits" | "locale" | "theme" | "height" | "timeZone" | "fileName" | "label" | "drillDown" | "drillDownLimit" | "saveTemplates" | "templateStore" | "canPublish" | "tips" | "storageKey" | "dismissedTips" | "chartOptions" | "shareLink" | "persistView" | "loading" | "fieldInfo" | "zoneInfo" | "settingInfo" | "sourceId" | "sourceName" | "sources" | "schemaUrl" | "grow" | "fieldList";
|
|
11
|
+
type Settable = "data" | "dataKey" | "view" | "defaultView" | "templates" | "labels" | "fieldDefaults" | "limits" | "locale" | "theme" | "height" | "timeZone" | "fileName" | "label" | "drillDown" | "drillDownLimit" | "saveTemplates" | "templateStore" | "canPublish" | "tips" | "storageKey" | "dismissedTips" | "chartOptions" | "shareLink" | "persistView" | "loading" | "fieldInfo" | "zoneInfo" | "settingInfo" | "sourceId" | "sourceName" | "sources" | "schemaUrl" | "grow" | "fieldList" | "allowImport" | "plugins";
|
|
12
12
|
|
|
13
13
|
/** The props of <pivot-report> in JSX. */
|
|
14
14
|
export type PivotReportJsxProps = DetailedHTMLProps<HTMLAttributes<PivotReportElement>, PivotReportElement> &
|