@visactor/vtable-search 1.22.4-alpha.2 → 1.22.4
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/cjs/search-component/search-component.d.ts +4 -0
- package/cjs/search-component/search-component.js +47 -19
- package/cjs/search-component/search-component.js.map +1 -1
- package/dist/vtable-export.js +76 -19
- package/dist/vtable-export.min.js +1 -1
- package/es/search-component/search-component.d.ts +4 -0
- package/es/search-component/search-component.js +45 -17
- package/es/search-component/search-component.js.map +1 -1
- package/package.json +4 -4
|
@@ -16,6 +16,7 @@ export type SearchComponentOption = {
|
|
|
16
16
|
skipHeader?: boolean;
|
|
17
17
|
highlightCellStyle?: VTable.TYPES.CellStyle;
|
|
18
18
|
focuseHighlightCellStyle?: VTable.TYPES.CellStyle;
|
|
19
|
+
focusHighlightCellStyle?: VTable.TYPES.CellStyle;
|
|
19
20
|
queryMethod?: (queryStr: string, value: string, option?: {
|
|
20
21
|
col: number;
|
|
21
22
|
row: number;
|
|
@@ -26,6 +27,7 @@ export type SearchComponentOption = {
|
|
|
26
27
|
}) => boolean;
|
|
27
28
|
fieldsToSearch?: string[];
|
|
28
29
|
scrollOption?: ITableAnimationOption;
|
|
30
|
+
enableViewportScroll?: boolean;
|
|
29
31
|
callback?: (queryResult: QueryResult, table: IVTable) => void;
|
|
30
32
|
};
|
|
31
33
|
export declare class SearchComponent {
|
|
@@ -34,6 +36,7 @@ export declare class SearchComponent {
|
|
|
34
36
|
autoJump: boolean;
|
|
35
37
|
highlightCellStyle: Partial<VTable.TYPES.CellStyle>;
|
|
36
38
|
focuseHighlightCellStyle: Partial<VTable.TYPES.CellStyle>;
|
|
39
|
+
focusHighlightCellStyle: Partial<VTable.TYPES.CellStyle>;
|
|
37
40
|
queryMethod: (queryStr: string, value: string, option: {
|
|
38
41
|
col: number;
|
|
39
42
|
row: number;
|
|
@@ -43,6 +46,7 @@ export declare class SearchComponent {
|
|
|
43
46
|
table: IVTable;
|
|
44
47
|
}) => boolean;
|
|
45
48
|
fieldsToSearch: string[];
|
|
49
|
+
enableViewportScroll?: boolean;
|
|
46
50
|
callback?: (queryResult: QueryResult, table: IVTable) => void;
|
|
47
51
|
queryStr: string;
|
|
48
52
|
queryResult: {
|
|
@@ -4,17 +4,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.SearchComponent = void 0;
|
|
6
6
|
|
|
7
|
-
const vutils_1 = require("@visactor/vutils"), HighlightStyleId = "__search_component_highlight",
|
|
7
|
+
const vutils_1 = require("@visactor/vutils"), HighlightStyleId = "__search_component_highlight", FocusHighlightStyleId = "__search_component_focus", defaultHighlightCellStyle = {
|
|
8
8
|
bgColor: "rgba(255, 255, 0, 0.2)"
|
|
9
|
-
},
|
|
9
|
+
}, defaultFocusHighlightCellStyle = {
|
|
10
10
|
bgColor: "rgba(255, 155, 0, 0.2)"
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
-
function
|
|
13
|
+
function defaultQueryMethod(queryStr, value) {
|
|
14
14
|
return (0, vutils_1.isValid)(queryStr) && (0, vutils_1.isValid)(value) && value.toString().includes(queryStr);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
function
|
|
17
|
+
function defaultTreeQueryMethod(queryStr, node, fieldsToSearch) {
|
|
18
18
|
if (!(0, vutils_1.isValid)(queryStr)) return !1;
|
|
19
19
|
return (Array.isArray(fieldsToSearch) && fieldsToSearch.length > 0 ? fieldsToSearch : Object.keys(node)).some((field => (0,
|
|
20
20
|
vutils_1.isValid)(null == node ? void 0 : node[field]) && node[field].toString().includes(queryStr)));
|
|
@@ -23,15 +23,15 @@ function defalultTreeQueryMethod(queryStr, node, fieldsToSearch) {
|
|
|
23
23
|
class SearchComponent {
|
|
24
24
|
constructor(option) {
|
|
25
25
|
this.table = option.table, this.autoJump = option.autoJump || !1, this.skipHeader = option.skipHeader || !1,
|
|
26
|
-
this.highlightCellStyle = option.highlightCellStyle ||
|
|
27
|
-
this.
|
|
28
|
-
this.queryMethod = option.queryMethod ||
|
|
26
|
+
this.highlightCellStyle = option.highlightCellStyle || defaultHighlightCellStyle,
|
|
27
|
+
this.focusHighlightCellStyle = option.focusHighlightCellStyle || option.focuseHighlightCellStyle || defaultFocusHighlightCellStyle,
|
|
28
|
+
this.queryMethod = option.queryMethod || defaultQueryMethod, this.treeQueryMethod = option.treeQueryMethod || defaultTreeQueryMethod,
|
|
29
29
|
this.fieldsToSearch = option.fieldsToSearch || [], this.isTree = !1, this.treeIndex = 0,
|
|
30
30
|
this.callback = option.callback, this.scrollOption = option.scrollOption || {
|
|
31
31
|
duration: 900,
|
|
32
32
|
easing: "quartIn"
|
|
33
|
-
}, this.table.registerCustomCellStyle(HighlightStyleId, this.highlightCellStyle),
|
|
34
|
-
this.table.registerCustomCellStyle(
|
|
33
|
+
}, this.enableViewportScroll = option.enableViewportScroll || !1, this.table.registerCustomCellStyle(HighlightStyleId, this.highlightCellStyle),
|
|
34
|
+
this.table.registerCustomCellStyle(FocusHighlightStyleId, this.focusHighlightCellStyle);
|
|
35
35
|
}
|
|
36
36
|
search(str) {
|
|
37
37
|
if (this.clear(), this.queryStr = str, !str) return {
|
|
@@ -118,7 +118,7 @@ class SearchComponent {
|
|
|
118
118
|
updateCellStyle(highlight = !0) {
|
|
119
119
|
if (highlight) {
|
|
120
120
|
if (this.queryResult) if (this.table.hasCustomCellStyle(HighlightStyleId) || this.table.registerCustomCellStyle(HighlightStyleId, this.highlightCellStyle),
|
|
121
|
-
this.table.hasCustomCellStyle(
|
|
121
|
+
this.table.hasCustomCellStyle(FocusHighlightStyleId) || this.table.registerCustomCellStyle(FocusHighlightStyleId, this.focusHighlightCellStyle),
|
|
122
122
|
this.isTree) {
|
|
123
123
|
const {range: range, indexNumber: indexNumber} = this.queryResult[0];
|
|
124
124
|
let i = 0;
|
|
@@ -126,7 +126,7 @@ class SearchComponent {
|
|
|
126
126
|
const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;
|
|
127
127
|
range.start.row = row, range.end.row = row, this.arrangeCustomCellStyle({
|
|
128
128
|
range: range
|
|
129
|
-
}, highlight,
|
|
129
|
+
}, highlight, FocusHighlightStyleId);
|
|
130
130
|
} else for (let i = 0; i < this.queryResult.length; i++) this.arrangeCustomCellStyle(this.queryResult[i], highlight);
|
|
131
131
|
} else (this.queryResult || []).forEach((resultItem => {
|
|
132
132
|
this.arrangeCustomCellStyle(resultItem, highlight);
|
|
@@ -159,13 +159,13 @@ class SearchComponent {
|
|
|
159
159
|
const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;
|
|
160
160
|
range.start.row = row, range.end.row = row, this.arrangeCustomCellStyle({
|
|
161
161
|
range: range
|
|
162
|
-
}, !0,
|
|
162
|
+
}, !0, FocusHighlightStyleId);
|
|
163
163
|
}
|
|
164
164
|
} else {
|
|
165
165
|
-1 !== this.currentIndex && this.arrangeCustomCellStyle(this.queryResult[this.currentIndex]),
|
|
166
166
|
this.currentIndex++, this.currentIndex >= this.queryResult.length && (this.currentIndex = 0);
|
|
167
167
|
const {col: col, row: row} = this.queryResult[this.currentIndex];
|
|
168
|
-
this.arrangeCustomCellStyle(this.queryResult[this.currentIndex], !0,
|
|
168
|
+
this.arrangeCustomCellStyle(this.queryResult[this.currentIndex], !0, FocusHighlightStyleId),
|
|
169
169
|
this.jumpToCell({
|
|
170
170
|
col: col,
|
|
171
171
|
row: row
|
|
@@ -203,13 +203,13 @@ class SearchComponent {
|
|
|
203
203
|
const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;
|
|
204
204
|
range.start.row = row, range.end.row = row, this.arrangeCustomCellStyle({
|
|
205
205
|
range: range
|
|
206
|
-
}, !0,
|
|
206
|
+
}, !0, FocusHighlightStyleId);
|
|
207
207
|
}
|
|
208
208
|
} else {
|
|
209
209
|
-1 !== this.currentIndex && this.arrangeCustomCellStyle(this.queryResult[this.currentIndex]),
|
|
210
210
|
this.currentIndex--, this.currentIndex < 0 && (this.currentIndex = this.queryResult.length - 1);
|
|
211
211
|
const {col: col, row: row} = this.queryResult[this.currentIndex];
|
|
212
|
-
this.arrangeCustomCellStyle(this.queryResult[this.currentIndex], !0,
|
|
212
|
+
this.arrangeCustomCellStyle(this.queryResult[this.currentIndex], !0, FocusHighlightStyleId),
|
|
213
213
|
this.jumpToCell({
|
|
214
214
|
col: col,
|
|
215
215
|
row: row
|
|
@@ -231,12 +231,19 @@ class SearchComponent {
|
|
|
231
231
|
const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;
|
|
232
232
|
"expand" !== this.table.getHierarchyState(this.treeIndex, row) && this.table.toggleHierarchyState(this.treeIndex, row);
|
|
233
233
|
}
|
|
234
|
-
this.
|
|
234
|
+
const finalRow = this.getBodyRowIndexByRecordIndex(indexNumbers) + i;
|
|
235
|
+
this.table.scrollToRow(finalRow, this.scrollOption), this.enableViewportScroll && scrollVTableCellIntoView(this.table, {
|
|
236
|
+
row: finalRow,
|
|
237
|
+
col: this.treeIndex
|
|
238
|
+
});
|
|
235
239
|
} else {
|
|
236
240
|
const {col: col, row: row} = params, {rowStart: rowStart, rowEnd: rowEnd} = this.table.getBodyVisibleRowRange(), {colStart: colStart, colEnd: colEnd} = this.table.getBodyVisibleColRange();
|
|
237
|
-
(row <= rowStart || row >= rowEnd || col <= colStart || col >= colEnd)
|
|
241
|
+
!(row <= rowStart || row >= rowEnd || col <= colStart || col >= colEnd) || this.table.scrollToCell({
|
|
238
242
|
col: col,
|
|
239
243
|
row: row
|
|
244
|
+
}), this.enableViewportScroll && scrollVTableCellIntoView(this.table, {
|
|
245
|
+
row: row,
|
|
246
|
+
col: col
|
|
240
247
|
});
|
|
241
248
|
}
|
|
242
249
|
}
|
|
@@ -248,5 +255,26 @@ class SearchComponent {
|
|
|
248
255
|
}
|
|
249
256
|
}
|
|
250
257
|
|
|
251
|
-
|
|
252
|
-
|
|
258
|
+
function scrollVTableCellIntoView(table, cellInfo) {
|
|
259
|
+
var _a, _b, _c;
|
|
260
|
+
if ("undefined" == typeof document || "undefined" == typeof window) return;
|
|
261
|
+
const tableEl = (null === (_a = table.getElement) || void 0 === _a ? void 0 : _a.call(table)) || table.container;
|
|
262
|
+
if (!tableEl) return;
|
|
263
|
+
const cellRect = table.getCellRect(cellInfo.col, cellInfo.row);
|
|
264
|
+
if (!cellRect) return;
|
|
265
|
+
let scrollContainer = tableEl.parentElement;
|
|
266
|
+
for (;scrollContainer; ) {
|
|
267
|
+
const computedStyle = getComputedStyle(scrollContainer), hasScroll = /(auto|scroll|overlay)/.test(computedStyle.overflowY), canScroll = scrollContainer.scrollHeight > scrollContainer.clientHeight;
|
|
268
|
+
if (hasScroll && canScroll) break;
|
|
269
|
+
scrollContainer = scrollContainer.parentElement || (null === (_c = null === (_b = scrollContainer.getRootNode) || void 0 === _b ? void 0 : _b.call(scrollContainer)) || void 0 === _c ? void 0 : _c.host) || null;
|
|
270
|
+
}
|
|
271
|
+
scrollContainer || (scrollContainer = document.scrollingElement || document.documentElement);
|
|
272
|
+
const scrollContainerEl = scrollContainer, tableRect = tableEl.getBoundingClientRect(), containerRect = scrollContainerEl.getBoundingClientRect(), cellTop = tableRect.top - containerRect.top + scrollContainerEl.scrollTop + cellRect.top, cellBottom = cellTop + cellRect.height, containerHeight = scrollContainerEl.clientHeight, scrollTop = scrollContainerEl.scrollTop;
|
|
273
|
+
if (!(cellTop >= scrollTop && cellBottom <= scrollTop + containerHeight)) {
|
|
274
|
+
let newScrollTop;
|
|
275
|
+
newScrollTop = cellTop < scrollTop ? cellTop : cellBottom - containerHeight, scrollContainerEl.scrollTop = Math.max(0, newScrollTop);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
//# sourceMappingURL=search-component.js.map
|
|
280
|
+
exports.SearchComponent = SearchComponent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["search-component/search-component.ts"],"names":[],"mappings":";;;AAGA,6CAA2C;AA0B3C,MAAM,gBAAgB,GAAG,8BAA8B,CAAC;AACx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C,4BAA4B,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;SAChG;aAAM;YACL,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC;YAE5B,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,sBAAsB,EAAE,CAAC;YACjE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,sBAAsB,EAAE,CAAC;YACjE,IAAI,GAAG,IAAI,QAAQ,IAAI,GAAG,IAAI,MAAM,IAAI,GAAG,IAAI,QAAQ,IAAI,GAAG,IAAI,MAAM,EAAE;gBACxE,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;aACvC;SACF;IACH,CAAC;IACD,4BAA4B,CAAC,KAAwB;QACnD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;YAC9C,KAAK,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;SAClB;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACpD,CAAC;IACD,KAAK;QAEH,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QAC5B,IAAI,CAAC,QAAQ,GAAG,EAAE,CAAC;QACnB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC;IACzB,CAAC;CACF;AAjaD,0CAiaC","file":"search-component.js","sourcesContent":["import type * as VTable from '@visactor/vtable';\nimport type { ITableAnimationOption } from '@visactor/vtable/src/ts-types';\nimport type { EasingType } from '@visactor/vtable/src/vrender';\nimport { isValid } from '@visactor/vutils';\ntype IVTable = VTable.ListTable | VTable.PivotTable | VTable.PivotChart;\n\nexport type QueryResult = {\n queryStr: string;\n results: {\n col?: number;\n row?: number;\n value?: string;\n indexNumber?: number[];\n }[];\n};\n\nexport type SearchComponentOption = {\n table: IVTable;\n autoJump?: boolean;\n skipHeader?: boolean;\n highlightCellStyle?: VTable.TYPES.CellStyle;\n focuseHighlightCellStyle?: VTable.TYPES.CellStyle;\n queryMethod?: (queryStr: string, value: string, option?: { col: number; row: number; table: IVTable }) => boolean;\n treeQueryMethod?: (queryStr: string, node: any, fieldsToSearch?: string[], option?: { table: IVTable }) => boolean;\n fieldsToSearch?: string[];\n scrollOption?: ITableAnimationOption;\n callback?: (queryResult: QueryResult, table: IVTable) => void;\n};\n\nconst HighlightStyleId = '__search_component_highlight';\nconst FocuseHighlightStyleId = '__search_component_focuse';\n\nconst defalutHightlightCellStyle: Partial<VTable.TYPES.CellStyle> = {\n bgColor: 'rgba(255, 255, 0, 0.2)'\n};\n\nconst defalutFocusHightlightCellStyle: Partial<VTable.TYPES.CellStyle> = {\n bgColor: 'rgba(255, 155, 0, 0.2)'\n};\n\nfunction defalultQueryMethod(queryStr: string, value: string) {\n return isValid(queryStr) && isValid(value) && value.toString().includes(queryStr);\n}\nfunction defalultTreeQueryMethod(queryStr: string, node: any, fieldsToSearch?: string[]) {\n if (!isValid(queryStr)) {\n return false;\n }\n\n // 如果没有传 fieldsToSearch,则用 node 的全部 key\n const searchFields = Array.isArray(fieldsToSearch) && fieldsToSearch.length > 0 ? fieldsToSearch : Object.keys(node);\n\n return searchFields.some(field => isValid(node?.[field]) && node[field].toString().includes(queryStr));\n}\nexport class SearchComponent {\n table: IVTable;\n skipHeader: boolean;\n autoJump: boolean;\n highlightCellStyle: Partial<VTable.TYPES.CellStyle>;\n focuseHighlightCellStyle: Partial<VTable.TYPES.CellStyle>;\n queryMethod: (queryStr: string, value: string, option: { col: number; row: number; table: IVTable }) => boolean;\n treeQueryMethod: (queryStr: string, node: any, fieldsToSearch?: string[], option?: { table: IVTable }) => boolean;\n fieldsToSearch: string[];\n\n callback?: (queryResult: QueryResult, table: IVTable) => void;\n\n queryStr: string;\n queryResult: {\n col?: number;\n row?: number;\n range?: VTable.TYPES.CellRange;\n value?: string;\n indexNumber?: number[];\n }[];\n\n currentIndex: number;\n isTree: boolean;\n treeIndex: number;\n scrollOption: ITableAnimationOption;\n\n constructor(option: SearchComponentOption) {\n this.table = option.table;\n this.autoJump = option.autoJump || false;\n this.skipHeader = option.skipHeader || false;\n this.highlightCellStyle = option.highlightCellStyle || defalutHightlightCellStyle;\n this.focuseHighlightCellStyle = option.focuseHighlightCellStyle || defalutFocusHightlightCellStyle;\n this.queryMethod = option.queryMethod || defalultQueryMethod;\n this.treeQueryMethod = option.treeQueryMethod || defalultTreeQueryMethod;\n this.fieldsToSearch = option.fieldsToSearch || [];\n this.isTree = false;\n this.treeIndex = 0;\n this.callback = option.callback;\n this.scrollOption =\n option.scrollOption || ({ duration: 900, easing: 'quartIn' as EasingType } as ITableAnimationOption);\n this.table.registerCustomCellStyle(HighlightStyleId, this.highlightCellStyle as any);\n this.table.registerCustomCellStyle(FocuseHighlightStyleId, this.focuseHighlightCellStyle as any);\n }\n\n search(str: string) {\n this.clear();\n this.queryStr = str;\n\n if (!str) {\n return {\n index: 0,\n results: this.queryResult\n };\n }\n this.isTree = this.table.options.columns.some((item: any) => item.tree);\n this.treeIndex = this.isTree ? this.table.options.columns.findIndex((item: any) => item.tree) : 0;\n if (this.isTree) {\n // 如果传入单一节点也能处理\n const colEnd = this.table.colCount;\n const walk = (nodes: any[], path: number[]) => {\n nodes.forEach((item: any, idx: number) => {\n const currentPath = [...path, idx]; // 当前节点的完整路径\n\n // 保持你的 treeQueryMethod 调用方式(this 上下文来自定义环境)\n if (this.treeQueryMethod(this.queryStr, item, this.fieldsToSearch, { table: this.table })) {\n this.queryResult.push({\n indexNumber: currentPath,\n range: {\n start: { row: null, col: 0 },\n end: { row: null, col: colEnd }\n }\n });\n }\n\n if (item.children && Array.isArray(item.children) && item.children.length > 0) {\n walk(item.children, currentPath);\n }\n });\n };\n\n walk(this.table.records, []);\n if (this.queryResult.length > 0) {\n this.jumpToCell({ IndexNumber: this.queryResult[0].indexNumber });\n }\n\n if (this.callback) {\n this.callback(\n {\n queryStr: this.queryStr,\n results: this.queryResult\n },\n this.table\n );\n }\n this.updateCellStyle();\n\n // if (this.autoJump) {\n // return this.next();\n // }\n this.currentIndex = 0;\n\n return {\n index: 0,\n results: this.queryResult\n };\n }\n for (let row = 0; row < this.table.rowCount; row++) {\n for (let col = 0; col < this.table.colCount; col++) {\n if (this.skipHeader && this.table.isHeader(col, row)) {\n continue;\n }\n const value = this.table.getCellValue(col, row);\n if (this.queryMethod(this.queryStr, value, { col, row, table: this.table })) {\n // deal merge cell\n const mergeCell = this.table.getCellRange(col, row);\n if (mergeCell.start.col !== mergeCell.end.col || mergeCell.start.row !== mergeCell.end.row) {\n // find is cell already in queryResult\n let isIn = false;\n for (let i = this.queryResult.length - 1; i >= 0; i--) {\n if (this.queryResult[i].col === mergeCell.start.col && this.queryResult[i].row === mergeCell.start.row) {\n isIn = true;\n break;\n }\n }\n if (!isIn) {\n this.queryResult.push({\n col: mergeCell.start.col,\n row: mergeCell.start.row,\n range: mergeCell,\n value\n });\n }\n } else {\n this.queryResult.push({\n col,\n row,\n value\n });\n }\n }\n }\n }\n this.updateCellStyle();\n\n if (this.callback) {\n this.callback(\n {\n queryStr: this.queryStr,\n results: this.queryResult\n },\n this.table\n );\n }\n\n if (this.autoJump) {\n return this.next();\n }\n return {\n index: 0,\n results: this.queryResult\n };\n }\n\n /**\n * @description: 为查询结果项设置自定义单元格样式\n * @param {(typeof this.queryResult)[number]} resultItem 查询结果项\n * @param {boolean} highlight 是否高亮\n * @param {string} customStyleId 自定义样式ID\n */\n arrangeCustomCellStyle(\n resultItem: (typeof this.queryResult)[number],\n highlight: boolean = true,\n customStyleId: string = HighlightStyleId\n ) {\n const { col, row, range } = resultItem;\n this.table.arrangeCustomCellStyle(\n range\n ? { range }\n : {\n row,\n col\n },\n highlight ? customStyleId : null\n );\n }\n\n updateCellStyle(highlight: boolean = true) {\n if (!highlight) {\n (this.queryResult || []).forEach(resultItem => {\n this.arrangeCustomCellStyle(resultItem, highlight);\n });\n return;\n }\n if (!this.queryResult) {\n return;\n }\n\n if (!this.table.hasCustomCellStyle(HighlightStyleId)) {\n this.table.registerCustomCellStyle(HighlightStyleId, this.highlightCellStyle as any);\n }\n if (!this.table.hasCustomCellStyle(FocuseHighlightStyleId)) {\n this.table.registerCustomCellStyle(FocuseHighlightStyleId, this.focuseHighlightCellStyle as any);\n }\n if (this.isTree) {\n const { range, indexNumber } = this.queryResult[0];\n\n let i = 0;\n\n // 如果是表头就往下偏移\n while (this.table.isHeader(0, i)) {\n i++;\n }\n const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;\n range.start.row = row;\n range.end.row = row;\n\n this.arrangeCustomCellStyle(\n {\n range\n },\n highlight,\n FocuseHighlightStyleId\n );\n } else {\n for (let i = 0; i < this.queryResult.length; i++) {\n this.arrangeCustomCellStyle(this.queryResult[i], highlight);\n }\n }\n }\n\n next() {\n if (!this.queryResult.length) {\n return {\n index: 0,\n results: this.queryResult\n };\n }\n if (this.isTree) {\n if (this.currentIndex !== -1) {\n const { range, indexNumber } = this.queryResult[this.currentIndex];\n\n if (range) {\n let i = 0;\n\n // 如果是表头就往下偏移\n while (this.table.isHeader(0, i)) {\n i++;\n }\n const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;\n range.start.row = row;\n range.end.row = row;\n this.arrangeCustomCellStyle({ range });\n }\n }\n\n this.currentIndex++;\n if (this.currentIndex >= this.queryResult.length) {\n this.currentIndex = 0;\n }\n const { range, indexNumber } = this.queryResult[this.currentIndex];\n this.jumpToCell({ IndexNumber: indexNumber });\n\n if (range) {\n let i = 0;\n\n // 如果是表头就往下偏移\n while (this.table.isHeader(0, i)) {\n i++;\n }\n const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;\n range.start.row = row;\n range.end.row = row;\n this.arrangeCustomCellStyle(\n {\n range\n },\n true,\n FocuseHighlightStyleId\n );\n }\n } else {\n if (this.currentIndex !== -1) {\n // reset last focus\n this.arrangeCustomCellStyle(this.queryResult[this.currentIndex]);\n }\n this.currentIndex++;\n if (this.currentIndex >= this.queryResult.length) {\n this.currentIndex = 0;\n }\n const { col, row } = this.queryResult[this.currentIndex];\n\n this.arrangeCustomCellStyle(this.queryResult[this.currentIndex], true, FocuseHighlightStyleId);\n\n this.jumpToCell({ col, row });\n }\n\n return {\n index: this.currentIndex,\n results: this.queryResult\n };\n }\n\n prev() {\n if (!this.queryResult.length) {\n return {\n index: 0,\n results: this.queryResult\n };\n }\n\n if (this.isTree) {\n // 先取消当前高亮\n if (this.currentIndex !== -1) {\n const { range, indexNumber } = this.queryResult[this.currentIndex];\n if (range) {\n let i = 0;\n while (this.table.isHeader(0, i)) {\n i++;\n }\n const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;\n range.start.row = row;\n range.end.row = row;\n this.arrangeCustomCellStyle({ range });\n }\n }\n\n // 索引向前\n this.currentIndex--;\n if (this.currentIndex < 0) {\n this.currentIndex = this.queryResult.length - 1;\n }\n\n // 焦点样式\n const { range, indexNumber } = this.queryResult[this.currentIndex];\n this.jumpToCell({ IndexNumber: indexNumber });\n\n if (range) {\n let i = 0;\n while (this.table.isHeader(0, i)) {\n i++;\n }\n const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;\n range.start.row = row;\n range.end.row = row;\n this.arrangeCustomCellStyle({ range }, true, FocuseHighlightStyleId);\n }\n } else {\n // 普通表格处理\n if (this.currentIndex !== -1) {\n this.arrangeCustomCellStyle(this.queryResult[this.currentIndex]);\n }\n\n this.currentIndex--;\n if (this.currentIndex < 0) {\n this.currentIndex = this.queryResult.length - 1;\n }\n\n const { col, row } = this.queryResult[this.currentIndex];\n this.arrangeCustomCellStyle(this.queryResult[this.currentIndex], true, FocuseHighlightStyleId);\n this.jumpToCell({ col, row });\n }\n\n return {\n index: this.currentIndex,\n results: this.queryResult\n };\n }\n\n jumpToCell(params: { col?: number; row?: number; IndexNumber?: number[] }) {\n if (this.isTree) {\n const { IndexNumber } = params;\n const indexNumbers = [...IndexNumber];\n\n const tmp = [...indexNumbers];\n let tmpNumber = 0;\n let i = 0;\n\n while (tmpNumber < tmp.length - 1) {\n tmpNumber++;\n const indexNumber = indexNumbers.slice(0, tmpNumber);\n\n // 如果是表头就往下偏移\n while (this.table.isHeader(0, i)) {\n i++;\n }\n const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;\n\n const hierarchyState = this.table.getHierarchyState(this.treeIndex, row);\n\n if (hierarchyState !== 'expand') {\n this.table.toggleHierarchyState(this.treeIndex, row);\n }\n }\n this.table.scrollToRow(this.getBodyRowIndexByRecordIndex(indexNumbers) + i, this.scrollOption);\n } else {\n const { col, row } = params;\n // if focus cell out of screen, jump to cell\n const { rowStart, rowEnd } = this.table.getBodyVisibleRowRange();\n const { colStart, colEnd } = this.table.getBodyVisibleColRange();\n if (row <= rowStart || row >= rowEnd || col <= colStart || col >= colEnd) {\n this.table.scrollToCell({ col, row });\n }\n }\n }\n getBodyRowIndexByRecordIndex(index: number | number[]): number {\n if (Array.isArray(index) && index.length === 1) {\n index = index[0];\n }\n return this.table.dataSource.getTableIndex(index);\n }\n clear() {\n // reset highlight cell style\n this.updateCellStyle(false);\n this.queryStr = '';\n this.queryResult = [];\n this.currentIndex = -1;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["search-component/search-component.ts"],"names":[],"mappings":";;;AAGA,6CAA2C;AAmC3C,MAAM,gBAAgB,GAAG,8BAA8B,CAAC;AACxD,MAAM,qBAAqB,GAAG,0BAA0B,CAAC;AAEzD,MAAM,yBAAyB,GAAoC;IACjE,OAAO,EAAE,wBAAwB;CAClC,CAAC;AAEF,MAAM,8BAA8B,GAAoC;IACtE,OAAO,EAAE,wBAAwB;CAClC,CAAC;AAEF,SAAS,kBAAkB,CAAC,QAAgB,EAAE,KAAa;IACzD,OAAO,IAAA,gBAA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MAAM,cAAc,GAAG,SAAS,CAAC,GAAG,GAAG,aAAa,CAAC,GAAG,GAAG,iBAAiB,CAAC,SAAS,CAAC;IAGvF,MAAM,OAAO,GAAG,cAAc,GAAG,QAAQ,CAAC,GAAG,CAAC;IAC9C,MAAM,UAAU,GAAG,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC;IAC7C,MAAM,eAAe,GAAG,iBAAiB,CAAC,YAAY,CAAC;IACvD,MAAM,SAAS,GAAG,iBAAiB,CAAC,SAAS,CAAC;IAG9C,MAAM,cAAc,GAAG,OAAO,IAAI,SAAS,IAAI,UAAU,IAAI,SAAS,GAAG,eAAe,CAAC;IAEzF,IAAI,CAAC,cAAc,EAAE;QAEnB,IAAI,YAAoB,CAAC;QAEzB,IAAI,OAAO,GAAG,SAAS,EAAE;YAEvB,YAAY,GAAG,OAAO,CAAC;SACxB;aAAM;YAEL,YAAY,GAAG,UAAU,GAAG,eAAe,CAAC;SAC7C;QAGD,iBAAiB,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;KACzD;AACH,CAAC","file":"search-component.js","sourcesContent":["import type * as VTable from '@visactor/vtable';\nimport type { ITableAnimationOption } from '@visactor/vtable/src/ts-types';\nimport type { EasingType } from '@visactor/vtable/src/vrender';\nimport { isValid } from '@visactor/vutils';\ntype IVTable = VTable.ListTable | VTable.PivotTable | VTable.PivotChart;\n\nexport type QueryResult = {\n queryStr: string;\n results: {\n col?: number;\n row?: number;\n value?: string;\n indexNumber?: number[];\n }[];\n};\n\nexport type SearchComponentOption = {\n table: IVTable;\n autoJump?: boolean;\n skipHeader?: boolean;\n highlightCellStyle?: VTable.TYPES.CellStyle;\n /**\n * @deprecated use focusHighlightCellStyle instead\n */\n focuseHighlightCellStyle?: VTable.TYPES.CellStyle;\n focusHighlightCellStyle?: VTable.TYPES.CellStyle;\n queryMethod?: (queryStr: string, value: string, option?: { col: number; row: number; table: IVTable }) => boolean;\n treeQueryMethod?: (queryStr: string, node: any, fieldsToSearch?: string[], option?: { table: IVTable }) => boolean;\n fieldsToSearch?: string[];\n scrollOption?: ITableAnimationOption;\n /**\n * 当开启时,搜索结果会自动滚动到视口范围内\n * @since 1.22.4\n */\n enableViewportScroll?: boolean;\n callback?: (queryResult: QueryResult, table: IVTable) => void;\n};\n\nconst HighlightStyleId = '__search_component_highlight';\nconst FocusHighlightStyleId = '__search_component_focus';\n\nconst defaultHighlightCellStyle: Partial<VTable.TYPES.CellStyle> = {\n bgColor: 'rgba(255, 255, 0, 0.2)'\n};\n\nconst defaultFocusHighlightCellStyle: Partial<VTable.TYPES.CellStyle> = {\n bgColor: 'rgba(255, 155, 0, 0.2)'\n};\n\nfunction defaultQueryMethod(queryStr: string, value: string) {\n return isValid(queryStr) && isValid(value) && value.toString().includes(queryStr);\n}\nfunction defaultTreeQueryMethod(queryStr: string, node: any, fieldsToSearch?: string[]) {\n if (!isValid(queryStr)) {\n return false;\n }\n\n // 如果没有传 fieldsToSearch,则用 node 的全部 key\n const searchFields = Array.isArray(fieldsToSearch) && fieldsToSearch.length > 0 ? fieldsToSearch : Object.keys(node);\n\n return searchFields.some(field => isValid(node?.[field]) && node[field].toString().includes(queryStr));\n}\nexport class SearchComponent {\n table: IVTable;\n skipHeader: boolean;\n autoJump: boolean;\n highlightCellStyle: Partial<VTable.TYPES.CellStyle>;\n focuseHighlightCellStyle: Partial<VTable.TYPES.CellStyle>;\n focusHighlightCellStyle: Partial<VTable.TYPES.CellStyle>;\n queryMethod: (queryStr: string, value: string, option: { col: number; row: number; table: IVTable }) => boolean;\n treeQueryMethod: (queryStr: string, node: any, fieldsToSearch?: string[], option?: { table: IVTable }) => boolean;\n fieldsToSearch: string[];\n enableViewportScroll?: boolean;\n callback?: (queryResult: QueryResult, table: IVTable) => void;\n\n queryStr: string;\n queryResult: {\n col?: number;\n row?: number;\n range?: VTable.TYPES.CellRange;\n value?: string;\n indexNumber?: number[];\n }[];\n\n currentIndex: number;\n isTree: boolean;\n treeIndex: number;\n scrollOption: ITableAnimationOption;\n\n constructor(option: SearchComponentOption) {\n this.table = option.table;\n this.autoJump = option.autoJump || false;\n this.skipHeader = option.skipHeader || false;\n this.highlightCellStyle = option.highlightCellStyle || defaultHighlightCellStyle;\n this.focusHighlightCellStyle =\n // 兼容兜底处理,修复拼写错误的问题\n option.focusHighlightCellStyle || option.focuseHighlightCellStyle || defaultFocusHighlightCellStyle;\n this.queryMethod = option.queryMethod || defaultQueryMethod;\n this.treeQueryMethod = option.treeQueryMethod || defaultTreeQueryMethod;\n this.fieldsToSearch = option.fieldsToSearch || [];\n this.isTree = false;\n this.treeIndex = 0;\n this.callback = option.callback;\n this.scrollOption =\n option.scrollOption || ({ duration: 900, easing: 'quartIn' as EasingType } as ITableAnimationOption);\n this.enableViewportScroll = option.enableViewportScroll || false;\n this.table.registerCustomCellStyle(HighlightStyleId, this.highlightCellStyle as any);\n this.table.registerCustomCellStyle(FocusHighlightStyleId, this.focusHighlightCellStyle as any);\n }\n\n search(str: string) {\n this.clear();\n this.queryStr = str;\n\n if (!str) {\n return {\n index: 0,\n results: this.queryResult\n };\n }\n this.isTree = this.table.options.columns.some((item: any) => item.tree);\n this.treeIndex = this.isTree ? this.table.options.columns.findIndex((item: any) => item.tree) : 0;\n if (this.isTree) {\n // 如果传入单一节点也能处理\n const colEnd = this.table.colCount;\n const walk = (nodes: any[], path: number[]) => {\n nodes.forEach((item: any, idx: number) => {\n const currentPath = [...path, idx]; // 当前节点的完整路径\n\n // 保持你的 treeQueryMethod 调用方式(this 上下文来自定义环境)\n if (this.treeQueryMethod(this.queryStr, item, this.fieldsToSearch, { table: this.table })) {\n this.queryResult.push({\n indexNumber: currentPath,\n range: {\n start: { row: null, col: 0 },\n end: { row: null, col: colEnd }\n }\n });\n }\n\n if (item.children && Array.isArray(item.children) && item.children.length > 0) {\n walk(item.children, currentPath);\n }\n });\n };\n\n walk(this.table.records, []);\n if (this.queryResult.length > 0) {\n this.jumpToCell({ IndexNumber: this.queryResult[0].indexNumber });\n }\n\n if (this.callback) {\n this.callback(\n {\n queryStr: this.queryStr,\n results: this.queryResult\n },\n this.table\n );\n }\n this.updateCellStyle();\n\n // if (this.autoJump) {\n // return this.next();\n // }\n this.currentIndex = 0;\n\n return {\n index: 0,\n results: this.queryResult\n };\n }\n for (let row = 0; row < this.table.rowCount; row++) {\n for (let col = 0; col < this.table.colCount; col++) {\n if (this.skipHeader && this.table.isHeader(col, row)) {\n continue;\n }\n const value = this.table.getCellValue(col, row);\n if (this.queryMethod(this.queryStr, value, { col, row, table: this.table })) {\n // deal merge cell\n const mergeCell = this.table.getCellRange(col, row);\n if (mergeCell.start.col !== mergeCell.end.col || mergeCell.start.row !== mergeCell.end.row) {\n // find is cell already in queryResult\n let isIn = false;\n for (let i = this.queryResult.length - 1; i >= 0; i--) {\n if (this.queryResult[i].col === mergeCell.start.col && this.queryResult[i].row === mergeCell.start.row) {\n isIn = true;\n break;\n }\n }\n if (!isIn) {\n this.queryResult.push({\n col: mergeCell.start.col,\n row: mergeCell.start.row,\n range: mergeCell,\n value\n });\n }\n } else {\n this.queryResult.push({\n col,\n row,\n value\n });\n }\n }\n }\n }\n this.updateCellStyle();\n\n if (this.callback) {\n this.callback(\n {\n queryStr: this.queryStr,\n results: this.queryResult\n },\n this.table\n );\n }\n\n if (this.autoJump) {\n return this.next();\n }\n return {\n index: 0,\n results: this.queryResult\n };\n }\n\n /**\n * @description: 为查询结果项设置自定义单元格样式\n * @param {(typeof this.queryResult)[number]} resultItem 查询结果项\n * @param {boolean} highlight 是否高亮\n * @param {string} customStyleId 自定义样式ID\n */\n arrangeCustomCellStyle(\n resultItem: (typeof this.queryResult)[number],\n highlight: boolean = true,\n customStyleId: string = HighlightStyleId\n ) {\n const { col, row, range } = resultItem;\n this.table.arrangeCustomCellStyle(\n range\n ? { range }\n : {\n row,\n col\n },\n highlight ? customStyleId : null\n );\n }\n\n updateCellStyle(highlight: boolean = true) {\n if (!highlight) {\n (this.queryResult || []).forEach(resultItem => {\n this.arrangeCustomCellStyle(resultItem, highlight);\n });\n return;\n }\n if (!this.queryResult) {\n return;\n }\n\n if (!this.table.hasCustomCellStyle(HighlightStyleId)) {\n this.table.registerCustomCellStyle(HighlightStyleId, this.highlightCellStyle as any);\n }\n if (!this.table.hasCustomCellStyle(FocusHighlightStyleId)) {\n this.table.registerCustomCellStyle(FocusHighlightStyleId, this.focusHighlightCellStyle as any);\n }\n if (this.isTree) {\n const { range, indexNumber } = this.queryResult[0];\n\n let i = 0;\n\n // 如果是表头就往下偏移\n while (this.table.isHeader(0, i)) {\n i++;\n }\n const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;\n range.start.row = row;\n range.end.row = row;\n\n this.arrangeCustomCellStyle(\n {\n range\n },\n highlight,\n FocusHighlightStyleId\n );\n } else {\n for (let i = 0; i < this.queryResult.length; i++) {\n this.arrangeCustomCellStyle(this.queryResult[i], highlight);\n }\n }\n }\n\n next() {\n if (!this.queryResult.length) {\n return {\n index: 0,\n results: this.queryResult\n };\n }\n if (this.isTree) {\n if (this.currentIndex !== -1) {\n const { range, indexNumber } = this.queryResult[this.currentIndex];\n\n if (range) {\n let i = 0;\n\n // 如果是表头就往下偏移\n while (this.table.isHeader(0, i)) {\n i++;\n }\n const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;\n range.start.row = row;\n range.end.row = row;\n this.arrangeCustomCellStyle({ range });\n }\n }\n\n this.currentIndex++;\n if (this.currentIndex >= this.queryResult.length) {\n this.currentIndex = 0;\n }\n const { range, indexNumber } = this.queryResult[this.currentIndex];\n this.jumpToCell({ IndexNumber: indexNumber });\n\n if (range) {\n let i = 0;\n\n // 如果是表头就往下偏移\n while (this.table.isHeader(0, i)) {\n i++;\n }\n const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;\n range.start.row = row;\n range.end.row = row;\n this.arrangeCustomCellStyle(\n {\n range\n },\n true,\n FocusHighlightStyleId\n );\n }\n } else {\n if (this.currentIndex !== -1) {\n // reset last focus\n this.arrangeCustomCellStyle(this.queryResult[this.currentIndex]);\n }\n this.currentIndex++;\n if (this.currentIndex >= this.queryResult.length) {\n this.currentIndex = 0;\n }\n const { col, row } = this.queryResult[this.currentIndex];\n\n this.arrangeCustomCellStyle(this.queryResult[this.currentIndex], true, FocusHighlightStyleId);\n\n this.jumpToCell({ col, row });\n }\n\n return {\n index: this.currentIndex,\n results: this.queryResult\n };\n }\n\n prev() {\n if (!this.queryResult.length) {\n return {\n index: 0,\n results: this.queryResult\n };\n }\n\n if (this.isTree) {\n // 先取消当前高亮\n if (this.currentIndex !== -1) {\n const { range, indexNumber } = this.queryResult[this.currentIndex];\n if (range) {\n let i = 0;\n while (this.table.isHeader(0, i)) {\n i++;\n }\n const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;\n range.start.row = row;\n range.end.row = row;\n this.arrangeCustomCellStyle({ range });\n }\n }\n\n // 索引向前\n this.currentIndex--;\n if (this.currentIndex < 0) {\n this.currentIndex = this.queryResult.length - 1;\n }\n\n // 焦点样式\n const { range, indexNumber } = this.queryResult[this.currentIndex];\n this.jumpToCell({ IndexNumber: indexNumber });\n\n if (range) {\n let i = 0;\n while (this.table.isHeader(0, i)) {\n i++;\n }\n const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;\n range.start.row = row;\n range.end.row = row;\n this.arrangeCustomCellStyle({ range }, true, FocusHighlightStyleId);\n }\n } else {\n // 普通表格处理\n if (this.currentIndex !== -1) {\n this.arrangeCustomCellStyle(this.queryResult[this.currentIndex]);\n }\n\n this.currentIndex--;\n if (this.currentIndex < 0) {\n this.currentIndex = this.queryResult.length - 1;\n }\n\n const { col, row } = this.queryResult[this.currentIndex];\n this.arrangeCustomCellStyle(this.queryResult[this.currentIndex], true, FocusHighlightStyleId);\n this.jumpToCell({ col, row });\n }\n\n return {\n index: this.currentIndex,\n results: this.queryResult\n };\n }\n\n jumpToCell(params: { col?: number; row?: number; IndexNumber?: number[] }) {\n if (this.isTree) {\n const { IndexNumber } = params;\n const indexNumbers = [...IndexNumber];\n\n const tmp = [...indexNumbers];\n let tmpNumber = 0;\n let i = 0;\n\n // 展开树形结构的父节点\n while (tmpNumber < tmp.length - 1) {\n tmpNumber++;\n const indexNumber = indexNumbers.slice(0, tmpNumber);\n\n // 跳过表头行\n while (this.table.isHeader(0, i)) {\n i++;\n }\n const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;\n\n const hierarchyState = this.table.getHierarchyState(this.treeIndex, row);\n if (hierarchyState !== 'expand') {\n this.table.toggleHierarchyState(this.treeIndex, row);\n }\n }\n\n const finalRow = this.getBodyRowIndexByRecordIndex(indexNumbers) + i;\n\n // 根据配置决定是否滚动表格\n this.table.scrollToRow(finalRow, this.scrollOption);\n\n // 根据配置决定是否滚动页面\n if (this.enableViewportScroll) {\n scrollVTableCellIntoView(this.table, { row: finalRow, col: this.treeIndex });\n }\n } else {\n const { col, row } = params;\n const { rowStart, rowEnd } = this.table.getBodyVisibleRowRange();\n const { colStart, colEnd } = this.table.getBodyVisibleColRange();\n\n // 检查单元格是否在表格可视范围内\n const isInTableView = !(row <= rowStart || row >= rowEnd || col <= colStart || col >= colEnd);\n\n // 根据配置决定是否滚动表格\n if (!isInTableView) {\n this.table.scrollToCell({ col, row });\n }\n\n // 根据配置决定是否滚动页面\n if (this.enableViewportScroll) {\n scrollVTableCellIntoView(this.table, { row, col });\n }\n }\n }\n getBodyRowIndexByRecordIndex(index: number | number[]): number {\n if (Array.isArray(index) && index.length === 1) {\n index = index[0];\n }\n return this.table.dataSource.getTableIndex(index);\n }\n clear() {\n // reset highlight cell style\n this.updateCellStyle(false);\n this.queryStr = '';\n this.queryResult = [];\n this.currentIndex = -1;\n }\n}\n\nfunction scrollVTableCellIntoView(table: IVTable, cellInfo: { row: number; col: number }): void {\n if (typeof document === 'undefined' || typeof window === 'undefined') {\n return;\n }\n\n const tableEl = table.getElement?.() || table.container;\n if (!tableEl) {\n return;\n }\n\n // 获取单元格在表格中的位置信息\n const cellRect = table.getCellRect(cellInfo.col, cellInfo.row);\n if (!cellRect) {\n return;\n }\n\n // 查找最近的可滚动父容器\n let scrollContainer: Element | null = tableEl.parentElement;\n while (scrollContainer) {\n const computedStyle = getComputedStyle(scrollContainer);\n const hasScroll = /(auto|scroll|overlay)/.test(computedStyle.overflowY);\n const canScroll = scrollContainer.scrollHeight > scrollContainer.clientHeight;\n\n if (hasScroll && canScroll) {\n break;\n }\n\n // 向上查找父元素,包括 Shadow DOM 情况\n scrollContainer = scrollContainer.parentElement || (scrollContainer.getRootNode?.() as ShadowRoot)?.host || null;\n }\n\n // 如果没找到可滚动容器,使用 document\n if (!scrollContainer) {\n scrollContainer = document.scrollingElement || document.documentElement;\n }\n\n const scrollContainerEl = scrollContainer as HTMLElement;\n\n // 计算单元格在滚动容器中的绝对位置\n const tableRect = tableEl.getBoundingClientRect();\n const containerRect = scrollContainerEl.getBoundingClientRect();\n\n // 表格相对于滚动容器的位置\n const tableOffsetTop = tableRect.top - containerRect.top + scrollContainerEl.scrollTop;\n\n // 单元格在滚动容器中的绝对位置\n const cellTop = tableOffsetTop + cellRect.top;\n const cellBottom = cellTop + cellRect.height;\n const containerHeight = scrollContainerEl.clientHeight;\n const scrollTop = scrollContainerEl.scrollTop;\n\n // 检查单元格是否完全可见\n const isFullyVisible = cellTop >= scrollTop && cellBottom <= scrollTop + containerHeight;\n\n if (!isFullyVisible) {\n // 计算新的滚动位置\n let newScrollTop: number;\n\n if (cellTop < scrollTop) {\n // 单元格在上方,滚动到单元格顶部\n newScrollTop = cellTop;\n } else {\n // 单元格在下方,滚动到单元格底部对齐容器底部\n newScrollTop = cellBottom - containerHeight;\n }\n\n // 确保滚动位置不小于 0\n scrollContainerEl.scrollTop = Math.max(0, newScrollTop);\n }\n}\n"]}
|
package/dist/vtable-export.js
CHANGED
|
@@ -8,17 +8,17 @@
|
|
|
8
8
|
var isValid$1 = isValid;
|
|
9
9
|
|
|
10
10
|
const HighlightStyleId = '__search_component_highlight';
|
|
11
|
-
const
|
|
12
|
-
const
|
|
11
|
+
const FocusHighlightStyleId = '__search_component_focus';
|
|
12
|
+
const defaultHighlightCellStyle = {
|
|
13
13
|
bgColor: 'rgba(255, 255, 0, 0.2)'
|
|
14
14
|
};
|
|
15
|
-
const
|
|
15
|
+
const defaultFocusHighlightCellStyle = {
|
|
16
16
|
bgColor: 'rgba(255, 155, 0, 0.2)'
|
|
17
17
|
};
|
|
18
|
-
function
|
|
18
|
+
function defaultQueryMethod(queryStr, value) {
|
|
19
19
|
return isValid$1(queryStr) && isValid$1(value) && value.toString().includes(queryStr);
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function defaultTreeQueryMethod(queryStr, node, fieldsToSearch) {
|
|
22
22
|
if (!isValid$1(queryStr)) {
|
|
23
23
|
return false;
|
|
24
24
|
}
|
|
@@ -31,9 +31,11 @@
|
|
|
31
31
|
autoJump;
|
|
32
32
|
highlightCellStyle;
|
|
33
33
|
focuseHighlightCellStyle;
|
|
34
|
+
focusHighlightCellStyle;
|
|
34
35
|
queryMethod;
|
|
35
36
|
treeQueryMethod;
|
|
36
37
|
fieldsToSearch;
|
|
38
|
+
enableViewportScroll;
|
|
37
39
|
callback;
|
|
38
40
|
queryStr;
|
|
39
41
|
queryResult;
|
|
@@ -45,18 +47,20 @@
|
|
|
45
47
|
this.table = option.table;
|
|
46
48
|
this.autoJump = option.autoJump || false;
|
|
47
49
|
this.skipHeader = option.skipHeader || false;
|
|
48
|
-
this.highlightCellStyle = option.highlightCellStyle ||
|
|
49
|
-
this.
|
|
50
|
-
|
|
51
|
-
this.
|
|
50
|
+
this.highlightCellStyle = option.highlightCellStyle || defaultHighlightCellStyle;
|
|
51
|
+
this.focusHighlightCellStyle =
|
|
52
|
+
option.focusHighlightCellStyle || option.focuseHighlightCellStyle || defaultFocusHighlightCellStyle;
|
|
53
|
+
this.queryMethod = option.queryMethod || defaultQueryMethod;
|
|
54
|
+
this.treeQueryMethod = option.treeQueryMethod || defaultTreeQueryMethod;
|
|
52
55
|
this.fieldsToSearch = option.fieldsToSearch || [];
|
|
53
56
|
this.isTree = false;
|
|
54
57
|
this.treeIndex = 0;
|
|
55
58
|
this.callback = option.callback;
|
|
56
59
|
this.scrollOption =
|
|
57
60
|
option.scrollOption || { duration: 900, easing: 'quartIn' };
|
|
61
|
+
this.enableViewportScroll = option.enableViewportScroll || false;
|
|
58
62
|
this.table.registerCustomCellStyle(HighlightStyleId, this.highlightCellStyle);
|
|
59
|
-
this.table.registerCustomCellStyle(
|
|
63
|
+
this.table.registerCustomCellStyle(FocusHighlightStyleId, this.focusHighlightCellStyle);
|
|
60
64
|
}
|
|
61
65
|
search(str) {
|
|
62
66
|
this.clear();
|
|
@@ -177,8 +181,8 @@
|
|
|
177
181
|
if (!this.table.hasCustomCellStyle(HighlightStyleId)) {
|
|
178
182
|
this.table.registerCustomCellStyle(HighlightStyleId, this.highlightCellStyle);
|
|
179
183
|
}
|
|
180
|
-
if (!this.table.hasCustomCellStyle(
|
|
181
|
-
this.table.registerCustomCellStyle(
|
|
184
|
+
if (!this.table.hasCustomCellStyle(FocusHighlightStyleId)) {
|
|
185
|
+
this.table.registerCustomCellStyle(FocusHighlightStyleId, this.focusHighlightCellStyle);
|
|
182
186
|
}
|
|
183
187
|
if (this.isTree) {
|
|
184
188
|
const { range, indexNumber } = this.queryResult[0];
|
|
@@ -191,7 +195,7 @@
|
|
|
191
195
|
range.end.row = row;
|
|
192
196
|
this.arrangeCustomCellStyle({
|
|
193
197
|
range
|
|
194
|
-
}, highlight,
|
|
198
|
+
}, highlight, FocusHighlightStyleId);
|
|
195
199
|
}
|
|
196
200
|
else {
|
|
197
201
|
for (let i = 0; i < this.queryResult.length; i++) {
|
|
@@ -236,7 +240,7 @@
|
|
|
236
240
|
range.end.row = row;
|
|
237
241
|
this.arrangeCustomCellStyle({
|
|
238
242
|
range
|
|
239
|
-
}, true,
|
|
243
|
+
}, true, FocusHighlightStyleId);
|
|
240
244
|
}
|
|
241
245
|
}
|
|
242
246
|
else {
|
|
@@ -248,7 +252,7 @@
|
|
|
248
252
|
this.currentIndex = 0;
|
|
249
253
|
}
|
|
250
254
|
const { col, row } = this.queryResult[this.currentIndex];
|
|
251
|
-
this.arrangeCustomCellStyle(this.queryResult[this.currentIndex], true,
|
|
255
|
+
this.arrangeCustomCellStyle(this.queryResult[this.currentIndex], true, FocusHighlightStyleId);
|
|
252
256
|
this.jumpToCell({ col, row });
|
|
253
257
|
}
|
|
254
258
|
return {
|
|
@@ -291,7 +295,7 @@
|
|
|
291
295
|
const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;
|
|
292
296
|
range.start.row = row;
|
|
293
297
|
range.end.row = row;
|
|
294
|
-
this.arrangeCustomCellStyle({ range }, true,
|
|
298
|
+
this.arrangeCustomCellStyle({ range }, true, FocusHighlightStyleId);
|
|
295
299
|
}
|
|
296
300
|
}
|
|
297
301
|
else {
|
|
@@ -303,7 +307,7 @@
|
|
|
303
307
|
this.currentIndex = this.queryResult.length - 1;
|
|
304
308
|
}
|
|
305
309
|
const { col, row } = this.queryResult[this.currentIndex];
|
|
306
|
-
this.arrangeCustomCellStyle(this.queryResult[this.currentIndex], true,
|
|
310
|
+
this.arrangeCustomCellStyle(this.queryResult[this.currentIndex], true, FocusHighlightStyleId);
|
|
307
311
|
this.jumpToCell({ col, row });
|
|
308
312
|
}
|
|
309
313
|
return {
|
|
@@ -330,15 +334,23 @@
|
|
|
330
334
|
this.table.toggleHierarchyState(this.treeIndex, row);
|
|
331
335
|
}
|
|
332
336
|
}
|
|
333
|
-
this.
|
|
337
|
+
const finalRow = this.getBodyRowIndexByRecordIndex(indexNumbers) + i;
|
|
338
|
+
this.table.scrollToRow(finalRow, this.scrollOption);
|
|
339
|
+
if (this.enableViewportScroll) {
|
|
340
|
+
scrollVTableCellIntoView(this.table, { row: finalRow, col: this.treeIndex });
|
|
341
|
+
}
|
|
334
342
|
}
|
|
335
343
|
else {
|
|
336
344
|
const { col, row } = params;
|
|
337
345
|
const { rowStart, rowEnd } = this.table.getBodyVisibleRowRange();
|
|
338
346
|
const { colStart, colEnd } = this.table.getBodyVisibleColRange();
|
|
339
|
-
|
|
347
|
+
const isInTableView = !(row <= rowStart || row >= rowEnd || col <= colStart || col >= colEnd);
|
|
348
|
+
if (!isInTableView) {
|
|
340
349
|
this.table.scrollToCell({ col, row });
|
|
341
350
|
}
|
|
351
|
+
if (this.enableViewportScroll) {
|
|
352
|
+
scrollVTableCellIntoView(this.table, { row, col });
|
|
353
|
+
}
|
|
342
354
|
}
|
|
343
355
|
}
|
|
344
356
|
getBodyRowIndexByRecordIndex(index) {
|
|
@@ -354,6 +366,51 @@
|
|
|
354
366
|
this.currentIndex = -1;
|
|
355
367
|
}
|
|
356
368
|
}
|
|
369
|
+
function scrollVTableCellIntoView(table, cellInfo) {
|
|
370
|
+
if (typeof document === 'undefined' || typeof window === 'undefined') {
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
const tableEl = table.getElement?.() || table.container;
|
|
374
|
+
if (!tableEl) {
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
const cellRect = table.getCellRect(cellInfo.col, cellInfo.row);
|
|
378
|
+
if (!cellRect) {
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
let scrollContainer = tableEl.parentElement;
|
|
382
|
+
while (scrollContainer) {
|
|
383
|
+
const computedStyle = getComputedStyle(scrollContainer);
|
|
384
|
+
const hasScroll = /(auto|scroll|overlay)/.test(computedStyle.overflowY);
|
|
385
|
+
const canScroll = scrollContainer.scrollHeight > scrollContainer.clientHeight;
|
|
386
|
+
if (hasScroll && canScroll) {
|
|
387
|
+
break;
|
|
388
|
+
}
|
|
389
|
+
scrollContainer = scrollContainer.parentElement || scrollContainer.getRootNode?.()?.host || null;
|
|
390
|
+
}
|
|
391
|
+
if (!scrollContainer) {
|
|
392
|
+
scrollContainer = document.scrollingElement || document.documentElement;
|
|
393
|
+
}
|
|
394
|
+
const scrollContainerEl = scrollContainer;
|
|
395
|
+
const tableRect = tableEl.getBoundingClientRect();
|
|
396
|
+
const containerRect = scrollContainerEl.getBoundingClientRect();
|
|
397
|
+
const tableOffsetTop = tableRect.top - containerRect.top + scrollContainerEl.scrollTop;
|
|
398
|
+
const cellTop = tableOffsetTop + cellRect.top;
|
|
399
|
+
const cellBottom = cellTop + cellRect.height;
|
|
400
|
+
const containerHeight = scrollContainerEl.clientHeight;
|
|
401
|
+
const scrollTop = scrollContainerEl.scrollTop;
|
|
402
|
+
const isFullyVisible = cellTop >= scrollTop && cellBottom <= scrollTop + containerHeight;
|
|
403
|
+
if (!isFullyVisible) {
|
|
404
|
+
let newScrollTop;
|
|
405
|
+
if (cellTop < scrollTop) {
|
|
406
|
+
newScrollTop = cellTop;
|
|
407
|
+
}
|
|
408
|
+
else {
|
|
409
|
+
newScrollTop = cellBottom - containerHeight;
|
|
410
|
+
}
|
|
411
|
+
scrollContainerEl.scrollTop = Math.max(0, newScrollTop);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
357
414
|
|
|
358
415
|
exports.SearchComponent = SearchComponent;
|
|
359
416
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).VTable=e.VTable||{},e.VTable.export={}))}(this,(function(e){"use strict";var t=e=>null!=e;const r="__search_component_highlight",
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).VTable=e.VTable||{},e.VTable.export={}))}(this,(function(e){"use strict";var t=e=>null!=e;const r="__search_component_highlight",l="__search_component_focus",s={bgColor:"rgba(255, 255, 0, 0.2)"},i={bgColor:"rgba(255, 155, 0, 0.2)"};function n(e,r){return t(e)&&t(r)&&r.toString().includes(e)}function o(e,r,l){if(!t(e))return!1;return(Array.isArray(l)&&l.length>0?l:Object.keys(r)).some((l=>t(r?.[l])&&r[l].toString().includes(e)))}function h(e,t){if("undefined"==typeof document||"undefined"==typeof window)return;const r=e.getElement?.()||e.container;if(!r)return;const l=e.getCellRect(t.col,t.row);if(!l)return;let s=r.parentElement;for(;s;){const e=getComputedStyle(s),t=/(auto|scroll|overlay)/.test(e.overflowY),r=s.scrollHeight>s.clientHeight;if(t&&r)break;s=s.parentElement||s.getRootNode?.()?.host||null}s||(s=document.scrollingElement||document.documentElement);const i=s,n=r.getBoundingClientRect(),o=i.getBoundingClientRect(),h=n.top-o.top+i.scrollTop+l.top,u=h+l.height,a=i.clientHeight,c=i.scrollTop;if(!(h>=c&&u<=c+a)){let e;e=h<c?h:u-a,i.scrollTop=Math.max(0,e)}}e.SearchComponent=class{table;skipHeader;autoJump;highlightCellStyle;focuseHighlightCellStyle;focusHighlightCellStyle;queryMethod;treeQueryMethod;fieldsToSearch;enableViewportScroll;callback;queryStr;queryResult;currentIndex;isTree;treeIndex;scrollOption;constructor(e){this.table=e.table,this.autoJump=e.autoJump||!1,this.skipHeader=e.skipHeader||!1,this.highlightCellStyle=e.highlightCellStyle||s,this.focusHighlightCellStyle=e.focusHighlightCellStyle||e.focuseHighlightCellStyle||i,this.queryMethod=e.queryMethod||n,this.treeQueryMethod=e.treeQueryMethod||o,this.fieldsToSearch=e.fieldsToSearch||[],this.isTree=!1,this.treeIndex=0,this.callback=e.callback,this.scrollOption=e.scrollOption||{duration:900,easing:"quartIn"},this.enableViewportScroll=e.enableViewportScroll||!1,this.table.registerCustomCellStyle(r,this.highlightCellStyle),this.table.registerCustomCellStyle(l,this.focusHighlightCellStyle)}search(e){if(this.clear(),this.queryStr=e,!e)return{index:0,results:this.queryResult};if(this.isTree=this.table.options.columns.some((e=>e.tree)),this.treeIndex=this.isTree?this.table.options.columns.findIndex((e=>e.tree)):0,this.isTree){const e=this.table.colCount,t=(r,l)=>{r.forEach(((r,s)=>{const i=[...l,s];this.treeQueryMethod(this.queryStr,r,this.fieldsToSearch,{table:this.table})&&this.queryResult.push({indexNumber:i,range:{start:{row:null,col:0},end:{row:null,col:e}}}),r.children&&Array.isArray(r.children)&&r.children.length>0&&t(r.children,i)}))};return t(this.table.records,[]),this.queryResult.length>0&&this.jumpToCell({IndexNumber:this.queryResult[0].indexNumber}),this.callback&&this.callback({queryStr:this.queryStr,results:this.queryResult},this.table),this.updateCellStyle(),this.currentIndex=0,{index:0,results:this.queryResult}}for(let e=0;e<this.table.rowCount;e++)for(let t=0;t<this.table.colCount;t++){if(this.skipHeader&&this.table.isHeader(t,e))continue;const r=this.table.getCellValue(t,e);if(this.queryMethod(this.queryStr,r,{col:t,row:e,table:this.table})){const l=this.table.getCellRange(t,e);if(l.start.col!==l.end.col||l.start.row!==l.end.row){let e=!1;for(let t=this.queryResult.length-1;t>=0;t--)if(this.queryResult[t].col===l.start.col&&this.queryResult[t].row===l.start.row){e=!0;break}e||this.queryResult.push({col:l.start.col,row:l.start.row,range:l,value:r})}else this.queryResult.push({col:t,row:e,value:r})}}return this.updateCellStyle(),this.callback&&this.callback({queryStr:this.queryStr,results:this.queryResult},this.table),this.autoJump?this.next():{index:0,results:this.queryResult}}arrangeCustomCellStyle(e,t=!0,l=r){const{col:s,row:i,range:n}=e;this.table.arrangeCustomCellStyle(n?{range:n}:{row:i,col:s},t?l:null)}updateCellStyle(e=!0){if(e){if(this.queryResult)if(this.table.hasCustomCellStyle(r)||this.table.registerCustomCellStyle(r,this.highlightCellStyle),this.table.hasCustomCellStyle(l)||this.table.registerCustomCellStyle(l,this.focusHighlightCellStyle),this.isTree){const{range:t,indexNumber:r}=this.queryResult[0];let s=0;for(;this.table.isHeader(0,s);)s++;const i=this.getBodyRowIndexByRecordIndex(r)+s;t.start.row=i,t.end.row=i,this.arrangeCustomCellStyle({range:t},e,l)}else for(let t=0;t<this.queryResult.length;t++)this.arrangeCustomCellStyle(this.queryResult[t],e)}else(this.queryResult||[]).forEach((t=>{this.arrangeCustomCellStyle(t,e)}))}next(){if(!this.queryResult.length)return{index:0,results:this.queryResult};if(this.isTree){if(-1!==this.currentIndex){const{range:e,indexNumber:t}=this.queryResult[this.currentIndex];if(e){let r=0;for(;this.table.isHeader(0,r);)r++;const l=this.getBodyRowIndexByRecordIndex(t)+r;e.start.row=l,e.end.row=l,this.arrangeCustomCellStyle({range:e})}}this.currentIndex++,this.currentIndex>=this.queryResult.length&&(this.currentIndex=0);const{range:e,indexNumber:t}=this.queryResult[this.currentIndex];if(this.jumpToCell({IndexNumber:t}),e){let r=0;for(;this.table.isHeader(0,r);)r++;const s=this.getBodyRowIndexByRecordIndex(t)+r;e.start.row=s,e.end.row=s,this.arrangeCustomCellStyle({range:e},!0,l)}}else{-1!==this.currentIndex&&this.arrangeCustomCellStyle(this.queryResult[this.currentIndex]),this.currentIndex++,this.currentIndex>=this.queryResult.length&&(this.currentIndex=0);const{col:e,row:t}=this.queryResult[this.currentIndex];this.arrangeCustomCellStyle(this.queryResult[this.currentIndex],!0,l),this.jumpToCell({col:e,row:t})}return{index:this.currentIndex,results:this.queryResult}}prev(){if(!this.queryResult.length)return{index:0,results:this.queryResult};if(this.isTree){if(-1!==this.currentIndex){const{range:e,indexNumber:t}=this.queryResult[this.currentIndex];if(e){let r=0;for(;this.table.isHeader(0,r);)r++;const l=this.getBodyRowIndexByRecordIndex(t)+r;e.start.row=l,e.end.row=l,this.arrangeCustomCellStyle({range:e})}}this.currentIndex--,this.currentIndex<0&&(this.currentIndex=this.queryResult.length-1);const{range:e,indexNumber:t}=this.queryResult[this.currentIndex];if(this.jumpToCell({IndexNumber:t}),e){let r=0;for(;this.table.isHeader(0,r);)r++;const s=this.getBodyRowIndexByRecordIndex(t)+r;e.start.row=s,e.end.row=s,this.arrangeCustomCellStyle({range:e},!0,l)}}else{-1!==this.currentIndex&&this.arrangeCustomCellStyle(this.queryResult[this.currentIndex]),this.currentIndex--,this.currentIndex<0&&(this.currentIndex=this.queryResult.length-1);const{col:e,row:t}=this.queryResult[this.currentIndex];this.arrangeCustomCellStyle(this.queryResult[this.currentIndex],!0,l),this.jumpToCell({col:e,row:t})}return{index:this.currentIndex,results:this.queryResult}}jumpToCell(e){if(this.isTree){const{IndexNumber:t}=e,r=[...t],l=[...r];let s=0,i=0;for(;s<l.length-1;){s++;const e=r.slice(0,s);for(;this.table.isHeader(0,i);)i++;const t=this.getBodyRowIndexByRecordIndex(e)+i;"expand"!==this.table.getHierarchyState(this.treeIndex,t)&&this.table.toggleHierarchyState(this.treeIndex,t)}const n=this.getBodyRowIndexByRecordIndex(r)+i;this.table.scrollToRow(n,this.scrollOption),this.enableViewportScroll&&h(this.table,{row:n,col:this.treeIndex})}else{const{col:t,row:r}=e,{rowStart:l,rowEnd:s}=this.table.getBodyVisibleRowRange(),{colStart:i,colEnd:n}=this.table.getBodyVisibleColRange();!(r<=l||r>=s||t<=i||t>=n)||this.table.scrollToCell({col:t,row:r}),this.enableViewportScroll&&h(this.table,{row:r,col:t})}}getBodyRowIndexByRecordIndex(e){return Array.isArray(e)&&1===e.length&&(e=e[0]),this.table.dataSource.getTableIndex(e)}clear(){this.updateCellStyle(!1),this.queryStr="",this.queryResult=[],this.currentIndex=-1}}}));
|
|
@@ -16,6 +16,7 @@ export type SearchComponentOption = {
|
|
|
16
16
|
skipHeader?: boolean;
|
|
17
17
|
highlightCellStyle?: VTable.TYPES.CellStyle;
|
|
18
18
|
focuseHighlightCellStyle?: VTable.TYPES.CellStyle;
|
|
19
|
+
focusHighlightCellStyle?: VTable.TYPES.CellStyle;
|
|
19
20
|
queryMethod?: (queryStr: string, value: string, option?: {
|
|
20
21
|
col: number;
|
|
21
22
|
row: number;
|
|
@@ -26,6 +27,7 @@ export type SearchComponentOption = {
|
|
|
26
27
|
}) => boolean;
|
|
27
28
|
fieldsToSearch?: string[];
|
|
28
29
|
scrollOption?: ITableAnimationOption;
|
|
30
|
+
enableViewportScroll?: boolean;
|
|
29
31
|
callback?: (queryResult: QueryResult, table: IVTable) => void;
|
|
30
32
|
};
|
|
31
33
|
export declare class SearchComponent {
|
|
@@ -34,6 +36,7 @@ export declare class SearchComponent {
|
|
|
34
36
|
autoJump: boolean;
|
|
35
37
|
highlightCellStyle: Partial<VTable.TYPES.CellStyle>;
|
|
36
38
|
focuseHighlightCellStyle: Partial<VTable.TYPES.CellStyle>;
|
|
39
|
+
focusHighlightCellStyle: Partial<VTable.TYPES.CellStyle>;
|
|
37
40
|
queryMethod: (queryStr: string, value: string, option: {
|
|
38
41
|
col: number;
|
|
39
42
|
row: number;
|
|
@@ -43,6 +46,7 @@ export declare class SearchComponent {
|
|
|
43
46
|
table: IVTable;
|
|
44
47
|
}) => boolean;
|
|
45
48
|
fieldsToSearch: string[];
|
|
49
|
+
enableViewportScroll?: boolean;
|
|
46
50
|
callback?: (queryResult: QueryResult, table: IVTable) => void;
|
|
47
51
|
queryStr: string;
|
|
48
52
|
queryResult: {
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { isValid } from "@visactor/vutils";
|
|
2
2
|
|
|
3
|
-
const HighlightStyleId = "__search_component_highlight",
|
|
3
|
+
const HighlightStyleId = "__search_component_highlight", FocusHighlightStyleId = "__search_component_focus", defaultHighlightCellStyle = {
|
|
4
4
|
bgColor: "rgba(255, 255, 0, 0.2)"
|
|
5
|
-
},
|
|
5
|
+
}, defaultFocusHighlightCellStyle = {
|
|
6
6
|
bgColor: "rgba(255, 155, 0, 0.2)"
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
function
|
|
9
|
+
function defaultQueryMethod(queryStr, value) {
|
|
10
10
|
return isValid(queryStr) && isValid(value) && value.toString().includes(queryStr);
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
function
|
|
13
|
+
function defaultTreeQueryMethod(queryStr, node, fieldsToSearch) {
|
|
14
14
|
if (!isValid(queryStr)) return !1;
|
|
15
15
|
return (Array.isArray(fieldsToSearch) && fieldsToSearch.length > 0 ? fieldsToSearch : Object.keys(node)).some((field => isValid(null == node ? void 0 : node[field]) && node[field].toString().includes(queryStr)));
|
|
16
16
|
}
|
|
@@ -18,15 +18,15 @@ function defalultTreeQueryMethod(queryStr, node, fieldsToSearch) {
|
|
|
18
18
|
export class SearchComponent {
|
|
19
19
|
constructor(option) {
|
|
20
20
|
this.table = option.table, this.autoJump = option.autoJump || !1, this.skipHeader = option.skipHeader || !1,
|
|
21
|
-
this.highlightCellStyle = option.highlightCellStyle ||
|
|
22
|
-
this.
|
|
23
|
-
this.queryMethod = option.queryMethod ||
|
|
21
|
+
this.highlightCellStyle = option.highlightCellStyle || defaultHighlightCellStyle,
|
|
22
|
+
this.focusHighlightCellStyle = option.focusHighlightCellStyle || option.focuseHighlightCellStyle || defaultFocusHighlightCellStyle,
|
|
23
|
+
this.queryMethod = option.queryMethod || defaultQueryMethod, this.treeQueryMethod = option.treeQueryMethod || defaultTreeQueryMethod,
|
|
24
24
|
this.fieldsToSearch = option.fieldsToSearch || [], this.isTree = !1, this.treeIndex = 0,
|
|
25
25
|
this.callback = option.callback, this.scrollOption = option.scrollOption || {
|
|
26
26
|
duration: 900,
|
|
27
27
|
easing: "quartIn"
|
|
28
|
-
}, this.table.registerCustomCellStyle(HighlightStyleId, this.highlightCellStyle),
|
|
29
|
-
this.table.registerCustomCellStyle(
|
|
28
|
+
}, this.enableViewportScroll = option.enableViewportScroll || !1, this.table.registerCustomCellStyle(HighlightStyleId, this.highlightCellStyle),
|
|
29
|
+
this.table.registerCustomCellStyle(FocusHighlightStyleId, this.focusHighlightCellStyle);
|
|
30
30
|
}
|
|
31
31
|
search(str) {
|
|
32
32
|
if (this.clear(), this.queryStr = str, !str) return {
|
|
@@ -113,7 +113,7 @@ export class SearchComponent {
|
|
|
113
113
|
updateCellStyle(highlight = !0) {
|
|
114
114
|
if (highlight) {
|
|
115
115
|
if (this.queryResult) if (this.table.hasCustomCellStyle(HighlightStyleId) || this.table.registerCustomCellStyle(HighlightStyleId, this.highlightCellStyle),
|
|
116
|
-
this.table.hasCustomCellStyle(
|
|
116
|
+
this.table.hasCustomCellStyle(FocusHighlightStyleId) || this.table.registerCustomCellStyle(FocusHighlightStyleId, this.focusHighlightCellStyle),
|
|
117
117
|
this.isTree) {
|
|
118
118
|
const {range: range, indexNumber: indexNumber} = this.queryResult[0];
|
|
119
119
|
let i = 0;
|
|
@@ -121,7 +121,7 @@ export class SearchComponent {
|
|
|
121
121
|
const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;
|
|
122
122
|
range.start.row = row, range.end.row = row, this.arrangeCustomCellStyle({
|
|
123
123
|
range: range
|
|
124
|
-
}, highlight,
|
|
124
|
+
}, highlight, FocusHighlightStyleId);
|
|
125
125
|
} else for (let i = 0; i < this.queryResult.length; i++) this.arrangeCustomCellStyle(this.queryResult[i], highlight);
|
|
126
126
|
} else (this.queryResult || []).forEach((resultItem => {
|
|
127
127
|
this.arrangeCustomCellStyle(resultItem, highlight);
|
|
@@ -154,13 +154,13 @@ export class SearchComponent {
|
|
|
154
154
|
const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;
|
|
155
155
|
range.start.row = row, range.end.row = row, this.arrangeCustomCellStyle({
|
|
156
156
|
range: range
|
|
157
|
-
}, !0,
|
|
157
|
+
}, !0, FocusHighlightStyleId);
|
|
158
158
|
}
|
|
159
159
|
} else {
|
|
160
160
|
-1 !== this.currentIndex && this.arrangeCustomCellStyle(this.queryResult[this.currentIndex]),
|
|
161
161
|
this.currentIndex++, this.currentIndex >= this.queryResult.length && (this.currentIndex = 0);
|
|
162
162
|
const {col: col, row: row} = this.queryResult[this.currentIndex];
|
|
163
|
-
this.arrangeCustomCellStyle(this.queryResult[this.currentIndex], !0,
|
|
163
|
+
this.arrangeCustomCellStyle(this.queryResult[this.currentIndex], !0, FocusHighlightStyleId),
|
|
164
164
|
this.jumpToCell({
|
|
165
165
|
col: col,
|
|
166
166
|
row: row
|
|
@@ -198,13 +198,13 @@ export class SearchComponent {
|
|
|
198
198
|
const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;
|
|
199
199
|
range.start.row = row, range.end.row = row, this.arrangeCustomCellStyle({
|
|
200
200
|
range: range
|
|
201
|
-
}, !0,
|
|
201
|
+
}, !0, FocusHighlightStyleId);
|
|
202
202
|
}
|
|
203
203
|
} else {
|
|
204
204
|
-1 !== this.currentIndex && this.arrangeCustomCellStyle(this.queryResult[this.currentIndex]),
|
|
205
205
|
this.currentIndex--, this.currentIndex < 0 && (this.currentIndex = this.queryResult.length - 1);
|
|
206
206
|
const {col: col, row: row} = this.queryResult[this.currentIndex];
|
|
207
|
-
this.arrangeCustomCellStyle(this.queryResult[this.currentIndex], !0,
|
|
207
|
+
this.arrangeCustomCellStyle(this.queryResult[this.currentIndex], !0, FocusHighlightStyleId),
|
|
208
208
|
this.jumpToCell({
|
|
209
209
|
col: col,
|
|
210
210
|
row: row
|
|
@@ -226,12 +226,19 @@ export class SearchComponent {
|
|
|
226
226
|
const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;
|
|
227
227
|
"expand" !== this.table.getHierarchyState(this.treeIndex, row) && this.table.toggleHierarchyState(this.treeIndex, row);
|
|
228
228
|
}
|
|
229
|
-
this.
|
|
229
|
+
const finalRow = this.getBodyRowIndexByRecordIndex(indexNumbers) + i;
|
|
230
|
+
this.table.scrollToRow(finalRow, this.scrollOption), this.enableViewportScroll && scrollVTableCellIntoView(this.table, {
|
|
231
|
+
row: finalRow,
|
|
232
|
+
col: this.treeIndex
|
|
233
|
+
});
|
|
230
234
|
} else {
|
|
231
235
|
const {col: col, row: row} = params, {rowStart: rowStart, rowEnd: rowEnd} = this.table.getBodyVisibleRowRange(), {colStart: colStart, colEnd: colEnd} = this.table.getBodyVisibleColRange();
|
|
232
|
-
(row <= rowStart || row >= rowEnd || col <= colStart || col >= colEnd)
|
|
236
|
+
!(row <= rowStart || row >= rowEnd || col <= colStart || col >= colEnd) || this.table.scrollToCell({
|
|
233
237
|
col: col,
|
|
234
238
|
row: row
|
|
239
|
+
}), this.enableViewportScroll && scrollVTableCellIntoView(this.table, {
|
|
240
|
+
row: row,
|
|
241
|
+
col: col
|
|
235
242
|
});
|
|
236
243
|
}
|
|
237
244
|
}
|
|
@@ -242,4 +249,25 @@ export class SearchComponent {
|
|
|
242
249
|
this.updateCellStyle(!1), this.queryStr = "", this.queryResult = [], this.currentIndex = -1;
|
|
243
250
|
}
|
|
244
251
|
}
|
|
252
|
+
|
|
253
|
+
function scrollVTableCellIntoView(table, cellInfo) {
|
|
254
|
+
var _a, _b, _c;
|
|
255
|
+
if ("undefined" == typeof document || "undefined" == typeof window) return;
|
|
256
|
+
const tableEl = (null === (_a = table.getElement) || void 0 === _a ? void 0 : _a.call(table)) || table.container;
|
|
257
|
+
if (!tableEl) return;
|
|
258
|
+
const cellRect = table.getCellRect(cellInfo.col, cellInfo.row);
|
|
259
|
+
if (!cellRect) return;
|
|
260
|
+
let scrollContainer = tableEl.parentElement;
|
|
261
|
+
for (;scrollContainer; ) {
|
|
262
|
+
const computedStyle = getComputedStyle(scrollContainer), hasScroll = /(auto|scroll|overlay)/.test(computedStyle.overflowY), canScroll = scrollContainer.scrollHeight > scrollContainer.clientHeight;
|
|
263
|
+
if (hasScroll && canScroll) break;
|
|
264
|
+
scrollContainer = scrollContainer.parentElement || (null === (_c = null === (_b = scrollContainer.getRootNode) || void 0 === _b ? void 0 : _b.call(scrollContainer)) || void 0 === _c ? void 0 : _c.host) || null;
|
|
265
|
+
}
|
|
266
|
+
scrollContainer || (scrollContainer = document.scrollingElement || document.documentElement);
|
|
267
|
+
const scrollContainerEl = scrollContainer, tableRect = tableEl.getBoundingClientRect(), containerRect = scrollContainerEl.getBoundingClientRect(), cellTop = tableRect.top - containerRect.top + scrollContainerEl.scrollTop + cellRect.top, cellBottom = cellTop + cellRect.height, containerHeight = scrollContainerEl.clientHeight, scrollTop = scrollContainerEl.scrollTop;
|
|
268
|
+
if (!(cellTop >= scrollTop && cellBottom <= scrollTop + containerHeight)) {
|
|
269
|
+
let newScrollTop;
|
|
270
|
+
newScrollTop = cellTop < scrollTop ? cellTop : cellBottom - containerHeight, scrollContainerEl.scrollTop = Math.max(0, newScrollTop);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
245
273
|
//# sourceMappingURL=search-component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["search-component/search-component.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AA0B3C,MAAM,gBAAgB,GAAG,8BAA8B,CAAC;AACxD,MAAM,sBAAsB,GAAG,2BAA2B,CAAC;AAE3D,MAAM,0BAA0B,GAAoC;IAClE,OAAO,EAAE,wBAAwB;CAClC,CAAC;AAEF,MAAM,+BAA+B,GAAoC;IACvE,OAAO,EAAE,wBAAwB;CAClC,CAAC;AAEF,SAAS,mBAAmB,CAAC,QAAgB,EAAE,KAAa;IAC1D,OAAO,OAAO,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACpF,CAAC;AACD,SAAS,uBAAuB,CAAC,QAAgB,EAAE,IAAS,EAAE,cAAyB;IACrF,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QACtB,OAAO,KAAK,CAAC;KACd;IAGD,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAErH,OAAO,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAG,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;AACzG,CAAC;AACD,MAAM,OAAO,eAAe;IA0B1B,YAAY,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YAAY,GAAG,CAAC,CAAC,CAAC;IACzB,CAAC;CACF","file":"search-component.js","sourcesContent":["import type * as VTable from '@visactor/vtable';\nimport type { ITableAnimationOption } from '@visactor/vtable/src/ts-types';\nimport type { EasingType } from '@visactor/vtable/src/vrender';\nimport { isValid } from '@visactor/vutils';\ntype IVTable = VTable.ListTable | VTable.PivotTable | VTable.PivotChart;\n\nexport type QueryResult = {\n queryStr: string;\n results: {\n col?: number;\n row?: number;\n value?: string;\n indexNumber?: number[];\n }[];\n};\n\nexport type SearchComponentOption = {\n table: IVTable;\n autoJump?: boolean;\n skipHeader?: boolean;\n highlightCellStyle?: VTable.TYPES.CellStyle;\n focuseHighlightCellStyle?: VTable.TYPES.CellStyle;\n queryMethod?: (queryStr: string, value: string, option?: { col: number; row: number; table: IVTable }) => boolean;\n treeQueryMethod?: (queryStr: string, node: any, fieldsToSearch?: string[], option?: { table: IVTable }) => boolean;\n fieldsToSearch?: string[];\n scrollOption?: ITableAnimationOption;\n callback?: (queryResult: QueryResult, table: IVTable) => void;\n};\n\nconst HighlightStyleId = '__search_component_highlight';\nconst FocuseHighlightStyleId = '__search_component_focuse';\n\nconst defalutHightlightCellStyle: Partial<VTable.TYPES.CellStyle> = {\n bgColor: 'rgba(255, 255, 0, 0.2)'\n};\n\nconst defalutFocusHightlightCellStyle: Partial<VTable.TYPES.CellStyle> = {\n bgColor: 'rgba(255, 155, 0, 0.2)'\n};\n\nfunction defalultQueryMethod(queryStr: string, value: string) {\n return isValid(queryStr) && isValid(value) && value.toString().includes(queryStr);\n}\nfunction defalultTreeQueryMethod(queryStr: string, node: any, fieldsToSearch?: string[]) {\n if (!isValid(queryStr)) {\n return false;\n }\n\n // 如果没有传 fieldsToSearch,则用 node 的全部 key\n const searchFields = Array.isArray(fieldsToSearch) && fieldsToSearch.length > 0 ? fieldsToSearch : Object.keys(node);\n\n return searchFields.some(field => isValid(node?.[field]) && node[field].toString().includes(queryStr));\n}\nexport class SearchComponent {\n table: IVTable;\n skipHeader: boolean;\n autoJump: boolean;\n highlightCellStyle: Partial<VTable.TYPES.CellStyle>;\n focuseHighlightCellStyle: Partial<VTable.TYPES.CellStyle>;\n queryMethod: (queryStr: string, value: string, option: { col: number; row: number; table: IVTable }) => boolean;\n treeQueryMethod: (queryStr: string, node: any, fieldsToSearch?: string[], option?: { table: IVTable }) => boolean;\n fieldsToSearch: string[];\n\n callback?: (queryResult: QueryResult, table: IVTable) => void;\n\n queryStr: string;\n queryResult: {\n col?: number;\n row?: number;\n range?: VTable.TYPES.CellRange;\n value?: string;\n indexNumber?: number[];\n }[];\n\n currentIndex: number;\n isTree: boolean;\n treeIndex: number;\n scrollOption: ITableAnimationOption;\n\n constructor(option: SearchComponentOption) {\n this.table = option.table;\n this.autoJump = option.autoJump || false;\n this.skipHeader = option.skipHeader || false;\n this.highlightCellStyle = option.highlightCellStyle || defalutHightlightCellStyle;\n this.focuseHighlightCellStyle = option.focuseHighlightCellStyle || defalutFocusHightlightCellStyle;\n this.queryMethod = option.queryMethod || defalultQueryMethod;\n this.treeQueryMethod = option.treeQueryMethod || defalultTreeQueryMethod;\n this.fieldsToSearch = option.fieldsToSearch || [];\n this.isTree = false;\n this.treeIndex = 0;\n this.callback = option.callback;\n this.scrollOption =\n option.scrollOption || ({ duration: 900, easing: 'quartIn' as EasingType } as ITableAnimationOption);\n this.table.registerCustomCellStyle(HighlightStyleId, this.highlightCellStyle as any);\n this.table.registerCustomCellStyle(FocuseHighlightStyleId, this.focuseHighlightCellStyle as any);\n }\n\n search(str: string) {\n this.clear();\n this.queryStr = str;\n\n if (!str) {\n return {\n index: 0,\n results: this.queryResult\n };\n }\n this.isTree = this.table.options.columns.some((item: any) => item.tree);\n this.treeIndex = this.isTree ? this.table.options.columns.findIndex((item: any) => item.tree) : 0;\n if (this.isTree) {\n // 如果传入单一节点也能处理\n const colEnd = this.table.colCount;\n const walk = (nodes: any[], path: number[]) => {\n nodes.forEach((item: any, idx: number) => {\n const currentPath = [...path, idx]; // 当前节点的完整路径\n\n // 保持你的 treeQueryMethod 调用方式(this 上下文来自定义环境)\n if (this.treeQueryMethod(this.queryStr, item, this.fieldsToSearch, { table: this.table })) {\n this.queryResult.push({\n indexNumber: currentPath,\n range: {\n start: { row: null, col: 0 },\n end: { row: null, col: colEnd }\n }\n });\n }\n\n if (item.children && Array.isArray(item.children) && item.children.length > 0) {\n walk(item.children, currentPath);\n }\n });\n };\n\n walk(this.table.records, []);\n if (this.queryResult.length > 0) {\n this.jumpToCell({ IndexNumber: this.queryResult[0].indexNumber });\n }\n\n if (this.callback) {\n this.callback(\n {\n queryStr: this.queryStr,\n results: this.queryResult\n },\n this.table\n );\n }\n this.updateCellStyle();\n\n // if (this.autoJump) {\n // return this.next();\n // }\n this.currentIndex = 0;\n\n return {\n index: 0,\n results: this.queryResult\n };\n }\n for (let row = 0; row < this.table.rowCount; row++) {\n for (let col = 0; col < this.table.colCount; col++) {\n if (this.skipHeader && this.table.isHeader(col, row)) {\n continue;\n }\n const value = this.table.getCellValue(col, row);\n if (this.queryMethod(this.queryStr, value, { col, row, table: this.table })) {\n // deal merge cell\n const mergeCell = this.table.getCellRange(col, row);\n if (mergeCell.start.col !== mergeCell.end.col || mergeCell.start.row !== mergeCell.end.row) {\n // find is cell already in queryResult\n let isIn = false;\n for (let i = this.queryResult.length - 1; i >= 0; i--) {\n if (this.queryResult[i].col === mergeCell.start.col && this.queryResult[i].row === mergeCell.start.row) {\n isIn = true;\n break;\n }\n }\n if (!isIn) {\n this.queryResult.push({\n col: mergeCell.start.col,\n row: mergeCell.start.row,\n range: mergeCell,\n value\n });\n }\n } else {\n this.queryResult.push({\n col,\n row,\n value\n });\n }\n }\n }\n }\n this.updateCellStyle();\n\n if (this.callback) {\n this.callback(\n {\n queryStr: this.queryStr,\n results: this.queryResult\n },\n this.table\n );\n }\n\n if (this.autoJump) {\n return this.next();\n }\n return {\n index: 0,\n results: this.queryResult\n };\n }\n\n /**\n * @description: 为查询结果项设置自定义单元格样式\n * @param {(typeof this.queryResult)[number]} resultItem 查询结果项\n * @param {boolean} highlight 是否高亮\n * @param {string} customStyleId 自定义样式ID\n */\n arrangeCustomCellStyle(\n resultItem: (typeof this.queryResult)[number],\n highlight: boolean = true,\n customStyleId: string = HighlightStyleId\n ) {\n const { col, row, range } = resultItem;\n this.table.arrangeCustomCellStyle(\n range\n ? { range }\n : {\n row,\n col\n },\n highlight ? customStyleId : null\n );\n }\n\n updateCellStyle(highlight: boolean = true) {\n if (!highlight) {\n (this.queryResult || []).forEach(resultItem => {\n this.arrangeCustomCellStyle(resultItem, highlight);\n });\n return;\n }\n if (!this.queryResult) {\n return;\n }\n\n if (!this.table.hasCustomCellStyle(HighlightStyleId)) {\n this.table.registerCustomCellStyle(HighlightStyleId, this.highlightCellStyle as any);\n }\n if (!this.table.hasCustomCellStyle(FocuseHighlightStyleId)) {\n this.table.registerCustomCellStyle(FocuseHighlightStyleId, this.focuseHighlightCellStyle as any);\n }\n if (this.isTree) {\n const { range, indexNumber } = this.queryResult[0];\n\n let i = 0;\n\n // 如果是表头就往下偏移\n while (this.table.isHeader(0, i)) {\n i++;\n }\n const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;\n range.start.row = row;\n range.end.row = row;\n\n this.arrangeCustomCellStyle(\n {\n range\n },\n highlight,\n FocuseHighlightStyleId\n );\n } else {\n for (let i = 0; i < this.queryResult.length; i++) {\n this.arrangeCustomCellStyle(this.queryResult[i], highlight);\n }\n }\n }\n\n next() {\n if (!this.queryResult.length) {\n return {\n index: 0,\n results: this.queryResult\n };\n }\n if (this.isTree) {\n if (this.currentIndex !== -1) {\n const { range, indexNumber } = this.queryResult[this.currentIndex];\n\n if (range) {\n let i = 0;\n\n // 如果是表头就往下偏移\n while (this.table.isHeader(0, i)) {\n i++;\n }\n const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;\n range.start.row = row;\n range.end.row = row;\n this.arrangeCustomCellStyle({ range });\n }\n }\n\n this.currentIndex++;\n if (this.currentIndex >= this.queryResult.length) {\n this.currentIndex = 0;\n }\n const { range, indexNumber } = this.queryResult[this.currentIndex];\n this.jumpToCell({ IndexNumber: indexNumber });\n\n if (range) {\n let i = 0;\n\n // 如果是表头就往下偏移\n while (this.table.isHeader(0, i)) {\n i++;\n }\n const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;\n range.start.row = row;\n range.end.row = row;\n this.arrangeCustomCellStyle(\n {\n range\n },\n true,\n FocuseHighlightStyleId\n );\n }\n } else {\n if (this.currentIndex !== -1) {\n // reset last focus\n this.arrangeCustomCellStyle(this.queryResult[this.currentIndex]);\n }\n this.currentIndex++;\n if (this.currentIndex >= this.queryResult.length) {\n this.currentIndex = 0;\n }\n const { col, row } = this.queryResult[this.currentIndex];\n\n this.arrangeCustomCellStyle(this.queryResult[this.currentIndex], true, FocuseHighlightStyleId);\n\n this.jumpToCell({ col, row });\n }\n\n return {\n index: this.currentIndex,\n results: this.queryResult\n };\n }\n\n prev() {\n if (!this.queryResult.length) {\n return {\n index: 0,\n results: this.queryResult\n };\n }\n\n if (this.isTree) {\n // 先取消当前高亮\n if (this.currentIndex !== -1) {\n const { range, indexNumber } = this.queryResult[this.currentIndex];\n if (range) {\n let i = 0;\n while (this.table.isHeader(0, i)) {\n i++;\n }\n const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;\n range.start.row = row;\n range.end.row = row;\n this.arrangeCustomCellStyle({ range });\n }\n }\n\n // 索引向前\n this.currentIndex--;\n if (this.currentIndex < 0) {\n this.currentIndex = this.queryResult.length - 1;\n }\n\n // 焦点样式\n const { range, indexNumber } = this.queryResult[this.currentIndex];\n this.jumpToCell({ IndexNumber: indexNumber });\n\n if (range) {\n let i = 0;\n while (this.table.isHeader(0, i)) {\n i++;\n }\n const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;\n range.start.row = row;\n range.end.row = row;\n this.arrangeCustomCellStyle({ range }, true, FocuseHighlightStyleId);\n }\n } else {\n // 普通表格处理\n if (this.currentIndex !== -1) {\n this.arrangeCustomCellStyle(this.queryResult[this.currentIndex]);\n }\n\n this.currentIndex--;\n if (this.currentIndex < 0) {\n this.currentIndex = this.queryResult.length - 1;\n }\n\n const { col, row } = this.queryResult[this.currentIndex];\n this.arrangeCustomCellStyle(this.queryResult[this.currentIndex], true, FocuseHighlightStyleId);\n this.jumpToCell({ col, row });\n }\n\n return {\n index: this.currentIndex,\n results: this.queryResult\n };\n }\n\n jumpToCell(params: { col?: number; row?: number; IndexNumber?: number[] }) {\n if (this.isTree) {\n const { IndexNumber } = params;\n const indexNumbers = [...IndexNumber];\n\n const tmp = [...indexNumbers];\n let tmpNumber = 0;\n let i = 0;\n\n while (tmpNumber < tmp.length - 1) {\n tmpNumber++;\n const indexNumber = indexNumbers.slice(0, tmpNumber);\n\n // 如果是表头就往下偏移\n while (this.table.isHeader(0, i)) {\n i++;\n }\n const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;\n\n const hierarchyState = this.table.getHierarchyState(this.treeIndex, row);\n\n if (hierarchyState !== 'expand') {\n this.table.toggleHierarchyState(this.treeIndex, row);\n }\n }\n this.table.scrollToRow(this.getBodyRowIndexByRecordIndex(indexNumbers) + i, this.scrollOption);\n } else {\n const { col, row } = params;\n // if focus cell out of screen, jump to cell\n const { rowStart, rowEnd } = this.table.getBodyVisibleRowRange();\n const { colStart, colEnd } = this.table.getBodyVisibleColRange();\n if (row <= rowStart || row >= rowEnd || col <= colStart || col >= colEnd) {\n this.table.scrollToCell({ col, row });\n }\n }\n }\n getBodyRowIndexByRecordIndex(index: number | number[]): number {\n if (Array.isArray(index) && index.length === 1) {\n index = index[0];\n }\n return this.table.dataSource.getTableIndex(index);\n }\n clear() {\n // reset highlight cell style\n this.updateCellStyle(false);\n this.queryStr = '';\n this.queryResult = [];\n this.currentIndex = -1;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["search-component/search-component.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAmC3C,MAAM,g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eAAe,GAAG,QAAQ,CAAC,gBAAgB,IAAI,QAAQ,CAAC,eAAe,CAAC;KACzE;IAED,MAAM,iBAAiB,GAAG,eAA8B,CAAC;IAGzD,MAAM,SAAS,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAClD,MAAM,aAAa,GAAG,iBAAiB,CAAC,qBAAqB,EAAE,CAAC;IAGhE,MAAM,cAAc,GAAG,SAAS,CAAC,GAAG,GAAG,aAAa,CAAC,GAAG,GAAG,iBAAiB,CAAC,SAAS,CAAC;IAGvF,MAAM,OAAO,GAAG,cAAc,GAAG,QAAQ,CAAC,GAAG,CAAC;IAC9C,MAAM,UAAU,GAAG,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC;IAC7C,MAAM,eAAe,GAAG,iBAAiB,CAAC,YAAY,CAAC;IACvD,MAAM,SAAS,GAAG,iBAAiB,CAAC,SAAS,CAAC;IAG9C,MAAM,cAAc,GAAG,OAAO,IAAI,SAAS,IAAI,UAAU,IAAI,SAAS,GAAG,eAAe,CAAC;IAEzF,IAAI,CAAC,cAAc,EAAE;QAEnB,IAAI,YAAoB,CAAC;QAEzB,IAAI,OAAO,GAAG,SAAS,EAAE;YAEvB,YAAY,GAAG,OAAO,CAAC;SACxB;aAAM;YAEL,YAAY,GAAG,UAAU,GAAG,eAAe,CAAC;SAC7C;QAGD,iBAAiB,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;KACzD;AACH,CAAC","file":"search-component.js","sourcesContent":["import type * as VTable from '@visactor/vtable';\nimport type { ITableAnimationOption } from '@visactor/vtable/src/ts-types';\nimport type { EasingType } from '@visactor/vtable/src/vrender';\nimport { isValid } from '@visactor/vutils';\ntype IVTable = VTable.ListTable | VTable.PivotTable | VTable.PivotChart;\n\nexport type QueryResult = {\n queryStr: string;\n results: {\n col?: number;\n row?: number;\n value?: string;\n indexNumber?: number[];\n }[];\n};\n\nexport type SearchComponentOption = {\n table: IVTable;\n autoJump?: boolean;\n skipHeader?: boolean;\n highlightCellStyle?: VTable.TYPES.CellStyle;\n /**\n * @deprecated use focusHighlightCellStyle instead\n */\n focuseHighlightCellStyle?: VTable.TYPES.CellStyle;\n focusHighlightCellStyle?: VTable.TYPES.CellStyle;\n queryMethod?: (queryStr: string, value: string, option?: { col: number; row: number; table: IVTable }) => boolean;\n treeQueryMethod?: (queryStr: string, node: any, fieldsToSearch?: string[], option?: { table: IVTable }) => boolean;\n fieldsToSearch?: string[];\n scrollOption?: ITableAnimationOption;\n /**\n * 当开启时,搜索结果会自动滚动到视口范围内\n * @since 1.22.4\n */\n enableViewportScroll?: boolean;\n callback?: (queryResult: QueryResult, table: IVTable) => void;\n};\n\nconst HighlightStyleId = '__search_component_highlight';\nconst FocusHighlightStyleId = '__search_component_focus';\n\nconst defaultHighlightCellStyle: Partial<VTable.TYPES.CellStyle> = {\n bgColor: 'rgba(255, 255, 0, 0.2)'\n};\n\nconst defaultFocusHighlightCellStyle: Partial<VTable.TYPES.CellStyle> = {\n bgColor: 'rgba(255, 155, 0, 0.2)'\n};\n\nfunction defaultQueryMethod(queryStr: string, value: string) {\n return isValid(queryStr) && isValid(value) && value.toString().includes(queryStr);\n}\nfunction defaultTreeQueryMethod(queryStr: string, node: any, fieldsToSearch?: string[]) {\n if (!isValid(queryStr)) {\n return false;\n }\n\n // 如果没有传 fieldsToSearch,则用 node 的全部 key\n const searchFields = Array.isArray(fieldsToSearch) && fieldsToSearch.length > 0 ? fieldsToSearch : Object.keys(node);\n\n return searchFields.some(field => isValid(node?.[field]) && node[field].toString().includes(queryStr));\n}\nexport class SearchComponent {\n table: IVTable;\n skipHeader: boolean;\n autoJump: boolean;\n highlightCellStyle: Partial<VTable.TYPES.CellStyle>;\n focuseHighlightCellStyle: Partial<VTable.TYPES.CellStyle>;\n focusHighlightCellStyle: Partial<VTable.TYPES.CellStyle>;\n queryMethod: (queryStr: string, value: string, option: { col: number; row: number; table: IVTable }) => boolean;\n treeQueryMethod: (queryStr: string, node: any, fieldsToSearch?: string[], option?: { table: IVTable }) => boolean;\n fieldsToSearch: string[];\n enableViewportScroll?: boolean;\n callback?: (queryResult: QueryResult, table: IVTable) => void;\n\n queryStr: string;\n queryResult: {\n col?: number;\n row?: number;\n range?: VTable.TYPES.CellRange;\n value?: string;\n indexNumber?: number[];\n }[];\n\n currentIndex: number;\n isTree: boolean;\n treeIndex: number;\n scrollOption: ITableAnimationOption;\n\n constructor(option: SearchComponentOption) {\n this.table = option.table;\n this.autoJump = option.autoJump || false;\n this.skipHeader = option.skipHeader || false;\n this.highlightCellStyle = option.highlightCellStyle || defaultHighlightCellStyle;\n this.focusHighlightCellStyle =\n // 兼容兜底处理,修复拼写错误的问题\n option.focusHighlightCellStyle || option.focuseHighlightCellStyle || defaultFocusHighlightCellStyle;\n this.queryMethod = option.queryMethod || defaultQueryMethod;\n this.treeQueryMethod = option.treeQueryMethod || defaultTreeQueryMethod;\n this.fieldsToSearch = option.fieldsToSearch || [];\n this.isTree = false;\n this.treeIndex = 0;\n this.callback = option.callback;\n this.scrollOption =\n option.scrollOption || ({ duration: 900, easing: 'quartIn' as EasingType } as ITableAnimationOption);\n this.enableViewportScroll = option.enableViewportScroll || false;\n this.table.registerCustomCellStyle(HighlightStyleId, this.highlightCellStyle as any);\n this.table.registerCustomCellStyle(FocusHighlightStyleId, this.focusHighlightCellStyle as any);\n }\n\n search(str: string) {\n this.clear();\n this.queryStr = str;\n\n if (!str) {\n return {\n index: 0,\n results: this.queryResult\n };\n }\n this.isTree = this.table.options.columns.some((item: any) => item.tree);\n this.treeIndex = this.isTree ? this.table.options.columns.findIndex((item: any) => item.tree) : 0;\n if (this.isTree) {\n // 如果传入单一节点也能处理\n const colEnd = this.table.colCount;\n const walk = (nodes: any[], path: number[]) => {\n nodes.forEach((item: any, idx: number) => {\n const currentPath = [...path, idx]; // 当前节点的完整路径\n\n // 保持你的 treeQueryMethod 调用方式(this 上下文来自定义环境)\n if (this.treeQueryMethod(this.queryStr, item, this.fieldsToSearch, { table: this.table })) {\n this.queryResult.push({\n indexNumber: currentPath,\n range: {\n start: { row: null, col: 0 },\n end: { row: null, col: colEnd }\n }\n });\n }\n\n if (item.children && Array.isArray(item.children) && item.children.length > 0) {\n walk(item.children, currentPath);\n }\n });\n };\n\n walk(this.table.records, []);\n if (this.queryResult.length > 0) {\n this.jumpToCell({ IndexNumber: this.queryResult[0].indexNumber });\n }\n\n if (this.callback) {\n this.callback(\n {\n queryStr: this.queryStr,\n results: this.queryResult\n },\n this.table\n );\n }\n this.updateCellStyle();\n\n // if (this.autoJump) {\n // return this.next();\n // }\n this.currentIndex = 0;\n\n return {\n index: 0,\n results: this.queryResult\n };\n }\n for (let row = 0; row < this.table.rowCount; row++) {\n for (let col = 0; col < this.table.colCount; col++) {\n if (this.skipHeader && this.table.isHeader(col, row)) {\n continue;\n }\n const value = this.table.getCellValue(col, row);\n if (this.queryMethod(this.queryStr, value, { col, row, table: this.table })) {\n // deal merge cell\n const mergeCell = this.table.getCellRange(col, row);\n if (mergeCell.start.col !== mergeCell.end.col || mergeCell.start.row !== mergeCell.end.row) {\n // find is cell already in queryResult\n let isIn = false;\n for (let i = this.queryResult.length - 1; i >= 0; i--) {\n if (this.queryResult[i].col === mergeCell.start.col && this.queryResult[i].row === mergeCell.start.row) {\n isIn = true;\n break;\n }\n }\n if (!isIn) {\n this.queryResult.push({\n col: mergeCell.start.col,\n row: mergeCell.start.row,\n range: mergeCell,\n value\n });\n }\n } else {\n this.queryResult.push({\n col,\n row,\n value\n });\n }\n }\n }\n }\n this.updateCellStyle();\n\n if (this.callback) {\n this.callback(\n {\n queryStr: this.queryStr,\n results: this.queryResult\n },\n this.table\n );\n }\n\n if (this.autoJump) {\n return this.next();\n }\n return {\n index: 0,\n results: this.queryResult\n };\n }\n\n /**\n * @description: 为查询结果项设置自定义单元格样式\n * @param {(typeof this.queryResult)[number]} resultItem 查询结果项\n * @param {boolean} highlight 是否高亮\n * @param {string} customStyleId 自定义样式ID\n */\n arrangeCustomCellStyle(\n resultItem: (typeof this.queryResult)[number],\n highlight: boolean = true,\n customStyleId: string = HighlightStyleId\n ) {\n const { col, row, range } = resultItem;\n this.table.arrangeCustomCellStyle(\n range\n ? { range }\n : {\n row,\n col\n },\n highlight ? customStyleId : null\n );\n }\n\n updateCellStyle(highlight: boolean = true) {\n if (!highlight) {\n (this.queryResult || []).forEach(resultItem => {\n this.arrangeCustomCellStyle(resultItem, highlight);\n });\n return;\n }\n if (!this.queryResult) {\n return;\n }\n\n if (!this.table.hasCustomCellStyle(HighlightStyleId)) {\n this.table.registerCustomCellStyle(HighlightStyleId, this.highlightCellStyle as any);\n }\n if (!this.table.hasCustomCellStyle(FocusHighlightStyleId)) {\n this.table.registerCustomCellStyle(FocusHighlightStyleId, this.focusHighlightCellStyle as any);\n }\n if (this.isTree) {\n const { range, indexNumber } = this.queryResult[0];\n\n let i = 0;\n\n // 如果是表头就往下偏移\n while (this.table.isHeader(0, i)) {\n i++;\n }\n const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;\n range.start.row = row;\n range.end.row = row;\n\n this.arrangeCustomCellStyle(\n {\n range\n },\n highlight,\n FocusHighlightStyleId\n );\n } else {\n for (let i = 0; i < this.queryResult.length; i++) {\n this.arrangeCustomCellStyle(this.queryResult[i], highlight);\n }\n }\n }\n\n next() {\n if (!this.queryResult.length) {\n return {\n index: 0,\n results: this.queryResult\n };\n }\n if (this.isTree) {\n if (this.currentIndex !== -1) {\n const { range, indexNumber } = this.queryResult[this.currentIndex];\n\n if (range) {\n let i = 0;\n\n // 如果是表头就往下偏移\n while (this.table.isHeader(0, i)) {\n i++;\n }\n const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;\n range.start.row = row;\n range.end.row = row;\n this.arrangeCustomCellStyle({ range });\n }\n }\n\n this.currentIndex++;\n if (this.currentIndex >= this.queryResult.length) {\n this.currentIndex = 0;\n }\n const { range, indexNumber } = this.queryResult[this.currentIndex];\n this.jumpToCell({ IndexNumber: indexNumber });\n\n if (range) {\n let i = 0;\n\n // 如果是表头就往下偏移\n while (this.table.isHeader(0, i)) {\n i++;\n }\n const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;\n range.start.row = row;\n range.end.row = row;\n this.arrangeCustomCellStyle(\n {\n range\n },\n true,\n FocusHighlightStyleId\n );\n }\n } else {\n if (this.currentIndex !== -1) {\n // reset last focus\n this.arrangeCustomCellStyle(this.queryResult[this.currentIndex]);\n }\n this.currentIndex++;\n if (this.currentIndex >= this.queryResult.length) {\n this.currentIndex = 0;\n }\n const { col, row } = this.queryResult[this.currentIndex];\n\n this.arrangeCustomCellStyle(this.queryResult[this.currentIndex], true, FocusHighlightStyleId);\n\n this.jumpToCell({ col, row });\n }\n\n return {\n index: this.currentIndex,\n results: this.queryResult\n };\n }\n\n prev() {\n if (!this.queryResult.length) {\n return {\n index: 0,\n results: this.queryResult\n };\n }\n\n if (this.isTree) {\n // 先取消当前高亮\n if (this.currentIndex !== -1) {\n const { range, indexNumber } = this.queryResult[this.currentIndex];\n if (range) {\n let i = 0;\n while (this.table.isHeader(0, i)) {\n i++;\n }\n const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;\n range.start.row = row;\n range.end.row = row;\n this.arrangeCustomCellStyle({ range });\n }\n }\n\n // 索引向前\n this.currentIndex--;\n if (this.currentIndex < 0) {\n this.currentIndex = this.queryResult.length - 1;\n }\n\n // 焦点样式\n const { range, indexNumber } = this.queryResult[this.currentIndex];\n this.jumpToCell({ IndexNumber: indexNumber });\n\n if (range) {\n let i = 0;\n while (this.table.isHeader(0, i)) {\n i++;\n }\n const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;\n range.start.row = row;\n range.end.row = row;\n this.arrangeCustomCellStyle({ range }, true, FocusHighlightStyleId);\n }\n } else {\n // 普通表格处理\n if (this.currentIndex !== -1) {\n this.arrangeCustomCellStyle(this.queryResult[this.currentIndex]);\n }\n\n this.currentIndex--;\n if (this.currentIndex < 0) {\n this.currentIndex = this.queryResult.length - 1;\n }\n\n const { col, row } = this.queryResult[this.currentIndex];\n this.arrangeCustomCellStyle(this.queryResult[this.currentIndex], true, FocusHighlightStyleId);\n this.jumpToCell({ col, row });\n }\n\n return {\n index: this.currentIndex,\n results: this.queryResult\n };\n }\n\n jumpToCell(params: { col?: number; row?: number; IndexNumber?: number[] }) {\n if (this.isTree) {\n const { IndexNumber } = params;\n const indexNumbers = [...IndexNumber];\n\n const tmp = [...indexNumbers];\n let tmpNumber = 0;\n let i = 0;\n\n // 展开树形结构的父节点\n while (tmpNumber < tmp.length - 1) {\n tmpNumber++;\n const indexNumber = indexNumbers.slice(0, tmpNumber);\n\n // 跳过表头行\n while (this.table.isHeader(0, i)) {\n i++;\n }\n const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;\n\n const hierarchyState = this.table.getHierarchyState(this.treeIndex, row);\n if (hierarchyState !== 'expand') {\n this.table.toggleHierarchyState(this.treeIndex, row);\n }\n }\n\n const finalRow = this.getBodyRowIndexByRecordIndex(indexNumbers) + i;\n\n // 根据配置决定是否滚动表格\n this.table.scrollToRow(finalRow, this.scrollOption);\n\n // 根据配置决定是否滚动页面\n if (this.enableViewportScroll) {\n scrollVTableCellIntoView(this.table, { row: finalRow, col: this.treeIndex });\n }\n } else {\n const { col, row } = params;\n const { rowStart, rowEnd } = this.table.getBodyVisibleRowRange();\n const { colStart, colEnd } = this.table.getBodyVisibleColRange();\n\n // 检查单元格是否在表格可视范围内\n const isInTableView = !(row <= rowStart || row >= rowEnd || col <= colStart || col >= colEnd);\n\n // 根据配置决定是否滚动表格\n if (!isInTableView) {\n this.table.scrollToCell({ col, row });\n }\n\n // 根据配置决定是否滚动页面\n if (this.enableViewportScroll) {\n scrollVTableCellIntoView(this.table, { row, col });\n }\n }\n }\n getBodyRowIndexByRecordIndex(index: number | number[]): number {\n if (Array.isArray(index) && index.length === 1) {\n index = index[0];\n }\n return this.table.dataSource.getTableIndex(index);\n }\n clear() {\n // reset highlight cell style\n this.updateCellStyle(false);\n this.queryStr = '';\n this.queryResult = [];\n this.currentIndex = -1;\n }\n}\n\nfunction scrollVTableCellIntoView(table: IVTable, cellInfo: { row: number; col: number }): void {\n if (typeof document === 'undefined' || typeof window === 'undefined') {\n return;\n }\n\n const tableEl = table.getElement?.() || table.container;\n if (!tableEl) {\n return;\n }\n\n // 获取单元格在表格中的位置信息\n const cellRect = table.getCellRect(cellInfo.col, cellInfo.row);\n if (!cellRect) {\n return;\n }\n\n // 查找最近的可滚动父容器\n let scrollContainer: Element | null = tableEl.parentElement;\n while (scrollContainer) {\n const computedStyle = getComputedStyle(scrollContainer);\n const hasScroll = /(auto|scroll|overlay)/.test(computedStyle.overflowY);\n const canScroll = scrollContainer.scrollHeight > scrollContainer.clientHeight;\n\n if (hasScroll && canScroll) {\n break;\n }\n\n // 向上查找父元素,包括 Shadow DOM 情况\n scrollContainer = scrollContainer.parentElement || (scrollContainer.getRootNode?.() as ShadowRoot)?.host || null;\n }\n\n // 如果没找到可滚动容器,使用 document\n if (!scrollContainer) {\n scrollContainer = document.scrollingElement || document.documentElement;\n }\n\n const scrollContainerEl = scrollContainer as HTMLElement;\n\n // 计算单元格在滚动容器中的绝对位置\n const tableRect = tableEl.getBoundingClientRect();\n const containerRect = scrollContainerEl.getBoundingClientRect();\n\n // 表格相对于滚动容器的位置\n const tableOffsetTop = tableRect.top - containerRect.top + scrollContainerEl.scrollTop;\n\n // 单元格在滚动容器中的绝对位置\n const cellTop = tableOffsetTop + cellRect.top;\n const cellBottom = cellTop + cellRect.height;\n const containerHeight = scrollContainerEl.clientHeight;\n const scrollTop = scrollContainerEl.scrollTop;\n\n // 检查单元格是否完全可见\n const isFullyVisible = cellTop >= scrollTop && cellBottom <= scrollTop + containerHeight;\n\n if (!isFullyVisible) {\n // 计算新的滚动位置\n let newScrollTop: number;\n\n if (cellTop < scrollTop) {\n // 单元格在上方,滚动到单元格顶部\n newScrollTop = cellTop;\n } else {\n // 单元格在下方,滚动到单元格底部对齐容器底部\n newScrollTop = cellBottom - containerHeight;\n }\n\n // 确保滚动位置不小于 0\n scrollContainerEl.scrollTop = Math.max(0, newScrollTop);\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visactor/vtable-search",
|
|
3
|
-
"version": "1.22.4
|
|
3
|
+
"version": "1.22.4",
|
|
4
4
|
"description": "The search util of VTable",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "VisActor",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@visactor/
|
|
34
|
-
"@visactor/
|
|
33
|
+
"@visactor/vutils": "~0.19.1",
|
|
34
|
+
"@visactor/vtable": "1.22.4"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"cross-env": "^7.0.3",
|
|
@@ -77,8 +77,8 @@
|
|
|
77
77
|
"axios": "^1.4.0",
|
|
78
78
|
"@types/react-is": "^17.0.3",
|
|
79
79
|
"rollup-plugin-node-resolve": "5.2.0",
|
|
80
|
-
"@internal/eslint-config": "0.0.1",
|
|
81
80
|
"@internal/bundler": "0.0.1",
|
|
81
|
+
"@internal/eslint-config": "0.0.1",
|
|
82
82
|
"@internal/ts-config": "0.0.1"
|
|
83
83
|
},
|
|
84
84
|
"scripts": {
|