@visactor/vtable-plugins 1.22.7-alpha.0 → 1.22.7-alpha.10

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.
Files changed (67) hide show
  1. package/cjs/auto-fill/index.js +2 -1
  2. package/cjs/contextmenu/index.js +1 -2
  3. package/cjs/contextmenu/types.js +1 -1
  4. package/cjs/filter/condition-filter.d.ts +13 -2
  5. package/cjs/filter/condition-filter.js +69 -172
  6. package/cjs/filter/condition-filter.js.map +1 -1
  7. package/cjs/filter/constant.d.ts +7 -0
  8. package/cjs/filter/constant.js +124 -0
  9. package/cjs/filter/constant.js.map +1 -0
  10. package/cjs/filter/filter-engine.d.ts +3 -1
  11. package/cjs/filter/filter-engine.js +5 -3
  12. package/cjs/filter/filter-engine.js.map +1 -1
  13. package/cjs/filter/filter-state-manager.js +8 -2
  14. package/cjs/filter/filter-state-manager.js.map +1 -1
  15. package/cjs/filter/filter-toolbar.d.ts +9 -4
  16. package/cjs/filter/filter-toolbar.js +46 -27
  17. package/cjs/filter/filter-toolbar.js.map +1 -1
  18. package/cjs/filter/filter.d.ts +2 -0
  19. package/cjs/filter/filter.js +28 -14
  20. package/cjs/filter/filter.js.map +1 -1
  21. package/cjs/filter/styles.js +1 -1
  22. package/cjs/filter/styles.js.map +1 -1
  23. package/cjs/filter/types.d.ts +35 -0
  24. package/cjs/filter/types.js.map +1 -1
  25. package/cjs/filter/value-filter.d.ts +10 -2
  26. package/cjs/filter/value-filter.js +105 -55
  27. package/cjs/filter/value-filter.js.map +1 -1
  28. package/cjs/focus-highlight.js +1 -1
  29. package/cjs/focus-highlight.js.map +1 -1
  30. package/cjs/master-detail-plugin/checkbox.js +0 -1
  31. package/cjs/master-detail-plugin/utils.js +1 -1
  32. package/cjs/table-export/index.js +1 -1
  33. package/dist/vtable-plugins.js +9821 -163
  34. package/dist/vtable-plugins.min.js +3 -3
  35. package/es/auto-fill/index.js +2 -1
  36. package/es/contextmenu/index.js +1 -2
  37. package/es/contextmenu/types.js +1 -1
  38. package/es/filter/condition-filter.d.ts +13 -2
  39. package/es/filter/condition-filter.js +67 -168
  40. package/es/filter/condition-filter.js.map +1 -1
  41. package/es/filter/constant.d.ts +7 -0
  42. package/es/filter/constant.js +120 -0
  43. package/es/filter/constant.js.map +1 -0
  44. package/es/filter/filter-engine.d.ts +3 -1
  45. package/es/filter/filter-engine.js +5 -3
  46. package/es/filter/filter-engine.js.map +1 -1
  47. package/es/filter/filter-state-manager.js +8 -2
  48. package/es/filter/filter-state-manager.js.map +1 -1
  49. package/es/filter/filter-toolbar.d.ts +9 -4
  50. package/es/filter/filter-toolbar.js +46 -24
  51. package/es/filter/filter-toolbar.js.map +1 -1
  52. package/es/filter/filter.d.ts +2 -0
  53. package/es/filter/filter.js +35 -15
  54. package/es/filter/filter.js.map +1 -1
  55. package/es/filter/styles.js +1 -1
  56. package/es/filter/styles.js.map +1 -1
  57. package/es/filter/types.d.ts +35 -0
  58. package/es/filter/types.js.map +1 -1
  59. package/es/filter/value-filter.d.ts +10 -2
  60. package/es/filter/value-filter.js +103 -52
  61. package/es/filter/value-filter.js.map +1 -1
  62. package/es/focus-highlight.js +1 -1
  63. package/es/focus-highlight.js.map +1 -1
  64. package/es/master-detail-plugin/checkbox.js +1 -2
  65. package/es/master-detail-plugin/utils.js +1 -1
  66. package/es/table-export/index.js +1 -1
  67. package/package.json +9 -9
@@ -1,10 +1,12 @@
1
1
  import type { ListTable, PivotTable, TYPES } from '@visactor/vtable';
2
- import type { FilterState } from './types';
2
+ import type { FilterState, FilterOptions } from './types';
3
3
  export declare class FilterEngine {
4
4
  filterFuncRule: (TYPES.FilterFuncRule & {
5
5
  fieldId?: string;
6
6
  })[];
7
7
  filterValueRule: TYPES.FilterValueRule[];
8
+ private pluginOptions;
9
+ constructor(filterPluginOptions: FilterOptions);
8
10
  applyFilter(state: FilterState, table: ListTable | PivotTable): void;
9
11
  private createFilterFunction;
10
12
  private compareValues;
@@ -5,10 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  }), exports.FilterEngine = void 0;
6
6
 
