@vaadin/field-base 22.0.0 → 22.0.4

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 (56) hide show
  1. package/LICENSE +1 -1
  2. package/package.json +3 -3
  3. package/src/checked-mixin.d.ts +1 -1
  4. package/src/checked-mixin.js +1 -1
  5. package/src/delegate-focus-mixin.d.ts +1 -1
  6. package/src/delegate-focus-mixin.js +1 -1
  7. package/src/delegate-state-mixin.d.ts +1 -1
  8. package/src/delegate-state-mixin.js +1 -1
  9. package/src/field-aria-controller.d.ts +1 -1
  10. package/src/field-aria-controller.js +1 -1
  11. package/src/field-mixin.d.ts +3 -1
  12. package/src/field-mixin.js +50 -161
  13. package/src/helper-controller.d.ts +23 -0
  14. package/src/helper-controller.js +185 -0
  15. package/src/input-constraints-mixin.d.ts +1 -1
  16. package/src/input-constraints-mixin.js +1 -1
  17. package/src/input-control-mixin.d.ts +1 -1
  18. package/src/input-control-mixin.js +1 -1
  19. package/src/input-controller.d.ts +3 -3
  20. package/src/input-controller.js +5 -4
  21. package/src/input-field-mixin.d.ts +1 -1
  22. package/src/input-field-mixin.js +16 -1
  23. package/src/input-mixin.d.ts +1 -1
  24. package/src/input-mixin.js +1 -1
  25. package/src/label-controller.d.ts +26 -0
  26. package/src/label-controller.js +186 -0
  27. package/src/label-mixin.d.ts +4 -3
  28. package/src/label-mixin.js +10 -49
  29. package/src/labelled-input-controller.d.ts +1 -1
  30. package/src/labelled-input-controller.js +17 -4
  31. package/src/pattern-mixin.d.ts +1 -1
  32. package/src/pattern-mixin.js +1 -1
  33. package/src/shadow-focus-mixin.d.ts +1 -1
  34. package/src/shadow-focus-mixin.js +1 -1
  35. package/src/slot-styles-mixin.d.ts +1 -1
  36. package/src/slot-styles-mixin.js +1 -1
  37. package/src/slot-target-controller.d.ts +31 -0
  38. package/src/slot-target-controller.js +119 -0
  39. package/src/styles/clear-button-styles.d.ts +1 -1
  40. package/src/styles/clear-button-styles.js +1 -1
  41. package/src/styles/field-shared-styles.d.ts +1 -1
  42. package/src/styles/field-shared-styles.js +1 -1
  43. package/src/styles/input-field-container-styles.d.ts +1 -1
  44. package/src/styles/input-field-container-styles.js +1 -1
  45. package/src/styles/input-field-shared-styles.d.ts +1 -1
  46. package/src/styles/input-field-shared-styles.js +1 -1
  47. package/src/text-area-controller.d.ts +3 -3
  48. package/src/text-area-controller.js +5 -4
  49. package/src/validate-mixin.d.ts +1 -1
  50. package/src/validate-mixin.js +1 -1
  51. package/src/slot-controller.d.ts +0 -8
  52. package/src/slot-controller.js +0 -36
  53. package/src/slot-label-mixin.d.ts +0 -15
  54. package/src/slot-label-mixin.js +0 -38
  55. package/src/slot-target-mixin.d.ts +0 -25
  56. package/src/slot-target-mixin.js +0 -110
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2022 Vaadin Ltd..
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { CSSResult } from 'lit';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2022 Vaadin Ltd..
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { css } from 'lit';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2022 Vaadin Ltd..
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { CSSResult } from 'lit';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2022 Vaadin Ltd..
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { css } from 'lit';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2022 Vaadin Ltd..
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { CSSResult } from 'lit';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2022 Vaadin Ltd..
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { css } from 'lit';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2022 Vaadin Ltd..
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { CSSResult } from 'lit';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2022 Vaadin Ltd..
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { clearButton } from './clear-button-styles.js';
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { SlotController } from './slot-controller.js';
6
+ import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
7
7
 
