@openremote/or-mwc-components 1.8.0-snapshot.20250725120002 → 1.8.0-snapshot.20250728102340
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/README.md +32 -32
- package/build.gradle +19 -19
- package/custom-elements.json +4 -4
- package/lib/or-mwc-dialog.js +76 -329
- package/lib/or-mwc-drawer.js +10 -114
- package/lib/or-mwc-input.js +439 -1760
- package/lib/or-mwc-list.js +71 -283
- package/lib/or-mwc-menu.js +45 -237
- package/lib/or-mwc-snackbar.js +17 -141
- package/lib/or-mwc-table.js +245 -685
- package/lib/or-mwc-tabs.js +53 -173
- package/lib/style.js +121 -125
- package/package.json +5 -5
- package/rspack.config.js +7 -7
- package/src/or-mwc-dialog.ts +374 -374
- package/src/or-mwc-drawer.ts +100 -100
- package/src/or-mwc-input.ts +1876 -1876
- package/src/or-mwc-list.ts +335 -335
- package/src/or-mwc-menu.ts +279 -279
- package/src/or-mwc-snackbar.ts +157 -157
- package/src/or-mwc-table.ts +712 -712
- package/src/or-mwc-tabs.ts +175 -175
- package/src/style.ts +125 -125
- package/tsconfig.json +15 -15
- package/tsconfig.tsbuildinfo +1 -1
package/lib/or-mwc-input.js
CHANGED
|
@@ -1,1760 +1,439 @@
|
|
|
1
|
-
var __decorate = (
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
.mdc-radio-container {
|
|
441
|
-
display: flex;
|
|
442
|
-
flex-direction: column;
|
|
443
|
-
}
|
|
444
|
-
.mdc-text-field.mdc-text-field--invalid:not(.mdc-text-field--disabled) + .mdc-text-field-helper-line .mdc-text-field-helper-text {
|
|
445
|
-
color: var(--mdc-theme-error, #b00020)
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
.mdc-checkbox-list input:checked + label {
|
|
449
|
-
color: var(--or-app-color2);
|
|
450
|
-
background-color: var(--mdc-theme-primary);
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
.mdc-button--rounded,
|
|
454
|
-
.or-mwc-input--rounded {
|
|
455
|
-
border-radius: 24px !important;
|
|
456
|
-
--mdc-shape-small: 32px;
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
#select-searchable {
|
|
460
|
-
background-color: transparent;
|
|
461
|
-
border: 1px solid var(--or-app-color5, ${unsafeCSS(DefaultColor5)});
|
|
462
|
-
margin: 8px;
|
|
463
|
-
width: calc(100% - 16px);
|
|
464
|
-
border-radius: 4px;
|
|
465
|
-
padding: 4px 16px;
|
|
466
|
-
flex: 0 0 auto;
|
|
467
|
-
align-items: center;
|
|
468
|
-
height: auto;
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
.mdc-text-field__input::-webkit-calendar-picker-indicator {
|
|
472
|
-
display: block;
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
::-webkit-clear-button {display: none;}
|
|
476
|
-
::-webkit-inner-spin-button { display: none; }
|
|
477
|
-
::-webkit-datetime-edit { padding: 0em; }
|
|
478
|
-
::-webkit-datetime-edit-text { padding: 0; }
|
|
479
|
-
|
|
480
|
-
.mdc-text-field--focused:not(.mdc-text-field--disabled) .mdc-floating-label {
|
|
481
|
-
color: var(--mdc-theme-primary);
|
|
482
|
-
}
|
|
483
|
-
.mdc-text-field--focused .mdc-text-field__input:required ~ .mdc-floating-label::after,
|
|
484
|
-
.mdc-text-field--focused .mdc-text-field__input:required ~ .mdc-notched-outline .mdc-floating-label::after {
|
|
485
|
-
color: var(--mdc-theme-primary);
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
.mdc-text-field__input.resize-vertical {
|
|
489
|
-
resize: vertical;
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
.mdc-text-field, .mdc-text-field-helper-line {
|
|
493
|
-
width: 100%;
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
.mdc-text-field.dense-comfortable, .mdc-select.dense-comfortable {
|
|
497
|
-
height: 48px;
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
.mdc-text-field.dense-compact {
|
|
501
|
-
height: 36px;
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
.mdc-select:not(.mdc-list) {
|
|
505
|
-
white-space: nowrap;
|
|
506
|
-
display: flex;
|
|
507
|
-
flex-direction: column;
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
.mdc-select:not(.mdc-select--disabled).mdc-select--focused .mdc-floating-label {
|
|
511
|
-
color: var(--mdc-theme-primary);
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
.mdc-select-helper-text {
|
|
515
|
-
white-space: normal;
|
|
516
|
-
color: rgba(0, 0, 0, 0.6);
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
.mdc-icon-button {
|
|
520
|
-
padding: 0;
|
|
521
|
-
color: var(--internal-or-mwc-input-color);
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
/* Give slider min width like select etc. */
|
|
525
|
-
.mdc-slider {
|
|
526
|
-
min-width: 200px;
|
|
527
|
-
flex: 1;
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
.mdc-switch {
|
|
531
|
-
margin: 0 24px;
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
.mdc-switch--full-width {
|
|
535
|
-
margin-left: auto;
|
|
536
|
-
}
|
|
537
|
-
.mdc-button--fullwidth {
|
|
538
|
-
width: 100%;
|
|
539
|
-
}
|
|
540
|
-
#field {
|
|
541
|
-
height: 100%;
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
.mdc-select__menu .mdc-list .mdc-list-item.mdc-list-item--selected or-icon {
|
|
545
|
-
--or-icon-fill: var(--or-app-color4);
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
.mdc-menu__searchable {
|
|
549
|
-
overflow: hidden;
|
|
550
|
-
}
|
|
551
|
-
.mdc-menu__searchable.mdc-menu-surface--open {
|
|
552
|
-
display: flex;
|
|
553
|
-
flex-direction: column-reverse;
|
|
554
|
-
}
|
|
555
|
-
.mdc-menu__searchable.mdc-menu-surface--is-open-below {
|
|
556
|
-
flex-direction: column;
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
/* Prevent mouse events being fired from inside the or-icon shadowDOM */
|
|
560
|
-
.mdc-list-item__graphic > or-icon {
|
|
561
|
-
pointer-events: none;
|
|
562
|
-
}
|
|
563
|
-
`;
|
|
564
|
-
let OrMwcInput = class OrMwcInput extends LitElement {
|
|
565
|
-
constructor() {
|
|
566
|
-
super(...arguments);
|
|
567
|
-
this.readonly = false;
|
|
568
|
-
this.required = false;
|
|
569
|
-
this.checked = false;
|
|
570
|
-
this.indeterminate = false;
|
|
571
|
-
this.multiple = false;
|
|
572
|
-
this.searchLabel = "search";
|
|
573
|
-
this.compact = false;
|
|
574
|
-
this.comfortable = false;
|
|
575
|
-
/* BUTTON STYLES START */
|
|
576
|
-
this.raised = false;
|
|
577
|
-
this.action = false;
|
|
578
|
-
this.unElevated = false;
|
|
579
|
-
this.outlined = false;
|
|
580
|
-
this.rounded = false;
|
|
581
|
-
this.disableSliderNumberInput = false;
|
|
582
|
-
/* BUTTON STYLES END */
|
|
583
|
-
/* TEXT INPUT STYLES START */
|
|
584
|
-
this.fullWidth = false;
|
|
585
|
-
this.helperPersistent = false;
|
|
586
|
-
this.autoValidate = false;
|
|
587
|
-
this.charCounter = false;
|
|
588
|
-
this.disabled = false;
|
|
589
|
-
this.continuous = false;
|
|
590
|
-
this.resizeVertical = false;
|
|
591
|
-
/**
|
|
592
|
-
* Always censure text fields (like a password), and do not allow toggling
|
|
593
|
-
*/
|
|
594
|
-
this.censored = false;
|
|
595
|
-
/**
|
|
596
|
-
* Toggles visibility state of the password InputType (true = shown, false = hidden)
|
|
597
|
-
*/
|
|
598
|
-
this.advertised = false;
|
|
599
|
-
this._selectedIndex = -1;
|
|
600
|
-
this.isUiValid = true;
|
|
601
|
-
}
|
|
602
|
-
static get styles() {
|
|
603
|
-
return [
|
|
604
|
-
css `${unsafeCSS(iconButtonStyle)}`,
|
|
605
|
-
css `${unsafeCSS(buttonStyle)}`,
|
|
606
|
-
css `${unsafeCSS(buttonFabStyle)}`,
|
|
607
|
-
css `${unsafeCSS(textfieldStyle)}`,
|
|
608
|
-
css `${unsafeCSS(rippleStyle)}`,
|
|
609
|
-
css `${unsafeCSS(lineRippleStyle)}`,
|
|
610
|
-
css `${unsafeCSS(floatingLabelStyle)}`,
|
|
611
|
-
css `${unsafeCSS(formFieldStyle)}`,
|
|
612
|
-
css `${unsafeCSS(checkboxStyle)}`,
|
|
613
|
-
css `${unsafeCSS(radioStyle)}`,
|
|
614
|
-
css `${unsafeCSS(switchStyle)}`,
|
|
615
|
-
css `${unsafeCSS(selectStyle)}`,
|
|
616
|
-
css `${unsafeCSS(listStyle)}`,
|
|
617
|
-
css `${unsafeCSS(menuStyle)}`,
|
|
618
|
-
css `${unsafeCSS(menuSurfaceStyle)}`,
|
|
619
|
-
css `${unsafeCSS(sliderStyle)}`,
|
|
620
|
-
style
|
|
621
|
-
];
|
|
622
|
-
}
|
|
623
|
-
get nativeValue() {
|
|
624
|
-
if (this._mdcComponent) {
|
|
625
|
-
return this._mdcComponent.value;
|
|
626
|
-
}
|
|
627
|
-
}
|
|
628
|
-
disconnectedCallback() {
|
|
629
|
-
var _a, _b;
|
|
630
|
-
super.disconnectedCallback();
|
|
631
|
-
if (this._mdcComponent) {
|
|
632
|
-
this._mdcComponent.destroy();
|
|
633
|
-
this._mdcComponent = undefined;
|
|
634
|
-
(_a = this._menuObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
635
|
-
}
|
|
636
|
-
if (this._mdcComponent2) {
|
|
637
|
-
this._mdcComponent2.destroy();
|
|
638
|
-
this._mdcComponent2 = undefined;
|
|
639
|
-
(_b = this._menuObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
shouldUpdate(_changedProperties) {
|
|
643
|
-
if (_changedProperties.has("indeterminate")) {
|
|
644
|
-
if (this._mdcComponent && this.type === InputType.CHECKBOX) {
|
|
645
|
-
this._mdcComponent.indeterminate = this.indeterminate;
|
|
646
|
-
}
|
|
647
|
-
}
|
|
648
|
-
if (_changedProperties.has("disabled")) {
|
|
649
|
-
if (this._mdcComponent) {
|
|
650
|
-
this._mdcComponent.disabled = this.disabled;
|
|
651
|
-
}
|
|
652
|
-
if (this.type === InputType.RANGE && this._mdcComponent2) {
|
|
653
|
-
this._mdcComponent2.disabled = this.disabled;
|
|
654
|
-
}
|
|
655
|
-
}
|
|
656
|
-
if (_changedProperties.has("readonly")) {
|
|
657
|
-
if (this._mdcComponent) {
|
|
658
|
-
this._mdcComponent.readonly = this.readonly;
|
|
659
|
-
}
|
|
660
|
-
if (this.type === InputType.RANGE && this._mdcComponent2) {
|
|
661
|
-
this._mdcComponent2.readonly = this.readonly;
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
if (!this.type && this.value) {
|
|
665
|
-
if (this.value instanceof Date) {
|
|
666
|
-
this.type = InputType.DATETIME;
|
|
667
|
-
}
|
|
668
|
-
else if (typeof (this.value) === "boolean") {
|
|
669
|
-
this.type = InputType.CHECKBOX;
|
|
670
|
-
}
|
|
671
|
-
else if (typeof (this.value) === "number") {
|
|
672
|
-
this.type = InputType.NUMBER;
|
|
673
|
-
}
|
|
674
|
-
else if (typeof (this.value) === "string") {
|
|
675
|
-
this.type = InputType.TEXT;
|
|
676
|
-
}
|
|
677
|
-
else {
|
|
678
|
-
this.type = InputType.JSON;
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
return true;
|
|
682
|
-
}
|
|
683
|
-
focus() {
|
|
684
|
-
if (this.type === InputType.RANGE && this._mdcComponent2) {
|
|
685
|
-
this._mdcComponent2.focus();
|
|
686
|
-
}
|
|
687
|
-
else if (this._mdcComponent && typeof this._mdcComponent.focus === "function") {
|
|
688
|
-
this._mdcComponent.focus();
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
render() {
|
|
692
|
-
var _a;
|
|
693
|
-
if (this.type) {
|
|
694
|
-
const showLabel = !this.fullWidth && this.label;
|
|
695
|
-
let outlined = !this.fullWidth && this.outlined;
|
|
696
|
-
let hasHelper = !!this.helperText;
|
|
697
|
-
const showValidationMessage = !this.isUiValid && (!!this.errorMessage || !!this.validationMessage);
|
|
698
|
-
const helperClasses = {
|
|
699
|
-
"mdc-text-field-helper-text--persistent": !showValidationMessage && this.helperPersistent,
|
|
700
|
-
"mdc-text-field-helper-text--validation-msg": showValidationMessage,
|
|
701
|
-
};
|
|
702
|
-
const hasValue = (this.value !== null && this.value !== undefined) || this.value === false;
|
|
703
|
-
let labelTemplate = showLabel ? html `<span class="mdc-floating-label ${hasValue ? "mdc-floating-label--float-above" : ""}" id="label">${this.label}</span>` : undefined;
|
|
704
|
-
switch (this.type) {
|
|
705
|
-
case InputType.RADIO:
|
|
706
|
-
const optsRadio = this.resolveOptions(this.options);
|
|
707
|
-
this._selectedIndex = -1;
|
|
708
|
-
return html `
|
|
709
|
-
<div class="mdc-radio-container">
|
|
710
|
-
${optsRadio ? optsRadio.map(([optValue, optDisplay], index) => {
|
|
711
|
-
if (this.value === optValue) {
|
|
712
|
-
this._selectedIndex = index;
|
|
713
|
-
}
|
|
714
|
-
return html `
|
|
715
|
-
<div id="field" class="mdc-form-field">
|
|
716
|
-
<div class="mdc-radio">
|
|
717
|
-
<input type="radio"
|
|
718
|
-
id="elem-${optValue}"
|
|
719
|
-
name="${ifDefined(this.name)}"
|
|
720
|
-
value="${optValue}"
|
|
721
|
-
?checked="${this.value && this.value.includes(optValue)}"
|
|
722
|
-
?required="${this.required}"
|
|
723
|
-
?disabled="${this.disabled || this.readonly}"
|
|
724
|
-
@change="${(e) => this.onValueChange(e.target, optValue)}"
|
|
725
|
-
class="mdc-radio__native-control"/>
|
|
726
|
-
<div class="mdc-radio__background">
|
|
727
|
-
<div class="mdc-radio__outer-circle"></div>
|
|
728
|
-
<div class="mdc-radio__inner-circle"></div>
|
|
729
|
-
</div>
|
|
730
|
-
<div class="mdc-radio__ripple"></div>
|
|
731
|
-
</div>
|
|
732
|
-
<label for="elem-${optValue}"><or-translate value="${optDisplay}"></or-translate></label>
|
|
733
|
-
</div>
|
|
734
|
-
|
|
735
|
-
`;
|
|
736
|
-
}) : ``}
|
|
737
|
-
</div>
|
|
738
|
-
`;
|
|
739
|
-
case InputType.SWITCH:
|
|
740
|
-
const classesSwitch = {
|
|
741
|
-
"mdc-switch--disabled": this.disabled || this.readonly,
|
|
742
|
-
"mdc-switch--full-width": this.fullWidth,
|
|
743
|
-
"mdc-switch--checked": this.value,
|
|
744
|
-
};
|
|
745
|
-
return html `
|
|
746
|
-
<span id="wrapper">
|
|
747
|
-
${this.label ? html `<label for="elem" class="${this.disabled ? "mdc-switch--disabled" : ""}">${this.label}</label>` : ``}
|
|
748
|
-
<div id="component" class="mdc-switch ${classMap(classesSwitch)}">
|
|
749
|
-
<div class="mdc-switch__track"></div>
|
|
750
|
-
<div class="mdc-switch__thumb-underlay">
|
|
751
|
-
<div class="mdc-switch__thumb">
|
|
752
|
-
<input type="checkbox" id="elem" class="mdc-switch__native-control"
|
|
753
|
-
?checked="${this.value}"
|
|
754
|
-
?required="${this.required}"
|
|
755
|
-
?disabled="${this.disabled || this.readonly}"
|
|
756
|
-
@change="${(e) => this.onValueChange(e.target, e.target.checked)}"
|
|
757
|
-
role="switch">
|
|
758
|
-
</div>
|
|
759
|
-
</div>
|
|
760
|
-
</div>
|
|
761
|
-
</span>
|
|
762
|
-
`;
|
|
763
|
-
case InputType.LIST:
|
|
764
|
-
const classesList = {
|
|
765
|
-
"mdc-select--outlined": outlined,
|
|
766
|
-
"mdc-select--disabled": this.disabled,
|
|
767
|
-
"mdc-select--required": this.required,
|
|
768
|
-
"mdc-select--dense": false, // this.dense,
|
|
769
|
-
"mdc-select--no-label": !this.label,
|
|
770
|
-
"mdc-select--with-leading-icon": !!this.icon
|
|
771
|
-
};
|
|
772
|
-
const optsList = this.resolveOptions(this.options);
|
|
773
|
-
this._selectedIndex = -1;
|
|
774
|
-
return html `
|
|
775
|
-
<div id="component" class="mdc-list mdc-select ${classMap(classesList)}" @MDCList:action="${(e) => this.onValueChange(undefined, e.detail.index === -1 ? undefined : Array.isArray(this.options[e.detail.index]) ? this.options[e.detail.index][0] : this.options[e.detail.index])}">
|
|
776
|
-
<ul class="mdc-list">
|
|
777
|
-
${optsList ? optsList.map(([optValue, optDisplay], index) => {
|
|
778
|
-
if (this.value === optValue) {
|
|
779
|
-
this._selectedIndex = index;
|
|
780
|
-
}
|
|
781
|
-
// todo: it's not actually putting the mdc-list-item--selected class on even when this.value === optValue...
|
|
782
|
-
return html `<li class="${classMap({ "mdc-list-item": true, "mdc-list-item--selected": this.value === optValue })}" role="option" data-value="${optValue}"><or-translate value="${optDisplay}"></or-translate></li>`;
|
|
783
|
-
}) : ``}
|
|
784
|
-
</ul>
|
|
785
|
-
</div>
|
|
786
|
-
`;
|
|
787
|
-
case InputType.SELECT:
|
|
788
|
-
const classes = {
|
|
789
|
-
"mdc-select--outlined": outlined,
|
|
790
|
-
"mdc-select--filled": !outlined,
|
|
791
|
-
"mdc-select--disabled": this.disabled || this.readonly,
|
|
792
|
-
"mdc-select--required": this.required,
|
|
793
|
-
"mdc-select--dense": false, // this.dense,
|
|
794
|
-
"dense-comfortable": this.comfortable,
|
|
795
|
-
"mdc-select--no-label": !this.label,
|
|
796
|
-
"mdc-select--with-leading-icon": !!this.icon,
|
|
797
|
-
"or-mwc-input--rounded": this.rounded
|
|
798
|
-
};
|
|
799
|
-
let opts;
|
|
800
|
-
if (this.searchProvider != undefined) {
|
|
801
|
-
opts = this.searchProvider(this.searchableValue);
|
|
802
|
-
}
|
|
803
|
-
else {
|
|
804
|
-
opts = this.resolveOptions(this.options);
|
|
805
|
-
}
|
|
806
|
-
const itemClickHandler = (ev, item) => {
|
|
807
|
-
var _a;
|
|
808
|
-
const value = item.value;
|
|
809
|
-
if (this.multiple) {
|
|
810
|
-
ev.stopPropagation();
|
|
811
|
-
const inputValue = (_a = this._tempValue) !== null && _a !== void 0 ? _a : (Array.isArray(this.value) ? [...this.value] : this.value !== undefined ? [this.value] : []);
|
|
812
|
-
const index = inputValue.findIndex((v) => v === value);
|
|
813
|
-
if (index >= 0) {
|
|
814
|
-
inputValue.splice(index, 1);
|
|
815
|
-
}
|
|
816
|
-
else {
|
|
817
|
-
inputValue.push(value);
|
|
818
|
-
}
|
|
819
|
-
const listItemEl = ev.composedPath()[0].closest("li"), iconEl = listItemEl.getElementsByTagName("or-icon")[0];
|
|
820
|
-
if (listItemEl) {
|
|
821
|
-
if (index >= 0) {
|
|
822
|
-
listItemEl.classList.remove("mdc-list-item--selected");
|
|
823
|
-
}
|
|
824
|
-
else {
|
|
825
|
-
listItemEl.classList.add("mdc-list-item--selected");
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
if (iconEl) {
|
|
829
|
-
iconEl.icon = index >= 0 ? "checkbox-blank-outline" : "checkbox-marked";
|
|
830
|
-
}
|
|
831
|
-
this._tempValue = inputValue;
|
|
832
|
-
}
|
|
833
|
-
// A narrowed down list with search, or a different asynchronous approach does not always trigger @MDCSelect:change,
|
|
834
|
-
// so using itemClickHandler instead to let it trigger anyway.
|
|
835
|
-
else if (this.searchProvider != undefined || !Array.isArray(opts)) {
|
|
836
|
-
this.onValueChange(undefined, item.value);
|
|
837
|
-
}
|
|
838
|
-
};
|
|
839
|
-
const menuCloseHandler = () => {
|
|
840
|
-
var _a;
|
|
841
|
-
const v = ((_a = this._tempValue) !== null && _a !== void 0 ? _a : this.value);
|
|
842
|
-
window.setTimeout(() => {
|
|
843
|
-
if (this._mdcComponent) {
|
|
844
|
-
// Hack to stop label moving down when there is a value set
|
|
845
|
-
this._mdcComponent.foundation.adapter.floatLabel(v && (!Array.isArray(v) || v.length > 0));
|
|
846
|
-
}
|
|
847
|
-
});
|
|
848
|
-
if (!this._tempValue) {
|
|
849
|
-
return;
|
|
850
|
-
}
|
|
851
|
-
const val = [...this._tempValue];
|
|
852
|
-
this._tempValue = undefined;
|
|
853
|
-
this.onValueChange(undefined, val);
|
|
854
|
-
};
|
|
855
|
-
const listTemplate = (options) => {
|
|
856
|
-
if (this.searchProvider != undefined && (!options || options.length == 0)) {
|
|
857
|
-
return html `<span class="mdc-text-field-helper-line" style="margin: 8px 8px 8px 0;">${i18next.t('noResults')}</span>`;
|
|
858
|
-
}
|
|
859
|
-
else {
|
|
860
|
-
return getListTemplate(this.multiple ? ListType.MULTI_TICK : ListType.SELECT, html `${options === null || options === void 0 ? void 0 : options.map(([optValue, optDisplay], index) => {
|
|
861
|
-
return getItemTemplate({
|
|
862
|
-
text: optDisplay,
|
|
863
|
-
value: optValue
|
|
864
|
-
}, index, Array.isArray(this.value) ? this.value : this.value ? [this.value] : [], this.multiple ? ListType.MULTI_TICK : ListType.SELECT, false, itemClickHandler);
|
|
865
|
-
})}`, false, undefined);
|
|
866
|
-
}
|
|
867
|
-
};
|
|
868
|
-
return html `
|
|
869
|
-
<div id="component"
|
|
870
|
-
class="mdc-select ${classMap(classes)}"
|
|
871
|
-
@MDCSelect:change="${(e) => __awaiter(this, void 0, void 0, function* () {
|
|
872
|
-
const options = (Array.isArray(opts) ? opts : yield opts);
|
|
873
|
-
this.onValueChange(undefined, e.detail.index === -1 ? undefined : Array.isArray(options[e.detail.index]) ? options[e.detail.index][0] : options[e.detail.index]);
|
|
874
|
-
})}">
|
|
875
|
-
<div class="mdc-select__anchor" role="button"
|
|
876
|
-
aria-haspopup="listbox"
|
|
877
|
-
aria-expanded="false"
|
|
878
|
-
aria-disabled="${"" + (this.disabled || this.readonly)}"
|
|
879
|
-
aria-labelledby="label selected-text">
|
|
880
|
-
${!outlined ? html `<span class="mdc-select__ripple"></span>` : undefined}
|
|
881
|
-
${outlined ? this.renderOutlined(labelTemplate) : labelTemplate}
|
|
882
|
-
<span class="mdc-select__selected-text-container">
|
|
883
|
-
<span id="selected-text" class="mdc-select__selected-text"></span>
|
|
884
|
-
</span>
|
|
885
|
-
<span class="mdc-select__dropdown-icon">
|
|
886
|
-
<svg
|
|
887
|
-
class="mdc-select__dropdown-icon-graphic"
|
|
888
|
-
viewBox="7 10 10 5">
|
|
889
|
-
<polygon
|
|
890
|
-
class="mdc-select__dropdown-icon-inactive"
|
|
891
|
-
stroke="none"
|
|
892
|
-
fill-rule="evenodd"
|
|
893
|
-
points="7 10 12 15 17 10">
|
|
894
|
-
</polygon>
|
|
895
|
-
<polygon
|
|
896
|
-
class="mdc-select__dropdown-icon-active"
|
|
897
|
-
stroke="none"
|
|
898
|
-
fill-rule="evenodd"
|
|
899
|
-
points="7 15 12 10 17 15">
|
|
900
|
-
</polygon>
|
|
901
|
-
</svg>
|
|
902
|
-
</span>
|
|
903
|
-
${!outlined ? html `<div class="mdc-line-ripple"></div>` : ``}
|
|
904
|
-
</div>
|
|
905
|
-
<div id="mdc-select-menu" class="mdc-select__menu mdc-menu mdc-menu-surface mdc-menu-surface--fixed ${this.searchProvider != undefined ? 'mdc-menu__searchable' : undefined}" @MDCMenuSurface:closed="${menuCloseHandler}">
|
|
906
|
-
${when(this.searchProvider != undefined, () => html `
|
|
907
|
-
<label id="select-searchable" class="mdc-text-field mdc-text-field--filled">
|
|
908
|
-
<span class="mdc-floating-label" style="color: rgba(0, 0, 0, 0.6); text-transform: capitalize; visibility: ${this.searchableValue ? 'hidden' : 'visible'}" id="my-label-id">
|
|
909
|
-
<or-translate .value="${this.searchLabel}"></or-translate>
|
|
910
|
-
</span>
|
|
911
|
-
<input class="mdc-text-field__input" type="text"
|
|
912
|
-
@keyup="${(e) => this.searchableValue = e.target.value}"
|
|
913
|
-
/>
|
|
914
|
-
</label>
|
|
915
|
-
`)}
|
|
916
|
-
${when(Array.isArray(opts), () => {
|
|
917
|
-
return listTemplate(opts);
|
|
918
|
-
}, () => {
|
|
919
|
-
return until(new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
|
920
|
-
resolve(listTemplate(yield opts));
|
|
921
|
-
})), html `<span class="mdc-text-field-helper-line" style="margin: 8px 8px 8px 0;">${i18next.t('loading')}</span>`);
|
|
922
|
-
})}
|
|
923
|
-
</div>
|
|
924
|
-
${hasHelper || showValidationMessage ? html `
|
|
925
|
-
<p id="component-helper-text" class="mdc-select-helper-text ${classMap(helperClasses)}" aria-hidden="true">
|
|
926
|
-
${showValidationMessage ? this.errorMessage || this.validationMessage : this.helperText}
|
|
927
|
-
</p>` : ``}
|
|
928
|
-
</div>
|
|
929
|
-
`;
|
|
930
|
-
case InputType.BUTTON_TOGGLE:
|
|
931
|
-
return html `
|
|
932
|
-
<button id="component" class="mdc-icon-button ${this.value ? "mdc-icon-button--on" : ""}"
|
|
933
|
-
?readonly="${this.readonly}"
|
|
934
|
-
?disabled="${this.disabled}"
|
|
935
|
-
@MDCIconButtonToggle:change="${(evt) => this.onValueChange(undefined, evt.detail.isOn)}">
|
|
936
|
-
${this.icon ? html `<or-icon class="mdc-icon-button__icon" aria-hidden="true" icon="${this.icon}"></or-icon>` : ``}
|
|
937
|
-
${this.iconOn ? html `<or-icon class="mdc-icon-button__icon mdc-icon-button__icon--on" aria-hidden="true" icon="${this.iconOn}"></or-icon>` : ``}
|
|
938
|
-
</button>
|
|
939
|
-
`;
|
|
940
|
-
case InputType.BUTTON:
|
|
941
|
-
case InputType.BUTTON_MOMENTARY: {
|
|
942
|
-
const onMouseDown = (ev) => {
|
|
943
|
-
if (this.disabled) {
|
|
944
|
-
ev.stopPropagation();
|
|
945
|
-
}
|
|
946
|
-
if (isMomentary)
|
|
947
|
-
this.dispatchEvent(new OrInputChangedEvent(true, null));
|
|
948
|
-
};
|
|
949
|
-
const onMouseUp = (ev) => {
|
|
950
|
-
if (this.disabled) {
|
|
951
|
-
ev.stopPropagation();
|
|
952
|
-
}
|
|
953
|
-
if (isMomentary)
|
|
954
|
-
this.dispatchEvent(new OrInputChangedEvent(false, true));
|
|
955
|
-
};
|
|
956
|
-
const onClick = (ev) => {
|
|
957
|
-
if (this.disabled) {
|
|
958
|
-
ev.stopPropagation();
|
|
959
|
-
}
|
|
960
|
-
if (!isMomentary)
|
|
961
|
-
this.dispatchEvent(new OrInputChangedEvent(true, null));
|
|
962
|
-
};
|
|
963
|
-
const isMomentary = this.type === InputType.BUTTON_MOMENTARY;
|
|
964
|
-
const isIconButton = !this.action && !this.label;
|
|
965
|
-
// If no action, label or icons are given, show as a circle.
|
|
966
|
-
if (isIconButton && !this.iconTrailing && !this.icon) {
|
|
967
|
-
this.icon = "circle";
|
|
968
|
-
}
|
|
969
|
-
const classes = {
|
|
970
|
-
"mdc-icon-button": isIconButton,
|
|
971
|
-
"mdc-fab": !isIconButton && this.action,
|
|
972
|
-
"mdc-fab--extended": !isIconButton && this.action && !!this.label,
|
|
973
|
-
"mdc-fab--mini": !isIconButton && this.action && (this.compact || this.comfortable),
|
|
974
|
-
"mdc-button": !isIconButton && !this.action,
|
|
975
|
-
"mdc-button--raised": !isIconButton && !this.action && this.raised,
|
|
976
|
-
"mdc-button--unelevated": !isIconButton && !this.action && this.unElevated,
|
|
977
|
-
"mdc-button--outlined": !isIconButton && !this.action && (this.outlined || isMomentary),
|
|
978
|
-
"mdc-button--rounded": !isIconButton && !this.action && this.rounded,
|
|
979
|
-
"mdc-button--fullwidth": this.fullWidth,
|
|
980
|
-
};
|
|
981
|
-
return html `
|
|
982
|
-
<button id="component" class="${classMap(classes)}"
|
|
983
|
-
?readonly="${this.readonly}"
|
|
984
|
-
?disabled="${this.disabled}"
|
|
985
|
-
@click="${(ev) => onClick(ev)}"
|
|
986
|
-
@mousedown="${(ev) => onMouseDown(ev)}" @mouseup="${(ev) => onMouseUp(ev)}">
|
|
987
|
-
${!isIconButton ? html `<div class="mdc-button__ripple"></div>` : ``}
|
|
988
|
-
${this.icon ? html `<or-icon class="${isIconButton ? "" : this.action ? "mdc-fab__icon" : "mdc-button__icon"}" aria-hidden="true" icon="${this.icon}"></or-icon>` : ``}
|
|
989
|
-
${this.label ? html `<span class="${this.action ? "mdc-fab__label" : "mdc-button__label"}"><or-translate .value="${this.label}"></or-translate></span>` : ``}
|
|
990
|
-
${!isIconButton && this.iconTrailing ? html `<or-icon class="${this.action ? "mdc-fab__icon" : "mdc-button__icon"}" aria-hidden="true" icon="${this.iconTrailing}"></or-icon>` : ``}
|
|
991
|
-
</button>
|
|
992
|
-
`;
|
|
993
|
-
}
|
|
994
|
-
case InputType.CHECKBOX_LIST:
|
|
995
|
-
if (!Array.isArray(this.value)) {
|
|
996
|
-
if (this.value === null || this.value === undefined) {
|
|
997
|
-
this.value = [];
|
|
998
|
-
}
|
|
999
|
-
else {
|
|
1000
|
-
this.value = [this.value];
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
const optsCheckboxList = this.resolveOptions(this.options);
|
|
1004
|
-
this._selectedIndex = -1;
|
|
1005
|
-
return html `
|
|
1006
|
-
<div class="mdc-checkbox-list">
|
|
1007
|
-
${optsCheckboxList ? optsCheckboxList.map(([optValue, optDisplay], index) => {
|
|
1008
|
-
if (this.value === optValue) {
|
|
1009
|
-
this._selectedIndex = index;
|
|
1010
|
-
}
|
|
1011
|
-
return html `
|
|
1012
|
-
<div id="field" class="mdc-form-field">
|
|
1013
|
-
<div id="component" class="mdc-checkbox">
|
|
1014
|
-
<input type="checkbox"
|
|
1015
|
-
?checked="${this.value && this.value.includes(optValue)}"
|
|
1016
|
-
?required="${this.required}"
|
|
1017
|
-
name="${optValue}"
|
|
1018
|
-
?disabled="${this.disabled || this.readonly}"
|
|
1019
|
-
@change="${(e) => {
|
|
1020
|
-
let val = this.value;
|
|
1021
|
-
if (e.target.checked) {
|
|
1022
|
-
if (!val.includes(optValue)) {
|
|
1023
|
-
val = [optValue, ...val];
|
|
1024
|
-
}
|
|
1025
|
-
}
|
|
1026
|
-
else {
|
|
1027
|
-
val = val.filter((v) => v !== optValue);
|
|
1028
|
-
}
|
|
1029
|
-
this.onValueChange(e.target, val);
|
|
1030
|
-
}}"
|
|
1031
|
-
class="mdc-checkbox__native-control" id="elem-${optValue}"/>
|
|
1032
|
-
|
|
1033
|
-
<label for="elem-${optValue}"><or-translate value="${optDisplay}"></or-translate></label>
|
|
1034
|
-
|
|
1035
|
-
</div>
|
|
1036
|
-
</div>
|
|
1037
|
-
|
|
1038
|
-
`;
|
|
1039
|
-
}) : ``}
|
|
1040
|
-
</div>
|
|
1041
|
-
`;
|
|
1042
|
-
case InputType.CHECKBOX:
|
|
1043
|
-
let classList = {
|
|
1044
|
-
"mdc-checkbox": true,
|
|
1045
|
-
"mdc-checkbox--disabled": this.disabled || this.readonly
|
|
1046
|
-
};
|
|
1047
|
-
return html `
|
|
1048
|
-
<div id="field" class="mdc-form-field">
|
|
1049
|
-
<div id="component" class="${classMap(classList)}">
|
|
1050
|
-
<input type="checkbox"
|
|
1051
|
-
id="elem"
|
|
1052
|
-
data-indeterminate="${this.indeterminate}"
|
|
1053
|
-
?checked="${this.value}"
|
|
1054
|
-
?required="${this.required}"
|
|
1055
|
-
?disabled="${this.disabled || this.readonly}"
|
|
1056
|
-
@change="${(e) => this.onValueChange(e.target, e.target.checked)}"
|
|
1057
|
-
class="mdc-checkbox__native-control" />
|
|
1058
|
-
<div class="mdc-checkbox__background">
|
|
1059
|
-
<svg class="mdc-checkbox__checkmark" viewBox="0 0 24 24">
|
|
1060
|
-
<path class="mdc-checkbox__checkmark-path" fill="none" d="M1.73,12.91 8.1,19.28 22.79,4.59"></path>
|
|
1061
|
-
</svg>
|
|
1062
|
-
<div class="mdc-checkbox__mixedmark"></div>
|
|
1063
|
-
</div>
|
|
1064
|
-
<div class="mdc-checkbox__ripple"></div>
|
|
1065
|
-
</div>
|
|
1066
|
-
<label class="mdc-checkbox-circle" for="elem">${this.label}</label>
|
|
1067
|
-
</div>
|
|
1068
|
-
`;
|
|
1069
|
-
case InputType.COLOUR:
|
|
1070
|
-
return html `
|
|
1071
|
-
<div id="component" style="width: 100%; display: inline-flex; align-items: center; padding: 8px 0;">
|
|
1072
|
-
<input type="color" id="elem" style="border: none; height: 31px; width: 31px; padding: 1px 3px; min-height: 22px; min-width: 30px;cursor: pointer" value="${this.value}"
|
|
1073
|
-
?disabled="${this.disabled || this.readonly}"
|
|
1074
|
-
?required="${this.required}"
|
|
1075
|
-
@change="${(e) => this.onValueChange(e.target, e.target.value)}"
|
|
1076
|
-
/>
|
|
1077
|
-
<label style="margin-left: 10px; cursor: pointer" for="elem">${this.label}</label>
|
|
1078
|
-
</div>
|
|
1079
|
-
`;
|
|
1080
|
-
case InputType.NUMBER:
|
|
1081
|
-
case InputType.RANGE:
|
|
1082
|
-
case InputType.DATE:
|
|
1083
|
-
case InputType.DATETIME:
|
|
1084
|
-
case InputType.TIME:
|
|
1085
|
-
case InputType.MONTH:
|
|
1086
|
-
case InputType.WEEK:
|
|
1087
|
-
case InputType.EMAIL:
|
|
1088
|
-
case InputType.PASSWORD:
|
|
1089
|
-
case InputType.TELEPHONE:
|
|
1090
|
-
case InputType.URL:
|
|
1091
|
-
case InputType.TEXT:
|
|
1092
|
-
case InputType.TEXTAREA:
|
|
1093
|
-
case InputType.JSON:
|
|
1094
|
-
case InputType.JSON_OBJECT: {
|
|
1095
|
-
// The following HTML input types require the values as specially formatted strings
|
|
1096
|
-
let valMinMax = [this.value === undefined || this.value === null ? undefined : this.value, this.min, this.max];
|
|
1097
|
-
if (valMinMax.some((v) => typeof (v) !== "string")) {
|
|
1098
|
-
if (this.type === InputType.JSON || this.type === InputType.JSON_OBJECT) {
|
|
1099
|
-
if (valMinMax[0] !== undefined) {
|
|
1100
|
-
if (typeof valMinMax[0] !== "string" || valMinMax[0] === null) {
|
|
1101
|
-
try {
|
|
1102
|
-
valMinMax[0] = JSON.stringify(valMinMax[0], null, 2);
|
|
1103
|
-
}
|
|
1104
|
-
catch (e) {
|
|
1105
|
-
console.warn("Failed to parse JSON expression for input control");
|
|
1106
|
-
valMinMax[0] = "";
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1109
|
-
}
|
|
1110
|
-
else {
|
|
1111
|
-
valMinMax[0] = "";
|
|
1112
|
-
}
|
|
1113
|
-
}
|
|
1114
|
-
else {
|
|
1115
|
-
const format = this.format ? Object.assign({}, this.format) : {};
|
|
1116
|
-
switch (this.type) {
|
|
1117
|
-
case InputType.TIME:
|
|
1118
|
-
format.asDate = true;
|
|
1119
|
-
format.hour12 = false;
|
|
1120
|
-
format.timeStyle = this.step && this.step < 60 ? "medium" /* ValueFormatStyleRepresentation.MEDIUM */ : "short" /* ValueFormatStyleRepresentation.SHORT */;
|
|
1121
|
-
break;
|
|
1122
|
-
case InputType.DATE:
|
|
1123
|
-
format.asDate = true;
|
|
1124
|
-
format.momentJsFormat = "YYYY-MM-DD";
|
|
1125
|
-
break;
|
|
1126
|
-
case InputType.WEEK:
|
|
1127
|
-
format.asDate = true;
|
|
1128
|
-
format.momentJsFormat = "YYYY-[W]WW";
|
|
1129
|
-
break;
|
|
1130
|
-
case InputType.MONTH:
|
|
1131
|
-
format.asDate = true;
|
|
1132
|
-
format.momentJsFormat = "YYYY-MM";
|
|
1133
|
-
break;
|
|
1134
|
-
case InputType.DATETIME:
|
|
1135
|
-
format.asDate = true;
|
|
1136
|
-
format.momentJsFormat = "YYYY-MM-DDTHH:mm";
|
|
1137
|
-
break;
|
|
1138
|
-
case InputType.NUMBER:
|
|
1139
|
-
(_a = format.maximumFractionDigits) !== null && _a !== void 0 ? _a : (format.maximumFractionDigits = 20); // default according to Web documentation
|
|
1140
|
-
break;
|
|
1141
|
-
}
|
|
1142
|
-
// Numbers/dates must be in english locale without commas etc.
|
|
1143
|
-
format.useGrouping = false;
|
|
1144
|
-
valMinMax = valMinMax.map((val) => val !== undefined ? Util.getValueAsString(val, () => format, "en-GB") : undefined);
|
|
1145
|
-
}
|
|
1146
|
-
}
|
|
1147
|
-
let inputElem;
|
|
1148
|
-
let label = this.label;
|
|
1149
|
-
let type = this.type;
|
|
1150
|
-
let componentId = "component";
|
|
1151
|
-
if (this.type === InputType.RANGE) {
|
|
1152
|
-
// Change vars so number input can be included alongside the slider
|
|
1153
|
-
label = undefined;
|
|
1154
|
-
outlined = false;
|
|
1155
|
-
hasHelper = false;
|
|
1156
|
-
type = InputType.NUMBER;
|
|
1157
|
-
componentId = "number";
|
|
1158
|
-
}
|
|
1159
|
-
if (!(this.type === InputType.RANGE && this.disableSliderNumberInput)) {
|
|
1160
|
-
// Handle password toggling logic
|
|
1161
|
-
if (this.censored)
|
|
1162
|
-
type = InputType.PASSWORD;
|
|
1163
|
-
if (this.type === InputType.PASSWORD && this.advertised)
|
|
1164
|
-
type = InputType.TEXT;
|
|
1165
|
-
const classes = {
|
|
1166
|
-
"mdc-text-field": true,
|
|
1167
|
-
"mdc-text-field--invalid": !this.valid,
|
|
1168
|
-
"mdc-text-field--filled": !outlined,
|
|
1169
|
-
"mdc-text-field--outlined": outlined,
|
|
1170
|
-
"mdc-text-field--textarea": type === InputType.TEXTAREA || type === InputType.JSON || type === InputType.JSON_OBJECT,
|
|
1171
|
-
"mdc-text-field--disabled": this.disabled,
|
|
1172
|
-
"mdc-text-field--fullwidth": this.fullWidth && !outlined,
|
|
1173
|
-
"dense-comfortable": this.comfortable && !(type === InputType.TEXTAREA || type === InputType.JSON || type === InputType.JSON_OBJECT),
|
|
1174
|
-
"dense-compact": !this.comfortable && this.compact,
|
|
1175
|
-
"mdc-text-field--label-floating": hasValue,
|
|
1176
|
-
"mdc-text-field--no-label": !this.label,
|
|
1177
|
-
"mdc-text-field--with-leading-icon": !!this.icon,
|
|
1178
|
-
"mdc-text-field--with-trailing-icon": !!this.iconTrailing,
|
|
1179
|
-
"or-mwc-input--rounded": this.rounded
|
|
1180
|
-
};
|
|
1181
|
-
inputElem = type === InputType.TEXTAREA || type === InputType.JSON || type === InputType.JSON_OBJECT
|
|
1182
|
-
? html `
|
|
1183
|
-
<textarea id="elem" class="mdc-text-field__input ${this.resizeVertical ? "resize-vertical" : ""}" ?required="${this.required}"
|
|
1184
|
-
?readonly="${this.readonly}" ?disabled="${this.disabled}" minlength="${ifDefined(this.minLength)}"
|
|
1185
|
-
maxlength="${ifDefined(this.maxLength)}" rows="${this.rows ? this.rows : 5}"
|
|
1186
|
-
cols="${ifDefined(this.cols)}" aria-label="${ifDefined(label)}"
|
|
1187
|
-
aria-labelledby="${ifDefined(label ? "label" : undefined)}"
|
|
1188
|
-
@change="${(e) => this.onValueChange(e.target, e.target.value)}">${valMinMax[0] ? valMinMax[0] : ""}</textarea>`
|
|
1189
|
-
: html `
|
|
1190
|
-
<input type="${type}" id="elem" aria-labelledby="${ifDefined(label ? "label" : undefined)}"
|
|
1191
|
-
class="mdc-text-field__input" ?required="${this.required}" ?readonly="${this.readonly}"
|
|
1192
|
-
?disabled="${this.disabled}" min="${ifDefined(valMinMax[1])}" max="${ifDefined(valMinMax[2])}"
|
|
1193
|
-
step="${this.step ? this.step : "any"}" minlength="${ifDefined(this.minLength)}" pattern="${ifDefined(this.pattern)}"
|
|
1194
|
-
maxlength="${ifDefined(this.maxLength)}" placeholder="${ifDefined(this.placeHolder)}"
|
|
1195
|
-
.value="${valMinMax[0] !== null && valMinMax[0] !== undefined ? valMinMax[0] : ""}"
|
|
1196
|
-
@keydown="${(e) => {
|
|
1197
|
-
if ((e.code === "Enter" || e.code === "NumpadEnter")) {
|
|
1198
|
-
this.onValueChange(e.target, e.target.value, true);
|
|
1199
|
-
}
|
|
1200
|
-
}}"
|
|
1201
|
-
@blur="${(e) => { if (e.target.value === "")
|
|
1202
|
-
this.reportValidity(); }}"
|
|
1203
|
-
@change="${(e) => this.onValueChange(e.target, e.target.value)}" />`;
|
|
1204
|
-
inputElem = html `
|
|
1205
|
-
<label id="${componentId}" class="${classMap(classes)}">
|
|
1206
|
-
${this.icon ? html `<or-icon class="mdc-text-field__icon mdc-text-field__icon--leading" style="color: ${this.iconColor ? "#" + this.iconColor : "unset"}" aria-hidden="true" icon="${this.icon}"></or-icon>` : ``}
|
|
1207
|
-
${outlined ? `` : html `<span class="mdc-text-field__ripple"></span>`}
|
|
1208
|
-
${inputElem}
|
|
1209
|
-
${outlined ? this.renderOutlined(labelTemplate) : labelTemplate}
|
|
1210
|
-
${outlined ? `` : html `<span class="mdc-line-ripple"></span>`}
|
|
1211
|
-
${this.type === InputType.PASSWORD && !this.censored ? html `<or-icon class="mdc-text-field__icon mdc-text-field__icon--trailing" aria-hidden="true" icon=${this.advertised ? 'eye' : 'eye-off'} style="pointer-events: auto;" @click=${() => this.advertised = !this.advertised}></or-icon>` : ``}
|
|
1212
|
-
${this.iconTrailing ? html `<or-icon class="mdc-text-field__icon mdc-text-field__icon--trailing" aria-hidden="true" icon="${this.iconTrailing}"></or-icon>` : ``}
|
|
1213
|
-
</label>
|
|
1214
|
-
${hasHelper || showValidationMessage ? html `
|
|
1215
|
-
<div class="mdc-text-field-helper-line">
|
|
1216
|
-
<div class="mdc-text-field-helper-text ${classMap(helperClasses)}">${showValidationMessage ? this.errorMessage || this.validationMessage : this.helperText}</div>
|
|
1217
|
-
${this.charCounter && !this.readonly ? html `<div class="mdc-text-field-character-counter"></div>` : ``}
|
|
1218
|
-
</div>
|
|
1219
|
-
` : ``}
|
|
1220
|
-
`;
|
|
1221
|
-
}
|
|
1222
|
-
if (this.type === InputType.RANGE) {
|
|
1223
|
-
const classes = {
|
|
1224
|
-
"mdc-slider": true,
|
|
1225
|
-
"mdc-slider--range": this.continuous,
|
|
1226
|
-
"mdc-slider--discreet": !this.continuous,
|
|
1227
|
-
"mdc-slider--disabled": this.disabled || this.readonly
|
|
1228
|
-
};
|
|
1229
|
-
inputElem = html `
|
|
1230
|
-
<span id="wrapper">
|
|
1231
|
-
${this.label ? html `<label for="component" class="${this.disabled ? "mdc-switch--disabled" : ""}">${this.label}</label>` : ``}
|
|
1232
|
-
<div id="component" class="${classMap(classes)}" @MDCSlider:change="${(ev) => this.onValueChange(undefined, ev.detail.value)}">
|
|
1233
|
-
<input id="elem" class="mdc-slider__input" type="range" min="${ifDefined(valMinMax[1])}" max="${ifDefined(valMinMax[2])}" value="${valMinMax[0] || valMinMax[1] || 0}" name="slider" step="${this.step || 1}" ?readonly="${this.readonly}" ?disabled="${this.disabled}" aria-label="${ifDefined(this.label)}" />
|
|
1234
|
-
<div class="mdc-slider__track">
|
|
1235
|
-
<div class="mdc-slider__track--inactive"></div>
|
|
1236
|
-
<div class="mdc-slider__track--active">
|
|
1237
|
-
<div class="mdc-slider__track--active_fill"></div>
|
|
1238
|
-
</div>
|
|
1239
|
-
</div>
|
|
1240
|
-
<div class="mdc-slider__thumb">
|
|
1241
|
-
${!this.continuous ? html `<div class="mdc-slider__value-indicator-container" aria-hidden="true">
|
|
1242
|
-
<div class="mdc-slider__value-indicator">
|
|
1243
|
-
<span class="mdc-slider__value-indicator-text">
|
|
1244
|
-
50
|
|
1245
|
-
</span>
|
|
1246
|
-
</div>
|
|
1247
|
-
</div>` : ``}
|
|
1248
|
-
<div class="mdc-slider__thumb-knob"></div>
|
|
1249
|
-
</div>
|
|
1250
|
-
</div>
|
|
1251
|
-
${inputElem ? html `<div style="min-width: 70px; width: 70px;">${inputElem}</div>` : ``}
|
|
1252
|
-
</span>
|
|
1253
|
-
`;
|
|
1254
|
-
}
|
|
1255
|
-
return inputElem;
|
|
1256
|
-
}
|
|
1257
|
-
}
|
|
1258
|
-
}
|
|
1259
|
-
return html `<span>INPUT TYPE NOT IMPLEMENTED</span>`;
|
|
1260
|
-
}
|
|
1261
|
-
_getFormat() {
|
|
1262
|
-
if (this.format) {
|
|
1263
|
-
return this.format;
|
|
1264
|
-
}
|
|
1265
|
-
}
|
|
1266
|
-
update(_changedProperties) {
|
|
1267
|
-
if (_changedProperties.has('autoValidate') && this._mdcComponent) {
|
|
1268
|
-
const comp = this._mdcComponent;
|
|
1269
|
-
if (comp.foundation && comp.foundation.setValidateOnValueChange) {
|
|
1270
|
-
comp.foundation.setValidateOnValueChange(this.autoValidate);
|
|
1271
|
-
}
|
|
1272
|
-
}
|
|
1273
|
-
super.update(_changedProperties);
|
|
1274
|
-
}
|
|
1275
|
-
firstUpdated(_changedProperties) {
|
|
1276
|
-
super.firstUpdated(_changedProperties);
|
|
1277
|
-
if (this.autoValidate) {
|
|
1278
|
-
this.reportValidity();
|
|
1279
|
-
}
|
|
1280
|
-
}
|
|
1281
|
-
updated(_changedProperties) {
|
|
1282
|
-
var _a, _b;
|
|
1283
|
-
super.updated(_changedProperties);
|
|
1284
|
-
if (_changedProperties.has("type")) {
|
|
1285
|
-
const component = this.shadowRoot.getElementById("component");
|
|
1286
|
-
if (this._mdcComponent) {
|
|
1287
|
-
this._mdcComponent.destroy();
|
|
1288
|
-
this._mdcComponent = undefined;
|
|
1289
|
-
}
|
|
1290
|
-
if (this._mdcComponent2) {
|
|
1291
|
-
this._mdcComponent2.destroy();
|
|
1292
|
-
this._mdcComponent2 = undefined;
|
|
1293
|
-
}
|
|
1294
|
-
if (component && this.type) {
|
|
1295
|
-
switch (this.type) {
|
|
1296
|
-
case InputType.LIST:
|
|
1297
|
-
const mdcList = new MDCList(component);
|
|
1298
|
-
this._mdcComponent = mdcList;
|
|
1299
|
-
mdcList.selectedIndex = this._selectedIndex;
|
|
1300
|
-
break;
|
|
1301
|
-
case InputType.SELECT:
|
|
1302
|
-
const mdcSelect = new MDCSelect(component);
|
|
1303
|
-
this._mdcComponent = mdcSelect;
|
|
1304
|
-
const hasValue = (this.value !== null && this.value !== undefined);
|
|
1305
|
-
if (!hasValue) {
|
|
1306
|
-
mdcSelect.selectedIndex = -1; // Without this first option will be shown as selected
|
|
1307
|
-
}
|
|
1308
|
-
if (this.multiple) {
|
|
1309
|
-
// To make multiple select work then override the adapter getSelectedIndex
|
|
1310
|
-
this._mdcComponent.foundation.adapter.getSelectedIndex = () => {
|
|
1311
|
-
// Return first item index
|
|
1312
|
-
if (!Array.isArray(this.value) || this.value.length === 0) {
|
|
1313
|
-
return -1;
|
|
1314
|
-
}
|
|
1315
|
-
const firstSelected = this.value[0];
|
|
1316
|
-
const items = this._mdcComponent.foundation.adapter.getMenuItemValues();
|
|
1317
|
-
return items.indexOf(firstSelected);
|
|
1318
|
-
};
|
|
1319
|
-
}
|
|
1320
|
-
mdcSelect.useDefaultValidation = !this.multiple;
|
|
1321
|
-
mdcSelect.valid = !this.required || (!this.multiple && mdcSelect.valid) || (this.multiple && Array.isArray(this.value) && this.value.length > 0);
|
|
1322
|
-
const selectedText = this.getSelectedTextValue();
|
|
1323
|
-
this._mdcComponent.foundation.adapter.setSelectedText(selectedText);
|
|
1324
|
-
this._mdcComponent.foundation.adapter.floatLabel(!!selectedText);
|
|
1325
|
-
// Set width of fixed select menu to match the component width
|
|
1326
|
-
// Using an observer to prevent forced reflow / DOM measurements; prevents blocking the thread
|
|
1327
|
-
if (!this._menuObserver) {
|
|
1328
|
-
this._menuObserver = new IntersectionObserver((entries, observer) => {
|
|
1329
|
-
var _a, _b;
|
|
1330
|
-
if (entries[0].target.style.minWidth != (((_a = entries[0].target.parentElement) === null || _a === void 0 ? void 0 : _a.clientWidth) + "px")) {
|
|
1331
|
-
entries[0].target.style.minWidth = ((_b = entries[0].target.parentElement) === null || _b === void 0 ? void 0 : _b.clientWidth) + "px";
|
|
1332
|
-
}
|
|
1333
|
-
});
|
|
1334
|
-
this._menuObserver.observe(this.shadowRoot.getElementById("mdc-select-menu"));
|
|
1335
|
-
}
|
|
1336
|
-
// This overrides the standard mdc menu body click capture handler as it doesn't work with webcomponents
|
|
1337
|
-
const searchable = (this.searchProvider !== undefined);
|
|
1338
|
-
const multi = this.multiple;
|
|
1339
|
-
mdcSelect.menu.menuSurface_.foundation.handleBodyClick = function (evt) {
|
|
1340
|
-
const el = evt.composedPath()[0]; // Use composed path not evt target to work with webcomponents
|
|
1341
|
-
if (this.adapter.isElementInContainer(el)) {
|
|
1342
|
-
if (!searchable) {
|
|
1343
|
-
return; // Normal select menu closes automatically, so abort
|
|
1344
|
-
}
|
|
1345
|
-
// if searchable, we manually close the menu when clicking a list item.
|
|
1346
|
-
// However, if something else than a list item (for example the search field) is clicked, it should not close, so abort.
|
|
1347
|
-
else if (el instanceof Element && !el.className.includes('mdc-list-item')) {
|
|
1348
|
-
return;
|
|
1349
|
-
}
|
|
1350
|
-
else if (multi) {
|
|
1351
|
-
return;
|
|
1352
|
-
}
|
|
1353
|
-
}
|
|
1354
|
-
mdcSelect.menu.menuSurface_.close();
|
|
1355
|
-
};
|
|
1356
|
-
break;
|
|
1357
|
-
case InputType.RADIO:
|
|
1358
|
-
case InputType.CHECKBOX_LIST:
|
|
1359
|
-
case InputType.COLOUR:
|
|
1360
|
-
break;
|
|
1361
|
-
case InputType.BUTTON:
|
|
1362
|
-
case InputType.BUTTON_MOMENTARY:
|
|
1363
|
-
const isIconButton = !this.action && !this.label;
|
|
1364
|
-
const ripple = new MDCRipple(component);
|
|
1365
|
-
if (isIconButton) {
|
|
1366
|
-
ripple.unbounded = true;
|
|
1367
|
-
}
|
|
1368
|
-
this._mdcComponent = ripple;
|
|
1369
|
-
break;
|
|
1370
|
-
case InputType.BUTTON_TOGGLE:
|
|
1371
|
-
this._mdcComponent = new MDCIconButtonToggle(component);
|
|
1372
|
-
break;
|
|
1373
|
-
case InputType.CHECKBOX:
|
|
1374
|
-
this._mdcComponent = new MDCCheckbox(component);
|
|
1375
|
-
const field = this.shadowRoot.getElementById("field");
|
|
1376
|
-
if (field) {
|
|
1377
|
-
const mdcField = new MDCFormField(field);
|
|
1378
|
-
mdcField.input = this._mdcComponent;
|
|
1379
|
-
this._mdcComponent2 = mdcField;
|
|
1380
|
-
}
|
|
1381
|
-
break;
|
|
1382
|
-
case InputType.SWITCH:
|
|
1383
|
-
this._mdcComponent = new MDCSwitch(component);
|
|
1384
|
-
break;
|
|
1385
|
-
case InputType.RANGE:
|
|
1386
|
-
this._mdcComponent = new MDCSlider(component);
|
|
1387
|
-
const numberComponent = this.shadowRoot.getElementById("number");
|
|
1388
|
-
if (numberComponent) {
|
|
1389
|
-
const numberField = new MDCTextField(numberComponent);
|
|
1390
|
-
numberField.useNativeValidation = false;
|
|
1391
|
-
this._mdcComponent2 = numberField;
|
|
1392
|
-
}
|
|
1393
|
-
break;
|
|
1394
|
-
default:
|
|
1395
|
-
const textField = new MDCTextField(component);
|
|
1396
|
-
textField.useNativeValidation = false;
|
|
1397
|
-
this._mdcComponent = textField;
|
|
1398
|
-
break;
|
|
1399
|
-
}
|
|
1400
|
-
if (this._mdcComponent && this.focused && typeof (this._mdcComponent.focus) === "function") {
|
|
1401
|
-
this._mdcComponent.focus();
|
|
1402
|
-
}
|
|
1403
|
-
}
|
|
1404
|
-
}
|
|
1405
|
-
else {
|
|
1406
|
-
// some components need to be kept in sync with the DOM
|
|
1407
|
-
if (this.type === InputType.SELECT && this._mdcComponent) {
|
|
1408
|
-
if (_changedProperties.has("options")) {
|
|
1409
|
-
this._mdcComponent.layoutOptions(); // has big impact on performance when the MDCSelect list is large.
|
|
1410
|
-
}
|
|
1411
|
-
this._mdcComponent.disabled = !!(this.disabled || this.readonly);
|
|
1412
|
-
this._mdcComponent.useDefaultValidation = !this.multiple;
|
|
1413
|
-
this._mdcComponent.valid = !this.required || (!this.multiple && this._mdcComponent.valid) || (this.multiple && Array.isArray(this.value) && this.value.length > 0);
|
|
1414
|
-
const selectedText = this.getSelectedTextValue();
|
|
1415
|
-
this._mdcComponent.foundation.adapter.setSelectedText(selectedText);
|
|
1416
|
-
this._mdcComponent.foundation.adapter.floatLabel(!!selectedText);
|
|
1417
|
-
}
|
|
1418
|
-
else if (this.type === InputType.RANGE && this._mdcComponent) {
|
|
1419
|
-
const slider = this._mdcComponent;
|
|
1420
|
-
slider.setDisabled(this.disabled || this.readonly);
|
|
1421
|
-
// slider.getDefaultFoundation(). getDefaultFoundation()..getMax() = this.min;
|
|
1422
|
-
// slider.max = this.max;
|
|
1423
|
-
slider.setValue(this.value);
|
|
1424
|
-
}
|
|
1425
|
-
else if (this.type === InputType.SWITCH && this._mdcComponent) {
|
|
1426
|
-
const swtch = this._mdcComponent;
|
|
1427
|
-
swtch.checked = this.value;
|
|
1428
|
-
}
|
|
1429
|
-
else if (this.type === InputType.CHECKBOX && this._mdcComponent) {
|
|
1430
|
-
const checkbox = this._mdcComponent;
|
|
1431
|
-
checkbox.checked = !!this.value;
|
|
1432
|
-
checkbox.disabled = !!(this.disabled || this.readonly);
|
|
1433
|
-
}
|
|
1434
|
-
if (this._mdcComponent) {
|
|
1435
|
-
this._mdcComponent.required = !!this.required;
|
|
1436
|
-
}
|
|
1437
|
-
}
|
|
1438
|
-
if (_changedProperties.has("label")) {
|
|
1439
|
-
(_b = (_a = this._mdcComponent) === null || _a === void 0 ? void 0 : _a.layout) === null || _b === void 0 ? void 0 : _b.call(_a); // Adjusts the dimensions and positions for all sub-elements.
|
|
1440
|
-
}
|
|
1441
|
-
if (this.autoValidate) {
|
|
1442
|
-
this.reportValidity();
|
|
1443
|
-
}
|
|
1444
|
-
}
|
|
1445
|
-
renderOutlined(labelTemplate) {
|
|
1446
|
-
return html `
|
|
1447
|
-
<span class="mdc-notched-outline">
|
|
1448
|
-
<span class="mdc-notched-outline__leading"></span>
|
|
1449
|
-
${labelTemplate ? html `
|
|
1450
|
-
<span class="mdc-notched-outline__notch">
|
|
1451
|
-
${labelTemplate}
|
|
1452
|
-
</span>
|
|
1453
|
-
` : ``}
|
|
1454
|
-
<span class="mdc-notched-outline__trailing"></span>
|
|
1455
|
-
</span>
|
|
1456
|
-
`;
|
|
1457
|
-
}
|
|
1458
|
-
setCustomValidity(msg) {
|
|
1459
|
-
this.errorMessage = msg;
|
|
1460
|
-
const elem = this.shadowRoot.getElementById("elem");
|
|
1461
|
-
if (elem && elem.setCustomValidity) {
|
|
1462
|
-
elem.setCustomValidity(msg !== null && msg !== void 0 ? msg : "");
|
|
1463
|
-
}
|
|
1464
|
-
this.reportValidity();
|
|
1465
|
-
}
|
|
1466
|
-
checkValidity() {
|
|
1467
|
-
const elem = this.shadowRoot.getElementById("elem");
|
|
1468
|
-
let valid = true;
|
|
1469
|
-
if (elem && elem.validity) {
|
|
1470
|
-
const nativeValidity = elem.validity;
|
|
1471
|
-
valid = nativeValidity.valid;
|
|
1472
|
-
}
|
|
1473
|
-
if (valid && (this.type === InputType.JSON || this.type === InputType.JSON_OBJECT)) {
|
|
1474
|
-
// JSON needs special validation - if no text value but this.value then parsing failed
|
|
1475
|
-
if (this.value !== undefined && this.value !== null && this._mdcComponent.value === "") {
|
|
1476
|
-
valid = false;
|
|
1477
|
-
}
|
|
1478
|
-
}
|
|
1479
|
-
return valid;
|
|
1480
|
-
}
|
|
1481
|
-
reportValidity() {
|
|
1482
|
-
const isValid = this.checkValidity();
|
|
1483
|
-
this.isUiValid = isValid;
|
|
1484
|
-
if (this._mdcComponent) {
|
|
1485
|
-
this._mdcComponent.valid = isValid;
|
|
1486
|
-
}
|
|
1487
|
-
return isValid;
|
|
1488
|
-
}
|
|
1489
|
-
onValueChange(elem, newValue, enterPressed) {
|
|
1490
|
-
var _a, _b;
|
|
1491
|
-
let previousValue = this.value;
|
|
1492
|
-
let errorMsg;
|
|
1493
|
-
if (newValue === "undefined") {
|
|
1494
|
-
previousValue = null;
|
|
1495
|
-
newValue = undefined;
|
|
1496
|
-
}
|
|
1497
|
-
if (newValue === "null") {
|
|
1498
|
-
previousValue = undefined;
|
|
1499
|
-
newValue = null;
|
|
1500
|
-
}
|
|
1501
|
-
if (typeof (newValue) === "string") {
|
|
1502
|
-
switch (this.type) {
|
|
1503
|
-
case InputType.CHECKBOX:
|
|
1504
|
-
case InputType.SWITCH:
|
|
1505
|
-
newValue = newValue === "on";
|
|
1506
|
-
break;
|
|
1507
|
-
case InputType.JSON:
|
|
1508
|
-
case InputType.JSON_OBJECT:
|
|
1509
|
-
case InputType.NUMBER:
|
|
1510
|
-
case InputType.RANGE:
|
|
1511
|
-
if (newValue === "") {
|
|
1512
|
-
newValue = null;
|
|
1513
|
-
}
|
|
1514
|
-
else {
|
|
1515
|
-
try {
|
|
1516
|
-
newValue = JSON.parse(newValue);
|
|
1517
|
-
if (this.type === InputType.JSON_OBJECT && (typeof newValue !== 'object' || Array.isArray(newValue))) {
|
|
1518
|
-
newValue = this.value;
|
|
1519
|
-
errorMsg = i18next.t("validation.invalidJSON");
|
|
1520
|
-
}
|
|
1521
|
-
}
|
|
1522
|
-
catch (e) {
|
|
1523
|
-
newValue = this.value;
|
|
1524
|
-
errorMsg = this.type === InputType.JSON || this.type == InputType.JSON_OBJECT ? i18next.t("validation.invalidJSON") : i18next.t("validation.invalidNumber");
|
|
1525
|
-
}
|
|
1526
|
-
}
|
|
1527
|
-
break;
|
|
1528
|
-
case InputType.DATETIME:
|
|
1529
|
-
if (newValue === "") {
|
|
1530
|
-
newValue = null;
|
|
1531
|
-
}
|
|
1532
|
-
else {
|
|
1533
|
-
try {
|
|
1534
|
-
newValue = Date.parse(newValue);
|
|
1535
|
-
}
|
|
1536
|
-
catch (e) {
|
|
1537
|
-
newValue = this.value;
|
|
1538
|
-
errorMsg = i18next.t("validation.invalidDate");
|
|
1539
|
-
}
|
|
1540
|
-
}
|
|
1541
|
-
break;
|
|
1542
|
-
}
|
|
1543
|
-
}
|
|
1544
|
-
this.value = newValue;
|
|
1545
|
-
this.setCustomValidity(errorMsg);
|
|
1546
|
-
this.reportValidity();
|
|
1547
|
-
if (this.type !== InputType.CHECKBOX_LIST && newValue !== previousValue) {
|
|
1548
|
-
if (this.type === InputType.RANGE) {
|
|
1549
|
-
this._mdcComponent.setValue(newValue);
|
|
1550
|
-
if (this._mdcComponent2) {
|
|
1551
|
-
this._mdcComponent2.value = newValue;
|
|
1552
|
-
}
|
|
1553
|
-
}
|
|
1554
|
-
this.dispatchEvent(new OrInputChangedEvent(this.value, previousValue, enterPressed));
|
|
1555
|
-
}
|
|
1556
|
-
// Reset search if value has been selected
|
|
1557
|
-
if (this.searchProvider != undefined && this.type === InputType.SELECT) {
|
|
1558
|
-
const searchableElement = (_b = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.getElementById('select-searchable')) === null || _b === void 0 ? void 0 : _b.children[1];
|
|
1559
|
-
if (searchableElement) {
|
|
1560
|
-
this.searchableValue = undefined;
|
|
1561
|
-
searchableElement.value = "";
|
|
1562
|
-
}
|
|
1563
|
-
}
|
|
1564
|
-
if (this.type === InputType.CHECKBOX_LIST && !Util.objectsEqual(newValue, previousValue, true)) {
|
|
1565
|
-
this.dispatchEvent(new OrInputChangedEvent(newValue, previousValue, enterPressed));
|
|
1566
|
-
}
|
|
1567
|
-
}
|
|
1568
|
-
get valid() {
|
|
1569
|
-
const elem = this.shadowRoot.getElementById("elem");
|
|
1570
|
-
if (elem && elem.checkValidity) {
|
|
1571
|
-
return elem.checkValidity();
|
|
1572
|
-
}
|
|
1573
|
-
return true;
|
|
1574
|
-
}
|
|
1575
|
-
get currentValue() {
|
|
1576
|
-
const elem = this.shadowRoot.getElementById("elem");
|
|
1577
|
-
if (elem && elem.value) {
|
|
1578
|
-
return elem.value;
|
|
1579
|
-
}
|
|
1580
|
-
}
|
|
1581
|
-
resolveOptions(options) {
|
|
1582
|
-
let resolved;
|
|
1583
|
-
if (options && options.length > 0) {
|
|
1584
|
-
resolved = options.map(opt => {
|
|
1585
|
-
if (Array.isArray(opt)) {
|
|
1586
|
-
return opt;
|
|
1587
|
-
}
|
|
1588
|
-
else {
|
|
1589
|
-
const optStr = "" + opt;
|
|
1590
|
-
return [opt, i18next.t(optStr, { defaultValue: Util.camelCaseToSentenceCase(optStr) })];
|
|
1591
|
-
}
|
|
1592
|
-
});
|
|
1593
|
-
}
|
|
1594
|
-
return resolved;
|
|
1595
|
-
}
|
|
1596
|
-
getSelectedTextValue(options) {
|
|
1597
|
-
const value = this.value;
|
|
1598
|
-
const values = Array.isArray(value) ? value : value != null ? [value] : undefined;
|
|
1599
|
-
if (!values) {
|
|
1600
|
-
return "";
|
|
1601
|
-
}
|
|
1602
|
-
const opts = options || this.resolveOptions(this.options);
|
|
1603
|
-
return !opts || !values ? "" : values.map(v => opts.find(([optValue, optDisplay], index) => v === optValue)).map((opt) => opt ? opt[1] : "").join(", ");
|
|
1604
|
-
}
|
|
1605
|
-
};
|
|
1606
|
-
__decorate([
|
|
1607
|
-
property({ type: Boolean })
|
|
1608
|
-
], OrMwcInput.prototype, "focused", void 0);
|
|
1609
|
-
__decorate([
|
|
1610
|
-
property()
|
|
1611
|
-
], OrMwcInput.prototype, "value", void 0);
|
|
1612
|
-
__decorate([
|
|
1613
|
-
property({ type: String })
|
|
1614
|
-
], OrMwcInput.prototype, "type", void 0);
|
|
1615
|
-
__decorate([
|
|
1616
|
-
property({ type: String })
|
|
1617
|
-
], OrMwcInput.prototype, "name", void 0);
|
|
1618
|
-
__decorate([
|
|
1619
|
-
property({ type: Boolean })
|
|
1620
|
-
], OrMwcInput.prototype, "readonly", void 0);
|
|
1621
|
-
__decorate([
|
|
1622
|
-
property({ type: Boolean })
|
|
1623
|
-
], OrMwcInput.prototype, "required", void 0);
|
|
1624
|
-
__decorate([
|
|
1625
|
-
property()
|
|
1626
|
-
], OrMwcInput.prototype, "max", void 0);
|
|
1627
|
-
__decorate([
|
|
1628
|
-
property()
|
|
1629
|
-
], OrMwcInput.prototype, "min", void 0);
|
|
1630
|
-
__decorate([
|
|
1631
|
-
property({ type: Number })
|
|
1632
|
-
], OrMwcInput.prototype, "step", void 0);
|
|
1633
|
-
__decorate([
|
|
1634
|
-
property({ type: Boolean })
|
|
1635
|
-
], OrMwcInput.prototype, "checked", void 0);
|
|
1636
|
-
__decorate([
|
|
1637
|
-
property({ type: Boolean })
|
|
1638
|
-
], OrMwcInput.prototype, "indeterminate", void 0);
|
|
1639
|
-
__decorate([
|
|
1640
|
-
property({ type: Number })
|
|
1641
|
-
], OrMwcInput.prototype, "maxLength", void 0);
|
|
1642
|
-
__decorate([
|
|
1643
|
-
property({ type: Number })
|
|
1644
|
-
], OrMwcInput.prototype, "minLength", void 0);
|
|
1645
|
-
__decorate([
|
|
1646
|
-
property({ type: Number })
|
|
1647
|
-
], OrMwcInput.prototype, "rows", void 0);
|
|
1648
|
-
__decorate([
|
|
1649
|
-
property({ type: Number })
|
|
1650
|
-
], OrMwcInput.prototype, "cols", void 0);
|
|
1651
|
-
__decorate([
|
|
1652
|
-
property({ type: Boolean })
|
|
1653
|
-
], OrMwcInput.prototype, "multiple", void 0);
|
|
1654
|
-
__decorate([
|
|
1655
|
-
property({ type: String, attribute: true, reflect: false })
|
|
1656
|
-
], OrMwcInput.prototype, "pattern", void 0);
|
|
1657
|
-
__decorate([
|
|
1658
|
-
property({ type: String })
|
|
1659
|
-
], OrMwcInput.prototype, "placeHolder", void 0);
|
|
1660
|
-
__decorate([
|
|
1661
|
-
property({ type: Array })
|
|
1662
|
-
], OrMwcInput.prototype, "options", void 0);
|
|
1663
|
-
__decorate([
|
|
1664
|
-
property({ type: Boolean })
|
|
1665
|
-
], OrMwcInput.prototype, "autoSelect", void 0);
|
|
1666
|
-
__decorate([
|
|
1667
|
-
property({ type: Object })
|
|
1668
|
-
], OrMwcInput.prototype, "searchProvider", void 0);
|
|
1669
|
-
__decorate([
|
|
1670
|
-
property({ type: String })
|
|
1671
|
-
], OrMwcInput.prototype, "searchLabel", void 0);
|
|
1672
|
-
__decorate([
|
|
1673
|
-
property({ type: String })
|
|
1674
|
-
], OrMwcInput.prototype, "icon", void 0);
|
|
1675
|
-
__decorate([
|
|
1676
|
-
property({ type: String })
|
|
1677
|
-
], OrMwcInput.prototype, "iconColor", void 0);
|
|
1678
|
-
__decorate([
|
|
1679
|
-
property({ type: String })
|
|
1680
|
-
], OrMwcInput.prototype, "iconOn", void 0);
|
|
1681
|
-
__decorate([
|
|
1682
|
-
property({ type: String })
|
|
1683
|
-
], OrMwcInput.prototype, "iconTrailing", void 0);
|
|
1684
|
-
__decorate([
|
|
1685
|
-
property({ type: Boolean })
|
|
1686
|
-
], OrMwcInput.prototype, "compact", void 0);
|
|
1687
|
-
__decorate([
|
|
1688
|
-
property({ type: Boolean })
|
|
1689
|
-
], OrMwcInput.prototype, "comfortable", void 0);
|
|
1690
|
-
__decorate([
|
|
1691
|
-
property({ type: Boolean })
|
|
1692
|
-
], OrMwcInput.prototype, "raised", void 0);
|
|
1693
|
-
__decorate([
|
|
1694
|
-
property({ type: Boolean })
|
|
1695
|
-
], OrMwcInput.prototype, "action", void 0);
|
|
1696
|
-
__decorate([
|
|
1697
|
-
property({ type: Boolean })
|
|
1698
|
-
], OrMwcInput.prototype, "unElevated", void 0);
|
|
1699
|
-
__decorate([
|
|
1700
|
-
property({ type: Boolean })
|
|
1701
|
-
], OrMwcInput.prototype, "outlined", void 0);
|
|
1702
|
-
__decorate([
|
|
1703
|
-
property({ type: Boolean })
|
|
1704
|
-
], OrMwcInput.prototype, "rounded", void 0);
|
|
1705
|
-
__decorate([
|
|
1706
|
-
property({ type: Object })
|
|
1707
|
-
], OrMwcInput.prototype, "format", void 0);
|
|
1708
|
-
__decorate([
|
|
1709
|
-
property({ type: Boolean })
|
|
1710
|
-
], OrMwcInput.prototype, "disableSliderNumberInput", void 0);
|
|
1711
|
-
__decorate([
|
|
1712
|
-
property({ type: Boolean })
|
|
1713
|
-
], OrMwcInput.prototype, "fullWidth", void 0);
|
|
1714
|
-
__decorate([
|
|
1715
|
-
property({ type: String })
|
|
1716
|
-
], OrMwcInput.prototype, "helperText", void 0);
|
|
1717
|
-
__decorate([
|
|
1718
|
-
property({ type: Boolean })
|
|
1719
|
-
], OrMwcInput.prototype, "helperPersistent", void 0);
|
|
1720
|
-
__decorate([
|
|
1721
|
-
property({ type: String, attribute: true })
|
|
1722
|
-
], OrMwcInput.prototype, "validationMessage", void 0);
|
|
1723
|
-
__decorate([
|
|
1724
|
-
property({ type: Boolean })
|
|
1725
|
-
], OrMwcInput.prototype, "autoValidate", void 0);
|
|
1726
|
-
__decorate([
|
|
1727
|
-
property({ type: Boolean })
|
|
1728
|
-
], OrMwcInput.prototype, "charCounter", void 0);
|
|
1729
|
-
__decorate([
|
|
1730
|
-
property({ type: String })
|
|
1731
|
-
], OrMwcInput.prototype, "label", void 0);
|
|
1732
|
-
__decorate([
|
|
1733
|
-
property({ type: Boolean })
|
|
1734
|
-
], OrMwcInput.prototype, "disabled", void 0);
|
|
1735
|
-
__decorate([
|
|
1736
|
-
property({ type: Boolean })
|
|
1737
|
-
], OrMwcInput.prototype, "continuous", void 0);
|
|
1738
|
-
__decorate([
|
|
1739
|
-
property({ type: Boolean })
|
|
1740
|
-
], OrMwcInput.prototype, "resizeVertical", void 0);
|
|
1741
|
-
__decorate([
|
|
1742
|
-
property({ type: Boolean })
|
|
1743
|
-
], OrMwcInput.prototype, "censored", void 0);
|
|
1744
|
-
__decorate([
|
|
1745
|
-
property({ type: Boolean, reflect: true })
|
|
1746
|
-
], OrMwcInput.prototype, "advertised", void 0);
|
|
1747
|
-
__decorate([
|
|
1748
|
-
state()
|
|
1749
|
-
], OrMwcInput.prototype, "isUiValid", void 0);
|
|
1750
|
-
__decorate([
|
|
1751
|
-
state()
|
|
1752
|
-
], OrMwcInput.prototype, "searchableValue", void 0);
|
|
1753
|
-
__decorate([
|
|
1754
|
-
state()
|
|
1755
|
-
], OrMwcInput.prototype, "errorMessage", void 0);
|
|
1756
|
-
OrMwcInput = __decorate([
|
|
1757
|
-
customElement("or-mwc-input")
|
|
1758
|
-
], OrMwcInput);
|
|
1759
|
-
export { OrMwcInput };
|
|
1760
|
-
//# sourceMappingURL=or-mwc-input.js.map
|
|
1
|
+
var __decorate=this&&this.__decorate||function(e,t,i,a){var n,s=arguments.length,o=s<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,i):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,a);else for(var l=e.length-1;l>=0;l--)(n=e[l])&&(o=(s<3?n(o):s>3?n(t,i,o):n(t,i))||o);return s>3&&o&&Object.defineProperty(t,i,o),o},__awaiter=this&&this.__awaiter||function(e,t,i,a){return new(i||(i=Promise))(function(n,s){function o(e){try{d(a.next(e))}catch(e){s(e)}}function l(e){try{d(a.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?n(e.value):((t=e.value)instanceof i?t:new i(function(e){e(t)})).then(o,l)}d((a=a.apply(e,t||[])).next())})};import{css as e,html as t,LitElement as i,unsafeCSS as a}from"lit";import{customElement as n,property as s,state as o}from"lit/decorators.js";import{ref as l,createRef as d}from"lit/directives/ref.js";import{classMap as r}from"lit/directives/class-map.js";import{ifDefined as c}from"lit/directives/if-defined.js";import{when as p}from"lit/directives/when.js";import{until as u}from"lit/directives/until.js";import{MDCTextField as m}from"@material/textfield";import{MDCRipple as h}from"@material/ripple";import{MDCCheckbox as y}from"@material/checkbox";import{MDCSwitch as v}from"@material/switch";import{MDCSlider as _}from"@material/slider";import{MDCSelect as b}from"@material/select";import{MDCList as T}from"@material/list";import{MDCFormField as f}from"@material/form-field";import{MDCIconButtonToggle as I}from"@material/icon-button";import{DefaultColor4 as g,DefaultColor5 as x,DefaultColor8 as O,Util as w}from"@openremote/core";import"@openremote/or-icon";import{getItemTemplate as E,getListTemplate as $,ListType as C}from"./or-mwc-list";import{i18next as S}from"@openremote/or-translate";import{styleMap as M}from"lit/directives/style-map.js";let buttonStyle=require("@material/button/dist/mdc.button.css"),buttonFabStyle=require("@material/fab/dist/mdc.fab.css"),iconButtonStyle=require("@material/icon-button/dist/mdc.icon-button.css"),textfieldStyle=require("@material/textfield/dist/mdc.textfield.css"),rippleStyle=require("@material/ripple/dist/mdc.ripple.css"),lineRippleStyle=require("@material/line-ripple/dist/mdc.line-ripple.css"),floatingLabelStyle=require("@material/floating-label/dist/mdc.floating-label.css"),formFieldStyle=require("@material/form-field/dist/mdc.form-field.css"),checkboxStyle=require("@material/checkbox/dist/mdc.checkbox.css"),radioStyle=require("@material/radio/dist/mdc.radio.css"),switchStyle=require("@material/switch/dist/mdc.switch.css"),selectStyle=require("@material/select/dist/mdc.select.css"),listStyle=require("@material/list/dist/mdc.list.css"),menuSurfaceStyle=require("@material/menu-surface/dist/mdc.menu-surface.css"),menuStyle=require("@material/menu/dist/mdc.menu.css"),sliderStyle=require("@material/slider/dist/mdc.slider.css");export class OrInputChangedEvent extends CustomEvent{constructor(e,t,i){super(OrInputChangedEvent.NAME,{detail:{value:e,previousValue:t,enterPressed:i},bubbles:!0,composed:!0})}}OrInputChangedEvent.NAME="or-mwc-input-changed";export var InputType;function inputTypeSupportsButton(e){return e===InputType.NUMBER||e===InputType.BIG_INT||e===InputType.TELEPHONE||e===InputType.TEXT||e===InputType.PASSWORD||e===InputType.DATE||e===InputType.DATETIME||e===InputType.EMAIL||e===InputType.JSON||e===InputType.JSON_OBJECT||e===InputType.MONTH||e===InputType.TEXTAREA||e===InputType.TIME||e===InputType.URL||e===InputType.WEEK}function inputTypeSupportsHelperText(e){return inputTypeSupportsButton(e)||e===InputType.SELECT}function inputTypeSupportsLabel(e){return inputTypeSupportsHelperText(e)||e===InputType.CHECKBOX||e===InputType.BUTTON_MOMENTARY}!function(e){e.BUTTON="button",e.BUTTON_TOGGLE="button-toggle",e.BUTTON_MOMENTARY="button-momentary",e.CHECKBOX="checkbox",e.CHECKBOX_LIST="checkbox-list",e.COLOUR="color",e.DATE="date",e.DATETIME="datetime-local",e.EMAIL="email",e.JSON="json",e.JSON_OBJECT="json-object",e.MONTH="month",e.NUMBER="number",e.BIG_INT="big-int",e.PASSWORD="password",e.RADIO="radio",e.SWITCH="switch",e.RANGE="range",e.TELEPHONE="tel",e.TEXT="text",e.TEXTAREA="textarea",e.TIME="time",e.URL="url",e.WEEK="week",e.SELECT="select",e.LIST="list",e.CRON="cron",e.DURATION="duration",e.DURATION_TIME="duration-time",e.DURATION_PERIOD="duration-period"}(InputType||(InputType={}));export const getValueHolderInputTemplateProvider=(e,i,a,n,s,o)=>{let r,c,p,u,m,h,y,v,_=o.inputType,b={},T="string"==typeof e?e:e.name,f=(i&&i.meta||n&&n.meta?w.getAttributeValueConstraints(i,a,T):w.getMetaValueConstraints(i,a,T))||[],I=i&&i.meta||n&&n.meta?w.getAttributeValueFormat(i,a,T):w.getMetaValueFormat(i,a,T);if(!_){switch(n.name){case"text":case"email":case"UUID":case"assetID":case"hostOrIPAddress":case"IPAddress":_=!0===w.getMetaValue("multiline",i,a)?InputType.TEXTAREA:InputType.TEXT;break;case"boolean":if(I&&I.asNumber){_=InputType.NUMBER,r=1,p=0,u=1,v=e=>!!e;break}_=I&&(I.asOnOff||I.asOpenClosed)?InputType.SWITCH:InputType.CHECKBOX,(I&&I.asMomentary||!0===w.getMetaValue("momentary",i,a))&&(_=InputType.BUTTON_MOMENTARY);break;case"bigNumber":case"number":case"positiveInteger":case"positiveNumber":case"long":case"integer":case"byte":case"integerByte":case"direction":case"TCP_IPPortNumber":"byte"===n.name||"integerByte"===n.name?(p=0,u=255,r=1):("integer"===n.name||"long"===n.name)&&(r=1),I&&I.asDate?_=InputType.DATETIME:I&&I.asBoolean?(_=InputType.CHECKBOX,v=e=>+!!e):_=I&&I.asSlider?InputType.RANGE:InputType.NUMBER;break;case"bigInteger":_=InputType.BIG_INT,r=1;break;case"colourRGB":_=InputType.COLOUR;break;case"dateAndTime":case"timestamp":case"timestampISO8601":_=InputType.DATETIME;break;case"CRONExpression":_=InputType.CRON;break;case"timeDurationISO8601":_=InputType.DURATION_TIME;break;case"periodDurationISO8601":_=InputType.DURATION_PERIOD;break;case"timeAndPeriodDurationISO8601":_=InputType.DURATION;break;case"JSONObject":_=InputType.JSON_OBJECT}n.arrayDimensions&&n.arrayDimensions>0&&(_=InputType.JSON)}if(!_)switch(n.jsonType){case"number":case"bigint":_=InputType.NUMBER;break;case"boolean":_=InputType.CHECKBOX;break;case"string":_=InputType.TEXT;break;case"date":_=InputType.DATETIME}_||(_=InputType.JSON);let g=f&&f.find(e=>"size"===e.type),x=f&&f.find(e=>"pattern"===e.type),O=f&&f.find(e=>"min"===e.type),E=f&&f.find(e=>"max"===e.type),$=f&&f.find(e=>"allowedValues"===e.type),C=f&&f.find(e=>"past"===e.type),S=f&&f.find(e=>"pastOrPresent"===e.type),N=f&&f.find(e=>"future"===e.type),k=f&&f.find(e=>"futureOrPresent"===e.type),A=f&&f.find(e=>"notEmpty"===e.type),B=f&&f.find(e=>"notBlank"===e.type),V=f&&f.find(e=>"notNull"===e.type);if(g&&(p=g.min,u=g.max),g&&(p=g.min,u=g.max),O&&(p=O.min),E&&(u=E.max),x&&(c=x.regexp),V&&(h=!0),B&&!c?c="\\S+":A&&!c&&(c=".+"),$&&$.allowedValues){let e=$.allowedValueNames&&$.allowedValueNames.length===$.allowedValues.length?$.allowedValueNames:void 0;y=$.allowedValues.map((t,i)=>{let a=e?e[i]:""+t;return[t,(a=w.getAllowedValueLabel(a))||""+t]}),_=InputType.SELECT,n.arrayDimensions&&n.arrayDimensions>0&&(m=!0)}_===InputType.DATETIME&&(C||S?(p=void 0,u=new Date):(N||k)&&(p=new Date,u=void 0),I&&(I.timeStyle&&!I.dateStyle?_=InputType.TIME:I.dateStyle&&!I.timeStyle&&(_=InputType.DATE))),_===InputType.NUMBER&&I&&I.resolution&&(r=I.resolution),_===InputType.COLOUR&&(b.marginLeft="24px");let R=inputTypeSupportsHelperText(_),D=inputTypeSupportsLabel(_),L=inputTypeSupportsButton(_),P=o.readonly;h=h||o.required;let U=o.comfortable,J=o.resizeVertical,q=d();return{templateFunction:(e,i,a,n,d,T)=>{let f=o.disabled||a||n,g=D?o.label:void 0;return t`<or-mwc-input ${l(q)} id="input" style="${M(b)}" .type="${_}" .label="${g}" .value="${e}" .pattern="${c}"
|
|
2
|
+
.min="${p}" .max="${u}" .format="${I}" .focused="${i}" .required="${h}" .multiple="${m}"
|
|
3
|
+
.options="${y}" .comfortable="${U}" .readonly="${P}" .disabled="${f}" .step="${r}"
|
|
4
|
+
.helperText="${T}" .helperPersistent="${!0}" .resizeVertical="${J}"
|
|
5
|
+
.rounded="${o.rounded}"
|
|
6
|
+
.outlined="${o.outlined}"
|
|
7
|
+
@or-mwc-input-changed="${e=>{e.stopPropagation(),e.detail.value=v?v(e.detail.value):e.detail.value,s(e.detail)}}"></or-mwc-input>`},supportsHelperText:R,supportsSendButton:L,supportsLabel:D,validator:()=>!!q.value&&q.value.checkValidity()}};let style=e`
|
|
8
|
+
|
|
9
|
+
:host {
|
|
10
|
+
display: inline-block;
|
|
11
|
+
--internal-or-mwc-input-color: var(--or-mwc-input-color, var(--or-app-color4, ${a(g)}));
|
|
12
|
+
--internal-or-mwc-input-text-color: var(--or-mwc-input-text-color, var(--or-app-color8, ${a(O)}));
|
|
13
|
+
|
|
14
|
+
--mdc-theme-primary: var(--internal-or-mwc-input-color);
|
|
15
|
+
--mdc-theme-on-primary: var(--internal-or-mwc-input-text-color);
|
|
16
|
+
--mdc-theme-secondary: var(--internal-or-mwc-input-color);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
:host([hidden]) {
|
|
20
|
+
display: none;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
:host([type=select]) {
|
|
24
|
+
height: 56px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
#wrapper {
|
|
28
|
+
display: flex;
|
|
29
|
+
align-items: center;
|
|
30
|
+
min-height: 48px;
|
|
31
|
+
height: 100%;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
#wrapper > label {
|
|
35
|
+
white-space: nowrap;
|
|
36
|
+
margin-right: 20px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
#component {
|
|
40
|
+
max-width: 100%;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.mdc-text-field {
|
|
44
|
+
flex: 1 1 0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.mdc-list {
|
|
48
|
+
flex: 1;
|
|
49
|
+
overflow: auto;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.mdc-select__anchor {
|
|
53
|
+
max-width: 100%;
|
|
54
|
+
width: 100%;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.mdc-checkbox-list input {
|
|
58
|
+
display: none;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.mdc-checkbox-list label {
|
|
62
|
+
display: block;
|
|
63
|
+
border-radius: 50%;
|
|
64
|
+
text-align: center;
|
|
65
|
+
width: 32px;
|
|
66
|
+
line-height: 32px;
|
|
67
|
+
height: 32px;
|
|
68
|
+
cursor: pointer;
|
|
69
|
+
background-color: var(--or-app-color2);
|
|
70
|
+
font-size: 13px;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
input::-webkit-calendar-picker-indicator {
|
|
74
|
+
margin: 0;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.mdc-checkbox-list .mdc-checkbox {
|
|
78
|
+
padding: 0;
|
|
79
|
+
height: 32px;
|
|
80
|
+
width: 32px;
|
|
81
|
+
}
|
|
82
|
+
.mdc-radio-container {
|
|
83
|
+
display: flex;
|
|
84
|
+
flex-direction: column;
|
|
85
|
+
}
|
|
86
|
+
.mdc-text-field.mdc-text-field--invalid:not(.mdc-text-field--disabled) + .mdc-text-field-helper-line .mdc-text-field-helper-text {
|
|
87
|
+
color: var(--mdc-theme-error, #b00020)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.mdc-checkbox-list input:checked + label {
|
|
91
|
+
color: var(--or-app-color2);
|
|
92
|
+
background-color: var(--mdc-theme-primary);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.mdc-button--rounded,
|
|
96
|
+
.or-mwc-input--rounded {
|
|
97
|
+
border-radius: 24px !important;
|
|
98
|
+
--mdc-shape-small: 32px;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
#select-searchable {
|
|
102
|
+
background-color: transparent;
|
|
103
|
+
border: 1px solid var(--or-app-color5, ${a(x)});
|
|
104
|
+
margin: 8px;
|
|
105
|
+
width: calc(100% - 16px);
|
|
106
|
+
border-radius: 4px;
|
|
107
|
+
padding: 4px 16px;
|
|
108
|
+
flex: 0 0 auto;
|
|
109
|
+
align-items: center;
|
|
110
|
+
height: auto;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.mdc-text-field__input::-webkit-calendar-picker-indicator {
|
|
114
|
+
display: block;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
::-webkit-clear-button {display: none;}
|
|
118
|
+
::-webkit-inner-spin-button { display: none; }
|
|
119
|
+
::-webkit-datetime-edit { padding: 0em; }
|
|
120
|
+
::-webkit-datetime-edit-text { padding: 0; }
|
|
121
|
+
|
|
122
|
+
.mdc-text-field--focused:not(.mdc-text-field--disabled) .mdc-floating-label {
|
|
123
|
+
color: var(--mdc-theme-primary);
|
|
124
|
+
}
|
|
125
|
+
.mdc-text-field--focused .mdc-text-field__input:required ~ .mdc-floating-label::after,
|
|
126
|
+
.mdc-text-field--focused .mdc-text-field__input:required ~ .mdc-notched-outline .mdc-floating-label::after {
|
|
127
|
+
color: var(--mdc-theme-primary);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.mdc-text-field__input.resize-vertical {
|
|
131
|
+
resize: vertical;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.mdc-text-field, .mdc-text-field-helper-line {
|
|
135
|
+
width: 100%;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.mdc-text-field.dense-comfortable, .mdc-select.dense-comfortable {
|
|
139
|
+
height: 48px;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.mdc-text-field.dense-compact {
|
|
143
|
+
height: 36px;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.mdc-select:not(.mdc-list) {
|
|
147
|
+
white-space: nowrap;
|
|
148
|
+
display: flex;
|
|
149
|
+
flex-direction: column;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.mdc-select:not(.mdc-select--disabled).mdc-select--focused .mdc-floating-label {
|
|
153
|
+
color: var(--mdc-theme-primary);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.mdc-select-helper-text {
|
|
157
|
+
white-space: normal;
|
|
158
|
+
color: rgba(0, 0, 0, 0.6);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.mdc-icon-button {
|
|
162
|
+
padding: 0;
|
|
163
|
+
color: var(--internal-or-mwc-input-color);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/* Give slider min width like select etc. */
|
|
167
|
+
.mdc-slider {
|
|
168
|
+
min-width: 200px;
|
|
169
|
+
flex: 1;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.mdc-switch {
|
|
173
|
+
margin: 0 24px;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.mdc-switch--full-width {
|
|
177
|
+
margin-left: auto;
|
|
178
|
+
}
|
|
179
|
+
.mdc-button--fullwidth {
|
|
180
|
+
width: 100%;
|
|
181
|
+
}
|
|
182
|
+
#field {
|
|
183
|
+
height: 100%;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.mdc-select__menu .mdc-list .mdc-list-item.mdc-list-item--selected or-icon {
|
|
187
|
+
--or-icon-fill: var(--or-app-color4);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
.mdc-menu__searchable {
|
|
191
|
+
overflow: hidden;
|
|
192
|
+
}
|
|
193
|
+
.mdc-menu__searchable.mdc-menu-surface--open {
|
|
194
|
+
display: flex;
|
|
195
|
+
flex-direction: column-reverse;
|
|
196
|
+
}
|
|
197
|
+
.mdc-menu__searchable.mdc-menu-surface--is-open-below {
|
|
198
|
+
flex-direction: column;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/* Prevent mouse events being fired from inside the or-icon shadowDOM */
|
|
202
|
+
.mdc-list-item__graphic > or-icon {
|
|
203
|
+
pointer-events: none;
|
|
204
|
+
}
|
|
205
|
+
`,OrMwcInput=class extends i{constructor(){super(...arguments),this.readonly=!1,this.required=!1,this.checked=!1,this.indeterminate=!1,this.multiple=!1,this.searchLabel="search",this.compact=!1,this.comfortable=!1,this.raised=!1,this.action=!1,this.unElevated=!1,this.outlined=!1,this.rounded=!1,this.disableSliderNumberInput=!1,this.fullWidth=!1,this.helperPersistent=!1,this.autoValidate=!1,this.charCounter=!1,this.disabled=!1,this.continuous=!1,this.resizeVertical=!1,this.censored=!1,this.advertised=!1,this._selectedIndex=-1,this.isUiValid=!0}static get styles(){return[e`${a(iconButtonStyle)}`,e`${a(buttonStyle)}`,e`${a(buttonFabStyle)}`,e`${a(textfieldStyle)}`,e`${a(rippleStyle)}`,e`${a(lineRippleStyle)}`,e`${a(floatingLabelStyle)}`,e`${a(formFieldStyle)}`,e`${a(checkboxStyle)}`,e`${a(radioStyle)}`,e`${a(switchStyle)}`,e`${a(selectStyle)}`,e`${a(listStyle)}`,e`${a(menuStyle)}`,e`${a(menuSurfaceStyle)}`,e`${a(sliderStyle)}`,style]}get nativeValue(){if(this._mdcComponent)return this._mdcComponent.value}disconnectedCallback(){var e,t;super.disconnectedCallback(),this._mdcComponent&&(this._mdcComponent.destroy(),this._mdcComponent=void 0,null==(e=this._menuObserver)||e.disconnect()),this._mdcComponent2&&(this._mdcComponent2.destroy(),this._mdcComponent2=void 0,null==(t=this._menuObserver)||t.disconnect())}shouldUpdate(e){return e.has("indeterminate")&&this._mdcComponent&&this.type===InputType.CHECKBOX&&(this._mdcComponent.indeterminate=this.indeterminate),e.has("disabled")&&(this._mdcComponent&&(this._mdcComponent.disabled=this.disabled),this.type===InputType.RANGE&&this._mdcComponent2&&(this._mdcComponent2.disabled=this.disabled)),e.has("readonly")&&(this._mdcComponent&&(this._mdcComponent.readonly=this.readonly),this.type===InputType.RANGE&&this._mdcComponent2&&(this._mdcComponent2.readonly=this.readonly)),!this.type&&this.value&&(this.value instanceof Date?this.type=InputType.DATETIME:"boolean"==typeof this.value?this.type=InputType.CHECKBOX:"number"==typeof this.value?this.type=InputType.NUMBER:"string"==typeof this.value?this.type=InputType.TEXT:this.type=InputType.JSON),!0}focus(){this.type===InputType.RANGE&&this._mdcComponent2?this._mdcComponent2.focus():this._mdcComponent&&"function"==typeof this._mdcComponent.focus&&this._mdcComponent.focus()}render(){if(this.type){let e=!this.fullWidth&&this.label,i=!this.fullWidth&&this.outlined,a=!!this.helperText,n=!this.isUiValid&&(!!this.errorMessage||!!this.validationMessage),s={"mdc-text-field-helper-text--persistent":!n&&this.helperPersistent,"mdc-text-field-helper-text--validation-msg":n},o=null!==this.value&&void 0!==this.value||!1===this.value,l=e?t`<span class="mdc-floating-label ${o?"mdc-floating-label--float-above":""}" id="label">${this.label}</span>`:void 0;switch(this.type){case InputType.RADIO:let d=this.resolveOptions(this.options);return this._selectedIndex=-1,t`
|
|
206
|
+
<div class="mdc-radio-container">
|
|
207
|
+
${d?d.map(([e,i],a)=>(this.value===e&&(this._selectedIndex=a),t`
|
|
208
|
+
<div id="field" class="mdc-form-field">
|
|
209
|
+
<div class="mdc-radio">
|
|
210
|
+
<input type="radio"
|
|
211
|
+
id="elem-${e}"
|
|
212
|
+
name="${c(this.name)}"
|
|
213
|
+
value="${e}"
|
|
214
|
+
?checked="${this.value&&this.value.includes(e)}"
|
|
215
|
+
?required="${this.required}"
|
|
216
|
+
?disabled="${this.disabled||this.readonly}"
|
|
217
|
+
@change="${t=>this.onValueChange(t.target,e)}"
|
|
218
|
+
class="mdc-radio__native-control"/>
|
|
219
|
+
<div class="mdc-radio__background">
|
|
220
|
+
<div class="mdc-radio__outer-circle"></div>
|
|
221
|
+
<div class="mdc-radio__inner-circle"></div>
|
|
222
|
+
</div>
|
|
223
|
+
<div class="mdc-radio__ripple"></div>
|
|
224
|
+
</div>
|
|
225
|
+
<label for="elem-${e}"><or-translate value="${i}"></or-translate></label>
|
|
226
|
+
</div>
|
|
227
|
+
|
|
228
|
+
`)):""}
|
|
229
|
+
</div>
|
|
230
|
+
`;case InputType.SWITCH:let m={"mdc-switch--disabled":this.disabled||this.readonly,"mdc-switch--full-width":this.fullWidth,"mdc-switch--checked":this.value};return t`
|
|
231
|
+
<span id="wrapper">
|
|
232
|
+
${this.label?t`<label for="elem" class="${this.disabled?"mdc-switch--disabled":""}">${this.label}</label>`:""}
|
|
233
|
+
<div id="component" class="mdc-switch ${r(m)}">
|
|
234
|
+
<div class="mdc-switch__track"></div>
|
|
235
|
+
<div class="mdc-switch__thumb-underlay">
|
|
236
|
+
<div class="mdc-switch__thumb">
|
|
237
|
+
<input type="checkbox" id="elem" class="mdc-switch__native-control"
|
|
238
|
+
?checked="${this.value}"
|
|
239
|
+
?required="${this.required}"
|
|
240
|
+
?disabled="${this.disabled||this.readonly}"
|
|
241
|
+
@change="${e=>this.onValueChange(e.target,e.target.checked)}"
|
|
242
|
+
role="switch">
|
|
243
|
+
</div>
|
|
244
|
+
</div>
|
|
245
|
+
</div>
|
|
246
|
+
</span>
|
|
247
|
+
`;case InputType.LIST:let h={"mdc-select--outlined":i,"mdc-select--disabled":this.disabled,"mdc-select--required":this.required,"mdc-select--dense":!1,"mdc-select--no-label":!this.label,"mdc-select--with-leading-icon":!!this.icon},y=this.resolveOptions(this.options);return this._selectedIndex=-1,t`
|
|
248
|
+
<div id="component" class="mdc-list mdc-select ${r(h)}" @MDCList:action="${e=>this.onValueChange(void 0,-1===e.detail.index?void 0:Array.isArray(this.options[e.detail.index])?this.options[e.detail.index][0]:this.options[e.detail.index])}">
|
|
249
|
+
<ul class="mdc-list">
|
|
250
|
+
${y?y.map(([e,i],a)=>(this.value===e&&(this._selectedIndex=a),t`<li class="${r({"mdc-list-item":!0,"mdc-list-item--selected":this.value===e})}" role="option" data-value="${e}"><or-translate value="${i}"></or-translate></li>`)):""}
|
|
251
|
+
</ul>
|
|
252
|
+
</div>
|
|
253
|
+
`;case InputType.SELECT:let v,_={"mdc-select--outlined":i,"mdc-select--filled":!i,"mdc-select--disabled":this.disabled||this.readonly,"mdc-select--required":this.required,"mdc-select--dense":!1,"dense-comfortable":this.comfortable,"mdc-select--no-label":!this.label,"mdc-select--with-leading-icon":!!this.icon,"or-mwc-input--rounded":this.rounded};v=void 0!=this.searchProvider?this.searchProvider(this.searchableValue):this.resolveOptions(this.options);let b=(e,t)=>{var i;let a=t.value;if(this.multiple){e.stopPropagation();let t=null!=(i=this._tempValue)?i:Array.isArray(this.value)?[...this.value]:void 0!==this.value?[this.value]:[],n=t.findIndex(e=>e===a);n>=0?t.splice(n,1):t.push(a);let s=e.composedPath()[0].closest("li"),o=s.getElementsByTagName("or-icon")[0];s&&(n>=0?s.classList.remove("mdc-list-item--selected"):s.classList.add("mdc-list-item--selected")),o&&(o.icon=n>=0?"checkbox-blank-outline":"checkbox-marked"),this._tempValue=t}else void 0==this.searchProvider&&Array.isArray(v)||this.onValueChange(void 0,t.value)},T=e=>void 0==this.searchProvider||e&&0!=e.length?$(this.multiple?C.MULTI_TICK:C.SELECT,t`${null==e?void 0:e.map(([e,t],i)=>E({text:t,value:e},i,Array.isArray(this.value)?this.value:this.value?[this.value]:[],this.multiple?C.MULTI_TICK:C.SELECT,!1,b))}`,!1,void 0):t`<span class="mdc-text-field-helper-line" style="margin: 8px 8px 8px 0;">${S.t("noResults")}</span>`;return t`
|
|
254
|
+
<div id="component"
|
|
255
|
+
class="mdc-select ${r(_)}"
|
|
256
|
+
@MDCSelect:change="${e=>__awaiter(this,void 0,void 0,function*(){let t=Array.isArray(v)?v:yield v;this.onValueChange(void 0,-1===e.detail.index?void 0:Array.isArray(t[e.detail.index])?t[e.detail.index][0]:t[e.detail.index])})}">
|
|
257
|
+
<div class="mdc-select__anchor" role="button"
|
|
258
|
+
aria-haspopup="listbox"
|
|
259
|
+
aria-expanded="false"
|
|
260
|
+
aria-disabled="${""+(this.disabled||this.readonly)}"
|
|
261
|
+
aria-labelledby="label selected-text">
|
|
262
|
+
${!i?t`<span class="mdc-select__ripple"></span>`:void 0}
|
|
263
|
+
${i?this.renderOutlined(l):l}
|
|
264
|
+
<span class="mdc-select__selected-text-container">
|
|
265
|
+
<span id="selected-text" class="mdc-select__selected-text"></span>
|
|
266
|
+
</span>
|
|
267
|
+
<span class="mdc-select__dropdown-icon">
|
|
268
|
+
<svg
|
|
269
|
+
class="mdc-select__dropdown-icon-graphic"
|
|
270
|
+
viewBox="7 10 10 5">
|
|
271
|
+
<polygon
|
|
272
|
+
class="mdc-select__dropdown-icon-inactive"
|
|
273
|
+
stroke="none"
|
|
274
|
+
fill-rule="evenodd"
|
|
275
|
+
points="7 10 12 15 17 10">
|
|
276
|
+
</polygon>
|
|
277
|
+
<polygon
|
|
278
|
+
class="mdc-select__dropdown-icon-active"
|
|
279
|
+
stroke="none"
|
|
280
|
+
fill-rule="evenodd"
|
|
281
|
+
points="7 15 12 10 17 15">
|
|
282
|
+
</polygon>
|
|
283
|
+
</svg>
|
|
284
|
+
</span>
|
|
285
|
+
${!i?t`<div class="mdc-line-ripple"></div>`:""}
|
|
286
|
+
</div>
|
|
287
|
+
<div id="mdc-select-menu" class="mdc-select__menu mdc-menu mdc-menu-surface mdc-menu-surface--fixed ${void 0!=this.searchProvider?"mdc-menu__searchable":void 0}" @MDCMenuSurface:closed="${()=>{var e;let t=null!=(e=this._tempValue)?e:this.value;if(window.setTimeout(()=>{this._mdcComponent&&this._mdcComponent.foundation.adapter.floatLabel(t&&(!Array.isArray(t)||t.length>0))}),!this._tempValue)return;let i=[...this._tempValue];this._tempValue=void 0,this.onValueChange(void 0,i)}}">
|
|
288
|
+
${p(void 0!=this.searchProvider,()=>t`
|
|
289
|
+
<label id="select-searchable" class="mdc-text-field mdc-text-field--filled">
|
|
290
|
+
<span class="mdc-floating-label" style="color: rgba(0, 0, 0, 0.6); text-transform: capitalize; visibility: ${this.searchableValue?"hidden":"visible"}" id="my-label-id">
|
|
291
|
+
<or-translate .value="${this.searchLabel}"></or-translate>
|
|
292
|
+
</span>
|
|
293
|
+
<input class="mdc-text-field__input" type="text"
|
|
294
|
+
@keyup="${e=>this.searchableValue=e.target.value}"
|
|
295
|
+
/>
|
|
296
|
+
</label>
|
|
297
|
+
`)}
|
|
298
|
+
${p(Array.isArray(v),()=>T(v),()=>u(new Promise(e=>__awaiter(this,void 0,void 0,function*(){e(T((yield v)))})),t`<span class="mdc-text-field-helper-line" style="margin: 8px 8px 8px 0;">${S.t("loading")}</span>`))}
|
|
299
|
+
</div>
|
|
300
|
+
${a||n?t`
|
|
301
|
+
<p id="component-helper-text" class="mdc-select-helper-text ${r(s)}" aria-hidden="true">
|
|
302
|
+
${n?this.errorMessage||this.validationMessage:this.helperText}
|
|
303
|
+
</p>`:""}
|
|
304
|
+
</div>
|
|
305
|
+
`;case InputType.BUTTON_TOGGLE:return t`
|
|
306
|
+
<button id="component" class="mdc-icon-button ${this.value?"mdc-icon-button--on":""}"
|
|
307
|
+
?readonly="${this.readonly}"
|
|
308
|
+
?disabled="${this.disabled}"
|
|
309
|
+
@MDCIconButtonToggle:change="${e=>this.onValueChange(void 0,e.detail.isOn)}">
|
|
310
|
+
${this.icon?t`<or-icon class="mdc-icon-button__icon" aria-hidden="true" icon="${this.icon}"></or-icon>`:""}
|
|
311
|
+
${this.iconOn?t`<or-icon class="mdc-icon-button__icon mdc-icon-button__icon--on" aria-hidden="true" icon="${this.iconOn}"></or-icon>`:""}
|
|
312
|
+
</button>
|
|
313
|
+
`;case InputType.BUTTON:case InputType.BUTTON_MOMENTARY:{let e=this.type===InputType.BUTTON_MOMENTARY,i=!this.action&&!this.label;!i||this.iconTrailing||this.icon||(this.icon="circle");let a={"mdc-icon-button":i,"mdc-fab":!i&&this.action,"mdc-fab--extended":!i&&this.action&&!!this.label,"mdc-fab--mini":!i&&this.action&&(this.compact||this.comfortable),"mdc-button":!i&&!this.action,"mdc-button--raised":!i&&!this.action&&this.raised,"mdc-button--unelevated":!i&&!this.action&&this.unElevated,"mdc-button--outlined":!i&&!this.action&&(this.outlined||e),"mdc-button--rounded":!i&&!this.action&&this.rounded,"mdc-button--fullwidth":this.fullWidth};return t`
|
|
314
|
+
<button id="component" class="${r(a)}"
|
|
315
|
+
?readonly="${this.readonly}"
|
|
316
|
+
?disabled="${this.disabled}"
|
|
317
|
+
@click="${t=>{this.disabled&&t.stopPropagation(),!e&&this.dispatchEvent(new OrInputChangedEvent(!0,null))}}"
|
|
318
|
+
@mousedown="${t=>{this.disabled&&t.stopPropagation(),e&&this.dispatchEvent(new OrInputChangedEvent(!0,null))}}" @mouseup="${t=>{this.disabled&&t.stopPropagation(),e&&this.dispatchEvent(new OrInputChangedEvent(!1,!0))}}">
|
|
319
|
+
${!i?t`<div class="mdc-button__ripple"></div>`:""}
|
|
320
|
+
${this.icon?t`<or-icon class="${i?"":this.action?"mdc-fab__icon":"mdc-button__icon"}" aria-hidden="true" icon="${this.icon}"></or-icon>`:""}
|
|
321
|
+
${this.label?t`<span class="${this.action?"mdc-fab__label":"mdc-button__label"}"><or-translate .value="${this.label}"></or-translate></span>`:""}
|
|
322
|
+
${!i&&this.iconTrailing?t`<or-icon class="${this.action?"mdc-fab__icon":"mdc-button__icon"}" aria-hidden="true" icon="${this.iconTrailing}"></or-icon>`:""}
|
|
323
|
+
</button>
|
|
324
|
+
`}case InputType.CHECKBOX_LIST:Array.isArray(this.value)||(null===this.value||void 0===this.value?this.value=[]:this.value=[this.value]);let f=this.resolveOptions(this.options);return this._selectedIndex=-1,t`
|
|
325
|
+
<div class="mdc-checkbox-list">
|
|
326
|
+
${f?f.map(([e,i],a)=>(this.value===e&&(this._selectedIndex=a),t`
|
|
327
|
+
<div id="field" class="mdc-form-field">
|
|
328
|
+
<div id="component" class="mdc-checkbox">
|
|
329
|
+
<input type="checkbox"
|
|
330
|
+
?checked="${this.value&&this.value.includes(e)}"
|
|
331
|
+
?required="${this.required}"
|
|
332
|
+
name="${e}"
|
|
333
|
+
?disabled="${this.disabled||this.readonly}"
|
|
334
|
+
@change="${t=>{let i=this.value;t.target.checked?i.includes(e)||(i=[e,...i]):i=i.filter(t=>t!==e),this.onValueChange(t.target,i)}}"
|
|
335
|
+
class="mdc-checkbox__native-control" id="elem-${e}"/>
|
|
336
|
+
|
|
337
|
+
<label for="elem-${e}"><or-translate value="${i}"></or-translate></label>
|
|
338
|
+
|
|
339
|
+
</div>
|
|
340
|
+
</div>
|
|
341
|
+
|
|
342
|
+
`)):""}
|
|
343
|
+
</div>
|
|
344
|
+
`;case InputType.CHECKBOX:let I={"mdc-checkbox":!0,"mdc-checkbox--disabled":this.disabled||this.readonly};return t`
|
|
345
|
+
<div id="field" class="mdc-form-field">
|
|
346
|
+
<div id="component" class="${r(I)}">
|
|
347
|
+
<input type="checkbox"
|
|
348
|
+
id="elem"
|
|
349
|
+
data-indeterminate="${this.indeterminate}"
|
|
350
|
+
?checked="${this.value}"
|
|
351
|
+
?required="${this.required}"
|
|
352
|
+
?disabled="${this.disabled||this.readonly}"
|
|
353
|
+
@change="${e=>this.onValueChange(e.target,e.target.checked)}"
|
|
354
|
+
class="mdc-checkbox__native-control" />
|
|
355
|
+
<div class="mdc-checkbox__background">
|
|
356
|
+
<svg class="mdc-checkbox__checkmark" viewBox="0 0 24 24">
|
|
357
|
+
<path class="mdc-checkbox__checkmark-path" fill="none" d="M1.73,12.91 8.1,19.28 22.79,4.59"></path>
|
|
358
|
+
</svg>
|
|
359
|
+
<div class="mdc-checkbox__mixedmark"></div>
|
|
360
|
+
</div>
|
|
361
|
+
<div class="mdc-checkbox__ripple"></div>
|
|
362
|
+
</div>
|
|
363
|
+
<label class="mdc-checkbox-circle" for="elem">${this.label}</label>
|
|
364
|
+
</div>
|
|
365
|
+
`;case InputType.COLOUR:return t`
|
|
366
|
+
<div id="component" style="width: 100%; display: inline-flex; align-items: center; padding: 8px 0;">
|
|
367
|
+
<input type="color" id="elem" style="border: none; height: 31px; width: 31px; padding: 1px 3px; min-height: 22px; min-width: 30px;cursor: pointer" value="${this.value}"
|
|
368
|
+
?disabled="${this.disabled||this.readonly}"
|
|
369
|
+
?required="${this.required}"
|
|
370
|
+
@change="${e=>this.onValueChange(e.target,e.target.value)}"
|
|
371
|
+
/>
|
|
372
|
+
<label style="margin-left: 10px; cursor: pointer" for="elem">${this.label}</label>
|
|
373
|
+
</div>
|
|
374
|
+
`;case InputType.NUMBER:case InputType.RANGE:case InputType.DATE:case InputType.DATETIME:case InputType.TIME:case InputType.MONTH:case InputType.WEEK:case InputType.EMAIL:case InputType.PASSWORD:case InputType.TELEPHONE:case InputType.URL:case InputType.TEXT:case InputType.TEXTAREA:case InputType.JSON:case InputType.JSON_OBJECT:{let e,d=[void 0===this.value||null===this.value?void 0:this.value,this.min,this.max];if(d.some(e=>"string"!=typeof e))if(this.type===InputType.JSON||this.type===InputType.JSON_OBJECT)if(void 0!==d[0]){if("string"!=typeof d[0]||null===d[0])try{d[0]=JSON.stringify(d[0],null,2)}catch(e){console.warn("Failed to parse JSON expression for input control"),d[0]=""}}else d[0]="";else{let e=this.format?Object.assign({},this.format):{};switch(this.type){case InputType.TIME:e.asDate=!0,e.hour12=!1,e.timeStyle=this.step&&this.step<60?"medium":"short";break;case InputType.DATE:e.asDate=!0,e.momentJsFormat="YYYY-MM-DD";break;case InputType.WEEK:e.asDate=!0,e.momentJsFormat="YYYY-[W]WW";break;case InputType.MONTH:e.asDate=!0,e.momentJsFormat="YYYY-MM";break;case InputType.DATETIME:e.asDate=!0,e.momentJsFormat="YYYY-MM-DDTHH:mm";break;case InputType.NUMBER:null!=e.maximumFractionDigits||(e.maximumFractionDigits=20)}e.useGrouping=!1,d=d.map(t=>void 0!==t?w.getValueAsString(t,()=>e,"en-GB"):void 0)}let p=this.label,u=this.type,m="component";if(this.type===InputType.RANGE&&(p=void 0,i=!1,a=!1,u=InputType.NUMBER,m="number"),!(this.type===InputType.RANGE&&this.disableSliderNumberInput)){this.censored&&(u=InputType.PASSWORD),this.type===InputType.PASSWORD&&this.advertised&&(u=InputType.TEXT);let h={"mdc-text-field":!0,"mdc-text-field--invalid":!this.valid,"mdc-text-field--filled":!i,"mdc-text-field--outlined":i,"mdc-text-field--textarea":u===InputType.TEXTAREA||u===InputType.JSON||u===InputType.JSON_OBJECT,"mdc-text-field--disabled":this.disabled,"mdc-text-field--fullwidth":this.fullWidth&&!i,"dense-comfortable":this.comfortable&&u!==InputType.TEXTAREA&&u!==InputType.JSON&&u!==InputType.JSON_OBJECT,"dense-compact":!this.comfortable&&this.compact,"mdc-text-field--label-floating":o,"mdc-text-field--no-label":!this.label,"mdc-text-field--with-leading-icon":!!this.icon,"mdc-text-field--with-trailing-icon":!!this.iconTrailing,"or-mwc-input--rounded":this.rounded};e=u===InputType.TEXTAREA||u===InputType.JSON||u===InputType.JSON_OBJECT?t`
|
|
375
|
+
<textarea id="elem" class="mdc-text-field__input ${this.resizeVertical?"resize-vertical":""}" ?required="${this.required}"
|
|
376
|
+
?readonly="${this.readonly}" ?disabled="${this.disabled}" minlength="${c(this.minLength)}"
|
|
377
|
+
maxlength="${c(this.maxLength)}" rows="${this.rows?this.rows:5}"
|
|
378
|
+
cols="${c(this.cols)}" aria-label="${c(p)}"
|
|
379
|
+
aria-labelledby="${c(p?"label":void 0)}"
|
|
380
|
+
@change="${e=>this.onValueChange(e.target,e.target.value)}">${d[0]?d[0]:""}</textarea>`:t`
|
|
381
|
+
<input type="${u}" id="elem" aria-labelledby="${c(p?"label":void 0)}"
|
|
382
|
+
class="mdc-text-field__input" ?required="${this.required}" ?readonly="${this.readonly}"
|
|
383
|
+
?disabled="${this.disabled}" min="${c(d[1])}" max="${c(d[2])}"
|
|
384
|
+
step="${this.step?this.step:"any"}" minlength="${c(this.minLength)}" pattern="${c(this.pattern)}"
|
|
385
|
+
maxlength="${c(this.maxLength)}" placeholder="${c(this.placeHolder)}"
|
|
386
|
+
.value="${null!==d[0]&&void 0!==d[0]?d[0]:""}"
|
|
387
|
+
@keydown="${e=>{("Enter"===e.code||"NumpadEnter"===e.code)&&this.onValueChange(e.target,e.target.value,!0)}}"
|
|
388
|
+
@blur="${e=>{""===e.target.value&&this.reportValidity()}}"
|
|
389
|
+
@change="${e=>this.onValueChange(e.target,e.target.value)}" />`,e=t`
|
|
390
|
+
<label id="${m}" class="${r(h)}">
|
|
391
|
+
${this.icon?t`<or-icon class="mdc-text-field__icon mdc-text-field__icon--leading" style="color: ${this.iconColor?"#"+this.iconColor:"unset"}" aria-hidden="true" icon="${this.icon}"></or-icon>`:""}
|
|
392
|
+
${i?"":t`<span class="mdc-text-field__ripple"></span>`}
|
|
393
|
+
${e}
|
|
394
|
+
${i?this.renderOutlined(l):l}
|
|
395
|
+
${i?"":t`<span class="mdc-line-ripple"></span>`}
|
|
396
|
+
${this.type===InputType.PASSWORD&&!this.censored?t`<or-icon class="mdc-text-field__icon mdc-text-field__icon--trailing" aria-hidden="true" icon=${this.advertised?"eye":"eye-off"} style="pointer-events: auto;" @click=${()=>this.advertised=!this.advertised}></or-icon>`:""}
|
|
397
|
+
${this.iconTrailing?t`<or-icon class="mdc-text-field__icon mdc-text-field__icon--trailing" aria-hidden="true" icon="${this.iconTrailing}"></or-icon>`:""}
|
|
398
|
+
</label>
|
|
399
|
+
${a||n?t`
|
|
400
|
+
<div class="mdc-text-field-helper-line">
|
|
401
|
+
<div class="mdc-text-field-helper-text ${r(s)}">${n?this.errorMessage||this.validationMessage:this.helperText}</div>
|
|
402
|
+
${this.charCounter&&!this.readonly?t`<div class="mdc-text-field-character-counter"></div>`:""}
|
|
403
|
+
</div>
|
|
404
|
+
`:""}
|
|
405
|
+
`}if(this.type===InputType.RANGE){let i={"mdc-slider":!0,"mdc-slider--range":this.continuous,"mdc-slider--discreet":!this.continuous,"mdc-slider--disabled":this.disabled||this.readonly};e=t`
|
|
406
|
+
<span id="wrapper">
|
|
407
|
+
${this.label?t`<label for="component" class="${this.disabled?"mdc-switch--disabled":""}">${this.label}</label>`:""}
|
|
408
|
+
<div id="component" class="${r(i)}" @MDCSlider:change="${e=>this.onValueChange(void 0,e.detail.value)}">
|
|
409
|
+
<input id="elem" class="mdc-slider__input" type="range" min="${c(d[1])}" max="${c(d[2])}" value="${d[0]||d[1]||0}" name="slider" step="${this.step||1}" ?readonly="${this.readonly}" ?disabled="${this.disabled}" aria-label="${c(this.label)}" />
|
|
410
|
+
<div class="mdc-slider__track">
|
|
411
|
+
<div class="mdc-slider__track--inactive"></div>
|
|
412
|
+
<div class="mdc-slider__track--active">
|
|
413
|
+
<div class="mdc-slider__track--active_fill"></div>
|
|
414
|
+
</div>
|
|
415
|
+
</div>
|
|
416
|
+
<div class="mdc-slider__thumb">
|
|
417
|
+
${!this.continuous?t`<div class="mdc-slider__value-indicator-container" aria-hidden="true">
|
|
418
|
+
<div class="mdc-slider__value-indicator">
|
|
419
|
+
<span class="mdc-slider__value-indicator-text">
|
|
420
|
+
50
|
|
421
|
+
</span>
|
|
422
|
+
</div>
|
|
423
|
+
</div>`:""}
|
|
424
|
+
<div class="mdc-slider__thumb-knob"></div>
|
|
425
|
+
</div>
|
|
426
|
+
</div>
|
|
427
|
+
${e?t`<div style="min-width: 70px; width: 70px;">${e}</div>`:""}
|
|
428
|
+
</span>
|
|
429
|
+
`}return e}}}return t`<span>INPUT TYPE NOT IMPLEMENTED</span>`}_getFormat(){if(this.format)return this.format}update(e){if(e.has("autoValidate")&&this._mdcComponent){let e=this._mdcComponent;e.foundation&&e.foundation.setValidateOnValueChange&&e.foundation.setValidateOnValueChange(this.autoValidate)}super.update(e)}firstUpdated(e){super.firstUpdated(e),this.autoValidate&&this.reportValidity()}updated(e){var t,i;if(super.updated(e),e.has("type")){let e=this.shadowRoot.getElementById("component");if(this._mdcComponent&&(this._mdcComponent.destroy(),this._mdcComponent=void 0),this._mdcComponent2&&(this._mdcComponent2.destroy(),this._mdcComponent2=void 0),e&&this.type){switch(this.type){case InputType.LIST:let t=new T(e);this._mdcComponent=t,t.selectedIndex=this._selectedIndex;break;case InputType.SELECT:let i=new b(e);this._mdcComponent=i,(null===this.value||void 0===this.value)&&(i.selectedIndex=-1),this.multiple&&(this._mdcComponent.foundation.adapter.getSelectedIndex=()=>{if(!Array.isArray(this.value)||0===this.value.length)return -1;let e=this.value[0];return this._mdcComponent.foundation.adapter.getMenuItemValues().indexOf(e)}),i.useDefaultValidation=!this.multiple,i.valid=!this.required||!this.multiple&&i.valid||this.multiple&&Array.isArray(this.value)&&this.value.length>0;let a=this.getSelectedTextValue();this._mdcComponent.foundation.adapter.setSelectedText(a),this._mdcComponent.foundation.adapter.floatLabel(!!a),this._menuObserver||(this._menuObserver=new IntersectionObserver((e,t)=>{var i,a;e[0].target.style.minWidth!=(null==(i=e[0].target.parentElement)?void 0:i.clientWidth)+"px"&&(e[0].target.style.minWidth=(null==(a=e[0].target.parentElement)?void 0:a.clientWidth)+"px")}),this._menuObserver.observe(this.shadowRoot.getElementById("mdc-select-menu")));let n=void 0!==this.searchProvider,s=this.multiple;i.menu.menuSurface_.foundation.handleBodyClick=function(e){let t=e.composedPath()[0];if(this.adapter.isElementInContainer(t)){if(!n)return;else if(t instanceof Element&&!t.className.includes("mdc-list-item"))return;else if(s)return}i.menu.menuSurface_.close()};break;case InputType.RADIO:case InputType.CHECKBOX_LIST:case InputType.COLOUR:break;case InputType.BUTTON:case InputType.BUTTON_MOMENTARY:let o=!this.action&&!this.label,l=new h(e);o&&(l.unbounded=!0),this._mdcComponent=l;break;case InputType.BUTTON_TOGGLE:this._mdcComponent=new I(e);break;case InputType.CHECKBOX:this._mdcComponent=new y(e);let d=this.shadowRoot.getElementById("field");if(d){let e=new f(d);e.input=this._mdcComponent,this._mdcComponent2=e}break;case InputType.SWITCH:this._mdcComponent=new v(e);break;case InputType.RANGE:this._mdcComponent=new _(e);let r=this.shadowRoot.getElementById("number");if(r){let e=new m(r);e.useNativeValidation=!1,this._mdcComponent2=e}break;default:let c=new m(e);c.useNativeValidation=!1,this._mdcComponent=c}this._mdcComponent&&this.focused&&"function"==typeof this._mdcComponent.focus&&this._mdcComponent.focus()}}else{if(this.type===InputType.SELECT&&this._mdcComponent){e.has("options")&&this._mdcComponent.layoutOptions(),this._mdcComponent.disabled=!!(this.disabled||this.readonly),this._mdcComponent.useDefaultValidation=!this.multiple,this._mdcComponent.valid=!this.required||!this.multiple&&this._mdcComponent.valid||this.multiple&&Array.isArray(this.value)&&this.value.length>0;let t=this.getSelectedTextValue();this._mdcComponent.foundation.adapter.setSelectedText(t),this._mdcComponent.foundation.adapter.floatLabel(!!t)}else if(this.type===InputType.RANGE&&this._mdcComponent){let e=this._mdcComponent;e.setDisabled(this.disabled||this.readonly),e.setValue(this.value)}else if(this.type===InputType.SWITCH&&this._mdcComponent)this._mdcComponent.checked=this.value;else if(this.type===InputType.CHECKBOX&&this._mdcComponent){let e=this._mdcComponent;e.checked=!!this.value,e.disabled=!!(this.disabled||this.readonly)}this._mdcComponent&&(this._mdcComponent.required=!!this.required)}e.has("label")&&(null==(i=null==(t=this._mdcComponent)?void 0:t.layout)||i.call(t)),this.autoValidate&&this.reportValidity()}renderOutlined(e){return t`
|
|
430
|
+
<span class="mdc-notched-outline">
|
|
431
|
+
<span class="mdc-notched-outline__leading"></span>
|
|
432
|
+
${e?t`
|
|
433
|
+
<span class="mdc-notched-outline__notch">
|
|
434
|
+
${e}
|
|
435
|
+
</span>
|
|
436
|
+
`:""}
|
|
437
|
+
<span class="mdc-notched-outline__trailing"></span>
|
|
438
|
+
</span>
|
|
439
|
+
`}setCustomValidity(e){this.errorMessage=e;let t=this.shadowRoot.getElementById("elem");t&&t.setCustomValidity&&t.setCustomValidity(null!=e?e:""),this.reportValidity()}checkValidity(){let e=this.shadowRoot.getElementById("elem"),t=!0;return e&&e.validity&&(t=e.validity.valid),t&&(this.type===InputType.JSON||this.type===InputType.JSON_OBJECT)&&void 0!==this.value&&null!==this.value&&""===this._mdcComponent.value&&(t=!1),t}reportValidity(){let e=this.checkValidity();return this.isUiValid=e,this._mdcComponent&&(this._mdcComponent.valid=e),e}onValueChange(e,t,i){var a,n;let s,o=this.value;if("undefined"===t&&(o=null,t=void 0),"null"===t&&(o=void 0,t=null),"string"==typeof t)switch(this.type){case InputType.CHECKBOX:case InputType.SWITCH:t="on"===t;break;case InputType.JSON:case InputType.JSON_OBJECT:case InputType.NUMBER:case InputType.RANGE:if(""===t)t=null;else try{t=JSON.parse(t),this.type===InputType.JSON_OBJECT&&("object"!=typeof t||Array.isArray(t))&&(t=this.value,s=S.t("validation.invalidJSON"))}catch(e){t=this.value,s=this.type===InputType.JSON||this.type==InputType.JSON_OBJECT?S.t("validation.invalidJSON"):S.t("validation.invalidNumber")}break;case InputType.DATETIME:if(""===t)t=null;else try{t=Date.parse(t)}catch(e){t=this.value,s=S.t("validation.invalidDate")}}if(this.value=t,this.setCustomValidity(s),this.reportValidity(),this.type!==InputType.CHECKBOX_LIST&&t!==o&&(this.type===InputType.RANGE&&(this._mdcComponent.setValue(t),this._mdcComponent2&&(this._mdcComponent2.value=t)),this.dispatchEvent(new OrInputChangedEvent(this.value,o,i))),void 0!=this.searchProvider&&this.type===InputType.SELECT){let e=null==(n=null==(a=this.shadowRoot)?void 0:a.getElementById("select-searchable"))?void 0:n.children[1];e&&(this.searchableValue=void 0,e.value="")}this.type!==InputType.CHECKBOX_LIST||w.objectsEqual(t,o,!0)||this.dispatchEvent(new OrInputChangedEvent(t,o,i))}get valid(){let e=this.shadowRoot.getElementById("elem");return!e||!e.checkValidity||e.checkValidity()}get currentValue(){let e=this.shadowRoot.getElementById("elem");if(e&&e.value)return e.value}resolveOptions(e){let t;return e&&e.length>0&&(t=e.map(e=>{if(Array.isArray(e))return e;{let t=""+e;return[e,S.t(t,{defaultValue:w.camelCaseToSentenceCase(t)})]}})),t}getSelectedTextValue(e){let t=this.value,i=Array.isArray(t)?t:null!=t?[t]:void 0;if(!i)return"";let a=e||this.resolveOptions(this.options);return a&&i?i.map(e=>a.find(([t,i],a)=>e===t)).map(e=>e?e[1]:"").join(", "):""}};__decorate([s({type:Boolean})],OrMwcInput.prototype,"focused",void 0),__decorate([s()],OrMwcInput.prototype,"value",void 0),__decorate([s({type:String})],OrMwcInput.prototype,"type",void 0),__decorate([s({type:String})],OrMwcInput.prototype,"name",void 0),__decorate([s({type:Boolean})],OrMwcInput.prototype,"readonly",void 0),__decorate([s({type:Boolean})],OrMwcInput.prototype,"required",void 0),__decorate([s()],OrMwcInput.prototype,"max",void 0),__decorate([s()],OrMwcInput.prototype,"min",void 0),__decorate([s({type:Number})],OrMwcInput.prototype,"step",void 0),__decorate([s({type:Boolean})],OrMwcInput.prototype,"checked",void 0),__decorate([s({type:Boolean})],OrMwcInput.prototype,"indeterminate",void 0),__decorate([s({type:Number})],OrMwcInput.prototype,"maxLength",void 0),__decorate([s({type:Number})],OrMwcInput.prototype,"minLength",void 0),__decorate([s({type:Number})],OrMwcInput.prototype,"rows",void 0),__decorate([s({type:Number})],OrMwcInput.prototype,"cols",void 0),__decorate([s({type:Boolean})],OrMwcInput.prototype,"multiple",void 0),__decorate([s({type:String,attribute:!0,reflect:!1})],OrMwcInput.prototype,"pattern",void 0),__decorate([s({type:String})],OrMwcInput.prototype,"placeHolder",void 0),__decorate([s({type:Array})],OrMwcInput.prototype,"options",void 0),__decorate([s({type:Boolean})],OrMwcInput.prototype,"autoSelect",void 0),__decorate([s({type:Object})],OrMwcInput.prototype,"searchProvider",void 0),__decorate([s({type:String})],OrMwcInput.prototype,"searchLabel",void 0),__decorate([s({type:String})],OrMwcInput.prototype,"icon",void 0),__decorate([s({type:String})],OrMwcInput.prototype,"iconColor",void 0),__decorate([s({type:String})],OrMwcInput.prototype,"iconOn",void 0),__decorate([s({type:String})],OrMwcInput.prototype,"iconTrailing",void 0),__decorate([s({type:Boolean})],OrMwcInput.prototype,"compact",void 0),__decorate([s({type:Boolean})],OrMwcInput.prototype,"comfortable",void 0),__decorate([s({type:Boolean})],OrMwcInput.prototype,"raised",void 0),__decorate([s({type:Boolean})],OrMwcInput.prototype,"action",void 0),__decorate([s({type:Boolean})],OrMwcInput.prototype,"unElevated",void 0),__decorate([s({type:Boolean})],OrMwcInput.prototype,"outlined",void 0),__decorate([s({type:Boolean})],OrMwcInput.prototype,"rounded",void 0),__decorate([s({type:Object})],OrMwcInput.prototype,"format",void 0),__decorate([s({type:Boolean})],OrMwcInput.prototype,"disableSliderNumberInput",void 0),__decorate([s({type:Boolean})],OrMwcInput.prototype,"fullWidth",void 0),__decorate([s({type:String})],OrMwcInput.prototype,"helperText",void 0),__decorate([s({type:Boolean})],OrMwcInput.prototype,"helperPersistent",void 0),__decorate([s({type:String,attribute:!0})],OrMwcInput.prototype,"validationMessage",void 0),__decorate([s({type:Boolean})],OrMwcInput.prototype,"autoValidate",void 0),__decorate([s({type:Boolean})],OrMwcInput.prototype,"charCounter",void 0),__decorate([s({type:String})],OrMwcInput.prototype,"label",void 0),__decorate([s({type:Boolean})],OrMwcInput.prototype,"disabled",void 0),__decorate([s({type:Boolean})],OrMwcInput.prototype,"continuous",void 0),__decorate([s({type:Boolean})],OrMwcInput.prototype,"resizeVertical",void 0),__decorate([s({type:Boolean})],OrMwcInput.prototype,"censored",void 0),__decorate([s({type:Boolean,reflect:!0})],OrMwcInput.prototype,"advertised",void 0),__decorate([o()],OrMwcInput.prototype,"isUiValid",void 0),__decorate([o()],OrMwcInput.prototype,"searchableValue",void 0),__decorate([o()],OrMwcInput.prototype,"errorMessage",void 0),OrMwcInput=__decorate([n("or-mwc-input")],OrMwcInput);export{OrMwcInput};
|