@operato/input 1.0.0-alpha.2 → 1.0.0-alpha.22

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.
Files changed (101) hide show
  1. package/CHANGELOG.md +175 -0
  2. package/README.md +9 -6
  3. package/assets/images/icon-editor-gradient-direction.png +0 -0
  4. package/assets/images/icon-properties-label.png +0 -0
  5. package/assets/images/icon-properties-line-type.png +0 -0
  6. package/assets/images/icon-properties-table.png +0 -0
  7. package/demo/index-color-gradient.html +35 -0
  8. package/demo/index-color-stops.html +62 -0
  9. package/demo/index-color.html +35 -0
  10. package/demo/index-file.html +41 -0
  11. package/demo/index-image.html +1 -1
  12. package/demo/index-multiple-colors.html +37 -0
  13. package/demo/index-options.html +43 -0
  14. package/demo/index-range.html +40 -0
  15. package/demo/index-table.html +39 -0
  16. package/demo/index-value-map.html +80 -0
  17. package/demo/index-value-ranges.html +80 -0
  18. package/demo/index.html +21 -54
  19. package/dist/src/index.d.ts +19 -11
  20. package/dist/src/index.js +19 -11
  21. package/dist/src/index.js.map +1 -1
  22. package/dist/src/ox-checkbox.js +1 -1
  23. package/dist/src/ox-checkbox.js.map +1 -1
  24. package/dist/src/ox-input-code.d.ts +4 -4
  25. package/dist/src/ox-input-code.js +8 -8
  26. package/dist/src/ox-input-code.js.map +1 -1
  27. package/dist/src/ox-input-color-gradient.d.ts +26 -0
  28. package/dist/src/ox-input-color-gradient.js +318 -0
  29. package/dist/src/ox-input-color-gradient.js.map +1 -0
  30. package/dist/src/ox-input-color-stops.d.ts +71 -0
  31. package/dist/src/ox-input-color-stops.js +445 -0
  32. package/dist/src/ox-input-color-stops.js.map +1 -0
  33. package/dist/src/ox-input-color.d.ts +176 -0
  34. package/dist/src/ox-input-color.js +298 -0
  35. package/dist/src/ox-input-color.js.map +1 -0
  36. package/dist/src/ox-input-data.d.ts +2 -2
  37. package/dist/src/ox-input-data.js +2 -2
  38. package/dist/src/ox-input-data.js.map +1 -1
  39. package/dist/src/ox-input-file.d.ts +2 -0
  40. package/dist/src/ox-input-file.js +6 -1
  41. package/dist/src/ox-input-file.js.map +1 -1
  42. package/dist/src/ox-input-layout/ox-input-card-layout.d.ts +4 -0
  43. package/dist/src/ox-input-layout/ox-input-card-layout.js +57 -0
  44. package/dist/src/ox-input-layout/ox-input-card-layout.js.map +1 -0
  45. package/dist/src/ox-input-layout/ox-input-grid-layout.d.ts +4 -0
  46. package/dist/src/ox-input-layout/ox-input-grid-layout.js +63 -0
  47. package/dist/src/ox-input-layout/ox-input-grid-layout.js.map +1 -0
  48. package/dist/src/ox-input-layout/ox-input-layout.d.ts +5 -0
  49. package/dist/src/ox-input-layout/ox-input-layout.js +73 -0
  50. package/dist/src/ox-input-layout/ox-input-layout.js.map +1 -0
  51. package/dist/src/ox-input-multiple-colors.d.ts +28 -0
  52. package/dist/src/ox-input-multiple-colors.js +113 -0
  53. package/dist/src/ox-input-multiple-colors.js.map +1 -0
  54. package/dist/src/ox-input-options.d.ts +22 -0
  55. package/dist/src/ox-input-options.js +137 -0
  56. package/dist/src/ox-input-options.js.map +1 -0
  57. package/dist/src/ox-input-range.d.ts +4 -0
  58. package/dist/src/ox-input-range.js +161 -0
  59. package/dist/src/ox-input-range.js.map +1 -0
  60. package/dist/src/{ox-input-id.d.ts → ox-input-scene-component-id.d.ts} +0 -0
  61. package/dist/src/{ox-input-id.js → ox-input-scene-component-id.js} +2 -2
  62. package/dist/src/ox-input-scene-component-id.js.map +1 -0
  63. package/dist/src/ox-input-stack.d.ts +1 -1
  64. package/dist/src/ox-input-stack.js +1 -1
  65. package/dist/src/ox-input-stack.js.map +1 -1
  66. package/dist/src/ox-input-table.d.ts +8 -0
  67. package/dist/src/ox-input-table.js +379 -0
  68. package/dist/src/ox-input-table.js.map +1 -0
  69. package/dist/src/ox-input-value-map.d.ts +41 -0
  70. package/dist/src/ox-input-value-map.js +278 -0
  71. package/dist/src/ox-input-value-map.js.map +1 -0
  72. package/dist/src/ox-input-value-ranges.d.ts +41 -0
  73. package/dist/src/ox-input-value-ranges.js +298 -0
  74. package/dist/src/ox-input-value-ranges.js.map +1 -0
  75. package/dist/tsconfig.tsbuildinfo +1 -1
  76. package/package.json +23 -7
  77. package/src/index.ts +19 -11
  78. package/src/ox-checkbox.ts +1 -1
  79. package/src/ox-input-code.ts +9 -10
  80. package/src/ox-input-color-gradient.ts +343 -0
  81. package/src/ox-input-color-stops.ts +499 -0
  82. package/src/ox-input-color.ts +323 -0
  83. package/src/ox-input-data.ts +5 -5
  84. package/src/ox-input-file.ts +8 -3
  85. package/src/ox-input-layout/ox-input-card-layout.ts +58 -0
  86. package/src/ox-input-layout/ox-input-grid-layout.ts +64 -0
  87. package/src/ox-input-layout/ox-input-layout.ts +77 -0
  88. package/src/ox-input-multiple-colors.ts +113 -0
  89. package/src/ox-input-options.ts +165 -0
  90. package/src/ox-input-range.ts +147 -0
  91. package/src/{ox-input-id.ts → ox-input-scene-component-id.ts} +1 -1
  92. package/src/ox-input-stack.ts +1 -1
  93. package/src/ox-input-table.ts +404 -0
  94. package/src/{ox-input-keyvalues.ts.ing → ox-input-value-map.ts} +122 -93
  95. package/src/ox-input-value-ranges.ts +325 -0
  96. package/translations/en.json +1 -0
  97. package/translations/ko.json +1 -0
  98. package/translations/ms.json +1 -0
  99. package/translations/zh.json +1 -0
  100. package/dist/src/ox-input-id.js.map +0 -1
  101. package/src/ox-input-ranges.ts.ing +0 -292
