@vaadin/field-base 22.0.0-alpha5 → 22.0.0-alpha9

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 (77) hide show
  1. package/index.d.ts +7 -15
  2. package/index.js +7 -15
  3. package/package.json +24 -18
  4. package/src/aria-label-controller.d.ts +11 -0
  5. package/src/aria-label-controller.js +53 -0
  6. package/src/checked-mixin.d.ts +21 -0
  7. package/src/checked-mixin.js +54 -0
  8. package/src/delegate-focus-mixin.d.ts +2 -2
  9. package/src/delegate-focus-mixin.js +150 -133
  10. package/src/delegate-state-mixin.d.ts +1 -1
  11. package/src/delegate-state-mixin.js +100 -88
  12. package/src/field-mixin.d.ts +39 -0
  13. package/src/field-mixin.js +317 -0
  14. package/src/input-constraints-mixin.d.ts +4 -2
  15. package/src/input-constraints-mixin.js +107 -64
  16. package/src/input-control-mixin.d.ts +52 -0
  17. package/src/input-control-mixin.js +170 -0
  18. package/src/input-controller.d.ts +11 -0
  19. package/src/input-controller.js +35 -0
  20. package/src/input-field-mixin.d.ts +2 -16
  21. package/src/input-field-mixin.js +125 -80
  22. package/src/input-mixin.d.ts +1 -1
  23. package/src/input-mixin.js +156 -145
  24. package/src/label-mixin.d.ts +2 -2
  25. package/src/label-mixin.js +73 -60
  26. package/src/pattern-mixin.js +9 -9
  27. package/src/shadow-focus-mixin.d.ts +21 -0
  28. package/src/shadow-focus-mixin.js +87 -0
  29. package/src/slot-controller.d.ts +8 -0
  30. package/src/slot-controller.js +36 -0
  31. package/src/slot-label-mixin.d.ts +20 -0
  32. package/src/slot-label-mixin.js +38 -0
  33. package/src/slot-styles-mixin.js +38 -31
  34. package/src/slot-target-mixin.d.ts +32 -0
  35. package/src/slot-target-mixin.js +110 -0
  36. package/src/styles/clear-button-styles.d.ts +8 -0
  37. package/src/styles/clear-button-styles.js +21 -0
  38. package/src/styles/field-shared-styles.d.ts +8 -0
  39. package/src/styles/field-shared-styles.js +29 -0
  40. package/src/styles/input-field-container-styles.d.ts +8 -0
  41. package/src/styles/input-field-container-styles.js +16 -0
  42. package/src/styles/input-field-shared-styles.d.ts +8 -0
  43. package/src/styles/input-field-shared-styles.js +10 -0
  44. package/src/text-area-controller.d.ts +11 -0
  45. package/src/text-area-controller.js +38 -0
  46. package/src/validate-mixin.d.ts +1 -9
  47. package/src/validate-mixin.js +43 -118
  48. package/src/active-mixin.d.ts +0 -26
  49. package/src/active-mixin.js +0 -106
  50. package/src/aria-label-mixin.d.ts +0 -20
  51. package/src/aria-label-mixin.js +0 -71
  52. package/src/char-length-mixin.d.ts +0 -30
  53. package/src/char-length-mixin.js +0 -42
  54. package/src/clear-button-mixin.d.ts +0 -28
  55. package/src/clear-button-mixin.js +0 -82
  56. package/src/delegate-input-state-mixin.d.ts +0 -43
  57. package/src/delegate-input-state-mixin.js +0 -63
  58. package/src/disabled-mixin.d.ts +0 -23
  59. package/src/disabled-mixin.js +0 -60
  60. package/src/field-aria-mixin.d.ts +0 -24
  61. package/src/field-aria-mixin.js +0 -61
  62. package/src/focus-mixin.d.ts +0 -33
  63. package/src/focus-mixin.js +0 -104
  64. package/src/helper-text-mixin.d.ts +0 -24
  65. package/src/helper-text-mixin.js +0 -144
  66. package/src/input-slot-mixin.d.ts +0 -26
  67. package/src/input-slot-mixin.js +0 -71
  68. package/src/keyboard-mixin.d.ts +0 -32
  69. package/src/keyboard-mixin.js +0 -51
  70. package/src/slot-mixin.d.ts +0 -23
  71. package/src/slot-mixin.js +0 -49
  72. package/src/tabindex-mixin.d.ts +0 -29
  73. package/src/tabindex-mixin.js +0 -78
  74. package/src/text-area-slot-mixin.d.ts +0 -21
  75. package/src/text-area-slot-mixin.js +0 -56
  76. package/src/text-field-mixin.d.ts +0 -21
  77. package/src/text-field-mixin.js +0 -17
