@veltra/sheet 2.0.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.
- package/dist/components/report/binding-badge.js +76 -0
- package/dist/components/report/designer/cell-coords.js +46 -0
- package/dist/components/report/designer/col-widths.js +15 -0
- package/dist/components/report/designer/conditional-rules/helpers.js +139 -0
- package/dist/components/report/designer/drop-highlight-overlay.js +76 -0
- package/dist/components/report/designer/float-panel.js +385 -0
- package/dist/components/report/designer/role.js +17 -0
- package/dist/components/report/designer/rule-preview.js +33 -0
- package/dist/components/report/designer/rule-row.js +269 -0
- package/dist/components/report/designer/rules-dialog.js +135 -0
- package/dist/components/report/designer/topology-overlay.js +122 -0
- package/dist/components/report/designer/topology.js +64 -0
- package/dist/components/report/designer/use-grid-overlay.js +75 -0
- package/dist/components/report/designer-hub.js +177 -0
- package/dist/components/report/field-panel-helpers.js +33 -0
- package/dist/components/report/field-panel.js +132 -0
- package/dist/components/report/filter-bar.js +74 -0
- package/dist/components/report/hub-connection-form.js +145 -0
- package/dist/components/report/hub-dataset-editor.js +394 -0
- package/dist/components/report/report-designer.js +343 -0
- package/dist/components/report/report-viewer.js +111 -0
- package/dist/components/report/style.d.ts +17 -0
- package/dist/components/report/style.js +18 -0
- package/dist/components/report/style2.css +869 -0
- package/dist/components/report/use-report-designer.js +360 -0
- package/dist/components/report/use-report-viewer.js +50 -0
- package/dist/components/sheet/formula-bar.js +393 -0
- package/dist/components/sheet/formula-suggest-list.js +66 -0
- package/dist/components/sheet/import-file.js +140 -0
- package/dist/components/sheet/insert-count-menu-item.js +68 -0
- package/dist/components/sheet/insert-image.js +79 -0
- package/dist/components/sheet/popup-helpers.js +73 -0
- package/dist/components/sheet/popups/border-popup.js +75 -0
- package/dist/components/sheet/popups/border-preset-glyph.js +106 -0
- package/dist/components/sheet/popups/export-popup.js +51 -0
- package/dist/components/sheet/popups/fill-color-popup.js +37 -0
- package/dist/components/sheet/popups/find-popup.js +113 -0
- package/dist/components/sheet/popups/font-color-popup.js +37 -0
- package/dist/components/sheet/popups/font-size-popup.js +63 -0
- package/dist/components/sheet/popups/import.worker.d.ts +21 -0
- package/dist/components/sheet/popups/import.worker.js +41 -0
- package/dist/components/sheet/popups/insert-image-popup.js +38 -0
- package/dist/components/sheet/sheet-context-menu.js +200 -0
- package/dist/components/sheet/sheet-tabs.js +162 -0
- package/dist/components/sheet/sheet-toolbar.js +106 -0
- package/dist/components/sheet/sheet.js +198 -0
- package/dist/components/sheet/style.d.ts +11 -0
- package/dist/components/sheet/style.js +12 -0
- package/dist/components/sheet/style2.css +654 -0
- package/dist/components/sheet/use-find-replace.js +161 -0
- package/dist/components/sheet/use-formula-ref-select.js +37 -0
- package/dist/components/sheet/use-formula-suggest.js +126 -0
- package/dist/components/sheet/use-sheet-grid.js +188 -0
- package/dist/components/sheet/use-sheet-state.js +122 -0
- package/dist/components/sheet/use-sheet-tabs-bar.js +90 -0
- package/dist/components/sheet/use-tool-groups.js +42 -0
- package/dist/components/sheet/use-tool-popup.js +123 -0
- package/dist/components/sheet/use-toolbar-scroll.js +72 -0
- package/dist/index.d.ts +18 -26
- package/dist/index.js +14 -24
- package/dist/report/binding.d.ts +45 -0
- package/dist/report/binding.js +175 -0
- package/dist/report/connector.d.ts +66 -0
- package/dist/report/connector.js +159 -0
- package/dist/report/export-xlsx.d.ts +19 -0
- package/dist/report/export-xlsx.js +95 -0
- package/dist/report/filter-bar.d.ts +10 -0
- package/dist/report/filter-bar.js +31 -0
- package/dist/report/index.d.ts +12 -0
- package/dist/report/params.d.ts +13 -0
- package/dist/report/params.js +61 -0
- package/dist/report/render/aggregate.js +157 -0
- package/dist/report/render/builder.d.ts +12 -0
- package/dist/report/render/builder.js +139 -0
- package/dist/report/render/coordinate.d.ts +25 -0
- package/dist/report/render/coordinate.js +733 -0
- package/dist/report/render/index.d.ts +14 -0
- package/dist/report/render/index.js +21 -0
- package/dist/report/render/style-resolver.js +50 -0
- package/dist/report/render/template-index.d.ts +24 -0
- package/dist/report/render/template-index.js +137 -0
- package/dist/report/rules/evaluate.d.ts +25 -0
- package/dist/report/rules/evaluate.js +82 -0
- package/dist/report/rules/index.d.ts +2 -0
- package/dist/report/template.d.ts +59 -0
- package/dist/report/template.js +80 -0
- package/dist/report/types.d.ts +85 -0
- package/dist/tools/builtin.js +279 -8
- package/dist/tools/context.d.ts +54 -11
- package/dist/tools/context.js +28 -5
- package/dist/tools/download.js +68 -0
- package/dist/tools/export.worker.d.ts +16 -0
- package/dist/tools/export.worker.js +29 -0
- package/dist/tools/registry.d.ts +7 -4
- package/dist/tools/registry.js +1 -3
- package/dist/types/index.d.ts +3 -1
- package/dist/types/report-designer.d.ts +36 -0
- package/dist/types/report-viewer.d.ts +38 -0
- package/dist/types/sheet.d.ts +22 -5
- package/package.json +10 -7
- package/src/components/report/__test__/conditional-rules-helpers.test.ts +87 -0
- package/src/components/report/__test__/field-panel-helpers.test.ts +65 -0
- package/src/components/report/__test__/float-panel-position.test.ts +45 -0
- package/src/components/report/__test__/report-designer.test.ts +388 -0
- package/src/components/report/__test__/report-viewer.test.ts +334 -0
- package/src/components/report/__test__/topology.test.ts +143 -0
- package/src/components/report/__test__/use-report-designer.test.ts +565 -0
- package/src/components/report/binding-badge.ts +73 -0
- package/src/components/report/designer/cell-coords.ts +94 -0
- package/src/components/report/designer/col-widths.ts +33 -0
- package/src/components/report/designer/conditional-rules/helpers.ts +186 -0
- package/src/components/report/designer/drop-highlight-overlay.vue +74 -0
- package/src/components/report/designer/float-panel.vue +387 -0
- package/src/components/report/designer/role.ts +32 -0
- package/src/components/report/designer/rule-preview.vue +40 -0
- package/src/components/report/designer/rule-row.vue +252 -0
- package/src/components/report/designer/rules-dialog.vue +126 -0
- package/src/components/report/designer/topology-overlay.vue +127 -0
- package/src/components/report/designer/topology.ts +124 -0
- package/src/components/report/designer/use-grid-overlay.ts +113 -0
- package/src/components/report/designer-hub.vue +198 -0
- package/src/components/report/field-panel-helpers.ts +44 -0
- package/src/components/report/field-panel.vue +136 -0
- package/src/components/report/filter-bar.vue +77 -0
- package/src/components/report/hub-connection-form.vue +124 -0
- package/src/components/report/hub-dataset-editor.vue +369 -0
- package/src/components/report/index.ts +2 -0
- package/src/components/report/report-designer.vue +356 -0
- package/src/components/report/report-viewer.vue +128 -0
- package/src/components/report/style-designer.scss +583 -0
- package/src/components/report/style-hub.scss +292 -0
- package/src/components/report/style-viewer.scss +104 -0
- package/src/components/report/style.scss +3 -0
- package/src/components/report/style.ts +20 -0
- package/src/components/report/use-report-designer.ts +547 -0
- package/src/components/report/use-report-viewer.ts +79 -0
- package/src/components/sheet/__test__/formula-bar.test.ts +474 -0
- package/src/components/sheet/__test__/import-file.test.ts +183 -0
- package/src/components/sheet/__test__/insert-count-menu-item.test.ts +123 -0
- package/src/components/sheet/__test__/insert-image-popup.test.ts +89 -0
- package/src/components/sheet/__test__/insert-image.test.ts +100 -0
- package/src/components/sheet/__test__/sheet-component.test.ts +993 -0
- package/src/components/sheet/__test__/sheet-context-menu.test.ts +206 -0
- package/src/components/sheet/__test__/use-formula-ref-select.test.ts +35 -0
- package/src/components/sheet/__test__/use-formula-suggest.test.ts +83 -0
- package/src/components/sheet/formula-bar.vue +473 -0
- package/src/components/sheet/formula-suggest-list.vue +64 -0
- package/src/components/sheet/import-file.ts +173 -0
- package/src/components/sheet/insert-count-menu-item.vue +69 -0
- package/src/components/sheet/insert-image.ts +90 -0
- package/src/components/sheet/parsing.ts +11 -0
- package/src/components/sheet/popup-helpers.ts +50 -0
- package/src/components/sheet/popups/border-popup.vue +93 -0
- package/src/components/sheet/popups/border-preset-glyph.vue +111 -0
- package/src/components/sheet/popups/export-popup.vue +52 -0
- package/src/components/sheet/popups/fill-color-popup.vue +39 -0
- package/src/components/sheet/popups/find-popup.vue +111 -0
- package/src/components/sheet/popups/font-color-popup.vue +39 -0
- package/src/components/sheet/popups/font-size-popup.vue +52 -0
- package/src/components/sheet/popups/import.worker.ts +66 -0
- package/src/components/sheet/popups/insert-image-popup.vue +39 -0
- package/src/components/sheet/sheet-context-menu.ts +229 -0
- package/src/components/sheet/sheet-tabs.vue +162 -0
- package/src/components/sheet/sheet-toolbar.vue +91 -0
- package/src/components/sheet/sheet.vue +211 -0
- package/src/components/sheet/style.scss +737 -0
- package/src/components/sheet/style.ts +13 -0
- package/src/components/sheet/use-find-replace.ts +200 -0
- package/src/components/sheet/use-formula-ref-select.ts +34 -0
- package/src/components/sheet/use-formula-suggest.ts +150 -0
- package/src/components/sheet/use-sheet-grid.ts +247 -0
- package/src/components/sheet/use-sheet-state.ts +161 -0
- package/src/components/sheet/use-sheet-tabs-bar.ts +115 -0
- package/src/components/sheet/use-tool-groups.ts +61 -0
- package/src/components/sheet/use-tool-popup.ts +150 -0
- package/src/components/sheet/use-toolbar-scroll.ts +95 -0
- package/src/env.d.ts +11 -0
- package/src/index.ts +39 -14
- package/src/report/__test__/binding.test.ts +218 -0
- package/src/report/__test__/connector.test.ts +218 -0
- package/src/report/__test__/export-xlsx.test.ts +118 -0
- package/src/report/__test__/filter-bar.test.ts +58 -0
- package/src/report/__test__/params.test.ts +156 -0
- package/src/report/__test__/render.test.ts +728 -0
- package/src/report/__test__/rules.test.ts +131 -0
- package/src/report/__test__/template.test.ts +355 -0
- package/src/report/binding.ts +243 -0
- package/src/report/connector.ts +205 -0
- package/src/report/export-xlsx.ts +118 -0
- package/src/report/filter-bar.ts +36 -0
- package/src/report/index.ts +13 -0
- package/src/report/params.ts +96 -0
- package/src/report/render/__test__/aggregate.test.ts +16 -0
- package/src/report/render/__test__/coordinate.test.ts +405 -0
- package/src/report/render/aggregate.ts +240 -0
- package/src/report/render/builder.ts +211 -0
- package/src/report/render/coordinate.ts +1239 -0
- package/src/report/render/index.ts +30 -0
- package/src/report/render/style-resolver.ts +68 -0
- package/src/report/render/template-index.ts +200 -0
- package/src/report/rules/evaluate.ts +113 -0
- package/src/report/rules/index.ts +7 -0
- package/src/report/template.ts +141 -0
- package/src/report/types.ts +96 -0
- package/src/tools/__test__/builtin.test.ts +208 -66
- package/src/tools/__test__/context.test.ts +62 -2
- package/src/tools/builtin.ts +350 -6
- package/src/tools/context.ts +89 -11
- package/src/tools/download.ts +82 -0
- package/src/tools/export.worker.ts +61 -0
- package/src/tools/registry.ts +16 -1
- package/src/types/index.ts +2 -0
- package/src/types/report-designer.ts +36 -0
- package/src/types/report-viewer.ts +37 -0
- package/src/types/sheet.ts +26 -3
- package/dist/core/address.d.ts +0 -60
- package/dist/core/address.js +0 -142
- package/dist/core/address.js.map +0 -1
- package/dist/core/cell-store.d.ts +0 -61
- package/dist/core/cell-store.js +0 -135
- package/dist/core/cell-store.js.map +0 -1
- package/dist/core/command/default-registry.d.ts +0 -10
- package/dist/core/command/default-registry.js +0 -18
- package/dist/core/command/default-registry.js.map +0 -1
- package/dist/core/command/history.d.ts +0 -64
- package/dist/core/command/history.js +0 -127
- package/dist/core/command/history.js.map +0 -1
- package/dist/core/command/merge-cells.d.ts +0 -21
- package/dist/core/command/merge-cells.js +0 -74
- package/dist/core/command/merge-cells.js.map +0 -1
- package/dist/core/command/registry.d.ts +0 -17
- package/dist/core/command/registry.js +0 -26
- package/dist/core/command/registry.js.map +0 -1
- package/dist/core/command/set-cell-formula.d.ts +0 -17
- package/dist/core/command/set-cell-formula.js +0 -29
- package/dist/core/command/set-cell-formula.js.map +0 -1
- package/dist/core/command/set-cell-value.d.ts +0 -22
- package/dist/core/command/set-cell-value.js +0 -35
- package/dist/core/command/set-cell-value.js.map +0 -1
- package/dist/core/command/types.d.ts +0 -68
- package/dist/core/events.js +0 -29
- package/dist/core/events.js.map +0 -1
- package/dist/core/fill.d.ts +0 -34
- package/dist/core/fill.js +0 -320
- package/dist/core/fill.js.map +0 -1
- package/dist/core/formula/ast.d.ts +0 -58
- package/dist/core/formula/ast.js +0 -38
- package/dist/core/formula/ast.js.map +0 -1
- package/dist/core/formula/dependency-graph.d.ts +0 -70
- package/dist/core/formula/dependency-graph.js +0 -269
- package/dist/core/formula/dependency-graph.js.map +0 -1
- package/dist/core/formula/errors.d.ts +0 -25
- package/dist/core/formula/errors.js +0 -36
- package/dist/core/formula/errors.js.map +0 -1
- package/dist/core/formula/evaluator.d.ts +0 -41
- package/dist/core/formula/evaluator.js +0 -154
- package/dist/core/formula/evaluator.js.map +0 -1
- package/dist/core/formula/functions.d.ts +0 -30
- package/dist/core/formula/functions.js +0 -209
- package/dist/core/formula/functions.js.map +0 -1
- package/dist/core/formula/parser.d.ts +0 -7
- package/dist/core/formula/parser.js +0 -208
- package/dist/core/formula/parser.js.map +0 -1
- package/dist/core/formula/tokenizer.d.ts +0 -37
- package/dist/core/formula/tokenizer.js +0 -146
- package/dist/core/formula/tokenizer.js.map +0 -1
- package/dist/core/merge-manager.d.ts +0 -64
- package/dist/core/merge-manager.js +0 -111
- package/dist/core/merge-manager.js.map +0 -1
- package/dist/core/selection.d.ts +0 -31
- package/dist/core/selection.js +0 -62
- package/dist/core/selection.js.map +0 -1
- package/dist/core/sheet.d.ts +0 -116
- package/dist/core/sheet.js +0 -224
- package/dist/core/sheet.js.map +0 -1
- package/dist/core/workbook.d.ts +0 -43
- package/dist/core/workbook.js +0 -77
- package/dist/core/workbook.js.map +0 -1
- package/dist/grid/sheet-grid.d.ts +0 -81
- package/dist/grid/sheet-grid.js +0 -331
- package/dist/grid/sheet-grid.js.map +0 -1
- package/dist/grid/vtable-theme.js +0 -80
- package/dist/grid/vtable-theme.js.map +0 -1
- package/dist/tools/builtin.js.map +0 -1
- package/dist/tools/context.js.map +0 -1
- package/dist/tools/registry.js.map +0 -1
- package/dist/vue/index.d.ts +0 -2
- package/dist/vue/sheet.js +0 -211
- package/dist/vue/sheet.js.map +0 -1
- package/dist/vue/sheet.vue.d.ts +0 -24
- package/dist/vue/style.d.ts +0 -1
- package/dist/vue/style.js +0 -2
- package/dist/vue/style2.css +0 -93
- package/src/core/__test__/address.test.ts +0 -113
- package/src/core/__test__/cell-store.test.ts +0 -97
- package/src/core/__test__/command.test.ts +0 -377
- package/src/core/__test__/fill.test.ts +0 -140
- package/src/core/__test__/formula-adversarial.test.ts +0 -265
- package/src/core/__test__/formula-engine.test.ts +0 -470
- package/src/core/__test__/formula-functions.test.ts +0 -178
- package/src/core/__test__/formula-parser.test.ts +0 -160
- package/src/core/__test__/history.test.ts +0 -225
- package/src/core/__test__/merge-manager.test.ts +0 -106
- package/src/core/__test__/sheet.test.ts +0 -142
- package/src/core/address.ts +0 -166
- package/src/core/cell-store.ts +0 -173
- package/src/core/command/default-registry.ts +0 -15
- package/src/core/command/history.ts +0 -167
- package/src/core/command/index.ts +0 -7
- package/src/core/command/merge-cells.ts +0 -74
- package/src/core/command/registry.ts +0 -30
- package/src/core/command/set-cell-formula.ts +0 -29
- package/src/core/command/set-cell-value.ts +0 -38
- package/src/core/command/types.ts +0 -73
- package/src/core/events.ts +0 -37
- package/src/core/fill.ts +0 -314
- package/src/core/formula/ast.ts +0 -66
- package/src/core/formula/dependency-graph.ts +0 -329
- package/src/core/formula/errors.ts +0 -41
- package/src/core/formula/evaluator.ts +0 -219
- package/src/core/formula/functions.ts +0 -266
- package/src/core/formula/index.ts +0 -7
- package/src/core/formula/parser.ts +0 -198
- package/src/core/formula/tokenizer.ts +0 -160
- package/src/core/merge-manager.ts +0 -158
- package/src/core/selection.ts +0 -66
- package/src/core/sheet.ts +0 -282
- package/src/core/workbook.ts +0 -99
- package/src/grid/__test__/canvas-mock.ts +0 -49
- package/src/grid/__test__/setup.ts +0 -3
- package/src/grid/__test__/sheet-grid-formula.test.ts +0 -140
- package/src/grid/__test__/sheet-grid.test.ts +0 -275
- package/src/grid/sheet-grid.ts +0 -407
- package/src/grid/vtable-theme.ts +0 -61
- package/src/vue/__test__/sheet-component.test.ts +0 -267
- package/src/vue/sheet.vue +0 -235
- package/src/vue/style.scss +0 -94
- package/src/vue/style.ts +0 -2
- /package/src/{vue → components/sheet}/index.ts +0 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { nextTick, onBeforeUnmount, onMounted, shallowRef, watch } from "vue";
|
|
2
|
+
import { applyWheelHorizontalScroll, computeOverflowNavState, scrollElementIntoView, scrollViewportByStep } from "@veltra/utils";
|
|
3
|
+
//#region src/components/sheet/use-sheet-tabs-bar.ts
|
|
4
|
+
/**
|
|
5
|
+
* Sheet 底部标签栏溢出滚动(滚动几何/滚轮转横滚/元素滚入视野共享
|
|
6
|
+
* @veltra/utils overflow-nav,见 #17;此处保留事件绑定与 watch 差异):
|
|
7
|
+
* - showNav / canPrev / canNext
|
|
8
|
+
* - 箭头按视口宽度 ~80% 步进
|
|
9
|
+
* - 活动 tab 滚入视野
|
|
10
|
+
* - 纵向滚轮转横滚;触控板横滑不拦截
|
|
11
|
+
* - 原生 ResizeObserver(不引入 @veltra/compositions peer)
|
|
12
|
+
*/
|
|
13
|
+
function useSheetTabsBar(options) {
|
|
14
|
+
const { viewportRef, listRef, sheetList, activeIndex } = options;
|
|
15
|
+
const showNav = shallowRef(false);
|
|
16
|
+
const canPrev = shallowRef(false);
|
|
17
|
+
const canNext = shallowRef(false);
|
|
18
|
+
let resizeObserver;
|
|
19
|
+
const updateNavState = () => {
|
|
20
|
+
const vp = viewportRef.value;
|
|
21
|
+
if (!vp) return;
|
|
22
|
+
const state = computeOverflowNavState(vp);
|
|
23
|
+
showNav.value = state.overflowing;
|
|
24
|
+
canPrev.value = state.canPrev;
|
|
25
|
+
canNext.value = state.canNext;
|
|
26
|
+
};
|
|
27
|
+
const scrollByStep = (dir) => {
|
|
28
|
+
const vp = viewportRef.value;
|
|
29
|
+
if (!vp) return;
|
|
30
|
+
scrollViewportByStep(vp, dir);
|
|
31
|
+
};
|
|
32
|
+
const ensureActiveVisible = () => {
|
|
33
|
+
const vp = viewportRef.value;
|
|
34
|
+
const list = listRef.value;
|
|
35
|
+
if (!vp || !list) return;
|
|
36
|
+
const index = activeIndex.value;
|
|
37
|
+
if (index < 0) return;
|
|
38
|
+
const el = list.children[index];
|
|
39
|
+
if (!el) return;
|
|
40
|
+
scrollElementIntoView(vp, el);
|
|
41
|
+
};
|
|
42
|
+
/** 鼠标滚轮(纵向)驱动水平滚动;触控板横滑(已有 deltaX)不拦截 */
|
|
43
|
+
const handleWheel = (e) => {
|
|
44
|
+
const vp = viewportRef.value;
|
|
45
|
+
if (!vp) return;
|
|
46
|
+
applyWheelHorizontalScroll(e, vp, showNav.value);
|
|
47
|
+
};
|
|
48
|
+
watch(activeIndex, async () => {
|
|
49
|
+
await nextTick();
|
|
50
|
+
ensureActiveVisible();
|
|
51
|
+
updateNavState();
|
|
52
|
+
});
|
|
53
|
+
watch(sheetList, async () => {
|
|
54
|
+
await nextTick();
|
|
55
|
+
updateNavState();
|
|
56
|
+
ensureActiveVisible();
|
|
57
|
+
}, { deep: false });
|
|
58
|
+
onMounted(() => {
|
|
59
|
+
const vp = viewportRef.value;
|
|
60
|
+
const list = listRef.value;
|
|
61
|
+
if (vp) {
|
|
62
|
+
vp.addEventListener("wheel", handleWheel, { passive: false });
|
|
63
|
+
vp.addEventListener("scroll", updateNavState, { passive: true });
|
|
64
|
+
}
|
|
65
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
66
|
+
resizeObserver = new ResizeObserver(() => updateNavState());
|
|
67
|
+
if (vp) resizeObserver.observe(vp);
|
|
68
|
+
if (list) resizeObserver.observe(list);
|
|
69
|
+
}
|
|
70
|
+
updateNavState();
|
|
71
|
+
nextTick(ensureActiveVisible);
|
|
72
|
+
});
|
|
73
|
+
onBeforeUnmount(() => {
|
|
74
|
+
const vp = viewportRef.value;
|
|
75
|
+
if (vp) {
|
|
76
|
+
vp.removeEventListener("wheel", handleWheel);
|
|
77
|
+
vp.removeEventListener("scroll", updateNavState);
|
|
78
|
+
}
|
|
79
|
+
resizeObserver?.disconnect();
|
|
80
|
+
resizeObserver = void 0;
|
|
81
|
+
});
|
|
82
|
+
return {
|
|
83
|
+
showNav,
|
|
84
|
+
canPrev,
|
|
85
|
+
canNext,
|
|
86
|
+
scrollByStep
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
//#endregion
|
|
90
|
+
export { useSheetTabsBar };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { defaultToolRegistry } from "../../tools/registry.js";
|
|
2
|
+
import { computed } from "vue";
|
|
3
|
+
//#region src/components/sheet/use-tool-groups.ts
|
|
4
|
+
/**
|
|
5
|
+
* 内置组稳定顺序:history | cell | text | edit | insert | file。
|
|
6
|
+
* 未列出的自定义组按注册先后排在已知组之后。
|
|
7
|
+
*/
|
|
8
|
+
const BUILTIN_GROUP_ORDER = [
|
|
9
|
+
"history",
|
|
10
|
+
"cell",
|
|
11
|
+
"text",
|
|
12
|
+
"edit",
|
|
13
|
+
"insert",
|
|
14
|
+
"file"
|
|
15
|
+
];
|
|
16
|
+
/**
|
|
17
|
+
* 工具栏分组视图模型:工具的 visible/disabled/active 是 (ctx) => boolean 纯函数,
|
|
18
|
+
* 依赖 stateTick 版本号(选区 / 历史 / 单元格 / 合并 / 冻结 / 注册表变化时 bump)触发重算。
|
|
19
|
+
*/
|
|
20
|
+
function useToolGroups(context, stateTick) {
|
|
21
|
+
return computed(() => {
|
|
22
|
+
stateTick.value;
|
|
23
|
+
const groups = defaultToolRegistry.getGroups().map((group) => ({
|
|
24
|
+
name: group.name,
|
|
25
|
+
tools: group.tools.map((tool) => ({
|
|
26
|
+
tool,
|
|
27
|
+
visible: tool.visible?.(context) ?? true,
|
|
28
|
+
disabled: tool.disabled?.(context) ?? false,
|
|
29
|
+
active: tool.active?.(context) ?? false
|
|
30
|
+
})).filter((item) => item.visible)
|
|
31
|
+
})).filter((group) => group.tools.length > 0);
|
|
32
|
+
const orderIndex = new Map(BUILTIN_GROUP_ORDER.map((name, index) => [name, index]));
|
|
33
|
+
return groups.sort((a, b) => {
|
|
34
|
+
const ai = orderIndex.get(a.name) ?? BUILTIN_GROUP_ORDER.length;
|
|
35
|
+
const bi = orderIndex.get(b.name) ?? BUILTIN_GROUP_ORDER.length;
|
|
36
|
+
if (ai !== bi) return ai - bi;
|
|
37
|
+
return 0;
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { useToolGroups };
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { defaultToolRegistry } from "../../tools/registry.js";
|
|
2
|
+
import { onBeforeUnmount, onMounted, shallowRef } from "vue";
|
|
3
|
+
//#region src/components/sheet/use-tool-popup.ts
|
|
4
|
+
/**
|
|
5
|
+
* 面板打开期间的写入是否合并为一个 undo 单元(关闭时提交):
|
|
6
|
+
* 填充颜色 / 边框 / 字体颜色 / 字号参与事务;查找(每次替换独立 undo)、
|
|
7
|
+
* 导出(下载侧效应,无模型写入)不参与。导入无弹层,不经此路径。
|
|
8
|
+
*/
|
|
9
|
+
function joinsTransaction(tool) {
|
|
10
|
+
return tool.popup === "fill-color" || tool.popup === "border" || tool.popup === "font-color" || tool.popup === "font-size";
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 弹层型工具编排(填充颜色 / 边框 / 查找 / 插入图片 / 导出):
|
|
14
|
+
* - popupTool:当前打开的弹层工具(null = 未打开)
|
|
15
|
+
* - popupAnchor:触发按钮元素(面板定位参照,见 sheet.vue 的 left 计算)
|
|
16
|
+
* - 打开 / 关闭时的事务包裹(面板期间写入合并为一个 undo 单元,关闭时提交)
|
|
17
|
+
* - 点击面板外关闭(面板内 @click.stop 不冒泡到 window)
|
|
18
|
+
* - Ctrl/Cmd+F 开合查找条(与工具按钮同一 toggle 逻辑)
|
|
19
|
+
* 导入在 sheet.vue 特殊处理(直接系统文件选择),不经弹层。
|
|
20
|
+
*/
|
|
21
|
+
function useToolPopup(context, rootEl) {
|
|
22
|
+
/** 当前打开的弹层工具(null = 未打开) */
|
|
23
|
+
const popupTool = shallowRef(null);
|
|
24
|
+
/** 触发按钮元素(打开时的 currentTarget;用于面板 left 对齐按钮) */
|
|
25
|
+
const popupAnchor = shallowRef(null);
|
|
26
|
+
/** 延迟打开定时器(#23:组件卸载后不再执行 openPopup) */
|
|
27
|
+
let openTimer = null;
|
|
28
|
+
function openPopup(tool, anchor) {
|
|
29
|
+
closePopup();
|
|
30
|
+
popupTool.value = tool;
|
|
31
|
+
popupAnchor.value = anchor ?? null;
|
|
32
|
+
if (joinsTransaction(tool)) context.beginTransaction();
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* 延迟到本次点击事件流结束后打开(setTimeout 宏任务,避开冒泡到 window 时
|
|
36
|
+
* onWindowClick 误关——queueMicrotask 会在事件传播中途的 microtask checkpoint
|
|
37
|
+
* 执行,面板会被同一 click 关闭)。保存 timer id,卸载/提前关闭时取消。
|
|
38
|
+
*/
|
|
39
|
+
function scheduleOpen(tool, anchor) {
|
|
40
|
+
if (openTimer !== null) clearTimeout(openTimer);
|
|
41
|
+
openTimer = setTimeout(() => {
|
|
42
|
+
openTimer = null;
|
|
43
|
+
openPopup(tool, anchor);
|
|
44
|
+
}, 0);
|
|
45
|
+
}
|
|
46
|
+
/** 关闭弹层并提交面板期间的事务(无写入则空事务,不入历史) */
|
|
47
|
+
function closePopup() {
|
|
48
|
+
if (openTimer !== null) {
|
|
49
|
+
clearTimeout(openTimer);
|
|
50
|
+
openTimer = null;
|
|
51
|
+
}
|
|
52
|
+
const tool = popupTool.value;
|
|
53
|
+
if (!tool) return;
|
|
54
|
+
popupTool.value = null;
|
|
55
|
+
popupAnchor.value = null;
|
|
56
|
+
if (!joinsTransaction(tool)) return;
|
|
57
|
+
try {
|
|
58
|
+
context.commit();
|
|
59
|
+
} catch {
|
|
60
|
+
context.rollback();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function handleToolClick(tool, event) {
|
|
64
|
+
if (tool.disabled?.(context)) return;
|
|
65
|
+
if (tool.popup) {
|
|
66
|
+
if (popupTool.value?.id === tool.id) {
|
|
67
|
+
closePopup();
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
scheduleOpen(tool, event?.currentTarget instanceof HTMLElement ? event.currentTarget : null);
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
tool.onClick(context);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* 点击面板外任意处关闭。面板内部 @click.stop 不冒泡到 window;
|
|
77
|
+
* 触发按钮本身的点击由 handleToolClick 同步处理(打开/关闭 toggle),
|
|
78
|
+
* 冒泡到达这里时 popupTool 已更新,不会误关。
|
|
79
|
+
*/
|
|
80
|
+
function onWindowClick() {
|
|
81
|
+
if (!popupTool.value) return;
|
|
82
|
+
closePopup();
|
|
83
|
+
}
|
|
84
|
+
/** Ctrl/Cmd+F 打开 / 关闭查找条(与工具按钮同一 toggle 逻辑) */
|
|
85
|
+
function onGlobalKeydown(event) {
|
|
86
|
+
if (!(event.metaKey || event.ctrlKey) || event.key.toLowerCase() !== "f") return;
|
|
87
|
+
const root = rootEl.value;
|
|
88
|
+
if (root) {
|
|
89
|
+
const target = event.target instanceof Node ? event.target : null;
|
|
90
|
+
const active = document.activeElement instanceof Node ? document.activeElement : null;
|
|
91
|
+
if (!(target !== null && root.contains(target) || active !== null && root.contains(active)) && popupTool.value === null) return;
|
|
92
|
+
}
|
|
93
|
+
event.preventDefault();
|
|
94
|
+
const findTool = defaultToolRegistry.get("find");
|
|
95
|
+
if (!findTool) return;
|
|
96
|
+
if (popupTool.value?.id === findTool.id) {
|
|
97
|
+
closePopup();
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
scheduleOpen(findTool);
|
|
101
|
+
}
|
|
102
|
+
onMounted(() => {
|
|
103
|
+
window.addEventListener("click", onWindowClick);
|
|
104
|
+
window.addEventListener("keydown", onGlobalKeydown);
|
|
105
|
+
});
|
|
106
|
+
onBeforeUnmount(() => {
|
|
107
|
+
if (openTimer !== null) {
|
|
108
|
+
clearTimeout(openTimer);
|
|
109
|
+
openTimer = null;
|
|
110
|
+
}
|
|
111
|
+
closePopup();
|
|
112
|
+
window.removeEventListener("click", onWindowClick);
|
|
113
|
+
window.removeEventListener("keydown", onGlobalKeydown);
|
|
114
|
+
});
|
|
115
|
+
return {
|
|
116
|
+
popupTool,
|
|
117
|
+
popupAnchor,
|
|
118
|
+
closePopup,
|
|
119
|
+
handleToolClick
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
//#endregion
|
|
123
|
+
export { useToolPopup };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { onBeforeUnmount, onMounted, shallowRef, watch } from "vue";
|
|
2
|
+
import { applyWheelHorizontalScroll, computeOverflowNavState, scrollViewportByStep } from "@veltra/utils";
|
|
3
|
+
//#region src/components/sheet/use-toolbar-scroll.ts
|
|
4
|
+
/**
|
|
5
|
+
* 工具栏溢出滚动(滚动几何/滚轮转横滚共享 @veltra/utils overflow-nav,见 #17;
|
|
6
|
+
* 无活动项跟随):
|
|
7
|
+
* - 内容超出视口宽度时显示左右箭头(showNav / canPrev / canNext)
|
|
8
|
+
* - 箭头按视口宽度 ~80% 步进
|
|
9
|
+
* - 纵向滚轮转横滚;触控板横滑不拦截
|
|
10
|
+
* - 原生 ResizeObserver(不引入 @veltra/compositions peer)
|
|
11
|
+
*/
|
|
12
|
+
function useToolbarScroll(options) {
|
|
13
|
+
const { viewportRef, listRef, content } = options;
|
|
14
|
+
const showNav = shallowRef(false);
|
|
15
|
+
const canPrev = shallowRef(false);
|
|
16
|
+
const canNext = shallowRef(false);
|
|
17
|
+
let resizeObserver;
|
|
18
|
+
const updateNavState = () => {
|
|
19
|
+
const vp = viewportRef.value;
|
|
20
|
+
if (!vp) return;
|
|
21
|
+
const state = computeOverflowNavState(vp);
|
|
22
|
+
showNav.value = state.overflowing;
|
|
23
|
+
canPrev.value = state.canPrev;
|
|
24
|
+
canNext.value = state.canNext;
|
|
25
|
+
};
|
|
26
|
+
const scrollByStep = (dir) => {
|
|
27
|
+
const vp = viewportRef.value;
|
|
28
|
+
if (!vp) return;
|
|
29
|
+
scrollViewportByStep(vp, dir);
|
|
30
|
+
};
|
|
31
|
+
/** 鼠标滚轮(纵向)驱动水平滚动;触控板横滑(已有 deltaX)不拦截 */
|
|
32
|
+
const handleWheel = (e) => {
|
|
33
|
+
const vp = viewportRef.value;
|
|
34
|
+
if (!vp) return;
|
|
35
|
+
applyWheelHorizontalScroll(e, vp, showNav.value);
|
|
36
|
+
};
|
|
37
|
+
watch(content, async () => {
|
|
38
|
+
await Promise.resolve();
|
|
39
|
+
updateNavState();
|
|
40
|
+
}, { deep: false });
|
|
41
|
+
onMounted(() => {
|
|
42
|
+
const vp = viewportRef.value;
|
|
43
|
+
if (vp) {
|
|
44
|
+
vp.addEventListener("wheel", handleWheel, { passive: false });
|
|
45
|
+
vp.addEventListener("scroll", updateNavState, { passive: true });
|
|
46
|
+
}
|
|
47
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
48
|
+
resizeObserver = new ResizeObserver(() => updateNavState());
|
|
49
|
+
if (vp) resizeObserver.observe(vp);
|
|
50
|
+
const list = listRef.value;
|
|
51
|
+
if (list) resizeObserver.observe(list);
|
|
52
|
+
}
|
|
53
|
+
updateNavState();
|
|
54
|
+
});
|
|
55
|
+
onBeforeUnmount(() => {
|
|
56
|
+
const vp = viewportRef.value;
|
|
57
|
+
if (vp) {
|
|
58
|
+
vp.removeEventListener("wheel", handleWheel);
|
|
59
|
+
vp.removeEventListener("scroll", updateNavState);
|
|
60
|
+
}
|
|
61
|
+
resizeObserver?.disconnect();
|
|
62
|
+
resizeObserver = void 0;
|
|
63
|
+
});
|
|
64
|
+
return {
|
|
65
|
+
showNav,
|
|
66
|
+
canPrev,
|
|
67
|
+
canNext,
|
|
68
|
+
scrollByStep
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
export { useToolbarScroll };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,29 +1,21 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { AstNode, AstReference, BinaryOperator, collectReferences } from "./core/formula/ast.js";
|
|
5
|
-
import { DependencyGraph, FormulaDependency, FormulaNode } from "./core/formula/dependency-graph.js";
|
|
6
|
-
import { CellInfo, MergeManager, MergeResult, MergedCellKind } from "./core/merge-manager.js";
|
|
7
|
-
import { SelectionModel, SelectionState } from "./core/selection.js";
|
|
8
|
-
import { Sheet, SheetEvents } from "./core/sheet.js";
|
|
9
|
-
import { CellPatch, Command, CommandContext, CommandResult, MergePatch, Mutation, Patch, PatchDirection } from "./core/command/types.js";
|
|
10
|
-
import { SetCellValueCommand, SetCellValueItem, SetCellValueParams } from "./core/command/set-cell-value.js";
|
|
11
|
-
import { FillDirection, GenerateFillOptions, computeFillTargetRange, generateFill, shiftFormulaRefs } from "./core/fill.js";
|
|
12
|
-
import { Workbook, WorkbookEvents } from "./core/workbook.js";
|
|
13
|
-
import { CommandRegistry } from "./core/command/registry.js";
|
|
14
|
-
import { SetCellFormulaCommand, SetCellFormulaParams } from "./core/command/set-cell-formula.js";
|
|
15
|
-
import { MergeCellsCommand, MergeCellsParams, UnmergeCellsCommand, UnmergeCellsParams } from "./core/command/merge-cells.js";
|
|
16
|
-
import { defaultCommandRegistry } from "./core/command/default-registry.js";
|
|
17
|
-
import { FORMULA_ERROR_CODES, FormulaError, FormulaErrorCode, formulaError, isFormulaError, isFormulaErrorCode } from "./core/formula/errors.js";
|
|
18
|
-
import { FormulaOperator, FormulaParseError, FormulaToken, tokenizeFormula } from "./core/formula/tokenizer.js";
|
|
19
|
-
import { parseFormula } from "./core/formula/parser.js";
|
|
20
|
-
import { EvalValue, FormulaEvalContext, ScalarValue, coerceToBoolean, coerceToNumber, coerceToText, compareScalars, evaluateAst } from "./core/formula/evaluator.js";
|
|
21
|
-
import { FormulaFunction, getFormulaFunction, invokeFormulaFunction, registerFormulaFunction } from "./core/formula/functions.js";
|
|
22
|
-
import { SheetGrid, SheetGridContextMenuInfo, SheetGridOptions } from "./grid/sheet-grid.js";
|
|
1
|
+
import _sfc_main$2 from "./components/sheet/sheet.js";
|
|
2
|
+
import _sfc_main$1 from "./components/report/report-viewer.js";
|
|
3
|
+
import _sfc_main from "./components/report/report-designer.js";
|
|
23
4
|
import { SheetContext, createSheetContext } from "./tools/context.js";
|
|
24
|
-
import {
|
|
5
|
+
import { SheetTool, SheetToolGroup, SheetToolPopupType, defaultToolRegistry, registerTool, unregisterTool } from "./tools/registry.js";
|
|
25
6
|
import { SheetEmits, SheetExposed, SheetProps, _SheetExposed } from "./types/sheet.js";
|
|
7
|
+
import { ConditionalOperator, ConditionalRule, DatasetCatalogItem, DatasetField, DatasetRecords, ParamValues, QueryParamDef, QueryParamOption, QueryParamType, ReportAggregate, ReportBinding, ReportExpand, ReportPreset, ReportSort } from "./report/types.js";
|
|
8
|
+
import { REPORT_META_NAMESPACE, applyReportPreset, createReportBinding, formatBindingPlaceholder, formatCellAddress, inferColParentCandidate, inferDropPreset, inferReportPreset, inferRowParentCandidate, isExpansionBandRow, isHorizontalExpandBinding, isVerticalExpandBinding, listColParentCandidates, listRowParentCandidates, parseCellAddress, presetBindingPatch, setBindingCatalog } from "./report/binding.js";
|
|
9
|
+
import { ConditionalEvalContext, evaluateCondition, evaluateConditionalStyle, resolveRuleCompareValue, toComparableNumber } from "./report/rules/evaluate.js";
|
|
10
|
+
import { buildParamDefs, extractParamIds, resolveBoundDatasetParams } from "./report/params.js";
|
|
11
|
+
import { ReportColWidthEntry, buildColumnDefs, exportFilledReportXlsx, pxToExcelColWidth } from "./report/export-xlsx.js";
|
|
12
|
+
import { mapFilledColWidths } from "./report/render/builder.js";
|
|
13
|
+
import { renderReport, resolveFilledColWidths } from "./report/render/index.js";
|
|
14
|
+
import { ConnectionType, ConnectorError, CreateHttpConnectorOptions, DEFAULT_CONNECTION_PORTS, DataConnection, DataConnector, QueryResult, Result, createHttpConnector, resolvePortOnTypeChange } from "./report/connector.js";
|
|
15
|
+
import { IncompatibleTemplateVersionError, REPORT_TEMPLATE_VERSION, ReportDatasetDef, ReportTemplate, assertCompatibleTemplateVersion, createReportTemplate, fetchTemplateRecords, getBoundDatasetIds, getTemplateDatasets, resolveParamDefaults, resolveTemplateParams } from "./report/template.js";
|
|
16
|
+
import { parseDateRangeValue, patchParamValues, resolveNumberParamValue } from "./report/filter-bar.js";
|
|
17
|
+
import "./report/index.js";
|
|
18
|
+
import { ReportViewerExposed, ReportViewerProps, _ReportViewerExposed } from "./types/report-viewer.js";
|
|
19
|
+
import { ReportDesignerEmits, ReportDesignerExposed, ReportDesignerProps, _ReportDesignerExposed } from "./types/report-designer.js";
|
|
26
20
|
import "./types/index.js";
|
|
27
|
-
|
|
28
|
-
import "./vue/index.js";
|
|
29
|
-
export { AstNode, AstReference, BinaryOperator, COL_KEY_BASE, CellAddress, CellData, CellInfo, CellPatch, CellRange, CellSnapshotItem, CellStore, CellType, CellValue, Command, CommandContext, CommandRegistry, CommandResult, DEFAULT_HISTORY_CAPACITY, DEFAULT_TOOL_GROUP, DependencyGraph, EvalValue, FORMULA_ERROR_CODES, FillDirection, FormulaDependency, FormulaError, FormulaErrorCode, FormulaEvalContext, FormulaFunction, FormulaNode, FormulaOperator, FormulaParseError, FormulaToken, GenerateFillOptions, HistoryManager, HistoryState, MergeCellsCommand, MergeCellsParams, MergeManager, MergePatch, MergeResult, MergedCellKind, Mutation, Patch, PatchDirection, ScalarValue, SelectionModel, SelectionState, SetCellFormulaCommand, SetCellFormulaParams, SetCellValueCommand, SetCellValueItem, SetCellValueParams, Sheet, SheetContext, SheetEmits, SheetEvents, SheetExposed, SheetGrid, SheetGridContextMenuInfo, SheetGridOptions, SheetProps, SheetTool, SheetToolGroup, ToolRegistry, _default as USheet, UnmergeCellsCommand, UnmergeCellsParams, Workbook, WorkbookEvents, _SheetExposed, addressFromKey, addressesEqual, boundingBox, cellDataEqual, cellKey, coerceToBoolean, coerceToNumber, coerceToText, colIndexToName, colNameToIndex, collectReferences, compareScalars, computeFillTargetRange, createRange, createSheetContext, defaultCommandRegistry, defaultToolRegistry, evaluateAst, formatAddress, formatRange, formulaError, generateFill, getFormulaFunction, inferCellType, invokeFormulaFunction, isEmptyCellData, isFormulaError, isFormulaErrorCode, iterateRange, parseAddress, parseFormula, parseRange, rangeContainsAddress, rangeContainsRange, rangeSize, rangesEqual, rangesIntersect, registerFormulaFunction, registerTool, shiftFormulaRefs, tokenizeFormula, unregisterTool };
|
|
21
|
+
export { type ConditionalEvalContext, ConditionalOperator, ConditionalRule, ConnectionType, ConnectorError, CreateHttpConnectorOptions, DEFAULT_CONNECTION_PORTS, DataConnection, DataConnector, DatasetCatalogItem, DatasetField, DatasetRecords, IncompatibleTemplateVersionError, ParamValues, QueryParamDef, QueryParamOption, QueryParamType, QueryResult, REPORT_META_NAMESPACE, REPORT_TEMPLATE_VERSION, ReportAggregate, ReportBinding, ReportColWidthEntry, ReportDatasetDef, type ReportDesignerEmits, type ReportDesignerExposed, type ReportDesignerProps, ReportExpand, ReportPreset, ReportSort, ReportTemplate, type ReportViewerExposed, type ReportViewerProps, Result, type SheetContext, type SheetEmits, type SheetExposed, type SheetProps, type SheetTool, type SheetToolGroup, type SheetToolPopupType, _sfc_main as UReportDesigner, _sfc_main$1 as UReportViewer, _sfc_main$2 as USheet, type _ReportDesignerExposed, type _ReportViewerExposed, type _SheetExposed, applyReportPreset, assertCompatibleTemplateVersion, buildColumnDefs, buildParamDefs, createHttpConnector, createReportBinding, createReportTemplate, createSheetContext, defaultToolRegistry, evaluateCondition, evaluateConditionalStyle, exportFilledReportXlsx, extractParamIds, fetchTemplateRecords, formatBindingPlaceholder, formatCellAddress, getBoundDatasetIds, getTemplateDatasets, inferColParentCandidate, inferDropPreset, inferReportPreset, inferRowParentCandidate, isExpansionBandRow, isHorizontalExpandBinding, isVerticalExpandBinding, listColParentCandidates, listRowParentCandidates, mapFilledColWidths, parseCellAddress, parseDateRangeValue, patchParamValues, presetBindingPatch, pxToExcelColWidth, registerTool, renderReport, resolveBoundDatasetParams, resolveFilledColWidths, resolveNumberParamValue, resolveParamDefaults, resolvePortOnTypeChange, resolveRuleCompareValue, resolveTemplateParams, setBindingCatalog, toComparableNumber, unregisterTool };
|
package/dist/index.js
CHANGED
|
@@ -1,26 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { DEFAULT_TOOL_GROUP, ToolRegistry, defaultToolRegistry, registerTool, unregisterTool } from "./tools/registry.js";
|
|
1
|
+
import { defaultToolRegistry, registerTool, unregisterTool } from "./tools/registry.js";
|
|
3
2
|
import "./tools/builtin.js";
|
|
4
|
-
import { CellStore, cellDataEqual, inferCellType, isEmptyCellData } from "./core/cell-store.js";
|
|
5
|
-
import { computeFillTargetRange, generateFill, shiftFormulaRefs } from "./core/fill.js";
|
|
6
|
-
import { MergeManager } from "./core/merge-manager.js";
|
|
7
|
-
import { SelectionModel } from "./core/selection.js";
|
|
8
|
-
import { MergeCellsCommand, UnmergeCellsCommand } from "./core/command/merge-cells.js";
|
|
9
|
-
import { CommandRegistry } from "./core/command/registry.js";
|
|
10
|
-
import { SetCellFormulaCommand } from "./core/command/set-cell-formula.js";
|
|
11
|
-
import { SetCellValueCommand } from "./core/command/set-cell-value.js";
|
|
12
|
-
import { defaultCommandRegistry } from "./core/command/default-registry.js";
|
|
13
|
-
import { DEFAULT_HISTORY_CAPACITY, HistoryManager } from "./core/command/history.js";
|
|
14
|
-
import { collectReferences } from "./core/formula/ast.js";
|
|
15
|
-
import { FORMULA_ERROR_CODES, formulaError, isFormulaError, isFormulaErrorCode } from "./core/formula/errors.js";
|
|
16
|
-
import { coerceToBoolean, coerceToNumber, coerceToText, compareScalars, evaluateAst } from "./core/formula/evaluator.js";
|
|
17
|
-
import { getFormulaFunction, invokeFormulaFunction, registerFormulaFunction } from "./core/formula/functions.js";
|
|
18
|
-
import { FormulaParseError, tokenizeFormula } from "./core/formula/tokenizer.js";
|
|
19
|
-
import { parseFormula } from "./core/formula/parser.js";
|
|
20
|
-
import { DependencyGraph } from "./core/formula/dependency-graph.js";
|
|
21
|
-
import { Sheet } from "./core/sheet.js";
|
|
22
|
-
import { Workbook } from "./core/workbook.js";
|
|
23
|
-
import { SheetGrid } from "./grid/sheet-grid.js";
|
|
24
3
|
import { createSheetContext } from "./tools/context.js";
|
|
25
|
-
import _sfc_main from "./
|
|
26
|
-
|
|
4
|
+
import _sfc_main$2 from "./components/sheet/sheet.js";
|
|
5
|
+
import { buildColumnDefs, exportFilledReportXlsx, pxToExcelColWidth } from "./report/export-xlsx.js";
|
|
6
|
+
import { parseDateRangeValue, patchParamValues, resolveNumberParamValue } from "./report/filter-bar.js";
|
|
7
|
+
import { REPORT_META_NAMESPACE, applyReportPreset, createReportBinding, formatBindingPlaceholder, formatCellAddress, inferColParentCandidate, inferDropPreset, inferReportPreset, inferRowParentCandidate, isExpansionBandRow, isHorizontalExpandBinding, isVerticalExpandBinding, listColParentCandidates, listRowParentCandidates, parseCellAddress, presetBindingPatch, setBindingCatalog } from "./report/binding.js";
|
|
8
|
+
import { evaluateCondition, evaluateConditionalStyle, resolveRuleCompareValue, toComparableNumber } from "./report/rules/evaluate.js";
|
|
9
|
+
import { mapFilledColWidths } from "./report/render/builder.js";
|
|
10
|
+
import { renderReport, resolveFilledColWidths } from "./report/render/index.js";
|
|
11
|
+
import { buildParamDefs, extractParamIds, resolveBoundDatasetParams } from "./report/params.js";
|
|
12
|
+
import { IncompatibleTemplateVersionError, REPORT_TEMPLATE_VERSION, assertCompatibleTemplateVersion, createReportTemplate, fetchTemplateRecords, getBoundDatasetIds, getTemplateDatasets, resolveParamDefaults, resolveTemplateParams } from "./report/template.js";
|
|
13
|
+
import _sfc_main$1 from "./components/report/report-viewer.js";
|
|
14
|
+
import { DEFAULT_CONNECTION_PORTS, createHttpConnector, resolvePortOnTypeChange } from "./report/connector.js";
|
|
15
|
+
import _sfc_main from "./components/report/report-designer.js";
|
|
16
|
+
export { DEFAULT_CONNECTION_PORTS, IncompatibleTemplateVersionError, REPORT_META_NAMESPACE, REPORT_TEMPLATE_VERSION, _sfc_main as UReportDesigner, _sfc_main$1 as UReportViewer, _sfc_main$2 as USheet, applyReportPreset, assertCompatibleTemplateVersion, buildColumnDefs, buildParamDefs, createHttpConnector, createReportBinding, createReportTemplate, createSheetContext, defaultToolRegistry, evaluateCondition, evaluateConditionalStyle, exportFilledReportXlsx, extractParamIds, fetchTemplateRecords, formatBindingPlaceholder, formatCellAddress, getBoundDatasetIds, getTemplateDatasets, inferColParentCandidate, inferDropPreset, inferReportPreset, inferRowParentCandidate, isExpansionBandRow, isHorizontalExpandBinding, isVerticalExpandBinding, listColParentCandidates, listRowParentCandidates, mapFilledColWidths, parseCellAddress, parseDateRangeValue, patchParamValues, presetBindingPatch, pxToExcelColWidth, registerTool, renderReport, resolveBoundDatasetParams, resolveFilledColWidths, resolveNumberParamValue, resolveParamDefaults, resolvePortOnTypeChange, resolveRuleCompareValue, resolveTemplateParams, setBindingCatalog, toComparableNumber, unregisterTool };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { DatasetCatalogItem, ReportBinding, ReportPreset } from "./types.js";
|
|
2
|
+
import { CellAddress } from "@veltra/sheet-core";
|
|
3
|
+
//#region src/report/binding.d.ts
|
|
4
|
+
declare function setBindingCatalog(catalog: DatasetCatalogItem[]): void;
|
|
5
|
+
declare const REPORT_META_NAMESPACE = "report";
|
|
6
|
+
/** 预设 → 绑定字段补丁(父格除 grandTotal 外均保留推断值) */
|
|
7
|
+
declare function presetBindingPatch(preset: ReportPreset, options?: {
|
|
8
|
+
transpose?: boolean;
|
|
9
|
+
}): Partial<ReportBinding>;
|
|
10
|
+
/** 将预设写入绑定(grandTotal 清空双父格;其余保留既有父格) */
|
|
11
|
+
declare function applyReportPreset(binding: ReportBinding, preset: ReportPreset, options?: {
|
|
12
|
+
transpose?: boolean;
|
|
13
|
+
}): ReportBinding;
|
|
14
|
+
declare function isVerticalExpandBinding(binding: ReportBinding): boolean;
|
|
15
|
+
declare function isHorizontalExpandBinding(binding: ReportBinding): boolean;
|
|
16
|
+
/** 指定模板行是否含纵向扩展绑定(展开带行) */
|
|
17
|
+
declare function isExpansionBandRow(row: number, getBindingAt: (addr: CellAddress) => ReportBinding | undefined, scanCols?: number): boolean;
|
|
18
|
+
/** 落格时推断预设:默认明细;数值字段且位于展开带正下方相邻行 → 小计 */
|
|
19
|
+
declare function inferDropPreset(addr: CellAddress, fieldType: DatasetCatalogItem['fields'][number]['type'], getBindingAt: (addr: CellAddress) => ReportBinding | undefined): ReportPreset;
|
|
20
|
+
/** 同数据集纵向扩展绑定格(行方向父格下拉候选) */
|
|
21
|
+
declare function listRowParentCandidates(binding: ReportBinding, entries: ReadonlyArray<{
|
|
22
|
+
addr: CellAddress;
|
|
23
|
+
binding: ReportBinding;
|
|
24
|
+
}>): CellAddress[];
|
|
25
|
+
/** 同数据集横向扩展绑定格(列方向父格下拉候选) */
|
|
26
|
+
declare function listColParentCandidates(binding: ReportBinding, entries: ReadonlyArray<{
|
|
27
|
+
addr: CellAddress;
|
|
28
|
+
binding: ReportBinding;
|
|
29
|
+
}>): CellAddress[];
|
|
30
|
+
/** 同列向上找最近的纵向扩展绑定,作为 rowParent 候选 */
|
|
31
|
+
declare function inferRowParentCandidate(addr: CellAddress, getBindingAt: (addr: CellAddress) => ReportBinding | undefined): CellAddress | null;
|
|
32
|
+
/** 同行向左找最近的横向扩展绑定,作为 colParent 候选 */
|
|
33
|
+
declare function inferColParentCandidate(addr: CellAddress, getBindingAt: (addr: CellAddress) => ReportBinding | undefined): CellAddress | null;
|
|
34
|
+
/** 从绑定字段推断预设;不匹配任何预设时返回 null(自定义) */
|
|
35
|
+
declare function inferReportPreset(binding: ReportBinding): ReportPreset | null;
|
|
36
|
+
/** 默认明细 + 纵向扩展 */
|
|
37
|
+
declare function createReportBinding(dataset: DatasetCatalogItem, fieldName: string): ReportBinding;
|
|
38
|
+
/** 设计地址 → A1 标签(支持多字母列) */
|
|
39
|
+
declare function formatCellAddress(addr: CellAddress): string;
|
|
40
|
+
/** A1 标签 → 设计地址;非法输入返回 null */
|
|
41
|
+
declare function parseCellAddress(label: string): CellAddress | null;
|
|
42
|
+
/** Binding Placeholder 中文可读文案(如「分组 · 客户」) */
|
|
43
|
+
declare function formatBindingPlaceholder(binding: ReportBinding, resolveLabel?: (datasetId: string, fieldName: string) => string): string;
|
|
44
|
+
//#endregion
|
|
45
|
+
export { REPORT_META_NAMESPACE, applyReportPreset, createReportBinding, formatBindingPlaceholder, formatCellAddress, inferColParentCandidate, inferDropPreset, inferReportPreset, inferRowParentCandidate, isExpansionBandRow, isHorizontalExpandBinding, isVerticalExpandBinding, listColParentCandidates, listRowParentCandidates, parseCellAddress, presetBindingPatch, setBindingCatalog };
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { formatAddress, parseAddress } from "@veltra/sheet-core";
|
|
2
|
+
//#region src/report/binding.ts
|
|
3
|
+
/** 字段 label 解析用的 catalog(由宿主注入) */
|
|
4
|
+
let bindingCatalog = [];
|
|
5
|
+
function setBindingCatalog(catalog) {
|
|
6
|
+
bindingCatalog = catalog;
|
|
7
|
+
}
|
|
8
|
+
const REPORT_META_NAMESPACE = "report";
|
|
9
|
+
const AGGREGATE_PLACEHOLDER_TAG = {
|
|
10
|
+
list: "明细",
|
|
11
|
+
group: "分组",
|
|
12
|
+
sum: "求和",
|
|
13
|
+
avg: "平均",
|
|
14
|
+
count: "计数",
|
|
15
|
+
max: "最大",
|
|
16
|
+
min: "最小"
|
|
17
|
+
};
|
|
18
|
+
/** 预设 → 绑定字段补丁(父格除 grandTotal 外均保留推断值) */
|
|
19
|
+
function presetBindingPatch(preset, options) {
|
|
20
|
+
const expand = options?.transpose ? "right" : "down";
|
|
21
|
+
switch (preset) {
|
|
22
|
+
case "groupHeader": return {
|
|
23
|
+
preset,
|
|
24
|
+
expand,
|
|
25
|
+
aggregate: "group"
|
|
26
|
+
};
|
|
27
|
+
case "detail": return {
|
|
28
|
+
preset,
|
|
29
|
+
expand,
|
|
30
|
+
aggregate: "list"
|
|
31
|
+
};
|
|
32
|
+
case "subtotal": return {
|
|
33
|
+
preset,
|
|
34
|
+
expand: "none",
|
|
35
|
+
aggregate: "sum"
|
|
36
|
+
};
|
|
37
|
+
case "grandTotal": return {
|
|
38
|
+
preset,
|
|
39
|
+
expand: "none",
|
|
40
|
+
aggregate: "sum",
|
|
41
|
+
rowParent: void 0,
|
|
42
|
+
colParent: void 0
|
|
43
|
+
};
|
|
44
|
+
case "cross": return {
|
|
45
|
+
preset,
|
|
46
|
+
expand: "none",
|
|
47
|
+
aggregate: "sum"
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/** 将预设写入绑定(grandTotal 清空双父格;其余保留既有父格) */
|
|
52
|
+
function applyReportPreset(binding, preset, options) {
|
|
53
|
+
const patch = presetBindingPatch(preset, options);
|
|
54
|
+
const next = {
|
|
55
|
+
...binding,
|
|
56
|
+
...patch
|
|
57
|
+
};
|
|
58
|
+
if (preset === "grandTotal") {
|
|
59
|
+
delete next.rowParent;
|
|
60
|
+
delete next.colParent;
|
|
61
|
+
}
|
|
62
|
+
return next;
|
|
63
|
+
}
|
|
64
|
+
function isVerticalExpandBinding(binding) {
|
|
65
|
+
return binding.expand === "down" && (binding.aggregate === "group" || binding.aggregate === "list");
|
|
66
|
+
}
|
|
67
|
+
function isHorizontalExpandBinding(binding) {
|
|
68
|
+
return binding.expand === "right" && binding.aggregate === "group";
|
|
69
|
+
}
|
|
70
|
+
/** 指定模板行是否含纵向扩展绑定(展开带行) */
|
|
71
|
+
function isExpansionBandRow(row, getBindingAt, scanCols = 64) {
|
|
72
|
+
for (let col = 0; col < scanCols; col++) {
|
|
73
|
+
const binding = getBindingAt({
|
|
74
|
+
row,
|
|
75
|
+
col
|
|
76
|
+
});
|
|
77
|
+
if (binding && isVerticalExpandBinding(binding)) return true;
|
|
78
|
+
}
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
/** 落格时推断预设:默认明细;数值字段且位于展开带正下方相邻行 → 小计 */
|
|
82
|
+
function inferDropPreset(addr, fieldType, getBindingAt) {
|
|
83
|
+
if (fieldType === "number" && addr.row > 0 && isExpansionBandRow(addr.row - 1, getBindingAt)) return "subtotal";
|
|
84
|
+
return "detail";
|
|
85
|
+
}
|
|
86
|
+
/** 同数据集纵向扩展绑定格(行方向父格下拉候选) */
|
|
87
|
+
function listRowParentCandidates(binding, entries) {
|
|
88
|
+
const candidates = [];
|
|
89
|
+
for (const entry of entries) {
|
|
90
|
+
if (entry.binding.dataset !== binding.dataset) continue;
|
|
91
|
+
if (!isVerticalExpandBinding(entry.binding)) continue;
|
|
92
|
+
candidates.push(entry.addr);
|
|
93
|
+
}
|
|
94
|
+
return candidates;
|
|
95
|
+
}
|
|
96
|
+
/** 同数据集横向扩展绑定格(列方向父格下拉候选) */
|
|
97
|
+
function listColParentCandidates(binding, entries) {
|
|
98
|
+
const candidates = [];
|
|
99
|
+
for (const entry of entries) {
|
|
100
|
+
if (entry.binding.dataset !== binding.dataset) continue;
|
|
101
|
+
if (!isHorizontalExpandBinding(entry.binding)) continue;
|
|
102
|
+
candidates.push(entry.addr);
|
|
103
|
+
}
|
|
104
|
+
return candidates;
|
|
105
|
+
}
|
|
106
|
+
/** 同列向上找最近的纵向扩展绑定,作为 rowParent 候选 */
|
|
107
|
+
function inferRowParentCandidate(addr, getBindingAt) {
|
|
108
|
+
for (let row = addr.row - 1; row >= 0; row--) {
|
|
109
|
+
const binding = getBindingAt({
|
|
110
|
+
row,
|
|
111
|
+
col: addr.col
|
|
112
|
+
});
|
|
113
|
+
if (binding && isVerticalExpandBinding(binding)) return {
|
|
114
|
+
row,
|
|
115
|
+
col: addr.col
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
/** 同行向左找最近的横向扩展绑定,作为 colParent 候选 */
|
|
121
|
+
function inferColParentCandidate(addr, getBindingAt) {
|
|
122
|
+
for (let col = addr.col - 1; col >= 0; col--) {
|
|
123
|
+
const binding = getBindingAt({
|
|
124
|
+
row: addr.row,
|
|
125
|
+
col
|
|
126
|
+
});
|
|
127
|
+
if (binding && isHorizontalExpandBinding(binding)) return {
|
|
128
|
+
row: addr.row,
|
|
129
|
+
col
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
/** 从绑定字段推断预设;不匹配任何预设时返回 null(自定义) */
|
|
135
|
+
function inferReportPreset(binding) {
|
|
136
|
+
if (binding.preset) return binding.preset;
|
|
137
|
+
if (binding.expand === "none" && binding.aggregate === "sum" && binding.rowParent && binding.colParent) return "cross";
|
|
138
|
+
if (binding.expand === "none" && binding.aggregate === "sum" && !binding.rowParent && !binding.colParent) return "grandTotal";
|
|
139
|
+
if (binding.expand === "none" && binding.aggregate === "sum" && binding.rowParent && !binding.colParent) return "subtotal";
|
|
140
|
+
if (binding.aggregate === "group" && (binding.expand === "down" || binding.expand === "right")) return "groupHeader";
|
|
141
|
+
if (binding.aggregate === "list" && (binding.expand === "down" || binding.expand === "right")) return "detail";
|
|
142
|
+
return null;
|
|
143
|
+
}
|
|
144
|
+
/** 默认明细 + 纵向扩展 */
|
|
145
|
+
function createReportBinding(dataset, fieldName) {
|
|
146
|
+
return {
|
|
147
|
+
dataset: dataset.id,
|
|
148
|
+
field: fieldName,
|
|
149
|
+
aggregate: "list",
|
|
150
|
+
expand: "down",
|
|
151
|
+
preset: "detail",
|
|
152
|
+
sort: "none",
|
|
153
|
+
conditionalRules: []
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
/** 设计地址 → A1 标签(支持多字母列) */
|
|
157
|
+
function formatCellAddress(addr) {
|
|
158
|
+
return formatAddress(addr);
|
|
159
|
+
}
|
|
160
|
+
/** A1 标签 → 设计地址;非法输入返回 null */
|
|
161
|
+
function parseCellAddress(label) {
|
|
162
|
+
return parseAddress(label);
|
|
163
|
+
}
|
|
164
|
+
/** 解析字段中文标签(找不到时回退字段名);可传入报表配置中的 label */
|
|
165
|
+
function resolveFieldLabel(datasetId, fieldName, resolveLabel) {
|
|
166
|
+
const override = resolveLabel?.(datasetId, fieldName);
|
|
167
|
+
if (override) return override;
|
|
168
|
+
return (bindingCatalog.find((d) => d.id === datasetId)?.fields.find((f) => f.name === fieldName))?.label ?? fieldName;
|
|
169
|
+
}
|
|
170
|
+
/** Binding Placeholder 中文可读文案(如「分组 · 客户」) */
|
|
171
|
+
function formatBindingPlaceholder(binding, resolveLabel) {
|
|
172
|
+
return `${AGGREGATE_PLACEHOLDER_TAG[binding.aggregate]} · ${resolveFieldLabel(binding.dataset, binding.field, resolveLabel)}`;
|
|
173
|
+
}
|
|
174
|
+
//#endregion
|
|
175
|
+
export { REPORT_META_NAMESPACE, applyReportPreset, createReportBinding, formatBindingPlaceholder, formatCellAddress, inferColParentCandidate, inferDropPreset, inferReportPreset, inferRowParentCandidate, isExpansionBandRow, isHorizontalExpandBinding, isVerticalExpandBinding, listColParentCandidates, listRowParentCandidates, parseCellAddress, presetBindingPatch, setBindingCatalog };
|