@@ -0,0 +1,323 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
5
+ import '@operato/color-picker/paper-color-picker.js'
6
+
7
+ import { css, html } from 'lit'
8
+ import { customElement, property } from 'lit/decorators.js'
9
+
10
+ import { OxFormField } from './ox-form-field'
11
+ import { tinycolor } from '@thebespokepixel/es-tinycolor'
12
+
13
+ /**
14
+ 색상을 입력하는데 사용되는 입력 컴포넌트이다.
15
+ 화면상에는 두개의 입력 필드가 보이며, 하나는 색상값을 키보드로 직접 입력하는 입력 픽드이며,
16
+ 다른 하나는 마우스로 클릭하여 컬러 파레트를 팝업 시키는 입력 필드이다.
17
+ 컬러 파레트를 팝업시키는 입력필드는 현재 입력된 색상으로 표시된다.
18
+
19
+ 색상값을 직접 입력하는 필드에서는 'white', 'red', 'yellow' 등 색상의미 단어를 사용할 수도 있고,
20
+ #fff, #123456 와 같이 스타일에서 지정하는 방식의 3자리 및 6자리 숫자 표현도 가능하다.
21
+ 컬러 파레트를 팝업시키는 입력 필드에서 색상을 지정하게되면, 모두 6자리 숫자 표현방식만을 사용한다.
22
+
23
+ 의미 단어를 지원하는 색상은 다음과 같다.
24
+
25
+ aliceblue : #f0f8ff<br>
26
+ antiquewhite : #faebd7<br>
27
+ aqua : #00ffff<br>
28
+ aquamarine : #7fffd4<br>
29
+ azure : #f0ffff<br>
30
+ beige : #f5f5dc<br>
31
+ bisque : #ffe4c4<br>
32
+ black : #000000<br>
33
+ blanchedalmond : #ffebcd<br>
34
+ blue : #0000ff<br>
35
+ blueviolet : #8a2be2<br>
36
+ brown : #a52a2a<br>
37
+ burlywood : #deb887<br>
38
+ cadetblue : #5f9ea0<br>
39
+ chartreuse : #7fff00<br>
40
+ chocolate : #d2691e<br>
41
+ coral : #ff7f50<br>
42
+ cornflowerblue : #6495ed<br>
43
+ cornsilk : #fff8dc<br>
44
+ crimson : #dc143c<br>
45
+ cyan : #00ffff<br>
46
+ darkblue : #00008b<br>
47
+ darkcyan : #008b8b<br>
48
+ darkgoldenrod : #b8860b<br>
49
+ darkgray : #a9a9a9<br>
50
+ darkgreen : #006400<br>
51
+ darkkhaki : #bdb76b<br>
52
+ darkmagenta : #8b008b<br>
53
+ darkolivegreen : #556b2f<br>
54
+ darkorange : #ff8c00<br>
55
+ darkorchid : #9932cc<br>
56
+ darkred : #8b0000<br>
57
+ darksalmon : #e9967a<br>
58
+ darkseagreen : #8fbc8f<br>
59
+ darkslateblue : #483d8b<br>
60
+ darkslategray : #2f4f4f<br>
61
+ darkturquoise : #00ced1<br>
62
+ darkviolet : #9400d3<br>
63
+ deeppink : #ff1493<br>
64
+ deepskyblue : #00bfff<br>
65
+ dimgray : #696969<br>
66
+ dodgerblue : #1e90ff<br>
67
+ firebrick : #b22222<br>
68
+ floralwhite : #fffaf0<br>
69
+ forestgreen : #228b22<br>
70
+ fuchsia : #ff00ff<br>
71
+ gainsboro : #dcdcdc<br>
72
+ ghostwhite : #f8f8ff<br>
73
+ gold : #ffd700<br>
74
+ goldenrod : #daa520<br>
75
+ gray : #808080<br>
76
+ green : #008000<br>
77
+ greenyellow : #adff2f<br>
78
+ honeydew : #f0fff0<br>
79
+ hotpink : #ff69b4<br>
80
+ indianred : #cd5c5c<br>
81
+ indigo : #4b0082<br>
82
+ ivory : #fffff0<br>
83
+ khaki : #f0e68c<br>
84
+ lavender : #e6e6fa<br>
85
+ lavenderblush : #fff0f5<br>
86
+ lawngreen : #7cfc00<br>
87
+ lemonchiffon : #fffacd<br>
88
+ lightblue : #add8e6<br>
89
+ lightcoral : #f08080<br>
90
+ lightcyan : #e0ffff<br>
91
+ lightgoldenrodyellow : #fafad2<br>
92
+ lightgrey : #d3d3d3<br>
93
+ lightgreen : #90ee90<br>
94
+ lightpink : #ffb6c1<br>
95
+ lightsalmon : #ffa07a<br>
96
+ lightseagreen : #20b2aa<br>
97
+ lightskyblue : #87cefa<br>
98
+ lightslategray : #778899<br>
99
+ lightsteelblue : #b0c4de<br>
100
+ lightyellow : #ffffe0<br>
101
+ lime : #00ff00<br>
102
+ limegreen : #32cd32<br>
103
+ linen : #faf0e6<br>
104
+ magenta : #ff00ff<br>
105
+ maroon : #800000<br>
106
+ mediumaquamarine : #66cdaa<br>
107
+ mediumblue : #0000cd<br>
108
+ mediumorchid : #ba55d3<br>
109
+ mediumpurple : #9370d8<br>
110
+ mediumseagreen : #3cb371<br>
111
+ mediumslateblue : #7b68ee<br>
112
+ mediumspringgreen : #00fa9a<br>
113
+ mediumturquoise : #48d1cc<br>
114
+ mediumvioletred : #c71585<br>
115
+ midnightblue : #191970<br>
116
+ mintcream : #f5fffa<br>
117
+ mistyrose : #ffe4e1<br>
118
+ moccasin : #ffe4b5<br>
119
+ navajowhite : #ffdead<br>
120
+ navy : #000080<br>
121
+ oldlace : #fdf5e6<br>
122
+ olive : #808000<br>
123
+ olivedrab : #6b8e23<br>
124
+ orange : #ffa500<br>
125
+ orangered : #ff4500<br>
126
+ orchid : #da70d6<br>
127
+ palegoldenrod : #eee8aa<br>
128
+ palegreen : #98fb98<br>
129
+ paleturquoise : #afeeee<br>
130
+ palevioletred : #d87093<br>
131
+ papayawhip : #ffefd5<br>
132
+ peachpuff : #ffdab9<br>
133
+ peru : #cd853f<br>
134
+ pink : #ffc0cb<br>
135
+ plum : #dda0dd<br>
136
+ powderblue : #b0e0e6<br>
137
+ purple : #800080<br>
138
+ red : #ff0000<br>
139
+ rosybrown : #bc8f8f<br>
140
+ royalblue : #4169e1<br>
141
+ saddlebrown : #8b4513<br>
142
+ salmon : #fa8072<br>
143
+ sandybrown : #f4a460<br>
144
+ seagreen : #2e8b57<br>
145
+ seashell : #fff5ee<br>
146
+ sienna : #a0522d<br>
147
+ silver : #c0c0c0<br>
148
+ skyblue : #87ceeb<br>
149
+ slateblue : #6a5acd<br>
150
+ slategray : #708090<br>
151
+ snow : #fffafa<br>
152
+ springgreen : #00ff7f<br>
153
+ steelblue : #4682b4<br>
154
+ tan : #d2b48c<br>
155
+ teal : #008080<br>
156
+ thistle : #d8bfd8<br>
157
+ tomato : #ff6347<br>
158
+ turquoise : #40e0d0<br>
159
+ violet : #ee82ee<br>
160
+ wheat : #f5deb3<br>
161
+ white : #ffffff<br>
162
+ whitesmoke : #f5f5f5<br>
163
+ yellow : #ffff00<br>
164
+ yellowgreen : #9acd32<br>
165
+
166
+ Example:
167
+
168
+ <ox-input-color .value=${color}>
169
+ </ox-input-color>
170
+ */
171
+
172
+ @customElement('ox-input-color')
173
+ export class OxInputColor extends OxFormField {
174
+ static styles = css`
175
+ :host {
176
+ position: relative;
177
+ display: inline-flex;
178
+ align-items: center;
179
+ justify-content: flex-end;
180
+ }
181
+
182
+ input[type='text'] {
183
+ padding-right: 24px;
184
+ width: 100%;
185
+ height: 100%;
186
+ box-sizing: border-box;
187
+ border: 1px solid rgba(0, 0, 0, 0.2);
188
+ }
189
+
190
+ a {
191
+ -webkit-appearance: none;
192
+ display: flex;
193
+ position: absolute;
194
+ width: 24px;
195
+ height: 100%;
196
+ box-sizing: border-box;
197
+ align-items: center;
198
+ justify-content: center;
199
+ }
200
+
201
+ span {
202
+ width: 18px;
203
+ height: 100%;
204
+ max-height: 18px;
205
+ border-radius: 10%;
206
+ border: 1px solid #eee;
207
+ }
208
+
209
+ span.transparent {
210
+ background-color: #fefefe;
211
+ background-image: linear-gradient(45deg, #cbcbcb 25%, transparent 25%, transparent 75%, #cbcbcb 75%, #cbcbcb),
212
+ linear-gradient(45deg, #cbcbcb 25%, transparent 25%, transparent 75%, #cbcbcb 75%, #cbcbcb);
213
+ background-position: 0 0, 9px 9px;
214
+ background-size: 18px 18px;
215
+ }
216
+ `
217
+
218
+ @property({ type: String }) value?: string
219
+ @property({ type: Object }) properties: any
220
+
221
+ render() {
222
+ return html`
223
+ <input
224
+ id="text"
225
+ type="text"
226
+ .value=${this.value || ''}
227
+ @change=${(e: Event) => this._onInputChanged(e)}
228
+ .placeholder=${this.getAttribute('placeholder') || ''}
229
+ />
230
+
231
+ <a @click=${(e: MouseEvent) => this.showPicker()}>
232
+ <span id="color-thumbnail" .style="background-color:${this._thumbnail()}" class=${this._thumbnail()}> </span>
233
+ </a>
234
+ `
235
+ }
236
+
237
+ set colorString(colorString: string) {
238
+ var color = tinycolor(colorString, {})
239
+ var { withoutAlpha, valueType } = this.properties || {}
240
+
241
+ if (color.isValid()) {
242
+ if (valueType == 'hex' || withoutAlpha) {
243
+ this.value = color.toHexString(false)
244
+ } else this.value = color.toRgbString()
245
+
246
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
247
+ }
248
+ }
249
+
250
+ _thumbnail() {
251
+ return tinycolor(this.value || 'transparent', {}).toRgbString()
252
+ }
253
+
254
+ _onInputChanged(e: Event) {
255
+ e.stopPropagation()
256
+ this.value = (e.target as HTMLInputElement).value
257
+
258
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
259
+ }
260
+
261
+ /**
262
+ * 외부에서 호출 가능한 메쏘드임.
263
+ */
264
+ showPicker() {
265
+ var { withoutAlpha } = this.properties || {}
266
+
267
+ var color = tinycolor(this.value, {})
268
+
269
+ var picker = document.createElement('paper-color-picker') as HTMLElement & {
270
+ shape: string
271
+ color: any
272
+ colorAsString: string
273
+ allowAlpha: boolean
274
+ alwaysShowAlpha: boolean
275
+ type: string
276
+ _initialAlphaValueHack: number
277
+ set: (name: string, value: number) => void
278
+ open: () => void
279
+ }
280
+
281
+ picker.shape = 'huebox'
282
+ picker.color = color
283
+ picker.colorAsString = color.toRgbString()
284
+ if (!withoutAlpha) {
285
+ picker.allowAlpha = true
286
+ picker.alwaysShowAlpha = true
287
+ }
288
+ picker.type = 'hsl'
289
+
290
+ if (color.isValid()) {
291
+ let rgb = color.toRgb() as { r: number; g: number; b: number }
292
+ let alpha = color.getAlpha()
293
+
294
+ picker._initialAlphaValueHack = alpha
295
+
296
+ picker.set('immediateColor.red', rgb.r)
297
+ picker.set('immediateColor.green', rgb.g)
298
+ picker.set('immediateColor.blue', rgb.b)
299
+
300
+ if (alpha != undefined) {
301
+ picker.set('immediateColor.alpha', alpha)
302
+ }
303
+ }
304
+
305
+ document.body.appendChild(picker)
306
+
307
+ var _ = (e: Event) => {
308
+ if (!(e as CustomEvent)?.detail?.confirmed) {
309
+ return
310
+ }
311
+
312
+ if (picker.colorAsString) {
313
+ this.colorString = picker.colorAsString
314
+ }
315
+
316
+ picker.removeEventListener('iron-overlay-closed', _)
317
+ picker.parentNode?.removeChild(picker)
318
+ }
319
+ picker.addEventListener('iron-overlay-closed', _)
320
+
321
+ setTimeout(() => picker.open())
322
+ }
323
+ }
@@ -4,11 +4,11 @@
4
4
 
