@things-factory/barcode-ui 4.3.227 → 4.3.248
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.
|
@@ -9,7 +9,9 @@ export class BarcodeInput extends LitElement {
|
|
|
9
9
|
bcWidth: Number,
|
|
10
10
|
bcheight: Number,
|
|
11
11
|
bcScale: Number,
|
|
12
|
-
value: String
|
|
12
|
+
value: String,
|
|
13
|
+
showLogo: Boolean,
|
|
14
|
+
logo: String
|
|
13
15
|
}
|
|
14
16
|
}
|
|
15
17
|
|
|
@@ -49,6 +51,8 @@ export class BarcodeInput extends LitElement {
|
|
|
49
51
|
.bcWidth=${this.bcWidth}
|
|
50
52
|
.bcHeight=${this.bcHeight}
|
|
51
53
|
.bcScale=${this.bcScale}
|
|
54
|
+
.showLogo=${this.showLogo}
|
|
55
|
+
.logo=${this.logo}
|
|
52
56
|
></barcode-tag>
|
|
53
57
|
`
|
|
54
58
|
}
|
|
@@ -10,7 +10,9 @@ export class BarcodeTag extends LitElement {
|
|
|
10
10
|
bcScale: Number,
|
|
11
11
|
value: String,
|
|
12
12
|
validity: Boolean,
|
|
13
|
-
padding: Number
|
|
13
|
+
padding: Number,
|
|
14
|
+
showLogo: Boolean,
|
|
15
|
+
logo: String
|
|
14
16
|
}
|
|
15
17
|
}
|
|
16
18
|
|
|
@@ -55,7 +57,7 @@ export class BarcodeTag extends LitElement {
|
|
|
55
57
|
this.addEventListener('click', this._downloadQR)
|
|
56
58
|
}
|
|
57
59
|
|
|
58
|
-
_downloadQR() {
|
|
60
|
+
async _downloadQR() {
|
|
59
61
|
if (this.value && this.value != '') {
|
|
60
62
|
let link = document.createElement('a')
|
|
61
63
|
let canvas = this.shadowRoot.querySelector('canvas')
|
|
@@ -72,6 +74,9 @@ export class BarcodeTag extends LitElement {
|
|
|
72
74
|
backgroundcolor: 'ffffff'
|
|
73
75
|
}
|
|
74
76
|
canvas = bwipjs.toCanvas(canvas, options)
|
|
77
|
+
if (this.showLogo) {
|
|
78
|
+
await this.insertLogo(canvas)
|
|
79
|
+
}
|
|
75
80
|
|
|
76
81
|
link.download = `${this.value}` + '-barcode.png'
|
|
77
82
|
link.href = canvas.toDataURL()
|
|
@@ -85,6 +90,10 @@ export class BarcodeTag extends LitElement {
|
|
|
85
90
|
// includetext: true,
|
|
86
91
|
textalign: 'center'
|
|
87
92
|
})
|
|
93
|
+
|
|
94
|
+
if (this.showLogo) {
|
|
95
|
+
await this.insertLogo(canvas)
|
|
96
|
+
}
|
|
88
97
|
}
|
|
89
98
|
}
|
|
90
99
|
|
|
@@ -103,6 +112,9 @@ export class BarcodeTag extends LitElement {
|
|
|
103
112
|
try {
|
|
104
113
|
bwipjs.toCanvas(canvas, options)
|
|
105
114
|
|
|
115
|
+
if (this.showLogo) {
|
|
116
|
+
this.insertLogo(canvas)
|
|
117
|
+
}
|
|
106
118
|
this.validity = true
|
|
107
119
|
} catch (err) {
|
|
108
120
|
console.error(err)
|
|
@@ -110,6 +122,30 @@ export class BarcodeTag extends LitElement {
|
|
|
110
122
|
this.validity = false
|
|
111
123
|
}
|
|
112
124
|
}
|
|
125
|
+
|
|
126
|
+
async insertLogo(canvas) {
|
|
127
|
+
let context = canvas.getContext('2d')
|
|
128
|
+
let base_image = new Image()
|
|
129
|
+
base_image.src = this.logo || '/assets/manifest/icon-96x96.png'
|
|
130
|
+
|
|
131
|
+
let imageSize = {
|
|
132
|
+
width: canvas.width / 6,
|
|
133
|
+
height: canvas.height / 6
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
let logoSize = [
|
|
137
|
+
(canvas.width - imageSize.width) / 2,
|
|
138
|
+
(canvas.height - imageSize.height) / 2,
|
|
139
|
+
imageSize.width,
|
|
140
|
+
imageSize.height
|
|
141
|
+
]
|
|
142
|
+
|
|
143
|
+
context.fillStyle = '#ffffff'
|
|
144
|
+
context.fillRect(...logoSize)
|
|
145
|
+
|
|
146
|
+
await base_image.decode()
|
|
147
|
+
context.drawImage(base_image, ...logoSize)
|
|
148
|
+
}
|
|
113
149
|
}
|
|
114
150
|
|
|
115
151
|
customElements.define('barcode-tag', BarcodeTag)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@things-factory/barcode-ui",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.248",
|
|
4
4
|
"main": "dist-server/index.js",
|
|
5
5
|
"browser": "client/index.js",
|
|
6
6
|
"things-factory": true,
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@operato/layout": "^0.4.6",
|
|
27
|
-
"@things-factory/shell": "^4.3.
|
|
27
|
+
"@things-factory/shell": "^4.3.237",
|
|
28
28
|
"bwip-js": "^2.0.11"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "c45a9863ca451fa4d4fe3dbc797d7cc883b5bfd5"
|
|
31
31
|
}
|