@visactor/vtable-plugins 1.22.4-alpha.3 → 1.22.4-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -42,8 +42,8 @@ class FilterToolbar {
42
42
  this.clearFilterOptionLink.style.cursor = hasActiveFilter ? "pointer" : "not-allowed";
43
43
  }
44
44
  render(container) {
45
- this.filterMenu = document.createElement("div"), (0, styles_1.applyStyles)(this.filterMenu, this.styles.filterMenu),
46
- this.filterMenu.style.width = `${this.filterMenuWidth}px`;
45
+ this.filterMenu = document.createElement("div"), this.filterMenu.classList.add("vtable-filter-menu"),
46
+ (0, styles_1.applyStyles)(this.filterMenu, this.styles.filterMenu), this.filterMenu.style.width = `${this.filterMenuWidth}px`;
47
47
  const filterTabsContainer = document.createElement("div");
48
48
  (0, styles_1.applyStyles)(filterTabsContainer, this.styles.tabsContainer), this.filterTabByValue = document.createElement("button"),
49
49
  this.filterTabByValue.innerText = "按值筛选", (0, styles_1.applyStyles)(this.filterTabByValue, this.styles.tabStyle(!0)),
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/filter/filter-toolbar.ts"],"names":[],"mappings":";;;AAEA,iDAA6C;AAC7C,yDAAqD;AACrD,qCAAuC;AAMvC,MAAa,aAAa;IAsBxB,YAAY,KAA6B,EAAE,kBAAsC,EAAE,MAAoB;QAjBvG,gBAAW,GAAuB,IAAI,CAAC;QACvC,oBAAe,GAA2B,IAAI,CAAC;QAC/C,cAAS,GAA8B,SAAS,CAAC;QACjD,cAAS,GAAY,KAAK,CAAC;QAC3B,kBAAa,GAA2B,IAAI,CAAC;QAC7C,gBAAW,GAAiB,EAAE,CAAC;QAa7B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;QAC7C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,IAAI,0BAAW,CAAC,IAAI,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AC,aAAa,CAAC,SAAS,CAAC,cAAc,CAAC,GAAG,EAAE,GAAG,CAAoB,CAAC;QAC7F,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;QAGhC,MAAM,aAAa,GAAG,IAAI,CAAC,kBAAkB,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QACpE,IAAI,aAAa,IAAI,aAAa,CAAC,IAAI,KAAK,aAAa,EAAE;YACzD,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;SACjC;aAAM;YACL,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;SAC7B;QAGD,IAAI,CAAC,4BAA4B,CAAC,KAAK,CAAC,CAAC;QAGzC,UAAU,CAAC,GAAG,EAAE;YACd,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACxB,CAAC,EAAE,CAAC,CAAC,CAAC;IACR,CAAC;IAED,IAAI;QACF,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;QACvC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IACzB,CAAC;CACF;AA3QD,sCA2QC","file":"filter-toolbar.js","sourcesContent":["import type { ListTable, PivotTable } from '@visactor/vtable';\nimport type { FilterStateManager } from './filter-state-manager';\nimport { ValueFilter } from './value-filter';\nimport { ConditionFilter } from './condition-filter';\nimport { applyStyles } from './styles';\nimport type { FilterMode, FilterStyles } from './types';\n\n/**\n * 筛选工具栏,管理按值和按条件筛选组件\n */\nexport class FilterToolbar {\n table: ListTable | PivotTable;\n filterStateManager: FilterStateManager;\n styles: FilterStyles;\n\n valueFilter: ValueFilter | null = null;\n conditionFilter: ConditionFilter | null = null;\n activeTab: 'byValue' | 'byCondition' = 'byValue';\n isVisible: boolean = false;\n selectedField: string | number | null = null;\n filterModes: FilterMode[] = [];\n\n private filterMenu: HTMLElement;\n private filterMenuWidth: number;\n private currentCol?: number | null;\n private currentRow?: number | null;\n private filterTabByValue: HTMLButtonElement;\n private filterTabByCondition: HTMLButtonElement;\n private clearFilterOptionLink: HTMLAnchorElement;\n private cancelFilterButton: HTMLButtonElement;\n private applyFilterButton: HTMLButtonElement;\n\n constructor(table: ListTable | PivotTable, filterStateManager: FilterStateManager, styles: FilterStyles) {\n this.table = table;\n this.filterStateManager = filterStateManager;\n this.styles = styles;\n this.valueFilter = new ValueFilter(this.table, this.filterStateManager, this.styles);\n this.conditionFilter = new ConditionFilter(this.table, this.filterStateManager, this.styles);\n\n this.filterMenuWidth = 300; // 待优化,可能需要自适应内容的宽度\n\n // 监听筛选状态变化,更新清除筛选按钮状态\n this.filterStateManager.subscribe(state => {\n if (this.isVisible && this.selectedField !== null) {\n this.updateClearFilterButtonState(this.selectedField);\n }\n });\n }\n\n private onTabSwitch(tab: 'byValue' | 'byCondition'): void {\n this.activeTab = tab;\n if (tab === 'byValue') {\n this.valueFilter.show();\n this.conditionFilter.hide();\n } else {\n this.conditionFilter.show();\n this.valueFilter.hide();\n }\n\n const isValueTab = tab === 'byValue';\n applyStyles(this.filterTabByValue, this.styles.tabStyle(isValueTab));\n applyStyles(this.filterTabByCondition, this.styles.tabStyle(!isValueTab));\n }\n\n private updateSelectedField(field: string | number): void {\n this.selectedField = field;\n // 通知筛选组件更新选中字段\n if (this.valueFilter) {\n this.valueFilter.setSelectedField(field);\n }\n if (this.conditionFilter) {\n this.conditionFilter.setSelectedField(field);\n }\n }\n\n private applyFilter(field: string | number): void {\n if (this.activeTab === 'byValue') {\n this.valueFilter.applyFilter(field);\n } else if (this.activeTab === 'byCondition') {\n this.conditionFilter.applyFilter(field);\n }\n this.hide();\n }\n\n private clearFilter(field: string | number): void {\n if (this.valueFilter) {\n this.valueFilter.clearFilter(field);\n }\n if (this.conditionFilter) {\n this.conditionFilter.clearFilter(field);\n }\n this.hide();\n }\n\n /**\n * 更新清除筛选按钮的状态\n */\n private updateClearFilterButtonState(field: string | number): void {\n const currentFilter = this.filterStateManager.getFilterState(field);\n const hasActiveFilter = currentFilter && currentFilter.enable;\n\n this.clearFilterOptionLink.style.display = 'inline';\n this.clearFilterOptionLink.style.opacity = hasActiveFilter ? '1' : '0.5';\n this.clearFilterOptionLink.style.pointerEvents = hasActiveFilter ? 'auto' : 'none';\n this.clearFilterOptionLink.style.cursor = hasActiveFilter ? 'pointer' : 'not-allowed';\n }\n\n render(container: HTMLElement): void {\n // === 主容器 ===\n this.filterMenu = document.createElement('div');\n applyStyles(this.filterMenu, this.styles.filterMenu);\n this.filterMenu.style.width = `${this.filterMenuWidth}px`;\n\n // === 筛选 Tab ===\n const filterTabsContainer = document.createElement('div');\n applyStyles(filterTabsContainer, this.styles.tabsContainer);\n\n this.filterTabByValue = document.createElement('button');\n this.filterTabByValue.innerText = '按值筛选';\n applyStyles(this.filterTabByValue, this.styles.tabStyle(true));\n\n this.filterTabByCondition = document.createElement('button');\n this.filterTabByCondition.innerText = '按条件筛选';\n applyStyles(this.filterTabByCondition, this.styles.tabStyle(false));\n\n filterTabsContainer.append(this.filterTabByValue, this.filterTabByCondition);\n\n // === 页脚(清除、取消、确定 筛选按钮) ===\n const footerContainer = document.createElement('div');\n applyStyles(footerContainer, this.styles.footerContainer);\n\n this.clearFilterOptionLink = document.createElement('a');\n this.clearFilterOptionLink.href = '#';\n this.clearFilterOptionLink.innerText = '清除筛选';\n applyStyles(this.clearFilterOptionLink, this.styles.clearLink);\n\n const footerButtons = document.createElement('div');\n this.cancelFilterButton = document.createElement('button');\n this.cancelFilterButton.innerText = '取消';\n applyStyles(this.cancelFilterButton, this.styles.footerButton(false));\n\n this.applyFilterButton = document.createElement('button');\n this.applyFilterButton.innerText = '确认';\n applyStyles(this.applyFilterButton, this.styles.footerButton(true));\n\n footerButtons.append(this.cancelFilterButton, this.applyFilterButton);\n footerContainer.append(this.clearFilterOptionLink, footerButtons);\n\n // --- 筛选器头部 Tab ---\n this.filterMenu.append(filterTabsContainer);\n\n // --- 筛选器内容 ---\n this.valueFilter.render(this.filterMenu);\n this.conditionFilter.render(this.filterMenu);\n\n // --- 筛选器页脚 ---\n this.filterMenu.append(footerContainer);\n\n container.appendChild(this.filterMenu); // 将筛选器添加到 DOM 中\n this.attachEventListeners();\n }\n\n attachEventListeners() {\n // 按值筛选/按条件筛选的事件监听\n this.filterTabByValue.addEventListener('click', () => {\n this.onTabSwitch('byValue');\n });\n\n this.filterTabByCondition.addEventListener('click', () => {\n this.onTabSwitch('byCondition');\n });\n\n this.cancelFilterButton.addEventListener('click', () => this.hide());\n\n this.clearFilterOptionLink.addEventListener('click', e => {\n e.preventDefault();\n this.clearFilter(this.selectedField);\n });\n\n this.applyFilterButton.addEventListener('click', () => {\n this.applyFilter(this.selectedField);\n });\n\n // 点击空白处整个筛选菜单可消失\n document.addEventListener('click', () => {\n if (this.isVisible) {\n this.hide();\n }\n });\n\n this.filterMenu.addEventListener('click', e => {\n e.stopPropagation();\n });\n }\n\n adjustMenuPosition(\n col?: number | null,\n row?: number | null,\n providedLeft?: number | null,\n providedTop?: number | null\n ) {\n if (typeof providedLeft === 'number' && typeof providedTop === 'number') {\n this.filterMenu.style.display = this.isVisible ? 'block' : 'none';\n this.filterMenu.style.left = `${providedLeft}px`;\n this.filterMenu.style.top = `${providedTop}px`;\n return;\n }\n\n // 明晰的参数 > 记忆的数字\n const effectiveCol = typeof col === 'number' ? col : this.currentCol;\n const effectiveRow = typeof row === 'number' ? row : this.currentRow;\n\n if (typeof effectiveCol !== 'number' || typeof effectiveRow !== 'number') {\n return;\n }\n\n this.currentCol = effectiveCol;\n this.currentRow = effectiveRow;\n\n let left: number = 0;\n let top: number = 0;\n\n const canvasBounds = this.table.canvas.getBoundingClientRect();\n const cell = this.table.getCellRelativeRect(effectiveCol, effectiveRow);\n\n if (cell.right < this.filterMenuWidth) {\n // 无法把筛选菜单完整地显示在左侧,那么显示在右侧\n left = cell.left + canvasBounds.left;\n top = cell.bottom + canvasBounds.top;\n } else {\n // 筛选菜单默认显示在左侧\n left = cell.right + canvasBounds.left - this.filterMenuWidth;\n top = cell.bottom + canvasBounds.top;\n }\n\n this.filterMenu.style.display = this.isVisible ? 'block' : 'none';\n this.filterMenu.style.left = `${left}px`;\n this.filterMenu.style.top = `${top}px`;\n }\n\n show(col: number, row: number, filterModes: FilterMode[]): void {\n this.filterModes = filterModes;\n if (!this.filterModes.includes('byValue')) {\n this.filterTabByValue.style.display = 'none';\n this.onTabSwitch('byCondition');\n } else if (!this.filterModes.includes('byCondition')) {\n this.filterTabByCondition.style.display = 'none';\n this.onTabSwitch('byValue');\n }\n\n this.adjustMenuPosition(col, row);\n this.filterMenu.style.display = 'block';\n\n const field = this.table.internalProps.layoutMap.getHeaderField(col, row) as string | number;\n this.updateSelectedField(field);\n\n // 根据当前筛选配置自动选择正确的筛选标签页\n const currentFilter = this.filterStateManager.getFilterState(field);\n if (currentFilter && currentFilter.type === 'byCondition') {\n this.onTabSwitch('byCondition');\n } else {\n this.onTabSwitch('byValue');\n }\n\n // 更新清除筛选按钮状态\n this.updateClearFilterButtonState(field);\n\n // 确保在事件冒泡完成后才设置 isVisible 为 true\n setTimeout(() => {\n this.isVisible = true;\n }, 0);\n }\n\n hide(): void {\n this.filterMenu.style.display = 'none';\n this.isVisible = false;\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/filter/filter-toolbar.ts"],"names":[],"mappings":";;;AAEA,iDAA6C;AAC7C,yDAAqD;AACrD,qCAAuC;AAMvC,MAAa,aAAa;IAsBxB,YAAY,KAA6B,EAAE,kBAAsC,EAAE,MAAoB;QAjBvG,gBAAW,GAAuB,IAAI,CAAC;QACvC,oBAAe,GAA2B,IAAI,CAAC;QAC/C,cAAS,GAA8B,SAAS,CAAC;QACjD,cAAS,GAAY,KAAK,CAAC;QAC3B,kBAAa,GAA2B,IAAI,CAAC;QAC7C,gBAAW,GAAiB,EAAE,CAAC;QAa7B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;QAC7C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACr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AG,CAAC,CAAC;QAClC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC;QAExC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,SAAS,CAAC,cAAc,CAAC,GAAG,EAAE,GAAG,CAAoB,CAAC;QAC7F,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;QAGhC,MAAM,aAAa,GAAG,IAAI,CAAC,kBAAkB,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QACpE,IAAI,aAAa,IAAI,aAAa,CAAC,IAAI,KAAK,aAAa,EAAE;YACzD,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;SACjC;aAAM;YACL,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;SAC7B;QAGD,IAAI,CAAC,4BAA4B,CAAC,KAAK,CAAC,CAAC;QAGzC,UAAU,CAAC,GAAG,EAAE;YACd,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACxB,CAAC,EAAE,CAAC,CAAC,CAAC;IACR,CAAC;IAED,IAAI;QACF,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;QACvC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IACzB,CAAC;CACF;AA5QD,sCA4QC","file":"filter-toolbar.js","sourcesContent":["import type { ListTable, PivotTable } from '@visactor/vtable';\nimport type { FilterStateManager } from './filter-state-manager';\nimport { ValueFilter } from './value-filter';\nimport { ConditionFilter } from './condition-filter';\nimport { applyStyles } from './styles';\nimport type { FilterMode, FilterStyles } from './types';\n\n/**\n * 筛选工具栏,管理按值和按条件筛选组件\n */\nexport class FilterToolbar {\n table: ListTable | PivotTable;\n filterStateManager: FilterStateManager;\n styles: FilterStyles;\n\n valueFilter: ValueFilter | null = null;\n conditionFilter: ConditionFilter | null = null;\n activeTab: 'byValue' | 'byCondition' = 'byValue';\n isVisible: boolean = false;\n selectedField: string | number | null = null;\n filterModes: FilterMode[] = [];\n\n private filterMenu: HTMLElement;\n private filterMenuWidth: number;\n private currentCol?: number | null;\n private currentRow?: number | null;\n private filterTabByValue: HTMLButtonElement;\n private filterTabByCondition: HTMLButtonElement;\n private clearFilterOptionLink: HTMLAnchorElement;\n private cancelFilterButton: HTMLButtonElement;\n private applyFilterButton: HTMLButtonElement;\n\n constructor(table: ListTable | PivotTable, filterStateManager: FilterStateManager, styles: FilterStyles) {\n this.table = table;\n this.filterStateManager = filterStateManager;\n this.styles = styles;\n this.valueFilter = new ValueFilter(this.table, this.filterStateManager, this.styles);\n this.conditionFilter = new ConditionFilter(this.table, this.filterStateManager, this.styles);\n\n this.filterMenuWidth = 300; // 待优化,可能需要自适应内容的宽度\n\n // 监听筛选状态变化,更新清除筛选按钮状态\n this.filterStateManager.subscribe(state => {\n if (this.isVisible && this.selectedField !== null) {\n this.updateClearFilterButtonState(this.selectedField);\n }\n });\n }\n\n private onTabSwitch(tab: 'byValue' | 'byCondition'): void {\n this.activeTab = tab;\n if (tab === 'byValue') {\n this.valueFilter.show();\n this.conditionFilter.hide();\n } else {\n this.conditionFilter.show();\n this.valueFilter.hide();\n }\n\n const isValueTab = tab === 'byValue';\n applyStyles(this.filterTabByValue, this.styles.tabStyle(isValueTab));\n applyStyles(this.filterTabByCondition, this.styles.tabStyle(!isValueTab));\n }\n\n private updateSelectedField(field: string | number): void {\n this.selectedField = field;\n // 通知筛选组件更新选中字段\n if (this.valueFilter) {\n this.valueFilter.setSelectedField(field);\n }\n if (this.conditionFilter) {\n this.conditionFilter.setSelectedField(field);\n }\n }\n\n private applyFilter(field: string | number): void {\n if (this.activeTab === 'byValue') {\n this.valueFilter.applyFilter(field);\n } else if (this.activeTab === 'byCondition') {\n this.conditionFilter.applyFilter(field);\n }\n this.hide();\n }\n\n private clearFilter(field: string | number): void {\n if (this.valueFilter) {\n this.valueFilter.clearFilter(field);\n }\n if (this.conditionFilter) {\n this.conditionFilter.clearFilter(field);\n }\n this.hide();\n }\n\n /**\n * 更新清除筛选按钮的状态\n */\n private updateClearFilterButtonState(field: string | number): void {\n const currentFilter = this.filterStateManager.getFilterState(field);\n const hasActiveFilter = currentFilter && currentFilter.enable;\n\n this.clearFilterOptionLink.style.display = 'inline';\n this.clearFilterOptionLink.style.opacity = hasActiveFilter ? '1' : '0.5';\n this.clearFilterOptionLink.style.pointerEvents = hasActiveFilter ? 'auto' : 'none';\n this.clearFilterOptionLink.style.cursor = hasActiveFilter ? 'pointer' : 'not-allowed';\n }\n\n render(container: HTMLElement): void {\n // === 主容器 ===\n this.filterMenu = document.createElement('div');\n this.filterMenu.classList.add('vtable-filter-menu');\n applyStyles(this.filterMenu, this.styles.filterMenu);\n this.filterMenu.style.width = `${this.filterMenuWidth}px`;\n\n // === 筛选 Tab ===\n const filterTabsContainer = document.createElement('div');\n applyStyles(filterTabsContainer, this.styles.tabsContainer);\n\n this.filterTabByValue = document.createElement('button');\n this.filterTabByValue.innerText = '按值筛选';\n applyStyles(this.filterTabByValue, this.styles.tabStyle(true));\n\n this.filterTabByCondition = document.createElement('button');\n this.filterTabByCondition.innerText = '按条件筛选';\n applyStyles(this.filterTabByCondition, this.styles.tabStyle(false));\n\n filterTabsContainer.append(this.filterTabByValue, this.filterTabByCondition);\n\n // === 页脚(清除、取消、确定 筛选按钮) ===\n const footerContainer = document.createElement('div');\n applyStyles(footerContainer, this.styles.footerContainer);\n\n this.clearFilterOptionLink = document.createElement('a');\n this.clearFilterOptionLink.href = '#';\n this.clearFilterOptionLink.innerText = '清除筛选';\n applyStyles(this.clearFilterOptionLink, this.styles.clearLink);\n\n const footerButtons = document.createElement('div');\n this.cancelFilterButton = document.createElement('button');\n this.cancelFilterButton.innerText = '取消';\n applyStyles(this.cancelFilterButton, this.styles.footerButton(false));\n\n this.applyFilterButton = document.createElement('button');\n this.applyFilterButton.innerText = '确认';\n applyStyles(this.applyFilterButton, this.styles.footerButton(true));\n\n footerButtons.append(this.cancelFilterButton, this.applyFilterButton);\n footerContainer.append(this.clearFilterOptionLink, footerButtons);\n\n // --- 筛选器头部 Tab ---\n this.filterMenu.append(filterTabsContainer);\n\n // --- 筛选器内容 ---\n this.valueFilter.render(this.filterMenu);\n this.conditionFilter.render(this.filterMenu);\n\n // --- 筛选器页脚 ---\n this.filterMenu.append(footerContainer);\n\n container.appendChild(this.filterMenu); // 将筛选器添加到 DOM 中\n this.attachEventListeners();\n }\n\n attachEventListeners() {\n // 按值筛选/按条件筛选的事件监听\n this.filterTabByValue.addEventListener('click', () => {\n this.onTabSwitch('byValue');\n });\n\n this.filterTabByCondition.addEventListener('click', () => {\n this.onTabSwitch('byCondition');\n });\n\n this.cancelFilterButton.addEventListener('click', () => this.hide());\n\n this.clearFilterOptionLink.addEventListener('click', e => {\n e.preventDefault();\n this.clearFilter(this.selectedField);\n });\n\n this.applyFilterButton.addEventListener('click', () => {\n this.applyFilter(this.selectedField);\n });\n\n // 点击空白处整个筛选菜单可消失\n document.addEventListener('click', () => {\n if (this.isVisible) {\n this.hide();\n }\n });\n\n this.filterMenu.addEventListener('click', e => {\n e.stopPropagation();\n });\n }\n\n adjustMenuPosition(\n col?: number | null,\n row?: number | null,\n providedLeft?: number | null,\n providedTop?: number | null\n ) {\n if (typeof providedLeft === 'number' && typeof providedTop === 'number') {\n this.filterMenu.style.display = this.isVisible ? 'block' : 'none';\n this.filterMenu.style.left = `${providedLeft}px`;\n this.filterMenu.style.top = `${providedTop}px`;\n return;\n }\n\n // 明晰的参数 > 记忆的数字\n const effectiveCol = typeof col === 'number' ? col : this.currentCol;\n const effectiveRow = typeof row === 'number' ? row : this.currentRow;\n\n if (typeof effectiveCol !== 'number' || typeof effectiveRow !== 'number') {\n return;\n }\n\n this.currentCol = effectiveCol;\n this.currentRow = effectiveRow;\n\n let left: number = 0;\n let top: number = 0;\n\n const canvasBounds = this.table.canvas.getBoundingClientRect();\n const cell = this.table.getCellRelativeRect(effectiveCol, effectiveRow);\n\n if (cell.right < this.filterMenuWidth) {\n // 无法把筛选菜单完整地显示在左侧,那么显示在右侧\n left = cell.left + canvasBounds.left;\n top = cell.bottom + canvasBounds.top;\n } else {\n // 筛选菜单默认显示在左侧\n left = cell.right + canvasBounds.left - this.filterMenuWidth;\n top = cell.bottom + canvasBounds.top;\n }\n\n this.filterMenu.style.display = this.isVisible ? 'block' : 'none';\n this.filterMenu.style.left = `${left}px`;\n this.filterMenu.style.top = `${top}px`;\n }\n\n show(col: number, row: number, filterModes: FilterMode[]): void {\n this.filterModes = filterModes;\n if (!this.filterModes.includes('byValue')) {\n this.filterTabByValue.style.display = 'none';\n this.onTabSwitch('byCondition');\n } else if (!this.filterModes.includes('byCondition')) {\n this.filterTabByCondition.style.display = 'none';\n this.onTabSwitch('byValue');\n }\n\n this.adjustMenuPosition(col, row);\n this.filterMenu.style.display = 'block';\n\n const field = this.table.internalProps.layoutMap.getHeaderField(col, row) as string | number;\n this.updateSelectedField(field);\n\n // 根据当前筛选配置自动选择正确的筛选标签页\n const currentFilter = this.filterStateManager.getFilterState(field);\n if (currentFilter && currentFilter.type === 'byCondition') {\n this.onTabSwitch('byCondition');\n } else {\n this.onTabSwitch('byValue');\n }\n\n // 更新清除筛选按钮状态\n this.updateClearFilterButtonState(field);\n\n // 确保在事件冒泡完成后才设置 isVisible 为 true\n setTimeout(() => {\n this.isVisible = true;\n }, 0);\n }\n\n hide(): void {\n this.filterMenu.style.display = 'none';\n this.isVisible = false;\n }\n}\n"]}
@@ -11223,6 +11223,7 @@ ${recordsStr}
11223
11223
  }
11224
11224
  render(container) {
11225
11225
  this.filterMenu = document.createElement('div');
11226
+ this.filterMenu.classList.add('vtable-filter-menu');
11226
11227
  applyStyles(this.filterMenu, this.styles.filterMenu);
11227
11228
  this.filterMenu.style.width = `${this.filterMenuWidth}px`;
11228
11229
  const filterTabsContainer = document.createElement('div');