@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,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EAEjB,iBAAiB,EACjB,2BAA2B,EAC3B,cAAc,EACd,yBAAyB,EACzB,uBAAuB,EACvB,gCAAgC,EACjC,MAAM,0BAA0B,CAAC;AAWlC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAO3C,MAAM,UAAU,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,YAAY,CAAC,CAAA,EAAE;QACpE,MAAM,iBAAiB,GAAG,MAAA,cAAc,aAAd,cAAc,uBAAd,cAAc,CAAE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,KAAK,YAAY,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,aA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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 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,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EAEjB,iBAAiB,EACjB,2BAA2B,EAC3B,cAAc,EACd,yBAAyB,EACzB,uBAAuB,EACvB,gCAAgC,EACjC,MAAM,0BAA0B,CAAC;AAWlC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAO3C,MAAM,UAAU,eAAe,CAC7B,WAA0B,EAC1B,OAA6B;;IAE7B,MAAM,OAAO,GAAmC,EAA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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
  }
@@ -86,8 +86,9 @@ export class FormulaEngine {
86
86
  isNaN(numericValue) || "" === processedValue.trim() || (processedValue = numericValue);
87
87
  }
88
88
  if (sheet[cell.row][cell.col] = processedValue, "string" == typeof processedValue && processedValue.startsWith("=")) {
89
- const cellKey = this.getCellKey(cell);
90
- this.formulaCells.set(cellKey, processedValue), this.updateDependencies(cellKey, processedValue);
89
+ const cellKey = this.getCellKey(cell), correctedFormula = this.correctFormulaCase(processedValue);
90
+ this.formulaCells.set(cellKey, correctedFormula), this.updateDependencies(cellKey, correctedFormula),
91
+ sheet[cell.row][cell.col] = correctedFormula;
91
92
  }
92
93
  this.recalculateDependents(cell);
93
94
  }
@@ -133,7 +134,7 @@ export class FormulaEngine {
133
134
  value: formula,
134
135
  error: void 0
135
136
  };
136
- const expression = formula.substring(1).trim();
137
+ const expression = this.correctFormulaCase(formula).substring(1).trim();
137
138
  if (expression.includes("#REF!")) return {
138
139
  value: "#REF!",
139
140
  error: void 0
@@ -146,6 +147,62 @@ export class FormulaEngine {
146
147
  };
147
148
  }
148
149
  }
150
+ correctFormulaCase(formula) {
151
+ if (!formula.startsWith("=")) return formula;
152
+ let corrected = "=";
153
+ const expression = formula.substring(1);
154
+ let inQuotes = !1, quoteChar = "", i = 0;
155
+ for (;i < expression.length; ) {
156
+ const char = expression[i];
157
+ if (!('"' !== char && "'" !== char || 0 !== i && "\\" === expression[i - 1])) {
158
+ inQuotes ? char === quoteChar && (inQuotes = !1, quoteChar = "") : (inQuotes = !0,
159
+ quoteChar = char), corrected += char, i++;
160
+ continue;
161
+ }
162
+ if (inQuotes) {
163
+ corrected += char, i++;
164
+ continue;
165
+ }
166
+ const funcMatch = expression.substring(i).match(/^[A-Za-z][A-Za-z0-9]*\s*\(/);
167
+ if (funcMatch) {
168
+ const funcName = funcMatch[0].replace(/\s*\($/, "");
169
+ for (corrected += funcName.toUpperCase() + "(", i += funcName.length + 1; i < expression.length && " " === expression[i]; ) i++;
170
+ continue;
171
+ }
172
+ const sheetCellMatch = expression.substring(i).match(/^[A-Za-z0-9_]+![A-Za-z]+[0-9]+/);
173
+ if (sheetCellMatch) {
174
+ 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, "");
175
+ corrected += (originalSheetName || sheetName) + "!" + letters.toUpperCase() + numbers,
176
+ i += fullRef.length;
177
+ continue;
178
+ }
179
+ const sheetRangeMatch = expression.substring(i).match(/^[A-Za-z0-9_]+![A-Za-z]+[0-9]+:[A-Za-z]+[0-9]+/);
180
+ if (sheetRangeMatch) {
181
+ 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, "");
182
+ corrected += (originalSheetName || sheetPart) + "!" + newStartCell + ":" + (endLetters.toUpperCase() + endNumbers),
183
+ i += fullRangeRef.length;
184
+ continue;
185
+ }
186
+ const cellMatch = expression.substring(i).match(/^[A-Za-z]+[0-9]+/);
187
+ if (cellMatch) {
188
+ const cellRef = cellMatch[0], letters = cellRef.replace(/[0-9]/g, ""), numbers = cellRef.replace(/[A-Za-z]/g, "");
189
+ corrected += letters.toUpperCase() + numbers, i += cellRef.length;
190
+ continue;
191
+ }
192
+ const rangeMatch = expression.substring(i).match(/^[A-Za-z]+[0-9]+:[A-Za-z]+[0-9]+/);
193
+ if (rangeMatch) {
194
+ 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, "");
195
+ corrected += newStartCell + ":" + (endLetters.toUpperCase() + endNumbers), i += rangeRef.length;
196
+ } else corrected += char, i++;
197
+ }
198
+ return corrected;
199
+ }
200
+ findOriginalSheetName(sheetName) {
201
+ if (this.sheets.has(sheetName)) return sheetName;
202
+ const lowerSheetName = sheetName.toLowerCase();
203
+ for (const [existingSheetName] of this.sheets.entries()) if (existingSheetName.toLowerCase() === lowerSheetName) return existingSheetName;
204
+ return null;
205
+ }
149
206
  parseExpression(expr) {
150
207
  expr = expr.trim();
151
208
  const functionResult = this.tryParseFunction(expr);
@@ -683,29 +740,6 @@ export class FormulaEngine {
683
740
  };
684
741
  }
