@veltra/sheet 2.3.1 → 2.3.3

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.
@@ -1,5 +1,5 @@
1
1
  import { formatBindingPlaceholderParts, inferReportPreset } from "../../report/binding.js";
2
- import { CustomLayout } from "@veltra/sheet-core";
2
+ import { CustomLayout } from "@veltra/sheet-core/grid";
3
3
  //#region src/components/report/binding-badge.ts
4
4
  const REPORT_PRESET_BADGE_COLORS = {
5
5
  groupHeader: {
@@ -155,10 +155,14 @@ function useReportDesigner(options) {
155
155
  if (("aggregate" in patch || "expand" in patch) && !("preset" in patch) && !presetStillApplies(next)) delete next.preset;
156
156
  if (patch.preset === "subtotal") {
157
157
  const inferred = inferParentsForPreset(cell, "subtotal", getBindingAt);
158
- if (parentNeedsCorrection(next.rowParent)) if (inferred.rowParent) next.rowParent = inferred.rowParent;
159
- else delete next.rowParent;
160
- if (parentNeedsCorrection(next.colParent)) if (inferred.colParent) next.colParent = inferred.colParent;
161
- else delete next.colParent;
158
+ if (parentNeedsCorrection(next.rowParent)) {
159
+ if (inferred.rowParent) next.rowParent = inferred.rowParent;
160
+ else delete next.rowParent;
161
+ }
162
+ if (parentNeedsCorrection(next.colParent)) {
163
+ if (inferred.colParent) next.colParent = inferred.colParent;
164
+ else delete next.colParent;
165
+ }
162
166
  }
163
167
  workbook.value.activeSheet.setCellMeta(cell, REPORT_META_NAMESPACE, next);
164
168
  }
@@ -3,8 +3,8 @@ self.onmessage = (e) => {
3
3
  const { buffer } = e.data;
4
4
  (async () => {
5
5
  try {
6
- const [{ readXlsx }, { buildWorkbookFromHucre }] = await Promise.all([import("hucre/xlsx"), import("@veltra/sheet-core/core/io/import")]);
7
- const hucreWb = await readXlsx(new Uint8Array(buffer), { readStyles: true });
6
+ const [{ readXlsx }, { buildWorkbookFromHucre, XLSX_READ_OPTIONS }] = await Promise.all([import("hucre/xlsx"), import("@veltra/sheet-core/core/io/import")]);
7
+ const hucreWb = await readXlsx(new Uint8Array(buffer), XLSX_READ_OPTIONS);
8
8
  let lastPercent = -1;
9
9
  const wb = buildWorkbookFromHucre(hucreWb, (done, total) => {
10
10
  const percent = total > 0 ? Math.floor(done / total * 10) : 10;
@@ -1,7 +1,7 @@
1
1
  import { buildBodyMenus, buildColHeaderMenus, buildRowHeaderMenus, ensureContextMenuSelection, resolveRenderSize } from "./sheet-context-menu.js";
2
2
  import { onBeforeUnmount, onMounted, watch } from "vue";
3
3
  import { contextmenu } from "@veltra/desktop";
4
- import { SheetGrid } from "@veltra/sheet-core/grid/sheet-grid";
4
+ import { SheetGrid } from "@veltra/sheet-core/grid";
5
5
  //#region src/components/sheet/use-sheet-grid.ts
6
6
  /**
7
7
  * 缓存容量:最近 N 个 sheet 的 SheetGrid 实例常驻(tab 来回切换零重建)。
@@ -127,8 +127,9 @@ function useSheetGrid(options) {
127
127
  * tab 切换:优先复用缓存实例(零重建)。
128
128
  * 命中时校验实例是否过期(隐藏期间程序化 structure-change——插入/删除/undo
129
129
  * 行列——vue 层只绑定激活 sheet 的 structure-change,隐藏实例靠自持订阅标记
130
- * dirty);过期则释放重建,否则同步模型状态(选区回驱 + 冻结校正;数据/样式/
131
- * 行高由实例常驻的 sheet 事件订阅持续同步,隐藏期间跨表重算等模型变更不丢)。
130
+ * dirty);过期则释放重建。命中且未过期只翻可见性:隐藏实例的 cell/merge/
131
+ * content-reset 已在 GridSyncManager 置脏,setVisible(true) 时一次性 flush,
132
+ * 不必每次切 tab 都 syncFromModel(会重放全部列宽)。
132
133
  */
133
134
  function activateGrid() {
134
135
  const sheet = getActiveSheet();
@@ -136,7 +137,6 @@ function useSheetGrid(options) {
136
137
  const cached = cache.get(sheet);
137
138
  if (cached && !cached.dirty) {
138
139
  cached.lastUsed = ++seq;
139
- cached.grid.syncFromModel();
140
140
  showOnly(cached);
141
141
  active = cached;
142
142
  bindGridPointerDown(cached.el);
@@ -266,11 +266,13 @@ function inferParentsForPreset(addr, preset, getBindingAt) {
266
266
  const result = {};
267
267
  if (rowSubtotal && rowParent) result.rowParent = rowParent;
268
268
  if (columnSubtotal && colParent) result.colParent = colParent;
269
- if (!rowSubtotal && !columnSubtotal) if (belowBand && rowParent) result.rowParent = rowParent;
270
- else if (rightOfBand && colParent) result.colParent = colParent;
271
- else {
272
- if (rowParent) result.rowParent = rowParent;
273
- if (colParent) result.colParent = colParent;
269
+ if (!rowSubtotal && !columnSubtotal) {
270
+ if (belowBand && rowParent) result.rowParent = rowParent;
271
+ else if (rightOfBand && colParent) result.colParent = colParent;
272
+ else {
273
+ if (rowParent) result.rowParent = rowParent;
274
+ if (colParent) result.colParent = colParent;
275
+ }
274
276
  }
275
277
  return result;
276
278
  }
@@ -1,7 +1,7 @@
1
1
  import { SheetContext } from "../tools/context.js";
2
2
  import { ComputedRef } from "vue";
3
3
  import { DeconstructValue } from "@veltra/utils";
4
- import { ResolveCellRenderer, ResolveCellStyleHook, ResolveDisplayValue, SheetGrid } from "@veltra/sheet-core/grid/sheet-grid";
4
+ import { ResolveCellRenderer, ResolveCellStyleHook, ResolveDisplayValue, SheetGrid } from "@veltra/sheet-core/grid";
5
5
  import { Workbook } from "@veltra/sheet-core/core/workbook";
6
6
  import { Sheet } from "@veltra/sheet-core/core/sheet";
7
7
  //#region src/types/sheet.d.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veltra/sheet",
3
- "version": "2.3.1",
3
+ "version": "2.3.3",
4
4
  "homepage": "https://github.com/cabinet-fe/ultra-ui#readme",
5
5
  "bugs": {
6
6
  "url": "https://github.com/cabinet-fe/ultra-ui/issues"
@@ -34,17 +34,17 @@
34
34
  }
35
35
  },
36
36
  "dependencies": {
37
- "hucre": "^1.0.0"
37
+ "hucre": "^1.1.0"
38
38
  },
39
39
  "peerDependencies": {
40
40
  "@cat-kit/core": ">=1.1.8",
41
41
  "@cat-kit/fe": ">=1.1.8",
42
- "@veltra/compositions": "^1.6.2",
43
- "@veltra/desktop": "^1.6.2",
42
+ "@veltra/compositions": "^1.6.4",
43
+ "@veltra/desktop": "^1.6.4",
44
44
  "@veltra/icons": "^1.5.0",
45
- "@veltra/sheet-core": "^2.3.1",
46
- "@veltra/styles": "^1.6.2",
47
- "@veltra/utils": "^1.6.2",
45
+ "@veltra/sheet-core": "^2.3.3",
46
+ "@veltra/styles": "^1.6.4",
47
+ "@veltra/utils": "^1.6.4",
48
48
  "vue": ">=3.5.41"
49
49
  }
50
50
  }
@@ -3,7 +3,7 @@ import {
3
3
  CustomLayout,
4
4
  type ResolveCellRenderer,
5
5
  type ResolveCellStyleHook
6
- } from '@veltra/sheet-core'
6
+ } from '@veltra/sheet-core/grid'
7
7
 
8
8
  import { formatBindingPlaceholderParts, inferReportPreset } from '../../report/binding'
9
9
  import type { ReportBinding, ReportPreset } from '../../report/types'
@@ -1,4 +1,5 @@
1
- import type { CellAddress, SheetGrid } from '@veltra/sheet-core'
1
+ import type { CellAddress } from '@veltra/sheet-core'
2
+ import type { SheetGrid } from '@veltra/sheet-core/grid'
2
3
 
3
4
  export interface CellOverlayRect {
4
5
  left: number
@@ -6,7 +6,8 @@
6
6
  </template>
7
7
 
8
8
  <script lang="ts" setup>
9
- import type { CellAddress, SheetGrid } from '@veltra/sheet-core'
9
+ import type { CellAddress } from '@veltra/sheet-core'
10
+ import type { SheetGrid } from '@veltra/sheet-core/grid'
10
11
  import { bem } from '@veltra/utils'
11
12
  import { computed, ref, toRef } from 'vue'
12
13
 
@@ -150,7 +150,8 @@
150
150
 
151
151
  <script lang="ts" setup>
152
152
  import { UButton, URadioGroup, USelect, USwitch } from '@veltra/desktop'
153
- import type { CellAddress, SheetGrid } from '@veltra/sheet-core'
153
+ import type { CellAddress } from '@veltra/sheet-core'
154
+ import type { SheetGrid } from '@veltra/sheet-core/grid'
154
155
  import { bem } from '@veltra/utils'
155
156
  import { computed, nextTick, ref, toRef, watch } from 'vue'
156
157
 
@@ -35,7 +35,8 @@
35
35
  </template>
36
36
 
37
37
  <script lang="ts" setup>
38
- import type { CellAddress, SheetGrid } from '@veltra/sheet-core'
38
+ import type { CellAddress } from '@veltra/sheet-core'
39
+ import type { SheetGrid } from '@veltra/sheet-core/grid'
39
40
  import { bem } from '@veltra/utils'
40
41
  import { computed, ref, toRef } from 'vue'
41
42
 
@@ -1,4 +1,5 @@
1
- import type { CellAddress, SheetGrid } from '@veltra/sheet-core'
1
+ import type { CellAddress } from '@veltra/sheet-core'
2
+ import type { SheetGrid } from '@veltra/sheet-core/grid'
2
3
  import { onBeforeUnmount, watch, type Ref } from 'vue'
3
4
 
4
5
  import {
@@ -146,8 +146,9 @@
146
146
 
147
147
  <script lang="ts" setup>
148
148
  import { UButton, UDrawer } from '@veltra/desktop'
149
- import type { CellAddress, SheetGrid } from '@veltra/sheet-core'
149
+ import type { CellAddress } from '@veltra/sheet-core'
150
150
  import { Workbook } from '@veltra/sheet-core'
151
+ import type { SheetGrid } from '@veltra/sheet-core/grid'
151
152
  import { bem } from '@veltra/utils'
152
153
  import { computed, nextTick, onScopeDispose, ref, shallowRef, useTemplateRef, watch } from 'vue'
153
154
 
@@ -1,6 +1,6 @@
1
1
  import type { CellAddress } from '@veltra/sheet-core'
2
- import type { ResolveCellRenderer, ResolveCellStyleHook } from '@veltra/sheet-core'
3
2
  import { Workbook } from '@veltra/sheet-core'
3
+ import type { ResolveCellRenderer, ResolveCellStyleHook } from '@veltra/sheet-core/grid'
4
4
  import { computed, onScopeDispose, ref, watch, type ComputedRef, type Ref } from 'vue'
5
5
 
6
6
  import {
@@ -30,11 +30,11 @@ self.onmessage = (e: MessageEvent<{ buffer: ArrayBuffer }>): void => {
30
30
  const { buffer } = e.data
31
31
  void (async () => {
32
32
  try {
33
- const [{ readXlsx }, { buildWorkbookFromHucre }] = await Promise.all([
33
+ const [{ readXlsx }, { buildWorkbookFromHucre, XLSX_READ_OPTIONS }] = await Promise.all([
34
34
  import('hucre/xlsx'),
35
35
  import('@veltra/sheet-core/core/io/import')
36
36
  ])
37
- const hucreWb = await readXlsx(new Uint8Array(buffer), { readStyles: true })
37
+ const hucreWb = await readXlsx(new Uint8Array(buffer), XLSX_READ_OPTIONS)
38
38
  // 分片构建:按 10% 粒度回报进度(避免 196 条/秒的消息风暴与文字跳变过快;
39
39
  // 模型构建段约 1s,10 次更新肉眼可见数字推进)
40
40
  let lastPercent = -1
@@ -1,7 +1,7 @@
1
1
  import { contextmenu } from '@veltra/desktop'
2
2
  import type { CellAddress, CellRange } from '@veltra/sheet-core/core/address'
3
3
  import type { Sheet } from '@veltra/sheet-core/core/sheet'
4
- import { SheetGrid, type SheetGridContextMenuInfo } from '@veltra/sheet-core/grid/sheet-grid'
4
+ import { SheetGrid, type SheetGridContextMenuInfo } from '@veltra/sheet-core/grid'
5
5
  import { onBeforeUnmount, onMounted, watch } from 'vue'
6
6
 
7
7
  import type { SheetContext } from '../../tools/context'
@@ -189,8 +189,9 @@ export function useSheetGrid(options: UseSheetGridOptions) {
189
189
  * tab 切换:优先复用缓存实例(零重建)。
190
190
  * 命中时校验实例是否过期(隐藏期间程序化 structure-change——插入/删除/undo
191
191
  * 行列——vue 层只绑定激活 sheet 的 structure-change,隐藏实例靠自持订阅标记
192
- * dirty);过期则释放重建,否则同步模型状态(选区回驱 + 冻结校正;数据/样式/
193
- * 行高由实例常驻的 sheet 事件订阅持续同步,隐藏期间跨表重算等模型变更不丢)。
192
+ * dirty);过期则释放重建。命中且未过期只翻可见性:隐藏实例的 cell/merge/
193
+ * content-reset 已在 GridSyncManager 置脏,setVisible(true) 时一次性 flush,
194
+ * 不必每次切 tab 都 syncFromModel(会重放全部列宽)。
194
195
  */
195
196
  function activateGrid(): void {
196
197
  const sheet = getActiveSheet()
@@ -199,7 +200,6 @@ export function useSheetGrid(options: UseSheetGridOptions) {
199
200
  const cached = cache.get(sheet)
200
201
  if (cached && !cached.dirty) {
201
202
  cached.lastUsed = ++seq
202
- cached.grid.syncFromModel()
203
203
  showOnly(cached)
204
204
  active = cached
205
205
  bindGridPointerDown(cached.el)
package/src/index.ts CHANGED
@@ -4,8 +4,8 @@
4
4
  import './tools/builtin'
5
5
 
6
6
  // 数据模型 / 渲染内核在 @veltra/sheet-core(独立发包)。本包**不做** re-export:
7
- // core API(Workbook / Sheet / SheetGrid / 公式 / IO 等)一律
8
- // `from '@veltra/sheet-core'` 直导,白名单外符号深导入其子路径。
7
+ // core API(Workbook / Sheet / 公式 / IO 等)一律 `from '@veltra/sheet-core'` 直导;
8
+ // SheetGrid 走 `@veltra/sheet-core/grid`;白名单外符号深导入其子路径。
9
9
  // 本入口只导出 sheet 自有能力:组件、tools、组件类型。
10
10
 
11
11
  export { createSheetContext, type SheetContext } from './tools/context'
@@ -1,5 +1,5 @@
1
1
  import { Sheet } from '@veltra/sheet-core'
2
- import { buildWorkbookFromHucre } from '@veltra/sheet-core/core/io/import'
2
+ import { buildWorkbookFromHucre, XLSX_READ_OPTIONS } from '@veltra/sheet-core/core/io/import'
3
3
  import { readXlsx } from 'hucre/xlsx'
4
4
  import { describe, expect, it } from 'vitest'
5
5
 
@@ -69,7 +69,7 @@ describe('exportFilledReportXlsx', () => {
69
69
  expect(buffer[0]).toBe(0x50)
70
70
  expect(buffer[1]).toBe(0x4b)
71
71
 
72
- const hucreWb = await readXlsx(buffer, { readStyles: true })
72
+ const hucreWb = await readXlsx(buffer, XLSX_READ_OPTIONS)
73
73
  const workbook = buildWorkbookFromHucre(hucreWb)
74
74
  const sheet = workbook.getSheets()[0]!
75
75
 
@@ -5,7 +5,7 @@ import type {
5
5
  ResolveCellStyleHook,
6
6
  ResolveDisplayValue,
7
7
  SheetGrid
8
- } from '@veltra/sheet-core/grid/sheet-grid'
8
+ } from '@veltra/sheet-core/grid'
9
9
  import type { DeconstructValue } from '@veltra/utils'
10
10
  import type { ComputedRef } from 'vue'
11
11