@pdfme/schemas 5.3.11-dev.6 → 5.3.11-dev.7

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 (152) hide show
  1. package/dist/cjs/src/barcodes/helper.js +1 -1
  2. package/dist/cjs/src/barcodes/helper.js.map +1 -1
  3. package/dist/cjs/src/barcodes/pdfRender.js +5 -1
  4. package/dist/cjs/src/barcodes/pdfRender.js.map +1 -1
  5. package/dist/cjs/src/barcodes/uiRender.js +5 -3
  6. package/dist/cjs/src/barcodes/uiRender.js.map +1 -1
  7. package/dist/cjs/src/checkbox/index.js +2 -1
  8. package/dist/cjs/src/checkbox/index.js.map +1 -1
  9. package/dist/cjs/src/date/helper.js +1 -1
  10. package/dist/cjs/src/date/helper.js.map +1 -1
  11. package/dist/cjs/src/graphics/image.js +6 -3
  12. package/dist/cjs/src/graphics/image.js.map +1 -1
  13. package/dist/cjs/src/graphics/svg.js +3 -2
  14. package/dist/cjs/src/graphics/svg.js.map +1 -1
  15. package/dist/cjs/src/multiVariableText/helper.js +3 -3
  16. package/dist/cjs/src/multiVariableText/helper.js.map +1 -1
  17. package/dist/cjs/src/multiVariableText/propPanel.js +18 -10
  18. package/dist/cjs/src/multiVariableText/propPanel.js.map +1 -1
  19. package/dist/cjs/src/multiVariableText/uiRender.js +14 -11
  20. package/dist/cjs/src/multiVariableText/uiRender.js.map +1 -1
  21. package/dist/cjs/src/select/index.js +2 -1
  22. package/dist/cjs/src/select/index.js.map +1 -1
  23. package/dist/cjs/src/tables/classes.js.map +1 -1
  24. package/dist/cjs/src/tables/propPanel.js +1 -1
  25. package/dist/cjs/src/tables/propPanel.js.map +1 -1
  26. package/dist/cjs/src/tables/tableHelper.js +1 -1
  27. package/dist/cjs/src/tables/tableHelper.js.map +1 -1
  28. package/dist/cjs/src/tables/uiRender.js +4 -2
  29. package/dist/cjs/src/tables/uiRender.js.map +1 -1
  30. package/dist/cjs/src/text/extraFormatter.js +1 -0
  31. package/dist/cjs/src/text/extraFormatter.js.map +1 -1
  32. package/dist/cjs/src/text/helper.js +19 -3
  33. package/dist/cjs/src/text/helper.js.map +1 -1
  34. package/dist/cjs/src/text/pdfRender.js +1 -1
  35. package/dist/cjs/src/text/pdfRender.js.map +1 -1
  36. package/dist/cjs/src/text/propPanel.js.map +1 -1
  37. package/dist/cjs/src/text/uiRender.js +7 -5
  38. package/dist/cjs/src/text/uiRender.js.map +1 -1
  39. package/dist/cjs/src/utils.js +3 -3
  40. package/dist/cjs/src/utils.js.map +1 -1
  41. package/dist/esm/src/barcodes/helper.js +1 -1
  42. package/dist/esm/src/barcodes/helper.js.map +1 -1
  43. package/dist/esm/src/barcodes/pdfRender.js +5 -1
  44. package/dist/esm/src/barcodes/pdfRender.js.map +1 -1
  45. package/dist/esm/src/barcodes/uiRender.js +5 -3
  46. package/dist/esm/src/barcodes/uiRender.js.map +1 -1
  47. package/dist/esm/src/checkbox/index.js +2 -1
  48. package/dist/esm/src/checkbox/index.js.map +1 -1
  49. package/dist/esm/src/date/helper.js +1 -1
  50. package/dist/esm/src/date/helper.js.map +1 -1
  51. package/dist/esm/src/graphics/image.js +6 -3
  52. package/dist/esm/src/graphics/image.js.map +1 -1
  53. package/dist/esm/src/graphics/svg.js +3 -2
  54. package/dist/esm/src/graphics/svg.js.map +1 -1
  55. package/dist/esm/src/multiVariableText/helper.js +3 -3
  56. package/dist/esm/src/multiVariableText/helper.js.map +1 -1
  57. package/dist/esm/src/multiVariableText/propPanel.js +18 -10
  58. package/dist/esm/src/multiVariableText/propPanel.js.map +1 -1
  59. package/dist/esm/src/multiVariableText/uiRender.js +14 -11
  60. package/dist/esm/src/multiVariableText/uiRender.js.map +1 -1
  61. package/dist/esm/src/select/index.js +2 -1
  62. package/dist/esm/src/select/index.js.map +1 -1
  63. package/dist/esm/src/tables/classes.js.map +1 -1
  64. package/dist/esm/src/tables/propPanel.js +1 -1
  65. package/dist/esm/src/tables/propPanel.js.map +1 -1
  66. package/dist/esm/src/tables/tableHelper.js +1 -1
  67. package/dist/esm/src/tables/tableHelper.js.map +1 -1
  68. package/dist/esm/src/tables/uiRender.js +4 -2
  69. package/dist/esm/src/tables/uiRender.js.map +1 -1
  70. package/dist/esm/src/text/extraFormatter.js +1 -0
  71. package/dist/esm/src/text/extraFormatter.js.map +1 -1
  72. package/dist/esm/src/text/helper.js +19 -3
  73. package/dist/esm/src/text/helper.js.map +1 -1
  74. package/dist/esm/src/text/pdfRender.js +1 -1
  75. package/dist/esm/src/text/pdfRender.js.map +1 -1
  76. package/dist/esm/src/text/propPanel.js.map +1 -1
  77. package/dist/esm/src/text/uiRender.js +7 -5
  78. package/dist/esm/src/text/uiRender.js.map +1 -1
  79. package/dist/esm/src/utils.js +3 -3
  80. package/dist/esm/src/utils.js.map +1 -1
  81. package/dist/node/src/barcodes/helper.js +1 -1
  82. package/dist/node/src/barcodes/helper.js.map +1 -1
  83. package/dist/node/src/barcodes/pdfRender.js +5 -1
  84. package/dist/node/src/barcodes/pdfRender.js.map +1 -1
  85. package/dist/node/src/barcodes/uiRender.js +5 -3
  86. package/dist/node/src/barcodes/uiRender.js.map +1 -1
  87. package/dist/node/src/checkbox/index.js +2 -1
  88. package/dist/node/src/checkbox/index.js.map +1 -1
  89. package/dist/node/src/date/helper.js +1 -1
  90. package/dist/node/src/date/helper.js.map +1 -1
  91. package/dist/node/src/graphics/image.js +6 -3
  92. package/dist/node/src/graphics/image.js.map +1 -1
  93. package/dist/node/src/graphics/svg.js +3 -2
  94. package/dist/node/src/graphics/svg.js.map +1 -1
  95. package/dist/node/src/multiVariableText/helper.js +3 -3
  96. package/dist/node/src/multiVariableText/helper.js.map +1 -1
  97. package/dist/node/src/multiVariableText/propPanel.js +18 -10
  98. package/dist/node/src/multiVariableText/propPanel.js.map +1 -1
  99. package/dist/node/src/multiVariableText/uiRender.js +14 -11
  100. package/dist/node/src/multiVariableText/uiRender.js.map +1 -1
  101. package/dist/node/src/select/index.js +2 -1
  102. package/dist/node/src/select/index.js.map +1 -1
  103. package/dist/node/src/tables/classes.js.map +1 -1
  104. package/dist/node/src/tables/propPanel.js +1 -1
  105. package/dist/node/src/tables/propPanel.js.map +1 -1
  106. package/dist/node/src/tables/tableHelper.js +1 -1
  107. package/dist/node/src/tables/tableHelper.js.map +1 -1
  108. package/dist/node/src/tables/uiRender.js +4 -2
  109. package/dist/node/src/tables/uiRender.js.map +1 -1
  110. package/dist/node/src/text/extraFormatter.js +1 -0
  111. package/dist/node/src/text/extraFormatter.js.map +1 -1
  112. package/dist/node/src/text/helper.js +19 -3
  113. package/dist/node/src/text/helper.js.map +1 -1
  114. package/dist/node/src/text/pdfRender.js +1 -1
  115. package/dist/node/src/text/pdfRender.js.map +1 -1
  116. package/dist/node/src/text/propPanel.js.map +1 -1
  117. package/dist/node/src/text/uiRender.js +7 -5
  118. package/dist/node/src/text/uiRender.js.map +1 -1
  119. package/dist/node/src/utils.js +3 -3
  120. package/dist/node/src/utils.js.map +1 -1
  121. package/dist/types/src/barcodes/helper.d.ts +9 -0
  122. package/dist/types/src/graphics/image.d.ts +1 -2
  123. package/dist/types/src/graphics/svg.d.ts +1 -2
  124. package/dist/types/src/tables/classes.d.ts +2 -1
  125. package/dist/types/src/tables/dynamicTemplate.d.ts +1 -1
  126. package/dist/types/src/tables/tableHelper.d.ts +1 -1
  127. package/dist/types/src/text/extraFormatter.d.ts +1 -2
  128. package/dist/types/src/text/helper.d.ts +1 -1
  129. package/dist/types/src/utils.d.ts +1 -1
  130. package/package.json +1 -1
  131. package/src/barcodes/helper.ts +14 -2
  132. package/src/barcodes/pdfRender.ts +7 -4
  133. package/src/barcodes/uiRender.ts +3 -3
  134. package/src/checkbox/index.ts +1 -1
  135. package/src/date/helper.ts +5 -5
  136. package/src/graphics/image.ts +4 -4
  137. package/src/graphics/svg.ts +4 -3
  138. package/src/multiVariableText/helper.ts +4 -4
  139. package/src/multiVariableText/propPanel.ts +20 -12
  140. package/src/multiVariableText/uiRender.ts +15 -14
  141. package/src/select/index.ts +1 -1
  142. package/src/tables/classes.ts +2 -2
  143. package/src/tables/dynamicTemplate.ts +1 -1
  144. package/src/tables/propPanel.ts +1 -1
  145. package/src/tables/tableHelper.ts +3 -2
  146. package/src/tables/uiRender.ts +2 -2
  147. package/src/text/extraFormatter.ts +2 -2
  148. package/src/text/helper.ts +19 -6
  149. package/src/text/pdfRender.ts +3 -3
  150. package/src/text/propPanel.ts +4 -4
  151. package/src/text/uiRender.ts +6 -6
  152. package/src/utils.ts +5 -5
