@gridsheet/react-core 3.0.7 → 3.1.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/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { calcSideStyle as qn, clampPopup as en, clampLeft as Gn, zoneToArea as he, focus as O, Lexer as Ge, getFunctionHelps as Pt, expandInput as Qn, y2r as be, x2c as pe, resetInput as Jn, handleFormulaQuoteAutoClose as tn, areaToZone as Qe, insertTextAtCursor as nn, operations as X, isRefInsertable as sn, COLOR_PALETTE as Ie, DEFAULT_WIDTH as vt, DEFAULT_HEIGHT as bt, between as Ae, makeSequence as Xt, p2a as xe, MIN_HEIGHT as Ht, MIN_WIDTH as Ot, zoneShape as se, getLabel as wt, FormulaError as es, Pending as ts, insertRef as De, areaToRange as rn, calcBelowPosition as ns, hAlignTransform as ss, among as rs, getAreaInTabular as Lt, isFocus as os, Autofill as is, getCellRectPositions as Fe, a2p as Rt, virtualize as Bt, stripAddressAbsolute as ls, stripSheetName as as, preventSafariBounce as cs, smartScroll as us, isZoneNotSelected as ds, Sheet as gs, embedStyle as hs, getMaxSizesFromCells as on, HEADER_HEIGHT as fs, DEFAULT_ROW_KEY as ms, SHEET_HEIGHT as Kt, HEADER_WIDTH as ps, DEFAULT_COL_KEY as ys, SHEET_WIDTH as Wt } from "@gridsheet/core";
2
2
  import { BaseFunction as Yr, BaseFunctionAsync as $r, DEFAULT_HISTORY_LIMIT as Pr, FormulaError as Xr, FormulaParser as Hr, Lexer as Or, Pending as Lr, PercentagePolicyMixin as Br, Policy as Kr, RangeEntity as Wr, RefEntity as Zr, Registry as Ur, Sheet as zr, Spilling as _r, ThousandSeparatorPolicyMixin as jr, Time as Vr, ValueEntity as qr, a2p as Gr, aa2oa as Qr, addressesToAreas as Jr, addressesToCols as eo, addressesToRows as to, areaToRange as no, areaToZone as so, buildInitialCells as ro, buildInitialCellsFromOrigin as oo, c2x as io, ch as lo, check as ao, conditionArg as co, createBook as uo, createBooleanMask as go, createRegistry as ho, eachMatrix as fo, ensureBoolean as mo, ensureDate as po, ensureNumber as yo, ensureString as vo, matrixShape as bo, oa2aa as wo, operations as Ro, p2a as Co, r2y as So, rh as No, stripMatrix as xo, toCellCols as Eo, toCellMatrix as ko, toCellObject as To, toCellRows as Ao, toValueCols as Mo, toValueMatrix as Do, toValueObject as Io, toValueRows as Fo, x2c as Yo, y2r as $o, zoneToArea as Po } from "@gridsheet/core";
3
3
  import { jsxs as Y, jsx as a, Fragment as Re } from "react/jsx-runtime";
4
- import at, { createContext as ln, useRef as re, useContext as le, useLayoutEffect as ct, useState as ee, useMemo as $e, useCallback as k, memo as nt, useEffect as K, createRef as an, useReducer as vs } from "react";
5
- import { u as bs, s as de, w as Ze, a as te, b as Ue, r as ut, c as cn, d as un, e as Pe, f as dn, g as gn, h as we, i as je, j as ws, k as Zt, l as dt, p as gt, m as Je, n as Ne, o as ht, q as ft, t as Ye, v as Ct, x as hn, y as fn, z as mn, A as pn, B as yn, C as vn, D as ze, E as et, F as mt, G as st, H as Rs, I as Xe, J as me, K as ke, L as bn, M as We, N as Ut, O as wn, P as zt, Q as _t, R as Cs, S as Ss, T as jt, U as Ns, V as xs, W as Es } from "./hooks-CvkA2lFB.mjs";
4
+ import at, { createContext as ln, useRef as re, useContext as le, useLayoutEffect as ct, useState as te, useMemo as $e, useCallback as k, memo as nt, useEffect as W, createRef as an, useReducer as vs } from "react";
5
+ import { u as bs, s as ue, w as Ze, a as ne, b as Ue, r as ut, c as cn, d as un, e as Pe, f as dn, g as gn, h as we, i as je, j as ws, k as Zt, l as dt, p as gt, m as Je, n as Ne, o as ht, q as ft, t as Ye, v as Ct, x as hn, y as fn, z as mn, A as pn, B as yn, C as vn, D as ze, E as et, F as mt, G as st, H as Rs, I as Xe, J as me, K as ke, L as bn, M as We, N as Ut, O as wn, P as zt, Q as _t, R as Cs, S as Ss, T as jt, U as Ns, V as xs, W as Es } from "./hooks-CvkA2lFB.mjs";
6
6
  import { X as Ho } from "./hooks-CvkA2lFB.mjs";
7
7
  import { createPortal as St } from "react-dom";
