@veltra/sheet 2.8.1 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/components/sheet/formula-bar.js +1 -1
  2. package/dist/components/sheet/import-file.js +4 -2
  3. package/dist/components/sheet/insert-image.js +1 -1
  4. package/dist/components/sheet/popup-helpers.js +1 -1
  5. package/dist/components/sheet/popups/border-popup.js +1 -2
  6. package/dist/components/sheet/popups/functions-popup.js +3 -3
  7. package/dist/components/sheet/popups/import.worker.d.ts +5 -1
  8. package/dist/components/sheet/popups/import.worker.js +4 -2
  9. package/dist/components/sheet/sheet-context-menu.js +8 -6
  10. package/dist/components/sheet/sheet.js +12 -2
  11. package/dist/components/sheet/use-find-replace.js +1 -2
  12. package/dist/components/sheet/use-formula-suggest.js +5 -4
  13. package/dist/components/sheet/use-sheet-grid.js +55 -4
  14. package/dist/components/sheet/use-sheet-state.js +1 -1
  15. package/dist/components/sheet/use-tool-popup.js +13 -2
  16. package/dist/index.d.ts +2 -2
  17. package/dist/tools/builtin.js +1 -1
  18. package/dist/tools/context.d.ts +1 -11
  19. package/dist/tools/download.js +3 -3
  20. package/dist/tools/export.worker.d.ts +1 -1
  21. package/dist/tools/export.worker.js +1 -1
  22. package/dist/tools/registry.js +1 -1
  23. package/dist/types/sheet.d.ts +12 -6
  24. package/package.json +2 -3
  25. package/src/components/sheet/__test__/canvas-mock.ts +49 -0
  26. package/src/components/sheet/__test__/find-shortcut-anchor.test.ts +117 -0
  27. package/src/components/sheet/__test__/formula-bar.test.ts +11 -9
  28. package/src/components/sheet/__test__/formula-capability.test.ts +160 -0
  29. package/src/components/sheet/__test__/functions-popup.test.ts +7 -7
  30. package/src/components/sheet/__test__/grid-setup.ts +3 -0
  31. package/src/components/sheet/__test__/grid-test-utils.ts +46 -0
  32. package/src/components/sheet/__test__/import-file.test.ts +44 -9
  33. package/src/components/sheet/__test__/insert-image-popup.test.ts +1 -1
  34. package/src/components/sheet/__test__/insert-image.test.ts +1 -1
  35. package/src/components/sheet/__test__/sheet-component.test.ts +9 -19
  36. package/src/components/sheet/__test__/sheet-context-menu.test.ts +45 -2
  37. package/src/components/sheet/__test__/sheet-grow-on-scroll.test.ts +105 -0
  38. package/src/components/sheet/__test__/sheet-scrollbar.test.ts +87 -0
  39. package/src/components/sheet/__test__/sheet-theme.test.ts +212 -0
  40. package/src/components/sheet/__test__/use-formula-suggest.test.ts +1 -1
  41. package/src/components/sheet/formula-bar.vue +4 -4
  42. package/src/components/sheet/import-file.ts +22 -9
  43. package/src/components/sheet/insert-image.ts +2 -2
  44. package/src/components/sheet/popup-helpers.ts +3 -3
  45. package/src/components/sheet/popups/border-popup.vue +4 -4
  46. package/src/components/sheet/popups/export-popup.vue +1 -1
  47. package/src/components/sheet/popups/find-popup.vue +1 -1
  48. package/src/components/sheet/popups/functions-popup.vue +3 -9
  49. package/src/components/sheet/popups/import.worker.ts +21 -7
  50. package/src/components/sheet/sheet-context-menu.ts +18 -8
  51. package/src/components/sheet/sheet-tabs.vue +2 -2
  52. package/src/components/sheet/sheet.vue +11 -3
  53. package/src/components/sheet/use-find-replace.ts +3 -7
  54. package/src/components/sheet/use-formula-suggest.ts +6 -8
  55. package/src/components/sheet/use-sheet-grid.ts +58 -6
  56. package/src/components/sheet/use-sheet-state.ts +2 -2
  57. package/src/components/sheet/use-tool-popup.ts +22 -2
  58. package/src/index.ts +3 -1
  59. package/src/tools/__test__/apply-style.test.ts +2 -2
  60. package/src/tools/__test__/builtin.test.ts +4 -4
  61. package/src/tools/__test__/context.test.ts +2 -2
  62. package/src/tools/apply-style.ts +3 -3
  63. package/src/tools/builtin.ts +2 -2
  64. package/src/tools/context.ts +11 -11
  65. package/src/tools/download.ts +4 -4
  66. package/src/tools/export.worker.ts +4 -7
  67. package/src/tools/registry.ts +1 -1
  68. package/src/types/sheet.ts +15 -7
@@ -1,6 +1,6 @@
1
1
  import type { ContextmenuItem } from '@veltra/desktop'