685
742
  }
686
- evaluateBasicArithmetic(expr) {
687
- try {
688
- if (/[A-Z]+\s*\(/.test(expr)) return {
689
- value: null,
690
- error: "Expression contains function calls"
691
- };
692
- let processedExpr = expr;
693
- const cellRefs = processedExpr.match(/[A-Z]+[0-9]+/g) || [];
694
- for (const cellRef of cellRefs) {
695
- const value = this.getCellValueByA1(cellRef);
696
- processedExpr = processedExpr.replace(cellRef, String(value));
697
- }
698
- return {
699
- value: Function('"use strict"; return (' + processedExpr + ")")(),
700
- error: void 0
701
- };
702
- } catch (error) {
703
- return {
704
- value: null,
705
- error: "Basic arithmetic evaluation failed"
706
- };
707
- }
708
- }
709
743
  getCellValueByA1(a1Notation) {
710
744
  try {
711
745
  let sheetKey = this.activeSheetKey || this.reverseSheets.get(0) || "Sheet1", cellRef = a1Notation;
@@ -1064,7 +1098,8 @@ export class FormulaEngine {
1064
1098
  }, deletedCellKey = this.getCellKey(deletedCell);
1065
1099
  deletedCells.add(deletedCellKey);
1066
1100
  }
1067
- for (const [cellKey, formula] of Array.from(this.formulaCells.entries())) {
1101
+ const entries = Array.from(this.formulaCells.entries());
1102
+ for (const [cellKey, formula] of entries) {
1068
1103
  const cell = this.parseCellKey(cellKey);
1069
1104
  if (!cell || cell.sheet !== sheetKey) continue;
1070
1105
  const newCell = Object.assign({}, cell);
@@ -1195,11 +1230,13 @@ export class FormulaEngine {
1195
1230
  let newStartCell, newEndCell, newMinRow = minRow, newMaxRow = maxRow, newMinCol = minCol, newMaxCol = maxCol;
1196
1231
  if ("row" === dimension) {
1197
1232
  const deleteEndRow = index + count - 1;
1198
- if (minRow >= index && minRow <= deleteEndRow ? newMinRow = index > 0 ? index - 1 : 0 : minRow > deleteEndRow && (newMinRow = minRow - count,
1233
+ if (minRow >= index && maxRow <= deleteEndRow) return "#REF!";
1234
+ if (minRow >= index && minRow <= deleteEndRow ? newMinRow = index : minRow > deleteEndRow && (newMinRow = minRow - count,
1199
1235
  newMinRow < 0 && (newMinRow = 0)), maxRow >= index && maxRow <= deleteEndRow ? newMaxRow = index > 0 ? index - 1 : 0 : maxRow > deleteEndRow && (newMaxRow = maxRow - count,
1200
1236
  newMaxRow < 0 && (newMaxRow = 0)), newMinRow > newMaxRow) return "#REF!";
1201
1237
  } else if ("column" === dimension) {
1202
1238
  const deleteEndCol = index + count - 1;
1239
+ if (minCol >= index && maxCol <= deleteEndCol) return "#REF!";
1203
1240
  if (minCol >= index && minCol <= deleteEndCol ? newMinCol = index > 0 ? index - 1 : 0 : minCol > deleteEndCol && (newMinCol = minCol - count,
1204
1241
  newMinCol < 0 && (newMinCol = 0)), maxCol >= index && maxCol <= deleteEndCol ? newMaxCol = index > 0 ? index - 1 : 0 : maxCol > deleteEndCol && (newMaxCol = maxCol - count,
1205
1242
  newMaxCol < 0 && (newMaxCol = 0)), newMinCol > newMaxCol) return "#REF!";
@@ -1213,6 +1250,222 @@ export class FormulaEngine {
1213
1250
  return "#REF!";
1214
1251
  }
1215
1252
  }
1253
+ adjustFormulaReferencesForColumnMove(sheetKey, sourceCol, targetCol, totalColCount, totalRowCount) {
1254
+ try {
1255
+ const adjustedFormulas = [], movedFormulas = [], isMovingForward = targetCol > sourceCol, columnMapping = new Map;
1256
+ if (isMovingForward) {
1257
+ for (let col = sourceCol + 1; col <= targetCol; col++) columnMapping.set(col, col - 1);
1258
+ columnMapping.set(sourceCol, targetCol);
1259
+ } else {
1260
+ for (let col = targetCol; col < sourceCol; col++) columnMapping.set(col, col + 1);
1261
+ columnMapping.set(sourceCol, targetCol);
1262
+ }
1263
+ for (const [cellKey, formula] of Array.from(this.formulaCells.entries())) {
1264
+ const cell = this.parseCellKey(cellKey);
1265
+ if (!cell || cell.sheet !== sheetKey) continue;
1266
+ let needsCellMove = !1;
1267
+ const newCellLocation = Object.assign({}, cell);
1268
+ if (columnMapping.has(cell.col)) {
1269
+ const mappedCol = columnMapping.get(cell.col);
1270
+ void 0 !== mappedCol && (newCellLocation.col = mappedCol, needsCellMove = !0);
1271
+ }
1272
+ const newFormula = this.adjustFormulaWithColumnMapping(formula, columnMapping);
1273
+ (needsCellMove || newFormula !== formula) && (needsCellMove ? (movedFormulas.push({
1274
+ oldCellKey: cellKey,
1275
+ newCell: newCellLocation,
1276
+ formula: newFormula
1277
+ }), this.formulaCells.delete(cellKey), this.clearDependencies(cellKey)) : (adjustedFormulas.push({
1278
+ cell: cell,
1279
+ oldFormula: formula,
1280
+ newFormula: newFormula
1281
+ }), this.clearDependencies(cellKey)));
1282
+ }
1283
+ for (const {newCell: newCell, formula: formula} of movedFormulas) {
1284
+ const newCellKey = this.getCellKey(newCell);
1285
+ this.formulaCells.set(newCellKey, formula), this.updateDependencies(newCellKey, formula),
1286
+ this.setCellContentWithoutDependencyUpdate(newCell, formula);
1287
+ }
1288
+ for (const {cell: cell, newFormula: newFormula} of adjustedFormulas) {
1289
+ const cellKey = this.getCellKey(cell);
1290
+ this.formulaCells.set(cellKey, newFormula), this.updateDependencies(cellKey, newFormula),
1291
+ this.setCellContentWithoutDependencyUpdate(cell, newFormula);
1292
+ }
1293
+ const adjustedCells = adjustedFormulas.map((item => item.cell));
1294
+ return {
1295
+ adjustedCells: adjustedCells,
1296
+ movedCells: movedFormulas.map((item => item.newCell))
1297
+ };
1298
+ } catch (error) {
1299
+ return {
1300
+ adjustedCells: [],
1301
+ movedCells: []
1302
+ };
1303
+ }
1304
+ }
1305
+ adjustFormulaWithColumnMapping(formula, columnMapping) {
1306
+ if (!formula || !formula.startsWith("=")) return formula;
1307
+ let expression = formula.substring(1);
1308
+ const rangeRegex = /([A-Z]+)([0-9]+):([A-Z]+)([0-9]+)/g;
1309
+ let match;
1310
+ const rangeReplacements = [], processedRanges = [];
1311
+ for (;null !== (match = rangeRegex.exec(expression)); ) {
1312
+ const fullMatch = match[0], startCol = match[1], startRow = match[2], endCol = match[3], endRow = match[4], startColIndex = this.columnLettersToIndex(startCol), endColIndex = this.columnLettersToIndex(endCol);
1313
+ let newStartCol = startColIndex, newEndCol = endColIndex;
1314
+ if (columnMapping.has(startColIndex)) {
1315
+ const mappedStartCol = columnMapping.get(startColIndex);
1316
+ void 0 !== mappedStartCol && (newStartCol = mappedStartCol);
1317
+ }
1318
+ if (columnMapping.has(endColIndex)) {
1319
+ const mappedEndCol = columnMapping.get(endColIndex);
1320
+ void 0 !== mappedEndCol && (newEndCol = mappedEndCol);
1321
+ }
1322
+ newStartCol > newEndCol && ([newStartCol, newEndCol] = [ newEndCol, newStartCol ]);
1323
+ const replacement = `${this.indexToColumnLetters(newStartCol)}${startRow}:${this.indexToColumnLetters(newEndCol)}${endRow}`;
1324
+ rangeReplacements.push({
1325
+ start: match.index,
1326
+ end: match.index + fullMatch.length,
1327
+ replacement: replacement
1328
+ }), processedRanges.push({
1329
+ start: match.index,
1330
+ end: match.index + fullMatch.length
1331
+ });
1332
+ }
1333
+ for (let i = rangeReplacements.length - 1; i >= 0; i--) {
1334
+ const {start: start, end: end, replacement: replacement} = rangeReplacements[i];
1335
+ expression = expression.substring(0, start) + replacement + expression.substring(end);
1336
+ }
1337
+ const cellRegex = /([A-Z]+)([0-9]+)/g, cellReplacements = [];
1338
+ for (;null !== (match = cellRegex.exec(expression)); ) {
1339
+ const fullMatch = match[0], colLetters = match[1], row = match[2], colIndex = this.columnLettersToIndex(colLetters), matchIndex = match.index;
1340
+ if (!processedRanges.some((range => matchIndex >= range.start && matchIndex < range.end)) && columnMapping.has(colIndex)) {
1341
+ const newColIndex = columnMapping.get(colIndex);
1342
+ if (void 0 !== newColIndex) {
1343
+ const replacement = `${this.indexToColumnLetters(newColIndex)}${row}`;
1344
+ cellReplacements.push({
1345
+ start: match.index,
1346
+ end: match.index + fullMatch.length,
1347
+ replacement: replacement
1348
+ });
1349
+ }
1350
+ }
1351
+ }
1352
+ for (let i = cellReplacements.length - 1; i >= 0; i--) {
1353
+ const {start: start, end: end, replacement: replacement} = cellReplacements[i];
1354
+ expression = expression.substring(0, start) + replacement + expression.substring(end);
1355
+ }
1356
+ return "=" + expression;
1357
+ }
1358
+ adjustFormulaReferencesForRowMove(sheetKey, sourceRow, targetRow) {
1359
+ try {
1360
+ if (sourceRow < 0 || targetRow < 0) return {
1361
+ adjustedCells: [],
1362
+ movedCells: []
1363
+ };
1364
+ const adjustedFormulas = [], movedFormulas = [], isMovingForward = targetRow > sourceRow, rowMapping = new Map;
1365
+ if (isMovingForward) {
1366
+ for (let row = sourceRow + 1; row <= targetRow; row++) rowMapping.set(row, row - 1);
1367
+ rowMapping.set(sourceRow, targetRow);
1368
+ } else {
1369
+ for (let row = targetRow; row < sourceRow; row++) rowMapping.set(row, row + 1);
1370
+ rowMapping.set(sourceRow, targetRow);
1371
+ }
1372
+ for (const [cellKey, formula] of Array.from(this.formulaCells.entries())) {
1373
+ const cell = this.parseCellKey(cellKey);
1374
+ if (!cell || cell.sheet !== sheetKey) continue;
1375
+ let needsCellMove = !1;
1376
+ const newCellLocation = Object.assign({}, cell);
1377
+ if (rowMapping.has(cell.row)) {
1378
+ const mappedRow = rowMapping.get(cell.row);
1379
+ void 0 !== mappedRow && mappedRow !== cell.row && (newCellLocation.row = mappedRow,
1380
+ needsCellMove = !0);
1381
+ }
1382
+ const newFormula = this.adjustFormulaWithRowMapping(formula, rowMapping);
1383
+ (needsCellMove || newFormula !== formula) && (needsCellMove ? (movedFormulas.push({
1384
+ oldCellKey: cellKey,
1385
+ newCell: newCellLocation,
1386
+ formula: newFormula
1387
+ }), this.formulaCells.delete(cellKey), this.clearDependencies(cellKey)) : (adjustedFormulas.push({
1388
+ cell: cell,
1389
+ oldFormula: formula,
1390
+ newFormula: newFormula
1391
+ }), this.clearDependencies(cellKey)));
1392
+ }
1393
+ for (const {newCell: newCell, formula: formula} of movedFormulas) {
1394
+ const newCellKey = this.getCellKey(newCell);
1395
+ this.formulaCells.set(newCellKey, formula), this.updateDependencies(newCellKey, formula),
1396
+ this.setCellContentWithoutDependencyUpdate(newCell, formula);
1397
+ }
1398
+ for (const {cell: cell, newFormula: newFormula} of adjustedFormulas) {
1399
+ const cellKey = this.getCellKey(cell);
1400
+ this.formulaCells.set(cellKey, newFormula), this.updateDependencies(cellKey, newFormula),
1401
+ this.setCellContentWithoutDependencyUpdate(cell, newFormula);
1402
+ }
1403
+ const adjustedCells = adjustedFormulas.map((item => item.cell));
1404
+ return {
1405
+ adjustedCells: adjustedCells,
1406
+ movedCells: movedFormulas.map((item => item.newCell))
1407
+ };
1408
+ } catch (error) {
1409
+ return {
1410
+ adjustedCells: [],
1411
+ movedCells: []
1412
+ };
1413
+ }
1414
+ }
1415
+ adjustFormulaWithRowMapping(formula, rowMapping) {
1416
+ if (!formula || !formula.startsWith("=")) return formula;
1417
+ let expression = formula.substring(1);
1418
+ const rangeRegex = /([A-Z]+)([0-9]+):([A-Z]+)([0-9]+)/g;
1419
+ let match;
1420
+ const rangeReplacements = [], processedRanges = [];
1421
+ for (;null !== (match = rangeRegex.exec(expression)); ) {
1422
+ 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;
1423
+ let newStartRow = startRowIndex, newEndRow = endRowIndex;
1424
+ if (rowMapping.has(startRowIndex)) {
1425
+ const mappedStartRow = rowMapping.get(startRowIndex);
1426
+ void 0 !== mappedStartRow && (newStartRow = mappedStartRow);
1427
+ }
1428
+ if (rowMapping.has(endRowIndex)) {
1429
+ const mappedEndRow = rowMapping.get(endRowIndex);
1430
+ void 0 !== mappedEndRow && (newEndRow = mappedEndRow);
1431
+ }
1432
+ if (newStartRow !== startRowIndex || newEndRow !== endRowIndex) {
1433
+ const replacement = `${startCol}${newStartRow + 1}:${endCol}${newEndRow + 1}`;
1434
+ rangeReplacements.push({
1435
+ start: match.index,
1436
+ end: match.index + fullMatch.length,
1437
+ replacement: replacement
1438
+ }), processedRanges.push({
1439
+ start: match.index,
1440
+ end: match.index + fullMatch.length
1441
+ });
1442
+ }
1443
+ }
1444
+ for (let i = rangeReplacements.length - 1; i >= 0; i--) {
1445
+ const {start: start, end: end, replacement: replacement} = rangeReplacements[i];
1446
+ expression = expression.substring(0, start) + replacement + expression.substring(end);
1447
+ }
1448
+ const cellRegex = /([A-Z]+)([0-9]+)/g, cellReplacements = [];
1449
+ for (;null !== (match = cellRegex.exec(expression)); ) {
1450
+ const fullMatch = match[0], colLetters = match[1], row = match[2], rowIndex = parseInt(row, 10) - 1, matchIndex = match.index;
1451
+ if (!processedRanges.some((range => matchIndex >= range.start && matchIndex < range.end)) && rowMapping.has(rowIndex)) {
1452
+ const newRowIndex = rowMapping.get(rowIndex);
1453
+ if (void 0 !== newRowIndex) {
1454
+ const replacement = `${colLetters}${newRowIndex + 1}`;
1455
+ cellReplacements.push({
1456
+ start: match.index,
1457
+ end: match.index + fullMatch.length,
1458
+ replacement: replacement
1459
+ });
1460
+ }
1461
+ }
1462
+ }
1463
+ for (let i = cellReplacements.length - 1; i >= 0; i--) {
1464
+ const {start: start, end: end, replacement: replacement} = cellReplacements[i];
1465
+ expression = expression.substring(0, start) + replacement + expression.substring(end);
1466
+ }
1467
+ return "=" + expression;
1468
+ }
1216
1469
  }
1217
1470
 
1218
1471
  class FormulaError {