pivotkit-react 0.5.0 → 0.6.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/dist/menus.js CHANGED
@@ -56,12 +56,16 @@ import {
56
56
  viewFromText,
57
57
  wholeYears,
58
58
  withLinkParam
59
- } from "./chunks/chunk-2AT72SLA.js";
59
+ } from "./chunks/chunk-2RAVX4DO.js";
60
60
  import {
61
61
  addMenuTexts,
62
62
  hasMenuTexts,
63
63
  menuLabels
64
- } from "./chunks/chunk-U5Q5I2D5.js";
64
+ } from "./chunks/chunk-TR2HROIK.js";
65
+ import {
66
+ listedFor,
67
+ sheetOfSource
68
+ } from "./chunks/chunk-W2KIPREL.js";
65
69
  import {
66
70
  Group,
67
71
  Icon,
@@ -80,7 +84,7 @@ import {
80
84
  hostFailure,
81
85
  messageOf,
82
86
  plural
83
- } from "./chunks/chunk-3WUGQPWV.js";
87
+ } from "./chunks/chunk-XN5HNKJ2.js";
84
88
 
85
89
  // src/chip-menus.jsx
86
90
  import React6, { useId as useId4, useMemo as useMemo3, useState as useState4 } from "react";
@@ -147,16 +151,17 @@ function replaceFilters(view, field, types, entries) {
147
151
  }
148
152
  return next;
149
153
  }