7
7
  class FilterEngine {
8
- constructor() {
9
- this.filterFuncRule = [], this.filterValueRule = [];
8
+ constructor(filterPluginOptions) {
9
+ this.filterFuncRule = [], this.filterValueRule = [], this.pluginOptions = filterPluginOptions;
10
10
  }
11
11
  applyFilter(state, table) {
12
+ var _a;
12
13
  const {filters: filters} = state;
13
14
  this.filterFuncRule = [], this.filterValueRule = [], filters.forEach(((filter, field) => {
14
15
  if (filter.enable) if ("byValue" === filter.type) this.filterValueRule.push({
@@ -22,7 +23,8 @@ class FilterEngine {
22
23
  });
23
24
  }
24
25
  })), table.updateFilterRules([ ...this.filterFuncRule, ...this.filterValueRule ], {
25
- clearRowHeightCache: !1
26
+ clearRowHeightCache: !1,
27
+ onFilterRecordsEnd: null === (_a = this.pluginOptions) || void 0 === _a ? void 0 : _a.onFilterRecordsEnd
26
28
  });
27
29
  }
28
30
  createFilterFunction(filter) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/filter/filter-engine.ts"],"names":[],"mappings":";;;AAMA,MAAa,YAAY;IAAzB;QACE,mBAAc,GAAoD,EAAE,CAAC;QACrE,oBAAe,GAA4B,EAAE,CAAC;IAgIhD,CAAC;IA9HC,WAAW,CAAC,KAAkB,EAAE,KAA6B;QAC3D,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;QAC1B,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;QAE1B,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;YAChC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;gBAClB,OAAO;aACR;YAED,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE;gBAC7B,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC;oBACxB,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;oBA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,CAAC;SACrC;QAED,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;QAC7C,MAAM,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,CAAC;QACrD,OAAO,QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1E,CAAC;IAED,cAAc,CAAC,KAA6B;QAC1C,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;QAC1B,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC;IAED,WAAW,CAAC,KAA6B,EAAE,OAAwB;QACjE,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,KAAK,OAAO,CAAC,CAAC;QACvF,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,KAAK,OAAO,CAAC,CAAC;QAEnF,KAAK,CAAC,iBAAiB,CAAC,CAAC,GAAG,IAAI,CAAC,cAAc,EAAE,GAAG,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC;IAC7E,CAAC;CACF;AAlID,oCAkIC","file":"filter-engine.js","sourcesContent":["import type { ListTable, PivotTable, TYPES } from '@visactor/vtable';\nimport type { FilterState, FilterOperator, FilterConfig } from './types';\n\n/**\n * 筛选引擎,用于进行实际的筛选操作\n */\nexport class FilterEngine {\n filterFuncRule: (TYPES.FilterFuncRule & { fieldId?: string })[] = [];\n filterValueRule: TYPES.FilterValueRule[] = [];\n\n applyFilter(state: FilterState, table: ListTable | PivotTable) {\n const { filters } = state;\n this.filterFuncRule = [];\n this.filterValueRule = [];\n\n filters.forEach((filter, field) => {\n if (!filter.enable) {\n return;\n }\n\n if (filter.type === 'byValue') {\n this.filterValueRule.push({\n filterKey: String(filter.field),\n filteredValues: filter.values\n });\n } else if (filter.type === 'byCondition') {\n // 为条件筛选生成过滤函数\n const filterFunc = this.createFilterFunction(filter);\n this.filterFuncRule.push({\n filterFunc,\n fieldId: String(filter.field)\n });\n }\n });\n\n table.updateFilterRules([...this.filterFuncRule, ...this.filterValueRule], {\n clearRowHeightCache: false\n });\n }\n\n /**\n * 根据筛选配置创建筛选函数\n */\n private createFilterFunction(filter: FilterConfig): (record: any) => boolean {\n const { field, operator, condition } = filter;\n\n // 如果没有操作符或条件,返回一个总是通过的函数\n if (!operator || condition === undefined) {\n return () => true;\n }\n\n return (record: any) => {\n const value = record[field];\n\n if (value === null || value === undefined) {\n return false;\n }\n\n // 根据操作符生成对应的比较逻辑\n switch (operator) {\n case 'equals':\n return this.compareValues(value, condition) === 0;\n case 'notEquals':\n return this.compareValues(value, condition) !== 0;\n case 'greaterThan':\n return this.compareValues(value, condition) > 0;\n case 'lessThan':\n return this.compareValues(value, condition) < 0;\n case 'greaterThanOrEqual':\n return this.compareValues(value, condition) >= 0;\n case 'lessThanOrEqual':\n return this.compareValues(value, condition) <= 0;\n case 'between':\n // 范围条件需要是数组形式 [min, max]\n if (Array.isArray(condition) && condition.length === 2) {\n return this.compareValues(value, condition[0]) >= 0 && this.compareValues(value, condition[1]) <= 0;\n }\n return true;\n case 'notBetween':\n // 范围条件需要是数组形式 [min, max]\n if (Array.isArray(condition) && condition.length === 2) {\n return this.compareValues(value, condition[0]) < 0 || this.compareValues(value, condition[1]) > 0;\n }\n return true;\n case 'contains':\n return String(value).toLowerCase().includes(String(condition).toLowerCase());\n case 'notContains':\n return !String(value).toLowerCase().includes(String(condition).toLowerCase());\n case 'startsWith':\n return String(value).toLowerCase().startsWith(String(condition).toLowerCase());\n case 'notStartsWith':\n return !String(value).toLowerCase().startsWith(String(condition).toLowerCase());\n case 'endsWith':\n return String(value).toLowerCase().endsWith(String(condition).toLowerCase());\n case 'notEndsWith':\n return !String(value).toLowerCase().endsWith(String(condition).toLowerCase());\n case 'isChecked':\n return Boolean(value) === true;\n case 'isUnchecked':\n return Boolean(value) === false;\n default:\n return true;\n }\n };\n }\n\n /**\n * 比较两个值\n * 返回: -1 (value < condition), 0 (value === condition), 1 (value > condition)\n */\n private compareValues(value: any, condition: any): number {\n if (typeof value === 'number' && typeof condition === 'number') {\n return value === condition ? 0 : value > condition ? 1 : -1;\n }\n\n if (typeof value === 'boolean' && typeof condition === 'boolean') {\n return value === condition ? 0 : -1;\n }\n\n const valueStr = String(value).toLowerCase();\n const conditionStr = String(condition).toLowerCase();\n return valueStr === conditionStr ? 0 : valueStr > conditionStr ? 1 : -1;\n }\n\n clearAllFilter(table: ListTable | PivotTable) {\n this.filterFuncRule = [];\n this.filterValueRule = [];\n table.updateFilterRules([]);\n }\n\n clearFilter(table: ListTable | PivotTable, fieldId: string | number) {\n this.filterValueRule = this.filterValueRule.filter(rule => rule.filterKey !== fieldId);\n this.filterFuncRule = this.filterFuncRule.filter(rule => rule.fieldId !== fieldId);\n\n table.updateFilterRules([...this.filterFuncRule, ...this.filterValueRule]);\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/filter/filter-engine.ts"],"names":[],"mappings":";;;AAMA,MAAa,YAAY;IAMvB,YAAY,mBAAkC;QAL9C,mBAAc,GAAoD,EAAE,CAAC;QACrE,oBAAe,GAA4B,EAAE,CAAC;QAK5C,IAAI,CAAC,aAAa,GAAG,mBAAmB,CAAC;IAC3C,CAAC;IAED,WAAW,CAAC,KAAkB,EAAE,KAA6B;;QAC3D,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;QAC1B,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;QAE1B,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,KAAK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":"filter-engine.js","sourcesContent":["import type { ListTable, PivotTable, TYPES } from '@visactor/vtable';\nimport type { FilterState, FilterConfig, FilterOptions } from './types';\n\n/**\n * 筛选引擎,用于进行实际的筛选操作\n */\nexport class FilterEngine {\n filterFuncRule: (TYPES.FilterFuncRule & { fieldId?: string })[] = [];\n filterValueRule: TYPES.FilterValueRule[] = [];\n\n private pluginOptions: FilterOptions;\n\n constructor(filterPluginOptions: FilterOptions) {\n this.pluginOptions = filterPluginOptions;\n }\n\n applyFilter(state: FilterState, table: ListTable | PivotTable) {\n const { filters } = state;\n this.filterFuncRule = [];\n this.filterValueRule = [];\n\n filters.forEach((filter, field) => {\n if (!filter.enable) {\n return;\n }\n\n if (filter.type === 'byValue') {\n this.filterValueRule.push({\n filterKey: String(filter.field),\n filteredValues: filter.values\n });\n } else if (filter.type === 'byCondition') {\n // 为条件筛选生成过滤函数\n const filterFunc = this.createFilterFunction(filter);\n this.filterFuncRule.push({\n filterFunc,\n fieldId: String(filter.field)\n });\n }\n });\n\n table.updateFilterRules([...this.filterFuncRule, ...this.filterValueRule], {\n clearRowHeightCache: false,\n onFilterRecordsEnd: this.pluginOptions?.onFilterRecordsEnd\n });\n }\n\n /**\n * 根据筛选配置创建筛选函数\n */\n private createFilterFunction(filter: FilterConfig): (record: any) => boolean {\n const { field, operator, condition } = filter;\n\n // 如果没有操作符或条件,返回一个总是通过的函数\n if (!operator || condition === undefined) {\n return () => true;\n }\n\n return (record: any) => {\n const value = record[field];\n\n if (value === null || value === undefined) {\n return false;\n }\n\n // 根据操作符生成对应的比较逻辑\n switch (operator) {\n case 'equals':\n return this.compareValues(value, condition) === 0;\n case 'notEquals':\n return this.compareValues(value, condition) !== 0;\n case 'greaterThan':\n return this.compareValues(value, condition) > 0;\n case 'lessThan':\n return this.compareValues(value, condition) < 0;\n case 'greaterThanOrEqual':\n return this.compareValues(value, condition) >= 0;\n case 'lessThanOrEqual':\n return this.compareValues(value, condition) <= 0;\n case 'between':\n // 范围条件需要是数组形式 [min, max]\n if (Array.isArray(condition) && condition.length === 2) {\n return this.compareValues(value, condition[0]) >= 0 && this.compareValues(value, condition[1]) <= 0;\n }\n return true;\n case 'notBetween':\n // 范围条件需要是数组形式 [min, max]\n if (Array.isArray(condition) && condition.length === 2) {\n return this.compareValues(value, condition[0]) < 0 || this.compareValues(value, condition[1]) > 0;\n }\n return true;\n case 'contains':\n return String(value).toLowerCase().includes(String(condition).toLowerCase());\n case 'notContains':\n return !String(value).toLowerCase().includes(String(condition).toLowerCase());\n case 'startsWith':\n return String(value).toLowerCase().startsWith(String(condition).toLowerCase());\n case 'notStartsWith':\n return !String(value).toLowerCase().startsWith(String(condition).toLowerCase());\n case 'endsWith':\n return String(value).toLowerCase().endsWith(String(condition).toLowerCase());\n case 'notEndsWith':\n return !String(value).toLowerCase().endsWith(String(condition).toLowerCase());\n case 'isChecked':\n return Boolean(value) === true;\n case 'isUnchecked':\n return Boolean(value) === false;\n default:\n return true;\n }\n };\n }\n\n /**\n * 比较两个值\n * 返回: -1 (value < condition), 0 (value === condition), 1 (value > condition)\n */\n private compareValues(value: any, condition: any): number {\n if (typeof value === 'number' && typeof condition === 'number') {\n return value === condition ? 0 : value > condition ? 1 : -1;\n }\n\n if (typeof value === 'boolean' && typeof condition === 'boolean') {\n return value === condition ? 0 : -1;\n }\n\n const valueStr = String(value).toLowerCase();\n const conditionStr = String(condition).toLowerCase();\n return valueStr === conditionStr ? 0 : valueStr > conditionStr ? 1 : -1;\n }\n\n clearAllFilter(table: ListTable | PivotTable) {\n this.filterFuncRule = [];\n this.filterValueRule = [];\n table.updateFilterRules([]);\n }\n\n clearFilter(table: ListTable | PivotTable, fieldId: string | number) {\n this.filterValueRule = this.filterValueRule.filter(rule => rule.filterKey !== fieldId);\n this.filterFuncRule = this.filterFuncRule.filter(rule => rule.fieldId !== fieldId);\n\n table.updateFilterRules([...this.filterFuncRule, ...this.filterValueRule]);\n }\n}\n"]}
@@ -43,11 +43,17 @@ class FilterStateManager {
43
43
  const {type: type, payload: payload} = action, newFilter = new Map(state.filters);
44
44
  switch (type) {
45
45
  case types_1.FilterActionType.ADD_FILTER:
46
- newFilter.set(payload.field, payload);
46
+ payload.shouldKeepUnrelatedState ? newFilter.set(payload.field, Object.assign(Object.assign({}, newFilter.get(payload.field)), payload)) : newFilter.set(payload.field, payload);
47
47
  break;
48
48
 
49
49
  case types_1.FilterActionType.REMOVE_FILTER:
50
- newFilter.delete(payload.field);
50
+ payload.shouldKeepUnrelatedState && "byValue" === payload.type ? (delete newFilter.get(payload.field).values,
51
+ newFilter.set(payload.field, Object.assign(Object.assign({}, newFilter.get(payload.field)), {
52
+ enable: !1
53
+ }))) : payload.shouldKeepUnrelatedState && "byCondition" === payload.type ? (delete newFilter.get(payload.field).condition,
54
+ delete newFilter.get(payload.field).operator, newFilter.set(payload.field, Object.assign(Object.assign({}, newFilter.get(payload.field)), {
55
+ enable: !1
56
+ }))) : newFilter.delete(payload.field);
51
57
  break;
52
58
 
53
59
  case types_1.FilterActionType.UPDATE_FILTER:
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/filter/filter-state-manager.ts"],"names":[],"mappings":";;;AAEA,mCAA2C;AAM3C,MAAa,kBAAkB;IAO7B,YAAY,KAA6B,EAAE,MAAoB;QAJvD,cAAS,GAA0B,EAAE,CAAC;QAK5C,IAAI,CAAC,KAAK,GAAG;YACX,OAAO,EAAE,IAAI,GAAG,EAAE;SACnB,CAAC;QACF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,cAAc,CAAC,OAAyB;QACtC,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAKD,qBAAqB;QACnB,MAAM,YAAY,GAAwB,EAAE,CAAC;QAC7C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,KAAK,EAA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C,WAAW,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IAClD,CAAC;IAEO,iBAAiB,CAAC,MAAoB;QAC5C,MAAM,kBAAkB,GAAG;YACzB,wBAAgB,CAAC,aAAa;YAC9B,wBAAgB,CAAC,aAAa;YAC9B,wBAAgB,CAAC,cAAc;YAC/B,wBAAgB,CAAC,iBAAiB;YAClC,wBAAgB,CAAC,aAAa;SAC/B,CAAC;QACF,OAAO,kBAAkB,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC;CACF;AAjHD,gDAiHC","file":"filter-state-manager.js","sourcesContent":["import type { ListTable, PivotTable } from '@visactor/vtable';\nimport type { FilterState, FilterAction, FilterConfig, FilterListener } from './types';\nimport { FilterActionType } from './types';\nimport type { FilterEngine } from './filter-engine';\n\n/**\n * 筛选状态管理器,用于管理筛选状态\n */\nexport class FilterStateManager {\n private state: FilterState;\n private engine: FilterEngine;\n private listeners: Array<FilterListener> = [];\n\n private table: ListTable | PivotTable;\n\n constructor(table: ListTable | PivotTable, engine: FilterEngine) {\n this.state = {\n filters: new Map()\n };\n this.engine = engine;\n this.table = table;\n }\n\n getFilterState(fieldId?: string | number): FilterConfig {\n return this.state.filters.get(fieldId);\n }\n\n /**\n * 获取所有激活的筛选字段\n */\n getActiveFilterFields(): (string | number)[] {\n const activeFields: (string | number)[] = [];\n this.state.filters.forEach((config, field) => {\n if (config.enable) {\n activeFields.push(field);\n }\n });\n return activeFields;\n }\n\n /**\n * 获取所有筛选状态\n */\n getAllFilterStates(): FilterState {\n return this.state;\n }\n\n /**\n * 公共方法:重新应用当前所有激活的筛选状态\n * 用于在表格配置更新后恢复筛选显示\n */\n reapplyCurrentFilters(): void {\n const activeFields = this.getActiveFilterFields();\n if (activeFields.length > 0) {\n this.applyFilters();\n }\n }\n\n dispatch(action: FilterAction) {\n this.state = this.reduce(this.state, action);\n if (this.shouldApplyFilter(action)) {\n this.applyFilters();\n }\n this.notifyListeners(action);\n }\n\n subscribe(listener: FilterListener): () => void {\n this.listeners.push(listener);\n return () => {\n this.listeners = this.listeners.filter(l => l !== listener);\n };\n }\n\n private notifyListeners(action: FilterAction): void {\n this.listeners.forEach(listener => listener(this.state, action));\n }\n\n private reduce(state: FilterState, action: FilterAction): FilterState {\n const { type, payload } = action;\n const newFilter = new Map(state.filters);\n switch (type) {\n case FilterActionType.ADD_FILTER:\n newFilter.set(payload.field, payload);\n break;\n case FilterActionType.REMOVE_FILTER:\n newFilter.delete(payload.field);\n break;\n case FilterActionType.UPDATE_FILTER:\n newFilter.set(payload.field, { ...newFilter.get(payload.field), ...payload });\n break;\n case FilterActionType.ENABLE_FILTER:\n newFilter.set(payload.field, { ...newFilter.get(payload.field), enable: true });\n break;\n case FilterActionType.DISABLE_FILTER:\n newFilter.set(payload.field, { ...newFilter.get(payload.field), enable: false });\n break;\n case FilterActionType.CLEAR_ALL_FILTERS:\n newFilter.clear();\n break;\n case FilterActionType.APPLY_FILTERS:\n newFilter.set(payload.field, { ...newFilter.get(payload.field), ...payload, enable: true });\n break;\n }\n\n return { ...state, filters: newFilter };\n }\n\n private applyFilters() {\n this.engine.applyFilter(this.state, this.table);\n }\n\n private shouldApplyFilter(action: FilterAction) {\n const shouldApplyActions = [\n FilterActionType.REMOVE_FILTER,\n FilterActionType.ENABLE_FILTER,\n FilterActionType.DISABLE_FILTER,\n FilterActionType.CLEAR_ALL_FILTERS,\n FilterActionType.APPLY_FILTERS\n ];\n return shouldApplyActions.includes(action.type);\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/filter/filter-state-manager.ts"],"names":[],"mappings":";;;AAEA,mCAA2C;AAM3C,MAAa,kBAAkB;IAO7B,YAAY,KAA6B,EAAE,MAAoB;QAJvD,cAAS,GAA0B,EAAE,CAAC;QAK5C,IAAI,CAAC,KAAK,GAAG;YACX,OAAO,EAAE,IAAI,GAAG,EAAE;SACnB,CAAC;QACF,IAAI,CAAC,MAAM,GAAG,MA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KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IAClD,CAAC;IAEO,iBAAiB,CAAC,MAAoB;QAC5C,MAAM,kBAAkB,GAAG;YACzB,wBAAgB,CAAC,aAAa;YAC9B,wBAAgB,CAAC,aAAa;YAC9B,wBAAgB,CAAC,cAAc;YAC/B,wBAAgB,CAAC,iBAAiB;YAClC,wBAAgB,CAAC,aAAa;SAC/B,CAAC;QACF,OAAO,kBAAkB,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC;CACF;AA/HD,gDA+HC","file":"filter-state-manager.js","sourcesContent":["import type { ListTable, PivotTable } from '@visactor/vtable';\nimport type { FilterState, FilterAction, FilterConfig, FilterListener } from './types';\nimport { FilterActionType } from './types';\nimport type { FilterEngine } from './filter-engine';\n\n/**\n * 筛选状态管理器,用于管理筛选状态\n */\nexport class FilterStateManager {\n private state: FilterState;\n private engine: FilterEngine;\n private listeners: Array<FilterListener> = [];\n\n private table: ListTable | PivotTable;\n\n constructor(table: ListTable | PivotTable, engine: FilterEngine) {\n this.state = {\n filters: new Map()\n };\n this.engine = engine;\n this.table = table;\n }\n\n getFilterState(fieldId?: string | number): FilterConfig {\n return this.state.filters.get(fieldId);\n }\n\n /**\n * 获取所有激活的筛选字段\n */\n getActiveFilterFields(): (string | number)[] {\n const activeFields: (string | number)[] = [];\n this.state.filters.forEach((config, field) => {\n if (config.enable) {\n activeFields.push(field);\n }\n });\n return activeFields;\n }\n\n /**\n * 获取所有筛选状态\n */\n getAllFilterStates(): FilterState {\n return this.state;\n }\n\n /**\n * 公共方法:重新应用当前所有激活的筛选状态\n * 用于在表格配置更新后恢复筛选显示\n */\n reapplyCurrentFilters(): void {\n const activeFields = this.getActiveFilterFields();\n if (activeFields.length > 0) {\n this.applyFilters();\n }\n }\n\n dispatch(action: FilterAction) {\n this.state = this.reduce(this.state, action);\n if (this.shouldApplyFilter(action)) {\n this.applyFilters();\n }\n this.notifyListeners(action);\n }\n\n subscribe(listener: FilterListener): () => void {\n this.listeners.push(listener);\n return () => {\n this.listeners = this.listeners.filter(l => l !== listener);\n };\n }\n\n private notifyListeners(action: FilterAction): void {\n this.listeners.forEach(listener => listener(this.state, action));\n }\n\n private reduce(state: FilterState, action: FilterAction): FilterState {\n const { type, payload } = action;\n const newFilter = new Map(state.filters);\n switch (type) {\n case FilterActionType.ADD_FILTER:\n if (payload.shouldKeepUnrelatedState) {\n newFilter.set(payload.field, { ...newFilter.get(payload.field), ...payload });\n } else {\n newFilter.set(payload.field, payload);\n }\n break;\n case FilterActionType.REMOVE_FILTER:\n if (payload.shouldKeepUnrelatedState && payload.type === 'byValue') {\n delete newFilter.get(payload.field).values;\n newFilter.set(payload.field, { ...newFilter.get(payload.field), enable: false });\n } else if (payload.shouldKeepUnrelatedState && payload.type === 'byCondition') {\n delete newFilter.get(payload.field).condition;\n delete newFilter.get(payload.field).operator;\n newFilter.set(payload.field, { ...newFilter.get(payload.field), enable: false });\n } else {\n newFilter.delete(payload.field);\n }\n\n break;\n case FilterActionType.UPDATE_FILTER:\n newFilter.set(payload.field, { ...newFilter.get(payload.field), ...payload });\n break;\n case FilterActionType.ENABLE_FILTER:\n newFilter.set(payload.field, { ...newFilter.get(payload.field), enable: true });\n break;\n case FilterActionType.DISABLE_FILTER:\n newFilter.set(payload.field, { ...newFilter.get(payload.field), enable: false });\n break;\n case FilterActionType.CLEAR_ALL_FILTERS:\n newFilter.clear();\n break;\n case FilterActionType.APPLY_FILTERS:\n newFilter.set(payload.field, { ...newFilter.get(payload.field), ...payload, enable: true });\n break;\n }\n\n return { ...state, filters: newFilter };\n }\n\n private applyFilters() {\n this.engine.applyFilter(this.state, this.table);\n }\n\n private shouldApplyFilter(action: FilterAction) {\n const shouldApplyActions = [\n FilterActionType.REMOVE_FILTER,\n FilterActionType.ENABLE_FILTER,\n FilterActionType.DISABLE_FILTER,\n FilterActionType.CLEAR_ALL_FILTERS,\n FilterActionType.APPLY_FILTERS\n ];\n return shouldApplyActions.includes(action.type);\n }\n}\n"]}
@@ -1,11 +1,12 @@
1
- import type { ListTable, PivotTable } from '@visactor/vtable';
1
+ import { type ListTable, type PivotTable } from '@visactor/vtable';
2
2
  import type { FilterStateManager } from './filter-state-manager';
3
3
  import { ValueFilter } from './value-filter';
4
4
  import { ConditionFilter } from './condition-filter';
5
- import type { FilterMode } from './types';
5
+ import type { FilterMode, FilterOptions, FilterStyles } from './types';
6
6
  export declare class FilterToolbar {
7
7
  table: ListTable | PivotTable;
8
8
  filterStateManager: FilterStateManager;
9
+ pluginOptions: FilterOptions;
9
10
  valueFilter: ValueFilter | null;
10
11
  conditionFilter: ConditionFilter | null;
11
12
  activeTab: 'byValue' | 'byCondition';
@@ -13,23 +14,27 @@ export declare class FilterToolbar {
13
14
  selectedField: string | number | null;
14
15
  filterModes: FilterMode[];
15
16
  private filterMenu;
17
+ private filterTabsContainer;
16
18
  private filterMenuWidth;
17
19
  private currentCol?;
18
20
  private currentRow?;
19
21
  private filterTabByValue;
20
22
  private filterTabByCondition;
23
+ private footerContainer;
21
24
  private clearFilterOptionLink;
22
25
  private cancelFilterButton;
23
26
  private applyFilterButton;
24
- constructor(table: ListTable | PivotTable, filterStateManager: FilterStateManager);
27
+ constructor(table: ListTable | PivotTable, filterStateManager: FilterStateManager, pluginOptions: FilterOptions);
25
28
  private onTabSwitch;
26
29
  private updateSelectedField;
27
30
  private applyFilter;
28
31
  private clearFilter;
29
32
  private updateClearFilterButtonState;
30
33
  render(container: HTMLElement): void;
34
+ updateStyles(styles: FilterStyles): void;
31
35
  attachEventListeners(): void;
32
36
  adjustMenuPosition(col?: number | null, row?: number | null, providedLeft?: number | null, providedTop?: number | null): void;
33
37
  show(col: number, row: number, filterModes: FilterMode[]): void;
34
- hide(): void;
38
+ hide: (currentCol?: number, currentRow?: number) => void;
39
+ destroy(): void;
35
40
  }
@@ -4,15 +4,19 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  }), exports.FilterToolbar = void 0;
6
6
 
7
- const value_filter_1 = require("./value-filter"), condition_filter_1 = require("./condition-filter"), styles_1 = require("./styles");
7
+ const vtable_1 = require("@visactor/vtable"), value_filter_1 = require("./value-filter"), condition_filter_1 = require("./condition-filter"), styles_1 = require("./styles");
8
8
 
9
9
  class FilterToolbar {
10
- constructor(table, filterStateManager) {
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.table = table,
13
- this.filterStateManager = filterStateManager, this.valueFilter = new value_filter_1.ValueFilter(this.table, this.filterStateManager),
14
- this.conditionFilter = new condition_filter_1.ConditionFilter(this.table, this.filterStateManager),
15
- this.filterMenuWidth = 300, this.filterStateManager.subscribe((state => {
12
+ this.isVisible = !1, this.selectedField = null, this.filterModes = [], this.hide = (currentCol, currentRow) => {
13
+ this.filterMenu.style.display = "none", this.isVisible = !1, this.table.fireListeners(vtable_1.TABLE_EVENT_TYPE.FILTER_MENU_HIDE, {
14
+ col: null != currentCol ? currentCol : this.currentCol,
15
+ row: null != currentRow ? currentRow : this.currentRow
16
+ });
17
+ }, this.table = table, this.filterStateManager = filterStateManager, this.valueFilter = new value_filter_1.ValueFilter(this.table, this.filterStateManager, pluginOptions),
18
+ this.conditionFilter = new condition_filter_1.ConditionFilter(this.table, this.filterStateManager, pluginOptions, this.hide),
19
+ this.pluginOptions = pluginOptions, this.filterMenuWidth = 300, this.filterStateManager.subscribe((state => {
16
20
  this.isVisible && null !== this.selectedField && this.updateClearFilterButtonState(this.selectedField);
17
21
  }));
18
22
  }
@@ -42,29 +46,40 @@ class FilterToolbar {
42
46
  this.clearFilterOptionLink.style.cursor = hasActiveFilter ? "pointer" : "not-allowed";
43
47
  }
44
48
  render(container) {
45
- this.filterMenu = document.createElement("div"), (0, styles_1.applyStyles)(this.filterMenu, styles_1.filterStyles.filterMenu),
46
- this.filterMenu.style.width = `${this.filterMenuWidth}px`;
47
- const filterTabsContainer = document.createElement("div");
48
- (0, styles_1.applyStyles)(filterTabsContainer, styles_1.filterStyles.tabsContainer),
49
+ const filterStyles = this.pluginOptions.styles || {};
50
+ this.filterMenu = document.createElement("div"), this.filterMenu.classList.add("vtable-filter-menu"),
51
+ (0, styles_1.applyStyles)(this.filterMenu, filterStyles.filterMenu), this.filterMenu.style.width = `${this.filterMenuWidth}px`,
52
+ this.filterTabsContainer = document.createElement("div"), (0, styles_1.applyStyles)(this.filterTabsContainer, filterStyles.tabsContainer),
49
53
  this.filterTabByValue = document.createElement("button"), this.filterTabByValue.innerText = "按值筛选",
50
- (0, styles_1.applyStyles)(this.filterTabByValue, styles_1.filterStyles.tabStyle(!0)),
51
- this.filterTabByCondition = document.createElement("button"), this.filterTabByCondition.innerText = "按条件筛选",
52
- (0, styles_1.applyStyles)(this.filterTabByCondition, styles_1.filterStyles.tabStyle(!1)),
53
- filterTabsContainer.append(this.filterTabByValue, this.filterTabByCondition);
54
- const footerContainer = document.createElement("div");
55
- (0, styles_1.applyStyles)(footerContainer, styles_1.filterStyles.footerContainer),
54
+ (0, styles_1.applyStyles)(this.filterTabByValue, filterStyles.tabStyle(!0)), this.filterTabByCondition = document.createElement("button"),
55
+ this.filterTabByCondition.innerText = "按条件筛选", (0, styles_1.applyStyles)(this.filterTabByCondition, filterStyles.tabStyle(!1)),
56
+ this.filterTabsContainer.append(this.filterTabByValue, this.filterTabByCondition),
57
+ this.footerContainer = document.createElement("div"), (0, styles_1.applyStyles)(this.footerContainer, filterStyles.footerContainer),
56
58
  this.clearFilterOptionLink = document.createElement("a"), this.clearFilterOptionLink.href = "#",
57
- this.clearFilterOptionLink.innerText = "清除筛选", (0, styles_1.applyStyles)(this.clearFilterOptionLink, styles_1.filterStyles.clearLink);
59
+ this.clearFilterOptionLink.innerText = "清除筛选", (0, styles_1.applyStyles)(this.clearFilterOptionLink, filterStyles.clearLink);
58
60
  const footerButtons = document.createElement("div");
59
61
  this.cancelFilterButton = document.createElement("button"), this.cancelFilterButton.innerText = "取消",
60
- (0, styles_1.applyStyles)(this.cancelFilterButton, styles_1.filterStyles.footerButton(!1)),
62
+ (0, styles_1.applyStyles)(this.cancelFilterButton, filterStyles.footerButton(!1)),
61
63
  this.applyFilterButton = document.createElement("button"), this.applyFilterButton.innerText = "确认",
62
- (0, styles_1.applyStyles)(this.applyFilterButton, styles_1.filterStyles.footerButton(!0)),
63
- footerButtons.append(this.cancelFilterButton, this.applyFilterButton), footerContainer.append(this.clearFilterOptionLink, footerButtons),
64
- this.filterMenu.append(filterTabsContainer), this.valueFilter.render(this.filterMenu),
65
- this.conditionFilter.render(this.filterMenu), this.filterMenu.append(footerContainer),
64
+ (0, styles_1.applyStyles)(this.applyFilterButton, filterStyles.footerButton(!0)),
65
+ footerButtons.append(this.cancelFilterButton, this.applyFilterButton), this.footerContainer.append(this.clearFilterOptionLink, footerButtons),
66
+ this.filterMenu.append(this.filterTabsContainer), this.valueFilter.render(this.filterMenu),
67
+ this.conditionFilter.render(this.filterMenu), this.filterMenu.append(this.footerContainer),
66
68
  container.appendChild(this.filterMenu), this.attachEventListeners();
67
69
  }
70
+ updateStyles(styles) {
71
+ var _a;
72
+ const realDisplay = (null !== (_a = this.filterMenu.style.display) && void 0 !== _a ? _a : styles.filterMenu.display) || "none";
73
+ (0, styles_1.applyStyles)(this.filterMenu, Object.assign(Object.assign({}, styles.filterMenu), {
74
+ display: realDisplay
75
+ })), (0, styles_1.applyStyles)(this.filterTabsContainer, styles.tabsContainer),
76
+ (0, styles_1.applyStyles)(this.filterTabByValue, styles.tabStyle(!0)), (0, styles_1.applyStyles)(this.footerContainer, styles.footerContainer),
77
+ (0, styles_1.applyStyles)(this.clearFilterOptionLink, styles.clearLink), (0, styles_1.applyStyles)(this.cancelFilterButton, styles.footerButton(!1)),
78
+ (0, styles_1.applyStyles)(this.applyFilterButton, styles.footerButton(!0)), this.valueFilter.updateStyles(styles),
79
+ this.conditionFilter.updateStyles(styles);
80
+ const currentFilter = this.filterStateManager.getFilterState(this.selectedField);
81
+ currentFilter && "byCondition" === currentFilter.type ? this.onTabSwitch("byCondition") : this.onTabSwitch("byValue");
82
+ }
68
83
  attachEventListeners() {
69
84
  this.filterTabByValue.addEventListener("click", (() => {
70
85
  this.onTabSwitch("byValue");
@@ -87,9 +102,10 @@ class FilterToolbar {
87
102
  if ("number" != typeof effectiveCol || "number" != typeof effectiveRow) return;
88
103
  this.currentCol = effectiveCol, this.currentRow = effectiveRow;
89
104
  let left = 0, top = 0;
90
- const canvasBounds = this.table.canvas.getBoundingClientRect(), cell = this.table.getCellRelativeRect(effectiveCol, effectiveRow);
105
+ const canvasBounds = this.table.canvas.getBoundingClientRect(), cell = this.table.getCellRelativeRect(effectiveCol, effectiveRow), filterMenuWidth = this.filterMenuWidth;
91
106
  cell.right < this.filterMenuWidth ? (left = cell.left + canvasBounds.left, top = cell.bottom + canvasBounds.top) : (left = cell.right + canvasBounds.left - this.filterMenuWidth,
92
- top = cell.bottom + canvasBounds.top), this.filterMenu.style.display = this.isVisible ? "block" : "none",
107
+ top = cell.bottom + canvasBounds.top), left = Math.max(0, Math.min(window.innerWidth - filterMenuWidth, left)),
108
+ top = Math.max(0, Math.min(window.innerHeight - 380, top)), this.filterMenu.style.display = this.isVisible ? "block" : "none",
93
109
  this.filterMenu.style.left = `${left}px`, this.filterMenu.style.top = `${top}px`;
94
110
  }
95
111
  show(col, row, filterModes) {
@@ -101,11 +117,14 @@ class FilterToolbar {
101
117
  const currentFilter = this.filterStateManager.getFilterState(field);
102
118
  currentFilter && "byCondition" === currentFilter.type ? this.onTabSwitch("byCondition") : this.onTabSwitch("byValue"),
103
119
  this.updateClearFilterButtonState(field), setTimeout((() => {
104
- this.isVisible = !0;
120
+ this.isVisible = !0, this.table.fireListeners(vtable_1.TABLE_EVENT_TYPE.FILTER_MENU_SHOW, {
121
+ col: col,
122
+ row: row
123
+ });
105
124
  }), 0);
106
125
  }
107
- hide() {
108
- this.filterMenu.style.display = "none", this.isVisible = !1;
126
+ destroy() {
127
+ this.valueFilter.destroy(), this.filterMenu.remove();
109
128
  }
110
129
  }
111
130
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/filter/filter-toolbar.ts"],"names":[],"mappings":";;;AAEA,iDAA6C;AAC7C,yDAAqD;AACrD,qCAAqD;AAMrD,MAAa,aAAa;IAoBxB,YAAY,KAA6B,EAAE,kBAAsC;QAjBjF,gBAAW,GAAuB,IAAI,CAAC;QACvC,oBAAe,GAA2B,IAAI,CAAC;QAC/C,cAAS,GAA8B,SAAS,CAAC;QACjD,cAAS,GAAY,KAAK,CAAC;QAC3B,kBAAa,GAA2B,IAAI,CAAC;QAC7C,gBAAW,GAAiB,EAAE,CAAC;QAa7B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;QAC7C,IAAI,CAAC,WAAW,GAAG,IAAI,0BAAW,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;QACxE,IAAI,CAAC,eAAe,GAAG,IAAI,kCAAe,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAEhF,IAAI,CAAC,eAAe,GAAG,GAAG,CAAC;QAG3B,IAAI,CAAC,kBAAkB,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;YACxC,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,aAAa,KAAK,IAAI,EAAE;gBACjD,IAAI,CAAC,4BAA4B,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;aACvD;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,WAAW,CAAC,GAA8B;QAChD,IAAI,CAAC,SAAS,GAAG,GAAG,CAAC;QACrB,IAAI,GAAG,KAAK,SAAS,EAAE;YACrB,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;YACxB,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;SAC7B;aAAM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type { FilterStateManager } from './filter-state-manager';\nimport { ValueFilter } from './value-filter';\nimport { ConditionFilter } from './condition-filter';\nimport { applyStyles, filterStyles } from './styles';\nimport type { FilterMode } from './types';\n\n/**\n * 筛选工具栏,管理按值和按条件筛选组件\n */\nexport class FilterToolbar {\n table: ListTable | PivotTable;\n filterStateManager: FilterStateManager;\n valueFilter: ValueFilter | null = null;\n conditionFilter: ConditionFilter | null = null;\n activeTab: 'byValue' | 'byCondition' = 'byValue';\n isVisible: boolean = false;\n selectedField: string | number | null = null;\n filterModes: FilterMode[] = [];\n\n private filterMenu: HTMLElement;\n private filterMenuWidth: number;\n private currentCol?: number | null;\n private currentRow?: number | null;\n private filterTabByValue: HTMLButtonElement;\n private filterTabByCondition: HTMLButtonElement;\n private clearFilterOptionLink: HTMLAnchorElement;\n private cancelFilterButton: HTMLButtonElement;\n private applyFilterButton: HTMLButtonElement;\n\n constructor(table: ListTable | PivotTable, filterStateManager: FilterStateManager) {\n this.table = table;\n this.filterStateManager = filterStateManager;\n this.valueFilter = new ValueFilter(this.table, this.filterStateManager);\n this.conditionFilter = new ConditionFilter(this.table, this.filterStateManager);\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 // === 主容器 ===\n this.filterMenu = document.createElement('div');\n applyStyles(this.filterMenu, filterStyles.filterMenu);\n this.filterMenu.style.width = `${this.filterMenuWidth}px`;\n\n // === 筛选 Tab ===\n const filterTabsContainer = document.createElement('div');\n applyStyles(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 filterTabsContainer.append(this.filterTabByValue, this.filterTabByCondition);\n\n // === 页脚(清除、取消、确定 筛选按钮) ===\n const footerContainer = document.createElement('div');\n applyStyles(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 footerContainer.append(this.clearFilterOptionLink, footerButtons);\n\n // --- 筛选器头部 Tab ---\n this.filterMenu.append(filterTabsContainer);\n\n // --- 筛选器内容 ---\n this.valueFilter.render(this.filterMenu);\n this.conditionFilter.render(this.filterMenu);\n\n // --- 筛选器页脚 ---\n this.filterMenu.append(footerContainer);\n\n container.appendChild(this.filterMenu); // 将筛选器添加到 DOM 中\n this.attachEventListeners();\n }\n\n attachEventListeners() {\n // 按值筛选/按条件筛选的事件监听\n this.filterTabByValue.addEventListener('click', () => {\n this.onTabSwitch('byValue');\n });\n\n this.filterTabByCondition.addEventListener('click', () => {\n this.onTabSwitch('byCondition');\n });\n\n this.cancelFilterButton.addEventListener('click', () => this.hide());\n\n this.clearFilterOptionLink.addEventListener('click', e => {\n e.preventDefault();\n this.clearFilter(this.selectedField);\n });\n\n this.applyFilterButton.addEventListener('click', () => {\n this.applyFilter(this.selectedField);\n });\n\n // 点击空白处整个筛选菜单可消失\n document.addEventListener('click', () => {\n if (this.isVisible) {\n this.hide();\n }\n });\n\n this.filterMenu.addEventListener('click', e => {\n e.stopPropagation();\n });\n }\n\n adjustMenuPosition(\n col?: number | null,\n row?: number | null,\n providedLeft?: number | null,\n providedTop?: number | null\n ) {\n if (typeof providedLeft === 'number' && typeof providedTop === 'number') {\n this.filterMenu.style.display = this.isVisible ? 'block' : 'none';\n this.filterMenu.style.left = `${providedLeft}px`;\n this.filterMenu.style.top = `${providedTop}px`;\n return;\n }\n\n // 明晰的参数 > 记忆的数字\n const effectiveCol = typeof col === 'number' ? col : this.currentCol;\n const effectiveRow = typeof row === 'number' ? row : this.currentRow;\n\n if (typeof effectiveCol !== 'number' || typeof effectiveRow !== 'number') {\n return;\n }\n\n this.currentCol = effectiveCol;\n this.currentRow = effectiveRow;\n\n let left: number = 0;\n let top: number = 0;\n\n const canvasBounds = this.table.canvas.getBoundingClientRect();\n const cell = this.table.getCellRelativeRect(effectiveCol, effectiveRow);\n\n if (cell.right < this.filterMenuWidth) {\n // 无法把筛选菜单完整地显示在左侧,那么显示在右侧\n left = cell.left + canvasBounds.left;\n top = cell.bottom + canvasBounds.top;\n } else {\n // 筛选菜单默认显示在左侧\n left = cell.right + canvasBounds.left - this.filterMenuWidth;\n top = cell.bottom + canvasBounds.top;\n }\n\n this.filterMenu.style.display = this.isVisible ? 'block' : 'none';\n this.filterMenu.style.left = `${left}px`;\n this.filterMenu.style.top = `${top}px`;\n }\n\n show(col: number, row: number, filterModes: FilterMode[]): void {\n this.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 }, 0);\n }\n\n hide(): void {\n this.filterMenu.style.display = 'none';\n this.isVisible = false;\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/filter/filter-toolbar.ts"],"names":[],"m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AAC;YACjD,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;SAC7B;QAED,IAAI,CAAC,kBAAkB,CAAC,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,yBAAgB,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;AA3TD,sCA2TC","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"]}
@@ -14,7 +14,9 @@ export declare class FilterPlugin implements pluginsDefinition.IVTablePlugin {
14
14
  filterStateManager: FilterStateManager;
15
15
  filterToolbar: FilterToolbar;
16
16
  constructor(pluginOptions: FilterOptions);
17
+ initFilterPlugin(eventArgs: any): void;
17
18
  run(...args: any[]): void;
19
+ updatePluginOptions(pluginOptions: FilterOptions): void;
18
20
  update(): void;
19
21
  private handleOptionUpdate;
20
22
  private reapplyActiveFilters;
@@ -4,11 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: !0
5
5
  }), exports.FilterPlugin = void 0;
6
6
 
7
- const vtable_1 = require("@visactor/vtable"), filter_engine_1 = require("./filter-engine"), filter_state_manager_1 = require("./filter-state-manager"), filter_toolbar_1 = require("./filter-toolbar"), types_1 = require("./types");
7
+ const vtable_1 = require("@visactor/vtable"), filter_engine_1 = require("./filter-engine"), filter_state_manager_1 = require("./filter-state-manager"), filter_toolbar_1 = require("./filter-toolbar"), types_1 = require("./types"), lodash_1 = require("lodash"), styles_1 = require("./styles"), constant_1 = require("./constant");
8
8
 
9
9
  class FilterPlugin {
10
10
  constructor(pluginOptions) {
11
- var _a, _b, _c;
11
+ var _a, _b, _c, _d, _e;
12
12
  this.id = "filter", this.name = "Filter", this.runTime = [ vtable_1.TABLE_EVENT_TYPE.BEFORE_INIT, vtable_1.TABLE_EVENT_TYPE.BEFORE_UPDATE_OPTION, vtable_1.TABLE_EVENT_TYPE.ICON_CLICK, vtable_1.TABLE_EVENT_TYPE.SCROLL ],
13
13
  this.id = null !== (_a = null == pluginOptions ? void 0 : pluginOptions.id) && void 0 !== _a ? _a : this.id,
14
14
  this.pluginOptions = pluginOptions, this.pluginOptions.filterIcon = null !== (_b = pluginOptions.filterIcon) && void 0 !== _b ? _b : {
@@ -27,27 +27,39 @@ class FilterPlugin {
27
27
  positionType: vtable_1.TYPES.IconPosition.right,
28
28
  cursor: "pointer",
29
29
  svg: '<svg t="1752821771292" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="11926" width="200" height="200"><path d="M971.614323 53.05548L655.77935 412.054233C635.196622 435.434613 623.906096 465.509377 623.906096 496.583302v495.384307c0 28.975686-35.570152 43.063864-55.353551 21.781723l-159.865852-171.256294c-5.495389-5.895053-8.59279-13.688514-8.592789-21.781722V496.583302c0-31.073925-11.290526-61.148688-31.873254-84.429153L52.385677 53.05548C34.200936 32.472751 48.888611 0 76.365554 0h871.268892c27.476943 0 42.164618 32.472751 23.979877 53.05548z" fill="#416eff" p-id="11927"></path></svg>'
30
- }, this.pluginOptions.filterModes && this.pluginOptions.filterModes.length || (this.pluginOptions.filterModes = [ "byValue", "byCondition" ]);
30
+ }, this.pluginOptions.filterModes && this.pluginOptions.filterModes.length || (this.pluginOptions.filterModes = [ "byValue", "byCondition" ]),
31
+ this.pluginOptions.styles = (0, lodash_1.merge)(styles_1.filterStyles, null !== (_d = this.pluginOptions.styles) && void 0 !== _d ? _d : {}),
32
+ this.pluginOptions.conditionCategories = null !== (_e = pluginOptions.conditionCategories) && void 0 !== _e ? _e : constant_1.categories;
31
33
  }
32
- run(...args) {
33
- var _a, _b, _c;
34
- const eventArgs = args[0], runtime = args[1], table = args[2];
35
- if (this.table = table, runtime === vtable_1.TABLE_EVENT_TYPE.BEFORE_INIT) this.filterEngine = new filter_engine_1.FilterEngine,
36
- this.filterStateManager = new filter_state_manager_1.FilterStateManager(this.table, this.filterEngine),
37
- this.filterToolbar = new filter_toolbar_1.FilterToolbar(this.table, this.filterStateManager),
34
+ initFilterPlugin(eventArgs) {
35
+ this.filterEngine = new filter_engine_1.FilterEngine(this.pluginOptions), this.filterStateManager = new filter_state_manager_1.FilterStateManager(this.table, this.filterEngine),
36
+ this.filterToolbar = new filter_toolbar_1.FilterToolbar(this.table, this.filterStateManager, this.pluginOptions),
38
37
  this.columns = eventArgs.options.columns, this.filterToolbar.render(document.body),
39
38
  this.updateFilterIcons(this.columns), this.filterStateManager.subscribe(((_, action) => {
40
39
  (null == action ? void 0 : action.type) !== types_1.FilterActionType.ADD_FILTER && (this.updateFilterIcons(this.columns),
41
40
  this.table.updateColumns(this.columns, {
42
41
  clearRowHeightCache: !1
43
42
  }));
44
- })); else if (runtime === vtable_1.TABLE_EVENT_TYPE.BEFORE_UPDATE_OPTION) this.pluginOptions = Object.assign(Object.assign({}, this.pluginOptions), eventArgs.options.plugins.find((plugin => plugin.id === this.id)).pluginOptions),
43
+ }));
44
+ }
45
+ run(...args) {
46
+ var _a, _b, _c, _d, _e;
47
+ const eventArgs = args[0], runtime = args[1], table = args[2];
48
+ if (this.table = table, runtime === vtable_1.TABLE_EVENT_TYPE.BEFORE_INIT) this.initFilterPlugin(eventArgs); else if (runtime === vtable_1.TABLE_EVENT_TYPE.BEFORE_UPDATE_OPTION) this.filterEngine && this.filterStateManager && this.filterToolbar || this.initFilterPlugin(eventArgs),
49
+ this.pluginOptions = Object.assign(Object.assign({}, this.pluginOptions), null === (_b = null === (_a = eventArgs.options.plugins) || void 0 === _a ? void 0 : _a.find((plugin => plugin.id === this.id))) || void 0 === _b ? void 0 : _b.pluginOptions),
45
50
  this.columns = eventArgs.options.columns, this.handleOptionUpdate(eventArgs.options); else if (runtime === vtable_1.TABLE_EVENT_TYPE.ICON_CLICK && "filter-icon" === eventArgs.name || "filtering-icon" === eventArgs.name) {
46
- if (3 === (null === (_a = eventArgs.event) || void 0 === _a ? void 0 : _a.which) || 2 === (null === (_b = eventArgs.event) || void 0 === _b ? void 0 : _b.button) || 2 == (2 & (null === (_c = eventArgs.event) || void 0 === _c ? void 0 : _c.buttons))) return;
51
+ if (3 === (null === (_c = eventArgs.event) || void 0 === _c ? void 0 : _c.which) || 2 === (null === (_d = eventArgs.event) || void 0 === _d ? void 0 : _d.button) || 2 == (2 & (null === (_e = eventArgs.event) || void 0 === _e ? void 0 : _e.buttons))) return;
47
52
  const col = eventArgs.col, row = eventArgs.row;
48
- this.filterToolbar.isVisible ? this.filterToolbar.hide() : this.filterToolbar.show(col, row, this.pluginOptions.filterModes);
53
+ this.filterToolbar.isVisible ? this.filterToolbar.hide(eventArgs.col, eventArgs.row) : (this.filterToolbar.show(col, row, this.pluginOptions.filterModes),
54
+ this.table.fireListeners(vtable_1.TABLE_EVENT_TYPE.FILTER_MENU_SHOW, {
55
+ col: eventArgs.col,
56
+ row: eventArgs.row
57
+ }));
49
58
  } else runtime === vtable_1.TABLE_EVENT_TYPE.SCROLL && "horizontal" === eventArgs.scrollDirection && this.filterToolbar.adjustMenuPosition();
50
59
  }
60
+ updatePluginOptions(pluginOptions) {
61
+ this.pluginOptions = (0, lodash_1.merge)(this.pluginOptions, pluginOptions), this.filterToolbar.updateStyles(this.pluginOptions.styles);
62
+ }
51
63
  update() {
52
64
  this.filterStateManager && this.reapplyActiveFilters();
53
65
  }
@@ -126,8 +138,10 @@ class FilterPlugin {
126
138
  })));
127
139
  }
128
140
  release() {
129
- this.table = null, this.filterEngine = null, this.filterStateManager = null, this.filterToolbar.valueFilter.destroy(),
130
- this.filterToolbar = null;
141
+ this.columns.forEach((column => {
142
+ column.headerIcon = void 0;
143
+ })), this.table = null, this.filterEngine = null, this.filterStateManager = null,
144
+ this.filterToolbar.destroy(), this.filterToolbar = null;
131
145
  }
132
146
  }
133
147