@visactor/vtable-search 1.22.11-alpha.7 → 1.22.11-alpha.8

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.
@@ -71,7 +71,7 @@ export declare class SearchComponent {
71
71
  indexNumber?: number[];
72
72
  }[];
73
73
  };
74
- arrangeCustomCellStyle(resultItem: typeof this.queryResult[number], highlight?: boolean, customStyleId?: string): void;
74
+ arrangeCustomCellStyle(resultItem: (typeof this.queryResult)[number], highlight?: boolean, customStyleId?: string): void;
75
75
  updateCellStyle(highlight?: boolean): void;
76
76
  next(): {
77
77
  index: number;
@@ -116,27 +116,21 @@ class SearchComponent {
116
116
  }, highlight ? customStyleId : null);
117
117
  }
118
118
  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();
123
- if (this.queryResult) if (this.table.hasCustomCellStyle(HighlightStyleId) || this.table.registerCustomCellStyle(HighlightStyleId, this.highlightCellStyle),
124
- 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);
133
- } else {
134
- for (let i = 0; i < this.queryResult.length; i++) this.table.customCellStylePlugin.addCustomCellStyleArrangement({
135
- col: this.queryResult[i].col,
136
- row: this.queryResult[i].row
137
- }, HighlightStyleId), this.table.scenegraph.updateCellContent(this.queryResult[i].col, this.queryResult[i].row, !0);
138
- this.table.scenegraph.updateNextFrame();
139
- }
119
+ if (highlight) {
120
+ if (this.queryResult) if (this.table.hasCustomCellStyle(HighlightStyleId) || this.table.registerCustomCellStyle(HighlightStyleId, this.highlightCellStyle),
121
+ this.table.hasCustomCellStyle(FocusHighlightStyleId) || this.table.registerCustomCellStyle(FocusHighlightStyleId, this.focusHighlightCellStyle),
122
+ this.isTree) {
123
+ const {range: range, indexNumber: indexNumber} = this.queryResult[0];
124
+ let i = 0;
125
+ for (;this.table.isHeader(0, i); ) i++;
126
+ const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;
127
+ range.start.row = row, range.end.row = row, this.arrangeCustomCellStyle({
128
+ range: range
129
+ }, highlight, FocusHighlightStyleId);
130
+ } else for (let i = 0; i < this.queryResult.length; i++) this.arrangeCustomCellStyle(this.queryResult[i], highlight);
131
+ } else (this.queryResult || []).forEach((resultItem => {
132
+ this.arrangeCustomCellStyle(resultItem, highlight);
133
+ }));
140
134
  }
