@everymatrix/general-registration 1.10.5 → 1.10.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/cjs/checkbox-input_11.cjs.entry.js +1126 -526
  2. package/dist/cjs/general-registration.cjs.js +2 -2
  3. package/dist/cjs/{index-ad0df8ea.js → index-68f93e1e.js} +9 -1
  4. package/dist/cjs/loader.cjs.js +2 -2
  5. package/dist/collection/components/general-registration/general-registration.css +40 -14
  6. package/dist/collection/components/general-registration/general-registration.js +144 -275
  7. package/dist/components/checkbox-input2.js +2 -2
  8. package/dist/components/date-input2.js +15 -1441
  9. package/dist/components/email-input2.js +18 -6
  10. package/dist/components/general-input2.js +6 -6
  11. package/dist/components/general-registration.js +102 -248
  12. package/dist/components/input-field-shared-styles.js +13776 -0
  13. package/dist/components/number-input2.js +1 -1
  14. package/dist/components/password-input2.js +738 -6
  15. package/dist/components/pattern-mixin.js +84 -0
  16. package/dist/components/radio-input2.js +1 -1
  17. package/dist/components/select-input2.js +4 -4
  18. package/dist/components/tel-input2.js +12 -8
  19. package/dist/components/text-input2.js +17 -13
  20. package/dist/components/vaadin-button.js +1432 -0
  21. package/dist/components/vaadin-combo-box.js +3 -82
  22. package/dist/components/virtual-keyboard-controller.js +2136 -15909
  23. package/dist/esm/checkbox-input_11.entry.js +1126 -526
  24. package/dist/esm/general-registration.js +2 -2
  25. package/dist/esm/{index-bb9c8eb3.js → index-16916adb.js} +9 -1
  26. package/dist/esm/loader.js +2 -2
  27. package/dist/general-registration/general-registration.esm.js +1 -1
  28. package/dist/general-registration/p-8f644809.js +1 -0
  29. package/dist/general-registration/{p-8a77bab6.entry.js → p-b5f7ebdd.entry.js} +210 -100
  30. package/dist/types/Users/adrian.pripon/Documents/Work/stencil/widgets-stencil/packages/general-registration/.stencil/packages/general-input/src/utils/types.d.ts +4 -2
  31. package/dist/types/components/general-registration/general-registration.d.ts +20 -284
  32. package/dist/types/components.d.ts +11 -17
  33. package/package.json +3 -2
  34. package/dist/general-registration/p-4800d8b4.js +0 -1
@@ -1,6 +1,8 @@
1
- import { proxyCustomElement, HTMLElement as HTMLElement$1, createEvent, h } from '@stencil/core/internal/client';
1
+ import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
2
  import { t as translate$1 } from './locale.utils.js';
3
- import { i, r as registerStyles, m as menuOverlay, a as microTask, D as DisabledMixin, K as KeyboardMixin, T as TabindexMixin, F as FocusMixin, E as ElementMixin, b as ThemableMixin, C as ControllerMixin, P as PolymerElement, h as html, c as TooltipController, d as inputFieldShared, e as dedupingMixin, f as ElementMixin$1, w as wrap$1, g as PositionMixin, O as Overlay, l as legacyOptimizations, u as useShadow, j as OptionalMutableData, s as suppressTemplateNotifications, t as templatize, k as timeOut, n as microTask$1, o as modelForElement, p as matches, q as translate, v as isFirefox, x as Debouncer$1, y as timeOut$1, z as afterNextRender, A as DirMixin, B as DelegateFocusMixin, I as InputConstraintsMixin, G as isIOS, V as VirtualKeyboardController, H as InputControlMixin, J as InputController, L as LabelledInputController, M as inputFieldShared$1 } from './virtual-keyboard-controller.js';
3
+ import { i, r as registerStyles, a as inputFieldShared, d as dedupingMixin, E as ElementMixin, w as wrap, l as legacyOptimizations, u as useShadow, P as PolymerElement, s as suppressTemplateNotifications, t as timeOut, m as microTask, b as matches, c as translate, F as FocusMixin, T as ThemableMixin, h as html, D as Debouncer$1, e as timeOut$1, C as ControllerMixin, f as DirMixin, g as DelegateFocusMixin, I as InputConstraintsMixin, K as KeyboardMixin, j as InputControlMixin, k as InputController, L as LabelledInputController, n as TooltipController, o as inputFieldShared$1, p as ElementMixin$1 } from './input-field-shared-styles.js';
4
+ import { m as menuOverlay, P as PositionMixin, O as Overlay, a as OptionalMutableData, t as templatize, b as modelForElement, i as isFirefox, c as afterNextRender, d as isIOS, V as VirtualKeyboardController } from './virtual-keyboard-controller.js';
5
+ import { a as addListener, s as setTouchAction } from './vaadin-button.js';
4
6
 
