@visactor/vtable-search 1.26.0 → 1.26.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -61,6 +61,11 @@ export declare class SearchComponent {
61
61
  treeIndex: number;
62
62
  scrollOption: ITableAnimationOption;
63
63
  constructor(option: SearchComponentOption);
64
+ private getHeaderOffset;
65
+ private getHeaderCellAddressByField;
66
+ private getTreeCol;
67
+ private getVisibleTreeCell;
68
+ private clearRenderedCellStyles;
64
69
  search(str: string): {
65
70
  index: number;
66
71
  results: {
@@ -33,40 +33,93 @@ class SearchComponent {
33
33
  }, this.enableViewportScroll = option.enableViewportScroll || !1, this.table.registerCustomCellStyle(HighlightStyleId, this.highlightCellStyle),
34
34
  this.table.registerCustomCellStyle(FocusHighlightStyleId, this.focusHighlightCellStyle);
35
35
  }
36
+ getHeaderOffset() {
37
+ let offset = 0;
38
+ for (;this.table.isHeader(0, offset); ) offset++;
39
+ return offset;
40
+ }
41
+ getHeaderCellAddressByField(field) {
42
+ var _a, _b;
43
+ const layoutMap = null === (_a = this.table.internalProps) || void 0 === _a ? void 0 : _a.layoutMap;
44
+ return null === (_b = null == layoutMap ? void 0 : layoutMap.getHeaderCellAddressByField) || void 0 === _b ? void 0 : _b.call(layoutMap, field);
45
+ }
46
+ getTreeCol() {
47
+ var _a, _b, _c;
48
+ const treeColumn = null === (_c = null === (_b = null === (_a = this.table) || void 0 === _a ? void 0 : _a.options) || void 0 === _b ? void 0 : _b.columns) || void 0 === _c ? void 0 : _c.find((c => null == c ? void 0 : c.tree)), field = null == treeColumn ? void 0 : treeColumn.field;
49
+ if ("string" == typeof field && field) {
50
+ const addr = this.getHeaderCellAddressByField(field);
51
+ if (addr && "number" == typeof addr.col) return addr.col;
52
+ }
53
+ return this.treeIndex;
54
+ }
55
+ getVisibleTreeCell(resultItem) {
56
+ if (!resultItem.indexNumber) return;
57
+ const rawIndex = this.getBodyRowIndexByRecordIndex(resultItem.indexNumber);
58
+ return rawIndex < 0 ? void 0 : {
59
+ col: "number" == typeof resultItem.col ? resultItem.col : this.getTreeCol(),
60
+ row: rawIndex + this.getHeaderOffset()
61
+ };
62
+ }
63
+ clearRenderedCellStyles() {
64
+ const plugin = this.table.customCellStylePlugin, cellsToRefresh = [];
65
+ Array.from((null == plugin ? void 0 : plugin.customCellStyleArrangement) || []).forEach((item => {
66
+ const cellPosition = null == item ? void 0 : item.cellPosition;
67
+ "number" == typeof (null == cellPosition ? void 0 : cellPosition.col) && "number" == typeof (null == cellPosition ? void 0 : cellPosition.row) && cellsToRefresh.push({
68
+ col: cellPosition.col,
69
+ row: cellPosition.row
70
+ });
71
+ })), plugin.clearCustomCellStyleArrangement(), cellsToRefresh.forEach((({col: col, row: row}) => {
72
+ this.table.scenegraph.updateCellContent(col, row, !0);
73
+ }));
74
+ }
36
75
  search(str) {
76
+ var _a;
37
77
  if (this.clear(), this.queryStr = str, !str) return {
38
78
  index: 0,
39
79
  results: this.queryResult
40
80
  };
41
81
  if (this.isTree = this.table.options.columns.some((item => item.tree)), this.treeIndex = this.isTree ? this.table.options.columns.findIndex((item => item.tree)) : 0,
42
82
  this.isTree) {
43
- const colEnd = this.table.colCount, walk = (nodes, path) => {
83
+ const treeCol = this.getTreeCol(), walk = (nodes, path) => {
44
84
  nodes.forEach(((item, idx) => {
45
- const currentPath = [ ...path, idx ];
46
- this.treeQueryMethod(this.queryStr, item, this.fieldsToSearch, {
85
+ const currentPath = [ ...path, idx ], searchFields = Array.isArray(this.fieldsToSearch) && this.fieldsToSearch.length > 0 ? this.fieldsToSearch : Object.keys(item);
86
+ let hitAnyField = !1;
87
+ searchFields.forEach((field => {
88
+ var _a, _b, _c, _d;
89
+ const value = null == item ? void 0 : item[field];
90
+ if (!(0, vutils_1.isValid)(value)) return;
91
+ const col = null !== (_b = null === (_a = this.getHeaderCellAddressByField(field)) || void 0 === _a ? void 0 : _a.col) && void 0 !== _b ? _b : treeCol;
92
+ this.queryMethod(this.queryStr, value, {
93
+ col: col,
94
+ row: 0,
95
+ table: this.table
96
+ }) && (hitAnyField = !0, this.queryResult.push({
97
+ indexNumber: currentPath,
98
+ col: col,
99
+ value: null !== (_d = null === (_c = null == value ? void 0 : value.toString) || void 0 === _c ? void 0 : _c.call(value)) && void 0 !== _d ? _d : String(value)
100
+ }));
101
+ })), !hitAnyField && this.treeQueryMethod && this.treeQueryMethod(this.queryStr, item, this.fieldsToSearch, {
47
102
  table: this.table
48
103
  }) && this.queryResult.push({
49
104
  indexNumber: currentPath,
50
- range: {
51
- start: {
52
- row: null,
53
- col: 0
54
- },
55
- end: {
56
- row: null,
57
- col: colEnd
58
- }
59
- }
105
+ col: treeCol
60
106
  }), item.children && Array.isArray(item.children) && item.children.length > 0 && walk(item.children, currentPath);
61
107
  }));
62
108
  };
63
- return walk(this.table.records, []), this.queryResult.length > 0 && this.jumpToCell({
64
- IndexNumber: this.queryResult[0].indexNumber
109
+ walk(this.table.records, []);
110
+ const dedup = new Set;
111
+ return this.queryResult = this.queryResult.filter((r => {
112
+ var _a;
113
+ const key = `${(r.indexNumber || []).join(".")}:${null !== (_a = r.col) && void 0 !== _a ? _a : ""}`;
114
+ return !dedup.has(key) && (dedup.add(key), !0);
115
+ })), this.currentIndex = this.queryResult.length > 0 ? 0 : -1, this.queryResult.length > 0 && this.jumpToCell({
116
+ IndexNumber: this.queryResult[0].indexNumber,
117
+ col: null !== (_a = this.queryResult[0].col) && void 0 !== _a ? _a : treeCol
65
118
  }), this.callback && this.callback({
66
119
  queryStr: this.queryStr,
67
120
  results: this.queryResult
68
- }, this.table), this.updateCellStyle(), this.currentIndex = 0, {
69
- index: 0,
121
+ }, this.table), this.updateCellStyle(), {
122
+ index: this.currentIndex >= 0 ? this.currentIndex : 0,
70
123
  results: this.queryResult
71
124
  };
72
125
  }
@@ -116,20 +169,26 @@ class SearchComponent {
116
169
  }, highlight ? customStyleId : null);
117
170
  }
118
171
  updateCellStyle(highlight = !0) {
119
- if (!highlight) return this.table.customCellStylePlugin.clearCustomCellStyleArrangement(),
120
- (this.queryResult || []).forEach((resultItem => {
121
- this.table.scenegraph.updateCellContent(resultItem.col, resultItem.row);
122
- })), void this.table.scenegraph.updateNextFrame();
172
+ if (!highlight) return this.clearRenderedCellStyles(), void this.table.scenegraph.updateNextFrame();
123
173
  if (this.queryResult) if (this.table.hasCustomCellStyle(HighlightStyleId) || this.table.registerCustomCellStyle(HighlightStyleId, this.highlightCellStyle),
124
174
  this.table.hasCustomCellStyle(FocusHighlightStyleId) || this.table.registerCustomCellStyle(FocusHighlightStyleId, this.focusHighlightCellStyle),
125
- this.isTree) {
126
- const {range: range, indexNumber: indexNumber} = this.queryResult[0];
127
- let i = 0;
128
- for (;this.table.isHeader(0, i); ) i++;
129
- const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;
130
- range.start.row = row, range.end.row = row, this.arrangeCustomCellStyle({
131
- range: range
132
- }, highlight, FocusHighlightStyleId);
175
+ this.clearRenderedCellStyles(), this.isTree) {
176
+ if (!this.queryResult.length) return void this.table.scenegraph.updateNextFrame();
177
+ for (let i = 0; i < this.queryResult.length; i++) {
178
+ const cell = this.getVisibleTreeCell(this.queryResult[i]);
179
+ cell && (this.table.customCellStylePlugin.addCustomCellStyleArrangement({
180
+ col: cell.col,
181
+ row: cell.row
182
+ }, HighlightStyleId), this.table.scenegraph.updateCellContent(cell.col, cell.row, !0));
183
+ }
184
+ if (this.currentIndex >= 0 && this.currentIndex < this.queryResult.length) {
185
+ const cell = this.getVisibleTreeCell(this.queryResult[this.currentIndex]);
186
+ cell && (this.table.customCellStylePlugin.addCustomCellStyleArrangement({
187
+ col: cell.col,
188
+ row: cell.row
189
+ }, FocusHighlightStyleId), this.table.scenegraph.updateCellContent(cell.col, cell.row, !0));
190
+ }
191
+ this.table.scenegraph.updateNextFrame();
133
192
  } else {
134
193
  for (let i = 0; i < this.queryResult.length; i++) this.table.customCellStylePlugin.addCustomCellStyleArrangement({
135
194
  col: this.queryResult[i].col,
@@ -144,29 +203,12 @@ class SearchComponent {
144
203
  results: this.queryResult
145
204
  };
146
205
  if (this.isTree) {
147
- if (-1 !== this.currentIndex) {
148
- const {range: range, indexNumber: indexNumber} = this.queryResult[this.currentIndex];
149
- if (range) {
150
- let i = 0;
151
- for (;this.table.isHeader(0, i); ) i++;
152
- const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;
153
- range.start.row = row, range.end.row = row, this.arrangeCustomCellStyle({
154
- range: range
155
- });
156
- }
157
- }
158
206
  this.currentIndex++, this.currentIndex >= this.queryResult.length && (this.currentIndex = 0);
159
- const {range: range, indexNumber: indexNumber} = this.queryResult[this.currentIndex];
160
- if (this.jumpToCell({
161
- IndexNumber: indexNumber
162
- }), range) {
163
- let i = 0;
164
- for (;this.table.isHeader(0, i); ) i++;
165
- const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;
166
- range.start.row = row, range.end.row = row, this.arrangeCustomCellStyle({
167
- range: range
168
- }, !0, FocusHighlightStyleId);
169
- }
207
+ const {indexNumber: indexNumber, col: col} = this.queryResult[this.currentIndex];
208
+ this.jumpToCell({
209
+ IndexNumber: indexNumber,
210
+ col: col
211
+ }), this.updateCellStyle();
170
212
  } else {
171
213
  -1 !== this.currentIndex && this.arrangeCustomCellStyle(this.queryResult[this.currentIndex]),
172
214
  this.currentIndex++, this.currentIndex >= this.queryResult.length && (this.currentIndex = 0);
@@ -188,29 +230,12 @@ class SearchComponent {
188
230
  results: this.queryResult
189
231
  };
190
232
  if (this.isTree) {
191
- if (-1 !== this.currentIndex) {
192
- const {range: range, indexNumber: indexNumber} = this.queryResult[this.currentIndex];
193
- if (range) {
194
- let i = 0;
195
- for (;this.table.isHeader(0, i); ) i++;
196
- const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;
197
- range.start.row = row, range.end.row = row, this.arrangeCustomCellStyle({
198
- range: range
199
- });
200
- }
201
- }
202
233
  this.currentIndex--, this.currentIndex < 0 && (this.currentIndex = this.queryResult.length - 1);
203
- const {range: range, indexNumber: indexNumber} = this.queryResult[this.currentIndex];
204
- if (this.jumpToCell({
205
- IndexNumber: indexNumber
206
- }), range) {
207
- let i = 0;
208
- for (;this.table.isHeader(0, i); ) i++;
209
- const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;
210
- range.start.row = row, range.end.row = row, this.arrangeCustomCellStyle({
211
- range: range
212
- }, !0, FocusHighlightStyleId);
213
- }
234
+ const {indexNumber: indexNumber, col: col} = this.queryResult[this.currentIndex];
235
+ this.jumpToCell({
236
+ IndexNumber: indexNumber,
237
+ col: col
238
+ }), this.updateCellStyle();
214
239
  } else {
215
240
  -1 !== this.currentIndex && this.arrangeCustomCellStyle(this.queryResult[this.currentIndex]),
216
241
  this.currentIndex--, this.currentIndex < 0 && (this.currentIndex = this.queryResult.length - 1);
@@ -237,10 +262,13 @@ class SearchComponent {
237
262
  const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;
238
263
  "expand" !== this.table.getHierarchyState(this.treeIndex, row) && this.table.toggleHierarchyState(this.treeIndex, row);
239
264
  }
240
- const finalRow = this.getBodyRowIndexByRecordIndex(indexNumbers) + i;
241
- this.table.scrollToRow(finalRow, this.scrollOption), this.enableViewportScroll && scrollVTableCellIntoView(this.table, {
265
+ const finalRow = this.getBodyRowIndexByRecordIndex(indexNumbers) + i, targetCol = "number" == typeof params.col ? params.col : this.getTreeCol();
266
+ this.table.scrollToCell({
267
+ row: finalRow,
268
+ col: targetCol
269
+ }, this.scrollOption), this.enableViewportScroll && scrollVTableCellIntoView(this.table, {
242
270
  row: finalRow,
243
- col: this.treeIndex
271
+ col: targetCol
244
272
  });
245
273
  } else {
246
274
  const {col: col, row: row} = params, {rowStart: rowStart, rowEnd: rowEnd} = this.table.getBodyVisibleRowRange(), {colStart: colStart, colEnd: colEnd} = this.table.getBodyVisibleColRange();
@@ -1 +1 @@
1
- {"version":3,"sources":["search-component/search-component.ts"],"names":[],"mappings":";;;AAGA,6CAA2C;AAmC3C,MAAM,gBAAgB,GAAG,8BAA8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Ac,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 this.table.customCellStylePlugin.clearCustomCellStyleArrangement();\n (this.queryResult || []).forEach(resultItem => {\n this.table.scenegraph.updateCellContent(resultItem.col, resultItem.row);\n });\n this.table.scenegraph.updateNextFrame();\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 for (let i = 0; i < this.queryResult.length; i++) {\n this.table.customCellStylePlugin.addCustomCellStyleArrangement(\n {\n col: this.queryResult[i].col,\n row: this.queryResult[i].row\n },\n HighlightStyleId\n );\n this.table.scenegraph.updateCellContent(this.queryResult[i].col, this.queryResult[i].row, true);\n }\n this.table.scenegraph.updateNextFrame();\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"]}
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,8B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AC,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 private getHeaderOffset(): number {\n let offset = 0;\n while (this.table.isHeader(0, offset)) {\n offset++;\n }\n return offset;\n }\n\n private getHeaderCellAddressByField(field: string): { col: number; row: number } | undefined {\n // PivotTable/ListTable share internal layoutMap API but it's not exposed on the public type.\n const layoutMap = (this.table as any).internalProps?.layoutMap;\n return layoutMap?.getHeaderCellAddressByField?.(field);\n }\n\n private getTreeCol(): number {\n const treeColumn = (this.table as any)?.options?.columns?.find((c: any) => c?.tree);\n const field = treeColumn?.field;\n if (typeof field === 'string' && field) {\n const addr = this.getHeaderCellAddressByField(field);\n if (addr && typeof addr.col === 'number') {\n return addr.col;\n }\n }\n // Fallback to previous behavior.\n return this.treeIndex;\n }\n\n private getVisibleTreeCell(resultItem: typeof this.queryResult[number]): { col: number; row: number } | undefined {\n if (!resultItem.indexNumber) {\n return undefined;\n }\n const rawIndex = this.getBodyRowIndexByRecordIndex(resultItem.indexNumber);\n if (rawIndex < 0) {\n return undefined;\n }\n return {\n col: typeof resultItem.col === 'number' ? resultItem.col : this.getTreeCol(),\n row: rawIndex + this.getHeaderOffset()\n };\n }\n\n private clearRenderedCellStyles() {\n const plugin = this.table.customCellStylePlugin;\n const cellsToRefresh: { col: number; row: number }[] = [];\n const arrangements = Array.from((plugin as any)?.customCellStyleArrangement || []);\n\n arrangements.forEach((item: any) => {\n const cellPosition = item?.cellPosition;\n if (typeof cellPosition?.col === 'number' && typeof cellPosition?.row === 'number') {\n cellsToRefresh.push({\n col: cellPosition.col,\n row: cellPosition.row\n });\n }\n });\n\n plugin.clearCustomCellStyleArrangement();\n cellsToRefresh.forEach(({ col, row }) => {\n this.table.scenegraph.updateCellContent(col, row, true);\n });\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 treeCol = this.getTreeCol();\n const walk = (nodes: any[], path: number[]) => {\n nodes.forEach((item: any, idx: number) => {\n const currentPath = [...path, idx]; // 当前节点的完整路径\n\n // 为了做到“单元格级别高亮”,优先按字段匹配并映射到具体列。\n const searchFields =\n Array.isArray(this.fieldsToSearch) && this.fieldsToSearch.length > 0\n ? this.fieldsToSearch\n : Object.keys(item);\n\n let hitAnyField = false;\n searchFields.forEach(field => {\n const value = item?.[field];\n if (!isValid(value)) {\n return;\n }\n const col = this.getHeaderCellAddressByField(field)?.col ?? treeCol;\n // row 在树形场景下要在展开后才能准确计算,这里传 0 仅用于自定义 queryMethod 的兼容参数。\n if (this.queryMethod(this.queryStr, value, { col, row: 0, table: this.table })) {\n hitAnyField = true;\n this.queryResult.push({\n indexNumber: currentPath,\n col,\n value: value?.toString?.() ?? String(value)\n });\n }\n });\n\n // 兼容旧用法:如果用户自定义 treeQueryMethod 命中但字段级别未命中,则至少高亮树列。\n if (\n !hitAnyField &&\n this.treeQueryMethod &&\n this.treeQueryMethod(this.queryStr, item, this.fieldsToSearch, { table: this.table })\n ) {\n this.queryResult.push({\n indexNumber: currentPath,\n col: treeCol\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 // 同一节点同一列可能被多次命中(例如 fieldsToSearch 未限制且字段值重复),做一次简单去重\n const dedup = new Set<string>();\n this.queryResult = this.queryResult.filter(r => {\n const key = `${(r.indexNumber || []).join('.')}:${r.col ?? ''}`;\n if (dedup.has(key)) {\n return false;\n }\n dedup.add(key);\n return true;\n });\n\n this.currentIndex = this.queryResult.length > 0 ? 0 : -1;\n\n if (this.queryResult.length > 0) {\n this.jumpToCell({ IndexNumber: this.queryResult[0].indexNumber, col: this.queryResult[0].col ?? treeCol });\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 return {\n index: this.currentIndex >= 0 ? this.currentIndex : 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.clearRenderedCellStyles();\n this.table.scenegraph.updateNextFrame();\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\n this.clearRenderedCellStyles();\n\n if (this.isTree) {\n if (!this.queryResult.length) {\n this.table.scenegraph.updateNextFrame();\n return;\n }\n\n // 先为所有命中节点打普通高亮\n for (let i = 0; i < this.queryResult.length; i++) {\n const cell = this.getVisibleTreeCell(this.queryResult[i]);\n if (!cell) {\n continue;\n }\n this.table.customCellStylePlugin.addCustomCellStyleArrangement(\n {\n col: cell.col,\n row: cell.row\n },\n HighlightStyleId\n );\n this.table.scenegraph.updateCellContent(cell.col, cell.row, true);\n }\n\n // 再为当前索引打焦点高亮\n if (this.currentIndex >= 0 && this.currentIndex < this.queryResult.length) {\n const cell = this.getVisibleTreeCell(this.queryResult[this.currentIndex]);\n if (cell) {\n this.table.customCellStylePlugin.addCustomCellStyleArrangement(\n {\n col: cell.col,\n row: cell.row\n },\n FocusHighlightStyleId\n );\n this.table.scenegraph.updateCellContent(cell.col, cell.row, true);\n }\n }\n\n this.table.scenegraph.updateNextFrame();\n } else {\n for (let i = 0; i < this.queryResult.length; i++) {\n this.table.customCellStylePlugin.addCustomCellStyleArrangement(\n {\n col: this.queryResult[i].col,\n row: this.queryResult[i].row\n },\n HighlightStyleId\n );\n this.table.scenegraph.updateCellContent(this.queryResult[i].col, this.queryResult[i].row, true);\n }\n this.table.scenegraph.updateNextFrame();\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 this.currentIndex++;\n if (this.currentIndex >= this.queryResult.length) {\n this.currentIndex = 0;\n }\n const { indexNumber, col } = this.queryResult[this.currentIndex];\n this.jumpToCell({ IndexNumber: indexNumber, col });\n this.updateCellStyle();\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 this.currentIndex--;\n if (this.currentIndex < 0) {\n this.currentIndex = this.queryResult.length - 1;\n }\n\n const { indexNumber, col } = this.queryResult[this.currentIndex];\n this.jumpToCell({ IndexNumber: indexNumber, col });\n this.updateCellStyle();\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 const targetCol = typeof params.col === 'number' ? params.col : this.getTreeCol();\n this.table.scrollToCell({ row: finalRow, col: targetCol }, this.scrollOption);\n\n // 根据配置决定是否滚动页面\n if (this.enableViewportScroll) {\n scrollVTableCellIntoView(this.table, { row: finalRow, col: targetCol });\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"]}
@@ -1,7 +1,7 @@
1
1
  (function (global, factory) {
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
3
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.VTable = global.VTable || {}, global.VTable.export = {})));
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.VTable = global.VTable || {}, global.VTable.search = {})));
5
5
  })(this, (function (exports) { 'use strict';
6
6
 
7
7
  const isValid = value => null != value;
@@ -62,6 +62,59 @@
62
62
  this.table.registerCustomCellStyle(HighlightStyleId, this.highlightCellStyle);
63
63
  this.table.registerCustomCellStyle(FocusHighlightStyleId, this.focusHighlightCellStyle);
64
64
  }
65
+ getHeaderOffset() {
66
+ let offset = 0;
67
+ while (this.table.isHeader(0, offset)) {
68
+ offset++;
69
+ }
70
+ return offset;
71
+ }
72
+ getHeaderCellAddressByField(field) {
73
+ const layoutMap = this.table.internalProps?.layoutMap;
74
+ return layoutMap?.getHeaderCellAddressByField?.(field);
75
+ }
76
+ getTreeCol() {
77
+ const treeColumn = this.table?.options?.columns?.find((c) => c?.tree);
78
+ const field = treeColumn?.field;
79
+ if (typeof field === 'string' && field) {
80
+ const addr = this.getHeaderCellAddressByField(field);
81
+ if (addr && typeof addr.col === 'number') {
82
+ return addr.col;
83
+ }
84
+ }
85
+ return this.treeIndex;
86
+ }
87
+ getVisibleTreeCell(resultItem) {
88
+ if (!resultItem.indexNumber) {
89
+ return undefined;
90
+ }
91
+ const rawIndex = this.getBodyRowIndexByRecordIndex(resultItem.indexNumber);
92
+ if (rawIndex < 0) {
93
+ return undefined;
94
+ }
95
+ return {
96
+ col: typeof resultItem.col === 'number' ? resultItem.col : this.getTreeCol(),
97
+ row: rawIndex + this.getHeaderOffset()
98
+ };
99
+ }
100
+ clearRenderedCellStyles() {
101
+ const plugin = this.table.customCellStylePlugin;
102
+ const cellsToRefresh = [];
103
+ const arrangements = Array.from(plugin?.customCellStyleArrangement || []);
104
+ arrangements.forEach((item) => {
105
+ const cellPosition = item?.cellPosition;
106
+ if (typeof cellPosition?.col === 'number' && typeof cellPosition?.row === 'number') {
107
+ cellsToRefresh.push({
108
+ col: cellPosition.col,
109
+ row: cellPosition.row
110
+ });
111
+ }
112
+ });
113
+ plugin.clearCustomCellStyleArrangement();
114
+ cellsToRefresh.forEach(({ col, row }) => {
115
+ this.table.scenegraph.updateCellContent(col, row, true);
116
+ });
117
+ }
65
118
  search(str) {
66
119
  this.clear();
67
120
  this.queryStr = str;
@@ -74,17 +127,35 @@
74
127
  this.isTree = this.table.options.columns.some((item) => item.tree);
75
128
  this.treeIndex = this.isTree ? this.table.options.columns.findIndex((item) => item.tree) : 0;
76
129
  if (this.isTree) {
77
- const colEnd = this.table.colCount;
130
+ const treeCol = this.getTreeCol();
78
131
  const walk = (nodes, path) => {
79
132
  nodes.forEach((item, idx) => {
80
133
  const currentPath = [...path, idx];
81
- if (this.treeQueryMethod(this.queryStr, item, this.fieldsToSearch, { table: this.table })) {
134
+ const searchFields = Array.isArray(this.fieldsToSearch) && this.fieldsToSearch.length > 0
135
+ ? this.fieldsToSearch
136
+ : Object.keys(item);
137
+ let hitAnyField = false;
138
+ searchFields.forEach(field => {
139
+ const value = item?.[field];
140
+ if (!isValid$1(value)) {
141
+ return;
142
+ }
143
+ const col = this.getHeaderCellAddressByField(field)?.col ?? treeCol;
144
+ if (this.queryMethod(this.queryStr, value, { col, row: 0, table: this.table })) {
145
+ hitAnyField = true;
146
+ this.queryResult.push({
147
+ indexNumber: currentPath,
148
+ col,
149
+ value: value?.toString?.() ?? String(value)
150
+ });
151
+ }
152
+ });
153
+ if (!hitAnyField &&
154
+ this.treeQueryMethod &&
155
+ this.treeQueryMethod(this.queryStr, item, this.fieldsToSearch, { table: this.table })) {
82
156
  this.queryResult.push({
83
157
  indexNumber: currentPath,
84
- range: {
85
- start: { row: null, col: 0 },
86
- end: { row: null, col: colEnd }
87
- }
158
+ col: treeCol
88
159
  });
89
160
  }
90
161
  if (item.children && Array.isArray(item.children) && item.children.length > 0) {
@@ -93,8 +164,18 @@
93
164
  });
94
165
  };
95
166
  walk(this.table.records, []);
167
+ const dedup = new Set();
168
+ this.queryResult = this.queryResult.filter(r => {
169
+ const key = `${(r.indexNumber || []).join('.')}:${r.col ?? ''}`;
170
+ if (dedup.has(key)) {
171
+ return false;
172
+ }
173
+ dedup.add(key);
174
+ return true;
175
+ });
176
+ this.currentIndex = this.queryResult.length > 0 ? 0 : -1;
96
177
  if (this.queryResult.length > 0) {
97
- this.jumpToCell({ IndexNumber: this.queryResult[0].indexNumber });
178
+ this.jumpToCell({ IndexNumber: this.queryResult[0].indexNumber, col: this.queryResult[0].col ?? treeCol });
98
179
  }
99
180
  if (this.callback) {
100
181
  this.callback({
@@ -103,9 +184,8 @@
103
184
  }, this.table);
104
185
  }
105
186
  this.updateCellStyle();
106
- this.currentIndex = 0;
107
187
  return {
108
- index: 0,
188
+ index: this.currentIndex >= 0 ? this.currentIndex : 0,
109
189
  results: this.queryResult
110
190
  };
111
191
  }
@@ -170,10 +250,7 @@
170
250
  }
171
251
  updateCellStyle(highlight = true) {
172
252
  if (!highlight) {
173
- this.table.customCellStylePlugin.clearCustomCellStyleArrangement();
174
- (this.queryResult || []).forEach(resultItem => {
175
- this.table.scenegraph.updateCellContent(resultItem.col, resultItem.row);
176
- });
253
+ this.clearRenderedCellStyles();
177
254
  this.table.scenegraph.updateNextFrame();
178
255
  return;
179
256
  }
@@ -186,18 +263,34 @@
186
263
  if (!this.table.hasCustomCellStyle(FocusHighlightStyleId)) {
187
264
  this.table.registerCustomCellStyle(FocusHighlightStyleId, this.focusHighlightCellStyle);
188
265
  }
266
+ this.clearRenderedCellStyles();
189
267
  if (this.isTree) {
190
- const { range, indexNumber } = this.queryResult[0];
191
- let i = 0;
192
- while (this.table.isHeader(0, i)) {
193
- i++;
268
+ if (!this.queryResult.length) {
269
+ this.table.scenegraph.updateNextFrame();
270
+ return;
194
271
  }
195
- const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;
196
- range.start.row = row;
197
- range.end.row = row;
198
- this.arrangeCustomCellStyle({
199
- range
200
- }, highlight, FocusHighlightStyleId);
272
+ for (let i = 0; i < this.queryResult.length; i++) {
273
+ const cell = this.getVisibleTreeCell(this.queryResult[i]);
274
+ if (!cell) {
275
+ continue;
276
+ }
277
+ this.table.customCellStylePlugin.addCustomCellStyleArrangement({
278
+ col: cell.col,
279
+ row: cell.row
280
+ }, HighlightStyleId);
281
+ this.table.scenegraph.updateCellContent(cell.col, cell.row, true);
282
+ }
283
+ if (this.currentIndex >= 0 && this.currentIndex < this.queryResult.length) {
284
+ const cell = this.getVisibleTreeCell(this.queryResult[this.currentIndex]);
285
+ if (cell) {
286
+ this.table.customCellStylePlugin.addCustomCellStyleArrangement({
287
+ col: cell.col,
288
+ row: cell.row
289
+ }, FocusHighlightStyleId);
290
+ this.table.scenegraph.updateCellContent(cell.col, cell.row, true);
291
+ }
292
+ }
293
+ this.table.scenegraph.updateNextFrame();
201
294
  }
202
295
  else {
203
296
  for (let i = 0; i < this.queryResult.length; i++) {
@@ -218,37 +311,13 @@
218
311
  };
219
312
  }
220
313
  if (this.isTree) {
221
- if (this.currentIndex !== -1) {
222
- const { range, indexNumber } = this.queryResult[this.currentIndex];
223
- if (range) {
224
- let i = 0;
225
- while (this.table.isHeader(0, i)) {
226
- i++;
227
- }
228
- const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;
229
- range.start.row = row;
230
- range.end.row = row;
231
- this.arrangeCustomCellStyle({ range });
232
- }
233
- }
234
314
  this.currentIndex++;
235
315
  if (this.currentIndex >= this.queryResult.length) {
236
316
  this.currentIndex = 0;
237
317
  }
238
- const { range, indexNumber } = this.queryResult[this.currentIndex];
239
- this.jumpToCell({ IndexNumber: indexNumber });
240
- if (range) {
241
- let i = 0;
242
- while (this.table.isHeader(0, i)) {
243
- i++;
244
- }
245
- const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;
246
- range.start.row = row;
247
- range.end.row = row;
248
- this.arrangeCustomCellStyle({
249
- range
250
- }, true, FocusHighlightStyleId);
251
- }
318
+ const { indexNumber, col } = this.queryResult[this.currentIndex];
319
+ this.jumpToCell({ IndexNumber: indexNumber, col });
320
+ this.updateCellStyle();
252
321
  }
253
322
  else {
254
323
  if (this.currentIndex !== -1) {
@@ -275,35 +344,13 @@
275
344
  };
276
345
  }
277
346
  if (this.isTree) {
278
- if (this.currentIndex !== -1) {
279
- const { range, indexNumber } = this.queryResult[this.currentIndex];
280
- if (range) {
281
- let i = 0;
282
- while (this.table.isHeader(0, i)) {
283
- i++;
284
- }
285
- const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;
286
- range.start.row = row;
287
- range.end.row = row;
288
- this.arrangeCustomCellStyle({ range });
289
- }
290
- }
291
347
  this.currentIndex--;
292
348
  if (this.currentIndex < 0) {
293
349
  this.currentIndex = this.queryResult.length - 1;
294
350
  }
295
- const { range, indexNumber } = this.queryResult[this.currentIndex];
296
- this.jumpToCell({ IndexNumber: indexNumber });
297
- if (range) {
298
- let i = 0;
299
- while (this.table.isHeader(0, i)) {
300
- i++;
301
- }
302
- const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;
303
- range.start.row = row;
304
- range.end.row = row;
305
- this.arrangeCustomCellStyle({ range }, true, FocusHighlightStyleId);
306
- }
351
+ const { indexNumber, col } = this.queryResult[this.currentIndex];
352
+ this.jumpToCell({ IndexNumber: indexNumber, col });
353
+ this.updateCellStyle();
307
354
  }
308
355
  else {
309
356
  if (this.currentIndex !== -1) {
@@ -342,9 +389,10 @@
342
389
  }
343
390
  }
344
391
  const finalRow = this.getBodyRowIndexByRecordIndex(indexNumbers) + i;
345
- this.table.scrollToRow(finalRow, this.scrollOption);
392
+ const targetCol = typeof params.col === 'number' ? params.col : this.getTreeCol();
393
+ this.table.scrollToCell({ row: finalRow, col: targetCol }, this.scrollOption);
346
394
  if (this.enableViewportScroll) {
347
- scrollVTableCellIntoView(this.table, { row: finalRow, col: this.treeIndex });
395
+ scrollVTableCellIntoView(this.table, { row: finalRow, col: targetCol });
348
396
  }
349
397
  }
350
398
  else {
@@ -0,0 +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.search={}))}(this,(function(e){"use strict";var t=e=>null!=e;const l="__search_component_highlight",r="__search_component_focus",s={bgColor:"rgba(255, 255, 0, 0.2)"},i={bgColor:"rgba(255, 155, 0, 0.2)"};function o(e,l){return t(e)&&t(l)&&l.toString().includes(e)}function n(e,l,r){if(!t(e))return!1;return(Array.isArray(r)&&r.length>0?r:Object.keys(l)).some((r=>t(l?.[r])&&l[r].toString().includes(e)))}function h(e,t){if("undefined"==typeof document||"undefined"==typeof window)return;const l=e.getElement?.()||e.container;if(!l)return;const r=e.getCellRect(t.col,t.row);if(!r)return;let s=l.parentElement;for(;s;){const e=getComputedStyle(s),t=/(auto|scroll|overlay)/.test(e.overflowY),l=s.scrollHeight>s.clientHeight;if(t&&l)break;s=s.parentElement||s.getRootNode?.()?.host||null}s||(s=document.scrollingElement||document.documentElement);const i=s,o=l.getBoundingClientRect(),n=i.getBoundingClientRect(),h=o.top-n.top+i.scrollTop+r.top,u=h+r.height,c=i.clientHeight,a=i.scrollTop;if(!(h>=a&&u<=a+c)){let e;e=h<a?h:u-c,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||o,this.treeQueryMethod=e.treeQueryMethod||n,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(l,this.highlightCellStyle),this.table.registerCustomCellStyle(r,this.focusHighlightCellStyle)}getHeaderOffset(){let e=0;for(;this.table.isHeader(0,e);)e++;return e}getHeaderCellAddressByField(e){const t=this.table.internalProps?.layoutMap;return t?.getHeaderCellAddressByField?.(e)}getTreeCol(){const e=this.table?.options?.columns?.find((e=>e?.tree)),t=e?.field;if("string"==typeof t&&t){const e=this.getHeaderCellAddressByField(t);if(e&&"number"==typeof e.col)return e.col}return this.treeIndex}getVisibleTreeCell(e){if(!e.indexNumber)return;const t=this.getBodyRowIndexByRecordIndex(e.indexNumber);return t<0?void 0:{col:"number"==typeof e.col?e.col:this.getTreeCol(),row:t+this.getHeaderOffset()}}clearRenderedCellStyles(){const e=this.table.customCellStylePlugin,t=[];Array.from(e?.customCellStyleArrangement||[]).forEach((e=>{const l=e?.cellPosition;"number"==typeof l?.col&&"number"==typeof l?.row&&t.push({col:l.col,row:l.row})})),e.clearCustomCellStyleArrangement(),t.forEach((({col:e,row:t})=>{this.table.scenegraph.updateCellContent(e,t,!0)}))}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.getTreeCol(),l=(r,s)=>{r.forEach(((r,i)=>{const o=[...s,i],n=Array.isArray(this.fieldsToSearch)&&this.fieldsToSearch.length>0?this.fieldsToSearch:Object.keys(r);let h=!1;n.forEach((l=>{const s=r?.[l];if(!t(s))return;const i=this.getHeaderCellAddressByField(l)?.col??e;this.queryMethod(this.queryStr,s,{col:i,row:0,table:this.table})&&(h=!0,this.queryResult.push({indexNumber:o,col:i,value:s?.toString?.()??String(s)}))})),!h&&this.treeQueryMethod&&this.treeQueryMethod(this.queryStr,r,this.fieldsToSearch,{table:this.table})&&this.queryResult.push({indexNumber:o,col:e}),r.children&&Array.isArray(r.children)&&r.children.length>0&&l(r.children,o)}))};l(this.table.records,[]);const r=new Set;return this.queryResult=this.queryResult.filter((e=>{const t=`${(e.indexNumber||[]).join(".")}:${e.col??""}`;return!r.has(t)&&(r.add(t),!0)})),this.currentIndex=this.queryResult.length>0?0:-1,this.queryResult.length>0&&this.jumpToCell({IndexNumber:this.queryResult[0].indexNumber,col:this.queryResult[0].col??e}),this.callback&&this.callback({queryStr:this.queryStr,results:this.queryResult},this.table),this.updateCellStyle(),{index:this.currentIndex>=0?this.currentIndex: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 l=this.table.getCellValue(t,e);if(this.queryMethod(this.queryStr,l,{col:t,row:e,table:this.table})){const r=this.table.getCellRange(t,e);if(r.start.col!==r.end.col||r.start.row!==r.end.row){let e=!1;for(let t=this.queryResult.length-1;t>=0;t--)if(this.queryResult[t].col===r.start.col&&this.queryResult[t].row===r.start.row){e=!0;break}e||this.queryResult.push({col:r.start.col,row:r.start.row,range:r,value:l})}else this.queryResult.push({col:t,row:e,value:l})}}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,r=l){const{col:s,row:i,range:o}=e;this.table.arrangeCustomCellStyle(o?{range:o}:{row:i,col:s},t?r:null)}updateCellStyle(e=!0){if(!e)return this.clearRenderedCellStyles(),void this.table.scenegraph.updateNextFrame();if(this.queryResult)if(this.table.hasCustomCellStyle(l)||this.table.registerCustomCellStyle(l,this.highlightCellStyle),this.table.hasCustomCellStyle(r)||this.table.registerCustomCellStyle(r,this.focusHighlightCellStyle),this.clearRenderedCellStyles(),this.isTree){if(!this.queryResult.length)return void this.table.scenegraph.updateNextFrame();for(let e=0;e<this.queryResult.length;e++){const t=this.getVisibleTreeCell(this.queryResult[e]);t&&(this.table.customCellStylePlugin.addCustomCellStyleArrangement({col:t.col,row:t.row},l),this.table.scenegraph.updateCellContent(t.col,t.row,!0))}if(this.currentIndex>=0&&this.currentIndex<this.queryResult.length){const e=this.getVisibleTreeCell(this.queryResult[this.currentIndex]);e&&(this.table.customCellStylePlugin.addCustomCellStyleArrangement({col:e.col,row:e.row},r),this.table.scenegraph.updateCellContent(e.col,e.row,!0))}this.table.scenegraph.updateNextFrame()}else{for(let e=0;e<this.queryResult.length;e++)this.table.customCellStylePlugin.addCustomCellStyleArrangement({col:this.queryResult[e].col,row:this.queryResult[e].row},l),this.table.scenegraph.updateCellContent(this.queryResult[e].col,this.queryResult[e].row,!0);this.table.scenegraph.updateNextFrame()}}next(){if(!this.queryResult.length)return{index:0,results:this.queryResult};if(this.isTree){this.currentIndex++,this.currentIndex>=this.queryResult.length&&(this.currentIndex=0);const{indexNumber:e,col:t}=this.queryResult[this.currentIndex];this.jumpToCell({IndexNumber:e,col:t}),this.updateCellStyle()}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,r),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){this.currentIndex--,this.currentIndex<0&&(this.currentIndex=this.queryResult.length-1);const{indexNumber:e,col:t}=this.queryResult[this.currentIndex];this.jumpToCell({IndexNumber:e,col:t}),this.updateCellStyle()}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,r),this.jumpToCell({col:e,row:t})}return{index:this.currentIndex,results:this.queryResult}}jumpToCell(e){if(this.isTree){const{IndexNumber:t}=e,l=[...t],r=[...l];let s=0,i=0;for(;s<r.length-1;){s++;const e=l.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 o=this.getBodyRowIndexByRecordIndex(l)+i,n="number"==typeof e.col?e.col:this.getTreeCol();this.table.scrollToCell({row:o,col:n},this.scrollOption),this.enableViewportScroll&&h(this.table,{row:o,col:n})}else{const{col:t,row:l}=e,{rowStart:r,rowEnd:s}=this.table.getBodyVisibleRowRange(),{colStart:i,colEnd:o}=this.table.getBodyVisibleColRange();!(l<=r||l>=s||t<=i||t>=o)||this.table.scrollToCell({col:t,row:l}),this.enableViewportScroll&&h(this.table,{row:l,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}}}));
@@ -61,6 +61,11 @@ export declare class SearchComponent {
61
61
  treeIndex: number;
62
62
  scrollOption: ITableAnimationOption;
63
63
  constructor(option: SearchComponentOption);
64
+ private getHeaderOffset;
65
+ private getHeaderCellAddressByField;
66
+ private getTreeCol;
67
+ private getVisibleTreeCell;
68
+ private clearRenderedCellStyles;
64
69
  search(str: string): {
65
70
  index: number;
66
71
  results: {
@@ -28,40 +28,93 @@ export class SearchComponent {
28
28
  }, this.enableViewportScroll = option.enableViewportScroll || !1, this.table.registerCustomCellStyle(HighlightStyleId, this.highlightCellStyle),
29
29
  this.table.registerCustomCellStyle(FocusHighlightStyleId, this.focusHighlightCellStyle);
30
30
  }
31
+ getHeaderOffset() {
32
+ let offset = 0;
33
+ for (;this.table.isHeader(0, offset); ) offset++;
34
+ return offset;
35
+ }
36
+ getHeaderCellAddressByField(field) {
37
+ var _a, _b;
38
+ const layoutMap = null === (_a = this.table.internalProps) || void 0 === _a ? void 0 : _a.layoutMap;
39
+ return null === (_b = null == layoutMap ? void 0 : layoutMap.getHeaderCellAddressByField) || void 0 === _b ? void 0 : _b.call(layoutMap, field);
40
+ }
41
+ getTreeCol() {
42
+ var _a, _b, _c;
43
+ const treeColumn = null === (_c = null === (_b = null === (_a = this.table) || void 0 === _a ? void 0 : _a.options) || void 0 === _b ? void 0 : _b.columns) || void 0 === _c ? void 0 : _c.find((c => null == c ? void 0 : c.tree)), field = null == treeColumn ? void 0 : treeColumn.field;
44
+ if ("string" == typeof field && field) {
45
+ const addr = this.getHeaderCellAddressByField(field);
46
+ if (addr && "number" == typeof addr.col) return addr.col;
47
+ }
48
+ return this.treeIndex;
49
+ }
50
+ getVisibleTreeCell(resultItem) {
51
+ if (!resultItem.indexNumber) return;
52
+ const rawIndex = this.getBodyRowIndexByRecordIndex(resultItem.indexNumber);
53
+ return rawIndex < 0 ? void 0 : {
54
+ col: "number" == typeof resultItem.col ? resultItem.col : this.getTreeCol(),
55
+ row: rawIndex + this.getHeaderOffset()
56
+ };
57
+ }
58
+ clearRenderedCellStyles() {
59
+ const plugin = this.table.customCellStylePlugin, cellsToRefresh = [];
60
+ Array.from((null == plugin ? void 0 : plugin.customCellStyleArrangement) || []).forEach((item => {
61
+ const cellPosition = null == item ? void 0 : item.cellPosition;
62
+ "number" == typeof (null == cellPosition ? void 0 : cellPosition.col) && "number" == typeof (null == cellPosition ? void 0 : cellPosition.row) && cellsToRefresh.push({
63
+ col: cellPosition.col,
64
+ row: cellPosition.row
65
+ });
66
+ })), plugin.clearCustomCellStyleArrangement(), cellsToRefresh.forEach((({col: col, row: row}) => {
67
+ this.table.scenegraph.updateCellContent(col, row, !0);
68
+ }));
69
+ }
31
70
  search(str) {
71
+ var _a;
32
72
  if (this.clear(), this.queryStr = str, !str) return {
33
73
  index: 0,
34
74
  results: this.queryResult
35
75
  };
36
76
  if (this.isTree = this.table.options.columns.some((item => item.tree)), this.treeIndex = this.isTree ? this.table.options.columns.findIndex((item => item.tree)) : 0,
37
77
  this.isTree) {
38
- const colEnd = this.table.colCount, walk = (nodes, path) => {
78
+ const treeCol = this.getTreeCol(), walk = (nodes, path) => {
39
79
  nodes.forEach(((item, idx) => {
40
- const currentPath = [ ...path, idx ];
41
- this.treeQueryMethod(this.queryStr, item, this.fieldsToSearch, {
80
+ const currentPath = [ ...path, idx ], searchFields = Array.isArray(this.fieldsToSearch) && this.fieldsToSearch.length > 0 ? this.fieldsToSearch : Object.keys(item);
81
+ let hitAnyField = !1;
82
+ searchFields.forEach((field => {
83
+ var _a, _b, _c, _d;
84
+ const value = null == item ? void 0 : item[field];
85
+ if (!isValid(value)) return;
86
+ const col = null !== (_b = null === (_a = this.getHeaderCellAddressByField(field)) || void 0 === _a ? void 0 : _a.col) && void 0 !== _b ? _b : treeCol;
87
+ this.queryMethod(this.queryStr, value, {
88
+ col: col,
89
+ row: 0,
90
+ table: this.table
91
+ }) && (hitAnyField = !0, this.queryResult.push({
92
+ indexNumber: currentPath,
93
+ col: col,
94
+ value: null !== (_d = null === (_c = null == value ? void 0 : value.toString) || void 0 === _c ? void 0 : _c.call(value)) && void 0 !== _d ? _d : String(value)
95
+ }));
96
+ })), !hitAnyField && this.treeQueryMethod && this.treeQueryMethod(this.queryStr, item, this.fieldsToSearch, {
42
97
  table: this.table
43
98
  }) && this.queryResult.push({
44
99
  indexNumber: currentPath,
45
- range: {
46
- start: {
47
- row: null,
48
- col: 0
49
- },
50
- end: {
51
- row: null,
52
- col: colEnd
53
- }
54
- }
100
+ col: treeCol
55
101
  }), item.children && Array.isArray(item.children) && item.children.length > 0 && walk(item.children, currentPath);
56
102
  }));
57
103
  };
58
- return walk(this.table.records, []), this.queryResult.length > 0 && this.jumpToCell({
59
- IndexNumber: this.queryResult[0].indexNumber
104
+ walk(this.table.records, []);
105
+ const dedup = new Set;
106
+ return this.queryResult = this.queryResult.filter((r => {
107
+ var _a;
108
+ const key = `${(r.indexNumber || []).join(".")}:${null !== (_a = r.col) && void 0 !== _a ? _a : ""}`;
109
+ return !dedup.has(key) && (dedup.add(key), !0);
110
+ })), this.currentIndex = this.queryResult.length > 0 ? 0 : -1, this.queryResult.length > 0 && this.jumpToCell({
111
+ IndexNumber: this.queryResult[0].indexNumber,
112
+ col: null !== (_a = this.queryResult[0].col) && void 0 !== _a ? _a : treeCol
60
113
  }), this.callback && this.callback({
61
114
  queryStr: this.queryStr,
62
115
  results: this.queryResult
63
- }, this.table), this.updateCellStyle(), this.currentIndex = 0, {
64
- index: 0,
116
+ }, this.table), this.updateCellStyle(), {
117
+ index: this.currentIndex >= 0 ? this.currentIndex : 0,
65
118
  results: this.queryResult
66
119
  };
67
120
  }
@@ -111,20 +164,26 @@ export class SearchComponent {
111
164
  }, highlight ? customStyleId : null);
112
165
  }
113
166
  updateCellStyle(highlight = !0) {
114
- if (!highlight) return this.table.customCellStylePlugin.clearCustomCellStyleArrangement(),
115
- (this.queryResult || []).forEach((resultItem => {
116
- this.table.scenegraph.updateCellContent(resultItem.col, resultItem.row);
117
- })), void this.table.scenegraph.updateNextFrame();
167
+ if (!highlight) return this.clearRenderedCellStyles(), void this.table.scenegraph.updateNextFrame();
118
168
  if (this.queryResult) if (this.table.hasCustomCellStyle(HighlightStyleId) || this.table.registerCustomCellStyle(HighlightStyleId, this.highlightCellStyle),
119
169
  this.table.hasCustomCellStyle(FocusHighlightStyleId) || this.table.registerCustomCellStyle(FocusHighlightStyleId, this.focusHighlightCellStyle),
120
- this.isTree) {
121
- const {range: range, indexNumber: indexNumber} = this.queryResult[0];
122
- let i = 0;
123
- for (;this.table.isHeader(0, i); ) i++;
124
- const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;
125
- range.start.row = row, range.end.row = row, this.arrangeCustomCellStyle({
126
- range: range
127
- }, highlight, FocusHighlightStyleId);
170
+ this.clearRenderedCellStyles(), this.isTree) {
171
+ if (!this.queryResult.length) return void this.table.scenegraph.updateNextFrame();
172
+ for (let i = 0; i < this.queryResult.length; i++) {
173
+ const cell = this.getVisibleTreeCell(this.queryResult[i]);
174
+ cell && (this.table.customCellStylePlugin.addCustomCellStyleArrangement({
175
+ col: cell.col,
176
+ row: cell.row
177
+ }, HighlightStyleId), this.table.scenegraph.updateCellContent(cell.col, cell.row, !0));
178
+ }
179
+ if (this.currentIndex >= 0 && this.currentIndex < this.queryResult.length) {
180
+ const cell = this.getVisibleTreeCell(this.queryResult[this.currentIndex]);
181
+ cell && (this.table.customCellStylePlugin.addCustomCellStyleArrangement({
182
+ col: cell.col,
183
+ row: cell.row
184
+ }, FocusHighlightStyleId), this.table.scenegraph.updateCellContent(cell.col, cell.row, !0));
185
+ }
186
+ this.table.scenegraph.updateNextFrame();
128
187
  } else {
129
188
  for (let i = 0; i < this.queryResult.length; i++) this.table.customCellStylePlugin.addCustomCellStyleArrangement({
130
189
  col: this.queryResult[i].col,
@@ -139,29 +198,12 @@ export class SearchComponent {
139
198
  results: this.queryResult
140
199
  };
141
200
  if (this.isTree) {
142
- if (-1 !== this.currentIndex) {
143
- const {range: range, indexNumber: indexNumber} = this.queryResult[this.currentIndex];
144
- if (range) {
145
- let i = 0;
146
- for (;this.table.isHeader(0, i); ) i++;
147
- const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;
148
- range.start.row = row, range.end.row = row, this.arrangeCustomCellStyle({
149
- range: range
150
- });
151
- }
152
- }
153
201
  this.currentIndex++, this.currentIndex >= this.queryResult.length && (this.currentIndex = 0);
154
- const {range: range, indexNumber: indexNumber} = this.queryResult[this.currentIndex];
155
- if (this.jumpToCell({
156
- IndexNumber: indexNumber
157
- }), range) {
158
- let i = 0;
159
- for (;this.table.isHeader(0, i); ) i++;
160
- const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;
161
- range.start.row = row, range.end.row = row, this.arrangeCustomCellStyle({
162
- range: range
163
- }, !0, FocusHighlightStyleId);
164
- }
202
+ const {indexNumber: indexNumber, col: col} = this.queryResult[this.currentIndex];
203
+ this.jumpToCell({
204
+ IndexNumber: indexNumber,
205
+ col: col
206
+ }), this.updateCellStyle();
165
207
  } else {
166
208
  -1 !== this.currentIndex && this.arrangeCustomCellStyle(this.queryResult[this.currentIndex]),
167
209
  this.currentIndex++, this.currentIndex >= this.queryResult.length && (this.currentIndex = 0);
@@ -183,29 +225,12 @@ export class SearchComponent {
183
225
  results: this.queryResult
184
226
  };
185
227
  if (this.isTree) {
186
- if (-1 !== this.currentIndex) {
187
- const {range: range, indexNumber: indexNumber} = this.queryResult[this.currentIndex];
188
- if (range) {
189
- let i = 0;
190
- for (;this.table.isHeader(0, i); ) i++;
191
- const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;
192
- range.start.row = row, range.end.row = row, this.arrangeCustomCellStyle({
193
- range: range
194
- });
195
- }
196
- }
197
228
  this.currentIndex--, this.currentIndex < 0 && (this.currentIndex = this.queryResult.length - 1);
198
- const {range: range, indexNumber: indexNumber} = this.queryResult[this.currentIndex];
199
- if (this.jumpToCell({
200
- IndexNumber: indexNumber
201
- }), range) {
202
- let i = 0;
203
- for (;this.table.isHeader(0, i); ) i++;
204
- const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;
205
- range.start.row = row, range.end.row = row, this.arrangeCustomCellStyle({
206
- range: range
207
- }, !0, FocusHighlightStyleId);
208
- }
229
+ const {indexNumber: indexNumber, col: col} = this.queryResult[this.currentIndex];
230
+ this.jumpToCell({
231
+ IndexNumber: indexNumber,
232
+ col: col
233
+ }), this.updateCellStyle();
209
234
  } else {
210
235
  -1 !== this.currentIndex && this.arrangeCustomCellStyle(this.queryResult[this.currentIndex]),
211
236
  this.currentIndex--, this.currentIndex < 0 && (this.currentIndex = this.queryResult.length - 1);
@@ -232,10 +257,13 @@ export class SearchComponent {
232
257
  const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;
233
258
  "expand" !== this.table.getHierarchyState(this.treeIndex, row) && this.table.toggleHierarchyState(this.treeIndex, row);
234
259
  }
235
- const finalRow = this.getBodyRowIndexByRecordIndex(indexNumbers) + i;
236
- this.table.scrollToRow(finalRow, this.scrollOption), this.enableViewportScroll && scrollVTableCellIntoView(this.table, {
260
+ const finalRow = this.getBodyRowIndexByRecordIndex(indexNumbers) + i, targetCol = "number" == typeof params.col ? params.col : this.getTreeCol();
261
+ this.table.scrollToCell({
262
+ row: finalRow,
263
+ col: targetCol
264
+ }, this.scrollOption), this.enableViewportScroll && scrollVTableCellIntoView(this.table, {
237
265
  row: finalRow,
238
- col: this.treeIndex
266
+ col: targetCol
239
267
  });
240
268
  } else {
241
269
  const {col: col, row: row} = params, {rowStart: rowStart, rowEnd: rowEnd} = this.table.getBodyVisibleRowRange(), {colStart: colStart, colEnd: colEnd} = this.table.getBodyVisibleColRange();
@@ -1 +1 @@
1
- {"version":3,"sources":["search-component/search-component.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;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,OAAO,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACpF,CAAC;AACD,SAAS,sBAAsB,CAAC,QAAgB,EAAE,IAAS,EAAE,cAAyB;IACpF,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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M,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 this.table.customCellStylePlugin.clearCustomCellStyleArrangement();\n (this.queryResult || []).forEach(resultItem => {\n this.table.scenegraph.updateCellContent(resultItem.col, resultItem.row);\n });\n this.table.scenegraph.updateNextFrame();\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 for (let i = 0; i < this.queryResult.length; i++) {\n this.table.customCellStylePlugin.addCustomCellStyleArrangement(\n {\n col: this.queryResult[i].col,\n row: this.queryResult[i].row\n },\n HighlightStyleId\n );\n this.table.scenegraph.updateCellContent(this.queryResult[i].col, this.queryResult[i].row, true);\n }\n this.table.scenegraph.updateNextFrame();\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"]}
1
+ {"version":3,"sources":["search-component/search-component.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;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,OAAO,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AACpF,CAAC;AACD,SAAS,sBAAsB,CAAC,QAAgB,EAAE,IAAS,EAAE,cAAyB;IACpF,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,KAA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AQ,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 private getHeaderOffset(): number {\n let offset = 0;\n while (this.table.isHeader(0, offset)) {\n offset++;\n }\n return offset;\n }\n\n private getHeaderCellAddressByField(field: string): { col: number; row: number } | undefined {\n // PivotTable/ListTable share internal layoutMap API but it's not exposed on the public type.\n const layoutMap = (this.table as any).internalProps?.layoutMap;\n return layoutMap?.getHeaderCellAddressByField?.(field);\n }\n\n private getTreeCol(): number {\n const treeColumn = (this.table as any)?.options?.columns?.find((c: any) => c?.tree);\n const field = treeColumn?.field;\n if (typeof field === 'string' && field) {\n const addr = this.getHeaderCellAddressByField(field);\n if (addr && typeof addr.col === 'number') {\n return addr.col;\n }\n }\n // Fallback to previous behavior.\n return this.treeIndex;\n }\n\n private getVisibleTreeCell(resultItem: typeof this.queryResult[number]): { col: number; row: number } | undefined {\n if (!resultItem.indexNumber) {\n return undefined;\n }\n const rawIndex = this.getBodyRowIndexByRecordIndex(resultItem.indexNumber);\n if (rawIndex < 0) {\n return undefined;\n }\n return {\n col: typeof resultItem.col === 'number' ? resultItem.col : this.getTreeCol(),\n row: rawIndex + this.getHeaderOffset()\n };\n }\n\n private clearRenderedCellStyles() {\n const plugin = this.table.customCellStylePlugin;\n const cellsToRefresh: { col: number; row: number }[] = [];\n const arrangements = Array.from((plugin as any)?.customCellStyleArrangement || []);\n\n arrangements.forEach((item: any) => {\n const cellPosition = item?.cellPosition;\n if (typeof cellPosition?.col === 'number' && typeof cellPosition?.row === 'number') {\n cellsToRefresh.push({\n col: cellPosition.col,\n row: cellPosition.row\n });\n }\n });\n\n plugin.clearCustomCellStyleArrangement();\n cellsToRefresh.forEach(({ col, row }) => {\n this.table.scenegraph.updateCellContent(col, row, true);\n });\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 treeCol = this.getTreeCol();\n const walk = (nodes: any[], path: number[]) => {\n nodes.forEach((item: any, idx: number) => {\n const currentPath = [...path, idx]; // 当前节点的完整路径\n\n // 为了做到“单元格级别高亮”,优先按字段匹配并映射到具体列。\n const searchFields =\n Array.isArray(this.fieldsToSearch) && this.fieldsToSearch.length > 0\n ? this.fieldsToSearch\n : Object.keys(item);\n\n let hitAnyField = false;\n searchFields.forEach(field => {\n const value = item?.[field];\n if (!isValid(value)) {\n return;\n }\n const col = this.getHeaderCellAddressByField(field)?.col ?? treeCol;\n // row 在树形场景下要在展开后才能准确计算,这里传 0 仅用于自定义 queryMethod 的兼容参数。\n if (this.queryMethod(this.queryStr, value, { col, row: 0, table: this.table })) {\n hitAnyField = true;\n this.queryResult.push({\n indexNumber: currentPath,\n col,\n value: value?.toString?.() ?? String(value)\n });\n }\n });\n\n // 兼容旧用法:如果用户自定义 treeQueryMethod 命中但字段级别未命中,则至少高亮树列。\n if (\n !hitAnyField &&\n this.treeQueryMethod &&\n this.treeQueryMethod(this.queryStr, item, this.fieldsToSearch, { table: this.table })\n ) {\n this.queryResult.push({\n indexNumber: currentPath,\n col: treeCol\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 // 同一节点同一列可能被多次命中(例如 fieldsToSearch 未限制且字段值重复),做一次简单去重\n const dedup = new Set<string>();\n this.queryResult = this.queryResult.filter(r => {\n const key = `${(r.indexNumber || []).join('.')}:${r.col ?? ''}`;\n if (dedup.has(key)) {\n return false;\n }\n dedup.add(key);\n return true;\n });\n\n this.currentIndex = this.queryResult.length > 0 ? 0 : -1;\n\n if (this.queryResult.length > 0) {\n this.jumpToCell({ IndexNumber: this.queryResult[0].indexNumber, col: this.queryResult[0].col ?? treeCol });\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 return {\n index: this.currentIndex >= 0 ? this.currentIndex : 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.clearRenderedCellStyles();\n this.table.scenegraph.updateNextFrame();\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\n this.clearRenderedCellStyles();\n\n if (this.isTree) {\n if (!this.queryResult.length) {\n this.table.scenegraph.updateNextFrame();\n return;\n }\n\n // 先为所有命中节点打普通高亮\n for (let i = 0; i < this.queryResult.length; i++) {\n const cell = this.getVisibleTreeCell(this.queryResult[i]);\n if (!cell) {\n continue;\n }\n this.table.customCellStylePlugin.addCustomCellStyleArrangement(\n {\n col: cell.col,\n row: cell.row\n },\n HighlightStyleId\n );\n this.table.scenegraph.updateCellContent(cell.col, cell.row, true);\n }\n\n // 再为当前索引打焦点高亮\n if (this.currentIndex >= 0 && this.currentIndex < this.queryResult.length) {\n const cell = this.getVisibleTreeCell(this.queryResult[this.currentIndex]);\n if (cell) {\n this.table.customCellStylePlugin.addCustomCellStyleArrangement(\n {\n col: cell.col,\n row: cell.row\n },\n FocusHighlightStyleId\n );\n this.table.scenegraph.updateCellContent(cell.col, cell.row, true);\n }\n }\n\n this.table.scenegraph.updateNextFrame();\n } else {\n for (let i = 0; i < this.queryResult.length; i++) {\n this.table.customCellStylePlugin.addCustomCellStyleArrangement(\n {\n col: this.queryResult[i].col,\n row: this.queryResult[i].row\n },\n HighlightStyleId\n );\n this.table.scenegraph.updateCellContent(this.queryResult[i].col, this.queryResult[i].row, true);\n }\n this.table.scenegraph.updateNextFrame();\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 this.currentIndex++;\n if (this.currentIndex >= this.queryResult.length) {\n this.currentIndex = 0;\n }\n const { indexNumber, col } = this.queryResult[this.currentIndex];\n this.jumpToCell({ IndexNumber: indexNumber, col });\n this.updateCellStyle();\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 this.currentIndex--;\n if (this.currentIndex < 0) {\n this.currentIndex = this.queryResult.length - 1;\n }\n\n const { indexNumber, col } = this.queryResult[this.currentIndex];\n this.jumpToCell({ IndexNumber: indexNumber, col });\n this.updateCellStyle();\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 const targetCol = typeof params.col === 'number' ? params.col : this.getTreeCol();\n this.table.scrollToCell({ row: finalRow, col: targetCol }, this.scrollOption);\n\n // 根据配置决定是否滚动页面\n if (this.enableViewportScroll) {\n scrollVTableCellIntoView(this.table, { row: finalRow, col: targetCol });\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.26.0",
3
+ "version": "1.26.1",
4
4
  "description": "The search util of VTable",
5
5
  "author": {
6
6
  "name": "VisActor",
@@ -24,14 +24,15 @@
24
24
  },
25
25
  "unpkg": "latest",
26
26
  "unpkgFiles": [
27
- "dist/vtable-exporter.js"
27
+ "dist/vtable-search.js",
28
+ "dist/vtable-search.min.js"
28
29
  ],
29
30
  "publishConfig": {
30
31
  "access": "public"
31
32
  },
32
33
  "dependencies": {
33
34
  "@visactor/vutils": "~1.0.17",
34
- "@visactor/vtable": "1.26.0"
35
+ "@visactor/vtable": "1.26.1"
35
36
  },
36
37
  "devDependencies": {
37
38
  "cross-env": "^7.0.3",
@@ -77,8 +78,8 @@
77
78
  "axios": "^1.4.0",
78
79
  "@types/react-is": "^17.0.3",
79
80
  "rollup-plugin-node-resolve": "5.2.0",
80
- "@internal/ts-config": "0.0.1",
81
81
  "@internal/eslint-config": "0.0.1",
82
+ "@internal/ts-config": "0.0.1",
82
83
  "@internal/bundler": "0.0.1"
83
84
  },
84
85
  "scripts": {
@@ -1 +0,0 @@
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)return this.table.customCellStylePlugin.clearCustomCellStyleArrangement(),(this.queryResult||[]).forEach((e=>{this.table.scenegraph.updateCellContent(e.col,e.row)})),void this.table.scenegraph.updateNextFrame();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 e=0;e<this.queryResult.length;e++)this.table.customCellStylePlugin.addCustomCellStyleArrangement({col:this.queryResult[e].col,row:this.queryResult[e].row},r),this.table.scenegraph.updateCellContent(this.queryResult[e].col,this.queryResult[e].row,!0);this.table.scenegraph.updateNextFrame()}}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}}}));