@visactor/vtable-plugins 1.22.7-alpha.2 → 1.22.7-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/filter/condition-filter.d.ts +2 -12
- package/cjs/filter/condition-filter.js +144 -38
- package/cjs/filter/condition-filter.js.map +1 -1
- package/cjs/filter/filter-toolbar.d.ts +4 -8
- package/cjs/filter/filter-toolbar.js +30 -43
- package/cjs/filter/filter-toolbar.js.map +1 -1
- package/cjs/filter/filter.d.ts +0 -2
- package/cjs/filter/filter.js +14 -30
- package/cjs/filter/filter.js.map +1 -1
- package/cjs/filter/types.d.ts +0 -34
- package/cjs/filter/types.js.map +1 -1
- package/cjs/filter/value-filter.d.ts +2 -11
- package/cjs/filter/value-filter.js +33 -67
- package/cjs/filter/value-filter.js.map +1 -1
- package/cjs/focus-highlight.js +1 -1
- package/cjs/focus-highlight.js.map +1 -1
- package/cjs/master-detail-plugin/config.js +1 -2
- package/cjs/master-detail-plugin/types.js +1 -1
- package/cjs/master-detail-plugin/utils.js +1 -1
- package/cjs/table-export/index.js +2 -1
- package/dist/vtable-plugins.js +126 -9727
- package/dist/vtable-plugins.min.js +3 -3
- package/es/filter/condition-filter.d.ts +2 -12
- package/es/filter/condition-filter.js +140 -36
- package/es/filter/condition-filter.js.map +1 -1
- package/es/filter/filter-toolbar.d.ts +4 -8
- package/es/filter/filter-toolbar.js +27 -44
- package/es/filter/filter-toolbar.js.map +1 -1
- package/es/filter/filter.d.ts +0 -2
- package/es/filter/filter.js +15 -37
- package/es/filter/filter.js.map +1 -1
- package/es/filter/types.d.ts +0 -34
- package/es/filter/types.js.map +1 -1
- package/es/filter/value-filter.d.ts +2 -11
- package/es/filter/value-filter.js +30 -65
- package/es/filter/value-filter.js.map +1 -1
- package/es/focus-highlight.js +1 -1
- package/es/focus-highlight.js.map +1 -1
- package/es/master-detail-plugin/config.js +1 -2
- package/es/master-detail-plugin/types.js +1 -1
- package/es/master-detail-plugin/utils.js +1 -1
- package/es/table-export/index.js +2 -1
- package/package.json +9 -9
- package/cjs/filter/constant.d.ts +0 -7
- package/cjs/filter/constant.js +0 -124
- package/cjs/filter/constant.js.map +0 -1
- package/es/filter/constant.d.ts +0 -7
- package/es/filter/constant.js +0 -120
- package/es/filter/constant.js.map +0 -1
|
@@ -1,27 +1,18 @@
|
|
|
1
1
|
import type { ListTable, PivotTable } from '@visactor/vtable';
|
|
2
2
|
import type { FilterStateManager } from './filter-state-manager';
|
|
3
|
-
import type { FilterOptions, FilterStyles, OperatorOption } from './types';
|
|
4
3
|
export declare class ConditionFilter {
|
|
5
4
|
private table;
|
|
6
5
|
private filterStateManager;
|
|
7
|
-
private pluginOptions;
|
|
8
|
-
private styles;
|
|
9
6
|
private filterByConditionPanel;
|
|
10
|
-
private conditionContainer;
|
|
11
|
-
private categoryLabel;
|
|
12
7
|
private selectedField;
|
|
13
8
|
private operatorSelect;
|
|
14
9
|
private valueInput;
|
|
15
|
-
private andLabel;
|
|
16
10
|
private valueInputMax;
|
|
17
11
|
private categorySelect;
|
|
18
|
-
private operatorLabel;
|
|
19
|
-
private rangeInputContainer;
|
|
20
|
-
private valueLabel;
|
|
21
12
|
private currentCategory;
|
|
13
|
+
private operators;
|
|
22
14
|
private categories;
|
|
23
|
-
|
|
24
|
-
constructor(table: ListTable | PivotTable, filterStateManager: FilterStateManager, pluginOptions: FilterOptions);
|
|
15
|
+
constructor(table: ListTable | PivotTable, filterStateManager: FilterStateManager);
|
|
25
16
|
setSelectedField(fieldId: string | number): void;
|
|
26
17
|
private updateOperatorOptions;
|
|
27
18
|
private handleCategoryChange;
|
|
@@ -33,7 +24,6 @@ export declare class ConditionFilter {
|
|
|
33
24
|
applyFilter(fieldId?: string | number): void;
|
|
34
25
|
clearFilter(fieldId: string | number): void;
|
|
35
26
|
render(container: HTMLElement): void;
|
|
36
|
-
updateStyles(styles: FilterStyles): void;
|
|
37
27
|
private bindEvents;
|
|
38
28
|
show(): void;
|
|
39
29
|
hide(): void;
|
|
@@ -4,14 +4,125 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.ConditionFilter = void 0;
|
|
6
6
|
|
|
7
|
-
const styles_1 = require("./styles"), types_1 = require("./types")
|
|
7
|
+
const styles_1 = require("./styles"), types_1 = require("./types");
|
|
8
8
|
|
|
9
9
|
class ConditionFilter {
|
|
10
|
-
constructor(table, filterStateManager
|
|
11
|
-
this.currentCategory = types_1.FilterOperatorCategory.ALL, this.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
constructor(table, filterStateManager) {
|
|
11
|
+
this.currentCategory = types_1.FilterOperatorCategory.ALL, this.operators = [ {
|
|
12
|
+
value: "equals",
|
|
13
|
+
label: "等于",
|
|
14
|
+
category: types_1.FilterOperatorCategory.ALL
|
|
15
|
+
}, {
|
|
16
|
+
value: "notEquals",
|
|
17
|
+
label: "不等于",
|
|
18
|
+
category: types_1.FilterOperatorCategory.ALL
|
|
19
|
+
}, {
|
|
20
|
+
value: "equals",
|
|
21
|
+
label: "等于",
|
|
22
|
+
category: types_1.FilterOperatorCategory.NUMBER
|
|
23
|
+
}, {
|
|
24
|
+
value: "notEquals",
|
|
25
|
+
label: "不等于",
|
|
26
|
+
category: types_1.FilterOperatorCategory.NUMBER
|
|
27
|
+
}, {
|
|
28
|
+
value: "greaterThan",
|
|
29
|
+
label: "大于",
|
|
30
|
+
category: types_1.FilterOperatorCategory.NUMBER
|
|
31
|
+
}, {
|
|
32
|
+
value: "lessThan",
|
|
33
|
+
label: "小于",
|
|
34
|
+
category: types_1.FilterOperatorCategory.NUMBER
|
|
35
|
+
}, {
|
|
36
|
+
value: "greaterThanOrEqual",
|
|
37
|
+
label: "大于等于",
|
|
38
|
+
category: types_1.FilterOperatorCategory.NUMBER
|
|
39
|
+
}, {
|
|
40
|
+
value: "lessThanOrEqual",
|
|
41
|
+
label: "小于等于",
|
|
42
|
+
category: types_1.FilterOperatorCategory.NUMBER
|
|
43
|
+
}, {
|
|
44
|
+
value: "between",
|
|
45
|
+
label: "介于",
|
|
46
|
+
category: types_1.FilterOperatorCategory.NUMBER
|
|
47
|
+
}, {
|
|
48
|
+
value: "notBetween",
|
|
49
|
+
label: "不介于",
|
|
50
|
+
category: types_1.FilterOperatorCategory.NUMBER
|
|
51
|
+
}, {
|
|
52
|
+
value: "equals",
|
|
53
|
+
label: "等于",
|
|
54
|
+
category: types_1.FilterOperatorCategory.TEXT
|
|
55
|
+
}, {
|
|
56
|
+
value: "notEquals",
|
|
57
|
+
label: "不等于",
|
|
58
|
+
category: types_1.FilterOperatorCategory.TEXT
|
|
59
|
+
}, {
|
|
60
|
+
value: "contains",
|
|
61
|
+
label: "包含",
|
|
62
|
+
category: types_1.FilterOperatorCategory.TEXT
|
|
63
|
+
}, {
|
|
64
|
+
value: "notContains",
|
|
65
|
+
label: "不包含",
|
|
66
|
+
category: types_1.FilterOperatorCategory.TEXT
|
|
67
|
+
}, {
|
|
68
|
+
value: "startsWith",
|
|
69
|
+
label: "开头是",
|
|
70
|
+
category: types_1.FilterOperatorCategory.TEXT
|
|
71
|
+
}, {
|
|
72
|
+
value: "notStartsWith",
|
|
73
|
+
label: "开头不是",
|
|
74
|
+
category: types_1.FilterOperatorCategory.TEXT
|
|
75
|
+
}, {
|
|
76
|
+
value: "endsWith",
|
|
77
|
+
label: "结尾是",
|
|
78
|
+
category: types_1.FilterOperatorCategory.TEXT
|
|
79
|
+
}, {
|
|
80
|
+
value: "notEndsWith",
|
|
81
|
+
label: "结尾不是",
|
|
82
|
+
category: types_1.FilterOperatorCategory.TEXT
|
|
83
|
+
}, {
|
|
84
|
+
value: "equals",
|
|
85
|
+
label: "等于",
|
|
86
|
+
category: types_1.FilterOperatorCategory.COLOR
|
|
87
|
+
}, {
|
|
88
|
+
value: "notEquals",
|
|
89
|
+
label: "不等于",
|
|
90
|
+
category: types_1.FilterOperatorCategory.COLOR
|
|
91
|
+
}, {
|
|
92
|
+
value: "isChecked",
|
|
93
|
+
label: "已选中",
|
|
94
|
+
category: types_1.FilterOperatorCategory.CHECKBOX
|
|
95
|
+
}, {
|
|
96
|
+
value: "isUnchecked",
|
|
97
|
+
label: "未选中",
|
|
98
|
+
category: types_1.FilterOperatorCategory.CHECKBOX
|
|
99
|
+
}, {
|
|
100
|
+
value: "isChecked",
|
|
101
|
+
label: "已选中",
|
|
102
|
+
category: types_1.FilterOperatorCategory.RADIO
|
|
103
|
+
}, {
|
|
104
|
+
value: "isUnchecked",
|
|
105
|
+
label: "未选中",
|
|
106
|
+
category: types_1.FilterOperatorCategory.RADIO
|
|
107
|
+
} ], this.categories = [ {
|
|
108
|
+
value: types_1.FilterOperatorCategory.ALL,
|
|
109
|
+
label: "全部"
|
|
110
|
+
}, {
|
|
111
|
+
value: types_1.FilterOperatorCategory.TEXT,
|
|
112
|
+
label: "文本"
|
|
113
|
+
}, {
|
|
114
|
+
value: types_1.FilterOperatorCategory.NUMBER,
|
|
115
|
+
label: "数值"
|
|
116
|
+
}, {
|
|
117
|
+
value: types_1.FilterOperatorCategory.COLOR,
|
|
118
|
+
label: "颜色"
|
|
119
|
+
}, {
|
|
120
|
+
value: types_1.FilterOperatorCategory.CHECKBOX,
|
|
121
|
+
label: "复选框"
|
|
122
|
+
}, {
|
|
123
|
+
value: types_1.FilterOperatorCategory.RADIO,
|
|
124
|
+
label: "单选框"
|
|
125
|
+
} ], this.table = table, this.filterStateManager = filterStateManager;
|
|
15
126
|
}
|
|
16
127
|
setSelectedField(fieldId) {
|
|
17
128
|
this.selectedField = fieldId, this.updateOperatorOptions(), this.loadCurrentFilterState();
|
|
@@ -21,7 +132,7 @@ class ConditionFilter {
|
|
|
21
132
|
let filteredOperators;
|
|
22
133
|
if (this.operatorSelect.innerHTML = "", this.currentCategory === types_1.FilterOperatorCategory.ALL) {
|
|
23
134
|
const uniqueOperators = new Map;
|
|
24
|
-
this.operators.
|
|
135
|
+
this.operators.forEach((op => {
|
|
25
136
|
uniqueOperators.has(op.value) || uniqueOperators.set(op.value, op);
|
|
26
137
|
})), filteredOperators = Array.from(uniqueOperators.values());
|
|
27
138
|
} else filteredOperators = this.operators.filter((op => op.category === this.currentCategory));
|
|
@@ -98,45 +209,40 @@ class ConditionFilter {
|
|
|
98
209
|
}), this.hide();
|
|
99
210
|
}
|
|
100
211
|
render(container) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
styles_1.applyStyles)(
|
|
106
|
-
styles_1.createElement)("select"), (0, styles_1.applyStyles)(this.categorySelect, filterStyles.operatorSelect),
|
|
212
|
+
this.filterByConditionPanel = document.createElement("div"), (0, styles_1.applyStyles)(this.filterByConditionPanel, styles_1.filterStyles.filterPanel);
|
|
213
|
+
const conditionContainer = document.createElement("div");
|
|
214
|
+
(0, styles_1.applyStyles)(conditionContainer, styles_1.filterStyles.conditionContainer);
|
|
215
|
+
const categoryLabel = (0, styles_1.createElement)("label", {}, [ "筛选类型:" ]);
|
|
216
|
+
(0, styles_1.applyStyles)(categoryLabel, styles_1.filterStyles.formLabel), this.categorySelect = (0,
|
|
217
|
+
styles_1.createElement)("select"), (0, styles_1.applyStyles)(this.categorySelect, styles_1.filterStyles.operatorSelect),
|
|
107
218
|
this.categories.forEach((category => {
|
|
108
219
|
const option = document.createElement("option");
|
|
109
220
|
option.value = category.value, option.textContent = category.label, this.categorySelect.appendChild(option);
|
|
110
|
-
}))
|
|
111
|
-
(0, styles_1.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
221
|
+
}));
|
|
222
|
+
const operatorLabel = (0, styles_1.createElement)("label", {}, [ "筛选条件:" ]);
|
|
223
|
+
(0, styles_1.applyStyles)(operatorLabel, styles_1.filterStyles.formLabel), this.operatorSelect = (0,
|
|
224
|
+
styles_1.createElement)("select"), (0, styles_1.applyStyles)(this.operatorSelect, styles_1.filterStyles.operatorSelect);
|
|
225
|
+
const valueLabel = (0, styles_1.createElement)("label", {}, [ "筛选值:" ]);
|
|
226
|
+
(0, styles_1.applyStyles)(valueLabel, styles_1.filterStyles.formLabel);
|
|
227
|
+
const rangeInputContainer = (0, styles_1.createElement)("div");
|
|
228
|
+
(0, styles_1.applyStyles)(rangeInputContainer, styles_1.filterStyles.rangeInputContainer),
|
|
115
229
|
this.valueInput = (0, styles_1.createElement)("input", {
|
|
116
230
|
type: "text",
|
|
117
231
|
placeholder: "请输入筛选值"
|
|
118
|
-
}), (0, styles_1.applyStyles)(this.valueInput, filterStyles.searchInput)
|
|
119
|
-
styles_1.createElement)("span", {}, [ "和" ])
|
|
120
|
-
|
|
232
|
+
}), (0, styles_1.applyStyles)(this.valueInput, styles_1.filterStyles.searchInput);
|
|
233
|
+
const andLabel = (0, styles_1.createElement)("span", {}, [ "和" ]);
|
|
234
|
+
(0, styles_1.applyStyles)(andLabel, styles_1.filterStyles.addLabel), andLabel.style.display = "none",
|
|
235
|
+
this.valueInputMax = (0, styles_1.createElement)("input", {
|
|
121
236
|
type: "text",
|
|
122
237
|
placeholder: "最大值"
|
|
123
|
-
}), (0, styles_1.applyStyles)(this.valueInputMax, filterStyles.searchInput),
|
|
124
|
-
this.
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
this.bindEvents();
|
|
131
|
-
}
|
|
132
|
-
updateStyles(styles) {
|
|
133
|
-
(0, styles_1.applyStyles)(this.filterByConditionPanel, styles.filterPanel), (0,
|
|
134
|
-
styles_1.applyStyles)(this.conditionContainer, styles.conditionContainer), (0, styles_1.applyStyles)(this.categoryLabel, styles.formLabel),
|
|
135
|
-
(0, styles_1.applyStyles)(this.categorySelect, styles.operatorSelect), (0, styles_1.applyStyles)(this.operatorLabel, styles.formLabel),
|
|
136
|
-
(0, styles_1.applyStyles)(this.operatorSelect, styles.operatorSelect), (0, styles_1.applyStyles)(this.valueLabel, styles.formLabel),
|
|
137
|
-
(0, styles_1.applyStyles)(this.rangeInputContainer, styles.rangeInputContainer),
|
|
138
|
-
(0, styles_1.applyStyles)(this.valueInput, styles.searchInput), (0, styles_1.applyStyles)(this.andLabel, styles.addLabel),
|
|
139
|
-
(0, styles_1.applyStyles)(this.valueInputMax, styles.searchInput);
|
|
238
|
+
}), (0, styles_1.applyStyles)(this.valueInputMax, styles_1.filterStyles.searchInput),
|
|
239
|
+
this.valueInputMax.style.display = "none", rangeInputContainer.appendChild(this.valueInput),
|
|
240
|
+
rangeInputContainer.appendChild(andLabel), rangeInputContainer.appendChild(this.valueInputMax),
|
|
241
|
+
conditionContainer.appendChild(categoryLabel), conditionContainer.appendChild(this.categorySelect),
|
|
242
|
+
conditionContainer.appendChild(operatorLabel), conditionContainer.appendChild(this.operatorSelect),
|
|
243
|
+
conditionContainer.appendChild(valueLabel), conditionContainer.appendChild(rangeInputContainer),
|
|
244
|
+
this.filterByConditionPanel.appendChild(conditionContainer), container.appendChild(this.filterByConditionPanel),
|
|
245
|
+
this.hide(), this.updateOperatorOptions(), this.bindEvents();
|
|
140
246
|
}
|
|
141
247
|
bindEvents() {
|
|
142
248
|
this.valueInput.addEventListener("keypress", (event => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/filter/condition-filter.ts"],"names":[],"mappings":";;;AAEA,qCAAoE;AAQpE,mCAAmE;AACnE,yCAAuC;AAKvC,MAAa,eAAe;IAyB1B,YAAY,KAA6B,EAAE,kBAAsC,EAAE,aAA4B;QALvG,oBAAe,GAA2B,8BAAsB,CAAC,GAAG,CAAC;QAErE,eAAU,GAAmC,EAAE,CAAC;QAC9C,cAAS,GAAqB,EAAE,CAAC;QAGzC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;QAC7C,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,aAAa,CAAC,MAAM,IAAI,EAAE,CAAC;QACzC,IAAI,CAAC,UAAU,GAAG,aAAa,CAAC,mB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IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,QAAQ,EAAE,GAAG,EAAE;YAClD,MAAM,gBAAgB,GAAG,IAAI,CAAC,cAAc,CAAC,KAAuB,CAAC;YACrE,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,kBAAiC,CAAC;YAEnE,IAAI,IAAI,CAAC,eAAe,CAAC,gBAAgB,CAAC,EAAE;gBAC1C,IAAI,CAAC,UAAU,CAAC,WAAW,GAAG,KAAK,CAAC;gBACpC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,OAAO,GAAG,cAAc,CAAC;gBAClD,QAAQ,CAAC,KAAK,CAAC,OAAO,GAAG,cAAc,CAAC;aACzC;iBAAM;gBACL,IAAI,CAAC,UAAU,CAAC,WAAW,GAAG,QAAQ,CAAC;gBACvC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;gBAC1C,QAAQ,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;aACjC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAKD,IAAI;QACF,IAAI,IAAI,CAAC,sBAAsB,EAAE;YAC/B,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC;YACpD,IAAI,CAAC,sBAAsB,EAAE,CAAC;SAC/B;IACH,CAAC;IAKD,IAAI;QACF,IAAI,IAAI,CAAC,sBAAsB,EAAE;YAC/B,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;SACpD;IACH,CAAC;CACF;AA5aD,0CA4aC","file":"condition-filter.js","sourcesContent":["import type { ListTable, PivotTable } from '@visactor/vtable';\nimport type { FilterStateManager } from './filter-state-manager';\nimport { applyStyles, filterStyles, createElement } from './styles';\nimport type {\n FilterOperator,\n FilterOperatorCategoryOption,\n FilterOptions,\n FilterStyles,\n OperatorOption\n} from './types';\nimport { FilterActionType, FilterOperatorCategory } from './types';\nimport { operators } from './constant';\n\n/**\n * 按条件筛选组件\n */\nexport class ConditionFilter {\n private table: ListTable | PivotTable;\n private filterStateManager: FilterStateManager;\n private pluginOptions: FilterOptions;\n\n private styles: Record<any, any>;\n\n private filterByConditionPanel: HTMLElement;\n private conditionContainer: HTMLElement;\n private categoryLabel: HTMLElement;\n private selectedField: string | number;\n private operatorSelect: HTMLSelectElement;\n private valueInput: HTMLInputElement;\n private andLabel: HTMLElement;\n private valueInputMax: HTMLInputElement;\n private categorySelect: HTMLSelectElement;\n private operatorLabel: HTMLElement;\n private rangeInputContainer: HTMLElement;\n private valueLabel: HTMLElement;\n\n private currentCategory: FilterOperatorCategory = FilterOperatorCategory.ALL;\n\n private categories: FilterOperatorCategoryOption[] = [];\n protected operators: OperatorOption[] = [];\n\n constructor(table: ListTable | PivotTable, filterStateManager: FilterStateManager, pluginOptions: FilterOptions) {\n this.table = table;\n this.filterStateManager = filterStateManager;\n this.pluginOptions = pluginOptions;\n this.styles = pluginOptions.styles || {};\n this.categories = pluginOptions.conditionCategories;\n this.operators = operators;\n }\n\n setSelectedField(fieldId: string | number): void {\n this.selectedField = fieldId;\n this.updateOperatorOptions();\n this.loadCurrentFilterState();\n }\n\n /**\n * 更新操作符下拉选项\n */\n private updateOperatorOptions(): void {\n if (!this.operatorSelect) {\n return;\n }\n this.operatorSelect.innerHTML = '';\n let filteredOperators: OperatorOption[];\n\n if (this.currentCategory === FilterOperatorCategory.ALL) {\n // 当选择\"全部\"时,收集所有配置的分类中, 不重复的操作符\n const uniqueOperators = new Map<string, OperatorOption>();\n this.operators\n .filter(op => this.categories.map(cat => cat.value).includes(op.category))\n .forEach(op => {\n if (!uniqueOperators.has(op.value)) {\n uniqueOperators.set(op.value, op);\n }\n });\n filteredOperators = Array.from(uniqueOperators.values());\n } else {\n // 其他类别正常筛选\n filteredOperators = this.operators.filter(op => op.category === this.currentCategory);\n }\n\n // 添加新选项\n filteredOperators.forEach(op => {\n const option = document.createElement('option');\n option.value = op.value;\n option.textContent = op.label;\n this.operatorSelect.appendChild(option);\n });\n }\n\n private handleCategoryChange(): void {\n if (!this.categorySelect) {\n return;\n }\n\n this.currentCategory = this.categorySelect.value as FilterOperatorCategory;\n this.updateOperatorOptions();\n\n // 分类切换后也需要同步UI状态\n this.syncUIState();\n }\n\n /**\n * 加载当前的筛选状态\n */\n private loadCurrentFilterState(): void {\n const filter = this.filterStateManager.getFilterState(this.selectedField);\n\n if (filter && filter.type === 'byCondition') {\n // 设置操作符\n if (filter.operator && this.operatorSelect) {\n this.operatorSelect.value = filter.operator;\n }\n\n // 设置条件值\n if (filter.condition !== undefined && this.valueInput) {\n if (Array.isArray(filter.condition)) {\n this.valueInput.value = String(filter.condition[0]);\n if (this.valueInputMax) {\n this.valueInputMax.value = String(filter.condition[1]);\n }\n } else {\n this.valueInput.value = String(filter.condition);\n if (this.valueInputMax) {\n this.valueInputMax.value = '';\n }\n }\n }\n\n // 同步UI状态:根据当前操作符显示/隐藏范围输入框\n this.syncUIState();\n } else {\n // 重置为默认值\n this.reset();\n }\n }\n\n /**\n * 重置筛选条件到默认状态\n */\n reset(): void {\n // 重置操作符选择\n if (this.operatorSelect) {\n this.operatorSelect.selectedIndex = 0;\n }\n\n // 重置所有输入框\n if (this.valueInput) {\n this.valueInput.value = '';\n this.valueInput.placeholder = '请输入筛选值';\n }\n\n if (this.valueInputMax) {\n this.valueInputMax.value = '';\n }\n\n // 重置分类选择\n this.currentCategory = FilterOperatorCategory.ALL;\n if (this.categorySelect) {\n this.categorySelect.value = FilterOperatorCategory.ALL;\n }\n\n // 更新操作符选项\n this.updateOperatorOptions();\n\n // 同步UI状态\n this.syncUIState();\n }\n\n /**\n * 同步UI状态:根据当前选择的操作符调整UI显示\n */\n private syncUIState(): void {\n if (!this.operatorSelect || !this.valueInput) {\n return;\n }\n\n const selectedOperator = this.operatorSelect.value as FilterOperator;\n const andLabel = this.valueInput.nextElementSibling as HTMLElement;\n\n if (this.isRangeOperator(selectedOperator)) {\n // 显示范围输入相关UI\n this.valueInput.placeholder = '最小值';\n if (this.valueInputMax) {\n this.valueInputMax.style.display = 'inline-block';\n }\n if (andLabel) {\n andLabel.style.display = 'inline-block';\n }\n } else {\n // 隐藏范围输入相关UI\n this.valueInput.placeholder = '请输入筛选值';\n if (this.valueInputMax) {\n this.valueInputMax.style.display = 'none';\n }\n if (andLabel) {\n andLabel.style.display = 'none';\n }\n }\n }\n\n private isBooleanOperator(operator: FilterOperator): boolean {\n const booleanCondition = ['isChecked', 'isUnchecked'];\n return booleanCondition.includes(operator);\n }\n\n private isRangeOperator(operator: FilterOperator): boolean {\n return operator === 'between' || operator === 'notBetween';\n }\n\n /**\n * 应用筛选条件\n */\n applyFilter(fieldId: string | number = this.selectedField): void {\n if (!this.operatorSelect || !this.valueInput) {\n return;\n }\n\n const operator = this.operatorSelect?.value as FilterOperator;\n let conditionValue: any = this.valueInput?.value;\n\n // 根据所选操作符和分类尝试转换输入值\n if (this.currentCategory === FilterOperatorCategory.NUMBER) {\n conditionValue = parseFloat(conditionValue);\n if (isNaN(conditionValue)) {\n console.warn('请输入有效的数字');\n return;\n }\n }\n\n // 处理范围操作符的双值输入\n if (this.isRangeOperator(operator)) {\n const minValue = conditionValue;\n let maxValue: string | number = this.valueInputMax.value.trim();\n\n // 尝试将最大值也转换为数字\n if (this.currentCategory === FilterOperatorCategory.NUMBER) {\n const numMaxValue = parseFloat(maxValue);\n if (!isNaN(numMaxValue)) {\n maxValue = numMaxValue;\n } else {\n console.warn('请输入有效的最大值');\n return;\n }\n }\n\n // 使用数组形式传递范围值\n conditionValue = [minValue, maxValue];\n }\n\n if (!conditionValue && conditionValue !== false && conditionValue !== 0 && !this.isBooleanOperator(operator)) {\n this.clearFilter(fieldId);\n return;\n }\n\n // TODO:处理单元格颜色和字体颜色的筛选\n\n this.filterStateManager.dispatch({\n type: FilterActionType.APPLY_FILTERS,\n payload: {\n field: fieldId,\n type: 'byCondition',\n operator,\n condition: conditionValue,\n enable: true\n }\n });\n\n this.hide();\n }\n\n /**\n * 清除筛选\n */\n clearFilter(fieldId: string | number): void {\n this.filterStateManager.dispatch({\n type: FilterActionType.REMOVE_FILTER,\n payload: {\n field: fieldId\n }\n });\n\n this.hide();\n }\n\n /**\n * 渲染条件筛选面板\n */\n render(container: HTMLElement): void {\n const filterStyles = this.styles;\n // 按条件筛选面板\n this.filterByConditionPanel = document.createElement('div');\n applyStyles(this.filterByConditionPanel, filterStyles.filterPanel);\n\n // 条件选择区域\n this.conditionContainer = document.createElement('div');\n applyStyles(this.conditionContainer, this.styles.conditionContainer);\n\n // 分类选择下拉框\n this.categoryLabel = createElement('label', {}, ['筛选类型:']);\n applyStyles(this.categoryLabel, this.styles.formLabel);\n\n this.categorySelect = createElement('select') as HTMLSelectElement;\n applyStyles(this.categorySelect, filterStyles.operatorSelect);\n\n // 添加分类选项\n this.categories.forEach(category => {\n const option = document.createElement('option');\n option.value = category.value;\n option.textContent = category.label;\n this.categorySelect.appendChild(option);\n });\n\n // 操作符选择下拉框\n this.operatorLabel = createElement('label', {}, ['筛选条件:']);\n applyStyles(this.operatorLabel, this.styles.formLabel);\n\n this.operatorSelect = createElement('select') as HTMLSelectElement;\n applyStyles(this.operatorSelect, filterStyles.operatorSelect);\n\n // 条件值输入框\n this.valueLabel = createElement('label', {}, ['筛选值:']);\n applyStyles(this.valueLabel, this.styles.formLabel);\n\n // 一个容器来包装两个输入框和\"和\"字\n this.rangeInputContainer = createElement('div');\n applyStyles(this.rangeInputContainer, this.styles.rangeInputContainer);\n\n this.valueInput = createElement('input', {\n type: 'text',\n placeholder: '请输入筛选值'\n }) as HTMLInputElement;\n applyStyles(this.valueInput, filterStyles.searchInput);\n\n // \"和\"字标签\n this.andLabel = createElement('span', {}, ['和']);\n applyStyles(this.andLabel, this.styles.addLabel);\n this.andLabel.style.display = 'none'; // 默认隐藏\n\n // 范围筛选的最大值输入框\n this.valueInputMax = createElement('input', {\n type: 'text',\n placeholder: '最大值'\n }) as HTMLInputElement;\n applyStyles(this.valueInputMax, filterStyles.searchInput);\n this.valueInputMax.style.display = 'none'; // 默认隐藏\n\n // 将输入框和\"和\"字添加到容器中\n this.rangeInputContainer.appendChild(this.valueInput);\n this.rangeInputContainer.appendChild(this.andLabel);\n this.rangeInputContainer.appendChild(this.valueInputMax);\n\n // 将元素添加到容器中\n this.conditionContainer.appendChild(this.categoryLabel);\n this.conditionContainer.appendChild(this.categorySelect);\n this.conditionContainer.appendChild(this.operatorLabel);\n this.conditionContainer.appendChild(this.operatorSelect);\n this.conditionContainer.appendChild(this.valueLabel);\n this.conditionContainer.appendChild(this.rangeInputContainer);\n\n this.filterByConditionPanel.appendChild(this.conditionContainer);\n container.appendChild(this.filterByConditionPanel);\n\n // 默认隐藏\n this.hide();\n\n // 初始化操作符选项\n this.updateOperatorOptions();\n this.bindEvents();\n }\n\n updateStyles(styles: FilterStyles) {\n applyStyles(this.filterByConditionPanel, styles.filterPanel);\n applyStyles(this.conditionContainer, styles.conditionContainer);\n applyStyles(this.categoryLabel, styles.formLabel);\n applyStyles(this.categorySelect, styles.operatorSelect);\n applyStyles(this.operatorLabel, styles.formLabel);\n applyStyles(this.operatorSelect, styles.operatorSelect);\n applyStyles(this.valueLabel, styles.formLabel);\n applyStyles(this.rangeInputContainer, styles.rangeInputContainer);\n applyStyles(this.valueInput, styles.searchInput);\n applyStyles(this.andLabel, styles.addLabel);\n applyStyles(this.valueInputMax, styles.searchInput);\n }\n\n /**\n * 绑定事件\n */\n private bindEvents(): void {\n // 输入框回车事件\n this.valueInput.addEventListener('keypress', event => {\n if (event.key === 'Enter') {\n this.applyFilter();\n }\n });\n\n // 最大值输入框回车事件\n this.valueInputMax.addEventListener('keypress', event => {\n if (event.key === 'Enter') {\n this.applyFilter();\n }\n });\n\n // 分类切换事件\n this.categorySelect.addEventListener('change', () => {\n this.handleCategoryChange();\n });\n\n // 操作符切换事件\n this.operatorSelect.addEventListener('change', () => {\n const selectedOperator = this.operatorSelect.value as FilterOperator;\n const andLabel = this.valueInput.nextElementSibling as HTMLElement;\n\n if (this.isRangeOperator(selectedOperator)) {\n this.valueInput.placeholder = '最小值';\n this.valueInputMax.style.display = 'inline-block';\n andLabel.style.display = 'inline-block';\n } else {\n this.valueInput.placeholder = '请输入筛选值';\n this.valueInputMax.style.display = 'none';\n andLabel.style.display = 'none';\n }\n });\n }\n\n /**\n * 显示筛选面板\n */\n show(): void {\n if (this.filterByConditionPanel) {\n this.filterByConditionPanel.style.display = 'block';\n this.loadCurrentFilterState();\n }\n }\n\n /**\n * 隐藏筛选面板\n */\n hide(): void {\n if (this.filterByConditionPanel) {\n this.filterByConditionPanel.style.display = 'none';\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/filter/condition-filter.ts"],"names":[],"mappings":";;;AAEA,qCAAoE;AAEpE,mCAAmE;AAKnE,MAAa,eAAe;IA4D1B,YAAY,KAA6B,EAAE,kBAAsC;QAnDzE,oBAAe,GAA2B,8BAAsB,CAAC,GAAG,CAAC;QAGrE,cAAS,GAAqB;YAEpC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,8BAAsB,CAAC,GAAG,EAAE;YACtE,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,8BAAsB,CAAC,GAAG,EAAE;YAG1E,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,8BAAsB,CAAC,MAAM,EAAE;YACzE,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,8BAAsB,CAAC,MAAM,EAAE;YAC7E,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,8BAAsB,CAAC,MAAM,EAAE;YAC9E,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,8BAAsB,CAAC,MAAM,EAAE;YAC3E,EAAE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,OAAO,GAAG,cAAc,CAAC;aACzC;iBAAM;gBACL,IAAI,CAAC,UAAU,CAAC,WAAW,GAAG,QAAQ,CAAC;gBACvC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;gBAC1C,QAAQ,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;aACjC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAKD,IAAI;QACF,IAAI,IAAI,CAAC,sBAAsB,EAAE;YAC/B,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC;YACpD,IAAI,CAAC,sBAAsB,EAAE,CAAC;SAC/B;IACH,CAAC;IAKD,IAAI;QACF,IAAI,IAAI,CAAC,sBAAsB,EAAE;YAC/B,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;SACpD;IACH,CAAC;CACF;AA1bD,0CA0bC","file":"condition-filter.js","sourcesContent":["import type { ListTable, PivotTable } from '@visactor/vtable';\nimport type { FilterStateManager } from './filter-state-manager';\nimport { applyStyles, filterStyles, createElement } from './styles';\nimport type { FilterOperator, OperatorOption } from './types';\nimport { FilterActionType, FilterOperatorCategory } from './types';\n\n/**\n * 按条件筛选组件\n */\nexport class ConditionFilter {\n private table: ListTable | PivotTable;\n private filterStateManager: FilterStateManager;\n private filterByConditionPanel: HTMLElement;\n private selectedField: string | number;\n private operatorSelect: HTMLSelectElement;\n private valueInput: HTMLInputElement;\n private valueInputMax: HTMLInputElement;\n private categorySelect: HTMLSelectElement;\n private currentCategory: FilterOperatorCategory = FilterOperatorCategory.ALL;\n\n // 按分类组织的操作符选项\n private operators: OperatorOption[] = [\n // 通用操作符 (全部分类中显示)\n { value: 'equals', label: '等于', category: FilterOperatorCategory.ALL },\n { value: 'notEquals', label: '不等于', category: FilterOperatorCategory.ALL },\n\n // 数值操作符\n { value: 'equals', label: '等于', category: FilterOperatorCategory.NUMBER },\n { value: 'notEquals', label: '不等于', category: FilterOperatorCategory.NUMBER },\n { value: 'greaterThan', label: '大于', category: FilterOperatorCategory.NUMBER },\n { value: 'lessThan', label: '小于', category: FilterOperatorCategory.NUMBER },\n { value: 'greaterThanOrEqual', label: '大于等于', category: FilterOperatorCategory.NUMBER },\n { value: 'lessThanOrEqual', label: '小于等于', category: FilterOperatorCategory.NUMBER },\n { value: 'between', label: '介于', category: FilterOperatorCategory.NUMBER },\n { value: 'notBetween', label: '不介于', category: FilterOperatorCategory.NUMBER },\n\n // 文本操作符\n { value: 'equals', label: '等于', category: FilterOperatorCategory.TEXT },\n { value: 'notEquals', label: '不等于', category: FilterOperatorCategory.TEXT },\n { value: 'contains', label: '包含', category: FilterOperatorCategory.TEXT },\n { value: 'notContains', label: '不包含', category: FilterOperatorCategory.TEXT },\n { value: 'startsWith', label: '开头是', category: FilterOperatorCategory.TEXT },\n { value: 'notStartsWith', label: '开头不是', category: FilterOperatorCategory.TEXT },\n { value: 'endsWith', label: '结尾是', category: FilterOperatorCategory.TEXT },\n { value: 'notEndsWith', label: '结尾不是', category: FilterOperatorCategory.TEXT },\n\n // 颜色操作符\n { value: 'equals', label: '等于', category: FilterOperatorCategory.COLOR },\n { value: 'notEquals', label: '不等于', category: FilterOperatorCategory.COLOR },\n\n // 复选框操作符\n { value: 'isChecked', label: '已选中', category: FilterOperatorCategory.CHECKBOX },\n { value: 'isUnchecked', label: '未选中', category: FilterOperatorCategory.CHECKBOX },\n\n // 单选框操作符\n { value: 'isChecked', label: '已选中', category: FilterOperatorCategory.RADIO },\n { value: 'isUnchecked', label: '未选中', category: FilterOperatorCategory.RADIO }\n ];\n\n // 分类下拉选项\n private categories = [\n { value: FilterOperatorCategory.ALL, label: '全部' },\n { value: FilterOperatorCategory.TEXT, label: '文本' },\n { value: FilterOperatorCategory.NUMBER, label: '数值' },\n { value: FilterOperatorCategory.COLOR, label: '颜色' },\n { value: FilterOperatorCategory.CHECKBOX, label: '复选框' },\n { value: FilterOperatorCategory.RADIO, label: '单选框' }\n ];\n\n constructor(table: ListTable | PivotTable, filterStateManager: FilterStateManager) {\n this.table = table;\n this.filterStateManager = filterStateManager;\n }\n\n setSelectedField(fieldId: string | number): void {\n this.selectedField = fieldId;\n this.updateOperatorOptions();\n this.loadCurrentFilterState();\n }\n\n /**\n * 更新操作符下拉选项\n */\n private updateOperatorOptions(): void {\n if (!this.operatorSelect) {\n return;\n }\n this.operatorSelect.innerHTML = '';\n let filteredOperators: OperatorOption[];\n\n if (this.currentCategory === FilterOperatorCategory.ALL) {\n // 当选择\"全部\"时,收集所有不重复的操作符\n const uniqueOperators = new Map<string, OperatorOption>();\n this.operators.forEach(op => {\n if (!uniqueOperators.has(op.value)) {\n uniqueOperators.set(op.value, op);\n }\n });\n filteredOperators = Array.from(uniqueOperators.values());\n } else {\n // 其他类别正常筛选\n filteredOperators = this.operators.filter(op => op.category === this.currentCategory);\n }\n\n // 添加新选项\n filteredOperators.forEach(op => {\n const option = document.createElement('option');\n option.value = op.value;\n option.textContent = op.label;\n this.operatorSelect.appendChild(option);\n });\n }\n\n private handleCategoryChange(): void {\n if (!this.categorySelect) {\n return;\n }\n\n this.currentCategory = this.categorySelect.value as FilterOperatorCategory;\n this.updateOperatorOptions();\n\n // 分类切换后也需要同步UI状态\n this.syncUIState();\n }\n\n /**\n * 加载当前的筛选状态\n */\n private loadCurrentFilterState(): void {\n const filter = this.filterStateManager.getFilterState(this.selectedField);\n\n if (filter && filter.type === 'byCondition') {\n // 设置操作符\n if (filter.operator && this.operatorSelect) {\n this.operatorSelect.value = filter.operator;\n }\n\n // 设置条件值\n if (filter.condition !== undefined && this.valueInput) {\n if (Array.isArray(filter.condition)) {\n this.valueInput.value = String(filter.condition[0]);\n if (this.valueInputMax) {\n this.valueInputMax.value = String(filter.condition[1]);\n }\n } else {\n this.valueInput.value = String(filter.condition);\n if (this.valueInputMax) {\n this.valueInputMax.value = '';\n }\n }\n }\n\n // 同步UI状态:根据当前操作符显示/隐藏范围输入框\n this.syncUIState();\n } else {\n // 重置为默认值\n this.reset();\n }\n }\n\n /**\n * 重置筛选条件到默认状态\n */\n reset(): void {\n // 重置操作符选择\n if (this.operatorSelect) {\n this.operatorSelect.selectedIndex = 0;\n }\n\n // 重置所有输入框\n if (this.valueInput) {\n this.valueInput.value = '';\n this.valueInput.placeholder = '请输入筛选值';\n }\n\n if (this.valueInputMax) {\n this.valueInputMax.value = '';\n }\n\n // 重置分类选择\n this.currentCategory = FilterOperatorCategory.ALL;\n if (this.categorySelect) {\n this.categorySelect.value = FilterOperatorCategory.ALL;\n }\n\n // 更新操作符选项\n this.updateOperatorOptions();\n\n // 同步UI状态\n this.syncUIState();\n }\n\n /**\n * 同步UI状态:根据当前选择的操作符调整UI显示\n */\n private syncUIState(): void {\n if (!this.operatorSelect || !this.valueInput) {\n return;\n }\n\n const selectedOperator = this.operatorSelect.value as FilterOperator;\n const andLabel = this.valueInput.nextElementSibling as HTMLElement;\n\n if (this.isRangeOperator(selectedOperator)) {\n // 显示范围输入相关UI\n this.valueInput.placeholder = '最小值';\n if (this.valueInputMax) {\n this.valueInputMax.style.display = 'inline-block';\n }\n if (andLabel) {\n andLabel.style.display = 'inline-block';\n }\n } else {\n // 隐藏范围输入相关UI\n this.valueInput.placeholder = '请输入筛选值';\n if (this.valueInputMax) {\n this.valueInputMax.style.display = 'none';\n }\n if (andLabel) {\n andLabel.style.display = 'none';\n }\n }\n }\n\n private isBooleanOperator(operator: FilterOperator): boolean {\n const booleanCondition = ['isChecked', 'isUnchecked'];\n return booleanCondition.includes(operator);\n }\n\n private isRangeOperator(operator: FilterOperator): boolean {\n return operator === 'between' || operator === 'notBetween';\n }\n\n /**\n * 应用筛选条件\n */\n applyFilter(fieldId: string | number = this.selectedField): void {\n if (!this.operatorSelect || !this.valueInput) {\n return;\n }\n\n const operator = this.operatorSelect?.value as FilterOperator;\n let conditionValue: any = this.valueInput?.value;\n\n // 根据所选操作符和分类尝试转换输入值\n if (this.currentCategory === FilterOperatorCategory.NUMBER) {\n conditionValue = parseFloat(conditionValue);\n if (isNaN(conditionValue)) {\n console.warn('请输入有效的数字');\n return;\n }\n }\n\n // 处理范围操作符的双值输入\n if (this.isRangeOperator(operator)) {\n const minValue = conditionValue;\n let maxValue: string | number = this.valueInputMax.value.trim();\n\n // 尝试将最大值也转换为数字\n if (this.currentCategory === FilterOperatorCategory.NUMBER) {\n const numMaxValue = parseFloat(maxValue);\n if (!isNaN(numMaxValue)) {\n maxValue = numMaxValue;\n } else {\n console.warn('请输入有效的最大值');\n return;\n }\n }\n\n // 使用数组形式传递范围值\n conditionValue = [minValue, maxValue];\n }\n\n if (!conditionValue && conditionValue !== false && conditionValue !== 0 && !this.isBooleanOperator(operator)) {\n this.clearFilter(fieldId);\n return;\n }\n\n // TODO:处理单元格颜色和字体颜色的筛选\n\n this.filterStateManager.dispatch({\n type: FilterActionType.APPLY_FILTERS,\n payload: {\n field: fieldId,\n type: 'byCondition',\n operator,\n condition: conditionValue,\n enable: true\n }\n });\n\n this.hide();\n }\n\n /**\n * 清除筛选\n */\n clearFilter(fieldId: string | number): void {\n this.filterStateManager.dispatch({\n type: FilterActionType.REMOVE_FILTER,\n payload: {\n field: fieldId\n }\n });\n\n this.hide();\n }\n\n /**\n * 渲染条件筛选面板\n */\n render(container: HTMLElement): void {\n // 按条件筛选面板\n this.filterByConditionPanel = document.createElement('div');\n applyStyles(this.filterByConditionPanel, filterStyles.filterPanel);\n\n // 条件选择区域\n const conditionContainer = document.createElement('div');\n applyStyles(conditionContainer, filterStyles.conditionContainer);\n\n // 分类选择下拉框\n const categoryLabel = createElement('label', {}, ['筛选类型:']);\n applyStyles(categoryLabel, filterStyles.formLabel);\n\n this.categorySelect = createElement('select') as HTMLSelectElement;\n applyStyles(this.categorySelect, filterStyles.operatorSelect);\n\n // 添加分类选项\n this.categories.forEach(category => {\n const option = document.createElement('option');\n option.value = category.value;\n option.textContent = category.label;\n this.categorySelect.appendChild(option);\n });\n\n // 操作符选择下拉框\n const operatorLabel = createElement('label', {}, ['筛选条件:']);\n applyStyles(operatorLabel, filterStyles.formLabel);\n\n this.operatorSelect = createElement('select') as HTMLSelectElement;\n applyStyles(this.operatorSelect, filterStyles.operatorSelect);\n\n // 条件值输入框\n const valueLabel = createElement('label', {}, ['筛选值:']);\n applyStyles(valueLabel, filterStyles.formLabel);\n\n // 一个容器来包装两个输入框和\"和\"字\n const rangeInputContainer = createElement('div');\n applyStyles(rangeInputContainer, filterStyles.rangeInputContainer);\n\n this.valueInput = createElement('input', {\n type: 'text',\n placeholder: '请输入筛选值'\n }) as HTMLInputElement;\n applyStyles(this.valueInput, filterStyles.searchInput);\n\n // \"和\"字标签\n const andLabel = createElement('span', {}, ['和']);\n applyStyles(andLabel, filterStyles.addLabel);\n andLabel.style.display = 'none'; // 默认隐藏\n\n // 范围筛选的最大值输入框\n this.valueInputMax = createElement('input', {\n type: 'text',\n placeholder: '最大值'\n }) as HTMLInputElement;\n applyStyles(this.valueInputMax, filterStyles.searchInput);\n this.valueInputMax.style.display = 'none'; // 默认隐藏\n\n // 将输入框和\"和\"字添加到容器中\n rangeInputContainer.appendChild(this.valueInput);\n rangeInputContainer.appendChild(andLabel);\n rangeInputContainer.appendChild(this.valueInputMax);\n\n // 将元素添加到容器中\n conditionContainer.appendChild(categoryLabel);\n conditionContainer.appendChild(this.categorySelect);\n conditionContainer.appendChild(operatorLabel);\n conditionContainer.appendChild(this.operatorSelect);\n conditionContainer.appendChild(valueLabel);\n conditionContainer.appendChild(rangeInputContainer);\n\n this.filterByConditionPanel.appendChild(conditionContainer);\n container.appendChild(this.filterByConditionPanel);\n\n // 默认隐藏\n this.hide();\n\n // 初始化操作符选项\n this.updateOperatorOptions();\n this.bindEvents();\n }\n\n /**\n * 绑定事件\n */\n private bindEvents(): void {\n // 输入框回车事件\n this.valueInput.addEventListener('keypress', event => {\n if (event.key === 'Enter') {\n this.applyFilter();\n }\n });\n\n // 最大值输入框回车事件\n this.valueInputMax.addEventListener('keypress', event => {\n if (event.key === 'Enter') {\n this.applyFilter();\n }\n });\n\n // 分类切换事件\n this.categorySelect.addEventListener('change', () => {\n this.handleCategoryChange();\n });\n\n // 操作符切换事件\n this.operatorSelect.addEventListener('change', () => {\n const selectedOperator = this.operatorSelect.value as FilterOperator;\n const andLabel = this.valueInput.nextElementSibling as HTMLElement;\n\n if (this.isRangeOperator(selectedOperator)) {\n this.valueInput.placeholder = '最小值';\n this.valueInputMax.style.display = 'inline-block';\n andLabel.style.display = 'inline-block';\n } else {\n this.valueInput.placeholder = '请输入筛选值';\n this.valueInputMax.style.display = 'none';\n andLabel.style.display = 'none';\n }\n });\n }\n\n /**\n * 显示筛选面板\n */\n show(): void {\n if (this.filterByConditionPanel) {\n this.filterByConditionPanel.style.display = 'block';\n this.loadCurrentFilterState();\n }\n }\n\n /**\n * 隐藏筛选面板\n */\n hide(): void {\n if (this.filterByConditionPanel) {\n this.filterByConditionPanel.style.display = 'none';\n }\n }\n}\n"]}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ListTable, 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
|
|
5
|
+
import type { FilterMode } from './types';
|
|
6
6
|
export declare class FilterToolbar {
|
|
7
7
|
table: ListTable | PivotTable;
|
|
8
8
|
filterStateManager: FilterStateManager;
|
|
9
|
-
pluginOptions: FilterOptions;
|
|
10
9
|
valueFilter: ValueFilter | null;
|
|
11
10
|
conditionFilter: ConditionFilter | null;
|
|
12
11
|
activeTab: 'byValue' | 'byCondition';
|
|
@@ -14,26 +13,23 @@ export declare class FilterToolbar {
|
|
|
14
13
|
selectedField: string | number | null;
|
|
15
14
|
filterModes: FilterMode[];
|
|
16
15
|
private filterMenu;
|
|
17
|
-
private filterTabsContainer;
|
|
18
16
|
private filterMenuWidth;
|
|
19
17
|
private currentCol?;
|
|
20
18
|
private currentRow?;
|
|
21
19
|
private filterTabByValue;
|
|
22
20
|
private filterTabByCondition;
|
|
23
|
-
private footerContainer;
|
|
24
21
|
private clearFilterOptionLink;
|
|
25
22
|
private cancelFilterButton;
|
|
26
23
|
private applyFilterButton;
|
|
27
|
-
constructor(table: ListTable | PivotTable, filterStateManager: FilterStateManager
|
|
24
|
+
constructor(table: ListTable | PivotTable, filterStateManager: FilterStateManager);
|
|
28
25
|
private onTabSwitch;
|
|
29
26
|
private updateSelectedField;
|
|
30
27
|
private applyFilter;
|
|
31
28
|
private clearFilter;
|
|
32
29
|
private updateClearFilterButtonState;
|
|
33
30
|
render(container: HTMLElement): void;
|
|
34
|
-
updateStyles(styles: FilterStyles): void;
|
|
35
31
|
attachEventListeners(): void;
|
|
36
32
|
adjustMenuPosition(col?: number | null, row?: number | null, providedLeft?: number | null, providedTop?: number | null): void;
|
|
37
33
|
show(col: number, row: number, filterModes: FilterMode[]): void;
|
|
38
|
-
hide(
|
|
34
|
+
hide(): void;
|
|
39
35
|
}
|
|
@@ -4,15 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
}), exports.FilterToolbar = void 0;
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const 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) {
|
|
11
11
|
this.valueFilter = null, this.conditionFilter = null, this.activeTab = "byValue",
|
|
12
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.
|
|
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 => {
|
|
16
16
|
this.isVisible && null !== this.selectedField && this.updateClearFilterButtonState(this.selectedField);
|
|
17
17
|
}));
|
|
18
18
|
}
|
|
@@ -29,11 +29,11 @@ class FilterToolbar {
|
|
|
29
29
|
}
|
|
30
30
|
applyFilter(field) {
|
|
31
31
|
"byValue" === this.activeTab ? this.valueFilter.applyFilter(field) : "byCondition" === this.activeTab && this.conditionFilter.applyFilter(field),
|
|
32
|
-
this.hide(
|
|
32
|
+
this.hide();
|
|
33
33
|
}
|
|
34
34
|
clearFilter(field) {
|
|
35
35
|
this.valueFilter && this.valueFilter.clearFilter(field), this.conditionFilter && this.conditionFilter.clearFilter(field),
|
|
36
|
-
this.hide(
|
|
36
|
+
this.hide();
|
|
37
37
|
}
|
|
38
38
|
updateClearFilterButtonState(field) {
|
|
39
39
|
const currentFilter = this.filterStateManager.getFilterState(field), hasActiveFilter = currentFilter && currentFilter.enable;
|
|
@@ -42,46 +42,40 @@ class FilterToolbar {
|
|
|
42
42
|
this.clearFilterOptionLink.style.cursor = hasActiveFilter ? "pointer" : "not-allowed";
|
|
43
43
|
}
|
|
44
44
|
render(container) {
|
|
45
|
-
|
|
46
|
-
this.filterMenu =
|
|
47
|
-
|
|
48
|
-
|
|
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
49
|
this.filterTabByValue = document.createElement("button"), this.filterTabByValue.innerText = "按值筛选",
|
|
50
|
-
(0, styles_1.applyStyles)(this.filterTabByValue, filterStyles.tabStyle(!0)),
|
|
51
|
-
this.filterTabByCondition
|
|
52
|
-
|
|
53
|
-
|
|
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
56
|
this.clearFilterOptionLink = document.createElement("a"), this.clearFilterOptionLink.href = "#",
|
|
55
|
-
this.clearFilterOptionLink.innerText = "清除筛选", (0, styles_1.applyStyles)(this.clearFilterOptionLink, filterStyles.clearLink);
|
|
57
|
+
this.clearFilterOptionLink.innerText = "清除筛选", (0, styles_1.applyStyles)(this.clearFilterOptionLink, styles_1.filterStyles.clearLink);
|
|
56
58
|
const footerButtons = document.createElement("div");
|
|
57
59
|
this.cancelFilterButton = document.createElement("button"), this.cancelFilterButton.innerText = "取消",
|
|
58
|
-
(0, styles_1.applyStyles)(this.cancelFilterButton, filterStyles.footerButton(!1)),
|
|
60
|
+
(0, styles_1.applyStyles)(this.cancelFilterButton, styles_1.filterStyles.footerButton(!1)),
|
|
59
61
|
this.applyFilterButton = document.createElement("button"), this.applyFilterButton.innerText = "确认",
|
|
60
|
-
(0, styles_1.applyStyles)(this.applyFilterButton, filterStyles.footerButton(!0)),
|
|
61
|
-
footerButtons.append(this.cancelFilterButton, this.applyFilterButton),
|
|
62
|
-
this.filterMenu.append(
|
|
63
|
-
this.conditionFilter.render(this.filterMenu), this.filterMenu.append(
|
|
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
66
|
container.appendChild(this.filterMenu), this.attachEventListeners();
|
|
65
67
|
}
|
|
66
|
-
updateStyles(styles) {
|
|
67
|
-
(0, styles_1.applyStyles)(this.filterMenu, styles.filterMenu), (0, styles_1.applyStyles)(this.filterTabsContainer, styles.tabsContainer),
|
|
68
|
-
(0, styles_1.applyStyles)(this.filterTabByValue, styles.tabStyle(!0)), (0, styles_1.applyStyles)(this.footerContainer, styles.footerContainer),
|
|
69
|
-
(0, styles_1.applyStyles)(this.clearFilterOptionLink, styles.clearLink), (0, styles_1.applyStyles)(this.cancelFilterButton, styles.footerButton(!1)),
|
|
70
|
-
(0, styles_1.applyStyles)(this.applyFilterButton, styles.footerButton(!0)), this.valueFilter.updateStyles(styles),
|
|
71
|
-
this.conditionFilter.updateStyles(styles);
|
|
72
|
-
}
|
|
73
68
|
attachEventListeners() {
|
|
74
69
|
this.filterTabByValue.addEventListener("click", (() => {
|
|
75
70
|
this.onTabSwitch("byValue");
|
|
76
71
|
})), this.filterTabByCondition.addEventListener("click", (() => {
|
|
77
72
|
this.onTabSwitch("byCondition");
|
|
78
|
-
})), this.cancelFilterButton.addEventListener("click", (() => this.hide(
|
|
79
|
-
this.clearFilterOptionLink.addEventListener("click", (e => {
|
|
73
|
+
})), this.cancelFilterButton.addEventListener("click", (() => this.hide())), this.clearFilterOptionLink.addEventListener("click", (e => {
|
|
80
74
|
e.preventDefault(), this.clearFilter(this.selectedField);
|
|
81
75
|
})), this.applyFilterButton.addEventListener("click", (() => {
|
|
82
76
|
this.applyFilter(this.selectedField);
|
|
83
77
|
})), document.addEventListener("click", (() => {
|
|
84
|
-
this.isVisible && this.hide(
|
|
78
|
+
this.isVisible && this.hide();
|
|
85
79
|
})), this.filterMenu.addEventListener("click", (e => {
|
|
86
80
|
e.stopPropagation();
|
|
87
81
|
}));
|
|
@@ -93,10 +87,9 @@ class FilterToolbar {
|
|
|
93
87
|
if ("number" != typeof effectiveCol || "number" != typeof effectiveRow) return;
|
|
94
88
|
this.currentCol = effectiveCol, this.currentRow = effectiveRow;
|
|
95
89
|
let left = 0, top = 0;
|
|
96
|
-
const canvasBounds = this.table.canvas.getBoundingClientRect(), cell = this.table.getCellRelativeRect(effectiveCol, effectiveRow)
|
|
90
|
+
const canvasBounds = this.table.canvas.getBoundingClientRect(), cell = this.table.getCellRelativeRect(effectiveCol, effectiveRow);
|
|
97
91
|
cell.right < this.filterMenuWidth ? (left = cell.left + canvasBounds.left, top = cell.bottom + canvasBounds.top) : (left = cell.right + canvasBounds.left - this.filterMenuWidth,
|
|
98
|
-
top = cell.bottom + canvasBounds.top),
|
|
99
|
-
top = Math.max(0, Math.min(window.innerHeight - 380, top)), this.filterMenu.style.display = this.isVisible ? "block" : "none",
|
|
92
|
+
top = cell.bottom + canvasBounds.top), this.filterMenu.style.display = this.isVisible ? "block" : "none",
|
|
100
93
|
this.filterMenu.style.left = `${left}px`, this.filterMenu.style.top = `${top}px`;
|
|
101
94
|
}
|
|
102
95
|
show(col, row, filterModes) {
|
|
@@ -108,17 +101,11 @@ class FilterToolbar {
|
|
|
108
101
|
const currentFilter = this.filterStateManager.getFilterState(field);
|
|
109
102
|
currentFilter && "byCondition" === currentFilter.type ? this.onTabSwitch("byCondition") : this.onTabSwitch("byValue"),
|
|
110
103
|
this.updateClearFilterButtonState(field), setTimeout((() => {
|
|
111
|
-
this.isVisible = !0
|
|
112
|
-
col: col,
|
|
113
|
-
row: row
|
|
114
|
-
});
|
|
104
|
+
this.isVisible = !0;
|
|
115
105
|
}), 0);
|
|
116
106
|
}
|
|
117
|
-
hide(
|
|
118
|
-
this.filterMenu.style.display = "none", this.isVisible = !1
|
|
119
|
-
col: currentCol,
|
|
120
|
-
row: currentRow
|
|
121
|
-
});
|
|
107
|
+
hide() {
|
|
108
|
+
this.filterMenu.style.display = "none", this.isVisible = !1;
|
|
122
109
|
}
|
|
123
110
|
}
|
|
124
111
|
|