@ishibashi0112/spreadsheet-grid-core 1.2.1 → 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.
- package/dist/controllers/clipboardController.cjs +1 -1
- package/dist/controllers/clipboardController.js +79 -71
- package/dist/controllers/columnMenuController.cjs +1 -1
- package/dist/controllers/columnMenuController.js +75 -73
- package/dist/controllers/contextMenuController.cjs +1 -1
- package/dist/controllers/contextMenuController.js +63 -61
- package/dist/controllers/detailRowController.cjs +1 -1
- package/dist/controllers/detailRowController.js +60 -59
- package/dist/controllers/detailTabOrder.cjs +1 -1
- package/dist/controllers/detailTabOrder.js +17 -16
- package/dist/controllers/editController.cjs +1 -1
- package/dist/controllers/editController.d.ts +4 -1
- package/dist/controllers/editController.js +163 -91
- package/dist/controllers/escapeClaimController.cjs +1 -1
- package/dist/controllers/escapeClaimController.js +23 -19
- package/dist/controllers/fillHandleController.cjs +1 -1
- package/dist/controllers/fillHandleController.js +107 -106
- package/dist/controllers/filterPopoverController.cjs +1 -1
- package/dist/controllers/filterPopoverController.js +1 -0
- package/dist/controllers/imeInputController.cjs +1 -1
- package/dist/controllers/imeInputController.js +87 -76
- package/dist/controllers/keyboardController.cjs +1 -1
- package/dist/controllers/keyboardController.d.ts +3 -0
- package/dist/controllers/keyboardController.js +15 -13
- package/dist/controllers/popoverSupport.cjs +1 -1
- package/dist/controllers/popoverSupport.d.ts +3 -0
- package/dist/controllers/popoverSupport.js +62 -41
- package/dist/controllers/toolPanelController.cjs +1 -1
- package/dist/controllers/toolPanelController.js +74 -73
- package/dist/controllers/tooltipController.cjs +1 -1
- package/dist/controllers/tooltipController.d.ts +1 -1
- package/dist/controllers/tooltipController.js +122 -97
- package/dist/controllers/viewportSyncController.cjs +1 -1
- package/dist/controllers/viewportSyncController.js +55 -54
- package/dist/engine/columnCommands.cjs +1 -1
- package/dist/engine/columnCommands.d.ts +2 -1
- package/dist/engine/columnCommands.js +98 -67
- package/dist/engine/exportCommands.cjs +1 -1
- package/dist/engine/exportCommands.js +2 -2
- package/dist/engine/gridApi.cjs +6 -5
- package/dist/engine/gridApi.d.ts +1 -0
- package/dist/engine/gridApi.js +151 -143
- package/dist/engine/rowSelectionCommands.cjs +1 -1
- package/dist/engine/rowSelectionCommands.d.ts +5 -0
- package/dist/engine/rowSelectionCommands.js +73 -38
- package/dist/locales/en.cjs +1 -1
- package/dist/locales/en.js +2 -2
- package/dist/logic/contextMenuTarget.cjs +1 -1
- package/dist/logic/contextMenuTarget.d.ts +20 -2
- package/dist/logic/contextMenuTarget.js +62 -3
- package/dist/logic/dateFilterCondition.cjs +1 -1
- package/dist/logic/dateFilterCondition.d.ts +1 -0
- package/dist/logic/dateFilterCondition.js +17 -13
- package/dist/logic/detailRow.cjs +1 -1
- package/dist/logic/detailRow.d.ts +2 -1
- package/dist/logic/detailRow.js +19 -18
- package/dist/logic/domGuards.cjs +1 -1
- package/dist/logic/domGuards.d.ts +5 -0
- package/dist/logic/domGuards.js +11 -1
- package/dist/logic/editorValues.cjs +1 -1
- package/dist/logic/editorValues.d.ts +1 -0
- package/dist/logic/editorValues.js +10 -7
- package/dist/logic/gridState.cjs +1 -1
- package/dist/logic/gridState.d.ts +1 -0
- package/dist/logic/gridState.js +19 -16
- package/dist/logic/localeText.cjs +1 -1
- package/dist/logic/localeText.js +2 -2
- package/dist/logic/rowDragTarget.cjs +1 -0
- package/dist/logic/rowDragTarget.d.ts +14 -0
- package/dist/logic/rowDragTarget.js +47 -0
- package/dist/logic/selectEditorState.d.ts +4 -4
- package/dist/logic/valueFormatters.d.ts +8 -3
- package/dist/model/gridTypes.core.d.ts +31 -12
- package/dist/utils/clipboard.cjs +4 -4
- package/dist/utils/clipboard.js +60 -59
- package/dist/utils/popupContainer.cjs +1 -1
- package/dist/utils/popupContainer.js +35 -28
- package/dist/utils/shadowDom.cjs +1 -0
- package/dist/utils/shadowDom.d.ts +5 -0
- package/dist/utils/shadowDom.js +33 -0
- package/package.json +1 -1
package/dist/utils/clipboard.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { getCellValue as e, setCellValue as t } from "./permissions.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
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
|
|
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
|
-
},
|
|
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
|
-
},
|
|
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 ||
|
|
54
|
+
(t === void 0 || m(t)) && r.push(i);
|
|
54
55
|
}
|
|
55
56
|
return r;
|
|
56
|
-
},
|
|
57
|
-
if (!
|
|
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 (
|
|
60
|
-
let t = r
|
|
61
|
-
if (
|
|
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(
|
|
65
|
+
t && (s && !s(t, n) || c.push(f(a.map((e) => g(t, e)))));
|
|
65
66
|
}
|
|
66
|
-
return
|
|
67
|
+
return p(c);
|
|
67
68
|
}
|
|
68
|
-
if (
|
|
69
|
-
let t =
|
|
70
|
-
if (
|
|
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(
|
|
74
|
+
t && (s && !s(t, n) || c.push(f(i.map((e) => g(t, e)))));
|
|
74
75
|
}
|
|
75
|
-
return
|
|
76
|
+
return p(c);
|
|
76
77
|
}
|
|
77
|
-
let l =
|
|
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(
|
|
82
|
+
t && (s && !s(t, n) || c.push(f(u.map((e) => g(t, e)))));
|
|
82
83
|
}
|
|
83
|
-
return
|
|
84
|
-
},
|
|
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,
|
|
89
|
-
if (
|
|
90
|
-
let
|
|
91
|
-
if (!
|
|
92
|
-
let
|
|
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 =
|
|
95
|
+
let a = m[n], f = r[a];
|
|
95
96
|
if (!f) continue;
|
|
96
|
-
let
|
|
97
|
-
if (!
|
|
97
|
+
let p = i[e][n];
|
|
98
|
+
if (!s(h, a, g, f, o)) {
|
|
98
99
|
u?.({
|
|
99
100
|
rowIndex: o,
|
|
100
|
-
sourceRowIndex:
|
|
101
|
+
sourceRowIndex: h,
|
|
101
102
|
colIndex: a,
|
|
102
|
-
row:
|
|
103
|
+
row: g,
|
|
103
104
|
column: f,
|
|
104
|
-
text:
|
|
105
|
+
text: p,
|
|
105
106
|
reason: "readOnly"
|
|
106
107
|
});
|
|
107
108
|
continue;
|
|
108
109
|
}
|
|
109
|
-
let y =
|
|
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:
|
|
114
|
+
sourceRowIndex: h,
|
|
114
115
|
colIndex: a,
|
|
115
|
-
row:
|
|
116
|
+
row: g,
|
|
116
117
|
column: f,
|
|
117
|
-
text:
|
|
118
|
+
text: p,
|
|
118
119
|
reason: "invalid",
|
|
119
120
|
value: y,
|
|
120
121
|
message: b.message
|
|
121
122
|
});
|
|
122
123
|
continue;
|
|
123
124
|
}
|
|
124
|
-
|
|
125
|
+
_ = t(_, f, y), v = !0;
|
|
125
126
|
}
|
|
126
|
-
|
|
127
|
+
v && (f[h] = _, p = !0);
|
|
127
128
|
}
|
|
128
|
-
return f;
|
|
129
|
-
},
|
|
130
|
-
let u = [], d =
|
|
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 =
|
|
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
|
-
},
|
|
173
|
-
let { body: t
|
|
173
|
+
}, x = (e) => {
|
|
174
|
+
let { body: t } = document, r = n();
|
|
174
175
|
if (!t) return !1;
|
|
175
|
-
let
|
|
176
|
-
|
|
177
|
-
let
|
|
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
|
-
|
|
180
|
+
i.select(), a = document.execCommand("copy");
|
|
180
181
|
} catch {
|
|
181
|
-
|
|
182
|
+
a = !1;
|
|
182
183
|
} finally {
|
|
183
|
-
t.removeChild(
|
|
184
|
+
t.removeChild(i), r instanceof HTMLElement && r.focus();
|
|
184
185
|
}
|
|
185
|
-
return
|
|
186
|
-
},
|
|
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
|
|
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 {
|
|
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
|
|
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
|
|
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
|
|
6
|
-
if (!((
|
|
7
|
-
let
|
|
8
|
-
return !
|
|
9
|
-
},
|
|
10
|
-
if (e.matches("dialog, [popover]") || !
|
|
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
|
|
15
|
+
if (n?.getComputedStyle(r).position === "fixed") return s(r) ? e : r;
|
|
15
16
|
}
|
|
16
17
|
return e;
|
|
17
18
|
};
|
|
18
|
-
function
|
|
19
|
-
let n =
|
|
20
|
-
return
|
|
19
|
+
function l(e) {
|
|
20
|
+
let n = e.parentElement?.closest(t);
|
|
21
|
+
return r(n) ? c(n) : null;
|
|
21
22
|
}
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
27
|
-
|
|
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)
|
|
36
|
+
for (let e of n) f.set(e, t);
|
|
30
37
|
return () => {
|
|
31
|
-
for (let e of n)
|
|
38
|
+
for (let e of n) f.get(e) === t && f.delete(e);
|
|
32
39
|
};
|
|
33
40
|
}
|
|
34
|
-
function
|
|
35
|
-
for (let
|
|
36
|
-
if (
|
|
37
|
-
let e =
|
|
38
|
-
if (e) return e() ?? t
|
|
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 ?
|
|
47
|
+
return e ? l(e) ?? u(e) ?? i(e) : i(null);
|
|
41
48
|
}
|
|
42
|
-
function
|
|
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
|
|
62
|
+
function g(e, t) {
|
|
56
63
|
let n = t ?? e.ownerDocument.body;
|
|
57
|
-
e.parentElement !== n && n.appendChild(e),
|
|
64
|
+
e.parentElement !== n && n.appendChild(e), h(e);
|
|
58
65
|
}
|
|
59
66
|
//#endregion
|
|
60
|
-
export {
|
|
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