@ishibashi0112/spreadsheet-grid-core 1.2.0 → 1.2.1
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 +35 -34
- package/dist/controllers/detailRowController.cjs +1 -0
- package/dist/controllers/detailRowController.d.ts +41 -0
- package/dist/controllers/detailRowController.js +96 -0
- package/dist/controllers/keyboardController.cjs +1 -1
- package/dist/controllers/keyboardController.d.ts +1 -0
- package/dist/controllers/keyboardController.js +98 -96
- 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/engine/cellCommands.cjs +1 -0
- package/dist/engine/cellCommands.d.ts +27 -0
- package/dist/engine/cellCommands.js +89 -0
- package/dist/engine/gridApi.cjs +3 -3
- package/dist/engine/gridApi.d.ts +2 -0
- package/dist/engine/gridApi.js +72 -66
- 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/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 +4 -0
- package/dist/logic/detailRow.js +10 -7
- package/dist/logic/domGuards.cjs +1 -1
- package/dist/logic/domGuards.d.ts +5 -0
- package/dist/logic/domGuards.js +8 -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/gridBarSummary.cjs +1 -0
- package/dist/logic/gridBarSummary.d.ts +27 -0
- package/dist/logic/gridBarSummary.js +137 -0
- package/dist/logic/selectEditorState.cjs +1 -1
- package/dist/logic/selectEditorState.d.ts +24 -1
- package/dist/logic/selectEditorState.js +29 -14
- 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/package.json +1 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { isNumberInputPrefix as e, normalizeNumberText as t, normalizeTypedDateText as n, toDateInputValue as r, toNumberInputText as i } from "./editorValues.js";
|
|
2
|
+
//#region src/logic/editorStart.ts
|
|
3
|
+
var a = (e, t) => e === String(t ?? "") ? void 0 : e, o = (t) => {
|
|
4
|
+
if (t === "" || e(t)) return {
|
|
5
|
+
text: t,
|
|
6
|
+
textMode: t !== ""
|
|
7
|
+
};
|
|
8
|
+
let n = i(t);
|
|
9
|
+
return n === null ? {
|
|
10
|
+
text: t,
|
|
11
|
+
textMode: !0
|
|
12
|
+
} : {
|
|
13
|
+
text: n,
|
|
14
|
+
textMode: !1
|
|
15
|
+
};
|
|
16
|
+
}, s = (n, r) => r && e(t(n)) ? "" : n, c = (e) => {
|
|
17
|
+
let t = String(e).trim();
|
|
18
|
+
if (t === "") return "";
|
|
19
|
+
let i = r(n(t));
|
|
20
|
+
return i === "" ? null : i;
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
export { c as readTypedDateCommitValue, s as resolveNumberEditorCommitValue, o as resolveNumberEditorStart, a as resolveTypedStartText };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require("./grouping.cjs"),require("./rowReorder.cjs");const e=require("./detailRow.cjs"),t=require("./localeTextFilters.cjs"),n=require("./localeText.cjs"),r=require("./labelRows.cjs"),i=require("./filtering.cjs"),a=require("../utils/excelColumnName.cjs");var o=(e,t=16)=>e.length<=t?e:`${e.slice(0,t)}…`,s=(t,r={detail:n.DEFAULT_GRID_LOCALE_TEXT.detailColumnName,rowDrag:n.DEFAULT_GRID_LOCALE_TEXT.rowDragColumnName})=>{let i=[],o=new Map,s=0;for(let[n,a]of t.entries())i.push(s),e.isSyntheticColumnKey(a.key)&&(s+=1),a.key===`__ssg_group__`?o.set(n,a.title||a.key):a.key===`__ssg_detail_toggle__`?o.set(n,r.detail):a.key===`__ssg_row_drag_handle__`&&o.set(n,r.rowDrag);return s===0?a.toExcelColumnName:Object.assign(e=>a.toExcelColumnName(Math.max(e-(i[e]??s),0)),{cellNameOf:e=>o.get(e)})},c=(e,t,n)=>{let r=e.cellNameOf?.(t);return r===void 0?`${e(t)}${n}`:`${r} ${n}`},l=(e,t,n)=>{if(!e.cellNameOf)return!1;for(let r=t;r<=n;r+=1)if(e.cellNameOf(r)===void 0)return!1;return!0},u={numberOf:e=>e+1,lastNumberOf:e=>e+1,countRows:(e,t)=>t-e+1},d=e=>!e||e.length===0?u:{numberOf:t=>t-r.countLabelsBefore(e,t)+1,lastNumberOf:t=>t+1-r.countLabelsBefore(e,t+1),countRows:(t,n)=>n-t+1-(r.countLabelsBefore(e,n+1)-r.countLabelsBefore(e,t))},f=(e,t=a.toExcelColumnName,r=u,i=n.DEFAULT_GRID_LOCALE_TEXT)=>e?c(t,e.col,r.numberOf(e.row)):i.none,p=(e,t=a.toExcelColumnName,r=u,i=n.DEFAULT_GRID_LOCALE_TEXT)=>{if(!e)return i.none;if(e.type===`cell`){let n=Math.min(e.range.start.row,e.range.end.row),i=Math.max(e.range.start.row,e.range.end.row),a=Math.min(e.range.start.col,e.range.end.col),o=Math.max(e.range.start.col,e.range.end.col);if(n===i&&a===o)return c(t,a,r.numberOf(n));let s=a===o?t.cellNameOf?.(a):void 0;if(s!==void 0)return`${s} ${r.numberOf(n)}:${r.lastNumberOf(i)}`;if(l(t,a,o)){let e=t.cellNameOf?.(a)??``,s=t.cellNameOf?.(o)??``;return`${e} ${r.numberOf(n)}:${s} ${r.lastNumberOf(i)}`}let u=`${t(a)}${r.numberOf(n)}`,d=`${t(o)}${r.lastNumberOf(i)}`;return u===d?u:`${u}:${d}`}if(e.type===`row`){let t=Math.min(e.startRow,e.endRow),n=Math.max(e.startRow,e.endRow);return`${r.numberOf(t)}:${r.lastNumberOf(n)}`}let o=Math.min(e.startCol,e.endCol),s=Math.max(e.startCol,e.endCol);return`${t(o)}:${t(s)}`},m=(e,r,i=e.rows.length,a=n.DEFAULT_GRID_LOCALE_TEXT)=>t.formatLocaleText(a.rowCount,{shown:r,total:i}),h=t=>{let n=0;for(let r of t)e.isSyntheticColumnKey(r.key)||(n+=1);return n},g=(t,n,r)=>{let i=0;for(let a=n;a<=r;a+=1){let n=t[a];(!n||!e.isSyntheticColumnKey(n.key))&&(i+=1)}return i},_=(e,r=n.DEFAULT_GRID_LOCALE_TEXT)=>t.formatLocaleText(r.columnCount,{shown:h(e.visibleColumns),total:e.columns.length}),v=(e,t,n=u)=>{let r=e.selection;if(!r)return{selectedCellCount:0,selectedRowCount:0,selectedColumnCount:0};if(r.type===`cell`){let t=Math.min(r.range.start.row,r.range.end.row),i=Math.max(r.range.start.row,r.range.end.row),a=Math.min(r.range.start.col,r.range.end.col),o=Math.max(r.range.start.col,r.range.end.col),s=n.countRows(t,i),c=g(e.visibleColumns,a,o);return{selectedCellCount:s*c,selectedRowCount:s,selectedColumnCount:c}}if(r.type===`row`){let t=Math.min(r.startRow,r.endRow),i=Math.max(r.startRow,r.endRow),a=n.countRows(t,i),o=h(e.visibleColumns);return{selectedCellCount:a*o,selectedRowCount:a,selectedColumnCount:o}}let i=Math.min(r.startCol,r.endCol),a=Math.max(r.startCol,r.endCol),o=g(e.visibleColumns,i,a),s=t;return{selectedCellCount:s*o,selectedRowCount:s,selectedColumnCount:o}},y=(e,r,i=u,a=n.DEFAULT_GRID_LOCALE_TEXT)=>{let o=v(e,r,i);return t.formatLocaleText(a.selectionSize,{cells:o.selectedCellCount,rows:o.selectedRowCount})},b=e=>Object.values(e).filter(e=>i.isActiveColumnFilterValue(e)).length,x=(e,r=n.DEFAULT_GRID_LOCALE_TEXT)=>{let i=e.globalFilterText.trim(),a=b(e.columnFilterValues),s=[];return i.length>0&&s.push(t.formatLocaleText(r.filterGlobal,{text:o(i)})),a>0&&s.push(t.formatLocaleText(r.filterColumns,{count:a})),t.formatLocaleText(r.filterSummary,{value:s.length>0?s.join(` + `):r.none})},S=(e,t)=>{let n=e.find(e=>e.key===t);return n?.title||n?.key||t},C=(e,r=n.DEFAULT_GRID_LOCALE_TEXT)=>{let i=e.sortState.length===0?r.none:e.sortState.map(n=>t.formatLocaleText(r.sortEntry,{column:S(e.columns,n.columnKey),direction:n.direction===`asc`?r.sortAscending:r.sortDescending})).join(r.listSeparator);return t.formatLocaleText(r.sortSummary,{value:i})},w=(e,r,i,s=a.toExcelColumnName,c=u,l=n.DEFAULT_GRID_LOCALE_TEXT)=>{let d=v(e,r,c),h=e.globalFilterText.trim().length>0,g=h?o(e.globalFilterText.trim()):null,w=b(e.columnFilterValues),T=h||w>0,E=e.sortState.length>0,D=E?S(e.columns,e.sortState[0].columnKey):null;return{rowSummaryText:m(e,r,i,l),columnSummaryText:_(e,l),filterSummaryText:x(e,l),sortSummaryText:C(e,l),activeCellLabel:f(e.activeCell,s,c,l),selectionLabel:p(e.selection,s,c,l),selectionStatsText:y(e,r,c,l),selectedColumnsText:t.formatLocaleText(l.selectedColumns,{count:d.selectedColumnCount}),selectionStats:d,hasGlobalFilter:h,globalFilterPreview:g,activeColumnFilterCount:w,hasAnyFilter:T,hasSorting:E,sortedColumnLabel:D}};exports.buildGridDerivedSummary=w,exports.createDataColumnNamer=s,exports.createDataRowNumberer=d,exports.formatGridCellLabel=f,exports.formatGridColumnSummary=_,exports.formatGridFilterSummary=x,exports.formatGridRowSummary=m,exports.formatGridSelectionLabel=p,exports.formatGridSelectionStatsLabel=y,exports.formatGridSortSummary=C,exports.getGridSelectionStats=v;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { CellCoord, GridSelection, SpreadsheetGridSlotContext, SpreadsheetGridDerivedSummary, SpreadsheetGridSelectionStats } from '../model/gridTypes.unbound.js';
|
|
2
|
+
import { type ResolvedGridLocaleText } from './localeText.js';
|
|
3
|
+
export type GridColumnNamer = ((columnIndex: number) => string) & {
|
|
4
|
+
readonly cellNameOf?: (columnIndex: number) => string | undefined;
|
|
5
|
+
};
|
|
6
|
+
export declare const createDataColumnNamer: (orderedColumns: ReadonlyArray<{
|
|
7
|
+
key: string;
|
|
8
|
+
title?: string;
|
|
9
|
+
}>, names?: {
|
|
10
|
+
detail: string;
|
|
11
|
+
rowDrag: string;
|
|
12
|
+
}) => GridColumnNamer;
|
|
13
|
+
export type GridRowNumberer = {
|
|
14
|
+
numberOf: (viewRowIndex: number) => number;
|
|
15
|
+
lastNumberOf: (viewRowIndex: number) => number;
|
|
16
|
+
countRows: (startRow: number, endRow: number) => number;
|
|
17
|
+
};
|
|
18
|
+
export declare const createDataRowNumberer: (labelViewIndexes: ArrayLike<number> | undefined) => GridRowNumberer;
|
|
19
|
+
export declare const formatGridCellLabel: (cell: CellCoord | null, toColumnName?: GridColumnNamer, rowNumberer?: GridRowNumberer, texts?: ResolvedGridLocaleText) => string;
|
|
20
|
+
export declare const formatGridSelectionLabel: (selection: GridSelection, toColumnName?: GridColumnNamer, rowNumberer?: GridRowNumberer, texts?: ResolvedGridLocaleText) => string;
|
|
21
|
+
export declare const formatGridRowSummary: <T>(context: Pick<SpreadsheetGridSlotContext<T>, "rows">, filteredRowCount: number, totalRowCount?: number, texts?: ResolvedGridLocaleText) => string;
|
|
22
|
+
export declare const formatGridColumnSummary: <T>(context: Pick<SpreadsheetGridSlotContext<T>, "columns" | "visibleColumns">, texts?: ResolvedGridLocaleText) => string;
|
|
23
|
+
export declare const getGridSelectionStats: <T>(context: Pick<SpreadsheetGridSlotContext<T>, "selection" | "visibleColumns">, filteredRowCount: number, rowNumberer?: GridRowNumberer) => SpreadsheetGridSelectionStats;
|
|
24
|
+
export declare const formatGridSelectionStatsLabel: <T>(context: Pick<SpreadsheetGridSlotContext<T>, "selection" | "visibleColumns">, filteredRowCount: number, rowNumberer?: GridRowNumberer, texts?: ResolvedGridLocaleText) => string;
|
|
25
|
+
export declare const formatGridFilterSummary: <T>(context: Pick<SpreadsheetGridSlotContext<T>, "globalFilterText" | "columnFilterValues">, texts?: ResolvedGridLocaleText) => string;
|
|
26
|
+
export declare const formatGridSortSummary: <T>(context: Pick<SpreadsheetGridSlotContext<T>, "columns" | "sortState">, texts?: ResolvedGridLocaleText) => string;
|
|
27
|
+
export declare const buildGridDerivedSummary: <T>(context: Pick<SpreadsheetGridSlotContext<T>, "rows" | "columns" | "visibleColumns" | "globalFilterText" | "columnFilterValues" | "sortState" | "activeCell" | "selection">, filteredRowCount: number, totalRowCount?: number, toColumnName?: GridColumnNamer, rowNumberer?: GridRowNumberer, texts?: ResolvedGridLocaleText) => SpreadsheetGridDerivedSummary;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import "./grouping.js";
|
|
2
|
+
import "./rowReorder.js";
|
|
3
|
+
import { isSyntheticColumnKey as e } from "./detailRow.js";
|
|
4
|
+
import { formatLocaleText as t } from "./localeTextFilters.js";
|
|
5
|
+
import { DEFAULT_GRID_LOCALE_TEXT as n } from "./localeText.js";
|
|
6
|
+
import { countLabelsBefore as r } from "./labelRows.js";
|
|
7
|
+
import { isActiveColumnFilterValue as i } from "./filtering.js";
|
|
8
|
+
import { toExcelColumnName as a } from "../utils/excelColumnName.js";
|
|
9
|
+
//#region src/logic/gridBarSummary.ts
|
|
10
|
+
var o = (e, t = 16) => e.length <= t ? e : `${e.slice(0, t)}…`, s = (t, r = {
|
|
11
|
+
detail: n.detailColumnName,
|
|
12
|
+
rowDrag: n.rowDragColumnName
|
|
13
|
+
}) => {
|
|
14
|
+
let i = [], o = /* @__PURE__ */ new Map(), s = 0;
|
|
15
|
+
for (let [n, a] of t.entries()) i.push(s), e(a.key) && (s += 1), a.key === "__ssg_group__" ? o.set(n, a.title || a.key) : a.key === "__ssg_detail_toggle__" ? o.set(n, r.detail) : a.key === "__ssg_row_drag_handle__" && o.set(n, r.rowDrag);
|
|
16
|
+
return s === 0 ? a : Object.assign((e) => a(Math.max(e - (i[e] ?? s), 0)), { cellNameOf: (e) => o.get(e) });
|
|
17
|
+
}, c = (e, t, n) => {
|
|
18
|
+
let r = e.cellNameOf?.(t);
|
|
19
|
+
return r === void 0 ? `${e(t)}${n}` : `${r} ${n}`;
|
|
20
|
+
}, l = (e, t, n) => {
|
|
21
|
+
if (!e.cellNameOf) return !1;
|
|
22
|
+
for (let r = t; r <= n; r += 1) if (e.cellNameOf(r) === void 0) return !1;
|
|
23
|
+
return !0;
|
|
24
|
+
}, u = {
|
|
25
|
+
numberOf: (e) => e + 1,
|
|
26
|
+
lastNumberOf: (e) => e + 1,
|
|
27
|
+
countRows: (e, t) => t - e + 1
|
|
28
|
+
}, d = (e) => !e || e.length === 0 ? u : {
|
|
29
|
+
numberOf: (t) => t - r(e, t) + 1,
|
|
30
|
+
lastNumberOf: (t) => t + 1 - r(e, t + 1),
|
|
31
|
+
countRows: (t, n) => n - t + 1 - (r(e, n + 1) - r(e, t))
|
|
32
|
+
}, f = (e, t = a, r = u, i = n) => e ? c(t, e.col, r.numberOf(e.row)) : i.none, p = (e, t = a, r = u, i = n) => {
|
|
33
|
+
if (!e) return i.none;
|
|
34
|
+
if (e.type === "cell") {
|
|
35
|
+
let n = Math.min(e.range.start.row, e.range.end.row), i = Math.max(e.range.start.row, e.range.end.row), a = Math.min(e.range.start.col, e.range.end.col), o = Math.max(e.range.start.col, e.range.end.col);
|
|
36
|
+
if (n === i && a === o) return c(t, a, r.numberOf(n));
|
|
37
|
+
let s = a === o ? t.cellNameOf?.(a) : void 0;
|
|
38
|
+
if (s !== void 0) return `${s} ${r.numberOf(n)}:${r.lastNumberOf(i)}`;
|
|
39
|
+
if (l(t, a, o)) {
|
|
40
|
+
let e = t.cellNameOf?.(a) ?? "", s = t.cellNameOf?.(o) ?? "";
|
|
41
|
+
return `${e} ${r.numberOf(n)}:${s} ${r.lastNumberOf(i)}`;
|
|
42
|
+
}
|
|
43
|
+
let u = `${t(a)}${r.numberOf(n)}`, d = `${t(o)}${r.lastNumberOf(i)}`;
|
|
44
|
+
return u === d ? u : `${u}:${d}`;
|
|
45
|
+
}
|
|
46
|
+
if (e.type === "row") {
|
|
47
|
+
let t = Math.min(e.startRow, e.endRow), n = Math.max(e.startRow, e.endRow);
|
|
48
|
+
return `${r.numberOf(t)}:${r.lastNumberOf(n)}`;
|
|
49
|
+
}
|
|
50
|
+
let o = Math.min(e.startCol, e.endCol), s = Math.max(e.startCol, e.endCol);
|
|
51
|
+
return `${t(o)}:${t(s)}`;
|
|
52
|
+
}, m = (e, r, i = e.rows.length, a = n) => t(a.rowCount, {
|
|
53
|
+
shown: r,
|
|
54
|
+
total: i
|
|
55
|
+
}), h = (t) => {
|
|
56
|
+
let n = 0;
|
|
57
|
+
for (let r of t) e(r.key) || (n += 1);
|
|
58
|
+
return n;
|
|
59
|
+
}, g = (t, n, r) => {
|
|
60
|
+
let i = 0;
|
|
61
|
+
for (let a = n; a <= r; a += 1) {
|
|
62
|
+
let n = t[a];
|
|
63
|
+
(!n || !e(n.key)) && (i += 1);
|
|
64
|
+
}
|
|
65
|
+
return i;
|
|
66
|
+
}, _ = (e, r = n) => t(r.columnCount, {
|
|
67
|
+
shown: h(e.visibleColumns),
|
|
68
|
+
total: e.columns.length
|
|
69
|
+
}), v = (e, t, n = u) => {
|
|
70
|
+
let r = e.selection;
|
|
71
|
+
if (!r) return {
|
|
72
|
+
selectedCellCount: 0,
|
|
73
|
+
selectedRowCount: 0,
|
|
74
|
+
selectedColumnCount: 0
|
|
75
|
+
};
|
|
76
|
+
if (r.type === "cell") {
|
|
77
|
+
let t = Math.min(r.range.start.row, r.range.end.row), i = Math.max(r.range.start.row, r.range.end.row), a = Math.min(r.range.start.col, r.range.end.col), o = Math.max(r.range.start.col, r.range.end.col), s = n.countRows(t, i), c = g(e.visibleColumns, a, o);
|
|
78
|
+
return {
|
|
79
|
+
selectedCellCount: s * c,
|
|
80
|
+
selectedRowCount: s,
|
|
81
|
+
selectedColumnCount: c
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
if (r.type === "row") {
|
|
85
|
+
let t = Math.min(r.startRow, r.endRow), i = Math.max(r.startRow, r.endRow), a = n.countRows(t, i), o = h(e.visibleColumns);
|
|
86
|
+
return {
|
|
87
|
+
selectedCellCount: a * o,
|
|
88
|
+
selectedRowCount: a,
|
|
89
|
+
selectedColumnCount: o
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
let i = Math.min(r.startCol, r.endCol), a = Math.max(r.startCol, r.endCol), o = g(e.visibleColumns, i, a), s = t;
|
|
93
|
+
return {
|
|
94
|
+
selectedCellCount: s * o,
|
|
95
|
+
selectedRowCount: s,
|
|
96
|
+
selectedColumnCount: o
|
|
97
|
+
};
|
|
98
|
+
}, y = (e, r, i = u, a = n) => {
|
|
99
|
+
let o = v(e, r, i);
|
|
100
|
+
return t(a.selectionSize, {
|
|
101
|
+
cells: o.selectedCellCount,
|
|
102
|
+
rows: o.selectedRowCount
|
|
103
|
+
});
|
|
104
|
+
}, b = (e) => Object.values(e).filter((e) => i(e)).length, x = (e, r = n) => {
|
|
105
|
+
let i = e.globalFilterText.trim(), a = b(e.columnFilterValues), s = [];
|
|
106
|
+
return i.length > 0 && s.push(t(r.filterGlobal, { text: o(i) })), a > 0 && s.push(t(r.filterColumns, { count: a })), t(r.filterSummary, { value: s.length > 0 ? s.join(" + ") : r.none });
|
|
107
|
+
}, S = (e, t) => {
|
|
108
|
+
let n = e.find((e) => e.key === t);
|
|
109
|
+
return n?.title || n?.key || t;
|
|
110
|
+
}, C = (e, r = n) => {
|
|
111
|
+
let i = e.sortState.length === 0 ? r.none : e.sortState.map((n) => t(r.sortEntry, {
|
|
112
|
+
column: S(e.columns, n.columnKey),
|
|
113
|
+
direction: n.direction === "asc" ? r.sortAscending : r.sortDescending
|
|
114
|
+
})).join(r.listSeparator);
|
|
115
|
+
return t(r.sortSummary, { value: i });
|
|
116
|
+
}, w = (e, r, i, s = a, c = u, l = n) => {
|
|
117
|
+
let d = v(e, r, c), h = e.globalFilterText.trim().length > 0, g = h ? o(e.globalFilterText.trim()) : null, w = b(e.columnFilterValues), T = h || w > 0, E = e.sortState.length > 0, D = E ? S(e.columns, e.sortState[0].columnKey) : null;
|
|
118
|
+
return {
|
|
119
|
+
rowSummaryText: m(e, r, i, l),
|
|
120
|
+
columnSummaryText: _(e, l),
|
|
121
|
+
filterSummaryText: x(e, l),
|
|
122
|
+
sortSummaryText: C(e, l),
|
|
123
|
+
activeCellLabel: f(e.activeCell, s, c, l),
|
|
124
|
+
selectionLabel: p(e.selection, s, c, l),
|
|
125
|
+
selectionStatsText: y(e, r, c, l),
|
|
126
|
+
selectedColumnsText: t(l.selectedColumns, { count: d.selectedColumnCount }),
|
|
127
|
+
selectionStats: d,
|
|
128
|
+
hasGlobalFilter: h,
|
|
129
|
+
globalFilterPreview: g,
|
|
130
|
+
activeColumnFilterCount: w,
|
|
131
|
+
hasAnyFilter: T,
|
|
132
|
+
hasSorting: E,
|
|
133
|
+
sortedColumnLabel: D
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
//#endregion
|
|
137
|
+
export { w as buildGridDerivedSummary, s as createDataColumnNamer, d as createDataRowNumberer, f as formatGridCellLabel, _ as formatGridColumnSummary, x as formatGridFilterSummary, m as formatGridRowSummary, p as formatGridSelectionLabel, y as formatGridSelectionStatsLabel, C as formatGridSortSummary, v as getGridSelectionStats };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./editorKeys.cjs");var t=180,n=28,r=4,i=1,a=8,o=8,s=2,c=700,l=(e,t)=>{let n=String(t??``),r=e.findIndex(e=>e.value===n);return r>=0?r:0},u=(e,t,n)=>{if(n<=0)return 0;let r=e+t;return r<0?0:r>n-1?n-1:r},d=()=>({buffer:``,lastInputTime:0}),f=(e,t,n,r)=>{let i=(n-e.lastInputTime>700?``:e.buffer)+t.toLocaleLowerCase(),a=r.findIndex(e=>e.label.toLocaleLowerCase().startsWith(i));return{state:{buffer:i,lastInputTime:n},index:a>=0?a:null}},p=44,m=()=>typeof matchMedia==`function`&&matchMedia(`(pointer: coarse)`).matches?44:28,h=(e,t,n,r,i=28)=>{let c=Math.max(e.width,180),l=Math.max(o,n-c-o),u=Math.min(Math.max(e.left,o),l),d=Math.min(Math.max(t,1),a)*i+8+2,f=e.bottom+s;return{left:u,top:f+d<=r-o?f:Math.max(o,e.top-s-d),width:c,maxHeight:d}},g=/[\uFF01-\uFF5E]/g,_=e=>e.replace(g,e=>String.fromCharCode(e.charCodeAt(0)-65248)).replace(/\u3000/g,` `).toLocaleLowerCase(),v=(e,t)=>{let n=_(t).trim();if(n===``)return null;let r=e.map(e=>_(e.label)),i=r.findIndex(e=>e.startsWith(n));if(i>=0)return i;let a=r.findIndex(e=>e.includes(n));return a>=0?a:null},y=8,b=(t,n)=>{let{key:r}=t,i=n.optionCount;r===`ArrowDown`||r===`ArrowUp`||r===`Home`||r===`End`||r===`PageUp`||r===`PageDown`?(t.preventDefault(),(r===`ArrowDown`||r===`ArrowUp`||i>0)&&n.onMove(e=>x(r,e,i))):r===`Enter`||r===`Tab`?(t.preventDefault(),n.onCommit(r===`Enter`?e.resolveEnterDirection(n.enterMove):t.shiftKey?`left`:`right`)):r===`Escape`?(t.preventDefault(),n.onCancel()):r.length===1&&!t.ctrlKey&&!t.metaKey&&!t.altKey&&(t.preventDefault(),n.onTypeahead(r))},x=(e,t,n)=>e===`ArrowDown`||e===`ArrowUp`?u(t,e===`ArrowDown`?1:-1,n):e===`Home`||e===`End`?e===`Home`?0:n-1:Math.min(Math.max((t<0?0:t)+(e===`PageDown`?8:-8),0),n-1),S=(e,t,n,r)=>{let i=l(e,t);if(!n)return{highlight:i,typeahead:d()};let a=f(d(),n,r,e);return{highlight:a.index??i,typeahead:a.state}};exports.SELECT_OPTION_ROW_HEIGHT=n,exports.SELECT_OPTION_ROW_HEIGHT_COARSE=p,exports.SELECT_PAGE_STEP=y,exports.SELECT_POPOVER_BORDER_Y=i,exports.SELECT_POPOVER_MIN_WIDTH=t,exports.SELECT_POPOVER_PADDING_Y=r,exports.SELECT_TYPEAHEAD_RESET_MS=c,exports.computeSelectPopoverPlacement=h,exports.createTypeaheadState=d,exports.findOptionByComposedText=v,exports.handleSelectEditorKeyDown=b,exports.moveHighlight=u,exports.moveSelectHighlight=x,exports.resolveInitialHighlight=l,exports.resolveSelectEditorStart=S,exports.resolveSelectOptionRowHeight=m,exports.typeaheadJump=f;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GridSelectEditorOption } from '../model/gridTypes.unbound.js';
|
|
1
|
+
import type { EditorCommitDirection, EditorEnterMove, GridSelectEditorOption } from '../model/gridTypes.unbound.js';
|
|
2
2
|
export declare const SELECT_POPOVER_MIN_WIDTH = 180;
|
|
3
3
|
export declare const SELECT_OPTION_ROW_HEIGHT = 28;
|
|
4
4
|
export declare const SELECT_POPOVER_PADDING_Y = 4;
|
|
@@ -30,3 +30,26 @@ export declare const computeSelectPopoverPlacement: (anchorRect: {
|
|
|
30
30
|
width: number;
|
|
31
31
|
}, optionCount: number, viewportWidth: number, viewportHeight: number, rowHeight?: number) => SelectPopoverPlacement;
|
|
32
32
|
export declare const findOptionByComposedText: (options: GridSelectEditorOption[], text: string) => number | null;
|
|
33
|
+
export declare const SELECT_PAGE_STEP = 8;
|
|
34
|
+
export type SelectEditorKeyEventLike = {
|
|
35
|
+
key: string;
|
|
36
|
+
shiftKey: boolean;
|
|
37
|
+
ctrlKey: boolean;
|
|
38
|
+
metaKey: boolean;
|
|
39
|
+
altKey: boolean;
|
|
40
|
+
preventDefault: () => void;
|
|
41
|
+
};
|
|
42
|
+
export type SelectEditorKeyOptions = {
|
|
43
|
+
optionCount: number;
|
|
44
|
+
enterMove: EditorEnterMove | undefined;
|
|
45
|
+
onMove: (next: (current: number) => number) => void;
|
|
46
|
+
onCommit: (direction: EditorCommitDirection | undefined) => void;
|
|
47
|
+
onCancel: () => void;
|
|
48
|
+
onTypeahead: (key: string) => void;
|
|
49
|
+
};
|
|
50
|
+
export declare const handleSelectEditorKeyDown: (event: SelectEditorKeyEventLike, options: SelectEditorKeyOptions) => void;
|
|
51
|
+
export declare const moveSelectHighlight: (key: string, current: number, optionCount: number) => number;
|
|
52
|
+
export declare const resolveSelectEditorStart: (options: GridSelectEditorOption[], value: unknown, initialText: string | undefined, now: number) => {
|
|
53
|
+
highlight: number;
|
|
54
|
+
typeahead: SelectTypeaheadState;
|
|
55
|
+
};
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
import { resolveEnterDirection as e } from "./editorKeys.js";
|
|
1
2
|
//#region src/logic/selectEditorState.ts
|
|
2
|
-
var
|
|
3
|
+
var t = 180, n = 28, r = 4, i = 1, a = 8, o = 8, s = 2, c = 700, l = (e, t) => {
|
|
3
4
|
let n = String(t ?? ""), r = e.findIndex((e) => e.value === n);
|
|
4
5
|
return r >= 0 ? r : 0;
|
|
5
|
-
},
|
|
6
|
+
}, u = (e, t, n) => {
|
|
6
7
|
if (n <= 0) return 0;
|
|
7
8
|
let r = e + t;
|
|
8
9
|
return r < 0 ? 0 : r > n - 1 ? n - 1 : r;
|
|
9
|
-
},
|
|
10
|
+
}, d = () => ({
|
|
10
11
|
buffer: "",
|
|
11
12
|
lastInputTime: 0
|
|
12
|
-
}),
|
|
13
|
+
}), f = (e, t, n, r) => {
|
|
13
14
|
let i = (n - e.lastInputTime > 700 ? "" : e.buffer) + t.toLocaleLowerCase(), a = r.findIndex((e) => e.label.toLocaleLowerCase().startsWith(i));
|
|
14
15
|
return {
|
|
15
16
|
state: {
|
|
@@ -18,21 +19,35 @@ var e = 180, t = 28, n = 4, r = 1, i = 700, a = (e, t) => {
|
|
|
18
19
|
},
|
|
19
20
|
index: a >= 0 ? a : null
|
|
20
21
|
};
|
|
21
|
-
},
|
|
22
|
-
let
|
|
22
|
+
}, p = 44, m = () => typeof matchMedia == "function" && matchMedia("(pointer: coarse)").matches ? 44 : 28, h = (e, t, n, r, i = 28) => {
|
|
23
|
+
let c = Math.max(e.width, 180), l = Math.max(o, n - c - o), u = Math.min(Math.max(e.left, o), l), d = Math.min(Math.max(t, 1), a) * i + 8 + 2, f = e.bottom + s;
|
|
23
24
|
return {
|
|
24
|
-
left:
|
|
25
|
-
top:
|
|
26
|
-
width:
|
|
27
|
-
maxHeight:
|
|
25
|
+
left: u,
|
|
26
|
+
top: f + d <= r - o ? f : Math.max(o, e.top - s - d),
|
|
27
|
+
width: c,
|
|
28
|
+
maxHeight: d
|
|
28
29
|
};
|
|
29
|
-
},
|
|
30
|
-
let n =
|
|
30
|
+
}, g = /[\uFF01-\uFF5E]/g, _ = (e) => e.replace(g, (e) => String.fromCharCode(e.charCodeAt(0) - 65248)).replace(/\u3000/g, " ").toLocaleLowerCase(), v = (e, t) => {
|
|
31
|
+
let n = _(t).trim();
|
|
31
32
|
if (n === "") return null;
|
|
32
|
-
let r = e.map((e) =>
|
|
33
|
+
let r = e.map((e) => _(e.label)), i = r.findIndex((e) => e.startsWith(n));
|
|
33
34
|
if (i >= 0) return i;
|
|
34
35
|
let a = r.findIndex((e) => e.includes(n));
|
|
35
36
|
return a >= 0 ? a : null;
|
|
37
|
+
}, y = 8, b = (t, n) => {
|
|
38
|
+
let { key: r } = t, i = n.optionCount;
|
|
39
|
+
r === "ArrowDown" || r === "ArrowUp" || r === "Home" || r === "End" || r === "PageUp" || r === "PageDown" ? (t.preventDefault(), (r === "ArrowDown" || r === "ArrowUp" || i > 0) && n.onMove((e) => x(r, e, i))) : r === "Enter" || r === "Tab" ? (t.preventDefault(), n.onCommit(r === "Enter" ? e(n.enterMove) : t.shiftKey ? "left" : "right")) : r === "Escape" ? (t.preventDefault(), n.onCancel()) : r.length === 1 && !t.ctrlKey && !t.metaKey && !t.altKey && (t.preventDefault(), n.onTypeahead(r));
|
|
40
|
+
}, x = (e, t, n) => e === "ArrowDown" || e === "ArrowUp" ? u(t, e === "ArrowDown" ? 1 : -1, n) : e === "Home" || e === "End" ? e === "Home" ? 0 : n - 1 : Math.min(Math.max((t < 0 ? 0 : t) + (e === "PageDown" ? 8 : -8), 0), n - 1), S = (e, t, n, r) => {
|
|
41
|
+
let i = l(e, t);
|
|
42
|
+
if (!n) return {
|
|
43
|
+
highlight: i,
|
|
44
|
+
typeahead: d()
|
|
45
|
+
};
|
|
46
|
+
let a = f(d(), n, r, e);
|
|
47
|
+
return {
|
|
48
|
+
highlight: a.index ?? i,
|
|
49
|
+
typeahead: a.state
|
|
50
|
+
};
|
|
36
51
|
};
|
|
37
52
|
//#endregion
|
|
38
|
-
export {
|
|
53
|
+
export { n as SELECT_OPTION_ROW_HEIGHT, p as SELECT_OPTION_ROW_HEIGHT_COARSE, y as SELECT_PAGE_STEP, i as SELECT_POPOVER_BORDER_Y, t as SELECT_POPOVER_MIN_WIDTH, r as SELECT_POPOVER_PADDING_Y, c as SELECT_TYPEAHEAD_RESET_MS, h as computeSelectPopoverPlacement, d as createTypeaheadState, v as findOptionByComposedText, b as handleSelectEditorKeyDown, u as moveHighlight, x as moveSelectHighlight, l as resolveInitialHighlight, S as resolveSelectEditorStart, m as resolveSelectOptionRowHeight, f as typeaheadJump };
|
|
@@ -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 };
|
package/package.json
CHANGED