@brightspace-ui/core 2.86.3 → 2.86.5

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.
@@ -20,38 +20,12 @@ export const ListItemButtonMixin = superclass => class extends ListItemMixin(sup
20
20
  :host(:not([button-disabled])) {
21
21
  --d2l-list-item-content-text-color: var(--d2l-color-celestine);
22
22
  }
23
- :host([button-disabled][_hovering-primary-action]) .d2l-list-item-content,
24
- :host([button-disabled][_focusing-primary-action]) .d2l-list-item-content {
25
- --d2l-list-item-content-text-color: unset;
26
- --d2l-list-item-content-text-decoration: none;
27
- }
28
- :host([button-disabled]) button {
29
- cursor: default;
23
+ :host([button-disabled]) [slot="content-action"] {
24
+ pointer-events: none;
30
25
  }
31
26
  [slot="outside-control-container"] {
32
27
  margin: 0 -12px;
33
28
  }
34
- :host(:not([selectable]):not([button-disabled]):not([skeleton])[_hovering]) [slot="control-container"]::before,
35
- :host(:not([selectable]):not([button-disabled]):not([skeleton])[_hovering]) [slot="control-container"]::after,
36
- :host(:not([selectable]):not([button-disabled]):not([skeleton])[_focusing]) [slot="control-container"]::before,
37
- :host(:not([selectable]):not([button-disabled]):not([skeleton])[_focusing]) [slot="control-container"]::after,
38
- :host([selectable]:not([selection-disabled][button-disabled]):not([skeleton])[_hovering]) [slot="control-container"]::before,
39
- :host([selectable]:not([selection-disabled][button-disabled]):not([skeleton])[_hovering]) [slot="control-container"]::after,
40
- :host([selectable]:not([selection-disabled][button-disabled]):not([skeleton])[_focusing]) [slot="control-container"]::before,
41
- :host([selectable]:not([selection-disabled][button-disabled]):not([skeleton])[_focusing]) [slot="control-container"]::after {
42
- border-top-color: transparent;
43
- }
44
- :host(:not([selectable]):not([button-disabled]):not([skeleton])[_hovering]) [slot="outside-control-container"],
45
- :host(:not([selectable]):not([button-disabled]):not([skeleton])[_focusing]) [slot="outside-control-container"],
46
- :host([selectable]:not([selection-disabled][button-disabled]):not([skeleton])[_hovering]) [slot="outside-control-container"],
47
- :host([selectable]:not([selection-disabled][button-disabled]):not([skeleton])[_focusing]) [slot="outside-control-container"] {
48
- background-color: white;
49
- border-color: #b6cbe8; /* celestine alpha 0.3 */
50
- }
51
- :host([selectable]:not([selection-disabled][button-disabled]):not([skeleton])[_hovering]) [slot="outside-control-container"],
52
- :host(:not([selectable]):not([button-disabled]):not([skeleton])[_hovering]) [slot="outside-control-container"] {
53
- box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
54
- }
55
29
  button {
56
30
  background-color: transparent;
57
31
  border: none;
@@ -61,11 +35,6 @@ export const ListItemButtonMixin = superclass => class extends ListItemMixin(sup
61
35
  outline: none;
62
36
  width: 100%;
63
37
  }
64
- /* simply hide the button action layer rather than disabling button so
65
- that the cursor pointer ins't displayed when hovering skeleton */
66
- :host([skeleton]) button {
67
- display: none;
68
- }
69
38
  ` ];
70
39
 
71
40
  super.styles && styles.unshift(super.styles);
@@ -78,6 +47,11 @@ export const ListItemButtonMixin = superclass => class extends ListItemMixin(sup
78
47
  this.buttonDisabled = false;
79
48
  }
80
49
 
50
+ willUpdate(changedProperties) {
51
+ super.willUpdate(changedProperties);
52
+ if (changedProperties.has('buttonDisabled') && this.buttonDisabled === true) this._hoveringPrimaryAction = false;
53
+ }
54
+
81
55
  _onButtonClick() {
82
56
  /** Dispatched when the item's primary button action is clicked */
83
57
  this.dispatchEvent(new CustomEvent('d2l-list-item-button-click', { bubbles: true }));
@@ -1,6 +1,5 @@
1
1
  import '../selection/selection-input.js';
2
2
  import { css, html, nothing } from 'lit';
3
- import { classMap } from 'lit/directives/class-map.js';
4
3
  import { getUniqueId } from '../../helpers/uniqueId.js';
5
4
  import { SelectionInfo } from '../selection/selection-mixin.js';
6
5
  import { SkeletonMixin } from '../skeleton/skeleton-mixin.js';
@@ -33,7 +32,8 @@ export const ListItemCheckboxMixin = superclass => class extends SkeletonMixin(s
33
32
  * Private. The selection info (set by the selection component).
34
33
  * @ignore
35
34
  */
36
- selectionInfo: { type: Object, attribute: false }
35
+ selectionInfo: { type: Object, attribute: false },
36
+ _hoveringSelection: { type: Boolean, attribute: '_hovering-selection', reflect: true }
37
37
  };
38
38
  }
39
39
 
@@ -44,7 +44,7 @@ export const ListItemCheckboxMixin = superclass => class extends SkeletonMixin(s
44
44
  display: block;
45
45
  height: 100%;
46
46
  }
47
- .d2l-checkbox-action.d2l-checkbox-action-disabled {
47
+ :host([selection-disabled]) .d2l-checkbox-action {
48
48
  cursor: default;
49
49
  }
50
50
  ` ];
@@ -95,6 +95,11 @@ export const ListItemCheckboxMixin = superclass => class extends SkeletonMixin(s
95
95
  if (!suppressEvent) this._dispatchSelected(selected);
96
96
  }
97
97
 
98
+ willUpdate(changedProperties) {
99
+ super.willUpdate(changedProperties);
100
+ if (changedProperties.has('selectionDisabled') && this.selectionDisabled === true) this._hoveringSelection = false;
101
+ }
102
+
98
103
  async _dispatchSelected(value) {
99
104
  /* wait for internal state to be updated in case of action-click case so that a consumer
100
105
  calling getSelectionInfo will get the correct state */
@@ -124,6 +129,20 @@ export const ListItemCheckboxMixin = superclass => class extends SkeletonMixin(s
124
129
  }
125
130
  }
126
131
 
132
+ _onCheckboxKeyDown(e) {
133
+ // handle the enter key
134
+ if (e.keyCode !== 13) return;
135
+ this.selected = !this.selected;
136
+ }
137
+
138
+ _onMouseEnterSelection() {
139
+ this._hoveringSelection = !this.selectionDisabled;
140
+ }
141
+
142
+ _onMouseLeaveSelection() {
143
+ this._hoveringSelection = false;
144
+ }
145
+
127
146
  _onNestedSlotChangeCheckboxMixin() {
128
147
  this._updateNestedSelectionProvider();
129
148
  }
@@ -137,26 +156,25 @@ export const ListItemCheckboxMixin = superclass => class extends SkeletonMixin(s
137
156
  return this.selectable ? html`
138
157
  <d2l-selection-input
139
158
  @d2l-selection-change="${this._onCheckboxChange}"
140
- ?selected="${this.selected}"
141
159
  ?disabled="${this.selectionDisabled}"
160
+ .hovering="${this._hoveringSelection}"
142
161
  id="${this._checkboxId}"
143
162
  ?_indeterminate="${this.selectionInfo.state === SelectionInfo.states.some}"
144
163
  key="${this.key}"
164
+ @keydown="${this._onCheckboxKeyDown}"
145
165
  label="${this.label}"
146
- ?skeleton="${this.skeleton}"
147
- .hovering="${this._hovering}">
166
+ ?selected="${this.selected}"
167
+ ?skeleton="${this.skeleton}">
148
168
  </d2l-selection-input>
149
169
  ` : nothing;
150
170
  }
151
171
 
152
172
  _renderCheckboxAction(inner) {
153
- const classes = {
154
- 'd2l-checkbox-action': true,
155
- 'd2l-checkbox-action-disabled': this.selectionDisabled
156
- };
157
173
  return this.selectable ? html`
158
- <div @click="${this._onCheckboxActionClick}"
159
- class="${classMap(classes)}">
174
+ <div class="d2l-checkbox-action"
175
+ @click="${this._onCheckboxActionClick}"
176
+ @mouseenter="${this._onMouseEnterSelection}"
177
+ @mouseleave="${this._onMouseLeaveSelection}">
160
178
  ${inner}
161
179
  </div>
162
180
  ` : nothing;
@@ -445,16 +445,10 @@ class ListItemGenericLayout extends RtlMixin(LitElement) {
445
445
 
446
446
  _onKeydown(event) {
447
447
  if (!this.gridActive) return;
448
+
448
449
  let node = null;
449
450
  let preventDefault = true;
450
451
  switch (event.keyCode) {
451
- case keyCodes.ENTER:
452
- case keyCodes.SPACE:
453
- node = getComposedActiveElement();
454
- node.click();
455
- // mouseup event is necessary for components like d2l-dropdown-more that control state by listening to this event
456
- node.dispatchEvent(new MouseEvent('mouseup', { composed: true }));
457
- break;
458
452
  case keyCodes.RIGHT:
459
453
  node = getComposedActiveElement();
460
454
  if (this.dir === 'rtl') {
@@ -21,29 +21,12 @@ export const ListItemLinkMixin = superclass => class extends ListItemMixin(super
21
21
  :host([action-href]:not([action-href=""])) {
22
22
  --d2l-list-item-content-text-color: var(--d2l-color-celestine);
23
23
  }
24
- :host([action-href]:not([action-href=""])[_hovering]) [slot="control-container"]::before,
25
- :host([action-href]:not([action-href=""])[_hovering]) [slot="control-container"]::after,
26
- :host([action-href]:not([action-href=""])[_focusing]) [slot="control-container"]::before,
27
- :host([action-href]:not([action-href=""])[_focusing]) [slot="control-container"]::after {
28
- border-top-color: transparent;
29
- }
30
- :host(:not([skeleton])[action-href]:not([action-href=""])[_hovering]) [slot="outside-control-container"],
31
- :host(:not([skeleton])[action-href]:not([action-href=""])[_focusing]) [slot="outside-control-container"] {
32
- background-color: white;
33
- border-color: #b6cbe8; /* celestine alpha 0.3 */
34
- }
35
- :host(:not([skeleton])[action-href]:not([action-href=""])[_hovering]) [slot="outside-control-container"] {
36
- box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
37
- }
38
24
  a[href] {
39
25
  display: block;
40
26
  height: 100%;
41
27
  outline: none;
42
28
  width: 100%;
43
29
  }
44
- :host([skeleton]) a {
45
- display: none;
46
- }
47
30
  ` ];
48
31
 
49
32
  super.styles && styles.unshift(super.styles);
@@ -56,14 +39,31 @@ export const ListItemLinkMixin = superclass => class extends ListItemMixin(super
56
39
  this._primaryActionId = getUniqueId();
57
40
  }
58
41
 
42
+ willUpdate(changedProperties) {
43
+ super.willUpdate(changedProperties);
44
+ if (changedProperties.has('actionHref') && !this.actionHref) this._hoveringPrimaryAction = false;
45
+ }
46
+
59
47
  _handleLinkClick() {
60
48
  /** Dispatched when the item's primary link action is clicked */
61
49
  this.dispatchEvent(new CustomEvent('d2l-list-item-link-click', { bubbles: true }));
62
50
  }
63
51
 
52
+ _handleLinkKeyDown(e) {
53
+ if (e.keyCode !== 32) return;
54
+ // handle the space key
55
+ e.preventDefault();
56
+ e.stopPropagation();
57
+ this.shadowRoot.querySelector(`#${this._primaryActionId}`).click();
58
+ }
59
+
64
60
  _renderPrimaryAction(labelledBy) {
65
61
  if (!this.actionHref) return;
66
- return html`<a id="${this._primaryActionId}" aria-labelledby="${labelledBy}" href="${this.actionHref}" @click="${this._handleLinkClick}"></a>`;
62
+ return html`<a aria-labelledby="${labelledBy}"
63
+ @click="${this._handleLinkClick}"
64
+ href="${this.actionHref}"
65
+ id="${this._primaryActionId}"
66
+ @keydown="${this._handleLinkKeyDown}"></a>`;
67
67
  }
68
68
 
69
69
  };
@@ -147,12 +147,16 @@ export const ListItemMixin = superclass => class extends composeMixins(
147
147
  :host(:last-of-type[_separators="between"]) [slot="control-container"]::after,
148
148
  :host([_separators="none"]) [slot="control-container"]::before,
149
149
  :host([_separators="none"]) [slot="control-container"]::after,
150
- :host([selectable][_hovering]:not([selection-disabled])) [slot="control-container"]::before,
151
- :host([selectable][_hovering]:not([selection-disabled])) [slot="control-container"]::after,
150
+ :host([_hovering-selection]) [slot="control-container"]::before,
151
+ :host([_hovering-selection]) [slot="control-container"]::after,
152
+ :host([_hovering-primary-action]) [slot="control-container"]::before,
153
+ :host([_hovering-primary-action]) [slot="control-container"]::after,
152
154
  :host([selectable][_focusing]) [slot="control-container"]::before,
153
155
  :host([selectable][_focusing]) [slot="control-container"]::after,
154
- :host([selected]) [slot="control-container"]::before,
155
- :host([selected]) [slot="control-container"]::after,
156
+ :host([_focusing-primary-action]) [slot="control-container"]::before,
157
+ :host([_focusing-primary-action]) [slot="control-container"]::after,
158
+ :host([selected]:not([selection-disabled]):not([skeleton])) [slot="control-container"]::before,
159
+ :host([selected]:not([selection-disabled]):not([skeleton])) [slot="control-container"]::after,
156
160
  :host(:first-of-type[_nested]) [slot="control-container"]::before {
157
161
  border-top-color: transparent;
158
162
  }
@@ -317,17 +321,21 @@ export const ListItemMixin = superclass => class extends composeMixins(
317
321
  margin: 0;
318
322
  }
319
323
 
320
- :host(:not([selection-disabled]):not([skeleton])[selected]) [slot="outside-control-container"],
321
- :host(:not([selection-disabled]):not([skeleton])[selectable][_hovering]) [slot="outside-control-container"],
324
+ :host([_hovering-primary-action]) [slot="outside-control-container"],
325
+ :host([_hovering-selection]) [slot="outside-control-container"],
326
+ :host([_focusing-primary-action]) [slot="outside-control-container"],
327
+ :host(:not([selection-disabled]):not([skeleton])[selected][_hovering-selection]) [slot="outside-control-container"],
322
328
  :host(:not([selection-disabled]):not([skeleton])[selectable][_focusing]) [slot="outside-control-container"] {
323
329
  background-color: white;
324
330
  border-color: #b6cbe8; /* celestine alpha 0.3 */
325
331
  }
326
- :host(:not([selection-disabled]):not([skeleton])[selectable][_hovering]) [slot="outside-control-container"] {
332
+ :host([_hovering-primary-action]) [slot="outside-control-container"],
333
+ :host([_hovering-selection]) [slot="outside-control-container"] {
327
334
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
328
335
  }
329
336
  :host(:not([selection-disabled]):not([skeleton])[selected]) [slot="outside-control-container"] {
330
337
  background-color: #f3fbff;
338
+ border-color: #b6cbe8; /* celestine alpha 0.3 */
331
339
  }
332
340
 
333
341
  :host(:not([selection-disabled]):not([skeleton])[padding-type="none"]) [slot="outside-control-container"] {
@@ -343,7 +351,7 @@ export const ListItemMixin = superclass => class extends composeMixins(
343
351
  transition: border-color 400ms linear;
344
352
  }
345
353
  :host([_highlighting]) [slot="outside-control-container"],
346
- :host(:not([selection-disabled]):not([skeleton])[_hovering][_highlighting]) [slot="outside-control-container"],
354
+ :host([_hovering-selection][_highlighting]) [slot="outside-control-container"],
347
355
  :host(:not([selection-disabled]):not([skeleton])[_focusing][_highlighting]) [slot="outside-control-container"],
348
356
  :host(:not([selection-disabled]):not([skeleton])[selected][_highlighting]) [slot="outside-control-container"] {
349
357
  background-color: var(--d2l-color-celestine-plus-2);
@@ -363,6 +371,9 @@ export const ListItemMixin = superclass => class extends composeMixins(
363
371
  .d2l-list-item-tooltip-key {
364
372
  font-weight: 700;
365
373
  }
374
+ :host([skeleton]) {
375
+ pointer-events: none;
376
+ }
366
377
  `];
367
378
 
368
379
  super.styles && styles.unshift(super.styles);
@@ -632,7 +643,8 @@ export const ListItemMixin = superclass => class extends composeMixins(
632
643
  ${this._renderExpandCollapse()}
633
644
  </div>
634
645
  ${this.selectable ? html`<div slot="control">${this._renderCheckbox()}</div>` : nothing}
635
- ${this.selectable || this.expandable ? html`<div slot="control-action"
646
+ ${this.selectable || this.expandable ? html`
647
+ <div slot="control-action"
636
648
  @mouseenter="${this._onMouseEnter}"
637
649
  @mouseleave="${this._onMouseLeave}">
638
650
  ${this._renderCheckboxAction('')}
@@ -8181,11 +8181,6 @@
8181
8181
  "default": "false"
8182
8182
  }
8183
8183
  ],
8184
- "events": [
8185
- {
8186
- "name": "mouseup"
8187
- }
8188
- ],
8189
8184
  "slots": [
8190
8185
  {
8191
8186
  "name": "outside-control",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "2.86.3",
3
+ "version": "2.86.5",
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",