@pdfme/common 1.2.2 → 1.2.4
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__/helper.test.js +14 -0
- package/dist/cjs/__tests__/helper.test.js.map +1 -1
- package/dist/cjs/src/helper.js +13 -0
- package/dist/cjs/src/helper.js.map +1 -1
- package/dist/cjs/src/schema.js +2 -2
- package/dist/cjs/src/schema.js.map +1 -1
- package/dist/esm/__tests__/helper.test.js +14 -0
- package/dist/esm/__tests__/helper.test.js.map +1 -1
- package/dist/esm/src/helper.js +13 -0
- package/dist/esm/src/helper.js.map +1 -1
- package/dist/esm/src/schema.js +2 -2
- package/dist/esm/src/schema.js.map +1 -1
- package/dist/types/src/schema.d.ts +106 -106
- package/dist/types/src/type.d.ts +2 -2
- package/package.json +1 -1
- package/src/helper.ts +16 -0
- package/src/schema.ts +2 -2
package/dist/types/src/type.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { z } from 'zod';
|
2
2
|
import { Lang, Size, Alignment, BarcodeSchemaType, SchemaType, CommonSchema as _CommonSchema, TextSchema, ImageSchema, BarcodeSchema, Schema, SchemaInputs, SchemaForUI, Font, BasePdf, Template, CommonProps, GeneratorOptions, GenerateProps, UIOptions, UIProps, PreviewProps, PreviewReactProps, DesignerProps, DesignerReactProps } from './schema.js';
|
3
3
|
declare type CommonSchema = z.infer<typeof _CommonSchema>;
|
4
|
-
export declare const schemaTypes: readonly ["text", "image", "qrcode", "japanpost", "ean13", "ean8", "code39", "code128", "nw7", "itf14", "upca", "upce"];
|
4
|
+
export declare const schemaTypes: readonly ["text", "image", "qrcode", "japanpost", "ean13", "ean8", "code39", "code128", "nw7", "itf14", "upca", "upce", "gs1datamatrix"];
|
5
5
|
export declare const isTextSchema: (arg: CommonSchema) => arg is {
|
6
6
|
type: "text";
|
7
7
|
height: number;
|
@@ -34,7 +34,7 @@ export declare const isImageSchema: (arg: CommonSchema) => arg is {
|
|
34
34
|
rotate?: number | undefined;
|
35
35
|
};
|
36
36
|
export declare const isBarcodeSchema: (arg: CommonSchema) => arg is {
|
37
|
-
type: "qrcode" | "japanpost" | "ean13" | "ean8" | "code39" | "code128" | "nw7" | "itf14" | "upca" | "upce";
|
37
|
+
type: "qrcode" | "japanpost" | "ean13" | "ean8" | "code39" | "code128" | "nw7" | "itf14" | "upca" | "upce" | "gs1datamatrix";
|
38
38
|
height: number;
|
39
39
|
width: number;
|
40
40
|
position: {
|
package/package.json
CHANGED
package/src/helper.ts
CHANGED
@@ -228,6 +228,22 @@ export const validateBarcodeInput = (type: BarCodeType, input: string) => {
|
|
228
228
|
|
229
229
|
return regexp.test(input) && validateCheckDigit(input, 8);
|
230
230
|
}
|
231
|
+
if (type === 'gs1datamatrix') {
|
232
|
+
let ret = false;
|
233
|
+
// find the GTIN application identifier, regex for "(01)" and the digits after it until another "("
|
234
|
+
const regexp = /\((01)\)(\d*)(\(|$)/;
|
235
|
+
let res = input.match(regexp);
|
236
|
+
if (
|
237
|
+
res != null &&
|
238
|
+
res[1] === '01' &&
|
239
|
+
(res[2].length === 14 || res[2].length === 8 || res[2].length === 12 || res[2].length === 13)
|
240
|
+
) {
|
241
|
+
let gtin = res[2];
|
242
|
+
ret = validateCheckDigit(gtin, gtin.length);
|
243
|
+
}
|
244
|
+
|
245
|
+
return ret;
|
246
|
+
}
|
231
247
|
|
232
248
|
return false;
|
233
249
|
};
|
package/src/schema.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/* eslint dot-notation: "off"*/
|
2
2
|
import { z } from 'zod';
|
3
3
|
|
4
|
-
const langs = ['en', 'ja', 'ar'] as const;
|
4
|
+
const langs = ['en', 'ja', 'ar', 'th'] as const;
|
5
5
|
export const Lang = z.enum(langs);
|
6
6
|
|
7
7
|
export const Size = z.object({ height: z.number(), width: z.number() });
|
@@ -10,7 +10,7 @@ const alignments = ['left', 'center', 'right'] as const;
|
|
10
10
|
export const Alignment = z.enum(alignments);
|
11
11
|
|
12
12
|
// prettier-ignore
|
13
|
-
export const barcodeSchemaTypes = ['qrcode', 'japanpost', 'ean13', 'ean8', 'code39', 'code128', 'nw7', 'itf14', 'upca', 'upce'] as const;
|
13
|
+
export const barcodeSchemaTypes = ['qrcode', 'japanpost', 'ean13', 'ean8', 'code39', 'code128', 'nw7', 'itf14', 'upca', 'upce', 'gs1datamatrix'] as const;
|
14
14
|
const notBarcodeSchemaTypes = ['text', 'image'] as const;
|
15
15
|
export const schemaTypes = [...notBarcodeSchemaTypes, ...barcodeSchemaTypes] as const;
|
16
16
|
|