pivotkit-element 0.0.0-stage → 0.2.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 +143 -0
- package/LICENSE +21 -0
- package/README.md +73 -2
- package/dist/THIRD_PARTY_LICENSES.txt +547 -0
- package/dist/chunks/chunk-BL6ROOK3.js +6 -0
- package/dist/chunks/chunk-CETTRMB6.js +9 -0
- package/dist/chunks/chunk-DCANE7XH.js +1 -0
- package/dist/chunks/chunk-JGSNJX3N.js +1 -0
- package/dist/chunks/chunk-MB64GADT.js +1 -0
- package/dist/chunks/chunk-UTPKLCNX.js +1 -0
- package/dist/chunks/echarts-42T6EZ6B.js +18 -0
- package/dist/chunks/export-EASUJGEK.js +6 -0
- package/dist/chunks/link-52SWRX4P.js +1 -0
- package/dist/chunks/menu-texts-de-TRCAQWTH.js +1 -0
- package/dist/chunks/menus-CRKZQ2O3.js +1 -0
- package/dist/chunks/unused-texts-YTNJCFFC-HJOIWMO6.js +1 -0
- package/dist/chunks/unused-texts-de-SGOHV4N7-LJH5VMQZ.js +1 -0
- package/dist/element.js +1 -0
- package/dist/index.js +1 -0
- package/package.json +72 -4
- package/types/element.d.ts +428 -0
- package/types/events.d.ts +34 -0
- package/types/global.d.ts +33 -0
- package/types/index.d.ts +22 -0
- package/types/jsx.d.ts +25 -0
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
/// <reference path="./global.d.ts" />
|
|
2
|
+
import { EVENTS } from "./events.js";
|
|
3
|
+
export { EVENTS };
|
|
4
|
+
export type PivotView = {
|
|
5
|
+
rows?: string[];
|
|
6
|
+
cols?: string[];
|
|
7
|
+
values?: Array<{
|
|
8
|
+
field?: string | null;
|
|
9
|
+
agg?: string;
|
|
10
|
+
format?: string | null;
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
}>;
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
};
|
|
15
|
+
export type Template = {
|
|
16
|
+
/**
|
|
17
|
+
* shown in the menu; default the view file's name
|
|
18
|
+
*/
|
|
19
|
+
name?: string;
|
|
20
|
+
view?: PivotView;
|
|
21
|
+
/**
|
|
22
|
+
* a view file ("pivotkit-view") instead of `view`
|
|
23
|
+
*/
|
|
24
|
+
file?: Record<string, unknown> | string;
|
|
25
|
+
/**
|
|
26
|
+
* the group: "Shared views" or "My views"; default "user"
|
|
27
|
+
* for a deletable entry, else "shared"
|
|
28
|
+
*/
|
|
29
|
+
scope?: "shared" | "user";
|
|
30
|
+
/**
|
|
31
|
+
* offers a delete button (pivot-template-delete)
|
|
32
|
+
*/
|
|
33
|
+
deletable?: boolean;
|
|
34
|
+
};
|
|
35
|
+
export type FieldDefaults = {
|
|
36
|
+
/**
|
|
37
|
+
* aggregator of a new value, when it fits the field's type ("average" for durations)
|
|
38
|
+
*/
|
|
39
|
+
agg?: string;
|
|
40
|
+
/**
|
|
41
|
+
* a format of pivotkit-core ("duration:h", "currency:EUR") for a new value,
|
|
42
|
+
* and for the field's own numbers in the drill-down unless `drillFormat` is set
|
|
43
|
+
*/
|
|
44
|
+
format?: string;
|
|
45
|
+
/**
|
|
46
|
+
* the format of the field's values in the drill-down ("text": an identifier as it is)
|
|
47
|
+
*/
|
|
48
|
+
drillFormat?: string;
|
|
49
|
+
/**
|
|
50
|
+
* the field's own order of items on Rows or Columns
|
|
51
|
+
*/
|
|
52
|
+
order?: Array<string | number | boolean | null>;
|
|
53
|
+
/**
|
|
54
|
+
* the name shown for the field; views keep the field's own name
|
|
55
|
+
*/
|
|
56
|
+
label?: string;
|
|
57
|
+
/**
|
|
58
|
+
* plain text shown with an "i" next to the field, in its menu and on its headers
|
|
59
|
+
*/
|
|
60
|
+
description?: string;
|
|
61
|
+
/**
|
|
62
|
+
* an https link shown as "Learn more" with the description
|
|
63
|
+
*/
|
|
64
|
+
href?: string;
|
|
65
|
+
/**
|
|
66
|
+
* the type the field's column is read as
|
|
67
|
+
*/
|
|
68
|
+
type?: "string" | "number" | "date" | "boolean";
|
|
69
|
+
};
|
|
70
|
+
export type TipDismiss = {
|
|
71
|
+
/**
|
|
72
|
+
* the tip dismissed, "*" when every tip was switched off, null when tips came back
|
|
73
|
+
*/
|
|
74
|
+
id: string | null;
|
|
75
|
+
/**
|
|
76
|
+
* every dismissed id now: set it as `dismissedTips` next time
|
|
77
|
+
*/
|
|
78
|
+
dismissed: string[];
|
|
79
|
+
};
|
|
80
|
+
export type CellClick = {
|
|
81
|
+
/**
|
|
82
|
+
* key path of the row ([] is the grand total)
|
|
83
|
+
*/
|
|
84
|
+
row: any[];
|
|
85
|
+
/**
|
|
86
|
+
* key path of the column
|
|
87
|
+
*/
|
|
88
|
+
col: any[];
|
|
89
|
+
/**
|
|
90
|
+
* the raw value of the cell
|
|
91
|
+
*/
|
|
92
|
+
value: unknown;
|
|
93
|
+
valueIndex: number | undefined;
|
|
94
|
+
/**
|
|
95
|
+
* the value as shown
|
|
96
|
+
*/
|
|
97
|
+
text: string | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* source rows behind the cell
|
|
100
|
+
*/
|
|
101
|
+
count: number;
|
|
102
|
+
/**
|
|
103
|
+
* the first `drillDownLimit` of them: the host's row objects
|
|
104
|
+
*/
|
|
105
|
+
rows: object[];
|
|
106
|
+
};
|
|
107
|
+
export type ExportFile = {
|
|
108
|
+
/**
|
|
109
|
+
* "json": the view file (Views, "Download view"); "copy-table", "copy-json": Export → Copy table,
|
|
110
|
+
* Copy data as JSON; "drill-*": the drill-down panel's Export menu
|
|
111
|
+
*/
|
|
112
|
+
kind: "xlsx" | "csv" | "png" | "json" | "copy-table" | "copy-json" | "drill-copy" | "drill-json" | "drill-csv" | "drill-xlsx";
|
|
113
|
+
/**
|
|
114
|
+
* with the extension ("pivot.xlsx"); for a copy the name it would have as a file
|
|
115
|
+
*/
|
|
116
|
+
fileName: string;
|
|
117
|
+
blob: Blob;
|
|
118
|
+
/**
|
|
119
|
+
* a copy's text
|
|
120
|
+
*/
|
|
121
|
+
text?: string;
|
|
122
|
+
/**
|
|
123
|
+
* a drill-down export: the rows it holds and the rows behind the value
|
|
124
|
+
*/
|
|
125
|
+
rows?: {
|
|
126
|
+
shown: number;
|
|
127
|
+
count: number;
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
export type TemplateSave = {
|
|
131
|
+
name: string;
|
|
132
|
+
/**
|
|
133
|
+
* the normalized view to store
|
|
134
|
+
*/
|
|
135
|
+
view: PivotView;
|
|
136
|
+
/**
|
|
137
|
+
* where it goes: "user", the user's own views
|
|
138
|
+
*/
|
|
139
|
+
scope: "shared" | "user";
|
|
140
|
+
/**
|
|
141
|
+
* call it in the listener with the promise of the
|
|
142
|
+
* host's save: "Saved" shows when it resolves, the error's message when it rejects
|
|
143
|
+
*/
|
|
144
|
+
respondWith: (result: unknown) => void;
|
|
145
|
+
};
|
|
146
|
+
export type TemplateDelete = {
|
|
147
|
+
name: string;
|
|
148
|
+
/**
|
|
149
|
+
* the entry's group
|
|
150
|
+
*/
|
|
151
|
+
scope: "shared" | "user";
|
|
152
|
+
/**
|
|
153
|
+
* as for pivot-template-save: the entry goes when
|
|
154
|
+
* the promise resolves (the host then sets `templates` without it)
|
|
155
|
+
*/
|
|
156
|
+
respondWith: (result: unknown) => void;
|
|
157
|
+
};
|
|
158
|
+
export type TemplatePublish = {
|
|
159
|
+
name: string;
|
|
160
|
+
/**
|
|
161
|
+
* the user's view to publish as a shared view
|
|
162
|
+
*/
|
|
163
|
+
view: PivotView;
|
|
164
|
+
/**
|
|
165
|
+
* as for pivot-template-save: "Published" shows
|
|
166
|
+
* when the promise resolves (the host then sets `templates` with the new shared entry)
|
|
167
|
+
*/
|
|
168
|
+
respondWith: (result: unknown) => void;
|
|
169
|
+
};
|
|
170
|
+
export type SourceEntry = {
|
|
171
|
+
id: string;
|
|
172
|
+
name?: string;
|
|
173
|
+
};
|
|
174
|
+
export type SourceSwitch = {
|
|
175
|
+
/**
|
|
176
|
+
* the entry of `sources`
|
|
177
|
+
*/
|
|
178
|
+
source: SourceEntry;
|
|
179
|
+
/**
|
|
180
|
+
* the view as the file has it (made for that data, not normalized here)
|
|
181
|
+
*/
|
|
182
|
+
view: PivotView;
|
|
183
|
+
/**
|
|
184
|
+
* the view's name in the file
|
|
185
|
+
*/
|
|
186
|
+
name?: string;
|
|
187
|
+
};
|
|
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
|
+
/** The tag the package defines. */
|
|
275
|
+
export declare const TAG = "pivot-report";
|
|
276
|
+
declare const Base: typeof HTMLElement;
|
|
277
|
+
export declare class PivotReportElement extends Base {
|
|
278
|
+
#private;
|
|
279
|
+
static get observedAttributes(): string[];
|
|
280
|
+
constructor();
|
|
281
|
+
/** The version of pivotkit-element this class comes from (two copies on a page tell each other apart). */
|
|
282
|
+
static get version(): string;
|
|
283
|
+
connectedCallback(): void;
|
|
284
|
+
disconnectedCallback(): void;
|
|
285
|
+
/**
|
|
286
|
+
* @param {string} name
|
|
287
|
+
* @param {string | null} _old
|
|
288
|
+
* @param {string | null} value
|
|
289
|
+
*/
|
|
290
|
+
attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
|
|
291
|
+
/** Numbers, dates, sorting and the language of the labels ("de-DE"); else the element's `lang`, else "en-US". */
|
|
292
|
+
get locale(): string | undefined;
|
|
293
|
+
set locale(value: string | undefined);
|
|
294
|
+
/** "auto" (default) follows the nearest data-theme above the report, then the system. */
|
|
295
|
+
get theme(): "auto" | "light" | "dark";
|
|
296
|
+
set theme(value: "auto" | "light" | "dark");
|
|
297
|
+
/** The report's height: a number of pixels or a CSS length (default 640). */
|
|
298
|
+
get height(): number | string | undefined;
|
|
299
|
+
set height(value: number | string | undefined);
|
|
300
|
+
/** The zone `data` is encoded in (default "UTC"). */
|
|
301
|
+
get timeZone(): string | undefined;
|
|
302
|
+
set timeZone(value: string | undefined);
|
|
303
|
+
/** Name of exported files without extension (default "pivot"). */
|
|
304
|
+
get fileName(): string | undefined;
|
|
305
|
+
set fileName(value: string | undefined);
|
|
306
|
+
/** The name of the report's region landmark (default the labels' `report`, "Pivot report"). */
|
|
307
|
+
get label(): string | undefined;
|
|
308
|
+
set label(value: string | undefined);
|
|
309
|
+
/** The panel with the rows behind a clicked value (default true; attribute drill-down="false"). */
|
|
310
|
+
get drillDown(): boolean;
|
|
311
|
+
set drillDown(value: boolean);
|
|
312
|
+
/** Rows passed to the panel and to pivot-cell-click (default 1000). */
|
|
313
|
+
get drillDownLimit(): number | undefined;
|
|
314
|
+
set drillDownLimit(value: number | undefined);
|
|
315
|
+
/** Offers "Save current view" in the Views menu; a save is a pivot-template-save event. */
|
|
316
|
+
get saveTemplates(): boolean;
|
|
317
|
+
set saveTemplates(value: boolean);
|
|
318
|
+
/**
|
|
319
|
+
* "browser": the user's own views ("My views") are kept in this browser's localStorage under the
|
|
320
|
+
* storage key, when the page does not take the saves (save-templates).
|
|
321
|
+
*/
|
|
322
|
+
get templateStore(): string | undefined;
|
|
323
|
+
set templateStore(value: string | undefined);
|
|
324
|
+
/**
|
|
325
|
+
* "open" or "collapsed": the field list of a wide report open or collapsed to a rail; without it
|
|
326
|
+
* the user's choice (remembered with the tips) decides.
|
|
327
|
+
*/
|
|
328
|
+
get fieldList(): string | undefined;
|
|
329
|
+
set fieldList(value: string | undefined);
|
|
330
|
+
/** Offers "Publish as shared view" on the user's views; a publish is a pivot-template-publish event. */
|
|
331
|
+
get canPublish(): boolean;
|
|
332
|
+
set canPublish(value: boolean);
|
|
333
|
+
/** "on" (default), "off", or a comma-separated list of the tip ids allowed. */
|
|
334
|
+
get tips(): string | undefined;
|
|
335
|
+
set tips(value: string | undefined);
|
|
336
|
+
/**
|
|
337
|
+
* Remembers dismissed tips in localStorage under this key (and, with template-store="browser",
|
|
338
|
+
* the user's views); give each report on a page its own.
|
|
339
|
+
*/
|
|
340
|
+
get storageKey(): string | undefined;
|
|
341
|
+
set storageKey(value: string | undefined);
|
|
342
|
+
/** "Copy link" and shared links: true for the page's address, or a base URL (attribute share-link). */
|
|
343
|
+
get shareLink(): boolean | string | undefined;
|
|
344
|
+
set shareLink(value: boolean | string | undefined);
|
|
345
|
+
/** "session": the view is kept for this tab (sessionStorage, per storage-key). */
|
|
346
|
+
get persistView(): "session" | undefined;
|
|
347
|
+
set persistView(value: "session" | undefined);
|
|
348
|
+
/** "on" or "off" decides the "i" of the field descriptions; unset, the user switches it in Options. */
|
|
349
|
+
get fieldInfo(): "on" | "off" | undefined;
|
|
350
|
+
set fieldInfo(value: "on" | "off" | undefined);
|
|
351
|
+
/** "on" or "off" decides the "i" next to the zone titles; unset, the user switches it in Options. */
|
|
352
|
+
get zoneInfo(): "on" | "off" | undefined;
|
|
353
|
+
set zoneInfo(value: "on" | "off" | undefined);
|
|
354
|
+
/** "on" or "off" decides the "i" next to the settings ("Show explanations"); unset, the user switches it. */
|
|
355
|
+
get settingInfo(): "on" | "off" | undefined;
|
|
356
|
+
set settingInfo(value: "on" | "off" | undefined);
|
|
357
|
+
/** The id of the data shown ("sales"): it goes into the view files and links, a view for another source asks first. */
|
|
358
|
+
get sourceId(): string | undefined;
|
|
359
|
+
set sourceId(value: string | undefined);
|
|
360
|
+
/**
|
|
361
|
+
* The `$schema` of the view files the report writes: a URL (a self-hosted copy of the schema), or
|
|
362
|
+
* "" to leave it out; unset, pivotkit's published schema.
|
|
363
|
+
*/
|
|
364
|
+
get schemaUrl(): string | undefined;
|
|
365
|
+
set schemaUrl(value: string | undefined);
|
|
366
|
+
/**
|
|
367
|
+
* "on": the report grows past its height to keep the result's least height (the page scrolls);
|
|
368
|
+
* "off": it stays inside its height and the result scrolls. Unset: "on" without a height attribute.
|
|
369
|
+
*/
|
|
370
|
+
get grow(): "on" | "off" | undefined;
|
|
371
|
+
set grow(value: "on" | "off" | undefined);
|
|
372
|
+
/** The name of the data shown, for people ("Sales 2026"); with source-id. */
|
|
373
|
+
get sourceName(): string | undefined;
|
|
374
|
+
set sourceName(value: string | undefined);
|
|
375
|
+
/** The page is loading the data: the report shows its skeleton (attribute loading). */
|
|
376
|
+
get loading(): boolean;
|
|
377
|
+
set loading(value: boolean);
|
|
378
|
+
/** Controlled: the view to show; set it again from every pivot-view-change. Undefined: uncontrolled. */
|
|
379
|
+
get view(): PivotView | undefined;
|
|
380
|
+
set view(value: PivotView | undefined);
|
|
381
|
+
/**
|
|
382
|
+
* Uncontrolled: the start view. A different one (by value) starts the report again on it, with a
|
|
383
|
+
* new undo history; frameworks often set it only after the element is in the page.
|
|
384
|
+
*/
|
|
385
|
+
get defaultView(): PivotView | undefined;
|
|
386
|
+
set defaultView(value: PivotView | undefined);
|
|
387
|
+
/** The rows: an array of objects; encoded once per array, or once per `dataKey`. */
|
|
388
|
+
get data(): object[] | undefined;
|
|
389
|
+
set data(value: object[] | undefined);
|
|
390
|
+
/** The identity of `data`: a new array with the same key is not encoded again. */
|
|
391
|
+
get dataKey(): string | number | undefined;
|
|
392
|
+
set dataKey(value: string | number | undefined);
|
|
393
|
+
/** The Templates menu; the first three are also offered in the empty state. */
|
|
394
|
+
get templates(): Template[] | undefined;
|
|
395
|
+
set templates(value: Template[] | undefined);
|
|
396
|
+
/** Texts merged over the locale's labels (pivotkit-react's LABELS.en has every key). */
|
|
397
|
+
get labels(): Record<string, unknown> | undefined;
|
|
398
|
+
set labels(value: Record<string, unknown> | undefined);
|
|
399
|
+
/** Per field name: the aggregator and format of a new value, display name, description, column type. */
|
|
400
|
+
get fieldDefaults(): Record<string, FieldDefaults> | undefined;
|
|
401
|
+
set fieldDefaults(value: Record<string, FieldDefaults> | undefined);
|
|
402
|
+
/** Dismissed tip ids from the page's own storage (from pivot-tip-dismiss); "*" switches every tip off. */
|
|
403
|
+
get dismissedTips(): string[] | undefined;
|
|
404
|
+
set dismissedTips(value: string[] | undefined);
|
|
405
|
+
/**
|
|
406
|
+
* Plain JSON merged over the chart's ECharts option (a font size, axis names); it wins over the
|
|
407
|
+
* view's chart settings. Functions and values that are not JSON are left out.
|
|
408
|
+
*/
|
|
409
|
+
get chartOptions(): Record<string, unknown> | undefined;
|
|
410
|
+
set chartOptions(value: Record<string, unknown> | undefined);
|
|
411
|
+
/**
|
|
412
|
+
* The other data the page can show, as { id, name }: a view made for one of them offers "Switch to
|
|
413
|
+
* <name> and load" (event pivot-source-switch).
|
|
414
|
+
*/
|
|
415
|
+
get sources(): SourceEntry[] | undefined;
|
|
416
|
+
set sources(value: SourceEntry[] | undefined);
|
|
417
|
+
/** pivotkit-core's limits (rows, cells, ...). */
|
|
418
|
+
get limits(): Record<string, number> | undefined;
|
|
419
|
+
set limits(value: Record<string, number> | undefined);
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Defines the element under a tag name (default "pivot-report"). A name that is already defined is
|
|
423
|
+
* left alone, so loading the package twice does not throw; its constructor is returned, and a warning
|
|
424
|
+
* names both versions when the definition is not this copy's.
|
|
425
|
+
* @param {string} [name]
|
|
426
|
+
* @returns {CustomElementConstructor | undefined} undefined without customElements (Node)
|
|
427
|
+
*/
|
|
428
|
+
export declare function define(name?: string): CustomElementConstructor | undefined;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** The event names, by what they report. */
|
|
2
|
+
export declare const EVENTS: Readonly<{
|
|
3
|
+
viewChange: "pivot-view-change";
|
|
4
|
+
cellClick: "pivot-cell-click";
|
|
5
|
+
templateSave: "pivot-template-save";
|
|
6
|
+
templateDelete: "pivot-template-delete";
|
|
7
|
+
templatePublish: "pivot-template-publish";
|
|
8
|
+
export: "pivot-export";
|
|
9
|
+
tipDismiss: "pivot-tip-dismiss";
|
|
10
|
+
sourceSwitch: "pivot-source-switch";
|
|
11
|
+
}>;
|
|
12
|
+
/**
|
|
13
|
+
* Dispatches an event on the element.
|
|
14
|
+
* @param {EventTarget} target
|
|
15
|
+
* @param {string} type
|
|
16
|
+
* @param {object} detail
|
|
17
|
+
* @param {{ cancelable?: boolean }} [options]
|
|
18
|
+
* @returns {boolean} false when a listener called preventDefault()
|
|
19
|
+
*/
|
|
20
|
+
export declare function emit(target: EventTarget, type: string, detail: object, options?: {
|
|
21
|
+
cancelable?: boolean;
|
|
22
|
+
}): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Dispatches an event whose listener may answer with `event.detail.respondWith(value or promise)`,
|
|
25
|
+
* called while the event is dispatched (in the listener itself, not later). The returned promise
|
|
26
|
+
* settles with that answer: the report shows "Saved" (or removes the template) when it resolves, and
|
|
27
|
+
* an error with its message when it rejects. Without an answer it resolves at once, with a console
|
|
28
|
+
* warning: the page may have no listener, or call respondWith() too late (after an await).
|
|
29
|
+
* @param {EventTarget} target
|
|
30
|
+
* @param {string} type
|
|
31
|
+
* @param {object} detail
|
|
32
|
+
* @returns {Promise<unknown>}
|
|
33
|
+
*/
|
|
34
|
+
export declare function request(target: EventTarget, type: string, detail: object): Promise<unknown>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// The element in the DOM's type maps: document.createElement("pivot-report") and querySelector give a
|
|
2
|
+
// PivotReportElement, and addEventListener("pivot-view-change", ...) on it (or on a parent: the events
|
|
3
|
+
// bubble and are composed) knows the event's detail. Copied next to the generated declarations by
|
|
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";
|
|
6
|
+
|
|
7
|
+
/** The events of <pivot-report>. */
|
|
8
|
+
export interface PivotReportEventMap {
|
|
9
|
+
/** Every change of the view, normalized. Controlled: set `view` to `detail.view`. */
|
|
10
|
+
"pivot-view-change": CustomEvent<{ view: PivotView }>;
|
|
11
|
+
/** A click (or Enter) on a value or a chart point. */
|
|
12
|
+
"pivot-cell-click": CustomEvent<CellClick>;
|
|
13
|
+
/** "Save current view" (shown with `save-templates`); answer with `detail.respondWith(promise)`. */
|
|
14
|
+
"pivot-template-save": CustomEvent<TemplateSave>;
|
|
15
|
+
/** Delete of a template marked `deletable`, after the user confirmed; answer with `detail.respondWith(promise)`. */
|
|
16
|
+
"pivot-template-delete": CustomEvent<TemplateDelete>;
|
|
17
|
+
/** "Publish as shared view" on a user's view (shown with `can-publish`); answer with `detail.respondWith(promise)`. */
|
|
18
|
+
"pivot-template-publish": CustomEvent<TemplatePublish>;
|
|
19
|
+
/** Every exported file before its download and every copy before the clipboard; `preventDefault()` skips it. */
|
|
20
|
+
"pivot-export": CustomEvent<ExportFile>;
|
|
21
|
+
/** A tip dismissed, all tips switched off or back on; `detail.dismissed` is the whole list to store. */
|
|
22
|
+
"pivot-tip-dismiss": CustomEvent<TipDismiss>;
|
|
23
|
+
/** "Switch to <name> and load" for a view made for other data (one of `sources`): show that data with `detail.view`. */
|
|
24
|
+
"pivot-source-switch": CustomEvent<SourceSwitch>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
declare global {
|
|
28
|
+
interface HTMLElementTagNameMap {
|
|
29
|
+
"pivot-report": PivotReportElement;
|
|
30
|
+
}
|
|
31
|
+
// on the element, a parent, the document and the window: the events bubble and are composed
|
|
32
|
+
interface GlobalEventHandlersEventMap extends PivotReportEventMap {}
|
|
33
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference path="./global.d.ts" />
|
|
2
|
+
export type PivotView = import("./element.js").PivotView;
|
|
3
|
+
export type Template = import("./element.js").Template;
|
|
4
|
+
export type FieldDefaults = import("./element.js").FieldDefaults;
|
|
5
|
+
export type CellClick = import("./element.js").CellClick;
|
|
6
|
+
export type ExportFile = import("./element.js").ExportFile;
|
|
7
|
+
export type TemplateSave = import("./element.js").TemplateSave;
|
|
8
|
+
export type TemplateDelete = import("./element.js").TemplateDelete;
|
|
9
|
+
export type TemplatePublish = import("./element.js").TemplatePublish;
|
|
10
|
+
export type PivotReportEventMap = import("./global.js").PivotReportEventMap;
|
|
11
|
+
/**
|
|
12
|
+
* @typedef {import("./element.js").PivotView} PivotView
|
|
13
|
+
* @typedef {import("./element.js").Template} Template
|
|
14
|
+
* @typedef {import("./element.js").FieldDefaults} FieldDefaults
|
|
15
|
+
* @typedef {import("./element.js").CellClick} CellClick
|
|
16
|
+
* @typedef {import("./element.js").ExportFile} ExportFile
|
|
17
|
+
* @typedef {import("./element.js").TemplateSave} TemplateSave
|
|
18
|
+
* @typedef {import("./element.js").TemplateDelete} TemplateDelete
|
|
19
|
+
* @typedef {import("./element.js").TemplatePublish} TemplatePublish
|
|
20
|
+
* @typedef {import("./global.js").PivotReportEventMap} PivotReportEventMap
|
|
21
|
+
*/
|
|
22
|
+
export { EVENTS, PivotReportElement, TAG, define } from "./element.js";
|
package/types/jsx.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Opt-in JSX types for React: `import type {} from "pivotkit-element/jsx";` once in a React app
|
|
2
|
+
// makes <pivot-report> a known element with its properties and its events as `on<event-name>` props.
|
|
3
|
+
// They describe React 19, which sets a prop as a property when the element has one and listens for a
|
|
4
|
+
// custom event through `on` + its exact name (react.dev, "Custom HTML elements"). React 18 passes
|
|
5
|
+
// every prop as an attribute and has no custom event props: set objects and listeners in a ref there.
|
|
6
|
+
// Copied next to the generated declarations by types.js; needs @types/react 18.3 or later.
|
|
7
|
+
import type { DetailedHTMLProps, HTMLAttributes } from "react";
|
|
8
|
+
import type { PivotReportElement } from "./element.js";
|
|
9
|
+
import type { PivotReportEventMap } from "./global.js";
|
|
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";
|
|
12
|
+
|
|
13
|
+
/** The props of <pivot-report> in JSX. */
|
|
14
|
+
export type PivotReportJsxProps = DetailedHTMLProps<HTMLAttributes<PivotReportElement>, PivotReportElement> &
|
|
15
|
+
Partial<Pick<PivotReportElement, Settable>> & {
|
|
16
|
+
[K in keyof PivotReportEventMap as `on${K}`]?: (event: PivotReportEventMap[K]) => void;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
declare module "react" {
|
|
20
|
+
namespace JSX {
|
|
21
|
+
interface IntrinsicElements {
|
|
22
|
+
"pivot-report": PivotReportJsxProps;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|