@visactor/vtable-sheet 1.22.0 → 1.22.2

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 (41) hide show
  1. package/cjs/components/vtable-sheet.d.ts +2 -2
  2. package/cjs/components/vtable-sheet.js +28 -2
  3. package/cjs/components/vtable-sheet.js.map +1 -1
  4. package/cjs/core/WorkSheet.d.ts +3 -0
  5. package/cjs/core/WorkSheet.js +22 -3
  6. package/cjs/core/WorkSheet.js.map +1 -1
  7. package/cjs/core/table-plugins.js +1 -2
  8. package/cjs/core/table-plugins.js.map +1 -1
  9. package/cjs/formula/formula-engine.d.ts +12 -1
  10. package/cjs/formula/formula-engine.js +281 -28
  11. package/cjs/formula/formula-engine.js.map +1 -1
  12. package/cjs/index.d.ts +1 -1
  13. package/cjs/index.js +1 -1
  14. package/cjs/index.js.map +1 -1
  15. package/cjs/managers/formula-manager.d.ts +2 -0
  16. package/cjs/managers/formula-manager.js +29 -0
  17. package/cjs/managers/formula-manager.js.map +1 -1
  18. package/cjs/ts-types/index.d.ts +2 -2
  19. package/cjs/ts-types/index.js.map +1 -1
  20. package/dist/vtable-sheet.js +771 -158
  21. package/dist/vtable-sheet.min.js +1 -1
  22. package/es/components/vtable-sheet.d.ts +2 -2
  23. package/es/components/vtable-sheet.js +29 -3
  24. package/es/components/vtable-sheet.js.map +1 -1
  25. package/es/core/WorkSheet.d.ts +3 -0
  26. package/es/core/WorkSheet.js +22 -3
  27. package/es/core/WorkSheet.js.map +1 -1
  28. package/es/core/table-plugins.js +1 -2
  29. package/es/core/table-plugins.js.map +1 -1
  30. package/es/formula/formula-engine.d.ts +12 -1
  31. package/es/formula/formula-engine.js +281 -28
  32. package/es/formula/formula-engine.js.map +1 -1
  33. package/es/index.d.ts +1 -1
  34. package/es/index.js +1 -1
  35. package/es/index.js.map +1 -1
  36. package/es/managers/formula-manager.d.ts +2 -0
  37. package/es/managers/formula-manager.js +29 -0
  38. package/es/managers/formula-manager.js.map +1 -1
  39. package/es/ts-types/index.d.ts +2 -2
  40. package/es/ts-types/index.js.map +1 -1
  41. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/table-plugins.ts"],"names":[],"mappings":";;;AACA,6DAWkC;AAWlC,6CAA2C;AAO3C,SAAgB,eAAe,CAC7B,WAA0B,EAC1B,OAA6B;;IAE7B,MAAM,OAAO,GAAmC,EAAE,CAAC;IAEnD,MAAM,eAAe,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,mBAAmB,0CAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACxF,MAAM,cAAc,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,mBAAmB,0CAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACxF,IAAI,CAAC,CAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,KAAK,6BAAY,CAAC,CAAA,EAAE;QACpE,MAAM,iBAAiB,GAAG,MAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,KAAK,6BAAY,CAAC,0CACpF,aAA8B,CAAC;QACnC,MAAM,YAAY,GAAG,kBAAkB,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAC;QACxE,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;KAC5B;IACD,IAAI,CAAC,CAAA,eAAe,aAAf,eAAe,uBAAf,eAAe,CAAE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,KAAK,mCAAkB,CAAC,CAAA,EAAE;QAC1E,MAAM,iBAAiB,GAAG,MAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE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AG,CAAC,KAAe,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,CAAC,WAAW,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;IACpD,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,EAAE;QACzG,kBAAkB,EAAE,KAAK;QACzB,mBAAmB,EAAE,KAAK;KAC3B,CAAC,CAAC;IACH,KAAK,CAAC,UAAU,CAAC,eAAe,EAAE,CAAC;AACrC,CAAC","file":"table-plugins.js","sourcesContent":["import type * as VTable from '@visactor/vtable';\nimport {\n FilterPlugin,\n AddRowColumnPlugin,\n TableSeriesNumber,\n HighlightHeaderWhenSelectCellPlugin,\n ContextMenuPlugin,\n ExcelEditCellKeyboardPlugin,\n AutoFillPlugin,\n DEFAULT_HEADER_MENU_ITEMS,\n DEFAULT_BODY_MENU_ITEMS,\n DEFAULT_COLUMN_SERIES_MENU_ITEMS\n} from '@visactor/vtable-plugins';\nimport type {\n FilterOptions,\n MenuItemOrSeparator,\n MenuClickEventArgs,\n AddRowColumnOptions,\n TableSeriesNumberOptions,\n IHighlightHeaderWhenSelectCellPluginOptions,\n ContextMenuOptions\n} from '@visactor/vtable-plugins';\nimport type { ISheetDefine, IColumnDefine, IVTableSheetOptions } from '../ts-types';\nimport { isValid } from '@visactor/vutils';\n\n/**\n * 获取表格插件列表\n * @param sheetDefine Sheet配置定义\n * @returns 插件数组\n */\nexport function getTablePlugins(\n sheetDefine?: ISheetDefine,\n options?: IVTableSheetOptions\n): VTable.plugins.IVTablePlugin[] {\n const plugins: VTable.plugins.IVTablePlugin[] = [];\n // 结合options.VTablePluginModules,来判断是否禁用插件\n const disabledPlugins = options?.VTablePluginModules?.filter(module => module.disabled);\n const enabledPlugins = options?.VTablePluginModules?.filter(module => !module.disabled);\n if (!disabledPlugins?.some(module => module.module === FilterPlugin)) {\n const userPluginOptions = enabledPlugins?.find(module => module.module === FilterPlugin)\n ?.moduleOptions as FilterOptions;\n const filterPlugin = createFilterPlugin(sheetDefine, userPluginOptions);\n plugins.push(filterPlugin);\n }\n if (!disabledPlugins?.some(module => module.module === AddRowColumnPlugin)) {\n const userPluginOptions = enabledPlugins?.find(module => module.module === AddRowColumnPlugin)\n ?.moduleOptions as AddRowColumnOptions;\n const addRowColumnPlugin = new AddRowColumnPlugin({\n addRowCallback: (row: number, tableInstance: VTable.ListTable) => {\n tableInstance.addRecord([], row - tableInstance.columnHeaderLevelCount);\n },\n ...userPluginOptions\n });\n plugins.push(addRowColumnPlugin);\n }\n if (!disabledPlugins?.some(module => module.module === TableSeriesNumber)) {\n const userPluginOptions = enabledPlugins?.find(module => module.module === TableSeriesNumber)\n ?.moduleOptions as TableSeriesNumberOptions;\n const tableSeriesNumberPlugin = new TableSeriesNumber({\n rowCount: sheetDefine?.rowCount || 100,\n colCount: sheetDefine?.columnCount || 100,\n rowSeriesNumberWidth: 30,\n colSeriesNumberHeight: 30,\n rowSeriesNumberCellStyle:\n sheetDefine?.theme?.rowSeriesNumberCellStyle || options?.theme?.rowSeriesNumberCellStyle,\n colSeriesNumberCellStyle:\n sheetDefine?.theme?.colSeriesNumberCellStyle || options?.theme?.colSeriesNumberCellStyle,\n ...userPluginOptions\n });\n plugins.push(tableSeriesNumberPlugin);\n }\n // 这个插件有个bug 先不启用 #4447\n // if (!disabledPlugins?.some(module => module.module === HighlightHeaderWhenSelectCellPlugin)) {\n // const userPluginOptions = enabledPlugins?.find(module => module.module === HighlightHeaderWhenSelectCellPlugin)\n // ?.moduleOptions as IHighlightHeaderWhenSelectCellPluginOptions;\n // const highlightHeaderWhenSelectCellPlugin = new HighlightHeaderWhenSelectCellPlugin({\n // colHighlight: true,\n // rowHighlight: true,\n // ...userPluginOptions\n // });\n // plugins.push(highlightHeaderWhenSelectCellPlugin); // 这个插件有个bug 先不启用 #4447\n // }\n if (!disabledPlugins?.some(module => module.module === ContextMenuPlugin)) {\n const userPluginOptions = enabledPlugins?.find(module => module.module === ContextMenuPlugin)?.moduleOptions;\n const contextMenuPlugin = createContextMenuItems(sheetDefine, userPluginOptions);\n plugins.push(contextMenuPlugin);\n }\n if (!disabledPlugins?.some(module => module.module === ExcelEditCellKeyboardPlugin)) {\n const userPluginOptions = enabledPlugins?.find(\n module => module.module === ExcelEditCellKeyboardPlugin\n )?.moduleOptions;\n const excelEditCellKeyboardPlugin = new ExcelEditCellKeyboardPlugin(userPluginOptions);\n plugins.push(excelEditCellKeyboardPlugin);\n }\n if (!disabledPlugins?.some(module => module.module === AutoFillPlugin)) {\n // const userPluginOptions = enabledPlugins?.find(\n // module => module.module === VTablePlugins.AutoFillPlugin\n // )?.moduleOptions;\n const autoFillPlugin = new AutoFillPlugin();\n plugins.push(autoFillPlugin);\n }\n if (options?.VTablePluginModules) {\n options.VTablePluginModules.forEach(\n (module: { module: new (options: any) => VTable.plugins.IVTablePlugin; moduleOptions: any }) => {\n if (typeof module.module === 'function') {\n // 检查是否为构造函数\n plugins.push(new module.module(module.moduleOptions));\n } else {\n throw new Error(`Invalid plugin: ${module.module}`);\n }\n }\n );\n }\n return plugins;\n}\n\n/**\n * 创建筛选插件(如果需要)\n * @param sheetDefine Sheet配置\n * @returns 筛选插件实例或null\n */\nfunction createFilterPlugin(sheetDefine?: ISheetDefine, userPluginOptions?: FilterOptions): FilterPlugin | null {\n // // 对象配置\n // if (typeof sheetDefine.filter === 'object') {\n // return new VTablePlugins.FilterPlugin({\n // filterIcon: sheetDefine.filter.filterIcon,\n // filteringIcon: sheetDefine.filter.filteringIcon,\n // enableFilter: createColumnFilterChecker(sheetDefine),\n // filterModes: sheetDefine.filter.filterModes\n // });\n // }\n return new FilterPlugin({\n enableFilter: createColumnFilterChecker(sheetDefine),\n ...userPluginOptions\n });\n}\n\n/**\n * 创建列级别筛选检查函数\n * @param sheetDefine Sheet配置\n * @returns 筛选检查函数\n */\nfunction createColumnFilterChecker(sheetDefine: ISheetDefine) {\n return (columnIndex: number, column: VTable.TYPES.ColumnDefine): boolean => {\n // 由于在 vtable-sheet,把列索引作为列的唯一标识 field,因此这里直接使用列索引\n if (columnIndex < 0 || !sheetDefine.columns || columnIndex >= sheetDefine.columns.length) {\n return false; // 默认启用,保持向后兼容\n }\n\n // 获取列定义配置\n const columnDefine = sheetDefine.columns[columnIndex] as IColumnDefine;\n const filter = !!(columnDefine?.filter ?? sheetDefine.filter);\n // 明确禁用检查\n return filter;\n };\n}\n\nfunction createContextMenuItems(sheetDefine: ISheetDefine, userPluginOptions?: ContextMenuOptions) {\n return new ContextMenuPlugin({\n headerCellMenuItems: [\n ...DEFAULT_HEADER_MENU_ITEMS,\n {\n text: '设置筛选器',\n menuKey: 'set_filter'\n },\n {\n text: '取消筛选器',\n menuKey: 'cancel_filter'\n },\n {\n text: '首行表头',\n menuKey: 'enable_first_row_as_header'\n },\n {\n text: '取消表头',\n menuKey: 'disable_first_row_as_header'\n }\n ],\n bodyCellMenuItems: [\n ...DEFAULT_BODY_MENU_ITEMS,\n {\n text: '启用首行表头',\n menuKey: 'enable_first_row_as_header'\n }\n ],\n columnSeriesNumberMenuItems: [\n ...DEFAULT_COLUMN_SERIES_MENU_ITEMS,\n {\n text: '首行表头',\n menuKey: 'enable_first_row_as_header'\n },\n {\n text: '取消表头',\n menuKey: 'disable_first_row_as_header'\n }\n ],\n beforeShowAdjustMenuItems: (\n menuItems: MenuItemOrSeparator[],\n table: VTable.ListTable,\n col: number,\n row: number\n ) => {\n let isColumnSeriesNumber = false;\n let isHeaderCell = false;\n let isBodyCell = false;\n\n if (!isValid(row)) {\n isColumnSeriesNumber = true;\n }\n if (isValid(col) && isValid(row)) {\n if (table.isHeader(col, row)) {\n isHeaderCell = true;\n } else {\n isBodyCell = true;\n }\n }\n if (isHeaderCell) {\n const column = table.options.columns[col] as IColumnDefine;\n if (column.filter ?? sheetDefine?.filter) {\n menuItems = menuItems.filter(item => typeof item === 'string' || item.menuKey !== 'set_filter');\n } else {\n menuItems = menuItems.filter(item => typeof item === 'string' || item.menuKey !== 'cancel_filter');\n }\n }\n\n if (isHeaderCell) {\n menuItems = menuItems.filter(item => typeof item === 'string' || item.menuKey !== 'enable_first_row_as_header');\n } else if (isBodyCell) {\n if (row === 0) {\n menuItems = menuItems.filter(\n item => typeof item === 'string' || item.menuKey !== 'disable_first_row_as_header'\n );\n } else {\n menuItems = menuItems.filter(\n item => typeof item === 'string' || item.menuKey !== 'enable_first_row_as_header'\n );\n }\n } else if (isColumnSeriesNumber) {\n if (table.isHeader(col, 0)) {\n menuItems = menuItems.filter(\n item => typeof item === 'string' || item.menuKey !== 'enable_first_row_as_header'\n );\n } else {\n menuItems = menuItems.filter(\n item => typeof item === 'string' || item.menuKey !== 'disable_first_row_as_header'\n );\n }\n }\n return menuItems;\n },\n menuClickCallback: {\n set_filter: (args: MenuClickEventArgs, table: VTable.ListTable) => {\n // 更新 sheetDefine 配置\n sheetDefine.columns[args.colIndex].filter = true;\n\n // 创建新的 options 对象,确保配置变化被正确传递\n const newOptions = {\n ...table.options,\n columns: table.options.columns.map((col: VTable.ColumnDefine, index: number) => {\n if (index === args.colIndex) {\n return { ...col, filter: true };\n }\n return col;\n })\n };\n // 更新表格配置\n table.updateOption(newOptions, { clearColWidthCache: false, clearRowHeightCache: false });\n },\n cancel_filter: (args: MenuClickEventArgs, table: VTable.ListTable) => {\n // 更新 sheetDefine 配置\n sheetDefine.columns[args.colIndex].filter = false;\n\n // 创建新的 options 对象,确保配置变化被正确传递\n const newOptions = {\n ...table.options,\n columns: table.options.columns.map((col: VTable.ColumnDefine, index: number) => {\n if (index === args.colIndex) {\n return { ...col, filter: false };\n }\n return col;\n })\n };\n\n // 更新表格配置\n table.updateOption(newOptions, { clearColWidthCache: false, clearRowHeightCache: false });\n },\n enable_first_row_as_header: (args: MenuClickEventArgs, table: VTable.ListTable) => {\n handleEnableFirstRowAsHeader(table);\n },\n disable_first_row_as_header: (args: MenuClickEventArgs, table: VTable.ListTable) => {\n handleDisableFirstRowAsHeader(table);\n }\n },\n ...userPluginOptions\n });\n}\n\n/**\n * 处理启用第一行作为表头\n */\nfunction handleEnableFirstRowAsHeader(table: VTable.ListTable): void {\n // 获取第一行数据\n const firstRecord = table.records[0] as string[];\n // 获取剩余数据\n const new_records = table.records.slice(1);\n //获取当前column\n const columns = table.columns;\n // 设置第一行为表头\n firstRecord.forEach((item, index) => {\n columns[index].title = item;\n });\n table.updateOption(Object.assign({}, table.options, { records: new_records, columns, showHeader: true }), {\n clearColWidthCache: false,\n clearRowHeightCache: false\n });\n // 更新渲染\n table.scenegraph.updateNextFrame();\n}\n\n/**\n * 处理禁用第一行作为表头\n */\nfunction handleDisableFirstRowAsHeader(table: VTable.ListTable): void {\n const columns = table.columns;\n const firstRecord: (string | number)[] = [];\n columns.forEach((col, index) => {\n firstRecord.push(col.title as string);\n });\n //像records中添加第一行\n const new_records = [firstRecord, ...table.records];\n table.updateOption(Object.assign({}, table.options, { records: new_records, columns, showHeader: false }), {\n clearColWidthCache: false,\n clearRowHeightCache: false\n });\n table.scenegraph.updateNextFrame();\n}\n"]}
1
+ {"version":3,"sources":["../src/core/table-plugins.ts"],"names":[],"mappings":";;;AACA,6DAWkC;AAWlC,6CAA2C;AAO3C,SAAgB,eAAe,CAC7B,WAA0B,EAC1B,OAA6B;;IAE7B,MAAM,OAAO,GAAmC,EAAE,CAAC;IAEnD,MAAM,eAAe,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,mBAAmB,0CAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACxF,MAAM,cAAc,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,mBAAmB,0CAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACxF,IAAI,CAAC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E9B,WAAW,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QAClC,OAAO,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC;IAC9B,CAAC,CAAC,CAAC;IACH,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,EAAE;QACxG,kBAAkB,EAAE,KAAK;QACzB,mBAAmB,EAAE,KAAK;KAC3B,CAAC,CAAC;IAEH,KAAK,CAAC,UAAU,CAAC,eAAe,EAAE,CAAC;AACrC,CAAC;AAKD,SAAS,6BAA6B,CAAC,KAAuB;IAC5D,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;IAC9B,MAAM,WAAW,GAAwB,EAAE,CAAC;IAC5C,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;QAC7B,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,KAAe,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,CAAC,WAAW,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;IACpD,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,EAAE;QACzG,kBAAkB,EAAE,KAAK;QACzB,mBAAmB,EAAE,KAAK;KAC3B,CAAC,CAAC;IACH,KAAK,CAAC,UAAU,CAAC,eAAe,EAAE,CAAC;AACrC,CAAC","file":"table-plugins.js","sourcesContent":["import type * as VTable from '@visactor/vtable';\nimport {\n FilterPlugin,\n AddRowColumnPlugin,\n TableSeriesNumber,\n HighlightHeaderWhenSelectCellPlugin,\n ContextMenuPlugin,\n ExcelEditCellKeyboardPlugin,\n AutoFillPlugin,\n DEFAULT_HEADER_MENU_ITEMS,\n DEFAULT_BODY_MENU_ITEMS,\n DEFAULT_COLUMN_SERIES_MENU_ITEMS\n} from '@visactor/vtable-plugins';\nimport type {\n FilterOptions,\n MenuItemOrSeparator,\n MenuClickEventArgs,\n AddRowColumnOptions,\n TableSeriesNumberOptions,\n IHighlightHeaderWhenSelectCellPluginOptions,\n ContextMenuOptions\n} from '@visactor/vtable-plugins';\nimport type { ISheetDefine, IColumnDefine, IVTableSheetOptions } from '../ts-types';\nimport { isValid } from '@visactor/vutils';\n\n/**\n * 获取表格插件列表\n * @param sheetDefine Sheet配置定义\n * @returns 插件数组\n */\nexport function getTablePlugins(\n sheetDefine?: ISheetDefine,\n options?: IVTableSheetOptions\n): VTable.plugins.IVTablePlugin[] {\n const plugins: VTable.plugins.IVTablePlugin[] = [];\n // 结合options.VTablePluginModules,来判断是否禁用插件\n const disabledPlugins = options?.VTablePluginModules?.filter(module => module.disabled);\n const enabledPlugins = options?.VTablePluginModules?.filter(module => !module.disabled);\n if (!disabledPlugins?.some(module => module.module === FilterPlugin)) {\n const userPluginOptions = enabledPlugins?.find(module => module.module === FilterPlugin)\n ?.moduleOptions as FilterOptions;\n const filterPlugin = createFilterPlugin(sheetDefine, userPluginOptions);\n plugins.push(filterPlugin);\n }\n if (!disabledPlugins?.some(module => module.module === AddRowColumnPlugin)) {\n const userPluginOptions = enabledPlugins?.find(module => module.module === AddRowColumnPlugin)\n ?.moduleOptions as AddRowColumnOptions;\n const addRowColumnPlugin = new AddRowColumnPlugin({\n addRowCallback: (row: number, tableInstance: VTable.ListTable) => {\n tableInstance.addRecord([], row - tableInstance.columnHeaderLevelCount);\n },\n ...userPluginOptions\n });\n plugins.push(addRowColumnPlugin);\n }\n if (!disabledPlugins?.some(module => module.module === TableSeriesNumber)) {\n const userPluginOptions = enabledPlugins?.find(module => module.module === TableSeriesNumber)\n ?.moduleOptions as TableSeriesNumberOptions;\n const tableSeriesNumberPlugin = new TableSeriesNumber({\n rowCount: sheetDefine?.rowCount || 100,\n colCount: sheetDefine?.columnCount || 100,\n rowSeriesNumberWidth: 30,\n colSeriesNumberHeight: 30,\n rowSeriesNumberCellStyle:\n sheetDefine?.theme?.rowSeriesNumberCellStyle || options?.theme?.rowSeriesNumberCellStyle,\n colSeriesNumberCellStyle:\n sheetDefine?.theme?.colSeriesNumberCellStyle || options?.theme?.colSeriesNumberCellStyle,\n ...userPluginOptions\n });\n plugins.push(tableSeriesNumberPlugin);\n }\n // 这个插件有个bug 先不启用 #4447\n // if (!disabledPlugins?.some(module => module.module === HighlightHeaderWhenSelectCellPlugin)) {\n // const userPluginOptions = enabledPlugins?.find(module => module.module === HighlightHeaderWhenSelectCellPlugin)\n // ?.moduleOptions as IHighlightHeaderWhenSelectCellPluginOptions;\n // const highlightHeaderWhenSelectCellPlugin = new HighlightHeaderWhenSelectCellPlugin({\n // colHighlight: true,\n // rowHighlight: true,\n // ...userPluginOptions\n // });\n // plugins.push(highlightHeaderWhenSelectCellPlugin); // 这个插件有个bug 先不启用 #4447\n // }\n if (!disabledPlugins?.some(module => module.module === ContextMenuPlugin)) {\n const userPluginOptions = enabledPlugins?.find(module => module.module === ContextMenuPlugin)?.moduleOptions;\n const contextMenuPlugin = createContextMenuItems(sheetDefine, userPluginOptions);\n plugins.push(contextMenuPlugin);\n }\n if (!disabledPlugins?.some(module => module.module === ExcelEditCellKeyboardPlugin)) {\n const userPluginOptions = enabledPlugins?.find(\n module => module.module === ExcelEditCellKeyboardPlugin\n )?.moduleOptions;\n const excelEditCellKeyboardPlugin = new ExcelEditCellKeyboardPlugin(userPluginOptions);\n plugins.push(excelEditCellKeyboardPlugin);\n }\n if (!disabledPlugins?.some(module => module.module === AutoFillPlugin)) {\n // const userPluginOptions = enabledPlugins?.find(\n // module => module.module === VTablePlugins.AutoFillPlugin\n // )?.moduleOptions;\n const autoFillPlugin = new AutoFillPlugin();\n plugins.push(autoFillPlugin);\n }\n if (options?.VTablePluginModules) {\n options.VTablePluginModules.forEach(\n (module: { module: new (options: any) => VTable.plugins.IVTablePlugin; moduleOptions: any }) => {\n if (typeof module?.module === 'function') {\n // 检查是否为构造函数\n plugins.push(new module.module(module.moduleOptions));\n } else {\n console.error(`Invalid plugin: ${module.module}`);\n }\n }\n );\n }\n return plugins;\n}\n\n/**\n * 创建筛选插件(如果需要)\n * @param sheetDefine Sheet配置\n * @returns 筛选插件实例或null\n */\nfunction createFilterPlugin(sheetDefine?: ISheetDefine, userPluginOptions?: FilterOptions): FilterPlugin | null {\n // // 对象配置\n // if (typeof sheetDefine.filter === 'object') {\n // return new VTablePlugins.FilterPlugin({\n // filterIcon: sheetDefine.filter.filterIcon,\n // filteringIcon: sheetDefine.filter.filteringIcon,\n // enableFilter: createColumnFilterChecker(sheetDefine),\n // filterModes: sheetDefine.filter.filterModes\n // });\n // }\n return new FilterPlugin({\n enableFilter: createColumnFilterChecker(sheetDefine),\n ...userPluginOptions\n });\n}\n\n/**\n * 创建列级别筛选检查函数\n * @param sheetDefine Sheet配置\n * @returns 筛选检查函数\n */\nfunction createColumnFilterChecker(sheetDefine: ISheetDefine) {\n return (columnIndex: number, column: VTable.TYPES.ColumnDefine): boolean => {\n // 由于在 vtable-sheet,把列索引作为列的唯一标识 field,因此这里直接使用列索引\n if (columnIndex < 0 || !sheetDefine.columns || columnIndex >= sheetDefine.columns.length) {\n return false; // 默认启用,保持向后兼容\n }\n\n // 获取列定义配置\n const columnDefine = sheetDefine.columns[columnIndex] as IColumnDefine;\n const filter = !!(columnDefine?.filter ?? sheetDefine.filter);\n // 明确禁用检查\n return filter;\n };\n}\n\nfunction createContextMenuItems(sheetDefine: ISheetDefine, userPluginOptions?: ContextMenuOptions) {\n return new ContextMenuPlugin({\n headerCellMenuItems: [\n ...DEFAULT_HEADER_MENU_ITEMS,\n {\n text: '设置筛选器',\n menuKey: 'set_filter'\n },\n {\n text: '取消筛选器',\n menuKey: 'cancel_filter'\n },\n {\n text: '首行表头',\n menuKey: 'enable_first_row_as_header'\n },\n {\n text: '取消表头',\n menuKey: 'disable_first_row_as_header'\n }\n ],\n bodyCellMenuItems: [\n ...DEFAULT_BODY_MENU_ITEMS,\n {\n text: '启用首行表头',\n menuKey: 'enable_first_row_as_header'\n }\n ],\n columnSeriesNumberMenuItems: [\n ...DEFAULT_COLUMN_SERIES_MENU_ITEMS,\n {\n text: '首行表头',\n menuKey: 'enable_first_row_as_header'\n },\n {\n text: '取消表头',\n menuKey: 'disable_first_row_as_header'\n }\n ],\n beforeShowAdjustMenuItems: (\n menuItems: MenuItemOrSeparator[],\n table: VTable.ListTable,\n col: number,\n row: number\n ) => {\n let isColumnSeriesNumber = false;\n let isHeaderCell = false;\n let isBodyCell = false;\n\n if (!isValid(row)) {\n isColumnSeriesNumber = true;\n }\n if (isValid(col) && isValid(row)) {\n if (table.isHeader(col, row)) {\n isHeaderCell = true;\n } else {\n isBodyCell = true;\n }\n }\n if (isHeaderCell) {\n const column = table.options.columns[col] as IColumnDefine;\n if (column.filter ?? sheetDefine?.filter) {\n menuItems = menuItems.filter(item => typeof item === 'string' || item.menuKey !== 'set_filter');\n } else {\n menuItems = menuItems.filter(item => typeof item === 'string' || item.menuKey !== 'cancel_filter');\n }\n }\n\n if (isHeaderCell) {\n menuItems = menuItems.filter(item => typeof item === 'string' || item.menuKey !== 'enable_first_row_as_header');\n } else if (isBodyCell) {\n if (row === 0) {\n menuItems = menuItems.filter(\n item => typeof item === 'string' || item.menuKey !== 'disable_first_row_as_header'\n );\n } else {\n menuItems = menuItems.filter(\n item => typeof item === 'string' || item.menuKey !== 'enable_first_row_as_header'\n );\n }\n } else if (isColumnSeriesNumber) {\n if (table.isHeader(col, 0)) {\n menuItems = menuItems.filter(\n item => typeof item === 'string' || item.menuKey !== 'enable_first_row_as_header'\n );\n } else {\n menuItems = menuItems.filter(\n item => typeof item === 'string' || item.menuKey !== 'disable_first_row_as_header'\n );\n }\n }\n return menuItems;\n },\n menuClickCallback: {\n set_filter: (args: MenuClickEventArgs, table: VTable.ListTable) => {\n // 更新 sheetDefine 配置\n sheetDefine.columns[args.colIndex].filter = true;\n\n // 创建新的 options 对象,确保配置变化被正确传递\n const newOptions = {\n ...table.options,\n columns: table.options.columns.map((col: VTable.ColumnDefine, index: number) => {\n if (index === args.colIndex) {\n return { ...col, filter: true };\n }\n return col;\n })\n };\n // 更新表格配置\n table.updateOption(newOptions, { clearColWidthCache: false, clearRowHeightCache: false });\n },\n cancel_filter: (args: MenuClickEventArgs, table: VTable.ListTable) => {\n // 更新 sheetDefine 配置\n sheetDefine.columns[args.colIndex].filter = false;\n\n // 创建新的 options 对象,确保配置变化被正确传递\n const newOptions = {\n ...table.options,\n columns: table.options.columns.map((col: VTable.ColumnDefine, index: number) => {\n if (index === args.colIndex) {\n return { ...col, filter: false };\n }\n return col;\n })\n };\n\n // 更新表格配置\n table.updateOption(newOptions, { clearColWidthCache: false, clearRowHeightCache: false });\n },\n enable_first_row_as_header: (args: MenuClickEventArgs, table: VTable.ListTable) => {\n handleEnableFirstRowAsHeader(table);\n },\n disable_first_row_as_header: (args: MenuClickEventArgs, table: VTable.ListTable) => {\n handleDisableFirstRowAsHeader(table);\n }\n },\n ...userPluginOptions\n });\n}\n\n/**\n * 处理启用第一行作为表头\n */\nfunction handleEnableFirstRowAsHeader(table: VTable.ListTable): void {\n // 获取第一行数据\n const firstRecord = table.records[0] as string[];\n // 获取剩余数据\n const new_records = table.records.slice(1);\n //获取当前column\n const columns = table.columns;\n // 设置第一行为表头\n firstRecord.forEach((item, index) => {\n columns[index].title = item;\n });\n table.updateOption(Object.assign({}, table.options, { records: new_records, columns, showHeader: true }), {\n clearColWidthCache: false,\n clearRowHeightCache: false\n });\n // 更新渲染\n table.scenegraph.updateNextFrame();\n}\n\n/**\n * 处理禁用第一行作为表头\n */\nfunction handleDisableFirstRowAsHeader(table: VTable.ListTable): void {\n const columns = table.columns;\n const firstRecord: (string | number)[] = [];\n columns.forEach((col, index) => {\n firstRecord.push(col.title as string);\n });\n //像records中添加第一行\n const new_records = [firstRecord, ...table.records];\n table.updateOption(Object.assign({}, table.options, { records: new_records, columns, showHeader: false }), {\n clearColWidthCache: false,\n clearRowHeightCache: false\n });\n table.scenegraph.updateNextFrame();\n}\n"]}
@@ -39,6 +39,8 @@ export declare class FormulaEngine {
39
39
  value: unknown;
40
40
  error?: string;
41
41
  };
42
+ private correctFormulaCase;
43
+ private findOriginalSheetName;
42
44
  private parseExpression;
43
45
  private tryParseComparison;
44
46
  private parseArithmetic;
@@ -69,7 +71,6 @@ export declare class FormulaEngine {
69
71
  private flattenArgsWithRanges;
70
72
  private isTruthy;
71
73
  private evaluateArithmeticWithFunctions;
72
- private evaluateBasicArithmetic;
73
74
  private getCellValueByA1;
74
75
  private getRangeValuesFromExpr;
75
76
  getCellValue(cell: FormulaCell): FormulaResult;
@@ -112,4 +113,14 @@ export declare class FormulaEngine {
112
113
  private indexToColumnLetters;
113
114
  private rangeContainsDeletedCells;
114
115
  private adjustRangeForDeletion;
116
+ adjustFormulaReferencesForColumnMove(sheetKey: string, sourceCol: number, targetCol: number, totalColCount: number, totalRowCount: number): {
117
+ adjustedCells: FormulaCell[];
118
+ movedCells: FormulaCell[];
119
+ };
120
+ private adjustFormulaWithColumnMapping;
121
+ adjustFormulaReferencesForRowMove(sheetKey: string, sourceRow: number, targetRow: number): {
122
+ adjustedCells: FormulaCell[];
123
+ movedCells: FormulaCell[];
124
+ };
125
+ private adjustFormulaWithRowMapping;
115
126
  }
@@ -92,8 +92,9 @@ class FormulaEngine {
92
92
  isNaN(numericValue) || "" === processedValue.trim() || (processedValue = numericValue);
93
93
  }
94
94
  if (sheet[cell.row][cell.col] = processedValue, "string" == typeof processedValue && processedValue.startsWith("=")) {
95
- const cellKey = this.getCellKey(cell);
96
- this.formulaCells.set(cellKey, processedValue), this.updateDependencies(cellKey, processedValue);
95
+ const cellKey = this.getCellKey(cell), correctedFormula = this.correctFormulaCase(processedValue);
96
+ this.formulaCells.set(cellKey, correctedFormula), this.updateDependencies(cellKey, correctedFormula),
97
+ sheet[cell.row][cell.col] = correctedFormula;
97
98
  }
98
99
  this.recalculateDependents(cell);
99
100
  }
@@ -139,7 +140,7 @@ class FormulaEngine {
139
140
  value: formula,
140
141
  error: void 0
141
142
  };
142
- const expression = formula.substring(1).trim();
143
+ const expression = this.correctFormulaCase(formula).substring(1).trim();
143
144
  if (expression.includes("#REF!")) return {
144
145
  value: "#REF!",
145
146
  error: void 0
@@ -152,6 +153,62 @@ class FormulaEngine {
152
153
  };
153
154
  }
154
155
  }
