@vaadin/field-base 24.1.0-alpha1 → 24.1.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.1.0-alpha1",
3
+ "version": "24.1.0-alpha10",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -32,8 +32,8 @@
32
32
  "dependencies": {
33
33
  "@open-wc/dedupe-mixin": "^1.3.0",
34
34
  "@polymer/polymer": "^3.0.0",
35
- "@vaadin/a11y-base": "24.1.0-alpha1",
36
- "@vaadin/component-base": "24.1.0-alpha1",
35
+ "@vaadin/a11y-base": "24.1.0-alpha10",
36
+ "@vaadin/component-base": "24.1.0-alpha10",
37
37
  "lit": "^2.0.0"
38
38
  },
39
39
  "devDependencies": {
@@ -41,5 +41,5 @@
41
41
  "@vaadin/testing-helpers": "^0.4.0",
42
42
  "sinon": "^13.0.2"
43
43
  },
44
- "gitHead": "599a339181595923b9ad6373d6888d8a79540141"
44
+ "gitHead": "12e39be7eb3b49c68708e8ca3de2fb22e91051a1"
45
45
  }
@@ -39,6 +39,18 @@ export declare class FieldMixinClass {
39
39
  */
40
40
  errorMessage: string | null | undefined;
41
41
 
42
+ /**
43
+ * String used to label the component to screen reader users.
44
+ * @attr {string} accessible-name
45
+ */
46
+ accessibleName: string | null | undefined;
47
+
48
+ /**
49
+ * Id of the element used as label of the component to screen reader users.
50
+ * @attr {string} accessible-name-ref
51
+ */
52
+ accessibleNameRef: string | null | undefined;
53
+
42
54
  protected readonly _errorNode: HTMLElement;
43
55
 
44
56
  protected readonly _helperNode?: HTMLElement;
@@ -49,6 +49,24 @@ export const FieldMixin = (superclass) =>
49
49
  type: String,
50
50
  observer: '_helperTextChanged',
51
51
  },
52
+
53
+ /**
54
+ * String used to label the component to screen reader users.
55
+ * @attr {string} accessible-name
56
+ */
57
+ accessibleName: {
58
+ type: String,
59
+ observer: '_accessibleNameChanged',
60
+ },
61
+
62
+ /**
63
+ * Id of the element used as label of the component to screen reader users.
64
+ * @attr {string} accessible-name-ref
65
+ */
66
+ accessibleNameRef: {
67
+ type: String,
68
+ observer: '_accessibleNameRefChanged',
69
+ },
52
70
  };
53
71
  }
54
72
 
@@ -113,6 +131,16 @@ export const FieldMixin = (superclass) =>
113
131
  }
114
132
  }
115
133
 
134
+ /** @protected */
135
+ _accessibleNameChanged(accessibleName) {
136
+ this._fieldAriaController.setAriaLabel(accessibleName);
137
+ }
138
+
139
+ /** @protected */
140
+ _accessibleNameRefChanged(accessibleNameRef) {
141
+ this._fieldAriaController.setLabelId(accessibleNameRef, true);
142
+ }
143
+
116
144
  /** @private */
117
145
  __labelChanged(hasLabel, labelNode) {
118
146
  // Label ID should be only added when the label content is present.
@@ -54,10 +54,7 @@ export const InputMixin = dedupingMixin(
54
54
  },
55
55
 
56
56
  /**
57
- * Whether the input element has user input.
58
- *
59
- * Note, the property indicates true only if the input has been entered by the user.
60
- * In the case of programmatic changes, the property must be reset to false.
57
+ * Whether the input element has a non-empty value.
61
58
  *
62
59
  * @protected
63
60
  */
@@ -26,4 +26,17 @@ export const fieldShared = css`
26
26
  :host(:not([has-label])) [part='label'] {
27
27
  display: none;
28
28
  }
29
+
30
+ @media (forced-colors: active) {
31
+ :host(:not([readonly])) [part='input-field'] {
32
+ outline: 1px solid;
33
+ outline-offset: -1px;
34
+ }
35
+ :host([focused]) [part='input-field'] {
36
+ outline-width: 2px;
37
+ }
38
+ :host([disabled]) [part='input-field'] {
39
+ outline-color: GrayText;
40
+ }
41
+ }
29
42
  `;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2021 - 2023 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 screenReaderOnly: CSSResult;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @license
3
+ * Copyright (c) 2021 - 2023 Vaadin Ltd..
4
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
5
+ */
6
+
7
+ /**
8
+ * @note Taken from Gaël Poupard gist
9
+ * @author Gaël Poupard
10
+ * @see https://gist.github.com/ffoodd/000b59f431e3e64e4ce1a24d5bb36034
11
+ */
12
+ import { css } from 'lit';
13
+
14
+ export const screenReaderOnly = css`
15
+ .sr-only {
16
+ border: 0 !important;
17
+ clip: rect(1px, 1px, 1px, 1px) !important;
18
+ -webkit-clip-path: inset(50%) !important;
19
+ clip-path: inset(50%) !important;
20
+ height: 1px !important;
21
+ margin: -1px !important;
22
+ overflow: hidden !important;
23
+ padding: 0 !important;
24
+ position: absolute !important;
25
+ width: 1px !important;
26
+ white-space: nowrap !important;
27
+ }
28
+ `;