@brightspace-ui/core 2.120.1 → 2.122.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.
@@ -189,6 +189,7 @@ The `d2l-filter-dimension-set` component is the main dimension type that will wo
189
189
 
190
190
  | Property | Type | Description |
191
191
  |---|---|---|
192
+ | `header-text` | String | A heading displayed above the list items. This is usually unnecessary, but can be used to emphasize or promote something specific about the list of items to help orient users. |
192
193
  | `introductory-text` | String | The introductory text to display at the top of the filter dropdown |
193
194
  | `key` | String, required | Unique identifier for the dimension |
194
195
  | `loading` | Boolean | Whether the values for this dimension are still loading and a loading spinner should be displayed |
@@ -57,11 +57,30 @@
57
57
  </template>
58
58
  </d2l-demo-snippet>
59
59
 
60
+ <h2>Single Set Dimension - Header Text</h2>
61
+ <d2l-demo-snippet>
62
+ <template>
63
+ <d2l-filter id="filter-single">
64
+ <d2l-filter-dimension-set key="course" introductory-text="Filter content by courses. Start typing any course name to explore." header-text="Skills Promoted at Your Company" text="Course" select-all>
65
+ <d2l-filter-dimension-set-value key="art" text="Art" count="12"></d2l-filter-dimension-set-value>
66
+ <d2l-filter-dimension-set-value key="astronomy" text="Astronomy" count="2" selected></d2l-filter-dimension-set-value>
67
+ <d2l-filter-dimension-set-value key="biology" text="Biology" count="15"></d2l-filter-dimension-set-value>
68
+ <d2l-filter-dimension-set-value key="chemistry" text="Chemistry" count="1"disabled></d2l-filter-dimension-set-value>
69
+ <d2l-filter-dimension-set-value key="drama" text="Drama" count="23" disabled></d2l-filter-dimension-set-value>
70
+ <d2l-filter-dimension-set-value key="english" text="English" count="100"></d2l-filter-dimension-set-value>
71
+ <d2l-filter-dimension-set-value key="physics" text="Physics" count="23"></d2l-filter-dimension-set-value>
72
+ <d2l-filter-dimension-set-value key="stats" text="Statistics" count="333"></d2l-filter-dimension-set-value>
73
+ <d2l-filter-dimension-set-value key="writerscraft" text="Writer's Craft" count="2211"></d2l-filter-dimension-set-value>
74
+ </d2l-filter-dimension-set>
75
+ </d2l-filter>
76
+ </template>
77
+ </d2l-demo-snippet>
78
+
60
79
  <h2>Multiple Dimensions</h2>
61
80
  <d2l-demo-snippet>
62
81
  <template>
63
82
  <d2l-filter>
64
- <d2l-filter-dimension-set key="course" introductory-text="Filter content by courses. Start typing any course name to explore." text="Course" select-all>
83
+ <d2l-filter-dimension-set key="course" introductory-text="Filter content by courses. Start typing any course name to explore." header-text="Skills Promoted at Your Company" text="Course" select-all>
65
84
  <d2l-filter-dimension-set-value key="art" text="Art" count="0"></d2l-filter-dimension-set-value>
66
85
  <d2l-filter-dimension-set-value key="astronomy" text="Astronomy" count="1" selected></d2l-filter-dimension-set-value>
67
86
  <d2l-filter-dimension-set-value key="biology" text="Biology" count="-12"></d2l-filter-dimension-set-value>
