@visactor/vtable-plugins 1.22.6-alpha.2 → 1.22.6

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 (77) hide show
  1. package/cjs/auto-fill/__tests__/formula-integration.test.d.ts +23 -0
  2. package/cjs/auto-fill/__tests__/formula-integration.test.js +61 -0
  3. package/cjs/auto-fill/__tests__/formula-integration.test.js.map +1 -0
  4. package/cjs/auto-fill/auto-fill-manager.d.ts +1 -0
  5. package/cjs/auto-fill/auto-fill-manager.js +27 -10
  6. package/cjs/auto-fill/auto-fill-manager.js.map +1 -1
  7. package/cjs/auto-fill/auto-fill-services.js +1 -1
  8. package/cjs/auto-fill/auto-fill-services.js.map +1 -1
  9. package/cjs/auto-fill/formula-integration.d.ts +40 -0
  10. package/cjs/auto-fill/formula-integration.js +77 -0
  11. package/cjs/auto-fill/formula-integration.js.map +1 -0
  12. package/cjs/auto-fill/index.d.ts +6 -0
  13. package/cjs/auto-fill/index.js +19 -1
  14. package/cjs/auto-fill/index.js.map +1 -1
  15. package/cjs/auto-fill/rules.d.ts +1 -0
  16. package/cjs/auto-fill/rules.js +128 -3
  17. package/cjs/auto-fill/rules.js.map +1 -1
  18. package/cjs/contextmenu/index.js +1 -2
  19. package/cjs/contextmenu/menu-manager.js +2 -1
  20. package/cjs/excel-edit-cell-keyboard.d.ts +1 -0
  21. package/cjs/excel-edit-cell-keyboard.js +5 -4
  22. package/cjs/excel-edit-cell-keyboard.js.map +1 -1
  23. package/cjs/filter/filter-state-manager.js +1 -1
  24. package/cjs/filter/filter-state-manager.js.map +1 -1
  25. package/cjs/filter/filter-toolbar.d.ts +1 -0
  26. package/cjs/filter/filter-toolbar.js +10 -2
  27. package/cjs/filter/filter-toolbar.js.map +1 -1
  28. package/cjs/filter/filter.js +2 -1
  29. package/cjs/filter/filter.js.map +1 -1
  30. package/cjs/filter/types.d.ts +1 -1
  31. package/cjs/filter/types.js.map +1 -1
  32. package/cjs/filter/value-filter.d.ts +14 -9
  33. package/cjs/filter/value-filter.js +102 -182
  34. package/cjs/filter/value-filter.js.map +1 -1
  35. package/cjs/master-detail-plugin/config.js +1 -2
  36. package/cjs/master-detail-plugin/core.js +2 -1
  37. package/cjs/table-export/index.js +1 -1
  38. package/dist/vtable-plugins.js +698 -403
  39. package/dist/vtable-plugins.min.js +3 -3
  40. package/es/auto-fill/__tests__/formula-integration.test.d.ts +23 -0
  41. package/es/auto-fill/__tests__/formula-integration.test.js +54 -0
  42. package/es/auto-fill/__tests__/formula-integration.test.js.map +1 -0
  43. package/es/auto-fill/auto-fill-manager.d.ts +1 -0
  44. package/es/auto-fill/auto-fill-manager.js +34 -15
  45. package/es/auto-fill/auto-fill-manager.js.map +1 -1
  46. package/es/auto-fill/auto-fill-services.js +2 -2
  47. package/es/auto-fill/auto-fill-services.js.map +1 -1
  48. package/es/auto-fill/formula-integration.d.ts +40 -0
  49. package/es/auto-fill/formula-integration.js +67 -0
  50. package/es/auto-fill/formula-integration.js.map +1 -0
  51. package/es/auto-fill/index.d.ts +6 -0
  52. package/es/auto-fill/index.js +7 -1
  53. package/es/auto-fill/index.js.map +1 -1
  54. package/es/auto-fill/rules.d.ts +1 -0
  55. package/es/auto-fill/rules.js +127 -0
  56. package/es/auto-fill/rules.js.map +1 -1
  57. package/es/contextmenu/index.js +1 -2
  58. package/es/contextmenu/menu-manager.js +2 -1
  59. package/es/excel-edit-cell-keyboard.d.ts +1 -0
  60. package/es/excel-edit-cell-keyboard.js +5 -4
  61. package/es/excel-edit-cell-keyboard.js.map +1 -1
  62. package/es/filter/filter-state-manager.js +1 -1
  63. package/es/filter/filter-state-manager.js.map +1 -1
  64. package/es/filter/filter-toolbar.d.ts +1 -0
  65. package/es/filter/filter-toolbar.js +10 -2
  66. package/es/filter/filter-toolbar.js.map +1 -1
  67. package/es/filter/filter.js +2 -1
  68. package/es/filter/filter.js.map +1 -1
  69. package/es/filter/types.d.ts +1 -1
  70. package/es/filter/types.js.map +1 -1
  71. package/es/filter/value-filter.d.ts +14 -9
  72. package/es/filter/value-filter.js +101 -182
  73. package/es/filter/value-filter.js.map +1 -1
  74. package/es/master-detail-plugin/config.js +1 -2
  75. package/es/master-detail-plugin/core.js +2 -1
  76. package/es/table-export/index.js +1 -1
  77. package/package.json +8 -8