141
135
  next() {
142
136
  if (!this.queryResult.length) return {
@@ -1 +1 @@
1
- {"version":3,"sources":["search-component/search-component.ts"],"names":[],"mappings":";;;AAGA,6CAA2C;AAmC3C,MAAM,gBAAgB,GAAG,8BAA8B,CAAC;AACxD,MAAM,qBAAqB,GAAG,0BAA0B,CAAC;AAEzD,MAAM,yBAAyB,GAAoC;IACjE,OAAO,EAAE,wBAAwB;CAClC,CAAC;AAEF,MAAM,8BAA8B,GAAoC;IACtE,OAAO,EAAE,wBAAwB;CAClC,CAAC;AAEF,SAAS,kBAAkB,CAAC,QAAgB,EAAE,KAAa;IACzD,OAAO,IAAA,gBAAO,EAAC,QAAQ,CAAC,IAAI,IAAA,gBAAO,EAAC,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,IAAA,gBAAO,EAAC,QAAQ,CAAC,EAAE;QACtB,O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AI,IAAI,CAAC;KAClH;IAGD,IAAI,CAAC,eAAe,EAAE;QACpB,eAAe,GAAG,QAAQ,CAAC,gBAAgB,IAAI,QAAQ,CAAC,eAAe,CAAC;KACzE;IAED,MAAM,iBAAiB,GAAG,eAA8B,CAAC;IAGzD,MAAM,SAAS,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAClD,MAAM,aAAa,GAAG,iBAAiB,CAAC,qBAAqB,EAAE,CAAC;IAGhE,MAAM,cAAc,GAAG,SAAS,CAAC,GAAG,GAAG,aAAa,CAAC,GAAG,GAAG,iBAAiB,CAAC,SAAS,CAAC;IAGvF,MAAM,OAAO,GAAG,cAAc,GAAG,QAAQ,CAAC,GAAG,CAAC;IAC9C,MAAM,UAAU,GAAG,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC;IAC7C,MAAM,eAAe,GAAG,iBAAiB,CAAC,YAAY,CAAC;IACvD,MAAM,SAAS,GAAG,iBAAiB,CAAC,SAAS,CAAC;IAG9C,MAAM,cAAc,GAAG,OAAO,IAAI,SAAS,IAAI,UAAU,IAAI,SAAS,GAAG,eAAe,CAAC;IAEzF,IAAI,CAAC,cAAc,EAAE;QAEnB,IAAI,YAAoB,CAAC;QAEzB,IAAI,OAAO,GAAG,SAAS,EAAE;YAEvB,YAAY,GAAG,OAAO,CAAC;SACxB;aAAM;YAEL,YAAY,GAAG,UAAU,GAAG,eAAe,CAAC;SAC7C;QAGD,iBAAiB,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;KACzD;AACH,CAAC","file":"search-component.js","sourcesContent":["import type * as VTable from '@visactor/vtable';\nimport type { ITableAnimationOption } from '@visactor/vtable/src/ts-types';\nimport type { EasingType } from '@visactor/vtable/src/vrender';\nimport { isValid } from '@visactor/vutils';\ntype IVTable = VTable.ListTable | VTable.PivotTable | VTable.PivotChart;\n\nexport type QueryResult = {\n queryStr: string;\n results: {\n col?: number;\n row?: number;\n value?: string;\n indexNumber?: number[];\n }[];\n};\n\nexport type SearchComponentOption = {\n table: IVTable;\n autoJump?: boolean;\n skipHeader?: boolean;\n highlightCellStyle?: VTable.TYPES.CellStyle;\n /**\n * @deprecated use focusHighlightCellStyle instead\n */\n focuseHighlightCellStyle?: VTable.TYPES.CellStyle;\n focusHighlightCellStyle?: VTable.TYPES.CellStyle;\n queryMethod?: (queryStr: string, value: string, option?: { col: number; row: number; table: IVTable }) => boolean;\n treeQueryMethod?: (queryStr: string, node: any, fieldsToSearch?: string[], option?: { table: IVTable }) => boolean;\n fieldsToSearch?: string[];\n scrollOption?: ITableAnimationOption;\n /**\n * 当开启时,搜索结果会自动滚动到视口范围内\n * @since 1.22.4\n */\n enableViewportScroll?: boolean;\n callback?: (queryResult: QueryResult, table: IVTable) => void;\n};\n\nconst HighlightStyleId = '__search_component_highlight';\nconst FocusHighlightStyleId = '__search_component_focus';\n\nconst defaultHighlightCellStyle: Partial<VTable.TYPES.CellStyle> = {\n bgColor: 'rgba(255, 255, 0, 0.2)'\n};\n\nconst defaultFocusHighlightCellStyle: Partial<VTable.TYPES.CellStyle> = {\n bgColor: 'rgba(255, 155, 0, 0.2)'\n};\n\nfunction defaultQueryMethod(queryStr: string, value: string) {\n return isValid(queryStr) && isValid(value) && value.toString().includes(queryStr);\n}\nfunction defaultTreeQueryMethod(queryStr: string, node: any, fieldsToSearch?: string[]) {\n if (!isValid(queryStr)) {\n return false;\n }\n\n // 如果没有传 fieldsToSearch,则用 node 的全部 key\n const searchFields = Array.isArray(fieldsToSearch) && fieldsToSearch.length > 0 ? fieldsToSearch : Object.keys(node);\n\n return searchFields.some(field => isValid(node?.[field]) && node[field].toString().includes(queryStr));\n}\nexport class SearchComponent {\n table: IVTable;\n skipHeader: boolean;\n autoJump: boolean;\n highlightCellStyle: Partial<VTable.TYPES.CellStyle>;\n focuseHighlightCellStyle: Partial<VTable.TYPES.CellStyle>;\n focusHighlightCellStyle: Partial<VTable.TYPES.CellStyle>;\n queryMethod: (queryStr: string, value: string, option: { col: number; row: number; table: IVTable }) => boolean;\n treeQueryMethod: (queryStr: string, node: any, fieldsToSearch?: string[], option?: { table: IVTable }) => boolean;\n fieldsToSearch: string[];\n enableViewportScroll?: boolean;\n callback?: (queryResult: QueryResult, table: IVTable) => void;\n\n queryStr: string;\n queryResult: {\n col?: number;\n row?: number;\n range?: VTable.TYPES.CellRange;\n value?: string;\n indexNumber?: number[];\n }[];\n\n currentIndex: number;\n isTree: boolean;\n treeIndex: number;\n scrollOption: ITableAnimationOption;\n\n constructor(option: SearchComponentOption) {\n this.table = option.table;\n this.autoJump = option.autoJump || false;\n this.skipHeader = option.skipHeader || false;\n this.highlightCellStyle = option.highlightCellStyle || defaultHighlightCellStyle;\n this.focusHighlightCellStyle =\n // 兼容兜底处理,修复拼写错误的问题\n option.focusHighlightCellStyle || option.focuseHighlightCellStyle || defaultFocusHighlightCellStyle;\n this.queryMethod = option.queryMethod || defaultQueryMethod;\n this.treeQueryMethod = option.treeQueryMethod || defaultTreeQueryMethod;\n this.fieldsToSearch = option.fieldsToSearch || [];\n this.isTree = false;\n this.treeIndex = 0;\n this.callback = option.callback;\n this.scrollOption =\n option.scrollOption || ({ duration: 900, easing: 'quartIn' as EasingType } as ITableAnimationOption);\n this.enableViewportScroll = option.enableViewportScroll || false;\n this.table.registerCustomCellStyle(HighlightStyleId, this.highlightCellStyle as any);\n this.table.registerCustomCellStyle(FocusHighlightStyleId, this.focusHighlightCellStyle as any);\n }\n\n search(str: string) {\n this.clear();\n this.queryStr = str;\n\n if (!str) {\n return {\n index: 0,\n results: this.queryResult\n };\n }\n this.isTree = this.table.options.columns.some((item: any) => item.tree);\n this.treeIndex = this.isTree ? this.table.options.columns.findIndex((item: any) => item.tree) : 0;\n if (this.isTree) {\n // 如果传入单一节点也能处理\n const colEnd = this.table.colCount;\n const walk = (nodes: any[], path: number[]) => {\n nodes.forEach((item: any, idx: number) => {\n const currentPath = [...path, idx]; // 当前节点的完整路径\n\n // 保持你的 treeQueryMethod 调用方式(this 上下文来自定义环境)\n if (this.treeQueryMethod(this.queryStr, item, this.fieldsToSearch, { table: this.table })) {\n this.queryResult.push({\n indexNumber: currentPath,\n range: {\n start: { row: null, col: 0 },\n end: { row: null, col: colEnd }\n }\n });\n }\n\n if (item.children && Array.isArray(item.children) && item.children.length > 0) {\n walk(item.children, currentPath);\n }\n });\n };\n\n walk(this.table.records, []);\n if (this.queryResult.length > 0) {\n this.jumpToCell({ IndexNumber: this.queryResult[0].indexNumber });\n }\n\n if (this.callback) {\n this.callback(\n {\n queryStr: this.queryStr,\n results: this.queryResult\n },\n this.table\n );\n }\n this.updateCellStyle();\n\n // if (this.autoJump) {\n // return this.next();\n // }\n this.currentIndex = 0;\n\n return {\n index: 0,\n results: this.queryResult\n };\n }\n for (let row = 0; row < this.table.rowCount; row++) {\n for (let col = 0; col < this.table.colCount; col++) {\n if (this.skipHeader && this.table.isHeader(col, row)) {\n continue;\n }\n const value = this.table.getCellValue(col, row);\n if (this.queryMethod(this.queryStr, value, { col, row, table: this.table })) {\n // deal merge cell\n const mergeCell = this.table.getCellRange(col, row);\n if (mergeCell.start.col !== mergeCell.end.col || mergeCell.start.row !== mergeCell.end.row) {\n // find is cell already in queryResult\n let isIn = false;\n for (let i = this.queryResult.length - 1; i >= 0; i--) {\n if (this.queryResult[i].col === mergeCell.start.col && this.queryResult[i].row === mergeCell.start.row) {\n isIn = true;\n break;\n }\n }\n if (!isIn) {\n this.queryResult.push({\n col: mergeCell.start.col,\n row: mergeCell.start.row,\n range: mergeCell,\n value\n });\n }\n } else {\n this.queryResult.push({\n col,\n row,\n value\n });\n }\n }\n }\n }\n this.updateCellStyle();\n\n if (this.callback) {\n this.callback(\n {\n queryStr: this.queryStr,\n results: this.queryResult\n },\n this.table\n );\n }\n\n if (this.autoJump) {\n return this.next();\n }\n return {\n index: 0,\n results: this.queryResult\n };\n }\n\n /**\n * @description: 为查询结果项设置自定义单元格样式\n * @param {(typeof this.queryResult)[number]} resultItem 查询结果项\n * @param {boolean} highlight 是否高亮\n * @param {string} customStyleId 自定义样式ID\n */\n arrangeCustomCellStyle(\n resultItem: typeof this.queryResult[number],\n highlight: boolean = true,\n customStyleId: string = HighlightStyleId\n ) {\n const { col, row, range } = resultItem;\n this.table.arrangeCustomCellStyle(\n range\n ? { range }\n : {\n row,\n col\n },\n highlight ? customStyleId : null\n );\n }\n\n updateCellStyle(highlight: boolean = true) {\n if (!highlight) {\n // (this.queryResult || []).forEach(resultItem => {\n // this.arrangeCustomCellStyle(resultItem, highlight);\n // });\n 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,8BAA8B,GAAoC;IACtE,OAAO,EAAE,wBAAwB;CAClC,CAAC;AAEF,SAAS,kBAAkB,CAAC,QAAgB,EAAE,KAAa;IACzD,OAAO,IAAA,gBAAO,EAAC,QAAQ,CAAC,IAAI,IAAA,gBAAO,EAAC,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,IAAA,gBAAO,EAAC,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,C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eAAe,CAAC;IAEzF,IAAI,CAAC,cAAc,EAAE;QAEnB,IAAI,YAAoB,CAAC;QAEzB,IAAI,OAAO,GAAG,SAAS,EAAE;YAEvB,YAAY,GAAG,OAAO,CAAC;SACxB;aAAM;YAEL,YAAY,GAAG,UAAU,GAAG,eAAe,CAAC;SAC7C;QAGD,iBAAiB,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;KACzD;AACH,CAAC","file":"search-component.js","sourcesContent":["import type * as VTable from '@visactor/vtable';\nimport type { ITableAnimationOption } from '@visactor/vtable/src/ts-types';\nimport type { EasingType } from '@visactor/vtable/src/vrender';\nimport { isValid } from '@visactor/vutils';\ntype IVTable = VTable.ListTable | VTable.PivotTable | VTable.PivotChart;\n\nexport type QueryResult = {\n queryStr: string;\n results: {\n col?: number;\n row?: number;\n value?: string;\n indexNumber?: number[];\n }[];\n};\n\nexport type SearchComponentOption = {\n table: IVTable;\n autoJump?: boolean;\n skipHeader?: boolean;\n highlightCellStyle?: VTable.TYPES.CellStyle;\n /**\n * @deprecated use focusHighlightCellStyle instead\n */\n focuseHighlightCellStyle?: VTable.TYPES.CellStyle;\n focusHighlightCellStyle?: VTable.TYPES.CellStyle;\n queryMethod?: (queryStr: string, value: string, option?: { col: number; row: number; table: IVTable }) => boolean;\n treeQueryMethod?: (queryStr: string, node: any, fieldsToSearch?: string[], option?: { table: IVTable }) => boolean;\n fieldsToSearch?: string[];\n scrollOption?: ITableAnimationOption;\n /**\n * 当开启时,搜索结果会自动滚动到视口范围内\n * @since 1.22.4\n */\n enableViewportScroll?: boolean;\n callback?: (queryResult: QueryResult, table: IVTable) => void;\n};\n\nconst HighlightStyleId = '__search_component_highlight';\nconst FocusHighlightStyleId = '__search_component_focus';\n\nconst defaultHighlightCellStyle: Partial<VTable.TYPES.CellStyle> = {\n bgColor: 'rgba(255, 255, 0, 0.2)'\n};\n\nconst defaultFocusHighlightCellStyle: Partial<VTable.TYPES.CellStyle> = {\n bgColor: 'rgba(255, 155, 0, 0.2)'\n};\n\nfunction defaultQueryMethod(queryStr: string, value: string) {\n return isValid(queryStr) && isValid(value) && value.toString().includes(queryStr);\n}\nfunction defaultTreeQueryMethod(queryStr: string, node: any, fieldsToSearch?: string[]) {\n if (!isValid(queryStr)) {\n return false;\n }\n\n // 如果没有传 fieldsToSearch,则用 node 的全部 key\n const searchFields = Array.isArray(fieldsToSearch) && fieldsToSearch.length > 0 ? fieldsToSearch : Object.keys(node);\n\n return searchFields.some(field => isValid(node?.[field]) && node[field].toString().includes(queryStr));\n}\nexport class SearchComponent {\n table: IVTable;\n skipHeader: boolean;\n autoJump: boolean;\n highlightCellStyle: Partial<VTable.TYPES.CellStyle>;\n focuseHighlightCellStyle: Partial<VTable.TYPES.CellStyle>;\n focusHighlightCellStyle: Partial<VTable.TYPES.CellStyle>;\n queryMethod: (queryStr: string, value: string, option: { col: number; row: number; table: IVTable }) => boolean;\n treeQueryMethod: (queryStr: string, node: any, fieldsToSearch?: string[], option?: { table: IVTable }) => boolean;\n fieldsToSearch: string[];\n enableViewportScroll?: boolean;\n callback?: (queryResult: QueryResult, table: IVTable) => void;\n\n queryStr: string;\n queryResult: {\n col?: number;\n row?: number;\n range?: VTable.TYPES.CellRange;\n value?: string;\n indexNumber?: number[];\n }[];\n\n currentIndex: number;\n isTree: boolean;\n treeIndex: number;\n scrollOption: ITableAnimationOption;\n\n constructor(option: SearchComponentOption) {\n this.table = option.table;\n this.autoJump = option.autoJump || false;\n this.skipHeader = option.skipHeader || false;\n this.highlightCellStyle = option.highlightCellStyle || defaultHighlightCellStyle;\n this.focusHighlightCellStyle =\n // 兼容兜底处理,修复拼写错误的问题\n option.focusHighlightCellStyle || option.focuseHighlightCellStyle || defaultFocusHighlightCellStyle;\n this.queryMethod = option.queryMethod || defaultQueryMethod;\n this.treeQueryMethod = option.treeQueryMethod || defaultTreeQueryMethod;\n this.fieldsToSearch = option.fieldsToSearch || [];\n this.isTree = false;\n this.treeIndex = 0;\n this.callback = option.callback;\n this.scrollOption =\n option.scrollOption || ({ duration: 900, easing: 'quartIn' as EasingType } as ITableAnimationOption);\n this.enableViewportScroll = option.enableViewportScroll || false;\n this.table.registerCustomCellStyle(HighlightStyleId, this.highlightCellStyle as any);\n this.table.registerCustomCellStyle(FocusHighlightStyleId, this.focusHighlightCellStyle as any);\n }\n\n search(str: string) {\n this.clear();\n this.queryStr = str;\n\n if (!str) {\n return {\n index: 0,\n results: this.queryResult\n };\n }\n this.isTree = this.table.options.columns.some((item: any) => item.tree);\n this.treeIndex = this.isTree ? this.table.options.columns.findIndex((item: any) => item.tree) : 0;\n if (this.isTree) {\n // 如果传入单一节点也能处理\n const colEnd = this.table.colCount;\n const walk = (nodes: any[], path: number[]) => {\n nodes.forEach((item: any, idx: number) => {\n const currentPath = [...path, idx]; // 当前节点的完整路径\n\n // 保持你的 treeQueryMethod 调用方式(this 上下文来自定义环境)\n if (this.treeQueryMethod(this.queryStr, item, this.fieldsToSearch, { table: this.table })) {\n this.queryResult.push({\n indexNumber: currentPath,\n range: {\n start: { row: null, col: 0 },\n end: { row: null, col: colEnd }\n }\n });\n }\n\n if (item.children && Array.isArray(item.children) && item.children.length > 0) {\n walk(item.children, currentPath);\n }\n });\n };\n\n walk(this.table.records, []);\n if (this.queryResult.length > 0) {\n this.jumpToCell({ IndexNumber: this.queryResult[0].indexNumber });\n }\n\n if (this.callback) {\n this.callback(\n {\n queryStr: this.queryStr,\n results: this.queryResult\n },\n this.table\n );\n }\n this.updateCellStyle();\n\n // if (this.autoJump) {\n // return this.next();\n // }\n this.currentIndex = 0;\n\n return {\n index: 0,\n results: this.queryResult\n };\n }\n for (let row = 0; row < this.table.rowCount; row++) {\n for (let col = 0; col < this.table.colCount; col++) {\n if (this.skipHeader && this.table.isHeader(col, row)) {\n continue;\n }\n const value = this.table.getCellValue(col, row);\n if (this.queryMethod(this.queryStr, value, { col, row, table: this.table })) {\n // deal merge cell\n const mergeCell = this.table.getCellRange(col, row);\n if (mergeCell.start.col !== mergeCell.end.col || mergeCell.start.row !== mergeCell.end.row) {\n // find is cell already in queryResult\n let isIn = false;\n for (let i = this.queryResult.length - 1; i >= 0; i--) {\n if (this.queryResult[i].col === mergeCell.start.col && this.queryResult[i].row === mergeCell.start.row) {\n isIn = true;\n break;\n }\n }\n if (!isIn) {\n this.queryResult.push({\n col: mergeCell.start.col,\n row: mergeCell.start.row,\n range: mergeCell,\n value\n });\n }\n } else {\n this.queryResult.push({\n col,\n row,\n value\n });\n }\n }\n }\n }\n this.updateCellStyle();\n\n if (this.callback) {\n this.callback(\n {\n queryStr: this.queryStr,\n results: this.queryResult\n },\n this.table\n );\n }\n\n if (this.autoJump) {\n return this.next();\n }\n return {\n index: 0,\n results: this.queryResult\n };\n }\n\n /**\n * @description: 为查询结果项设置自定义单元格样式\n * @param {(typeof this.queryResult)[number]} resultItem 查询结果项\n * @param {boolean} highlight 是否高亮\n * @param {string} customStyleId 自定义样式ID\n */\n arrangeCustomCellStyle(\n resultItem: (typeof this.queryResult)[number],\n highlight: boolean = true,\n customStyleId: string = HighlightStyleId\n ) {\n const { col, row, range } = resultItem;\n this.table.arrangeCustomCellStyle(\n range\n ? { range }\n : {\n row,\n col\n },\n highlight ? customStyleId : null\n );\n }\n\n updateCellStyle(highlight: boolean = true) {\n if (!highlight) {\n (this.queryResult || []).forEach(resultItem => {\n this.arrangeCustomCellStyle(resultItem, highlight);\n });\n return;\n }\n if (!this.queryResult) {\n return;\n }\n\n if (!this.table.hasCustomCellStyle(HighlightStyleId)) {\n this.table.registerCustomCellStyle(HighlightStyleId, this.highlightCellStyle as any);\n }\n if (!this.table.hasCustomCellStyle(FocusHighlightStyleId)) {\n this.table.registerCustomCellStyle(FocusHighlightStyleId, this.focusHighlightCellStyle as any);\n }\n if (this.isTree) {\n const { range, indexNumber } = this.queryResult[0];\n\n let i = 0;\n\n // 如果是表头就往下偏移\n while (this.table.isHeader(0, i)) {\n i++;\n }\n const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;\n range.start.row = row;\n range.end.row = row;\n\n this.arrangeCustomCellStyle(\n {\n range\n },\n highlight,\n FocusHighlightStyleId\n );\n } else {\n for (let i = 0; i < this.queryResult.length; i++) {\n this.arrangeCustomCellStyle(this.queryResult[i], highlight);\n }\n }\n }\n\n next() {\n if (!this.queryResult.length) {\n return {\n index: 0,\n results: this.queryResult\n };\n }\n if (this.isTree) {\n if (this.currentIndex !== -1) {\n const { range, indexNumber } = this.queryResult[this.currentIndex];\n\n if (range) {\n let i = 0;\n\n // 如果是表头就往下偏移\n while (this.table.isHeader(0, i)) {\n i++;\n }\n const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;\n range.start.row = row;\n range.end.row = row;\n this.arrangeCustomCellStyle({ range });\n }\n }\n\n this.currentIndex++;\n if (this.currentIndex >= this.queryResult.length) {\n this.currentIndex = 0;\n }\n const { range, indexNumber } = this.queryResult[this.currentIndex];\n this.jumpToCell({ IndexNumber: indexNumber });\n\n if (range) {\n let i = 0;\n\n // 如果是表头就往下偏移\n while (this.table.isHeader(0, i)) {\n i++;\n }\n const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;\n range.start.row = row;\n range.end.row = row;\n this.arrangeCustomCellStyle(\n {\n range\n },\n true,\n FocusHighlightStyleId\n );\n }\n } else {\n if (this.currentIndex !== -1) {\n // reset last focus\n this.arrangeCustomCellStyle(this.queryResult[this.currentIndex]);\n }\n this.currentIndex++;\n if (this.currentIndex >= this.queryResult.length) {\n this.currentIndex = 0;\n }\n const { col, row } = this.queryResult[this.currentIndex];\n\n this.arrangeCustomCellStyle(this.queryResult[this.currentIndex], true, FocusHighlightStyleId);\n\n this.jumpToCell({ col, row });\n }\n\n return {\n index: this.currentIndex,\n results: this.queryResult\n };\n }\n\n prev() {\n if (!this.queryResult.length) {\n return {\n index: 0,\n results: this.queryResult\n };\n }\n\n if (this.isTree) {\n // 先取消当前高亮\n if (this.currentIndex !== -1) {\n const { range, indexNumber } = this.queryResult[this.currentIndex];\n if (range) {\n let i = 0;\n while (this.table.isHeader(0, i)) {\n i++;\n }\n const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;\n range.start.row = row;\n range.end.row = row;\n this.arrangeCustomCellStyle({ range });\n }\n }\n\n // 索引向前\n this.currentIndex--;\n if (this.currentIndex < 0) {\n this.currentIndex = this.queryResult.length - 1;\n }\n\n // 焦点样式\n const { range, indexNumber } = this.queryResult[this.currentIndex];\n this.jumpToCell({ IndexNumber: indexNumber });\n\n if (range) {\n let i = 0;\n while (this.table.isHeader(0, i)) {\n i++;\n }\n const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;\n range.start.row = row;\n range.end.row = row;\n this.arrangeCustomCellStyle({ range }, true, FocusHighlightStyleId);\n }\n } else {\n // 普通表格处理\n if (this.currentIndex !== -1) {\n this.arrangeCustomCellStyle(this.queryResult[this.currentIndex]);\n }\n\n this.currentIndex--;\n if (this.currentIndex < 0) {\n this.currentIndex = this.queryResult.length - 1;\n }\n\n const { col, row } = this.queryResult[this.currentIndex];\n this.arrangeCustomCellStyle(this.queryResult[this.currentIndex], true, FocusHighlightStyleId);\n this.jumpToCell({ col, row });\n }\n\n return {\n index: this.currentIndex,\n results: this.queryResult\n };\n }\n\n jumpToCell(params: { col?: number; row?: number; IndexNumber?: number[] }) {\n if (this.isTree) {\n const { IndexNumber } = params;\n const indexNumbers = [...IndexNumber];\n\n const tmp = [...indexNumbers];\n let tmpNumber = 0;\n let i = 0;\n\n // 展开树形结构的父节点\n while (tmpNumber < tmp.length - 1) {\n tmpNumber++;\n const indexNumber = indexNumbers.slice(0, tmpNumber);\n\n // 跳过表头行\n while (this.table.isHeader(0, i)) {\n i++;\n }\n const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;\n\n const hierarchyState = this.table.getHierarchyState(this.treeIndex, row);\n if (hierarchyState !== 'expand') {\n this.table.toggleHierarchyState(this.treeIndex, row);\n }\n }\n\n const finalRow = this.getBodyRowIndexByRecordIndex(indexNumbers) + i;\n\n // 根据配置决定是否滚动表格\n this.table.scrollToRow(finalRow, this.scrollOption);\n\n // 根据配置决定是否滚动页面\n if (this.enableViewportScroll) {\n scrollVTableCellIntoView(this.table, { row: finalRow, col: this.treeIndex });\n }\n } else {\n const { col, row } = params;\n const { rowStart, rowEnd } = this.table.getBodyVisibleRowRange();\n const { colStart, colEnd } = this.table.getBodyVisibleColRange();\n\n // 检查单元格是否在表格可视范围内\n const isInTableView = !(row <= rowStart || row >= rowEnd || col <= colStart || col >= colEnd);\n\n // 根据配置决定是否滚动表格\n if (!isInTableView) {\n this.table.scrollToCell({ col, row });\n }\n\n // 根据配置决定是否滚动页面\n if (this.enableViewportScroll) {\n scrollVTableCellIntoView(this.table, { row, col });\n }\n }\n }\n getBodyRowIndexByRecordIndex(index: number | number[]): number {\n if (Array.isArray(index) && index.length === 1) {\n index = index[0];\n }\n return this.table.dataSource.getTableIndex(index);\n }\n clear() {\n // reset highlight cell style\n this.updateCellStyle(false);\n this.queryStr = '';\n this.queryResult = [];\n this.currentIndex = -1;\n }\n}\n\nfunction scrollVTableCellIntoView(table: IVTable, cellInfo: { row: number; col: number }): void {\n if (typeof document === 'undefined' || typeof window === 'undefined') {\n return;\n }\n\n const tableEl = table.getElement?.() || table.container;\n if (!tableEl) {\n return;\n }\n\n // 获取单元格在表格中的位置信息\n const cellRect = table.getCellRect(cellInfo.col, cellInfo.row);\n if (!cellRect) {\n return;\n }\n\n // 查找最近的可滚动父容器\n let scrollContainer: Element | null = tableEl.parentElement;\n while (scrollContainer) {\n const computedStyle = getComputedStyle(scrollContainer);\n const hasScroll = /(auto|scroll|overlay)/.test(computedStyle.overflowY);\n const canScroll = scrollContainer.scrollHeight > scrollContainer.clientHeight;\n\n if (hasScroll && canScroll) {\n break;\n }\n\n // 向上查找父元素,包括 Shadow DOM 情况\n scrollContainer = scrollContainer.parentElement || (scrollContainer.getRootNode?.() as ShadowRoot)?.host || null;\n }\n\n // 如果没找到可滚动容器,使用 document\n if (!scrollContainer) {\n scrollContainer = document.scrollingElement || document.documentElement;\n }\n\n const scrollContainerEl = scrollContainer as HTMLElement;\n\n // 计算单元格在滚动容器中的绝对位置\n const tableRect = tableEl.getBoundingClientRect();\n const containerRect = scrollContainerEl.getBoundingClientRect();\n\n // 表格相对于滚动容器的位置\n const tableOffsetTop = tableRect.top - containerRect.top + scrollContainerEl.scrollTop;\n\n // 单元格在滚动容器中的绝对位置\n const cellTop = tableOffsetTop + cellRect.top;\n const cellBottom = cellTop + cellRect.height;\n const containerHeight = scrollContainerEl.clientHeight;\n const scrollTop = scrollContainerEl.scrollTop;\n\n // 检查单元格是否完全可见\n const isFullyVisible = cellTop >= scrollTop && cellBottom <= scrollTop + containerHeight;\n\n if (!isFullyVisible) {\n // 计算新的滚动位置\n let newScrollTop: number;\n\n if (cellTop < scrollTop) {\n // 单元格在上方,滚动到单元格顶部\n newScrollTop = cellTop;\n } else {\n // 单元格在下方,滚动到单元格底部对齐容器底部\n newScrollTop = cellBottom - containerHeight;\n }\n\n // 确保滚动位置不小于 0\n scrollContainerEl.scrollTop = Math.max(0, newScrollTop);\n }\n}\n"]}
@@ -170,11 +170,9 @@
170
170
  }
171
171
  updateCellStyle(highlight = true) {
172
172
  if (!highlight) {
173
- this.table.customCellStylePlugin.clearCustomCellStyleArrangement();
174
173
  (this.queryResult || []).forEach(resultItem => {
175
- this.table.scenegraph.updateCellContent(resultItem.col, resultItem.row);
174
+ this.arrangeCustomCellStyle(resultItem, highlight);
176
175
  });
177
- this.table.scenegraph.updateNextFrame();
178
176
  return;
179
177
  }
180
178
  if (!this.queryResult) {
@@ -201,13 +199,8 @@
201
199
  }
202
200
  else {
203
201
  for (let i = 0; i < this.queryResult.length; i++) {
204
- this.table.customCellStylePlugin.addCustomCellStyleArrangement({
205
- col: this.queryResult[i].col,
206
- row: this.queryResult[i].row
207
- }, HighlightStyleId);
208
- this.table.scenegraph.updateCellContent(this.queryResult[i].col, this.queryResult[i].row, true);
202
+ this.arrangeCustomCellStyle(this.queryResult[i], highlight);
209
203
  }
210
- this.table.scenegraph.updateNextFrame();
211
204
  }
212
205
  }
213
206
  next() {
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).VTable=e.VTable||{},e.VTable.export={}))}(this,(function(e){"use strict";var t=e=>null!=e;const r="__search_component_highlight",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}}}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).VTable=e.VTable||{},e.VTable.export={}))}(this,(function(e){"use strict";var t=e=>null!=e;const r="__search_component_highlight",l="__search_component_focus",s={bgColor:"rgba(255, 255, 0, 0.2)"},i={bgColor:"rgba(255, 155, 0, 0.2)"};function n(e,r){return t(e)&&t(r)&&r.toString().includes(e)}function o(e,r,l){if(!t(e))return!1;return(Array.isArray(l)&&l.length>0?l:Object.keys(r)).some((l=>t(r?.[l])&&r[l].toString().includes(e)))}function h(e,t){if("undefined"==typeof document||"undefined"==typeof window)return;const r=e.getElement?.()||e.container;if(!r)return;const l=e.getCellRect(t.col,t.row);if(!l)return;let s=r.parentElement;for(;s;){const e=getComputedStyle(s),t=/(auto|scroll|overlay)/.test(e.overflowY),r=s.scrollHeight>s.clientHeight;if(t&&r)break;s=s.parentElement||s.getRootNode?.()?.host||null}s||(s=document.scrollingElement||document.documentElement);const i=s,n=r.getBoundingClientRect(),o=i.getBoundingClientRect(),h=n.top-o.top+i.scrollTop+l.top,u=h+l.height,a=i.clientHeight,c=i.scrollTop;if(!(h>=c&&u<=c+a)){let e;e=h<c?h:u-a,i.scrollTop=Math.max(0,e)}}e.SearchComponent=class{table;skipHeader;autoJump;highlightCellStyle;focuseHighlightCellStyle;focusHighlightCellStyle;queryMethod;treeQueryMethod;fieldsToSearch;enableViewportScroll;callback;queryStr;queryResult;currentIndex;isTree;treeIndex;scrollOption;constructor(e){this.table=e.table,this.autoJump=e.autoJump||!1,this.skipHeader=e.skipHeader||!1,this.highlightCellStyle=e.highlightCellStyle||s,this.focusHighlightCellStyle=e.focusHighlightCellStyle||e.focuseHighlightCellStyle||i,this.queryMethod=e.queryMethod||n,this.treeQueryMethod=e.treeQueryMethod||o,this.fieldsToSearch=e.fieldsToSearch||[],this.isTree=!1,this.treeIndex=0,this.callback=e.callback,this.scrollOption=e.scrollOption||{duration:900,easing:"quartIn"},this.enableViewportScroll=e.enableViewportScroll||!1,this.table.registerCustomCellStyle(r,this.highlightCellStyle),this.table.registerCustomCellStyle(l,this.focusHighlightCellStyle)}search(e){if(this.clear(),this.queryStr=e,!e)return{index:0,results:this.queryResult};if(this.isTree=this.table.options.columns.some((e=>e.tree)),this.treeIndex=this.isTree?this.table.options.columns.findIndex((e=>e.tree)):0,this.isTree){const e=this.table.colCount,t=(r,l)=>{r.forEach(((r,s)=>{const i=[...l,s];this.treeQueryMethod(this.queryStr,r,this.fieldsToSearch,{table:this.table})&&this.queryResult.push({indexNumber:i,range:{start:{row:null,col:0},end:{row:null,col:e}}}),r.children&&Array.isArray(r.children)&&r.children.length>0&&t(r.children,i)}))};return t(this.table.records,[]),this.queryResult.length>0&&this.jumpToCell({IndexNumber:this.queryResult[0].indexNumber}),this.callback&&this.callback({queryStr:this.queryStr,results:this.queryResult},this.table),this.updateCellStyle(),this.currentIndex=0,{index:0,results:this.queryResult}}for(let e=0;e<this.table.rowCount;e++)for(let t=0;t<this.table.colCount;t++){if(this.skipHeader&&this.table.isHeader(t,e))continue;const r=this.table.getCellValue(t,e);if(this.queryMethod(this.queryStr,r,{col:t,row:e,table:this.table})){const l=this.table.getCellRange(t,e);if(l.start.col!==l.end.col||l.start.row!==l.end.row){let e=!1;for(let t=this.queryResult.length-1;t>=0;t--)if(this.queryResult[t].col===l.start.col&&this.queryResult[t].row===l.start.row){e=!0;break}e||this.queryResult.push({col:l.start.col,row:l.start.row,range:l,value:r})}else this.queryResult.push({col:t,row:e,value:r})}}return this.updateCellStyle(),this.callback&&this.callback({queryStr:this.queryStr,results:this.queryResult},this.table),this.autoJump?this.next():{index:0,results:this.queryResult}}arrangeCustomCellStyle(e,t=!0,l=r){const{col:s,row:i,range:n}=e;this.table.arrangeCustomCellStyle(n?{range:n}:{row:i,col:s},t?l:null)}updateCellStyle(e=!0){if(e){if(this.queryResult)if(this.table.hasCustomCellStyle(r)||this.table.registerCustomCellStyle(r,this.highlightCellStyle),this.table.hasCustomCellStyle(l)||this.table.registerCustomCellStyle(l,this.focusHighlightCellStyle),this.isTree){const{range:t,indexNumber:r}=this.queryResult[0];let s=0;for(;this.table.isHeader(0,s);)s++;const i=this.getBodyRowIndexByRecordIndex(r)+s;t.start.row=i,t.end.row=i,this.arrangeCustomCellStyle({range:t},e,l)}else for(let t=0;t<this.queryResult.length;t++)this.arrangeCustomCellStyle(this.queryResult[t],e)}else(this.queryResult||[]).forEach((t=>{this.arrangeCustomCellStyle(t,e)}))}next(){if(!this.queryResult.length)return{index:0,results:this.queryResult};if(this.isTree){if(-1!==this.currentIndex){const{range:e,indexNumber:t}=this.queryResult[this.currentIndex];if(e){let r=0;for(;this.table.isHeader(0,r);)r++;const l=this.getBodyRowIndexByRecordIndex(t)+r;e.start.row=l,e.end.row=l,this.arrangeCustomCellStyle({range:e})}}this.currentIndex++,this.currentIndex>=this.queryResult.length&&(this.currentIndex=0);const{range:e,indexNumber:t}=this.queryResult[this.currentIndex];if(this.jumpToCell({IndexNumber:t}),e){let r=0;for(;this.table.isHeader(0,r);)r++;const s=this.getBodyRowIndexByRecordIndex(t)+r;e.start.row=s,e.end.row=s,this.arrangeCustomCellStyle({range:e},!0,l)}}else{-1!==this.currentIndex&&this.arrangeCustomCellStyle(this.queryResult[this.currentIndex]),this.currentIndex++,this.currentIndex>=this.queryResult.length&&(this.currentIndex=0);const{col:e,row:t}=this.queryResult[this.currentIndex];this.arrangeCustomCellStyle(this.queryResult[this.currentIndex],!0,l),this.jumpToCell({col:e,row:t})}return{index:this.currentIndex,results:this.queryResult}}prev(){if(!this.queryResult.length)return{index:0,results:this.queryResult};if(this.isTree){if(-1!==this.currentIndex){const{range:e,indexNumber:t}=this.queryResult[this.currentIndex];if(e){let r=0;for(;this.table.isHeader(0,r);)r++;const l=this.getBodyRowIndexByRecordIndex(t)+r;e.start.row=l,e.end.row=l,this.arrangeCustomCellStyle({range:e})}}this.currentIndex--,this.currentIndex<0&&(this.currentIndex=this.queryResult.length-1);const{range:e,indexNumber:t}=this.queryResult[this.currentIndex];if(this.jumpToCell({IndexNumber:t}),e){let r=0;for(;this.table.isHeader(0,r);)r++;const s=this.getBodyRowIndexByRecordIndex(t)+r;e.start.row=s,e.end.row=s,this.arrangeCustomCellStyle({range:e},!0,l)}}else{-1!==this.currentIndex&&this.arrangeCustomCellStyle(this.queryResult[this.currentIndex]),this.currentIndex--,this.currentIndex<0&&(this.currentIndex=this.queryResult.length-1);const{col:e,row:t}=this.queryResult[this.currentIndex];this.arrangeCustomCellStyle(this.queryResult[this.currentIndex],!0,l),this.jumpToCell({col:e,row:t})}return{index:this.currentIndex,results:this.queryResult}}jumpToCell(e){if(this.isTree){const{IndexNumber:t}=e,r=[...t],l=[...r];let s=0,i=0;for(;s<l.length-1;){s++;const e=r.slice(0,s);for(;this.table.isHeader(0,i);)i++;const t=this.getBodyRowIndexByRecordIndex(e)+i;"expand"!==this.table.getHierarchyState(this.treeIndex,t)&&this.table.toggleHierarchyState(this.treeIndex,t)}const n=this.getBodyRowIndexByRecordIndex(r)+i;this.table.scrollToRow(n,this.scrollOption),this.enableViewportScroll&&h(this.table,{row:n,col:this.treeIndex})}else{const{col:t,row:r}=e,{rowStart:l,rowEnd:s}=this.table.getBodyVisibleRowRange(),{colStart:i,colEnd:n}=this.table.getBodyVisibleColRange();!(r<=l||r>=s||t<=i||t>=n)||this.table.scrollToCell({col:t,row:r}),this.enableViewportScroll&&h(this.table,{row:r,col:t})}}getBodyRowIndexByRecordIndex(e){return Array.isArray(e)&&1===e.length&&(e=e[0]),this.table.dataSource.getTableIndex(e)}clear(){this.updateCellStyle(!1),this.queryStr="",this.queryResult=[],this.currentIndex=-1}}}));
@@ -71,7 +71,7 @@ export declare class SearchComponent {
71
71
  indexNumber?: number[];
72
72
  }[];
