@operato/input 1.0.0-beta.3 → 1.0.0-beta.30
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/.storybook/main.js +2 -2
- package/.storybook/server.mjs +4 -4
- package/CHANGELOG.md +477 -0
- package/demo/index-multiple-colors.html +4 -1
- package/demo/index-partition-keys.html +2 -5
- package/demo/index-select.html +1 -1
- package/demo/index.html +4 -0
- package/dist/src/locales/en.d.ts +8 -0
- package/dist/src/locales/en.js +8 -0
- package/dist/src/locales/en.js.map +1 -1
- package/dist/src/locales/ko.d.ts +8 -0
- package/dist/src/locales/ko.js +8 -0
- package/dist/src/locales/ko.js.map +1 -1
- package/dist/src/locales/ms.d.ts +8 -0
- package/dist/src/locales/ms.js +8 -0
- package/dist/src/locales/ms.js.map +1 -1
- package/dist/src/locales/zh.d.ts +8 -0
- package/dist/src/locales/zh.js +8 -0
- package/dist/src/locales/zh.js.map +1 -1
- package/dist/src/ox-input-3dish.js +24 -8
- package/dist/src/ox-input-3dish.js.map +1 -1
- package/dist/src/ox-input-barcode.d.ts +1 -1
- package/dist/src/ox-input-barcode.js +14 -14
- package/dist/src/ox-input-barcode.js.map +1 -1
- package/dist/src/ox-input-color.js +16 -11
- package/dist/src/ox-input-color.js.map +1 -1
- package/dist/src/ox-input-crontab.js +28 -10
- package/dist/src/ox-input-crontab.js.map +1 -1
- package/dist/src/ox-input-file.js +5 -3
- package/dist/src/ox-input-file.js.map +1 -1
- package/dist/src/ox-input-key-values.d.ts +41 -0
- package/dist/src/ox-input-key-values.js +233 -0
- package/dist/src/ox-input-key-values.js.map +1 -0
- package/dist/src/ox-input-multiple-colors.d.ts +1 -0
- package/dist/src/ox-input-multiple-colors.js +29 -21
- package/dist/src/ox-input-multiple-colors.js.map +1 -1
- package/dist/src/ox-input-options.d.ts +1 -0
- package/dist/src/ox-input-options.js +54 -14
- package/dist/src/ox-input-options.js.map +1 -1
- package/dist/src/ox-input-partition-keys.d.ts +1 -0
- package/dist/src/ox-input-partition-keys.js +51 -23
- package/dist/src/ox-input-partition-keys.js.map +1 -1
- package/dist/src/ox-input-range.js +35 -38
- package/dist/src/ox-input-range.js.map +1 -1
- package/dist/src/ox-input-search.d.ts +0 -1
- package/dist/src/ox-input-search.js +14 -7
- package/dist/src/ox-input-search.js.map +1 -1
- package/dist/src/ox-input-unit.d.ts +17 -0
- package/dist/src/ox-input-unit.js +122 -0
- package/dist/src/ox-input-unit.js.map +1 -0
- package/dist/src/ox-input-value-map.d.ts +2 -2
- package/dist/src/ox-input-value-map.js +51 -15
- package/dist/src/ox-input-value-map.js.map +1 -1
- package/dist/src/ox-input-value-ranges.d.ts +2 -2
- package/dist/src/ox-input-value-ranges.js +50 -23
- package/dist/src/ox-input-value-ranges.js.map +1 -1
- package/dist/src/ox-input-work-shift.js +77 -43
- package/dist/src/ox-input-work-shift.js.map +1 -1
- package/dist/src/ox-select.js +9 -1
- package/dist/src/ox-select.js.map +1 -1
- package/dist/stories/ox-checkbox.stories.d.ts +39 -0
- package/dist/stories/ox-checkbox.stories.js +44 -0
- package/dist/stories/ox-checkbox.stories.js.map +1 -0
- package/dist/stories/ox-input-3dish.stories.d.ts +26 -0
- package/dist/stories/ox-input-3dish.stories.js +59 -0
- package/dist/stories/ox-input-3dish.stories.js.map +1 -0
- package/dist/stories/{index.stories.d.ts → ox-input-barcode.stories.d.ts} +11 -11
- package/dist/stories/ox-input-barcode.stories.js +24 -0
- package/dist/stories/ox-input-barcode.stories.js.map +1 -0
- package/dist/stories/ox-input-crontab.stories.d.ts +26 -0
- package/dist/stories/ox-input-crontab.stories.js +37 -0
- package/dist/stories/ox-input-crontab.stories.js.map +1 -0
- package/dist/stories/ox-input-file.stories.d.ts +49 -0
- package/dist/stories/ox-input-file.stories.js +48 -0
- package/dist/stories/ox-input-file.stories.js.map +1 -0
- package/dist/stories/ox-input-key-values.stories.d.ts +29 -0
- package/dist/stories/ox-input-key-values.stories.js +49 -0
- package/dist/stories/ox-input-key-values.stories.js.map +1 -0
- package/dist/stories/ox-input-multiple-colors.stories.d.ts +20 -0
- package/dist/stories/ox-input-multiple-colors.stories.js +167 -0
- package/dist/stories/ox-input-multiple-colors.stories.js.map +1 -0
- package/dist/stories/ox-input-options.stories.d.ts +25 -0
- package/dist/stories/ox-input-options.stories.js +33 -0
- package/dist/stories/ox-input-options.stories.js.map +1 -0
- package/dist/stories/ox-input-partition-keys.stories.d.ts +25 -0
- package/dist/stories/ox-input-partition-keys.stories.js +37 -0
- package/dist/stories/ox-input-partition-keys.stories.js.map +1 -0
- package/dist/stories/ox-input-range.stories.d.ts +37 -0
- package/dist/stories/ox-input-range.stories.js +28 -0
- package/dist/stories/ox-input-range.stories.js.map +1 -0
- package/dist/stories/ox-input-search.stories.d.ts +29 -0
- package/dist/stories/ox-input-search.stories.js +32 -0
- package/dist/stories/ox-input-search.stories.js.map +1 -0
- package/dist/stories/ox-input-unit.stories.d.ts +40 -0
- package/dist/stories/ox-input-unit.stories.js +42 -0
- package/dist/stories/ox-input-unit.stories.js.map +1 -0
- package/dist/stories/ox-input-value-map.stories.d.ts +35 -0
- package/dist/stories/ox-input-value-map.stories.js +37 -0
- package/dist/stories/ox-input-value-map.stories.js.map +1 -0
- package/dist/stories/ox-input-value-ranges.stories.d.ts +35 -0
- package/dist/stories/ox-input-value-ranges.stories.js +37 -0
- package/dist/stories/ox-input-value-ranges.stories.js.map +1 -0
- package/dist/stories/ox-input-work-shift.stories.d.ts +26 -0
- package/dist/stories/ox-input-work-shift.stories.js +59 -0
- package/dist/stories/ox-input-work-shift.stories.js.map +1 -0
- package/dist/stories/ox-select.stories.d.ts +30 -0
- package/dist/stories/ox-select.stories.js +83 -0
- package/dist/stories/ox-select.stories.js.map +1 -0
- package/dist/themes/common-grist-styles.d.ts +1 -0
- package/dist/themes/common-grist-styles.js +110 -0
- package/dist/themes/common-grist-styles.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -11
- package/src/locales/en.ts +8 -0
- package/src/locales/ko.ts +8 -0
- package/src/locales/ms.ts +8 -0
- package/src/locales/zh.ts +8 -0
- package/src/ox-input-3dish.ts +24 -8
- package/src/ox-input-barcode.ts +16 -15
- package/src/ox-input-color.ts +17 -11
- package/src/ox-input-crontab.ts +30 -10
- package/src/ox-input-file.ts +7 -6
- package/src/ox-input-key-values.ts +270 -0
- package/src/ox-input-multiple-colors.ts +29 -21
- package/src/ox-input-options.ts +53 -13
- package/src/ox-input-partition-keys.ts +51 -22
- package/src/ox-input-range.ts +35 -38
- package/src/ox-input-search.ts +14 -8
- package/src/ox-input-unit.ts +123 -0
- package/src/ox-input-value-map.ts +52 -16
- package/src/ox-input-value-ranges.ts +52 -25
- package/src/ox-input-work-shift.ts +78 -43
- package/src/ox-select.ts +12 -3
- package/stories/ox-checkbox.stories.ts +69 -0
- package/stories/ox-input-3dish.stories.ts +73 -0
- package/stories/ox-input-barcode.stories.ts +40 -0
- package/stories/ox-input-code.stories.ts_ +51 -0
- package/stories/ox-input-crontab.stories.ts +51 -0
- package/stories/ox-input-file.stories.ts +77 -0
- package/stories/ox-input-key-values.stories.ts +64 -0
- package/stories/ox-input-multiple-colors.stories.ts +178 -0
- package/stories/ox-input-options.stories.ts +47 -0
- package/stories/ox-input-partition-keys.stories.ts +51 -0
- package/stories/ox-input-range.stories.ts +45 -0
- package/stories/ox-input-search.stories.ts +47 -0
- package/stories/ox-input-unit.stories.ts +66 -0
- package/stories/ox-input-value-map.stories.ts +58 -0
- package/stories/ox-input-value-ranges.stories.ts +58 -0
- package/stories/ox-input-work-shift.stories.ts +73 -0
- package/stories/ox-select.stories.ts +101 -0
- package/themes/app-theme.css +142 -0
- package/themes/common-grist-styles.ts +110 -0
- package/themes/input-theme.css +19 -0
- package/xliff/en.xlf +24 -0
- package/xliff/ko.xlf +32 -0
- package/xliff/ms.xlf +24 -0
- package/xliff/zh.xlf +24 -0
- package/dist/stories/index.stories.js +0 -33
- package/dist/stories/index.stories.js.map +0 -1
- package/stories/index.stories.ts +0 -52
package/src/ox-input-barcode.ts
CHANGED
@@ -3,9 +3,10 @@ import '@operato/popup/ox-popup.js'
|
|
3
3
|
import { css, html } from 'lit'
|
4
4
|
import { customElement, property, query, state } from 'lit/decorators.js'
|
5
5
|
|
6
|
+
import { OxPopup } from '@operato/popup'
|
6
7
|
import { BrowserMultiFormatReader } from '@zxing/library'
|
8
|
+
|
7
9
|
import { OxFormField } from './ox-form-field.js'
|
8
|
-
import { OxPopup } from '@operato/popup'
|
9
10
|
|
10
11
|
const barcodeIcon = `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAYBAMAAAAfR1CMAAADKGlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxNDUgNzkuMTYzNDk5LCAyMDE4LzA4LzEzLTE2OjQwOjIyICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOnhtcE1NPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvbW0vIiB4bWxuczpzdFJlZj0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL3NUeXBlL1Jlc291cmNlUmVmIyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgQ0MgMjAxOSAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDpFNjM4RURDQkQ1OUExMUU5QkExMkQ4NUY3NkMxNzBFOSIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDpFNjM4RURDQ0Q1OUExMUU5QkExMkQ4NUY3NkMxNzBFOSI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkU2MzhFREM5RDU5QTExRTlCQTEyRDg1Rjc2QzE3MEU5IiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkU2MzhFRENBRDU5QTExRTlCQTEyRDg1Rjc2QzE3MEU5Ii8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+55pr/QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAAkUExURQAAAEdwTAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEus/7UCWQwAAAALdFJOU9YAg3wKBFBDSz9PnvQNDgAAAE9JREFUGNNjEEQFDKLJSnCOklkgg9QUJFn3RgZhRyS+iCGDEIp2RSBfQICRkRGIgTSQL4jCF6ScvxsZYOFT2T50/6D7Fz080MMLPTzRwhsAHVspfelur08AAAAASUVORK5CYII=`
|
11
12
|
|
@@ -18,9 +19,6 @@ export class OxInputBarcode extends OxFormField {
|
|
18
19
|
align-items: center;
|
19
20
|
border: none;
|
20
21
|
overflow: hidden;
|
21
|
-
background-color: #fff;
|
22
|
-
|
23
|
-
padding: var(--custom-input-barcode-field-padding) !important;
|
24
22
|
}
|
25
23
|
|
26
24
|
* {
|
@@ -32,23 +30,26 @@ export class OxInputBarcode extends OxFormField {
|
|
32
30
|
}
|
33
31
|
|
34
32
|
input {
|
35
|
-
flex: 1
|
36
|
-
border:
|
37
|
-
|
38
|
-
|
39
|
-
|
33
|
+
flex: 1;
|
34
|
+
border: 0;
|
35
|
+
border-bottom: var(--border-dark-color);
|
36
|
+
padding: var(--input-padding);
|
37
|
+
padding-right: 35px;
|
38
|
+
font: var(--input-font);
|
39
|
+
color: var(--primary-text-color);
|
40
|
+
}
|
41
|
+
input:focus {
|
42
|
+
outline: none;
|
43
|
+
border-bottom: 1px solid var(--primary-color);
|
40
44
|
}
|
41
45
|
|
42
46
|
#scan-button {
|
43
47
|
display: block;
|
48
|
+
position: relative;
|
49
|
+
margin-left: -30px;
|
44
50
|
width: 30px;
|
45
|
-
height: 100%;
|
46
|
-
min-height: 24px;
|
47
51
|
border: none;
|
48
|
-
background
|
49
|
-
background-repeat: no-repeat;
|
50
|
-
background-position: center;
|
51
|
-
background-image: var(--barcodescan-input-button-icon);
|
52
|
+
background: var(--barcodescan-input-button-icon) no-repeat center center;
|
52
53
|
}
|
53
54
|
|
54
55
|
#scan-button[hidden] {
|
package/src/ox-input-color.ts
CHANGED
@@ -7,9 +7,10 @@ import '@operato/color-picker/paper-color-picker.js'
|
|
7
7
|
import { css, html } from 'lit'
|
8
8
|
import { customElement, property } from 'lit/decorators.js'
|
9
9
|
|
10
|
-
import { OxFormField } from './ox-form-field'
|
11
10
|
import { tinycolor } from '@thebespokepixel/es-tinycolor'
|
12
11
|
|
12
|
+
import { OxFormField } from './ox-form-field'
|
13
|
+
|
13
14
|
/**
|
14
15
|
색상을 입력하는데 사용되는 입력 컴포넌트이다.
|
15
16
|
화면상에는 두개의 입력 필드가 보이며, 하나는 색상값을 키보드로 직접 입력하는 입력 픽드이며,
|
@@ -180,18 +181,24 @@ export class OxInputColor extends OxFormField {
|
|
180
181
|
}
|
181
182
|
|
182
183
|
input[type='text'] {
|
183
|
-
padding-right: 24px;
|
184
184
|
width: 100%;
|
185
|
-
|
186
|
-
|
187
|
-
|
185
|
+
border: 0;
|
186
|
+
border-bottom: var(--border-dark-color);
|
187
|
+
padding: var(--input-padding);
|
188
|
+
font: var(--input-font);
|
189
|
+
color: var(--primary-text-color);
|
190
|
+
padding-right: 35px;
|
191
|
+
}
|
192
|
+
input:focus {
|
193
|
+
outline: none;
|
194
|
+
border-bottom: 1px solid var(--primary-color);
|
188
195
|
}
|
189
196
|
|
190
197
|
a {
|
191
198
|
-webkit-appearance: none;
|
192
199
|
display: flex;
|
193
200
|
position: absolute;
|
194
|
-
width:
|
201
|
+
width: 35px;
|
195
202
|
height: 100%;
|
196
203
|
box-sizing: border-box;
|
197
204
|
align-items: center;
|
@@ -199,11 +206,10 @@ export class OxInputColor extends OxFormField {
|
|
199
206
|
}
|
200
207
|
|
201
208
|
span {
|
202
|
-
width:
|
203
|
-
height:
|
204
|
-
|
205
|
-
border-radius:
|
206
|
-
border: 1px solid #eee;
|
209
|
+
width: 80%;
|
210
|
+
height: 60%;
|
211
|
+
border: var(--border-dark-color);
|
212
|
+
border-radius: var(--border-radius);
|
207
213
|
}
|
208
214
|
|
209
215
|
span.transparent {
|
package/src/ox-input-crontab.ts
CHANGED
@@ -84,7 +84,6 @@ export class OxInputCrontab extends OxFormField {
|
|
84
84
|
width: 100%;
|
85
85
|
height: 100%;
|
86
86
|
border: 0;
|
87
|
-
background-color: var(--main-section-background-color);
|
88
87
|
}
|
89
88
|
|
90
89
|
:host * {
|
@@ -118,32 +117,36 @@ export class OxInputCrontab extends OxFormField {
|
|
118
117
|
grid-column: 4 / span 3;
|
119
118
|
width: 100%;
|
120
119
|
height: 100%;
|
121
|
-
|
120
|
+
padding: var(--input-padding);
|
121
|
+
border: 0;
|
122
|
+
border-bottom: var(--border-dark-color);
|
122
123
|
text-transform: capitalize;
|
123
|
-
|
124
|
-
|
124
|
+
font: var(--label-font);
|
125
|
+
color: var(--label-color);
|
125
126
|
}
|
126
127
|
|
127
128
|
input {
|
128
129
|
width: 100%;
|
129
130
|
margin-top: var(--margin-default);
|
130
131
|
padding: 5px;
|
131
|
-
border
|
132
|
-
border: var(--border-dark-color);
|
133
|
-
|
132
|
+
border: 0;
|
133
|
+
border-bottom: var(--border-dark-color);
|
134
|
+
padding: var(--input-padding);
|
135
|
+
font: var(--input-font);
|
136
|
+
color: var(--primary-text-color);
|
134
137
|
}
|
135
138
|
input:focus {
|
136
|
-
|
139
|
+
outline: none;
|
140
|
+
border-bottom: 1px solid var(--primary-color);
|
137
141
|
}
|
138
142
|
|
139
143
|
input:invalid {
|
140
|
-
border: 1px solid var(--status-danger-color);
|
144
|
+
border-bottom: 1px solid var(--status-danger-color);
|
141
145
|
color: var(--status-danger-color);
|
142
146
|
}
|
143
147
|
|
144
148
|
label {
|
145
149
|
width: 100%;
|
146
|
-
height: 100%;
|
147
150
|
font: normal 0.8em var(--theme-font);
|
148
151
|
color: var(--primary-color);
|
149
152
|
}
|
@@ -370,6 +373,23 @@ export class OxInputCrontab extends OxFormField {
|
|
370
373
|
`
|
371
374
|
)}
|
372
375
|
</div>
|
376
|
+
<button
|
377
|
+
id="clear"
|
378
|
+
@click=${(e: Event) => {
|
379
|
+
e.preventDefault()
|
380
|
+
e.stopPropagation()
|
381
|
+
this.value = ''
|
382
|
+
this.dispatchEvent(
|
383
|
+
new CustomEvent('change', {
|
384
|
+
bubbles: true,
|
385
|
+
composed: true,
|
386
|
+
detail: this.value
|
387
|
+
})
|
388
|
+
)
|
389
|
+
}}
|
390
|
+
>
|
391
|
+
Clear
|
392
|
+
</button>
|
373
393
|
</form>
|
374
394
|
`
|
375
395
|
}
|
package/src/ox-input-file.ts
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
import '@material/mwc-icon'
|
2
2
|
|
3
|
-
import {
|
3
|
+
import { css, html, PropertyValues } from 'lit'
|
4
4
|
import { customElement, property, query } from 'lit/decorators.js'
|
5
5
|
|
6
|
+
import { ScrollbarStyles } from '@operato/styles'
|
6
7
|
import { FileDropHelper } from '@operato/utils'
|
8
|
+
|
7
9
|
import { OxFormField } from './ox-form-field.js'
|
8
|
-
import { ScrollbarStyles } from '@operato/styles'
|
9
10
|
|
10
11
|
@customElement('ox-input-file')
|
11
12
|
export class OxInputFile extends OxFormField {
|
@@ -85,9 +86,9 @@ export class OxInputFile extends OxFormField {
|
|
85
86
|
|
86
87
|
@property({ type: Boolean }) multiple?: boolean
|
87
88
|
@property({ type: String }) accept?: string
|
88
|
-
@property({ type: String }) icon?: string
|
89
|
+
@property({ type: String }) icon?: string = 'upload'
|
89
90
|
@property({ type: String }) label?: string
|
90
|
-
@property({ type: String }) description?: string
|
91
|
+
@property({ type: String }) description?: string = 'drop files here!'
|
91
92
|
@property({ type: Boolean, reflect: true, attribute: 'hide-filelist' })
|
92
93
|
hideFileList: boolean = false
|
93
94
|
@property({ type: Boolean, reflect: true, attribute: 'attach-filelist' })
|
@@ -99,9 +100,9 @@ export class OxInputFile extends OxFormField {
|
|
99
100
|
var files: File[] = this.value || []
|
100
101
|
|
101
102
|
return html`
|
102
|
-
<mwc-icon
|
103
|
+
<mwc-icon>${this.icon || 'upload'}</mwc-icon>
|
103
104
|
|
104
|
-
<span
|
105
|
+
<span>${this.description || 'drop files here!'}</span>
|
105
106
|
|
106
107
|
<input
|
107
108
|
id="input-file"
|
@@ -0,0 +1,270 @@
|
|
1
|
+
/**
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
3
|
+
*/
|
4
|
+
|
5
|
+
import '@material/mwc-icon'
|
6
|
+
|
7
|
+
import { css, html } from 'lit'
|
8
|
+
import { customElement, property, queryAll } from 'lit/decorators.js'
|
9
|
+
|
10
|
+
import { OxFormField } from './ox-form-field'
|
11
|
+
|
12
|
+
type KeyValues = { [key: string]: any }
|
13
|
+
type ArrayedKeyValues = { key: string; value: any }
|
14
|
+
|
15
|
+
/**
|
16
|
+
input component for key-value map
|
17
|
+
|
18
|
+
Example:
|
19
|
+
|
20
|
+
<ox-input-key-values
|
21
|
+
value=${map}
|
22
|
+
</ox-input-key-values>
|
23
|
+
*/
|
24
|
+
@customElement('ox-input-key-values')
|
25
|
+
export class OxInputKeyValues extends OxFormField {
|
26
|
+
static styles = css`
|
27
|
+
:host {
|
28
|
+
display: flex;
|
29
|
+
flex-direction: column;
|
30
|
+
overflow: hidden;
|
31
|
+
margin-bottom: var(--margin-wide);
|
32
|
+
}
|
33
|
+
|
34
|
+
div {
|
35
|
+
display: flex;
|
36
|
+
flex-flow: row nowrap;
|
37
|
+
gap: var(--margin-default);
|
38
|
+
margin-bottom: var(--margin-narrow);
|
39
|
+
}
|
40
|
+
|
41
|
+
button {
|
42
|
+
border: var(--button-border);
|
43
|
+
border-radius: var(--border-radius);
|
44
|
+
background-color: var(--button-background-color);
|
45
|
+
padding: var(--padding-narrow) var(--padding-default);
|
46
|
+
line-height: 0.8;
|
47
|
+
color: var(--button-color);
|
48
|
+
cursor: pointer;
|
49
|
+
}
|
50
|
+
button + button {
|
51
|
+
margin-left: -5px;
|
52
|
+
}
|
53
|
+
button mwc-icon {
|
54
|
+
font-size: var(--fontsize-default);
|
55
|
+
}
|
56
|
+
button:focus,
|
57
|
+
button:hover,
|
58
|
+
button:active {
|
59
|
+
border: var(--button-activ-border);
|
60
|
+
background-color: var(--button-background-focus-color);
|
61
|
+
color: var(--theme-white-color);
|
62
|
+
}
|
63
|
+
|
64
|
+
input {
|
65
|
+
flex: 1;
|
66
|
+
border: 0;
|
67
|
+
border-bottom: var(--border-dark-color);
|
68
|
+
padding: var(--input-padding);
|
69
|
+
font: var(--input-font);
|
70
|
+
color: var(--primary-text-color);
|
71
|
+
}
|
72
|
+
input:focus {
|
73
|
+
outline: none;
|
74
|
+
border-bottom: 1px solid var(--primary-color);
|
75
|
+
}
|
76
|
+
button.hidden {
|
77
|
+
opacity: 0;
|
78
|
+
cursor: default;
|
79
|
+
}
|
80
|
+
`
|
81
|
+
|
82
|
+
@property({ type: Object }) value: KeyValues = {}
|
83
|
+
@property({ type: Object }) options: { display: string; value: string }[] = []
|
84
|
+
|
85
|
+
private _changingNow: boolean = false
|
86
|
+
|
87
|
+
firstUpdated() {
|
88
|
+
this.renderRoot.addEventListener('change', this._onChange.bind(this))
|
89
|
+
}
|
90
|
+
|
91
|
+
render() {
|
92
|
+
const value = !this.value || typeof this.value !== 'object' ? {} : this.value
|
93
|
+
const options = this.options || []
|
94
|
+
|
95
|
+
return html`
|
96
|
+
${this._toArray(value).map(
|
97
|
+
item => html`
|
98
|
+
<div data-record>
|
99
|
+
<input type="text" data-key placeholder="key" .value=${item.key} />
|
100
|
+
<input type="text" data-value placeholder="value" .value=${item.value} list="value-template" />
|
101
|
+
<button class="record-action" @click=${(e: MouseEvent) => this._delete(e)} tabindex="-1">
|
102
|
+
<mwc-icon>remove</mwc-icon>
|
103
|
+
</button>
|
104
|
+
<button class="record-action" @click=${(e: MouseEvent) => this._up(e)} tabindex="-1">
|
105
|
+
<mwc-icon>arrow_upward</mwc-icon>
|
106
|
+
</button>
|
107
|
+
<button class="record-action" @click=${(e: MouseEvent) => this._down(e)} tabindex="-1">
|
108
|
+
<mwc-icon>arrow_downward</mwc-icon>
|
109
|
+
</button>
|
110
|
+
</div>
|
111
|
+
`
|
112
|
+
)}
|
113
|
+
|
114
|
+
<div data-record-new>
|
115
|
+
<input type="text" data-key placeholder="key" value="" />
|
116
|
+
<input type="text" data-value placeholder="value" value="" list="value-template" />
|
117
|
+
<button class="record-action" @click=${(e: MouseEvent) => this._add()} tabindex="-1">
|
118
|
+
<mwc-icon>add</mwc-icon>
|
119
|
+
</button>
|
120
|
+
<button class="hidden"><mwc-icon>add</mwc-icon></button>
|
121
|
+
<button class="hidden"><mwc-icon>add</mwc-icon></button>
|
122
|
+
</div>
|
123
|
+
|
124
|
+
<datalist id="value-template">
|
125
|
+
${options.map(({ display, value }) => html` <option value="${value}">${display}</option> `)}
|
126
|
+
</datalist>
|
127
|
+
`
|
128
|
+
}
|
129
|
+
|
130
|
+
_onChange(e: Event) {
|
131
|
+
if (this._changingNow) {
|
132
|
+
return
|
133
|
+
}
|
134
|
+
|
135
|
+
this._changingNow = true
|
136
|
+
|
137
|
+
const input = e.target as HTMLInputElement
|
138
|
+
|
139
|
+
const record = (e.target as Element).closest('[data-record],[data-record-new]') as HTMLElement
|
140
|
+
|
141
|
+
if (record.hasAttribute('data-record')) {
|
142
|
+
this._build()
|
143
|
+
} else if (record.hasAttribute('data-record-new') && input.hasAttribute('data-value')) {
|
144
|
+
this._add()
|
145
|
+
}
|
146
|
+
|
147
|
+
this._changingNow = false
|
148
|
+
}
|
149
|
+
|
150
|
+
_build(includeNewRecord?: boolean) {
|
151
|
+
if (includeNewRecord) {
|
152
|
+
var records = this.renderRoot.querySelectorAll('[data-record],[data-record-new]') as NodeListOf<HTMLElement>
|
153
|
+
} else {
|
154
|
+
var records = this.renderRoot.querySelectorAll('[data-record]') as NodeListOf<HTMLElement>
|
155
|
+
}
|
156
|
+
|
157
|
+
var newmap: KeyValues = {}
|
158
|
+
|
159
|
+
for (var i = 0; i < records.length; i++) {
|
160
|
+
var record = records[i]
|
161
|
+
|
162
|
+
const key = (record.querySelector('[data-key]') as HTMLInputElement).value
|
163
|
+
const inputs = record.querySelectorAll(
|
164
|
+
'[data-value]:not([style*="display: none"])'
|
165
|
+
) as NodeListOf<HTMLInputElement>
|
166
|
+
|
167
|
+
if (!inputs || inputs.length == 0) {
|
168
|
+
continue
|
169
|
+
}
|
170
|
+
|
171
|
+
var input = inputs[inputs.length - 1]
|
172
|
+
|
173
|
+
var value = input.value
|
174
|
+
|
175
|
+
if (key) {
|
176
|
+
newmap[key] = value || ''
|
177
|
+
}
|
178
|
+
}
|
179
|
+
|
180
|
+
this.value = newmap
|
181
|
+
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))
|
182
|
+
}
|
183
|
+
|
184
|
+
/* map아이템들을 template(dom-repeat)용 배열로 변환하는 함수 */
|
185
|
+
_toArray(map: KeyValues) {
|
186
|
+
var array: ArrayedKeyValues[] = []
|
187
|
+
|
188
|
+
for (var key in map) {
|
189
|
+
array.push({
|
190
|
+
key: key,
|
191
|
+
value: map[key]
|
192
|
+
})
|
193
|
+
}
|
194
|
+
|
195
|
+
return array
|
196
|
+
}
|
197
|
+
|
198
|
+
_add() {
|
199
|
+
this._build(true)
|
200
|
+
|
201
|
+
const inputs = this.renderRoot.querySelectorAll(
|
202
|
+
'[data-record-new] input:not([style*="display: none"])'
|
203
|
+
) as NodeListOf<HTMLInputElement & { value: any }>
|
204
|
+
|
205
|
+
for (var i = 0; i < inputs.length; i++) {
|
206
|
+
let input = inputs[i]
|
207
|
+
|
208
|
+
if (input.type == 'checkbox') input.checked = false
|
209
|
+
else input.value = ''
|
210
|
+
}
|
211
|
+
|
212
|
+
inputs[0].focus()
|
213
|
+
}
|
214
|
+
|
215
|
+
_delete(e: MouseEvent) {
|
216
|
+
const record = (e.target as Element).closest('[data-record]') as HTMLElement
|
217
|
+
|
218
|
+
;(record!.querySelector('[data-key]') as HTMLInputElement)!.value = ''
|
219
|
+
|
220
|
+
this._build()
|
221
|
+
}
|
222
|
+
|
223
|
+
@queryAll('[data-record]') records!: NodeListOf<HTMLElement>
|
224
|
+
|
225
|
+
_up(e: MouseEvent) {
|
226
|
+
const record = (e.target as Element).closest('[data-record]') as HTMLElement
|
227
|
+
const array = Array.from(this.records)
|
228
|
+
const index = array.indexOf(record) - 1
|
229
|
+
|
230
|
+
if (index < 0) {
|
231
|
+
return
|
232
|
+
}
|
233
|
+
|
234
|
+
const deleted = array.splice(index, 1)
|
235
|
+
array.splice(index + 1, 0, ...deleted)
|
236
|
+
|
237
|
+
this.value = array.reduce((sum, record) => {
|
238
|
+
const key = (record.querySelector('[data-key]') as HTMLInputElement).value
|
239
|
+
const value = (record.querySelector('[data-value]') as HTMLInputElement).value
|
240
|
+
|
241
|
+
sum[key] = value
|
242
|
+
return sum
|
243
|
+
}, {} as { [key: string]: string })
|
244
|
+
|
245
|
+
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))
|
246
|
+
}
|
247
|
+
|
248
|
+
_down(e: MouseEvent) {
|
249
|
+
const record = (e.target as Element).closest('[data-record]') as HTMLElement
|
250
|
+
const array = Array.from(this.records)
|
251
|
+
const index = array.indexOf(record)
|
252
|
+
|
253
|
+
if (index > array.length) {
|
254
|
+
return
|
255
|
+
}
|
256
|
+
|
257
|
+
array.splice(index, 1)
|
258
|
+
array.splice(index + 1, 0, record)
|
259
|
+
|
260
|
+
this.value = array.reduce((sum, record) => {
|
261
|
+
const key = (record.querySelector('[data-key]') as HTMLInputElement).value
|
262
|
+
const value = (record.querySelector('[data-value]') as HTMLInputElement).value
|
263
|
+
|
264
|
+
sum[key] = value
|
265
|
+
return sum
|
266
|
+
}, {} as { [key: string]: string })
|
267
|
+
|
268
|
+
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))
|
269
|
+
}
|
270
|
+
}
|
@@ -3,6 +3,7 @@
|
|
3
3
|
*/
|
4
4
|
|
5
5
|
import './ox-input-color.js'
|
6
|
+
import '@material/mwc-icon'
|
6
7
|
|
7
8
|
import { css, html } from 'lit'
|
8
9
|
import { customElement, property, query, queryAll } from 'lit/decorators.js'
|
@@ -28,29 +29,38 @@ export class OxInputMultipleColors extends OxFormField {
|
|
28
29
|
:host {
|
29
30
|
display: inline-block;
|
30
31
|
}
|
31
|
-
|
32
32
|
#colors-container > div {
|
33
33
|
display: grid;
|
34
|
-
grid-template-columns:
|
35
|
-
grid-gap:
|
34
|
+
grid-template-columns: 34px 1fr 34px;
|
35
|
+
grid-gap: var(--margin-default);
|
36
36
|
align-items: center;
|
37
37
|
justify-content: left;
|
38
|
+
margin-bottom: var(--margin-narrow);
|
38
39
|
}
|
39
40
|
|
40
41
|
ox-input-color {
|
41
|
-
height: 25px;
|
42
42
|
width: 100%;
|
43
43
|
}
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
border:
|
49
|
-
|
50
|
-
padding
|
51
|
-
|
52
|
-
color:
|
53
|
-
|
45
|
+
button {
|
46
|
+
height: 100%;
|
47
|
+
border: var(--button-border);
|
48
|
+
border-radius: var(--border-radius);
|
49
|
+
background-color: var(--button-background-color);
|
50
|
+
padding: var(--padding-narrow) var(--padding-default);
|
51
|
+
line-height: 0.8;
|
52
|
+
color: var(--button-color);
|
53
|
+
cursor: pointer;
|
54
|
+
}
|
55
|
+
button mwc-icon {
|
56
|
+
font-size: var(--fontsize-default);
|
57
|
+
}
|
58
|
+
button:focus,
|
59
|
+
button:hover,
|
60
|
+
button:active {
|
61
|
+
border: var(--button-activ-border);
|
62
|
+
background-color: var(--button-background-focus-color);
|
63
|
+
color: var(--theme-white-color);
|
54
64
|
}
|
55
65
|
`
|
56
66
|
|
@@ -69,18 +79,16 @@ export class OxInputMultipleColors extends OxFormField {
|
|
69
79
|
${(this.value || []).map(
|
70
80
|
(item, index) => html`
|
71
81
|
<div>
|
72
|
-
<
|
73
|
-
|
82
|
+
<button @click=${() => this._appendEditorColor()} data-index=${index}>
|
83
|
+
<mwc-icon>add</mwc-icon>
|
84
|
+
</button>
|
74
85
|
<ox-input-color .value=${item}> </ox-input-color>
|
75
86
|
|
76
87
|
${(this.value || []).length > 1
|
77
88
|
? html`
|
78
|
-
<
|
79
|
-
|
80
|
-
|
81
|
-
@click=${(e: Event) => this._removeEditorColor(e)}
|
82
|
-
data-index=${index}
|
83
|
-
/>
|
89
|
+
<button @click=${(e: Event) => this._removeEditorColor(e)} data-index=${index}>
|
90
|
+
<mwc-icon>remove</mwc-icon>
|
91
|
+
</button>
|
84
92
|
`
|
85
93
|
: html``}
|
86
94
|
</div>
|
package/src/ox-input-options.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
/**
|
2
2
|
* @license Copyright © HatioLab Inc. All rights reserved.
|
3
3
|
*/
|
4
|
+
import '@material/mwc-icon'
|
4
5
|
|
5
6
|
import { css, html } from 'lit'
|
6
7
|
import { customElement, property } from 'lit/decorators.js'
|
@@ -12,23 +13,58 @@ type Option = { text: string; value: string }
|
|
12
13
|
@customElement('ox-input-options')
|
13
14
|
export class OxInputOptions extends OxFormField {
|
14
15
|
static styles = css`
|
15
|
-
|
16
|
-
display:
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
:host {
|
17
|
+
display: flex;
|
18
|
+
flex-direction: column;
|
19
|
+
overflow: hidden;
|
20
|
+
margin-bottom: var(--margin-wide);
|
20
21
|
}
|
21
22
|
|
22
|
-
|
23
|
-
|
23
|
+
div {
|
24
|
+
display: flex;
|
25
|
+
flex-flow: row nowrap;
|
26
|
+
gap: var(--margin-default);
|
27
|
+
margin-bottom: var(--margin-narrow);
|
24
28
|
}
|
25
29
|
|
26
|
-
|
27
|
-
|
30
|
+
button {
|
31
|
+
border: var(--button-border);
|
32
|
+
border-radius: var(--border-radius);
|
33
|
+
background-color: var(--button-background-color);
|
34
|
+
padding: var(--padding-narrow) var(--padding-default);
|
35
|
+
line-height: 0.8;
|
36
|
+
color: var(--button-color);
|
37
|
+
cursor: pointer;
|
38
|
+
}
|
39
|
+
button + button {
|
40
|
+
margin-left: -5px;
|
41
|
+
}
|
42
|
+
button mwc-icon {
|
43
|
+
font-size: var(--fontsize-default);
|
44
|
+
}
|
45
|
+
button:focus,
|
46
|
+
button:hover,
|
47
|
+
button:active {
|
48
|
+
border: var(--button-activ-border);
|
49
|
+
background-color: var(--button-background-focus-color);
|
50
|
+
color: var(--theme-white-color);
|
28
51
|
}
|
29
52
|
|
30
|
-
|
31
|
-
|
53
|
+
input {
|
54
|
+
flex: 1;
|
55
|
+
border: 0;
|
56
|
+
border-bottom: var(--border-dark-color);
|
57
|
+
padding: var(--input-padding);
|
58
|
+
font: var(--input-font);
|
59
|
+
color: var(--primary-text-color);
|
60
|
+
}
|
61
|
+
input:focus {
|
62
|
+
outline: none;
|
63
|
+
border-bottom: 1px solid var(--primary-color);
|
64
|
+
}
|
65
|
+
button.hidden {
|
66
|
+
opacity: 0;
|
67
|
+
cursor: default;
|
32
68
|
}
|
33
69
|
`
|
34
70
|
|
@@ -47,7 +83,9 @@ export class OxInputOptions extends OxFormField {
|
|
47
83
|
<div data-record="">
|
48
84
|
<input type="text" data-text="" placeholder="text" .value=${item.text} />
|
49
85
|
<input type="text" data-value="" placeholder="value" .value=${item.value} />
|
50
|
-
<button class="record-action" @click=${(e: MouseEvent) => this._delete(e)} tabindex="-1"
|
86
|
+
<button class="record-action" @click=${(e: MouseEvent) => this._delete(e)} tabindex="-1">
|
87
|
+
<mwc-icon>remove</mwc-icon>
|
88
|
+
</button>
|
51
89
|
</div>
|
52
90
|
`
|
53
91
|
)}
|
@@ -55,7 +93,9 @@ export class OxInputOptions extends OxFormField {
|
|
55
93
|
<div data-record-new="">
|
56
94
|
<input type="text" data-text="" placeholder="text" value="" />
|
57
95
|
<input type="text" data-value="" placeholder="value" value="" @change=${(e: Event) => this._add()} />
|
58
|
-
<button class="record-action" @click=${(e: MouseEvent) => this._add()} tabindex="-1"
|
96
|
+
<button class="record-action" @click=${(e: MouseEvent) => this._add()} tabindex="-1">
|
97
|
+
<mwc-icon>add</mwc-icon>
|
98
|
+
</button>
|
59
99
|
</div>
|
60
100
|
`
|
61
101
|
}
|