@veltra/sheet 2.5.7 → 2.6.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.
- package/dist/components/sheet/formula-bar.js +7 -2
- package/dist/components/sheet/import-file.js +1 -1
- package/dist/components/sheet/popup-helpers.js +1 -1
- package/dist/components/sheet/popups/border-popup.js +2 -2
- package/dist/components/sheet/popups/functions-popup.js +1 -1
- package/dist/components/sheet/popups/import.worker.d.ts +1 -1
- package/dist/components/sheet/popups/import.worker.js +1 -1
- package/dist/components/sheet/sheet-context-menu.js +42 -6
- package/dist/components/sheet/sheet.js +12 -4
- package/dist/components/sheet/style2.css +1 -1
- package/dist/components/sheet/use-find-replace.js +2 -2
- package/dist/components/sheet/use-formula-suggest.js +1 -1
- package/dist/components/sheet/use-sheet-grid.js +17 -7
- package/dist/components/sheet/use-sheet-state.js +5 -2
- package/dist/components/sheet/use-tool-popup.js +1 -2
- package/dist/index.d.ts +2 -2
- package/dist/tools/builtin.js +1 -1
- package/dist/tools/context.d.ts +26 -11
- package/dist/tools/context.js +22 -1
- package/dist/tools/download.js +1 -1
- package/dist/tools/export.worker.d.ts +1 -1
- package/dist/tools/export.worker.js +1 -1
- package/dist/tools/registry.js +1 -1
- package/dist/types/sheet.d.ts +17 -7
- package/package.json +5 -2
- package/src/components/sheet/__test__/formula-bar.test.ts +54 -44
- package/src/components/sheet/__test__/functions-popup.test.ts +2 -2
- package/src/components/sheet/__test__/import-file.test.ts +4 -4
- package/src/components/sheet/__test__/insert-count-menu-item.test.ts +1 -1
- package/src/components/sheet/__test__/insert-image-popup.test.ts +2 -2
- package/src/components/sheet/__test__/insert-image.test.ts +2 -2
- package/src/components/sheet/__test__/sheet-component.test.ts +312 -25
- package/src/components/sheet/__test__/sheet-context-menu.test.ts +34 -5
- package/src/components/sheet/__test__/use-formula-ref-select.test.ts +1 -1
- package/src/components/sheet/__test__/use-formula-suggest.test.ts +2 -2
- package/src/components/sheet/formula-bar.vue +17 -4
- package/src/components/sheet/import-file.ts +3 -3
- package/src/components/sheet/insert-image.ts +1 -1
- package/src/components/sheet/popup-helpers.ts +3 -3
- package/src/components/sheet/popups/border-popup.vue +3 -3
- package/src/components/sheet/popups/find-popup.vue +1 -1
- package/src/components/sheet/popups/functions-popup.vue +1 -1
- package/src/components/sheet/popups/import.worker.ts +2 -2
- package/src/components/sheet/sheet-context-menu.ts +63 -6
- package/src/components/sheet/sheet-tabs.vue +2 -2
- package/src/components/sheet/sheet.vue +5 -2
- package/src/components/sheet/style.scss +2 -2
- package/src/components/sheet/use-find-replace.ts +3 -3
- package/src/components/sheet/use-formula-suggest.ts +1 -1
- package/src/components/sheet/use-sheet-grid.ts +33 -11
- package/src/components/sheet/use-sheet-state.ts +7 -3
- package/src/components/sheet/use-tool-popup.ts +5 -4
- package/src/index.ts +1 -1
- package/src/tools/__test__/apply-style.test.ts +3 -3
- package/src/tools/__test__/builtin.test.ts +4 -4
- package/src/tools/__test__/context.test.ts +68 -4
- package/src/tools/__test__/registry.test.ts +1 -1
- package/src/tools/apply-style.ts +3 -3
- package/src/tools/builtin.ts +2 -2
- package/src/tools/context.ts +58 -11
- package/src/tools/download.ts +2 -2
- package/src/tools/export.worker.ts +3 -3
- package/src/tools/registry.ts +1 -1
- package/src/types/sheet.ts +19 -7
- package/src/components/sheet/parsing.ts +0 -11
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { parseRange } from '@veltra/sheet-core/core/address'
|
|
2
|
-
import { Workbook } from '@veltra/sheet-core/core/workbook'
|
|
1
|
+
import { parseRange } from '@veltra/sheet-core/core/address.js'
|
|
2
|
+
import { Workbook } from '@veltra/sheet-core/core/workbook.js'
|
|
3
3
|
import type { SheetGrid } from '@veltra/sheet-core/grid'
|
|
4
|
-
import { afterEach, describe, expect, it } from '
|
|
4
|
+
import { afterEach, describe, expect, it } from 'vite-plus/test'
|
|
5
5
|
import { createApp, h, nextTick, type App } from 'vue'
|
|
6
6
|
|
|
7
7
|
import { USheet } from '../../../index'
|
|
@@ -226,8 +226,8 @@ describe('USheet 公式栏(名称框 + fx 输入栏)', () => {
|
|
|
226
226
|
await nextTick()
|
|
227
227
|
expect(sheet.getCellData({ row: 2, col: 0 })).toMatchObject({ f: 'SUM(A1:A2)', v: 3 })
|
|
228
228
|
|
|
229
|
-
// 提交后网格渲染计算值(模型 A3
|
|
230
|
-
expect(exposed.value?.getGrid()?.getTable().
|
|
229
|
+
// 提交后网格渲染计算值(模型 A3 = 引擎数据坐标 (0,2),无行列头偏移)
|
|
230
|
+
expect(exposed.value?.getGrid()?.getTable().getCellText(0, 2)).toBe('3')
|
|
231
231
|
})
|
|
232
232
|
|
|
233
233
|
it('网格侧编辑提交(change_cell_value)后公式栏同步显示', async () => {
|
|
@@ -239,8 +239,8 @@ describe('USheet 公式栏(名称框 + fx 输入栏)', () => {
|
|
|
239
239
|
sheet.selectCell({ row: 0, col: 0 })
|
|
240
240
|
await nextTick()
|
|
241
241
|
|
|
242
|
-
//
|
|
243
|
-
exposed.value?.getGrid()?.getTable().
|
|
242
|
+
// 模拟网格编辑提交(引擎公开回写 API:updateCell → TableModel → 模型命令系统)
|
|
243
|
+
exposed.value?.getGrid()?.getTable().updateCell(0, 0, 'grid-edited')
|
|
244
244
|
await nextTick()
|
|
245
245
|
expect(fxInput(el).value).toBe('grid-edited')
|
|
246
246
|
})
|
|
@@ -255,14 +255,14 @@ describe('USheet 公式栏(名称框 + fx 输入栏)', () => {
|
|
|
255
255
|
sheet.selectCell({ row: 0, col: 0 })
|
|
256
256
|
await nextTick()
|
|
257
257
|
|
|
258
|
-
//
|
|
259
|
-
exposed.value?.getGrid()?.getTable().
|
|
258
|
+
// 程序化进入网格编辑(引擎数据坐标 (0,0) = 模型 A1)
|
|
259
|
+
expect(exposed.value?.getGrid()?.getTable().startEdit(0, 0)).toBe(true)
|
|
260
260
|
await nextTick()
|
|
261
261
|
expect(fxInput(el).readOnly).toBe(true)
|
|
262
262
|
expect(fxInput(el).value).toBe('=SUM(1,2)')
|
|
263
263
|
|
|
264
264
|
// 提交 → 编辑器 onEnd → 公式栏退出镜像(显示模型内容)
|
|
265
|
-
exposed.value?.getGrid()?.getTable().
|
|
265
|
+
exposed.value?.getGrid()?.getTable().commitEdit()
|
|
266
266
|
await nextTick()
|
|
267
267
|
expect(sheet.getCellData({ row: 0, col: 0 })).toMatchObject({ f: 'SUM(1,2)' })
|
|
268
268
|
expect(fxInput(el).readOnly).toBe(false)
|
|
@@ -271,7 +271,6 @@ describe('USheet 公式栏(名称框 + fx 输入栏)', () => {
|
|
|
271
271
|
|
|
272
272
|
it('tab 切换:重绑订阅并刷新(新 sheet 的选区 / 单元格内容回显)', async () => {
|
|
273
273
|
const workbook = createWorkbook()
|
|
274
|
-
const sheet1 = workbook.activeSheet
|
|
275
274
|
const sheet2 = workbook.getSheet('Sheet2')!
|
|
276
275
|
const { el } = mount(() => ({ workbook, rows: 20, cols: 8 }))
|
|
277
276
|
await nextTick()
|
|
@@ -551,15 +550,33 @@ describe('USheet 公式栏:函数补全与引用选择', () => {
|
|
|
551
550
|
const input = setFxText(el, '=SUM(')
|
|
552
551
|
await nextTick()
|
|
553
552
|
|
|
554
|
-
//
|
|
553
|
+
// 画布数据格点选(引擎选区事件管线)→ 引用插入 + blur 挂起(引用选择);
|
|
554
|
+
// 引用拾取为手势收敛语义(按下起手记录、抬手一次回交,见 sheet-core
|
|
555
|
+
// grid-selection),故插入断言在 pointerup 之后。pointerdown 监听绑定在
|
|
556
|
+
// 实例容器(LRU 缓存)。画布几何口径与 sheet-core grid-theme 一致
|
|
557
|
+
// (行号列 46、列头 28、列宽 80、行高 28)→ (51, 117) 命中 A4
|
|
555
558
|
const gridEl = el.querySelector('.u-sheet__grid-instance')!
|
|
556
|
-
gridEl.dispatchEvent(
|
|
557
|
-
|
|
559
|
+
gridEl.dispatchEvent(
|
|
560
|
+
new PointerEvent('pointerdown', { clientX: 51, clientY: 117, bubbles: true })
|
|
561
|
+
)
|
|
558
562
|
await nextTick()
|
|
563
|
+
// 手势未结束(未抬手):不插入、模型选区不变
|
|
559
564
|
expect(sheet.getCellData({ row: 2, col: 0 })).toBeUndefined()
|
|
560
565
|
expect(input.value).toBe('=SUM(')
|
|
566
|
+
gridEl.dispatchEvent(
|
|
567
|
+
new PointerEvent('pointerup', { clientX: 51, clientY: 117, bubbles: true })
|
|
568
|
+
)
|
|
569
|
+
await nextTick()
|
|
570
|
+
expect(sheet.getCellData({ row: 2, col: 0 })).toBeUndefined()
|
|
571
|
+
expect(input.value).toBe('=SUM(A4')
|
|
572
|
+
|
|
573
|
+
// 插入后失焦仍被挂起(beginBlurSuppress 置位):草稿不提交
|
|
574
|
+
input.dispatchEvent(new FocusEvent('blur'))
|
|
575
|
+
await nextTick()
|
|
576
|
+
expect(sheet.getCellData({ row: 2, col: 0 })).toBeUndefined()
|
|
577
|
+
expect(input.value).toBe('=SUM(A4')
|
|
561
578
|
|
|
562
|
-
// 网格选区拦截 → handleRefSelect
|
|
579
|
+
// 网格选区拦截 → handleRefSelect 路径(引擎选区事件管线,见 sheet-core grid-selection)
|
|
563
580
|
const { el: barEl, exposed: barExposed } = mountFormulaBar(sheet)
|
|
564
581
|
await nextTick()
|
|
565
582
|
setFxText(barEl, '=SUM(')
|
|
@@ -588,13 +605,13 @@ describe('USheet 公式栏:函数补全与引用选择', () => {
|
|
|
588
605
|
sheet.selectCell({ row: 0, col: 0 })
|
|
589
606
|
await nextTick()
|
|
590
607
|
|
|
591
|
-
exposed.value?.getGrid()?.getTable().
|
|
608
|
+
expect(exposed.value?.getGrid()?.getTable().startEdit(0, 0)).toBe(true)
|
|
592
609
|
await nextTick()
|
|
593
610
|
expect(fxInput(el).readOnly).toBe(true)
|
|
594
611
|
expect(fxInput(el).value).toBe('=SUM(1,2)')
|
|
595
612
|
expect(suggestList(el)).toBeNull()
|
|
596
613
|
|
|
597
|
-
exposed.value?.getGrid()?.getTable().
|
|
614
|
+
exposed.value?.getGrid()?.getTable().commitEdit()
|
|
598
615
|
await nextTick()
|
|
599
616
|
})
|
|
600
617
|
|
|
@@ -644,19 +661,14 @@ describe('USheet 公式栏:函数补全与引用选择', () => {
|
|
|
644
661
|
|
|
645
662
|
// ─── 目标格选区高亮保持(弹框打开与参数点选期间)──────────────
|
|
646
663
|
|
|
647
|
-
/** VTable 事件名(ListTable.EVENT_TYPE 常量值;@veltra/sheet 不直接依赖 @visactor/vtable,不做运行时引入) */
|
|
648
|
-
const EVT_SELECTED_CELL = 'selected_cell'
|
|
649
|
-
const EVT_DRAG_SELECT_END = 'drag_select_end'
|
|
650
|
-
|
|
651
664
|
type GridTable = ReturnType<SheetGrid['getTable']>
|
|
652
665
|
|
|
653
|
-
/**
|
|
666
|
+
/** 模拟画布点选格(引擎选区事件管线:selectCells 即驱动拦截 / 回写路径) */
|
|
654
667
|
function canvasClickCell(table: GridTable, col: number, row: number): void {
|
|
655
668
|
table.selectCells([{ start: { col, row }, end: { col, row } }])
|
|
656
|
-
table.fireListeners(EVT_SELECTED_CELL, { col, row })
|
|
657
669
|
}
|
|
658
670
|
|
|
659
|
-
/**
|
|
671
|
+
/** 画布当前选区末尾项(引擎数据坐标,无行列头偏移) */
|
|
660
672
|
function lastCanvasRange(table: GridTable) {
|
|
661
673
|
return table.getSelectedCellRanges().at(-1)
|
|
662
674
|
}
|
|
@@ -675,19 +687,19 @@ describe('USheet 公式栏:目标格选区高亮保持', () => {
|
|
|
675
687
|
await flushPopup()
|
|
676
688
|
expect(functionsPanel()).not.toBeNull()
|
|
677
689
|
|
|
678
|
-
// 弹框打开期间点选画布 B2
|
|
690
|
+
// 弹框打开期间点选画布 B2(引擎数据坐标 (1,1))
|
|
679
691
|
const table = exposed.value!.getGrid()!.getTable()
|
|
680
|
-
canvasClickCell(table,
|
|
692
|
+
canvasClickCell(table, 1, 1)
|
|
681
693
|
|
|
682
694
|
expect(sheet.getSelection().activeCell).toEqual({ row: 2, col: 0 })
|
|
683
695
|
expect(sheet.getSelection().ranges[0]).toEqual({
|
|
684
696
|
start: { row: 2, col: 0 },
|
|
685
697
|
end: { row: 2, col: 0 }
|
|
686
698
|
})
|
|
687
|
-
// 画布选区回推为目标格 A3
|
|
699
|
+
// 画布选区回推为目标格 A3(引擎数据坐标 (0,2)),名称框仍显示 A3
|
|
688
700
|
expect(lastCanvasRange(table)).toMatchObject({
|
|
689
|
-
start: { col:
|
|
690
|
-
end: { col:
|
|
701
|
+
start: { col: 0, row: 2 },
|
|
702
|
+
end: { col: 0, row: 2 }
|
|
691
703
|
})
|
|
692
704
|
expect(nameBox(el).value).toBe('A3')
|
|
693
705
|
// 未处于引用选择上下文:不插入引用文本
|
|
@@ -713,15 +725,15 @@ describe('USheet 公式栏:目标格选区高亮保持', () => {
|
|
|
713
725
|
const input = fxInput(el)
|
|
714
726
|
expect(input.value).toBe('=SUM()')
|
|
715
727
|
|
|
716
|
-
// 点选参数格 A1
|
|
728
|
+
// 点选参数格 A1(引擎数据坐标 (0,0))→ 只插入引用文本(括号随 =SUM() 模板闭合),目标格选区不变
|
|
717
729
|
const table = exposed.value!.getGrid()!.getTable()
|
|
718
|
-
canvasClickCell(table,
|
|
730
|
+
canvasClickCell(table, 0, 0)
|
|
719
731
|
await nextTick()
|
|
720
732
|
expect(input.value).toBe('=SUM(A1)')
|
|
721
733
|
expect(sheet.getSelection().activeCell).toEqual({ row: 2, col: 0 })
|
|
722
734
|
expect(lastCanvasRange(table)).toMatchObject({
|
|
723
|
-
start: { col:
|
|
724
|
-
end: { col:
|
|
735
|
+
start: { col: 0, row: 2 },
|
|
736
|
+
end: { col: 0, row: 2 }
|
|
725
737
|
})
|
|
726
738
|
expect(nameBox(el).value).toBe('A3')
|
|
727
739
|
|
|
@@ -732,8 +744,8 @@ describe('USheet 公式栏:目标格选区高亮保持', () => {
|
|
|
732
744
|
expect(sheet.getSelection().activeCell).toEqual({ row: 2, col: 0 })
|
|
733
745
|
expect(nameBox(el).value).toBe('A3')
|
|
734
746
|
expect(lastCanvasRange(table)).toMatchObject({
|
|
735
|
-
start: { col:
|
|
736
|
-
end: { col:
|
|
747
|
+
start: { col: 0, row: 2 },
|
|
748
|
+
end: { col: 0, row: 2 }
|
|
737
749
|
})
|
|
738
750
|
})
|
|
739
751
|
|
|
@@ -755,23 +767,21 @@ describe('USheet 公式栏:目标格选区高亮保持', () => {
|
|
|
755
767
|
|
|
756
768
|
// 弹框打开期间点选画布 B2:目标格 A3 高亮保持、模型选区不变、不插入文本
|
|
757
769
|
const table = exposed.value!.getGrid()!.getTable()
|
|
758
|
-
canvasClickCell(table,
|
|
770
|
+
canvasClickCell(table, 1, 1)
|
|
759
771
|
expect(sheet.getSelection().activeCell).toEqual({ row: 2, col: 0 })
|
|
760
772
|
expect(lastCanvasRange(table)).toMatchObject({
|
|
761
|
-
start: { col:
|
|
762
|
-
end: { col:
|
|
773
|
+
start: { col: 0, row: 2 },
|
|
774
|
+
end: { col: 0, row: 2 }
|
|
763
775
|
})
|
|
764
776
|
expect(fxInput(el).value).toBe('')
|
|
765
777
|
|
|
766
|
-
// 选中 SUM → 拖选参数区域 A1:A2
|
|
778
|
+
// 选中 SUM → 拖选参数区域 A1:A2(引擎选区事件:selectCells 即完整时序)
|
|
767
779
|
document.querySelector<HTMLElement>('#pop-container .u-sheet__functions-item')!.click()
|
|
768
780
|
await nextTick()
|
|
769
781
|
await nextTick()
|
|
770
782
|
const input = fxInput(el)
|
|
771
783
|
expect(input.value).toBe('=SUM()')
|
|
772
|
-
table.selectCells([{ start: { col:
|
|
773
|
-
table.fireListeners(EVT_SELECTED_CELL, { col: 1, row: 2 })
|
|
774
|
-
table.fireListeners(EVT_DRAG_SELECT_END, {})
|
|
784
|
+
table.selectCells([{ start: { col: 0, row: 0 }, end: { col: 0, row: 1 } }])
|
|
775
785
|
await nextTick()
|
|
776
786
|
expect(input.value).toBe('=SUM(A1:A2)')
|
|
777
787
|
expect(sheet.getSelection().activeCell).toEqual({ row: 2, col: 0 })
|
|
@@ -808,8 +818,8 @@ describe('USheet 公式栏:目标格选区高亮保持', () => {
|
|
|
808
818
|
expect(sheet.getSelection().activeCell).toEqual({ row: 2, col: 0 })
|
|
809
819
|
expect(nameBox(el).value).toBe('A3')
|
|
810
820
|
expect(lastCanvasRange(exposed.value!.getGrid()!.getTable())).toMatchObject({
|
|
811
|
-
start: { col:
|
|
812
|
-
end: { col:
|
|
821
|
+
start: { col: 0, row: 2 },
|
|
822
|
+
end: { col: 0, row: 2 }
|
|
813
823
|
})
|
|
814
824
|
})
|
|
815
825
|
})
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
listFormulaFunctions,
|
|
3
3
|
registerFormulaFunction
|
|
4
|
-
} from '@veltra/sheet-core/core/formula/functions'
|
|
5
|
-
import { afterEach, describe, expect, it, vi } from '
|
|
4
|
+
} from '@veltra/sheet-core/core/formula/functions.js'
|
|
5
|
+
import { afterEach, describe, expect, it, vi } from 'vite-plus/test'
|
|
6
6
|
import { createApp, h, nextTick, type App } from 'vue'
|
|
7
7
|
|
|
8
8
|
import USheetFunctionsPopup from '../popups/functions-popup.vue'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Sheet } from '@veltra/sheet-core/core/sheet'
|
|
2
|
-
import { Workbook } from '@veltra/sheet-core/core/workbook'
|
|
3
|
-
import { afterEach, describe, expect, it, vi } from '
|
|
1
|
+
import type { Sheet } from '@veltra/sheet-core/core/sheet.js'
|
|
2
|
+
import { Workbook } from '@veltra/sheet-core/core/workbook.js'
|
|
3
|
+
import { afterEach, describe, expect, it, vi } from 'vite-plus/test'
|
|
4
4
|
import { ref } from 'vue'
|
|
5
5
|
|
|
6
6
|
import { IMPORT_FILE_ACCEPT, importFromFile, pickAndImportFile } from '../import-file'
|
|
@@ -36,7 +36,7 @@ const EMPTY_SNAPSHOT = {
|
|
|
36
36
|
|
|
37
37
|
vi.mock('@veltra/desktop', () => ({ message: mocks.message, messageConfirm: mocks.messageConfirm }))
|
|
38
38
|
|
|
39
|
-
vi.mock('@veltra/sheet-core/core/io/import', () => ({
|
|
39
|
+
vi.mock('@veltra/sheet-core/core/io/import.js', () => ({
|
|
40
40
|
importCsv: mocks.importCsv,
|
|
41
41
|
importXlsx: mocks.importXlsx,
|
|
42
42
|
replaceWorkbookWithSnapshots: mocks.replaceWorkbookWithSnapshots
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ContextmenuRootDIKey } from '@veltra/desktop'
|
|
2
|
-
import { describe, expect, it, vi } from '
|
|
2
|
+
import { describe, expect, it, vi } from 'vite-plus/test'
|
|
3
3
|
import { createApp, h, nextTick } from 'vue'
|
|
4
4
|
|
|
5
5
|
import InsertCountMenuItem from '../insert-count-menu-item.vue'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Sheet } from '@veltra/sheet-core/core/sheet'
|
|
2
|
-
import { afterEach, describe, expect, it, vi } from '
|
|
1
|
+
import { Sheet } from '@veltra/sheet-core/core/sheet.js'
|
|
2
|
+
import { afterEach, describe, expect, it, vi } from 'vite-plus/test'
|
|
3
3
|
import { createApp, h, type App } from 'vue'
|
|
4
4
|
|
|
5
5
|
import { createSheetContext } from '../../../tools/context'
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Sheet } from '@veltra/sheet-core/core/sheet'
|
|
2
|
-
import { afterEach, describe, expect, it, vi } from '
|
|
1
|
+
import { Sheet } from '@veltra/sheet-core/core/sheet.js'
|
|
2
|
+
import { afterEach, describe, expect, it, vi } from 'vite-plus/test'
|
|
3
3
|
|
|
4
4
|
import { createSheetContext } from '../../../tools/context'
|
|
5
5
|
import {
|