@everymatrix/general-input 1.22.0 → 1.22.1

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.
@@ -1,27 +1,335 @@
1
- import { r as registerStyles, i, T as ThemableMixin, A as DirMixin, P as PolymerElement, h as html, j as requiredField, k as helper, d as dedupingMixin, D as DelegateStateMixin, V as ValidateMixin, I as InputMixin, c as DelegateFocusMixin, F as FieldMixin, K as KeyboardMixin, y as Debouncer, z as timeOut } from './field-mixin.js';
1
+ import { o, i, h as html, P as PolymerElement, y as registerStyles$1, r as requiredField, g as helper, d as dedupingMixin, I as InputMixin, K as KeyboardMixin, D as DelegateStateMixin, V as ValidateMixin, c as DelegateFocusMixin, F as FieldMixin } from './field-mixin.js';
2
+
3
+ /**
4
+ * @license
5
+ * Copyright (c) 2017 - 2023 Vaadin Ltd.
6
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
7
+ */
8
+ /**
9
+ * @polymerMixin
10
+ */
11
+ const ThemePropertyMixin = (superClass) =>
12
+ class VaadinThemePropertyMixin extends superClass {
13
+ static get properties() {
14
+ return {
15
+ /**
16
+ * Helper property with theme attribute value facilitating propagation
17
+ * in shadow DOM.
18
+ *
19
+ * Enables the component implementation to propagate the `theme`
20
+ * attribute value to the sub-components in Shadow DOM by binding
21
+ * the sub-component's "theme" attribute to the `theme` property of
22
+ * the host.
23
+ *
24
+ * **NOTE:** Extending the mixin only provides the property for binding,
25
+ * and does not make the propagation alone.
26
+ *
27
+ * See [Styling Components: Sub-components](https://vaadin.com/docs/latest/styling/styling-components/#sub-components).
28
+ * page for more information.
29
+ *
30
+ * @protected
31
+ */
32
+ _theme: {
33
+ type: String,
34
+ readOnly: true,
35
+ },
36
+ };
37
+ }
38
+
39
+ static get observedAttributes() {
40
+ return [...super.observedAttributes, 'theme'];
41
+ }
42
+
43
+ /** @protected */
44
+ attributeChangedCallback(name, oldValue, newValue) {
45
+ super.attributeChangedCallback(name, oldValue, newValue);
46
+
47
+ if (name === 'theme') {
48
+ this._set_theme(newValue);
49
+ }
50
+ }
51
+ };
52
+
53
+ /**
54
+ * @license
55
+ * Copyright (c) 2017 - 2023 Vaadin Ltd.
56
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
57
+ */
58
+
59
+ /**
60
+ * @typedef {Object} Theme
61
+ * @property {string} themeFor
62
+ * @property {CSSResult[]} styles
63
+ * @property {string | string[]} [include]
64
+ * @property {string} [moduleId]
65
+ *
66
+ * @typedef {CSSResult[] | CSSResult} CSSResultGroup
67
+ */
68
+
69
+ /**
70
+ * @type {Theme[]}
71
+ */
72
+ const themeRegistry = [];
73
+
74
+ /**
75
+ * Check if the custom element type has themes applied.
76
+ * @param {Function} elementClass
77
+ * @returns {boolean}
78
+ */
79
+ function classHasThemes(elementClass) {
80
+ return elementClass && Object.prototype.hasOwnProperty.call(elementClass, '__themes');
81
+ }
82
+
83
+ /**
84
+ * Check if the custom element type has themes applied.
85
+ * @param {string} tagName
86
+ * @returns {boolean}
87
+ */
88
+ function hasThemes(tagName) {
89
+ return classHasThemes(customElements.get(tagName));
90
+ }
91
+
92
+ /**
93
+ * Flattens the styles into a single array of styles.
94
+ * @param {CSSResultGroup} styles
95
+ * @param {CSSResult[]} result
96
+ * @returns {CSSResult[]}
97
+ */
98
+ function flattenStyles(styles = []) {
99
+ return [styles].flat(Infinity).filter((style) => {
100
+ if (style instanceof o) {
101
+ return true;
102
+ }
103
+ console.warn('An item in styles is not of type CSSResult. Use `unsafeCSS` or `css`.');
104
+ return false;
105
+ });
106
+ }
107
+
108
+ /**
109
+ * Registers CSS styles for a component type. Make sure to register the styles before
110
+ * the first instance of a component of the type is attached to DOM.
111
+ *
112
+ * @param {string} themeFor The local/tag name of the component type to register the styles for
113
+ * @param {CSSResultGroup} styles The CSS style rules to be registered for the component type
114
+ * matching themeFor and included in the local scope of each component instance
115
+ * @param {{moduleId?: string, include?: string | string[]}} options Additional options
116
+ * @return {void}
117
+ */
118
+ function registerStyles(themeFor, styles, options = {}) {
119
+ if (themeFor) {
120
+ if (hasThemes(themeFor)) {
121
+ console.warn(`The custom element definition for "${themeFor}"
122
+ was finalized before a style module was registered.
123
+ Make sure to add component specific style modules before
124
+ importing the corresponding custom element.`);
125
+ }
126
+ }
127
+
128
+ styles = flattenStyles(styles);
129
+
130
+ if (window.Vaadin && window.Vaadin.styleModules) {
131
+ window.Vaadin.styleModules.registerStyles(themeFor, styles, options);
132
+ } else {
133
+ themeRegistry.push({
134
+ themeFor,
135
+ styles,
136
+ include: options.include,
137
+ moduleId: options.moduleId,
138
+ });
139
+ }
140
+ }
141
+
142
+ /**
143
+ * Returns all registered themes. By default the themeRegistry is returned as is.
144
+ * In case the style-modules adapter is imported, the themes are obtained from there instead
145
+ * @returns {Theme[]}
146
+ */
147
+ function getAllThemes() {
148
+ if (window.Vaadin && window.Vaadin.styleModules) {
149
+ return window.Vaadin.styleModules.getAllThemes();
150
+ }
151
+ return themeRegistry;
152
+ }
153
+
154
+ /**
155
+ * Returns true if the themeFor string matches the tag name
156
+ * @param {string} themeFor
157
+ * @param {string} tagName
158
+ * @returns {boolean}
159
+ */
160
+ function matchesThemeFor(themeFor, tagName) {
161
+ return (themeFor || '').split(' ').some((themeForToken) => {
162
+ return new RegExp(`^${themeForToken.split('*').join('.*')}$`, 'u').test(tagName);
163
+ });
164
+ }
165
+
166
+ /**
167
+ * Maps the moduleName to an include priority number which is used for
168
+ * determining the order in which styles are applied.
169
+ * @param {string} moduleName
170
+ * @returns {number}
171
+ */
172
+ function getIncludePriority(moduleName = '') {
173
+ let includePriority = 0;
174
+ if (moduleName.startsWith('lumo-') || moduleName.startsWith('material-')) {
175
+ includePriority = 1;
176
+ } else if (moduleName.startsWith('vaadin-')) {
177
+ includePriority = 2;
178
+ }
179
+ return includePriority;
180
+ }
181
+
182
+ /**
183
+ * Gets an array of CSSResults matching the include property of the theme.
184
+ * @param {Theme} theme
185
+ * @returns {CSSResult[]}
186
+ */
187
+ function getIncludedStyles(theme) {
188
+ const includedStyles = [];
189
+ if (theme.include) {
190
+ [].concat(theme.include).forEach((includeModuleId) => {
191
+ const includedTheme = getAllThemes().find((s) => s.moduleId === includeModuleId);
192
+ if (includedTheme) {
193
+ includedStyles.push(...getIncludedStyles(includedTheme), ...includedTheme.styles);
194
+ } else {
195
+ console.warn(`Included moduleId ${includeModuleId} not found in style registry`);
196
+ }
197
+ }, theme.styles);
198
+ }
199
+ return includedStyles;
200
+ }
201
+
202
+ /**
203
+ * Includes the styles to the template.
204
+ * @param {CSSResult[]} styles
205
+ * @param {HTMLTemplateElement} template
206
+ */
207
+ function addStylesToTemplate(styles, template) {
208
+ const styleEl = document.createElement('style');
209
+ styleEl.innerHTML = styles.map((style) => style.cssText).join('\n');
210
+ template.content.appendChild(styleEl);
211
+ }
212
+
213
+ /**
214
+ * Returns an array of themes that should be used for styling a component matching
215
+ * the tag name. The array is sorted by the include order.
216
+ * @param {string} tagName
217
+ * @returns {Theme[]}
218
+ */
219
+ function getThemes(tagName) {
220
+ const defaultModuleName = `${tagName}-default-theme`;
221
+
222
+ const themes = getAllThemes()
223
+ // Filter by matching themeFor properties
224
+ .filter((theme) => theme.moduleId !== defaultModuleName && matchesThemeFor(theme.themeFor, tagName))
225
+ .map((theme) => ({
226
+ ...theme,
227
+ // Prepend styles from included themes
228
+ styles: [...getIncludedStyles(theme), ...theme.styles],
229
+ // Map moduleId to includePriority
230
+ includePriority: getIncludePriority(theme.moduleId),
231
+ }))
232
+ // Sort by includePriority
233
+ .sort((themeA, themeB) => themeB.includePriority - themeA.includePriority);
234
+
235
+ if (themes.length > 0) {
236
+ return themes;
237
+ }
238
+ // No theme modules found, return the default module if it exists
239
+ return getAllThemes().filter((theme) => theme.moduleId === defaultModuleName);
240
+ }
241
+
242
+ /**
243
+ * @polymerMixin
244
+ * @mixes ThemePropertyMixin
245
+ */
246
+ const ThemableMixin = (superClass) =>
247
+ class VaadinThemableMixin extends ThemePropertyMixin(superClass) {
248
+ /**
249
+ * Covers PolymerElement based component styling
250
+ * @protected
251
+ */
252
+ static finalize() {
253
+ super.finalize();
254
+
255
+ // Make sure not to run the logic intended for PolymerElement when LitElement is used.
256
+ if (this.elementStyles) {
257
+ return;
258
+ }
259
+
260
+ const template = this.prototype._template;
261
+ if (!template || classHasThemes(this)) {
262
+ return;
263
+ }
264
+
265
+ addStylesToTemplate(this.getStylesForThis(), template);
266
+ }
267
+
268
+ /**
269
+ * Covers LitElement based component styling
270
+ *
271
+ * @protected
272
+ */
273
+ static finalizeStyles(styles) {
274
+ // The "styles" object originates from the "static get styles()" function of
275
+ // a LitElement based component. The theme styles are added after it
276
+ // so that they can override the component styles.
277
+ const themeStyles = this.getStylesForThis();
278
+ return styles ? [...super.finalizeStyles(styles), ...themeStyles] : themeStyles;
279
+ }
280
+
281
+ /**
282
+ * Get styles for the component type
283
+ *
284
+ * @private
285
+ */
286
+ static getStylesForThis() {
287
+ const parent = Object.getPrototypeOf(this.prototype);
288
+ const inheritedThemes = (parent ? parent.constructor.__themes : []) || [];
289
+ this.__themes = [...inheritedThemes, ...getThemes(this.is)];
290
+ const themeStyles = this.__themes.flatMap((theme) => theme.styles);
291
+ // Remove duplicates
292
+ return themeStyles.filter((style, index) => index === themeStyles.lastIndexOf(style));
293
+ }
294
+ };
2
295
 
