@pdfme/schemas 3.1.5-dev.12 → 3.1.5-dev.14

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.
Files changed (128) hide show
  1. package/dist/cjs/__tests__/renderUtils.test.js +29 -8
  2. package/dist/cjs/__tests__/renderUtils.test.js.map +1 -1
  3. package/dist/cjs/src/barcodes/pdfRender.js +2 -2
  4. package/dist/cjs/src/barcodes/pdfRender.js.map +1 -1
  5. package/dist/cjs/src/barcodes/uiRender.js +3 -3
  6. package/dist/cjs/src/barcodes/uiRender.js.map +1 -1
  7. package/dist/cjs/src/graphics/image.js +122 -0
  8. package/dist/cjs/src/graphics/image.js.map +1 -0
  9. package/dist/cjs/src/index.js +13 -10
  10. package/dist/cjs/src/index.js.map +1 -1
  11. package/dist/cjs/src/{renderUtils.js → pdfRenderUtils.js} +2 -5
  12. package/dist/cjs/src/pdfRenderUtils.js.map +1 -0
  13. package/dist/cjs/src/shapes/line.js +57 -0
  14. package/dist/cjs/src/shapes/line.js.map +1 -0
  15. package/dist/cjs/src/shapes/rectAndEllipse.js +100 -0
  16. package/dist/cjs/src/shapes/rectAndEllipse.js.map +1 -0
  17. package/dist/cjs/src/text/pdfRender.js +5 -5
  18. package/dist/cjs/src/text/pdfRender.js.map +1 -1
  19. package/dist/cjs/src/text/uiRender.js +3 -3
  20. package/dist/cjs/src/text/uiRender.js.map +1 -1
  21. package/dist/cjs/src/uiRenderUtils.js +29 -0
  22. package/dist/cjs/src/uiRenderUtils.js.map +1 -0
  23. package/dist/esm/__tests__/renderUtils.test.js +22 -1
  24. package/dist/esm/__tests__/renderUtils.test.js.map +1 -1
  25. package/dist/esm/src/barcodes/pdfRender.js +1 -1
  26. package/dist/esm/src/barcodes/pdfRender.js.map +1 -1
  27. package/dist/esm/src/barcodes/uiRender.js +1 -1
  28. package/dist/esm/src/barcodes/uiRender.js.map +1 -1
  29. package/dist/esm/src/graphics/image.js +120 -0
  30. package/dist/esm/src/graphics/image.js.map +1 -0
  31. package/dist/esm/src/index.js +5 -4
  32. package/dist/esm/src/index.js.map +1 -1
  33. package/dist/esm/src/{renderUtils.js → pdfRenderUtils.js} +2 -5
  34. package/dist/esm/src/pdfRenderUtils.js.map +1 -0
  35. package/dist/esm/src/shapes/line.js +55 -0
  36. package/dist/esm/src/shapes/line.js.map +1 -0
  37. package/dist/esm/src/shapes/rectAndEllipse.js +97 -0
  38. package/dist/esm/src/shapes/rectAndEllipse.js.map +1 -0
  39. package/dist/esm/src/text/pdfRender.js +1 -1
  40. package/dist/esm/src/text/pdfRender.js.map +1 -1
  41. package/dist/esm/src/text/uiRender.js +1 -1
  42. package/dist/esm/src/text/uiRender.js.map +1 -1
  43. package/dist/esm/src/uiRenderUtils.js +25 -0
  44. package/dist/esm/src/uiRenderUtils.js.map +1 -0
  45. package/dist/types/src/{image/index.d.ts → graphics/image.d.ts} +3 -1
  46. package/dist/types/src/index.d.ts +5 -4
  47. package/dist/types/src/shapes/line.d.ts +6 -0
  48. package/dist/types/src/shapes/rectAndEllipse.d.ts +138 -0
  49. package/dist/types/src/uiRenderUtils.d.ts +1 -0
  50. package/package.json +1 -1
  51. package/src/barcodes/pdfRender.ts +1 -1
  52. package/src/barcodes/uiRender.ts +1 -1
  53. package/src/graphics/image.ts +151 -0
  54. package/src/index.ts +15 -4
  55. package/src/{renderUtils.ts → pdfRenderUtils.ts} +1 -4
  56. package/src/shapes/line.ts +67 -0
  57. package/src/shapes/rectAndEllipse.ts +110 -0
  58. package/src/text/pdfRender.ts +1 -1
  59. package/src/text/uiRender.ts +1 -1
  60. package/src/uiRenderUtils.ts +27 -0
  61. package/dist/cjs/src/image/index.js +0 -8
  62. package/dist/cjs/src/image/index.js.map +0 -1
  63. package/dist/cjs/src/image/pdfRender.js +0 -22
  64. package/dist/cjs/src/image/pdfRender.js.map +0 -1
  65. package/dist/cjs/src/image/propPanel.js +0 -19
  66. package/dist/cjs/src/image/propPanel.js.map +0 -1
  67. package/dist/cjs/src/image/types.js +0 -3
  68. package/dist/cjs/src/image/types.js.map +0 -1
  69. package/dist/cjs/src/image/uiRender.js +0 -113
  70. package/dist/cjs/src/image/uiRender.js.map +0 -1
  71. package/dist/cjs/src/line/constants.js +0 -5
  72. package/dist/cjs/src/line/constants.js.map +0 -1
  73. package/dist/cjs/src/line/index.js +0 -8
  74. package/dist/cjs/src/line/index.js.map +0 -1
  75. package/dist/cjs/src/line/pdfRender.js +0 -20
  76. package/dist/cjs/src/line/pdfRender.js.map +0 -1
  77. package/dist/cjs/src/line/propPanel.js +0 -35
  78. package/dist/cjs/src/line/propPanel.js.map +0 -1
  79. package/dist/cjs/src/line/types.js +0 -3
  80. package/dist/cjs/src/line/types.js.map +0 -1
  81. package/dist/cjs/src/line/uiRender.js +0 -14
  82. package/dist/cjs/src/line/uiRender.js.map +0 -1
  83. package/dist/cjs/src/renderUtils.js.map +0 -1
  84. package/dist/esm/src/image/index.js +0 -6
  85. package/dist/esm/src/image/index.js.map +0 -1
  86. package/dist/esm/src/image/pdfRender.js +0 -18
  87. package/dist/esm/src/image/pdfRender.js.map +0 -1
  88. package/dist/esm/src/image/propPanel.js +0 -16
  89. package/dist/esm/src/image/propPanel.js.map +0 -1
  90. package/dist/esm/src/image/types.js +0 -2
  91. package/dist/esm/src/image/types.js.map +0 -1
  92. package/dist/esm/src/image/uiRender.js +0 -109
  93. package/dist/esm/src/image/uiRender.js.map +0 -1
  94. package/dist/esm/src/line/constants.js +0 -2
  95. package/dist/esm/src/line/constants.js.map +0 -1
  96. package/dist/esm/src/line/index.js +0 -6
  97. package/dist/esm/src/line/index.js.map +0 -1
  98. package/dist/esm/src/line/pdfRender.js +0 -16
  99. package/dist/esm/src/line/pdfRender.js.map +0 -1
  100. package/dist/esm/src/line/propPanel.js +0 -32
  101. package/dist/esm/src/line/propPanel.js.map +0 -1
  102. package/dist/esm/src/line/types.js +0 -2
  103. package/dist/esm/src/line/types.js.map +0 -1
  104. package/dist/esm/src/line/uiRender.js +0 -10
  105. package/dist/esm/src/line/uiRender.js.map +0 -1
  106. package/dist/esm/src/renderUtils.js.map +0 -1
  107. package/dist/types/src/image/pdfRender.d.ts +0 -3
  108. package/dist/types/src/image/propPanel.d.ts +0 -3
  109. package/dist/types/src/image/types.d.ts +0 -3
  110. package/dist/types/src/image/uiRender.d.ts +0 -3
  111. package/dist/types/src/line/constants.d.ts +0 -1
  112. package/dist/types/src/line/index.d.ts +0 -4
  113. package/dist/types/src/line/pdfRender.d.ts +0 -3
  114. package/dist/types/src/line/propPanel.d.ts +0 -3
  115. package/dist/types/src/line/types.d.ts +0 -4
  116. package/dist/types/src/line/uiRender.d.ts +0 -3
  117. package/src/image/index.ts +0 -8
  118. package/src/image/pdfRender.ts +0 -29
  119. package/src/image/propPanel.ts +0 -19
  120. package/src/image/types.ts +0 -3
  121. package/src/image/uiRender.ts +0 -123
  122. package/src/line/constants.ts +0 -1
  123. package/src/line/index.ts +0 -8
  124. package/src/line/pdfRender.ts +0 -24
  125. package/src/line/propPanel.ts +0 -34
  126. package/src/line/types.ts +0 -5
  127. package/src/line/uiRender.ts +0 -12
  128. /package/dist/types/src/{renderUtils.d.ts → pdfRenderUtils.d.ts} +0 -0
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/line/types.ts"],"names":[],"mappings":""}
@@ -1,10 +0,0 @@
1
- import { DEFAULT_LINE_COLOR } from './constants.js';
2
- export const uiRender = (arg) => {
3
- const { schema, rootElement } = arg;
4
- const div = document.createElement('div');
5
- div.style.backgroundColor = schema.color ?? DEFAULT_LINE_COLOR;
6
- div.style.width = '100%';
7
- div.style.height = '100%';
8
- rootElement.appendChild(div);
9
- };
10
- //# sourceMappingURL=uiRender.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"uiRender.js","sourceRoot":"","sources":["../../../../src/line/uiRender.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,k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G,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;gBACf,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;gBACf,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;gBACf,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;gBACf,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAEpB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;AAC7F,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,SAA6B,EAAE,EAAE;IAC5D,IAAI,SAAS,EAAE;QACb,MAAM,OAAO,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;QAEtC,IAAI,CAAC,OAAO,EAAE;YACZ,MAAM,IAAI,KAAK,CAAC,2BAA2B,SAAS,EAAE,CAAC,CAAC;SACzD;QAED,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;QAErC,OAAO,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC;KACvC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { PDFRenderProps } from '@pdfme/common';
2
- import type { ImageSchema } from './types';
3
- export declare const pdfRender: (arg: PDFRenderProps<ImageSchema>) => Promise<void>;
@@ -1,3 +0,0 @@
1
- import { PropPanel } from '@pdfme/common';
2
- import type { ImageSchema } from './types';
3
- export declare const propPanel: PropPanel<ImageSchema>;
@@ -1,3 +0,0 @@
1
- import { Schema } from '@pdfme/common';
2
- export interface ImageSchema extends Schema {
3
- }
@@ -1,3 +0,0 @@
1
- import type { ImageSchema } from './types';
2
- import { UIRenderProps } from '@pdfme/common';
3
- export declare const uiRender: (arg: UIRenderProps<ImageSchema>) => Promise<void>;
@@ -1 +0,0 @@
1
- export declare const DEFAULT_LINE_COLOR = "#000000";
@@ -1,4 +0,0 @@
1
- import type { Plugin } from '@pdfme/common';
2
- import type { LineSchema } from './types.js';
3
- declare const schema: Plugin<LineSchema>;
4
- export default schema;
@@ -1,3 +0,0 @@
1
- import type { PDFRenderProps } from '@pdfme/common';
2
- import type { LineSchema } from './types';
3
- export declare const pdfRender: (arg: PDFRenderProps<LineSchema>) => void;
@@ -1,3 +0,0 @@
1
- import { PropPanel } from '@pdfme/common';
2
- import type { LineSchema } from './types';
3
- export declare const propPanel: PropPanel<LineSchema>;
@@ -1,4 +0,0 @@
1
- import { Schema } from '@pdfme/common';
2
- export interface LineSchema extends Schema {
3
- color: string;
4
- }
@@ -1,3 +0,0 @@
1
- import type { LineSchema } from './types';
2
- import { UIRenderProps } from '@pdfme/common';
3
- export declare const uiRender: (arg: UIRenderProps<LineSchema>) => void;
@@ -1,8 +0,0 @@
1
- import type { Plugin } from '@pdfme/common';
2
- import { pdfRender } from './pdfRender.js';
3
- import { propPanel } from './propPanel.js';
4
- import { uiRender } from './uiRender.js';
5
- import type { ImageSchema } from './types';
6
-
7
- const schema: Plugin<ImageSchema> = { pdf: pdfRender, ui: uiRender, propPanel };
8
- export default schema;
@@ -1,29 +0,0 @@
1
- import type { PDFRenderProps, Schema } from '@pdfme/common';
2
- import type { ImageSchema } from './types';
3
- import { convertForPdfLayoutProps } from '../renderUtils.js';
4
-
5
- const getCacheKey = (schema: Schema, input: string) => `${schema.type}${input}`;
6
-
7
- export const pdfRender = async (arg: PDFRenderProps<ImageSchema>) => {
8
- const { value, schema, pdfDoc, page, _cache } = arg;
9
- if (!value || !value.startsWith('data:image/')) return;
10
-
11
- const inputImageCacheKey = getCacheKey(schema, value);
12
- let image = _cache.get(inputImageCacheKey);
13
- if (!image) {
14
- const isPng = value.startsWith('data:image/png;');
15
- image = await (isPng ? pdfDoc.embedPng(value) : pdfDoc.embedJpg(value));
16
- _cache.set(inputImageCacheKey, image);
17
- }
18
-
19
- const pageHeight = page.getHeight();
20
- const {
21
- width,
22
- height,
23
- rotate,
24
- position: { x, y },
25
- opacity,
26
- } = convertForPdfLayoutProps({ schema, pageHeight });
27
-
28
- page.drawImage(image, { x, y, rotate, width, height, opacity });
29
- };
@@ -1,19 +0,0 @@
1
- import { PropPanel } from '@pdfme/common';
2
- import type { ImageSchema } from './types';
3
- import { DEFAULT_OPACITY } from '../constants.js';
4
-
5
- export const propPanel: PropPanel<ImageSchema> = {
6
- schema: {},
7
- defaultValue:
8
- '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',
9
- defaultSchema: {
10
- type: 'image',
11
- position: { x: 0, y: 0 },
12
- width: 40,
13
- height: 40,
14
- // If the value of "rotate" is set to undefined or not set at all, rotation will be disabled in the UI.
15
- // Check this document: https://pdfme.com//docs/custom-schemas#learning-how-to-create-from-pdfmeschemas-code
16
- rotate: 0,
17
- opacity: DEFAULT_OPACITY,
18
- },
19
- };
@@ -1,3 +0,0 @@
1
- import { Schema } from '@pdfme/common';
2
-
3
- export interface ImageSchema extends Schema {}
@@ -1,123 +0,0 @@
1
- import type { ChangeEvent } from 'react';
2
- import type * as CSS from 'csstype';
3
- import type { ImageSchema } from './types';
4
- import { UIRenderProps, ZOOM } from '@pdfme/common';
5
- import { addAlphaToHex, isEditable } from '../renderUtils.js';
6
- import { propPanel } from "./propPanel";
7
-
8
- const fullSize = { width: '100%', height: '100%' };
9
-
10
- const readFile = (input: File | FileList | null): Promise<string | ArrayBuffer> =>
11
- new Promise((resolve, reject) => {
12
- const fileReader = new FileReader();
13
-
14
- fileReader.onload = (e) => {
15
- if (e.target?.result) {
16
- resolve(e.target.result);
17
- }
18
- };
19
-
20
- fileReader.onerror = (e) => {
21
- reject(new Error('[@pdfme/schemas] File reading failed'));
22
- };
23
-
24
- let file: File | null = null;
25
- if (input instanceof FileList && input.length > 0) {
26
- file = input[0];
27
- } else if (input instanceof File) {
28
- file = input;
29
- }
30
-
31
- if (file) {
32
- fileReader.readAsDataURL(file);
33
- } else {
34
- reject(new Error('[@pdfme/schemas] No files provided'));
35
- }
36
- });
37
-
38
- export const uiRender = async (arg: UIRenderProps<ImageSchema>) => {
39
- const { value, rootElement, mode, onChange, stopEditing, tabIndex, placeholder, schema, theme } =
40
- arg;
41
- const editable = isEditable(mode);
42
- const isDefault = value === propPanel.defaultValue;
43
-
44
- const size = { width: schema.width * ZOOM, height: schema.height * ZOOM };
45
-
46
- const container = document.createElement('div');
47
- const backgroundStyle = placeholder ? `url(${placeholder})` : 'none';
48
- const containerStyle: CSS.Properties = {
49
- ...fullSize,
50
- backgroundImage: value ? 'none' : backgroundStyle,
51
- backgroundSize: `${size.width}px ${size.height}px`,
52
- };
53
- Object.assign(container.style, containerStyle);
54
- container.addEventListener('click', (e) => {
55
- if (editable) {
56
- e.stopPropagation();
57
- }
58
- });
59
- rootElement.appendChild(container);
60
-
61
- // image tag
62
- if (value) {
63
- const img = document.createElement('img');
64
- const imgStyle: CSS.Properties = { height: '100%', width: '100%', borderRadius: 0 };
65
- Object.assign(img.style, imgStyle);
66
- img.src = value;
67
- container.appendChild(img);
68
- }
69
-
70
- // remove button
71
- if (value && !isDefault && editable) {
72
- const button = document.createElement('button');
73
- button.textContent = 'x';
74
- const buttonStyle: CSS.Properties = {
75
- position: 'absolute',
76
- top: 0,
77
- left: 0,
78
- zIndex: 1,
79
- display: 'flex',
80
- justifyContent: 'center',
81
- alignItems: 'center',
82
- color: '#333',
83
- background: '#f2f2f2',
84
- borderRadius: '2px',
85
- border: '1px solid #767676',
86
- cursor: 'pointer',
87
- height: '24px',
88
- width: '24px',
89
- };
90
- Object.assign(button.style, buttonStyle);
91
- button.addEventListener('click', () => {
92
- onChange && onChange('');
93
- });
94
- container.appendChild(button);
95
- }
96
-
97
- // file input
98
- if ((!value || isDefault) && editable) {
99
- const label = document.createElement('label');
100
- const labelStyle: CSS.Properties = {
101
- ...fullSize,
102
- display: editable ? 'flex' : 'none',
103
- position: 'absolute',
104
- top: 0,
105
- backgroundColor: editable || value ? addAlphaToHex(theme.colorPrimaryBg, 30) : 'none',
106
- cursor: 'pointer',
107
- };
108
- Object.assign(label.style, labelStyle);
109
- container.appendChild(label);
110
- const input = document.createElement('input');
111
- const inputStyle: CSS.Properties = { ...fullSize, position: 'absolute', top: '50%' };
112
- Object.assign(input.style, inputStyle);
113
- input.tabIndex = tabIndex || 0;
114
- input.type = 'file';
115
- input.accept = 'image/jpeg, image/png';
116
- input.addEventListener('change', (event: Event) => {
117
- const changeEvent = event as unknown as ChangeEvent<HTMLInputElement>;
118
- readFile(changeEvent.target.files).then((result) => onChange && onChange(result as string));
119
- });
120
- input.addEventListener('blur', () => stopEditing && stopEditing());
121
- label.appendChild(input);
122
- }
123
- };
@@ -1 +0,0 @@
1
- export const DEFAULT_LINE_COLOR = '#000000';
package/src/line/index.ts DELETED
@@ -1,8 +0,0 @@
1
- import type { Plugin } from '@pdfme/common';
2
- import { pdfRender } from './pdfRender.js';
3
- import { propPanel } from './propPanel.js';
4
- import { uiRender } from './uiRender.js';
5
- import type { LineSchema } from './types.js';
6
-
7
- const schema: Plugin<LineSchema> = { pdf: pdfRender, ui: uiRender, propPanel };
8
- export default schema;
@@ -1,24 +0,0 @@
1
- import type { PDFRenderProps } from '@pdfme/common';
2
- import type { LineSchema } from './types';
3
- import { rotatePoint, convertForPdfLayoutProps, hex2RgbColor } from '../renderUtils.js';
4
- import { DEFAULT_LINE_COLOR } from './constants.js';
5
-
6
- export const pdfRender = (arg: PDFRenderProps<LineSchema>) => {
7
- const { page, schema } = arg;
8
- const pageHeight = page.getHeight();
9
- const {
10
- width,
11
- height,
12
- rotate,
13
- position: { x, y },
14
- opacity,
15
- } = convertForPdfLayoutProps({ schema, pageHeight, applyRotateTranslate: false });
16
- const pivot = { x: x + width / 2, y: y + height / 2 };
17
- page.drawLine({
18
- start: rotatePoint({ x, y: y + height / 2 }, pivot, rotate.angle),
19
- end: rotatePoint({ x: x + width, y: y + height / 2 }, pivot, rotate.angle),
20
- thickness: height,
21
- color: hex2RgbColor(schema.color ?? DEFAULT_LINE_COLOR),
22
- opacity: opacity,
23
- });
24
- };
@@ -1,34 +0,0 @@
1
- import { PropPanel } from '@pdfme/common';
2
- import type { LineSchema } from './types';
3
- import { HEX_COLOR_PATTERN } from '../constants.js';
4
- import { DEFAULT_LINE_COLOR } from './constants.js';
5
-
6
- export const propPanel: PropPanel<LineSchema> = {
7
- schema: ({ i18n }) => {
8
- return {
9
- color: {
10
- title: i18n('schemas.line.color'),
11
- type: 'string',
12
- widget: 'color',
13
- required: true,
14
- rules: [
15
- {
16
- pattern: HEX_COLOR_PATTERN,
17
- message: i18n('hexColorPrompt'),
18
- },
19
- ],
20
- },
21
- };
22
- },
23
- defaultValue: '',
24
- defaultSchema: {
25
- type: 'line',
26
- position: { x: 0, y: 0 },
27
- width: 50,
28
- height: 1,
29
- rotate: 0,
30
- opacity: 1,
31
- readOnly: true,
32
- color: DEFAULT_LINE_COLOR,
33
- },
34
- };
package/src/line/types.ts DELETED
@@ -1,5 +0,0 @@
1
- import { Schema } from '@pdfme/common';
2
-
3
- export interface LineSchema extends Schema {
4
- color: string;
5
- }
@@ -1,12 +0,0 @@
1
- import type { LineSchema } from './types';
2
- import { UIRenderProps } from '@pdfme/common';
3
- import { DEFAULT_LINE_COLOR } from './constants.js';
4
-
5
- export const uiRender = (arg: UIRenderProps<LineSchema>) => {
6
- const { schema, rootElement } = arg;
7
- const div = document.createElement('div');
8
- div.style.backgroundColor = schema.color ?? DEFAULT_LINE_COLOR;
9
- div.style.width = '100%';
10
- div.style.height = '100%';
11
- rootElement.appendChild(div);
12
- };