@operato/input 1.0.0-alpha.9 → 1.0.0-beta.2
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 +412 -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-code.d.ts +1 -1
- package/dist/src/ox-input-code.js +12 -7
- package/dist/src/ox-input-code.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-code.ts +14 -8
- 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
@@ -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
|
+
}
|
@@ -18,8 +18,8 @@ import { OxInputColor } from './ox-input-color.js'
|
|
18
18
|
|
19
19
|
Example:
|
20
20
|
|
21
|
-
<ox-input-multiple-
|
22
|
-
</ox-input-multiple-
|
21
|
+
<ox-input-multiple-colors values=${values}>
|
22
|
+
</ox-input-multiple-colors>
|
23
23
|
*/
|
24
24
|
|
25
25
|
@customElement('ox-input-multiple-colors')
|
package/src/ox-input-options.ts
CHANGED
@@ -0,0 +1,243 @@
|
|
1
|
+
/**
|
2
|
+
* @license Copyright © HatioLab Inc. All rights reserved.
|
3
|
+
*/
|
4
|
+
|
5
|
+
import { css, html } from 'lit'
|
6
|
+
import { customElement, property, queryAll } from 'lit/decorators.js'
|
7
|
+
|
8
|
+
import { OxFormField } from './ox-form-field'
|
9
|
+
|
10
|
+
type PartitionKeys = { [key: string]: any }
|
11
|
+
type ArrayedPartitionKeys = { key: string; value: any }
|
12
|
+
|
13
|
+
/**
|
14
|
+
key-value map for partitions editor element
|
15
|
+
|
16
|
+
Example:
|
17
|
+
|
18
|
+
<ox-input-partition-keys
|
19
|
+
value=${map}
|
20
|
+
</ox-input-partition-keys>
|
21
|
+
*/
|
22
|
+
@customElement('ox-input-partition-keys')
|
23
|
+
export class OxInputPartitionKeys extends OxFormField {
|
24
|
+
static styles = css`
|
25
|
+
:host {
|
26
|
+
display: flex;
|
27
|
+
flex-direction: column;
|
28
|
+
align-content: center;
|
29
|
+
|
30
|
+
width: 100%;
|
31
|
+
overflow: hidden;
|
32
|
+
border: 1px solid #ccc;
|
33
|
+
}
|
34
|
+
|
35
|
+
div {
|
36
|
+
display: flex;
|
37
|
+
flex-flow: row nowrap;
|
38
|
+
align-items: center;
|
39
|
+
|
40
|
+
border-bottom: 1px solid #c0c0c0;
|
41
|
+
}
|
42
|
+
|
43
|
+
div:last-child {
|
44
|
+
border-bottom: none;
|
45
|
+
}
|
46
|
+
|
47
|
+
div > * {
|
48
|
+
min-width: 0px;
|
49
|
+
margin: 2px;
|
50
|
+
padding: 0;
|
51
|
+
}
|
52
|
+
|
53
|
+
button {
|
54
|
+
width: 20px;
|
55
|
+
text-align: center;
|
56
|
+
}
|
57
|
+
|
58
|
+
input {
|
59
|
+
flex: 1;
|
60
|
+
}
|
61
|
+
`
|
62
|
+
|
63
|
+
@property({ type: Object }) value: PartitionKeys = {}
|
64
|
+
|
65
|
+
private _changingNow: boolean = false
|
66
|
+
|
67
|
+
firstUpdated() {
|
68
|
+
this.renderRoot.addEventListener('change', this._onChange.bind(this))
|
69
|
+
}
|
70
|
+
|
71
|
+
render() {
|
72
|
+
const value = !this.value || typeof this.value !== 'object' ? {} : this.value
|
73
|
+
|
74
|
+
return html`
|
75
|
+
${this._toArray(value).map(
|
76
|
+
item => html`
|
77
|
+
<div data-record>
|
78
|
+
<input type="text" data-key placeholder="key" .value=${item.key} />
|
79
|
+
<input type="text" data-value placeholder="value" .value=${item.value} list="value-template" />
|
80
|
+
<button class="record-action" @click=${(e: MouseEvent) => this._delete(e)} tabindex="-1">-</button>
|
81
|
+
<button class="record-action" @click=${(e: MouseEvent) => this._up(e)} tabindex="-1">↑</button>
|
82
|
+
<button class="record-action" @click=${(e: MouseEvent) => this._down(e)} tabindex="-1">↓</button>
|
83
|
+
</div>
|
84
|
+
`
|
85
|
+
)}
|
86
|
+
|
87
|
+
<div data-record-new>
|
88
|
+
<input type="text" data-key placeholder="key" value="" />
|
89
|
+
<input type="text" data-value placeholder="value" value="" list="value-template" />
|
90
|
+
<button class="record-action" @click=${(e: MouseEvent) => this._add()} tabindex="-1">+</button>
|
91
|
+
</div>
|
92
|
+
|
93
|
+
<datalist id="value-template">
|
94
|
+
<option value="%YYYY">year</option>
|
95
|
+
<option value="%MM">month</option>
|
96
|
+
<option value="%DD">day</option>
|
97
|
+
<option value="%YYYYMMDD">date</option>
|
98
|
+
</datalist>
|
99
|
+
`
|
100
|
+
}
|
101
|
+
|
102
|
+
_onChange(e: Event) {
|
103
|
+
if (this._changingNow) {
|
104
|
+
return
|
105
|
+
}
|
106
|
+
|
107
|
+
this._changingNow = true
|
108
|
+
|
109
|
+
const input = e.target as HTMLInputElement
|
110
|
+
var value = input.value
|
111
|
+
|
112
|
+
const record = (e.target as Element).closest('[data-record],[data-record-new]') as HTMLElement
|
113
|
+
|
114
|
+
if (record.hasAttribute('data-record')) {
|
115
|
+
this._build()
|
116
|
+
} else if (record.hasAttribute('data-record-new') && input.hasAttribute('data-value')) {
|
117
|
+
this._add()
|
118
|
+
}
|
119
|
+
|
120
|
+
this._changingNow = false
|
121
|
+
}
|
122
|
+
|
123
|
+
_build(includeNewRecord?: boolean) {
|
124
|
+
if (includeNewRecord) {
|
125
|
+
var records = this.renderRoot.querySelectorAll('[data-record],[data-record-new]') as NodeListOf<HTMLElement>
|
126
|
+
} else {
|
127
|
+
var records = this.renderRoot.querySelectorAll('[data-record]') as NodeListOf<HTMLElement>
|
128
|
+
}
|
129
|
+
|
130
|
+
var newmap: PartitionKeys = {}
|
131
|
+
|
132
|
+
for (var i = 0; i < records.length; i++) {
|
133
|
+
var record = records[i]
|
134
|
+
|
135
|
+
const key = (record.querySelector('[data-key]') as HTMLInputElement).value
|
136
|
+
const inputs = record.querySelectorAll(
|
137
|
+
'[data-value]:not([style*="display: none"])'
|
138
|
+
) as NodeListOf<HTMLInputElement>
|
139
|
+
|
140
|
+
if (!inputs || inputs.length == 0) {
|
141
|
+
continue
|
142
|
+
}
|
143
|
+
|
144
|
+
var input = inputs[inputs.length - 1]
|
145
|
+
|
146
|
+
var value = input.value
|
147
|
+
|
148
|
+
if (key) {
|
149
|
+
newmap[key] = value || ''
|
150
|
+
}
|
151
|
+
}
|
152
|
+
|
153
|
+
this.value = newmap
|
154
|
+
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))
|
155
|
+
}
|
156
|
+
|
157
|
+
/* map아이템들을 template(dom-repeat)용 배열로 변환하는 함수 */
|
158
|
+
_toArray(map: PartitionKeys) {
|
159
|
+
var array: ArrayedPartitionKeys[] = []
|
160
|
+
|
161
|
+
for (var key in map) {
|
162
|
+
array.push({
|
163
|
+
key: key,
|
164
|
+
value: map[key]
|
165
|
+
})
|
166
|
+
}
|
167
|
+
|
168
|
+
return array
|
169
|
+
}
|
170
|
+
|
171
|
+
_add() {
|
172
|
+
this._build(true)
|
173
|
+
|
174
|
+
const inputs = this.renderRoot.querySelectorAll(
|
175
|
+
'[data-record-new] input:not([style*="display: none"])'
|
176
|
+
) as NodeListOf<HTMLInputElement & { value: any }>
|
177
|
+
|
178
|
+
for (var i = 0; i < inputs.length; i++) {
|
179
|
+
let input = inputs[i]
|
180
|
+
|
181
|
+
if (input.type == 'checkbox') input.checked = false
|
182
|
+
else input.value = ''
|
183
|
+
}
|
184
|
+
|
185
|
+
inputs[0].focus()
|
186
|
+
}
|
187
|
+
|
188
|
+
_delete(e: MouseEvent) {
|
189
|
+
const record = (e.target as Element).closest('[data-record]') as HTMLElement
|
190
|
+
|
191
|
+
;(record!.querySelector('[data-key]') as HTMLInputElement)!.value = ''
|
192
|
+
|
193
|
+
this._build()
|
194
|
+
}
|
195
|
+
|
196
|
+
@queryAll('[data-record]') records!: NodeListOf<HTMLElement>
|
197
|
+
|
198
|
+
_up(e: MouseEvent) {
|
199
|
+
const record = (e.target as Element).closest('[data-record]') as HTMLElement
|
200
|
+
const array = Array.from(this.records)
|
201
|
+
const index = array.indexOf(record) - 1
|
202
|
+
|
203
|
+
if (index < 0) {
|
204
|
+
return
|
205
|
+
}
|
206
|
+
|
207
|
+
const deleted = array.splice(index, 1)
|
208
|
+
array.splice(index + 1, 0, ...deleted)
|
209
|
+
|
210
|
+
this.value = array.reduce((sum, record) => {
|
211
|
+
const key = (record.querySelector('[data-key]') as HTMLInputElement).value
|
212
|
+
const value = (record.querySelector('[data-value]') as HTMLInputElement).value
|
213
|
+
|
214
|
+
sum[key] = value
|
215
|
+
return sum
|
216
|
+
}, {} as { [key: string]: string })
|
217
|
+
|
218
|
+
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))
|
219
|
+
}
|
220
|
+
|
221
|
+
_down(e: MouseEvent) {
|
222
|
+
const record = (e.target as Element).closest('[data-record]') as HTMLElement
|
223
|
+
const array = Array.from(this.records)
|
224
|
+
const index = array.indexOf(record)
|
225
|
+
|
226
|
+
if (index > array.length) {
|
227
|
+
return
|
228
|
+
}
|
229
|
+
|
230
|
+
array.splice(index, 1)
|
231
|
+
array.splice(index + 1, 0, record)
|
232
|
+
|
233
|
+
this.value = array.reduce((sum, record) => {
|
234
|
+
const key = (record.querySelector('[data-key]') as HTMLInputElement).value
|
235
|
+
const value = (record.querySelector('[data-value]') as HTMLInputElement).value
|
236
|
+
|
237
|
+
sum[key] = value
|
238
|
+
return sum
|
239
|
+
}, {} as { [key: string]: string })
|
240
|
+
|
241
|
+
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true, detail: this.value }))
|
242
|
+
}
|
243
|
+
}
|
package/src/ox-input-search.ts
CHANGED
@@ -46,7 +46,7 @@ export class OxInputSearch extends OxFormField {
|
|
46
46
|
|
47
47
|
render() {
|
48
48
|
return html`
|
49
|
-
<mwc-icon>search</mwc-icon>
|
49
|
+
<mwc-icon @click=${(e: Event) => this._onClickSearch(e)}>search</mwc-icon>
|
50
50
|
<input
|
51
51
|
type="text"
|
52
52
|
.value=${this.value || ''}
|
@@ -72,4 +72,12 @@ export class OxInputSearch extends OxFormField {
|
|
72
72
|
})
|
73
73
|
)
|
74
74
|
}
|
75
|
+
|
76
|
+
_onClickSearch(e: Event) {
|
77
|
+
e.stopPropagation()
|
78
|
+
|
79
|
+
if (this._form) {
|
80
|
+
this._form.requestSubmit()
|
81
|
+
}
|
82
|
+
}
|
75
83
|
}
|