pivotkit-react 0.2.0 → 0.3.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 (39) hide show
  1. package/CHANGELOG.md +164 -1
  2. package/README.md +1 -1
  3. package/dist/chunks/{chunk-F6MVUAQD.js → chunk-32Z33U6S.js} +23 -0
  4. package/dist/chunks/{chunk-QBD4FOBB.js → chunk-7CC4JHDY.js} +123 -14
  5. package/dist/chunks/{chunk-LQCWFJBS.js → chunk-APB4NW4O.js} +146 -22
  6. package/dist/chunks/{chunk-53ZMK4BH.js → chunk-EM23V5GH.js} +6 -0
  7. package/dist/chunks/{chunk-X7H7BAVT.js → chunk-IOPAM4JD.js} +307 -179
  8. package/dist/chunks/{chunk-OYY4BKIL.js → chunk-RWYHJRQO.js} +6 -0
  9. package/dist/chunks/{unused-texts-YTNJCFFC.js → unused-texts-K3VFH65P.js} +1 -1
  10. package/dist/chunks/{unused-texts-de-SGOHV4N7.js → unused-texts-de-OW4TGIVX.js} +1 -1
  11. package/dist/index.js +58 -56
  12. package/dist/labels.js +5 -5
  13. package/dist/menu-texts-de.js +1 -1
  14. package/dist/menus.js +2429 -670
  15. package/dist/styles.css +557 -117
  16. package/package.json +2 -2
  17. package/types/chip-menus.d.ts +20 -4
  18. package/types/dnd.d.ts +8 -4
  19. package/types/filter-level.d.ts +16 -0
  20. package/types/filter.d.ts +31 -0
  21. package/types/help.d.ts +0 -7
  22. package/types/labels.d.ts +71 -0
  23. package/types/lazy-menus.d.ts +2 -2
  24. package/types/levels.d.ts +105 -0
  25. package/types/menu-fields.d.ts +80 -0
  26. package/types/menu-labels.d.ts +214 -19
  27. package/types/menu-ops.d.ts +150 -9
  28. package/types/menu-topics.d.ts +293 -0
  29. package/types/menus.d.ts +1 -1
  30. package/types/names.d.ts +141 -1
  31. package/types/place.d.ts +44 -0
  32. package/types/section.d.ts +8 -11
  33. package/types/tips.d.ts +1 -36
  34. package/types/toolbar-panels.d.ts +15 -8
  35. package/types/unused-texts.d.ts +6 -0
  36. package/types/use-view-history.d.ts +2 -1
  37. package/types/view-ops.d.ts +12 -0
  38. package/types/zones.d.ts +5 -4
  39. package/types/sections.d.ts +0 -2
@@ -1,6 +1,7 @@
1
1
  import {
2
- fill
3
- } from "./chunk-F6MVUAQD.js";
2
+ fill,
3
+ plural
4
+ } from "./chunk-32Z33U6S.js";
4
5
 
5
6
  // src/chart-types.js
6
7
  import { autoChartType } from "pivotkit-core";
@@ -52,7 +53,7 @@ var MANY_SERIES = 8;
52
53
  var MAX_CATEGORIES = 50;
53
54
 
54
55
  // src/names.js
