mirror of
https://github.com/pdfme/pdfme.git
synced 2026-04-18 13:09:38 -04:00
Fix missing setting for gs1datamatrix
This commit is contained in:
8
package-lock.json
generated
8
package-lock.json
generated
@@ -9593,7 +9593,7 @@
|
||||
"version": "1.2.3",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@pdfme/common": "^1.2.1",
|
||||
"@pdfme/common": "file:../common",
|
||||
"@pdfme/pdf-lib": "^1.17.3",
|
||||
"atob": "^2.1.2",
|
||||
"bwip-js": "^3.2.2",
|
||||
@@ -9618,7 +9618,7 @@
|
||||
"@dnd-kit/core": "^5.0.1",
|
||||
"@dnd-kit/sortable": "^6.0.0",
|
||||
"@heroicons/react": "^2.0.13",
|
||||
"@pdfme/common": "^1.2.1",
|
||||
"@pdfme/common": "file:../common",
|
||||
"@scena/react-guides": "^0.16.0",
|
||||
"hotkeys-js": "^3.8.7",
|
||||
"pdfjs-dist": "2.12.313",
|
||||
@@ -10580,7 +10580,7 @@
|
||||
"@pdfme/generator": {
|
||||
"version": "file:packages/generator",
|
||||
"requires": {
|
||||
"@pdfme/common": "^1.2.1",
|
||||
"@pdfme/common": "file:../common",
|
||||
"@pdfme/pdf-lib": "^1.17.3",
|
||||
"@types/bwip-js": "^3.0.0",
|
||||
"@types/pngjs": "^6.0.1",
|
||||
@@ -10612,7 +10612,7 @@
|
||||
"@dnd-kit/core": "^5.0.1",
|
||||
"@dnd-kit/sortable": "^6.0.0",
|
||||
"@heroicons/react": "^2.0.13",
|
||||
"@pdfme/common": "^1.2.1",
|
||||
"@pdfme/common": "file:../common",
|
||||
"@scena/react-guides": "^0.16.0",
|
||||
"@testing-library/jest-dom": "^5.16.1",
|
||||
"@testing-library/react": "^12.1.2",
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
"prune": "ts-prune src"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pdfme/common": "^1.2.1",
|
||||
"@pdfme/common": "file:../common",
|
||||
"@pdfme/pdf-lib": "^1.17.3",
|
||||
"atob": "^2.1.2",
|
||||
"bwip-js": "^3.2.2",
|
||||
@@ -80,4 +80,4 @@
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,5 +2,10 @@
|
||||
"extends": "./tsconfig.esm",
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist",
|
||||
},
|
||||
"paths": {
|
||||
"@pdfme/common": [
|
||||
"packages/common/src"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -41,7 +41,7 @@
|
||||
"@dnd-kit/core": "^5.0.1",
|
||||
"@dnd-kit/sortable": "^6.0.0",
|
||||
"@heroicons/react": "^2.0.13",
|
||||
"@pdfme/common": "^1.2.1",
|
||||
"@pdfme/common": "file:../common",
|
||||
"@scena/react-guides": "^0.16.0",
|
||||
"hotkeys-js": "^3.8.7",
|
||||
"pdfjs-dist": "2.12.313",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useRef, useState, useEffect, useContext, useCallback } from 'react';
|
||||
import { DesignerReactProps, Template, SchemaForUI } from '@pdfme/common';
|
||||
import { DesignerReactProps, Template, SchemaForUI, SchemaType } from '@pdfme/common';
|
||||
import Sidebar from './Sidebar/index';
|
||||
import Main from './Main/index';
|
||||
import { ZOOM, RULER_HEIGHT } from '../../constants';
|
||||
@@ -96,11 +96,11 @@ const TemplateEditor = ({
|
||||
// Assign to reference
|
||||
set(tgt, key, value);
|
||||
if (key === 'type') {
|
||||
const type = String(value);
|
||||
const type = String(value) as SchemaType;
|
||||
// set default value, text or barcode
|
||||
set(tgt, 'data', getSampleByType(type));
|
||||
// For barcodes, adjust the height to get the correct ratio.
|
||||
if (value !== 'text') {
|
||||
if (type !== 'text' && type !== 'image') {
|
||||
set(tgt, 'height', getKeepRatioHeightByWidth(type, tgt.width));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import React, { forwardRef, Ref } from 'react';
|
||||
import { validateBarcodeInput, BarCodeType, BarcodeSchema } from '@pdfme/common';
|
||||
import { validateBarcodeInput, BarCodeType, BarcodeSchema, } from '@pdfme/common';
|
||||
import { ZOOM } from '../../constants';
|
||||
import { SchemaUIProps } from './SchemaUI';
|
||||
|
||||
const barcodeExampleImageObj: { [key: string]: string } = {
|
||||
const barcodeExampleImageObj: { [K in BarCodeType]: string } = {
|
||||
qrcode:
|
||||
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPoAAAD6AQMAAACyIsh+AAAABlBMVEVHcEwAAACfKoRRAAAAAXRSTlMAQObYZgAAAUBJREFUaN7t2UEOxCAIBVASD9Aj9eoeqQdowqiAYhsbTGb5u2gm9s2GIFBLrNdNnI+biI72y5YzAURBJpJlOstCuXVaLoAdUMOaLcCiWrwl/AD7QKJclwH+AUYNANgFtv0lyudFq/oA8A3mljQKwaJnAazAdKW6kpiWF8Aa2H7XRmSpmrQvZYAwGJteM7fV1drmr8QAO6A8c7Mms85KvSUBxIDkaw2r2/Ityu2fBBAHdavrwK75KkmrhQAgDFojv/qs1Da9gMQAcdCe+VlTIt8neYAoGNv/8Yr+rg8An0A6j9ykOWlfstETIAjcjO4z198AQsC/TlpsNXMB9sA4Cpbz4Es7Vc9qgCjox27a5pM73ZjP5QDCQFPVzt74FWqACJDYajVNGvQMEAfTJzOhbDVgrg8An+DxGXd8o9A2DxADPwiEPe8Jo46KAAAAAElFTkSuQmCC',
|
||||
japanpost:
|
||||
|
||||
@@ -10,6 +10,8 @@ import {
|
||||
Template,
|
||||
SchemaForUI,
|
||||
Schema,
|
||||
SchemaType,
|
||||
BarCodeType,
|
||||
Size,
|
||||
DEFAULT_ALIGNMENT,
|
||||
DEFAULT_FONT_SIZE,
|
||||
@@ -409,8 +411,8 @@ export const getInitialSchema = (): SchemaForUI => ({
|
||||
lineHeight: DEFAULT_LINE_HEIGHT,
|
||||
});
|
||||
|
||||
export const getSampleByType = (type: string) => {
|
||||
const defaultValue: { [key: string]: string } = {
|
||||
export const getSampleByType = (type: SchemaType) => {
|
||||
const defaultValue: { [K in SchemaType]: string } = {
|
||||
text: 'text',
|
||||
image:
|
||||
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAu4AAALuAQMAAADL0wGJAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAGUExURbzAw+rv8fKruy0AAAPoSURBVHja7dwxbtwwEEBRCkKwRQodYftcYk+ROkcJz5NTsEuZK/AIKlIQAUEnke0VqQ0pA5zxWvFnZcD2s0CNuENxPOZBc0QDDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PDw8PD/+P8bkxvnTzzjTG0M2b5rh08rHNT518aPOnTt63+aGTd23edPJ2h//ax+/oO6Gzx6c78+cuPu7x01vmwx5/6uLnO/PjO+b/rGifvtWH3VnT9vmh/e3eqx/bc9d79af2YwEPDw8P/6r8r1GVt5VcUoZPtXxGhp9rGYEM72vbEBne1hJ5Gb6ayIvwqZppi/CxmgqL8KGaTIrwc3WDfATeV/ffIryr7r+PwNvq/vsIfH17D5/qbw/gb/mLKp/OqnycFPj14yqcJPm4vfp5VJ0cP6jyzqjy9rr2q/Dr4qzBp3V5E1wxp/V3rl8LXn32qF6fAY31Psv2NXi/5lQaH+Vuzak0eLsmPRppVPa3FPiU3QiFFDZmD4FCAh6yxV+Bn7O9isLmx2d/TGHr5rI7obDxtFkcKWyb89M2+U1/sX7Kv7Io8gaxFy5l2D/faRk++3x6PgsalV52+fwUW4j/+eGhDPuneyH/otHmp9jyfHHMLM6n4phZnI/FObA4H4qDWnF+Lo46xXlflG+I864o3xDnbVG+Ic6X9RXSfCrrK6T5WBZASPOhrFCQ5ufyjF+a92XdkjTvyrolad6WdUvS/KawSI7/sQn7JfDl+O+bsF8CX44fN2FvHnNnIT4Nm7BfAl+ON5uwXwJfjA/LCuk2BXvCvN0U7InxflmAtxV1gvx0U2N3luPtdZOlwj/FoR5vbuq85Pi48F6LD0scOk3+sq1cleP9ohlNfkpq/N9pGaMuH7T4ZVqGWYt/nBavyxstftblfaVIWJU/y72yODCfzJH5oMvPh+adLm+PzCdzZD5U/61ClT9Lnvyo8e7QvFHlE3ydj0zOu5ucickhcpgcJofJedUVk8j5b/nGgIeHh4d/I3x/RwLlhgfNH3DavSwGXf7YjT76uqCEQ/P37p9z7uKVmwspd17S7hul3PXK6fbsmnvWhO6GZlMnn3ri8gXN5GzHnX0B35ydj91814CHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHl+d/A9cKjmiL040TAAAAAElFTkSuQmCC',
|
||||
@@ -424,14 +426,13 @@ export const getSampleByType = (type: string) => {
|
||||
itf14: '04601234567893',
|
||||
upca: '416000336108',
|
||||
upce: '00123457',
|
||||
gs1datamatrix: '(01)03453120000011(17)191125(10)ABCD1234',
|
||||
};
|
||||
|
||||
return defaultValue[type] ? defaultValue[type] : '';
|
||||
return defaultValue[type];
|
||||
};
|
||||
|
||||
export const getKeepRatioHeightByWidth = (type: string, width: number) => {
|
||||
const raito: { [key: string]: number } = {
|
||||
image: 1,
|
||||
export const getKeepRatioHeightByWidth = (type: BarCodeType, width: number) => {
|
||||
const ratio: { [K in BarCodeType]: number } = {
|
||||
qrcode: 1,
|
||||
japanpost: 0.09,
|
||||
ean13: 0.4,
|
||||
@@ -442,9 +443,9 @@ export const getKeepRatioHeightByWidth = (type: string, width: number) => {
|
||||
itf14: 0.3,
|
||||
upca: 0.4,
|
||||
upce: 0.5,
|
||||
gs1datamatrix: 1,
|
||||
};
|
||||
|
||||
return width * (raito[type] ? raito[type] : 1);
|
||||
return width * ratio[type];
|
||||
};
|
||||
|
||||
export const getUniqSchemaKey = (arg: {
|
||||
|
||||
@@ -14,7 +14,11 @@
|
||||
"strict": true,
|
||||
"types": ["node", "jest", "@types/jest"],
|
||||
"typeRoots": ["../node_modules/@types"],
|
||||
"sourceMap": true
|
||||
"sourceMap": true,
|
||||
"baseUrl": "..",
|
||||
"paths": {
|
||||
"@pdfme/common": ["packages/common/src"]
|
||||
}
|
||||
},
|
||||
"baseUrl": ".",
|
||||
"include": ["src/**/*.ts", "src/**/*.tsx"],
|
||||
|
||||
Reference in New Issue
Block a user