pivotkit-react 0.8.2 → 0.9.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 +93 -1
- package/dist/chunks/chunk-24T2VRMU.js +1010 -0
- package/dist/chunks/chunk-6R7TJHS3.js +212 -0
- package/dist/chunks/{chunk-GUSQWPTH.js → chunk-EPGRJSPP.js} +20 -5
- package/dist/chunks/{chunk-JAOOFDNR.js → chunk-FAAQZSR4.js} +4 -1
- package/dist/chunks/{chunk-2N2UGSIG.js → chunk-FI22Z6CC.js} +5 -2
- package/dist/chunks/{chunk-ZM45YU3W.js → chunk-G3R5C3J7.js} +28 -6
- package/dist/chunks/{chunk-MU5BTKSY.js → chunk-QCBVEI23.js} +6 -2
- package/dist/chunks/{chunk-6OWC6X5W.js → chunk-QVE7JM4G.js} +1 -1
- package/dist/chunks/{chunk-3WWWKPB4.js → chunk-V233JHVY.js} +75 -336
- package/dist/chunks/chunk-W6BG3GGS.js +679 -0
- package/dist/chunks/chunk-YAT2TFMK.js +138 -0
- package/dist/chunks/chunk-ZQ2M3U74.js +341 -0
- package/dist/chunks/{unused-texts-de-GB3IWWEM.js → labels-de-ZC3CSQZR.js} +1 -1
- package/dist/chunks/tips-SYGQPI3Q.js +22 -0
- package/dist/chunks/{unused-texts-LRYVWFFN.js → unused-texts-ERQ6ACNX.js} +1 -1
- package/dist/chunks/unused-texts-de-AC5GS3FS.js +6 -0
- package/dist/deferred-late.js +13 -0
- package/dist/deferred.js +18 -0
- package/dist/echarts.js +30 -6
- package/dist/import-ui.js +3 -3
- package/dist/index.js +427 -202
- package/dist/labels.js +15 -12
- package/dist/menu-texts-de.js +1 -1
- package/dist/menus.js +518 -381
- package/dist/styles.css +128 -9
- package/package.json +5 -4
- package/types/PivotReport.d.ts +3 -1
- package/types/chart-tooltip.d.ts +18 -1
- package/types/chart-types.d.ts +7 -2
- package/types/chart.d.ts +10 -2
- package/types/chip-menus.d.ts +1 -1
- package/types/deferred-late.d.ts +2 -0
- package/types/deferred.d.ts +28 -0
- package/types/field-info.d.ts +6 -3
- package/types/fields.d.ts +3 -2
- package/types/icons.d.ts +2 -0
- package/types/index.d.ts +20 -10
- package/types/labels-de.d.ts +2 -0
- package/types/labels.d.ts +55 -459
- package/types/lazy-menus.d.ts +2 -2
- package/types/menu-labels.d.ts +20 -0
- package/types/menu-ops.d.ts +33 -0
- package/types/menu-topics.d.ts +6 -3
- package/types/menus.d.ts +1 -0
- package/types/names.d.ts +20 -2
- package/types/notices.d.ts +212 -0
- package/types/point-menu.d.ts +21 -0
- package/types/quick-choices.d.ts +28 -0
- package/types/side-by-side.d.ts +19 -0
- package/types/tip-state.d.ts +97 -0
- package/types/tips.d.ts +13 -250
- package/types/unused-texts.d.ts +3 -0
- package/types/view-ops.d.ts +27 -14
- package/types/view-tabs.d.ts +4 -3
- package/dist/chunks/chunk-W2SVDHGN.js +0 -1898
package/dist/menus.js
CHANGED
|
@@ -1,9 +1,51 @@
|
|
|
1
1
|
import {
|
|
2
|
-
CHART_TYPES,
|
|
3
|
-
CHART_TYPE_NAMES,
|
|
4
2
|
ClearInput,
|
|
5
3
|
HelpContext,
|
|
6
4
|
InfoButton,
|
|
5
|
+
dateDisplayLocale,
|
|
6
|
+
dateFormatter,
|
|
7
|
+
dateRangeText,
|
|
8
|
+
decodeRow,
|
|
9
|
+
importNow,
|
|
10
|
+
linkNow,
|
|
11
|
+
loadCheck,
|
|
12
|
+
loadLink,
|
|
13
|
+
matchingFields,
|
|
14
|
+
readLinkParam,
|
|
15
|
+
shareBase,
|
|
16
|
+
viewFromObject,
|
|
17
|
+
viewFromText,
|
|
18
|
+
withLinkParam
|
|
19
|
+
} from "./chunks/chunk-W6BG3GGS.js";
|
|
20
|
+
import {
|
|
21
|
+
addMenuTexts,
|
|
22
|
+
hasMenuTexts,
|
|
23
|
+
menuLabels
|
|
24
|
+
} from "./chunks/chunk-G3R5C3J7.js";
|
|
25
|
+
import {
|
|
26
|
+
listedFor,
|
|
27
|
+
sheetOfSource
|
|
28
|
+
} from "./chunks/chunk-W2KIPREL.js";
|
|
29
|
+
import {
|
|
30
|
+
Group,
|
|
31
|
+
Icon,
|
|
32
|
+
LayerContext,
|
|
33
|
+
MenuButton,
|
|
34
|
+
Option,
|
|
35
|
+
Popover,
|
|
36
|
+
TYPE_ICON,
|
|
37
|
+
ZONE_ICON,
|
|
38
|
+
activeIn,
|
|
39
|
+
rootOf,
|
|
40
|
+
stopAfter,
|
|
41
|
+
useFormName,
|
|
42
|
+
useIsoLayoutEffect,
|
|
43
|
+
useModal
|
|
44
|
+
} from "./chunks/chunk-FAAQZSR4.js";
|
|
45
|
+
import {
|
|
46
|
+
CHART_TYPES,
|
|
47
|
+
CHART_TYPE_NAMES,
|
|
48
|
+
ITEM_TYPES,
|
|
7
49
|
RULE_OPS,
|
|
8
50
|
SHORTCUTS,
|
|
9
51
|
SLICE_TYPES,
|
|
@@ -11,13 +53,10 @@ import {
|
|
|
11
53
|
axisOf,
|
|
12
54
|
chartTypeOf,
|
|
13
55
|
clone,
|
|
14
|
-
|
|
15
|
-
dateFormatter,
|
|
16
|
-
dateRangeText,
|
|
56
|
+
columnText,
|
|
17
57
|
dateSpan,
|
|
18
58
|
dayMs,
|
|
19
59
|
dayText,
|
|
20
|
-
decodeRow,
|
|
21
60
|
emptyPick,
|
|
22
61
|
filterZoneFields,
|
|
23
62
|
filtersOf,
|
|
@@ -26,14 +65,10 @@ import {
|
|
|
26
65
|
groupingOf,
|
|
27
66
|
hiddenAfter,
|
|
28
67
|
hiddenNot,
|
|
29
|
-
|
|
68
|
+
isFiltered,
|
|
30
69
|
isoDay,
|
|
31
70
|
isoYear,
|
|
32
71
|
itemRuleText,
|
|
33
|
-
linkNow,
|
|
34
|
-
loadCheck,
|
|
35
|
-
loadLink,
|
|
36
|
-
matchingFields,
|
|
37
72
|
moveField,
|
|
38
73
|
namedUntil,
|
|
39
74
|
numericResult,
|
|
@@ -42,7 +77,6 @@ import {
|
|
|
42
77
|
pickFilter,
|
|
43
78
|
plainRange,
|
|
44
79
|
rangeShare,
|
|
45
|
-
readLinkParam,
|
|
46
80
|
refLabel,
|
|
47
81
|
relativeText,
|
|
48
82
|
reorder,
|
|
@@ -51,69 +85,42 @@ import {
|
|
|
51
85
|
sameRef,
|
|
52
86
|
searchItems,
|
|
53
87
|
selectedItems,
|
|
88
|
+
setFieldLabel,
|
|
54
89
|
setSort,
|
|
55
|
-
shareBase,
|
|
56
90
|
sortEntry,
|
|
57
91
|
sortOf,
|
|
58
92
|
sortText,
|
|
93
|
+
sourceFieldName,
|
|
59
94
|
sourceOf,
|
|
60
95
|
todayIn,
|
|
61
96
|
valueConditionText,
|
|
62
97
|
valueLabel,
|
|
63
98
|
valueLabels,
|
|
64
|
-
viewFromObject,
|
|
65
|
-
viewFromText,
|
|
66
99
|
wholeYears,
|
|
67
|
-
withLinkParam,
|
|
68
100
|
yearOf,
|
|
69
101
|
yearText
|
|
70
|
-
} from "./chunks/chunk-
|
|
71
|
-
import {
|
|
72
|
-
addMenuTexts,
|
|
73
|
-
hasMenuTexts,
|
|
74
|
-
menuLabels
|
|
75
|
-
} from "./chunks/chunk-ZM45YU3W.js";
|
|
76
|
-
import {
|
|
77
|
-
listedFor,
|
|
78
|
-
sheetOfSource
|
|
79
|
-
} from "./chunks/chunk-W2KIPREL.js";
|
|
80
|
-
import {
|
|
81
|
-
Group,
|
|
82
|
-
Icon,
|
|
83
|
-
LayerContext,
|
|
84
|
-
MenuButton,
|
|
85
|
-
Option,
|
|
86
|
-
Popover,
|
|
87
|
-
TYPE_ICON,
|
|
88
|
-
ZONE_ICON,
|
|
89
|
-
activeIn,
|
|
90
|
-
rootOf,
|
|
91
|
-
stopAfter,
|
|
92
|
-
useFormName,
|
|
93
|
-
useIsoLayoutEffect,
|
|
94
|
-
useModal
|
|
95
|
-
} from "./chunks/chunk-JAOOFDNR.js";
|
|
102
|
+
} from "./chunks/chunk-24T2VRMU.js";
|
|
96
103
|
import {
|
|
97
104
|
fill,
|
|
98
105
|
hostFailure,
|
|
99
106
|
messageOf,
|
|
100
107
|
plural
|
|
101
|
-
} from "./chunks/chunk-
|
|
108
|
+
} from "./chunks/chunk-V233JHVY.js";
|
|
102
109
|
|
|
103
110
|
// src/chip-menus.jsx
|
|
104
|
-
import
|
|
105
|
-
import { computePivot as computePivot2, fieldLabel as
|
|
111
|
+
import React7, { useId as useId5, useMemo as useMemo3, useState as useState5 } from "react";
|
|
112
|
+
import { computePivot as computePivot2, fieldLabel as fieldLabel5 } from "pivotkit-core";
|
|
106
113
|
|
|
107
114
|
// src/filter-level.jsx
|
|
108
|
-
import
|
|
109
|
-
import { CATALOG as
|
|
115
|
+
import React6, { useContext as useContext3, useEffect as useEffect2, useId as useId4, useMemo as useMemo2, useRef as useRef2, useState as useState4 } from "react";
|
|
116
|
+
import { CATALOG as CATALOG5, LIMITS as LIMITS2, fieldItems as fieldItems3, fieldLabel as fieldLabel4, formatter as formatter2 } from "pivotkit-core";
|
|
110
117
|
|
|
111
118
|
// src/filter.jsx
|
|
112
119
|
import React, { useMemo, useState } from "react";
|
|
113
|
-
import { LIMITS, fieldItems, fieldLabel } from "pivotkit-core";
|
|
120
|
+
import { LIMITS, fieldItems as fieldItems2, fieldLabel as fieldLabel2 } from "pivotkit-core";
|
|
114
121
|
|
|
115
122
|
// src/menu-ops.js
|
|
116
|
-
import { CATALOG, MATCH_DEFAULTS, MAX_DATE_MS, computePivot, isFormat } from "pivotkit-core";
|
|
123
|
+
import { CATALOG, MATCH_DEFAULTS, MAX_DATE_MS, computePivot, fieldItems, fieldLabel, isFormat } from "pivotkit-core";
|
|
117
124
|
|
|
118
125
|
// src/numbers.js
|
|
119
126
|
var cache = /* @__PURE__ */ new Map();
|
|
@@ -250,7 +257,7 @@ function setItemFilter(view, field, selected, all) {
|
|
|
250
257
|
return replaceFilters(view, field, ["in"], excluded.length ? [pickFilter(field, excluded)] : []);
|
|
251
258
|
}
|
|
252
259
|
function setLabelFilter(view, field, condition) {
|
|
253
|
-
return replaceFilters(view, field, ["text"], condition && condition.value !== "" ? [textRule(field, condition)] : []);
|
|
260
|
+
return replaceFilters(view, field, ["text"], condition && condition.value.trim() !== "" ? [textRule(field, condition)] : []);
|
|
254
261
|
}
|
|
255
262
|
var textRule = (field, { op, value, on }) => ({ field, type: "text", ...opOf(op), value, on, match: { ...MATCH_DEFAULTS }, blanks: "exclude" });
|
|
256
263
|
var textOn = (encoded, field) => encoded.column(field)?.type === "string" ? "value" : "label";
|
|
@@ -484,6 +491,31 @@ function parseTarget(text, locale, format) {
|
|
|
484
491
|
const n = /^percent/.test(format ?? "") ? parseNumber(percent[1], locale) : null;
|
|
485
492
|
return n === null ? null : /^percent100/.test(format ?? "") ? n : n / 100;
|
|
486
493
|
}
|
|
494
|
+
function pointActions(view, point, encoded, labels, locale, { showRows = true } = {}) {
|
|
495
|
+
const out = point.slice || !showRows ? [] : [{ id: "rows", text: labels.pointRows }];
|
|
496
|
+
const add = (axis, field, key) => {
|
|
497
|
+
const info = fieldItems(encoded, field, { view, locale, labels: labels.core });
|
|
498
|
+
if (!info) {
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
501
|
+
const all = info.items.map((i) => i.value);
|
|
502
|
+
const item = info.items.find((i) => i.value === key)?.label ?? String(key);
|
|
503
|
+
const shown = selectedItems(view, field, all);
|
|
504
|
+
const name = fieldLabel(field, labels.core);
|
|
505
|
+
const note = { step: "filter", field: name };
|
|
506
|
+
if (shown.length > 1) {
|
|
507
|
+
out.push({ id: `only-${axis}`, text: fill(labels.pointOnly, { item }), field: name, change: () => ({ view: setItemFilter(view, field, [key], all), note }) });
|
|
508
|
+
out.push({ id: `without-${axis}`, text: fill(labels.pointWithout, { item }), field: name, change: () => ({ view: setItemFilter(view, field, shown.filter((v) => v !== key), all), note }) });
|
|
509
|
+
}
|
|
510
|
+
};
|
|
511
|
+
if (point.rowPath.length && view.rows.length >= point.rowPath.length) {
|
|
512
|
+
add("row", view.rows[point.rowPath.length - 1], point.rowPath[point.rowPath.length - 1]);
|
|
513
|
+
}
|
|
514
|
+
if (point.colPath.length && view.cols.length >= point.colPath.length) {
|
|
515
|
+
add("col", view.cols[point.colPath.length - 1], point.colPath[point.colPath.length - 1]);
|
|
516
|
+
}
|
|
517
|
+
return out;
|
|
518
|
+
}
|
|
487
519
|
|
|
488
520
|
// src/filter.jsx
|
|
489
521
|
var FILTER_LIST_MAX = 300;
|
|
@@ -530,7 +562,7 @@ function ValueList({ items, selected, onChange, labels, locale, autoFocus = fals
|
|
|
530
562
|
function FilterBody({ view: current, base, field, encoded, locale, labels, commit, close, onCancel, titled = true }) {
|
|
531
563
|
const view = base ?? current;
|
|
532
564
|
const formName = useFormName();
|
|
533
|
-
const info = useMemo(() =>
|
|
565
|
+
const info = useMemo(() => fieldItems2(encoded, field, { view, locale, labels: labels.core }), [encoded, field, view, locale, labels]);
|
|
534
566
|
const all = useMemo(() => info ? info.items.map((i) => i.value) : [], [info]);
|
|
535
567
|
const [selected, setSelected] = useState(() => new Set(selectedItems(view, field, all).map(keyOf)));
|
|
536
568
|
const label = filtersOf(view, field, ["text"])[0];
|
|
@@ -539,13 +571,14 @@ function FilterBody({ view: current, base, field, encoded, locale, labels, commi
|
|
|
539
571
|
if (!info) {
|
|
540
572
|
return null;
|
|
541
573
|
}
|
|
542
|
-
const name =
|
|
574
|
+
const name = fieldLabel2(field, labels.core);
|
|
575
|
+
const applied = () => setLabelFilter(setItemFilter(view, field, all.filter((v) => selected.has(keyOf(v))), all), field, op ? { op, value: text, on: textOn(encoded, field) } : null);
|
|
543
576
|
const apply = () => {
|
|
544
|
-
|
|
545
|
-
next = setLabelFilter(next, field, op ? { op, value: text, on: textOn(encoded, field) } : null);
|
|
577
|
+
const next = applied();
|
|
546
578
|
close();
|
|
547
579
|
commit(next, { step: "filter", field: name });
|
|
548
580
|
};
|
|
581
|
+
const keepsAll = !isFiltered(applied(), field);
|
|
549
582
|
const kind = conditionKind(encoded, view, field) ?? (label ? "text" : null);
|
|
550
583
|
return /* @__PURE__ */ React.createElement(
|
|
551
584
|
"form",
|
|
@@ -556,7 +589,7 @@ function FilterBody({ view: current, base, field, encoded, locale, labels, commi
|
|
|
556
589
|
apply();
|
|
557
590
|
}
|
|
558
591
|
},
|
|
559
|
-
/* @__PURE__ */ React.createElement("div", { className: "pk-popover-head" }, titled ? /* @__PURE__ */ React.createElement("h3", null, fill(labels.filterTitle, { field: name })) : null, /* @__PURE__ */ React.createElement("span", { className: "pk-muted" }, fill(labels.selected, { count: selected.size.toLocaleString(locale) }))),
|
|
592
|
+
/* @__PURE__ */ React.createElement("div", { className: "pk-popover-head" }, titled ? /* @__PURE__ */ React.createElement("h3", null, fill(labels.filterTitle, { field: name })) : null, /* @__PURE__ */ React.createElement("span", { className: "pk-muted", "data-testid": "filter-selected" }, fill(keepsAll ? labels.selectedAll : labels.selected, { count: selected.size.toLocaleString(locale) }))),
|
|
560
593
|
/* @__PURE__ */ React.createElement(ValueList, { items: info.items, selected, onChange: setSelected, labels, locale, autoFocus: true }, kind ? /* @__PURE__ */ React.createElement("fieldset", { className: "pk-condition" }, /* @__PURE__ */ React.createElement("legend", null, kind === "number" ? labels.conditionNumber : labels.condition), /* @__PURE__ */ React.createElement("select", { name: `${formName}-op`, value: op, onChange: (e) => setOp(e.target.value), "aria-label": kind === "number" ? labels.conditionNumber : labels.condition }, /* @__PURE__ */ React.createElement("option", { value: "" }, labels.conditionNone), RULE_OPS.text.map((o) => /* @__PURE__ */ React.createElement("option", { key: o, value: o }, labels.labelOps[o] ?? o))), op ? /* @__PURE__ */ React.createElement(
|
|
561
594
|
ClearInput,
|
|
562
595
|
{
|
|
@@ -580,9 +613,13 @@ function FilterBody({ view: current, base, field, encoded, locale, labels, commi
|
|
|
580
613
|
}
|
|
581
614
|
function FilterPopover({ target, onClose, view, encoded, locale, labels, commit }) {
|
|
582
615
|
const anchor = useMemo(() => ({ current: target ? target.anchor : null }), [target]);
|
|
583
|
-
return /* @__PURE__ */ React.createElement(Popover, { open: Boolean(target), anchor, onClose, label: target ? fill(labels.filterTitle, { field:
|
|
616
|
+
return /* @__PURE__ */ React.createElement(Popover, { open: Boolean(target), anchor, onClose, label: target ? fill(labels.filterTitle, { field: fieldLabel2(target.field, labels.core) }) : "", className: "pk-filter-popover", fill: true }, target ? /* @__PURE__ */ React.createElement(FilterBody, { key: target.field, view, base: target.base, field: target.field, encoded, locale, labels, commit, close: onClose }) : null);
|
|
584
617
|
}
|
|
585
618
|
|
|
619
|
+
// src/quick-choices.jsx
|
|
620
|
+
import React5, { useId as useId3, useState as useState3 } from "react";
|
|
621
|
+
import { CATALOG as CATALOG4, relativeDateRange } from "pivotkit-core";
|
|
622
|
+
|
|
586
623
|
// src/levels.jsx
|
|
587
624
|
import React3, { useContext as useContext2, useEffect, useId, useLayoutEffect, useRef, useState as useState2 } from "react";
|
|
588
625
|
|
|
@@ -602,11 +639,11 @@ function Section({ title, children, info }) {
|
|
|
602
639
|
}
|
|
603
640
|
|
|
604
641
|
// src/menu-topics.js
|
|
605
|
-
import { CATALOG as CATALOG3, aggregatorsFor, fieldLabel as
|
|
642
|
+
import { CATALOG as CATALOG3, COLOR_SCALES, aggregatorsFor, fieldLabel as fieldLabel3, formatter, isFormat as isFormat2 } from "pivotkit-core";
|
|
606
643
|
|
|
607
644
|
// src/group-context.js
|
|
608
645
|
import { MAX_DATE_MS as MAX_DATE_MS2, isDateMs } from "pivotkit-core";
|
|
609
|
-
import { CATALOG as CATALOG2 } from "pivotkit-core";
|
|
646
|
+
import { CATALOG as CATALOG2, monthName } from "pivotkit-core";
|
|
610
647
|
function groupStats(encoded, field) {
|
|
611
648
|
const column = encoded?.column(field);
|
|
612
649
|
if (!column || column.type !== "date") return null;
|
|
@@ -644,7 +681,7 @@ function groupHint(encoded, field, unit, locale, labels, stats = groupStats(enco
|
|
|
644
681
|
if (CATALOG2.cyclicUnits.includes(unit)) {
|
|
645
682
|
let example = labels.unitHints[unit];
|
|
646
683
|
if (unit === "month" || unit === "quarter") {
|
|
647
|
-
const name = (m) => unit === "quarter" ? `Q${Math.floor(m / 3) + 1}` :
|
|
684
|
+
const name = (m) => unit === "quarter" ? `Q${Math.floor(m / 3) + 1}` : monthName(m + 1, locale);
|
|
648
685
|
const periods = [...new Set(months.map((m) => unit === "quarter" ? Math.floor(m / 3) : m))];
|
|
649
686
|
const runs = [];
|
|
650
687
|
const text = (p) => name(unit === "quarter" ? p * 3 : p);
|
|
@@ -692,7 +729,7 @@ function moveTopic(view, zone, index, count, labels, name, type, defaults) {
|
|
|
692
729
|
}
|
|
693
730
|
function axisTopics({ view, zone, index, field, types, labels, locale, state, defaultsOf, encoded }) {
|
|
694
731
|
const source = sourceOf(view, field);
|
|
695
|
-
const name =
|
|
732
|
+
const name = fieldLabel3(field, labels.core);
|
|
696
733
|
const sourceType = types.get(source.toLowerCase());
|
|
697
734
|
const date = sourceType === "date";
|
|
698
735
|
const grouping = groupingOf(view, field);
|
|
@@ -702,7 +739,7 @@ function axisTopics({ view, zone, index, field, types, labels, locale, state, de
|
|
|
702
739
|
const hostOrder = source === field ? defaultsOf?.(source)?.order : void 0;
|
|
703
740
|
const hosted = Array.isArray(hostOrder) && hostOrder.length > 0;
|
|
704
741
|
const customItems = sort?.by === "custom" ? sort.items : hosted ? hostOrder : null;
|
|
705
|
-
const isSort = (by, order, ref) => sort ? sort.by === by && sort.order === order && (by !== "value" || sameRef(sort.value, ref)) : by === "label" && order === "asc";
|
|
742
|
+
const isSort = (by, order, ref) => sort ? sort.by === by && sort.order === order && (by !== "value" || sameRef(sort.value, ref) && !sort.column) : by === "label" && order === "asc";
|
|
706
743
|
const sortChoice = (id, text, by, order, ref, icon) => ({
|
|
707
744
|
id: `sort-${id}`,
|
|
708
745
|
text,
|
|
@@ -720,7 +757,7 @@ function axisTopics({ view, zone, index, field, types, labels, locale, state, de
|
|
|
720
757
|
if (customItems) {
|
|
721
758
|
byValue.push(sortChoice("custom", labels.sortCustom, "custom", "asc", null, "sortAsc"), sortChoice("custom-desc", labels.sortCustomDesc, "custom", "desc", null, "sortDesc"));
|
|
722
759
|
}
|
|
723
|
-
const otherSort = sort && sort.by !== "label" ? sortText(view, sort, labels) : null;
|
|
760
|
+
const otherSort = sort && sort.by !== "label" ? sortText(view, sort, labels, sort.column && encoded ? columnText(view, sort.column, encoded, labels, locale) : void 0) : null;
|
|
724
761
|
const topics = [
|
|
725
762
|
{
|
|
726
763
|
id: "sort",
|
|
@@ -737,29 +774,7 @@ function axisTopics({ view, zone, index, field, types, labels, locale, state, de
|
|
|
737
774
|
filterTopic({ view, field, labels, locale, state, encoded })
|
|
738
775
|
];
|
|
739
776
|
if (date) {
|
|
740
|
-
|
|
741
|
-
const span = stats?.span;
|
|
742
|
-
const dateLocale = dateDisplayLocale(view.formatting?.locale || locale);
|
|
743
|
-
const regroup = (unit2) => () => {
|
|
744
|
-
const sourceName = fieldLabel2(source, labels.core);
|
|
745
|
-
const grouped = unit2 ? groupingName(sourceName, unit2, labels) : null;
|
|
746
|
-
return { view: groupField(view, field, unit2, { name: grouped ?? void 0 }).view, note: { step: "group", field: sourceName } };
|
|
747
|
-
};
|
|
748
|
-
const unit = (u) => ({ id: `group-${u}`, text: labels.units[u] ?? u, hint: groupHint(encoded, source, u, dateLocale, labels, stats), checked: grouping?.by === u, closes: true, change: regroup(u) });
|
|
749
|
-
topics.push({
|
|
750
|
-
id: "group",
|
|
751
|
-
intro: span ? fill(plural(labels.groupDataRange, calendarDays(span), { lang: labels.lang, locale: dateLocale }), { range: dateRangeText(span, dateLocale) }) : void 0,
|
|
752
|
-
title: labels.groupTopic,
|
|
753
|
-
kind: "menu",
|
|
754
|
-
icon: "date",
|
|
755
|
-
state: grouping ? labels.units[grouping.by] ?? grouping.by : labels.groupNoneShort,
|
|
756
|
-
changed: Boolean(grouping),
|
|
757
|
-
groups: [
|
|
758
|
-
{ title: labels.groupTimeline, choices: CATALOG3.timelineUnits.map(unit) },
|
|
759
|
-
{ title: labels.groupCyclic, choices: CATALOG3.cyclicUnits.map(unit) },
|
|
760
|
-
{ choices: [{ id: "group-none", text: labels.groupNone, checked: !grouping, closes: true, change: regroup(null) }] }
|
|
761
|
-
]
|
|
762
|
-
});
|
|
777
|
+
topics.push(groupTopic({ view, field, source, labels, locale, encoded }));
|
|
763
778
|
} else if (sourceType === "number") {
|
|
764
779
|
const bins = grouping?.by === "bin" ? grouping : null;
|
|
765
780
|
topics.push({ id: "bins", title: labels.bins, kind: "panel", icon: "number", state: bins ? fill(labels.binsState, { size: number(bins.size), start: number(bins.origin ?? 0) }) : labels.off, changed: Boolean(bins) });
|
|
@@ -780,12 +795,17 @@ function axisTopics({ view, zone, index, field, types, labels, locale, state, de
|
|
|
780
795
|
choice: { id: `top-${n}`, text: fill(labels.topBadge, { count: n.toLocaleString(locale) }), checked: Boolean(top && !top.bottom && top.count === n), change: () => ({ view: setTopFilter(view, field, { count: n, bottom: false, by: topBy }, top), note: { step: "top", field: name } }) }
|
|
781
796
|
}))
|
|
782
797
|
});
|
|
798
|
+
topics.push(nameTopic(view, field, labels));
|
|
783
799
|
topics.push(moveTopic(view, zone, index, view[zone].length, labels, name, sourceType, defaultsOf?.(field)));
|
|
784
800
|
return topics;
|
|
785
801
|
}
|
|
802
|
+
function nameTopic(view, field, labels) {
|
|
803
|
+
const own = Object.entries(view.fieldLabels ?? {}).some(([key]) => key.toLowerCase() === field.toLowerCase());
|
|
804
|
+
return { id: "name", title: labels.rename, kind: "panel", icon: "text", state: fieldLabel3(field, labels.core), changed: own, keywords: labels.nameKeywords };
|
|
805
|
+
}
|
|
786
806
|
var NUMBER_TYPED = /\d+/;
|
|
787
807
|
function filterTopic({ view, field, labels, locale, state, encoded }) {
|
|
788
|
-
const name =
|
|
808
|
+
const name = fieldLabel3(field, labels.core);
|
|
789
809
|
const note = { step: "filter", field: name };
|
|
790
810
|
const filtered = filterState(view, field, state, labels, locale);
|
|
791
811
|
const fk = encoded ? ruleKind(encoded, view, field) : null;
|
|
@@ -828,15 +848,49 @@ function filterTopic({ view, field, labels, locale, state, encoded }) {
|
|
|
828
848
|
searchExtra: [
|
|
829
849
|
{ id: "open-filter-rules", text: labels.rulesTitle, focus: "conditions" },
|
|
830
850
|
// the rule on the name by its operators too ("does not begin with")
|
|
831
|
-
|
|
832
|
-
{ id: "open-filter-
|
|
851
|
+
// both add a rule: "rule" finds them under their "Filter by …" names
|
|
852
|
+
{ id: "open-filter-text", text: labels.addRuleName, focus: "conditions", keywords: `${labels.rulesTitle} ${Object.values(labels.labelOps).join(" ")}` },
|
|
853
|
+
{ id: "open-filter-value", text: labels.addRuleTotal, focus: "conditions", keywords: labels.rulesTitle }
|
|
833
854
|
],
|
|
834
855
|
searchFor
|
|
835
856
|
};
|
|
836
857
|
}
|
|
858
|
+
function groupTopic({ view, field, source, labels, locale, encoded }) {
|
|
859
|
+
const grouping = groupingOf(view, field);
|
|
860
|
+
const stats = groupStats(encoded, source);
|
|
861
|
+
const span = stats?.span;
|
|
862
|
+
const dateLocale = dateDisplayLocale(view.formatting?.locale || locale);
|
|
863
|
+
const regroup = (unit2) => () => {
|
|
864
|
+
const sourceName = fieldLabel3(source, labels.core);
|
|
865
|
+
const grouped = unit2 ? groupingName(sourceName, unit2, labels) : null;
|
|
866
|
+
return { view: groupField(view, field, unit2, { name: grouped ?? void 0 }).view, note: { step: "group", field: sourceName } };
|
|
867
|
+
};
|
|
868
|
+
const unit = (u) => ({ id: `group-${u}`, text: labels.units[u] ?? u, hint: groupHint(encoded, source, u, dateLocale, labels, stats), checked: grouping?.by === u, closes: true, change: regroup(u) });
|
|
869
|
+
return {
|
|
870
|
+
id: "group",
|
|
871
|
+
// the data's range, and for a filtered field that another grouping clears the filter
|
|
872
|
+
intro: [span ? fill(plural(labels.groupDataRange, calendarDays(span), { lang: labels.lang, locale: dateLocale }), { range: dateRangeText(span, dateLocale) }) : "", isFiltered(view, field) ? labels.groupClearsFilter : ""].filter(Boolean).join(" ") || void 0,
|
|
873
|
+
title: labels.groupTopic,
|
|
874
|
+
kind: "menu",
|
|
875
|
+
icon: "date",
|
|
876
|
+
state: grouping ? labels.units[grouping.by] ?? grouping.by : labels.groupNoneShort,
|
|
877
|
+
changed: Boolean(grouping),
|
|
878
|
+
groups: [
|
|
879
|
+
{ title: labels.groupTimeline, choices: CATALOG3.timelineUnits.map(unit) },
|
|
880
|
+
{ title: labels.groupCyclic, choices: CATALOG3.cyclicUnits.map(unit) },
|
|
881
|
+
{ choices: [{ id: "group-none", text: labels.groupNone, checked: !grouping, closes: true, change: regroup(null) }] }
|
|
882
|
+
]
|
|
883
|
+
};
|
|
884
|
+
}
|
|
837
885
|
function filterZoneTopics({ view, index, field, types, labels, locale, state, encoded }) {
|
|
838
|
-
const
|
|
839
|
-
|
|
886
|
+
const source = sourceOf(view, field);
|
|
887
|
+
const type = types.get(source.toLowerCase());
|
|
888
|
+
return [
|
|
889
|
+
filterTopic({ view, field, labels, locale, state, encoded }),
|
|
890
|
+
...type === "date" ? [groupTopic({ view, field, source, labels, locale, encoded })] : [],
|
|
891
|
+
nameTopic(view, field, labels),
|
|
892
|
+
moveTopic(view, "filters", index, filterZoneFields(view).length, labels, fieldLabel3(field, labels.core), type)
|
|
893
|
+
];
|
|
840
894
|
}
|
|
841
895
|
function topText(view, top, labels, locale) {
|
|
842
896
|
const by = top.by ?? (view.values?.[0] ? { field: view.values[0].field ?? null, agg: view.values[0].agg } : null);
|
|
@@ -853,6 +907,19 @@ function formatLabel(format, labels, locale) {
|
|
|
853
907
|
const kind = format.split(":")[0];
|
|
854
908
|
return Object.hasOwn(labels.formats, kind) ? labels.formats[kind] : format;
|
|
855
909
|
}
|
|
910
|
+
var THEME_SCALE = Object.freeze(["var(--pk-scale-low)", "var(--pk-scale-mid, color-mix(in srgb, var(--pk-scale-low), var(--pk-scale-high)))", "var(--pk-scale-high)"]);
|
|
911
|
+
function scaleTopic(colors, write, labels) {
|
|
912
|
+
const same2 = (list) => list.length === colors.length && list.every((c, i) => c.toLowerCase() === colors[i].toLowerCase());
|
|
913
|
+
const presets = Object.entries(COLOR_SCALES).map(([key, list]) => ({ key, list: [...list] }));
|
|
914
|
+
const own = colors.length > 0 && !presets.some((p) => same2(p.list));
|
|
915
|
+
const choices = [
|
|
916
|
+
{ id: "scale-theme", text: labels.scaleNames.theme, scale: [...THEME_SCALE], checked: colors.length === 0, change: colors.length === 0 ? () => null : write([]) },
|
|
917
|
+
...presets.map(({ key, list }) => ({ id: `scale-${key}`, text: labels.scaleNames[key], note: key === "redGreen" ? labels.scaleRedGreenHint : void 0, scale: list, checked: same2(list), change: same2(list) ? () => null : write(list) })),
|
|
918
|
+
...own ? [{ id: "scale-own", text: labels.scaleOwn, scale: colors, checked: true, change: () => null }] : []
|
|
919
|
+
];
|
|
920
|
+
const current = choices.find((c) => c.checked);
|
|
921
|
+
return { id: "scaleColors", title: labels.scaleColors, kind: "menu", icon: "heatmap", state: current?.text, changed: colors.length > 0, keywords: labels.scaleKeywords, groups: [{ choices }] };
|
|
922
|
+
}
|
|
856
923
|
function valueTopics({ view, index, types, labels, locale, defaultsOf, earlier }) {
|
|
857
924
|
const spec = view.values[index];
|
|
858
925
|
const type = spec.field ? types.get(spec.field.toLowerCase()) ?? "string" : "number";
|
|
@@ -946,6 +1013,9 @@ function valueTopics({ view, index, types, labels, locale, defaultsOf, earlier }
|
|
|
946
1013
|
]
|
|
947
1014
|
});
|
|
948
1015
|
}
|
|
1016
|
+
if (spec.conditional?.type === "colorScale") {
|
|
1017
|
+
topics.push(scaleTopic(spec.conditional.colors ?? [], (colors) => set({ conditional: { type: "colorScale", colors } }), labels));
|
|
1018
|
+
}
|
|
949
1019
|
topics.push({ id: "name", title: labels.rename, kind: "panel", icon: "text", state: name, changed: Boolean(spec.label), keywords: labels.nameKeywords });
|
|
950
1020
|
topics.push(moveTopic(view, "values", index, view.values.length, labels, name, type));
|
|
951
1021
|
return topics;
|
|
@@ -954,11 +1024,11 @@ function rowFoldTexts(view, labels) {
|
|
|
954
1024
|
if (view.rows.length < 2) {
|
|
955
1025
|
return { expand: labels.chartShowDetails, collapse: labels.chartShowTotals, named: false };
|
|
956
1026
|
}
|
|
957
|
-
const name = (f) =>
|
|
1027
|
+
const name = (f) => fieldLabel3(f, labels.core);
|
|
958
1028
|
return { expand: fill(labels.chartShowEach, { field: name(view.rows.at(-1)) }), collapse: fill(labels.chartShowOnly, { field: name(view.rows[0]) }), named: true };
|
|
959
1029
|
}
|
|
960
1030
|
function foldState(view, folding, labels) {
|
|
961
|
-
const name = (f) =>
|
|
1031
|
+
const name = (f) => fieldLabel3(f, labels.core);
|
|
962
1032
|
if (!folding.collapsed) {
|
|
963
1033
|
return { text: fill(labels.chartFoldEach, { field: name(view.rows.at(-1)) }), changed: false };
|
|
964
1034
|
}
|
|
@@ -1015,10 +1085,11 @@ function moreTopics({ labels, tips, explanations, act }) {
|
|
|
1015
1085
|
];
|
|
1016
1086
|
}
|
|
1017
1087
|
var VALUE_LABELS = Object.freeze({ slices: ["auto", "off", "value", "percent", "both"], other: ["auto", "off", "value"] });
|
|
1018
|
-
function chartTopics({ view, drawn, labels, names, act, lines = { rules: { average: true, trend: true, target: true, notes: [] }, targetText: "" }, drawnColors = /* @__PURE__ */ new Map(), folding }) {
|
|
1088
|
+
function chartTopics({ view, drawn, labels, names, act, lines = { rules: { average: true, trend: true, target: true, extremes: true, notes: [] }, targetText: "" }, drawnColors = /* @__PURE__ */ new Map(), folding }) {
|
|
1019
1089
|
const chart = view.chart;
|
|
1020
1090
|
const pie = SLICE_TYPES.includes(drawn);
|
|
1021
1091
|
const axis = CHART_TYPES[drawn]?.axis ?? false;
|
|
1092
|
+
const legend = drawn !== "treemap";
|
|
1022
1093
|
const pickOf = (key, value, text, id, info = void 0) => ({ id, text, checked: (chart[key] ?? null) === value, info, run: () => act.display({ [key]: value }) });
|
|
1023
1094
|
const flip = (key, text, id, info = void 0) => ({ id, text, checkbox: true, checked: Boolean(chart[key]), info, run: () => act.display({ [key]: !chart[key] }) });
|
|
1024
1095
|
const valueLabels2 = !pie && (chart.valueLabels === "percent" || chart.valueLabels === "both") ? "value" : chart.valueLabels;
|
|
@@ -1031,7 +1102,10 @@ function chartTopics({ view, drawn, labels, names, act, lines = { rules: { avera
|
|
|
1031
1102
|
changed: valueLabels2 !== "auto",
|
|
1032
1103
|
groups: [{ choices: (pie ? VALUE_LABELS.slices : VALUE_LABELS.other).map((v) => ({ ...pickOf("valueLabels", v, labels.valueLabelNames[v], `labels-${v}`), checked: valueLabels2 === v })) }]
|
|
1033
1104
|
},
|
|
1034
|
-
|
|
1105
|
+
...legend ? [
|
|
1106
|
+
/** @type {Topic} */
|
|
1107
|
+
{ id: "legend", title: labels.legend, kind: "menu", state: labels.legendNames[chart.legend], changed: chart.legend !== "auto", groups: [{ choices: ["auto", "bottom", "right", "off"].map((v) => pickOf("legend", v, labels.legendNames[v], `legend-${v}`)) }] }
|
|
1108
|
+
] : [],
|
|
1035
1109
|
{ id: "title", title: labels.chartTitle, kind: "panel", state: chart.title || labels.chartTitleNone, changed: Boolean(chart.title) }
|
|
1036
1110
|
];
|
|
1037
1111
|
if (axis) {
|
|
@@ -1063,8 +1137,8 @@ function chartTopics({ view, drawn, labels, names, act, lines = { rules: { avera
|
|
|
1063
1137
|
groups: [...axis ? [{ choices: ["auto", "axis"].map((v) => pickOf("tooltip", v, labels.tooltipNames[v], `tooltip-${v}`)) }] : [], { choices: [flip("tooltipShare", labels.tooltipShare, "chart-tooltip-share")] }]
|
|
1064
1138
|
});
|
|
1065
1139
|
}
|
|
1066
|
-
if (axis) {
|
|
1067
|
-
const now = chart.referenceLines ?? { average: false, trend: false, target: null };
|
|
1140
|
+
if (axis && CHART_TYPES[drawn]?.lines !== false) {
|
|
1141
|
+
const now = chart.referenceLines ?? { average: false, trend: false, target: null, extremes: false };
|
|
1068
1142
|
const words = labels.core.referenceLines;
|
|
1069
1143
|
const { rules, targetText } = lines;
|
|
1070
1144
|
const notes = Array.isArray(rules.notes) ? rules.notes : [];
|
|
@@ -1077,11 +1151,13 @@ function chartTopics({ view, drawn, labels, names, act, lines = { rules: { avera
|
|
|
1077
1151
|
const choices = [
|
|
1078
1152
|
{ id: "line-average", text: words.average, checkbox: true, checked: now.average, disabled: !rules.average, reason: rules.average ? void 0 : say(total), run: () => set({ average: !now.average }) },
|
|
1079
1153
|
{ id: "line-trend", text: words.trend, checkbox: true, checked: now.trend, disabled: !rules.trend, reason: rules.trend ? void 0 : say([...total, "noTime"]), run: () => set({ trend: !now.trend }) },
|
|
1154
|
+
// the high and low points (#574): where an average is drawn, with its reason where not
|
|
1155
|
+
{ id: "line-extremes", text: labels.linesExtremes, checkbox: true, checked: Boolean(now.extremes), disabled: !rules.extremes, reason: rules.extremes ? void 0 : say(total), run: () => set({ extremes: !now.extremes }) },
|
|
1080
1156
|
{ id: "line-target", text: words.target, hint: now.target !== null ? targetText : labels.targetNone, open: "linesTarget", disabled: !rules.target, reason: rules.target ? void 0 : say(["noTotal", "percentStack", "mixedUnits"]) },
|
|
1081
1157
|
// a target the chart cannot draw stays removable
|
|
1082
1158
|
...!rules.target && now.target !== null ? [{ id: "target-remove", text: labels.targetRemove, run: () => set({ target: null }) }] : []
|
|
1083
1159
|
];
|
|
1084
|
-
const on2 = [now.average ? words.average : null, now.trend ? words.trend : null, now.target !== null ? words.target : null].filter(Boolean);
|
|
1160
|
+
const on2 = [now.average ? words.average : null, now.trend ? words.trend : null, now.extremes ? labels.linesExtremes : null, now.target !== null ? words.target : null].filter(Boolean);
|
|
1085
1161
|
const note = notes.includes("table") ? labels.linesNotes.table : notes.includes("byIndex") && rules.trend ? labels.linesNotes.byIndex : null;
|
|
1086
1162
|
topics.push({ id: "lines", title: labels.referenceLines, kind: "menu", state: on2.length ? on2.join(", ") : labels.linesOff, changed: on2.length > 0, groups: [{ choices }], note, noteId: "lines-note" });
|
|
1087
1163
|
topics.push({ id: "linesTarget", title: words.target, kind: "panel", hidden: true, levelTitle: `${labels.referenceLines} \u203A ${words.target}` });
|
|
@@ -1382,7 +1458,10 @@ function ChoiceItem({ choice: c, onPick, start }) {
|
|
|
1382
1458
|
const item = /* @__PURE__ */ React3.createElement(MenuItem, { id: c.id, testId: c.testId, text: c.text, label: c.label, hint: c.hint, icon: c.icon, checked: c.checked, checkbox: c.checkbox, current: c.current, disabled: c.disabled, reason: c.reason, description: text, note: c.note, start, haspopup: c.open ? "dialog" : void 0, className, onSelect: () => onPick(c) }, (c.tags ?? []).map((t) => /* @__PURE__ */ React3.createElement("span", { key: t.text, className: "pk-tag", "aria-hidden": "true" }, /* @__PURE__ */ React3.createElement(Icon, { name: (
|
|
1383
1459
|
/** @type {any} */
|
|
1384
1460
|
t.icon
|
|
1385
|
-
), size: 12 }), t.text)), c.
|
|
1461
|
+
), size: 12 }), t.text)), c.scale ? /* @__PURE__ */ React3.createElement("span", { className: "pk-scale-swatch", "aria-hidden": "true", style: (
|
|
1462
|
+
/** @type {any} */
|
|
1463
|
+
{ "--pk-swatch": `linear-gradient(to right, ${c.scale.join(", ")})` }
|
|
1464
|
+
) }) : null, c.open ? /* @__PURE__ */ React3.createElement(Icon, { name: "chevronRight", size: 16, className: "pk-topic-chevron" }) : null);
|
|
1386
1465
|
if (!text && !c.actions?.length && !c.color) {
|
|
1387
1466
|
return item;
|
|
1388
1467
|
}
|
|
@@ -1730,102 +1809,9 @@ function measuresOf(view, types, labels, ref) {
|
|
|
1730
1809
|
return { choices, names: choices.map((c) => refLabel(view, c, labels)) };
|
|
1731
1810
|
}
|
|
1732
1811
|
|
|
1733
|
-
// src/
|
|
1734
|
-
var twin = (op) => op === "between" || op === "notBetween";
|
|
1735
|
-
function useLatest(props) {
|
|
1736
|
-
const ref = useRef2(props);
|
|
1737
|
-
useEffect2(() => {
|
|
1738
|
-
ref.current = props;
|
|
1739
|
-
});
|
|
1740
|
-
return ref;
|
|
1741
|
-
}
|
|
1742
|
-
var emptied = (patch) => ["a", "b", "count"].some((k) => {
|
|
1743
|
-
const v = patch[k];
|
|
1744
|
-
return typeof v === "string" && v.trim() === "";
|
|
1745
|
-
});
|
|
1812
|
+
// src/quick-choices.jsx
|
|
1746
1813
|
var capital = (text, locale) => text.charAt(0).toLocaleUpperCase(locale) + text.slice(1);
|
|
1747
|
-
var rulesKeyOf = (rules) => JSON.stringify(rules, (_k, v) => v && typeof v === "object" && !Array.isArray(v) ? Object.fromEntries(Object.entries(v).sort(([a], [b]) => a < b ? -1 : 1)) : v);
|
|
1748
|
-
var rowKind = (f) => !editable(f) ? "fixed" : f.type === "value" ? "total" : f.type === "text" ? "name" : "item";
|
|
1749
|
-
var RANGE_UNITS = Object.freeze(["year", "month", "day"]);
|
|
1750
|
-
var ruleRange = (f) => plainRange(f) && (f.direction ?? "last") === "last" && f.includeCurrent !== false && RANGE_UNITS.includes(f.unit);
|
|
1751
|
-
var editable = (f) => !hiddenNot(f) && (f.type !== "relative" || ruleRange(f)) && (f.type !== "compare" || (f.precision ?? "day") === "day");
|
|
1752
1814
|
var REACH = Object.freeze({ year: 10, quarter: 12, month: 24, week: 104, day: 90 });
|
|
1753
|
-
var PICKER_MIN = 13;
|
|
1754
|
-
function nounOf(fk, labels) {
|
|
1755
|
-
const unit = fk.unit;
|
|
1756
|
-
const key = unit === null ? fk.item === "number" ? "value" : fk.item === "date" ? "date" : "item" : unit === "bin" ? "range" : unit === "day" ? "day" : unit.replace(/^year(.)/, (_m, c) => c.toLowerCase());
|
|
1757
|
-
return Object.hasOwn(labels.nouns, key) ? labels.nouns[key] : labels.nouns.item;
|
|
1758
|
-
}
|
|
1759
|
-
function countsOf(column) {
|
|
1760
|
-
const counts = new Float64Array(column.dict.length);
|
|
1761
|
-
for (let i = 0; i < column.codes.length; i++) {
|
|
1762
|
-
if (column.codes[i] >= 0) {
|
|
1763
|
-
counts[column.codes[i]]++;
|
|
1764
|
-
}
|
|
1765
|
-
}
|
|
1766
|
-
return counts;
|
|
1767
|
-
}
|
|
1768
|
-
function yearsOf(column, counts) {
|
|
1769
|
-
const rows = /* @__PURE__ */ new Map();
|
|
1770
|
-
column.dict.forEach((v, code) => {
|
|
1771
|
-
if (typeof v === "number") {
|
|
1772
|
-
const y = new Date(v).getUTCFullYear();
|
|
1773
|
-
rows.set(y, (rows.get(y) ?? 0) + counts[code]);
|
|
1774
|
-
}
|
|
1775
|
-
});
|
|
1776
|
-
return [...rows.entries()].sort((a, b) => a[0] - b[0]).map(([year, n]) => ({ year, rows: n }));
|
|
1777
|
-
}
|
|
1778
|
-
function LeftOut({ out, row, searching, labels, locale }) {
|
|
1779
|
-
const [open, setOpen] = useState3(false);
|
|
1780
|
-
const id = useId3();
|
|
1781
|
-
const shown = open || searching;
|
|
1782
|
-
const list = useRef2(
|
|
1783
|
-
/** @type {HTMLUListElement | null} */
|
|
1784
|
-
null
|
|
1785
|
-
);
|
|
1786
|
-
useEffect2(() => {
|
|
1787
|
-
if (open) {
|
|
1788
|
-
list.current?.firstElementChild?.scrollIntoView?.({ block: "nearest" });
|
|
1789
|
-
}
|
|
1790
|
-
}, [open]);
|
|
1791
|
-
return /* @__PURE__ */ React5.createElement("li", { className: "pk-values-tail" }, /* @__PURE__ */ React5.createElement("button", { type: "button", className: "pk-tail-toggle", "aria-expanded": shown, "aria-controls": id, onClick: () => setOpen(!shown), "data-testid": "tail-toggle" }, /* @__PURE__ */ React5.createElement(Icon, { name: shown ? "chevronDown" : "chevronRight", size: 14 }), /* @__PURE__ */ React5.createElement("span", null, fill(plural(labels.tailOut, out.length, { lang: labels.lang, locale }), { count: out.length.toLocaleString(locale) }))), shown ? /* @__PURE__ */ React5.createElement("ul", { ref: list, id, role: "list", className: "pk-tail-list", "data-testid": "tail-list" }, out.slice(0, FILTER_LIST_MAX).map(row)) : null);
|
|
1792
|
-
}
|
|
1793
|
-
function Section2({ id, title, state, open, onToggle, action, children }) {
|
|
1794
|
-
const bodyId = useId3();
|
|
1795
|
-
return /* @__PURE__ */ React5.createElement("section", { className: "pk-fsection", "data-testid": `fsection-${id}` }, /* @__PURE__ */ React5.createElement("div", { className: "pk-fsection-head" }, /* @__PURE__ */ React5.createElement("button", { type: "button", className: "pk-fsection-toggle", "aria-expanded": open, "aria-controls": bodyId, onClick: onToggle, "data-testid": `section-${id}` }, /* @__PURE__ */ React5.createElement(Icon, { name: open ? "chevronDown" : "chevronRight", size: 16 }), /* @__PURE__ */ React5.createElement("span", { className: "pk-fsection-title" }, title), state ? /* @__PURE__ */ React5.createElement("span", { className: "pk-fsection-state" }, state) : null), action), open ? /* @__PURE__ */ React5.createElement("div", { className: "pk-fsection-body", id: bodyId, "data-testid": `${id}-body` }, children) : null);
|
|
1796
|
-
}
|
|
1797
|
-
function Summary({ ctx, state }) {
|
|
1798
|
-
const { labels, locale, view, field } = ctx;
|
|
1799
|
-
const { shown, total, noun, unpicked, byQuick, byRules, byTotals, rows, rowsAll, span, yearsText, empty, quickWords } = state;
|
|
1800
|
-
const number = (n) => n.toLocaleString(locale);
|
|
1801
|
-
const lang = { lang: labels.lang, locale };
|
|
1802
|
-
const head = shown === 0 ? labels.summaryNone : shown === total ? fill(labels.summaryAll, { total: number(total), noun: plural(noun, total, lang) }) : fill(labels.summarySome, { shown: number(shown), total: number(total), noun: plural(noun, total, lang) });
|
|
1803
|
-
const why = [];
|
|
1804
|
-
if (shown === 0 && empty) {
|
|
1805
|
-
why.push(empty);
|
|
1806
|
-
} else {
|
|
1807
|
-
if (unpicked) {
|
|
1808
|
-
why.push(fill(labels.summaryPicks, { count: number(unpicked) }));
|
|
1809
|
-
}
|
|
1810
|
-
if (byQuick) {
|
|
1811
|
-
why.push(fill(labels.summaryQuick, { count: number(byQuick), quick: quickWords }));
|
|
1812
|
-
}
|
|
1813
|
-
if (byRules) {
|
|
1814
|
-
why.push(fill(plural(labels.summaryRules, state.itemRules, lang), { items: number(byRules) }));
|
|
1815
|
-
}
|
|
1816
|
-
if (byTotals) {
|
|
1817
|
-
why.push(fill(plural(labels.summaryTotals, state.totalRules, lang), { items: number(byTotals) }));
|
|
1818
|
-
}
|
|
1819
|
-
}
|
|
1820
|
-
const meta = [fill(labels.summaryRows, { rows: number(rows), total: number(rowsAll) })];
|
|
1821
|
-
if (span) {
|
|
1822
|
-
meta.push(fill(labels.summaryData, { range: `${dayText(isoDay(span.min), locale)} \u2013 ${dayText(isoDay(span.max), locale)}` }));
|
|
1823
|
-
}
|
|
1824
|
-
if (yearsText) {
|
|
1825
|
-
meta.push(yearsText);
|
|
1826
|
-
}
|
|
1827
|
-
return /* @__PURE__ */ React5.createElement("div", { className: "pk-filter-summary" }, /* @__PURE__ */ React5.createElement("div", { className: `pk-summary-card${shown === 0 ? " pk-summary-empty" : ""}`, role: "status", "data-testid": "filter-summary" }, /* @__PURE__ */ React5.createElement("p", { className: "pk-summary-head", "data-testid": "filter-summary-head" }, head), /* @__PURE__ */ React5.createElement("p", { className: "pk-summary-why", "data-testid": "filter-summary-why" }, why.length ? why.join(" \xB7 ") : state.rules ? labels.summaryKept : quickWords ? fill(labels.summaryQuickOnly, { quick: quickWords }) : labels.summaryOk), /* @__PURE__ */ React5.createElement("p", { className: "pk-summary-meta", "data-testid": "filter-summary-meta" }, meta.join(" \xB7 ")), /* @__PURE__ */ React5.createElement("button", { type: "button", className: "pk-action pk-summary-reset", disabled: !state.canReset, onClick: () => ctx.act(resetFilter(view, field), "section-picks"), "data-testid": "filter-reset" }, labels.resetFilter)));
|
|
1828
|
-
}
|
|
1829
1815
|
var COUNTED = Object.freeze(["last", "next", "before"]);
|
|
1830
1816
|
var MORE = Object.freeze(["next", "before"]);
|
|
1831
1817
|
var inMore = (quick) => MORE.includes(quick.id) || COUNTED.includes(quick.id) && quick.calendar === false;
|
|
@@ -2091,6 +2077,101 @@ function QuickChoices({ ctx, quick, anchor, setAnchorLocal, span, column, counts
|
|
|
2091
2077
|
}
|
|
2092
2078
|
), /* @__PURE__ */ React5.createElement("span", null, labels.quickRolling)), anchorOutside ? null : anchorRow) : null);
|
|
2093
2079
|
}
|
|
2080
|
+
|
|
2081
|
+
// src/filter-level.jsx
|
|
2082
|
+
var twin = (op) => op === "between" || op === "notBetween";
|
|
2083
|
+
function useLatest(props) {
|
|
2084
|
+
const ref = useRef2(props);
|
|
2085
|
+
useEffect2(() => {
|
|
2086
|
+
ref.current = props;
|
|
2087
|
+
});
|
|
2088
|
+
return ref;
|
|
2089
|
+
}
|
|
2090
|
+
var emptied = (patch) => ["a", "b", "count"].some((k) => {
|
|
2091
|
+
const v = patch[k];
|
|
2092
|
+
return typeof v === "string" && v.trim() === "";
|
|
2093
|
+
});
|
|
2094
|
+
var rulesKeyOf = (rules) => JSON.stringify(rules, (_k, v) => v && typeof v === "object" && !Array.isArray(v) ? Object.fromEntries(Object.entries(v).sort(([a], [b]) => a < b ? -1 : 1)) : v);
|
|
2095
|
+
var rowKind = (f) => !editable(f) ? "fixed" : f.type === "value" ? "total" : f.type === "text" ? "name" : "item";
|
|
2096
|
+
var RANGE_UNITS = Object.freeze(["year", "month", "day"]);
|
|
2097
|
+
var ruleRange = (f) => plainRange(f) && (f.direction ?? "last") === "last" && f.includeCurrent !== false && RANGE_UNITS.includes(f.unit);
|
|
2098
|
+
var editable = (f) => !hiddenNot(f) && (f.type !== "relative" || ruleRange(f)) && (f.type !== "compare" || (f.precision ?? "day") === "day");
|
|
2099
|
+
var PICKER_MIN = 13;
|
|
2100
|
+
function nounOf(fk, labels) {
|
|
2101
|
+
const unit = fk.unit;
|
|
2102
|
+
const key = unit === null ? fk.item === "number" ? "value" : fk.item === "date" ? "date" : "item" : unit === "bin" ? "range" : unit === "day" ? "day" : unit.replace(/^year(.)/, (_m, c) => c.toLowerCase());
|
|
2103
|
+
return Object.hasOwn(labels.nouns, key) ? labels.nouns[key] : labels.nouns.item;
|
|
2104
|
+
}
|
|
2105
|
+
function countsOf(column) {
|
|
2106
|
+
const counts = new Float64Array(column.dict.length);
|
|
2107
|
+
for (let i = 0; i < column.codes.length; i++) {
|
|
2108
|
+
if (column.codes[i] >= 0) {
|
|
2109
|
+
counts[column.codes[i]]++;
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2112
|
+
return counts;
|
|
2113
|
+
}
|
|
2114
|
+
function yearsOf(column, counts) {
|
|
2115
|
+
const rows = /* @__PURE__ */ new Map();
|
|
2116
|
+
column.dict.forEach((v, code) => {
|
|
2117
|
+
if (typeof v === "number") {
|
|
2118
|
+
const y = new Date(v).getUTCFullYear();
|
|
2119
|
+
rows.set(y, (rows.get(y) ?? 0) + counts[code]);
|
|
2120
|
+
}
|
|
2121
|
+
});
|
|
2122
|
+
return [...rows.entries()].sort((a, b) => a[0] - b[0]).map(([year, n]) => ({ year, rows: n }));
|
|
2123
|
+
}
|
|
2124
|
+
function LeftOut({ out, row, searching, labels, locale }) {
|
|
2125
|
+
const [open, setOpen] = useState4(false);
|
|
2126
|
+
const id = useId4();
|
|
2127
|
+
const shown = open || searching;
|
|
2128
|
+
const list = useRef2(
|
|
2129
|
+
/** @type {HTMLUListElement | null} */
|
|
2130
|
+
null
|
|
2131
|
+
);
|
|
2132
|
+
useEffect2(() => {
|
|
2133
|
+
if (open) {
|
|
2134
|
+
list.current?.firstElementChild?.scrollIntoView?.({ block: "nearest" });
|
|
2135
|
+
}
|
|
2136
|
+
}, [open]);
|
|
2137
|
+
return /* @__PURE__ */ React6.createElement("li", { className: "pk-values-tail" }, /* @__PURE__ */ React6.createElement("button", { type: "button", className: "pk-tail-toggle", "aria-expanded": shown, "aria-controls": id, onClick: () => setOpen(!shown), "data-testid": "tail-toggle" }, /* @__PURE__ */ React6.createElement(Icon, { name: shown ? "chevronDown" : "chevronRight", size: 14 }), /* @__PURE__ */ React6.createElement("span", null, fill(plural(labels.tailOut, out.length, { lang: labels.lang, locale }), { count: out.length.toLocaleString(locale) }))), shown ? /* @__PURE__ */ React6.createElement("ul", { ref: list, id, role: "list", className: "pk-tail-list", "data-testid": "tail-list" }, out.slice(0, FILTER_LIST_MAX).map(row)) : null);
|
|
2138
|
+
}
|
|
2139
|
+
function Section2({ id, title, state, open, onToggle, action, children }) {
|
|
2140
|
+
const bodyId = useId4();
|
|
2141
|
+
return /* @__PURE__ */ React6.createElement("section", { className: "pk-fsection", "data-testid": `fsection-${id}` }, /* @__PURE__ */ React6.createElement("div", { className: "pk-fsection-head" }, /* @__PURE__ */ React6.createElement("button", { type: "button", className: "pk-fsection-toggle", "aria-expanded": open, "aria-controls": bodyId, onClick: onToggle, "data-testid": `section-${id}` }, /* @__PURE__ */ React6.createElement(Icon, { name: open ? "chevronDown" : "chevronRight", size: 16 }), /* @__PURE__ */ React6.createElement("span", { className: "pk-fsection-title" }, title), state ? /* @__PURE__ */ React6.createElement("span", { className: "pk-fsection-state" }, state) : null), action), open ? /* @__PURE__ */ React6.createElement("div", { className: "pk-fsection-body", id: bodyId, "data-testid": `${id}-body` }, children) : null);
|
|
2142
|
+
}
|
|
2143
|
+
function Summary({ ctx, state }) {
|
|
2144
|
+
const { labels, locale, view, field } = ctx;
|
|
2145
|
+
const { shown, total, noun, unpicked, byQuick, byRules, byTotals, rows, rowsAll, span, yearsText, empty, quickWords } = state;
|
|
2146
|
+
const number = (n) => n.toLocaleString(locale);
|
|
2147
|
+
const lang = { lang: labels.lang, locale };
|
|
2148
|
+
const head = shown === 0 ? labels.summaryNone : shown === total ? fill(labels.summaryAll, { total: number(total), noun: plural(noun, total, lang) }) : fill(labels.summarySome, { shown: number(shown), total: number(total), noun: plural(noun, total, lang) });
|
|
2149
|
+
const why = [];
|
|
2150
|
+
if (shown === 0 && empty) {
|
|
2151
|
+
why.push(empty);
|
|
2152
|
+
} else {
|
|
2153
|
+
if (unpicked) {
|
|
2154
|
+
why.push(fill(labels.summaryPicks, { count: number(unpicked) }));
|
|
2155
|
+
}
|
|
2156
|
+
if (byQuick) {
|
|
2157
|
+
why.push(fill(labels.summaryQuick, { count: number(byQuick), quick: quickWords }));
|
|
2158
|
+
}
|
|
2159
|
+
if (byRules) {
|
|
2160
|
+
why.push(fill(plural(labels.summaryRules, state.itemRules, lang), { items: number(byRules) }));
|
|
2161
|
+
}
|
|
2162
|
+
if (byTotals) {
|
|
2163
|
+
why.push(fill(plural(labels.summaryTotals, state.totalRules, lang), { items: number(byTotals) }));
|
|
2164
|
+
}
|
|
2165
|
+
}
|
|
2166
|
+
const meta = [fill(labels.summaryRows, { rows: number(rows), total: number(rowsAll) })];
|
|
2167
|
+
if (span) {
|
|
2168
|
+
meta.push(fill(labels.summaryData, { range: `${dayText(isoDay(span.min), locale)} \u2013 ${dayText(isoDay(span.max), locale)}` }));
|
|
2169
|
+
}
|
|
2170
|
+
if (yearsText) {
|
|
2171
|
+
meta.push(yearsText);
|
|
2172
|
+
}
|
|
2173
|
+
return /* @__PURE__ */ React6.createElement("div", { className: "pk-filter-summary" }, /* @__PURE__ */ React6.createElement("div", { className: `pk-summary-card${shown === 0 ? " pk-summary-empty" : ""}`, role: "status", "data-testid": "filter-summary" }, /* @__PURE__ */ React6.createElement("p", { className: "pk-summary-head", "data-testid": "filter-summary-head" }, head), /* @__PURE__ */ React6.createElement("p", { className: "pk-summary-why", "data-testid": "filter-summary-why" }, why.length ? why.join(" \xB7 ") : state.rules ? labels.summaryKept : quickWords ? fill(labels.summaryQuickOnly, { quick: quickWords }) : labels.summaryOk), /* @__PURE__ */ React6.createElement("p", { className: "pk-summary-meta", "data-testid": "filter-summary-meta" }, meta.join(" \xB7 ")), /* @__PURE__ */ React6.createElement("button", { type: "button", className: "pk-action pk-summary-reset", disabled: !state.canReset, onClick: () => ctx.act(resetFilter(view, field), "section-picks"), "data-testid": "filter-reset" }, labels.resetFilter)));
|
|
2174
|
+
}
|
|
2094
2175
|
function YearsCombined({ ctx, years, on }) {
|
|
2095
2176
|
const { view, field, labels, locale, commit, note, noun } = ctx;
|
|
2096
2177
|
const all = years.map((y) => y.year);
|
|
@@ -2098,20 +2179,20 @@ function YearsCombined({ ctx, years, on }) {
|
|
|
2098
2179
|
const next = on.includes(year) ? on.filter((y) => y !== year) : [...on, year].sort((a, b) => a - b);
|
|
2099
2180
|
commit(setYearsCombined(view, field, next, all), note);
|
|
2100
2181
|
};
|
|
2101
|
-
return /* @__PURE__ */
|
|
2182
|
+
return /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement("p", { className: "pk-hint pk-years-hint" }, fill(labels.yearsCombinedHint, { noun: plural(noun, 1, { lang: labels.lang, locale }) })), /* @__PURE__ */ React6.createElement("div", { className: "pk-years", role: "group", "aria-label": labels.yearsCombined, "data-testid": "years-combined" }, years.map((y) => {
|
|
2102
2183
|
const pressed = on.includes(y.year);
|
|
2103
|
-
return /* @__PURE__ */
|
|
2104
|
-
})), on.length === 1 ? /* @__PURE__ */
|
|
2184
|
+
return /* @__PURE__ */ React6.createElement("button", { key: y.year, type: "button", className: "pk-year-chip", "aria-pressed": pressed, disabled: pressed && on.length === 1, onClick: () => toggle(y.year), "data-testid": `year-${y.year}` }, pressed ? /* @__PURE__ */ React6.createElement(Icon, { name: "check", size: 12 }) : null, /* @__PURE__ */ React6.createElement("span", null, yearText(y.year, locale)), /* @__PURE__ */ React6.createElement("span", { className: "pk-quick-rows" }, fill(labels.quickRows, { rows: y.rows.toLocaleString(locale) })));
|
|
2185
|
+
})), on.length === 1 ? /* @__PURE__ */ React6.createElement("p", { className: "pk-hint" }, fill(labels.yearsCombinedOne, { year: yearText(on[0], locale) })) : null);
|
|
2105
2186
|
}
|
|
2106
2187
|
function ItemPicker({ items, value, onChange, label, testId, labels, locale }) {
|
|
2107
|
-
const [open, setOpen] =
|
|
2108
|
-
const [query, setQuery] =
|
|
2109
|
-
const [active, setActive] =
|
|
2188
|
+
const [open, setOpen] = useState4(false);
|
|
2189
|
+
const [query, setQuery] = useState4("");
|
|
2190
|
+
const [active, setActive] = useState4(0);
|
|
2110
2191
|
const anchor = useRef2(
|
|
2111
2192
|
/** @type {HTMLButtonElement | null} */
|
|
2112
2193
|
null
|
|
2113
2194
|
);
|
|
2114
|
-
const listId =
|
|
2195
|
+
const listId = useId4();
|
|
2115
2196
|
const searchName = useFormName();
|
|
2116
2197
|
const found = searchItems(items, query);
|
|
2117
2198
|
const matching = found.slice(0, FILTER_LIST_MAX);
|
|
@@ -2142,7 +2223,7 @@ function ItemPicker({ items, value, onChange, label, testId, labels, locale }) {
|
|
|
2142
2223
|
close();
|
|
2143
2224
|
}
|
|
2144
2225
|
};
|
|
2145
|
-
return /* @__PURE__ */
|
|
2226
|
+
return /* @__PURE__ */ React6.createElement("span", { className: "pk-picker" }, /* @__PURE__ */ React6.createElement(
|
|
2146
2227
|
"button",
|
|
2147
2228
|
{
|
|
2148
2229
|
ref: anchor,
|
|
@@ -2161,7 +2242,7 @@ function ItemPicker({ items, value, onChange, label, testId, labels, locale }) {
|
|
|
2161
2242
|
"data-testid": testId
|
|
2162
2243
|
},
|
|
2163
2244
|
current ? current.label : value || labels.ruleValue
|
|
2164
|
-
), /* @__PURE__ */
|
|
2245
|
+
), /* @__PURE__ */ React6.createElement(Popover, { open, anchor, onClose: close, label, className: "pk-picker-pop" }, /* @__PURE__ */ React6.createElement(
|
|
2165
2246
|
"input",
|
|
2166
2247
|
{
|
|
2167
2248
|
type: "search",
|
|
@@ -2184,7 +2265,7 @@ function ItemPicker({ items, value, onChange, label, testId, labels, locale }) {
|
|
|
2184
2265
|
"data-autofocus": "",
|
|
2185
2266
|
"data-testid": "picker-search"
|
|
2186
2267
|
}
|
|
2187
|
-
), /* @__PURE__ */
|
|
2268
|
+
), /* @__PURE__ */ React6.createElement("ul", { role: "listbox", id: listId, className: "pk-picker-list", "aria-label": label, "data-testid": "picker-list" }, matching.map((item, i) => /* @__PURE__ */ React6.createElement(
|
|
2188
2269
|
"li",
|
|
2189
2270
|
{
|
|
2190
2271
|
key: String(item.value),
|
|
@@ -2196,9 +2277,9 @@ function ItemPicker({ items, value, onChange, label, testId, labels, locale }) {
|
|
|
2196
2277
|
onClick: () => pick2(item),
|
|
2197
2278
|
"data-testid": "picker-option"
|
|
2198
2279
|
},
|
|
2199
|
-
/* @__PURE__ */
|
|
2200
|
-
/* @__PURE__ */
|
|
2201
|
-
)), matching.length ? null : /* @__PURE__ */
|
|
2280
|
+
/* @__PURE__ */ React6.createElement("span", null, item.label),
|
|
2281
|
+
/* @__PURE__ */ React6.createElement("span", { className: "pk-count" }, item.count.toLocaleString(locale))
|
|
2282
|
+
)), matching.length ? null : /* @__PURE__ */ React6.createElement("li", { className: "pk-hint pk-picker-none" }, labels.pickerNone)), /* @__PURE__ */ React6.createElement("p", { className: "pk-hint pk-picker-count", "aria-live": "polite", "data-testid": "picker-count" }, fill(labels.pickerMatch, { count: found.length.toLocaleString(locale), total: items.length.toLocaleString(locale) }))));
|
|
2202
2283
|
}
|
|
2203
2284
|
function ItemRule({ rule, ctx, apply, unset, first }) {
|
|
2204
2285
|
const { field, labels, locale, fk, items } = ctx;
|
|
@@ -2208,7 +2289,7 @@ function ItemRule({ rule, ctx, apply, unset, first }) {
|
|
|
2208
2289
|
const textOf = (v) => v === void 0 ? "" : fk.item === "number" ? numberText(v, locale) : String(v);
|
|
2209
2290
|
const compared = rule?.type === "compare" ? rule : null;
|
|
2210
2291
|
const ranged = rule?.type === "relative" ? rule : null;
|
|
2211
|
-
const [s, setS] =
|
|
2292
|
+
const [s, setS] = useState4(() => ({
|
|
2212
2293
|
op: ranged ? "last" : compared ? ruleOp(compared) : ">=",
|
|
2213
2294
|
a: textOf(compared?.value),
|
|
2214
2295
|
b: textOf(compared?.value2),
|
|
@@ -2221,7 +2302,7 @@ function ItemRule({ rule, ctx, apply, unset, first }) {
|
|
|
2221
2302
|
const read = (text) => fk.item === "number" ? parseNumber(text, locale) : fk.item === "date" ? /^\d{4,}-\d{2}-\d{2}$/.test(text) ? text : null : text === "" ? null : Number(text);
|
|
2222
2303
|
const entryOf = (x) => {
|
|
2223
2304
|
if (x.op === "last") {
|
|
2224
|
-
const n = readNumber(x.count, { kind: "count", max:
|
|
2305
|
+
const n = readNumber(x.count, { kind: "count", max: CATALOG5.relativeMaxCount, labels, locale }).value;
|
|
2225
2306
|
return n !== null ? { ...relativeRule(field, { unit: x.unit, count: n, anchor: ranged?.anchor }), ...ranged ? { not: ranged.not, blanks: ranged.blanks } : {} } : null;
|
|
2226
2307
|
}
|
|
2227
2308
|
const [a, b] = [read(x.a), read(x.b)];
|
|
@@ -2258,23 +2339,23 @@ function ItemRule({ rule, ctx, apply, unset, first }) {
|
|
|
2258
2339
|
const value = (key, label2, testId) => {
|
|
2259
2340
|
if (fk.item === "number") {
|
|
2260
2341
|
const problem = readNumber(s[key], { required: false, labels, locale }).problem;
|
|
2261
|
-
return /* @__PURE__ */
|
|
2342
|
+
return /* @__PURE__ */ React6.createElement(NumberField, { value: s[key], onChange: (t) => change({ [key]: t }, true), onKeyDown: keys, onBlur: later.now, problem, label: label2, testId, className: "pk-field-label pk-narrow-input" });
|
|
2262
2343
|
}
|
|
2263
2344
|
if (fk.item === "date") {
|
|
2264
|
-
return /* @__PURE__ */
|
|
2345
|
+
return /* @__PURE__ */ React6.createElement("input", { type: "date", name: `${formName}-${key}`, value: s[key], onChange: (e) => change({ [key]: e.target.value }), "aria-label": label2, "data-testid": testId });
|
|
2265
2346
|
}
|
|
2266
2347
|
const listed = items.filter((i) => typeof i.value === "number");
|
|
2267
2348
|
const own = s[key] !== "" && !listed.some((i) => String(i.value) === s[key]);
|
|
2268
2349
|
if (listed.length >= PICKER_MIN && !narrow) {
|
|
2269
|
-
return /* @__PURE__ */
|
|
2350
|
+
return /* @__PURE__ */ React6.createElement(ItemPicker, { items: own ? [{ value: Number(s[key]), label: s[key], count: 0 }, ...listed] : listed, value: s[key], onChange: (v) => change({ [key]: v }), label: label2, testId, labels, locale });
|
|
2270
2351
|
}
|
|
2271
|
-
return /* @__PURE__ */
|
|
2352
|
+
return /* @__PURE__ */ React6.createElement("select", { name: `${formName}-${key}`, value: s[key], onChange: (e) => change({ [key]: e.target.value }), "aria-label": label2, "data-testid": testId }, /* @__PURE__ */ React6.createElement("option", { value: "", disabled: true }, labels.ruleValue), own ? /* @__PURE__ */ React6.createElement("option", { value: s[key] }, s[key]) : null, listed.map((i) => /* @__PURE__ */ React6.createElement("option", { key: String(i.value), value: String(i.value) }, i.label)));
|
|
2272
2353
|
};
|
|
2273
2354
|
const label = fk.item === "date" ? labels.ruleDate : labels.ruleValue;
|
|
2274
2355
|
const lang = { lang: labels.lang, locale };
|
|
2275
|
-
const counted = readNumber(s.count, { kind: "count", max:
|
|
2356
|
+
const counted = readNumber(s.count, { kind: "count", max: CATALOG5.relativeMaxCount, labels, locale });
|
|
2276
2357
|
const many = counted.value ?? 2;
|
|
2277
|
-
return /* @__PURE__ */
|
|
2358
|
+
return /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement("span", { className: "pk-rule-subject" }, fieldLabel4(field, labels.core)), /* @__PURE__ */ React6.createElement("select", { className: "pk-rule-op", name: `${formName}-op`, value: s.op, onChange: (e) => change({ op: e.target.value }), "aria-label": labels.valueFilterOp, "data-autofocus": first ? "" : void 0, "data-testid": "rule-item-op" }, ops.map((o) => /* @__PURE__ */ React6.createElement("option", { key: o, value: o }, o === "last" ? plural(labels.lastOp, many, lang) : words[o] ?? o))), s.op === "last" ? /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement(
|
|
2278
2359
|
NumberField,
|
|
2279
2360
|
{
|
|
2280
2361
|
value: s.count,
|
|
@@ -2286,12 +2367,12 @@ function ItemRule({ rule, ctx, apply, unset, first }) {
|
|
|
2286
2367
|
testId: "rule-last-count",
|
|
2287
2368
|
className: "pk-field-label pk-count-input"
|
|
2288
2369
|
}
|
|
2289
|
-
), /* @__PURE__ */
|
|
2370
|
+
), /* @__PURE__ */ React6.createElement("select", { name: `${formName}-unit`, value: s.unit, onChange: (e) => change({ unit: e.target.value }), "aria-label": labels.ruleUnit, "data-testid": "rule-last-unit" }, RANGE_UNITS.map((u) => /* @__PURE__ */ React6.createElement("option", { key: u, value: u }, plural(labels.ruleUnits[u], many, lang))))) : /* @__PURE__ */ React6.createElement(React6.Fragment, null, value("a", label, "rule-item-value"), twin(s.op) ? /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement("span", null, labels.valueFilterTo), value("b", `${labels.valueFilterTo} ${label}`, "rule-item-value2")) : null, (s.op === "!=" || s.op === "notBetween") && (compared?.blanks ?? (ctx.keepBlanks ? "include" : "exclude")) === "exclude" ? /* @__PURE__ */ React6.createElement("span", { className: "pk-hint pk-rule-note", "data-testid": "rule-blanks" }, labels.blanksOut) : null));
|
|
2290
2371
|
}
|
|
2291
2372
|
function TotalRule({ rule, ctx, apply, unset, first }) {
|
|
2292
2373
|
const { view, types, labels, locale } = ctx;
|
|
2293
2374
|
const { choices, names } = measuresOf(view, types, labels, rule?.by);
|
|
2294
|
-
const [s, setS] =
|
|
2375
|
+
const [s, setS] = useState4(() => ({ by: choiceIndex(choices, rule?.by), op: rule ? ruleOp(rule) : ">", a: numberText(rule?.value, locale), b: numberText(rule?.value2, locale) }));
|
|
2295
2376
|
const later = useLater();
|
|
2296
2377
|
const latest = useLatest({ rule, apply, unset });
|
|
2297
2378
|
const formName = useFormName();
|
|
@@ -2324,12 +2405,12 @@ function TotalRule({ rule, ctx, apply, unset, first }) {
|
|
|
2324
2405
|
return true;
|
|
2325
2406
|
};
|
|
2326
2407
|
const keys = fieldKeys({ now: later.now, restore, back: ctx.back });
|
|
2327
|
-
const number = (key, label, testId, shown) => /* @__PURE__ */
|
|
2328
|
-
return /* @__PURE__ */
|
|
2408
|
+
const number = (key, label, testId, shown) => /* @__PURE__ */ React6.createElement(NumberField, { value: s[key], onChange: (t) => change({ [key]: t }, true), onKeyDown: keys, onBlur: later.now, problem: readNumber(s[key], { required: false, labels, locale }).problem, label, shown, testId, className: "pk-field-label pk-narrow-input" });
|
|
2409
|
+
return /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement("span", { className: "pk-rule-subject pk-rule-lead" }, fill(labels.ruleWhose, { field: fieldLabel4(ctx.field, labels.core) })), /* @__PURE__ */ React6.createElement(MeasurePick, { choices, names, index: s.by, onChange: (i) => change({ by: i }), label: labels.valueFilterBy, testId: "value-filter-by" }), /* @__PURE__ */ React6.createElement("select", { className: "pk-rule-op", name: `${formName}-op`, value: s.op, onChange: (e) => change({ op: e.target.value }), "aria-label": labels.valueFilterOp, "data-autofocus": first ? "" : void 0, "data-testid": "value-filter-op" }, RULE_OPS.compare.map((o) => /* @__PURE__ */ React6.createElement("option", { key: o, value: o }, labels.valueOps[o] ?? o))), number("a", labels.valueFilterNumber, "value-filter-number"), twin(s.op) ? number("b", `${labels.valueFilterTo} ${labels.valueFilterNumber}`, "value-filter-number2", labels.valueFilterTo) : null);
|
|
2329
2410
|
}
|
|
2330
2411
|
function NameRule({ rule, ctx, apply, unset, first }) {
|
|
2331
2412
|
const { field, labels } = ctx;
|
|
2332
|
-
const [op, setOp] =
|
|
2413
|
+
const [op, setOp] = useState4(rule ? ruleOp(rule) : "contains");
|
|
2333
2414
|
const send = (o, value) => {
|
|
2334
2415
|
if (value.trim() !== "") {
|
|
2335
2416
|
apply({ ...textRule(field, { op: o, value, on: ctx.textOn }), ...rule ? { blanks: rule.blanks } : {} });
|
|
@@ -2339,7 +2420,7 @@ function NameRule({ rule, ctx, apply, unset, first }) {
|
|
|
2339
2420
|
};
|
|
2340
2421
|
const text = useAppliedText(rule?.value ?? "", (value) => send(op, value));
|
|
2341
2422
|
const opName = useFormName();
|
|
2342
|
-
return /* @__PURE__ */
|
|
2423
|
+
return /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement("span", { className: "pk-rule-subject" }, labels.ruleName), /* @__PURE__ */ React6.createElement(
|
|
2343
2424
|
"select",
|
|
2344
2425
|
{
|
|
2345
2426
|
className: "pk-rule-op",
|
|
@@ -2353,8 +2434,8 @@ function NameRule({ rule, ctx, apply, unset, first }) {
|
|
|
2353
2434
|
"data-autofocus": first ? "" : void 0,
|
|
2354
2435
|
"data-testid": "filter-condition-op"
|
|
2355
2436
|
},
|
|
2356
|
-
RULE_OPS.text.map((o) => /* @__PURE__ */
|
|
2357
|
-
), /* @__PURE__ */
|
|
2437
|
+
RULE_OPS.text.map((o) => /* @__PURE__ */ React6.createElement("option", { key: o, value: o }, labels.labelOps[o] ?? o))
|
|
2438
|
+
), /* @__PURE__ */ React6.createElement(
|
|
2358
2439
|
ClearInput,
|
|
2359
2440
|
{
|
|
2360
2441
|
type: "text",
|
|
@@ -2372,31 +2453,31 @@ function NameRule({ rule, ctx, apply, unset, first }) {
|
|
|
2372
2453
|
));
|
|
2373
2454
|
}
|
|
2374
2455
|
function FixedRule({ rule, ctx }) {
|
|
2375
|
-
return /* @__PURE__ */
|
|
2456
|
+
return /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement("span", { className: "pk-rule-subject" }, ctx.say(rule)), /* @__PURE__ */ React6.createElement("span", { className: "pk-hint pk-rule-note", "data-testid": "rule-fixed" }, ctx.labels.ruleFixed));
|
|
2376
2457
|
}
|
|
2377
2458
|
var ROWS = { item: ItemRule, total: TotalRule, name: NameRule, fixed: FixedRule };
|
|
2378
2459
|
function RuleEditor({ ctx, rules, focusFirst, quickLine, results, blanks }) {
|
|
2379
2460
|
const { view, field, labels, locale, commit, note, fk, nameKind, noun } = ctx;
|
|
2380
2461
|
const { explain } = useContext3(HelpContext);
|
|
2381
2462
|
const lang = { lang: labels.lang, locale };
|
|
2382
|
-
const [draft, setDraft] =
|
|
2463
|
+
const [draft, setDraft] = useState4(
|
|
2383
2464
|
/** @type {"item" | "total" | "name" | null} */
|
|
2384
2465
|
null
|
|
2385
2466
|
);
|
|
2386
|
-
const [added, setAdded] =
|
|
2387
|
-
const [held, setHeld] =
|
|
2467
|
+
const [added, setAdded] = useState4(0);
|
|
2468
|
+
const [held, setHeld] = useState4(
|
|
2388
2469
|
/** @type {Array<{ at: number, kind: "item" | "total" | "name", blanks?: string }>} */
|
|
2389
2470
|
[]
|
|
2390
2471
|
);
|
|
2391
2472
|
const blanksName = useFormName();
|
|
2392
|
-
const [info, setInfo] =
|
|
2473
|
+
const [info, setInfo] = useState4(
|
|
2393
2474
|
/** @type {number | null} */
|
|
2394
2475
|
null
|
|
2395
2476
|
);
|
|
2396
|
-
const [gen, setGen] =
|
|
2477
|
+
const [gen, setGen] = useState4(0);
|
|
2397
2478
|
const rulesKey = rulesKeyOf(rules);
|
|
2398
|
-
const [seen, setSeen] =
|
|
2399
|
-
const [own, setOwn] =
|
|
2479
|
+
const [seen, setSeen] = useState4(rulesKey);
|
|
2480
|
+
const [own, setOwn] = useState4(
|
|
2400
2481
|
/** @type {string | null} */
|
|
2401
2482
|
null
|
|
2402
2483
|
);
|
|
@@ -2457,7 +2538,7 @@ function RuleEditor({ ctx, rules, focusFirst, quickLine, results, blanks }) {
|
|
|
2457
2538
|
);
|
|
2458
2539
|
const count = rules.length + (draft ? 1 : 0) + held.length;
|
|
2459
2540
|
const full = count >= RULES_MAX || view.filters.length >= LIMITS2.filters;
|
|
2460
|
-
const addText = { item: fill(labels.addRuleItem, { field:
|
|
2541
|
+
const addText = { item: fill(labels.addRuleItem, { field: fieldLabel4(field, labels.core) }), total: labels.addRuleTotal, name: labels.addRuleName };
|
|
2461
2542
|
const infoText = (rule, kind) => {
|
|
2462
2543
|
const one = plural(noun, 1, lang);
|
|
2463
2544
|
if (kind === "total") {
|
|
@@ -2520,7 +2601,7 @@ function RuleEditor({ ctx, rules, focusFirst, quickLine, results, blanks }) {
|
|
|
2520
2601
|
const result = rule ? results.get(rule) : null;
|
|
2521
2602
|
const open = info === i;
|
|
2522
2603
|
const infoId = `${gen}-${i}`;
|
|
2523
|
-
return /* @__PURE__ */
|
|
2604
|
+
return /* @__PURE__ */ React6.createElement("li", { key, className: "pk-rule", "data-testid": "rule", "data-kind": kind }, i > 0 || quickLine ? /* @__PURE__ */ React6.createElement("span", { className: "pk-rule-and" }, labels.ruleAnd) : null, /* @__PURE__ */ React6.createElement("span", { className: "pk-rule-body" }, /* @__PURE__ */ React6.createElement(Row, { rule, ctx, apply, unset, first: focusFirst && i === 0 || !rule && !isHeld && draft !== null })), /* @__PURE__ */ React6.createElement("span", { className: "pk-rule-tools" }, explain ? /* @__PURE__ */ React6.createElement("button", { type: "button", className: "pk-icon-btn pk-rule-info", "aria-expanded": open, "aria-controls": open ? infoId : void 0, onClick: () => setInfo(open ? null : i), "aria-label": labels.explainRule, title: labels.explainRule, "data-testid": "rule-info" }, /* @__PURE__ */ React6.createElement(Icon, { name: "info", size: 14 })) : null, /* @__PURE__ */ React6.createElement("button", { type: "button", className: "pk-icon-btn pk-rule-remove", onMouseDown: (e) => e.preventDefault(), onClick: remove, "aria-label": labels.removeRule, title: labels.removeRule, "data-testid": "rule-remove" }, /* @__PURE__ */ React6.createElement(Icon, { name: "x", size: 14 }))), /* @__PURE__ */ React6.createElement("p", { className: `pk-hint pk-rule-result${result && result.kept === 0 ? " pk-rule-result-empty" : ""}`, "data-testid": "rule-result" }, result ? result.text : labels.ruleIncomplete), open ? /* @__PURE__ */ React6.createElement("p", { className: "pk-rule-info-text", id: infoId, "data-testid": "rule-info-text" }, infoText(rule, kind)) : null);
|
|
2524
2605
|
};
|
|
2525
2606
|
const rows = rules.map((r) => ({ rule: r, kind: rowKind(r), isHeld: false }));
|
|
2526
2607
|
for (const h of held) {
|
|
@@ -2536,7 +2617,7 @@ function RuleEditor({ ctx, rules, focusFirst, quickLine, results, blanks }) {
|
|
|
2536
2617
|
}
|
|
2537
2618
|
}
|
|
2538
2619
|
});
|
|
2539
|
-
return /* @__PURE__ */
|
|
2620
|
+
return /* @__PURE__ */ React6.createElement("fieldset", { ref: box, className: "pk-condition pk-rules", "data-testid": "rules" }, /* @__PURE__ */ React6.createElement("legend", { className: "pk-sr" }, labels.rulesTitle), /* @__PURE__ */ React6.createElement("p", { className: "pk-hint" }, fill(count || quickLine ? labels.rulesKeep : labels.rulesNone, { noun: plural(noun, 2, lang) })), count || quickLine ? /* @__PURE__ */ React6.createElement("ul", { className: "pk-rule-list", role: "list" }, quickLine ? /* @__PURE__ */ React6.createElement("li", { className: "pk-rule pk-rule-quick", "data-testid": "rule-quick" }, /* @__PURE__ */ React6.createElement("span", null, fill(labels.quickLine, { text: quickLine })), /* @__PURE__ */ React6.createElement("button", { type: "button", className: "pk-action", onClick: ctx.focusQuick, "data-testid": "rule-quick-change" }, labels.changeAbove)) : null, rows.map((x, i) => row(x.rule, x.kind, i, x.isHeld))) : null, blanks ? /* @__PURE__ */ React6.createElement("label", { className: "pk-check pk-rules-blanks" }, /* @__PURE__ */ React6.createElement("input", { type: "checkbox", name: `${blanksName}`, checked: blanks.on, onChange: (e) => commit(setRuleBlanks(view, field, e.target.checked), note), "data-testid": "rules-blanks" }), /* @__PURE__ */ React6.createElement("span", null, fill(plural(labels.rulesBlanks, blanks.rows, lang), { rows: blanks.rows.toLocaleString(locale) }))) : null, /* @__PURE__ */ React6.createElement("div", { className: "pk-rule-adds", role: "group", "aria-label": labels.addRule }, kinds.map((k, i) => /* @__PURE__ */ React6.createElement(
|
|
2540
2621
|
"button",
|
|
2541
2622
|
{
|
|
2542
2623
|
key: k,
|
|
@@ -2548,13 +2629,13 @@ function RuleEditor({ ctx, rules, focusFirst, quickLine, results, blanks }) {
|
|
|
2548
2629
|
"data-autofocus": focusFirst && !count && i === 0 ? "" : void 0,
|
|
2549
2630
|
"data-testid": `rule-add-${k}`
|
|
2550
2631
|
},
|
|
2551
|
-
/* @__PURE__ */
|
|
2552
|
-
/* @__PURE__ */
|
|
2553
|
-
))), full ? /* @__PURE__ */
|
|
2632
|
+
/* @__PURE__ */ React6.createElement(Icon, { name: "plus", size: 14 }),
|
|
2633
|
+
/* @__PURE__ */ React6.createElement("span", { className: "pk-btn-text" }, addText[k])
|
|
2634
|
+
))), full ? /* @__PURE__ */ React6.createElement("p", { className: "pk-hint" }, fill(labels.rulesFull, { max: RULES_MAX })) : null);
|
|
2554
2635
|
}
|
|
2555
2636
|
var without = (view, field, types) => view.filters.filter((f) => !(typeof f.field === "string" && f.field.toLowerCase() === field.toLowerCase() && types.includes(f.type)));
|
|
2556
2637
|
function FilterLevel({ view, field, encoded, types, labels, locale, commit, back, hint }) {
|
|
2557
|
-
const info = useMemo2(() =>
|
|
2638
|
+
const info = useMemo2(() => fieldItems3(encoded, field, { view, locale, labels: labels.core }), [encoded, field, view, locale, labels]);
|
|
2558
2639
|
const narrow = useContext3(LayerContext).size === "narrow";
|
|
2559
2640
|
const fk = useMemo2(() => ruleKind(encoded, view, field), [encoded, view, field]);
|
|
2560
2641
|
const source = sourceOf(view, field);
|
|
@@ -2563,18 +2644,18 @@ function FilterLevel({ view, field, encoded, types, labels, locale, commit, back
|
|
|
2563
2644
|
const counts = useMemo2(() => column ? countsOf(column) : null, [column]);
|
|
2564
2645
|
const years = useMemo2(() => fk.cyclic && column && counts ? yearsOf(column, counts) : [], [fk.cyclic, column, counts]);
|
|
2565
2646
|
const quick = quickChoice(view, field, fk, years.map((y) => y.year));
|
|
2566
|
-
const [anchorLocal, setAnchorLocal] =
|
|
2647
|
+
const [anchorLocal, setAnchorLocal] = useState4(
|
|
2567
2648
|
/** @type {string | null} */
|
|
2568
2649
|
null
|
|
2569
2650
|
);
|
|
2570
2651
|
const anchor = quick.anchor ?? anchorLocal ?? "today";
|
|
2571
|
-
const [moreOpen, setMoreOpen] =
|
|
2572
|
-
const [openQuick, setOpenQuick] =
|
|
2573
|
-
const [openPicks, setOpenPicks] =
|
|
2652
|
+
const [moreOpen, setMoreOpen] = useState4(() => inMore(quick));
|
|
2653
|
+
const [openQuick, setOpenQuick] = useState4(true);
|
|
2654
|
+
const [openPicks, setOpenPicks] = useState4(
|
|
2574
2655
|
/** @type {boolean | null} */
|
|
2575
2656
|
null
|
|
2576
2657
|
);
|
|
2577
|
-
const [openRules, setOpenRules] =
|
|
2658
|
+
const [openRules, setOpenRules] = useState4(
|
|
2578
2659
|
/** @type {boolean | null} */
|
|
2579
2660
|
hint === "conditions" ? true : null
|
|
2580
2661
|
);
|
|
@@ -2614,7 +2695,7 @@ function FilterLevel({ view, field, encoded, types, labels, locale, commit, back
|
|
|
2614
2695
|
setTimeout(refocus, 100);
|
|
2615
2696
|
}
|
|
2616
2697
|
}, [anyRule]);
|
|
2617
|
-
const [goQuick, setGoQuick] =
|
|
2698
|
+
const [goQuick, setGoQuick] = useState4(0);
|
|
2618
2699
|
useEffect2(() => {
|
|
2619
2700
|
if (goQuick) {
|
|
2620
2701
|
const target = (
|
|
@@ -2647,11 +2728,11 @@ function FilterLevel({ view, field, encoded, types, labels, locale, commit, back
|
|
|
2647
2728
|
const itemResults = useMemo2(() => {
|
|
2648
2729
|
const out = /* @__PURE__ */ new Map();
|
|
2649
2730
|
for (const r of itemRules) {
|
|
2650
|
-
const kept2 =
|
|
2731
|
+
const kept2 = fieldItems3(encoded, field, { view: { ...view, filters: [r] }, locale, labels: labels.core });
|
|
2651
2732
|
out.set(r, kept2 ? kept2.items.filter((i) => i.kept).length : 0);
|
|
2652
2733
|
}
|
|
2653
2734
|
if (quick.filters.length && itemRules.length) {
|
|
2654
|
-
const kept2 =
|
|
2735
|
+
const kept2 = fieldItems3(encoded, field, { view: { ...view, filters: quick.filters }, locale, labels: labels.core });
|
|
2655
2736
|
out.set("quick", new Set(kept2 ? kept2.items.filter((i) => !i.kept).map((i) => keyOf(i.value)) : []));
|
|
2656
2737
|
}
|
|
2657
2738
|
return out;
|
|
@@ -2659,7 +2740,7 @@ function FilterLevel({ view, field, encoded, types, labels, locale, commit, back
|
|
|
2659
2740
|
if (!info || !totals) {
|
|
2660
2741
|
return null;
|
|
2661
2742
|
}
|
|
2662
|
-
const name =
|
|
2743
|
+
const name = fieldLabel4(field, labels.core);
|
|
2663
2744
|
const note = { step: "filter", field: name };
|
|
2664
2745
|
const all = info.items.map((i) => i.value);
|
|
2665
2746
|
const picked = selectedItems(view, field, all);
|
|
@@ -2724,7 +2805,7 @@ function FilterLevel({ view, field, encoded, types, labels, locale, commit, back
|
|
|
2724
2805
|
}
|
|
2725
2806
|
}
|
|
2726
2807
|
const others = [...view.rows, ...view.cols].filter((f) => f.toLowerCase() !== field.toLowerCase());
|
|
2727
|
-
const scopeParts = others.map((f) => fill(labels.scopeItems, { count: number(
|
|
2808
|
+
const scopeParts = others.map((f) => fill(labels.scopeItems, { count: number(fieldItems3(encoded, f, { view, locale, labels: labels.core })?.items.length ?? 0), field: fieldLabel4(f, labels.core) }));
|
|
2728
2809
|
if (span) {
|
|
2729
2810
|
scopeParts.push(fill(labels.scopeDates, { range: `${dayText(isoDay(span.min), locale)} \u2013 ${dayText(isoDay(span.max), locale)}` }));
|
|
2730
2811
|
}
|
|
@@ -2779,8 +2860,8 @@ function FilterLevel({ view, field, encoded, types, labels, locale, commit, back
|
|
|
2779
2860
|
};
|
|
2780
2861
|
const summary = { shown, total: all.length, noun, unpicked, byQuick, byRules, byTotals, itemRules: itemRules.length, totalRules: totalRules.length, rows: totals.rows, rowsAll: encoded.length, span, yearsText, empty, quickWords, rules: rules.length, canReset: unpicked > 0 || anyRule };
|
|
2781
2862
|
const outOf = (i) => i.kept === false;
|
|
2782
|
-
const quickSection = fk.quick && span && column && counts ? { id: "quick", title: labels.quickTitle, body: /* @__PURE__ */
|
|
2783
|
-
return /* @__PURE__ */
|
|
2863
|
+
const quickSection = fk.quick && span && column && counts ? { id: "quick", title: labels.quickTitle, body: /* @__PURE__ */ React6.createElement(QuickChoices, { ctx, quick, anchor, setAnchorLocal, span, column, counts, moreOpen, setMoreOpen }) } : fk.cyclic && years.length > 1 && years.length <= 12 ? { id: "years", title: labels.yearsCombined, body: /* @__PURE__ */ React6.createElement(YearsCombined, { ctx, years, on: yearsOn }) } : null;
|
|
2864
|
+
return /* @__PURE__ */ React6.createElement("div", { ref: box, className: "pk-filter pk-filter-level" }, /* @__PURE__ */ React6.createElement(Summary, { ctx, state: summary }), quickSection ? /* @__PURE__ */ React6.createElement(Section2, { id: quickSection.id, title: quickSection.title, state: quickWords && !openQuick ? quickWords : null, open: openQuick, onToggle: () => setOpenQuick(!openQuick) }, quickSection.body) : null, /* @__PURE__ */ React6.createElement(
|
|
2784
2865
|
Section2,
|
|
2785
2866
|
{
|
|
2786
2867
|
id: "picks",
|
|
@@ -2788,9 +2869,9 @@ function FilterLevel({ view, field, encoded, types, labels, locale, commit, back
|
|
|
2788
2869
|
state: unpicked ? fill(labels.picksState, { picked: number(picked.length), total: number(all.length) }) : fill(labels.picksAll, { total: number(all.length) }),
|
|
2789
2870
|
open: picksOpen,
|
|
2790
2871
|
onToggle: togglePicks,
|
|
2791
|
-
action: /* @__PURE__ */
|
|
2872
|
+
action: /* @__PURE__ */ React6.createElement("button", { type: "button", className: "pk-action", disabled: !unpicked, "aria-label": labels.clearPicks, onClick: () => act(setItemFilter(view, field, all, all), "section-picks"), "data-testid": "filter-clear-picks" }, labels.clear)
|
|
2792
2873
|
},
|
|
2793
|
-
/* @__PURE__ */
|
|
2874
|
+
/* @__PURE__ */ React6.createElement(
|
|
2794
2875
|
ValueList,
|
|
2795
2876
|
{
|
|
2796
2877
|
items: info.items,
|
|
@@ -2799,20 +2880,20 @@ function FilterLevel({ view, field, encoded, types, labels, locale, commit, back
|
|
|
2799
2880
|
labels,
|
|
2800
2881
|
locale,
|
|
2801
2882
|
autoFocus: !anyRule && !fk.quick && hint !== "conditions",
|
|
2802
|
-
tail: anyRule ? { isOut: outOf, render: (out, row, searching) => /* @__PURE__ */
|
|
2883
|
+
tail: anyRule ? { isOut: outOf, render: (out, row, searching) => /* @__PURE__ */ React6.createElement(LeftOut, { out, row, searching, labels, locale }) } : void 0
|
|
2803
2884
|
}
|
|
2804
2885
|
)
|
|
2805
|
-
), /* @__PURE__ */
|
|
2886
|
+
), /* @__PURE__ */ React6.createElement(
|
|
2806
2887
|
Section2,
|
|
2807
2888
|
{
|
|
2808
2889
|
id: "rules",
|
|
2809
2890
|
title: labels.rulesTitle,
|
|
2810
|
-
state: rules.length ? /* @__PURE__ */
|
|
2891
|
+
state: rules.length ? /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement("span", { className: "pk-section-mark" }, "\u25CF"), " ", fill(plural(labels.rulesState, rules.length, lang), { count: number(rules.length) })) : labels.rulesNoneState,
|
|
2811
2892
|
open: rulesOpen,
|
|
2812
2893
|
onToggle: toggleRules,
|
|
2813
|
-
action: /* @__PURE__ */
|
|
2894
|
+
action: /* @__PURE__ */ React6.createElement("button", { type: "button", className: "pk-action", disabled: !rules.length, "aria-label": labels.removeRules, onClick: () => act(removeRules(view, field, quick.filters), "section-rules"), "data-testid": "filter-remove-rules" }, labels.removeAll)
|
|
2814
2895
|
},
|
|
2815
|
-
/* @__PURE__ */
|
|
2896
|
+
/* @__PURE__ */ React6.createElement(RuleEditor, { ctx, rules, focusFirst: hint === "conditions", quickLine: quickWords, results, blanks })
|
|
2816
2897
|
));
|
|
2817
2898
|
}
|
|
2818
2899
|
|
|
@@ -2822,14 +2903,14 @@ function TopLevel({ view, field, types, labels, locale, commit, back, encoded })
|
|
|
2822
2903
|
const axis = view.rows[0]?.toLowerCase() === field.toLowerCase() ? "rowRoot" : view.cols[0]?.toLowerCase() === field.toLowerCase() ? "colRoot" : null;
|
|
2823
2904
|
const shown = useMemo3(() => top && axis && encoded ? computePivot2(encoded, view)[axis].children.length : null, [top, axis, encoded, view]);
|
|
2824
2905
|
const { choices, names } = measuresOf(view, types, labels, top?.by);
|
|
2825
|
-
const [by, setBy] =
|
|
2906
|
+
const [by, setBy] = useState5(() => choiceIndex(choices, top?.by));
|
|
2826
2907
|
const quick = top && !top.bottom && TOP_COUNTS.includes(top.count) ? top.count : null;
|
|
2827
|
-
const [own, setOwn] =
|
|
2828
|
-
const [bottom, setBottom] =
|
|
2829
|
-
const [count, setCount] =
|
|
2908
|
+
const [own, setOwn] = useState5(Boolean(top) && quick === null);
|
|
2909
|
+
const [bottom, setBottom] = useState5(Boolean(top?.bottom));
|
|
2910
|
+
const [count, setCount] = useState5(numberText(top?.count ?? 10, locale));
|
|
2830
2911
|
const later = useLater();
|
|
2831
2912
|
const counted = readNumber(count, { kind: "count", labels, locale });
|
|
2832
|
-
const name =
|
|
2913
|
+
const name = fieldLabel5(field, labels.core);
|
|
2833
2914
|
const set = (t) => commit(setTopFilter(view, field, t, top), { step: "top", field: name });
|
|
2834
2915
|
const applyOwn = (next) => {
|
|
2835
2916
|
const s = { bottom, count, by, ...next };
|
|
@@ -2840,17 +2921,17 @@ function TopLevel({ view, field, types, labels, locale, commit, back, encoded })
|
|
|
2840
2921
|
};
|
|
2841
2922
|
const groupName = useFormName();
|
|
2842
2923
|
const tiesName = useFormName();
|
|
2843
|
-
const radio = (id, text, checked, onPick) => /* @__PURE__ */
|
|
2844
|
-
return /* @__PURE__ */
|
|
2924
|
+
const radio = (id, text, checked, onPick) => /* @__PURE__ */ React7.createElement("label", { className: "pk-radio" }, /* @__PURE__ */ React7.createElement(Radio, { name: groupName, checked, onChange: onPick, "data-autofocus": checked ? "" : void 0, "data-testid": `top-${id}` }), /* @__PURE__ */ React7.createElement("span", null, text));
|
|
2925
|
+
return /* @__PURE__ */ React7.createElement("div", { className: "pk-level-form" }, /* @__PURE__ */ React7.createElement("div", { role: "radiogroup", "aria-label": labels.topN, className: "pk-radios" }, radio("off", labels.off, !top && !own, () => {
|
|
2845
2926
|
setOwn(false);
|
|
2846
2927
|
set(null);
|
|
2847
|
-
}), TOP_COUNTS.map((n) => /* @__PURE__ */
|
|
2928
|
+
}), TOP_COUNTS.map((n) => /* @__PURE__ */ React7.createElement(React7.Fragment, { key: n }, radio(String(n), fill(labels.topBadge, { count: n.toLocaleString(locale) }), !own && quick === n, () => {
|
|
2848
2929
|
setOwn(false);
|
|
2849
2930
|
set({ count: n, bottom: false, by: choices[by] });
|
|
2850
2931
|
}))), radio("own", labels.topOwn, own, () => {
|
|
2851
2932
|
setOwn(true);
|
|
2852
2933
|
applyOwn({});
|
|
2853
|
-
})), own ? /* @__PURE__ */
|
|
2934
|
+
})), own ? /* @__PURE__ */ React7.createElement("div", { className: "pk-inline-form" }, /* @__PURE__ */ React7.createElement("div", { className: "pk-segmented pk-small", role: "group", "aria-label": labels.topN }, [false, true].map((b) => /* @__PURE__ */ React7.createElement(
|
|
2854
2935
|
"button",
|
|
2855
2936
|
{
|
|
2856
2937
|
key: String(b),
|
|
@@ -2863,7 +2944,7 @@ function TopLevel({ view, field, types, labels, locale, commit, back, encoded })
|
|
|
2863
2944
|
"data-testid": b ? "top-bottom" : "top-top"
|
|
2864
2945
|
},
|
|
2865
2946
|
b ? labels.bottom : labels.top
|
|
2866
|
-
))), /* @__PURE__ */
|
|
2947
|
+
))), /* @__PURE__ */ React7.createElement(
|
|
2867
2948
|
NumberField,
|
|
2868
2949
|
{
|
|
2869
2950
|
value: count,
|
|
@@ -2890,12 +2971,12 @@ function TopLevel({ view, field, types, labels, locale, commit, back, encoded })
|
|
|
2890
2971
|
testId: "top-count",
|
|
2891
2972
|
className: "pk-field-label pk-narrow-input"
|
|
2892
2973
|
}
|
|
2893
|
-
)) : null, /* @__PURE__ */
|
|
2974
|
+
)) : null, /* @__PURE__ */ React7.createElement("div", { className: "pk-inline-form" }, /* @__PURE__ */ React7.createElement(MeasurePick, { choices, names, index: by, onChange: (i) => {
|
|
2894
2975
|
setBy(i);
|
|
2895
2976
|
if (top) {
|
|
2896
2977
|
set({ count: top.count, bottom: Boolean(top.bottom), by: choices[i] });
|
|
2897
2978
|
}
|
|
2898
|
-
}, label: labels.topBy, prefix: labels.topBy, testId: "top-by" })), top ? /* @__PURE__ */
|
|
2979
|
+
}, label: labels.topBy, prefix: labels.topBy, testId: "top-by" })), top ? /* @__PURE__ */ React7.createElement("label", { className: "pk-check" }, /* @__PURE__ */ React7.createElement(
|
|
2899
2980
|
"input",
|
|
2900
2981
|
{
|
|
2901
2982
|
type: "checkbox",
|
|
@@ -2904,22 +2985,22 @@ function TopLevel({ view, field, types, labels, locale, commit, back, encoded })
|
|
|
2904
2985
|
onChange: (e) => set({ count: top.count, bottom: Boolean(top.bottom), by: top.by ?? choices[by], ties: e.target.checked ? "all" : "first" }),
|
|
2905
2986
|
"data-testid": "top-ties"
|
|
2906
2987
|
}
|
|
2907
|
-
), /* @__PURE__ */
|
|
2988
|
+
), /* @__PURE__ */ React7.createElement("span", null, labels.topTies)) : null, top && (shown !== null || top.ties === "all") ? /* @__PURE__ */ React7.createElement("p", { className: "pk-hint pk-top-shown", "data-testid": "top-shown" }, shown !== null ? fill(plural(labels.topShown, shown, { lang: labels.lang, locale }), { count: shown.toLocaleString(locale) }) : fill(labels.topTiesGroups, { count: top.count.toLocaleString(locale) })) : null);
|
|
2908
2989
|
}
|
|
2909
2990
|
function BinsLevel({ view, field, labels, locale, range, regroup, back }) {
|
|
2910
2991
|
const grouping = groupingOf(view, field);
|
|
2911
2992
|
const bins = grouping?.by === "bin" ? grouping : null;
|
|
2912
|
-
const [size, setSize] =
|
|
2913
|
-
const [start, setStart] =
|
|
2914
|
-
const [tried, setTried] =
|
|
2915
|
-
const problemId =
|
|
2993
|
+
const [size, setSize] = useState5(numberText(bins?.size, locale));
|
|
2994
|
+
const [start, setStart] = useState5(numberText(bins?.origin, locale));
|
|
2995
|
+
const [tried, setTried] = useState5(false);
|
|
2996
|
+
const problemId = useId5();
|
|
2916
2997
|
const sized = readNumber(size, { kind: "size", tried, labels, locale });
|
|
2917
2998
|
const started = readNumber(start, { required: false, labels, locale });
|
|
2918
2999
|
const n = sized.value;
|
|
2919
3000
|
const s = start.trim() === "" ? 0 : started.value;
|
|
2920
3001
|
const far = n !== null && s !== null && binProblem(n, s, range) === "far";
|
|
2921
3002
|
const number = (x) => x.toLocaleString(locale, { maximumFractionDigits: 6 });
|
|
2922
|
-
return /* @__PURE__ */
|
|
3003
|
+
return /* @__PURE__ */ React7.createElement(
|
|
2923
3004
|
"form",
|
|
2924
3005
|
{
|
|
2925
3006
|
className: "pk-inline-form pk-bin-form",
|
|
@@ -2942,11 +3023,11 @@ function BinsLevel({ view, field, labels, locale, range, regroup, back }) {
|
|
|
2942
3023
|
}
|
|
2943
3024
|
}
|
|
2944
3025
|
},
|
|
2945
|
-
/* @__PURE__ */
|
|
2946
|
-
/* @__PURE__ */
|
|
2947
|
-
started.problem ? /* @__PURE__ */
|
|
2948
|
-
/* @__PURE__ */
|
|
2949
|
-
bins ? /* @__PURE__ */
|
|
3026
|
+
/* @__PURE__ */ React7.createElement(NumberField, { value: size, onChange: setSize, problem: sized.problem, label: labels.binSize, shown: labels.binSize, testId: "bin-size", autoFocus: true }),
|
|
3027
|
+
/* @__PURE__ */ React7.createElement("label", { className: "pk-field-label" }, /* @__PURE__ */ React7.createElement("span", null, labels.binStart), /* @__PURE__ */ React7.createElement(ClearInput, { type: "text", inputMode: "decimal", autoComplete: "off", spellCheck: false, value: start, placeholder: "0", onChange: setStart, clearLabel: labels.clearText, "data-testid": "bin-start", "aria-invalid": far || started.problem ? true : void 0, "aria-describedby": far || started.problem ? problemId : void 0 })),
|
|
3028
|
+
started.problem ? /* @__PURE__ */ React7.createElement("p", { id: problemId, className: "pk-form-problem", "data-testid": "bin-start-problem" }, started.problem) : far && range && s !== null && n !== null ? /* @__PURE__ */ React7.createElement("p", { id: problemId, className: "pk-form-problem", "data-testid": "bin-problem" }, fill(labels.binStartFar, { start: number(s), min: number(range.min), max: number(range.max) })) : null,
|
|
3029
|
+
/* @__PURE__ */ React7.createElement("button", { type: "submit", className: "pk-btn pk-primary", disabled: far, "data-testid": "bin-apply" }, labels.apply),
|
|
3030
|
+
bins ? /* @__PURE__ */ React7.createElement("button", { type: "button", className: "pk-btn", onClick: () => regroup(null), "data-testid": "bin-off" }, labels.binsOff) : null
|
|
2950
3031
|
);
|
|
2951
3032
|
}
|
|
2952
3033
|
function NameLevel({ view, index, labels, commit, back }) {
|
|
@@ -2954,7 +3035,7 @@ function NameLevel({ view, index, labels, commit, back }) {
|
|
|
2954
3035
|
const name = valueLabel(spec, labels);
|
|
2955
3036
|
const note = { step: "value", field: name };
|
|
2956
3037
|
const text = useAppliedText(spec.label ?? "", (t) => commit(updateValue(view, index, { label: t.trim() || null }), note), 0);
|
|
2957
|
-
return /* @__PURE__ */
|
|
3038
|
+
return /* @__PURE__ */ React7.createElement("div", { className: "pk-inline-form pk-level-form" }, /* @__PURE__ */ React7.createElement(
|
|
2958
3039
|
ClearInput,
|
|
2959
3040
|
{
|
|
2960
3041
|
type: "text",
|
|
@@ -2977,17 +3058,47 @@ function NameLevel({ view, index, labels, commit, back }) {
|
|
|
2977
3058
|
"data-autofocus": "",
|
|
2978
3059
|
"data-testid": "value-name"
|
|
2979
3060
|
}
|
|
2980
|
-
), /* @__PURE__ */
|
|
3061
|
+
), /* @__PURE__ */ React7.createElement("p", { className: "pk-hint" }, labels.nameHint));
|
|
3062
|
+
}
|
|
3063
|
+
function FieldNameLevel({ view, field, labels, commit, back }) {
|
|
3064
|
+
const own = Object.entries(view.fieldLabels ?? {}).find(([key]) => key.toLowerCase() === field.toLowerCase())?.[1] ?? "";
|
|
3065
|
+
const original = sourceFieldName(field, labels);
|
|
3066
|
+
const note = { step: "rename", field: original };
|
|
3067
|
+
const text = useAppliedText(own, (t) => commit(setFieldLabel(view, field, t), note), 0);
|
|
3068
|
+
return /* @__PURE__ */ React7.createElement("div", { className: "pk-inline-form pk-level-form" }, /* @__PURE__ */ React7.createElement(
|
|
3069
|
+
ClearInput,
|
|
3070
|
+
{
|
|
3071
|
+
type: "text",
|
|
3072
|
+
value: text.text,
|
|
3073
|
+
placeholder: original,
|
|
3074
|
+
onChange: text.set,
|
|
3075
|
+
onBlur: text.flush,
|
|
3076
|
+
onKeyDown: fieldKeys({
|
|
3077
|
+
now: () => {
|
|
3078
|
+
text.flush();
|
|
3079
|
+
back();
|
|
3080
|
+
},
|
|
3081
|
+
restore: text.restore,
|
|
3082
|
+
back
|
|
3083
|
+
}),
|
|
3084
|
+
onClear: () => own ? commit(setFieldLabel(view, field, null), note) : void 0,
|
|
3085
|
+
clearLabel: labels.fieldNameReset,
|
|
3086
|
+
"aria-label": labels.rename,
|
|
3087
|
+
maxLength: 200,
|
|
3088
|
+
"data-autofocus": "",
|
|
3089
|
+
"data-testid": "field-name"
|
|
3090
|
+
}
|
|
3091
|
+
), /* @__PURE__ */ React7.createElement("p", { className: "pk-hint" }, labels.fieldNameHint), /* @__PURE__ */ React7.createElement("p", { className: "pk-hint" }, labels.nameHint));
|
|
2981
3092
|
}
|
|
2982
3093
|
function MenuHead({ name, info, extra, labels }) {
|
|
2983
|
-
const text = /* @__PURE__ */
|
|
2984
|
-
return /* @__PURE__ */
|
|
3094
|
+
const text = /* @__PURE__ */ React7.createElement(React7.Fragment, null, info?.description, info?.href ? /* @__PURE__ */ React7.createElement(React7.Fragment, null, " ", /* @__PURE__ */ React7.createElement("a", { href: info.href, target: "_blank", rel: "noopener noreferrer", className: "pk-learn-more" }, labels.learnMore)) : null, info?.description && extra ? /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement("br", null), /* @__PURE__ */ React7.createElement("br", null)) : null, extra);
|
|
3095
|
+
return /* @__PURE__ */ React7.createElement("div", { className: "pk-level-name" }, /* @__PURE__ */ React7.createElement("span", { className: "pk-level-name-text", "data-testid": "menu-head" }, name), info?.description || extra ? /* @__PURE__ */ React7.createElement(InfoButton, { info: { description: (
|
|
2985
3096
|
/** @type {any} */
|
|
2986
3097
|
text
|
|
2987
3098
|
) }, name, labels, className: "pk-menu-info", testId: "menu-info" }) : null);
|
|
2988
3099
|
}
|
|
2989
3100
|
function RemoveItem({ labels, onRemove, close }) {
|
|
2990
|
-
return /* @__PURE__ */
|
|
3101
|
+
return /* @__PURE__ */ React7.createElement(
|
|
2991
3102
|
MenuItem,
|
|
2992
3103
|
{
|
|
2993
3104
|
id: "menu-remove",
|
|
@@ -3015,13 +3126,13 @@ function AxisMenu({ view, zone, index, field, types, labels, commit, close, onRe
|
|
|
3015
3126
|
const topics = axisTopics({ view, zone, index, field, types, labels, locale, state, defaultsOf, encoded });
|
|
3016
3127
|
const regroup = (unit, size, origin) => {
|
|
3017
3128
|
close();
|
|
3018
|
-
const sourceName =
|
|
3129
|
+
const sourceName = fieldLabel5(source, labels.core);
|
|
3019
3130
|
const grouped = unit ? groupingName(sourceName, unit, labels, size) : null;
|
|
3020
3131
|
commit(groupField(view, field, unit, { size, origin, name: grouped ?? void 0 }).view, { step: "group", field: sourceName });
|
|
3021
3132
|
};
|
|
3022
|
-
const panel = (id, back, hint) => id === "filter" ? /* @__PURE__ */
|
|
3023
|
-
const name =
|
|
3024
|
-
return /* @__PURE__ */
|
|
3133
|
+
const panel = (id, back, hint) => id === "filter" ? /* @__PURE__ */ React7.createElement(FilterLevel, { view, field, encoded, types, labels, locale, commit, back, hint }) : id === "top" ? /* @__PURE__ */ React7.createElement(TopLevel, { view, field, types, labels, locale, commit, back, encoded }) : id === "bins" ? /* @__PURE__ */ React7.createElement(BinsLevel, { view, field, labels, locale, range: rangeOf?.(source) ?? null, regroup, back }) : id === "name" ? /* @__PURE__ */ React7.createElement(FieldNameLevel, { view, field, labels, commit, back }) : null;
|
|
3134
|
+
const name = fieldLabel5(field, labels.core);
|
|
3135
|
+
return /* @__PURE__ */ React7.createElement(
|
|
3025
3136
|
LevelMenu,
|
|
3026
3137
|
{
|
|
3027
3138
|
name,
|
|
@@ -3032,14 +3143,14 @@ function AxisMenu({ view, zone, index, field, types, labels, commit, close, onRe
|
|
|
3032
3143
|
onPick: picker(commit, close),
|
|
3033
3144
|
panel,
|
|
3034
3145
|
search: true,
|
|
3035
|
-
head: /* @__PURE__ */
|
|
3036
|
-
foot: /* @__PURE__ */
|
|
3146
|
+
head: /* @__PURE__ */ React7.createElement(MenuHead, { name, info, labels }),
|
|
3147
|
+
foot: /* @__PURE__ */ React7.createElement(RemoveItem, { labels, onRemove, close })
|
|
3037
3148
|
}
|
|
3038
3149
|
);
|
|
3039
3150
|
}
|
|
3040
3151
|
function FilterMenu({ view, index, field, types, labels, commit, close, onRemove, locale, info, state, encoded }) {
|
|
3041
|
-
const name =
|
|
3042
|
-
return /* @__PURE__ */
|
|
3152
|
+
const name = fieldLabel5(field, labels.core);
|
|
3153
|
+
return /* @__PURE__ */ React7.createElement(
|
|
3043
3154
|
LevelMenu,
|
|
3044
3155
|
{
|
|
3045
3156
|
name,
|
|
@@ -3048,18 +3159,18 @@ function FilterMenu({ view, index, field, types, labels, commit, close, onRemove
|
|
|
3048
3159
|
topics: filterZoneTopics({ view, index, field, types, labels, locale, state, encoded }),
|
|
3049
3160
|
close,
|
|
3050
3161
|
onPick: picker(commit, close),
|
|
3051
|
-
panel: (id, back, hint) => id === "filter" ? /* @__PURE__ */
|
|
3162
|
+
panel: (id, back, hint) => id === "filter" ? /* @__PURE__ */ React7.createElement(FilterLevel, { view, field, encoded, types, labels, locale, commit, back, hint }) : id === "name" ? /* @__PURE__ */ React7.createElement(FieldNameLevel, { view, field, labels, commit, back }) : null,
|
|
3052
3163
|
search: true,
|
|
3053
|
-
head: /* @__PURE__ */
|
|
3054
|
-
foot: /* @__PURE__ */
|
|
3164
|
+
head: /* @__PURE__ */ React7.createElement(MenuHead, { name, info, labels }),
|
|
3165
|
+
foot: /* @__PURE__ */ React7.createElement(RemoveItem, { labels, onRemove, close })
|
|
3055
3166
|
}
|
|
3056
3167
|
);
|
|
3057
3168
|
}
|
|
3058
3169
|
function ValueMenu({ view, index, types, labels, commit, close, onRemove, defaultsOf, info, earlier, locale = "en-US" }) {
|
|
3059
|
-
const { explain } =
|
|
3170
|
+
const { explain } = React7.useContext(HelpContext);
|
|
3060
3171
|
const name = valueLabels(view.values, labels)[index];
|
|
3061
3172
|
const topics = valueTopics({ view, index, types, labels, locale, defaultsOf, earlier });
|
|
3062
|
-
return /* @__PURE__ */
|
|
3173
|
+
return /* @__PURE__ */ React7.createElement(
|
|
3063
3174
|
LevelMenu,
|
|
3064
3175
|
{
|
|
3065
3176
|
name,
|
|
@@ -3068,16 +3179,16 @@ function ValueMenu({ view, index, types, labels, commit, close, onRemove, defaul
|
|
|
3068
3179
|
topics,
|
|
3069
3180
|
close,
|
|
3070
3181
|
onPick: picker(commit, close),
|
|
3071
|
-
panel: (id, back) => id === "name" ? /* @__PURE__ */
|
|
3182
|
+
panel: (id, back) => id === "name" ? /* @__PURE__ */ React7.createElement(NameLevel, { view, index, labels, commit, back }) : null,
|
|
3072
3183
|
search: true,
|
|
3073
|
-
head: /* @__PURE__ */
|
|
3074
|
-
foot: /* @__PURE__ */
|
|
3184
|
+
head: /* @__PURE__ */ React7.createElement(MenuHead, { name, info, extra: explain ? labels.settingInfo.valuesFilter : null, labels }),
|
|
3185
|
+
foot: /* @__PURE__ */ React7.createElement(RemoveItem, { labels, onRemove, close })
|
|
3075
3186
|
}
|
|
3076
3187
|
);
|
|
3077
3188
|
}
|
|
3078
3189
|
|
|
3079
3190
|
// src/add-menu.jsx
|
|
3080
|
-
import
|
|
3191
|
+
import React8, { useState as useState6 } from "react";
|
|
3081
3192
|
var OTHER = { rows: "cols", cols: "rows" };
|
|
3082
3193
|
function addEffect(view, zone, name) {
|
|
3083
3194
|
const inFilters = filterZoneFields(view).some((f) => same(f, name));
|
|
@@ -3093,7 +3204,7 @@ function addEffect(view, zone, name) {
|
|
|
3093
3204
|
return { from: view[OTHER[zone]].some((f) => same(f, name)) ? OTHER[zone] : inFilters ? "filters" : null, already: false };
|
|
3094
3205
|
}
|
|
3095
3206
|
function AddMenu({ zone, view, fields, placed, nameOf, info, labels, close, placeName, onAdd, filterDraft, onAdded, commit, encoded, locale, fullText }) {
|
|
3096
|
-
const [picked, setPicked] =
|
|
3207
|
+
const [picked, setPicked] = useState6(
|
|
3097
3208
|
/** @type {{ field: string, from: string | null } | null} */
|
|
3098
3209
|
null
|
|
3099
3210
|
);
|
|
@@ -3139,7 +3250,7 @@ function AddMenu({ zone, view, fields, placed, nameOf, info, labels, close, plac
|
|
|
3139
3250
|
"panel"
|
|
3140
3251
|
), hidden: true }
|
|
3141
3252
|
];
|
|
3142
|
-
return /* @__PURE__ */
|
|
3253
|
+
return /* @__PURE__ */ React8.createElement("div", { className: "pk-add-menu", "data-testid": `add-menu-${zone}` }, /* @__PURE__ */ React8.createElement(
|
|
3143
3254
|
LevelMenu,
|
|
3144
3255
|
{
|
|
3145
3256
|
name,
|
|
@@ -3150,9 +3261,9 @@ function AddMenu({ zone, view, fields, placed, nameOf, info, labels, close, plac
|
|
|
3150
3261
|
onPick: (choice) => choice.run?.(),
|
|
3151
3262
|
search: true,
|
|
3152
3263
|
searchText: labels.searchFields,
|
|
3153
|
-
filter: (query) => [topicOf(matchingFields(fields, query, info))],
|
|
3154
|
-
head: /* @__PURE__ */
|
|
3155
|
-
panel: (id, back) => id === "filter" && picked && draft ? /* @__PURE__ */
|
|
3264
|
+
filter: (query) => [topicOf(matchingFields(fields, query, info, nameOf))],
|
|
3265
|
+
head: /* @__PURE__ */ React8.createElement("div", { className: "pk-level-name" }, /* @__PURE__ */ React8.createElement("span", { className: "pk-level-name-text", "data-testid": "menu-head" }, name)),
|
|
3266
|
+
panel: (id, back) => id === "filter" && picked && draft ? /* @__PURE__ */ React8.createElement(
|
|
3156
3267
|
FilterBody,
|
|
3157
3268
|
{
|
|
3158
3269
|
view,
|
|
@@ -3172,7 +3283,7 @@ function AddMenu({ zone, view, fields, placed, nameOf, info, labels, close, plac
|
|
|
3172
3283
|
}
|
|
3173
3284
|
|
|
3174
3285
|
// src/toolbar-panels.jsx
|
|
3175
|
-
import
|
|
3286
|
+
import React9, { useEffect as useEffect3, useId as useId6, useRef as useRef3, useState as useState7 } from "react";
|
|
3176
3287
|
import { VIEW_FILE_LIMITS, referenceLineRules, swapAxes } from "pivotkit-core";
|
|
3177
3288
|
|
|
3178
3289
|
// src/export-scope.js
|
|
@@ -3335,7 +3446,7 @@ async function copyImage(blob, env = { clipboard: typeof navigator !== "undefine
|
|
|
3335
3446
|
}
|
|
3336
3447
|
|
|
3337
3448
|
// src/version.js
|
|
3338
|
-
var VERSION = true ? "0.
|
|
3449
|
+
var VERSION = true ? "0.9.0" : "0.0.0-source";
|
|
3339
3450
|
|
|
3340
3451
|
// src/share-actions.js
|
|
3341
3452
|
var here = () => typeof location !== "undefined" ? location.href : void 0;
|
|
@@ -3952,12 +4063,15 @@ function storeViews(raw, change, labels, locale, keep) {
|
|
|
3952
4063
|
// src/toolbar-panels.jsx
|
|
3953
4064
|
function ChartTypeOptions({ view, plan, labels, onChart, close }) {
|
|
3954
4065
|
const current = chartTypeOf(view.chart);
|
|
3955
|
-
|
|
4066
|
+
const short = (p) => (CHART_TYPES[p].values ?? 0) > view.values.length && current !== p;
|
|
4067
|
+
return CHART_TYPE_NAMES.map((p) => /* @__PURE__ */ React9.createElement(
|
|
3956
4068
|
Option,
|
|
3957
4069
|
{
|
|
3958
4070
|
key: p,
|
|
3959
4071
|
icon: CHART_TYPES[p].icon,
|
|
3960
|
-
checked: view.display
|
|
4072
|
+
checked: view.display !== "table" && current === p,
|
|
4073
|
+
disabled: short(p) || void 0,
|
|
4074
|
+
reason: short(p) ? labels.chartNeedsValues : void 0,
|
|
3961
4075
|
hint: p === "auto" && plan ? fill(labels.chartAutoNow, { type: labels.chartTypes[plan.name] }) : void 0,
|
|
3962
4076
|
onSelect: () => {
|
|
3963
4077
|
close();
|
|
@@ -3972,16 +4086,16 @@ function legendNames(drawn, series) {
|
|
|
3972
4086
|
if (!series || drawn === "heatmap") {
|
|
3973
4087
|
return [];
|
|
3974
4088
|
}
|
|
3975
|
-
return [...new Set(
|
|
4089
|
+
return [...new Set(ITEM_TYPES.includes(drawn) ? series.categories : series.series.map((s) => s.name))];
|
|
3976
4090
|
}
|
|
3977
4091
|
function ChartTitle({ title, labels, onDisplay }) {
|
|
3978
|
-
const [text, setText] =
|
|
3979
|
-
const [last, setLast] =
|
|
4092
|
+
const [text, setText] = useState7(title ?? "");
|
|
4093
|
+
const [last, setLast] = useState7(title);
|
|
3980
4094
|
if (title !== last) {
|
|
3981
4095
|
setLast(title);
|
|
3982
4096
|
setText(title ?? "");
|
|
3983
4097
|
}
|
|
3984
|
-
return /* @__PURE__ */
|
|
4098
|
+
return /* @__PURE__ */ React9.createElement(
|
|
3985
4099
|
"form",
|
|
3986
4100
|
{
|
|
3987
4101
|
className: "pk-inline-form",
|
|
@@ -3990,7 +4104,7 @@ function ChartTitle({ title, labels, onDisplay }) {
|
|
|
3990
4104
|
onDisplay({ title: text.trim() || null });
|
|
3991
4105
|
}
|
|
3992
4106
|
},
|
|
3993
|
-
/* @__PURE__ */
|
|
4107
|
+
/* @__PURE__ */ React9.createElement(
|
|
3994
4108
|
ClearInput,
|
|
3995
4109
|
{
|
|
3996
4110
|
type: "text",
|
|
@@ -4004,7 +4118,7 @@ function ChartTitle({ title, labels, onDisplay }) {
|
|
|
4004
4118
|
"data-testid": "chart-title"
|
|
4005
4119
|
}
|
|
4006
4120
|
),
|
|
4007
|
-
/* @__PURE__ */
|
|
4121
|
+
/* @__PURE__ */ React9.createElement("button", { type: "submit", className: "pk-btn pk-primary", disabled: (text.trim() || null) === (title ?? null) }, labels.apply)
|
|
4008
4122
|
);
|
|
4009
4123
|
}
|
|
4010
4124
|
function colorsDrawn(instance) {
|
|
@@ -4022,23 +4136,23 @@ function colorsDrawn(instance) {
|
|
|
4022
4136
|
return out;
|
|
4023
4137
|
}
|
|
4024
4138
|
function TargetField({ target, labels, locale, format, onTarget }) {
|
|
4025
|
-
const [text, setText] =
|
|
4026
|
-
const [last, setLast] =
|
|
4139
|
+
const [text, setText] = useState7(numberText(target, locale));
|
|
4140
|
+
const [last, setLast] = useState7(target);
|
|
4027
4141
|
if (target !== last) {
|
|
4028
4142
|
setLast(target);
|
|
4029
4143
|
setText(numberText(target, locale));
|
|
4030
4144
|
}
|
|
4031
4145
|
const value = parseTarget(text, locale, format);
|
|
4032
4146
|
const bad = text.trim() !== "" && value === null;
|
|
4033
|
-
const hintId =
|
|
4034
|
-
const warnId =
|
|
4147
|
+
const hintId = useId6();
|
|
4148
|
+
const warnId = useId6();
|
|
4035
4149
|
const share = /^percent(?!100)/.test(format ?? "");
|
|
4036
4150
|
const hint = share ? labels.targetPercent : /^percent100/.test(format ?? "") ? labels.targetPercent100 : null;
|
|
4037
4151
|
const typed = text.trim();
|
|
4038
4152
|
const high = share && value !== null && value > 1 && !typed.endsWith("%");
|
|
4039
4153
|
const shown = (n) => new Intl.NumberFormat(locale, { style: "percent", maximumFractionDigits: 2 }).format(n);
|
|
4040
4154
|
const describedBy = [hint ? hintId : "", high ? warnId : ""].filter(Boolean).join(" ") || void 0;
|
|
4041
|
-
return /* @__PURE__ */
|
|
4155
|
+
return /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(
|
|
4042
4156
|
"form",
|
|
4043
4157
|
{
|
|
4044
4158
|
className: "pk-inline-form",
|
|
@@ -4049,7 +4163,7 @@ function TargetField({ target, labels, locale, format, onTarget }) {
|
|
|
4049
4163
|
}
|
|
4050
4164
|
}
|
|
4051
4165
|
},
|
|
4052
|
-
/* @__PURE__ */
|
|
4166
|
+
/* @__PURE__ */ React9.createElement(
|
|
4053
4167
|
ClearInput,
|
|
4054
4168
|
{
|
|
4055
4169
|
type: "text",
|
|
@@ -4065,22 +4179,22 @@ function TargetField({ target, labels, locale, format, onTarget }) {
|
|
|
4065
4179
|
"data-testid": "chart-target"
|
|
4066
4180
|
}
|
|
4067
4181
|
),
|
|
4068
|
-
/* @__PURE__ */
|
|
4069
|
-
), hint ? /* @__PURE__ */
|
|
4182
|
+
/* @__PURE__ */ React9.createElement("button", { type: "submit", className: "pk-btn pk-primary", disabled: bad || value === target }, labels.apply)
|
|
4183
|
+
), hint ? /* @__PURE__ */ React9.createElement("p", { id: hintId, className: "pk-hint pk-subtitle", "data-testid": "target-hint" }, hint) : null, high ? /* @__PURE__ */ React9.createElement("p", { id: warnId, className: "pk-hint pk-subtitle", role: "status", "data-testid": "target-warning" }, fill(labels.targetPercentHigh, { typed, shown: shown(
|
|
4070
4184
|
/** @type {number} */
|
|
4071
4185
|
value
|
|
4072
4186
|
), share: shown(
|
|
4073
4187
|
/** @type {number} */
|
|
4074
4188
|
value / 100
|
|
4075
|
-
) })) : null, target !== null ? /* @__PURE__ */
|
|
4189
|
+
) })) : null, target !== null ? /* @__PURE__ */ React9.createElement("button", { type: "button", className: "pk-btn", onClick: () => onTarget(null), "data-testid": "target-remove" }, labels.targetRemove) : null);
|
|
4076
4190
|
}
|
|
4077
4191
|
function ChartSettingsPanel({ view, plan, encoded, lineChecks, labels, locale, onChart, onDisplay, close, series, colors, folding, onExpand, onCollapse }) {
|
|
4078
4192
|
const drawn = plan ? plan.name : chartTypeOf(view.chart);
|
|
4079
4193
|
const names = legendNames(drawn, series);
|
|
4080
4194
|
const lines = view.chart.referenceLines;
|
|
4081
|
-
const plain = plan?.chart && encoded ? referenceLineRules(plan.swap ? swapAxes(view) : view, { ...view.chart, ...plan.chart }, encoded) : { average: true, trend: true, target: true };
|
|
4195
|
+
const plain = plan?.chart && encoded ? referenceLineRules(plan.swap ? swapAxes(view) : view, { ...view.chart, ...plan.chart }, encoded) : { average: true, trend: true, target: true, extremes: true };
|
|
4082
4196
|
const rules = lineChecks ?? { ...plain, notes: ["table"] };
|
|
4083
|
-
const [drawnColors, setDrawnColors] =
|
|
4197
|
+
const [drawnColors, setDrawnColors] = useState7(
|
|
4084
4198
|
/** @type {Map<string, string>} */
|
|
4085
4199
|
/* @__PURE__ */ new Map()
|
|
4086
4200
|
);
|
|
@@ -4096,8 +4210,8 @@ function ChartSettingsPanel({ view, plan, encoded, lineChecks, labels, locale, o
|
|
|
4096
4210
|
return () => instance.off("finished", read);
|
|
4097
4211
|
}, [colors?.chart]);
|
|
4098
4212
|
const topics = chartTopics({ view, drawn, labels, names, act: { display: onDisplay, expand: () => onExpand(labels), collapse: () => onCollapse(labels) }, lines: { rules, targetText: numberText(lines?.target, locale) }, drawnColors, folding });
|
|
4099
|
-
const head = /* @__PURE__ */
|
|
4100
|
-
return /* @__PURE__ */
|
|
4213
|
+
const head = /* @__PURE__ */ React9.createElement(Section, { title: labels.chartType }, /* @__PURE__ */ React9.createElement("div", { className: "pk-choice-grid", role: "group", "aria-label": fill(labels.chartTypeIs, { type: labels.chartTypes[plan?.auto ? "auto" : drawn] }), "data-testid": "chart-types" }, /* @__PURE__ */ React9.createElement(ChartTypeOptions, { view, plan, labels, onChart, close })));
|
|
4214
|
+
return /* @__PURE__ */ React9.createElement(
|
|
4101
4215
|
LevelMenu,
|
|
4102
4216
|
{
|
|
4103
4217
|
name: labels.chartSettings,
|
|
@@ -4106,17 +4220,17 @@ function ChartSettingsPanel({ view, plan, encoded, lineChecks, labels, locale, o
|
|
|
4106
4220
|
close,
|
|
4107
4221
|
onPick: runChoice(close),
|
|
4108
4222
|
head,
|
|
4109
|
-
panel: (id) => id === "title" ? /* @__PURE__ */
|
|
4223
|
+
panel: (id) => id === "title" ? /* @__PURE__ */ React9.createElement(ChartTitle, { title: view.chart.title, labels, onDisplay }) : id === "linesTarget" ? /* @__PURE__ */ React9.createElement(TargetField, { target: lines?.target ?? null, labels, locale, format: lineChecks?.format, onTarget: (target) => onDisplay({ referenceLines: { ...lines, target } }) }) : null
|
|
4110
4224
|
}
|
|
4111
4225
|
);
|
|
4112
4226
|
}
|
|
4113
4227
|
function Shortcuts({ labels, mod }) {
|
|
4114
4228
|
const key = (k) => k === "Mod" ? mod === "\u2318" ? "\u2318" : labels.keys.Mod : Object.hasOwn(labels.keys, k) ? labels.keys[k] : k;
|
|
4115
|
-
return /* @__PURE__ */
|
|
4229
|
+
return /* @__PURE__ */ React9.createElement("dl", { className: "pk-shortcuts", "data-testid": "shortcuts" }, SHORTCUTS.map((s) => /* @__PURE__ */ React9.createElement("div", { key: s.text, className: "pk-shortcut" }, /* @__PURE__ */ React9.createElement("dt", null, s.keys.map((k, i) => /* @__PURE__ */ React9.createElement(React9.Fragment, { key: k }, i ? " + " : null, /* @__PURE__ */ React9.createElement("kbd", null, key(k))))), /* @__PURE__ */ React9.createElement("dd", null, labels.shortcuts[s.text]))));
|
|
4116
4230
|
}
|
|
4117
4231
|
function TableSettingsPanel({ view, labels, onTotal, onExpand, onCollapse, close, folding }) {
|
|
4118
4232
|
const topics = tableTopics({ view, labels, folding, act: { total: onTotal, expand: () => onExpand(labels), collapse: () => onCollapse(labels) } });
|
|
4119
|
-
return /* @__PURE__ */
|
|
4233
|
+
return /* @__PURE__ */ React9.createElement(LevelMenu, { name: labels.tableSettings, labels, topics, close, onPick: runChoice(close), panel: () => null });
|
|
4120
4234
|
}
|
|
4121
4235
|
function MorePanel({ labels, tips, mod, help, close, foot }) {
|
|
4122
4236
|
const topics = moreTopics({
|
|
@@ -4125,7 +4239,7 @@ function MorePanel({ labels, tips, mod, help, close, foot }) {
|
|
|
4125
4239
|
explanations: help?.explanations ?? null,
|
|
4126
4240
|
act: { tipsOn: (on) => tips.onOn(on), resetTips: () => tips.onReset(), explain: (on) => help?.explanations?.set(on) }
|
|
4127
4241
|
});
|
|
4128
|
-
return /* @__PURE__ */
|
|
4242
|
+
return /* @__PURE__ */ React9.createElement(LevelMenu, { name: labels.more, labels, topics, close, onPick: runChoice(close), foot: foot?.(close), panel: (id) => id === "shortcuts" ? /* @__PURE__ */ React9.createElement(Shortcuts, { labels, mod }) : null });
|
|
4129
4243
|
}
|
|
4130
4244
|
var runChoice = (close) => (c) => {
|
|
4131
4245
|
if (c.closes) {
|
|
@@ -4145,11 +4259,11 @@ function Confirm({ question, action, cancel, onYes, onNo, testId, yesId, noId, d
|
|
|
4145
4259
|
useEffect3(() => {
|
|
4146
4260
|
(focusYes ? yes : no).current?.focus({ preventScroll: true });
|
|
4147
4261
|
}, [focusYes]);
|
|
4148
|
-
return /* @__PURE__ */
|
|
4262
|
+
return /* @__PURE__ */ React9.createElement("div", { className: "pk-confirm pk-save-confirm", role: "group", "aria-label": question, "data-testid": testId }, /* @__PURE__ */ React9.createElement("span", { className: "pk-confirm-text" }, question), /* @__PURE__ */ React9.createElement("button", { ref: yes, type: "button", className: danger ? "pk-btn pk-danger-btn" : "pk-btn pk-primary", disabled: busy, "data-autofocus": focusYes ? "" : void 0, "data-testid": yesId, onClick: onYes }, action), /* @__PURE__ */ React9.createElement("button", { ref: no, type: "button", className: "pk-btn", disabled: busy, "data-autofocus": focusYes ? void 0 : "", "data-testid": noId, onClick: onNo }, cancel));
|
|
4149
4263
|
}
|
|
4150
4264
|
function SaveView({ labels, button, onSave, resolve, close }) {
|
|
4151
|
-
const [name, setName] =
|
|
4152
|
-
const [asking, setAsking] =
|
|
4265
|
+
const [name, setName] = useState7("");
|
|
4266
|
+
const [asking, setAsking] = useState7(
|
|
4153
4267
|
/** @type {any} */
|
|
4154
4268
|
null
|
|
4155
4269
|
);
|
|
@@ -4166,7 +4280,7 @@ function SaveView({ labels, button, onSave, resolve, close }) {
|
|
|
4166
4280
|
}
|
|
4167
4281
|
}, [asking]);
|
|
4168
4282
|
if (asking) {
|
|
4169
|
-
return /* @__PURE__ */
|
|
4283
|
+
return /* @__PURE__ */ React9.createElement(
|
|
4170
4284
|
Confirm,
|
|
4171
4285
|
{
|
|
4172
4286
|
question: fill(labels.replaceConfirm, { name: asking.name }),
|
|
@@ -4183,7 +4297,7 @@ function SaveView({ labels, button, onSave, resolve, close }) {
|
|
|
4183
4297
|
}
|
|
4184
4298
|
);
|
|
4185
4299
|
}
|
|
4186
|
-
return /* @__PURE__ */
|
|
4300
|
+
return /* @__PURE__ */ React9.createElement(
|
|
4187
4301
|
"form",
|
|
4188
4302
|
{
|
|
4189
4303
|
className: "pk-inline-form",
|
|
@@ -4199,12 +4313,12 @@ function SaveView({ labels, button, onSave, resolve, close }) {
|
|
|
4199
4313
|
}
|
|
4200
4314
|
}
|
|
4201
4315
|
},
|
|
4202
|
-
/* @__PURE__ */
|
|
4203
|
-
/* @__PURE__ */
|
|
4316
|
+
/* @__PURE__ */ React9.createElement(ClearInput, { type: "text", value: name, onChange: setName, clearLabel: labels.clearText, placeholder: labels.viewName, "aria-label": labels.viewName, maxLength: 120, "data-testid": "saved-view-name", inputRef: field }),
|
|
4317
|
+
/* @__PURE__ */ React9.createElement("button", { type: "submit", className: "pk-btn pk-primary", disabled: !name.trim() }, button)
|
|
4204
4318
|
);
|
|
4205
4319
|
}
|
|
4206
4320
|
function LoadCheck({ check, labels, onCancel, close, title, quiet = false }) {
|
|
4207
|
-
const titleId =
|
|
4321
|
+
const titleId = useId6();
|
|
4208
4322
|
const first = useRef3(
|
|
4209
4323
|
/** @type {HTMLButtonElement | null} */
|
|
4210
4324
|
null
|
|
@@ -4214,25 +4328,25 @@ function LoadCheck({ check, labels, onCancel, close, title, quiet = false }) {
|
|
|
4214
4328
|
first.current?.focus({ preventScroll: true });
|
|
4215
4329
|
}
|
|
4216
4330
|
}, [quiet]);
|
|
4217
|
-
return /* @__PURE__ */
|
|
4331
|
+
return /* @__PURE__ */ React9.createElement("div", { className: "pk-load-check", role: "group", "aria-labelledby": titleId, "data-testid": "load-check" }, /* @__PURE__ */ React9.createElement("p", { id: titleId, className: "pk-load-check-title" }, /* @__PURE__ */ React9.createElement(Icon, { name: "info", size: 16 }), /* @__PURE__ */ React9.createElement("span", null, title ?? labels.loadCheckTitle)), /* @__PURE__ */ React9.createElement("ul", { className: "pk-load-check-lines" }, check.lines.map((line, i) => /* @__PURE__ */ React9.createElement("li", { key: i }, line))), /* @__PURE__ */ React9.createElement("div", { className: "pk-load-check-actions" }, check.switchTo ? /* @__PURE__ */ React9.createElement("button", { ref: first, type: "button", className: "pk-btn pk-primary", "data-autofocus": "", "data-testid": "load-switch", onClick: () => {
|
|
4218
4332
|
close();
|
|
4219
4333
|
check.switchTo?.run();
|
|
4220
|
-
} }, fill(labels.switchAndLoad, { source: check.switchTo.name })) : null, /* @__PURE__ */
|
|
4334
|
+
} }, fill(labels.switchAndLoad, { source: check.switchTo.name })) : null, /* @__PURE__ */ React9.createElement("button", { ref: check.switchTo ? void 0 : first, type: "button", className: check.switchTo ? "pk-btn" : "pk-btn pk-primary", "data-autofocus": check.switchTo ? void 0 : "", "data-testid": "load-anyway", onClick: () => {
|
|
4221
4335
|
close();
|
|
4222
4336
|
check.load();
|
|
4223
|
-
} }, labels.loadAnyway), /* @__PURE__ */
|
|
4337
|
+
} }, labels.loadAnyway), /* @__PURE__ */ React9.createElement("button", { type: "button", className: "pk-btn", "data-testid": "load-cancel", onClick: onCancel }, labels.cancel)), check.switchTo ? /* @__PURE__ */ React9.createElement("p", { className: "pk-hint" }, labels.switchStartsFresh) : null);
|
|
4224
4338
|
}
|
|
4225
4339
|
function LoadView({ labels, onLoadText, close }) {
|
|
4226
|
-
const [text, setText] =
|
|
4227
|
-
const [problem, setProblem] =
|
|
4340
|
+
const [text, setText] = useState7("");
|
|
4341
|
+
const [problem, setProblem] = useState7(
|
|
4228
4342
|
/** @type {string | null} */
|
|
4229
4343
|
null
|
|
4230
4344
|
);
|
|
4231
|
-
const [check, setCheck] =
|
|
4345
|
+
const [check, setCheck] = useState7(
|
|
4232
4346
|
/** @type {any} */
|
|
4233
4347
|
null
|
|
4234
4348
|
);
|
|
4235
|
-
const [busy, setBusy] =
|
|
4349
|
+
const [busy, setBusy] = useState7(false);
|
|
4236
4350
|
const file = useRef3(
|
|
4237
4351
|
/** @type {HTMLInputElement | null} */
|
|
4238
4352
|
null
|
|
@@ -4241,7 +4355,7 @@ function LoadView({ labels, onLoadText, close }) {
|
|
|
4241
4355
|
/** @type {HTMLTextAreaElement | null} */
|
|
4242
4356
|
null
|
|
4243
4357
|
);
|
|
4244
|
-
const problemId =
|
|
4358
|
+
const problemId = useId6();
|
|
4245
4359
|
const fileName = useFormName();
|
|
4246
4360
|
useEffect3(() => {
|
|
4247
4361
|
if (!check) {
|
|
@@ -4261,9 +4375,9 @@ function LoadView({ labels, onLoadText, close }) {
|
|
|
4261
4375
|
}
|
|
4262
4376
|
};
|
|
4263
4377
|
if (check) {
|
|
4264
|
-
return /* @__PURE__ */
|
|
4378
|
+
return /* @__PURE__ */ React9.createElement(LoadCheck, { check, labels, onCancel: () => setCheck(null), close });
|
|
4265
4379
|
}
|
|
4266
|
-
return /* @__PURE__ */
|
|
4380
|
+
return /* @__PURE__ */ React9.createElement(
|
|
4267
4381
|
"form",
|
|
4268
4382
|
{
|
|
4269
4383
|
className: "pk-inline-form pk-load-view",
|
|
@@ -4272,8 +4386,8 @@ function LoadView({ labels, onLoadText, close }) {
|
|
|
4272
4386
|
load(text);
|
|
4273
4387
|
}
|
|
4274
4388
|
},
|
|
4275
|
-
/* @__PURE__ */
|
|
4276
|
-
/* @__PURE__ */
|
|
4389
|
+
/* @__PURE__ */ React9.createElement("p", { className: "pk-hint" }, labels.loadViewHint),
|
|
4390
|
+
/* @__PURE__ */ React9.createElement(
|
|
4277
4391
|
ClearInput,
|
|
4278
4392
|
{
|
|
4279
4393
|
multiline: true,
|
|
@@ -4293,8 +4407,8 @@ function LoadView({ labels, onLoadText, close }) {
|
|
|
4293
4407
|
inputRef: field
|
|
4294
4408
|
}
|
|
4295
4409
|
),
|
|
4296
|
-
problem ? /* @__PURE__ */
|
|
4297
|
-
/* @__PURE__ */
|
|
4410
|
+
problem ? /* @__PURE__ */ React9.createElement("p", { id: problemId, className: "pk-form-problem", role: "alert", "data-testid": "load-view-problem" }, problem) : null,
|
|
4411
|
+
/* @__PURE__ */ React9.createElement(
|
|
4298
4412
|
"input",
|
|
4299
4413
|
{
|
|
4300
4414
|
ref: file,
|
|
@@ -4325,8 +4439,8 @@ function LoadView({ labels, onLoadText, close }) {
|
|
|
4325
4439
|
}
|
|
4326
4440
|
}
|
|
4327
4441
|
),
|
|
4328
|
-
/* @__PURE__ */
|
|
4329
|
-
/* @__PURE__ */
|
|
4442
|
+
/* @__PURE__ */ React9.createElement("button", { type: "button", className: "pk-btn", onClick: () => file.current?.click(), disabled: busy, "data-testid": "load-view-choose" }, /* @__PURE__ */ React9.createElement(Icon, { name: "file" }), /* @__PURE__ */ React9.createElement("span", { className: "pk-btn-text" }, labels.chooseFile)),
|
|
4443
|
+
/* @__PURE__ */ React9.createElement("button", { type: "submit", className: "pk-btn pk-primary", disabled: busy || !text.trim(), "data-testid": "load-view-apply" }, labels.load)
|
|
4330
4444
|
);
|
|
4331
4445
|
}
|
|
4332
4446
|
function viewActions(ctx, labels) {
|
|
@@ -4373,11 +4487,11 @@ function ViewsPanel({ templates, labels, onLoad, actions, close, share }) {
|
|
|
4373
4487
|
const can = { host: Boolean(actions.onSave), store: Boolean(actions.store), publish: Boolean(onPublish), sourceId: actions.sourceId, sheet: actions.sheet ?? null };
|
|
4374
4488
|
const target = saveTarget(actions.loaded, templates, can, actions.empty);
|
|
4375
4489
|
const store = actions.store && !actions.onSave;
|
|
4376
|
-
const [asking, setAsking] =
|
|
4490
|
+
const [asking, setAsking] = useState7(
|
|
4377
4491
|
/** @type {{ kind: "delete" | "publish" | "replaceShared", t?: any, focus?: string } | null} */
|
|
4378
4492
|
null
|
|
4379
4493
|
);
|
|
4380
|
-
const [busy, setBusy] =
|
|
4494
|
+
const [busy, setBusy] = useState7(false);
|
|
4381
4495
|
useEffect3(() => {
|
|
4382
4496
|
share?.prepare?.();
|
|
4383
4497
|
}, [share]);
|
|
@@ -4480,13 +4594,13 @@ function ViewsPanel({ templates, labels, onLoad, actions, close, share }) {
|
|
|
4480
4594
|
];
|
|
4481
4595
|
const panel = (id, back) => {
|
|
4482
4596
|
if (id === "saveAs") {
|
|
4483
|
-
return /* @__PURE__ */
|
|
4597
|
+
return /* @__PURE__ */ React9.createElement(SaveView, { labels, button: actions.loaded ? labels.saveAs.replace(/…$/, "") : labels.save, onSave: (name, t) => save(t, name), resolve: (name) => saveAsTarget(name, templates, can), close });
|
|
4484
4598
|
}
|
|
4485
4599
|
if (id === "load" && act) {
|
|
4486
|
-
return /* @__PURE__ */
|
|
4600
|
+
return /* @__PURE__ */ React9.createElement(LoadView, { labels, onLoadText: act.loadText, close });
|
|
4487
4601
|
}
|
|
4488
4602
|
if (id === "confirm" && question && asking) {
|
|
4489
|
-
return /* @__PURE__ */
|
|
4603
|
+
return /* @__PURE__ */ React9.createElement(
|
|
4490
4604
|
Confirm,
|
|
4491
4605
|
{
|
|
4492
4606
|
question: question.text,
|
|
@@ -4517,11 +4631,11 @@ function ViewsPanel({ templates, labels, onLoad, actions, close, share }) {
|
|
|
4517
4631
|
}
|
|
4518
4632
|
return null;
|
|
4519
4633
|
};
|
|
4520
|
-
return /* @__PURE__ */
|
|
4634
|
+
return /* @__PURE__ */ React9.createElement(LevelMenu, { name: labels.views, labels, topics, close, onPick: runChoice(close), panel, focusAgain: templates.length });
|
|
4521
4635
|
}
|
|
4522
4636
|
function ExportOption({ icon, text, info, onSelect, testId, disabled, reason, onIntent }) {
|
|
4523
|
-
const option = /* @__PURE__ */
|
|
4524
|
-
return info ? /* @__PURE__ */
|
|
4637
|
+
const option = /* @__PURE__ */ React9.createElement(Option, { icon, onSelect, disabled, reason, testId }, text);
|
|
4638
|
+
return info ? /* @__PURE__ */ React9.createElement("div", { className: "pk-setting-row", onPointerEnter: onIntent, onPointerDown: onIntent, onFocus: onIntent }, option, /* @__PURE__ */ React9.createElement(SettingInfo, { id: (
|
|
4525
4639
|
/** @type {any} */
|
|
4526
4640
|
info
|
|
4527
4641
|
), name: text })) : option;
|
|
@@ -4535,11 +4649,11 @@ function ExportPanel({ labels, onExport, chartReady, display, empty = false, dat
|
|
|
4535
4649
|
};
|
|
4536
4650
|
const off = empty ? { disabled: true, reason: labels.exportNeedsField } : {};
|
|
4537
4651
|
const noRows = (dataExport?.encoded?.length ?? 0) === 0 ? { disabled: true, reason: labels.exportNeedsRows } : {};
|
|
4538
|
-
return /* @__PURE__ */
|
|
4652
|
+
return /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(Section, { title: labels.exportDownload }, /* @__PURE__ */ React9.createElement(ExportOption, { icon: "file", text: labels.exportXlsx, info: "exportXlsx", onSelect: run("xlsx"), ...off, testId: "export-xlsx" }), /* @__PURE__ */ React9.createElement(ExportOption, { icon: "file", text: labels.exportCsv, info: "exportCsv", onSelect: run("csv"), ...off, testId: "export-csv" }), /* @__PURE__ */ React9.createElement(ExportOption, { icon: "file", text: labels.exportHtml, info: "exportHtml", onSelect: run("html"), ...off, testId: "export-html" }), /* @__PURE__ */ React9.createElement(ExportOption, { icon: "image", text: labels.exportPng, disabled: empty || !chartReady, reason: empty ? off.reason : display === "table" ? labels.exportPngNeedsChart : void 0, onSelect: run("png"), testId: "export-png" }), /* @__PURE__ */ React9.createElement(ExportOption, { icon: "image", text: labels.exportSvg, disabled: empty || display === "table", reason: empty ? off.reason : display === "table" ? labels.exportPngNeedsChart : void 0, onSelect: run("svg"), testId: "export-svg" })), /* @__PURE__ */ React9.createElement(Section, { title: labels.exportPrintGroup }, /* @__PURE__ */ React9.createElement(ExportOption, { icon: "print", text: labels.exportPrint, info: "exportPrint", onSelect: run("print"), ...off, testId: "export-print", onIntent: () => prepare("print") })), /* @__PURE__ */ React9.createElement(Section, { title: labels.exportCopy }, /* @__PURE__ */ React9.createElement(ExportOption, { icon: "copy", text: labels.copyTable, info: "copyTable", onSelect: run("copy-table"), ...off, testId: "export-copy-table" }), /* @__PURE__ */ React9.createElement(ExportOption, { icon: "copy", text: labels.copyDataJson, info: "copyDataJson", onSelect: run("copy-json"), ...off, testId: "export-copy-json" }), /* @__PURE__ */ React9.createElement(ExportOption, { icon: "image", text: labels.copyChart, disabled: empty || !chartReady, reason: empty ? off.reason : display === "table" ? labels.exportPngNeedsChart : void 0, onSelect: run("copy-chart"), testId: "export-copy-chart" })), source ? /* @__PURE__ */ React9.createElement(Section, { title: labels.exportDataGroup }, /* @__PURE__ */ React9.createElement(ExportOption, { icon: "file", text: labels.exportDataCsv, info: "exportDataCsv", onSelect: run("data-csv"), ...noRows, testId: "export-data-csv" }), /* @__PURE__ */ React9.createElement(ExportOption, { icon: "file", text: labels.exportDataJson, info: "exportDataJson", onSelect: run("data-json"), ...noRows, testId: "export-data-json" })) : null);
|
|
4539
4653
|
}
|
|
4540
4654
|
|
|
4541
4655
|
// src/drill-panel.jsx
|
|
4542
|
-
import
|
|
4656
|
+
import React10, { useContext as useContext4, useEffect as useEffect4, useId as useId7, useMemo as useMemo4, useRef as useRef4, useState as useState8 } from "react";
|
|
4543
4657
|
|
|
4544
4658
|
// src/drill-export.js
|
|
4545
4659
|
function pick(row, columns) {
|
|
@@ -4588,9 +4702,9 @@ async function exportDrill(kind, { drill, encoded, labels, columns, onExport, an
|
|
|
4588
4702
|
}
|
|
4589
4703
|
|
|
4590
4704
|
// src/drill-table.js
|
|
4591
|
-
import { fieldLabel as
|
|
4705
|
+
import { fieldLabel as fieldLabel6, findNode, formatter as formatter3, isFormat as isFormat3 } from "pivotkit-core";
|
|
4592
4706
|
var DATE_FORMATS = /* @__PURE__ */ new Set(["date", "datetime", "time"]);
|
|
4593
|
-
function
|
|
4707
|
+
function columnText2(column, { locale, labels, format }) {
|
|
4594
4708
|
const spec = typeof format === "string" && isFormat3(format) ? format.trim().toLowerCase() : null;
|
|
4595
4709
|
if (column.type === "date") {
|
|
4596
4710
|
const f = formatter3(spec && DATE_FORMATS.has(spec.split(":")[0]) ? spec : column.dateOnly ? "date" : "datetime", { locale });
|
|
@@ -4610,7 +4724,7 @@ function columnText(column, { locale, labels, format }) {
|
|
|
4610
4724
|
return { text: (v) => String(v), numeric: false };
|
|
4611
4725
|
}
|
|
4612
4726
|
function drillTable(encoded, indices, { locale, labels, formatOf = () => void 0 }) {
|
|
4613
|
-
const cols = encoded.columns.map((column) => ({ column, ...
|
|
4727
|
+
const cols = encoded.columns.map((column) => ({ column, ...columnText2(column, { locale, labels, format: formatOf(column.name) }) }));
|
|
4614
4728
|
const rows = Array.from(
|
|
4615
4729
|
indices,
|
|
4616
4730
|
(i) => cols.map(({ column, text }) => {
|
|
@@ -4628,7 +4742,7 @@ function pathTitle(result, rowPath, colPath, labels) {
|
|
|
4628
4742
|
const node = findNode(result, axis, path);
|
|
4629
4743
|
for (let n = node; n && n.parent; n = n.parent) {
|
|
4630
4744
|
const item = result.label(axis, n, labels.core);
|
|
4631
|
-
parts.unshift(`${
|
|
4745
|
+
parts.unshift(`${fieldLabel6(fields[n.depth - 1], labels.core)}: ${item}`);
|
|
4632
4746
|
items.unshift(item);
|
|
4633
4747
|
}
|
|
4634
4748
|
};
|
|
@@ -4648,13 +4762,13 @@ function DrillPanel({ drill: source, onClose, labels, locale, exportContext: con
|
|
|
4648
4762
|
const scope = context ? dataExportFor(context.exportData, context.encoded) : void 0;
|
|
4649
4763
|
const columns = scope?.columns;
|
|
4650
4764
|
const exportContext = context && scope && drillExportOn(scope, { drillDownExport: context.drillDownExport }) ? context : void 0;
|
|
4651
|
-
const id =
|
|
4765
|
+
const id = useId7();
|
|
4652
4766
|
const drill = useMemo4(() => source ? drillOf(source, labels) : null, [source, labels]);
|
|
4653
4767
|
const panel = useRef4(
|
|
4654
4768
|
/** @type {HTMLDivElement | null} */
|
|
4655
4769
|
null
|
|
4656
4770
|
);
|
|
4657
|
-
const [big, setBig] =
|
|
4771
|
+
const [big, setBig] = useState8(false);
|
|
4658
4772
|
const pressed = useRef4(false);
|
|
4659
4773
|
const narrow = useContext4(LayerContext).size === "narrow";
|
|
4660
4774
|
const { onKeyDown } = useModal(panel, Boolean(drill), big ? () => setBig(false) : onClose);
|
|
@@ -4674,7 +4788,7 @@ function DrillPanel({ drill: source, onClose, labels, locale, exportContext: con
|
|
|
4674
4788
|
void exportDrill(kind, { drill, labels, ...exportContext, columns, root: exportContext.root.current });
|
|
4675
4789
|
}
|
|
4676
4790
|
};
|
|
4677
|
-
return /* @__PURE__ */
|
|
4791
|
+
return /* @__PURE__ */ React10.createElement(React10.Fragment, null, /* @__PURE__ */ React10.createElement("div", { className: "pk-scrim pk-drill-scrim", onPointerDown: (e) => pressed.current = e.target === e.currentTarget, onClick: () => pressed.current && onClose(), "aria-hidden": "true" }), /* @__PURE__ */ React10.createElement(
|
|
4678
4792
|
"div",
|
|
4679
4793
|
{
|
|
4680
4794
|
className: `pk-drill${big && !narrow ? " pk-drill-big" : ""}`,
|
|
@@ -4691,22 +4805,44 @@ function DrillPanel({ drill: source, onClose, labels, locale, exportContext: con
|
|
|
4691
4805
|
}
|
|
4692
4806
|
}
|
|
4693
4807
|
},
|
|
4694
|
-
/* @__PURE__ */
|
|
4695
|
-
/* @__PURE__ */
|
|
4808
|
+
/* @__PURE__ */ React10.createElement("div", { className: "pk-drill-head" }, /* @__PURE__ */ React10.createElement("div", { className: "pk-drill-heading" }, /* @__PURE__ */ React10.createElement("h2", { id }, labels.drillTitle), /* @__PURE__ */ React10.createElement("p", { className: "pk-drill-path" }, drill.title), /* @__PURE__ */ React10.createElement("p", { className: "pk-muted", "data-testid": "drill-count" }, partial ? fill(labels.drillShown, { shown: drill.rows.length.toLocaleString(locale), count: n }) : plural(labels.drillCount, drill.count, { lang: labels.lang, locale }))), /* @__PURE__ */ React10.createElement("div", { className: "pk-drill-actions" }, exportContext ? /* @__PURE__ */ React10.createElement(MenuButton, { label: labels.exportLabel, icon: "download", text: labels.exportLabel, role: "dialog", align: "end", testId: "drill-export", className: "pk-btn pk-small-btn" }, (close) => /* @__PURE__ */ React10.createElement(React10.Fragment, null, partial ? /* @__PURE__ */ React10.createElement("p", { className: "pk-hint pk-menu-hint", "data-testid": "drill-export-note" }, fill(labels.drillExportNote, { shown: drill.rows.length.toLocaleString(locale), count: n })) : null, /* @__PURE__ */ React10.createElement(Section, { title: labels.exportDownload }, /* @__PURE__ */ React10.createElement(ExportOption, { icon: "file", text: labels.drillCsv, onSelect: run("drill-csv", close), testId: "drill-csv" }), /* @__PURE__ */ React10.createElement(ExportOption, { icon: "file", text: labels.drillXlsx, onSelect: run("drill-xlsx", close), testId: "drill-xlsx" })), /* @__PURE__ */ React10.createElement(Section, { title: labels.exportCopy }, /* @__PURE__ */ React10.createElement(ExportOption, { icon: "copy", text: labels.drillCopy, info: "drillCopy", onSelect: run("drill-copy", close), testId: "drill-copy" }), /* @__PURE__ */ React10.createElement(ExportOption, { icon: "copy", text: labels.drillJson, info: "drillJson", onSelect: run("drill-json", close), testId: "drill-json" })))) : null, narrow ? null : /* @__PURE__ */ React10.createElement("button", { type: "button", className: "pk-btn pk-pressable pk-small-btn", "data-pk-on": big ? "" : void 0, onClick: () => setBig((on) => !on), "data-testid": "drill-enlarge" }, /* @__PURE__ */ React10.createElement(Icon, { name: "enlarge", size: 14 }), /* @__PURE__ */ React10.createElement("span", { className: "pk-btn-text" }, big ? labels.reduce : labels.enlarge)), /* @__PURE__ */ React10.createElement("button", { type: "button", className: "pk-icon-btn", onClick: onClose, "data-autofocus": "", "aria-label": labels.close, title: labels.close }, /* @__PURE__ */ React10.createElement(Icon, { name: "x" })))),
|
|
4809
|
+
/* @__PURE__ */ React10.createElement("div", { className: "pk-drill-body", tabIndex: 0, "aria-label": drill.title }, /* @__PURE__ */ React10.createElement("table", { className: "pk-drill-table" }, /* @__PURE__ */ React10.createElement("thead", null, /* @__PURE__ */ React10.createElement("tr", null, drill.columns.map((c) => /* @__PURE__ */ React10.createElement("th", { key: c.name, scope: "col", className: c.numeric ? "pk-num" : void 0, title: c.description, "aria-description": c.description }, c.label ?? c.name)))), /* @__PURE__ */ React10.createElement("tbody", null, drill.rows.map((row, i) => /* @__PURE__ */ React10.createElement("tr", { key: i }, drill.columns.map((c, k) => /* @__PURE__ */ React10.createElement("td", { key: c.name, className: c.numeric ? "pk-num" : void 0 }, c.numeric || row[k].length < 24 ? row[k] : /* @__PURE__ */ React10.createElement("div", { className: "pk-drill-text" }, row[k]))))))))
|
|
4696
4810
|
));
|
|
4697
4811
|
}
|
|
4698
4812
|
|
|
4813
|
+
// src/point-menu.jsx
|
|
4814
|
+
import React11, { useMemo as useMemo5 } from "react";
|
|
4815
|
+
function PointMenu({ target, onClose, onRows, view, encoded, locale, labels, commit, showRows = true }) {
|
|
4816
|
+
const anchor = useMemo5(() => ({ current: target ? target.anchor : null }), [target]);
|
|
4817
|
+
const actions = target ? pointActions(view, target.point, encoded, labels, locale, { showRows }) : [];
|
|
4818
|
+
const close = () => {
|
|
4819
|
+
target?.home?.focus({ preventScroll: true });
|
|
4820
|
+
onClose();
|
|
4821
|
+
};
|
|
4822
|
+
const pick2 = (a) => {
|
|
4823
|
+
close();
|
|
4824
|
+
if (a.id === "rows") {
|
|
4825
|
+
onRows(target?.point);
|
|
4826
|
+
} else if (a.change) {
|
|
4827
|
+
const { view: next, note } = a.change();
|
|
4828
|
+
commit(next, note);
|
|
4829
|
+
}
|
|
4830
|
+
};
|
|
4831
|
+
const name = target ? [target.point.rowLabel, target.point.colLabel].filter(Boolean).join(", ") : "";
|
|
4832
|
+
return /* @__PURE__ */ React11.createElement(Popover, { open: Boolean(target) && actions.length > 0, anchor, onClose: close, label: fill(labels.pointMenu, { name }), role: "menu", className: "pk-point-menu" }, /* @__PURE__ */ React11.createElement(Group, { title: name, menu: true }, actions.map((a) => /* @__PURE__ */ React11.createElement(Option, { key: a.id, inMenu: true, icon: a.id === "rows" ? "table" : a.id.startsWith("only") ? "filter" : "x", hint: a.field, onSelect: () => pick2(a), testId: `point-${a.id}` }, a.text))));
|
|
4833
|
+
}
|
|
4834
|
+
|
|
4699
4835
|
// src/data-menu.jsx
|
|
4700
|
-
import
|
|
4836
|
+
import React12, { useEffect as useEffect5, useRef as useRef5, useState as useState9 } from "react";
|
|
4701
4837
|
function DataMenu({ api, close, labels }) {
|
|
4702
4838
|
const mod = importNow();
|
|
4703
|
-
const [failed, setFailed] =
|
|
4704
|
-
const [attempt, setAttempt] =
|
|
4839
|
+
const [failed, setFailed] = useState9(false);
|
|
4840
|
+
const [attempt, setAttempt] = useState9(0);
|
|
4705
4841
|
const box = useRef5(
|
|
4706
4842
|
/** @type {HTMLDivElement | null} */
|
|
4707
4843
|
null
|
|
4708
4844
|
);
|
|
4709
|
-
const [late] =
|
|
4845
|
+
const [late] = useState9(() => !mod);
|
|
4710
4846
|
const load = useRef5(api.load);
|
|
4711
4847
|
useEffect5(() => {
|
|
4712
4848
|
load.current = api.load;
|
|
@@ -4728,10 +4864,10 @@ function DataMenu({ api, close, labels }) {
|
|
|
4728
4864
|
popover.querySelector("[data-pk-option], [data-autofocus]")?.focus({ preventScroll: true });
|
|
4729
4865
|
}
|
|
4730
4866
|
}, [late, mod, failed]);
|
|
4731
|
-
return /* @__PURE__ */
|
|
4867
|
+
return /* @__PURE__ */ React12.createElement("div", { ref: box }, mod ? /* @__PURE__ */ React12.createElement(mod.DataMenuPanel, { api, close }) : failed ? /* @__PURE__ */ React12.createElement("div", { className: "pk-menu-failed", role: "alert", "data-testid": "menu-failed" }, /* @__PURE__ */ React12.createElement("p", null, labels.menuFailed), /* @__PURE__ */ React12.createElement("button", { type: "button", className: "pk-btn pk-small-btn", "data-autofocus": "", onClick: () => {
|
|
4732
4868
|
setFailed(false);
|
|
4733
4869
|
setAttempt((n) => n + 1);
|
|
4734
|
-
} }, labels.tryAgain)) : /* @__PURE__ */
|
|
4870
|
+
} }, labels.tryAgain)) : /* @__PURE__ */ React12.createElement("p", { className: "pk-hint pk-menu-loading", role: "status" }, labels.loadingMenu));
|
|
4735
4871
|
}
|
|
4736
4872
|
export {
|
|
4737
4873
|
AddMenu,
|
|
@@ -4744,6 +4880,7 @@ export {
|
|
|
4744
4880
|
FilterPopover,
|
|
4745
4881
|
LoadCheck,
|
|
4746
4882
|
MorePanel,
|
|
4883
|
+
PointMenu,
|
|
4747
4884
|
TableSettingsPanel,
|
|
4748
4885
|
ValueMenu,
|
|
4749
4886
|
ViewsPanel,
|