@ishibashi0112/spreadsheet-grid-core 1.0.2 → 1.2.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/activeRowFollowController.cjs +1 -0
- package/dist/controllers/activeRowFollowController.d.ts +18 -0
- package/dist/controllers/activeRowFollowController.js +68 -0
- package/dist/controllers/autoHeightMeasurer.cjs +1 -1
- package/dist/controllers/autoHeightMeasurer.js +17 -17
- package/dist/controllers/clipboardController.cjs +1 -1
- package/dist/controllers/clipboardController.d.ts +4 -0
- package/dist/controllers/clipboardController.js +82 -54
- package/dist/controllers/columnAutosizeRunner.cjs +1 -1
- package/dist/controllers/columnAutosizeRunner.d.ts +1 -0
- package/dist/controllers/columnAutosizeRunner.js +17 -16
- package/dist/controllers/columnHeaderDragController.cjs +1 -1
- package/dist/controllers/columnHeaderDragController.js +169 -168
- package/dist/controllers/columnMenuController.cjs +1 -1
- package/dist/controllers/columnMenuController.js +71 -69
- package/dist/controllers/contextMenuController.cjs +1 -1
- package/dist/controllers/contextMenuController.d.ts +5 -1
- package/dist/controllers/contextMenuController.js +62 -40
- package/dist/controllers/editController.cjs +1 -1
- package/dist/controllers/editController.d.ts +1 -0
- package/dist/controllers/editController.js +106 -99
- package/dist/controllers/fillHandleController.cjs +1 -1
- package/dist/controllers/fillHandleController.d.ts +1 -0
- package/dist/controllers/fillHandleController.js +157 -157
- package/dist/controllers/filterPopoverController.cjs +1 -1
- package/dist/controllers/filterPopoverController.js +6 -6
- package/dist/controllers/findController.cjs +1 -1
- package/dist/controllers/findController.d.ts +1 -0
- package/dist/controllers/findController.js +16 -15
- package/dist/controllers/historyController.cjs +1 -1
- package/dist/controllers/historyController.d.ts +6 -0
- package/dist/controllers/historyController.js +79 -37
- package/dist/controllers/imeInputController.cjs +1 -1
- package/dist/controllers/imeInputController.js +65 -54
- package/dist/controllers/keyboardController.cjs +1 -1
- package/dist/controllers/keyboardController.d.ts +1 -0
- package/dist/controllers/keyboardController.js +46 -42
- package/dist/controllers/pointerInteractionsController.cjs +1 -1
- package/dist/controllers/pointerInteractionsController.d.ts +1 -0
- package/dist/controllers/pointerInteractionsController.js +172 -172
- package/dist/controllers/popoverSupport.cjs +1 -1
- package/dist/controllers/popoverSupport.d.ts +1 -0
- package/dist/controllers/popoverSupport.js +9 -4
- package/dist/controllers/rowDragController.cjs +1 -1
- package/dist/controllers/rowDragController.d.ts +2 -0
- package/dist/controllers/rowDragController.js +160 -146
- package/dist/controllers/scrollSyncController.cjs +1 -1
- package/dist/controllers/scrollSyncController.js +45 -43
- package/dist/controllers/serverSideRowModel.cjs +1 -1
- package/dist/controllers/serverSideRowModel.js +19 -19
- package/dist/controllers/toolPanelController.cjs +1 -1
- package/dist/controllers/toolPanelController.js +26 -14
- package/dist/controllers/tooltipController.cjs +1 -1
- package/dist/controllers/tooltipController.js +74 -72
- package/dist/controllers/viewportSyncController.cjs +1 -1
- package/dist/controllers/viewportSyncController.d.ts +4 -1
- package/dist/controllers/viewportSyncController.js +66 -28
- package/dist/engine/columnCommands.cjs +1 -1
- package/dist/engine/columnCommands.js +113 -113
- package/dist/engine/createGridEngine.cjs +3 -3
- package/dist/engine/createGridEngine.d.ts +2 -0
- package/dist/engine/createGridEngine.js +72 -70
- package/dist/engine/exportCommands.cjs +1 -1
- package/dist/engine/exportCommands.js +18 -9
- package/dist/engine/fullFeatures.cjs +1 -1
- package/dist/engine/fullFeatures.js +6 -6
- package/dist/engine/gridApi.cjs +6 -6
- package/dist/engine/gridApi.d.ts +8 -2
- package/dist/engine/gridApi.js +197 -187
- package/dist/engine/notifiers.cjs +1 -1
- package/dist/engine/notifiers.d.ts +4 -0
- package/dist/engine/notifiers.js +7 -7
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +7 -6
- package/dist/locales/en.cjs +1 -1
- package/dist/locales/en.js +5 -0
- package/dist/logic/autoScrollGeometry.cjs +1 -1
- package/dist/logic/autoScrollGeometry.d.ts +2 -0
- package/dist/logic/autoScrollGeometry.js +3 -3
- package/dist/logic/editorValues.cjs +1 -1
- package/dist/logic/editorValues.js +37 -34
- package/dist/logic/exportCsv.cjs +3 -3
- package/dist/logic/exportCsv.d.ts +4 -1
- package/dist/logic/exportCsv.js +22 -20
- package/dist/logic/exportData.cjs +1 -1
- package/dist/logic/exportData.d.ts +4 -1
- package/dist/logic/exportData.js +40 -36
- package/dist/logic/filtering.cjs +1 -1
- package/dist/logic/filtering.d.ts +2 -1
- package/dist/logic/filtering.js +16 -3
- package/dist/logic/geometry.cjs +1 -1
- package/dist/logic/geometry.d.ts +2 -0
- package/dist/logic/geometry.js +41 -20
- package/dist/logic/gridState.cjs +1 -1
- package/dist/logic/gridState.d.ts +3 -2
- package/dist/logic/gridState.js +32 -23
- package/dist/logic/groupExport.cjs +1 -1
- package/dist/logic/groupExport.js +28 -27
- package/dist/logic/grouping.cjs +1 -1
- package/dist/logic/grouping.d.ts +1 -0
- package/dist/logic/grouping.js +52 -41
- package/dist/logic/historyRebase.cjs +1 -0
- package/dist/logic/historyRebase.d.ts +5 -0
- package/dist/logic/historyRebase.js +36 -0
- package/dist/logic/imeInput.cjs +1 -1
- package/dist/logic/imeInput.js +6 -4
- package/dist/logic/localeTextFeatures.cjs +1 -1
- package/dist/logic/localeTextFeatures.d.ts +8 -0
- package/dist/logic/localeTextFeatures.js +11 -5
- package/dist/logic/localeTextPopups.cjs +1 -1
- package/dist/logic/localeTextPopups.d.ts +1 -0
- package/dist/logic/localeTextPopups.js +1 -0
- package/dist/logic/pasteFill.cjs +1 -0
- package/dist/logic/pasteFill.d.ts +2 -0
- package/dist/logic/pasteFill.js +25 -0
- package/dist/logic/selectEditorState.cjs +1 -1
- package/dist/logic/selectEditorState.d.ts +4 -1
- package/dist/logic/selectEditorState.js +14 -14
- package/dist/logic/selectLabels.cjs +1 -0
- package/dist/logic/selectLabels.d.ts +3 -0
- package/dist/logic/selectLabels.js +41 -0
- package/dist/logic/selectionAggregates.cjs +1 -1
- package/dist/logic/selectionAggregates.js +2 -3
- package/dist/logic/validation.cjs +1 -1
- package/dist/logic/validation.d.ts +1 -1
- package/dist/logic/validation.js +21 -21
- package/dist/logic/valueParsers.cjs +1 -0
- package/dist/logic/valueParsers.d.ts +14 -0
- package/dist/logic/valueParsers.js +23 -0
- package/dist/model/gridActions.cjs +1 -1
- package/dist/model/gridActions.d.ts +13 -0
- package/dist/model/gridActions.js +11 -0
- package/dist/model/gridReducer.cjs +1 -1
- package/dist/model/gridReducer.js +128 -65
- package/dist/model/gridTypes.core.d.ts +345 -43
- package/dist/utils/clipboard.cjs +4 -4
- package/dist/utils/clipboard.d.ts +14 -2
- package/dist/utils/clipboard.js +101 -49
- package/dist/utils/gridVisibleBand.cjs +1 -0
- package/dist/utils/gridVisibleBand.d.ts +4 -0
- package/dist/utils/gridVisibleBand.js +24 -0
- package/dist/utils/popupContainer.cjs +1 -0
- package/dist/utils/popupContainer.d.ts +8 -0
- package/dist/utils/popupContainer.js +60 -0
- package/dist/utils/scrollBottom.cjs +1 -0
- package/dist/utils/scrollBottom.d.ts +1 -0
- package/dist/utils/scrollBottom.js +4 -0
- package/dist/utils/topAlignedInput.cjs +1 -0
- package/dist/utils/topAlignedInput.d.ts +3 -0
- package/dist/utils/topAlignedInput.js +23 -0
- package/package.json +1 -1
package/dist/utils/clipboard.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./permissions.cjs"),t=require("../logic/detailRow.cjs"),n=require("../model/gridSelectors.cjs"),r=require("../logic/
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./permissions.cjs"),t=require("../logic/detailRow.cjs"),n=require("../model/gridSelectors.cjs"),r=require("../logic/selectLabels.cjs"),i=require("../logic/editorValues.cjs"),a=require("../logic/validation.cjs");var o=e=>{let t=e.replace(/\r\n/g,`
|
|
2
2
|
`).replace(/\r/g,`
|
|
3
3
|
`);if(!t)return[];let n=[],r=[],i=``,a=0,o=t.length,s=-1,c=0;for(;a<o;){let e=t[a];if(i===``&&e===`"`&&a===c&&a!==s){let e=a+1,n=``,r=!1;for(;e<o;){let i=t[e];if(i===`"`){if(t[e+1]===`"`){n+=`"`,e+=2;continue}r=!0,e+=1;break}n+=i,e+=1}if(!r){s=a;continue}i=n,a=e;continue}if(e===` `){r.push(i),i=``,a+=1,c=a;continue}if(e===`
|
|
4
4
|
`){r.push(i),n.push(r),r=[],i=``,a+=1,c=a;continue}i+=e,a+=1}return i===``&&r.length===0&&t.endsWith(`
|
|
5
|
-
`)||(r.push(i),n.push(r)),n},
|
|
6
|
-
`);return t!==void 0&&/^\t*$/.test(t)?`${n}\n`:n},
|
|
7
|
-
[SpreadsheetGrid] Failed to copy to the clipboard (navigator.clipboard is unavailable and the execCommand fallback failed).`),!1)};exports.applyClipboardMatrixToRows=
|
|
5
|
+
`)||(r.push(i),n.push(r)),n},s=e=>/[\t\n\r"]/.test(e)?`"${e.replace(/"/g,`""`)}"`:e,c=e=>e.map(s).join(` `),l=e=>{let t=e[e.length-1],n=e.join(`
|
|
6
|
+
`);return t!==void 0&&/^\t*$/.test(t)?`${n}\n`:n},u=e=>e!==void 0&&!t.isSyntheticColumnKey(e.key),d=(e,t,n)=>{let r=[];for(let i=t;r.length<n;i+=1){let t=e[i];(t===void 0||u(t))&&r.push(i)}return r},f=(t,n)=>r.formatCellClipboardText(n,e.getCellValue(t,n),t),p=e=>e.filter(u),m=(e,t,r,i,a)=>{if(!i)return``;let o=[];if(i.type===`cell`){let t=n.normalizeCellRange(i.range),s=r.slice(t.start.col,t.end.col+1).filter(u);if(s.length===0)return``;for(let n=t.start.row;n<=t.end.row;n+=1){let t=e(n);t&&(a&&!a(t,n)||o.push(c(s.map(e=>f(t,e)))))}return l(o)}if(i.type===`row`){let t=n.normalizeRowRange(i.startRow,i.endRow),s=r.filter(u);if(s.length===0)return``;for(let n=t.startRow;n<=t.endRow;n+=1){let t=e(n);t&&(a&&!a(t,n)||o.push(c(s.map(e=>f(t,e)))))}return l(o)}let s=n.normalizeColumnRange(i.startCol,i.endCol),d=r.slice(s.startCol,s.endCol+1).filter(u);if(d.length===0)return``;for(let n=0;n<t;n+=1){let t=e(n);t&&(a&&!a(t,n)||o.push(c(d.map(e=>f(t,e)))))}return l(o)},h=(t,n,r,o,s,c,l,u,f)=>{if(o.length===0)return t;let p=[...t],m=d(r,c,o.reduce((e,t)=>Math.max(e,t.length),0));for(let t=0;t<o.length;t+=1){let c=s+t,d=n(c);if(d===void 0)continue;let h=p[d];if(!h)continue;let g=h,_=!1;for(let n=0;n<o[t].length;n+=1){let s=m[n],p=r[s];if(!p)continue;let v=o[t][n];if(!l(d,s,h,p,c)){u?.({rowIndex:c,sourceRowIndex:d,colIndex:s,row:h,column:p,text:v,reason:`readOnly`});continue}let y=i.resolveCellParser(p)(v,h),b=a.decideCellWrite(p,h,y,f);if(b.action===`reject`){u?.({rowIndex:c,sourceRowIndex:d,colIndex:s,row:h,column:p,text:v,reason:`invalid`,value:y,message:b.message});continue}g=e.setCellValue(g,p,y),_=!0}_&&(p[d]=g)}return p},g=(e,t,n,r,o,s,c,l)=>{let u=[],f=d(t,o,n.reduce((e,t)=>Math.max(e,t.length),0));for(let o=0;o<n.length;o+=1){let d=r+o,p=e(d);if(p)for(let e=0;e<n[o].length;e+=1){let r=f[e],m=t[r];if(!m)continue;let h=n[o][e];if(!s(d,r,p,m)){c?.({rowIndex:d,sourceRowIndex:void 0,colIndex:r,row:p,column:m,text:h,reason:`readOnly`});continue}let g=i.resolveCellParser(m)(h,p),_=a.decideCellWrite(m,p,g,l);if(_.action===`reject`){c?.({rowIndex:d,sourceRowIndex:void 0,colIndex:r,row:p,column:m,text:h,reason:`invalid`,value:g,message:_.message});continue}u.push({viewIndex:d,column:m,value:g})}}return u},_=e=>{let{body:t,activeElement:n}=document;if(!t)return!1;let r=document.createElement(`textarea`);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);let i;try{r.select(),i=document.execCommand(`copy`)}catch{i=!1}finally{t.removeChild(r),n instanceof HTMLElement&&n.focus()}return i},v=async e=>{if(navigator.clipboard?.writeText)try{return await navigator.clipboard.writeText(e),!0}catch{}return _(e)?!0:(console.warn(`[SpreadsheetGrid] クリップボードへのコピーに失敗しました(navigator.clipboard が利用できず、execCommand フォールバックも失敗)。
|
|
7
|
+
[SpreadsheetGrid] Failed to copy to the clipboard (navigator.clipboard is unavailable and the execCommand fallback failed).`),!1)};exports.applyClipboardMatrixToRows=h,exports.buildClipboardCellEdits=g,exports.copyTextViaExecCommand=_,exports.escapeTsvField=s,exports.filterClipboardColumns=p,exports.formatClipboardCell=f,exports.joinTsvLines=l,exports.joinTsvRow=c,exports.parseClipboardText=o,exports.resolvePasteColumnIndexes=d,exports.serializeSelectionToTsv=m,exports.writeTextToClipboard=v;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { GridColumn } from '../model/gridTypes.unbound.js';
|
|
2
2
|
import type { ServerSideCellEditInput } from '../logic/serverSideEdits.js';
|
|
3
|
+
import { type ValidationLocaleText } from '../logic/validation.js';
|
|
3
4
|
export type ClipboardMatrix = string[][];
|
|
4
5
|
export declare const parseClipboardText: (text: string) => ClipboardMatrix;
|
|
5
6
|
export declare const escapeTsvField: (value: string) => string;
|
|
@@ -29,7 +30,18 @@ export declare const serializeSelectionToTsv: <T>(getRow: (viewIndex: number) =>
|
|
|
29
30
|
startCol: number;
|
|
30
31
|
endCol: number;
|
|
31
32
|
} | null, isRowIncluded?: (row: T, viewRowIndex: number) => boolean) => string;
|
|
32
|
-
export
|
|
33
|
-
|
|
33
|
+
export type PasteSkip<T> = {
|
|
34
|
+
rowIndex: number;
|
|
35
|
+
sourceRowIndex: number | undefined;
|
|
36
|
+
colIndex: number;
|
|
37
|
+
row: T;
|
|
38
|
+
column: GridColumn<T>;
|
|
39
|
+
text: string;
|
|
40
|
+
reason: 'readOnly' | 'invalid';
|
|
41
|
+
value?: unknown;
|
|
42
|
+
message?: string | undefined;
|
|
43
|
+
};
|
|
44
|
+
export declare const applyClipboardMatrixToRows: <T extends object>(rows: T[], resolveSourceIndex: (viewIndex: number) => number | undefined, columns: GridColumn<T>[], matrix: ClipboardMatrix, startRowIndex: number, startColIndex: number, canWriteCell: (originalRowIndex: number, colIndex: number, row: T, column: GridColumn<T>, filteredRowIndex: number) => boolean, onSkip?: (skip: PasteSkip<T>) => void, validationTexts?: ValidationLocaleText) => T[];
|
|
45
|
+
export declare const buildClipboardCellEdits: <T extends object>(getRow: (viewIndex: number) => T | undefined, columns: GridColumn<T>[], matrix: ClipboardMatrix, startRowIndex: number, startColIndex: number, canWriteCell: (viewIndex: number, colIndex: number, row: T, column: GridColumn<T>) => boolean, onSkip?: (skip: PasteSkip<T>) => void, validationTexts?: ValidationLocaleText) => ServerSideCellEditInput<T>[];
|
|
34
46
|
export declare const copyTextViaExecCommand: (text: string) => boolean;
|
|
35
47
|
export declare const writeTextToClipboard: (text: string) => Promise<boolean>;
|
package/dist/utils/clipboard.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { getCellValue as e, setCellValue as t } from "./permissions.js";
|
|
2
2
|
import { isSyntheticColumnKey as n } from "../logic/detailRow.js";
|
|
3
3
|
import { normalizeCellRange as r, normalizeColumnRange as i, normalizeRowRange as a } from "../model/gridSelectors.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
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";
|
|
6
7
|
//#region src/utils/clipboard.ts
|
|
7
|
-
var
|
|
8
|
+
var l = (e) => {
|
|
8
9
|
let t = e.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
|
|
9
10
|
if (!t) return [];
|
|
10
11
|
let n = [], r = [], i = "", a = 0, o = t.length, s = -1, c = 0;
|
|
@@ -42,82 +43,133 @@ var c = (e) => {
|
|
|
42
43
|
i += e, a += 1;
|
|
43
44
|
}
|
|
44
45
|
return i === "" && r.length === 0 && t.endsWith("\n") || (r.push(i), n.push(r)), n;
|
|
45
|
-
},
|
|
46
|
+
}, u = (e) => /[\t\n\r"]/.test(e) ? `"${e.replace(/"/g, "\"\"")}"` : e, d = (e) => e.map(u).join(" "), f = (e) => {
|
|
46
47
|
let t = e[e.length - 1], n = e.join("\n");
|
|
47
48
|
return t !== void 0 && /^\t*$/.test(t) ? `${n}\n` : n;
|
|
48
|
-
},
|
|
49
|
+
}, p = (e) => e !== void 0 && !n(e.key), m = (e, t, n) => {
|
|
49
50
|
let r = [];
|
|
50
51
|
for (let i = t; r.length < n; i += 1) {
|
|
51
52
|
let t = e[i];
|
|
52
|
-
(t === void 0 ||
|
|
53
|
+
(t === void 0 || p(t)) && r.push(i);
|
|
53
54
|
}
|
|
54
55
|
return r;
|
|
55
|
-
},
|
|
56
|
-
let r = e(t, n);
|
|
57
|
-
return n.formatClipboardValue ? n.formatClipboardValue(r, t) : String(r ?? "");
|
|
58
|
-
}, h = (e) => e.filter(f), g = (e, t, n, o, s) => {
|
|
56
|
+
}, h = (t, n) => o(n, e(t, n), t), g = (e) => e.filter(p), _ = (e, t, n, o, s) => {
|
|
59
57
|
if (!o) return "";
|
|
60
58
|
let c = [];
|
|
61
59
|
if (o.type === "cell") {
|
|
62
|
-
let t = r(o.range), i = n.slice(t.start.col, t.end.col + 1).filter(
|
|
60
|
+
let t = r(o.range), i = n.slice(t.start.col, t.end.col + 1).filter(p);
|
|
63
61
|
if (i.length === 0) return "";
|
|
64
62
|
for (let n = t.start.row; n <= t.end.row; n += 1) {
|
|
65
63
|
let t = e(n);
|
|
66
|
-
t && (s && !s(t, n) || c.push(
|
|
64
|
+
t && (s && !s(t, n) || c.push(d(i.map((e) => h(t, e)))));
|
|
67
65
|
}
|
|
68
|
-
return
|
|
66
|
+
return f(c);
|
|
69
67
|
}
|
|
70
68
|
if (o.type === "row") {
|
|
71
|
-
let t = a(o.startRow, o.endRow), r = n.filter(
|
|
69
|
+
let t = a(o.startRow, o.endRow), r = n.filter(p);
|
|
72
70
|
if (r.length === 0) return "";
|
|
73
71
|
for (let n = t.startRow; n <= t.endRow; n += 1) {
|
|
74
72
|
let t = e(n);
|
|
75
|
-
t && (s && !s(t, n) || c.push(
|
|
73
|
+
t && (s && !s(t, n) || c.push(d(r.map((e) => h(t, e)))));
|
|
76
74
|
}
|
|
77
|
-
return
|
|
75
|
+
return f(c);
|
|
78
76
|
}
|
|
79
|
-
let l = i(o.startCol, o.endCol),
|
|
80
|
-
if (
|
|
77
|
+
let l = i(o.startCol, o.endCol), u = n.slice(l.startCol, l.endCol + 1).filter(p);
|
|
78
|
+
if (u.length === 0) return "";
|
|
81
79
|
for (let n = 0; n < t; n += 1) {
|
|
82
80
|
let t = e(n);
|
|
83
|
-
t && (s && !s(t, n) || c.push(u
|
|
81
|
+
t && (s && !s(t, n) || c.push(d(u.map((e) => h(t, e)))));
|
|
84
82
|
}
|
|
85
|
-
return
|
|
86
|
-
},
|
|
83
|
+
return f(c);
|
|
84
|
+
}, v = (e, n, r, i, a, o, l, u, d) => {
|
|
87
85
|
if (i.length === 0) return e;
|
|
88
|
-
let
|
|
86
|
+
let f = [...e], p = m(r, o, i.reduce((e, t) => Math.max(e, t.length), 0));
|
|
89
87
|
for (let e = 0; e < i.length; e += 1) {
|
|
90
|
-
let
|
|
91
|
-
if (
|
|
92
|
-
let
|
|
93
|
-
if (!
|
|
94
|
-
let
|
|
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;
|
|
95
93
|
for (let n = 0; n < i[e].length; n += 1) {
|
|
96
|
-
let a =
|
|
97
|
-
if (!
|
|
98
|
-
let
|
|
99
|
-
|
|
94
|
+
let a = p[n], f = r[a];
|
|
95
|
+
if (!f) continue;
|
|
96
|
+
let v = i[e][n];
|
|
97
|
+
if (!l(m, a, h, f, o)) {
|
|
98
|
+
u?.({
|
|
99
|
+
rowIndex: o,
|
|
100
|
+
sourceRowIndex: m,
|
|
101
|
+
colIndex: a,
|
|
102
|
+
row: h,
|
|
103
|
+
column: f,
|
|
104
|
+
text: v,
|
|
105
|
+
reason: "readOnly"
|
|
106
|
+
});
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
let y = s(f)(v, h), b = c(f, h, y, d);
|
|
110
|
+
if (b.action === "reject") {
|
|
111
|
+
u?.({
|
|
112
|
+
rowIndex: o,
|
|
113
|
+
sourceRowIndex: m,
|
|
114
|
+
colIndex: a,
|
|
115
|
+
row: h,
|
|
116
|
+
column: f,
|
|
117
|
+
text: v,
|
|
118
|
+
reason: "invalid",
|
|
119
|
+
value: y,
|
|
120
|
+
message: b.message
|
|
121
|
+
});
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
g = t(g, f, y), _ = !0;
|
|
100
125
|
}
|
|
101
|
-
|
|
126
|
+
_ && (f[m] = g);
|
|
102
127
|
}
|
|
103
|
-
return
|
|
104
|
-
},
|
|
105
|
-
let
|
|
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));
|
|
106
131
|
for (let i = 0; i < n.length; i += 1) {
|
|
107
|
-
let
|
|
108
|
-
if (
|
|
109
|
-
let r =
|
|
110
|
-
if (!
|
|
111
|
-
let
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
132
|
+
let f = r + i, p = e(f);
|
|
133
|
+
if (p) for (let e = 0; e < n[i].length; e += 1) {
|
|
134
|
+
let r = d[e], m = t[r];
|
|
135
|
+
if (!m) continue;
|
|
136
|
+
let h = n[i][e];
|
|
137
|
+
if (!a(f, r, p, m)) {
|
|
138
|
+
o?.({
|
|
139
|
+
rowIndex: f,
|
|
140
|
+
sourceRowIndex: void 0,
|
|
141
|
+
colIndex: r,
|
|
142
|
+
row: p,
|
|
143
|
+
column: m,
|
|
144
|
+
text: h,
|
|
145
|
+
reason: "readOnly"
|
|
146
|
+
});
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
let g = s(m)(h, p), _ = c(m, p, g, l);
|
|
150
|
+
if (_.action === "reject") {
|
|
151
|
+
o?.({
|
|
152
|
+
rowIndex: f,
|
|
153
|
+
sourceRowIndex: void 0,
|
|
154
|
+
colIndex: r,
|
|
155
|
+
row: p,
|
|
156
|
+
column: m,
|
|
157
|
+
text: h,
|
|
158
|
+
reason: "invalid",
|
|
159
|
+
value: g,
|
|
160
|
+
message: _.message
|
|
161
|
+
});
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
u.push({
|
|
165
|
+
viewIndex: f,
|
|
166
|
+
column: m,
|
|
167
|
+
value: g
|
|
116
168
|
});
|
|
117
169
|
}
|
|
118
170
|
}
|
|
119
|
-
return
|
|
120
|
-
},
|
|
171
|
+
return u;
|
|
172
|
+
}, b = (e) => {
|
|
121
173
|
let { body: t, activeElement: n } = document;
|
|
122
174
|
if (!t) return !1;
|
|
123
175
|
let r = document.createElement("textarea");
|
|
@@ -131,11 +183,11 @@ var c = (e) => {
|
|
|
131
183
|
t.removeChild(r), n instanceof HTMLElement && n.focus();
|
|
132
184
|
}
|
|
133
185
|
return i;
|
|
134
|
-
},
|
|
186
|
+
}, x = async (e) => {
|
|
135
187
|
if (navigator.clipboard?.writeText) try {
|
|
136
188
|
return await navigator.clipboard.writeText(e), !0;
|
|
137
189
|
} catch {}
|
|
138
|
-
return
|
|
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);
|
|
139
191
|
};
|
|
140
192
|
//#endregion
|
|
141
|
-
export {
|
|
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 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=e=>{let t=e.closest(`.ssg-scroll-container`);if(!t||t.clientHeight<=0)return null;let n=t.getBoundingClientRect().top+t.clientTop,r=n+t.clientHeight;for(let e of[`.ssg-header-row`,`.ssg-pinned-rows--top`,`[data-ssg-sticky-label]`]){let r=t.querySelector(e);r&&(n=Math.max(n,r.getBoundingClientRect().bottom))}for(let e of[`.ssg-pinned-rows--bottom`,`.ssg-total-row`]){let n=t.querySelector(e);n&&(r=Math.min(r,n.getBoundingClientRect().top))}return{top:n,bottom:r}};exports.resolveGridVisibleBand=e;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/utils/gridVisibleBand.ts
|
|
2
|
+
var e = (e) => {
|
|
3
|
+
let t = e.closest(".ssg-scroll-container");
|
|
4
|
+
if (!t || t.clientHeight <= 0) return null;
|
|
5
|
+
let n = t.getBoundingClientRect().top + t.clientTop, r = n + t.clientHeight;
|
|
6
|
+
for (let e of [
|
|
7
|
+
".ssg-header-row",
|
|
8
|
+
".ssg-pinned-rows--top",
|
|
9
|
+
"[data-ssg-sticky-label]"
|
|
10
|
+
]) {
|
|
11
|
+
let r = t.querySelector(e);
|
|
12
|
+
r && (n = Math.max(n, r.getBoundingClientRect().bottom));
|
|
13
|
+
}
|
|
14
|
+
for (let e of [".ssg-pinned-rows--bottom", ".ssg-total-row"]) {
|
|
15
|
+
let n = t.querySelector(e);
|
|
16
|
+
n && (r = Math.min(r, n.getBoundingClientRect().top));
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
top: n,
|
|
20
|
+
bottom: r
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { e as resolveGridVisibleBand };
|
|
@@ -0,0 +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;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { GridPopupContainer } from '../model/gridTypes.core.js';
|
|
2
|
+
export type { GridPopupContainer };
|
|
3
|
+
export declare function findPopupHost(element: Element): HTMLElement | null;
|
|
4
|
+
export declare function resolvePopupContainer(gridElement: HTMLElement | null | undefined, option: GridPopupContainer | undefined): HTMLElement | null;
|
|
5
|
+
export declare function registerPopupContainer(elements: readonly (Element | null | undefined)[], get: () => HTMLElement | null): () => void;
|
|
6
|
+
export declare function getPopupContainerFor(element: Element | null | undefined): HTMLElement | null;
|
|
7
|
+
export declare function syncPopupOrigin(popup: HTMLElement | null | undefined): void;
|
|
8
|
+
export declare function appendToPopupContainer(popup: HTMLElement, container: HTMLElement | null): void;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
//#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
|
+
let t = e.ownerDocument.defaultView;
|
|
4
|
+
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;
|
|
11
|
+
let t = e.ownerDocument, n = t.defaultView;
|
|
12
|
+
for (let r = e.parentElement; r !== null && r !== t.body && r !== t.documentElement; r = r.parentElement) {
|
|
13
|
+
if (r.matches("dialog, [popover]")) return e;
|
|
14
|
+
if (n?.getComputedStyle(r).position === "fixed") return i(r) ? e : r;
|
|
15
|
+
}
|
|
16
|
+
return e;
|
|
17
|
+
};
|
|
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;
|
|
21
|
+
}
|
|
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;
|
|
25
|
+
}
|
|
26
|
+
var c = /* @__PURE__ */ new WeakMap();
|
|
27
|
+
function l(e, t) {
|
|
28
|
+
let n = e.filter((e) => e != null);
|
|
29
|
+
for (let e of n) c.set(e, t);
|
|
30
|
+
return () => {
|
|
31
|
+
for (let e of n) c.get(e) === t && c.delete(e);
|
|
32
|
+
};
|
|
33
|
+
}
|
|
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);
|
|
39
|
+
}
|
|
40
|
+
return e ? o(e) ?? t(e) : t(null);
|
|
41
|
+
}
|
|
42
|
+
function d(e) {
|
|
43
|
+
let t = e?.parentElement;
|
|
44
|
+
if (!e || !t) return;
|
|
45
|
+
let n = e.ownerDocument, r = 0, i = 0;
|
|
46
|
+
if (t !== n.body && t !== n.documentElement) {
|
|
47
|
+
let e = n.createElement("div");
|
|
48
|
+
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);
|
|
49
|
+
let a = e.getBoundingClientRect();
|
|
50
|
+
e.remove(), r = Number.isFinite(a.left) ? a.left : 0, i = Number.isFinite(a.top) ? a.top : 0;
|
|
51
|
+
}
|
|
52
|
+
let a = r === 0 && i === 0 ? "" : `${-r}px ${-i}px`;
|
|
53
|
+
e.style.getPropertyValue("translate") !== a && (a === "" ? e.style.removeProperty("translate") : e.style.setProperty("translate", a));
|
|
54
|
+
}
|
|
55
|
+
function f(e, t) {
|
|
56
|
+
let n = t ?? e.ownerDocument.body;
|
|
57
|
+
e.parentElement !== n && n.appendChild(e), d(e);
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
export { f as appendToPopupContainer, o as findPopupHost, u as getPopupContainerFor, l as registerPopupContainer, s as resolvePopupContainer, d as syncPopupOrigin };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=2,t=t=>t.scrollHeight-t.scrollTop-t.clientHeight<=e;exports.isScrolledToBottom=t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isScrolledToBottom: (el: HTMLElement) => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../logic/elementScale.cjs"),t=require("./gridVisibleBand.cjs");var n=.4,r=n=>{let r=t.resolveGridVisibleBand(n);if(r===null)return 0;let i=n.getBoundingClientRect(),a=r.top-i.top;return a<=0?0:a/e.resolveElementScale(n,i).y},i=(e,t,r,i=0)=>{let a=e.style;if(!t){a.paddingTop=``,a.paddingBottom=``,a.lineHeight=``;return}let o=a.height;a.lineHeight=`inherit`,a.paddingTop=`0px`,a.paddingBottom=`0px`,a.height=`auto`;let s=e.clientHeight;a.height=o;let c=getComputedStyle(e),l=Number.parseFloat(c.fontSize)||0,u=Number.parseFloat(c.borderTopWidth)||0,d=Number.parseFloat(c.borderBottomWidth)||0,f=Math.max(0,Math.round(l*n-u)),p=Math.max(0,r-u-d-s),m=i>0?Math.max(f,Math.min(p,Math.round(f+i))):f,h=Math.max(0,r-u-d-m-s);a.paddingTop=`${m}px`,a.paddingBottom=`${h}px`};exports.TOP_ALIGNED_PADDING_EM=n,exports.alignInputTextToTop=i,exports.resolveHiddenTopOf=r;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { resolveElementScale as e } from "../logic/elementScale.js";
|
|
2
|
+
import { resolveGridVisibleBand as t } from "./gridVisibleBand.js";
|
|
3
|
+
//#region src/utils/topAlignedInput.ts
|
|
4
|
+
var n = .4, r = (n) => {
|
|
5
|
+
let r = t(n);
|
|
6
|
+
if (r === null) return 0;
|
|
7
|
+
let i = n.getBoundingClientRect(), a = r.top - i.top;
|
|
8
|
+
return a <= 0 ? 0 : a / e(n, i).y;
|
|
9
|
+
}, i = (e, t, r, i = 0) => {
|
|
10
|
+
let a = e.style;
|
|
11
|
+
if (!t) {
|
|
12
|
+
a.paddingTop = "", a.paddingBottom = "", a.lineHeight = "";
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
let o = a.height;
|
|
16
|
+
a.lineHeight = "inherit", a.paddingTop = "0px", a.paddingBottom = "0px", a.height = "auto";
|
|
17
|
+
let s = e.clientHeight;
|
|
18
|
+
a.height = o;
|
|
19
|
+
let c = getComputedStyle(e), l = Number.parseFloat(c.fontSize) || 0, u = Number.parseFloat(c.borderTopWidth) || 0, d = Number.parseFloat(c.borderBottomWidth) || 0, f = Math.max(0, Math.round(l * n - u)), p = Math.max(0, r - u - d - s), m = i > 0 ? Math.max(f, Math.min(p, Math.round(f + i))) : f, h = Math.max(0, r - u - d - m - s);
|
|
20
|
+
a.paddingTop = `${m}px`, a.paddingBottom = `${h}px`;
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { n as TOP_ALIGNED_PADDING_EM, i as alignInputTextToTop, r as resolveHiddenTopOf };
|
package/package.json
CHANGED