@softwear/latestcollectioncore 1.0.175 → 1.0.176

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softwear/latestcollectioncore",
3
- "version": "1.0.175",
3
+ "version": "1.0.176",
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,76 @@
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
+ }
65
+
66
+ export type LayoutObject = TextLayoutObject | FieldLayoutObject | RectangleLayoutObject | ImageLayoutObject | ContainerLayoutObject
67
+
68
+ export interface Layout {
69
+ name?: string
70
+ group?: string
71
+ paperSize: PaperSize
72
+ objects: LayoutObject[]
73
+ active?: boolean
74
+ /** Default font for text/field objects that have no fontFamily. E.g. 'Inter', 'Helvetica'. */
75
+ defaultFontFamily?: string
76
+ }