@univerjs/sheets-filter-ui 1.3.1 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/README.md +18 -7
  2. package/lib/cjs/config-BF97qkoE.js +309 -0
  3. package/lib/cjs/index.js +217 -465
  4. package/lib/cjs/locale/ar-SA.js +1 -2
  5. package/lib/cjs/locale/ca-ES.js +1 -2
  6. package/lib/cjs/locale/de-DE.js +1 -2
  7. package/lib/cjs/locale/en-US.js +1 -2
  8. package/lib/cjs/locale/es-ES.js +1 -2
  9. package/lib/cjs/locale/fa-IR.js +1 -2
  10. package/lib/cjs/locale/fr-FR.js +1 -2
  11. package/lib/cjs/locale/id-ID.js +1 -2
  12. package/lib/cjs/locale/it-IT.js +1 -2
  13. package/lib/cjs/locale/ja-JP.js +1 -2
  14. package/lib/cjs/locale/ko-KR.js +1 -2
  15. package/lib/cjs/locale/pl-PL.js +1 -2
  16. package/lib/cjs/locale/pt-BR.js +1 -2
  17. package/lib/cjs/locale/ru-RU.js +1 -2
  18. package/lib/cjs/locale/sk-SK.js +1 -2
  19. package/lib/cjs/locale/vi-VN.js +1 -2
  20. package/lib/cjs/locale/zh-CN.js +1 -2
  21. package/lib/cjs/locale/zh-HK.js +1 -2
  22. package/lib/cjs/locale/zh-TW.js +1 -2
  23. package/lib/cjs/worker.js +39 -0
  24. package/lib/config-CbqvVwlO.js +244 -0
  25. package/lib/es/config-CbqvVwlO.js +244 -0
  26. package/lib/es/index.js +110 -352
  27. package/lib/es/locale/ar-SA.js +1 -2
  28. package/lib/es/locale/ca-ES.js +1 -2
  29. package/lib/es/locale/de-DE.js +1 -2
  30. package/lib/es/locale/en-US.js +1 -2
  31. package/lib/es/locale/es-ES.js +1 -2
  32. package/lib/es/locale/fa-IR.js +1 -2
  33. package/lib/es/locale/fr-FR.js +1 -2
  34. package/lib/es/locale/id-ID.js +1 -2
  35. package/lib/es/locale/it-IT.js +1 -2
  36. package/lib/es/locale/ja-JP.js +1 -2
  37. package/lib/es/locale/ko-KR.js +1 -2
  38. package/lib/es/locale/pl-PL.js +1 -2
  39. package/lib/es/locale/pt-BR.js +1 -2
  40. package/lib/es/locale/ru-RU.js +1 -2
  41. package/lib/es/locale/sk-SK.js +1 -2
  42. package/lib/es/locale/vi-VN.js +1 -2
  43. package/lib/es/locale/zh-CN.js +1 -2
  44. package/lib/es/locale/zh-HK.js +1 -2
  45. package/lib/es/locale/zh-TW.js +1 -2
  46. package/lib/es/worker.js +33 -0
  47. package/lib/index.js +110 -352
  48. package/lib/locale/ar-SA.js +1 -2
  49. package/lib/locale/ca-ES.js +1 -2
  50. package/lib/locale/de-DE.js +1 -2
  51. package/lib/locale/en-US.js +1 -2
  52. package/lib/locale/es-ES.js +1 -2
  53. package/lib/locale/fa-IR.js +1 -2
  54. package/lib/locale/fr-FR.js +1 -2
  55. package/lib/locale/id-ID.js +1 -2
  56. package/lib/locale/it-IT.js +1 -2
  57. package/lib/locale/ja-JP.js +1 -2
  58. package/lib/locale/ko-KR.js +1 -2
  59. package/lib/locale/pl-PL.js +1 -2
  60. package/lib/locale/pt-BR.js +1 -2
  61. package/lib/locale/ru-RU.js +1 -2
  62. package/lib/locale/sk-SK.js +1 -2
  63. package/lib/locale/vi-VN.js +1 -2
  64. package/lib/locale/zh-CN.js +1 -2
  65. package/lib/locale/zh-HK.js +1 -2
  66. package/lib/locale/zh-TW.js +1 -2
  67. package/lib/types/__tests__/data.d.ts +2 -2
  68. package/lib/types/index.d.ts +0 -1
  69. package/lib/types/services/sheets-filter-panel.service.d.ts +1 -1
  70. package/lib/types/worker/generate-filter-values.service.d.ts +1 -1
  71. package/lib/types/worker.d.ts +16 -0
  72. package/lib/umd/index.js +5 -5
  73. package/lib/worker.js +33 -0
  74. package/package.json +21 -16