73
73
  };
74
- arrangeCustomCellStyle(resultItem: typeof this.queryResult[number], highlight?: boolean, customStyleId?: string): void;
74
+ arrangeCustomCellStyle(resultItem: (typeof this.queryResult)[number], highlight?: boolean, customStyleId?: string): void;
75
75
  updateCellStyle(highlight?: boolean): void;
76
76
  next(): {
77
77
  index: number;
@@ -111,27 +111,21 @@ export class SearchComponent {
111
111
  }, highlight ? customStyleId : null);
112
112
  }
113
113
  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();
118
- if (this.queryResult) if (this.table.hasCustomCellStyle(HighlightStyleId) || this.table.registerCustomCellStyle(HighlightStyleId, this.highlightCellStyle),
119
- 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);
128
- } else {
129
- for (let i = 0; i < this.queryResult.length; i++) this.table.customCellStylePlugin.addCustomCellStyleArrangement({
130
- col: this.queryResult[i].col,
131
- row: this.queryResult[i].row
132
- }, HighlightStyleId), this.table.scenegraph.updateCellContent(this.queryResult[i].col, this.queryResult[i].row, !0);
133
- this.table.scenegraph.updateNextFrame();
134
- }
114
+ if (highlight) {
115
+ if (this.queryResult) if (this.table.hasCustomCellStyle(HighlightStyleId) || this.table.registerCustomCellStyle(HighlightStyleId, this.highlightCellStyle),
116
+ this.table.hasCustomCellStyle(FocusHighlightStyleId) || this.table.registerCustomCellStyle(FocusHighlightStyleId, this.focusHighlightCellStyle),
117
+ this.isTree) {
118
+ const {range: range, indexNumber: indexNumber} = this.queryResult[0];
119
+ let i = 0;
120
+ for (;this.table.isHeader(0, i); ) i++;
121
+ const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;
122
+ range.start.row = row, range.end.row = row, this.arrangeCustomCellStyle({
123
+ range: range
124
+ }, highlight, FocusHighlightStyleId);
125
+ } else for (let i = 0; i < this.queryResult.length; i++) this.arrangeCustomCellStyle(this.queryResult[i], highlight);
126
+ } else (this.queryResult || []).forEach((resultItem => {
127
+ this.arrangeCustomCellStyle(resultItem, highlight);
128
+ }));
135
129
  }
