@pdfme/schemas 5.3.13 → 5.3.14-dev.10
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/checkbox/index.js.map +1 -1
- package/dist/cjs/src/date/helper.js.map +1 -1
- package/dist/cjs/src/graphics/image.js.map +1 -1
- package/dist/cjs/src/graphics/svg.js.map +1 -1
- package/dist/cjs/src/radioGroup/index.js.map +1 -1
- package/dist/cjs/src/select/index.js.map +1 -1
- package/dist/cjs/src/shapes/line.js.map +1 -1
- package/dist/cjs/src/shapes/rectAndEllipse.js +16 -2
- package/dist/cjs/src/shapes/rectAndEllipse.js.map +1 -1
- package/dist/cjs/src/tables/cell.js.map +1 -1
- package/dist/esm/src/checkbox/index.js.map +1 -1
- package/dist/esm/src/date/helper.js +1 -1
- package/dist/esm/src/date/helper.js.map +1 -1
- package/dist/esm/src/graphics/image.js.map +1 -1
- package/dist/esm/src/graphics/svg.js.map +1 -1
- package/dist/esm/src/radioGroup/index.js.map +1 -1
- package/dist/esm/src/select/index.js.map +1 -1
- package/dist/esm/src/shapes/line.js.map +1 -1
- package/dist/esm/src/shapes/rectAndEllipse.js +16 -2
- package/dist/esm/src/shapes/rectAndEllipse.js.map +1 -1
- package/dist/esm/src/tables/cell.js +1 -1
- package/dist/esm/src/tables/cell.js.map +1 -1
- package/dist/node/src/checkbox/index.js.map +1 -1
- package/dist/node/src/date/helper.js.map +1 -1
- package/dist/node/src/graphics/image.js.map +1 -1
- package/dist/node/src/graphics/svg.js.map +1 -1
- package/dist/node/src/radioGroup/index.js.map +1 -1
- package/dist/node/src/select/index.js.map +1 -1
- package/dist/node/src/shapes/line.js.map +1 -1
- package/dist/node/src/shapes/rectAndEllipse.js +16 -2
- package/dist/node/src/shapes/rectAndEllipse.js.map +1 -1
- package/dist/node/src/tables/cell.js.map +1 -1
- package/dist/types/src/shapes/rectAndEllipse.d.ts +8 -5
- package/package.json +4 -4
- package/src/checkbox/index.ts +3 -3
- package/src/date/helper.ts +3 -10
- package/src/graphics/image.ts +4 -4
- package/src/graphics/svg.ts +3 -3
- package/src/radioGroup/index.ts +3 -3
- package/src/select/index.ts +2 -2
- package/src/shapes/line.ts +3 -3
- package/src/shapes/rectAndEllipse.ts +20 -5
- package/src/tables/cell.ts +3 -9
package/src/select/index.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import type * as CSS from 'csstype';
|
2
2
|
import { propPanel as parentPropPanel } from '../text/propPanel.js';
|
3
|
-
import { Plugin, PropPanelWidgetProps, SchemaForUI
|
3
|
+
import { Plugin, PropPanelWidgetProps, SchemaForUI } from '@pdfme/common';
|
4
4
|
import text from '../text/index.js';
|
5
5
|
import { TextSchema } from '../text/types.js';
|
6
6
|
import { ChevronDown } from 'lucide';
|
@@ -112,7 +112,7 @@ const addOptions = (props: PropPanelWidgetProps) => {
|
|
112
112
|
};
|
113
113
|
|
114
114
|
const schema: Plugin<Select> = {
|
115
|
-
ui: async (arg
|
115
|
+
ui: async (arg) => {
|
116
116
|
const { schema, value, onChange, rootElement, mode } = arg;
|
117
117
|
await text.ui(Object.assign(arg, { mode: 'viewer' }));
|
118
118
|
|
package/src/shapes/line.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { Schema, Plugin
|
1
|
+
import type { Schema, Plugin } from '@pdfme/common';
|
2
2
|
import {
|
3
3
|
rotatePoint,
|
4
4
|
convertForPdfLayoutProps,
|
@@ -15,7 +15,7 @@ interface LineSchema extends Schema {
|
|
15
15
|
}
|
16
16
|
|
17
17
|
const lineSchema: Plugin<LineSchema> = {
|
18
|
-
pdf: (arg
|
18
|
+
pdf: (arg) => {
|
19
19
|
const { page, schema, options } = arg;
|
20
20
|
if (schema.width === 0 || schema.height === 0 || !schema.color) return;
|
21
21
|
const { colorType } = options;
|
@@ -36,7 +36,7 @@ const lineSchema: Plugin<LineSchema> = {
|
|
36
36
|
opacity: opacity,
|
37
37
|
});
|
38
38
|
},
|
39
|
-
ui: (arg
|
39
|
+
ui: (arg) => {
|
40
40
|
const { schema, rootElement } = arg;
|
41
41
|
const div = document.createElement('div');
|
42
42
|
div.style.backgroundColor = schema.color ?? 'transparent';
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Plugin, Schema, mm2pt
|
1
|
+
import { Plugin, Schema, mm2pt } from '@pdfme/common';
|
2
2
|
import { HEX_COLOR_PATTERN } from '../constants.js';
|
3
3
|
import { hex2PrintingColor, convertForPdfLayoutProps, createSvgStr } from '../utils.js';
|
4
4
|
import { toRadians } from '@pdfme/pdf-lib';
|
@@ -9,10 +9,11 @@ interface ShapeSchema extends Schema {
|
|
9
9
|
borderWidth: number;
|
10
10
|
borderColor: string;
|
11
11
|
color: string;
|
12
|
+
radius?: number;
|
12
13
|
}
|
13
14
|
|
14
15
|
const shape: Plugin<ShapeSchema> = {
|
15
|
-
ui: (arg
|
16
|
+
ui: (arg) => {
|
16
17
|
const { schema, rootElement } = arg;
|
17
18
|
const div = document.createElement('div');
|
18
19
|
div.style.width = '100%';
|
@@ -20,6 +21,8 @@ const shape: Plugin<ShapeSchema> = {
|
|
20
21
|
div.style.boxSizing = 'border-box';
|
21
22
|
if (schema.type === 'ellipse') {
|
22
23
|
div.style.borderRadius = '50%';
|
24
|
+
} else if (schema.radius && schema.radius > 0) {
|
25
|
+
div.style.borderRadius = `${schema.radius}mm`;
|
23
26
|
}
|
24
27
|
div.style.borderWidth = `${schema.borderWidth ?? 0}mm`;
|
25
28
|
div.style.borderStyle = schema.borderWidth && schema.borderColor ? 'solid' : 'none';
|
@@ -28,7 +31,7 @@ const shape: Plugin<ShapeSchema> = {
|
|
28
31
|
|
29
32
|
rootElement.appendChild(div);
|
30
33
|
},
|
31
|
-
pdf: (arg
|
34
|
+
pdf: (arg) => {
|
32
35
|
const { schema, page, options } = arg;
|
33
36
|
if (!schema.color && !schema.borderColor) return;
|
34
37
|
const { colorType } = options;
|
@@ -57,6 +60,8 @@ const shape: Plugin<ShapeSchema> = {
|
|
57
60
|
...drawOptions,
|
58
61
|
});
|
59
62
|
} else if (schema.type === 'rectangle') {
|
63
|
+
const radius = schema.radius ?? 0;
|
64
|
+
|
60
65
|
page.drawRectangle({
|
61
66
|
x:
|
62
67
|
position.x +
|
@@ -68,6 +73,7 @@ const shape: Plugin<ShapeSchema> = {
|
|
68
73
|
Math.tan(toRadians(rotate)) * Math.PI ** 2,
|
69
74
|
width: width - borderWidth,
|
70
75
|
height: height - borderWidth,
|
76
|
+
...(radius ? { radius: mm2pt(radius) } : {}),
|
71
77
|
...drawOptions,
|
72
78
|
});
|
73
79
|
}
|
@@ -78,8 +84,8 @@ const shape: Plugin<ShapeSchema> = {
|
|
78
84
|
title: i18n('schemas.borderWidth'),
|
79
85
|
type: 'number',
|
80
86
|
widget: 'inputNumber',
|
81
|
-
props: { min: 0 },
|
82
|
-
|
87
|
+
props: { min: 0, step: 1 },
|
88
|
+
span: 12,
|
83
89
|
},
|
84
90
|
borderColor: {
|
85
91
|
title: i18n('schemas.borderColor'),
|
@@ -89,6 +95,7 @@ const shape: Plugin<ShapeSchema> = {
|
|
89
95
|
disabledAlpha: true,
|
90
96
|
},
|
91
97
|
rules: [{ pattern: HEX_COLOR_PATTERN, message: i18n('validation.hexColor') }],
|
98
|
+
span: 12,
|
92
99
|
},
|
93
100
|
color: {
|
94
101
|
title: i18n('schemas.color'),
|
@@ -99,6 +106,13 @@ const shape: Plugin<ShapeSchema> = {
|
|
99
106
|
},
|
100
107
|
rules: [{ pattern: HEX_COLOR_PATTERN, message: i18n('validation.hexColor') }],
|
101
108
|
},
|
109
|
+
radius: {
|
110
|
+
title: i18n('schemas.radius'),
|
111
|
+
type: 'number',
|
112
|
+
widget: 'inputNumber',
|
113
|
+
props: { min: 0, step: 1 },
|
114
|
+
span: 12,
|
115
|
+
},
|
102
116
|
}),
|
103
117
|
defaultSchema: {
|
104
118
|
name: '',
|
@@ -112,6 +126,7 @@ const shape: Plugin<ShapeSchema> = {
|
|
112
126
|
borderColor: '#000000',
|
113
127
|
color: '',
|
114
128
|
readOnly: true,
|
129
|
+
radius: 0,
|
115
130
|
},
|
116
131
|
},
|
117
132
|
};
|
package/src/tables/cell.ts
CHANGED
@@ -1,10 +1,4 @@
|
|
1
|
-
import {
|
2
|
-
DEFAULT_FONT_NAME,
|
3
|
-
Plugin,
|
4
|
-
PDFRenderProps,
|
5
|
-
UIRenderProps,
|
6
|
-
getFallbackFontName,
|
7
|
-
} from '@pdfme/common';
|
1
|
+
import { DEFAULT_FONT_NAME, Plugin, PDFRenderProps, getFallbackFontName } from '@pdfme/common';
|
8
2
|
import { uiRender as textUiRender } from '../text/uiRender.js';
|
9
3
|
import { pdfRender as textPdfRender } from '../text/pdfRender.js';
|
10
4
|
import line from '../shapes/line.js';
|
@@ -60,7 +54,7 @@ const createLineDiv = (
|
|
60
54
|
};
|
61
55
|
|
62
56
|
const cellSchema: Plugin<CellSchema> = {
|
63
|
-
pdf: async (arg
|
57
|
+
pdf: async (arg) => {
|
64
58
|
const { schema } = arg;
|
65
59
|
const { position, width, height, borderWidth, padding } = schema;
|
66
60
|
|
@@ -115,7 +109,7 @@ const cellSchema: Plugin<CellSchema> = {
|
|
115
109
|
},
|
116
110
|
});
|
117
111
|
},
|
118
|
-
ui: async (arg
|
112
|
+
ui: async (arg) => {
|
119
113
|
const { schema, rootElement } = arg;
|
120
114
|
const { borderWidth, width, height, borderColor, backgroundColor } = schema;
|
121
115
|
rootElement.style.backgroundColor = backgroundColor;
|