@@ -11,6 +11,11 @@ class FilterDimensionSet extends LitElement {
11
11
 
12
12
  static get properties() {
13
13
  return {
14
+ /**
15
+ * A heading displayed above the list items. This is usually unnecessary, but can be used to emphasize or promote something specific about the list of items to help orient users.
16
+ * @type {string}
17
+ */
18
+ headerText: { type: String, attribute: 'header-text' },
14
19
  /**
15
20
  * The introductory text to display at the top of the filter dropdown
16
21
  * @type {string}
@@ -56,6 +61,7 @@ class FilterDimensionSet extends LitElement {
56
61
 
57
62
  constructor() {
58
63
  super();
64
+ this.headerText = '';
59
65
  this.introductoryText = '';
60
66
  this.loading = false;
61
67
  this.searchType = 'automatic';
@@ -18,7 +18,7 @@ import '../menu/menu-item.js';
18
18
  import '../selection/selection-select-all.js';
19
19
  import '../selection/selection-summary.js';
20
20
 
21
- import { bodyCompactStyles, bodySmallStyles, bodyStandardStyles } from '../typography/styles.js';
21
+ import { bodyCompactStyles, bodySmallStyles, bodyStandardStyles, heading4Styles } from '../typography/styles.js';
22
22
  import { css, html, LitElement, nothing } from 'lit';
23
23
  import { announce } from '../../helpers/announce.js';
24
24
  import { classMap } from 'lit/directives/class-map.js';
@@ -69,7 +69,7 @@ class Filter extends FocusMixin(LocalizeCoreElement(RtlMixin(LitElement))) {
69
69
  }
70
70
 
71
71
  static get styles() {
72
- return [bodyCompactStyles, bodySmallStyles, bodyStandardStyles, offscreenStyles, css`
72
+ return [bodyCompactStyles, bodySmallStyles, bodyStandardStyles, heading4Styles, offscreenStyles, css`
73
73
  [slot="header"] {
74
74
  padding: 0.9rem 0.3rem;
75
75
  }
@@ -164,6 +164,13 @@ class Filter extends FocusMixin(LocalizeCoreElement(RtlMixin(LitElement))) {
164
164
  padding: 0.9rem;
165
165
  }
166
166
 
167
+ .list-header-text {
168
+ color: var(--d2l-color-ferrite);
169
+ margin: 0;
170
+ padding-bottom: 0.05rem;
171
+ padding-top: 0.65rem;
172
+ }
173
+
167
174
  .d2l-filter-dimension-info-message {
168
175
  color: var(--d2l-color-ferrite);
169
176
  text-align: center;
@@ -487,6 +494,17 @@ class Filter extends FocusMixin(LocalizeCoreElement(RtlMixin(LitElement))) {
487
494
  if (count === 0) return searchResults;
488
495
  }
489
496
 
497
+ let listHeader = nothing;
498
+ let listLabel = undefined;
499
+ if (dimension.headerText && dimension.searchValue === '') {
500
+ listHeader = html`
501
+ <d2l-list-item>
502
+ <h4 class="d2l-heading-4 list-header-text" aria-hidden="true">${dimension.headerText}</h4>
503
+ </d2l-list-item>
504
+ `;
505
+ listLabel = dimension.headerText;
506
+ }
507
+
490
508
  return html`
491
509
  ${searchResults}
492
510
  <d2l-list
@@ -494,8 +512,10 @@ class Filter extends FocusMixin(LocalizeCoreElement(RtlMixin(LitElement))) {
494
512
  @d2l-list-selection-change="${this._handleChangeSetDimension}"
495
513
  extend-separators
496
514
  grid
515
+ label="${ifDefined(listLabel)}"
497
516
  ?selection-single="${dimension.selectionSingle}"
498
517
  separators="between">
518
+ ${listHeader}
499
519
  ${dimension.values.map(item => html`
500
520
  <d2l-list-item
501
521
  ?selection-disabled="${item.disabled}"
@@ -739,8 +759,10 @@ class Filter extends FocusMixin(LocalizeCoreElement(RtlMixin(LitElement))) {
739
759
 
740
760
  switch (type) {
741
761
  case 'd2l-filter-dimension-set': {
762
+ info.headerText = dimension.headerText;
742
763
  info.introductoryText = dimension.introductoryText;
743
764
  info.searchType = dimension.searchType;
765
+ info.searchValue = '';
744
766
  info.selectionSingle = dimension.selectionSingle;
745
767
  if (dimension.selectAll && !dimension.selectionSingle) info.selectAllIdPrefix = SET_DIMENSION_ID_PREFIX;
746
768
  info.searchEmptyState = dimension.getSearchEmptyState();
@@ -70,7 +70,6 @@ class List extends PageableMixin(SelectionMixin(LitElement)) {
70
70
  this.dragMultiple = false;
71
71
  this.extendSeparators = false;
72
72
  this.grid = false;
73
- this.label = undefined;
74
73
  this._listItemChanges = [];
75
74
  this._childHasExpandCollapseToggle = false;
76
75
 
@@ -3766,6 +3766,12 @@
3766
3766
  "description": "REQUIRED: Unique key to represent this dimension in the filter",
3767
3767
  "type": "string"
3768
3768
  },
3769
+ {
3770
+ "name": "header-text",
3771
+ "description": "A heading displayed above the list items. This is usually unnecessary, but can be used to emphasize or promote something specific about the list of items to help orient users.",
3772
+ "type": "string",
3773
+ "default": "\"\""
3774
+ },
3769
3775
  {
3770
3776
  "name": "introductory-text",
3771
3777
  "description": "The introductory text to display at the top of the filter dropdown",
@@ -3816,6 +3822,13 @@
3816
3822
  "description": "REQUIRED: Unique key to represent this dimension in the filter",
3817
3823
  "type": "string"
3818
3824
  },
3825
+ {
3826
+ "name": "headerText",
3827
+ "attribute": "header-text",
3828
+ "description": "A heading displayed above the list items. This is usually unnecessary, but can be used to emphasize or promote something specific about the list of items to help orient users.",
3829
+ "type": "string",
3830
+ "default": "\"\""
3831
+ },
3819
3832
  {
3820
3833
  "name": "introductoryText",
3821
3834
  "attribute": "introductory-text",
@@ -8894,6 +8907,11 @@
8894
8907
  "path": "./components/list/list.js",
8895
8908
  "description": "A container for a styled list of items (\"d2l-list-item\"). It provides the appropriate \"list\" semantics as well as options for displaying separators, etc.",
8896
8909
  "attributes": [
8910
+ {
8911
+ "name": "label",
8912
+ "description": "Sets an accessible label. For use when the list context is unclear. This property is only valid on top-level lists and will have no effect on nested lists.",
8913
+ "type": "string"
8914
+ },
8897
8915
  {
8898
8916
  "name": "separators",
8899
8917
  "description": "Display separators. Valid values are \"all\" (default), \"between\", \"none\"",
@@ -8918,12 +8936,6 @@
8918
8936
  "type": "boolean",
8919
8937
  "default": "false"
8920
8938
  },
8921
- {
8922
- "name": "label",
8923
- "description": "Sets an accessible label. For use when the list context is unclear. This property is only valid on top-level lists and will have no effect on nested lists.",
8924
- "type": "string",
8925
- "default": "\"undefined\""
8926
- },
8927
8939
  {
8928
8940
  "name": "item-count",
8929
8941
  "description": "Total number of items. If not specified, features like select-all-pages will be disabled.",
@@ -8942,6 +8954,12 @@
8942
8954
  }
8943
8955
  ],
8944
8956
  "properties": [
8957
+ {
8958
+ "name": "label",
8959
+ "attribute": "label",
8960
+ "description": "Sets an accessible label. For use when the list context is unclear. This property is only valid on top-level lists and will have no effect on nested lists.",
8961
+ "type": "string"
8962
+ },
8945
8963
  {
8946
8964
  "name": "separators",
8947
8965
  "attribute": "separators",
@@ -8970,13 +8988,6 @@
8970
8988
  "type": "boolean",
8971
8989
  "default": "false"
8972
8990
  },
8973
- {
8974
- "name": "label",
8975
- "attribute": "label",
8976
- "description": "Sets an accessible label. For use when the list context is unclear. This property is only valid on top-level lists and will have no effect on nested lists.",
8977
- "type": "string",
8978
- "default": "\"undefined\""
8979
- },
8980
8991
  {
8981
8992
  "name": "itemCount",
8982
8993
  "attribute": "item-count",
@@ -43,12 +43,36 @@ class HtmlBlockMathRenderer {
43
43
 
44
44
  const context = JSON.parse(contextVal) || {};
45
45
 
46
- await typesetMath(elem, {
46
+ if (!elem.querySelector('math') && !(context.renderLatex && /\$\$|\\\(|\\\[|\\begin{|\\ref{|\\eqref{/.test(elem.innerHTML))) return elem;
47
+
48
+ const mathJaxConfig = {
47
49
  deferTypeset: true,
48
50
  renderLatex: context.renderLatex,
49
51
  outputScale: context.outputScale || 1,
50
52
  window: window
53
+ };
54
+
55
+ await loadMathJax(mathJaxConfig);
56
+
57
+ // MathJax 3 does not support newlines, but it does persist styles, so add custom styles to mimic a linebreak
58
+ // This work-around should be removed when linebreaks are natively supported.
59
+ // MathJax issue: https://github.com/mathjax/MathJax/issues/2312
60
+ // A duplicate that explains our exact issue: https://github.com/mathjax/MathJax/issues/2495
61
+ elem.querySelectorAll('mspace[linebreak="newline"]').forEach(elm => {
62
+ elm.style.display = 'block';
63
+ elm.style.height = '0.5rem';
51
64
  });
65
+
66
+ // If we're using deferred rendering, we need to create a document structure
67
+ // within the element so MathJax can appropriately process math.
68
+ if (!options.noDeferredRendering) elem.innerHTML = `<mjx-doc><mjx-head></mjx-head><mjx-body>${elem.innerHTML}</mjx-body></mjx-doc>`;
69
+
70
+ await window.MathJax.startup.promise;
71
+ window.D2L = window.D2L || {};
72
+
73
+ if (!window.D2L.renderingPromise) window.D2L.renderingPromise = Promise.resolve();
74
+ window.D2L.renderingPromise = window.D2L.renderingPromise.then(() => window.MathJax.typesetShadow(elem.getRootNode(), elem));
75
+ await window.D2L.renderingPromise;
52
76
  }
53
77
 
54
78
  }
@@ -214,38 +238,3 @@ export function loadMathJax(mathJaxConfig) {
214
238
  return win.D2L.mathJaxLoaded;
215
239
 
216
240
  }
217
-
218
- export async function typesetMath(elem, options) {
219
- if (!elem.querySelector('math') && !(options.renderLatex && /\$\$|\\\(|\\\[|\\begin{|\\ref{|\\eqref{/.test(elem.innerHTML))) return elem;
220
-
221
- const win = options.window;
222
-
223
- const mathJaxConfig = {
224
- deferTypeset: options.deferTypeset,
225
- renderLatex: options.renderLatex,
226
- outputScale: options.outputScale || 1,
227
- window: win
228
- };
229
-
230
- await loadMathJax(mathJaxConfig);
231
-
232
- // MathJax 3 does not support newlines, but it does persist styles, so add custom styles to mimic a linebreak
233
- // This work-around should be removed when linebreaks are natively supported.
234
- // MathJax issue: https://github.com/mathjax/MathJax/issues/2312
235
- // A duplicate that explains our exact issue: https://github.com/mathjax/MathJax/issues/2495
236
- elem.querySelectorAll('mspace[linebreak="newline"]').forEach(elm => {
237
- elm.style.display = 'block';
238
- elm.style.height = '0.5rem';
239
- });
240
-
241
- // If we're using deferred rendering, we need to create a document structure
242
- // within the element so MathJax can appropriately process math.
243
- if (!options.noDeferredRendering) elem.innerHTML = `<mjx-doc><mjx-head></mjx-head><mjx-body>${elem.innerHTML}</mjx-body></mjx-doc>`;
244
-
245
- await win.MathJax.startup.promise;
246
- win.D2L = win.D2L || {};
247
-
248
- if (!win.D2L.renderingPromise) win.D2L.renderingPromise = Promise.resolve();
249
- win.D2L.renderingPromise = win.D2L.renderingPromise.then(() => win.MathJax.typesetShadow(elem.getRootNode(), elem));
250
- await win.D2L.renderingPromise;
251
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "2.120.1",
3
+ "version": "2.122.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",