136
130
  next() {
137
131
  if (!this.queryResult.length) return {
@@ -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,IA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C,qBAAqB,EAAE,CAAC;IAClD,MAAM,aAAa,GAAG,iBAAiB,CAAC,qBAAqB,EAAE,CAAC;IAGhE,MAAM,cAAc,GAAG,SAAS,CAAC,GAAG,GAAG,aAAa,CAAC,GAAG,GAAG,iBAAiB,CAAC,SAAS,CAAC;IAGvF,MAAM,OAAO,GAAG,cAAc,GAAG,QAAQ,CAAC,GAAG,CAAC;IAC9C,MAAM,UAAU,GAAG,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC;IAC7C,MAAM,eAAe,GAAG,iBAAiB,CAAC,YAAY,CAAC;IACvD,MAAM,SAAS,GAAG,iBAAiB,CAAC,SAAS,CAAC;IAG9C,MAAM,cAAc,GAAG,OAAO,IAAI,SAAS,IAAI,UAAU,IAAI,SAAS,GAAG,eAAe,CAAC;IAEzF,IAAI,CAAC,cAAc,EAAE;QAEnB,IAAI,YAAoB,CAAC;QAEzB,IAAI,OAAO,GAAG,SAAS,EAAE;YAEvB,YAAY,GAAG,OAAO,CAAC;SACxB;aAAM;YAEL,YAAY,GAAG,UAAU,GAAG,eAAe,CAAC;SAC7C;QAGD,iBAAiB,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;KACzD;AACH,CAAC","file":"search-component.js","sourcesContent":["import type * as VTable from '@visactor/vtable';\nimport type { ITableAnimationOption } from '@visactor/vtable/src/ts-types';\nimport type { EasingType } from '@visactor/vtable/src/vrender';\nimport { isValid } from '@visactor/vutils';\ntype IVTable = VTable.ListTable | VTable.PivotTable | VTable.PivotChart;\n\nexport type QueryResult = {\n queryStr: string;\n results: {\n col?: number;\n row?: number;\n value?: string;\n indexNumber?: number[];\n }[];\n};\n\nexport type SearchComponentOption = {\n table: IVTable;\n autoJump?: boolean;\n skipHeader?: boolean;\n highlightCellStyle?: VTable.TYPES.CellStyle;\n /**\n * @deprecated use focusHighlightCellStyle instead\n */\n focuseHighlightCellStyle?: VTable.TYPES.CellStyle;\n focusHighlightCellStyle?: VTable.TYPES.CellStyle;\n queryMethod?: (queryStr: string, value: string, option?: { col: number; row: number; table: IVTable }) => boolean;\n treeQueryMethod?: (queryStr: string, node: any, fieldsToSearch?: string[], option?: { table: IVTable }) => boolean;\n fieldsToSearch?: string[];\n scrollOption?: ITableAnimationOption;\n /**\n * 当开启时,搜索结果会自动滚动到视口范围内\n * @since 1.22.4\n */\n enableViewportScroll?: boolean;\n callback?: (queryResult: QueryResult, table: IVTable) => void;\n};\n\nconst HighlightStyleId = '__search_component_highlight';\nconst FocusHighlightStyleId = '__search_component_focus';\n\nconst defaultHighlightCellStyle: Partial<VTable.TYPES.CellStyle> = {\n bgColor: 'rgba(255, 255, 0, 0.2)'\n};\n\nconst defaultFocusHighlightCellStyle: Partial<VTable.TYPES.CellStyle> = {\n bgColor: 'rgba(255, 155, 0, 0.2)'\n};\n\nfunction defaultQueryMethod(queryStr: string, value: string) {\n return isValid(queryStr) && isValid(value) && value.toString().includes(queryStr);\n}\nfunction defaultTreeQueryMethod(queryStr: string, node: any, fieldsToSearch?: string[]) {\n if (!isValid(queryStr)) {\n return false;\n }\n\n // 如果没有传 fieldsToSearch,则用 node 的全部 key\n const searchFields = Array.isArray(fieldsToSearch) && fieldsToSearch.length > 0 ? fieldsToSearch : Object.keys(node);\n\n return searchFields.some(field => isValid(node?.[field]) && node[field].toString().includes(queryStr));\n}\nexport class SearchComponent {\n table: IVTable;\n skipHeader: boolean;\n autoJump: boolean;\n highlightCellStyle: Partial<VTable.TYPES.CellStyle>;\n focuseHighlightCellStyle: Partial<VTable.TYPES.CellStyle>;\n focusHighlightCellStyle: Partial<VTable.TYPES.CellStyle>;\n queryMethod: (queryStr: string, value: string, option: { col: number; row: number; table: IVTable }) => boolean;\n treeQueryMethod: (queryStr: string, node: any, fieldsToSearch?: string[], option?: { table: IVTable }) => boolean;\n fieldsToSearch: string[];\n enableViewportScroll?: boolean;\n callback?: (queryResult: QueryResult, table: IVTable) => void;\n\n queryStr: string;\n queryResult: {\n col?: number;\n row?: number;\n range?: VTable.TYPES.CellRange;\n value?: string;\n indexNumber?: number[];\n }[];\n\n currentIndex: number;\n isTree: boolean;\n treeIndex: number;\n scrollOption: ITableAnimationOption;\n\n constructor(option: SearchComponentOption) {\n this.table = option.table;\n this.autoJump = option.autoJump || false;\n this.skipHeader = option.skipHeader || false;\n this.highlightCellStyle = option.highlightCellStyle || defaultHighlightCellStyle;\n this.focusHighlightCellStyle =\n // 兼容兜底处理,修复拼写错误的问题\n option.focusHighlightCellStyle || option.focuseHighlightCellStyle || defaultFocusHighlightCellStyle;\n this.queryMethod = option.queryMethod || defaultQueryMethod;\n this.treeQueryMethod = option.treeQueryMethod || defaultTreeQueryMethod;\n this.fieldsToSearch = option.fieldsToSearch || [];\n this.isTree = false;\n this.treeIndex = 0;\n this.callback = option.callback;\n this.scrollOption =\n option.scrollOption || ({ duration: 900, easing: 'quartIn' as EasingType } as ITableAnimationOption);\n this.enableViewportScroll = option.enableViewportScroll || false;\n this.table.registerCustomCellStyle(HighlightStyleId, this.highlightCellStyle as any);\n this.table.registerCustomCellStyle(FocusHighlightStyleId, this.focusHighlightCellStyle as any);\n }\n\n search(str: string) {\n this.clear();\n this.queryStr = str;\n\n if (!str) {\n return {\n index: 0,\n results: this.queryResult\n };\n }\n this.isTree = this.table.options.columns.some((item: any) => item.tree);\n this.treeIndex = this.isTree ? this.table.options.columns.findIndex((item: any) => item.tree) : 0;\n if (this.isTree) {\n // 如果传入单一节点也能处理\n const colEnd = this.table.colCount;\n const walk = (nodes: any[], path: number[]) => {\n nodes.forEach((item: any, idx: number) => {\n const currentPath = [...path, idx]; // 当前节点的完整路径\n\n // 保持你的 treeQueryMethod 调用方式(this 上下文来自定义环境)\n if (this.treeQueryMethod(this.queryStr, item, this.fieldsToSearch, { table: this.table })) {\n this.queryResult.push({\n indexNumber: currentPath,\n range: {\n start: { row: null, col: 0 },\n end: { row: null, col: colEnd }\n }\n });\n }\n\n if (item.children && Array.isArray(item.children) && item.children.length > 0) {\n walk(item.children, currentPath);\n }\n });\n };\n\n walk(this.table.records, []);\n if (this.queryResult.length > 0) {\n this.jumpToCell({ IndexNumber: this.queryResult[0].indexNumber });\n }\n\n if (this.callback) {\n this.callback(\n {\n queryStr: this.queryStr,\n results: this.queryResult\n },\n this.table\n );\n }\n this.updateCellStyle();\n\n // if (this.autoJump) {\n // return this.next();\n // }\n this.currentIndex = 0;\n\n return {\n index: 0,\n results: this.queryResult\n };\n }\n for (let row = 0; row < this.table.rowCount; row++) {\n for (let col = 0; col < this.table.colCount; col++) {\n if (this.skipHeader && this.table.isHeader(col, row)) {\n continue;\n }\n const value = this.table.getCellValue(col, row);\n if (this.queryMethod(this.queryStr, value, { col, row, table: this.table })) {\n // deal merge cell\n const mergeCell = this.table.getCellRange(col, row);\n if (mergeCell.start.col !== mergeCell.end.col || mergeCell.start.row !== mergeCell.end.row) {\n // find is cell already in queryResult\n let isIn = false;\n for (let i = this.queryResult.length - 1; i >= 0; i--) {\n if (this.queryResult[i].col === mergeCell.start.col && this.queryResult[i].row === mergeCell.start.row) {\n isIn = true;\n break;\n }\n }\n if (!isIn) {\n this.queryResult.push({\n col: mergeCell.start.col,\n row: mergeCell.start.row,\n range: mergeCell,\n value\n });\n }\n } else {\n this.queryResult.push({\n col,\n row,\n value\n });\n }\n }\n }\n }\n this.updateCellStyle();\n\n if (this.callback) {\n this.callback(\n {\n queryStr: this.queryStr,\n results: this.queryResult\n },\n this.table\n );\n }\n\n if (this.autoJump) {\n return this.next();\n }\n return {\n index: 0,\n results: this.queryResult\n };\n }\n\n /**\n * @description: 为查询结果项设置自定义单元格样式\n * @param {(typeof this.queryResult)[number]} resultItem 查询结果项\n * @param {boolean} highlight 是否高亮\n * @param {string} customStyleId 自定义样式ID\n */\n arrangeCustomCellStyle(\n resultItem: typeof this.queryResult[number],\n highlight: boolean = true,\n customStyleId: string = HighlightStyleId\n ) {\n const { col, row, range } = resultItem;\n this.table.arrangeCustomCellStyle(\n range\n ? { range }\n : {\n row,\n col\n },\n highlight ? customStyleId : null\n );\n }\n\n updateCellStyle(highlight: boolean = true) {\n if (!highlight) {\n // (this.queryResult || []).forEach(resultItem => {\n // this.arrangeCustomCellStyle(resultItem, highlight);\n // });\n 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,C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iBAAiB,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;KACzD;AACH,CAAC","file":"search-component.js","sourcesContent":["import type * as VTable from '@visactor/vtable';\nimport type { ITableAnimationOption } from '@visactor/vtable/src/ts-types';\nimport type { EasingType } from '@visactor/vtable/src/vrender';\nimport { isValid } from '@visactor/vutils';\ntype IVTable = VTable.ListTable | VTable.PivotTable | VTable.PivotChart;\n\nexport type QueryResult = {\n queryStr: string;\n results: {\n col?: number;\n row?: number;\n value?: string;\n indexNumber?: number[];\n }[];\n};\n\nexport type SearchComponentOption = {\n table: IVTable;\n autoJump?: boolean;\n skipHeader?: boolean;\n highlightCellStyle?: VTable.TYPES.CellStyle;\n /**\n * @deprecated use focusHighlightCellStyle instead\n */\n focuseHighlightCellStyle?: VTable.TYPES.CellStyle;\n focusHighlightCellStyle?: VTable.TYPES.CellStyle;\n queryMethod?: (queryStr: string, value: string, option?: { col: number; row: number; table: IVTable }) => boolean;\n treeQueryMethod?: (queryStr: string, node: any, fieldsToSearch?: string[], option?: { table: IVTable }) => boolean;\n fieldsToSearch?: string[];\n scrollOption?: ITableAnimationOption;\n /**\n * 当开启时,搜索结果会自动滚动到视口范围内\n * @since 1.22.4\n */\n enableViewportScroll?: boolean;\n callback?: (queryResult: QueryResult, table: IVTable) => void;\n};\n\nconst HighlightStyleId = '__search_component_highlight';\nconst FocusHighlightStyleId = '__search_component_focus';\n\nconst defaultHighlightCellStyle: Partial<VTable.TYPES.CellStyle> = {\n bgColor: 'rgba(255, 255, 0, 0.2)'\n};\n\nconst defaultFocusHighlightCellStyle: Partial<VTable.TYPES.CellStyle> = {\n bgColor: 'rgba(255, 155, 0, 0.2)'\n};\n\nfunction defaultQueryMethod(queryStr: string, value: string) {\n return isValid(queryStr) && isValid(value) && value.toString().includes(queryStr);\n}\nfunction defaultTreeQueryMethod(queryStr: string, node: any, fieldsToSearch?: string[]) {\n if (!isValid(queryStr)) {\n return false;\n }\n\n // 如果没有传 fieldsToSearch,则用 node 的全部 key\n const searchFields = Array.isArray(fieldsToSearch) && fieldsToSearch.length > 0 ? fieldsToSearch : Object.keys(node);\n\n return searchFields.some(field => isValid(node?.[field]) && node[field].toString().includes(queryStr));\n}\nexport class SearchComponent {\n table: IVTable;\n skipHeader: boolean;\n autoJump: boolean;\n highlightCellStyle: Partial<VTable.TYPES.CellStyle>;\n focuseHighlightCellStyle: Partial<VTable.TYPES.CellStyle>;\n focusHighlightCellStyle: Partial<VTable.TYPES.CellStyle>;\n queryMethod: (queryStr: string, value: string, option: { col: number; row: number; table: IVTable }) => boolean;\n treeQueryMethod: (queryStr: string, node: any, fieldsToSearch?: string[], option?: { table: IVTable }) => boolean;\n fieldsToSearch: string[];\n enableViewportScroll?: boolean;\n callback?: (queryResult: QueryResult, table: IVTable) => void;\n\n queryStr: string;\n queryResult: {\n col?: number;\n row?: number;\n range?: VTable.TYPES.CellRange;\n value?: string;\n indexNumber?: number[];\n }[];\n\n currentIndex: number;\n isTree: boolean;\n treeIndex: number;\n scrollOption: ITableAnimationOption;\n\n constructor(option: SearchComponentOption) {\n this.table = option.table;\n this.autoJump = option.autoJump || false;\n this.skipHeader = option.skipHeader || false;\n this.highlightCellStyle = option.highlightCellStyle || defaultHighlightCellStyle;\n this.focusHighlightCellStyle =\n // 兼容兜底处理,修复拼写错误的问题\n option.focusHighlightCellStyle || option.focuseHighlightCellStyle || defaultFocusHighlightCellStyle;\n this.queryMethod = option.queryMethod || defaultQueryMethod;\n this.treeQueryMethod = option.treeQueryMethod || defaultTreeQueryMethod;\n this.fieldsToSearch = option.fieldsToSearch || [];\n this.isTree = false;\n this.treeIndex = 0;\n this.callback = option.callback;\n this.scrollOption =\n option.scrollOption || ({ duration: 900, easing: 'quartIn' as EasingType } as ITableAnimationOption);\n this.enableViewportScroll = option.enableViewportScroll || false;\n this.table.registerCustomCellStyle(HighlightStyleId, this.highlightCellStyle as any);\n this.table.registerCustomCellStyle(FocusHighlightStyleId, this.focusHighlightCellStyle as any);\n }\n\n search(str: string) {\n this.clear();\n this.queryStr = str;\n\n if (!str) {\n return {\n index: 0,\n results: this.queryResult\n };\n }\n this.isTree = this.table.options.columns.some((item: any) => item.tree);\n this.treeIndex = this.isTree ? this.table.options.columns.findIndex((item: any) => item.tree) : 0;\n if (this.isTree) {\n // 如果传入单一节点也能处理\n const colEnd = this.table.colCount;\n const walk = (nodes: any[], path: number[]) => {\n nodes.forEach((item: any, idx: number) => {\n const currentPath = [...path, idx]; // 当前节点的完整路径\n\n // 保持你的 treeQueryMethod 调用方式(this 上下文来自定义环境)\n if (this.treeQueryMethod(this.queryStr, item, this.fieldsToSearch, { table: this.table })) {\n this.queryResult.push({\n indexNumber: currentPath,\n range: {\n start: { row: null, col: 0 },\n end: { row: null, col: colEnd }\n }\n });\n }\n\n if (item.children && Array.isArray(item.children) && item.children.length > 0) {\n walk(item.children, currentPath);\n }\n });\n };\n\n walk(this.table.records, []);\n if (this.queryResult.length > 0) {\n this.jumpToCell({ IndexNumber: this.queryResult[0].indexNumber });\n }\n\n if (this.callback) {\n this.callback(\n {\n queryStr: this.queryStr,\n results: this.queryResult\n },\n this.table\n );\n }\n this.updateCellStyle();\n\n // if (this.autoJump) {\n // return this.next();\n // }\n this.currentIndex = 0;\n\n return {\n index: 0,\n results: this.queryResult\n };\n }\n for (let row = 0; row < this.table.rowCount; row++) {\n for (let col = 0; col < this.table.colCount; col++) {\n if (this.skipHeader && this.table.isHeader(col, row)) {\n continue;\n }\n const value = this.table.getCellValue(col, row);\n if (this.queryMethod(this.queryStr, value, { col, row, table: this.table })) {\n // deal merge cell\n const mergeCell = this.table.getCellRange(col, row);\n if (mergeCell.start.col !== mergeCell.end.col || mergeCell.start.row !== mergeCell.end.row) {\n // find is cell already in queryResult\n let isIn = false;\n for (let i = this.queryResult.length - 1; i >= 0; i--) {\n if (this.queryResult[i].col === mergeCell.start.col && this.queryResult[i].row === mergeCell.start.row) {\n isIn = true;\n break;\n }\n }\n if (!isIn) {\n this.queryResult.push({\n col: mergeCell.start.col,\n row: mergeCell.start.row,\n range: mergeCell,\n value\n });\n }\n } else {\n this.queryResult.push({\n col,\n row,\n value\n });\n }\n }\n }\n }\n this.updateCellStyle();\n\n if (this.callback) {\n this.callback(\n {\n queryStr: this.queryStr,\n results: this.queryResult\n },\n this.table\n );\n }\n\n if (this.autoJump) {\n return this.next();\n }\n return {\n index: 0,\n results: this.queryResult\n };\n }\n\n /**\n * @description: 为查询结果项设置自定义单元格样式\n * @param {(typeof this.queryResult)[number]} resultItem 查询结果项\n * @param {boolean} highlight 是否高亮\n * @param {string} customStyleId 自定义样式ID\n */\n arrangeCustomCellStyle(\n resultItem: (typeof this.queryResult)[number],\n highlight: boolean = true,\n customStyleId: string = HighlightStyleId\n ) {\n const { col, row, range } = resultItem;\n this.table.arrangeCustomCellStyle(\n range\n ? { range }\n : {\n row,\n col\n },\n highlight ? customStyleId : null\n );\n }\n\n updateCellStyle(highlight: boolean = true) {\n if (!highlight) {\n (this.queryResult || []).forEach(resultItem => {\n this.arrangeCustomCellStyle(resultItem, highlight);\n });\n return;\n }\n if (!this.queryResult) {\n return;\n }\n\n if (!this.table.hasCustomCellStyle(HighlightStyleId)) {\n this.table.registerCustomCellStyle(HighlightStyleId, this.highlightCellStyle as any);\n }\n if (!this.table.hasCustomCellStyle(FocusHighlightStyleId)) {\n this.table.registerCustomCellStyle(FocusHighlightStyleId, this.focusHighlightCellStyle as any);\n }\n if (this.isTree) {\n const { range, indexNumber } = this.queryResult[0];\n\n let i = 0;\n\n // 如果是表头就往下偏移\n while (this.table.isHeader(0, i)) {\n i++;\n }\n const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;\n range.start.row = row;\n range.end.row = row;\n\n this.arrangeCustomCellStyle(\n {\n range\n },\n highlight,\n FocusHighlightStyleId\n );\n } else {\n for (let i = 0; i < this.queryResult.length; i++) {\n this.arrangeCustomCellStyle(this.queryResult[i], highlight);\n }\n }\n }\n\n next() {\n if (!this.queryResult.length) {\n return {\n index: 0,\n results: this.queryResult\n };\n }\n if (this.isTree) {\n if (this.currentIndex !== -1) {\n const { range, indexNumber } = this.queryResult[this.currentIndex];\n\n if (range) {\n let i = 0;\n\n // 如果是表头就往下偏移\n while (this.table.isHeader(0, i)) {\n i++;\n }\n const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;\n range.start.row = row;\n range.end.row = row;\n this.arrangeCustomCellStyle({ range });\n }\n }\n\n this.currentIndex++;\n if (this.currentIndex >= this.queryResult.length) {\n this.currentIndex = 0;\n }\n const { range, indexNumber } = this.queryResult[this.currentIndex];\n this.jumpToCell({ IndexNumber: indexNumber });\n\n if (range) {\n let i = 0;\n\n // 如果是表头就往下偏移\n while (this.table.isHeader(0, i)) {\n i++;\n }\n const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;\n range.start.row = row;\n range.end.row = row;\n this.arrangeCustomCellStyle(\n {\n range\n },\n true,\n FocusHighlightStyleId\n );\n }\n } else {\n if (this.currentIndex !== -1) {\n // reset last focus\n this.arrangeCustomCellStyle(this.queryResult[this.currentIndex]);\n }\n this.currentIndex++;\n if (this.currentIndex >= this.queryResult.length) {\n this.currentIndex = 0;\n }\n const { col, row } = this.queryResult[this.currentIndex];\n\n this.arrangeCustomCellStyle(this.queryResult[this.currentIndex], true, FocusHighlightStyleId);\n\n this.jumpToCell({ col, row });\n }\n\n return {\n index: this.currentIndex,\n results: this.queryResult\n };\n }\n\n prev() {\n if (!this.queryResult.length) {\n return {\n index: 0,\n results: this.queryResult\n };\n }\n\n if (this.isTree) {\n // 先取消当前高亮\n if (this.currentIndex !== -1) {\n const { range, indexNumber } = this.queryResult[this.currentIndex];\n if (range) {\n let i = 0;\n while (this.table.isHeader(0, i)) {\n i++;\n }\n const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;\n range.start.row = row;\n range.end.row = row;\n this.arrangeCustomCellStyle({ range });\n }\n }\n\n // 索引向前\n this.currentIndex--;\n if (this.currentIndex < 0) {\n this.currentIndex = this.queryResult.length - 1;\n }\n\n // 焦点样式\n const { range, indexNumber } = this.queryResult[this.currentIndex];\n this.jumpToCell({ IndexNumber: indexNumber });\n\n if (range) {\n let i = 0;\n while (this.table.isHeader(0, i)) {\n i++;\n }\n const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;\n range.start.row = row;\n range.end.row = row;\n this.arrangeCustomCellStyle({ range }, true, FocusHighlightStyleId);\n }\n } else {\n // 普通表格处理\n if (this.currentIndex !== -1) {\n this.arrangeCustomCellStyle(this.queryResult[this.currentIndex]);\n }\n\n this.currentIndex--;\n if (this.currentIndex < 0) {\n this.currentIndex = this.queryResult.length - 1;\n }\n\n const { col, row } = this.queryResult[this.currentIndex];\n this.arrangeCustomCellStyle(this.queryResult[this.currentIndex], true, FocusHighlightStyleId);\n this.jumpToCell({ col, row });\n }\n\n return {\n index: this.currentIndex,\n results: this.queryResult\n };\n }\n\n jumpToCell(params: { col?: number; row?: number; IndexNumber?: number[] }) {\n if (this.isTree) {\n const { IndexNumber } = params;\n const indexNumbers = [...IndexNumber];\n\n const tmp = [...indexNumbers];\n let tmpNumber = 0;\n let i = 0;\n\n // 展开树形结构的父节点\n while (tmpNumber < tmp.length - 1) {\n tmpNumber++;\n const indexNumber = indexNumbers.slice(0, tmpNumber);\n\n // 跳过表头行\n while (this.table.isHeader(0, i)) {\n i++;\n }\n const row = this.getBodyRowIndexByRecordIndex(indexNumber) + i;\n\n const hierarchyState = this.table.getHierarchyState(this.treeIndex, row);\n if (hierarchyState !== 'expand') {\n this.table.toggleHierarchyState(this.treeIndex, row);\n }\n }\n\n const finalRow = this.getBodyRowIndexByRecordIndex(indexNumbers) + i;\n\n // 根据配置决定是否滚动表格\n this.table.scrollToRow(finalRow, this.scrollOption);\n\n // 根据配置决定是否滚动页面\n if (this.enableViewportScroll) {\n scrollVTableCellIntoView(this.table, { row: finalRow, col: this.treeIndex });\n }\n } else {\n const { col, row } = params;\n const { rowStart, rowEnd } = this.table.getBodyVisibleRowRange();\n const { colStart, colEnd } = this.table.getBodyVisibleColRange();\n\n // 检查单元格是否在表格可视范围内\n const isInTableView = !(row <= rowStart || row >= rowEnd || col <= colStart || col >= colEnd);\n\n // 根据配置决定是否滚动表格\n if (!isInTableView) {\n this.table.scrollToCell({ col, row });\n }\n\n // 根据配置决定是否滚动页面\n if (this.enableViewportScroll) {\n scrollVTableCellIntoView(this.table, { row, col });\n }\n }\n }\n getBodyRowIndexByRecordIndex(index: number | number[]): number {\n if (Array.isArray(index) && index.length === 1) {\n index = index[0];\n }\n return this.table.dataSource.getTableIndex(index);\n }\n clear() {\n // reset highlight cell style\n this.updateCellStyle(false);\n this.queryStr = '';\n this.queryResult = [];\n this.currentIndex = -1;\n }\n}\n\nfunction scrollVTableCellIntoView(table: IVTable, cellInfo: { row: number; col: number }): void {\n if (typeof document === 'undefined' || typeof window === 'undefined') {\n return;\n }\n\n const tableEl = table.getElement?.() || table.container;\n if (!tableEl) {\n return;\n }\n\n // 获取单元格在表格中的位置信息\n const cellRect = table.getCellRect(cellInfo.col, cellInfo.row);\n if (!cellRect) {\n return;\n }\n\n // 查找最近的可滚动父容器\n let scrollContainer: Element | null = tableEl.parentElement;\n while (scrollContainer) {\n const computedStyle = getComputedStyle(scrollContainer);\n const hasScroll = /(auto|scroll|overlay)/.test(computedStyle.overflowY);\n const canScroll = scrollContainer.scrollHeight > scrollContainer.clientHeight;\n\n if (hasScroll && canScroll) {\n break;\n }\n\n // 向上查找父元素,包括 Shadow DOM 情况\n scrollContainer = scrollContainer.parentElement || (scrollContainer.getRootNode?.() as ShadowRoot)?.host || null;\n }\n\n // 如果没找到可滚动容器,使用 document\n if (!scrollContainer) {\n scrollContainer = document.scrollingElement || document.documentElement;\n }\n\n const scrollContainerEl = scrollContainer as HTMLElement;\n\n // 计算单元格在滚动容器中的绝对位置\n const tableRect = tableEl.getBoundingClientRect();\n const containerRect = scrollContainerEl.getBoundingClientRect();\n\n // 表格相对于滚动容器的位置\n const tableOffsetTop = tableRect.top - containerRect.top + scrollContainerEl.scrollTop;\n\n // 单元格在滚动容器中的绝对位置\n const cellTop = tableOffsetTop + cellRect.top;\n const cellBottom = cellTop + cellRect.height;\n const containerHeight = scrollContainerEl.clientHeight;\n const scrollTop = scrollContainerEl.scrollTop;\n\n // 检查单元格是否完全可见\n const isFullyVisible = cellTop >= scrollTop && cellBottom <= scrollTop + containerHeight;\n\n if (!isFullyVisible) {\n // 计算新的滚动位置\n let newScrollTop: number;\n\n if (cellTop < scrollTop) {\n // 单元格在上方,滚动到单元格顶部\n newScrollTop = cellTop;\n } else {\n // 单元格在下方,滚动到单元格底部对齐容器底部\n newScrollTop = cellBottom - containerHeight;\n }\n\n // 确保滚动位置不小于 0\n scrollContainerEl.scrollTop = Math.max(0, newScrollTop);\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visactor/vtable-search",
3
- "version": "1.22.11-alpha.7",
3
+ "version": "1.22.11-alpha.8",
4
4
  "description": "The search util of VTable",
5
5
  "author": {
6
6
  "name": "VisActor",
@@ -30,13 +30,13 @@
30
30
  "access": "public"
31
31
  },
32
32
  "dependencies": {
33
- "@visactor/vtable": "1.22.11-alpha.7",
33
+ "@visactor/vtable": "1.22.11-alpha.8",
34
34
  "@visactor/vutils": "~1.0.17"
35
35
  },
36
36
  "devDependencies": {
37
37
  "cross-env": "^7.0.3",
38
38
  "increase-memory-limit": "^1.0.7",
39
- "@visactor/vchart": "2.0.11-alpha.3",
39
+ "@visactor/vchart": " 2.0.13-alpha.9",
40
40
  "@rushstack/eslint-patch": "~1.1.4",
41
41
  "react": "^18.0.0",
42
42
  "react-dom": "^18.0.0",
@@ -78,8 +78,8 @@
78
78
  "@types/react-is": "^17.0.3",
79
79
  "rollup-plugin-node-resolve": "5.2.0",
80
80
  "@internal/bundler": "0.0.1",
81
- "@internal/ts-config": "0.0.1",
82
- "@internal/eslint-config": "0.0.1"
81
+ "@internal/eslint-config": "0.0.1",
82
+ "@internal/ts-config": "0.0.1"
83
83
  },
84
84
  "scripts": {
85
85
  "start": "vite ./demo",