@campxdev/pdfme 1.2.2 → 1.3.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.
Files changed (46) hide show
  1. package/dist/cjs/chunks/{index-C8qZMUOU.js → fontSizePxWidget-Drk8HKGH.js} +138 -9
  2. package/dist/cjs/chunks/fontSizeTransform-CQQ_O42f.js +37 -0
  3. package/dist/cjs/chunks/{helper-BfoMn47R.js → helper-DGH62Z2s.js} +4 -0
  4. package/dist/cjs/chunks/{index-COKtXyPp.js → index-CoNR0xQU.js} +6 -2
  5. package/dist/cjs/chunks/{index-CVqJfcgy.js → index-CsEKt088.js} +697 -547
  6. package/dist/cjs/chunks/{pluginRegistry-C8bMreez.js → pluginRegistry-D2vr9MUy.js} +1 -1
  7. package/dist/cjs/common.js +7 -3
  8. package/dist/cjs/converter.js +1 -1
  9. package/dist/cjs/generator.js +3 -3
  10. package/dist/cjs/index.js +23 -16
  11. package/dist/cjs/print-designer-editor.js +3320 -3296
  12. package/dist/cjs/schemas.js +500 -38
  13. package/dist/cjs/ui.js +2007 -1868
  14. package/dist/esm/chunks/{index-C4F7EwBG.js → fontSizePxWidget-CbzQrSSM.js} +130 -5
  15. package/dist/esm/chunks/fontSizeTransform-CkTVJdRF.js +34 -0
  16. package/dist/esm/chunks/{helper-D5PPN6Bv.js → helper-DSxGxZ0j.js} +4 -1
  17. package/dist/esm/chunks/{index-CDhErAtE.js → index-DJkUkUo9.js} +4 -3
  18. package/dist/esm/chunks/{index-C7jr4GIK.js → index-D_-j4c4P.js} +691 -544
  19. package/dist/esm/chunks/{pluginRegistry-B-XSNgmK.js → pluginRegistry-Bgrz5qWG.js} +1 -1
  20. package/dist/esm/common.js +4 -3
  21. package/dist/esm/converter.js +1 -1
  22. package/dist/esm/generator.js +3 -3
  23. package/dist/esm/index.js +7 -6
  24. package/dist/esm/print-designer-editor.js +3307 -3286
  25. package/dist/esm/schemas.js +472 -13
  26. package/dist/esm/ui.js +2007 -1868
  27. package/dist/types/_vendors/common/fontSizeTransform.d.ts +5 -0
  28. package/dist/types/_vendors/common/helper.d.ts +1 -0
  29. package/dist/types/_vendors/common/index.d.ts +3 -2
  30. package/dist/types/_vendors/print-designer-editor/index.d.ts +2 -1
  31. package/dist/types/_vendors/print-designer-editor/types.d.ts +1 -1
  32. package/dist/types/_vendors/print-designer-editor/useDesigner.d.ts +1 -1
  33. package/dist/types/_vendors/schemas/index.d.ts +8 -2
  34. package/dist/types/_vendors/schemas/richText/helper.d.ts +3 -0
  35. package/dist/types/_vendors/schemas/richText/index.d.ts +4 -0
  36. package/dist/types/_vendors/schemas/richText/pdfRender.d.ts +3 -0
  37. package/dist/types/_vendors/schemas/richText/propPanel.d.ts +3 -0
  38. package/dist/types/_vendors/schemas/richText/types.d.ts +7 -0
  39. package/dist/types/_vendors/schemas/richText/uiRender.d.ts +3 -0
  40. package/dist/types/_vendors/schemas/singleVariableText/index.d.ts +4 -0
  41. package/dist/types/_vendors/schemas/singleVariableText/propPanel.d.ts +3 -0
  42. package/dist/types/_vendors/schemas/singleVariableText/types.d.ts +4 -0
  43. package/dist/types/_vendors/schemas/text/fontSizePxWidget.d.ts +9 -0
  44. package/dist/types/_vendors/ui/components/CtlBar.d.ts +1 -1
  45. package/dist/types/_vendors/ui/components/Paper.d.ts +1 -0
  46. package/package.json +1 -1
