@freereportjs/core 0.9.0 → 0.10.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.
package/dist/index.d.ts CHANGED
@@ -76,9 +76,21 @@ interface ElementBase {
76
76
  canGrow?: boolean;
77
77
  /**
78
78
  * Follow the band's height when it grows. Default: true for elements that touch the bottom
79
- * of the band, so cells of a table row stay the same height.
79
+ * of the band, so cells of a table row stay the same height. 'row': take the height of the
80
+ * tallest element on the same row (same y and h), so a label cell grows with its content cell.
80
81
  */
81
- stretch?: boolean;
82
+ stretch?: boolean | 'row';
83
+ /**
84
+ * Move down when an element above it grows (canGrow), by as much as that element grew, so
85
+ * long text pushes the rest of the band down instead of overlapping it. Only elements that
86
+ * overlap it horizontally move. Default true.
87
+ */
88
+ shift?: boolean;
89
+ /**
90
+ * When `visible` is false, give its space back: the elements below it move up into its place
91
+ * and the band shrinks. Default false (the space stays empty).
92
+ */
93
+ collapse?: boolean;
82
94
  /** Excel export: column name in "data" mode; ignored elsewhere. */
83
95
  name?: string;
84
96
  }
@@ -433,6 +445,8 @@ interface TextItem {
433
445
  /** Rotation in degrees around the box centre (watermarks). */
434
446
  rotate?: number;
435
447
  opacity?: number;
448
+ /** The text does not fit its box and is cut off (a box that cannot grow, or a page-sized band). */
449
+ overflow?: boolean;
436
450
  source?: ItemSource;
437
451
  }
