@softwear/latestcollectioncore 1.0.175 → 1.0.177
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/index.d.ts +3 -0
- package/dist/index.js +5 -1
- package/dist/pdf.d.ts +69 -0
- package/dist/pdf.js +2 -0
- package/dist/reports.d.ts +35 -0
- package/dist/reports.js +724 -0
- package/package.json +3 -2
- package/src/index.ts +3 -0
- package/src/pdf.ts +78 -0
- package/src/reports.ts +859 -0
- package/test/reports.spec.ts +141 -0
- package/test.pdf +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@softwear/latestcollectioncore",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.177",
|
|
4
4
|
"description": "Core functions for LatestCollections applications",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"date-fns": "^2.29.3",
|
|
40
|
-
"filtrex": "^2.2.3"
|
|
40
|
+
"filtrex": "^2.2.3",
|
|
41
|
+
"jspdf": "^4.2.1"
|
|
41
42
|
}
|
|
42
43
|
}
|
package/src/index.ts
CHANGED
|
@@ -14,9 +14,12 @@ export { default as hasOnlyDigits } from './hasOnlyDigits'
|
|
|
14
14
|
export { default as imageBinder } from './imageBinder'
|
|
15
15
|
export { default as isean13 } from './isean13'
|
|
16
16
|
export { default as pivotTable } from './pivotTable'
|
|
17
|
+
export { default as reports, genPDF } from './reports'
|
|
17
18
|
export { default as round2 } from './round2'
|
|
18
19
|
export { default as sizeToMap } from './sizeToMap'
|
|
19
20
|
export { default as transaction } from './transaction'
|
|
21
|
+
export * from './pdf'
|
|
22
|
+
export type { GenPdfAlert, GenPdfOptions, PdfFontDefinition, PdfFontVariant, PdfImageAsset } from './reports'
|
|
20
23
|
export * from './types'
|
|
21
24
|
export * from './consts'
|
|
22
25
|
export {
|
package/src/pdf.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export interface PaperSize {
|
|
2
|
+
width: number
|
|
3
|
+
height: number
|
|
4
|
+
footerHeight: number
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export type TextAlign = 1 | 2 | 3 // 1: left, 2: center, 3: right
|
|
8
|
+
export type ObjectType = 'text' | 'field' | 'rectangle' | 'image' | 'container'
|
|
9
|
+
export type RepeatContainer = 'horizontal' | 'vertical' | undefined
|
|
10
|
+
|
|
11
|
+
export interface BaseLayoutObject {
|
|
12
|
+
type: ObjectType
|
|
13
|
+
x: number
|
|
14
|
+
y: number
|
|
15
|
+
width: number
|
|
16
|
+
height: number
|
|
17
|
+
active?: boolean
|
|
18
|
+
snapToBottom?: boolean
|
|
19
|
+
name?: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface TextLayoutObject extends BaseLayoutObject {
|
|
23
|
+
type: 'text'
|
|
24
|
+
text: string
|
|
25
|
+
textAlign?: TextAlign
|
|
26
|
+
fontFamily: string
|
|
27
|
+
fontSize: number
|
|
28
|
+
fontStyle: number
|
|
29
|
+
case?: 1 | 2 // 1: uppercase, 2: lowercase
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface FieldLayoutObject extends BaseLayoutObject {
|
|
33
|
+
type: 'field'
|
|
34
|
+
source?: string
|
|
35
|
+
format?: 'date' | 'currency'
|
|
36
|
+
textAlign?: TextAlign
|
|
37
|
+
fontFamily: string
|
|
38
|
+
fontSize: number
|
|
39
|
+
fontStyle: number
|
|
40
|
+
case?: 1 | 2
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface RectangleLayoutObject extends BaseLayoutObject {
|
|
44
|
+
type: 'rectangle'
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface ImageLayoutObject extends BaseLayoutObject {
|
|
48
|
+
type: 'image'
|
|
49
|
+
url?: string
|
|
50
|
+
image?: HTMLImageElement
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface ContainerLayoutObject extends BaseLayoutObject {
|
|
54
|
+
type: 'container'
|
|
55
|
+
source: string
|
|
56
|
+
children: LayoutObject[]
|
|
57
|
+
repeatContainer?: RepeatContainer
|
|
58
|
+
repeatOnOverflow?: boolean
|
|
59
|
+
pageBreak?: boolean
|
|
60
|
+
/** Minimum mm of remaining space before drawing next item; if less, break to next page first */
|
|
61
|
+
minHeightBeforeBreak?: number
|
|
62
|
+
/** When true, container and children are drawn only once at the end of the report, not on every page */
|
|
63
|
+
printOnlyAtEnd?: boolean
|
|
64
|
+
/** When true, container and children are drawn only once before other body containers (first page header block) */
|
|
65
|
+
printOnlyAtStart?: boolean
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export type LayoutObject = TextLayoutObject | FieldLayoutObject | RectangleLayoutObject | ImageLayoutObject | ContainerLayoutObject
|
|
69
|
+
|
|
70
|
+
export interface Layout {
|
|
71
|
+
name?: string
|
|
72
|
+
group?: string
|
|
73
|
+
paperSize: PaperSize
|
|
74
|
+
objects: LayoutObject[]
|
|
75
|
+
active?: boolean
|
|
76
|
+
/** Default font for text/field objects that have no fontFamily. E.g. 'Inter', 'Helvetica'. */
|
|
77
|
+
defaultFontFamily?: string
|
|
78
|
+
}
|