@@ -0,0 +1,5 @@
1
+ import type { Template } from './types.js';
2
+ /** Convert all fontSize fields in a template from pt (pdfme internal) → px (user-facing). */
3
+ export declare const templatePtToPx: (template: Template) => Template;
4
+ /** Convert all fontSize fields in a template from px (user-facing) → pt (pdfme internal). */
5
+ export declare const templatePxToPt: (template: Template) => Template;
@@ -8,6 +8,7 @@ export declare const getAllFontsWithGoogle: () => Font;
8
8
  export declare const mm2pt: (mm: number) => number;
9
9
  export declare const pt2mm: (pt: number) => number;
10
10
  export declare const pt2px: (pt: number) => number;
11
+ export declare const px2pt: (px: number) => number;
11
12
  export declare const px2mm: (px: number) => number;
12
13
  export declare const isHexValid: (hex: string) => boolean;
13
14
  /**
@@ -1,10 +1,11 @@
1
1
  import { PDFME_VERSION } from './version.js';
2
2
  import { MM_TO_PT_RATIO, PT_TO_MM_RATIO, PT_TO_PX_RATIO, BLANK_PDF, BLANK_A4_PDF, CUSTOM_A4_PDF, ZOOM, DEFAULT_FONT_NAME } from './constants.js';
3
3
  import type { ChangeSchemaItem, ChangeSchemas, SchemaPageArray, PropPanel, PropPanelSchema, PropPanelWidgetProps, PDFRenderProps, Mode, UIRenderProps, Plugin, Lang, Dict, Size, Schema, SchemaForUI, Font, ColorType, BasePdf, BlankPdf, CustomPdf, Template, CommonOptions, GeneratorOptions, Plugins, PluginRegistry, GenerateProps, UIOptions, UIProps, PreviewProps, DesignerProps } from './types.js';
4
- import { cloneDeep, getFallbackFontName, getDefaultFont, getBuiltinFontsData, getAllFonts, getAllFontsWithGoogle, getB64BasePdf, b64toUint8Array, checkFont, checkInputs, checkUIOptions, checkTemplate, checkUIProps, checkPreviewProps, checkDesignerProps, checkGenerateProps, mm2pt, pt2mm, pt2px, px2mm, isHexValid, getInputFromTemplate, isBlankPdf } from './helper.js';
4
+ import { cloneDeep, getFallbackFontName, getDefaultFont, getBuiltinFontsData, getAllFonts, getAllFontsWithGoogle, getB64BasePdf, b64toUint8Array, checkFont, checkInputs, checkUIOptions, checkTemplate, checkUIProps, checkPreviewProps, checkDesignerProps, checkGenerateProps, mm2pt, pt2mm, pt2px, px2pt, px2mm, isHexValid, getInputFromTemplate, isBlankPdf } from './helper.js';
5
5
  import { getDynamicTemplate } from './dynamicTemplate.js';
6
+ import { templatePtToPx, templatePxToPt } from './fontSizeTransform.js';
6
7
  import { replacePlaceholders } from './expression.js';
7
8
  import { pluginRegistry } from './pluginRegistry.js';
8
9
  import { googleFonts, getGoogleFontsData, isGoogleFont } from './googleFonts.js';
9
- export { PDFME_VERSION, MM_TO_PT_RATIO, PT_TO_MM_RATIO, PT_TO_PX_RATIO, BLANK_PDF, BLANK_A4_PDF, CUSTOM_A4_PDF, ZOOM, DEFAULT_FONT_NAME, cloneDeep, getFallbackFontName, getDefaultFont, getBuiltinFontsData, getAllFonts, getAllFontsWithGoogle, getB64BasePdf, b64toUint8Array, mm2pt, pt2mm, pt2px, px2mm, isHexValid, getInputFromTemplate, isBlankPdf, getDynamicTemplate, replacePlaceholders, checkFont, checkInputs, checkUIOptions, checkTemplate, checkUIProps, checkPreviewProps, checkDesignerProps, checkGenerateProps, pluginRegistry, googleFonts, getGoogleFontsData, isGoogleFont, };
10
+ export { PDFME_VERSION, MM_TO_PT_RATIO, PT_TO_MM_RATIO, PT_TO_PX_RATIO, BLANK_PDF, BLANK_A4_PDF, CUSTOM_A4_PDF, ZOOM, DEFAULT_FONT_NAME, cloneDeep, getFallbackFontName, getDefaultFont, getBuiltinFontsData, getAllFonts, getAllFontsWithGoogle, getB64BasePdf, b64toUint8Array, mm2pt, pt2mm, pt2px, px2pt, px2mm, isHexValid, getInputFromTemplate, isBlankPdf, getDynamicTemplate, replacePlaceholders, checkFont, checkInputs, checkUIOptions, checkTemplate, checkUIProps, checkPreviewProps, checkDesignerProps, checkGenerateProps, pluginRegistry, googleFonts, getGoogleFontsData, isGoogleFont, templatePtToPx, templatePxToPt, };
10
11
  export type { Lang, Dict, Size, Schema, SchemaForUI, Font, ColorType, BasePdf, BlankPdf, CustomPdf, Template, CommonOptions, GeneratorOptions, Plugin, Plugins, PluginRegistry, GenerateProps, UIOptions, UIProps, PreviewProps, DesignerProps, ChangeSchemaItem, ChangeSchemas, SchemaPageArray, PropPanel, PropPanelSchema, PropPanelWidgetProps, PDFRenderProps, UIRenderProps, Mode, };
@@ -9,6 +9,7 @@ export { useDesigner } from './useDesigner.js';
9
9
  export { useDesignerContext } from './useDesignerContext.js';
10
10
  export { convertPdfToBase64 } from './utils.js';
11
11
  export { generate } from '../generator/index.js';
12
- export { getInputFromTemplate, getDefaultFont, getBuiltinFontsData, getAllFonts, getAllFontsWithGoogle, getGoogleFontsData, isGoogleFont } from '../common/index.js';
12
+ export { getInputFromTemplate, getDefaultFont, getBuiltinFontsData, getAllFonts, getAllFontsWithGoogle, getGoogleFontsData, isGoogleFont, templatePtToPx, templatePxToPt, px2pt } from '../common/index.js';
13
13
  export { plugins } from './plugins.js';
14
+ export { fontSizePxWidget } from '../schemas/index.js';
14
15
  export type { Template, Schema, SchemaForUI, ChangeSchemas, Size, BasePdf, Font, Lang, UIOptions, Plugin, PluginRegistry, PdfmeProviderProps, DesignerContextValue, TemplateVariable, TemplateVariables, } from './types.js';
@@ -43,7 +43,7 @@ export type DesignerContextValue = {
43
43
  setPageCursor: (page: number) => void;
44
44
  addPageAfter: () => void;
45
45
  removePage: () => void;
46
- clonePageAfter: () => void;
46
+ clonePageAfter: (times?: number) => void;
47
47
  handleChangePageSize: (w: number, h: number) => void;
48
48
  handleChangePadding: (padding: [number, number, number, number]) => void;
49
49
  handleChangeBasePdf: (basePdf: BasePdf) => void;
@@ -12,7 +12,7 @@ export declare const useDesigner: () => {
12
12
  getTotalPages: () => number;
13
13
  addPage: () => void;
14
14
  removePage: () => void;
15
- clonePage: () => void;
15
+ clonePage: (times?: number) => void;
16
16
  changePageSize: (w: number, h: number) => void;
17
17
  changePadding: (padding: [number, number, number, number]) => void;
18
18
  undo: () => void;
@@ -1,4 +1,6 @@
1
1
  import multiVariableText from './multiVariableText/index.js';
2
+ import richText from './richText/index.js';
3
+ import singleVariableText from './singleVariableText/index.js';
2
4
  import text from './text/index.js';
3
5
  import image from './graphics/image.js';
4
6
  import svg from './graphics/svg.js';
@@ -16,7 +18,11 @@ import checkbox from './checkbox/index.js';
16
18
  import dynamicTable from './dynamicTable/index.js';
17
19
  import variableBarcodes, { dynamicQrCode, dynamicBarcode } from './variableBarcode/index.js';
18
20
  declare const builtInPlugins: {
19
- Text: import('../common/index.js').Plugin<import("./multiVariableText/types.js").MultiVariableTextSchema>;
21
+ Text: import('../common/index.js').Plugin<import("./text/types.js").TextSchema>;
22
+ 'Dynamic Text': import('../common/index.js').Plugin<import("./singleVariableText/types.js").SingleVariableTextSchema>;
23
+ 'Rich Text': import('../common/index.js').Plugin<import("./richText/types.js").RichTextSchema>;
20
24
  };
21
- export { builtInPlugins, text, multiVariableText, image, svg, signature, table, barcodes, line, rectangle, ellipse, dateTime, date, time, select, radioGroup, checkbox, dynamicTable, variableBarcodes, dynamicQrCode, dynamicBarcode, };
25
+ export { builtInPlugins, text, singleVariableText, richText, multiVariableText, // kept for backward compatibility
26
+ image, svg, signature, table, barcodes, line, rectangle, ellipse, dateTime, date, time, select, radioGroup, checkbox, dynamicTable, variableBarcodes, dynamicQrCode, dynamicBarcode, };
22
27
  export { getDynamicHeightsForTable } from './tables/dynamicTemplate.js';
28
+ export { fontSizePxWidget } from './text/fontSizePxWidget.js';
@@ -0,0 +1,3 @@
1
+ import { RichTextSchema } from './types.js';
2
+ export declare const substituteVariables: (text: string, variablesIn: string | Record<string, string>, extraContext?: Record<string, unknown>) => string;
3
+ export declare const validateVariables: (value: string, schema: RichTextSchema) => boolean;
@@ -0,0 +1,4 @@
1
+ import type { Plugin } from '../../common/index.js';
2
+ import type { RichTextSchema } from './types.js';
3
+ declare const schema: Plugin<RichTextSchema>;
4
+ export default schema;
@@ -0,0 +1,3 @@
1
+ import { PDFRenderProps } from '../../common/index.js';
2
+ import { RichTextSchema } from './types.js';
3
+ export declare const pdfRender: (arg: PDFRenderProps<RichTextSchema>) => Promise<void>;
@@ -0,0 +1,3 @@
1
+ import { PropPanel } from '../../common/index.js';
2
+ import { RichTextSchema } from './types.js';
3
+ export declare const propPanel: PropPanel<RichTextSchema>;
@@ -0,0 +1,7 @@
1
+ import type { TextSchema } from '../text/types.js';
2
+ export interface RichTextSchema extends TextSchema {
3
+ /** Template text containing {varName} placeholders */
4
+ text?: string;
5
+ /** Variable names extracted from template */
6
+ variables?: string[];
7
+ }
@@ -0,0 +1,3 @@
1
+ import { UIRenderProps } from '../../common/index.js';
2
+ import { RichTextSchema } from './types.js';
3
+ export declare const uiRender: (arg: UIRenderProps<RichTextSchema>) => Promise<void>;
@@ -0,0 +1,4 @@
1
+ import type { Plugin } from '../../common/index.js';
2
+ import type { SingleVariableTextSchema } from './types.js';
3
+ declare const schema: Plugin<SingleVariableTextSchema>;
4
+ export default schema;
@@ -0,0 +1,3 @@
1
+ import { PropPanel } from '../../common/index.js';
2
+ import { SingleVariableTextSchema } from './types.js';
3
+ export declare const propPanel: PropPanel<SingleVariableTextSchema>;
@@ -0,0 +1,4 @@
1
+ import type { RichTextSchema } from '../richText/types.js';
2
+ export interface SingleVariableTextSchema extends RichTextSchema {
3
+ type: 'singleVariableText';
4
+ }
@@ -0,0 +1,9 @@
1
+ import type { PropPanelWidgetProps } from '../../common/index.js';
2
+ /**
3
+ * A custom propPanel widget that displays fontSize in pixels (px) while
4
+ * storing the value internally in points (pt) as pdfme requires.
5
+ *
6
+ * Register as `widgets: { fontSizePxWidget }` in Designer options, then
7
+ * swap the fontSize field's widget to 'fontSizePxWidget' in your propPanel schema.
8
+ */
9
+ export declare const fontSizePxWidget: (props: PropPanelWidgetProps) => void;
@@ -9,7 +9,7 @@ type CtlBarProps = {
9
9
  setZoomLevel: (zoom: number) => void;
10
10
  addPageAfter?: () => void;
11
11
  removePage?: () => void;
12
- clonePageAfter?: () => void;
12
+ clonePageAfter?: (times: number) => void;
13
13
  basePdf?: BasePdf;
14
14
  onChangePageSize?: (w: number, h: number) => void;
15
15
  onChangePadding?: (padding: [number, number, number, number]) => void;
@@ -13,6 +13,7 @@ declare const Paper: (props: {
13
13
  }) => ReactNode;
14
14
  renderSchema: (arg: {
15
15
  index: number;
16
+ pageIndex: number;
16
17
  schema: SchemaForUI;
17
18
  }) => ReactNode;
18
19
  hasRulers?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@campxdev/pdfme",
3
- "version": "1.2.2",
3
+ "version": "1.3.0",
4
4
  "sideEffects": false,
5
5
  "author": "hand-dot",
6
6
  "license": "MIT",