@@ -1,4 +1,4 @@
1
- //#region src/locale/ar-SA.ts
1
+ // src/locale/ar-SA.ts
2
2
  const locale = { "sheets-filter-ui": {
3
3
  toolbar: {
4
4
  "smart-toggle-filter-tooltip": "تبديل التصفية",
@@ -80,5 +80,4 @@ const locale = { "sheets-filter-ui": {
80
80
  }
81
81
  } };
82
82
 
83
- //#endregion
84
83
  module.exports = locale;
@@ -1,4 +1,4 @@
1
- //#region src/locale/ca-ES.ts
1
+ // src/locale/ca-ES.ts
2
2
  const locale = { "sheets-filter-ui": {
3
3
  toolbar: {
4
4
  "smart-toggle-filter-tooltip": "Alterna el filtre",
@@ -80,5 +80,4 @@ const locale = { "sheets-filter-ui": {
80
80
  }
81
81
  } };
82
82
 
83
- //#endregion
84
83
  module.exports = locale;
@@ -1,4 +1,4 @@
1
- //#region src/locale/de-DE.ts
1
+ // src/locale/de-DE.ts
2
2
  const locale = { "sheets-filter-ui": {
3
3
  toolbar: {
4
4
  "smart-toggle-filter-tooltip": "Filter ein-/ausschalten",
@@ -80,5 +80,4 @@ const locale = { "sheets-filter-ui": {
80
80
  }
81
81
  } };
82
82
 
83
- //#endregion
84
83
  module.exports = locale;
@@ -1,4 +1,4 @@
1
- //#region src/locale/en-US.ts
1
+ // src/locale/en-US.ts
2
2
  /**
3
3
  * Copyright 2023-present DreamNum Co., Ltd.
4
4
  *
@@ -95,5 +95,4 @@ const locale = { "sheets-filter-ui": {
95
95
  }
96
96
  } };
97
97
 
98
- //#endregion
99
98
  module.exports = locale;
@@ -1,4 +1,4 @@
1
- //#region src/locale/es-ES.ts
1
+ // src/locale/es-ES.ts
2
2
  const locale = { "sheets-filter-ui": {
3
3
  toolbar: {
4
4
  "smart-toggle-filter-tooltip": "Alternar filtro",
@@ -80,5 +80,4 @@ const locale = { "sheets-filter-ui": {
80
80
  }
81
81
  } };
82
82
 
83
- //#endregion
84
83
  module.exports = locale;
@@ -1,4 +1,4 @@
1
- //#region src/locale/fa-IR.ts
1
+ // src/locale/fa-IR.ts
2
2
  const locale = { "sheets-filter-ui": {
3
3
  toolbar: {
4
4
  "smart-toggle-filter-tooltip": "تغییر حالت فیلتر",
@@ -80,5 +80,4 @@ const locale = { "sheets-filter-ui": {
80
80
  }
81
81
  } };
82
82
 
83
- //#endregion
84
83
  module.exports = locale;
@@ -1,4 +1,4 @@
1
- //#region src/locale/fr-FR.ts
1
+ // src/locale/fr-FR.ts
2
2
  const locale = { "sheets-filter-ui": {
3
3
  toolbar: {
4
4
  "smart-toggle-filter-tooltip": "Inverser le filtre",
@@ -80,5 +80,4 @@ const locale = { "sheets-filter-ui": {
80
80
  }
81
81
  } };
82
82
 
83
- //#endregion
84
83
  module.exports = locale;
@@ -1,4 +1,4 @@
1
- //#region src/locale/id-ID.ts
1
+ // src/locale/id-ID.ts
2
2
  const locale = { "sheets-filter-ui": {
3
3
  toolbar: {
4
4
  "smart-toggle-filter-tooltip": "Aktifkan/Nonaktifkan Filter",
@@ -80,5 +80,4 @@ const locale = { "sheets-filter-ui": {
80
80
  }
81
81
  } };
82
82
 
83
- //#endregion
84
83
  module.exports = locale;
@@ -1,4 +1,4 @@
1
- //#region src/locale/it-IT.ts
1
+ // src/locale/it-IT.ts
2
2
  const locale = { "sheets-filter-ui": {
3
3
  toolbar: {
4
4
  "smart-toggle-filter-tooltip": "Attiva/disattiva filtro",
@@ -80,5 +80,4 @@ const locale = { "sheets-filter-ui": {
80
80
  }
81
81
  } };
82
82
 
83
- //#endregion
84
83
  module.exports = locale;
@@ -1,4 +1,4 @@
1
- //#region src/locale/ja-JP.ts
1
+ // src/locale/ja-JP.ts
2
2
  const locale = { "sheets-filter-ui": {
3
3
  toolbar: {
4
4
  "smart-toggle-filter-tooltip": "フィルタの切替",
@@ -80,5 +80,4 @@ const locale = { "sheets-filter-ui": {
80
80
  }
81
81
  } };
82
82
 
83
- //#endregion
84
83
  module.exports = locale;
@@ -1,4 +1,4 @@
1
- //#region src/locale/ko-KR.ts
1
+ // src/locale/ko-KR.ts
2
2
  const locale = { "sheets-filter-ui": {
3
3
  toolbar: {
4
4
  "smart-toggle-filter-tooltip": "필터 토글",
@@ -80,5 +80,4 @@ const locale = { "sheets-filter-ui": {
80
80
  }
81
81
  } };
82
82
 
83
- //#endregion
84
83
  module.exports = locale;
@@ -1,4 +1,4 @@
1
- //#region src/locale/pl-PL.ts
1
+ // src/locale/pl-PL.ts
2
2
  const locale = { "sheets-filter-ui": {
3
3
  toolbar: {
4
4
  "smart-toggle-filter-tooltip": "Przełącz filtr",
@@ -80,5 +80,4 @@ const locale = { "sheets-filter-ui": {
80
80
  }
81
81
  } };
82
82
 
83
- //#endregion
84
83
  module.exports = locale;
@@ -1,4 +1,4 @@
1
- //#region src/locale/pt-BR.ts
1
+ // src/locale/pt-BR.ts
2
2
  const locale = { "sheets-filter-ui": {
3
3
  toolbar: {
4
4
  "smart-toggle-filter-tooltip": "Alternar Filtro",
@@ -80,5 +80,4 @@ const locale = { "sheets-filter-ui": {
80
80
  }
81
81
  } };
82
82
 
83
- //#endregion
84
83
  module.exports = locale;
@@ -1,4 +1,4 @@
1
- //#region src/locale/ru-RU.ts
1
+ // src/locale/ru-RU.ts
2
2
  const locale = { "sheets-filter-ui": {
3
3
  toolbar: {
4
4
  "smart-toggle-filter-tooltip": "Переключить фильтр",
@@ -80,5 +80,4 @@ const locale = { "sheets-filter-ui": {
80
80
  }
81
81
  } };
82
82
 
83
- //#endregion
84
83
  module.exports = locale;
@@ -1,4 +1,4 @@
1
- //#region src/locale/sk-SK.ts
1
+ // src/locale/sk-SK.ts
2
2
  const locale = { "sheets-filter-ui": {
3
3
  toolbar: {
4
4
  "smart-toggle-filter-tooltip": "Prepnúť filter",
@@ -80,5 +80,4 @@ const locale = { "sheets-filter-ui": {
80
80
  }
81
81
  } };
82
82
 
83
- //#endregion
84
83
  module.exports = locale;
@@ -1,4 +1,4 @@
1
- //#region src/locale/vi-VN.ts
1
+ // src/locale/vi-VN.ts
2
2
  const locale = { "sheets-filter-ui": {
3
3
  toolbar: {
4
4
  "smart-toggle-filter-tooltip": "Lọc",
@@ -80,5 +80,4 @@ const locale = { "sheets-filter-ui": {
80
80
  }
81
81
  } };
82
82
 
83
- //#endregion
84
83
  module.exports = locale;
@@ -1,4 +1,4 @@
1
- //#region src/locale/zh-CN.ts
1
+ // src/locale/zh-CN.ts
2
2
  const locale = { "sheets-filter-ui": {
3
3
  toolbar: {
4
4
  "smart-toggle-filter-tooltip": "筛选",
@@ -80,5 +80,4 @@ const locale = { "sheets-filter-ui": {
80
80
  }
81
81
  } };
82
82
 
83
- //#endregion
84
83
  module.exports = locale;
@@ -1,4 +1,4 @@
1
- //#region src/locale/zh-HK.ts
1
+ // src/locale/zh-HK.ts
2
2
  const locale = { "sheets-filter-ui": {
3
3
  toolbar: {
4
4
  "smart-toggle-filter-tooltip": "篩選",
@@ -80,5 +80,4 @@ const locale = { "sheets-filter-ui": {
80
80
  }
81
81
  } };
82
82
 
83
- //#endregion
84
83
  module.exports = locale;
@@ -1,4 +1,4 @@
1
- //#region src/locale/zh-TW.ts
1
+ // src/locale/zh-TW.ts
2
2
  const locale = { "sheets-filter-ui": {
3
3
  toolbar: {
4
4
  "smart-toggle-filter-tooltip": "篩選",
@@ -80,5 +80,4 @@ const locale = { "sheets-filter-ui": {
80
80
  }
81
81
  } };
82
82
 
83
- //#endregion
84
83
  module.exports = locale;
@@ -0,0 +1,39 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_config = require("./config-BF97qkoE.js");
3
+ let _univerjs_core = require("@univerjs/core");
4
+ let _univerjs_rpc = require("@univerjs/rpc");
5
+
6
+ // src/worker/plugin.ts
7
+ let UniverSheetsFilterUIWorkerPlugin = class UniverSheetsFilterUIWorkerPlugin extends _univerjs_core.Plugin {
8
+ constructor(_config = require_config.defaultPluginConfig, _injector, _configService, _rpcChannelService) {
9
+ super();
10
+ this._config = _config;
11
+ this._injector = _injector;
12
+ this._configService = _configService;
13
+ this._rpcChannelService = _rpcChannelService;
14
+ const { ...rest } = (0, _univerjs_core.merge)({}, require_config.defaultPluginConfig, this._config);
15
+ this._configService.setConfig(require_config.SHEETS_FILTER_UI_PLUGIN_CONFIG_KEY, rest);
16
+ }
17
+ onStarting() {
18
+ [[require_config.ISheetsGenerateFilterValuesService, { useClass: require_config.SheetsGenerateFilterValuesService }]].forEach((d) => this._injector.add(d));
19
+ }
20
+ onReady() {
21
+ this._rpcChannelService.registerChannel(require_config.SHEETS_GENERATE_FILTER_VALUES_SERVICE_NAME, (0, _univerjs_rpc.fromModule)(this._injector.get(require_config.ISheetsGenerateFilterValuesService)));
22
+ }
23
+ };
24
+ require_config._defineProperty(UniverSheetsFilterUIWorkerPlugin, "type", _univerjs_core.UniverInstanceType.UNIVER_SHEET);
25
+ require_config._defineProperty(UniverSheetsFilterUIWorkerPlugin, "pluginName", "SHEET_FILTER_UI_WORKER_PLUGIN");
26
+ require_config._defineProperty(UniverSheetsFilterUIWorkerPlugin, "packageName", require_config.name);
27
+ require_config._defineProperty(UniverSheetsFilterUIWorkerPlugin, "version", require_config.version);
28
+ UniverSheetsFilterUIWorkerPlugin = require_config.__decorate([
29
+ require_config.__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
30
+ require_config.__decorateParam(2, _univerjs_core.IConfigService),
31
+ require_config.__decorateParam(3, _univerjs_rpc.IRPCChannelService)
32
+ ], UniverSheetsFilterUIWorkerPlugin);
33
+
34
+ Object.defineProperty(exports, "UniverSheetsFilterUIWorkerPlugin", {
35
+ enumerable: true,
36
+ get: function () {
37
+ return UniverSheetsFilterUIWorkerPlugin;
38
+ }
39
+ });
@@ -0,0 +1,244 @@
1
+ import { Disposable, ILogService, IUniverInstanceService, Inject, LocaleService, createIdentifier, extractPureTextFromCell, isNumeric, numfmt } from "@univerjs/core";
2
+ import { FilterBy } from "@univerjs/sheets-filter";
3
+
4
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/decorateParam.js
5
+ function __decorateParam(paramIndex, decorator) {
6
+ return function(target, key) {
7
+ decorator(target, key, paramIndex);
8
+ };
9
+ }
10
+
11
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/decorate.js
12
+ function __decorate(decorators, target, key, desc) {
13
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
14
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
15
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
16
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
17
+ }
18
+
19
+ // src/worker/generate-filter-values.service.ts
20
+ const SHEETS_GENERATE_FILTER_VALUES_SERVICE_NAME = "sheets-filter.generate-filter-values.service";
21
+ const ISheetsGenerateFilterValuesService = createIdentifier(SHEETS_GENERATE_FILTER_VALUES_SERVICE_NAME);
22
+ let SheetsGenerateFilterValuesService = class SheetsGenerateFilterValuesService extends Disposable {
23
+ constructor(_localeService, _univerInstanceService, _logService) {
24
+ super();
25
+ this._localeService = _localeService;
26
+ this._univerInstanceService = _univerInstanceService;
27
+ this._logService = _logService;
28
+ }
29
+ async getFilterValues(params) {
30
+ var _this$_univerInstance;
31
+ const { unitId, subUnitId, filteredOutRowsByOtherColumns, filterColumn, filters, blankChecked, iterateRange, alreadyChecked } = params;
32
+ const workbook = this._univerInstanceService.getUnit(unitId);
33
+ const worksheet = (_this$_univerInstance = this._univerInstanceService.getUnit(unitId)) === null || _this$_univerInstance === void 0 ? void 0 : _this$_univerInstance.getSheetBySheetId(subUnitId);
34
+ if (!workbook || !worksheet) return [];
35
+ this._logService.debug("[SheetsGenerateFilterValuesService]", "getFilterValues for", {
36
+ unitId,
37
+ subUnitId
38
+ });
39
+ return getFilterTreeByValueItems(filters, this._localeService, iterateRange, worksheet, new Set(filteredOutRowsByOtherColumns), filterColumn, new Set(alreadyChecked.map(String)), blankChecked, workbook.getStyles());
40
+ }
41
+ };
42
+ SheetsGenerateFilterValuesService = __decorate([
43
+ __decorateParam(0, Inject(LocaleService)),
44
+ __decorateParam(1, IUniverInstanceService),
45
+ __decorateParam(2, ILogService)
46
+ ], SheetsGenerateFilterValuesService);
47
+ function getFilterTreeByValueItems(filters, localeService, iterateRange, worksheet, filteredOutRowsByOtherColumns, filterColumn, alreadyChecked, blankChecked, styles) {
48
+ var _filterColumn$filtere;
49
+ const items = /* @__PURE__ */ new Map();
50
+ const treeMap = /* @__PURE__ */ new Map();
51
+ const DefaultPattern = "yyyy-mm-dd";
52
+ const EmptyKey = "empty";
53
+ const isNeedClearCheckedStatus = !filters && ((filterColumn === null || filterColumn === void 0 ? void 0 : filterColumn.filterBy) === FilterBy.COLORS || (filterColumn === null || filterColumn === void 0 ? void 0 : filterColumn.filterBy) === FilterBy.CONDITIONS) && ((_filterColumn$filtere = filterColumn.filteredOutRows) === null || _filterColumn$filtere === void 0 ? void 0 : _filterColumn$filtere.size);
54
+ let emptyCount = 0;
55
+ for (const cell of worksheet.iterateByColumn(iterateRange, false, false)) {
56
+ const { row, rowSpan = 1 } = cell;
57
+ let rowIndex = 0;
58
+ while (rowIndex < rowSpan) {
59
+ var _cell$value, _styles$get, _cell$value2;
60
+ const targetRow = row + rowIndex;
61
+ if (filteredOutRowsByOtherColumns.has(targetRow)) {
62
+ rowIndex++;
63
+ continue;
64
+ }
65
+ const value = (cell === null || cell === void 0 ? void 0 : cell.value) ? extractPureTextFromCell(cell.value) : "";
66
+ if (!value) {
67
+ emptyCount += 1;
68
+ rowIndex += rowSpan;
69
+ continue;
70
+ }
71
+ const fmtStr = ((_cell$value = cell.value) === null || _cell$value === void 0 ? void 0 : _cell$value.v) && !cell.value.p ? (_styles$get = styles.get((_cell$value2 = cell.value) === null || _cell$value2 === void 0 ? void 0 : _cell$value2.s)) === null || _styles$get === void 0 || (_styles$get = _styles$get.n) === null || _styles$get === void 0 ? void 0 : _styles$get.pattern : "";
72
+ const isDateValue = fmtStr && numfmt.getFormatInfo(fmtStr).isDate;
73
+ let isIncludeDatePart = false;
74
+ if (isDateValue) {
75
+ const { year, month, day } = numfmt.getFormatDateInfo(fmtStr);
76
+ isIncludeDatePart = year || month || day;
77
+ }
78
+ if (fmtStr && isDateValue && isIncludeDatePart) {
79
+ var _worksheet$getCellRaw, _yearItem$children, _monthItem$children;
80
+ const originValue = (_worksheet$getCellRaw = worksheet.getCellRaw(cell.row, cell.col)) === null || _worksheet$getCellRaw === void 0 ? void 0 : _worksheet$getCellRaw.v;
81
+ if (!originValue) {
82
+ rowIndex++;
83
+ continue;
84
+ }
85
+ const [year, month, day] = numfmt.format(DefaultPattern, Number(originValue)).split("-").map(Number);
86
+ let yearItem = items.get(`${year}`);
87
+ if (!yearItem) {
88
+ yearItem = {
89
+ title: `${year}`,
90
+ key: `${year}`,
91
+ children: [],
92
+ count: 0,
93
+ leaf: false,
94
+ checked: false
95
+ };
96
+ items.set(`${year}`, yearItem);
97
+ treeMap.set(`${year}`, [`${year}`]);
98
+ }
99
+ let monthItem = (_yearItem$children = yearItem.children) === null || _yearItem$children === void 0 ? void 0 : _yearItem$children.find((item) => item.key === `${year}-${month}`);
100
+ if (!monthItem) {
101
+ var _yearItem$children2;
102
+ monthItem = {
103
+ title: localeService.t(`sheets-filter-ui.date.${month}`),
104
+ key: `${year}-${month}`,
105
+ children: [],
106
+ count: 0,
107
+ leaf: false,
108
+ checked: false
109
+ };
110
+ (_yearItem$children2 = yearItem.children) === null || _yearItem$children2 === void 0 || _yearItem$children2.push(monthItem);
111
+ treeMap.set(`${year}-${month}`, [`${year}`, `${year}-${month}`]);
112
+ }
113
+ const dayItem = monthItem === null || monthItem === void 0 || (_monthItem$children = monthItem.children) === null || _monthItem$children === void 0 ? void 0 : _monthItem$children.find((item) => item.key === `${year}-${month}-${day}`);
114
+ if (!dayItem) {
115
+ var _monthItem$children2;
116
+ (_monthItem$children2 = monthItem.children) === null || _monthItem$children2 === void 0 || _monthItem$children2.push({
117
+ title: `${day}`,
118
+ key: `${year}-${month}-${day}`,
119
+ count: 1,
120
+ originValues: /* @__PURE__ */ new Set([value]),
121
+ leaf: true,
122
+ checked: isNeedClearCheckedStatus ? false : alreadyChecked.size ? alreadyChecked.has(value) : !blankChecked
123
+ });
124
+ monthItem.count++;
125
+ yearItem.count++;
126
+ treeMap.set(`${year}-${month}-${day}`, [
127
+ `${year}`,
128
+ `${year}-${month}`,
129
+ `${year}-${month}-${day}`
130
+ ]);
131
+ } else {
132
+ dayItem.originValues.add(value);
133
+ dayItem.count++;
134
+ monthItem.count++;
135
+ yearItem.count++;
136
+ }
137
+ } else {
138
+ const key = value;
139
+ let item = items.get(key);
140
+ if (!item) {
141
+ item = {
142
+ title: value,
143
+ leaf: true,
144
+ checked: isNeedClearCheckedStatus ? false : alreadyChecked.size ? alreadyChecked.has(value) : !blankChecked,
145
+ key,
146
+ count: 1
147
+ };
148
+ items.set(key, item);
149
+ treeMap.set(key, [key]);
150
+ } else item.count++;
151
+ }
152
+ rowIndex++;
153
+ }
154
+ }
155
+ const initialBlankChecked = isNeedClearCheckedStatus ? false : filters ? blankChecked : true;
156
+ if (emptyCount > 0) {
157
+ const item = {
158
+ title: localeService.t("sheets-filter-ui.panel.empty"),
159
+ count: emptyCount,
160
+ leaf: true,
161
+ checked: initialBlankChecked,
162
+ key: EmptyKey
163
+ };
164
+ items.set("empty", item);
165
+ treeMap.set("empty", [EmptyKey]);
166
+ }
167
+ return {
168
+ filterTreeItems: generateFilterTreeBySort(Array.from(items.values())),
169
+ filterTreeMapCache: treeMap
170
+ };
171
+ }
172
+ function generateFilterTreeBySort(tree) {
173
+ return Array.from(tree).sort((a, b) => {
174
+ if (a.children && !b.children) return -1;
175
+ if (!a.children && b.children) return 1;
176
+ return compare(a.title, b.title);
177
+ }).map((yearItem) => {
178
+ if (yearItem.children) yearItem.children.sort((a, b) => {
179
+ return Number.parseInt(a.key.split("-")[1], 10) - Number.parseInt(b.key.split("-")[1], 10);
180
+ }).forEach((monthItem) => {
181
+ if (monthItem.children) monthItem.children.sort((a, b) => {
182
+ return Number.parseInt(a.key.split("-")[2], 10) - Number.parseInt(b.key.split("-")[2], 10);
183
+ });
184
+ });
185
+ return yearItem;
186
+ });
187
+ }
188
+ function compare(strA, strB) {
189
+ const aIsNumeric = isNumeric(strA);
190
+ const bIsNumeric = isNumeric(strB);
191
+ if (aIsNumeric && bIsNumeric) return Number.parseFloat(strA) - Number.parseFloat(strB);
192
+ else if (aIsNumeric && !bIsNumeric) return -1;
193
+ else if (!aIsNumeric && bIsNumeric) return 1;
194
+ else return strA.localeCompare(strB);
195
+ }
196
+
197
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/typeof.js
198
+ function _typeof(o) {
199
+ "@babel/helpers - typeof";
200
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
201
+ return typeof o;
202
+ } : function(o) {
203
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
204
+ }, _typeof(o);
205
+ }
206
+
207
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/toPrimitive.js
208
+ function toPrimitive(t, e) {
209
+ if ("object" != _typeof(t) || !t) return t;
210
+ var r;
211
+ if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
212
+ var i = r.call(t, e || "default");
213
+ if ("object" != _typeof(i)) return i;
214
+ throw new TypeError("@@toPrimitive must return a primitive value.");
215
+ }
216
+ return ("string" === e ? String : Number)(t);
217
+ }
218
+
219
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/toPropertyKey.js
220
+ function toPropertyKey(t) {
221
+ var i = toPrimitive(t, "string");
222
+ return "symbol" == _typeof(i) ? i : i + "";
223
+ }
224
+
225
+ // \0@oxc-project+runtime@0.157.0/helpers/esm/defineProperty.js
226
+ function _defineProperty(e, r, t) {
227
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
228
+ value: t,
229
+ enumerable: !0,
230
+ configurable: !0,
231
+ writable: !0
232
+ }) : e[r] = t, e;
233
+ }
234
+
235
+ // package.json
236
+ var name = "@univerjs/sheets-filter-ui";
237
+ var version = "1.5.0";
238
+
239
+ // src/config/config.ts
240
+ const SHEETS_FILTER_UI_PLUGIN_CONFIG_KEY = "sheets-filter-ui.config";
241
+ const configSymbol = Symbol(SHEETS_FILTER_UI_PLUGIN_CONFIG_KEY);
242
+ const defaultPluginConfig = {};
243
+
244
+ export { _defineProperty as a, SheetsGenerateFilterValuesService as c, __decorateParam as d, version as i, getFilterTreeByValueItems as l, defaultPluginConfig as n, ISheetsGenerateFilterValuesService as o, name as r, SHEETS_GENERATE_FILTER_VALUES_SERVICE_NAME as s, SHEETS_FILTER_UI_PLUGIN_CONFIG_KEY as t, __decorate as u };