@extable/core 0.3.1 → 0.3.2

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
@@ -1259,12 +1259,12 @@ const oi = {
1259
1259
  aliases: {
1260
1260
  Fall: "Autumn"
1261
1261
  }
1262
- }, Ri = {
1262
+ }, Mi = {
1263
1263
  id: "seasons-ja",
1264
1264
  mode: "cycle",
1265
1265
  langs: ["ja"],
1266
1266
  items: ["春", "夏", "秋", "冬"]
1267
- }, Mi = {
1267
+ }, Ri = {
1268
1268
  id: "solfege-ja",
1269
1269
  mode: "cycle",
1270
1270
  langs: ["ja"],
@@ -2020,8 +2020,8 @@ const oi = {
2020
2020
  Si,
2021
2021
  xi,
2022
2022
  bi,
2023
- Ri,
2024
2023
  Mi,
2024
+ Ri,
2025
2025
  ki,
2026
2026
  Ii,
2027
2027
  Ei,
@@ -2393,10 +2393,10 @@ const ve = 1e-9, sn = 100, on = (r) => ({
2393
2393
  ...Object.keys(Nt),
2394
2394
  ...Object.keys(xe),
2395
2395
  ...Object.keys(xn)
2396
- ]), Rn = (r) => bn.has(r), Mn = (r) => /[壱弐参肆伍陸柒捌玖拾萬佰仟]/.test(r) ? "traditional" : "modern", be = (r) => {
2396
+ ]), Mn = (r) => bn.has(r), Rn = (r) => /[壱弐参肆伍陸柒捌玖拾萬佰仟]/.test(r) ? "traditional" : "modern", be = (r) => {
2397
2397
  if (!r)
2398
2398
  return null;
2399
- const t = Mn(r);
2399
+ const t = Rn(r);
2400
2400
  if (r.includes("万") || r.includes("萬")) {
2401
2401
  const o = /^([一二三四五六七八九壱弐参肆伍陸柒捌玖])?(万|萬)$/.exec(r);
2402
2402
  if (!o)
@@ -2427,7 +2427,7 @@ const ve = 1e-9, sn = 100, on = (r) => ({
2427
2427
  const t = [];
2428
2428
  let e = "", i = 0, n = 0;
2429
2429
  for (const c of r)
2430
- Rn(c) ? (e || (i = n), e += c) : e && (t.push({ start: i, end: n, text: e }), e = ""), n += c.length;
2430
+ Mn(c) ? (e || (i = n), e += c) : e && (t.push({ start: i, end: n, text: e }), e = ""), n += c.length;
2431
2431
  e && t.push({ start: i, end: n, text: e });
2432
2432
  const s = t.map((c) => ({ run: c, parsed: be(c.text) })).filter((c) => c.parsed !== null);
2433
2433
  if (s.length !== 1)
@@ -2439,7 +2439,7 @@ const ve = 1e-9, sn = 100, on = (r) => ({
2439
2439
  suffix: a,
2440
2440
  style: o.parsed.style
2441
2441
  };
2442
- }, Re = (r, t) => {
2442
+ }, Me = (r, t) => {
2443
2443
  if (!Number.isFinite(r) || r <= 0 || r > 1e4)
2444
2444
  return null;
2445
2445
  const e = t === "traditional" ? ["", "壱", "弐", "参", "肆", "伍", "陸", "柒", "捌", "玖"] : ["", "一", "二", "三", "四", "五", "六", "七", "八", "九"], i = t === "traditional" ? "拾" : "十", n = t === "traditional" ? "萬" : "万";
@@ -2457,7 +2457,7 @@ const ve = 1e-9, sn = 100, on = (r) => ({
2457
2457
  return {
2458
2458
  next() {
2459
2459
  i += 1;
2460
- const n = r + t * i, s = Re(n, e);
2460
+ const n = r + t * i, s = Me(n, e);
2461
2461
  return s ? { value: s, done: !1 } : { value: void 0, done: !0 };
2462
2462
  }
2463
2463
  };
@@ -2466,7 +2466,7 @@ const ve = 1e-9, sn = 100, on = (r) => ({
2466
2466
  return {
2467
2467
  next() {
2468
2468
  i += 1;
2469
- const n = t + e * i, s = Re(n, r.style);
2469
+ const n = t + e * i, s = Me(n, r.style);
2470
2470
  return s ? { value: `${r.prefix}${s}${r.suffix}`, done: !1 } : { value: void 0, done: !0 };
2471
2471
  }
2472
2472
  };
@@ -2671,7 +2671,7 @@ function Ln(r) {
2671
2671
  }
2672
2672
  return null;
2673
2673
  }
2674
- function Me(r, t) {
2674
+ function Re(r, t) {
2675
2675
  if (t.length !== 1) return null;
2676
2676
  const e = Dn(t[0]);
2677
2677
  if (e.kind !== "cells") return null;
@@ -2766,12 +2766,12 @@ function Ee(r, t = ke) {
2766
2766
  function Te(r, t, e) {
2767
2767
  return r >= e.left && r <= e.right && t >= e.top && t <= e.bottom;
2768
2768
  }
2769
- function Rt(r, t, e, i, n) {
2769
+ function Mt(r, t, e, i, n) {
2770
2770
  if (n === "readonly") return !1;
2771
- const s = Me(r, t);
2771
+ const s = Re(r, t);
2772
2772
  return !(!s || !e || e === "__all__" || i === null || i === "__all__" || i === null || i !== s.colKey || r.isReadonly(e, i));
2773
2773
  }
2774
- function Mt(r) {
2774
+ function Rt(r) {
2775
2775
  const t = r.style, e = t?.decorations;
2776
2776
  return {
2777
2777
  backgroundColor: t?.backgroundColor,
@@ -2797,7 +2797,7 @@ function J(r, t) {
2797
2797
  } : r;
2798
2798
  }
2799
2799
  function Fn(r, t, e) {
2800
- const i = Mt(e), n = r.resolveConditionalStyle(t, e).delta ?? {}, s = r.getCellStyle(t, e.key) ?? {}, o = J(J(i, n), s);
2800
+ const i = Rt(e), n = r.resolveConditionalStyle(t, e).delta ?? {}, s = r.getCellStyle(t, e.key) ?? {}, o = J(J(i, n), s);
2801
2801
  return { columnStyle: i, cellStyle: s, resolved: o };
2802
2802
  }
2803
2803
  function ae(r) {
@@ -2959,7 +2959,7 @@ class bt {
2959
2959
  if (this.frame += 1, !this.tableEl) return;
2960
2960
  const e = this.tableEl.parentElement, i = e?.scrollTop ?? 0, n = e?.scrollLeft ?? 0, s = this.dataModel.getSchema(), o = this.dataModel.getView(), l = this.dataModel.listRows();
2961
2961
  this.tableEl.innerHTML = "";
2962
- const a = G(s, o), c = s.columns.map((p) => Mt(p)), h = c.map((p) => ae(p)), d = this.rowHeaderWidth + a.reduce((p, v) => p + (v ?? 0), 0), u = document.createElement("colgroup"), g = document.createElement("col");
2962
+ const a = G(s, o), c = s.columns.map((p) => Rt(p)), h = c.map((p) => ae(p)), d = this.rowHeaderWidth + a.reduce((p, v) => p + (v ?? 0), 0), u = document.createElement("colgroup"), g = document.createElement("col");
2963
2963
  g.style.width = `${this.rowHeaderWidth}px`, u.appendChild(g);
2964
2964
  for (const p of a) {
2965
2965
  const v = document.createElement("col");
@@ -3081,7 +3081,7 @@ class bt {
3081
3081
  y && (g.style.width = `${y}px`);
3082
3082
  const w = l.wrapText?.[u.key] ?? u.wrapText;
3083
3083
  g.classList.add(w ? "cell-wrap" : "cell-nowrap");
3084
- const C = this.dataModel.getRawCell(t.id, u.key), S = this.dataModel.resolveCellValue(t.id, u), b = S.textOverride ?? (p.forceErrorText ? "#ERROR" : void 0), x = b ? { text: b } : this.formatValue(S.value, u), D = this.dataModel.getCellInteraction(t.id, u.key), F = u.type === "tags" && !b ? Bt(S.value) : null, M = u.type === "button" || u.type === "link", H = M ? u.type === "button" ? ut(S.value) : ft(S.value) : null, R = M ? u.type === "button" ? rt(S.value) : lt(S.value) : "";
3084
+ const C = this.dataModel.getRawCell(t.id, u.key), S = this.dataModel.resolveCellValue(t.id, u), b = S.textOverride ?? (p.forceErrorText ? "#ERROR" : void 0), x = b ? { text: b } : this.formatValue(S.value, u), D = this.dataModel.getCellInteraction(t.id, u.key), F = u.type === "tags" && !b ? Bt(S.value) : null, R = u.type === "button" || u.type === "link", H = R ? u.type === "button" ? ut(S.value) : ft(S.value) : null, M = R ? u.type === "button" ? rt(S.value) : lt(S.value) : "";
3085
3085
  if (F && F.length) {
3086
3086
  const E = document.createElement("div");
3087
3087
  E.className = "extable-tag-list", F.forEach((B, T) => {
@@ -3092,11 +3092,11 @@ class bt {
3092
3092
  const N = document.createElement("button");
3093
3093
  N.type = "button", N.className = "extable-tag-remove", N.dataset.extableTagRemove = "1", N.dataset.extableTagIndex = String(T), N.textContent = "×", (D.readonly || D.disabled) && (N.disabled = !0), A.appendChild(k), A.appendChild(N), E.appendChild(A);
3094
3094
  }), g.replaceChildren(E);
3095
- } else if (M && !b && H && R) {
3095
+ } else if (R && !b && H && M) {
3096
3096
  const E = u.type === "button" ? document.createElement("button") : document.createElement("span");
3097
- E instanceof HTMLButtonElement && (E.type = "button"), E.className = u.type === "button" ? "extable-action-button" : "extable-action-link", D.disabled && E.classList.add("extable-action-disabled"), u.type === "link" && f && (E.style.color = "inherit"), E.dataset.extableAction = u.type, E.textContent = R, g.replaceChildren(E);
3097
+ E instanceof HTMLButtonElement && (E.type = "button"), E.className = u.type === "button" ? "extable-action-button" : "extable-action-link", D.disabled && E.classList.add("extable-action-disabled"), u.type === "link" && f && (E.style.color = "inherit"), E.dataset.extableAction = u.type, E.textContent = M, g.replaceChildren(E);
3098
3098
  } else
3099
- g.textContent = R || x.text, x.color && (g.style.color = x.color);
3099
+ g.textContent = M || x.text, x.color && (g.style.color = x.color);
3100
3100
  const K = this.dataModel.getCellMarker(t.id, u.key);
3101
3101
  K ? (g.classList.toggle("extable-diag-warning", K.level === "warning"), g.classList.toggle("extable-diag-error", K.level === "error"), g.dataset.extableDiagMessage = K.message) : (g.classList.remove("extable-diag-warning", "extable-diag-error"), g.removeAttribute("data-extable-diag-message"));
3102
3102
  const L = u.style?.align ?? (u.type === "number" ? "right" : "left");
@@ -3272,7 +3272,7 @@ const U = class U {
3272
3272
  if (!e) return;
3273
3273
  e.font = "14px sans-serif";
3274
3274
  let i = e.font;
3275
- const n = this.activeRowId === "__all__" && this.activeColKey === "__all__", s = this.dataModel.getSchema(), o = this.dataModel.getView(), l = this.dataModel.listRows(), a = G(s, o), c = s.columns.map((T) => Mt(T)), h = /* @__PURE__ */ new Map(), d = s.columns.some((T) => o.wrapText?.[T.key] ?? T.wrapText), u = d ? this.getRowHeightCacheKey(s, o, a) : null;
3275
+ const n = this.activeRowId === "__all__" && this.activeColKey === "__all__", s = this.dataModel.getSchema(), o = this.dataModel.getView(), l = this.dataModel.listRows(), a = G(s, o), c = s.columns.map((T) => Rt(T)), h = /* @__PURE__ */ new Map(), d = s.columns.some((T) => o.wrapText?.[T.key] ?? T.wrapText), u = d ? this.getRowHeightCacheKey(s, o, a) : null;
3276
3276
  u !== this.rowHeightCacheKey && (this.rowHeightCacheKey = u, this.rowHeightMeasuredVersion.clear(), this.rowHeightMeasureTask = null), d || this.cancelRowHeightMeasurement(), this.ensureHeightIndex(l, d ? u : null, d);
3277
3277
  const g = this.heightIndex;
3278
3278
  if (!g) return;
@@ -3291,7 +3291,7 @@ const U = class U {
3291
3291
  };
3292
3292
  let x = g.fenwick.total();
3293
3293
  const D = this.canvas?.height ?? this.root.clientHeight, F = Math.max(0, D - this.headerHeight);
3294
- let M = Math.max(0, x - F), H = Math.max(0, Math.min(C, M)), { accum: R, visibleStart: K, visibleEnd: L } = b(H);
3294
+ let R = Math.max(0, x - F), H = Math.max(0, Math.min(C, R)), { accum: M, visibleStart: K, visibleEnd: L } = b(H);
3295
3295
  if (d && u) {
3296
3296
  const T = {};
3297
3297
  for (let A = K; A < L; A += 1) {
@@ -3302,12 +3302,12 @@ const U = class U {
3302
3302
  const V = this.measureRowHeight(e, k, s, a);
3303
3303
  T[k.id] = V, this.rowHeightMeasuredVersion.set(k.id, N);
3304
3304
  }
3305
- this.applyRowHeightUpdates(T), x = g.fenwick.total(), this.dataModel.setRowHeightsBulk(T), M = Math.max(0, x - F), H = Math.max(0, Math.min(C, M)), { accum: R, visibleStart: K, visibleEnd: L } = b(H), (this.rowHeightMeasureTask || Object.keys(T).length > 0) && this.scheduleRowHeightMeasurement();
3305
+ this.applyRowHeightUpdates(T), x = g.fenwick.total(), this.dataModel.setRowHeightsBulk(T), R = Math.max(0, x - F), H = Math.max(0, Math.min(C, R)), { accum: M, visibleStart: K, visibleEnd: L } = b(H), (this.rowHeightMeasureTask || Object.keys(T).length > 0) && this.scheduleRowHeightMeasurement();
3306
3306
  }
3307
- this.spacer && (this.spacer.style.height = `${M}px`, this.spacer.style.width = `${m}px`);
3307
+ this.spacer && (this.spacer.style.height = `${R}px`, this.spacer.style.width = `${m}px`);
3308
3308
  const _ = this.rowHeaderWidth - S;
3309
3309
  e.clearRect(0, 0, this.canvas.width, this.canvas.height), e.fillStyle = "#e5e7eb", e.fillRect(0, 0, this.rowHeaderWidth, this.canvas.height);
3310
- let E = this.headerHeight + R - H;
3310
+ let E = this.headerHeight + M - H;
3311
3311
  for (let T = K; T < L; T += 1) {
3312
3312
  const A = l[T], k = g.heights[T] ?? this.rowHeight;
3313
3313
  e.strokeStyle = "#d0d7de", e.fillStyle = "#e5e7eb", e.fillRect(0, E, this.rowHeaderWidth, k), e.strokeRect(0, E, this.rowHeaderWidth, k);
@@ -3330,7 +3330,7 @@ const U = class U {
3330
3330
  const et = this.dataModel.resolveConditionalStyle(A.id, I), ct = this.dataModel.getCellStyle(A.id, I.key), jt = c[$] ?? {}, Wt = et.delta ? J(jt, et.delta) : jt, z = ct ? J(Wt, ct) : Wt, Ke = at ? "#f3f4f6" : z.backgroundColor ?? "#ffffff";
3331
3331
  e.fillStyle = Ke, e.fillRect(V, E, P, k), e.strokeRect(V, E, P, k);
3332
3332
  const it = this.dataModel.resolveCellValue(A.id, I), qt = it.textOverride ?? (et.forceErrorText ? "#ERROR" : void 0), Et = qt ? { text: "#ERROR" } : this.formatValue(it.value, I), Tt = I.type === "button" || I.type === "link", Ut = Tt ? I.type === "button" ? ut(it.value) : ft(it.value) : null, Xt = Tt ? Ut?.label ?? (I.type === "button" ? rt(it.value) : lt(it.value)) : "", gt = !!(Tt && Ut && Xt && !qt), zt = Xt || Et.text, Gt = I.style?.align ?? (I.type === "number" ? "right" : "left");
3333
- if (this.activeRowId === A.id && this.activeColKey !== null && this.activeColKey === I.key && (e.strokeStyle = "#3b82f6", e.lineWidth = 2, e.strokeRect(V + 1, E + 1, P - 2, k - 2), e.lineWidth = 1, Rt(
3333
+ if (this.activeRowId === A.id && this.activeColKey !== null && this.activeColKey === I.key && (e.strokeStyle = "#3b82f6", e.lineWidth = 2, e.strokeRect(V + 1, E + 1, P - 2, k - 2), e.lineWidth = 1, Mt(
3334
3334
  this.dataModel,
3335
3335
  this.selection,
3336
3336
  this.activeRowId,
@@ -3514,7 +3514,7 @@ const U = class U {
3514
3514
  }
3515
3515
  hitTest(t) {
3516
3516
  if (!this.root || !this.canvas) return null;
3517
- const e = this.canvas.getBoundingClientRect(), i = t.clientX - e.left, n = t.clientY - e.top, s = i + this.root.scrollLeft, o = this.dataModel.getSchema(), l = this.dataModel.getView(), a = this.dataModel.listRows(), c = this.headerHeight, h = G(o, l), d = o.columns.some((R) => l.wrapText?.[R.key] ?? R.wrapText), u = d ? this.getRowHeightCacheKey(o, l, h) : null;
3517
+ const e = this.canvas.getBoundingClientRect(), i = t.clientX - e.left, n = t.clientY - e.top, s = i + this.root.scrollLeft, o = this.dataModel.getSchema(), l = this.dataModel.getView(), a = this.dataModel.listRows(), c = this.headerHeight, h = G(o, l), d = o.columns.some((M) => l.wrapText?.[M.key] ?? M.wrapText), u = d ? this.getRowHeightCacheKey(o, l, h) : null;
3518
3518
  this.ensureHeightIndex(a, u, d);
3519
3519
  const g = this.heightIndex;
3520
3520
  if (!g) return null;
@@ -3526,18 +3526,18 @@ const U = class U {
3526
3526
  rect: new DOMRect(e.left, e.top, this.rowHeaderWidth, c)
3527
3527
  };
3528
3528
  if (n < c) {
3529
- let R = this.rowHeaderWidth, K = -1;
3529
+ let M = this.rowHeaderWidth, K = -1;
3530
3530
  for (let L = 0; L < h.length; L += 1) {
3531
3531
  const _ = h[L] ?? 100;
3532
- if (s >= R && s <= R + _) {
3532
+ if (s >= M && s <= M + _) {
3533
3533
  K = L;
3534
3534
  break;
3535
3535
  }
3536
- R += _;
3536
+ M += _;
3537
3537
  }
3538
3538
  if (K >= 0) {
3539
3539
  const L = o.columns[K], _ = new DOMRect(
3540
- e.left + R - this.root.scrollLeft,
3540
+ e.left + M - this.root.scrollLeft,
3541
3541
  e.top,
3542
3542
  h[K] ?? 100,
3543
3543
  c
@@ -3547,9 +3547,9 @@ const U = class U {
3547
3547
  return null;
3548
3548
  }
3549
3549
  if (i < this.rowHeaderWidth) {
3550
- const R = n - c + y, K = Math.max(
3550
+ const M = n - c + y, K = Math.max(
3551
3551
  0,
3552
- Math.min(a.length - 1, g.fenwick.lowerBound(R + 1))
3552
+ Math.min(a.length - 1, g.fenwick.lowerBound(M + 1))
3553
3553
  ), L = g.fenwick.sum(K);
3554
3554
  if (K < 0 || K >= a.length) return null;
3555
3555
  const _ = a[K], E = e.top + c + L - y, B = new DOMRect(
@@ -3563,18 +3563,18 @@ const U = class U {
3563
3563
  const w = n - c + y, C = Math.max(0, Math.min(a.length - 1, g.fenwick.lowerBound(w + 1))), S = g.fenwick.sum(C);
3564
3564
  if (C < 0 || C >= a.length) return null;
3565
3565
  let b = this.rowHeaderWidth, x = -1;
3566
- for (let R = 0; R < h.length; R += 1) {
3567
- const K = h[R] ?? 100;
3566
+ for (let M = 0; M < h.length; M += 1) {
3567
+ const K = h[M] ?? 100;
3568
3568
  if (s >= b && s <= b + K) {
3569
- x = R;
3569
+ x = M;
3570
3570
  break;
3571
3571
  }
3572
3572
  b += K;
3573
3573
  }
3574
3574
  if (x === -1) return null;
3575
- const D = a[C], F = o.columns[x], M = S, H = new DOMRect(
3575
+ const D = a[C], F = o.columns[x], R = S, H = new DOMRect(
3576
3576
  e.left + b - this.root.scrollLeft,
3577
- e.top + c + M - this.root.scrollTop,
3577
+ e.top + c + R - this.root.scrollTop,
3578
3578
  h[x] ?? 100,
3579
3579
  g.heights[C] ?? this.rowHeight
3580
3580
  );
@@ -3592,7 +3592,7 @@ const U = class U {
3592
3592
  if (!a || !a.label) return null;
3593
3593
  const c = this.canvas.getContext("2d");
3594
3594
  if (!c) return null;
3595
- const h = Mt(n), d = o.delta ? J(h, o.delta) : h, u = this.dataModel.getCellStyle(e.rowId, n.key), g = u ? J(d, u) : d, m = g.bold ? "600 " : "", p = g.italic ? "italic " : "";
3595
+ const h = Rt(n), d = o.delta ? J(h, o.delta) : h, u = this.dataModel.getCellStyle(e.rowId, n.key), g = u ? J(d, u) : d, m = g.bold ? "600 " : "", p = g.italic ? "italic " : "";
3596
3596
  c.save(), c.font = `${p}${m}14px sans-serif`.trim() || "14px sans-serif", c.textBaseline = "alphabetic";
3597
3597
  const f = this.dataModel.getView().wrapText?.[n.key] ?? n.wrapText ?? !1, y = n.style?.align ?? "left", w = e.rect.left + 8, C = e.rect.top + 2, S = Math.max(0, e.rect.width - 12), b = Math.max(0, e.rect.height - 8), x = this.measureTextBounds(
3598
3598
  c,
@@ -3605,8 +3605,8 @@ const U = class U {
3605
3605
  y
3606
3606
  );
3607
3607
  if (c.restore(), !x) return null;
3608
- const D = n.type === "button" ? 6 : 2, F = Math.max(e.rect.left, x.x - D), M = Math.max(e.rect.top, x.y - D), H = Math.min(e.rect.right, x.x + x.width + D), R = Math.min(e.rect.bottom, x.y + x.height + D);
3609
- return t.clientX >= F && t.clientX <= H && t.clientY >= M && t.clientY <= R ? { rowId: e.rowId, colKey: String(e.colKey), kind: n.type } : null;
3608
+ const D = n.type === "button" ? 6 : 2, F = Math.max(e.rect.left, x.x - D), R = Math.max(e.rect.top, x.y - D), H = Math.min(e.rect.right, x.x + x.width + D), M = Math.min(e.rect.bottom, x.y + x.height + D);
3609
+ return t.clientX >= F && t.clientX <= H && t.clientY >= R && t.clientY <= M ? { rowId: e.rowId, colKey: String(e.colKey), kind: n.type } : null;
3610
3610
  }
3611
3611
  isPointInSelection(t, e) {
3612
3612
  if (!this.selection.length) return !1;
@@ -3668,18 +3668,18 @@ const U = class U {
3668
3668
  const S = this.dataModel.getSchema(), b = this.dataModel.getView(), x = G(S, b);
3669
3669
  let D = this.rowHeaderWidth, F = -1;
3670
3670
  for (let H = 0; H < x.length; H += 1) {
3671
- const R = x[H] ?? 100;
3672
- if (m >= D && m <= D + R) {
3671
+ const M = x[H] ?? 100;
3672
+ if (m >= D && m <= D + M) {
3673
3673
  F = H;
3674
3674
  break;
3675
3675
  }
3676
- D += R;
3676
+ D += M;
3677
3677
  }
3678
- const M = F >= 0 ? S.columns[F] : null;
3679
- if (M) {
3680
- y = M.key;
3681
- const H = x[F] ?? 100, R = 18, L = D + H - R - 4, _ = Math.floor((this.headerHeight - R) / 2);
3682
- w = m >= L && m <= L + R && p >= _ && p <= _ + R;
3678
+ const R = F >= 0 ? S.columns[F] : null;
3679
+ if (R) {
3680
+ y = R.key;
3681
+ const H = x[F] ?? 100, M = 18, L = D + H - M - 4, _ = Math.floor((this.headerHeight - M) / 2);
3682
+ w = m >= L && m <= L + M && p >= _ && p <= _ + M;
3683
3683
  }
3684
3684
  }
3685
3685
  const C = String(v ?? "") !== String(y ?? "") || !!f != !!w;
@@ -3725,7 +3725,7 @@ const U = class U {
3725
3725
  this.canvas.style.cursor = "cell";
3726
3726
  return;
3727
3727
  }
3728
- if (this.activeRowId && this.activeColKey !== null && this.activeRowId !== "__all__" && this.activeColKey !== "__all__" && Rt(
3728
+ if (this.activeRowId && this.activeColKey !== null && this.activeRowId !== "__all__" && this.activeColKey !== "__all__" && Mt(
3729
3729
  this.dataModel,
3730
3730
  this.selection,
3731
3731
  this.activeRowId,
@@ -3880,18 +3880,18 @@ class On {
3880
3880
  const y = f.target;
3881
3881
  if (y?.closest('button[data-extable-fs-open="1"]') || y?.closest(".extable-filter-sort-trigger") || this.inputEl && f.target && this.inputEl.contains(f.target)) return;
3882
3882
  if (this.inputEl && this.activeCell && this.activeCell.colKey !== null) {
3883
- const { rowId: M, colKey: H } = this.activeCell, R = this.readActiveValue();
3884
- this.commitEdit(M, H, R), this.onMove(M), this.teardownInput(!1);
3883
+ const { rowId: R, colKey: H } = this.activeCell, M = this.readActiveValue();
3884
+ this.commitEdit(R, H, M), this.onMove(R), this.teardownInput(!1);
3885
3885
  }
3886
3886
  if (this.fillDragging) return;
3887
3887
  const w = this.hitTest(f);
3888
3888
  if (!w || w.rowId === "__all__" && w.colKey === "__all__" || w.colKey === "__all__") return;
3889
- const C = Me(this.dataModel, this.selectionRanges);
3889
+ const C = Re(this.dataModel, this.selectionRanges);
3890
3890
  if (C && this.activeCell) {
3891
- const M = this.dataModel.getSchema(), H = this.dataModel.listRows(), R = C.endRowIndex, K = C.colIndex, L = H[R], _ = M.columns[K];
3891
+ const R = this.dataModel.getSchema(), H = this.dataModel.listRows(), M = C.endRowIndex, K = C.colIndex, L = H[M], _ = R.columns[K];
3892
3892
  if (L && _) {
3893
3893
  const E = this.findHtmlCellElement(L.id, _.key)?.getBoundingClientRect() ?? this.computeCanvasCellRect(L.id, _.key);
3894
- if (E && Rt(
3894
+ if (E && Mt(
3895
3895
  this.dataModel,
3896
3896
  this.selectionRanges,
3897
3897
  this.activeCell.rowId,
@@ -3919,20 +3919,20 @@ class On {
3919
3919
  }
3920
3920
  }
3921
3921
  }
3922
- const S = this.dataModel.getSchema(), b = this.dataModel.listRows(), x = w.rowId === "__header__" ? 0 : this.dataModel.getRowIndex(w.rowId), D = S.columns.findIndex((M) => String(M.key) === String(w.colKey));
3922
+ const S = this.dataModel.getSchema(), b = this.dataModel.listRows(), x = w.rowId === "__header__" ? 0 : this.dataModel.getRowIndex(w.rowId), D = S.columns.findIndex((R) => String(R.key) === String(w.colKey));
3923
3923
  if (D < 0) return;
3924
3924
  if (w.rowId === "__header__") {
3925
3925
  if (!b.length) return;
3926
- const M = {
3926
+ const R = {
3927
3927
  kind: "cells",
3928
3928
  startRow: 0,
3929
3929
  endRow: b.length - 1,
3930
3930
  startCol: D,
3931
3931
  endCol: D
3932
3932
  };
3933
- this.selectionRanges = [M], this.onSelectionChange(this.selectionRanges), this.dragging = !1, this.selectionMode = !0, this.dragStart = null, this.selectionAnchor = null, this.suppressNextClick = !1;
3934
- const H = b[0], R = S.columns[D];
3935
- H && R && (this.activeCell = { rowId: H.id, colKey: R.key }, this.onActiveChange(H.id, R.key)), this.focusSelectionInput("");
3933
+ this.selectionRanges = [R], this.onSelectionChange(this.selectionRanges), this.dragging = !1, this.selectionMode = !0, this.dragStart = null, this.selectionAnchor = null, this.suppressNextClick = !1;
3934
+ const H = b[0], M = S.columns[D];
3935
+ H && M && (this.activeCell = { rowId: H.id, colKey: M.key }, this.onActiveChange(H.id, M.key)), this.focusSelectionInput("");
3936
3936
  return;
3937
3937
  }
3938
3938
  if (x < 0) return;
@@ -3992,8 +3992,29 @@ class On {
3992
3992
  f.preventDefault();
3993
3993
  const y = f.clipboardData?.getData("text/html") ?? "", w = f.clipboardData?.getData("text/tab-separated-values") ?? "", C = f.clipboardData?.getData("text/plain") ?? "", S = this.parseClipboardGrid({ html: y, tsv: w, text: C });
3994
3994
  S && this.applyClipboardGrid(S);
3995
- }, this.handleSelectionCompositionStart = () => {
3996
- this.selectionMode && (this.selectionMode = !1, this.teardownSelectionInput(), this.openEditorAtActiveCell());
3995
+ }, this.handleSelectionCompositionStart = (f) => {
3996
+ if (!this.selectionMode) return;
3997
+ const y = this.activeCell;
3998
+ if (!(!y || y.colKey === null)) {
3999
+ if (this.isCellReadonly(y.rowId, y.colKey)) {
4000
+ f?.preventDefault?.(), f?.stopPropagation?.();
4001
+ const w = this.dataModel.getCell(y.rowId, y.colKey), C = this.cellToClipboardString(w);
4002
+ this.teardownSelectionInput(), this.focusSelectionInput(C);
4003
+ return;
4004
+ }
4005
+ this.selectionMode = !1, this.teardownSelectionInput(), this.openEditorAtActiveCell();
4006
+ }
4007
+ }, this.handleSelectionBeforeInput = (f) => {
4008
+ if (!this.selectionMode) return;
4009
+ const y = this.activeCell;
4010
+ if (!(!y || y.colKey === null) && this.isCellReadonly(y.rowId, y.colKey)) {
4011
+ f.preventDefault();
4012
+ try {
4013
+ const w = this.dataModel.getCell(y.rowId, y.colKey), C = this.cellToClipboardString(w), S = this.ensureSelectionInput();
4014
+ S.value = C, S.select();
4015
+ } catch {
4016
+ }
4017
+ }
3997
4018
  }, this.handleSelectionKeydown = async (f) => {
3998
4019
  if (!this.selectionMode || !this.activeCell || f.isComposing || this.composing || f.key === "Shift" || f.key === "Control" || f.key === "Alt" || f.key === "Meta" || f.key === "CapsLock" || f.key === "NumLock" || f.key === "ScrollLock")
3999
4020
  return;
@@ -4063,8 +4084,8 @@ class On {
4063
4084
  if (this.inputEl && f.target && this.inputEl.contains(f.target))
4064
4085
  return;
4065
4086
  if (this.inputEl && this.activeCell && this.activeCell.colKey !== null) {
4066
- const { rowId: M, colKey: H } = this.activeCell, R = this.readActiveValue();
4067
- this.commitEdit(M, H, R), this.onMove(M), this.teardownInput(!1);
4087
+ const { rowId: R, colKey: H } = this.activeCell, M = this.readActiveValue();
4088
+ this.commitEdit(R, H, M), this.onMove(R), this.teardownInput(!1);
4068
4089
  }
4069
4090
  const w = typeof document.elementFromPoint == "function" ? this.getHitAtClientPoint(f.clientX, f.clientY) : this.hitTest(f);
4070
4091
  if (!w) return;
@@ -4082,27 +4103,27 @@ class On {
4082
4103
  } else globalThis.__EXTABLE_DEBUG_ACTIONS && console.log("[extable][canvas][action-click]", null);
4083
4104
  const S = this.selectionMode && !f.shiftKey && !f.metaKey && !f.ctrlKey && this.activeCell?.rowId === w.rowId && String(this.activeCell?.colKey) === String(w.colKey);
4084
4105
  if (w.rowId === "__all__" && w.colKey === "__all__") {
4085
- const M = this.dataModel.getSchema(), H = this.dataModel.listRows();
4086
- this.teardownInput(!1), H.length && M.columns.length ? (this.selectionRanges = [
4106
+ const R = this.dataModel.getSchema(), H = this.dataModel.listRows();
4107
+ this.teardownInput(!1), H.length && R.columns.length ? (this.selectionRanges = [
4087
4108
  {
4088
4109
  kind: "cells",
4089
4110
  startRow: 0,
4090
4111
  endRow: H.length - 1,
4091
4112
  startCol: 0,
4092
- endCol: M.columns.length - 1
4113
+ endCol: R.columns.length - 1
4093
4114
  }
4094
4115
  ], this.activeCell = { rowId: "__all__", colKey: "__all__" }, this.onActiveChange("__all__", "__all__"), this.onSelectionChange(this.selectionRanges), this.updateFillHandleFlag(), this.selectionMode = !0, this.selectionAnchor = null, this.focusSelectionInput("")) : (this.activeCell = null, this.onActiveChange("__all__", "__all__"), this.selectionAnchor = null);
4095
4116
  return;
4096
4117
  }
4097
4118
  if (this.onRowSelect(w.rowId), w.rowId === "__header__") {
4098
- const M = this.dataModel.getSchema(), H = this.dataModel.listRows(), R = M.columns.findIndex((K) => String(K.key) === String(w.colKey));
4099
- H.length && R >= 0 && (this.selectionRanges = [
4119
+ const R = this.dataModel.getSchema(), H = this.dataModel.listRows(), M = R.columns.findIndex((K) => String(K.key) === String(w.colKey));
4120
+ H.length && M >= 0 && (this.selectionRanges = [
4100
4121
  {
4101
4122
  kind: "cells",
4102
4123
  startRow: 0,
4103
4124
  endRow: H.length - 1,
4104
- startCol: R,
4105
- endCol: R
4125
+ startCol: M,
4126
+ endCol: M
4106
4127
  }
4107
4128
  ], this.activeCell = { rowId: H[0].id, colKey: w.colKey }, this.onActiveChange(this.activeCell.rowId, this.activeCell.colKey), this.onSelectionChange(this.selectionRanges), this.updateFillHandleFlag(), this.selectionMode = !0, this.selectionAnchor = null, this.focusSelectionInput(""));
4108
4129
  return;
@@ -4117,13 +4138,13 @@ class On {
4117
4138
  }
4118
4139
  if (this.isCellReadonly(w.rowId, w.colKey)) {
4119
4140
  this.selectionMode = !0, this.selectionAnchor = null, this.teardownInput(!1);
4120
- const M = this.dataModel.getCell(w.rowId, w.colKey);
4121
- this.focusSelectionInput(this.cellToClipboardString(M));
4141
+ const R = this.dataModel.getCell(w.rowId, w.colKey);
4142
+ this.focusSelectionInput(this.cellToClipboardString(R));
4122
4143
  return;
4123
4144
  }
4124
4145
  if (this.findColumn(w.colKey)?.type === "boolean") {
4125
- const M = this.lastBooleanCell?.rowId === w.rowId && String(this.lastBooleanCell?.colKey) === String(w.colKey);
4126
- if (this.lastBooleanCell = { rowId: w.rowId, colKey: w.colKey }, this.selectionMode = !0, this.selectionAnchor = null, this.teardownInput(!1), this.teardownSelectionInput(), M) {
4146
+ const R = this.lastBooleanCell?.rowId === w.rowId && String(this.lastBooleanCell?.colKey) === String(w.colKey);
4147
+ if (this.lastBooleanCell = { rowId: w.rowId, colKey: w.colKey }, this.selectionMode = !0, this.selectionAnchor = null, this.teardownInput(!1), this.teardownSelectionInput(), R) {
4127
4148
  this.toggleBoolean(w.rowId, w.colKey), this.focusSelectionInput("");
4128
4149
  return;
4129
4150
  }
@@ -4230,7 +4251,7 @@ class On {
4230
4251
  }
4231
4252
  updateFillHandleFlag() {
4232
4253
  const t = this.activeCell?.colKey ?? null, e = this.activeCell?.rowId ?? null;
4233
- this.root.dataset.extableFillHandle = Rt(
4254
+ this.root.dataset.extableFillHandle = Mt(
4234
4255
  this.dataModel,
4235
4256
  this.selectionRanges,
4236
4257
  e,
@@ -4303,7 +4324,7 @@ class On {
4303
4324
  ensureSelectionInput() {
4304
4325
  if (this.selectionInput) return this.selectionInput;
4305
4326
  const t = document.createElement("input");
4306
- return t.type = "text", t.autocomplete = "off", t.spellcheck = !1, t.style.position = "absolute", t.style.left = "0", t.style.top = "0", t.style.transform = "translate(-10000px, 0)", t.style.width = "1px", t.style.height = "1px", t.style.opacity = "0", t.style.pointerEvents = "none", t.addEventListener("keydown", this.handleSelectionKeydown), t.addEventListener("compositionstart", this.handleSelectionCompositionStart), t.addEventListener("copy", this.handleSelectionCopy), t.addEventListener("cut", this.handleSelectionCut), t.addEventListener("paste", this.handleSelectionPaste), t.addEventListener("blur", this.handleSelectionBlur), this.root.appendChild(t), this.selectionInput = t, t;
4327
+ return t.type = "text", t.readOnly = !0, t.inputMode = "none", t.autocomplete = "off", t.spellcheck = !1, t.style.position = "absolute", t.style.left = "0", t.style.top = "0", t.style.transform = "translate(-10000px, 0)", t.style.width = "1px", t.style.height = "1px", t.style.opacity = "0", t.style.pointerEvents = "none", t.addEventListener("keydown", this.handleSelectionKeydown), t.addEventListener("beforeinput", this.handleSelectionBeforeInput), t.addEventListener("compositionstart", this.handleSelectionCompositionStart), t.addEventListener("copy", this.handleSelectionCopy), t.addEventListener("cut", this.handleSelectionCut), t.addEventListener("paste", this.handleSelectionPaste), t.addEventListener("blur", this.handleSelectionBlur), this.root.appendChild(t), this.selectionInput = t, t;
4307
4328
  }
4308
4329
  focusSelectionInput(t) {
4309
4330
  const e = this.ensureSelectionInput();
@@ -4605,7 +4626,7 @@ class On {
4605
4626
  }
4606
4627
  teardownSelectionInput() {
4607
4628
  const t = this.selectionInput;
4608
- t && (this.selectionInput = null, t.removeEventListener("keydown", this.handleSelectionKeydown), t.removeEventListener("compositionstart", this.handleSelectionCompositionStart), t.removeEventListener("copy", this.handleSelectionCopy), t.removeEventListener("cut", this.handleSelectionCut), t.removeEventListener("paste", this.handleSelectionPaste), t.removeEventListener("blur", this.handleSelectionBlur), j(t));
4629
+ t && (this.selectionInput = null, t.removeEventListener("keydown", this.handleSelectionKeydown), t.removeEventListener("beforeinput", this.handleSelectionBeforeInput), t.removeEventListener("compositionstart", this.handleSelectionCompositionStart), t.removeEventListener("copy", this.handleSelectionCopy), t.removeEventListener("cut", this.handleSelectionCut), t.removeEventListener("paste", this.handleSelectionPaste), t.removeEventListener("blur", this.handleSelectionBlur), j(t));
4609
4630
  }
4610
4631
  async copySelection() {
4611
4632
  const t = this.buildSelectionClipboardPayload();