@veltra/sheet 2.1.1 → 2.2.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 (202) hide show
  1. package/dist/components/report/binding-badge.js +76 -0
  2. package/dist/components/report/designer/cell-coords.js +46 -0
  3. package/dist/components/report/designer/col-widths.js +15 -0
  4. package/dist/components/report/designer/conditional-rules/helpers.js +139 -0
  5. package/dist/components/report/designer/drop-highlight-overlay.js +76 -0
  6. package/dist/components/report/designer/float-panel.js +385 -0
  7. package/dist/components/report/designer/role.js +17 -0
  8. package/dist/components/report/designer/rule-preview.js +33 -0
  9. package/dist/components/report/designer/rule-row.js +269 -0
  10. package/dist/components/report/designer/rules-dialog.js +135 -0
  11. package/dist/components/report/designer/topology-overlay.js +122 -0
  12. package/dist/components/report/designer/topology.js +64 -0
  13. package/dist/components/report/designer/use-grid-overlay.js +75 -0
  14. package/dist/components/report/designer-hub.js +177 -0
  15. package/dist/components/report/field-panel-helpers.js +33 -0
  16. package/dist/components/report/field-panel.js +132 -0
  17. package/dist/components/report/filter-bar.js +74 -0
  18. package/dist/components/report/hub-connection-form.js +145 -0
  19. package/dist/components/report/hub-dataset-editor.js +394 -0
  20. package/dist/components/report/report-designer.js +343 -0
  21. package/dist/components/report/report-viewer.js +111 -0
  22. package/dist/components/report/style.d.ts +17 -0
  23. package/dist/components/report/style.js +18 -0
  24. package/dist/components/report/style2.css +869 -0
  25. package/dist/components/report/use-report-designer.js +360 -0
  26. package/dist/components/report/use-report-viewer.js +50 -0
  27. package/dist/{vue → components/sheet}/formula-bar.js +1 -1
  28. package/dist/{vue → components/sheet}/formula-suggest-list.js +1 -1
  29. package/dist/{vue → components/sheet}/import-file.js +1 -1
  30. package/dist/{vue → components/sheet}/insert-count-menu-item.js +1 -1
  31. package/dist/{vue → components/sheet}/insert-image.js +1 -1
  32. package/dist/{vue → components/sheet}/popup-helpers.js +1 -1
  33. package/dist/{vue → components/sheet}/popups/border-popup.js +1 -1
  34. package/dist/{vue → components/sheet}/popups/border-preset-glyph.js +1 -1
  35. package/dist/{vue → components/sheet}/popups/export-popup.js +2 -2
  36. package/dist/{vue → components/sheet}/popups/fill-color-popup.js +1 -1
  37. package/dist/{vue → components/sheet}/popups/find-popup.js +1 -1
  38. package/dist/{vue → components/sheet}/popups/font-color-popup.js +1 -1
  39. package/dist/{vue → components/sheet}/popups/font-size-popup.js +1 -1
  40. package/dist/{vue → components/sheet}/popups/import.worker.d.ts +1 -1
  41. package/dist/{vue → components/sheet}/popups/import.worker.js +1 -1
  42. package/dist/{vue → components/sheet}/popups/insert-image-popup.js +1 -1
  43. package/dist/{vue → components/sheet}/sheet-context-menu.js +1 -1
  44. package/dist/{vue → components/sheet}/sheet-tabs.js +1 -1
  45. package/dist/{vue → components/sheet}/sheet-toolbar.js +1 -1
  46. package/dist/{vue → components/sheet}/sheet.js +8 -1
  47. package/dist/{vue → components/sheet}/use-find-replace.js +1 -1
  48. package/dist/{vue → components/sheet}/use-formula-ref-select.js +1 -1
  49. package/dist/{vue → components/sheet}/use-sheet-grid.js +10 -2
  50. package/dist/{vue → components/sheet}/use-sheet-state.js +3 -3
  51. package/dist/{vue → components/sheet}/use-sheet-tabs-bar.js +1 -1
  52. package/dist/{vue → components/sheet}/use-tool-groups.js +2 -2
  53. package/dist/{vue → components/sheet}/use-tool-popup.js +2 -2
  54. package/dist/{vue → components/sheet}/use-toolbar-scroll.js +1 -1
  55. package/dist/index.d.ts +17 -3
  56. package/dist/index.js +13 -3
  57. package/dist/report/binding.d.ts +45 -0
  58. package/dist/report/binding.js +175 -0
  59. package/dist/report/connector.d.ts +66 -0
  60. package/dist/report/connector.js +159 -0
  61. package/dist/report/export-xlsx.d.ts +19 -0
  62. package/dist/report/export-xlsx.js +95 -0
  63. package/dist/report/filter-bar.d.ts +10 -0
  64. package/dist/report/filter-bar.js +31 -0
  65. package/dist/report/index.d.ts +12 -0
  66. package/dist/report/params.d.ts +13 -0
  67. package/dist/report/params.js +61 -0
  68. package/dist/report/render/aggregate.js +157 -0
  69. package/dist/report/render/builder.d.ts +12 -0
  70. package/dist/report/render/builder.js +139 -0
  71. package/dist/report/render/coordinate.d.ts +25 -0
  72. package/dist/report/render/coordinate.js +733 -0
  73. package/dist/report/render/index.d.ts +14 -0
  74. package/dist/report/render/index.js +21 -0
  75. package/dist/report/render/style-resolver.js +50 -0
  76. package/dist/report/render/template-index.d.ts +24 -0
  77. package/dist/report/render/template-index.js +137 -0
  78. package/dist/report/rules/evaluate.d.ts +25 -0
  79. package/dist/report/rules/evaluate.js +82 -0
  80. package/dist/report/rules/index.d.ts +2 -0
  81. package/dist/report/template.d.ts +59 -0
  82. package/dist/report/template.js +80 -0
  83. package/dist/report/types.d.ts +85 -0
  84. package/dist/tools/context.d.ts +1 -1
  85. package/dist/types/index.d.ts +3 -2
  86. package/dist/types/report-designer.d.ts +36 -0
  87. package/dist/types/report-viewer.d.ts +38 -0
  88. package/dist/types/sheet.d.ts +17 -1
  89. package/package.json +3 -5
  90. package/src/components/report/__test__/conditional-rules-helpers.test.ts +87 -0
  91. package/src/components/report/__test__/field-panel-helpers.test.ts +65 -0
  92. package/src/components/report/__test__/float-panel-position.test.ts +45 -0
  93. package/src/components/report/__test__/report-designer.test.ts +388 -0
  94. package/src/components/report/__test__/report-viewer.test.ts +334 -0
  95. package/src/components/report/__test__/topology.test.ts +143 -0
  96. package/src/components/report/__test__/use-report-designer.test.ts +565 -0
  97. package/src/components/report/binding-badge.ts +73 -0
  98. package/src/components/report/designer/cell-coords.ts +94 -0
  99. package/src/components/report/designer/col-widths.ts +33 -0
  100. package/src/components/report/designer/conditional-rules/helpers.ts +186 -0
  101. package/src/components/report/designer/drop-highlight-overlay.vue +74 -0
  102. package/src/components/report/designer/float-panel.vue +387 -0
  103. package/src/components/report/designer/role.ts +32 -0
  104. package/src/components/report/designer/rule-preview.vue +40 -0
  105. package/src/components/report/designer/rule-row.vue +252 -0
  106. package/src/components/report/designer/rules-dialog.vue +126 -0
  107. package/src/components/report/designer/topology-overlay.vue +127 -0
  108. package/src/components/report/designer/topology.ts +124 -0
  109. package/src/components/report/designer/use-grid-overlay.ts +113 -0
  110. package/src/components/report/designer-hub.vue +198 -0
  111. package/src/components/report/field-panel-helpers.ts +44 -0
  112. package/src/components/report/field-panel.vue +136 -0
  113. package/src/components/report/filter-bar.vue +77 -0
  114. package/src/components/report/hub-connection-form.vue +124 -0
  115. package/src/components/report/hub-dataset-editor.vue +369 -0
  116. package/src/components/report/index.ts +2 -0
  117. package/src/components/report/report-designer.vue +356 -0
  118. package/src/components/report/report-viewer.vue +128 -0
  119. package/src/components/report/style-designer.scss +583 -0
  120. package/src/components/report/style-hub.scss +292 -0
  121. package/src/components/report/style-viewer.scss +104 -0
  122. package/src/components/report/style.scss +3 -0
  123. package/src/components/report/style.ts +20 -0
  124. package/src/components/report/use-report-designer.ts +547 -0
  125. package/src/components/report/use-report-viewer.ts +79 -0
  126. package/src/{vue → components/sheet}/__test__/formula-bar.test.ts +37 -18
  127. package/src/{vue → components/sheet}/__test__/insert-image-popup.test.ts +1 -1
  128. package/src/{vue → components/sheet}/__test__/insert-image.test.ts +1 -1
  129. package/src/{vue → components/sheet}/__test__/sheet-component.test.ts +40 -3
  130. package/src/{vue → components/sheet}/__test__/sheet-context-menu.test.ts +1 -1
  131. package/src/{vue → components/sheet}/formula-bar.vue +1 -1
  132. package/src/{vue → components/sheet}/insert-image.ts +1 -1
  133. package/src/{vue → components/sheet}/popup-helpers.ts +1 -1
  134. package/src/{vue → components/sheet}/popups/border-popup.vue +1 -1
  135. package/src/{vue → components/sheet}/popups/export-popup.vue +2 -2
  136. package/src/{vue → components/sheet}/popups/fill-color-popup.vue +1 -1
  137. package/src/{vue → components/sheet}/popups/find-popup.vue +1 -1
  138. package/src/{vue → components/sheet}/popups/font-color-popup.vue +1 -1
  139. package/src/{vue → components/sheet}/popups/font-size-popup.vue +1 -1
  140. package/src/{vue → components/sheet}/popups/insert-image-popup.vue +1 -1
  141. package/src/{vue → components/sheet}/sheet-context-menu.ts +2 -2
  142. package/src/{vue → components/sheet}/sheet-toolbar.vue +2 -2
  143. package/src/{vue → components/sheet}/sheet.vue +4 -3
  144. package/src/{vue → components/sheet}/use-find-replace.ts +1 -1
  145. package/src/{vue → components/sheet}/use-sheet-grid.ts +7 -3
  146. package/src/{vue → components/sheet}/use-sheet-state.ts +3 -3
  147. package/src/{vue → components/sheet}/use-tool-groups.ts +2 -2
  148. package/src/{vue → components/sheet}/use-tool-popup.ts +2 -2
  149. package/src/index.ts +24 -188
  150. package/src/report/__test__/binding.test.ts +218 -0
  151. package/src/report/__test__/connector.test.ts +218 -0
  152. package/src/report/__test__/export-xlsx.test.ts +118 -0
  153. package/src/report/__test__/filter-bar.test.ts +58 -0
  154. package/src/report/__test__/params.test.ts +156 -0
  155. package/src/report/__test__/render.test.ts +728 -0
  156. package/src/report/__test__/rules.test.ts +131 -0
  157. package/src/report/__test__/template.test.ts +355 -0
  158. package/src/report/binding.ts +243 -0
  159. package/src/report/connector.ts +205 -0
  160. package/src/report/export-xlsx.ts +118 -0
  161. package/src/report/filter-bar.ts +36 -0
  162. package/src/report/index.ts +13 -0
  163. package/src/report/params.ts +96 -0
  164. package/src/report/render/__test__/aggregate.test.ts +16 -0
  165. package/src/report/render/__test__/coordinate.test.ts +405 -0
  166. package/src/report/render/aggregate.ts +240 -0
  167. package/src/report/render/builder.ts +211 -0
  168. package/src/report/render/coordinate.ts +1239 -0
  169. package/src/report/render/index.ts +30 -0
  170. package/src/report/render/style-resolver.ts +68 -0
  171. package/src/report/render/template-index.ts +200 -0
  172. package/src/report/rules/evaluate.ts +113 -0
  173. package/src/report/rules/index.ts +7 -0
  174. package/src/report/template.ts +141 -0
  175. package/src/report/types.ts +96 -0
  176. package/src/tools/builtin.ts +2 -2
  177. package/src/types/index.ts +2 -6
  178. package/src/types/report-designer.ts +36 -0
  179. package/src/types/report-viewer.ts +37 -0
  180. package/src/types/sheet.ts +22 -1
  181. /package/dist/{vue → components/sheet}/style.d.ts +0 -0
  182. /package/dist/{vue → components/sheet}/style.js +0 -0
  183. /package/dist/{vue → components/sheet}/style2.css +0 -0
  184. /package/dist/{vue → components/sheet}/use-formula-suggest.js +0 -0
  185. /package/src/{vue → components/sheet}/__test__/import-file.test.ts +0 -0
  186. /package/src/{vue → components/sheet}/__test__/insert-count-menu-item.test.ts +0 -0
  187. /package/src/{vue → components/sheet}/__test__/use-formula-ref-select.test.ts +0 -0
  188. /package/src/{vue → components/sheet}/__test__/use-formula-suggest.test.ts +0 -0
  189. /package/src/{vue → components/sheet}/formula-suggest-list.vue +0 -0
  190. /package/src/{vue → components/sheet}/import-file.ts +0 -0
  191. /package/src/{vue → components/sheet}/index.ts +0 -0
  192. /package/src/{vue → components/sheet}/insert-count-menu-item.vue +0 -0
  193. /package/src/{vue → components/sheet}/parsing.ts +0 -0
  194. /package/src/{vue → components/sheet}/popups/border-preset-glyph.vue +0 -0
  195. /package/src/{vue → components/sheet}/popups/import.worker.ts +0 -0
  196. /package/src/{vue → components/sheet}/sheet-tabs.vue +0 -0
  197. /package/src/{vue → components/sheet}/style.scss +0 -0
  198. /package/src/{vue → components/sheet}/style.ts +0 -0
  199. /package/src/{vue → components/sheet}/use-formula-ref-select.ts +0 -0
  200. /package/src/{vue → components/sheet}/use-formula-suggest.ts +0 -0
  201. /package/src/{vue → components/sheet}/use-sheet-tabs-bar.ts +0 -0
  202. /package/src/{vue → components/sheet}/use-toolbar-scroll.ts +0 -0