@@ -215,4 +215,131 @@ export const loopSeriesRule = {
215
215
  export function reverseIfNeed(data, reverse) {
216
216
  return reverse ? data.reverse() : data;
217
217
  }
218
+
219
+ export const formulaRule = {
220
+ type: DATA_TYPE.FORMULA,
221
+ priority: 1200,
222
+ match: (cellData, accessor) => "string" == typeof (null == cellData ? void 0 : cellData.v) && cellData.v.startsWith("="),
223
+ isContinue: (prev, cur) => {
224
+ var _a;
225
+ return !(prev.type !== DATA_TYPE.FORMULA || !(null === (_a = null == cur ? void 0 : cur.v) || void 0 === _a ? void 0 : _a.startsWith("=")));
226
+ },
227
+ applyFunctions: {
228
+ [APPLY_TYPE.COPY]: (dataWithIndex, len, direction, copyDataPiece, location) => {
229
+ const {data: data} = dataWithIndex;
230
+ return fillCopy(data, len);
231
+ },
232
+ [APPLY_TYPE.SERIES]: (dataWithIndex, len, direction, copyDataPiece, location) => {
233
+ const {data: data} = dataWithIndex;
234
+ if (1 === data.length) return adjustFormulaReferences(data, len, direction, location);
235
+ const adjustedFormulas = adjustFormulaReferencesInSeries(data, len, direction, location);
236
+ return adjustedFormulas || fillCopy(data, len);
237
+ }
238
+ }
239
+ };
240
+
241
+ function adjustFormulaReferences(formulas, len, direction, location) {
242
+ var _a, _b;
243
+ const result = [], baseFormula = (null === (_a = formulas[0]) || void 0 === _a ? void 0 : _a.v) || "";
244
+ for (let i = 0; i < len; i++) {
245
+ let newFormula = baseFormula, rowOffset = 0, colOffset = 0;
246
+ switch (direction) {
247
+ case Direction.DOWN:
248
+ rowOffset = i + 1;
249
+ break;
250
+
251
+ case Direction.UP:
252
+ rowOffset = -(i + 1);
253
+ break;
254
+
255
+ case Direction.RIGHT:
256
+ colOffset = i + 1;
257
+ break;
258
+
259
+ case Direction.LEFT:
260
+ colOffset = -(i + 1);
261
+ }
262
+ newFormula = adjustCellReferencesInFormula(baseFormula, rowOffset, colOffset), result.push({
263
+ v: newFormula,
264
+ t: null === (_b = formulas[0]) || void 0 === _b ? void 0 : _b.t
265
+ });
266
+ }
267
+ return result;
268
+ }
269
+
270
+ function adjustFormulaReferencesInSeries(formulas, len, direction, location) {
271
+ var _a, _b, _c;
272
+ if (formulas.length < 2) return null;
273
+ const baseFormula1 = (null === (_a = formulas[0]) || void 0 === _a ? void 0 : _a.v) || "", pattern = detectFormulaPattern(baseFormula1, (null === (_b = formulas[1]) || void 0 === _b ? void 0 : _b.v) || "");
274
+ if (!pattern) return null;
275
+ const result = [];
276
+ for (let i = 0; i < len; i++) {
277
+ let newFormula = baseFormula1;
278
+ newFormula = applyFormulaPattern(newFormula, pattern, i + 1, direction), result.push({
279
+ v: newFormula,
280
+ t: null === (_c = formulas[0]) || void 0 === _c ? void 0 : _c.t
281
+ });
282
+ }
283
+ return result;
284
+ }
285
+
286
+ function detectFormulaPattern(formula1, formula2) {
287
+ const cellRefRegex = /\$?([A-Z]+)\$?(\d+)/g, matches1 = [ ...formula1.matchAll(cellRefRegex) ], matches2 = [ ...formula2.matchAll(cellRefRegex) ];
288
+ if (matches1.length !== matches2.length || 0 === matches1.length) return null;
289
+ let totalRowOffset = 0, totalColOffset = 0, validMatches = 0;
290
+ for (let i = 0; i < matches1.length; i++) {
291
+ const col1 = matches1[i][1], row1 = parseInt(matches1[i][2], 10), col2 = matches2[i][1], row2 = parseInt(matches2[i][2], 10), colOffset = columnToNumber(col2) - columnToNumber(col1), rowOffset = row2 - row1;
292
+ Math.abs(colOffset) < 100 && Math.abs(rowOffset) < 1e4 && (totalColOffset += colOffset,
293
+ totalRowOffset += rowOffset, validMatches++);
294
+ }
295
+ return 0 === validMatches ? null : {
296
+ rowOffset: totalRowOffset / validMatches,
297
+ colOffset: totalColOffset / validMatches
298
+ };
299
+ }
300
+
301
+ function applyFormulaPattern(formula, pattern, multiplier, direction) {
302
+ return formula.replace(/\$?([A-Z]+)\$?(\d+)/g, ((match, colStr, rowStr) => {
303
+ const isColAbsolute = match.startsWith("$") && match.indexOf(colStr) > 0, isRowAbsolute = match.includes("$" + rowStr);
304
+ let newCol = colStr, newRow = rowStr;
305
+ if (!isColAbsolute && 0 !== pattern.colOffset) {
306
+ newCol = numberToColumn(columnToNumber(colStr) + pattern.colOffset * multiplier);
307
+ }
308
+ if (!isRowAbsolute && 0 !== pattern.rowOffset) {
309
+ newRow = (parseInt(rowStr, 10) + pattern.rowOffset * multiplier).toString();
310
+ }
311
+ let result = "";
312
+ return isColAbsolute && (result += "$"), result += newCol, isRowAbsolute && (result += "$"),
313
+ result += newRow, result;
314
+ }));
315
+ }
316
+
317
+ function adjustCellReferencesInFormula(formula, rowOffset, colOffset) {
318
+ return formula.replace(/\$?([A-Z]+)\$?(\d+)/g, ((match, colStr, rowStr) => {
319
+ const isColAbsolute = match.startsWith("$") && match.indexOf(colStr) > 0, isRowAbsolute = match.includes("$" + rowStr);
320
+ let newCol = colStr, newRow = rowStr;
321
+ if (!isColAbsolute && 0 !== colOffset) {
322
+ newCol = numberToColumn(columnToNumber(colStr) + colOffset);
323
+ }
324
+ if (!isRowAbsolute && 0 !== rowOffset) {
325
+ newRow = (parseInt(rowStr, 10) + rowOffset).toString();
326
+ }
327
+ let result = "";
328
+ return isColAbsolute && (result += "$"), result += newCol, isRowAbsolute && (result += "$"),
329
+ result += newRow, result;
330
+ }));
331
+ }
332
+
333
+ function columnToNumber(col) {
334
+ let result = 0;
335
+ for (let i = 0; i < col.length; i++) result = 26 * result + (col.charCodeAt(i) - "A".charCodeAt(0) + 1);
336
+ return result;
337
+ }
338
+
339
+ function numberToColumn(num) {
340
+ let result = "";
341
+ for (;num > 0; ) num--, result = String.fromCharCode("A".charCodeAt(0) + num % 26) + result,
342
+ num = Math.floor(num / 26);
343
+ return result;
344
+ }
218
345
  //# sourceMappingURL=rules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ACX,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;yBACpB;6BAAM;4BACL,UAAU,EAAE,CAAC;4BACb,UAAU,CAAC,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;yBAC7C;qBACF;yBAAM;wBACL,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,UAAU,GAAG,CAAC,CAAC,CAAC;qBAClE;iBACF;aACF;YAED,IAAI,SAAS,EAAE;gBACb,IAAI,CAAC,OAAO,EAAE,CAAC;gBACf,UAAU,CAAC,OAAO,EAAE,CAAC;aACtB;YAED,IAAI,WAAW,CAAC,UAAU,CAAC,EAAE;gBAC3B,MAAM,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;gBAC3C,OAAO,aAAa,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC;aAC1E;YACD,OAAO,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QAC7B,CAAC;KACF;CACF,CAAC;AAEF,MAAM,UAAU,aAAa,CAAI,IAAS,EAAE,OAAgB;IAC1D,OAAO,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;AACzC,CAAC","file":"rules.js","sourcesContent":["/**\n * Copyright 2023-present DreamNum Co., Ltd.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { IAutoFillRule } from './types';\n\nimport {\n chineseToNumber,\n fillChnNumber,\n fillChnWeek,\n fillCopy,\n fillExtendNumber,\n fillLoopSeries,\n fillSeries,\n getLoopSeriesInfo,\n isChnNumber,\n isChnWeek2,\n isChnWeek3,\n isEqualDiff,\n isLoopSeries,\n matchExtendNumber\n} from './utils/fill';\nimport { APPLY_TYPE, DATA_TYPE, Direction } from './types';\nimport { converterManager, DateConverter } from './series-converters';\nimport { CellValueType } from './types';\nexport const dateRule: IAutoFillRule = {\n type: DATA_TYPE.DATE,\n priority: 1100,\n match: (cellData: any, accessor: any) => {\n return typeof cellData?.v === 'string' && converterManager.getConverter(cellData.v) instanceof DateConverter;\n },\n isContinue: (prev: any, cur: any) => {\n if (prev.type === DATA_TYPE.DATE) {\n return true;\n }\n return false;\n },\n applyFunctions: {\n [APPLY_TYPE.SERIES]: (dataWithIndex: any, len: any, direction: any) => {\n const { data } = dataWithIndex;\n const converter = converterManager.getConverter(data[0]?.v);\n if (direction === Direction.LEFT || direction === Direction.UP) {\n data.reverse();\n return fillSeries(data, len, direction, converter).reverse();\n }\n return fillSeries(data, len, direction, converter);\n }\n }\n};\n\nexport const numberRule: IAutoFillRule = {\n type: DATA_TYPE.NUMBER,\n priority: 1000,\n match: (cellData: any) => typeof cellData?.v === 'number' || cellData?.t === CellValueType.NUMBER,\n isContinue: (prev: any, cur: any) => {\n if (prev.type === DATA_TYPE.NUMBER) {\n return true;\n }\n return false;\n },\n applyFunctions: {\n [APPLY_TYPE.SERIES]: (dataWithIndex: any, len: any, direction: any) => {\n const { data } = dataWithIndex;\n if (direction === Direction.LEFT || direction === Direction.UP) {\n data.reverse();\n return fillSeries(data, len, direction).reverse();\n }\n return fillSeries(data, len, direction);\n }\n }\n};\n\nexport const otherRule: IAutoFillRule = {\n type: DATA_TYPE.OTHER,\n priority: 0,\n match: () => true,\n isContinue: (prev: any, cur: any) => {\n if (prev.type === DATA_TYPE.OTHER) {\n return true;\n }\n return false;\n }\n};\n\nexport const extendNumberRule: IAutoFillRule = {\n type: DATA_TYPE.EXTEND_NUMBER,\n priority: 900,\n match: cellData => matchExtendNumber(`${(cellData as any)?.v ?? ''}` || '').isExtendNumber,\n isContinue: (prev: any, cur: any) => {\n if (prev.type === DATA_TYPE.EXTEND_NUMBER) {\n const { beforeTxt, afterTxt } = matchExtendNumber(`${(prev.cellData as any)?.v ?? ''}` || '');\n const { beforeTxt: curBeforeTxt, afterTxt: curAfterTxt } = matchExtendNumber(`${(cur as any)?.v ?? ''}` || '');\n if (beforeTxt === curBeforeTxt && afterTxt === curAfterTxt) {\n return true;\n }\n }\n return false;\n },\n applyFunctions: {\n [APPLY_TYPE.SERIES]: (dataWithIndex: any, len: any, direction: any) => {\n const { data } = dataWithIndex;\n const isReverse = direction === Direction.UP || direction === Direction.LEFT;\n\n let step;\n if (data.length === 1) {\n step = isReverse ? -1 : 1;\n return reverseIfNeed(fillExtendNumber(data, len, step), isReverse);\n }\n const dataNumArr = [];\n\n for (let i = 0; i < data.length; i++) {\n const txt = `${data[i]?.v}`;\n txt && dataNumArr.push(Number(matchExtendNumber(txt).matchTxt));\n }\n\n if (isReverse) {\n data.reverse();\n dataNumArr.reverse();\n }\n\n if (isEqualDiff(dataNumArr)) {\n step = dataNumArr[1] - dataNumArr[0];\n return reverseIfNeed(fillExtendNumber(data, len, step), isReverse);\n }\n return fillCopy(data, len);\n }\n }\n};\n\nexport const chnNumberRule: IAutoFillRule = {\n type: DATA_TYPE.CHN_NUMBER,\n priority: 830,\n match: cellData => {\n if (isChnNumber(`${(cellData as any)?.v ?? ''}` || '')) {\n return true;\n }\n return false;\n },\n isContinue: (prev: any, cur: any) => {\n if (prev.type === DATA_TYPE.CHN_NUMBER) {\n return true;\n }\n return false;\n },\n applyFunctions: {\n [APPLY_TYPE.SERIES]: (dataWithIndex: any, len: any, direction: any) => {\n const { data } = dataWithIndex;\n\n const isReverse = direction === Direction.LEFT || direction === Direction.UP;\n if (data.length === 1) {\n let step;\n if (!isReverse) {\n step = 1;\n } else {\n step = -1;\n }\n return reverseIfNeed(fillChnNumber(data, len, step), isReverse);\n }\n let hasWeek = false;\n for (let i = 0; i < data.length; i++) {\n const formattedValue = data[i]?.v;\n\n if (formattedValue === '日') {\n hasWeek = true;\n break;\n }\n }\n\n const dataNumArr = [];\n let weekIndex = 0;\n for (let i = 0; i < data.length; i++) {\n const formattedValue = `${data[i]?.v}`;\n if (formattedValue === '日') {\n if (i === 0) {\n dataNumArr.push(0);\n } else {\n weekIndex++;\n dataNumArr.push(weekIndex * 7);\n }\n } else if (hasWeek && chineseToNumber(formattedValue) > 0 && chineseToNumber(formattedValue) < 7) {\n dataNumArr.push(chineseToNumber(formattedValue) + weekIndex * 7);\n } else {\n dataNumArr.push(chineseToNumber(formattedValue));\n }\n }\n\n if (isReverse) {\n data.reverse();\n dataNumArr.reverse();\n }\n\n if (isEqualDiff(dataNumArr)) {\n // Always fill with sequence of Chinese lowercase numbers\n const step = dataNumArr[1] - dataNumArr[0];\n return reverseIfNeed(fillChnNumber(data, len, step), isReverse);\n }\n // Not an arithmetic progression, copy data\n return fillCopy(data, len);\n }\n }\n};\n\nexport const chnWeek2Rule: IAutoFillRule = {\n type: DATA_TYPE.CHN_WEEK2,\n priority: 820,\n match: cellData => {\n if (isChnWeek2(`${(cellData as any)?.v ?? ''}` || '')) {\n return true;\n }\n return false;\n },\n isContinue: (prev: any, cur: any) => prev.type === DATA_TYPE.CHN_WEEK2,\n applyFunctions: {\n [APPLY_TYPE.SERIES]: (dataWithIndex: any, len: any, direction: any) => {\n const { data } = dataWithIndex;\n\n const isReverse = direction === Direction.LEFT || direction === Direction.UP;\n if (data.length === 1) {\n let step;\n if (!isReverse) {\n step = 1;\n } else {\n step = -1;\n }\n\n return reverseIfNeed(fillChnWeek(data, len, step, 1), isReverse);\n }\n const dataNumArr = [];\n let weekIndex = 0;\n\n for (let i = 0; i < data.length; i++) {\n const formattedValue = `${data[i]?.v}`;\n const lastTxt = formattedValue?.substr(formattedValue.length - 1, 1);\n if (formattedValue === '周日') {\n if (i === 0) {\n dataNumArr.push(0);\n } else {\n weekIndex++;\n dataNumArr.push(weekIndex * 7);\n }\n } else {\n dataNumArr.push(chineseToNumber(lastTxt) + weekIndex * 7);\n }\n }\n\n if (isReverse) {\n data.reverse();\n dataNumArr.reverse();\n }\n\n if (isEqualDiff(dataNumArr)) {\n const step = dataNumArr[1] - dataNumArr[0];\n return reverseIfNeed(fillChnWeek(data, len, step, 1), isReverse);\n }\n return fillCopy(data, len);\n }\n }\n};\n\nexport const chnWeek3Rule: IAutoFillRule = {\n type: DATA_TYPE.CHN_WEEK3,\n priority: 810,\n match: cellData => isChnWeek3(`${(cellData as any)?.v ?? ''}` || ''),\n isContinue: (prev: any, cur: any) => prev.type === DATA_TYPE.CHN_WEEK3,\n applyFunctions: {\n [APPLY_TYPE.SERIES]: (dataWithIndex: any, len: any, direction: any) => {\n const { data } = dataWithIndex;\n\n const isReverse = direction === Direction.LEFT || direction === Direction.UP;\n if (data.length === 1) {\n let step;\n if (!isReverse) {\n step = 1;\n } else {\n step = -1;\n }\n\n return reverseIfNeed(fillChnWeek(data, len, step, 2), isReverse);\n }\n const dataNumArr = [];\n let weekIndex = 0;\n\n for (let i = 0; i < data.length; i++) {\n const formattedValue = `${data[i]?.v}`;\n if (formattedValue) {\n const lastTxt = formattedValue.substr(formattedValue.length - 1, 1);\n if (formattedValue === '星期日') {\n if (i === 0) {\n dataNumArr.push(0);\n } else {\n weekIndex++;\n dataNumArr.push(weekIndex * 7);\n }\n } else {\n dataNumArr.push(chineseToNumber(lastTxt) + weekIndex * 7);\n }\n }\n }\n\n if (isReverse) {\n data.reverse();\n dataNumArr.reverse();\n }\n\n if (isEqualDiff(dataNumArr)) {\n const step = dataNumArr[1] - dataNumArr[0];\n return reverseIfNeed(fillChnWeek(data, len, step, 2), isReverse);\n }\n return fillCopy(data, len);\n }\n }\n};\n\nexport const loopSeriesRule: IAutoFillRule = {\n type: DATA_TYPE.LOOP_SERIES,\n priority: 800,\n match: cellData => isLoopSeries(`${(cellData as any)?.v ?? ''}` || ''),\n isContinue: (prev: any, cur: any) => {\n if (prev.type === DATA_TYPE.LOOP_SERIES) {\n return (\n getLoopSeriesInfo(`${(prev.cellData as any)?.v ?? ''}` || '').name ===\n getLoopSeriesInfo(`${(cur as any)?.v ?? ''}` || '').name\n );\n }\n return false;\n },\n applyFunctions: {\n [APPLY_TYPE.SERIES]: (dataWithIndex: any, len: any, direction: any) => {\n const { data } = dataWithIndex;\n const isReverse = direction === Direction.LEFT || direction === Direction.UP;\n const { series } = getLoopSeriesInfo(`${data[0]?.v}` || '');\n if (data.length === 1) {\n let step;\n if (!isReverse) {\n step = 1;\n } else {\n step = -1;\n }\n\n return reverseIfNeed(fillLoopSeries(data, len, step, series), isReverse);\n }\n const dataNumArr = [];\n let cycleIndex = 0;\n for (let i = 0; i < data.length; i++) {\n const formattedValue = `${data[i]?.v}`;\n if (formattedValue) {\n if (formattedValue === series[0]) {\n if (i === 0) {\n dataNumArr.push(0);\n } else {\n cycleIndex++;\n dataNumArr.push(cycleIndex * series.length);\n }\n } else {\n dataNumArr.push(series.indexOf(formattedValue) + cycleIndex * 7);\n }\n }\n }\n\n if (isReverse) {\n data.reverse();\n dataNumArr.reverse();\n }\n\n if (isEqualDiff(dataNumArr)) {\n const step = dataNumArr[1] - dataNumArr[0];\n return reverseIfNeed(fillLoopSeries(data, len, step, series), isReverse);\n }\n return fillCopy(data, len);\n }\n }\n};\n\nexport function reverseIfNeed<T>(data: T[], reverse: boolean): T[] {\n return reverse ? data.reverse() : data;\n}\n"]}
1
+ {"version":3,"sources":["../src/auto-fill/rules.ts"],"names":[],"mappings":"AAkBA,OAAO,EACL,eAAe,EACf,aAAa,EACb,WAAW,EACX,QAAQ,EACR,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,iBAAiB,EACjB,WAAW,EACX,UAAU,EACV,UAAU,EACV,WAAW,EACX,YAAY,EACZ,iBAAiB,EAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,UAAU,EAAE,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ent":["/**\n * Copyright 2023-present DreamNum Co., Ltd.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { IAutoFillRule, ICellData, Nullable } from './types';\n\nimport {\n chineseToNumber,\n fillChnNumber,\n fillChnWeek,\n fillCopy,\n fillExtendNumber,\n fillLoopSeries,\n fillSeries,\n getLoopSeriesInfo,\n isChnNumber,\n isChnWeek2,\n isChnWeek3,\n isEqualDiff,\n isLoopSeries,\n matchExtendNumber\n} from './utils/fill';\nimport { APPLY_TYPE, DATA_TYPE, Direction } from './types';\nimport { converterManager, DateConverter } from './series-converters';\nimport { CellValueType } from './types';\nexport const dateRule: IAutoFillRule = {\n type: DATA_TYPE.DATE,\n priority: 1100,\n match: (cellData: any, accessor: any) => {\n return typeof cellData?.v === 'string' && converterManager.getConverter(cellData.v) instanceof DateConverter;\n },\n isContinue: (prev: any, cur: any) => {\n if (prev.type === DATA_TYPE.DATE) {\n return true;\n }\n return false;\n },\n applyFunctions: {\n [APPLY_TYPE.SERIES]: (dataWithIndex: any, len: any, direction: any) => {\n const { data } = dataWithIndex;\n const converter = converterManager.getConverter(data[0]?.v);\n if (direction === Direction.LEFT || direction === Direction.UP) {\n data.reverse();\n return fillSeries(data, len, direction, converter).reverse();\n }\n return fillSeries(data, len, direction, converter);\n }\n }\n};\n\nexport const numberRule: IAutoFillRule = {\n type: DATA_TYPE.NUMBER,\n priority: 1000,\n match: (cellData: any) => typeof cellData?.v === 'number' || cellData?.t === CellValueType.NUMBER,\n isContinue: (prev: any, cur: any) => {\n if (prev.type === DATA_TYPE.NUMBER) {\n return true;\n }\n return false;\n },\n applyFunctions: {\n [APPLY_TYPE.SERIES]: (dataWithIndex: any, len: any, direction: any) => {\n const { data } = dataWithIndex;\n if (direction === Direction.LEFT || direction === Direction.UP) {\n data.reverse();\n return fillSeries(data, len, direction).reverse();\n }\n return fillSeries(data, len, direction);\n }\n }\n};\n\nexport const otherRule: IAutoFillRule = {\n type: DATA_TYPE.OTHER,\n priority: 0,\n match: () => true,\n isContinue: (prev: any, cur: any) => {\n if (prev.type === DATA_TYPE.OTHER) {\n return true;\n }\n return false;\n }\n};\n\nexport const extendNumberRule: IAutoFillRule = {\n type: DATA_TYPE.EXTEND_NUMBER,\n priority: 900,\n match: cellData => matchExtendNumber(`${(cellData as any)?.v ?? ''}` || '').isExtendNumber,\n isContinue: (prev: any, cur: any) => {\n if (prev.type === DATA_TYPE.EXTEND_NUMBER) {\n const { beforeTxt, afterTxt } = matchExtendNumber(`${(prev.cellData as any)?.v ?? ''}` || '');\n const { beforeTxt: curBeforeTxt, afterTxt: curAfterTxt } = matchExtendNumber(`${(cur as any)?.v ?? ''}` || '');\n if (beforeTxt === curBeforeTxt && afterTxt === curAfterTxt) {\n return true;\n }\n }\n return false;\n },\n applyFunctions: {\n [APPLY_TYPE.SERIES]: (dataWithIndex: any, len: any, direction: any) => {\n const { data } = dataWithIndex;\n const isReverse = direction === Direction.UP || direction === Direction.LEFT;\n\n let step;\n if (data.length === 1) {\n step = isReverse ? -1 : 1;\n return reverseIfNeed(fillExtendNumber(data, len, step), isReverse);\n }\n const dataNumArr = [];\n\n for (let i = 0; i < data.length; i++) {\n const txt = `${data[i]?.v}`;\n txt && dataNumArr.push(Number(matchExtendNumber(txt).matchTxt));\n }\n\n if (isReverse) {\n data.reverse();\n dataNumArr.reverse();\n }\n\n if (isEqualDiff(dataNumArr)) {\n step = dataNumArr[1] - dataNumArr[0];\n return reverseIfNeed(fillExtendNumber(data, len, step), isReverse);\n }\n return fillCopy(data, len);\n }\n }\n};\n\nexport const chnNumberRule: IAutoFillRule = {\n type: DATA_TYPE.CHN_NUMBER,\n priority: 830,\n match: cellData => {\n if (isChnNumber(`${(cellData as any)?.v ?? ''}` || '')) {\n return true;\n }\n return false;\n },\n isContinue: (prev: any, cur: any) => {\n if (prev.type === DATA_TYPE.CHN_NUMBER) {\n return true;\n }\n return false;\n },\n applyFunctions: {\n [APPLY_TYPE.SERIES]: (dataWithIndex: any, len: any, direction: any) => {\n const { data } = dataWithIndex;\n\n const isReverse = direction === Direction.LEFT || direction === Direction.UP;\n if (data.length === 1) {\n let step;\n if (!isReverse) {\n step = 1;\n } else {\n step = -1;\n }\n return reverseIfNeed(fillChnNumber(data, len, step), isReverse);\n }\n let hasWeek = false;\n for (let i = 0; i < data.length; i++) {\n const formattedValue = data[i]?.v;\n\n if (formattedValue === '日') {\n hasWeek = true;\n break;\n }\n }\n\n const dataNumArr = [];\n let weekIndex = 0;\n for (let i = 0; i < data.length; i++) {\n const formattedValue = `${data[i]?.v}`;\n if (formattedValue === '日') {\n if (i === 0) {\n dataNumArr.push(0);\n } else {\n weekIndex++;\n dataNumArr.push(weekIndex * 7);\n }\n } else if (hasWeek && chineseToNumber(formattedValue) > 0 && chineseToNumber(formattedValue) < 7) {\n dataNumArr.push(chineseToNumber(formattedValue) + weekIndex * 7);\n } else {\n dataNumArr.push(chineseToNumber(formattedValue));\n }\n }\n\n if (isReverse) {\n data.reverse();\n dataNumArr.reverse();\n }\n\n if (isEqualDiff(dataNumArr)) {\n // Always fill with sequence of Chinese lowercase numbers\n const step = dataNumArr[1] - dataNumArr[0];\n return reverseIfNeed(fillChnNumber(data, len, step), isReverse);\n }\n // Not an arithmetic progression, copy data\n return fillCopy(data, len);\n }\n }\n};\n\nexport const chnWeek2Rule: IAutoFillRule = {\n type: DATA_TYPE.CHN_WEEK2,\n priority: 820,\n match: cellData => {\n if (isChnWeek2(`${(cellData as any)?.v ?? ''}` || '')) {\n return true;\n }\n return false;\n },\n isContinue: (prev: any, cur: any) => prev.type === DATA_TYPE.CHN_WEEK2,\n applyFunctions: {\n [APPLY_TYPE.SERIES]: (dataWithIndex: any, len: any, direction: any) => {\n const { data } = dataWithIndex;\n\n const isReverse = direction === Direction.LEFT || direction === Direction.UP;\n if (data.length === 1) {\n let step;\n if (!isReverse) {\n step = 1;\n } else {\n step = -1;\n }\n\n return reverseIfNeed(fillChnWeek(data, len, step, 1), isReverse);\n }\n const dataNumArr = [];\n let weekIndex = 0;\n\n for (let i = 0; i < data.length; i++) {\n const formattedValue = `${data[i]?.v}`;\n const lastTxt = formattedValue?.substr(formattedValue.length - 1, 1);\n if (formattedValue === '周日') {\n if (i === 0) {\n dataNumArr.push(0);\n } else {\n weekIndex++;\n dataNumArr.push(weekIndex * 7);\n }\n } else {\n dataNumArr.push(chineseToNumber(lastTxt) + weekIndex * 7);\n }\n }\n\n if (isReverse) {\n data.reverse();\n dataNumArr.reverse();\n }\n\n if (isEqualDiff(dataNumArr)) {\n const step = dataNumArr[1] - dataNumArr[0];\n return reverseIfNeed(fillChnWeek(data, len, step, 1), isReverse);\n }\n return fillCopy(data, len);\n }\n }\n};\n\nexport const chnWeek3Rule: IAutoFillRule = {\n type: DATA_TYPE.CHN_WEEK3,\n priority: 810,\n match: cellData => isChnWeek3(`${(cellData as any)?.v ?? ''}` || ''),\n isContinue: (prev: any, cur: any) => prev.type === DATA_TYPE.CHN_WEEK3,\n applyFunctions: {\n [APPLY_TYPE.SERIES]: (dataWithIndex: any, len: any, direction: any) => {\n const { data } = dataWithIndex;\n\n const isReverse = direction === Direction.LEFT || direction === Direction.UP;\n if (data.length === 1) {\n let step;\n if (!isReverse) {\n step = 1;\n } else {\n step = -1;\n }\n\n return reverseIfNeed(fillChnWeek(data, len, step, 2), isReverse);\n }\n const dataNumArr = [];\n let weekIndex = 0;\n\n for (let i = 0; i < data.length; i++) {\n const formattedValue = `${data[i]?.v}`;\n if (formattedValue) {\n const lastTxt = formattedValue.substr(formattedValue.length - 1, 1);\n if (formattedValue === '星期日') {\n if (i === 0) {\n dataNumArr.push(0);\n } else {\n weekIndex++;\n dataNumArr.push(weekIndex * 7);\n }\n } else {\n dataNumArr.push(chineseToNumber(lastTxt) + weekIndex * 7);\n }\n }\n }\n\n if (isReverse) {\n data.reverse();\n dataNumArr.reverse();\n }\n\n if (isEqualDiff(dataNumArr)) {\n const step = dataNumArr[1] - dataNumArr[0];\n return reverseIfNeed(fillChnWeek(data, len, step, 2), isReverse);\n }\n return fillCopy(data, len);\n }\n }\n};\n\nexport const loopSeriesRule: IAutoFillRule = {\n type: DATA_TYPE.LOOP_SERIES,\n priority: 800,\n match: cellData => isLoopSeries(`${(cellData as any)?.v ?? ''}` || ''),\n isContinue: (prev: any, cur: any) => {\n if (prev.type === DATA_TYPE.LOOP_SERIES) {\n return (\n getLoopSeriesInfo(`${(prev.cellData as any)?.v ?? ''}` || '').name ===\n getLoopSeriesInfo(`${(cur as any)?.v ?? ''}` || '').name\n );\n }\n return false;\n },\n applyFunctions: {\n [APPLY_TYPE.SERIES]: (dataWithIndex: any, len: any, direction: any) => {\n const { data } = dataWithIndex;\n const isReverse = direction === Direction.LEFT || direction === Direction.UP;\n const { series } = getLoopSeriesInfo(`${data[0]?.v}` || '');\n if (data.length === 1) {\n let step;\n if (!isReverse) {\n step = 1;\n } else {\n step = -1;\n }\n\n return reverseIfNeed(fillLoopSeries(data, len, step, series), isReverse);\n }\n const dataNumArr = [];\n let cycleIndex = 0;\n for (let i = 0; i < data.length; i++) {\n const formattedValue = `${data[i]?.v}`;\n if (formattedValue) {\n if (formattedValue === series[0]) {\n if (i === 0) {\n dataNumArr.push(0);\n } else {\n cycleIndex++;\n dataNumArr.push(cycleIndex * series.length);\n }\n } else {\n dataNumArr.push(series.indexOf(formattedValue) + cycleIndex * 7);\n }\n }\n }\n\n if (isReverse) {\n data.reverse();\n dataNumArr.reverse();\n }\n\n if (isEqualDiff(dataNumArr)) {\n const step = dataNumArr[1] - dataNumArr[0];\n return reverseIfNeed(fillLoopSeries(data, len, step, series), isReverse);\n }\n return fillCopy(data, len);\n }\n }\n};\n\nexport function reverseIfNeed<T>(data: T[], reverse: boolean): T[] {\n return reverse ? data.reverse() : data;\n}\n\nexport const formulaRule: IAutoFillRule = {\n type: DATA_TYPE.FORMULA,\n priority: 1200,\n match: (cellData: any, accessor: any) => {\n // Check if cell contains a formula (starts with =)\n return typeof cellData?.v === 'string' && cellData.v.startsWith('=');\n },\n isContinue: (prev: any, cur: any) => {\n // Continue if both are formulas\n if (prev.type === DATA_TYPE.FORMULA && cur?.v?.startsWith('=')) {\n return true;\n }\n return false;\n },\n applyFunctions: {\n [APPLY_TYPE.COPY]: (dataWithIndex: any, len: any, direction: any, copyDataPiece: any, location?: any) => {\n const { data } = dataWithIndex;\n return fillCopy(data, len);\n },\n [APPLY_TYPE.SERIES]: (dataWithIndex: any, len: any, direction: any, copyDataPiece: any, location?: any) => {\n const { data } = dataWithIndex;\n\n // For formulas, series fill means adjusting cell references\n if (data.length === 1) {\n // Single formula - adjust references based on direction\n return adjustFormulaReferences(data, len, direction, location);\n }\n\n // Multiple formulas - check if they follow a pattern\n const adjustedFormulas = adjustFormulaReferencesInSeries(data, len, direction, location);\n if (adjustedFormulas) {\n return adjustedFormulas;\n }\n\n // If no clear pattern, fall back to copy\n return fillCopy(data, len);\n }\n }\n};\n\n/**\n * Adjust formula cell references for auto-fill\n */\nfunction adjustFormulaReferences(\n formulas: any[],\n len: number,\n direction: Direction,\n location?: any\n): Array<Nullable<ICellData>> {\n const result: Array<Nullable<ICellData>> = [];\n const baseFormula = formulas[0]?.v || '';\n\n for (let i = 0; i < len; i++) {\n let newFormula = baseFormula;\n\n // Calculate offset based on direction and position\n let rowOffset = 0;\n let colOffset = 0;\n\n switch (direction) {\n case Direction.DOWN:\n rowOffset = i + 1;\n break;\n case Direction.UP:\n rowOffset = -(i + 1);\n break;\n case Direction.RIGHT:\n colOffset = i + 1;\n break;\n case Direction.LEFT:\n colOffset = -(i + 1);\n break;\n }\n\n // Adjust cell references in formula\n newFormula = adjustCellReferencesInFormula(baseFormula, rowOffset, colOffset);\n\n result.push({\n v: newFormula,\n t: formulas[0]?.t\n });\n }\n\n return result;\n}\n\n/**\n * Adjust formula references in a series pattern\n */\nfunction adjustFormulaReferencesInSeries(\n formulas: any[],\n len: number,\n direction: Direction,\n location?: any\n): Array<Nullable<ICellData>> | null {\n if (formulas.length < 2) {\n return null;\n }\n\n // Extract and analyze the pattern in existing formulas\n const baseFormula1 = formulas[0]?.v || '';\n const baseFormula2 = formulas[1]?.v || '';\n\n // Try to detect the pattern difference\n const pattern = detectFormulaPattern(baseFormula1, baseFormula2);\n if (!pattern) {\n return null;\n }\n\n const result: Array<Nullable<ICellData>> = [];\n\n // Generate formulas following the detected pattern\n for (let i = 0; i < len; i++) {\n let newFormula = baseFormula1;\n\n // Apply pattern multiplier based on position\n const multiplier = i + 1;\n newFormula = applyFormulaPattern(newFormula, pattern, multiplier, direction);\n\n result.push({\n v: newFormula,\n t: formulas[0]?.t\n });\n }\n\n return result;\n}\n\n/**\n * Detect the pattern between two formulas\n */\nfunction detectFormulaPattern(formula1: string, formula2: string): { rowOffset: number; colOffset: number } | null {\n // Simple pattern detection - look for cell reference differences\n const cellRefRegex = /\\$?([A-Z]+)\\$?(\\d+)/g;\n const matches1 = [...formula1.matchAll(cellRefRegex)];\n const matches2 = [...formula2.matchAll(cellRefRegex)];\n\n if (matches1.length !== matches2.length || matches1.length === 0) {\n return null;\n }\n\n // Calculate average offset\n let totalRowOffset = 0;\n let totalColOffset = 0;\n let validMatches = 0;\n\n for (let i = 0; i < matches1.length; i++) {\n const col1 = matches1[i][1];\n const row1 = parseInt(matches1[i][2], 10);\n const col2 = matches2[i][1];\n const row2 = parseInt(matches2[i][2], 10);\n\n const colOffset = columnToNumber(col2) - columnToNumber(col1);\n const rowOffset = row2 - row1;\n\n if (Math.abs(colOffset) < 100 && Math.abs(rowOffset) < 10000) {\n // Sanity check\n totalColOffset += colOffset;\n totalRowOffset += rowOffset;\n validMatches++;\n }\n }\n\n if (validMatches === 0) {\n return null;\n }\n\n return {\n rowOffset: totalRowOffset / validMatches,\n colOffset: totalColOffset / validMatches\n };\n}\n\n/**\n * Apply pattern to formula\n */\nfunction applyFormulaPattern(\n formula: string,\n pattern: { rowOffset: number; colOffset: number },\n multiplier: number,\n direction: Direction\n): string {\n const cellRefRegex = /\\$?([A-Z]+)\\$?(\\d+)/g;\n\n return formula.replace(cellRefRegex, (match, colStr, rowStr) => {\n const isColAbsolute = match.startsWith('$') && match.indexOf(colStr) > 0;\n const isRowAbsolute = match.includes('$' + rowStr);\n\n let newCol = colStr;\n let newRow = rowStr;\n\n if (!isColAbsolute && pattern.colOffset !== 0) {\n const colNum = columnToNumber(colStr);\n const newColNum = colNum + pattern.colOffset * multiplier;\n newCol = numberToColumn(newColNum);\n }\n\n if (!isRowAbsolute && pattern.rowOffset !== 0) {\n const rowNum = parseInt(rowStr, 10);\n const newRowNum = rowNum + pattern.rowOffset * multiplier;\n newRow = newRowNum.toString();\n }\n\n // Reconstruct reference with original absolute references preserved\n let result = '';\n if (isColAbsolute) {\n result += '$';\n }\n result += newCol;\n if (isRowAbsolute) {\n result += '$';\n }\n result += newRow;\n\n return result;\n });\n}\n\n/**\n * Adjust cell references in formula\n */\nfunction adjustCellReferencesInFormula(formula: string, rowOffset: number, colOffset: number): string {\n const cellRefRegex = /\\$?([A-Z]+)\\$?(\\d+)/g;\n\n return formula.replace(cellRefRegex, (match, colStr, rowStr) => {\n const isColAbsolute = match.startsWith('$') && match.indexOf(colStr) > 0;\n const isRowAbsolute = match.includes('$' + rowStr);\n\n let newCol = colStr;\n let newRow = rowStr;\n\n if (!isColAbsolute && colOffset !== 0) {\n const colNum = columnToNumber(colStr);\n const newColNum = colNum + colOffset;\n newCol = numberToColumn(newColNum);\n }\n\n if (!isRowAbsolute && rowOffset !== 0) {\n const rowNum = parseInt(rowStr, 10);\n const newRowNum = rowNum + rowOffset;\n newRow = newRowNum.toString();\n }\n\n // Reconstruct reference with original absolute references preserved\n let result = '';\n if (isColAbsolute) {\n result += '$';\n }\n result += newCol;\n if (isRowAbsolute) {\n result += '$';\n }\n result += newRow;\n\n return result;\n });\n}\n\n/**\n * Convert column letter to number (A=1, B=2, etc.)\n */\nfunction columnToNumber(col: string): number {\n let result = 0;\n for (let i = 0; i < col.length; i++) {\n result = result * 26 + (col.charCodeAt(i) - 'A'.charCodeAt(0) + 1);\n }\n return result;\n}\n\n/**\n * Convert column number to letter (1=A, 2=B, etc.)\n */\nfunction numberToColumn(num: number): string {\n let result = '';\n while (num > 0) {\n num--;\n result = String.fromCharCode('A'.charCodeAt(0) + (num % 26)) + result;\n num = Math.floor(num / 26);\n }\n return result;\n}\n"]}
@@ -2,5 +2,4 @@ export * from "./menu-manager";
2
2
 
3
3
  export * from "./styles";
4
4
 
5
- export * from "./types";
6
- //# sourceMappingURL=index.js.map
5
+ export * from "./types";
@@ -126,4 +126,5 @@ export class MenuManager {
126
126
  this.menuContainer = null), null !== this.hideTimeout && (clearTimeout(this.hideTimeout),
127
127
  this.hideTimeout = null), vglobal.removeEventListener("click", this.handleDocumentClick);
128
128
  }
