@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.
- package/dist/controllers/clipboardController.cjs +1 -1
- package/dist/controllers/clipboardController.d.ts +1 -0
- package/dist/controllers/clipboardController.js +79 -70
- 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 -0
- package/dist/controllers/detailRowController.d.ts +41 -0
- package/dist/controllers/detailRowController.js +97 -0
- 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 +4 -0
- package/dist/controllers/keyboardController.js +101 -97
- package/dist/controllers/liveUiState.cjs +1 -0
- package/dist/controllers/liveUiState.d.ts +7 -0
- package/dist/controllers/liveUiState.js +4 -0
- package/dist/controllers/pointerInteractionsController.cjs +1 -1
- package/dist/controllers/pointerInteractionsController.d.ts +1 -0
- package/dist/controllers/pointerInteractionsController.js +127 -126
- 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/cellCommands.cjs +1 -0
- package/dist/engine/cellCommands.d.ts +27 -0
- package/dist/engine/cellCommands.js +89 -0
- 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 +3 -0
- package/dist/engine/gridApi.js +158 -144
- 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/cellPlacement.cjs +1 -0
- package/dist/logic/cellPlacement.d.ts +22 -0
- package/dist/logic/cellPlacement.js +44 -0
- 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/density.cjs +1 -0
- package/dist/logic/density.d.ts +5 -0
- package/dist/logic/density.js +17 -0
- package/dist/logic/detailRow.cjs +1 -1
- package/dist/logic/detailRow.d.ts +6 -1
- package/dist/logic/detailRow.js +21 -17
- package/dist/logic/domGuards.cjs +1 -1
- package/dist/logic/domGuards.d.ts +10 -0
- package/dist/logic/domGuards.js +18 -2
- package/dist/logic/editorKeys.cjs +1 -0
- package/dist/logic/editorKeys.d.ts +30 -0
- package/dist/logic/editorKeys.js +34 -0
- package/dist/logic/editorStart.cjs +1 -0
- package/dist/logic/editorStart.d.ts +7 -0
- package/dist/logic/editorStart.js +23 -0
- 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/gridBarSummary.cjs +1 -0
- package/dist/logic/gridBarSummary.d.ts +27 -0
- package/dist/logic/gridBarSummary.js +137 -0
- 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.cjs +1 -1
- package/dist/logic/selectEditorState.d.ts +27 -4
- package/dist/logic/selectEditorState.js +29 -14
- 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/editorVisibleBounds.cjs +1 -0
- package/dist/utils/editorVisibleBounds.d.ts +10 -0
- package/dist/utils/editorVisibleBounds.js +40 -0
- package/dist/utils/errorBubblePlacement.cjs +1 -0
- package/dist/utils/errorBubblePlacement.d.ts +8 -0
- package/dist/utils/errorBubblePlacement.js +26 -0
- package/dist/utils/multilineEditor.cjs +2 -0
- package/dist/utils/multilineEditor.d.ts +7 -0
- package/dist/utils/multilineEditor.js +22 -0
- 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 };
|
|
@@ -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
|
|
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