@brightspace-ui/core 3.106.3 → 3.107.0

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.
@@ -258,7 +258,7 @@ class CollapsiblePanelDaylightDemo extends LitElement {
258
258
 
259
259
  <p class="d2l-label-text">Add-ons</p>
260
260
  ${this._addons.map((item) => (
261
- html`<d2l-input-checkbox id="${item.id}" @change="${this._onChangeCheckbox}">${item.text}</d2l-input-checkbox>`
261
+ html`<d2l-input-checkbox id="${item.id}" @change="${this._onChangeCheckbox}" label="${item.text}"></d2l-input-checkbox>`
262
262
  ))}
263
263
  </d2l-collapsible-panel>
264
264
  `;
@@ -303,7 +303,7 @@
303
303
  <template>
304
304
  <d2l-button id="openNoScrollDialog">Show Dialog</d2l-button>
305
305
  <d2l-dialog id="noScrollDialog" title-text="Dialog Title">
306
- <d2l-input-checkbox id="noScroll">Show extra paragraphs</d2l-input-checkbox>
306
+ <d2l-input-checkbox id="noScroll" label="Show extra paragraphs"></d2l-input-checkbox>
307
307
  <div>
308
308
  <p>Deadlights jack lad schooner scallywag dance the hempen jig carouser broadside cable strike colors. Bring a spring upon her cable holystone blow the man down spanker</p>
309
309
  <p id="p2" style="display: none;">Shiver me timbers to go on account lookout wherry doubloon chase. Belay yo-ho-ho keelhaul squiffy black spot yardarm spyglass sheet transom heave to.</p>
@@ -34,7 +34,7 @@
34
34
  <d2l-link href="http://www.d2l.com">Before Trap</d2l-link>
35
35
  <d2l-focus-trap trap>
36
36
  <d2l-link href="http://www.d2l.com">Inside Trap</d2l-link>
37
- <d2l-input-checkbox checked>Trapping</d2l-input-checkbox>
37
+ <d2l-input-checkbox checked label="Trapping"></d2l-input-checkbox>
38
38
  Trysail Sail ho Corsair red ensign hulk smartly boom jib rum gangway.
39
39
  <d2l-link href="http://www.d2l.com">Inside Trap</d2l-link>
40
40
  </d2l-focus-trap>
@@ -49,7 +49,7 @@
49
49
  <d2l-link href="http://www.d2l.com">Before Trap</d2l-link>
50
50
  <d2l-focus-trap id="custom">
51
51
  <d2l-link href="http://www.d2l.com">Inside Trap</d2l-link>
52
- <d2l-input-checkbox>Trapping</d2l-input-checkbox>
52
+ <d2l-input-checkbox label="Trapping"></d2l-input-checkbox>
53
53
  Trysail Sail ho Corsair red ensign hulk smartly boom jib rum gangway.
54
54
  <d2l-link href="http://www.d2l.com">Inside Trap</d2l-link>
55
55
  </d2l-focus-trap>
@@ -16,56 +16,50 @@
16
16
  <h2>Simple checkbox with label</h2>
17
17
  <d2l-demo-snippet>
18
18
  <template>
19
- <d2l-input-checkbox checked>Checked item</d2l-input-checkbox>
20
- <d2l-input-checkbox>Unchecked item</d2l-input-checkbox>
19
+ <d2l-input-checkbox label="Checked item" checked></d2l-input-checkbox>
20
+ <d2l-input-checkbox label="Unchecked item"></d2l-input-checkbox>
21
21
  </template>
22
22
  </d2l-demo-snippet>
23
23
 
24
24
  <h2>Checkbox with multi-line label</h2>
25
25
  <d2l-demo-snippet>
26
26
  <template>
27
- <d2l-input-checkbox style="overflow: hidden; width: 200px;">
28
- Label for checkbox that wraps nicely onto
29
- multiple lines and stays aligned
30
- </d2l-input-checkbox>
31
- <d2l-input-checkbox style="overflow: hidden; width: 200px;">
32
- https://en.wikipedia.org/wiki/Dark_matter
33
- </d2l-input-checkbox>
27
+ <d2l-input-checkbox style="overflow: hidden; width: 200px;" label="Label for checkbox that wraps nicely onto multiple lines and stays aligned"></d2l-input-checkbox>
28
+ <d2l-input-checkbox style="overflow: hidden; width: 200px;" label="https://en.wikipedia.org/wiki/Dark_matter"></d2l-input-checkbox>
34
29
  </template>
35
30
  </d2l-demo-snippet>
36
31
 
37
32
  <h2>Checkbox with hidden label</h2>
38
33
  <d2l-demo-snippet>
39
34
  <template>
40
- <d2l-input-checkbox aria-label="Label for checkbox"></d2l-input-checkbox>
35
+ <d2l-input-checkbox label="Label for checkbox" label-hidden></d2l-input-checkbox>
41
36
  </template>
42
37
  </d2l-demo-snippet>
43
38
 
44
39
  <h2>Disabled checkbox</h2>
45
40
  <d2l-demo-snippet>
46
41
  <template>
47
- <d2l-input-checkbox checked disabled>Disabled checkbox</d2l-input-checkbox>
42
+ <d2l-input-checkbox label="Disabled checkbox" checked disabled></d2l-input-checkbox>
48
43
  </template>
49
44
  </d2l-demo-snippet>
50
45
 
51
46
  <h2>Disabled checkbox with tooltip</h2>
52
47
  <d2l-demo-snippet>
53
48
  <template>
54
- <d2l-input-checkbox checked disabled disabled-tooltip="Explanation for why checkbox is disabled">Disabled checkbox with tooltip</d2l-input-checkbox>
49
+ <d2l-input-checkbox label="Disabled checkbox with tooltip" checked disabled disabled-tooltip="Explanation for why checkbox is disabled"></d2l-input-checkbox>
55
50
  </template>
56
51
  </d2l-demo-snippet>
57
52
 
58
53
  <h2>Checkbox with label and supporting content</h2>
59
54
  <d2l-demo-snippet>
60
55
  <template>
61
- <d2l-input-checkbox>
62
- Label for checkbox
56
+ <d2l-input-checkbox label="Label for checkbox">
63
57
  <div slot="supporting" style="color: #999999;">
64
58
  Additional content can go here and will<br>
65
59
  also line up nicely with the checkbox.
66
60
  </div>
67
61
  </d2l-input-checkbox>
68
- <d2l-input-checkbox>Label for checkbox</d2l-input-checkbox>
62
+ <d2l-input-checkbox label="Label for checkbox"></d2l-input-checkbox>
69
63
  <d2l-input-checkbox-spacer style="color: #999999;">
70
64
  Additional content can go here and will<br>
71
65
  also line up nicely with the checkbox.
@@ -76,15 +70,14 @@
76
70
  <h2>Indeterminate checkbox</h2>
77
71
  <d2l-demo-snippet>
78
72
  <template>
79
- <d2l-input-checkbox indeterminate>Indeterminate checkbox</d2l-input-checkbox>
73
+ <d2l-input-checkbox label="Indeterminate checkbox" indeterminate></d2l-input-checkbox>
80
74
  </template>
81
75
  </d2l-demo-snippet>
82
76
 
83
77
  <h2>Inline help checkbox</h2>
84
78
  <d2l-demo-snippet>
85
79
  <template>
86
- <d2l-input-checkbox>
87
- Inline help checkbox
80
+ <d2l-input-checkbox label="Inline help checkbox">
88
81
  <div slot="inline-help">
89
82
  Help text <b>right here</b>!
90
83
  </div>
@@ -95,8 +88,7 @@
95
88
  <h2>Inline help (multiline) checkbox</h2>
96
89
  <d2l-demo-snippet>
97
90
  <template>
98
- <d2l-input-checkbox>
99
- Inline help checkbox
91
+ <d2l-input-checkbox label="Inline help checkbox">
100
92
  <div slot="inline-help">
101
93
  Lorem ipsum dolor sit amet, consectetur adipiscing elit,
102
94
  sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
@@ -7,7 +7,7 @@ Checkboxes are used in forms to toggle an option or preference.
7
7
  <script type="module">
8
8
  import '@brightspace-ui/core/components/inputs/input-checkbox.js';
9
9
  </script>
10
- <d2l-input-checkbox checked>Label for checkbox</d2l-input-checkbox>
10
+ <d2l-input-checkbox label="Label for checkbox" checked></d2l-input-checkbox>
11
11
  ```
12
12
 
13
13
  ## Best Practices
@@ -44,8 +44,8 @@ The `<d2l-input-checkbox>` element can be used to get a checkbox and optional vi
44
44
  });
