@pdfme/schemas 3.2.3 → 4.0.0-alpha.0
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__/text.test.js +5 -4
- package/dist/cjs/__tests__/text.test.js.map +1 -1
- package/dist/cjs/__tests__/utils.test.js +3 -0
- package/dist/cjs/__tests__/utils.test.js.map +1 -1
- package/dist/cjs/src/barcodes/propPanel.js +11 -11
- package/dist/cjs/src/barcodes/propPanel.js.map +1 -1
- package/dist/cjs/src/barcodes/uiRender.js +1 -1
- package/dist/cjs/src/barcodes/uiRender.js.map +1 -1
- package/dist/cjs/src/graphics/image.js +5 -11
- package/dist/cjs/src/graphics/image.js.map +1 -1
- package/dist/cjs/src/graphics/svg.js +2 -3
- package/dist/cjs/src/graphics/svg.js.map +1 -1
- package/dist/cjs/src/index.js +6 -1
- package/dist/cjs/src/index.js.map +1 -1
- package/dist/cjs/src/shapes/line.js +5 -9
- package/dist/cjs/src/shapes/line.js.map +1 -1
- package/dist/cjs/src/shapes/rectAndEllipse.js +3 -2
- package/dist/cjs/src/shapes/rectAndEllipse.js.map +1 -1
- package/dist/cjs/src/tables/cell.js +125 -0
- package/dist/cjs/src/tables/cell.js.map +1 -0
- package/dist/cjs/src/tables/classes.js +467 -0
- package/dist/cjs/src/tables/classes.js.map +1 -0
- package/dist/cjs/src/tables/dynamicTemplate.js +71 -0
- package/dist/cjs/src/tables/dynamicTemplate.js.map +1 -0
- package/dist/cjs/src/tables/helper.js +171 -0
- package/dist/cjs/src/tables/helper.js.map +1 -0
- package/dist/cjs/src/tables/index.js +12 -0
- package/dist/cjs/src/tables/index.js.map +1 -0
- package/dist/cjs/src/tables/pdfRender.js +95 -0
- package/dist/cjs/src/tables/pdfRender.js.map +1 -0
- package/dist/cjs/src/tables/propPanel.js +87 -0
- package/dist/cjs/src/tables/propPanel.js.map +1 -0
- package/dist/cjs/src/tables/tableHelper.js +231 -0
- package/dist/cjs/src/tables/tableHelper.js.map +1 -0
- package/dist/cjs/src/tables/types.js +3 -0
- package/dist/cjs/src/tables/types.js.map +1 -0
- package/dist/cjs/src/tables/uiRender.js +321 -0
- package/dist/cjs/src/tables/uiRender.js.map +1 -0
- package/dist/cjs/src/text/helper.js +21 -6
- package/dist/cjs/src/text/helper.js.map +1 -1
- package/dist/cjs/src/text/index.js +0 -1
- package/dist/cjs/src/text/index.js.map +1 -1
- package/dist/cjs/src/text/pdfRender.js +5 -8
- package/dist/cjs/src/text/pdfRender.js.map +1 -1
- package/dist/cjs/src/text/propPanel.js +6 -4
- package/dist/cjs/src/text/propPanel.js.map +1 -1
- package/dist/cjs/src/text/uiRender.js +18 -17
- package/dist/cjs/src/text/uiRender.js.map +1 -1
- package/dist/cjs/src/utils.js +9 -1
- package/dist/cjs/src/utils.js.map +1 -1
- package/dist/esm/__tests__/text.test.js +5 -4
- package/dist/esm/__tests__/text.test.js.map +1 -1
- package/dist/esm/__tests__/utils.test.js +3 -0
- package/dist/esm/__tests__/utils.test.js.map +1 -1
- package/dist/esm/src/barcodes/propPanel.js +11 -11
- package/dist/esm/src/barcodes/propPanel.js.map +1 -1
- package/dist/esm/src/barcodes/uiRender.js +1 -1
- package/dist/esm/src/barcodes/uiRender.js.map +1 -1
- package/dist/esm/src/graphics/image.js +4 -10
- package/dist/esm/src/graphics/image.js.map +1 -1
- package/dist/esm/src/graphics/svg.js +2 -3
- package/dist/esm/src/graphics/svg.js.map +1 -1
- package/dist/esm/src/index.js +3 -1
- package/dist/esm/src/index.js.map +1 -1
- package/dist/esm/src/shapes/line.js +5 -9
- package/dist/esm/src/shapes/line.js.map +1 -1
- package/dist/esm/src/shapes/rectAndEllipse.js +3 -2
- package/dist/esm/src/shapes/rectAndEllipse.js.map +1 -1
- package/dist/esm/src/tables/cell.js +120 -0
- package/dist/esm/src/tables/cell.js.map +1 -0
- package/dist/esm/src/tables/classes.js +460 -0
- package/dist/esm/src/tables/classes.js.map +1 -0
- package/dist/esm/src/tables/dynamicTemplate.js +66 -0
- package/dist/esm/src/tables/dynamicTemplate.js.map +1 -0
- package/dist/esm/src/tables/helper.js +163 -0
- package/dist/esm/src/tables/helper.js.map +1 -0
- package/dist/esm/src/tables/index.js +10 -0
- package/dist/esm/src/tables/index.js.map +1 -0
- package/dist/esm/src/tables/pdfRender.js +88 -0
- package/dist/esm/src/tables/pdfRender.js.map +1 -0
- package/dist/esm/src/tables/propPanel.js +84 -0
- package/dist/esm/src/tables/propPanel.js.map +1 -0
- package/dist/esm/src/tables/tableHelper.js +226 -0
- package/dist/esm/src/tables/tableHelper.js.map +1 -0
- package/dist/esm/src/tables/types.js +2 -0
- package/dist/esm/src/tables/types.js.map +1 -0
- package/dist/esm/src/tables/uiRender.js +314 -0
- package/dist/esm/src/tables/uiRender.js.map +1 -0
- package/dist/esm/src/text/helper.js +19 -5
- package/dist/esm/src/text/helper.js.map +1 -1
- package/dist/esm/src/text/index.js +0 -1
- package/dist/esm/src/text/index.js.map +1 -1
- package/dist/esm/src/text/pdfRender.js +6 -9
- package/dist/esm/src/text/pdfRender.js.map +1 -1
- package/dist/esm/src/text/propPanel.js +6 -4
- package/dist/esm/src/text/propPanel.js.map +1 -1
- package/dist/esm/src/text/uiRender.js +19 -18
- package/dist/esm/src/text/uiRender.js.map +1 -1
- package/dist/esm/src/utils.js +6 -0
- package/dist/esm/src/utils.js.map +1 -1
- package/dist/types/src/index.d.ts +3 -1
- package/dist/types/src/shapes/rectAndEllipse.d.ts +13 -27
- package/dist/types/src/tables/cell.d.ts +4 -0
- package/dist/types/src/tables/classes.d.ts +68 -0
- package/dist/types/src/tables/dynamicTemplate.d.ts +13 -0
- package/dist/types/src/tables/helper.d.ts +252 -0
- package/dist/types/src/tables/index.d.ts +4 -0
- package/dist/types/src/tables/pdfRender.d.ts +3 -0
- package/dist/types/src/tables/propPanel.d.ts +3 -0
- package/dist/types/src/tables/tableHelper.d.ts +11 -0
- package/dist/types/src/tables/types.d.ts +91 -0
- package/dist/types/src/tables/uiRender.d.ts +3 -0
- package/dist/types/src/text/helper.d.ts +8 -1
- package/dist/types/src/utils.d.ts +2 -0
- package/package.json +1 -1
- package/src/barcodes/propPanel.ts +12 -12
- package/src/barcodes/uiRender.ts +1 -1
- package/src/graphics/image.ts +6 -11
- package/src/graphics/svg.ts +2 -3
- package/src/index.ts +5 -0
- package/src/shapes/line.ts +4 -9
- package/src/shapes/rectAndEllipse.ts +4 -4
- package/src/tables/cell.ts +157 -0
- package/src/tables/classes.ts +398 -0
- package/src/tables/dynamicTemplate.ts +81 -0
- package/src/tables/helper.ts +198 -0
- package/src/tables/index.ts +12 -0
- package/src/tables/pdfRender.ts +115 -0
- package/src/tables/propPanel.ts +90 -0
- package/src/tables/tableHelper.ts +322 -0
- package/src/tables/types.ts +88 -0
- package/src/tables/uiRender.ts +362 -0
- package/src/text/helper.ts +30 -6
- package/src/text/index.ts +0 -1
- package/src/text/pdfRender.ts +7 -11
- package/src/text/propPanel.ts +6 -4
- package/src/text/uiRender.ts +18 -18
- package/src/utils.ts +8 -0
@@ -0,0 +1,71 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getDynamicHeightForTable = exports.modifyTemplateForTable = void 0;
|
4
|
+
const tableHelper_1 = require("./tableHelper");
|
5
|
+
const utils_1 = require("../utils");
|
6
|
+
const helper_js_1 = require("./helper.js");
|
7
|
+
const modifyTemplateForTable = async (arg) => {
|
8
|
+
const { template: t, input, options, _cache } = arg;
|
9
|
+
const template = Object.assign((0, utils_1.cloneDeep)(t), { schemas: [] });
|
10
|
+
let pageIndex = 0;
|
11
|
+
for (const schemaObj of t.schemas) {
|
12
|
+
const additionalSchemaObjs = [];
|
13
|
+
for (const [key, schema] of Object.entries(schemaObj)) {
|
14
|
+
if (schema.type === 'table') {
|
15
|
+
schema.__bodyRange = undefined;
|
16
|
+
const body = JSON.parse(input?.[key] || '[]');
|
17
|
+
const tables = await (0, tableHelper_1.createMultiTables)(body, {
|
18
|
+
schema,
|
19
|
+
basePdf: template.basePdf,
|
20
|
+
options,
|
21
|
+
_cache,
|
22
|
+
});
|
23
|
+
if (tables.length > 1) {
|
24
|
+
const firstTable = tables[0];
|
25
|
+
schema.__bodyRange = { start: 0, end: firstTable.body.length };
|
26
|
+
const allBodies = tables.map((table) => table.body);
|
27
|
+
const from2ndTable = tables.slice(1);
|
28
|
+
from2ndTable.forEach((table, i) => {
|
29
|
+
const additionalPageIndex = pageIndex + i + 1;
|
30
|
+
const additionalSchemaObj = {
|
31
|
+
[key]: {
|
32
|
+
...schema,
|
33
|
+
position: { x: schema.position.x, y: table.settings.startY },
|
34
|
+
height: table.getHeight(),
|
35
|
+
showHead: false,
|
36
|
+
__bodyRange: {
|
37
|
+
start: allBodies.slice(0, i + 1).reduce((acc, cur) => acc + cur.length, 0),
|
38
|
+
end: allBodies.slice(0, i + 2).reduce((acc, cur) => acc + cur.length, 0),
|
39
|
+
},
|
40
|
+
content: input[key],
|
41
|
+
},
|
42
|
+
};
|
43
|
+
additionalSchemaObjs[additionalPageIndex] = additionalSchemaObj;
|
44
|
+
});
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
48
|
+
template.schemas.push(schemaObj);
|
49
|
+
additionalSchemaObjs.forEach((obj, index) => {
|
50
|
+
if (!template.schemas[index]) {
|
51
|
+
template.schemas[index] = obj;
|
52
|
+
}
|
53
|
+
else {
|
54
|
+
template.schemas[index] = { ...template.schemas[index], ...obj };
|
55
|
+
}
|
56
|
+
});
|
57
|
+
pageIndex++;
|
58
|
+
}
|
59
|
+
return template;
|
60
|
+
};
|
61
|
+
exports.modifyTemplateForTable = modifyTemplateForTable;
|
62
|
+
const getDynamicHeightForTable = async (value, args) => {
|
63
|
+
if (args.schema.type !== 'table')
|
64
|
+
return Promise.resolve(args.schema.height);
|
65
|
+
const schema = args.schema;
|
66
|
+
const body = schema.__bodyRange?.start === 0 ? (0, helper_js_1.getBody)(value) : (0, helper_js_1.getBodyWithRange)(value, schema.__bodyRange);
|
67
|
+
const table = await (0, tableHelper_1.createSingleTable)(body, args);
|
68
|
+
return table.getHeight();
|
69
|
+
};
|
70
|
+
exports.getDynamicHeightForTable = getDynamicHeightForTable;
|
71
|
+
//# sourceMappingURL=dynamicTemplate.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"dynamicTemplate.js","sourceRoot":"","sources":["../../../../src/tables/dynamicTemplate.ts"],"names":[],"mappings":";;;AACA,+CAAqE;AACrE,oCAAqC;AACrC,2CAAwD;AAEjD,MAAM,sBAAsB,GAAG,KAAK,EAAE,GAK5C,EAAqB,EAAE;IACtB,MAAM,EAAE,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;IACpD,MAAM,QAAQ,GAAa,MAAM,CAAC,MAAM,CAAC,IAAA,iBAAS,EAAC,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC;IACxE,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,KAAK,MAAM,SAAS,IAAI,CAAC,CAAC,OAAO,EAAE;QACjC,MAAM,oBAAoB,GAAyB,EAAE,CAAC;QACtD,KAAK,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;YACrD,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO,EAAE;gBAC3B,MAAM,CAAC,WAAW,GAAG,SAAS,CAAC;gBAC/B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,IAAI,IAAI,CAAe,CAAC;gBAC5D,MAAM,MAAM,GAAG,MAAM,IAAA,+BAAiB,EAAC,IAAI,EAAE;oBAC3C,MAAM;oBACN,OAAO,EAAE,QAAQ,CAAC,OAAO;oBACzB,OAAO;oBACP,MAAM;iBACP,CAAC,CAAC;gBACH,IAAI,MAAM,CAAC,MAAM,GAAG,C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4BAenC"}
|
@@ -0,0 +1,171 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getBodyWithRange = exports.getBody = exports.getColumnStylesPropPanelSchema = exports.getCellPropPanelSchema = exports.getDefaultCellStyles = void 0;
|
4
|
+
const constants_1 = require("../text/constants");
|
5
|
+
const constants_js_1 = require("../constants.js");
|
6
|
+
const getDefaultCellStyles = () => ({
|
7
|
+
fontName: undefined,
|
8
|
+
alignment: constants_1.DEFAULT_ALIGNMENT,
|
9
|
+
verticalAlignment: constants_1.VERTICAL_ALIGN_MIDDLE,
|
10
|
+
fontSize: constants_1.DEFAULT_FONT_SIZE,
|
11
|
+
lineHeight: constants_1.DEFAULT_LINE_HEIGHT,
|
12
|
+
characterSpacing: constants_1.DEFAULT_CHARACTER_SPACING,
|
13
|
+
fontColor: constants_1.DEFAULT_FONT_COLOR,
|
14
|
+
backgroundColor: '',
|
15
|
+
borderColor: '#888888',
|
16
|
+
borderWidth: { top: 0.1, bottom: 0.1, left: 0.1, right: 0.1 },
|
17
|
+
padding: { top: 5, bottom: 5, left: 5, right: 5 },
|
18
|
+
});
|
19
|
+
exports.getDefaultCellStyles = getDefaultCellStyles;
|
20
|
+
const getBoxDimensionProp = (step = 1) => {
|
21
|
+
const getCommonProp = () => ({
|
22
|
+
type: 'number',
|
23
|
+
widget: 'inputNumber',
|
24
|
+
props: { min: 0, step },
|
25
|
+
span: 6,
|
26
|
+
});
|
27
|
+
return {
|
28
|
+
top: { title: 'Top', ...getCommonProp() },
|
29
|
+
right: { title: 'Right', ...getCommonProp() },
|
30
|
+
bottom: { title: 'Bottom', ...getCommonProp() },
|
31
|
+
left: { title: 'Left', ...getCommonProp() },
|
32
|
+
};
|
33
|
+
};
|
34
|
+
const getCellPropPanelSchema = (arg) => {
|
35
|
+
const { i18n, fallbackFontName, fontNames, isBody } = arg;
|
36
|
+
return {
|
37
|
+
fontName: {
|
38
|
+
title: i18n('schemas.text.fontName'),
|
39
|
+
type: 'string',
|
40
|
+
widget: 'select',
|
41
|
+
default: fallbackFontName,
|
42
|
+
props: { options: fontNames.map((name) => ({ label: name, value: name })) },
|
43
|
+
span: 12,
|
44
|
+
},
|
45
|
+
fontSize: {
|
46
|
+
title: i18n('schemas.text.size'),
|
47
|
+
type: 'number',
|
48
|
+
widget: 'inputNumber',
|
49
|
+
props: { min: 0 },
|
50
|
+
span: 6,
|
51
|
+
},
|
52
|
+
characterSpacing: {
|
53
|
+
title: i18n('schemas.text.spacing'),
|
54
|
+
type: 'number',
|
55
|
+
widget: 'inputNumber',
|
56
|
+
props: { min: 0 },
|
57
|
+
span: 6,
|
58
|
+
},
|
59
|
+
alignment: {
|
60
|
+
title: i18n('schemas.text.textAlign'),
|
61
|
+
type: 'string',
|
62
|
+
widget: 'select',
|
63
|
+
props: {
|
64
|
+
options: [
|
65
|
+
{ label: i18n('schemas.left'), value: constants_1.ALIGN_LEFT },
|
66
|
+
{ label: i18n('schemas.center'), value: constants_1.ALIGN_CENTER },
|
67
|
+
{ label: i18n('schemas.right'), value: constants_1.ALIGN_RIGHT },
|
68
|
+
],
|
69
|
+
},
|
70
|
+
span: 8,
|
71
|
+
},
|
72
|
+
verticalAlignment: {
|
73
|
+
title: i18n('schemas.text.verticalAlign'),
|
74
|
+
type: 'string',
|
75
|
+
widget: 'select',
|
76
|
+
props: {
|
77
|
+
options: [
|
78
|
+
{ label: i18n('schemas.top'), value: constants_1.VERTICAL_ALIGN_TOP },
|
79
|
+
{ label: i18n('schemas.middle'), value: constants_1.VERTICAL_ALIGN_MIDDLE },
|
80
|
+
{ label: i18n('schemas.bottom'), value: constants_1.VERTICAL_ALIGN_BOTTOM },
|
81
|
+
],
|
82
|
+
},
|
83
|
+
span: 8,
|
84
|
+
},
|
85
|
+
lineHeight: {
|
86
|
+
title: i18n('schemas.text.lineHeight'),
|
87
|
+
type: 'number',
|
88
|
+
widget: 'inputNumber',
|
89
|
+
props: { step: 0.1, min: 0 },
|
90
|
+
span: 8,
|
91
|
+
},
|
92
|
+
fontColor: {
|
93
|
+
title: i18n('schemas.textColor'),
|
94
|
+
type: 'string',
|
95
|
+
widget: 'color',
|
96
|
+
rules: [{ pattern: constants_js_1.HEX_COLOR_PATTERN, message: i18n('hexColorPrompt') }],
|
97
|
+
},
|
98
|
+
borderColor: {
|
99
|
+
title: i18n('schemas.borderColor'),
|
100
|
+
type: 'string',
|
101
|
+
widget: 'color',
|
102
|
+
rules: [{ pattern: constants_js_1.HEX_COLOR_PATTERN, message: i18n('hexColorPrompt') }],
|
103
|
+
},
|
104
|
+
backgroundColor: {
|
105
|
+
title: i18n('schemas.backgroundColor'),
|
106
|
+
type: 'string',
|
107
|
+
widget: 'color',
|
108
|
+
rules: [{ pattern: constants_js_1.HEX_COLOR_PATTERN, message: i18n('hexColorPrompt') }],
|
109
|
+
},
|
110
|
+
...(isBody
|
111
|
+
? {
|
112
|
+
alternateBackgroundColor: {
|
113
|
+
title: i18n('schemas.table.alternateBackgroundColor'),
|
114
|
+
type: 'string',
|
115
|
+
widget: 'color',
|
116
|
+
rules: [{ pattern: constants_js_1.HEX_COLOR_PATTERN, message: i18n('hexColorPrompt') }],
|
117
|
+
},
|
118
|
+
}
|
119
|
+
: {}),
|
120
|
+
'-': { type: 'void', widget: 'Divider' },
|
121
|
+
borderWidth: {
|
122
|
+
title: i18n('schemas.borderWidth'),
|
123
|
+
type: 'object',
|
124
|
+
widget: 'lineTitle',
|
125
|
+
span: 24,
|
126
|
+
properties: getBoxDimensionProp(0.1),
|
127
|
+
},
|
128
|
+
'--': { type: 'void', widget: 'Divider' },
|
129
|
+
padding: {
|
130
|
+
title: i18n('schemas.padding'),
|
131
|
+
type: 'object',
|
132
|
+
widget: 'lineTitle',
|
133
|
+
span: 24,
|
134
|
+
properties: getBoxDimensionProp(),
|
135
|
+
},
|
136
|
+
};
|
137
|
+
};
|
138
|
+
exports.getCellPropPanelSchema = getCellPropPanelSchema;
|
139
|
+
const getColumnStylesPropPanelSchema = ({ head, i18n, }) => ({
|
140
|
+
alignment: {
|
141
|
+
type: 'object',
|
142
|
+
widget: 'lineTitle',
|
143
|
+
title: i18n('schemas.text.textAlign'),
|
144
|
+
column: 3,
|
145
|
+
properties: head.reduce((acc, cur, i) => Object.assign(acc, {
|
146
|
+
[i]: {
|
147
|
+
title: cur || 'Column ' + String(i + 1),
|
148
|
+
type: 'string',
|
149
|
+
widget: 'select',
|
150
|
+
props: {
|
151
|
+
options: [
|
152
|
+
{ label: i18n('schemas.left'), value: constants_1.ALIGN_LEFT },
|
153
|
+
{ label: i18n('schemas.center'), value: constants_1.ALIGN_CENTER },
|
154
|
+
{ label: i18n('schemas.right'), value: constants_1.ALIGN_RIGHT },
|
155
|
+
],
|
156
|
+
},
|
157
|
+
},
|
158
|
+
}), {}),
|
159
|
+
},
|
160
|
+
});
|
161
|
+
exports.getColumnStylesPropPanelSchema = getColumnStylesPropPanelSchema;
|
162
|
+
const getBody = (value) => JSON.parse(value || '[]');
|
163
|
+
exports.getBody = getBody;
|
164
|
+
const getBodyWithRange = (value, range) => {
|
165
|
+
const body = (0, exports.getBody)(value);
|
166
|
+
if (!range)
|
167
|
+
return body;
|
168
|
+
return body.slice(range.start, range.end);
|
169
|
+
};
|
170
|
+
exports.getBodyWithRange = getBodyWithRange;
|
171
|
+
//# sourceMappingURL=helper.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"helper.js","sourceRoot":"","sources":["../../../../src/tables/helper.ts"],"names":[],"mappings":";;;AAAA,iDAY2B;AAC3B,kDAAoD;AAE7C,MAAM,oBAAoB,GAAG,GAAG,EAAE,CAAC,CAAC;IACzC,QAAQ,EAAE,SAAS;IACnB,SAAS,EAAE,6BAAiB;IAC5B,iBAAiB,EAAE,iCAAqB;IACxC,QAAQ,EAAE,6BAAiB;IAC3B,UAAU,EAAE,+BAAmB;IAC/B,gBAAgB,EAAE,qCAAyB;IAC3C,SAAS,EAAE,8BAAkB;IAC7B,eAAe,EAAE,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EAAE,KAAK,EAAE,IAAI,CAAC,cAAc,CAAC,EAAE,KAAK,EAAE,sBAAU,EAAE;wBAClD,EAAE,KAAK,EAAE,IAAI,CAAC,gBAAgB,CAAC,EAAE,KAAK,EAAE,wBAAY,EAAE;wBACtD,EAAE,KAAK,EAAE,IAAI,CAAC,eAAe,CAAC,EAAE,KAAK,EAAE,uBAAW,EAAE;qBACrD;iBACF;aACF;SACF,CAAC,EACJ,EAAE,CACH;KACF;CACF,CAAC,CAAC;AA/BU,QAAA,8BAA8B,kCA+BxC;AAEI,MAAM,OAAO,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,IAAI,CAAe,CAAC;AAArE,QAAA,OAAO,WAA8D;AAE3E,MAAM,gBAAgB,GAAG,CAC9B,KAAa,EACb,KAAmD,EACnD,EAAE;IACF,MAAM,IAAI,GAAG,IAAA,eAAO,EAAC,KAAK,CAAC,CAAC;IAC5B,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;AAC5C,CAAC,CAAC;AAPW,QAAA,gBAAgB,oBAO3B"}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const pdfRender_js_1 = require("./pdfRender.js");
|
4
|
+
const uiRender_js_1 = require("./uiRender.js");
|
5
|
+
const propPanel_js_1 = require("./propPanel.js");
|
6
|
+
const tableSchema = {
|
7
|
+
pdf: pdfRender_js_1.pdfRender,
|
8
|
+
ui: uiRender_js_1.uiRender,
|
9
|
+
propPanel: propPanel_js_1.propPanel,
|
10
|
+
};
|
11
|
+
exports.default = tableSchema;
|
12
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/tables/index.ts"],"names":[],"mappings":";;AAEA,iDAA2C;AAC3C,+CAAyC;AACzC,iDAA2C;AAE3C,MAAM,WAAW,GAAwB;IACvC,GAAG,EAAE,wBAAS;IACd,EAAE,EAAE,sBAAQ;IACZ,SAAS,EAAT,wBAAS;CACV,CAAC;AACF,kBAAe,WAAW,CAAC"}
|
@@ -0,0 +1,95 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
4
|
+
};
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
6
|
+
exports.pdfRender = void 0;
|
7
|
+
const rectAndEllipse_1 = require("../shapes/rectAndEllipse");
|
8
|
+
const cell_1 = __importDefault(require("./cell"));
|
9
|
+
const helper_1 = require("./helper");
|
10
|
+
const tableHelper_1 = require("./tableHelper");
|
11
|
+
const rectanglePdfRender = rectAndEllipse_1.rectangle.pdf;
|
12
|
+
const cellPdfRender = cell_1.default.pdf;
|
13
|
+
async function drawCell(arg, cell) {
|
14
|
+
// TODO Not considering the table border
|
15
|
+
// The cell's position and size should indeed be shifted to accommodate the table border
|
16
|
+
await cellPdfRender({
|
17
|
+
...arg,
|
18
|
+
value: cell.raw,
|
19
|
+
schema: {
|
20
|
+
type: 'cell',
|
21
|
+
position: { x: cell.x, y: cell.y },
|
22
|
+
width: cell.width,
|
23
|
+
height: cell.height,
|
24
|
+
fontName: cell.styles.fontName,
|
25
|
+
alignment: cell.styles.alignment,
|
26
|
+
verticalAlignment: cell.styles.verticalAlignment,
|
27
|
+
fontSize: cell.styles.fontSize,
|
28
|
+
lineHeight: cell.styles.lineHeight,
|
29
|
+
characterSpacing: cell.styles.characterSpacing,
|
30
|
+
backgroundColor: cell.styles.backgroundColor,
|
31
|
+
fontColor: cell.styles.textColor,
|
32
|
+
borderColor: cell.styles.lineColor,
|
33
|
+
borderWidth: cell.styles.lineWidth,
|
34
|
+
padding: cell.styles.cellPadding,
|
35
|
+
},
|
36
|
+
});
|
37
|
+
}
|
38
|
+
async function drawRow(arg, table, row, cursor, columns) {
|
39
|
+
cursor.x = table.settings.margin.left;
|
40
|
+
for (const column of columns) {
|
41
|
+
const cell = row.cells[column.index];
|
42
|
+
if (!cell) {
|
43
|
+
cursor.x += column.width;
|
44
|
+
continue;
|
45
|
+
}
|
46
|
+
cell.x = cursor.x;
|
47
|
+
cell.y = cursor.y;
|
48
|
+
await drawCell(arg, cell);
|
49
|
+
cursor.x += column.width;
|
50
|
+
}
|
51
|
+
cursor.y += row.height;
|
52
|
+
}
|
53
|
+
async function drawTableBorder(arg, table, startPos, cursor) {
|
54
|
+
const lineWidth = table.settings.tableLineWidth;
|
55
|
+
const lineColor = table.settings.tableLineColor;
|
56
|
+
if (!lineWidth || !lineColor)
|
57
|
+
return;
|
58
|
+
await rectanglePdfRender({
|
59
|
+
...arg,
|
60
|
+
schema: {
|
61
|
+
type: 'rectangle',
|
62
|
+
borderWidth: lineWidth,
|
63
|
+
borderColor: lineColor,
|
64
|
+
color: '',
|
65
|
+
position: { x: startPos.x, y: startPos.y },
|
66
|
+
width: table.getWidth(),
|
67
|
+
height: cursor.y - startPos.y,
|
68
|
+
readOnly: true,
|
69
|
+
},
|
70
|
+
});
|
71
|
+
}
|
72
|
+
async function drawTable(arg, table) {
|
73
|
+
const settings = table.settings;
|
74
|
+
const startY = settings.startY;
|
75
|
+
const margin = settings.margin;
|
76
|
+
const cursor = { x: margin.left, y: startY };
|
77
|
+
const startPos = Object.assign({}, cursor);
|
78
|
+
if (settings.showHead) {
|
79
|
+
for (const row of table.head) {
|
80
|
+
await drawRow(arg, table, row, cursor, table.columns);
|
81
|
+
}
|
82
|
+
}
|
83
|
+
for (const row of table.body) {
|
84
|
+
await drawRow(arg, table, row, cursor, table.columns);
|
85
|
+
}
|
86
|
+
await drawTableBorder(arg, table, startPos, cursor);
|
87
|
+
}
|
88
|
+
const pdfRender = async (arg) => {
|
89
|
+
const { value, schema } = arg;
|
90
|
+
const body = (0, helper_1.getBodyWithRange)(value, schema.__bodyRange);
|
91
|
+
const table = await (0, tableHelper_1.createSingleTable)(body, arg);
|
92
|
+
await drawTable(arg, table);
|
93
|
+
};
|
94
|
+
exports.pdfRender = pdfRender;
|
95
|
+
//# sourceMappingURL=pdfRender.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"pdfRender.js","sourceRoot":"","sources":["../../../../src/tables/pdfRender.ts"],"names":[],"mappings":";;;;;;AAGA,6DAAqD;AACrD,kDAA0B;AAC1B,qCAA4C;AAC5C,+CAAkD;AAIlD,MAAM,kBAAkB,GAAG,0BAAS,CAAC,GAAG,CAAC;AACzC,MAAM,aAAa,GAAG,cAAI,CAAC,GAAG,CAAC;AAE/B,KAAK,UAAU,QAAQ,CAAC,GAAgC,EAAE,IAAU;IAClE,wCAAwC;IACxC,wFAAwF;IACxF,MAAM,aAAa,CAAC;QAClB,GAAG,GAAG;QACN,KAAK,EAAE,IAAI,CAAC,GAAG;QACf,MAAM,EAAE;YACN,IAAI,EAAE,MAAM;YACZ,QAAQ,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE;YAClC,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ;YAC9B,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS;YAChC,iBAAiB,EAAE,IAAI,CAAC,MAAM,CAAC,iBAAiB;YAChD,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ;YAC9B,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU;YAClC,gBAAgB,EAAE,IAAI,CAAC,MAAM,CAAC,gBAAgB;YAC9C,eAAe,EAAE,IAAI,CAAC,MAAM,CAAC,eAAe;YAC5C,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,SA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AG,GAAG,CAAC;IAC9B,MAAM,IAAI,GAAG,IAAA,yBAAgB,EAAC,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IACzD,MAAM,KAAK,GAAG,MAAM,IAAA,+BAAiB,EAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IACjD,MAAM,SAAS,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AAC9B,CAAC,CAAC;AALW,QAAA,SAAS,aAKpB"}
|
@@ -0,0 +1,87 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.propPanel = void 0;
|
4
|
+
const common_1 = require("@pdfme/common");
|
5
|
+
const helper_js_1 = require("./helper.js");
|
6
|
+
const constants_js_1 = require("../constants.js");
|
7
|
+
exports.propPanel = {
|
8
|
+
schema: ({ activeSchema, options, i18n }) => {
|
9
|
+
// @ts-ignore
|
10
|
+
const head = (activeSchema.head || []);
|
11
|
+
const font = options.font || { [common_1.DEFAULT_FONT_NAME]: { data: '', fallback: true } };
|
12
|
+
const fontNames = Object.keys(font);
|
13
|
+
const fallbackFontName = (0, common_1.getFallbackFontName)(font);
|
14
|
+
return {
|
15
|
+
tableStyles: {
|
16
|
+
title: i18n('schemas.table.tableStyle'),
|
17
|
+
type: 'object',
|
18
|
+
widget: 'Card',
|
19
|
+
span: 24,
|
20
|
+
properties: {
|
21
|
+
borderWidth: {
|
22
|
+
title: i18n('schemas.borderWidth'),
|
23
|
+
type: 'number',
|
24
|
+
widget: 'inputNumber',
|
25
|
+
props: { min: 0, step: 0.1 },
|
26
|
+
step: 1,
|
27
|
+
},
|
28
|
+
borderColor: {
|
29
|
+
title: i18n('schemas.borderColor'),
|
30
|
+
type: 'string',
|
31
|
+
widget: 'color',
|
32
|
+
rules: [{ pattern: constants_js_1.HEX_COLOR_PATTERN, message: i18n('hexColorPrompt') }],
|
33
|
+
},
|
34
|
+
},
|
35
|
+
},
|
36
|
+
headStyles: {
|
37
|
+
title: i18n('schemas.table.headStyle'),
|
38
|
+
type: 'object',
|
39
|
+
widget: 'Card',
|
40
|
+
span: 24,
|
41
|
+
properties: (0, helper_js_1.getCellPropPanelSchema)({ i18n, fallbackFontName, fontNames }),
|
42
|
+
},
|
43
|
+
bodyStyles: {
|
44
|
+
title: i18n('schemas.table.bodyStyle'),
|
45
|
+
type: 'object',
|
46
|
+
widget: 'Card',
|
47
|
+
span: 24,
|
48
|
+
properties: (0, helper_js_1.getCellPropPanelSchema)({ i18n, fallbackFontName, fontNames, isBody: true }),
|
49
|
+
},
|
50
|
+
columnStyles: {
|
51
|
+
title: i18n('schemas.table.columnStyle'),
|
52
|
+
type: 'object',
|
53
|
+
widget: 'Card',
|
54
|
+
span: 24,
|
55
|
+
properties: (0, helper_js_1.getColumnStylesPropPanelSchema)({ head, i18n }),
|
56
|
+
},
|
57
|
+
};
|
58
|
+
},
|
59
|
+
defaultSchema: {
|
60
|
+
type: 'table',
|
61
|
+
position: { x: 0, y: 0 },
|
62
|
+
width: 150,
|
63
|
+
height: 20,
|
64
|
+
content: JSON.stringify([
|
65
|
+
['Alice', 'New York', 'Alice is a freelance web designer and developer'],
|
66
|
+
['Bob', 'Paris', 'Bob is a freelance illustrator and graphic designer'],
|
67
|
+
]),
|
68
|
+
showHead: true,
|
69
|
+
head: ['Name', 'City', 'Description'],
|
70
|
+
headWidthPercentages: [30, 30, 40],
|
71
|
+
tableStyles: {
|
72
|
+
borderColor: '#000000',
|
73
|
+
borderWidth: 0.3,
|
74
|
+
},
|
75
|
+
headStyles: Object.assign((0, helper_js_1.getDefaultCellStyles)(), {
|
76
|
+
fontColor: '#ffffff',
|
77
|
+
backgroundColor: '#2980ba',
|
78
|
+
borderColor: '',
|
79
|
+
borderWidth: { top: 0, right: 0, bottom: 0, left: 0 },
|
80
|
+
}),
|
81
|
+
bodyStyles: Object.assign((0, helper_js_1.getDefaultCellStyles)(), {
|
82
|
+
alternateBackgroundColor: '#f5f5f5',
|
83
|
+
}),
|
84
|
+
columnStyles: {},
|
85
|
+
},
|
86
|
+
};
|
87
|
+
//# sourceMappingURL=propPanel.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"propPanel.js","sourceRoot":"","sources":["../../../../src/tables/propPanel.ts"],"names":[],"mappings":";;;AAEA,0CAAuE;AACvE,2CAIqB;AACrB,kDAAoD;AAEvC,QAAA,SAAS,GAA2B;IAC/C,MAAM,EAAE,CAAC,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE;QAC1C,aAAa;QACb,MAAM,IAAI,GAAG,CAAC,YAAY,CAAC,IAAI,IAAI,EAAE,CAAa,CAAC;QACnD,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,0BAAiB,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC;QACnF,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpC,MAAM,gBAAgB,GAAG,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;QACnD,OAAO;YACL,WAAW,EAAE;gBACX,KAAK,EAAE,IAAI,CAAC,0BAA0B,CAAC;gBACvC,IAAI,EAAE,QAAQ;gBACd,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,EAAE;gBACR,UAAU,EAAE;oBACV,WAAW,EAAE;wBACX,KAAK,EAAE,IAAI,CAAC,qBAAqB,CAAC;wBAClC,IAAI,EAAE,QAAQ;wBACd,MAAM,EAAE,aAAa;wBACrB,KAAK,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE;wBAC5B,IAAI,EAAE,CAAC;qBACR;oBACD,WAAW,EAAE;wBACX,KAAK,EAAE,IAAI,CAAC,qBAAqB,CAAC;wBAClC,IAAI,EAAE,QAAQ;wBACd,MAAM,EAAE,OAAO;wBACf,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,gCAA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