2
- import { createRange, type CellAddress, type CellRange } from '@veltra/sheet-core/core/address.js'
3
- import type { NumFmt } from '@veltra/sheet-core/core/style/types.js'
2
+ import { createRange, type CellAddress, type CellRange } from 'infinitable/sheet'
3
+ import type { NumFmt } from 'infinitable/sheet'
4
4
  import { defineComponent, h } from 'vue'
5
5
 
6
6
  import type { SheetContext } from '../../tools/context'
@@ -20,7 +20,7 @@ export const DECIMAL_PLACES_MAX = 10
20
20
  /** 行高/列宽数值项输入上限(下限复用门面 MIN_ROW_COL_SIZE,对齐引擎 resize 最小值) */
21
21
  export const AXIS_SIZE_MAX = 1000
22
22
 
23
- /** 数值项默认值回落:未设置自定义尺寸时展示引擎默认行高/列宽(对齐 sheet-core grid-theme) */
23
+ /** 数值项默认值回落:未设置自定义尺寸时展示引擎默认行高/列宽(对齐引擎 grid-theme) */
24
24
  export const FALLBACK_ROW_HEIGHT = 28
25
25
  export const FALLBACK_COL_WIDTH = 80
26
26
 
@@ -106,6 +106,10 @@ function insertCountRender(options: {
106
106
  export interface HeaderMenuOptions {
107
107
  /** 只读模式:行高/列宽项禁用(尺寸写入属编辑操作) */
108
108
  readonly?: boolean
109
+ /** 右键命中的行号(行头菜单):冻结以点击行为准,缺省回落选区末端 */
110
+ row?: number
111
+ /** 右键命中的列号(列头菜单):冻结以点击列为准,缺省回落选区末端 */
112
+ col?: number
109
113
  }
110
114
 
111
115
  /**
@@ -148,7 +152,11 @@ export function buildRowHeaderMenus(
148
152
  const rowCount = defaultInsertCount(range, 'row')
149
153
  const deleteCount = range ? endRow - startRow + 1 : 1
150
154
  const frozen = ctx.frozen
151
- const freezeActive = frozen.rows === endRow + 1
155
+ // 冻结目标 = 右键命中的行;缺省回落选区末端。不能直接用选区末端:先冻结行的
156
+ // 整行选区横跨全部列,随后列头右键判定「在选区内」保留选区,选区末端列会把
157
+ // 冻结列放大到全部列(反之亦然),表现为冻结不生效
158
+ const freezeRow = (options?.row ?? endRow) + 1
159
+ const freezeActive = frozen.rows === freezeRow
152
160
 
153
161
  return [
154
162
  {
@@ -181,7 +189,7 @@ export function buildRowHeaderMenus(
181
189
  { divider: true },
182
190
  {
183
191
  label: freezeActive ? '✓ 冻结到当前行' : '冻结到当前行',
184
- callback: () => ctx.setFrozen(endRow + 1, frozen.cols)
192
+ callback: () => ctx.setFrozen(freezeRow, frozen.cols)
185
193
  },
186
194
  {
187
195
  label: '取消冻结',
@@ -202,7 +210,9 @@ export function buildColHeaderMenus(
202
210
  const colCount = defaultInsertCount(range, 'col')
203
211
  const deleteCount = range ? endCol - startCol + 1 : 1
204
212
  const frozen = ctx.frozen
205
- const freezeActive = frozen.cols === endCol + 1
213
+ // 冻结目标 = 右键命中的列(同 buildRowHeaderMenus:整行/整列选区残留时选区末端会放大冻结范围)
214
+ const freezeCol = (options?.col ?? endCol) + 1
215
+ const freezeActive = frozen.cols === freezeCol
206
216
 
207
217
  return [
208
218
  {
@@ -235,7 +245,7 @@ export function buildColHeaderMenus(
235
245
  { divider: true },
236
246
  {
237
247
  label: freezeActive ? '✓ 冻结到当前列' : '冻结到当前列',
238
- callback: () => ctx.setFrozen(frozen.rows, endCol + 1)
248
+ callback: () => ctx.setFrozen(frozen.rows, freezeCol)
239
249
  },
240
250
  {
241
251
  label: '取消冻结',
@@ -247,7 +257,7 @@ export function buildColHeaderMenus(
247
257
 
248
258
  /**
249
259
  * 对当前选区应用 numFmt(经 applyStyle → 命令系统,天然可 undo/redo)。
250
- * 仅影响显示,单元格恒存原始值(见 sheet-core `core/format.ts`)。
260
+ * 仅影响显示,单元格恒存原始值(引擎 numFmt 显示约定)。
251
261
  */
252
262
  export function applyNumFmtToSelection(ctx: SheetContext, numFmt: NumFmt): void {
253
263
  for (const range of ctx.getSelection().ranges) ctx.applyStyle(range, { numFmt })
@@ -54,9 +54,9 @@
54
54
  <script lang="ts" setup>
55
55
  import { contextmenu, message, messageConfirm, UIcon } from '@veltra/desktop'
56
56
  import { ArrowLeft, ArrowRight } from '@veltra/icons/normal'
57
- import type { Sheet } from '@veltra/sheet-core/core/sheet.js'
58
- import type { Workbook } from '@veltra/sheet-core/core/workbook.js'
59
57
  import { bem } from '@veltra/utils'
58
+ import type { Sheet } from 'infinitable/sheet'
59
+ import type { Workbook } from 'infinitable/sheet'
60
60
  import { nextTick, ref, toRef, useTemplateRef } from 'vue'
61
61
 
62
62
  import { useSheetTabsBar } from './use-sheet-tabs-bar'
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <div ref="rootRef" :class="cls.b">
3
- <div :class="cls.e('toolbar-wrap')">
3
+ <div ref="toolbarWrapRef" :class="cls.e('toolbar-wrap')">
4
4
  <u-sheet-toolbar v-if="showToolbar" :groups="toolGroups" @tool-click="handleToolClick" />
5
5
 
6
6
  <!-- 弹层型工具面板(填充/边框/字体色/字号/查找/函数/插入图片/导出):UDropdown(Teleport 到
@@ -113,7 +113,12 @@ const props = withDefaults(defineProps<SheetProps>(), {
113
113
  showColHeader: true,
114
114
  readonly: false,
115
115
  colResize: false,
116
- scrollbar: true
116
+ // 缺省画布常驻档:true 经引擎归一化为 canvas always + reserve——滚动条常驻
117
+ // 画在画布内,reserve 只在画布内预留轨道(不占页面布局、不遮挡单元格)
118
+ scrollbar: true,
119
+ // 显式对齐引擎当前缺省(true 近边增长):boolean prop 不写 default 会被
120
+ // Vue 铸成 false,把引擎缺省翻成固定尺寸网格
121
+ growOnScroll: true
117
122
  })
118
123
 
119
124
  const emit = defineEmits<SheetEmits>()
@@ -123,6 +128,9 @@ const cls = bem('sheet')
123
128
  /** 根容器 ref:Ctrl/Cmd+F 判定焦点是否在本实例内(#6,避免劫持浏览器查找) */
124
129
  const rootRef = useTemplateRef<HTMLElement>('rootRef')
125
130
 
131
+ /** 工具栏容器 ref:工具栏隐藏(showToolbar=false)时查找弹层的回退锚点(0 高贴 sheet 顶) */
132
+ const toolbarWrapRef = useTemplateRef<HTMLElement>('toolbarWrapRef')
133
+
126
134
  // ─── 状态源(workbook / sheet 列表 / 活动 sheet / 工具上下文)────────
127
135
  // hooks 引用的 closePopup / rebuildGrid 由下方组合提供:箭头函数在事件触发时才
128
136
  // 求值(彼时已完成全部 setup),组合声明顺序不构成循环依赖。
@@ -144,7 +152,7 @@ const {
144
152
  popupAnchor,
145
153
  closePopup,
146
154
  handleToolClick: openOrRunTool
147
- } = useToolPopup(context, rootRef)
155
+ } = useToolPopup(context, rootRef, () => toolbarWrapRef.value ?? null)
148
156
  // xlsx 解析中(worker):grid 容器显示自绘覆盖层(import-file 写入 parsing /
149
157
  // parseProgress;遮罩 + 动画 + 文字同层——动画在上、文字在下)
150
158
  const parsing = ref(false)
@@ -1,17 +1,13 @@
1
1
  import { debounce } from '@cat-kit/core'
2
- import {
3
- inferCellType,
4
- normalizeInputValue,
5
- type CellData
6
- } from '@veltra/sheet-core/core/cell-store.js'
2
+ import { inferCellType, normalizeInputValue, type CellData } from 'infinitable/sheet'
7
3
  import {
8
4
  findAll,
9
5
  findNextFrom,
10
6
  findPrevFrom,
11
7
  type FindMatch,
12
8
  type FindOptions
13
- } from '@veltra/sheet-core/core/find.js'
14
- import type { Sheet } from '@veltra/sheet-core/core/sheet.js'
9
+ } from 'infinitable/sheet'
10
+ import type { Sheet } from 'infinitable/sheet'
15
11
  import { computed, ref, shallowRef, watch } from 'vue'
16
12
 
17
13
  import type { SheetContext } from '../../tools/context'
@@ -1,7 +1,4 @@
1
- import {
2
- listFormulaFunctions,
3
- type FormulaFunctionMeta
4
- } from '@veltra/sheet-core/core/formula/functions.js'
1
+ import { listFormulaFunctions, type FormulaFunctionInfo } from 'infinitable'
5
2
 
6
3
  /** 补全候选上限 */
7
4
  export const FORMULA_SUGGEST_LIMIT = 10
@@ -26,7 +23,7 @@ export const COMMON_FORMULA_NAMES = [
26
23
  /**
27
24
  * 函数弹框分类导航固定集合(顺序即展示顺序)。
28
25
  * 「常用」「全部」是导航概念(非注册表分类):常用 = COMMON_FORMULA_NAMES 固定清单,
29
- * 全部 = 全部已注册函数;其余与 sheet-core `FormulaFunctionCategory` 对应。
26
+ * 全部 = 全部已注册函数;其余与公式注册表 `FormulaFunctionCategory` 对应。
30
27
  */
31
28
  export const FUNCTION_POPUP_CATEGORIES = [
32
29
  '常用',
@@ -131,12 +128,13 @@ export function filterFormulaSuggestions(prefix: string): FormulaSuggestItem[] {
131
128
  return items
132
129
  }
133
130
 
134
- function toSuggestItem(fn: { name: string } & FormulaFunctionMeta): FormulaSuggestItem {
131
+ function toSuggestItem(fn: FormulaFunctionInfo): FormulaSuggestItem {
132
+ const params = fn.params.map((p) => p.name)
135
133
  return {
136
134
  name: fn.name,
137
- params: fn.params,
135
+ params,
138
136
  description: fn.description,
139
- signature: formatFunctionSignature(fn.name, fn.params)
137
+ signature: formatFunctionSignature(fn.name, params)
140
138
  }
141
139
  }
142
140
 
@@ -1,7 +1,9 @@
1
1
  import { contextmenu } from '@veltra/desktop'
2
- import type { CellAddress, CellRange } from '@veltra/sheet-core/core/address.js'
3
- import type { Sheet } from '@veltra/sheet-core/core/sheet.js'
4
- import { SheetGrid, type SheetGridContextMenuInfo } from '@veltra/sheet-core/grid'
2
+ import { currentTheme } from '@veltra/styles/theme'
3
+ import type { ThemeOverride } from 'infinitable'
4
+ import type { CellAddress, CellRange } from 'infinitable/sheet'
5
+ import type { Sheet } from 'infinitable/sheet'
6
+ import { SheetGrid, type SheetGridContextMenuInfo } from 'infinitable/sheet'
5
7
  import { onBeforeUnmount, onMounted, watch } from 'vue'
6
8
 
7
9
  import type { SheetContext } from '../../tools/context'
@@ -63,6 +65,34 @@ interface CachedGrid {
63
65
  */
64
66
  const GRID_CACHE_CAPACITY = 3
65
67
 
68
+ /**
69
+ * 画布主题映射:读 grid 宿主元素上生效的 `--u-*` CSS 变量(loadTheme 注入 html、
70
+ * 继承到宿主),换算为引擎 `ThemeOverride`——画布底色 / 表头 / 文字 / 网格线 /
71
+ * 冻结分隔线跟随 UI 主题。rowHeader / corner 由引擎随生效 header 派生,无需单写。
72
+ *
73
+ * 任一变量为空(未 loadTheme)返回 `undefined`:SheetGrid 不传 theme、保持引擎
74
+ * 缺省白底,不破坏无主题环境。
75
+ */
76
+ export function resolveCanvasThemeOverride(el: HTMLElement): ThemeOverride | undefined {
77
+ const style = getComputedStyle(el)
78
+ const bgColorTop = style.getPropertyValue('--u-bg-color-top').trim()
79
+ const bgColorBottom = style.getPropertyValue('--u-bg-color-bottom').trim()
80
+ const textColorMain = style.getPropertyValue('--u-text-color-main').trim()
81
+ const borderColor = style.getPropertyValue('--u-border-color').trim()
82
+ const borderMutedColor = style.getPropertyValue('--u-border-muted-color').trim()
83
+ if (!bgColorTop || !bgColorBottom || !textColorMain || !borderColor || !borderMutedColor) {
84
+ return undefined
85
+ }
86
+ return {
87
+ // 底色与 .u-sheet 外层同底;underlay 是数据区外空白处直接可见的底
88
+ body: { background: bgColorTop, color: textColorMain, borderColor },
89
+ header: { background: bgColorBottom, color: textColorMain, borderColor },
90
+ underlayBackgroundColor: bgColorTop,
91
+ interaction: { freezeDividerColor: borderMutedColor },
92
+ frameStyle: { color: borderColor }
93
+ }
94
+ }
95
+
66
96
  /**
67
97
  * SheetGrid 生命周期与网格右键菜单(LRU 实例缓存):
68
98
  * - activateGrid:tab 切换入口——命中缓存 → 显示 + 模型同步(零重建);
@@ -86,9 +116,9 @@ export function useSheetGrid(options: UseSheetGridOptions) {
86
116
 
87
117
  const menus =
88
118
  info.kind === 'row-header'
89
- ? buildRowHeaderMenus(context, { readonly: props.readonly })
119
+ ? buildRowHeaderMenus(context, { readonly: props.readonly, row: info.row })
90
120
  : info.kind === 'col-header'
91
- ? buildColHeaderMenus(context, { readonly: props.readonly })
121
+ ? buildColHeaderMenus(context, { readonly: props.readonly, col: info.col })
92
122
  : buildBodyMenus(context)
93
123
 
94
124
  // 最小宽度兜底;实际宽度由最长菜单项撑开(勿固定 240 导致空白过大)
@@ -132,6 +162,10 @@ export function useSheetGrid(options: UseSheetGridOptions) {
132
162
  editors: props.editors,
133
163
  colResize: props.colResize,
134
164
  scrollbar: props.scrollbar,
165
+ growOnScroll: props.growOnScroll,
166
+ // 画布跟随 UI 主题:loadTheme 注入的 CSS 变量换算为引擎 override
167
+ //(未 loadTheme 时为 undefined,引擎保持缺省白底)
168
+ theme: resolveCanvasThemeOverride(host),
135
169
  onContextMenu: handleContextMenu,
136
170
  onEditStart: (addr) => formulaBarRef.value?.mirrorGridEdit(addr),
137
171
  onEditEnd: (addr) => formulaBarRef.value?.exitMirror(addr),
@@ -275,7 +309,8 @@ export function useSheetGrid(options: UseSheetGridOptions) {
275
309
  props.header,
276
310
  props.editors,
277
311
  props.colResize,
278
- props.scrollbar
312
+ props.scrollbar,
313
+ props.growOnScroll
279
314
  ] as const,
280
315
  ([nextRows, nextCols]) => {
281
316
  const sheet = getActiveSheet()
@@ -289,6 +324,23 @@ export function useSheetGrid(options: UseSheetGridOptions) {
289
324
  invalidateAll()
290
325
  })
291
326
 
327
+ // 主题切换换肤:loadTheme 换实例(ref 替换)或主题 token 原地改(deep)后,
328
+ // 等 UITheme 把 CSS 变量渲染进 html(flush: 'post' 晚于其渲染)再重读映射,
329
+ // 对缓存中所有实例原地 updateTheme——零重建,滚动 / 选区 / 冻结等运行时状态
330
+ // 不受影响;未 loadTheme(解析为 undefined)时不动,保持引擎缺省白底
331
+ watch(
332
+ [() => currentTheme.value?.theme, currentTheme],
333
+ () => {
334
+ const host = gridRef.value
335
+ const override = host ? resolveCanvasThemeOverride(host) : undefined
336
+ if (!override) return
337
+ for (const item of cache.values()) {
338
+ item.grid.updateTheme(override)
339
+ }
340
+ },
341
+ { deep: true, flush: 'post' }
342
+ )
343
+
292
344
  /** fx 引用拾取会话置/清选区锚点(公式栏 → 活动实例透传;无活动实例时静默) */
293
345
  function setSelectionAnchor(addr: CellAddress | null): void {
294
346
  active?.grid.setSelectionAnchor(addr)
@@ -1,5 +1,5 @@
1
- import type { Sheet } from '@veltra/sheet-core/core/sheet.js'
2
- import { Workbook } from '@veltra/sheet-core/core/workbook.js'
1
+ import type { Sheet } from 'infinitable/sheet'
2
+ import { Workbook } from 'infinitable/sheet'
3
3
  import { computed, onBeforeUnmount, onMounted, ref, shallowRef, watch } from 'vue'
4
4
 
5
5
  import { createSheetContext } from '../../tools/context'
@@ -31,7 +31,15 @@ function joinsTransaction(tool: SheetTool): boolean {
31
31
  * 函数面板选中只进入公式栏编辑态(无直接模型写入),与查找 / 导出一样不参与事务。
32
32
  * 导入在 sheet.vue 特殊处理(直接系统文件选择),不经弹层。
33
33
  */
34
- export function useToolPopup(context: SheetContext, rootEl: ElRef) {
34
+ export function useToolPopup(
35
+ context: SheetContext,
36
+ rootEl: ElRef,
37
+ /**
38
+ * 查找弹层回退锚点(工具栏隐藏时 find 按钮不可达,取 sheet 顶部容器:
39
+ * 0 高贴 sheet 顶,bottom-start 定位下弹层自 sheet 左上角展开,落在 sheet 视口内)
40
+ */
41
+ getFallbackAnchor?: () => HTMLElement | null | undefined
42
+ ) {
35
43
  /** 当前打开的弹层工具(null = 未打开) */
36
44
  const popupTool = shallowRef<SheetTool | null>(null)
37
45
  /** 触发按钮元素(打开时的 currentTarget;用于面板 left 对齐按钮) */
@@ -104,6 +112,18 @@ export function useToolPopup(context: SheetContext, rootEl: ElRef) {
104
112
  closePopup()
105
113
  }
106
114
 
115
+ /**
116
+ * Ctrl/Cmd+F 的锚点解析:优先工具栏「查找与替换」按钮(与按钮入口完全同锚点,
117
+ * 弹层同样锚定按钮下方);按钮不可达(showToolbar 隐藏)时回退 sheet 顶部容器。
118
+ */
119
+ function resolveFindAnchor(): HTMLElement | null {
120
+ const root = rootEl.value
121
+ if (!root) return null
122
+ const button = root.querySelector<HTMLElement>('[data-tool-id="find"]')
123
+ if (button) return button
124
+ return getFallbackAnchor?.() ?? null
125
+ }
126
+
107
127
  /** Ctrl/Cmd+F 打开 / 关闭查找条(与工具按钮同一 toggle 逻辑) */
108
128
  function onGlobalKeydown(event: KeyboardEvent): void {
109
129
  if (!(event.metaKey || event.ctrlKey) || event.key.toLowerCase() !== 'f') return
@@ -131,7 +151,7 @@ export function useToolPopup(context: SheetContext, rootEl: ElRef) {
131
151
  closePopup()
132
152
  return
133
153
  }
134
- scheduleOpen(findTool)
154
+ scheduleOpen(findTool, resolveFindAnchor())
135
155
  }
136
156
 
137
157
  onMounted(() => {
package/src/index.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import './tools/builtin'
2
2
 
3
- export { createSheetContext, type SheetContext } from './tools/context'
3
+ // SheetContextOptions:createSheetContext(公共导出)的第三参类型——导出函数
4
+ // 签名引用的稳定类型须随函数可达(无头场景宿主需引用该类型),不属引擎符号
5
+ export { createSheetContext, type SheetContext, type SheetContextOptions } from './tools/context'
4
6
 
5
7
  export {
6
8
  defaultToolRegistry,
@@ -1,5 +1,5 @@
1
- import { createRange } from '@veltra/sheet-core/core/address.js'
2
- import { Sheet } from '@veltra/sheet-core/core/sheet.js'
1
+ import { createRange } from 'infinitable/sheet'
2
+ import { Sheet } from 'infinitable/sheet'
3
3
  import { describe, expect, it } from 'vite-plus/test'
4
4
 
5
5
  import { classifySelectionStyleTarget, type SelectionStyleTarget } from '../apply-style'
@@ -1,8 +1,8 @@
1
- import { createRange } from '@veltra/sheet-core/core/address.js'
1
+ import { createRange } from 'infinitable/sheet'
2
2
 
3
3
  import '../builtin'
4
- import { Sheet } from '@veltra/sheet-core/core/sheet.js'
5
- import { Workbook } from '@veltra/sheet-core/core/workbook.js'
4
+ import { Sheet } from 'infinitable/sheet'
5
+ import { Workbook } from 'infinitable/sheet'
6
6
  import { describe, expect, it, vi } from 'vite-plus/test'
7
7
 
8
8
  import { createSheetContext } from '../context'
@@ -122,7 +122,7 @@ describe('内置工具(dogfood 扩展机制)', () => {
122
122
  }
123
123
  })
124
124
 
125
- it('导出 xlsx:sheet 名含 Excel 非法字符时 reject(sheet-core 写入校验,错误传播给调用方)', async () => {
125
+ it('导出 xlsx:sheet 名含 Excel 非法字符时 reject(引擎写入校验,错误传播给调用方)', async () => {
126
126
  const workbook = new Workbook()
127
127
  workbook.renameSheet('Sheet1', 'a:b')
128
128
  const ctx = createSheetContext(workbook.activeSheet, workbook)
@@ -1,5 +1,5 @@
1
- import { createRange } from '@veltra/sheet-core/core/address.js'
2
- import { Sheet } from '@veltra/sheet-core/core/sheet.js'
1
+ import { createRange } from 'infinitable/sheet'
2
+ import { Sheet } from 'infinitable/sheet'
3
3
  import { describe, expect, it, vi } from 'vite-plus/test'
4
4
 
5
5
  import { createSheetContext, MIN_ROW_COL_SIZE } from '../context'
@@ -1,6 +1,6 @@
1
- import type { CellRange } from '@veltra/sheet-core/core/address.js'
2
- import type { SetAxisStyleItem } from '@veltra/sheet-core/core/command/set-axis-style.js'
3
- import type { CellStylePatch } from '@veltra/sheet-core/core/style/types.js'
1
+ import type { CellRange } from 'infinitable/sheet'
2
+ import type { SetAxisStyleItem } from 'infinitable/sheet'
3
+ import type { CellStylePatch } from 'infinitable/sheet'
4
4
 
5
5
  /** 样式写入目标:整行 / 整列默认样式,或逐格 */
6
6
  export type SelectionStyleTarget = 'row' | 'col' | 'cell'
@@ -24,8 +24,8 @@ import {
24
24
  VerticalAlignRight,
25
25
  Wrap
26
26
  } from '@veltra/icons/normal'
27
- import { rangesEqual } from '@veltra/sheet-core/core/address.js'
28
- import type { HorizontalAlign, VerticalAlign } from '@veltra/sheet-core/core/style/types.js'
27
+ import { rangesEqual } from 'infinitable/sheet'
28
+ import type { HorizontalAlign, VerticalAlign } from 'infinitable/sheet'
29
29
 
30
30
  import type { SheetContext } from './context'
31
31
  import { registerTool } from './registry'
@@ -1,14 +1,14 @@
1
- import type { CellAddress, CellRange } from '@veltra/sheet-core/core/address.js'
2
- import type { CellData, CellValue } from '@veltra/sheet-core/core/cell-store.js'
3
- import type { HistoryState } from '@veltra/sheet-core/core/command/history.js'
4
- import type { ImageUpdateFields } from '@veltra/sheet-core/core/command/image.js'
5
- import type { SetCellValueItem } from '@veltra/sheet-core/core/command/set-cell-value.js'
6
- import type { ImageInput, SheetImage } from '@veltra/sheet-core/core/image.js'
7
- import type { CellInfo } from '@veltra/sheet-core/core/merge-manager.js'
8
- import type { SelectionState } from '@veltra/sheet-core/core/selection.js'
9
- import type { FrozenState, Sheet } from '@veltra/sheet-core/core/sheet.js'
10
- import type { CellStyle, CellStylePatch } from '@veltra/sheet-core/core/style/types.js'
11
- import type { Workbook } from '@veltra/sheet-core/core/workbook.js'
1
+ import type { CellAddress, CellRange } from 'infinitable/sheet'
2
+ import type { CellData, CellValue } from 'infinitable/sheet'
3
+ import type { HistoryState } from 'infinitable/sheet'
4
+ import type { ImageUpdateFields } from 'infinitable/sheet'
5
+ import type { SetCellValueItem } from 'infinitable/sheet'
6
+ import type { ImageInput, SheetImage } from 'infinitable/sheet'
7
+ import type { CellInfo } from 'infinitable/sheet'
8
+ import type { SelectionState } from 'infinitable/sheet'
9
+ import type { FrozenState, Sheet } from 'infinitable/sheet'
10
+ import type { CellStyle, CellStylePatch } from 'infinitable/sheet'
11
+ import type { Workbook } from 'infinitable/sheet'
12
12
 
13
13
  import { axisStyleItemsForRange, classifySelectionStyleTarget } from './apply-style'
14
14
 
@@ -1,12 +1,12 @@
1
1
  import { saveBlob } from '@cat-kit/fe'
2
- import { exportSheetCsv, exportWorkbookXlsx } from '@veltra/sheet-core/core/io/export.js'
3
- import type { Workbook } from '@veltra/sheet-core/core/workbook.js'
2
+ import { exportSheetCsv, exportWorkbookXlsx } from 'infinitable/sheet'
3
+ import type { Workbook } from 'infinitable/sheet'
4
4
 
5
5
  import type { SheetContext } from './context'
6
6
  import type { ExportWorkerPayload, ExportWorkerResponse } from './export.worker'
7
7
 
8
8
  /**
9
- * 大工作簿的 XLSX 导出(sheet-core 序列化 + ZIP 压缩为秒级同步重活)移入 Web Worker:
9
+ * 大工作簿的 XLSX 导出(引擎序列化 + ZIP 压缩为秒级同步重活)移入 Web Worker:
10
10
  * 主线程只采集快照(结构化克隆友好的纯数据,行高随 SheetSnapshot.rowHeights
11
11
  * 携带),序列化与压缩在 worker 线程进行。worker 不可用(极端环境 / 打包产物
12
12
  * 缺文件)回退主线程导出——与导入侧 parseXlsxAsync 同一模式。
@@ -55,7 +55,7 @@ async function exportWorkbookXlsxAsync(workbook: Workbook): Promise<Uint8Array>
55
55
  /**
56
56
  * 导出当前工作簿为 .xlsx(无 workbook 时空操作)。
57
57
  * 下载动作复用 @cat-kit/fe 的 saveBlob(#28:不再自研 Object URL + a.click)。
58
- * 导出侧 sheet-core 的 writeXlsx 会校验 sheet 名(Excel 非法字符 / 超长 / 保留名)并抛
58
+ * 导出侧引擎的 writeXlsx 会校验 sheet 名(Excel 非法字符 / 超长 / 保留名)并抛
59
59
  * InvalidArgumentError——失败经返回的 Promise 传播,调用方(导出面板)负责提示。
60
60
  */
61
61
  export async function exportWorkbookFile(ctx: SheetContext): Promise<void> {
@@ -1,6 +1,6 @@
1
1
  /// <reference lib="webworker" />
2
2
  /**
3
- * XLSX 导出 Worker:sheet-core exportWorkbookXlsx(模型序列化 + ZIP 压缩,
3
+ * XLSX 导出 Worker:infinitable/sheet exportWorkbookXlsx(模型序列化 + ZIP 压缩,
4
4
  * 大工作簿为秒级同步重活)移到独立线程,主线程保持空闲。
5
5
  *
6
6
  * 协议:主线程 postMessage({ sheets: [{ name, snapshot }], activeIndex })
@@ -12,7 +12,7 @@
12
12
  * 静态 import 在 vite dev 的 worker 上下文中会因模块图加载顺序导致
13
13
  * `Workbook is not defined`(实测)。
14
14
  */
15
- import type { SheetSnapshot } from '@veltra/sheet-core/core/sheet.js'
15
+ import type { SheetSnapshot } from 'infinitable/sheet'
16
16
 
17
17
  export interface ExportWorkerPayload {
18
18
  sheets: { name: string; snapshot: SheetSnapshot }[]
@@ -26,17 +26,14 @@ export interface ExportWorkerResponse {
26
26
  }
27
27
 
28
28
  self.onmessage = (e: MessageEvent<ExportWorkerPayload>): void => {
29
- void Promise.all([
30
- import('@veltra/sheet-core/core/io/export.js'),
31
- import('@veltra/sheet-core/core/workbook.js')
32
- ])
29
+ void Promise.all([import('infinitable/sheet'), import('infinitable/sheet')])
33
30
  .then(([{ exportWorkbookXlsx }, { Workbook }]) => {
34
31
  const wb = new Workbook()
35
32
  const sheets = e.data.sheets
36
33
  for (let i = 0; i < sheets.length; i++) {
37
34
  const { name, snapshot } = sheets[i]!
38
35
  // 首个 sheet 复用 Workbook 自带的默认表:先改名对齐(空名/重名保持原名,
39
- // 导出侧 sheet-core 的 writeXlsx 会校验表名合法性)
36
+ // 导出侧引擎的 writeXlsx 会校验表名合法性)
40
37
  const sheet = i === 0 ? wb.activeSheet : wb.addSheet(name)
41
38
  if (i === 0 && sheet.name !== name) wb.renameSheet(sheet.name, name)
42
39
  sheet.restore(snapshot)
@@ -1,4 +1,4 @@
1
- import { TypedEventEmitter } from '@veltra/sheet-core/core/events.js'
1
+ import { TypedEventEmitter } from 'infinitable/sheet'
2
2
 
3
3
  import type { SheetContext } from './context'
4
4
 
@@ -1,5 +1,6 @@
1
- import type { Sheet } from '@veltra/sheet-core/core/sheet.js'
2
- import type { Workbook } from '@veltra/sheet-core/core/workbook.js'
1
+ import type { DeconstructValue } from '@veltra/utils'
2
+ import type { Sheet } from 'infinitable/sheet'
3
+ import type { Workbook } from 'infinitable/sheet'
3
4
  import type {
4
5
  ResolveCellRenderer,
5
6
  ResolveCellStyleHook,
@@ -7,8 +8,7 @@ import type {
7
8
  SheetGrid,
8
9
  SheetGridEditorsOptions,
9
10
  SheetGridHeaderOptions
10
- } from '@veltra/sheet-core/grid'
11
- import type { DeconstructValue } from '@veltra/utils'
11
+ } from 'infinitable/sheet'
12
12
  import type { ComputedRef } from 'vue'
13
13
 
14
14
  import type { SheetContext } from '../tools/context'
@@ -31,7 +31,7 @@ export interface SheetProps {
31
31
  resolveCellStyle?: ResolveCellStyleHook
32
32
  /**
33
33
  * 动态单元格渲染(ADR-0004):视口布局时按格自定义渲染形态(返回引擎
34
- * `CellRenderer`,见 `@veltra/sheet-core/grid`),返回 undefined 回落默认渲染;
34
+ * `CellRenderer`,见 `infinitable/sheet`),返回 undefined 回落默认渲染;
35
35
  * 不写模型、不进快照
36
36
  */
37
37
  resolveCellRenderer?: ResolveCellRenderer
@@ -63,10 +63,18 @@ export interface SheetProps {
63
63
  */
64
64
  colResize?: boolean
65
65
  /**
66
- * 画布滚动条(透传 SheetGrid → 引擎内建):内容溢出的轴在画布右/下缘绘制滚动条
67
- * (可拖拽 / 点按跳转);缺省 true。变化触发网格重建(构造期选项)
66
+ * 滚动条(透传 SheetGrid → 引擎内建,构造期选项):false 整体关闭(不显示任何
67
+ * 滚动条);缺省 true 画布常驻档——引擎归一化 canvas always + reserve,滚动条
68
+ * 常驻画在画布内(reserve 只在画布内预留轨道,不占页面布局、不遮挡单元格)。
69
+ * 变化触发网格重建
68
70
  */
69
71
  scrollbar?: boolean
72
+ /**
73
+ * 滚动近端动态增长(透传 SheetGrid,构造期选项):滚动缓冲末端触到当前行列数
74
+ * 时模型与引擎同步扩容(引擎缺省 true);false 为固定尺寸网格——内容定尺寸的
75
+ * 报表 / 表单宿主置 false 后不再滚入空白增长区。变化触发网格重建
76
+ */
77
+ growOnScroll?: boolean
70
78
  }
71
79
 
72
80
  export interface SheetEmits {