3
296
  registerStyles(
4
297
  'vaadin-input-container',
5
298
  i`
6
299
  :host {
7
- border-radius: var(--lumo-border-radius-m);
8
300
  background-color: var(--lumo-contrast-10pct);
9
- padding: 0 calc(0.375em + var(--lumo-border-radius-m) / 4 - 1px);
301
+ padding: 0 calc(0.375em + var(--_input-container-radius) / 4 - 1px);
10
302
  font-weight: 500;
11
303
  line-height: 1;
12
304
  position: relative;
13
305
  cursor: text;
14
306
  box-sizing: border-box;
307
+ border-radius:
308
+ /* See https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius#syntax */
309
+ var(--vaadin-input-field-top-start-radius, var(--_input-container-radius))
310
+ var(--vaadin-input-field-top-end-radius, var(--_input-container-radius))
311
+ var(--vaadin-input-field-bottom-end-radius, var(--_input-container-radius))
312
+ var(--vaadin-input-field-bottom-start-radius, var(--_input-container-radius));
313
+ /* Fallback */
314
+ --_input-container-radius: var(--vaadin-input-field-border-radius, var(--lumo-border-radius-m));
315
+ /* Default field border color */
316
+ --_input-border-color: var(--vaadin-input-field-border-color, var(--lumo-contrast-50pct));
317
+ }
318
+
319
+ :host([dir='rtl']) {
320
+ border-radius:
321
+ /* Don't use logical props, see https://github.com/vaadin/vaadin-time-picker/issues/145 */
322
+ var(--vaadin-input-field-top-end-radius, var(--_input-container-radius))
323
+ var(--vaadin-input-field-top-start-radius, var(--_input-container-radius))
324
+ var(--vaadin-input-field-bottom-start-radius, var(--_input-container-radius))
325
+ var(--vaadin-input-field-bottom-end-radius, var(--_input-container-radius));
15
326
  }
16
327
 
17
328
  /* Used for hover and activation effects */
18
329
  :host::after {
19
330
  content: '';
20
331
  position: absolute;
21
- top: 0;
22
- right: 0;
23
- bottom: 0;
24
- left: 0;
332
+ inset: 0;
25
333
  border-radius: inherit;
26
334
  pointer-events: none;
27
335
  background-color: var(--lumo-contrast-50pct);
@@ -72,7 +380,6 @@ registerStyles(
72
380
  }
73
381
 
74
382
  /* Slotted icons */
75
- ::slotted(iron-icon),
76
383
  ::slotted(vaadin-icon) {
77
384
  color: var(--lumo-contrast-60pct);
78
385
  width: var(--lumo-icon-size-m);
@@ -80,7 +387,6 @@ registerStyles(
80
387
  }
81
388
 
82
389
  /* 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
390
  ::slotted(vaadin-icon[icon^='vaadin:']) {
85
391
  padding: 0.25em;
86
392
  box-sizing: border-box !important;
@@ -162,10 +468,184 @@ registerStyles(
162
468
 
163
469
  /**
164
470
  * @license
165
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
471
+ * Copyright (c) 2021 - 2023 Vaadin Ltd.
472
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
473
+ */
474
+ function defineCustomElement(CustomElement) {
475
+ const defined = customElements.get(CustomElement.is);
476
+ if (!defined) {
477
+ customElements.define(CustomElement.is, CustomElement);
478
+ } else {
479
+ const definedVersion = defined.version;
480
+ if (definedVersion && CustomElement.version && definedVersion === CustomElement.version) {
481
+ // Just loading the same thing again
482
+ console.warn(`The component ${CustomElement.is} has been loaded twice`);
483
+ } else {
484
+ console.error(
485
+ `Tried to define ${CustomElement.is} version ${CustomElement.version} when version ${defined.version} is already in use. Something will probably break.`,
486
+ );
487
+ }
488
+ }
489
+ }
490
+
491
+ /**
492
+ * @license
493
+ * Copyright (c) 2021 - 2023 Vaadin Ltd.
166
494
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
167
495
  */
168
496
 
497
+ /**
498
+ * Array of Vaadin custom element classes that have been subscribed to the dir changes.
499
+ */
500
+ const directionSubscribers = [];
501
+
502
+ function alignDirs(element, documentDir, elementDir = element.getAttribute('dir')) {
503
+ if (documentDir) {
504
+ element.setAttribute('dir', documentDir);
505
+ } else if (elementDir != null) {
506
+ element.removeAttribute('dir');
507
+ }
508
+ }
509
+
510
+ function getDocumentDir() {
511
+ return document.documentElement.getAttribute('dir');
512
+ }
513
+
514
+ function directionUpdater() {
515
+ const documentDir = getDocumentDir();
516
+ directionSubscribers.forEach((element) => {
517
+ alignDirs(element, documentDir);
518
+ });
519
+ }
520
+
521
+ const directionObserver = new MutationObserver(directionUpdater);
522
+ directionObserver.observe(document.documentElement, { attributes: true, attributeFilter: ['dir'] });
523
+
524
+ /**
525
+ * A mixin to handle `dir` attribute based on the one set on the `<html>` element.
526
+ *
527
+ * @polymerMixin
528
+ */
529
+ const DirMixin = (superClass) =>
530
+ class VaadinDirMixin extends superClass {
531
+ static get properties() {
532
+ return {
533
+ /**
534
+ * @protected
535
+ */
536
+ dir: {
537
+ type: String,
538
+ value: '',
539
+ reflectToAttribute: true,
540
+ converter: {
541
+ fromAttribute: (attr) => {
542
+ return !attr ? '' : attr;
543
+ },
544
+ toAttribute: (prop) => {
545
+ return prop === '' ? null : prop;
546
+ },
547
+ },
548
+ },
549
+ };
550
+ }
551
+
552
+ /**
553
+ * @return {boolean}
554
+ * @protected
555
+ */
556
+ get __isRTL() {
557
+ return this.getAttribute('dir') === 'rtl';
558
+ }
559
+
560
+ /** @protected */
561
+ connectedCallback() {
562
+ super.connectedCallback();
563
+
564
+ if (!this.hasAttribute('dir') || this.__restoreSubscription) {
565
+ this.__subscribe();
566
+ alignDirs(this, getDocumentDir(), null);
567
+ }
568
+ }
569
+
570
+ /** @protected */
571
+ attributeChangedCallback(name, oldValue, newValue) {
572
+ super.attributeChangedCallback(name, oldValue, newValue);
573
+ if (name !== 'dir') {
574
+ return;
575
+ }
576
+
577
+ const documentDir = getDocumentDir();
578
+
579
+ // New value equals to the document direction and the element is not subscribed to the changes
580
+ const newValueEqlDocDir = newValue === documentDir && directionSubscribers.indexOf(this) === -1;
581
+ // Value was emptied and the element is not subscribed to the changes
582
+ const newValueEmptied = !newValue && oldValue && directionSubscribers.indexOf(this) === -1;
583
+ // New value is different and the old equals to document direction and the element is not subscribed to the changes
584
+ const newDiffValue = newValue !== documentDir && oldValue === documentDir;
585
+
586
+ if (newValueEqlDocDir || newValueEmptied) {
587
+ this.__subscribe();
588
+ alignDirs(this, documentDir, newValue);
589
+ } else if (newDiffValue) {
590
+ this.__unsubscribe();
591
+ }
592
+ }
593
+
594
+ /** @protected */
595
+ disconnectedCallback() {
596
+ super.disconnectedCallback();
597
+ this.__restoreSubscription = directionSubscribers.includes(this);
598
+ this.__unsubscribe();
599
+ }
600
+
601
+ /** @protected */
602
+ _valueToNodeAttribute(node, value, attribute) {
603
+ // Override default Polymer attribute reflection to match native behavior of HTMLElement.dir property
604
+ // If the property contains an empty string then it should not create an empty attribute
605
+ if (attribute === 'dir' && value === '' && !node.hasAttribute('dir')) {
606
+ return;
607
+ }
608
+ super._valueToNodeAttribute(node, value, attribute);
609
+ }
610
+
611
+ /** @protected */
612
+ _attributeToProperty(attribute, value, type) {
613
+ // Override default Polymer attribute reflection to match native behavior of HTMLElement.dir property
614
+ // If the attribute is removed, then the dir property should contain an empty string instead of null
615
+ if (attribute === 'dir' && !value) {
616
+ this.dir = '';
617
+ } else {
618
+ super._attributeToProperty(attribute, value, type);
619
+ }
620
+ }
621
+
622
+ /** @private */
623
+ __subscribe() {
624
+ if (!directionSubscribers.includes(this)) {
625
+ directionSubscribers.push(this);
626
+ }
627
+ }
628
+
629
+ /** @private */
630
+ __unsubscribe() {
631
+ if (directionSubscribers.includes(this)) {
632
+ directionSubscribers.splice(directionSubscribers.indexOf(this), 1);
633
+ }
634
+ }
635
+ };
636
+
637
+ /**
638
+ * @license
639
+ * Copyright (c) 2021 - 2023 Vaadin Ltd.
640
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
641
+ */
642
+
643
+ /**
644
+ * @customElement
645
+ * @extends HTMLElement
646
+ * @mixes ThemableMixin
647
+ * @mixes DirMixin
648
+ */
169
649
  class InputContainer extends ThemableMixin(DirMixin(PolymerElement)) {
170
650
  static get is() {
171
651
  return 'vaadin-input-container';
@@ -178,6 +658,25 @@ class InputContainer extends ThemableMixin(DirMixin(PolymerElement)) {
178
658
  display: flex;
179
659
  align-items: center;
180
660
  flex: 0 1 auto;
661
+ border-radius:
662
+ /* See https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius */
663
+ var(--vaadin-input-field-top-start-radius, var(--__border-radius))
664
+ var(--vaadin-input-field-top-end-radius, var(--__border-radius))
665
+ var(--vaadin-input-field-bottom-end-radius, var(--__border-radius))
666
+ var(--vaadin-input-field-bottom-start-radius, var(--__border-radius));
667
+ --_border-radius: var(--vaadin-input-field-border-radius, 0px);
668
+ --_input-border-width: var(--vaadin-input-field-border-width, 0);
669
+ --_input-border-color: var(--vaadin-input-field-border-color, transparent);
670
+ box-shadow: inset 0 0 0 var(--_input-border-width, 0) var(--_input-border-color);
671
+ }
672
+
673
+ :host([dir='rtl']) {
674
+ border-radius:
675
+ /* Don't use logical props, see https://github.com/vaadin/vaadin-time-picker/issues/145 */
676
+ var(--vaadin-input-field-top-end-radius, var(--_border-radius))
677
+ var(--vaadin-input-field-top-start-radius, var(--_border-radius))
678
+ var(--vaadin-input-field-bottom-start-radius, var(--_border-radius))
679
+ var(--vaadin-input-field-bottom-end-radius, var(--_border-radius));
181
680
  }
182
681
 
183
682
  :host([hidden]) {
@@ -278,47 +777,11 @@ class InputContainer extends ThemableMixin(DirMixin(PolymerElement)) {
278
777
  }
279
778
  }
280
779
 
281
- customElements.define(InputContainer.is, InputContainer);
282
-
283
- /**
284
- * @license
285
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
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
- })();
780
+ defineCustomElement(InputContainer);
318
781
 
319
782
  /**
320
783
  * @license
321
- * Copyright (c) 2017 - 2022 Vaadin Ltd.
784
+ * Copyright (c) 2017 - 2023 Vaadin Ltd.
322
785
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
323
786
  */
324
787
 
@@ -350,11 +813,11 @@ const fieldButton = i`
350
813
  display: block;
351
814
  }
