pivotkit-react 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +121 -1
- package/README.md +1 -1
- package/dist/chunks/{chunk-32Z33U6S.js → chunk-6MDAL3IO.js} +28 -3
- package/dist/chunks/{chunk-APB4NW4O.js → chunk-LEN5RPBM.js} +3 -6
- package/dist/chunks/{chunk-7CC4JHDY.js → chunk-WB4GKWFQ.js} +1 -4
- package/dist/chunks/chunk-XN55BQ4M.js +618 -0
- package/dist/chunks/{chunk-IOPAM4JD.js → chunk-YITKWZ4L.js} +48 -492
- package/dist/chunks/chunk-ZYEYZSYL.js +187 -0
- package/dist/import-ui.js +769 -0
- package/dist/import-worker.js +20 -0
- package/dist/index.js +599 -175
- package/dist/labels.js +14 -10
- package/dist/menu-texts-de.js +1 -1
- package/dist/menus.js +132 -68
- package/dist/styles.css +116 -8
- package/package.json +3 -2
- package/types/data-history.d.ts +85 -0
- package/types/data-keep.d.ts +51 -0
- package/types/data-menu.d.ts +11 -0
- package/types/dom.d.ts +40 -7
- package/types/field-info.d.ts +32 -0
- package/types/import-host.d.ts +53 -0
- package/types/import-labels.d.ts +360 -0
- package/types/import-module.d.ts +2 -0
- package/types/import-run.d.ts +73 -0
- package/types/import-source.d.ts +32 -0
- package/types/import-steps.d.ts +121 -0
- package/types/import-ui.d.ts +108 -0
- package/types/import-worker.d.ts +1 -0
- package/types/index.d.ts +56 -4
- package/types/labels.d.ts +26 -2
- package/types/lazy-import.d.ts +4 -0
- package/types/lazy-menus.d.ts +2 -2
- package/types/levels.d.ts +3 -2
- package/types/menu-labels.d.ts +0 -3
- package/types/menu-topics.d.ts +2 -4
- package/types/menus.d.ts +1 -0
- package/types/overflow.d.ts +29 -17
- package/types/popover.d.ts +47 -5
- package/types/section.d.ts +2 -2
- package/types/toasts.d.ts +1 -1
- package/types/toolbar-panels.d.ts +6 -5
- package/types/unused-keep.d.ts +20 -0
- package/types/unused.d.ts +1 -0
- package/types/use-view-history.d.ts +12 -4
- package/types/virtual.d.ts +15 -0
package/dist/menus.js
CHANGED
|
@@ -3,16 +3,10 @@ import {
|
|
|
3
3
|
CHART_TYPE_NAMES,
|
|
4
4
|
ClearInput,
|
|
5
5
|
HelpContext,
|
|
6
|
-
Icon,
|
|
7
6
|
InfoButton,
|
|
8
|
-
LayerContext,
|
|
9
|
-
MenuButton,
|
|
10
|
-
Option,
|
|
11
|
-
Popover,
|
|
12
7
|
SHORTCUTS,
|
|
13
8
|
SLICE_TYPES,
|
|
14
9
|
ZONES,
|
|
15
|
-
activeIn,
|
|
16
10
|
axisOf,
|
|
17
11
|
chartTypeOf,
|
|
18
12
|
clone,
|
|
@@ -24,6 +18,7 @@ import {
|
|
|
24
18
|
groupField,
|
|
25
19
|
groupingName,
|
|
26
20
|
groupingOf,
|
|
21
|
+
importNow,
|
|
27
22
|
isoDay,
|
|
28
23
|
itemRuleText,
|
|
29
24
|
linkNow,
|
|
@@ -38,7 +33,6 @@ import {
|
|
|
38
33
|
relativeDays,
|
|
39
34
|
relativeText,
|
|
40
35
|
reorder,
|
|
41
|
-
rootOf,
|
|
42
36
|
same,
|
|
43
37
|
sameRef,
|
|
44
38
|
selectedItems,
|
|
@@ -48,32 +42,44 @@ import {
|
|
|
48
42
|
sortOf,
|
|
49
43
|
sortText,
|
|
50
44
|
sourceOf,
|
|
51
|
-
useModal,
|
|
52
45
|
valueConditionText,
|
|
53
46
|
valueLabel,
|
|
54
47
|
viewFromObject,
|
|
55
48
|
viewFromText,
|
|
56
49
|
wholeYears,
|
|
57
50
|
withLinkParam
|
|
58
|
-
} from "./chunks/chunk-
|
|
51
|
+
} from "./chunks/chunk-YITKWZ4L.js";
|
|
59
52
|
import {
|
|
60
53
|
addMenuTexts,
|
|
61
54
|
hasMenuTexts,
|
|
62
55
|
menuLabels
|
|
63
|
-
} from "./chunks/chunk-
|
|
56
|
+
} from "./chunks/chunk-LEN5RPBM.js";
|
|
57
|
+
import {
|
|
58
|
+
Group,
|
|
59
|
+
Icon,
|
|
60
|
+
LayerContext,
|
|
61
|
+
MenuButton,
|
|
62
|
+
Option,
|
|
63
|
+
Popover,
|
|
64
|
+
activeIn,
|
|
65
|
+
rootOf,
|
|
66
|
+
stopAfter,
|
|
67
|
+
useFormName,
|
|
68
|
+
useModal
|
|
69
|
+
} from "./chunks/chunk-XN55BQ4M.js";
|
|
64
70
|
import {
|
|
65
71
|
fill,
|
|
66
72
|
hostFailure,
|
|
67
73
|
messageOf,
|
|
68
74
|
plural
|
|
69
|
-
} from "./chunks/chunk-
|
|
75
|
+
} from "./chunks/chunk-6MDAL3IO.js";
|
|
70
76
|
|
|
71
77
|
// src/chip-menus.jsx
|
|
72
|
-
import React6, { useId as
|
|
78
|
+
import React6, { useId as useId4, useState as useState4 } from "react";
|
|
73
79
|
import { fieldLabel as fieldLabel4 } from "pivotkit-core";
|
|
74
80
|
|
|
75
81
|
// src/filter-level.jsx
|
|
76
|
-
import React5, { useContext as useContext3, useEffect as useEffect2, useId as
|
|
82
|
+
import React5, { useContext as useContext3, useEffect as useEffect2, useId as useId3, useMemo as useMemo2, useRef as useRef2, useState as useState3 } from "react";
|
|
77
83
|
import { CATALOG as CATALOG4, LIMITS, fieldItems as fieldItems2, fieldLabel as fieldLabel3, formatter as formatter2 } from "pivotkit-core";
|
|
78
84
|
|
|
79
85
|
// src/filter.jsx
|
|
@@ -317,6 +323,7 @@ var FILTER_LIST_MAX = 300;
|
|
|
317
323
|
var keyOf = (v) => JSON.stringify(v);
|
|
318
324
|
function ValueList({ items, selected, onChange, labels, locale, autoFocus = false, tail, children }) {
|
|
319
325
|
const [query, setQuery] = useState("");
|
|
326
|
+
const name = useFormName();
|
|
320
327
|
const q = query.trim().toLocaleLowerCase();
|
|
321
328
|
const matching = q ? items.filter((i) => i.label.toLocaleLowerCase().includes(q)) : items;
|
|
322
329
|
const inList = tail ? matching.filter((i) => !tail.isOut(i)) : matching;
|
|
@@ -345,12 +352,13 @@ function ValueList({ items, selected, onChange, labels, locale, autoFocus = fals
|
|
|
345
352
|
};
|
|
346
353
|
const row = (i, muted) => {
|
|
347
354
|
const k = keyOf(i.value);
|
|
348
|
-
return /* @__PURE__ */ React.createElement("li", { key: k, className: `pk-value${muted ? " pk-value-out" : ""}` }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("input", { type: "checkbox", checked: selected.has(k), onChange: () => toggle(i.value) }), /* @__PURE__ */ React.createElement("span", { className: "pk-value-label" }, i.label), /* @__PURE__ */ React.createElement("span", { className: "pk-count" }, i.count.toLocaleString(locale))), /* @__PURE__ */ React.createElement("button", { type: "button", className: "pk-link pk-only", onClick: () => onChange(/* @__PURE__ */ new Set([k])), "aria-label": `${labels.onlyThis}: ${i.label}` }, labels.onlyThis));
|
|
355
|
+
return /* @__PURE__ */ React.createElement("li", { key: k, className: `pk-value${muted ? " pk-value-out" : ""}` }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement("input", { type: "checkbox", name, checked: selected.has(k), onChange: () => toggle(i.value) }), /* @__PURE__ */ React.createElement("span", { className: "pk-value-label" }, i.label), /* @__PURE__ */ React.createElement("span", { className: "pk-count" }, i.count.toLocaleString(locale))), /* @__PURE__ */ React.createElement("button", { type: "button", className: "pk-link pk-only", onClick: () => onChange(/* @__PURE__ */ new Set([k])), "aria-label": `${labels.onlyThis}: ${i.label}` }, labels.onlyThis));
|
|
349
356
|
};
|
|
350
357
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("label", { className: "pk-search" }, /* @__PURE__ */ React.createElement(Icon, { name: "search" }), /* @__PURE__ */ React.createElement("span", { className: "pk-sr" }, labels.searchValues), /* @__PURE__ */ React.createElement(ClearInput, { type: "search", value: query, placeholder: labels.searchValues, onChange: setQuery, clearLabel: labels.clearText, "data-autofocus": autoFocus ? "" : void 0, "data-testid": "filter-search" })), /* @__PURE__ */ React.createElement("div", { className: "pk-filter-actions" }, /* @__PURE__ */ React.createElement("button", { type: "button", className: "pk-action", onClick: () => setAll(true), "data-testid": "select-all" }, labels.selectAll), /* @__PURE__ */ React.createElement("button", { type: "button", className: "pk-action", onClick: () => setAll(false), "data-testid": "select-none" }, labels.selectNone)), /* @__PURE__ */ React.createElement("div", { className: "pk-filter-body" }, /* @__PURE__ */ React.createElement("ul", { className: "pk-values", role: "list" }, shown.map((i) => row(i, false)), inList.length > shown.length ? /* @__PURE__ */ React.createElement("li", { className: "pk-hint pk-values-more" }, fill(labels.valuesShown, { shown: shown.length, total: inList.length.toLocaleString(locale) })) : null, out.length && tail ? tail.render(out, (i) => row(i, true), q !== "") : null), children));
|
|
351
358
|
}
|
|
352
359
|
function FilterBody({ view: current, base, field, encoded, locale, labels, commit, close }) {
|
|
353
360
|
const view = base ?? current;
|
|
361
|
+
const formName = useFormName();
|
|
354
362
|
const info = useMemo(() => fieldItems(encoded, field, { view, locale, labels: labels.core }), [encoded, field, view, locale, labels]);
|
|
355
363
|
const all = useMemo(() => info ? info.items.map((i) => i.value) : [], [info]);
|
|
356
364
|
const [selected, setSelected] = useState(() => new Set(selectedItems(view, field, all).map(keyOf)));
|
|
@@ -378,7 +386,7 @@ function FilterBody({ view: current, base, field, encoded, locale, labels, commi
|
|
|
378
386
|
}
|
|
379
387
|
},
|
|
380
388
|
/* @__PURE__ */ React.createElement("div", { className: "pk-popover-head" }, /* @__PURE__ */ React.createElement("h3", null, fill(labels.filterTitle, { field: name })), /* @__PURE__ */ React.createElement("span", { className: "pk-muted" }, fill(labels.selected, { count: selected.size.toLocaleString(locale) }))),
|
|
381
|
-
/* @__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", { value: op, onChange: (e) => setOp(e.target.value), "aria-label": kind === "number" ? labels.conditionNumber : labels.condition }, /* @__PURE__ */ React.createElement("option", { value: "" }, labels.conditionNone), CATALOG2.labelOps.map((o) => /* @__PURE__ */ React.createElement("option", { key: o, value: o }, labels.labelOps[o] ?? o))), op ? /* @__PURE__ */ React.createElement(
|
|
389
|
+
/* @__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), CATALOG2.labelOps.map((o) => /* @__PURE__ */ React.createElement("option", { key: o, value: o }, labels.labelOps[o] ?? o))), op ? /* @__PURE__ */ React.createElement(
|
|
382
390
|
ClearInput,
|
|
383
391
|
{
|
|
384
392
|
type: "text",
|
|
@@ -405,10 +413,10 @@ function FilterPopover({ target, onClose, view, encoded, locale, labels, commit
|
|
|
405
413
|
}
|
|
406
414
|
|
|
407
415
|
// src/levels.jsx
|
|
408
|
-
import React3, { useContext as useContext2, useEffect, useId
|
|
416
|
+
import React3, { useContext as useContext2, useEffect, useId, useLayoutEffect, useRef, useState as useState2 } from "react";
|
|
409
417
|
|
|
410
418
|
// src/section.jsx
|
|
411
|
-
import React2, { useContext
|
|
419
|
+
import React2, { useContext } from "react";
|
|
412
420
|
function SettingInfo({ id, name, tabIndex }) {
|
|
413
421
|
const { explain, labels } = useContext(HelpContext);
|
|
414
422
|
const text = labels && labels.settingInfo && Object.hasOwn(labels.settingInfo, id) ? labels.settingInfo[id] : null;
|
|
@@ -418,9 +426,8 @@ function SettingInfo({ id, name, tabIndex }) {
|
|
|
418
426
|
return /* @__PURE__ */ React2.createElement(InfoButton, { info: { description: text }, name, label: fill(labels.aboutSetting, { setting: name }), labels, className: "pk-setting-info", testId: `setting-info-${id}`, tabIndex });
|
|
419
427
|
}
|
|
420
428
|
function Section({ title, children, info }) {
|
|
421
|
-
const titleId = useId();
|
|
422
429
|
const name = typeof title === "string" ? title : "";
|
|
423
|
-
return /* @__PURE__ */ React2.createElement(
|
|
430
|
+
return /* @__PURE__ */ React2.createElement(Group, { title, head: info ? /* @__PURE__ */ React2.createElement(SettingInfo, { id: info, name }) : null }, children);
|
|
424
431
|
}
|
|
425
432
|
|
|
426
433
|
// src/menu-topics.js
|
|
@@ -430,9 +437,9 @@ var MORE_FORMATS = Object.freeze(["integer", "compact", "bytes", "duration:h", "
|
|
|
430
437
|
var COMMON_SHOW_AS = CATALOG3.showAs.filter((s) => ["percentOfGrandTotal", "percentOfRowTotal", "percentOfColumnTotal"].includes(s));
|
|
431
438
|
var EXAMPLE = Object.freeze({ percent: 0.256, bytes: 1536e3, "duration:h": 1.5, "duration:s": 3725 });
|
|
432
439
|
var TOP_COUNTS = Object.freeze([3, 5, 10]);
|
|
433
|
-
function moveTopic(view, zone, index, count, labels, name, type) {
|
|
440
|
+
function moveTopic(view, zone, index, count, labels, name, type, defaults) {
|
|
434
441
|
const note = (z) => ({ step: "moved", field: name, zone: z });
|
|
435
|
-
const choices = ZONES.filter((z) => z !== zone).map((z) => ({ id: `move-${z}`, text: fill(labels.moveTo, { zone: labels.zones[z] }), icon: "chevronRight", closes: true, change: () => ({ view: moveField(view, zone, index, z, void 0, { type }), note: note(z) }) }));
|
|
442
|
+
const choices = ZONES.filter((z) => z !== zone).map((z) => ({ id: `move-${z}`, text: fill(labels.moveTo, { zone: labels.zones[z] }), icon: "chevronRight", closes: true, change: () => ({ view: moveField(view, zone, index, z, void 0, { type, defaults: z === "values" ? defaults : void 0 }), note: note(z) }) }));
|
|
436
443
|
if (zone !== "filters" && index > 0) {
|
|
437
444
|
choices.push({ id: "move-left", text: labels.moveLeft, icon: "chevronRight", closes: true, change: () => ({ view: reorder(view, zone, index, index - 1), note: { step: "reordered", zone } }) });
|
|
438
445
|
}
|
|
@@ -527,7 +534,7 @@ function axisTopics({ view, zone, index, field, types, labels, locale, state, de
|
|
|
527
534
|
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 } }) }
|
|
528
535
|
}))
|
|
529
536
|
});
|
|
530
|
-
topics.push(moveTopic(view, zone, index, view[zone].length, labels, name, sourceType));
|
|
537
|
+
topics.push(moveTopic(view, zone, index, view[zone].length, labels, name, sourceType, defaultsOf?.(field)));
|
|
531
538
|
return topics;
|
|
532
539
|
}
|
|
533
540
|
var NUMBER_TYPED = /\d+/;
|
|
@@ -825,10 +832,11 @@ function tabLeaves(e, close) {
|
|
|
825
832
|
/** @type {Element} */
|
|
826
833
|
e.target
|
|
827
834
|
);
|
|
828
|
-
|
|
835
|
+
const next = opener ? stopAfter(opener) : null;
|
|
836
|
+
e.preventDefault();
|
|
837
|
+
next?.focus();
|
|
838
|
+
if (opener && (!next || activeIn(next) !== next)) {
|
|
829
839
|
opener.focus({ preventScroll: true });
|
|
830
|
-
} else {
|
|
831
|
-
e.preventDefault();
|
|
832
840
|
}
|
|
833
841
|
close();
|
|
834
842
|
return true;
|
|
@@ -932,7 +940,7 @@ function MenuList({ label, labelledBy, className, close, children, testId }) {
|
|
|
932
940
|
}
|
|
933
941
|
function MenuItem({ id, text, onSelect, checked, checkbox, hint, icon, danger, testId, start, plain, label, className, disabled, reason, haspopup, level, description, current, children }) {
|
|
934
942
|
const role = checked === void 0 ? "menuitem" : checkbox ? "menuitemcheckbox" : "menuitemradio";
|
|
935
|
-
const reasonId =
|
|
943
|
+
const reasonId = useId();
|
|
936
944
|
const describedBy = [disabled && reason ? reasonId : null, description ? `${reasonId}-d` : null].filter(Boolean).join(" ") || void 0;
|
|
937
945
|
return /* @__PURE__ */ React3.createElement(
|
|
938
946
|
"button",
|
|
@@ -999,21 +1007,17 @@ function TopicRow({ topic, labels, onOpen }) {
|
|
|
999
1007
|
);
|
|
1000
1008
|
}
|
|
1001
1009
|
function Groups({ topic, onPick }) {
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
});
|
|
1007
|
-
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, groups, topic.note ? /* @__PURE__ */ React3.createElement("p", { className: "pk-hint pk-menu-hint", role: "none", "data-testid": topic.noteId }, topic.note) : null);
|
|
1010
|
+
return /* @__PURE__ */ React3.createElement(React3.Fragment, null, (topic.groups ?? []).map((g, i) => /* @__PURE__ */ React3.createElement(Group, { key: i, menu: true, title: g.title, label: g.title ? void 0 : topic.title }, g.choices.map((c) => /* @__PURE__ */ React3.createElement(ChoiceItem, { key: c.id, choice: c, start: c.checked, onPick })))), /* @__PURE__ */ React3.createElement(TopicNote, { topic }));
|
|
1011
|
+
}
|
|
1012
|
+
function TopicNote({ topic }) {
|
|
1013
|
+
return topic.note ? /* @__PURE__ */ React3.createElement("p", { className: "pk-hint pk-menu-hint", role: "none", "data-testid": topic.noteId }, topic.note) : null;
|
|
1008
1014
|
}
|
|
1009
1015
|
function TopicFirst({ topic, labels, onPick, onOpen }) {
|
|
1010
|
-
const titleId = useId2();
|
|
1011
1016
|
if (topic.hidden) {
|
|
1012
1017
|
return null;
|
|
1013
1018
|
}
|
|
1014
1019
|
if (topic.kind === "menu" || topic.kind === "panel") {
|
|
1015
|
-
|
|
1016
|
-
return topic.heading ? /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement("div", { className: "pk-subtitle", id: titleId, role: "presentation", "data-testid": `topic-title-${topic.id}` }, topic.heading), /* @__PURE__ */ React3.createElement("div", { role: "group", "aria-labelledby": titleId }, row)) : row;
|
|
1020
|
+
return /* @__PURE__ */ React3.createElement(TopicRow, { topic, labels, onOpen });
|
|
1017
1021
|
}
|
|
1018
1022
|
const choices = topic.groups?.[0]?.choices ?? [];
|
|
1019
1023
|
if (topic.kind === "segmented") {
|
|
@@ -1025,7 +1029,8 @@ function TopicFirst({ topic, labels, onPick, onOpen }) {
|
|
|
1025
1029
|
) }) : null), topic.title, topic.changed && !topic.state ? /* @__PURE__ */ React3.createElement("span", { className: "pk-section-mark" }, " \u25CF") : null), topic.state ? /* @__PURE__ */ React3.createElement("span", { className: "pk-topic-state pk-topic-seg-state", "data-testid": `topic-state-${topic.id}` }, topic.changed ? /* @__PURE__ */ React3.createElement("span", { className: "pk-section-mark", "aria-hidden": "true" }, "\u25CF ") : null, /* @__PURE__ */ React3.createElement("span", { className: "pk-badge-cut" }, topic.state)) : null, /* @__PURE__ */ React3.createElement("span", { className: "pk-segmented pk-small" }, choices.map((c) => /* @__PURE__ */ React3.createElement("button", { key: c.id, type: "button", role: "menuitemradio", "aria-checked": Boolean(c.checked), tabIndex: -1, "data-pk-option": "", "data-pk-item": c.id, "data-pk-text": c.text, "data-testid": c.id, onClick: () => onPick(c) }, c.text))))
|
|
1026
1030
|
);
|
|
1027
1031
|
}
|
|
1028
|
-
|
|
1032
|
+
const items = choices.map((c) => /* @__PURE__ */ React3.createElement(ChoiceItem, { key: c.id, choice: c, onPick }));
|
|
1033
|
+
return topic.titled ? /* @__PURE__ */ React3.createElement(Group, { menu: true, title: topic.title, testId: `topic-${topic.id}`, titleTestId: `topic-title-${topic.id}`, after: /* @__PURE__ */ React3.createElement(TopicNote, { topic }) }, items) : /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement("div", { role: "group", "aria-label": topic.title, "data-testid": `topic-${topic.id}` }, items), /* @__PURE__ */ React3.createElement(TopicNote, { topic }));
|
|
1029
1034
|
}
|
|
1030
1035
|
function SearchHits({ hits, labels, onPick, onOpen, close }) {
|
|
1031
1036
|
if (!hits.length) {
|
|
@@ -1044,7 +1049,7 @@ function LevelMenu({ name, labels, topics, close, onPick, panel, head, foot, sea
|
|
|
1044
1049
|
/** @type {HTMLDivElement | null} */
|
|
1045
1050
|
null
|
|
1046
1051
|
);
|
|
1047
|
-
const titleId =
|
|
1052
|
+
const titleId = useId();
|
|
1048
1053
|
const topic = level ? topics.find((t) => t.id === level) ?? null : null;
|
|
1049
1054
|
useLayoutEffect(() => {
|
|
1050
1055
|
const el = box.current;
|
|
@@ -1213,7 +1218,7 @@ function useAppliedText(applied, apply, wait = 450) {
|
|
|
1213
1218
|
}
|
|
1214
1219
|
|
|
1215
1220
|
// src/menu-fields.jsx
|
|
1216
|
-
import React4, { useId as
|
|
1221
|
+
import React4, { useId as useId2 } from "react";
|
|
1217
1222
|
|
|
1218
1223
|
// src/numbers.js
|
|
1219
1224
|
var cache = /* @__PURE__ */ new Map();
|
|
@@ -1283,11 +1288,13 @@ function readNumber(text, { kind = "number", required = true, tried = false, max
|
|
|
1283
1288
|
return ok ? { value, problem: null } : { value: null, problem: say() };
|
|
1284
1289
|
}
|
|
1285
1290
|
function NumberField({ value, onChange, problem, label, testId, className = "pk-field-label", shown, shownClass, onKeyDown, onBlur, onFocus, autoFocus }) {
|
|
1286
|
-
const id =
|
|
1291
|
+
const id = useId2();
|
|
1292
|
+
const name = useFormName();
|
|
1287
1293
|
return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement("label", { className }, shown ? /* @__PURE__ */ React4.createElement("span", { className: shownClass }, shown) : /* @__PURE__ */ React4.createElement("span", { className: "pk-sr" }, label), /* @__PURE__ */ React4.createElement(
|
|
1288
1294
|
"input",
|
|
1289
1295
|
{
|
|
1290
1296
|
type: "text",
|
|
1297
|
+
name,
|
|
1291
1298
|
inputMode: "decimal",
|
|
1292
1299
|
autoComplete: "off",
|
|
1293
1300
|
spellCheck: false,
|
|
@@ -1317,10 +1324,11 @@ var fieldKeys = ({ now, restore, back }) => (e) => {
|
|
|
1317
1324
|
}
|
|
1318
1325
|
};
|
|
1319
1326
|
function MeasurePick({ choices, names, index, onChange, label, prefix, testId }) {
|
|
1327
|
+
const name = useFormName();
|
|
1320
1328
|
if (choices.length < 2) {
|
|
1321
1329
|
return /* @__PURE__ */ React4.createElement("span", { className: "pk-by", "data-testid": testId }, prefix ? `${prefix} ${names[0]}` : names[0]);
|
|
1322
1330
|
}
|
|
1323
|
-
return /* @__PURE__ */ React4.createElement("label", { className: "pk-field-label pk-by-pick" }, prefix ? /* @__PURE__ */ React4.createElement("span", null, prefix) : /* @__PURE__ */ React4.createElement("span", { className: "pk-sr" }, label), /* @__PURE__ */ React4.createElement("select", { value: index, onChange: (e) => onChange(Number(e.target.value)), "aria-label": label, "data-testid": testId }, choices.map((c, i) => /* @__PURE__ */ React4.createElement("option", { key: `${c.field}:${c.agg}`, value: i }, names[i]))));
|
|
1331
|
+
return /* @__PURE__ */ React4.createElement("label", { className: "pk-field-label pk-by-pick" }, prefix ? /* @__PURE__ */ React4.createElement("span", null, prefix) : /* @__PURE__ */ React4.createElement("span", { className: "pk-sr" }, label), /* @__PURE__ */ React4.createElement("select", { name, value: index, onChange: (e) => onChange(Number(e.target.value)), "aria-label": label, "data-testid": testId }, choices.map((c, i) => /* @__PURE__ */ React4.createElement("option", { key: `${c.field}:${c.agg}`, value: i }, names[i]))));
|
|
1324
1332
|
}
|
|
1325
1333
|
var choiceIndex = (choices, ref) => Math.max(0, choices.findIndex((c) => sameRef(c, ref)));
|
|
1326
1334
|
function measuresOf(view, types, labels, ref) {
|
|
@@ -1373,7 +1381,7 @@ function yearsOf(column, counts) {
|
|
|
1373
1381
|
}
|
|
1374
1382
|
function LeftOut({ out, row, searching, labels, locale }) {
|
|
1375
1383
|
const [open, setOpen] = useState3(false);
|
|
1376
|
-
const id =
|
|
1384
|
+
const id = useId3();
|
|
1377
1385
|
const shown = open || searching;
|
|
1378
1386
|
const list = useRef2(
|
|
1379
1387
|
/** @type {HTMLUListElement | null} */
|
|
@@ -1387,7 +1395,7 @@ function LeftOut({ out, row, searching, labels, locale }) {
|
|
|
1387
1395
|
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);
|
|
1388
1396
|
}
|
|
1389
1397
|
function Section2({ id, title, state, open, onToggle, action, children }) {
|
|
1390
|
-
const bodyId =
|
|
1398
|
+
const bodyId = useId3();
|
|
1391
1399
|
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);
|
|
1392
1400
|
}
|
|
1393
1401
|
function Summary({ ctx, state }) {
|
|
@@ -1458,7 +1466,8 @@ function QuickChoices({ ctx, quick, anchor, setAnchorLocal, span, column, counts
|
|
|
1458
1466
|
setTexts(synced);
|
|
1459
1467
|
}
|
|
1460
1468
|
const later = useLater();
|
|
1461
|
-
const group =
|
|
1469
|
+
const group = useId3();
|
|
1470
|
+
const groupName = useFormName();
|
|
1462
1471
|
const set = (range) => commit(setQuickRange(view, field, range ? { ...range, anchor } : null), note);
|
|
1463
1472
|
const sub = (range, unit, id) => {
|
|
1464
1473
|
const share = rangeShare(range, unit, span, locale);
|
|
@@ -1470,7 +1479,7 @@ function QuickChoices({ ctx, quick, anchor, setAnchorLocal, span, column, counts
|
|
|
1470
1479
|
return /* @__PURE__ */ React5.createElement("span", { className: "pk-quick-sub", id: subId(id) }, /* @__PURE__ */ React5.createElement("span", null, period, missing ? /* @__PURE__ */ React5.createElement("span", { className: "pk-quick-missing" }, "(", missing, ")") : null), /* @__PURE__ */ React5.createElement("span", { className: "pk-quick-rows" }, fill(labels.quickRows, { rows: rowsIn(range, column, counts).toLocaleString(locale) })));
|
|
1471
1480
|
};
|
|
1472
1481
|
const subId = (id) => `${group}-${id}`;
|
|
1473
|
-
const radio = (id, checked, onPick, name, children, sub2, described = Boolean(sub2)) => /* @__PURE__ */ React5.createElement("label", { className: "pk-radio pk-quick", key: id }, /* @__PURE__ */ React5.createElement("input", { type: "radio", name:
|
|
1482
|
+
const radio = (id, checked, onPick, name, children, sub2, described = Boolean(sub2)) => /* @__PURE__ */ React5.createElement("label", { className: "pk-radio pk-quick", key: id }, /* @__PURE__ */ React5.createElement("input", { type: "radio", name: groupName, checked, onChange: onPick, "aria-label": name, "aria-describedby": described ? subId(id) : void 0, "data-autofocus": checked && ctx.hint !== "conditions" ? "" : void 0, "data-testid": `quick-${id}` }), children, sub2);
|
|
1474
1483
|
const hidden = [];
|
|
1475
1484
|
const rows = [radio("all", quick.id === "all" || quick.id === "custom", () => set(null), labels.filterAll, /* @__PURE__ */ React5.createElement("span", null, labels.filterAll), /* @__PURE__ */ React5.createElement("span", { className: "pk-quick-sub", id: subId("all") }, /* @__PURE__ */ React5.createElement("span", null, `${dayText(isoDay(span.min), locale)}\u2013${dayText(latestDay, locale)}`), /* @__PURE__ */ React5.createElement("span", { className: "pk-quick-rows" }, fill(labels.quickRows, { rows: column.codes.length.toLocaleString(locale) }))))];
|
|
1476
1485
|
const thisYear = days("year", 1);
|
|
@@ -1547,11 +1556,13 @@ function QuickChoices({ ctx, quick, anchor, setAnchorLocal, span, column, counts
|
|
|
1547
1556
|
const today = new Date(relativeDays({ unit: "day", count: 1 }, timeZone, now)?.from ?? isoDay(now));
|
|
1548
1557
|
const periodStart = fk.months ? Date.UTC(today.getUTCFullYear(), today.getUTCMonth(), 1) : Date.UTC(today.getUTCFullYear(), 0, 1);
|
|
1549
1558
|
const showAnchor = latest < periodStart;
|
|
1550
|
-
const anchorId =
|
|
1559
|
+
const anchorId = useId3();
|
|
1560
|
+
const anchorName = useFormName();
|
|
1551
1561
|
return /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement("div", { role: "radiogroup", "aria-label": labels.quickTitle, className: "pk-radios pk-quick-choices", "data-testid": "quick-choices" }, rows), showAnchor ? /* @__PURE__ */ React5.createElement("div", { className: "pk-quick-anchor" }, /* @__PURE__ */ React5.createElement("label", { htmlFor: anchorId }, labels.anchorLabel), /* @__PURE__ */ React5.createElement(
|
|
1552
1562
|
"select",
|
|
1553
1563
|
{
|
|
1554
1564
|
id: anchorId,
|
|
1565
|
+
name: anchorName,
|
|
1555
1566
|
value: anchor,
|
|
1556
1567
|
onChange: (e) => {
|
|
1557
1568
|
const next = (
|
|
@@ -1589,7 +1600,8 @@ function ItemPicker({ items, value, onChange, label, testId, labels, locale }) {
|
|
|
1589
1600
|
/** @type {HTMLButtonElement | null} */
|
|
1590
1601
|
null
|
|
1591
1602
|
);
|
|
1592
|
-
const listId =
|
|
1603
|
+
const listId = useId3();
|
|
1604
|
+
const searchName = useFormName();
|
|
1593
1605
|
const q = query.trim().toLocaleLowerCase();
|
|
1594
1606
|
const found = q ? items.filter((i) => i.label.toLocaleLowerCase().includes(q)) : items;
|
|
1595
1607
|
const matching = found.slice(0, FILTER_LIST_MAX);
|
|
@@ -1643,6 +1655,7 @@ function ItemPicker({ items, value, onChange, label, testId, labels, locale }) {
|
|
|
1643
1655
|
"input",
|
|
1644
1656
|
{
|
|
1645
1657
|
type: "search",
|
|
1658
|
+
name: searchName,
|
|
1646
1659
|
role: "combobox",
|
|
1647
1660
|
className: "pk-picker-search",
|
|
1648
1661
|
value: query,
|
|
@@ -1693,6 +1706,7 @@ function ItemRule({ rule, ctx, apply, first }) {
|
|
|
1693
1706
|
unit: ranged?.unit ?? "year"
|
|
1694
1707
|
}));
|
|
1695
1708
|
const later = useLater();
|
|
1709
|
+
const formName = useFormName();
|
|
1696
1710
|
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);
|
|
1697
1711
|
const entryOf = (x) => {
|
|
1698
1712
|
if (x.op === "last") {
|
|
@@ -1734,20 +1748,20 @@ function ItemRule({ rule, ctx, apply, first }) {
|
|
|
1734
1748
|
return /* @__PURE__ */ React5.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" });
|
|
1735
1749
|
}
|
|
1736
1750
|
if (fk.item === "date") {
|
|
1737
|
-
return /* @__PURE__ */ React5.createElement("input", { type: "date", value: s[key], onChange: (e) => change({ [key]: e.target.value }), "aria-label": label2, "data-testid": testId });
|
|
1751
|
+
return /* @__PURE__ */ React5.createElement("input", { type: "date", name: `${formName}-${key}`, value: s[key], onChange: (e) => change({ [key]: e.target.value }), "aria-label": label2, "data-testid": testId });
|
|
1738
1752
|
}
|
|
1739
1753
|
const listed = items.filter((i) => typeof i.value === "number");
|
|
1740
1754
|
const own = s[key] !== "" && !listed.some((i) => String(i.value) === s[key]);
|
|
1741
1755
|
if (listed.length >= PICKER_MIN && !narrow) {
|
|
1742
1756
|
return /* @__PURE__ */ React5.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 });
|
|
1743
1757
|
}
|
|
1744
|
-
return /* @__PURE__ */ React5.createElement("select", { value: s[key], onChange: (e) => change({ [key]: e.target.value }), "aria-label": label2, "data-testid": testId }, /* @__PURE__ */ React5.createElement("option", { value: "", disabled: true }, labels.ruleValue), own ? /* @__PURE__ */ React5.createElement("option", { value: s[key] }, s[key]) : null, listed.map((i) => /* @__PURE__ */ React5.createElement("option", { key: String(i.value), value: String(i.value) }, i.label)));
|
|
1758
|
+
return /* @__PURE__ */ React5.createElement("select", { name: `${formName}-${key}`, value: s[key], onChange: (e) => change({ [key]: e.target.value }), "aria-label": label2, "data-testid": testId }, /* @__PURE__ */ React5.createElement("option", { value: "", disabled: true }, labels.ruleValue), own ? /* @__PURE__ */ React5.createElement("option", { value: s[key] }, s[key]) : null, listed.map((i) => /* @__PURE__ */ React5.createElement("option", { key: String(i.value), value: String(i.value) }, i.label)));
|
|
1745
1759
|
};
|
|
1746
1760
|
const label = fk.item === "date" ? labels.ruleDate : labels.ruleValue;
|
|
1747
1761
|
const lang = { lang: labels.lang, locale };
|
|
1748
1762
|
const counted = readNumber(s.count, { kind: "count", max: CATALOG4.relativeMaxCount, labels, locale });
|
|
1749
1763
|
const many = counted.value ?? 2;
|
|
1750
|
-
return /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement("span", { className: "pk-rule-subject" }, fieldLabel3(field, labels.core)), /* @__PURE__ */ React5.createElement("select", { className: "pk-rule-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__ */ React5.createElement("option", { key: o, value: o }, o === "last" ? plural(labels.lastOp, many, lang) : words[o] ?? o))), s.op === "last" ? /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement(
|
|
1764
|
+
return /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement("span", { className: "pk-rule-subject" }, fieldLabel3(field, labels.core)), /* @__PURE__ */ React5.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__ */ React5.createElement("option", { key: o, value: o }, o === "last" ? plural(labels.lastOp, many, lang) : words[o] ?? o))), s.op === "last" ? /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement(
|
|
1751
1765
|
NumberField,
|
|
1752
1766
|
{
|
|
1753
1767
|
value: s.count,
|
|
@@ -1759,13 +1773,14 @@ function ItemRule({ rule, ctx, apply, first }) {
|
|
|
1759
1773
|
testId: "rule-last-count",
|
|
1760
1774
|
className: "pk-field-label pk-count-input"
|
|
1761
1775
|
}
|
|
1762
|
-
), /* @__PURE__ */ React5.createElement("select", { value: s.unit, onChange: (e) => change({ unit: e.target.value }), "aria-label": labels.ruleUnit, "data-testid": "rule-last-unit" }, CATALOG4.relativeUnits.map((u) => /* @__PURE__ */ React5.createElement("option", { key: u, value: u }, plural(labels.ruleUnits[u], many, lang))))) : /* @__PURE__ */ React5.createElement(React5.Fragment, null, value("a", label, "rule-item-value"), twin(s.op) ? /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement("span", null, labels.valueFilterTo), value("b", `${labels.valueFilterTo} ${label}`, "rule-item-value2")) : null, s.op === "!=" || s.op === "notBetween" ? /* @__PURE__ */ React5.createElement("span", { className: "pk-hint pk-rule-note", "data-testid": "rule-blanks" }, labels.blanksOut) : null));
|
|
1776
|
+
), /* @__PURE__ */ React5.createElement("select", { name: `${formName}-unit`, value: s.unit, onChange: (e) => change({ unit: e.target.value }), "aria-label": labels.ruleUnit, "data-testid": "rule-last-unit" }, CATALOG4.relativeUnits.map((u) => /* @__PURE__ */ React5.createElement("option", { key: u, value: u }, plural(labels.ruleUnits[u], many, lang))))) : /* @__PURE__ */ React5.createElement(React5.Fragment, null, value("a", label, "rule-item-value"), twin(s.op) ? /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement("span", null, labels.valueFilterTo), value("b", `${labels.valueFilterTo} ${label}`, "rule-item-value2")) : null, s.op === "!=" || s.op === "notBetween" ? /* @__PURE__ */ React5.createElement("span", { className: "pk-hint pk-rule-note", "data-testid": "rule-blanks" }, labels.blanksOut) : null));
|
|
1763
1777
|
}
|
|
1764
1778
|
function TotalRule({ rule, ctx, apply, first }) {
|
|
1765
1779
|
const { view, types, labels, locale } = ctx;
|
|
1766
1780
|
const { choices, names } = measuresOf(view, types, labels, rule?.by);
|
|
1767
1781
|
const [s, setS] = useState3(() => ({ by: choiceIndex(choices, rule?.by), op: rule?.op ?? ">", a: numberText(rule?.value, locale), b: numberText(rule?.value2, locale) }));
|
|
1768
1782
|
const later = useLater();
|
|
1783
|
+
const formName = useFormName();
|
|
1769
1784
|
const change = (patch, wait = false) => {
|
|
1770
1785
|
const next = { ...s, ...patch };
|
|
1771
1786
|
setS(next);
|
|
@@ -1794,7 +1809,7 @@ function TotalRule({ rule, ctx, apply, first }) {
|
|
|
1794
1809
|
};
|
|
1795
1810
|
const keys = fieldKeys({ now: later.now, restore, back: ctx.back });
|
|
1796
1811
|
const number = (key, label, testId, shown) => /* @__PURE__ */ React5.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" });
|
|
1797
|
-
return /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement("span", { className: "pk-rule-subject pk-rule-lead" }, fill(labels.ruleWhose, { field: fieldLabel3(ctx.field, labels.core) })), /* @__PURE__ */ React5.createElement(MeasurePick, { choices, names, index: s.by, onChange: (i) => change({ by: i }), label: labels.valueFilterBy, testId: "value-filter-by" }), /* @__PURE__ */ React5.createElement("select", { className: "pk-rule-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" }, CATALOG4.valueOps.map((o) => /* @__PURE__ */ React5.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);
|
|
1812
|
+
return /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement("span", { className: "pk-rule-subject pk-rule-lead" }, fill(labels.ruleWhose, { field: fieldLabel3(ctx.field, labels.core) })), /* @__PURE__ */ React5.createElement(MeasurePick, { choices, names, index: s.by, onChange: (i) => change({ by: i }), label: labels.valueFilterBy, testId: "value-filter-by" }), /* @__PURE__ */ React5.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" }, CATALOG4.valueOps.map((o) => /* @__PURE__ */ React5.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);
|
|
1798
1813
|
}
|
|
1799
1814
|
function NameRule({ rule, ctx, apply, first }) {
|
|
1800
1815
|
const { field, labels } = ctx;
|
|
@@ -1805,10 +1820,12 @@ function NameRule({ rule, ctx, apply, first }) {
|
|
|
1805
1820
|
}
|
|
1806
1821
|
};
|
|
1807
1822
|
const text = useAppliedText(rule?.value ?? "", (value) => send(op, value));
|
|
1823
|
+
const opName = useFormName();
|
|
1808
1824
|
return /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement("span", { className: "pk-rule-subject" }, labels.ruleName), /* @__PURE__ */ React5.createElement(
|
|
1809
1825
|
"select",
|
|
1810
1826
|
{
|
|
1811
1827
|
className: "pk-rule-op",
|
|
1828
|
+
name: opName,
|
|
1812
1829
|
value: op,
|
|
1813
1830
|
onChange: (e) => {
|
|
1814
1831
|
setOp(e.target.value);
|
|
@@ -2216,7 +2233,7 @@ function TopLevel({ view, field, types, labels, locale, commit, back }) {
|
|
|
2216
2233
|
set({ count: n, bottom: s.bottom, by: choices[s.by] });
|
|
2217
2234
|
}
|
|
2218
2235
|
};
|
|
2219
|
-
const groupName =
|
|
2236
|
+
const groupName = useFormName();
|
|
2220
2237
|
const radio = (id, text, checked, onPick) => /* @__PURE__ */ React6.createElement("label", { className: "pk-radio" }, /* @__PURE__ */ React6.createElement("input", { type: "radio", name: groupName, checked, onChange: onPick, "data-autofocus": checked ? "" : void 0, "data-testid": `top-${id}` }), /* @__PURE__ */ React6.createElement("span", null, text));
|
|
2221
2238
|
return /* @__PURE__ */ React6.createElement("div", { className: "pk-level-form" }, /* @__PURE__ */ React6.createElement("div", { role: "radiogroup", "aria-label": labels.topN, className: "pk-radios" }, radio("off", labels.off, !top && !own, () => {
|
|
2222
2239
|
setOwn(false);
|
|
@@ -2280,7 +2297,7 @@ function BinsLevel({ view, field, labels, locale, range, regroup, back }) {
|
|
|
2280
2297
|
const [size, setSize] = useState4(numberText(bins?.size, locale));
|
|
2281
2298
|
const [start, setStart] = useState4(numberText(bins?.origin, locale));
|
|
2282
2299
|
const [tried, setTried] = useState4(false);
|
|
2283
|
-
const problemId =
|
|
2300
|
+
const problemId = useId4();
|
|
2284
2301
|
const sized = readNumber(size, { kind: "size", tried, labels, locale });
|
|
2285
2302
|
const started = readNumber(start, { required: false, labels, locale });
|
|
2286
2303
|
const n = sized.value;
|
|
@@ -2445,7 +2462,7 @@ function ValueMenu({ view, index, types, labels, commit, close, onRemove, defaul
|
|
|
2445
2462
|
}
|
|
2446
2463
|
|
|
2447
2464
|
// src/toolbar-panels.jsx
|
|
2448
|
-
import React7, { useEffect as useEffect3, useId as
|
|
2465
|
+
import React7, { useEffect as useEffect3, useId as useId5, useRef as useRef3, useState as useState5 } from "react";
|
|
2449
2466
|
import { VIEW_FILE_LIMITS } from "pivotkit-core";
|
|
2450
2467
|
|
|
2451
2468
|
// src/share-actions.js
|
|
@@ -2530,7 +2547,7 @@ async function copyText(text, container) {
|
|
|
2530
2547
|
}
|
|
2531
2548
|
|
|
2532
2549
|
// src/version.js
|
|
2533
|
-
var VERSION = true ? "0.
|
|
2550
|
+
var VERSION = true ? "0.4.0" : "0.0.0-source";
|
|
2534
2551
|
|
|
2535
2552
|
// src/share-actions.js
|
|
2536
2553
|
var here = () => typeof location !== "undefined" ? location.href : void 0;
|
|
@@ -2771,6 +2788,10 @@ function ChartTitle({ title, labels, onDisplay }) {
|
|
|
2771
2788
|
/* @__PURE__ */ React7.createElement("button", { type: "submit", className: "pk-btn pk-primary", disabled: (text.trim() || null) === (title ?? null) }, labels.apply)
|
|
2772
2789
|
);
|
|
2773
2790
|
}
|
|
2791
|
+
function Sub({ title, info, children }) {
|
|
2792
|
+
const titleId = useId5();
|
|
2793
|
+
return /* @__PURE__ */ React7.createElement("div", { className: "pk-subsection", role: title ? "group" : void 0, "aria-labelledby": title ? titleId : void 0 }, title ? /* @__PURE__ */ React7.createElement("div", { className: `pk-subtitle${info ? " pk-setting-row" : ""}` }, /* @__PURE__ */ React7.createElement("span", { id: titleId }, title), info ? /* @__PURE__ */ React7.createElement(SettingInfo, { id: info, name: title }) : null) : null, children);
|
|
2794
|
+
}
|
|
2774
2795
|
function ChartDisplay({ view, plan, labels, onDisplay }) {
|
|
2775
2796
|
const chart = view.chart;
|
|
2776
2797
|
const drawn = plan ? plan.name : chartTypeOf(chart);
|
|
@@ -2778,7 +2799,7 @@ function ChartDisplay({ view, plan, labels, onDisplay }) {
|
|
|
2778
2799
|
const axis = CHART_TYPES[drawn].axis;
|
|
2779
2800
|
const choices = pie ? VALUE_LABELS.slices : VALUE_LABELS.other;
|
|
2780
2801
|
const valueLabels = !pie && (chart.valueLabels === "percent" || chart.valueLabels === "both") ? "value" : chart.valueLabels;
|
|
2781
|
-
return /* @__PURE__ */ React7.createElement(Section, { title: labels.chartDisplay }, /* @__PURE__ */ React7.createElement(
|
|
2802
|
+
return /* @__PURE__ */ React7.createElement(Section, { title: labels.chartDisplay }, /* @__PURE__ */ React7.createElement(Sub, { title: labels.valueLabels }, /* @__PURE__ */ React7.createElement("div", { className: "pk-choice-grid" }, choices.map((v) => /* @__PURE__ */ React7.createElement(Option, { key: v, checked: valueLabels === v, onSelect: () => onDisplay({ valueLabels: v }), testId: `labels-${v}` }, labels.valueLabelNames[v])))), pie ? /* @__PURE__ */ React7.createElement(Sub, { title: labels.labelPosition, info: "labelPosition" }, /* @__PURE__ */ React7.createElement("div", { className: "pk-choice-grid" }, LABEL_POSITIONS.map((v) => /* @__PURE__ */ React7.createElement(Option, { key: v, checked: (chart.labelPosition ?? "outside") === v, disabled: chart.valueLabels === "off", onSelect: () => onDisplay({ labelPosition: v }), testId: `label-position-${v}` }, labels.labelPositionNames[v])))) : null, /* @__PURE__ */ React7.createElement(Sub, { title: labels.legend }, /* @__PURE__ */ React7.createElement("div", { className: "pk-choice-grid" }, LEGENDS.map((v) => /* @__PURE__ */ React7.createElement(Option, { key: v, checked: chart.legend === v, onSelect: () => onDisplay({ legend: v }), testId: `legend-${v}` }, labels.legendNames[v])))), /* @__PURE__ */ React7.createElement(Sub, { title: labels.chartTitle }, /* @__PURE__ */ React7.createElement(ChartTitle, { title: chart.title, labels, onDisplay })), axis ? /* @__PURE__ */ React7.createElement(Sub, { title: labels.axisLabels }, /* @__PURE__ */ React7.createElement("div", { className: "pk-choice-grid" }, AXIS_LABELS.map((v) => /* @__PURE__ */ React7.createElement(Option, { key: v, checked: chart.axisLabels === v, onSelect: () => onDisplay({ axisLabels: v }), testId: `axis-${v}` }, labels.axisLabelNames[v])))) : null, axis && view.rows.length >= 2 ? /* @__PURE__ */ React7.createElement(Sub, { title: labels.groupLabels, info: "groupLabels" }, /* @__PURE__ */ React7.createElement("div", { className: "pk-choice-grid" }, GROUP_LABELS.map((v) => /* @__PURE__ */ React7.createElement(Option, { key: v, checked: chart.groupLabels === v, onSelect: () => onDisplay({ groupLabels: v }), testId: `groups-${v}` }, labels.groupLabelNames[v])))) : null, drawn === "line" || drawn === "area" ? /* @__PURE__ */ React7.createElement(Sub, null, /* @__PURE__ */ React7.createElement(Switch, { checked: chart.smooth, onChange: (on) => onDisplay({ smooth: on }), testId: "chart-smooth" }, labels.smoothLines)) : null);
|
|
2782
2803
|
}
|
|
2783
2804
|
function ChartTypePanel({ view, plan, labels, onChart, onDisplay, close }) {
|
|
2784
2805
|
return /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement(Section, { title: labels.chartType }, /* @__PURE__ */ React7.createElement("div", { className: "pk-choice-grid" }, /* @__PURE__ */ React7.createElement(ChartTypeOptions, { view, plan, labels, onChart, close }))), /* @__PURE__ */ React7.createElement(ChartDisplay, { view, plan, labels, onDisplay }));
|
|
@@ -2788,7 +2809,8 @@ function Shortcuts({ labels, mod }) {
|
|
|
2788
2809
|
return /* @__PURE__ */ React7.createElement("dl", { className: "pk-shortcuts", "data-testid": "shortcuts" }, SHORTCUTS.map((s) => /* @__PURE__ */ React7.createElement("div", { key: s.text, className: "pk-shortcut" }, /* @__PURE__ */ React7.createElement("dt", null, s.keys.map((k, i) => /* @__PURE__ */ React7.createElement(React7.Fragment, { key: k }, i ? " + " : null, /* @__PURE__ */ React7.createElement("kbd", null, key(k))))), /* @__PURE__ */ React7.createElement("dd", null, labels.shortcuts[s.text]))));
|
|
2789
2810
|
}
|
|
2790
2811
|
function Switch({ checked, onChange, testId, children }) {
|
|
2791
|
-
|
|
2812
|
+
const name = useFormName();
|
|
2813
|
+
return /* @__PURE__ */ React7.createElement("label", { className: "pk-switch" }, /* @__PURE__ */ React7.createElement("input", { type: "checkbox", name, checked, onChange: (e) => onChange(e.target.checked), "data-testid": testId }), /* @__PURE__ */ React7.createElement("span", { className: "pk-switch-track", "aria-hidden": "true" }), /* @__PURE__ */ React7.createElement("span", { className: "pk-switch-text" }, children));
|
|
2792
2814
|
}
|
|
2793
2815
|
function OptionsPanel({ view, labels, onTotal, onExpand, onCollapse, close, tips, mod, folding, help }) {
|
|
2794
2816
|
const topics = optionTopics({
|
|
@@ -2885,7 +2907,7 @@ function SaveView({ labels, button, onSave, resolve, close }) {
|
|
|
2885
2907
|
);
|
|
2886
2908
|
}
|
|
2887
2909
|
function LoadCheck({ check, labels, onCancel, close, title, quiet = false }) {
|
|
2888
|
-
const titleId =
|
|
2910
|
+
const titleId = useId5();
|
|
2889
2911
|
const first = useRef3(
|
|
2890
2912
|
/** @type {HTMLButtonElement | null} */
|
|
2891
2913
|
null
|
|
@@ -2922,7 +2944,8 @@ function LoadView({ labels, onLoadText, close }) {
|
|
|
2922
2944
|
/** @type {HTMLTextAreaElement | null} */
|
|
2923
2945
|
null
|
|
2924
2946
|
);
|
|
2925
|
-
const problemId =
|
|
2947
|
+
const problemId = useId5();
|
|
2948
|
+
const fileName = useFormName();
|
|
2926
2949
|
useEffect3(() => {
|
|
2927
2950
|
if (!check) {
|
|
2928
2951
|
field.current?.focus({ preventScroll: true });
|
|
@@ -2979,10 +3002,12 @@ function LoadView({ labels, onLoadText, close }) {
|
|
|
2979
3002
|
{
|
|
2980
3003
|
ref: file,
|
|
2981
3004
|
type: "file",
|
|
3005
|
+
name: `${fileName}-file`,
|
|
2982
3006
|
accept: "application/json,.json",
|
|
2983
3007
|
className: "pk-sr",
|
|
2984
3008
|
tabIndex: -1,
|
|
2985
3009
|
"aria-hidden": "true",
|
|
3010
|
+
"aria-label": labels.chooseFile,
|
|
2986
3011
|
"data-testid": "load-view-file",
|
|
2987
3012
|
onChange: async (e) => {
|
|
2988
3013
|
const chosen = e.target.files?.[0];
|
|
@@ -3089,11 +3114,13 @@ function ViewsPanel({ templates, labels, onLoad, actions, close, share }) {
|
|
|
3089
3114
|
if (canSaveAs(can)) {
|
|
3090
3115
|
thisView.push({ id: "save-as", text: actions.loaded ? labels.saveAs : `${labels.saveView}\u2026`, icon: "save", open: "saveAs" });
|
|
3091
3116
|
}
|
|
3092
|
-
thisView.push({ id: "new-report", text: labels.newEmpty, icon: "newFile", disabled: !actions.canNew, reason: actions.canNew ? void 0 : labels.newAlready, info: "newReport", closes: true, run: () => actions.onNew() });
|
|
3093
3117
|
const act = share ? shareActions(share, labels) : null;
|
|
3094
3118
|
const question = asking?.kind === "replaceShared" ? { text: fill(labels.replaceSharedConfirm, { name: actions.loaded?.name }), action: labels.replaceAction, testId: "replace-shared-confirm", yesId: "confirm-replace-shared", noId: "cancel-replace-shared" } : asking ? { text: fill(asking.kind === "publish" ? labels.publishConfirm : labels.deleteConfirm, { name: asking.t.name }), action: asking.kind === "publish" ? labels.publishAction : labels.deleteAction, testId: `${asking.kind}-confirm`, yesId: `confirm-${asking.kind}`, noId: `cancel-${asking.kind}` } : null;
|
|
3095
3119
|
const topics = [
|
|
3096
|
-
{ id: "thisView", title: labels.thisView, kind:
|
|
3120
|
+
...thisView.length ? [{ id: "thisView", title: labels.thisView, kind: (
|
|
3121
|
+
/** @type {const} */
|
|
3122
|
+
"inline"
|
|
3123
|
+
), titled: true, groups: [{ choices: thisView }] }] : [],
|
|
3097
3124
|
...shared.length ? [{ id: "sharedViews", title: labels.sharedViews, kind: (
|
|
3098
3125
|
/** @type {const} */
|
|
3099
3126
|
"inline"
|
|
@@ -3116,14 +3143,12 @@ function ViewsPanel({ templates, labels, onLoad, actions, close, share }) {
|
|
|
3116
3143
|
...act ? [
|
|
3117
3144
|
{
|
|
3118
3145
|
id: "share",
|
|
3119
|
-
title: labels.
|
|
3120
|
-
// under a heading of its own, like the lists before it
|
|
3121
|
-
heading: labels.shareThisView,
|
|
3146
|
+
title: labels.shareThisView,
|
|
3122
3147
|
kind: (
|
|
3123
3148
|
/** @type {const} */
|
|
3124
|
-
"
|
|
3149
|
+
"inline"
|
|
3125
3150
|
),
|
|
3126
|
-
|
|
3151
|
+
titled: true,
|
|
3127
3152
|
groups: [
|
|
3128
3153
|
{
|
|
3129
3154
|
choices: [
|
|
@@ -3204,7 +3229,7 @@ function ExportPanel({ labels, onExport, chartReady, display, empty = false, pre
|
|
|
3204
3229
|
}
|
|
3205
3230
|
|
|
3206
3231
|
// src/drill-panel.jsx
|
|
3207
|
-
import React8, { useContext as useContext4, useEffect as useEffect4, useId as
|
|
3232
|
+
import React8, { useContext as useContext4, useEffect as useEffect4, useId as useId6, useMemo as useMemo3, useRef as useRef4, useState as useState6 } from "react";
|
|
3208
3233
|
|
|
3209
3234
|
// src/export-run.js
|
|
3210
3235
|
import { toGrid } from "pivotkit-core";
|
|
@@ -3374,7 +3399,7 @@ function drillOf({ result, rowPath, colPath, count, indices, formatOf, nameOf, i
|
|
|
3374
3399
|
|
|
3375
3400
|
// src/drill-panel.jsx
|
|
3376
3401
|
function DrillPanel({ drill: source, onClose, labels, locale, exportContext }) {
|
|
3377
|
-
const id =
|
|
3402
|
+
const id = useId6();
|
|
3378
3403
|
const drill = useMemo3(() => source ? drillOf(source, labels) : null, [source, labels]);
|
|
3379
3404
|
const panel = useRef4(
|
|
3380
3405
|
/** @type {HTMLDivElement | null} */
|
|
@@ -3420,9 +3445,48 @@ function DrillPanel({ drill: source, onClose, labels, locale, exportContext }) {
|
|
|
3420
3445
|
/* @__PURE__ */ React8.createElement("div", { className: "pk-drill-body", tabIndex: 0, "aria-label": drill.title }, /* @__PURE__ */ React8.createElement("table", { className: "pk-drill-table" }, /* @__PURE__ */ React8.createElement("thead", null, /* @__PURE__ */ React8.createElement("tr", null, drill.columns.map((c) => /* @__PURE__ */ React8.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__ */ React8.createElement("tbody", null, drill.rows.map((row, i) => /* @__PURE__ */ React8.createElement("tr", { key: i }, drill.columns.map((c, k) => /* @__PURE__ */ React8.createElement("td", { key: c.name, className: c.numeric ? "pk-num" : void 0 }, c.numeric || row[k].length < 24 ? row[k] : /* @__PURE__ */ React8.createElement("div", { className: "pk-drill-text" }, row[k]))))))))
|
|
3421
3446
|
));
|
|
3422
3447
|
}
|
|
3448
|
+
|
|
3449
|
+
// src/data-menu.jsx
|
|
3450
|
+
import React9, { useEffect as useEffect5, useRef as useRef5, useState as useState7 } from "react";
|
|
3451
|
+
function DataMenu({ api, close, labels }) {
|
|
3452
|
+
const mod = importNow();
|
|
3453
|
+
const [failed, setFailed] = useState7(false);
|
|
3454
|
+
const [attempt, setAttempt] = useState7(0);
|
|
3455
|
+
const box = useRef5(
|
|
3456
|
+
/** @type {HTMLDivElement | null} */
|
|
3457
|
+
null
|
|
3458
|
+
);
|
|
3459
|
+
const [late] = useState7(() => !mod);
|
|
3460
|
+
const load = useRef5(api.load);
|
|
3461
|
+
useEffect5(() => {
|
|
3462
|
+
load.current = api.load;
|
|
3463
|
+
});
|
|
3464
|
+
useEffect5(() => {
|
|
3465
|
+
if (mod) {
|
|
3466
|
+
return void 0;
|
|
3467
|
+
}
|
|
3468
|
+
let live = true;
|
|
3469
|
+
load.current().catch(() => live && setFailed(true));
|
|
3470
|
+
return () => {
|
|
3471
|
+
live = false;
|
|
3472
|
+
};
|
|
3473
|
+
}, [mod, attempt]);
|
|
3474
|
+
useEffect5(() => {
|
|
3475
|
+
const popover = box.current?.closest(".pk-popover");
|
|
3476
|
+
const now = activeIn(popover);
|
|
3477
|
+
if (late && popover && (now === popover || !now || !popover.contains(now))) {
|
|
3478
|
+
popover.querySelector("[data-pk-option], [data-autofocus]")?.focus({ preventScroll: true });
|
|
3479
|
+
}
|
|
3480
|
+
}, [late, mod, failed]);
|
|
3481
|
+
return /* @__PURE__ */ React9.createElement("div", { ref: box }, mod ? /* @__PURE__ */ React9.createElement(mod.DataMenuPanel, { api, close }) : failed ? /* @__PURE__ */ React9.createElement("div", { className: "pk-menu-failed", role: "alert", "data-testid": "menu-failed" }, /* @__PURE__ */ React9.createElement("p", null, labels.menuFailed), /* @__PURE__ */ React9.createElement("button", { type: "button", className: "pk-btn pk-small-btn", "data-autofocus": "", onClick: () => {
|
|
3482
|
+
setFailed(false);
|
|
3483
|
+
setAttempt((n) => n + 1);
|
|
3484
|
+
} }, labels.tryAgain)) : /* @__PURE__ */ React9.createElement("p", { className: "pk-hint pk-menu-loading", role: "status" }, labels.loadingMenu));
|
|
3485
|
+
}
|
|
3423
3486
|
export {
|
|
3424
3487
|
AxisMenu,
|
|
3425
3488
|
ChartTypePanel,
|
|
3489
|
+
DataMenu,
|
|
3426
3490
|
DrillPanel,
|
|
3427
3491
|
ExportPanel,
|
|
3428
3492
|
FilterMenu,
|