@brightspace-ui/core 3.103.1 → 3.104.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.
@@ -55,9 +55,16 @@
55
55
  </template>
56
56
  </d2l-demo-snippet>
57
57
 
58
- <h2>Checkbox with label and secondary content</h2>
58
+ <h2>Checkbox with label and supporting content</h2>
59
59
  <d2l-demo-snippet>
60
60
  <template>
61
+ <d2l-input-checkbox>
62
+ Label for checkbox
63
+ <div slot="supporting" style="color: #999999;">
64
+ Additional content can go here and will<br>
65
+ also line up nicely with the checkbox.
66
+ </div>
67
+ </d2l-input-checkbox>
61
68
  <d2l-input-checkbox>Label for checkbox</d2l-input-checkbox>
62
69
  <d2l-input-checkbox-spacer style="color: #999999;">
63
70
  Additional content can go here and will<br>
@@ -77,6 +77,7 @@ checkbox.addEventListener('change', (e) => {
77
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
+ * `supporting`: Supporting information which will appear below and be aligned with the checkbox.
80
81
  <!-- docs: end hidden content -->
81
82
 
82
83
  ### Methods
@@ -85,6 +86,9 @@ checkbox.addEventListener('change', (e) => {
85
86
 
86
87
  ## Checkbox Spacer [d2l-input-checkbox-spacer]
87
88
 
89
+ > [!NOTE]
90
+ > Spacer is obsolete. Use the `supporting` slot instead.
91
+
88
92
  To align related content below checkboxes, the `d2l-input-checkbox-spacer` element can be used:
89
93
 
90
94
  <!-- docs: demo code display:block -->
@@ -63,6 +63,7 @@ export const checkboxStyles = css`
63
63
  * A component that can be used to show a checkbox and optional visible label.
64
64
  * @slot - Checkbox information (e.g., text)
65
65
  * @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
+ * @slot supporting - Supporting information which will appear below and be aligned with the checkbox.
66
67
  * @fires change - Dispatched when the checkbox's state changes
67
68
  */
68
69
  class InputCheckbox extends InputInlineHelpMixin(FocusMixin(SkeletonMixin(LitElement))) {
@@ -114,6 +115,7 @@ class InputCheckbox extends InputInlineHelpMixin(FocusMixin(SkeletonMixin(LitEle
114
115
  * @type {string}
115
116
  */
116
117
  value: { type: String },
118
+ _hasSupporting: { state: true },
117
119
  _isHovered: { state: true },
118
120
  };
119
121
  }
@@ -123,7 +125,6 @@ class InputCheckbox extends InputInlineHelpMixin(FocusMixin(SkeletonMixin(LitEle
123
125
  css`
124
126
  :host {
125
127
  display: block;
126
- line-height: ${cssSizes.inputBoxSize}rem;
127
128
  margin-bottom: 0.9rem;
128
129
  }
129
130
  :host([hidden]) {
@@ -135,6 +136,7 @@ class InputCheckbox extends InputInlineHelpMixin(FocusMixin(SkeletonMixin(LitEle
135
136
  }
136
137
  label {
137
138
  display: flex;
139
+ line-height: ${cssSizes.inputBoxSize}rem;
138
140
  overflow-wrap: anywhere;
139
141
  }
140
142
  .d2l-input-checkbox-wrapper {
@@ -156,7 +158,8 @@ class InputCheckbox extends InputInlineHelpMixin(FocusMixin(SkeletonMixin(LitEle
156
158
  bottom: 0.3rem;
157
159
  top: 0.3rem;
158
160
  }
159
- .d2l-input-inline-help {
161
+ .d2l-input-inline-help,
162
+ .d2l-input-checkbox-supporting {
160
163
  margin-inline-start: ${cssSizes.inputBoxSize + cssSizes.checkboxMargin}rem;
161
164
  }
162
165
  .d2l-input-checkbox-text-disabled {
@@ -168,6 +171,13 @@ class InputCheckbox extends InputInlineHelpMixin(FocusMixin(SkeletonMixin(LitEle
168
171
  input[type="checkbox"].d2l-input-checkbox {
169
172
  vertical-align: top;
170
173
  }
174
+ .d2l-input-checkbox-supporting {
175
+ display: none;
176
+ margin-block: 0.9rem;
177
+ }
178
+ .d2l-input-checkbox-supporting-visible {
179
+ display: block;
180
+ }
171
181
  `
172
182
  ];
173
183
  }
@@ -180,6 +190,7 @@ class InputCheckbox extends InputInlineHelpMixin(FocusMixin(SkeletonMixin(LitEle
180
190
  this.name = '';
181
191
  this.notTabbable = false;
182
192
  this.value = 'on';
193
+ this._hasSupporting = false;
183
194
  this._isHovered = false;
184
195
  }
185
196
 
@@ -189,6 +200,10 @@ class InputCheckbox extends InputInlineHelpMixin(FocusMixin(SkeletonMixin(LitEle
189
200
 
190
201
  render() {
191
202
  const tabindex = this.notTabbable ? -1 : undefined;
203
+ const supportingClasses = {
204
+ 'd2l-input-checkbox-supporting': true,
205
+ 'd2l-input-checkbox-supporting-visible': this._hasSupporting
206
+ };
192
207
  const textClasses = {
193
208
  'd2l-input-checkbox-text': true,
194
209
  'd2l-skeletize': true,
@@ -221,8 +236,9 @@ class InputCheckbox extends InputInlineHelpMixin(FocusMixin(SkeletonMixin(LitEle
221
236
  .value="${this.value}"></span><span class="${classMap(textClasses)}"><slot></slot></span>
222
237
  </label>
223
238
  ${this._renderInlineHelp(this.#inlineHelpId)}
224
- ${offscreenContainer}
239
+ ${offscreenContainer}
225
240
  ${disabledTooltip}
241
+ <div class="${classMap(supportingClasses)}"><slot name="supporting" @slotchange="${this.#handleSupportingSlotChange}"></slot></div>
226
242
  `;
227
243
  }
228
244
 
@@ -260,5 +276,10 @@ class InputCheckbox extends InputInlineHelpMixin(FocusMixin(SkeletonMixin(LitEle
260
276
  this._isHovered = false;
261
277
  }
262
278
 
279
+ #handleSupportingSlotChange(e) {
280
+ const content = e.target.assignedNodes({ flatten: true });
281
+ this._hasSupporting = content?.length > 0;
282
+ }
283
+
263
284
  }
264
285
  customElements.define('d2l-input-checkbox', InputCheckbox);
@@ -5184,6 +5184,10 @@
5184
5184
  {
5185
5185
  "name": "inline-help",
5186
5186
  "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."
5187
+ },
5188
+ {
5189
+ "name": "supporting",
5190
+ "description": "Supporting information which will appear below and be aligned with the checkbox."
5187
5191
  }
5188
5192
  ]
5189
5193
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.103.1",
3
+ "version": "3.104.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",