@brightspace-ui/core 2.119.0 → 2.120.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.
@@ -135,6 +135,7 @@ The `d2l-list` is the container to create a styled list of items using `d2l-list
135
135
  |---|---|---|
136
136
  | `drag-multiple` | Boolean | Whether the user can drag multiple items |
137
137
  | `grid` | Boolean | Enables keyboard grid for supported list items. See [Accessibility](#accessibility). |
138
+ | `label` | String | 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. |
138
139
  | `selection-single` | Boolean | Whether to render with single selection behaviour. If `selection-single` is specified, the list-items will render with radios instead of checkboxes, and the list component will maintain a single selected item. |
139
140
  | `separators` | String | Display separators (`all` (default), `between`, `none`) |
140
141
  | `extend-separators` | Boolean | Whether to extend the separators beyond the content's edge |
@@ -1,6 +1,7 @@
1
1
  import { css, html, LitElement } from 'lit';
2
2
  import { getNextFocusable, getPreviousFocusable } from '../../helpers/focus.js';
3
3
  import { SelectionInfo, SelectionMixin } from '../selection/selection-mixin.js';
4
+ import { ifDefined } from 'lit/directives/if-defined.js';
4
5
  import { PageableMixin } from '../paging/pageable-mixin.js';
5
6
  import { SubscriberRegistryController } from '../../controllers/subscriber/subscriberControllers.js';
6
7
 
@@ -36,6 +37,11 @@ class List extends PageableMixin(SelectionMixin(LitElement)) {
36
37
  * @type {boolean}
37
38
  */
38
39
  grid: { type: Boolean },
40
+ /**
41
+ * 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.
42
+ * @type {string}
43
+ */
44
+ label: { type: String },
39
45
  /**
40
46
  * Display separators. Valid values are "all" (default), "between", "none"
41
47
  * @type {'all'|'between'|'none'}
@@ -64,6 +70,7 @@ class List extends PageableMixin(SelectionMixin(LitElement)) {
64
70
  this.dragMultiple = false;
65
71
  this.extendSeparators = false;
66
72
  this.grid = false;
73
+ this.label = undefined;
67
74
  this._listItemChanges = [];
68
75
  this._childHasExpandCollapseToggle = false;
69
76
 
@@ -117,10 +124,11 @@ class List extends PageableMixin(SelectionMixin(LitElement)) {
117
124
 
118
125
  render() {
119
126
  const role = !this.grid ? 'list' : 'application';
127
+ const ariaLabel = this.slot !== 'nested' ? this.label : undefined;
120
128
  return html`
121
129
  <slot name="controls"></slot>
122
130
  <slot name="header"></slot>
123
- <div role="${role}">
131
+ <div role="${role}" aria-label="${ifDefined(ariaLabel)}">
124
132
  <slot @keydown="${this._handleKeyDown}" @slotchange="${this._handleSlotChange}"></slot>
125
133
  </div>
126
134
  ${this._renderPagerContainer()}
@@ -90,10 +90,11 @@ export const OverflowGroupMixin = superclass => class extends LocalizeCoreElemen
90
90
 
91
91
  this._handleItemMutation = this._handleItemMutation.bind(this);
92
92
  this._handleResize = this._handleResize.bind(this);
93
+ this._itemObserver = new MutationObserver(this._handleItemMutation);
93
94
  this._resizeObserver = new ResizeObserver((entries) => requestAnimationFrame(() => this._handleResize(entries)));
94
95
 
95
96
  this._hasResized = false;
96
- this._isObserving = false;
97
+ this._isObservingResize = false;
97
98
  this._itemHeight = 0;
98
99
  this._mini = this.openerType === OPENER_TYPE.ICON;
99
100
  this._overflowContainerHidden = false;
@@ -109,8 +110,8 @@ export const OverflowGroupMixin = superclass => class extends LocalizeCoreElemen
109
110
  disconnectedCallback() {
110
111
  super.disconnectedCallback();
111
112
 
112
- if (this._isObserving) {
113
- this._isObserving = false;
113
+ if (this._isObservingResize) {
114
+ this._isObservingResize = false;
114
115
  this._resizeObserver.disconnect();
115
116
  }
116
117
  }
@@ -147,8 +148,8 @@ export const OverflowGroupMixin = superclass => class extends LocalizeCoreElemen
147
148
  update(changedProperties) {
148
149
  super.update(changedProperties);
149
150
 
150
- if (!this._isObserving) {
151
- this._isObserving = true;
151
+ if (!this._isObservingResize) {
152
+ this._isObservingResize = true;
152
153
  this._resizeObserver.observe(this.shadowRoot.querySelector('.d2l-overflow-group-container'));
153
154
  }
154
155
 
@@ -370,8 +371,7 @@ export const OverflowGroupMixin = superclass => class extends LocalizeCoreElemen
370
371
  await this._getItems();
371
372
 
372
373
  this._slotItems.forEach(item => {
373
- const observer = new MutationObserver(this._handleItemMutation);
374
- observer.observe(item, {
374
+ this._itemObserver.observe(item, {
375
375
  attributes: true, /* required for legacy-Edge, otherwise attributeFilter throws a syntax error */
376
376
  attributeFilter: ['disabled', 'text', 'selected'],
377
377
  childList: false,
@@ -387,4 +387,5 @@ export const OverflowGroupMixin = superclass => class extends LocalizeCoreElemen
387
387
  this.requestUpdate();
388
388
  });
389
389
  }
390
+
390
391
  };
@@ -8899,6 +8899,12 @@
8899
8899
  "type": "boolean",
8900
8900
  "default": "false"
8901
8901
  },
8902
+ {
8903
+ "name": "label",
8904
+ "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.",
8905
+ "type": "string",
8906
+ "default": "\"undefined\""
8907
+ },
8902
8908
  {
8903
8909
  "name": "item-count",
8904
8910
  "description": "Total number of items. If not specified, features like select-all-pages will be disabled.",
@@ -8945,6 +8951,13 @@
8945
8951
  "type": "boolean",
8946
8952
  "default": "false"
8947
8953
  },
8954
+ {
8955
+ "name": "label",
8956
+ "attribute": "label",
8957
+ "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.",
8958
+ "type": "string",
8959
+ "default": "\"undefined\""
8960
+ },
8948
8961
  {
8949
8962
  "name": "itemCount",
8950
8963
  "attribute": "item-count",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "2.119.0",
3
+ "version": "2.120.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",