5
5
  import './ox-input-code'
6
6
 
7
- import { css, html, PropertyValues } from 'lit'
8
- import { customElement } from 'lit/decorators.js'
7
+ import { PropertyValues, css, html } from 'lit'
9
8
 
10
- import { OxFormField } from './ox-form-field'
11
- import OxInputCode from './ox-input-code'
9
+ import { OxFormField } from './ox-form-field.js'
10
+ import { OxInputCode } from './ox-input-code.js'
11
+ import { customElement } from 'lit/decorators.js'
12
12
 
13
13
  /**
14
14
  WEB Component for code-mirror based data editor.
@@ -19,7 +19,7 @@ Example:
19
19
  </ox-input-data>
20
20
  */
21
21
  @customElement('ox-input-data')
22
- export default class OxInputData extends OxFormField {
22
+ export class OxInputData extends OxFormField {
23
23
  static styles = [
24
24
  css`
25
25
  :host {
@@ -1,12 +1,11 @@
1
1
  import '@material/mwc-icon'
2
2
 
3
- import { css, html } from 'lit'
3
+ import { PropertyValues, css, html } from 'lit'
4
4
  import { customElement, property, query } from 'lit/decorators.js'
5
5
 
6
- import { ScrollbarStyles } from '@operato/styles'
7
6
  import { FileDropHelper } from '@operato/utils'
8
-
9
7
  import { OxFormField } from './ox-form-field.js'
8
+ import { ScrollbarStyles } from '@operato/styles'
10
9
 
11
10
  @customElement('ox-input-file')
12
11
  export class OxInputFile extends OxFormField {
@@ -138,6 +137,12 @@ export class OxInputFile extends OxFormField {
138
137
  `
139
138
  }
140
139
 
140
+ updated(changes: PropertyValues<this>) {
141
+ if (changes.has('value') && !(this.value instanceof Array)) {
142
+ this.value = !this.value ? [] : [this.value]
143
+ }
144
+ }
145
+
141
146
  firstUpdated() {
142
147
  FileDropHelper.set(this)
143
148
 
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
5
+ import { LitElement, PropertyValues, css, html } from 'lit'
6
+ import { customElement, property, state } from 'lit/decorators.js'
7
+
8
+ const DEFAULT = {
9
+ activeIndex: 0
10
+ }
11
+
12
+ @customElement('ox-input-card-layout')
13
+ class OxInputCardLayout extends LitElement {
14
+ static styles = css`
15
+ :host {
16
+ display: inline-block;
17
+ }
18
+ `
19
+
20
+ @property({ type: Object }) value: any
21
+ @property({ type: Number }) activeIndex: number = 0
22
+
23
+ firstUpdated() {
24
+ this.renderRoot.addEventListener('change', this._onValueChange.bind(this))
25
+ }
26
+
27
+ updated(changes: PropertyValues<this>) {
28
+ if (changes.has('value')) {
29
+ let { activeIndex } = this.value || DEFAULT
30
+
31
+ this.activeIndex = activeIndex
32
+ }
33
+ }
34
+
35
+ render() {
36
+ return html`
37
+ <label>active index</label>
38
+ <input type="number" value-key="activeIndex" .value=${this.activeIndex} />
39
+ `
40
+ }
41
+
42
+ _onValueChange(e: Event) {
43
+ var element = e.target as HTMLInputElement
44
+ var key = element.getAttribute('value-key') as 'activeIndex'
45
+
46
+ if (!key) {
47
+ return
48
+ }
49
+
50
+ this[key] = Number(element.value)
51
+
52
+ this.value = {
53
+ activeIndex: this.activeIndex
54
+ }
55
+
56
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
57
+ }
58
+ }
@@ -0,0 +1,64 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
5
+ import { LitElement, PropertyValues, css, html } from 'lit'
6
+ import { customElement, property, state } from 'lit/decorators.js'
7
+
8
+ @customElement('ox-input-grid-layout')
9
+ class OxInputGridLayout extends LitElement {
10
+ static styles = css`
11
+ :host {
12
+ display: inline-block;
13
+ }
14
+ `
15
+
16
+ @property({ type: Object }) value: any
17
+ @property({ type: String }) direction: 'row' | 'column' = 'row'
18
+
19
+ firstUpdated() {
20
+ this.renderRoot.addEventListener('change', this._onValueChange.bind(this))
21
+ }
22
+
23
+ updated(changes: PropertyValues<this>) {
24
+ if (changes.has('value')) {
25
+ let { direction = 'row' } = this.value || {}
26
+
27
+ this.direction = direction
28
+ }
29
+
30
+ if (changes.has('value')) {
31
+ }
32
+ }
33
+
34
+ render() {
35
+ return html`
36
+ <label>direction</label>
37
+ <select value-key="direction" .value=${this.direction}>
38
+ <option value="row" selected>row</option>
39
+ <option value="column">column</option>
40
+ </select>
41
+ `
42
+ }
43
+
44
+ _onValueChange(e: Event) {
45
+ var element = e.target as HTMLSelectElement
46
+ var key = element.getAttribute('value-key')
47
+
48
+ if (!key) {
49
+ return
50
+ }
51
+
52
+ switch (key) {
53
+ case 'direction':
54
+ this.direction = element.value as 'row' | 'column'
55
+ default:
56
+ }
57
+
58
+ this.value = {
59
+ direction: this.direction
60
+ }
61
+
62
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
63
+ }
64
+ }
@@ -0,0 +1,77 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
5
+ import './things-grid-layout'
6
+ import './things-card-layout'
7
+
8
+ import { LitElement, PropertyValues, html } from 'lit'
9
+ import { customElement, property, state } from 'lit/decorators.js'
10
+
11
+ // import './things-linear-horizontal-layout'
12
+ // import './things-linear-vertical-layout'
13
+
14
+ const layouts = ['absolute', 'card', 'grid', 'linear-horizontal', 'linear-vertical', 'table']
15
+
16
+ @customElement('ox-input-layout')
17
+ class OxInputLayout extends LitElement {
18
+ @property({ type: Object }) value: any = {}
19
+ @property({ type: String }) layout:
20
+ | ''
21
+ | 'absolute'
22
+ | 'card'
23
+ | 'grid'
24
+ | 'linear-horizontal'
25
+ | 'linear-vertical'
26
+ | 'table' = ''
27
+ @property({ type: Object }) options: any = {}
28
+
29
+ firstUpdated() {
30
+ this.renderRoot.addEventListener('change', this._onValueChange.bind(this))
31
+ }
32
+
33
+ updated(changes: PropertyValues<this>) {
34
+ if (changes.has('value')) {
35
+ this.layout = this.value.layout
36
+ this.options = this.value.options
37
+ }
38
+ }
39
+
40
+ render() {
41
+ return html`
42
+ <div>
43
+ <select value-key="layout" .value=${this.layout}>
44
+ <option value="" selected></option>
45
+ ${layouts.map(layout => {
46
+ return html` <option value=${layout}>${layout}</option> `
47
+ })}
48
+ </select>
49
+
50
+ ${this.layout == 'grid'
51
+ ? html` <things-grid-layout value-key="options" .value=${this.options}></things-grid-layout> `
52
+ : this.layout == 'card'
53
+ ? html` <things-card-layout value-key="options" .value=${this.options}></things-card-layout> `
54
+ : html``}
55
+ </div>
56
+ `
57
+ }
58
+
59
+ _onValueChange(e: Event) {
60
+ var element = e.target as HTMLElement
61
+ var key = element.getAttribute('value-key')
62
+
63
+ if (!key) {
64
+ return
65
+ }
66
+
67
+ //@ts-ignore
68
+ this[key] = element.value
69
+
70
+ this.value = {
71
+ layout: this.layout,
72
+ options: this.options
73
+ }
74
+
75
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
76
+ }
77
+ }
@@ -0,0 +1,113 @@
1
+ /**
2
+ * @license Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
5
+ import './ox-input-color.js'
6
+
7
+ import { css, html } from 'lit'
8
+ import { customElement, property, query, queryAll } from 'lit/decorators.js'
9
+
10
+ import { OxFormField } from './ox-form-field.js'
11
+ import { OxInputColor } from './ox-input-color.js'
12
+
13
+ /**
14
+ 색상 배열을 편집하는 컴포넌트이다.
15
+
16
+ 새로운 색상을 추가하고자 할 때는 `+` 버튼을 클릭한다.<br />
17
+ 색상을 제거하고자 할 때는 `-` 버튼을 클릭한다.<br />
18
+
19
+ Example:
20
+
21
+ <ox-input-multiple-colors values=${values}>
22
+ </ox-input-multiple-colors>
23
+ */
24
+
25
+ @customElement('ox-input-multiple-colors')
26
+ export class OxInputMultipleColors extends OxFormField {
27
+ static styles = css`
28
+ :host {
29
+ display: inline-block;
30
+ }
31
+
32
+ #colors-container > div {
33
+ display: grid;
34
+ grid-template-columns: 22px 1fr 22px;
35
+ grid-gap: 5px;
36
+ align-items: center;
37
+ justify-content: left;
38
+ }
39
+
40
+ ox-input-color {
41
+ height: 25px;
42
+ width: 100%;
43
+ }
44
+
45
+ input[type='button'] {
46
+ width: 22px;
47
+ height: 25px;
48
+ border: 1px solid rgba(0, 0, 0, 0.15);
49
+ padding-top: 0px;
50
+ padding-bottom: 2px;
51
+ background-color: #f1f2f4;
52
+ color: #8f9192;
53
+ font-size: 16px;
54
+ }
55
+ `
56
+
57
+ @property({ type: Array }) value: string[] = []
58
+
59
+ @query('#colors-container') colorsContainer!: HTMLDivElement
60
+ @queryAll('ox-input-color') colors!: NodeListOf<OxInputColor>
61
+
62
+ firstUpdated() {
63
+ this.renderRoot.addEventListener('change', this._onValueChanged.bind(this))
64
+ }
65
+
66
+ render() {
67
+ return html`
68
+ <div id="colors-container">
69
+ ${(this.value || []).map(
70
+ (item, index) => html`
71
+ <div>
72
+ <input type="button" value="+" @click=${() => this._appendEditorColor()} data-index=${index} />
73
+
74
+ <ox-input-color .value=${item}> </ox-input-color>
75
+
76
+ ${(this.value || []).length > 1
77
+ ? html`
78
+ <input
79
+ type="button"
80
+ value="-"
81
+ @click=${(e: Event) => this._removeEditorColor(e)}
82
+ data-index=${index}
83
+ />
84
+ `
85
+ : html``}
86
+ </div>
87
+ `
88
+ )}
89
+ </div>
90
+ `
91
+ }
92
+
93
+ _onValueChanged() {
94
+ this.value = Array.from(this.colors).map(color => color.value!)
95
+ }
96
+
97
+ _appendEditorColor() {
98
+ this.value = [...this.value, 'black']
99
+
100
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
101
+ }
102
+
103
+ _removeEditorColor(e: Event) {
104
+ var values = []
105
+ for (var i = 0; i < this.value.length; i++) {
106
+ if (i == Number((e.target as HTMLElement).dataset.index)) continue
107
+ else values.push(this.value[i])
108
+ }
109
+
110
+ this.value = values
111
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
112
+ }
113
+ }