@openworkbook/react 0.2.0 → 0.2.1

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.
@@ -6721,6 +6721,11 @@ var Icon = {
6721
6721
  /* @__PURE__ */ jsx("path", { d: "M6 3H3.500v12H6" }),
6722
6722
  /* @__PURE__ */ jsx("path", { d: "M8.500 5.500h7M8.500 9h7M8.500 12.500h7" })
6723
6723
  ] }),
6724
+ errorCheck: () => /* @__PURE__ */ jsxs(Svg, { children: [
6725
+ /* @__PURE__ */ jsx("path", { d: "M9 2 16 9 9 16 2 9Z" }),
6726
+ /* @__PURE__ */ jsx("path", { d: "M9 5.500v4.200" }),
6727
+ /* @__PURE__ */ jsx("circle", { cx: "9", cy: "12.300", r: "0.600", fill: "currentColor" })
6728
+ ] }),
6724
6729
  eye: () => /* @__PURE__ */ jsxs(Svg, { children: [
6725
6730
  /* @__PURE__ */ jsx("path", { d: "M1.500 9S4.500 4 9 4s7.500 5 7.500 5-3 5-7.500 5S1.500 9 1.500 9Z" }),
6726
6731
  /* @__PURE__ */ jsx("circle", { cx: "9", cy: "9", r: "2.200" })
package/dist/client.cjs CHANGED
@@ -7288,6 +7288,11 @@ var init_icons = __esm({
7288
7288
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "M6 3H3.500v12H6" }),
7289
7289
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "M8.500 5.500h7M8.500 9h7M8.500 12.500h7" })
7290
7290
  ] }),
7291
+ errorCheck: () => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(Svg, { children: [
7292
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "M9 2 16 9 9 16 2 9Z" }),
7293
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "M9 5.500v4.200" }),
7294
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("circle", { cx: "9", cy: "12.300", r: "0.600", fill: "currentColor" })
7295
+ ] }),
7291
7296
  eye: () => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(Svg, { children: [
7292
7297
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "M1.500 9S4.500 4 9 4s7.500 5 7.500 5-3 5-7.500 5S1.500 9 1.500 9Z" }),
7293
7298
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("circle", { cx: "9", cy: "9", r: "2.200" })
@@ -11859,6 +11864,9 @@ var Spreadsheet = (0, import_react12.forwardRef)(function Spreadsheet2(props, re
11859
11864
  viewRef.current.invalidate();
11860
11865
  }
11861
11866
  }, [readOnly]);
