@visactor/vtable-plugins 1.22.7-alpha.10 → 1.22.7-alpha.11
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.d.ts +1 -0
- package/cjs/filter/filter-toolbar.js +5 -6
- package/cjs/filter/filter-toolbar.js.map +1 -1
- package/cjs/master-detail-plugin/checkbox.js +1 -0
- package/cjs/master-detail-plugin/types.js +1 -1
- package/cjs/table-export/index.js +1 -2
- package/dist/vtable-plugins.js +4 -2
- package/dist/vtable-plugins.min.js +1 -1
- package/es/filter/filter-toolbar.d.ts +1 -0
- package/es/filter/filter-toolbar.js +6 -6
- package/es/filter/filter-toolbar.js.map +1 -1
- package/es/master-detail-plugin/checkbox.js +2 -1
- package/es/master-detail-plugin/types.js +1 -1
- package/es/table-export/index.js +1 -2
- package/package.json +8 -8
|
@@ -24,6 +24,7 @@ export declare class FilterToolbar {
|
|
|
24
24
|
private clearFilterOptionLink;
|
|
25
25
|
private cancelFilterButton;
|
|
26
26
|
private applyFilterButton;
|
|
27
|
+
private activeType;
|
|
27
28
|
constructor(table: ListTable | PivotTable, filterStateManager: FilterStateManager, pluginOptions: FilterOptions);
|
|
28
29
|
private onTabSwitch;
|
|
29
30
|
private updateSelectedField;
|
|
@@ -9,7 +9,8 @@ import { applyStyles, filterStyles } from "./styles";
|
|
|
9
9
|
export class FilterToolbar {
|
|
10
10
|
constructor(table, filterStateManager, pluginOptions) {
|
|
11
11
|
this.valueFilter = null, this.conditionFilter = null, this.activeTab = "byValue",
|
|
12
|
-
this.isVisible = !1, this.selectedField = null, this.filterModes = [], this.
|
|
12
|
+
this.isVisible = !1, this.selectedField = null, this.filterModes = [], this.activeType = "byValue",
|
|
13
|
+
this.hide = (currentCol, currentRow) => {
|
|
13
14
|
this.filterMenu.style.display = "none", this.isVisible = !1, this.table.fireListeners(TABLE_EVENT_TYPE.FILTER_MENU_HIDE, {
|
|
14
15
|
col: null != currentCol ? currentCol : this.currentCol,
|
|
15
16
|
row: null != currentRow ? currentRow : this.currentRow
|
|
@@ -73,15 +74,14 @@ export class FilterToolbar {
|
|
|
73
74
|
})), applyStyles(this.filterTabsContainer, styles.tabsContainer), applyStyles(this.filterTabByValue, styles.tabStyle(!0)),
|
|
74
75
|
applyStyles(this.footerContainer, styles.footerContainer), applyStyles(this.clearFilterOptionLink, styles.clearLink),
|
|
75
76
|
applyStyles(this.cancelFilterButton, styles.footerButton(!1)), applyStyles(this.applyFilterButton, styles.footerButton(!0)),
|
|
76
|
-
this.valueFilter.updateStyles(styles), this.conditionFilter.updateStyles(styles)
|
|
77
|
-
|
|
78
|
-
currentFilter && "byCondition" === currentFilter.type ? this.onTabSwitch("byCondition") : this.onTabSwitch("byValue");
|
|
77
|
+
this.valueFilter.updateStyles(styles), this.conditionFilter.updateStyles(styles),
|
|
78
|
+
"byCondition" === this.activeType ? this.onTabSwitch("byCondition") : this.onTabSwitch("byValue");
|
|
79
79
|
}
|
|
80
80
|
attachEventListeners() {
|
|
81
81
|
this.filterTabByValue.addEventListener("click", (() => {
|
|
82
|
-
this.onTabSwitch("byValue");
|
|
82
|
+
this.activeType = "byValue", this.onTabSwitch("byValue");
|
|
83
83
|
})), this.filterTabByCondition.addEventListener("click", (() => {
|
|
84
|
-
this.onTabSwitch("byCondition");
|
|
84
|
+
this.activeType = "byCondition", this.onTabSwitch("byCondition");
|
|
85
85
|
})), this.cancelFilterButton.addEventListener("click", (() => this.hide())), this.clearFilterOptionLink.addEventListener("click", (e => {
|
|
86
86
|
e.preventDefault(), this.clearFilter(this.selectedField);
|
|
87
87
|
})), this.applyFilterButton.addEventListener("click", (() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/filter/filter-toolbar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAmC,MAAM,kBAAkB,CAAC;AAErF,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,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C,GAAG,EAAE,GAAG,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;YACtB,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,gBAAgB,CAAC,gBAAgB,EAAE;gBAC1D,GAAG,EAAE,GAAG;gBACR,GAAG,EAAE,GAAG;aACT,CAAC,CAAC;QACL,CAAC,EAAE,CAAC,CAAC,CAAC;IACR,CAAC;IAWD,OAAO;QACL,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;QAC3B,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;IAC3B,CAAC;CACF","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, filterStyles } from './styles';\nimport type { FilterMode, FilterOptions, FilterStyles } from './types';\n\n/**\n * 筛选工具栏,管理按值和按条件筛选组件\n */\nexport class FilterToolbar {\n table: ListTable | PivotTable;\n filterStateManager: FilterStateManager;\n pluginOptions: FilterOptions;\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 filterTabsContainer: 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 footerContainer: HTMLElement;\n private clearFilterOptionLink: HTMLAnchorElement;\n private cancelFilterButton: HTMLButtonElement;\n private applyFilterButton: HTMLButtonElement;\n\n constructor(table: ListTable | PivotTable, filterStateManager: FilterStateManager, pluginOptions: FilterOptions) {\n this.table = table;\n this.filterStateManager = filterStateManager;\n this.valueFilter = new ValueFilter(this.table, this.filterStateManager, pluginOptions);\n this.conditionFilter = new ConditionFilter(this.table, this.filterStateManager, pluginOptions, this.hide);\n this.pluginOptions = pluginOptions;\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, filterStyles.tabStyle(isValueTab));\n applyStyles(this.filterTabByCondition, filterStyles.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 const filterStyles = this.pluginOptions.styles || {};\n // === 主容器 ===\n this.filterMenu = document.createElement('div');\n this.filterMenu.classList.add('vtable-filter-menu');\n applyStyles(this.filterMenu, filterStyles.filterMenu);\n this.filterMenu.style.width = `${this.filterMenuWidth}px`;\n\n // === 筛选 Tab ===\n this.filterTabsContainer = document.createElement('div');\n applyStyles(this.filterTabsContainer, filterStyles.tabsContainer);\n\n this.filterTabByValue = document.createElement('button');\n this.filterTabByValue.innerText = '按值筛选';\n applyStyles(this.filterTabByValue, filterStyles.tabStyle(true));\n\n this.filterTabByCondition = document.createElement('button');\n this.filterTabByCondition.innerText = '按条件筛选';\n applyStyles(this.filterTabByCondition, filterStyles.tabStyle(false));\n\n this.filterTabsContainer.append(this.filterTabByValue, this.filterTabByCondition);\n\n // === 页脚(清除、取消、确定 筛选按钮) ===\n this.footerContainer = document.createElement('div');\n applyStyles(this.footerContainer, filterStyles.footerContainer);\n\n this.clearFilterOptionLink = document.createElement('a');\n this.clearFilterOptionLink.href = '#';\n this.clearFilterOptionLink.innerText = '清除筛选';\n applyStyles(this.clearFilterOptionLink, filterStyles.clearLink);\n\n const footerButtons = document.createElement('div');\n this.cancelFilterButton = document.createElement('button');\n this.cancelFilterButton.innerText = '取消';\n applyStyles(this.cancelFilterButton, filterStyles.footerButton(false));\n\n this.applyFilterButton = document.createElement('button');\n this.applyFilterButton.innerText = '确认';\n applyStyles(this.applyFilterButton, filterStyles.footerButton(true));\n\n footerButtons.append(this.cancelFilterButton, this.applyFilterButton);\n this.footerContainer.append(this.clearFilterOptionLink, footerButtons);\n\n // --- 筛选器头部 Tab ---\n this.filterMenu.append(this.filterTabsContainer);\n\n // --- 筛选器内容 ---\n this.valueFilter.render(this.filterMenu);\n this.conditionFilter.render(this.filterMenu);\n\n // --- 筛选器页脚 ---\n this.filterMenu.append(this.footerContainer);\n\n container.appendChild(this.filterMenu); // 将筛选器添加到 DOM 中\n this.attachEventListeners();\n }\n\n updateStyles(styles: FilterStyles) {\n const realDisplay = (this.filterMenu.style.display ?? styles.filterMenu.display) || 'none';\n applyStyles(this.filterMenu, { ...styles.filterMenu, display: realDisplay });\n applyStyles(this.filterTabsContainer, styles.tabsContainer);\n applyStyles(this.filterTabByValue, styles.tabStyle(true));\n applyStyles(this.footerContainer, styles.footerContainer);\n applyStyles(this.clearFilterOptionLink, styles.clearLink);\n applyStyles(this.cancelFilterButton, styles.footerButton(false));\n applyStyles(this.applyFilterButton, styles.footerButton(true));\n this.valueFilter.updateStyles(styles);\n this.conditionFilter.updateStyles(styles);\n\n // 面板处于显示状态, 更新了样式, 则需要手动控制tab显隐\n // 面板显示按值筛选或按条件筛选\n const currentFilter = this.filterStateManager.getFilterState(this.selectedField);\n if (currentFilter && currentFilter.type === 'byCondition') {\n this.onTabSwitch('byCondition');\n } else {\n this.onTabSwitch('byValue');\n }\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 const filterMenuWidth = this.filterMenuWidth;\n // 最高高度预估值\n // TODO: 需要获取精确高度\n const filterMenuHeight = 380;\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 // 确保筛选菜单不会超出窗口边界\n left = Math.max(0, Math.min(window.innerWidth - filterMenuWidth, left));\n top = Math.max(0, Math.min(window.innerHeight - filterMenuHeight, top));\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, currentRow?: number): void => {\n this.filterMenu.style.display = 'none';\n this.isVisible = false;\n this.table.fireListeners(TABLE_EVENT_TYPE.FILTER_MENU_HIDE, {\n col: currentCol ?? this.currentCol,\n row: currentRow ?? this.currentRow\n });\n };\n\n destroy() {\n this.valueFilter.destroy();\n this.filterMenu.remove();\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/filter/filter-toolbar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAmC,MAAM,kBAAkB,CAAC;AAErF,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAMrD,M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AC;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;YACtB,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,gBAAgB,CAAC,gBAAgB,EAAE;gBAC1D,GAAG,EAAE,GAAG;gBACR,GAAG,EAAE,GAAG;aACT,CAAC,CAAC;QACL,CAAC,EAAE,CAAC,CAAC,CAAC;IACR,CAAC;IAWD,OAAO;QACL,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;QAC3B,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;IAC3B,CAAC;CACF","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, filterStyles } from './styles';\nimport type { FilterMode, FilterOptions, FilterStyles } from './types';\n\n/**\n * 筛选工具栏,管理按值和按条件筛选组件\n */\nexport class FilterToolbar {\n table: ListTable | PivotTable;\n filterStateManager: FilterStateManager;\n pluginOptions: FilterOptions;\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 filterTabsContainer: 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 footerContainer: HTMLElement;\n private clearFilterOptionLink: HTMLAnchorElement;\n private cancelFilterButton: HTMLButtonElement;\n private applyFilterButton: HTMLButtonElement;\n\n private activeType: 'byValue' | 'byCondition' = 'byValue';\n\n constructor(table: ListTable | PivotTable, filterStateManager: FilterStateManager, pluginOptions: FilterOptions) {\n this.table = table;\n this.filterStateManager = filterStateManager;\n this.valueFilter = new ValueFilter(this.table, this.filterStateManager, pluginOptions);\n this.conditionFilter = new ConditionFilter(this.table, this.filterStateManager, pluginOptions, this.hide);\n this.pluginOptions = pluginOptions;\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, filterStyles.tabStyle(isValueTab));\n applyStyles(this.filterTabByCondition, filterStyles.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 const filterStyles = this.pluginOptions.styles || {};\n // === 主容器 ===\n this.filterMenu = document.createElement('div');\n this.filterMenu.classList.add('vtable-filter-menu');\n applyStyles(this.filterMenu, filterStyles.filterMenu);\n this.filterMenu.style.width = `${this.filterMenuWidth}px`;\n\n // === 筛选 Tab ===\n this.filterTabsContainer = document.createElement('div');\n applyStyles(this.filterTabsContainer, filterStyles.tabsContainer);\n\n this.filterTabByValue = document.createElement('button');\n this.filterTabByValue.innerText = '按值筛选';\n applyStyles(this.filterTabByValue, filterStyles.tabStyle(true));\n\n this.filterTabByCondition = document.createElement('button');\n this.filterTabByCondition.innerText = '按条件筛选';\n applyStyles(this.filterTabByCondition, filterStyles.tabStyle(false));\n\n this.filterTabsContainer.append(this.filterTabByValue, this.filterTabByCondition);\n\n // === 页脚(清除、取消、确定 筛选按钮) ===\n this.footerContainer = document.createElement('div');\n applyStyles(this.footerContainer, filterStyles.footerContainer);\n\n this.clearFilterOptionLink = document.createElement('a');\n this.clearFilterOptionLink.href = '#';\n this.clearFilterOptionLink.innerText = '清除筛选';\n applyStyles(this.clearFilterOptionLink, filterStyles.clearLink);\n\n const footerButtons = document.createElement('div');\n this.cancelFilterButton = document.createElement('button');\n this.cancelFilterButton.innerText = '取消';\n applyStyles(this.cancelFilterButton, filterStyles.footerButton(false));\n\n this.applyFilterButton = document.createElement('button');\n this.applyFilterButton.innerText = '确认';\n applyStyles(this.applyFilterButton, filterStyles.footerButton(true));\n\n footerButtons.append(this.cancelFilterButton, this.applyFilterButton);\n this.footerContainer.append(this.clearFilterOptionLink, footerButtons);\n\n // --- 筛选器头部 Tab ---\n this.filterMenu.append(this.filterTabsContainer);\n\n // --- 筛选器内容 ---\n this.valueFilter.render(this.filterMenu);\n this.conditionFilter.render(this.filterMenu);\n\n // --- 筛选器页脚 ---\n this.filterMenu.append(this.footerContainer);\n\n container.appendChild(this.filterMenu); // 将筛选器添加到 DOM 中\n this.attachEventListeners();\n }\n\n updateStyles(styles: FilterStyles) {\n const realDisplay = (this.filterMenu.style.display ?? styles.filterMenu.display) || 'none';\n applyStyles(this.filterMenu, { ...styles.filterMenu, display: realDisplay });\n applyStyles(this.filterTabsContainer, styles.tabsContainer);\n applyStyles(this.filterTabByValue, styles.tabStyle(true));\n applyStyles(this.footerContainer, styles.footerContainer);\n applyStyles(this.clearFilterOptionLink, styles.clearLink);\n applyStyles(this.cancelFilterButton, styles.footerButton(false));\n applyStyles(this.applyFilterButton, styles.footerButton(true));\n this.valueFilter.updateStyles(styles);\n this.conditionFilter.updateStyles(styles);\n\n // 面板处于显示状态, 更新了样式, 则需要手动控制tab显隐\n // 面板显示按值筛选或按条件筛选\n if (this.activeType === 'byCondition') {\n this.onTabSwitch('byCondition');\n } else {\n this.onTabSwitch('byValue');\n }\n }\n\n attachEventListeners() {\n // 按值筛选/按条件筛选的事件监听\n this.filterTabByValue.addEventListener('click', () => {\n this.activeType = 'byValue';\n this.onTabSwitch('byValue');\n });\n\n this.filterTabByCondition.addEventListener('click', () => {\n this.activeType = 'byCondition';\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 const filterMenuWidth = this.filterMenuWidth;\n // 最高高度预估值\n // TODO: 需要获取精确高度\n const filterMenuHeight = 380;\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 // 确保筛选菜单不会超出窗口边界\n left = Math.max(0, Math.min(window.innerWidth - filterMenuWidth, left));\n top = Math.max(0, Math.min(window.innerHeight - filterMenuHeight, top));\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, currentRow?: number): void => {\n this.filterMenu.style.display = 'none';\n this.isVisible = false;\n this.table.fireListeners(TABLE_EVENT_TYPE.FILTER_MENU_HIDE, {\n col: currentCol ?? this.currentCol,\n row: currentRow ?? this.currentRow\n });\n };\n\n destroy() {\n this.valueFilter.destroy();\n this.filterMenu.remove();\n }\n}\n"]}
|
|
@@ -90,4 +90,5 @@ function updateAllSubTableCheckboxes(subTable, field, checked) {
|
|
|
90
90
|
subTable.scenegraph.updateHeaderCheckboxCellState(checkboxCol, 0, checked);
|
|
91
91
|
for (let row = subTable.columnHeaderLevelCount; row < subTable.rowCount; row++) setCellCheckboxStateByAttribute(checkboxCol, row, checked, subTable);
|
|
92
92
|
}
|
|
93
|
-
}
|
|
93
|
+
}
|
|
94
|
+
//# sourceMappingURL=checkbox.js.map
|
package/es/table-export/index.js
CHANGED
|
@@ -4,5 +4,4 @@ import { exportVTableToCsv } from "./csv";
|
|
|
4
4
|
|
|
5
5
|
import { downloadCsv, downloadExcel } from "./util/download";
|
|
6
6
|
|
|
7
|
-
export { exportVTableToCsv, downloadCsv, exportVTableToExcel, downloadExcel };
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
|
7
|
+
export { exportVTableToCsv, downloadCsv, exportVTableToExcel, downloadExcel };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visactor/vtable-plugins",
|
|
3
|
-
"version": "1.22.7-alpha.
|
|
3
|
+
"version": "1.22.7-alpha.11",
|
|
4
4
|
"description": "The search util of VTable",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "VisActor",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"@types/file-saver": "2.0.7"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@visactor/vtable": "1.22.7-alpha.
|
|
46
|
-
"@visactor/vtable-gantt": "1.22.7-alpha.
|
|
45
|
+
"@visactor/vtable": "1.22.7-alpha.11",
|
|
46
|
+
"@visactor/vtable-gantt": "1.22.7-alpha.11"
|
|
47
47
|
},
|
|
48
48
|
"peerDependenciesMeta": {
|
|
49
49
|
"@visactor/vtable-gantt": {
|
|
@@ -53,9 +53,9 @@
|
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"cross-env": "^7.0.3",
|
|
55
55
|
"increase-memory-limit": "^1.0.7",
|
|
56
|
-
"@visactor/vtable": "1.22.7-alpha.
|
|
57
|
-
"@visactor/vtable-editors": "1.22.7-alpha.
|
|
58
|
-
"@visactor/vtable-gantt": "1.22.7-alpha.
|
|
56
|
+
"@visactor/vtable": "1.22.7-alpha.11",
|
|
57
|
+
"@visactor/vtable-editors": "1.22.7-alpha.11",
|
|
58
|
+
"@visactor/vtable-gantt": "1.22.7-alpha.11",
|
|
59
59
|
"@visactor/vchart": "2.0.8-alpha.5",
|
|
60
60
|
"@rushstack/eslint-patch": "~1.1.4",
|
|
61
61
|
"react": "^18.0.0",
|
|
@@ -98,9 +98,9 @@
|
|
|
98
98
|
"@types/react-is": "^17.0.3",
|
|
99
99
|
"rollup-plugin-node-resolve": "5.2.0",
|
|
100
100
|
"@types/lodash": "4.14.182",
|
|
101
|
+
"@internal/bundler": "0.0.1",
|
|
101
102
|
"@internal/eslint-config": "0.0.1",
|
|
102
|
-
"@internal/ts-config": "0.0.1"
|
|
103
|
-
"@internal/bundler": "0.0.1"
|
|
103
|
+
"@internal/ts-config": "0.0.1"
|
|
104
104
|
},
|
|
105
105
|
"scripts": {
|
|
106
106
|
"demo": "vite ./demo",
|