5
7
  const datePickerOverlay = i`
6
8
  [part='overlay'] {
@@ -56,1435 +58,6 @@ registerStyles('vaadin-date-picker-overlay', [menuOverlay, datePickerOverlay], {
56
58
  moduleId: 'lumo-date-picker-overlay',
57
59
  });
58
60
 
59
- const button = i`
60
- :host {
61
- /* Sizing */
62
- --lumo-button-size: var(--lumo-size-m);
63
- min-width: calc(var(--lumo-button-size) * 2);
64
- height: var(--lumo-button-size);
65
- padding: 0 calc(var(--lumo-button-size) / 3 + var(--lumo-border-radius-m) / 2);
66
- margin: var(--lumo-space-xs) 0;
67
- box-sizing: border-box;
68
- /* Style */
69
- font-family: var(--lumo-font-family);
70
- font-size: var(--lumo-font-size-m);
71
- font-weight: 500;
72
- color: var(--_lumo-button-color, var(--lumo-primary-text-color));
73
- background-color: var(--_lumo-button-background-color, var(--lumo-contrast-5pct));
74
- border-radius: var(--lumo-border-radius-m);
75
- cursor: var(--lumo-clickable-cursor);
76
- -webkit-tap-highlight-color: transparent;
77
- -webkit-font-smoothing: antialiased;
78
- -moz-osx-font-smoothing: grayscale;
79
- }
80
-
81
- /* Set only for the internal parts so we don't affect the host vertical alignment */
82
- [part='label'],
83
- [part='prefix'],
84
- [part='suffix'] {
85
- line-height: var(--lumo-line-height-xs);
86
- }
87
-
88
- [part='label'] {
89
- padding: calc(var(--lumo-button-size) / 6) 0;
90
- }
91
-
92
- :host([theme~='small']) {
93
- font-size: var(--lumo-font-size-s);
94
- --lumo-button-size: var(--lumo-size-s);
95
- }
96
-
97
- :host([theme~='large']) {
98
- font-size: var(--lumo-font-size-l);
99
- --lumo-button-size: var(--lumo-size-l);
100
- }
101
-
102
- /* For interaction states */
103
- :host::before,
104
- :host::after {
105
- content: '';
106
- /* We rely on the host always being relative */
107
- position: absolute;
108
- z-index: 1;
109
- top: 0;
110
- right: 0;
111
- bottom: 0;
112
- left: 0;
113
- background-color: currentColor;
114
- border-radius: inherit;
115
- opacity: 0;
116
- pointer-events: none;
117
- }
118
-
119
- /* Hover */
120
-
121
- @media (any-hover: hover) {
122
- :host(:hover)::before {
123
- opacity: 0.02;
124
- }
125
- }
126
-
127
- /* Active */
128
-
129
- :host::after {
130
- transition: opacity 1.4s, transform 0.1s;
131
- filter: blur(8px);
132
- }
133
-
134
- :host([active])::before {
135
- opacity: 0.05;
136
- transition-duration: 0s;
137
- }
138
-
139
- :host([active])::after {
140
- opacity: 0.1;
141
- transition-duration: 0s, 0s;
142
- transform: scale(0);
143
- }
144
-
145
- /* Keyboard focus */
146
-
147
- :host([focus-ring]) {
148
- box-shadow: 0 0 0 2px var(--lumo-primary-color-50pct);
149
- }
150
-
151
- :host([theme~='primary'][focus-ring]) {
152
- box-shadow: 0 0 0 1px var(--lumo-base-color), 0 0 0 3px var(--lumo-primary-color-50pct);
153
- }
154
-
155
- /* Types (primary, tertiary, tertiary-inline */
156
-
157
- :host([theme~='tertiary']),
158
- :host([theme~='tertiary-inline']) {
159
- background-color: transparent !important;
160
- min-width: 0;
161
- }
162
-
163
- :host([theme~='tertiary']) {
164
- padding: 0 calc(var(--lumo-button-size) / 6);
165
- }
166
-
167
- :host([theme~='tertiary-inline'])::before {
168
- display: none;
169
- }
170
-
171
- :host([theme~='tertiary-inline']) {
172
- margin: 0;
173
- height: auto;
174
- padding: 0;
175
- line-height: inherit;
176
- font-size: inherit;
177
- }
178
-
179
- :host([theme~='tertiary-inline']) [part='label'] {
180
- padding: 0;
181
- overflow: visible;
182
- line-height: inherit;
183
- }
184
-
185
- :host([theme~='primary']) {
186
- background-color: var(--_lumo-button-primary-background-color, var(--lumo-primary-color));
187
- color: var(--_lumo-button-primary-color, var(--lumo-primary-contrast-color));
188
- font-weight: 600;
189
- min-width: calc(var(--lumo-button-size) * 2.5);
190
- }
191
-
192
- :host([theme~='primary'])::before {
193
- background-color: black;
194
- }
195
-
196
- @media (any-hover: hover) {
197
- :host([theme~='primary']:hover)::before {
198
- opacity: 0.05;
199
- }
200
- }
201
-
202
- :host([theme~='primary'][active])::before {
203
- opacity: 0.1;
204
- }
205
-
206
- :host([theme~='primary'][active])::after {
207
- opacity: 0.2;
208
- }
209
-
210
- /* Colors (success, error, contrast) */
211
-
212
- :host([theme~='success']) {
213
- color: var(--lumo-success-text-color);
214
- }
215
-
216
- :host([theme~='success'][theme~='primary']) {
217
- background-color: var(--lumo-success-color);
218
- color: var(--lumo-success-contrast-color);
219
- }
220
-
221
- :host([theme~='error']) {
222
- color: var(--lumo-error-text-color);
223
- }
224
-
225
- :host([theme~='error'][theme~='primary']) {
226
- background-color: var(--lumo-error-color);
227
- color: var(--lumo-error-contrast-color);
228
- }
229
-
230
- :host([theme~='contrast']) {
231
- color: var(--lumo-contrast);
232
- }
233
-
234
- :host([theme~='contrast'][theme~='primary']) {
235
- background-color: var(--lumo-contrast);
236
- color: var(--lumo-base-color);
237
- }
238
-
239
- /* Disabled state. Keep selectors after other color variants. */
240
-
241
- :host([disabled]) {
242
- pointer-events: none;
243
- color: var(--lumo-disabled-text-color);
244
- }
245
-
246
- :host([theme~='primary'][disabled]) {
247
- background-color: var(--lumo-contrast-30pct);
248
- color: var(--lumo-base-color);
249
- }
250
-
251
- :host([theme~='primary'][disabled]) [part] {
252
- opacity: 0.7;
253
- }
254
-
255
- /* Icons */
256
-
257
- [part] ::slotted(vaadin-icon),
258
- [part] ::slotted(iron-icon) {
259
- display: inline-block;
260
- width: var(--lumo-icon-size-m);
261
- height: var(--lumo-icon-size-m);
262
- }
263
-
264
- /* Vaadin icons are based on a 16x16 grid (unlike Lumo and Material icons with 24x24), so they look too big by default */
265
- [part] ::slotted(vaadin-icon[icon^='vaadin:']),
266
- [part] ::slotted(iron-icon[icon^='vaadin:']) {
267
- padding: 0.25em;
268
- box-sizing: border-box !important;
269
- }
270
-
271
- [part='prefix'] {
272
- margin-left: -0.25em;
273
- margin-right: 0.25em;
274
- }
275
-
276
- [part='suffix'] {
277
- margin-left: 0.25em;
278
- margin-right: -0.25em;
279
- }
280
-
281
- /* Icon-only */
282
-
283
- :host([theme~='icon']:not([theme~='tertiary-inline'])) {
284
- min-width: var(--lumo-button-size);
285
- padding-left: calc(var(--lumo-button-size) / 4);
286
- padding-right: calc(var(--lumo-button-size) / 4);
287
- }
288
-
289
- :host([theme~='icon']) [part='prefix'],
290
- :host([theme~='icon']) [part='suffix'] {
291
- margin-left: 0;
292
- margin-right: 0;
293
- }
294
-
295
- /* RTL specific styles */
296
-
297
- :host([dir='rtl']) [part='prefix'] {
298
- margin-left: 0.25em;
299
- margin-right: -0.25em;
300
- }
301
-
302
- :host([dir='rtl']) [part='suffix'] {
303
- margin-left: -0.25em;
304
- margin-right: 0.25em;
305
- }
306
-
307
- :host([dir='rtl'][theme~='icon']) [part='prefix'],
308
- :host([dir='rtl'][theme~='icon']) [part='suffix'] {
309
- margin-left: 0;
310
- margin-right: 0;
311
- }
312
- `;
313
-
314
- registerStyles('vaadin-button', button, { moduleId: 'lumo-button' });
315
-
316
- /**
317
- @license
318
- Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
319
- This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
320
- The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
321
- The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
322
- Code distributed by Google as part of the polymer project is also
323
- subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
324
- */
325
-
326
- const passiveTouchGestures = false;
327
- const wrap = (node) => node;
328
-
329
- // Detect native touch action support
330
- const HAS_NATIVE_TA = typeof document.head.style.touchAction === 'string';
331
- const GESTURE_KEY = '__polymerGestures';
332
- const HANDLED_OBJ = '__polymerGesturesHandled';
333
- const TOUCH_ACTION = '__polymerGesturesTouchAction';
334
- // Radius for tap and track
335
- const TAP_DISTANCE = 25;
336
- const TRACK_DISTANCE = 5;
337
- // Number of last N track positions to keep
338
- const TRACK_LENGTH = 2;
339
-
340
- const MOUSE_EVENTS = ['mousedown', 'mousemove', 'mouseup', 'click'];
341
- // An array of bitmask values for mapping MouseEvent.which to MouseEvent.buttons
342
- const MOUSE_WHICH_TO_BUTTONS = [0, 1, 4, 2];
343
- const MOUSE_HAS_BUTTONS = (function () {
344
- try {
345
- return new MouseEvent('test', { buttons: 1 }).buttons === 1;
346
- } catch (e) {
347
- return false;
348
- }
349
- })();
350
-
351
- /**
352
- * @param {string} name Possible mouse event name
353
- * @return {boolean} true if mouse event, false if not
354
- */
355
- function isMouseEvent(name) {
356
- return MOUSE_EVENTS.indexOf(name) > -1;
357
- }
358
-
359
- /* eslint no-empty: ["error", { "allowEmptyCatch": true }] */
360
- // check for passive event listeners
361
- let supportsPassive = false;
362
- (function () {
363
- try {
364
- const opts = Object.defineProperty({}, 'passive', {
365
- // eslint-disable-next-line getter-return
366
- get() {
367
- supportsPassive = true;
368
- },
369
- });
370
- window.addEventListener('test', null, opts);
371
- window.removeEventListener('test', null, opts);
372
- } catch (e) {}
373
- })();
374
-
375
- /**
376
- * Generate settings for event listeners, dependant on `passiveTouchGestures`
377
- *
378
- * @param {string} eventName Event name to determine if `{passive}` option is
379
- * needed
380
- * @return {{passive: boolean} | undefined} Options to use for addEventListener
381
- * and removeEventListener
382
- */
383
- function PASSIVE_TOUCH(eventName) {
384
- if (isMouseEvent(eventName) || eventName === 'touchend') {
385
- return;
386
- }
387
- if (HAS_NATIVE_TA && supportsPassive && passiveTouchGestures) {
388
- return { passive: true };
389
- }
390
- }
391
-
392
- // Check for touch-only devices
393
- const IS_TOUCH_ONLY = navigator.userAgent.match(/iP(?:[oa]d|hone)|Android/);
394
-
395
- // Defined at https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#enabling-and-disabling-form-controls:-the-disabled-attribute
396
- /** @type {!Object<boolean>} */
397
- const canBeDisabled = {
398
- button: true,
399
- command: true,
400
- fieldset: true,
401
- input: true,
402
- keygen: true,
403
- optgroup: true,
404
- option: true,
405
- select: true,
406
- textarea: true,
407
- };
408
-
409
- /**
410
- * @param {MouseEvent} ev event to test for left mouse button down
411
- * @return {boolean} has left mouse button down
412
- */
413
- function hasLeftMouseButton(ev) {
414
- const type = ev.type;
415
- // Exit early if the event is not a mouse event
416
- if (!isMouseEvent(type)) {
417
- return false;
418
- }
419
- // Ev.button is not reliable for mousemove (0 is overloaded as both left button and no buttons)
420
- // instead we use ev.buttons (bitmask of buttons) or fall back to ev.which (deprecated, 0 for no buttons, 1 for left button)
421
- if (type === 'mousemove') {
422
- // Allow undefined for testing events
423
- let buttons = ev.buttons === undefined ? 1 : ev.buttons;
424
- if (ev instanceof window.MouseEvent && !MOUSE_HAS_BUTTONS) {
425
- buttons = MOUSE_WHICH_TO_BUTTONS[ev.which] || 0;
426
- }
427
- // Buttons is a bitmask, check that the left button bit is set (1)
428
- return Boolean(buttons & 1);
429
- }
430
- // Allow undefined for testing events
431
- const button = ev.button === undefined ? 0 : ev.button;
432
- // Ev.button is 0 in mousedown/mouseup/click for left button activation
433
- return button === 0;
434
- }
435
-
436
- function isSyntheticClick(ev) {
437
- if (ev.type === 'click') {
438
- // Ev.detail is 0 for HTMLElement.click in most browsers
439
- if (ev.detail === 0) {
440
- return true;
441
- }
442
- // In the worst case, check that the x/y position of the click is within
443
- // the bounding box of the target of the event
444
- // Thanks IE 10 >:(
445
- const t = _findOriginalTarget(ev);
446
- // Make sure the target of the event is an element so we can use getBoundingClientRect,
447
- // if not, just assume it is a synthetic click
448
- if (!t.nodeType || /** @type {Element} */ (t).nodeType !== Node.ELEMENT_NODE) {
449
- return true;
450
- }
451
- const bcr = /** @type {Element} */ (t).getBoundingClientRect();
452
- // Use page x/y to account for scrolling
453
- const x = ev.pageX,
454
- y = ev.pageY;
455
- // Ev is a synthetic click if the position is outside the bounding box of the target
456
- return !(x >= bcr.left && x <= bcr.right && y >= bcr.top && y <= bcr.bottom);
457
- }
458
- return false;
459
- }
460
-
461
- const POINTERSTATE = {
462
- mouse: {
463
- target: null,
464
- mouseIgnoreJob: null,
465
- },
466
- touch: {
467
- x: 0,
468
- y: 0,
469
- id: -1,
470
- scrollDecided: false,
471
- },
472
- };
473
-
474
- function firstTouchAction(ev) {
475
- let ta = 'auto';
476
- const path = getComposedPath(ev);
477
- for (let i = 0, n; i < path.length; i++) {
478
- n = path[i];
479
- if (n[TOUCH_ACTION]) {
480
- ta = n[TOUCH_ACTION];
481
- break;
482
- }
483
- }
484
- return ta;
485
- }
486
-
487
- function trackDocument(stateObj, movefn, upfn) {
488
- stateObj.movefn = movefn;
489
- stateObj.upfn = upfn;
490
- document.addEventListener('mousemove', movefn);
491
- document.addEventListener('mouseup', upfn);
492
- }
493
-
494
- function untrackDocument(stateObj) {
495
- document.removeEventListener('mousemove', stateObj.movefn);
496
- document.removeEventListener('mouseup', stateObj.upfn);
497
- stateObj.movefn = null;
498
- stateObj.upfn = null;
499
- }
500
-
501
- /**
502
- * Returns the composedPath for the given event.
503
- * @param {Event} event to process
504
- * @return {!Array<!EventTarget>} Path of the event
505
- */
506
- const getComposedPath =
507
- window.ShadyDOM && window.ShadyDOM.noPatch
508
- ? window.ShadyDOM.composedPath
509
- : (event) => (event.composedPath && event.composedPath()) || [];
510
-
511
- /** @type {!Object<string, !GestureRecognizer>} */
512
- const gestures = {};
513
-
514
- /** @type {!Array<!GestureRecognizer>} */
515
- const recognizers = [];
516
-
517
- /**
518
- * Finds the element rendered on the screen at the provided coordinates.
519
- *
520
- * Similar to `document.elementFromPoint`, but pierces through
521
- * shadow roots.
522
- *
523
- * @param {number} x Horizontal pixel coordinate
524
- * @param {number} y Vertical pixel coordinate
525
- * @return {Element} Returns the deepest shadowRoot inclusive element
526
- * found at the screen position given.
527
- */
528
- function deepTargetFind(x, y) {
529
- let node = document.elementFromPoint(x, y);
530
- let next = node;
531
- // This code path is only taken when native ShadowDOM is used
532
- // if there is a shadowroot, it may have a node at x/y
533
- // if there is not a shadowroot, exit the loop
534
- while (next && next.shadowRoot && !window.ShadyDOM) {
535
- // If there is a node at x/y in the shadowroot, look deeper
536
- const oldNext = next;
537
- next = next.shadowRoot.elementFromPoint(x, y);
538
- // On Safari, elementFromPoint may return the shadowRoot host
539
- if (oldNext === next) {
540
- break;
541
- }
542
- if (next) {
543
- node = next;
544
- }
545
- }
546
- return node;
547
- }
548
-
549
- /**
550
- * A cheaper check than ev.composedPath()[0];
551
- *
552
- * @private
553
- * @param {Event|Touch} ev Event.
554
- * @return {EventTarget} Returns the event target.
555
- */
556
- function _findOriginalTarget(ev) {
557
- const path = getComposedPath(/** @type {?Event} */ (ev));
558
- // It shouldn't be, but sometimes path is empty (window on Safari).
559
- return path.length > 0 ? path[0] : ev.target;
560
- }
561
-
562
- /**
563
- * @private
564
- * @param {Event} ev Event.
565
- * @return {void}
566
- */
567
- function _handleNative(ev) {
568
- const type = ev.type;
569
- const node = ev.currentTarget;
570
- const gobj = node[GESTURE_KEY];
571
- if (!gobj) {
572
- return;
573
- }
574
- const gs = gobj[type];
575
- if (!gs) {
576
- return;
577
- }
578
- if (!ev[HANDLED_OBJ]) {
579
- ev[HANDLED_OBJ] = {};
580
- if (type.startsWith('touch')) {
581
- const t = ev.changedTouches[0];
582
- if (type === 'touchstart') {
583
- // Only handle the first finger
584
- if (ev.touches.length === 1) {
585
- POINTERSTATE.touch.id = t.identifier;
586
- }
587
- }
588
- if (POINTERSTATE.touch.id !== t.identifier) {
589
- return;
590
- }
591
- if (!HAS_NATIVE_TA) {
592
- if (type === 'touchstart' || type === 'touchmove') {
593
- _handleTouchAction(ev);
594
- }
595
- }
596
- }
597
- }
598
- const handled = ev[HANDLED_OBJ];
599
- // Used to ignore synthetic mouse events
600
- if (handled.skip) {
601
- return;
602
- }
603
- // Reset recognizer state
604
- for (let i = 0, r; i < recognizers.length; i++) {
605
- r = recognizers[i];
606
- if (gs[r.name] && !handled[r.name]) {
607
- if (r.flow && r.flow.start.indexOf(ev.type) > -1 && r.reset) {
608
- r.reset();
609
- }
610
- }
611
- }
612
- // Enforce gesture recognizer order
613
- for (let i = 0, r; i < recognizers.length; i++) {
614
- r = recognizers[i];
615
- if (gs[r.name] && !handled[r.name]) {
616
- handled[r.name] = true;
617
- r[type](ev);
618
- }
619
- }
620
- }
621
-
622
- /**
623
- * @private
624
- * @param {TouchEvent} ev Event.
625
- * @return {void}
626
- */
627
- function _handleTouchAction(ev) {
628
- const t = ev.changedTouches[0];
629
- const type = ev.type;
630
- if (type === 'touchstart') {
631
- POINTERSTATE.touch.x = t.clientX;
632
- POINTERSTATE.touch.y = t.clientY;
633
- POINTERSTATE.touch.scrollDecided = false;
634
- } else if (type === 'touchmove') {
635
- if (POINTERSTATE.touch.scrollDecided) {
636
- return;
637
- }
638
- POINTERSTATE.touch.scrollDecided = true;
639
- const ta = firstTouchAction(ev);
640
- let shouldPrevent = false;
641
- const dx = Math.abs(POINTERSTATE.touch.x - t.clientX);
642
- const dy = Math.abs(POINTERSTATE.touch.y - t.clientY);
643
- if (!ev.cancelable) ; else if (ta === 'none') {
644
- shouldPrevent = true;
645
- } else if (ta === 'pan-x') {
646
- shouldPrevent = dy > dx;
647
- } else if (ta === 'pan-y') {
648
- shouldPrevent = dx > dy;
649
- }
650
- if (shouldPrevent) {
651
- ev.preventDefault();
652
- } else {
653
- prevent('track');
654
- }
655
- }
656
- }
657
-
658
- /**
659
- * Adds an event listener to a node for the given gesture type.
660
- *
661
- * @param {!EventTarget} node Node to add listener on
662
- * @param {string} evType Gesture type: `down`, `up`, `track`, or `tap`
663
- * @param {!function(!Event):void} handler Event listener function to call
664
- * @return {boolean} Returns true if a gesture event listener was added.
665
- */
666
- function addListener(node, evType, handler) {
667
- if (gestures[evType]) {
668
- _add(node, evType, handler);
669
- return true;
670
- }
671
- return false;
672
- }
673
-
674
- /**
675
- * Automate the event listeners for the native events
676
- *
677
- * @private
678
- * @param {!EventTarget} node Node on which to add the event.
679
- * @param {string} evType Event type to add.
680
- * @param {function(!Event)} handler Event handler function.
681
- * @return {void}
682
- */
683
- function _add(node, evType, handler) {
684
- const recognizer = gestures[evType];
685
- const deps = recognizer.deps;
686
- const name = recognizer.name;
687
- let gobj = node[GESTURE_KEY];
688
- if (!gobj) {
689
- node[GESTURE_KEY] = gobj = {};
690
- }
691
- for (let i = 0, dep, gd; i < deps.length; i++) {
692
- dep = deps[i];
693
- // Don't add mouse handlers on iOS because they cause gray selection overlays
694
- if (IS_TOUCH_ONLY && isMouseEvent(dep) && dep !== 'click') {
695
- continue;
696
- }
697
- gd = gobj[dep];
698
- if (!gd) {
699
- gobj[dep] = gd = { _count: 0 };
700
- }
701
- if (gd._count === 0) {
702
- node.addEventListener(dep, _handleNative, PASSIVE_TOUCH(dep));
703
- }
704
- gd[name] = (gd[name] || 0) + 1;
705
- gd._count = (gd._count || 0) + 1;
706
- }
707
- node.addEventListener(evType, handler);
708
- if (recognizer.touchAction) {
709
- setTouchAction(node, recognizer.touchAction);
710
- }
711
- }
712
-
713
- /**
714
- * Registers a new gesture event recognizer for adding new custom
715
- * gesture event types.
716
- *
717
- * @param {!GestureRecognizer} recog Gesture recognizer descriptor
718
- * @return {void}
719
- */
720
- function register(recog) {
721
- recognizers.push(recog);
722
- for (let i = 0; i < recog.emits.length; i++) {
723
- gestures[recog.emits[i]] = recog;
724
- }
725
- }
726
-
727
- /**
728
- * @private
729
- * @param {string} evName Event name.
730
- * @return {Object} Returns the gesture for the given event name.
731
- */
732
- function _findRecognizerByEvent(evName) {
733
- for (let i = 0, r; i < recognizers.length; i++) {
734
- r = recognizers[i];
735
- for (let j = 0, n; j < r.emits.length; j++) {
736
- n = r.emits[j];
737
- if (n === evName) {
738
- return r;
739
- }
740
- }
741
- }
742
- return null;
743
- }
744
-
745
- /**
746
- * Sets scrolling direction on node.
747
- *
748
- * This value is checked on first move, thus it should be called prior to
749
- * adding event listeners.
750
- *
751
- * @param {!EventTarget} node Node to set touch action setting on
752
- * @param {string} value Touch action value
753
- * @return {void}
754
- */
755
- function setTouchAction(node, value) {
756
- if (HAS_NATIVE_TA && node instanceof HTMLElement) {
757
- // NOTE: add touchAction async so that events can be added in
758
- // custom element constructors. Otherwise we run afoul of custom
759
- // elements restriction against settings attributes (style) in the
760
- // constructor.
761
- microTask.run(() => {
762
- node.style.touchAction = value;
763
- });
764
- }
765
- node[TOUCH_ACTION] = value;
766
- }
767
-
768
- /**
769
- * Dispatches an event on the `target` element of `type` with the given
770
- * `detail`.
771
- * @private
772
- * @param {!EventTarget} target The element on which to fire an event.
773
- * @param {string} type The type of event to fire.
774
- * @param {!Object=} detail The detail object to populate on the event.
775
- * @return {void}
776
- */
777
- function _fire(target, type, detail) {
778
- const ev = new Event(type, { bubbles: true, cancelable: true, composed: true });
779
- ev.detail = detail;
780
- wrap(/** @type {!Node} */ (target)).dispatchEvent(ev);
781
- // Forward `preventDefault` in a clean way
782
- if (ev.defaultPrevented) {
783
- const preventer = detail.preventer || detail.sourceEvent;
784
- if (preventer && preventer.preventDefault) {
785
- preventer.preventDefault();
786
- }
787
- }
788
- }
789
-
790
- /**
791
- * Prevents the dispatch and default action of the given event name.
792
- *
793
- * @param {string} evName Event name.
794
- * @return {void}
795
- */
796
- function prevent(evName) {
797
- const recognizer = _findRecognizerByEvent(evName);
798
- if (recognizer.info) {
799
- recognizer.info.prevent = true;
800
- }
801
- }
802
-
803
- register({
804
- name: 'downup',
805
- deps: ['mousedown', 'touchstart', 'touchend'],
806
- flow: {
807
- start: ['mousedown', 'touchstart'],
808
- end: ['mouseup', 'touchend'],
809
- },
810
- emits: ['down', 'up'],
811
-
812
- info: {
813
- movefn: null,
814
- upfn: null,
815
- },
816
-
817
- /**
818
- * @this {GestureRecognizer}
819
- * @return {void}
820
- */
821
- reset() {
822
- untrackDocument(this.info);
823
- },
824
-
825
- /**
826
- * @this {GestureRecognizer}
827
- * @param {MouseEvent} e
828
- * @return {void}
829
- */
830
- mousedown(e) {
831
- if (!hasLeftMouseButton(e)) {
832
- return;
833
- }
834
- const t = _findOriginalTarget(e);
835
- // eslint-disable-next-line @typescript-eslint/no-this-alias
836
- const self = this;
837
- const movefn = (e) => {
838
- if (!hasLeftMouseButton(e)) {
839
- downupFire('up', t, e);
840
- untrackDocument(self.info);
841
- }
842
- };
843
- const upfn = (e) => {
844
- if (hasLeftMouseButton(e)) {
845
- downupFire('up', t, e);
846
- }
847
- untrackDocument(self.info);
848
- };
849
- trackDocument(this.info, movefn, upfn);
850
- downupFire('down', t, e);
851
- },
852
-
853
- /**
854
- * @this {GestureRecognizer}
855
- * @param {TouchEvent} e
856
- * @return {void}
857
- */
858
- touchstart(e) {
859
- downupFire('down', _findOriginalTarget(e), e.changedTouches[0], e);
860
- },
861
-
862
- /**
863
- * @this {GestureRecognizer}
864
- * @param {TouchEvent} e
865
- * @return {void}
866
- */
867
- touchend(e) {
868
- downupFire('up', _findOriginalTarget(e), e.changedTouches[0], e);
869
- },
870
- });
871
-
872
- /**
873
- * @param {string} type
874
- * @param {EventTarget} target
875
- * @param {Event|Touch} event
876
- * @param {Event=} preventer
877
- * @return {void}
878
- */
879
- function downupFire(type, target, event, preventer) {
880
- if (!target) {
881
- return;
882
- }
883
- _fire(target, type, {
884
- x: event.clientX,
885
- y: event.clientY,
886
- sourceEvent: event,
887
- preventer,
888
- prevent(e) {
889
- return prevent(e);
890
- },
891
- });
892
- }
893
-
894
- register({
895
- name: 'track',
896
- touchAction: 'none',
897
- deps: ['mousedown', 'touchstart', 'touchmove', 'touchend'],
898
- flow: {
899
- start: ['mousedown', 'touchstart'],
900
- end: ['mouseup', 'touchend'],
901
- },
902
- emits: ['track'],
903
-
904
- info: {
905
- x: 0,
906
- y: 0,
907
- state: 'start',
908
- started: false,
909
- moves: [],
910
- /** @this {GestureInfo} */
911
- addMove(move) {
912
- if (this.moves.length > TRACK_LENGTH) {
913
- this.moves.shift();
914
- }
915
- this.moves.push(move);
916
- },
917
- movefn: null,
918
- upfn: null,
919
- prevent: false,
920
- },
921
-
922
- /**
923
- * @this {GestureRecognizer}
924
- * @return {void}
925
- */
926
- reset() {
927
- this.info.state = 'start';
928
- this.info.started = false;
929
- this.info.moves = [];
930
- this.info.x = 0;
931
- this.info.y = 0;
932
- this.info.prevent = false;
933
- untrackDocument(this.info);
934
- },
935
-
936
- /**
937
- * @this {GestureRecognizer}
938
- * @param {MouseEvent} e
939
- * @return {void}
940
- */
941
- mousedown(e) {
942
- if (!hasLeftMouseButton(e)) {
943
- return;
944
- }
945
- const t = _findOriginalTarget(e);
946
- // eslint-disable-next-line @typescript-eslint/no-this-alias
947
- const self = this;
948
- const movefn = (e) => {
949
- const x = e.clientX,
950
- y = e.clientY;
951
- if (trackHasMovedEnough(self.info, x, y)) {
952
- // First move is 'start', subsequent moves are 'move', mouseup is 'end'
953
- self.info.state = self.info.started ? (e.type === 'mouseup' ? 'end' : 'track') : 'start';
954
- if (self.info.state === 'start') {
955
- // If and only if tracking, always prevent tap
956
- prevent('tap');
957
- }
958
- self.info.addMove({ x, y });
959
- if (!hasLeftMouseButton(e)) {
960
- // Always fire "end"
961
- self.info.state = 'end';
962
- untrackDocument(self.info);
963
- }
964
- if (t) {
965
- trackFire(self.info, t, e);
966
- }
967
- self.info.started = true;
968
- }
969
- };
970
- const upfn = (e) => {
971
- if (self.info.started) {
972
- movefn(e);
973
- }
974
-
975
- // Remove the temporary listeners
976
- untrackDocument(self.info);
977
- };
978
- // Add temporary document listeners as mouse retargets
979
- trackDocument(this.info, movefn, upfn);
980
- this.info.x = e.clientX;
981
- this.info.y = e.clientY;
982
- },
983
-
984
- /**
985
- * @this {GestureRecognizer}
986
- * @param {TouchEvent} e
987
- * @return {void}
988
- */
989
- touchstart(e) {
990
- const ct = e.changedTouches[0];
991
- this.info.x = ct.clientX;
992
- this.info.y = ct.clientY;
993
- },
994
-
995
- /**
996
- * @this {GestureRecognizer}
997
- * @param {TouchEvent} e
998
- * @return {void}
999
- */
1000
- touchmove(e) {
1001
- const t = _findOriginalTarget(e);
1002
- const ct = e.changedTouches[0];
1003
- const x = ct.clientX,
1004
- y = ct.clientY;
1005
- if (trackHasMovedEnough(this.info, x, y)) {
1006
- if (this.info.state === 'start') {
1007
- // If and only if tracking, always prevent tap
1008
- prevent('tap');
1009
- }
1010
- this.info.addMove({ x, y });
1011
- trackFire(this.info, t, ct);
1012
- this.info.state = 'track';
1013
- this.info.started = true;
1014
- }
1015
- },
1016
-
1017
- /**
1018
- * @this {GestureRecognizer}
1019
- * @param {TouchEvent} e
1020
- * @return {void}
1021
- */
1022
- touchend(e) {
1023
- const t = _findOriginalTarget(e);
1024
- const ct = e.changedTouches[0];
1025
- // Only trackend if track was started and not aborted
1026
- if (this.info.started) {
1027
- // Reset started state on up
1028
- this.info.state = 'end';
1029
- this.info.addMove({ x: ct.clientX, y: ct.clientY });
1030
- trackFire(this.info, t, ct);
1031
- }
1032
- },
1033
- });
1034
-
1035
- /**
1036
- * @param {!GestureInfo} info
1037
- * @param {number} x
1038
- * @param {number} y
1039
- * @return {boolean}
1040
- */
1041
- function trackHasMovedEnough(info, x, y) {
1042
- if (info.prevent) {
1043
- return false;
1044
- }
1045
- if (info.started) {
1046
- return true;
1047
- }
1048
- const dx = Math.abs(info.x - x);
1049
- const dy = Math.abs(info.y - y);
1050
- return dx >= TRACK_DISTANCE || dy >= TRACK_DISTANCE;
1051
- }
1052
-
1053
- /**
1054
- * @param {!GestureInfo} info
1055
- * @param {?EventTarget} target
1056
- * @param {Touch} touch
1057
- * @return {void}
1058
- */
1059
- function trackFire(info, target, touch) {
1060
- if (!target) {
1061
- return;
1062
- }
1063
- const secondlast = info.moves[info.moves.length - 2];
1064
- const lastmove = info.moves[info.moves.length - 1];
1065
- const dx = lastmove.x - info.x;
1066
- const dy = lastmove.y - info.y;
1067
- let ddx,
1068
- ddy = 0;
1069
- if (secondlast) {
1070
- ddx = lastmove.x - secondlast.x;
1071
- ddy = lastmove.y - secondlast.y;
1072
- }
1073
- _fire(target, 'track', {
1074
- state: info.state,
1075
- x: touch.clientX,
1076
- y: touch.clientY,
1077
- dx,
1078
- dy,
1079
- ddx,
1080
- ddy,
1081
- sourceEvent: touch,
1082
- hover() {
1083
- return deepTargetFind(touch.clientX, touch.clientY);
1084
- },
1085
- });
1086
- }
1087
-
1088
- register({
1089
- name: 'tap',
1090
- deps: ['mousedown', 'click', 'touchstart', 'touchend'],
1091
- flow: {
1092
- start: ['mousedown', 'touchstart'],
1093
- end: ['click', 'touchend'],
1094
- },
1095
- emits: ['tap'],
1096
- info: {
1097
- x: NaN,
1098
- y: NaN,
1099
- prevent: false,
1100
- },
1101
-
1102
- /**
1103
- * @this {GestureRecognizer}
1104
- * @return {void}
1105
- */
1106
- reset() {
1107
- this.info.x = NaN;
1108
- this.info.y = NaN;
1109
- this.info.prevent = false;
1110
- },
1111
-
1112
- /**
1113
- * @this {GestureRecognizer}
1114
- * @param {MouseEvent} e
1115
- * @return {void}
1116
- */
1117
- mousedown(e) {
1118
- if (hasLeftMouseButton(e)) {
1119
- this.info.x = e.clientX;
1120
- this.info.y = e.clientY;
1121
- }
1122
- },
1123
-
1124
- /**
1125
- * @this {GestureRecognizer}
1126
- * @param {MouseEvent} e
1127
- * @return {void}
1128
- */
1129
- click(e) {
1130
- if (hasLeftMouseButton(e)) {
1131
- trackForward(this.info, e);
1132
- }
1133
- },
1134
-
1135
- /**
1136
- * @this {GestureRecognizer}
1137
- * @param {TouchEvent} e
1138
- * @return {void}
1139
- */
1140
- touchstart(e) {
1141
- const touch = e.changedTouches[0];
1142
- this.info.x = touch.clientX;
1143
- this.info.y = touch.clientY;
1144
- },
1145
-
1146
- /**
1147
- * @this {GestureRecognizer}
1148
- * @param {TouchEvent} e
1149
- * @return {void}
1150
- */
1151
- touchend(e) {
1152
- trackForward(this.info, e.changedTouches[0], e);
1153
- },
1154
- });
1155
-
1156
- /**
1157
- * @param {!GestureInfo} info
1158
- * @param {Event | Touch} e
1159
- * @param {Event=} preventer
1160
- * @return {void}
1161
- */
1162
- function trackForward(info, e, preventer) {
1163
- const dx = Math.abs(e.clientX - info.x);
1164
- const dy = Math.abs(e.clientY - info.y);
1165
- // Find original target from `preventer` for TouchEvents, or `e` for MouseEvents
1166
- const t = _findOriginalTarget(preventer || e);
1167
- if (!t || (canBeDisabled[/** @type {!HTMLElement} */ (t).localName] && t.hasAttribute('disabled'))) {
1168
- return;
1169
- }
1170
- // Dx,dy can be NaN if `click` has been simulated and there was no `down` for `start`
1171
- if (isNaN(dx) || isNaN(dy) || (dx <= TAP_DISTANCE && dy <= TAP_DISTANCE) || isSyntheticClick(e)) {
1172
- // Prevent taps from being generated if an event has canceled them
1173
- if (!info.prevent) {
1174
- _fire(t, 'tap', {
1175
- x: e.clientX,
1176
- y: e.clientY,
1177
- sourceEvent: e,
1178
- preventer,
1179
- });
1180
- }
1181
- }
1182
- }
1183
-
1184
- /**
1185
- * @license
1186
- * Copyright (c) 2021 - 2022 Vaadin Ltd.
1187
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
1188
- */
1189
-
1190
- /**
1191
- * A mixin to toggle the `active` attribute.
1192
- *
1193
- * The attribute is set whenever the user activates the element by a pointer
1194
- * or presses an activation key on the element from the keyboard.
1195
- *
1196
- * The attribute is removed as soon as the element is deactivated
1197
- * by the pointer or by releasing the activation key.
1198
- *
1199
- * @polymerMixin
1200
- */
1201
- const ActiveMixin = (superclass) =>
1202
- class ActiveMixinClass extends DisabledMixin(KeyboardMixin(superclass)) {
1203
- /**
1204
- * An array of activation keys.
1205
- *
1206
- * See possible values here:
1207
- * https://developer.mozilla.org/ru/docs/Web/API/KeyboardEvent/key/Key_Values
1208
- *
1209
- * @protected
1210
- * @return {!Array<!string>}
1211
- */
1212
- get _activeKeys() {
1213
- return [' '];
1214
- }
1215
-
1216
- /** @protected */
1217
- ready() {
1218
- super.ready();
1219
-
1220
- addListener(this, 'down', (event) => {
1221
- if (this._shouldSetActive(event)) {
1222
- this._setActive(true);
1223
- }
1224
- });
1225
-
1226
- addListener(this, 'up', () => {
1227
- this._setActive(false);
1228
- });
1229
- }
1230
-
1231
- /** @protected */
1232
- disconnectedCallback() {
1233
- super.disconnectedCallback();
1234
-
1235
- // When the element is disconnecting from the DOM at the moment being active,
1236
- // the `active` attribute needs to be manually removed from the element.
1237
- // Otherwise, it will preserve on the element until the element is activated once again.
1238
- // The case reproduces for `<vaadin-date-picker>` when closing on `Cancel` or `Today` click.
1239
- this._setActive(false);
1240
- }
1241
-
1242
- /**
1243
- * @param {KeyboardEvent | MouseEvent} _event
1244
- * @protected
1245
- */
1246
- _shouldSetActive(_event) {
1247
- return !this.disabled;
1248
- }
1249
-
1250
- /**
1251
- * Sets the `active` attribute on the element if an activation key is pressed.
1252
- *
1253
- * @param {KeyboardEvent} event
1254
- * @protected
1255
- * @override
1256
- */
1257
- _onKeyDown(event) {
1258
- super._onKeyDown(event);
1259
-
1260
- if (this._shouldSetActive(event) && this._activeKeys.includes(event.key)) {
1261
- this._setActive(true);
1262
-
1263
- // Element can become hidden before the `keyup` event, e.g. on button click.
1264
- // Use document listener to ensure `active` attribute is removed correctly.
1265
- document.addEventListener(
1266
- 'keyup',
1267
- (e) => {
1268
- if (this._activeKeys.includes(e.key)) {
1269
- this._setActive(false);
1270
- }
1271
- },
1272
- { once: true },
1273
- );
1274
- }
1275
- }
1276
-
1277
- /**
1278
- * Toggles the `active` attribute on the element.
1279
- *
1280
- * @param {boolean} active
1281
- * @protected
1282
- */
1283
- _setActive(active) {
1284
- this.toggleAttribute('active', active);
1285
- }
1286
- };
1287
-
1288
- /**
1289
- * @license
1290
- * Copyright (c) 2017 - 2022 Vaadin Ltd.
1291
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
1292
- */
1293
-
1294
- /**
1295
- * A mixin providing common button functionality.
1296
- *
1297
- * @polymerMixin
1298
- * @mixes ActiveMixin
1299
- * @mixes FocusMixin
1300
- * @mixes TabindexMixin
1301
- */
1302
- const ButtonMixin = (superClass) =>
1303
- class ButtonMixinClass extends ActiveMixin(TabindexMixin(FocusMixin(superClass))) {
1304
- static get properties() {
1305
- return {
1306
- /**
1307
- * Indicates whether the element can be focused and where it participates in sequential keyboard navigation.
1308
- *
1309
- * @override
1310
- * @protected
1311
- */
1312
- tabindex: {
1313
- value: 0,
1314
- },
1315
- };
1316
- }
1317
-
1318
- /**
1319
- * By default, `Space` is the only possible activation key for a focusable HTML element.
1320
- * Nonetheless, the button is an exception as it can be also activated by pressing `Enter`.
1321
- * See the "Keyboard Support" section in https://www.w3.org/TR/wai-aria-practices/examples/button/button.html.
1322
- *
1323
- * @protected
1324
- * @override
1325
- */
1326
- get _activeKeys() {
1327
- return ['Enter', ' '];
1328
- }
1329
-
1330
- /** @protected */
1331
- ready() {
1332
- super.ready();
1333
-
1334
- // By default, if the user hasn't provided a custom role,
1335
- // the role attribute is set to "button".
1336
- if (!this.hasAttribute('role')) {
1337
- this.setAttribute('role', 'button');
1338
- }
1339
- }
1340
-
1341
- /**
1342
- * Since the button component is designed on the base of the `[role=button]` attribute,
1343
- * and doesn't have a native <button> inside, in order to be fully accessible from the keyboard,
1344
- * it should manually fire the `click` event once an activation key is pressed,
1345
- * as it follows from the WAI-ARIA specifications:
1346
- * https://www.w3.org/TR/wai-aria-practices-1.1/#button
1347
- *
1348
- * According to the UI Events specifications,
1349
- * the `click` event should be fired exactly on `keydown`:
1350
- * https://www.w3.org/TR/uievents/#event-type-keydown
1351
- *
1352
- * @param {KeyboardEvent} event
1353
- * @protected
1354
- * @override
1355
- */
1356
- _onKeyDown(event) {
1357
- super._onKeyDown(event);
1358
-
1359
- if (this._activeKeys.includes(event.key)) {
1360
- event.preventDefault();
1361
-
1362
- // `DisabledMixin` overrides the standard `click()` method
1363
- // so that it doesn't fire the `click` event when the element is disabled.
1364
- this.click();
1365
- }
1366
- }
1367
- };
1368
-
1369
- /**
1370
- * @license
1371
- * Copyright (c) 2017 - 2022 Vaadin Ltd.
1372
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
1373
- */
1374
-
1375
- /**
1376
- * `<vaadin-button>` is an accessible and customizable button that allows users to perform actions.
1377
- *
1378
- * ```html
1379
- * <vaadin-button>Press me</vaadin-button>
1380
- * ```
1381
- *
1382
- * ### Styling
1383
- *
1384
- * The following shadow DOM parts are available for styling:
1385
- *
1386
- * Part name | Description
1387
- * ----------|-------------
1388
- * `label` | The label (text) inside the button.
1389
- * `prefix` | A slot for content before the label (e.g. an icon).
1390
- * `suffix` | A slot for content after the label (e.g. an icon).
1391
- *
1392
- * The following attributes are available for styling:
1393
- *
1394
- * Attribute | Description
1395
- * -------------|-------------
1396
- * `active` | Set when the button is pressed down, either with mouse, touch or the keyboard.
1397
- * `disabled` | Set when the button is disabled.
1398
- * `focus-ring` | Set when the button is focused using the keyboard.
1399
- * `focused` | Set when the button is focused.
1400
- *
1401
- * See [Styling Components](https://vaadin.com/docs/latest/styling/custom-theme/styling-components) documentation.
1402
- *
1403
- * @extends HTMLElement
1404
- * @mixes ButtonMixin
1405
- * @mixes ControllerMixin
1406
- * @mixes ElementMixin
1407
- * @mixes ThemableMixin
1408
- */
1409
- class Button extends ButtonMixin(ElementMixin(ThemableMixin(ControllerMixin(PolymerElement)))) {
1410
- static get is() {
1411
- return 'vaadin-button';
1412
- }
1413
-
1414
- static get template() {
1415
- return html`
1416
- <style>
1417
- :host {
1418
- display: inline-block;
1419
- position: relative;
1420
- outline: none;
1421
- white-space: nowrap;
1422
- -webkit-user-select: none;
1423
- -moz-user-select: none;
1424
- user-select: none;
1425
- }
1426
-
1427
- :host([hidden]) {
1428
- display: none !important;
1429
- }
1430
-
1431
- /* Aligns the button with form fields when placed on the same line.
1432
- Note, to make it work, the form fields should have the same "::before" pseudo-element. */
1433
- .vaadin-button-container::before {
1434
- content: '\\2003';
1435
- display: inline-block;
1436
- width: 0;
1437
- max-height: 100%;
1438
- }
1439
-
1440
- .vaadin-button-container {
1441
- display: inline-flex;
1442
- align-items: center;
1443
- justify-content: center;
1444
- text-align: center;
1445
- width: 100%;
1446
- height: 100%;
1447
- min-height: inherit;
1448
- text-shadow: inherit;
1449
- }
1450
-
1451
- [part='prefix'],
1452
- [part='suffix'] {
1453
- flex: none;
1454
- }
1455
-
1456
- [part='label'] {
1457
- white-space: nowrap;
1458
- overflow: hidden;
1459
- text-overflow: ellipsis;
1460
- }
1461
- </style>
1462
- <div class="vaadin-button-container">
1463
- <span part="prefix" aria-hidden="true">
1464
- <slot name="prefix"></slot>
1465
- </span>
1466
- <span part="label">
1467
- <slot></slot>
1468
- </span>
1469
- <span part="suffix" aria-hidden="true">
1470
- <slot name="suffix"></slot>
1471
- </span>
1472
- </div>
1473
- <slot name="tooltip"></slot>
1474
- `;
1475
- }
1476
-
1477
- /** @protected */
1478
- ready() {
1479
- super.ready();
1480
-
1481
- this._tooltipController = new TooltipController(this);
1482
- this.addController(this._tooltipController);
1483
- }
1484
- }
1485
-
1486
- customElements.define(Button.is, Button);
1487
-
1488
61
  registerStyles(
1489
62
  'vaadin-date-picker-overlay-content',
1490
63
  i`