@@ -1,6 +1,5 @@
1
1
  import type { Plugin } from '@pdfme/common';
2
2
  import type { Schema } from '@pdfme/common';
3
- interface ImageSchema extends Schema {
4
- }
3
+ type ImageSchema = Schema;
5
4
  declare const imageSchema: Plugin<ImageSchema>;
6
5
  export default imageSchema;
@@ -1,5 +1,4 @@
1
1
  import { Plugin, Schema } from '@pdfme/common';
2
- interface SVGSchema extends Schema {
3
- }
2
+ export type SVGSchema = Schema;
4
3
  declare const svgSchema: Plugin<SVGSchema>;
5
4
  export default svgSchema;
@@ -1,4 +1,5 @@
1
1
  import { Font } from '@pdfme/common';
2
+ import type { Font as FontKitFont } from 'fontkit';
2
3
  import type { Styles, TableInput, Settings, Section, StylesProps } from './types.js';
3
4
  type ContentSettings = {
4
5
  body: Row[];
@@ -57,7 +58,7 @@ export declare class Table {
57
58
  input: TableInput;
58
59
  content: ContentSettings;
59
60
  font: Font;
60
- _cache: Map<any, any>;
61
+ _cache: Map<string, FontKitFont>;
61
62
  }): Promise<Table>;
