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.
Files changed (46) hide show
  1. package/CHANGELOG.md +121 -1
  2. package/README.md +1 -1
  3. package/dist/chunks/{chunk-32Z33U6S.js → chunk-6MDAL3IO.js} +28 -3
  4. package/dist/chunks/{chunk-APB4NW4O.js → chunk-LEN5RPBM.js} +3 -6
  5. package/dist/chunks/{chunk-7CC4JHDY.js → chunk-WB4GKWFQ.js} +1 -4
  6. package/dist/chunks/chunk-XN55BQ4M.js +618 -0
  7. package/dist/chunks/{chunk-IOPAM4JD.js → chunk-YITKWZ4L.js} +48 -492
  8. package/dist/chunks/chunk-ZYEYZSYL.js +187 -0
  9. package/dist/import-ui.js +769 -0
  10. package/dist/import-worker.js +20 -0
  11. package/dist/index.js +599 -175
  12. package/dist/labels.js +14 -10
  13. package/dist/menu-texts-de.js +1 -1
  14. package/dist/menus.js +132 -68
  15. package/dist/styles.css +116 -8
  16. package/package.json +3 -2
  17. package/types/data-history.d.ts +85 -0
  18. package/types/data-keep.d.ts +51 -0
  19. package/types/data-menu.d.ts +11 -0
  20. package/types/dom.d.ts +40 -7
  21. package/types/field-info.d.ts +32 -0
  22. package/types/import-host.d.ts +53 -0
  23. package/types/import-labels.d.ts +360 -0
  24. package/types/import-module.d.ts +2 -0
  25. package/types/import-run.d.ts +73 -0
  26. package/types/import-source.d.ts +32 -0
  27. package/types/import-steps.d.ts +121 -0
  28. package/types/import-ui.d.ts +108 -0
  29. package/types/import-worker.d.ts +1 -0
  30. package/types/index.d.ts +56 -4
  31. package/types/labels.d.ts +26 -2
  32. package/types/lazy-import.d.ts +4 -0
  33. package/types/lazy-menus.d.ts +2 -2
  34. package/types/levels.d.ts +3 -2
  35. package/types/menu-labels.d.ts +0 -3
  36. package/types/menu-topics.d.ts +2 -4
  37. package/types/menus.d.ts +1 -0
  38. package/types/overflow.d.ts +29 -17
  39. package/types/popover.d.ts +47 -5
  40. package/types/section.d.ts +2 -2
  41. package/types/toasts.d.ts +1 -1
  42. package/types/toolbar-panels.d.ts +6 -5
  43. package/types/unused-keep.d.ts +20 -0
  44. package/types/unused.d.ts +1 -0
  45. package/types/use-view-history.d.ts +12 -4
  46. package/types/virtual.d.ts +15 -0
