@vaadin/field-base 24.8.4 → 25.0.0-alpha10

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.8.4",
3
+ "version": "25.0.0-alpha10",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -22,7 +22,9 @@
22
22
  "files": [
23
23
  "index.d.ts",
24
24
  "index.js",
25
- "src"
25
+ "src",
26
+ "!src/styles/*-base-styles.d.ts",
27
+ "!src/styles/*-base-styles.js"
26
28
  ],
27
29
  "keywords": [
28
30
  "Vaadin",
@@ -31,16 +33,15 @@
31
33
  ],
32
34
  "dependencies": {
33
35
  "@open-wc/dedupe-mixin": "^1.3.0",
34
- "@polymer/polymer": "^3.0.0",
35
- "@vaadin/a11y-base": "~24.8.4",
36
- "@vaadin/component-base": "~24.8.4",
36
+ "@vaadin/a11y-base": "25.0.0-alpha10",
37
+ "@vaadin/component-base": "25.0.0-alpha10",
37
38
  "lit": "^3.0.0"
38
39
  },
39
40
  "devDependencies": {
40
- "@vaadin/chai-plugins": "~24.8.4",
41
- "@vaadin/test-runner-commands": "~24.8.4",
42
- "@vaadin/testing-helpers": "^1.1.0",
41
+ "@vaadin/chai-plugins": "25.0.0-alpha10",
42
+ "@vaadin/test-runner-commands": "25.0.0-alpha10",
43
+ "@vaadin/testing-helpers": "^2.0.0",
43
44
  "sinon": "^18.0.0"
44
45
  },
45
- "gitHead": "849e54e967563080a685965e2dced02060b3ab23"
46
+ "gitHead": "6cc6c94079e805fa5b2f0af4dbf3b2a7485e57d0"
46
47
  }
@@ -5,7 +5,6 @@
5
5
  */
6
6
  import type { Constructor } from '@open-wc/dedupe-mixin';
7
7
  import type { KeyboardMixinClass } from '@vaadin/a11y-base/src/keyboard-mixin.js';
8
- import type { ControllerMixinClass } from '@vaadin/component-base/src/controller-mixin.js';
9
8
  import type { InputMixinClass } from './input-mixin.js';
10
9
 
11
10
  /**
@@ -13,11 +12,7 @@ import type { InputMixinClass } from './input-mixin.js';
13
12
  */
14
13
  export declare function ClearButtonMixin<T extends Constructor<HTMLElement>>(
15
14
  base: T,
16
- ): Constructor<ClearButtonMixinClass> &
17
- Constructor<ControllerMixinClass> &
18
- Constructor<InputMixinClass> &
19
- Constructor<KeyboardMixinClass> &
20
- T;
15
+ ): Constructor<ClearButtonMixinClass> & Constructor<InputMixinClass> & Constructor<KeyboardMixinClass> & T;
21
16
 
22
17
  export declare class ClearButtonMixinClass {
23
18
  /**
@@ -4,7 +4,6 @@
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import type { Constructor } from '@open-wc/dedupe-mixin';
7
- import type { ControllerMixinClass } from '@vaadin/component-base/src/controller-mixin.js';
8
7
  import type { LabelMixinClass } from './label-mixin.js';
9
8
  import type { ValidateMixinClass } from './validate-mixin.js';
10
9
 
@@ -13,11 +12,7 @@ import type { ValidateMixinClass } from './validate-mixin.js';
13
12
  */
14
13
  export declare function FieldMixin<T extends Constructor<HTMLElement>>(
15
14
  superclass: T,
16
- ): Constructor<ControllerMixinClass> &
17
- Constructor<FieldMixinClass> &
18
- Constructor<LabelMixinClass> &
19
- Constructor<ValidateMixinClass> &
20
- T;
15
+ ): Constructor<FieldMixinClass> & Constructor<LabelMixinClass> & Constructor<ValidateMixinClass> & T;
21
16
 