45
45
  </script>
46
46
  <div>
47
- <d2l-input-checkbox id="checkbox">Label for checkbox</d2l-input-checkbox>
48
- <d2l-input-checkbox>Label for second checkbox</d2l-input-checkbox>
47
+ <d2l-input-checkbox id="checkbox" label="Label for checkbox"></d2l-input-checkbox>
48
+ <d2l-input-checkbox label="Label for second checkbox"></d2l-input-checkbox>
49
49
  </div>
50
50
  ```
51
51
 
@@ -54,11 +54,12 @@ The `<d2l-input-checkbox>` element can be used to get a checkbox and optional vi
54
54
 
55
55
  | Property | Type | Description |
56
56
  |---|---|---|
57
- | `aria-label` | String | Overrides the text in the `Default` slot for screenreader users |
58
57
  | `checked` | Boolean | Checked state |
59
58
  | `description` | String | Additional information communicated to screenreader users when focusing on the input |
60
59
  | `disabled` | Boolean | Disables the input |
61
60
  | `indeterminate` | Boolean | Sets checkbox to an indeterminate state |
61
+ | `label` | String, required | Label for the input |
62
+ | `label-hidden` | Boolean | Hides the label visually (moves it to the input's `aria-label` attribute) |
62
63
  | `name` | String | Name of the input |
63
64
  | `not-tabbable` | Boolean | Sets `tabindex="-1"` on the checkbox. Note that an alternative method of focusing is necessary to implement if using this property. |
64
65
  | `value` | String | Value of the input |
@@ -75,15 +76,10 @@ checkbox.addEventListener('change', (e) => {
75
76
 
76
77
  ### Slots
77
78
 
78
- * `default`: Primary text that will appear next to the input box and function as the label for the checkbox.
79
79
  * `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.
