@ishibashi0112/spreadsheet-grid-core 1.2.1 → 1.4.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 (82) hide show
  1. package/README.md +2 -2
  2. package/dist/controllers/clipboardController.cjs +1 -1
  3. package/dist/controllers/clipboardController.js +79 -71
  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 -1
  9. package/dist/controllers/detailRowController.js +60 -59
  10. package/dist/controllers/detailTabOrder.cjs +1 -1
  11. package/dist/controllers/detailTabOrder.js +17 -16
  12. package/dist/controllers/editController.cjs +1 -1
  13. package/dist/controllers/editController.d.ts +4 -1
  14. package/dist/controllers/editController.js +163 -91
  15. package/dist/controllers/escapeClaimController.cjs +1 -1
  16. package/dist/controllers/escapeClaimController.js +23 -19
  17. package/dist/controllers/fillHandleController.cjs +1 -1
  18. package/dist/controllers/fillHandleController.js +107 -106
  19. package/dist/controllers/filterPopoverController.cjs +1 -1
  20. package/dist/controllers/filterPopoverController.js +1 -0
  21. package/dist/controllers/imeInputController.cjs +1 -1
  22. package/dist/controllers/imeInputController.js +87 -76
  23. package/dist/controllers/keyboardController.cjs +1 -1
  24. package/dist/controllers/keyboardController.d.ts +3 -0
  25. package/dist/controllers/keyboardController.js +15 -13
  26. package/dist/controllers/popoverSupport.cjs +1 -1
  27. package/dist/controllers/popoverSupport.d.ts +3 -0
  28. package/dist/controllers/popoverSupport.js +62 -41
  29. package/dist/controllers/toolPanelController.cjs +1 -1
  30. package/dist/controllers/toolPanelController.js +74 -73
  31. package/dist/controllers/tooltipController.cjs +1 -1
  32. package/dist/controllers/tooltipController.d.ts +1 -1
  33. package/dist/controllers/tooltipController.js +122 -97
  34. package/dist/controllers/viewportSyncController.cjs +1 -1
  35. package/dist/controllers/viewportSyncController.js +55 -54
  36. package/dist/engine/columnCommands.cjs +1 -1
  37. package/dist/engine/columnCommands.d.ts +2 -1
  38. package/dist/engine/columnCommands.js +98 -67
  39. package/dist/engine/exportCommands.cjs +1 -1
  40. package/dist/engine/exportCommands.js +2 -2
  41. package/dist/engine/gridApi.cjs +6 -5
  42. package/dist/engine/gridApi.d.ts +1 -0
  43. package/dist/engine/gridApi.js +151 -143
  44. package/dist/engine/rowSelectionCommands.cjs +1 -1
  45. package/dist/engine/rowSelectionCommands.d.ts +5 -0
  46. package/dist/engine/rowSelectionCommands.js +73 -38
  47. package/dist/locales/en.cjs +1 -1
  48. package/dist/locales/en.js +2 -2
  49. package/dist/logic/contextMenuTarget.cjs +1 -1
  50. package/dist/logic/contextMenuTarget.d.ts +20 -2
  51. package/dist/logic/contextMenuTarget.js +62 -3
  52. package/dist/logic/dateFilterCondition.cjs +1 -1
  53. package/dist/logic/dateFilterCondition.d.ts +1 -0
  54. package/dist/logic/dateFilterCondition.js +17 -13
  55. package/dist/logic/detailRow.cjs +1 -1
  56. package/dist/logic/detailRow.d.ts +2 -1
  57. package/dist/logic/detailRow.js +19 -18
  58. package/dist/logic/domGuards.cjs +1 -1
  59. package/dist/logic/domGuards.d.ts +5 -0
  60. package/dist/logic/domGuards.js +11 -1
  61. package/dist/logic/editorValues.cjs +1 -1
  62. package/dist/logic/editorValues.d.ts +1 -0
  63. package/dist/logic/editorValues.js +10 -7
  64. package/dist/logic/gridState.cjs +1 -1
  65. package/dist/logic/gridState.d.ts +1 -0
  66. package/dist/logic/gridState.js +19 -16
  67. package/dist/logic/localeText.cjs +1 -1
  68. package/dist/logic/localeText.js +2 -2
  69. package/dist/logic/rowDragTarget.cjs +1 -0
  70. package/dist/logic/rowDragTarget.d.ts +14 -0
  71. package/dist/logic/rowDragTarget.js +47 -0
  72. package/dist/logic/selectEditorState.d.ts +4 -4
  73. package/dist/logic/valueFormatters.d.ts +8 -3
  74. package/dist/model/gridTypes.core.d.ts +31 -12
  75. package/dist/utils/clipboard.cjs +4 -4
  76. package/dist/utils/clipboard.js +60 -59
  77. package/dist/utils/popupContainer.cjs +1 -1
  78. package/dist/utils/popupContainer.js +35 -28
  79. package/dist/utils/shadowDom.cjs +1 -0
  80. package/dist/utils/shadowDom.d.ts +5 -0
  81. package/dist/utils/shadowDom.js +33 -0
  82. 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 };
@@ -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.1",
3
+ "version": "1.4.0",
4
4
  "description": "SpreadsheetGrid のフレームワーク非依存コア(状態 / 派生値計算 / コマンド / DOM コントローラ)。React 版 @ishibashi0112/spreadsheet-grid と将来の Solid 版が共有します。",
5
5
  "keywords": [
6
6
  "grid",