8
8
  /**
9
9
  * A controller to create and initialize slotted `<textarea>` element.
10
10
  */
11
- export class TextAreaController implements SlotController {}
11
+ export class TextAreaController extends SlotController {}
@@ -1,16 +1,17 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
- import { SlotController } from './slot-controller.js';
6
+ import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
7
7
 
8
8
  /**
9
9
  * A controller to create and initialize slotted `<textarea>` element.
10
10
  */
11
11
  export class TextAreaController extends SlotController {
12
12
  constructor(host, callback) {
13
- super(host, [
13
+ super(
14
+ host,
14
15
  'textarea',
15
16
  () => document.createElement('textarea'),
16
17
  (host, node) => {
@@ -33,6 +34,6 @@ export class TextAreaController extends SlotController {
33
34
  callback(node);
34
35
  }
35
36
  }
36
- ]);
37
+ );
37
38
  }
38
39
  }
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { Constructor } from '@open-wc/dedupe-mixin';
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * Copyright (c) 2021 Vaadin Ltd.
3
+ * Copyright (c) 2021 - 2022 Vaadin Ltd.
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { dedupingMixin } from '@polymer/polymer/lib/utils/mixin.js';
@@ -1,8 +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 { ReactiveController } from 'lit';
7
-
8
- export class SlotController implements ReactiveController {}
@@ -1,36 +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
- export class SlotController {
7
- constructor(host, [slotName, slotFactory, slotInitializer]) {
8
- this.host = host;
9
- this.slotName = slotName;
10
- this.slotFactory = slotFactory;
11
- this.slotInitializer = slotInitializer;
12
- }
13
-
14
- hostConnected() {
15
- if (!this.__initialized) {
16
- const { host, slotName, slotFactory } = this;
17
-
18
- const slotted = host.querySelector(`[slot=${slotName}]`);
19
-
20
- if (!slotted) {
21
- const slotContent = slotFactory(host);
22
- if (slotContent instanceof Element) {
23
- slotContent.setAttribute('slot', slotName);
24
- host.appendChild(slotContent);
25
- this.__slotContent = slotContent;
26
- }
27
- } else {
28
- this.__slotContent = slotted;
29
- }
30
-
31
- this.slotInitializer(host, this.__slotContent);
32
-
33
- this.__initialized = true;
34
- }
35
- }
36
- }
@@ -1,15 +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 { Constructor } from '@open-wc/dedupe-mixin';
7
- import { LabelMixinClass } from './label-mixin.js';
8
- import { SlotTargetMixinClass } from './slot-target-mixin.js';
9
-
10
- /**
11
- * A mixin to forward any content from the default slot to the label node.
12
- */
13
- export declare function SlotLabelMixin<T extends Constructor<HTMLElement>>(
14
- base: T
15
- ): T & Constructor<LabelMixinClass> & Constructor<SlotTargetMixinClass>;
@@ -1,38 +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 { LabelMixin } from './label-mixin.js';
8
- import { SlotTargetMixin } from './slot-target-mixin.js';
9
-
10
- /**
11
- * A mixin to forward any content from the default slot to the label node.
12
- *
13
- * @polymerMixin
14
- * @mixes LabelMixin
15
- * @mixes SlotTargetMixin
16
- */
17
- export const SlotLabelMixin = dedupingMixin(
18
- (superclass) =>
19
- class SlotLabelMixinClass extends SlotTargetMixin(LabelMixin(superclass)) {
20
- /** @protected */
21
- get _slotTarget() {
22
- return this._labelNode;
23
- }
24
-
25
- /** @protected */
26
- ready() {
27
- super.ready();
28
-
29
- if (this._labelNode) {
30
- // The default slot's content is moved to the label node
31
- // only after `LabelMixin` is initialized which means
32
- // we should manually toggle the `has-label` attribute
33
- // respecting the new label content.
34
- this._toggleHasLabelAttribute();
35
- }
36
- }
37
- }
38
- );
@@ -1,25 +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 { Constructor } from '@open-wc/dedupe-mixin';
7
-
8
- /**
9
- * A mixin to copy the content from a source slot to a target element.
10
- */
11
- export declare function SlotTargetMixin<T extends Constructor<HTMLElement>>(
12
- base: T
13
- ): T & Constructor<SlotTargetMixinClass>;
14
-
15
- export declare class SlotTargetMixinClass {
16
- /**
17
- * A reference to the source slot from which the content is copied to the target element.
18
- */
19
- protected readonly _sourceSlot: HTMLSlotElement;
20
-
21
- /**
22
- * A reference to the target element to which the content is copied from the source slot.
23
- */
24
- protected readonly _slotTarget: HTMLElement;
25
- }
@@ -1,110 +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
- /**
9
- * A mixin to copy the content from a source slot to a target element.
10
- *
11
- * @polymerMixin
12
- */
13
- export const SlotTargetMixin = dedupingMixin(
14
- (superclass) =>
15
- class SlotTargetMixinClass extends superclass {
16
- /** @protected */
17
- ready() {
18
- super.ready();
19
-
20
- if (this._sourceSlot) {
21
- this.__sourceSlotObserver = new MutationObserver(() => this.__checkAndCopyNodesToSlotTarget());
22
-
23
- this.__checkAndCopyNodesToSlotTarget();
24
-
25
- this._sourceSlot.addEventListener('slotchange', () => {
26
- this.__checkAndCopyNodesToSlotTarget();
27
- });
28
- }
29
- }
30
-
31
- /**
32
- * A reference to the source slot from which the nodes are copied to the target element.
33
- *
34
- * @type {HTMLSlotElement | null}
35
- * @protected
36
- */
37
- get _sourceSlot() {
38
- console.warn(`Please implement the '_sourceSlot' property in <${this.localName}>`);
39
- return null;
40
- }
41
-
42
- /**
43
- * A reference to the target element to which the nodes are copied from the source slot.
44
- *
45
- * @type {HTMLElement | null}
46
- * @protected
47
- */
48
- get _slotTarget() {
49
- console.warn(`Please implement the '_slotTarget' property in <${this.localName}>`);
50
- return null;
51
- }
52
-
53
- /**
54
- * Copies every node from the source slot to the target element
55
- * once the source slot' content is changed.
56
- *
57
- * @private
58
- */
59
- __checkAndCopyNodesToSlotTarget() {
60
- this.__sourceSlotObserver.disconnect();
61
-
62
- if (!this._slotTarget) {
63
- return;
64
- }
65
-
66
- // Remove any existing clones from the slot target
67
- if (this.__slotTargetClones) {
68
- this.__slotTargetClones.forEach((node) => {
69
- if (node.parentElement === this._slotTarget) {
70
- this._slotTarget.removeChild(node);
71
- }
72
- });
73
- delete this.__slotTargetClones;
74
- }
75
-
76
- // Exclude whitespace text nodes
77
- const nodes = this._sourceSlot
78
- .assignedNodes({ flatten: true })
79
- .filter((node) => !(node.nodeType == Node.TEXT_NODE && node.textContent.trim() === ''));
80
-
81
- if (nodes.length > 0) {
82
- this._slotTarget.innerHTML = '';
83
- this.__copyNodesToSlotTarget(nodes);
84
- }
85
- }
86
-
87
- /**
88
- * Copies the nodes to the target element.
89
- *
90
- * @protected
91
- * @param {!Array<!Node>} nodes
92
- */
93
- __copyNodesToSlotTarget(nodes) {
94
- this.__slotTargetClones = this.__slotTargetClones || [];
95
- nodes.forEach((node) => {
96
- // Clone the nodes and append the clones to the target slot
97
- const clone = node.cloneNode(true);
98
- this.__slotTargetClones.push(clone);
99
- this._slotTarget.appendChild(clone);
100
- // Observe all changes to the source node to have the clones updated
101
- this.__sourceSlotObserver.observe(node, {
102
- attributes: true,
103
- childList: true,
104
- subtree: true,
105
- characterData: true
106
- });
107
- });
108
- }
109
- }
110
- );