55
- import { fieldLabel } from "pivotkit-core";
56
+ import { fieldLabel, relativeDateRange } from "pivotkit-core";
56
57
  function valueLabel(spec, labels) {
57
58
  if (spec.label) {
58
59
  return spec.label;
@@ -72,11 +73,12 @@ function valueLabel(spec, labels) {
72
73
  return fill(core.showAsName, { showAs, value: spec.field && spec.agg === "sum" ? fieldLabel(spec.field, core) : base });
73
74
  }
74
75
  function refLabel(view, ref, labels) {
75
- if (!ref) {
76
- return labels.core.countRows;
76
+ const field = ref?.field ?? null;
77
+ const sameField = (v) => field === null || v.field === null || v.field === void 0 ? (v.field ?? null) === field : v.field.toLowerCase() === field.toLowerCase();
78
+ const spec = ref ? (view.values ?? []).find((v) => v.agg === ref.agg && sameField(v)) : void 0;
79
+ if (!spec && field === null) {
80
+ return labels.countOfRows;
77
81
  }
78
- const sameField = (v) => ref.field === null || v.field === null || v.field === void 0 ? (v.field ?? null) === ref.field : v.field.toLowerCase() === ref.field.toLowerCase();
79
- const spec = (view.values ?? []).find((v) => v.agg === ref.agg && sameField(v));
80
82
  return valueLabel({ ...spec ?? ref, showAs: null }, labels);
81
83
  }
82
84
  function sortText(view, sort, labels) {
@@ -99,6 +101,126 @@ function valueConditionText(view, f, labels, locale) {
99
101
  }
100
102
  return fill(labels.valueConditions.compare, { value, op: Object.hasOwn(OP_SIGNS, f.op) ? OP_SIGNS[f.op] : f.op, number: number(f.value) });
101
103
  }
104
+ var dayText = (iso, locale) => (/* @__PURE__ */ new Date(`${iso}T00:00Z`)).toLocaleDateString(locale, { dateStyle: "medium", timeZone: "UTC" });
105
+ var isoDay = (ms) => new Date(ms).toISOString().slice(0, 10);
106
+ var dayAfter = (iso, n = 1) => isoDay(Date.parse(`${iso}T00:00Z`) + n * 864e5);
107
+ var relativeDays = (f, timeZone, now, latest) => relativeDateRange(f.unit, f.count, { timeZone, now, anchor: f.anchor, latest: latest ?? void 0 });
108
+ function periodText(range, unit, locale) {
109
+ const month = (iso) => (/* @__PURE__ */ new Date(`${iso}T00:00Z`)).toLocaleDateString(locale, { month: "short", year: "numeric", timeZone: "UTC" });
110
+ const text = unit === "year" ? (iso) => iso.slice(0, 4) : unit === "month" ? month : (iso) => dayText(iso, locale);
111
+ const [from, to] = [text(range.from), text(range.to)];
112
+ return from === to ? from : `${from}\u2013${to}`;
113
+ }
114
+ function rangeShare(range, unit, span, locale) {
115
+ const [first, last] = [periodStart(isoDay(span.min), unit), periodEnd(isoDay(span.max), unit)];
116
+ if (first <= range.from && last >= range.to) {
117
+ return null;
118
+ }
119
+ const from = range.from > first ? range.from : first;
120
+ const to = range.to < last ? range.to : last;
121
+ if (from > to) {
122
+ return { none: true };
123
+ }
124
+ const missing = [];
125
+ let count = 0;
126
+ const part = (a, b, dataYear) => {
127
+ const years = [];
128
+ const [ya, yb] = [Number(a.slice(0, 4)), Number(b.slice(0, 4))];
129
+ for (let y = ya; y <= yb; y++) {
130
+ if (y !== dataYear) {
131
+ years.push(y);
132
+ }
133
+ }
134
+ if (years.length) {
135
+ missing.push(years.length === 1 ? String(years[0]) : `${years[0]}\u2013${years[years.length - 1]}`);
136
+ count += years.length;
137
+ }
138
+ if (ya <= dataYear && dataYear <= yb) {
139
+ const yearFrom = `${String(dataYear).padStart(4, "0")}-01-01`;
140
+ const yearTo = `${String(dataYear).padStart(4, "0")}-12-31`;
141
+ const rest = { from: a > yearFrom ? a : yearFrom, to: b < yearTo ? b : yearTo };
142
+ missing.push(periodText(rest, unit, locale));
143
+ count += periodText({ from: rest.from, to: rest.from }, unit, locale) === periodText({ from: rest.to, to: rest.to }, unit, locale) ? 1 : 2;
144
+ }
145
+ };
146
+ if (range.from < first) {
147
+ part(range.from, dayAfter(first, -1), Number(first.slice(0, 4)));
148
+ }
149
+ if (range.to > last) {
150
+ part(dayAfter(last), range.to, Number(last.slice(0, 4)));
151
+ }
152
+ return { none: false, data: periodText({ from, to }, unit, locale), missing, count };
153
+ }
154
+ var periodStart = (iso, unit) => unit === "year" ? `${iso.slice(0, 4)}-01-01` : unit === "month" ? `${iso.slice(0, 7)}-01` : iso;
155
+ function periodEnd(iso, unit) {
156
+ if (unit === "day") {
157
+ return iso;
158
+ }
159
+ const [y, m] = [Number(iso.slice(0, 4)), Number(iso.slice(5, 7))];
160
+ return isoDay(unit === "year" ? Date.UTC(y, 11, 31) : Date.UTC(y, m, 0));
161
+ }
162
+ function relativeText(f, labels, locale, timeZone, now, span) {
163
+ const key = f.count === 1 ? f.unit : `${f.unit}s`;
164
+ let text = fill(Object.hasOwn(labels.relative, key) ? labels.relative[key] : key, { count: f.count.toLocaleString(locale) });
165
+ const range = relativeDays(f, timeZone, now, span?.max);
166
+ if (!range) {
167
+ return text;
168
+ }
169
+ const latest = f.anchor === "latest";
170
+ if (latest) {
171
+ text = fill(labels.relativeTo, { text, end: periodText({ from: range.to, to: range.to }, f.unit, locale) });
172
+ }
173
+ const share = span ? rangeShare(range, f.unit, span, locale) : null;
174
+ if (!share) {
175
+ return latest ? text : fill(labels.withRange, { text, range: periodText(range, f.unit, locale) });
176
+ }
177
+ const lang = { lang: labels.lang, locale };
178
+ if (share.none) {
179
+ return fill(labels.withRange, { text, range: fill(plural(labels.noData, 1, lang), { range: periodText(range, f.unit, locale) }) });
180
+ }
181
+ return fill(labels.withShare, { text, range: share.data, missing: fill(plural(labels.noData, share.count, lang), { range: share.missing.join(", ") }) });
182
+ }
183
+ function wholeYears(from, to) {
184
+ const whole = typeof from === "string" && typeof to === "string" && /^\d{4}-01-01$/.test(from) && /^\d{4}-12-31$/.test(to);
185
+ return whole ? [from.slice(0, 4), to.slice(0, 4)] : null;
186
+ }
187
+ function compareText(f, labels, locale, { date, labelOf }) {
188
+ const shown = (v) => typeof v === "string" ? dayText(v, locale) : labelOf?.(v) ?? (date ? String(v) : v.toLocaleString(locale, { maximumFractionDigits: 6 }));
189
+ const forms = labels.compareShort;
190
+ if (f.op === "between" || f.op === "notBetween") {
191
+ const [from, to] = f.value2 !== void 0 && f.value2 < f.value ? [f.value2, f.value] : [f.value, f.value2];
192
+ const years = wholeYears(from, to);
193
+ if (years) {
194
+ return years[0] === years[1] ? fill(forms[f.op === "between" ? "=" : "!="], { value: years[0] }) : fill(forms[f.op], { from: years[0], to: years[1] });
195
+ }
196
+ return fill(forms[f.op], { from: shown(from), to: shown(to) });
197
+ }
198
+ return date && Object.hasOwn(forms, f.op) ? fill(forms[f.op], { value: shown(f.value) }) : `${Object.hasOwn(OP_SIGNS, f.op) ? OP_SIGNS[f.op] : f.op} ${shown(f.value)}`;
199
+ }
200
+ function itemRuleText(f, labels, locale, { timeZone, date, labelOf, span }) {
201
+ if (f.type === "relative") {
202
+ return relativeText(
203
+ /** @type {any} */
204
+ f,
205
+ labels,
206
+ locale,
207
+ timeZone,
208
+ void 0,
209
+ span
210
+ );
211
+ }
212
+ if (f.type === "compare") {
213
+ return compareText(
214
+ /** @type {any} */
215
+ f,
216
+ labels,
217
+ locale,
218
+ { date, labelOf }
219
+ );
220
+ }
221
+ const op = String(f.op);
222
+ return `${Object.hasOwn(labels.labelOps, op) ? labels.labelOps[op] : op} ${fill(labels.quote, { text: f.value })}`;
223
+ }
102
224
  function groupingName(source, unit, labels, size) {
103
225
  const inName = labels.unitInName && Object.hasOwn(labels.unitInName, unit) ? labels.unitInName[unit] : labels.units[unit];
104
226
  return unit === "bin" ? fill(labels.binsName, { field: source, size }) : fill(labels.derivedName, { field: source, unit: inName ?? unit });
@@ -374,6 +496,11 @@ import { createPortal } from "react-dom";
374
496
  // src/place.js
375
497
  var MARGIN = 8;
376
498
  var GAP = 6;
499
+ function viewportOf(doc) {
500
+ const root = doc.documentElement;
501
+ const win = doc.defaultView;
502
+ return { width: root?.clientWidth || win?.innerWidth || 0, height: root?.clientHeight || win?.innerHeight || 0 };
503
+ }
377
504
  function placePopover(anchor, size, viewport, align = "start", { fill: fill2 = false } = {}) {
378
505
  const below = viewport.height - anchor.bottom - GAP - MARGIN;
379
506
  const above = anchor.top - GAP - MARGIN;
@@ -392,6 +519,19 @@ function placePopover(anchor, size, viewport, align = "start", { fill: fill2 = f
392
519
  const top = side === "below" ? anchor.bottom + GAP : anchor.top - GAP - height;
393
520
  return { top: Math.max(MARGIN, top), left, maxHeight: Math.max(120, room), side };
394
521
  }
522
+ var KEEP_ROOM = 240;
523
+ function keepPlace(last, next, anchor, size, viewport) {
524
+ if (!last || last.anchorTop !== anchor.top || last.side === next.side) {
525
+ return next;
526
+ }
527
+ const room = last.side === "below" ? viewport.height - anchor.bottom - GAP - MARGIN : anchor.top - GAP - MARGIN;
528
+ if (room < Math.min(size.height, KEEP_ROOM)) {
529
+ return next;
530
+ }
531
+ const height = Math.min(size.height, room);
532
+ const top = last.side === "below" ? anchor.bottom + GAP : anchor.top - GAP - height;
533
+ return { ...next, top: Math.max(MARGIN, top), maxHeight: room, side: last.side };
534
+ }
395
535
  function fromOrigin(place, origin) {
396
536
  return { ...place, top: place.top - origin.top, left: place.left - origin.left };
397
537
  }
@@ -427,6 +567,10 @@ function Popover({ open, anchor, onClose, label, role = "dialog", align = "start
427
567
  /** @type {HTMLDivElement | null} */
428
568
  null
429
569
  );
570
+ const ownId = useId();
571
+ const elId = id ?? ownId;
572
+ const parentId = anchor.current?.closest?.(".pk-popover")?.id;
573
+ const within = (n) => n === ref.current || n.getAttribute("data-pk-parent") === elId;
430
574
  const [pos, setPos] = useState(
431
575
  /** @type {null | { top: number, left: number, maxHeight: number, side: string }} */
432
576
  null
@@ -437,6 +581,7 @@ function Popover({ open, anchor, onClose, label, role = "dialog", align = "start
437
581
  setPos(null);
438
582
  return void 0;
439
583
  }
584
+ let last = null;
440
585
  const place = () => {
441
586
  const el2 = ref.current;
442
587
  const a = anchor.current;
@@ -444,7 +589,10 @@ function Popover({ open, anchor, onClose, label, role = "dialog", align = "start
444
589
  return;
445
590
  }
446
591
  const r = a.getBoundingClientRect();
447
- const place2 = placePopover(r, { width: el2.offsetWidth, height: el2.scrollHeight }, { width: window.innerWidth, height: window.innerHeight }, align, { fill: fill2 });
592
+ const size2 = { width: el2.offsetWidth, height: el2.scrollHeight };
593
+ const viewport = viewportOf(el2.ownerDocument);
594
+ const place2 = keepPlace(last, placePopover(r, size2, viewport, align, { fill: fill2 }), r, size2, viewport);
595
+ last = { top: place2.top, side: place2.side, anchorTop: r.top };
448
596
  const probe = layer?.querySelector(".pk-origin");
449
597
  setPos(probe ? fromOrigin(place2, probe.getBoundingClientRect()) : place2);
450
598
  };
@@ -473,13 +621,13 @@ function Popover({ open, anchor, onClose, label, role = "dialog", align = "start
473
621
  }
474
622
  const el = ref.current;
475
623
  const shown = (o) => o.getClientRects().length > 0;
476
- const first = el?.querySelector("[data-autofocus]") ?? [...el?.querySelectorAll(OPTION) ?? []].find(shown) ?? [...el?.querySelectorAll(FOCUSABLE) ?? []].find(shown);
624
+ const first = el?.querySelector("[data-autofocus]") ?? [...el?.querySelectorAll(OPTION) ?? []].find(shown) ?? [...el?.querySelectorAll(FOCUSABLE) ?? []].find((o) => shown(o) && !o.classList.contains("pk-info")) ?? (el?.querySelector("[data-pk-option]") ? el : null);
477
625
  const t = requestAnimationFrame(() => (
478
626
  /** @type {HTMLElement | null} */
479
627
  first?.focus({ preventScroll: true })
480
628
  ));
481
629
  const onDown = (e) => {
482
- if (!eventWithin(e, [el, anchor.current])) {
630
+ if (!eventWithin(e, [el, anchor.current]) && !e.composedPath().some((n) => n instanceof Element && n !== el && n.getAttribute("data-pk-parent") === elId)) {
483
631
  closeRef.current();
484
632
  }
485
633
  };
@@ -501,7 +649,7 @@ function Popover({ open, anchor, onClose, label, role = "dialog", align = "start
501
649
  button.focus({ preventScroll: true });
502
650
  }
503
651
  };
504
- }, [open, anchor, passive]);
652
+ }, [open, anchor, passive, elId]);
505
653
  if (!open || !layer) {
506
654
  return null;
507
655
  }
@@ -536,7 +684,7 @@ function Popover({ open, anchor, onClose, label, role = "dialog", align = "start
536
684
  /** @type {Node | null} */
537
685
  e.relatedTarget
538
686
  );
539
- if (to && !ref.current?.contains(to) && !anchor.current?.contains(to)) {
687
+ if (to && !ref.current?.contains(to) && !anchor.current?.contains(to) && !(to instanceof Element && [...to.ownerDocument.querySelectorAll(".pk-popover")].some((p) => p.contains(to) && within(p)))) {
540
688
  onClose();
541
689
  }
542
690
  };
@@ -549,7 +697,8 @@ function Popover({ open, anchor, onClose, label, role = "dialog", align = "start
549
697
  "div",
550
698
  {
551
699
  ref,
552
- id,
700
+ id: elId,
701
+ "data-pk-parent": parentId,
553
702
  role,
554
703
  "aria-label": passive ? void 0 : label,
555
704
  "aria-modal": sheet && role === "dialog" ? true : void 0,
@@ -909,6 +1058,21 @@ function numberRange(encoded, field) {
909
1058
  }
910
1059
  return min <= max ? { min, max } : null;
911
1060
  }
1061
+ function dateSpan(encoded, field) {
1062
+ const column = encoded.column(field);
1063
+ if (!column || column.type !== "date") {
1064
+ return null;
1065
+ }
1066
+ let min = Infinity;
1067
+ let max = -Infinity;
1068
+ for (const v of column.dict) {
1069
+ if (typeof v === "number") {
1070
+ min = Math.min(min, v);
1071
+ max = Math.max(max, v);
1072
+ }
1073
+ }
1074
+ return min <= max ? { min, max } : null;
1075
+ }
912
1076
  function groupField(view, field, unit, options = {}) {
913
1077
  const spec = view.derived.find((d) => same(d.name, field));
914
1078
  const source = spec ? spec.field : field;
@@ -1111,10 +1275,115 @@ function isEmptyView(view) {
1111
1275
  import { createContext as createContext2 } from "react";
1112
1276
  var HelpContext = createContext2(
1113
1277
  /** @type {Help} */
1114
- { explain: true, isOpen: () => true, setOpen: () => {
1115
- }, labels: null }
1278
+ { explain: true, labels: null }
1116
1279
  );
1117
1280
 
1281
+ // src/share.js
1282
+ import { VIEW_FILE_LIMITS, fromViewFile, normalize } from "pivotkit-core";
1283
+ var linkModule = null;
1284
+ var linkLoaded = null;
1285
+ function loadLink() {
1286
+ linkModule ??= import("pivotkit-core/link").then((m) => {
1287
+ linkLoaded = m;
1288
+ return m;
1289
+ });
1290
+ return linkModule;
1291
+ }
1292
+ var linkNow = () => linkLoaded;
1293
+ function linkParam(storageKey) {
1294
+ return storageKey ? `pivot-${storageKey}` : "pivot";
1295
+ }
1296
+ var entries = (fragment) => fragment ? fragment.split("&") : [];
1297
+ var isEntry = (entry, param) => entry.startsWith(`${encodeURIComponent(param)}=`);
1298
+ function readLinkParam(hash, param) {
1299
+ const text = typeof hash === "string" ? hash.replace(/^#/, "") : "";
1300
+ const entry = entries(text).find((e) => isEntry(e, param));
1301
+ const value = entry ? entry.slice(encodeURIComponent(param).length + 1) : "";
1302
+ return value ? value : null;
1303
+ }
1304
+ function withLinkParam(url, param, encoded) {
1305
+ const at = url.indexOf("#");
1306
+ const base = at === -1 ? url : url.slice(0, at);
1307
+ const kept = entries(at === -1 ? "" : url.slice(at + 1)).filter((e) => !isEntry(e, param));
1308
+ const next = encoded ? [...kept, `${encodeURIComponent(param)}=${encoded}`] : kept;
1309
+ return next.length ? `${base}#${next.join("&")}` : base;
1310
+ }
1311
+ function shareBase(shareLink, here) {
1312
+ if (shareLink === true) {
1313
+ if (!here) {
1314
+ return null;
1315
+ }
1316
+ try {
1317
+ const url = new URL(here);
1318
+ return `${url.origin}${url.pathname}${url.hash}`;
1319
+ } catch {
1320
+ return null;
1321
+ }
1322
+ }
1323
+ return typeof shareLink === "string" && shareLink.trim() ? shareLink.trim() : null;
1324
+ }
1325
+ var viewStorageName = (key) => `pivotkit:view:${key ?? ""}`;
1326
+ function readStoredView(key, storage) {
1327
+ if (!storage) {
1328
+ return null;
1329
+ }
1330
+ try {
1331
+ return storage.getItem(viewStorageName(key));
1332
+ } catch {
1333
+ return null;
1334
+ }
1335
+ }
1336
+ function writeStoredView(key, storage, view) {
1337
+ if (!storage) {
1338
+ return;
1339
+ }
1340
+ try {
1341
+ storage.setItem(viewStorageName(key), JSON.stringify(view));
1342
+ } catch {
1343
+ }
1344
+ }
1345
+ var VIEW_TEXT_MAX = VIEW_FILE_LIMITS.text;
1346
+ var quoteNames = (names, labels) => {
1347
+ const shown = names.slice(0, 5).map((n) => fill(labels.quote, { text: n.length > 60 ? `${n.slice(0, 59)}\u2026` : n })).join(", ");
1348
+ return names.length > 5 ? `${shown} \u2026` : shown;
1349
+ };
1350
+ var FAILED = Object.freeze({ newerFormat: "newer", newerView: "newer" });
1351
+ function viewFromText(text, encoded, options = {}) {
1352
+ return viewFromObject(text, encoded, options);
1353
+ }
1354
+ function viewFromObject(input, encoded, options = {}) {
1355
+ const file = fromViewFile(input, { data: encoded, sourceId: options.sourceId });
1356
+ if (file.failed || !file.view) {
1357
+ const failed = file.failed ?? "notView";
1358
+ return { view: null, issues: file.issues, failed: Object.hasOwn(FAILED, failed) ? FAILED[failed] : failed, file };
1359
+ }
1360
+ const { view, issues } = normalize(file.view, encoded, options.limits ? { limits: options.limits } : void 0);
1361
+ if (issues.some((i) => i.path === "version")) {
1362
+ return { view: null, issues, failed: "newer", file };
1363
+ }
1364
+ return { view, issues, failed: null, file };
1365
+ }
1366
+ function loadCheck(loaded, labels, sources = []) {
1367
+ const fit = loaded.file?.compatible;
1368
+ if (!loaded.view || !fit || fit.ok) {
1369
+ return null;
1370
+ }
1371
+ const lines2 = [];
1372
+ const fileSource = loaded.file?.source;
1373
+ const target = fit.source === "other" && fileSource?.id ? sources.find((s) => s && s.id === fileSource.id) : void 0;
1374
+ if (fit.source === "other") {
1375
+ const name2 = target?.name || fileSource?.name || fileSource?.id;
1376
+ lines2.push(name2 ? fill(labels.loadCheckSource, { source: name2 }) : labels.loadCheckOtherSource);
1377
+ }
1378
+ if (fit.missing.length) {
1379
+ lines2.push(fill(labels.loadCheckMissing, { fields: quoteNames(fit.missing, labels) }));
1380
+ }
1381
+ if (fit.changed.length) {
1382
+ lines2.push(fill(labels.loadCheckChanged, { fields: quoteNames(fit.changed.map((c) => c.name), labels) }));
1383
+ }
1384
+ return { lines: lines2, switchTo: target ? { id: target.id, name: target.name || target.id } : null };
1385
+ }
1386
+
1118
1387
  // src/storage.js
1119
1388
  function localStore() {
1120
1389
  try {
@@ -1381,48 +1650,7 @@ var SWITCHES = Object.freeze([ALL_TIPS, NO_EXPLANATIONS, FIELDS_COLLAPSED]);
1381
1650
  function fieldsCollapsed(session, forced, dismissed) {
1382
1651
  return session ?? (forced === "collapsed" || forced === "open" ? forced === "collapsed" : dismissed.includes(FIELDS_COLLAPSED));
1383
1652
  }
1384
- var SECTIONS = Object.freeze({
1385
- // a value's menu
1386
- summarize: true,
1387
- showAs: true,
1388
- format: false,
1389
- highlight: false,
1390
- move: false,
1391
- // a field's menu on Rows or Columns
1392
- sort: true,
1393
- groupBy: true,
1394
- bins: true,
1395
- topN: true,
1396
- filters: true,
1397
- // the toolbar's menus
1398
- totals: true,
1399
- help: true,
1400
- // the Export menus (the toolbar's and the drill-down's)
1401
- exportDownload: true,
1402
- exportCopy: true,
1403
- thisView: true,
1404
- sharedViews: true,
1405
- myViews: true,
1406
- share: false,
1407
- chartType: true,
1408
- chartDisplay: false
1409
- });
1410
- function sectionOpen(id, dismissed) {
1411
- if (dismissed.includes(`open:${id}`)) {
1412
- return true;
1413
- }
1414
- if (dismissed.includes(`closed:${id}`)) {
1415
- return false;
1416
- }
1417
- return Object.hasOwn(SECTIONS, id) ? SECTIONS[id] : true;
1418
- }
1419
- function withSection(dismissed, id, open) {
1420
- const rest = dismissed.filter((d) => d !== `open:${id}` && d !== `closed:${id}`);
1421
- const def = Object.hasOwn(SECTIONS, id) ? SECTIONS[id] : true;
1422
- return open === def ? rest : [...rest, `${open ? "open" : "closed"}:${id}`];
1423
- }
1424
- var isSection = (id) => /^(open|closed):/.test(id) && Object.hasOwn(SECTIONS, id.slice(id.indexOf(":") + 1));
1425
- var keptOnReset = (id) => SWITCHES.includes(id) || isSection(id);
1653
+ var keptOnReset = (id) => SWITCHES.includes(id);
1426
1654
  function helpSwitch(forced, dismissed, off = NO_EXPLANATIONS) {
1427
1655
  if (forced === "on" || forced === "off") {
1428
1656
  return { on: forced === "on", user: false };
@@ -1513,7 +1741,7 @@ function allowedTips(value) {
1513
1741
  return list.map((id) => String(id).trim()).filter((id) => TIP_IDS.includes(id));
1514
1742
  }
1515
1743
  function cleanDismissed(value) {
1516
- return Array.isArray(value) ? [...new Set(value.filter((id) => typeof id === "string" && (SWITCHES.includes(id) || TIP_IDS.includes(id) || isSection(id))))] : [];
1744
+ return Array.isArray(value) ? [...new Set(value.filter((id) => typeof id === "string" && (SWITCHES.includes(id) || TIP_IDS.includes(id))))] : [];
1517
1745
  }
1518
1746
  var storageName = (key) => `pivotkit:tips:${key}`;
1519
1747
  function readStored(key, storage) {
@@ -1542,112 +1770,6 @@ function withoutFilters(view) {
1542
1770
  return { ...view, filters: filterZoneFields(view).map((field) => ({ field, type: "exclude", items: [] })) };
1543
1771
  }
1544
1772
 
1545
- // src/share.js
1546
- import { VIEW_FILE_LIMITS, fromViewFile, normalize } from "pivotkit-core";
1547
- var linkModule = null;
1548
- var linkLoaded = null;
1549
- function loadLink() {
1550
- linkModule ??= import("pivotkit-core/link").then((m) => {
1551
- linkLoaded = m;
1552
- return m;
1553
- });
1554
- return linkModule;
1555
- }
1556
- var linkNow = () => linkLoaded;
1557
- function linkParam(storageKey) {
1558
- return storageKey ? `pivot-${storageKey}` : "pivot";
1559
- }
1560
- var entries = (fragment) => fragment ? fragment.split("&") : [];
1561
- var isEntry = (entry, param) => entry.startsWith(`${encodeURIComponent(param)}=`);
1562
- function readLinkParam(hash, param) {
1563
- const text = typeof hash === "string" ? hash.replace(/^#/, "") : "";
1564
- const entry = entries(text).find((e) => isEntry(e, param));
1565
- const value = entry ? entry.slice(encodeURIComponent(param).length + 1) : "";
1566
- return value ? value : null;
1567
- }
1568
- function withLinkParam(url, param, encoded) {
1569
- const at = url.indexOf("#");
1570
- const base = at === -1 ? url : url.slice(0, at);
1571
- const kept = entries(at === -1 ? "" : url.slice(at + 1)).filter((e) => !isEntry(e, param));
1572
- const next = encoded ? [...kept, `${encodeURIComponent(param)}=${encoded}`] : kept;
1573
- return next.length ? `${base}#${next.join("&")}` : base;
1574
- }
1575
- function shareBase(shareLink, here) {
1576
- if (shareLink === true) {
1577
- if (!here) {
1578
- return null;
1579
- }
1580
- try {
1581
- const url = new URL(here);
1582
- return `${url.origin}${url.pathname}${url.hash}`;
1583
- } catch {
1584
- return null;
1585
- }
1586
- }
1587
- return typeof shareLink === "string" && shareLink.trim() ? shareLink.trim() : null;
1588
- }
1589
- var viewStorageName = (key) => `pivotkit:view:${key ?? ""}`;
1590
- function readStoredView(key, storage) {
1591
- if (!storage) {
1592
- return null;
1593
- }
1594
- try {
1595
- return storage.getItem(viewStorageName(key));
1596
- } catch {
1597
- return null;
1598
- }
1599
- }
1600
- function writeStoredView(key, storage, view) {
1601
- if (!storage) {
1602
- return;
1603
- }
1604
- try {
1605
- storage.setItem(viewStorageName(key), JSON.stringify(view));
1606
- } catch {
1607
- }
1608
- }
1609
- var VIEW_TEXT_MAX = VIEW_FILE_LIMITS.text;
1610
- var quoteNames = (names) => {
1611
- const shown = names.slice(0, 5).map((n) => `\u201C${n.length > 60 ? `${n.slice(0, 59)}\u2026` : n}\u201D`).join(", ");
1612
- return names.length > 5 ? `${shown} \u2026` : shown;
1613
- };
1614
- var FAILED = Object.freeze({ newerFormat: "newer", newerView: "newer" });
1615
- function viewFromText(text, encoded, options = {}) {
1616
- return viewFromObject(text, encoded, options);
1617
- }
1618
- function viewFromObject(input, encoded, options = {}) {
1619
- const file = fromViewFile(input, { data: encoded, sourceId: options.sourceId });
1620
- if (file.failed || !file.view) {
1621
- const failed = file.failed ?? "notView";
1622
- return { view: null, issues: file.issues, failed: Object.hasOwn(FAILED, failed) ? FAILED[failed] : failed, file };
1623
- }
1624
- const { view, issues } = normalize(file.view, encoded, options.limits ? { limits: options.limits } : void 0);
1625
- if (issues.some((i) => i.path === "version")) {
1626
- return { view: null, issues, failed: "newer", file };
1627
- }
1628
- return { view, issues, failed: null, file };
1629
- }
1630
- function loadCheck(loaded, labels, sources = []) {
1631
- const fit = loaded.file?.compatible;
1632
- if (!loaded.view || !fit || fit.ok) {
1633
- return null;
1634
- }
1635
- const lines2 = [];
1636
- const fileSource = loaded.file?.source;
1637
- const target = fit.source === "other" && fileSource?.id ? sources.find((s) => s && s.id === fileSource.id) : void 0;
1638
- if (fit.source === "other") {
1639
- const name2 = target?.name || fileSource?.name || fileSource?.id;
1640
- lines2.push(name2 ? fill(labels.loadCheckSource, { source: name2 }) : labels.loadCheckOtherSource);
1641
- }
1642
- if (fit.missing.length) {
1643
- lines2.push(fill(labels.loadCheckMissing, { fields: quoteNames(fit.missing) }));
1644
- }
1645
- if (fit.changed.length) {
1646
- lines2.push(fill(labels.loadCheckChanged, { fields: quoteNames(fit.changed.map((c) => c.name)) }));
1647
- }
1648
- return { lines: lines2, switchTo: target ? { id: target.id, name: target.name || target.id } : null };
1649
- }
1650
-
1651
1773
  export {
1652
1774
  CHART_TYPES,
1653
1775
  SLICE_TYPES,
@@ -1659,6 +1781,14 @@ export {
1659
1781
  refLabel,
1660
1782
  sortText,
1661
1783
  valueConditionText,
1784
+ dayText,
1785
+ isoDay,
1786
+ relativeDays,
1787
+ periodText,
1788
+ rangeShare,
1789
+ relativeText,
1790
+ wholeYears,
1791
+ itemRuleText,
1662
1792
  groupingName,
1663
1793
  fieldAction,
1664
1794
  layoutSummary,
@@ -1689,6 +1819,7 @@ export {
1689
1819
  moveField,
1690
1820
  reorder,
1691
1821
  numberRange,
1822
+ dateSpan,
1692
1823
  groupField,
1693
1824
  groupingOf,
1694
1825
  sourceOf,
@@ -1713,6 +1844,17 @@ export {
1713
1844
  swapAxes,
1714
1845
  isEmptyView,
1715
1846
  HelpContext,
1847
+ loadLink,
1848
+ linkNow,
1849
+ linkParam,
1850
+ readLinkParam,
1851
+ withLinkParam,
1852
+ shareBase,
1853
+ readStoredView,
1854
+ writeStoredView,
1855
+ viewFromText,
1856
+ viewFromObject,
1857
+ loadCheck,
1716
1858
  localStore,
1717
1859
  readItem,
1718
1860
  subscribeItem,
@@ -1721,9 +1863,6 @@ export {
1721
1863
  NO_EXPLANATIONS,
1722
1864
  FIELDS_COLLAPSED,
1723
1865
  fieldsCollapsed,
1724
- sectionOpen,
1725
- withSection,
1726
- isSection,
1727
1866
  keptOnReset,
1728
1867
  helpSwitch,
1729
1868
  SHORTCUTS,
@@ -1737,16 +1876,5 @@ export {
1737
1876
  parseStored,
1738
1877
  subscribeStored,
1739
1878
  writeDismissed,
1740
- withoutFilters,
1741
- loadLink,
1742
- linkNow,
1743
- linkParam,
1744
- readLinkParam,
1745
- withLinkParam,
1746
- shareBase,
1747
- readStoredView,
1748
- writeStoredView,
1749
- viewFromText,
1750
- viewFromObject,
1751
- loadCheck
1879
+ withoutFilters
1752
1880
  };
@@ -75,6 +75,12 @@ var de = {
75
75
  filterCount: "\u201EOberste\u201C braucht eine ganze Zahl von 1 bis {max} - dieser Filter wird weggelassen",
76
76
  filterValue: "die Bedingung braucht einen Vergleich und eine Zahl - dieser Filter wird weggelassen",
77
77
  filterValue2: "\u201E{value}\u201C braucht eine zweite Zahl - dieser Filter wird weggelassen",
78
+ filterCompareField: "nur Zahlen und Daten lassen sich vergleichen - dieser Filter wird weggelassen",
79
+ filterCompareValue: "der Vergleich braucht einen Operator und eine Zahl oder ein Datum (2022-03-01), das zum Feld passt - dieser Filter wird weggelassen",
80
+ filterRelativeField: "ein Zeitraum wie \u201Eletzte 5 Jahre\u201C braucht ein Datumsfeld - dieser Filter wird weggelassen",
81
+ filterRelativeUnit: "die Einheit \u201E{value}\u201C ist unbekannt (Jahre, Monate oder Tage) - dieser Filter wird weggelassen",
82
+ filterRelativeCount: "der Zeitraum braucht eine ganze Zahl von 1 bis {max} - dieser Filter wird weggelassen",
83
+ filterRelativeAnchor: "der Zeitraum kann ab \u201Etoday\u201C (heute) oder \u201Elatest\u201C (dem letzten Datensatz) zur\xFCckz\xE4hlen, nicht ab \u201E{value}\u201C - dieser Filter wird weggelassen",
78
84
  sortNoItems: "die eigene Reihenfolge nennt keine Eintr\xE4ge - die \xFCbliche Reihenfolge gilt",
79
85
  sortedTwice: "das Feld wird zweimal sortiert - nur seine erste Sortierung gilt",
80
86
  badTotals: "die Summen lassen sich nicht lesen - die \xFCblichen Summen werden gezeigt",
@@ -2,7 +2,7 @@ import {
2
2
  en,
3
3
  unusedItem,
4
4
  unusedItems
5
- } from "./chunk-53ZMK4BH.js";
5
+ } from "./chunk-EM23V5GH.js";
6
6
  export {
7
7
  en,
8
8
  unusedItem,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  de
3
- } from "./chunk-OYY4BKIL.js";
3
+ } from "./chunk-RWYHJRQO.js";
4
4
  export {
5
5
  de
6
6
  };