@pdfme/schemas 5.3.8-dev.4 → 5.3.8-dev.42
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/cjs/__tests__/barcode.test.js +115 -116
- package/dist/cjs/__tests__/barcode.test.js.map +1 -1
- package/dist/cjs/__tests__/multiVariableText.test.js +15 -15
- package/dist/cjs/__tests__/multiVariableText.test.js.map +1 -1
- package/dist/cjs/__tests__/text.test.js +71 -71
- package/dist/cjs/__tests__/text.test.js.map +1 -1
- package/dist/cjs/__tests__/utils.test.js +76 -15
- package/dist/cjs/__tests__/utils.test.js.map +1 -1
- package/dist/cjs/src/checkbox/index.js +3 -3
- package/dist/cjs/src/checkbox/index.js.map +1 -1
- package/dist/cjs/src/date/date.js +2 -2
- package/dist/cjs/src/date/date.js.map +1 -1
- package/dist/cjs/src/date/dateTime.js +2 -2
- package/dist/cjs/src/date/dateTime.js.map +1 -1
- package/dist/cjs/src/date/helper.js +11 -11
- package/dist/cjs/src/date/helper.js.map +1 -1
- package/dist/cjs/src/date/time.js +2 -2
- package/dist/cjs/src/date/time.js.map +1 -1
- package/dist/cjs/src/graphics/svg.js +25 -2
- package/dist/cjs/src/graphics/svg.js.map +1 -1
- package/dist/cjs/src/index.js +30 -30
- package/dist/cjs/src/index.js.map +1 -1
- package/dist/cjs/src/multiVariableText/helper.js +2 -2
- package/dist/cjs/src/multiVariableText/helper.js.map +1 -1
- package/dist/cjs/src/multiVariableText/pdfRender.js +5 -5
- package/dist/cjs/src/multiVariableText/pdfRender.js.map +1 -1
- package/dist/cjs/src/multiVariableText/propPanel.js +5 -5
- package/dist/cjs/src/multiVariableText/propPanel.js.map +1 -1
- package/dist/cjs/src/multiVariableText/uiRender.js +10 -10
- package/dist/cjs/src/multiVariableText/uiRender.js.map +1 -1
- package/dist/cjs/src/radioGroup/index.js +3 -3
- package/dist/cjs/src/radioGroup/index.js.map +1 -1
- package/dist/cjs/src/select/index.js +9 -9
- package/dist/cjs/src/select/index.js.map +1 -1
- package/dist/cjs/src/tables/classes.js +4 -4
- package/dist/cjs/src/tables/classes.js.map +1 -1
- package/dist/cjs/src/tables/dynamicTemplate.js +2 -2
- package/dist/cjs/src/tables/dynamicTemplate.js.map +1 -1
- package/dist/cjs/src/tables/helper.js +21 -21
- package/dist/cjs/src/tables/helper.js.map +1 -1
- package/dist/cjs/src/tables/pdfRender.js +8 -8
- package/dist/cjs/src/tables/pdfRender.js.map +1 -1
- package/dist/cjs/src/tables/tableHelper.js +5 -5
- package/dist/cjs/src/tables/tableHelper.js.map +1 -1
- package/dist/cjs/src/text/extraFormatter.js +14 -14
- package/dist/cjs/src/text/extraFormatter.js.map +1 -1
- package/dist/cjs/src/text/propPanel.js +2 -2
- package/dist/cjs/src/text/propPanel.js.map +1 -1
- package/dist/cjs/src/utils.js +53 -9
- package/dist/cjs/src/utils.js.map +1 -1
- package/dist/esm/__tests__/barcode.test.js +10 -11
- package/dist/esm/__tests__/barcode.test.js.map +1 -1
- package/dist/esm/__tests__/multiVariableText.test.js +1 -1
- package/dist/esm/__tests__/multiVariableText.test.js.map +1 -1
- package/dist/esm/__tests__/text.test.js +2 -2
- package/dist/esm/__tests__/text.test.js.map +1 -1
- package/dist/esm/__tests__/utils.test.js +65 -4
- package/dist/esm/__tests__/utils.test.js.map +1 -1
- package/dist/esm/src/checkbox/index.js +1 -1
- package/dist/esm/src/checkbox/index.js.map +1 -1
- package/dist/esm/src/date/date.js +1 -1
- package/dist/esm/src/date/date.js.map +1 -1
- package/dist/esm/src/date/dateTime.js +1 -1
- package/dist/esm/src/date/dateTime.js.map +1 -1
- package/dist/esm/src/date/helper.js +4 -4
- package/dist/esm/src/date/helper.js.map +1 -1
- package/dist/esm/src/date/time.js +1 -1
- package/dist/esm/src/date/time.js.map +1 -1
- package/dist/esm/src/graphics/svg.js +25 -2
- package/dist/esm/src/graphics/svg.js.map +1 -1
- package/dist/esm/src/index.js +14 -14
- package/dist/esm/src/index.js.map +1 -1
- package/dist/esm/src/multiVariableText/helper.js +2 -2
- package/dist/esm/src/multiVariableText/helper.js.map +1 -1
- package/dist/esm/src/multiVariableText/pdfRender.js +2 -2
- package/dist/esm/src/multiVariableText/pdfRender.js.map +1 -1
- package/dist/esm/src/multiVariableText/propPanel.js +1 -1
- package/dist/esm/src/multiVariableText/propPanel.js.map +1 -1
- package/dist/esm/src/multiVariableText/uiRender.js +4 -4
- package/dist/esm/src/multiVariableText/uiRender.js.map +1 -1
- package/dist/esm/src/radioGroup/index.js +1 -1
- package/dist/esm/src/radioGroup/index.js.map +1 -1
- package/dist/esm/src/select/index.js +2 -2
- package/dist/esm/src/select/index.js.map +1 -1
- package/dist/esm/src/tables/classes.js +1 -1
- package/dist/esm/src/tables/classes.js.map +1 -1
- package/dist/esm/src/tables/dynamicTemplate.js +1 -1
- package/dist/esm/src/tables/dynamicTemplate.js.map +1 -1
- package/dist/esm/src/tables/helper.js +1 -1
- package/dist/esm/src/tables/helper.js.map +1 -1
- package/dist/esm/src/tables/pdfRender.js +4 -4
- package/dist/esm/src/tables/pdfRender.js.map +1 -1
- package/dist/esm/src/tables/tableHelper.js +1 -1
- package/dist/esm/src/tables/tableHelper.js.map +1 -1
- package/dist/esm/src/text/extraFormatter.js +2 -2
- package/dist/esm/src/text/extraFormatter.js.map +1 -1
- package/dist/esm/src/text/propPanel.js +1 -1
- package/dist/esm/src/text/propPanel.js.map +1 -1
- package/dist/esm/src/utils.js +53 -9
- package/dist/esm/src/utils.js.map +1 -1
- package/dist/node/__tests__/barcode.test.js +115 -116
- package/dist/node/__tests__/barcode.test.js.map +1 -1
- package/dist/node/__tests__/multiVariableText.test.js +15 -15
- package/dist/node/__tests__/multiVariableText.test.js.map +1 -1
- package/dist/node/__tests__/text.test.js +71 -71
- package/dist/node/__tests__/text.test.js.map +1 -1
- package/dist/node/__tests__/utils.test.js +76 -15
- package/dist/node/__tests__/utils.test.js.map +1 -1
- package/dist/node/src/checkbox/index.js +3 -3
- package/dist/node/src/checkbox/index.js.map +1 -1
- package/dist/node/src/date/date.js +2 -2
- package/dist/node/src/date/date.js.map +1 -1
- package/dist/node/src/date/dateTime.js +2 -2
- package/dist/node/src/date/dateTime.js.map +1 -1
- package/dist/node/src/date/helper.js +11 -11
- package/dist/node/src/date/helper.js.map +1 -1
- package/dist/node/src/date/time.js +2 -2
- package/dist/node/src/date/time.js.map +1 -1
- package/dist/node/src/graphics/svg.js +25 -2
- package/dist/node/src/graphics/svg.js.map +1 -1
- package/dist/node/src/index.js +30 -30
- package/dist/node/src/index.js.map +1 -1
- package/dist/node/src/multiVariableText/helper.js +2 -2
- package/dist/node/src/multiVariableText/helper.js.map +1 -1
- package/dist/node/src/multiVariableText/pdfRender.js +5 -5
- package/dist/node/src/multiVariableText/pdfRender.js.map +1 -1
- package/dist/node/src/multiVariableText/propPanel.js +5 -5
- package/dist/node/src/multiVariableText/propPanel.js.map +1 -1
- package/dist/node/src/multiVariableText/uiRender.js +10 -10
- package/dist/node/src/multiVariableText/uiRender.js.map +1 -1
- package/dist/node/src/radioGroup/index.js +3 -3
- package/dist/node/src/radioGroup/index.js.map +1 -1
- package/dist/node/src/select/index.js +9 -9
- package/dist/node/src/select/index.js.map +1 -1
- package/dist/node/src/tables/classes.js +4 -4
- package/dist/node/src/tables/classes.js.map +1 -1
- package/dist/node/src/tables/dynamicTemplate.js +2 -2
- package/dist/node/src/tables/dynamicTemplate.js.map +1 -1
- package/dist/node/src/tables/helper.js +21 -21
- package/dist/node/src/tables/helper.js.map +1 -1
- package/dist/node/src/tables/pdfRender.js +8 -8
- package/dist/node/src/tables/pdfRender.js.map +1 -1
- package/dist/node/src/tables/tableHelper.js +5 -5
- package/dist/node/src/tables/tableHelper.js.map +1 -1
- package/dist/node/src/text/extraFormatter.js +14 -14
- package/dist/node/src/text/extraFormatter.js.map +1 -1
- package/dist/node/src/text/propPanel.js +2 -2
- package/dist/node/src/text/propPanel.js.map +1 -1
- package/dist/node/src/utils.js +53 -9
- package/dist/node/src/utils.js.map +1 -1
- package/dist/types/src/barcodes/helper.d.ts +1 -1
- package/dist/types/src/barcodes/index.d.ts +1 -1
- package/dist/types/src/barcodes/pdfRender.d.ts +1 -1
- package/dist/types/src/barcodes/propPanel.d.ts +1 -1
- package/dist/types/src/barcodes/uiRender.d.ts +1 -1
- package/dist/types/src/date/date.d.ts +1 -1
- package/dist/types/src/date/dateTime.d.ts +1 -1
- package/dist/types/src/date/helper.d.ts +1 -1
- package/dist/types/src/date/time.d.ts +1 -1
- package/dist/types/src/date/types.d.ts +6 -1
- package/dist/types/src/index.d.ts +15 -15
- package/dist/types/src/multiVariableText/helper.d.ts +1 -1
- package/dist/types/src/multiVariableText/index.d.ts +1 -1
- package/dist/types/src/multiVariableText/pdfRender.d.ts +1 -1
- package/dist/types/src/multiVariableText/propPanel.d.ts +1 -1
- package/dist/types/src/multiVariableText/types.d.ts +1 -1
- package/dist/types/src/multiVariableText/uiRender.d.ts +1 -1
- package/dist/types/src/select/index.d.ts +1 -1
- package/dist/types/src/tables/cell.d.ts +1 -1
- package/dist/types/src/tables/classes.d.ts +1 -1
- package/dist/types/src/tables/helper.d.ts +4 -4
- package/dist/types/src/tables/pdfRender.d.ts +1 -1
- package/dist/types/src/tables/propPanel.d.ts +1 -1
- package/dist/types/src/tables/tableHelper.d.ts +1 -1
- package/dist/types/src/tables/types.d.ts +1 -1
- package/dist/types/src/text/constants.d.ts +1 -1
- package/dist/types/src/text/helper.d.ts +1 -1
- package/dist/types/src/text/index.d.ts +1 -1
- package/dist/types/src/text/pdfRender.d.ts +1 -1
- package/dist/types/src/text/propPanel.d.ts +1 -1
- package/dist/types/src/text/uiRender.d.ts +1 -1
- package/eslint.config.mjs +22 -0
- package/package.json +3 -4
- package/src/barcodes/helper.ts +1 -1
- package/src/barcodes/index.ts +1 -1
- package/src/barcodes/pdfRender.ts +1 -1
- package/src/barcodes/propPanel.ts +1 -1
- package/src/barcodes/uiRender.ts +1 -1
- package/src/checkbox/index.ts +1 -1
- package/src/date/date.ts +1 -1
- package/src/date/dateTime.ts +1 -1
- package/src/date/helper.ts +17 -10
- package/src/date/time.ts +1 -1
- package/src/date/types.ts +7 -1
- package/src/graphics/svg.ts +27 -2
- package/src/index.ts +14 -14
- package/src/multiVariableText/helper.ts +15 -7
- package/src/multiVariableText/index.ts +1 -1
- package/src/multiVariableText/pdfRender.ts +3 -3
- package/src/multiVariableText/propPanel.ts +2 -2
- package/src/multiVariableText/types.ts +1 -1
- package/src/multiVariableText/uiRender.ts +5 -5
- package/src/radioGroup/index.ts +1 -1
- package/src/select/index.ts +3 -3
- package/src/tables/cell.ts +1 -1
- package/src/tables/classes.ts +2 -2
- package/src/tables/dynamicTemplate.ts +2 -2
- package/src/tables/helper.ts +1 -1
- package/src/tables/pdfRender.ts +6 -6
- package/src/tables/propPanel.ts +1 -1
- package/src/tables/tableHelper.ts +2 -2
- package/src/tables/types.ts +1 -1
- package/src/tables/uiRender.ts +1 -1
- package/src/text/constants.ts +1 -1
- package/src/text/extraFormatter.ts +2 -2
- package/src/text/helper.ts +1 -1
- package/src/text/index.ts +1 -1
- package/src/text/pdfRender.ts +1 -1
- package/src/text/propPanel.ts +2 -2
- package/src/text/uiRender.ts +1 -1
- package/src/utils.ts +64 -15
- package/tsconfig.esm.json +2 -1
- package/.eslintrc.cjs +0 -3
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@pdfme/schemas",
|
3
|
-
"version": "5.3.8-dev.
|
3
|
+
"version": "5.3.8-dev.42",
|
4
4
|
"sideEffects": false,
|
5
5
|
"author": "hand-dot",
|
6
6
|
"license": "MIT",
|
@@ -49,7 +49,7 @@
|
|
49
49
|
"build:esm": "tsc -p tsconfig.esm.json",
|
50
50
|
"build:node": "tsc -p tsconfig.node.json",
|
51
51
|
"clean": "rimraf dist",
|
52
|
-
"lint": "eslint --ext .ts src",
|
52
|
+
"lint": "eslint --ext .ts src --config eslint.config.mjs --no-error-on-unmatched-pattern",
|
53
53
|
"test": "jest",
|
54
54
|
"prune": "ts-prune src",
|
55
55
|
"prettier": "prettier --write 'src/**/*.ts'"
|
@@ -59,9 +59,8 @@
|
|
59
59
|
"air-datepicker": "^3.5.3",
|
60
60
|
"bwip-js": "^4.1.1",
|
61
61
|
"date-fns": "^4.1.0",
|
62
|
-
"fast-xml-parser": "^4.3.2",
|
63
62
|
"fontkit": "^2.0.2",
|
64
|
-
"lucide": "^0.
|
63
|
+
"lucide": "^0.476.0"
|
65
64
|
},
|
66
65
|
"devDependencies": {
|
67
66
|
"@pdfme/common": "file:../common",
|
package/src/barcodes/helper.ts
CHANGED
@@ -2,7 +2,7 @@ import { b64toUint8Array } from '@pdfme/common';
|
|
2
2
|
import bwipjs, { RenderOptions } from 'bwip-js';
|
3
3
|
import { Buffer } from 'buffer';
|
4
4
|
import { BARCODE_TYPES, DEFAULT_BARCODE_INCLUDETEXT } from './constants.js';
|
5
|
-
import { BarcodeTypes } from './types';
|
5
|
+
import { BarcodeTypes } from './types.js';
|
6
6
|
|
7
7
|
// GTIN-13, GTIN-8, GTIN-12, GTIN-14
|
8
8
|
const validateCheckDigit = (input: string, checkDigitPos: number) => {
|
package/src/barcodes/index.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { pdfRender } from './pdfRender.js';
|
2
2
|
import { getPropPanelByBarcodeType } from './propPanel.js';
|
3
3
|
import { uiRender } from './uiRender.js';
|
4
|
-
import type { BarcodeSchema, BarcodeTypes } from './types';
|
4
|
+
import type { BarcodeSchema, BarcodeTypes } from './types.js';
|
5
5
|
import { BARCODE_TYPES } from './constants.js';
|
6
6
|
import { createSvgStr } from '../utils.js';
|
7
7
|
import { Plugin } from '@pdfme/common';
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { PDFRenderProps } from '@pdfme/common';
|
2
2
|
import { convertForPdfLayoutProps } from '../utils.js';
|
3
|
-
import type { BarcodeSchema } from './types';
|
3
|
+
import type { BarcodeSchema } from './types.js';
|
4
4
|
import { createBarCode, validateBarcodeInput } from './helper.js';
|
5
5
|
|
6
6
|
const getBarcodeCacheKey = (schema: BarcodeSchema, value: string) => {
|
package/src/barcodes/uiRender.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import type * as CSS from 'csstype';
|
2
2
|
import { UIRenderProps } from '@pdfme/common';
|
3
|
-
import type { BarcodeSchema } from './types';
|
3
|
+
import type { BarcodeSchema } from './types.js';
|
4
4
|
import { validateBarcodeInput, createBarCode } from './helper.js';
|
5
5
|
import { addAlphaToHex, isEditable, createErrorElm } from '../utils.js';
|
6
6
|
|
package/src/checkbox/index.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { Plugin } from '@pdfme/common';
|
2
2
|
import { Schema } from '@pdfme/common';
|
3
|
-
import svg from '../graphics/svg';
|
3
|
+
import svg from '../graphics/svg.js';
|
4
4
|
import { isEditable } from '../utils.js';
|
5
5
|
import { HEX_COLOR_PATTERN } from '../constants.js';
|
6
6
|
import { Square, SquareCheck } from 'lucide';
|
package/src/date/date.ts
CHANGED
package/src/date/dateTime.ts
CHANGED
package/src/date/helper.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import type * as CSS from 'csstype';
|
2
2
|
|
3
3
|
import AirDatepicker from 'air-datepicker';
|
4
|
-
import type { AirDatepickerLocale, AirDatepickerButton } from 'air-datepicker';
|
4
|
+
import type { AirDatepickerLocale, AirDatepickerButton, AirDatepickerDate } from 'air-datepicker';
|
5
5
|
import localeAr from 'air-datepicker/locale/ar';
|
6
6
|
import localeBg from 'air-datepicker/locale/bg';
|
7
7
|
import localeCa from 'air-datepicker/locale/ca';
|
@@ -40,9 +40,9 @@ import * as dateFns from 'date-fns/locale';
|
|
40
40
|
import { format } from 'date-fns';
|
41
41
|
|
42
42
|
import { Plugin, getFallbackFontName, DEFAULT_FONT_NAME, PropPanelSchema } from '@pdfme/common';
|
43
|
-
import text from '../text';
|
43
|
+
import text from '../text/index.js';
|
44
44
|
import { DEFAULT_OPACITY, HEX_COLOR_PATTERN } from '../constants.js';
|
45
|
-
import { mapVerticalAlignToFlex } from '../text/uiRender';
|
45
|
+
import { mapVerticalAlignToFlex } from '../text/uiRender.js';
|
46
46
|
import {
|
47
47
|
DEFAULT_FONT_SIZE,
|
48
48
|
DEFAULT_ALIGNMENT,
|
@@ -51,9 +51,16 @@ import {
|
|
51
51
|
DEFAULT_CHARACTER_SPACING,
|
52
52
|
DEFAULT_FONT_COLOR,
|
53
53
|
} from '../text/constants.js';
|
54
|
-
import { DateSchema } from './types';
|
55
|
-
import { getExtraFormatterSchema, Formatter } from '../text/extraFormatter';
|
56
|
-
import { isEditable } from '../utils';
|
54
|
+
import { DateSchema } from './types.js';
|
55
|
+
import { getExtraFormatterSchema, Formatter } from '../text/extraFormatter.js';
|
56
|
+
import { isEditable } from '../utils.js';
|
57
|
+
|
58
|
+
interface AirDatepickerInstance {
|
59
|
+
selectedDates: Date[];
|
60
|
+
hide: () => void;
|
61
|
+
destroy: () => void;
|
62
|
+
show: () => void;
|
63
|
+
}
|
57
64
|
|
58
65
|
type PickerType = 'date' | 'time' | 'dateTime';
|
59
66
|
|
@@ -259,16 +266,16 @@ export const getPlugin = ({ type, icon }: { type: PickerType; icon: string }) =>
|
|
259
266
|
},
|
260
267
|
});
|
261
268
|
}
|
262
|
-
|
263
269
|
const airDatepicker = new AirDatepicker(input, {
|
264
270
|
locale: locale.adLocale,
|
265
271
|
selectedDates: [strDateToDate(value, type)],
|
266
|
-
dateFormat: (date) =>
|
272
|
+
dateFormat: (date: AirDatepickerDate) =>
|
273
|
+
format(date, schema.format, { locale: locale.formatLocale }),
|
267
274
|
timepicker: type !== 'date',
|
268
275
|
onlyTimepicker: type === 'time',
|
269
276
|
isMobile: window.innerWidth < 768,
|
270
277
|
buttons: adButtons,
|
271
|
-
onSelect: ({ datepicker }) => {
|
278
|
+
onSelect: ({ datepicker }: { datepicker: AirDatepickerInstance }) => {
|
272
279
|
if (type === 'date') {
|
273
280
|
commitChange(datepicker.selectedDates.length ? datepicker.selectedDates[0] : null);
|
274
281
|
datepicker.hide();
|
@@ -441,7 +448,7 @@ export const getPlugin = ({ type, icon }: { type: PickerType; icon: string }) =>
|
|
441
448
|
backgroundColor: '',
|
442
449
|
locale: undefined,
|
443
450
|
opacity: DEFAULT_OPACITY,
|
444
|
-
},
|
451
|
+
} as DateSchema,
|
445
452
|
},
|
446
453
|
icon,
|
447
454
|
};
|
package/src/date/time.ts
CHANGED
package/src/date/types.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { Schema } from '@pdfme/common';
|
2
|
-
import { ALIGNMENT } from '../text/types';
|
2
|
+
import { ALIGNMENT } from '../text/types.js';
|
3
3
|
|
4
4
|
export interface DateSchema extends Schema {
|
5
5
|
format: string;
|
@@ -10,4 +10,10 @@ export interface DateSchema extends Schema {
|
|
10
10
|
fontColor: string;
|
11
11
|
backgroundColor: string;
|
12
12
|
locale?: string;
|
13
|
+
// Explicitly include these properties from Schema for TypeScript
|
14
|
+
width: number;
|
15
|
+
height: number;
|
16
|
+
name: string;
|
17
|
+
type: string;
|
18
|
+
content?: string;
|
13
19
|
}
|
package/src/graphics/svg.ts
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
import { Plugin, Schema } from '@pdfme/common';
|
2
|
-
import { XMLValidator } from 'fast-xml-parser';
|
3
2
|
import {
|
4
3
|
convertForPdfLayoutProps,
|
5
4
|
isEditable,
|
@@ -9,7 +8,33 @@ import {
|
|
9
8
|
} from '../utils.js';
|
10
9
|
import { Route } from 'lucide';
|
11
10
|
|
12
|
-
const isValidSVG = (svgString: string) =>
|
11
|
+
const isValidSVG = (svgString: string): boolean => {
|
12
|
+
try {
|
13
|
+
// Basic validation checks that work in both Node.js and browser
|
14
|
+
if (!svgString || typeof svgString !== 'string') {
|
15
|
+
return false;
|
16
|
+
}
|
17
|
+
|
18
|
+
// Check for basic SVG structure
|
19
|
+
if (!svgString.includes('<svg') || !svgString.includes('</svg>')) {
|
20
|
+
return false;
|
21
|
+
}
|
22
|
+
|
23
|
+
// Additional browser-specific validation if DOMParser is available
|
24
|
+
if (typeof DOMParser !== 'undefined') {
|
25
|
+
const parser = new DOMParser();
|
26
|
+
const doc = parser.parseFromString(svgString, 'image/svg+xml');
|
27
|
+
const parserError = doc.querySelector('parsererror');
|
28
|
+
if (parserError !== null) {
|
29
|
+
return false;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
return true;
|
34
|
+
} catch (error) {
|
35
|
+
return false;
|
36
|
+
}
|
37
|
+
};
|
13
38
|
|
14
39
|
const defaultValue = `<svg viewBox="0 0 488 600" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
15
40
|
<g transform="matrix(1,0,0,1,-56,0)" fill="#000000" stroke="none">
|
package/src/index.ts
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
import multiVariableText from './multiVariableText/index';
|
2
|
-
import text from './text/index';
|
3
|
-
import image from './graphics/image';
|
4
|
-
import svg from './graphics/svg';
|
5
|
-
import barcodes from './barcodes/index';
|
6
|
-
import line from './shapes/line';
|
7
|
-
import table from './tables/index';
|
8
|
-
import { rectangle, ellipse } from './shapes/rectAndEllipse';
|
9
|
-
import dateTime from './date/dateTime';
|
10
|
-
import date from './date/date';
|
11
|
-
import time from './date/time';
|
12
|
-
import select from './select/index';
|
13
|
-
import radioGroup from './radioGroup/index';
|
14
|
-
import checkbox from './checkbox/index';
|
1
|
+
import multiVariableText from './multiVariableText/index.js';
|
2
|
+
import text from './text/index.js';
|
3
|
+
import image from './graphics/image.js';
|
4
|
+
import svg from './graphics/svg.js';
|
5
|
+
import barcodes from './barcodes/index.js';
|
6
|
+
import line from './shapes/line.js';
|
7
|
+
import table from './tables/index.js';
|
8
|
+
import { rectangle, ellipse } from './shapes/rectAndEllipse.js';
|
9
|
+
import dateTime from './date/dateTime.js';
|
10
|
+
import date from './date/date.js';
|
11
|
+
import time from './date/time.js';
|
12
|
+
import select from './select/index.js';
|
13
|
+
import radioGroup from './radioGroup/index.js';
|
14
|
+
import checkbox from './checkbox/index.js';
|
15
15
|
|
16
16
|
const builtInPlugins = { Text: text };
|
17
17
|
|
@@ -1,14 +1,18 @@
|
|
1
|
-
import { MultiVariableTextSchema } from
|
1
|
+
import { MultiVariableTextSchema } from './types.js';
|
2
2
|
|
3
|
-
export const substituteVariables = (
|
3
|
+
export const substituteVariables = (
|
4
|
+
text: string,
|
5
|
+
variablesIn: string | Record<string, string>
|
6
|
+
): string => {
|
4
7
|
if (!text) {
|
5
|
-
return
|
8
|
+
return '';
|
6
9
|
}
|
7
10
|
|
8
11
|
let substitutedText = text;
|
9
12
|
|
10
13
|
if (variablesIn) {
|
11
|
-
const variables: Record<string, string> =
|
14
|
+
const variables: Record<string, string> =
|
15
|
+
typeof variablesIn === 'string' ? JSON.parse(variablesIn) || {} : variablesIn;
|
12
16
|
|
13
17
|
Object.keys(variables).forEach((variableName) => {
|
14
18
|
// handle special characters in variable name
|
@@ -33,13 +37,17 @@ export const validateVariables = (value: string, schema: MultiVariableTextSchema
|
|
33
37
|
try {
|
34
38
|
values = value ? JSON.parse(value) : {};
|
35
39
|
} catch (e) {
|
36
|
-
throw new SyntaxError(
|
40
|
+
throw new SyntaxError(
|
41
|
+
`[@pdfme/generator] invalid JSON string '${value}' for variables in field ${schema.name}`
|
42
|
+
);
|
37
43
|
}
|
38
44
|
|
39
45
|
for (const variable of schema.variables) {
|
40
46
|
if (!values[variable]) {
|
41
47
|
if (schema.required) {
|
42
|
-
throw new Error(
|
48
|
+
throw new Error(
|
49
|
+
`[@pdfme/generator] variable ${variable} is missing for field ${schema.name}`
|
50
|
+
);
|
43
51
|
}
|
44
52
|
// If not required, then simply don't render this field if an input is missing
|
45
53
|
return false;
|
@@ -47,4 +55,4 @@ export const validateVariables = (value: string, schema: MultiVariableTextSchema
|
|
47
55
|
}
|
48
56
|
|
49
57
|
return true;
|
50
|
-
}
|
58
|
+
};
|
@@ -2,7 +2,7 @@ import type { Plugin } from '@pdfme/common';
|
|
2
2
|
import { pdfRender } from './pdfRender.js';
|
3
3
|
import { propPanel } from './propPanel.js';
|
4
4
|
import { uiRender } from './uiRender.js';
|
5
|
-
import type { MultiVariableTextSchema } from './types';
|
5
|
+
import type { MultiVariableTextSchema } from './types.js';
|
6
6
|
import { Type } from 'lucide';
|
7
7
|
import { createSvgStr } from '../utils.js';
|
8
8
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { PDFRenderProps } from '@pdfme/common';
|
2
|
-
import { MultiVariableTextSchema } from './types';
|
3
|
-
import { pdfRender as parentPdfRender } from '../text/pdfRender';
|
4
|
-
import { substituteVariables, validateVariables } from './helper';
|
2
|
+
import { MultiVariableTextSchema } from './types.js';
|
3
|
+
import { pdfRender as parentPdfRender } from '../text/pdfRender.js';
|
4
|
+
import { substituteVariables, validateVariables } from './helper.js';
|
5
5
|
|
6
6
|
export const pdfRender = async (arg: PDFRenderProps<MultiVariableTextSchema>) => {
|
7
7
|
const { value, schema, ...rest } = arg;
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { propPanel as parentPropPanel } from '../text/propPanel';
|
1
|
+
import { propPanel as parentPropPanel } from '../text/propPanel.js';
|
2
2
|
import { PropPanel, PropPanelWidgetProps } from '@pdfme/common';
|
3
|
-
import { MultiVariableTextSchema } from './types';
|
3
|
+
import { MultiVariableTextSchema } from './types.js';
|
4
4
|
|
5
5
|
const mapDynamicVariables = (props: PropPanelWidgetProps) => {
|
6
6
|
const { rootElement, changeSchemas, activeSchema, i18n, options } = props;
|
@@ -1,13 +1,13 @@
|
|
1
1
|
import { getDefaultFont, UIRenderProps } from '@pdfme/common';
|
2
|
-
import { MultiVariableTextSchema } from './types';
|
2
|
+
import { MultiVariableTextSchema } from './types.js';
|
3
3
|
import {
|
4
4
|
uiRender as parentUiRender,
|
5
5
|
buildStyledTextContainer,
|
6
6
|
makeElementPlainTextContentEditable
|
7
|
-
} from '../text/uiRender';
|
8
|
-
import { isEditable } from '../utils';
|
9
|
-
import { getFontKitFont } from '../text/helper';
|
10
|
-
import { substituteVariables } from './helper';
|
7
|
+
} from '../text/uiRender.js';
|
8
|
+
import { isEditable } from '../utils.js';
|
9
|
+
import { getFontKitFont } from '../text/helper.js';
|
10
|
+
import { substituteVariables } from './helper.js';
|
11
11
|
|
12
12
|
export const uiRender = async (arg: UIRenderProps<MultiVariableTextSchema>) => {
|
13
13
|
const { value, schema, rootElement, mode, onChange, ...rest } = arg;
|
package/src/radioGroup/index.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Plugin } from '@pdfme/common';
|
2
2
|
import { Schema } from '@pdfme/common';
|
3
3
|
import { Circle, CircleDot } from 'lucide';
|
4
|
-
import svg from '../graphics/svg';
|
4
|
+
import svg from '../graphics/svg.js';
|
5
5
|
import { isEditable, createSvgStr } from '../utils.js';
|
6
6
|
import { HEX_COLOR_PATTERN } from '../constants.js';
|
7
7
|
|
package/src/select/index.ts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
import type * as CSS from 'csstype';
|
2
|
-
import { propPanel as parentPropPanel } from '../text/propPanel';
|
2
|
+
import { propPanel as parentPropPanel } from '../text/propPanel.js';
|
3
3
|
import { Plugin, PropPanelWidgetProps, SchemaForUI } from '@pdfme/common';
|
4
|
-
import text from '../text';
|
5
|
-
import { TextSchema } from '../text/types';
|
4
|
+
import text from '../text/index.js';
|
5
|
+
import { TextSchema } from '../text/types.js';
|
6
6
|
import { ChevronDown } from 'lucide';
|
7
7
|
import { createSvgStr } from '../utils.js';
|
8
8
|
|
package/src/tables/cell.ts
CHANGED
@@ -9,7 +9,7 @@ import { uiRender as textUiRender } from '../text/uiRender.js';
|
|
9
9
|
import { pdfRender as textPdfRender } from '../text/pdfRender.js';
|
10
10
|
import line from '../shapes/line.js';
|
11
11
|
import { rectangle } from '../shapes/rectAndEllipse.js';
|
12
|
-
import type { CellSchema } from './types';
|
12
|
+
import type { CellSchema } from './types.js';
|
13
13
|
import { getCellPropPanelSchema, getDefaultCellStyles } from './helper.js';
|
14
14
|
const linePdfRender = line.pdf;
|
15
15
|
const rectanglePdfRender = rectangle.pdf;
|
package/src/tables/classes.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Font, mm2pt, pt2mm } from '@pdfme/common';
|
2
2
|
import type { Font as FontKitFont } from 'fontkit';
|
3
|
-
import { splitTextToSize, getFontKitFont, widthOfTextAtSize } from '../text/helper';
|
4
|
-
import type { Styles, TableInput, Settings, Section, StylesProps } from './types';
|
3
|
+
import { splitTextToSize, getFontKitFont, widthOfTextAtSize } from '../text/helper.js';
|
4
|
+
import type { Styles, TableInput, Settings, Section, StylesProps } from './types.js';
|
5
5
|
|
6
6
|
type ContentSettings = { body: Row[]; head: Row[]; columns: Column[] };
|
7
7
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Schema, BasePdf, CommonOptions } from '@pdfme/common';
|
2
|
-
import { createSingleTable } from './tableHelper';
|
2
|
+
import { createSingleTable } from './tableHelper.js';
|
3
3
|
import { getBodyWithRange, getBody } from './helper.js';
|
4
|
-
import { TableSchema } from './types';
|
4
|
+
import { TableSchema } from './types.js';
|
5
5
|
|
6
6
|
export const getDynamicHeightsForTable = async (
|
7
7
|
value: string,
|
package/src/tables/helper.ts
CHANGED
package/src/tables/pdfRender.ts
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
import type { TableSchema } from './types';
|
1
|
+
import type { TableSchema } from './types.js';
|
2
2
|
import type { PDFRenderProps } from '@pdfme/common';
|
3
|
-
import { Cell, Table, Row, Column } from './classes';
|
4
|
-
import { rectangle } from '../shapes/rectAndEllipse';
|
5
|
-
import cell from './cell';
|
6
|
-
import { getBodyWithRange } from './helper';
|
7
|
-
import { createSingleTable } from './tableHelper';
|
3
|
+
import { Cell, Table, Row, Column } from './classes.js';
|
4
|
+
import { rectangle } from '../shapes/rectAndEllipse.js';
|
5
|
+
import cell from './cell.js';
|
6
|
+
import { getBodyWithRange } from './helper.js';
|
7
|
+
import { createSingleTable } from './tableHelper.js';
|
8
8
|
|
9
9
|
type Pos = { x: number; y: number };
|
10
10
|
|
package/src/tables/propPanel.ts
CHANGED
@@ -15,8 +15,8 @@ import type {
|
|
15
15
|
TableInput,
|
16
16
|
StylesProps,
|
17
17
|
Section,
|
18
|
-
} from './types';
|
19
|
-
import { Cell, Column, Row, Table } from './classes';
|
18
|
+
} from './types.js';
|
19
|
+
import { Cell, Column, Row, Table } from './classes.js';
|
20
20
|
|
21
21
|
type StyleProp = 'styles' | 'headStyles' | 'bodyStyles' | 'alternateRowStyles' | 'columnStyles';
|
22
22
|
|
package/src/tables/types.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { ALIGNMENT, VERTICAL_ALIGNMENT } from '../text/types';
|
1
|
+
import type { ALIGNMENT, VERTICAL_ALIGNMENT } from '../text/types.js';
|
2
2
|
import type { Schema } from '@pdfme/common';
|
3
3
|
|
4
4
|
export type Spacing = { top: number; right: number; bottom: number; left: number };
|
package/src/tables/uiRender.ts
CHANGED
@@ -4,7 +4,7 @@ import { px2mm } from '@pdfme/common';
|
|
4
4
|
import { createSingleTable } from './tableHelper.js';
|
5
5
|
import { getBody, getBodyWithRange } from './helper.js';
|
6
6
|
import cell from './cell.js';
|
7
|
-
import { Row } from './classes';
|
7
|
+
import { Row } from './classes.js';
|
8
8
|
|
9
9
|
const buttonSize = 30;
|
10
10
|
|
package/src/text/constants.ts
CHANGED
@@ -9,7 +9,7 @@ import {
|
|
9
9
|
TextVerticalAlignBottomIcon,
|
10
10
|
TextVerticalAlignMiddleIcon,
|
11
11
|
TextVerticalAlignTopIcon,
|
12
|
-
} from './icons';
|
12
|
+
} from './icons/index.js';
|
13
13
|
import {
|
14
14
|
ALIGN_CENTER,
|
15
15
|
ALIGN_RIGHT,
|
@@ -18,7 +18,7 @@ import {
|
|
18
18
|
VERTICAL_ALIGN_BOTTOM,
|
19
19
|
VERTICAL_ALIGN_MIDDLE,
|
20
20
|
ALIGN_JUSTIFY,
|
21
|
-
} from './constants';
|
21
|
+
} from './constants.js';
|
22
22
|
|
23
23
|
export enum Formatter {
|
24
24
|
STRIKETHROUGH = 'strikethrough',
|
package/src/text/helper.ts
CHANGED
@@ -11,7 +11,7 @@ import {
|
|
11
11
|
DEFAULT_FONT_NAME,
|
12
12
|
} from '@pdfme/common';
|
13
13
|
import { Buffer } from 'buffer';
|
14
|
-
import type { TextSchema, FontWidthCalcValues } from './types';
|
14
|
+
import type { TextSchema, FontWidthCalcValues } from './types.js';
|
15
15
|
import {
|
16
16
|
DEFAULT_FONT_SIZE,
|
17
17
|
DEFAULT_CHARACTER_SPACING,
|
package/src/text/index.ts
CHANGED
@@ -2,7 +2,7 @@ import type { Plugin } from '@pdfme/common';
|
|
2
2
|
import { pdfRender } from './pdfRender.js';
|
3
3
|
import { propPanel } from './propPanel.js';
|
4
4
|
import { uiRender } from './uiRender.js';
|
5
|
-
import type { TextSchema } from './types';
|
5
|
+
import type { TextSchema } from './types.js';
|
6
6
|
import { TextCursorInput } from 'lucide';
|
7
7
|
import { createSvgStr } from '../utils.js';
|
8
8
|
|
package/src/text/pdfRender.ts
CHANGED
package/src/text/propPanel.ts
CHANGED
@@ -5,7 +5,7 @@ import {
|
|
5
5
|
PropPanelSchema,
|
6
6
|
getFallbackFontName,
|
7
7
|
} from '@pdfme/common';
|
8
|
-
import type { TextSchema } from './types';
|
8
|
+
import type { TextSchema } from './types.js';
|
9
9
|
import {
|
10
10
|
DEFAULT_FONT_SIZE,
|
11
11
|
DEFAULT_ALIGNMENT,
|
@@ -20,7 +20,7 @@ import {
|
|
20
20
|
DEFAULT_DYNAMIC_MAX_FONT_SIZE,
|
21
21
|
} from './constants.js';
|
22
22
|
import { DEFAULT_OPACITY, HEX_COLOR_PATTERN } from '../constants.js';
|
23
|
-
import { getExtraFormatterSchema } from './extraFormatter';
|
23
|
+
import { getExtraFormatterSchema } from './extraFormatter.js';
|
24
24
|
|
25
25
|
const UseDynamicFontSize = (props: PropPanelWidgetProps) => {
|
26
26
|
const { rootElement, changeSchemas, activeSchema, i18n } = props;
|
package/src/text/uiRender.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import type * as CSS from 'csstype';
|
2
2
|
import type { Font as FontKitFont } from 'fontkit';
|
3
3
|
import { UIRenderProps, getDefaultFont } from '@pdfme/common';
|
4
|
-
import type { TextSchema } from './types';
|
4
|
+
import type { TextSchema } from './types.js';
|
5
5
|
import {
|
6
6
|
DEFAULT_FONT_SIZE,
|
7
7
|
DEFAULT_ALIGNMENT,
|