@k-table/report 0.1.0 → 1.0.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/index.d.ts CHANGED
@@ -1,4 +1,16 @@
1
1
  import type { ReactNode } from "react";
2
+ import type * as React from "react";
3
+
4
+ /** 预览/打印数据袋(b=绑定袋 m=映射袋 params=参数袋);与 @k-table/sheet-core 同形 */
5
+ export type ReportFieldData = {
6
+ m?: Record<string, unknown>;
7
+ b?: Record<string, unknown>;
8
+ params?: Record<string, unknown>;
9
+ [key: string]: unknown;
10
+ };
11
+ /** 模板工作簿状态(KTL 解析后);结构化细节见 @k-table/sheet-core */
12
+ export type TemplateWorkbookState = any;
13
+ export const SHEET_TEMPLATE_JSON_VERSION: 2;
2
14
 
3
15
  export class KtStoreError extends Error {
4
16
  readonly status?: number;
@@ -14,6 +26,24 @@ export class KtConflictError extends KtStoreError {
14
26
  export function errorFromHttp(status: number, message: string, body?: unknown): KtStoreError;
15
27
 
16
28
  export type ArtifactKind = "master" | "record" | "report" | "sheet";
29
+ export type ArtifactField = {
30
+ fieldId: string;
31
+ fieldCode: string;
32
+ label: string;
33
+ dataType: string;
34
+ sort: number;
35
+ formula?: string | null;
36
+ tableRelation?: number;
37
+ dictCode?: string | null;
38
+ paramId?: string | null;
39
+ roundKind?: string | null;
40
+ roundDigits?: number | null;
41
+ readOnly?: boolean;
42
+ defaultValue?: string | null;
43
+ optionsJson?: string | null;
44
+ inputKind?: string | null;
45
+ sampleAttrKey?: string | null;
46
+ };
17
47
  export interface Artifact {
18
48
  id: string;
19
49
  name: string;
@@ -22,6 +52,12 @@ export interface Artifact {
22
52
  masterId?: string;
23
53
  faces?: { fill?: string; report?: string };
24
54
  commonFieldKeys?: string[];
55
+ /** 字段目录(设计器字段/公式面板数据源) */
56
+ fields?: ArtifactField[];
57
+ /** 录入面/报表面显示闸(缺省 = 两面都显示) */
58
+ showFaces?: { entry?: boolean; report?: boolean };
59
+ /** 宿主角色语义,透传不解释 */
60
+ formRole?: string;
25
61
  etag?: string;
26
62
  }
27
63
  export interface ArtifactMeta {
@@ -150,6 +186,84 @@ export interface KtTheme {
150
186
  chrome?: KtThemeChrome;
151
187
  styleId?: KtUiStyleId;
152
188
  }
189
+ export interface KtPdfExportRequest {
190
+ title?: string;
191
+ pageRanges?: string;
192
+ pageSizeMm?: { width: number; height: number };
193
+ landscape?: boolean;
194
+ }
195
+ export interface KtPdfExportResult {
196
+ canceled?: boolean;
197
+ filePath?: string;
198
+ }
199
+ export interface KtPrintHooks {
200
+ /** 打印前(可异步);返回 false 取消本次打印 */
201
+ beforePrint?: (ctx: { title?: string }) => void | boolean | Promise<void | boolean>;
202
+ afterPrint?: () => void;
203
+ /** PDF 导出器(宿主注入桌面桥);缺省 = 浏览器「另存为 PDF」提示 */
204
+ pdfExporter?: (req: KtPdfExportRequest) => Promise<KtPdfExportResult>;
205
+ /** 「打印选项」菜单追加项 */
206
+ extraOptions?: { label: string; onClick: () => void }[];
207
+ /** 打印记忆 localStorage key 前缀;缺省 "kt-preview-print-mem" */
208
+ memoryKey?: string;
209
+ }
210
+ export interface KtPreviewHooks {
211
+ /** 灌数后处理:业务 enrich / 图表与签名图槽数据注入 */
212
+ enrichFieldData?: (
213
+ fieldData: ReportFieldData,
214
+ ctx: { artifactId?: string; instanceId?: string },
215
+ ) => ReportFieldData | Promise<ReportFieldData>;
216
+ /** 页眉页脚 chrome 数据(审批意见/二维码/审核人区);null = 无 */
217
+ pageChrome?: (ctx: { artifactId?: string; instanceId?: string }) => Promise<{
218
+ showOpinion: boolean;
219
+ showQr: boolean;
220
+ showReviewer: boolean;
221
+ } | null>;
222
+ onPageChromeCommit?: (
223
+ next: { showOpinion: boolean; showQr: boolean; showReviewer: boolean },
224
+ remember: { rememberUnit?: boolean; rememberMaster?: boolean },
225
+ ctx: { artifactId?: string },
226
+ ) => void;
227
+ }
228
+ export interface KtDesignerHooks {
229
+ /** 业务绑定字段目录,并入设计器字段面板 */
230
+ bindingSchemas?: unknown[];
231
+ /** 公式试算(宿主业务 API,按字段);缺省时公式面板只编辑不试算 */
232
+ trialFormula?: (ctx: {
233
+ artifactId?: string;
234
+ fieldCode: string;
235
+ formula: string;
236
+ roundKind?: string | null;
237
+ roundDigits?: number | null;
238
+ }) => Promise<{ rounded?: string; raw?: string; source?: string }>;
239
+ /** prepage 规则面板的字典选项源(dictCode → 选项);缺省隐藏字典相关入口 */
240
+ prepageDicts?: () => Promise<Record<string, { value: string; label: string }[]>>;
241
+ /** 服务端设计包导入(宿主自弹 UI);返回 "reload" 让设计器重取 artifact */
242
+ importDesignPack?: (ctx: {
243
+ artifactId: string;
244
+ name?: string;
245
+ masterId?: string;
246
+ ktl?: string;
247
+ hasFields?: boolean;
248
+ }) => Promise<"reload" | null>;
249
+ /** 实例联排数据源;缺省隐藏实例模式 */
250
+ instances?: {
251
+ list: (artifactId: string) => Promise<{ id: string; title: string }[]>;
252
+ fieldData: (instanceId: string, ctx: { artifactId: string }) => Promise<ReportFieldData>;
253
+ };
254
+ }
255
+ export interface KtFillHooks {
256
+ /** 录入画布字典选项(dictCode → 选项);缺省无字典下拉 */
257
+ dicts?: () => Promise<Record<string, { value: string; label: string }[]>>;
258
+ /** 预览公共袋最后加工(单位名/人员签名等宿主语义);在包内 enrich 之后执行 */
259
+ enrichCommon?: (bag: Record<string, string>, ctx: { instanceId?: string }) => Record<string, string>;
260
+ }
261
+ export interface KtHooks {
262
+ print?: KtPrintHooks;
263
+ preview?: KtPreviewHooks;
264
+ designer?: KtDesignerHooks;
265
+ fill?: KtFillHooks;
266
+ }
153
267
  export interface KtConfig {
154
268
  sku: KtSku;
155
269
  locale?: "zh-CN";
@@ -174,6 +288,8 @@ export interface KtConfig {
174
288
  print?: boolean;
175
289
  pdf?: boolean;
176
290
  };
291
+ /** 宿主钩子:打印/PDF/预览灌数/设计器字段目录。全部可选。 */
292
+ hooks?: KtHooks;
177
293
  }
178
294
  export interface ResolvedFeatures {
179
295
  master: boolean;
@@ -293,27 +409,28 @@ export function KtVersionPanel(props: {
293
409
  onRestored?: () => void;
294
410
  }): JSX.Element | null;
295
411
 
296
- export type DesignerFormField = {
297
- fieldId: string;
298
- fieldCode: string;
299
- label: string;
300
- dataType: string;
301
- sort: number;
302
- formula?: string | null;
303
- tableRelation?: number;
304
- };
412
+ /** 向后兼容别名;正本为 ArtifactField(Artifact.fields 元素型) */
413
+ export type DesignerFormField = ArtifactField;
305
414
  export function withSplitFaces(artifact: Artifact, workbook: unknown): Artifact;
306
415
  export function previewKtlOf(artifact: Artifact): string;
307
416
  export function KtReportDesigner(props: {
308
417
  artifact?: Artifact;
309
418
  artifactId?: string;
310
419
  store?: ArtifactStore;
420
+ /** 母版清单/读取的独立 store(如目录 defs 适配器 + reports 母版);缺省同 store */
421
+ masterStore?: ArtifactStore;
311
422
  masters?: { id: string; name: string }[];
312
423
  values?: Record<string, unknown>;
313
424
  formFields?: DesignerFormField[];
314
425
  sheetFaceEnabled?: boolean;
315
426
  onSave?: (a: Artifact) => void;
316
427
  onConflict?: (e: KtConflictError) => void;
428
+ /** 提供则铬层出现「另存」,参数为当前内存稿(含未保存改动) */
429
+ onSaveAs?: (a: Artifact) => void;
430
+ /** true = 铬层名称可编辑(随保存落库) */
431
+ nameEditable?: boolean;
432
+ /** true 且 hooks.designer.importDesignPack 存在时,导入按钮带「导入设计包(服务端)」入口 */
433
+ allowImportPack?: boolean;
317
434
  extraActions?: ReactNode;
318
435
  leadingActions?: ReactNode;
319
436
  }): JSX.Element;
@@ -324,15 +441,109 @@ export function KtReportPreview(props: {
324
441
  rev?: string;
325
442
  values?: ValueBag;
326
443
  common?: ValueBag;
444
+ /** false = 极简纸面(无打印条);缺省走完整预览壳 */
327
445
  print?: boolean;
328
446
  showVersionPanel?: boolean;
329
447
  extraActions?: ReactNode;
448
+ onBack?: () => void;
449
+ backDisabled?: boolean;
450
+ preferSampleContent?: boolean;
451
+ /** 当次附加绑定字段(与 hooks.designer.bindingSchemas 合并) */
452
+ bindingSchema?: unknown[];
453
+ /** 打印空白:空袋求值后的合成稿;null = 有闸门无默认不打页 */
454
+ blankWorkbook?: unknown;
455
+ blankEmptyHint?: string;
456
+ fieldDataForSheet?: (sheetId: string) => ReportFieldData;
457
+ /** 实例上下文:透传给 hooks 的 ctx.instanceId */
458
+ instanceId?: string;
459
+ /** 打印记忆表 key;缺省 artifact.id */
460
+ tableKey?: string;
461
+ /** 打印记忆种类(以下空白分槽);缺省按 artifact.kind 映射 */
462
+ printKind?: "record" | "report" | "consign";
463
+ /** 页眉页脚 chrome(优先于 hooks.preview.pageChrome) */
464
+ pageChrome?: { showOpinion: boolean; showQr: boolean; showReviewer: boolean } | null;
465
+ onPageChromeCommit?: (
466
+ next: { showOpinion: boolean; showQr: boolean; showReviewer: boolean },
467
+ remember: { rememberUnit?: boolean; rememberMaster?: boolean },
468
+ ) => void;
469
+ }): JSX.Element;
470
+ // C3:低层逃生舱与通用预览工具
471
+ export type PageChromeRegions = { showOpinion: boolean; showQr: boolean; showReviewer: boolean };
472
+ export type PageChromePartial = Partial<PageChromeRegions>;
473
+ export type PageChromeRemember = { rememberUnit?: boolean; rememberMaster?: boolean };
474
+ export const DEFAULT_PAGE_CHROME: PageChromeRegions;
475
+ export function overlayPageChrome(...layers: Array<PageChromePartial | null | undefined>): PageChromeRegions;
476
+ export function pageChromeEquals(a: PageChromeRegions, b: PageChromeRegions): boolean;
477
+ export function parsePageChromeFromBag(bag: Record<string, unknown> | null | undefined): PageChromePartial | null;
478
+ export function parsePageChromeFromSearch(search: { get(name: string): string | null } | null | undefined): PageChromePartial | null;
479
+ export function parsePageChromePartial(raw: unknown): PageChromePartial | null;
480
+ export function stringifyPageChrome(chrome: PageChromeRegions): string;
481
+ export function writePageChromeToBag(bag: Record<string, string>, chrome: PageChromeRegions): Record<string, string>;
482
+ export type PreviewPrintKind = "record" | "report" | "consign";
483
+ export function resolvePrintMemoryTableKey(legacyCode?: string | null, formDefId?: string | null): string;
484
+ export type BindingField = { label: string; value: string; group?: string };
485
+ export function mergeBindingSchema(base: BindingField[], extra?: BindingField[]): BindingField[];
486
+ export function bindingFieldsFromFieldData(fieldData?: ReportFieldData | null): BindingField[];
487
+ export function bindingFieldsFromWorkbook(workbook: unknown): BindingField[];
488
+ export function readBindingExtras(workbook: unknown): BindingField[];
489
+ export const SAMPLE_FIELD_DATA: ReportFieldData;
490
+ export function applySampleInfoCompose(
491
+ bag: Record<string, string>,
492
+ keys: string[],
493
+ labelOf: (key: string) => string,
494
+ ): Record<string, string>;
495
+ export const SAMPLE_INFO_PAPER_LABEL: string;
496
+ export function enrichLabNameFieldData(fieldData?: ReportFieldData | null, fallbackLabName?: string): ReportFieldData;
497
+ export function resolvePreviewLabName(
498
+ bag?: Record<string, unknown> | null,
499
+ extras?: { queryLabName?: string; homeOrgName?: string },
500
+ ): string;
501
+ // C3:导入设计包/母版拼接工具
502
+ export type MasterZones = any;
503
+ export type MasterComposeFail = { fail: true; reason?: string; [key: string]: unknown };
504
+ export function isMasterFail(v: unknown): boolean;
505
+ export function deriveMasterZones(sheet: unknown): MasterZones | MasterComposeFail;
506
+ export function fitWorkbookToMasterBodySlot(
507
+ workbook: TemplateWorkbookState,
508
+ master: unknown,
509
+ masterId?: string,
510
+ opts?: { resetBorder?: boolean; sheetIds?: string[] },
511
+ ): TemplateWorkbookState;
512
+ export function normalizeWorkbookBordersToThinSolid(workbook: TemplateWorkbookState): TemplateWorkbookState;
513
+ export function mergeImportedPrepage(
514
+ currentEntryKtl: string | null | undefined,
515
+ incomingEntryKtl: string | null | undefined,
516
+ opts: { replaceLayout: boolean; replaceRules: boolean },
517
+ ): string;
518
+ export function prepageDisplayName(raw?: string | null): string;
519
+ export function KtReportPreviewSurface(props: {
520
+ workbook: unknown;
521
+ blankWorkbook?: unknown;
522
+ blankEmptyHint?: string;
523
+ fieldData?: ReportFieldData;
524
+ fieldDataForSheet?: (sheetId: string) => ReportFieldData;
525
+ bindingSchema?: BindingField[];
526
+ preferSampleContent?: boolean;
527
+ title?: string;
528
+ composeWarn?: string | null;
529
+ chrome?: "page" | "modal";
530
+ onBack?: () => void;
531
+ backDisabled?: boolean;
532
+ extraActions?: ReactNode;
533
+ tableKey?: string;
534
+ printKind?: PreviewPrintKind;
535
+ fallbackLabName?: string;
536
+ pageChrome?: PageChromeRegions | null;
537
+ onPageChromeCommit?: (next: PageChromeRegions, remember: PageChromeRemember) => void;
538
+ watermarkOverride?: unknown;
330
539
  }): JSX.Element;
331
540
  export function KtReportCatalog(props: {
332
541
  store?: ArtifactStore;
333
542
  kinds?: ArtifactKind[];
334
543
  onOpenDesign: (id: string) => void;
335
544
  onOpenPreview: (id: string) => void;
545
+ /** 提供且 features.fill 开启时,行内出现「录入」入口 */
546
+ onOpenFill?: (id: string) => void;
336
547
  }): JSX.Element;
337
548
  export function KtThemeBar(props?: { variant?: "default" | "onPrimary" }): JSX.Element;
338
549
  export function KtBrandBar(props: { title: string; themeBar?: boolean }): JSX.Element;
@@ -346,3 +557,271 @@ export function composeKtlForPreview(
346
557
  ktl: string,
347
558
  fetchMasterKtl: (masterId: string) => Promise<string | null>,
348
559
  ): Promise<{ workbook: unknown; masterId?: string; composed: boolean; error?: string }>;
560
+
561
+ // ---- C1c:目录设计器适配器用纯函数 ----
562
+ export function splitFormFaceKtls(workbook: unknown): { entryKtl: string; reportKtl: string };
563
+ export function mergeFormFaceKtls(entryKtl?: string | null, reportKtl?: string | null): string;
564
+ export function hasUsableFaceLayout(ktl: string): boolean;
565
+ export function mergeMiddleComposeMeta(
566
+ workbook: unknown,
567
+ meta: { masterId?: string; importColWidths?: number[]; importRowHeights?: number[] },
568
+ ): unknown;
569
+ export function readMiddleComposeMeta(workbook: unknown): {
570
+ masterId?: string;
571
+ importColWidths?: number[];
572
+ importRowHeights?: number[];
573
+ columnPrecisionMul?: number;
574
+ } | null;
575
+ export function validateFieldsFormulas(fields: FormulaField[]): string | null;
576
+ export function prepageSaveError(workbook: unknown): string | null;
577
+ export function readPrepage(workbook: unknown): { sheetId?: string; rules: unknown[] } | null;
578
+ export function isPrepageSheet(workbook: unknown, sheetId: string): boolean;
579
+ export function parseKtlSafe(ktl: string): { workbook: any; diagnostics: { severity: string; message: string }[] };
580
+ export function workbookToKtlText(workbook: unknown): string;
581
+
582
+ // ---- C2a:实例填报(KtReportFill + 画布三件套) ----
583
+ export interface SheetCommonStore {
584
+ legacy: Record<string, string>;
585
+ byReport: Record<string, Record<string, string>>;
586
+ }
587
+ export function parseSheetCommonStore(raw?: string | null): SheetCommonStore;
588
+ export function stringifySheetCommonStore(store?: SheetCommonStore | null): string;
589
+
590
+ export type KtFillCommonField = { fieldKey: string; label: string; dataType?: string; enabled?: boolean };
591
+ export type KtFillSheet = {
592
+ sheetId: string;
593
+ formDefId: string;
594
+ formName?: string;
595
+ tabTitle?: string;
596
+ formRole?: string;
597
+ entryMiddleKtl?: string | null;
598
+ reportMiddleKtl?: string | null;
599
+ middleKtl?: string | null;
600
+ showEntry?: boolean;
601
+ showReport?: boolean;
602
+ commonFieldKeys?: string[];
603
+ fields?: ArtifactField[];
604
+ };
605
+ export type KtFillComboMember = { formDefId: string; tabTitle?: string; formRole?: string };
606
+ export type ComboMapRule = {
607
+ sourceFormDefId: string;
608
+ sourceFieldCode: string;
609
+ targetFormDefId: string;
610
+ targetFieldCode: string;
611
+ mode?: string;
612
+ formula?: string;
613
+ whenMode?: string;
614
+ sourceRoundKind?: string;
615
+ sourceRoundDigits?: number | null;
616
+ targetRoundKind?: string;
617
+ targetRoundDigits?: number | null;
618
+ sourceSlot?: number | null;
619
+ };
620
+ export type KtFillSnapshot = {
621
+ common: Record<string, string>;
622
+ tabCommons: Record<string, SheetCommonStore>;
623
+ values: Record<string, Record<string, string>>;
624
+ handEdited: Record<string, string[]>;
625
+ };
626
+ export interface KtReportFillHandle {
627
+ collect(): KtFillSnapshot;
628
+ getCommonField(key: string): string;
629
+ setCommonField(key: string, val: string): void;
630
+ }
631
+ export type KtCommonFieldCtx = {
632
+ value: string;
633
+ readOnly: boolean;
634
+ setValue: (v: string) => void;
635
+ setField: (key: string, v: string) => void;
636
+ bag: (key: string) => string;
637
+ label: string;
638
+ };
639
+ export const KtReportFill: React.ForwardRefExoticComponent<
640
+ React.RefAttributes<KtReportFillHandle> & {
641
+ instanceId: string;
642
+ kind: string;
643
+ sheets: KtFillSheet[];
644
+ commonFields: KtFillCommonField[];
645
+ comboMembers?: KtFillComboMember[];
646
+ comboMappings?: ComboMapRule[];
647
+ comboCommonFieldKeys?: string[];
648
+ initialCommon?: Record<string, string>;
649
+ initialTabCommons?: Record<string, SheetCommonStore>;
650
+ initialValues?: Record<string, Record<string, string>>;
651
+ initialHandEdited?: Record<string, string[]>;
652
+ version?: unknown;
653
+ readOnly?: boolean;
654
+ onSnapshot?: (snap: KtFillSnapshot) => void;
655
+ onActiveSheetChange?: (sheet: KtFillSheet | undefined) => void;
656
+ previewBar?: ReactNode;
657
+ toolbar?: ReactNode;
658
+ hint?: ReactNode;
659
+ title?: string;
660
+ leftTitle?: string;
661
+ renderCommonField?: (f: KtFillCommonField, ctx: KtCommonFieldCtx) => ReactNode;
662
+ leftFooter?: ReactNode;
663
+ withPreview?: boolean;
664
+ previewExtra?: {
665
+ fallbackLabName?: string;
666
+ staffSigners?: unknown[];
667
+ sampleComposeKeys?: string[] | null;
668
+ sampleFieldLabel?: (key: string) => string;
669
+ pageChrome?: unknown;
670
+ request?: <T>(path: string, init?: RequestInit) => Promise<T>;
671
+ scheme?: any;
672
+ onSchemeChange?: (s: any, b: any) => void;
673
+ };
674
+ dicts?: Record<string, { value: string; label: string }[]>;
675
+ className?: string;
676
+ }
677
+ >;
678
+ export function InstanceFillSheet(props: {
679
+ ktl?: string | null;
680
+ fields?: ArtifactField[];
681
+ values?: Record<string, string>;
682
+ readOnly?: boolean;
683
+ hideBoundCodesHint?: boolean;
684
+ showBoundCodes?: boolean;
685
+ mappedCodes?: string[];
686
+ handEditedCodes?: string[];
687
+ mappingTips?: Record<string, string>;
688
+ dicts?: Record<string, { value: string; label: string }[]>;
689
+ digitOverlays?: unknown;
690
+ omitTrailingZerosOverride?: boolean;
691
+ reportSheets?: { id: string; name: string }[];
692
+ reportSheetId?: string;
693
+ onReportSheetChange?: (id: string) => void;
694
+ /** 组合设计:点绑定格挑字段 */
695
+ onPickBind?: (info: { fieldCode: string; bagKey: string }) => void;
696
+ pickedBagKey?: string | null;
697
+ face?: "entry" | "report";
698
+ onChange?: (code: string, val: string, meta?: { handEdit?: boolean; restore?: boolean; blur?: boolean; remove?: boolean }) => void;
699
+ }): JSX.Element;
700
+ export function InstanceFillLayout(props: any): JSX.Element;
701
+ // ---- C2b:宿主薄壳用纯函数 ----
702
+ export function applyComboMappingsToSheets(
703
+ valuesBySheet: Record<string, Record<string, string>>,
704
+ sheets: { sheetId: string; formDefId: string; fields?: any[] }[],
705
+ mappings: ComboMapRule[],
706
+ handsBySheet: Record<string, string[]>,
707
+ ): Record<string, Record<string, string>>;
708
+ export function applyComboMappings(...args: any[]): any;
709
+ export function mappingLine(opts: any): string;
710
+ export function applySheetFormulas(bag: Record<string, string>, fields: any[], hands?: string[]): Record<string, string>;
711
+ export function codesMatch(list: string[] | undefined, code: string): boolean;
712
+ export function fieldCodeFromBindKey(bindKey: string): string | null;
713
+ export function fieldHasFormula(field: any): boolean;
714
+ export function evalFormula(formula: string, bag: Record<string, string>): string | null;
715
+ export function validateFormula(formula?: string | null, knownCodes?: string[]): string | null;
716
+ // C2c:公式引擎全量面(正本单源)
717
+ export type FormulaField = {
718
+ fieldCode: string;
719
+ formula?: string | null;
720
+ roundKind?: string | null;
721
+ roundDigits?: number | null;
722
+ readOnly?: boolean;
723
+ tableRelation?: number | null;
724
+ };
725
+ export const FORMULA_FNS: { label: string; insert: string }[];
726
+ export function normalizeDialect(formula: string): string;
727
+ export function currentToken(text: string, caret: number): { start: number; end: number; token: string };
728
+ export function suggestFormulaTokens(
729
+ text: string,
730
+ caret: number,
731
+ fields: { fieldCode: string; label: string }[],
732
+ ): { insert: string; label: string; kind: "field" | "fn" }[];
733
+ export const OMIT_TRAILING_ZEROS_KEY: string;
734
+ export const OMIT_TRAILING_ZEROS_EVENT: string;
735
+ export function loadOmitTrailingZeros(): boolean;
736
+ export function saveOmitTrailingZeros(on: boolean): void;
737
+ export function applyRound(raw: string, kind?: string | null, digits?: number | null): string;
738
+ export function formatRoundDisplay(raw: string, kind?: string | null, digits?: number | null, omitTrailingZeros?: boolean): string;
739
+ export function formatFieldBag(
740
+ bag: Record<string, string>,
741
+ fields: { fieldCode: string; roundKind?: string | null; roundDigits?: number | null }[],
742
+ omitTrailingZeros?: boolean,
743
+ ): Record<string, string>;
744
+ export function formatReportFieldData<T extends { m?: Record<string, unknown> }>(
745
+ data: T,
746
+ fields: { fieldCode: string; roundKind?: string | null; roundDigits?: number | null }[],
747
+ omitTrailingZeros?: boolean,
748
+ ): T;
749
+ export function stripFieldDataTrailingZeros<T extends { m?: Record<string, unknown> }>(data: T): T;
750
+ export function expandFormulaFns(formula: string): string;
751
+ export function isSubField(f: { fieldCode: string; tableRelation?: number | null }): boolean;
752
+ export function isSubtableField(f: FormulaField | undefined, fieldCode: string): boolean;
753
+ export function markLabel(code?: string | null): string;
754
+ export function listSubRows(bag: Record<string, string>): { sid: number; slot: number }[];
755
+ export function projectRow(bag: Record<string, string>, sid: number, slot: number): Record<string, string>;
756
+ export function fieldHandLocked(hands: Set<string>, code: string, sid?: number, slot?: number): boolean;
757
+ export function readFieldSlots(
758
+ bag: Record<string, string>,
759
+ fieldCode: string,
760
+ ): { key: string; value: string; sid?: number; slot: number }[];
761
+ export function inferSubSid(field: FormulaField | undefined, bag: Record<string, string>, fieldCode: string, srcSid?: number): number;
762
+ export function writeMappedValue(
763
+ bag: Record<string, string>,
764
+ field: FormulaField | undefined,
765
+ fieldCode: string,
766
+ value: string,
767
+ srcSid: number | undefined,
768
+ slot: number,
769
+ ): void;
770
+ export function extractFieldRefs(formula: string): string[];
771
+ export function trialFormula(formula: string, fields: { fieldCode: string }[], kind?: string | null, digits?: number | null): string | null;
772
+ export function emptySheetCommonStore(): SheetCommonStore;
773
+ export const FILL_LEFT_COLLAPSED_KEY: string;
774
+ export const FILL_LEFT_COMMON: string;
775
+ export const FILL_LEFT_MEMBER: string;
776
+ export function loadFillLeftCollapsed(): boolean;
777
+ export function saveFillLeftCollapsed(collapsed: boolean): void;
778
+ export function coalesceCommon(
779
+ inst: Record<string, string>,
780
+ tab: Record<string, string>,
781
+ skipNos?: boolean,
782
+ ): Record<string, string>;
783
+ export function isSignCommonField(fieldKey?: string | null): boolean;
784
+ export const RECORD_SIGN_LABELS: Record<string, string>;
785
+ export const REPORT_SIGN_LABELS: Record<string, string>;
786
+ export const SHEET_COMMON_BY_REPORT: string;
787
+ export function coalesceMemberCommon(inst: Record<string, string>, store?: SheetCommonStore | null): Record<string, string>;
788
+ export function coalesceReportPageCommon(inst: Record<string, string>, store: SheetCommonStore | null | undefined, reportSheetId: string): Record<string, string>;
789
+ export function reportPageOverlay(store: SheetCommonStore | null | undefined, reportSheetId: string): Record<string, string>;
790
+ export function setReportPageOverlayField(store: SheetCommonStore | null | undefined, reportSheetId: string, key: string, val: string): SheetCommonStore;
791
+ export function setSheetLegacyField(store: SheetCommonStore | null | undefined, key: string, val: string): SheetCommonStore;
792
+ export function commonFieldLabel(key: string, kind: string | undefined, fallback?: string): string;
793
+ export function orderFillEntryFields<T extends { fieldKey: string }>(fields: T[]): T[];
794
+ export function isFillNoKey(key: string): boolean;
795
+ export function enrichPreviewCommon(common: Record<string, string>, opts?: any): Record<string, string>;
796
+ export function stripFillDefaultBag(bag: Record<string, string>): Record<string, string>;
797
+ export function stripFillDefaultStore(store?: SheetCommonStore | null): SheetCommonStore;
798
+ export function recordNoLabelForKind(kind?: string): string;
799
+ export const DEFAULT_SAMPLE_COMPOSE_KEYS: string[];
800
+ export const SAMPLE_INFO_KEY: string;
801
+ export const SAMPLE_INFO_LABEL: string;
802
+ export function normalizeSampleComposeKeys(keys?: string[] | null): string[];
803
+ export function parseSampleComposeKeys(raw?: string | null): string[];
804
+ export function listVisibleReportSheets(reportKtl?: string | null, entryKtl?: string | null, bag?: any, opts?: { showReport?: boolean }): { id: string; name: string }[];
805
+ export function reportWorkbookForPreview(reportKtl: string | null | undefined, entryKtl: string | null | undefined, bag: any, opts?: { treatAsEmpty?: boolean; showReport?: boolean }): { workbook: any; emptyHint: string };
806
+ export const PREPAGE_EMPTY_HINT: string;
807
+ export type KtFormField = ArtifactField;
808
+ export type StaffSignerLite = { staffId: string; displayName: string; certNos: string[]; hasSignImage?: boolean; signImageSrc?: string };
809
+ export const PERSON_SIGN_SLOTS: readonly { personKey: string; label: string }[];
810
+ export function staffIdKey(personKey: string): string;
811
+ export function certNoKey(personKey: string): string;
812
+ export function formatTestDateCn(raw?: string): string;
813
+ export function formatTestDateText(start?: string, end?: string): string;
814
+ export function sampleNoFromRecordNo(recordNo?: string): string;
815
+ export function useFillLeftScope(
816
+ reportSheets: { id: string; name: string }[],
817
+ resetKey?: string,
818
+ combo?: boolean,
819
+ ): {
820
+ leftScope: string;
821
+ scopeLocked: boolean;
822
+ editingMember: boolean;
823
+ editingReport: boolean;
824
+ previewSheetId?: string;
825
+ onLeftScopeChange: (v: string) => void;
826
+ };
827
+ export function InstanceFillPreviewPane(props: any): JSX.Element;