@operato/input 0.2.51 → 0.3.4
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/CHANGELOG.md +51 -0
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.js +2 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/ox-buttons-radio.d.ts +1 -1
- package/dist/src/ox-buttons-radio.js +3 -5
- package/dist/src/ox-buttons-radio.js.map +1 -1
- package/dist/src/ox-checkbox.d.ts +1 -2
- package/dist/src/ox-checkbox.js +1 -4
- package/dist/src/ox-checkbox.js.map +1 -1
- package/dist/src/{ox-formfield.d.ts → ox-form-field.d.ts} +0 -0
- package/dist/src/{ox-formfield.js → ox-form-field.js} +2 -2
- package/dist/src/ox-form-field.js.map +1 -0
- package/dist/src/ox-input-3dish.d.ts +1 -1
- package/dist/src/ox-input-3dish.js +13 -14
- package/dist/src/ox-input-3dish.js.map +1 -1
- package/dist/src/ox-input-angle.d.ts +1 -1
- package/dist/src/ox-input-angle.js +1 -1
- package/dist/src/ox-input-angle.js.map +1 -1
- package/dist/src/ox-input-barcode.d.ts +3 -4
- package/dist/src/ox-input-barcode.js +3 -7
- package/dist/src/ox-input-barcode.js.map +1 -1
- package/dist/src/ox-input-code.d.ts +2 -2
- package/dist/src/ox-input-code.js +7 -8
- package/dist/src/ox-input-code.js.map +1 -1
- package/dist/src/ox-input-container.d.ts +10 -0
- package/dist/src/ox-input-container.js +35 -0
- package/dist/src/ox-input-container.js.map +1 -0
- package/dist/src/ox-input-data.d.ts +1 -5
- package/dist/src/ox-input-data.js +3 -7
- package/dist/src/ox-input-data.js.map +1 -1
- package/dist/src/ox-input-file.d.ts +19 -0
- package/dist/src/ox-input-file.js +186 -0
- package/dist/src/ox-input-file.js.map +1 -0
- package/dist/src/ox-input-stack.d.ts +1 -1
- package/dist/src/ox-input-stack.js +1 -1
- package/dist/src/ox-input-stack.js.map +1 -1
- package/dist/src/ox-select.d.ts +2 -2
- package/dist/src/ox-select.js +2 -2
- package/dist/src/ox-select.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +18 -6
- package/src/index.ts +2 -1
- package/src/ox-buttons-radio.ts +1 -1
- package/src/ox-checkbox.ts +1 -2
- package/src/{ox-formfield.ts → ox-form-field.ts} +1 -1
- package/src/ox-input-3dish.ts +1 -1
- package/src/ox-input-angle.ts +1 -1
- package/src/ox-input-barcode.ts +5 -5
- package/src/ox-input-code.ts +7 -6
- package/src/ox-input-container.ts +35 -0
- package/src/ox-input-data.ts +3 -8
- package/src/ox-input-file.ts +185 -0
- package/src/ox-input-keyvalues.ts.ing +277 -0
- package/src/ox-input-ranges.ts.ing +292 -0
- package/src/ox-input-stack.ts +1 -1
- package/src/ox-select.ts +2 -2
- package/tsconfig.json +3 -1
- package/dist/src/ox-formfield.js.map +0 -1
@@ -0,0 +1,292 @@
|
|
1
|
+
/**
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
3
|
+
*/
|
4
|
+
|
5
|
+
import { LitElement, html, css } from 'lit-element'
|
6
|
+
|
7
|
+
import './things-editor-color'
|
8
|
+
|
9
|
+
/**
|
10
|
+
range value editor element
|
11
|
+
|
12
|
+
Example:
|
13
|
+
|
14
|
+
<things-editor-value-range range=${range}
|
15
|
+
rangetype=${type}
|
16
|
+
valuetype=${valuetype}>
|
17
|
+
</things-editor-value-range>
|
18
|
+
*/
|
19
|
+
export default class ThingsEditorValueRange extends LitElement {
|
20
|
+
static get is() {
|
21
|
+
return 'things-editor-value-range'
|
22
|
+
}
|
23
|
+
|
24
|
+
static get properties() {
|
25
|
+
return {
|
26
|
+
value: Object,
|
27
|
+
valuetype: String
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
static get styles() {
|
32
|
+
return [
|
33
|
+
css`
|
34
|
+
:host {
|
35
|
+
display: flex;
|
36
|
+
flex-direction: column;
|
37
|
+
align-content: center;
|
38
|
+
|
39
|
+
width: 100%;
|
40
|
+
overflow: hidden;
|
41
|
+
border: 1px solid #ccc;
|
42
|
+
}
|
43
|
+
|
44
|
+
div {
|
45
|
+
display: flex;
|
46
|
+
flex-flow: row nowrap;
|
47
|
+
align-items: center;
|
48
|
+
|
49
|
+
border-bottom: 1px solid #c0c0c0;
|
50
|
+
}
|
51
|
+
|
52
|
+
div:last-child {
|
53
|
+
border-bottom: none;
|
54
|
+
}
|
55
|
+
|
56
|
+
div > * {
|
57
|
+
min-width: 0px;
|
58
|
+
margin: 2px;
|
59
|
+
padding: 0;
|
60
|
+
}
|
61
|
+
|
62
|
+
button {
|
63
|
+
width: 20px;
|
64
|
+
text-align: center;
|
65
|
+
}
|
66
|
+
|
67
|
+
input,
|
68
|
+
things-editor-color {
|
69
|
+
flex: 1;
|
70
|
+
}
|
71
|
+
|
72
|
+
things-editor-color {
|
73
|
+
--things-editor-color-input-color: {
|
74
|
+
margin: 2px;
|
75
|
+
}
|
76
|
+
--things-editor-color-input-span: {
|
77
|
+
width: 12px;
|
78
|
+
height: 12px;
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
[placeholder='value'] {
|
83
|
+
flex: 2;
|
84
|
+
}
|
85
|
+
|
86
|
+
div {
|
87
|
+
border-bottom: 1px solid #c0c0c0;
|
88
|
+
}
|
89
|
+
|
90
|
+
div:last-child {
|
91
|
+
border-bottom: none;
|
92
|
+
}
|
93
|
+
|
94
|
+
input[type='checkbox'] {
|
95
|
+
width: initial;
|
96
|
+
}
|
97
|
+
`
|
98
|
+
]
|
99
|
+
}
|
100
|
+
|
101
|
+
constructor() {
|
102
|
+
super()
|
103
|
+
|
104
|
+
this.value = {}
|
105
|
+
this.valuetype = 'string'
|
106
|
+
this.rangetype = 'number'
|
107
|
+
}
|
108
|
+
|
109
|
+
firstUpdated() {
|
110
|
+
this.renderRoot.addEventListener('change', this._onChange.bind(this))
|
111
|
+
}
|
112
|
+
|
113
|
+
render() {
|
114
|
+
return html`
|
115
|
+
${this._toArray(this.value).map(
|
116
|
+
item => html`
|
117
|
+
<div data-record>
|
118
|
+
<input type="text" data-from placeholder="<=" .value=${item.from} />
|
119
|
+
<input type="text" data-to placeholder=">" .value=${item.to} />
|
120
|
+
|
121
|
+
${this.valuetype == 'boolean'
|
122
|
+
? html` <input type="checkbox" data-value .checked=${item.value} data-value-type=${this.valuetype} /> `
|
123
|
+
: this.valuetype == 'color'
|
124
|
+
? html` <things-editor-color data-value .value=${item.value}> </things-editor-color> `
|
125
|
+
: html`
|
126
|
+
<input
|
127
|
+
type="text"
|
128
|
+
data-value
|
129
|
+
placeholder="value"
|
130
|
+
.value=${item.value}
|
131
|
+
data-value-type=${this.valuetype}
|
132
|
+
/>
|
133
|
+
`} <button class="record-action" @click=${e => this._delete(e)} tabindex="-1">-</button>
|
134
|
+
</div>
|
135
|
+
`
|
136
|
+
)}
|
137
|
+
|
138
|
+
<div data-record-new>
|
139
|
+
<input type="text" data-from placeholder="<=" value="" />
|
140
|
+
<input type="text" data-to placeholder=">" value="" />
|
141
|
+
|
142
|
+
${this.valuetype == 'boolean'
|
143
|
+
? html` <input type="checkbox" data-value data-value-type=${this.valuetype} /> `
|
144
|
+
: this.valuetype == 'color'
|
145
|
+
? html` <things-editor-color data-value value="" placeholder="value"> </things-editor-color> `
|
146
|
+
: html` <input type="text" data-value placeholder="value" value="" data-value-type=${this.valuetype} /> `}
|
147
|
+
<button class="record-action" @click=${e => this._add(e)} tabindex="-1">+</button>
|
148
|
+
</div>
|
149
|
+
|
150
|
+
<div data-record>
|
151
|
+
<input type="text" data-from data-default="" disabled value="default" />
|
152
|
+
<input type="text" data-to placeholder=">" value="" hidden />
|
153
|
+
|
154
|
+
${this.valuetype == 'boolean'
|
155
|
+
? html`
|
156
|
+
<input
|
157
|
+
type="checkbox"
|
158
|
+
data-value
|
159
|
+
.checked=${this.value && this.value.default}
|
160
|
+
data-value-type=${this.valuetype}
|
161
|
+
/>
|
162
|
+
`
|
163
|
+
: this.valuetype == 'color'
|
164
|
+
? html`
|
165
|
+
<things-editor-color data-value .value=${(this.value && this.value.default) || ''} placeholder="value">
|
166
|
+
</things-editor-color>
|
167
|
+
`
|
168
|
+
: html`
|
169
|
+
<input
|
170
|
+
type="text"
|
171
|
+
data-value
|
172
|
+
.value=${(this.value && this.value.default) || ''}
|
173
|
+
placeholder="value"
|
174
|
+
class="default-value"
|
175
|
+
data-value-type=${this.valuetype}
|
176
|
+
/>
|
177
|
+
`} <button class="record-action" @click="${e => this._sort(e)}">></button>
|
178
|
+
</div>
|
179
|
+
`
|
180
|
+
}
|
181
|
+
|
182
|
+
_defaultValue(type) {
|
183
|
+
switch (type || this.valuetype) {
|
184
|
+
case 'color':
|
185
|
+
return '#000000'
|
186
|
+
case 'boolean':
|
187
|
+
case 'checkbox':
|
188
|
+
return false
|
189
|
+
default:
|
190
|
+
return ''
|
191
|
+
}
|
192
|
+
}
|
193
|
+
|
194
|
+
_onChange(e) {
|
195
|
+
if (this._changingNow) return
|
196
|
+
|
197
|
+
this._changingNow = true
|
198
|
+
|
199
|
+
var input = e.target
|
200
|
+
var value
|
201
|
+
if (input.type == 'checkbox') value = Boolean(input.checked)
|
202
|
+
else value = input.value
|
203
|
+
var div = input.parentElement
|
204
|
+
if (input.hasAttribute('data-value')) {
|
205
|
+
var dataList = div.querySelectorAll('[data-value]:not([hidden])')
|
206
|
+
for (var i = 0; i < dataList.length; i++) if (dataList[i] !== input) dataList[i].value = value
|
207
|
+
}
|
208
|
+
if (div.hasAttribute('data-record')) this._build()
|
209
|
+
else if (div.hasAttribute('data-record-new') && input.hasAttribute('data-value')) this._add()
|
210
|
+
|
211
|
+
this._changingNow = false
|
212
|
+
}
|
213
|
+
|
214
|
+
_build(includeNewRecord) {
|
215
|
+
if (includeNewRecord) var records = this.renderRoot.querySelectorAll('[data-record],[data-record-new]')
|
216
|
+
else var records = this.renderRoot.querySelectorAll('[data-record]')
|
217
|
+
var newrange = {}
|
218
|
+
for (var i = 0; i < records.length; i++) {
|
219
|
+
var record = records[i]
|
220
|
+
var from = record.querySelector('[data-from]').value
|
221
|
+
var to = record.querySelector('[data-to]').value
|
222
|
+
var inputs = record.querySelectorAll('[data-value]:not([style*="display: none"])')
|
223
|
+
if (!inputs || inputs.length == 0) continue
|
224
|
+
var input = inputs[inputs.length - 1]
|
225
|
+
var value
|
226
|
+
if (input.type == 'checkbox') value = Boolean(input.checked)
|
227
|
+
else value = input.value
|
228
|
+
if (from) {
|
229
|
+
if (from === 'default') newrange['default'] = value || (this.valuetype == 'color' ? '#000000' : '')
|
230
|
+
else newrange[`${from}~${to}`] = value
|
231
|
+
}
|
232
|
+
}
|
233
|
+
|
234
|
+
this.value = newrange
|
235
|
+
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
|
236
|
+
}
|
237
|
+
|
238
|
+
/* default를 제외한 range아이템들을 template(dom-repeat)용 배열로 변환하는 함수 */
|
239
|
+
_toArray(range) {
|
240
|
+
var array = []
|
241
|
+
for (var key in range) {
|
242
|
+
if (key == 'default') continue
|
243
|
+
var fromto = key.split('~')
|
244
|
+
array.push({
|
245
|
+
from: fromto[0],
|
246
|
+
to: fromto[1],
|
247
|
+
value: range[key]
|
248
|
+
})
|
249
|
+
}
|
250
|
+
return array
|
251
|
+
}
|
252
|
+
|
253
|
+
_sort(e) {
|
254
|
+
var sorter =
|
255
|
+
this.rangetype === 'number'
|
256
|
+
? function (a, b) {
|
257
|
+
return parseFloat(b.from) < parseFloat(a.from)
|
258
|
+
}
|
259
|
+
: function (a, b) {
|
260
|
+
return b.from < a.from
|
261
|
+
}
|
262
|
+
var range = this._toArray(this.value)
|
263
|
+
.sort(sorter)
|
264
|
+
.reduce(function (sum, i) {
|
265
|
+
sum[`${i.from}~${i.to}`] = i.value
|
266
|
+
return sum
|
267
|
+
}, {})
|
268
|
+
range.default = this.value.default
|
269
|
+
|
270
|
+
this.value = range
|
271
|
+
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
|
272
|
+
}
|
273
|
+
|
274
|
+
_add(e) {
|
275
|
+
this._build(true)
|
276
|
+
var inputs = this.renderRoot.querySelectorAll('[data-record-new] input:not([style*="display: none"])')
|
277
|
+
for (var i = 0; i < inputs.length; i++) {
|
278
|
+
let input = inputs[i]
|
279
|
+
if (input.type == 'checkbox') input.checked = false
|
280
|
+
else input.value = this._defaultValue(input.type)
|
281
|
+
}
|
282
|
+
inputs[0].focus()
|
283
|
+
}
|
284
|
+
|
285
|
+
_delete(e) {
|
286
|
+
var record = e.target.parentElement
|
287
|
+
record.querySelector('[data-from]').value = ''
|
288
|
+
this._build()
|
289
|
+
}
|
290
|
+
}
|
291
|
+
|
292
|
+
customElements.define(ThingsEditorValueRange.is, ThingsEditorValueRange)
|
package/src/ox-input-stack.ts
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
import { css, html } from 'lit'
|
6
6
|
import { customElement, property } from 'lit/decorators.js'
|
7
7
|
|
8
|
-
import { OxFormField } from './ox-
|
8
|
+
import { OxFormField } from './ox-form-field'
|
9
9
|
|
10
10
|
@customElement('ox-input-stack')
|
11
11
|
export default class OxInputStack extends OxFormField {
|
package/src/ox-select.ts
CHANGED
@@ -3,14 +3,14 @@
|
|
3
3
|
*/
|
4
4
|
|
5
5
|
import '@material/mwc-icon'
|
6
|
-
import '@operato/popup'
|
6
|
+
import '@operato/popup/ox-popup-list.js'
|
7
7
|
|
8
8
|
import { css, html } from 'lit'
|
9
9
|
import { customElement, property } from 'lit/decorators.js'
|
10
10
|
|
11
11
|
import { OxPopupList } from '@operato/popup'
|
12
12
|
|
13
|
-
import { OxFormField } from './ox-
|
13
|
+
import { OxFormField } from './ox-form-field.js'
|
14
14
|
|
15
15
|
@customElement('ox-select')
|
16
16
|
export class Select extends OxFormField {
|
package/tsconfig.json
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
{
|
2
2
|
"compilerOptions": {
|
3
|
-
"target": "
|
3
|
+
"target": "esnext",
|
4
4
|
"module": "esnext",
|
5
5
|
"moduleResolution": "node",
|
6
|
+
"resolveJsonModule": true,
|
6
7
|
"noEmitOnError": true,
|
7
8
|
"lib": ["es2017", "dom"],
|
8
9
|
"strict": true,
|
9
10
|
"esModuleInterop": false,
|
10
11
|
"allowSyntheticDefaultImports": true,
|
11
12
|
"experimentalDecorators": true,
|
13
|
+
"useDefineForClassFields": false,
|
12
14
|
"importHelpers": true,
|
13
15
|
"outDir": "dist",
|
14
16
|
"sourceMap": true,
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"ox-formfield.js","sourceRoot":"","sources":["../../src/ox-formfield.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAE5C,MAAM,OAAgB,WAAY,SAAQ,UAAU;IAApD;;QAIU,UAAK,GAA2B,IAAI,CAAA;QACpC,0BAAqB,GAAyB,IAAI,CAAA;IA2B5D,CAAC;IAzBU,iBAAiB;QACxB,KAAK,CAAC,iBAAiB,EAAE,CAAA;QAEzB,IAAI,IAAI,CAAC,IAAI,EAAE;YACb,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;YACjC,IAAI,IAAI,CAAC,KAAK,EAAE;gBACd,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAkB,CAAA;gBAC5E,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,qBAAqB,CAAC,CAAA;aACpE;SACF;IACH,CAAC;IAEQ,oBAAoB;QAC3B,KAAK,CAAC,oBAAoB,EAAE,CAAA;QAE5B,IAAI,IAAI,CAAC,KAAK,EAAE;YACd,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,UAAU,EAAE,IAAI,CAAC,qBAAsB,CAAC,CAAA;YACvE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;YACjB,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAA;SAClC;IACH,CAAC;IAES,cAAc,CAAC,EAAE,QAAQ,EAAiB;QAClD,IAAI,CAAC,IAAI,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;IACrD,CAAC;CACF;AA/B6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCAAc;AAC7B;IAAX,QAAQ,EAAE;0CAAY","sourcesContent":["import { LitElement } from 'lit-element'\nimport { property } from 'lit/decorators.js'\n\nexport abstract class OxFormField extends LitElement {\n @property({ type: String }) name?: string\n @property() value?: any\n\n private _form: HTMLFormElement | null = null\n private _formdataEventHandler: EventListener | null = null\n\n override connectedCallback(): void {\n super.connectedCallback()\n\n if (this.name) {\n this._form = this.closest('form')\n if (this._form) {\n this._formdataEventHandler = this.appendFormData.bind(this) as EventListener\n this._form.addEventListener('formdata', this._formdataEventHandler)\n }\n }\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback()\n\n if (this._form) {\n this._form.removeEventListener('formdata', this._formdataEventHandler!)\n this._form = null\n this._formdataEventHandler = null\n }\n }\n\n protected appendFormData({ formData }: FormDataEvent): void {\n this.name && formData.append(this.name, this.value)\n }\n}\n"]}
|