@brightspace-ui/core 2.42.0 → 2.43.1

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.
@@ -58,7 +58,7 @@ class FilterTags extends RtlMixin(LocalizeCoreElement(LitElement)) {
58
58
  }
59
59
 
60
60
  .d2l-filter-tags-none-label {
61
- color: var(--d2l-color-corundum);
61
+ color: var(--d2l-color-galena);
62
62
  display: inline-block;
63
63
  font-style: italic;
64
64
  padding-top: 0.15rem;
@@ -1,6 +1,7 @@
1
1
  import '../colors/colors.js';
2
2
  import { codeStyles, HtmlBlockCodeRenderer } from '../../helpers/prism.js';
3
- import { css, LitElement } from 'lit';
3
+ import { css, html, LitElement } from 'lit';
4
+ import { classMap } from 'lit/directives/class-map.js';
4
5
  import { HtmlAttributeObserverController } from '../../controllers/attributeObserver/htmlAttributeObserverController.js';
5
6
  import { HtmlBlockMathRenderer } from '../../helpers/mathjax.js';
6
7
  import { requestInstance } from '../../mixins/provider-mixin.js';
@@ -140,6 +141,7 @@ class HtmlBlock extends RtlMixin(LitElement) {
140
141
  compact: { type: Boolean },
141
142
  /**
142
143
  * Whether to display the HTML in inline mode
144
+ * @type {Boolean}
143
145
  */
144
146
  inline: { type: Boolean },
145
147
  /**
@@ -161,13 +163,17 @@ class HtmlBlock extends RtlMixin(LitElement) {
161
163
  text-align: left;
162
164
  }
163
165
  :host([inline]),
164
- :host([inline]) div.d2l-html-block-rendered {
166
+ :host([inline]) .d2l-html-block-rendered {
165
167
  display: inline;
166
168
  }
167
169
  :host([hidden]),
168
- :host([no-deferred-rendering]) div.d2l-html-block-rendered {
170
+ :host([no-deferred-rendering]) .d2l-html-block-rendered,
171
+ slot {
169
172
  display: none;
170
173
  }
174
+ :host([no-deferred-rendering]) slot {
175
+ display: contents;
176
+ }
171
177
  :host([dir="rtl"]) {
172
178
  text-align: right;
173
179
  }
@@ -209,52 +215,60 @@ class HtmlBlock extends RtlMixin(LitElement) {
209
215
 
210
216
  firstUpdated(changedProperties) {
211
217
  super.firstUpdated(changedProperties);
218
+ this._updateContextKeys();
219
+ }
212
220
 
213
- if (this._renderContainer) return;
214
-
215
- // The d2l-html-block-rendered class is used to apply CSS outside of the html-block component. Do not change lightly.
216
- this.shadowRoot.innerHTML += '<div class="d2l-html-block-rendered'
217
- + `${this.compact ? ' d2l-html-block-compact' : ''}`
218
- + '"></div><slot'
219
- + `${!this.noDeferredRendering ? ' style="display: none"' : ''}`
220
- + '></slot>';
221
+ render() {
222
+ const renderContainerClasses = {
223
+ 'd2l-html-block-rendered': true,
224
+ 'd2l-html-block-compact': this.compact
225
+ };
221
226
 
222
- this.shadowRoot.querySelector('slot').addEventListener('slotchange', async e => await this._render(e.target));
223
- this._renderContainer = this.shadowRoot.querySelector('.d2l-html-block-rendered');
224
- this._context = this._contextObserverController ? { ...this._contextObserverController.values } : {};
227
+ return html`
228
+ <div class="${classMap(renderContainerClasses)}"></div>
229
+ <slot @slotchange="${this._handleSlotChange}"></slot>
230
+ `;
225
231
  }
226
232
 
227
- updated() {
228
- super.updated();
229
- if (this._contextObserverController && this._contextObjectHasChanged()) this._render();
233
+ updated(changedProperties) {
234
+ super.updated(changedProperties);
235
+ if (this._contextChanged()) {
236
+ this._render();
237
+ this._updateContextKeys();
238
+ }
230
239
  }
231
240
 
232
- _contextObjectHasChanged() {
233
- if (this._context.size !== this._contextObserverController.values.size) return true;
234
- for (const [attr, val] of this._context) {
241
+ _contextChanged() {
242
+ if (!this._contextObserverController) return false;
243
+
244
+ if (this._contextKeys.size !== this._contextObserverController.values.size) return true;
245
+ for (const [attr, val] of this._contextKeys) {
235
246
  if (!this._contextObserverController.values.has(attr)) return true;
236
247
  if (this._contextObserverController.values.get(attr) !== val) return true;
237
248
  }
238
249
  return false;
239
250
  }
240
251
 
252
+ async _handleSlotChange(e) {
253
+ if (!e.target) return;
254
+ await this._render(e.target);
255
+ }
256
+
241
257
  async _processRenderers(elem) {
242
258
  for (const renderer of getRenderers()) {
243
259
  if (this._contextObserverController && renderer.contextAttributes) {
244
260
  const contextValues = new Map();
245
261
  renderer.contextAttributes.forEach(attr => contextValues.set(attr, this._contextObserverController.values.get(attr)));
246
- elem = await renderer.render(elem, {
262
+ await renderer.render(elem, {
247
263
  contextValues: contextValues,
248
264
  noDeferredRendering: this.noDeferredRendering
249
265
  });
250
266
  } else {
251
- elem = await renderer.render(elem, {
267
+ await renderer.render(elem, {
252
268
  noDeferredRendering: this.noDeferredRendering
253
269
  });
254
270
  }
255
271
  }
256
-
257
- return elem;
258
272
  }
259
273
 
260
274
  async _render(slot) {
@@ -274,20 +288,16 @@ class HtmlBlock extends RtlMixin(LitElement) {
274
288
  }
275
289
 
276
290
  _stamp(slot) {
277
- const stampHTML = async nodes => {
278
- if (nodes && nodes.length > 0) {
279
-
280
- let temp = document.createElement('div');
281
- temp.style.display = 'none';
282
- nodes.forEach(node => temp.appendChild(node.cloneNode(true)));
291
+ const renderContainer = this.shadowRoot.querySelector('.d2l-html-block-rendered');
283
292
 
284
- this._renderContainer.appendChild(temp);
285
- temp = await this._processRenderers(temp);
286
- this._renderContainer.innerHTML = temp.innerHTML;
293
+ const stampHTML = async nodes => {
294
+ renderContainer.innerHTML = '';
295
+ if (!nodes || nodes.length === 0) return;
287
296
 
288
- } else {
289
- this._renderContainer.innerHTML = '';
290
- }
297
+ // Nodes must be cloned into the render container before processing, as
298
+ // some renderers require connected nodes (e.g. MathJax).
299
+ nodes.forEach(node => renderContainer.appendChild(node.cloneNode(true)));
300
+ await this._processRenderers(renderContainer);
291
301
  };
292
302
 
293
303
  if (this._contentObserver) this._contentObserver.disconnect();
@@ -303,6 +313,15 @@ class HtmlBlock extends RtlMixin(LitElement) {
303
313
  stampHTML(slottedNodes);
304
314
  }
305
315
 
316
+ _updateContextKeys() {
317
+ if (!this._contextObserverController) return;
318
+ if (!this._contextKeys) this._contextKeys = new Map();
319
+
320
+ this._contextObserverController.values.forEach((val, attr) => {
321
+ this._contextKeys.set(attr, val);
322
+ });
323
+ }
324
+
306
325
  }
307
326
 
308
327
  customElements.define('d2l-html-block', HtmlBlock);
@@ -63,6 +63,8 @@ To make your usage of `d2l-switch` accessible, use the following property:
63
63
 
64
64
  The `d2l-switch-visibility` element is a variant of the generic switch configured with special icons and default text for toggling "visibility".
65
65
 
66
+ It consists of 3 states: On ("Visible"), Off ("Hidden"), and On with Conditions ("Visible. Conditions must be met.").
67
+
66
68
  <!-- docs: demo live name:d2l-switch-visibility autoSize:false size:small -->
67
69
  ```html
68
70
  <script type="module">
@@ -76,12 +78,36 @@ The `d2l-switch-visibility` element is a variant of the generic switch configure
76
78
 
77
79
  | Property | Type | Description |
78
80
  |---|---|---|
79
- | `text`| String, required | Accessible text for the switch; defaults to "Visibility" |
80
81
  | `disabled` | Boolean | Disabled the switch |
81
- | `on` | Boolean | Whether the switch is "on" or "off" |
82
+ | `on` | Boolean | Whether the switch is "on" or "off". If content is passed into the switch slot, the switch will be "on with conditions". |
82
83
  | `text-position` | String | Valid values are: `start`, `end` (default), and `hidden` |
83
84
 
84
85
  ### Events
85
86
 
86
87
  - `change`: dispatched when the `on` property is updated
88
+
89
+ ### Slots
90
+
91
+ - Optional default slot content - Content that will be displayed within the "conditions" opener tooltip when the switch is on.
92
+
87
93
  <!-- docs: end hidden content -->
94
+
95
+ ### Visibility Switch with Conditions
96
+ It may be helpful to have visibility be dependent on additional conditions being met outside of the Visibility Switch.
97
+
98
+ Additional information can be added to the label by passing it into the `d2l-switch-visibility` element.
99
+
100
+ <!-- docs: demo code autoSize:false size:large -->
101
+ ```html
102
+ <script type="module">
103
+ import '@brightspace-ui/core/components/switch/switch-visibility.js';
104
+ </script>
105
+ <d2l-switch-visibility on>
106
+ These are some conditions that must be met for the activity to be visible.
107
+ <ul>
108
+ <li> Condition 1 </li>
109
+ <li> Condition 2 </li>
110
+ <li> Condition 3 </li>
111
+ </ul>
112
+ </d2l-switch-visibility>
113
+ ```
@@ -53,6 +53,21 @@
53
53
  </template>
54
54
  </d2l-demo-snippet>
55
55
 
56
+ <h2>Visibility (with conditions)</h2>
57
+
58
+ <d2l-demo-snippet>
59
+ <template>
60
+ <d2l-switch-visibility>
61
+ These are some conditions that must be met for the activity to be visible.
62
+ <ul>
63
+ <li> Condition 1 </li>
64
+ <li> Condition 2 </li>
65
+ <li> Condition 3 </li>
66
+ </ul>
67
+ </d2l-switch-visibility>
68
+ </template>
69
+ </d2l-demo-snippet>
70
+
56
71
  </d2l-demo-page>
57
72
  </body>
58
73
  </html>
@@ -1,5 +1,6 @@
1
1
  import '../colors/colors.js';
2
2
  import { css, html } from 'lit';
3
+ import { classMap } from 'lit/directives/class-map.js';
3
4
  import { FocusMixin } from '../../mixins/focus-mixin.js';
4
5
  import { FocusVisiblePolyfillMixin } from '../../mixins/focus-visible-polyfill-mixin.js';
5
6
  import { getUniqueId } from '../../helpers/uniqueId.js';
@@ -21,8 +22,7 @@ export const SwitchMixin = superclass => class extends FocusMixin(RtlMixin(Focus
21
22
  */
22
23
  on: { type: Boolean, reflect: true },
23
24
  /**
24
- * REQUIRED: The text that is displayed for the switch label.
25
- * @type {string}
25
+ * @ignore - Need to add documentation in each component that uses this mixin.
26
26
  */
27
27
  text: { type: String, reflect: true },
28
28
  /**
@@ -30,7 +30,8 @@ export const SwitchMixin = superclass => class extends FocusMixin(RtlMixin(Focus
30
30
  * @type {'start'|'end'|'hidden'}
31
31
  * @default end
32
32
  */
33
- textPosition: { type: String, attribute: 'text-position', reflect: true }
33
+ textPosition: { type: String, attribute: 'text-position', reflect: true },
34
+ _hovering: { state: true }
34
35
  };
35
36
  }