@@ -1,82 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
- import { dedupingMixin } from '@polymer/polymer/lib/utils/mixin.js';
7
- import { InputMixin } from './input-mixin.js';
8
- import { KeyboardMixin } from './keyboard-mixin.js';
9
-
10
- const ClearButtonMixinImplementation = (superclass) =>
11
- class ClearButtonMixinClass extends InputMixin(KeyboardMixin(superclass)) {
12
- static get properties() {
13
- return {
14
- /**
15
- * Set to true to display the clear icon which clears the input.
16
- * @attr {boolean} clear-button-visible
17
- */
18
- clearButtonVisible: {
19
- type: Boolean,
20
- reflectToAttribute: true,
21
- value: false
22
- }
23
- };
24
- }
25
-
26
- /**
27
- * Any element extending this mixin is required to implement this getter.
28
- * It returns the reference to the clear button element.
29
- * @protected
30
- * @return {Element | null | undefined}
31
- */
32
- get clearElement() {
33
- console.warn(`Please implement the 'clearElement' property in <${this.localName}>`);
34
- return null;
35
- }
36
-
37
- /** @protected */
38
- get _clearOnEsc() {
39
- return true;
40
- }
41
-
42
- /** @protected */
43
- ready() {
44
- super.ready();
45
-
46
- if (this.clearElement) {
47
- this.clearElement.addEventListener('click', (e) => this._onClearButtonClick(e));
48
- }
49
- }
50
-
51
- /**
52
- * @param {Event} event
53
- * @protected
54
- */
55
- _onClearButtonClick(event) {
56
- event.preventDefault();
57
- this.inputElement.focus();
58
- this.clear();
59
- this.inputElement.dispatchEvent(new Event('input', { bubbles: true, composed: true }));
60
- this.inputElement.dispatchEvent(new Event('change', { bubbles: true }));
61
- }
62
-
63
- /**
64
- * @param {KeyboardEvent} event
65
- * @protected
66
- * @override
67
- */
68
- _onKeyDown(event) {
69
- super._onKeyDown(event);
70
-
71
- if (event.key === 'Escape' && this.clearButtonVisible && this._clearOnEsc) {
72
- const dispatchChange = !!this.value;
73
- this.clear();
74
- dispatchChange && this.inputElement.dispatchEvent(new Event('change', { bubbles: true }));
75
- }
76
- }
77
- };
78
-
79
- /**
80
- * A mixin to add clear button support to field components.
81
- */
82
- export const ClearButtonMixin = dedupingMixin(ClearButtonMixinImplementation);
@@ -1,43 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
- import { DelegateStateMixin } from './delegate-state-mixin.js';
7
- import { InputMixin } from './input-mixin.js';
8
- import { ValidateMixin } from './validate-mixin.js';
9
-
10
- /**
11
- * A mixin to forward properties to the input element.
12
- */
13
- declare function DelegateInputStateMixin<T extends new (...args: any[]) => {}>(
14
- base: T
15
- ): T & DelegateInputStateMixinConstructor;
16
-
17
- interface DelegateInputStateMixinConstructor {
18
- new (...args: any[]): DelegateInputStateMixin;
19
- }
20
-
21
- interface DelegateInputStateMixin extends DelegateStateMixin, ValidateMixin, InputMixin {
22
- /**
23
- * The name of this field.
24
- */
25
- name: string;
26
-
27
- /**
28
- * A hint to the user of what can be entered in the field.
29
- */
30
- placeholder: string;
31
-
32
- /**
33
- * When present, it specifies that the field is read-only.
34
- */
35
- readonly: boolean;
36
-
37
- /**
38
- * The text usually displayed in a tooltip popup when the mouse is over the field.
39
- */
40
- title: string;
41
- }
42
-
43
- export { DelegateInputStateMixinConstructor, DelegateInputStateMixin };
@@ -1,63 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
- import { dedupingMixin } from '@polymer/polymer/lib/utils/mixin.js';
7
- import { DelegateStateMixin } from './delegate-state-mixin.js';
8
- import { InputMixin } from './input-mixin.js';
9
- import { ValidateMixin } from './validate-mixin.js';
10
-
11
- const DelegateInputStateMixinImplementation = (superclass) =>
12
- class DelegateInputStateMixinClass extends DelegateStateMixin(ValidateMixin(InputMixin(superclass))) {
13
- static get properties() {
14
- return {
15
- /**
16
- * The name of this field.
17
- */
18
- name: {
19
- type: String,
20
- reflectToAttribute: true
21
- },
22
-
23
- /**
24
- * A hint to the user of what can be entered in the field.
25
- */
26
- placeholder: {
27
- type: String,
28
- reflectToAttribute: true
29
- },
30
-
31
- /**
32
- * When present, it specifies that the field is read-only.
33
- */
34
- readonly: {
35
- type: Boolean,
36
- value: false,
37
- reflectToAttribute: true
38
- },
39
-
40
- /**
41
- * The text usually displayed in a tooltip popup when the mouse is over the field.
42
- */
43
- title: {
44
- type: String,
45
- reflectToAttribute: true
46
- }
47
- };
48
- }
49
-
50
- static get delegateAttrs() {
51
- return ['name', 'type', 'placeholder', 'required', 'readonly', 'invalid', 'title'];
52
- }
53
-
54
- /** @protected */
55
- get _delegateStateTarget() {
56
- return this.inputElement;
57
- }
58
- };
59
-
60
- /**
61
- * A mixin to delegate attributes to the input element.
62
- */
63
- export const DelegateInputStateMixin = dedupingMixin(DelegateInputStateMixinImplementation);
@@ -1,23 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
-
7
- /**
8
- * A mixin to provide disabled property for field components.
9
- */
10
- declare function DisabledMixin<T extends new (...args: any[]) => {}>(base: T): T & DisabledMixinConstructor;
11
-
12
- interface DisabledMixinConstructor {
13
- new (...args: any[]): DisabledMixin;
14
- }
15
-
16
- interface DisabledMixin {
17
- /**
18
- * If true, the user cannot interact with this element.
19
- */
20
- disabled: boolean;
21
- }
22
-
23
- export { DisabledMixinConstructor, DisabledMixin };
@@ -1,60 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
- import { dedupingMixin } from '@polymer/polymer/lib/utils/mixin.js';
7
-
8
- const DisabledMixinImplementation = (superclass) =>
9
- class DisabledMixinClass extends superclass {
10
- static get properties() {
11
- return {
12
- /**
13
- * If true, the user cannot interact with this element.
14
- */
15
- disabled: {
16
- type: Boolean,
17
- value: false,
18
- observer: '_disabledChanged',
19
- reflectToAttribute: true
20
- }
21
- };
22
- }
23
-
24
- /**
25
- * @param {boolean} disabled
26
- * @protected
27
- */
28
- _disabledChanged(disabled) {
29
- this._setAriaDisabled(disabled);
30
- }
31
-
32
- /**
33
- * @param {boolean} disabled
34
- * @protected
35
- */
36
- _setAriaDisabled(disabled) {
37
- if (disabled) {
38
- this.setAttribute('aria-disabled', 'true');
39
- } else {
40
- this.removeAttribute('aria-disabled');
41
- }
42
- }
43
-
44
- /**
45
- * Overrides the default element `click` method in order to prevent
46
- * firing the `click` event when the element is disabled.
47
- *
48
- * @override
49
- */
50
- click() {
51
- if (!this.disabled) {
52
- super.click();
53
- }
54
- }
55
- };
56
-
57
- /**
58
- * A mixin to provide disabled property for field components.
59
- */
60
- export const DisabledMixin = dedupingMixin(DisabledMixinImplementation);
@@ -1,24 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
- import { HelperTextMixin } from './helper-text-mixin.js';
7
- import { ValidateMixin } from './validate-mixin.js';
8
-
9
- /**
10
- * A mixin to handle field ARIA attributes based on the label, error message and helper text.
11
- */
12
- declare function FieldAriaMixin<T extends new (...args: any[]) => {}>(base: T): T & FieldAriaMixinConstructor;
13
-
14
- interface FieldAriaMixinConstructor {
15
- new (...args: any[]): FieldAriaMixin;
16
- }
17
-
18
- interface FieldAriaMixin extends HelperTextMixin, ValidateMixin {
19
- readonly _ariaTarget: HTMLElement;
20
-
21
- readonly _ariaAttr: string;
22
- }
23
-
24
- export { FieldAriaMixin, FieldAriaMixinConstructor };
@@ -1,61 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
- import { dedupingMixin } from '@polymer/polymer/lib/utils/mixin.js';
7
- import { HelperTextMixin } from './helper-text-mixin.js';
8
- import { ValidateMixin } from './validate-mixin.js';
9
-
10
- const FieldAriaMixinImplementation = (superclass) =>
11
- class FieldAriaMixinClass extends HelperTextMixin(ValidateMixin(superclass)) {
12
- /** @protected */
13
- get _ariaTarget() {
14
- return this;
15
- }
16
-
17
- /** @protected */
18
- get _ariaAttr() {
19
- return 'aria-describedby';
20
- }
21
-
22
- static get observers() {
23
- return ['__ariaChanged(invalid, _helperId)'];
24
- }
25
-
26
- /** @protected */
27
- ready() {
28
- super.ready();
29
-
30
- this._updateAriaAttribute(this.invalid, this._helperId);
31
- }
32
-
33
- /** @protected */
34
- _updateAriaAttribute(invalid, helperId) {
35
- const attr = this._ariaAttr;
36
-
37
- if (this._ariaTarget && attr) {
38
- // For groups, add all IDs to aria-labelledby rather than aria-describedby -
39
- // that should guarantee that it's announced when the group is entered.
40
- const ariaIds = attr === 'aria-describedby' ? [helperId] : [this._labelId, helperId];
41
-
42
- // Error message ID needs to be dynamically added / removed based on the validity
43
- // Otherwise assistive technologies would announce the error, even if we hide it.
44
- if (invalid) {
45
- ariaIds.push(this._errorId);
46
- }
47
-
48
- this._ariaTarget.setAttribute(attr, ariaIds.join(' '));
49
- }
50
- }
51
-
52
- /** @private */
53
- __ariaChanged(invalid, helperId) {
54
- this._updateAriaAttribute(invalid, helperId);
55
- }
56
- };
57
-
58
- /**
59
- * A mixin to handle field ARIA attributes based on the label, error message and helper text.
60
- */
61
- export const FieldAriaMixin = dedupingMixin(FieldAriaMixinImplementation);
@@ -1,33 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
-
7
- /**
8
- * A mixin to handle `focused` and `focus-ring` attributes based on focus.
9
- */
10
- declare function FocusMixin<T extends new (...args: any[]) => {}>(base: T): T & FocusMixinConstructor;
11
-
12
- interface FocusMixinConstructor {
13
- new (...args: any[]): FocusMixin;
14
- }
15
-
16
- interface FocusMixin {
17
- /**
18
- * Override to change how focused and focus-ring attributes are set.
19
- */
20
- _setFocused(focused: boolean): void;
21
-
22
- /**
23
- * Override to define if the field receives focus based on the event.
24
- */
25
- _shouldSetFocus(event: FocusEvent): boolean;
26
-
27
- /**
28
- * Override to define if the field loses focus based on the event.
29
- */
30
- _shouldRemoveFocus(event: FocusEvent): boolean;
31
- }
32
-
33
- export { FocusMixinConstructor, FocusMixin };
@@ -1,104 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
- import { dedupingMixin } from '@polymer/polymer/lib/utils/mixin.js';
7
-
8
- // We consider the keyboard to be active if the window has received a keydown
9
- // event since the last mousedown event.
10
- let keyboardActive = false;
11
-
12
- // Listen for top-level keydown and mousedown events.
13
- // Use capture phase so we detect events even if they're handled.
14
- window.addEventListener(
15
- 'keydown',
16
- () => {
17
- keyboardActive = true;
18
- },
19
- { capture: true }
20
- );
21
-
22
- window.addEventListener(
23
- 'mousedown',
24
- () => {
25
- keyboardActive = false;
26
- },
27
- { capture: true }
28
- );
29
-
30
- const FocusMixinImplementation = (superclass) =>
31
- class FocusMixinClass extends superclass {
32
- /** @protected */
33
- ready() {
34
- this.addEventListener('focusin', (e) => {
35
- if (this._shouldSetFocus(e)) {
36
- this._setFocused(true);
37
- }
38
- });
39
-
40
- this.addEventListener('focusout', (e) => {
41
- if (this._shouldRemoveFocus(e)) {
42
- this._setFocused(false);
43
- }
44
- });
45
-
46
- // In super.ready() other 'focusin' and 'focusout' listeners might be
47
- // added, so we call it after our own ones to ensure they execute first.
48
- // Issue to watch out: when incorrect, <vaadin-combo-box> refocuses the
49
- // input field on iOS after “Done” is pressed.
50
- super.ready();
51
- }
52
-
53
- /** @protected */
54
- disconnectedCallback() {
55
- super.disconnectedCallback();
56
-
57
- // in non-Chrome browsers, blur does not fire on the element when it is disconnected.
58
- // reproducible in `<vaadin-date-picker>` when closing on `Cancel` or `Today` click.
59
- if (this.hasAttribute('focused')) {
60
- this._setFocused(false);
61
- }
62
- }
63
-
64
- /**
65
- * Override to change how focused and focus-ring attributes are set.
66
- *
67
- * @param {boolean} focused
68
- * @protected
69
- */
70
- _setFocused(focused) {
71
- this.toggleAttribute('focused', focused);
72
-
73
- // focus-ring is true when the element was focused from the keyboard.
74
- // Focus Ring [A11ycasts]: https://youtu.be/ilj2P5-5CjI
75
- this.toggleAttribute('focus-ring', focused && keyboardActive);
76
- }
77
-
78
- /**
79
- * Override to define if the field receives focus based on the event.
80
- *
81
- * @param {FocusEvent} event
82
- * @return {boolean}
83
- * @protected
84
- */
85
- _shouldSetFocus(_event) {
86
- return true;
87
- }
88
-
89
- /**
90
- * Override to define if the field loses focus based on the event.
91
- *
92
- * @param {FocusEvent} event
93
- * @return {boolean}
94
- * @protected
95
- */
96
- _shouldRemoveFocus(_event) {
97
- return true;
98
- }
99
- };
100
-
101
- /**
102
- * A mixin to handle `focused` and `focus-ring` attributes based on focus.
103
- */
104
- export const FocusMixin = dedupingMixin(FocusMixinImplementation);
@@ -1,24 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
- import { SlotMixin } from './slot-mixin.js';
7
-
8
- /**
9
- * A mixin to provide helper text via corresponding property or named slot.
10
- */
11
- declare function HelperTextMixin<T extends new (...args: any[]) => {}>(base: T): T & HelperTextMixinConstructor;
12
-
13
- interface HelperTextMixinConstructor {
14
- new (...args: any[]): HelperTextMixin;
15
- }
16
-
17
- interface HelperTextMixin extends SlotMixin {
18
- /**
19
- * String used for the helper text.
20
- */
21
- helperText: string;
22
- }
23
-
24
- export { HelperTextMixinConstructor, HelperTextMixin };
@@ -1,144 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
- import { dedupingMixin } from '@polymer/polymer/lib/utils/mixin.js';
7
- import { SlotMixin } from './slot-mixin.js';
8
-
9
- const HelperTextMixinImplementation = (superclass) =>
10
- class HelperTextMixinClass extends SlotMixin(superclass) {
11
- static get properties() {
12
- return {
13
- /**
14
- * String used for the helper text.
15
- * @attr {string} helper-text
16
- */
17
- helperText: {
18
- type: String,
19
- observer: '_helperTextChanged'
20
- },
21
-
22
- /** @protected */
23
- _helperId: String
24
- };
25
- }
26
-
27
- get slots() {
28
- return {
29
- ...super.slots,
30
- helper: () => {
31
- const helper = document.createElement('div');
32
- helper.textContent = this.helperText;
33
- return helper;
34
- }
35
- };
36
- }
37
-
38
- /** @protected */
39
- get _helperNode() {
40
- return this._getDirectSlotChild('helper');
41
- }
42
-
43
- constructor() {
44
- super();
45
-
46
- // Ensure every instance has unique ID
47
- const uniqueId = (HelperTextMixinClass._uniqueId = 1 + HelperTextMixinClass._uniqueId || 0);
48
- this._helperId = `helper-${this.localName}-${uniqueId}`;
49
-
50
- // Save generated ID to restore later
51
- this.__savedHelperId = this._helperId;
52
- }
53
-
54
- /** @protected */
55
- connectedCallback() {
56
- super.connectedCallback();
57
-
58
- if (this._helperNode) {
59
- this._currentHelper = this._helperNode;
60
- this._helperNode.id = this._helperId;
61
-
62
- this._applyCustomHelper();
63
- }
64
- }
65
-
66
- /** @protected */
67
- ready() {
68
- super.ready();
69
-
70
- this.__helperSlot = this.shadowRoot.querySelector('[name="helper"]');
71
- this.__helperSlot.addEventListener('slotchange', this.__onHelperSlotChange.bind(this));
72
- this.__helperIdObserver = new MutationObserver((mutationRecord) => {
73
- mutationRecord.forEach((mutation) => {
74
- // only handle helper nodes
75
- if (
76
- mutation.type === 'attributes' &&
77
- mutation.attributeName === 'id' &&
78
- mutation.target === this._currentHelper &&
79
- mutation.target.id !== this.__savedHelperId
80
- ) {
81
- this.__updateHelperId(mutation.target);
82
- }
83
- });
84
- });
85
-
86
- this.__helperIdObserver.observe(this, { attributes: true, subtree: true });
87
- }
88
-
89
- /** @private */
90
- __updateHelperId(customHelper) {
91
- let newId;
92
-
93
- if (customHelper.id) {
94
- newId = customHelper.id;
95
- } else {
96
- newId = this.__savedHelperId;
97
- customHelper.id = newId;
98
- }
99
-
100
- this._helperId = newId;
101
- }
102
-
103
- /** @private */
104
- __onHelperSlotChange() {
105
- // Check fot slotted element node that is not the one created by this mixin.
106
- const customHelper = this.__helperSlot
107
- .assignedElements({ flatten: true })
108
- .find((node) => node !== this._currentHelper);
109
-
110
- if (customHelper) {
111
- this.__updateHelperId(customHelper);
112
-
113
- if (this._currentHelper.isConnected) {
114
- this._currentHelper.remove();
115
- }
116
-
117
- this._applyCustomHelper();
118
-
119
- this._currentHelper = customHelper;
120
- }
121
- }
122
-
123
- /** @protected */
124
- _applyCustomHelper() {
125
- const helper = this._helperNode.textContent;
126
- if (helper !== this.helperText) {
127
- this.helperText = helper;
128
- }
129
- }
130
-
131
- /** @protected */
132
- _helperTextChanged(helper) {
133
- if (this._helperNode) {
134
- this._helperNode.textContent = helper;
135
- }
136
-
137
- this.toggleAttribute('has-helper', Boolean(helper));
138
- }
139
- };
140
-
141
- /**
142
- * A mixin to provide helper text via corresponding property or named slot.
143
- */
144
- export const HelperTextMixin = dedupingMixin(HelperTextMixinImplementation);
@@ -1,26 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
4
- * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
- */
6
- import { DelegatesFocusMixin } from './delegate-focus-mixin.js';
7
- import { SlotMixin } from './slot-mixin.js';
8
- import { InputMixin } from './input-mixin.js';
9
-
10
- /**
11
- * A mixin to add `<input>` element to the corresponding named slot.
12
- */
13
- declare function InputSlotMixin<T extends new (...args: any[]) => {}>(base: T): T & InputSlotMixinConstructor;
14
-
15
- interface InputSlotMixinConstructor {
16
- new (...args: any[]): InputSlotMixin;
17
- }
18
-
19
- interface InputSlotMixin extends DelegatesFocusMixin, InputMixin, SlotMixin {
20
- /**
21
- * String used to define input type.
22
- */
23
- readonly type: string;
24
- }
25
-
26
- export { InputSlotMixinConstructor, InputSlotMixin };