package/CHANGELOG.md CHANGED
@@ -6,6 +6,125 @@ All notable changes to `pivotkit-react` are documented in this file. The format
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.4.0] - 2026-11-11
10
+
11
+ ### Added
12
+
13
+ - Loading data in the browser ([#44](https://github.com/eizedev/pivotkit/issues/44)), with the new
14
+ prop `allowImport` (off by default): a **Data** button before Views (under More on a narrow report)
15
+ with the data source (name, rows × columns), **Load data…** and **Back to original data**; a file
16
+ dropped onto the report, with an overlay while it is dragged; a preview before the data is
17
+ replaced: the sheet of a workbook, the first rows, a type per column (Text, Number, Date, Yes/No),
18
+ the readers' notes, progress and **Cancel** while it reads, Escape to cancel. A file that cannot be
19
+ read keeps the data and says why with the reader's message. Loading is a step of the undo history
20
+ (Undo and Redo move between the data sets with their own views, up to three kept); a dot on Data
21
+ and a line under the result name the file while its data is shown. The empty report offers to load a
22
+ file ("Load data to start" without data). Texts in English and German (`labels.dataImport`).
23
+ - `plugins`: reader plugins of `pivotkit-core/import` (pivotkit-xlsx for Excel workbooks);
24
+ `onDataLoad`: every change of the data shown (`cause` "load", "original", "undo", "redo"; returning
25
+ `false` refuses a file); `importWorker`: a module worker (the new entry `pivotkit-react/import-worker`)
26
+ that reads CSV and JSON off the page, with the page as the fallback.
27
+ - While a file's data is shown the report's source is the file's: its name and the first 16 hex digits
28
+ of the SHA-256 of its name and column names, so the browser store keeps views per file.
29
+ - A report mounted again by its host ([#131](https://github.com/eizedev/pivotkit/issues/131)), as
30
+ PowerShell Universal does on its light/dark switch and on `Sync-UDElement`, shows the loaded file
31
+ again with its view and its undo steps, when it has the same `storageKey` and the host's data is
32
+ the same (`dataKey`, else its columns, and `source`). Kept in the page's memory only, never in
33
+ browser storage, for up to four reports; let go when the host's data is shown again. `onDataLoad`
34
+ hears it as `cause` "restore".
35
+ - `data` takes columnar data (`{ columns, types, data }`), as pivotkit-core's `encode` does.
36
+ - The import UI is a file of its own, `dist/import-ui.js` (with `pivotkit-core/import`, which this
37
+ release needs from pivotkit-core), loaded on its first use; the first load keeps the Data button and
38
+ the drop handler.
39
+
40
+ - Identifier fields ([#113](https://github.com/eizedev/pivotkit/issues/113)): a number field of whole numbers whose name ends in the word ID, Nr,
41
+ No, Number, Key or "#" ("ID", "CustomerId", "customer_id", "Order No", "Serial #", "userID2", "ID
42
+ (Asset)"; not "Paid", "UUID" or "Number of items"), for which
43
+ `fieldDefaults` sets none of `agg`, `format` and `drillFormat`, is counted when it is added to
44
+ Values (from the field list, by a drag or by Move to; Sum stays a choice) and shows its numbers as
45
+ they are in the drill-down (27000, not 27,000). Any of the three entries overrides it.
46
+ - The token `--pk-layer-z` (default `50`): the z-index of the layer of menus, sheets and popups in a
47
+ browser without the Popover API ([#111](https://github.com/eizedev/pivotkit/issues/111)).
48
+ - The host's own view (`view`, else the first `defaultView`) is warned about like a loaded view when
49
+ the data cannot use parts of it, once per distinct view, not while `loading` ([#83](https://github.com/eizedev/pivotkit/issues/83)).
50
+
51
+ ### Changed
52
+
53
+ - UI: **Start over** in the toolbar, a menu button after Undo and Redo, replaces the Reset button. It
54
+ holds **Reset** ("Back to the start view. Your data stays.") and **New, empty report** ("No fields.
55
+ Undo brings it back. Your data stays."), each greyed out with its reason ("Already at the start
56
+ view.", "The report is empty already."); Reset is also off when the start view is the empty report
57
+ ("The start view is empty: use New, empty report."). When both are off, Start over itself is off
58
+ (focusable, `aria-disabled`, with the reason "The report is empty already." as its description
59
+ and tooltip). Enter, Space or the down arrow opens it. In
60
+ More, Reset and New are entries of their own. The test id `reset` is now Reset's entry in that menu
61
+ (`start-over` is the button; `new-report` and `more-new-report` New's), so a host's test that
62
+ clicked `reset` opens Start over first. New labels `startOver`, `resetAlready`, `resetStartEmpty`,
63
+ `newHint`; `resetHint` is the new longer text; `newAlready` is a first-load text now
64
+ ([#88](https://github.com/eizedev/pivotkit/issues/88)).
65
+ - UI: the Views menu holds what persists, in four groups: This view (Save, Save as…), Shared views,
66
+ My views, Share this view (Copy link, Copy view as JSON, Download view, Open view file…), with no
67
+ Share level in between. "New, empty report" left it for Start over; "Load view…" reads "Open view
68
+ file…" (the label `loadView`; German "Ansichtsdatei öffnen…"), its level "Views › Open view file".
69
+ The labels `share` and `settingInfo.newReport` are gone.
70
+ - UI: every menu draws its groups alike: each group's title in bold, as Export's, with a rule between
71
+ one group and the next (Options, Views, the chart type, More, a chip menu's levels such as "More
72
+ statistics"); More has rules only; the chart's Display parts its own groups (Value labels, Legend,
73
+ Title, ...) with a dashed rule, each a named group for a screen reader. One component draws them
74
+ (`Group` in popover.jsx) ([#105](https://github.com/eizedev/pivotkit/issues/105)).
75
+ - An item of a toolbar menu (Start over, More) that is greyed out stays reachable with the arrow keys
76
+ (`aria-disabled`), so a screen reader hears its reason.
77
+ - Reset's note "Back to the start view" has **Undo**, as New's has. In More, a letter jumps to the
78
+ next entry that starts with it, as in the other menus, and Layout is a checkbox item
79
+ (`menuitemcheckbox`), not one of a set of choices.
80
+
81
+ ### Fixed
82
+
83
+ - A loaded file shown again after a new mount lost its view when the host mounted the report twice in
84
+ a row (PowerShell Universal's `Sync-UDElement`, two mounts within about 30 ms) or mounted it again
85
+ before it passed back a view it was told: the report now starts on the kept view history at once,
86
+ and keeps the view it told a host that controls the view, not the host's view from before
87
+ ([#135](https://github.com/eizedev/pivotkit/issues/135)).
88
+ - Toolbar buttons moved into More although the free room would hold some of them (a report about
89
+ 1,000 px wide showed Reset, Layout and Options in More next to a wide gap). A button moves now only
90
+ when the room left cannot hold it: the room is measured with the texts of the report's language
91
+ (not the longest of every language), and a button that fits stays even when one before it in the
92
+ order had to go. The chart type keeps the room of its longest type, so picking one never moves a
93
+ button, and while a toolbar menu is open nothing moves (a language change keeps the menu, its
94
+ button and its focus). The order is Layout, Options, the chart type, then Start over (where New is) and Views
95
+ last; More lists them in groups
96
+ ([#88](https://github.com/eizedev/pivotkit/issues/88)).
97
+ - Menus, bottom sheets and "i" popups opened by a click open in the browser's top layer
98
+ (`popover="manual"`; a description shown on hover stays in the report's layer): a host's
99
+ fixed navigation above z-index 50 (PowerShell Universal's drawer at 1200) no longer covers the left
100
+ of a sheet or an "About" popup at 800 px or less ([#111](https://github.com/eizedev/pivotkit/issues/111)). They stay in the report's DOM, so its
101
+ tokens and the web component's shadow styles apply; Tab inside them is moved by the report (WebKit
102
+ left a top-layer popover for the page's body), past the last control a popover closes and the
103
+ focus goes back to its button.
104
+ - A large table scrolls in one box: the screen reader texts of empty cells no longer made the result
105
+ area scroll as well, with two scroll bars side by side ([#112](https://github.com/eizedev/pivotkit/issues/112)).
106
+ - A virtual table's row label column (300 rows or more) keeps its width while the table scrolls:
107
+ measured per view and data over its 50 longest labels in the table's own font (again when the font,
108
+ its size or a web font changes), at most 28em, a longer label cut with "…" and whole in its tooltip
109
+ ([#110](https://github.com/eizedev/pivotkit/issues/110), [#121](https://github.com/eizedev/pivotkit/issues/121)).
110
+ - Tab in a bottom sheet: one Tab from a chip menu's first level closes it and moves on from its chip;
111
+ a level with fields keeps Tab inside the sheet (Chromium let it out to the page). One definition of
112
+ a Tab stop for every layer (`tabStops`).
113
+ - Field names in the field list break between words only; a word too long for its line ends in "…"
114
+ ([#114](https://github.com/eizedev/pivotkit/issues/114)). The field list is wider (`--pk-panel-w`
115
+ 288 px, at most 284 px on a medium report; it was 268 and 244) and a field's menu button takes the
116
+ least room a control may (24 px), so a name of up to about 16 characters fits next to its zone mark.
117
+ - A description opened on a narrow report is a bottom sheet as wide as the window, not a 320 px box.
118
+ - Every `input`, `select` and `textarea` has a `name` of its own report (unique also across two web
119
+ components on a page) and a label; Chrome listed them as form fields without an id or name
120
+ ([#115](https://github.com/eizedev/pivotkit/issues/115)).
121
+ - A line of the warning about a view's unused parts goes once its part of the view is changed by
122
+ hand, and comes back with Undo ([#82](https://github.com/eizedev/pivotkit/issues/82)).
123
+ - A modal layer (the file preview, the drill-down, the field drawer) whose first frame comes late
124
+ (WebKit) no longer takes the focus back from a control inside it: **Load data** keeps the focus once
125
+ the first rows are read, and the sheet list keeps it after a sheet over the limits
126
+ ([#136](https://github.com/eizedev/pivotkit/issues/136)).
127
+
9
128
  ## [0.3.0] - 2026-11-09
10
129
 
11
130
  ### Added
@@ -599,7 +718,8 @@ First release.
599
718
  weather (Open-Meteo), countries (World Bank), earthquakes (USGS), Nobel laureates and the release
600
719
  cycles of software products (endoflife.date).
601
720
 
602
- [Unreleased]: https://github.com/eizedev/pivotkit/compare/pivotkit-react@0.3.0...HEAD
721
+ [Unreleased]: https://github.com/eizedev/pivotkit/compare/pivotkit-react@0.4.0...HEAD
722
+ [0.4.0]: https://github.com/eizedev/pivotkit/compare/pivotkit-react@0.3.0...pivotkit-react@0.4.0
603
723
  [0.3.0]: https://github.com/eizedev/pivotkit/compare/pivotkit-react@0.2.0...pivotkit-react@0.3.0
604
724
  [0.2.0]: https://github.com/eizedev/pivotkit/compare/pivotkit-react@0.1.0...pivotkit-react@0.2.0
605
725
  [0.1.0]: https://github.com/eizedev/pivotkit/releases/tag/pivotkit-react@0.1.0
package/README.md CHANGED
@@ -26,7 +26,7 @@ npm install pivotkit-react react react-dom echarts
26
26
 
27
27
  TypeScript declarations are included. pivotkit-core (a caret range) and @dnd-kit come with the
28
28
  package. In 0.x a caret range spans patch
29
- versions only (`^0.3.0` is 0.3.x): an app that also imports pivotkit-core itself must use a version
29
+ versions only (`^0.4.0` is 0.4.x): an app that also imports pivotkit-core itself must use a version
30
30
  inside that range, since npm shares one copy only when the ranges overlap.
31
31
 
32
32
  ## Example
@@ -68,8 +68,15 @@ var en = {
68
68
  chartTypes: { auto: "Automatic", bar: "Bars", stacked: "Stacked bars", horizontal: "Horizontal bars", line: "Lines", area: "Area", pie: "Pie", donut: "Donut", heatmap: "Heatmap" },
69
69
  undo: "Undo",
70
70
  redo: "Redo",
71
+ // Start over: the toolbar's menu of Reset and New (or their entries in More), each with what it
72
+ // does and, while it does nothing, why
73
+ startOver: "Start over",
71
74
  reset: "Reset",
72
- resetHint: "Back to the start view",
75
+ resetHint: "Back to the start view. Your data stays.",
76
+ resetAlready: "Already at the start view.",
77
+ resetStartEmpty: "The start view is empty: use New, empty report.",
78
+ newHint: "No fields. Undo brings it back. Your data stays.",
79
+ newAlready: "The report is empty already.",
73
80
  // next to Views: the name of the view loaded, and the mark while it has changes not saved
74
81
  unsavedChanges: "Unsaved changes",
75
82
  swap: "Swap rows and columns",
@@ -80,6 +87,13 @@ var en = {
80
87
  more: "More",
81
88
  // the Views menu: the saved views (the host's templates) and sharing
82
89
  views: "Views",
90
+ // loading data (allowImport): the Data button, its dot while a file's data is shown, the empty report
91
+ data: "Data",
92
+ dataLoaded: "Data from a file",
93
+ loadData: "Load data\u2026",
94
+ emptyLoad: "Or load your own data: drop a file onto the report, or",
95
+ emptyDrop: "Drop a file onto the report, or",
96
+ emptyNoData: "Load data to start",
83
97
  exportLabel: "Export",
84
98
  options: "Options",
85
99
  expand: "Expand {label}",
@@ -186,7 +200,7 @@ var en = {
186
200
  toastUndone: "Undone: {step}",
187
201
  toastRedone: "Redone: {step}",
188
202
  toastReset: "Back to the start view",
189
- // New's step said in the status line, and its entry in the Views menu
203
+ // New's entry under Start over, and its step said in the status line
190
204
  newEmpty: "New, empty report",
191
205
  toastLoaded: "View \u201C{name}\u201D loaded",
192
206
  toastExportFailed: "Export failed: {message}",
@@ -415,8 +429,13 @@ var de = {
415
429
  chartTypes: { auto: "Automatisch", bar: "Balken", stacked: "Gestapelte Balken", horizontal: "Liegende Balken", line: "Linien", area: "Fl\xE4che", pie: "Kreis", donut: "Ring", heatmap: "Heatmap" },
416
430
  undo: "R\xFCckg\xE4ngig",
417
431
  redo: "Wiederholen",
432
+ startOver: "Neu beginnen",
418
433
  reset: "Zur\xFCcksetzen",
419
- resetHint: "Zur\xFCck zur Startansicht",
434
+ resetHint: "Zur\xFCck zur Startansicht. Deine Daten bleiben.",
435
+ resetAlready: "Schon in der Startansicht.",
436
+ resetStartEmpty: "Die Startansicht ist leer: Nimm \u201ENeuer, leerer Bericht\u201C.",
437
+ newHint: "Keine Felder. R\xFCckg\xE4ngig bringt den Bericht zur\xFCck. Deine Daten bleiben.",
438
+ newAlready: "Der Bericht ist schon leer.",
420
439
  unsavedChanges: "Nicht gespeicherte \xC4nderungen",
421
440
  swap: "Zeilen und Spalten tauschen",
422
441
  layout: "Anordnung",
@@ -424,6 +443,12 @@ var de = {
424
443
  layoutEmpty: "Noch keine Felder angeordnet",
425
444
  more: "Mehr",
426
445
  views: "Ansichten",
446
+ data: "Daten",
447
+ dataLoaded: "Daten aus einer Datei",
448
+ loadData: "Daten laden\u2026",
449
+ emptyLoad: "Oder eigene Daten laden: eine Datei auf den Bericht ziehen, oder",
450
+ emptyDrop: "Eine Datei auf den Bericht ziehen, oder",
451
+ emptyNoData: "Daten laden, um zu beginnen",
427
452
  exportLabel: "Export",
428
453
  options: "Optionen",
429
454
  expand: "{label} aufklappen",
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  MENU_TEXTS,
3
3
  mergeLabels
4
- } from "./chunk-32Z33U6S.js";
4
+ } from "./chunk-6MDAL3IO.js";
5
5
 
6
6
  // src/menu-labels.js
7
7
  var en = {
@@ -23,7 +23,6 @@ var en = {
23
23
  groupLabels: "With two or more fields in Rows: the outer field's items written once under the axis, below their categories.",
24
24
  labelPosition: "Outside: each slice's name and number next to it. Inside: the number on the slice, the names in the legend; outside when a donut's ring is too thin for it.",
25
25
  sharedView: "Only admins can change shared views.",
26
- newReport: "Takes every field out, to start over. Undo brings them back; saved views stay.",
27
26
  valuesFilter: "Values are not filtered here: filter a field on Rows or Columns through its menu, or move a field to Filters."
28
27
  },
29
28
  // a menu in levels: the way back, a level's title, the search of a menu
@@ -206,7 +205,6 @@ var en = {
206
205
  replaceConfirm: "\u201C{name}\u201D exists. Replace it?",
207
206
  replaceAction: "Replace",
208
207
  replaceSharedConfirm: "Replace the shared view \u201C{name}\u201D for everyone?",
209
- newAlready: "The report is empty already.",
210
208
  save: "Save",
211
209
  cancel: "Cancel",
212
210
  expandAll: "Expand all",
@@ -348,15 +346,14 @@ var en = {
348
346
  groupLabels: "Group labels under the axis",
349
347
  groupLabelNames: { auto: "Automatic", on: "On", off: "Off" },
350
348
  defaultName: "Use the default name",
351
- // sharing a view (the Views menu): the group heading above the Share row, and the row
349
+ // sharing a view (the Views menu): the group's title
352
350
  shareThisView: "Share this view",
353
- share: "Share",
354
351
  copyLink: "Copy link",
355
352
  copyJson: "Copy view as JSON",
356
353
  downloadView: "Download view (.pivotkit.json)",
357
354
  // said where a view leaves the report as a file, as JSON or as a link
358
355
  sharePrivacy: "A view holds the names of fields and, in its filters, the values chosen there: share it only where those may be seen.",
359
- loadView: "Load view\u2026",
356
+ loadView: "Open view file\u2026",
360
357
  loadViewHint: "Paste a view file, a view as JSON or a link, or choose a .pivotkit.json file.",
361
358
  loadViewText: "View as JSON or link",
362
359
  chooseFile: "Choose file\u2026",
@@ -17,7 +17,6 @@ var de = {
17
17
  groupLabels: "Mit zwei oder mehr Feldern in Zeilen: die Eintr\xE4ge des \xE4u\xDFeren Felds einmal unter der Achse, unter ihren Kategorien.",
18
18
  labelPosition: "Au\xDFen: Name und Zahl jedes Segments daneben. Innen: die Zahl auf dem Segment, die Namen in der Legende; au\xDFen, wenn der Ring eines Donuts daf\xFCr zu schmal ist.",
19
19
  sharedView: "Nur Admins k\xF6nnen gemeinsame Ansichten \xE4ndern.",
20
- newReport: "Nimmt alle Felder heraus, um neu anzufangen. R\xFCckg\xE4ngig holt sie zur\xFCck; gespeicherte Ansichten bleiben.",
21
20
  valuesFilter: "Werte werden hier nicht gefiltert: Ein Feld in Zeilen oder Spalten \xFCber sein Men\xFC filtern oder ein Feld in Filter ziehen."
22
21
  },
23
22
  back: "Zur\xFCck",
@@ -177,7 +176,6 @@ var de = {
177
176
  replaceConfirm: "\u201E{name}\u201C gibt es schon. Ersetzen?",
178
177
  replaceAction: "Ersetzen",
179
178
  replaceSharedConfirm: "Die gemeinsame Ansicht \u201E{name}\u201C f\xFCr alle ersetzen?",
180
- newAlready: "Der Bericht ist schon leer.",
181
179
  save: "Speichern",
182
180
  cancel: "Abbrechen",
183
181
  expandAll: "Alle aufklappen",
@@ -312,12 +310,11 @@ var de = {
312
310
  groupLabelNames: { auto: "Automatisch", on: "Ein", off: "Aus" },
313
311
  defaultName: "Standardnamen verwenden",
314
312
  shareThisView: "Diese Ansicht teilen",
315
- share: "Teilen",
316
313
  copyLink: "Link kopieren",
317
314
  copyJson: "Ansicht als JSON kopieren",
318
315
  downloadView: "Ansicht herunterladen (.pivotkit.json)",
319
316
  sharePrivacy: "Eine Ansicht enth\xE4lt die Namen der Felder und in ihren Filtern die dort gew\xE4hlten Werte: Nur dort teilen, wo diese gesehen werden d\xFCrfen.",
320
- loadView: "Ansicht laden\u2026",
317
+ loadView: "Ansichtsdatei \xF6ffnen\u2026",
321
318
  loadViewHint: "Eine Ansichtsdatei, eine Ansicht als JSON oder einen Link einf\xFCgen oder eine .pivotkit.json-Datei w\xE4hlen.",
322
319
  loadViewText: "Ansicht als JSON oder Link",
323
320
  chooseFile: "Datei w\xE4hlen\u2026",