@everymatrix/general-input 1.27.6 → 1.27.8
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/dist/cjs/checkbox-group-input_10.cjs.entry.js +12152 -11622
- package/dist/components/active-mixin.js +6 -6
- package/dist/components/checkbox-group-input2.js +260 -307
- package/dist/components/date-input2.js +3461 -2218
- package/dist/components/field-mixin.js +2188 -2474
- package/dist/components/input-field-shared-styles.js +308 -211
- package/dist/components/password-input2.js +119 -72
- package/dist/components/vaadin-button.js +102 -73
- package/dist/components/vaadin-combo-box.js +988 -805
- package/dist/components/virtual-keyboard-controller.js +1114 -1771
- package/dist/esm/checkbox-group-input_10.entry.js +12152 -11622
- package/dist/general-input/general-input.esm.js +1 -1
- package/dist/general-input/p-e322bf39.entry.js +3646 -0
- package/dist/types/Users/dragos.bodea/Documents/everymatrix-prjs/emfe-widgets/widgets-stencil/packages/general-input/.stencil/packages/general-input/stencil.config.d.ts +2 -0
- package/package.json +1 -1
- package/dist/components/pattern-mixin.js +0 -85
- package/dist/general-input/p-de2b2f7b.entry.js +0 -3581
- package/dist/types/Users/sebastian.strulea/Documents/work/widgets-stencil/packages/general-input/.stencil/packages/general-input/stencil.config.d.ts +0 -2
|
@@ -1,27 +1,42 @@
|
|
|
1
|
-
import { r as registerStyles, i,
|
|
1
|
+
import { r as registerStyles, i, f as defineCustomElement, g as ThemableMixin, n as DirMixin, P as PolymerElement, h as html, j as requiredField, k as helper, d as dedupingMixin, I as InputMixin, K as KeyboardMixin, D as DelegateStateMixin, V as ValidateMixin, b as DelegateFocusMixin, F as FieldMixin, o as Debouncer, t as timeOut } from './field-mixin.js';
|
|
2
2
|
|
|
3
3
|
registerStyles(
|
|
4
4
|
'vaadin-input-container',
|
|
5
5
|
i`
|
|
6
6
|
:host {
|
|
7
|
-
border-radius: var(--lumo-border-radius-m);
|
|
8
7
|
background-color: var(--lumo-contrast-10pct);
|
|
9
|
-
padding: 0 calc(0.375em + var(--
|
|
8
|
+
padding: 0 calc(0.375em + var(--_input-container-radius) / 4 - 1px);
|
|
10
9
|
font-weight: 500;
|
|
11
10
|
line-height: 1;
|
|
12
11
|
position: relative;
|
|
13
12
|
cursor: text;
|
|
14
13
|
box-sizing: border-box;
|
|
14
|
+
border-radius:
|
|
15
|
+
/* See https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius#syntax */
|
|
16
|
+
var(--vaadin-input-field-top-start-radius, var(--_input-container-radius))
|
|
17
|
+
var(--vaadin-input-field-top-end-radius, var(--_input-container-radius))
|
|
18
|
+
var(--vaadin-input-field-bottom-end-radius, var(--_input-container-radius))
|
|
19
|
+
var(--vaadin-input-field-bottom-start-radius, var(--_input-container-radius));
|
|
20
|
+
/* Fallback */
|
|
21
|
+
--_input-container-radius: var(--vaadin-input-field-border-radius, var(--lumo-border-radius-m));
|
|
22
|
+
/* Default field border color */
|
|
23
|
+
--_input-border-color: var(--vaadin-input-field-border-color, var(--lumo-contrast-50pct));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
:host([dir='rtl']) {
|
|
27
|
+
border-radius:
|
|
28
|
+
/* Don't use logical props, see https://github.com/vaadin/vaadin-time-picker/issues/145 */
|
|
29
|
+
var(--vaadin-input-field-top-end-radius, var(--_input-container-radius))
|
|
30
|
+
var(--vaadin-input-field-top-start-radius, var(--_input-container-radius))
|
|
31
|
+
var(--vaadin-input-field-bottom-start-radius, var(--_input-container-radius))
|
|
32
|
+
var(--vaadin-input-field-bottom-end-radius, var(--_input-container-radius));
|
|
15
33
|
}
|
|
16
34
|
|
|
17
35
|
/* Used for hover and activation effects */
|
|
18
36
|
:host::after {
|
|
19
37
|
content: '';
|
|
20
38
|
position: absolute;
|
|
21
|
-
|
|
22
|
-
right: 0;
|
|
23
|
-
bottom: 0;
|
|
24
|
-
left: 0;
|
|
39
|
+
inset: 0;
|
|
25
40
|
border-radius: inherit;
|
|
26
41
|
pointer-events: none;
|
|
27
42
|
background-color: var(--lumo-contrast-50pct);
|
|
@@ -72,7 +87,6 @@ registerStyles(
|
|
|
72
87
|
}
|
|
73
88
|
|
|
74
89
|
/* Slotted icons */
|
|
75
|
-
::slotted(iron-icon),
|
|
76
90
|
::slotted(vaadin-icon) {
|
|
77
91
|
color: var(--lumo-contrast-60pct);
|
|
78
92
|
width: var(--lumo-icon-size-m);
|
|
@@ -80,7 +94,6 @@ registerStyles(
|
|
|
80
94
|
}
|
|
81
95
|
|
|
82
96
|
/* Vaadin icons are based on a 16x16 grid (unlike Lumo and Material icons with 24x24), so they look too big by default */
|
|
83
|
-
::slotted(iron-icon[icon^='vaadin:']),
|
|
84
97
|
::slotted(vaadin-icon[icon^='vaadin:']) {
|
|
85
98
|
padding: 0.25em;
|
|
86
99
|
box-sizing: border-box !important;
|
|
@@ -162,10 +175,16 @@ registerStyles(
|
|
|
162
175
|
|
|
163
176
|
/**
|
|
164
177
|
* @license
|
|
165
|
-
* Copyright (c) 2021 -
|
|
178
|
+
* Copyright (c) 2021 - 2023 Vaadin Ltd.
|
|
166
179
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
167
180
|
*/
|
|
168
181
|
|
|
182
|
+
/**
|
|
183
|
+
* @customElement
|
|
184
|
+
* @extends HTMLElement
|
|
185
|
+
* @mixes ThemableMixin
|
|
186
|
+
* @mixes DirMixin
|
|
187
|
+
*/
|
|
169
188
|
class InputContainer extends ThemableMixin(DirMixin(PolymerElement)) {
|
|
170
189
|
static get is() {
|
|
171
190
|
return 'vaadin-input-container';
|
|
@@ -178,6 +197,25 @@ class InputContainer extends ThemableMixin(DirMixin(PolymerElement)) {
|
|
|
178
197
|
display: flex;
|
|
179
198
|
align-items: center;
|
|
180
199
|
flex: 0 1 auto;
|
|
200
|
+
border-radius:
|
|
201
|
+
/* See https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius */
|
|
202
|
+
var(--vaadin-input-field-top-start-radius, var(--__border-radius))
|
|
203
|
+
var(--vaadin-input-field-top-end-radius, var(--__border-radius))
|
|
204
|
+
var(--vaadin-input-field-bottom-end-radius, var(--__border-radius))
|
|
205
|
+
var(--vaadin-input-field-bottom-start-radius, var(--__border-radius));
|
|
206
|
+
--_border-radius: var(--vaadin-input-field-border-radius, 0px);
|
|
207
|
+
--_input-border-width: var(--vaadin-input-field-border-width, 0);
|
|
208
|
+
--_input-border-color: var(--vaadin-input-field-border-color, transparent);
|
|
209
|
+
box-shadow: inset 0 0 0 var(--_input-border-width, 0) var(--_input-border-color);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
:host([dir='rtl']) {
|
|
213
|
+
border-radius:
|
|
214
|
+
/* Don't use logical props, see https://github.com/vaadin/vaadin-time-picker/issues/145 */
|
|
215
|
+
var(--vaadin-input-field-top-end-radius, var(--_border-radius))
|
|
216
|
+
var(--vaadin-input-field-top-start-radius, var(--_border-radius))
|
|
217
|
+
var(--vaadin-input-field-bottom-start-radius, var(--_border-radius))
|
|
218
|
+
var(--vaadin-input-field-bottom-end-radius, var(--_border-radius));
|
|
181
219
|
}
|
|
182
220
|
|
|
183
221
|
:host([hidden]) {
|
|
@@ -278,47 +316,11 @@ class InputContainer extends ThemableMixin(DirMixin(PolymerElement)) {
|
|
|
278
316
|
}
|
|
279
317
|
}
|
|
280
318
|
|
|
281
|
-
|
|
319
|
+
defineCustomElement(InputContainer);
|
|
282
320
|
|
|
283
321
|
/**
|
|
284
322
|
* @license
|
|
285
|
-
* Copyright (c)
|
|
286
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
287
|
-
*/
|
|
288
|
-
|
|
289
|
-
const testUserAgent = (regexp) => regexp.test(navigator.userAgent);
|
|
290
|
-
|
|
291
|
-
const testPlatform = (regexp) => regexp.test(navigator.platform);
|
|
292
|
-
|
|
293
|
-
const testVendor = (regexp) => regexp.test(navigator.vendor);
|
|
294
|
-
|
|
295
|
-
testUserAgent(/Android/);
|
|
296
|
-
|
|
297
|
-
testUserAgent(/Chrome/) && testVendor(/Google Inc/);
|
|
298
|
-
|
|
299
|
-
const isFirefox = testUserAgent(/Firefox/);
|
|
300
|
-
|
|
301
|
-
// IPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.
|
|
302
|
-
const isIPad = testPlatform(/^iPad/) || (testPlatform(/^Mac/) && navigator.maxTouchPoints > 1);
|
|
303
|
-
|
|
304
|
-
const isIPhone = testPlatform(/^iPhone/);
|
|
305
|
-
|
|
306
|
-
const isIOS = isIPhone || isIPad;
|
|
307
|
-
|
|
308
|
-
const isSafari = testUserAgent(/^((?!chrome|android).)*safari/i);
|
|
309
|
-
|
|
310
|
-
const isTouch = (() => {
|
|
311
|
-
try {
|
|
312
|
-
document.createEvent('TouchEvent');
|
|
313
|
-
return true;
|
|
314
|
-
} catch (e) {
|
|
315
|
-
return false;
|
|
316
|
-
}
|
|
317
|
-
})();
|
|
318
|
-
|
|
319
|
-
/**
|
|
320
|
-
* @license
|
|
321
|
-
* Copyright (c) 2017 - 2022 Vaadin Ltd.
|
|
323
|
+
* Copyright (c) 2017 - 2023 Vaadin Ltd.
|
|
322
324
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
323
325
|
*/
|
|
324
326
|
|
|
@@ -354,7 +356,7 @@ registerStyles('', fieldButton, { moduleId: 'lumo-field-button' });
|
|
|
354
356
|
|
|
355
357
|
/**
|
|
356
358
|
* @license
|
|
357
|
-
* Copyright (c) 2017 -
|
|
359
|
+
* Copyright (c) 2017 - 2023 Vaadin Ltd.
|
|
358
360
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
359
361
|
*/
|
|
360
362
|
|
|
@@ -430,9 +432,15 @@ const inputField = i`
|
|
|
430
432
|
opacity: 0;
|
|
431
433
|
}
|
|
432
434
|
|
|
435
|
+
/* Read-only style */
|
|
436
|
+
:host([readonly]) {
|
|
437
|
+
--vaadin-input-field-border-color: transparent;
|
|
438
|
+
}
|
|
439
|
+
|
|
433
440
|
/* Disabled style */
|
|
434
441
|
:host([disabled]) {
|
|
435
442
|
pointer-events: none;
|
|
443
|
+
--vaadin-input-field-border-color: var(--lumo-contrast-20pct);
|
|
436
444
|
}
|
|
437
445
|
|
|
438
446
|
:host([disabled]) [part='label'],
|
|
@@ -442,6 +450,10 @@ const inputField = i`
|
|
|
442
450
|
}
|
|
443
451
|
|
|
444
452
|
/* Invalid style */
|
|
453
|
+
:host([invalid]) {
|
|
454
|
+
--vaadin-input-field-border-color: var(--lumo-error-color);
|
|
455
|
+
}
|
|
456
|
+
|
|
445
457
|
:host([invalid][focus-ring]) [part='input-field'] {
|
|
446
458
|
box-shadow: 0 0 0 2px var(--lumo-error-color-50pct);
|
|
447
459
|
}
|
|
@@ -474,7 +486,7 @@ const inputField = i`
|
|
|
474
486
|
}
|
|
475
487
|
|
|
476
488
|
/* Slotted content */
|
|
477
|
-
[part='input-field'] ::slotted(:not(
|
|
489
|
+
[part='input-field'] ::slotted(:not(vaadin-icon):not(input):not(textarea)) {
|
|
478
490
|
color: var(--lumo-secondary-text-color);
|
|
479
491
|
font-weight: 400;
|
|
480
492
|
}
|
|
@@ -492,7 +504,229 @@ registerStyles('', inputFieldShared$1, {
|
|
|
492
504
|
|
|
493
505
|
/**
|
|
494
506
|
* @license
|
|
495
|
-
* Copyright (c) 2021 -
|
|
507
|
+
* Copyright (c) 2021 - 2023 Vaadin Ltd.
|
|
508
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
509
|
+
*/
|
|
510
|
+
|
|
511
|
+
const testUserAgent = (regexp) => regexp.test(navigator.userAgent);
|
|
512
|
+
|
|
513
|
+
const testPlatform = (regexp) => regexp.test(navigator.platform);
|
|
514
|
+
|
|
515
|
+
const testVendor = (regexp) => regexp.test(navigator.vendor);
|
|
516
|
+
|
|
517
|
+
testUserAgent(/Android/u);
|
|
518
|
+
|
|
519
|
+
testUserAgent(/Chrome/u) && testVendor(/Google Inc/u);
|
|
520
|
+
|
|
521
|
+
const isFirefox = testUserAgent(/Firefox/u);
|
|
522
|
+
|
|
523
|
+
// IPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.
|
|
524
|
+
const isIPad = testPlatform(/^iPad/u) || (testPlatform(/^Mac/u) && navigator.maxTouchPoints > 1);
|
|
525
|
+
|
|
526
|
+
const isIPhone = testPlatform(/^iPhone/u);
|
|
527
|
+
|
|
528
|
+
const isIOS = isIPhone || isIPad;
|
|
529
|
+
|
|
530
|
+
const isSafari = testUserAgent(/^((?!chrome|android).)*safari/iu);
|
|
531
|
+
|
|
532
|
+
const isTouch = (() => {
|
|
533
|
+
try {
|
|
534
|
+
document.createEvent('TouchEvent');
|
|
535
|
+
return true;
|
|
536
|
+
} catch (e) {
|
|
537
|
+
return false;
|
|
538
|
+
}
|
|
539
|
+
})();
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* @license
|
|
543
|
+
* Copyright (c) 2021 - 2023 Vaadin Ltd.
|
|
544
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
545
|
+
*/
|
|
546
|
+
|
|
547
|
+
const stylesMap = new WeakMap();
|
|
548
|
+
|
|
549
|
+
/**
|
|
550
|
+
* Get all the styles inserted into root.
|
|
551
|
+
* @param {DocumentOrShadowRoot} root
|
|
552
|
+
* @return {Set<string>}
|
|
553
|
+
*/
|
|
554
|
+
function getRootStyles(root) {
|
|
555
|
+
if (!stylesMap.has(root)) {
|
|
556
|
+
stylesMap.set(root, new Set());
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
return stylesMap.get(root);
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
/**
|
|
563
|
+
* Insert styles into the root.
|
|
564
|
+
* @param {string} styles
|
|
565
|
+
* @param {DocumentOrShadowRoot} root
|
|
566
|
+
*/
|
|
567
|
+
function insertStyles(styles, root) {
|
|
568
|
+
const style = document.createElement('style');
|
|
569
|
+
style.textContent = styles;
|
|
570
|
+
|
|
571
|
+
if (root === document) {
|
|
572
|
+
document.head.appendChild(style);
|
|
573
|
+
} else {
|
|
574
|
+
root.insertBefore(style, root.firstChild);
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* Mixin to insert styles into the outer scope to handle slotted components.
|
|
580
|
+
* This is useful e.g. to hide native `<input type="number">` controls.
|
|
581
|
+
*
|
|
582
|
+
* @polymerMixin
|
|
583
|
+
*/
|
|
584
|
+
const SlotStylesMixin = dedupingMixin(
|
|
585
|
+
(superclass) =>
|
|
586
|
+
class SlotStylesMixinClass extends superclass {
|
|
587
|
+
/**
|
|
588
|
+
* List of styles to insert into root.
|
|
589
|
+
* @protected
|
|
590
|
+
*/
|
|
591
|
+
get slotStyles() {
|
|
592
|
+
return {};
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
/** @protected */
|
|
596
|
+
connectedCallback() {
|
|
597
|
+
super.connectedCallback();
|
|
598
|
+
|
|
599
|
+
this.__applySlotStyles();
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
/** @private */
|
|
603
|
+
__applySlotStyles() {
|
|
604
|
+
const root = this.getRootNode();
|
|
605
|
+
const rootStyles = getRootStyles(root);
|
|
606
|
+
|
|
607
|
+
this.slotStyles.forEach((styles) => {
|
|
608
|
+
if (!rootStyles.has(styles)) {
|
|
609
|
+
insertStyles(styles, root);
|
|
610
|
+
rootStyles.add(styles);
|
|
611
|
+
}
|
|
612
|
+
});
|
|
613
|
+
}
|
|
614
|
+
},
|
|
615
|
+
);
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* @license
|
|
619
|
+
* Copyright (c) 2021 - 2023 Vaadin Ltd.
|
|
620
|
+
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
621
|
+
*/
|
|
622
|
+
|
|
623
|
+
/**
|
|
624
|
+
* A mixin that manages the clear button.
|
|
625
|
+
*
|
|
626
|
+
* @polymerMixin
|
|
627
|
+
* @mixes InputMixin
|
|
628
|
+
* @mixes KeyboardMixin
|
|
629
|
+
*/
|
|
630
|
+
const ClearButtonMixin = (superclass) =>
|
|
631
|
+
class ClearButtonMixinClass extends InputMixin(KeyboardMixin(superclass)) {
|
|
632
|
+
static get properties() {
|
|
633
|
+
return {
|
|
634
|
+
/**
|
|
635
|
+
* Set to true to display the clear icon which clears the input.
|
|
636
|
+
*
|
|
637
|
+
* It is up to the component to choose where to place the clear icon:
|
|
638
|
+
* in the Shadow DOM or in the light DOM. In any way, a reference to
|
|
639
|
+
* the clear icon element should be provided via the `clearElement` getter.
|
|
640
|
+
*
|
|
641
|
+
* @attr {boolean} clear-button-visible
|
|
642
|
+
*/
|
|
643
|
+
clearButtonVisible: {
|
|
644
|
+
type: Boolean,
|
|
645
|
+
reflectToAttribute: true,
|
|
646
|
+
value: false,
|
|
647
|
+
},
|
|
648
|
+
};
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
/**
|
|
652
|
+
* Any element extending this mixin is required to implement this getter.
|
|
653
|
+
* It returns the reference to the clear button element.
|
|
654
|
+
*
|
|
655
|
+
* @protected
|
|
656
|
+
* @return {Element | null | undefined}
|
|
657
|
+
*/
|
|
658
|
+
get clearElement() {
|
|
659
|
+
console.warn(`Please implement the 'clearElement' property in <${this.localName}>`);
|
|
660
|
+
return null;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
/** @protected */
|
|
664
|
+
ready() {
|
|
665
|
+
super.ready();
|
|
666
|
+
|
|
667
|
+
if (this.clearElement) {
|
|
668
|
+
this.clearElement.addEventListener('mousedown', (event) => this._onClearButtonMouseDown(event));
|
|
669
|
+
this.clearElement.addEventListener('click', (event) => this._onClearButtonClick(event));
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* @param {Event} event
|
|
675
|
+
* @protected
|
|
676
|
+
*/
|
|
677
|
+
_onClearButtonClick(event) {
|
|
678
|
+
event.preventDefault();
|
|
679
|
+
this._onClearAction();
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* @param {MouseEvent} event
|
|
684
|
+
* @protected
|
|
685
|
+
*/
|
|
686
|
+
_onClearButtonMouseDown(event) {
|
|
687
|
+
event.preventDefault();
|
|
688
|
+
if (!isTouch) {
|
|
689
|
+
this.inputElement.focus();
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
/**
|
|
694
|
+
* Override an event listener inherited from `KeydownMixin` to clear on Esc.
|
|
695
|
+
* Components that extend this mixin can prevent this behavior by overriding
|
|
696
|
+
* this method without calling `super._onEscape` to provide custom logic.
|
|
697
|
+
*
|
|
698
|
+
* @param {KeyboardEvent} event
|
|
699
|
+
* @protected
|
|
700
|
+
* @override
|
|
701
|
+
*/
|
|
702
|
+
_onEscape(event) {
|
|
703
|
+
super._onEscape(event);
|
|
704
|
+
|
|
705
|
+
if (this.clearButtonVisible && !!this.value) {
|
|
706
|
+
event.stopPropagation();
|
|
707
|
+
this._onClearAction();
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* Clears the value and dispatches `input` and `change` events
|
|
713
|
+
* on the input element. This method should be called
|
|
714
|
+
* when the clear action originates from the user.
|
|
715
|
+
*
|
|
716
|
+
* @protected
|
|
717
|
+
*/
|
|
718
|
+
_onClearAction() {
|
|
719
|
+
this.clear();
|
|
720
|
+
// Note, according to the HTML spec, the native change event isn't composed
|
|
721
|
+
// while the input event is composed.
|
|
722
|
+
this.inputElement.dispatchEvent(new Event('input', { bubbles: true, composed: true }));
|
|
723
|
+
this.inputElement.dispatchEvent(new Event('change', { bubbles: true }));
|
|
724
|
+
}
|
|
725
|
+
};
|
|
726
|
+
|
|
727
|
+
/**
|
|
728
|
+
* @license
|
|
729
|
+
* Copyright (c) 2021 - 2023 Vaadin Ltd.
|
|
496
730
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
497
731
|
*/
|
|
498
732
|
|
|
@@ -620,83 +854,7 @@ const InputConstraintsMixin = dedupingMixin(
|
|
|
620
854
|
|
|
621
855
|
/**
|
|
622
856
|
* @license
|
|
623
|
-
* Copyright (c) 2021 -
|
|
624
|
-
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
625
|
-
*/
|
|
626
|
-
|
|
627
|
-
const stylesMap = new WeakMap();
|
|
628
|
-
|
|
629
|
-
/**
|
|
630
|
-
* Get all the styles inserted into root.
|
|
631
|
-
* @param {DocumentOrShadowRoot} root
|
|
632
|
-
* @return {Set<string>}
|
|
633
|
-
*/
|
|
634
|
-
function getRootStyles(root) {
|
|
635
|
-
if (!stylesMap.has(root)) {
|
|
636
|
-
stylesMap.set(root, new Set());
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
return stylesMap.get(root);
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
/**
|
|
643
|
-
* Insert styles into the root.
|
|
644
|
-
* @param {string} styles
|
|
645
|
-
* @param {DocumentOrShadowRoot} root
|
|
646
|
-
*/
|
|
647
|
-
function insertStyles(styles, root) {
|
|
648
|
-
const style = document.createElement('style');
|
|
649
|
-
style.textContent = styles;
|
|
650
|
-
|
|
651
|
-
if (root === document) {
|
|
652
|
-
document.head.appendChild(style);
|
|
653
|
-
} else {
|
|
654
|
-
root.insertBefore(style, root.firstChild);
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
/**
|
|
659
|
-
* Mixin to insert styles into the outer scope to handle slotted components.
|
|
660
|
-
* This is useful e.g. to hide native `<input type="number">` controls.
|
|
661
|
-
*
|
|
662
|
-
* @polymerMixin
|
|
663
|
-
*/
|
|
664
|
-
const SlotStylesMixin = dedupingMixin(
|
|
665
|
-
(superclass) =>
|
|
666
|
-
class SlotStylesMixinClass extends superclass {
|
|
667
|
-
/**
|
|
668
|
-
* List of styles to insert into root.
|
|
669
|
-
* @protected
|
|
670
|
-
*/
|
|
671
|
-
get slotStyles() {
|
|
672
|
-
return {};
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
/** @protected */
|
|
676
|
-
connectedCallback() {
|
|
677
|
-
super.connectedCallback();
|
|
678
|
-
|
|
679
|
-
this.__applySlotStyles();
|
|
680
|
-
}
|
|
681
|
-
|
|
682
|
-
/** @private */
|
|
683
|
-
__applySlotStyles() {
|
|
684
|
-
const root = this.getRootNode();
|
|
685
|
-
const rootStyles = getRootStyles(root);
|
|
686
|
-
|
|
687
|
-
this.slotStyles.forEach((styles) => {
|
|
688
|
-
if (!rootStyles.has(styles)) {
|
|
689
|
-
insertStyles(styles, root);
|
|
690
|
-
rootStyles.add(styles);
|
|
691
|
-
}
|
|
692
|
-
});
|
|
693
|
-
}
|
|
694
|
-
},
|
|
695
|
-
);
|
|
696
|
-
|
|
697
|
-
/**
|
|
698
|
-
* @license
|
|
699
|
-
* Copyright (c) 2021 - 2022 Vaadin Ltd.
|
|
857
|
+
* Copyright (c) 2021 - 2023 Vaadin Ltd.
|
|
700
858
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
701
859
|
*/
|
|
702
860
|
|
|
@@ -708,11 +866,12 @@ const SlotStylesMixin = dedupingMixin(
|
|
|
708
866
|
* @mixes FieldMixin
|
|
709
867
|
* @mixes InputConstraintsMixin
|
|
710
868
|
* @mixes KeyboardMixin
|
|
869
|
+
* @mixes ClearButtonMixin
|
|
711
870
|
* @mixes SlotStylesMixin
|
|
712
871
|
*/
|
|
713
872
|
const InputControlMixin = (superclass) =>
|
|
714
873
|
class InputControlMixinClass extends SlotStylesMixin(
|
|
715
|
-
DelegateFocusMixin(InputConstraintsMixin(FieldMixin(KeyboardMixin(superclass)))),
|
|
874
|
+
DelegateFocusMixin(InputConstraintsMixin(FieldMixin(ClearButtonMixin(KeyboardMixin(superclass))))),
|
|
716
875
|
) {
|
|
717
876
|
static get properties() {
|
|
718
877
|
return {
|
|
@@ -741,16 +900,6 @@ const InputControlMixin = (superclass) =>
|
|
|
741
900
|
value: false,
|
|
742
901
|
},
|
|
743
902
|
|
|
744
|
-
/**
|
|
745
|
-
* Set to true to display the clear icon which clears the input.
|
|
746
|
-
* @attr {boolean} clear-button-visible
|
|
747
|
-
*/
|
|
748
|
-
clearButtonVisible: {
|
|
749
|
-
type: Boolean,
|
|
750
|
-
reflectToAttribute: true,
|
|
751
|
-
value: false,
|
|
752
|
-
},
|
|
753
|
-
|
|
754
903
|
/**
|
|
755
904
|
* The name of this field.
|
|
756
905
|
*/
|
|
@@ -798,17 +947,6 @@ const InputControlMixin = (superclass) =>
|
|
|
798
947
|
this._boundOnBeforeInput = this._onBeforeInput.bind(this);
|
|
799
948
|
}
|
|
800
949
|
|
|
801
|
-
/**
|
|
802
|
-
* Any element extending this mixin is required to implement this getter.
|
|
803
|
-
* It returns the reference to the clear button element.
|
|
804
|
-
* @protected
|
|
805
|
-
* @return {Element | null | undefined}
|
|
806
|
-
*/
|
|
807
|
-
get clearElement() {
|
|
808
|
-
console.warn(`Please implement the 'clearElement' property in <${this.localName}>`);
|
|
809
|
-
return null;
|
|
810
|
-
}
|
|
811
|
-
|
|
812
950
|
/** @protected */
|
|
813
951
|
get slotStyles() {
|
|
814
952
|
// Needed for Safari, where ::slotted(...)::placeholder does not work
|
|
@@ -822,36 +960,6 @@ const InputControlMixin = (superclass) =>
|
|
|
822
960
|
];
|
|
823
961
|
}
|
|
824
962
|
|
|
825
|
-
/** @protected */
|
|
826
|
-
ready() {
|
|
827
|
-
super.ready();
|
|
828
|
-
|
|
829
|
-
if (this.clearElement) {
|
|
830
|
-
this.clearElement.addEventListener('click', (e) => this._onClearButtonClick(e));
|
|
831
|
-
this.clearElement.addEventListener('mousedown', (e) => this._onClearButtonMouseDown(e));
|
|
832
|
-
}
|
|
833
|
-
}
|
|
834
|
-
|
|
835
|
-
/**
|
|
836
|
-
* @param {Event} event
|
|
837
|
-
* @protected
|
|
838
|
-
*/
|
|
839
|
-
_onClearButtonClick(event) {
|
|
840
|
-
event.preventDefault();
|
|
841
|
-
this.__clear();
|
|
842
|
-
}
|
|
843
|
-
|
|
844
|
-
/**
|
|
845
|
-
* @param {Event} event
|
|
846
|
-
* @protected
|
|
847
|
-
*/
|
|
848
|
-
_onClearButtonMouseDown(event) {
|
|
849
|
-
event.preventDefault();
|
|
850
|
-
if (!isTouch) {
|
|
851
|
-
this.inputElement.focus();
|
|
852
|
-
}
|
|
853
|
-
}
|
|
854
|
-
|
|
855
963
|
/**
|
|
856
964
|
* Override an event listener from `DelegateFocusMixin`.
|
|
857
965
|
* @param {FocusEvent} event
|
|
@@ -866,23 +974,6 @@ const InputControlMixin = (superclass) =>
|
|
|
866
974
|
}
|
|
867
975
|
}
|
|
868
976
|
|
|
869
|
-
/**
|
|
870
|
-
* Override an event listener inherited from `KeydownMixin` to clear on Esc.
|
|
871
|
-
* Components that extend this mixin can prevent this behavior by overriding
|
|
872
|
-
* this method without calling `super._onEscape` to provide custom logic.
|
|
873
|
-
* @param {KeyboardEvent} event
|
|
874
|
-
* @protected
|
|
875
|
-
* @override
|
|
876
|
-
*/
|
|
877
|
-
_onEscape(event) {
|
|
878
|
-
super._onEscape(event);
|
|
879
|
-
|
|
880
|
-
if (this.clearButtonVisible && !!this.value) {
|
|
881
|
-
event.stopPropagation();
|
|
882
|
-
this.__clear();
|
|
883
|
-
}
|
|
884
|
-
}
|
|
885
|
-
|
|
886
977
|
/**
|
|
887
978
|
* Override an event listener inherited from `InputMixin`
|
|
888
979
|
* to capture native `change` event and make sure that
|
|
@@ -907,13 +998,6 @@ const InputControlMixin = (superclass) =>
|
|
|
907
998
|
);
|
|
908
999
|
}
|
|
909
1000
|
|
|
910
|
-
/** @private */
|
|
911
|
-
__clear() {
|
|
912
|
-
this.clear();
|
|
913
|
-
this.inputElement.dispatchEvent(new Event('input', { bubbles: true, composed: true }));
|
|
914
|
-
this.inputElement.dispatchEvent(new Event('change', { bubbles: true }));
|
|
915
|
-
}
|
|
916
|
-
|
|
917
1001
|
/**
|
|
918
1002
|
* Override a method from `InputMixin`.
|
|
919
1003
|
* @param {!HTMLElement} input
|
|
@@ -1015,8 +1099,8 @@ const InputControlMixin = (superclass) =>
|
|
|
1015
1099
|
_allowedCharPatternChanged(charPattern) {
|
|
1016
1100
|
if (charPattern) {
|
|
1017
1101
|
try {
|
|
1018
|
-
this.__allowedCharRegExp = new RegExp(`^${charPattern}
|
|
1019
|
-
this.__allowedTextRegExp = new RegExp(`^${charPattern}
|
|
1102
|
+
this.__allowedCharRegExp = new RegExp(`^${charPattern}$`, 'u');
|
|
1103
|
+
this.__allowedTextRegExp = new RegExp(`^${charPattern}*$`, 'u');
|
|
1020
1104
|
} catch (e) {
|
|
1021
1105
|
console.error(e);
|
|
1022
1106
|
}
|
|
@@ -1039,7 +1123,7 @@ const InputControlMixin = (superclass) =>
|
|
|
1039
1123
|
|
|
1040
1124
|
/**
|
|
1041
1125
|
* @license
|
|
1042
|
-
* Copyright (c) 2021 -
|
|
1126
|
+
* Copyright (c) 2021 - 2023 Vaadin Ltd..
|
|
1043
1127
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
1044
1128
|
*/
|
|
1045
1129
|
|
|
@@ -1050,7 +1134,7 @@ const clearButton = i`
|
|
|
1050
1134
|
}
|
|
1051
1135
|
|
|
1052
1136
|
[part='clear-button']::before {
|
|
1053
|
-
content: '
|
|
1137
|
+
content: '\\2715';
|
|
1054
1138
|
}
|
|
1055
1139
|
|
|
1056
1140
|
:host([clear-button-visible][has-value]:not([disabled]):not([readonly])) [part='clear-button'] {
|
|
@@ -1060,7 +1144,7 @@ const clearButton = i`
|
|
|
1060
1144
|
|
|
1061
1145
|
/**
|
|
1062
1146
|
* @license
|
|
1063
|
-
* Copyright (c) 2021 -
|
|
1147
|
+
* Copyright (c) 2021 - 2023 Vaadin Ltd..
|
|
1064
1148
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
1065
1149
|
*/
|
|
1066
1150
|
|
|
@@ -1085,11 +1169,24 @@ const fieldShared = i`
|
|
|
1085
1169
|
:host(:not([has-label])) [part='label'] {
|
|
1086
1170
|
display: none;
|
|
1087
1171
|
}
|
|
1172
|
+
|
|
1173
|
+
@media (forced-colors: active) {
|
|
1174
|
+
:host(:not([readonly])) [part='input-field'] {
|
|
1175
|
+
outline: 1px solid;
|
|
1176
|
+
outline-offset: -1px;
|
|
1177
|
+
}
|
|
1178
|
+
:host([focused]) [part='input-field'] {
|
|
1179
|
+
outline-width: 2px;
|
|
1180
|
+
}
|
|
1181
|
+
:host([disabled]) [part='input-field'] {
|
|
1182
|
+
outline-color: GrayText;
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1088
1185
|
`;
|
|
1089
1186
|
|
|
1090
1187
|
/**
|
|
1091
1188
|
* @license
|
|
1092
|
-
* Copyright (c) 2021 -
|
|
1189
|
+
* Copyright (c) 2021 - 2023 Vaadin Ltd..
|
|
1093
1190
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
1094
1191
|
*/
|
|
1095
1192
|
|
|
@@ -1105,7 +1202,7 @@ const inputFieldContainer = i`
|
|
|
1105
1202
|
|
|
1106
1203
|
/**
|
|
1107
1204
|
* @license
|
|
1108
|
-
* Copyright (c) 2021 -
|
|
1205
|
+
* Copyright (c) 2021 - 2023 Vaadin Ltd..
|
|
1109
1206
|
* This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
|
|
1110
1207
|
*/
|
|
1111
1208
|
|