@pdfme/schemas 5.2.4-dev.2 → 5.2.5-dev.1
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/src/barcodes/helper.js +9 -1
- package/dist/cjs/src/barcodes/helper.js.map +1 -1
- package/dist/cjs/src/barcodes/index.js +3 -3
- package/dist/cjs/src/barcodes/index.js.map +1 -1
- package/dist/cjs/src/checkbox/index.js +4 -2
- package/dist/cjs/src/checkbox/index.js.map +1 -1
- package/dist/cjs/src/date/date.js +3 -6
- package/dist/cjs/src/date/date.js.map +1 -1
- package/dist/cjs/src/date/dateTime.js +3 -1
- package/dist/cjs/src/date/dateTime.js.map +1 -1
- package/dist/cjs/src/date/time.js +3 -5
- package/dist/cjs/src/date/time.js.map +1 -1
- package/dist/cjs/src/graphics/image.js +2 -1
- package/dist/cjs/src/graphics/image.js.map +1 -1
- package/dist/cjs/src/graphics/svg.js +2 -1
- package/dist/cjs/src/graphics/svg.js.map +1 -1
- package/dist/cjs/src/multiVariableText/index.js +4 -2
- package/dist/cjs/src/multiVariableText/index.js.map +1 -1
- package/dist/cjs/src/radioGroup/index.js +3 -2
- package/dist/cjs/src/radioGroup/index.js.map +1 -1
- package/dist/cjs/src/select/index.js +3 -1
- package/dist/cjs/src/select/index.js.map +1 -1
- package/dist/cjs/src/shapes/line.js +2 -1
- package/dist/cjs/src/shapes/line.js.map +1 -1
- package/dist/cjs/src/shapes/rectAndEllipse.js +3 -4
- package/dist/cjs/src/shapes/rectAndEllipse.js.map +1 -1
- package/dist/cjs/src/tables/index.js +3 -1
- package/dist/cjs/src/tables/index.js.map +1 -1
- package/dist/cjs/src/text/icons/index.js +10 -8
- package/dist/cjs/src/text/icons/index.js.map +1 -1
- package/dist/cjs/src/text/index.js +3 -1
- package/dist/cjs/src/text/index.js.map +1 -1
- package/dist/cjs/src/utils.js +15 -1
- package/dist/cjs/src/utils.js.map +1 -1
- package/dist/esm/src/barcodes/helper.js +9 -1
- package/dist/esm/src/barcodes/helper.js.map +1 -1
- package/dist/esm/src/barcodes/index.js +3 -3
- package/dist/esm/src/barcodes/index.js.map +1 -1
- package/dist/esm/src/checkbox/index.js +4 -2
- package/dist/esm/src/checkbox/index.js.map +1 -1
- package/dist/esm/src/date/date.js +3 -6
- package/dist/esm/src/date/date.js.map +1 -1
- package/dist/esm/src/date/dateTime.js +3 -1
- package/dist/esm/src/date/dateTime.js.map +1 -1
- package/dist/esm/src/date/time.js +3 -5
- package/dist/esm/src/date/time.js.map +1 -1
- package/dist/esm/src/graphics/image.js +3 -2
- package/dist/esm/src/graphics/image.js.map +1 -1
- package/dist/esm/src/graphics/svg.js +3 -2
- package/dist/esm/src/graphics/svg.js.map +1 -1
- package/dist/esm/src/multiVariableText/index.js +4 -2
- package/dist/esm/src/multiVariableText/index.js.map +1 -1
- package/dist/esm/src/radioGroup/index.js +4 -3
- package/dist/esm/src/radioGroup/index.js.map +1 -1
- package/dist/esm/src/select/index.js +3 -1
- package/dist/esm/src/select/index.js.map +1 -1
- package/dist/esm/src/shapes/line.js +3 -2
- package/dist/esm/src/shapes/line.js.map +1 -1
- package/dist/esm/src/shapes/rectAndEllipse.js +4 -5
- package/dist/esm/src/shapes/rectAndEllipse.js.map +1 -1
- package/dist/esm/src/tables/index.js +3 -1
- package/dist/esm/src/tables/index.js.map +1 -1
- package/dist/esm/src/text/icons/index.js +9 -7
- package/dist/esm/src/text/icons/index.js.map +1 -1
- package/dist/esm/src/text/index.js +3 -1
- package/dist/esm/src/text/index.js.map +1 -1
- package/dist/esm/src/utils.js +13 -0
- package/dist/esm/src/utils.js.map +1 -1
- package/dist/types/src/text/icons/index.d.ts +7 -7
- package/dist/types/src/utils.d.ts +2 -0
- package/package.json +3 -2
- package/src/barcodes/helper.ts +10 -1
- package/src/barcodes/index.ts +3 -4
- package/src/checkbox/index.ts +4 -4
- package/src/date/date.ts +3 -7
- package/src/date/dateTime.ts +3 -2
- package/src/date/time.ts +3 -6
- package/src/graphics/image.ts +10 -3
- package/src/graphics/svg.ts +9 -2
- package/src/multiVariableText/index.ts +7 -5
- package/src/radioGroup/index.ts +5 -6
- package/src/select/index.ts +3 -2
- package/src/shapes/line.ts +8 -2
- package/src/shapes/rectAndEllipse.ts +4 -8
- package/src/tables/index.ts +3 -1
- package/src/text/icons/index.ts +18 -8
- package/src/text/index.ts +4 -2
- package/src/utils.ts +14 -1
package/dist/esm/src/utils.js
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import { cmyk, degrees, degreesToRadians, rgb } from '@pdfme/pdf-lib';
|
2
2
|
import { mm2pt, isHexValid } from '@pdfme/common';
|
3
|
+
import { createElement } from 'lucide';
|
3
4
|
import { getDynamicHeightsForTable as _getDynamicHeightsForTable } from './tables/dynamicTemplate.js';
|
4
5
|
export const convertForPdfLayoutProps = ({ schema, pageHeight, applyRotateTranslate = true, }) => {
|
5
6
|
const { width: mmWidth, height: mmHeight, position, rotate, opacity } = schema;
|
@@ -158,4 +159,16 @@ export const createErrorElm = () => {
|
|
158
159
|
container.appendChild(span);
|
159
160
|
return container;
|
160
161
|
};
|
162
|
+
export const createSvgStr = (icon, attrs) => {
|
163
|
+
if (typeof window === 'undefined') {
|
164
|
+
return '';
|
165
|
+
}
|
166
|
+
const svg = createElement(icon);
|
167
|
+
if (attrs) {
|
168
|
+
Object.entries(attrs).forEach(([key, value]) => {
|
169
|
+
svg.setAttribute(key, value);
|
170
|
+
});
|
171
|
+
}
|
172
|
+
return new XMLSerializer().serializeToString(svg);
|
173
|
+
};
|
161
174
|
//# sourceMappingURL=utils.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAU,KAAK,EAAQ,UAAU,EAAa,MAAM,eAAe,CAAC;AAC3E,OAA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C,OAAO,EAAE,CAAC;KACX;IACD,MAAM,GAAG,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IAChC,IAAI,KAAK,EAAE;QACT,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;YAC7C,GAAG,CAAC,YAAY,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC/B,CAAC,CAAC,CAAC;KACJ;IACD,OAAO,IAAI,aAAa,EAAE,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;AACpD,CAAC,CAAC"}
|
@@ -1,8 +1,8 @@
|
|
1
|
-
export declare const TextStrikethroughIcon
|
2
|
-
export declare const TextUnderlineIcon
|
3
|
-
export declare const TextAlignLeftIcon
|
4
|
-
export declare const TextAlignCenterIcon
|
5
|
-
export declare const TextAlignRightIcon
|
6
|
-
export declare const TextVerticalAlignTopIcon
|
1
|
+
export declare const TextStrikethroughIcon: string;
|
2
|
+
export declare const TextUnderlineIcon: string;
|
3
|
+
export declare const TextAlignLeftIcon: string;
|
4
|
+
export declare const TextAlignCenterIcon: string;
|
5
|
+
export declare const TextAlignRightIcon: string;
|
6
|
+
export declare const TextVerticalAlignTopIcon: string;
|
7
7
|
export declare const TextVerticalAlignMiddleIcon = "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" viewBox=\"0 0 24 24\"><path d=\"M8 19h3v4h2v-4h3l-4-4l-4 4zm8-14h-3V1h-2v4H8l4 4l4-4zM4 11v2h16v-2H4z\" fill=\"currentColor\"></path></svg>";
|
8
|
-
export declare const TextVerticalAlignBottomIcon
|
8
|
+
export declare const TextVerticalAlignBottomIcon: string;
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { Schema, Mode, ColorType } from '@pdfme/common';
|
2
|
+
import { IconNode } from 'lucide';
|
2
3
|
export declare const convertForPdfLayoutProps: ({ schema, pageHeight, applyRotateTranslate, }: {
|
3
4
|
schema: Schema;
|
4
5
|
pageHeight: number;
|
@@ -116,3 +117,4 @@ export declare const hex2RgbColor: (hexString: string | undefined) => import("@p
|
|
116
117
|
export declare const hex2PrintingColor: (hexString: string | undefined, colorType?: ColorType) => import("@pdfme/pdf-lib").RGB | import("@pdfme/pdf-lib").CMYK | undefined;
|
117
118
|
export declare const readFile: (input: File | FileList | null) => Promise<string | ArrayBuffer>;
|
118
119
|
export declare const createErrorElm: () => HTMLDivElement;
|
120
|
+
export declare const createSvgStr: (icon: IconNode, attrs?: Record<string, string>) => string;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@pdfme/schemas",
|
3
|
-
"version": "5.2.
|
3
|
+
"version": "5.2.5-dev.1",
|
4
4
|
"sideEffects": false,
|
5
5
|
"author": "hand-dot",
|
6
6
|
"license": "MIT",
|
@@ -53,7 +53,8 @@
|
|
53
53
|
"bwip-js": "^4.1.1",
|
54
54
|
"date-fns": "^4.1.0",
|
55
55
|
"fast-xml-parser": "^4.3.2",
|
56
|
-
"fontkit": "^2.0.2"
|
56
|
+
"fontkit": "^2.0.2",
|
57
|
+
"lucide": "^0.460.0"
|
57
58
|
},
|
58
59
|
"devDependencies": {
|
59
60
|
"@pdfme/common": "file:../common",
|
package/src/barcodes/helper.ts
CHANGED
@@ -148,7 +148,15 @@ export const createBarCode = async (arg: {
|
|
148
148
|
|
149
149
|
const bcid = barCodeType2Bcid(type);
|
150
150
|
const scale = 5;
|
151
|
-
const bwipjsArg: RenderOptions = {
|
151
|
+
const bwipjsArg: RenderOptions = {
|
152
|
+
bcid,
|
153
|
+
text: input,
|
154
|
+
width,
|
155
|
+
height,
|
156
|
+
scale,
|
157
|
+
includetext,
|
158
|
+
textxalign: 'center',
|
159
|
+
};
|
152
160
|
|
153
161
|
if (backgroundColor) bwipjsArg.backgroundcolor = mapHexColorForBwipJsLib(backgroundColor);
|
154
162
|
if (barColor) bwipjsArg.barcolor = mapHexColorForBwipJsLib(barColor);
|
@@ -168,3 +176,4 @@ export const createBarCode = async (arg: {
|
|
168
176
|
|
169
177
|
return res;
|
170
178
|
};
|
179
|
+
|
package/src/barcodes/index.ts
CHANGED
@@ -3,10 +3,9 @@ import { getPropPanelByBarcodeType } from './propPanel.js';
|
|
3
3
|
import { uiRender } from './uiRender.js';
|
4
4
|
import type { BarcodeSchema, BarcodeTypes } from './types';
|
5
5
|
import { BARCODE_TYPES } from './constants.js';
|
6
|
+
import { createSvgStr } from '../utils.js';
|
6
7
|
import { Plugin } from '@pdfme/common';
|
7
|
-
|
8
|
-
const qrIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-qr-code"><rect width="5" height="5" x="3" y="3" rx="1"/><rect width="5" height="5" x="16" y="3" rx="1"/><rect width="5" height="5" x="3" y="16" rx="1"/><path d="M21 16h-3a2 2 0 0 0-2 2v3"/><path d="M21 21v.01"/><path d="M12 7v3a2 2 0 0 1-2 2H7"/><path d="M3 12h.01"/><path d="M12 3h.01"/><path d="M12 16v.01"/><path d="M16 12h1"/><path d="M21 12v.01"/><path d="M12 21v-1"/></svg>';
|
9
|
-
const barcodeIcon = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-barcode"><path d="M3 5v14"/><path d="M8 5v14"/><path d="M12 5v14"/><path d="M17 5v14"/><path d="M21 5v14"/></svg>';
|
8
|
+
import { QrCode, Barcode } from 'lucide';
|
10
9
|
|
11
10
|
const barcodes = BARCODE_TYPES.reduce(
|
12
11
|
(acc, type) =>
|
@@ -15,7 +14,7 @@ const barcodes = BARCODE_TYPES.reduce(
|
|
15
14
|
pdf: pdfRender,
|
16
15
|
ui: uiRender,
|
17
16
|
propPanel: getPropPanelByBarcodeType(type),
|
18
|
-
icon: type == 'qrcode' ?
|
17
|
+
icon: createSvgStr(type == 'qrcode' ? QrCode : Barcode),
|
19
18
|
},
|
20
19
|
}),
|
21
20
|
{} as Record<BarcodeTypes, Plugin<BarcodeSchema>>
|
package/src/checkbox/index.ts
CHANGED
@@ -3,13 +3,13 @@ import { Schema } from '@pdfme/common';
|
|
3
3
|
import svg from '../graphics/svg';
|
4
4
|
import { isEditable } from '../utils.js';
|
5
5
|
import { HEX_COLOR_PATTERN } from '../constants.js';
|
6
|
+
import { Square, SquareCheck } from 'lucide';
|
7
|
+
import { createSvgStr } from '../utils.js';
|
6
8
|
|
7
9
|
const defaultStroke = 'currentColor';
|
8
10
|
|
9
|
-
const getCheckedIcon = (
|
10
|
-
|
11
|
-
const getUncheckedIcon = (color = defaultStroke) =>
|
12
|
-
`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="${color}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-square"><rect width="18" height="18" x="3" y="3" rx="0"/></svg>`;
|
11
|
+
const getCheckedIcon = (stroke = defaultStroke) => createSvgStr(SquareCheck, { stroke });
|
12
|
+
const getUncheckedIcon = (stroke = defaultStroke) => createSvgStr(Square, { stroke });
|
13
13
|
|
14
14
|
interface Checkbox extends Schema {
|
15
15
|
color: string;
|
package/src/date/date.ts
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
import { Lang } from '@pdfme/common';
|
2
2
|
import { getPlugin } from './helper';
|
3
|
+
import { createSvgStr } from '../utils.js';
|
4
|
+
import { Calendar } from 'lucide';
|
3
5
|
|
4
6
|
const type = 'date';
|
5
7
|
|
@@ -47,12 +49,6 @@ const formatsByLang: Record<Lang, string[]> = {
|
|
47
49
|
fr: [defaultFormat, 'dd/MM/yyyy', 'd MMMM yyyy', 'd MMM yyyy', 'EEEE d MMMM yyyy', 'yyyy-MM-dd'],
|
48
50
|
};
|
49
51
|
|
50
|
-
const icon =
|
51
|
-
'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" ' +
|
52
|
-
'viewBox="0 0 24 24" fill="none" stroke="currentColor" ' +
|
53
|
-
'stroke-width="2" stroke-linecap="round" stroke-linejoin="round" ' +
|
54
|
-
'class="lucide lucide-calendar"><path d="M8 2v4"/><path d="M16 2v4"/>' +
|
55
|
-
'<rect width="18" height="18" x="3" y="4" rx="2"/><path d="M3 10h18"/>' +
|
56
|
-
'</svg>';
|
52
|
+
const icon = createSvgStr(Calendar);
|
57
53
|
|
58
54
|
export default getPlugin({ type, defaultFormat, icon, formatsByLang });
|
package/src/date/dateTime.ts
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
import { Lang } from '@pdfme/common';
|
2
2
|
import { getPlugin } from './helper';
|
3
|
+
import { createSvgStr } from '../utils.js';
|
4
|
+
import { CalendarClock } from 'lucide';
|
3
5
|
|
4
6
|
const type = 'dateTime';
|
5
7
|
|
@@ -94,7 +96,6 @@ const formatsByLang: Record<Lang, string[]> = {
|
|
94
96
|
],
|
95
97
|
};
|
96
98
|
|
97
|
-
const icon =
|
98
|
-
'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-calendar-clock"><path d="M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5"/><path d="M16 2v4"/><path d="M8 2v4"/><path d="M3 10h5"/><path d="M17.5 17.5 16 16.3V14"/><circle cx="16" cy="16" r="6"/></svg>';
|
99
|
+
const icon = createSvgStr(CalendarClock);
|
99
100
|
|
100
101
|
export default getPlugin({ type, defaultFormat, icon, formatsByLang });
|
package/src/date/time.ts
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
import { Lang } from '@pdfme/common';
|
2
2
|
import { getPlugin } from './helper';
|
3
|
+
import { createSvgStr } from '../utils.js';
|
4
|
+
import { Clock } from 'lucide';
|
3
5
|
|
4
6
|
const type = 'time';
|
5
7
|
|
@@ -19,11 +21,6 @@ const formatsByLang: Record<Lang, string[]> = {
|
|
19
21
|
fr: [defaultFormat, 'HH:mm:ss'],
|
20
22
|
};
|
21
23
|
|
22
|
-
const icon =
|
23
|
-
'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" ' +
|
24
|
-
'viewBox="0 0 24 24" fill="none" stroke="currentColor" ' +
|
25
|
-
'stroke-width="2" stroke-linecap="round" stroke-linejoin="round" ' +
|
26
|
-
'class="lucide lucide-clock"><circle cx="12" cy="12" r="10"/>' +
|
27
|
-
'<polyline points="12 6 12 12 16 14"/></svg>';
|
24
|
+
const icon = createSvgStr(Clock);
|
28
25
|
|
29
26
|
export default getPlugin({ type, defaultFormat, icon, formatsByLang });
|
package/src/graphics/image.ts
CHANGED
@@ -4,7 +4,14 @@ import type { Plugin } from '@pdfme/common';
|
|
4
4
|
import type { PDFRenderProps, Schema } from '@pdfme/common';
|
5
5
|
import type * as CSS from 'csstype';
|
6
6
|
import { UIRenderProps, px2mm } from '@pdfme/common';
|
7
|
-
import {
|
7
|
+
import { Image } from 'lucide';
|
8
|
+
import {
|
9
|
+
convertForPdfLayoutProps,
|
10
|
+
addAlphaToHex,
|
11
|
+
isEditable,
|
12
|
+
readFile,
|
13
|
+
createSvgStr,
|
14
|
+
} from '../utils.js';
|
8
15
|
import { DEFAULT_OPACITY } from '../constants.js';
|
9
16
|
import { getImageDimension } from './imagehelper.js';
|
10
17
|
import { isPdf, pdfToImage } from './pdfHelper.js';
|
@@ -193,7 +200,7 @@ const imageSchema: Plugin<ImageSchema> = {
|
|
193
200
|
opacity: DEFAULT_OPACITY,
|
194
201
|
},
|
195
202
|
},
|
196
|
-
icon:
|
203
|
+
icon: createSvgStr(Image),
|
197
204
|
};
|
198
205
|
|
199
|
-
export default imageSchema;
|
206
|
+
export default imageSchema;
|
package/src/graphics/svg.ts
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
import { Plugin, Schema } from '@pdfme/common';
|
2
2
|
import { XMLValidator } from 'fast-xml-parser';
|
3
|
-
import {
|
3
|
+
import {
|
4
|
+
convertForPdfLayoutProps,
|
5
|
+
isEditable,
|
6
|
+
addAlphaToHex,
|
7
|
+
createErrorElm,
|
8
|
+
createSvgStr,
|
9
|
+
} from '../utils.js';
|
10
|
+
import { Route } from 'lucide';
|
4
11
|
|
5
12
|
const isValidSVG = (svgString: string) => XMLValidator.validate(svgString) === true;
|
6
13
|
|
@@ -80,7 +87,7 @@ const svgSchema: Plugin<SVGSchema> = {
|
|
80
87
|
height: 50,
|
81
88
|
},
|
82
89
|
},
|
83
|
-
icon:
|
90
|
+
icon: createSvgStr(Route),
|
84
91
|
};
|
85
92
|
|
86
93
|
export default svgSchema;
|
@@ -3,12 +3,14 @@ import { pdfRender } from './pdfRender.js';
|
|
3
3
|
import { propPanel } from './propPanel.js';
|
4
4
|
import { uiRender } from './uiRender.js';
|
5
5
|
import type { MultiVariableTextSchema } from './types';
|
6
|
+
import { Type } from 'lucide';
|
7
|
+
import { createSvgStr } from '../utils.js';
|
6
8
|
|
7
9
|
const schema: Plugin<MultiVariableTextSchema> = {
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
pdf: pdfRender,
|
11
|
+
ui: uiRender,
|
12
|
+
propPanel,
|
13
|
+
icon: createSvgStr(Type),
|
14
|
+
uninterruptedEditMode: true,
|
13
15
|
};
|
14
16
|
export default schema;
|
package/src/radioGroup/index.ts
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
import { Plugin } from '@pdfme/common';
|
2
2
|
import { Schema } from '@pdfme/common';
|
3
|
+
import { Circle, CircleDot } from 'lucide';
|
3
4
|
import svg from '../graphics/svg';
|
4
|
-
import { isEditable } from '../utils.js';
|
5
|
+
import { isEditable, createSvgStr } from '../utils.js';
|
5
6
|
import { HEX_COLOR_PATTERN } from '../constants.js';
|
6
7
|
|
7
8
|
const defaultStroke = 'currentColor';
|
8
9
|
|
9
|
-
const getCheckedIcon = (
|
10
|
-
|
11
|
-
const getUncheckedIcon = (color = defaultStroke) =>
|
12
|
-
`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="${color}" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-circle"><circle cx="12" cy="12" r="10"/></svg>`;
|
10
|
+
const getCheckedIcon = (stroke = defaultStroke) => createSvgStr(CircleDot, { stroke });
|
11
|
+
const getUncheckedIcon = (stroke = defaultStroke) => createSvgStr(Circle, { stroke });
|
13
12
|
|
14
13
|
interface RadioGroup extends Schema {
|
15
14
|
group: string;
|
@@ -35,7 +34,7 @@ const schema: Plugin<RadioGroup> = {
|
|
35
34
|
const container = document.createElement('div');
|
36
35
|
container.style.width = '100%';
|
37
36
|
container.style.height = '100%';
|
38
|
-
|
37
|
+
|
39
38
|
if (onChange) {
|
40
39
|
radioButtonStates.set(schema.name, { value, onChange });
|
41
40
|
}
|
package/src/select/index.ts
CHANGED
@@ -3,9 +3,10 @@ import { propPanel as parentPropPanel } from '../text/propPanel';
|
|
3
3
|
import { Plugin, PropPanelWidgetProps, SchemaForUI } from '@pdfme/common';
|
4
4
|
import text from '../text';
|
5
5
|
import { TextSchema } from '../text/types';
|
6
|
+
import { ChevronDown } from 'lucide';
|
7
|
+
import { createSvgStr } from '../utils.js';
|
6
8
|
|
7
|
-
const selectIcon =
|
8
|
-
'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-chevron-down"><path d="m6 9 6 6 6-6"/></svg>';
|
9
|
+
const selectIcon = createSvgStr(ChevronDown);
|
9
10
|
|
10
11
|
interface Select extends TextSchema {
|
11
12
|
options: string[];
|
package/src/shapes/line.ts
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
import type { Schema, Plugin, PDFRenderProps, UIRenderProps } from '@pdfme/common';
|
2
|
-
import {
|
2
|
+
import {
|
3
|
+
rotatePoint,
|
4
|
+
convertForPdfLayoutProps,
|
5
|
+
hex2PrintingColor,
|
6
|
+
createSvgStr,
|
7
|
+
} from '../utils.js';
|
3
8
|
import { HEX_COLOR_PATTERN } from '../constants.js';
|
9
|
+
import { Minus } from 'lucide';
|
4
10
|
|
5
11
|
const DEFAULT_LINE_COLOR = '#000000';
|
6
12
|
|
@@ -60,6 +66,6 @@ const lineSchema: Plugin<LineSchema> = {
|
|
60
66
|
color: DEFAULT_LINE_COLOR,
|
61
67
|
},
|
62
68
|
},
|
63
|
-
icon:
|
69
|
+
icon: createSvgStr(Minus),
|
64
70
|
};
|
65
71
|
export default lineSchema;
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { Plugin, Schema, mm2pt } from '@pdfme/common';
|
2
2
|
import { HEX_COLOR_PATTERN } from '../constants.js';
|
3
|
-
import { hex2PrintingColor, convertForPdfLayoutProps } from '../utils.js';
|
3
|
+
import { hex2PrintingColor, convertForPdfLayoutProps, createSvgStr } from '../utils.js';
|
4
|
+
import { Circle, Square } from 'lucide';
|
4
5
|
|
5
6
|
interface ShapeSchema extends Schema {
|
6
7
|
type: 'ellipse' | 'rectangle';
|
@@ -102,11 +103,6 @@ const shape: Plugin<ShapeSchema> = {
|
|
102
103
|
},
|
103
104
|
};
|
104
105
|
|
105
|
-
const rectangleIcon =
|
106
|
-
'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-square"><rect width="18" height="18" x="3" y="3" rx="2"/></svg>';
|
107
|
-
const ellipseIcon =
|
108
|
-
'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-circle"><circle cx="12" cy="12" r="10"/></svg>';
|
109
|
-
|
110
106
|
const getPropPanelSchema = (type: 'rectangle' | 'ellipse') => ({
|
111
107
|
...shape.propPanel,
|
112
108
|
defaultSchema: {
|
@@ -118,11 +114,11 @@ const getPropPanelSchema = (type: 'rectangle' | 'ellipse') => ({
|
|
118
114
|
export const rectangle = {
|
119
115
|
...shape,
|
120
116
|
propPanel: getPropPanelSchema('rectangle'),
|
121
|
-
icon:
|
117
|
+
icon: createSvgStr(Square),
|
122
118
|
};
|
123
119
|
|
124
120
|
export const ellipse = {
|
125
121
|
...shape,
|
126
122
|
propPanel: getPropPanelSchema('ellipse'),
|
127
|
-
icon:
|
123
|
+
icon: createSvgStr(Circle),
|
128
124
|
};
|
package/src/tables/index.ts
CHANGED
@@ -3,11 +3,13 @@ import type { TableSchema } from './types.js';
|
|
3
3
|
import { pdfRender } from './pdfRender.js';
|
4
4
|
import { uiRender } from './uiRender.js';
|
5
5
|
import { propPanel } from './propPanel.js';
|
6
|
+
import { Table } from 'lucide';
|
7
|
+
import { createSvgStr } from '../utils.js';
|
6
8
|
|
7
9
|
const tableSchema: Plugin<TableSchema> = {
|
8
10
|
pdf: pdfRender,
|
9
11
|
ui: uiRender,
|
10
12
|
propPanel,
|
11
|
-
icon:
|
13
|
+
icon: createSvgStr(Table),
|
12
14
|
};
|
13
15
|
export default tableSchema;
|
package/src/text/icons/index.ts
CHANGED
@@ -1,17 +1,27 @@
|
|
1
|
-
|
1
|
+
import {
|
2
|
+
Strikethrough,
|
3
|
+
Underline,
|
4
|
+
AlignLeft,
|
5
|
+
AlignCenter,
|
6
|
+
AlignRight,
|
7
|
+
ArrowUpToLine,
|
8
|
+
ArrowDownToLine,
|
9
|
+
} from 'lucide';
|
10
|
+
import { createSvgStr } from '../../utils.js';
|
2
11
|
|
3
|
-
export const TextStrikethroughIcon =
|
12
|
+
export const TextStrikethroughIcon = createSvgStr(Strikethrough);
|
4
13
|
|
5
|
-
export const TextUnderlineIcon =
|
14
|
+
export const TextUnderlineIcon = createSvgStr(Underline);
|
6
15
|
|
7
|
-
export const TextAlignLeftIcon =
|
16
|
+
export const TextAlignLeftIcon = createSvgStr(AlignLeft);
|
8
17
|
|
9
|
-
export const TextAlignCenterIcon =
|
18
|
+
export const TextAlignCenterIcon = createSvgStr(AlignCenter);
|
10
19
|
|
11
|
-
export const TextAlignRightIcon =
|
20
|
+
export const TextAlignRightIcon = createSvgStr(AlignRight);
|
12
21
|
|
13
|
-
export const TextVerticalAlignTopIcon =
|
22
|
+
export const TextVerticalAlignTopIcon = createSvgStr(ArrowUpToLine);
|
14
23
|
|
24
|
+
// svg icons are material icons from https://www.xicons.org
|
15
25
|
export const TextVerticalAlignMiddleIcon = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24"><path d="M8 19h3v4h2v-4h3l-4-4l-4 4zm8-14h-3V1h-2v4H8l4 4l4-4zM4 11v2h16v-2H4z" fill="currentColor"></path></svg>`;
|
16
26
|
|
17
|
-
export const TextVerticalAlignBottomIcon =
|
27
|
+
export const TextVerticalAlignBottomIcon = createSvgStr(ArrowDownToLine);
|
package/src/text/index.ts
CHANGED
@@ -3,12 +3,14 @@ import { pdfRender } from './pdfRender.js';
|
|
3
3
|
import { propPanel } from './propPanel.js';
|
4
4
|
import { uiRender } from './uiRender.js';
|
5
5
|
import type { TextSchema } from './types';
|
6
|
+
import { TextCursorInput } from 'lucide';
|
7
|
+
import { createSvgStr } from '../utils.js';
|
6
8
|
|
7
9
|
const textSchema: Plugin<TextSchema> = {
|
8
10
|
pdf: pdfRender,
|
9
11
|
ui: uiRender,
|
10
12
|
propPanel,
|
11
|
-
icon:
|
13
|
+
icon: createSvgStr(TextCursorInput),
|
12
14
|
};
|
13
15
|
|
14
|
-
export default textSchema;
|
16
|
+
export default textSchema;
|
package/src/utils.ts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
import type * as CSS from 'csstype';
|
2
2
|
import { cmyk, degrees, degreesToRadians, rgb } from '@pdfme/pdf-lib';
|
3
3
|
import { Schema, mm2pt, Mode, isHexValid, ColorType } from '@pdfme/common';
|
4
|
+
import { IconNode, createElement } from 'lucide';
|
4
5
|
import { getDynamicHeightsForTable as _getDynamicHeightsForTable } from './tables/dynamicTemplate.js';
|
5
|
-
|
6
6
|
export const convertForPdfLayoutProps = ({
|
7
7
|
schema,
|
8
8
|
pageHeight,
|
@@ -208,3 +208,16 @@ export const createErrorElm = () => {
|
|
208
208
|
|
209
209
|
return container;
|
210
210
|
};
|
211
|
+
|
212
|
+
export const createSvgStr = (icon: IconNode, attrs?: Record<string, string>): string => {
|
213
|
+
if (typeof window === 'undefined') {
|
214
|
+
return '';
|
215
|
+
}
|
216
|
+
const svg = createElement(icon);
|
217
|
+
if (attrs) {
|
218
|
+
Object.entries(attrs).forEach(([key, value]) => {
|
219
|
+
svg.setAttribute(key, value);
|
220
|
+
});
|
221
|
+
}
|
222
|
+
return new XMLSerializer().serializeToString(svg);
|
223
|
+
};
|