129
- }
129
+ }
130
+ //# sourceMappingURL=menu-manager.js.map
@@ -14,6 +14,7 @@ export declare enum ExcelEditCellKeyboardResponse {
14
14
  export type IExcelEditCellKeyboardPluginOptions = {
15
15
  id?: string;
16
16
  responseKeyboard?: ExcelEditCellKeyboardResponse[];
17
+ deleteWorkOnEditableCell?: boolean;
17
18
  };
18
19
  export declare class ExcelEditCellKeyboardPlugin implements pluginsDefinition.IVTablePlugin {
19
20
  id: string;
@@ -25,7 +25,8 @@ export class ExcelEditCellKeyboardPlugin {
25
25
  document.addEventListener("keydown", this.handleKeyDown.bind(this), !0);
26
26
  }
27
27
  handleKeyDown(event) {
28
- if (this.table.editorManager && this.isExcelShortcutKey(event)) {
28
+ var _a, _b, _c;
29
+ if ((null === (_a = this.table) || void 0 === _a ? void 0 : _a.editorManager) && this.isExcelShortcutKey(event)) {
29
30
  const eventKey = event.key.toLowerCase();
30
31
  if (this.table.editorManager.editingEditor && "keydown" === this.table.editorManager.beginTriggerEditCellMode) {
31
32
  const {col: col, row: row} = this.table.editorManager.editCell;
@@ -36,7 +37,7 @@ export class ExcelEditCellKeyboardPlugin {
36
37
  if (!this.table.editorManager.editingEditor || eventKey !== ExcelEditCellKeyboardResponse.ENTER && eventKey !== ExcelEditCellKeyboardResponse.TAB) {
37
38
  if (!this.table.editorManager.editingEditor && (eventKey === ExcelEditCellKeyboardResponse.DELETE || eventKey === ExcelEditCellKeyboardResponse.BACKSPACE)) {
38
39
  const selectCells = this.table.getSelectedCellInfos();
39
- (null == selectCells ? void 0 : selectCells.length) > 0 && document.activeElement === this.table.getElement() && (deleteSelectRange(selectCells, this.table),
40
+ (null == selectCells ? void 0 : selectCells.length) > 0 && document.activeElement === this.table.getElement() && (deleteSelectRange(selectCells, this.table, null === (_c = null === (_b = this.pluginOptions) || void 0 === _b ? void 0 : _b.deleteWorkOnEditableCell) || void 0 === _c || _c),
40
41
  event.stopPropagation(), event.preventDefault());
41
42
  }
42
43
  } else this.table.editorManager.completeEdit(), this.table.getElement().focus(),
@@ -62,7 +63,7 @@ export class ExcelEditCellKeyboardPlugin {
62
63
  }
63
64
  }
64
65
 
65
- function deleteSelectRange(selectCells, tableInstance) {
66
- for (let i = 0; i < selectCells.length; i++) for (let j = 0; j < selectCells[i].length; j++) tableInstance.changeCellValue(selectCells[i][j].col, selectCells[i][j].row, "");
66
+ function deleteSelectRange(selectCells, tableInstance, workOnEditableCell = !1) {
67
+ for (let i = 0; i < selectCells.length; i++) for (let j = 0; j < selectCells[i].length; j++) tableInstance.changeCellValue(selectCells[i][j].col, selectCells[i][j].row, "", workOnEditableCell);
67
68
  }
68
69
  //# sourceMappingURL=excel-edit-cell-keyboard.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/excel-edit-cell-keyboard.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGpD,MAAM,CAAN,IAAY,6BASX;AATD,WAAY,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AAE;QAC3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC9C,aAAa,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;SACjF;KACF;AACH,CAAC","file":"excel-edit-cell-keyboard.js","sourcesContent":["import type { ListTable, BaseTableAPI, TYPES, pluginsDefinition } from '@visactor/vtable';\nimport { TABLE_EVENT_TYPE } from '@visactor/vtable';\nimport type { TableEvents } from '@visactor/vtable/src/core/TABLE_EVENT_TYPE';\nimport type { EventArg } from './types';\nexport enum ExcelEditCellKeyboardResponse {\n ENTER = 'enter',\n TAB = 'tab',\n ARROW_LEFT = 'arrowLeft',\n ARROW_RIGHT = 'arrowRight',\n ARROW_DOWN = 'arrowDown',\n ARROW_UP = 'arrowUp',\n DELETE = 'delete',\n BACKSPACE = 'backspace'\n}\n//备用 插件配置项 目前感觉都走默认逻辑就行\nexport type IExcelEditCellKeyboardPluginOptions = {\n id?: string;\n responseKeyboard?: ExcelEditCellKeyboardResponse[];\n // keyDown_before?: (event: KeyboardEvent) => void;\n // keyDown_after?: (event: KeyboardEvent) => void;\n // 是否响应删除\n // enableDeleteKey?: boolean;\n};\n\nexport class ExcelEditCellKeyboardPlugin implements pluginsDefinition.IVTablePlugin {\n id = `excel-edit-cell-keyboard`;\n name = 'Excel Edit Cell Keyboard';\n runTime = [TABLE_EVENT_TYPE.INITIALIZED];\n table: ListTable;\n pluginOptions: IExcelEditCellKeyboardPluginOptions;\n responseKeyboard: ExcelEditCellKeyboardResponse[];\n constructor(pluginOptions?: IExcelEditCellKeyboardPluginOptions) {\n this.id = pluginOptions?.id ?? this.id;\n this.pluginOptions = pluginOptions;\n this.responseKeyboard = pluginOptions?.responseKeyboard ?? [\n ExcelEditCellKeyboardResponse.ENTER,\n ExcelEditCellKeyboardResponse.TAB,\n ExcelEditCellKeyboardResponse.ARROW_LEFT,\n ExcelEditCellKeyboardResponse.ARROW_RIGHT,\n ExcelEditCellKeyboardResponse.ARROW_DOWN,\n ExcelEditCellKeyboardResponse.ARROW_UP,\n ExcelEditCellKeyboardResponse.DELETE,\n ExcelEditCellKeyboardResponse.BACKSPACE\n ];\n\n this.bindEvent();\n }\n run(...args: [EventArg, TableEvents[keyof TableEvents] | TableEvents[keyof TableEvents][], BaseTableAPI]) {\n const table: BaseTableAPI = args[2];\n this.table = table as ListTable;\n }\n\n bindEvent() {\n //监听document全局的keydown事件 捕获阶段监听 可以及时阻止事件传播和默认行为\n document.addEventListener('keydown', this.handleKeyDown.bind(this), true);\n // this.table.on('selected_cell', () => {\n // this.updateHighlight();\n // });\n\n // this.table.on('selected_clear', () => {\n // this.clearHighlight();\n // });\n\n // this.table.on('mousemove_table', () => {\n // if (this.table.stateManager.select.selecting) {\n // this.updateHighlight();\n // }\n // });\n }\n handleKeyDown(event: KeyboardEvent) {\n // this.pluginOptions?.keyDown_before?.(event);\n if (this.table.editorManager && this.isExcelShortcutKey(event)) {\n const eventKey = event.key.toLowerCase() as ExcelEditCellKeyboardResponse;\n //判断是键盘触发编辑单元格的情况下,那么在编辑状态中切换方向需要选中下一个继续编辑\n if (this.table.editorManager.editingEditor && this.table.editorManager.beginTriggerEditCellMode === 'keydown') {\n const { col, row } = this.table.editorManager.editCell;\n this.table.editorManager.completeEdit();\n this.table.getElement().focus();\n if (!event.shiftKey && !event.ctrlKey && !event.metaKey) {\n //有这些配合键,则不进行选中下一个单元格的行为 执行vtable内部逻辑\n if (eventKey === ExcelEditCellKeyboardResponse.ENTER) {\n this.table.selectCell(col, row + 1);\n } else if (eventKey === ExcelEditCellKeyboardResponse.TAB) {\n this.table.selectCell(col + 1, row);\n } else if (eventKey === ExcelEditCellKeyboardResponse.ARROW_LEFT) {\n this.table.selectCell(col - 1, row);\n } else if (eventKey === ExcelEditCellKeyboardResponse.ARROW_RIGHT) {\n this.table.selectCell(col + 1, row);\n } else if (eventKey === ExcelEditCellKeyboardResponse.ARROW_DOWN) {\n this.table.selectCell(col, row + 1);\n } else if (eventKey === ExcelEditCellKeyboardResponse.ARROW_UP) {\n this.table.selectCell(col, row - 1);\n }\n // 阻止事件传播和默认行为\n event.stopPropagation();\n event.preventDefault();\n }\n } else {\n const { col, row } = this.table.stateManager.select.cellPos;\n if (\n this.table.editorManager.editingEditor &&\n (eventKey === ExcelEditCellKeyboardResponse.ENTER || eventKey === ExcelEditCellKeyboardResponse.TAB)\n ) {\n this.table.editorManager.completeEdit();\n this.table.getElement().focus();\n if (eventKey === ExcelEditCellKeyboardResponse.ENTER) {\n this.table.selectCell(col, row + 1);\n } else if (eventKey === ExcelEditCellKeyboardResponse.TAB) {\n this.table.selectCell(col + 1, row);\n }\n // 阻止事件传播和默认行为\n event.stopPropagation();\n event.preventDefault();\n } else if (\n !this.table.editorManager.editingEditor &&\n (eventKey === ExcelEditCellKeyboardResponse.DELETE || eventKey === ExcelEditCellKeyboardResponse.BACKSPACE)\n ) {\n //响应删除键,删除\n const selectCells = this.table.getSelectedCellInfos();\n if (selectCells?.length > 0 && document.activeElement === this.table.getElement()) {\n // 如果选中的是范围,则删除范围内的所有单元格\n deleteSelectRange(selectCells, this.table);\n // 阻止事件传播和默认行为\n event.stopPropagation();\n event.preventDefault();\n }\n }\n }\n }\n // this.pluginOptions?.keyDown_after?.apply(this, [event]);\n }\n // 判断event的keyCode是否是excel的快捷键\n isExcelShortcutKey(event: KeyboardEvent) {\n return this.responseKeyboard.includes(event.key.toLowerCase() as ExcelEditCellKeyboardResponse);\n }\n setResponseKeyboard(responseKeyboard: ExcelEditCellKeyboardResponse[]) {\n this.responseKeyboard = responseKeyboard;\n }\n deleteResponseKeyboard(responseKeyboard: ExcelEditCellKeyboardResponse[]) {\n this.responseKeyboard = this.responseKeyboard.filter(key => !responseKeyboard.includes(key));\n }\n addResponseKeyboard(responseKeyboard: ExcelEditCellKeyboardResponse[]) {\n this.responseKeyboard = [...this.responseKeyboard, ...responseKeyboard];\n }\n release() {\n document.removeEventListener('keydown', this.handleKeyDown, true);\n }\n}\n//将选中单元格的值设置为空\nfunction deleteSelectRange(selectCells: TYPES.CellInfo[][], tableInstance: ListTable) {\n for (let i = 0; i < selectCells.length; i++) {\n for (let j = 0; j < selectCells[i].length; j++) {\n tableInstance.changeCellValue(selectCells[i][j].col, selectCells[i][j].row, '');\n }\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/excel-edit-cell-keyboard.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGpD,MAAM,CAAN,IAAY,6BASX;AATD,WAAY,6BAA6B;IACvC,gDAAe,CAAA;IACf,4CAAW,CAAA;IACX,yDAAwB,CAAA;IACxB,2DAA0B,CAAA;IAC1B,yDAAwB,CAAA;IACxB,qDAAoB,CAAA;IACpB,kDAAiB,CAAA;IACjB,wDAAuB,CAAA;AACzB,CAAC,EATW,6BAA6B,KAA7B,6BAA6B,QASxC;AAYD,MAAM,OAAO,2BAA2B;IAOtC,YAAY,aAAmD;;QAN/D,OAAE,GAAG,0BAA0B,CAAC;QAChC,SAAI,GAAG,0BAA0B,CAAC;QAClC,YAAO,GAAG,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC;QAKvC,IAAI,CAAC,EAAE,GAAG,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,EAAE,mCAAI,IAAI,CAAC,EAAE,CAAC;QACvC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,gBAAgB,GAAG,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,gBAAgB,mCAAI;YACzD,6BAA6B,CAAC,KAAK;YACnC,6BAA6B,CAAC,GAAG;YACjC,6BAA6B,CAAC,UAAU;YACxC,6BAA6B,CAAC,WAAW;Y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B,CAAC,gBAAiD;QACtE,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,gBAAgB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;IAC/F,CAAC;IACD,mBAAmB,CAAC,gBAAiD;QACnE,IAAI,CAAC,gBAAgB,GAAG,CAAC,GAAG,IAAI,CAAC,gBAAgB,EAAE,GAAG,gBAAgB,CAAC,CAAC;IAC1E,CAAC;IACD,OAAO;QACL,QAAQ,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;IACpE,CAAC;CACF;AAED,SAAS,iBAAiB,CACxB,WAA+B,EAC/B,aAAwB,EACxB,qBAA8B,KAAK;IAEnC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC9C,aAAa,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,EAAE,kBAAkB,CAAC,CAAC;SACrG;KACF;AACH,CAAC","file":"excel-edit-cell-keyboard.js","sourcesContent":["import type { ListTable, BaseTableAPI, TYPES, pluginsDefinition } from '@visactor/vtable';\nimport { TABLE_EVENT_TYPE } from '@visactor/vtable';\nimport type { TableEvents } from '@visactor/vtable/src/core/TABLE_EVENT_TYPE';\nimport type { EventArg } from './types';\nexport enum ExcelEditCellKeyboardResponse {\n ENTER = 'enter',\n TAB = 'tab',\n ARROW_LEFT = 'arrowLeft',\n ARROW_RIGHT = 'arrowRight',\n ARROW_DOWN = 'arrowDown',\n ARROW_UP = 'arrowUp',\n DELETE = 'delete',\n BACKSPACE = 'backspace'\n}\n//备用 插件配置项 目前感觉都走默认逻辑就行\nexport type IExcelEditCellKeyboardPluginOptions = {\n id?: string;\n /** 该插件响应的键盘事件列表 */\n responseKeyboard?: ExcelEditCellKeyboardResponse[];\n /** 删除能力是否只应用到可编辑单元格 */\n deleteWorkOnEditableCell?: boolean;\n // keyDown_before?: (event: KeyboardEvent) => void;\n // keyDown_after?: (event: KeyboardEvent) => void;\n};\n\nexport class ExcelEditCellKeyboardPlugin implements pluginsDefinition.IVTablePlugin {\n id = `excel-edit-cell-keyboard`;\n name = 'Excel Edit Cell Keyboard';\n runTime = [TABLE_EVENT_TYPE.INITIALIZED];\n table: ListTable;\n pluginOptions: IExcelEditCellKeyboardPluginOptions;\n responseKeyboard: ExcelEditCellKeyboardResponse[];\n constructor(pluginOptions?: IExcelEditCellKeyboardPluginOptions) {\n this.id = pluginOptions?.id ?? this.id;\n this.pluginOptions = pluginOptions;\n this.responseKeyboard = pluginOptions?.responseKeyboard ?? [\n ExcelEditCellKeyboardResponse.ENTER,\n ExcelEditCellKeyboardResponse.TAB,\n ExcelEditCellKeyboardResponse.ARROW_LEFT,\n ExcelEditCellKeyboardResponse.ARROW_RIGHT,\n ExcelEditCellKeyboardResponse.ARROW_DOWN,\n ExcelEditCellKeyboardResponse.ARROW_UP,\n ExcelEditCellKeyboardResponse.DELETE,\n ExcelEditCellKeyboardResponse.BACKSPACE\n ];\n\n this.bindEvent();\n }\n run(...args: [EventArg, TableEvents[keyof TableEvents] | TableEvents[keyof TableEvents][], BaseTableAPI]) {\n const table: BaseTableAPI = args[2];\n this.table = table as ListTable;\n }\n\n bindEvent() {\n //监听document全局的keydown事件 捕获阶段监听 可以及时阻止事件传播和默认行为\n document.addEventListener('keydown', this.handleKeyDown.bind(this), true);\n // this.table.on('selected_cell', () => {\n // this.updateHighlight();\n // });\n\n // this.table.on('selected_clear', () => {\n // this.clearHighlight();\n // });\n\n // this.table.on('mousemove_table', () => {\n // if (this.table.stateManager.select.selecting) {\n // this.updateHighlight();\n // }\n // });\n }\n handleKeyDown(event: KeyboardEvent) {\n // this.pluginOptions?.keyDown_before?.(event);\n if (this.table?.editorManager && this.isExcelShortcutKey(event)) {\n const eventKey = event.key.toLowerCase() as ExcelEditCellKeyboardResponse;\n //判断是键盘触发编辑单元格的情况下,那么在编辑状态中切换方向需要选中下一个继续编辑\n if (this.table.editorManager.editingEditor && this.table.editorManager.beginTriggerEditCellMode === 'keydown') {\n const { col, row } = this.table.editorManager.editCell;\n this.table.editorManager.completeEdit();\n this.table.getElement().focus();\n if (!event.shiftKey && !event.ctrlKey && !event.metaKey) {\n //有这些配合键,则不进行选中下一个单元格的行为 执行vtable内部逻辑\n if (eventKey === ExcelEditCellKeyboardResponse.ENTER) {\n this.table.selectCell(col, row + 1);\n } else if (eventKey === ExcelEditCellKeyboardResponse.TAB) {\n this.table.selectCell(col + 1, row);\n } else if (eventKey === ExcelEditCellKeyboardResponse.ARROW_LEFT) {\n this.table.selectCell(col - 1, row);\n } else if (eventKey === ExcelEditCellKeyboardResponse.ARROW_RIGHT) {\n this.table.selectCell(col + 1, row);\n } else if (eventKey === ExcelEditCellKeyboardResponse.ARROW_DOWN) {\n this.table.selectCell(col, row + 1);\n } else if (eventKey === ExcelEditCellKeyboardResponse.ARROW_UP) {\n this.table.selectCell(col, row - 1);\n }\n // 阻止事件传播和默认行为\n event.stopPropagation();\n event.preventDefault();\n }\n } else {\n const { col, row } = this.table.stateManager.select.cellPos;\n if (\n this.table.editorManager.editingEditor &&\n (eventKey === ExcelEditCellKeyboardResponse.ENTER || eventKey === ExcelEditCellKeyboardResponse.TAB)\n ) {\n this.table.editorManager.completeEdit();\n this.table.getElement().focus();\n if (eventKey === ExcelEditCellKeyboardResponse.ENTER) {\n this.table.selectCell(col, row + 1);\n } else if (eventKey === ExcelEditCellKeyboardResponse.TAB) {\n this.table.selectCell(col + 1, row);\n }\n // 阻止事件传播和默认行为\n event.stopPropagation();\n event.preventDefault();\n } else if (\n !this.table.editorManager.editingEditor &&\n (eventKey === ExcelEditCellKeyboardResponse.DELETE || eventKey === ExcelEditCellKeyboardResponse.BACKSPACE)\n ) {\n //响应删除键,删除\n const selectCells = this.table.getSelectedCellInfos();\n if (selectCells?.length > 0 && document.activeElement === this.table.getElement()) {\n // 如果选中的是范围,则删除范围内的所有单元格\n deleteSelectRange(selectCells, this.table, this.pluginOptions?.deleteWorkOnEditableCell ?? true);\n // 阻止事件传播和默认行为\n event.stopPropagation();\n event.preventDefault();\n }\n }\n }\n }\n // this.pluginOptions?.keyDown_after?.apply(this, [event]);\n }\n // 判断event的keyCode是否是excel的快捷键\n isExcelShortcutKey(event: KeyboardEvent) {\n return this.responseKeyboard.includes(event.key.toLowerCase() as ExcelEditCellKeyboardResponse);\n }\n setResponseKeyboard(responseKeyboard: ExcelEditCellKeyboardResponse[]) {\n this.responseKeyboard = responseKeyboard;\n }\n deleteResponseKeyboard(responseKeyboard: ExcelEditCellKeyboardResponse[]) {\n this.responseKeyboard = this.responseKeyboard.filter(key => !responseKeyboard.includes(key));\n }\n addResponseKeyboard(responseKeyboard: ExcelEditCellKeyboardResponse[]) {\n this.responseKeyboard = [...this.responseKeyboard, ...responseKeyboard];\n }\n release() {\n document.removeEventListener('keydown', this.handleKeyDown, true);\n }\n}\n//将选中单元格的值设置为空\nfunction deleteSelectRange(\n selectCells: TYPES.CellInfo[][],\n tableInstance: ListTable,\n workOnEditableCell: boolean = false\n) {\n for (let i = 0; i < selectCells.length; i++) {\n for (let j = 0; j < selectCells[i].length; j++) {\n tableInstance.changeCellValue(selectCells[i][j].col, selectCells[i][j].row, '', workOnEditableCell);\n }\n }\n}\n"]}
@@ -77,7 +77,7 @@ export class FilterStateManager {
77
77
  this.engine.applyFilter(this.state, this.table);
78
78
  }
79
79
  shouldApplyFilter(action) {
80
- return [ FilterActionType.REMOVE_FILTER, FilterActionType.ENABLE_FILTER, FilterActionType.DISABLE_FILTER, FilterActionType.CLEAR_ALL_FILTERS, FilterActionType.APPLY_FILTERS ].includes(action.type) || action.payload.enable;
80
+ return [ FilterActionType.REMOVE_FILTER, FilterActionType.ENABLE_FILTER, FilterActionType.DISABLE_FILTER, FilterActionType.CLEAR_ALL_FILTERS, FilterActionType.APPLY_FILTERS ].includes(action.type);
81
81
  }
82
82
  }
83
83
  //# sourceMappingURL=filter-state-manager.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/filter/filter-state-manager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAM3C,MAAM,OAAO,kBAAkB;IAO7B,YAAY,KAA6B,EAAE,MAAoB;QAJvD,cAAS,GAA0B,EAAE,CAAC;QAK5C,IAAI,CAAC,KAAK,GAAG;YACX,OAAO,EAAE,IAAI,GAAG,EAAE;SACnB,CAAC;QACF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,cAAc,CAAC,OAAyB;QACtC,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAKD,qBAAqB;QACnB,MAAM,YAAY,GAAwB,EAAE,CAAC;QAC7C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;YAC3C,IAAI,MAAM,CAAC,MAAM,EAAE;gBACjB,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aAC1B;QACH,CAAC,CAAC,CAAC;QACH,OAAO,YAAY,CAAC;IACtB,CAAC;IAKD,kBAAkB;QAChB,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAMD,qBAAqB;QACnB,MAAM,YAAY,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAClD,IAAI,YAAY,CAAC,MAAM,GAAG,CAAC,EA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IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;IAC3E,CAAC;CACF","file":"filter-state-manager.js","sourcesContent":["import type { ListTable, PivotTable } from '@visactor/vtable';\nimport type { FilterState, FilterAction, FilterConfig, FilterListener } from './types';\nimport { FilterActionType } from './types';\nimport type { FilterEngine } from './filter-engine';\n\n/**\n * 筛选状态管理器,用于管理筛选状态\n */\nexport class FilterStateManager {\n private state: FilterState;\n private engine: FilterEngine;\n private listeners: Array<FilterListener> = [];\n\n private table: ListTable | PivotTable;\n\n constructor(table: ListTable | PivotTable, engine: FilterEngine) {\n this.state = {\n filters: new Map()\n };\n this.engine = engine;\n this.table = table;\n }\n\n getFilterState(fieldId?: string | number): FilterConfig {\n return this.state.filters.get(fieldId);\n }\n\n /**\n * 获取所有激活的筛选字段\n */\n getActiveFilterFields(): (string | number)[] {\n const activeFields: (string | number)[] = [];\n this.state.filters.forEach((config, field) => {\n if (config.enable) {\n activeFields.push(field);\n }\n });\n return activeFields;\n }\n\n /**\n * 获取所有筛选状态\n */\n getAllFilterStates(): FilterState {\n return this.state;\n }\n\n /**\n * 公共方法:重新应用当前所有激活的筛选状态\n * 用于在表格配置更新后恢复筛选显示\n */\n reapplyCurrentFilters(): void {\n const activeFields = this.getActiveFilterFields();\n if (activeFields.length > 0) {\n this.applyFilters();\n }\n }\n\n dispatch(action: FilterAction) {\n this.state = this.reduce(this.state, action);\n if (this.shouldApplyFilter(action)) {\n this.applyFilters();\n }\n this.notifyListeners(action);\n }\n\n subscribe(listener: FilterListener): () => void {\n this.listeners.push(listener);\n return () => {\n this.listeners = this.listeners.filter(l => l !== listener);\n };\n }\n\n private notifyListeners(action: FilterAction): void {\n this.listeners.forEach(listener => listener(this.state, action));\n }\n\n private reduce(state: FilterState, action: FilterAction): FilterState {\n const { type, payload } = action;\n const newFilter = new Map(state.filters);\n switch (type) {\n case FilterActionType.ADD_FILTER:\n newFilter.set(payload.field, payload);\n break;\n case FilterActionType.REMOVE_FILTER:\n newFilter.delete(payload.field);\n break;\n case FilterActionType.UPDATE_FILTER:\n newFilter.set(payload.field, { ...newFilter.get(payload.field), ...payload });\n break;\n case FilterActionType.ENABLE_FILTER:\n newFilter.set(payload.field, { ...newFilter.get(payload.field), enable: true });\n break;\n case FilterActionType.DISABLE_FILTER:\n newFilter.set(payload.field, { ...newFilter.get(payload.field), enable: false });\n break;\n case FilterActionType.CLEAR_ALL_FILTERS:\n newFilter.clear();\n break;\n case FilterActionType.APPLY_FILTERS:\n newFilter.set(payload.field, { ...newFilter.get(payload.field), ...payload, enable: true });\n break;\n }\n\n return { ...state, filters: newFilter };\n }\n\n private applyFilters() {\n this.engine.applyFilter(this.state, this.table);\n }\n\n private shouldApplyFilter(action: FilterAction) {\n const shouldApplyActions = [\n FilterActionType.REMOVE_FILTER,\n FilterActionType.ENABLE_FILTER,\n FilterActionType.DISABLE_FILTER,\n FilterActionType.CLEAR_ALL_FILTERS,\n FilterActionType.APPLY_FILTERS\n ];\n return shouldApplyActions.includes(action.type) || action.payload.enable;\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/filter/filter-state-manager.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAM3C,MAAM,OAAO,kBAAkB;IAO7B,YAAY,KAA6B,EAAE,MAAoB;QAJvD,cAAS,GAA0B,EAAE,CAAC;QAK5C,IAAI,CAAC,KAAK,GAAG;YACX,OAAO,EAAE,IAAI,GAAG,EAAE;SACnB,CAAC;QACF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,cAAc,CAAC,OAAyB;QACtC,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAKD,qBAAqB;QACnB,MAAM,YAAY,GAAwB,EAAE,CAAC;QAC7C,IAAI,CAAC,KAAK,CAAC,OAAO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,CAAC;IAEO,YAAY;QAClB,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IAClD,CAAC;IAEO,iBAAiB,CAAC,MAAoB;QAC5C,MAAM,kBAAkB,GAAG;YACzB,gBAAgB,CAAC,aAAa;YAC9B,gBAAgB,CAAC,aAAa;YAC9B,gBAAgB,CAAC,cAAc;YAC/B,gBAAgB,CAAC,iBAAiB;YAClC,gBAAgB,CAAC,aAAa;SAC/B,CAAC;QACF,OAAO,kBAAkB,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAClD,CAAC;CACF","file":"filter-state-manager.js","sourcesContent":["import type { ListTable, PivotTable } from '@visactor/vtable';\nimport type { FilterState, FilterAction, FilterConfig, FilterListener } from './types';\nimport { FilterActionType } from './types';\nimport type { FilterEngine } from './filter-engine';\n\n/**\n * 筛选状态管理器,用于管理筛选状态\n */\nexport class FilterStateManager {\n private state: FilterState;\n private engine: FilterEngine;\n private listeners: Array<FilterListener> = [];\n\n private table: ListTable | PivotTable;\n\n constructor(table: ListTable | PivotTable, engine: FilterEngine) {\n this.state = {\n filters: new Map()\n };\n this.engine = engine;\n this.table = table;\n }\n\n getFilterState(fieldId?: string | number): FilterConfig {\n return this.state.filters.get(fieldId);\n }\n\n /**\n * 获取所有激活的筛选字段\n */\n getActiveFilterFields(): (string | number)[] {\n const activeFields: (string | number)[] = [];\n this.state.filters.forEach((config, field) => {\n if (config.enable) {\n activeFields.push(field);\n }\n });\n return activeFields;\n }\n\n /**\n * 获取所有筛选状态\n */\n getAllFilterStates(): FilterState {\n return this.state;\n }\n\n /**\n * 公共方法:重新应用当前所有激活的筛选状态\n * 用于在表格配置更新后恢复筛选显示\n */\n reapplyCurrentFilters(): void {\n const activeFields = this.getActiveFilterFields();\n if (activeFields.length > 0) {\n this.applyFilters();\n }\n }\n\n dispatch(action: FilterAction) {\n this.state = this.reduce(this.state, action);\n if (this.shouldApplyFilter(action)) {\n this.applyFilters();\n }\n this.notifyListeners(action);\n }\n\n subscribe(listener: FilterListener): () => void {\n this.listeners.push(listener);\n return () => {\n this.listeners = this.listeners.filter(l => l !== listener);\n };\n }\n\n private notifyListeners(action: FilterAction): void {\n this.listeners.forEach(listener => listener(this.state, action));\n }\n\n private reduce(state: FilterState, action: FilterAction): FilterState {\n const { type, payload } = action;\n const newFilter = new Map(state.filters);\n switch (type) {\n case FilterActionType.ADD_FILTER:\n newFilter.set(payload.field, payload);\n break;\n case FilterActionType.REMOVE_FILTER:\n newFilter.delete(payload.field);\n break;\n case FilterActionType.UPDATE_FILTER:\n newFilter.set(payload.field, { ...newFilter.get(payload.field), ...payload });\n break;\n case FilterActionType.ENABLE_FILTER:\n newFilter.set(payload.field, { ...newFilter.get(payload.field), enable: true });\n break;\n case FilterActionType.DISABLE_FILTER:\n newFilter.set(payload.field, { ...newFilter.get(payload.field), enable: false });\n break;\n case FilterActionType.CLEAR_ALL_FILTERS:\n newFilter.clear();\n break;\n case FilterActionType.APPLY_FILTERS:\n newFilter.set(payload.field, { ...newFilter.get(payload.field), ...payload, enable: true });\n break;\n }\n\n return { ...state, filters: newFilter };\n }\n\n private applyFilters() {\n this.engine.applyFilter(this.state, this.table);\n }\n\n private shouldApplyFilter(action: FilterAction) {\n const shouldApplyActions = [\n FilterActionType.REMOVE_FILTER,\n FilterActionType.ENABLE_FILTER,\n FilterActionType.DISABLE_FILTER,\n FilterActionType.CLEAR_ALL_FILTERS,\n FilterActionType.APPLY_FILTERS\n ];\n return shouldApplyActions.includes(action.type);\n }\n}\n"]}
@@ -26,6 +26,7 @@ export declare class FilterToolbar {
26
26
  private updateSelectedField;
27
27
  private applyFilter;
28
28
  private clearFilter;
29
+ private updateClearFilterButtonState;
29
30
  render(container: HTMLElement): void;
30
31
  attachEventListeners(): void;
31
32
  adjustMenuPosition(col?: number | null, row?: number | null, providedLeft?: number | null, providedTop?: number | null): void;
@@ -10,7 +10,9 @@ export class FilterToolbar {
10
10
  this.isVisible = !1, this.selectedField = null, this.filterModes = [], this.table = table,
11
11
  this.filterStateManager = filterStateManager, this.valueFilter = new ValueFilter(this.table, this.filterStateManager),
12
12
  this.conditionFilter = new ConditionFilter(this.table, this.filterStateManager),
13
- this.filterMenuWidth = 300;
13
+ this.filterMenuWidth = 300, this.filterStateManager.subscribe((state => {
14
+ this.isVisible && null !== this.selectedField && this.updateClearFilterButtonState(this.selectedField);
15
+ }));
14
16
  }
15
17
  onTabSwitch(tab) {
16
18
  this.activeTab = tab, "byValue" === tab ? (this.valueFilter.show(), this.conditionFilter.hide()) : (this.conditionFilter.show(),
@@ -30,6 +32,12 @@ export class FilterToolbar {
30
32
  this.valueFilter && this.valueFilter.clearFilter(field), this.conditionFilter && this.conditionFilter.clearFilter(field),
31
33
  this.hide();
32
34
  }
35
+ updateClearFilterButtonState(field) {
36
+ const currentFilter = this.filterStateManager.getFilterState(field), hasActiveFilter = currentFilter && currentFilter.enable;
37
+ this.clearFilterOptionLink.style.display = "inline", this.clearFilterOptionLink.style.opacity = hasActiveFilter ? "1" : "0.5",
38
+ this.clearFilterOptionLink.style.pointerEvents = hasActiveFilter ? "auto" : "none",
39
+ this.clearFilterOptionLink.style.cursor = hasActiveFilter ? "pointer" : "not-allowed";
40
+ }
33
41
  render(container) {
34
42
  this.filterMenu = document.createElement("div"), applyStyles(this.filterMenu, filterStyles.filterMenu),
35
43
  this.filterMenu.style.width = `${this.filterMenuWidth}px`;
@@ -86,7 +94,7 @@ export class FilterToolbar {
86
94
  this.updateSelectedField(field);
87
95
  const currentFilter = this.filterStateManager.getFilterState(field);
88
96
  currentFilter && "byCondition" === currentFilter.type ? this.onTabSwitch("byCondition") : this.onTabSwitch("byValue"),
89
- setTimeout((() => {
97
+ this.updateClearFilterButtonState(field), setTimeout((() => {
90
98
  this.isVisible = !0;
91
99
  }), 0);
92
100
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/filter/filter-toolbar.ts"],"names":[],"mappings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xB,CAAC,EAAE,CAAC,CAAC,CAAC;IACR,CAAC;IAED,IAAI;QACF,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;QACvC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IACzB,CAAC;CACF","file":"filter-toolbar.js","sourcesContent":["import type { ListTable, PivotTable } from '@visactor/vtable';\nimport type { FilterStateManager } from './filter-state-manager';\nimport { ValueFilter } from './value-filter';\nimport { ConditionFilter } from './condition-filter';\nimport { applyStyles, filterStyles } from './styles';\nimport type { FilterMode } from './types';\n\n/**\n * 筛选工具栏,管理按值和按条件筛选组件\n */\nexport class FilterToolbar {\n table: ListTable | PivotTable;\n filterStateManager: FilterStateManager;\n valueFilter: ValueFilter | null = null;\n conditionFilter: ConditionFilter | null = null;\n activeTab: 'byValue' | 'byCondition' = 'byValue';\n isVisible: boolean = false;\n selectedField: string | number | null = null;\n filterModes: FilterMode[] = [];\n\n private filterMenu: HTMLElement;\n private filterMenuWidth: number;\n private currentCol?: number | null;\n private currentRow?: number | null;\n private filterTabByValue: HTMLButtonElement;\n private filterTabByCondition: HTMLButtonElement;\n private clearFilterOptionLink: HTMLAnchorElement;\n private cancelFilterButton: HTMLButtonElement;\n private applyFilterButton: HTMLButtonElement;\n\n constructor(table: ListTable | PivotTable, filterStateManager: FilterStateManager) {\n this.table = table;\n this.filterStateManager = filterStateManager;\n this.valueFilter = new ValueFilter(this.table, this.filterStateManager);\n this.conditionFilter = new ConditionFilter(this.table, this.filterStateManager);\n\n this.filterMenuWidth = 300; // 待优化,可能需要自适应内容的宽度\n }\n\n private onTabSwitch(tab: 'byValue' | 'byCondition'): void {\n this.activeTab = tab;\n if (tab === 'byValue') {\n this.valueFilter.show();\n this.conditionFilter.hide();\n } else {\n this.conditionFilter.show();\n this.valueFilter.hide();\n }\n\n const isValueTab = tab === 'byValue';\n applyStyles(this.filterTabByValue, filterStyles.tabStyle(isValueTab));\n applyStyles(this.filterTabByCondition, filterStyles.tabStyle(!isValueTab));\n }\n\n private updateSelectedField(field: string | number): void {\n this.selectedField = field;\n // 通知筛选组件更新选中字段\n if (this.valueFilter) {\n this.valueFilter.setSelectedField(field);\n }\n if (this.conditionFilter) {\n this.conditionFilter.setSelectedField(field);\n }\n }\n\n private applyFilter(field: string | number): void {\n if (this.activeTab === 'byValue') {\n this.valueFilter.applyFilter(field);\n } else if (this.activeTab === 'byCondition') {\n this.conditionFilter.applyFilter(field);\n }\n this.hide();\n }\n\n private clearFilter(field: string | number): void {\n if (this.valueFilter) {\n this.valueFilter.clearFilter(field);\n }\n if (this.conditionFilter) {\n this.conditionFilter.clearFilter(field);\n }\n this.hide();\n }\n\n render(container: HTMLElement): void {\n // === 主容器 ===\n this.filterMenu = document.createElement('div');\n applyStyles(this.filterMenu, filterStyles.filterMenu);\n this.filterMenu.style.width = `${this.filterMenuWidth}px`;\n\n // === 筛选 Tab ===\n const filterTabsContainer = document.createElement('div');\n applyStyles(filterTabsContainer, filterStyles.tabsContainer);\n\n this.filterTabByValue = document.createElement('button');\n this.filterTabByValue.innerText = '按值筛选';\n applyStyles(this.filterTabByValue, filterStyles.tabStyle(true));\n\n this.filterTabByCondition = document.createElement('button');\n this.filterTabByCondition.innerText = '按条件筛选';\n applyStyles(this.filterTabByCondition, filterStyles.tabStyle(false));\n\n filterTabsContainer.append(this.filterTabByValue, this.filterTabByCondition);\n\n // === 页脚(清除、取消、确定 筛选按钮) ===\n const footerContainer = document.createElement('div');\n applyStyles(footerContainer, filterStyles.footerContainer);\n\n this.clearFilterOptionLink = document.createElement('a');\n this.clearFilterOptionLink.href = '#';\n this.clearFilterOptionLink.innerText = '清除筛选';\n applyStyles(this.clearFilterOptionLink, filterStyles.clearLink);\n\n const footerButtons = document.createElement('div');\n this.cancelFilterButton = document.createElement('button');\n this.cancelFilterButton.innerText = '取消';\n applyStyles(this.cancelFilterButton, filterStyles.footerButton(false));\n\n this.applyFilterButton = document.createElement('button');\n this.applyFilterButton.innerText = '确认';\n applyStyles(this.applyFilterButton, filterStyles.footerButton(true));\n\n footerButtons.append(this.cancelFilterButton, this.applyFilterButton);\n footerContainer.append(this.clearFilterOptionLink, footerButtons);\n\n // --- 筛选器头部 Tab ---\n this.filterMenu.append(filterTabsContainer);\n\n // --- 筛选器内容 ---\n this.valueFilter.render(this.filterMenu);\n this.conditionFilter.render(this.filterMenu);\n\n // --- 筛选器页脚 ---\n this.filterMenu.append(footerContainer);\n\n container.appendChild(this.filterMenu); // 将筛选器添加到 DOM 中\n this.attachEventListeners();\n }\n\n attachEventListeners() {\n // 按值筛选/按条件筛选的事件监听\n this.filterTabByValue.addEventListener('click', () => {\n this.onTabSwitch('byValue');\n });\n\n this.filterTabByCondition.addEventListener('click', () => {\n this.onTabSwitch('byCondition');\n });\n\n this.cancelFilterButton.addEventListener('click', () => this.hide());\n\n this.clearFilterOptionLink.addEventListener('click', e => {\n e.preventDefault();\n this.clearFilter(this.selectedField);\n });\n\n this.applyFilterButton.addEventListener('click', () => {\n this.applyFilter(this.selectedField);\n });\n\n // 点击空白处整个筛选菜单可消失\n document.addEventListener('click', () => {\n if (this.isVisible) {\n this.hide();\n }\n });\n\n this.filterMenu.addEventListener('click', e => {\n e.stopPropagation();\n });\n }\n\n adjustMenuPosition(\n col?: number | null,\n row?: number | null,\n providedLeft?: number | null,\n providedTop?: number | null\n ) {\n if (typeof providedLeft === 'number' && typeof providedTop === 'number') {\n this.filterMenu.style.display = this.isVisible ? 'block' : 'none';\n this.filterMenu.style.left = `${providedLeft}px`;\n this.filterMenu.style.top = `${providedTop}px`;\n return;\n }\n\n // 明晰的参数 > 记忆的数字\n const effectiveCol = typeof col === 'number' ? col : this.currentCol;\n const effectiveRow = typeof row === 'number' ? row : this.currentRow;\n\n if (typeof effectiveCol !== 'number' || typeof effectiveRow !== 'number') {\n return;\n }\n\n this.currentCol = effectiveCol;\n this.currentRow = effectiveRow;\n\n let left: number = 0;\n let top: number = 0;\n\n const canvasBounds = this.table.canvas.getBoundingClientRect();\n const cell = this.table.getCellRelativeRect(effectiveCol, effectiveRow);\n\n if (cell.right < this.filterMenuWidth) {\n // 无法把筛选菜单完整地显示在左侧,那么显示在右侧\n left = cell.left + canvasBounds.left;\n top = cell.bottom + canvasBounds.top;\n } else {\n // 筛选菜单默认显示在左侧\n left = cell.right + canvasBounds.left - this.filterMenuWidth;\n top = cell.bottom + canvasBounds.top;\n }\n\n this.filterMenu.style.display = this.isVisible ? 'block' : 'none';\n this.filterMenu.style.left = `${left}px`;\n this.filterMenu.style.top = `${top}px`;\n }\n\n show(col: number, row: number, filterModes: FilterMode[]): void {\n this.valueFilter.clearSearchInputValue();\n this.filterModes = filterModes;\n if (!this.filterModes.includes('byValue')) {\n this.filterTabByValue.style.display = 'none';\n this.onTabSwitch('byCondition');\n } else if (!this.filterModes.includes('byCondition')) {\n this.filterTabByCondition.style.display = 'none';\n this.onTabSwitch('byValue');\n }\n\n this.adjustMenuPosition(col, row);\n this.filterMenu.style.display = 'block';\n\n const field = this.table.internalProps.layoutMap.getHeaderField(col, row) as string | number;\n this.updateSelectedField(field);\n\n // 根据当前筛选配置自动选择正确的筛选标签页\n const currentFilter = this.filterStateManager.getFilterState(field);\n if (currentFilter && currentFilter.type === 'byCondition') {\n this.onTabSwitch('byCondition');\n } else {\n this.onTabSwitch('byValue');\n }\n\n // 确保在事件冒泡完成后才设置 isVisible 为 true\n setTimeout(() => {\n this.isVisible = true;\n }, 0);\n }\n\n hide(): void {\n this.filterMenu.style.display = 'none';\n this.isVisible = false;\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/filter/filter-toolbar.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAMrD,MAAM,OAAO,aAAa;IAoBxB,YAAY,KAA6B,EAAE,kBAAsC;QAjBjF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,GAAG,EAAE,GAAG,CAAC,CAAC;QAClC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC;QAExC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,SAAS,CAAC,cAAc,CAAC,GAAG,EAAE,GAAG,CAAoB,CAAC;QAC7F,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;QAGhC,MAAM,aAAa,GAAG,IAAI,CAAC,kBAAkB,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;QACpE,IAAI,aAAa,IAAI,aAAa,CAAC,IAAI,KAAK,aAAa,EAAE;YACzD,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;SACjC;aAAM;YACL,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;SAC7B;QAGD,IAAI,CAAC,4BAA4B,CAAC,KAAK,CAAC,CAAC;QAGzC,UAAU,CAAC,GAAG,EAAE;YACd,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACxB,CAAC,EAAE,CAAC,CAAC,CAAC;IACR,CAAC;IAED,IAAI;QACF,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC;QACvC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IACzB,CAAC;CACF","file":"filter-toolbar.js","sourcesContent":["import type { ListTable, PivotTable } from '@visactor/vtable';\nimport type { FilterStateManager } from './filter-state-manager';\nimport { ValueFilter } from './value-filter';\nimport { ConditionFilter } from './condition-filter';\nimport { applyStyles, filterStyles } from './styles';\nimport type { FilterMode } from './types';\n\n/**\n * 筛选工具栏,管理按值和按条件筛选组件\n */\nexport class FilterToolbar {\n table: ListTable | PivotTable;\n filterStateManager: FilterStateManager;\n valueFilter: ValueFilter | null = null;\n conditionFilter: ConditionFilter | null = null;\n activeTab: 'byValue' | 'byCondition' = 'byValue';\n isVisible: boolean = false;\n selectedField: string | number | null = null;\n filterModes: FilterMode[] = [];\n\n private filterMenu: HTMLElement;\n private filterMenuWidth: number;\n private currentCol?: number | null;\n private currentRow?: number | null;\n private filterTabByValue: HTMLButtonElement;\n private filterTabByCondition: HTMLButtonElement;\n private clearFilterOptionLink: HTMLAnchorElement;\n private cancelFilterButton: HTMLButtonElement;\n private applyFilterButton: HTMLButtonElement;\n\n constructor(table: ListTable | PivotTable, filterStateManager: FilterStateManager) {\n this.table = table;\n this.filterStateManager = filterStateManager;\n this.valueFilter = new ValueFilter(this.table, this.filterStateManager);\n this.conditionFilter = new ConditionFilter(this.table, this.filterStateManager);\n\n this.filterMenuWidth = 300; // 待优化,可能需要自适应内容的宽度\n\n // 监听筛选状态变化,更新清除筛选按钮状态\n this.filterStateManager.subscribe(state => {\n if (this.isVisible && this.selectedField !== null) {\n this.updateClearFilterButtonState(this.selectedField);\n }\n });\n }\n\n private onTabSwitch(tab: 'byValue' | 'byCondition'): void {\n this.activeTab = tab;\n if (tab === 'byValue') {\n this.valueFilter.show();\n this.conditionFilter.hide();\n } else {\n this.conditionFilter.show();\n this.valueFilter.hide();\n }\n\n const isValueTab = tab === 'byValue';\n applyStyles(this.filterTabByValue, filterStyles.tabStyle(isValueTab));\n applyStyles(this.filterTabByCondition, filterStyles.tabStyle(!isValueTab));\n }\n\n private updateSelectedField(field: string | number): void {\n this.selectedField = field;\n // 通知筛选组件更新选中字段\n if (this.valueFilter) {\n this.valueFilter.setSelectedField(field);\n }\n if (this.conditionFilter) {\n this.conditionFilter.setSelectedField(field);\n }\n }\n\n private applyFilter(field: string | number): void {\n if (this.activeTab === 'byValue') {\n this.valueFilter.applyFilter(field);\n } else if (this.activeTab === 'byCondition') {\n this.conditionFilter.applyFilter(field);\n }\n this.hide();\n }\n\n private clearFilter(field: string | number): void {\n if (this.valueFilter) {\n this.valueFilter.clearFilter(field);\n }\n if (this.conditionFilter) {\n this.conditionFilter.clearFilter(field);\n }\n this.hide();\n }\n\n /**\n * 更新清除筛选按钮的状态\n */\n private updateClearFilterButtonState(field: string | number): void {\n const currentFilter = this.filterStateManager.getFilterState(field);\n const hasActiveFilter = currentFilter && currentFilter.enable;\n\n this.clearFilterOptionLink.style.display = 'inline';\n this.clearFilterOptionLink.style.opacity = hasActiveFilter ? '1' : '0.5';\n this.clearFilterOptionLink.style.pointerEvents = hasActiveFilter ? 'auto' : 'none';\n this.clearFilterOptionLink.style.cursor = hasActiveFilter ? 'pointer' : 'not-allowed';\n }\n\n render(container: HTMLElement): void {\n // === 主容器 ===\n this.filterMenu = document.createElement('div');\n applyStyles(this.filterMenu, filterStyles.filterMenu);\n this.filterMenu.style.width = `${this.filterMenuWidth}px`;\n\n // === 筛选 Tab ===\n const filterTabsContainer = document.createElement('div');\n applyStyles(filterTabsContainer, filterStyles.tabsContainer);\n\n this.filterTabByValue = document.createElement('button');\n this.filterTabByValue.innerText = '按值筛选';\n applyStyles(this.filterTabByValue, filterStyles.tabStyle(true));\n\n this.filterTabByCondition = document.createElement('button');\n this.filterTabByCondition.innerText = '按条件筛选';\n applyStyles(this.filterTabByCondition, filterStyles.tabStyle(false));\n\n filterTabsContainer.append(this.filterTabByValue, this.filterTabByCondition);\n\n // === 页脚(清除、取消、确定 筛选按钮) ===\n const footerContainer = document.createElement('div');\n applyStyles(footerContainer, filterStyles.footerContainer);\n\n this.clearFilterOptionLink = document.createElement('a');\n this.clearFilterOptionLink.href = '#';\n this.clearFilterOptionLink.innerText = '清除筛选';\n applyStyles(this.clearFilterOptionLink, filterStyles.clearLink);\n\n const footerButtons = document.createElement('div');\n this.cancelFilterButton = document.createElement('button');\n this.cancelFilterButton.innerText = '取消';\n applyStyles(this.cancelFilterButton, filterStyles.footerButton(false));\n\n this.applyFilterButton = document.createElement('button');\n this.applyFilterButton.innerText = '确认';\n applyStyles(this.applyFilterButton, filterStyles.footerButton(true));\n\n footerButtons.append(this.cancelFilterButton, this.applyFilterButton);\n footerContainer.append(this.clearFilterOptionLink, footerButtons);\n\n // --- 筛选器头部 Tab ---\n this.filterMenu.append(filterTabsContainer);\n\n // --- 筛选器内容 ---\n this.valueFilter.render(this.filterMenu);\n this.conditionFilter.render(this.filterMenu);\n\n // --- 筛选器页脚 ---\n this.filterMenu.append(footerContainer);\n\n container.appendChild(this.filterMenu); // 将筛选器添加到 DOM 中\n this.attachEventListeners();\n }\n\n attachEventListeners() {\n // 按值筛选/按条件筛选的事件监听\n this.filterTabByValue.addEventListener('click', () => {\n this.onTabSwitch('byValue');\n });\n\n this.filterTabByCondition.addEventListener('click', () => {\n this.onTabSwitch('byCondition');\n });\n\n this.cancelFilterButton.addEventListener('click', () => this.hide());\n\n this.clearFilterOptionLink.addEventListener('click', e => {\n e.preventDefault();\n this.clearFilter(this.selectedField);\n });\n\n this.applyFilterButton.addEventListener('click', () => {\n this.applyFilter(this.selectedField);\n });\n\n // 点击空白处整个筛选菜单可消失\n document.addEventListener('click', () => {\n if (this.isVisible) {\n this.hide();\n }\n });\n\n this.filterMenu.addEventListener('click', e => {\n e.stopPropagation();\n });\n }\n\n adjustMenuPosition(\n col?: number | null,\n row?: number | null,\n providedLeft?: number | null,\n providedTop?: number | null\n ) {\n if (typeof providedLeft === 'number' && typeof providedTop === 'number') {\n this.filterMenu.style.display = this.isVisible ? 'block' : 'none';\n this.filterMenu.style.left = `${providedLeft}px`;\n this.filterMenu.style.top = `${providedTop}px`;\n return;\n }\n\n // 明晰的参数 > 记忆的数字\n const effectiveCol = typeof col === 'number' ? col : this.currentCol;\n const effectiveRow = typeof row === 'number' ? row : this.currentRow;\n\n if (typeof effectiveCol !== 'number' || typeof effectiveRow !== 'number') {\n return;\n }\n\n this.currentCol = effectiveCol;\n this.currentRow = effectiveRow;\n\n let left: number = 0;\n let top: number = 0;\n\n const canvasBounds = this.table.canvas.getBoundingClientRect();\n const cell = this.table.getCellRelativeRect(effectiveCol, effectiveRow);\n\n if (cell.right < this.filterMenuWidth) {\n // 无法把筛选菜单完整地显示在左侧,那么显示在右侧\n left = cell.left + canvasBounds.left;\n top = cell.bottom + canvasBounds.top;\n } else {\n // 筛选菜单默认显示在左侧\n left = cell.right + canvasBounds.left - this.filterMenuWidth;\n top = cell.bottom + canvasBounds.top;\n }\n\n this.filterMenu.style.display = this.isVisible ? 'block' : 'none';\n this.filterMenu.style.left = `${left}px`;\n this.filterMenu.style.top = `${top}px`;\n }\n\n show(col: number, row: number, filterModes: FilterMode[]): void {\n this.valueFilter.clearSearchInputValue();\n this.filterModes = filterModes;\n if (!this.filterModes.includes('byValue')) {\n this.filterTabByValue.style.display = 'none';\n this.onTabSwitch('byCondition');\n } else if (!this.filterModes.includes('byCondition')) {\n this.filterTabByCondition.style.display = 'none';\n this.onTabSwitch('byValue');\n }\n\n this.adjustMenuPosition(col, row);\n this.filterMenu.style.display = 'block';\n\n const field = this.table.internalProps.layoutMap.getHeaderField(col, row) as string | number;\n this.updateSelectedField(field);\n\n // 根据当前筛选配置自动选择正确的筛选标签页\n const currentFilter = this.filterStateManager.getFilterState(field);\n if (currentFilter && currentFilter.type === 'byCondition') {\n this.onTabSwitch('byCondition');\n } else {\n this.onTabSwitch('byValue');\n }\n\n // 更新清除筛选按钮状态\n this.updateClearFilterButtonState(field);\n\n // 确保在事件冒泡完成后才设置 isVisible 为 true\n setTimeout(() => {\n this.isVisible = true;\n }, 0);\n }\n\n hide(): void {\n this.filterMenu.style.display = 'none';\n this.isVisible = false;\n }\n}\n"]}
@@ -128,7 +128,8 @@ export class FilterPlugin {
128
128
  })));
129
129
  }
130
130
  release() {
131
- this.table = null, this.filterEngine = null, this.filterStateManager = null, this.filterToolbar = null;
131
+ this.table = null, this.filterEngine = null, this.filterStateManager = null, this.filterToolbar.valueFilter.destroy(),
132
+ this.filterToolbar = null;
132
133
  }
133
134
  }
134
135
  //# sourceMappingURL=filter.js.map