11867
+ (0, import_react12.useEffect)(() => {
11868
+ if (viewRef.current) viewRef.current.htmlPasteFormulas = props.htmlPasteFormulas !== false;
11869
+ }, [wb, props.htmlPasteFormulas]);
11862
11870
  (0, import_react12.useEffect)(() => {
11863
11871
  const v = viewRef.current;
11864
11872
  if (v) {
@@ -24975,7 +24983,7 @@ var STUDIO_CSS = `
24975
24983
  [dir=rtl] .ox-cg-name .ox-btn svg{transform:scaleX(-1)}
24976
24984
  .ox-cg-col{display:flex;flex-direction:column;justify-content:space-between}
24977
24985
  .ox-cg-col.ox-cg-n2{justify-content:space-evenly}
24978
- .ox-cg-col.ox-cg-n1{justify-content:flex-start}
24986
+ .ox-cg-col.ox-cg-n1{justify-content:center}
24979
24987
  .ox-cg-row{display:flex;align-items:center;gap:1px;height:24px}
24980
24988
  .ox-cg-row .ox-btn{height:24px;min-width:24px;padding:0 4px;gap:4px;justify-content:flex-start}
24981
24989
  .ox-cg-row .ox-btn:not(.ox-chev)>svg:first-child{width:18px;height:18px}
@@ -25577,8 +25585,19 @@ var rowOf = (r) => Array.isArray(r) ? flatNodes(r) : present(r) ? flatNodes([r])
25577
25585
  function columnsOf(g, level) {
25578
25586
  const out = [];
25579
25587
  let pending2 = [];
25588
+ const lone = (row) => {
25589
+ if (level > 1 || row.length !== 1) return false;
25590
+ const n = row[0], p = propsOf(n);
25591
+ return isButton(n) && present(p.icon) && p.label !== void 0 && p.label !== false;
25592
+ };
25580
25593
  const flush = () => {
25581
- for (let i = 0; i < pending2.length; i += 3) out.push({ rows: pending2.slice(i, i + 3) });
25594
+ const n = pending2.length, k = Math.ceil(n / 3);
25595
+ for (let c = 0, at2 = 0; c < k; c++) {
25596
+ const size = Math.ceil((n - at2) / (k - c)), rows = pending2.slice(at2, at2 + size);
25597
+ at2 += size;
25598
+ if (rows.length === 1 && lone(rows[0])) out.push({ large: rows[0][0] });
25599
+ else out.push({ rows });
25600
+ }
25582
25601
  pending2 = [];
25583
25602
  };
25584
25603
  for (const p of g.parts) {
@@ -34661,6 +34680,9 @@ var StudioImpl = (0, import_react68.forwardRef)(function Studio(props, ref) {
34661
34680
  viewRef.current.invalidate();
34662
34681
  }
34663
34682
  }, [ro]);
34683
+ (0, import_react68.useEffect)(() => {
34684
+ if (viewRef.current) viewRef.current.htmlPasteFormulas = props.htmlPasteFormulas !== false;
34685
+ }, [wb, props.htmlPasteFormulas]);
34664
34686
  (0, import_react68.useEffect)(() => {
34665
34687
  viewRef.current?.setTheme(gridThemeRef.current);
34666
34688
  }, [gridThemeKey]);
@@ -36240,7 +36262,7 @@ var StudioImpl = (0, import_react68.forwardRef)(function Studio(props, ref) {
36240
36262
  [...fnMenus.slice(0, 6).map((m) => BM(m.id, m.items, { label: true })), BM("formulas.fn.more", tidy2(fnMenus.slice(6).map((m) => mi(m.id, { items: m.items }))), { label: true })],
36241
36263
  [B2("formulas.nameManager", { label: true }), B2("formulas.formulaEditor", { label: true })],
36242
36264
  // [formula editor]
36243
- [BM("formulas.auditing", M("formulas.tracePrecedents", "formulas.traceDependents", "formulas.removeArrows"), { label: t("short.formulas.auditing") }), B2("view.showFormulas", { label: true, icon: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(Icon.fx, {}) }), BS("formulas.errorChecking", [...errorCheckUi.menu, ...refStyleUi.errorMenu], { label: true }), B2("formulas.evaluateFormula", { label: true }), B2("formulas.watchWindow", { label: true })],
36265
+ [BM("formulas.auditing", M("formulas.tracePrecedents", "formulas.traceDependents", "formulas.removeArrows"), { label: t("short.formulas.auditing") }), B2("view.showFormulas", { label: true, icon: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(Icon.fx, {}) }), BS("formulas.errorChecking", [...errorCheckUi.menu, ...refStyleUi.errorMenu], { label: true, icon: /* @__PURE__ */ (0, import_jsx_runtime80.jsx)(Icon.errorCheck, {}) }), B2("formulas.evaluateFormula", { label: true }), B2("formulas.watchWindow", { label: true })],
36244
36266
  // [iteration] Error Checking > Circular References; [evaluate formula] [watch window]
36245
36267
  [BM("formulas.calculation", M("formulas.calc.automatic", "formulas.calc.exceptTables", "formulas.calc.manual", "-", "options.iterative", "options.r1c1"), { label: t("short.formulas.calculation") }), B2("formulas.calculateWorkbook", { label: true }), B2("formulas.calculateSheet", { label: true })]
36246
36268
  ] },
package/dist/client.js CHANGED
@@ -54,7 +54,7 @@ import {
54
54
  useLocale,
55
55
  usePopup,
56
56
  useRovingTabindex
57
- } from "./chunk-YMZE7SCY.js";
57
+ } from "./chunk-MV44TEEG.js";
58
58
 
59
59
  // src/Spreadsheet.tsx
60
60
  import {
@@ -1858,6 +1858,9 @@ var Spreadsheet = forwardRef(function Spreadsheet2(props, ref) {
1858
1858
  viewRef.current.invalidate();
1859
1859
  }
1860
1860
  }, [readOnly]);
1861
+ useEffect8(() => {
1862
+ if (viewRef.current) viewRef.current.htmlPasteFormulas = props.htmlPasteFormulas !== false;
1863
+ }, [wb, props.htmlPasteFormulas]);
1861
1864
  useEffect8(() => {
1862
1865
  const v = viewRef.current;
1863
1866
  if (v) {
@@ -15126,7 +15129,7 @@ var STUDIO_CSS = `
15126
15129
  [dir=rtl] .ox-cg-name .ox-btn svg{transform:scaleX(-1)}
15127
15130
  .ox-cg-col{display:flex;flex-direction:column;justify-content:space-between}
15128
15131
  .ox-cg-col.ox-cg-n2{justify-content:space-evenly}
15129
- .ox-cg-col.ox-cg-n1{justify-content:flex-start}
15132
+ .ox-cg-col.ox-cg-n1{justify-content:center}
15130
15133
  .ox-cg-row{display:flex;align-items:center;gap:1px;height:24px}
15131
15134
  .ox-cg-row .ox-btn{height:24px;min-width:24px;padding:0 4px;gap:4px;justify-content:flex-start}
15132
15135
  .ox-cg-row .ox-btn:not(.ox-chev)>svg:first-child{width:18px;height:18px}
@@ -15719,8 +15722,19 @@ var rowOf = (r) => Array.isArray(r) ? flatNodes(r) : present(r) ? flatNodes([r])
15719
15722
  function columnsOf(g, level) {
15720
15723
  const out = [];
15721
15724
  let pending = [];
15725
+ const lone = (row) => {
15726
+ if (level > 1 || row.length !== 1) return false;
15727
+ const n = row[0], p = propsOf(n);
15728
+ return isButton(n) && present(p.icon) && p.label !== void 0 && p.label !== false;
15729
+ };
15722
15730
  const flush = () => {
15723
- for (let i = 0; i < pending.length; i += 3) out.push({ rows: pending.slice(i, i + 3) });
15731
+ const n = pending.length, k = Math.ceil(n / 3);
15732
+ for (let c = 0, at2 = 0; c < k; c++) {
15733
+ const size = Math.ceil((n - at2) / (k - c)), rows = pending.slice(at2, at2 + size);
15734
+ at2 += size;
15735
+ if (rows.length === 1 && lone(rows[0])) out.push({ large: rows[0][0] });
15736
+ else out.push({ rows });
15737
+ }
15724
15738
  pending = [];
15725
15739
  };
15726
15740
  for (const p of g.parts) {
@@ -24519,7 +24533,7 @@ function applySizeInput(wb, sheet, axis, selections, text) {
24519
24533
  import { Suspense, lazy, useEffect as useEffect46, useRef as useRef37, useState as useState54 } from "react";
24520
24534
  import { jsx as jsx73 } from "react/jsx-runtime";
24521
24535
  var loading = null;
24522
- var loadScreen = () => loading ?? (loading = import("./printSettingsUi-JFNADOSF.js").catch((e) => {
24536
+ var loadScreen = () => loading ?? (loading = import("./printSettingsUi-HSDXW6ZE.js").catch((e) => {
24523
24537
  loading = null;
24524
24538
  throw e;
24525
24539
  }));
@@ -24948,6 +24962,9 @@ var StudioImpl = forwardRef2(function Studio(props, ref) {
24948
24962
  viewRef.current.invalidate();
24949
24963
  }
24950
24964
  }, [ro]);
24965
+ useEffect47(() => {
24966
+ if (viewRef.current) viewRef.current.htmlPasteFormulas = props.htmlPasteFormulas !== false;
24967
+ }, [wb, props.htmlPasteFormulas]);
24951
24968
  useEffect47(() => {
24952
24969
  viewRef.current?.setTheme(gridThemeRef.current);
24953
24970
  }, [gridThemeKey]);
@@ -26527,7 +26544,7 @@ var StudioImpl = forwardRef2(function Studio(props, ref) {
26527
26544
  [...fnMenus.slice(0, 6).map((m) => BM(m.id, m.items, { label: true })), BM("formulas.fn.more", tidy2(fnMenus.slice(6).map((m) => mi(m.id, { items: m.items }))), { label: true })],
26528
26545
  [B("formulas.nameManager", { label: true }), B("formulas.formulaEditor", { label: true })],
26529
26546
  // [formula editor]
26530
- [BM("formulas.auditing", M("formulas.tracePrecedents", "formulas.traceDependents", "formulas.removeArrows"), { label: t("short.formulas.auditing") }), B("view.showFormulas", { label: true, icon: /* @__PURE__ */ jsx75(Icon.fx, {}) }), BS("formulas.errorChecking", [...errorCheckUi.menu, ...refStyleUi.errorMenu], { label: true }), B("formulas.evaluateFormula", { label: true }), B("formulas.watchWindow", { label: true })],
26547
+ [BM("formulas.auditing", M("formulas.tracePrecedents", "formulas.traceDependents", "formulas.removeArrows"), { label: t("short.formulas.auditing") }), B("view.showFormulas", { label: true, icon: /* @__PURE__ */ jsx75(Icon.fx, {}) }), BS("formulas.errorChecking", [...errorCheckUi.menu, ...refStyleUi.errorMenu], { label: true, icon: /* @__PURE__ */ jsx75(Icon.errorCheck, {}) }), B("formulas.evaluateFormula", { label: true }), B("formulas.watchWindow", { label: true })],
26531
26548
  // [iteration] Error Checking > Circular References; [evaluate formula] [watch window]
26532
26549
  [BM("formulas.calculation", M("formulas.calc.automatic", "formulas.calc.exceptTables", "formulas.calc.manual", "-", "options.iterative", "options.r1c1"), { label: t("short.formulas.calculation") }), B("formulas.calculateWorkbook", { label: true }), B("formulas.calculateSheet", { label: true })]
26533
26550
  ] },
package/dist/index.d.cts CHANGED
@@ -6092,6 +6092,12 @@ interface SpreadsheetProps {
6092
6092
  */
6093
6093
  locale?: string | LocalePack;
6094
6094
  readOnly?: boolean;
6095
+ /**
6096
+ * [html paste] Whether a paste keeps the formulas found in clipboard HTML that looks like Excel's or Google Sheets'
6097
+ * (`GridView.htmlPasteFormulas`). Default true. A web page can imitate that markup, so an application whose users
6098
+ * do not paste formulas in can set false: such a paste then brings values and formatting only.
6099
+ */
6100
+ htmlPasteFormulas?: boolean;
6095
6101
  showToolbar?: boolean;
6096
6102
  showFormulaBar?: boolean;
6097
6103
  /** [name box] The Name Box: `false` hides it; an object sets `width`, `dropdown`, `dropdownMaxHeight`, `define`, `navigate` (see `NameBoxOptions`). */
@@ -7019,6 +7025,12 @@ interface StudioProps {
7019
7025
  * carriage return gets an apostrophe and is quoted. Default false (the displayed text, as Excel saves it).
7020
7026
  */
7021
7027
  csvEscapeFormulas?: boolean;
7028
+ /**
7029
+ * [html paste] Whether a paste keeps the formulas found in clipboard HTML that looks like Excel's or Google Sheets'
7030
+ * (`GridView.htmlPasteFormulas`). Default true. A web page can imitate that markup, so an application whose users
7031
+ * do not paste formulas in can set false: such a paste then brings values and formatting only.
7032
+ */
7033
+ htmlPasteFormulas?: boolean;
7022
7034
  /**
7023
7035
  * Opt-in persistence to `localStorage`: the workbook JSON stored under `key` is restored on mount (taking
7024
7036
  * precedence over `data` / the initial content of `workbook`) and rewritten `debounceMs` (default 800)
package/dist/index.d.ts CHANGED
@@ -6092,6 +6092,12 @@ interface SpreadsheetProps {
6092
6092
  */
6093
6093
  locale?: string | LocalePack;
6094
6094
  readOnly?: boolean;
6095
+ /**
6096
+ * [html paste] Whether a paste keeps the formulas found in clipboard HTML that looks like Excel's or Google Sheets'
6097
+ * (`GridView.htmlPasteFormulas`). Default true. A web page can imitate that markup, so an application whose users
6098
+ * do not paste formulas in can set false: such a paste then brings values and formatting only.
6099
+ */
6100
+ htmlPasteFormulas?: boolean;
6095
6101
  showToolbar?: boolean;
6096
6102
  showFormulaBar?: boolean;
6097
6103
  /** [name box] The Name Box: `false` hides it; an object sets `width`, `dropdown`, `dropdownMaxHeight`, `define`, `navigate` (see `NameBoxOptions`). */
@@ -7019,6 +7025,12 @@ interface StudioProps {
7019
7025
  * carriage return gets an apostrophe and is quoted. Default false (the displayed text, as Excel saves it).
7020
7026
  */
7021
7027
  csvEscapeFormulas?: boolean;
7028
+ /**
7029
+ * [html paste] Whether a paste keeps the formulas found in clipboard HTML that looks like Excel's or Google Sheets'
7030
+ * (`GridView.htmlPasteFormulas`). Default true. A web page can imitate that markup, so an application whose users
7031
+ * do not paste formulas in can set false: such a paste then brings values and formatting only.
7032
+ */
7033
+ htmlPasteFormulas?: boolean;
7022
7034
  /**
7023
7035
  * Opt-in persistence to `localStorage`: the workbook JSON stored under `key` is restored on mount (taking
7024
7036
  * precedence over `data` / the initial content of `workbook`) and rewritten `debounceMs` (default 800)
@@ -7,7 +7,7 @@ import {
7
7
  printSheets,
8
8
  sheetPrintPages,
9
9
  useLocale
10
- } from "./chunk-YMZE7SCY.js";
10
+ } from "./chunk-MV44TEEG.js";
11
11
 
12
12
  // src/printSettingsUi.tsx
13
13
  import {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openworkbook/react",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "React / Next.js spreadsheet component for OpenWorkbook",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -38,7 +38,7 @@
38
38
  ],
39
39
  "sideEffects": false,
40
40
  "dependencies": {
41
- "@openworkbook/core": "0.2.0"
41
+ "@openworkbook/core": "0.2.1"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "react": ">=18",