156
+ correctFormulaCase(formula) {
157
+ if (!formula.startsWith("=")) return formula;
158
+ let corrected = "=";
159
+ const expression = formula.substring(1);
160
+ let inQuotes = !1, quoteChar = "", i = 0;
161
+ for (;i < expression.length; ) {
162
+ const char = expression[i];
163
+ if (!('"' !== char && "'" !== char || 0 !== i && "\\" === expression[i - 1])) {
164
+ inQuotes ? char === quoteChar && (inQuotes = !1, quoteChar = "") : (inQuotes = !0,
165
+ quoteChar = char), corrected += char, i++;
166
+ continue;
167
+ }
168
+ if (inQuotes) {
169
+ corrected += char, i++;
170
+ continue;
171
+ }
172
+ const funcMatch = expression.substring(i).match(/^[A-Za-z][A-Za-z0-9]*\s*\(/);
173
+ if (funcMatch) {
174
+ const funcName = funcMatch[0].replace(/\s*\($/, "");
175
+ for (corrected += funcName.toUpperCase() + "(", i += funcName.length + 1; i < expression.length && " " === expression[i]; ) i++;
176
+ continue;
177
+ }
178
+ const sheetCellMatch = expression.substring(i).match(/^[A-Za-z0-9_]+![A-Za-z]+[0-9]+/);
179
+ if (sheetCellMatch) {
180
+ const fullRef = sheetCellMatch[0], [sheetName, cellRef] = fullRef.split("!"), originalSheetName = this.findOriginalSheetName(sheetName), letters = cellRef.replace(/[0-9]/g, ""), numbers = cellRef.replace(/[A-Za-z]/g, "");
181
+ corrected += (originalSheetName || sheetName) + "!" + letters.toUpperCase() + numbers,
182
+ i += fullRef.length;
183
+ continue;
184
+ }
185
+ const sheetRangeMatch = expression.substring(i).match(/^[A-Za-z0-9_]+![A-Za-z]+[0-9]+:[A-Za-z]+[0-9]+/);
186
+ if (sheetRangeMatch) {
187
+ const fullRangeRef = sheetRangeMatch[0], [sheetPart, rangePart] = fullRangeRef.split("!"), [startCell, endCell] = rangePart.split(":"), originalSheetName = this.findOriginalSheetName(sheetPart), startLetters = startCell.replace(/[0-9]/g, ""), startNumbers = startCell.replace(/[A-Za-z]/g, ""), newStartCell = startLetters.toUpperCase() + startNumbers, endLetters = endCell.replace(/[0-9]/g, ""), endNumbers = endCell.replace(/[A-Za-z]/g, "");
188
+ corrected += (originalSheetName || sheetPart) + "!" + newStartCell + ":" + (endLetters.toUpperCase() + endNumbers),
189
+ i += fullRangeRef.length;
190
+ continue;
191
+ }
192
+ const cellMatch = expression.substring(i).match(/^[A-Za-z]+[0-9]+/);
193
+ if (cellMatch) {
194
+ const cellRef = cellMatch[0], letters = cellRef.replace(/[0-9]/g, ""), numbers = cellRef.replace(/[A-Za-z]/g, "");
195
+ corrected += letters.toUpperCase() + numbers, i += cellRef.length;
196
+ continue;
197
+ }
198
+ const rangeMatch = expression.substring(i).match(/^[A-Za-z]+[0-9]+:[A-Za-z]+[0-9]+/);
199
+ if (rangeMatch) {
200
+ const rangeRef = rangeMatch[0], [startCell, endCell] = rangeRef.split(":"), startLetters = startCell.replace(/[0-9]/g, ""), startNumbers = startCell.replace(/[A-Za-z]/g, ""), newStartCell = startLetters.toUpperCase() + startNumbers, endLetters = endCell.replace(/[0-9]/g, ""), endNumbers = endCell.replace(/[A-Za-z]/g, "");
201
+ corrected += newStartCell + ":" + (endLetters.toUpperCase() + endNumbers), i += rangeRef.length;
202
+ } else corrected += char, i++;
203
+ }
204
+ return corrected;
205
+ }
206
+ findOriginalSheetName(sheetName) {
207
+ if (this.sheets.has(sheetName)) return sheetName;
208
+ const lowerSheetName = sheetName.toLowerCase();
209
+ for (const [existingSheetName] of this.sheets.entries()) if (existingSheetName.toLowerCase() === lowerSheetName) return existingSheetName;
210
+ return null;
211
+ }
155
212
  parseExpression(expr) {
156
213
  expr = expr.trim();
157
214
  const functionResult = this.tryParseFunction(expr);
@@ -689,29 +746,6 @@ class FormulaEngine {
689
746
  };
690
747
  }
691
748
  }
692
- evaluateBasicArithmetic(expr) {
693
- try {
694
- if (/[A-Z]+\s*\(/.test(expr)) return {
695
- value: null,
696
- error: "Expression contains function calls"
697
- };
698
- let processedExpr = expr;
699
- const cellRefs = processedExpr.match(/[A-Z]+[0-9]+/g) || [];
700
- for (const cellRef of cellRefs) {
701
- const value = this.getCellValueByA1(cellRef);
702
- processedExpr = processedExpr.replace(cellRef, String(value));
703
- }
704
- return {
705
- value: Function('"use strict"; return (' + processedExpr + ")")(),
706
- error: void 0
707
- };
708
- } catch (error) {
709
- return {
710
- value: null,
711
- error: "Basic arithmetic evaluation failed"
712
- };
713
- }
714
- }
715
749
  getCellValueByA1(a1Notation) {
716
750
  try {
717
751
  let sheetKey = this.activeSheetKey || this.reverseSheets.get(0) || "Sheet1", cellRef = a1Notation;
@@ -1070,7 +1104,8 @@ class FormulaEngine {
1070
1104
  }, deletedCellKey = this.getCellKey(deletedCell);
1071
1105
  deletedCells.add(deletedCellKey);
1072
1106
  }
1073
- for (const [cellKey, formula] of Array.from(this.formulaCells.entries())) {
1107
+ const entries = Array.from(this.formulaCells.entries());
1108
+ for (const [cellKey, formula] of entries) {
1074
1109
  const cell = this.parseCellKey(cellKey);
1075
1110
  if (!cell || cell.sheet !== sheetKey) continue;
1076
1111
  const newCell = Object.assign({}, cell);
@@ -1201,11 +1236,13 @@ class FormulaEngine {
1201
1236
  let newStartCell, newEndCell, newMinRow = minRow, newMaxRow = maxRow, newMinCol = minCol, newMaxCol = maxCol;
1202
1237
  if ("row" === dimension) {
1203
1238
  const deleteEndRow = index + count - 1;
1204
- if (minRow >= index && minRow <= deleteEndRow ? newMinRow = index > 0 ? index - 1 : 0 : minRow > deleteEndRow && (newMinRow = minRow - count,
1239
+ if (minRow >= index && maxRow <= deleteEndRow) return "#REF!";
1240
+ if (minRow >= index && minRow <= deleteEndRow ? newMinRow = index : minRow > deleteEndRow && (newMinRow = minRow - count,
1205
1241
  newMinRow < 0 && (newMinRow = 0)), maxRow >= index && maxRow <= deleteEndRow ? newMaxRow = index > 0 ? index - 1 : 0 : maxRow > deleteEndRow && (newMaxRow = maxRow - count,
1206
1242
  newMaxRow < 0 && (newMaxRow = 0)), newMinRow > newMaxRow) return "#REF!";
1207
1243
  } else if ("column" === dimension) {
1208
1244
  const deleteEndCol = index + count - 1;
1245
+ if (minCol >= index && maxCol <= deleteEndCol) return "#REF!";
1209
1246
  if (minCol >= index && minCol <= deleteEndCol ? newMinCol = index > 0 ? index - 1 : 0 : minCol > deleteEndCol && (newMinCol = minCol - count,
1210
1247
  newMinCol < 0 && (newMinCol = 0)), maxCol >= index && maxCol <= deleteEndCol ? newMaxCol = index > 0 ? index - 1 : 0 : maxCol > deleteEndCol && (newMaxCol = maxCol - count,
1211
1248
  newMaxCol < 0 && (newMaxCol = 0)), newMinCol > newMaxCol) return "#REF!";
@@ -1219,6 +1256,222 @@ class FormulaEngine {
1219
1256
  return "#REF!";
1220
1257
  }
1221
1258
  }
1259
+ adjustFormulaReferencesForColumnMove(sheetKey, sourceCol, targetCol, totalColCount, totalRowCount) {
1260
+ try {
1261
+ const adjustedFormulas = [], movedFormulas = [], isMovingForward = targetCol > sourceCol, columnMapping = new Map;
1262
+ if (isMovingForward) {
1263
+ for (let col = sourceCol + 1; col <= targetCol; col++) columnMapping.set(col, col - 1);
1264
+ columnMapping.set(sourceCol, targetCol);
1265
+ } else {
1266
+ for (let col = targetCol; col < sourceCol; col++) columnMapping.set(col, col + 1);
1267
+ columnMapping.set(sourceCol, targetCol);
1268
+ }
1269
+ for (const [cellKey, formula] of Array.from(this.formulaCells.entries())) {
1270
+ const cell = this.parseCellKey(cellKey);
1271
+ if (!cell || cell.sheet !== sheetKey) continue;
1272
+ let needsCellMove = !1;
1273
+ const newCellLocation = Object.assign({}, cell);
1274
+ if (columnMapping.has(cell.col)) {
1275
+ const mappedCol = columnMapping.get(cell.col);
1276
+ void 0 !== mappedCol && (newCellLocation.col = mappedCol, needsCellMove = !0);
1277
+ }
1278
+ const newFormula = this.adjustFormulaWithColumnMapping(formula, columnMapping);
1279
+ (needsCellMove || newFormula !== formula) && (needsCellMove ? (movedFormulas.push({
1280
+ oldCellKey: cellKey,
1281
+ newCell: newCellLocation,
1282
+ formula: newFormula
1283
+ }), this.formulaCells.delete(cellKey), this.clearDependencies(cellKey)) : (adjustedFormulas.push({
1284
+ cell: cell,
1285
+ oldFormula: formula,
1286
+ newFormula: newFormula
1287
+ }), this.clearDependencies(cellKey)));
1288
+ }
1289
+ for (const {newCell: newCell, formula: formula} of movedFormulas) {
1290
+ const newCellKey = this.getCellKey(newCell);
1291
+ this.formulaCells.set(newCellKey, formula), this.updateDependencies(newCellKey, formula),
1292
+ this.setCellContentWithoutDependencyUpdate(newCell, formula);
1293
+ }
1294
+ for (const {cell: cell, newFormula: newFormula} of adjustedFormulas) {
1295
+ const cellKey = this.getCellKey(cell);
1296
+ this.formulaCells.set(cellKey, newFormula), this.updateDependencies(cellKey, newFormula),
1297
+ this.setCellContentWithoutDependencyUpdate(cell, newFormula);
1298
+ }
1299
+ const adjustedCells = adjustedFormulas.map((item => item.cell));
1300
+ return {
1301
+ adjustedCells: adjustedCells,
1302
+ movedCells: movedFormulas.map((item => item.newCell))
1303
+ };
1304
+ } catch (error) {
1305
+ return {
1306
+ adjustedCells: [],
1307
+ movedCells: []
1308
+ };
1309
+ }
1310
+ }
1311
+ adjustFormulaWithColumnMapping(formula, columnMapping) {
1312
+ if (!formula || !formula.startsWith("=")) return formula;
1313
+ let expression = formula.substring(1);
1314
+ const rangeRegex = /([A-Z]+)([0-9]+):([A-Z]+)([0-9]+)/g;
1315
+ let match;
1316
+ const rangeReplacements = [], processedRanges = [];
1317
+ for (;null !== (match = rangeRegex.exec(expression)); ) {
1318
+ const fullMatch = match[0], startCol = match[1], startRow = match[2], endCol = match[3], endRow = match[4], startColIndex = this.columnLettersToIndex(startCol), endColIndex = this.columnLettersToIndex(endCol);
1319
+ let newStartCol = startColIndex, newEndCol = endColIndex;
1320
+ if (columnMapping.has(startColIndex)) {
1321
+ const mappedStartCol = columnMapping.get(startColIndex);
1322
+ void 0 !== mappedStartCol && (newStartCol = mappedStartCol);
1323
+ }
1324
+ if (columnMapping.has(endColIndex)) {
1325
+ const mappedEndCol = columnMapping.get(endColIndex);
1326
+ void 0 !== mappedEndCol && (newEndCol = mappedEndCol);
1327
+ }
1328
+ newStartCol > newEndCol && ([newStartCol, newEndCol] = [ newEndCol, newStartCol ]);
1329
+ const replacement = `${this.indexToColumnLetters(newStartCol)}${startRow}:${this.indexToColumnLetters(newEndCol)}${endRow}`;
1330
+ rangeReplacements.push({
1331
+ start: match.index,
1332
+ end: match.index + fullMatch.length,
1333
+ replacement: replacement
1334
+ }), processedRanges.push({
1335
+ start: match.index,
1336
+ end: match.index + fullMatch.length
1337
+ });
1338
+ }
1339
+ for (let i = rangeReplacements.length - 1; i >= 0; i--) {
1340
+ const {start: start, end: end, replacement: replacement} = rangeReplacements[i];
1341
+ expression = expression.substring(0, start) + replacement + expression.substring(end);
1342
+ }
1343
+ const cellRegex = /([A-Z]+)([0-9]+)/g, cellReplacements = [];
1344
+ for (;null !== (match = cellRegex.exec(expression)); ) {
1345
+ const fullMatch = match[0], colLetters = match[1], row = match[2], colIndex = this.columnLettersToIndex(colLetters), matchIndex = match.index;
1346
+ if (!processedRanges.some((range => matchIndex >= range.start && matchIndex < range.end)) && columnMapping.has(colIndex)) {
1347
+ const newColIndex = columnMapping.get(colIndex);
1348
+ if (void 0 !== newColIndex) {
1349
+ const replacement = `${this.indexToColumnLetters(newColIndex)}${row}`;
1350
+ cellReplacements.push({
1351
+ start: match.index,
1352
+ end: match.index + fullMatch.length,
1353
+ replacement: replacement
1354
+ });
1355
+ }
1356
+ }
1357
+ }
1358
+ for (let i = cellReplacements.length - 1; i >= 0; i--) {
1359
+ const {start: start, end: end, replacement: replacement} = cellReplacements[i];
1360
+ expression = expression.substring(0, start) + replacement + expression.substring(end);
1361
+ }
1362
+ return "=" + expression;
1363
+ }
1364
+ adjustFormulaReferencesForRowMove(sheetKey, sourceRow, targetRow) {
1365
+ try {
1366
+ if (sourceRow < 0 || targetRow < 0) return {
1367
+ adjustedCells: [],
1368
+ movedCells: []
1369
+ };
1370
+ const adjustedFormulas = [], movedFormulas = [], isMovingForward = targetRow > sourceRow, rowMapping = new Map;
1371
+ if (isMovingForward) {
1372
+ for (let row = sourceRow + 1; row <= targetRow; row++) rowMapping.set(row, row - 1);
1373
+ rowMapping.set(sourceRow, targetRow);
1374
+ } else {
1375
+ for (let row = targetRow; row < sourceRow; row++) rowMapping.set(row, row + 1);
1376
+ rowMapping.set(sourceRow, targetRow);
1377
+ }
1378
+ for (const [cellKey, formula] of Array.from(this.formulaCells.entries())) {
1379
+ const cell = this.parseCellKey(cellKey);
1380
+ if (!cell || cell.sheet !== sheetKey) continue;
1381
+ let needsCellMove = !1;
1382
+ const newCellLocation = Object.assign({}, cell);
1383
+ if (rowMapping.has(cell.row)) {
1384
+ const mappedRow = rowMapping.get(cell.row);
1385
+ void 0 !== mappedRow && mappedRow !== cell.row && (newCellLocation.row = mappedRow,
1386
+ needsCellMove = !0);
1387
+ }
1388
+ const newFormula = this.adjustFormulaWithRowMapping(formula, rowMapping);
1389
+ (needsCellMove || newFormula !== formula) && (needsCellMove ? (movedFormulas.push({
1390
+ oldCellKey: cellKey,
1391
+ newCell: newCellLocation,
1392
+ formula: newFormula
1393
+ }), this.formulaCells.delete(cellKey), this.clearDependencies(cellKey)) : (adjustedFormulas.push({
1394
+ cell: cell,
1395
+ oldFormula: formula,
1396
+ newFormula: newFormula
1397
+ }), this.clearDependencies(cellKey)));
1398
+ }
1399
+ for (const {newCell: newCell, formula: formula} of movedFormulas) {
1400
+ const newCellKey = this.getCellKey(newCell);
1401
+ this.formulaCells.set(newCellKey, formula), this.updateDependencies(newCellKey, formula),
1402
+ this.setCellContentWithoutDependencyUpdate(newCell, formula);
1403
+ }
1404
+ for (const {cell: cell, newFormula: newFormula} of adjustedFormulas) {
1405
+ const cellKey = this.getCellKey(cell);
1406
+ this.formulaCells.set(cellKey, newFormula), this.updateDependencies(cellKey, newFormula),
1407
+ this.setCellContentWithoutDependencyUpdate(cell, newFormula);
1408
+ }
1409
+ const adjustedCells = adjustedFormulas.map((item => item.cell));
1410
+ return {
1411
+ adjustedCells: adjustedCells,
1412
+ movedCells: movedFormulas.map((item => item.newCell))
1413
+ };
1414
+ } catch (error) {
1415
+ return {
1416
+ adjustedCells: [],
1417
+ movedCells: []
1418
+ };
1419
+ }
1420
+ }
1421
+ adjustFormulaWithRowMapping(formula, rowMapping) {
1422
+ if (!formula || !formula.startsWith("=")) return formula;
1423
+ let expression = formula.substring(1);
1424
+ const rangeRegex = /([A-Z]+)([0-9]+):([A-Z]+)([0-9]+)/g;
1425
+ let match;
1426
+ const rangeReplacements = [], processedRanges = [];
1427
+ for (;null !== (match = rangeRegex.exec(expression)); ) {
1428
+ const fullMatch = match[0], startCol = match[1], startRow = match[2], endCol = match[3], endRow = match[4], startRowIndex = parseInt(startRow, 10) - 1, endRowIndex = parseInt(endRow, 10) - 1;
1429
+ let newStartRow = startRowIndex, newEndRow = endRowIndex;
1430
+ if (rowMapping.has(startRowIndex)) {
1431
+ const mappedStartRow = rowMapping.get(startRowIndex);
1432
+ void 0 !== mappedStartRow && (newStartRow = mappedStartRow);
1433
+ }
1434
+ if (rowMapping.has(endRowIndex)) {
1435
+ const mappedEndRow = rowMapping.get(endRowIndex);
1436
+ void 0 !== mappedEndRow && (newEndRow = mappedEndRow);
1437
+ }
1438
+ if (newStartRow !== startRowIndex || newEndRow !== endRowIndex) {
1439
+ const replacement = `${startCol}${newStartRow + 1}:${endCol}${newEndRow + 1}`;
1440
+ rangeReplacements.push({
1441
+ start: match.index,
1442
+ end: match.index + fullMatch.length,
1443
+ replacement: replacement
1444
+ }), processedRanges.push({
1445
+ start: match.index,
1446
+ end: match.index + fullMatch.length
1447
+ });
1448
+ }
1449
+ }
1450
+ for (let i = rangeReplacements.length - 1; i >= 0; i--) {
1451
+ const {start: start, end: end, replacement: replacement} = rangeReplacements[i];
1452
+ expression = expression.substring(0, start) + replacement + expression.substring(end);
1453
+ }
1454
+ const cellRegex = /([A-Z]+)([0-9]+)/g, cellReplacements = [];
1455
+ for (;null !== (match = cellRegex.exec(expression)); ) {
1456
+ const fullMatch = match[0], colLetters = match[1], row = match[2], rowIndex = parseInt(row, 10) - 1, matchIndex = match.index;
1457
+ if (!processedRanges.some((range => matchIndex >= range.start && matchIndex < range.end)) && rowMapping.has(rowIndex)) {
1458
+ const newRowIndex = rowMapping.get(rowIndex);
1459
+ if (void 0 !== newRowIndex) {
1460
+ const replacement = `${colLetters}${newRowIndex + 1}`;
1461
+ cellReplacements.push({
1462
+ start: match.index,
1463
+ end: match.index + fullMatch.length,
1464
+ replacement: replacement
1465
+ });
1466
+ }
1467
+ }
1468
+ }
1469
+ for (let i = cellReplacements.length - 1; i >= 0; i--) {
1470
+ const {start: start, end: end, replacement: replacement} = cellReplacements[i];
1471
+ expression = expression.substring(0, start) + replacement + expression.substring(end);
1472
+ }
1473
+ return "=" + expression;
1474
+ }
1222
1475
  }
1223
1476
 
1224
1477
  exports.FormulaEngine = FormulaEngine;