8
8
  const ae = ln(
@@ -114,7 +114,7 @@ const ae = ln(
114
114
  selected: s,
115
115
  onOptionMouseDown: o
116
116
  }) => {
117
- const i = re(null), [l, h] = ee(t);
117
+ const i = re(null), [l, h] = te(t);
118
118
  return ct(() => {
119
119
  if (!i.current)
120
120
  return;
@@ -212,7 +212,7 @@ const ae = ln(
212
212
  o.pop();
213
213
  return `<table>${o.map((i) => i.html).join("")}</table>`;
214
214
  }, Cn = ({ inputting: e, selectionStart: n, optionsAll: t, functions: s }) => {
215
- const [o, i] = ee(0), { filteredOptions: l, matchParams: h, activeFunctionHelp: f, activeArgIndex: c } = $e(() => {
215
+ const [o, i] = te(0), { filteredOptions: l, matchParams: h, activeFunctionHelp: f, activeArgIndex: c } = $e(() => {
216
216
  var C, I;
217
217
  const g = e.startsWith("=");
218
218
  let m = null, p = 0;
@@ -480,7 +480,7 @@ const Nn = (e, n = " ") => {
480
480
  "UL"
481
481
  ]), Ms = ({ mode: e }) => {
482
482
  var Ft, Yt;
483
- const { store: n, dispatch: t } = le(ae), [s, o] = ee(!1), [i, l] = ee(0), [h, f] = ee(!1), c = re(!1), {
483
+ const { store: n, dispatch: t } = le(ae), [s, o] = te(!1), [i, l] = te(0), [h, f] = te(!1), c = re(!1), {
484
484
  choosing: d,
485
485
  inputting: b,
486
486
  selectingZone: y,
@@ -511,7 +511,7 @@ const Nn = (e, n = " ") => {
511
511
  Nt,
512
512
  {
513
513
  activeFunctionGuide: B,
514
- activeArgIndex: U,
514
+ activeArgIndex: z,
515
515
  top: V,
516
516
  left: ie
517
517
  }
@@ -539,27 +539,27 @@ const Nn = (e, n = " ") => {
539
539
  handleArrowUp: oe,
540
540
  handleArrowDown: ce,
541
541
  activeFunctionHelp: B,
542
- activeArgIndex: U
542
+ activeArgIndex: z
543
543
  } = Cn({
544
544
  inputting: b,
545
545
  selectionStart: i,
546
546
  optionsAll: N,
547
547
  functions: r == null ? void 0 : r.registry.functions
548
548
  });
549
- K(() => {
549
+ W(() => {
550
550
  O(T == null ? void 0 : T.current);
551
- }, [T]), K(() => {
552
- r && r.registry.lastFocused != null && r.registry.lastFocused === T.current && r.registry.lastFocused === S.current && t(de(""));
553
- }, [r == null ? void 0 : r.registry.lastFocused, r, T, S, t]), K(() => {
551
+ }, [T]), W(() => {
552
+ r && r.registry.lastFocused != null && r.registry.lastFocused === T.current && r.registry.lastFocused === S.current && t(ue(""));
553
+ }, [r == null ? void 0 : r.registry.lastFocused, r, T, S, t]), W(() => {
554
554
  r && (r.registry.editingSheetId = C, r.registry.editingAddress = m);
555
- }, [m, r, C]), K(() => {
555
+ }, [m, r, C]), W(() => {
556
556
  Qn(T.current);
557
557
  }, [b, m, T]);
558
- const { y: W, x: J } = d, j = `${be(W)}`, G = `${pe(J)}${j}`, L = m === G, Q = r == null ? void 0 : r.getCell({ y: W, x: J }, { resolution: "RAW" }), w = r ? r.getSerializedValue({ point: d, cell: Q, resolution: "RAW" }) : "", [z, ue] = ee(w), ne = k(
558
+ const { y: Z, x: J } = d, j = `${be(Z)}`, G = `${pe(J)}${j}`, L = m === G, Q = r == null ? void 0 : r.getCell({ y: Z, x: J }, { resolution: "RAW" }), w = r ? r.getSerializedValue({ point: d, cell: Q, resolution: "RAW" }) : "", [K, de] = te(w), ee = k(
559
559
  (x) => {
560
- z !== x && t(Ze({ value: x })), ue(x);
560
+ K !== x && t(Ze({ value: x })), de(x);
561
561
  },
562
- [z, t]
562
+ [K, t]
563
563
  ), ye = k(
564
564
  (x) => {
565
565
  if (!r)
@@ -568,7 +568,7 @@ const Nn = (e, n = " ") => {
568
568
  if (V) {
569
569
  if (V.isFunction) {
570
570
  const { value: ie, selectionStart: ge } = _(V);
571
- t(te(ie)), setTimeout(() => {
571
+ t(ne(ie)), setTimeout(() => {
572
572
  T.current && (O(T.current), T.current.setSelectionRange(ge, ge));
573
573
  }, 0);
574
574
  } else {
@@ -576,18 +576,18 @@ const Nn = (e, n = " ") => {
576
576
  diff: { [G]: { value: V.value } },
577
577
  partial: !0
578
578
  });
579
- t(Ue(ie.clone())), t(de("")), t(te(""));
579
+ t(Ue(ie.clone())), t(ue("")), t(ne(""));
580
580
  }
581
581
  q(0);
582
582
  }
583
583
  },
584
- [R, r, G, b, ne, t, T]
584
+ [R, r, G, b, ee, t, T]
585
585
  );
586
- K(() => {
587
- r && (ue(w), t(te(w)), Jn(T.current, r, d));
586
+ W(() => {
587
+ r && (de(w), t(ne(w)), Jn(T.current, r, d));
588
588
  }, [d, w, t, T, r]);
589
589
  const { y: Ee, x: _e, height: At, width: Mt } = g, Bn = w.split(`
590
- `).length, [Dt, It] = ee(!1), Kn = k(
590
+ `).length, [Dt, It] = te(!1), Kn = k(
591
591
  (x) => {
592
592
  var ge, Oe, Me, Le, Be, $t;
593
593
  if (!r || x.nativeEvent.isComposing || c.current || Dt)
@@ -597,7 +597,7 @@ const Nn = (e, n = " ") => {
597
597
  }));
598
598
  const V = x.currentTarget;
599
599
  if (tn(x, b))
600
- return t(te(V.value)), !1;
600
+ return t(ne(V.value)), !1;
601
601
  const ie = x.shiftKey;
602
602
  switch (x.key) {
603
603
  case "Tab":
@@ -607,7 +607,7 @@ const Nn = (e, n = " ") => {
607
607
  if (ye(H), ve)
608
608
  return !1;
609
609
  } else
610
- ne(V.value), t(de("")), t(te(""));
610
+ ee(V.value), t(ue("")), t(ne(""));
611
611
  return t(
612
612
  dt({
613
613
  numRows: r.numRows,
@@ -615,7 +615,7 @@ const Nn = (e, n = " ") => {
615
615
  deltaY: 0,
616
616
  deltaX: ie ? -1 : 1
617
617
  })
618
- ), t(de("")), !1;
618
+ ), t(ue("")), !1;
619
619
  case "Enter":
620
620
  if (L)
621
621
  if (R.length) {
@@ -625,10 +625,10 @@ const Nn = (e, n = " ") => {
625
625
  } else {
626
626
  if (x.altKey)
627
627
  return nn(V, `
628
- `), t(te(V.value)), x.preventDefault(), !1;
628
+ `), t(ne(V.value)), x.preventDefault(), !1;
629
629
  if (x.nativeEvent.isComposing)
630
630
  return !1;
631
- ne(V.value), t(de("")), t(te(""));
631
+ ee(V.value), t(ue("")), t(ne(""));
632
632
  }
633
633
  else if ($ && y.endY === -1) {
634
634
  const ve = document.createEvent("MouseEvents");
@@ -644,11 +644,11 @@ const Nn = (e, n = " ") => {
644
644
  ), x.preventDefault(), !1;
645
645
  case "Backspace":
646
646
  if (!L)
647
- return ((Me = r.getSystem({ y: W, x: J })) == null ? void 0 : Me.spilledFrom) != null ? (x.preventDefault(), !1) : (t(Zt(null)), t(te("")), !1);
647
+ return ((Me = r.getSystem({ y: Z, x: J })) == null ? void 0 : Me.spilledFrom) != null ? (x.preventDefault(), !1) : (t(Zt(null)), t(ne("")), !1);
648
648
  break;
649
649
  case "Delete":
650
650
  if (!L)
651
- return ((Le = r.getSystem({ y: W, x: J })) == null ? void 0 : Le.spilledFrom) != null ? (x.preventDefault(), !1) : (t(Zt(null)), t(te("")), !1);
651
+ return ((Le = r.getSystem({ y: Z, x: J })) == null ? void 0 : Le.spilledFrom) != null ? (x.preventDefault(), !1) : (t(Zt(null)), t(ne("")), !1);
652
652
  break;
653
653
  case "Shift":
654
654
  return o(!0), !1;
@@ -661,7 +661,7 @@ const Nn = (e, n = " ") => {
661
661
  case "NumLock":
662
662
  return !1;
663
663
  case "Escape":
664
- return t(ws(null)), t(Pe(void 0)), t(te(z)), !1;
664
+ return t(ws(null)), t(Pe(void 0)), t(ne(K)), !1;
665
665
  case "ArrowLeft":
666
666
  if (!L)
667
667
  return t(
@@ -743,7 +743,7 @@ const Nn = (e, n = " ") => {
743
743
  // R
744
744
  case "y":
745
745
  if ((x.ctrlKey || x.metaKey) && !L)
746
- return x.preventDefault(), t(ut(null)), requestAnimationFrame(() => t(te(""))), !1;
746
+ return x.preventDefault(), t(ut(null)), requestAnimationFrame(() => t(ne(""))), !1;
747
747
  break;
748
748
  case "s":
749
749
  if ((x.ctrlKey || x.metaKey) && !L)
@@ -778,10 +778,10 @@ const Nn = (e, n = " ") => {
778
778
  return x.preventDefault(), x.shiftKey ? t(ut(null)) : t(cn(null)), !1;
779
779
  break;
780
780
  case ";":
781
- (x.ctrlKey || x.metaKey) && (L || (x.preventDefault(), ne((/* @__PURE__ */ new Date()).toDateString())));
781
+ (x.ctrlKey || x.metaKey) && (L || (x.preventDefault(), ee((/* @__PURE__ */ new Date()).toDateString())));
782
782
  break;
783
783
  }
784
- return x.ctrlKey || x.metaKey ? !1 : X.hasOperation(Q == null ? void 0 : Q.prevention, X.Write) ? (console.warn("This cell is protected from writing."), !1) : (t(de(G)), L || t(te("")), q(0), !1);
784
+ return x.ctrlKey || x.metaKey ? !1 : X.hasOperation(Q == null ? void 0 : Q.prevention, X.Write) ? (console.warn("This cell is protected from writing."), !1) : (t(ue(G)), L || t(ne("")), q(0), !1);
785
785
  },
786
786
  [
787
787
  Dt,
@@ -790,13 +790,13 @@ const Nn = (e, n = " ") => {
790
790
  H,
791
791
  $,
792
792
  y,
793
- z,
793
+ K,
794
794
  r,
795
795
  d,
796
796
  n,
797
797
  Q,
798
798
  G,
799
- ne,
799
+ ee,
800
800
  F,
801
801
  b
802
802
  ]
@@ -812,7 +812,7 @@ const Nn = (e, n = " ") => {
812
812
  return;
813
813
  }
814
814
  const V = x.currentTarget;
815
- L || (t(te(w)), t(de(G)), requestAnimationFrame(() => {
815
+ L || (t(ne(w)), t(ue(G)), requestAnimationFrame(() => {
816
816
  V.style.width = `${V.scrollWidth}px`, V.style.height = `${V.scrollHeight}px`;
817
817
  const ie = new String(w).length;
818
818
  V.setSelectionRange(ie, ie);
@@ -823,12 +823,12 @@ const Nn = (e, n = " ") => {
823
823
  (x) => {
824
824
  if (f(!1), sn(x.currentTarget))
825
825
  return !0;
826
- L && ne(x.currentTarget.value), t(de(""));
826
+ L && ee(x.currentTarget.value), t(ue(""));
827
827
  },
828
- [L, ne, t]
828
+ [L, ee, t]
829
829
  ), zn = k(
830
830
  (x) => {
831
- X.hasOperation(Q == null ? void 0 : Q.prevention, X.Write) || (t(te(x.currentTarget.value)), l(x.currentTarget.selectionStart), q(0));
831
+ X.hasOperation(Q == null ? void 0 : Q.prevention, X.Write) || (t(ne(x.currentTarget.value)), l(x.currentTarget.selectionStart), q(0));
832
832
  },
833
833
  [Q]
834
834
  ), _n = k(
@@ -909,10 +909,10 @@ const Nn = (e, n = " ") => {
909
909
  onKeyDown: Kn,
910
910
  onKeyUp: jn,
911
911
  onCompositionStart: () => {
912
- c.current = !0, L || (t(de(G)), t(te("")));
912
+ c.current = !0, L || (t(ue(G)), t(ne("")));
913
913
  },
914
914
  onCompositionEnd: (x) => {
915
- c.current = !1, t(te(x.currentTarget.value));
915
+ c.current = !1, t(ne(x.currentTarget.value));
916
916
  },
917
917
  onMouseEnter: () => {
918
918
  t(Je(!0));
@@ -980,7 +980,7 @@ const Nn = (e, n = " ") => {
980
980
  ] });
981
981
  }, En = ln({});
982
982
  function Nr() {
983
- const [e, n] = ee(void 0), [t, s] = ee();
983
+ const [e, n] = te(void 0), [t, s] = te();
984
984
  return {
985
985
  provided: !0,
986
986
  store: e,
@@ -1007,9 +1007,9 @@ const Ds = ({
1007
1007
  mode: l
1008
1008
  }) => {
1009
1009
  const { store: h, dispatch: f } = le(ae), { sheetReactive: c } = h, d = c.current;
1010
- K(() => {
1010
+ W(() => {
1011
1011
  d && e && e !== d.name && (d.name = e, d.registry.sheetIdsByName[e] = d.id, delete d.registry.sheetIdsByName[d.prevName], d.prevName = e);
1012
- }, [e]), K(() => {
1012
+ }, [e]), W(() => {
1013
1013
  if (!d)
1014
1014
  return;
1015
1015
  const { registry: g } = d;
@@ -1025,17 +1025,17 @@ const Ds = ({
1025
1025
  },
1026
1026
  dispatch: f
1027
1027
  });
1028
- }, [h, d, s, o]), K(() => {
1028
+ }, [h, d, s, o]), W(() => {
1029
1029
  n && f(Ne({ sheetHeight: n }));
1030
- }, [n, f]), K(() => {
1030
+ }, [n, f]), W(() => {
1031
1031
  t && f(Ne({ sheetWidth: t }));
1032
- }, [t]), K(() => {
1032
+ }, [t]), W(() => {
1033
1033
  typeof i < "u" && f(Ne({ editingOnEnter: i }));
1034
- }, [i]), K(() => {
1034
+ }, [i]), W(() => {
1035
1035
  l && f(Ne({ mode: l }));
1036
1036
  }, [l]);
1037
1037
  const [b, y] = kn();
1038
- return K(() => {
1038
+ return W(() => {
1039
1039
  b && (y.setStore(h), y.setApply(() => f));
1040
1040
  }, [h, b, y]), /* @__PURE__ */ a(Re, {});
1041
1041
  }, Is = () => {
@@ -1106,7 +1106,7 @@ const Ds = ({
1106
1106
  );
1107
1107
  }, Fs = () => {
1108
1108
  const { store: e } = le(ae), { choosing: n, selectingZone: t, sheetReactive: s } = e, o = s.current;
1109
- return K(() => {
1109
+ return W(() => {
1110
1110
  o != null && o.isInitialized && o.currentVersion > 0 && o.registry.onChange && o.registry.onChange({
1111
1111
  sheet: o,
1112
1112
  points: {
@@ -1115,7 +1115,7 @@ const Ds = ({
1115
1115
  selectingTo: { y: t.endY, x: t.endX }
1116
1116
  }
1117
1117
  });
1118
- }, [s]), K(() => {
1118
+ }, [s]), W(() => {
1119
1119
  o && o.registry.onSelect && o.registry.onSelect({
1120
1120
  sheet: o,
1121
1121
  points: {
@@ -1620,7 +1620,7 @@ const kt = ({
1620
1620
  );
1621
1621
  }, Tt = () => /* @__PURE__ */ a("li", { className: "gs-menu-divider" }), Zs = () => {
1622
1622
  const { store: e, dispatch: n } = le(ae), { contextMenuPosition: t, contextMenu: s } = e, { y: o, x: i } = t, l = re(null);
1623
- if (K(() => {
1623
+ if (W(() => {
1624
1624
  l.current && en(l.current);
1625
1625
  }), o === -1)
1626
1626
  return null;
@@ -1664,14 +1664,14 @@ const kt = ({
1664
1664
  includes: "Includes",
1665
1665
  excludes: "Excludes"
1666
1666
  }, Gt = ["blank", "nonblank"], Ve = { method: "eq", value: [""] }, Us = ({ x: e, close: n, onWaiting: t }) => {
1667
- const { store: s, dispatch: o } = le(ae), { sheetReactive: i } = s, l = i.current, [h, f] = ee([{ ...Ve }]), [c, d] = ee("or"), [b, y] = ee(null), g = k(
1667
+ const { store: s, dispatch: o } = le(ae), { sheetReactive: i } = s, l = i.current, [h, f] = te([{ ...Ve }]), [c, d] = te("or"), [b, y] = te(null), g = k(
1668
1668
  (C) => {
1669
1669
  C && C.focus();
1670
1670
  },
1671
1671
  // eslint-disable-next-line react-hooks/exhaustive-deps
1672
1672
  [e]
1673
1673
  );
1674
- K(() => {
1674
+ W(() => {
1675
1675
  if (l) {
1676
1676
  const C = l.getCell({ y: 0, x: e }, { resolution: "SYSTEM" }), I = C == null ? void 0 : C.filter;
1677
1677
  I && I.conditions.length > 0 ? (f(I.conditions.map((r) => ({ ...r, value: [...r.value] }))), d(I.mode || "or")) : (f([{ ...Ve, value: [""] }]), d("or"));
@@ -1680,9 +1680,9 @@ const kt = ({
1680
1680
  const m = k(() => {
1681
1681
  y(null), t == null || t(null), n();
1682
1682
  }, [n, t]);
1683
- K(() => {
1683
+ W(() => {
1684
1684
  b && (t == null || t("Filtering…", m));
1685
- }, [b]), K(() => {
1685
+ }, [b]), W(() => {
1686
1686
  if (!b)
1687
1687
  return;
1688
1688
  let C = !1;
@@ -1799,12 +1799,12 @@ const kt = ({
1799
1799
  };
1800
1800
  Et("col-filter", Us);
1801
1801
  const zs = ({ x: e, close: n, onWaiting: t }) => {
1802
- const { store: s, dispatch: o } = le(ae), { sheetReactive: i } = s, l = i.current, [h, f] = ee(null), c = k(() => {
1802
+ const { store: s, dispatch: o } = le(ae), { sheetReactive: i } = s, l = i.current, [h, f] = te(null), c = k(() => {
1803
1803
  f(null), t == null || t(null), n();
1804
1804
  }, [n, t]);
1805
- if (K(() => {
1805
+ if (W(() => {
1806
1806
  h && (t == null || t("Sorting…", c));
1807
- }, [h]), K(() => {
1807
+ }, [h]), W(() => {
1808
1808
  if (!h)
1809
1809
  return;
1810
1810
  let y = !1;
@@ -1847,8 +1847,8 @@ const zs = ({ x: e, close: n, onWaiting: t }) => {
1847
1847
  };
1848
1848
  Et("col-sort", zs);
1849
1849
  const _s = ({ x: e, close: n }) => {
1850
- const { store: t, dispatch: s } = le(ae), { sheetReactive: o } = t, i = o.current, l = re(null), [h, f] = ee("");
1851
- K(() => {
1850
+ const { store: t, dispatch: s } = le(ae), { sheetReactive: o } = t, i = o.current, l = re(null), [h, f] = te("");
1851
+ W(() => {
1852
1852
  if (i) {
1853
1853
  const g = i.getCell({ y: 0, x: e }, { resolution: "SYSTEM" });
1854
1854
  f((g == null ? void 0 : g.label) ?? "");
@@ -1899,7 +1899,7 @@ const _s = ({ x: e, close: n }) => {
1899
1899
  };
1900
1900
  Et("col-label", _s);
1901
1901
  const js = () => {
1902
- const { store: e, dispatch: n } = le(ae), { columnMenuState: t, editorRef: s, colMenu: o } = e, i = e.sheetReactive.current, l = t == null ? void 0 : t.x, h = t == null ? void 0 : t.position, [f, c] = ee(null), d = k(() => {
1902
+ const { store: e, dispatch: n } = le(ae), { columnMenuState: t, editorRef: s, colMenu: o } = e, i = e.sheetReactive.current, l = t == null ? void 0 : t.x, h = t == null ? void 0 : t.position, [f, c] = te(null), d = k(() => {
1903
1903
  n(et(null)), O(s.current);
1904
1904
  }, [n, s]), b = k(
1905
1905
  (g, m) => {
@@ -2017,7 +2017,7 @@ const qs = () => {
2017
2017
  e.type.startsWith("touch") || e.preventDefault();
2018
2018
  }, Gs = nt(({ y: e, x: n }) => {
2019
2019
  var Q;
2020
- const t = be(e), o = `${pe(n)}${t}`, { store: i, dispatch: l } = le(ae), h = re(!0), f = re(null), [c, d] = ee(null), {
2020
+ const t = be(e), o = `${pe(n)}${t}`, { store: i, dispatch: l } = le(ae), h = re(!0), f = re(null), [c, d] = te(null), {
2021
2021
  sheetReactive: b,
2022
2022
  editingAddress: y,
2023
2023
  choosing: g,
@@ -2028,8 +2028,8 @@ const qs = () => {
2028
2028
  autofillDraggingTo: F,
2029
2029
  contextMenu: T
2030
2030
  } = i, S = b.current, D = st(i), $ = S == null ? void 0 : S.registry.lastFocused, P = he(m), C = y === o, I = g.y === e && g.x === n, r = k(() => {
2031
- var z;
2032
- const w = (z = f.current) == null ? void 0 : z.getBoundingClientRect();
2031
+ var K;
2032
+ const w = (K = f.current) == null ? void 0 : K.getBoundingClientRect();
2033
2033
  if (w == null)
2034
2034
  return null;
2035
2035
  l(
@@ -2041,7 +2041,7 @@ const qs = () => {
2041
2041
  })
2042
2042
  );
2043
2043
  }, [l]);
2044
- K(() => {
2044
+ W(() => {
2045
2045
  if (I && !h.current) {
2046
2046
  r();
2047
2047
  return;
@@ -2072,8 +2072,8 @@ const qs = () => {
2072
2072
  if (w.type.startsWith("touch"))
2073
2073
  return oe && _ && _.blur(), l(Xe({ y: e, x: n })), l(we({ startY: e, startX: n, endY: e, endX: n })), !0;
2074
2074
  w.shiftKey ? l(me({ y: e, x: n })) : l(we({ startY: e, startX: n, endY: -1, endX: -1 })), l(ke(!0));
2075
- const z = `${S.sheetPrefix(!D)}${o}`;
2076
- return oe && De({ input: $ || null, ref: z }) || (S.registry.lastFocused = _, O(_), l(de("")), F) ? !1 : (oe && v(_.value), w.shiftKey || l(Xe({ y: e, x: n })), !0);
2075
+ const K = `${S.sheetPrefix(!D)}${o}`;
2076
+ return oe && De({ input: $ || null, ref: K }) || (S.registry.lastFocused = _, O(_), l(ue("")), F) ? !1 : (oe && v(_.value), w.shiftKey || l(Xe({ y: e, x: n })), !0);
2077
2077
  },
2078
2078
  [oe, _, o, D, $, F, v, S]
2079
2079
  ), B = k(
@@ -2085,7 +2085,7 @@ const qs = () => {
2085
2085
  }
2086
2086
  },
2087
2087
  [F, oe, _]
2088
- ), U = k(
2088
+ ), z = k(
2089
2089
  (w) => {
2090
2090
  if (!He(w) || w.type.startsWith("touch") || !S)
2091
2091
  return !1;
@@ -2098,8 +2098,8 @@ const qs = () => {
2098
2098
  if (oe && !sn($ || null))
2099
2099
  return !1;
2100
2100
  if (l(me({ y: e, x: n })), oe) {
2101
- const z = he({ ...m, endY: e, endX: n }), ue = `${S.sheetPrefix(!D)}${rn(z)}`;
2102
- De({ input: $ || null, ref: ue });
2101
+ const K = he({ ...m, endY: e, endX: n }), de = `${S.sheetPrefix(!D)}${rn(K)}`;
2102
+ De({ input: $ || null, ref: de });
2103
2103
  }
2104
2104
  return !0;
2105
2105
  },
@@ -2113,25 +2113,25 @@ const qs = () => {
2113
2113
  m,
2114
2114
  D
2115
2115
  ]
2116
- ), W = k(
2116
+ ), Z = k(
2117
2117
  (w) => {
2118
2118
  l(We({ x: n, y: e })), l(ke(!0)), w.stopPropagation();
2119
2119
  },
2120
2120
  [l, n, e]
2121
2121
  ), J = k(() => {
2122
- var z;
2123
- const w = (z = f.current) == null ? void 0 : z.getBoundingClientRect();
2122
+ var K;
2123
+ const w = (K = f.current) == null ? void 0 : K.getBoundingClientRect();
2124
2124
  w && d(ns(w));
2125
2125
  }, []), j = k(() => {
2126
2126
  d(null);
2127
- }, []), Z = k(
2127
+ }, []), U = k(
2128
2128
  (w) => T.length > 0 ? (w.stopPropagation(), fe(w), l(ze({ y: w.clientY, x: w.clientX })), !1) : !0,
2129
2129
  [T.length]
2130
2130
  ), G = k(
2131
2131
  (w) => {
2132
- w.stopPropagation(), fe(w), de(o);
2133
- const z = document.createEvent("MouseEvents");
2134
- return z.initEvent("dblclick", !0, !0), _ == null || _.dispatchEvent(z), !1;
2132
+ w.stopPropagation(), fe(w), ue(o);
2133
+ const K = document.createEvent("MouseEvents");
2134
+ return K.initEvent("dblclick", !0, !0), _ == null || _.dispatchEvent(K), !1;
2135
2135
  },
2136
2136
  [o, _]
2137
2137
  ), L = $e(() => !C && I && P.bottom === -1 || P.bottom === e && P.right === n ? "gs-autofill-drag" : "gs-autofill-drag gs-hidden", [C, I, P]);
@@ -2146,7 +2146,7 @@ const qs = () => {
2146
2146
  style: {
2147
2147
  ...u == null ? void 0 : u.style
2148
2148
  },
2149
- onContextMenu: Z,
2149
+ onContextMenu: U,
2150
2150
  onDoubleClick: G,
2151
2151
  children: /* @__PURE__ */ Y(
2152
2152
  "div",
@@ -2154,7 +2154,7 @@ const qs = () => {
2154
2154
  className: "gs-cell-inner-wrap",
2155
2155
  onMouseDown: ce,
2156
2156
  onTouchStart: ce,
2157
- onMouseEnter: U,
2157
+ onMouseEnter: z,
2158
2158
  onMouseUp: B,
2159
2159
  children: [
2160
2160
  /* @__PURE__ */ Y(
@@ -2202,7 +2202,7 @@ const qs = () => {
2202
2202
  children: A
2203
2203
  }
2204
2204
  ),
2205
- /* @__PURE__ */ a("div", { className: L, onMouseDown: W })
2205
+ /* @__PURE__ */ a("div", { className: L, onMouseDown: Z })
2206
2206
  ]
2207
2207
  }
2208
2208
  )
@@ -2307,7 +2307,7 @@ function Te({ style: e, horizontal: n = 0, vertical: t = 0, className: s = "" })
2307
2307
  ), I = k(() => {
2308
2308
  $();
2309
2309
  }, [$]);
2310
- return K(() => $, [$]), !b.current || !c && !f ? /* @__PURE__ */ a("div", { className: `gs-scroll-handle gs-hidden ${s}` }) : /* @__PURE__ */ a(
2310
+ return W(() => $, [$]), !b.current || !c && !f ? /* @__PURE__ */ a("div", { className: `gs-scroll-handle gs-hidden ${s}` }) : /* @__PURE__ */ a(
2311
2311
  "div",
2312
2312
  {
2313
2313
  style: e,
@@ -2355,7 +2355,7 @@ const er = nt(({ x: e }) => {
2355
2355
  range: { start: v, end: e },
2356
2356
  numRows: m.numRows
2357
2357
  })
2358
- ), S && D((T == null ? void 0 : T.value) ?? ""), s(de("")), s(ke(!0)), O(c.current), !d;
2358
+ ), S && D((T == null ? void 0 : T.value) ?? ""), s(ue("")), s(ke(!0)), O(c.current), !d;
2359
2359
  },
2360
2360
  [
2361
2361
  b,
@@ -2495,7 +2495,7 @@ const er = nt(({ x: e }) => {
2495
2495
  range: { start: v, end: e },
2496
2496
  numCols: m.numCols
2497
2497
  })
2498
- ), T && S((F == null ? void 0 : F.value) ?? ""), s(de("")), s(ke(!0)), O(f.current), !d;
2498
+ ), T && S((F == null ? void 0 : F.value) ?? ""), s(ue("")), s(ke(!0)), O(f.current), !d;
2499
2499
  },
2500
2500
  [
2501
2501
  b,
@@ -2634,10 +2634,10 @@ const er = nt(({ x: e }) => {
2634
2634
  qe(D, g, u, v, C, I, B.wholeArea, ar, 1, [5, 5]);
2635
2635
  }
2636
2636
  {
2637
- const { y: B, x: U } = o;
2638
- if (B !== -1 && U !== -1) {
2639
- const W = Fe(g, { y: B, x: U }), J = W.left - v, j = W.top - u;
2640
- yt(D, J, j, W.width, W.height, lt, 2, []);
2637
+ const { y: B, x: z } = o;
2638
+ if (B !== -1 && z !== -1) {
2639
+ const Z = Fe(g, { y: B, x: z }), J = Z.left - v, j = Z.top - u;
2640
+ yt(D, J, j, Z.width, Z.height, lt, 2, []);
2641
2641
  }
2642
2642
  }
2643
2643
  const { copyingSheetId: H, copyingZone: q, cutting: _ } = r;
@@ -2645,21 +2645,21 @@ const er = nt(({ x: e }) => {
2645
2645
  const B = he(q);
2646
2646
  qe(D, g, u, v, C, I, B, _ ? or : rr, 2.5, _ ? [4, 4] : [6, 4]);
2647
2647
  }
2648
- Object.entries(e).forEach(([B, U]) => {
2649
- const W = Ie[U % Ie.length];
2648
+ Object.entries(e).forEach(([B, z]) => {
2649
+ const Z = Ie[z % Ie.length];
2650
2650
  try {
2651
2651
  const J = g.rangeToArea(B);
2652
- qe(D, g, u, v, C, I, J, W, 2, [5, 5]);
2652
+ qe(D, g, u, v, C, I, J, Z, 2, [5, 5]);
2653
2653
  } catch {
2654
2654
  }
2655
- }), l.forEach((B, U) => {
2656
- const { y: W, x: J } = Rt(B), j = Fe(g, { y: W, x: J }), Z = j.left - v, G = j.top - u;
2657
- if (Z + j.width < 0 || Z > C || G + j.height < 0 || G > I)
2655
+ }), l.forEach((B, z) => {
2656
+ const { y: Z, x: J } = Rt(B), j = Fe(g, { y: Z, x: J }), U = j.left - v, G = j.top - u;
2657
+ if (U + j.width < 0 || U > C || G + j.height < 0 || G > I)
2658
2658
  return;
2659
- const L = U === h;
2659
+ const L = z === h;
2660
2660
  yt(
2661
2661
  D,
2662
- Z,
2662
+ U,
2663
2663
  G,
2664
2664
  j.width,
2665
2665
  j.height,
@@ -2671,26 +2671,26 @@ const er = nt(({ x: e }) => {
2671
2671
  }), D.restore();
2672
2672
  const oe = g.numCols, ce = g.numRows;
2673
2673
  for (let B = 1; B <= oe; B++) {
2674
- let U = null, W = null;
2675
- if (Ae({ start: i.startX, end: i.endX }, B) && (U = "rgba(80, 180, 255, 1)", W = c ? "rgba(128, 128, 128, 0.25)" : "rgba(0, 119, 255, 0.05)"), o.x === B && (U = lt, W = c ? "rgba(128, 128, 128, 0.45)" : "rgba(0, 119, 255, 0.15)"), !U)
2674
+ let z = null, Z = null;
2675
+ if (Ae({ start: i.startX, end: i.endX }, B) && (z = "rgba(80, 180, 255, 1)", Z = c ? "rgba(128, 128, 128, 0.25)" : "rgba(0, 119, 255, 0.05)"), o.x === B && (z = lt, Z = c ? "rgba(128, 128, 128, 0.45)" : "rgba(0, 119, 255, 0.15)"), !z)
2676
2676
  continue;
2677
2677
  const J = Fe(g, { y: 1, x: B }), j = J.left - v;
2678
2678
  if (j + J.width < N || j > C)
2679
2679
  continue;
2680
- const Z = Math.max(j, N), G = Math.min(j + J.width, C) - Z;
2681
- G > 0 && (W && Jt(D, Z, 0, G, A, W), D.strokeStyle = U, D.lineWidth = 2, D.beginPath(), D.moveTo(Z, A + 1), D.lineTo(Z + G, A + 1), D.stroke());
2680
+ const U = Math.max(j, N), G = Math.min(j + J.width, C) - U;
2681
+ G > 0 && (Z && Jt(D, U, 0, G, A, Z), D.strokeStyle = z, D.lineWidth = 2, D.beginPath(), D.moveTo(U, A + 1), D.lineTo(U + G, A + 1), D.stroke());
2682
2682
  }
2683
2683
  for (let B = 1; B <= ce; B++) {
2684
2684
  if (g.isRowFiltered(B))
2685
2685
  continue;
2686
- let U = null, W = null;
2687
- if (Ae({ start: i.startY, end: i.endY }, B) && (U = "rgba(80, 180, 255, 1)", W = d ? "rgba(128, 128, 128, 0.25)" : "rgba(0, 119, 255, 0.05)"), o.y === B && (U = lt, W = d ? "rgba(128, 128, 128, 0.45)" : "rgba(0, 119, 255, 0.15)"), !U)
2686
+ let z = null, Z = null;
2687
+ if (Ae({ start: i.startY, end: i.endY }, B) && (z = "rgba(80, 180, 255, 1)", Z = d ? "rgba(128, 128, 128, 0.25)" : "rgba(0, 119, 255, 0.05)"), o.y === B && (z = lt, Z = d ? "rgba(128, 128, 128, 0.45)" : "rgba(0, 119, 255, 0.15)"), !z)
2688
2688
  continue;
2689
2689
  const J = Fe(g, { y: B, x: 1 }), j = J.top - u;
2690
2690
  if (j + J.height < A || j > I)
2691
2691
  continue;
2692
- const Z = Math.max(j, A), G = Math.min(j + J.height, I) - Z;
2693
- G > 0 && (W && Jt(D, 0, Z, N, G, W), D.strokeStyle = U, D.lineWidth = 2, D.beginPath(), D.moveTo(N + 1, Z), D.lineTo(N + 1, Z + G), D.stroke());
2692
+ const U = Math.max(j, A), G = Math.min(j + J.height, I) - U;
2693
+ G > 0 && (Z && Jt(D, 0, U, N, G, Z), D.strokeStyle = z, D.lineWidth = 2, D.beginPath(), D.moveTo(N + 1, U), D.lineTo(N + 1, U + G), D.stroke());
2694
2694
  }
2695
2695
  }, [
2696
2696
  g,
@@ -2714,7 +2714,7 @@ const er = nt(({ x: e }) => {
2714
2714
  }, [E]), T = k(() => {
2715
2715
  E();
2716
2716
  }, [E]);
2717
- return K(() => (F(), () => cancelAnimationFrame(p.current)), [F]), K(() => {
2717
+ return W(() => (F(), () => cancelAnimationFrame(p.current)), [F]), W(() => {
2718
2718
  const S = s.current;
2719
2719
  if (!S)
2720
2720
  return;
@@ -2751,7 +2751,7 @@ const er = nt(({ x: e }) => {
2751
2751
  );
2752
2752
  }, ur = () => {
2753
2753
  var $, P, C, I, r, u, v, N, A;
2754
- const [e, n] = ee({}), { store: t, dispatch: s } = le(ae), {
2754
+ const [e, n] = te({}), { store: t, dispatch: s } = le(ae), {
2755
2755
  sheetReactive: o,
2756
2756
  choosing: i,
2757
2757
  editingAddress: l,
@@ -2763,7 +2763,7 @@ const er = nt(({ x: e }) => {
2763
2763
  leftHeaderSelecting: y,
2764
2764
  topHeaderSelecting: g,
2765
2765
  contextMenu: m
2766
- } = t, p = o.current, [M, E] = ee(null), F = k((R) => {
2766
+ } = t, p = o.current, [M, E] = te(null), F = k((R) => {
2767
2767
  R.preventDefault(), R.stopPropagation();
2768
2768
  }, []), T = k(
2769
2769
  (R) => {
@@ -2782,7 +2782,7 @@ const er = nt(({ x: e }) => {
2782
2782
  );
2783
2783
  }));
2784
2784
  }, [o]);
2785
- K(() => {
2785
+ W(() => {
2786
2786
  if (!p)
2787
2787
  return;
2788
2788
  if (!(l && b.startsWith("="))) {
@@ -2794,19 +2794,19 @@ const er = nt(({ x: e }) => {
2794
2794
  let oe = 0;
2795
2795
  for (const ce of _.tokens)
2796
2796
  if (ce.type === "REF" || ce.type === "RANGE") {
2797
- const B = ls(ce.stringify()), U = B.indexOf("!");
2798
- if (U !== -1) {
2799
- const W = B.substring(0, U), J = B.substring(U + 1), j = as(W), Z = J.toUpperCase();
2800
- q[j] == null && (q[j] = {}), q[j][Z] == null && (q[j][Z] = oe++);
2797
+ const B = ls(ce.stringify()), z = B.indexOf("!");
2798
+ if (z !== -1) {
2799
+ const Z = B.substring(0, z), J = B.substring(z + 1), j = as(Z), U = J.toUpperCase();
2800
+ q[j] == null && (q[j] = {}), q[j][U] == null && (q[j][U] = oe++);
2801
2801
  } else {
2802
- const W = B.toUpperCase();
2803
- H[W] == null && (H[W] = oe++);
2802
+ const Z = B.toUpperCase();
2803
+ H[Z] == null && (H[Z] = oe++);
2804
2804
  }
2805
2805
  }
2806
2806
  n(H), p.registry.paletteBySheetName = q;
2807
- }, [t.inputting, t.editingAddress, o]), K(() => {
2807
+ }, [t.inputting, t.editingAddress, o]), W(() => {
2808
2808
  p && (p.registry.choosingAddress = xe(i), p.registry.choosingSheetId = p.id);
2809
- }, [i]), K(() => {
2809
+ }, [i]), W(() => {
2810
2810
  p && E(Bt(p, h.current));
2811
2811
  }, [
2812
2812
  h.current,
@@ -2815,11 +2815,13 @@ const er = nt(({ x: e }) => {
2815
2815
  (P = f.current) == null ? void 0 : P.clientWidth,
2816
2816
  d,
2817
2817
  c
2818
- ]), K(() => {
2818
+ ]), W(() => {
2819
2819
  const R = h.current;
2820
2820
  if (R)
2821
2821
  return cs(R);
2822
- }, [o]);
2822
+ }, [o]), W(() => {
2823
+ !p || !p.eager || !p.registry.ready || p.resolveAll();
2824
+ }, [p, o]);
2823
2825
  const D = {
2824
2826
  ...e,
2825
2827
  ...p ? p.registry.paletteBySheetName[p.name] : {}
@@ -2931,7 +2933,7 @@ const er = nt(({ x: e }) => {
2931
2933
  ) });
2932
2934
  }, dr = ({ ready: e }) => {
2933
2935
  var L, Q;
2934
- const { store: n, dispatch: t } = le(ae), [s, o] = ee(""), [i, l] = ee(0), [h, f] = ee(!1), {
2936
+ const { store: n, dispatch: t } = le(ae), [s, o] = te(""), [i, l] = te(0), [h, f] = te(!1), {
2935
2937
  choosing: c,
2936
2938
  selectingZone: d,
2937
2939
  editorRef: b,
@@ -2941,22 +2943,22 @@ const er = nt(({ x: e }) => {
2941
2943
  editingAddress: p,
2942
2944
  dragging: M
2943
2945
  } = n, E = g.current, F = re(null), T = c.x === -1 ? "" : xe(c), S = E == null ? void 0 : E.getCell(c, { resolution: "SYSTEM" }), D = (L = E == null ? void 0 : E.getSystem(c)) == null ? void 0 : L.spilledFrom, $ = D ? Rt(D) : void 0, P = $ != null ? xe($) : void 0;
2944
- K(() => {
2945
- var z;
2946
+ W(() => {
2947
+ var K;
2946
2948
  if (!E)
2947
2949
  return;
2948
- let w = ((z = E.getCell(c, { resolution: "SYSTEM" })) == null ? void 0 : z.value) ?? "";
2950
+ let w = ((K = E.getCell(c, { resolution: "SYSTEM" })) == null ? void 0 : K.value) ?? "";
2949
2951
  w = E.getSerializedValue({ point: c, cell: { ...S, value: w }, resolution: "RAW" }), y.current.value = w, o(w);
2950
2952
  }, [T, E]);
2951
2953
  const C = k(
2952
2954
  (w) => {
2953
- s !== w && t(Ze({ value: w })), t(de("")), O(b.current);
2955
+ s !== w && t(Ze({ value: w })), t(ue("")), O(b.current);
2954
2956
  },
2955
2957
  [s]
2956
2958
  );
2957
- K(() => {
2958
- const w = new ResizeObserver((z) => {
2959
- z.forEach(U);
2959
+ W(() => {
2960
+ const w = new ResizeObserver((K) => {
2961
+ K.forEach(z);
2960
2962
  });
2961
2963
  return y.current && w.observe(y.current), () => {
2962
2964
  w.disconnect();
@@ -2976,14 +2978,14 @@ const er = nt(({ x: e }) => {
2976
2978
  optionsAll: r,
2977
2979
  functions: E == null ? void 0 : E.registry.functions
2978
2980
  }), _ = re(!1), oe = y.current, ce = k((w) => {
2979
- t(te(w.currentTarget.value)), l(w.currentTarget.selectionStart);
2981
+ t(ne(w.currentTarget.value)), l(w.currentTarget.selectionStart);
2980
2982
  }, []), B = k((w) => {
2981
2983
  l(w.currentTarget.selectionStart);
2982
- }, []), U = k(() => {
2984
+ }, []), z = k(() => {
2983
2985
  !F.current || !y.current || (F.current.style.height = `${y.current.clientHeight}px`, F.current.scrollLeft = y.current.scrollLeft, F.current.scrollTop = y.current.scrollTop);
2984
- }, []), W = k(
2986
+ }, []), Z = k(
2985
2987
  (w) => {
2986
- !oe || !E || (f(!0), t(de(T)), E.registry.lastFocused = w.currentTarget);
2988
+ !oe || !E || (f(!0), t(ue(T)), E.registry.lastFocused = w.currentTarget);
2987
2989
  },
2988
2990
  [oe, T, E]
2989
2991
  );
@@ -3001,21 +3003,21 @@ const er = nt(({ x: e }) => {
3001
3003
  return;
3002
3004
  if (w.ctrlKey || !E)
3003
3005
  return !0;
3004
- const z = w.currentTarget;
3006
+ const K = w.currentTarget;
3005
3007
  if (tn(w, m))
3006
- return t(te(z.value)), !1;
3008
+ return t(ne(K.value)), !1;
3007
3009
  switch (w.key) {
3008
3010
  case "Tab":
3009
3011
  if (w.preventDefault(), u.length) {
3010
- const ne = u[v];
3011
- if (ne == null ? void 0 : ne.isFunction) {
3012
- const { value: Ee, selectionStart: _e } = N(ne);
3013
- return t(te(Ee)), setTimeout(() => {
3012
+ const ee = u[v];
3013
+ if (ee == null ? void 0 : ee.isFunction) {
3014
+ const { value: Ee, selectionStart: _e } = N(ee);
3015
+ return t(ne(Ee)), setTimeout(() => {
3014
3016
  y.current && (O(y.current), y.current.setSelectionRange(_e, _e));
3015
3017
  }, 0), !1;
3016
3018
  } else {
3017
- const Ee = E.update({ diff: { [T]: { value: ne.value } }, partial: !0 });
3018
- t(Ue(Ee.clone())), t(de("")), t(te(""));
3019
+ const Ee = E.update({ diff: { [T]: { value: ee.value } }, partial: !0 });
3020
+ t(Ue(Ee.clone())), t(ue("")), t(ne(""));
3019
3021
  }
3020
3022
  }
3021
3023
  break;
@@ -3029,19 +3031,19 @@ const er = nt(({ x: e }) => {
3029
3031
  break;
3030
3032
  case "Enter": {
3031
3033
  if (u.length) {
3032
- const ne = u[v];
3033
- if (ne != null && ne.isFunction) {
3034
- const { value: ye, selectionStart: Ee } = N(ne);
3035
- return t(te(ye)), setTimeout(() => {
3034
+ const ee = u[v];
3035
+ if (ee != null && ee.isFunction) {
3036
+ const { value: ye, selectionStart: Ee } = N(ee);
3037
+ return t(ne(ye)), setTimeout(() => {
3036
3038
  y.current && (O(y.current), y.current.setSelectionRange(Ee, Ee));
3037
3039
  }, 0), w.preventDefault(), !1;
3038
3040
  }
3039
3041
  }
3040
3042
  if (w.altKey)
3041
- nn(z, `
3043
+ nn(K, `
3042
3044
  `);
3043
3045
  else
3044
- return C(z.value), t(te("")), t(
3046
+ return C(K.value), t(ne("")), t(
3045
3047
  dt({
3046
3048
  numRows: E.numRows,
3047
3049
  numCols: E.numCols,
@@ -3052,7 +3054,7 @@ const er = nt(({ x: e }) => {
3052
3054
  break;
3053
3055
  }
3054
3056
  case "Escape": {
3055
- z.value = s, t(te(s)), t(de("")), w.preventDefault(), O(b.current);
3057
+ K.value = s, t(ne(s)), t(ue("")), w.preventDefault(), O(b.current);
3056
3058
  break;
3057
3059
  }
3058
3060
  case "a":
@@ -3067,8 +3069,8 @@ const er = nt(({ x: e }) => {
3067
3069
  return !0;
3068
3070
  break;
3069
3071
  }
3070
- const ue = E.getCell(c, { resolution: "SYSTEM" });
3071
- return X.hasOperation(ue == null ? void 0 : ue.prevention, X.Write) && (console.warn("This cell is protected from writing."), w.preventDefault()), U(), !1;
3072
+ const de = E.getCell(c, { resolution: "SYSTEM" });
3073
+ return X.hasOperation(de == null ? void 0 : de.prevention, X.Write) && (console.warn("This cell is protected from writing."), w.preventDefault()), z(), !1;
3072
3074
  },
3073
3075
  [
3074
3076
  E,
@@ -3076,7 +3078,7 @@ const er = nt(({ x: e }) => {
3076
3078
  T,
3077
3079
  s,
3078
3080
  C,
3079
- U,
3081
+ z,
3080
3082
  u,
3081
3083
  v,
3082
3084
  N,
@@ -3085,32 +3087,32 @@ const er = nt(({ x: e }) => {
3085
3087
  m
3086
3088
  ]
3087
3089
  ), j = k(
3088
- (w, z) => {
3090
+ (w, K) => {
3089
3091
  w.preventDefault(), w.stopPropagation();
3090
- const ue = u[z];
3091
- if (ue.isFunction) {
3092
- const { value: ne, selectionStart: ye } = N(ue);
3093
- C(ne), t(te(ne)), setTimeout(() => {
3092
+ const de = u[K];
3093
+ if (de.isFunction) {
3094
+ const { value: ee, selectionStart: ye } = N(de);
3095
+ C(ee), t(ne(ee)), setTimeout(() => {
3094
3096
  y.current && (O(y.current), y.current.setSelectionRange(ye, ye));
3095
3097
  }, 0);
3096
3098
  }
3097
3099
  },
3098
3100
  [u, N, C, t]
3099
- ), Z = e ? {} : { visibility: "hidden" };
3101
+ ), U = e ? {} : { visibility: "hidden" };
3100
3102
  if (!E)
3101
- return /* @__PURE__ */ Y("label", { className: "gs-formula-bar gs-hidden", style: Z, children: [
3103
+ return /* @__PURE__ */ Y("label", { className: "gs-formula-bar gs-hidden", style: U, children: [
3102
3104
  /* @__PURE__ */ a("div", { className: "gs-selecting-address" }),
3103
3105
  /* @__PURE__ */ a("div", { className: "gs-fx", children: "Fx" }),
3104
3106
  /* @__PURE__ */ a("div", { className: "gs-formula-bar-editor-inner", children: /* @__PURE__ */ a("textarea", {}) })
3105
3107
  ] });
3106
3108
  const G = () => {
3107
- var ne;
3109
+ var ee;
3108
3110
  if (!h || typeof document > "u" || y.current !== document.activeElement)
3109
3111
  return null;
3110
- const w = (ne = y.current) == null ? void 0 : ne.getBoundingClientRect();
3112
+ const w = (ee = y.current) == null ? void 0 : ee.getBoundingClientRect();
3111
3113
  if (!w)
3112
3114
  return null;
3113
- const z = w.bottom, ue = w.left;
3115
+ const K = w.bottom, de = w.left;
3114
3116
  return St(
3115
3117
  /* @__PURE__ */ Y(Re, { children: [
3116
3118
  H && u.length === 0 && (!d || d.endY === -1 && d.endX === -1) && /* @__PURE__ */ a(
@@ -3118,16 +3120,16 @@ const er = nt(({ x: e }) => {
3118
3120
  {
3119
3121
  activeFunctionGuide: H,
3120
3122
  activeArgIndex: q,
3121
- top: z,
3122
- left: ue
3123
+ top: K,
3124
+ left: de
3123
3125
  }
3124
3126
  ),
3125
3127
  u.length > 0 && c.x !== -1 && /* @__PURE__ */ a(
3126
3128
  Rn,
3127
3129
  {
3128
3130
  filteredOptions: u,
3129
- top: z,
3130
- left: ue,
3131
+ top: K,
3132
+ left: de,
3131
3133
  selected: v,
3132
3134
  onOptionMouseDown: j
3133
3135
  }
@@ -3142,7 +3144,7 @@ const er = nt(({ x: e }) => {
3142
3144
  className: "gs-formula-bar",
3143
3145
  "data-sheet-id": n.sheetId,
3144
3146
  "data-spill": P != null ? "true" : void 0,
3145
- style: Z,
3147
+ style: U,
3146
3148
  children: [
3147
3149
  /* @__PURE__ */ a(Te, { style: { position: "absolute", left: 0, top: 0, zIndex: 2 }, vertical: -1 }),
3148
3150
  /* @__PURE__ */ a("div", { className: "gs-selecting-address", children: P ?? T }),
@@ -3172,20 +3174,20 @@ const er = nt(({ x: e }) => {
3172
3174
  value: m,
3173
3175
  readOnly: P != null,
3174
3176
  onInput: ce,
3175
- onFocus: W,
3177
+ onFocus: Z,
3176
3178
  onSelect: B,
3177
3179
  onPaste: (w) => {
3178
3180
  w.stopPropagation();
3179
3181
  },
3180
3182
  onKeyDown: J,
3181
- onKeyUp: U,
3183
+ onKeyUp: z,
3182
3184
  onCompositionStart: () => {
3183
3185
  _.current = !0;
3184
3186
  },
3185
3187
  onCompositionEnd: (w) => {
3186
- _.current = !1, t(te(w.currentTarget.value));
3188
+ _.current = !1, t(ne(w.currentTarget.value));
3187
3189
  },
3188
- onScroll: U,
3190
+ onScroll: z,
3189
3191
  onMouseEnter: (w) => {
3190
3192
  t(Je(!0));
3191
3193
  },
@@ -3238,7 +3240,7 @@ const er = nt(({ x: e }) => {
3238
3240
  matchingCells: y,
3239
3241
  sheetReactive: g
3240
3242
  } = e, m = g.current, p = y[b];
3241
- K(() => {
3243
+ W(() => {
3242
3244
  if (!p || !m)
3243
3245
  return;
3244
3246
  const u = Rt(p);
@@ -3369,16 +3371,17 @@ function Ar({
3369
3371
  style: l,
3370
3372
  book: h
3371
3373
  }) {
3372
- var W, J, j;
3373
- const { sheetResize: f, showFormulaBar: c = !0, mode: d = "light" } = o, b = re(null), y = re(null), g = re(null), m = re(null), p = re(null), M = re(null), E = re(null), F = mr(), T = t ?? F, S = pr(), D = s ?? S, $ = Ns({}), P = h ?? $, { registry: C } = P, [I] = ee(() => n ? (C._componentSheetIds.has(n) || C._componentSheetIds.set(n, ++C.sheetHead), C._componentSheetIds.get(n)) : ++C.sheetHead), r = re(null), [u] = ee(() => {
3374
- var ue;
3374
+ var Z, J, j;
3375
+ const { sheetResize: f, showFormulaBar: c = !0, mode: d = "light" } = o, b = re(null), y = re(null), g = re(null), m = re(null), p = re(null), M = re(null), E = re(null), F = mr(), T = t ?? F, S = pr(), D = s ?? S, $ = Ns({}), P = h ?? $, { registry: C } = P, [I] = te(() => n ? (C._componentSheetIds.has(n) || C._componentSheetIds.set(n, ++C.sheetHead), C._componentSheetIds.get(n)) : ++C.sheetHead), r = re(null), [u] = te(() => {
3376
+ var ee;
3375
3377
  n || (n = `Sheet${I}`, console.debug("GridSheet: sheetName is not provided, using default name:", n));
3376
- const { limits: Z, contextMenu: G, rowMenu: L, colMenu: Q } = o, w = new gs({
3377
- limits: Z,
3378
+ const { limits: U, contextMenu: G, rowMenu: L, colMenu: Q, eager: w } = o, K = new gs({
3379
+ limits: U,
3378
3380
  name: n,
3379
- registry: C
3381
+ registry: C,
3382
+ eager: w
3380
3383
  });
3381
- return w.id = I, C.sheetIdsByName[n] = I, w.initialize(e), (ue = C.onInit) == null || ue.call(C, { sheet: w }), w.setTotalSize(), r.current = w, {
3384
+ return K.id = I, C.sheetIdsByName[n] = I, K.initialize(e), (ee = C.onInit) == null || ee.call(C, { sheet: K }), K.setTotalSize(), r.current = K, {
3382
3385
  sheetId: I,
3383
3386
  sheetReactive: r,
3384
3387
  rootRef: b,
@@ -3421,55 +3424,55 @@ function Ar({
3421
3424
  u,
3422
3425
  () => u
3423
3426
  );
3424
- K(() => {
3427
+ W(() => {
3425
3428
  hs();
3426
3429
  }, []);
3427
- const A = typeof o.sheetWidth == "string", R = typeof o.sheetHeight == "string", [H, q] = ee(
3430
+ const A = typeof o.sheetWidth == "string", R = typeof o.sheetHeight == "string", [H, q] = te(
3428
3431
  typeof (o == null ? void 0 : o.sheetHeight) == "number" ? o.sheetHeight : yr(e)
3429
- ), [_, oe] = ee(
3432
+ ), [_, oe] = te(
3430
3433
  typeof (o == null ? void 0 : o.sheetWidth) == "number" ? o.sheetWidth : vr(e)
3431
3434
  );
3432
- K(() => {
3433
- const Z = g.current;
3434
- if (!Z)
3435
+ W(() => {
3436
+ const U = g.current;
3437
+ if (!U)
3435
3438
  return;
3436
3439
  let G = !0;
3437
3440
  const L = new ResizeObserver(() => {
3438
3441
  if (G && (G = !1, !A && !R))
3439
3442
  return;
3440
3443
  const Q = b.current;
3441
- q(Q ? Math.min(Z.clientHeight, Q.clientHeight) : Z.clientHeight), oe(Q ? Math.min(Z.clientWidth, Q.clientWidth) : Z.clientWidth);
3444
+ q(Q ? Math.min(U.clientHeight, Q.clientHeight) : U.clientHeight), oe(Q ? Math.min(U.clientWidth, Q.clientWidth) : U.clientWidth);
3442
3445
  });
3443
- return L.observe(Z), () => L.disconnect();
3444
- }, [A, R]), K(() => {
3446
+ return L.observe(U), () => L.disconnect();
3447
+ }, [A, R]), W(() => {
3445
3448
  typeof o.sheetHeight == "number" && q(o.sheetHeight);
3446
- }, [o.sheetHeight]), K(() => {
3449
+ }, [o.sheetHeight]), W(() => {
3447
3450
  typeof o.sheetWidth == "number" && oe(o.sheetWidth);
3448
3451
  }, [o.sheetWidth]);
3449
- const [ce, B] = ee(!1);
3450
- K(() => {
3452
+ const [ce, B] = te(!1);
3453
+ W(() => {
3451
3454
  ce && B(!1);
3452
3455
  });
3453
- const U = k(
3454
- (Z) => {
3455
- if (!Es(Z.type)) {
3456
- N(Z);
3456
+ const z = k(
3457
+ (U) => {
3458
+ if (!Es(U.type)) {
3459
+ N(U);
3457
3460
  return;
3458
3461
  }
3459
3462
  B(!0), requestAnimationFrame(() => {
3460
- N(Z);
3463
+ N(U);
3461
3464
  });
3462
3465
  },
3463
3466
  [N]
3464
3467
  );
3465
- return /* @__PURE__ */ a(ae.Provider, { value: { store: v, dispatch: U }, children: /* @__PURE__ */ Y(
3468
+ return /* @__PURE__ */ a(ae.Provider, { value: { store: v, dispatch: z }, children: /* @__PURE__ */ Y(
3466
3469
  "div",
3467
3470
  {
3468
3471
  className: `gs-root1 ${C.ready ? "gs-initialized" : ""}`,
3469
3472
  ref: b,
3470
3473
  "data-sheet-name": n,
3471
3474
  "data-mode": d,
3472
- "data-rows": ((W = v.sheetReactive.current) == null ? void 0 : W.numRows) ?? 0,
3475
+ "data-rows": ((Z = v.sheetReactive.current) == null ? void 0 : Z.numRows) ?? 0,
3473
3476
  "data-cols": ((J = v.sheetReactive.current) == null ? void 0 : J.numCols) ?? 0,
3474
3477
  style: A || R ? {
3475
3478
  // inline-flex (when width isn't filled) keeps the prior shrink-to-content width.