@everymatrix/helper-filters 0.1.5 → 0.1.20

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.
@@ -2,8 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-0c5bb1ff.js');
6
- require('@everymatrix/helper-modal');
5
+ const index = require('./index-4be1aa12.js');
7
6
 
8
7
  const DEFAULT_LANGUAGE = 'en';
9
8
  const SUPPORTED_LANGUAGES = ['ro', 'en'];
@@ -45,7 +44,7 @@ const translate$1 = (key, customLang) => {
45
44
  */
46
45
  class Lumo extends HTMLElement {
47
46
  static get version() {
48
- return '23.2.0';
47
+ return '23.1.5';
49
48
  }
50
49
  }
51
50
 
@@ -101,7 +100,7 @@ const ThemePropertyMixin = (superClass) =>
101
100
  * **NOTE:** Extending the mixin only provides the property for binding,
102
101
  * and does not make the propagation alone.
103
102
  *
104
- * See [Styling Components: Sub-components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components/#sub-components).
103
+ * See [Styling Components: Sub-components](https://vaadin.com/docs/latest/ds/customization/styling-components/#sub-components).
105
104
  * page for more information.
106
105
  *
107
106
  * @deprecated The `theme` property is not supposed for public use and will be dropped in Vaadin 24.
@@ -126,7 +125,7 @@ const ThemePropertyMixin = (superClass) =>
126
125
  * **NOTE:** Extending the mixin only provides the property for binding,
127
126
  * and does not make the propagation alone.
128
127
  *
129
- * See [Styling Components: Sub-components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components/#sub-components).
128
+ * See [Styling Components: Sub-components](https://vaadin.com/docs/latest/ds/customization/styling-components/#sub-components).
130
129
  * page for more information.
131
130
  *
132
131
  * @protected
@@ -231,9 +230,9 @@ function matchesThemeFor(themeFor, tagName) {
231
230
  */
232
231
  function getIncludePriority(moduleName = '') {
233
232
  let includePriority = 0;
234
- if (moduleName.startsWith('lumo-') || moduleName.startsWith('material-')) {
233
+ if (moduleName.indexOf('lumo-') === 0 || moduleName.indexOf('material-') === 0) {
235
234
  includePriority = 1;
236
- } else if (moduleName.startsWith('vaadin-')) {
235
+ } else if (moduleName.indexOf('vaadin-') === 0) {
237
236
  includePriority = 2;
238
237
  }
239
238
  return includePriority;
@@ -10118,38 +10117,6 @@ const ControllerMixin = dedupingMixin(
10118
10117
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
10119
10118
  */
10120
10119
 
10121
- // We consider the keyboard to be active if the window has received a keydown
10122
- // event since the last mousedown event.
10123
- let keyboardActive = false;
10124
-
10125
- // Listen for top-level keydown and mousedown events.
10126
- // Use capture phase so we detect events even if they're handled.
10127
- window.addEventListener(
10128
- 'keydown',
10129
- () => {
10130
- keyboardActive = true;
10131
- },
10132
- { capture: true },
10133
- );
10134
-
10135
- window.addEventListener(
10136
- 'mousedown',
10137
- () => {
10138
- keyboardActive = false;
10139
- },
10140
- { capture: true },
10141
- );
10142
-
10143
- /**
10144
- * Returns true if the window has received a keydown
10145
- * event since the last mousedown event.
10146
- *
10147
- * @return {boolean}
10148
- */
10149
- function isKeyboardActive() {
10150
- return keyboardActive;
10151
- }
10152
-
10153
10120
  /**
10154
10121
  * Returns true if the element is hidden directly with `display: none` or `visibility: hidden`,
10155
10122
  * false otherwise.
@@ -10590,7 +10557,7 @@ class FocusTrapController {
10590
10557
  * ---|---|---
10591
10558
  * `--vaadin-overlay-viewport-bottom` | Bottom offset of the visible viewport area | `0` or detected offset
10592
10559
  *
10593
- * See [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.
10560
+ * See [Styling Components](https://vaadin.com/docs/latest/ds/customization/styling-components) documentation.
10594
10561
  *
10595
10562
  * @fires {CustomEvent} opened-changed - Fired when the `opened` property changes.
10596
10563
  * @fires {CustomEvent} vaadin-overlay-open - Fired after the overlay is opened.
@@ -12860,7 +12827,7 @@ const registered = new Set();
12860
12827
  const ElementMixin = (superClass) =>
12861
12828
  class VaadinElementMixin extends DirMixin(superClass) {
12862
12829
  static get version() {
12863
- return '23.2.0';
12830
+ return '23.1.5';
12864
12831
  }
12865
12832
 
12866
12833
  /** @protected */
@@ -13158,7 +13125,7 @@ function _handleNative(ev) {
13158
13125
  }
13159
13126
  if (!ev[HANDLED_OBJ]) {
13160
13127
  ev[HANDLED_OBJ] = {};
13161
- if (type.startsWith('touch')) {
13128
+ if (type.slice(0, 5) === 'touch') {
13162
13129
  const t = ev.changedTouches[0];
13163
13130
  if (type === 'touchstart') {
13164
13131
  // Only handle the first finger
@@ -14017,6 +13984,28 @@ const ActiveMixin = (superclass) =>
14017
13984
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
14018
13985
  */
14019
13986
 
13987
+ // We consider the keyboard to be active if the window has received a keydown
13988
+ // event since the last mousedown event.
13989
+ let keyboardActive = false;
13990
+
13991
+ // Listen for top-level keydown and mousedown events.
13992
+ // Use capture phase so we detect events even if they're handled.
13993
+ window.addEventListener(
13994
+ 'keydown',
13995
+ () => {
13996
+ keyboardActive = true;
13997
+ },
13998
+ { capture: true },
13999
+ );
14000
+
14001
+ window.addEventListener(
14002
+ 'mousedown',
14003
+ () => {
14004
+ keyboardActive = false;
14005
+ },
14006
+ { capture: true },
14007
+ );
14008
+
14020
14009
  /**
14021
14010
  * A mixin to handle `focused` and `focus-ring` attributes based on focus.
14022
14011
  *
@@ -14030,7 +14019,7 @@ const FocusMixin = dedupingMixin(
14030
14019
  * @return {boolean}
14031
14020
  */
14032
14021
  get _keyboardActive() {
14033
- return isKeyboardActive();
14022
+ return keyboardActive;
14034
14023
  }
14035
14024
 
14036
14025
  /** @protected */
@@ -14294,7 +14283,7 @@ const ButtonMixin = (superClass) =>
14294
14283
  * `focus-ring` | Set when the button is focused using the keyboard.
14295
14284
  * `focused` | Set when the button is focused.
14296
14285
  *
14297
- * See [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.
14286
+ * See [Styling Components](https://vaadin.com/docs/latest/ds/customization/styling-components) documentation.
14298
14287
  *
14299
14288
  * @extends HTMLElement
14300
14289
  * @mixes ButtonMixin
@@ -14376,6 +14365,7 @@ registerStyles(
14376
14365
  i$1`
14377
14366
  :host {
14378
14367
  position: relative;
14368
+ background-color: transparent;
14379
14369
  /* Background for the year scroller, placed here as we are using a mask image on the actual years part */
14380
14370
  background-image: linear-gradient(var(--lumo-shade-5pct), var(--lumo-shade-5pct));
14381
14371
  background-size: 57px 100%;
@@ -14483,10 +14473,17 @@ registerStyles(
14483
14473
 
14484
14474
  [part='toolbar'] {
14485
14475
  padding: var(--lumo-space-s);
14476
+ box-shadow: 0 -1px 0 0 var(--lumo-contrast-10pct);
14486
14477
  border-bottom-left-radius: var(--lumo-border-radius-l);
14487
14478
  margin-right: 57px;
14488
14479
  }
14489
14480
 
14481
+ @supports (mask-image: linear-gradient(#000, #000)) or (-webkit-mask-image: linear-gradient(#000, #000)) {
14482
+ [part='toolbar'] {
14483
+ box-shadow: none;
14484
+ }
14485
+ }
14486
+
14490
14487
  /* Today and Cancel buttons */
14491
14488
 
14492
14489
  [part='toolbar'] [part\$='button'] {
@@ -14519,6 +14516,8 @@ registerStyles(
14519
14516
  /* Very narrow screen (year scroller initially hidden) */
14520
14517
 
14521
14518
  [part='years-toggle-button'] {
14519
+ position: relative;
14520
+ right: auto;
14522
14521
  display: flex;
14523
14522
  align-items: center;
14524
14523
  height: var(--lumo-size-s);
@@ -14536,6 +14535,10 @@ registerStyles(
14536
14535
  color: var(--lumo-primary-contrast-color);
14537
14536
  }
14538
14537
 
14538
+ [part='years-toggle-button']::before {
14539
+ content: none;
14540
+ }
14541
+
14539
14542
  /* TODO magic number (same as used for iron-media-query in vaadin-date-picker-overlay-content) */
14540
14543
  @media screen and (max-width: 374px) {
14541
14544
  :host {
@@ -14711,9 +14714,9 @@ registerStyles(
14711
14714
  { moduleId: 'lumo-month-calendar' },
14712
14715
  );
14713
14716
 
14714
- const template$1 = document.createElement('template');
14717
+ const $_documentContainer$1 = document.createElement('template');
14715
14718
 
14716
- template$1.innerHTML = `
14719
+ $_documentContainer$1.innerHTML = `
14717
14720
  <style>
14718
14721
  @keyframes vaadin-date-picker-month-calendar-focus-date {
14719
14722
  50% {
@@ -14723,7 +14726,7 @@ template$1.innerHTML = `
14723
14726
  </style>
14724
14727
  `;
14725
14728
 
14726
- document.head.appendChild(template$1.content);
14729
+ document.head.appendChild($_documentContainer$1.content);
14727
14730
 
14728
14731
  /**
14729
14732
  * @license
@@ -14731,9 +14734,9 @@ document.head.appendChild(template$1.content);
14731
14734
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
14732
14735
  */
14733
14736
 
14734
- const template = document.createElement('template');
14737
+ const $_documentContainer = document.createElement('template');
14735
14738
 
14736
- template.innerHTML = `
14739
+ $_documentContainer.innerHTML = `
14737
14740
  <style>
14738
14741
  @font-face {
14739
14742
  font-family: 'lumo-icons';
@@ -14789,7 +14792,7 @@ template.innerHTML = `
14789
14792
  </style>
14790
14793
  `;
14791
14794
 
14792
- document.head.appendChild(template.content);
14795
+ document.head.appendChild($_documentContainer.content);
14793
14796
 
14794
14797
  /**
14795
14798
  * @license
@@ -15356,57 +15359,6 @@ function getAncestorRootNodes(node) {
15356
15359
  return result;
15357
15360
  }
15358
15361
 
15359
- /**
15360
- * @param {string} value
15361
- * @return {Set<string>}
15362
- */
15363
- function deserializeAttributeValue(value) {
15364
- if (!value) {
15365
- return new Set();
15366
- }
15367
-
15368
- return new Set(value.split(' '));
15369
- }
15370
-
15371
- /**
15372
- * @param {Set<string>} values
15373
- * @return {string}
15374
- */
15375
- function serializeAttributeValue(values) {
15376
- return [...values].join(' ');
15377
- }
15378
-
15379
- /**
15380
- * Adds a value to an attribute containing space-delimited values.
15381
- *
15382
- * @param {HTMLElement} element
15383
- * @param {string} attr
15384
- * @param {string} value
15385
- */
15386
- function addValueToAttribute(element, attr, value) {
15387
- const values = deserializeAttributeValue(element.getAttribute(attr));
15388
- values.add(value);
15389
- element.setAttribute(attr, serializeAttributeValue(values));
15390
- }
15391
-
15392
- /**
15393
- * Removes a value from an attribute containing space-delimited values.
15394
- * If the value is the last one, the whole attribute is removed.
15395
- *
15396
- * @param {HTMLElement} element
15397
- * @param {string} attr
15398
- * @param {string} value
15399
- */
15400
- function removeValueFromAttribute(element, attr, value) {
15401
- const values = deserializeAttributeValue(element.getAttribute(attr));
15402
- values.delete(value);
15403
- if (values.size === 0) {
15404
- element.removeAttribute(attr);
15405
- return;
15406
- }
15407
- element.setAttribute(attr, serializeAttributeValue(values));
15408
- }
15409
-
15410
15362
  /**
15411
15363
  * @license
15412
15364
  * Copyright (c) 2017 - 2022 Vaadin Ltd.
@@ -17131,9 +17083,7 @@ class MonthCalendar extends FocusMixin(ThemableMixin(PolymerElement)) {
17131
17083
 
17132
17084
  _onMonthGridTouchStart() {
17133
17085
  this._notTapping = false;
17134
- setTimeout(() => {
17135
- this._notTapping = true;
17136
- }, 300);
17086
+ setTimeout(() => (this._notTapping = true), 300);
17137
17087
  }
17138
17088
 
17139
17089
  _dateAdd(date, delta) {
@@ -17468,7 +17418,7 @@ class InfiniteScroller extends PolymerElement {
17468
17418
  // Once the first set of items start fading in, stamp the rest
17469
17419
  this._buffers.forEach((buffer) => {
17470
17420
  [].forEach.call(buffer.children, (insertionPoint) => this._ensureStampedInstance(insertionPoint._itemWrapper));
17471
- });
17421
+ }, this);
17472
17422
 
17473
17423
  if (!this._buffers[0].translateY) {
17474
17424
  this._reset();
@@ -17631,7 +17581,7 @@ class InfiniteScroller extends PolymerElement {
17631
17581
  }
17632
17582
  }, 1); // Wait for first reset
17633
17583
  }
17634
- });
17584
+ }, this);
17635
17585
 
17636
17586
  setTimeout(() => {
17637
17587
  afterNextRender(this, this._finishInit.bind(this));
@@ -17669,7 +17619,7 @@ class InfiniteScroller extends PolymerElement {
17669
17619
  });
17670
17620
  buffer.updated = true;
17671
17621
  }
17672
- });
17622
+ }, this);
17673
17623
  }
17674
17624
 
17675
17625
  _isVisible(element, container) {
@@ -17768,6 +17718,7 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
17768
17718
  height: 100%;
17769
17719
  width: 100%;
17770
17720
  outline: none;
17721
+ background: #fff;
17771
17722
  }
17772
17723
 
17773
17724
  [part='overlay-header'] {
@@ -17785,14 +17736,22 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
17785
17736
  flex-grow: 1;
17786
17737
  }
17787
17738
 
17788
- [hidden] {
17789
- display: none !important;
17739
+ [part='clear-button']:not([showclear]) {
17740
+ display: none;
17790
17741
  }
17791
17742
 
17792
17743
  [part='years-toggle-button'] {
17793
17744
  display: flex;
17794
17745
  }
17795
17746
 
17747
+ [part='years-toggle-button'][desktop] {
17748
+ display: none;
17749
+ }
17750
+
17751
+ :host(:not([years-visible])) [part='years-toggle-button']::before {
17752
+ transform: rotate(180deg);
17753
+ }
17754
+
17796
17755
  #scrollers {
17797
17756
  display: flex;
17798
17757
  height: 100%;
@@ -17866,14 +17825,27 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
17866
17825
  z-index: 2;
17867
17826
  flex-shrink: 0;
17868
17827
  }
17828
+
17829
+ [part~='overlay-header']:not([desktop]) {
17830
+ padding-bottom: 40px;
17831
+ }
17832
+
17833
+ [part~='years-toggle-button'] {
17834
+ position: absolute;
17835
+ top: auto;
17836
+ right: 8px;
17837
+ bottom: 0;
17838
+ z-index: 1;
17839
+ padding: 8px;
17840
+ }
17869
17841
  </style>
17870
17842
 
17871
17843
  <div part="overlay-header" on-touchend="_preventDefault" desktop$="[[_desktopMode]]" aria-hidden="true">
17872
17844
  <div part="label">[[_formatDisplayed(selectedDate, i18n.formatDate, label)]]</div>
17873
- <div part="clear-button" hidden$="[[!selectedDate]]"></div>
17845
+ <div part="clear-button" showclear$="[[_showClear(selectedDate)]]"></div>
17874
17846
  <div part="toggle-button"></div>
17875
17847
 
17876
- <div part="years-toggle-button" hidden$="[[_desktopMode]]" aria-hidden="true">
17848
+ <div part="years-toggle-button" desktop$="[[_desktopMode]]" aria-hidden="true">
17877
17849
  [[_yearAfterXMonths(_visibleMonthIndex)]]
17878
17850
  </div>
17879
17851
  </div>
@@ -17959,7 +17931,6 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
17959
17931
  */
17960
17932
  selectedDate: {
17961
17933
  type: Date,
17962
- value: null,
17963
17934
  },
17964
17935
 
17965
17936
  /**
@@ -18035,12 +18006,10 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
18035
18006
  return this.getAttribute('dir') === 'rtl';
18036
18007
  }
18037
18008
 
18038
- get calendars() {
18039
- return [...this.shadowRoot.querySelectorAll('vaadin-month-calendar')];
18040
- }
18041
-
18042
18009
  get focusableDateElement() {
18043
- return this.calendars.map((calendar) => calendar.focusableDateElement).find(Boolean);
18010
+ return [...this.shadowRoot.querySelectorAll('vaadin-month-calendar')]
18011
+ .map((calendar) => calendar.focusableDateElement)
18012
+ .find(Boolean);
18044
18013
  }
18045
18014
 
18046
18015
  ready() {
@@ -18048,6 +18017,7 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
18048
18017
 
18049
18018
  this.setAttribute('role', 'dialog');
18050
18019
 
18020
+ addListener(this, 'tap', this._stopPropagation);
18051
18021
  addListener(this.$.scrollers, 'track', this._track.bind(this));
18052
18022
  addListener(this.shadowRoot.querySelector('[part="clear-button"]'), 'tap', this._clear.bind(this));
18053
18023
  addListener(this.shadowRoot.querySelector('[part="today-button"]'), 'tap', this._onTodayTap.bind(this));
@@ -18169,9 +18139,7 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
18169
18139
 
18170
18140
  _onYearScrollTouchStart() {
18171
18141
  this._notTapping = false;
18172
- setTimeout(() => {
18173
- this._notTapping = true;
18174
- }, 300);
18142
+ setTimeout(() => (this._notTapping = true), 300);
18175
18143
 
18176
18144
  this._repositionMonthScroller();
18177
18145
  }
@@ -18182,9 +18150,7 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
18182
18150
 
18183
18151
  _doIgnoreTaps() {
18184
18152
  this._ignoreTaps = true;
18185
- this._debouncer = Debouncer$1.debounce(this._debouncer, timeOut.after(300), () => {
18186
- this._ignoreTaps = false;
18187
- });
18153
+ this._debouncer = Debouncer$1.debounce(this._debouncer, timeOut.after(300), () => (this._ignoreTaps = false));
18188
18154
  }
18189
18155
 
18190
18156
  _formatDisplayed(date, formatDate, label) {
@@ -18215,6 +18181,10 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
18215
18181
  this.scrollToDate(new Date(), true);
18216
18182
  }
18217
18183
 
18184
+ _showClear(selectedDate) {
18185
+ return !!selectedDate;
18186
+ }
18187
+
18218
18188
  _onYearTap(e) {
18219
18189
  if (!this._ignoreTaps && !this._notTapping) {
18220
18190
  const scrollDelta =
@@ -18240,11 +18210,6 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
18240
18210
 
18241
18211
  this._targetPosition = targetPosition;
18242
18212
 
18243
- let revealResolve;
18244
- this._revealPromise = new Promise((resolve) => {
18245
- revealResolve = resolve;
18246
- });
18247
-
18248
18213
  // http://gizma.com/easing/
18249
18214
  const easingFunction = (t, b, c, d) => {
18250
18215
  t /= d / 2;
@@ -18285,9 +18250,7 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
18285
18250
 
18286
18251
  this.$.monthScroller.position = this._targetPosition;
18287
18252
  this._targetPosition = undefined;
18288
-
18289
- revealResolve();
18290
- this._revealPromise = undefined;
18253
+ this.__tryFocusDate();
18291
18254
  }
18292
18255
 
18293
18256
  setTimeout(this._repositionYearScroller.bind(this), 1);
@@ -18497,44 +18460,51 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
18497
18460
  switch (section) {
18498
18461
  case 'calendar':
18499
18462
  if (event.shiftKey) {
18463
+ // Return focus back to the input field.
18500
18464
  event.preventDefault();
18501
-
18502
- if (this.hasAttribute('fullscreen')) {
18503
- // Trap focus in the overlay
18504
- this.$.cancelButton.focus();
18505
- } else {
18506
- this.__focusInput();
18507
- }
18465
+ this.__focusInput();
18508
18466
  }
18509
18467
  break;
18510
18468
  case 'today':
18511
18469
  if (event.shiftKey) {
18512
- event.preventDefault();
18513
- this.focusDateElement();
18470
+ // Browser returns focus back to the calendar.
18471
+ // We need to move the scroll to focused date.
18472
+ setTimeout(() => this.revealDate(this.focusedDate), 1);
18514
18473
  }
18515
18474
  break;
18516
18475
  case 'cancel':
18517
18476
  if (!event.shiftKey) {
18477
+ // Return focus back to the input field.
18518
18478
  event.preventDefault();
18519
-
18520
- if (this.hasAttribute('fullscreen')) {
18521
- // Trap focus in the overlay
18522
- this.focusDateElement();
18523
- } else {
18524
- this.__focusInput();
18525
- }
18479
+ this.__focusInput();
18526
18480
  }
18527
18481
  break;
18528
18482
  }
18529
18483
  }
18530
18484
 
18531
18485
  __onTodayButtonKeyDown(event) {
18486
+ if (this.hasAttribute('fullscreen')) {
18487
+ // Do not prevent closing on Esc
18488
+ if (event.key !== 'Escape') {
18489
+ event.stopPropagation();
18490
+ }
18491
+ return;
18492
+ }
18493
+
18532
18494
  if (event.key === 'Tab') {
18533
18495
  this._onTabKeyDown(event, 'today');
18534
18496
  }
18535
18497
  }
18536
18498
 
18537
18499
  __onCancelButtonKeyDown(event) {
18500
+ if (this.hasAttribute('fullscreen')) {
18501
+ // Do not prevent closing on Esc
18502
+ if (event.key !== 'Escape') {
18503
+ event.stopPropagation();
18504
+ }
18505
+ return;
18506
+ }
18507
+
18538
18508
  if (event.key === 'Tab') {
18539
18509
  this._onTabKeyDown(event, 'cancel');
18540
18510
  }
@@ -18563,29 +18533,15 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
18563
18533
  if (!keepMonth) {
18564
18534
  this._focusedMonthDate = dateToFocus.getDate();
18565
18535
  }
18566
- await this.focusDateElement(false);
18536
+ await this.focusDateElement();
18567
18537
  }
18568
18538
 
18569
- async focusDateElement(reveal = true) {
18539
+ async focusDateElement() {
18570
18540
  this.__pendingDateFocus = this.focusedDate;
18571
18541
 
18572
- // Wait for `vaadin-month-calendar` elements to be rendered
18573
- if (!this.calendars.length) {
18574
- await new Promise((resolve) => {
18575
- setTimeout(resolve);
18576
- });
18577
- }
18578
-
18579
- // Reveal focused date unless it has been just set,
18580
- // which triggers `revealDate()` in the observer.
18581
- if (reveal) {
18582
- this.revealDate(this.focusedDate);
18583
- }
18584
-
18585
- if (this._revealPromise) {
18586
- // Wait for focused date to be scrolled into view.
18587
- await this._revealPromise;
18588
- }
18542
+ await new Promise((resolve) => {
18543
+ requestAnimationFrame(resolve);
18544
+ });
18589
18545
 
18590
18546
  this.__tryFocusDate();
18591
18547
  }
@@ -18683,6 +18639,10 @@ class DatePickerOverlayContent extends ControllerMixin(ThemableMixin(DirMixin(Po
18683
18639
  todayMidnight.setDate(today.getDate());
18684
18640
  return this._dateAllowed(todayMidnight, min, max);
18685
18641
  }
18642
+
18643
+ _stopPropagation(e) {
18644
+ e.stopPropagation();
18645
+ }
18686
18646
  }
18687
18647
 
18688
18648
  customElements.define(DatePickerOverlayContent.is, DatePickerOverlayContent);
@@ -18913,24 +18873,6 @@ const DelegateFocusMixin = dedupingMixin(
18913
18873
  },
18914
18874
  );
18915
18875
 
18916
- /**
18917
- * @license
18918
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
18919
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
18920
- */
18921
-
18922
- let uniqueId = 0;
18923
-
18924
- /**
18925
- * Returns a unique integer id.
18926
- *
18927
- * @return {number}
18928
- */
18929
- function generateUniqueId() {
18930
- // eslint-disable-next-line no-plusplus
18931
- return uniqueId++;
18932
- }
18933
-
18934
18876
  /**
18935
18877
  * @license
18936
18878
  * Copyright (c) 2021 - 2022 Vaadin Ltd.
@@ -18951,21 +18893,24 @@ class SlotController extends EventTarget {
18951
18893
  */
18952
18894
  static generateId(slotName, host) {
18953
18895
  const prefix = slotName || 'default';
18954
- return `${prefix}-${host.localName}-${generateUniqueId()}`;
18896
+
18897
+ // Support dash-case slot names e.g. "error-message"
18898
+ const field = `${dashToCamelCase(prefix)}Id`;
18899
+
18900
+ // Maintain the unique ID counter for a given prefix.
18901
+ this[field] = 1 + this[field] || 0;
18902
+
18903
+ return `${prefix}-${host.localName}-${this[field]}`;
18955
18904
  }
18956
18905
 
18957
- constructor(host, slotName, slotFactory, slotInitializer, useUniqueId) {
18906
+ constructor(host, slotName, slotFactory, slotInitializer) {
18958
18907
  super();
18959
18908
 
18960
18909
  this.host = host;
18961
18910
  this.slotName = slotName;
18962
18911
  this.slotFactory = slotFactory;
18963
18912
  this.slotInitializer = slotInitializer;
18964
-
18965
- // Only generate the default ID if requested by the controller.
18966
- if (useUniqueId) {
18967
- this.defaultId = SlotController.generateId(slotName, host);
18968
- }
18913
+ this.defaultId = SlotController.generateId(slotName, host);
18969
18914
  }
18970
18915
 
18971
18916
  hostConnected() {
@@ -19120,7 +19065,6 @@ class ErrorController extends SlotController {
19120
19065
 
19121
19066
  this.__updateHasError();
19122
19067
  },
19123
- true,
19124
19068
  );
19125
19069
  }
19126
19070
 
@@ -19235,6 +19179,63 @@ class ErrorController extends SlotController {
19235
19179
  }
19236
19180
  }
19237
19181
 
19182
+ /**
19183
+ * @license
19184
+ * Copyright (c) 2021 - 2022 Vaadin Ltd.
19185
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
19186
+ */
19187
+
19188
+ /**
19189
+ * @param {string} value
19190
+ * @return {Set<string>}
19191
+ */
19192
+ function deserializeAttributeValue(value) {
19193
+ if (!value) {
19194
+ return new Set();
19195
+ }
19196
+
19197
+ return new Set(value.split(' '));
19198
+ }
19199
+
19200
+ /**
19201
+ * @param {Set<string>} values
19202
+ * @return {string}
19203
+ */
19204
+ function serializeAttributeValue(values) {
19205
+ return [...values].join(' ');
19206
+ }
19207
+
19208
+ /**
19209
+ * Adds a value to an attribute containing space-delimited values.
19210
+ *
19211
+ * @param {HTMLElement} element
19212
+ * @param {string} attr
19213
+ * @param {string} value
19214
+ */
19215
+ function addValueToAttribute(element, attr, value) {
19216
+ const values = deserializeAttributeValue(element.getAttribute(attr));
19217
+ values.add(value);
19218
+ element.setAttribute(attr, serializeAttributeValue(values));
19219
+ }
19220
+
19221
+ /**
19222
+ * Removes a value from an attribute containing space-delimited values.
19223
+ * If the value is the last one, the whole attribute is removed.
19224
+ *
19225
+ * @param {HTMLElement} element
19226
+ * @param {string} attr
19227
+ * @param {string} value
19228
+ */
19229
+ function removeValueFromAttribute(element, attr, value) {
19230
+ const values = deserializeAttributeValue(element.getAttribute(attr));
19231
+ values.delete(value);
19232
+ if (values.size === 0) {
19233
+ element.removeAttribute(attr);
19234
+ return;
19235
+ }
19236
+ element.setAttribute(attr, serializeAttributeValue(values));
19237
+ }
19238
+
19238
19239
  /**
19239
19240
  * @license
19240
19241
  * Copyright (c) 2021 - 2022 Vaadin Ltd.
@@ -19409,7 +19410,7 @@ class FieldAriaController {
19409
19410
 
19410
19411
  /**
19411
19412
  * @license
19412
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
19413
+ * Copyright (c) 2021 Vaadin Ltd.
19413
19414
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
19414
19415
  */
19415
19416
 
@@ -19419,7 +19420,7 @@ class FieldAriaController {
19419
19420
  class HelperController extends SlotController {
19420
19421
  constructor(host) {
19421
19422
  // Do not provide slot factory, as only create helper lazily.
19422
- super(host, 'helper', null, null, true);
19423
+ super(host, 'helper');
19423
19424
  }
19424
19425
 
19425
19426
  get helperId() {
@@ -19616,7 +19617,6 @@ class LabelController extends SlotController {
19616
19617
 
19617
19618
  this.__observeLabel(node);
19618
19619
  },
19619
- true,
19620
19620
  );
19621
19621
  }
19622
19622
 
@@ -19823,12 +19823,6 @@ const LabelMixin = dedupingMixin(
19823
19823
  super();
19824
19824
 
19825
19825
  this._labelController = new LabelController(this);
19826
- }
19827
-
19828
- /** @protected */
19829
- ready() {
19830
- super.ready();
19831
-
19832
19826
  this.addController(this._labelController);
19833
19827
  }
19834
19828
 
@@ -19876,17 +19870,12 @@ const ValidateMixin = dedupingMixin(
19876
19870
  }
19877
19871
 
19878
19872
  /**
19879
- * Validates the field and sets the `invalid` property based on the result.
19880
- *
19881
- * The method fires a `validated` event with the result of the validation.
19873
+ * Returns true if field is valid, and sets `invalid` based on the field validity.
19882
19874
  *
19883
19875
  * @return {boolean} True if the value is valid.
19884
19876
  */
19885
19877
  validate() {
19886
- const isValid = this.checkValidity();
19887
- this._setInvalid(!isValid);
19888
- this.dispatchEvent(new CustomEvent('validated', { detail: { valid: isValid } }));
19889
- return isValid;
19878
+ return !(this.invalid = !this.checkValidity());
19890
19879
  }
19891
19880
 
19892
19881
  /**
@@ -19897,37 +19886,8 @@ const ValidateMixin = dedupingMixin(
19897
19886
  checkValidity() {
19898
19887
  return !this.required || !!this.value;
19899
19888
  }
19900
-
19901
- /**
19902
- * @param {boolean} invalid
19903
- * @protected
19904
- */
19905
- _setInvalid(invalid) {
19906
- if (this._shouldSetInvalid(invalid)) {
19907
- this.invalid = invalid;
19908
- }
19909
- }
19910
-
19911
- /**
19912
- * Override this method to define whether the given `invalid` state should be set.
19913
- *
19914
- * @param {boolean} _invalid
19915
- * @return {boolean}
19916
- * @protected
19917
- */
19918
- _shouldSetInvalid(_invalid) {
19919
- return true;
19920
- }
19921
-
19922
- /**
19923
- * Fired whenever the field is validated.
19924
- *
19925
- * @event validated
19926
- * @param {Object} detail
19927
- * @param {boolean} detail.valid the result of the validation.
19928
- */
19929
- },
19930
- );
19889
+ },
19890
+ );
19931
19891
 
19932
19892
  /**
19933
19893
  * @license
@@ -20014,6 +19974,10 @@ const FieldMixin = (superclass) =>
20014
19974
  this._helperController = new HelperController(this);
20015
19975
  this._errorController = new ErrorController(this);
20016
19976
 
19977
+ this.addController(this._fieldAriaController);
19978
+ this.addController(this._helperController);
19979
+ this.addController(this._errorController);
19980
+
20017
19981
  this._labelController.addEventListener('label-changed', (event) => {
20018
19982
  const { hasLabel, node } = event.detail;
20019
19983
  this.__labelChanged(hasLabel, node);
@@ -20025,15 +19989,6 @@ const FieldMixin = (superclass) =>
20025
19989
  });
20026
19990
  }
20027
19991
 
20028
- /** @protected */
20029
- ready() {
20030
- super.ready();
20031
-
20032
- this.addController(this._fieldAriaController);
20033
- this.addController(this._helperController);
20034
- this.addController(this._errorController);
20035
- }
20036
-
20037
19992
  /** @private */
20038
19993
  __helperChanged(hasHelper, helperNode) {
20039
19994
  if (hasHelper) {
@@ -20089,7 +20044,7 @@ const FieldMixin = (superclass) =>
20089
20044
  }
20090
20045
 
20091
20046
  /**
20092
- * @param {boolean} invalid
20047
+ * @param {boolean} required
20093
20048
  * @protected
20094
20049
  */
20095
20050
  _invalidChanged(invalid) {
@@ -20289,23 +20244,13 @@ const InputMixin = dedupingMixin(
20289
20244
  observer: '_valueChanged',
20290
20245
  notify: true,
20291
20246
  },
20292
-
20293
- /**
20294
- * When true, the input element has a non-empty value entered by the user.
20295
- * @protected
20296
- */
20297
- _hasInputValue: {
20298
- type: Boolean,
20299
- value: false,
20300
- observer: '_hasInputValueChanged',
20301
- },
20302
20247
  };
20303
20248
  }
20304
20249
 
20305
20250
  constructor() {
20306
20251
  super();
20307
20252
 
20308
- this._boundOnInput = this.__onInput.bind(this);
20253
+ this._boundOnInput = this._onInput.bind(this);
20309
20254
  this._boundOnChange = this._onChange.bind(this);
20310
20255
  }
20311
20256
 
@@ -20320,7 +20265,6 @@ const InputMixin = dedupingMixin(
20320
20265
  * Add event listeners to the input element instance.
20321
20266
  * Override this method to add custom listeners.
20322
20267
  * @param {!HTMLElement} input
20323
- * @protected
20324
20268
  */
20325
20269
  _addInputListeners(input) {
20326
20270
  input.addEventListener('input', this._boundOnInput);
@@ -20330,7 +20274,6 @@ const InputMixin = dedupingMixin(
20330
20274
  /**
20331
20275
  * Remove event listeners from the input element instance.
20332
20276
  * @param {!HTMLElement} input
20333
- * @protected
20334
20277
  */
20335
20278
  _removeInputListeners(input) {
20336
20279
  input.removeEventListener('input', this._boundOnInput);
@@ -20344,6 +20287,7 @@ const InputMixin = dedupingMixin(
20344
20287
  * for example to skip this in certain conditions.
20345
20288
  * @param {string} value
20346
20289
  * @protected
20290
+ * @override
20347
20291
  */
20348
20292
  _forwardInputValue(value) {
20349
20293
  // Value might be set before an input element is initialized.
@@ -20360,11 +20304,7 @@ const InputMixin = dedupingMixin(
20360
20304
  }
20361
20305
  }
20362
20306
 
20363
- /**
20364
- * @param {HTMLElement | undefined} input
20365
- * @param {HTMLElement | undefined} oldInput
20366
- * @protected
20367
- */
20307
+ /** @protected */
20368
20308
  _inputElementChanged(input, oldInput) {
20369
20309
  if (input) {
20370
20310
  this._addInputListeners(input);
@@ -20373,47 +20313,17 @@ const InputMixin = dedupingMixin(
20373
20313
  }
20374
20314
  }
20375
20315
 
20376
- /**
20377
- * Observer to notify about the change of private property.
20378
- *
20379
- * @private
20380
- */
20381
- _hasInputValueChanged(hasValue, oldHasValue) {
20382
- if (hasValue || oldHasValue) {
20383
- this.dispatchEvent(new CustomEvent('has-input-value-changed'));
20384
- }
20385
- }
20386
-
20387
- /**
20388
- * An input event listener used to update `_hasInputValue` property.
20389
- * Do not override this method.
20390
- *
20391
- * @param {Event} event
20392
- * @private
20393
- */
20394
- __onInput(event) {
20395
- // In the case a custom web component is passed as `inputElement`,
20396
- // the actual native input element, on which the event occurred,
20397
- // can be inside shadow trees.
20398
- const target = event.composedPath()[0];
20399
- this._hasInputValue = target.value.length > 0;
20400
- this._onInput(event);
20401
- }
20402
-
20403
20316
  /**
20404
20317
  * An input event listener used to update the field value.
20405
- *
20406
- * @param {Event} event
20318
+ * Override this method with an actual implementation.
20319
+ * @param {Event} _event
20407
20320
  * @protected
20321
+ * @override
20408
20322
  */
20409
20323
  _onInput(event) {
20410
- // In the case a custom web component is passed as `inputElement`,
20411
- // the actual native input element, on which the event occurred,
20412
- // can be inside shadow trees.
20413
- const target = event.composedPath()[0];
20414
20324
  // Ignore fake input events e.g. used by clear button.
20415
20325
  this.__userInput = event.isTrusted;
20416
- this.value = target.value;
20326
+ this.value = event.target.value;
20417
20327
  this.__userInput = false;
20418
20328
  }
20419
20329
 
@@ -20422,12 +20332,12 @@ const InputMixin = dedupingMixin(
20422
20332
  * Override this method with an actual implementation.
20423
20333
  * @param {Event} _event
20424
20334
  * @protected
20335
+ * @override
20425
20336
  */
20426
20337
  _onChange(_event) {}
20427
20338
 
20428
20339
  /**
20429
20340
  * Toggle the has-value attribute based on the value property.
20430
- *
20431
20341
  * @param {boolean} hasValue
20432
20342
  * @protected
20433
20343
  */
@@ -20440,9 +20350,10 @@ const InputMixin = dedupingMixin(
20440
20350
  * @param {string | undefined} newVal
20441
20351
  * @param {string | undefined} oldVal
20442
20352
  * @protected
20353
+ * @override
20443
20354
  */
20444
20355
  _valueChanged(newVal, oldVal) {
20445
- this._toggleHasValue(this._hasValue);
20356
+ this._toggleHasValue(newVal !== '' && newVal != null);
20446
20357
 
20447
20358
  // Setting initial value to empty string, do nothing.
20448
20359
  if (newVal === '' && oldVal === undefined) {
@@ -20457,16 +20368,6 @@ const InputMixin = dedupingMixin(
20457
20368
  // Setting a value programmatically, sync it to input element.
20458
20369
  this._forwardInputValue(newVal);
20459
20370
  }
20460
-
20461
- /**
20462
- * Indicates whether the value is different from the default one.
20463
- * Override if the `value` property has a type other than `string`.
20464
- *
20465
- * @protected
20466
- */
20467
- get _hasValue() {
20468
- return this.value != null && this.value !== '';
20469
- }
20470
20371
  },
20471
20372
  );
20472
20373
 
@@ -20538,32 +20439,26 @@ const InputConstraintsMixin = dedupingMixin(
20538
20439
  _createConstraintsObserver() {
20539
20440
  // This complex observer needs to be added dynamically instead of using `static get observers()`
20540
20441
  // to make it possible to tweak this behavior in classes that apply this mixin.
20541
- this._createMethodObserver(`_constraintsChanged(stateTarget, ${this.constructor.constraints.join(', ')})`);
20442
+ this._createMethodObserver(`_constraintsChanged(${this.constructor.constraints.join(', ')})`);
20542
20443
  }
20543
20444
 
20544
20445
  /**
20545
20446
  * Override this method to implement custom validation constraints.
20546
- * @param {HTMLElement | undefined} stateTarget
20547
20447
  * @param {unknown[]} constraints
20548
20448
  * @protected
20549
20449
  */
20550
- _constraintsChanged(stateTarget, ...constraints) {
20551
- // The input element's validity cannot be determined until
20552
- // all the necessary constraint attributes aren't set on it.
20553
- if (!stateTarget) {
20450
+ _constraintsChanged(...constraints) {
20451
+ // Prevent marking field as invalid when setting required state
20452
+ // or any other constraint before a user has entered the value.
20453
+ if (!this.invalid) {
20554
20454
  return;
20555
20455
  }
20556
20456
 
20557
- const hasConstraints = this._hasValidConstraints(constraints);
20558
- const isLastConstraintRemoved = this.__previousHasConstraints && !hasConstraints;
20559
-
20560
- if ((this._hasValue || this.invalid) && hasConstraints) {
20457
+ if (this._hasValidConstraints(constraints)) {
20561
20458
  this.validate();
20562
- } else if (isLastConstraintRemoved) {
20563
- this._setInvalid(false);
20459
+ } else {
20460
+ this.invalid = false;
20564
20461
  }
20565
-
20566
- this.__previousHasConstraints = hasConstraints;
20567
20462
  }
20568
20463
 
20569
20464
  /**
@@ -20619,22 +20514,6 @@ const InputControlMixin = (superclass) =>
20619
20514
  ) {
20620
20515
  static get properties() {
20621
20516
  return {
20622
- /**
20623
- * A pattern matched against individual characters the user inputs.
20624
- *
20625
- * When set, the field will prevent:
20626
- * - `keydown` events if the entered key doesn't match `/^allowedCharPattern$/`
20627
- * - `paste` events if the pasted text doesn't match `/^allowedCharPattern*$/`
20628
- * - `drop` events if the dropped text doesn't match `/^allowedCharPattern*$/`
20629
- *
20630
- * For example, to allow entering only numbers and minus signs, use:
20631
- * `allowedCharPattern = "[\\d-]"`
20632
- */
20633
- allowedCharPattern: {
20634
- type: String,
20635
- observer: '_allowedCharPatternChanged',
20636
- },
20637
-
20638
20517
  /**
20639
20518
  * If true, the input text gets fully selected when the field is focused using click or touch / tap.
20640
20519
  */
@@ -20692,14 +20571,6 @@ const InputControlMixin = (superclass) =>
20692
20571
  return [...super.delegateAttrs, 'name', 'type', 'placeholder', 'readonly', 'invalid', 'title'];
20693
20572
  }
20694
20573
 
20695
- constructor() {
20696
- super();
20697
-
20698
- this._boundOnPaste = this._onPaste.bind(this);
20699
- this._boundOnDrop = this._onDrop.bind(this);
20700
- this._boundOnBeforeInput = this._onBeforeInput.bind(this);
20701
- }
20702
-
20703
20574
  /**
20704
20575
  * Any element extending this mixin is required to implement this getter.
20705
20576
  * It returns the reference to the clear button element.
@@ -20792,115 +20663,6 @@ const InputControlMixin = (superclass) =>
20792
20663
  this.inputElement.dispatchEvent(new Event('change', { bubbles: true }));
20793
20664
  }
20794
20665
 
20795
- /**
20796
- * Override a method from `InputMixin`.
20797
- * @param {!HTMLElement} input
20798
- * @protected
20799
- * @override
20800
- */
20801
- _addInputListeners(input) {
20802
- super._addInputListeners(input);
20803
-
20804
- input.addEventListener('paste', this._boundOnPaste);
20805
- input.addEventListener('drop', this._boundOnDrop);
20806
- input.addEventListener('beforeinput', this._boundOnBeforeInput);
20807
- }
20808
-
20809
- /**
20810
- * Override a method from `InputMixin`.
20811
- * @param {!HTMLElement} input
20812
- * @protected
20813
- * @override
20814
- */
20815
- _removeInputListeners(input) {
20816
- super._removeInputListeners(input);
20817
-
20818
- input.removeEventListener('paste', this._boundOnPaste);
20819
- input.removeEventListener('drop', this._boundOnDrop);
20820
- input.removeEventListener('beforeinput', this._boundOnBeforeInput);
20821
- }
20822
-
20823
- /**
20824
- * Override an event listener from `KeyboardMixin`.
20825
- * @param {!KeyboardEvent} event
20826
- * @protected
20827
- * @override
20828
- */
20829
- _onKeyDown(event) {
20830
- super._onKeyDown(event);
20831
-
20832
- if (this.allowedCharPattern && !this.__shouldAcceptKey(event)) {
20833
- event.preventDefault();
20834
- this._markInputPrevented();
20835
- }
20836
- }
20837
-
20838
- /** @protected */
20839
- _markInputPrevented() {
20840
- // Add input-prevented attribute for 200ms
20841
- this.setAttribute('input-prevented', '');
20842
- this._preventInputDebouncer = Debouncer$1.debounce(this._preventInputDebouncer, timeOut.after(200), () => {
20843
- this.removeAttribute('input-prevented');
20844
- });
20845
- }
20846
-
20847
- /** @private */
20848
- __shouldAcceptKey(event) {
20849
- return (
20850
- event.metaKey ||
20851
- event.ctrlKey ||
20852
- !event.key || // Allow typing anything if event.key is not supported
20853
- event.key.length !== 1 || // Allow "Backspace", "ArrowLeft" etc.
20854
- this.__allowedCharRegExp.test(event.key)
20855
- );
20856
- }
20857
-
20858
- /** @private */
20859
- _onPaste(e) {
20860
- if (this.allowedCharPattern) {
20861
- const pastedText = e.clipboardData.getData('text');
20862
- if (!this.__allowedTextRegExp.test(pastedText)) {
20863
- e.preventDefault();
20864
- this._markInputPrevented();
20865
- }
20866
- }
20867
- }
20868
-
20869
- /** @private */
20870
- _onDrop(e) {
20871
- if (this.allowedCharPattern) {
20872
- const draggedText = e.dataTransfer.getData('text');
20873
- if (!this.__allowedTextRegExp.test(draggedText)) {
20874
- e.preventDefault();
20875
- this._markInputPrevented();
20876
- }
20877
- }
20878
- }
20879
-
20880
- /** @private */
20881
- _onBeforeInput(e) {
20882
- // The `beforeinput` event covers all the cases for `allowedCharPattern`: keyboard, pasting and dropping,
20883
- // but it is still experimental technology so we can't rely on it. It's used here just as an additional check,
20884
- // because it seems to be the only way to detect and prevent specific keys on mobile devices.
20885
- // See https://github.com/vaadin/vaadin-text-field/issues/429
20886
- if (this.allowedCharPattern && e.data && !this.__allowedTextRegExp.test(e.data)) {
20887
- e.preventDefault();
20888
- this._markInputPrevented();
20889
- }
20890
- }
20891
-
20892
- /** @private */
20893
- _allowedCharPatternChanged(charPattern) {
20894
- if (charPattern) {
20895
- try {
20896
- this.__allowedCharRegExp = new RegExp(`^${charPattern}$`);
20897
- this.__allowedTextRegExp = new RegExp(`^${charPattern}*$`);
20898
- } catch (e) {
20899
- console.error(e);
20900
- }
20901
- }
20902
- }
20903
-
20904
20666
  /**
20905
20667
  * Fired when the user commits a value change.
20906
20668
  *
@@ -20939,13 +20701,14 @@ class InputController extends SlotController {
20939
20701
  }
20940
20702
 
20941
20703
  // Ensure every instance has unique ID
20942
- node.id = this.defaultId;
20704
+ const uniqueId = (InputController._uniqueInputId = 1 + InputController._uniqueInputId || 0);
20705
+ host._inputId = `${host.localName}-${uniqueId}`;
20706
+ node.id = host._inputId;
20943
20707
 
20944
20708
  if (typeof callback === 'function') {
20945
20709
  callback(node);
20946
20710
  }
20947
20711
  },
20948
- true,
20949
20712
  );
20950
20713
  }
20951
20714
  }
@@ -21127,9 +20890,7 @@ class VirtualKeyboardController {
21127
20890
  * @param {function(new:HTMLElement)} subclass
21128
20891
  */
21129
20892
  const DatePickerMixin = (subclass) =>
21130
- class VaadinDatePickerMixin extends ControllerMixin(
21131
- DelegateFocusMixin(InputConstraintsMixin(KeyboardMixin(subclass))),
21132
- ) {
20893
+ class VaadinDatePickerMixin extends ControllerMixin(DelegateFocusMixin(InputMixin(KeyboardMixin(subclass)))) {
21133
20894
  static get properties() {
21134
20895
  return {
21135
20896
  /**
@@ -21158,6 +20919,7 @@ const DatePickerMixin = (subclass) =>
21158
20919
  */
21159
20920
  value: {
21160
20921
  type: String,
20922
+ observer: '_valueChanged',
21161
20923
  notify: true,
21162
20924
  value: '',
21163
20925
  },
@@ -21213,6 +20975,13 @@ const DatePickerMixin = (subclass) =>
21213
20975
  value: '(max-width: 420px), (max-height: 420px)',
21214
20976
  },
21215
20977
 
20978
+ /**
20979
+ * An array of ancestor elements whose -webkit-overflow-scrolling is forced from value
20980
+ * 'touch' to value 'auto' in order to prevent them from clipping the dropdown. iOS only.
20981
+ * @private
20982
+ */
20983
+ _touchPrevented: Array,
20984
+
21216
20985
  /**
21217
20986
  * The object used to localize this component.
21218
20987
  * To change the default localization, replace the entire
@@ -21368,6 +21137,7 @@ const DatePickerMixin = (subclass) =>
21368
21137
  */
21369
21138
  min: {
21370
21139
  type: String,
21140
+ observer: '_minChanged',
21371
21141
  },
21372
21142
 
21373
21143
  /**
@@ -21381,26 +21151,28 @@ const DatePickerMixin = (subclass) =>
21381
21151
  */
21382
21152
  max: {
21383
21153
  type: String,
21154
+ observer: '_maxChanged',
21384
21155
  },
21385
21156
 
21386
21157
  /**
21387
21158
  * The earliest date that can be selected. All earlier dates will be disabled.
21388
- * @type {Date | undefined}
21159
+ * @type {Date | string}
21389
21160
  * @protected
21390
21161
  */
21391
21162
  _minDate: {
21392
21163
  type: Date,
21393
- computed: '__computeMinOrMaxDate(min)',
21164
+ // Null does not work here because minimizer passes undefined to overlay (#351)
21165
+ value: '',
21394
21166
  },
21395
21167
 
21396
21168
  /**
21397
21169
  * The latest date that can be selected. All later dates will be disabled.
21398
- * @type {Date | undefined}
21170
+ * @type {Date | string}
21399
21171
  * @protected
21400
21172
  */
21401
21173
  _maxDate: {
21402
21174
  type: Date,
21403
- computed: '__computeMinOrMaxDate(max)',
21175
+ value: '',
21404
21176
  },
21405
21177
 
21406
21178
  /** @private */
@@ -21415,6 +21187,12 @@ const DatePickerMixin = (subclass) =>
21415
21187
  value: isIOS,
21416
21188
  },
21417
21189
 
21190
+ /** @private */
21191
+ _webkitOverflowScroll: {
21192
+ type: Boolean,
21193
+ value: document.createElement('div').style.webkitOverflowScrolling === '',
21194
+ },
21195
+
21418
21196
  /** @private */
21419
21197
  _focusOverlayOnOpen: Boolean,
21420
21198
 
@@ -21430,10 +21208,6 @@ const DatePickerMixin = (subclass) =>
21430
21208
  ];
21431
21209
  }
21432
21210
 
21433
- static get constraints() {
21434
- return [...super.constraints, 'min', 'max'];
21435
- }
21436
-
21437
21211
  /**
21438
21212
  * Override a getter from `InputControlMixin` to make it optional
21439
21213
  * and to prevent warning when a clear button is missing,
@@ -21500,10 +21274,12 @@ const DatePickerMixin = (subclass) =>
21500
21274
  }
21501
21275
  }
21502
21276
 
21503
- this.validate();
21504
-
21505
- if (this._inputValue === '' && this.value !== '') {
21277
+ if (this.inputElement.value === '' && this.__dispatchChange) {
21278
+ this.validate();
21506
21279
  this.value = '';
21280
+ this.__dispatchChange = false;
21281
+ } else {
21282
+ this.validate();
21507
21283
  }
21508
21284
  }
21509
21285
  }
@@ -21572,19 +21348,14 @@ const DatePickerMixin = (subclass) =>
21572
21348
  this.$.overlay.removeAttribute('disable-upgrade');
21573
21349
  this._overlayInitialized = true;
21574
21350
 
21575
- this.$.overlay.addEventListener('opened-changed', (e) => {
21576
- this.opened = e.detail.value;
21577
- });
21351
+ this.$.overlay.addEventListener('opened-changed', (e) => (this.opened = e.detail.value));
21578
21352
 
21579
21353
  this.$.overlay.addEventListener('vaadin-overlay-escape-press', () => {
21580
21354
  this._focusedDate = this._selectedDate;
21581
21355
  this._close();
21582
21356
  });
21583
21357
 
21584
- this._overlayContent.addEventListener('close', () => {
21585
- this._close();
21586
- });
21587
-
21358
+ this._overlayContent.addEventListener('close', this._close.bind(this));
21588
21359
  this._overlayContent.addEventListener('focus-input', this._focusAndSelect.bind(this));
21589
21360
 
21590
21361
  // User confirmed selected date by clicking the calendar.
@@ -21593,7 +21364,7 @@ const DatePickerMixin = (subclass) =>
21593
21364
 
21594
21365
  this._selectDate(e.detail.date);
21595
21366
 
21596
- this._close();
21367
+ this._close(e);
21597
21368
  });
21598
21369
 
21599
21370
  // User confirmed selected date by pressing Enter or Today.
@@ -21603,18 +21374,24 @@ const DatePickerMixin = (subclass) =>
21603
21374
  this._selectDate(e.detail.date);
21604
21375
  });
21605
21376
 
21606
- // Set focus-ring attribute when moving focus to the overlay
21607
- // by pressing Tab or arrow key, after opening it on click.
21377
+ // Keep focus attribute in focusElement for styling
21608
21378
  this._overlayContent.addEventListener('focusin', () => {
21609
- if (this._keyboardActive) {
21610
- this._setFocused(true);
21611
- }
21379
+ this._setFocused(true);
21612
21380
  });
21613
21381
 
21614
21382
  this.addEventListener('mousedown', () => this.__bringToFront());
21615
21383
  this.addEventListener('touchstart', () => this.__bringToFront());
21616
21384
  }
21617
21385
 
21386
+ /**
21387
+ * Returns true if `value` is valid, and sets the `invalid` flag appropriately.
21388
+ *
21389
+ * @return {boolean} True if the value is valid and sets the `invalid` flag appropriately
21390
+ */
21391
+ validate() {
21392
+ return !(this.invalid = !this.checkValidity());
21393
+ }
21394
+
21618
21395
  /**
21619
21396
  * Returns true if the current input value satisfies all constraints (if any)
21620
21397
  *
@@ -21625,7 +21402,7 @@ const DatePickerMixin = (subclass) =>
21625
21402
  checkValidity() {
21626
21403
  const inputValid =
21627
21404
  !this._inputValue ||
21628
- (!!this._selectedDate && this._inputValue === this._getFormattedDate(this.i18n.formatDate, this._selectedDate));
21405
+ (this._selectedDate && this._inputValue === this._getFormattedDate(this.i18n.formatDate, this._selectedDate));
21629
21406
  const minMaxValid = !this._selectedDate || dateAllowed(this._selectedDate, this._minDate, this._maxDate);
21630
21407
 
21631
21408
  let inputValidity = true;
@@ -21641,51 +21418,6 @@ const DatePickerMixin = (subclass) =>
21641
21418
  return inputValid && minMaxValid && inputValidity;
21642
21419
  }
21643
21420
 
21644
- /**
21645
- * Override method inherited from `FocusMixin`
21646
- * to not call `_setFocused(true)` when focus
21647
- * is restored after closing overlay on click,
21648
- * and to avoid removing `focus-ring` attribute.
21649
- *
21650
- * @param {!FocusEvent} _event
21651
- * @return {boolean}
21652
- * @protected
21653
- * @override
21654
- */
21655
- _shouldSetFocus(_event) {
21656
- return !this._shouldKeepFocusRing;
21657
- }
21658
-
21659
- /**
21660
- * Override method inherited from `FocusMixin`
21661
- * to prevent removing the `focused` attribute:
21662
- * - when moving focus to the overlay content,
21663
- * - when closing on date click / outside click.
21664
- *
21665
- * @param {!FocusEvent} _event
21666
- * @return {boolean}
21667
- * @protected
21668
- * @override
21669
- */
21670
- _shouldRemoveFocus(_event) {
21671
- return !this.opened;
21672
- }
21673
-
21674
- /**
21675
- * Override method inherited from `FocusMixin`
21676
- * to store the `focus-ring` state to restore
21677
- * it later when closing on outside click.
21678
- *
21679
- * @param {boolean} focused
21680
- * @protected
21681
- * @override
21682
- */
21683
- _setFocused(focused) {
21684
- super._setFocused(focused);
21685
-
21686
- this._shouldKeepFocusRing = focused && this._keyboardActive;
21687
- }
21688
-
21689
21421
  /**
21690
21422
  * Select date on user interaction and set the flag
21691
21423
  * to fire change event if necessary.
@@ -21705,7 +21437,10 @@ const DatePickerMixin = (subclass) =>
21705
21437
  }
21706
21438
 
21707
21439
  /** @private */
21708
- _close() {
21440
+ _close(e) {
21441
+ if (e) {
21442
+ e.stopPropagation();
21443
+ }
21709
21444
  this._focus();
21710
21445
  this.close();
21711
21446
  }
@@ -21834,46 +21569,47 @@ const DatePickerMixin = (subclass) =>
21834
21569
  }
21835
21570
  }
21836
21571
 
21837
- /**
21838
- * Override the value observer from `InputMixin` to implement custom
21839
- * handling of the `value` property. The date-picker doesn't forward
21840
- * the value directly to the input like the default implementation of `InputMixin`.
21841
- * Instead, it parses the value into a date, puts it in `_selectedDate` which
21842
- * is then displayed in the input with respect to the specified date format.
21843
- *
21844
- * @param {string | undefined} value
21845
- * @param {string | undefined} oldValue
21846
- * @protected
21847
- * @override
21848
- */
21849
- _valueChanged(value, oldValue) {
21850
- const newDate = this._parseDate(value);
21572
+ /** @private */
21573
+ _handleDateChange(property, value, oldValue) {
21574
+ if (!value) {
21575
+ this[property] = '';
21576
+ return;
21577
+ }
21851
21578
 
21852
- if (value && !newDate) {
21853
- // The new value cannot be parsed, revert the old value.
21579
+ const date = this._parseDate(value);
21580
+ if (!date) {
21854
21581
  this.value = oldValue;
21855
21582
  return;
21856
21583
  }
21857
-
21858
- if (value) {
21859
- if (!dateEquals(this._selectedDate, newDate)) {
21860
- // Update the date instance only if the date has actually changed.
21861
- this._selectedDate = newDate;
21862
-
21863
- if (oldValue !== undefined) {
21864
- // Validate only if `value` changes after initialization.
21865
- this.validate();
21866
- }
21584
+ if (!dateEquals(this[property], date)) {
21585
+ this[property] = date;
21586
+ if (this.value) {
21587
+ this.validate();
21867
21588
  }
21868
- } else {
21869
- this._selectedDate = null;
21870
21589
  }
21590
+ }
21591
+
21592
+ /** @private */
21593
+ _valueChanged(value, oldValue) {
21594
+ this._handleDateChange('_selectedDate', value, oldValue);
21871
21595
 
21872
- this._toggleHasValue(this._hasValue);
21596
+ this._toggleHasValue(!!value);
21597
+ }
21598
+
21599
+ /** @private */
21600
+ _minChanged(value, oldValue) {
21601
+ this._handleDateChange('_minDate', value, oldValue);
21602
+ }
21603
+
21604
+ /** @private */
21605
+ _maxChanged(value, oldValue) {
21606
+ this._handleDateChange('_maxDate', value, oldValue);
21873
21607
  }
21874
21608
 
21875
21609
  /** @protected */
21876
21610
  _onOverlayOpened() {
21611
+ this._openedWithFocusRing = this.hasAttribute('focus-ring');
21612
+
21877
21613
  const parsedInitialPosition = this._parseDate(this.initialPosition);
21878
21614
 
21879
21615
  const initialPosition =
@@ -21893,6 +21629,10 @@ const DatePickerMixin = (subclass) =>
21893
21629
 
21894
21630
  window.addEventListener('scroll', this._boundOnScroll, true);
21895
21631
 
21632
+ if (this._webkitOverflowScroll) {
21633
+ this._touchPrevented = this._preventWebkitOverflowScrollingTouch(this.parentElement);
21634
+ }
21635
+
21896
21636
  if (this._focusOverlayOnOpen) {
21897
21637
  this._overlayContent.focusDateElement();
21898
21638
  this._focusOverlayOnOpen = false;
@@ -21906,6 +21646,25 @@ const DatePickerMixin = (subclass) =>
21906
21646
  }
21907
21647
  }
21908
21648
 
21649
+ // A hack needed for iOS to prevent dropdown from being clipped in an
21650
+ // ancestor container with -webkit-overflow-scrolling: touch;
21651
+ /** @private */
21652
+ _preventWebkitOverflowScrollingTouch(element) {
21653
+ const result = [];
21654
+ while (element) {
21655
+ if (window.getComputedStyle(element).webkitOverflowScrolling === 'touch') {
21656
+ const oldInlineValue = element.style.webkitOverflowScrolling;
21657
+ element.style.webkitOverflowScrolling = 'auto';
21658
+ result.push({
21659
+ element,
21660
+ oldInlineValue,
21661
+ });
21662
+ }
21663
+ element = element.parentElement;
21664
+ }
21665
+ return result;
21666
+ }
21667
+
21909
21668
  /** @private */
21910
21669
  _selectParsedOrFocusedDate() {
21911
21670
  // Select the parsed input or focused date
@@ -21932,6 +21691,13 @@ const DatePickerMixin = (subclass) =>
21932
21691
  _onOverlayClosed() {
21933
21692
  window.removeEventListener('scroll', this._boundOnScroll, true);
21934
21693
 
21694
+ if (this._touchPrevented) {
21695
+ this._touchPrevented.forEach(
21696
+ (prevented) => (prevented.element.style.webkitOverflowScrolling = prevented.oldInlineValue),
21697
+ );
21698
+ this._touchPrevented = [];
21699
+ }
21700
+
21935
21701
  // No need to select date on close if it was confirmed by the user.
21936
21702
  if (this.__userConfirmedDate) {
21937
21703
  this.__userConfirmedDate = false;
@@ -21947,6 +21713,11 @@ const DatePickerMixin = (subclass) =>
21947
21713
  if (!this.value) {
21948
21714
  this.validate();
21949
21715
  }
21716
+
21717
+ // If the input isn't focused when overlay closes (fullscreen mode), clear focused state
21718
+ if (this.getRootNode().activeElement !== this.inputElement) {
21719
+ this._setFocused(false);
21720
+ }
21950
21721
  }
21951
21722
 
21952
21723
  /** @private */
@@ -21999,7 +21770,10 @@ const DatePickerMixin = (subclass) =>
21999
21770
  _onChange(event) {
22000
21771
  // For change event on the native <input> blur, after the input is cleared,
22001
21772
  // we schedule change event to be dispatched on date-picker blur.
22002
- if (this._inputValue === '') {
21773
+ if (
21774
+ this.inputElement.value === '' &&
21775
+ !(event.detail && event.detail.sourceEvent && event.detail.sourceEvent.__fromClearButton)
21776
+ ) {
22003
21777
  this.__dispatchChange = true;
22004
21778
  }
22005
21779
 
@@ -22086,7 +21860,7 @@ const DatePickerMixin = (subclass) =>
22086
21860
  if (e.shiftKey) {
22087
21861
  this._overlayContent.focusCancel();
22088
21862
  } else {
22089
- this._overlayContent.focusDateElement();
21863
+ this._overlayContent.focusDate(this._focusedDate);
22090
21864
  }
22091
21865
  }
22092
21866
  break;
@@ -22197,11 +21971,6 @@ const DatePickerMixin = (subclass) =>
22197
21971
  return this.$.overlay.content.querySelector('#overlay-content');
22198
21972
  }
22199
21973
 
22200
- /** @private */
22201
- __computeMinOrMaxDate(dateString) {
22202
- return this._parseDate(dateString);
22203
- }
22204
-
22205
21974
  /**
22206
21975
  * Fired when the user commits a value change.
22207
21976
  *
@@ -22313,13 +22082,12 @@ registerStyles('vaadin-date-picker', [inputFieldShared, datePickerStyles], { mod
22313
22082
  * Note: the `theme` attribute value set on `<vaadin-date-picker>` is
22314
22083
  * propagated to the internal components listed above.
22315
22084
  *
22316
- * See [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.
22085
+ * See [Styling Components](https://vaadin.com/docs/latest/ds/customization/styling-components) documentation.
22317
22086
  *
22318
22087
  * @fires {Event} change - Fired when the user commits a value change.
22319
22088
  * @fires {CustomEvent} invalid-changed - Fired when the `invalid` property changes.
22320
22089
  * @fires {CustomEvent} opened-changed - Fired when the `opened` property changes.
22321
22090
  * @fires {CustomEvent} value-changed - Fired when the `value` property changes.
22322
- * @fires {CustomEvent} validated - Fired whenever the field is validated.
22323
22091
  *
22324
22092
  * @extends HTMLElement
22325
22093
  * @mixes ElementMixin
@@ -22373,7 +22141,7 @@ class DatePicker extends DatePickerMixin(InputControlMixin(ThemableMixin(Element
22373
22141
  fullscreen$="[[_fullscreen]]"
22374
22142
  theme$="[[__getOverlayTheme(_theme, _overlayInitialized)]]"
22375
22143
  on-vaadin-overlay-open="_onOverlayOpened"
22376
- on-vaadin-overlay-closing="_onOverlayClosed"
22144
+ on-vaadin-overlay-close="_onOverlayClosed"
22377
22145
  restore-focus-on-close
22378
22146
  restore-focus-node="[[inputElement]]"
22379
22147
  disable-upgrade
@@ -22433,6 +22201,11 @@ class DatePicker extends DatePickerMixin(InputControlMixin(ThemableMixin(Element
22433
22201
 
22434
22202
  /** @private */
22435
22203
  _onVaadinOverlayClose(e) {
22204
+ if (this._openedWithFocusRing && this.hasAttribute('focused')) {
22205
+ this.setAttribute('focus-ring', '');
22206
+ } else if (!this.hasAttribute('focused')) {
22207
+ this.blur();
22208
+ }
22436
22209
  if (e.detail.sourceEvent && e.detail.sourceEvent.composedPath().includes(this)) {
22437
22210
  e.preventDefault();
22438
22211
  }
@@ -22492,26 +22265,55 @@ const HelperFilters = class {
22492
22265
  * Language
22493
22266
  */
22494
22267
  this.language = 'en';
22268
+ /**
22269
+ * Notifies if the quick filters from tickets are active
22270
+ */
22271
+ this.quickFiltersActive = false;
22272
+ /**
22273
+ * Client custom styling via string
22274
+ */
22275
+ this.clientStyling = '';
22276
+ /**
22277
+ * Client custom styling via url content
22278
+ */
22279
+ this.clientStylingUrlContent = '';
22495
22280
  this.showFilterModal = false;
22496
22281
  this.showClearButton = false;
22497
22282
  this.filterData = {};
22498
22283
  this.filterDataReset = { ticketDrawId: '', filterFromCalendar: '', filterToCalendar: '' };
22284
+ this.limitStylingAppends = false;
22285
+ this.setClientStyling = () => {
22286
+ let sheet = document.createElement('style');
22287
+ sheet.innerHTML = this.clientStyling;
22288
+ this.stylingContainer.prepend(sheet);
22289
+ };
22290
+ this.setClientStylingURL = () => {
22291
+ let cssFile = document.createElement('style');
22292
+ setTimeout(() => {
22293
+ cssFile.innerHTML = this.clientStylingUrlContent;
22294
+ this.stylingContainer.prepend(cssFile);
22295
+ }, 1);
22296
+ };
22499
22297
  }
22500
22298
  // reset field values each time the filter modal opens
22501
22299
  componentDidRender() {
22502
- this.filterData.ticketDrawId = null;
22503
- this.filterData.filterFromCalendar = null;
22504
- this.filterData.filterToCalendar = null;
22505
22300
  // @TODO: to way binding?
22506
22301
  if (document.getElementById('#FilterById'))
22507
22302
  document.getElementById('#FilterById').value = '';
22303
+ // start custom styling area
22304
+ if (!this.limitStylingAppends && this.stylingContainer) {
22305
+ if (this.clientStyling)
22306
+ this.setClientStyling();
22307
+ if (this.clientStylingUrlContent)
22308
+ this.setClientStylingURL();
22309
+ this.limitStylingAppends = true;
22310
+ }
22311
+ // end custom styling area
22508
22312
  }
22509
22313
  filterSelectionHandler(event) {
22510
22314
  if (this.postMessage)
22511
22315
  window.postMessage({ type: 'filterSelection', event }, window.location.href);
22512
- if (this.filterData.ticketDrawId)
22513
- this.filterDraw.emit(event);
22514
- if (this.filterData.filterFromCalendar || this.filterData.filterToCalendar)
22316
+ if (this.filterData.ticketDrawId || this.filterData.filterFromCalendar || this.filterData.filterToCalendar)
22515
22317
  this.filterSelection.emit(event);
22516
22318
  }
22517
22319
  filterSelectionResetHandler(event) {
@@ -22547,9 +22349,50 @@ const HelperFilters = class {
22547
22349
  this.filterData.filterToCalendar = new Date(event.target.value).toISOString();
22548
22350
  }
22549
22351
  render() {
22550
- return (index.h("div", { class: "HelperFilters" }, index.h("div", { class: "FilterButtonsWrapper" }, index.h("button", { class: "FilterOpen", onClick: () => this.toggleFilterModal() }, translate$1('filterOpen', this.language)), this.showClearButton ? index.h("button", { class: "FilterClear", onClick: () => this.resetSearch() }, translate$1('filterClear', this.language)) : null), index.h("helper-modal", { "title-modal": "Filter Modal", visible: this.showFilterModal }, index.h("div", { class: "FilterModalHeader" }, index.h("h3", { class: "FilterModalTitle" }, this.activateTicketSearch ? translate$1('filterModalTicketTitle', this.language) : translate$1('filterModalDrawTitle', this.language))), index.h("div", { class: "FilterModalBody" }, index.h("input", { id: "FilterById", type: "text", value: this.filterData.ticketDrawId, onInput: (event) => this.handleTicketDrawId(event), class: "FilterModalSearch", placeholder: this.activateTicketSearch ? translate$1('filterTicketPlaceholder', this.language) : translate$1('filterDrawPlaceholder', this.language) }), index.h("p", null, translate$1('filterOrDate', this.language)), index.h("div", { class: "FilterCalendarWrapper" }, index.h("vaadin-date-picker", { value: this.filterData.filterFromCalendar, onChange: (event) => this.handleFilterFrom(event), placeholder: translate$1('filterFromCalendar', this.language), class: "VaadinDatePicker" }), index.h("vaadin-date-picker", { value: this.filterData.filterToCalendar, onChange: (event) => this.handleFilterTo(event), placeholder: translate$1('filterToCalendar', this.language), class: "VaadinDatePicker" }))), index.h("div", { class: "FilterModalFooter" }, index.h("button", { class: "FilterModalButton", onClick: () => this.filterSearch() }, translate$1('filterModalButton', this.language))))));
22352
+ return (index.h("div", { class: "HelperFilters", ref: el => this.stylingContainer = el }, index.h("div", { class: "FilterButtonsWrapper" }, index.h("button", { class: "FilterOpen", onClick: () => this.toggleFilterModal() }, translate$1('filterOpen', this.language)), (this.showClearButton || this.quickFiltersActive) ?
22353
+ index.h("button", { class: "FilterClear", onClick: () => this.resetSearch() }, translate$1('filterClear', this.language))
22354
+ :
22355
+ null), index.h("helper-modal", { "title-modal": "Filter Modal", visible: this.showFilterModal, "client-styling": this.clientStyling, "client-styling-url-content": this.clientStylingUrlContent }, index.h("div", { class: "FilterModalHeader" }, index.h("h3", { class: "FilterModalTitle" }, this.activateTicketSearch ? translate$1('filterModalTicketTitle', this.language) : translate$1('filterModalDrawTitle', this.language))), index.h("div", { class: "FilterModalBody" }, index.h("input", { id: "FilterById", type: "text", value: this.filterData.ticketDrawId, onInput: (event) => this.handleTicketDrawId(event), class: "FilterModalSearch", placeholder: this.activateTicketSearch ? translate$1('filterTicketPlaceholder', this.language) : translate$1('filterDrawPlaceholder', this.language) }), index.h("p", null, translate$1('filterOrDate', this.language)), index.h("div", { class: "FilterCalendarWrapper" }, index.h("vaadin-date-picker", { value: this.filterData.filterFromCalendar, onChange: (event) => this.handleFilterFrom(event), placeholder: translate$1('filterFromCalendar', this.language), class: "VaadinDatePicker" }), index.h("vaadin-date-picker", { value: this.filterData.filterToCalendar, onChange: (event) => this.handleFilterTo(event), placeholder: translate$1('filterToCalendar', this.language), class: "VaadinDatePicker" }))), index.h("div", { class: "FilterModalFooter" }, index.h("button", { class: "FilterModalButton", onClick: () => this.filterSearch() }, translate$1('filterModalButton', this.language))))));
22551
22356
  }
22552
22357
  };
22553
22358
  HelperFilters.style = helperFiltersCss;
22554
22359
 
22360
+ /**
22361
+ * @name isMobile
22362
+ * @description A method that returns if the browser used to access the app is from a mobile device or not
22363
+ * @param {String} userAgent window.navigator.userAgent
22364
+ * @returns {Boolean} true or false
22365
+ */
22366
+ const isMobile = (userAgent) => {
22367
+ return !!(userAgent.toLowerCase().match(/android/i) ||
22368
+ userAgent.toLowerCase().match(/blackberry|bb/i) ||
22369
+ userAgent.toLowerCase().match(/iphone|ipad|ipod/i) ||
22370
+ userAgent.toLowerCase().match(/windows phone|windows mobile|iemobile|wpdesktop/i));
22371
+ };
22372
+
22373
+ const helperModalCss = ":host{display:block}.HelperModalWrapper{position:fixed;left:0;top:0;width:100%;height:100%;background:rgba(0, 0, 0, 0.7);opacity:0;visibility:hidden;transform:scale(1.1);transition:visibility 0s linear 0.25s, opacity 0.25s 0s, transform 0.25s;z-index:1}.HelperModalVisible{opacity:1;visibility:visible;transform:scale(1);transition:visibility 0s linear 0s, opacity 0.25s 0s, transform 0.25s}.HelperModalContent{position:relative;border:solid 1px #848e97;box-shadow:2px 2px 2px rgba(0, 0, 0, 0.007);font-size:14px;padding:10px 10px 5px 10px;background-color:#fff;position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);border-radius:4px;width:600px;max-height:600px;overflow-y:scroll}.HelperModalMobileContent{background:#FFF;top:50%;left:50%;transform:translate(-50%, -50%);border-radius:4px;width:80%;max-height:350px}.HelperModalClose{cursor:pointer;position:absolute;top:15px;right:15px;font-size:20px;color:#000}.HelperModalMobileClose{position:absolute;top:15px;right:15px;font-size:20px;color:#000}";
22374
+
22375
+ const HelperModal = class {
22376
+ constructor(hostRef) {
22377
+ index.registerInstance(this, hostRef);
22378
+ this.cancel = index.createEvent(this, "modalCloseEvent", 7);
22379
+ /**
22380
+ * Toggles if the helper is visible or not
22381
+ */
22382
+ this.visible = true;
22383
+ this.userAgent = window.navigator.userAgent;
22384
+ }
22385
+ handleHelperModalClose() {
22386
+ this.visible = false;
22387
+ this.cancel.emit();
22388
+ }
22389
+ ;
22390
+ render() {
22391
+ return ((this.visible &&
22392
+ index.h("div", { class: this.visible ? "HelperModalWrapper HelperModalVisible" : "HelperModalWrapper" }, index.h("div", { class: "HelperModalWrapper HelperModalVisible" }, index.h("div", { class: "HelperModalContent" + (isMobile(this.userAgent) ? ' HelperModalMobileContent' : '') }, index.h("span", { class: "HelperModalClose" + (isMobile(this.userAgent) ? ' HelperModalMobileClose' : ''), onClick: this.handleHelperModalClose.bind(this) }, "X"), index.h("slot", null))))));
22393
+ }
22394
+ };
22395
+ HelperModal.style = helperModalCss;
22396
+
22555
22397
  exports.helper_filters = HelperFilters;
22398
+ exports.helper_modal = HelperModal;