@vaadin/field-base 24.0.0-alpha1 → 24.0.0-alpha3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/field-base",
3
- "version": "24.0.0-alpha1",
3
+ "version": "24.0.0-alpha3",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -32,7 +32,7 @@
32
32
  "dependencies": {
33
33
  "@open-wc/dedupe-mixin": "^1.3.0",
34
34
  "@polymer/polymer": "^3.0.0",
35
- "@vaadin/component-base": "24.0.0-alpha1",
35
+ "@vaadin/component-base": "24.0.0-alpha3",
36
36
  "lit": "^2.0.0"
37
37
  },
38
38
  "devDependencies": {
@@ -40,5 +40,5 @@
40
40
  "@vaadin/testing-helpers": "^0.3.2",
41
41
  "sinon": "^13.0.2"
42
42
  },
43
- "gitHead": "427527c27c4b27822d61fd41d38d7b170134770b"
43
+ "gitHead": "7a013a3c5a56abd61dd4f7773c6ec77c3541bdf2"
44
44
  }
@@ -10,17 +10,14 @@ import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
10
10
  */
11
11
  export class ErrorController extends SlotController {
12
12
  constructor(host) {
13
- super(
14
- host,
15
- 'error-message',
16
- () => document.createElement('div'),
17
- (_host, node) => {
13
+ super(host, 'error-message', 'div', {
14
+ initializer: (node) => {
18
15
  this.__updateErrorId(node);
19
16
 
20
17
  this.__updateHasError();
21
18
  },
22
- true,
23
- );
19
+ useUniqueId: true,
20
+ });
24
21
  }
25
22
 
26
23
  /**
@@ -55,7 +52,7 @@ export class ErrorController extends SlotController {
55
52
  }
56
53
 
57
54
  /**
58
- * Override to initialize the newly added custom label.
55
+ * Override to initialize the newly added custom error message.
59
56
  *
60
57
  * @param {Node} errorNode
61
58
  * @protected
@@ -73,7 +70,7 @@ export class ErrorController extends SlotController {
73
70
  }
74
71
 
75
72
  /**
76
- * Override to cleanup label node when it's removed.
73
+ * Override to cleanup error message node when it's removed.
77
74
  *
78
75
  * @param {Node} node
79
76
  * @protected
@@ -86,7 +83,7 @@ export class ErrorController extends SlotController {
86
83
  if (!errorNode && node !== this.defaultNode) {
87
84
  errorNode = this.attachDefaultNode();
88
85
 
89
- // Run initializer to update default label and ID.
86
+ // Run initializer to update default error message ID.
90
87
  this.initNode(errorNode);
91
88
  }
92
89
 
@@ -10,8 +10,10 @@ import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
10
10
  */
11
11
  export class HelperController extends SlotController {
12
12
  constructor(host) {
13
- // Do not provide slot factory, as only create helper lazily.
14
- super(host, 'helper', null, null, true);
13
+ // Do not provide tag name, as we create helper lazily.
14
+ super(host, 'helper', null, {
15
+ useUniqueId: true,
16
+ });
15
17
  }
16
18
 
17
19
  get helperId() {
@@ -106,8 +108,8 @@ export class HelperController extends SlotController {
106
108
  const hasHelperText = this.__isNotEmpty(helperText);
107
109
 
108
110
  if (hasHelperText && !helperNode) {
109
- // Set slot factory lazily to only create helper node when needed.
110
- this.slotFactory = () => document.createElement('div');
111
+ // Set tag name lazily to only create helper node when needed.
112
+ this.tagName = 'div';
111
113
 
112
114
  helperNode = this.attachDefaultNode();
113
115
 
@@ -10,11 +10,8 @@ import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
10
10
  */
11
11
  export class InputController extends SlotController {
12
12
  constructor(host, callback) {
13
- super(
14
- host,
15
- 'input',
16
- () => document.createElement('input'),
17
- (host, node) => {
13
+ super(host, 'input', 'input', {
14
+ initializer: (node, host) => {
18
15
  if (host.value) {
19
16
  node.setAttribute('value', host.value);
20
17
  }
@@ -29,7 +26,7 @@ export class InputController extends SlotController {
29
26
  callback(node);
30
27
  }
31
28
  },
32
- true,
33
- );
29
+ useUniqueId: true,
30
+ });
34
31
  }
35
32
  }
@@ -77,6 +77,12 @@ export const InputMixin = dedupingMixin(
77
77
  */
78
78
  clear() {
79
79
  this.value = '';
80
+
81
+ // Clear the input immediately without waiting for the observer.
82
+ // Otherwise, when using Lit, the old value would be restored.
83
+ if (this.inputElement) {
84
+ this.inputElement.value = '';
85
+ }
80
86
  }
81
87
 
82
88
  /**
@@ -10,11 +10,8 @@ import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
10
10
  */
11
11
  export class LabelController extends SlotController {
12
12
  constructor(host) {
13
- super(
14
- host,
15
- 'label',
16
- () => document.createElement('label'),
17
- (_host, node) => {
13
+ super(host, 'label', 'label', {
14
+ initializer: (node) => {
18
15
  // Set ID attribute or use the existing one.
19
16
  this.__updateLabelId(node);
20
17
 
@@ -23,8 +20,8 @@ export class LabelController extends SlotController {
23
20
 
24
21
  this.__observeLabel(node);
25
22
  },
26
- true,
27
- );
23
+ useUniqueId: true,
24
+ });
28
25
  }
29
26
 
30
27
  /**
@@ -11,7 +11,7 @@ import { LabelController } from './label-controller.js';
11
11
  * A mixin to provide label via corresponding property or named slot.
12
12
  *
13
13
  * @polymerMixin
14
- * @mixes SlotMixin
14
+ * @mixes ControllerMixin
15
15
  */
16
16
  export const LabelMixin = dedupingMixin(
17
17
  (superclass) =>
@@ -11,7 +11,7 @@ import type { InputMixinClass } from './input-mixin.js';
11
11
  import type { ValidateMixinClass } from './validate-mixin.js';
12
12
 
13
13
  /**
14
- * A mixin to provide `pattern` and `preventInvalidInput` properties.
14
+ * A mixin to provide `pattern` property.
15
15
  */
16
16
  export declare function PatternMixin<T extends Constructor<HTMLElement>>(
17
17
  base: T,
@@ -29,12 +29,4 @@ export declare class PatternMixinClass {
29
29
  * The pattern must match the entire value, not just some subset.
30
30
  */
31
31
  pattern: string;
32
-
33
- /**
34
- * When set to true, user is prevented from typing a value that
35
- * conflicts with the given `pattern`.
36
- * @attr {boolean} prevent-invalid-input
37
- * @deprecated Please use `allowedCharPattern` instead.
38
- */
39
- preventInvalidInput: boolean | null | undefined;
40
32
  }
@@ -3,12 +3,10 @@
3
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 { timeOut } from '@vaadin/component-base/src/async.js';
7
- import { Debouncer } from '@vaadin/component-base/src/debounce.js';
8
6
  import { InputConstraintsMixin } from './input-constraints-mixin.js';
9
7
 
10
8
  /**
11
- * A mixin to provide `pattern` and `preventInvalidInput` properties.
9
+ * A mixin to provide `pattern` property.
12
10
  *
13
11
  * @polymerMixin
14
12
  * @mixes InputConstraintsMixin
@@ -24,17 +22,6 @@ export const PatternMixin = (superclass) =>
24
22
  pattern: {
25
23
  type: String,
26
24
  },
27
-
28
- /**
29
- * When set to true, user is prevented from typing a value that
30
- * conflicts with the given `pattern`.
31
- * @attr {boolean} prevent-invalid-input
32
- * @deprecated Please use `allowedCharPattern` instead.
33
- */
34
- preventInvalidInput: {
35
- type: Boolean,
36
- observer: '_preventInvalidInputChanged',
37
- },
38
25
  };
39
26
  }
40
27
 
@@ -45,39 +32,4 @@ export const PatternMixin = (superclass) =>
45
32
  static get constraints() {
46
33
  return [...super.constraints, 'pattern'];
47
34
  }
48
-
49
- /** @private */
50
- _checkInputValue() {
51
- if (this.preventInvalidInput) {
52
- const input = this.inputElement;
53
- if (input && input.value.length > 0 && !this.checkValidity()) {
54
- input.value = this.value || '';
55
- // Add input-prevented attribute for 200ms
56
- this.setAttribute('input-prevented', '');
57
- this._inputDebouncer = Debouncer.debounce(this._inputDebouncer, timeOut.after(200), () => {
58
- this.removeAttribute('input-prevented');
59
- });
60
- }
61
- }
62
- }
63
-
64
- /**
65
- * @param {Event} event
66
- * @protected
67
- * @override
68
- */
69
- _onInput(event) {
70
- this._checkInputValue();
71
-
72
- super._onInput(event);
73
- }
74
-
75
- /** @private */
76
- _preventInvalidInputChanged(preventInvalidInput) {
77
- if (preventInvalidInput) {
78
- console.warn(
79
- `WARNING: Since Vaadin 23.2, "preventInvalidInput" is deprecated. Please use "allowedCharPattern" instead.`,
80
- );
81
- }
82
- }
83
35
  };
@@ -10,11 +10,8 @@ import { SlotController } from '@vaadin/component-base/src/slot-controller.js';
10
10
  */
11
11
  export class TextAreaController extends SlotController {
12
12
  constructor(host, callback) {
13
- super(
14
- host,
15
- 'textarea',
16
- () => document.createElement('textarea'),
17
- (host, node) => {
13
+ super(host, 'textarea', 'textarea', {
14
+ initializer: (node, host) => {
18
15
  const value = host.getAttribute('value');
19
16
  if (value) {
20
17
  node.value = value;
@@ -31,7 +28,7 @@ export class TextAreaController extends SlotController {
31
28
  callback(node);
32
29
  }
33
30
  },
34
- true,
35
- );
31
+ useUniqueId: true,
32
+ });
36
33
  }
37
34
  }