@@ -1928,7 +501,7 @@ const DisableUpgradeMixin = dedupingMixin((base) => {
1928
501
  * @extends {HTMLElement}
1929
502
  * @private
1930
503
  */
1931
- const superClass = ElementMixin$1(base);
504
+ const superClass = ElementMixin(base);
1932
505
 
1933
506
  // Work around for closure bug #126934458. Using `super` in a property
1934
507
  // getter does not work so instead we search the Base prototype for an
@@ -1997,7 +570,7 @@ const DisableUpgradeMixin = dedupingMixin((base) => {
1997
570
  if (this.__isUpgradeDisabled && value == null) {
1998
571
  super._initializeProperties();
1999
572
  this.__isUpgradeDisabled = false;
2000
- if (wrap$1(this).isConnected) {
573
+ if (wrap(this).isConnected) {
2001
574
  super.connectedCallback();
2002
575
  }
2003
576
  }
@@ -2665,7 +1238,7 @@ class DomRepeat extends domRepeatBase {
2665
1238
  // only perform attachment if the element was previously detached.
2666
1239
  if (this.__isDetached) {
2667
1240
  this.__isDetached = false;
2668
- let wrappedParent = wrap$1(wrap$1(this).parentNode);
1241
+ let wrappedParent = wrap(wrap(this).parentNode);
2669
1242
  for (let i=0; i<this.__instances.length; i++) {
2670
1243
  this.__attachInstance(i, wrappedParent);
2671
1244
  }
@@ -2822,7 +1395,7 @@ class DomRepeat extends domRepeatBase {
2822
1395
  __debounceRender(fn, delay = 0) {
2823
1396
  this.__renderDebouncer = Debouncer.debounce(
2824
1397
  this.__renderDebouncer
2825
- , delay > 0 ? timeOut.after(delay) : microTask$1
1398
+ , delay > 0 ? timeOut.after(delay) : microTask
2826
1399
  , fn.bind(this));
2827
1400
  enqueueDebouncer(this.__renderDebouncer);
2828
1401
  }
@@ -2976,7 +1549,7 @@ class DomRepeat extends domRepeatBase {
2976
1549
 
2977
1550
  __detachInstance(idx) {
2978
1551
  let inst = this.__instances[idx];
2979
- const wrappedRoot = wrap$1(inst.root);
1552
+ const wrappedRoot = wrap(inst.root);
2980
1553
  for (let i=0; i<inst.children.length; i++) {
2981
1554
  let el = inst.children[i];
2982
1555
  wrappedRoot.appendChild(el);
@@ -3007,7 +1580,7 @@ class DomRepeat extends domRepeatBase {
3007
1580
  const inst = this.__stampInstance(item, instIdx, itemIdx);
3008
1581
  let beforeRow = this.__instances[instIdx + 1];
3009
1582
  let beforeNode = beforeRow ? beforeRow.children[0] : this;
3010
- wrap$1(wrap$1(this).parentNode).insertBefore(inst.root, beforeNode);
1583
+ wrap(wrap(this).parentNode).insertBefore(inst.root, beforeNode);
3011
1584
  this.__instances[instIdx] = inst;
3012
1585
  return inst;
3013
1586
  }
@@ -6343,7 +4916,7 @@ registerStyles('vaadin-date-picker', [inputFieldShared$1, datePickerStyles], { m
6343
4916
  * @mixes InputControlMixin
6344
4917
  * @mixes DatePickerMixin
6345
4918
  */
6346
- class DatePicker extends DatePickerMixin(InputControlMixin(ThemableMixin(ElementMixin(PolymerElement)))) {
4919
+ class DatePicker extends DatePickerMixin(InputControlMixin(ThemableMixin(ElementMixin$1(PolymerElement)))) {
6347
4920
  static get is() {
6348
4921
  return 'vaadin-date-picker';
6349
4922
  }
@@ -6479,9 +5052,9 @@ class DatePicker extends DatePickerMixin(InputControlMixin(ThemableMixin(Element
6479
5052
 
6480
5053
  customElements.define(DatePicker.is, DatePicker);
6481
5054
 
6482
- const dateInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.date__wrapper{position:relative;display:flex;flex-direction:column-reverse;padding-top:10px}.date__label{color:#474747;font-size:16px;position:absolute;bottom:15px;left:5px;transform:translateY(-25px);transition:all 0.3s cubic-bezier(0.5, 0, 0.5, 1)}.date__label--required::after{content:\"*\";margin-left:5px;color:#666666}.date__input{width:inherit;position:relative;border:none;border-bottom:3px solid #666666;color:#666666;font-size:16px;font-family:inherit}.date__input:focus{outline:none;box-shadow:0 5px 5px rgba(16, 15, 15, 0.1)}.date__input::placeholder{color:#666666}.date__input--invalid{border-bottom:3px solid #cc0000}.date__input:placeholder-shown+.date__label{opacity:0;visibility:hidden;transform:translateY(0)}.date__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000}";
5055
+ const dateInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.date{font-family:\"Roboto\";font-style:normal}.date__wrapper{position:relative;width:100%;padding-top:26px}.date__label{font-family:inherit;font-style:normal;font-weight:500;font-size:16px;line-height:20px;color:#1F1F1F;position:absolute;top:0;left:0}.date__label--required::after{content:\"*\";font-family:inherit;color:#1F1F1F;margin-left:2px}.date__input{border:none;width:inherit;position:relative}.date__input[focused]::part(input-field){border-color:#3E3E3E}.date__input[invalid]::part(input-field){border-color:#cc0000b3}.date__input::part(input-field){border-radius:4px;background-color:#FFFFFF;border:2px solid #DEE1EE;color:#2A2E3F;border-radius:4px;background-color:transparent;font-family:inherit;font-style:normal;font-weight:300;font-size:16px;line-height:19px}.date__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000b3}";
6483
5056
 
6484
- const DateInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement$1 {
5057
+ const DateInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
6485
5058
  constructor() {
6486
5059
  super();
6487
5060
  this.__registerHost();
@@ -6532,7 +5105,8 @@ const DateInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement$1 {
6532
5105
  }
6533
5106
  }
6534
5107
  render() {
6535
- return h("div", { class: 'date__wrapper' }, h("vaadin-date-picker", { id: `${this.name}__input`, type: 'date', class: `date__input`, value: this.defaultValue, readOnly: this.autofilled, placeholder: `${this.displayName} ${this.validation.mandatory ? '*' : ''}`, required: this.validation.mandatory, max: this.validation.max, min: this.validation.min, onBlur: (e) => this.handleInput(e) }), h("label", { class: `date__label ${this.validation.mandatory ? 'date__label--required' : ''}}`, htmlFor: `${this.name}__input` }, this.displayName, " ", this.validation.mandatory ? '*' : ''), h("small", { class: 'date__error-message' }, this.errorMessage));
5108
+ const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'date__input--invalid';
5109
+ return h("div", { class: 'date__wrapper' }, h("label", { class: `date__label ${this.validation.mandatory ? 'date__label--required' : ''}}`, htmlFor: `${this.name}__input` }, this.displayName, " ", this.validation.mandatory ? '*' : ''), h("vaadin-date-picker", { id: `${this.name}__input`, type: 'date', class: `date__input ${invalidClass}`, value: this.defaultValue, readOnly: this.autofilled, placeholder: `${this.displayName} ${this.validation.mandatory ? '*' : ''}`, required: this.validation.mandatory, max: this.validation.max, min: this.validation.min, onBlur: (e) => this.handleInput(e) }), h("small", { class: 'date__error-message' }, this.errorMessage));
6536
5110
  }
6537
5111
  get element() { return this; }
6538
5112
  static get watchers() { return {