36
37
 
@@ -49,7 +50,7 @@ export const SwitchMixin = superclass => class extends FocusMixin(RtlMixin(Focus
49
50
  border: 2px solid transparent;
50
51
  border-radius: 1rem;
51
52
  box-sizing: border-box;
52
- cursor: pointer;
53
+ cursor: default;
53
54
  display: inline-block;
54
55
  font-size: 0;
55
56
  line-height: 0;
@@ -60,10 +61,6 @@ export const SwitchMixin = superclass => class extends FocusMixin(RtlMixin(Focus
60
61
  .d2l-switch-container.focus-visible {
61
62
  border-color: var(--d2l-color-celestine);
62
63
  }
63
- .d2l-switch-container:hover > .d2l-switch-inner {
64
- border-color: var(--d2l-color-celestine);
65
- box-shadow: 0 0 0 1px var(--d2l-color-celestine) inset;
66
- }
67
64
  :host([disabled]) .d2l-switch-container {
68
65
  cursor: default;
69
66
  opacity: 0.5;
@@ -147,9 +144,17 @@ export const SwitchMixin = superclass => class extends FocusMixin(RtlMixin(Focus
147
144
  transform: scale(0.35);
148
145
  }
149
146
  .d2l-switch-text {
147
+ cursor: default;
150
148
  font-size: 0.8rem;
151
149
  font-weight: 400;
152
150
  }
151
+ :host([text-position="hidden"]) .d2l-switch-text {
152
+ display: none;
153
+ }
154
+ .d2l-switch-inner:hover, .switch-hover {
155
+ border-color: var(--d2l-color-celestine);
156
+ box-shadow: 0 0 0 1px var(--d2l-color-celestine) inset;
157
+ }
153
158
  @media (prefers-reduced-motion: reduce) {
154
159
  .d2l-switch-toggle,
155
160
  .d2l-switch-icon-on,
@@ -167,6 +172,7 @@ export const SwitchMixin = superclass => class extends FocusMixin(RtlMixin(Focus
167
172
  this.on = false;
168
173
  this.textPosition = 'end';
169
174
  this._textId = getUniqueId();
175
+ this._hovering = false;
170
176
  }
171
177
 
172
178
  static get focusElementSelector() {
@@ -182,11 +188,17 @@ export const SwitchMixin = superclass => class extends FocusMixin(RtlMixin(Focus
182
188
 
183
189
  render() {
184
190
  const tabindex = (!this.disabled ? '0' : undefined);
185
- const text = html`<span id="${this._textId}" class="d2l-switch-text">${this.text}</span>`;
191
+ const innerSwitchClasses = {
192
+ 'switch-hover': this._hovering,
193
+ 'd2l-switch-inner': true
194
+ };
195
+ const switchLabel = html`<span id="${this._textId}" class="d2l-switch-text">${this._labelContent}</span>`;
186
196
  const textPosition = (this.textPosition === 'start' || this.textPosition === 'hidden'
187
197
  ? this.textPosition : 'end');
198
+
199
+ // Note: we render the switchLabel in the case of textPosition === 'hidden' so that any slot handlers can pick up on content being passed in
188
200
  return html`
189
- ${textPosition === 'start' ? text : ''}
201
+ ${textPosition === 'start' ? switchLabel : ''}
190
202
  <div
191
203
  aria-checked="${this.on ? 'true' : 'false'}"
192
204
  aria-label="${ifDefined(textPosition === 'hidden' ? this.text : undefined)}"
@@ -197,16 +209,25 @@ export const SwitchMixin = superclass => class extends FocusMixin(RtlMixin(Focus
197
209
  @keyup="${this._handleKeyUp}"
198
210
  role="switch"
199
211
  tabindex="${ifDefined(tabindex)}">
200
- <div class="d2l-switch-inner">
212
+ <div class="${classMap(innerSwitchClasses)}">
201
213
  <div class="d2l-switch-toggle"><div></div></div>
202
214
  <div class="d2l-switch-icon-on">${this.onIcon}</div>
203
215
  <div class="d2l-switch-icon-off">${this.offIcon}</div>
204
216
  </div>
205
217
  </div>
206
- ${textPosition === 'end' ? text : ''}
218
+ ${textPosition === 'end' || textPosition === 'hidden' ? switchLabel : ''}
207
219
  `;
208
220
  }
209
221
 
222
+ get _labelContent() {
223
+ return html`<span
224
+ @click='${this._handleClick}'
225
+ @mouseenter='${this._handleSwitchHover}'
226
+ @mouseleave='${this._handleSwitchHoverLeave}'>
227
+ ${this.text}
228
+ </span>`;
229
+ }
230
+
210
231
  _handleClick() {
211
232
  this._toggleState();
212
233
  }
@@ -221,6 +242,14 @@ export const SwitchMixin = superclass => class extends FocusMixin(RtlMixin(Focus
221
242
  if (e.keyCode === 32) this._toggleState();
222
243
  }
223
244
 
245
+ _handleSwitchHover() {
246
+ this._hovering = true;
247
+ }
248
+
249
+ _handleSwitchHoverLeave() {
250
+ this._hovering = false;
251
+ }
252
+
224
253
  _toggleState() {
225
254
  if (this.disabled) return;
226
255
  this.on = !this.on;
@@ -1,19 +1,53 @@
1
1
  import '../icons/icon.js';
2
- import { html, LitElement } from 'lit';
2
+ import '../tooltip/tooltip-help.js';
3
+ import { css, html, LitElement } from 'lit';
4
+ import { classMap } from 'lit/directives/class-map.js';
3
5
  import { LocalizeCoreElement } from '../../helpers/localize-core-element.js';
4
6
  import { SwitchMixin } from './switch-mixin.js';
5
7
 
6
8
  /**
7
9
  * A variant of the generic switch configured with special icons and default text for toggling "visibility".
10
+ * @slot - Optional content that will be displayed within the "conditions" opener tooltip when the switch is on.
8
11
  */
9
12
  class VisibilitySwitch extends LocalizeCoreElement(SwitchMixin(LitElement)) {
10
13
 
11
- /**
12
- * The text that is displayed for the switch label.
13
- * @default "Visibility"
14
- */
14
+ static get properties() {
15
+ return {
16
+ _hasConditions: { state: true }
17
+ };
18
+ }
19
+
20
+ static get styles() {
21
+ return [super.styles, css`
22
+ d2l-tooltip-help {
23
+ display: none;
24
+ }
25
+ d2l-tooltip-help.switch-visibility-conditions-show {
26
+ display: inline;
27
+ }
28
+ `];
29
+ }
30
+
31
+ constructor() {
32
+ super();
33
+ this._hasConditions = false;
34
+ }
35
+
15
36
  get text() {
16
- return (this._text ? this._text : this.localize('components.switch.visibility'));
37
+ if (this._text) return this._text;
38
+
39
+ if (this.on && this._hasConditions && this.textPosition === 'hidden') {
40
+ return `${this.localize('components.switch.visibleWithPeriod')} ${this.localize('components.switch.conditions')}`;
41
+ }
42
+ else if (this.on && this._hasConditions) {
43
+ return this.localize('components.switch.visibleWithPeriod');
44
+ }
45
+ else if (this.on) {
46
+ return this.localize('components.switch.visible');
47
+ }
48
+ else {
49
+ return this.localize('components.switch.hidden');
50
+ }
17
51
  }
18
52
 
19
53
  set text(val) {
@@ -32,6 +66,30 @@ class VisibilitySwitch extends LocalizeCoreElement(SwitchMixin(LitElement)) {
32
66
  return html`<d2l-icon icon="tier1:visibility-show"></d2l-icon>`;
33
67
  }
34
68
 
69
+ get _labelContent() {
70
+ if (this._text) return super._labelContent;
71
+
72
+ const tooltipHelpClasses = {
73
+ 'switch-visibility-conditions-show': this.on && this._hasConditions,
74
+ 'd2l-switch-text': true
75
+ };
76
+
77
+ const conditions = html`
78
+ <d2l-tooltip-help
79
+ class="${classMap(tooltipHelpClasses)}"
80
+ id="conditions-help"
81
+ inherit-font-style
82
+ text="${this.localize('components.switch.conditions')}">
83
+ <slot @slotchange="${this._handleConditionsSlotChange}"></slot>
84
+ </d2l-tooltip-help>
85
+ `;
86
+
87
+ return html`${super._labelContent}${conditions}`;
88
+ }
89
+
90
+ _handleConditionsSlotChange(e) {
91
+ this._hasConditions = e.target.assignedNodes({ flatten: true }).length > 0;
92
+ }
35
93
  }
36
94
 
37
95
  customElements.define('d2l-switch-visibility', VisibilitySwitch);
@@ -6,6 +6,7 @@ import { SwitchMixin } from './switch-mixin.js';
6
6
 
7
7
  /**
8
8
  * A generic switch with on/off semantics.
9
+ * @attr {string} text - REQUIRED: The text that is displayed for the switch label.
9
10
  */
10
11
  class Switch extends SwitchMixin(LitElement) {
11
12
 
@@ -466,11 +466,14 @@ class Tooltip extends RtlMixin(LitElement) {
466
466
  }
467
467
  }
468
468
 
469
+ // Note: role="text" is a workaround for Safari. Otherwise, list-item content is not announced with VoiceOver
469
470
  return html`
470
471
  <div class="d2l-tooltip-container">
471
472
  <div class="d2l-tooltip-position" style=${styleMap(tooltipPositionStyle)}>
472
473
  <div class="d2l-body-small d2l-tooltip-content">
473
- <slot></slot>
474
+ <div role="text">
475
+ <slot></slot>
476
+ </div>
474
477
  </div>
475
478
  </div>
476
479
  <div class="d2l-tooltip-pointer">
@@ -3813,7 +3813,7 @@
3813
3813
  {
3814
3814
  "name": "inline",
3815
3815
  "description": "Whether to display the HTML in inline mode",
3816
- "type": "boolean",
3816
+ "type": "Boolean",
3817
3817
  "default": "false"
3818
3818
  },
3819
3819
  {
@@ -3835,7 +3835,7 @@
3835
3835
  "name": "inline",
3836
3836
  "attribute": "inline",
3837
3837
  "description": "Whether to display the HTML in inline mode",
3838
- "type": "boolean",
3838
+ "type": "Boolean",
3839
3839
  "default": "false"
3840
3840
  },
3841
3841
  {
@@ -9851,12 +9851,6 @@
9851
9851
  "path": "./components/switch/switch-visibility.js",
9852
9852
  "description": "A variant of the generic switch configured with special icons and default text for toggling \"visibility\".",
9853
9853
  "attributes": [
9854
- {
9855
- "name": "text",
9856
- "description": "The text that is displayed for the switch label.",
9857
- "type": "string",
9858
- "default": "\"\\\"Visibility\\\"\""
9859
- },
9860
9854
  {
9861
9855
  "name": "disabled",
9862
9856
  "description": "Disables the switch from being toggled.",
@@ -9877,6 +9871,9 @@
9877
9871
  }
9878
9872
  ],
9879
9873
  "properties": [
9874
+ {
9875
+ "name": "text"
9876
+ },
9880
9877
  {
9881
9878
  "name": "offIcon",
9882
9879
  "type": "TemplateResult<1>"
@@ -9885,13 +9882,6 @@
9885
9882
  "name": "onIcon",
9886
9883
  "type": "TemplateResult<1>"
9887
9884
  },
9888
- {
9889
- "name": "text",
9890
- "attribute": "text",
9891
- "description": "The text that is displayed for the switch label.",
9892
- "type": "string",
9893
- "default": "\"\\\"Visibility\\\"\""
9894
- },
9895
9885
  {
9896
9886
  "name": "disabled",
9897
9887
  "attribute": "disabled",
@@ -9924,6 +9914,12 @@
9924
9914
  "name": "change",
9925
9915
  "description": "Dispatched when the `on` property is updated"
9926
9916
  }
9917
+ ],
9918
+ "slots": [
9919
+ {
9920
+ "name": "",
9921
+ "description": "Optional content that will be displayed within the \"conditions\" opener tooltip when the switch is on."
9922
+ }
9927
9923
  ]
9928
9924
  },
9929
9925
  {
@@ -9931,11 +9927,6 @@
9931
9927
  "path": "./components/switch/switch.js",
9932
9928
  "description": "A generic switch with on/off semantics.",
9933
9929
  "attributes": [
9934
- {
9935
- "name": "text",
9936
- "description": "REQUIRED: The text that is displayed for the switch label.",
9937
- "type": "string"
9938
- },
9939
9930
  {
9940
9931
  "name": "disabled",
9941
9932
  "description": "Disables the switch from being toggled.",
@@ -9953,6 +9944,11 @@
9953
9944
  "description": "Determines where text should be positioned relative to the switch.",
9954
9945
  "type": "'start'|'end'|'hidden'",
9955
9946
  "default": "\"end\""
9947
+ },
9948
+ {
9949
+ "name": "text",
9950
+ "description": "REQUIRED: The text that is displayed for the switch label.",
9951
+ "type": "string"
9956
9952
  }
9957
9953
  ],
9958
9954
  "properties": [
@@ -9964,12 +9960,6 @@
9964
9960
  "name": "onIcon",
9965
9961
  "type": "TemplateResult<1>"
9966
9962
  },
9967
- {
9968
- "name": "text",
9969
- "attribute": "text",
9970
- "description": "REQUIRED: The text that is displayed for the switch label.",
9971
- "type": "string"
9972
- },
9973
9963
  {
9974
9964
  "name": "disabled",
9975
9965
  "attribute": "disabled",
@@ -61,35 +61,18 @@ export class HtmlBlockMathRenderer {
61
61
  // This work-around should be removed when linebreaks are natively supported.
62
62
  // MathJax issue: https://github.com/mathjax/MathJax/issues/2312
63
63
  // A duplicate that explains our exact issue: https://github.com/mathjax/MathJax/issues/2495
64
- const lineBreakStyle = 'display: block; height: 0.5rem;';
65
-
66
- // If we're opting out of deferred rendering, we need to rely
67
- // on the global MathJax install for rendering.
68
- if (options.noDeferredRendering) {
69
- elem.querySelectorAll('mspace[linebreak="newline"]').forEach(elm => {
70
- elm.setAttribute('style', lineBreakStyle);
71
- });
72
-
73
- await window.MathJax.startup.promise;
74
- renderingPromise = renderingPromise.then(() => window.MathJax.typesetShadow(elem.getRootNode(), elem));
75
- await renderingPromise;
76
- return elem;
77
- }
78
-
79
- const inner = elem.innerHTML.replace(/<mspace linebreak="newline">/gi, `<mspace linebreak="newline" style="${lineBreakStyle}">`);
80
-
81
- const temp = document.createElement('div');
82
- temp.style.display = 'none';
83
- temp.attachShadow({ mode: 'open' });
84
- temp.shadowRoot.innerHTML = `<div><mjx-doc><mjx-head></mjx-head><mjx-body>${inner}</mjx-body></mjx-doc></div>`;
64
+ elem.querySelectorAll('mspace[linebreak="newline"]').forEach(elm => {
65
+ elm.style.display = 'block';
66
+ elm.style.height = '0.5rem';
67
+ });
85
68
 
86
- elem.appendChild(temp);
69
+ // If we're using deferred rendering, we need to create a document structure
70
+ // within the element so MathJax can appropriately process math.
71
+ if (!options.noDeferredRendering) elem.innerHTML = `<mjx-doc><mjx-head></mjx-head><mjx-body>${elem.innerHTML}</mjx-body></mjx-doc>`;
87
72
 
88
73
  await window.MathJax.startup.promise;
89
- renderingPromise = renderingPromise.then(() => window.MathJax.typesetShadow(temp.shadowRoot));
74
+ renderingPromise = renderingPromise.then(() => window.MathJax.typesetShadow(elem.getRootNode(), elem));
90
75
  await renderingPromise;
91
-
92
- return temp.shadowRoot.firstChild;
93
76
  }
94
77
 
95
78
  }
@@ -129,12 +112,18 @@ export function loadMathJax(mathJaxConfig) {
129
112
  const AbstractHandler = window.MathJax._.core.Handler.AbstractHandler.prototype;
130
113
  const startup = window.MathJax.startup;
131
114
 
115
+ const getFirstChild = doc => {
116
+ const child = doc.firstChild;
117
+ if (!child || child.nodeType === Node.ELEMENT_NODE) return child;
118
+ else return child.nextElementSibling;
119
+ };
120
+
132
121
  //
133
122
  // Extend HTMLAdaptor to handle shadowDOM as the document
134
123
  //
135
124
  class ShadowAdaptor extends HTMLAdaptor {
136
125
  body(doc) {
137
- return doc.body || (doc.firstChild || {}).lastChild || doc;
126
+ return doc.body || (getFirstChild(doc) || {}).lastChild || doc;
138
127
  }
139
128
  create(kind, ns) {
140
129
  const document = (this.document.createElement ? this.document : this.window.document);
@@ -143,10 +132,10 @@ export function loadMathJax(mathJaxConfig) {
143
132
  document.createElement(kind));
144
133
  }
145
134
  head(doc) {
146
- return doc.head || (doc.firstChild || {}).firstChild || doc;
135
+ return doc.head || (getFirstChild(doc) || {}).firstChild || doc;
147
136
  }
148
137
  root(doc) {
149
- return doc.documentElement || doc.firstChild || doc;
138
+ return doc.documentElement || getFirstChild(doc) || doc;
150
139
  }
151
140
  text(text) {
152
141
  const document = (this.document.createTextNode ? this.document : this.window.document);
package/helpers/prism.js CHANGED
@@ -450,8 +450,6 @@ export async function formatCodeElement(elem) {
450
450
 
451
451
  if (!elem.dataset.language && languageInfo.key !== 'plain') elem.dataset.language = languageInfo.desc;
452
452
  Prism.highlightElement(code);
453
-
454
- return elem;
455
453
  }
456
454
 
457
455
  export class HtmlBlockCodeRenderer {
package/lang/ar.js CHANGED
@@ -98,7 +98,10 @@ export default {
98
98
  "components.selection.select-all": "تحديد الكل",
99
99
  "components.selection.select-all-items": "تحديد كل المواد الـ {count}.",
100
100
  "components.selection.selected": "تم تحديد {count}",
101
- "components.switch.visibility": "إمكانية الرؤية",
101
+ "components.switch.visible": "Visible",
102
+ "components.switch.visibleWithPeriod": "Visible.",
103
+ "components.switch.hidden": "Hidden",
104
+ "components.switch.conditions": "Conditions must be met",
102
105
  "components.tabs.next": "التمرير إلى الأمام",
103
106
  "components.tabs.previous": "التمرير إلى الخلف",
104
107
  "components.tag-list.clear": "انقر فوق، أو اضغط على مسافة للخلف، أو اضغط على مفتاح حذف لإزالة العنصر {value}",
package/lang/cy.js CHANGED
@@ -98,7 +98,10 @@ export default {
98
98
  "components.selection.select-all": "Dewis y Cyfan",
99
99
  "components.selection.select-all-items": "Dewis Pob {count} Eitem",
100
100
  "components.selection.selected": "{count} wedi’u dewis.",
101
- "components.switch.visibility": "Gwelededd",
101
+ "components.switch.visible": "Visible",
102
+ "components.switch.visibleWithPeriod": "Visible.",
103
+ "components.switch.hidden": "Hidden",
104
+ "components.switch.conditions": "Conditions must be met",
102
105
  "components.tabs.next": "Sgrolio Ymlaen",
103
106
  "components.tabs.previous": "Sgrolio Yn Ôl",
104
107
  "components.tag-list.clear": "Cliciwch, pwyswch yn ôl, neu pwyswch y bysell dileu i dynnu’r eitem {value}",
package/lang/da.js CHANGED
@@ -98,7 +98,10 @@ export default {
98
98
  "components.selection.select-all": "Vælg alle",
99
99
  "components.selection.select-all-items": "Vælg alle {count} elementer",
100
100
  "components.selection.selected": "{count} valgt",
101
- "components.switch.visibility": "Synlighed",
101
+ "components.switch.visible": "Visible",
102
+ "components.switch.visibleWithPeriod": "Visible.",
103
+ "components.switch.hidden": "Hidden",
104
+ "components.switch.conditions": "Conditions must be met",
102
105
  "components.tabs.next": "Rul frem",
103
106
  "components.tabs.previous": "Rul tilbage",
104
107
  "components.tag-list.clear": "Klik, tryk på tilbagetasten, eller tryk på slettasten for at fjerne element {value}",
package/lang/de.js CHANGED
@@ -98,7 +98,10 @@ export default {
98
98
  "components.selection.select-all": "Alle auswählen",
99
99
  "components.selection.select-all-items": "Alle {count} Elemente auswählen",
100
100
  "components.selection.selected": "{count} ausgewählt",
101
- "components.switch.visibility": "Sichtbarkeit",
101
+ "components.switch.visible": "Visible",
102
+ "components.switch.visibleWithPeriod": "Visible.",
103
+ "components.switch.hidden": "Hidden",
104
+ "components.switch.conditions": "Conditions must be met",
102
105
  "components.tabs.next": "Weiterblättern",
103
106
  "components.tabs.previous": "Zurückblättern",
104
107
  "components.tag-list.clear": "Klicken Sie, drücken Sie die Rücktaste, oder drücken Sie die Entfernen-Taste, um das Element {value} zu entfernen",
package/lang/en.js CHANGED
@@ -98,7 +98,10 @@ export default {
98
98
  "components.selection.select-all": "Select All",
99
99
  "components.selection.select-all-items": "Select All {count} Items",
100
100
  "components.selection.selected": "{count} selected",
101
- "components.switch.visibility": "Visibility",
101
+ "components.switch.visible": "Visible",
102
+ "components.switch.visibleWithPeriod": "Visible.",
103
+ "components.switch.hidden": "Hidden",
104
+ "components.switch.conditions": "Conditions must be met",
102
105
  "components.tabs.next": "Scroll Forward",
103
106
  "components.tabs.previous": "Scroll Backward",
104
107
  "components.tag-list.clear": "Click, press backspace, or press delete key to remove item {value}",
package/lang/es-es.js CHANGED
@@ -98,7 +98,10 @@ export default {
98
98
  "components.selection.select-all": "Seleccionar todo",
99
99
  "components.selection.select-all-items": "Seleccione los {count} elementos",
100
100
  "components.selection.selected": "{count} seleccionados",
101
- "components.switch.visibility": "Visibilidad",
101
+ "components.switch.visible": "Visible",
102
+ "components.switch.visibleWithPeriod": "Visible.",
103
+ "components.switch.hidden": "Hidden",
104
+ "components.switch.conditions": "Conditions must be met",
102
105
  "components.tabs.next": "Desplazarse hacia delante",
103
106
  "components.tabs.previous": "Desplazarse hacia atrás",
104
107
  "components.tag-list.clear": "Haga clic, pulse Retroceso o pulse la tecla Supr para eliminar el elemento {value}",
package/lang/es.js CHANGED
@@ -98,7 +98,10 @@ export default {
98
98
  "components.selection.select-all": "Seleccionar todo",
99
99
  "components.selection.select-all-items": "Seleccione todos los {count} elementos",
100
100
  "components.selection.selected": "{count} seleccionados",
101
- "components.switch.visibility": "Visibilidad",
101
+ "components.switch.visible": "Visible",
102
+ "components.switch.visibleWithPeriod": "Visible.",
103
+ "components.switch.hidden": "Hidden",
104
+ "components.switch.conditions": "Conditions must be met",
102
105
  "components.tabs.next": "Desplazarse hacia adelante",
103
106
  "components.tabs.previous": "Desplazarse hacia atrás",
104
107
  "components.tag-list.clear": "Haga clic, presione Retroceso o presione la tecla Suprimir para eliminar el elemento {value}",
package/lang/fr-fr.js CHANGED
@@ -98,7 +98,10 @@ export default {
98
98
  "components.selection.select-all": "Tout sélectionner",
99
99
  "components.selection.select-all-items": "Sélectionner tous les {count} éléments",
100
100
  "components.selection.selected": "{count} sélectionnés",
101
- "components.switch.visibility": "Visibilité",
101
+ "components.switch.visible": "Visible",
102
+ "components.switch.visibleWithPeriod": "Visible.",
103
+ "components.switch.hidden": "Hidden",
104
+ "components.switch.conditions": "Conditions must be met",
102
105
  "components.tabs.next": "Faire défiler vers l'avant",
103
106
  "components.tabs.previous": "Faire défiler vers l'arrière",
104
107
  "components.tag-list.clear": "Cliquez sur l’élément, appuyez sur la touche Retour arrière ou sur la touche Suppr pour supprimer l’élément {value}",
package/lang/fr.js CHANGED
@@ -98,7 +98,10 @@ export default {
98
98
  "components.selection.select-all": "Tout sélectionner",
99
99
  "components.selection.select-all-items": "Sélectionner tous les {count} éléments",
100
100
  "components.selection.selected": "{count} sélectionné(s)",
101
- "components.switch.visibility": "Visibilité",
101
+ "components.switch.visible": "Visible",
102
+ "components.switch.visibleWithPeriod": "Visible.",
103
+ "components.switch.hidden": "Hidden",
104
+ "components.switch.conditions": "Conditions must be met",
102
105
  "components.tabs.next": "Défilement avant",
103
106
  "components.tabs.previous": "Défilement arrière",
104
107
  "components.tag-list.clear": "Cliquez sur le bouton, appuyez sur retour arrière ou appuyez sur la touche de suppression pour supprimer l’élément {value}",
package/lang/hi.js CHANGED
@@ -98,7 +98,10 @@ export default {
98
98
  "components.selection.select-all": "सभी का चयन करें",
99
99
  "components.selection.select-all-items": "सभी {count} आइटम चुनें।",
100
100
  "components.selection.selected": "{count} चयनित",
101
- "components.switch.visibility": "दृश्यता",
101
+ "components.switch.visible": "Visible",
102
+ "components.switch.visibleWithPeriod": "Visible.",
103
+ "components.switch.hidden": "Hidden",
104
+ "components.switch.conditions": "Conditions must be met",
102
105
  "components.tabs.next": "आगे स्क्रॉल करें",
103
106
  "components.tabs.previous": "पीछे स्क्रॉल करें",
104
107
  "components.tag-list.clear": "{value} को हटाने के लिए क्लिक करें, बैकस्पेस दबाएँ, या हटाएँ कुंजी को दबाएँ",
package/lang/ja.js CHANGED
@@ -98,7 +98,10 @@ export default {
98
98
  "components.selection.select-all": "すべて選択",
99
99
  "components.selection.select-all-items": "{count} 個の項目をすべて選択",
100
100
  "components.selection.selected": "{count} 個を選択済み",
101
- "components.switch.visibility": "表示",
101
+ "components.switch.visible": "Visible",
102
+ "components.switch.visibleWithPeriod": "Visible.",
103
+ "components.switch.hidden": "Hidden",
104
+ "components.switch.conditions": "Conditions must be met",
102
105
  "components.tabs.next": "前方にスクロール",
103
106
  "components.tabs.previous": "後方にスクロール",
104
107
  "components.tag-list.clear": "クリックする、Backspace キーを押す、または Delete キーを押すと項目 {value} が削除されます",
package/lang/ko.js CHANGED
@@ -98,7 +98,10 @@ export default {
98
98
  "components.selection.select-all": "모두 선택",
99
99
  "components.selection.select-all-items": "{count}개 항목을 모두 선택하십시오.",
100
100
  "components.selection.selected": "{count}개 선택됨",
101
- "components.switch.visibility": "표시여부",
101
+ "components.switch.visible": "Visible",
102
+ "components.switch.visibleWithPeriod": "Visible.",
103
+ "components.switch.hidden": "Hidden",
104
+ "components.switch.conditions": "Conditions must be met",
102
105
  "components.tabs.next": "앞으로 스크롤",
103
106
  "components.tabs.previous": "뒤로 스크롤",
104
107
  "components.tag-list.clear": "항목 {value}을(를) 제거하려면 클릭하거나, 백스페이스 또는 삭제 키를 누릅니다.",
package/lang/nl.js CHANGED
@@ -98,7 +98,10 @@ export default {
98
98
  "components.selection.select-all": "Alles selecteren",
99
99
  "components.selection.select-all-items": "Alle {count} records selecteren",
100
100
  "components.selection.selected": "{count} geselecteerd",
101
- "components.switch.visibility": "Zichtbaarheid",
101
+ "components.switch.visible": "Visible",
102
+ "components.switch.visibleWithPeriod": "Visible.",
103
+ "components.switch.hidden": "Hidden",
104
+ "components.switch.conditions": "Conditions must be met",
102
105
  "components.tabs.next": "Naar voren scrollen",
103
106
  "components.tabs.previous": "Naar achteren scrollen",
104
107
  "components.tag-list.clear": "Klik, druk op Backspace of druk op de Delete-toets om item {value} te verwijderen",
package/lang/pt.js CHANGED
@@ -98,7 +98,10 @@ export default {
98
98
  "components.selection.select-all": "Selecionar tudo",
99
99
  "components.selection.select-all-items": "Selecione todos os {count} itens",
100
100
  "components.selection.selected": "{count} selecionados",
101
- "components.switch.visibility": "Visibilidade",
101
+ "components.switch.visible": "Visible",
102
+ "components.switch.visibleWithPeriod": "Visible.",
103
+ "components.switch.hidden": "Hidden",
104
+ "components.switch.conditions": "Conditions must be met",
102
105
  "components.tabs.next": "Ir para frente",
103
106
  "components.tabs.previous": "Ir para trás",
104
107
  "components.tag-list.clear": "Clique em, pressione Backspace ou pressione a tecla Delete para remover o item {value}",
package/lang/sv.js CHANGED
@@ -98,7 +98,10 @@ export default {
98
98
  "components.selection.select-all": "Välj alla",
99
99
  "components.selection.select-all-items": "Välj alla {count} objekt",
100
100
  "components.selection.selected": "{count} valda",
101
- "components.switch.visibility": "Synlighet",
101
+ "components.switch.visible": "Visible",
102
+ "components.switch.visibleWithPeriod": "Visible.",
103
+ "components.switch.hidden": "Hidden",
104
+ "components.switch.conditions": "Conditions must be met",
102
105
  "components.tabs.next": "Bläddra framåt",
103
106
  "components.tabs.previous": "Bläddra bakåt",
104
107
  "components.tag-list.clear": "Klicka, tryck på backstegstangenten eller Delete-tangenten för att ta bort objektet {value}",
package/lang/tr.js CHANGED
@@ -98,7 +98,10 @@ export default {
98
98
  "components.selection.select-all": "Tümünü Seç",
99
99
  "components.selection.select-all-items": "{count} Öğenin Tamamını Seç",
100
100
  "components.selection.selected": "{count} öğe seçildi",
101
- "components.switch.visibility": "Görünürlük",
101
+ "components.switch.visible": "Visible",
102
+ "components.switch.visibleWithPeriod": "Visible.",
103
+ "components.switch.hidden": "Hidden",
104
+ "components.switch.conditions": "Conditions must be met",
102
105
  "components.tabs.next": "İleri Kaydır",
103
106
  "components.tabs.previous": "Geri Kaydır",
104
107
  "components.tag-list.clear": "Öğe {value} değerini kaldırmak için tıklatın, geri al tuşuna veya sil tuşuna basın",
package/lang/zh-cn.js CHANGED
@@ -98,7 +98,10 @@ export default {
98
98
  "components.selection.select-all": "全选",
99
99
  "components.selection.select-all-items": "选择全部 {count} 个项目",
100
100
  "components.selection.selected": "已选 {count}",
101
- "components.switch.visibility": "可见性",
101
+ "components.switch.visible": "Visible",
102
+ "components.switch.visibleWithPeriod": "Visible.",
103
+ "components.switch.hidden": "Hidden",
104
+ "components.switch.conditions": "Conditions must be met",
102
105
  "components.tabs.next": "向前滚动",
103
106
  "components.tabs.previous": "向后滚动",
104
107
  "components.tag-list.clear": "单击、按退格键或按 Delete 键以移除项目 {value}",
package/lang/zh-tw.js CHANGED
@@ -98,7 +98,10 @@ export default {
98
98
  "components.selection.select-all": "全選",
99
99
  "components.selection.select-all-items": "選取所有 {count} 個項目",
100
100
  "components.selection.selected": "已選取 {count} 個",
101
- "components.switch.visibility": "能見度",
101
+ "components.switch.visible": "Visible",
102
+ "components.switch.visibleWithPeriod": "Visible.",
103
+ "components.switch.hidden": "Hidden",
104
+ "components.switch.conditions": "Conditions must be met",
102
105
  "components.tabs.next": "向前捲動",
103
106
  "components.tabs.previous": "向後捲動",
104
107
  "components.tag-list.clear": "按一下、按下退格鍵或按下刪除鍵以移除項目 {value}",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "2.42.0",
3
+ "version": "2.43.1",
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",
@@ -44,7 +44,7 @@
44
44
  "license": "Apache-2.0",
45
45
  "devDependencies": {
46
46
  "@babel/eslint-parser": "^7",
47
- "@brightspace-ui/stylelint-config": "^0.6",
47
+ "@brightspace-ui/stylelint-config": "^0.7",
48
48
  "@open-wc/testing": "^3",
49
49
  "@web/dev-server": "^0.1",
50
50
  "@web/test-runner": "^0.14",