@@ -1,10 +1,12 @@
1
+ import { parseRange } from '@veltra/sheet-core/core/address'
1
2
  import { Workbook } from '@veltra/sheet-core/core/workbook'
2
- import { ListTable } from '@visactor/vtable'
3
3
  import { afterEach, describe, expect, it } from 'vitest'
4
4
  import { createApp, h, nextTick, type App } from 'vue'
5
5
 
6
- import { USheet } from '../../index'
7
- import type { SheetExposed } from '../../types'
6
+ import { USheet } from '../../../index'
7
+ import { createSheetContext } from '../../../tools/context'
8
+ import type { SheetExposed } from '../../../types'
9
+ import UFormulaBar from '../formula-bar.vue'
8
10
 
9
11
  const apps: App[] = []
10
12
  const containers: HTMLElement[] = []
@@ -32,6 +34,26 @@ function mount(
32
34
  return { app, el }
33
35
  }
34
36
 
37
+ function mountFormulaBar(sheet: Workbook['activeSheet']) {
38
+ const el = document.createElement('div')
39
+ document.body.appendChild(el)
40
+ containers.push(el)
41
+ const exposed: { value: InstanceType<typeof UFormulaBar> | undefined } = { value: undefined }
42
+ const app = createApp({
43
+ render: () =>
44
+ h(UFormulaBar, {
45
+ sheet,
46
+ context: createSheetContext(sheet),
47
+ ref: (value: unknown) => {
48
+ exposed.value = value as InstanceType<typeof UFormulaBar> | undefined
49
+ }
50
+ })
51
+ })
52
+ app.mount(el)
53
+ apps.push(app)
54
+ return { el, exposed }
55
+ }
56
+
35
57
  function createWorkbook() {
36
58
  const workbook = new Workbook()
37
59
  workbook.addSheet('Sheet2')
@@ -397,15 +419,16 @@ describe('USheet 公式栏:函数补全与引用选择', () => {
397
419
  expect(sheet.getCellData({ row: 2, col: 0 })).toBeUndefined()
398
420
  expect(input.value).toBe('=SUM(')
399
421
 
400
- // 与 grid 选区测试同路径:selectCells 设视觉选区 + fire SELECTED_CELL
401
- const table = exposed.value!.getGrid()!.getTable()
402
- table.selectCells([{ start: { col: 1, row: 1 }, end: { col: 2, row: 2 } }])
403
- table.fireListeners(ListTable.EVENT_TYPE.SELECTED_CELL, { col: 2, row: 2 })
422
+ // 网格选区拦截 → handleRefSelect 路径(VTable 时序见 sheet-core selection-debug)
423
+ const { el: barEl, exposed: barExposed } = mountFormulaBar(sheet)
404
424
  await nextTick()
405
- expect(input.value).toBe('=SUM(A1:B2')
406
- expect(input.selectionStart).toBe('=SUM(A1:B2'.length)
407
- // intercept 不写模型选区
408
- expect(sheet.getSelection().activeCell).toEqual({ row: 2, col: 0 })
425
+ setFxText(barEl, '=SUM(')
426
+ await nextTick()
427
+ barExposed.value!.handleRefSelect(parseRange('A1:B2'))
428
+ await nextTick()
429
+ const barInput = fxInput(barEl)
430
+ expect(barInput.value).toBe('=SUM(A1:B2')
431
+ expect(barInput.selectionStart).toBe('=SUM(A1:B2'.length)
409
432
 
410
433
  // 非引用选择场景失焦提交
411
434
  setFxText(el, 'plain')
@@ -436,19 +459,15 @@ describe('USheet 公式栏:函数补全与引用选择', () => {
436
459
  })
437
460
 
438
461
  it('连续引用选择:=A1+ 后再插入 B1', async () => {
439
- const workbook = new Workbook()
440
- const sheet = workbook.activeSheet
441
- const exposed: { value: SheetExposed | undefined } = { value: undefined }
442
- const { el } = mount(() => ({ workbook, rows: 20, cols: 8 }), exposed)
462
+ const sheet = new Workbook().activeSheet
463
+ const { el, exposed } = mountFormulaBar(sheet)
443
464
  await nextTick()
444
465
  sheet.selectCell({ row: 2, col: 0 })
445
466
  await nextTick()
446
467
 
447
468
  setFxText(el, '=A1+')
448
469
  await nextTick()
449
- const table = exposed.value!.getGrid()!.getTable()
450
- table.selectCells([{ start: { col: 2, row: 1 }, end: { col: 2, row: 1 } }])
451
- table.fireListeners(ListTable.EVENT_TYPE.SELECTED_CELL, { col: 2, row: 1 })
470
+ exposed.value!.handleRefSelect(parseRange('B1'))
452
471
  await nextTick()
453
472
  expect(fxInput(el).value).toBe('=A1+B1')
454
473
  })
@@ -2,7 +2,7 @@ import { Sheet } from '@veltra/sheet-core/core/sheet'
2
2
  import { afterEach, describe, expect, it, vi } from 'vitest'
3
3
  import { createApp, h, type App } from 'vue'
4
4
 
5
- import { createSheetContext } from '../../tools/context'
5
+ import { createSheetContext } from '../../../tools/context'
6
6
  import USheetInsertImagePopup from '../popups/insert-image-popup.vue'
7
7
 
8
8
  const mocks = vi.hoisted(() => {
@@ -1,7 +1,7 @@
1
1
  import { Sheet } from '@veltra/sheet-core/core/sheet'
2
2
  import { afterEach, describe, expect, it, vi } from 'vitest'
3
3
 
4
- import { createSheetContext } from '../../tools/context'
4
+ import { createSheetContext } from '../../../tools/context'
5
5
  import {
6
6
  INSERT_IMAGE_ACCEPT,
7
7
  insertImageFromFile,
@@ -2,9 +2,9 @@ import { Workbook } from '@veltra/sheet-core/core/workbook'
2
2
  import { afterEach, describe, expect, it, vi } from 'vitest'
3
3
  import { createApp, h, nextTick, ref, type App } from 'vue'
4
4
 
5
- import { USheet } from '../../index'
6
- import { registerTool, unregisterTool } from '../../tools/registry'
7
- import type { SheetExposed } from '../../types'
5
+ import { USheet } from '../../../index'
6
+ import { registerTool, unregisterTool } from '../../../tools/registry'
7
+ import type { SheetExposed } from '../../../types'
8
8
 
9
9
  const apps: App[] = []
10
10
  const containers: HTMLElement[] = []
@@ -258,6 +258,43 @@ describe('USheet 组件', () => {
258
258
  expect(gridAfter).not.toBe(gridBefore)
259
259
  })
260
260
 
261
+ it('resolveCellStyle prop 传入 SheetGrid 视口渲染', async () => {
262
+ const workbook = createWorkbook()
263
+ const sheet = workbook.activeSheet
264
+ const exposed: { value: SheetExposed | undefined } = { value: undefined }
265
+ mount(
266
+ () => ({
267
+ workbook,
268
+ rows: 10,
269
+ cols: 6,
270
+ resolveCellStyle: (
271
+ addr: { row: number; col: number },
272
+ baseStyle?: { fill?: { color: string } }
273
+ ) => {
274
+ if (addr.row === 1 && addr.col === 1) {
275
+ return { ...baseStyle, fill: { color: '#FFE0E0' } }
276
+ }
277
+ return baseStyle
278
+ }
279
+ }),
280
+ exposed
281
+ )
282
+ await nextTick()
283
+
284
+ const addr = { row: 1, col: 1 }
285
+ sheet.setCellStyle({ start: addr, end: addr }, { fill: { color: '#CCCCCC' } })
286
+ await nextTick()
287
+
288
+ const table = exposed.value?.getGrid()?.getTable()
289
+ expect(table).toBeDefined()
290
+ const column = table!.getBodyColumnDefine(2, 2) as {
291
+ style?: (arg: { row: number; col: number; table: unknown }) => Record<string, unknown>
292
+ }
293
+ const rendered = column.style!({ row: 2, col: 2, table })
294
+ expect(rendered.bgColor).toBe('#FFE0E0')
295
+ expect(sheet.getCellStyle(addr)?.fill?.color).toBe('#CCCCCC')
296
+ })
297
+
261
298
  it('workbook prop 变更:tabs 与 grid 切到新工作簿', async () => {
262
299
  const workbook1 = createWorkbook()
263
300
  const workbook2 = new Workbook()
@@ -2,7 +2,7 @@ import { createRange } from '@veltra/sheet-core/core/address'
2
2
  import { Sheet } from '@veltra/sheet-core/core/sheet'
3
3
  import { describe, expect, it } from 'vitest'
4
4
 
5
- import { createSheetContext } from '../../tools/context'
5
+ import { createSheetContext } from '../../../tools/context'
6
6
  import {
7
7
  buildBodyMenus,
8
8
  buildColHeaderMenus,
@@ -86,7 +86,7 @@ import {
86
86
  watch
87
87
  } from 'vue'
88
88
 
89
- import type { SheetContext } from '../tools/context'
89
+ import type { SheetContext } from '../../tools/context'
90
90
  import UFormulaSuggestList from './formula-suggest-list.vue'
91
91
  import { insertRefText, isRefSelectContext } from './use-formula-ref-select'
92
92
  import {
@@ -1,7 +1,7 @@
1
1
  import { message } from '@veltra/desktop'
2
2
  import type { SheetImageType } from '@veltra/sheet-core/core/image'
3
3
 
4
- import type { SheetContext } from '../tools/context'
4
+ import type { SheetContext } from '../../tools/context'
5
5
 
6
6
  /** 文件选择 accept(工具栏弹层与右键菜单共用;不用裸 image/*) */
7
7
  export const INSERT_IMAGE_ACCEPT = '.png,.jpg,.jpeg,.gif,.svg,.webp'
@@ -2,7 +2,7 @@ import type { CellRange } from '@veltra/sheet-core/core/address'
2
2
  import type { BorderPreset } from '@veltra/sheet-core/core/style/border-presets'
3
3
  import { BORDER_STYLE_WIDTH, type BorderLineStyle } from '@veltra/sheet-core/core/style/types'
4
4
 
5
- import type { SheetContext } from '../tools/context'
5
+ import type { SheetContext } from '../../tools/context'
6
6
 
7
7
  /** 当前选区(ranges[0] 优先;无区域选区时用活动格单格) */
8
8
  export function currentRange(context: SheetContext): CellRange | null {
@@ -45,7 +45,7 @@ import {
45
45
  import { bem } from '@veltra/utils'
46
46
  import { ref } from 'vue'
47
47
 
48
- import type { SheetContext } from '../../tools/context'
48
+ import type { SheetContext } from '../../../tools/context'
49
49
  import {
50
50
  BORDER_LINE_STYLES,
51
51
  BORDER_LINE_TITLES,
@@ -13,8 +13,8 @@
13
13
  import { message } from '@veltra/desktop'
14
14
  import { bem } from '@veltra/utils'
15
15
 
16
- import type { SheetContext } from '../../tools/context'
17
- import { exportSheetCsvFile, exportWorkbookFile } from '../../tools/download'
16
+ import type { SheetContext } from '../../../tools/context'
17
+ import { exportSheetCsvFile, exportWorkbookFile } from '../../../tools/download'
18
18
 
19
19
  defineOptions({ name: 'USheetExportPopup' })
20
20
 
@@ -6,7 +6,7 @@
6
6
  import { UPalette } from '@veltra/desktop'
7
7
  import { onMounted, ref } from 'vue'
8
8
 
9
- import type { SheetContext } from '../../tools/context'
9
+ import type { SheetContext } from '../../../tools/context'
10
10
  import { currentRange } from '../popup-helpers'
11
11
 
12
12
  defineOptions({ name: 'USheetFillColorPopup' })
@@ -72,7 +72,7 @@ import { UInput } from '@veltra/desktop'
72
72
  import type { Sheet } from '@veltra/sheet-core/core/sheet'
73
73
  import { bem } from '@veltra/utils'
74
74
 
75
- import type { SheetContext } from '../../tools/context'
75
+ import type { SheetContext } from '../../../tools/context'
76
76
  import { useFindReplace } from '../use-find-replace'
77
77
 
78
78
  defineOptions({ name: 'USheetFindPopup' })
@@ -6,7 +6,7 @@
6
6
  import { UPalette } from '@veltra/desktop'
7
7
  import { onMounted, ref } from 'vue'
8
8
 
9
- import type { SheetContext } from '../../tools/context'
9
+ import type { SheetContext } from '../../../tools/context'
10
10
  import { currentRange } from '../popup-helpers'
11
11
 
12
12
  defineOptions({ name: 'USheetFontColorPopup' })
@@ -20,7 +20,7 @@ import { UScroll } from '@veltra/desktop'
20
20
  import { bem } from '@veltra/utils'
21
21
  import { onMounted, ref } from 'vue'
22
22
 
23
- import type { SheetContext } from '../../tools/context'
23
+ import type { SheetContext } from '../../../tools/context'
24
24
  import { currentRange } from '../popup-helpers'
25
25
 
26
26
  defineOptions({ name: 'USheetFontSizePopup' })
@@ -15,7 +15,7 @@
15
15
  import { UFilePicker } from '@veltra/desktop'
16
16
  import { bem } from '@veltra/utils'
17
17
 
18
- import type { SheetContext } from '../../tools/context'
18
+ import type { SheetContext } from '../../../tools/context'
19
19
  import { INSERT_IMAGE_ACCEPT, insertImageFromFile } from '../insert-image'
20
20
 
21
21
  defineOptions({ name: 'USheetInsertImagePopup' })
@@ -2,8 +2,8 @@ import type { ContextmenuItem } from '@veltra/desktop'
2
2
  import { createRange, type CellAddress, type CellRange } from '@veltra/sheet-core/core/address'
3
3
  import { defineComponent, h } from 'vue'
4
4
 
5
- import type { SheetContext } from '../tools/context'
6
- import { defaultToolRegistry } from '../tools/registry'
5
+ import type { SheetContext } from '../../tools/context'
6
+ import { defaultToolRegistry } from '../../tools/registry'
7
7
  import InsertCountMenuItem from './insert-count-menu-item.vue'
8
8
  import { pickAndInsertImage } from './insert-image'
9
9
 
@@ -61,8 +61,8 @@ import { ArrowLeft, ArrowRight } from '@veltra/icons/normal'
61
61
  import { bem } from '@veltra/utils'
62
62
  import { toRef, useTemplateRef } from 'vue'
63
63
 
64
- import type { SheetTool } from '../tools/registry'
65
- import type { ToolGroupView } from '../use-tool-groups'
64
+ import type { SheetTool } from '../../tools/registry'
65
+ import type { ToolGroupView } from './use-tool-groups'
66
66
  import { useToolbarScroll } from './use-toolbar-scroll'
67
67
 
68
68
  defineOptions({ name: 'USheetToolbar' })
@@ -77,8 +77,8 @@ import { UDropdown } from '@veltra/desktop'
77
77
  import { bem } from '@veltra/utils'
78
78
  import { computed, ref, useTemplateRef, watch } from 'vue'
79
79
 
80
- import type { SheetTool } from '../tools/registry'
81
- import type { SheetEmits, SheetProps, _SheetExposed } from '../types'
80
+ import type { SheetTool } from '../../tools/registry'
81
+ import type { SheetEmits, SheetProps, _SheetExposed } from '../../types'
82
82
  import UFormulaBar from './formula-bar.vue'
83
83
  import { pickAndImportFile } from './import-file'
84
84
  import USheetBorderPopup from './popups/border-popup.vue'
@@ -102,7 +102,8 @@ const props = withDefaults(defineProps<SheetProps>(), {
102
102
  cols: 26,
103
103
  showToolbar: true,
104
104
  showFormulaBar: true,
105
- showTabs: true
105
+ showTabs: true,
106
+ readonly: false
106
107
  })
107
108
 
108
109
  const emit = defineEmits<SheetEmits>()
@@ -14,7 +14,7 @@ import {
14
14
  import type { Sheet } from '@veltra/sheet-core/core/sheet'
15
15
  import { computed, ref, shallowRef, watch } from 'vue'
16
16
 
17
- import type { SheetContext } from '../tools/context'
17
+ import type { SheetContext } from '../../tools/context'
18
18
 
19
19
  interface UseFindReplaceOptions {
20
20
  /** 目标 sheet(弹层存活期间固定;tab 切换会关闭并销毁弹层) */
@@ -4,8 +4,8 @@ import type { Sheet } from '@veltra/sheet-core/core/sheet'
4
4
  import { SheetGrid, type SheetGridContextMenuInfo } from '@veltra/sheet-core/grid/sheet-grid'
5
5
  import { onBeforeUnmount, onMounted, watch } from 'vue'
6
6
 
7
- import type { SheetContext } from '../tools/context'
8
- import type { SheetProps } from '../types'
7
+ import type { SheetContext } from '../../tools/context'
8
+ import type { SheetProps } from '../../types'
9
9
  import {
10
10
  buildBodyMenus,
11
11
  buildColHeaderMenus,
@@ -114,6 +114,10 @@ export function useSheetGrid(options: UseSheetGridOptions) {
114
114
  sheet,
115
115
  rows: props.rows,
116
116
  cols: props.cols,
117
+ readonly: props.readonly,
118
+ resolveDisplayValue: props.resolveDisplayValue,
119
+ resolveCellStyle: props.resolveCellStyle,
120
+ resolveCellRenderer: props.resolveCellRenderer,
117
121
  onContextMenu: handleContextMenu,
118
122
  onEditStart: (addr) => formulaBarRef.value?.mirrorGridEdit(addr),
119
123
  onEditEnd: (addr) => formulaBarRef.value?.exitMirror(addr),
@@ -233,7 +237,7 @@ export function useSheetGrid(options: UseSheetGridOptions) {
233
237
 
234
238
  onMounted(activateGrid)
235
239
 
236
- watch(() => [props.rows, props.cols], rebuildGrid)
240
+ watch(() => [props.rows, props.cols, props.readonly], rebuildGrid)
237
241
 
238
242
  onBeforeUnmount(() => {
239
243
  invalidateAll()
@@ -2,9 +2,9 @@ import type { Sheet } from '@veltra/sheet-core/core/sheet'
2
2
  import { Workbook } from '@veltra/sheet-core/core/workbook'
3
3
  import { computed, onBeforeUnmount, onMounted, ref, shallowRef, watch } from 'vue'
4
4
 
5
- import { createSheetContext } from '../tools/context'
6
- import { defaultToolRegistry } from '../tools/registry'
7
- import type { SheetProps } from '../types'
5
+ import { createSheetContext } from '../../tools/context'
6
+ import { defaultToolRegistry } from '../../tools/registry'
7
+ import type { SheetProps } from '../../types'
8
8
 
9
9
  /**
10
10
  * useSheetState 与宿主组件的协作钩子。
@@ -1,7 +1,7 @@
1
1
  import { computed, type ComputedRef, type Ref } from 'vue'
2
2
 
3
- import type { SheetContext } from '../tools/context'
4
- import { defaultToolRegistry, type SheetTool } from '../tools/registry'
3
+ import type { SheetContext } from '../../tools/context'
4
+ import { defaultToolRegistry, type SheetTool } from '../../tools/registry'
5
5
 
6
6
  /** 工具栏按钮视图模型 */
7
7
  export interface ToolGroupItem {
@@ -1,7 +1,7 @@
1
1
  import { onBeforeUnmount, onMounted, shallowRef } from 'vue'
2
2
 
3
- import type { SheetContext } from '../tools/context'
4
- import { defaultToolRegistry, type SheetTool } from '../tools/registry'
3
+ import type { SheetContext } from '../../tools/context'
4
+ import { defaultToolRegistry, type SheetTool } from '../../tools/registry'
5
5
 
6
6
  /** 模板 ref 只读形态 */
7
7
  type ElRef = { readonly value: HTMLElement | null | undefined }
package/src/index.ts CHANGED
@@ -3,192 +3,10 @@
3
3
  // 无头场景不涉及
4
4
  import './tools/builtin'
5
5
 
6
- // 数据模型 / 渲染内核(原 src/core、src/grid)已迁至 @veltra/sheet-core,
7
- // 下方 core/grid 来源的导出全部为其主入口白名单的 re-export(公开 API 不变)。
8
- // 聚合导出为**公开 API 白名单**:仅测试引用的内部符号(如 rangeContainsRange、
9
- // mergeCellStyle、shiftFormulaRefs、io 转换函数、grid 样式映射、normalizeStyle、
10
- // ToolRegistry 类等,见 #31)不在此导出,测试一律深导入 @veltra/sheet-core 子路径。
11
- // 类成员方法(Sheet.setCell / setCellStyles、CellStore.setCellValue 等)随类整体
12
- // 导出,属内部实现细节,见 packages/sheet/AGENTS.md「核心语义」注。
13
-
14
- export {
15
- cellKey,
16
- colIndexToName,
17
- colNameToIndex,
18
- parseAddress,
19
- formatAddress,
20
- createRange,
21
- parseRange,
22
- formatRange,
23
- rangesEqual,
24
- rangesIntersect,
25
- rangeContainsAddress,
26
- boundingBox,
27
- iterateRange,
28
- type CellAddress,
29
- type CellRange
30
- } from '@veltra/sheet-core'
31
-
32
- export {
33
- NUMERIC_TEXT_RE,
34
- normalizeInputValue,
35
- inferCellType,
36
- isEmptyCellData,
37
- cellDataEqual,
38
- CellStore,
39
- type CellType,
40
- type CellValue,
41
- type CellData,
42
- type CellSnapshotItem
43
- } from '@veltra/sheet-core'
44
-
45
- export {
46
- computeFillTargetRange,
47
- generateFill,
48
- type FillDirection,
49
- type GenerateFillOptions
50
- } from '@veltra/sheet-core'
51
-
52
- export {
53
- findAll,
54
- findNext,
55
- findNextFrom,
56
- findPrev,
57
- findPrevFrom,
58
- type FindOptions,
59
- type FindMatch
60
- } from '@veltra/sheet-core'
61
-
62
- export {
63
- MergeManager,
64
- type MergedCellKind,
65
- type CellInfo,
66
- type MergeResult
67
- } from '@veltra/sheet-core'
68
-
69
- export { SelectionModel, type SelectionState } from '@veltra/sheet-core'
70
-
71
- export { Sheet, type FrozenState, type SheetSnapshot, type SheetEvents } from '@veltra/sheet-core'
72
-
73
- export {
74
- createImageId,
75
- cloneImageAnchor,
76
- cloneSheetImage,
77
- type SheetImageType,
78
- type SheetImageAnchor,
79
- type SheetImage,
80
- type ImageInput
81
- } from '@veltra/sheet-core'
82
-
83
- export {
84
- BORDER_SIDES,
85
- BORDER_STYLE_WIDTH,
86
- BORDER_EDGE_DEFAULTS,
87
- FONT_STYLE_KEYS,
88
- ALIGN_STYLE_KEYS,
89
- type BorderLineStyle,
90
- type BorderSide,
91
- type BorderEdge,
92
- type HorizontalAlign,
93
- type VerticalAlign,
94
- type CellFont,
95
- type CellAlign,
96
- type CellStyle,
97
- type StyleId,
98
- type CellStylePatch
99
- } from '@veltra/sheet-core'
100
-
101
- export { StylePool } from '@veltra/sheet-core'
102
-
103
- export {
104
- buildBorderPresetItems,
105
- type BorderPreset,
106
- type BorderPresetItem
107
- } from '@veltra/sheet-core'
108
-
109
- export { Workbook, type WorkbookEvents } from '@veltra/sheet-core'
110
-
111
- export {
112
- HistoryManager,
113
- type HistoryState,
114
- type PatchDirection,
115
- type CellPatch,
116
- type MergePatch,
117
- type StructureChange,
118
- type StructurePatch,
119
- type SnapshotPatch,
120
- type ImagePatch,
121
- type Patch,
122
- type Mutation,
123
- type CommandResult,
124
- type CommandContext,
125
- type Command,
126
- type SetCellValueItem,
127
- type SetCellValueParams,
128
- SetCellValueCommand,
129
- type SetCellFormulaParams,
130
- SetCellFormulaCommand,
131
- type SetCellStyleItem,
132
- type SetCellStyleParams,
133
- SetCellStyleCommand,
134
- type InsertCellsParams,
135
- InsertCellsCommand,
136
- type MergeCellsParams,
137
- MergeCellsCommand,
138
- type UnmergeCellsParams,
139
- UnmergeCellsCommand,
140
- type InsertImageParams,
141
- InsertImageCommand,
142
- type RemoveImageParams,
143
- RemoveImageCommand,
144
- type ImageUpdateFields,
145
- type UpdateImageParams,
146
- UpdateImageCommand,
147
- defaultCommandRegistry
148
- } from '@veltra/sheet-core'
149
-
150
- export {
151
- FORMULA_ERROR_CODES,
152
- formulaError,
153
- isFormulaError,
154
- isFormulaErrorCode,
155
- type FormulaErrorCode,
156
- type FormulaError,
157
- type BinaryOperator,
158
- type AstNode,
159
- type AstReference,
160
- collectReferences,
161
- FormulaParseError,
162
- tokenizeFormula,
163
- type FormulaOperator,
164
- type FormulaToken,
165
- parseFormula,
166
- type ScalarValue,
167
- type EvalValue,
168
- type FormulaEvalContext,
169
- coerceToNumber,
170
- coerceToText,
171
- coerceToBoolean,
172
- evaluateAst,
173
- registerFormulaFunction,
174
- listFormulaFunctions,
175
- invokeFormulaFunction,
176
- type FormulaFunctionMeta,
177
- type FormulaFunction,
178
- type FormulaDependency,
179
- type FormulaNode,
180
- DependencyGraph
181
- } from '@veltra/sheet-core'
182
-
183
- export { exportWorkbookXlsx, exportSheetCsv } from '@veltra/sheet-core'
184
- export { importXlsx, importCsv, replaceWorkbook } from '@veltra/sheet-core'
185
-
186
- export {
187
- SheetGrid,
188
- type SheetGridOptions,
189
- type SheetGridContextMenuKind,
190
- type SheetGridContextMenuInfo
191
- } from '@veltra/sheet-core'
6
+ // 数据模型 / 渲染内核在 @veltra/sheet-core(独立发包)。本包**不做** re-export:
7
+ // core API(Workbook / Sheet / SheetGrid / 公式 / IO 等)一律
8
+ // `from '@veltra/sheet-core'` 直导,白名单外符号深导入其子路径。
9
+ // 本入口只导出 sheet 自有能力:组件、tools、组件类型。
192
10
 
193
11
  export { createSheetContext, type SheetContext } from './tools/context'
194
12
 
@@ -201,6 +19,24 @@ export {
201
19
  type SheetToolGroup
202
20
  } from './tools/registry'
203
21
 
204
- export { type SheetProps, type SheetEmits, type _SheetExposed, type SheetExposed } from './types'
22
+ export {
23
+ type SheetProps,
24
+ type SheetEmits,
25
+ type _SheetExposed,
26
+ type SheetExposed,
27
+ type ReportViewerProps,
28
+ type _ReportViewerExposed,
29
+ type ReportViewerExposed,
30
+ type ReportDesignerProps,
31
+ type ReportDesignerEmits,
32
+ type _ReportDesignerExposed,
33
+ type ReportDesignerExposed
34
+ } from './types'
35
+
36
+ export { USheet } from './components/sheet'
37
+
38
+ export { UReportViewer, UReportDesigner } from './components/report'
205
39
 
206
- export { default as USheet } from './vue/sheet.vue'
40
+ // 报表纯 TS 内核:renderReport / binding / rules / params / DataConnector / Report Template /
41
+ // Filter Bar 值规范化(结构见 packages/sheet/AGENTS.md)
42
+ export * from './report'