352
815
  `;
353
- registerStyles('', fieldButton, { moduleId: 'lumo-field-button' });
816
+ registerStyles$1('', fieldButton, { moduleId: 'lumo-field-button' });
354
817
 
355
818
  /**
356
819
  * @license
357
- * Copyright (c) 2017 - 2022 Vaadin Ltd.
820
+ * Copyright (c) 2017 - 2023 Vaadin Ltd.
358
821
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
359
822
  */
360
823
 
@@ -430,9 +893,15 @@ const inputField = i`
430
893
  opacity: 0;
431
894
  }
432
895
 
896
+ /* Read-only style */
897
+ :host([readonly]) {
898
+ --vaadin-input-field-border-color: transparent;
899
+ }
900
+
433
901
  /* Disabled style */
434
902
  :host([disabled]) {
435
903
  pointer-events: none;
904
+ --vaadin-input-field-border-color: var(--lumo-contrast-20pct);
436
905
  }
437
906
 
438
907
  :host([disabled]) [part='label'],
@@ -442,6 +911,10 @@ const inputField = i`
442
911
  }
443
912
 
444
913
  /* Invalid style */
914
+ :host([invalid]) {
915
+ --vaadin-input-field-border-color: var(--lumo-error-color);
916
+ }
917
+
445
918
  :host([invalid][focus-ring]) [part='input-field'] {
446
919
  box-shadow: 0 0 0 2px var(--lumo-error-color-50pct);
447
920
  }
@@ -450,49 +923,464 @@ const inputField = i`
450
923
  animation: shake 0.15s infinite;
