@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,71 +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 { DelegateFocusMixin } from './delegate-focus-mixin.js';
8
- import { InputMixin } from './input-mixin.js';
9
- import { SlotMixin } from './slot-mixin.js';
10
-
11
- const InputSlotMixinImplementation = (superclass) =>
12
- class InputSlotMixinClass extends DelegateFocusMixin(InputMixin(SlotMixin(superclass))) {
13
- static get properties() {
14
- /**
15
- * String used to define input type.
16
- */
17
- return {
18
- type: {
19
- type: String,
20
- readOnly: true
21
- }
22
- };
23
- }
24
-
25
- get slots() {
26
- return {
27
- ...super.slots,
28
- input: () => {
29
- const native = document.createElement('input');
30
- const value = this.getAttribute('value');
31
- if (value) {
32
- native.setAttribute('value', value);
33
- }
34
- const name = this.getAttribute('name');
35
- if (name) {
36
- native.setAttribute('name', name);
37
- }
38
- if (this.type) {
39
- native.setAttribute('type', this.type);
40
- }
41
- return native;
42
- }
43
- };
44
- }
45
-
46
- constructor() {
47
- super();
48
-
49
- // Ensure every instance has unique ID
50
- const uniqueId = (InputSlotMixinClass._uniqueId = 1 + InputSlotMixinClass._uniqueId || 0);
51
- this._inputId = `${this.localName}-${uniqueId}`;
52
- }
53
-
54
- /** @protected */
55
- ready() {
56
- super.ready();
57
-
58
- const inputNode = this._getDirectSlotChild('input');
59
- if (inputNode) {
60
- inputNode.id = this._inputId;
61
-
62
- this._setInputElement(inputNode);
63
- this._setFocusElement(inputNode);
64
- }
65
- }
66
- };
67
-
68
- /**
69
- * A mixin to add `<input>` element to the corresponding named slot.
70
- */
71
- export const InputSlotMixin = dedupingMixin(InputSlotMixinImplementation);
@@ -1,32 +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 that manages keyboard handling.
9
- * The mixin subscribes to the keyboard events while an actual implementation
10
- * for the event handlers is left to the client (a component or another mixin).
11
- */
12
- declare function KeyboardMixin<T extends new (...args: any[]) => {}>(base: T): T & KeyboardMixinConstructor;
13
-
14
- interface KeyboardMixinConstructor {
15
- new (...args: any[]): KeyboardMixin;
16
- }
17
-
18
- interface KeyboardMixin {
19
- /**
20
- * A handler for the `keydown` event. By default, it does nothing.
21
- * Override the method to implement your own behavior.
22
- */
23
- _onKeyDown(event: KeyboardEvent): void;
24
-
25
- /**
26
- * A handler for the `keyup` event. By default, it does nothing.
27
- * Override the method to implement your own behavior.
28
- */
29
- _onKeyUp(event: KeyboardEvent): void;
30
- }
31
-
32
- export { KeyboardMixinConstructor, KeyboardMixin };
@@ -1,51 +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 KeyboardMixinImplementation = (superclass) =>
9
- class KeyboardMixinClass extends superclass {
10
- /** @protected */
11
- ready() {
12
- super.ready();
13
-
14
- this.addEventListener('keydown', (event) => {
15
- this._onKeyDown(event);
16
- });
17
-
18
- this.addEventListener('keyup', (event) => {
19
- this._onKeyUp(event);
20
- });
21
- }
22
-
23
- /**
24
- * A handler for the `keydown` event. By default, it does nothing.
25
- * Override the method to implement your own behavior.
26
- *
27
- * @param {KeyboardEvent} _event
28
- * @protected
29
- */
30
- _onKeyDown(_event) {
31
- // To be implemented.
32
- }
33
-
34
- /**
35
- * A handler for the `keyup` event. By default, it does nothing.
36
- * Override the method to implement your own behavior.
37
- *
38
- * @param {KeyboardEvent} _event
39
- * @protected
40
- */
41
- _onKeyUp(_event) {
42
- // To be implemented.
43
- }
44
- };
45
-
46
- /**
47
- * A mixin that manages keyboard handling.
48
- * The mixin subscribes to the keyboard events while an actual implementation
49
- * for the event handlers is left to the client (a component or another mixin).
50
- */
51
- export const KeyboardMixin = dedupingMixin(KeyboardMixinImplementation);
@@ -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 content for named slots defined by component.
9
- */
10
- declare function SlotMixin<T extends new (...args: any[]) => {}>(base: T): T & SlotMixinConstructor;
11
-
12
- interface SlotMixinConstructor {
13
- new (...args: any[]): SlotMixin;
14
- }
15
-
16
- interface SlotMixin {
17
- /**
18
- * List of named slots to initialize.
19
- */
20
- readonly slots: Record<string, () => HTMLElement>;
21
- }
22
-
23
- export { SlotMixinConstructor, SlotMixin };
package/src/slot-mixin.js DELETED
@@ -1,49 +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 SlotMixinImplementation = (superclass) =>
9
- class SlotMixinClass extends superclass {
10
- /**
11
- * List of named slots to initialize.
12
- */
13
- get slots() {
14
- return {};
15
- }
16
-
17
- /** @protected */
18
- ready() {
19
- super.ready();
20
- this._connectSlotMixin();
21
- }
22
-
23
- /** @private */
24
- _connectSlotMixin() {
25
- Object.keys(this.slots).forEach((slotName) => {
26
- // Ignore labels of nested components, if any
27
- const hasContent = this._getDirectSlotChild(slotName) !== undefined;
28
-
29
- if (!hasContent) {
30
- const slotFactory = this.slots[slotName];
31
- const slotContent = slotFactory();
32
- if (slotContent instanceof Element) {
33
- slotContent.setAttribute('slot', slotName);
34
- this.appendChild(slotContent);
35
- }
36
- }
37
- });
38
- }
39
-
40
- /** @protected */
41
- _getDirectSlotChild(slotName) {
42
- return Array.from(this.children).find((el) => el.slot === slotName);
43
- }
44
- };
45
-
46
- /**
47
- * A mixin to provide content for named slots defined by component.
48
- */
49
- export const SlotMixin = dedupingMixin(SlotMixinImplementation);
@@ -1,29 +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 { DisabledMixin } from './disabled-mixin.js';
7
-
8
- /**
9
- * A mixin to provide the `tabindex` attribute.
10
- *
11
- * By default, the attribute is set to 0 that makes the element focusable.
12
- *
13
- * The attribute is set to -1 whenever the user disables the element
14
- * and restored with the last known value once the element is enabled.
15
- */
16
- declare function TabindexMixin<T extends new (...args: any[]) => {}>(base: T): T & TabindexMixinConstructor;
17
-
18
- interface TabindexMixinConstructor {
19
- new (...args: any[]): TabindexMixin;
20
- }
21
-
22
- interface TabindexMixin extends DisabledMixin {
23
- /**
24
- * Indicates whether the element can be focused and where it participates in sequential keyboard navigation.
25
- */
26
- tabindex: number | undefined | null;
27
- }
28
-
29
- export { TabindexMixinConstructor, TabindexMixin };
@@ -1,78 +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 { DisabledMixin } from './disabled-mixin.js';
8
-
9
- const TabindexMixinImplementation = (superclass) =>
10
- class TabindexMixinClass extends DisabledMixin(superclass) {
11
- static get properties() {
12
- return {
13
- /**
14
- * Indicates whether the element can be focused and where it participates in sequential keyboard navigation.
15
- */
16
- tabindex: {
17
- type: Number,
18
- value: 0,
19
- reflectToAttribute: true,
20
- observer: '_tabindexChanged'
21
- },
22
-
23
- /**
24
- * Stores the last known tabindex since the element has been disabled.
25
- *
26
- * @private
27
- */
28
- __lastTabIndex: {
29
- type: Number,
30
- value: 0
31
- }
32
- };
33
- }
34
-
35
- /**
36
- * When the element gets disabled, the observer saves the last known tabindex
37
- * and makes the element not focusable by setting tabindex to -1.
38
- * As soon as the element gets enabled, the observer restores the last known tabindex
39
- * so that the element can be focusable again.
40
- *
41
- * @protected
42
- * @override
43
- */
44
- _disabledChanged(disabled, oldDisabled) {
45
- super._disabledChanged(disabled, oldDisabled);
46
-
47
- if (disabled) {
48
- this.__lastTabIndex = this.tabindex;
49
- this.tabindex = -1;
50
- } else if (oldDisabled) {
51
- this.tabindex = this.__lastTabIndex;
52
- }
53
- }
54
-
55
- /**
56
- * When the user has changed tabindex while the element is disabled,
57
- * the observer reverts tabindex to -1 and rather saves the new tabindex value to apply it later.
58
- * The new value will be applied as soon as the element becomes enabled.
59
- *
60
- * @protected
61
- */
62
- _tabindexChanged(tabindex) {
63
- if (this.disabled && tabindex !== -1) {
64
- this.__lastTabIndex = tabindex;
65
- this.tabindex = -1;
66
- }
67
- }
68
- };
69
-
70
- /**
71
- * A mixin to provide the `tabindex` attribute.
72
- *
73
- * By default, the attribute is set to 0 that makes the element focusable.
74
- *
75
- * The attribute is set to -1 whenever the user disables the element
76
- * and restored with the last known value once the element is enabled.
77
- */
78
- export const TabindexMixin = dedupingMixin(TabindexMixinImplementation);
@@ -1,21 +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 `<textarea>` element to the corresponding named slot.
12
- */
13
- declare function TextAreaSlotMixin<T extends new (...args: any[]) => {}>(base: T): T & TextAreaSlotMixinConstructor;
14
-
15
- interface TextAreaSlotMixinConstructor {
16
- new (...args: any[]): TextAreaSlotMixin;
17
- }
18
-
19
- interface TextAreaSlotMixin extends DelegatesFocusMixin, InputMixin, SlotMixin {}
20
-
21
- export { TextAreaSlotMixinConstructor, TextAreaSlotMixin };
@@ -1,56 +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 { DelegateFocusMixin } from './delegate-focus-mixin.js';
8
- import { InputMixin } from './input-mixin.js';
9
- import { SlotMixin } from './slot-mixin.js';
10
-
11
- const TextAreaSlotMixinImplementation = (superclass) =>
12
- class TextAreaSlotMixinClass extends DelegateFocusMixin(InputMixin(SlotMixin(superclass))) {
13
- get slots() {
14
- return {
15
- ...super.slots,
16
- textarea: () => {
17
- const native = document.createElement('textarea');
18
- const value = this.getAttribute('value');
19
- if (value) {
20
- native.value = value;
21
- }
22
- const name = this.getAttribute('name');
23
- if (name) {
24
- native.setAttribute('name', name);
25
- }
26
- return native;
27
- }
28
- };
29
- }
30
-
31
- constructor() {
32
- super();
33
-
34
- // Ensure every instance has unique ID
35
- const uniqueId = (TextAreaSlotMixinClass._uniqueId = 1 + TextAreaSlotMixinClass._uniqueId || 0);
36
- this._textareaId = `${this.localName}-${uniqueId}`;
37
- }
38
-
39
- /** @protected */
40
- ready() {
41
- super.ready();
42
-
43
- const textArea = this._getDirectSlotChild('textarea');
44
- if (textArea) {
45
- textArea.id = this._textareaId;
46
-
47
- this._setInputElement(textArea);
48
- this._setFocusElement(textArea);
49
- }
50
- }
51
- };
52
-
53
- /**
54
- * A mixin to add `<textarea>` element to the corresponding named slot.
55
- */
56
- export const TextAreaSlotMixin = dedupingMixin(TextAreaSlotMixinImplementation);
@@ -1,21 +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 { CharLengthMixin } from './char-length-mixin.js';
7
- import { InputFieldMixin } from './input-field-mixin.js';
8
- import { PatternMixin } from './pattern-mixin.js';
9
-
10
- /**
11
- * A mixin to provide validation constraints for vaadin-text-field and related components.
12
- */
13
- declare function TextFieldMixin<T extends new (...args: any[]) => {}>(base: T): T & TextFieldMixinConstructor;
14
-
15
- interface TextFieldMixinConstructor {
16
- new (...args: any[]): TextFieldMixin;
17
- }
18
-
19
- interface TextFieldMixin extends CharLengthMixin, InputFieldMixin, PatternMixin {}
20
-
21
- export { TextFieldMixin, TextFieldMixinConstructor };
@@ -1,17 +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 { CharLengthMixin } from './char-length-mixin.js';
8
- import { InputFieldMixin } from './input-field-mixin.js';
9
- import { PatternMixin } from './pattern-mixin.js';
10
-
11
- const TextFieldMixinImplementation = (superclass) =>
12
- class TextFieldMixinClass extends InputFieldMixin(CharLengthMixin(PatternMixin(superclass))) {};
13
-
14
- /**
15
- * A mixin to provide validation constraints for vaadin-text-field and related components.
16
- */
17
- export const TextFieldMixin = dedupingMixin(TextFieldMixinImplementation);