62
63
  getHeadHeight(): number;
63
64
  getBodyHeight(): number;
@@ -3,5 +3,5 @@ export declare const getDynamicHeightsForTable: (value: string, args: {
3
3
  schema: Schema;
4
4
  basePdf: BasePdf;
5
5
  options: CommonOptions;
6
- _cache: Map<any, any>;
6
+ _cache: Map<string, unknown>;
7
7
  }) => Promise<number[]>;
@@ -4,7 +4,7 @@ interface CreateTableArgs {
4
4
  schema: Schema;
5
5
  basePdf: BasePdf;
6
6
  options: CommonOptions;
7
- _cache: Map<any, any>;
7
+ _cache: Map<string, unknown>;
8
8
  }
9
9
  export declare function createSingleTable(body: string[][], args: CreateTableArgs): Promise<Table>;
10
10
  export {};
@@ -1,4 +1,3 @@
1
- import { Dict } from '@pdfme/common';
2
1
  export declare enum Formatter {
3
2
  STRIKETHROUGH = "strikethrough",
4
3
  UNDERLINE = "underline",
@@ -17,7 +16,7 @@ interface GroupButtonString {
17
16
  value: string;
18
17
  }
19
18
  type GroupButton = GroupButtonBoolean | GroupButtonString;
20
- export declare function getExtraFormatterSchema(i18n: (key: keyof Dict | string) => string): {
19
+ export declare function getExtraFormatterSchema(i18n: (key: string) => string): {
21
20
  title: string;
22
21
  widget: string;
23
22
  buttons: GroupButton[];
@@ -9,7 +9,7 @@ export declare const getBrowserVerticalFontAdjustments: (fontKitFont: FontKitFon
9
9
  export declare const getFontDescentInPt: (fontKitFont: FontKitFont, fontSize: number) => number;
10
10
  export declare const heightOfFontAtSize: (fontKitFont: FontKitFont, fontSize: number) => number;
11
11
  export declare const widthOfTextAtSize: (text: string, fontKitFont: FontKitFont, fontSize: number, characterSpacing: number) => number;
12
- export declare const getFontKitFont: (fontName: string | undefined, font: Font, _cache: Map<any, any>) => Promise<fontkit.Font>;
12
+ export declare const getFontKitFont: (fontName: string | undefined, font: Font, _cache: Map<string, fontkit.Font>) => Promise<fontkit.Font>;
13
13
  /**
14
14
  * Recursively splits the line at getSplitPosition.
15
15
  * If there is some leftover, split the rest again in the same manner.
@@ -29,7 +29,7 @@ export declare const getDynamicHeightsForTable: (value: string, args: {
29
29
  schema: Schema;
30
30
  basePdf: import("@pdfme/common").BasePdf;
31
31
  options: import("@pdfme/common").CommonOptions;
32
- _cache: Map<any, any>;
32
+ _cache: Map<string, unknown>;
33
33
  }) => Promise<number[]>;
34
34
  export declare const addAlphaToHex: (hex: string, alphaPercentage: number) => string;
35
35
  export declare const isEditable: (mode: Mode, schema: Schema) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdfme/schemas",
3
- "version": "5.3.11-dev.6",
3
+ "version": "5.3.11-dev.7",
4
4
  "sideEffects": false,
5
5
  "author": "hand-dot",
6
6
  "license": "MIT",
@@ -1,6 +1,18 @@
1
1
  import { b64toUint8Array } from '@pdfme/common';
2
2
  import bwipjs, { RenderOptions } from 'bwip-js';
3
3
  import { Buffer } from 'buffer';
4
+
5
+ // Extend the bwipjs type to include browser-specific methods
6
+ declare module 'bwip-js' {
7
+ interface BwipJs {
8
+ toCanvas(canvas: HTMLCanvasElement, options: any): void;
9
+ }
10
+
11
+ export default interface BwipJsModule {
12
+ toCanvas(canvas: HTMLCanvasElement, options: any): void;
13
+ toBuffer(options: any): Promise<Buffer>;
14
+ }
15
+ }
4
16
  import { BARCODE_TYPES, DEFAULT_BARCODE_INCLUDETEXT } from './constants.js';
5
17
  import { BarcodeTypes } from './types.js';
6
18
 
@@ -166,8 +178,8 @@ export const createBarCode = async (arg: {
166
178
 
167
179
  if (typeof window !== 'undefined') {
168
180
  const canvas = document.createElement('canvas');
169
- // @ts-ignore
170
- bwipjs.toCanvas(canvas, bwipjsArg);
181
+ // Using any type for bwipjs to avoid type errors with toCanvas method
182
+ (bwipjs as any).toCanvas(canvas, bwipjsArg);
171
183
  const dataUrl = canvas.toDataURL('image/png');
172
184
  res = Buffer.from(b64toUint8Array(dataUrl).buffer);
173
185
  } else {
@@ -2,6 +2,7 @@ import { PDFRenderProps } from '@pdfme/common';
2
2
  import { convertForPdfLayoutProps } from '../utils.js';
3
3
  import type { BarcodeSchema } from './types.js';
4
4
  import { createBarCode, validateBarcodeInput } from './helper.js';
5
+ import { PDFImage } from '@pdfme/pdf-lib';
5
6
 
6
7
  const getBarcodeCacheKey = (schema: BarcodeSchema, value: string) => {
7
8
  return `${schema.type}${schema.backgroundColor}${schema.barColor}${schema.textColor}${value}${schema.includetext}`;
@@ -12,11 +13,13 @@ export const pdfRender = async (arg: PDFRenderProps<BarcodeSchema>) => {
12
13
  if (!validateBarcodeInput(schema.type, value)) return;
13
14
 
14
15
  const inputBarcodeCacheKey = getBarcodeCacheKey(schema, value);
15
- let image = _cache.get(inputBarcodeCacheKey);
16
+ let image = _cache.get(inputBarcodeCacheKey) as PDFImage | undefined;
16
17
  if (!image) {
17
- const imageBuf = await createBarCode(
18
- Object.assign(schema, { type: schema.type, input: value }),
19
- );
18
+ const imageBuf = await createBarCode({
19
+ ...schema,
20
+ type: schema.type,
21
+ input: value,
22
+ });
20
23
  image = await pdfDoc.embedPng(imageBuf);
21
24
  _cache.set(inputBarcodeCacheKey, image);
22
25
  }
@@ -69,10 +69,10 @@ export const uiRender = async (arg: UIRenderProps<BarcodeSchema>) => {
69
69
  input.placeholder = placeholder || '';
70
70
  input.tabIndex = tabIndex || 0;
71
71
  input.addEventListener('change', (e: Event) => {
72
- onChange && onChange({ key: 'content', value: (e.target as HTMLInputElement).value });
72
+ if (onChange) onChange({ key: 'content', value: (e.target as HTMLInputElement).value });
73
73
  });
74
74
  input.addEventListener('blur', () => {
75
- stopEditing && stopEditing();
75
+ if (stopEditing) stopEditing();
76
76
  });
77
77
  container.appendChild(input);
78
78
  input.setSelectionRange(value.length, value.length);
@@ -88,7 +88,7 @@ export const uiRender = async (arg: UIRenderProps<BarcodeSchema>) => {
88
88
  const imgElm = await createBarcodeImageElm(schema, value);
89
89
  container.appendChild(imgElm);
90
90
  } catch (err) {
91
- console.error(`[@pdfme/ui] ${err}`);
91
+ console.error(`[@pdfme/ui] ${String(err)}`);
92
92
  container.appendChild(createErrorElm());
93
93
  }
94
94
  };
@@ -27,7 +27,7 @@ const schema: Plugin<Checkbox> = {
27
27
 
28
28
  if (isEditable(mode, schema)) {
29
29
  container.addEventListener('click', () => {
30
- onChange && onChange({ key: 'content', value: value === 'true' ? 'false' : 'true' });
30
+ if (onChange) onChange({ key: 'content', value: value === 'true' ? 'false' : 'true' });
31
31
  });
32
32
  }
33
33
 
@@ -318,12 +318,12 @@ export const getPlugin = ({ type, icon }: { type: PickerType; icon: string }) =>
318
318
  const fallbackFontName = getFallbackFontName(font);
319
319
 
320
320
  const locale = getAirDatepickerLocale(
321
- (activeSchema as any).locale || options.lang || defaultLocale,
321
+ (activeSchema as { locale?: string }).locale || options.lang || defaultLocale,
322
322
  );
323
323
 
324
324
  if (
325
- (activeSchema as any).locale === undefined &&
326
- (activeSchema as any).locale !== options.lang
325
+ (activeSchema as { locale?: string }).locale === undefined &&
326
+ (activeSchema as { locale?: string }).locale !== options.lang
327
327
  ) {
328
328
  changeSchemas([
329
329
  { schemaId: activeSchema.id, key: 'locale', value: options.lang },
@@ -336,13 +336,13 @@ export const getPlugin = ({ type, icon }: { type: PickerType; icon: string }) =>
336
336
  (button) => button.key === Formatter.ALIGNMENT,
337
337
  );
338
338
 
339
- const validateDateTimeFormat = (_rule: any, formatString: string): boolean => {
339
+ const validateDateTimeFormat = (_rule: unknown, formatString: string): boolean => {
340
340
  try {
341
341
  format('Thu Jan 01 1970 00:00:00 GMT+0000', formatString, {
342
342
  locale: locale.formatLocale,
343
343
  });
344
344
  return true;
345
- } catch (_err) {
345
+ } catch {
346
346
  return false;
347
347
  }
348
348
  };
@@ -20,7 +20,7 @@ const fullSize = { width: '100%', height: '100%' };
20
20
  const defaultValue =
21
21
  'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAUgAAAGQBAMAAAA+V+RCAAAAAXNSR0IArs4c6QAAABtQTFRFAAAAR3BMAAAAAAAAAAAAAAAAAAAAAAAAAAAAqmQqwQAAAAh0Uk5TDQAvVYGtxusE1uR9AAAKg0lEQVR42tTbwU7bQBDG8TWoPeOBPoBbdbhiVMGV0Kr0GChSe0RtRfccEOROnP0eu8ckTMHrjD27/h4Afvo7u4kUxZXbjuboZ+Hx9vrz+6J8eW5rJKPHhYfr46J/JHn0u/DnuHcko/eF71Ub0j6k3P1Rr0jGIHs4bkPah5RbnveHZMBQ6VKHlMqjnpCMAdfUApk8pNx91QeSMex+C2R2IYFwrkcyht6yEsjkIeXutEjG8AtnApldSGBRq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OIhHJkQ4mJABGJSvvGeiT1F7aMyzH9KJL2biyN6zdUjUTlr6l54vZDj+qQWPrXmWEi5KUEJBa//26RGRMuP449+jEkprV8TLPGgenjx8uomkj0N73+g6V/XjknAAAAAElFTkSuQmCC';
22
22
 
23
- interface ImageSchema extends Schema {}
23
+ type ImageSchema = Schema;
24
24
 
25
25
  const imageSchema: Plugin<ImageSchema> = {
26
26
  pdf: async (arg: PDFRenderProps<ImageSchema>) => {
@@ -131,7 +131,7 @@ const imageSchema: Plugin<ImageSchema> = {
131
131
  };
132
132
  Object.assign(button.style, buttonStyle);
133
133
  button.addEventListener('click', () => {
134
- onChange && onChange({ key: 'content', value: '' });
134
+ if (onChange) onChange({ key: 'content', value: '' });
135
135
  });
136
136
  container.appendChild(button);
137
137
  }
@@ -168,13 +168,13 @@ const imageSchema: Plugin<ImageSchema> = {
168
168
  const changeEvent = event as unknown as ChangeEvent<HTMLInputElement>;
169
169
  readFile(changeEvent.target.files)
170
170
  .then((result) => {
171
- onChange && onChange({ key: 'content', value: result as string });
171
+ if (onChange) onChange({ key: 'content', value: result as string });
172
172
  })
173
173
  .catch((error) => {
174
174
  console.error('Error reading file:', error);
175
175
  });
176
176
  });
177
- input.addEventListener('blur', () => stopEditing && stopEditing());
177
+ input.addEventListener('blur', () => { if (stopEditing) stopEditing(); });
178
178
  label.appendChild(input);
179
179
  }
180
180
  },
@@ -31,7 +31,7 @@ const isValidSVG = (svgString: string): boolean => {
31
31
  }
32
32
 
33
33
  return true;
34
- } catch (error) {
34
+ } catch {
35
35
  return false;
36
36
  }
37
37
  };
@@ -42,7 +42,8 @@ const defaultValue = `<svg viewBox="0 0 488 600" version="1.1" xmlns="http://www
42
42
  </g>
43
43
  </svg>`;
44
44
 
45
- interface SVGSchema extends Schema {}
45
+ // This interface extends Schema with no additional properties
46
+ export type SVGSchema = Schema;
46
47
 
47
48
  const svgSchema: Plugin<SVGSchema> = {
48
49
  ui: (arg) => {
@@ -73,7 +74,7 @@ const svgSchema: Plugin<SVGSchema> = {
73
74
 
74
75
  textarea.addEventListener('change', (e: Event) => {
75
76
  const newValue = (e.target as HTMLTextAreaElement).value;
76
- onChange && onChange({ key: 'content', value: newValue });
77
+ if (onChange) onChange({ key: 'content', value: newValue });
77
78
  });
78
79
  rootElement.appendChild(container);
79
80
  textarea.setSelectionRange(value.length, value.length);
@@ -12,7 +12,7 @@ export const substituteVariables = (
12
12
 
13
13
  if (variablesIn) {
14
14
  const variables: Record<string, string> =
15
- typeof variablesIn === 'string' ? JSON.parse(variablesIn) || {} : variablesIn;
15
+ typeof variablesIn === 'string' ? JSON.parse(variablesIn || '{}') as Record<string, string> : variablesIn;
16
16
 
17
17
  Object.keys(variables).forEach((variableName) => {
18
18
  // handle special characters in variable name
@@ -29,14 +29,14 @@ export const substituteVariables = (
29
29
  };
30
30
 
31
31
  export const validateVariables = (value: string, schema: MultiVariableTextSchema): boolean => {
32
- if (schema.variables.length == 0) {
32
+ if (schema.variables.length === 0) {
33
33
  return true;
34
34
  }
35
35
 
36
36
  let values;
37
37
  try {
38
- values = value ? JSON.parse(value) : {};
39
- } catch (e) {
38
+ values = value ? JSON.parse(value) as Record<string, string> : {};
39
+ } catch {
40
40
  throw new SyntaxError(
41
41
  `[@pdfme/generator] invalid JSON string '${value}' for variables in field ${schema.name}`,
42
42
  );
@@ -5,9 +5,9 @@ import { MultiVariableTextSchema } from './types.js';
5
5
  const mapDynamicVariables = (props: PropPanelWidgetProps) => {
6
6
  const { rootElement, changeSchemas, activeSchema, i18n, options } = props;
7
7
 
8
- const mvtSchema = activeSchema as any;
8
+ const mvtSchema = activeSchema as unknown as MultiVariableTextSchema;
9
9
  const text = mvtSchema.text || '';
10
- const variables = JSON.parse(mvtSchema.content) || {};
10
+ const variables = JSON.parse(mvtSchema.content || '{}') as Record<string, string>;
11
11
  const variablesChanged = updateVariablesFromText(text, variables);
12
12
  const varNames = Object.keys(variables);
13
13
 
@@ -37,10 +37,12 @@ const mapDynamicVariables = (props: PropPanelWidgetProps) => {
37
37
  textarea.id = 'dynamic-var-' + variableName;
38
38
  textarea.value = variables[variableName];
39
39
  textarea.addEventListener('change', (e: Event) => {
40
- variables[variableName] = (e.target as HTMLTextAreaElement).value;
41
- changeSchemas([
42
- { key: 'content', value: JSON.stringify(variables), schemaId: activeSchema.id },
43
- ]);
40
+ if (variableName in variables) {
41
+ variables[variableName] = (e.target as HTMLTextAreaElement).value;
42
+ changeSchemas([
43
+ { key: 'content', value: JSON.stringify(variables), schemaId: activeSchema.id },
44
+ ]);
45
+ }
44
46
  });
45
47
 
46
48
  const label = varRow.querySelector('label') as HTMLLabelElement;
@@ -51,9 +53,13 @@ const mapDynamicVariables = (props: PropPanelWidgetProps) => {
51
53
  }
52
54
  } else {
53
55
  const para = document.createElement('p');
56
+ // Extract color value to avoid unsafe property access
57
+ const colorValue = options?.theme?.token?.colorPrimary || '#168fe3';
58
+ const isValidColor = /^#[0-9A-F]{6}$/i.test(colorValue) || /^(rgb|hsl)a?\(\s*([+-]?\d+%?\s*,\s*){2,3}[+-]?\d+%?\s*\)$/i.test(colorValue);
59
+ const safeColorValue = isValidColor ? colorValue : '#168fe3';
54
60
  para.innerHTML =
55
61
  i18n('schemas.mvt.typingInstructions') +
56
- ` <code style="color:${options?.theme?.token?.colorPrimary || '#168fe3'}; font-weight:bold;">{` +
62
+ ` <code style="color:${safeColorValue}; font-weight:bold;">{` +
57
63
  i18n('schemas.mvt.sampleField') +
58
64
  '}</code>';
59
65
  rootElement.appendChild(para);
@@ -63,13 +69,15 @@ const mapDynamicVariables = (props: PropPanelWidgetProps) => {
63
69
  export const propPanel: PropPanel<MultiVariableTextSchema> = {
64
70
  schema: (propPanelProps: Omit<PropPanelWidgetProps, 'rootElement'>) => {
65
71
  if (typeof parentPropPanel.schema !== 'function') {
66
- throw Error('Oops, is text schema no longer a function?');
72
+ throw new Error('Oops, is text schema no longer a function?');
67
73
  }
74
+ // Safely call schema function with proper type handling
75
+ const parentSchema = parentPropPanel.schema?.(propPanelProps) || {};
68
76
  return {
69
- ...parentPropPanel.schema(propPanelProps),
77
+ ...parentSchema,
70
78
  '-------': { type: 'void', widget: 'Divider' },
71
79
  dynamicVarContainer: {
72
- title: propPanelProps.i18n('schemas.mvt.variablesSampleData'),
80
+ title: typeof propPanelProps.i18n === 'function' ? propPanelProps.i18n('schemas.mvt.variablesSampleData') : 'Variables Sample Data',
73
81
  type: 'string',
74
82
  widget: 'Card',
75
83
  span: 24,
@@ -97,7 +105,7 @@ export const propPanel: PropPanel<MultiVariableTextSchema> = {
97
105
  },
98
106
  };
99
107
  },
100
- widgets: { ...parentPropPanel.widgets, mapDynamicVariables },
108
+ widgets: { ...(parentPropPanel.widgets || {}), mapDynamicVariables },
101
109
  defaultSchema: {
102
110
  ...parentPropPanel.defaultSchema,
103
111
  readOnly: false,
@@ -110,7 +118,7 @@ export const propPanel: PropPanel<MultiVariableTextSchema> = {
110
118
  },
111
119
  };
112
120
 
113
- const updateVariablesFromText = (text: string, variables: any): boolean => {
121
+ const updateVariablesFromText = (text: string, variables: Record<string, string>): boolean => {
114
122
  const regex = /\{([^{}]+)}/g;
115
123
  const matches = text.match(regex);
116
124
  let changed = false;
@@ -23,16 +23,17 @@ export const uiRender = async (arg: UIRenderProps<MultiVariableTextSchema>) => {
23
23
  await parentUiRender({
24
24
  value: isEditable(mode, schema) ? text : substituteVariables(text, value),
25
25
  schema,
26
- mode: mode == 'form' ? 'viewer' : mode, // if no variables for form it's just a viewer
26
+ mode: mode === 'form' ? 'viewer' : mode, // if no variables for form it's just a viewer
27
27
  rootElement,
28
- onChange: (arg: { key: string; value: any } | { key: string; value: any }[]) => {
28
+ onChange: (arg: { key: string; value: string } | { key: string; value: string }[]) => {
29
29
  if (!Array.isArray(arg)) {
30
30
  const numVariables = countUniqueVariableNames(arg.value);
31
- onChange &&
31
+ if (onChange) {
32
32
  onChange([
33
33
  { key: 'text', value: arg.value },
34
- { key: 'readOnly', value: numVariables == 0 },
34
+ { key: 'readOnly', value: numVariables === 0 },
35
35
  ]);
36
+ }
36
37
  } else {
37
38
  throw new Error('onChange is not an array, the parent text plugin has changed...');
38
39
  }
@@ -40,7 +41,7 @@ export const uiRender = async (arg: UIRenderProps<MultiVariableTextSchema>) => {
40
41
  ...rest,
41
42
  });
42
43
 
43
- const textBlock = rootElement.querySelector('#text-' + schema.id) as HTMLDivElement;
44
+ const textBlock = rootElement.querySelector('#text-' + String(schema.id)) as HTMLDivElement;
44
45
  if (!textBlock) {
45
46
  throw new Error('Text block not found. Ensure the text block has an id of "text-" + schema.id');
46
47
  }
@@ -55,7 +56,7 @@ export const uiRender = async (arg: UIRenderProps<MultiVariableTextSchema>) => {
55
56
  if (onChange) {
56
57
  onChange([
57
58
  { key: 'text', value: text },
58
- { key: 'readOnly', value: newNumVariables == 0 },
59
+ { key: 'readOnly', value: newNumVariables === 0 },
59
60
  ]);
60
61
  }
61
62
  numVariables = newNumVariables;
@@ -74,11 +75,11 @@ const formUiRender = async (arg: UIRenderProps<MultiVariableTextSchema>) => {
74
75
  rootElement.parentElement.style.outline = '';
75
76
  }
76
77
 
77
- const variables: Record<string, string> = value ? JSON.parse(value) || {} : {};
78
+ const variables: Record<string, string> = value ? JSON.parse(value) as Record<string, string> || {} : {};
78
79
  const variableIndices = getVariableIndices(rawText);
79
80
  const substitutedText = substituteVariables(rawText, variables);
80
81
  const font = options?.font || getDefaultFont();
81
- const fontKitFont = await getFontKitFont(schema.fontName, font, _cache);
82
+ const fontKitFont = await getFontKitFont(schema.fontName, font, _cache as Map<string, import('fontkit').Font>);
82
83
 
83
84
  const textBlock = buildStyledTextContainer(arg, fontKitFont, substitutedText);
84
85
 
@@ -96,8 +97,8 @@ const formUiRender = async (arg: UIRenderProps<MultiVariableTextSchema>) => {
96
97
  const newValue = (e.target as HTMLSpanElement).textContent || '';
97
98
  if (newValue !== variables[variableIndices[i]]) {
98
99
  variables[variableIndices[i]] = newValue;
99
- onChange && onChange({ key: 'content', value: JSON.stringify(variables) });
100
- stopEditing && stopEditing();
100
+ if (onChange) onChange({ key: 'content', value: JSON.stringify(variables) });
101
+ if (stopEditing) stopEditing();
101
102
  }
102
103
  });
103
104
  textBlock.appendChild(span);
@@ -145,10 +146,10 @@ const countUniqueVariableNames = (content: string) => {
145
146
  */
146
147
  const keyPressShouldBeChecked = (event: KeyboardEvent) => {
147
148
  if (
148
- event.key == 'ArrowUp' ||
149
- event.key == 'ArrowDown' ||
150
- event.key == 'ArrowLeft' ||
151
- event.key == 'ArrowRight'
149
+ event.key === 'ArrowUp' ||
150
+ event.key === 'ArrowDown' ||
151
+ event.key === 'ArrowLeft' ||
152
+ event.key === 'ArrowRight'
152
153
  ) {
153
154
  return false;
154
155
  }
@@ -150,7 +150,7 @@ const schema: Plugin<Select> = {
150
150
 
151
151
  selectElement.addEventListener('change', (e) => {
152
152
  if (onChange && e.target instanceof HTMLSelectElement) {
153
- onChange && onChange({ key: 'content', value: e.target.value });
153
+ if (onChange) onChange({ key: 'content', value: e.target.value });
154
154
  }
155
155
  });
156
156
 
@@ -114,7 +114,7 @@ export class Table {
114
114
  input: TableInput;
115
115
  content: ContentSettings;
116
116
  font: Font;
117
- _cache: Map<any, any>;
117
+ _cache: Map<string, FontKitFont>;
118
118
  }) {
119
119
  const { input, content, font, _cache } = arg;
120
120
  const table = new Table(input, content);
@@ -145,7 +145,7 @@ export class Table {
145
145
  }
146
146
  }
147
147
 
148
- async function calculateWidths(arg: { table: Table; font: Font; _cache: Map<any, any> }) {
148
+ async function calculateWidths(arg: { table: Table; font: Font; _cache: Map<string, FontKitFont> }) {
149
149
  const { table, font, _cache } = arg;
150
150
 
151
151
  const getFontKitFontByFontName = (fontName: string | undefined) =>
@@ -9,7 +9,7 @@ export const getDynamicHeightsForTable = async (
9
9
  schema: Schema;
10
10
  basePdf: BasePdf;
11
11
  options: CommonOptions;
12
- _cache: Map<any, any>;
12
+ _cache: Map<string, unknown>;
13
13
  },
14
14
  ): Promise<number[]> => {
15
15
  if (args.schema.type !== 'table') return Promise.resolve([args.schema.height]);
@@ -10,7 +10,7 @@ import { HEX_COLOR_PATTERN } from '../constants.js';
10
10
 
11
11
  export const propPanel: PropPanel<TableSchema> = {
12
12
  schema: ({ activeSchema, options, i18n }) => {
13
- // @ts-expect-error
13
+ // @ts-expect-error Type casting is necessary here as the activeSchema type is generic
14
14
  const tableSchema = activeSchema as TableSchema;
15
15
  const head = tableSchema.head || [];
16
16
  const showHead = tableSchema.showHead || false;
@@ -7,6 +7,7 @@ import {
7
7
  getFallbackFontName,
8
8
  cloneDeep,
9
9
  } from '@pdfme/common';
10
+ import type { Font as FontKitFont } from 'fontkit';
10
11
  import type {
11
12
  TableSchema,
12
13
  CellStyle,
@@ -24,7 +25,7 @@ interface CreateTableArgs {
24
25
  schema: Schema;
25
26
  basePdf: BasePdf;
26
27
  options: CommonOptions;
27
- _cache: Map<any, any>;
28
+ _cache: Map<string, unknown>;
28
29
  }
29
30
 
30
31
  interface UserOptions {
@@ -278,5 +279,5 @@ export function createSingleTable(body: string[][], args: CreateTableArgs) {
278
279
 
279
280
  const content = parseContent4Table(input, fallbackFontName);
280
281
 
281
- return Table.create({ input, content, font, _cache });
282
+ return Table.create({ input, content, font, _cache: _cache as Map<string, FontKitFont> });
282
283
  }
@@ -250,7 +250,7 @@ export const uiRender = async (arg: UIRenderProps<TableSchema>) => {
250
250
  text: '+',
251
251
  onClick: () => {
252
252
  const newRow = Array(schema.head.length).fill('') as string[];
253
- onChange && onChange({ key: 'content', value: JSON.stringify(body.concat([newRow])) });
253
+ if (onChange) onChange({ key: 'content', value: JSON.stringify(body.concat([newRow])) });
254
254
  },
255
255
  });
256
256
 
@@ -266,7 +266,7 @@ export const uiRender = async (arg: UIRenderProps<TableSchema>) => {
266
266
  text: '-',
267
267
  onClick: () => {
268
268
  const newTableBody = body.filter((_, j) => j !== i + (schema.__bodyRange?.start ?? 0));
269
- onChange && onChange({ key: 'content', value: JSON.stringify(newTableBody) });
269
+ if (onChange) onChange({ key: 'content', value: JSON.stringify(newTableBody) });
270
270
  },
271
271
  });
272
272
  return removeRowButton;
@@ -1,4 +1,4 @@
1
- import { Dict } from '@pdfme/common';
1
+ // No imports needed from @pdfme/common
2
2
  import {
3
3
  TextAlignCenterIcon,
4
4
  TextAlignLeftIcon,
@@ -42,7 +42,7 @@ interface GroupButtonString {
42
42
 
43
43
  type GroupButton = GroupButtonBoolean | GroupButtonString;
44
44
 
45
- export function getExtraFormatterSchema(i18n: (key: keyof Dict | string) => string): {
45
+ export function getExtraFormatterSchema(i18n: (key: string) => string): {
46
46
  title: string;
47
47
  widget: string;
48
48
  buttons: GroupButton[];
@@ -112,7 +112,7 @@ const getCacheKey = (fontName: string) => `getFontKitFont-${fontName}`;
112
112
  export const getFontKitFont = async (
113
113
  fontName: string | undefined,
114
114
  font: Font,
115
- _cache: Map<any, any>,
115
+ _cache: Map<string, fontkit.Font>,
116
116
  ) => {
117
117
  const fntNm = fontName || getFallbackFontName(font);
118
118
  const cacheKey = getCacheKey(fntNm);
@@ -128,9 +128,14 @@ export const getFontKitFont = async (
128
128
  : b64toUint8Array(fontData);
129
129
  }
130
130
 
131
- const fontKitFont = fontkit.create(
132
- fontData instanceof Buffer ? fontData : Buffer.from(fontData as ArrayBuffer),
133
- ) as fontkit.Font;
131
+ // Convert fontData to Buffer if it's not already a Buffer
132
+ let fontDataBuffer: Buffer;
133
+ if (fontData instanceof Buffer) {
134
+ fontDataBuffer = fontData;
135
+ } else {
136
+ fontDataBuffer = Buffer.from(fontData as ArrayBufferLike);
137
+ }
138
+ const fontKitFont = fontkit.create(fontDataBuffer) as fontkit.Font;
134
139
  _cache.set(cacheKey, fontKitFont);
135
140
 
136
141
  return fontKitFont;
@@ -489,7 +494,11 @@ export const filterStartJP = (lines: string[]): string[] => {
489
494
  });
490
495
 
491
496
  if (charToAppend) {
492
- return [charToAppend + filtered.slice(0, 1)[0], ...filtered.slice(1)].reverse();
497
+ // Handle the case where filtered might be empty
498
+ const firstItem = filtered.length > 0 ? filtered[0] : '';
499
+ // Ensure we're concatenating strings
500
+ const combinedItem = String(charToAppend) + String(firstItem);
501
+ return [combinedItem, ...filtered.slice(1)].reverse();
493
502
  } else {
494
503
  return filtered.reverse();
495
504
  }
@@ -530,7 +539,11 @@ export const filterEndJP = (lines: string[]): string[] => {
530
539
  });
531
540
 
532
541
  if (charToPrepend) {
533
- return [...filtered.slice(0, -1), filtered.slice(-1)[0] + charToPrepend];
542
+ // Handle the case where filtered might be empty
543
+ const lastItem = filtered.length > 0 ? filtered[filtered.length - 1] : '';
544
+ // Ensure we're concatenating strings
545
+ const combinedItem = String(lastItem) + String(charToPrepend);
546
+ return [...filtered.slice(0, -1), combinedItem];
534
547
  } else {
535
548
  return filtered;
536
549
  }