@brightspace-ui/core 3.50.1 → 3.52.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -41,12 +41,12 @@ The `<d2l-input-number>` element is similar to `<d2l-input-text>`, except it's i
|
|
41
41
|
|
42
42
|
| Property | Type | Description |
|
43
43
|
|---|---|---|
|
44
|
-
| `label` | String, required |
|
44
|
+
| `label` | String, required | Explicitly defined label for the element. |
|
45
45
|
| `autocomplete` | String | Specifies which types of values [can be autofilled](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete) by the browser. |
|
46
46
|
| `autofocus` | Boolean, default: `false` | When set, will automatically place focus on the input. |
|
47
47
|
| `disabled` | Boolean, default: `false` | Disables the input. |
|
48
48
|
| `input-width` | String, default: `4rem` | Restricts the maximum width of the input box without impacting the width of the label. |
|
49
|
-
| `label-hidden` | Boolean, default: `false` | Hides the label visually
|
49
|
+
| `label-hidden` | Boolean, default: `false` | Hides the label visually. Hidden labels are still read by screen readers so make sure to set an appropriate label. |
|
50
50
|
| `labelled-by` | String | HTML id of an element in the same shadow root which acts as the input's label |
|
51
51
|
| `max` | Number | Maximum value allowed. |
|
52
52
|
| `max-exclusive` | Boolean, default: `false` | Indicates whether the max value is exclusive. |
|
@@ -56,6 +56,7 @@ The `<d2l-input-number>` element is similar to `<d2l-input-text>`, except it's i
|
|
56
56
|
| `min-fraction-digits` | Number, default: `0` | Minimum number of digits allowed after the decimal place. Must be between 0 and 20 and less than or equal to `maxFractionDigits` |
|
57
57
|
| `required` | Boolean, default: `false` | Indicates that a value is required. |
|
58
58
|
| `unit` | String | Unit associated with the input value, displayed next to input and announced as part of the label |
|
59
|
+
| `unit-label` | String | Label for the unit, which is only picked up by screenreaders. Required if `unit` is used. |
|
59
60
|
| `value` | Number | Value of the input. |
|
60
61
|
|
61
62
|
### Events
|
@@ -74,17 +75,6 @@ numberInput.addEventListener('change', (e) => {
|
|
74
75
|
* `inline-help`: Help text that will appear below the input. Use this only when other helpful cues are not sufficient, such as a carefully-worded label.
|
75
76
|
<!-- docs: end hidden content -->
|
76
77
|
|
77
|
-
### Accessibility Properties
|
78
|
-
|
79
|
-
To make your usage of `d2l-input-number` accessible, use the following properties when applicable:
|
80
|
-
|
81
|
-
| Attribute | Description |
|
82
|
-
|---|---|
|
83
|
-
| `label` | **REQUIRED.** [Acts as a primary label on the input](https://www.w3.org/WAI/tutorials/forms/labels/). Visible unless `label-hidden` is also used. |
|
84
|
-
| `label-hidden` | Use if label should be visually hidden but available for screen reader users. |
|
85
|
-
| `labelled-by` | Use when another visible element should act as the label |
|
86
|
-
| `unit` | Use to render the unit (offscreen) as part of the label. |
|
87
|
-
|
88
78
|
### Usage
|
89
79
|
|
90
80
|
**Integers Only:**
|
@@ -120,11 +110,11 @@ The `<d2l-input-percent>` element is similar to `<d2l-input-number>`, except it
|
|
120
110
|
|
121
111
|
| Property | Type | Description |
|
122
112
|
|---|---|---|
|
123
|
-
| `label` | String, required |
|
113
|
+
| `label` | String, required | Explicitly defined label for the element. |
|
124
114
|
| `autofocus` | Boolean, default: `false` | When set, will automatically place focus on the input. |
|
125
115
|
| `disabled` | Boolean, default: `false` | Disables the input. |
|
126
116
|
| `input-width` | String, default: `4rem` | Restricts the maximum width of the input box without impacting the width of the label. |
|
127
|
-
| `label-hidden` | Boolean, default: `false` | Hides the label visually
|
117
|
+
| `label-hidden` | Boolean, default: `false` | Hides the label visually. Hidden labels are still read by screen readers so make sure to set an appropriate label. |
|
128
118
|
| `max-fraction-digits` | Number | Maximum number of digits allowed after the decimal place. |
|
129
119
|
| `min-fraction-digits` | Number | Minimum number of digits allowed after the decimal place. |
|
130
120
|
| `required` | Boolean, default: `false` | Indicates that a value is required. |
|
@@ -146,11 +136,10 @@ numberInput.addEventListener('change', (e) => {
|
|
146
136
|
* `inline-help`: Help text that will appear below the input. Use this only when other helpful cues are not sufficient, such as a carefully-worded label.
|
147
137
|
<!-- docs: end hidden content -->
|
148
138
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
| `label-hidden` | Use if label should be visually hidden but available for screen reader users. |
|
139
|
+
## Accessibility
|
140
|
+
- While `unit-label` is not mandatory by default, using the `unit` property makes it a required property
|
141
|
+
- This helps provide screenreaders more context and lets you use short forms for `unit` without risking it being unclear to screenreaders (e.g. `unit` is 'lbs', but `unit-label` is 'in pounds' )
|
142
|
+
- Despite being a lighter colour than the input text, the `unit` text still meets the [WCAG Minimum Contrast](https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum.html) requirement of 4.5:1
|
143
|
+
- Neither input component uses the `type="number"` to denote their numerical nature, so the `label` must make it clear that numerical input is expected
|
144
|
+
- This is because `type="number"` does not take into consideration localizations, which can cause problems for languages that use a comma as the decimal place instead of a period
|
145
|
+
- Using `unit-label` can greatly help with making the numerical nature of the input explicit
|
@@ -107,7 +107,7 @@ class InputNumber extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixi
|
|
107
107
|
*/
|
108
108
|
inputWidth: { attribute: 'input-width', type: String },
|
109
109
|
/**
|
110
|
-
* Hides the label visually
|
110
|
+
* Hides the label visually. Hidden labels are still read by screen readers so make sure to set an appropriate label.
|
111
111
|
* @type {boolean}
|
112
112
|
*/
|
113
113
|
labelHidden: { type: Boolean, attribute: 'label-hidden' },
|
@@ -141,10 +141,6 @@ class InputNumber extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixi
|
|
141
141
|
* @type {number}
|
142
142
|
*/
|
143
143
|
minFractionDigits: { type: Number, attribute: 'min-fraction-digits' },
|
144
|
-
/**
|
145
|
-
* @ignore
|
146
|
-
*/
|
147
|
-
placeholder: { type: String },
|
148
144
|
/**
|
149
145
|
* Indicates that a value is required
|
150
146
|
* @type {boolean}
|
@@ -160,7 +156,7 @@ class InputNumber extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixi
|
|
160
156
|
*/
|
161
157
|
unit: { type: String },
|
162
158
|
/**
|
163
|
-
*
|
159
|
+
* ACCESSIBILITY: Label for the unit, which is only picked up by screenreaders. Required if `unit` is used.
|
164
160
|
* @type {string}
|
165
161
|
*/
|
166
162
|
unitLabel: { attribute: 'unit-label', type: String },
|
@@ -364,7 +360,6 @@ class InputNumber extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMixi
|
|
364
360
|
?label-hidden="${this.labelHidden || this.labelledBy}"
|
365
361
|
.labelRequired="${false}"
|
366
362
|
name="${ifDefined(this.name)}"
|
367
|
-
placeholder="${ifDefined(this.placeholder)}"
|
368
363
|
?required="${this.required}"
|
369
364
|
?skeleton="${this.skeleton}"
|
370
365
|
style="${ifDefined(hasRelativeInputWidth ? styleMap(inputWidthStyle) : undefined)}"
|
@@ -34,7 +34,7 @@ class InputPercent extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMix
|
|
34
34
|
*/
|
35
35
|
inputWidth: { attribute: 'input-width', type: String },
|
36
36
|
/**
|
37
|
-
* Hides the label visually
|
37
|
+
* Hides the label visually. Hidden labels are still read by screen readers so make sure to set an appropriate label.
|
38
38
|
* @type {boolean}
|
39
39
|
*/
|
40
40
|
labelHidden: { type: Boolean, attribute: 'label-hidden' },
|
package/custom-elements.json
CHANGED
@@ -6239,7 +6239,7 @@
|
|
6239
6239
|
},
|
6240
6240
|
{
|
6241
6241
|
"name": "unit-label",
|
6242
|
-
"description": "
|
6242
|
+
"description": "ACCESSIBILITY: Label for the unit, which is only picked up by screenreaders. Required if `unit` is used.",
|
6243
6243
|
"type": "string"
|
6244
6244
|
},
|
6245
6245
|
{
|
@@ -6271,7 +6271,7 @@
|
|
6271
6271
|
},
|
6272
6272
|
{
|
6273
6273
|
"name": "label-hidden",
|
6274
|
-
"description": "Hides the label visually
|
6274
|
+
"description": "Hides the label visually. Hidden labels are still read by screen readers so make sure to set an appropriate label.",
|
6275
6275
|
"type": "boolean",
|
6276
6276
|
"default": "false"
|
6277
6277
|
},
|
@@ -6354,7 +6354,7 @@
|
|
6354
6354
|
{
|
6355
6355
|
"name": "unitLabel",
|
6356
6356
|
"attribute": "unit-label",
|
6357
|
-
"description": "
|
6357
|
+
"description": "ACCESSIBILITY: Label for the unit, which is only picked up by screenreaders. Required if `unit` is used.",
|
6358
6358
|
"type": "string"
|
6359
6359
|
},
|
6360
6360
|
{
|
@@ -6405,7 +6405,7 @@
|
|
6405
6405
|
{
|
6406
6406
|
"name": "labelHidden",
|
6407
6407
|
"attribute": "label-hidden",
|
6408
|
-
"description": "Hides the label visually
|
6408
|
+
"description": "Hides the label visually. Hidden labels are still read by screen readers so make sure to set an appropriate label.",
|
6409
6409
|
"type": "boolean",
|
6410
6410
|
"default": "false"
|
6411
6411
|
},
|
@@ -6525,7 +6525,7 @@
|
|
6525
6525
|
},
|
6526
6526
|
{
|
6527
6527
|
"name": "label-hidden",
|
6528
|
-
"description": "Hides the label visually
|
6528
|
+
"description": "Hides the label visually. Hidden labels are still read by screen readers so make sure to set an appropriate label.",
|
6529
6529
|
"type": "boolean",
|
6530
6530
|
"default": "false"
|
6531
6531
|
},
|
@@ -6596,7 +6596,7 @@
|
|
6596
6596
|
{
|
6597
6597
|
"name": "labelHidden",
|
6598
6598
|
"attribute": "label-hidden",
|
6599
|
-
"description": "Hides the label visually
|
6599
|
+
"description": "Hides the label visually. Hidden labels are still read by screen readers so make sure to set an appropriate label.",
|
6600
6600
|
"type": "boolean",
|
6601
6601
|
"default": "false"
|
6602
6602
|
},
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@brightspace-ui/core",
|
3
|
-
"version": "3.
|
3
|
+
"version": "3.52.0",
|
4
4
|
"description": "A collection of accessible, free, open-source web components for building Brightspace applications",
|
5
5
|
"type": "module",
|
6
6
|
"repository": "https://github.com/BrightspaceUI/core.git",
|