451
924
  }
452
925
 
453
- @keyframes shake {
454
- 25% {
455
- transform: translateX(4px);
926
+ @keyframes shake {
927
+ 25% {
928
+ transform: translateX(4px);
929
+ }
930
+ 75% {
931
+ transform: translateX(-4px);
932
+ }
933
+ }
934
+
935
+ /* Small theme */
936
+ :host([theme~='small']) {
937
+ font-size: var(--lumo-font-size-s);
938
+ --lumo-text-field-size: var(--lumo-size-s);
939
+ }
940
+
941
+ :host([theme~='small']) [part='label'] {
942
+ font-size: var(--lumo-font-size-xs);
943
+ }
944
+
945
+ :host([theme~='small']) [part='error-message'] {
946
+ font-size: var(--lumo-font-size-xxs);
947
+ }
948
+
949
+ /* Slotted content */
950
+ [part='input-field'] ::slotted(:not(vaadin-icon):not(input):not(textarea)) {
951
+ color: var(--lumo-secondary-text-color);
952
+ font-weight: 400;
953
+ }
954
+
955
+ [part='clear-button']::before {
956
+ content: var(--lumo-icons-cross);
957
+ }
958
+ `;
959
+
960
+ const inputFieldShared$1 = [requiredField, fieldButton, helper, inputField];
961
+
962
+ registerStyles$1('', inputFieldShared$1, {
963
+ moduleId: 'lumo-input-field-shared-styles',
964
+ });
965
+
966
+ /**
967
+ * @license
968
+ * Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
969
+ * This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
970
+ * The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
971
+ * The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
972
+ * Code distributed by Google as part of the polymer project is also
973
+ * subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
974
+ */
975
+
976
+ /**
977
+ * Async interface wrapper around `setTimeout`.
978
+ *
979
+ * @namespace
980
+ * @summary Async interface wrapper around `setTimeout`.
981
+ */
982
+ const timeOut = {
983
+ /**
984
+ * Returns a sub-module with the async interface providing the provided
985
+ * delay.
986
+ *
987
+ * @memberof timeOut
988
+ * @param {number=} delay Time to wait before calling callbacks in ms
989
+ * @return {!AsyncInterface} An async timeout interface
990
+ */
991
+ after(delay) {
992
+ return {
993
+ run(fn) {
994
+ return window.setTimeout(fn, delay);
995
+ },
996
+ cancel(handle) {
997
+ window.clearTimeout(handle);
998
+ },
999
+ };
1000
+ },
1001
+ /**
1002
+ * Enqueues a function called in the next task.
1003
+ *
1004
+ * @memberof timeOut
1005
+ * @param {!Function} fn Callback to run
1006
+ * @param {number=} delay Delay in milliseconds
1007
+ * @return {number} Handle used for canceling task
1008
+ */
1009
+ run(fn, delay) {
1010
+ return window.setTimeout(fn, delay);
1011
+ },
1012
+ /**
1013
+ * Cancels a previously enqueued `timeOut` callback.
1014
+ *
1015
+ * @memberof timeOut
1016
+ * @param {number} handle Handle returned from `run` of callback to cancel
1017
+ * @return {void}
1018
+ */
1019
+ cancel(handle) {
1020
+ window.clearTimeout(handle);
1021
+ },
1022
+ };
1023
+
1024
+ /**
1025
+ @license
1026
+ Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
1027
+ This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
1028
+ The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
1029
+ The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
1030
+ Code distributed by Google as part of the polymer project is also
1031
+ subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
1032
+ */
1033
+
1034
+ const debouncerQueue = new Set();
1035
+
1036
+ /**
1037
+ * @summary Collapse multiple callbacks into one invocation after a timer.
1038
+ */
1039
+ class Debouncer {
1040
+ /**
1041
+ * Creates a debouncer if no debouncer is passed as a parameter
1042
+ * or it cancels an active debouncer otherwise. The following
1043
+ * example shows how a debouncer can be called multiple times within a
1044
+ * microtask and "debounced" such that the provided callback function is
1045
+ * called once. Add this method to a custom element:
1046
+ *
1047
+ * ```js
1048
+ * import {microTask} from '@vaadin/component-base/src/async.js';
1049
+ * import {Debouncer} from '@vaadin/component-base/src/debounce.js';
1050
+ * // ...
1051
+ *
1052
+ * _debounceWork() {
1053
+ * this._debounceJob = Debouncer.debounce(this._debounceJob,
1054
+ * microTask, () => this._doWork());
1055
+ * }
1056
+ * ```
1057
+ *
1058
+ * If the `_debounceWork` method is called multiple times within the same
1059
+ * microtask, the `_doWork` function will be called only once at the next
1060
+ * microtask checkpoint.
1061
+ *
1062
+ * Note: In testing it is often convenient to avoid asynchrony. To accomplish
1063
+ * this with a debouncer, you can use `enqueueDebouncer` and
1064
+ * `flush`. For example, extend the above example by adding
1065
+ * `enqueueDebouncer(this._debounceJob)` at the end of the
1066
+ * `_debounceWork` method. Then in a test, call `flush` to ensure
1067
+ * the debouncer has completed.
1068
+ *
1069
+ * @param {Debouncer?} debouncer Debouncer object.
1070
+ * @param {!AsyncInterface} asyncModule Object with Async interface
1071
+ * @param {function()} callback Callback to run.
1072
+ * @return {!Debouncer} Returns a debouncer object.
1073
+ */
1074
+ static debounce(debouncer, asyncModule, callback) {
1075
+ if (debouncer instanceof Debouncer) {
1076
+ // Cancel the async callback, but leave in debouncerQueue if it was
1077
+ // enqueued, to maintain 1.x flush order
1078
+ debouncer._cancelAsync();
1079
+ } else {
1080
+ debouncer = new Debouncer();
1081
+ }
1082
+ debouncer.setConfig(asyncModule, callback);
1083
+ return debouncer;
1084
+ }
1085
+
1086
+ constructor() {
1087
+ this._asyncModule = null;
1088
+ this._callback = null;
1089
+ this._timer = null;
1090
+ }
1091
+
1092
+ /**
1093
+ * Sets the scheduler; that is, a module with the Async interface,
1094
+ * a callback and optional arguments to be passed to the run function
1095
+ * from the async module.
1096
+ *
1097
+ * @param {!AsyncInterface} asyncModule Object with Async interface.
1098
+ * @param {function()} callback Callback to run.
1099
+ * @return {void}
1100
+ */
1101
+ setConfig(asyncModule, callback) {
1102
+ this._asyncModule = asyncModule;
1103
+ this._callback = callback;
1104
+ this._timer = this._asyncModule.run(() => {
1105
+ this._timer = null;
1106
+ debouncerQueue.delete(this);
1107
+ this._callback();
1108
+ });
1109
+ }
1110
+
1111
+ /**
1112
+ * Cancels an active debouncer and returns a reference to itself.
1113
+ *
1114
+ * @return {void}
1115
+ */
1116
+ cancel() {
1117
+ if (this.isActive()) {
1118
+ this._cancelAsync();
1119
+ // Canceling a debouncer removes its spot from the flush queue,
1120
+ // so if a debouncer is manually canceled and re-debounced, it
1121
+ // will reset its flush order (this is a very minor difference from 1.x)
1122
+ // Re-debouncing via the `debounce` API retains the 1.x FIFO flush order
1123
+ debouncerQueue.delete(this);
1124
+ }
1125
+ }
1126
+
1127
+ /**
1128
+ * Cancels a debouncer's async callback.
1129
+ *
1130
+ * @return {void}
1131
+ */
1132
+ _cancelAsync() {
1133
+ if (this.isActive()) {
1134
+ this._asyncModule.cancel(/** @type {number} */ (this._timer));
1135
+ this._timer = null;
1136
+ }
1137
+ }
1138
+
1139
+ /**
1140
+ * Flushes an active debouncer and returns a reference to itself.
1141
+ *
1142
+ * @return {void}
1143
+ */
1144
+ flush() {
1145
+ if (this.isActive()) {
1146
+ this.cancel();
1147
+ this._callback();
1148
+ }
1149
+ }
1150
+
1151
+ /**
1152
+ * Returns true if the debouncer is active.
1153
+ *
1154
+ * @return {boolean} True if active.
1155
+ */
1156
+ isActive() {
1157
+ return this._timer != null;
1158
+ }
1159
+ }
1160
+
1161
+ /**
1162
+ * @license
1163
+ * Copyright (c) 2021 - 2023 Vaadin Ltd.
1164
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
1165
+ */
1166
+
1167
+ const stylesMap = new WeakMap();
1168
+
1169
+ /**
1170
+ * Get all the styles inserted into root.
1171
+ * @param {DocumentOrShadowRoot} root
1172
+ * @return {Set<string>}
1173
+ */
1174
+ function getRootStyles(root) {
1175
+ if (!stylesMap.has(root)) {
1176
+ stylesMap.set(root, new Set());
1177
+ }
1178
+
1179
+ return stylesMap.get(root);
1180
+ }
1181
+
1182
+ /**
1183
+ * Insert styles into the root.
1184
+ * @param {string} styles
1185
+ * @param {DocumentOrShadowRoot} root
1186
+ */
1187
+ function insertStyles(styles, root) {
1188
+ const style = document.createElement('style');
1189
+ style.textContent = styles;
1190
+
1191
+ if (root === document) {
1192
+ document.head.appendChild(style);
1193
+ } else {
1194
+ root.insertBefore(style, root.firstChild);
1195
+ }
1196
+ }
1197
+
1198
+ /**
1199
+ * Mixin to insert styles into the outer scope to handle slotted components.
1200
+ * This is useful e.g. to hide native `<input type="number">` controls.
1201
+ *
1202
+ * @polymerMixin
1203
+ */
1204
+ const SlotStylesMixin = dedupingMixin(
1205
+ (superclass) =>
1206
+ class SlotStylesMixinClass extends superclass {
1207
+ /**
1208
+ * List of styles to insert into root.
1209
+ * @protected
1210
+ */
1211
+ get slotStyles() {
1212
+ return {};
1213
+ }
1214
+
1215
+ /** @protected */
1216
+ connectedCallback() {
1217
+ super.connectedCallback();
1218
+
1219
+ this.__applySlotStyles();
1220
+ }
1221
+
1222
+ /** @private */
1223
+ __applySlotStyles() {
1224
+ const root = this.getRootNode();
1225
+ const rootStyles = getRootStyles(root);
1226
+
1227
+ this.slotStyles.forEach((styles) => {
1228
+ if (!rootStyles.has(styles)) {
1229
+ insertStyles(styles, root);
1230
+ rootStyles.add(styles);
1231
+ }
1232
+ });
1233
+ }
1234
+ },
1235
+ );
1236
+
1237
+ /**
1238
+ * @license
1239
+ * Copyright (c) 2021 - 2023 Vaadin Ltd.
1240
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
1241
+ */
1242
+
1243
+ const testUserAgent = (regexp) => regexp.test(navigator.userAgent);
1244
+
1245
+ const testPlatform = (regexp) => regexp.test(navigator.platform);
1246
+
1247
+ const testVendor = (regexp) => regexp.test(navigator.vendor);
1248
+
1249
+ testUserAgent(/Android/u);
1250
+
1251
+ testUserAgent(/Chrome/u) && testVendor(/Google Inc/u);
1252
+
1253
+ testUserAgent(/Firefox/u);
1254
+
1255
+ // IPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.
1256
+ testPlatform(/^iPad/u) || (testPlatform(/^Mac/u) && navigator.maxTouchPoints > 1);
1257
+
1258
+ testPlatform(/^iPhone/u);
1259
+
1260
+ testUserAgent(/^((?!chrome|android).)*safari/iu);
1261
+
1262
+ const isTouch = (() => {
1263
+ try {
1264
+ document.createEvent('TouchEvent');
1265
+ return true;
1266
+ } catch (e) {
1267
+ return false;
1268
+ }
1269
+ })();
1270
+
1271
+ /**
1272
+ * @license
1273
+ * Copyright (c) 2021 - 2023 Vaadin Ltd.
1274
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
1275
+ */
1276
+
1277
+ /**
1278
+ * A mixin that manages the clear button.
1279
+ *
1280
+ * @polymerMixin
1281
+ * @mixes InputMixin
1282
+ * @mixes KeyboardMixin
1283
+ */
1284
+ const ClearButtonMixin = (superclass) =>
1285
+ class ClearButtonMixinClass extends InputMixin(KeyboardMixin(superclass)) {
1286
+ static get properties() {
1287
+ return {
1288
+ /**
1289
+ * Set to true to display the clear icon which clears the input.
1290
+ *
1291
+ * It is up to the component to choose where to place the clear icon:
1292
+ * in the Shadow DOM or in the light DOM. In any way, a reference to
1293
+ * the clear icon element should be provided via the `clearElement` getter.
1294
+ *
1295
+ * @attr {boolean} clear-button-visible
1296
+ */
1297
+ clearButtonVisible: {
1298
+ type: Boolean,
1299
+ reflectToAttribute: true,
1300
+ value: false,
1301
+ },
1302
+ };
456
1303
  }
457
- 75% {
458
- transform: translateX(-4px);
1304
+
1305
+ /**
1306
+ * Any element extending this mixin is required to implement this getter.
1307
+ * It returns the reference to the clear button element.
1308
+ *
1309
+ * @protected
1310
+ * @return {Element | null | undefined}
1311
+ */
1312
+ get clearElement() {
1313
+ console.warn(`Please implement the 'clearElement' property in <${this.localName}>`);
1314
+ return null;
459
1315
  }
460
- }
461
1316
 
462
- /* Small theme */
463
- :host([theme~='small']) {
464
- font-size: var(--lumo-font-size-s);
465
- --lumo-text-field-size: var(--lumo-size-s);
466
- }
1317
+ /** @protected */
1318
+ ready() {
1319
+ super.ready();
467
1320
 
468
- :host([theme~='small']) [part='label'] {
469
- font-size: var(--lumo-font-size-xs);
470
- }
1321
+ if (this.clearElement) {
1322
+ this.clearElement.addEventListener('mousedown', (event) => this._onClearButtonMouseDown(event));
1323
+ this.clearElement.addEventListener('click', (event) => this._onClearButtonClick(event));
1324
+ }
1325
+ }
471
1326
 
472
- :host([theme~='small']) [part='error-message'] {
473
- font-size: var(--lumo-font-size-xxs);
474
- }
1327
+ /**
1328
+ * @param {Event} event
1329
+ * @protected
1330
+ */
1331
+ _onClearButtonClick(event) {
1332
+ event.preventDefault();
1333
+ this._onClearAction();
1334
+ }
475
1335
 
476
- /* Slotted content */
477
- [part='input-field'] ::slotted(:not(iron-icon):not(vaadin-icon):not(input):not(textarea)) {
478
- color: var(--lumo-secondary-text-color);
479
- font-weight: 400;
480
- }
1336
+ /**
1337
+ * @param {MouseEvent} event
1338
+ * @protected
1339
+ */
1340
+ _onClearButtonMouseDown(event) {
1341
+ event.preventDefault();
1342
+ if (!isTouch) {
1343
+ this.inputElement.focus();
1344
+ }
1345
+ }
481
1346
 
482
- [part='clear-button']::before {
483
- content: var(--lumo-icons-cross);
484
- }
485
- `;
1347
+ /**
1348
+ * Override an event listener inherited from `KeydownMixin` to clear on Esc.
1349
+ * Components that extend this mixin can prevent this behavior by overriding
1350
+ * this method without calling `super._onEscape` to provide custom logic.
1351
+ *
1352
+ * @param {KeyboardEvent} event
1353
+ * @protected
1354
+ * @override
1355
+ */
1356
+ _onEscape(event) {
1357
+ super._onEscape(event);
486
1358
 
487
- const inputFieldShared$1 = [requiredField, fieldButton, helper, inputField];
1359
+ if (this.clearButtonVisible && !!this.value) {
1360
+ event.stopPropagation();
1361
+ this._onClearAction();
1362
+ }
1363
+ }
488
1364
 
489
- registerStyles('', inputFieldShared$1, {
490
- moduleId: 'lumo-input-field-shared-styles',
491
- });
1365
+ /**
1366
+ * Clears the value and dispatches `input` and `change` events
1367
+ * on the input element. This method should be called
1368
+ * when the clear action originates from the user.
1369
+ *
1370
+ * @protected
1371
+ */
1372
+ _onClearAction() {
1373
+ this.clear();
1374
+ // Note, according to the HTML spec, the native change event isn't composed
1375
+ // while the input event is composed.
1376
+ this.inputElement.dispatchEvent(new Event('input', { bubbles: true, composed: true }));
1377
+ this.inputElement.dispatchEvent(new Event('change', { bubbles: true }));
1378
+ }
1379
+ };
492
1380
 
493
1381
  /**
494
1382
  * @license
495
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
1383
+ * Copyright (c) 2021 - 2023 Vaadin Ltd.
496
1384
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
497
1385
  */
498
1386
 
@@ -620,83 +1508,7 @@ const InputConstraintsMixin = dedupingMixin(
620
1508
 
621
1509
  /**
622
1510
  * @license
623
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
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.
1511
+ * Copyright (c) 2021 - 2023 Vaadin Ltd.
700
1512
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
701
1513
  */
702
1514
 
@@ -708,11 +1520,12 @@ const SlotStylesMixin = dedupingMixin(
708
1520
  * @mixes FieldMixin
709
1521
  * @mixes InputConstraintsMixin
710
1522
  * @mixes KeyboardMixin
1523
+ * @mixes ClearButtonMixin
711
1524
  * @mixes SlotStylesMixin
712
1525
  */
713
1526
  const InputControlMixin = (superclass) =>
714
1527
  class InputControlMixinClass extends SlotStylesMixin(
715
- DelegateFocusMixin(InputConstraintsMixin(FieldMixin(KeyboardMixin(superclass)))),
1528
+ DelegateFocusMixin(InputConstraintsMixin(FieldMixin(ClearButtonMixin(KeyboardMixin(superclass))))),
716
1529
  ) {
717
1530
  static get properties() {
718
1531
  return {
@@ -741,16 +1554,6 @@ const InputControlMixin = (superclass) =>
741
1554
  value: false,
742
1555
  },
743
1556
 
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
1557
  /**
755
1558
  * The name of this field.
756
1559
  */
@@ -798,17 +1601,6 @@ const InputControlMixin = (superclass) =>
798
1601
  this._boundOnBeforeInput = this._onBeforeInput.bind(this);
799
1602
  }
800
1603
 
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
1604
  /** @protected */
813
1605
  get slotStyles() {
814
1606
  // Needed for Safari, where ::slotted(...)::placeholder does not work
@@ -822,36 +1614,6 @@ const InputControlMixin = (superclass) =>
822
1614
  ];
823
1615
  }
824
1616
 
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
1617
  /**
856
1618
  * Override an event listener from `DelegateFocusMixin`.
857
1619
  * @param {FocusEvent} event
@@ -866,23 +1628,6 @@ const InputControlMixin = (superclass) =>
866
1628
  }
867
1629
  }
868
1630
 
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
1631
  /**
887
1632
  * Override an event listener inherited from `InputMixin`
888
1633
  * to capture native `change` event and make sure that
@@ -907,13 +1652,6 @@ const InputControlMixin = (superclass) =>
907
1652
  );
908
1653
  }
909
1654
 
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
1655
  /**
918
1656
  * Override a method from `InputMixin`.
919
1657
  * @param {!HTMLElement} input
@@ -1015,8 +1753,8 @@ const InputControlMixin = (superclass) =>
1015
1753
  _allowedCharPatternChanged(charPattern) {
1016
1754
  if (charPattern) {
1017
1755
  try {
1018
- this.__allowedCharRegExp = new RegExp(`^${charPattern}$`);
1019
- this.__allowedTextRegExp = new RegExp(`^${charPattern}*$`);
1756
+ this.__allowedCharRegExp = new RegExp(`^${charPattern}$`, 'u');
1757
+ this.__allowedTextRegExp = new RegExp(`^${charPattern}*$`, 'u');
1020
1758
  } catch (e) {
1021
1759
  console.error(e);
1022
1760
  }
@@ -1039,7 +1777,7 @@ const InputControlMixin = (superclass) =>
1039
1777
 
1040
1778
  /**
1041
1779
  * @license
1042
- * Copyright (c) 2021 - 2022 Vaadin Ltd..
1780
+ * Copyright (c) 2021 - 2023 Vaadin Ltd..
1043
1781
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
1044
1782
  */
1045
1783
 
@@ -1050,7 +1788,7 @@ const clearButton = i`
1050
1788
  }
1051
1789
 
1052
1790
  [part='clear-button']::before {
1053
- content: '';
1791
+ content: '\\2715';
1054
1792
  }
1055
1793
 
1056
1794
  :host([clear-button-visible][has-value]:not([disabled]):not([readonly])) [part='clear-button'] {
@@ -1060,7 +1798,7 @@ const clearButton = i`
1060
1798
 
1061
1799
  /**
1062
1800
  * @license
1063
- * Copyright (c) 2021 - 2022 Vaadin Ltd..
1801
+ * Copyright (c) 2021 - 2023 Vaadin Ltd..
1064
1802
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
1065
1803
  */
1066
1804
 
@@ -1085,11 +1823,24 @@ const fieldShared = i`
1085
1823
  :host(:not([has-label])) [part='label'] {
1086
1824
  display: none;
1087
1825
  }
1826
+
1827
+ @media (forced-colors: active) {
1828
+ :host(:not([readonly])) [part='input-field'] {
1829
+ outline: 1px solid;
1830
+ outline-offset: -1px;
1831
+ }
1832
+ :host([focused]) [part='input-field'] {
1833
+ outline-width: 2px;
1834
+ }
1835
+ :host([disabled]) [part='input-field'] {
1836
+ outline-color: GrayText;
1837
+ }
1838
+ }
1088
1839
  `;
1089
1840
 
1090
1841
  /**
1091
1842
  * @license
1092
- * Copyright (c) 2021 - 2022 Vaadin Ltd..
1843
+ * Copyright (c) 2021 - 2023 Vaadin Ltd..
1093
1844
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
1094
1845
  */
1095
1846
 
@@ -1105,10 +1856,10 @@ const inputFieldContainer = i`
1105
1856
 
1106
1857
  /**
1107
1858
  * @license
1108
- * Copyright (c) 2021 - 2022 Vaadin Ltd..
1859
+ * Copyright (c) 2021 - 2023 Vaadin Ltd..
1109
1860
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
1110
1861
  */
1111
1862
 
1112
1863
  const inputFieldShared = [fieldShared, inputFieldContainer, clearButton];
1113
1864
 
1114
- export { InputConstraintsMixin as I, isFirefox as a, isIOS as b, InputControlMixin as c, inputFieldShared as d, isSafari as e, isTouch as f, inputFieldShared$1 as i };
1865
+ export { InputConstraintsMixin as I, InputControlMixin as a, inputFieldShared as b, inputFieldShared$1 as i };