@operato/input 1.0.0-alpha.4 → 1.0.0-alpha.42

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