@univerjs/sheets-filter-ui 0.5.4 → 0.5.5-experimental.20250122-3362a4a
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/lib/cjs/index.js +1 -9
- package/lib/cjs/locale/en-US.js +1 -1
- package/lib/cjs/locale/fa-IR.js +1 -1
- package/lib/cjs/locale/fr-FR.js +1 -1
- package/lib/cjs/locale/ru-RU.js +1 -1
- package/lib/cjs/locale/vi-VN.js +1 -1
- package/lib/cjs/locale/zh-CN.js +1 -1
- package/lib/cjs/locale/zh-TW.js +1 -1
- package/lib/es/index.js +1344 -1338
- package/lib/es/locale/en-US.js +2 -2
- package/lib/es/locale/fa-IR.js +2 -2
- package/lib/es/locale/fr-FR.js +2 -2
- package/lib/es/locale/ru-RU.js +2 -2
- package/lib/es/locale/vi-VN.js +2 -2
- package/lib/es/locale/zh-CN.js +2 -2
- package/lib/es/locale/zh-TW.js +2 -2
- package/lib/types/views/components/SheetsFilterByConditionsPanel.d.ts +1 -2
- package/lib/types/views/components/SheetsFilterByValuesPanel.d.ts +1 -2
- package/lib/types/views/components/SheetsFilterPanel.d.ts +16 -2
- package/lib/types/views/components/SheetsFilterPanel.stories.d.ts +3 -4
- package/lib/umd/index.js +1 -9
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +11 -11
- package/LICENSE +0 -176
package/lib/es/index.js
CHANGED
|
@@ -1,688 +1,701 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
|
+
import { BooleanNumber, createIdentifier, Inject, LocaleService, Disposable, IUniverInstanceService, ILogService, extractPureTextFromCell, numfmt, Injector, ICommandService, Quantity, Tools, CommandType, IContextService, useDependency, UniverInstanceType, ThemeService, RxDisposable, fromCallback, InterceptorEffectEnum, DependentOn, Optional, Plugin, merge as merge$1, IConfigService } from "@univerjs/core";
|
|
6
|
+
import { IRPCChannelService, toModule, fromModule } from "@univerjs/rpc";
|
|
7
|
+
import { CustomFilterOperator, SetSheetsFilterCriteriaCommand, SheetsFilterService, SmartToggleSheetsFilterCommand, ClearSheetsFilterCriteriaCommand, ReCalcSheetsFilterCommand, FILTER_MUTATIONS, SetSheetsFilterRangeMutation, SetSheetsFilterCriteriaMutation, RemoveSheetsFilterMutation, ReCalcSheetsFilterMutation, RemoveSheetFilterCommand, SetSheetFilterRangeCommand, UniverSheetsFilterPlugin } from "@univerjs/sheets-filter";
|
|
8
|
+
import { RefRangeService, SheetPermissionCheckController, SheetsSelectionsService, getSheetCommandTarget, RangeProtectionPermissionViewPoint, WorksheetFilterPermission, WorksheetViewPermission, expandToContinuousRange, SheetInterceptorService, SetRangeValuesMutation, INTERCEPTOR_POINT } from "@univerjs/sheets";
|
|
9
|
+
import { ILayoutService, useObservable, useComponentsOfPart, ComponentContainer, MenuItemType, getMenuHiddenObservable, RibbonStartGroup, KeyCode, MetaKeys, ComponentManager, IShortcutService, IMenuManagerService, IMessageService } from "@univerjs/ui";
|
|
10
|
+
import { SetCellEditVisibleOperation, SheetsUIPart, getObservableWithExclusiveRange$, getCurrentRangeDisable$, SheetSkeletonManagerService, ISheetSelectionRenderService, SelectionControl, attachSelectionWithCoord, getCoordByCell, SheetsRenderService, whenSheetEditorFocused, SheetCanvasPopManagerService } from "@univerjs/sheets-ui";
|
|
11
|
+
import { BehaviorSubject, ReplaySubject, of, Subject, merge, combineLatest, throttleTime, startWith, map, shareReplay, switchMap, filter, takeUntil, distinctUntilChanged } from "rxjs";
|
|
12
|
+
import { Select, RadioGroup, Radio, Input, Checkbox, Tree, Button, Segmented, MessageType } from "@univerjs/design";
|
|
13
|
+
import { Rect, Shape, IRenderManagerService } from "@univerjs/engine-render";
|
|
14
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
15
|
+
import { forwardRef, useRef, createElement, useCallback, useMemo } from "react";
|
|
16
|
+
const SHEETS_FILTER_UI_PLUGIN_CONFIG_KEY = "sheets-filter-ui.config", defaultPluginConfig = {};
|
|
17
|
+
var OperatorOrder = /* @__PURE__ */ ((OperatorOrder2) => (OperatorOrder2[OperatorOrder2.FIRST = 0] = "FIRST", OperatorOrder2[OperatorOrder2.SECOND = 1] = "SECOND", OperatorOrder2))(OperatorOrder || {}), ExtendCustomFilterOperator = /* @__PURE__ */ ((ExtendCustomFilterOperator2) => (ExtendCustomFilterOperator2.NONE = "none", ExtendCustomFilterOperator2.STARTS_WITH = "startsWith", ExtendCustomFilterOperator2.DOES_NOT_START_WITH = "doesNotStartWith", ExtendCustomFilterOperator2.ENDS_WITH = "endsWith", ExtendCustomFilterOperator2.DOES_NOT_END_WITH = "doesNotEndWith", ExtendCustomFilterOperator2.CONTAINS = "contains", ExtendCustomFilterOperator2.DOES_NOT_CONTAIN = "doesNotContain", ExtendCustomFilterOperator2.EQUALS = "equals", ExtendCustomFilterOperator2.NOT_EQUALS = "notEquals", ExtendCustomFilterOperator2.EMPTY = "empty", ExtendCustomFilterOperator2.NOT_EMPTY = "notEmpty", ExtendCustomFilterOperator2.BETWEEN = "between", ExtendCustomFilterOperator2.NOT_BETWEEN = "notBetween", ExtendCustomFilterOperator2.CUSTOM = "custom", ExtendCustomFilterOperator2))(ExtendCustomFilterOperator || {}), FilterConditionItems;
|
|
18
|
+
((FilterConditionItems2) => {
|
|
19
|
+
FilterConditionItems2.NONE = {
|
|
18
20
|
label: "sheets-filter.conditions.none",
|
|
19
|
-
operator:
|
|
20
|
-
order:
|
|
21
|
+
operator: ExtendCustomFilterOperator.NONE,
|
|
22
|
+
order: OperatorOrder.SECOND,
|
|
21
23
|
numOfParameters: 0,
|
|
22
|
-
getDefaultFormParams: () => {
|
|
24
|
+
getDefaultFormParams: /* @__PURE__ */ __name(() => {
|
|
23
25
|
throw new Error("[FilterConditionItems.NONE]: should not have initial form params!");
|
|
24
|
-
},
|
|
25
|
-
testMappingParams: (
|
|
26
|
-
mapToFilterColumn: () => null,
|
|
27
|
-
testMappingFilterColumn: (
|
|
28
|
-
},
|
|
26
|
+
}, "getDefaultFormParams"),
|
|
27
|
+
testMappingParams: /* @__PURE__ */ __name((params) => params.operator1 === ExtendCustomFilterOperator.NONE, "testMappingParams"),
|
|
28
|
+
mapToFilterColumn: /* @__PURE__ */ __name(() => null, "mapToFilterColumn"),
|
|
29
|
+
testMappingFilterColumn: /* @__PURE__ */ __name((filterColumn) => !filterColumn.customFilters && !filterColumn.filters ? {} : !1, "testMappingFilterColumn")
|
|
30
|
+
}, FilterConditionItems2.EMPTY = {
|
|
29
31
|
label: "sheets-filter.conditions.empty",
|
|
30
|
-
operator:
|
|
31
|
-
order:
|
|
32
|
+
operator: ExtendCustomFilterOperator.EMPTY,
|
|
33
|
+
order: OperatorOrder.SECOND,
|
|
32
34
|
numOfParameters: 0,
|
|
33
|
-
getDefaultFormParams: () => {
|
|
35
|
+
getDefaultFormParams: /* @__PURE__ */ __name(() => {
|
|
34
36
|
throw new Error("[FilterConditionItems.EMPTY]: should not have initial form params!");
|
|
35
|
-
},
|
|
36
|
-
testMappingParams: ({ operator1
|
|
37
|
-
mapToFilterColumn: () => ({ customFilters: { customFilters: [{ val: "" }] } }),
|
|
38
|
-
testMappingFilterColumn: (
|
|
39
|
-
var
|
|
40
|
-
if (((
|
|
37
|
+
}, "getDefaultFormParams"),
|
|
38
|
+
testMappingParams: /* @__PURE__ */ __name(({ operator1 }) => operator1 === ExtendCustomFilterOperator.EMPTY, "testMappingParams"),
|
|
39
|
+
mapToFilterColumn: /* @__PURE__ */ __name(() => ({ customFilters: { customFilters: [{ val: "" }] } }), "mapToFilterColumn"),
|
|
40
|
+
testMappingFilterColumn: /* @__PURE__ */ __name((filterColumn) => {
|
|
41
|
+
var _a13;
|
|
42
|
+
if (((_a13 = filterColumn.customFilters) == null ? void 0 : _a13.customFilters.length) !== 1)
|
|
41
43
|
return !1;
|
|
42
|
-
const
|
|
43
|
-
return
|
|
44
|
-
}
|
|
45
|
-
},
|
|
44
|
+
const firstCustomFilter = filterColumn.customFilters.customFilters[0];
|
|
45
|
+
return firstCustomFilter.val === "" && firstCustomFilter.operator === void 0 ? { operator1: ExtendCustomFilterOperator.EMPTY } : !1;
|
|
46
|
+
}, "testMappingFilterColumn")
|
|
47
|
+
}, FilterConditionItems2.NOT_EMPTY = {
|
|
46
48
|
label: "sheets-filter.conditions.not-empty",
|
|
47
|
-
operator:
|
|
48
|
-
order:
|
|
49
|
+
operator: ExtendCustomFilterOperator.NOT_EMPTY,
|
|
50
|
+
order: OperatorOrder.SECOND,
|
|
49
51
|
numOfParameters: 0,
|
|
50
|
-
getDefaultFormParams: () => {
|
|
52
|
+
getDefaultFormParams: /* @__PURE__ */ __name(() => {
|
|
51
53
|
throw new Error("[FilterConditionItems.NOT_EMPTY]: should not have initial form params!");
|
|
52
|
-
},
|
|
53
|
-
testMappingParams: ({ operator1
|
|
54
|
-
mapToFilterColumn: () => ({ customFilters: { customFilters: [{ val: "", operator:
|
|
55
|
-
testMappingFilterColumn: (
|
|
56
|
-
var
|
|
57
|
-
if (((
|
|
54
|
+
}, "getDefaultFormParams"),
|
|
55
|
+
testMappingParams: /* @__PURE__ */ __name(({ operator1 }) => operator1 === ExtendCustomFilterOperator.NOT_EMPTY, "testMappingParams"),
|
|
56
|
+
mapToFilterColumn: /* @__PURE__ */ __name(() => ({ customFilters: { customFilters: [{ val: "", operator: CustomFilterOperator.NOT_EQUALS }] } }), "mapToFilterColumn"),
|
|
57
|
+
testMappingFilterColumn: /* @__PURE__ */ __name((filterColumn) => {
|
|
58
|
+
var _a13;
|
|
59
|
+
if (((_a13 = filterColumn.customFilters) == null ? void 0 : _a13.customFilters.length) !== 1)
|
|
58
60
|
return !1;
|
|
59
|
-
const
|
|
60
|
-
return
|
|
61
|
-
}
|
|
62
|
-
},
|
|
61
|
+
const firstCustomFilter = filterColumn.customFilters.customFilters[0];
|
|
62
|
+
return firstCustomFilter.val === " " && firstCustomFilter.operator === CustomFilterOperator.NOT_EQUALS ? { operator1: ExtendCustomFilterOperator.NOT_EMPTY } : !1;
|
|
63
|
+
}, "testMappingFilterColumn")
|
|
64
|
+
}, FilterConditionItems2.TEXT_CONTAINS = {
|
|
63
65
|
label: "sheets-filter.conditions.text-contains",
|
|
64
|
-
operator:
|
|
65
|
-
order:
|
|
66
|
+
operator: ExtendCustomFilterOperator.CONTAINS,
|
|
67
|
+
order: OperatorOrder.FIRST,
|
|
66
68
|
numOfParameters: 1,
|
|
67
|
-
getDefaultFormParams: () => ({ operator1:
|
|
68
|
-
testMappingParams: (
|
|
69
|
-
const [
|
|
70
|
-
return
|
|
71
|
-
},
|
|
72
|
-
mapToFilterColumn: (
|
|
73
|
-
const { val1
|
|
74
|
-
return
|
|
75
|
-
customFilters: { customFilters: [{ val: `*${
|
|
69
|
+
getDefaultFormParams: /* @__PURE__ */ __name(() => ({ operator1: ExtendCustomFilterOperator.CONTAINS, val1: "" }), "getDefaultFormParams"),
|
|
70
|
+
testMappingParams: /* @__PURE__ */ __name((params) => {
|
|
71
|
+
const [op] = getOnlyOperatorAndVal(params);
|
|
72
|
+
return op === ExtendCustomFilterOperator.CONTAINS;
|
|
73
|
+
}, "testMappingParams"),
|
|
74
|
+
mapToFilterColumn: /* @__PURE__ */ __name((mapParams) => {
|
|
75
|
+
const { val1 } = mapParams;
|
|
76
|
+
return val1 === "" ? null : {
|
|
77
|
+
customFilters: { customFilters: [{ val: `*${val1}*` }] }
|
|
76
78
|
};
|
|
77
|
-
},
|
|
78
|
-
testMappingFilterColumn: (
|
|
79
|
-
var
|
|
80
|
-
if (((
|
|
79
|
+
}, "mapToFilterColumn"),
|
|
80
|
+
testMappingFilterColumn: /* @__PURE__ */ __name((filterColumn) => {
|
|
81
|
+
var _a13;
|
|
82
|
+
if (((_a13 = filterColumn.customFilters) == null ? void 0 : _a13.customFilters.length) !== 1)
|
|
81
83
|
return !1;
|
|
82
|
-
const
|
|
83
|
-
return !
|
|
84
|
-
}
|
|
85
|
-
},
|
|
84
|
+
const firstCustomFilter = filterColumn.customFilters.customFilters[0], valAsString = firstCustomFilter.val.toString();
|
|
85
|
+
return !firstCustomFilter.operator && valAsString.startsWith("*") && valAsString.endsWith("*") ? { operator1: ExtendCustomFilterOperator.CONTAINS, val1: valAsString.slice(1, -1) } : !1;
|
|
86
|
+
}, "testMappingFilterColumn")
|
|
87
|
+
}, FilterConditionItems2.DOES_NOT_CONTAIN = {
|
|
86
88
|
label: "sheets-filter.conditions.does-not-contain",
|
|
87
|
-
operator:
|
|
88
|
-
order:
|
|
89
|
+
operator: ExtendCustomFilterOperator.DOES_NOT_CONTAIN,
|
|
90
|
+
order: OperatorOrder.FIRST,
|
|
89
91
|
numOfParameters: 1,
|
|
90
|
-
getDefaultFormParams: () => ({ operator1:
|
|
91
|
-
mapToFilterColumn: (
|
|
92
|
-
customFilters: { customFilters: [{ val: `*${
|
|
93
|
-
}),
|
|
94
|
-
testMappingParams: (
|
|
95
|
-
const [
|
|
96
|
-
return
|
|
97
|
-
},
|
|
98
|
-
testMappingFilterColumn: (
|
|
99
|
-
var
|
|
100
|
-
if (((
|
|
92
|
+
getDefaultFormParams: /* @__PURE__ */ __name(() => ({ operator1: ExtendCustomFilterOperator.DOES_NOT_CONTAIN, val1: "" }), "getDefaultFormParams"),
|
|
93
|
+
mapToFilterColumn: /* @__PURE__ */ __name((mapParams) => ({
|
|
94
|
+
customFilters: { customFilters: [{ val: `*${mapParams.val1}*`, operator: CustomFilterOperator.NOT_EQUALS }] }
|
|
95
|
+
}), "mapToFilterColumn"),
|
|
96
|
+
testMappingParams: /* @__PURE__ */ __name((params) => {
|
|
97
|
+
const [op] = getOnlyOperatorAndVal(params);
|
|
98
|
+
return op === ExtendCustomFilterOperator.DOES_NOT_CONTAIN;
|
|
99
|
+
}, "testMappingParams"),
|
|
100
|
+
testMappingFilterColumn: /* @__PURE__ */ __name((filterColumn) => {
|
|
101
|
+
var _a13;
|
|
102
|
+
if (((_a13 = filterColumn.customFilters) == null ? void 0 : _a13.customFilters.length) !== 1)
|
|
101
103
|
return !1;
|
|
102
|
-
const
|
|
103
|
-
return
|
|
104
|
-
}
|
|
105
|
-
},
|
|
104
|
+
const firstCustomFilter = filterColumn.customFilters.customFilters[0], valAsString = firstCustomFilter.val.toString();
|
|
105
|
+
return firstCustomFilter.operator === CustomFilterOperator.NOT_EQUALS && valAsString.startsWith("*") && valAsString.endsWith("*") ? { operator1: ExtendCustomFilterOperator.DOES_NOT_CONTAIN, val1: valAsString.slice(1, -1) } : !1;
|
|
106
|
+
}, "testMappingFilterColumn")
|
|
107
|
+
}, FilterConditionItems2.STARTS_WITH = {
|
|
106
108
|
label: "sheets-filter.conditions.starts-with",
|
|
107
|
-
operator:
|
|
108
|
-
order:
|
|
109
|
+
operator: ExtendCustomFilterOperator.STARTS_WITH,
|
|
110
|
+
order: OperatorOrder.FIRST,
|
|
109
111
|
numOfParameters: 1,
|
|
110
|
-
getDefaultFormParams: () => ({ operator1:
|
|
111
|
-
mapToFilterColumn: (
|
|
112
|
-
customFilters: { customFilters: [{ val: `${
|
|
113
|
-
}),
|
|
114
|
-
testMappingParams: (
|
|
115
|
-
const [
|
|
116
|
-
return
|
|
117
|
-
},
|
|
118
|
-
testMappingFilterColumn: (
|
|
119
|
-
var
|
|
120
|
-
if (((
|
|
112
|
+
getDefaultFormParams: /* @__PURE__ */ __name(() => ({ operator1: ExtendCustomFilterOperator.STARTS_WITH, val1: "" }), "getDefaultFormParams"),
|
|
113
|
+
mapToFilterColumn: /* @__PURE__ */ __name((mapParams) => ({
|
|
114
|
+
customFilters: { customFilters: [{ val: `${mapParams.val1}*` }] }
|
|
115
|
+
}), "mapToFilterColumn"),
|
|
116
|
+
testMappingParams: /* @__PURE__ */ __name((params) => {
|
|
117
|
+
const [op] = getOnlyOperatorAndVal(params);
|
|
118
|
+
return op === ExtendCustomFilterOperator.STARTS_WITH;
|
|
119
|
+
}, "testMappingParams"),
|
|
120
|
+
testMappingFilterColumn: /* @__PURE__ */ __name((filterColumn) => {
|
|
121
|
+
var _a13;
|
|
122
|
+
if (((_a13 = filterColumn.customFilters) == null ? void 0 : _a13.customFilters.length) !== 1)
|
|
121
123
|
return !1;
|
|
122
|
-
const
|
|
123
|
-
return !
|
|
124
|
-
}
|
|
125
|
-
},
|
|
124
|
+
const firstCustomFilter = filterColumn.customFilters.customFilters[0], valAsString = firstCustomFilter.val.toString();
|
|
125
|
+
return !firstCustomFilter.operator && valAsString.endsWith("*") && !valAsString.startsWith("*") ? { operator1: ExtendCustomFilterOperator.STARTS_WITH, val1: valAsString.slice(0, -1) } : !1;
|
|
126
|
+
}, "testMappingFilterColumn")
|
|
127
|
+
}, FilterConditionItems2.ENDS_WITH = {
|
|
126
128
|
label: "sheets-filter.conditions.ends-with",
|
|
127
|
-
operator:
|
|
128
|
-
order:
|
|
129
|
+
operator: ExtendCustomFilterOperator.ENDS_WITH,
|
|
130
|
+
order: OperatorOrder.FIRST,
|
|
129
131
|
numOfParameters: 1,
|
|
130
|
-
getDefaultFormParams: () => ({ operator1:
|
|
131
|
-
mapToFilterColumn: (
|
|
132
|
-
customFilters: { customFilters: [{ val: `*${
|
|
133
|
-
}),
|
|
134
|
-
testMappingParams: (
|
|
135
|
-
const [
|
|
136
|
-
return
|
|
137
|
-
},
|
|
138
|
-
testMappingFilterColumn: (
|
|
139
|
-
var
|
|
140
|
-
if (((
|
|
132
|
+
getDefaultFormParams: /* @__PURE__ */ __name(() => ({ operator1: ExtendCustomFilterOperator.ENDS_WITH, val1: "" }), "getDefaultFormParams"),
|
|
133
|
+
mapToFilterColumn: /* @__PURE__ */ __name((mapParams) => ({
|
|
134
|
+
customFilters: { customFilters: [{ val: `*${mapParams.val1}` }] }
|
|
135
|
+
}), "mapToFilterColumn"),
|
|
136
|
+
testMappingParams: /* @__PURE__ */ __name((params) => {
|
|
137
|
+
const [op] = getOnlyOperatorAndVal(params);
|
|
138
|
+
return op === ExtendCustomFilterOperator.ENDS_WITH;
|
|
139
|
+
}, "testMappingParams"),
|
|
140
|
+
testMappingFilterColumn: /* @__PURE__ */ __name((filterColumn) => {
|
|
141
|
+
var _a13;
|
|
142
|
+
if (((_a13 = filterColumn.customFilters) == null ? void 0 : _a13.customFilters.length) !== 1)
|
|
141
143
|
return !1;
|
|
142
|
-
const
|
|
143
|
-
return !
|
|
144
|
-
}
|
|
145
|
-
},
|
|
144
|
+
const firstCustomFilter = filterColumn.customFilters.customFilters[0], valAsString = firstCustomFilter.val.toString();
|
|
145
|
+
return !firstCustomFilter.operator && valAsString.startsWith("*") && !valAsString.endsWith("*") ? { operator1: ExtendCustomFilterOperator.ENDS_WITH, val1: valAsString.slice(1) } : !1;
|
|
146
|
+
}, "testMappingFilterColumn")
|
|
147
|
+
}, FilterConditionItems2.EQUALS = {
|
|
146
148
|
label: "sheets-filter.conditions.equals",
|
|
147
|
-
operator:
|
|
148
|
-
order:
|
|
149
|
+
operator: ExtendCustomFilterOperator.EQUALS,
|
|
150
|
+
order: OperatorOrder.FIRST,
|
|
149
151
|
numOfParameters: 1,
|
|
150
|
-
getDefaultFormParams: () => ({ operator1:
|
|
151
|
-
testMappingParams: (
|
|
152
|
-
const [
|
|
153
|
-
return
|
|
154
|
-
},
|
|
155
|
-
mapToFilterColumn: (
|
|
156
|
-
const { val1
|
|
157
|
-
return
|
|
158
|
-
customFilters: { customFilters: [{ val:
|
|
152
|
+
getDefaultFormParams: /* @__PURE__ */ __name(() => ({ operator1: ExtendCustomFilterOperator.EQUALS, val1: "" }), "getDefaultFormParams"),
|
|
153
|
+
testMappingParams: /* @__PURE__ */ __name((params) => {
|
|
154
|
+
const [op] = getOnlyOperatorAndVal(params);
|
|
155
|
+
return op === ExtendCustomFilterOperator.EQUALS;
|
|
156
|
+
}, "testMappingParams"),
|
|
157
|
+
mapToFilterColumn: /* @__PURE__ */ __name((mapParams) => {
|
|
158
|
+
const { val1 } = mapParams;
|
|
159
|
+
return val1 === "" ? null : {
|
|
160
|
+
customFilters: { customFilters: [{ val: val1 }] }
|
|
159
161
|
};
|
|
160
|
-
},
|
|
161
|
-
testMappingFilterColumn: (
|
|
162
|
-
var
|
|
163
|
-
return ((
|
|
164
|
-
}
|
|
165
|
-
},
|
|
162
|
+
}, "mapToFilterColumn"),
|
|
163
|
+
testMappingFilterColumn: /* @__PURE__ */ __name((filterColumn) => {
|
|
164
|
+
var _a13, _b, _c;
|
|
165
|
+
return ((_b = (_a13 = filterColumn.filters) == null ? void 0 : _a13.filters) == null ? void 0 : _b.length) === 1 ? { operator1: ExtendCustomFilterOperator.EQUALS, val1: "" } : ((_c = filterColumn.customFilters) == null ? void 0 : _c.customFilters.length) === 1 && !filterColumn.customFilters.customFilters[0].operator ? { operator1: ExtendCustomFilterOperator.EQUALS, val1: filterColumn.customFilters.customFilters[0].val.toString() } : !1;
|
|
166
|
+
}, "testMappingFilterColumn")
|
|
167
|
+
}, FilterConditionItems2.GREATER_THAN = {
|
|
166
168
|
label: "sheets-filter.conditions.greater-than",
|
|
167
|
-
operator:
|
|
169
|
+
operator: CustomFilterOperator.GREATER_THAN,
|
|
168
170
|
numOfParameters: 1,
|
|
169
|
-
order:
|
|
170
|
-
getDefaultFormParams: () => ({ operator1:
|
|
171
|
-
mapToFilterColumn: (
|
|
172
|
-
customFilters: { customFilters: [{ val:
|
|
173
|
-
}),
|
|
174
|
-
testMappingParams: (
|
|
175
|
-
const [
|
|
176
|
-
return
|
|
177
|
-
},
|
|
178
|
-
testMappingFilterColumn: (
|
|
179
|
-
var
|
|
180
|
-
if (((
|
|
171
|
+
order: OperatorOrder.FIRST,
|
|
172
|
+
getDefaultFormParams: /* @__PURE__ */ __name(() => ({ operator1: CustomFilterOperator.GREATER_THAN, val1: "" }), "getDefaultFormParams"),
|
|
173
|
+
mapToFilterColumn: /* @__PURE__ */ __name((mapParams) => ({
|
|
174
|
+
customFilters: { customFilters: [{ val: mapParams.val1, operator: CustomFilterOperator.GREATER_THAN }] }
|
|
175
|
+
}), "mapToFilterColumn"),
|
|
176
|
+
testMappingParams: /* @__PURE__ */ __name((params) => {
|
|
177
|
+
const [op] = getOnlyOperatorAndVal(params);
|
|
178
|
+
return op === CustomFilterOperator.GREATER_THAN;
|
|
179
|
+
}, "testMappingParams"),
|
|
180
|
+
testMappingFilterColumn: /* @__PURE__ */ __name((filterColumn) => {
|
|
181
|
+
var _a13;
|
|
182
|
+
if (((_a13 = filterColumn.customFilters) == null ? void 0 : _a13.customFilters.length) !== 1)
|
|
181
183
|
return !1;
|
|
182
|
-
const
|
|
183
|
-
return
|
|
184
|
-
}
|
|
185
|
-
},
|
|
184
|
+
const firstCustomFilter = filterColumn.customFilters.customFilters[0];
|
|
185
|
+
return firstCustomFilter.operator !== CustomFilterOperator.GREATER_THAN ? !1 : { operator1: CustomFilterOperator.GREATER_THAN, val1: firstCustomFilter.val.toString() };
|
|
186
|
+
}, "testMappingFilterColumn")
|
|
187
|
+
}, FilterConditionItems2.GREATER_THAN_OR_EQUAL = {
|
|
186
188
|
label: "sheets-filter.conditions.greater-than-or-equal",
|
|
187
|
-
operator:
|
|
189
|
+
operator: CustomFilterOperator.GREATER_THAN_OR_EQUAL,
|
|
188
190
|
numOfParameters: 1,
|
|
189
|
-
order:
|
|
190
|
-
getDefaultFormParams: () => ({ operator1:
|
|
191
|
-
testMappingParams: (
|
|
192
|
-
const [
|
|
193
|
-
return
|
|
194
|
-
},
|
|
195
|
-
mapToFilterColumn: (
|
|
196
|
-
customFilters: { customFilters: [{ val:
|
|
197
|
-
}),
|
|
198
|
-
testMappingFilterColumn: (
|
|
199
|
-
var
|
|
200
|
-
if (((
|
|
191
|
+
order: OperatorOrder.FIRST,
|
|
192
|
+
getDefaultFormParams: /* @__PURE__ */ __name(() => ({ operator1: CustomFilterOperator.GREATER_THAN_OR_EQUAL, val1: "" }), "getDefaultFormParams"),
|
|
193
|
+
testMappingParams: /* @__PURE__ */ __name((params) => {
|
|
194
|
+
const [op] = getOnlyOperatorAndVal(params);
|
|
195
|
+
return op === CustomFilterOperator.GREATER_THAN_OR_EQUAL;
|
|
196
|
+
}, "testMappingParams"),
|
|
197
|
+
mapToFilterColumn: /* @__PURE__ */ __name((mapParams) => ({
|
|
198
|
+
customFilters: { customFilters: [{ val: mapParams.val1, operator: CustomFilterOperator.GREATER_THAN_OR_EQUAL }] }
|
|
199
|
+
}), "mapToFilterColumn"),
|
|
200
|
+
testMappingFilterColumn: /* @__PURE__ */ __name((filterColumn) => {
|
|
201
|
+
var _a13;
|
|
202
|
+
if (((_a13 = filterColumn.customFilters) == null ? void 0 : _a13.customFilters.length) !== 1)
|
|
201
203
|
return !1;
|
|
202
|
-
const
|
|
203
|
-
return
|
|
204
|
-
}
|
|
205
|
-
},
|
|
204
|
+
const firstCustomFilter = filterColumn.customFilters.customFilters[0];
|
|
205
|
+
return firstCustomFilter.operator !== CustomFilterOperator.GREATER_THAN_OR_EQUAL ? !1 : { operator1: CustomFilterOperator.GREATER_THAN_OR_EQUAL, val1: firstCustomFilter.val.toString() };
|
|
206
|
+
}, "testMappingFilterColumn")
|
|
207
|
+
}, FilterConditionItems2.LESS_THAN = {
|
|
206
208
|
label: "sheets-filter.conditions.less-than",
|
|
207
|
-
operator:
|
|
209
|
+
operator: CustomFilterOperator.LESS_THAN,
|
|
208
210
|
numOfParameters: 1,
|
|
209
|
-
order:
|
|
210
|
-
getDefaultFormParams: () => ({ operator1:
|
|
211
|
-
testMappingParams: (
|
|
212
|
-
const [
|
|
213
|
-
return
|
|
214
|
-
},
|
|
215
|
-
mapToFilterColumn: (
|
|
216
|
-
customFilters: { customFilters: [{ val:
|
|
217
|
-
}),
|
|
218
|
-
testMappingFilterColumn: (
|
|
219
|
-
var
|
|
220
|
-
if (((
|
|
211
|
+
order: OperatorOrder.FIRST,
|
|
212
|
+
getDefaultFormParams: /* @__PURE__ */ __name(() => ({ operator1: CustomFilterOperator.LESS_THAN, val1: "" }), "getDefaultFormParams"),
|
|
213
|
+
testMappingParams: /* @__PURE__ */ __name((params) => {
|
|
214
|
+
const [op] = getOnlyOperatorAndVal(params);
|
|
215
|
+
return op === CustomFilterOperator.LESS_THAN;
|
|
216
|
+
}, "testMappingParams"),
|
|
217
|
+
mapToFilterColumn: /* @__PURE__ */ __name((mapParams) => ({
|
|
218
|
+
customFilters: { customFilters: [{ val: mapParams.val1, operator: CustomFilterOperator.LESS_THAN }] }
|
|
219
|
+
}), "mapToFilterColumn"),
|
|
220
|
+
testMappingFilterColumn: /* @__PURE__ */ __name((filterColumn) => {
|
|
221
|
+
var _a13;
|
|
222
|
+
if (((_a13 = filterColumn.customFilters) == null ? void 0 : _a13.customFilters.length) !== 1)
|
|
221
223
|
return !1;
|
|
222
|
-
const
|
|
223
|
-
return
|
|
224
|
-
}
|
|
225
|
-
},
|
|
224
|
+
const firstCustomFilter = filterColumn.customFilters.customFilters[0];
|
|
225
|
+
return firstCustomFilter.operator !== CustomFilterOperator.LESS_THAN ? !1 : { operator1: CustomFilterOperator.LESS_THAN, val1: firstCustomFilter.val.toString() };
|
|
226
|
+
}, "testMappingFilterColumn")
|
|
227
|
+
}, FilterConditionItems2.LESS_THAN_OR_EQUAL = {
|
|
226
228
|
label: "sheets-filter.conditions.less-than-or-equal",
|
|
227
|
-
operator:
|
|
229
|
+
operator: CustomFilterOperator.LESS_THAN_OR_EQUAL,
|
|
228
230
|
numOfParameters: 1,
|
|
229
|
-
order:
|
|
230
|
-
getDefaultFormParams: () => ({ operator1:
|
|
231
|
-
testMappingParams: (
|
|
232
|
-
const [
|
|
233
|
-
return
|
|
234
|
-
},
|
|
235
|
-
mapToFilterColumn: (
|
|
236
|
-
customFilters: { customFilters: [{ val:
|
|
237
|
-
}),
|
|
238
|
-
testMappingFilterColumn: (
|
|
239
|
-
var
|
|
240
|
-
if (((
|
|
231
|
+
order: OperatorOrder.FIRST,
|
|
232
|
+
getDefaultFormParams: /* @__PURE__ */ __name(() => ({ operator1: CustomFilterOperator.LESS_THAN_OR_EQUAL, val1: "" }), "getDefaultFormParams"),
|
|
233
|
+
testMappingParams: /* @__PURE__ */ __name((params) => {
|
|
234
|
+
const [op] = getOnlyOperatorAndVal(params);
|
|
235
|
+
return op === CustomFilterOperator.LESS_THAN_OR_EQUAL;
|
|
236
|
+
}, "testMappingParams"),
|
|
237
|
+
mapToFilterColumn: /* @__PURE__ */ __name((mapParams) => ({
|
|
238
|
+
customFilters: { customFilters: [{ val: mapParams.val1, operator: CustomFilterOperator.LESS_THAN_OR_EQUAL }] }
|
|
239
|
+
}), "mapToFilterColumn"),
|
|
240
|
+
testMappingFilterColumn: /* @__PURE__ */ __name((filterColumn) => {
|
|
241
|
+
var _a13;
|
|
242
|
+
if (((_a13 = filterColumn.customFilters) == null ? void 0 : _a13.customFilters.length) !== 1)
|
|
241
243
|
return !1;
|
|
242
|
-
const
|
|
243
|
-
return
|
|
244
|
-
}
|
|
245
|
-
},
|
|
244
|
+
const firstCustomFilter = filterColumn.customFilters.customFilters[0];
|
|
245
|
+
return firstCustomFilter.operator !== CustomFilterOperator.LESS_THAN_OR_EQUAL ? !1 : { operator1: CustomFilterOperator.LESS_THAN_OR_EQUAL, val1: firstCustomFilter.val.toString() };
|
|
246
|
+
}, "testMappingFilterColumn")
|
|
247
|
+
}, FilterConditionItems2.EQUAL = {
|
|
246
248
|
label: "sheets-filter.conditions.equal",
|
|
247
|
-
operator:
|
|
249
|
+
operator: CustomFilterOperator.EQUAL,
|
|
248
250
|
numOfParameters: 1,
|
|
249
|
-
order:
|
|
250
|
-
getDefaultFormParams: () => ({ operator1:
|
|
251
|
-
testMappingParams: (
|
|
252
|
-
const [
|
|
253
|
-
return
|
|
254
|
-
},
|
|
255
|
-
mapToFilterColumn: (
|
|
256
|
-
customFilters: { customFilters: [{ val:
|
|
257
|
-
}),
|
|
258
|
-
testMappingFilterColumn: (
|
|
259
|
-
var
|
|
260
|
-
if (((
|
|
251
|
+
order: OperatorOrder.FIRST,
|
|
252
|
+
getDefaultFormParams: /* @__PURE__ */ __name(() => ({ operator1: CustomFilterOperator.EQUAL, val1: "" }), "getDefaultFormParams"),
|
|
253
|
+
testMappingParams: /* @__PURE__ */ __name((params) => {
|
|
254
|
+
const [op] = getOnlyOperatorAndVal(params);
|
|
255
|
+
return op === CustomFilterOperator.EQUAL;
|
|
256
|
+
}, "testMappingParams"),
|
|
257
|
+
mapToFilterColumn: /* @__PURE__ */ __name((mapParams) => ({
|
|
258
|
+
customFilters: { customFilters: [{ val: mapParams.val1, operator: CustomFilterOperator.EQUAL }] }
|
|
259
|
+
}), "mapToFilterColumn"),
|
|
260
|
+
testMappingFilterColumn: /* @__PURE__ */ __name((filterColumn) => {
|
|
261
|
+
var _a13;
|
|
262
|
+
if (((_a13 = filterColumn.customFilters) == null ? void 0 : _a13.customFilters.length) !== 1)
|
|
261
263
|
return !1;
|
|
262
|
-
const
|
|
263
|
-
return
|
|
264
|
-
}
|
|
265
|
-
},
|
|
264
|
+
const firstCustomFilter = filterColumn.customFilters.customFilters[0];
|
|
265
|
+
return firstCustomFilter.operator !== CustomFilterOperator.EQUAL ? !1 : { operator1: CustomFilterOperator.EQUAL, val1: firstCustomFilter.val.toString() };
|
|
266
|
+
}, "testMappingFilterColumn")
|
|
267
|
+
}, FilterConditionItems2.NOT_EQUAL = {
|
|
266
268
|
label: "sheets-filter.conditions.not-equal",
|
|
267
|
-
operator:
|
|
269
|
+
operator: CustomFilterOperator.NOT_EQUALS,
|
|
268
270
|
numOfParameters: 1,
|
|
269
|
-
order:
|
|
270
|
-
getDefaultFormParams: () => ({ operator1:
|
|
271
|
-
testMappingParams: (
|
|
272
|
-
const [
|
|
273
|
-
return
|
|
274
|
-
},
|
|
275
|
-
mapToFilterColumn: (
|
|
276
|
-
customFilters: { customFilters: [{ val:
|
|
277
|
-
}),
|
|
278
|
-
testMappingFilterColumn: (
|
|
279
|
-
var
|
|
280
|
-
if (((
|
|
271
|
+
order: OperatorOrder.FIRST,
|
|
272
|
+
getDefaultFormParams: /* @__PURE__ */ __name(() => ({ operator1: CustomFilterOperator.NOT_EQUALS, val1: "" }), "getDefaultFormParams"),
|
|
273
|
+
testMappingParams: /* @__PURE__ */ __name((params) => {
|
|
274
|
+
const [op] = getOnlyOperatorAndVal(params);
|
|
275
|
+
return op === CustomFilterOperator.NOT_EQUALS;
|
|
276
|
+
}, "testMappingParams"),
|
|
277
|
+
mapToFilterColumn: /* @__PURE__ */ __name((mapParams) => ({
|
|
278
|
+
customFilters: { customFilters: [{ val: mapParams.val1, operator: CustomFilterOperator.NOT_EQUALS }] }
|
|
279
|
+
}), "mapToFilterColumn"),
|
|
280
|
+
testMappingFilterColumn: /* @__PURE__ */ __name((filterColumn) => {
|
|
281
|
+
var _a13;
|
|
282
|
+
if (((_a13 = filterColumn.customFilters) == null ? void 0 : _a13.customFilters.length) !== 1)
|
|
281
283
|
return !1;
|
|
282
|
-
const
|
|
283
|
-
return
|
|
284
|
-
}
|
|
285
|
-
},
|
|
284
|
+
const firstCustomFilter = filterColumn.customFilters.customFilters[0];
|
|
285
|
+
return firstCustomFilter.operator !== CustomFilterOperator.NOT_EQUALS ? !1 : { operator1: CustomFilterOperator.NOT_EQUALS, val1: firstCustomFilter.val.toString() };
|
|
286
|
+
}, "testMappingFilterColumn")
|
|
287
|
+
}, FilterConditionItems2.BETWEEN = {
|
|
286
288
|
label: "sheets-filter.conditions.between",
|
|
287
|
-
operator:
|
|
288
|
-
order:
|
|
289
|
+
operator: ExtendCustomFilterOperator.BETWEEN,
|
|
290
|
+
order: OperatorOrder.SECOND,
|
|
289
291
|
numOfParameters: 2,
|
|
290
|
-
getDefaultFormParams: () => ({
|
|
292
|
+
getDefaultFormParams: /* @__PURE__ */ __name(() => ({
|
|
291
293
|
and: !0,
|
|
292
|
-
operator1:
|
|
294
|
+
operator1: CustomFilterOperator.GREATER_THAN_OR_EQUAL,
|
|
293
295
|
val1: "",
|
|
294
|
-
operator2:
|
|
296
|
+
operator2: CustomFilterOperator.LESS_THAN_OR_EQUAL,
|
|
295
297
|
val2: ""
|
|
296
|
-
}),
|
|
297
|
-
testMappingParams: (
|
|
298
|
-
const { and
|
|
299
|
-
if (!
|
|
300
|
-
const
|
|
301
|
-
return
|
|
302
|
-
},
|
|
303
|
-
mapToFilterColumn: (
|
|
304
|
-
const { val1
|
|
298
|
+
}), "getDefaultFormParams"),
|
|
299
|
+
testMappingParams: /* @__PURE__ */ __name((params) => {
|
|
300
|
+
const { and, operator1, operator2 } = params;
|
|
301
|
+
if (!and) return !1;
|
|
302
|
+
const operators = [operator1, operator2];
|
|
303
|
+
return operators.includes(CustomFilterOperator.GREATER_THAN_OR_EQUAL) && operators.includes(CustomFilterOperator.LESS_THAN_OR_EQUAL);
|
|
304
|
+
}, "testMappingParams"),
|
|
305
|
+
mapToFilterColumn: /* @__PURE__ */ __name((mapParams) => {
|
|
306
|
+
const { val1, val2, operator1 } = mapParams, operator1IsGreater = operator1 === CustomFilterOperator.GREATER_THAN_OR_EQUAL;
|
|
305
307
|
return {
|
|
306
308
|
customFilters: {
|
|
307
|
-
and:
|
|
309
|
+
and: BooleanNumber.TRUE,
|
|
308
310
|
customFilters: [
|
|
309
|
-
{ val:
|
|
310
|
-
{ val:
|
|
311
|
+
{ val: operator1IsGreater ? val1 : val2, operator: CustomFilterOperator.GREATER_THAN_OR_EQUAL },
|
|
312
|
+
{ val: operator1IsGreater ? val2 : val1, operator: CustomFilterOperator.LESS_THAN_OR_EQUAL }
|
|
311
313
|
]
|
|
312
314
|
}
|
|
313
315
|
};
|
|
314
|
-
},
|
|
315
|
-
testMappingFilterColumn: (
|
|
316
|
-
var
|
|
317
|
-
if (((
|
|
316
|
+
}, "mapToFilterColumn"),
|
|
317
|
+
testMappingFilterColumn: /* @__PURE__ */ __name((filterColumn) => {
|
|
318
|
+
var _a13;
|
|
319
|
+
if (((_a13 = filterColumn.customFilters) == null ? void 0 : _a13.customFilters.length) !== 2)
|
|
318
320
|
return !1;
|
|
319
|
-
const [
|
|
320
|
-
return
|
|
321
|
+
const [firstCustomFilter, secondCustomFilter] = filterColumn.customFilters.customFilters;
|
|
322
|
+
return firstCustomFilter.operator === CustomFilterOperator.GREATER_THAN_OR_EQUAL && secondCustomFilter.operator === CustomFilterOperator.LESS_THAN_OR_EQUAL && filterColumn.customFilters.and ? {
|
|
321
323
|
and: !0,
|
|
322
|
-
operator1:
|
|
323
|
-
val1:
|
|
324
|
-
operator2:
|
|
325
|
-
val2:
|
|
326
|
-
} :
|
|
324
|
+
operator1: CustomFilterOperator.GREATER_THAN_OR_EQUAL,
|
|
325
|
+
val1: firstCustomFilter.val.toString(),
|
|
326
|
+
operator2: CustomFilterOperator.LESS_THAN_OR_EQUAL,
|
|
327
|
+
val2: secondCustomFilter.val.toString()
|
|
328
|
+
} : secondCustomFilter.operator === CustomFilterOperator.GREATER_THAN_OR_EQUAL && firstCustomFilter.operator === CustomFilterOperator.LESS_THAN_OR_EQUAL && filterColumn.customFilters.and ? {
|
|
327
329
|
and: !0,
|
|
328
|
-
operator1:
|
|
329
|
-
val1:
|
|
330
|
-
operator2:
|
|
331
|
-
val2:
|
|
330
|
+
operator1: CustomFilterOperator.GREATER_THAN_OR_EQUAL,
|
|
331
|
+
val1: secondCustomFilter.val.toString(),
|
|
332
|
+
operator2: CustomFilterOperator.LESS_THAN_OR_EQUAL,
|
|
333
|
+
val2: firstCustomFilter.val.toLocaleString()
|
|
332
334
|
} : !1;
|
|
333
|
-
}
|
|
334
|
-
},
|
|
335
|
+
}, "testMappingFilterColumn")
|
|
336
|
+
}, FilterConditionItems2.NOT_BETWEEN = {
|
|
335
337
|
label: "sheets-filter.conditions.not-between",
|
|
336
|
-
operator:
|
|
337
|
-
order:
|
|
338
|
+
operator: ExtendCustomFilterOperator.NOT_BETWEEN,
|
|
339
|
+
order: OperatorOrder.SECOND,
|
|
338
340
|
numOfParameters: 2,
|
|
339
|
-
getDefaultFormParams: () => ({
|
|
340
|
-
operator1:
|
|
341
|
+
getDefaultFormParams: /* @__PURE__ */ __name(() => ({
|
|
342
|
+
operator1: CustomFilterOperator.LESS_THAN,
|
|
341
343
|
val1: "",
|
|
342
|
-
operator2:
|
|
344
|
+
operator2: CustomFilterOperator.GREATER_THAN,
|
|
343
345
|
val2: ""
|
|
344
|
-
}),
|
|
345
|
-
testMappingParams: (
|
|
346
|
-
const { and
|
|
347
|
-
if (
|
|
348
|
-
const
|
|
349
|
-
return
|
|
350
|
-
},
|
|
351
|
-
mapToFilterColumn: (
|
|
352
|
-
const { val1
|
|
346
|
+
}), "getDefaultFormParams"),
|
|
347
|
+
testMappingParams: /* @__PURE__ */ __name((params) => {
|
|
348
|
+
const { and, operator1, operator2 } = params;
|
|
349
|
+
if (and) return !1;
|
|
350
|
+
const operators = [operator1, operator2];
|
|
351
|
+
return operators.includes(CustomFilterOperator.GREATER_THAN) && operators.includes(CustomFilterOperator.LESS_THAN);
|
|
352
|
+
}, "testMappingParams"),
|
|
353
|
+
mapToFilterColumn: /* @__PURE__ */ __name((mapParams) => {
|
|
354
|
+
const { val1, val2, operator1 } = mapParams, operator1IsGreater = operator1 === CustomFilterOperator.GREATER_THAN;
|
|
353
355
|
return {
|
|
354
356
|
customFilters: {
|
|
355
357
|
customFilters: [
|
|
356
|
-
{ val:
|
|
357
|
-
{ val:
|
|
358
|
+
{ val: operator1IsGreater ? val1 : val2, operator: CustomFilterOperator.GREATER_THAN },
|
|
359
|
+
{ val: operator1IsGreater ? val2 : val1, operator: CustomFilterOperator.LESS_THAN }
|
|
358
360
|
]
|
|
359
361
|
}
|
|
360
362
|
};
|
|
361
|
-
},
|
|
362
|
-
testMappingFilterColumn: (
|
|
363
|
-
var
|
|
364
|
-
if (((
|
|
363
|
+
}, "mapToFilterColumn"),
|
|
364
|
+
testMappingFilterColumn: /* @__PURE__ */ __name((filterColumn) => {
|
|
365
|
+
var _a13;
|
|
366
|
+
if (((_a13 = filterColumn.customFilters) == null ? void 0 : _a13.customFilters.length) !== 2)
|
|
365
367
|
return !1;
|
|
366
|
-
const [
|
|
367
|
-
return
|
|
368
|
-
operator1:
|
|
369
|
-
val1:
|
|
370
|
-
operator2:
|
|
371
|
-
val2:
|
|
372
|
-
} :
|
|
373
|
-
operator1:
|
|
374
|
-
val1:
|
|
375
|
-
operator2:
|
|
376
|
-
val2:
|
|
368
|
+
const [firstCustomFilter, secondCustomFilter] = filterColumn.customFilters.customFilters;
|
|
369
|
+
return firstCustomFilter.operator === CustomFilterOperator.LESS_THAN && secondCustomFilter.operator === CustomFilterOperator.GREATER_THAN && !filterColumn.customFilters.and ? {
|
|
370
|
+
operator1: CustomFilterOperator.LESS_THAN,
|
|
371
|
+
val1: firstCustomFilter.val.toString(),
|
|
372
|
+
operator2: CustomFilterOperator.GREATER_THAN,
|
|
373
|
+
val2: secondCustomFilter.val.toString()
|
|
374
|
+
} : secondCustomFilter.operator === CustomFilterOperator.LESS_THAN && firstCustomFilter.operator === CustomFilterOperator.GREATER_THAN && !filterColumn.customFilters.and ? {
|
|
375
|
+
operator1: CustomFilterOperator.GREATER_THAN,
|
|
376
|
+
val1: secondCustomFilter.val.toString(),
|
|
377
|
+
operator2: CustomFilterOperator.LESS_THAN,
|
|
378
|
+
val2: firstCustomFilter.val.toLocaleString()
|
|
377
379
|
} : !1;
|
|
378
|
-
}
|
|
379
|
-
},
|
|
380
|
+
}, "testMappingFilterColumn")
|
|
381
|
+
}, FilterConditionItems2.CUSTOM = {
|
|
380
382
|
label: "sheets-filter.conditions.custom",
|
|
381
|
-
operator:
|
|
382
|
-
order:
|
|
383
|
+
operator: ExtendCustomFilterOperator.CUSTOM,
|
|
384
|
+
order: OperatorOrder.SECOND,
|
|
383
385
|
numOfParameters: 2,
|
|
384
|
-
getDefaultFormParams: () => ({
|
|
385
|
-
operator1:
|
|
386
|
+
getDefaultFormParams: /* @__PURE__ */ __name(() => ({
|
|
387
|
+
operator1: ExtendCustomFilterOperator.NONE,
|
|
386
388
|
val1: "",
|
|
387
|
-
operator2:
|
|
389
|
+
operator2: ExtendCustomFilterOperator.NONE,
|
|
388
390
|
val2: ""
|
|
389
|
-
}),
|
|
390
|
-
testMappingParams: () => !0,
|
|
391
|
-
mapToFilterColumn: (
|
|
392
|
-
const { and
|
|
393
|
-
function
|
|
394
|
-
for (const
|
|
395
|
-
if (
|
|
396
|
-
return
|
|
391
|
+
}), "getDefaultFormParams"),
|
|
392
|
+
testMappingParams: /* @__PURE__ */ __name(() => !0, "testMappingParams"),
|
|
393
|
+
mapToFilterColumn: /* @__PURE__ */ __name((mapParams) => {
|
|
394
|
+
const { and, val1, val2, operator1, operator2 } = mapParams;
|
|
395
|
+
function mapOperator(operator, val) {
|
|
396
|
+
for (const condition of FilterConditionItems2.ALL_CONDITIONS)
|
|
397
|
+
if (condition.operator === operator)
|
|
398
|
+
return condition.mapToFilterColumn({ val1: val, operator1: operator });
|
|
397
399
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
400
|
+
__name(mapOperator, "mapOperator");
|
|
401
|
+
const operator1IsNone = !operator1 || operator1 === FilterConditionItems2.NONE.operator, operator2IsNone = !operator2 || operator2 === FilterConditionItems2.NONE.operator;
|
|
402
|
+
if (operator1IsNone && operator2IsNone)
|
|
403
|
+
return FilterConditionItems2.NONE.mapToFilterColumn({});
|
|
404
|
+
if (operator1IsNone)
|
|
405
|
+
return mapOperator(operator2, val2);
|
|
406
|
+
if (operator2IsNone)
|
|
407
|
+
return mapOperator(operator1, val1);
|
|
408
|
+
const mappedCustomFilter1 = mapOperator(operator1, val1), mappedCustomFilter2 = mapOperator(operator2, val2), customFilters = {
|
|
406
409
|
customFilters: [
|
|
407
|
-
|
|
408
|
-
|
|
410
|
+
mappedCustomFilter1.customFilters.customFilters[0],
|
|
411
|
+
mappedCustomFilter2.customFilters.customFilters[0]
|
|
409
412
|
]
|
|
410
413
|
};
|
|
411
|
-
return
|
|
412
|
-
},
|
|
413
|
-
testMappingFilterColumn: (
|
|
414
|
-
var
|
|
415
|
-
if (((
|
|
414
|
+
return and && (customFilters.and = BooleanNumber.TRUE), { customFilters };
|
|
415
|
+
}, "mapToFilterColumn"),
|
|
416
|
+
testMappingFilterColumn: /* @__PURE__ */ __name((filterColumn) => {
|
|
417
|
+
var _a13;
|
|
418
|
+
if (((_a13 = filterColumn.customFilters) == null ? void 0 : _a13.customFilters.length) !== 2)
|
|
416
419
|
return !1;
|
|
417
|
-
const
|
|
418
|
-
operator1:
|
|
419
|
-
val1:
|
|
420
|
-
operator2:
|
|
421
|
-
val2:
|
|
420
|
+
const params = filterColumn.customFilters.customFilters.map((customFilter) => testMappingFilterColumn({ customFilters: { customFilters: [customFilter] } })), result = {
|
|
421
|
+
operator1: params[0][0].operator,
|
|
422
|
+
val1: params[0][1].val1,
|
|
423
|
+
operator2: params[1][0].operator,
|
|
424
|
+
val2: params[1][1].val1
|
|
422
425
|
};
|
|
423
|
-
return
|
|
424
|
-
}
|
|
425
|
-
},
|
|
426
|
+
return filterColumn.customFilters.and && (result.and = !0), result;
|
|
427
|
+
}, "testMappingFilterColumn")
|
|
428
|
+
}, FilterConditionItems2.ALL_CONDITIONS = [
|
|
426
429
|
// ------------------------------
|
|
427
|
-
|
|
430
|
+
FilterConditionItems2.NONE,
|
|
428
431
|
// ------------------------------
|
|
429
|
-
|
|
430
|
-
|
|
432
|
+
FilterConditionItems2.EMPTY,
|
|
433
|
+
FilterConditionItems2.NOT_EMPTY,
|
|
431
434
|
// ------------------------------
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
435
|
+
FilterConditionItems2.TEXT_CONTAINS,
|
|
436
|
+
FilterConditionItems2.DOES_NOT_CONTAIN,
|
|
437
|
+
FilterConditionItems2.STARTS_WITH,
|
|
438
|
+
FilterConditionItems2.ENDS_WITH,
|
|
439
|
+
FilterConditionItems2.EQUALS,
|
|
437
440
|
// ------------------------------
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
441
|
+
FilterConditionItems2.GREATER_THAN,
|
|
442
|
+
FilterConditionItems2.GREATER_THAN_OR_EQUAL,
|
|
443
|
+
FilterConditionItems2.LESS_THAN,
|
|
444
|
+
FilterConditionItems2.LESS_THAN_OR_EQUAL,
|
|
445
|
+
FilterConditionItems2.EQUAL,
|
|
446
|
+
FilterConditionItems2.NOT_EQUAL,
|
|
447
|
+
FilterConditionItems2.BETWEEN,
|
|
448
|
+
FilterConditionItems2.NOT_BETWEEN,
|
|
446
449
|
// ------------------------------
|
|
447
|
-
|
|
450
|
+
FilterConditionItems2.CUSTOM
|
|
448
451
|
];
|
|
449
|
-
function
|
|
450
|
-
const
|
|
451
|
-
if (!
|
|
452
|
-
throw new Error(`[SheetsFilter]: no condition item found for operator: ${
|
|
453
|
-
return
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
function
|
|
457
|
-
for (const
|
|
458
|
-
if (
|
|
459
|
-
return
|
|
460
|
-
for (const
|
|
461
|
-
if (
|
|
462
|
-
return
|
|
452
|
+
function getItemByOperator(operator) {
|
|
453
|
+
const item = FilterConditionItems2.ALL_CONDITIONS.find((condition) => condition.operator === operator);
|
|
454
|
+
if (!item)
|
|
455
|
+
throw new Error(`[SheetsFilter]: no condition item found for operator: ${operator}`);
|
|
456
|
+
return item;
|
|
457
|
+
}
|
|
458
|
+
__name(getItemByOperator, "getItemByOperator"), FilterConditionItems2.getItemByOperator = getItemByOperator;
|
|
459
|
+
function testMappingParams(mapParams, numOfParameters) {
|
|
460
|
+
for (const condition of FilterConditionItems2.ALL_CONDITIONS.filter((condition2) => condition2.numOfParameters === numOfParameters))
|
|
461
|
+
if (condition.numOfParameters !== 0 && condition.testMappingParams(mapParams))
|
|
462
|
+
return condition;
|
|
463
|
+
for (const condition of FilterConditionItems2.ALL_CONDITIONS)
|
|
464
|
+
if (condition.testMappingParams(mapParams))
|
|
465
|
+
return condition;
|
|
463
466
|
throw new Error("[SheetsFilter]: no condition item can be mapped from the filter map params!");
|
|
464
467
|
}
|
|
465
|
-
|
|
466
|
-
function
|
|
467
|
-
const
|
|
468
|
-
return (
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
function
|
|
472
|
-
return
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
function
|
|
476
|
-
if (!
|
|
477
|
-
return [
|
|
478
|
-
for (const
|
|
479
|
-
const
|
|
480
|
-
if (
|
|
481
|
-
return [
|
|
468
|
+
__name(testMappingParams, "testMappingParams"), FilterConditionItems2.testMappingParams = testMappingParams;
|
|
469
|
+
function getInitialFormParams(operator) {
|
|
470
|
+
const condition = FilterConditionItems2.ALL_CONDITIONS.find((condition2) => condition2.operator === operator);
|
|
471
|
+
return (condition == null ? void 0 : condition.numOfParameters) === 0 ? { operator1: condition.operator } : condition.getDefaultFormParams();
|
|
472
|
+
}
|
|
473
|
+
__name(getInitialFormParams, "getInitialFormParams"), FilterConditionItems2.getInitialFormParams = getInitialFormParams;
|
|
474
|
+
function mapToFilterColumn(condition, mapParams) {
|
|
475
|
+
return condition.mapToFilterColumn(mapParams);
|
|
476
|
+
}
|
|
477
|
+
__name(mapToFilterColumn, "mapToFilterColumn"), FilterConditionItems2.mapToFilterColumn = mapToFilterColumn;
|
|
478
|
+
function testMappingFilterColumn(filterColumn) {
|
|
479
|
+
if (!filterColumn)
|
|
480
|
+
return [FilterConditionItems2.NONE, {}];
|
|
481
|
+
for (const condition of FilterConditionItems2.ALL_CONDITIONS) {
|
|
482
|
+
const mapParams = condition.testMappingFilterColumn(filterColumn);
|
|
483
|
+
if (mapParams)
|
|
484
|
+
return [condition, mapParams];
|
|
482
485
|
}
|
|
483
|
-
return [
|
|
486
|
+
return [FilterConditionItems2.NONE, {}];
|
|
484
487
|
}
|
|
485
|
-
|
|
486
|
-
})(
|
|
487
|
-
function
|
|
488
|
-
const { operator1
|
|
489
|
-
if (
|
|
488
|
+
__name(testMappingFilterColumn, "testMappingFilterColumn"), FilterConditionItems2.testMappingFilterColumn = testMappingFilterColumn;
|
|
489
|
+
})(FilterConditionItems || (FilterConditionItems = {}));
|
|
490
|
+
function getOnlyOperatorAndVal(mapParams) {
|
|
491
|
+
const { operator1, operator2, val1, val2 } = mapParams;
|
|
492
|
+
if (operator1 && operator2)
|
|
490
493
|
throw new Error("Both operator1 and operator2 are set!");
|
|
491
|
-
if (!
|
|
494
|
+
if (!operator1 && !operator2)
|
|
492
495
|
throw new Error("Neither operator1 and operator2 and both not set!");
|
|
493
|
-
return
|
|
496
|
+
return operator1 ? [operator1, val1] : [operator2, val2];
|
|
494
497
|
}
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
498
|
+
__name(getOnlyOperatorAndVal, "getOnlyOperatorAndVal");
|
|
499
|
+
function statisticFilterByValueItems(items) {
|
|
500
|
+
const checkedItems = [], uncheckedItems = [];
|
|
501
|
+
let checked = 0, unchecked = 0;
|
|
502
|
+
function traverse(node) {
|
|
503
|
+
node.leaf && (node.checked ? (checkedItems.push(node), checked += node.count) : (uncheckedItems.push(node), unchecked += node.count)), node.children && node.children.forEach(traverse);
|
|
504
|
+
}
|
|
505
|
+
return __name(traverse, "traverse"), items.forEach(traverse), {
|
|
506
|
+
checkedItems,
|
|
507
|
+
uncheckedItems,
|
|
508
|
+
checked,
|
|
509
|
+
unchecked
|
|
506
510
|
};
|
|
507
511
|
}
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
};
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
512
|
+
__name(statisticFilterByValueItems, "statisticFilterByValueItems");
|
|
513
|
+
var __defProp$9 = Object.defineProperty, __getOwnPropDesc$9 = Object.getOwnPropertyDescriptor, __decorateClass$9 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
514
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$9(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
515
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
516
|
+
return kind && result && __defProp$9(target, key, result), result;
|
|
517
|
+
}, "__decorateClass$9"), __decorateParam$9 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$9");
|
|
518
|
+
const SHEETS_GENERATE_FILTER_VALUES_SERVICE_NAME = "sheets-filter.generate-filter-values.service", ISheetsGenerateFilterValuesService = createIdentifier(SHEETS_GENERATE_FILTER_VALUES_SERVICE_NAME), CAN_PARSE_DATE_FORMAT = ["yyyy-mm-dd", "yyyy-mm-dd;@", "yyyy/mm/dd;@", "yyyy/mm/dd hh:mm", "yyyy-m-d am/pm h:mm", "yyyy-MM-dd", "yyyy/MM/dd", "yyyy/mm/dd", 'yyyy"年"MM"月"dd"日"', "MM-dd", 'M"月"d"日"', "MM-dd A/P hh:mm"];
|
|
519
|
+
var _a;
|
|
520
|
+
let SheetsGenerateFilterValuesService = (_a = class extends Disposable {
|
|
521
|
+
constructor(_localeService, _univerInstanceService, _logService) {
|
|
522
|
+
super(), this._localeService = _localeService, this._univerInstanceService = _univerInstanceService, this._logService = _logService;
|
|
523
|
+
}
|
|
524
|
+
async getFilterValues(params) {
|
|
525
|
+
var _a13;
|
|
526
|
+
const { unitId, subUnitId, filteredOutRowsByOtherColumns, filters, blankChecked, iterateRange, alreadyChecked } = params, workbook = this._univerInstanceService.getUnit(unitId), worksheet = (_a13 = this._univerInstanceService.getUnit(unitId)) == null ? void 0 : _a13.getSheetBySheetId(subUnitId);
|
|
527
|
+
return !workbook || !worksheet ? [] : (this._logService.debug("[SheetsGenerateFilterValuesService]", "getFilterValues for", { unitId, subUnitId }), getFilterTreeByValueItems(filters, this._localeService, iterateRange, worksheet, new Set(filteredOutRowsByOtherColumns), new Set(alreadyChecked.map(String)), blankChecked, workbook.getStyles()));
|
|
528
|
+
}
|
|
529
|
+
}, __name(_a, "SheetsGenerateFilterValuesService"), _a);
|
|
530
|
+
SheetsGenerateFilterValuesService = __decorateClass$9([
|
|
531
|
+
__decorateParam$9(0, Inject(LocaleService)),
|
|
532
|
+
__decorateParam$9(1, IUniverInstanceService),
|
|
533
|
+
__decorateParam$9(2, ILogService)
|
|
534
|
+
], SheetsGenerateFilterValuesService);
|
|
535
|
+
function getFilterTreeByValueItems(filters, localeService, iterateRange, worksheet, filteredOutRowsByOtherColumns, alreadyChecked, blankChecked, styles2) {
|
|
536
|
+
var _a13, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
537
|
+
const items = /* @__PURE__ */ new Map(), treeMap = /* @__PURE__ */ new Map(), DefaultPattern = "yyyy-mm-dd", canSplitPatternSet = new Set(CAN_PARSE_DATE_FORMAT), EmptyKey = "empty";
|
|
538
|
+
let emptyCount = 0;
|
|
539
|
+
for (const cell of worksheet.iterateByColumn(iterateRange, !1, !1)) {
|
|
540
|
+
const { row, rowSpan = 1 } = cell;
|
|
541
|
+
let rowIndex = 0;
|
|
542
|
+
for (; rowIndex < rowSpan; ) {
|
|
543
|
+
const targetRow = row + rowIndex;
|
|
544
|
+
if (filteredOutRowsByOtherColumns.has(targetRow)) {
|
|
545
|
+
rowIndex++;
|
|
540
546
|
continue;
|
|
541
547
|
}
|
|
542
|
-
const
|
|
543
|
-
if (!
|
|
544
|
-
|
|
548
|
+
const value = cell != null && cell.value ? extractPureTextFromCell(cell.value) : "";
|
|
549
|
+
if (!value) {
|
|
550
|
+
emptyCount += 1, rowIndex += rowSpan;
|
|
545
551
|
continue;
|
|
546
552
|
}
|
|
547
|
-
const
|
|
548
|
-
if (
|
|
549
|
-
const
|
|
550
|
-
if (!
|
|
551
|
-
|
|
553
|
+
const fmtStr = (_a13 = cell.value) != null && _a13.v && !cell.value.p ? (_d = (_c = styles2.get((_b = cell.value) == null ? void 0 : _b.s)) == null ? void 0 : _c.n) == null ? void 0 : _d.pattern : "", isDateValue = fmtStr && numfmt.isDate(fmtStr);
|
|
554
|
+
if (fmtStr && isDateValue && canSplitPatternSet.has(fmtStr)) {
|
|
555
|
+
const originValue = (_e = worksheet.getCellRaw(cell.row, cell.col)) == null ? void 0 : _e.v;
|
|
556
|
+
if (!originValue) {
|
|
557
|
+
rowIndex++;
|
|
552
558
|
continue;
|
|
553
559
|
}
|
|
554
|
-
const
|
|
555
|
-
let
|
|
556
|
-
|
|
557
|
-
title: `${
|
|
558
|
-
key: `${
|
|
560
|
+
const valueParsedByDefaultPattern = numfmt.format(DefaultPattern, originValue), [year, month, day] = valueParsedByDefaultPattern.split("-").map(Number);
|
|
561
|
+
let yearItem = items.get(`${year}`);
|
|
562
|
+
yearItem || (yearItem = {
|
|
563
|
+
title: `${year}`,
|
|
564
|
+
key: `${year}`,
|
|
559
565
|
children: [],
|
|
560
566
|
count: 0,
|
|
561
567
|
leaf: !1,
|
|
562
568
|
checked: !1
|
|
563
|
-
},
|
|
564
|
-
let
|
|
565
|
-
|
|
566
|
-
title:
|
|
567
|
-
key: `${
|
|
569
|
+
}, items.set(`${year}`, yearItem), treeMap.set(`${year}`, [`${year}`]));
|
|
570
|
+
let monthItem = (_f = yearItem.children) == null ? void 0 : _f.find((item) => item.key === `${year}-${month}`);
|
|
571
|
+
monthItem || (monthItem = {
|
|
572
|
+
title: localeService.t(`sheets-filter.date.${month}`),
|
|
573
|
+
key: `${year}-${month}`,
|
|
568
574
|
children: [],
|
|
569
575
|
count: 0,
|
|
570
576
|
leaf: !1,
|
|
571
577
|
checked: !1
|
|
572
|
-
}, (
|
|
573
|
-
const
|
|
574
|
-
|
|
575
|
-
title: `${
|
|
576
|
-
key: `${
|
|
578
|
+
}, (_g = yearItem.children) == null || _g.push(monthItem), treeMap.set(`${year}-${month}`, [`${year}`, `${year}-${month}`]));
|
|
579
|
+
const dayItem = (_h = monthItem == null ? void 0 : monthItem.children) == null ? void 0 : _h.find((item) => item.key === `${year}-${month}-${day}`);
|
|
580
|
+
dayItem ? (dayItem.originValues.add(value), dayItem.count++, monthItem.count++, yearItem.count++) : ((_i = monthItem.children) == null || _i.push({
|
|
581
|
+
title: `${day}`,
|
|
582
|
+
key: `${year}-${month}-${day}`,
|
|
577
583
|
count: 1,
|
|
578
|
-
originValues: /* @__PURE__ */ new Set([
|
|
584
|
+
originValues: /* @__PURE__ */ new Set([value]),
|
|
579
585
|
leaf: !0,
|
|
580
|
-
checked:
|
|
581
|
-
}),
|
|
586
|
+
checked: alreadyChecked.size ? alreadyChecked.has(value) : !blankChecked
|
|
587
|
+
}), monthItem.count++, yearItem.count++, treeMap.set(`${year}-${month}-${day}`, [`${year}`, `${year}-${month}`, `${year}-${month}-${day}`]));
|
|
582
588
|
} else {
|
|
583
|
-
const
|
|
584
|
-
let
|
|
585
|
-
|
|
586
|
-
title:
|
|
589
|
+
const key = value;
|
|
590
|
+
let item = items.get(key);
|
|
591
|
+
item ? item.count++ : (item = {
|
|
592
|
+
title: value,
|
|
587
593
|
leaf: !0,
|
|
588
|
-
checked:
|
|
589
|
-
key
|
|
594
|
+
checked: alreadyChecked.size ? alreadyChecked.has(value) : !blankChecked,
|
|
595
|
+
key,
|
|
590
596
|
count: 1
|
|
591
|
-
},
|
|
597
|
+
}, items.set(key, item), treeMap.set(key, [key]));
|
|
592
598
|
}
|
|
593
|
-
|
|
599
|
+
rowIndex++;
|
|
594
600
|
}
|
|
595
601
|
}
|
|
596
|
-
const
|
|
597
|
-
if (
|
|
598
|
-
const
|
|
599
|
-
title:
|
|
600
|
-
count:
|
|
602
|
+
const initialBlankChecked = filters ? blankChecked : !0;
|
|
603
|
+
if (emptyCount > 0) {
|
|
604
|
+
const item = {
|
|
605
|
+
title: localeService.t("sheets-filter.panel.empty"),
|
|
606
|
+
count: emptyCount,
|
|
601
607
|
leaf: !0,
|
|
602
|
-
checked:
|
|
603
|
-
key:
|
|
608
|
+
checked: initialBlankChecked,
|
|
609
|
+
key: EmptyKey
|
|
604
610
|
};
|
|
605
|
-
|
|
611
|
+
items.set("empty", item), treeMap.set("empty", [EmptyKey]);
|
|
606
612
|
}
|
|
607
613
|
return {
|
|
608
|
-
filterTreeItems:
|
|
609
|
-
filterTreeMapCache:
|
|
614
|
+
filterTreeItems: generateFilterTreeBySort(Array.from(items.values())),
|
|
615
|
+
filterTreeMapCache: treeMap
|
|
610
616
|
};
|
|
611
617
|
}
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
618
|
+
__name(getFilterTreeByValueItems, "getFilterTreeByValueItems");
|
|
619
|
+
function generateFilterTreeBySort(tree) {
|
|
620
|
+
return Array.from(tree).sort((a, b) => a.children && !b.children ? -1 : !a.children && b.children ? 1 : b.title.localeCompare(a.title)).map((yearItem) => (yearItem.children && yearItem.children.sort((a, b) => {
|
|
621
|
+
const monthA = Number.parseInt(a.key.split("-")[1], 10), monthB = Number.parseInt(b.key.split("-")[1], 10);
|
|
622
|
+
return monthA - monthB;
|
|
623
|
+
}).forEach((monthItem) => {
|
|
624
|
+
monthItem.children && monthItem.children.sort((a, b) => {
|
|
625
|
+
const dayA = Number.parseInt(a.key.split("-")[2], 10), dayB = Number.parseInt(b.key.split("-")[2], 10);
|
|
626
|
+
return dayA - dayB;
|
|
620
627
|
});
|
|
621
|
-
}),
|
|
628
|
+
}), yearItem));
|
|
622
629
|
}
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
630
|
+
__name(generateFilterTreeBySort, "generateFilterTreeBySort");
|
|
631
|
+
function findObjectByKey(data, targetKey) {
|
|
632
|
+
for (const node of data) {
|
|
633
|
+
if (node.key === targetKey)
|
|
634
|
+
return node;
|
|
635
|
+
if (node.children) {
|
|
636
|
+
const result = findObjectByKey(node.children, targetKey);
|
|
637
|
+
if (result)
|
|
638
|
+
return result;
|
|
631
639
|
}
|
|
632
640
|
}
|
|
633
641
|
return null;
|
|
634
642
|
}
|
|
635
|
-
|
|
636
|
-
|
|
643
|
+
__name(findObjectByKey, "findObjectByKey");
|
|
644
|
+
function areAllLeafNodesChecked(node) {
|
|
645
|
+
return node.leaf ? node.checked : node.children ? node.children.every((child) => areAllLeafNodesChecked(child)) : !0;
|
|
637
646
|
}
|
|
638
|
-
|
|
639
|
-
|
|
647
|
+
__name(areAllLeafNodesChecked, "areAllLeafNodesChecked");
|
|
648
|
+
function updateLeafNodesCheckedStatus(node, status) {
|
|
649
|
+
node.leaf && (status !== void 0 ? node.checked = status : node.checked = !node.checked), node.children && node.children.forEach((child) => updateLeafNodesCheckedStatus(child, status));
|
|
640
650
|
}
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
651
|
+
__name(updateLeafNodesCheckedStatus, "updateLeafNodesCheckedStatus");
|
|
652
|
+
function searchTree(items, searchKeywords) {
|
|
653
|
+
const result = [];
|
|
654
|
+
return items.forEach((item) => {
|
|
655
|
+
const originMatches = item.originValues ? searchKeywords.some(
|
|
656
|
+
(keyword) => Array.from(item.originValues).some(
|
|
657
|
+
(value) => value.toLowerCase().includes(keyword.toLowerCase())
|
|
647
658
|
)
|
|
648
|
-
) : !1,
|
|
649
|
-
(
|
|
659
|
+
) : !1, titleMatches = !originMatches && searchKeywords.some(
|
|
660
|
+
(keyword) => item.title.toLowerCase().includes(keyword.toLowerCase())
|
|
650
661
|
);
|
|
651
|
-
if (
|
|
652
|
-
|
|
653
|
-
else if (
|
|
654
|
-
const
|
|
655
|
-
if (
|
|
656
|
-
const
|
|
657
|
-
|
|
662
|
+
if (originMatches || titleMatches)
|
|
663
|
+
result.push({ ...item });
|
|
664
|
+
else if (item.children) {
|
|
665
|
+
const filteredChildren = searchTree(item.children, searchKeywords);
|
|
666
|
+
if (filteredChildren.length > 0) {
|
|
667
|
+
const aggregatedCount = filteredChildren.reduce((sum, child) => sum + child.count, 0);
|
|
668
|
+
result.push({ ...item, count: aggregatedCount, children: filteredChildren });
|
|
658
669
|
}
|
|
659
670
|
}
|
|
660
|
-
}),
|
|
671
|
+
}), result;
|
|
661
672
|
}
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
673
|
+
__name(searchTree, "searchTree");
|
|
674
|
+
var __defProp$8 = Object.defineProperty, __getOwnPropDesc$8 = Object.getOwnPropertyDescriptor, __decorateClass$8 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
675
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$8(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
676
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
677
|
+
return kind && result && __defProp$8(target, key, result), result;
|
|
678
|
+
}, "__decorateClass$8"), __decorateParam$8 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$8"), FilterBy = /* @__PURE__ */ ((FilterBy2) => (FilterBy2[FilterBy2.VALUES = 0] = "VALUES", FilterBy2[FilterBy2.CONDITIONS = 1] = "CONDITIONS", FilterBy2))(FilterBy || {});
|
|
679
|
+
createIdentifier("sheets-filter-ui.sheets-filter-panel.service");
|
|
680
|
+
var _a2;
|
|
681
|
+
let SheetsFilterPanelService = (_a2 = class extends Disposable {
|
|
682
|
+
constructor(_injector, _refRangeService) {
|
|
670
683
|
super();
|
|
671
|
-
|
|
684
|
+
__publicField(this, "_filterBy$", new BehaviorSubject(
|
|
672
685
|
0
|
|
673
686
|
/* VALUES */
|
|
674
687
|
));
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
this._injector =
|
|
688
|
+
__publicField(this, "filterBy$", this._filterBy$.asObservable());
|
|
689
|
+
__publicField(this, "_filterByModel$", new ReplaySubject(1));
|
|
690
|
+
__publicField(this, "filterByModel$", this._filterByModel$.asObservable());
|
|
691
|
+
__publicField(this, "_filterByModel", null);
|
|
692
|
+
__publicField(this, "_hasCriteria$", new BehaviorSubject(!1));
|
|
693
|
+
__publicField(this, "hasCriteria$", this._hasCriteria$.asObservable());
|
|
694
|
+
__publicField(this, "_filterModel", null);
|
|
695
|
+
__publicField(this, "_col$", new BehaviorSubject(-1));
|
|
696
|
+
__publicField(this, "col$", this._col$.asObservable());
|
|
697
|
+
__publicField(this, "_filterHeaderListener", null);
|
|
698
|
+
this._injector = _injector, this._refRangeService = _refRangeService;
|
|
686
699
|
}
|
|
687
700
|
get filterBy() {
|
|
688
701
|
return this._filterBy$.getValue();
|
|
@@ -690,8 +703,8 @@ let j = class extends pe {
|
|
|
690
703
|
get filterByModel() {
|
|
691
704
|
return this._filterByModel;
|
|
692
705
|
}
|
|
693
|
-
set filterByModel(
|
|
694
|
-
this._filterByModel =
|
|
706
|
+
set filterByModel(model) {
|
|
707
|
+
this._filterByModel = model, this._filterByModel$.next(model);
|
|
695
708
|
}
|
|
696
709
|
get filterModel() {
|
|
697
710
|
return this._filterModel;
|
|
@@ -702,98 +715,99 @@ let j = class extends pe {
|
|
|
702
715
|
dispose() {
|
|
703
716
|
this._filterBy$.complete(), this._filterByModel$.complete(), this._hasCriteria$.complete();
|
|
704
717
|
}
|
|
705
|
-
setupCol(
|
|
706
|
-
this.terminate(), this._filterModel =
|
|
707
|
-
const
|
|
708
|
-
if (
|
|
709
|
-
const
|
|
710
|
-
if (
|
|
711
|
-
this._hasCriteria$.next(!0), this._setupByConditions(
|
|
718
|
+
setupCol(filterModel, col) {
|
|
719
|
+
this.terminate(), this._filterModel = filterModel, this._col$.next(col);
|
|
720
|
+
const filterColumn = filterModel.getFilterColumn(col);
|
|
721
|
+
if (filterColumn) {
|
|
722
|
+
const info = filterColumn.getColumnData();
|
|
723
|
+
if (info.customFilters) {
|
|
724
|
+
this._hasCriteria$.next(!0), this._setupByConditions(filterModel, col);
|
|
712
725
|
return;
|
|
713
726
|
}
|
|
714
|
-
if (
|
|
715
|
-
this._hasCriteria$.next(!0), this._setupByValues(
|
|
727
|
+
if (info.filters) {
|
|
728
|
+
this._hasCriteria$.next(!0), this._setupByValues(filterModel, col);
|
|
716
729
|
return;
|
|
717
730
|
}
|
|
718
|
-
this._hasCriteria$.next(!1), this._setupByValues(
|
|
731
|
+
this._hasCriteria$.next(!1), this._setupByValues(filterModel, col);
|
|
719
732
|
return;
|
|
720
733
|
}
|
|
721
|
-
this._hasCriteria$.next(!1), this._setupByValues(
|
|
734
|
+
this._hasCriteria$.next(!1), this._setupByValues(filterModel, col);
|
|
722
735
|
}
|
|
723
|
-
changeFilterBy(
|
|
724
|
-
return !this._filterModel || this.col === -1 ? !1 : (
|
|
736
|
+
changeFilterBy(filterBy) {
|
|
737
|
+
return !this._filterModel || this.col === -1 ? !1 : (filterBy === 0 ? this._setupByValues(this._filterModel, this.col) : this._setupByConditions(this._filterModel, this.col), !0);
|
|
725
738
|
}
|
|
726
739
|
terminate() {
|
|
727
740
|
return this._filterModel = null, this._col$.next(-1), this._disposeFilterHeaderChangeListener(), !0;
|
|
728
741
|
}
|
|
729
742
|
_disposeFilterHeaderChangeListener() {
|
|
730
|
-
var
|
|
731
|
-
(
|
|
743
|
+
var _a13;
|
|
744
|
+
(_a13 = this._filterHeaderListener) == null || _a13.dispose(), this._filterHeaderListener = null;
|
|
732
745
|
}
|
|
733
|
-
_listenToFilterHeaderChange(
|
|
746
|
+
_listenToFilterHeaderChange(filterModel, col) {
|
|
734
747
|
this._disposeFilterHeaderChangeListener();
|
|
735
|
-
const
|
|
736
|
-
startColumn:
|
|
737
|
-
startRow:
|
|
738
|
-
endRow:
|
|
739
|
-
endColumn:
|
|
748
|
+
const unitId = filterModel.unitId, subUnitId = filterModel.subUnitId, filterRange = filterModel.getRange(), columnHeaderRange = {
|
|
749
|
+
startColumn: col,
|
|
750
|
+
startRow: filterRange.startRow,
|
|
751
|
+
endRow: filterRange.startRow,
|
|
752
|
+
endColumn: col
|
|
740
753
|
};
|
|
741
|
-
this._filterHeaderListener = this._refRangeService.watchRange(
|
|
742
|
-
if (!
|
|
754
|
+
this._filterHeaderListener = this._refRangeService.watchRange(unitId, subUnitId, columnHeaderRange, (before, after) => {
|
|
755
|
+
if (!after)
|
|
743
756
|
this.terminate();
|
|
744
757
|
else {
|
|
745
|
-
const
|
|
746
|
-
|
|
758
|
+
const offset = after.startColumn - before.startColumn;
|
|
759
|
+
offset !== 0 && this._filterByModel.deltaCol(offset);
|
|
747
760
|
}
|
|
748
761
|
});
|
|
749
762
|
}
|
|
750
|
-
async _setupByValues(
|
|
763
|
+
async _setupByValues(filterModel, col) {
|
|
751
764
|
this._disposePreviousModel();
|
|
752
|
-
const
|
|
753
|
-
if (
|
|
754
|
-
const
|
|
765
|
+
const range = filterModel.getRange();
|
|
766
|
+
if (range.startRow === range.endRow) return !1;
|
|
767
|
+
const filterByModel = await ByValuesModel.fromFilterColumn(
|
|
755
768
|
this._injector,
|
|
756
|
-
|
|
757
|
-
|
|
769
|
+
filterModel,
|
|
770
|
+
col
|
|
758
771
|
);
|
|
759
|
-
return this.filterByModel =
|
|
772
|
+
return this.filterByModel = filterByModel, this._filterBy$.next(
|
|
760
773
|
0
|
|
761
774
|
/* VALUES */
|
|
762
|
-
), this._listenToFilterHeaderChange(
|
|
775
|
+
), this._listenToFilterHeaderChange(filterModel, col), !0;
|
|
763
776
|
}
|
|
764
|
-
_setupByConditions(
|
|
777
|
+
_setupByConditions(filterModel, col) {
|
|
765
778
|
this._disposePreviousModel();
|
|
766
|
-
const
|
|
767
|
-
if (
|
|
768
|
-
const
|
|
779
|
+
const range = filterModel.getRange();
|
|
780
|
+
if (range.startRow === range.endRow) return !1;
|
|
781
|
+
const model = ByConditionsModel.fromFilterColumn(
|
|
769
782
|
this._injector,
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
783
|
+
filterModel,
|
|
784
|
+
col,
|
|
785
|
+
filterModel.getFilterColumn(col)
|
|
773
786
|
);
|
|
774
|
-
return this.filterByModel =
|
|
787
|
+
return this.filterByModel = model, this._filterBy$.next(
|
|
775
788
|
1
|
|
776
789
|
/* CONDITIONS */
|
|
777
|
-
), this._listenToFilterHeaderChange(
|
|
790
|
+
), this._listenToFilterHeaderChange(filterModel, col), !0;
|
|
778
791
|
}
|
|
779
792
|
_disposePreviousModel() {
|
|
780
|
-
var
|
|
781
|
-
(
|
|
782
|
-
}
|
|
783
|
-
};
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
],
|
|
788
|
-
|
|
789
|
-
|
|
793
|
+
var _a13;
|
|
794
|
+
(_a13 = this._filterByModel) == null || _a13.dispose(), this.filterByModel = null;
|
|
795
|
+
}
|
|
796
|
+
}, __name(_a2, "SheetsFilterPanelService"), _a2);
|
|
797
|
+
SheetsFilterPanelService = __decorateClass$8([
|
|
798
|
+
__decorateParam$8(0, Inject(Injector)),
|
|
799
|
+
__decorateParam$8(1, Inject(RefRangeService))
|
|
800
|
+
], SheetsFilterPanelService);
|
|
801
|
+
var _a3;
|
|
802
|
+
let ByConditionsModel = (_a3 = class extends Disposable {
|
|
803
|
+
constructor(_filterModel, col, conditionItem, conditionParams, _commandService) {
|
|
790
804
|
super();
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
this._filterModel =
|
|
805
|
+
__publicField(this, "canApply$", of(!0));
|
|
806
|
+
__publicField(this, "_conditionItem$");
|
|
807
|
+
__publicField(this, "conditionItem$");
|
|
808
|
+
__publicField(this, "_filterConditionFormParams$");
|
|
809
|
+
__publicField(this, "filterConditionFormParams$");
|
|
810
|
+
this._filterModel = _filterModel, this.col = col, this._commandService = _commandService, this._conditionItem$ = new BehaviorSubject(conditionItem), this.conditionItem$ = this._conditionItem$.asObservable(), this._filterConditionFormParams$ = new BehaviorSubject(conditionParams), this.filterConditionFormParams$ = this._filterConditionFormParams$.asObservable();
|
|
797
811
|
}
|
|
798
812
|
/**
|
|
799
813
|
* Create a model with targeting filter column. If there is not a filter column, the model would be created with
|
|
@@ -806,9 +820,9 @@ let Ie = class extends pe {
|
|
|
806
820
|
*
|
|
807
821
|
* @returns the model to control the panel's state
|
|
808
822
|
*/
|
|
809
|
-
static fromFilterColumn(
|
|
810
|
-
const [
|
|
811
|
-
return
|
|
823
|
+
static fromFilterColumn(injector, filterModel, col, filterColumn) {
|
|
824
|
+
const [conditionItem, conditionParams] = FilterConditionItems.testMappingFilterColumn(filterColumn == null ? void 0 : filterColumn.getColumnData());
|
|
825
|
+
return injector.createInstance(ByConditionsModel, filterModel, col, conditionItem, conditionParams);
|
|
812
826
|
}
|
|
813
827
|
get conditionItem() {
|
|
814
828
|
return this._conditionItem$.getValue();
|
|
@@ -819,11 +833,11 @@ let Ie = class extends pe {
|
|
|
819
833
|
dispose() {
|
|
820
834
|
super.dispose(), this._conditionItem$.complete(), this._filterConditionFormParams$.complete();
|
|
821
835
|
}
|
|
822
|
-
deltaCol(
|
|
823
|
-
this.col +=
|
|
836
|
+
deltaCol(offset) {
|
|
837
|
+
this.col += offset;
|
|
824
838
|
}
|
|
825
839
|
clear() {
|
|
826
|
-
return this._disposed ? Promise.resolve(!1) : this._commandService.executeCommand(
|
|
840
|
+
return this._disposed ? Promise.resolve(!1) : this._commandService.executeCommand(SetSheetsFilterCriteriaCommand.id, {
|
|
827
841
|
unitId: this._filterModel.unitId,
|
|
828
842
|
subUnitId: this._filterModel.subUnitId,
|
|
829
843
|
col: this.col,
|
|
@@ -835,23 +849,23 @@ let Ie = class extends pe {
|
|
|
835
849
|
*/
|
|
836
850
|
async apply() {
|
|
837
851
|
if (this._disposed) return !1;
|
|
838
|
-
const
|
|
839
|
-
return this._commandService.executeCommand(
|
|
852
|
+
const filterColumn = FilterConditionItems.mapToFilterColumn(this.conditionItem, this.filterConditionFormParams);
|
|
853
|
+
return this._commandService.executeCommand(SetSheetsFilterCriteriaCommand.id, {
|
|
840
854
|
unitId: this._filterModel.unitId,
|
|
841
855
|
subUnitId: this._filterModel.subUnitId,
|
|
842
856
|
col: this.col,
|
|
843
|
-
criteria:
|
|
857
|
+
criteria: filterColumn
|
|
844
858
|
});
|
|
845
859
|
}
|
|
846
860
|
/**
|
|
847
861
|
* This method would be called when user changes the primary condition. The model would load the corresponding
|
|
848
862
|
* `IFilterConditionFormParams` and load default condition form params.
|
|
849
863
|
*/
|
|
850
|
-
onPrimaryConditionChange(
|
|
851
|
-
const
|
|
852
|
-
if (!
|
|
853
|
-
throw new Error(`[ByConditionsModel]: condition item not found for operator: ${
|
|
854
|
-
this._conditionItem$.next(
|
|
864
|
+
onPrimaryConditionChange(operator) {
|
|
865
|
+
const conditionItem = FilterConditionItems.ALL_CONDITIONS.find((item) => item.operator === operator);
|
|
866
|
+
if (!conditionItem)
|
|
867
|
+
throw new Error(`[ByConditionsModel]: condition item not found for operator: ${operator}!`);
|
|
868
|
+
this._conditionItem$.next(conditionItem), this._filterConditionFormParams$.next(FilterConditionItems.getInitialFormParams(operator));
|
|
855
869
|
}
|
|
856
870
|
/**
|
|
857
871
|
* This method would be called when user changes the primary conditions, the input values or "AND" "OR" ratio.
|
|
@@ -861,46 +875,47 @@ let Ie = class extends pe {
|
|
|
861
875
|
*
|
|
862
876
|
* @param params
|
|
863
877
|
*/
|
|
864
|
-
onConditionFormChange(
|
|
865
|
-
const
|
|
866
|
-
if (
|
|
867
|
-
const
|
|
868
|
-
this._conditionItem$.next(
|
|
878
|
+
onConditionFormChange(params) {
|
|
879
|
+
const newParams = { ...this.filterConditionFormParams, ...params };
|
|
880
|
+
if (newParams.and !== !0 && delete newParams.and, typeof params.and < "u" || typeof params.operator1 < "u" || typeof params.operator2 < "u") {
|
|
881
|
+
const conditionItem = FilterConditionItems.testMappingParams(newParams, this.conditionItem.numOfParameters);
|
|
882
|
+
this._conditionItem$.next(conditionItem);
|
|
869
883
|
}
|
|
870
|
-
this._filterConditionFormParams$.next(
|
|
871
|
-
}
|
|
872
|
-
};
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
],
|
|
876
|
-
|
|
877
|
-
|
|
884
|
+
this._filterConditionFormParams$.next(newParams);
|
|
885
|
+
}
|
|
886
|
+
}, __name(_a3, "ByConditionsModel"), _a3);
|
|
887
|
+
ByConditionsModel = __decorateClass$8([
|
|
888
|
+
__decorateParam$8(4, ICommandService)
|
|
889
|
+
], ByConditionsModel);
|
|
890
|
+
var _a4;
|
|
891
|
+
let ByValuesModel = (_a4 = class extends Disposable {
|
|
892
|
+
constructor(_filterModel, col, items, cache, _commandService) {
|
|
878
893
|
super();
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
this._filterModel =
|
|
889
|
-
|
|
894
|
+
__publicField(this, "_rawFilterItems$");
|
|
895
|
+
__publicField(this, "rawFilterItems$");
|
|
896
|
+
__publicField(this, "filterItems$");
|
|
897
|
+
__publicField(this, "_filterItems", []);
|
|
898
|
+
__publicField(this, "_treeMapCache");
|
|
899
|
+
__publicField(this, "canApply$");
|
|
900
|
+
__publicField(this, "_manuallyUpdateFilterItems$");
|
|
901
|
+
__publicField(this, "_searchString$");
|
|
902
|
+
__publicField(this, "searchString$");
|
|
903
|
+
this._filterModel = _filterModel, this.col = col, this._commandService = _commandService, this._treeMapCache = cache, this._searchString$ = new BehaviorSubject(""), this.searchString$ = this._searchString$.asObservable(), this._rawFilterItems$ = new BehaviorSubject(items), this.rawFilterItems$ = this._rawFilterItems$.asObservable(), this._manuallyUpdateFilterItems$ = new Subject(), this.filterItems$ = merge(
|
|
904
|
+
combineLatest([
|
|
890
905
|
this._searchString$.pipe(
|
|
891
|
-
|
|
892
|
-
|
|
906
|
+
throttleTime(500, void 0, { leading: !0, trailing: !0 }),
|
|
907
|
+
startWith(void 0)
|
|
893
908
|
),
|
|
894
909
|
this._rawFilterItems$
|
|
895
910
|
]).pipe(
|
|
896
|
-
|
|
897
|
-
if (!
|
|
898
|
-
const
|
|
899
|
-
return
|
|
911
|
+
map(([searchString, items2]) => {
|
|
912
|
+
if (!searchString) return items2;
|
|
913
|
+
const searchKeyWords = searchString.toLowerCase().split(/\s+/).filter((s) => !!s);
|
|
914
|
+
return searchTree(items2, searchKeyWords);
|
|
900
915
|
})
|
|
901
916
|
),
|
|
902
917
|
this._manuallyUpdateFilterItems$
|
|
903
|
-
).pipe(
|
|
918
|
+
).pipe(shareReplay(1)), this.canApply$ = this.filterItems$.pipe(map((items2) => statisticFilterByValueItems(items2).checked > 0)), this.disposeWithMe(this.filterItems$.subscribe((items2) => this._filterItems = items2));
|
|
904
919
|
}
|
|
905
920
|
/**
|
|
906
921
|
* Create a model with targeting filter column. If there is not a filter column, the model would be created with
|
|
@@ -912,30 +927,30 @@ let ye = class extends pe {
|
|
|
912
927
|
*
|
|
913
928
|
* @returns the model to control the panel's state
|
|
914
929
|
*/
|
|
915
|
-
static async fromFilterColumn(
|
|
916
|
-
var
|
|
917
|
-
const
|
|
918
|
-
if (!
|
|
919
|
-
const
|
|
920
|
-
if (!
|
|
921
|
-
const
|
|
922
|
-
let
|
|
923
|
-
if (
|
|
924
|
-
const
|
|
925
|
-
unitId
|
|
926
|
-
subUnitId
|
|
927
|
-
filteredOutRowsByOtherColumns: Array.from(
|
|
928
|
-
filters: !!
|
|
929
|
-
blankChecked
|
|
930
|
-
iterateRange
|
|
931
|
-
alreadyChecked: Array.from(
|
|
930
|
+
static async fromFilterColumn(injector, filterModel, col) {
|
|
931
|
+
var _a13;
|
|
932
|
+
const univerInstanceService = injector.get(IUniverInstanceService), localeService = injector.get(LocaleService), generateFilterValuesService = injector.get(ISheetsGenerateFilterValuesService, Quantity.OPTIONAL), { unitId, subUnitId } = filterModel, workbook = univerInstanceService.getUniverSheetInstance(unitId);
|
|
933
|
+
if (!workbook) throw new Error(`[ByValuesModel]: Workbook not found for filter model with unitId: ${unitId}!`);
|
|
934
|
+
const worksheet = workbook == null ? void 0 : workbook.getSheetBySheetId(subUnitId);
|
|
935
|
+
if (!worksheet) throw new Error(`[ByValuesModel]: Worksheet not found for filter model with unitId: ${unitId} and subUnitId: ${subUnitId}!`);
|
|
936
|
+
const range = filterModel.getRange(), column = col, filters = (_a13 = filterModel.getFilterColumn(col)) == null ? void 0 : _a13.getColumnData().filters, alreadyChecked = new Set(filters == null ? void 0 : filters.filters), blankChecked = !!(filters && filters.blank), filteredOutRowsByOtherColumns = filterModel.getFilteredOutRowsExceptCol(col), iterateRange = { ...range, startRow: range.startRow + 1, startColumn: column, endColumn: column };
|
|
937
|
+
let items, cache;
|
|
938
|
+
if (generateFilterValuesService) {
|
|
939
|
+
const res = await generateFilterValuesService.getFilterValues({
|
|
940
|
+
unitId,
|
|
941
|
+
subUnitId,
|
|
942
|
+
filteredOutRowsByOtherColumns: Array.from(filteredOutRowsByOtherColumns),
|
|
943
|
+
filters: !!filters,
|
|
944
|
+
blankChecked,
|
|
945
|
+
iterateRange,
|
|
946
|
+
alreadyChecked: Array.from(alreadyChecked)
|
|
932
947
|
});
|
|
933
|
-
|
|
948
|
+
items = res.filterTreeItems, cache = res.filterTreeMapCache;
|
|
934
949
|
} else {
|
|
935
|
-
const
|
|
936
|
-
|
|
950
|
+
const res = getFilterTreeByValueItems(!!filters, localeService, iterateRange, worksheet, filteredOutRowsByOtherColumns, alreadyChecked, blankChecked, workbook.getStyles());
|
|
951
|
+
items = res.filterTreeItems, cache = res.filterTreeMapCache;
|
|
937
952
|
}
|
|
938
|
-
return
|
|
953
|
+
return injector.createInstance(ByValuesModel, filterModel, col, items, cache);
|
|
939
954
|
}
|
|
940
955
|
get rawFilterItems() {
|
|
941
956
|
return this._rawFilterItems$.getValue();
|
|
@@ -949,40 +964,40 @@ let ye = class extends pe {
|
|
|
949
964
|
dispose() {
|
|
950
965
|
this._rawFilterItems$.complete(), this._searchString$.complete();
|
|
951
966
|
}
|
|
952
|
-
deltaCol(
|
|
953
|
-
this.col +=
|
|
967
|
+
deltaCol(offset) {
|
|
968
|
+
this.col += offset;
|
|
954
969
|
}
|
|
955
|
-
setSearchString(
|
|
956
|
-
this._searchString$.next(
|
|
970
|
+
setSearchString(str) {
|
|
971
|
+
this._searchString$.next(str);
|
|
957
972
|
}
|
|
958
|
-
onCheckAllToggled(
|
|
959
|
-
const
|
|
960
|
-
|
|
973
|
+
onCheckAllToggled(checked) {
|
|
974
|
+
const items = Tools.deepClone(this._filterItems);
|
|
975
|
+
items.forEach((item) => updateLeafNodesCheckedStatus(item, checked)), this._manuallyUpdateFilterItems(items);
|
|
961
976
|
}
|
|
962
977
|
/**
|
|
963
978
|
* Toggle a filter item.
|
|
964
979
|
*/
|
|
965
|
-
onFilterCheckToggled(
|
|
966
|
-
const
|
|
967
|
-
if (!
|
|
980
|
+
onFilterCheckToggled(item) {
|
|
981
|
+
const items = Tools.deepClone(this._filterItems), changedItem = findObjectByKey(items, item.key);
|
|
982
|
+
if (!changedItem)
|
|
968
983
|
return;
|
|
969
|
-
const
|
|
970
|
-
|
|
984
|
+
const allLeafChecked = areAllLeafNodesChecked(changedItem);
|
|
985
|
+
updateLeafNodesCheckedStatus(changedItem, !allLeafChecked), this._manuallyUpdateFilterItems(items);
|
|
971
986
|
}
|
|
972
|
-
onFilterOnly(
|
|
973
|
-
const
|
|
974
|
-
|
|
975
|
-
const
|
|
976
|
-
|
|
977
|
-
}), this._manuallyUpdateFilterItems(
|
|
987
|
+
onFilterOnly(itemKeys) {
|
|
988
|
+
const items = Tools.deepClone(this._filterItems);
|
|
989
|
+
items.forEach((item) => updateLeafNodesCheckedStatus(item, !1)), itemKeys.forEach((key) => {
|
|
990
|
+
const changedItem = findObjectByKey(items, key);
|
|
991
|
+
changedItem && updateLeafNodesCheckedStatus(changedItem, !0);
|
|
992
|
+
}), this._manuallyUpdateFilterItems(items);
|
|
978
993
|
}
|
|
979
|
-
_manuallyUpdateFilterItems(
|
|
980
|
-
this._manuallyUpdateFilterItems$.next(
|
|
994
|
+
_manuallyUpdateFilterItems(items) {
|
|
995
|
+
this._manuallyUpdateFilterItems$.next(items);
|
|
981
996
|
}
|
|
982
997
|
// expose method here to let the panel change filter items
|
|
983
998
|
// #region ByValuesModel apply methods
|
|
984
999
|
clear() {
|
|
985
|
-
return this._disposed ? Promise.resolve(!1) : this._commandService.executeCommand(
|
|
1000
|
+
return this._disposed ? Promise.resolve(!1) : this._commandService.executeCommand(SetSheetsFilterCriteriaCommand.id, {
|
|
986
1001
|
unitId: this._filterModel.unitId,
|
|
987
1002
|
subUnitId: this._filterModel.subUnitId,
|
|
988
1003
|
col: this.col,
|
|
@@ -995,541 +1010,521 @@ let ye = class extends pe {
|
|
|
995
1010
|
async apply() {
|
|
996
1011
|
if (this._disposed)
|
|
997
1012
|
return !1;
|
|
998
|
-
const
|
|
999
|
-
let
|
|
1000
|
-
for (const
|
|
1001
|
-
|
|
1002
|
-
const
|
|
1003
|
-
if (
|
|
1013
|
+
const statistics = statisticFilterByValueItems(this._filterItems), { checked, checkedItems } = statistics, rawFilterItems = this.rawFilterItems;
|
|
1014
|
+
let rawFilterCount = 0;
|
|
1015
|
+
for (const item of rawFilterItems)
|
|
1016
|
+
rawFilterCount += item.count;
|
|
1017
|
+
const noChecked = checked === 0, allChecked = statistics.checked === rawFilterCount, criteria = { colId: this.col };
|
|
1018
|
+
if (noChecked)
|
|
1004
1019
|
throw new Error("[ByValuesModel]: no checked items!");
|
|
1005
|
-
if (
|
|
1006
|
-
return this._commandService.executeCommand(
|
|
1020
|
+
if (allChecked)
|
|
1021
|
+
return this._commandService.executeCommand(SetSheetsFilterCriteriaCommand.id, {
|
|
1007
1022
|
unitId: this._filterModel.unitId,
|
|
1008
1023
|
subUnitId: this._filterModel.subUnitId,
|
|
1009
1024
|
col: this.col,
|
|
1010
1025
|
criteria: null
|
|
1011
1026
|
});
|
|
1012
1027
|
{
|
|
1013
|
-
|
|
1014
|
-
const
|
|
1015
|
-
|
|
1016
|
-
filters:
|
|
1017
|
-
}),
|
|
1028
|
+
criteria.filters = {};
|
|
1029
|
+
const nonEmptyItems = checkedItems.filter((item) => item.key !== "empty");
|
|
1030
|
+
nonEmptyItems.length > 0 && (criteria.filters = {
|
|
1031
|
+
filters: nonEmptyItems.flatMap((item) => item.originValues ? Array.from(item.originValues) : [item.title])
|
|
1032
|
+
}), nonEmptyItems.length !== checkedItems.length && (criteria.filters.blank = !0);
|
|
1018
1033
|
}
|
|
1019
|
-
return this._commandService.executeCommand(
|
|
1034
|
+
return this._commandService.executeCommand(SetSheetsFilterCriteriaCommand.id, {
|
|
1020
1035
|
unitId: this._filterModel.unitId,
|
|
1021
1036
|
subUnitId: this._filterModel.subUnitId,
|
|
1022
1037
|
col: this.col,
|
|
1023
|
-
criteria
|
|
1038
|
+
criteria
|
|
1024
1039
|
});
|
|
1025
1040
|
}
|
|
1026
1041
|
// #endregion
|
|
1027
|
-
};
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
],
|
|
1031
|
-
const
|
|
1042
|
+
}, __name(_a4, "ByValuesModel"), _a4);
|
|
1043
|
+
ByValuesModel = __decorateClass$8([
|
|
1044
|
+
__decorateParam$8(4, ICommandService)
|
|
1045
|
+
], ByValuesModel);
|
|
1046
|
+
const FILTER_PANEL_OPENED_KEY = "FILTER_PANEL_OPENED", OpenFilterPanelOperation = {
|
|
1032
1047
|
id: "sheet.operation.open-filter-panel",
|
|
1033
|
-
type:
|
|
1034
|
-
handler: (
|
|
1035
|
-
const
|
|
1036
|
-
|
|
1037
|
-
const { unitId
|
|
1038
|
-
return
|
|
1039
|
-
}
|
|
1040
|
-
},
|
|
1048
|
+
type: CommandType.OPERATION,
|
|
1049
|
+
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
1050
|
+
const contextService = accessor.get(IContextService), sheetsFilterService = accessor.get(SheetsFilterService), sheetsFilterPanelService = accessor.get(SheetsFilterPanelService);
|
|
1051
|
+
accessor.get(ICommandService).syncExecuteCommand(SetCellEditVisibleOperation.id, { visible: !1 });
|
|
1052
|
+
const { unitId, subUnitId, col } = params, filterModel = sheetsFilterService.getFilterModel(unitId, subUnitId);
|
|
1053
|
+
return filterModel ? (sheetsFilterPanelService.setupCol(filterModel, col), contextService.getContextValue(FILTER_PANEL_OPENED_KEY) || contextService.setContextValue(FILTER_PANEL_OPENED_KEY, !0), !0) : !1;
|
|
1054
|
+
}, "handler")
|
|
1055
|
+
}, CloseFilterPanelOperation = {
|
|
1041
1056
|
id: "sheet.operation.close-filter-panel",
|
|
1042
|
-
type:
|
|
1043
|
-
handler: (
|
|
1044
|
-
const
|
|
1045
|
-
return
|
|
1046
|
-
}
|
|
1047
|
-
},
|
|
1057
|
+
type: CommandType.OPERATION,
|
|
1058
|
+
handler: /* @__PURE__ */ __name((accessor) => {
|
|
1059
|
+
const contextService = accessor.get(IContextService), sheetsFilterPanelService = accessor.get(SheetsFilterPanelService), layoutService = accessor.get(ILayoutService, Quantity.OPTIONAL);
|
|
1060
|
+
return contextService.getContextValue(FILTER_PANEL_OPENED_KEY) ? (contextService.setContextValue(FILTER_PANEL_OPENED_KEY, !1), layoutService == null || layoutService.focus(), sheetsFilterPanelService.terminate()) : !1;
|
|
1061
|
+
}, "handler")
|
|
1062
|
+
}, ChangeFilterByOperation = {
|
|
1048
1063
|
id: "sheet.operation.apply-filter",
|
|
1049
|
-
type:
|
|
1050
|
-
handler: (
|
|
1051
|
-
const { filterBy
|
|
1052
|
-
return
|
|
1053
|
-
}
|
|
1064
|
+
type: CommandType.OPERATION,
|
|
1065
|
+
handler: /* @__PURE__ */ __name((accessor, params) => {
|
|
1066
|
+
const { filterBy } = params;
|
|
1067
|
+
return accessor.get(SheetsFilterPanelService).changeFilterBy(filterBy);
|
|
1068
|
+
}, "handler")
|
|
1054
1069
|
};
|
|
1055
|
-
var
|
|
1056
|
-
for (var
|
|
1057
|
-
(
|
|
1058
|
-
return
|
|
1059
|
-
},
|
|
1060
|
-
let
|
|
1061
|
-
constructor(
|
|
1062
|
-
super(), this._sheetsFilterService =
|
|
1070
|
+
var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPropertyDescriptor, __decorateClass$7 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1071
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1072
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1073
|
+
return kind && result && __defProp$7(target, key, result), result;
|
|
1074
|
+
}, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7"), _a5;
|
|
1075
|
+
let SheetsFilterPermissionController = (_a5 = class extends Disposable {
|
|
1076
|
+
constructor(_sheetsFilterService, _localeService, _commandService, _sheetPermissionCheckPermission, _injector, _sheetsSelectionService) {
|
|
1077
|
+
super(), this._sheetsFilterService = _sheetsFilterService, this._localeService = _localeService, this._commandService = _commandService, this._sheetPermissionCheckPermission = _sheetPermissionCheckPermission, this._injector = _injector, this._sheetsSelectionService = _sheetsSelectionService, this._commandExecutedListener();
|
|
1063
1078
|
}
|
|
1064
1079
|
_commandExecutedListener() {
|
|
1065
1080
|
this.disposeWithMe(
|
|
1066
|
-
this._commandService.beforeCommandExecuted((
|
|
1067
|
-
var
|
|
1068
|
-
if (
|
|
1069
|
-
const
|
|
1070
|
-
if (!
|
|
1071
|
-
const { unitId
|
|
1072
|
-
let
|
|
1073
|
-
if (
|
|
1074
|
-
|
|
1075
|
-
rangeTypes: [
|
|
1076
|
-
worksheetTypes: [
|
|
1077
|
-
}, [
|
|
1081
|
+
this._commandService.beforeCommandExecuted((command) => {
|
|
1082
|
+
var _a13, _b, _c;
|
|
1083
|
+
if (command.id === SmartToggleSheetsFilterCommand.id) {
|
|
1084
|
+
const univerInstanceService = this._injector.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService);
|
|
1085
|
+
if (!target) return;
|
|
1086
|
+
const { unitId, subUnitId, worksheet } = target, filterRange = (_a13 = this._sheetsFilterService.getFilterModel(unitId, subUnitId)) == null ? void 0 : _a13.getRange();
|
|
1087
|
+
let permission;
|
|
1088
|
+
if (filterRange)
|
|
1089
|
+
permission = this._sheetPermissionCheckPermission.permissionCheckWithRanges({
|
|
1090
|
+
rangeTypes: [RangeProtectionPermissionViewPoint],
|
|
1091
|
+
worksheetTypes: [WorksheetFilterPermission, WorksheetViewPermission]
|
|
1092
|
+
}, [filterRange]);
|
|
1078
1093
|
else {
|
|
1079
|
-
const
|
|
1080
|
-
if (
|
|
1081
|
-
let
|
|
1082
|
-
|
|
1083
|
-
rangeTypes: [
|
|
1084
|
-
worksheetTypes: [
|
|
1085
|
-
}, [
|
|
1094
|
+
const range = (_b = this._sheetsSelectionService.getCurrentLastSelection()) == null ? void 0 : _b.range;
|
|
1095
|
+
if (range) {
|
|
1096
|
+
let newRange = { ...range };
|
|
1097
|
+
newRange = range.startColumn === range.endColumn && range.startRow === range.endRow ? expandToContinuousRange(newRange, { left: !0, right: !0, up: !0, down: !0 }, worksheet) : newRange, permission = this._sheetPermissionCheckPermission.permissionCheckWithRanges({
|
|
1098
|
+
rangeTypes: [RangeProtectionPermissionViewPoint],
|
|
1099
|
+
worksheetTypes: [WorksheetViewPermission, WorksheetFilterPermission]
|
|
1100
|
+
}, [newRange], unitId, subUnitId);
|
|
1086
1101
|
} else
|
|
1087
|
-
|
|
1088
|
-
rangeTypes: [
|
|
1089
|
-
worksheetTypes: [
|
|
1102
|
+
permission = this._sheetPermissionCheckPermission.permissionCheckWithoutRange({
|
|
1103
|
+
rangeTypes: [RangeProtectionPermissionViewPoint],
|
|
1104
|
+
worksheetTypes: [WorksheetViewPermission, WorksheetFilterPermission]
|
|
1090
1105
|
});
|
|
1091
1106
|
}
|
|
1092
|
-
|
|
1107
|
+
permission || this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr"));
|
|
1093
1108
|
}
|
|
1094
|
-
if (
|
|
1095
|
-
const
|
|
1096
|
-
|
|
1097
|
-
rangeTypes: [
|
|
1098
|
-
worksheetTypes: [
|
|
1099
|
-
}, [
|
|
1109
|
+
if (command.id === OpenFilterPanelOperation.id) {
|
|
1110
|
+
const params = command.params, { unitId, subUnitId } = params, filterRange = (_c = this._sheetsFilterService.getFilterModel(unitId, subUnitId)) == null ? void 0 : _c.getRange(), colRange = Tools.deepClone(filterRange);
|
|
1111
|
+
colRange && (colRange.startColumn = params.col, colRange.endColumn = params.col, this._sheetPermissionCheckPermission.permissionCheckWithRanges({
|
|
1112
|
+
rangeTypes: [RangeProtectionPermissionViewPoint],
|
|
1113
|
+
worksheetTypes: [WorksheetFilterPermission, WorksheetViewPermission]
|
|
1114
|
+
}, [colRange]) || this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr")));
|
|
1100
1115
|
}
|
|
1101
1116
|
})
|
|
1102
1117
|
);
|
|
1103
1118
|
}
|
|
1104
|
-
};
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
],
|
|
1113
|
-
var
|
|
1114
|
-
return
|
|
1115
|
-
for (var
|
|
1116
|
-
|
|
1117
|
-
for (var
|
|
1119
|
+
}, __name(_a5, "SheetsFilterPermissionController"), _a5);
|
|
1120
|
+
SheetsFilterPermissionController = __decorateClass$7([
|
|
1121
|
+
__decorateParam$7(0, Inject(SheetsFilterService)),
|
|
1122
|
+
__decorateParam$7(1, Inject(LocaleService)),
|
|
1123
|
+
__decorateParam$7(2, ICommandService),
|
|
1124
|
+
__decorateParam$7(3, Inject(SheetPermissionCheckController)),
|
|
1125
|
+
__decorateParam$7(4, Inject(Injector)),
|
|
1126
|
+
__decorateParam$7(5, Inject(SheetsSelectionsService))
|
|
1127
|
+
], SheetsFilterPermissionController);
|
|
1128
|
+
var __assign = function() {
|
|
1129
|
+
return __assign = Object.assign || function(t) {
|
|
1130
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
1131
|
+
s = arguments[i];
|
|
1132
|
+
for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && (t[p] = s[p]);
|
|
1118
1133
|
}
|
|
1119
1134
|
return t;
|
|
1120
|
-
},
|
|
1121
|
-
},
|
|
1122
|
-
var
|
|
1123
|
-
for (var
|
|
1124
|
-
if (
|
|
1125
|
-
for (var i = 0,
|
|
1126
|
-
e.indexOf(
|
|
1127
|
-
return
|
|
1128
|
-
},
|
|
1129
|
-
var
|
|
1130
|
-
return
|
|
1135
|
+
}, __assign.apply(this, arguments);
|
|
1136
|
+
}, __rest = function(s, e) {
|
|
1137
|
+
var t = {};
|
|
1138
|
+
for (var p in s) Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0 && (t[p] = s[p]);
|
|
1139
|
+
if (s != null && typeof Object.getOwnPropertySymbols == "function")
|
|
1140
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)
|
|
1141
|
+
e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]) && (t[p[i]] = s[p[i]]);
|
|
1142
|
+
return t;
|
|
1143
|
+
}, IconBase = forwardRef(function(props, ref) {
|
|
1144
|
+
var icon = props.icon, id = props.id, className = props.className, extend = props.extend, restProps = __rest(props, ["icon", "id", "className", "extend"]), cls = "univerjs-icon univerjs-icon-".concat(id, " ").concat(className || "").trim(), idSuffix = useRef("_".concat(generateShortUuid()));
|
|
1145
|
+
return render(icon, "".concat(id), { defIds: icon.defIds, idSuffix: idSuffix.current }, __assign({ ref, className: cls }, restProps), extend);
|
|
1131
1146
|
});
|
|
1132
|
-
function
|
|
1133
|
-
return
|
|
1134
|
-
return
|
|
1147
|
+
function render(node, id, runtimeProps, rootProps, extend) {
|
|
1148
|
+
return createElement(node.tag, __assign(__assign({ key: id }, replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend)), rootProps), (replaceRuntimeIdsInDefs(node, runtimeProps).children || []).map(function(child, index) {
|
|
1149
|
+
return render(child, "".concat(id, "-").concat(node.tag, "-").concat(index), runtimeProps, void 0, extend);
|
|
1135
1150
|
}));
|
|
1136
1151
|
}
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1152
|
+
__name(render, "render");
|
|
1153
|
+
function replaceRuntimeIdsAndExtInAttrs(node, runtimeProps, extend) {
|
|
1154
|
+
var attrs = __assign({}, node.attrs);
|
|
1155
|
+
extend != null && extend.colorChannel1 && attrs.fill === "colorChannel1" && (attrs.fill = extend.colorChannel1);
|
|
1156
|
+
var defIds = runtimeProps.defIds;
|
|
1157
|
+
return !defIds || defIds.length === 0 || (node.tag === "use" && attrs["xlink:href"] && (attrs["xlink:href"] = attrs["xlink:href"] + runtimeProps.idSuffix), Object.entries(attrs).forEach(function(_a13) {
|
|
1158
|
+
var key = _a13[0], value = _a13[1];
|
|
1159
|
+
typeof value == "string" && (attrs[key] = value.replace(/url\(#(.*)\)/, "url(#$1".concat(runtimeProps.idSuffix, ")")));
|
|
1160
|
+
})), attrs;
|
|
1145
1161
|
}
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1162
|
+
__name(replaceRuntimeIdsAndExtInAttrs, "replaceRuntimeIdsAndExtInAttrs");
|
|
1163
|
+
function replaceRuntimeIdsInDefs(node, runtimeProps) {
|
|
1164
|
+
var _a13, defIds = runtimeProps.defIds;
|
|
1165
|
+
return !defIds || defIds.length === 0 ? node : node.tag === "defs" && (!((_a13 = node.children) === null || _a13 === void 0) && _a13.length) ? __assign(__assign({}, node), { children: node.children.map(function(child) {
|
|
1166
|
+
return typeof child.attrs.id == "string" && defIds && defIds.indexOf(child.attrs.id) > -1 ? __assign(__assign({}, child), { attrs: __assign(__assign({}, child.attrs), { id: child.attrs.id + runtimeProps.idSuffix }) }) : child;
|
|
1167
|
+
}) }) : node;
|
|
1151
1168
|
}
|
|
1152
|
-
|
|
1169
|
+
__name(replaceRuntimeIdsInDefs, "replaceRuntimeIdsInDefs");
|
|
1170
|
+
function generateShortUuid() {
|
|
1153
1171
|
return Math.random().toString(36).substring(2, 8);
|
|
1154
1172
|
}
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1173
|
+
__name(generateShortUuid, "generateShortUuid");
|
|
1174
|
+
IconBase.displayName = "UniverIcon";
|
|
1175
|
+
var element = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M3.32182 2.60967C2.98161 2.60967 2.79671 3.0074 3.01601 3.2675L6.85819 7.8246C6.94943 7.93282 6.99947 8.06981 6.99947 8.21136V12.7338C6.99947 12.898 7.0998 13.0455 7.2525 13.1058L8.73833 13.6928C9.00085 13.7965 9.28531 13.6031 9.28531 13.3208V8.21136C9.28531 8.06981 9.33535 7.93282 9.42659 7.8246L13.2688 3.2675C13.4881 3.0074 13.3032 2.60967 12.963 2.60967H3.32182ZM2.09858 4.04101C1.22139 3.0006 1.96097 1.40967 3.32182 1.40967H12.963C14.3238 1.40967 15.0634 3.0006 14.1862 4.04101L10.4853 8.43054V13.3208C10.4853 14.4498 9.34747 15.2237 8.29742 14.8089L6.81158 14.2219C6.20078 13.9806 5.79947 13.3905 5.79947 12.7338V8.43054L2.09858 4.04101Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, FilterSingle = forwardRef(function(props, ref) {
|
|
1176
|
+
return createElement(IconBase, Object.assign({}, props, {
|
|
1158
1177
|
id: "filter-single",
|
|
1159
|
-
ref
|
|
1160
|
-
icon:
|
|
1178
|
+
ref,
|
|
1179
|
+
icon: element
|
|
1161
1180
|
}));
|
|
1162
1181
|
});
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
sheetsFilterPanel: gs,
|
|
1195
|
-
sheetsFilterPanelHeader: vs,
|
|
1196
|
-
sheetsFilterPanelContent: Es,
|
|
1197
|
-
sheetsFilterPanelSelectAll: Ts,
|
|
1198
|
-
sheetsFilterPanelSelectAllCount: Fs,
|
|
1199
|
-
sheetsFilterPanelValuesContainer: Cs,
|
|
1200
|
-
inputAffixWrapper: Ns,
|
|
1201
|
-
select: Ps,
|
|
1202
|
-
radioGroup: Os,
|
|
1203
|
-
sheetsFilterPanelValuesFind: Rs,
|
|
1204
|
-
sheetsFilterPanelValuesList: Is,
|
|
1205
|
-
sheetsFilterPanelValuesListInnerContainer: ys,
|
|
1206
|
-
sheetsFilterPanelValuesVirtual: As,
|
|
1207
|
-
sheetsFilterPanelValuesItem: bs,
|
|
1208
|
-
sheetsFilterPanelValuesItemInner: Ls,
|
|
1209
|
-
sheetsFilterPanelValuesItemCount: Ms,
|
|
1210
|
-
sheetsFilterPanelValuesItemExcludeButton: $s,
|
|
1211
|
-
sheetsFilterPanelValuesItemText: ws,
|
|
1212
|
-
sheetsFilterPanelConditionsContainer: Us,
|
|
1213
|
-
sheetsFilterPanelConditionsContainerInner: Hs,
|
|
1214
|
-
sheetsFilterPanelConditionsDesc: Ds,
|
|
1215
|
-
sheetsFilterPanelFooter: xs,
|
|
1216
|
-
sheetsFilterPanelFooterPrimaryButtons: Bs,
|
|
1217
|
-
button: Vs,
|
|
1218
|
-
input: js,
|
|
1219
|
-
formDualColumnLayout: Ws,
|
|
1220
|
-
sheetsFilterTreeNode: ks,
|
|
1221
|
-
sheetsFilterTreeNodeFilterOnly: Qs,
|
|
1222
|
-
sheetsFilterTreeNodeAttach: Gs
|
|
1182
|
+
FilterSingle.displayName = "FilterSingle";
|
|
1183
|
+
const sheetsFilterPanel = "univer-sheets-filter-panel", sheetsFilterPanelHeader = "univer-sheets-filter-panel-header", sheetsFilterPanelContent = "univer-sheets-filter-panel-content", sheetsFilterPanelSelectAll = "univer-sheets-filter-panel-select-all", sheetsFilterPanelSelectAllCount = "univer-sheets-filter-panel-select-all-count", sheetsFilterPanelValuesContainer = "univer-sheets-filter-panel-values-container", inputAffixWrapper = "univer-input-affix-wrapper", select = "univer-select", radioGroup = "univer-radio-group", sheetsFilterPanelValuesFind = "univer-sheets-filter-panel-values-find", sheetsFilterPanelValuesList = "univer-sheets-filter-panel-values-list", sheetsFilterPanelValuesListInnerContainer = "univer-sheets-filter-panel-values-list-inner-container", sheetsFilterPanelValuesVirtual = "univer-sheets-filter-panel-values-virtual", sheetsFilterPanelValuesItem = "univer-sheets-filter-panel-values-item", sheetsFilterPanelValuesItemInner = "univer-sheets-filter-panel-values-item-inner", sheetsFilterPanelValuesItemCount = "univer-sheets-filter-panel-values-item-count", sheetsFilterPanelValuesItemExcludeButton = "univer-sheets-filter-panel-values-item-exclude-button", sheetsFilterPanelValuesItemText = "univer-sheets-filter-panel-values-item-text", sheetsFilterPanelConditionsContainer = "univer-sheets-filter-panel-conditions-container", sheetsFilterPanelConditionsContainerInner = "univer-sheets-filter-panel-conditions-container-inner", sheetsFilterPanelConditionsDesc = "univer-sheets-filter-panel-conditions-desc", sheetsFilterPanelFooter = "univer-sheets-filter-panel-footer", sheetsFilterPanelFooterPrimaryButtons = "univer-sheets-filter-panel-footer-primary-buttons", button = "univer-button", input = "univer-input", formDualColumnLayout = "univer-form-dual-column-layout", sheetsFilterTreeNode = "univer-sheets-filter-tree-node", sheetsFilterTreeNodeFilterOnly = "univer-sheets-filter-tree-node-filter-only", sheetsFilterTreeNodeAttach = "univer-sheets-filter-tree-node-attach", styles = {
|
|
1184
|
+
sheetsFilterPanel,
|
|
1185
|
+
sheetsFilterPanelHeader,
|
|
1186
|
+
sheetsFilterPanelContent,
|
|
1187
|
+
sheetsFilterPanelSelectAll,
|
|
1188
|
+
sheetsFilterPanelSelectAllCount,
|
|
1189
|
+
sheetsFilterPanelValuesContainer,
|
|
1190
|
+
inputAffixWrapper,
|
|
1191
|
+
select,
|
|
1192
|
+
radioGroup,
|
|
1193
|
+
sheetsFilterPanelValuesFind,
|
|
1194
|
+
sheetsFilterPanelValuesList,
|
|
1195
|
+
sheetsFilterPanelValuesListInnerContainer,
|
|
1196
|
+
sheetsFilterPanelValuesVirtual,
|
|
1197
|
+
sheetsFilterPanelValuesItem,
|
|
1198
|
+
sheetsFilterPanelValuesItemInner,
|
|
1199
|
+
sheetsFilterPanelValuesItemCount,
|
|
1200
|
+
sheetsFilterPanelValuesItemExcludeButton,
|
|
1201
|
+
sheetsFilterPanelValuesItemText,
|
|
1202
|
+
sheetsFilterPanelConditionsContainer,
|
|
1203
|
+
sheetsFilterPanelConditionsContainerInner,
|
|
1204
|
+
sheetsFilterPanelConditionsDesc,
|
|
1205
|
+
sheetsFilterPanelFooter,
|
|
1206
|
+
sheetsFilterPanelFooterPrimaryButtons,
|
|
1207
|
+
button,
|
|
1208
|
+
input,
|
|
1209
|
+
formDualColumnLayout,
|
|
1210
|
+
sheetsFilterTreeNode,
|
|
1211
|
+
sheetsFilterTreeNodeFilterOnly,
|
|
1212
|
+
sheetsFilterTreeNodeAttach
|
|
1223
1213
|
};
|
|
1224
|
-
function
|
|
1225
|
-
var
|
|
1226
|
-
const { model
|
|
1227
|
-
|
|
1228
|
-
}, [
|
|
1229
|
-
|
|
1230
|
-
}, [
|
|
1231
|
-
|
|
1232
|
-
}, [
|
|
1233
|
-
function
|
|
1234
|
-
const
|
|
1235
|
-
return /* @__PURE__ */
|
|
1236
|
-
|
|
1237
|
-
/* @__PURE__ */
|
|
1238
|
-
/* @__PURE__ */
|
|
1214
|
+
function FilterByCondition(props) {
|
|
1215
|
+
var _a13, _b;
|
|
1216
|
+
const { model } = props, localeService = useDependency(LocaleService), condition = useObservable(model.conditionItem$, void 0), formParams = useObservable(model.filterConditionFormParams$, void 0), radioValue = formParams != null && formParams.and ? "AND" : "OR", onRadioChange = useCallback((key) => {
|
|
1217
|
+
model.onConditionFormChange({ and: key === "AND" });
|
|
1218
|
+
}, [model]), primaryOptions = usePrimaryOptions(localeService), onPrimaryConditionChange = useCallback((value) => {
|
|
1219
|
+
model.onPrimaryConditionChange(value);
|
|
1220
|
+
}, [model]), secondaryOptions = useSecondaryOptions(localeService), onFormParamsChange = useCallback((diffParams) => {
|
|
1221
|
+
model.onConditionFormChange(diffParams);
|
|
1222
|
+
}, [model]), placeholder = localeService.t("sheets-filter.panel.input-values-placeholder");
|
|
1223
|
+
function renderSecondaryCondition(operator, val, name) {
|
|
1224
|
+
const shouldRenderInput = FilterConditionItems.getItemByOperator(operator).numOfParameters === 1;
|
|
1225
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1226
|
+
name === "operator2" && /* @__PURE__ */ jsxs(RadioGroup, { value: radioValue, onChange: onRadioChange, children: [
|
|
1227
|
+
/* @__PURE__ */ jsx(Radio, { value: "AND", children: localeService.t("sheets-filter.panel.and") }),
|
|
1228
|
+
/* @__PURE__ */ jsx(Radio, { value: "OR", children: localeService.t("sheets-filter.panel.or") })
|
|
1239
1229
|
] }),
|
|
1240
|
-
/* @__PURE__ */
|
|
1241
|
-
|
|
1230
|
+
/* @__PURE__ */ jsx(Select, { value: operator, options: secondaryOptions, onChange: /* @__PURE__ */ __name((operator2) => onFormParamsChange({ [name]: operator2 }), "onChange") }),
|
|
1231
|
+
shouldRenderInput && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Input, { value: val, placeholder, onChange: /* @__PURE__ */ __name((value) => onFormParamsChange({ [name === "operator1" ? "val1" : "val2"]: value }), "onChange") }) })
|
|
1242
1232
|
] });
|
|
1243
1233
|
}
|
|
1244
|
-
return /* @__PURE__ */
|
|
1245
|
-
/* @__PURE__ */
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
/* @__PURE__ */
|
|
1250
|
-
|
|
1251
|
-
/* @__PURE__ */
|
|
1252
|
-
|
|
1234
|
+
return __name(renderSecondaryCondition, "renderSecondaryCondition"), /* @__PURE__ */ jsx("div", { className: styles.sheetsFilterPanelConditionsContainer, children: condition && formParams && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1235
|
+
/* @__PURE__ */ jsx(Select, { value: condition.operator, options: primaryOptions, onChange: onPrimaryConditionChange }),
|
|
1236
|
+
FilterConditionItems.getItemByOperator(condition.operator).numOfParameters !== 0 ? /* @__PURE__ */ jsxs("div", { className: styles.sheetsFilterPanelConditionsContainerInner, children: [
|
|
1237
|
+
condition.numOfParameters >= 1 && renderSecondaryCondition(formParams.operator1, (_a13 = formParams.val1) != null ? _a13 : "", "operator1"),
|
|
1238
|
+
condition.numOfParameters >= 2 && renderSecondaryCondition(formParams.operator2, (_b = formParams.val2) != null ? _b : "", "operator2"),
|
|
1239
|
+
/* @__PURE__ */ jsxs("div", { className: styles.sheetsFilterPanelConditionsDesc, children: [
|
|
1240
|
+
localeService.t("sheets-filter.panel.?"),
|
|
1241
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
1242
|
+
localeService.t("sheets-filter.panel.*")
|
|
1253
1243
|
] })
|
|
1254
1244
|
] }) : null
|
|
1255
1245
|
] }) });
|
|
1256
1246
|
}
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1247
|
+
__name(FilterByCondition, "FilterByCondition");
|
|
1248
|
+
function usePrimaryOptions(localeService) {
|
|
1249
|
+
const locale = localeService.getCurrentLocale();
|
|
1250
|
+
return useMemo(
|
|
1260
1251
|
() => [
|
|
1261
1252
|
{
|
|
1262
1253
|
options: [
|
|
1263
|
-
{ label:
|
|
1254
|
+
{ label: localeService.t(FilterConditionItems.NONE.label), value: FilterConditionItems.NONE.operator }
|
|
1264
1255
|
]
|
|
1265
1256
|
},
|
|
1266
1257
|
{
|
|
1267
1258
|
options: [
|
|
1268
|
-
{ label:
|
|
1269
|
-
{ label:
|
|
1259
|
+
{ label: localeService.t(FilterConditionItems.EMPTY.label), value: FilterConditionItems.EMPTY.operator },
|
|
1260
|
+
{ label: localeService.t(FilterConditionItems.NOT_EMPTY.label), value: FilterConditionItems.NOT_EMPTY.operator }
|
|
1270
1261
|
]
|
|
1271
1262
|
},
|
|
1272
1263
|
{
|
|
1273
1264
|
options: [
|
|
1274
|
-
{ label:
|
|
1275
|
-
{ label:
|
|
1276
|
-
{ label:
|
|
1277
|
-
{ label:
|
|
1278
|
-
{ label:
|
|
1265
|
+
{ label: localeService.t(FilterConditionItems.TEXT_CONTAINS.label), value: FilterConditionItems.TEXT_CONTAINS.operator },
|
|
1266
|
+
{ label: localeService.t(FilterConditionItems.DOES_NOT_CONTAIN.label), value: FilterConditionItems.DOES_NOT_CONTAIN.operator },
|
|
1267
|
+
{ label: localeService.t(FilterConditionItems.STARTS_WITH.label), value: FilterConditionItems.STARTS_WITH.operator },
|
|
1268
|
+
{ label: localeService.t(FilterConditionItems.ENDS_WITH.label), value: FilterConditionItems.ENDS_WITH.operator },
|
|
1269
|
+
{ label: localeService.t(FilterConditionItems.EQUALS.label), value: FilterConditionItems.EQUALS.operator }
|
|
1279
1270
|
]
|
|
1280
1271
|
},
|
|
1281
1272
|
{
|
|
1282
1273
|
options: [
|
|
1283
|
-
{ label:
|
|
1284
|
-
{ label:
|
|
1285
|
-
{ label:
|
|
1286
|
-
{ label:
|
|
1287
|
-
{ label:
|
|
1288
|
-
{ label:
|
|
1289
|
-
{ label:
|
|
1290
|
-
{ label:
|
|
1274
|
+
{ label: localeService.t(FilterConditionItems.GREATER_THAN.label), value: FilterConditionItems.GREATER_THAN.operator },
|
|
1275
|
+
{ label: localeService.t(FilterConditionItems.GREATER_THAN_OR_EQUAL.label), value: FilterConditionItems.GREATER_THAN_OR_EQUAL.operator },
|
|
1276
|
+
{ label: localeService.t(FilterConditionItems.LESS_THAN.label), value: FilterConditionItems.LESS_THAN.operator },
|
|
1277
|
+
{ label: localeService.t(FilterConditionItems.LESS_THAN_OR_EQUAL.label), value: FilterConditionItems.LESS_THAN_OR_EQUAL.operator },
|
|
1278
|
+
{ label: localeService.t(FilterConditionItems.EQUAL.label), value: FilterConditionItems.EQUAL.operator },
|
|
1279
|
+
{ label: localeService.t(FilterConditionItems.NOT_EQUAL.label), value: FilterConditionItems.NOT_EQUAL.operator },
|
|
1280
|
+
{ label: localeService.t(FilterConditionItems.BETWEEN.label), value: FilterConditionItems.BETWEEN.operator },
|
|
1281
|
+
{ label: localeService.t(FilterConditionItems.NOT_BETWEEN.label), value: FilterConditionItems.NOT_BETWEEN.operator }
|
|
1291
1282
|
]
|
|
1292
1283
|
},
|
|
1293
1284
|
{
|
|
1294
1285
|
options: [
|
|
1295
|
-
{ label:
|
|
1286
|
+
{ label: localeService.t(FilterConditionItems.CUSTOM.label), value: FilterConditionItems.CUSTOM.operator }
|
|
1296
1287
|
]
|
|
1297
1288
|
}
|
|
1298
1289
|
],
|
|
1299
1290
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1300
|
-
[
|
|
1291
|
+
[locale, localeService]
|
|
1301
1292
|
);
|
|
1302
1293
|
}
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1294
|
+
__name(usePrimaryOptions, "usePrimaryOptions");
|
|
1295
|
+
function useSecondaryOptions(localeService) {
|
|
1296
|
+
const locale = localeService.getCurrentLocale();
|
|
1297
|
+
return useMemo(
|
|
1298
|
+
() => FilterConditionItems.ALL_CONDITIONS.filter((c) => c.numOfParameters !== 2).map((c) => ({ label: localeService.t(c.label), value: c.operator })),
|
|
1307
1299
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1308
|
-
[
|
|
1300
|
+
[locale, localeService]
|
|
1309
1301
|
);
|
|
1310
1302
|
}
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
/* @__PURE__ */
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1303
|
+
__name(useSecondaryOptions, "useSecondaryOptions");
|
|
1304
|
+
function FilterByValue(props) {
|
|
1305
|
+
const { model } = props, localeService = useDependency(LocaleService), searchText = useObservable(model.searchString$, "", !0), items = useObservable(model.filterItems$, void 0, !0), filterOnly = localeService.t("sheets-filter.panel.filter-only"), stat = statisticFilterByValueItems(items), allChecked = stat.checked > 0 && stat.unchecked === 0, indeterminate = stat.checked > 0 && stat.unchecked > 0, treeMap = model.treeMapCache, onCheckAllToggled = useCallback(() => {
|
|
1306
|
+
model.onCheckAllToggled(!allChecked);
|
|
1307
|
+
}, [model, allChecked]), onSearchValueChange = useCallback((str) => {
|
|
1308
|
+
model.setSearchString(str);
|
|
1309
|
+
}, [model]);
|
|
1310
|
+
function extractCheckedKeys(items2) {
|
|
1311
|
+
let checkedKeys = [];
|
|
1312
|
+
return items2.forEach((item) => {
|
|
1313
|
+
item.checked && checkedKeys.push(item.key), item.children && (checkedKeys = checkedKeys.concat(extractCheckedKeys(item.children)));
|
|
1314
|
+
}), checkedKeys;
|
|
1315
|
+
}
|
|
1316
|
+
return __name(extractCheckedKeys, "extractCheckedKeys"), /* @__PURE__ */ jsxs("div", { className: styles.sheetsFilterPanelValuesContainer, children: [
|
|
1317
|
+
/* @__PURE__ */ jsx(Input, { autoFocus: !0, value: searchText, placeholder: localeService.t("sheets-filter.panel.search-placeholder"), onChange: onSearchValueChange }),
|
|
1318
|
+
/* @__PURE__ */ jsxs("div", { className: styles.sheetsFilterPanelValuesList, children: [
|
|
1319
|
+
/* @__PURE__ */ jsx("div", { className: styles.sheetsFilterPanelValuesItem, children: /* @__PURE__ */ jsxs("div", { className: styles.sheetsFilterPanelValuesItemInner, children: [
|
|
1320
|
+
/* @__PURE__ */ jsx(
|
|
1321
|
+
Checkbox,
|
|
1329
1322
|
{
|
|
1330
|
-
indeterminate
|
|
1331
|
-
disabled:
|
|
1332
|
-
checked:
|
|
1333
|
-
onChange:
|
|
1323
|
+
indeterminate,
|
|
1324
|
+
disabled: items.length === 0,
|
|
1325
|
+
checked: allChecked,
|
|
1326
|
+
onChange: onCheckAllToggled
|
|
1334
1327
|
}
|
|
1335
1328
|
),
|
|
1336
|
-
/* @__PURE__ */
|
|
1337
|
-
/* @__PURE__ */
|
|
1329
|
+
/* @__PURE__ */ jsx("span", { className: styles.sheetsFilterPanelValuesItemText, children: `${localeService.t("sheets-filter.panel.select-all")}` }),
|
|
1330
|
+
/* @__PURE__ */ jsx("span", { className: styles.sheetsFilterPanelValuesItemCount, children: `(${stat.checked}/${stat.checked + stat.unchecked})` })
|
|
1338
1331
|
] }) }),
|
|
1339
|
-
/* @__PURE__ */
|
|
1340
|
-
|
|
1332
|
+
/* @__PURE__ */ jsx("div", { className: styles.sheetsFilterPanelValuesVirtual, children: /* @__PURE__ */ jsx(
|
|
1333
|
+
Tree,
|
|
1341
1334
|
{
|
|
1342
|
-
data:
|
|
1335
|
+
data: items,
|
|
1343
1336
|
defaultExpandAll: !1,
|
|
1344
|
-
valueGroup:
|
|
1337
|
+
valueGroup: extractCheckedKeys(items),
|
|
1345
1338
|
height: 180,
|
|
1346
|
-
onChange: (
|
|
1347
|
-
|
|
1348
|
-
},
|
|
1349
|
-
defaultCache:
|
|
1339
|
+
onChange: /* @__PURE__ */ __name((node) => {
|
|
1340
|
+
model.onFilterCheckToggled(node);
|
|
1341
|
+
}, "onChange"),
|
|
1342
|
+
defaultCache: treeMap,
|
|
1350
1343
|
itemHeight: 28,
|
|
1351
|
-
treeNodeClassName:
|
|
1352
|
-
attachRender: (
|
|
1353
|
-
/* @__PURE__ */
|
|
1354
|
-
/* @__PURE__ */
|
|
1355
|
-
|
|
1344
|
+
treeNodeClassName: styles.sheetsFilterTreeNode,
|
|
1345
|
+
attachRender: /* @__PURE__ */ __name((item) => /* @__PURE__ */ jsxs("div", { className: styles.sheetsFilterTreeNodeAttach, children: [
|
|
1346
|
+
/* @__PURE__ */ jsx("span", { className: styles.sheetsFilterPanelValuesItemCount, children: `(${item.count})` }),
|
|
1347
|
+
/* @__PURE__ */ jsx(
|
|
1348
|
+
Button,
|
|
1356
1349
|
{
|
|
1357
|
-
className:
|
|
1350
|
+
className: styles.sheetsFilterTreeNodeFilterOnly,
|
|
1358
1351
|
size: "small",
|
|
1359
1352
|
type: "link",
|
|
1360
|
-
onClick: () => {
|
|
1361
|
-
const
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
}) :
|
|
1366
|
-
}) :
|
|
1367
|
-
},
|
|
1368
|
-
children:
|
|
1353
|
+
onClick: /* @__PURE__ */ __name(() => {
|
|
1354
|
+
const filterValues = [];
|
|
1355
|
+
item.children ? item.children.forEach((child) => {
|
|
1356
|
+
child.children ? child.children.forEach((subChild) => {
|
|
1357
|
+
filterValues.push(subChild.key);
|
|
1358
|
+
}) : filterValues.push(child.key);
|
|
1359
|
+
}) : filterValues.push(item.key), model.onFilterOnly(filterValues);
|
|
1360
|
+
}, "onClick"),
|
|
1361
|
+
children: filterOnly
|
|
1369
1362
|
}
|
|
1370
1363
|
)
|
|
1371
|
-
] })
|
|
1364
|
+
] }), "attachRender")
|
|
1372
1365
|
}
|
|
1373
1366
|
) })
|
|
1374
1367
|
] })
|
|
1375
1368
|
] });
|
|
1376
1369
|
}
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1370
|
+
__name(FilterByValue, "FilterByValue");
|
|
1371
|
+
function FilterPanel() {
|
|
1372
|
+
var _a13;
|
|
1373
|
+
const sheetsFilterPanelService = useDependency(SheetsFilterPanelService), localeService = useDependency(LocaleService), commandService = useDependency(ICommandService), filterBy = useObservable(sheetsFilterPanelService.filterBy$, void 0, !0), filterByModel = useObservable(sheetsFilterPanelService.filterByModel$, void 0, !1), canApply = useObservable(() => (filterByModel == null ? void 0 : filterByModel.canApply$) || of(!1), void 0, !1, [filterByModel]), options = useFilterByOptions(localeService), clearFilterDisabled = !useObservable(sheetsFilterPanelService.hasCriteria$), onFilterByTypeChange = useCallback((value) => {
|
|
1374
|
+
commandService.executeCommand(ChangeFilterByOperation.id, { filterBy: value });
|
|
1375
|
+
}, [commandService]), onClearCriteria = useCallback(async () => {
|
|
1376
|
+
await (filterByModel == null ? void 0 : filterByModel.clear()), commandService.executeCommand(CloseFilterPanelOperation.id);
|
|
1377
|
+
}, [filterByModel, commandService]), onCancel = useCallback(() => {
|
|
1378
|
+
commandService.executeCommand(CloseFilterPanelOperation.id);
|
|
1379
|
+
}, [commandService]), onApply = useCallback(async () => {
|
|
1380
|
+
await (filterByModel == null ? void 0 : filterByModel.apply()), commandService.executeCommand(CloseFilterPanelOperation.id);
|
|
1381
|
+
}, [filterByModel, commandService]), range = (_a13 = useDependency(SheetsFilterService).activeFilterModel) == null ? void 0 : _a13.getRange(), colIndex = sheetsFilterPanelService.col, FilterPanelEmbedPointPart = useComponentsOfPart(SheetsUIPart.FILTER_PANEL_EMBED_POINT);
|
|
1382
|
+
return /* @__PURE__ */ jsxs("div", { className: styles.sheetsFilterPanel, children: [
|
|
1383
|
+
/* @__PURE__ */ jsx(
|
|
1384
|
+
ComponentContainer,
|
|
1391
1385
|
{
|
|
1392
|
-
components:
|
|
1393
|
-
sharedProps: { range
|
|
1386
|
+
components: FilterPanelEmbedPointPart,
|
|
1387
|
+
sharedProps: { range, colIndex, onClose: onCancel }
|
|
1394
1388
|
}
|
|
1395
1389
|
),
|
|
1396
|
-
/* @__PURE__ */
|
|
1397
|
-
|
|
1398
|
-
/* @__PURE__ */
|
|
1399
|
-
/* @__PURE__ */
|
|
1400
|
-
/* @__PURE__ */
|
|
1401
|
-
/* @__PURE__ */
|
|
1402
|
-
/* @__PURE__ */
|
|
1390
|
+
/* @__PURE__ */ jsx("div", { className: styles.sheetsFilterPanelHeader, children: /* @__PURE__ */ jsx(Segmented, { value: filterBy, options, onChange: /* @__PURE__ */ __name((value) => onFilterByTypeChange(value), "onChange") }) }),
|
|
1391
|
+
filterByModel ? /* @__PURE__ */ jsx("div", { className: styles.sheetsFilterPanelContent, children: filterBy === FilterBy.VALUES ? /* @__PURE__ */ jsx(FilterByValue, { model: filterByModel }) : /* @__PURE__ */ jsx(FilterByCondition, { model: filterByModel }) }) : /* @__PURE__ */ jsx("div", { style: { flex: 1 } }),
|
|
1392
|
+
/* @__PURE__ */ jsxs("div", { className: styles.sheetsFilterPanelFooter, children: [
|
|
1393
|
+
/* @__PURE__ */ jsx(Button, { type: "link", onClick: onClearCriteria, disabled: clearFilterDisabled, children: localeService.t("sheets-filter.panel.clear-filter") }),
|
|
1394
|
+
/* @__PURE__ */ jsxs("span", { className: styles.sheetsFilterPanelFooterPrimaryButtons, children: [
|
|
1395
|
+
/* @__PURE__ */ jsx(Button, { type: "default", onClick: onCancel, children: localeService.t("sheets-filter.panel.cancel") }),
|
|
1396
|
+
/* @__PURE__ */ jsx(Button, { disabled: !canApply, type: "primary", onClick: onApply, children: localeService.t("sheets-filter.panel.confirm") })
|
|
1403
1397
|
] })
|
|
1404
1398
|
] })
|
|
1405
1399
|
] });
|
|
1406
1400
|
}
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1401
|
+
__name(FilterPanel, "FilterPanel");
|
|
1402
|
+
function useFilterByOptions(localeService) {
|
|
1403
|
+
const locale = localeService.getCurrentLocale();
|
|
1404
|
+
return useMemo(
|
|
1410
1405
|
() => [
|
|
1411
|
-
{ label:
|
|
1412
|
-
{ label:
|
|
1406
|
+
{ label: localeService.t("sheets-filter.panel.by-values"), value: FilterBy.VALUES },
|
|
1407
|
+
{ label: localeService.t("sheets-filter.panel.by-conditions"), value: FilterBy.CONDITIONS }
|
|
1413
1408
|
],
|
|
1414
|
-
[
|
|
1409
|
+
[locale, localeService]
|
|
1415
1410
|
);
|
|
1416
1411
|
}
|
|
1417
|
-
|
|
1418
|
-
|
|
1412
|
+
__name(useFilterByOptions, "useFilterByOptions");
|
|
1413
|
+
function SmartToggleFilterMenuItemFactory(accessor) {
|
|
1414
|
+
const sheetsFilterService = accessor.get(SheetsFilterService);
|
|
1419
1415
|
return {
|
|
1420
|
-
id:
|
|
1421
|
-
type:
|
|
1416
|
+
id: SmartToggleSheetsFilterCommand.id,
|
|
1417
|
+
type: MenuItemType.BUTTON_SELECTOR,
|
|
1422
1418
|
icon: "FilterSingle",
|
|
1423
1419
|
tooltip: "sheets-filter.toolbar.smart-toggle-filter-tooltip",
|
|
1424
|
-
hidden$:
|
|
1425
|
-
activated$:
|
|
1426
|
-
disabled$:
|
|
1420
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
1421
|
+
activated$: sheetsFilterService.activeFilterModel$.pipe(map((model) => !!model)),
|
|
1422
|
+
disabled$: getObservableWithExclusiveRange$(accessor, getCurrentRangeDisable$(accessor, { worksheetTypes: [WorksheetFilterPermission, WorksheetViewPermission], rangeTypes: [RangeProtectionPermissionViewPoint] }))
|
|
1427
1423
|
};
|
|
1428
1424
|
}
|
|
1429
|
-
|
|
1430
|
-
|
|
1425
|
+
__name(SmartToggleFilterMenuItemFactory, "SmartToggleFilterMenuItemFactory");
|
|
1426
|
+
function ClearFilterCriteriaMenuItemFactory(accessor) {
|
|
1427
|
+
const sheetsFilterService = accessor.get(SheetsFilterService);
|
|
1431
1428
|
return {
|
|
1432
|
-
id:
|
|
1433
|
-
type:
|
|
1429
|
+
id: ClearSheetsFilterCriteriaCommand.id,
|
|
1430
|
+
type: MenuItemType.BUTTON,
|
|
1434
1431
|
title: "sheets-filter.toolbar.clear-filter-criteria",
|
|
1435
|
-
hidden$:
|
|
1436
|
-
disabled$:
|
|
1437
|
-
var
|
|
1438
|
-
return (
|
|
1432
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
1433
|
+
disabled$: sheetsFilterService.activeFilterModel$.pipe(switchMap((model) => {
|
|
1434
|
+
var _a13;
|
|
1435
|
+
return (_a13 = model == null ? void 0 : model.hasCriteria$.pipe(map((m) => !m))) != null ? _a13 : of(!0);
|
|
1439
1436
|
}))
|
|
1440
1437
|
};
|
|
1441
1438
|
}
|
|
1442
|
-
|
|
1443
|
-
|
|
1439
|
+
__name(ClearFilterCriteriaMenuItemFactory, "ClearFilterCriteriaMenuItemFactory");
|
|
1440
|
+
function ReCalcFilterMenuItemFactory(accessor) {
|
|
1441
|
+
const sheetsFilterService = accessor.get(SheetsFilterService);
|
|
1444
1442
|
return {
|
|
1445
|
-
id:
|
|
1446
|
-
type:
|
|
1443
|
+
id: ReCalcSheetsFilterCommand.id,
|
|
1444
|
+
type: MenuItemType.BUTTON,
|
|
1447
1445
|
title: "sheets-filter.toolbar.re-calc-filter-conditions",
|
|
1448
|
-
hidden$:
|
|
1449
|
-
disabled$:
|
|
1450
|
-
var
|
|
1451
|
-
return (
|
|
1446
|
+
hidden$: getMenuHiddenObservable(accessor, UniverInstanceType.UNIVER_SHEET),
|
|
1447
|
+
disabled$: sheetsFilterService.activeFilterModel$.pipe(switchMap((model) => {
|
|
1448
|
+
var _a13;
|
|
1449
|
+
return (_a13 = model == null ? void 0 : model.hasCriteria$.pipe(map((m) => !m))) != null ? _a13 : of(!0);
|
|
1452
1450
|
}))
|
|
1453
1451
|
};
|
|
1454
1452
|
}
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1453
|
+
__name(ReCalcFilterMenuItemFactory, "ReCalcFilterMenuItemFactory");
|
|
1454
|
+
const menuSchema = {
|
|
1455
|
+
[RibbonStartGroup.FORMULAS_INSERT]: {
|
|
1456
|
+
[SmartToggleSheetsFilterCommand.id]: {
|
|
1458
1457
|
order: 10,
|
|
1459
|
-
menuItemFactory:
|
|
1460
|
-
[
|
|
1458
|
+
menuItemFactory: SmartToggleFilterMenuItemFactory,
|
|
1459
|
+
[ClearSheetsFilterCriteriaCommand.id]: {
|
|
1461
1460
|
order: 0,
|
|
1462
|
-
menuItemFactory:
|
|
1461
|
+
menuItemFactory: ClearFilterCriteriaMenuItemFactory
|
|
1463
1462
|
},
|
|
1464
|
-
[
|
|
1463
|
+
[ReCalcSheetsFilterCommand.id]: {
|
|
1465
1464
|
order: 1,
|
|
1466
|
-
menuItemFactory:
|
|
1465
|
+
menuItemFactory: ReCalcFilterMenuItemFactory
|
|
1467
1466
|
}
|
|
1468
1467
|
}
|
|
1469
1468
|
}
|
|
1470
|
-
},
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
description: "sheets-filter.shortcut.smart-toggle-filter",
|
|
1474
|
-
preconditions: Lr,
|
|
1475
|
-
group: "4_sheet-edit"
|
|
1476
|
-
}, B = 16, nn = new Path2D("M3.30363 3C2.79117 3 2.51457 3.60097 2.84788 3.99024L6.8 8.60593V12.5662C6.8 12.7184 6.8864 12.8575 7.02289 12.9249L8.76717 13.7863C8.96655 13.8847 9.2 13.7396 9.2 13.5173V8.60593L13.1521 3.99024C13.4854 3.60097 13.2088 3 12.6964 3H3.30363Z");
|
|
1477
|
-
class dt {
|
|
1478
|
-
static drawNoCriteria(e, r, n, i) {
|
|
1479
|
-
e.save(), ct.drawWith(e, {
|
|
1469
|
+
}, BUTTON_VIEWPORT = 16, FILTER_BUTTON_EMPTY = new Path2D("M3.30363 3C2.79117 3 2.51457 3.60097 2.84788 3.99024L6.8 8.60593V12.5662C6.8 12.7184 6.8864 12.8575 7.02289 12.9249L8.76717 13.7863C8.96655 13.8847 9.2 13.7396 9.2 13.5173V8.60593L13.1521 3.99024C13.4854 3.60097 13.2088 3 12.6964 3H3.30363Z"), _FilterButton = class _FilterButton {
|
|
1470
|
+
static drawNoCriteria(ctx, size, fgColor, bgColor) {
|
|
1471
|
+
ctx.save(), Rect.drawWith(ctx, {
|
|
1480
1472
|
radius: 2,
|
|
1481
|
-
width:
|
|
1482
|
-
height:
|
|
1483
|
-
fill:
|
|
1484
|
-
}),
|
|
1473
|
+
width: BUTTON_VIEWPORT,
|
|
1474
|
+
height: BUTTON_VIEWPORT,
|
|
1475
|
+
fill: bgColor
|
|
1476
|
+
}), ctx.lineCap = "square", ctx.strokeStyle = fgColor, ctx.scale(size / BUTTON_VIEWPORT, size / BUTTON_VIEWPORT), ctx.beginPath(), ctx.lineWidth = 1, ctx.lineCap = "round", ctx.moveTo(3, 4), ctx.lineTo(13, 4), ctx.moveTo(4.5, 8), ctx.lineTo(11.5, 8), ctx.moveTo(6, 12), ctx.lineTo(10, 12), ctx.stroke(), ctx.restore();
|
|
1485
1477
|
}
|
|
1486
|
-
static drawHasCriteria(
|
|
1487
|
-
|
|
1478
|
+
static drawHasCriteria(ctx, size, fgColor, bgColor) {
|
|
1479
|
+
ctx.save(), Rect.drawWith(ctx, {
|
|
1488
1480
|
radius: 2,
|
|
1489
|
-
width:
|
|
1490
|
-
height:
|
|
1491
|
-
fill:
|
|
1492
|
-
}),
|
|
1481
|
+
width: BUTTON_VIEWPORT,
|
|
1482
|
+
height: BUTTON_VIEWPORT,
|
|
1483
|
+
fill: bgColor
|
|
1484
|
+
}), ctx.scale(size / BUTTON_VIEWPORT, size / BUTTON_VIEWPORT), ctx.fillStyle = fgColor, ctx.fill(FILTER_BUTTON_EMPTY), ctx.restore();
|
|
1493
1485
|
}
|
|
1494
|
-
}
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1486
|
+
};
|
|
1487
|
+
__name(_FilterButton, "FilterButton");
|
|
1488
|
+
let FilterButton = _FilterButton;
|
|
1489
|
+
var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __decorateClass$6 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1490
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1491
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1492
|
+
return kind && result && __defProp$6(target, key, result), result;
|
|
1493
|
+
}, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6");
|
|
1494
|
+
const FILTER_ICON_SIZE = 16, FILTER_ICON_PADDING = 1;
|
|
1495
|
+
var _a6;
|
|
1496
|
+
let SheetsFilterButtonShape = (_a6 = class extends Shape {
|
|
1497
|
+
constructor(key, props, _contextService, _commandService, _themeService) {
|
|
1498
|
+
super(key, props);
|
|
1499
|
+
__publicField(this, "_cellWidth", 0);
|
|
1500
|
+
__publicField(this, "_cellHeight", 0);
|
|
1501
|
+
__publicField(this, "_filterParams");
|
|
1502
|
+
__publicField(this, "_hovered", !1);
|
|
1503
|
+
this._contextService = _contextService, this._commandService = _commandService, this._themeService = _themeService, this.setShapeProps(props), this.onPointerDown$.subscribeEvent((evt) => this.onPointerDown(evt)), this.onPointerEnter$.subscribeEvent(() => this.onPointerEnter()), this.onPointerLeave$.subscribeEvent(() => this.onPointerLeave());
|
|
1504
|
+
}
|
|
1505
|
+
setShapeProps(props) {
|
|
1506
|
+
typeof props.cellHeight < "u" && (this._cellHeight = props.cellHeight), typeof props.cellWidth < "u" && (this._cellWidth = props.cellWidth), typeof props.filterParams < "u" && (this._filterParams = props.filterParams), this.transformByState({
|
|
1507
|
+
width: props.width,
|
|
1508
|
+
height: props.height
|
|
1514
1509
|
});
|
|
1515
1510
|
}
|
|
1516
|
-
_draw(
|
|
1517
|
-
const
|
|
1518
|
-
|
|
1519
|
-
const
|
|
1520
|
-
|
|
1521
|
-
const { hasCriteria
|
|
1522
|
-
|
|
1511
|
+
_draw(ctx) {
|
|
1512
|
+
const cellHeight = this._cellHeight, cellWidth = this._cellWidth, left = FILTER_ICON_SIZE - cellWidth, top = FILTER_ICON_SIZE - cellHeight;
|
|
1513
|
+
ctx.save();
|
|
1514
|
+
const cellRegion = new Path2D();
|
|
1515
|
+
cellRegion.rect(left, top, cellWidth, cellHeight), ctx.clip(cellRegion);
|
|
1516
|
+
const { hasCriteria } = this._filterParams, fgColor = this._themeService.getCurrentTheme().primaryColor, bgColor = this._hovered ? this._themeService.getCurrentTheme().grey50 : "rgba(255, 255, 255, 1.0)";
|
|
1517
|
+
hasCriteria ? FilterButton.drawHasCriteria(ctx, FILTER_ICON_SIZE, fgColor, bgColor) : FilterButton.drawNoCriteria(ctx, FILTER_ICON_SIZE, fgColor, bgColor), ctx.restore();
|
|
1523
1518
|
}
|
|
1524
|
-
onPointerDown(
|
|
1525
|
-
if (
|
|
1519
|
+
onPointerDown(evt) {
|
|
1520
|
+
if (evt.button === 2)
|
|
1526
1521
|
return;
|
|
1527
|
-
const { col
|
|
1528
|
-
this._contextService.getContextValue(
|
|
1529
|
-
this._commandService.executeCommand(
|
|
1530
|
-
unitId
|
|
1531
|
-
subUnitId
|
|
1532
|
-
col
|
|
1522
|
+
const { col, unitId, subUnitId } = this._filterParams;
|
|
1523
|
+
this._contextService.getContextValue(FILTER_PANEL_OPENED_KEY) || !this._commandService.hasCommand(OpenFilterPanelOperation.id) || setTimeout(() => {
|
|
1524
|
+
this._commandService.executeCommand(OpenFilterPanelOperation.id, {
|
|
1525
|
+
unitId,
|
|
1526
|
+
subUnitId,
|
|
1527
|
+
col
|
|
1533
1528
|
});
|
|
1534
1529
|
}, 200);
|
|
1535
1530
|
}
|
|
@@ -1539,342 +1534,353 @@ let Qe = class extends Jr {
|
|
|
1539
1534
|
onPointerLeave() {
|
|
1540
1535
|
this._hovered = !1, this.makeDirty(!0);
|
|
1541
1536
|
}
|
|
1542
|
-
};
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
],
|
|
1548
|
-
var
|
|
1549
|
-
for (var
|
|
1550
|
-
(
|
|
1551
|
-
return
|
|
1552
|
-
},
|
|
1553
|
-
const
|
|
1554
|
-
|
|
1555
|
-
|
|
1537
|
+
}, __name(_a6, "SheetsFilterButtonShape"), _a6);
|
|
1538
|
+
SheetsFilterButtonShape = __decorateClass$6([
|
|
1539
|
+
__decorateParam$6(2, IContextService),
|
|
1540
|
+
__decorateParam$6(3, ICommandService),
|
|
1541
|
+
__decorateParam$6(4, Inject(ThemeService))
|
|
1542
|
+
], SheetsFilterButtonShape);
|
|
1543
|
+
var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1544
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1545
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1546
|
+
return kind && result && __defProp$5(target, key, result), result;
|
|
1547
|
+
}, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5");
|
|
1548
|
+
const DEFAULT_Z_INDEX = 1e3, SHEETS_FILTER_BUTTON_Z_INDEX = 5e3;
|
|
1549
|
+
var _a7;
|
|
1550
|
+
let SheetsFilterRenderController = (_a7 = class extends RxDisposable {
|
|
1551
|
+
constructor(_context, _injector, _sheetSkeletonManagerService, _sheetsFilterService, _themeService, _sheetInterceptorService, _commandService, _selectionRenderService) {
|
|
1556
1552
|
super();
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
this._context =
|
|
1553
|
+
__publicField(this, "_filterRangeShape", null);
|
|
1554
|
+
__publicField(this, "_buttonRenderDisposable", null);
|
|
1555
|
+
__publicField(this, "_filterButtonShapes", []);
|
|
1556
|
+
this._context = _context, this._injector = _injector, this._sheetSkeletonManagerService = _sheetSkeletonManagerService, this._sheetsFilterService = _sheetsFilterService, this._themeService = _themeService, this._sheetInterceptorService = _sheetInterceptorService, this._commandService = _commandService, this._selectionRenderService = _selectionRenderService, this._initRenderer();
|
|
1561
1557
|
}
|
|
1562
1558
|
dispose() {
|
|
1563
1559
|
super.dispose(), this._disposeRendering();
|
|
1564
1560
|
}
|
|
1565
1561
|
_initRenderer() {
|
|
1566
1562
|
this._sheetSkeletonManagerService.currentSkeleton$.pipe(
|
|
1567
|
-
|
|
1568
|
-
var
|
|
1569
|
-
if (!
|
|
1570
|
-
const { unit:
|
|
1571
|
-
unitId
|
|
1572
|
-
worksheetId
|
|
1573
|
-
filterModel
|
|
1574
|
-
range:
|
|
1575
|
-
skeleton:
|
|
1576
|
-
});
|
|
1577
|
-
return
|
|
1578
|
-
|
|
1579
|
-
([
|
|
1580
|
-
var
|
|
1581
|
-
return
|
|
1563
|
+
switchMap((skeletonParams) => {
|
|
1564
|
+
var _a13, _b;
|
|
1565
|
+
if (!skeletonParams) return of(null);
|
|
1566
|
+
const { unit: workbook, unitId } = this._context, worksheetId = ((_a13 = workbook.getActiveSheet()) == null ? void 0 : _a13.getSheetId()) || "", filterModel = (_b = this._sheetsFilterService.getFilterModel(unitId, worksheetId)) != null ? _b : void 0, getParams = /* @__PURE__ */ __name(() => ({
|
|
1567
|
+
unitId,
|
|
1568
|
+
worksheetId,
|
|
1569
|
+
filterModel,
|
|
1570
|
+
range: filterModel == null ? void 0 : filterModel.getRange(),
|
|
1571
|
+
skeleton: skeletonParams.skeleton
|
|
1572
|
+
}), "getParams");
|
|
1573
|
+
return fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(
|
|
1574
|
+
filter(
|
|
1575
|
+
([command]) => {
|
|
1576
|
+
var _a14;
|
|
1577
|
+
return command.type === CommandType.MUTATION && ((_a14 = command.params) == null ? void 0 : _a14.unitId) === workbook.getUnitId() && (FILTER_MUTATIONS.has(command.id) || command.id === SetRangeValuesMutation.id);
|
|
1582
1578
|
}
|
|
1583
1579
|
),
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1580
|
+
throttleTime(20, void 0, { leading: !1, trailing: !0 }),
|
|
1581
|
+
map(getParams),
|
|
1582
|
+
startWith(getParams())
|
|
1587
1583
|
// must trigger once
|
|
1588
1584
|
);
|
|
1589
1585
|
}),
|
|
1590
|
-
|
|
1591
|
-
).subscribe((
|
|
1592
|
-
this._disposeRendering(), !(!
|
|
1586
|
+
takeUntil(this.dispose$)
|
|
1587
|
+
).subscribe((renderParams) => {
|
|
1588
|
+
this._disposeRendering(), !(!renderParams || !renderParams.range) && (this._renderRange(renderParams.range, renderParams.skeleton), this._renderButtons(renderParams));
|
|
1593
1589
|
});
|
|
1594
1590
|
}
|
|
1595
|
-
_renderRange(
|
|
1596
|
-
const { scene
|
|
1597
|
-
|
|
1598
|
-
|
|
1591
|
+
_renderRange(range, skeleton) {
|
|
1592
|
+
const { scene } = this._context, { rowHeaderWidth, columnHeaderHeight } = skeleton, filterRangeShape = this._filterRangeShape = new SelectionControl(
|
|
1593
|
+
scene,
|
|
1594
|
+
DEFAULT_Z_INDEX,
|
|
1599
1595
|
this._themeService,
|
|
1600
1596
|
{
|
|
1601
|
-
rowHeaderWidth
|
|
1602
|
-
columnHeaderHeight
|
|
1597
|
+
rowHeaderWidth,
|
|
1598
|
+
columnHeaderHeight,
|
|
1603
1599
|
enableAutoFill: !1,
|
|
1604
1600
|
highlightHeader: !1
|
|
1605
1601
|
}
|
|
1606
|
-
),
|
|
1607
|
-
range
|
|
1602
|
+
), selectionWithCoord = attachSelectionWithCoord({
|
|
1603
|
+
range,
|
|
1608
1604
|
primary: null,
|
|
1609
1605
|
style: { fill: "rgba(0, 0, 0, 0.0)" }
|
|
1610
|
-
},
|
|
1611
|
-
|
|
1612
|
-
}
|
|
1613
|
-
_renderButtons(
|
|
1614
|
-
const { range
|
|
1615
|
-
this._interceptCellContent(
|
|
1616
|
-
const { startColumn
|
|
1617
|
-
for (let
|
|
1618
|
-
const
|
|
1619
|
-
if (
|
|
1606
|
+
}, skeleton);
|
|
1607
|
+
filterRangeShape.updateRangeBySelectionWithCoord(selectionWithCoord), filterRangeShape.setEvent(!1), scene.makeDirty(!0);
|
|
1608
|
+
}
|
|
1609
|
+
_renderButtons(params) {
|
|
1610
|
+
const { range, filterModel, unitId, skeleton, worksheetId } = params, { scene } = this._context;
|
|
1611
|
+
this._interceptCellContent(unitId, worksheetId, params.range);
|
|
1612
|
+
const { startColumn, endColumn, startRow } = range;
|
|
1613
|
+
for (let col = startColumn; col <= endColumn; col++) {
|
|
1614
|
+
const key = `sheets-filter-button-${col}`, startPosition = getCoordByCell(startRow, col, scene, skeleton), { startX, startY, endX, endY } = startPosition, cellWidth = endX - startX, cellHeight = endY - startY;
|
|
1615
|
+
if (cellHeight <= FILTER_ICON_PADDING || cellWidth <= FILTER_ICON_PADDING)
|
|
1620
1616
|
continue;
|
|
1621
|
-
const
|
|
1622
|
-
left:
|
|
1623
|
-
top:
|
|
1624
|
-
height:
|
|
1625
|
-
width:
|
|
1626
|
-
zIndex:
|
|
1627
|
-
cellHeight
|
|
1628
|
-
cellWidth
|
|
1629
|
-
filterParams: { unitId
|
|
1630
|
-
},
|
|
1631
|
-
this._filterButtonShapes.push(
|
|
1617
|
+
const hasCriteria = !!filterModel.getFilterColumn(col), iconStartX = endX - FILTER_ICON_SIZE - FILTER_ICON_PADDING, iconStartY = endY - FILTER_ICON_SIZE - FILTER_ICON_PADDING, props = {
|
|
1618
|
+
left: iconStartX,
|
|
1619
|
+
top: iconStartY,
|
|
1620
|
+
height: FILTER_ICON_SIZE,
|
|
1621
|
+
width: FILTER_ICON_SIZE,
|
|
1622
|
+
zIndex: SHEETS_FILTER_BUTTON_Z_INDEX,
|
|
1623
|
+
cellHeight,
|
|
1624
|
+
cellWidth,
|
|
1625
|
+
filterParams: { unitId, subUnitId: worksheetId, col, hasCriteria }
|
|
1626
|
+
}, buttonShape = this._injector.createInstance(SheetsFilterButtonShape, key, props);
|
|
1627
|
+
this._filterButtonShapes.push(buttonShape);
|
|
1632
1628
|
}
|
|
1633
|
-
|
|
1634
|
-
}
|
|
1635
|
-
_interceptCellContent(
|
|
1636
|
-
const { startRow
|
|
1637
|
-
this._buttonRenderDisposable = this._sheetInterceptorService.intercept(
|
|
1638
|
-
effect:
|
|
1639
|
-
handler: (
|
|
1640
|
-
const { row
|
|
1641
|
-
return
|
|
1642
|
-
...
|
|
1629
|
+
scene.addObjects(this._filterButtonShapes), scene.makeDirty();
|
|
1630
|
+
}
|
|
1631
|
+
_interceptCellContent(workbookId, worksheetId, range) {
|
|
1632
|
+
const { startRow, startColumn, endColumn } = range;
|
|
1633
|
+
this._buttonRenderDisposable = this._sheetInterceptorService.intercept(INTERCEPTOR_POINT.CELL_CONTENT, {
|
|
1634
|
+
effect: InterceptorEffectEnum.Style,
|
|
1635
|
+
handler: /* @__PURE__ */ __name((cell, pos, next) => {
|
|
1636
|
+
const { row, col, unitId, subUnitId } = pos;
|
|
1637
|
+
return unitId !== workbookId || subUnitId !== worksheetId || row !== startRow || col < startColumn || col > endColumn ? next(cell) : next({
|
|
1638
|
+
...cell,
|
|
1643
1639
|
fontRenderExtension: {
|
|
1644
|
-
...
|
|
1645
|
-
rightOffset:
|
|
1640
|
+
...cell == null ? void 0 : cell.fontRenderExtension,
|
|
1641
|
+
rightOffset: FILTER_ICON_SIZE
|
|
1646
1642
|
}
|
|
1647
1643
|
});
|
|
1648
|
-
},
|
|
1644
|
+
}, "handler"),
|
|
1649
1645
|
priority: 10
|
|
1650
1646
|
});
|
|
1651
1647
|
}
|
|
1652
1648
|
_disposeRendering() {
|
|
1653
|
-
var
|
|
1654
|
-
(
|
|
1655
|
-
}
|
|
1656
|
-
};
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
],
|
|
1666
|
-
var
|
|
1667
|
-
for (var
|
|
1668
|
-
(
|
|
1669
|
-
return
|
|
1670
|
-
},
|
|
1671
|
-
let
|
|
1672
|
-
constructor(
|
|
1673
|
-
super(), this._renderManagerService =
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
].forEach((
|
|
1679
|
-
|
|
1680
|
-
[
|
|
1649
|
+
var _a13, _b;
|
|
1650
|
+
(_a13 = this._filterRangeShape) == null || _a13.dispose(), this._filterButtonShapes.forEach((s) => s.dispose()), (_b = this._buttonRenderDisposable) == null || _b.dispose(), this._filterRangeShape = null, this._buttonRenderDisposable = null, this._filterButtonShapes = [];
|
|
1651
|
+
}
|
|
1652
|
+
}, __name(_a7, "SheetsFilterRenderController"), _a7);
|
|
1653
|
+
SheetsFilterRenderController = __decorateClass$5([
|
|
1654
|
+
__decorateParam$5(1, Inject(Injector)),
|
|
1655
|
+
__decorateParam$5(2, Inject(SheetSkeletonManagerService)),
|
|
1656
|
+
__decorateParam$5(3, Inject(SheetsFilterService)),
|
|
1657
|
+
__decorateParam$5(4, Inject(ThemeService)),
|
|
1658
|
+
__decorateParam$5(5, Inject(SheetInterceptorService)),
|
|
1659
|
+
__decorateParam$5(6, ICommandService),
|
|
1660
|
+
__decorateParam$5(7, ISheetSelectionRenderService)
|
|
1661
|
+
], SheetsFilterRenderController);
|
|
1662
|
+
var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1663
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1664
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1665
|
+
return kind && result && __defProp$4(target, key, result), result;
|
|
1666
|
+
}, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a8;
|
|
1667
|
+
let SheetsFilterUIMobileController = (_a8 = class extends RxDisposable {
|
|
1668
|
+
constructor(_renderManagerService, _sheetsRenderService) {
|
|
1669
|
+
super(), this._renderManagerService = _renderManagerService, this._sheetsRenderService = _sheetsRenderService, [
|
|
1670
|
+
SetSheetsFilterRangeMutation,
|
|
1671
|
+
SetSheetsFilterCriteriaMutation,
|
|
1672
|
+
RemoveSheetsFilterMutation,
|
|
1673
|
+
ReCalcSheetsFilterMutation
|
|
1674
|
+
].forEach((m) => this.disposeWithMe(this._sheetsRenderService.registerSkeletonChangingMutations(m.id))), this.disposeWithMe(this._renderManagerService.registerRenderModule(
|
|
1675
|
+
UniverInstanceType.UNIVER_SHEET,
|
|
1676
|
+
[SheetsFilterRenderController]
|
|
1681
1677
|
));
|
|
1682
1678
|
}
|
|
1679
|
+
}, __name(_a8, "SheetsFilterUIMobileController"), _a8);
|
|
1680
|
+
SheetsFilterUIMobileController = __decorateClass$4([
|
|
1681
|
+
__decorateParam$4(0, IRenderManagerService),
|
|
1682
|
+
__decorateParam$4(1, Inject(SheetsRenderService))
|
|
1683
|
+
], SheetsFilterUIMobileController);
|
|
1684
|
+
const SmartToggleFilterShortcut = {
|
|
1685
|
+
id: SmartToggleSheetsFilterCommand.id,
|
|
1686
|
+
binding: KeyCode.L | MetaKeys.CTRL_COMMAND | MetaKeys.SHIFT,
|
|
1687
|
+
description: "sheets-filter.shortcut.smart-toggle-filter",
|
|
1688
|
+
preconditions: whenSheetEditorFocused,
|
|
1689
|
+
group: "4_sheet-edit"
|
|
1683
1690
|
};
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
super(m, g);
|
|
1697
|
-
_(this, "_popupDisposable");
|
|
1698
|
-
this._injector = e, this._componentManager = r, this._sheetsFilterPanelService = n, this._sheetCanvasPopupService = i, this._sheetsFilterService = l, this._localeService = s, this._shortcutService = o, this._commandService = a, this._menuManagerService = c, this._contextService = h, this._messageService = d, this._initCommands(), this._initShortcuts(), this._initMenuItems(), this._initUI();
|
|
1691
|
+
var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1692
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1693
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1694
|
+
return kind && result && __defProp$3(target, key, result), result;
|
|
1695
|
+
}, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3");
|
|
1696
|
+
const FILTER_PANEL_POPUP_KEY = "FILTER_PANEL_POPUP";
|
|
1697
|
+
var _a9;
|
|
1698
|
+
let SheetsFilterUIDesktopController = (_a9 = class extends SheetsFilterUIMobileController {
|
|
1699
|
+
constructor(_injector, _componentManager, _sheetsFilterPanelService, _sheetCanvasPopupService, _sheetsFilterService, _localeService, _shortcutService, _commandService, _menuManagerService, _contextService, _messageService, sheetsRenderService, renderManagerService) {
|
|
1700
|
+
super(renderManagerService, sheetsRenderService);
|
|
1701
|
+
__publicField(this, "_popupDisposable");
|
|
1702
|
+
this._injector = _injector, this._componentManager = _componentManager, this._sheetsFilterPanelService = _sheetsFilterPanelService, this._sheetCanvasPopupService = _sheetCanvasPopupService, this._sheetsFilterService = _sheetsFilterService, this._localeService = _localeService, this._shortcutService = _shortcutService, this._commandService = _commandService, this._menuManagerService = _menuManagerService, this._contextService = _contextService, this._messageService = _messageService, this._initCommands(), this._initShortcuts(), this._initMenuItems(), this._initUI();
|
|
1699
1703
|
}
|
|
1700
1704
|
dispose() {
|
|
1701
1705
|
super.dispose(), this._closeFilterPopup();
|
|
1702
1706
|
}
|
|
1703
1707
|
_initShortcuts() {
|
|
1704
1708
|
[
|
|
1705
|
-
|
|
1706
|
-
].forEach((
|
|
1707
|
-
this.disposeWithMe(this._shortcutService.registerShortcut(
|
|
1709
|
+
SmartToggleFilterShortcut
|
|
1710
|
+
].forEach((shortcut) => {
|
|
1711
|
+
this.disposeWithMe(this._shortcutService.registerShortcut(shortcut));
|
|
1708
1712
|
});
|
|
1709
1713
|
}
|
|
1710
1714
|
_initCommands() {
|
|
1711
1715
|
[
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
].forEach((
|
|
1722
|
-
this.disposeWithMe(this._commandService.registerCommand(
|
|
1716
|
+
SmartToggleSheetsFilterCommand,
|
|
1717
|
+
RemoveSheetFilterCommand,
|
|
1718
|
+
SetSheetFilterRangeCommand,
|
|
1719
|
+
SetSheetsFilterCriteriaCommand,
|
|
1720
|
+
ClearSheetsFilterCriteriaCommand,
|
|
1721
|
+
ReCalcSheetsFilterCommand,
|
|
1722
|
+
ChangeFilterByOperation,
|
|
1723
|
+
OpenFilterPanelOperation,
|
|
1724
|
+
CloseFilterPanelOperation
|
|
1725
|
+
].forEach((c) => {
|
|
1726
|
+
this.disposeWithMe(this._commandService.registerCommand(c));
|
|
1723
1727
|
});
|
|
1724
1728
|
}
|
|
1725
1729
|
_initMenuItems() {
|
|
1726
|
-
this._menuManagerService.mergeMenu(
|
|
1730
|
+
this._menuManagerService.mergeMenu(menuSchema);
|
|
1727
1731
|
}
|
|
1728
1732
|
_initUI() {
|
|
1729
|
-
this.disposeWithMe(this._componentManager.register(
|
|
1730
|
-
|
|
1731
|
-
})), this.disposeWithMe(this._sheetsFilterService.errorMsg$.subscribe((
|
|
1732
|
-
|
|
1733
|
-
type:
|
|
1734
|
-
content: this._localeService.t(
|
|
1733
|
+
this.disposeWithMe(this._componentManager.register(FILTER_PANEL_POPUP_KEY, FilterPanel)), this.disposeWithMe(this._componentManager.register("FilterSingle", FilterSingle)), this.disposeWithMe(this._contextService.subscribeContextValue$(FILTER_PANEL_OPENED_KEY).pipe(distinctUntilChanged()).subscribe((open) => {
|
|
1734
|
+
open ? this._openFilterPopup() : this._closeFilterPopup();
|
|
1735
|
+
})), this.disposeWithMe(this._sheetsFilterService.errorMsg$.subscribe((content) => {
|
|
1736
|
+
content && this._messageService.show({
|
|
1737
|
+
type: MessageType.Error,
|
|
1738
|
+
content: this._localeService.t(content)
|
|
1735
1739
|
});
|
|
1736
1740
|
}));
|
|
1737
1741
|
}
|
|
1738
1742
|
_openFilterPopup() {
|
|
1739
|
-
const
|
|
1740
|
-
if (!
|
|
1743
|
+
const currentFilterModel = this._sheetsFilterPanelService.filterModel;
|
|
1744
|
+
if (!currentFilterModel)
|
|
1741
1745
|
throw new Error("[SheetsFilterUIController]: no filter model when opening filter popup!");
|
|
1742
|
-
const
|
|
1743
|
-
this._popupDisposable = this._sheetCanvasPopupService.attachPopupToCell(
|
|
1744
|
-
componentKey:
|
|
1746
|
+
const range = currentFilterModel.getRange(), col = this._sheetsFilterPanelService.col, { startRow } = range;
|
|
1747
|
+
this._popupDisposable = this._sheetCanvasPopupService.attachPopupToCell(startRow, col, {
|
|
1748
|
+
componentKey: FILTER_PANEL_POPUP_KEY,
|
|
1745
1749
|
direction: "horizontal",
|
|
1746
|
-
onClickOutside: () => this._commandService.syncExecuteCommand(
|
|
1750
|
+
onClickOutside: /* @__PURE__ */ __name(() => this._commandService.syncExecuteCommand(CloseFilterPanelOperation.id), "onClickOutside"),
|
|
1747
1751
|
offset: [5, 0]
|
|
1748
1752
|
});
|
|
1749
1753
|
}
|
|
1750
1754
|
_closeFilterPopup() {
|
|
1751
|
-
var
|
|
1752
|
-
(
|
|
1753
|
-
}
|
|
1754
|
-
};
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
],
|
|
1770
|
-
var
|
|
1771
|
-
for (var
|
|
1772
|
-
(
|
|
1773
|
-
return
|
|
1774
|
-
},
|
|
1775
|
-
const
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1755
|
+
var _a13;
|
|
1756
|
+
(_a13 = this._popupDisposable) == null || _a13.dispose(), this._popupDisposable = null;
|
|
1757
|
+
}
|
|
1758
|
+
}, __name(_a9, "SheetsFilterUIDesktopController"), _a9);
|
|
1759
|
+
SheetsFilterUIDesktopController = __decorateClass$3([
|
|
1760
|
+
__decorateParam$3(0, Inject(Injector)),
|
|
1761
|
+
__decorateParam$3(1, Inject(ComponentManager)),
|
|
1762
|
+
__decorateParam$3(2, Inject(SheetsFilterPanelService)),
|
|
1763
|
+
__decorateParam$3(3, Inject(SheetCanvasPopManagerService)),
|
|
1764
|
+
__decorateParam$3(4, Inject(SheetsFilterService)),
|
|
1765
|
+
__decorateParam$3(5, Inject(LocaleService)),
|
|
1766
|
+
__decorateParam$3(6, IShortcutService),
|
|
1767
|
+
__decorateParam$3(7, ICommandService),
|
|
1768
|
+
__decorateParam$3(8, IMenuManagerService),
|
|
1769
|
+
__decorateParam$3(9, IContextService),
|
|
1770
|
+
__decorateParam$3(10, IMessageService),
|
|
1771
|
+
__decorateParam$3(11, Inject(SheetsRenderService)),
|
|
1772
|
+
__decorateParam$3(12, IRenderManagerService)
|
|
1773
|
+
], SheetsFilterUIDesktopController);
|
|
1774
|
+
var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __defNormalProp$1 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, "__defNormalProp$1"), __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1775
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1776
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1777
|
+
return kind && result && __defProp$2(target, key, result), result;
|
|
1778
|
+
}, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2"), __publicField$1 = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp$1(obj, typeof key != "symbol" ? key + "" : key, value), "__publicField$1");
|
|
1779
|
+
const NAME$1 = "SHEET_FILTER_UI_PLUGIN";
|
|
1780
|
+
var _a10;
|
|
1781
|
+
let UniverSheetsFilterUIPlugin = (_a10 = class extends Plugin {
|
|
1782
|
+
constructor(_config = defaultPluginConfig, _injector, _configService, _rpcChannelService) {
|
|
1783
|
+
super(), this._config = _config, this._injector = _injector, this._configService = _configService, this._rpcChannelService = _rpcChannelService;
|
|
1784
|
+
const { menu, ...rest } = merge$1(
|
|
1780
1785
|
{},
|
|
1781
|
-
|
|
1786
|
+
defaultPluginConfig,
|
|
1782
1787
|
this._config
|
|
1783
1788
|
);
|
|
1784
|
-
|
|
1789
|
+
menu && this._configService.setConfig("menu", menu, { merge: !0 }), this._configService.setConfig(SHEETS_FILTER_UI_PLUGIN_CONFIG_KEY, rest);
|
|
1785
1790
|
}
|
|
1786
1791
|
onStarting() {
|
|
1787
1792
|
[
|
|
1788
|
-
[
|
|
1789
|
-
[
|
|
1790
|
-
[
|
|
1791
|
-
].forEach((
|
|
1792
|
-
useFactory: () =>
|
|
1793
|
-
this._rpcChannelService.requestChannel(
|
|
1794
|
-
)
|
|
1793
|
+
[SheetsFilterPanelService],
|
|
1794
|
+
[SheetsFilterPermissionController],
|
|
1795
|
+
[SheetsFilterUIDesktopController]
|
|
1796
|
+
].forEach((d) => this._injector.add(d)), this._config.useRemoteFilterValuesGenerator && this._rpcChannelService && this._injector.add([ISheetsGenerateFilterValuesService, {
|
|
1797
|
+
useFactory: /* @__PURE__ */ __name(() => toModule(
|
|
1798
|
+
this._rpcChannelService.requestChannel(SHEETS_GENERATE_FILTER_VALUES_SERVICE_NAME)
|
|
1799
|
+
), "useFactory")
|
|
1795
1800
|
}]);
|
|
1796
1801
|
}
|
|
1797
1802
|
onReady() {
|
|
1798
|
-
this._injector.get(
|
|
1803
|
+
this._injector.get(SheetsFilterPermissionController);
|
|
1799
1804
|
}
|
|
1800
1805
|
onRendered() {
|
|
1801
|
-
this._injector.get(
|
|
1802
|
-
}
|
|
1803
|
-
};
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
],
|
|
1812
|
-
var
|
|
1813
|
-
for (var
|
|
1814
|
-
(
|
|
1815
|
-
return
|
|
1816
|
-
},
|
|
1817
|
-
const
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1806
|
+
this._injector.get(SheetsFilterUIDesktopController);
|
|
1807
|
+
}
|
|
1808
|
+
}, __name(_a10, "UniverSheetsFilterUIPlugin"), _a10);
|
|
1809
|
+
__publicField$1(UniverSheetsFilterUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
|
|
1810
|
+
__publicField$1(UniverSheetsFilterUIPlugin, "pluginName", NAME$1);
|
|
1811
|
+
UniverSheetsFilterUIPlugin = __decorateClass$2([
|
|
1812
|
+
DependentOn(UniverSheetsFilterPlugin),
|
|
1813
|
+
__decorateParam$2(1, Inject(Injector)),
|
|
1814
|
+
__decorateParam$2(2, IConfigService),
|
|
1815
|
+
__decorateParam$2(3, Optional(IRPCChannelService))
|
|
1816
|
+
], UniverSheetsFilterUIPlugin);
|
|
1817
|
+
var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __defNormalProp2 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, "__defNormalProp"), __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1818
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1819
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1820
|
+
return kind && result && __defProp$1(target, key, result), result;
|
|
1821
|
+
}, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), __publicField2 = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp2(obj, typeof key != "symbol" ? key + "" : key, value), "__publicField");
|
|
1822
|
+
const NAME = "SHEET_FILTER_UI_PLUGIN";
|
|
1823
|
+
var _a11;
|
|
1824
|
+
let UniverSheetsFilterMobileUIPlugin = (_a11 = class extends Plugin {
|
|
1825
|
+
constructor(_config = defaultPluginConfig, _injector, _configService) {
|
|
1826
|
+
super(), this._config = _config, this._injector = _injector, this._configService = _configService;
|
|
1827
|
+
const { menu, ...rest } = merge$1(
|
|
1822
1828
|
{},
|
|
1823
|
-
|
|
1829
|
+
defaultPluginConfig,
|
|
1824
1830
|
this._config
|
|
1825
1831
|
);
|
|
1826
|
-
|
|
1832
|
+
menu && this._configService.setConfig("menu", menu, { merge: !0 }), this._configService.setConfig(SHEETS_FILTER_UI_PLUGIN_CONFIG_KEY, rest);
|
|
1827
1833
|
}
|
|
1828
1834
|
onStarting() {
|
|
1829
1835
|
[
|
|
1830
|
-
[
|
|
1831
|
-
[
|
|
1832
|
-
].forEach((
|
|
1836
|
+
[SheetsFilterPermissionController],
|
|
1837
|
+
[SheetsFilterUIMobileController]
|
|
1838
|
+
].forEach((d) => this._injector.add(d));
|
|
1833
1839
|
}
|
|
1834
1840
|
onReady() {
|
|
1835
|
-
this._injector.get(
|
|
1841
|
+
this._injector.get(SheetsFilterPermissionController);
|
|
1836
1842
|
}
|
|
1837
1843
|
onRendered() {
|
|
1838
|
-
this._injector.get(
|
|
1839
|
-
}
|
|
1840
|
-
};
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
],
|
|
1848
|
-
var
|
|
1849
|
-
for (var
|
|
1850
|
-
(
|
|
1851
|
-
return
|
|
1852
|
-
},
|
|
1853
|
-
let
|
|
1854
|
-
constructor(
|
|
1855
|
-
super(), this._config =
|
|
1844
|
+
this._injector.get(SheetsFilterUIMobileController);
|
|
1845
|
+
}
|
|
1846
|
+
}, __name(_a11, "UniverSheetsFilterMobileUIPlugin"), _a11);
|
|
1847
|
+
__publicField2(UniverSheetsFilterMobileUIPlugin, "type", UniverInstanceType.UNIVER_SHEET);
|
|
1848
|
+
__publicField2(UniverSheetsFilterMobileUIPlugin, "pluginName", NAME);
|
|
1849
|
+
UniverSheetsFilterMobileUIPlugin = __decorateClass$1([
|
|
1850
|
+
DependentOn(UniverSheetsFilterPlugin),
|
|
1851
|
+
__decorateParam$1(1, Inject(Injector)),
|
|
1852
|
+
__decorateParam$1(2, IConfigService)
|
|
1853
|
+
], UniverSheetsFilterMobileUIPlugin);
|
|
1854
|
+
var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
|
|
1855
|
+
for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
|
|
1856
|
+
(decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
|
|
1857
|
+
return kind && result && __defProp2(target, key, result), result;
|
|
1858
|
+
}, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), _a12;
|
|
1859
|
+
let UniverSheetsFilterUIWorkerPlugin = (_a12 = class extends Plugin {
|
|
1860
|
+
constructor(_config, _injector, _rpcChannelService) {
|
|
1861
|
+
super(), this._config = _config, this._injector = _injector, this._rpcChannelService = _rpcChannelService;
|
|
1856
1862
|
}
|
|
1857
1863
|
onStarting() {
|
|
1858
1864
|
[
|
|
1859
|
-
[
|
|
1860
|
-
].forEach((
|
|
1865
|
+
[ISheetsGenerateFilterValuesService, { useClass: SheetsGenerateFilterValuesService }]
|
|
1866
|
+
].forEach((d) => this._injector.add(d));
|
|
1861
1867
|
}
|
|
1862
1868
|
onReady() {
|
|
1863
1869
|
this._rpcChannelService.registerChannel(
|
|
1864
|
-
|
|
1865
|
-
|
|
1870
|
+
SHEETS_GENERATE_FILTER_VALUES_SERVICE_NAME,
|
|
1871
|
+
fromModule(this._injector.get(ISheetsGenerateFilterValuesService))
|
|
1866
1872
|
);
|
|
1867
1873
|
}
|
|
1868
|
-
},
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
],
|
|
1874
|
+
}, __name(_a12, "UniverSheetsFilterUIWorkerPlugin"), __publicField(_a12, "type", UniverInstanceType.UNIVER_SHEET), __publicField(_a12, "pluginName", "SHEET_FILTER_UI_WORKER_PLUGIN"), _a12);
|
|
1875
|
+
UniverSheetsFilterUIWorkerPlugin = __decorateClass([
|
|
1876
|
+
__decorateParam(1, Inject(Injector)),
|
|
1877
|
+
__decorateParam(2, IRPCChannelService)
|
|
1878
|
+
], UniverSheetsFilterUIWorkerPlugin);
|
|
1873
1879
|
export {
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
+
ChangeFilterByOperation,
|
|
1881
|
+
CloseFilterPanelOperation,
|
|
1882
|
+
OpenFilterPanelOperation,
|
|
1883
|
+
UniverSheetsFilterMobileUIPlugin,
|
|
1884
|
+
UniverSheetsFilterUIPlugin,
|
|
1885
|
+
UniverSheetsFilterUIWorkerPlugin
|
|
1880
1886
|
};
|