@brightspace-ui/labs 2.42.1 → 2.43.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.
package/package.json CHANGED
@@ -80,7 +80,7 @@
80
80
  "@rollup/plugin-node-resolve": "^16",
81
81
  "@rollup/plugin-replace": "^6",
82
82
  "@web/dev-server": "^0.4",
83
- "@web/rollup-plugin-html": "^2",
83
+ "@web/rollup-plugin-html": "^3",
84
84
  "eslint": "^9",
85
85
  "eslint-config-brightspace": "^2",
86
86
  "glob-all": "^3",
@@ -114,5 +114,5 @@
114
114
  "resize-observer-polyfill": "^1",
115
115
  "webvtt-parser": "^2"
116
116
  },
117
- "version": "2.42.1"
117
+ "version": "2.43.0"
118
118
  }
@@ -861,12 +861,7 @@ class MediaPlayer extends LocalizeLabsElement(RtlMixin(LitElement)) {
861
861
  min="0"
862
862
  max="${Math.floor(this._getSeekbarValue(this.duration))}"
863
863
  value="${this._getSeekbarValue(this._currentTime)}"
864
- aria-label="${this.localize('components:mediaPlayer:seekSlider')}"
865
- aria-orientation="horizontal"
866
- aria-valuemin="0"
867
- aria-valuemax="${Math.floor(this._getSeekbarValue(this.duration))}"
868
- aria-valuenow="${this._getSeekbarValue(this._currentTime)}"
869
- title="${this.localize('components:mediaPlayer:seekSlider')}"
864
+ label="${this.localize('components:mediaPlayer:seekSlider')}"
870
865
  @drag-start=${this._onDragStartSeek}
871
866
  @drag-end=${this._onDragEndSeek}
872
867
  @position-change=${this._onPositionChangeSeek}
@@ -895,11 +890,7 @@ class MediaPlayer extends LocalizeLabsElement(RtlMixin(LitElement)) {
895
890
  id="d2l-labs-media-player-volume-slider"
896
891
  vertical
897
892
  value="${Math.round(this._volume * 100)}"
898
- aria-label="${this.localize('components:mediaPlayer:volumeSlider')}"
899
- aria-orientation="vertical" aria-valuemin="0"
900
- aria-valuemax="100"
901
- aria-valuenow="${Math.floor(this._volume * 100)}"
902
- title="${this.localize('components:mediaPlayer:volumeSlider')}"
893
+ label="${this.localize('components:mediaPlayer:volumeSlider')}"
903
894
  @drag-start=${this._onDragStartVolume}
904
895
  @focus=${this._startUsingVolumeContainer}
905
896
  @focusout=${this._stopUsingVolumeContainer}
@@ -1,9 +1,10 @@
1
1
  import '@brightspace-ui/core/components/colors/colors.js';
2
2
  import { css, html, LitElement } from 'lit';
3
3
  import { LocalizeLabsElement } from '../localize-labs-element.js';
4
+ import { PropertyRequiredMixin } from '@brightspace-ui/core/mixins/property-required/property-required-mixin.js';
4
5
  import { RtlMixin } from '@brightspace-ui/core/mixins/rtl-mixin.js';
5
6
 
6
- class SliderBar extends LocalizeLabsElement(RtlMixin(LitElement)) {
7
+ class SliderBar extends PropertyRequiredMixin(LocalizeLabsElement(RtlMixin(LitElement))) {
7
8
 
8
9
  static get properties() {
9
10
  return {
@@ -15,7 +16,8 @@ class SliderBar extends LocalizeLabsElement(RtlMixin(LitElement)) {
15
16
  vertical: { type: Boolean },
16
17
  fullWidth: { type: Boolean },
17
18
  min: { type: Number },
18
- max: { type: Number }
19
+ max: { type: Number },
20
+ label: { type: String, required: true },
19
21
  };
20
22
  }
21
23
 
@@ -43,11 +45,11 @@ class SliderBar extends LocalizeLabsElement(RtlMixin(LitElement)) {
43
45
  display: block;
44
46
  }
45
47
 
46
- :host(:focus) {
48
+ :host(:focus-within) {
47
49
  outline: none;
48
50
  }
49
51
 
50
- :host(:focus) .slider-knob::after {
52
+ :host(:focus-within) .slider-knob::after {
51
53
  border-radius: 50%;
52
54
  bottom: 0;
53
55
  box-shadow: 0 0 0 var(--d2l-calculated-knob-focus-size) var(--d2l-calculated-knob-focus-color);
@@ -151,23 +153,37 @@ class SliderBar extends LocalizeLabsElement(RtlMixin(LitElement)) {
151
153
  this.fullWidth = false;
152
154
  this.min = 0;
153
155
  this.max = 100;
156
+ this.#mouseUpBound = this._barUp.bind(this);
157
+ this.#mouseMoveBound = this._onTrack.bind(this);
154
158
  }
155
159
 
156
160
  connectedCallback() {
157
161
  super.connectedCallback();
158
- window.addEventListener('mouseup', () => { this._barUp(); });
159
- window.addEventListener('mousemove', (event) => { this._onTrack(event); });
162
+ window.addEventListener('mouseup', this.#mouseUpBound);
163
+ window.addEventListener('mousemove', this.#mouseMoveBound);
160
164
  }
161
165
 
162
166
  disconnectedCallback() {
163
167
  super.disconnectedCallback();
164
- window.removeEventListener('mouseup', () => { this._barUp(); });
165
- window.removeEventListener('mousemove', (event) => { this._onTrack(event); });
168
+ window.removeEventListener('mouseup', this.#mouseUpBound);
169
+ window.removeEventListener('mousemove', this.#mouseMoveBound);
166
170
  }
167
171
 
168
172
  render() {
173
+ const currentValue = this.dragging
174
+ ? this.immediateValue
175
+ : (this.value ?? this.immediateValue);
176
+ const ariaValueNow = Math.floor(currentValue || 0);
169
177
  return html`
170
178
  <div id="sliderContainer"
179
+ role="slider"
180
+ tabindex="0"
181
+ aria-label="${this.label}"
182
+ aria-orientation="${this.vertical ? 'vertical' : 'horizontal'}"
183
+ aria-valuemin="${String(this.min)}"
184
+ aria-valuemax="${String(this.max)}"
185
+ aria-valuenow="${String(ariaValueNow)}"
186
+ @keydown=${this._onKeyDown}
171
187
  @mouseover="${this._onHostHover}"
172
188
  @mousemove="${this._onHostMove}"
173
189
  @mouseout="${this._onHostUnhover}"
@@ -177,14 +193,6 @@ class SliderBar extends LocalizeLabsElement(RtlMixin(LitElement)) {
177
193
  <div
178
194
  id="sliderBar"
179
195
  @mousedown="${this._barDown}"
180
- @keydown="${this._onKeyPress}"
181
- tabindex="0"
182
- role="slider"
183
- aria-label="${this.localize('components:mediaPlayer:sliderBarProgress')}"
184
- aria-orientation="${this.vertical ? 'vertical' : 'horizontal'}"
185
- aria-valuemin="${this.min}"
186
- aria-valuemax="${this.max}"
187
- aria-valuenow="${this.immediateValue ? this.immediateValue : 0}"
188
196
  >
189
197
  <div id="progressContainer">
190
198
  <div id="primaryProgress"></div>
@@ -223,6 +231,9 @@ class SliderBar extends LocalizeLabsElement(RtlMixin(LitElement)) {
223
231
  }
224
232
  }
225
233
 
234
+ #mouseUpBound;
235
+ #mouseMoveBound;
236
+
226
237
  _barDown(event) {
227
238
  const knobContainer = this.shadowRoot.getElementById('knobContainer');
228
239
  this._w = knobContainer.offsetWidth;
@@ -239,7 +250,7 @@ class SliderBar extends LocalizeLabsElement(RtlMixin(LitElement)) {
239
250
  this._positionKnob(ratio);
240
251
 
241
252
  event.preventDefault();
242
- this.shadowRoot.getElementById('sliderKnob').focus();
253
+ this.shadowRoot.getElementById('sliderContainer')?.focus();
243
254
  }
244
255
 
245
256
  _barUp() {
@@ -321,7 +332,7 @@ class SliderBar extends LocalizeLabsElement(RtlMixin(LitElement)) {
321
332
  this.removeEventListener('mousemove', this._onTrack);
322
333
  }
323
334
 
324
- _onKeyPress(event) {
335
+ _onKeyDown(event) {
325
336
  if (this.vertical) {
326
337
  this._checkKey(event, 'ArrowUp', 5);
327
338
  this._checkKey(event, 'ArrowDown', -5);