22
17
  export declare class FieldMixinClass {
23
18
  /**
@@ -4,7 +4,6 @@
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { FieldAriaController } from '@vaadin/a11y-base/src/field-aria-controller.js';
7
- import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
8
7
  import { ErrorController } from './error-controller.js';
9
8
  import { HelperController } from './helper-controller.js';
10
9
  import { LabelMixin } from './label-mixin.js';
@@ -14,12 +13,11 @@ import { ValidateMixin } from './validate-mixin.js';
14
13
  * A mixin to provide common field logic: label, error message and helper text.
15
14
  *
16
15
  * @polymerMixin
17
- * @mixes ControllerMixin
18
16
  * @mixes LabelMixin
19
17
  * @mixes ValidateMixin
20
18
  */
21
19
  export const FieldMixin = (superclass) =>
22
- class FieldMixinClass extends ValidateMixin(LabelMixin(ControllerMixin(superclass))) {
20
+ class FieldMixinClass extends ValidateMixin(LabelMixin(superclass)) {
23
21
  static get properties() {
24
22
  return {
25
23
  /**
@@ -8,7 +8,6 @@ import type { DelegateFocusMixinClass } from '@vaadin/a11y-base/src/delegate-foc
8
8
  import type { DisabledMixinClass } from '@vaadin/a11y-base/src/disabled-mixin.js';
9
9
  import type { FocusMixinClass } from '@vaadin/a11y-base/src/focus-mixin.js';
10
10
  import type { KeyboardMixinClass } from '@vaadin/a11y-base/src/keyboard-mixin.js';
11
- import type { ControllerMixinClass } from '@vaadin/component-base/src/controller-mixin.js';
12
11
  import type { DelegateStateMixinClass } from '@vaadin/component-base/src/delegate-state-mixin.js';
13
12
  import type { SlotStylesMixinClass } from '@vaadin/component-base/src/slot-styles-mixin.js';
14
13
  import type { ClearButtonMixinClass } from './clear-button-mixin.js';
@@ -24,7 +23,6 @@ import type { ValidateMixinClass } from './validate-mixin.js';
24
23
  export declare function InputControlMixin<T extends Constructor<HTMLElement>>(
25
24
  base: T,
26
25
  ): Constructor<ClearButtonMixinClass> &
27
- Constructor<ControllerMixinClass> &
28
26
  Constructor<DelegateFocusMixinClass> &
29
27
  Constructor<DelegateStateMixinClass> &
30
28
  Constructor<DisabledMixinClass> &
@@ -103,13 +103,27 @@ export const InputControlMixin = (superclass) =>
103
103
 
104
104
  /** @protected */
105
105
  get slotStyles() {
106
- // Needed for Safari, where ::slotted(...)::placeholder does not work
106
+ const tag = this.localName;
107
+
107
108
  return [
108
109
  `
109
- :is(input[slot='input'], textarea[slot='textarea'])::placeholder {
110
+ /* Needed for Safari, where ::slotted(...)::placeholder does not work */
111
+ ${tag} > :is(input[slot='input'], textarea[slot='textarea'])::placeholder {
110
112
  font: inherit;
111
113
  color: inherit;
112
114
  }
115
+
116
+ /* Override built-in autofill styles */
117
+ ${tag} > input[slot='input']:autofill {
118
+ -webkit-text-fill-color: var(--vaadin-input-field-autofill-color, black);
119
+ background-clip: text;
120
+ }
121
+
122
+ ${tag}:has(> input[slot='input']:autofill) {
123
+ --vaadin-input-field-background: var(--vaadin-input-field-autofill-background, lightyellow);
124
+ --vaadin-input-field-value-color: var(--vaadin-input-field-autofill-color, black);
125
+ --vaadin-input-field-button-color: var(--vaadin-input-field-autofill-color, black);
126
+ }
113
127
  `,
114
128
  ];
115
129
  }
@@ -8,7 +8,6 @@ import type { DelegateFocusMixinClass } from '@vaadin/a11y-base/src/delegate-foc
8
8
  import type { DisabledMixinClass } from '@vaadin/a11y-base/src/disabled-mixin.js';
9
9
  import type { FocusMixinClass } from '@vaadin/a11y-base/src/focus-mixin.js';
10
10
  import type { KeyboardMixinClass } from '@vaadin/a11y-base/src/keyboard-mixin.js';
11
- import type { ControllerMixinClass } from '@vaadin/component-base/src/controller-mixin.js';
12
11
  import type { DelegateStateMixinClass } from '@vaadin/component-base/src/delegate-state-mixin.js';
13
12
  import type { SlotStylesMixinClass } from '@vaadin/component-base/src/slot-styles-mixin.js';
14
13
  import type { ClearButtonMixinClass } from './clear-button-mixin.js';
@@ -25,7 +24,6 @@ import type { ValidateMixinClass } from './validate-mixin.js';
25
24
  export declare function InputFieldMixin<T extends Constructor<HTMLElement>>(
26
25
  base: T,
27
26
  ): Constructor<ClearButtonMixinClass> &
28
- Constructor<ControllerMixinClass> &
29
27
  Constructor<DelegateFocusMixinClass> &
30
28
  Constructor<DelegateStateMixinClass> &
31
29
  Constructor<DisabledMixinClass> &
@@ -49,15 +47,6 @@ export declare class InputFieldMixinClass {
49
47
  */
50
48
  autocomplete: string | undefined;
51
49
 
52
- /**
53
- * This is a property supported by Safari that is used to control whether
54
- * autocorrection should be enabled when the user is entering/editing the text.
55
- * Possible values are:
56
- * on: Enable autocorrection.
57
- * off: Disable autocorrection.
58
- */
59
- autocorrect: 'off' | 'on' | undefined;
60
-
61
50
  /**
62
51
  * This is a property supported by Safari and Chrome that is used to control whether
63
52
  * autocapitalization should be enabled when the user is entering/editing the text.
@@ -56,15 +56,6 @@ export const InputFieldMixin = (superclass) =>
56
56
  return [...super.delegateAttrs, 'autocapitalize', 'autocomplete', 'autocorrect'];
57
57
  }
58
58
 
59
- // Workaround for https://github.com/Polymer/polymer/issues/5259
60
- get __data() {
61
- return this.__dataValue || {};
62
- }
63
-
64
- set __data(value) {
65
- this.__dataValue = value;
66
- }
67
-
68
59
  /**
69
60
  * @param {HTMLElement} input
70
61
  * @protected
@@ -15,11 +15,8 @@ export declare class InputMixinClass {
15
15
  /**
16
16
  * A reference to the input element controlled by the mixin.
17
17
  * Any component implementing this mixin is expected to provide it
18
- * by using `this._setInputElement(input)` Polymer API.
19
- *
20
- * A typical case is using `InputController` that does this automatically.
21
- * However, the input element does not have to always be native <input>:
22
- * as an example, <vaadin-combo-box-light> accepts other components.
18
+ * by using `this._setInputElement(input)` API. A typical case is
19
+ * using `InputController` that does this automatically.
23
20
  */
24
21
  readonly inputElement: HTMLElement;
25
22
 
@@ -19,11 +19,8 @@ export const InputMixin = dedupeMixin(
19
19
  /**
20
20
  * A reference to the input element controlled by the mixin.
21
21
  * Any component implementing this mixin is expected to provide it
22
- * by using `this._setInputElement(input)` Polymer API.
23
- *
24
- * A typical case is using `InputController` that does this automatically.
25
- * However, the input element does not have to always be native <input>:
26
- * as an example, <vaadin-combo-box-light> accepts other components.
22
+ * by using `this._setInputElement(input)` API. A typical case is
23
+ * using `InputController` that does this automatically.
27
24
  *
28
25
  * @protected
29
26
  * @type {!HTMLElement}
@@ -4,18 +4,16 @@
4
4
  * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
5
  */
6
6
  import { dedupeMixin } from '@open-wc/dedupe-mixin';
7
- import { ControllerMixin } from '@vaadin/component-base/src/controller-mixin.js';
8
7
  import { LabelController } from './label-controller.js';
9
8
 
10
9
  /**
11
10
  * A mixin to provide label via corresponding property or named slot.
12
11
  *
13
12
  * @polymerMixin
14
- * @mixes ControllerMixin
15
13
  */
16
14
  export const LabelMixin = dedupeMixin(
17
15
  (superclass) =>
18
- class LabelMixinClass extends ControllerMixin(superclass) {
16
+ class LabelMixinClass extends superclass {
19
17
  static get properties() {
20
18
  return {
21
19
  /**
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2017 - 2025 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import type { CSSResult } from 'lit';
7
+
8
+ export const checkable: (part: string, propName?: string) => CSSResult;
@@ -0,0 +1,64 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2017 - 2025 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import { css, unsafeCSS } from 'lit';
7
+
8
+ export const checkable = (part, propName = part) => css`
9
+ :host {
10
+ display: inline-block;
11
+ }
12
+
13
+ :host([hidden]) {
14
+ display: none !important;
15
+ }
16
+
17
+ :host([disabled]) {
18
+ -webkit-tap-highlight-color: transparent;
19
+ }
20
+
21
+ .vaadin-${unsafeCSS(propName)}-container {
22
+ display: grid;
23
+ grid-template-columns: auto 1fr;
24
+ align-items: baseline;
25
+ }
26
+
27
+ [part='${unsafeCSS(part)}'],
28
+ ::slotted(input),
29
+ [part='label'],
30
+ ::slotted(label) {
31
+ grid-row: 1;
32
+ }
33
+
34
+ [part='${unsafeCSS(part)}'],
35
+ ::slotted(input) {
36
+ grid-column: 1;
37
+ }
38
+
39
+ /* Control container (checkbox, radio button) */
40
+ [part='${unsafeCSS(part)}'] {
41
+ width: var(--vaadin-${unsafeCSS(propName)}-size, 1em);
42
+ height: var(--vaadin-${unsafeCSS(propName)}-size, 1em);
43
+ --_input-border-width: var(--vaadin-input-field-border-width, 0);
44
+ --_input-border-color: var(--vaadin-input-field-border-color, transparent);
45
+ box-shadow: inset 0 0 0 var(--_input-border-width, 0) var(--_input-border-color);
46
+ }
47
+
48
+ [part='${unsafeCSS(part)}']::before {
49
+ display: block;
50
+ content: '\\202F';
51
+ line-height: var(--vaadin-${unsafeCSS(propName)}-size, 1em);
52
+ contain: paint;
53
+ }
54
+
55
+ /* visually hidden */
56
+ ::slotted(input) {
57
+ cursor: inherit;
58
+ margin: 0;
59
+ align-self: stretch;
60
+ appearance: none;
61
+ width: initial;
62
+ height: initial;
63
+ }
64
+ `;
@@ -32,9 +32,11 @@ export const field = css`
32
32
  outline: 1px solid;
33
33
  outline-offset: -1px;
34
34
  }
35
+
35
36
  :host([focused]) [part='input-field'] {
36
37
  outline-width: 2px;
37
38
  }
39
+
38
40
  :host([disabled]) [part='input-field'] {
39
41
  outline-color: GrayText;
40
42
  }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2021 - 2025 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import type { CSSResult } from 'lit';
7
+
8
+ export const group: (name?: string) => CSSResult;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2017 - 2025 Vaadin Ltd.
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+ import { css } from 'lit';
7
+
8
+ export const group = () => css`
9
+ :host {
10
+ display: inline-flex;
11
+ }
12
+
13
+ :host::before {
14
+ content: '\\2003';
15
+ width: 0;
16
+ display: inline-block;
17
+ }
18
+
19
+ :host([hidden]) {
20
+ display: none !important;
21
+ }
22
+
23
+ .vaadin-group-field-container {
24
+ display: flex;
25
+ flex-direction: column;
26
+ width: 100%;
27
+ }
28
+
29
+ [part='group-field'] {
30
+ display: flex;
31
+ flex-wrap: wrap;
32
+ }
33
+
34
+ :host(:not([has-label])) [part='label'] {
35
+ display: none;
36
+ }
37
+ `;