@ishibashi0112/spreadsheet-grid-core 1.2.0 → 1.3.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.
Files changed (118) hide show
  1. package/dist/controllers/clipboardController.cjs +1 -1
  2. package/dist/controllers/clipboardController.d.ts +1 -0
  3. package/dist/controllers/clipboardController.js +79 -70
  4. package/dist/controllers/columnMenuController.cjs +1 -1
  5. package/dist/controllers/columnMenuController.js +75 -73
  6. package/dist/controllers/contextMenuController.cjs +1 -1
  7. package/dist/controllers/contextMenuController.js +63 -61
  8. package/dist/controllers/detailRowController.cjs +1 -0
  9. package/dist/controllers/detailRowController.d.ts +41 -0
  10. package/dist/controllers/detailRowController.js +97 -0
  11. package/dist/controllers/detailTabOrder.cjs +1 -1
  12. package/dist/controllers/detailTabOrder.js +17 -16
  13. package/dist/controllers/editController.cjs +1 -1
  14. package/dist/controllers/editController.d.ts +4 -1
  15. package/dist/controllers/editController.js +163 -91
  16. package/dist/controllers/escapeClaimController.cjs +1 -1
  17. package/dist/controllers/escapeClaimController.js +23 -19
  18. package/dist/controllers/fillHandleController.cjs +1 -1
  19. package/dist/controllers/fillHandleController.js +107 -106
  20. package/dist/controllers/filterPopoverController.cjs +1 -1
  21. package/dist/controllers/filterPopoverController.js +1 -0
  22. package/dist/controllers/imeInputController.cjs +1 -1
  23. package/dist/controllers/imeInputController.js +87 -76
  24. package/dist/controllers/keyboardController.cjs +1 -1
  25. package/dist/controllers/keyboardController.d.ts +4 -0
  26. package/dist/controllers/keyboardController.js +101 -97
  27. package/dist/controllers/liveUiState.cjs +1 -0
  28. package/dist/controllers/liveUiState.d.ts +7 -0
  29. package/dist/controllers/liveUiState.js +4 -0
  30. package/dist/controllers/pointerInteractionsController.cjs +1 -1
  31. package/dist/controllers/pointerInteractionsController.d.ts +1 -0
  32. package/dist/controllers/pointerInteractionsController.js +127 -126
  33. package/dist/controllers/popoverSupport.cjs +1 -1
  34. package/dist/controllers/popoverSupport.d.ts +3 -0
  35. package/dist/controllers/popoverSupport.js +62 -41
  36. package/dist/controllers/toolPanelController.cjs +1 -1
  37. package/dist/controllers/toolPanelController.js +74 -73
  38. package/dist/controllers/tooltipController.cjs +1 -1
  39. package/dist/controllers/tooltipController.d.ts +1 -1
  40. package/dist/controllers/tooltipController.js +122 -97
  41. package/dist/controllers/viewportSyncController.cjs +1 -1
  42. package/dist/controllers/viewportSyncController.js +55 -54
  43. package/dist/engine/cellCommands.cjs +1 -0
  44. package/dist/engine/cellCommands.d.ts +27 -0
  45. package/dist/engine/cellCommands.js +89 -0
  46. package/dist/engine/columnCommands.cjs +1 -1
  47. package/dist/engine/columnCommands.d.ts +2 -1
  48. package/dist/engine/columnCommands.js +98 -67
  49. package/dist/engine/exportCommands.cjs +1 -1
  50. package/dist/engine/exportCommands.js +2 -2
  51. package/dist/engine/gridApi.cjs +6 -5
  52. package/dist/engine/gridApi.d.ts +3 -0
  53. package/dist/engine/gridApi.js +158 -144
  54. package/dist/engine/rowSelectionCommands.cjs +1 -1
  55. package/dist/engine/rowSelectionCommands.d.ts +5 -0
  56. package/dist/engine/rowSelectionCommands.js +73 -38
  57. package/dist/locales/en.cjs +1 -1
  58. package/dist/locales/en.js +2 -2
  59. package/dist/logic/cellPlacement.cjs +1 -0
  60. package/dist/logic/cellPlacement.d.ts +22 -0
  61. package/dist/logic/cellPlacement.js +44 -0
  62. package/dist/logic/contextMenuTarget.cjs +1 -1
  63. package/dist/logic/contextMenuTarget.d.ts +20 -2
  64. package/dist/logic/contextMenuTarget.js +62 -3
  65. package/dist/logic/dateFilterCondition.cjs +1 -1
  66. package/dist/logic/dateFilterCondition.d.ts +1 -0
  67. package/dist/logic/dateFilterCondition.js +17 -13
  68. package/dist/logic/density.cjs +1 -0
  69. package/dist/logic/density.d.ts +5 -0
  70. package/dist/logic/density.js +17 -0
  71. package/dist/logic/detailRow.cjs +1 -1
  72. package/dist/logic/detailRow.d.ts +6 -1
  73. package/dist/logic/detailRow.js +21 -17
  74. package/dist/logic/domGuards.cjs +1 -1
  75. package/dist/logic/domGuards.d.ts +10 -0
  76. package/dist/logic/domGuards.js +18 -2
  77. package/dist/logic/editorKeys.cjs +1 -0
  78. package/dist/logic/editorKeys.d.ts +30 -0
  79. package/dist/logic/editorKeys.js +34 -0
  80. package/dist/logic/editorStart.cjs +1 -0
  81. package/dist/logic/editorStart.d.ts +7 -0
  82. package/dist/logic/editorStart.js +23 -0
  83. package/dist/logic/editorValues.cjs +1 -1
  84. package/dist/logic/editorValues.d.ts +1 -0
  85. package/dist/logic/editorValues.js +10 -7
  86. package/dist/logic/gridBarSummary.cjs +1 -0
  87. package/dist/logic/gridBarSummary.d.ts +27 -0
  88. package/dist/logic/gridBarSummary.js +137 -0
  89. package/dist/logic/gridState.cjs +1 -1
  90. package/dist/logic/gridState.d.ts +1 -0
  91. package/dist/logic/gridState.js +19 -16
  92. package/dist/logic/localeText.cjs +1 -1
  93. package/dist/logic/localeText.js +2 -2
  94. package/dist/logic/rowDragTarget.cjs +1 -0
  95. package/dist/logic/rowDragTarget.d.ts +14 -0
  96. package/dist/logic/rowDragTarget.js +47 -0
  97. package/dist/logic/selectEditorState.cjs +1 -1
  98. package/dist/logic/selectEditorState.d.ts +27 -4
  99. package/dist/logic/selectEditorState.js +29 -14
  100. package/dist/logic/valueFormatters.d.ts +8 -3
  101. package/dist/model/gridTypes.core.d.ts +31 -12
  102. package/dist/utils/clipboard.cjs +4 -4
  103. package/dist/utils/clipboard.js +60 -59
  104. package/dist/utils/editorVisibleBounds.cjs +1 -0
  105. package/dist/utils/editorVisibleBounds.d.ts +10 -0
  106. package/dist/utils/editorVisibleBounds.js +40 -0
  107. package/dist/utils/errorBubblePlacement.cjs +1 -0
  108. package/dist/utils/errorBubblePlacement.d.ts +8 -0
  109. package/dist/utils/errorBubblePlacement.js +26 -0
  110. package/dist/utils/multilineEditor.cjs +2 -0
  111. package/dist/utils/multilineEditor.d.ts +7 -0
  112. package/dist/utils/multilineEditor.js +22 -0
  113. package/dist/utils/popupContainer.cjs +1 -1
  114. package/dist/utils/popupContainer.js +35 -28
  115. package/dist/utils/shadowDom.cjs +1 -0
  116. package/dist/utils/shadowDom.d.ts +5 -0
  117. package/dist/utils/shadowDom.js +33 -0
  118. package/package.json +1 -1
