@agile-team/mach-report 2.7.0 → 2.8.1

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,7 +1,5 @@
1
1
  export * from "@agile-team/mach-report";
2
- import { AllowedComponentProps } from 'vue';
3
2
  import { App } from 'vue';
4
- import { ComponentCustomProps } from 'vue';
5
3
  import { ComponentOptionsMixin } from 'vue';
6
4
  import { ComputedRef } from 'vue';
7
5
  import { CSSProperties } from 'vue';
@@ -10,7 +8,6 @@ import { ExtractPropTypes } from 'vue';
10
8
  import { InjectionKey } from 'vue';
11
9
  import { PropType } from 'vue';
12
10
  import { Ref } from 'vue';
13
- import { VNodeProps } from 'vue';
14
11
  declare const __VLS_component: DefineComponent<ExtractPropTypes<{
15
12
  reportId: {
16
13
  type: PropType<string | string[] | null>;
@@ -164,8 +161,8 @@ declare const __VLS_component: DefineComponent<ExtractPropTypes<{
164
161
  cause?: unknown;
165
162
  } | undefined) => any;
166
163
  task: (task: Readonly<ReportPreviewTask>) => any;
167
- loaded: (pageCount: number) => any;
168
164
  diagnostic: (diagnostic: Readonly<ReportPreviewDiagnostic>) => any;
165
+ loaded: (pageCount: number) => any;
169
166
  "cell-edit": (edit: ReportCellEdit_2) => any;
170
167
  "template-import": (result: ExcelImportResult) => any;
171
168
  "preferences-change": (preferences: Readonly<ReportPreviewPreferences>) => any;
@@ -285,8 +282,8 @@ declare const __VLS_component: DefineComponent<ExtractPropTypes<{
285
282
  cause?: unknown;
286
283
  } | undefined) => any) | undefined;
287
284
  onTask?: ((task: Readonly<ReportPreviewTask>) => any) | undefined;
288
- onLoaded?: ((pageCount: number) => any) | undefined;
289
285
  onDiagnostic?: ((diagnostic: Readonly<ReportPreviewDiagnostic>) => any) | undefined;
286
+ onLoaded?: ((pageCount: number) => any) | undefined;
290
287
  "onCell-edit"?: ((edit: ReportCellEdit_2) => any) | undefined;
291
288
  "onTemplate-import"?: ((result: ExcelImportResult) => any) | undefined;
292
289
  "onPreferences-change"?: ((preferences: Readonly<ReportPreviewPreferences>) => any) | undefined;
@@ -317,6 +314,38 @@ declare const __VLS_component: DefineComponent<ExtractPropTypes<{
317
314
  paramDefs: ReportParamDef[] | undefined;
318
315
  fetcher: PlanFetcher | null;
319
316
  }>;