150
- function replaceFilter(view, field, previous, entry) {
154
+ function replaceFilter(view, field, previous, entry, before = null) {
151
155
  const next = clone(view);
152
- const key = previous ? JSON.stringify(previous) : null;
153
- const at = key === null ? -1 : next.filters.findIndex((f) => same(f.field, field) && JSON.stringify(f) === key);
156
+ const indexOf = (f) => f ? next.filters.findIndex((g) => same(g.field, field) && JSON.stringify(g) === JSON.stringify(f)) : -1;
157
+ const at = indexOf(previous);
154
158
  if (at === -1) {
155
159
  if (!entry) {
156
160
  return next;
157
161
  }
162
+ const ahead = indexOf(before);
158
163
  const last = next.filters.map((f) => same(f.field, field)).lastIndexOf(true);
159
- next.filters.splice(last + 1, 0, entry);
164
+ next.filters.splice(ahead === -1 ? last + 1 : ahead, 0, entry);
160
165
  return next;
161
166
  }
162
167
  if (entry) {
@@ -189,7 +194,7 @@ function setTopFilter(view, field, top, previous) {
189
194
  }
190
195
  var RULE_TYPES = Object.freeze(["relative", "compare", "value", "text"]);
191
196
  var RULES_MAX = 10;
192
- var setRule = (view, field, previous, entry) => replaceFilter(view, field, previous, entry);
197
+ var setRule = (view, field, previous, entry, before = null) => replaceFilter(view, field, previous, entry, before);
193
198
  var COARSE = Object.freeze(["year", "yearQuarter"]);
194
199
  var QUICK_UNITS = Object.freeze(["day", "week", "month", "quarter", "year"]);
195
200
  var FINEST = Object.freeze({ day: "day", yearWeek: "week", yearMonth: "month", yearQuarter: "quarter", year: "year" });
@@ -1981,12 +1986,14 @@ function TotalRule({ rule, ctx, apply, first }) {
1981
1986
  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" });
1982
1987
  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" }, RULE_OPS.compare.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);
1983
1988
  }
1984
- function NameRule({ rule, ctx, apply, first }) {
1989
+ function NameRule({ rule, ctx, apply, unset, first }) {
1985
1990
  const { field, labels } = ctx;
1986
1991
  const [op, setOp] = useState3(rule ? ruleOp(rule) : "contains");
1987
1992
  const send = (o, value) => {
1988
- if (value !== "") {
1993
+ if (value.trim() !== "") {
1989
1994
  apply({ ...textRule(field, { op: o, value, on: ctx.textOn }), ...rule ? { blanks: rule.blanks } : {} });
1995
+ } else if (rule) {
1996
+ unset();
1990
1997
  }
1991
1998
  };
1992
1999
  const text = useAppliedText(rule?.value ?? "", (value) => send(op, value));
@@ -2035,6 +2042,10 @@ function RuleEditor({ ctx, rules, focusFirst, quickLine, results, blanks }) {
2035
2042
  /** @type {"item" | "total" | "name" | null} */
2036
2043
  null
2037
2044
  );
2045
+ const [held, setHeld] = useState3(
2046
+ /** @type {Array<{ at: number, kind: "item" | "total" | "name", blanks?: string }>} */
2047
+ []
2048
+ );
2038
2049
  const blanksName = useFormName();
2039
2050
  const [info, setInfo] = useState3(
2040
2051
  /** @type {number | null} */
@@ -2052,6 +2063,7 @@ function RuleEditor({ ctx, rules, focusFirst, quickLine, results, blanks }) {
2052
2063
  if (rulesKey !== own) {
2053
2064
  setGen(gen + 1);
2054
2065
  setDraft(null);
2066
+ setHeld([]);
2055
2067
  }
2056
2068
  }
2057
2069
  const box = useRef2(
@@ -2086,7 +2098,7 @@ function RuleEditor({ ctx, rules, focusFirst, quickLine, results, blanks }) {
2086
2098
  /** @type {Array<"item" | "total" | "name">} */
2087
2099
  ["item", "total", "name"].filter((k) => k === "item" ? Boolean(fk.item) : k === "name" ? Boolean(nameKind) : true)
2088
2100
  );
2089
- const count = rules.length + (draft ? 1 : 0);
2101
+ const count = rules.length + (draft ? 1 : 0) + held.length;
2090
2102
  const full = count >= RULES_MAX || view.filters.length >= LIMITS2.filters;
2091
2103
  const addText = { item: fill(labels.addRuleItem, { field: fieldLabel3(field, labels.core) }), total: labels.addRuleTotal, name: labels.addRuleName };
2092
2104
  const infoText = (rule, kind) => {
@@ -2100,32 +2112,59 @@ function RuleEditor({ ctx, rules, focusFirst, quickLine, results, blanks }) {
2100
2112
  }
2101
2113
  return fill(labels.ruleInfo[fk.item === "group" ? fk.cyclic ? "cyclic" : "group" : fk.item ?? "group"], { noun: one });
2102
2114
  };
2103
- const row = (rule, kind, i) => {
2115
+ const commitOwn = (next) => {
2116
+ setOwn(rulesKeyOf(filtersOf(next, field, RULE_TYPES).filter((f) => !ctx.quickFilters.includes(f))));
2117
+ commit(next, note);
2118
+ };
2119
+ const row = (rule, kind, i, isHeld = false) => {
2104
2120
  const Row = ROWS[kind];
2105
2121
  const apply = (entry) => {
2106
- const own2 = !rule && ctx.keepBlanks && ITEM_RULE_TYPES.includes(entry.type) ? { ...entry, blanks: "include" } : entry;
2107
- const next = setRule(view, field, rule, own2);
2108
- setOwn(rulesKeyOf(filtersOf(next, field, RULE_TYPES).filter((f) => !ctx.quickFilters.includes(f))));
2109
- if (!rule) {
2122
+ const was = isHeld ? held.find((h) => h.at === i) : void 0;
2123
+ const own2 = was?.blanks && ITEM_RULE_TYPES.includes(entry.type) ? { ...entry, blanks: was.blanks } : !rule && ctx.keepBlanks && ITEM_RULE_TYPES.includes(entry.type) ? { ...entry, blanks: "include" } : entry;
2124
+ if (isHeld) {
2125
+ setHeld(held.filter((h) => h.at !== i));
2126
+ } else if (!rule) {
2110
2127
  setDraft(null);
2111
2128
  }
2112
- commit(next, note);
2129
+ const before = isHeld ? rows.slice(i + 1).find((x) => x.rule)?.rule ?? null : null;
2130
+ commitOwn(setRule(view, field, rule, own2, before));
2131
+ };
2132
+ const unset = () => {
2133
+ if (rule) {
2134
+ setHeld([...held, { at: i, kind, blanks: rule.blanks }].sort((a, b) => a.at - b.at));
2135
+ ctx.keepSections();
2136
+ commitOwn(setRule(view, field, rule, null));
2137
+ }
2113
2138
  };
2114
2139
  const remove = () => {
2115
2140
  focusAdd.current = true;
2116
2141
  if (rule) {
2117
2142
  commit(setRule(view, field, rule, null), note);
2118
2143
  } else {
2119
- setDraft(null);
2144
+ if (isHeld) {
2145
+ setHeld(held.filter((h) => h.at !== i));
2146
+ } else {
2147
+ setDraft(null);
2148
+ }
2120
2149
  setGen(gen + 1);
2150
+ if (rows.length === 1) {
2151
+ ctx.releaseSections();
2152
+ }
2121
2153
  }
2122
2154
  };
2123
2155
  const result = rule ? results.get(rule) : null;
2124
2156
  const open = info === i;
2125
2157
  const infoId = `${gen}-${i}`;
2126
- return /* @__PURE__ */ React5.createElement("li", { key: `${gen}:${i}`, className: "pk-rule", "data-testid": "rule", "data-kind": kind }, i > 0 || quickLine ? /* @__PURE__ */ React5.createElement("span", { className: "pk-rule-and" }, labels.ruleAnd) : null, /* @__PURE__ */ React5.createElement("span", { className: "pk-rule-body" }, /* @__PURE__ */ React5.createElement(Row, { rule, ctx, apply, first: focusFirst && i === 0 || !rule && draft !== null })), /* @__PURE__ */ React5.createElement("span", { className: "pk-rule-tools" }, explain ? /* @__PURE__ */ React5.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__ */ React5.createElement(Icon, { name: "info", size: 14 })) : null, /* @__PURE__ */ React5.createElement("button", { type: "button", className: "pk-icon-btn pk-rule-remove", onClick: remove, "aria-label": labels.removeRule, title: labels.removeRule, "data-testid": "rule-remove" }, /* @__PURE__ */ React5.createElement(Icon, { name: "x", size: 14 }))), /* @__PURE__ */ React5.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__ */ React5.createElement("p", { className: "pk-rule-info-text", id: infoId, "data-testid": "rule-info-text" }, infoText(rule, kind)) : null);
2158
+ return /* @__PURE__ */ React5.createElement("li", { key: `${gen}:${i}`, className: "pk-rule", "data-testid": "rule", "data-kind": kind }, i > 0 || quickLine ? /* @__PURE__ */ React5.createElement("span", { className: "pk-rule-and" }, labels.ruleAnd) : null, /* @__PURE__ */ React5.createElement("span", { className: "pk-rule-body" }, /* @__PURE__ */ React5.createElement(Row, { rule, ctx, apply, unset, first: focusFirst && i === 0 || !rule && !isHeld && draft !== null })), /* @__PURE__ */ React5.createElement("span", { className: "pk-rule-tools" }, explain ? /* @__PURE__ */ React5.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__ */ React5.createElement(Icon, { name: "info", size: 14 })) : null, /* @__PURE__ */ React5.createElement("button", { type: "button", className: "pk-icon-btn pk-rule-remove", onClick: remove, "aria-label": labels.removeRule, title: labels.removeRule, "data-testid": "rule-remove" }, /* @__PURE__ */ React5.createElement(Icon, { name: "x", size: 14 }))), /* @__PURE__ */ React5.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__ */ React5.createElement("p", { className: "pk-rule-info-text", id: infoId, "data-testid": "rule-info-text" }, infoText(rule, kind)) : null);
2127
2159
  };
2128
- return /* @__PURE__ */ React5.createElement("fieldset", { ref: box, className: "pk-condition pk-rules", "data-testid": "rules" }, /* @__PURE__ */ React5.createElement("legend", { className: "pk-sr" }, labels.rulesTitle), /* @__PURE__ */ React5.createElement("p", { className: "pk-hint" }, fill(count || quickLine ? labels.rulesKeep : labels.rulesNone, { noun: plural(noun, 2, lang) })), count || quickLine ? /* @__PURE__ */ React5.createElement("ul", { className: "pk-rule-list", role: "list" }, quickLine ? /* @__PURE__ */ React5.createElement("li", { className: "pk-rule pk-rule-quick", "data-testid": "rule-quick" }, /* @__PURE__ */ React5.createElement("span", null, fill(labels.quickLine, { text: quickLine })), /* @__PURE__ */ React5.createElement("button", { type: "button", className: "pk-action", onClick: ctx.focusQuick, "data-testid": "rule-quick-change" }, labels.changeAbove)) : null, [...rules.map((r, i) => row(r, rowKind(r), i)), ...draft ? [row(null, draft, rules.length)] : []]) : null, blanks ? /* @__PURE__ */ React5.createElement("label", { className: "pk-check pk-rules-blanks" }, /* @__PURE__ */ React5.createElement("input", { type: "checkbox", name: `${blanksName}`, checked: blanks.on, onChange: (e) => commit(setRuleBlanks(view, field, e.target.checked), note), "data-testid": "rules-blanks" }), /* @__PURE__ */ React5.createElement("span", null, fill(plural(labels.rulesBlanks, blanks.rows, lang), { rows: blanks.rows.toLocaleString(locale) }))) : null, /* @__PURE__ */ React5.createElement("div", { className: "pk-rule-adds", role: "group", "aria-label": labels.addRule }, kinds.map((k, i) => /* @__PURE__ */ React5.createElement(
2160
+ const rows = rules.map((r) => ({ rule: r, kind: rowKind(r), isHeld: false }));
2161
+ for (const h of held) {
2162
+ rows.splice(h.at, 0, { rule: null, kind: h.kind, isHeld: true });
2163
+ }
2164
+ if (draft) {
2165
+ rows.push({ rule: null, kind: draft, isHeld: false });
2166
+ }
2167
+ return /* @__PURE__ */ React5.createElement("fieldset", { ref: box, className: "pk-condition pk-rules", "data-testid": "rules" }, /* @__PURE__ */ React5.createElement("legend", { className: "pk-sr" }, labels.rulesTitle), /* @__PURE__ */ React5.createElement("p", { className: "pk-hint" }, fill(count || quickLine ? labels.rulesKeep : labels.rulesNone, { noun: plural(noun, 2, lang) })), count || quickLine ? /* @__PURE__ */ React5.createElement("ul", { className: "pk-rule-list", role: "list" }, quickLine ? /* @__PURE__ */ React5.createElement("li", { className: "pk-rule pk-rule-quick", "data-testid": "rule-quick" }, /* @__PURE__ */ React5.createElement("span", null, fill(labels.quickLine, { text: quickLine })), /* @__PURE__ */ React5.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__ */ React5.createElement("label", { className: "pk-check pk-rules-blanks" }, /* @__PURE__ */ React5.createElement("input", { type: "checkbox", name: `${blanksName}`, checked: blanks.on, onChange: (e) => commit(setRuleBlanks(view, field, e.target.checked), note), "data-testid": "rules-blanks" }), /* @__PURE__ */ React5.createElement("span", null, fill(plural(labels.rulesBlanks, blanks.rows, lang), { rows: blanks.rows.toLocaleString(locale) }))) : null, /* @__PURE__ */ React5.createElement("div", { className: "pk-rule-adds", role: "group", "aria-label": labels.addRule }, kinds.map((k, i) => /* @__PURE__ */ React5.createElement(
2129
2168
  "button",
2130
2169
  {
2131
2170
  key: k,
@@ -2334,7 +2373,19 @@ function FilterLevel({ view, field, encoded, types, labels, locale, commit, back
2334
2373
  });
2335
2374
  };
2336
2375
  const keepBlanks = keepsBlanks(view, field);
2337
- const ctx = { view, field, types, labels, locale, commit, note, back, fk, nameKind, say, textOn: textOn(encoded, field), timeZone, hint, items: info.items, noun, scope, quickFilters: quick.filters, focusQuick, act, keepBlanks };
2376
+ const keepSections = () => {
2377
+ if (rules.length === 1 && !quick.filters.length) {
2378
+ byHand.current = true;
2379
+ setOpenPicks(openPicks ?? !anyRule);
2380
+ setOpenRules(openRules ?? anyRule);
2381
+ }
2382
+ };
2383
+ const releaseSections = () => {
2384
+ setOpenPicks(null);
2385
+ setOpenRules(null);
2386
+ lost.current = true;
2387
+ };
2388
+ const ctx = { view, field, types, labels, locale, commit, note, back, fk, nameKind, say, textOn: textOn(encoded, field), timeZone, hint, items: info.items, noun, scope, quickFilters: quick.filters, focusQuick, act, keepBlanks, keepSections, releaseSections };
2338
2389
  const blankRows = info.items.find((i) => i.value === null)?.count ?? 0;
2339
2390
  const blanks = blankRows > 0 && (itemRules.length > 0 || quick.filters.length > 0) ? { rows: blankRows, on: keepBlanks } : null;
2340
2391
  const picksOpen = openPicks ?? !anyRule;
@@ -2738,13 +2789,14 @@ async function copyText(text, container) {
2738
2789
  }
2739
2790
 
2740
2791
  // src/version.js
2741
- var VERSION = true ? "0.5.0" : "0.0.0-source";
2792
+ var VERSION = true ? "0.6.0" : "0.0.0-source";
2742
2793
 
2743
2794
  // src/share-actions.js
2744
2795
  var here = () => typeof location !== "undefined" ? location.href : void 0;
2745
2796
  function shareActions(ctx, labels) {
2746
- const { view, viewName, sourceId, sourceName, schemaUrl, encoded, announce, limits, linkKey } = ctx;
2747
- const viewFile = () => viewFileText(toViewFile(view, { name: viewName ?? "", createdAt: /* @__PURE__ */ new Date(), generator: { name: "pivotkit-react", version: VERSION }, source: { id: sourceId, name: sourceName }, data: encoded, ...schemaUrl !== void 0 ? { schemaUrl } : {} }));
2797
+ const { view, viewName, sourceId, sourceName, sourceParams, schemaUrl, encoded, announce, limits, linkKey } = ctx;
2798
+ const params = sourceParams ? { params: sourceParams } : {};
2799
+ const viewFile = () => viewFileText(toViewFile(view, { name: viewName ?? "", createdAt: /* @__PURE__ */ new Date(), generator: { name: "pivotkit-react", version: VERSION }, source: { id: sourceId, name: sourceName, ...params }, data: encoded, ...schemaUrl !== void 0 ? { schemaUrl } : {} }));
2748
2800
  return {
2749
2801
  copyLink: async () => {
2750
2802
  const target = shareBase(ctx.shareLink, here());
@@ -2753,7 +2805,7 @@ function shareActions(ctx, labels) {
2753
2805
  }
2754
2806
  let text;
2755
2807
  try {
2756
- text = (linkNow() ?? await loadLink()).encodeViewLink(toViewFile(view, { name: viewName ?? void 0, source: { id: sourceId } }, { link: true }));
2808
+ text = (linkNow() ?? await loadLink()).encodeViewLink(toViewFile(view, { name: viewName ?? void 0, source: { id: sourceId, ...params } }, { link: true }));
2757
2809
  } catch (e) {
2758
2810
  announce(e && /** @type {any} */
2759
2811
  e.code === "LIMIT_EXCEEDED" ? labels.toastLinkTooLong : fill(labels.error, { message: String(e) }), { tone: "error" });
@@ -2803,6 +2855,10 @@ function shareActions(ctx, labels) {
2803
2855
  /** @type {import("./share.js").LoadedView} */
2804
2856
  loaded
2805
2857
  );
2858
+ const made = ready.file?.source;
2859
+ if (made && ready.file?.view && ctx.viaSheet?.({ id: made.id, sheet: sheetOfSource(made) }, ready.file.name || viewName || "", toViewFile(ready.file.view, { name: ready.file.name, source: made })) === "switch") {
2860
+ return null;
2861
+ }
2806
2862
  const check = loadCheck(ready, labels, Array.isArray(ctx.sources) ? ctx.sources : []);
2807
2863
  if (!check) {
2808
2864
  ctx.applyLoaded(ready);
@@ -2824,8 +2880,11 @@ function shareActions(ctx, labels) {
2824
2880
 
2825
2881
  // src/view-save.js
2826
2882
  var canSaveAs = (can) => can.host || can.store;
2827
- var isLoadedEntry = (t, loaded) => !!loaded && t.name === loaded.name && (t.scope === "user" ? "user" : "shared") === loaded.scope && t.at !== void 0 === loaded.store && (!loaded.store || (t.sourceId ?? null) === (loaded.storeSource ?? null));
2828
- var storeEntry = (entries, name, source) => entries.find((t) => t.at !== void 0 && t.name === name && (t.sourceId ?? null) === (source ?? null));
2883
+ var isLoadedEntry = (t, loaded) => !!loaded && t.name === loaded.name && (t.scope === "user" ? "user" : "shared") === loaded.scope && t.at !== void 0 === loaded.store && (!loaded.store || (t.sourceId ?? null) === (loaded.storeSource ?? null) && (t.sheet ?? null) === (loaded.storeSheet ?? null));
2884
+ var storeEntry = (entries, name, source, sheet) => {
2885
+ const of = (s) => entries.find((t) => t.at !== void 0 && t.name === name && (t.sourceId ?? null) === (source ?? null) && (t.sheet ?? null) === s);
2886
+ return of(source ? sheet ?? null : null) ?? (source && sheet ? of(null) : void 0);
2887
+ };
2829
2888
  function saveTarget(loaded, entries, can, empty = false) {
2830
2889
  if (!loaded) {
2831
2890
  return null;
@@ -2834,8 +2893,8 @@ function saveTarget(loaded, entries, can, empty = false) {
2834
2893
  if (loaded.scope === "shared") {
2835
2894
  target = can.publish ? { kind: "publish" } : canSaveAs(can) ? { kind: null, why: "saveSharedLocked" } : null;
2836
2895
  } else if (loaded.scope === "user" && loaded.store) {
2837
- const entry = storeEntry(entries, loaded.name, loaded.storeSource);
2838
- target = can.store ? entry ? { kind: "store", at: entry.at, storeSource: loaded.storeSource ?? null } : { kind: "store", storeSource: can.sourceId ?? null } : null;
2896
+ const entry = storeEntry(entries, loaded.name, loaded.storeSource, loaded.storeSheet);
2897
+ target = can.store ? entry ? { kind: "store", at: entry.at, storeSource: loaded.storeSource ?? null, storeSheet: loaded.storeSheet ?? null } : { kind: "store", storeSource: can.sourceId ?? null, storeSheet: can.sheet ?? null } : null;
2839
2898
  } else if (loaded.scope === "user") {
2840
2899
  target = can.host ? { kind: "host" } : null;
2841
2900
  } else {
@@ -2849,9 +2908,9 @@ function saveAsTarget(name, entries, can) {
2849
2908
  }
2850
2909
  const old = (
2851
2910
  /** @type {T | undefined} */
2852
- storeEntry(entries, name, can.sourceId) ?? storeEntry(entries, name, null)
2911
+ storeEntry(entries, name, can.sourceId, can.sheet) ?? storeEntry(entries, name, null, null)
2853
2912
  );
2854
- return old ? { kind: "store", at: old.at, storeSource: old.sourceId ?? null, replaces: old } : { kind: "store", storeSource: can.sourceId ?? null, replaces: null };
2913
+ return old ? { kind: "store", at: old.at, storeSource: old.sourceId ?? null, storeSheet: old.sheet ?? null, replaces: old } : { kind: "store", storeSource: can.sourceId ?? null, storeSheet: can.sheet ?? null, replaces: null };
2855
2914
  }
2856
2915
 
2857
2916
  // src/view-store.js
@@ -2872,9 +2931,13 @@ function readAll(raw) {
2872
2931
  }
2873
2932
  return parseTemplates(raw).templates;
2874
2933
  }
2875
- function storedViews(raw, sourceId) {
2876
- return readAll(raw).map((t, at) => ({ name: t.name, view: t.view, at, ...t.source?.id ? { sourceId: t.source.id } : {} })).filter((t) => !t.sourceId || !sourceId || t.sourceId === sourceId);
2934
+ function storedViews(raw, sourceId, shown = { sheet: null, sheets: [] }) {
2935
+ return readAll(raw).map((t, at) => {
2936
+ const sheet = sheetOfSource(t.source);
2937
+ return { name: t.name, view: t.view, at, ...t.source?.id ? { sourceId: t.source.id } : {}, ...sheet ? { sheet } : {} };
2938
+ }).filter((t) => listedFor(t, { id: sourceId, ...shown }));
2877
2939
  }
2940
+ var sourceOf2 = (id, sheet) => id ? { id, ...sheet ? { params: { sheet } } : {} } : void 0;
2878
2941
  function changedViews(raw, change, message) {
2879
2942
  const all = readAll(raw);
2880
2943
  let next = all;
@@ -2890,20 +2953,23 @@ function changedViews(raw, change, message) {
2890
2953
  if (old?.name !== change.name) {
2891
2954
  throw new Error(message("changed", 0));
2892
2955
  }
2956
+ const source = old.source?.id && old.source.id === change.sourceId ? sourceOf2(change.sourceId, change.sheet) : old.source;
2893
2957
  next = all.map((t, i) => i === change.replace ? { name: old.name, view: (
2894
2958
  /** @type {Record<string, unknown>} */
2895
2959
  change.view
2896
- ), ...old.source ? { source: old.source } : {} } : t);
2960
+ ), ...source ? { source } : {} } : t);
2897
2961
  } else if (saving) {
2898
2962
  const id = change.sourceId;
2899
- next = next.filter((t) => t.name !== change.name || (t.source?.id ?? void 0) !== id);
2963
+ const sheet = id ? change.sheet ?? null : null;
2964
+ next = next.filter((t) => t.name !== change.name || (t.source?.id ?? void 0) !== id || sheetOfSource(t.source) !== sheet);
2965
+ const source = sourceOf2(id, sheet);
2900
2966
  next.push({ name: (
2901
2967
  /** @type {string} */
2902
2968
  change.name
2903
2969
  ), view: (
2904
2970
  /** @type {Record<string, unknown>} */
2905
2971
  change.view
2906
- ), ...id ? { source: { id } } : {} });
2972
+ ), ...source ? { source } : {} });
2907
2973
  if (next.length > VIEW_STORE_LIMITS.count) {
2908
2974
  throw new Error(message("count", VIEW_STORE_LIMITS.count));
2909
2975
  }
@@ -3238,23 +3304,33 @@ function viewActions(ctx, labels) {
3238
3304
  const save = (target, name) => {
3239
3305
  const key = ctx.viewKey;
3240
3306
  return run(
3241
- () => target.kind === "publish" ? ctx.onPublish(name, ctx.view) : target.kind === "host" ? ctx.onSave(name, ctx.view, { scope: "user" }) : write({ name, view: ctx.view, sourceId: ctx.sourceId, replace: target.at }),
3307
+ () => target.kind === "publish" ? ctx.onPublish(name, ctx.view, { source: ctx.source }) : target.kind === "host" ? ctx.onSave(name, ctx.view, { scope: "user", source: ctx.source }) : write({ name, view: ctx.view, sourceId: ctx.sourceId, sheet: ctx.sheet, replace: target.at }),
3242
3308
  labels.toastSaved,
3243
3309
  labels.toastSaveFailed,
3244
3310
  labels.toastSaveRejected,
3245
3311
  name
3246
- ).then((ok) => ok && ctx.onSaved({ name, scope: target.kind === "publish" ? "shared" : "user", store: target.kind === "store", storeSource: target.kind === "store" ? target.storeSource : null }, key));
3312
+ ).then((ok) => ok && ctx.onSaved({ name, scope: target.kind === "publish" ? "shared" : "user", store: target.kind === "store", storeSource: target.kind === "store" ? target.storeSource : null, storeSheet: target.kind === "store" ? storedSheet(target, ctx) : null }, key));
3247
3313
  };
3248
3314
  return {
3249
3315
  // Save and Save as: where to is view-save.js's (the host's onSaveTemplate wins over the store)
3250
3316
  save,
3251
3317
  remove: ctx.onDelete || ctx.store ? (t) => run(() => t.at !== void 0 ? write({ remove: t.at, removeName: t.name }) : ctx.onDelete(t.name, { scope: t.scope }), labels.toastDeleted, labels.toastDeleteFailed, labels.toastDeleteRejected, t.name) : null,
3252
- publish: ctx.onPublish ? (t) => run(() => ctx.onPublish(t.name, ctx.normalized(t.view)), labels.toastPublished, labels.toastPublishFailed, labels.toastPublishRejected, t.name) : null
3318
+ // a view of the menu is published with the data it was made for, which is the data shown unless
3319
+ // the entry names other data (a view of the browser store kept for another file or sheet)
3320
+ publish: ctx.onPublish ? (t) => run(() => ctx.onPublish(t.name, ctx.normalized(t.view), { source: entrySource(t, ctx.source) }), labels.toastPublished, labels.toastPublishFailed, labels.toastPublishRejected, t.name) : null
3253
3321
  };
3254
3322
  }
3323
+ var entrySource = (t, shown) => {
3324
+ const id = t.sourceId ?? t.sheetOf ?? t.fileSource;
3325
+ if (!id) {
3326
+ return shown ?? null;
3327
+ }
3328
+ return { id, ...shown?.id === id && shown.name ? { name: shown.name } : {}, ...t.sheet ? { params: { sheet: t.sheet } } : {} };
3329
+ };
3330
+ var storedSheet = (target, ctx) => target.storeSource && target.storeSource === ctx.sourceId ? ctx.sheet ?? null : target.storeSheet ?? null;
3255
3331
  function ViewsPanel({ templates, labels, onLoad, actions, close, share }) {
3256
3332
  const { save, remove: onDelete, publish: onPublish } = viewActions(actions, labels);
3257
- const can = { host: Boolean(actions.onSave), store: Boolean(actions.store), publish: Boolean(onPublish), sourceId: actions.sourceId };
3333
+ const can = { host: Boolean(actions.onSave), store: Boolean(actions.store), publish: Boolean(onPublish), sourceId: actions.sourceId, sheet: actions.sheet ?? null };
3258
3334
  const target = saveTarget(actions.loaded, templates, can, actions.empty);
3259
3335
  const store = actions.store && !actions.onSave;
3260
3336
  const [asking, setAsking] = useState5(
@@ -3277,6 +3353,9 @@ function ViewsPanel({ templates, labels, onLoad, actions, close, share }) {
3277
3353
  id,
3278
3354
  testId: `saved-view-${t.name}`,
3279
3355
  text: t.name,
3356
+ // while a workbook's sheet is shown, a view made on a sheet says which (two views of a
3357
+ // name can be kept, one per sheet; one of another sheet reads that sheet when opened)
3358
+ hint: t.sheet && actions.sheet ? fill(labels.viewSheet, { sheet: t.sheet }) : void 0,
3280
3359
  icon: "bookmark",
3281
3360
  current: isLoadedEntry(t, actions.loaded),
3282
3361
  closes: true,
@@ -3407,7 +3486,7 @@ function ExportOption({ icon, text, info, onSelect, testId, disabled, reason })
3407
3486
  info
3408
3487
  ), name: text })) : option;
3409
3488
  }
3410
- function ExportPanel({ labels, onExport, chartReady, display, empty = false, prepare, close }) {
3489
+ function ExportPanel({ labels, onExport, chartReady, display, empty = false, dataExport = false, prepare, close }) {
3411
3490
  useEffect3(() => {
3412
3491
  prepare();
3413
3492
  }, [prepare]);
@@ -3416,7 +3495,7 @@ function ExportPanel({ labels, onExport, chartReady, display, empty = false, pre
3416
3495
  onExport(kind);
3417
3496
  };
3418
3497
  const off = empty ? { disabled: true, reason: labels.exportNeedsField } : {};
3419
- return /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement(Section, { title: labels.exportDownload }, /* @__PURE__ */ React7.createElement(ExportOption, { icon: "file", text: labels.exportXlsx, info: "exportXlsx", onSelect: run("xlsx"), ...off, testId: "export-xlsx" }), /* @__PURE__ */ React7.createElement(ExportOption, { icon: "file", text: labels.exportCsv, info: "exportCsv", onSelect: run("csv"), ...off, testId: "export-csv" }), /* @__PURE__ */ React7.createElement(ExportOption, { icon: "file", text: labels.exportHtml, info: "exportHtml", onSelect: run("html"), ...off, testId: "export-html" }), /* @__PURE__ */ React7.createElement(ExportOption, { icon: "image", text: labels.exportPng, disabled: empty || !chartReady, reason: empty ? off.reason : display !== "chart" ? labels.exportPngNeedsChart : void 0, onSelect: run("png"), testId: "export-png" }), /* @__PURE__ */ React7.createElement(ExportOption, { icon: "image", text: labels.exportSvg, disabled: empty || display !== "chart", reason: empty ? off.reason : display !== "chart" ? labels.exportPngNeedsChart : void 0, onSelect: run("svg"), testId: "export-svg" })), /* @__PURE__ */ React7.createElement(Section, { title: labels.exportPrintGroup }, /* @__PURE__ */ React7.createElement(ExportOption, { icon: "print", text: labels.exportPrint, info: "exportPrint", onSelect: run("print"), ...off, testId: "export-print" })), /* @__PURE__ */ React7.createElement(Section, { title: labels.exportCopy }, /* @__PURE__ */ React7.createElement(ExportOption, { icon: "copy", text: labels.copyTable, info: "copyTable", onSelect: run("copy-table"), ...off, testId: "export-copy-table" }), /* @__PURE__ */ React7.createElement(ExportOption, { icon: "copy", text: labels.copyDataJson, info: "copyDataJson", onSelect: run("copy-json"), ...off, testId: "export-copy-json" })));
3498
+ return /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement(Section, { title: labels.exportDownload }, /* @__PURE__ */ React7.createElement(ExportOption, { icon: "file", text: labels.exportXlsx, info: "exportXlsx", onSelect: run("xlsx"), ...off, testId: "export-xlsx" }), /* @__PURE__ */ React7.createElement(ExportOption, { icon: "file", text: labels.exportCsv, info: "exportCsv", onSelect: run("csv"), ...off, testId: "export-csv" }), /* @__PURE__ */ React7.createElement(ExportOption, { icon: "file", text: labels.exportHtml, info: "exportHtml", onSelect: run("html"), ...off, testId: "export-html" }), /* @__PURE__ */ React7.createElement(ExportOption, { icon: "image", text: labels.exportPng, disabled: empty || !chartReady, reason: empty ? off.reason : display !== "chart" ? labels.exportPngNeedsChart : void 0, onSelect: run("png"), testId: "export-png" }), /* @__PURE__ */ React7.createElement(ExportOption, { icon: "image", text: labels.exportSvg, disabled: empty || display !== "chart", reason: empty ? off.reason : display !== "chart" ? labels.exportPngNeedsChart : void 0, onSelect: run("svg"), testId: "export-svg" })), /* @__PURE__ */ React7.createElement(Section, { title: labels.exportPrintGroup }, /* @__PURE__ */ React7.createElement(ExportOption, { icon: "print", text: labels.exportPrint, info: "exportPrint", onSelect: run("print"), ...off, testId: "export-print" })), /* @__PURE__ */ React7.createElement(Section, { title: labels.exportCopy }, /* @__PURE__ */ React7.createElement(ExportOption, { icon: "copy", text: labels.copyTable, info: "copyTable", onSelect: run("copy-table"), ...off, testId: "export-copy-table" }), /* @__PURE__ */ React7.createElement(ExportOption, { icon: "copy", text: labels.copyDataJson, info: "copyDataJson", onSelect: run("copy-json"), ...off, testId: "export-copy-json" })), dataExport ? /* @__PURE__ */ React7.createElement(Section, { title: labels.exportDataGroup }, /* @__PURE__ */ React7.createElement(ExportOption, { icon: "file", text: labels.exportDataCsv, info: "exportDataCsv", onSelect: run("data-csv"), testId: "export-data-csv" }), /* @__PURE__ */ React7.createElement(ExportOption, { icon: "file", text: labels.exportDataJson, info: "exportDataJson", onSelect: run("data-json"), testId: "export-data-json" })) : null);
3420
3499
  }
3421
3500
 
3422
3501
  // src/drill-panel.jsx
@@ -3624,7 +3703,7 @@ function reportTokens(root, report, chart) {
3624
3703
  const tokens = lightTokens(root, report.REPORT_TOKENS, () => chart.tokenLengths(root, [...chart.LENGTH_TOKENS, ...report.REPORT_LENGTHS]));
3625
3704
  return Object.keys(tokens).length ? tokens : void 0;
3626
3705
  }
3627
- async function runExport(kind, { fileName, result, locale, labels, limits, root, chartRef, announce, onExport, title, source, loadECharts }) {
3706
+ async function runExport(kind, { fileName, result, encoded, exportData, locale, labels, limits, root, chartRef, announce, onExport, title, source, loadECharts }) {
3628
3707
  labels = menuLabels(labels);
3629
3708
  const base = safeFileName(fileName);
3630
3709
  const doc = root.current?.ownerDocument;
@@ -3638,6 +3717,23 @@ async function runExport(kind, { fileName, result, locale, labels, limits, root,
3638
3717
  }
3639
3718
  return;
3640
3719
  }
3720
+ if (kind === "data-csv" || kind === "data-json") {
3721
+ const data = encoded ?? result?.encoded;
3722
+ if (!exportData || !data) {
3723
+ return;
3724
+ }
3725
+ const m2 = exporters ?? await loadExporters();
3726
+ const csv = kind === "data-csv";
3727
+ const file2 = `${base}-data.${csv ? "csv" : "json"}`;
3728
+ const blob = csv ? new Blob([
3729
+ /** @type {BlobPart} */
3730
+ m2.dataToCsvBytes(data, limits ? { limits } : {})
3731
+ ], { type: "text/csv;charset=utf-8" }) : new Blob([m2.dataToJson(data, limits ? { limits } : {})], { type: "application/json" });
3732
+ if (deliver(blob, { kind, fileName: file2, doc, onExport })) {
3733
+ announce(fill(labels.toastExported, { file: file2 }));
3734
+ }
3735
+ return;
3736
+ }
3641
3737
  if (!result) {
3642
3738
  return;
3643
3739
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pivotkit-react",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "React 18/19 pivot report builder on pivotkit-core: drag-and-drop fields, table and Apache ECharts chart, filters, views as JSON files, undo, Excel and CSV export.",
5
5
  "license": "MIT",
6
6
  "author": "eizedev <oss@eize.dev>",
@@ -64,8 +64,8 @@
64
64
  "dependencies": {
65
65
  "@dnd-kit/core": "6.3.1",
66
66
  "@dnd-kit/sortable": "10.0.0",
67
- "pivotkit-core": "^0.5.0",
68
- "pivotkit-report": "^0.1.0"
67
+ "pivotkit-core": "^0.6.0",
68
+ "pivotkit-report": "^0.2.0"
69
69
  },
70
70
  "devDependencies": {
71
71
  "echarts": "6.1.0"
@@ -63,6 +63,8 @@ export declare function xlsxThemeOf(style: {
63
63
  export type ExportContext = {
64
64
  fileName: string;
65
65
  result: import("pivotkit-core").PivotResult | null;
66
+ encoded?: import("pivotkit-core").Encoded | null;
67
+ exportData?: boolean;
66
68
  locale: string;
67
69
  labels: import("./labels.js").UiLabels;
68
70
  limits: object | undefined;
@@ -77,17 +79,19 @@ export type ExportContext = {
77
79
  loadECharts?: () => Promise<any>;
78
80
  };
79
81
  /**
80
- * @typedef {{ fileName: string, result: import("pivotkit-core").PivotResult | null, locale: string,
82
+ * @typedef {{ fileName: string, result: import("pivotkit-core").PivotResult | null, encoded?: import("pivotkit-core").Encoded | null, exportData?: boolean, locale: string,
81
83
  * labels: import("./labels.js").UiLabels, limits: object | undefined, root: React.RefObject<HTMLElement | null>,
82
84
  * chartRef: React.RefObject<any>, announce: (text: string, extra?: { tone?: "error" }) => void,
83
85
  * onExport?: (file: ExportFile) => unknown, title?: string | null, source?: string | null, loadECharts?: () => Promise<any> }} ExportContext
84
86
  * `title`: the report's title in an HTML report (the loaded view's name); `source`: the data's name;
87
+ * `encoded`: the data shown (the host's or a loaded file's), which the source data exports, only
88
+ * with `exportData` (the host's prop: the menu hides it otherwise, and no other way reaches it);
85
89
  * `loadECharts`: chart.jsx's loader of dist/echarts.js (passed in: a module of the menus that
86
90
  * imported chart.jsx would move it out of the first load into a shared chunk)
87
91
  */
88
92
  /**
89
93
  * One export of the Export menu.
90
- * @param {"xlsx" | "csv" | "png" | "html" | "svg" | "print" | "copy-table" | "copy-json"} kind
94
+ * @param {"xlsx" | "csv" | "png" | "html" | "svg" | "print" | "copy-table" | "copy-json" | "data-csv" | "data-json"} kind
91
95
  * @param {ExportContext} context
92
96
  */
93
- export declare function runExport(kind: "xlsx" | "csv" | "png" | "html" | "svg" | "print" | "copy-table" | "copy-json", { fileName, result, locale, labels, limits, root, chartRef, announce, onExport, title, source, loadECharts }: ExportContext): Promise<void>;
97
+ export declare function runExport(kind: "xlsx" | "csv" | "png" | "html" | "svg" | "print" | "copy-table" | "copy-json" | "data-csv" | "data-json", { fileName, result, encoded, exportData, locale, labels, limits, root, chartRef, announce, onExport, title, source, loadECharts }: ExportContext): Promise<void>;
@@ -1,3 +1,4 @@
1
+ import { isIdentifierName } from "pivotkit-core";
1
2
  export type FieldInfo = {
2
3
  label?: string;
3
4
  description?: string;
@@ -32,16 +33,8 @@ export declare function typesOf(fieldDefaults: unknown): Record<string, string>
32
33
  * @param {FieldInfo | undefined} info
33
34
  */
34
35
  export declare function fieldMatches(field: string, query: string, info: FieldInfo | undefined): boolean;
35
- /**
36
- * Whether a field's name says it is an identifier: its last word is ID, Nr, No, Number, Key or "#",
37
- * in any case. Words are split at a space, "_", "-", ".", "/", ":", a change from a small letter to
38
- * a capital ("CustomerId", "CustomerID") and from a letter to a digit; a "#" is a word of its own
39
- * ("Serial#" as "Serial #"). Before the last word is read, a part in parentheses at the end ("ID
40
- * (Asset)") and digits at the end ("userID2") are left out. "Paid", "PAID" and "UUID" are one word,
41
- * not one ending in "id"; "Number of items" ends in "items".
42
- * @param {string} name
43
- */
44
- export declare function isIdentifierName(name: string): boolean;
36
+ /** Whether a field's name says it is an identifier: pivotkit-core's rule, which its suggestions share. */
37
+ export { isIdentifierName };
45
38
  /**
46
39
  * Whether a column is an identifier: a number column of whole numbers whose name says so
47
40
  * (isIdentifierName). That every value is another is no sign: a count per row is too.
@@ -1,13 +1,7 @@
1
1
  import React from "react";
2
2
  export type ImportApi = import("./import-steps.js").ImportContext & {
3
- job: {
4
- file: File;
5
- n: number;
6
- } | null;
7
- setJob: React.Dispatch<React.SetStateAction<{
8
- file: File;
9
- n: number;
10
- } | null>>;
3
+ job: ImportJob | null;
4
+ setJob: React.Dispatch<React.SetStateAction<ImportJob | null>>;
11
5
  dismiss?: (id: number) => void;
12
6
  dragging: boolean;
13
7
  encoded: import("pivotkit-core").Encoded;
@@ -18,6 +12,14 @@ export type ImportApi = import("./import-steps.js").ImportContext & {
18
12
  timeZone?: string;
19
13
  box: () => DOMRect | undefined;
20
14
  pick: () => void;
15
+ afterData: (run: (() => void) | null) => void;
16
+ };
17
+ export type ImportJob = {
18
+ file: File;
19
+ n: number;
20
+ sheet?: string;
21
+ auto?: boolean;
22
+ done?: (loaded: boolean, refused?: boolean) => void;
21
23
  };
22
24
  /**
23
25
  * Files picked or dropped: one opens its preview, more than one is said to be too many. The error
@@ -26,6 +28,30 @@ export type ImportApi = import("./import-steps.js").ImportContext & {
26
28
  * @param {File[]} files
27
29
  */
28
30
  export declare function startFiles(api: ImportApi, files: File[]): void;
31
+ /**
32
+ * Reads another sheet of the file shown and loads it at once (a saved view made on that sheet was
33
+ * opened, sheet-views.js): the dialog shows the progress and has Cancel, a sheet that cannot be read
34
+ * says why there. `done` is told whether the sheet was loaded (Cancel, a failure and a host's refusal
35
+ * are not).
36
+ * @param {ImportApi} api
37
+ * @param {string} sheet
38
+ * @param {(loaded: boolean, refused?: boolean) => void} done `refused`: the host refused it (onDataLoad)
39
+ */
40
+ export declare function loadSheet(api: ImportApi, sheet: string, done: (loaded: boolean, refused?: boolean) => void): void;
41
+ /**
42
+ * A view that names a sheet (sheet-views.js: sheetPlan): another sheet of the workbook shown is read
43
+ * first (loadSheet), and `then` runs once its data is shown (the report's `afterData`); a sheet the
44
+ * workbook does not have is said, and the view loads on the sheet shown. A sheet the host refuses
45
+ * (onDataLoad) is said too; Cancel is not. Returns what the plan was.
46
+ * @param {ImportApi} api
47
+ * @param {{ id?: string | null, sheet?: string | null }} made the data and sheet the view names
48
+ * @param {string} name the view's name
49
+ * @param {() => void} then
50
+ */
51
+ export declare function openOnSheet(api: ImportApi, made: {
52
+ id?: string | null;
53
+ sheet?: string | null;
54
+ }, name: string, then: () => void): "missing" | "none" | "switch";
29
55
  /**
30
56
  * Opens the browser's file picker: the report's hidden file input.
31
57
  * @param {HTMLInputElement | null} input
@@ -67,6 +67,8 @@ export declare const en: {
67
67
  };
68
68
  sourceLine: string;
69
69
  sourceSheet: string;
70
+ sheetMissing: string;
71
+ sheetRefused: string;
70
72
  notes: {
71
73
  ENCODING: string;
72
74
  SEPARATOR: string;
@@ -192,6 +194,8 @@ export declare const IMPORT_TEXTS: Readonly<{
192
194
  };
193
195
  sourceLine: string;
194
196
  sourceSheet: string;
197
+ sheetMissing: string;
198
+ sheetRefused: string;
195
199
  notes: {
196
200
  ENCODING: string;
197
201
  SEPARATOR: string;
@@ -311,6 +315,8 @@ export declare const IMPORT_TEXTS: Readonly<{
311
315
  };
312
316
  sourceLine: string;
313
317
  sourceSheet: string;
318
+ sheetMissing: string;
319
+ sheetRefused: string;
314
320
  notes: {
315
321
  ENCODING: string;
316
322
  SEPARATOR: string;
@@ -1,2 +1,2 @@
1
- export { DataMenuPanel, ImportLayer, SourceLine, pickFile, startFiles } from "./import-host.jsx";
1
+ export { DataMenuPanel, ImportLayer, SourceLine, loadSheet, openOnSheet, pickFile, startFiles } from "./import-host.jsx";
2
2
  export { moveData, restoreData } from "./import-steps.js";
@@ -9,6 +9,14 @@ export type ShownData = {
9
9
  name: string;
10
10
  };
11
11
  sheet: string | null;
12
+ /**
13
+ * the workbook's sheets (names)
14
+ */
15
+ sheets?: readonly string[];
16
+ /**
17
+ * the file, to read another of its sheets
18
+ */
19
+ blob?: File;
12
20
  file: {
13
21
  name: string;
14
22
  size: number;