@operato/input 1.0.0-alpha.9 → 1.0.0-beta.0
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 +395 -0
- package/assets/images/icon-properties-line-type.png +0 -0
- package/assets/images/icon-properties-table.png +0 -0
- package/demo/index-crontab.html +37 -0
- package/demo/index-partition-keys.html +71 -0
- package/demo/index-select.html +21 -14
- package/demo/index-table.html +39 -0
- package/demo/index-value-map.html +80 -0
- package/demo/index-value-ranges.html +80 -0
- package/demo/index-work-shift.html +59 -0
- package/demo/index.html +10 -0
- package/dist/src/index.d.ts +9 -3
- package/dist/src/index.js +9 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/ox-checkbox.d.ts +1 -1
- package/dist/src/ox-checkbox.js +1 -1
- package/dist/src/ox-checkbox.js.map +1 -1
- package/dist/src/ox-form-field.d.ts +2 -2
- package/dist/src/ox-form-field.js.map +1 -1
- package/dist/src/ox-input-barcode.d.ts +1 -1
- package/dist/src/ox-input-barcode.js +1 -1
- package/dist/src/ox-input-barcode.js.map +1 -1
- package/dist/src/ox-input-color-gradient.d.ts +4 -4
- package/dist/src/ox-input-color-gradient.js +3 -3
- package/dist/src/ox-input-color-gradient.js.map +1 -1
- package/dist/src/ox-input-color-stops.js +1 -1
- package/dist/src/ox-input-color-stops.js.map +1 -1
- package/dist/src/ox-input-crontab.d.ts +23 -0
- package/dist/src/ox-input-crontab.js +560 -0
- package/dist/src/ox-input-crontab.js.map +1 -0
- package/dist/src/ox-input-layout/ox-input-card-layout.d.ts +4 -0
- package/dist/src/ox-input-layout/ox-input-card-layout.js +57 -0
- package/dist/src/ox-input-layout/ox-input-card-layout.js.map +1 -0
- package/dist/src/ox-input-layout/ox-input-grid-layout.d.ts +4 -0
- package/dist/src/ox-input-layout/ox-input-grid-layout.js +63 -0
- package/dist/src/ox-input-layout/ox-input-grid-layout.js.map +1 -0
- package/dist/src/ox-input-layout/ox-input-layout.d.ts +5 -0
- package/dist/src/ox-input-layout/ox-input-layout.js +73 -0
- package/dist/src/ox-input-layout/ox-input-layout.js.map +1 -0
- package/dist/src/ox-input-multiple-colors.d.ts +2 -2
- package/dist/src/ox-input-multiple-colors.js +2 -2
- package/dist/src/ox-input-multiple-colors.js.map +1 -1
- package/dist/src/ox-input-options.js.map +1 -1
- package/dist/src/ox-input-partition-keys.d.ts +36 -0
- package/dist/src/ox-input-partition-keys.js +204 -0
- package/dist/src/ox-input-partition-keys.js.map +1 -0
- package/dist/src/ox-input-search.d.ts +1 -0
- package/dist/src/ox-input-search.js +7 -1
- package/dist/src/ox-input-search.js.map +1 -1
- package/dist/src/ox-input-table.d.ts +8 -0
- package/dist/src/ox-input-table.js +379 -0
- package/dist/src/ox-input-table.js.map +1 -0
- package/dist/src/ox-input-value-map.d.ts +41 -0
- package/dist/src/ox-input-value-map.js +279 -0
- package/dist/src/ox-input-value-map.js.map +1 -0
- package/dist/src/ox-input-value-ranges.d.ts +41 -0
- package/dist/src/ox-input-value-ranges.js +298 -0
- package/dist/src/ox-input-value-ranges.js.map +1 -0
- package/dist/src/ox-input-work-shift.d.ts +33 -0
- package/dist/src/ox-input-work-shift.js +229 -0
- package/dist/src/ox-input-work-shift.js.map +1 -0
- package/dist/src/ox-select.d.ts +3 -0
- package/dist/src/ox-select.js +28 -3
- package/dist/src/ox-select.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +18 -8
- package/src/index.ts +9 -3
- package/src/ox-checkbox.ts +2 -2
- package/src/ox-form-field.ts +2 -2
- package/src/ox-input-barcode.ts +2 -3
- package/src/{ox-input-color-gradient.ts.xxx → ox-input-color-gradient.ts} +4 -4
- package/src/ox-input-color-stops.ts +1 -1
- package/src/ox-input-crontab.ts +561 -0
- package/src/ox-input-layout/ox-input-card-layout.ts +58 -0
- package/src/ox-input-layout/ox-input-grid-layout.ts +64 -0
- package/src/ox-input-layout/ox-input-layout.ts +77 -0
- package/src/ox-input-multiple-colors.ts +2 -2
- package/src/ox-input-options.ts +1 -1
- package/src/ox-input-partition-keys.ts +243 -0
- package/src/ox-input-search.ts +9 -1
- package/src/ox-input-table.ts +404 -0
- package/src/{ox-input-keyvalues.ts.ing → ox-input-value-map.ts} +120 -89
- package/src/ox-input-value-ranges.ts +325 -0
- package/src/ox-input-work-shift.ts +251 -0
- package/src/ox-select.ts +31 -5
- package/dist/src/ox-input-background-pattern.d.ts +0 -31
- package/dist/src/ox-input-background-pattern.js +0 -147
- package/dist/src/ox-input-background-pattern.js.map +0 -1
- package/dist/src/ox-input-fill-style.d.ts +0 -42
- package/dist/src/ox-input-fill-style.js +0 -323
- package/dist/src/ox-input-fill-style.js.map +0 -1
- package/dist/src/ox-input-id.d.ts +0 -11
- package/dist/src/ox-input-id.js +0 -68
- package/dist/src/ox-input-id.js.map +0 -1
- package/src/ox-input-background-pattern.ts.xxx +0 -163
- package/src/ox-input-fill-style.ts.xxx +0 -361
- package/src/ox-input-ranges.ts.ing +0 -292
@@ -1,361 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @license Copyright © HatioLab Inc. All rights reserved.
|
3
|
-
*/
|
4
|
-
|
5
|
-
import '@operato/i18n/ox-i18n.js'
|
6
|
-
import './ox-input-color'
|
7
|
-
import './ox-input-color-gradient'
|
8
|
-
import './ox-input-background-pattern'
|
9
|
-
|
10
|
-
import { BackgroundPatternOption, OxInputBackgroundPattern } from './ox-input-background-pattern'
|
11
|
-
import { GradientOption, OxInputColorGradient } from './ox-input-color-gradient'
|
12
|
-
import { PropertyValues, css, html } from 'lit'
|
13
|
-
import { customElement, property, query } from 'lit/decorators.js'
|
14
|
-
|
15
|
-
import { ColorStop } from './ox-input-color-stops'
|
16
|
-
import { OxFormField } from './ox-form-field'
|
17
|
-
|
18
|
-
export type FillStyle =
|
19
|
-
| {
|
20
|
-
type?: 'no' | 'solid' | 'gradient' | 'pattern'
|
21
|
-
gradientType?: 'linear' | 'radial'
|
22
|
-
colorStops?: ColorStop[]
|
23
|
-
rotation?: number
|
24
|
-
center?: 'center' | 'left-top' | 'right-top' | 'right-bottom' | 'left-bottom'
|
25
|
-
image?: HTMLImageElement | string
|
26
|
-
offsetX?: number
|
27
|
-
offsetY?: number
|
28
|
-
width?: number
|
29
|
-
height?: number
|
30
|
-
align?: 'left-top' | 'top' | 'right-top' | 'left' | 'center' | 'right' | 'left-bottom' | 'bottom' | 'right-bottom'
|
31
|
-
fitPattern?: boolean
|
32
|
-
}
|
33
|
-
| 'no'
|
34
|
-
| string
|
35
|
-
|
36
|
-
@customElement('ox-input-color-style')
|
37
|
-
export class OxInputColorStyle extends OxFormField {
|
38
|
-
static styles = css`
|
39
|
-
:host {
|
40
|
-
display: flex;
|
41
|
-
flex-direction: column;
|
42
|
-
}
|
43
|
-
|
44
|
-
[fill-type] {
|
45
|
-
display: flex;
|
46
|
-
margin: 0 0 14px 0;
|
47
|
-
}
|
48
|
-
|
49
|
-
[fill-type] * {
|
50
|
-
flex: auto;
|
51
|
-
margin: 0;
|
52
|
-
text-align: left;
|
53
|
-
align-self: center;
|
54
|
-
}
|
55
|
-
|
56
|
-
.grid-10 {
|
57
|
-
display: grid;
|
58
|
-
|
59
|
-
grid-template-columns: repeat(10, 1fr);
|
60
|
-
grid-gap: 5px;
|
61
|
-
grid-auto-rows: minmax(24px, auto);
|
62
|
-
}
|
63
|
-
|
64
|
-
.grid-10 > ox-input-color {
|
65
|
-
grid-column: span 4;
|
66
|
-
}
|
67
|
-
|
68
|
-
.grid-10 > .icon-only-label {
|
69
|
-
grid-column: span 1;
|
70
|
-
|
71
|
-
background: url(/assets/images/icon-properties-label.png) no-repeat;
|
72
|
-
float: left;
|
73
|
-
margin: 0;
|
74
|
-
}
|
75
|
-
|
76
|
-
.icon-only-label.color {
|
77
|
-
background-position: 70% -498px;
|
78
|
-
}
|
79
|
-
|
80
|
-
[editors] > :not([active]) {
|
81
|
-
display: none;
|
82
|
-
}
|
83
|
-
`
|
84
|
-
|
85
|
-
@property({ type: Object }) value?: FillStyle
|
86
|
-
@property({ type: String }) fillType?: string
|
87
|
-
@property({ type: String }) solid?: string
|
88
|
-
@property({ type: Object }) gradient?: GradientOption
|
89
|
-
@property({ type: Object }) pattern?: BackgroundPatternOption
|
90
|
-
|
91
|
-
private _block_reset: boolean = false
|
92
|
-
|
93
|
-
updated(changes: PropertyValues<this>) {
|
94
|
-
changes.has('value') && this._onChangedValue(this.value || {})
|
95
|
-
}
|
96
|
-
|
97
|
-
render() {
|
98
|
-
return html`
|
99
|
-
<div @change=${(e: Event) => this._onChangedFillType(e)} fill-type>
|
100
|
-
<input
|
101
|
-
type="radio"
|
102
|
-
id="fill-type-no"
|
103
|
-
name="fill-type"
|
104
|
-
value="no"
|
105
|
-
.checked=${!this.fillType || this.fillType == 'no'}
|
106
|
-
/>
|
107
|
-
<label for="fill-type-no"><ox-i18n msgid="label.no-fill">no fill</ox-i18n></label>
|
108
|
-
<input type="radio" id="fill-type-solid" name="fill-type" value="solid" .checked=${this.fillType == 'solid'} />
|
109
|
-
<label for="fill-type-solid"><ox-i18n msgid="label.solid">solid</ox-i18n></label>
|
110
|
-
<input
|
111
|
-
type="radio"
|
112
|
-
id="fill-type-gradient"
|
113
|
-
name="fill-type"
|
114
|
-
value="gradient"
|
115
|
-
.checked=${this.fillType == 'gradient'}
|
116
|
-
/>
|
117
|
-
<label for="fill-type-gradient"><ox-i18n msgid="label.gradient">gradient</ox-i18n></label>
|
118
|
-
<input
|
119
|
-
type="radio"
|
120
|
-
id="fill-type-pattern"
|
121
|
-
name="fill-type"
|
122
|
-
value="pattern"
|
123
|
-
.checked=${this.fillType == 'pattern'}
|
124
|
-
/>
|
125
|
-
<label for="fill-type-pattern"><ox-i18n msgid="label.pattern">pattern</ox-i18n></label>
|
126
|
-
</div>
|
127
|
-
|
128
|
-
<div editors>
|
129
|
-
<div ?active=${this.fillType == 'no'}></div>
|
130
|
-
|
131
|
-
<div class="grid-10" ?active=${this.fillType == 'solid'}>
|
132
|
-
<label class="icon-only-label color"></label>
|
133
|
-
<ox-input-color @change=${(e: Event) => this._onChangedSolid(e)} .value=${this.solid}> </ox-input-color>
|
134
|
-
</div>
|
135
|
-
|
136
|
-
<div ?active=${this.fillType == 'gradient'}>
|
137
|
-
<ox-input-color-gradient @change=${(e: Event) => this._onChandedGradient(e)} .value=${this.gradient}>
|
138
|
-
</ox-input-color-gradient>
|
139
|
-
</div>
|
140
|
-
|
141
|
-
<div ?active=${this.fillType == 'pattern'}>
|
142
|
-
<ox-input-background-pattern @change=${(e: Event) => this._onChangedPattern(e)} .value=${this.pattern}>
|
143
|
-
</ox-input-background-pattern>
|
144
|
-
</div>
|
145
|
-
</div>
|
146
|
-
`
|
147
|
-
}
|
148
|
-
|
149
|
-
async _onChangedValue(value: FillStyle) {
|
150
|
-
/*
|
151
|
-
* this._block_reset의 역할은 내부 사용자 인터렉션에 의한 value의 변경시에는 각 type별 이전값을 유지하기 위함이다.
|
152
|
-
*/
|
153
|
-
await this.requestUpdate()
|
154
|
-
|
155
|
-
/* 설정 값에 따라서, 멤버 속성을 설정한다. */
|
156
|
-
if (!value) {
|
157
|
-
this.fillType = 'no'
|
158
|
-
|
159
|
-
if (!this._block_reset) {
|
160
|
-
this.solid = undefined
|
161
|
-
this.gradient = undefined
|
162
|
-
this.pattern = undefined
|
163
|
-
}
|
164
|
-
|
165
|
-
this._block_reset = false
|
166
|
-
return
|
167
|
-
}
|
168
|
-
|
169
|
-
switch (typeof value) {
|
170
|
-
case 'string':
|
171
|
-
this.fillType = 'solid'
|
172
|
-
this.solid = value
|
173
|
-
|
174
|
-
if (!this._block_reset) {
|
175
|
-
this.gradient = undefined
|
176
|
-
this.pattern = undefined
|
177
|
-
}
|
178
|
-
break
|
179
|
-
case 'object':
|
180
|
-
this.fillType = value.type
|
181
|
-
|
182
|
-
if (value.type === 'gradient') {
|
183
|
-
this.gradient = {
|
184
|
-
type: value.gradientType || 'linear',
|
185
|
-
colorStops: value.colorStops || [
|
186
|
-
{
|
187
|
-
position: 0,
|
188
|
-
color: this.solid || '#000000'
|
189
|
-
},
|
190
|
-
{
|
191
|
-
position: 1,
|
192
|
-
color: this.solid || '#FFFFFF'
|
193
|
-
}
|
194
|
-
],
|
195
|
-
rotation: Number(value.rotation) || 0,
|
196
|
-
center: value.center
|
197
|
-
}
|
198
|
-
|
199
|
-
if (!this._block_reset) {
|
200
|
-
this.pattern = undefined
|
201
|
-
this.solid = undefined
|
202
|
-
}
|
203
|
-
} else if (value.type === 'pattern') {
|
204
|
-
this.pattern = {
|
205
|
-
image: value.image,
|
206
|
-
offsetX: Number(value.offsetX) || 0,
|
207
|
-
offsetY: Number(value.offsetY) || 0,
|
208
|
-
width: Number(value.width),
|
209
|
-
height: Number(value.height),
|
210
|
-
align: value.align,
|
211
|
-
fitPattern: value.fitPattern
|
212
|
-
}
|
213
|
-
|
214
|
-
if (!this._block_reset) {
|
215
|
-
this.gradient = undefined
|
216
|
-
this.solid = undefined
|
217
|
-
}
|
218
|
-
}
|
219
|
-
|
220
|
-
break
|
221
|
-
default:
|
222
|
-
}
|
223
|
-
|
224
|
-
this._block_reset = false
|
225
|
-
}
|
226
|
-
|
227
|
-
_onChangedFillType(e: Event) {
|
228
|
-
const element = e.target as HTMLInputElement
|
229
|
-
this.fillType = element.value
|
230
|
-
|
231
|
-
switch (this.fillType) {
|
232
|
-
case 'gradient':
|
233
|
-
if (!this.gradient) {
|
234
|
-
this.gradient = {
|
235
|
-
type: 'linear',
|
236
|
-
colorStops: [
|
237
|
-
{
|
238
|
-
position: 0,
|
239
|
-
color: this.solid || '#000000'
|
240
|
-
},
|
241
|
-
{
|
242
|
-
position: 1,
|
243
|
-
color: this.solid || '#FFFFFF'
|
244
|
-
}
|
245
|
-
],
|
246
|
-
rotation: 0,
|
247
|
-
center: 'center'
|
248
|
-
}
|
249
|
-
}
|
250
|
-
|
251
|
-
this.value = {
|
252
|
-
type: 'gradient',
|
253
|
-
gradientType: this.gradient.type || 'linear',
|
254
|
-
colorStops: this.gradient.colorStops || [
|
255
|
-
{
|
256
|
-
position: 0,
|
257
|
-
color: this.solid || '#000000'
|
258
|
-
},
|
259
|
-
{
|
260
|
-
position: 1,
|
261
|
-
color: this.solid || '#FFFFFF'
|
262
|
-
}
|
263
|
-
],
|
264
|
-
rotation: Number(this.gradient.rotation) || 0,
|
265
|
-
center: this.gradient.center
|
266
|
-
}
|
267
|
-
break
|
268
|
-
|
269
|
-
case 'pattern':
|
270
|
-
if (!this.pattern) this.pattern = {}
|
271
|
-
|
272
|
-
this.value = {
|
273
|
-
type: 'pattern',
|
274
|
-
image: this.pattern.image,
|
275
|
-
offsetX: Number(this.pattern.offsetX) || 0,
|
276
|
-
offsetY: Number(this.pattern.offsetY) || 0,
|
277
|
-
width: Number(this.pattern.width),
|
278
|
-
height: Number(this.pattern.height),
|
279
|
-
align: this.pattern.align,
|
280
|
-
fitPattern: this.pattern.fitPattern
|
281
|
-
}
|
282
|
-
break
|
283
|
-
|
284
|
-
case 'solid':
|
285
|
-
if (!this.solid) this.solid = '#fff'
|
286
|
-
this.value = this.solid
|
287
|
-
break
|
288
|
-
|
289
|
-
case 'no':
|
290
|
-
this.value = ''
|
291
|
-
break
|
292
|
-
}
|
293
|
-
|
294
|
-
this._block_reset = true
|
295
|
-
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
|
296
|
-
}
|
297
|
-
|
298
|
-
_onChangedSolid(e: Event) {
|
299
|
-
if (this.fillType !== 'solid') return
|
300
|
-
|
301
|
-
this.solid = (e.target as HTMLInputElement).value
|
302
|
-
|
303
|
-
this.value = this.solid
|
304
|
-
|
305
|
-
this._block_reset = true
|
306
|
-
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
|
307
|
-
}
|
308
|
-
|
309
|
-
_onChandedGradient(e: Event) {
|
310
|
-
/*
|
311
|
-
* TODO Gradient의 rotation은 symmetry 기능 등으로 외부에서 변경될 수도 있다.
|
312
|
-
* 이 점을 감안해서, 외부 변경에 대한 대응을 해야 한다.
|
313
|
-
*/
|
314
|
-
|
315
|
-
if (this.fillType !== 'gradient') {
|
316
|
-
return
|
317
|
-
}
|
318
|
-
|
319
|
-
this.gradient = (e.target as OxInputColorGradient).value
|
320
|
-
|
321
|
-
this.value = {
|
322
|
-
type: 'gradient',
|
323
|
-
gradientType: this.gradient.type || 'linear',
|
324
|
-
colorStops: this.gradient.colorStops || [
|
325
|
-
{
|
326
|
-
position: 0,
|
327
|
-
color: this.solid || '#000000'
|
328
|
-
},
|
329
|
-
{
|
330
|
-
position: 1,
|
331
|
-
color: this.solid || '#FFFFFF'
|
332
|
-
}
|
333
|
-
],
|
334
|
-
rotation: Number(this.gradient.rotation) || 0,
|
335
|
-
center: this.gradient.center
|
336
|
-
}
|
337
|
-
|
338
|
-
this._block_reset = true
|
339
|
-
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
|
340
|
-
}
|
341
|
-
|
342
|
-
_onChangedPattern(e: Event) {
|
343
|
-
if (this.fillType !== 'pattern') return
|
344
|
-
|
345
|
-
this.pattern = (e.target as OxInputBackgroundPattern).value
|
346
|
-
|
347
|
-
this.value = {
|
348
|
-
type: 'pattern',
|
349
|
-
image: this.pattern?.image,
|
350
|
-
offsetX: Number(this.pattern?.offsetX) || 0,
|
351
|
-
offsetY: Number(this.pattern?.offsetY) || 0,
|
352
|
-
width: Number(this.pattern?.width),
|
353
|
-
height: Number(this.pattern?.height),
|
354
|
-
align: this.pattern?.align,
|
355
|
-
fitPattern: this.pattern?.fitPattern
|
356
|
-
}
|
357
|
-
|
358
|
-
this._block_reset = true
|
359
|
-
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
|
360
|
-
}
|
361
|
-
}
|
@@ -1,292 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @license Copyright © HatioLab Inc. All rights reserved.
|
3
|
-
*/
|
4
|
-
|
5
|
-
import { LitElement, html, css } from 'lit'
|
6
|
-
|
7
|
-
import './ox-input-color'
|
8
|
-
|
9
|
-
/**
|
10
|
-
range value editor element
|
11
|
-
|
12
|
-
Example:
|
13
|
-
|
14
|
-
<ox-input-value-range range=${range}
|
15
|
-
rangetype=${type}
|
16
|
-
valuetype=${valuetype}>
|
17
|
-
</ox-input-value-range>
|
18
|
-
*/
|
19
|
-
export 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
|
-
ox-input-color {
|
69
|
-
flex: 1;
|
70
|
-
}
|
71
|
-
|
72
|
-
ox-input-color {
|
73
|
-
--ox-input-color-input-color: {
|
74
|
-
margin: 2px;
|
75
|
-
}
|
76
|
-
--ox-input-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` <ox-input-color data-value .value=${item.value}> </ox-input-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` <ox-input-color data-value value="" placeholder="value"> </ox-input-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
|
-
<ox-input-color data-value .value=${(this.value && this.value.default) || ''} placeholder="value">
|
166
|
-
</ox-input-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)
|