@@ -1,11 +1,12 @@
1
1
  import { getCellValue as e, setCellValue as t } from "./permissions.js";
2
- import { isSyntheticColumnKey as n } from "../logic/detailRow.js";
3
- import { normalizeCellRange as r, normalizeColumnRange as i, normalizeRowRange as a } from "../model/gridSelectors.js";
4
- import { formatCellClipboardText as o } from "../logic/selectLabels.js";
5
- import { resolveCellParser as s } from "../logic/editorValues.js";
6
- import { decideCellWrite as c } from "../logic/validation.js";
2
+ import { getDeepActiveElement as n } from "./shadowDom.js";
3
+ import { isSyntheticColumnKey as r } from "../logic/detailRow.js";
4
+ import { normalizeCellRange as i, normalizeColumnRange as a, normalizeRowRange as o } from "../model/gridSelectors.js";
5
+ import { formatCellClipboardText as s } from "../logic/selectLabels.js";
6
+ import { resolveCellParser as c } from "../logic/editorValues.js";
7
+ import { decideCellWrite as l } from "../logic/validation.js";
7
8
  //#region src/utils/clipboard.ts
8
- var l = (e) => {
9
+ var u = (e) => {
9
10
  let t = e.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
10
11
  if (!t) return [];
11
12
  let n = [], r = [], i = "", a = 0, o = t.length, s = -1, c = 0;
@@ -43,91 +44,91 @@ var l = (e) => {
43
44
  i += e, a += 1;
44
45
  }
45
46
  return i === "" && r.length === 0 && t.endsWith("\n") || (r.push(i), n.push(r)), n;
46
- }, u = (e) => /[\t\n\r"]/.test(e) ? `"${e.replace(/"/g, "\"\"")}"` : e, d = (e) => e.map(u).join(" "), f = (e) => {
47
+ }, d = (e) => /[\t\n\r"]/.test(e) ? `"${e.replace(/"/g, "\"\"")}"` : e, f = (e) => e.map(d).join(" "), p = (e) => {
47
48
  let t = e[e.length - 1], n = e.join("\n");
48
49
  return t !== void 0 && /^\t*$/.test(t) ? `${n}\n` : n;
49
- }, p = (e) => e !== void 0 && !n(e.key), m = (e, t, n) => {
50
+ }, m = (e) => e !== void 0 && !r(e.key), h = (e, t, n) => {
50
51
  let r = [];
51
52
  for (let i = t; r.length < n; i += 1) {
52
53
  let t = e[i];
53
- (t === void 0 || p(t)) && r.push(i);
54
+ (t === void 0 || m(t)) && r.push(i);
54
55
  }
55
56
  return r;
56
- }, h = (t, n) => o(n, e(t, n), t), g = (e) => e.filter(p), _ = (e, t, n, o, s) => {
57
- if (!o) return "";
57
+ }, g = (t, n) => s(n, e(t, n), t), _ = (e) => e.filter(m), v = (e, t, n, r, s) => {
58
+ if (!r) return "";
58
59
  let c = [];
59
- if (o.type === "cell") {
60
- let t = r(o.range), i = n.slice(t.start.col, t.end.col + 1).filter(p);
61
- if (i.length === 0) return "";
60
+ if (r.type === "cell") {
61
+ let t = i(r.range), a = n.slice(t.start.col, t.end.col + 1).filter(m);
62
+ if (a.length === 0) return "";
62
63
  for (let n = t.start.row; n <= t.end.row; n += 1) {
63
64
  let t = e(n);
64
- t && (s && !s(t, n) || c.push(d(i.map((e) => h(t, e)))));
65
+ t && (s && !s(t, n) || c.push(f(a.map((e) => g(t, e)))));
65
66
  }
66
- return f(c);
67
+ return p(c);
67
68
  }
68
- if (o.type === "row") {
69
- let t = a(o.startRow, o.endRow), r = n.filter(p);
70
- if (r.length === 0) return "";
69
+ if (r.type === "row") {
70
+ let t = o(r.startRow, r.endRow), i = n.filter(m);
71
+ if (i.length === 0) return "";
71
72
  for (let n = t.startRow; n <= t.endRow; n += 1) {
72
73
  let t = e(n);
73
- t && (s && !s(t, n) || c.push(d(r.map((e) => h(t, e)))));
74
+ t && (s && !s(t, n) || c.push(f(i.map((e) => g(t, e)))));
74
75
  }
75
- return f(c);
76
+ return p(c);
76
77
  }
77
- let l = i(o.startCol, o.endCol), u = n.slice(l.startCol, l.endCol + 1).filter(p);
78
+ let l = a(r.startCol, r.endCol), u = n.slice(l.startCol, l.endCol + 1).filter(m);
78
79
  if (u.length === 0) return "";
79
80
  for (let n = 0; n < t; n += 1) {
80
81
  let t = e(n);
81
- t && (s && !s(t, n) || c.push(d(u.map((e) => h(t, e)))));
82
+ t && (s && !s(t, n) || c.push(f(u.map((e) => g(t, e)))));
82
83
  }
83
- return f(c);
84
- }, v = (e, n, r, i, a, o, l, u, d) => {
84
+ return p(c);
85
+ }, y = (e, n, r, i, a, o, s, u, d) => {
85
86
  if (i.length === 0) return e;
86
- let f = [...e], p = m(r, o, i.reduce((e, t) => Math.max(e, t.length), 0));
87
+ let f = [...e], p = !1, m = h(r, o, i.reduce((e, t) => Math.max(e, t.length), 0));
87
88
  for (let e = 0; e < i.length; e += 1) {
88
- let o = a + e, m = n(o);
89
- if (m === void 0) continue;
90
- let h = f[m];
91
- if (!h) continue;
92
- let g = h, _ = !1;
89
+ let o = a + e, h = n(o);
90
+ if (h === void 0) continue;
91
+ let g = f[h];
92
+ if (!g) continue;
93
+ let _ = g, v = !1;
93
94
  for (let n = 0; n < i[e].length; n += 1) {
94
- let a = p[n], f = r[a];
95
+ let a = m[n], f = r[a];
95
96
  if (!f) continue;
96
- let v = i[e][n];
97
- if (!l(m, a, h, f, o)) {
97
+ let p = i[e][n];
98
+ if (!s(h, a, g, f, o)) {
98
99
  u?.({
99
100
  rowIndex: o,
100
- sourceRowIndex: m,
101
+ sourceRowIndex: h,
101
102
  colIndex: a,
102
- row: h,
103
+ row: g,
103
104
  column: f,
104
- text: v,
105
+ text: p,
105
106
  reason: "readOnly"
106
107
  });
107
108
  continue;
108
109
  }
109
- let y = s(f)(v, h), b = c(f, h, y, d);
110
+ let y = c(f)(p, g), b = l(f, g, y, d);
110
111
  if (b.action === "reject") {
111
112
  u?.({
112
113
  rowIndex: o,
113
- sourceRowIndex: m,
114
+ sourceRowIndex: h,
114
115
  colIndex: a,
115
- row: h,
116
+ row: g,
116
117
  column: f,
117
- text: v,
118
+ text: p,
118
119
  reason: "invalid",
119
120
  value: y,
120
121
  message: b.message
121
122
  });
122
123
  continue;
123
124
  }
124
- g = t(g, f, y), _ = !0;
125
+ _ = t(_, f, y), v = !0;
125
126
  }
126
- _ && (f[m] = g);
127
+ v && (f[h] = _, p = !0);
127
128
  }
128
- return f;
129
- }, y = (e, t, n, r, i, a, o, l) => {
130
- let u = [], d = m(t, i, n.reduce((e, t) => Math.max(e, t.length), 0));
129
+ return p ? f : e;
130
+ }, b = (e, t, n, r, i, a, o, s) => {
131
+ let u = [], d = h(t, i, n.reduce((e, t) => Math.max(e, t.length), 0));
131
132
  for (let i = 0; i < n.length; i += 1) {
132
133
  let f = r + i, p = e(f);
133
134
  if (p) for (let e = 0; e < n[i].length; e += 1) {
@@ -146,7 +147,7 @@ var l = (e) => {
146
147
  });
147
148
  continue;
148
149
  }
149
- let g = s(m)(h, p), _ = c(m, p, g, l);
150
+ let g = c(m)(h, p), _ = l(m, p, g, s);
150
151
  if (_.action === "reject") {
151
152
  o?.({
152
153
  rowIndex: f,
@@ -169,25 +170,25 @@ var l = (e) => {
169
170
  }
170
171
  }
171
172
  return u;
172
- }, b = (e) => {
173
- let { body: t, activeElement: n } = document;
173
+ }, x = (e) => {
174
+ let { body: t } = document, r = n();
174
175
  if (!t) return !1;
175
- let r = document.createElement("textarea");
176
- r.value = e, r.setAttribute("readonly", ""), r.style.position = "fixed", r.style.top = "0", r.style.left = "-9999px", r.style.opacity = "0", t.appendChild(r);
177
- let i;
176
+ let i = document.createElement("textarea");
177
+ i.value = e, i.setAttribute("readonly", ""), i.style.position = "fixed", i.style.top = "0", i.style.left = "-9999px", i.style.opacity = "0", t.appendChild(i);
178
+ let a;
178
179
  try {
179
- r.select(), i = document.execCommand("copy");
180
+ i.select(), a = document.execCommand("copy");
180
181
  } catch {
181
- i = !1;
182
+ a = !1;
182
183
  } finally {
183
- t.removeChild(r), n instanceof HTMLElement && n.focus();
184
+ t.removeChild(i), r instanceof HTMLElement && r.focus();
184
185
  }
185
- return i;
186
- }, x = async (e) => {
186
+ return a;
187
+ }, S = async (e) => {
187
188
  if (navigator.clipboard?.writeText) try {
188
189
  return await navigator.clipboard.writeText(e), !0;
189
190
  } catch {}
190
- return b(e) ? !0 : (console.warn("[SpreadsheetGrid] クリップボードへのコピーに失敗しました(navigator.clipboard が利用できず、execCommand フォールバックも失敗)。\n[SpreadsheetGrid] Failed to copy to the clipboard (navigator.clipboard is unavailable and the execCommand fallback failed)."), !1);
191
+ return x(e) ? !0 : (console.warn("[SpreadsheetGrid] クリップボードへのコピーに失敗しました(navigator.clipboard が利用できず、execCommand フォールバックも失敗)。\n[SpreadsheetGrid] Failed to copy to the clipboard (navigator.clipboard is unavailable and the execCommand fallback failed)."), !1);
191
192
  };
192
193
  //#endregion
193
- export { v as applyClipboardMatrixToRows, y as buildClipboardCellEdits, b as copyTextViaExecCommand, u as escapeTsvField, g as filterClipboardColumns, h as formatClipboardCell, f as joinTsvLines, d as joinTsvRow, l as parseClipboardText, m as resolvePasteColumnIndexes, _ as serializeSelectionToTsv, x as writeTextToClipboard };
194
+ export { y as applyClipboardMatrixToRows, b as buildClipboardCellEdits, x as copyTextViaExecCommand, d as escapeTsvField, _ as filterClipboardColumns, g as formatClipboardCell, p as joinTsvLines, f as joinTsvRow, u as parseClipboardText, h as resolvePasteColumnIndexes, v as serializeSelectionToTsv, S as writeTextToClipboard };
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./gridVisibleBand.cjs");var t=e=>{let t=e.closest(`.ssg-scroll-container`);if(!t)return null;let n=t.getBoundingClientRect().left+t.clientLeft,r=n+t.clientWidth,i=e.closest(`.ssg-center-pane`)??t.querySelector(`.ssg-center-pane`);if(i){let t=i.previousElementSibling,a=i.nextElementSibling;if(i.contains(e))t&&(n=Math.max(n,t.getBoundingClientRect().right)),a&&(r=Math.min(r,a.getBoundingClientRect().left));else{let i=t?.contains(e)?t:a?.contains(e)?a:null;if(i){let e=i.getBoundingClientRect();n=Math.max(n,e.left),r=Math.min(r,e.right)}}}return r-n>0?{left:n,right:r}:null},n=t=>{let n=e.resolveGridVisibleBand(t);return{top:Math.max(0,n?.top??0),bottom:Math.min(window.innerHeight,n?.bottom??window.innerHeight)}},r=4,i=e=>{let n=t(e);if(!n)return null;let i=Math.floor(n.right-n.left-r*2);return i>0?i:null},a=e=>{let n=t(e);if(!n)return 0;let i=e.getBoundingClientRect(),a=i.right-(n.right-r);return a<=0?0:Math.max(0,Math.min(a,i.left-n.left))};exports.resolveEditorVisibleX=t,exports.resolveEditorVisibleY=n,exports.resolveShiftIntoView=a,exports.resolveVisibleWidth=i;
@@ -0,0 +1,10 @@
1
+ export declare const resolveEditorVisibleX: (element: Element) => {
2
+ left: number;
3
+ right: number;
4
+ } | null;
5
+ export declare const resolveEditorVisibleY: (element: Element) => {
6
+ top: number;
7
+ bottom: number;
8
+ };
9
+ export declare const resolveVisibleWidth: (element: Element) => number | null;
10
+ export declare const resolveShiftIntoView: (element: Element) => number;
@@ -0,0 +1,40 @@
1
+ import { resolveGridVisibleBand as e } from "./gridVisibleBand.js";
2
+ //#region src/utils/editorVisibleBounds.ts
3
+ var t = (e) => {
4
+ let t = e.closest(".ssg-scroll-container");
5
+ if (!t) return null;
6
+ let n = t.getBoundingClientRect().left + t.clientLeft, r = n + t.clientWidth, i = e.closest(".ssg-center-pane") ?? t.querySelector(".ssg-center-pane");
7
+ if (i) {
8
+ let t = i.previousElementSibling, a = i.nextElementSibling;
9
+ if (i.contains(e)) t && (n = Math.max(n, t.getBoundingClientRect().right)), a && (r = Math.min(r, a.getBoundingClientRect().left));
10
+ else {
11
+ let i = t?.contains(e) ? t : a?.contains(e) ? a : null;
12
+ if (i) {
13
+ let e = i.getBoundingClientRect();
14
+ n = Math.max(n, e.left), r = Math.min(r, e.right);
15
+ }
16
+ }
17
+ }
18
+ return r - n > 0 ? {
19
+ left: n,
20
+ right: r
21
+ } : null;
22
+ }, n = (t) => {
23
+ let n = e(t);
24
+ return {
25
+ top: Math.max(0, n?.top ?? 0),
26
+ bottom: Math.min(window.innerHeight, n?.bottom ?? window.innerHeight)
27
+ };
28
+ }, r = 4, i = (e) => {
29
+ let n = t(e);
30
+ if (!n) return null;
31
+ let i = Math.floor(n.right - n.left - r * 2);
32
+ return i > 0 ? i : null;
33
+ }, a = (e) => {
34
+ let n = t(e);
35
+ if (!n) return 0;
36
+ let i = e.getBoundingClientRect(), a = i.right - (n.right - r);
37
+ return a <= 0 ? 0 : Math.max(0, Math.min(a, i.left - n.left));
38
+ };
39
+ //#endregion
40
+ export { t as resolveEditorVisibleX, n as resolveEditorVisibleY, a as resolveShiftIntoView, i as resolveVisibleWidth };
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./editorVisibleBounds.cjs");var t=`ssg-cell-editor-error--above`,n={above:!1,shift:0,wrapWidth:null},r=4,i=t=>{let n=t.getBoundingClientRect(),i=e.resolveEditorVisibleY(t),a=n.bottom-(i.bottom-r);if(a<=0)return!1;let o=t.parentElement?.getBoundingClientRect().top??n.top;return i.top+r-(o-4-n.height)<a},a=(e,t)=>{e.style.width=t===null?``:`${t}px`,e.style.whiteSpace=t===null?``:`normal`},o=n=>{n.classList.remove(t),n.style.left=``,n.style.width=``,n.style.whiteSpace=``;let r=e.resolveVisibleWidth(n),o=r!==null&&n.getBoundingClientRect().width>r?r:null;a(n,o);let s={above:i(n),shift:e.resolveShiftIntoView(n),wrapWidth:o};return n.classList.toggle(t,s.above),n.style.left=s.shift>0?`${-s.shift}px`:``,s};exports.DEFAULT_ERROR_BUBBLE_PLACEMENT=n,exports.ERROR_BUBBLE_ABOVE_CLASS=t,exports.placeErrorBubble=o;
@@ -0,0 +1,8 @@
1
+ export declare const ERROR_BUBBLE_ABOVE_CLASS = "ssg-cell-editor-error--above";
2
+ export type ErrorBubblePlacement = {
3
+ above: boolean;
4
+ shift: number;
5
+ wrapWidth: number | null;
6
+ };
7
+ export declare const DEFAULT_ERROR_BUBBLE_PLACEMENT: ErrorBubblePlacement;
8
+ export declare const placeErrorBubble: (element: HTMLElement) => ErrorBubblePlacement;
@@ -0,0 +1,26 @@
1
+ import { resolveEditorVisibleY as e, resolveShiftIntoView as t, resolveVisibleWidth as n } from "./editorVisibleBounds.js";
2
+ //#region src/utils/errorBubblePlacement.ts
3
+ var r = "ssg-cell-editor-error--above", i = {
4
+ above: !1,
5
+ shift: 0,
6
+ wrapWidth: null
7
+ }, a = 4, o = (t) => {
8
+ let n = t.getBoundingClientRect(), r = e(t), i = n.bottom - (r.bottom - a);
9
+ if (i <= 0) return !1;
10
+ let o = t.parentElement?.getBoundingClientRect().top ?? n.top;
11
+ return r.top + a - (o - 4 - n.height) < i;
12
+ }, s = (e, t) => {
13
+ e.style.width = t === null ? "" : `${t}px`, e.style.whiteSpace = t === null ? "" : "normal";
14
+ }, c = (e) => {
15
+ e.classList.remove(r), e.style.left = "", e.style.width = "", e.style.whiteSpace = "";
16
+ let i = n(e), a = i !== null && e.getBoundingClientRect().width > i ? i : null;
17
+ s(e, a);
18
+ let c = {
19
+ above: o(e),
20
+ shift: t(e),
21
+ wrapWidth: a
22
+ };
23
+ return e.classList.toggle(r, c.above), e.style.left = c.shift > 0 ? `${-c.shift}px` : "", c;
24
+ };
25
+ //#endregion
26
+ export { i as DEFAULT_ERROR_BUBBLE_PLACEMENT, r as ERROR_BUBBLE_ABOVE_CLASS, c as placeErrorBubble };
@@ -0,0 +1,2 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=20,t=.4,n=(n,r,i)=>{if(i){let e=getComputedStyle(n),r=Number.parseFloat(e.fontSize)||0,i=Number.parseFloat(e.borderTopWidth)||0;return Math.max(0,Math.round(r*t-i))}n.style.paddingTop=`0px`,n.style.paddingBottom=`0px`,n.style.height=`0px`;let a=Number.parseFloat(getComputedStyle(n).lineHeight)||e,o=Math.max(n.scrollHeight,a);return Math.max(0,Math.floor((r-4-o)/2))},r=(e,t,n)=>{e.style.paddingTop=`${n}px`,e.style.paddingBottom=`${n}px`,e.style.height=`${t}px`;let r=e.offsetHeight-e.clientHeight,i=e.scrollHeight+r,a=1/0,o=e.closest(`.ssg-scroll-container`);o instanceof HTMLElement&&(a=o.getBoundingClientRect().top+o.clientTop+o.clientHeight-e.getBoundingClientRect().top),e.style.height=`${Math.max(t,Math.min(i,a))}px`},i=()=>typeof document.execCommand==`function`&&document.execCommand(`insertText`,!1,`
2
+ `),a=e=>{let t=e.selectionStart,n=e.selectionEnd;return{value:`${e.value.slice(0,t)}\n${e.value.slice(n)}`,caret:t+1}};exports.fitMultilineEditor=r,exports.insertNewlineByCommand=i,exports.insertNewlineText=a,exports.resolveMultilinePadding=n;
@@ -0,0 +1,7 @@
1
+ export declare const resolveMultilinePadding: (textarea: HTMLTextAreaElement, cellHeight: number, alignTop: boolean) => number;
2
+ export declare const fitMultilineEditor: (textarea: HTMLTextAreaElement, cellHeight: number, padding: number) => void;
3
+ export declare const insertNewlineByCommand: () => boolean;
4
+ export declare const insertNewlineText: (textarea: HTMLTextAreaElement) => {
5
+ value: string;
6
+ caret: number;
7
+ };
@@ -0,0 +1,22 @@
1
+ //#region src/utils/multilineEditor.ts
2
+ var e = (e, t, n) => {
3
+ if (n) {
4
+ let t = getComputedStyle(e), n = Number.parseFloat(t.fontSize) || 0, r = Number.parseFloat(t.borderTopWidth) || 0;
5
+ return Math.max(0, Math.round(n * .4 - r));
6
+ }
7
+ e.style.paddingTop = "0px", e.style.paddingBottom = "0px", e.style.height = "0px";
8
+ let r = Number.parseFloat(getComputedStyle(e).lineHeight) || 20, i = Math.max(e.scrollHeight, r);
9
+ return Math.max(0, Math.floor((t - 4 - i) / 2));
10
+ }, t = (e, t, n) => {
11
+ e.style.paddingTop = `${n}px`, e.style.paddingBottom = `${n}px`, e.style.height = `${t}px`;
12
+ let r = e.offsetHeight - e.clientHeight, i = e.scrollHeight + r, a = Infinity, o = e.closest(".ssg-scroll-container");
13
+ o instanceof HTMLElement && (a = o.getBoundingClientRect().top + o.clientTop + o.clientHeight - e.getBoundingClientRect().top), e.style.height = `${Math.max(t, Math.min(i, a))}px`;
14
+ }, n = () => typeof document.execCommand == "function" && document.execCommand("insertText", !1, "\n"), r = (e) => {
15
+ let t = e.selectionStart, n = e.selectionEnd;
16
+ return {
17
+ value: `${e.value.slice(0, t)}\n${e.value.slice(n)}`,
18
+ caret: t + 1
19
+ };
20
+ };
21
+ //#endregion
22
+ export { t as fitMultilineEditor, n as insertNewlineByCommand, r as insertNewlineText, e as resolveMultilinePadding };
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=`dialog, [popover], [aria-modal="true"], [role="dialog"], [role="alertdialog"]`,t=`.ssg-menu-panel, .ssg-filter-popover, .ssg-toolpanel, .ssg-select-editor-popover, .ssg-popover`,n=e=>typeof e==`object`&&!!e&&e.nodeType===1,r=e=>(e?.ownerDocument??(typeof document>`u`?null:document))?.body??null,i=/transform|translate|scale|rotate|perspective|filter/,a=/paint|layout|strict|content/,o=e=>{let t=e.ownerDocument.defaultView;if(!t||typeof t.getComputedStyle!=`function`)return!1;let n=t.getComputedStyle(e);if(!((n.overflowX||`visible`)!==`visible`||(n.overflowY||`visible`)!==`visible`))return!1;let r=e=>!e||e===`none`;return!r(n.transform)||!r(n.getPropertyValue(`translate`))||!r(n.getPropertyValue(`scale`))||!r(n.getPropertyValue(`rotate`))||!r(n.filter)||!r(n.perspective)||!r(n.getPropertyValue(`backdrop-filter`))||i.test(n.willChange||``)||a.test(n.contain||``)||(n.getPropertyValue(`container-type`)||`normal`)!==`normal`},s=e=>{if(e.matches(`dialog, [popover]`)||!o(e))return e;let t=e.ownerDocument,n=t.defaultView;for(let r=e.parentElement;r!==null&&r!==t.body&&r!==t.documentElement;r=r.parentElement){if(r.matches(`dialog, [popover]`))return e;if(n?.getComputedStyle(r).position===`fixed`)return o(r)?e:r}return e};function c(t){let r=t.parentElement?.closest(e);return n(r)?s(r):null}function l(e,t){let i=r(e);return n(t)?t:e?typeof t==`function`?t(e)??i:t===`body`?i:c(e)??i:i}var u=new WeakMap;function d(e,t){let n=e.filter(e=>e!=null);for(let e of n)u.set(e,t);return()=>{for(let e of n)u.get(e)===t&&u.delete(e)}}function f(e){for(let n=e??null;n!==null;n=n.parentElement){if(n.matches(t))return n.parentElement??r(n);let e=u.get(n);if(e)return e()??r(n)}return e?c(e)??r(e):r(null)}function p(e){let t=e?.parentElement;if(!e||!t)return;let n=e.ownerDocument,r=0,i=0;if(t!==n.body&&t!==n.documentElement){let e=n.createElement(`div`);e.style.cssText=`position:fixed;left:0;top:0;width:0;height:0;margin:0;padding:0;border:0;visibility:hidden;pointer-events:none`,t.appendChild(e);let a=e.getBoundingClientRect();e.remove(),r=Number.isFinite(a.left)?a.left:0,i=Number.isFinite(a.top)?a.top:0}let a=r===0&&i===0?``:`${-r}px ${-i}px`;e.style.getPropertyValue(`translate`)!==a&&(a===``?e.style.removeProperty(`translate`):e.style.setProperty(`translate`,a))}function m(e,t){let n=t??e.ownerDocument.body;e.parentElement!==n&&n.appendChild(e),p(e)}exports.appendToPopupContainer=m,exports.findPopupHost=c,exports.getPopupContainerFor=f,exports.registerPopupContainer=d,exports.resolvePopupContainer=l,exports.syncPopupOrigin=p;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./shadowDom.cjs");var t=`dialog, [popover], [aria-modal="true"], [role="dialog"], [role="alertdialog"]`,n=`.ssg-menu-panel, .ssg-filter-popover, .ssg-toolpanel, .ssg-select-editor-popover, .ssg-popover`,r=e=>typeof e==`object`&&!!e&&e.nodeType===1,i=e=>(e?.ownerDocument??(typeof document>`u`?null:document))?.body??null,a=/transform|translate|scale|rotate|perspective|filter/,o=/paint|layout|strict|content/,s=e=>{let t=e.ownerDocument.defaultView;if(!t||typeof t.getComputedStyle!=`function`)return!1;let n=t.getComputedStyle(e);if(!((n.overflowX||`visible`)!==`visible`||(n.overflowY||`visible`)!==`visible`))return!1;let r=e=>!e||e===`none`;return!r(n.transform)||!r(n.getPropertyValue(`translate`))||!r(n.getPropertyValue(`scale`))||!r(n.getPropertyValue(`rotate`))||!r(n.filter)||!r(n.perspective)||!r(n.getPropertyValue(`backdrop-filter`))||a.test(n.willChange||``)||o.test(n.contain||``)||(n.getPropertyValue(`container-type`)||`normal`)!==`normal`},c=e=>{if(e.matches(`dialog, [popover]`)||!s(e))return e;let t=e.ownerDocument,n=t.defaultView;for(let r=e.parentElement;r!==null&&r!==t.body&&r!==t.documentElement;r=r.parentElement){if(r.matches(`dialog, [popover]`))return e;if(n?.getComputedStyle(r).position===`fixed`)return s(r)?e:r}return e};function l(e){let n=e.parentElement?.closest(t);return r(n)?c(n):null}function u(t){if(e.getShadowRoot(t)===null)return null;let n=t;for(;n.parentElement!==null;)n=n.parentElement;return r(n)&&!n.matches(`.ssg-root`)?n:null}function d(e,t){let n=i(e);return r(t)?t:e?typeof t==`function`?t(e)??n:t===`body`?n:l(e)??u(e)??n:n}var f=new WeakMap;function p(e,t){let n=e.filter(e=>e!=null);for(let e of n)f.set(e,t);return()=>{for(let e of n)f.get(e)===t&&f.delete(e)}}function m(e){for(let t=e??null;t!==null;t=t.parentElement){if(t.matches(n))return t.parentElement??i(t);let e=f.get(t);if(e)return e()??i(t)}return e?l(e)??u(e)??i(e):i(null)}function h(e){let t=e?.parentElement;if(!e||!t)return;let n=e.ownerDocument,r=0,i=0;if(t!==n.body&&t!==n.documentElement){let e=n.createElement(`div`);e.style.cssText=`position:fixed;left:0;top:0;width:0;height:0;margin:0;padding:0;border:0;visibility:hidden;pointer-events:none`,t.appendChild(e);let a=e.getBoundingClientRect();e.remove(),r=Number.isFinite(a.left)?a.left:0,i=Number.isFinite(a.top)?a.top:0}let a=r===0&&i===0?``:`${-r}px ${-i}px`;e.style.getPropertyValue(`translate`)!==a&&(a===``?e.style.removeProperty(`translate`):e.style.setProperty(`translate`,a))}function g(e,t){let n=t??e.ownerDocument.body;e.parentElement!==n&&n.appendChild(e),h(e)}exports.appendToPopupContainer=g,exports.findPopupHost=l,exports.getPopupContainerFor=m,exports.registerPopupContainer=p,exports.resolvePopupContainer=d,exports.syncPopupOrigin=h;
@@ -1,45 +1,52 @@
1
+ import { getShadowRoot as e } from "./shadowDom.js";
1
2
  //#region src/utils/popupContainer.ts
2
- var e = (e) => typeof e == "object" && !!e && e.nodeType === 1, t = (e) => (e?.ownerDocument ?? (typeof document > "u" ? null : document))?.body ?? null, n = /transform|translate|scale|rotate|perspective|filter/, r = /paint|layout|strict|content/, i = (e) => {
3
+ var t = "dialog, [popover], [aria-modal=\"true\"], [role=\"dialog\"], [role=\"alertdialog\"]", n = ".ssg-menu-panel, .ssg-filter-popover, .ssg-toolpanel, .ssg-select-editor-popover, .ssg-popover", r = (e) => typeof e == "object" && !!e && e.nodeType === 1, i = (e) => (e?.ownerDocument ?? (typeof document > "u" ? null : document))?.body ?? null, a = /transform|translate|scale|rotate|perspective|filter/, o = /paint|layout|strict|content/, s = (e) => {
3
4
  let t = e.ownerDocument.defaultView;
4
5
  if (!t || typeof t.getComputedStyle != "function") return !1;
5
- let i = t.getComputedStyle(e);
6
- if (!((i.overflowX || "visible") !== "visible" || (i.overflowY || "visible") !== "visible")) return !1;
7
- let a = (e) => !e || e === "none";
8
- return !a(i.transform) || !a(i.getPropertyValue("translate")) || !a(i.getPropertyValue("scale")) || !a(i.getPropertyValue("rotate")) || !a(i.filter) || !a(i.perspective) || !a(i.getPropertyValue("backdrop-filter")) || n.test(i.willChange || "") || r.test(i.contain || "") || (i.getPropertyValue("container-type") || "normal") !== "normal";
9
- }, a = (e) => {
10
- if (e.matches("dialog, [popover]") || !i(e)) return e;
6
+ let n = t.getComputedStyle(e);
7
+ if (!((n.overflowX || "visible") !== "visible" || (n.overflowY || "visible") !== "visible")) return !1;
8
+ let r = (e) => !e || e === "none";
9
+ return !r(n.transform) || !r(n.getPropertyValue("translate")) || !r(n.getPropertyValue("scale")) || !r(n.getPropertyValue("rotate")) || !r(n.filter) || !r(n.perspective) || !r(n.getPropertyValue("backdrop-filter")) || a.test(n.willChange || "") || o.test(n.contain || "") || (n.getPropertyValue("container-type") || "normal") !== "normal";
10
+ }, c = (e) => {
11
+ if (e.matches("dialog, [popover]") || !s(e)) return e;
11
12
  let t = e.ownerDocument, n = t.defaultView;
12
13
  for (let r = e.parentElement; r !== null && r !== t.body && r !== t.documentElement; r = r.parentElement) {
13
14
  if (r.matches("dialog, [popover]")) return e;
14
- if (n?.getComputedStyle(r).position === "fixed") return i(r) ? e : r;
15
+ if (n?.getComputedStyle(r).position === "fixed") return s(r) ? e : r;
15
16
  }
16
17
  return e;
17
18
  };
18
- function o(t) {
19
- let n = t.parentElement?.closest("dialog, [popover], [aria-modal=\"true\"], [role=\"dialog\"], [role=\"alertdialog\"]");
20
- return e(n) ? a(n) : null;
19
+ function l(e) {
20
+ let n = e.parentElement?.closest(t);
21
+ return r(n) ? c(n) : null;
21
22
  }
22
- function s(n, r) {
23
- let i = t(n);
24
- return e(r) ? r : n ? typeof r == "function" ? r(n) ?? i : r === "body" ? i : o(n) ?? i : i;
23
+ function u(t) {
24
+ if (e(t) === null) return null;
25
+ let n = t;
26
+ for (; n.parentElement !== null;) n = n.parentElement;
27
+ return r(n) && !n.matches(".ssg-root") ? n : null;
25
28
  }
26
- var c = /* @__PURE__ */ new WeakMap();
27
- function l(e, t) {
29
+ function d(e, t) {
30
+ let n = i(e);
31
+ return r(t) ? t : e ? typeof t == "function" ? t(e) ?? n : t === "body" ? n : l(e) ?? u(e) ?? n : n;
32
+ }
33
+ var f = /* @__PURE__ */ new WeakMap();
34
+ function p(e, t) {
28
35
  let n = e.filter((e) => e != null);
29
- for (let e of n) c.set(e, t);
36
+ for (let e of n) f.set(e, t);
30
37
  return () => {
31
- for (let e of n) c.get(e) === t && c.delete(e);
38
+ for (let e of n) f.get(e) === t && f.delete(e);
32
39
  };
33
40
  }
34
- function u(e) {
35
- for (let n = e ?? null; n !== null; n = n.parentElement) {
36
- if (n.matches(".ssg-menu-panel, .ssg-filter-popover, .ssg-toolpanel, .ssg-select-editor-popover, .ssg-popover")) return n.parentElement ?? t(n);
37
- let e = c.get(n);
38
- if (e) return e() ?? t(n);
41
+ function m(e) {
42
+ for (let t = e ?? null; t !== null; t = t.parentElement) {
43
+ if (t.matches(n)) return t.parentElement ?? i(t);
44
+ let e = f.get(t);
45
+ if (e) return e() ?? i(t);
39
46
  }
40
- return e ? o(e) ?? t(e) : t(null);
47
+ return e ? l(e) ?? u(e) ?? i(e) : i(null);
41
48
  }
42
- function d(e) {
49
+ function h(e) {
43
50
  let t = e?.parentElement;
44
51
  if (!e || !t) return;
45
52
  let n = e.ownerDocument, r = 0, i = 0;
@@ -52,9 +59,9 @@ function d(e) {
52
59
  let a = r === 0 && i === 0 ? "" : `${-r}px ${-i}px`;
53
60
  e.style.getPropertyValue("translate") !== a && (a === "" ? e.style.removeProperty("translate") : e.style.setProperty("translate", a));
54
61
  }
55
- function f(e, t) {
62
+ function g(e, t) {
56
63
  let n = t ?? e.ownerDocument.body;
57
- e.parentElement !== n && n.appendChild(e), d(e);
64
+ e.parentElement !== n && n.appendChild(e), h(e);
58
65
  }
59
66
  //#endregion
60
- export { f as appendToPopupContainer, o as findPopupHost, u as getPopupContainerFor, l as registerPopupContainer, s as resolvePopupContainer, d as syncPopupOrigin };
67
+ export { g as appendToPopupContainer, l as findPopupHost, m as getPopupContainerFor, p as registerPopupContainer, d as resolvePopupContainer, h as syncPopupOrigin };
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=e=>typeof e==`object`&&!!e&&`activeElement`in e,t=e=>typeof e==`object`&&!!e&&typeof e.getRootNode==`function`,n=e=>e==null?typeof document>`u`?null:document:t(e)?e.getRootNode():e.document??null;function r(e,r){let i=typeof e.composedPath==`function`?e.composedPath():[];if(i.length===0)return e.target;let a=n(r),o=null;for(let e of i){if(!t(e))continue;let n=e.getRootNode();if(n===a)return e;o===null&&n.nodeType===9&&(o=e)}return o??i[0]??e.target}function i(t){let n=t?.nodeType===9?t:t?.ownerDocument??(typeof document>`u`?null:document),r=t?.getRootNode?.();return r!=null&&r!==n&&e(r)&&r.activeElement!==null?r.activeElement:n?.activeElement??null}function a(){let e=typeof document>`u`?null:document.activeElement;for(;e!==null&&e.shadowRoot!=null&&e.shadowRoot.activeElement!=null;)e=e.shadowRoot.activeElement;return e}function o(e,t){let n=e?.getRootNode?.();return n!=null&&typeof n.getElementById==`function`?n.getElementById(t):(e?.ownerDocument??(typeof document>`u`?null:document))?.getElementById(t)??null}function s(e){let t=e?.getRootNode?.();return t!=null&&typeof ShadowRoot<`u`&&t instanceof ShadowRoot?t:null}exports.findElementById=o,exports.getActiveElement=i,exports.getDeepActiveElement=a,exports.getEventTarget=r,exports.getShadowRoot=s;
@@ -0,0 +1,5 @@
1
+ export declare function getEventTarget(event: Event, context?: Node | Window | null): EventTarget | null;
2
+ export declare function getActiveElement(context?: Node | null): Element | null;
3
+ export declare function getDeepActiveElement(): Element | null;
4
+ export declare function findElementById(context: Node | null | undefined, id: string): HTMLElement | null;
5
+ export declare function getShadowRoot(element: Node | null | undefined): ShadowRoot | null;
@@ -0,0 +1,33 @@
1
+ //#region src/utils/shadowDom.ts
2
+ var e = (e) => typeof e == "object" && !!e && "activeElement" in e, t = (e) => typeof e == "object" && !!e && typeof e.getRootNode == "function", n = (e) => e == null ? typeof document > "u" ? null : document : t(e) ? e.getRootNode() : e.document ?? null;
3
+ function r(e, r) {
4
+ let i = typeof e.composedPath == "function" ? e.composedPath() : [];
5
+ if (i.length === 0) return e.target;
6
+ let a = n(r), o = null;
7
+ for (let e of i) {
8
+ if (!t(e)) continue;
9
+ let n = e.getRootNode();
10
+ if (n === a) return e;
11
+ o === null && n.nodeType === 9 && (o = e);
12
+ }
13
+ return o ?? i[0] ?? e.target;
14
+ }
15
+ function i(t) {
16
+ let n = t?.nodeType === 9 ? t : t?.ownerDocument ?? (typeof document > "u" ? null : document), r = t?.getRootNode?.();
17
+ return r != null && r !== n && e(r) && r.activeElement !== null ? r.activeElement : n?.activeElement ?? null;
18
+ }
19
+ function a() {
20
+ let e = typeof document > "u" ? null : document.activeElement;
21
+ for (; e !== null && e.shadowRoot != null && e.shadowRoot.activeElement != null;) e = e.shadowRoot.activeElement;
22
+ return e;
23
+ }
24
+ function o(e, t) {
25
+ let n = e?.getRootNode?.();
26
+ return n != null && typeof n.getElementById == "function" ? n.getElementById(t) : (e?.ownerDocument ?? (typeof document > "u" ? null : document))?.getElementById(t) ?? null;
27
+ }
28
+ function s(e) {
29
+ let t = e?.getRootNode?.();
30
+ return t != null && typeof ShadowRoot < "u" && t instanceof ShadowRoot ? t : null;
31
+ }
32
+ //#endregion
33
+ export { o as findElementById, i as getActiveElement, a as getDeepActiveElement, r as getEventTarget, s as getShadowRoot };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ishibashi0112/spreadsheet-grid-core",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "SpreadsheetGrid のフレームワーク非依存コア(状態 / 派生値計算 / コマンド / DOM コントローラ)。React 版 @ishibashi0112/spreadsheet-grid と将来の Solid 版が共有します。",
5
5
  "keywords": [
6
6
  "grid",