pivotkit-react 0.6.1 → 0.8.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 (62) hide show
  1. package/CHANGELOG.md +212 -1
  2. package/README.md +33 -15
  3. package/dist/chunks/{chunk-JMRTIOX4.js → chunk-2N2UGSIG.js} +7 -0
  4. package/dist/chunks/{chunk-ZK5RVCHP.js → chunk-BHHIZHUE.js} +1 -1
  5. package/dist/chunks/{chunk-YXLANLGL.js → chunk-GUSQWPTH.js} +56 -3
  6. package/dist/chunks/{chunk-JOWAEZAD.js → chunk-JAOOFDNR.js} +21 -1
  7. package/dist/chunks/{chunk-E6M57YLL.js → chunk-MU5BTKSY.js} +7 -0
  8. package/dist/chunks/{chunk-TR2HROIK.js → chunk-RNQ32FCN.js} +66 -5
  9. package/dist/chunks/{chunk-XN5HNKJ2.js → chunk-SJCG4I57.js} +98 -33
  10. package/dist/chunks/{chunk-3LDE2GPG.js → chunk-VMJMDP7C.js} +372 -33
  11. package/dist/chunks/{report-run-BZBFOMPF.js → report-run-HU4WPOB7.js} +3 -1
  12. package/dist/chunks/{unused-texts-Y4R67XSN.js → unused-texts-LRYVWFFN.js} +1 -1
  13. package/dist/chunks/{unused-texts-de-6YVPTNVS.js → unused-texts-de-GB3IWWEM.js} +1 -1
  14. package/dist/echarts.js +426 -35
  15. package/dist/import-ui.js +3 -3
  16. package/dist/index.js +769 -435
  17. package/dist/labels.js +6 -6
  18. package/dist/menu-texts-de.js +1 -1
  19. package/dist/menus.js +1133 -542
  20. package/dist/styles.css +271 -158
  21. package/package.json +8 -4
  22. package/styles.css.d.ts +3 -0
  23. package/types/PivotReport.d.ts +6 -0
  24. package/types/add-menu.d.ts +48 -0
  25. package/types/chart-colors.d.ts +8 -0
  26. package/types/chart-decorate.d.ts +66 -3
  27. package/types/chart-legend.d.ts +176 -0
  28. package/types/chart-summary.d.ts +8 -3
  29. package/types/chart-tooltip.d.ts +159 -17
  30. package/types/chart.d.ts +21 -3
  31. package/types/date-context.d.ts +30 -0
  32. package/types/drill-panel.d.ts +4 -2
  33. package/types/echarts.d.ts +7 -3
  34. package/types/export-run.d.ts +19 -14
  35. package/types/export-scope.d.ts +13 -2
  36. package/types/field-info.d.ts +12 -0
  37. package/types/files.d.ts +14 -0
  38. package/types/filter.d.ts +18 -0
  39. package/types/group-context.d.ts +20 -0
  40. package/types/index.d.ts +35 -6
  41. package/types/label-room.d.ts +13 -0
  42. package/types/labels.d.ts +85 -16
  43. package/types/lazy-menus.d.ts +2 -2
  44. package/types/levels.d.ts +16 -7
  45. package/types/menu-labels.d.ts +67 -1
  46. package/types/menu-ops.d.ts +10 -0
  47. package/types/menu-topics.d.ts +110 -21
  48. package/types/menus.d.ts +3 -2
  49. package/types/names.d.ts +32 -3
  50. package/types/overflow.d.ts +18 -30
  51. package/types/print-frame.d.ts +32 -3
  52. package/types/report-run.d.ts +5 -0
  53. package/types/rove.d.ts +10 -0
  54. package/types/theme-tokens.d.ts +17 -0
  55. package/types/toolbar-panels.d.ts +43 -15
  56. package/types/unused-texts.d.ts +7 -0
  57. package/types/use-big-result.d.ts +24 -9
  58. package/types/use-export.d.ts +8 -4
  59. package/types/view-ops.d.ts +19 -8
  60. package/types/view-tabs.d.ts +12 -0
  61. package/types/zones.d.ts +41 -9
  62. package/types/light-tokens.d.ts +0 -16
@@ -3,11 +3,11 @@ import {
3
3
  Popover,
4
4
  onTheWay,
5
5
  useFormName
6
- } from "./chunk-JOWAEZAD.js";
6
+ } from "./chunk-JAOOFDNR.js";
7
7
  import {
8
8
  fill,
9
9
  plural
10
- } from "./chunk-XN5HNKJ2.js";
10
+ } from "./chunk-SJCG4I57.js";
11
11
 
12
12
  // src/chart-types.js
13
13
  import { chartPlan as corePlan } from "pivotkit-core";
@@ -45,6 +45,7 @@ var MANY_SERIES = 8;
45
45
  var MAX_CATEGORIES = 50;
46
46
 
47
47
  // src/view-ops.js
48
+ import { MAX_DATE_MS } from "pivotkit-core";
48
49
  import { LIMITS, aggregatorsFor, foldText, isFormat, swapAxes } from "pivotkit-core";
49
50
  var ZONES = Object.freeze(
50
51
  /** @type {Zone[]} */
@@ -117,19 +118,30 @@ function resetCollapsed(view, before) {
117
118
  }
118
119
  }