317
+ declare const __VLS_component_2: DefineComponent<__VLS_Props, {
318
+ focusSearch: () => void;
319
+ }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {} & {
320
+ export: (format: ReportExportFormat) => any;
321
+ print: () => any;
322
+ zoom: (mode: number | "fit") => any;
323
+ goto: (page: number) => any;
324
+ "pdf-window": () => any;
325
+ "search-input": (query: string) => any;
326
+ "search-nav": (dir: 1 | -1) => any;
327
+ "search-toggle": () => any;
328
+ "thumbs-toggle": () => any;
329
+ "import-excel": () => any;
330
+ "settings-toggle": () => any;
331
+ }, string, MachReportVuePublicProps, Readonly<__VLS_Props> & Readonly<{
332
+ onExport?: ((format: ReportExportFormat) => any) | undefined;
333
+ onPrint?: (() => any) | undefined;
334
+ onZoom?: ((mode: number | "fit") => any) | undefined;
335
+ onGoto?: ((page: number) => any) | undefined;
336
+ "onPdf-window"?: (() => any) | undefined;
337
+ "onSearch-input"?: ((query: string) => any) | undefined;
338
+ "onSearch-nav"?: ((dir: 1 | -1) => any) | undefined;
339
+ "onSearch-toggle"?: (() => any) | undefined;
340
+ "onThumbs-toggle"?: (() => any) | undefined;
341
+ "onImport-excel"?: (() => any) | undefined;
342
+ "onSettings-toggle"?: (() => any) | undefined;
343
+ }>, {
344
+ showSearch: boolean;
345
+ showThumbnails: boolean;
346
+ showZoom: boolean;
347
+ exportFormats: readonly ReportExportFormat[];
348
+ }>;
320
349
  declare type __VLS_Props = {
321
350
  pageCount: number;
322
351
  currentPage: number;
@@ -342,8 +371,16 @@ declare type __VLS_Props = {
342
371
  showSettings?: boolean;
343
372
  settingsOpen?: boolean;
344
373
  busy?: boolean;
374
+ /** Standalone toolbar escape hatch; ReportPreview renders pagination in its footer. */
375
+ showPagination?: boolean;
345
376
  };
346
377
  declare type __VLS_Props_2 = {
378
+ pageCount: number;
379
+ currentPage: number;
380
+ messages: MachReportMessages;
381
+ busy?: boolean;
382
+ };
383
+ declare type __VLS_Props_3 = {
347
384
  defs: ReportParamDef[];
348
385
  modelValue: Record<string, string>;
349
386
  messages: MachReportMessages;
@@ -357,12 +394,29 @@ declare function __VLS_template(): {
357
394
  default?(_: {}): any;
358
395
  };
359
396
  };
397
+ declare function __VLS_template_2(): {
398
+ attrs: Partial<{}>;
399
+ slots: {
400
+ navigation?(_: {}): any;
401
+ };
402
+ refs: {
403
+ searchToggleRef: HTMLButtonElement;
404
+ searchInputRef: HTMLInputElement;
405
+ };
406
+ rootEl: HTMLDivElement;
407
+ };
360
408
  declare type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
409
+ declare type __VLS_TemplateResult_2 = ReturnType<typeof __VLS_template_2>;
361
410
  declare type __VLS_WithTemplateSlots<T, S> = T & {
362
411
  new (): {
363
412
  $slots: S;
364
413
  };
365
414
  };
415
+ declare type __VLS_WithTemplateSlots_2<T, S> = T & {
416
+ new (): {
417
+ $slots: S;
418
+ };
419
+ };
366
420
  declare interface AssetRenderBudget {
367
421
  /** Maximum newly rendered assets, default 1000. Existing imageData is kept unchanged. */
368
422
  maxAssets?: number;
@@ -566,6 +620,7 @@ declare interface DatasetValidationOptions {
566
620
  maxCells?: number;
567
621
  maxIssues?: number;
568
622
  }
623
+ export declare const DEFAULT_CALCULATION_MESSAGES: ReportCalculationMessages;
569
624
  export declare const DEFAULT_MESSAGES: MachReportMessages;
570
625
  export declare const DEFAULT_THEME: MachReportTheme;
571
626
  export declare interface DefaultPdfExporterOptions {
@@ -1121,7 +1176,27 @@ export declare type MachReportLogger = Pick<Console, "warn" | "info">;
1121
1176
  * - 优先级:组件 props > 路由级叠加 > preset > defaults(props 永远最高)
1122
1177
  */
1123
1178
  /** 工具栏与状态文案(默认简体中文;出海场景覆写) */
1124
- export declare interface MachReportMessages {
1179
+ export declare interface MachReportMessages extends Partial<ReportCalculationMessages> {
1180
+ exportMenu?: string;
1181
+ exportMenuDescription?: string;
1182
+ clearSearch?: string;
1183
+ searchHint?: string;
1184
+ searchNoMatches?: string;
1185
+ pageJump?: string;
1186
+ pageJumpInvalid?: string;
1187
+ pageJumpHint?: string;
1188
+ pagination?: string;
1189
+ columnSearchHint?: string;
1190
+ columnSearchShortcut?: string;
1191
+ closeColumnDirectory?: string;
1192
+ columnResultsMore?: string;
1193
+ columnCount?: string;
1194
+ settingsGeneral?: string;
1195
+ settingsTools?: string;
1196
+ settingsAdvanced?: string;
1197
+ settingsAdvancedDescription?: string;
1198
+ settingsCalculations?: string;
1199
+ settingsCalculationsDescription?: string;
1125
1200
  title: string;
1126
1201
  prevPage: string;
1127
1202
  nextPage: string;
@@ -1330,6 +1405,8 @@ export declare interface MachReportStateError {
1330
1405
  }
1331
1406
  /** 主题变量(组件外壳注入的 --mrp-* CSS 自定义属性) */
1332
1407
  export declare interface MachReportTheme {
1408
+ /** 空态插图强调色,不随正文颜色变灰。 */
1409
+ emptyAccent?: string;
1333
1410
  shellBg: string;
1334
1411
  shellFg: string;
1335
1412
  toolbarBg: string;
@@ -1647,6 +1724,35 @@ export declare interface ReportBeforeDiscardContext {
1647
1724
  /** Local input or a local draft, never a synonym for persisted differences. */
1648
1725
  pendingLocalChanges: true;
1649
1726
  }
1727
+ export declare interface ReportCalculationMessages {
1728
+ calculationTitle: string;
1729
+ calculationLocal: string;
1730
+ calculationHint: string;
1731
+ calculationFormula: string;
1732
+ calculationExpression: string;
1733
+ calculationExpressionHint: string;
1734
+ calculationPrecision: string;
1735
+ calculationRun: string;
1736
+ calculationCancel: string;
1737
+ calculationResult: string;
1738
+ calculationIncluded: string;
1739
+ calculationExcluded: string;
1740
+ calculationEmpty: string;
1741
+ calculationNoSelection: string;
1742
+ calculationSum: string;
1743
+ calculationAverage: string;
1744
+ calculationMin: string;
1745
+ calculationMax: string;
1746
+ calculationCount: string;
1747
+ calculationMedian: string;
1748
+ calculationCustom: string;
1749
+ calculationErrorSelection: string;
1750
+ calculationErrorLimit: string;
1751
+ calculationErrorExpression: string;
1752
+ calculationErrorDivision: string;
1753
+ calculationErrorOverflow: string;
1754
+ calculationErrorPrecision: string;
1755
+ }
1650
1756
  /** 预览中的物理坐标;合并单元格使用左上角坐标。 */
1651
1757
  declare interface ReportCellAddress {
1652
1758
  pageIndex: number;
@@ -1871,6 +1977,8 @@ export declare interface ReportFieldTarget {
1871
1977
  }
1872
1978
  export declare type ReportIdInput = string | string[] | null | undefined;
1873
1979
  export declare interface ReportInteractionOptions {
1980
+ /** 只读选区计算,默认关闭;不写回业务值或执行导入的 Excel 公式。 */
1981
+ calculations?: boolean;
1874
1982
  /** Screen-only frozen panes; exported geometry is unchanged. */
1875
1983
  freezeHeaders?: boolean;
1876
1984
  /** Leading identity columns, from 0 to 20. */
@@ -1888,6 +1996,11 @@ export declare interface ReportOutputOptions {
1888
1996
  /** warn preserves supported output and shows diagnostics; strict rejects known fidelity loss. */
1889
1997
  fidelity?: "warn" | "strict";
1890
1998
  }
1999
+ export declare const ReportPagination: DefineComponent<__VLS_Props_2, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {} & {
2000
+ goto: (page: number) => any;
2001
+ }, string, MachReportVuePublicProps, Readonly<__VLS_Props_2> & Readonly<{
2002
+ onGoto?: ((page: number) => any) | undefined;
2003
+ }>, {}>;
1891
2004
  /** 报表参数定义(声明式,模板自描述参数面:渲染组件据此生成查询面板) */
1892
2005
  declare interface ReportParamDef {
1893
2006
  /** 参数名(传入 params,与数据集 SQL #{field} 绑定对应) */
@@ -1958,13 +2071,13 @@ declare interface ReportParamIssue {
1958
2071
  message: string;
1959
2072
  }
1960
2073
  declare type ReportParamIssueCode = "definition" | "required" | "type" | "option" | "minimum" | "maximum" | "minLength" | "maxLength";
1961
- export declare const ReportParamPanel: DefineComponent<__VLS_Props_2, {
2074
+ export declare const ReportParamPanel: DefineComponent<__VLS_Props_3, {
1962
2075
  focusInvalid: typeof focusInvalid;
1963
2076
  }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {} & {
1964
2077
  reset: () => any;
1965
2078
  query: () => any;
1966
2079
  "update:modelValue": (value: Record<string, string>) => any;
1967
- }, string, MachReportVuePublicProps, Readonly<__VLS_Props_2> & Readonly<{
2080
+ }, string, MachReportVuePublicProps, Readonly<__VLS_Props_3> & Readonly<{
1968
2081
  onReset?: (() => any) | undefined;
1969
2082
  onQuery?: (() => any) | undefined;
1970
2083
  "onUpdate:modelValue"?: ((value: Record<string, string>) => any) | undefined;
@@ -2101,33 +2214,9 @@ declare interface ReportTemplateProvider {
2101
2214
  }): Promise<ReportTemplateDocument | undefined>;
2102
2215
  }
2103
2216
  declare type ReportTemplateSummary = Omit<ReportTemplateDocument, "template">;
2104
- export declare const ReportToolbar: DefineComponent<__VLS_Props, {
2105
- focusSearch: () => void;
2106
- }, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {} & {
2107
- export: (format: "pdf" | "xlsx" | "html" | "png" | "word") => any;
2108
- print: () => any;
2109
- zoom: (mode: number | "fit") => any;
2110
- goto: (page: number) => any;
2111
- "pdf-window": () => any;
2112
- "search-input": (query: string) => any;
2113
- "search-nav": (dir: 1 | -1) => any;
2114
- "search-toggle": () => any;
2115
- "thumbs-toggle": () => any;
2116
- "import-excel": () => any;
2117
- "settings-toggle": () => any;
2118
- }, string, MachReportVuePublicProps, Readonly<__VLS_Props> & Readonly<{
2119
- onExport?: ((format: "pdf" | "xlsx" | "html" | "png" | "word") => any) | undefined;
2120
- onPrint?: (() => any) | undefined;
2121
- onZoom?: ((mode: number | "fit") => any) | undefined;
2122
- onGoto?: ((page: number) => any) | undefined;
2123
- "onPdf-window"?: (() => any) | undefined;
2124
- "onSearch-input"?: ((query: string) => any) | undefined;
2125
- "onSearch-nav"?: ((dir: 1 | -1) => any) | undefined;
2126
- "onSearch-toggle"?: (() => any) | undefined;
2127
- "onThumbs-toggle"?: (() => any) | undefined;
2128
- "onImport-excel"?: (() => any) | undefined;
2129
- "onSettings-toggle"?: (() => any) | undefined;
2130
- }>, {}>;
2217
+ export declare const ReportToolbar: __VLS_WithTemplateSlots_2<typeof __VLS_component_2, __VLS_TemplateResult_2["slots"]>;
2218
+ /** 新消息保持可选,旧的完整文案对象也能获得新增能力的默认文案。 */
2219
+ export declare function resolveCalculationMessages(messages: Partial<ReportCalculationMessages>): ReportCalculationMessages;
2131
2220
  export declare function resolveConfig(config: MachReportConfig | null | undefined, presetName?: string): ResolvedConfig;
2132
2221
  export declare type ResolvedConfig = Required<Pick<MachReportDefaults, "showExport" | "showPrint" | "showPdfWindow" | "showSettings" | "showParams" | "gapPx">> & {
2133
2222
  pdfFontUrl: string;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("./plugin-9t_ZFwhz.cjs");function i(){return Promise.resolve().then(()=>require("./ReportPreview-BdvoqdOd.cjs")).then(e=>e.ReportPreview$1)}const t={install(e,o={}){r.machReportPlugin.install(e,o)}};exports.MachReportPreview=r.MachReportPreview;exports.default=t;exports.machReportAsyncPlugin=t;exports.preloadMachReport=i;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("./plugin-BAD7Ry8V.cjs");function i(){return Promise.resolve().then(()=>require("./ReportPreview-fKUPcCTN.cjs")).then(e=>e.ReportPreview$1)}const t={install(e,o={}){r.machReportPlugin.install(e,o)}};exports.MachReportPreview=r.MachReportPreview;exports.default=t;exports.machReportAsyncPlugin=t;exports.preloadMachReport=i;
package/dist/vue-async.js CHANGED
@@ -1,7 +1,7 @@
1
- import { m as o } from "./plugin-s8Ay8kKk.js";
2
- import { M as l } from "./plugin-s8Ay8kKk.js";
1
+ import { m as o } from "./plugin-zROi2Bgp.js";
2
+ import { M as l } from "./plugin-zROi2Bgp.js";
3
3
  function a() {
4
- return import("./ReportPreview-COFkbeEM.js").then((t) => t.z);
4
+ return import("./ReportPreview-vdZ5XYYb.js").then((t) => t.C);
5
5
  }
6
6
  const n = {
7
7
  install(t, r = {}) {
package/dist/vue.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("@agile-team/mach-report"),t=require("./ReportPreview-BdvoqdOd.cjs"),l=require("./plugin-9t_ZFwhz.cjs"),P=require("vue");function v(r){const e=p.createReportSource(r),i=async o=>{if(o.reportIds.length===0)throw new t.PlanLoadError("缺少报表 ID");for(const n of o.reportIds)if(!Object.prototype.hasOwnProperty.call(r,n)||!r[n])throw new t.PlanLoadError(`本地模板 ${n} 不存在`);return e(o)};return i.getParamDefs=e.getParamDefs,i}const C=Object.freeze({loading:!1,hasPlan:!1,pageCount:0,currentPage:1,exporting:null,printing:!1,canExport:!1,canPrint:!1,error:null,pdfFont:Object.freeze({status:"unchecked",fontUrl:""})});function M(){const r=P.shallowRef(null),e=()=>r.value?.state??C,i=Object.freeze({get loading(){return e().loading},get hasPlan(){return e().hasPlan},get pageCount(){return e().pageCount},get currentPage(){return e().currentPage},get exporting(){return e().exporting},get printing(){return e().printing},get canExport(){return e().canExport},get canPrint(){return e().canPrint},get error(){return e().error},get pdfFont(){return e().pdfFont},get editing(){return e().editing??!1},get saving(){return e().saving??!1},get importing(){return e().importing??!1},get dirty(){return e().dirty??!1},get pendingLocalChanges(){return e().pendingLocalChanges??!1},get task(){return e().task??null},get diagnostics(){return e().diagnostics??[]},get reportIds(){return e().reportIds??[]},get params(){return e().params??{}},get canUndo(){return e().canUndo??!1},get canRedo(){return e().canRedo??!1},get changeCount(){return e().changeCount??0},get selection(){return e().selection??null}});function o(){if(!r.value)throw new t.MachReportError("config","报表预览尚未挂载,请在 ready 后调用控制器");return r.value}return{ref(n){const a=n;r.value=a&&typeof a.reload=="function"&&typeof a.print=="function"&&typeof a.exportAs=="function"&&typeof a.openPdfWindow=="function"&&typeof a.gotoPage=="function"&&typeof a.setParams=="function"?a:null},ready:P.computed(()=>r.value!==null),state:i,async checkPdfFont(){const n=o();return n.checkPdfFont?n.checkPdfFont():{status:"unverified",fontUrl:"",message:"旧自定义控制器未提供字体检查,请由宿主确认字体配置"}},cancelTask(){o().cancelTask?.()},async confirmDiscard(n){return await o().confirmDiscard?.(n)??!0},getOutputDiagnostics(n){return o().getOutputDiagnostics?.(n)??[]},async reload(){await o().reload()},async print(){await o().print()},async exportAs(n){await o().exportAs(n)},openPdfWindow(){o().openPdfWindow()},gotoPage(n){o().gotoPage(n)},async setParams(n,a){await o().setParams(n,a)},async importExcel(n,a){const f=o();if(!f.importExcel)throw new t.MachReportError("config","旧自定义控制器未提供 Excel 导入");return f.importExcel(n,a)},getPlan(){return o().getPlan?.()??null},getChanges(){return o().getChanges?.()??[]},getDifferences:()=>o().getDifferences?.()??[],undo:async()=>await o().undo?.()??!1,redo:async()=>await o().redo?.()??!1,restoreChanges:async()=>await o().restoreChanges?.()??!1,getSelection:()=>o().getSelection?.()??null,focusCell:async(n,a)=>await o().focusCell?.(n,a)??!1,focusField:async n=>await o().focusField?.(n)??!1,copySelection:()=>o().copySelection?.()??"",pasteSelection:async n=>await o().pasteSelection?.(n)??!1}}function S(){return P.inject(l.MACH_REPORT_CONTROLLER_KEY,null)}function h(r){return!!r&&typeof r=="object"&&!Array.isArray(r)}function A(r){return Array.isArray(r)&&r.every(e=>h(e)&&typeof e.code=="string"&&typeof e.message=="string"&&["info","warning","error"].includes(e.severity)&&(e.path===void 0||typeof e.path=="string"))}function I(r,e){return Array.isArray(r)&&r.every(i=>h(i)&&Number.isSafeInteger(i.editIndex)&&i.editIndex>=0&&i.editIndex<e&&typeof i.code=="string"&&typeof i.message=="string")}function x(r,e){let i;if(!h(r)||typeof r.revision!="string"||!r.revision.trim()?i="非空 revision(请先在适配器解包业务响应)":r.sourceToken!==void 0&&typeof r.sourceToken!="string"?i="字符串 sourceToken":r.diagnostics!==void 0&&!A(r.diagnostics)?i="结构化 diagnostics":r.conflicts!==void 0&&!I(r.conflicts,e)&&(i="有效 editIndex/code/message conflicts"),i)throw new t.MachReportError("edit",`ReportProvider.save 必须返回${i};服务器可能已提交,请重新查询确认后再编辑`)}function y(r){return typeof r=="function"?r():r}function D(r,e){const i=new Set(r.flatMap(o=>o.source?.[e]===void 0?[]:[String(o.source[e])]));return i.size===1?[...i][0]:void 0}function w(r,e,i,o){return typeof r=="function"?r():D(e,i)??o??r}function L(r){return r.requestId??globalThis.crypto?.randomUUID?.()??`mr-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function F(r,e){if(!r.save)throw new t.MachReportError("config","ReportProvider.save 未配置,无法启用业务保存");let i="",o,n,a=0;function f(s,c,g){s.conflicts?.length||c!==i||g!==a||(o=s.revision,n=s.sourceToken)}async function m(s,c){if(c.signal.aborted)throw c.signal.reason??new DOMException("Aborted","AbortError");const g=y(e.reportId),T={...y(e.params??{})},R=JSON.stringify([g,T]),O=++a;if(R!==i&&(i=R,o=void 0,n=void 0),e.requireSource!==!1&&s.edits.some(u=>!u.source))throw new p.ReportCellEditError("missing");const d=await r.save({reportId:g,params:T,signal:c.signal,requestId:s.requestId,action:c.action,edits:t.cloneReportSnapshot(s.edits),expectedRevision:w(e.expectedRevision,s.edits,"revision",o),sourceToken:w(e.sourceToken,s.edits,"sourceToken",n)});if(c.signal.aborted)throw c.signal.reason??new DOMException("Aborted","AbortError");x(d,s.edits.length),d.diagnostics?.forEach(u=>e.onDiagnostic?.(u));const E=d.diagnostics?.filter(u=>u.severity==="error");if(E?.length)throw new t.MachReportError("edit",E.map(u=>u.message).join(";"),{diagnostics:E});const _=d.conflicts?.map(u=>({source:s.edits[u.editIndex]?.source,address:s.edits[u.editIndex]?.address,message:u.message}));return f(d,R,O),{revision:d.revision,sourceToken:d.sourceToken,conflicts:_}}return{requireSource:e.requireSource??!0,canEdit:e.canEdit,validate:e.validate,saveBatch:m,save:(s,c)=>m({requestId:L(c),edits:[t.cloneReportSnapshot(s)]},c)}}exports.DEFAULT_MESSAGES=t.DEFAULT_MESSAGES;exports.DEFAULT_THEME=t.DEFAULT_THEME;exports.MachReportError=t.MachReportError;exports.PlanLoadError=t.PlanLoadError;exports.REPORT_EXPORT_FORMATS=t.REPORT_EXPORT_FORMATS;exports.REPORT_PREVIEW_TOOLS=t.REPORT_PREVIEW_TOOLS;exports.ReportParamPanel=t.ReportParamPanel;exports.ReportPreview=t.ReportPreview;exports.ReportToolbar=t.ReportToolbar;exports.SILENT_LOGGER=t.SILENT_LOGGER;exports.buildPrintDocument=t.buildPrintDocument;exports.buildWordHtml=t.buildWordHtml;exports.createDefaultPdfExporter=t.createDefaultPdfExporter;exports.createFetchRequest=t.createFetchRequest;exports.createReportStoragePreferences=t.createReportStoragePreferences;exports.defineMachReportConfig=t.defineMachReportConfig;exports.defineMachReportPreset=t.defineMachReportPreset;exports.joinReportIds=t.joinReportIds;exports.normalizeReportIds=t.normalizeReportIds;exports.normalizeReportLoadError=t.normalizeReportLoadError;exports.printPlans=t.printPlans;exports.provideMachReportConfig=t.provideMachReportConfig;exports.resolveConfig=t.resolveConfig;exports.themeToCssVars=t.themeToCssVars;exports.toErrorDetail=t.toErrorDetail;exports.useMachReportConfig=t.useMachReportConfig;exports.usePageWindow=t.usePageWindow;exports.usePrintExport=t.usePrintExport;exports.useZoom=t.useZoom;exports.MACH_REPORT_CONFIG_KEY=l.MACH_REPORT_CONFIG_KEY;exports.MACH_REPORT_CONTROLLER_KEY=l.MACH_REPORT_CONTROLLER_KEY;exports.MACH_REPORT_FETCHER_KEY=l.MACH_REPORT_FETCHER_KEY;exports.MACH_REPORT_PDF_EXPORTER_KEY=l.MACH_REPORT_PDF_EXPORTER_KEY;exports.MachReportPreview=l.MachReportPreview;exports.machReportPlugin=l.machReportPlugin;exports.createLocalFetcher=v;exports.createProviderEditing=F;exports.useMachReport=M;exports.useReportPreview=S;Object.keys(p).forEach(r=>{r!=="default"&&!Object.prototype.hasOwnProperty.call(exports,r)&&Object.defineProperty(exports,r,{enumerable:!0,get:()=>p[r]})});
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("@agile-team/mach-report"),t=require("./ReportPreview-fKUPcCTN.cjs"),l=require("./plugin-BAD7Ry8V.cjs"),P=require("vue");function C(r){const e=p.createReportSource(r),i=async o=>{if(o.reportIds.length===0)throw new t.PlanLoadError("缺少报表 ID");for(const n of o.reportIds)if(!Object.prototype.hasOwnProperty.call(r,n)||!r[n])throw new t.PlanLoadError(`本地模板 ${n} 不存在`);return e(o)};return i.getParamDefs=e.getParamDefs,i}const M=Object.freeze({loading:!1,hasPlan:!1,pageCount:0,currentPage:1,exporting:null,printing:!1,canExport:!1,canPrint:!1,error:null,pdfFont:Object.freeze({status:"unchecked",fontUrl:""})});function S(){const r=P.shallowRef(null),e=()=>r.value?.state??M,i=Object.freeze({get loading(){return e().loading},get hasPlan(){return e().hasPlan},get pageCount(){return e().pageCount},get currentPage(){return e().currentPage},get exporting(){return e().exporting},get printing(){return e().printing},get canExport(){return e().canExport},get canPrint(){return e().canPrint},get error(){return e().error},get pdfFont(){return e().pdfFont},get editing(){return e().editing??!1},get saving(){return e().saving??!1},get importing(){return e().importing??!1},get dirty(){return e().dirty??!1},get pendingLocalChanges(){return e().pendingLocalChanges??!1},get task(){return e().task??null},get diagnostics(){return e().diagnostics??[]},get reportIds(){return e().reportIds??[]},get params(){return e().params??{}},get canUndo(){return e().canUndo??!1},get canRedo(){return e().canRedo??!1},get changeCount(){return e().changeCount??0},get selection(){return e().selection??null}});function o(){if(!r.value)throw new t.MachReportError("config","报表预览尚未挂载,请在 ready 后调用控制器");return r.value}return{ref(n){const a=n;r.value=a&&typeof a.reload=="function"&&typeof a.print=="function"&&typeof a.exportAs=="function"&&typeof a.openPdfWindow=="function"&&typeof a.gotoPage=="function"&&typeof a.setParams=="function"?a:null},ready:P.computed(()=>r.value!==null),state:i,async checkPdfFont(){const n=o();return n.checkPdfFont?n.checkPdfFont():{status:"unverified",fontUrl:"",message:"旧自定义控制器未提供字体检查,请由宿主确认字体配置"}},cancelTask(){o().cancelTask?.()},async confirmDiscard(n){return await o().confirmDiscard?.(n)??!0},getOutputDiagnostics(n){return o().getOutputDiagnostics?.(n)??[]},async reload(){await o().reload()},async print(){await o().print()},async exportAs(n){await o().exportAs(n)},openPdfWindow(){o().openPdfWindow()},gotoPage(n){o().gotoPage(n)},async setParams(n,a){await o().setParams(n,a)},async importExcel(n,a){const f=o();if(!f.importExcel)throw new t.MachReportError("config","旧自定义控制器未提供 Excel 导入");return f.importExcel(n,a)},getPlan(){return o().getPlan?.()??null},getChanges(){return o().getChanges?.()??[]},getDifferences:()=>o().getDifferences?.()??[],undo:async()=>await o().undo?.()??!1,redo:async()=>await o().redo?.()??!1,restoreChanges:async()=>await o().restoreChanges?.()??!1,getSelection:()=>o().getSelection?.()??null,focusCell:async(n,a)=>await o().focusCell?.(n,a)??!1,focusField:async n=>await o().focusField?.(n)??!1,copySelection:()=>o().copySelection?.()??"",pasteSelection:async n=>await o().pasteSelection?.(n)??!1}}function v(){return P.inject(l.MACH_REPORT_CONTROLLER_KEY,null)}function h(r){return!!r&&typeof r=="object"&&!Array.isArray(r)}function A(r){return Array.isArray(r)&&r.every(e=>h(e)&&typeof e.code=="string"&&typeof e.message=="string"&&["info","warning","error"].includes(e.severity)&&(e.path===void 0||typeof e.path=="string"))}function I(r,e){return Array.isArray(r)&&r.every(i=>h(i)&&Number.isSafeInteger(i.editIndex)&&i.editIndex>=0&&i.editIndex<e&&typeof i.code=="string"&&typeof i.message=="string")}function L(r,e){let i;if(!h(r)||typeof r.revision!="string"||!r.revision.trim()?i="非空 revision(请先在适配器解包业务响应)":r.sourceToken!==void 0&&typeof r.sourceToken!="string"?i="字符串 sourceToken":r.diagnostics!==void 0&&!A(r.diagnostics)?i="结构化 diagnostics":r.conflicts!==void 0&&!I(r.conflicts,e)&&(i="有效 editIndex/code/message conflicts"),i)throw new t.MachReportError("edit",`ReportProvider.save 必须返回${i};服务器可能已提交,请重新查询确认后再编辑`)}function y(r){return typeof r=="function"?r():r}function D(r,e){const i=new Set(r.flatMap(o=>o.source?.[e]===void 0?[]:[String(o.source[e])]));return i.size===1?[...i][0]:void 0}function w(r,e,i,o){return typeof r=="function"?r():D(e,i)??o??r}function x(r){return r.requestId??globalThis.crypto?.randomUUID?.()??`mr-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function F(r,e){if(!r.save)throw new t.MachReportError("config","ReportProvider.save 未配置,无法启用业务保存");let i="",o,n,a=0;function f(s,c,g){s.conflicts?.length||c!==i||g!==a||(o=s.revision,n=s.sourceToken)}async function T(s,c){if(c.signal.aborted)throw c.signal.reason??new DOMException("Aborted","AbortError");const g=y(e.reportId),m={...y(e.params??{})},E=JSON.stringify([g,m]),O=++a;if(E!==i&&(i=E,o=void 0,n=void 0),e.requireSource!==!1&&s.edits.some(u=>!u.source))throw new p.ReportCellEditError("missing");const d=await r.save({reportId:g,params:m,signal:c.signal,requestId:s.requestId,action:c.action,edits:t.cloneReportSnapshot(s.edits),expectedRevision:w(e.expectedRevision,s.edits,"revision",o),sourceToken:w(e.sourceToken,s.edits,"sourceToken",n)});if(c.signal.aborted)throw c.signal.reason??new DOMException("Aborted","AbortError");L(d,s.edits.length),d.diagnostics?.forEach(u=>e.onDiagnostic?.(u));const R=d.diagnostics?.filter(u=>u.severity==="error");if(R?.length)throw new t.MachReportError("edit",R.map(u=>u.message).join(";"),{diagnostics:R});const _=d.conflicts?.map(u=>({source:s.edits[u.editIndex]?.source,address:s.edits[u.editIndex]?.address,message:u.message}));return f(d,E,O),{revision:d.revision,sourceToken:d.sourceToken,conflicts:_}}return{requireSource:e.requireSource??!0,canEdit:e.canEdit,validate:e.validate,saveBatch:T,save:(s,c)=>T({requestId:x(c),edits:[t.cloneReportSnapshot(s)]},c)}}exports.DEFAULT_CALCULATION_MESSAGES=t.DEFAULT_CALCULATION_MESSAGES;exports.DEFAULT_MESSAGES=t.DEFAULT_MESSAGES;exports.DEFAULT_THEME=t.DEFAULT_THEME;exports.MachReportError=t.MachReportError;exports.PlanLoadError=t.PlanLoadError;exports.REPORT_EXPORT_FORMATS=t.REPORT_EXPORT_FORMATS;exports.REPORT_PREVIEW_TOOLS=t.REPORT_PREVIEW_TOOLS;exports.ReportPagination=t.ReportPagination;exports.ReportParamPanel=t.ReportParamPanel;exports.ReportPreview=t.ReportPreview;exports.ReportToolbar=t.ReportToolbar;exports.SILENT_LOGGER=t.SILENT_LOGGER;exports.buildPrintDocument=t.buildPrintDocument;exports.buildWordHtml=t.buildWordHtml;exports.createDefaultPdfExporter=t.createDefaultPdfExporter;exports.createFetchRequest=t.createFetchRequest;exports.createReportStoragePreferences=t.createReportStoragePreferences;exports.defineMachReportConfig=t.defineMachReportConfig;exports.defineMachReportPreset=t.defineMachReportPreset;exports.joinReportIds=t.joinReportIds;exports.normalizeReportIds=t.normalizeReportIds;exports.normalizeReportLoadError=t.normalizeReportLoadError;exports.printPlans=t.printPlans;exports.provideMachReportConfig=t.provideMachReportConfig;exports.resolveCalculationMessages=t.resolveCalculationMessages;exports.resolveConfig=t.resolveConfig;exports.themeToCssVars=t.themeToCssVars;exports.toErrorDetail=t.toErrorDetail;exports.useMachReportConfig=t.useMachReportConfig;exports.usePageWindow=t.usePageWindow;exports.usePrintExport=t.usePrintExport;exports.useZoom=t.useZoom;exports.MACH_REPORT_CONFIG_KEY=l.MACH_REPORT_CONFIG_KEY;exports.MACH_REPORT_CONTROLLER_KEY=l.MACH_REPORT_CONTROLLER_KEY;exports.MACH_REPORT_FETCHER_KEY=l.MACH_REPORT_FETCHER_KEY;exports.MACH_REPORT_PDF_EXPORTER_KEY=l.MACH_REPORT_PDF_EXPORTER_KEY;exports.MachReportPreview=l.MachReportPreview;exports.machReportPlugin=l.machReportPlugin;exports.createLocalFetcher=C;exports.createProviderEditing=F;exports.useMachReport=S;exports.useReportPreview=v;Object.keys(p).forEach(r=>{r!=="default"&&!Object.prototype.hasOwnProperty.call(exports,r)&&Object.defineProperty(exports,r,{enumerable:!0,get:()=>p[r]})});
package/dist/vue.js CHANGED
@@ -1,12 +1,12 @@
1
- import { createReportSource as x, ReportCellEditError as S } from "@agile-team/mach-report";
1
+ import { createReportSource as S, ReportCellEditError as x } from "@agile-team/mach-report";
2
2
  export * from "@agile-team/mach-report";
3
- import { P as R, M as f, c as y } from "./ReportPreview-COFkbeEM.js";
4
- import { D as $, a as V, R as X, b as B, d as J, e as Z, f as Q, S as ee, g as te, h as re, i as ne, j as oe, k as se, l as ae, m as ie, n as ce, o as ue, p as fe, q as de, r as ge, s as le, t as pe, u as me, v as Pe, w as Ee, x as Re, y as ye } from "./ReportPreview-COFkbeEM.js";
5
- import { a as C } from "./plugin-s8Ay8kKk.js";
6
- import { b as he, c as Te, d as ve, M as xe, m as Se } from "./plugin-s8Ay8kKk.js";
7
- import { shallowRef as I, computed as O, inject as A } from "vue";
8
- function H(t) {
9
- const e = x(t), o = async (r) => {
3
+ import { P as R, M as f, c as y } from "./ReportPreview-vdZ5XYYb.js";
4
+ import { D as $, a as B, b as V, R as X, d as J, e as Z, f as Q, g as ee, h as te, S as re, i as ne, j as oe, k as se, l as ae, m as ie, n as ce, o as ue, p as fe, q as de, r as ge, s as le, t as pe, u as me, v as Pe, w as Ee, x as Re, y as ye, z as we, A as he, B as Te } from "./ReportPreview-vdZ5XYYb.js";
5
+ import { a as C } from "./plugin-zROi2Bgp.js";
6
+ import { b as Se, c as xe, d as Ce, M as Ae, m as Ie } from "./plugin-zROi2Bgp.js";
7
+ import { shallowRef as A, computed as I, inject as O } from "vue";
8
+ function z(t) {
9
+ const e = S(t), o = async (r) => {
10
10
  if (r.reportIds.length === 0) throw new R("缺少报表 ID");
11
11
  for (const n of r.reportIds)
12
12
  if (!Object.prototype.hasOwnProperty.call(t, n) || !t[n])
@@ -15,7 +15,7 @@ function H(t) {
15
15
  };
16
16
  return o.getParamDefs = e.getParamDefs, o;
17
17
  }
18
- const D = Object.freeze({
18
+ const M = Object.freeze({
19
19
  loading: !1,
20
20
  hasPlan: !1,
21
21
  pageCount: 0,
@@ -27,8 +27,8 @@ const D = Object.freeze({
27
27
  error: null,
28
28
  pdfFont: Object.freeze({ status: "unchecked", fontUrl: "" })
29
29
  });
30
- function z() {
31
- const t = I(null), e = () => t.value?.state ?? D, o = Object.freeze({
30
+ function H() {
31
+ const t = A(null), e = () => t.value?.state ?? M, o = Object.freeze({
32
32
  get loading() {
33
33
  return e().loading;
34
34
  },
@@ -109,7 +109,7 @@ function z() {
109
109
  const s = n;
110
110
  t.value = s && typeof s.reload == "function" && typeof s.print == "function" && typeof s.exportAs == "function" && typeof s.openPdfWindow == "function" && typeof s.gotoPage == "function" && typeof s.setParams == "function" ? s : null;
111
111
  },
112
- ready: O(() => t.value !== null),
112
+ ready: I(() => t.value !== null),
113
113
  state: o,
114
114
  async checkPdfFont() {
115
115
  const n = r();
@@ -164,21 +164,21 @@ function z() {
164
164
  pasteSelection: async (n) => await r().pasteSelection?.(n) ?? !1
165
165
  };
166
166
  }
167
- function W() {
168
- return A(C, null);
167
+ function G() {
168
+ return O(C, null);
169
169
  }
170
170
  function m(t) {
171
171
  return !!t && typeof t == "object" && !Array.isArray(t);
172
172
  }
173
- function M(t) {
173
+ function _(t) {
174
174
  return Array.isArray(t) && t.every((e) => m(e) && typeof e.code == "string" && typeof e.message == "string" && ["info", "warning", "error"].includes(e.severity) && (e.path === void 0 || typeof e.path == "string"));
175
175
  }
176
- function _(t, e) {
176
+ function D(t, e) {
177
177
  return Array.isArray(t) && t.every((o) => m(o) && Number.isSafeInteger(o.editIndex) && o.editIndex >= 0 && o.editIndex < e && typeof o.code == "string" && typeof o.message == "string");
178
178
  }
179
179
  function k(t, e) {
180
180
  let o;
181
- if (!m(t) || typeof t.revision != "string" || !t.revision.trim() ? o = "非空 revision(请先在适配器解包业务响应)" : t.sourceToken !== void 0 && typeof t.sourceToken != "string" ? o = "字符串 sourceToken" : t.diagnostics !== void 0 && !M(t.diagnostics) ? o = "结构化 diagnostics" : t.conflicts !== void 0 && !_(t.conflicts, e) && (o = "有效 editIndex/code/message conflicts"), o) throw new f("edit", `ReportProvider.save 必须返回${o};服务器可能已提交,请重新查询确认后再编辑`);
181
+ if (!m(t) || typeof t.revision != "string" || !t.revision.trim() ? o = "非空 revision(请先在适配器解包业务响应)" : t.sourceToken !== void 0 && typeof t.sourceToken != "string" ? o = "字符串 sourceToken" : t.diagnostics !== void 0 && !_(t.diagnostics) ? o = "结构化 diagnostics" : t.conflicts !== void 0 && !D(t.conflicts, e) && (o = "有效 editIndex/code/message conflicts"), o) throw new f("edit", `ReportProvider.save 必须返回${o};服务器可能已提交,请重新查询确认后再编辑`);
182
182
  }
183
183
  function w(t) {
184
184
  return typeof t == "function" ? t() : t;
@@ -190,10 +190,10 @@ function F(t, e) {
190
190
  function h(t, e, o, r) {
191
191
  return typeof t == "function" ? t() : F(e, o) ?? r ?? t;
192
192
  }
193
- function b(t) {
193
+ function L(t) {
194
194
  return t.requestId ?? globalThis.crypto?.randomUUID?.() ?? `mr-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
195
195
  }
196
- function G(t, e) {
196
+ function N(t, e) {
197
197
  if (!t.save) throw new f("config", "ReportProvider.save 未配置,无法启用业务保存");
198
198
  let o = "", r, n, s = 0;
199
199
  function d(a, i, g) {
@@ -202,7 +202,7 @@ function G(t, e) {
202
202
  async function P(a, i) {
203
203
  if (i.signal.aborted) throw i.signal.reason ?? new DOMException("Aborted", "AbortError");
204
204
  const g = w(e.reportId), E = { ...w(e.params ?? {}) }, l = JSON.stringify([g, E]), T = ++s;
205
- if (l !== o && (o = l, r = void 0, n = void 0), e.requireSource !== !1 && a.edits.some((c) => !c.source)) throw new S("missing");
205
+ if (l !== o && (o = l, r = void 0, n = void 0), e.requireSource !== !1 && a.edits.some((c) => !c.source)) throw new x("missing");
206
206
  const u = await t.save({
207
207
  reportId: g,
208
208
  params: E,
@@ -225,47 +225,50 @@ function G(t, e) {
225
225
  canEdit: e.canEdit,
226
226
  validate: e.validate,
227
227
  saveBatch: P,
228
- save: (a, i) => P({ requestId: b(i), edits: [y(a)] }, i)
228
+ save: (a, i) => P({ requestId: L(i), edits: [y(a)] }, i)
229
229
  };
230
230
  }
231
231
  export {
232
- $ as DEFAULT_MESSAGES,
232
+ $ as DEFAULT_CALCULATION_MESSAGES,
233
+ B as DEFAULT_MESSAGES,
233
234
  V as DEFAULT_THEME,
234
- he as MACH_REPORT_CONFIG_KEY,
235
+ Se as MACH_REPORT_CONFIG_KEY,
235
236
  C as MACH_REPORT_CONTROLLER_KEY,
236
- Te as MACH_REPORT_FETCHER_KEY,
237
- ve as MACH_REPORT_PDF_EXPORTER_KEY,
237
+ xe as MACH_REPORT_FETCHER_KEY,
238
+ Ce as MACH_REPORT_PDF_EXPORTER_KEY,
238
239
  f as MachReportError,
239
- xe as MachReportPreview,
240
+ Ae as MachReportPreview,
240
241
  R as PlanLoadError,
241
242
  X as REPORT_EXPORT_FORMATS,
242
- B as REPORT_PREVIEW_TOOLS,
243
- J as ReportParamPanel,
244
- Z as ReportPreview,
245
- Q as ReportToolbar,
246
- ee as SILENT_LOGGER,
247
- te as buildPrintDocument,
248
- re as buildWordHtml,
249
- ne as createDefaultPdfExporter,
250
- oe as createFetchRequest,
251
- H as createLocalFetcher,
252
- G as createProviderEditing,
253
- se as createReportStoragePreferences,
254
- ae as defineMachReportConfig,
255
- ie as defineMachReportPreset,
256
- ce as joinReportIds,
257
- Se as machReportPlugin,
258
- ue as normalizeReportIds,
259
- fe as normalizeReportLoadError,
260
- de as printPlans,
261
- ge as provideMachReportConfig,
262
- le as resolveConfig,
263
- pe as themeToCssVars,
264
- me as toErrorDetail,
265
- z as useMachReport,
266
- Pe as useMachReportConfig,
267
- Ee as usePageWindow,
268
- Re as usePrintExport,
269
- W as useReportPreview,
270
- ye as useZoom
243
+ J as REPORT_PREVIEW_TOOLS,
244
+ Z as ReportPagination,
245
+ Q as ReportParamPanel,
246
+ ee as ReportPreview,
247
+ te as ReportToolbar,
248
+ re as SILENT_LOGGER,
249
+ ne as buildPrintDocument,
250
+ oe as buildWordHtml,
251
+ se as createDefaultPdfExporter,
252
+ ae as createFetchRequest,
253
+ z as createLocalFetcher,
254
+ N as createProviderEditing,
255
+ ie as createReportStoragePreferences,
256
+ ce as defineMachReportConfig,
257
+ ue as defineMachReportPreset,
258
+ fe as joinReportIds,
259
+ Ie as machReportPlugin,
260
+ de as normalizeReportIds,
261
+ ge as normalizeReportLoadError,
262
+ le as printPlans,
263
+ pe as provideMachReportConfig,
264
+ me as resolveCalculationMessages,
265
+ Pe as resolveConfig,
266
+ Ee as themeToCssVars,
267
+ Re as toErrorDetail,
268
+ H as useMachReport,
269
+ ye as useMachReportConfig,
270
+ we as usePageWindow,
271
+ he as usePrintExport,
272
+ G as useReportPreview,
273
+ Te as useZoom
271
274
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agile-team/mach-report",
3
- "version": "2.7.0",
3
+ "version": "2.8.1",
4
4
  "description": "独立的 TypeScript 报表引擎:模板分页、DOM/Canvas/PDF/Excel 输出与 Vue 3 预览组件",
5
5
  "type": "module",
6
6
  "sideEffects": [