@things-factory/barcode-ui 3.6.55 → 3.7.6

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.
@@ -1,6 +1,7 @@
1
- import { LitElement, html, css } from 'lit-element'
2
1
  import './barcode-tag'
3
2
 
3
+ import { css, html, LitElement } from 'lit-element'
4
+
4
5
  export class BarcodeInput extends LitElement {
5
6
  static get properties() {
6
7
  return {
@@ -41,7 +42,7 @@ export class BarcodeInput extends LitElement {
41
42
 
42
43
  render() {
43
44
  return html`
44
- <input type="text" @change=${this.onchange.bind(this)} />
45
+ <input type="text" @change=${this.onchange.bind(this)} .value=${this.value} />
45
46
  <barcode-tag
46
47
  .bcid=${this.bcid}
47
48
  .value=${this.value}
@@ -54,6 +55,7 @@ export class BarcodeInput extends LitElement {
54
55
 
55
56
  onchange(e) {
56
57
  this.value = e.target.value
58
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
57
59
  }
58
60
  }
59
61
 
@@ -108,7 +108,7 @@ export class BarcodeScanableInput extends LitElement {
108
108
  this.style.setProperty('--barcodescan-input-button-icon', `url(${barcodeIcon})`)
109
109
 
110
110
  return html`
111
- <input type="text" .value=${this.value || ''} maxlength="50" />
111
+ <input type="text" .value=${this.value || ''} maxlength="50" @change=${this.onchange.bind(this)} />
112
112
  <button
113
113
  ?hidden=${!this.scannable}
114
114
  id="scan-button"
@@ -119,6 +119,17 @@ export class BarcodeScanableInput extends LitElement {
119
119
  `
120
120
  }
121
121
 
122
+ onchange(e) {
123
+ this.value = e.target.value
124
+ this.dispatchEvent(
125
+ new CustomEvent('change', {
126
+ bubbles: true,
127
+ composed: true,
128
+ detail: this
129
+ })
130
+ )
131
+ }
132
+
122
133
  get input() {
123
134
  return this.shadowRoot.querySelector('input')
124
135
  }
@@ -147,10 +158,20 @@ export class BarcodeScanableInput extends LitElement {
147
158
  if (!popup.closed && this.stream) {
148
159
  var result = await this.reader.decodeOnceFromStream(this.stream, template.video)
149
160
 
150
- this.input.value = result
161
+ // this.input.value = result
162
+ this.value = result.text || ''
163
+
151
164
  if (!this.withoutEnter) {
152
165
  this.dispatchEvent(new KeyboardEvent('keypress', { keyCode: 0x0d }))
153
166
  }
167
+
168
+ this.dispatchEvent(
169
+ new CustomEvent('change', {
170
+ bubbles: true,
171
+ composed: true,
172
+ detail: this
173
+ })
174
+ )
154
175
  } else {
155
176
  /* popup이 비동기 진행 중에 close된 경우라면, stopScan()을 처리하지 못하게 되므로, 다시한번 clear해준다. */
156
177
  this.stopScan()
@@ -1,12 +1,12 @@
1
- import { LitElement, html, css } from 'lit-element'
2
1
  import bwipjs from '!bwip-js'
2
+ import { css, html, LitElement } from 'lit-element'
3
3
 
4
4
  export class BarcodeTag extends LitElement {
5
5
  static get properties() {
6
6
  return {
7
7
  bcid: String,
8
8
  bcWidth: Number,
9
- bcheight: Number,
9
+ bcHeight: Number,
10
10
  bcScale: Number,
11
11
  value: String,
12
12
  validity: Boolean,
package/client/index.js CHANGED
@@ -1,4 +1,3 @@
1
1
  export * from './components/barcode-tag'
2
2
  export * from './components/barcode-input'
3
- export * from './components/barcodescan-input'
4
3
  export * from './components/barcode-scanable-input'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/barcode-ui",
3
- "version": "3.6.55",
3
+ "version": "3.7.6",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -24,8 +24,8 @@
24
24
  "migration:create": "node ../../node_modules/typeorm/cli.js migration:create -d ./server/migrations"
25
25
  },
26
26
  "dependencies": {
27
- "@things-factory/layout-base": "^3.6.55",
27
+ "@things-factory/layout-base": "^3.7.5",
28
28
  "bwip-js": "^2.0.11"
29
29
  },
30
- "gitHead": "a835d6fbfc58a2bef6b1ecb96338cd572a77bdc0"
30
+ "gitHead": "d9d72c07fc3b01af2ede46808ec0aced3241ed51"
31
31
  }
@@ -1,12 +1,5 @@
1
1
  import bootstrap from './client/bootstrap'
2
- import route from './client/route'
2
+
3
3
  export default {
4
- bootstrap,
5
- route,
6
- routes: [
7
- {
8
- tagname: 'barcode-ui-test-page',
9
- page: 'barcode-ui-test'
10
- }
11
- ]
4
+ bootstrap
12
5
  }
@@ -1,124 +0,0 @@
1
- import { LitElement, html, css } from 'lit-element'
2
- import barcodeIcon from '../../assets/images/barcode.png'
3
-
4
- export class BarcodescanInput extends LitElement {
5
- static get properties() {
6
- return {
7
- name: {
8
- attribute: true
9
- },
10
- value: String
11
- }
12
- }
13
-
14
- static get styles() {
15
- return [
16
- css`
17
- :host {
18
- display: flex;
19
- align-items: center;
20
- border: none;
21
- overflow: hidden;
22
- background-color: #fff;
23
-
24
- padding: var(--custom-input-barcode-field-padding) !important;
25
- }
26
-
27
- * {
28
- align-self: stretch;
29
- }
30
-
31
- *:focus {
32
- outline: none;
33
- }
34
-
35
- input {
36
- flex: 1 !important;
37
- border: none;
38
- font: var(--custom-input-barcode-field-font);
39
- width: 10px;
40
- flex-grow: 1;
41
- }
42
-
43
- #scan-button {
44
- width: 30px;
45
- height: 24px;
46
- border: none;
47
- background-repeat: no-repeat;
48
- background-position: center;
49
- background-image: var(--barcodescan-input-button-icon);
50
- }
51
- `
52
- ]
53
- }
54
-
55
- connectedCallback() {
56
- super.connectedCallback()
57
-
58
- this._onBarcodeRespond = e => {
59
- var { value, responder } = e.detail
60
-
61
- if (responder != this.name) return
62
- this.value = value
63
- this.requestUpdate()
64
- }
65
-
66
- this._onFocusIn = e => {
67
- window.addEventListener('barcode-respond', this._onBarcodeRespond)
68
- }
69
-
70
- this._onFocusOut = e => {
71
- window.removeEventListener('barcode-respond', this._onBarcodeRespond)
72
- }
73
-
74
- this.renderRoot.addEventListener('focusin', this._onFocusIn)
75
- this.renderRoot.addEventListener('focusout', this._onFocusOut)
76
- }
77
-
78
- disconnectedCallback() {
79
- super.disconnectedCallback()
80
-
81
- if (this._onBarcodeRespond) {
82
- window.removeEventListener('barcode-respond', this._onBarcodeRespond)
83
- this._onBarcodeRespond = null
84
- }
85
- if (this._onFocusIn) {
86
- this.renderRoot.removeEventListener('focusin', this._onFocusIn)
87
- this._onFocusIn = null
88
- }
89
- if (this._onFocusOut) {
90
- this.renderRoot.removeEventListener('focusout', this._onFocusOut)
91
- this._onFocusOut = null
92
- }
93
- }
94
-
95
- render() {
96
- this.style.setProperty('--barcodescan-input-button-icon', `url(${barcodeIcon})`)
97
-
98
- return html`
99
- <input type="text" .value=${this.value || ''} />
100
- <button
101
- id="scan-button"
102
- @click=${e => {
103
- this.requestBarcodeScan(e)
104
- }}
105
- ></button>
106
- `
107
- }
108
-
109
- requestBarcodeScan(e) {
110
- if (!cordova_iab) throw 'no-app'
111
-
112
- cordova_iab.postMessage(
113
- JSON.stringify({
114
- type: 'scan-barcode',
115
- detail: {
116
- requester: this.name,
117
- barcodeTypes: []
118
- }
119
- })
120
- )
121
- }
122
- }
123
-
124
- customElements.define('barcodescan-input', BarcodescanInput)
@@ -1,65 +0,0 @@
1
- import { html, css } from 'lit-element'
2
- import gql from 'graphql-tag'
3
-
4
- import { connect } from 'pwa-helpers/connect-mixin.js'
5
- import { store, PageView, client } from '@things-factory/shell'
6
- import '../components/barcodescan-input'
7
-
8
- class BarcodeUiTestPage extends connect(store)(PageView) {
9
- static get properties() {
10
- return {}
11
- }
12
-
13
- static get styles() {
14
- return [
15
- css`
16
- :host {
17
- display: flex;
18
- flex-direction: column;
19
-
20
- width: 100%; /* 전체화면보기를 위해서 필요함. */
21
- height: 100%;
22
-
23
- overflow: hidden;
24
- }
25
- `
26
- ]
27
- }
28
-
29
- render() {
30
- return html`
31
- <barcodescan-input name="barcodescan-1"></barcodescan-input>
32
- <barcodescan-input name="barcodescan-2"></barcodescan-input>
33
- <barcodescan-input name="barcodescan-3"></barcodescan-input>
34
- `
35
- }
36
-
37
- async refresh() {
38
- if (!this._boardId) {
39
- return
40
- }
41
- var response = await client.query({
42
- query: gql`
43
- query FetchBoardById($id: String!) {
44
- board(id: $id) {
45
- id
46
- name
47
- model
48
- }
49
- }
50
- `,
51
- variables: { id: this._boardId }
52
- })
53
-
54
- var board = response.data.board
55
-
56
- this._board = {
57
- ...board,
58
- model: JSON.parse(board.model)
59
- }
60
-
61
- this.updateContext()
62
- }
63
- }
64
-
65
- customElements.define('barcode-ui-test-page', BarcodeUiTestPage)