@visactor/vtable-plugins 1.22.4-alpha.7 → 1.22.4-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.
- package/cjs/filter/filter-toolbar.js +1 -1
- package/cjs/filter/filter-toolbar.js.map +1 -1
- package/cjs/filter/value-filter.d.ts +2 -0
- package/cjs/filter/value-filter.js +22 -11
- package/cjs/filter/value-filter.js.map +1 -1
- package/dist/vtable-plugins.js +37 -11
- package/dist/vtable-plugins.min.js +1 -1
- package/es/filter/filter-toolbar.js +1 -1
- package/es/filter/filter-toolbar.js.map +1 -1
- package/es/filter/value-filter.d.ts +2 -0
- package/es/filter/value-filter.js +23 -12
- package/es/filter/value-filter.js.map +1 -1
- package/package.json +8 -8
|
@@ -28,7 +28,7 @@ class FilterToolbar {
|
|
|
28
28
|
this.conditionFilter && this.conditionFilter.setSelectedField(field);
|
|
29
29
|
}
|
|
30
30
|
applyFilter(field) {
|
|
31
|
-
"byValue" === this.activeTab ? this.valueFilter.applyFilter(field) : "byCondition" === this.activeTab && this.conditionFilter.applyFilter(field),
|
|
31
|
+
"byValue" === this.activeTab ? (this.valueFilter.updateCheckboxState(field), this.valueFilter.applyFilter(field)) : "byCondition" === this.activeTab && this.conditionFilter.applyFilter(field),
|
|
32
32
|
this.hide(this.currentCol, this.currentRow);
|
|
33
33
|
}
|
|
34
34
|
clearFilter(field) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/filter/filter-toolbar.ts"],"names":[],"mappings":";;;AAAA,6CAAqF;AAErF,iDAA6C;AAC7C,yDAAqD;AACrD,qCAAuC;AAMvC,MAAa,aAAa;IAsBxB,YACE,KAA6B,EAC7B,kBAAsC,EACtC,MAAoB,EACpB,mBAAmD;QArBrD,gBAAW,GAAuB,IAAI,CAAC;QACvC,oBAAe,GAA2B,IAAI,CAAC;QAC/C,cAAS,GAA8B,SAAS,CAAC;QACjD,cAAS,GAAY,KAAK,CAAC;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C;QACL,CAAC,EAAE,CAAC,CAAC,CAAC;IACR,CAAC;IAED,IAAI,CAAC,UAAyB,EAAE,UAAyB;QACvD,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;QACvC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,yBAAgB,CAAC,gBAAgB,EAAE;YAC1D,GAAG,EAAE,UAAU;YACf,GAAG,EAAE,UAAU;SAChB,CAAC,CAAC;IACL,CAAC;CACF;AA1RD,sCA0RC","file":"filter-toolbar.js","sourcesContent":["import { TABLE_EVENT_TYPE, type ListTable, type 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, FilterOperatorCategoryOption, 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(\n table: ListTable | PivotTable,\n filterStateManager: FilterStateManager,\n styles: FilterStyles,\n conditionCategories: FilterOperatorCategoryOption[]\n ) {\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, conditionCategories);\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(this.currentCol!, this.currentRow!);\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(this.currentCol!, this.currentRow!);\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(this.currentCol!, this.currentRow!));\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(this.currentCol!, this.currentRow!);\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.valueFilter.clearSearchInputValue();\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 this.table.fireListeners(TABLE_EVENT_TYPE.FILTER_MENU_SHOW, {\n col: col,\n row: row\n });\n }, 0);\n }\n\n hide(currentCol: number | null, currentRow: number | null): void {\n this.filterMenu.style.display = 'none';\n this.isVisible = false;\n this.table.fireListeners(TABLE_EVENT_TYPE.FILTER_MENU_HIDE, {\n col: currentCol,\n row: currentRow\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/filter/filter-toolbar.ts"],"names":[],"mappings":";;;AAAA,6CAAqF;AAErF,iDAA6C;AAC7C,yDAAqD;AACrD,qCAAuC;AAMvC,MAAa,aAAa;IAsBxB,YACE,KAA6B,EAC7B,kBAAsC,EACtC,MAAoB,EACpB,mBAAmD;QArBrD,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;QAkB7B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAA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C,UAAyB,EAAE,UAAyB;QACvD,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;QACvC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,yBAAgB,CAAC,gBAAgB,EAAE;YAC1D,GAAG,EAAE,UAAU;YACf,GAAG,EAAE,UAAU;SAChB,CAAC,CAAC;IACL,CAAC;CACF;AA5RD,sCA4RC","file":"filter-toolbar.js","sourcesContent":["import { TABLE_EVENT_TYPE, type ListTable, type 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, FilterOperatorCategoryOption, 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(\n table: ListTable | PivotTable,\n filterStateManager: FilterStateManager,\n styles: FilterStyles,\n conditionCategories: FilterOperatorCategoryOption[]\n ) {\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, conditionCategories);\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 // 更新筛选组件的全选选中状态\n this.valueFilter.updateCheckboxState(field);\n this.valueFilter.applyFilter(field);\n } else if (this.activeTab === 'byCondition') {\n this.conditionFilter.applyFilter(field);\n }\n this.hide(this.currentCol!, this.currentRow!);\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(this.currentCol!, this.currentRow!);\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(this.currentCol!, this.currentRow!));\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(this.currentCol!, this.currentRow!);\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.valueFilter.clearSearchInputValue();\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 this.table.fireListeners(TABLE_EVENT_TYPE.FILTER_MENU_SHOW, {\n col: col,\n row: row\n });\n }, 0);\n }\n\n hide(currentCol: number | null, currentRow: number | null): void {\n this.filterMenu.style.display = 'none';\n this.isVisible = false;\n this.table.fireListeners(TABLE_EVENT_TYPE.FILTER_MENU_HIDE, {\n col: currentCol,\n row: currentRow\n });\n }\n}\n"]}
|
|
@@ -30,6 +30,8 @@ export declare class ValueFilter {
|
|
|
30
30
|
render(container: HTMLElement): void;
|
|
31
31
|
private renderFilterOptions;
|
|
32
32
|
bindEventForFilterByValue(): void;
|
|
33
|
+
updateCheckboxUI(field: string | number): void;
|
|
34
|
+
updateCheckboxState(field: string | number): void;
|
|
33
35
|
show(): void;
|
|
34
36
|
hide(): void;
|
|
35
37
|
clearSearchInputValue(): void;
|
|
@@ -187,11 +187,8 @@ class ValueFilter {
|
|
|
187
187
|
if (!filter) return;
|
|
188
188
|
const selectedRawValues = filter.values || [], displayToRawMap = this.displayToRawValueMap.get(filter.field), optionDomList = this.valueFilterOptionList.get(filter.field);
|
|
189
189
|
null == optionDomList || optionDomList.forEach((optionDom => {
|
|
190
|
-
var _a, _b;
|
|
191
190
|
const displayValue = optionDom.originalValue, rawValue = displayToRawMap ? displayToRawMap.get(displayValue) : displayValue;
|
|
192
191
|
optionDom.checkbox.checked = selectedRawValues.some((v => v === rawValue));
|
|
193
|
-
const count = (null === (_b = null === (_a = this.uniqueKeys.get(filter.field)) || void 0 === _a ? void 0 : _a.find((key => String(key.value) === optionDom.id))) || void 0 === _b ? void 0 : _b.count) || 0;
|
|
194
|
-
optionDom.checkbox.disabled = 0 === count;
|
|
195
192
|
}));
|
|
196
193
|
}
|
|
197
194
|
syncSelectAllWithFilterState(filter) {
|
|
@@ -260,10 +257,10 @@ class ValueFilter {
|
|
|
260
257
|
(0, styles_1.applyStyles)(label, this.styles.optionLabel);
|
|
261
258
|
const checkbox = document.createElement("input");
|
|
262
259
|
checkbox.type = "checkbox", checkbox.value = String(value), checkbox.checked = selectedRawValueSet.has(rawValue),
|
|
263
|
-
|
|
260
|
+
(0, styles_1.applyStyles)(checkbox, this.styles.checkbox);
|
|
264
261
|
const countSpan = document.createElement("span");
|
|
265
262
|
countSpan.textContent = String(count), (0, styles_1.applyStyles)(countSpan, this.styles.countSpan),
|
|
266
|
-
label.append(checkbox, ` ${
|
|
263
|
+
label.append(checkbox, ` ${rawValue}`), itemDiv.append(label, countSpan), this.filterItemsContainer.appendChild(itemDiv);
|
|
267
264
|
const itemDom = {
|
|
268
265
|
id: String(value),
|
|
269
266
|
originalValue: value,
|
|
@@ -282,21 +279,35 @@ class ValueFilter {
|
|
|
282
279
|
this.onSearch(this.selectedField, value);
|
|
283
280
|
}
|
|
284
281
|
})), this.filterByValuePanel.addEventListener("change", (event => {
|
|
285
|
-
var _a, _b;
|
|
286
282
|
const target = event.target;
|
|
287
|
-
|
|
288
|
-
const checkbox = target, checked = checkbox.checked, value = null === (_b = null === (_a = this.valueFilterOptionList.get(this.selectedField)) || void 0 === _a ? void 0 : _a.find((item => item.id === checkbox.value))) || void 0 === _b ? void 0 : _b.originalValue;
|
|
289
|
-
this.onValueSelect(this.selectedField, value, checked);
|
|
290
|
-
}
|
|
283
|
+
target instanceof HTMLInputElement && "checkbox" === target.type && (target === this.selectAllCheckbox ? this.valueFilterOptionList.get(this.selectedField).forEach((item => item.checkbox.checked = target.checked)) : this.updateCheckboxUI(this.selectedField));
|
|
291
284
|
}));
|
|
292
285
|
}
|
|
286
|
+
updateCheckboxUI(field) {
|
|
287
|
+
var _a, _b;
|
|
288
|
+
const checkedItem = null === (_a = this.valueFilterOptionList.get(field)) || void 0 === _a ? void 0 : _a.filter((item => item.checkbox.checked)), uncheckedItem = null === (_b = this.valueFilterOptionList.get(field)) || void 0 === _b ? void 0 : _b.filter((item => !item.checkbox.checked));
|
|
289
|
+
(0, vutils_1.isValid)(checkedItem) && (0, vutils_1.isValid)(uncheckedItem) && (0 !== checkedItem.length && 0 !== uncheckedItem.length ? this.selectAllCheckbox.indeterminate = !0 : (this.selectAllCheckbox.indeterminate = !1,
|
|
290
|
+
this.selectAllCheckbox.checked = 0 === uncheckedItem.length));
|
|
291
|
+
}
|
|
292
|
+
updateCheckboxState(field) {
|
|
293
|
+
var _a;
|
|
294
|
+
const originalValues = null === (_a = this.valueFilterOptionList.get(field)) || void 0 === _a ? void 0 : _a.filter((item => item.checkbox.checked)).map((item => item.originalValue)), displayToRawMap = this.displayToRawValueMap.get(field), rawValues = originalValues.map((displayValue => displayToRawMap ? displayToRawMap.get(displayValue) : displayValue));
|
|
295
|
+
this.filterStateManager.dispatch({
|
|
296
|
+
type: types_1.FilterActionType.ADD_FILTER,
|
|
297
|
+
payload: {
|
|
298
|
+
field: field,
|
|
299
|
+
type: "byValue",
|
|
300
|
+
values: rawValues
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
}
|
|
293
304
|
show() {
|
|
294
305
|
this.collectUniqueColumnValues(this.selectedField), this.updateCandidateCounts(this.selectedField),
|
|
295
306
|
this.initFilterStateFromTableData(this.selectedField);
|
|
296
307
|
const uniqueValues = this.uniqueKeys.get(this.selectedField), displayToRawMap = this.displayToRawValueMap.get(this.selectedField);
|
|
297
308
|
uniqueValues && displayToRawMap && this.filterStateManager.initializeFilterMenuState(this.selectedField, uniqueValues, displayToRawMap),
|
|
298
309
|
this.filterByValueSearchInput && (this.filterByValueSearchInput.value = ""), this.renderFilterOptions(this.selectedField),
|
|
299
|
-
this.filterByValuePanel.style.display = "block";
|
|
310
|
+
this.updateCheckboxUI(this.selectedField), this.filterByValuePanel.style.display = "block";
|
|
300
311
|
}
|
|
301
312
|
hide() {
|
|
302
313
|
this.filterByValuePanel.style.display = "none";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/filter/value-filter.ts"],"names":[],"mappings":";;;AACA,6CAA8C;AAE9C,mCAA2C;AAE3C,qCAAuC;AAEvC,MAAa,WAAW;IActB,YAAY,KAA6B,EAAE,kBAAsC,EAAE,MAAoB;QAV/F,eAAU,GAAG,IAAI,GAAG,EAAwE,CAAC;QAC7F,yBAAoB,GAAG,IAAI,GAAG,EAAkC,CAAC;QAGjE,0BAAqB,GAAiD,IAAI,GAAG,EAAE,CAAC;QAOtF,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;QAC7C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC,KAAkB,EAAE,EAAE;YACvD,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAC1D,IAAI,WAAW,IAAI,WAAW,CAAC,IAAI,KAAK,SAAS,EAAE;gBACjD,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;aAC5B;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,QAAQ,CAAC,WAAyB;QACxC,IAAI,CAAC,6BAA6B,CAAC,WAAW,CAAC,CAAC;QAChD,IAAI,CAAC,4BAA4B,CAAC,WAAW,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AAC,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC;IAClD,CAAC;IAED,IAAI;QACF,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;IACjD,CAAC;IAED,qBAAqB;QACnB,IAAI,CAAC,wBAAwB,CAAC,KAAK,GAAG,EAAE,CAAC;IAC3C,CAAC;CACF;AAlnBD,kCAknBC","file":"value-filter.js","sourcesContent":["import type { ListTable, PivotTable } from '@visactor/vtable';\nimport { arrayEqual } from '@visactor/vutils';\nimport type { FilterConfig, ValueFilterOptionDom, FilterState, FilterStyles } from './types';\nimport { FilterActionType } from './types';\nimport type { FilterStateManager } from './filter-state-manager';\nimport { applyStyles } from './styles';\n\nexport class ValueFilter {\n private table: ListTable | PivotTable;\n private filterStateManager: FilterStateManager;\n private styles: FilterStyles;\n private uniqueKeys = new Map<string | number, Array<{ value: any; count: number; rawValue: any }>>();\n private displayToRawValueMap = new Map<string | number, Map<any, any>>();\n private selectedField: string | number;\n\n private valueFilterOptionList: Map<string | number, ValueFilterOptionDom[]> = new Map();\n private filterByValuePanel: HTMLElement;\n private filterByValueSearchInput: HTMLInputElement;\n private selectAllCheckbox: HTMLInputElement;\n private filterItemsContainer: HTMLElement;\n\n constructor(table: ListTable | PivotTable, filterStateManager: FilterStateManager, styles: FilterStyles) {\n this.table = table;\n this.filterStateManager = filterStateManager;\n this.styles = styles;\n\n this.filterStateManager.subscribe((state: FilterState) => {\n const filterState = state.filters.get(this.selectedField);\n if (filterState && filterState.type === 'byValue') {\n this.updateUI(filterState);\n }\n });\n }\n\n private updateUI(filterState: FilterConfig): void {\n this.syncCheckboxesWithFilterState(filterState);\n this.syncSelectAllWithFilterState(filterState);\n }\n\n setSelectedField(fieldId: string | number): void {\n this.selectedField = fieldId;\n this.collectUniqueColumnValues(fieldId);\n }\n\n collectUniqueColumnValues(fieldId: string | number): void {\n // 如果已经收集过,直接返回\n if (this.uniqueKeys.has(fieldId)) {\n return;\n }\n\n const displayToRawMap = new Map<any, any>(); // displayValue -> rawValue\n\n // 找到第一个匹配字段的列位置,用于获取格式化数据\n let targetCol = -1;\n for (let col = 0; col < this.table.colCount; col++) {\n for (let row = this.table.columnHeaderLevelCount; row < this.table.rowCount; row++) {\n if (!this.table.internalProps.layoutMap.isHeader(col, row)) {\n const bodyInfo = this.table.internalProps.layoutMap.getBody(col, row);\n if (bodyInfo && bodyInfo.field === fieldId) {\n targetCol = col;\n break;\n }\n }\n }\n if (targetCol !== -1) {\n break;\n }\n }\n\n // 从原始数据收集候选值(不计数,只收集唯一值)\n const records = this.table.internalProps.records;\n const recordsLength = records.length;\n\n for (let i = 0; i < recordsLength; i++) {\n let rawValue;\n let displayValue;\n if (targetCol !== -1) {\n const row = this.table.columnHeaderLevelCount + i;\n const currentRecord = records[i];\n // 获取原始数据\n rawValue = currentRecord[fieldId];\n // 获取格式化显示数据\n const bodyInfo = this.table.internalProps.layoutMap.getBody(targetCol, row);\n if (\n bodyInfo &&\n 'fieldFormat' in bodyInfo &&\n bodyInfo.fieldFormat &&\n typeof bodyInfo.fieldFormat === 'function'\n ) {\n displayValue = bodyInfo.fieldFormat({ [fieldId]: rawValue });\n } else {\n displayValue = rawValue;\n }\n } else {\n rawValue = records[i][fieldId];\n displayValue = rawValue;\n }\n\n if (rawValue !== undefined && rawValue !== null && !displayToRawMap.has(displayValue)) {\n displayToRawMap.set(displayValue, rawValue);\n }\n }\n\n // 保存显示值到原始值的映射关系\n this.displayToRawValueMap.set(fieldId, displayToRawMap);\n\n // 转换为所需格式,包含显示值、计数和原始值(count = 0 占位,后续会更新)\n const uniqueValues = Array.from(displayToRawMap.entries()).map(([displayValue, rawValue]) => ({\n value: displayValue, // UI显示的格式化值\n count: 0, // 计数占位,后续会根据筛选状态动态计算\n rawValue: rawValue // 对应的原始值\n }));\n\n this.uniqueKeys.set(fieldId, uniqueValues);\n }\n\n /**\n * 更新候选值列表的计数(基于当前筛选状态选择数据源)\n * - 未筛选列:使用当前表格数据(dataSource)计算计数\n * - 已筛选列:使用原始数据(records)计算计数\n */\n private updateCandidateCounts(fieldId: string | number): void {\n const uniqueValues = this.uniqueKeys.get(fieldId);\n if (!uniqueValues) {\n return;\n }\n\n // 判断当前列是否已启用筛选\n const filter = this.filterStateManager.getFilterState(fieldId);\n const isFiltered = filter?.enable;\n\n // 根据筛选状态选择数据源\n const dataSource = isFiltered\n ? this.table.internalProps.records // 已筛选:使用原始数据\n : this.table.internalProps.dataSource; // 未筛选:使用当前表格数据\n\n // 找到第一个匹配字段的列位置,用于获取格式化数据\n let targetCol = -1;\n for (let col = 0; col < this.table.colCount; col++) {\n for (let row = this.table.columnHeaderLevelCount; row < this.table.rowCount; row++) {\n if (!this.table.internalProps.layoutMap.isHeader(col, row)) {\n const bodyInfo = this.table.internalProps.layoutMap.getBody(col, row);\n if (bodyInfo && bodyInfo.field === fieldId) {\n targetCol = col;\n break;\n }\n }\n }\n if (targetCol !== -1) {\n break;\n }\n }\n\n // 计算每个候选值的计数\n const dataLength = dataSource.length;\n const countMap = new Map<any, number>();\n\n for (let i = 0; i < dataLength; i++) {\n let displayValue;\n if (targetCol !== -1) {\n const row = this.table.columnHeaderLevelCount + i;\n if (row < this.table.rowCount) {\n displayValue = this.table.getCellValue(targetCol, row);\n }\n } else {\n displayValue = this.table.getFieldData(\n String(fieldId),\n targetCol !== -1 ? targetCol : 0,\n this.table.columnHeaderLevelCount + i\n );\n }\n\n if (displayValue !== undefined && displayValue !== null) {\n countMap.set(displayValue, (countMap.get(displayValue) || 0) + 1);\n }\n }\n\n // 更新计数\n uniqueValues.forEach(item => {\n item.count = countMap.get(item.value) || 0;\n });\n }\n\n private onValueSelect(fieldId: string | number, displayValue: any, selected: boolean): void {\n // 获取显示值对应的原始值\n const displayToRawMap = this.displayToRawValueMap.get(fieldId);\n const rawValue = displayToRawMap ? displayToRawMap.get(displayValue) : displayValue;\n\n // 更新筛选状态\n const filter = this.filterStateManager.getFilterState(fieldId);\n let updatedValues: any[];\n if (!filter) {\n updatedValues = selected ? [rawValue] : [];\n this.filterStateManager.dispatch({\n type: FilterActionType.ADD_FILTER,\n payload: {\n field: fieldId,\n type: 'byValue',\n values: updatedValues\n }\n });\n } else {\n updatedValues = selected\n ? [...(filter.values || []), rawValue]\n : (filter.values || []).filter(v => v !== rawValue);\n this.filterStateManager.dispatch({\n type: FilterActionType.UPDATE_FILTER,\n payload: {\n field: fieldId,\n values: updatedValues\n }\n });\n }\n }\n\n /**\n * 检查值在当前搜索关键词下是否可见\n */\n private isValueVisible(displayValue: any, keyword: string): boolean {\n if (!keyword) {\n return true;\n }\n\n const filterKeywords = keyword\n .toUpperCase()\n .split(' ')\n .filter(s => s);\n\n const txtValue = String(displayValue).toUpperCase();\n return filterKeywords.some(keyword => txtValue.includes(keyword));\n }\n\n private toggleSelectAll(fieldId: string | number, selected: boolean): void {\n // 获取当前可见的值进行全选/取消全选\n const currentKeyword = this.filterStateManager.getCurrentSearchKeyword(fieldId);\n const stableCandidates = this.filterStateManager.getStableCandidateValues(fieldId);\n const displayToRawMap = this.displayToRawValueMap.get(fieldId);\n\n // 找出当前可见的所有值\n const visibleRawValues = stableCandidates\n .filter(candidate => this.isValueVisible(candidate.value, currentKeyword))\n .map(candidate => (displayToRawMap ? displayToRawMap.get(candidate.value) : candidate.value));\n\n const filter = this.filterStateManager.getFilterState(fieldId);\n const currentValues = new Set(filter?.values || []);\n\n let updatedValues: any[];\n if (selected) {\n // 全选:将可见的值添加到当前选中值中\n updatedValues = Array.from(new Set([...currentValues, ...visibleRawValues]));\n } else {\n // 取消全选:从当前选中值中移除可见的值\n updatedValues = Array.from(currentValues).filter(value => !visibleRawValues.includes(value));\n }\n\n if (!filter) {\n this.filterStateManager.dispatch({\n type: FilterActionType.ADD_FILTER,\n payload: {\n field: fieldId,\n type: 'byValue',\n values: updatedValues,\n enable: true\n }\n });\n } else {\n this.filterStateManager.dispatch({\n type: FilterActionType.UPDATE_FILTER,\n payload: {\n field: fieldId,\n values: updatedValues\n }\n });\n }\n }\n\n private onSearch(fieldId: string | number, value: string): void {\n // 更新 FilterStateManager 中的搜索关键词\n this.filterStateManager.updateSearchKeyword(fieldId, value);\n\n // 更新UI显示\n const items = this.valueFilterOptionList.get(fieldId);\n const filterKeywords = value\n .toUpperCase()\n .split(' ')\n .filter(s => s);\n\n for (const item of items) {\n const txtValue = item.id.toUpperCase() || '';\n const match = filterKeywords.some(keyword => txtValue.includes(keyword));\n const isVisible = filterKeywords.length === 0 || match;\n\n item.itemContainer.style.display = isVisible ? 'flex' : 'none';\n }\n }\n\n /**\n * 根据当前表格中的数据,初始化或更新 filter 的被选状态\n * 如果筛选已启用(enable=true),收集当前显示的数据作为选中项\n * 如果筛选未启用,初始化为所有值都选中\n */\n private initFilterStateFromTableData(fieldId: string | number): void {\n const filter = this.filterStateManager.getFilterState(fieldId);\n const isEnable = filter?.enable;\n\n // 如果筛选已启用,使用当前显示的数据作为选中值\n if (isEnable) {\n const selectedRawValues = new Set();\n const displayToRawMap = this.displayToRawValueMap.get(fieldId);\n\n // 找到第一个匹配字段的列位置,用于获取格式化数据\n let targetCol = -1;\n for (let col = 0; col < this.table.colCount; col++) {\n for (let row = this.table.columnHeaderLevelCount; row < this.table.rowCount; row++) {\n if (!this.table.internalProps.layoutMap.isHeader(col, row)) {\n const bodyInfo = this.table.internalProps.layoutMap.getBody(col, row);\n if (bodyInfo && bodyInfo.field === fieldId) {\n targetCol = col;\n break;\n }\n }\n }\n if (targetCol !== -1) {\n break;\n }\n }\n\n // 收集当前显示的数据对应的原始值\n const dataSource = this.table.internalProps.dataSource;\n const currentLength = dataSource.length;\n\n for (let i = 0; i < currentLength; i++) {\n let displayValue;\n let rawValue;\n if (targetCol !== -1) {\n const row = this.table.columnHeaderLevelCount + i;\n if (row < this.table.rowCount) {\n // 获取格式化显示值\n displayValue = this.table.getCellValue(targetCol, row);\n // 通过映射获取对应的原始值\n rawValue = displayToRawMap ? displayToRawMap.get(displayValue) : displayValue;\n }\n } else {\n displayValue = this.table.getFieldData(\n String(fieldId),\n targetCol !== -1 ? targetCol : 0,\n this.table.columnHeaderLevelCount + i\n );\n rawValue = displayToRawMap ? displayToRawMap.get(displayValue) : displayValue;\n }\n\n if (rawValue !== undefined && rawValue !== null) {\n selectedRawValues.add(rawValue);\n }\n }\n\n const hasChanged = !arrayEqual(filter.values, Array.from(selectedRawValues));\n if (hasChanged) {\n this.filterStateManager.dispatch({\n type: FilterActionType.UPDATE_FILTER,\n payload: {\n field: fieldId,\n values: Array.from(selectedRawValues)\n }\n });\n }\n } else {\n // 如果筛选未启用,初始化为计数>0的值都选中(但不启用筛选)\n if (!filter) {\n const availableRawValues =\n this.uniqueKeys\n .get(fieldId)\n ?.filter(item => item.count > 0) // 只选中计数>0的值\n ?.map(item => item.rawValue)\n .filter(v => v !== undefined && v !== null) || [];\n\n this.filterStateManager.dispatch({\n type: FilterActionType.ADD_FILTER,\n payload: {\n field: fieldId,\n type: 'byValue',\n values: availableRawValues,\n enable: false // 初始状态为未启用\n }\n });\n }\n }\n }\n\n /**\n * 根据 filter 的数据状态,更新 UI\n */\n private syncCheckboxesWithFilterState(filter: FilterConfig): void {\n if (!filter) {\n return;\n }\n const selectedRawValues = filter.values || [];\n const displayToRawMap = this.displayToRawValueMap.get(filter.field);\n const optionDomList = this.valueFilterOptionList.get(filter.field);\n\n optionDomList?.forEach(optionDom => {\n // optionDom.id 是显示值,需要转换为原始值进行比较\n const displayValue = optionDom.originalValue;\n const rawValue = displayToRawMap ? displayToRawMap.get(displayValue) : displayValue;\n\n // 检查原始值是否在选中的原始值列表中\n optionDom.checkbox.checked = selectedRawValues.some(v => v === rawValue);\n\n // 同步禁用状态:计数为0时禁用复选框\n const count = this.uniqueKeys.get(filter.field)?.find(key => String(key.value) === optionDom.id)?.count || 0;\n optionDom.checkbox.disabled = count === 0;\n });\n }\n\n /**\n * 根据 filter 的数据状态,更新 UI\n */\n private syncSelectAllWithFilterState(filter: FilterConfig): void {\n if (!filter || !filter.values) {\n this.selectAllCheckbox.checked = false;\n this.selectAllCheckbox.indeterminate = false;\n return;\n }\n\n const uniqueValuesCount = this.uniqueKeys.get(filter.field)?.length || 0;\n if (uniqueValuesCount === 0) {\n this.selectAllCheckbox.checked = false;\n this.selectAllCheckbox.indeterminate = false;\n } else if (filter.values.length === 0) {\n // 没有选中任何值\n this.selectAllCheckbox.checked = false;\n this.selectAllCheckbox.indeterminate = false;\n } else if (filter.values.length === uniqueValuesCount) {\n // 所有值都被选中\n this.selectAllCheckbox.checked = true;\n this.selectAllCheckbox.indeterminate = false;\n } else {\n // 部分值被选中\n this.selectAllCheckbox.checked = false;\n this.selectAllCheckbox.indeterminate = true;\n }\n }\n\n applyFilter(fieldId: string | number = this.selectedField): void {\n // 获取当前搜索过滤后可见的选中值\n const visibleSelectedKeys = Array.from(this.filterStateManager.getVisibleSelectedValues(fieldId));\n\n if (visibleSelectedKeys.length > 0 && visibleSelectedKeys.length < this.uniqueKeys.get(fieldId)?.length) {\n this.filterStateManager.dispatch({\n type: FilterActionType.APPLY_FILTERS,\n payload: {\n field: fieldId,\n type: 'byValue',\n values: visibleSelectedKeys,\n enable: true\n }\n });\n } else {\n this.filterStateManager.dispatch({\n type: FilterActionType.REMOVE_FILTER,\n payload: {\n field: fieldId\n }\n });\n }\n }\n\n clearFilter(fieldId: string | number): void {\n this.filterStateManager.dispatch({\n type: FilterActionType.REMOVE_FILTER,\n payload: {\n field: fieldId\n }\n });\n\n this.hide();\n }\n\n render(container: HTMLElement): void {\n // === 按值筛选的菜单内容 ===\n this.filterByValuePanel = document.createElement('div');\n applyStyles(this.filterByValuePanel, this.styles.filterPanel);\n\n // -- 搜索栏 ---\n const searchContainer = document.createElement('div');\n applyStyles(searchContainer, this.styles.searchContainer);\n\n this.filterByValueSearchInput = document.createElement('input');\n this.filterByValueSearchInput.type = 'text';\n this.filterByValueSearchInput.placeholder = '可使用空格分隔多个关键词';\n applyStyles(this.filterByValueSearchInput, this.styles.searchInput);\n\n searchContainer.appendChild(this.filterByValueSearchInput);\n\n // --- 筛选选项 ---\n const optionsContainer = document.createElement('div');\n applyStyles(optionsContainer, this.styles.optionsContainer);\n\n const selectAllItemDiv = document.createElement('div');\n applyStyles(selectAllItemDiv, this.styles.optionItem);\n\n const selectAllLabel = document.createElement('label');\n applyStyles(selectAllLabel, this.styles.optionLabel);\n\n this.selectAllCheckbox = document.createElement('input');\n this.selectAllCheckbox.type = 'checkbox';\n this.selectAllCheckbox.checked = true; // 默认全选\n applyStyles(this.selectAllCheckbox, this.styles.checkbox);\n\n selectAllLabel.append(this.selectAllCheckbox, ' 全选');\n selectAllItemDiv.appendChild(selectAllLabel);\n\n this.filterItemsContainer = document.createElement('div'); // 筛选条目的容器,后续应动态 appendChild\n\n optionsContainer.append(selectAllItemDiv, this.filterItemsContainer);\n this.filterByValuePanel.append(searchContainer, optionsContainer);\n\n container.appendChild(this.filterByValuePanel);\n\n this.bindEventForFilterByValue();\n }\n\n private renderFilterOptions(field: string | number): void {\n this.filterItemsContainer.innerHTML = '';\n this.valueFilterOptionList.delete(field);\n this.valueFilterOptionList.set(field, []);\n\n const selectedRawValues = this.filterStateManager.getFilterState(field)?.values || [];\n // 为了优化复杂度,将原始值转换为Set进行快速查找\n const selectedRawValueSet = new Set(selectedRawValues);\n\n const itemDomList: ValueFilterOptionDom[] = [];\n this.uniqueKeys.get(field)?.forEach(({ value, count, rawValue }) => {\n const itemDiv = document.createElement('div');\n applyStyles(itemDiv, this.styles.optionItem);\n itemDiv.style.display = 'flex';\n\n const label = document.createElement('label');\n applyStyles(label, this.styles.optionLabel);\n\n const checkbox = document.createElement('input');\n checkbox.type = 'checkbox';\n checkbox.value = String(value); // 显示值作为checkbox的value\n // 使用原始值进行选中状态判断,优化为O(1)复杂度\n checkbox.checked = selectedRawValueSet.has(rawValue);\n // 计数为0时禁用复选框(不可选中)\n checkbox.disabled = count === 0;\n applyStyles(checkbox, this.styles.checkbox);\n\n const countSpan = document.createElement('span');\n countSpan.textContent = String(count);\n applyStyles(countSpan, this.styles.countSpan);\n\n label.append(checkbox, ` ${value}`); // UI显示格式化值\n itemDiv.append(label, countSpan);\n this.filterItemsContainer.appendChild(itemDiv);\n\n const itemDom: ValueFilterOptionDom = {\n id: String(value), // 显示值作为id,用于UI交互\n originalValue: value,\n itemContainer: itemDiv,\n checkbox: checkbox,\n countSpan: countSpan\n };\n\n itemDomList.push(itemDom);\n });\n\n this.valueFilterOptionList.set(field, itemDomList);\n }\n\n bindEventForFilterByValue(): void {\n // 事件委托:搜索框的 keyup 事件\n this.filterByValuePanel.addEventListener('keyup', (event: KeyboardEvent) => {\n const target = event.target;\n if (target instanceof HTMLInputElement && target.type === 'text') {\n const value = target.value;\n this.onSearch(this.selectedField, value);\n }\n });\n\n // 事件委托:复选框的 change 事件\n this.filterByValuePanel.addEventListener('change', (event: Event) => {\n const target = event.target;\n if (target instanceof HTMLInputElement && target.type === 'checkbox') {\n if (target === this.selectAllCheckbox) {\n this.toggleSelectAll(this.selectedField, this.selectAllCheckbox.checked);\n } else {\n const checkbox = target;\n const checked = checkbox.checked;\n const value = this.valueFilterOptionList\n .get(this.selectedField)\n ?.find(item => item.id === checkbox.value)?.originalValue;\n this.onValueSelect(this.selectedField, value, checked);\n }\n }\n });\n }\n\n show(): void {\n // 1. 收集候选值(来自原始数据)\n this.collectUniqueColumnValues(this.selectedField);\n\n // 2. 更新计数(根据筛选状态选择数据源)\n this.updateCandidateCounts(this.selectedField);\n\n // 3. 初始化筛选状态(必须在 renderFilterOptions 之前执行)\n this.initFilterStateFromTableData(this.selectedField);\n\n // 4. 初始化筛选菜单状态,确保候选值列表稳定,并清空搜索关键词\n const uniqueValues = this.uniqueKeys.get(this.selectedField);\n const displayToRawMap = this.displayToRawValueMap.get(this.selectedField);\n if (uniqueValues && displayToRawMap) {\n this.filterStateManager.initializeFilterMenuState(this.selectedField, uniqueValues, displayToRawMap);\n }\n\n // 5. 清空搜索框\n if (this.filterByValueSearchInput) {\n this.filterByValueSearchInput.value = '';\n }\n\n // 6. 渲染选项(此时状态已经初始化完成)\n this.renderFilterOptions(this.selectedField);\n this.filterByValuePanel.style.display = 'block';\n }\n\n hide(): void {\n this.filterByValuePanel.style.display = 'none';\n }\n\n clearSearchInputValue(): void {\n this.filterByValueSearchInput.value = '';\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/filter/value-filter.ts"],"names":[],"mappings":";;;AACA,6CAAuD;AAEvD,mCAA2C;AAE3C,qCAAuC;AAEvC,MAAa,WAAW;IActB,YAAY,KAA6B,EAAE,kBAAsC,EAAE,MAAoB;QAV/F,eAAU,GAAG,IAAI,GAAG,EAAwE,CAAC;QAC7F,yBAAoB,GAAG,IAAI,GAAG,EAAkC,CAAC;QAGjE,0BAAqB,GAAiD,IAAI,GAAG,EAAE,CAAC;QAOtF,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;QAC7C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC,KAAkB,EAAE,EAAE;YACvD,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAC1D,IAAI,WAAW,IAAI,WAAW,CAAC,IAAI,KAAK,SAAS,EAAE;gBACjD,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;aAC5B;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,QAAQ,CAAC,WAAyB;QACxC,IAAI,CAAC,6BAA6B,CAAC,WAAW,CAAC,CAAC;QAChD,IAAI,CAAC,4BAA4B,CAAC,WAAW,CAAC,CAAC;IACjD,CAAC;IAED,gBAAgB,CAAC,OAAwB;QACvC,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC;QAC7B,IAAI,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED,yBAAyB,CAAC,OAAwB;QAEhD,I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CAAC,CAAC;IACL,CAAC;IAED,IAAI;QAEF,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAGnD,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAG/C,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAGtD,MAAM,YAAY,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC7D,MAAM,eAAe,GAAG,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC1E,IAAI,YAAY,IAAI,eAAe,EAAE;YACnC,IAAI,CAAC,kBAAkB,CAAC,yBAAyB,CAAC,IAAI,CAAC,aAAa,EAAE,YAAY,EAAE,eAAe,CAAC,CAAC;SACtG;QAGD,IAAI,IAAI,CAAC,wBAAwB,EAAE;YACjC,IAAI,CAAC,wBAAwB,CAAC,KAAK,GAAG,EAAE,CAAC;SAC1C;QAED,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAE7C,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC1C,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC;IAClD,CAAC;IAED,IAAI;QACF,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;IACjD,CAAC;IAED,qBAAqB;QACnB,IAAI,CAAC,wBAAwB,CAAC,KAAK,GAAG,EAAE,CAAC;IAC3C,CAAC;CACF;AAnpBD,kCAmpBC","file":"value-filter.js","sourcesContent":["import type { ListTable, PivotTable } from '@visactor/vtable';\nimport { arrayEqual, isValid } from '@visactor/vutils';\nimport type { FilterConfig, ValueFilterOptionDom, FilterState, FilterStyles } from './types';\nimport { FilterActionType } from './types';\nimport type { FilterStateManager } from './filter-state-manager';\nimport { applyStyles } from './styles';\n\nexport class ValueFilter {\n private table: ListTable | PivotTable;\n private filterStateManager: FilterStateManager;\n private styles: FilterStyles;\n private uniqueKeys = new Map<string | number, Array<{ value: any; count: number; rawValue: any }>>();\n private displayToRawValueMap = new Map<string | number, Map<any, any>>();\n private selectedField: string | number;\n\n private valueFilterOptionList: Map<string | number, ValueFilterOptionDom[]> = new Map();\n private filterByValuePanel: HTMLElement;\n private filterByValueSearchInput: HTMLInputElement;\n private selectAllCheckbox: HTMLInputElement;\n private filterItemsContainer: HTMLElement;\n\n constructor(table: ListTable | PivotTable, filterStateManager: FilterStateManager, styles: FilterStyles) {\n this.table = table;\n this.filterStateManager = filterStateManager;\n this.styles = styles;\n\n this.filterStateManager.subscribe((state: FilterState) => {\n const filterState = state.filters.get(this.selectedField);\n if (filterState && filterState.type === 'byValue') {\n this.updateUI(filterState);\n }\n });\n }\n\n private updateUI(filterState: FilterConfig): void {\n this.syncCheckboxesWithFilterState(filterState);\n this.syncSelectAllWithFilterState(filterState);\n }\n\n setSelectedField(fieldId: string | number): void {\n this.selectedField = fieldId;\n this.collectUniqueColumnValues(fieldId);\n }\n\n collectUniqueColumnValues(fieldId: string | number): void {\n // 如果已经收集过,直接返回\n if (this.uniqueKeys.has(fieldId)) {\n return;\n }\n\n const displayToRawMap = new Map<any, any>(); // displayValue -> rawValue\n\n // 找到第一个匹配字段的列位置,用于获取格式化数据\n let targetCol = -1;\n for (let col = 0; col < this.table.colCount; col++) {\n for (let row = this.table.columnHeaderLevelCount; row < this.table.rowCount; row++) {\n if (!this.table.internalProps.layoutMap.isHeader(col, row)) {\n const bodyInfo = this.table.internalProps.layoutMap.getBody(col, row);\n if (bodyInfo && bodyInfo.field === fieldId) {\n targetCol = col;\n break;\n }\n }\n }\n if (targetCol !== -1) {\n break;\n }\n }\n\n // 从原始数据收集候选值(不计数,只收集唯一值)\n const records = this.table.internalProps.records;\n const recordsLength = records.length;\n\n for (let i = 0; i < recordsLength; i++) {\n let rawValue;\n let displayValue;\n if (targetCol !== -1) {\n const row = this.table.columnHeaderLevelCount + i;\n const currentRecord = records[i];\n // 获取原始数据\n rawValue = currentRecord[fieldId];\n // 获取格式化显示数据\n const bodyInfo = this.table.internalProps.layoutMap.getBody(targetCol, row);\n if (\n bodyInfo &&\n 'fieldFormat' in bodyInfo &&\n bodyInfo.fieldFormat &&\n typeof bodyInfo.fieldFormat === 'function'\n ) {\n displayValue = bodyInfo.fieldFormat({ [fieldId]: rawValue });\n } else {\n displayValue = rawValue;\n }\n } else {\n rawValue = records[i][fieldId];\n displayValue = rawValue;\n }\n\n if (rawValue !== undefined && rawValue !== null && !displayToRawMap.has(displayValue)) {\n displayToRawMap.set(displayValue, rawValue);\n }\n }\n\n // 保存显示值到原始值的映射关系\n this.displayToRawValueMap.set(fieldId, displayToRawMap);\n\n // 转换为所需格式,包含显示值、计数和原始值(count = 0 占位,后续会更新)\n const uniqueValues = Array.from(displayToRawMap.entries()).map(([displayValue, rawValue]) => ({\n value: displayValue, // UI显示的格式化值\n count: 0, // 计数占位,后续会根据筛选状态动态计算\n rawValue: rawValue // 对应的原始值\n }));\n\n this.uniqueKeys.set(fieldId, uniqueValues);\n }\n\n /**\n * 更新候选值列表的计数(基于当前筛选状态选择数据源)\n * - 未筛选列:使用当前表格数据(dataSource)计算计数\n * - 已筛选列:使用原始数据(records)计算计数\n */\n private updateCandidateCounts(fieldId: string | number): void {\n const uniqueValues = this.uniqueKeys.get(fieldId);\n if (!uniqueValues) {\n return;\n }\n\n // 判断当前列是否已启用筛选\n const filter = this.filterStateManager.getFilterState(fieldId);\n const isFiltered = filter?.enable;\n\n // 根据筛选状态选择数据源\n const dataSource = isFiltered\n ? this.table.internalProps.records // 已筛选:使用原始数据\n : this.table.internalProps.dataSource; // 未筛选:使用当前表格数据\n\n // 找到第一个匹配字段的列位置,用于获取格式化数据\n let targetCol = -1;\n for (let col = 0; col < this.table.colCount; col++) {\n for (let row = this.table.columnHeaderLevelCount; row < this.table.rowCount; row++) {\n if (!this.table.internalProps.layoutMap.isHeader(col, row)) {\n const bodyInfo = this.table.internalProps.layoutMap.getBody(col, row);\n if (bodyInfo && bodyInfo.field === fieldId) {\n targetCol = col;\n break;\n }\n }\n }\n if (targetCol !== -1) {\n break;\n }\n }\n\n // 计算每个候选值的计数\n const dataLength = dataSource.length;\n const countMap = new Map<any, number>();\n\n for (let i = 0; i < dataLength; i++) {\n let displayValue;\n if (targetCol !== -1) {\n const row = this.table.columnHeaderLevelCount + i;\n if (row < this.table.rowCount) {\n displayValue = this.table.getCellValue(targetCol, row);\n }\n } else {\n displayValue = this.table.getFieldData(\n String(fieldId),\n targetCol !== -1 ? targetCol : 0,\n this.table.columnHeaderLevelCount + i\n );\n }\n\n if (displayValue !== undefined && displayValue !== null) {\n countMap.set(displayValue, (countMap.get(displayValue) || 0) + 1);\n }\n }\n\n // 更新计数\n uniqueValues.forEach(item => {\n item.count = countMap.get(item.value) || 0;\n });\n }\n\n private onValueSelect(fieldId: string | number, displayValue: any, selected: boolean): void {\n // 获取显示值对应的原始值\n const displayToRawMap = this.displayToRawValueMap.get(fieldId);\n const rawValue = displayToRawMap ? displayToRawMap.get(displayValue) : displayValue;\n\n // 更新筛选状态\n const filter = this.filterStateManager.getFilterState(fieldId);\n let updatedValues: any[];\n if (!filter) {\n updatedValues = selected ? [rawValue] : [];\n this.filterStateManager.dispatch({\n type: FilterActionType.ADD_FILTER,\n payload: {\n field: fieldId,\n type: 'byValue',\n values: updatedValues\n }\n });\n } else {\n updatedValues = selected\n ? [...(filter.values || []), rawValue]\n : (filter.values || []).filter(v => v !== rawValue);\n this.filterStateManager.dispatch({\n type: FilterActionType.UPDATE_FILTER,\n payload: {\n field: fieldId,\n values: updatedValues\n }\n });\n }\n }\n\n /**\n * 检查值在当前搜索关键词下是否可见\n */\n private isValueVisible(displayValue: any, keyword: string): boolean {\n if (!keyword) {\n return true;\n }\n\n const filterKeywords = keyword\n .toUpperCase()\n .split(' ')\n .filter(s => s);\n\n const txtValue = String(displayValue).toUpperCase();\n return filterKeywords.some(keyword => txtValue.includes(keyword));\n }\n\n private toggleSelectAll(fieldId: string | number, selected: boolean): void {\n // 获取当前可见的值进行全选/取消全选\n const currentKeyword = this.filterStateManager.getCurrentSearchKeyword(fieldId);\n const stableCandidates = this.filterStateManager.getStableCandidateValues(fieldId);\n const displayToRawMap = this.displayToRawValueMap.get(fieldId);\n\n // 找出当前可见的所有值\n const visibleRawValues = stableCandidates\n .filter(candidate => this.isValueVisible(candidate.value, currentKeyword))\n .map(candidate => (displayToRawMap ? displayToRawMap.get(candidate.value) : candidate.value));\n\n const filter = this.filterStateManager.getFilterState(fieldId);\n const currentValues = new Set(filter?.values || []);\n\n let updatedValues: any[];\n if (selected) {\n // 全选:将可见的值添加到当前选中值中\n updatedValues = Array.from(new Set([...currentValues, ...visibleRawValues]));\n } else {\n // 取消全选:从当前选中值中移除可见的值\n updatedValues = Array.from(currentValues).filter(value => !visibleRawValues.includes(value));\n }\n\n if (!filter) {\n this.filterStateManager.dispatch({\n type: FilterActionType.ADD_FILTER,\n payload: {\n field: fieldId,\n type: 'byValue',\n values: updatedValues,\n enable: true\n }\n });\n } else {\n this.filterStateManager.dispatch({\n type: FilterActionType.UPDATE_FILTER,\n payload: {\n field: fieldId,\n values: updatedValues\n }\n });\n }\n }\n\n private onSearch(fieldId: string | number, value: string): void {\n // 更新 FilterStateManager 中的搜索关键词\n this.filterStateManager.updateSearchKeyword(fieldId, value);\n\n // 更新UI显示\n const items = this.valueFilterOptionList.get(fieldId);\n const filterKeywords = value\n .toUpperCase()\n .split(' ')\n .filter(s => s);\n\n for (const item of items) {\n const txtValue = item.id.toUpperCase() || '';\n const match = filterKeywords.some(keyword => txtValue.includes(keyword));\n const isVisible = filterKeywords.length === 0 || match;\n\n item.itemContainer.style.display = isVisible ? 'flex' : 'none';\n }\n }\n\n /**\n * 根据当前表格中的数据,初始化或更新 filter 的被选状态\n * 如果筛选已启用(enable=true),收集当前显示的数据作为选中项\n * 如果筛选未启用,初始化为所有值都选中\n */\n private initFilterStateFromTableData(fieldId: string | number): void {\n const filter = this.filterStateManager.getFilterState(fieldId);\n const isEnable = filter?.enable;\n\n // 如果筛选已启用,使用当前显示的数据作为选中值\n if (isEnable) {\n const selectedRawValues = new Set();\n const displayToRawMap = this.displayToRawValueMap.get(fieldId);\n\n // 找到第一个匹配字段的列位置,用于获取格式化数据\n let targetCol = -1;\n for (let col = 0; col < this.table.colCount; col++) {\n for (let row = this.table.columnHeaderLevelCount; row < this.table.rowCount; row++) {\n if (!this.table.internalProps.layoutMap.isHeader(col, row)) {\n const bodyInfo = this.table.internalProps.layoutMap.getBody(col, row);\n if (bodyInfo && bodyInfo.field === fieldId) {\n targetCol = col;\n break;\n }\n }\n }\n if (targetCol !== -1) {\n break;\n }\n }\n\n // 收集当前显示的数据对应的原始值\n const dataSource = this.table.internalProps.dataSource;\n const currentLength = dataSource.length;\n\n for (let i = 0; i < currentLength; i++) {\n let displayValue;\n let rawValue;\n if (targetCol !== -1) {\n const row = this.table.columnHeaderLevelCount + i;\n if (row < this.table.rowCount) {\n // 获取格式化显示值\n displayValue = this.table.getCellValue(targetCol, row);\n // 通过映射获取对应的原始值\n rawValue = displayToRawMap ? displayToRawMap.get(displayValue) : displayValue;\n }\n } else {\n displayValue = this.table.getFieldData(\n String(fieldId),\n targetCol !== -1 ? targetCol : 0,\n this.table.columnHeaderLevelCount + i\n );\n rawValue = displayToRawMap ? displayToRawMap.get(displayValue) : displayValue;\n }\n\n if (rawValue !== undefined && rawValue !== null) {\n selectedRawValues.add(rawValue);\n }\n }\n\n const hasChanged = !arrayEqual(filter.values, Array.from(selectedRawValues));\n if (hasChanged) {\n this.filterStateManager.dispatch({\n type: FilterActionType.UPDATE_FILTER,\n payload: {\n field: fieldId,\n values: Array.from(selectedRawValues)\n }\n });\n }\n } else {\n // 如果筛选未启用,初始化为计数>0的值都选中(但不启用筛选)\n if (!filter) {\n const availableRawValues =\n this.uniqueKeys\n .get(fieldId)\n ?.filter(item => item.count > 0) // 只选中计数>0的值\n ?.map(item => item.rawValue)\n .filter(v => v !== undefined && v !== null) || [];\n\n this.filterStateManager.dispatch({\n type: FilterActionType.ADD_FILTER,\n payload: {\n field: fieldId,\n type: 'byValue',\n values: availableRawValues,\n enable: false // 初始状态为未启用\n }\n });\n }\n }\n }\n\n /**\n * 根据 filter 的数据状态,更新 UI\n */\n private syncCheckboxesWithFilterState(filter: FilterConfig): void {\n if (!filter) {\n return;\n }\n const selectedRawValues = filter.values || [];\n const displayToRawMap = this.displayToRawValueMap.get(filter.field);\n const optionDomList = this.valueFilterOptionList.get(filter.field);\n\n optionDomList?.forEach(optionDom => {\n // optionDom.id 是显示值,需要转换为原始值进行比较\n const displayValue = optionDom.originalValue;\n const rawValue = displayToRawMap ? displayToRawMap.get(displayValue) : displayValue;\n\n // 检查原始值是否在选中的原始值列表中\n optionDom.checkbox.checked = selectedRawValues.some(v => v === rawValue);\n\n // 同步禁用状态:计数为0时禁用复选框\n // const count = this.uniqueKeys.get(filter.field)?.find(key => String(key.value) === optionDom.id)?.count || 0;\n // optionDom.checkbox.disabled = count === 0;\n });\n }\n\n /**\n * 根据 filter 的数据状态,更新 UI\n */\n private syncSelectAllWithFilterState(filter: FilterConfig): void {\n if (!filter || !filter.values) {\n this.selectAllCheckbox.checked = false;\n this.selectAllCheckbox.indeterminate = false;\n return;\n }\n\n const uniqueValuesCount = this.uniqueKeys.get(filter.field)?.length || 0;\n if (uniqueValuesCount === 0) {\n this.selectAllCheckbox.checked = false;\n this.selectAllCheckbox.indeterminate = false;\n } else if (filter.values.length === 0) {\n // 没有选中任何值\n this.selectAllCheckbox.checked = false;\n this.selectAllCheckbox.indeterminate = false;\n } else if (filter.values.length === uniqueValuesCount) {\n // 所有值都被选中\n this.selectAllCheckbox.checked = true;\n this.selectAllCheckbox.indeterminate = false;\n } else {\n // 部分值被选中\n this.selectAllCheckbox.checked = false;\n this.selectAllCheckbox.indeterminate = true;\n }\n }\n\n applyFilter(fieldId: string | number = this.selectedField): void {\n // 获取当前搜索过滤后可见的选中值\n const visibleSelectedKeys = Array.from(this.filterStateManager.getVisibleSelectedValues(fieldId));\n\n if (visibleSelectedKeys.length > 0 && visibleSelectedKeys.length < this.uniqueKeys.get(fieldId)?.length) {\n this.filterStateManager.dispatch({\n type: FilterActionType.APPLY_FILTERS,\n payload: {\n field: fieldId,\n type: 'byValue',\n values: visibleSelectedKeys,\n enable: true\n }\n });\n } else {\n this.filterStateManager.dispatch({\n type: FilterActionType.REMOVE_FILTER,\n payload: {\n field: fieldId\n }\n });\n }\n }\n\n clearFilter(fieldId: string | number): void {\n this.filterStateManager.dispatch({\n type: FilterActionType.REMOVE_FILTER,\n payload: {\n field: fieldId\n }\n });\n\n this.hide();\n }\n\n render(container: HTMLElement): void {\n // === 按值筛选的菜单内容 ===\n this.filterByValuePanel = document.createElement('div');\n applyStyles(this.filterByValuePanel, this.styles.filterPanel);\n\n // -- 搜索栏 ---\n const searchContainer = document.createElement('div');\n applyStyles(searchContainer, this.styles.searchContainer);\n\n this.filterByValueSearchInput = document.createElement('input');\n this.filterByValueSearchInput.type = 'text';\n this.filterByValueSearchInput.placeholder = '可使用空格分隔多个关键词';\n applyStyles(this.filterByValueSearchInput, this.styles.searchInput);\n\n searchContainer.appendChild(this.filterByValueSearchInput);\n\n // --- 筛选选项 ---\n const optionsContainer = document.createElement('div');\n applyStyles(optionsContainer, this.styles.optionsContainer);\n\n const selectAllItemDiv = document.createElement('div');\n applyStyles(selectAllItemDiv, this.styles.optionItem);\n\n const selectAllLabel = document.createElement('label');\n applyStyles(selectAllLabel, this.styles.optionLabel);\n\n this.selectAllCheckbox = document.createElement('input');\n this.selectAllCheckbox.type = 'checkbox';\n this.selectAllCheckbox.checked = true; // 默认全选\n applyStyles(this.selectAllCheckbox, this.styles.checkbox);\n\n selectAllLabel.append(this.selectAllCheckbox, ' 全选');\n selectAllItemDiv.appendChild(selectAllLabel);\n\n this.filterItemsContainer = document.createElement('div'); // 筛选条目的容器,后续应动态 appendChild\n\n optionsContainer.append(selectAllItemDiv, this.filterItemsContainer);\n this.filterByValuePanel.append(searchContainer, optionsContainer);\n\n container.appendChild(this.filterByValuePanel);\n\n this.bindEventForFilterByValue();\n }\n\n private renderFilterOptions(field: string | number): void {\n this.filterItemsContainer.innerHTML = '';\n this.valueFilterOptionList.delete(field);\n this.valueFilterOptionList.set(field, []);\n\n const selectedRawValues = this.filterStateManager.getFilterState(field)?.values || [];\n // 为了优化复杂度,将原始值转换为Set进行快速查找\n const selectedRawValueSet = new Set(selectedRawValues);\n\n const itemDomList: ValueFilterOptionDom[] = [];\n this.uniqueKeys.get(field)?.forEach(({ value, count, rawValue }) => {\n const itemDiv = document.createElement('div');\n applyStyles(itemDiv, this.styles.optionItem);\n itemDiv.style.display = 'flex';\n\n const label = document.createElement('label');\n applyStyles(label, this.styles.optionLabel);\n\n const checkbox = document.createElement('input');\n checkbox.type = 'checkbox';\n checkbox.value = String(value); // 显示值作为checkbox的value\n // 使用原始值进行选中状态判断,优化为O(1)复杂度\n checkbox.checked = selectedRawValueSet.has(rawValue);\n // 计数为0时禁用复选框(不可选中)\n // checkbox.disabled = count === 0;\n applyStyles(checkbox, this.styles.checkbox);\n\n const countSpan = document.createElement('span');\n countSpan.textContent = String(count);\n applyStyles(countSpan, this.styles.countSpan);\n\n label.append(checkbox, ` ${rawValue}`); // UI显示原始值\n itemDiv.append(label, countSpan);\n this.filterItemsContainer.appendChild(itemDiv);\n\n const itemDom: ValueFilterOptionDom = {\n id: String(value), // 显示值作为id,用于UI交互\n originalValue: value,\n itemContainer: itemDiv,\n checkbox: checkbox,\n countSpan: countSpan\n };\n\n itemDomList.push(itemDom);\n });\n\n this.valueFilterOptionList.set(field, itemDomList);\n }\n\n bindEventForFilterByValue(): void {\n // 事件委托:搜索框的 keyup 事件\n this.filterByValuePanel.addEventListener('keyup', (event: KeyboardEvent) => {\n const target = event.target;\n if (target instanceof HTMLInputElement && target.type === 'text') {\n const value = target.value;\n this.onSearch(this.selectedField, value);\n }\n });\n\n // 事件委托:复选框的 change 事件\n // 只改变UI状态,不更新筛选状态\n // 因为只有点击确认后,筛选状态才能落库\n this.filterByValuePanel.addEventListener('change', (event: Event) => {\n const target = event.target;\n if (target instanceof HTMLInputElement && target.type === 'checkbox') {\n if (target === this.selectAllCheckbox) {\n this.valueFilterOptionList.get(this.selectedField).forEach(item => (item.checkbox.checked = target.checked));\n } else {\n this.updateCheckboxUI(this.selectedField);\n }\n }\n });\n }\n\n updateCheckboxUI(field: string | number): void {\n const checkedItem = this.valueFilterOptionList.get(field)?.filter(item => item.checkbox.checked);\n const uncheckedItem = this.valueFilterOptionList.get(field)?.filter(item => !item.checkbox.checked);\n if (!isValid(checkedItem) || !isValid(uncheckedItem)) {\n return;\n }\n if (checkedItem.length !== 0 && uncheckedItem.length !== 0) {\n this.selectAllCheckbox.indeterminate = true;\n } else {\n this.selectAllCheckbox.indeterminate = false;\n this.selectAllCheckbox.checked = uncheckedItem.length === 0;\n }\n }\n\n updateCheckboxState(field: string | number): void {\n const originalValues: any = this.valueFilterOptionList\n .get(field)\n ?.filter(item => item.checkbox.checked)\n .map(item => item.originalValue);\n // 获取显示值对应的原始值\n const displayToRawMap = this.displayToRawValueMap.get(field);\n const rawValues = originalValues.map((displayValue: any) => {\n return displayToRawMap ? displayToRawMap.get(displayValue) : displayValue;\n });\n // 更新筛选状态\n this.filterStateManager.dispatch({\n type: FilterActionType.ADD_FILTER,\n payload: {\n field: field,\n type: 'byValue',\n values: rawValues\n }\n });\n }\n\n show(): void {\n // 1. 收集候选值(来自原始数据)\n this.collectUniqueColumnValues(this.selectedField);\n\n // 2. 更新计数(根据筛选状态选择数据源)\n this.updateCandidateCounts(this.selectedField);\n\n // 3. 初始化筛选状态(必须在 renderFilterOptions 之前执行)\n this.initFilterStateFromTableData(this.selectedField);\n\n // 4. 初始化筛选菜单状态,确保候选值列表稳定,并清空搜索关键词\n const uniqueValues = this.uniqueKeys.get(this.selectedField);\n const displayToRawMap = this.displayToRawValueMap.get(this.selectedField);\n if (uniqueValues && displayToRawMap) {\n this.filterStateManager.initializeFilterMenuState(this.selectedField, uniqueValues, displayToRawMap);\n }\n\n // 5. 清空搜索框\n if (this.filterByValueSearchInput) {\n this.filterByValueSearchInput.value = '';\n }\n // 6. 渲染选项(此时状态已经初始化完成)\n this.renderFilterOptions(this.selectedField);\n // 7. 同步全选状态(必须放在render之后, 只有这样checkbox ui才能与state同步, 此时需要做的是同步全选状态)\n this.updateCheckboxUI(this.selectedField);\n this.filterByValuePanel.style.display = 'block';\n }\n\n hide(): void {\n this.filterByValuePanel.style.display = 'none';\n }\n\n clearSearchInputValue(): void {\n this.filterByValueSearchInput.value = '';\n }\n}\n"]}
|
package/dist/vtable-plugins.js
CHANGED
|
@@ -10665,8 +10665,6 @@ ${recordsStr}
|
|
|
10665
10665
|
const displayValue = optionDom.originalValue;
|
|
10666
10666
|
const rawValue = displayToRawMap ? displayToRawMap.get(displayValue) : displayValue;
|
|
10667
10667
|
optionDom.checkbox.checked = selectedRawValues.some(v => v === rawValue);
|
|
10668
|
-
const count = this.uniqueKeys.get(filter.field)?.find(key => String(key.value) === optionDom.id)?.count || 0;
|
|
10669
|
-
optionDom.checkbox.disabled = count === 0;
|
|
10670
10668
|
});
|
|
10671
10669
|
}
|
|
10672
10670
|
syncSelectAllWithFilterState(filter) {
|
|
@@ -10769,12 +10767,11 @@ ${recordsStr}
|
|
|
10769
10767
|
checkbox.type = 'checkbox';
|
|
10770
10768
|
checkbox.value = String(value);
|
|
10771
10769
|
checkbox.checked = selectedRawValueSet.has(rawValue);
|
|
10772
|
-
checkbox.disabled = count === 0;
|
|
10773
10770
|
applyStyles(checkbox, this.styles.checkbox);
|
|
10774
10771
|
const countSpan = document.createElement('span');
|
|
10775
10772
|
countSpan.textContent = String(count);
|
|
10776
10773
|
applyStyles(countSpan, this.styles.countSpan);
|
|
10777
|
-
label.append(checkbox, ` ${
|
|
10774
|
+
label.append(checkbox, ` ${rawValue}`);
|
|
10778
10775
|
itemDiv.append(label, countSpan);
|
|
10779
10776
|
this.filterItemsContainer.appendChild(itemDiv);
|
|
10780
10777
|
const itemDom = {
|
|
@@ -10800,19 +10797,46 @@ ${recordsStr}
|
|
|
10800
10797
|
const target = event.target;
|
|
10801
10798
|
if (target instanceof HTMLInputElement && target.type === 'checkbox') {
|
|
10802
10799
|
if (target === this.selectAllCheckbox) {
|
|
10803
|
-
this.
|
|
10800
|
+
this.valueFilterOptionList.get(this.selectedField).forEach(item => (item.checkbox.checked = target.checked));
|
|
10804
10801
|
}
|
|
10805
10802
|
else {
|
|
10806
|
-
|
|
10807
|
-
const checked = checkbox.checked;
|
|
10808
|
-
const value = this.valueFilterOptionList
|
|
10809
|
-
.get(this.selectedField)
|
|
10810
|
-
?.find(item => item.id === checkbox.value)?.originalValue;
|
|
10811
|
-
this.onValueSelect(this.selectedField, value, checked);
|
|
10803
|
+
this.updateCheckboxUI(this.selectedField);
|
|
10812
10804
|
}
|
|
10813
10805
|
}
|
|
10814
10806
|
});
|
|
10815
10807
|
}
|
|
10808
|
+
updateCheckboxUI(field) {
|
|
10809
|
+
const checkedItem = this.valueFilterOptionList.get(field)?.filter(item => item.checkbox.checked);
|
|
10810
|
+
const uncheckedItem = this.valueFilterOptionList.get(field)?.filter(item => !item.checkbox.checked);
|
|
10811
|
+
if (!isValid$2(checkedItem) || !isValid$2(uncheckedItem)) {
|
|
10812
|
+
return;
|
|
10813
|
+
}
|
|
10814
|
+
if (checkedItem.length !== 0 && uncheckedItem.length !== 0) {
|
|
10815
|
+
this.selectAllCheckbox.indeterminate = true;
|
|
10816
|
+
}
|
|
10817
|
+
else {
|
|
10818
|
+
this.selectAllCheckbox.indeterminate = false;
|
|
10819
|
+
this.selectAllCheckbox.checked = uncheckedItem.length === 0;
|
|
10820
|
+
}
|
|
10821
|
+
}
|
|
10822
|
+
updateCheckboxState(field) {
|
|
10823
|
+
const originalValues = this.valueFilterOptionList
|
|
10824
|
+
.get(field)
|
|
10825
|
+
?.filter(item => item.checkbox.checked)
|
|
10826
|
+
.map(item => item.originalValue);
|
|
10827
|
+
const displayToRawMap = this.displayToRawValueMap.get(field);
|
|
10828
|
+
const rawValues = originalValues.map((displayValue) => {
|
|
10829
|
+
return displayToRawMap ? displayToRawMap.get(displayValue) : displayValue;
|
|
10830
|
+
});
|
|
10831
|
+
this.filterStateManager.dispatch({
|
|
10832
|
+
type: exports.FilterActionType.ADD_FILTER,
|
|
10833
|
+
payload: {
|
|
10834
|
+
field: field,
|
|
10835
|
+
type: 'byValue',
|
|
10836
|
+
values: rawValues
|
|
10837
|
+
}
|
|
10838
|
+
});
|
|
10839
|
+
}
|
|
10816
10840
|
show() {
|
|
10817
10841
|
this.collectUniqueColumnValues(this.selectedField);
|
|
10818
10842
|
this.updateCandidateCounts(this.selectedField);
|
|
@@ -10826,6 +10850,7 @@ ${recordsStr}
|
|
|
10826
10850
|
this.filterByValueSearchInput.value = '';
|
|
10827
10851
|
}
|
|
10828
10852
|
this.renderFilterOptions(this.selectedField);
|
|
10853
|
+
this.updateCheckboxUI(this.selectedField);
|
|
10829
10854
|
this.filterByValuePanel.style.display = 'block';
|
|
10830
10855
|
}
|
|
10831
10856
|
hide() {
|
|
@@ -11209,6 +11234,7 @@ ${recordsStr}
|
|
|
11209
11234
|
}
|
|
11210
11235
|
applyFilter(field) {
|
|
11211
11236
|
if (this.activeTab === 'byValue') {
|
|
11237
|
+
this.valueFilter.updateCheckboxState(field);
|
|
11212
11238
|
this.valueFilter.applyFilter(field);
|
|
11213
11239
|
}
|
|
11214
11240
|
else if (this.activeTab === 'byCondition') {
|