80
80
  * `supporting`: Supporting information which will appear below and be aligned with the checkbox.
81
81
  <!-- docs: end hidden content -->
82
82
 
83
- ### Methods
84
-
85
- - `simulateClick()`: useful for testing, it simulates the user clicking on the checkbox, which toggles the state of the checkbox and fires the `change` event
86
-
87
83
  ## Checkbox Spacer [d2l-input-checkbox-spacer]
88
84
 
89
85
  > [!NOTE]
@@ -61,7 +61,6 @@ export const checkboxStyles = css`
61
61
 
62
62
  /**
63
63
  * A component that can be used to show a checkbox and optional visible label.
64
- * @slot - Checkbox information (e.g., text)
65
64
  * @slot 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.
66
65
  * @slot supporting - Supporting information which will appear below and be aligned with the checkbox.
67
66
  * @fires change - Dispatched when the checkbox's state changes
@@ -71,8 +70,7 @@ class InputCheckbox extends InputInlineHelpMixin(FocusMixin(SkeletonMixin(LitEle
71
70
  static get properties() {
72
71
  return {
73
72
  /**
74
- * ACCESSIBILITY: Overrides the text in the `Default` slot for screenreader users
75
- * @type {string}
73
+ * @ignore
76
74
  */
77
75
  ariaLabel: { type: String, attribute: 'aria-label' },
78
76
  /**
@@ -100,6 +98,16 @@ class InputCheckbox extends InputInlineHelpMixin(FocusMixin(SkeletonMixin(LitEle
100
98
  * @type {boolean}
101
99
  */
102
100
  indeterminate: { type: Boolean },
101
+ /**
102
+ * REQUIRED: Label for the input
103
+ * @type {string}
104
+ */
105
+ label: { type: String },
106
+ /**
107
+ * Hides the label visually
108
+ * @type {boolean}
109
+ */
110
+ labelHidden: { attribute: 'label-hidden', reflect: true, type: Boolean },
103
111
  /**
104
112
  * Name of the input
105
113
  * @type {string}
@@ -130,7 +138,7 @@ class InputCheckbox extends InputInlineHelpMixin(FocusMixin(SkeletonMixin(LitEle
130
138
  :host([hidden]) {
131
139
  display: none;
132
140
  }
133
- :host([aria-label]) {
141
+ :host([label-hidden]) {
134
142
  display: inline-block;
135
143
  margin-bottom: 0;
136
144
  }
@@ -151,7 +159,7 @@ class InputCheckbox extends InputInlineHelpMixin(FocusMixin(SkeletonMixin(LitEle
151
159
  vertical-align: top;
152
160
  white-space: normal;
153
161
  }
154
- :host([aria-label]) .d2l-input-checkbox-text {
162
+ :host([label-hidden]) .d2l-input-checkbox-text {
155
163
  margin-inline-start: 0;
156
164
  }
157
165
  :host([skeleton]) .d2l-input-checkbox-text.d2l-skeletize::before {
@@ -187,6 +195,8 @@ class InputCheckbox extends InputInlineHelpMixin(FocusMixin(SkeletonMixin(LitEle
187
195
  this.checked = false;
188
196
  this.disabled = false;
189
197
  this.indeterminate = false;
198
+ this.label = '';
199
+ this.labelHidden = false;
190
200
  this.name = '';
191
201
  this.notTabbable = false;
192
202
  this.value = 'on';
@@ -210,6 +220,8 @@ class InputCheckbox extends InputInlineHelpMixin(FocusMixin(SkeletonMixin(LitEle
210
220
  'd2l-input-checkbox-text-disabled': this.disabled
211
221
  };
212
222
  const ariaChecked = this.indeterminate ? 'mixed' : undefined;
223
+ const ariaLabel = (this.label && this.labelHidden) ? this.label : undefined;
224
+ const label = (this.label && !this.labelHidden) ? this.label : nothing;
213
225
  const disabled = this.disabled || this.skeleton;
214
226
  const offscreenContainer = this.description ? html`<div class="d2l-offscreen" id="${this.#descriptionId}">${this.description}</div>` : null;
215
227
  const ariaDescribedByIds = `${this.description ? this.#descriptionId : ''} ${this._hasInlineHelp ? this.#inlineHelpId : ''}`.trim();
@@ -222,7 +234,7 @@ class InputCheckbox extends InputInlineHelpMixin(FocusMixin(SkeletonMixin(LitEle
222
234
  aria-checked="${ifDefined(ariaChecked)}"
223
235
  aria-describedby="${ifDefined(ariaDescribedByIds.length > 0 ? ariaDescribedByIds : undefined)}"
224
236
  aria-disabled="${ifDefined(disabled && this.disabledTooltip ? 'true' : undefined)}"
225
- aria-label="${ifDefined(this.ariaLabel)}"
237
+ aria-label="${ifDefined(ariaLabel)}"
226
238
  @change="${this.#handleChange}"
227
239
  class="d2l-input-checkbox"
228
240
  @click="${this.#handleClick}"
@@ -233,15 +245,23 @@ class InputCheckbox extends InputInlineHelpMixin(FocusMixin(SkeletonMixin(LitEle
233
245
  name="${ifDefined(this.name)}"
234
246
  tabindex="${ifDefined(tabindex)}"
235
247
  type="checkbox"
236
- .value="${this.value}"></span><span class="${classMap(textClasses)}"><slot></slot></span>
248
+ .value="${this.value}"></span><span class="${classMap(textClasses)}">${label}<slot></slot></span>
237
249
  </label>
238
250
  ${this._renderInlineHelp(this.#inlineHelpId)}
239
251
  ${offscreenContainer}
240
252
  ${disabledTooltip}
241
- <div class="${classMap(supportingClasses)}"><slot name="supporting" @slotchange="${this.#handleSupportingSlotChange}"></slot></div>
253
+ <div class="${classMap(supportingClasses)}" @change="${this.#handleSupportingChange}"><slot name="supporting" @slotchange="${this.#handleSupportingSlotChange}"></slot></div>
242
254
  `;
243
255
  }
244
256
 
257
+ willUpdate(changedProperties) {
258
+ super.willUpdate(changedProperties);
259
+ if (changedProperties.has('ariaLabel') && this.ariaLabel !== undefined) {
260
+ this.label = this.ariaLabel;
261
+ this.labelHidden = true;
262
+ }
263
+ }
264
+
245
265
  simulateClick() {
246
266
  this.checked = !this.checked;
247
267
  this.indeterminate = false;
@@ -276,6 +296,10 @@ class InputCheckbox extends InputInlineHelpMixin(FocusMixin(SkeletonMixin(LitEle
276
296
  this._isHovered = false;
277
297
  }
278
298
 
299
+ #handleSupportingChange(e) {
300
+ e.stopPropagation();
301
+ }
302
+
279
303
  #handleSupportingSlotChange(e) {
280
304
  const content = e.target.assignedNodes({ flatten: true });
281
305
  this._hasSupporting = content?.length > 0;
@@ -114,7 +114,8 @@ class Input extends SkeletonMixin(LabelledMixin(LitElement)) {
114
114
  } else {
115
115
  return html`
116
116
  <d2l-input-checkbox
117
- aria-label="${this.label}"
117
+ label="${this.label}"
118
+ label-hidden
118
119
  @change="${this._handleCheckboxChange}"
119
120
  ?checked="${this.selected}"
120
121
  class="${ifDefined(this.hovering ? 'd2l-hovering' : undefined)}"
@@ -51,7 +51,8 @@ class SelectAll extends FocusMixin(LocalizeCoreElement(SelectionObserverMixin(Li
51
51
 
52
52
  return html`
53
53
  <d2l-input-checkbox
54
- aria-label="${this.localize('components.selection.select-all')}"
54
+ label="${this.localize('components.selection.select-all')}"
55
+ label-hidden
55
56
  @change="${this.#handleCheckboxChange}"
56
57
  ?checked="${this.#getIsChecked()}"
57
58
  ?disabled="${this.disabled}"
@@ -89,7 +89,7 @@ render() {
89
89
  <div class="d2l-skeletize-container">
90
90
  <div class="d2l-skeletize">This text will skeletize</div>
91
91
  <span>This text will hide</span>
92
- <d2l-input-checkbox ?skeleton="{this.skeleton}">This input will skeletize</d2l-input-checkbox>
92
+ <d2l-input-checkbox ?skeleton="{this.skeleton}" label="This input will skeletize"></d2l-input-checkbox>
93
93
  </div>
94
94
  `;
95
95
  }
@@ -36,7 +36,7 @@ export class SkeletonTestContainer extends SkeletonGroupMixin(LitElement) {
36
36
  <div class="d2l-demo-box d2l-skeletize-container">
37
37
  <div class="d2l-skeletize">Container with Skeletons Inside</div>
38
38
  <span class="d2l-body-compact">No skeleton</span>
39
- <d2l-input-checkbox checked>Skeleton</d2l-input-checkbox>
39
+ <d2l-input-checkbox checked label="Skeleton"></d2l-input-checkbox>
40
40
  </div>
41
41
  `;
42
42
  }
@@ -5129,11 +5129,6 @@
5129
5129
  "path": "./components/inputs/input-checkbox.js",
5130
5130
  "description": "A component that can be used to show a checkbox and optional visible label.",
5131
5131
  "attributes": [
5132
- {
5133
- "name": "aria-label",
5134
- "description": "ACCESSIBILITY: Overrides the text in the `Default` slot for screenreader users",
5135
- "type": "string"
5136
- },
5137
5132
  {
5138
5133
  "name": "description",
5139
5134
  "description": "ACCESSIBILITY: Additional information communicated to screenreader users when focusing on the input",
@@ -5162,6 +5157,18 @@
5162
5157
  "type": "boolean",
5163
5158
  "default": "false"
5164
5159
  },
5160
+ {
5161
+ "name": "label",
5162
+ "description": "REQUIRED: Label for the input",
5163
+ "type": "string",
5164
+ "default": "\"\""
5165
+ },
5166
+ {
5167
+ "name": "label-hidden",
5168
+ "description": "Hides the label visually",
5169
+ "type": "boolean",
5170
+ "default": "false"
5171
+ },
5165
5172
  {
5166
5173
  "name": "name",
5167
5174
  "description": "Name of the input",
@@ -5187,12 +5194,6 @@
5187
5194
  }
5188
5195
  ],
5189
5196
  "properties": [
5190
- {
5191
- "name": "ariaLabel",
5192
- "attribute": "aria-label",
5193
- "description": "ACCESSIBILITY: Overrides the text in the `Default` slot for screenreader users",
5194
- "type": "string"
5195
- },
5196
5197
  {
5197
5198
  "name": "description",
5198
5199
  "attribute": "description",
@@ -5226,6 +5227,20 @@
5226
5227
  "type": "boolean",
5227
5228
  "default": "false"
5228
5229
  },
5230
+ {
5231
+ "name": "label",
5232
+ "attribute": "label",
5233
+ "description": "REQUIRED: Label for the input",
5234
+ "type": "string",
5235
+ "default": "\"\""
5236
+ },
5237
+ {
5238
+ "name": "labelHidden",
5239
+ "attribute": "label-hidden",
5240
+ "description": "Hides the label visually",
5241
+ "type": "boolean",
5242
+ "default": "false"
5243
+ },
5229
5244
  {
5230
5245
  "name": "name",
5231
5246
  "attribute": "name",
@@ -5261,10 +5276,6 @@
5261
5276
  }
5262
5277
  ],
5263
5278
  "slots": [
5264
- {
5265
- "name": "",
5266
- "description": "Checkbox information (e.g., text)"
5267
- },
5268
5279
  {
5269
5280
  "name": "inline-help",
5270
5281
  "description": "Help text that will appear below the input. Use this only when other helpful cues are not sufficient, such as a carefully-worded label."
@@ -63,7 +63,7 @@ export class AnimateTest extends LitElement {
63
63
  </d2l-list-item>` : null;
64
64
  });
65
65
  return html`
66
- <d2l-input-checkbox .checked="${this._listVisibility}" @change="${this._handleToggleList}">Show items</d2l-input-checkbox>
66
+ <d2l-input-checkbox .checked="${this._listVisibility}" @change="${this._handleToggleList}" label="Show items"></d2l-input-checkbox>
67
67
  <d2l-list .animate="${animateAction}">${items}</d2l-list>
68
68
  <d2l-button @click="${this._handleAddItem}" ?disabled="${!this._listVisibility}">Add Item</d2l-button>
69
69
  <d2l-button @click="${this._handleReRender}">Re-render (${this._renderCount})</d2l-button>
@@ -22,7 +22,7 @@
22
22
  }
23
23
  render() {
24
24
  return html`
25
- <d2l-input-checkbox aria-label="${ifDefined(this.label)}"></d2l-input-checkbox>
25
+ <d2l-input-checkbox label="${ifDefined(this.label)}" label-hidden></d2l-input-checkbox>
26
26
  `;
27
27
  }
28
28
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.106.3",
3
+ "version": "3.107.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",