119
120
  function zoneOverLimit(view, limits) {
120
- const limit = (name2) => limits && Number.isInteger(limits[name2]) && limits[name2] > 0 ? limits[name2] : LIMITS[name2];
121
121
  for (
122
- const [zone, name2] of
122
+ const zone of
123
123
  /** @type {const} */
124
- [["rows", "axisFields"], ["cols", "axisFields"], ["values", "values"]]
124
+ ["rows", "cols", "values"]
125
125
  ) {
126
126
  const list = view && Array.isArray(view[zone]) ? view[zone] : [];
127
- if (list.length > limit(name2)) {
128
- return { zone, max: limit(name2) };
127
+ const max = (
128
+ /** @type {number} */
129
+ zoneMax(zone, limits)
130
+ );
131
+ if (list.length > max) {
132
+ return { zone, max };
129
133
  }
130
134
  }
131
135
  return null;
132
136
  }
137
+ function zoneMax(zone, limits) {
138
+ const name2 = zone === "values" ? "values" : zone === "rows" || zone === "cols" ? "axisFields" : null;
139
+ if (!name2) {
140
+ return null;
141
+ }
142
+ const own2 = limits?.[name2];
143
+ return typeof own2 === "number" && Number.isInteger(own2) && own2 > 0 ? own2 : LIMITS[name2];
144
+ }
133
145
  function addField(view, field, zone, options = {}) {
134
146
  if (options.dateUnit && zone !== "values") {
135
147
  const name2 = options.groupName ?? `${field} (${options.dateUnit})`;
@@ -237,7 +249,17 @@ function numberRange(encoded, field) {
237
249
  }
238
250
  return min <= max ? { min, max } : null;
239
251
  }
252
+ var dateSpans = /* @__PURE__ */ new WeakMap();
240
253
  function dateSpan(encoded, field) {
254
+ let spans = dateSpans.get(encoded);
255
+ if (!spans) dateSpans.set(encoded, spans = /* @__PURE__ */ new Map());
256
+ const key = field.toLowerCase();
257
+ if (spans.has(key)) {
258
+ const span2 = spans.get(key) ?? null;
259
+ spans.delete(key);
260
+ spans.set(key, span2);
261
+ return span2;
262
+ }
241
263
  const column = encoded.column(field);
242
264
  if (!column || column.type !== "date") {
243
265
  return null;
@@ -245,12 +267,18 @@ function dateSpan(encoded, field) {
245
267
  let min = Infinity;
246
268
  let max = -Infinity;
247
269
  for (const v of column.dict) {
248
- if (typeof v === "number") {
270
+ if (typeof v === "number" && Number.isFinite(v) && Math.abs(v) <= MAX_DATE_MS) {
249
271
  min = Math.min(min, v);
250
272
  max = Math.max(max, v);
251
273
  }
252
274
  }
253
- return min <= max ? { min, max } : null;
275
+ const span = min <= max ? { min, max } : null;
276
+ spans.set(key, span);
277
+ if (spans.size > LIMITS.cacheEntries) {
278
+ const oldest = spans.keys().next().value;
279
+ if (oldest !== void 0) spans.delete(oldest);
280
+ }
281
+ return span;
254
282
  }
255
283
  function groupField(view, field, unit, options = {}) {
256
284
  const spec = view.derived.find((d) => same(d.name, field));
@@ -397,9 +425,9 @@ function rowFolding(view, outer) {
397
425
  canCollapse,
398
426
  collapsed: view.collapsed.rows.length,
399
427
  open,
400
- // keys of the menus' texts (menu-labels.js): the Options menu shows them with its labels
428
+ // keys of the menus' texts (menu-labels.js): Table settings and Chart settings show them
401
429
  why: {
402
- expand: canExpand ? null : "expandNothing",
430
+ expand: canExpand ? null : view.rows.length < 2 ? "collapseNeedsRows" : "expandNothing",
403
431
  collapse: canCollapse ? null : view.rows.length < 2 ? "collapseNeedsRows" : "collapseAllDone"
404
432
  }
405
433
  };
@@ -430,13 +458,18 @@ function setChartDisplay(view, patch) {
430
458
  next.chart = { ...next.chart, ...patch };
431
459
  return next;
432
460
  }
461
+ function hiddenAfter(hidden, name2, shown) {
462
+ const rest = (hidden ?? []).filter((n) => n !== name2);
463
+ return shown ? rest : [...rest, name2];
464
+ }
433
465
  function isEmptyView(view) {
434
466
  return view.rows.length === 0 && view.cols.length === 0 && view.values.length === 0;
435
467
  }
436
468
 
437
469
  // src/names.js
438
- import { MAX_DATE_MS, fieldLabel, formatter, relativeDateRange } from "pivotkit-core";
470
+ import { MAX_DATE_MS as MAX_DATE_MS2, fieldLabel, formatter, numberRepeats, relativeDateRange } from "pivotkit-core";
439
471
  var withNot = (f, text, labels) => hiddenNot(f) ? fill(labels.notRule, { rule: text }) : text;
472
+ var valueLabels = (values, labels) => numberRepeats(values.map((v) => valueLabel(v, labels)));
440
473
  function valueLabel(spec, labels) {
441
474
  if (spec.label) {
442
475
  return spec.label;
@@ -498,7 +531,7 @@ var midYear = (y) => {
498
531
  var yearText = (y, locale) => y >= 1 ? String(y) : midYear(y).toLocaleDateString(locale, { year: "numeric", era: "short", calendar: "gregory", timeZone: "UTC" });
499
532
  var monthText = (iso, locale) => {
500
533
  const y = yearOf(iso);
501
- const at = Math.max(dayMs(`${isoYear(y)}-${String(monthOf(iso)).padStart(2, "0")}-01`) || -MAX_DATE_MS, -MAX_DATE_MS);
534
+ const at = Math.max(dayMs(`${isoYear(y)}-${String(monthOf(iso)).padStart(2, "0")}-01`) || -MAX_DATE_MS2, -MAX_DATE_MS2);
502
535
  return new Date(at).toLocaleDateString(locale, { month: "short", year: "numeric", timeZone: "UTC", ...y < 1 ? { era: "short" } : {} });
503
536
  };
504
537
  var dayText = (iso, locale) => formatter("date", { locale })(dayMs(iso));
@@ -508,6 +541,12 @@ function relativeDays(f, timeZone, now, latest, more = {}) {
508
541
  const range = datesOf(f, timeZone, now, latest, more);
509
542
  return range && range.from !== null ? { from: range.from, to: range.to } : null;
510
543
  }
544
+ var todayIn = (timeZone, now) => relativeDays({ unit: "day" }, timeZone, now)?.from ?? isoDay(now === void 0 ? Date.now() : new Date(now).getTime());
545
+ function namedUntil(range, span, today) {
546
+ const [from, to] = [dayPart(range.from), dayPart(range.to)];
547
+ const ended = dayMs(isoDay(span.max)) <= dayMs(today);
548
+ return ended && dayMs(from) <= dayMs(today) && dayMs(today) <= dayMs(to) ? dayAfter(today, -1) : to;
549
+ }
511
550
  var datesOf = (f, timeZone, now, latest, more = {}) => relativeDateRange(f.unit, f.count ?? 1, { timeZone, now, anchor: f.anchor, latest: latest ?? void 0, first: more.first ?? void 0, direction: f.direction, calendar: f.calendar, includeCurrent: f.includeCurrent, weekStart: more.weekStart });
512
551
  var plainRange = (f) => ["last", "this"].includes(f.direction ?? "last") && f.calendar !== false && (f.anchor === void 0 || f.anchor === "today" || f.anchor === "latest") && ["year", "quarter", "month", "week", "day"].includes(f.unit);
513
552
  function periodText(range, unit, locale) {
@@ -517,17 +556,18 @@ function periodText(range, unit, locale) {
517
556
  const [from, to] = [text(range.from), text(range.to)];
518
557
  return from === to ? from : `${from}\u2013${to}`;
519
558
  }
520
- function rangeShare(range, unit, span, locale) {
559
+ function rangeShare(range, unit, span, locale, today) {
521
560
  const grain = unit === "quarter" ? "month" : unit === "week" ? "day" : unit;
522
561
  range = { from: dayPart(range.from), to: dayPart(range.to) };
562
+ const until = namedUntil(range, span, today);
523
563
  const [first, last] = [periodStart(isoDay(span.min), grain), periodEnd(isoDay(span.max), grain)];
524
- if (dayMs(first) <= dayMs(range.from) && dayMs(last) >= dayMs(range.to)) {
564
+ if (dayMs(first) <= dayMs(range.from) && dayMs(last) >= dayMs(until)) {
525
565
  return null;
526
566
  }
527
567
  const from = dayMs(range.from) > dayMs(first) ? range.from : first;
528
568
  const to = dayMs(range.to) < dayMs(last) ? range.to : last;
529
569
  if (dayMs(from) > dayMs(to)) {
530
- return { none: true };
570
+ return dayMs(range.from) > dayMs(until) ? null : until === range.to ? { none: true } : { none: true, to: until };
531
571
  }
532
572
  const missing = [];
533
573
  let count = 0;
@@ -551,13 +591,14 @@ function rangeShare(range, unit, span, locale) {
551
591
  count += periodText({ from: rest.from, to: rest.from }, unit, locale) === periodText({ from: rest.to, to: rest.to }, unit, locale) ? 1 : 2;
552
592
  }
553
593
  };
554
- if (dayMs(range.from) < dayMs(first)) {
555
- part(range.from, dayAfter(first, -1), yearOf(first));
594
+ const before = dayMs(until) < dayMs(first) ? until : dayAfter(first, -1);
595
+ if (dayMs(range.from) <= dayMs(before)) {
596
+ part(range.from, before, yearOf(first));
556
597
  }
557
- if (dayMs(range.to) > dayMs(last)) {
558
- part(dayAfter(last), range.to, yearOf(last));
598
+ if (dayMs(until) > dayMs(last)) {
599
+ part(dayAfter(last), until, yearOf(last));
559
600
  }
560
- return { none: false, data: periodText({ from, to }, unit, locale), missing, count };
601
+ return missing.length ? { none: false, data: periodText({ from, to }, unit, locale), missing, count } : null;
561
602
  }
562
603
  var periodStart = (iso, unit) => unit === "year" ? `${isoYear(yearOf(iso))}-01-01` : unit === "month" ? `${iso.slice(0, -3)}-01` : iso;
563
604
  function periodEnd(iso, unit) {
@@ -567,7 +608,7 @@ function periodEnd(iso, unit) {
567
608
  const [y, m] = [yearOf(iso), monthOf(iso)];
568
609
  const end = /* @__PURE__ */ new Date(0);
569
610
  end.setUTCFullYear(y, unit === "year" ? 11 : m, unit === "year" ? 31 : 0);
570
- return isoDay(Math.min(end.getTime(), MAX_DATE_MS) || MAX_DATE_MS);
611
+ return isoDay(Math.min(end.getTime(), MAX_DATE_MS2) || MAX_DATE_MS2);
571
612
  }
572
613
  function relativeText(f, labels, locale, timeZone, now, span, weekStart) {
573
614
  if (!plainRange(f)) {
@@ -588,13 +629,13 @@ function relativeText(f, labels, locale, timeZone, now, span, weekStart) {
588
629
  if (latest) {
589
630
  text = fill(labels.relativeTo, { text, end: periodText({ from: range.to, to: range.to }, f.unit, locale) });
590
631
  }
591
- const share = span ? rangeShare(range, f.unit, span, locale) : null;
632
+ const share = span ? rangeShare(range, f.unit, span, locale, todayIn(timeZone, now)) : null;
592
633
  if (!share) {
593
634
  return latest ? text : fill(labels.withRange, { text, range: periodText(range, f.unit, locale) });
594
635
  }
595
636
  const lang = { lang: labels.lang, locale };
596
637
  if (share.none) {
597
- return fill(labels.withRange, { text, range: fill(plural(labels.noData, 1, lang), { range: periodText(range, f.unit, locale) }) });
638
+ return fill(labels.withRange, { text, range: fill(plural(labels.noData, 1, lang), { range: periodText({ from: range.from, to: share.to ?? range.to }, f.unit, locale) }) });
598
639
  }
599
640
  return fill(labels.withShare, { text, range: share.data, missing: fill(plural(labels.noData, share.count, lang), { range: share.missing.join(", ") }) });
600
641
  }
@@ -637,7 +678,7 @@ function precisionText(iso, precision, locale) {
637
678
  var pointText = (iso, locale) => iso.includes("T") ? formatter("datetime", { locale })(Date.parse(`${iso}Z`)) : dayText(iso, locale);
638
679
  function wholeYears(from, to) {
639
680
  const day = /^(?:\d{4}|[+-]\d{6})-\d{2}-\d{2}$/;
640
- const whole = typeof from === "string" && typeof to === "string" && day.test(from) && day.test(to) && (from.endsWith("-01-01") || from === isoDay(-MAX_DATE_MS)) && (to.endsWith("-12-31") || to === isoDay(MAX_DATE_MS));
681
+ const whole = typeof from === "string" && typeof to === "string" && day.test(from) && day.test(to) && (from.endsWith("-01-01") || from === isoDay(-MAX_DATE_MS2)) && (to.endsWith("-12-31") || to === isoDay(MAX_DATE_MS2));
641
682
  return whole ? [yearOf(from), yearOf(to)] : null;
642
683
  }
643
684
  function compareText(f, labels, locale, { date, labelOf }) {
@@ -720,6 +761,282 @@ function drillRows(result, { rowPath = [], colPath = [], data = null, limit = DR
720
761
  return { count: all.length, rows, indices };
721
762
  }
722
763
 
764
+ // src/date-context.js
765
+ import { isDateMs } from "pivotkit-core";
766
+ import { CATALOG, fieldLabel as fieldLabel2 } from "pivotkit-core";
767
+ var formatters = /* @__PURE__ */ new Map();
768
+ function dateFormatter(locale, options) {
769
+ const key = JSON.stringify([locale, options]);
770
+ let fmt = formatters.get(key);
771
+ if (!fmt) {
772
+ fmt = new Intl.DateTimeFormat(locale, options);
773
+ if (formatters.size >= 32) {
774
+ const oldest = formatters.keys().next().value;
775
+ if (oldest !== void 0) formatters.delete(oldest);
776
+ }
777
+ formatters.set(key, fmt);
778
+ }
779
+ return fmt;
780
+ }
781
+ function dateDisplayLocale(locale) {
782
+ try {
783
+ dateFormatter(locale, { year: "numeric", timeZone: "UTC" });
784
+ return locale;
785
+ } catch {
786
+ return "en-US";
787
+ }
788
+ }
789
+ function dateRangeText(span, locale) {
790
+ if (!span || !isDateMs(span.min) || !isDateMs(span.max)) return "";
791
+ const fmt = dateFormatter(locale, { year: "numeric", month: "short", day: "numeric", timeZone: "UTC", era: new Date(span.min).getUTCFullYear() <= 0 ? "short" : void 0 });
792
+ return `${fmt.format(span.min)} \u2013 ${fmt.format(span.max)}`;
793
+ }
794
+ var YEAR_CONTEXT_LIMIT = 32;
795
+ var YEAR_IN_ITEMS = ["month", "quarter"];
796
+ var yearCache = /* @__PURE__ */ new WeakMap();
797
+ function yearsOf(result, field) {
798
+ let cached = yearCache.get(result);
799
+ if (!cached) yearCache.set(result, cached = /* @__PURE__ */ new Map());
800
+ const previous = cached.get(field);
801
+ if (previous) return previous.years;
802
+ const column = result.encoded.column(field);
803
+ let truncated = false;
804
+ const spans = /* @__PURE__ */ new Map();
805
+ const months = /* @__PURE__ */ new Map();
806
+ if (column?.type === "date") {
807
+ const date = /* @__PURE__ */ new Date(0);
808
+ for (const row of result.rows) {
809
+ const code = column.codes[row];
810
+ const value = column.dict[code];
811
+ if (isDateMs(value)) {
812
+ date.setTime(value);
813
+ const year = date.getUTCFullYear();
814
+ const month = date.getUTCMonth() + 1;
815
+ const monthSpan = months.get(month);
816
+ if (monthSpan) {
817
+ monthSpan.min = Math.min(monthSpan.min, value);
818
+ monthSpan.max = Math.max(monthSpan.max, value);
819
+ } else months.set(month, { min: value, max: value });
820
+ const span = spans.get(year);
821
+ if (span) {
822
+ span.min = Math.min(span.min, value);
823
+ span.max = Math.max(span.max, value);
824
+ } else if (spans.size < YEAR_CONTEXT_LIMIT) spans.set(year, { min: value, max: value });
825
+ else truncated = true;
826
+ }
827
+ }
828
+ }
829
+ const sorted = [...spans.keys()].sort((a, b) => a - b);
830
+ cached.set(field, { years: sorted, spans, months, truncated });
831
+ return sorted;
832
+ }
833
+ function yearSetText(years, locale = "en-US") {
834
+ const truncated = years.length > YEAR_CONTEXT_LIMIT;
835
+ years = years.slice(0, YEAR_CONTEXT_LIMIT);
836
+ const runs = [];
837
+ for (let i = 0; i < years.length; i++) {
838
+ const first = years[i];
839
+ while (i + 1 < years.length && years[i + 1] === years[i] + 1) i++;
840
+ runs.push(first === years[i] ? yearText(first, locale) : `${yearText(first, locale)}\u2013${yearText(years[i], locale)}`);
841
+ }
842
+ return runs.join(", ") + (truncated ? ", \u2026" : "");
843
+ }
844
+ function observedYears(result, field) {
845
+ const years = yearsOf(result, field);
846
+ const truncated = yearCache.get(result)?.get(field)?.truncated ?? false;
847
+ const suffix = truncated ? ", \u2026" : "";
848
+ const fmt = dateFormatter(result.locale, { year: "numeric", timeZone: "UTC", era: years[0] <= 0 ? "short" : void 0 });
849
+ if (["gregory", "iso8601"].includes(fmt.resolvedOptions().calendar)) return { text: yearSetText(years, result.locale) + suffix, combined: truncated || years.length > 1 };
850
+ const spans = yearCache.get(result)?.get(field)?.spans;
851
+ const parts = [];
852
+ let combined = truncated || years.length > 1;
853
+ for (const year of years) {
854
+ const span = spans?.get(year);
855
+ if (!span) continue;
856
+ const first = fmt.format(span.min), last = fmt.format(span.max);
857
+ combined ||= first !== last;
858
+ const previous = parts[parts.length - 1];
859
+ if (previous && previous.last === first) previous.last = last;
860
+ else parts.push({ first, last });
861
+ }
862
+ return { text: parts.map(({ first, last }) => first === last ? first : `${first}\u2013${last}`).join(", ") + suffix, combined };
863
+ }
864
+ function dateContext(result, labels) {
865
+ if (!result) return { result, labels, ranges: [], titles: /* @__PURE__ */ new Map() };
866
+ const { view, encoded, locale } = result;
867
+ const fields = { ...labels.core.fields };
868
+ const single = /* @__PURE__ */ new Map();
869
+ const titles = /* @__PURE__ */ new Map();
870
+ const observedMonths = /* @__PURE__ */ new Map();
871
+ const used = /* @__PURE__ */ new Set([...view.rows, ...view.cols, ...filterZoneFields(view)]);
872
+ const combinedMonths = /* @__PURE__ */ new Set();
873
+ for (const d of view.derived) {
874
+ if (!used.has(d.name) || !CATALOG.cyclicUnits.includes(d.by)) continue;
875
+ const years = yearsOf(result, d.field);
876
+ const observed = observedYears(result, d.field);
877
+ const titled = (words) => {
878
+ const title = `${fieldLabel2(d.name, labels.core)} \xB7 ${fill(words, { years: observed.text })}`;
879
+ titles.set(d.name, title);
880
+ Object.defineProperty(fields, d.name, { value: title, enumerable: true, configurable: true, writable: true });
881
+ };
882
+ if (observed.combined) {
883
+ if (d.by === "month") combinedMonths.add(d.name);
884
+ titled(labels.dateYearsCombined);
885
+ } else if (years.length === 1 && YEAR_IN_ITEMS.includes(d.by)) {
886
+ single.set(d.name, observed.text);
887
+ if (d.by === "month") {
888
+ const months = yearCache.get(result)?.get(d.field)?.months;
889
+ if (months) observedMonths.set(d.name, months);
890
+ }
891
+ } else if (years.length === 1) {
892
+ titled(labels.dateYearOnly);
893
+ }
894
+ }
895
+ const decorated = { ...result, label: (axis, node, core) => {
896
+ const text = result.label(axis, node, core);
897
+ const field = (axis === "rows" ? result.rowFields : result.colFields)[node.depth - 1];
898
+ if (node.parent && typeof node.key === "number" && combinedMonths.has(field)) {
899
+ return dateFormatter(locale, { calendar: "gregory", month: "short", timeZone: "UTC" }).format(Date.UTC(2e3, node.key - 1, 1));
900
+ }
901
+ const span = typeof node.key === "number" ? observedMonths.get(field)?.get(node.key) : void 0;
902
+ if (node.parent && span) {
903
+ const fmt = dateFormatter(locale, { month: "short", year: "numeric", timeZone: "UTC", era: new Date(span.min).getUTCFullYear() <= 0 ? "short" : void 0 });
904
+ if (!["gregory", "iso8601"].includes(fmt.resolvedOptions().calendar)) {
905
+ const first = fmt.format(span.min), last = fmt.format(span.max);
906
+ return first === last ? first : `${first} \u2013 ${last}`;
907
+ }
908
+ }
909
+ return node.parent && node.key !== null && single.has(field) ? `${text} ${single.get(field)}` : text;
910
+ } };
911
+ const active = [...new Set([...view.rows, ...view.cols, ...filterZoneFields(view)].map((f) => sourceOf(view, f)))];
912
+ const ranges = active.flatMap((field) => {
913
+ const text = dateRangeText(dateSpan(encoded, field), locale);
914
+ return text ? [{ field, text }] : [];
915
+ });
916
+ return { result: decorated, labels: { ...labels, core: { ...labels.core, fields } }, ranges, titles };
917
+ }
918
+
919
+ // src/field-info.js
920
+ import { fieldDefaultsFromSchema, isIdentifierName } from "pivotkit-core";
921
+ var isObject = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
922
+ var own = (o, k) => isObject(o) && Object.hasOwn(o, k) ? o[k] : void 0;
923
+ var TYPES = Object.freeze(["string", "number", "date", "boolean"]);
924
+ function fieldInfoOf(fieldDefaults) {
925
+ const map = /* @__PURE__ */ new Map();
926
+ if (!isObject(fieldDefaults)) {
927
+ return map;
928
+ }
929
+ const properties = {};
930
+ for (const name2 of Object.keys(
931
+ /** @type {object} */
932
+ fieldDefaults
933
+ )) {
934
+ const d = own(fieldDefaults, name2);
935
+ const title = own(d, "label");
936
+ const description = own(d, "description");
937
+ const href = own(d, "href");
938
+ if (title !== void 0 || description !== void 0 || href !== void 0) {
939
+ Object.defineProperty(properties, name2, { value: { title, description, externalDocs: { url: href } }, enumerable: true });
940
+ }
941
+ }
942
+ if (Object.keys(properties).length === 0) {
943
+ return map;
944
+ }
945
+ const clean = fieldDefaultsFromSchema({ properties }).defaults;
946
+ for (const name2 of Object.keys(clean)) {
947
+ const { label, description, href } = clean[name2];
948
+ const info = {};
949
+ if (label) {
950
+ info.label = label;
951
+ }
952
+ if (description) {
953
+ info.description = description;
954
+ if (href) {
955
+ info.href = href;
956
+ }
957
+ }
958
+ if (Object.keys(info).length) {
959
+ map.set(name2.toLowerCase(), info);
960
+ }
961
+ }
962
+ return map;
963
+ }
964
+ function displayNames(info, fieldNames = []) {
965
+ const spelling = new Map(fieldNames.map((n) => [String(n).toLowerCase(), String(n)]));
966
+ const uses = /* @__PURE__ */ new Map();
967
+ for (const entry of info.values()) {
968
+ if (entry.label) {
969
+ const l = entry.label.toLowerCase();
970
+ uses.set(l, (uses.get(l) ?? 0) + 1);
971
+ }
972
+ }
973
+ const out = {};
974
+ for (const [key, entry] of info) {
975
+ if (!entry.label) {
976
+ continue;
977
+ }
978
+ const l = entry.label.toLowerCase();
979
+ const clash = uses.get(l) > 1 || spelling.has(l) && l !== key;
980
+ const value = clash ? `${entry.label} (${spelling.get(key) ?? key})` : entry.label;
981
+ Object.defineProperty(out, key, { value, enumerable: true });
982
+ }
983
+ return Object.keys(out).length ? out : null;
984
+ }
985
+ function typesOf(fieldDefaults) {
986
+ if (!isObject(fieldDefaults)) {
987
+ return null;
988
+ }
989
+ const out = {};
990
+ for (const name2 of Object.keys(
991
+ /** @type {object} */
992
+ fieldDefaults
993
+ )) {
994
+ const type = own(own(fieldDefaults, name2), "type");
995
+ if (typeof type === "string" && TYPES.includes(type)) {
996
+ Object.defineProperty(out, name2, { value: type, enumerable: true });
997
+ }
998
+ }
999
+ return Object.keys(out).length ? out : null;
1000
+ }
1001
+ function fieldMatches(field, query, info) {
1002
+ if (!query) {
1003
+ return true;
1004
+ }
1005
+ return [field, info?.label, info?.description].some((t) => typeof t === "string" && t.toLowerCase().includes(query));
1006
+ }
1007
+ function matchingFields(fields, query, info) {
1008
+ const q = query.trim().toLowerCase();
1009
+ return q ? fields.filter((f) => fieldMatches(f.name, q, info.get(f.name.toLowerCase()))) : fields;
1010
+ }
1011
+ var identifierColumns = /* @__PURE__ */ new WeakMap();
1012
+ function isIdentifier(column) {
1013
+ if (!column || column.type !== "number" || column.derived || !isIdentifierName(column.name)) {
1014
+ return false;
1015
+ }
1016
+ const known = identifierColumns.get(column);
1017
+ if (known !== void 0) {
1018
+ return known;
1019
+ }
1020
+ let whole = true;
1021
+ for (let i = 0; i < column.dict.length && whole; i++) {
1022
+ whole = Number.isInteger(column.dict[i]);
1023
+ }
1024
+ identifierColumns.set(column, whole);
1025
+ return whole;
1026
+ }
1027
+ function fieldDefaultsFor(fieldDefaults, field, column) {
1028
+ const key = isObject(fieldDefaults) ? Object.keys(
1029
+ /** @type {object} */
1030
+ fieldDefaults
1031
+ ).find((k) => k.toLowerCase() === String(field).toLowerCase()) : void 0;
1032
+ const host = key === void 0 ? void 0 : own(fieldDefaults, key);
1033
+ const set = ["agg", "format", "drillFormat"].some((k) => own(host, k) !== void 0);
1034
+ if (set || !isIdentifier(column)) {
1035
+ return isObject(host) ? host : void 0;
1036
+ }
1037
+ return { ...isObject(host) ? host : {}, agg: "count", drillFormat: "text" };
1038
+ }
1039
+
723
1040
  // src/clear-input.jsx
724
1041
  import React, { useRef } from "react";
725
1042
  function emptyField(el) {
@@ -742,12 +1059,12 @@ function emptyField(el) {
742
1059
  }
743
1060
  }
744
1061
  function ClearInput({ value, onChange, onClear, clearLabel, multiline = false, className, inputRef, ...rest }) {
745
- const own = useRef(
1062
+ const own2 = useRef(
746
1063
  /** @type {HTMLInputElement | HTMLTextAreaElement | null} */
747
1064
  null
748
1065
  );
749
1066
  const name2 = useFormName();
750
- const ref = inputRef ?? own;
1067
+ const ref = inputRef ?? own2;
751
1068
  const clear = () => {
752
1069
  if (ref.current) {
753
1070
  emptyField(ref.current);
@@ -806,6 +1123,10 @@ function InfoButton({ info, name: name2, labels, className, testId = "field-info
806
1123
  /** @type {{ x: number, y: number } | null} */
807
1124
  null
808
1125
  );
1126
+ const muted = useRef2(false);
1127
+ const muteIfHovered = () => {
1128
+ muted.current = Boolean(ref.current?.matches(":hover"));
1129
+ };
809
1130
  const stay = () => {
810
1131
  if (leaving.current) {
811
1132
  clearTimeout(leaving.current);
@@ -860,6 +1181,7 @@ function InfoButton({ info, name: name2, labels, className, testId = "field-info
860
1181
  }, [mode]);
861
1182
  const close = useCallback(() => {
862
1183
  quiet.current = true;
1184
+ muteIfHovered();
863
1185
  setMode(null);
864
1186
  requestAnimationFrame(() => {
865
1187
  quiet.current = false;
@@ -880,13 +1202,14 @@ function InfoButton({ info, name: name2, labels, className, testId = "field-info
880
1202
  tabIndex,
881
1203
  "data-pk-slot": slot,
882
1204
  "data-testid": testId,
883
- onPointerEnter: (e) => {
884
- if (e.pointerType === "mouse") {
1205
+ onPointerMove: (e) => {
1206
+ if (e.pointerType === "mouse" && !muted.current) {
885
1207
  stay();
886
1208
  setMode((m) => m ?? "peek");
887
1209
  }
888
1210
  },
889
1211
  onPointerLeave: (e) => {
1212
+ muted.current = false;
890
1213
  if (e.pointerType === "mouse" && mode === "peek") {
891
1214
  leaveSoon();
892
1215
  }
@@ -907,6 +1230,9 @@ function InfoButton({ info, name: name2, labels, className, testId = "field-info
907
1230
  },
908
1231
  onClick: () => {
909
1232
  stay();
1233
+ if (mode === "open") {
1234
+ muteIfHovered();
1235
+ }
910
1236
  setMode(mode === "open" ? null : "open");
911
1237
  }
912
1238
  },
@@ -1086,7 +1412,7 @@ function writeItem(name2, storage, text) {
1086
1412
  }
1087
1413
 
1088
1414
  // src/tips.js
1089
- import { CATALOG, fieldLabel as fieldLabel2, suggestDateUnit } from "pivotkit-core";
1415
+ import { CATALOG as CATALOG2, fieldLabel as fieldLabel3, suggestDateUnit } from "pivotkit-core";
1090
1416
  var TIP_LIMIT = 1;
1091
1417
  var TIP_THRESHOLDS = Object.freeze({
1092
1418
  /** columns of an ungrouped date on Columns from which grouping it is suggested */
@@ -1103,7 +1429,7 @@ var TIP_THRESHOLDS = Object.freeze({
1103
1429
  pieSlices: 7
1104
1430
  });
1105
1431
  var PERCENT_SHOW_AS = Object.freeze(["percentOfGrandTotal", "percentOfRowTotal", "percentOfColumnTotal", "percentOfParentRow", "percentOfParentColumn", "percentRunningTotal", "percentDifferenceFromPrevious"]);
1106
- var name = (ctx, field) => fieldLabel2(field, { fields: ctx.fields });
1432
+ var name = (ctx, field) => fieldLabel3(field, { fields: ctx.fields });
1107
1433
  var derivedBy = (ctx, field) => ctx.view.derived.find((d) => d.name.toLowerCase() === String(field).toLowerCase())?.by ?? "";
1108
1434
  var isRawDate = (ctx, field) => ctx.typeOf(field) === "date" && sourceOf(ctx.view, field).toLowerCase() === String(field).toLowerCase();
1109
1435
  var table = (ctx) => !ctx.failed && !ctx.empty && ctx.view.display === "table";
@@ -1181,7 +1507,7 @@ var TIPS = Object.freeze([
1181
1507
  if (chartPlan({ ...ctx.view, chart: { ...ctx.view.chart, type: "auto" } }, ctx.encoded).name !== "line") {
1182
1508
  return null;
1183
1509
  }
1184
- const field = [...ctx.view.rows, ...ctx.view.cols].find((f) => ctx.typeOf(f) === "date" && !CATALOG.cyclicUnits.includes(derivedBy(ctx, f)));
1510
+ const field = [...ctx.view.rows, ...ctx.view.cols].find((f) => ctx.typeOf(f) === "date" && !CATALOG2.cyclicUnits.includes(derivedBy(ctx, f)));
1185
1511
  return field ? { field: name(ctx, field) } : null;
1186
1512
  }
1187
1513
  },
@@ -1468,6 +1794,7 @@ export {
1468
1794
  filterZoneFields,
1469
1795
  axisOf,
1470
1796
  zoneOverLimit,
1797
+ zoneMax,
1471
1798
  addField,
1472
1799
  removeAt,
1473
1800
  moveField,
@@ -1495,7 +1822,9 @@ export {
1495
1822
  setDisplay,
1496
1823
  setChart,
1497
1824
  setChartDisplay,
1825
+ hiddenAfter,
1498
1826
  isEmptyView,
1827
+ valueLabels,
1499
1828
  valueLabel,
1500
1829
  refLabel,
1501
1830
  sortText,
@@ -1506,7 +1835,8 @@ export {
1506
1835
  yearText,
1507
1836
  dayText,
1508
1837
  isoDay,
1509
- relativeDays,
1838
+ todayIn,
1839
+ namedUntil,
1510
1840
  plainRange,
1511
1841
  periodText,
1512
1842
  rangeShare,
@@ -1519,6 +1849,15 @@ export {
1519
1849
  DRILL_LIMIT,
1520
1850
  decodeRow,
1521
1851
  drillRows,
1852
+ dateFormatter,
1853
+ dateDisplayLocale,
1854
+ dateRangeText,
1855
+ dateContext,
1856
+ fieldInfoOf,
1857
+ displayNames,
1858
+ typesOf,
1859
+ matchingFields,
1860
+ fieldDefaultsFor,
1522
1861
  ClearInput,
1523
1862
  InfoButton,
1524
1863
  HelpContext,
@@ -1,11 +1,13 @@
1
1
  // src/report-run.js
2
2
  import { use as register } from "echarts/core";
3
3
  import { SVGRenderer } from "echarts/renderers";
4
- import { LIGHT_TOKENS, SHAPE_TOKENS, SIZE_TOKENS, WEIGHT_TOKENS, render } from "pivotkit-report";
4
+ import { DARK_TOKENS, LIGHT_TOKENS, SHAPE_TOKENS, SIZE_TOKENS, WEIGHT_TOKENS, render } from "pivotkit-report";
5
5
  register([SVGRenderer]);
6
6
  var REPORT_TOKENS = Object.freeze([...Object.keys(WEIGHT_TOKENS), ...Object.keys(SHAPE_TOKENS), ...Object.keys(LIGHT_TOKENS), "--pk-scale-mid"]);
7
+ var REPORT_DARK_TOKENS = Object.freeze([...Object.keys(DARK_TOKENS), "--pk-scale-mid"]);
7
8
  var REPORT_LENGTHS = Object.freeze(Object.keys(SIZE_TOKENS));
8
9
  export {
10
+ REPORT_DARK_TOKENS,
9
11
  REPORT_LENGTHS,
10
12
  REPORT_TOKENS,
11
13
  render
@@ -2,7 +2,7 @@ import {
2
2
  en,
3
3
  unusedItem,
4
4
  unusedItems
5
- } from "./chunk-E6M57YLL.js";
5
+ } from "./chunk-MU5BTKSY.js";
6
6
  export {
7
7
  en,
8
8
  unusedItem,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  de
3
- } from "./chunk-JMRTIOX4.js";
3
+ } from "./chunk-2N2UGSIG.js";
4
4
  export {
5
5
  de
6
6
  };