@operato/input 1.0.0-alpha.5 → 1.0.0-alpha.52
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/README.md +9 -6
- package/assets/images/icon-editor-gradient-direction.png +0 -0
- package/assets/images/icon-properties-label.png +0 -0
- package/assets/images/icon-properties-line-type.png +0 -0
- package/assets/images/icon-properties-table.png +0 -0
- package/demo/index-color-gradient.html +35 -0
- package/demo/index-color-stops.html +62 -0
- package/demo/index-color.html +35 -0
- package/demo/index-crontab.html +37 -0
- package/demo/index-multiple-colors.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 +14 -0
- package/dist/src/index.d.ts +21 -11
- package/dist/src/index.js +21 -11
- 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 +4 -4
- package/dist/src/ox-input-code.js +8 -8
- package/dist/src/ox-input-code.js.map +1 -1
- package/dist/src/ox-input-color-gradient.d.ts +26 -0
- package/dist/src/ox-input-color-gradient.js +318 -0
- package/dist/src/ox-input-color-gradient.js.map +1 -0
- package/dist/src/ox-input-color-stops.d.ts +71 -0
- package/dist/src/ox-input-color-stops.js +445 -0
- package/dist/src/ox-input-color-stops.js.map +1 -0
- package/dist/src/ox-input-color.d.ts +176 -0
- package/dist/src/ox-input-color.js +298 -0
- package/dist/src/ox-input-color.js.map +1 -0
- 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-data.d.ts +1 -1
- package/dist/src/ox-input-data.js +1 -1
- package/dist/src/ox-input-data.js.map +1 -1
- 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 +28 -0
- package/dist/src/ox-input-multiple-colors.js +113 -0
- package/dist/src/ox-input-multiple-colors.js.map +1 -0
- 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-id.d.ts → ox-input-scene-component-id.d.ts} +0 -0
- package/dist/src/{ox-input-id.js → ox-input-scene-component-id.js} +2 -2
- package/dist/src/ox-input-scene-component-id.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-stack.d.ts +1 -1
- package/dist/src/ox-input-stack.js +1 -1
- package/dist/src/ox-input-stack.js.map +1 -1
- package/dist/src/ox-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 +24 -7
- package/src/index.ts +21 -11
- 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 +9 -10
- package/src/ox-input-color-gradient.ts +343 -0
- package/src/ox-input-color-stops.ts +499 -0
- package/src/ox-input-color.ts +323 -0
- package/src/ox-input-crontab.ts +561 -0
- package/src/ox-input-data.ts +2 -2
- 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 +113 -0
- package/src/ox-input-options.ts +1 -1
- package/src/ox-input-partition-keys.ts +243 -0
- package/src/{ox-input-id.ts → ox-input-scene-component-id.ts} +1 -1
- package/src/ox-input-search.ts +9 -1
- package/src/ox-input-stack.ts +1 -1
- package/src/ox-input-table.ts +404 -0
- package/src/{ox-input-keyvalues.ts.ing → ox-input-value-map.ts} +125 -94
- 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/translations/en.json +1 -0
- package/translations/ko.json +1 -0
- package/translations/ms.json +1 -0
- package/translations/zh.json +1 -0
- package/dist/src/ox-input-id.js.map +0 -1
- package/src/ox-input-ranges.ts.ing +0 -292
@@ -0,0 +1,561 @@
|
|
1
|
+
import '@material/mwc-button'
|
2
|
+
|
3
|
+
import { css, html, PropertyValues } from 'lit'
|
4
|
+
import { customElement, property, state } from 'lit/decorators.js'
|
5
|
+
|
6
|
+
import { i18next } from '@operato/i18n'
|
7
|
+
|
8
|
+
import { OxFormField } from './ox-form-field'
|
9
|
+
|
10
|
+
function createCronRegex(type: 'sec' | 'min' | 'hour' | 'day' | 'month' | 'dayOfWeek') {
|
11
|
+
// https://gist.github.com/dkandalov/a2aed17cfdeb65243022
|
12
|
+
var regexByField = {} as any
|
13
|
+
regexByField['sec'] = '[0-5]?\\d'
|
14
|
+
regexByField['min'] = '[0-5]?\\d'
|
15
|
+
regexByField['hour'] = '[01]?\\d|2[0-3]'
|
16
|
+
regexByField['day'] = '0?[1-9]|[12]\\d|3[01]'
|
17
|
+
regexByField['month'] = '[1-9]|1[012]'
|
18
|
+
regexByField['dayOfWeek'] = '[0-7]'
|
19
|
+
|
20
|
+
var crontabFields = [type]
|
21
|
+
if (!type) crontabFields = ['sec', 'min', 'hour', 'day', 'month', 'dayOfWeek']
|
22
|
+
|
23
|
+
crontabFields.forEach(field => {
|
24
|
+
var number = regexByField[field]
|
25
|
+
var range =
|
26
|
+
'(?:' +
|
27
|
+
number +
|
28
|
+
')' +
|
29
|
+
'(?:' +
|
30
|
+
'(?:-|/|,' +
|
31
|
+
('dayOfWeek' === field ? '|#' : '') +
|
32
|
+
')' +
|
33
|
+
'(?:' +
|
34
|
+
number +
|
35
|
+
')' +
|
36
|
+
')?'
|
37
|
+
if (field === 'dayOfWeek') range += '(?:L)?'
|
38
|
+
if (field === 'month') range += '(?:L|W)?'
|
39
|
+
regexByField[field] = '\\?|\\*|' + range + '(?:,' + range + ')*'
|
40
|
+
})
|
41
|
+
|
42
|
+
var monthValues = 'JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC'
|
43
|
+
var monthRange = '(?:' + monthValues + ')(?:(?:-)(?:' + monthValues + '))?'
|
44
|
+
regexByField['month'] += '|\\?|\\*|' + monthRange + '(?:,' + monthRange + ')*'
|
45
|
+
|
46
|
+
var dayOfWeekValues = 'MON|TUE|WED|THU|FRI|SAT|SUN'
|
47
|
+
var dayOfWeekRange = '(?:' + dayOfWeekValues + ')(?:(?:-)(?:' + dayOfWeekValues + '))?'
|
48
|
+
regexByField['dayOfWeek'] += '|\\?|\\*|' + dayOfWeekRange + '(?:,' + dayOfWeekRange + ')*'
|
49
|
+
|
50
|
+
if (!type)
|
51
|
+
return (
|
52
|
+
'^\\s*($' +
|
53
|
+
'|#' +
|
54
|
+
'|\\w+\\s*=' +
|
55
|
+
'|' +
|
56
|
+
'(' +
|
57
|
+
regexByField['sec'] +
|
58
|
+
')\\s+' +
|
59
|
+
'(' +
|
60
|
+
regexByField['min'] +
|
61
|
+
')\\s+' +
|
62
|
+
'(' +
|
63
|
+
regexByField['hour'] +
|
64
|
+
')\\s+' +
|
65
|
+
'(' +
|
66
|
+
regexByField['day'] +
|
67
|
+
')\\s+' +
|
68
|
+
'(' +
|
69
|
+
regexByField['month'] +
|
70
|
+
')\\s+' +
|
71
|
+
'(' +
|
72
|
+
regexByField['dayOfWeek'] +
|
73
|
+
')(|\\s)+' +
|
74
|
+
')$'
|
75
|
+
)
|
76
|
+
else return `^${regexByField[type]}$`
|
77
|
+
}
|
78
|
+
|
79
|
+
@customElement('ox-input-crontab')
|
80
|
+
export class OxInputCrontab extends OxFormField {
|
81
|
+
static styles = css`
|
82
|
+
:host {
|
83
|
+
display: block;
|
84
|
+
width: 100%;
|
85
|
+
height: 100%;
|
86
|
+
border: 0;
|
87
|
+
background-color: var(--main-section-background-color);
|
88
|
+
}
|
89
|
+
|
90
|
+
:host * {
|
91
|
+
box-sizing: border-box;
|
92
|
+
}
|
93
|
+
:host *:focus {
|
94
|
+
outline: none;
|
95
|
+
}
|
96
|
+
|
97
|
+
form {
|
98
|
+
display: grid;
|
99
|
+
width: 100%;
|
100
|
+
height: 100%;
|
101
|
+
padding: 1rem;
|
102
|
+
grid-template: auto auto 1fr auto / repeat(6, 1fr);
|
103
|
+
grid-gap: 0.5rem;
|
104
|
+
justify-content: center;
|
105
|
+
align-items: center;
|
106
|
+
overflow: auto;
|
107
|
+
}
|
108
|
+
|
109
|
+
label[for='example'] {
|
110
|
+
text-align: right;
|
111
|
+
grid-column: 3;
|
112
|
+
font: normal 1em var(--theme-font);
|
113
|
+
color: var(--secondary-color);
|
114
|
+
text-transform: capitalize;
|
115
|
+
}
|
116
|
+
|
117
|
+
#example {
|
118
|
+
grid-column: 4 / span 3;
|
119
|
+
width: 100%;
|
120
|
+
height: 100%;
|
121
|
+
font: normal 0.9em var(--theme-font);
|
122
|
+
text-transform: capitalize;
|
123
|
+
border-radius: var(--border-radius);
|
124
|
+
border: var(--border-dark-color);
|
125
|
+
}
|
126
|
+
|
127
|
+
input {
|
128
|
+
width: 100%;
|
129
|
+
margin-top: var(--margin-default);
|
130
|
+
padding: 5px;
|
131
|
+
border-radius: var(--border-radius);
|
132
|
+
border: var(--border-dark-color);
|
133
|
+
font: normal 1em var(--theme-font);
|
134
|
+
}
|
135
|
+
input:focus {
|
136
|
+
border: 1px solid var(--primary-color);
|
137
|
+
}
|
138
|
+
|
139
|
+
input:invalid {
|
140
|
+
border: 1px solid var(--status-danger-color);
|
141
|
+
color: var(--status-danger-color);
|
142
|
+
}
|
143
|
+
|
144
|
+
label {
|
145
|
+
width: 100%;
|
146
|
+
height: 100%;
|
147
|
+
font: normal 0.8em var(--theme-font);
|
148
|
+
color: var(--primary-color);
|
149
|
+
}
|
150
|
+
|
151
|
+
label:not([for='example']) {
|
152
|
+
text-align: center;
|
153
|
+
}
|
154
|
+
|
155
|
+
#input-wrapper {
|
156
|
+
grid-column: span 6;
|
157
|
+
display: flex;
|
158
|
+
flex-wrap: wrap;
|
159
|
+
margin: 0 -0.25rem;
|
160
|
+
}
|
161
|
+
|
162
|
+
#input-wrapper > div {
|
163
|
+
flex: 1;
|
164
|
+
display: grid;
|
165
|
+
grid-template-rows: 1fr auto;
|
166
|
+
grid-gap: 0.5rem;
|
167
|
+
min-width: 60px;
|
168
|
+
max-width: 33%;
|
169
|
+
margin: 0.25rem;
|
170
|
+
}
|
171
|
+
|
172
|
+
#tooltip {
|
173
|
+
grid-column: span 6;
|
174
|
+
display: grid;
|
175
|
+
grid-template-columns: auto 1fr;
|
176
|
+
grid-gap: 0;
|
177
|
+
margin: auto;
|
178
|
+
grid-auto-rows: min-content;
|
179
|
+
align-self: center;
|
180
|
+
align-items: center;
|
181
|
+
}
|
182
|
+
|
183
|
+
#tooltip > div {
|
184
|
+
padding: 0.25rem 0.5rem;
|
185
|
+
border-bottom: #ccc 1px dashed;
|
186
|
+
font: normal 0.9em var(--theme-font);
|
187
|
+
}
|
188
|
+
|
189
|
+
#tooltip > .crontab-value {
|
190
|
+
text-align: right;
|
191
|
+
color: var(--secondary-color);
|
192
|
+
}
|
193
|
+
|
194
|
+
#tooltip > .crontab-description {
|
195
|
+
text-align: left;
|
196
|
+
color: #585858;
|
197
|
+
}
|
198
|
+
|
199
|
+
#button-wrapper {
|
200
|
+
grid-column: 1 / span 6;
|
201
|
+
display: flex;
|
202
|
+
flex-wrap: wrap-reverse;
|
203
|
+
flex-direction: row-reverse;
|
204
|
+
margin: -0.25rem;
|
205
|
+
}
|
206
|
+
|
207
|
+
mwc-button {
|
208
|
+
background-color: var(--secondary-color);
|
209
|
+
border-radius: var(--button-border-radius);
|
210
|
+
--mdc-theme-primary: #fff;
|
211
|
+
margin: 0.25rem;
|
212
|
+
}
|
213
|
+
mwc-button:hover,
|
214
|
+
mwc-button:active {
|
215
|
+
background-color: var(--primary-color);
|
216
|
+
}
|
217
|
+
`
|
218
|
+
|
219
|
+
@property({ type: String }) value?: string
|
220
|
+
@property({ type: String }) second?: string
|
221
|
+
@property({ type: String }) minute?: string
|
222
|
+
@property({ type: String }) hour?: string
|
223
|
+
@property({ type: String }) dayOfMonth?: string
|
224
|
+
@property({ type: String }) month?: string
|
225
|
+
@property({ type: String }) dayOfWeek?: string
|
226
|
+
|
227
|
+
@state() tooltip: { value: string; description: string }[] = []
|
228
|
+
|
229
|
+
render() {
|
230
|
+
return html`
|
231
|
+
<form>
|
232
|
+
<label for="example">${i18next.t('label.examples')}</label>
|
233
|
+
<select
|
234
|
+
id="example"
|
235
|
+
@change=${(e: Event) => (this.value = (e.currentTarget as HTMLInputElement).value)}
|
236
|
+
.value=${this.value}
|
237
|
+
>
|
238
|
+
<optgroup label="${i18next.t('label.second by second')}">
|
239
|
+
<option value="* * * * * *">${i18next.t('text.every second')}</option>
|
240
|
+
<option value="0/2 * * * * *">${i18next.t('text.every 2 seconds')}</option>
|
241
|
+
<option value="0/15 * * * * *">${i18next.t('text.every 15 seconds')}</option>
|
242
|
+
<option value="0/30 * * * * *">${i18next.t('text.every 30 seconds')}</option>
|
243
|
+
</optgroup>
|
244
|
+
<optgroup label="${i18next.t('label.minute by minute')}">
|
245
|
+
<option value="0 * * * * *">${i18next.t('text.every minute')}</option>
|
246
|
+
<option value="0 0/2 * * * *">${i18next.t('text.every 2 minutes')}</option>
|
247
|
+
<option value="0 0/15 * * * *">${i18next.t('text.every 15 minutes')}</option>
|
248
|
+
<option value="0 0/30 * * * *">${i18next.t('text.every half hour')}</option>
|
249
|
+
</optgroup>
|
250
|
+
<optgroup label="${i18next.t('label.hourly')}">
|
251
|
+
<option value="0 0 * * * *">${i18next.t('text.every hour')}</option>
|
252
|
+
<option value="0 0 0/2 * * *">${i18next.t('text.every 2 hours')}</option>
|
253
|
+
<option value="0 0 0/12 * * *">${i18next.t('text.every 12 hours')}</option>
|
254
|
+
<option value="0 0 10-19 * * *">${i18next.t('text.every hour during working time')}</option>
|
255
|
+
</optgroup>
|
256
|
+
<optgroup label="${i18next.t('label.daily')}">
|
257
|
+
<option value="0 0 0 * * *">${i18next.t('text.every day')}</option>
|
258
|
+
</optgroup>
|
259
|
+
<optgroup label="${i18next.t('label.weekly')}">
|
260
|
+
<option value="0 0 0 * * SUN">${i18next.t('text.every sunday')}</option>
|
261
|
+
<option value="0 0 0 * * 0">${i18next.t('text.every sunday(2)')}</option>
|
262
|
+
<option value="0 0 0 * * 1-5">${i18next.t('text.every weekday')}</option>
|
263
|
+
</optgroup>
|
264
|
+
<optgroup label="${i18next.t('label.monthly')}">
|
265
|
+
<option value="0 0 0 1 * *">${i18next.t('text.the first day of every month')}</option>
|
266
|
+
<option value="0 0 10 21 * *">${i18next.t('text.10 am on every payday')}</option>
|
267
|
+
</optgroup>
|
268
|
+
<optgroup label="${i18next.t('label.yearly')}">
|
269
|
+
<option value="0 0 0 1 1 *">${i18next.t('text.the first day of every year')}</option>
|
270
|
+
<option value="0 0 0 25 12 *">${i18next.t('text.every christmas')}</option>
|
271
|
+
</optgroup>
|
272
|
+
</select>
|
273
|
+
<div id="input-wrapper">
|
274
|
+
<div>
|
275
|
+
<input
|
276
|
+
id="second-input"
|
277
|
+
class="second"
|
278
|
+
type="text"
|
279
|
+
.value=${this.second || ''}
|
280
|
+
@input=${(e: Event) => (this.second = (e.currentTarget as HTMLInputElement).value)}
|
281
|
+
@focus=${(e: Event) => {
|
282
|
+
this.showTooltip('second')
|
283
|
+
}}
|
284
|
+
pattern=${createCronRegex('sec')}
|
285
|
+
required
|
286
|
+
/>
|
287
|
+
<label for="second-input" class="second">${i18next.t('label.second')}</label>
|
288
|
+
</div>
|
289
|
+
<div>
|
290
|
+
<input
|
291
|
+
id="minute-input"
|
292
|
+
class="minute"
|
293
|
+
type="text"
|
294
|
+
.value=${this.minute || ''}
|
295
|
+
@input=${(e: Event) => (this.minute = (e.currentTarget as HTMLInputElement).value)}
|
296
|
+
@focus=${(e: Event) => {
|
297
|
+
this.showTooltip('minute')
|
298
|
+
}}
|
299
|
+
pattern=${createCronRegex('min')}
|
300
|
+
required
|
301
|
+
/>
|
302
|
+
<label for="minute-input" class="minute">${i18next.t('label.minute')}</label>
|
303
|
+
</div>
|
304
|
+
<div>
|
305
|
+
<input
|
306
|
+
id="hour-input"
|
307
|
+
class="hour"
|
308
|
+
type="text"
|
309
|
+
.value=${this.hour || ''}
|
310
|
+
@input=${(e: Event) => (this.hour = (e.currentTarget as HTMLInputElement).value)}
|
311
|
+
@focus=${(e: Event) => {
|
312
|
+
this.showTooltip('hour')
|
313
|
+
}}
|
314
|
+
pattern=${createCronRegex('hour')}
|
315
|
+
required
|
316
|
+
/>
|
317
|
+
<label for="hour-input" class="hour">${i18next.t('label.hour')}</label>
|
318
|
+
</div>
|
319
|
+
<div>
|
320
|
+
<input
|
321
|
+
id="day-of-month-input"
|
322
|
+
class="day-of-month"
|
323
|
+
type="text"
|
324
|
+
.value=${this.dayOfMonth || ''}
|
325
|
+
@input=${(e: Event) => (this.dayOfMonth = (e.currentTarget as HTMLInputElement).value)}
|
326
|
+
@focus=${(e: Event) => {
|
327
|
+
this.showTooltip('dayOfMonth')
|
328
|
+
}}
|
329
|
+
pattern=${createCronRegex('day')}
|
330
|
+
required
|
331
|
+
/>
|
332
|
+
<label for="day-of-month-input" class="day-of-month">${i18next.t('label.day-of-month')}</label>
|
333
|
+
</div>
|
334
|
+
<div>
|
335
|
+
<input
|
336
|
+
id="month-input"
|
337
|
+
class="month"
|
338
|
+
type="text"
|
339
|
+
.value=${this.month || ''}
|
340
|
+
@input=${(e: Event) => (this.month = (e.currentTarget as HTMLInputElement).value)}
|
341
|
+
@focus=${(e: Event) => {
|
342
|
+
this.showTooltip('month')
|
343
|
+
}}
|
344
|
+
pattern=${createCronRegex('month')}
|
345
|
+
required
|
346
|
+
/>
|
347
|
+
<label for="month-input" class="month">${i18next.t('label.month')}</label>
|
348
|
+
</div>
|
349
|
+
<div>
|
350
|
+
<input
|
351
|
+
id="day-of-week-input"
|
352
|
+
class="day-of-week"
|
353
|
+
type="text"
|
354
|
+
.value=${this.dayOfWeek || ''}
|
355
|
+
@input=${(e: Event) => (this.dayOfWeek = (e.currentTarget as HTMLInputElement).value)}
|
356
|
+
@focus=${(e: Event) => {
|
357
|
+
this.showTooltip('dayOfWeek')
|
358
|
+
}}
|
359
|
+
pattern=${createCronRegex('dayOfWeek')}
|
360
|
+
required
|
361
|
+
/>
|
362
|
+
<label for="day-of-week-input" class="day-of-week">${i18next.t('label.day-of-week')}</label>
|
363
|
+
</div>
|
364
|
+
</div>
|
365
|
+
<div id="tooltip">
|
366
|
+
${this.tooltip.map(
|
367
|
+
tip => html`
|
368
|
+
<div class="crontab-value">${tip.value}</div>
|
369
|
+
<div class="crontab-description">${i18next.t(`text.${tip.description}`)}</div>
|
370
|
+
`
|
371
|
+
)}
|
372
|
+
</div>
|
373
|
+
</form>
|
374
|
+
`
|
375
|
+
}
|
376
|
+
|
377
|
+
get focusableElements(): HTMLElement[] {
|
378
|
+
return Array.from(this.renderRoot.querySelectorAll('select, input, mwc-button'))
|
379
|
+
}
|
380
|
+
|
381
|
+
firstUpdated() {
|
382
|
+
;(this.renderRoot.querySelector('input') as HTMLInputElement).focus()
|
383
|
+
this.renderRoot.addEventListener('change', this.onChange.bind(this))
|
384
|
+
}
|
385
|
+
|
386
|
+
updated(changes: PropertyValues<this>) {
|
387
|
+
if (changes.has('value')) {
|
388
|
+
var values = (this.value || '').split(' ')
|
389
|
+
|
390
|
+
if (values.length == 1) values = ['*', '*', '*', '*', '*', '*']
|
391
|
+
else if (values.length == 5) values = ['0'].concat(values)
|
392
|
+
|
393
|
+
this.second = values[0]
|
394
|
+
this.minute = values[1]
|
395
|
+
this.hour = values[2]
|
396
|
+
this.dayOfMonth = values[3]
|
397
|
+
this.month = values[4]
|
398
|
+
this.dayOfWeek = values[5]
|
399
|
+
}
|
400
|
+
}
|
401
|
+
|
402
|
+
showTooltip(type: 'second' | 'minute' | 'hour' | 'dayOfMonth' | 'month' | 'dayOfWeek') {
|
403
|
+
switch (type) {
|
404
|
+
case 'second':
|
405
|
+
case 'minute':
|
406
|
+
this.tooltip = [
|
407
|
+
{
|
408
|
+
value: '*',
|
409
|
+
description: 'any value'
|
410
|
+
},
|
411
|
+
{
|
412
|
+
value: ',',
|
413
|
+
description: 'value list separator'
|
414
|
+
},
|
415
|
+
{
|
416
|
+
value: '-',
|
417
|
+
description: 'range of values'
|
418
|
+
},
|
419
|
+
{
|
420
|
+
value: '/',
|
421
|
+
description: 'step values'
|
422
|
+
},
|
423
|
+
{
|
424
|
+
value: '0-59',
|
425
|
+
description: 'allowed values'
|
426
|
+
}
|
427
|
+
]
|
428
|
+
break
|
429
|
+
case 'hour':
|
430
|
+
this.tooltip = [
|
431
|
+
{
|
432
|
+
value: '*',
|
433
|
+
description: 'any value'
|
434
|
+
},
|
435
|
+
{
|
436
|
+
value: ',',
|
437
|
+
description: 'value list separator'
|
438
|
+
},
|
439
|
+
{
|
440
|
+
value: '-',
|
441
|
+
description: 'range of values'
|
442
|
+
},
|
443
|
+
{
|
444
|
+
value: '/',
|
445
|
+
description: 'step values'
|
446
|
+
},
|
447
|
+
{
|
448
|
+
value: '0-23',
|
449
|
+
description: 'allowed values'
|
450
|
+
}
|
451
|
+
]
|
452
|
+
break
|
453
|
+
|
454
|
+
case 'dayOfMonth':
|
455
|
+
this.tooltip = [
|
456
|
+
{
|
457
|
+
value: '*',
|
458
|
+
description: 'any value'
|
459
|
+
},
|
460
|
+
{
|
461
|
+
value: ',',
|
462
|
+
description: 'value list separator'
|
463
|
+
},
|
464
|
+
{
|
465
|
+
value: '-',
|
466
|
+
description: 'range of values'
|
467
|
+
},
|
468
|
+
{
|
469
|
+
value: '/',
|
470
|
+
description: 'step values'
|
471
|
+
},
|
472
|
+
{
|
473
|
+
value: '1-31',
|
474
|
+
description: 'allowed values'
|
475
|
+
}
|
476
|
+
]
|
477
|
+
break
|
478
|
+
|
479
|
+
case 'month':
|
480
|
+
this.tooltip = [
|
481
|
+
{
|
482
|
+
value: '*',
|
483
|
+
description: 'any value'
|
484
|
+
},
|
485
|
+
{
|
486
|
+
value: ',',
|
487
|
+
description: 'value list separator'
|
488
|
+
},
|
489
|
+
{
|
490
|
+
value: '-',
|
491
|
+
description: 'range of values'
|
492
|
+
},
|
493
|
+
{
|
494
|
+
value: '/',
|
495
|
+
description: 'step values'
|
496
|
+
},
|
497
|
+
{
|
498
|
+
value: '1-12',
|
499
|
+
description: 'allowed values'
|
500
|
+
},
|
501
|
+
{
|
502
|
+
value: 'JAN-DEC',
|
503
|
+
description: 'alternative single values'
|
504
|
+
}
|
505
|
+
]
|
506
|
+
break
|
507
|
+
|
508
|
+
case 'dayOfWeek':
|
509
|
+
this.tooltip = [
|
510
|
+
{
|
511
|
+
value: '*',
|
512
|
+
description: 'any value'
|
513
|
+
},
|
514
|
+
{
|
515
|
+
value: ',',
|
516
|
+
description: 'value list separator'
|
517
|
+
},
|
518
|
+
{
|
519
|
+
value: '-',
|
520
|
+
description: 'range of values'
|
521
|
+
},
|
522
|
+
{
|
523
|
+
value: '/',
|
524
|
+
description: 'step values'
|
525
|
+
},
|
526
|
+
{
|
527
|
+
value: '0-6',
|
528
|
+
description: 'allowed values'
|
529
|
+
},
|
530
|
+
{
|
531
|
+
value: 'SUN-SAT',
|
532
|
+
description: 'alternative single values'
|
533
|
+
}
|
534
|
+
]
|
535
|
+
break
|
536
|
+
|
537
|
+
default:
|
538
|
+
this.tooltip = []
|
539
|
+
break
|
540
|
+
}
|
541
|
+
}
|
542
|
+
|
543
|
+
onChange() {
|
544
|
+
var form = this.renderRoot.querySelector('form') as HTMLFormElement
|
545
|
+
var valid = form.checkValidity()
|
546
|
+
if (!valid) {
|
547
|
+
form.reportValidity()
|
548
|
+
return
|
549
|
+
}
|
550
|
+
|
551
|
+
this.value = `${this.second} ${this.minute} ${this.hour} ${this.dayOfMonth} ${this.month} ${this.dayOfWeek}`
|
552
|
+
|
553
|
+
this.dispatchEvent(
|
554
|
+
new CustomEvent('change', {
|
555
|
+
bubbles: true,
|
556
|
+
composed: true,
|
557
|
+
detail: this.value
|
558
|
+
})
|
559
|
+
)
|
560
|
+
}
|
561
|
+
}
|
package/src/ox-input-data.ts
CHANGED
@@ -7,7 +7,7 @@ import './ox-input-code'
|
|
7
7
|
import { PropertyValues, css, html } from 'lit'
|
8
8
|
|
9
9
|
import { OxFormField } from './ox-form-field.js'
|
10
|
-
import OxInputCode from './ox-input-code.js'
|
10
|
+
import { OxInputCode } from './ox-input-code.js'
|
11
11
|
import { customElement } from 'lit/decorators.js'
|
12
12
|
|
13
13
|
/**
|
@@ -19,7 +19,7 @@ Example:
|
|
19
19
|
</ox-input-data>
|
20
20
|
*/
|
21
21
|
@customElement('ox-input-data')
|
22
|
-
export
|
22
|
+
export class OxInputData extends OxFormField {
|
23
23
|
static styles = [
|
24
24
|
css`
|
25
25
|
:host {
|
@@ -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
|
+
}
|