438
452
  interface LineItem {
@@ -489,6 +503,23 @@ interface ReportPage {
489
503
  width: number;
490
504
  height: number;
491
505
  items: PageItem[];
506
+ /** Where each element with an id landed (only with the `anchors` layout option). */
507
+ anchors?: ElementAnchor[];
508
+ }
509
+ /** The box of one element instance on a page, in mm from the page's top-left corner. */
510
+ interface ElementAnchor {
511
+ id: string;
512
+ band: BandKind;
513
+ /** Detail row index (detail band only). */
514
+ row?: number;
515
+ x: number;
516
+ y: number;
517
+ w: number;
518
+ h: number;
519
+ /** Its `visible` expression was false: the box it would have used. */
520
+ hidden?: boolean;
521
+ /** It ends below the page's printable area (a band that grew past the page). */
522
+ offPage?: boolean;
492
523
  }
493
524
  interface LayoutResult {
494
525
  pages: ReportPage[];
@@ -511,6 +542,11 @@ interface LayoutOptions {
511
542
  locale?: string;
512
543
  /** Stop after this many pages (safety net for runaway reports). Default 10000. */
513
544
  maxPages?: number;
545
+ /**
546
+ * Record the box of every element with an id on each page (`page.anchors`), including empty
547
+ * text and hidden elements. `report.anchors()` turns this on for you.
548
+ */
549
+ anchors?: boolean;
514
550
  }
515
551
  interface TextMeasurer {
516
552
  /** Width of the text in mm. */
@@ -749,6 +785,13 @@ interface ReportOptions extends LayoutOptions {
749
785
  */
750
786
  directPrint?: boolean | AgentPrintOptions;
751
787
  }
788
+ /** Where an element landed: its box in mm on a page, with that page's size. */
789
+ interface ReportAnchor extends ElementAnchor {
790
+ /** 1-based index of the page in the laid-out report (not the printed page number). */
791
+ page: number;
792
+ pageWidth: number;
793
+ pageHeight: number;
794
+ }
752
795
  interface Report {
753
796
  readonly definition: ReportDefinition;
754
797
  /** Lay out (cached until data, params or the definition change). */
@@ -767,6 +810,12 @@ interface Report {
767
810
  toCsv(): Promise<Blob | null>;
768
811
  /** 한/글 document (.hwpx, KS X 6101) laid out like the printed pages. */
769
812
  toHwpx(): Promise<Blob | null>;
813
+ /**
814
+ * Boxes of the elements with an id, page by page (mm from the page's top-left corner), including
815
+ * empty text and hidden elements: for signature fields, form overlays and tests. `prefix` keeps
816
+ * only ids that start with it, e.g. "sp:".
817
+ */
818
+ anchors(prefix?: string): ReportAnchor[];
770
819
  /** SHA-256 of the printed text (원본 확인); also available as `docHash` when the definition sets `fingerprint`. */
771
820
  fingerprint(): string;
772
821
  /** Save a file through the browser's download. */
@@ -881,10 +930,12 @@ declare function pagesToXlsx(layout: LayoutResult, def: ReportDefinition, opts?:
881
930
  declare function dataToXlsx(def: ReportDefinition, data: ReportData, opts?: {
882
931
  params?: Record<string, unknown>;
883
932
  sheetName?: string;
933
+ locale?: string;
884
934
  }): Uint8Array;
885
935
  /** CSV of the same columns as `dataToXlsx` (UTF-8 with BOM so Excel opens Korean correctly). */
886
936
  declare function dataToCsv(def: ReportDefinition, data: ReportData, opts?: {
887
937
  params?: Record<string, unknown>;
938
+ locale?: string;
888
939
  }): string;
889
940
 
890
941
  /** Export laid-out pages as an HWPX document (한/글 2018+, 한컴오피스 뷰어). */
@@ -1012,7 +1063,7 @@ declare function checkExpression(src: string): string | null;
1012
1063
  * Fill a text template: "Page {page} / {pages}", "{amount:#,##0} 원". The part after the last
1013
1064
  * top-level ":" is a format when it does not parse as part of the expression ("{a ? b : c}" works).
1014
1065
  */
1015
- declare function interpolate(template: string, scope: Scope): string;
1066
+ declare function interpolate(template: string, scope: Scope, locale?: string): string;
1016
1067
 
1017
1068
  /**
1018
1069
  * Value formatting for report fields.
@@ -1145,7 +1196,7 @@ declare function verifyLicense(key: string, host: string, opts?: {
1145
1196
  declare function setLicenseKey(key: string): void;
1146
1197
 
1147
1198
  /** FreeReport version (kept in sync with releases.json by scripts/release.mjs). */
1148
- declare const version = "0.9.0";
1199
+ declare const version = "0.10.1";
1149
1200
 
1150
1201
  type Lang = 'ko' | 'en';
1151
1202
 
@@ -1207,4 +1258,4 @@ declare function renderXlsx(def: ReportDefinition, data?: ReportData, opts?: Ser
1207
1258
  mode?: 'form' | 'data';
1208
1259
  }): Promise<Uint8Array>;
1209
1260
 
1210
- export { AgentError, type AgentLogEntry, type AgentPrintOptions, type AgentPrintResult, type AgentPrinter, type AgentStatus, type Align, type Band, type BandKind, type BarcodeElement, type BorderInput, type BorderSide, type BoxItem, type ChartElement, type ChartSeries, type CrosstabElement, type Designer, type DesignerOptions, type ElementType, type Emboss, type Expr, FUNCTIONS, type FieldElement, type FontBytes, type FontEntry, type GroupDefinition, type ImageElement, type ImageItem, type ItemSource, type LayoutOptions, type LayoutResult, type LicenseInfo, type LineElement, type LineItem, type OutputEvent, type OutputKind, PAPER, type PageItem, type PageSetup, type PaperSize, type ParamDefinition, type PathCommand, type PathItem, type PdfFontSource, type PdfOptions, type PdfPermissions, type PdfSecurity, type PrintOptions, type RectElement, type Report, type ReportData, type ReportDefinition, type ReportElement, type ReportOptions, type ReportPage, type ResolvedBorder, type ResolvedFont, type ServerRenderOptions, type Style, type TableColumn, type TableElement, type TextElement, type TextItem, type TextLine, type TextMeasurer, type VAlign, type Viewer, type ViewerOptions, type ViewerReadyEvent, type Watermark, type XCell, type XCellStyle, type XSheet, agent, applyEmboss, blankReport, canonicalText, canvasMeasurer, checkExpression, compile, contentWidth, createDesigner, createReport, createViewer, dataToCsv, dataToXlsx, defaultMeasurer, embossImage, encodeCode128, encodeDataMatrix, encodeEan13, encodePdf417, encodeQr, ensureFonts, estimateMeasurer, evaluate, fingerprintPages, formatDate, formatNumber, formatValue, getFont, interpolate, koreanAmount, koreanNumber, layoutReport, loadFontBytes, loadFonts, pageGeometry, pageToSvg, pagesToHwpx, pagesToXlsx, paramValues, printPages, registerFont, renderPage, renderPdf, renderXlsx, resetMeasurer, rowsOf, saveFile, setLicenseKey, sha256Hex, ttfMeasurer, verifyLicense, version, wrapText, writePdf, writeXlsx };
1261
+ export { AgentError, type AgentLogEntry, type AgentPrintOptions, type AgentPrintResult, type AgentPrinter, type AgentStatus, type Align, type Band, type BandKind, type BarcodeElement, type BorderInput, type BorderSide, type BoxItem, type ChartElement, type ChartSeries, type CrosstabElement, type Designer, type DesignerOptions, type ElementAnchor, type ElementType, type Emboss, type Expr, FUNCTIONS, type FieldElement, type FontBytes, type FontEntry, type GroupDefinition, type ImageElement, type ImageItem, type ItemSource, type LayoutOptions, type LayoutResult, type LicenseInfo, type LineElement, type LineItem, type OutputEvent, type OutputKind, PAPER, type PageItem, type PageSetup, type PaperSize, type ParamDefinition, type PathCommand, type PathItem, type PdfFontSource, type PdfOptions, type PdfPermissions, type PdfSecurity, type PrintOptions, type RectElement, type Report, type ReportAnchor, type ReportData, type ReportDefinition, type ReportElement, type ReportOptions, type ReportPage, type ResolvedBorder, type ResolvedFont, type ServerRenderOptions, type Style, type TableColumn, type TableElement, type TextElement, type TextItem, type TextLine, type TextMeasurer, type VAlign, type Viewer, type ViewerOptions, type ViewerReadyEvent, type Watermark, type XCell, type XCellStyle, type XSheet, agent, applyEmboss, blankReport, canonicalText, canvasMeasurer, checkExpression, compile, contentWidth, createDesigner, createReport, createViewer, dataToCsv, dataToXlsx, defaultMeasurer, embossImage, encodeCode128, encodeDataMatrix, encodeEan13, encodePdf417, encodeQr, ensureFonts, estimateMeasurer, evaluate, fingerprintPages, formatDate, formatNumber, formatValue, getFont, interpolate, koreanAmount, koreanNumber, layoutReport, loadFontBytes, loadFonts, pageGeometry, pageToSvg, pagesToHwpx, pagesToXlsx, paramValues, printPages, registerFont, renderPage, renderPdf, renderXlsx, resetMeasurer, rowsOf, saveFile, setLicenseKey, sha256Hex, ttfMeasurer, verifyLicense, version, wrapText, writePdf, writeXlsx };